Go to the documentation of this file.
20 #define GET_TARGET_REGBANK_IMPL
21 #include "X86GenRegisterBank.inc"
25 #define GET_TARGET_REGBANK_INFO_IMPL
26 #include "X86GenRegisterBankInfo.def"
33 assert(&X86::GPRRegBank == &RBGPR &&
"Incorrect RegBanks inizalization.");
38 "Subclass not added?");
39 assert(RBGPR.
getSize() == 64 &&
"GPRs should hold up to 64-bit");
46 if (X86::GR8RegClass.hasSubClassEq(&RC) ||
47 X86::GR16RegClass.hasSubClassEq(&RC) ||
48 X86::GR32RegClass.hasSubClassEq(&RC) ||
49 X86::GR64RegClass.hasSubClassEq(&RC) ||
50 X86::LOW32_ADDR_ACCESSRegClass.hasSubClassEq(&RC) ||
51 X86::LOW32_ADDR_ACCESS_RBPRegClass.hasSubClassEq(&RC))
54 if (X86::FR32XRegClass.hasSubClassEq(&RC) ||
55 X86::FR64XRegClass.hasSubClassEq(&RC) ||
56 X86::VR128XRegClass.hasSubClassEq(&RC) ||
57 X86::VR256XRegClass.hasSubClassEq(&RC) ||
58 X86::VR512RegClass.hasSubClassEq(&RC))
110 void X86RegisterBankInfo::getInstrPartialMappingIdxs(
114 unsigned NumOperands =
MI.getNumOperands();
115 for (
unsigned Idx = 0; Idx < NumOperands; ++Idx) {
116 auto &MO =
MI.getOperand(Idx);
118 OpRegBankIdx[Idx] = PMI_None;
124 bool X86RegisterBankInfo::getInstrValueMapping(
129 unsigned NumOperands =
MI.getNumOperands();
130 for (
unsigned Idx = 0; Idx < NumOperands; ++Idx) {
131 if (!
MI.getOperand(Idx).isReg())
135 if (!Mapping->isValid())
138 OpdsMapping[Idx] = Mapping;
144 X86RegisterBankInfo::getSameOperandsMapping(
const MachineInstr &
MI,
149 unsigned NumOperands =
MI.getNumOperands();
152 if (NumOperands != 3 || (Ty !=
MRI.
getType(
MI.getOperand(1).getReg())) ||
164 unsigned Opc =
MI.getOpcode();
175 case TargetOpcode::G_ADD:
176 case TargetOpcode::G_SUB:
177 case TargetOpcode::G_MUL:
178 return getSameOperandsMapping(
MI,
false);
179 case TargetOpcode::G_FADD:
180 case TargetOpcode::G_FSUB:
181 case TargetOpcode::G_FMUL:
182 case TargetOpcode::G_FDIV:
183 return getSameOperandsMapping(
MI,
true);
184 case TargetOpcode::G_SHL:
185 case TargetOpcode::G_LSHR:
186 case TargetOpcode::G_ASHR: {
187 unsigned NumOperands =
MI.getNumOperands();
198 unsigned NumOperands =
MI.getNumOperands();
202 case TargetOpcode::G_FPEXT:
203 case TargetOpcode::G_FPTRUNC:
204 case TargetOpcode::G_FCONSTANT:
206 getInstrPartialMappingIdxs(
MI,
MRI,
true, OpRegBankIdx);
208 case TargetOpcode::G_SITOFP:
209 case TargetOpcode::G_FPTOSI: {
212 auto &Op0 =
MI.getOperand(0);
213 auto &Op1 =
MI.getOperand(1);
217 bool FirstArgIsFP = Opc == TargetOpcode::G_SITOFP;
218 bool SecondArgIsFP = Opc == TargetOpcode::G_FPTOSI;
223 case TargetOpcode::G_FCMP: {
228 "Mismatched operand sizes for G_FCMP");
232 assert((Size == 32 || Size == 64) &&
"Unsupported size for G_FCMP");
235 OpRegBankIdx = {PMI_GPR8,
236 PMI_None, FpRegBank, FpRegBank};
239 case TargetOpcode::G_TRUNC:
240 case TargetOpcode::G_ANYEXT: {
241 auto &Op0 =
MI.getOperand(0);
242 auto &Op1 =
MI.getOperand(1);
251 Opc == TargetOpcode::G_ANYEXT;
253 getInstrPartialMappingIdxs(
MI,
MRI, isFPTrunc || isFPAnyExt,
258 getInstrPartialMappingIdxs(
MI,
MRI,
false, OpRegBankIdx);
264 if (!getInstrValueMapping(
MI, OpRegBankIdx, OpdsMapping))
284 switch (
MI.getOpcode()) {
285 case TargetOpcode::G_LOAD:
286 case TargetOpcode::G_STORE:
287 case TargetOpcode::G_IMPLICIT_DEF: {
290 if (Size != 32 && Size != 64)
293 unsigned NumOperands =
MI.getNumOperands();
297 getInstrPartialMappingIdxs(
MI,
MRI,
true, OpRegBankIdx);
301 if (!getInstrValueMapping(
MI, OpRegBankIdx, OpdsMapping))
307 AltMappings.push_back(&Mapping);
This is an optimization pass for GlobalISel generic memory operations.
void applyMappingImpl(const OperandsMapper &OpdMapper) const override
See RegisterBankInfo::applyMapping.
const InstructionMapping & getInstrMappingImpl(const MachineInstr &MI) const
Try to get the mapping of MI.
MachineRegisterInfo - Keep track of information for virtual and physical registers,...
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
bool isPreISelGenericOpcode(unsigned Opcode)
Check whether the given Opcode is a generic opcode that is not supposed to appear after ISel.
RegisterBank & getRegBank(unsigned ID)
Get the register bank identified by ID.
static void applyDefaultMapping(const OperandsMapper &OpdMapper)
Helper method to apply something that is like the default mapping.
virtual const TargetRegisterInfo * getRegisterInfo() const
getRegisterInfo - If register information is available, return it.
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
bool isValid() const
Check whether this object is valid.
const InstructionMapping & getInstrMapping(const MachineInstr &MI) const override
Get the mapping of the different operands of MI on the register bank.
unsigned const TargetRegisterInfo * TRI
static PartialMappingIdx getPartialMappingIdx(const LLT &Ty, bool isFP)
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
This class implements the register bank concept.
TypeSize getSizeInBits() const
Returns the total size of the type. Must only be called on sized types.
X86RegisterBankInfo(const TargetRegisterInfo &TRI)
virtual InstructionMappings getInstrAlternativeMappings(const MachineInstr &MI) const
Get the alternative mappings for MI.
unsigned getSizeInBits(Register Reg, const MachineRegisterInfo &MRI, const TargetRegisterInfo &TRI) const
Get the size in bits of Reg.
Helper class used to get/create the virtual registers that will be used to replace the MachineOperand...
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.
const RegisterBank & getRegBankFromRegClass(const TargetRegisterClass &RC, LLT) const override
Get a register bank that covers RC.
Representation of each machine instruction.
Helper class that represents how the value of an instruction may be mapped and what is the related co...
static const unsigned DefaultMappingID
Identifier used when the related instruction mapping instance is generated by target independent code...
const ValueMapping * getOperandsMapping(Iterator Begin, Iterator End) const
Get the uniquely generated array of ValueMapping for the elements of between Begin and End.
bool covers(const TargetRegisterClass &RC) const
Check whether this register bank covers RC.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
static const RegisterBankInfo::ValueMapping * getValueMapping(PartialMappingIdx Idx, unsigned NumOperands)
const InstructionMapping & getInstructionMapping(unsigned ID, unsigned Cost, const ValueMapping *OperandsMapping, unsigned NumOperands) const
Method to get a uniquely generated InstructionMapping.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
TargetSubtargetInfo - Generic base class for all target subtargets.
unsigned const MachineRegisterInfo * MRI
InstructionMappings getInstrAlternativeMappings(const MachineInstr &MI) const override
Get the alternative mappings for MI.
unsigned getSize() const
Get the maximal size in bits that fits in this register bank.
const InstructionMapping & getInvalidInstructionMapping() const
Method to get a uniquely generated invalid InstructionMapping.
LLT getType(Register Reg) const
Get the low-level type of Reg or LLT{} if Reg is not a generic (target independent) virtual register.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...