LLVM: lib/Target/M68k/M68kRegisterInfo.cpp Source File (original) (raw)

1

2

3

4

5

6

7

8

9

10

11

12

13

15

19

21

30

31#define GET_REGINFO_TARGET_DESC

32#include "M68kGenRegisterInfo.inc"

33

34#define DEBUG_TYPE "m68k-reg-info"

35

36using namespace llvm;

37

40 cl::desc("Enable use of a base pointer for complex stack frames"));

41

42

43void M68kRegisterInfo::anchor() {}

44

46

47

49 StackPtr = M68k::SP;

50 FramePtr = M68k::A6;

51 GlobalBasePtr = M68k::A5;

52 BasePtr = M68k::A4;

53}

54

55

56

57

58

61 return CSR_STD_SaveList;

62}

63

67 return CSR_STD_RegMask;

68}

69

72 return &M68k::XR32_TCRegClass;

73}

74

75unsigned

78 for (MCPhysReg Super : superregs(Reg))

80 return Super;

81 return 0;

82}

83

87 "reg must be a physical register");

88

89

90

92 for (regclass_iterator I = regclass_begin(), E = regclass_end(); I != E;

93 ++I) {

95 if ((VT == MVT::Other || isTypeLegalForClass(*RC, VT)) &&

97 (!BestRC ||

99 BestRC = RC;

100 }

101

102 assert(BestRC && "Couldn't find the register class");

103 return BestRC;

104}

105

108 for (unsigned i = 0; i < TRC.getNumRegs(); ++i) {

109 if (regsOverlap(Reg, TRC.getRegister(i))) {

110 return i;

111 }

112 }

113 return -1;

114}

115

118 assert(Result >= 0 && "Can not determine spill order");

119 return Result;

120}

121

124

126

127

128 auto setBitVector = [&Reserved, this](unsigned Reg) {

131 }

132 for (MCPhysReg I : subregs_inclusive(Reg)) {

134 }

135 };

136

137

138 for (size_t Reg = 0, Total = getNumRegs(); Reg != Total; ++Reg) {

140 setBitVector(Reg);

141 }

142

143 setBitVector(M68k::PC);

144 setBitVector(M68k::SP);

145

146 if (TFI->hasFP(MF)) {

147 setBitVector(FramePtr);

148 }

149

150

155 report_fatal_error("Stack realignment in presence of dynamic allocas is "

156 "not supported with"

157 "this calling convention.");

158

160 }

161

163}

164

166 int SPAdj, unsigned FIOperandNum,

171

172

173

176

177 int Imm = (int)(Disp.getImm());

178 int FIndex = (int)(Base.getIndex());

179

180

181 bool AfterFPPop = false;

182

183 unsigned BasePtr;

186 else if (hasStackRealignment(MF))

187 BasePtr = (FIndex < 0 ? FramePtr : StackPtr);

188 else if (AfterFPPop)

189 BasePtr = StackPtr;

190 else

191 BasePtr = (TFI->hasFP(MF) ? FramePtr : StackPtr);

192

193 Base.ChangeToRegister(BasePtr, false);

194

195

196 int64_t FIOffset;

198 if (AfterFPPop) {

199

202 } else {

203 FIOffset =

205 }

206

207 if (BasePtr == StackPtr)

208 FIOffset += SPAdj;

209

211 return false;

212}

213

218

223

227

230

232 return false;

233

234

235

236

237

238

239 bool CantUseFP = hasStackRealignment(MF);

240 return CantUseFP && CantUseSP(MFI);

241}

242

245 return false;

246

249

250

251

252 if (MRI->canReserveReg(FramePtr))

253 return false;

254

255

257 return MRI->canReserveReg(BasePtr);

258

259 return true;

260}

261

264 return TFI->hasFP(MF) ? FramePtr : StackPtr;

265}

266

268 return &M68k::DR32RegClass;

269}

unsigned const MachineRegisterInfo * MRI

static const TargetRegisterClass * getRegClass(const MachineInstr &MI, Register Reg)

assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")

This file provides M68k specific target descriptions.

This file declares the M68k specific subclass of MachineFunctionInfo.

static cl::opt< bool > EnableBasePointer("m68k-use-base-pointer", cl::Hidden, cl::init(true), cl::desc("Enable use of a base pointer for complex stack frames"))

static bool CantUseSP(const MachineFrameInfo &MFI)

Definition M68kRegisterInfo.cpp:224

This file contains the M68k implementation of the TargetRegisterInfo class.

This file declares the M68k specific subclass of TargetSubtargetInfo.

This file contains the entry points for global functions defined in the M68k target library,...

uint64_t IntrinsicInst * II

CallingConv::ID getCallingConv() const

getCallingConv()/setCallingConv(CC) - These method get and set the calling convention of this functio...

StackOffset getFrameIndexReference(const MachineFunction &MF, int FI, Register &FrameReg) const override

This method should return the base register and offset used to reference a frame index location.

unsigned getMatchingMegaReg(unsigned Reg, const TargetRegisterClass *RC) const

