32 #define GET_TARGET_REGBANK_IMPL 33 #include "AArch64GenRegisterBank.inc" 36 #include "AArch64GenRegisterBankInfo.def" 42 static bool AlreadyInit =
false;
54 assert(&AArch64::GPRRegBank == &RBGPR &&
55 "The order in RegBanks is messed up");
59 assert(&AArch64::FPRRegBank == &RBFPR &&
60 "The order in RegBanks is messed up");
64 assert(&AArch64::CCRegBank == &RBCCR &&
"The order in RegBanks is messed up");
69 "Subclass not added?");
70 assert(RBGPR.
getSize() == 64 &&
"GPRs should hold up to 64-bit");
75 "Subclass not added?");
77 "Subclass not added?");
79 "FPRs should hold up to 512-bit via QQQQ sequence");
83 assert(RBCCR.
getSize() == 32 &&
"CCR should hold up to 32-bit");
89 "PartialMappingIdx's are incorrectly ordered");
93 "PartialMappingIdx's are incorrectly ordered");
96 #define CHECK_PARTIALMAP(Idx, ValStartIdx, ValLength, RB) \ 99 checkPartialMap(PartialMappingIdx::Idx, ValStartIdx, ValLength, RB) && \ 100 #Idx " is incorrectly initialized"); \ 113 #define CHECK_VALUEMAP_IMPL(RBName, Size, Offset) \ 115 assert(checkValueMapImpl(PartialMappingIdx::PMI_##RBName##Size, \ 116 PartialMappingIdx::PMI_First##RBName, Size, \ 118 #RBName #Size " " #Offset " is incorrectly initialized"); \ 121 #define CHECK_VALUEMAP(RBName, Size) CHECK_VALUEMAP_IMPL(RBName, Size, 0) 134 #define CHECK_VALUEMAP_3OPS(RBName, Size) \ 136 CHECK_VALUEMAP_IMPL(RBName, Size, 0); \ 137 CHECK_VALUEMAP_IMPL(RBName, Size, 1); \ 138 CHECK_VALUEMAP_IMPL(RBName, Size, 2); \ 149 #define CHECK_VALUEMAP_CROSSREGCPY(RBNameDst, RBNameSrc, Size) \ 151 unsigned PartialMapDstIdx = PMI_##RBNameDst##Size - PMI_Min; \ 152 unsigned PartialMapSrcIdx = PMI_##RBNameSrc##Size - PMI_Min; \ 153 (void)PartialMapDstIdx; \ 154 (void)PartialMapSrcIdx; \ 155 const ValueMapping *Map = getCopyMapping( \ 156 AArch64::RBNameDst##RegBankID, AArch64::RBNameSrc##RegBankID, Size); \ 158 assert(Map[0].BreakDown == \ 159 &AArch64GenRegisterBankInfo::PartMappings[PartialMapDstIdx] && \ 160 Map[0].NumBreakDowns == 1 && #RBNameDst #Size \ 161 " Dst is incorrectly initialized"); \ 162 assert(Map[1].BreakDown == \ 163 &AArch64GenRegisterBankInfo::PartMappings[PartialMapSrcIdx] && \ 164 Map[1].NumBreakDowns == 1 && #RBNameSrc #Size \ 165 " Src is incorrectly initialized"); \ 178 #define CHECK_VALUEMAP_FPEXT(DstSize, SrcSize) \ 180 unsigned PartialMapDstIdx = PMI_FPR##DstSize - PMI_Min; \ 181 unsigned PartialMapSrcIdx = PMI_FPR##SrcSize - PMI_Min; \ 182 (void)PartialMapDstIdx; \ 183 (void)PartialMapSrcIdx; \ 184 const ValueMapping *Map = getFPExtMapping(DstSize, SrcSize); \ 186 assert(Map[0].BreakDown == \ 187 &AArch64GenRegisterBankInfo::PartMappings[PartialMapDstIdx] && \ 188 Map[0].NumBreakDowns == 1 && "FPR" #DstSize \ 189 " Dst is incorrectly initialized"); \ 190 assert(Map[1].BreakDown == \ 191 &AArch64GenRegisterBankInfo::PartMappings[PartialMapSrcIdx] && \ 192 Map[1].NumBreakDowns == 1 && "FPR" #SrcSize \ 193 " Src is incorrectly initialized"); \ 202 assert(
verify(TRI) &&
"Invalid register bank information");
207 unsigned Size)
const {
216 if (&A == &AArch64::GPRRegBank && &B == &AArch64::FPRRegBank)
219 if (&A == &AArch64::FPRRegBank && &B == &AArch64::GPRRegBank)
228 switch (RC.
getID()) {
229 case AArch64::FPR8RegClassID:
230 case AArch64::FPR16RegClassID:
231 case AArch64::FPR32RegClassID:
232 case AArch64::FPR64RegClassID:
233 case AArch64::FPR128RegClassID:
234 case AArch64::FPR128_loRegClassID:
235 case AArch64::DDRegClassID:
236 case AArch64::DDDRegClassID:
237 case AArch64::DDDDRegClassID:
238 case AArch64::QQRegClassID:
239 case AArch64::QQQRegClassID:
240 case AArch64::QQQQRegClassID:
242 case AArch64::GPR32commonRegClassID:
243 case AArch64::GPR32RegClassID:
244 case AArch64::GPR32spRegClassID:
245 case AArch64::GPR32sponlyRegClassID:
246 case AArch64::GPR32allRegClassID:
247 case AArch64::GPR64commonRegClassID:
248 case AArch64::GPR64RegClassID:
249 case AArch64::GPR64spRegClassID:
250 case AArch64::GPR64sponlyRegClassID:
251 case AArch64::GPR64allRegClassID:
252 case AArch64::tcGPR64RegClassID:
253 case AArch64::WSeqPairsClassRegClassID:
254 case AArch64::XSeqPairsClassRegClassID:
256 case AArch64::CCRRegClassID:
272 case TargetOpcode::G_OR: {
276 if (Size != 32 && Size != 64)
295 case TargetOpcode::G_BITCAST: {
297 if (Size != 32 && Size != 64)
308 getCopyMapping(AArch64::GPRRegBankID, AArch64::GPRRegBankID, Size),
312 getCopyMapping(AArch64::FPRRegBankID, AArch64::FPRRegBankID, Size),
316 copyCost(AArch64::GPRRegBank, AArch64::FPRRegBank, Size),
317 getCopyMapping(AArch64::FPRRegBankID, AArch64::GPRRegBankID, Size),
321 copyCost(AArch64::GPRRegBank, AArch64::FPRRegBank, Size),
322 getCopyMapping(AArch64::GPRRegBankID, AArch64::FPRRegBankID, Size),
331 case TargetOpcode::G_LOAD: {
365 void AArch64RegisterBankInfo::applyMappingImpl(
368 case TargetOpcode::G_OR:
369 case TargetOpcode::G_BITCAST:
370 case TargetOpcode::G_LOAD:
374 "Don't know how to handle that ID");
385 case TargetOpcode::G_FADD:
386 case TargetOpcode::G_FSUB:
387 case TargetOpcode::G_FMUL:
388 case TargetOpcode::G_FDIV:
389 case TargetOpcode::G_FCONSTANT:
390 case TargetOpcode::G_FPEXT:
391 case TargetOpcode::G_FPTRUNC:
392 case TargetOpcode::G_FCEIL:
399 AArch64RegisterBankInfo::getSameKindOfOperandsMapping(
406 assert(NumOperands <= 3 &&
407 "This code is for instructions with 3 or less operands");
424 for (
unsigned Idx = 1; Idx != NumOperands; ++Idx) {
430 "Operand has incompatible size");
433 assert(IsFPR == OpIsFPR &&
"Operand has incompatible type");
435 #endif // End NDEBUG. 448 Opc == TargetOpcode::G_PHI) {
463 case TargetOpcode::G_ADD:
464 case TargetOpcode::G_SUB:
465 case TargetOpcode::G_GEP:
466 case TargetOpcode::G_MUL:
467 case TargetOpcode::G_SDIV:
468 case TargetOpcode::G_UDIV:
470 case TargetOpcode::G_AND:
471 case TargetOpcode::G_OR:
472 case TargetOpcode::G_XOR:
474 case TargetOpcode::G_SHL:
475 case TargetOpcode::G_LSHR:
476 case TargetOpcode::G_ASHR:
478 case TargetOpcode::G_FADD:
479 case TargetOpcode::G_FSUB:
480 case TargetOpcode::G_FMUL:
481 case TargetOpcode::G_FDIV:
482 return getSameKindOfOperandsMapping(MI);
483 case TargetOpcode::G_FPEXT: {
491 case TargetOpcode::COPY: {
507 assert(DstRB && SrcRB &&
"Both RegBank were nullptr");
518 case TargetOpcode::G_BITCAST: {
525 DstIsGPR ? AArch64::GPRRegBank : AArch64::FPRRegBank;
527 SrcIsGPR ? AArch64::GPRRegBank : AArch64::FPRRegBank;
532 Opc == TargetOpcode::G_BITCAST ? 2 : 1);
543 for (
unsigned Idx = 0; Idx < NumOperands; ++Idx) {
545 if (!MO.isReg() || !MO.getReg())
564 case TargetOpcode::G_SITOFP:
565 case TargetOpcode::G_UITOFP:
568 case TargetOpcode::G_FPTOSI:
569 case TargetOpcode::G_FPTOUI:
572 case TargetOpcode::G_FCMP:
576 case TargetOpcode::G_BITCAST:
578 if (OpRegBankIdx[0] != OpRegBankIdx[1])
584 case TargetOpcode::G_LOAD:
591 if (OpRegBankIdx[0] != PMI_FirstGPR)
603 unsigned UseOpc =
UseMI.getOpcode();
609 ((UseOpc == TargetOpcode::COPY ||
UseMI.isPHI()) &&
611 &AArch64::FPRRegBank)) {
617 case TargetOpcode::G_STORE:
619 if (OpRegBankIdx[0] == PMI_FirstGPR) {
630 ((DefOpc == TargetOpcode::COPY || DefMI->
isPHI()) &&
632 &AArch64::FPRRegBank))
633 OpRegBankIdx[0] = PMI_FirstFPR;
640 for (
unsigned Idx = 0; Idx < NumOperands; ++Idx) {
643 if (!Mapping->isValid())
646 OpdsMapping[Idx] = Mapping;
AArch64RegisterBankInfo(const TargetRegisterInfo &TRI)
const ValueMapping * getOperandsMapping(Iterator Begin, Iterator End) const
Get the uniquely generated array of ValueMapping for the elements of between Begin and End...
This class represents lattice values for constants.
const InstructionMapping & getInstructionMapping(unsigned ID, unsigned Cost, const ValueMapping *OperandsMapping, unsigned NumOperands) const
Method to get a uniquely generated InstructionMapping.
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...
virtual const TargetRegisterInfo * getRegisterInfo() const
getRegisterInfo - If register information is available, return it.
class llvm::RegisterBankInfo GPR
Helper class that represents how the value of an instruction may be mapped and what is the related co...
void push_back(const T &Elt)
unsigned getReg() const
getReg - Returns the register number.
static bool checkPartialMappingIdx(PartialMappingIdx FirstAlias, PartialMappingIdx LastAlias, ArrayRef< PartialMappingIdx > Order)
LLT getType(unsigned Reg) const
Get the low-level type of Reg or LLT{} if Reg is not a generic (target independent) virtual register...
Helper class used to get/create the virtual registers that will be used to replace the MachineOperand...
#define CHECK_VALUEMAP(RBName, Size)
unsigned const TargetRegisterInfo * TRI
const TargetRegisterClass * getRegClass(unsigned i) const
Returns the register class associated with the enumeration value.
bool covers(const TargetRegisterClass &RC) const
Check whether this register bank covers RC.
This file declares the targeting of the RegisterBankInfo class for AArch64.
unsigned getNumOperands() const
Retuns the total number of operands.
const InstructionMapping & getInstrMapping() const
The final mapping of the instruction.
unsigned getOpcode() const
Returns the opcode of this MachineInstr.
unsigned getID() const
Return the register class ID number.
MachineInstr * getVRegDef(unsigned Reg) const
getVRegDef - Return the machine instr that defines the specified virtual register or null if none is ...
#define CHECK_VALUEMAP_3OPS(RBName, Size)
static const MCPhysReg FPR[]
FPR - The set of FP registers that should be allocated for arguments, on Darwin.
#define CHECK_VALUEMAP_FPEXT(DstSize, SrcSize)
static const RegisterBankInfo::ValueMapping * getFPExtMapping(unsigned DstSize, unsigned SrcSize)
Get the instruction mapping for G_FPEXT.
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
unsigned const MachineRegisterInfo * MRI
const InstructionMapping & getInvalidInstructionMapping() const
Method to get a uniquely generated invalid InstructionMapping.
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
MachineInstrBuilder & UseMI
static const unsigned DefaultMappingID
Identifier used when the related instruction mapping instance is generated by target independent code...
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...
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
bool verify(const TargetRegisterInfo &TRI) const
Check that information hold by this instance make sense for the given TRI.
bool isValid() const
Check whether this object is valid.
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.
MachineInstr & getMI() const
MachineInstrBuilder MachineInstrBuilder & DefMI
InstructionMappings getInstrAlternativeMappings(const MachineInstr &MI) const override
Get the alternative mappings for MI.
unsigned getSizeInBits() const
Returns the total size of the type. Must only be called on sized types.
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.
unsigned getID() const
Get the ID.
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...
const MachineBasicBlock * getParent() const
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.
static bool isPhysicalRegister(unsigned Reg)
Return true if the specified register number is in the physical register namespace.
const MachineFunction * getParent() const
Return the MachineFunction containing this basic block.
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.
virtual InstructionMappings getInstrAlternativeMappings(const MachineInstr &MI) const
Get the alternative mappings for MI.
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 & getInstrMappingImpl(const MachineInstr &MI) const
Try to get the mapping of MI.
bool isReg() const
isReg - Tests if this is a MO_Register operand.
iterator_range< use_instr_iterator > use_instructions(unsigned Reg) const
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
unsigned getSize() const
Get the maximal size in bits that fits in this register bank.
bool isPreISelGenericOpcode(unsigned Opcode)
Check whether the given Opcode is a generic opcode that is not supposed to appear after ISel...
unsigned getSizeInBits(unsigned Reg, const MachineRegisterInfo &MRI, const TargetRegisterInfo &TRI) const
Get the size in bits of Reg.
#define CHECK_VALUEMAP_CROSSREGCPY(RBNameDst, RBNameSrc, Size)
const RegisterBank & getRegBankFromRegClass(const TargetRegisterClass &RC) const override
Get a register bank that covers RC.
const MachineOperand & getOperand(unsigned i) const
static RegisterBankInfo::PartialMapping PartMappings[]
unsigned getID() const
Get the identifier of this register bank.