33 #define DEBUG_TYPE "arc-reg-info" 35 #define GET_REGINFO_TARGET_DESC 36 #include "ARCGenRegisterInfo.inc" 40 unsigned FrameReg,
int Offset,
int StackSize,
42 assert(RS &&
"Need register scavenger.");
46 unsigned BaseReg = FrameReg;
47 unsigned KillState = 0;
48 if (MI.
getOpcode() == ARC::LD_rs9 && (Offset >= 256 || Offset < -256)) {
50 BuildMI(MBB, II, dl, TII.get(ARC::LD_rlimm),
Reg)
58 if (MI.
getOpcode() != ARC::GETFI && (Offset >= 256 || Offset < -256)) {
67 assert(BaseReg &&
"Register scavenging failed.");
69 <<
" for FrameReg=" <<
printReg(FrameReg, TRI)
70 <<
"+Offset=" << Offset <<
"\n");
74 unsigned AddOpc = isUInt<6>(
Offset) ? ARC::ADD_rru6 : ARC::ADD_rrlimm;
75 BuildMI(MBB, II, dl, TII.get(AddOpc))
84 assert((Offset % 4 == 0) &&
"LD needs 4 byte alignment.");
88 assert((Offset % 2 == 0) &&
"LDH needs 2 byte alignment.");
94 .
addReg(BaseReg, KillState)
99 assert((Offset % 4 == 0) &&
"ST needs 4 byte alignment.");
102 assert((Offset % 2 == 0) &&
"STH needs 2 byte alignment.");
108 .
addReg(BaseReg, KillState)
115 TII.get(isUInt<6>(Offset) ? ARC::ADD_rru6 : ARC::ADD_rrlimm))
136 return CSR_ARC_SaveList;
142 Reserved.
set(ARC::ILINK);
143 Reserved.
set(ARC::SP);
144 Reserved.
set(ARC::GP);
145 Reserved.
set(ARC::R25);
146 Reserved.
set(ARC::BLINK);
147 Reserved.
set(ARC::FP);
166 int SPAdj,
unsigned FIOperandNum,
168 assert(SPAdj == 0 &&
"Unexpected");
188 LLVM_DEBUG(
dbgs() <<
"LocalFrameSize : " << LocalFrameSize <<
"\n");
189 (void)LocalFrameSize;
210 assert(ARC::GPR32RegClass.
contains(Reg) &&
"Unexpected register operand");
212 if (!TFI->
hasFP(MF)) {
213 Offset = StackSize +
Offset;
215 assert((Offset >= 0 && Offset < StackSize) &&
"SP Offset not in bounds.");
217 if (FrameIndex >= 0) {
218 assert((Offset < 0 && -Offset <= StackSize) &&
219 "FP Offset not in bounds.");
228 return TFI->
hasFP(MF) ? ARC::FP : ARC::SP;
234 return CSR_ARC_RegMask;
This class represents lattice values for constants.
virtual const TargetRegisterInfo * getRegisterInfo() const
getRegisterInfo - If register information is available, return it.
const DebugLoc & getDebugLoc() const
Returns the debug location id of this MachineInstr.
int64_t getLocalFrameSize() const
Get the size of the local object blob.
bool trackLivenessAfterRegAlloc(const MachineFunction &MF) const override
unsigned const TargetRegisterInfo * TRI
Printable printReg(Register Reg, const TargetRegisterInfo *TRI=nullptr, unsigned SubIdx=0, const MachineRegisterInfo *MRI=nullptr)
Prints virtual and physical registers with or without a TRI instance.
return AArch64::GPR64RegClass contains(Reg)
instr_iterator erase(instr_iterator I)
Remove an instruction from the instruction list and delete it.
const HexagonInstrInfo * TII
int64_t getObjectOffset(int ObjectIdx) const
Return the assigned stack offset of the specified object from the incoming stack pointer.
unsigned getOpcode() const
Returns the opcode of this MachineInstr.
void setRegUsed(Register Reg, LaneBitmask LaneMask=LaneBitmask::getAll())
Tell the scavenger a register is used.
BitVector getReservedRegs(const MachineFunction &MF) const override
bool useFPForScavengingIndex(const MachineFunction &MF) const override
int64_t getObjectSize(int ObjectIdx) const
Return the size of the specified object.
unsigned getKillRegState(bool B)
StringRef getName() const
getName - Return the name of the corresponding LLVM function.
void ChangeToImmediate(int64_t ImmVal)
ChangeToImmediate - Replace this operand with a new immediate operand of the specified value...
MachineInstrBuilder BuildMI(MachineFunction &MF, const DebugLoc &DL, const MCInstrDesc &MCID)
Builder interface. Specify how to create the initial instruction itself.
This file declares the machine register scavenger class.
static bool needsFrameMoves(const MachineFunction &MF)
Return whether to emit frame moves.
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.
bool hasFP(const MachineFunction &MF) const override
hasFP - Return true if the specified function should have a dedicated frame pointer register...
Register getFrameRegister(const MachineFunction &MF) const override
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
mmo_iterator memoperands_begin() const
Access to memory operands of the instruction.
bool isDebugValue() const
MachineOperand class - Representation of each machine instruction operand.
const MachineInstrBuilder & addMemOperand(MachineMemOperand *MMO) const
const uint32_t * getCallPreservedMask(const MachineFunction &MF, CallingConv::ID CC) const override
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
void eliminateFrameIndex(MachineBasicBlock::iterator II, int SPAdj, unsigned FIOperandNum, RegScavenger *RS=nullptr) const override
const MachineBasicBlock * getParent() const
Representation of each machine instruction.
const MachineFunction * getParent() const
Return the MachineFunction containing this basic block.
const MachineInstrBuilder & addImm(int64_t Val) const
Add a new immediate operand.
Register scavengeRegister(const TargetRegisterClass *RC, MachineBasicBlock::iterator I, int SPAdj, bool AllowSpill=true)
Make a register of the specific register class available and do the appropriate bookkeeping.
Register FindUnusedReg(const TargetRegisterClass *RC) const
Find an unused register of the specified register class.
void ChangeToRegister(Register Reg, bool isDef, bool isImp=false, bool isKill=false, bool isDead=false, bool isUndef=false, bool isDebug=false)
ChangeToRegister - Replace this operand with a new register operand of the specified value...
bool requiresRegisterScavenging(const MachineFunction &MF) const override
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
#define LLVM_FALLTHROUGH
LLVM_FALLTHROUGH - Mark fallthrough cases in switch statements.
static void ReplaceFrameIndex(MachineBasicBlock::iterator II, const ARCInstrInfo &TII, unsigned Reg, unsigned FrameReg, int Offset, int StackSize, int ObjSize, RegScavenger *RS, int SPAdj)
Register getReg() const
getReg - Returns the register number.
const MachineOperand & getOperand(unsigned i) const
const MCPhysReg * getCalleeSavedRegs(const MachineFunction *MF) const override
Code Generation virtual methods...
uint64_t getStackSize() const
Return the number of bytes that must be allocated to hold all of the fixed size frame objects...
bool needsFrameMoves() const
True if this function needs frame moves for debug or exceptions.
const MachineInstrBuilder & addReg(Register RegNo, unsigned flags=0, unsigned SubReg=0) const
Add a new virtual register operand.
Wrapper class representing virtual and physical registers.