15 #define DEBUG_TYPE "reginfo"
46 #define GET_REGINFO_TARGET_DESC
47 #include "PPCGenRegisterInfo.inc"
53 cl::desc(
"Enable use of a base pointer for complex stack frames"));
57 cl::desc(
"Force the use of a base pointer in every function"));
62 ST.isPPC64() ? 0 : 1),
64 ImmToIdxMap[
PPC::LD] = PPC::LDX; ImmToIdxMap[PPC::STD] = PPC::STDX;
65 ImmToIdxMap[PPC::LBZ] = PPC::LBZX; ImmToIdxMap[PPC::STB] = PPC::STBX;
66 ImmToIdxMap[PPC::LHZ] = PPC::LHZX; ImmToIdxMap[PPC::LHA] = PPC::LHAX;
67 ImmToIdxMap[PPC::LWZ] = PPC::LWZX; ImmToIdxMap[PPC::LWA] = PPC::LWAX;
68 ImmToIdxMap[PPC::LFS] = PPC::LFSX; ImmToIdxMap[PPC::LFD] = PPC::LFDX;
69 ImmToIdxMap[PPC::STH] = PPC::STHX; ImmToIdxMap[PPC::STW] = PPC::STWX;
70 ImmToIdxMap[PPC::STFS] = PPC::STFSX; ImmToIdxMap[PPC::STFD] = PPC::STFDX;
71 ImmToIdxMap[PPC::ADDI] = PPC::ADD4;
72 ImmToIdxMap[PPC::LWA_32] = PPC::LWAX_32;
75 ImmToIdxMap[PPC::LHA8] = PPC::LHAX8; ImmToIdxMap[PPC::LBZ8] = PPC::LBZX8;
76 ImmToIdxMap[PPC::LHZ8] = PPC::LHZX8; ImmToIdxMap[PPC::LWZ8] = PPC::LWZX8;
77 ImmToIdxMap[PPC::STB8] = PPC::STBX8; ImmToIdxMap[PPC::STH8] = PPC::STHX8;
78 ImmToIdxMap[PPC::STW8] = PPC::STWX8; ImmToIdxMap[PPC::STDU] = PPC::STDUX;
79 ImmToIdxMap[PPC::ADDI8] = PPC::ADD8;
91 return &PPC::G8RC_NOX0RegClass;
92 return &PPC::GPRC_NOR0RegClass;
96 return &PPC::G8RCRegClass;
97 return &PPC::GPRCRegClass;
104 CSR_Darwin64_Altivec_SaveList :
105 CSR_Darwin64_SaveList) :
107 CSR_Darwin32_Altivec_SaveList :
108 CSR_Darwin32_SaveList);
111 CSR_SVR464_Altivec_SaveList :
112 CSR_SVR464_SaveList) :
114 CSR_SVR432_Altivec_SaveList :
115 CSR_SVR432_SaveList);
122 CSR_Darwin64_Altivec_RegMask :
123 CSR_Darwin64_RegMask) :
125 CSR_Darwin32_Altivec_RegMask :
126 CSR_Darwin32_RegMask);
129 CSR_SVR464_Altivec_RegMask :
130 CSR_SVR464_RegMask) :
132 CSR_SVR432_Altivec_RegMask :
138 return CSR_NoRegs_RegMask;
148 Reserved.
set(PPC::ZERO);
149 Reserved.
set(PPC::ZERO8);
153 Reserved.
set(PPC::FP);
154 Reserved.
set(PPC::FP8);
158 Reserved.
set(PPC::BP);
159 Reserved.
set(PPC::BP8);
163 Reserved.
set(PPC::CTR);
164 Reserved.
set(PPC::CTR8);
166 Reserved.
set(PPC::R1);
167 Reserved.
set(PPC::LR);
168 Reserved.
set(PPC::LR8);
172 Reserved.
set(PPC::VRSAVE);
177 Reserved.
set(PPC::R13);
182 Reserved.
set(PPC::R13);
184 Reserved.
set(PPC::X1);
185 Reserved.
set(PPC::X13);
188 Reserved.
set(PPC::X31);
191 Reserved.
set(PPC::X30);
195 Reserved.
set(PPC::X2);
200 Reserved.
set(PPC::R31);
203 Reserved.
set(PPC::R30);
208 IE = PPC::VRRCRegClass.end();
I !=
IE; ++
I)
218 const unsigned DefaultSafety = 1;
220 switch (RC->
getID()) {
223 case PPC::G8RC_NOX0RegClassID:
224 case PPC::GPRC_NOR0RegClassID:
225 case PPC::G8RCRegClassID:
226 case PPC::GPRCRegClassID: {
227 unsigned FP = TFI->
hasFP(MF) ? 1 : 0;
228 return 32 - FP - DefaultSafety;
230 case PPC::F8RCRegClassID:
231 case PPC::F4RCRegClassID:
232 case PPC::VRRCRegClassID:
233 return 32 - DefaultSafety;
234 case PPC::CRRCRegClassID:
235 return 8 - DefaultSafety;
262 bool LP64 = Subtarget.
isPPC64();
273 assert((maxCallFrameSize & (MaxAlign-1)) == 0 &&
274 "Maximum call-frame size not sufficiently aligned");
286 if (MaxAlign < TargetAlign &&
isInt<16>(FrameSize)) {
306 if (MaxAlign > TargetAlign) {
307 unsigned UnalNegSizeReg = NegSizeReg;
312 BuildMI(MBB, II, dl, TII.
get(PPC::LI8), NegSizeReg)
313 .addImm(~(MaxAlign-1));
315 unsigned NegSizeReg1 = NegSizeReg;
317 BuildMI(MBB, II, dl, TII.
get(PPC::AND8), NegSizeReg)
320 KillNegSizeReg =
true;
323 BuildMI(MBB, II, dl, TII.
get(PPC::STDUX), PPC::X1)
329 .
addImm(maxCallFrameSize);
331 if (MaxAlign > TargetAlign) {
332 unsigned UnalNegSizeReg = NegSizeReg;
338 .addImm(~(MaxAlign-1));
340 unsigned NegSizeReg1 = NegSizeReg;
345 KillNegSizeReg =
true;
348 BuildMI(MBB, II, dl, TII.
get(PPC::STWUX), PPC::R1)
354 .
addImm(maxCallFrameSize);
379 bool LP64 = Subtarget.
isPPC64();
393 if (SrcReg != PPC::CR0) {
398 BuildMI(MBB, II, dl, TII.
get(LP64 ? PPC::RLWINM8 : PPC::RLWINM),
Reg)
400 .
addImm(getEncodingValue(SrcReg) * 4)
423 bool LP64 = Subtarget.
isPPC64();
430 "RESTORE_CR does not define its destination");
437 if (DestReg != PPC::CR0) {
441 unsigned ShiftBits = getEncodingValue(DestReg)*4;
443 BuildMI(MBB, II, dl, TII.
get(LP64 ? PPC::RLWINM8 : PPC::RLWINM),
Reg)
448 BuildMI(MBB, II, dl, TII.
get(LP64 ? PPC::MTOCRF8 : PPC::MTOCRF), DestReg)
494 "RESTORE_VRSAVE does not define its destination");
499 BuildMI(MBB, II, dl, TII.
get(PPC::MTVRSAVEv), DestReg)
508 unsigned Reg,
int &FrameIdx)
const {
515 if (Subtarget.
isSVR4ABI() && PPC::CR2 <= Reg && Reg <= PPC::CR4) {
545 unsigned FIOperandNum) {
547 unsigned OffsetOperandNo = (FIOperandNum == 2) ? 1 : 2;
549 OffsetOperandNo = FIOperandNum-1;
551 return OffsetOperandNo;
556 int SPAdj,
unsigned FIOperandNum,
558 assert(SPAdj == 0 &&
"Unexpected");
585 if (FPSI && FrameIndex == FPSI &&
592 if (OpC == PPC::SPILL_CR) {
595 }
else if (OpC == PPC::RESTORE_CR) {
598 }
else if (OpC == PPC::SPILL_VRSAVE) {
601 }
else if (OpC == PPC::RESTORE_VRSAVE) {
639 "This should be handle in a target independent way");
640 if (!noImmForm &&
isInt<16>(Offset) && (!isIXAddr || (Offset & 3) == 0)) {
648 bool is64Bit = Subtarget.
isPPC64();
656 BuildMI(MBB, II, dl, TII.
get(is64Bit ? PPC::LIS8 : PPC::LIS), SRegHi)
657 .addImm(Offset >> 16);
658 BuildMI(MBB, II, dl, TII.
get(is64Bit ? PPC::ORI8 : PPC::ORI), SReg)
666 unsigned OperandBase;
671 assert(ImmToIdxMap.
count(OpC) &&
672 "No indexed form of load or store available!");
673 unsigned NewOpcode = ImmToIdxMap.
find(OpC)->second;
677 OperandBase = OffsetOperandNo;
689 return TFI->
hasFP(MF) ? PPC::R31 : PPC::R1;
691 return TFI->
hasFP(MF) ? PPC::X31 : PPC::X1;
698 return Subtarget.
isPPC64() ? PPC::X30 : PPC::R30;
724 bool requiresRealignment =
738 assert(Offset < 0 &&
"Local offset must be negative");
740 unsigned FIOperandNum = 0;
743 assert(FIOperandNum < MI->getNumOperands() &&
744 "Instr doesn't have FrameIndex operand!");
760 if (!ImmToIdxMap.
count(OpC))
764 if ((OpC == PPC::ADDI || OpC == PPC::ADDI8) &&
796 unsigned BaseReg,
int FrameIdx,
797 int64_t Offset)
const {
798 unsigned ADDriOpc = Subtarget.
isPPC64() ? PPC::ADDI8 : PPC::ADDI;
802 if (Ins != MBB->
end())
803 DL = Ins->getDebugLoc();
811 BuildMI(*MBB, Ins, DL, MCID, BaseReg)
817 unsigned BaseReg, int64_t Offset)
const {
820 unsigned FIOperandNum = 0;
824 "Instr doesn't have FrameIndex operand!");
834 int64_t Offset)
const {
unsigned getStackAlignment() const
const MachineFunction * getParent() const
instr_iterator erase(instr_iterator I)
void ChangeToRegister(unsigned Reg, bool isDef, bool isImp=false, bool isKill=false, bool isDead=false, bool isUndef=false, bool isDebug=false)
void eliminateFrameIndex(MachineBasicBlock::iterator II, int SPAdj, unsigned FIOperandNum, RegScavenger *RS=NULL) const
unsigned createVirtualRegister(const TargetRegisterClass *RegClass)
void materializeFrameBaseRegister(MachineBasicBlock *MBB, unsigned BaseReg, int FrameIdx, int64_t Offset) const
const uint32_t * getCallPreservedMask(CallingConv::ID CC) const
const_iterator begin(StringRef path)
Get begin iterator over path.
const Function * getFunction() const
void lowerVRSAVERestore(MachineBasicBlock::iterator II, unsigned FrameIndex) const
bool needsStackRealignment(const MachineFunction &MF) const
bool hasAttribute(unsigned Index, Attribute::AttrKind Kind) const
Return true if the attribute exists at the given index.
const MCPhysReg * iterator
LoopInfoBase< BlockT, LoopT > * LI
unsigned getMaxAlignment() const
uint64_t getStackSize() const
const HexagonInstrInfo * TII
virtual bool hasFP(const MachineFunction &MF) const =0
bool hasReservedSpillSlot(const MachineFunction &MF, unsigned Reg, int &FrameIdx) const
unsigned getFrameRegister(const MachineFunction &MF) const
static unsigned getOffsetONFromFION(const MachineInstr &MI, unsigned FIOperandNum)
Abstract Stack Frame Information.
BitVector getReservedRegs(const MachineFunction &MF) const
ID
LLVM Calling Convention Representation.
const MachineInstrBuilder & addImm(int64_t Val) const
unsigned getNumOperands() const
bool needsFrameBaseReg(MachineInstr *MI, int64_t Offset) const
bool definesRegister(unsigned Reg, const TargetRegisterInfo *TRI=NULL) const
bool isFI() const
isFI - Tests if this is a MO_FrameIndex operand.
void lowerVRSAVESpilling(MachineBasicBlock::iterator II, unsigned FrameIndex) const
void lowerCRRestore(MachineBasicBlock::iterator II, unsigned FrameIndex) const
int getFramePointerSaveIndex() const
const TargetRegisterClass * constrainRegClass(unsigned Reg, const TargetRegisterClass *RC, unsigned MinNumRegs=0)
unsigned getKillRegState(bool B)
void ChangeToImmediate(int64_t ImmVal)
const MachineBasicBlock * getParent() const
bundle_iterator< MachineInstr, instr_iterator > iterator
initializer< Ty > init(const Ty &Val)
unsigned getBaseRegister(const MachineFunction &MF) const
const MachineOperand & getOperand(unsigned i) const
virtual const TargetRegisterClass * getPointerRegClass(const MachineFunction &MF, unsigned Kind=0) const
bool count(const KeyT &Val) const
count - Return true if the specified key is in the map.
void resolveFrameIndex(MachineBasicBlock::iterator I, unsigned BaseReg, int64_t Offset) const
MachineInstrBuilder BuildMI(MachineFunction &MF, DebugLoc DL, const MCInstrDesc &MCID)
virtual const TargetFrameLowering * getFrameLowering() const
const MCInstrDesc & get(unsigned Opcode) const
int64_t getObjectOffset(int ObjectIdx) const
static const MachineInstrBuilder & addFrameReference(const MachineInstrBuilder &MIB, int FI, int Offset=0, bool mem=true)
void lowerDynamicAlloc(MachineBasicBlock::iterator II) const
virtual const TargetInstrInfo * getInstrInfo() const
bool isFrameOffsetLegal(const MachineInstr *MI, int64_t Offset) const
const uint32_t * getNoPreservedMask() const
unsigned getRegPressureLimit(const TargetRegisterClass *RC, MachineFunction &MF) const
void setDesc(const MCInstrDesc &tid)
static cl::opt< bool > AlwaysBasePointer("ppc-always-use-base-pointer", cl::Hidden, cl::init(false), cl::desc("Force the use of a base pointer in every function"))
static bool usesIXAddr(const MachineInstr &MI)
unsigned getMaxCallFrameSize() const
MachineFrameInfo * getFrameInfo()
unsigned determineFrameLayout(MachineFunction &MF, bool UpdateMF=true, bool UseEstimate=false) const
const MachineInstrBuilder & addFrameIndex(int Idx) const
PPCRegisterInfo(const PPCSubtarget &SubTarget)
AttributeSet getAttributes() const
Return the attribute list for this Function.
bool needsFP(const MachineFunction &MF) const
bool hasFnAttribute(Attribute::AttrKind Kind) const
Return true if the function has the attribute.
MachineRegisterInfo & getRegInfo()
DBG_VALUE - a mapping of the llvm.dbg.value intrinsic.
const TargetMachine & getTarget() const
bool canRealignStack(const MachineFunction &MF) const
bool isInt< 16 >(int64_t x)
void lowerCRSpilling(MachineBasicBlock::iterator II, unsigned FrameIndex) const
unsigned getReg() const
getReg - Returns the register number.
static cl::opt< bool > EnableBasePointer("ppc-use-base-pointer", cl::Hidden, cl::init(true), cl::desc("Enable use of a base pointer for complex stack frames"))
const TargetRegisterClass * getRegClass(const MCInstrDesc &TID, unsigned OpNum, const TargetRegisterInfo *TRI, const MachineFunction &MF) const
const MCRegisterInfo & MRI
int getCRSpillFrameIndex() const
iterator find(const KeyT &Val)
const MachineInstrBuilder & addReg(unsigned RegNo, unsigned flags=0, unsigned SubReg=0) const
const uint16_t * getCalleeSavedRegs(const MachineFunction *MF=0) const
Code Generation virtual methods...
bool hasBasePointer(const MachineFunction &MF) const
DebugLoc getDebugLoc() const