32 #define GET_TARGET_REGBANK_IMPL
33 #include "AArch64GenRegisterBank.inc"
36 #include "AArch64GenRegisterBankInfo.def"
40 #ifndef LLVM_BUILD_GLOBAL_ISEL
41 #error "You shouldn't build this"
46 static bool AlreadyInit =
false;
58 assert(&AArch64::GPRRegBank == &RBGPR &&
59 "The order in RegBanks is messed up");
63 assert(&AArch64::FPRRegBank == &RBFPR &&
64 "The order in RegBanks is messed up");
68 assert(&AArch64::CCRRegBank == &RBCCR &&
69 "The order in RegBanks is messed up");
74 "Subclass not added?");
75 assert(RBGPR.
getSize() == 64 &&
"GPRs should hold up to 64-bit");
80 "Subclass not added?");
82 "Subclass not added?");
84 "FPRs should hold up to 512-bit via QQQQ sequence");
88 assert(RBCCR.
getSize() == 32 &&
"CCR should hold up to 32-bit");
94 "PartialMappingIdx's are incorrectly ordered");
98 "PartialMappingIdx's are incorrectly ordered");
101 #define CHECK_PARTIALMAP(Idx, ValStartIdx, ValLength, RB) \
104 checkPartialMap(PartialMappingIdx::Idx, ValStartIdx, ValLength, RB) && \
105 #Idx " is incorrectly initialized"); \
117 #define CHECK_VALUEMAP_IMPL(RBName, Size, Offset) \
119 assert(checkValueMapImpl(PartialMappingIdx::PMI_##RBName##Size, \
120 PartialMappingIdx::PMI_First##RBName, Size, \
122 #RBName #Size " " #Offset " is incorrectly initialized"); \
125 #define CHECK_VALUEMAP(RBName, Size) CHECK_VALUEMAP_IMPL(RBName, Size, 0)
137 #define CHECK_VALUEMAP_3OPS(RBName, Size) \
139 CHECK_VALUEMAP_IMPL(RBName, Size, 0); \
140 CHECK_VALUEMAP_IMPL(RBName, Size, 1); \
141 CHECK_VALUEMAP_IMPL(RBName, Size, 2); \
152 #define CHECK_VALUEMAP_CROSSREGCPY(RBNameDst, RBNameSrc, Size) \
154 unsigned PartialMapDstIdx = PMI_##RBNameDst##Size - PMI_Min; \
155 unsigned PartialMapSrcIdx = PMI_##RBNameSrc##Size - PMI_Min; \
156 (void)PartialMapDstIdx; \
157 (void)PartialMapSrcIdx; \
158 const ValueMapping *Map = getCopyMapping( \
159 AArch64::RBNameDst##RegBankID, AArch64::RBNameSrc##RegBankID, Size); \
161 assert(Map[0].BreakDown == \
162 &AArch64GenRegisterBankInfo::PartMappings[PartialMapDstIdx] && \
163 Map[0].NumBreakDowns == 1 && #RBNameDst #Size \
164 " Dst is incorrectly initialized"); \
165 assert(Map[1].BreakDown == \
166 &AArch64GenRegisterBankInfo::PartMappings[PartialMapSrcIdx] && \
167 Map[1].NumBreakDowns == 1 && #RBNameSrc #Size \
168 " Src is incorrectly initialized"); \
181 assert(
verify(TRI) &&
"Invalid register bank information");
186 unsigned Size)
const {
195 if (&A == &AArch64::GPRRegBank && &B == &AArch64::FPRRegBank)
198 if (&A == &AArch64::FPRRegBank && &B == &AArch64::GPRRegBank)
207 switch (RC.
getID()) {
208 case AArch64::FPR8RegClassID:
209 case AArch64::FPR16RegClassID:
210 case AArch64::FPR32RegClassID:
211 case AArch64::FPR64RegClassID:
212 case AArch64::FPR128RegClassID:
213 case AArch64::FPR128_loRegClassID:
214 case AArch64::DDRegClassID:
215 case AArch64::DDDRegClassID:
216 case AArch64::DDDDRegClassID:
217 case AArch64::QQRegClassID:
218 case AArch64::QQQRegClassID:
219 case AArch64::QQQQRegClassID:
221 case AArch64::GPR32commonRegClassID:
222 case AArch64::GPR32RegClassID:
223 case AArch64::GPR32spRegClassID:
224 case AArch64::GPR32sponlyRegClassID:
225 case AArch64::GPR32allRegClassID:
226 case AArch64::GPR64commonRegClassID:
227 case AArch64::GPR64RegClassID:
228 case AArch64::GPR64spRegClassID:
229 case AArch64::GPR64sponlyRegClassID:
230 case AArch64::GPR64allRegClassID:
231 case AArch64::tcGPR64RegClassID:
232 case AArch64::WSeqPairsClassRegClassID:
233 case AArch64::XSeqPairsClassRegClassID:
235 case AArch64::CCRRegClassID:
251 case TargetOpcode::G_OR: {
255 if (Size != 32 && Size != 64)
274 case TargetOpcode::G_BITCAST: {
276 if (Size != 32 && Size != 64)
287 getCopyMapping(AArch64::GPRRegBankID, AArch64::GPRRegBankID, Size),
291 getCopyMapping(AArch64::FPRRegBankID, AArch64::FPRRegBankID, Size),
295 copyCost(AArch64::GPRRegBank, AArch64::FPRRegBank, Size),
296 getCopyMapping(AArch64::FPRRegBankID, AArch64::GPRRegBankID, Size),
300 copyCost(AArch64::GPRRegBank, AArch64::FPRRegBank, Size),
301 getCopyMapping(AArch64::GPRRegBankID, AArch64::FPRRegBankID, Size),
310 case TargetOpcode::G_LOAD: {
344 void AArch64RegisterBankInfo::applyMappingImpl(
347 case TargetOpcode::G_OR:
348 case TargetOpcode::G_BITCAST:
349 case TargetOpcode::G_LOAD:
353 "Don't know how to handle that ID");
364 case TargetOpcode::G_FADD:
365 case TargetOpcode::G_FSUB:
366 case TargetOpcode::G_FMUL:
367 case TargetOpcode::G_FDIV:
368 case TargetOpcode::G_FCONSTANT:
369 case TargetOpcode::G_FPEXT:
370 case TargetOpcode::G_FPTRUNC:
377 AArch64RegisterBankInfo::getSameKindOfOperandsMapping(
384 assert(NumOperands <= 3 &&
385 "This code is for instructions with 3 or less operands");
402 for (
unsigned Idx = 1; Idx != NumOperands; ++Idx) {
408 "Operand has incompatible size");
411 assert(IsFPR == OpIsFPR &&
"Operand has incompatible type");
413 #endif // End NDEBUG.
437 case TargetOpcode::G_ADD:
438 case TargetOpcode::G_SUB:
439 case TargetOpcode::G_GEP:
440 case TargetOpcode::G_MUL:
441 case TargetOpcode::G_SDIV:
442 case TargetOpcode::G_UDIV:
444 case TargetOpcode::G_AND:
445 case TargetOpcode::G_OR:
446 case TargetOpcode::G_XOR:
448 case TargetOpcode::G_SHL:
449 case TargetOpcode::G_LSHR:
450 case TargetOpcode::G_ASHR:
452 case TargetOpcode::G_FADD:
453 case TargetOpcode::G_FSUB:
454 case TargetOpcode::G_FMUL:
455 case TargetOpcode::G_FDIV:
456 return getSameKindOfOperandsMapping(MI);
457 case TargetOpcode::G_BITCAST: {
464 DstIsGPR ? AArch64::GPRRegBank : AArch64::FPRRegBank;
466 SrcIsGPR ? AArch64::GPRRegBank : AArch64::FPRRegBank;
481 for (
unsigned Idx = 0; Idx < NumOperands; ++Idx) {
483 if (!MO.isReg() || !MO.getReg())
501 case TargetOpcode::G_SITOFP:
502 case TargetOpcode::G_UITOFP:
505 case TargetOpcode::G_FPTOSI:
506 case TargetOpcode::G_FPTOUI:
509 case TargetOpcode::G_FCMP:
513 case TargetOpcode::G_BITCAST:
515 if (OpRegBankIdx[0] != OpRegBankIdx[1])
521 case TargetOpcode::G_LOAD:
545 case TargetOpcode::G_STORE:
560 for (
unsigned Idx = 0; Idx < NumOperands; ++Idx) {
563 if (!Mapping->isValid())
566 OpdsMapping[Idx] = Mapping;
AArch64RegisterBankInfo(const TargetRegisterInfo &TRI)
void push_back(const T &Elt)
const MachineFunction * getParent() const
Return the MachineFunction containing this basic block.
virtual unsigned copyCost(const RegisterBank &A, const RegisterBank &B, unsigned Size) const
Get the cost of a copy from B to A, or put differently, get the cost of A = COPY B.
const InstructionMapping & getInvalidInstructionMapping() const
Method to get a uniquely generated invalid InstructionMapping.
const InstructionMapping & getInstructionMapping(unsigned ID, unsigned Cost, const ValueMapping *OperandsMapping, unsigned NumOperands) const
Method to get a uniquely generated InstructionMapping.
LLT getType(unsigned VReg) const
Get the low-level type of VReg or LLT{} if VReg is not a generic (target independent) virtual registe...
static const RegisterBankInfo::ValueMapping * getCopyMapping(unsigned DstBankID, unsigned SrcBankID, unsigned Size)
Get the pointer to the ValueMapping of the operands of a copy instruction from the SrcBankID register...
class llvm::RegisterBankInfo GPR
Helper class that represents how the value of an instruction may be mapped and what is the related co...
static bool checkPartialMappingIdx(PartialMappingIdx FirstAlias, PartialMappingIdx LastAlias, ArrayRef< PartialMappingIdx > Order)
unsigned getID() const
Return the register class ID number.
#define CHECK_VALUEMAP(RBName, Size)
This file declares the targeting of the RegisterBankInfo class for AArch64.
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
const TargetRegisterClass * getRegClass(unsigned i) const
Returns the register class associated with the enumeration value.
bool isReg() const
isReg - Tests if this is a MO_Register operand.
unsigned getNumOperands() const
Access to explicit operands of the instruction.
virtual InstructionMappings getInstrAlternativeMappings(const MachineInstr &MI) const
Get the alternative mappings for MI.
#define CHECK_VALUEMAP_3OPS(RBName, Size)
static const MCPhysReg FPR[]
FPR - The set of FP registers that should be allocated for arguments, on Darwin.
const ValueMapping * getOperandsMapping(Iterator Begin, Iterator End) const
Get the uniquely generated array of ValueMapping for the elements of between Begin and End...
unsigned getOpcode() const
Returns the opcode of this MachineInstr.
const MachineBasicBlock * getParent() const
bool verify(const TargetRegisterInfo &TRI) const
Check that information hold by this instance make sense for the given TRI.
unsigned const MachineRegisterInfo * MRI
MachineInstrBuilder & UseMI
static unsigned getSizeInBits(unsigned Reg, const MachineRegisterInfo &MRI, const TargetRegisterInfo &TRI)
Get the size in bits of Reg.
const MachineOperand & getOperand(unsigned i) const
unsigned getID() const
Get the identifier of this register bank.
static const unsigned DefaultMappingID
Identifier used when the related instruction mapping instance is generated by target independent code...
iterator_range< use_instr_iterator > use_instructions(unsigned Reg) const
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
static bool isPreISelGenericFloatingPointOpcode(unsigned Opc)
Returns whether opcode Opc is a pre-isel generic floating-point opcode, having only floating-point op...
Helper class used to get/create the virtual registers that will be used to replace the MachineOperand...
RegisterBank & getRegBank(unsigned ID)
Get the register bank identified by ID.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
static void applyDefaultMapping(const OperandsMapper &OpdMapper)
Helper method to apply something that is like the default mapping.
InstructionMappings getInstrAlternativeMappings(const MachineInstr &MI) const override
Get the alternative mappings for MI.
unsigned copyCost(const RegisterBank &A, const RegisterBank &B, unsigned Size) const override
Get the cost of a copy from B to A, or put differently, get the cost of A = COPY B.
#define CHECK_PARTIALMAP(Idx, ValStartIdx, ValLength, RB)
static unsigned getRegBankBaseIdxOffset(unsigned RBIdx, unsigned Size)
This class implements the register bank concept.
static bool isPreISelGenericOpcode(unsigned Opcode)
Check whether the given Opcode is a generic opcode that is not supposed to appear after ISel...
const InstructionMapping & getInstrMapping() const
The final mapping of the instruction.
bool isValid() const
Check whether this object is valid.
constexpr char Size[]
Key for Kernel::Arg::Metadata::mSize.
llvm_unreachable("Unknown RegBank!")
static const RegisterBankInfo::ValueMapping * getValueMapping(PartialMappingIdx RBIdx, unsigned Size)
Get the pointer to the ValueMapping representing the RegisterBank at RBIdx with a size of Size...
MachineRegisterInfo - Keep track of information for virtual and physical registers, including vreg register classes, use/def chains for registers, etc.
TargetSubtargetInfo - Generic base class for all target subtargets.
Representation of each machine instruction.
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
const InstructionMapping & getInstrMapping(const MachineInstr &MI) const override
Get the mapping of the different operands of MI on the register bank.
unsigned getSize() const
Get the maximal size in bits that fits in this register bank.
unsigned getID() const
Get the ID.
bool covers(const TargetRegisterClass &RC) const
Check whether this register bank covers RC.
MachineInstr * getVRegDef(unsigned Reg) const
getVRegDef - Return the machine instr that defines the specified virtual register or null if none is ...
unsigned getReg() const
getReg - Returns the register number.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
const InstructionMapping & getInstrMappingImpl(const MachineInstr &MI) const
Try to get the mapping of MI.
#define CHECK_VALUEMAP_CROSSREGCPY(RBNameDst, RBNameSrc, Size)
virtual const TargetRegisterInfo * getRegisterInfo() const
getRegisterInfo - If register information is available, return it.
unsigned getSizeInBits() const
Returns the total size of the type. Must only be called on sized types.
const RegisterBank & getRegBankFromRegClass(const TargetRegisterClass &RC) const override
Get a register bank that covers RC.
static RegisterBankInfo::PartialMapping PartMappings[]
MachineInstr & getMI() const