35 static std::pair<unsigned, unsigned> getMFHiLoOpc(
unsigned Src) {
36 if (Mips::ACC64RegClass.contains(Src))
37 return std::make_pair((
unsigned)Mips::PseudoMFHI,
38 (
unsigned)Mips::PseudoMFLO);
40 if (Mips::ACC64DSPRegClass.contains(Src))
41 return std::make_pair((
unsigned)Mips::MFHI_DSP, (
unsigned)Mips::MFLO_DSP);
43 if (Mips::ACC128RegClass.contains(Src))
44 return std::make_pair((
unsigned)Mips::PseudoMFHI64,
45 (
unsigned)Mips::PseudoMFLO64);
47 return std::make_pair(0, 0);
62 unsigned MFLoOpc,
unsigned RegSize);
73 : MF(MF_),
MRI(MF.getRegInfo()) {}
75 bool ExpandPseudo::expand() {
76 bool Expanded =
false;
80 for (Iter
I = BB->begin(), End = BB->end();
I != End;)
81 Expanded |= expandInstr(*BB,
I++);
87 switch(I->getOpcode()) {
88 case Mips::LOAD_CCOND_DSP:
89 expandLoadCCond(MBB, I);
91 case Mips::STORE_CCOND_DSP:
92 expandStoreCCond(MBB, I);
94 case Mips::LOAD_ACC64:
95 case Mips::LOAD_ACC64DSP:
96 expandLoadACC(MBB, I, 4);
98 case Mips::LOAD_ACC128:
99 expandLoadACC(MBB, I, 8);
101 case Mips::STORE_ACC64:
102 expandStoreACC(MBB, I, Mips::PseudoMFHI, Mips::PseudoMFLO, 4);
104 case Mips::STORE_ACC64DSP:
105 expandStoreACC(MBB, I, Mips::MFHI_DSP, Mips::MFLO_DSP, 4);
107 case Mips::STORE_ACC128:
108 expandStoreACC(MBB, I, Mips::PseudoMFHI64, Mips::PseudoMFLO64, 8);
111 if (!expandCopy(MBB, I))
126 assert(I->getOperand(0).isReg() && I->getOperand(1).isFI());
134 unsigned VR =
MRI.createVirtualRegister(RC);
135 unsigned Dst = I->getOperand(0).getReg(), FI = I->getOperand(1).getIndex();
137 TII.loadRegFromStack(MBB, I, VR, FI, RC, &RegInfo, 0);
146 assert(I->getOperand(0).isReg() && I->getOperand(1).isFI());
154 unsigned VR =
MRI.createVirtualRegister(RC);
155 unsigned Src = I->getOperand(0).getReg(), FI = I->getOperand(1).getIndex();
159 TII.storeRegToStack(MBB, I, VR,
true, FI, RC, &RegInfo, 0);
169 assert(I->getOperand(0).isReg() && I->getOperand(1).isFI());
177 unsigned VR0 =
MRI.createVirtualRegister(RC);
178 unsigned VR1 =
MRI.createVirtualRegister(RC);
179 unsigned Dst = I->getOperand(0).getReg(), FI = I->getOperand(1).getIndex();
180 unsigned Lo = RegInfo.getSubReg(Dst, Mips::sub_lo);
181 unsigned Hi = RegInfo.getSubReg(Dst, Mips::sub_hi);
185 TII.loadRegFromStack(MBB, I, VR0, FI, RC, &RegInfo, 0);
187 TII.loadRegFromStack(MBB, I, VR1, FI, RC, &RegInfo, RegSize);
192 unsigned MFHiOpc,
unsigned MFLoOpc,
199 assert(I->getOperand(0).isReg() && I->getOperand(1).isFI());
207 unsigned VR0 =
MRI.createVirtualRegister(RC);
208 unsigned VR1 =
MRI.createVirtualRegister(RC);
209 unsigned Src = I->getOperand(0).getReg(), FI = I->getOperand(1).getIndex();
213 BuildMI(MBB, I, DL, TII.get(MFLoOpc), VR0).addReg(Src);
214 TII.storeRegToStack(MBB, I, VR0,
true, FI, RC, &RegInfo, 0);
215 BuildMI(MBB, I, DL, TII.get(MFHiOpc), VR1).addReg(Src, SrcKill);
216 TII.storeRegToStack(MBB, I, VR1,
true, FI, RC, &RegInfo, RegSize);
220 unsigned Src = I->getOperand(1).getReg();
221 std::pair<unsigned, unsigned> Opcodes = getMFHiLoOpc(Src);
226 return expandCopyACC(MBB, I, Opcodes.first, Opcodes.second);
230 unsigned MFHiOpc,
unsigned MFLoOpc) {
241 unsigned Dst = I->getOperand(0).getReg(), Src = I->getOperand(1).getReg();
242 unsigned VRegSize = RegInfo.getMinimalPhysRegClass(Dst)->getSize() / 2;
244 unsigned VR0 =
MRI.createVirtualRegister(RC);
245 unsigned VR1 =
MRI.createVirtualRegister(RC);
247 unsigned DstLo = RegInfo.getSubReg(Dst, Mips::sub_lo);
248 unsigned DstHi = RegInfo.getSubReg(Dst, Mips::sub_hi);
251 BuildMI(MBB, I, DL, TII.get(MFLoOpc), VR0).addReg(Src);
254 BuildMI(MBB, I, DL, TII.get(MFHiOpc), VR1).addReg(Src, SrcKill);
261 static const unsigned EhDataReg[] = {
262 Mips::A0, Mips::A1, Mips::A2, Mips::A3
264 static const unsigned EhDataReg64[] = {
265 Mips::A0_64, Mips::A1_64, Mips::A2_64, Mips::A3_64
285 unsigned ZERO =
STI.
isABI_N64() ? Mips::ZERO_64 : Mips::ZERO;
286 unsigned ADDu =
STI.
isABI_N64() ? Mips::DADDu : Mips::ADDu;
299 TII.adjustStackPtr(SP, -StackSize, MBB, MBBI);
313 for (
unsigned i = 0; i < CSI.size(); ++i)
322 for (std::vector<CalleeSavedInfo>::const_iterator I = CSI.begin(),
323 E = CSI.end(); I != E; ++
I) {
325 unsigned Reg = I->getReg();
329 if (Mips::AFGR64RegClass.contains(Reg)) {
352 &Mips::GPR64RegClass : &Mips::GPR32RegClass;
355 for (
int I = 0; I < 4; ++
I) {
358 TII.storeRegToStackSlot(MBB, MBBI,
ehDataReg(I),
false,
366 for (
int I = 0; I < 4; ++
I) {
401 unsigned ZERO =
STI.
isABI_N64() ? Mips::ZERO_64 : Mips::ZERO;
402 unsigned ADDu =
STI.
isABI_N64() ? Mips::DADDu : Mips::ADDu;
418 &Mips::GPR64RegClass : &Mips::GPR32RegClass;
426 for (
int J = 0; J < 4; ++J) {
439 TII.adjustStackPtr(SP, StackSize, MBB, MBBI);
445 const std::vector<CalleeSavedInfo> &CSI,
451 for (
unsigned i = 0, e = CSI.size(); i != e; ++i) {
457 unsigned Reg = CSI[i].getReg();
458 bool IsRAAndRetAddrIsTaken = (Reg == Mips::RA || Reg == Mips::RA_64)
460 if (!IsRAAndRetAddrIsTaken)
464 bool IsKill = !IsRAAndRetAddrIsTaken;
467 CSI[i].getFrameIdx(), RC, TRI);
493 int64_t Amount = I->getOperand(0).getImm();
495 if (I->getOpcode() == Mips::ADJCALLSTACKDOWN)
522 if (ExpandPseudo(MF).expand()) {
526 &Mips::GPR64RegClass : &Mips::GPR32RegClass;
540 &Mips::GPR64RegClass : &Mips::GPR32RegClass;
unsigned getStackAlignment() const
const MachineFunction * getParent() const
instr_iterator erase(instr_iterator I)
void setPhysRegUsed(unsigned Reg)
int getDwarfRegNum(unsigned RegNum, bool isEH) const
Map a target register to an equivalent dwarf register number. Returns -1 if there is no equivalent va...
void adjustStackPtr(unsigned SP, int64_t Amount, MachineBasicBlock &MBB, MachineBasicBlock::iterator I) const
Adjust SP by Amount bytes.
const MipsFrameLowering * createMipsSEFrameLowering(const MipsSubtarget &ST)
const TargetRegisterClass * getMinimalPhysRegClass(unsigned Reg, EVT VT=MVT::Other) const
const MipsSubtarget & STI
unsigned ehDataReg(unsigned I) const
void emitPrologue(MachineFunction &MF) const
static MCCFIInstruction createOffset(MCSymbol *L, unsigned Register, int Offset)
.cfi_offset Previous value of Register is saved at offset Offset from CFA.
bool adjustsStack() const
void addLiveIn(unsigned Reg)
bool isReturnAddressTaken() const
static MCCFIInstruction createDefCfaOffset(MCSymbol *L, int Offset)
.cfi_def_cfa_offset modifies a rule for computing CFA. Register remains the same, but offset is new...
const std::vector< CalleeSavedInfo > & getCalleeSavedInfo() const
uint64_t getStackSize() const
bool hasReservedCallFrame(const MachineFunction &MF) const
MCSymbol * CreateTempSymbol()
bool spillCalleeSavedRegisters(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, const std::vector< CalleeSavedInfo > &CSI, const TargetRegisterInfo *TRI) const
const HexagonInstrInfo * TII
void createEhDataRegsFI()
Abstract Stack Frame Information.
virtual const TargetRegisterClass * intRegClass(unsigned Size) const =0
Return GPR register class.
const MachineBasicBlock & front() const
iterator getLastNonDebugInstr()
unsigned getKillRegState(bool B)
bundle_iterator< MachineInstr, instr_iterator > iterator
unsigned getAlignment() const
static MCCFIInstruction createDefCfaRegister(MCSymbol *L, unsigned Register)
.cfi_def_cfa_register modifies a rule for computing CFA. From now on Register will be used instead of...
void eliminateCallFramePseudoInstr(MachineFunction &MF, MachineBasicBlock &MBB, MachineBasicBlock::iterator I) const
MachineInstrBuilder BuildMI(MachineFunction &MF, DebugLoc DL, const MCInstrDesc &MCID)
virtual void storeRegToStackSlot(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, unsigned SrcReg, bool isKill, int FrameIndex, const TargetRegisterClass *RC, const TargetRegisterInfo *TRI) const
int getEhDataRegFI(unsigned Reg) const
int64_t getObjectOffset(int ObjectIdx) const
virtual const TargetInstrInfo * getInstrInfo() const
const MCContext & getContext() const
void addScavengingFrameIndex(int FI)
Add a scavenging frame index.
unsigned getMaxCallFrameSize() const
MachineFrameInfo * getFrameInfo()
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.
void processFunctionBeforeCalleeSavedScan(MachineFunction &MF, RegScavenger *RS) const
const MCRegisterInfo * getRegisterInfo() const
static DebugLoc get(unsigned Line, unsigned Col, MDNode *Scope, MDNode *InlinedAt=0)
int CreateStackObject(uint64_t Size, unsigned Alignment, bool isSS, bool MayNeedSP=false, const AllocaInst *Alloca=0)
bool callsEhReturn() const
bool isLiveIn(unsigned Reg) const
MachineRegisterInfo & getRegInfo()
void addFrameInst(const MCCFIInstruction &Inst)
const TargetMachine & getTarget() const
virtual const TargetRegisterInfo * getRegisterInfo() const
bool isInt< 16 >(int64_t x)
bool hasVarSizedObjects() const
uint64_t estimateStackSize(const MachineFunction &MF) const
BasicBlockListType::iterator iterator
void emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const
MachineModuleInfo & getMMI() const
const MCRegisterInfo & MRI
bool hasFP(const MachineFunction &MF) const
const MachineInstrBuilder & addReg(unsigned RegNo, unsigned flags=0, unsigned SubReg=0) const