mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-12-28 06:27:16 +00:00
Added MRegisterInfo hook to re-materialize an instruction.
llvm-svn: 35205
This commit is contained in:
parent
b9cc0ade43
commit
41f4f032ee
@ -374,6 +374,13 @@ public:
|
|||||||
unsigned DestReg, unsigned SrcReg,
|
unsigned DestReg, unsigned SrcReg,
|
||||||
const TargetRegisterClass *RC) const = 0;
|
const TargetRegisterClass *RC) const = 0;
|
||||||
|
|
||||||
|
/// reMaterialize - Re-issue the specified 'original' instruction at the
|
||||||
|
/// specific location targeting a new destination register.
|
||||||
|
virtual void reMaterialize(MachineBasicBlock &MBB,
|
||||||
|
MachineBasicBlock::iterator MI,
|
||||||
|
unsigned DestReg,
|
||||||
|
const MachineInstr *Orig) const = 0;
|
||||||
|
|
||||||
/// foldMemoryOperand - Attempt to fold a load or store of the
|
/// foldMemoryOperand - Attempt to fold a load or store of the
|
||||||
/// specified stack slot into the specified machine instruction for
|
/// specified stack slot into the specified machine instruction for
|
||||||
/// the specified operand. If this is possible, a new instruction
|
/// the specified operand. If this is possible, a new instruction
|
||||||
|
@ -195,6 +195,38 @@ void ARMRegisterInfo::copyRegToReg(MachineBasicBlock &MBB,
|
|||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// emitLoadConstPool - Emits a load from constpool to materialize the
|
||||||
|
/// specified immediate.
|
||||||
|
static void emitLoadConstPool(MachineBasicBlock &MBB,
|
||||||
|
MachineBasicBlock::iterator &MBBI,
|
||||||
|
unsigned DestReg, int Val,
|
||||||
|
const TargetInstrInfo &TII, bool isThumb) {
|
||||||
|
MachineFunction &MF = *MBB.getParent();
|
||||||
|
MachineConstantPool *ConstantPool = MF.getConstantPool();
|
||||||
|
Constant *C = ConstantInt::get(Type::Int32Ty, Val);
|
||||||
|
unsigned Idx = ConstantPool->getConstantPoolIndex(C, 2);
|
||||||
|
if (isThumb)
|
||||||
|
BuildMI(MBB, MBBI, TII.get(ARM::tLDRcp), DestReg).addConstantPoolIndex(Idx);
|
||||||
|
else
|
||||||
|
BuildMI(MBB, MBBI, TII.get(ARM::LDRcp), DestReg).addConstantPoolIndex(Idx)
|
||||||
|
.addReg(0).addImm(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ARMRegisterInfo::reMaterialize(MachineBasicBlock &MBB,
|
||||||
|
MachineBasicBlock::iterator I,
|
||||||
|
unsigned DestReg,
|
||||||
|
const MachineInstr *Orig) const {
|
||||||
|
if (Orig->getOpcode() == ARM::MOVi2pieces) {
|
||||||
|
emitLoadConstPool(MBB, I, DestReg, Orig->getOperand(1).getImmedValue(),
|
||||||
|
TII, false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
MachineInstr *MI = Orig->clone();
|
||||||
|
MI->getOperand(0).setReg(DestReg);
|
||||||
|
MBB.insert(I, MI);
|
||||||
|
}
|
||||||
|
|
||||||
/// isLowRegister - Returns true if the register is low register r0-r7.
|
/// isLowRegister - Returns true if the register is low register r0-r7.
|
||||||
///
|
///
|
||||||
static bool isLowRegister(unsigned Reg) {
|
static bool isLowRegister(unsigned Reg) {
|
||||||
@ -410,19 +442,6 @@ static unsigned calcNumMI(int Opc, int ExtraOpc, unsigned Bytes,
|
|||||||
return NumMIs;
|
return NumMIs;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// emitLoadConstPool - Emits a load from constpool to materialize NumBytes
|
|
||||||
/// immediate.
|
|
||||||
static void emitLoadConstPool(MachineBasicBlock &MBB,
|
|
||||||
MachineBasicBlock::iterator &MBBI,
|
|
||||||
unsigned DestReg, int NumBytes,
|
|
||||||
const TargetInstrInfo &TII) {
|
|
||||||
MachineFunction &MF = *MBB.getParent();
|
|
||||||
MachineConstantPool *ConstantPool = MF.getConstantPool();
|
|
||||||
Constant *C = ConstantInt::get(Type::Int32Ty, NumBytes);
|
|
||||||
unsigned Idx = ConstantPool->getConstantPoolIndex(C, 2);
|
|
||||||
BuildMI(MBB, MBBI, TII.get(ARM::tLDRpci), DestReg).addConstantPoolIndex(Idx);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// emitThumbRegPlusImmInReg - Emits a series of instructions to materialize
|
/// emitThumbRegPlusImmInReg - Emits a series of instructions to materialize
|
||||||
/// a destreg = basereg + immediate in Thumb code. Materialize the immediate
|
/// a destreg = basereg + immediate in Thumb code. Materialize the immediate
|
||||||
/// in a register using mov / mvn sequences or load the immediate from a
|
/// in a register using mov / mvn sequences or load the immediate from a
|
||||||
@ -459,7 +478,7 @@ void emitThumbRegPlusImmInReg(MachineBasicBlock &MBB,
|
|||||||
BuildMI(MBB, MBBI, TII.get(ARM::tNEG), LdReg)
|
BuildMI(MBB, MBBI, TII.get(ARM::tNEG), LdReg)
|
||||||
.addReg(LdReg, false, false, true);
|
.addReg(LdReg, false, false, true);
|
||||||
} else
|
} else
|
||||||
emitLoadConstPool(MBB, MBBI, LdReg, NumBytes, TII);
|
emitLoadConstPool(MBB, MBBI, LdReg, NumBytes, TII, true);
|
||||||
|
|
||||||
// Emit add / sub.
|
// Emit add / sub.
|
||||||
int Opc = (isSub) ? ARM::tSUBrr : (isHigh ? ARM::tADDhirr : ARM::tADDrr);
|
int Opc = (isSub) ? ARM::tSUBrr : (isHigh ? ARM::tADDhirr : ARM::tADDrr);
|
||||||
@ -885,7 +904,7 @@ void ARMRegisterInfo::eliminateFrameIndex(MachineBasicBlock::iterator II,
|
|||||||
if (FrameReg == ARM::SP)
|
if (FrameReg == ARM::SP)
|
||||||
emitThumbRegPlusImmInReg(MBB, II, TmpReg, FrameReg,Offset,false,TII);
|
emitThumbRegPlusImmInReg(MBB, II, TmpReg, FrameReg,Offset,false,TII);
|
||||||
else {
|
else {
|
||||||
emitLoadConstPool(MBB, II, TmpReg, Offset, TII);
|
emitLoadConstPool(MBB, II, TmpReg, Offset, TII, true);
|
||||||
UseRR = true;
|
UseRR = true;
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
@ -920,7 +939,7 @@ void ARMRegisterInfo::eliminateFrameIndex(MachineBasicBlock::iterator II,
|
|||||||
if (FrameReg == ARM::SP)
|
if (FrameReg == ARM::SP)
|
||||||
emitThumbRegPlusImmInReg(MBB, II, TmpReg, FrameReg,Offset,false,TII);
|
emitThumbRegPlusImmInReg(MBB, II, TmpReg, FrameReg,Offset,false,TII);
|
||||||
else {
|
else {
|
||||||
emitLoadConstPool(MBB, II, TmpReg, Offset, TII);
|
emitLoadConstPool(MBB, II, TmpReg, Offset, TII, true);
|
||||||
UseRR = true;
|
UseRR = true;
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
|
@ -60,6 +60,9 @@ public:
|
|||||||
unsigned DestReg, unsigned SrcReg,
|
unsigned DestReg, unsigned SrcReg,
|
||||||
const TargetRegisterClass *RC) const;
|
const TargetRegisterClass *RC) const;
|
||||||
|
|
||||||
|
void reMaterialize(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI,
|
||||||
|
unsigned DestReg, const MachineInstr *Orig) const;
|
||||||
|
|
||||||
MachineInstr* foldMemoryOperand(MachineInstr* MI, unsigned OpNum,
|
MachineInstr* foldMemoryOperand(MachineInstr* MI, unsigned OpNum,
|
||||||
int FrameIndex) const;
|
int FrameIndex) const;
|
||||||
|
|
||||||
|
@ -155,6 +155,15 @@ void AlphaRegisterInfo::copyRegToReg(MachineBasicBlock &MBB,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AlphaRegisterInfo::reMaterialize(MachineBasicBlock &MBB,
|
||||||
|
MachineBasicBlock::iterator I,
|
||||||
|
unsigned DestReg,
|
||||||
|
const MachineInstr *Orig) const {
|
||||||
|
MachineInstr *MI = Orig->clone();
|
||||||
|
MI->getOperand(0).setReg(DestReg);
|
||||||
|
MBB.insert(I, MI);
|
||||||
|
}
|
||||||
|
|
||||||
const unsigned* AlphaRegisterInfo::getCalleeSavedRegs() const {
|
const unsigned* AlphaRegisterInfo::getCalleeSavedRegs() const {
|
||||||
static const unsigned CalleeSavedRegs[] = {
|
static const unsigned CalleeSavedRegs[] = {
|
||||||
Alpha::R9, Alpha::R10,
|
Alpha::R9, Alpha::R10,
|
||||||
|
@ -45,6 +45,9 @@ struct AlphaRegisterInfo : public AlphaGenRegisterInfo {
|
|||||||
unsigned DestReg, unsigned SrcReg,
|
unsigned DestReg, unsigned SrcReg,
|
||||||
const TargetRegisterClass *RC) const;
|
const TargetRegisterClass *RC) const;
|
||||||
|
|
||||||
|
void reMaterialize(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI,
|
||||||
|
unsigned DestReg, const MachineInstr *Orig) const;
|
||||||
|
|
||||||
const unsigned *getCalleeSavedRegs() const;
|
const unsigned *getCalleeSavedRegs() const;
|
||||||
|
|
||||||
const TargetRegisterClass* const* getCalleeSavedRegClasses() const;
|
const TargetRegisterClass* const* getCalleeSavedRegClasses() const;
|
||||||
|
@ -93,6 +93,15 @@ void IA64RegisterInfo::copyRegToReg(MachineBasicBlock &MBB,
|
|||||||
BuildMI(MBB, MI, TII.get(IA64::MOV), DestReg).addReg(SrcReg);
|
BuildMI(MBB, MI, TII.get(IA64::MOV), DestReg).addReg(SrcReg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void IA64RegisterInfo::reMaterialize(MachineBasicBlock &MBB,
|
||||||
|
MachineBasicBlock::iterator I,
|
||||||
|
unsigned DestReg,
|
||||||
|
const MachineInstr *Orig) const {
|
||||||
|
MachineInstr *MI = Orig->clone();
|
||||||
|
MI->getOperand(0).setReg(DestReg);
|
||||||
|
MBB.insert(I, MI);
|
||||||
|
}
|
||||||
|
|
||||||
const unsigned* IA64RegisterInfo::getCalleeSavedRegs() const {
|
const unsigned* IA64RegisterInfo::getCalleeSavedRegs() const {
|
||||||
static const unsigned CalleeSavedRegs[] = {
|
static const unsigned CalleeSavedRegs[] = {
|
||||||
IA64::r5, 0
|
IA64::r5, 0
|
||||||
|
@ -44,6 +44,9 @@ struct IA64RegisterInfo : public IA64GenRegisterInfo {
|
|||||||
unsigned DestReg, unsigned SrcReg,
|
unsigned DestReg, unsigned SrcReg,
|
||||||
const TargetRegisterClass *RC) const;
|
const TargetRegisterClass *RC) const;
|
||||||
|
|
||||||
|
void reMaterialize(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI,
|
||||||
|
unsigned DestReg, const MachineInstr *Orig) const;
|
||||||
|
|
||||||
const unsigned *getCalleeSavedRegs() const;
|
const unsigned *getCalleeSavedRegs() const;
|
||||||
|
|
||||||
const TargetRegisterClass* const* getCalleeSavedRegClasses() const;
|
const TargetRegisterClass* const* getCalleeSavedRegClasses() const;
|
||||||
|
@ -239,6 +239,15 @@ void PPCRegisterInfo::copyRegToReg(MachineBasicBlock &MBB,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PPCRegisterInfo::reMaterialize(MachineBasicBlock &MBB,
|
||||||
|
MachineBasicBlock::iterator I,
|
||||||
|
unsigned DestReg,
|
||||||
|
const MachineInstr *Orig) const {
|
||||||
|
MachineInstr *MI = Orig->clone();
|
||||||
|
MI->getOperand(0).setReg(DestReg);
|
||||||
|
MBB.insert(I, MI);
|
||||||
|
}
|
||||||
|
|
||||||
const unsigned* PPCRegisterInfo::getCalleeSavedRegs() const {
|
const unsigned* PPCRegisterInfo::getCalleeSavedRegs() const {
|
||||||
// 32-bit Darwin calling convention.
|
// 32-bit Darwin calling convention.
|
||||||
static const unsigned Darwin32_CalleeSavedRegs[] = {
|
static const unsigned Darwin32_CalleeSavedRegs[] = {
|
||||||
|
@ -49,6 +49,9 @@ public:
|
|||||||
unsigned DestReg, unsigned SrcReg,
|
unsigned DestReg, unsigned SrcReg,
|
||||||
const TargetRegisterClass *RC) const;
|
const TargetRegisterClass *RC) const;
|
||||||
|
|
||||||
|
void reMaterialize(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI,
|
||||||
|
unsigned DestReg, const MachineInstr *Orig) const;
|
||||||
|
|
||||||
/// foldMemoryOperand - PowerPC (like most RISC's) can only fold spills into
|
/// foldMemoryOperand - PowerPC (like most RISC's) can only fold spills into
|
||||||
/// copy instructions, turning them into load/store instructions.
|
/// copy instructions, turning them into load/store instructions.
|
||||||
virtual MachineInstr* foldMemoryOperand(MachineInstr* MI, unsigned OpNum,
|
virtual MachineInstr* foldMemoryOperand(MachineInstr* MI, unsigned OpNum,
|
||||||
|
@ -77,6 +77,15 @@ void SparcRegisterInfo::copyRegToReg(MachineBasicBlock &MBB,
|
|||||||
assert (0 && "Can't copy this register");
|
assert (0 && "Can't copy this register");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SparcRegisterInfo::reMaterialize(MachineBasicBlock &MBB,
|
||||||
|
MachineBasicBlock::iterator I,
|
||||||
|
unsigned DestReg,
|
||||||
|
const MachineInstr *Orig) const {
|
||||||
|
MachineInstr *MI = Orig->clone();
|
||||||
|
MI->getOperand(0).setReg(DestReg);
|
||||||
|
MBB.insert(I, MI);
|
||||||
|
}
|
||||||
|
|
||||||
MachineInstr *SparcRegisterInfo::foldMemoryOperand(MachineInstr* MI,
|
MachineInstr *SparcRegisterInfo::foldMemoryOperand(MachineInstr* MI,
|
||||||
unsigned OpNum,
|
unsigned OpNum,
|
||||||
int FI) const {
|
int FI) const {
|
||||||
|
@ -44,6 +44,9 @@ struct SparcRegisterInfo : public SparcGenRegisterInfo {
|
|||||||
unsigned DestReg, unsigned SrcReg,
|
unsigned DestReg, unsigned SrcReg,
|
||||||
const TargetRegisterClass *RC) const;
|
const TargetRegisterClass *RC) const;
|
||||||
|
|
||||||
|
void reMaterialize(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI,
|
||||||
|
unsigned DestReg, const MachineInstr *Orig) const;
|
||||||
|
|
||||||
virtual MachineInstr* foldMemoryOperand(MachineInstr* MI,
|
virtual MachineInstr* foldMemoryOperand(MachineInstr* MI,
|
||||||
unsigned OpNum,
|
unsigned OpNum,
|
||||||
int FrameIndex) const;
|
int FrameIndex) const;
|
||||||
|
@ -167,6 +167,16 @@ void X86RegisterInfo::copyRegToReg(MachineBasicBlock &MBB,
|
|||||||
BuildMI(MBB, MI, TII.get(Opc), DestReg).addReg(SrcReg);
|
BuildMI(MBB, MI, TII.get(Opc), DestReg).addReg(SrcReg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void X86RegisterInfo::reMaterialize(MachineBasicBlock &MBB,
|
||||||
|
MachineBasicBlock::iterator I,
|
||||||
|
unsigned DestReg,
|
||||||
|
const MachineInstr *Orig) const {
|
||||||
|
MachineInstr *MI = Orig->clone();
|
||||||
|
MI->getOperand(0).setReg(DestReg);
|
||||||
|
MBB.insert(I, MI);
|
||||||
|
}
|
||||||
|
|
||||||
static MachineInstr *FuseTwoAddrInst(unsigned Opcode, unsigned FrameIndex,
|
static MachineInstr *FuseTwoAddrInst(unsigned Opcode, unsigned FrameIndex,
|
||||||
MachineInstr *MI,
|
MachineInstr *MI,
|
||||||
const TargetInstrInfo &TII) {
|
const TargetInstrInfo &TII) {
|
||||||
|
@ -59,6 +59,9 @@ public:
|
|||||||
unsigned DestReg, unsigned SrcReg,
|
unsigned DestReg, unsigned SrcReg,
|
||||||
const TargetRegisterClass *RC) const;
|
const TargetRegisterClass *RC) const;
|
||||||
|
|
||||||
|
void reMaterialize(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI,
|
||||||
|
unsigned DestReg, const MachineInstr *Orig) const;
|
||||||
|
|
||||||
/// foldMemoryOperand - If this target supports it, fold a load or store of
|
/// foldMemoryOperand - If this target supports it, fold a load or store of
|
||||||
/// the specified stack slot into the specified machine instruction for the
|
/// the specified stack slot into the specified machine instruction for the
|
||||||
/// specified operand. If this is possible, the target should perform the
|
/// specified operand. If this is possible, the target should perform the
|
||||||
|
Loading…
Reference in New Issue
Block a user