38 #define DEBUG_TYPE "xcore-reg-info" 40 #define GET_REGINFO_TARGET_DESC 41 #include "XCoreGenRegisterInfo.inc" 48 static inline bool isImmUs(
unsigned val) {
52 static inline bool isImmU6(
unsigned val) {
53 return val < (1 << 6);
57 return val < (1 << 16);
63 unsigned Reg,
unsigned FrameReg,
int Offset ) {
70 BuildMI(MBB, II, dl, TII.get(XCore::LDW_2rus),
Reg)
76 BuildMI(MBB, II, dl, TII.get(XCore::STW_2rus))
83 BuildMI(MBB, II, dl, TII.get(XCore::LDAWF_l2rus),
Reg)
94 unsigned Reg,
unsigned FrameReg,
96 assert(RS &&
"requiresRegisterScavenging failed");
100 unsigned ScratchOffset = RS->
scavengeRegister(&XCore::GRRegsRegClass, II, 0);
106 BuildMI(MBB, II, dl, TII.get(XCore::LDW_3r),
Reg)
112 BuildMI(MBB, II, dl, TII.get(XCore::STW_l3r))
119 BuildMI(MBB, II, dl, TII.get(XCore::LDAWF_l3r),
Reg)
139 NewOpcode = (isU6) ? XCore::LDWSP_ru6 : XCore::LDWSP_lru6;
145 NewOpcode = (isU6) ? XCore::STWSP_ru6 : XCore::STWSP_lru6;
146 BuildMI(MBB, II, dl, TII.get(NewOpcode))
152 NewOpcode = (isU6) ? XCore::LDAWSP_ru6 : XCore::LDAWSP_lru6;
164 assert(RS &&
"requiresRegisterScavenging failed");
170 unsigned ScratchBase;
171 if (OpCode==XCore::STWFI) {
176 BuildMI(MBB, II, dl, TII.get(XCore::LDAWSP_ru6), ScratchBase).addImm(0);
177 unsigned ScratchOffset = RS->
scavengeRegister(&XCore::GRRegsRegClass, II, 0);
183 BuildMI(MBB, II, dl, TII.get(XCore::LDW_3r),
Reg)
189 BuildMI(MBB, II, dl, TII.get(XCore::STW_l3r))
196 BuildMI(MBB, II, dl, TII.get(XCore::LDAWF_l3r),
Reg)
213 static const MCPhysReg CalleeSavedRegs[] = {
215 XCore::R8, XCore::R9, XCore::R10,
218 static const MCPhysReg CalleeSavedRegsFP[] = {
220 XCore::R8, XCore::R9,
225 return CalleeSavedRegsFP;
226 return CalleeSavedRegs;
234 Reserved.
set(XCore::DP);
235 Reserved.
set(XCore::SP);
236 Reserved.
set(XCore::LR);
237 if (TFI->
hasFP(MF)) {
238 Reserved.
set(XCore::R10);
260 int SPAdj,
unsigned FIOperandNum,
262 assert(SPAdj == 0 &&
"Unexpected");
299 assert(Offset%4 == 0 &&
"Misaligned stack offset");
305 assert(XCore::GRRegsRegClass.
contains(Reg) &&
"Unexpected register operand");
307 if (TFI->
hasFP(MF)) {
327 return TFI->
hasFP(MF) ? XCore::R10 : XCore::SP;
raw_ostream & errs()
This returns a reference to a raw_ostream for standard error.
This class represents lattice values for constants.
const DebugLoc & getDebugLoc() const
Returns the debug location id of this MachineInstr.
bool trackLivenessAfterRegAlloc(const MachineFunction &MF) const override
Register getFrameRegister(const MachineFunction &MF) const override
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.
static bool needsFrameMoves(const MachineFunction &MF)
Return whether to emit frame moves.
virtual const TargetInstrInfo * getInstrInfo() const
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...
MachineBasicBlock::iterator loadImmediate(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, unsigned Reg, uint64_t Value) const
MachineInstrBuilder BuildMI(MachineFunction &MF, const DebugLoc &DL, const MCInstrDesc &MCID)
Builder interface. Specify how to create the initial instruction itself.
bool useFPForScavengingIndex(const MachineFunction &MF) const override
This file declares the machine register scavenger class.
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.
static void InsertSPImmInst(MachineBasicBlock::iterator II, const XCoreInstrInfo &TII, unsigned Reg, int Offset)
static void InsertFPConstInst(MachineBasicBlock::iterator II, const XCoreInstrInfo &TII, unsigned Reg, unsigned FrameReg, int Offset, RegScavenger *RS)
void print(raw_ostream &OS, bool IsStandalone=true, bool SkipOpers=false, bool SkipDebugLoc=false, bool AddNewLine=true, const TargetInstrInfo *TII=nullptr) const
Print this MI to OS.
bool hasFP(const MachineFunction &MF) const override
hasFP - Return true if the specified function should have a dedicated frame pointer register...
bool requiresRegisterScavenging(const MachineFunction &MF) const override
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
static bool isImmUs(unsigned val)
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
BitVector getReservedRegs(const MachineFunction &MF) const override
static bool isImmU6(unsigned val)
const MachineBasicBlock * getParent() const
Representation of each machine instruction.
static bool isImmU16(unsigned val)
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.
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...
static void InsertSPConstInst(MachineBasicBlock::iterator II, const XCoreInstrInfo &TII, unsigned Reg, int Offset, RegScavenger *RS)
void eliminateFrameIndex(MachineBasicBlock::iterator II, int SPAdj, unsigned FIOperandNum, RegScavenger *RS=nullptr) const override
static void InsertFPImmInst(MachineBasicBlock::iterator II, const XCoreInstrInfo &TII, unsigned Reg, unsigned FrameReg, int Offset)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
Register getReg() const
getReg - Returns the register number.
const MachineOperand & getOperand(unsigned i) const
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.
const MCPhysReg * getCalleeSavedRegs(const MachineFunction *MF) const override
Code Generation virtual methods...