Return a mega-register of the specified register Reg so its sub-register of index SubIdx is Reg,...

Definition M68kRegisterInfo.cpp:76

const uint32_t * getCallPreservedMask(const MachineFunction &MF, CallingConv::ID) const override

Definition M68kRegisterInfo.cpp:65

const TargetRegisterClass * intRegClass(unsigned Size) const

Definition M68kRegisterInfo.cpp:267

Register getFrameRegister(const MachineFunction &MF) const override

Definition M68kRegisterInfo.cpp:262

unsigned getBaseRegister() const

M68kRegisterInfo(const M68kSubtarget &Subtarget)

Definition M68kRegisterInfo.cpp:45

bool trackLivenessAfterRegAlloc(const MachineFunction &MF) const override

Definition M68kRegisterInfo.cpp:219

int getSpillRegisterOrder(unsigned Reg) const

Return spill order index of a register, if there is none then trap.

Definition M68kRegisterInfo.cpp:116

bool requiresRegisterScavenging(const MachineFunction &MF) const override

Definition M68kRegisterInfo.cpp:214

const TargetRegisterClass * getRegsForTailCall(const MachineFunction &MF) const

Returns a register class with registers that can be used in forming tail calls.

Definition M68kRegisterInfo.cpp:71

const M68kSubtarget & Subtarget

const TargetRegisterClass * getMaximalPhysRegClass(unsigned reg, MVT VT) const

Returns the Register Class of a physical register of the given type, picking the biggest register cla...

Definition M68kRegisterInfo.cpp:85

int getRegisterOrder(unsigned Reg, const TargetRegisterClass &TRC) const

Return index of a register within a register class, otherwise return -1.

Definition M68kRegisterInfo.cpp:106

bool hasBasePointer(const MachineFunction &MF) const

Definition M68kRegisterInfo.cpp:228

bool eliminateFrameIndex(MachineBasicBlock::iterator II, int SPAdj, unsigned FIOperandNum, RegScavenger *RS=nullptr) const override

FrameIndex represent objects inside a abstract stack.

Definition M68kRegisterInfo.cpp:165

bool canRealignStack(const MachineFunction &MF) const override

True if the stack can be realigned for the target.

Definition M68kRegisterInfo.cpp:243

const MCPhysReg * getCalleeSavedRegs(const MachineFunction *MF) const override

Definition M68kRegisterInfo.cpp:60

BitVector getReservedRegs(const MachineFunction &MF) const override

Definition M68kRegisterInfo.cpp:122

bool isRegisterReservedByUser(Register R) const override

MCRegAliasIterator enumerates all registers aliasing Reg.

MachineInstrBundleIterator< MachineInstr > iterator

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 ...

bool hasOpaqueSPAdjustment() const

Returns true if the function contains opaque dynamic stack adjustments.

int64_t getObjectOffset(int ObjectIdx) const

Return the assigned stack offset of the specified object from the incoming stack pointer.

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.

MachineRegisterInfo & getRegInfo()

getRegInfo - Return information about the registers currently in use.

Function & getFunction()

Return the LLVM function that this machine code represents.

Representation of each machine instruction.

MachineOperand class - Representation of each machine instruction operand.

LLVM_ABI void ChangeToImmediate(int64_t ImmVal, unsigned TargetFlags=0)

ChangeToImmediate - Replace this operand with a new immediate operand of the specified value.

static bool clobbersPhysReg(const uint32_t *RegMask, MCRegister PhysReg)

clobbersPhysReg - Returns true if this RegMask clobbers PhysReg.

MachineRegisterInfo - Keep track of information for virtual and physical registers,...

Wrapper class representing virtual and physical registers.

static constexpr bool isPhysicalRegister(unsigned Reg)

Return true if the specified register number is in the physical register namespace.

static StackOffset getFixed(int64_t Fixed)

Information about stack frame layout on the target.

bool hasFP(const MachineFunction &MF) const

hasFP - Return true if the specified function should have a dedicated frame pointer register.

int getOffsetOfLocalArea() const

getOffsetOfLocalArea - This method returns the offset of the local area from the stack pointer on ent...

unsigned getNumRegs() const

Return the number of registers in this class.

bool contains(Register Reg) const

Return true if the specified register is included in this register class.

bool hasSubClass(const TargetRegisterClass *RC) const

Return true if the specified TargetRegisterClass is a proper sub-class of this TargetRegisterClass.

MCRegister getRegister(unsigned i) const

Return the specified register in the class.

virtual bool canRealignStack(const MachineFunction &MF) const

True if the stack can be realigned for the target.

virtual const TargetFrameLowering * getFrameLowering() const

unsigned ID

LLVM IR allows to use arbitrary numbers as calling convention identifiers.

Define some predicates that are used for node matching.

initializer< Ty > init(const Ty &Val)

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.

LLVM_ABI void report_fatal_error(Error Err, bool gen_crash_diag=true)

uint16_t MCPhysReg

An unsigned integer type large enough to represent all physical registers, but not necessarily virtua...