49 if (Mips::ACC64RegClass.
contains(Src))
50 return std::make_pair((
unsigned)Mips::PseudoMFHI,
51 (
unsigned)Mips::PseudoMFLO);
53 if (Mips::ACC64DSPRegClass.
contains(Src))
54 return std::make_pair((
unsigned)Mips::MFHI_DSP, (
unsigned)Mips::MFLO_DSP);
56 if (Mips::ACC128RegClass.
contains(Src))
57 return std::make_pair((
unsigned)Mips::PseudoMFHI64,
58 (
unsigned)Mips::PseudoMFLO64);
60 return std::make_pair(0, 0);
79 unsigned MFLoOpc,
unsigned RegSize);
98 : MF(MF_),
MRI(MF.getRegInfo()),
101 RegInfo(*Subtarget.getRegisterInfo()) {}
103bool ExpandPseudo::expand() {
104 bool Expanded =
false;
106 for (
auto &
MBB : MF) {
108 Expanded |= expandInstr(
MBB,
I++);
115 switch(
I->getOpcode()) {
116 case Mips::LOAD_CCOND_DSP:
117 expandLoadCCond(
MBB,
I);
119 case Mips::STORE_CCOND_DSP:
120 expandStoreCCond(
MBB,
I);
122 case Mips::LOAD_ACC64:
123 case Mips::LOAD_ACC64DSP:
124 expandLoadACC(
MBB,
I, 4);
126 case Mips::LOAD_ACC128:
127 expandLoadACC(
MBB,
I, 8);
129 case Mips::STORE_ACC64:
130 expandStoreACC(
MBB,
I, Mips::PseudoMFHI, Mips::PseudoMFLO, 4);
132 case Mips::STORE_ACC64DSP:
133 expandStoreACC(
MBB,
I, Mips::MFHI_DSP, Mips::MFLO_DSP, 4);
135 case Mips::STORE_ACC128:
136 expandStoreACC(
MBB,
I, Mips::PseudoMFHI64, Mips::PseudoMFLO64, 8);
138 case Mips::BuildPairF64:
139 if (expandBuildPairF64(
MBB,
I,
false))
142 case Mips::BuildPairF64_64:
143 if (expandBuildPairF64(
MBB,
I,
true))
146 case Mips::ExtractElementF64:
147 if (expandExtractElementF64(
MBB,
I,
false))
150 case Mips::ExtractElementF64_64:
151 if (expandExtractElementF64(
MBB,
I,
true))
154 case TargetOpcode::COPY:
155 if (!expandCopy(
MBB,
I))
170 assert(
I->getOperand(0).isReg() &&
I->getOperand(1).isFI());
174 Register Dst =
I->getOperand(0).getReg(), FI =
I->getOperand(1).getIndex();
185 assert(
I->getOperand(0).isReg() &&
I->getOperand(1).isFI());
189 Register Src =
I->getOperand(0).getReg(), FI =
I->getOperand(1).getIndex();
203 assert(
I->getOperand(0).isReg() &&
I->getOperand(1).isFI());
208 Register Dst =
I->getOperand(0).getReg(), FI =
I->getOperand(1).getIndex();
221 unsigned MFHiOpc,
unsigned MFLoOpc,
228 assert(
I->getOperand(0).isReg() &&
I->getOperand(1).isFI());
233 Register Src =
I->getOperand(0).getReg(), FI =
I->getOperand(1).getIndex();
244 Register Src =
I->getOperand(1).getReg();
245 std::pair<unsigned, unsigned> Opcodes =
getMFHiLoOpc(Src);
250 return expandCopyACC(
MBB,
I, Opcodes.first, Opcodes.second);
254 unsigned MFHiOpc,
unsigned MFLoOpc) {
260 unsigned Dst =
I->getOperand(0).getReg(), Src =
I->getOperand(1).getReg();
262 unsigned VRegSize =
RegInfo.getRegSizeInBits(*DstRC) / 16;
304 if (
I->getNumOperands() == 4 &&
I->getOperand(3).isReg()
305 &&
I->getOperand(3).getReg() == Mips::SP) {
306 Register DstReg =
I->getOperand(0).getReg();
307 Register LoReg =
I->getOperand(1).getReg();
308 Register HiReg =
I->getOperand(2).getReg();
313 assert(Subtarget.isGP64bit() || Subtarget.hasMTHC1() ||
314 !Subtarget.isFP64bit());
318 FP64 ? &Mips::FGR64RegClass : &Mips::AFGR64RegClass;
323 if (!Subtarget.isLittle())
325 TII.storeRegToStack(
MBB,
I, LoReg,
I->getOperand(1).isKill(), FI, RC,
327 TII.storeRegToStack(
MBB,
I, HiReg,
I->getOperand(2).isKill(), FI, RC,
348 Register DstReg =
I->getOperand(0).getReg();
349 BuildMI(
MBB,
I,
I->getDebugLoc(),
TII.get(Mips::IMPLICIT_DEF), DstReg);
369 if (
I->getNumOperands() == 4 &&
I->getOperand(3).isReg()
370 &&
I->getOperand(3).getReg() == Mips::SP) {
371 Register DstReg =
I->getOperand(0).getReg();
374 int64_t
Offset = 4 * (Subtarget.isLittle() ?
N : (1 -
N));
379 assert(Subtarget.isGP64bit() || Subtarget.hasMTHC1() ||
380 !Subtarget.isFP64bit());
383 FP64 ? &Mips::FGR64RegClass : &Mips::AFGR64RegClass;
413 unsigned SP = ABI.GetStackPtr();
414 unsigned FP = ABI.GetFramePtr();
415 unsigned ZERO = ABI.GetNullPtr();
416 unsigned MOVE = ABI.GetGPRMoveOp();
417 unsigned ADDiu = ABI.GetPtrAddiuOp();
418 unsigned AND = ABI.IsN64() ? Mips::AND64 : Mips::AND;
421 &Mips::GPR64RegClass : &Mips::GPR32RegClass;
432 TII.adjustStackPtr(SP, -StackSize,
MBB,
MBBI);
441 emitInterruptPrologueStub(MF,
MBB);
448 for (
unsigned i = 0; i < CSI.size(); ++i)
459 if (Mips::AFGR64RegClass.
contains(Reg)) {
461 MRI->getDwarfRegNum(RegInfo.getSubReg(Reg, Mips::sub_lo),
true);
463 MRI->getDwarfRegNum(RegInfo.getSubReg(Reg, Mips::sub_hi),
true);
477 }
else if (Mips::FGR64RegClass.
contains(Reg)) {
478 unsigned Reg0 =
MRI->getDwarfRegNum(Reg,
true);
479 unsigned Reg1 =
MRI->getDwarfRegNum(Reg,
true) + 1;
496 nullptr,
MRI->getDwarfRegNum(Reg,
true),
Offset));
505 for (
int I = 0;
I < 4; ++
I) {
514 for (
int I = 0;
I < 4; ++
I) {
516 unsigned Reg =
MRI->getDwarfRegNum(ABI.GetEhDataReg(
I),
true);
532 nullptr,
MRI->getDwarfRegNum(
FP,
true)));
536 if (RegInfo.hasStackRealignment(MF)) {
541 "Function's alignment size requirement is not supported.");
558void MipsSEFrameLowering::emitInterruptPrologueStub(
571 "\"interrupt\" attribute is not supported on pre-MIPS32R2 or "
580 "static relocation model on MIPS at the present time.");
584 "O32 ABI on MIPS32R2+ at the present time.");
593 if (IntKind ==
"eic") {
632 unsigned InsPosition = 8;
633 unsigned InsSize = 0;
634 unsigned SrcReg = Mips::ZERO;
638 if (IntKind ==
"eic") {
653 assert(InsSize != 0 &&
"Unknown interrupt type!");
699 unsigned SP = ABI.GetStackPtr();
700 unsigned FP = ABI.GetFramePtr();
701 unsigned ZERO = ABI.GetNullPtr();
702 unsigned MOVE = ABI.GetGPRMoveOp();
718 ABI.ArePtrs64bit() ? &Mips::GPR64RegClass : &Mips::GPR32RegClass;
726 for (
int J = 0; J < 4; ++J) {
734 emitInterruptEpilogueStub(MF,
MBB);
746void MipsSEFrameLowering::emitInterruptEpilogueStub(
783 FrameReg =
hasFP(MF) ? ABI.GetFramePtr() : ABI.GetStackPtr();
785 FrameReg =
hasBP(MF) ? ABI.GetBasePtr() : ABI.GetStackPtr();
805 bool IsRAAndRetAddrIsTaken = (Reg == Mips::RA || Reg == Mips::RA_64)
807 if (!IsRAAndRetAddrIsTaken)
812 bool IsLOHI = (Reg == Mips::LO0 || Reg == Mips::LO0_64 ||
813 Reg == Mips::HI0 || Reg == Mips::HI0_64);
815 if (IsLOHI && Func.hasFnAttribute(
"interrupt")) {
820 Op = (Reg == Mips::HI0) ? Mips::MFHI : Mips::MFLO;
823 Op = (Reg == Mips::HI0) ? Mips::MFHI64 : Mips::MFLO64;
831 bool IsKill = !IsRAAndRetAddrIsTaken;
866 unsigned RA = ABI.IsN64() ? Mips::RA_64 : Mips::RA;
867 unsigned FP = ABI.GetFramePtr();
868 unsigned BP = ABI.IsN64() ? Mips::S7_64 : Mips::S7;
889 if (ExpandPseudo(MF).
expand()) {
894 Mips::GPR64RegClass : Mips::GPR32RegClass;
896 TRI->getSpillAlign(RC),
false);
910 ABI.ArePtrs64bit() ? Mips::GPR64RegClass : Mips::GPR32RegClass;
912 TRI->getSpillAlign(RC),
false);
unsigned const MachineRegisterInfo * MRI
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
MachineBasicBlock MachineBasicBlock::iterator MBBI
This file implements the BitVector class.
@ ZERO
Special weight used for cases with exact zero probability.
static Expected< BitVector > expand(StringRef S, StringRef Original)
const HexagonInstrInfo * TII
unsigned const TargetRegisterInfo * TRI
static std::pair< unsigned, unsigned > getMFHiLoOpc(unsigned Src)
static void setAliasRegs(MachineFunction &MF, BitVector &SavedRegs, unsigned Reg)
Mark Reg and all registers aliasing it in the bitset.
This file declares the machine register scavenger class.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
SI optimize exec mask operations pre RA
static bool contains(SmallPtrSetImpl< ConstantExpr * > &Cache, ConstantExpr *Expr, Constant *C)
This file implements the StringSwitch template, which mimics a switch() statement whose cases are str...
support::ulittle16_t & Lo
support::ulittle16_t & Hi
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
StringRef getValueAsString() const
Return the attribute's value as a string.
The CalleeSavedInfo class tracks the information need to locate where a callee saved register is in t...
This class represents an Operation in the Expression.
Attribute getFnAttribute(Attribute::AttrKind Kind) const
Return the attribute for the given attribute kind.
bool hasFnAttribute(Attribute::AttrKind Kind) const
Return true if the function has the attribute.
void storeRegToStackSlot(MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI, Register SrcReg, bool isKill, int FrameIndex, const TargetRegisterClass *RC, const TargetRegisterInfo *TRI, Register VReg) const override
Store the specified register of the given register class to the specified stack frame index.
void loadRegFromStackSlot(MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI, Register DestReg, int FrameIndex, const TargetRegisterClass *RC, const TargetRegisterInfo *TRI, Register VReg) const override
Load the specified register of the given register class from the specified stack frame index.
static MCCFIInstruction createDefCfaRegister(MCSymbol *L, unsigned Register, SMLoc Loc={})
.cfi_def_cfa_register modifies a rule for computing CFA.
static MCCFIInstruction createOffset(MCSymbol *L, unsigned Register, int64_t Offset, SMLoc Loc={})
.cfi_offset Previous value of Register is saved at offset Offset from CFA.
static MCCFIInstruction cfiDefCfaOffset(MCSymbol *L, int64_t Offset, SMLoc Loc={})
.cfi_def_cfa_offset modifies a rule for computing CFA.
const MCRegisterInfo * getRegisterInfo() const
Describe properties that are true of each instruction in the target description file.
MCRegAliasIterator enumerates all registers aliasing Reg.
MCRegisterInfo base class - We assume that the target defines a static array of MCRegisterDesc object...
iterator getFirstTerminator()
Returns an iterator to the first terminator instruction of this basic block.
iterator getLastNonDebugInstr(bool SkipPseudoOp=true)
Returns an iterator to the last non-debug instruction in the basic block, or end().
void addLiveIn(MCRegister PhysReg, LaneBitmask LaneMask=LaneBitmask::getAll())
Adds the specified register as a live in.
const MachineFunction * getParent() const
Return the MachineFunction containing this basic block.
instr_iterator erase(instr_iterator I)
Remove an instruction from the instruction list and delete it.
MachineInstrBundleIterator< MachineInstr > iterator
bool isLiveIn(MCRegister Reg, LaneBitmask LaneMask=LaneBitmask::getAll()) const
Return true if the specified register is in the live in set.
The MachineFrameInfo class represents an abstract stack frame until prolog/epilog code is inserted.
bool hasVarSizedObjects() const
This method may be called any time after instruction selection is complete to determine if the stack ...
uint64_t getStackSize() const
Return the number of bytes that must be allocated to hold all of the fixed size frame objects.
bool adjustsStack() const
Return true if this function adjusts the stack – e.g., when calling another function.
int CreateStackObject(uint64_t Size, Align Alignment, bool isSpillSlot, const AllocaInst *Alloca=nullptr, uint8_t ID=0)
Create a new statically sized stack object, returning a nonnegative identifier to represent it.
bool isReturnAddressTaken() const
This method may be called any time after instruction selection is complete to determine if there is a...
Align getMaxAlign() const
Return the alignment in bytes that this function must be aligned to, which is greater than the defaul...
uint64_t getMaxCallFrameSize() const
Return the maximum size of a call frame that must be allocated for an outgoing function call.
int64_t getOffsetAdjustment() const
Return the correction for frame offsets.
const std::vector< CalleeSavedInfo > & getCalleeSavedInfo() const
Returns a reference to call saved info vector for the current function.
int64_t getObjectOffset(int ObjectIdx) const
Return the assigned stack offset of the specified object from the incoming stack pointer.
bool isFixedObjectIndex(int ObjectIdx) const
Returns true if the specified index corresponds to a fixed stack object.
unsigned addFrameInst(const MCCFIInstruction &Inst)
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
MachineFrameInfo & getFrameInfo()
getFrameInfo - Return the frame info object for the current function.
MCContext & getContext() const
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
Function & getFunction()
Return the LLVM function that this machine code represents.
Ty * getInfo()
getInfo - Keep track of various per-function pieces of information for backends that would like to do...
const MachineInstrBuilder & addCFIIndex(unsigned CFIIndex) const
const MachineInstrBuilder & setMIFlag(MachineInstr::MIFlag Flag) const
const MachineInstrBuilder & addImm(int64_t Val) const
Add a new immediate operand.
const MachineInstrBuilder & addReg(Register RegNo, unsigned flags=0, unsigned SubReg=0) const
Add a new virtual register operand.
MachineOperand class - Representation of each machine instruction operand.
bool isReg() const
isReg - Tests if this is a MO_Register operand.
Register getReg() const
getReg - Returns the register number.
MachineRegisterInfo - Keep track of information for virtual and physical registers,...
Register createVirtualRegister(const TargetRegisterClass *RegClass, StringRef Name="")
createVirtualRegister - Create and return a new virtual register in the function with the specified r...
bool ArePtrs64bit() const
bool hasBP(const MachineFunction &MF) const
uint64_t estimateStackSize(const MachineFunction &MF) const
const MipsSubtarget & STI
MipsFunctionInfo - This class is derived from MachineFunction private Mips target-specific informatio...
int getEhDataRegFI(unsigned Reg) const
int getISRRegFI(Register Reg) const
bool callsEhReturn() const
void createEhDataRegsFI(MachineFunction &MF)
void createISRRegFI(MachineFunction &MF)
void loadRegFromStackSlot(MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI, Register DestReg, int FrameIndex, const TargetRegisterClass *RC, const TargetRegisterInfo *TRI, Register VReg) const override
virtual void storeRegToStack(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, Register SrcReg, bool isKill, int FrameIndex, const TargetRegisterClass *RC, const TargetRegisterInfo *TRI, int64_t Offset) const =0
void determineCalleeSaves(MachineFunction &MF, BitVector &SavedRegs, RegScavenger *RS) const override
This method determines which of the registers reported by TargetRegisterInfo::getCalleeSavedRegs() sh...
MipsSEFrameLowering(const MipsSubtarget &STI)
StackOffset getFrameIndexReference(const MachineFunction &MF, int FI, Register &FrameReg) const override
getFrameIndexReference - This method should return the base register and offset used to reference a f...
bool hasReservedCallFrame(const MachineFunction &MF) const override
hasReservedCallFrame - Under normal circumstances, when a frame pointer is not required,...
bool spillCalleeSavedRegisters(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, ArrayRef< CalleeSavedInfo > CSI, const TargetRegisterInfo *TRI) const override
spillCalleeSavedRegisters - Issues instruction(s) to spill all callee saved registers and returns tru...
void emitPrologue(MachineFunction &MF, MachineBasicBlock &MBB) const override
emitProlog/emitEpilog - These methods insert prolog and epilog code into the function.
void emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const override
bool useSoftFloat() const
const MipsInstrInfo * getInstrInfo() const override
const MipsRegisterInfo * getRegisterInfo() const override
Reloc::Model getRelocationModel() const
const MipsABIInfo & getABI() const
void addScavengingFrameIndex(int FI)
Add a scavenging frame index.
Wrapper class representing virtual and physical registers.
StackOffset holds a fixed and a scalable offset in bytes.
int64_t getFixed() const
Returns the fixed component of the stack.
StringRef - Represent a constant reference to a string, i.e.
A switch()-like statement whose cases are string literals.
StringSwitch & Case(StringLiteral S, T Value)
unsigned getStackAlignment() const
getStackAlignment - This method returns the number of bytes to which the stack pointer must be aligne...
bool hasFP(const MachineFunction &MF) const
hasFP - Return true if the specified function should have a dedicated frame pointer register.
virtual void determineCalleeSaves(MachineFunction &MF, BitVector &SavedRegs, RegScavenger *RS=nullptr) const
This method determines which of the registers reported by TargetRegisterInfo::getCalleeSavedRegs() sh...
int getOffsetOfLocalArea() const
getOffsetOfLocalArea - This method returns the offset of the local area from the stack pointer on ent...
TargetInstrInfo - Interface to description of machine instruction set.
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
virtual const TargetRegisterInfo * getRegisterInfo() const
getRegisterInfo - If register information is available, return it.
@ Kill
The last use of a register.
This is an optimization pass for GlobalISel generic memory operations.
auto size(R &&Range, std::enable_if_t< std::is_base_of< std::random_access_iterator_tag, typename std::iterator_traits< decltype(Range.begin())>::iterator_category >::value, void > *=nullptr)
Get the size of a range.
MachineInstrBuilder BuildMI(MachineFunction &MF, const MIMetadata &MIMD, const MCInstrDesc &MCID)
Builder interface. Specify how to create the initial instruction itself.
const MipsFrameLowering * createMipsSEFrameLowering(const MipsSubtarget &ST)
void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
unsigned getKillRegState(bool B)
bool isIntN(unsigned N, int64_t x)
Checks if an signed integer fits into the given (dynamic) bit width.
unsigned Log2(Align A)
Returns the log2 of the alignment.
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.
uint64_t value() const
This is a hole in the type system and should not be abused.
Description of the encoding of one expression Op.