26 #define GET_TARGET_REGBANK_IMPL 27 #include "AMDGPUGenRegisterBank.inc" 30 #include "AMDGPUGenRegisterBankInfo.def" 39 static bool AlreadyInit =
false;
47 assert(&RBSGPR == &AMDGPU::SGPRRegBank);
51 assert(&RBVGPR == &AMDGPU::VGPRRegBank);
62 if (Def->
getOpcode() == AMDGPU::G_CONSTANT) {
75 unsigned Size)
const {
76 if (Dst.
getID() == AMDGPU::SGPRRegBankID &&
77 Src.
getID() == AMDGPU::VGPRRegBankID) {
83 if (Size == 1 && Dst.
getID() == AMDGPU::SCCRegBankID &&
84 (Src.
getID() == AMDGPU::SGPRRegBankID ||
85 Src.
getID() == AMDGPU::VGPRRegBankID ||
86 Src.
getID() == AMDGPU::VCCRegBankID))
111 case TargetOpcode::G_LOAD: {
140 case TargetOpcode::G_ICMP: {
176 case TargetOpcode::G_SELECT: {
196 case TargetOpcode::G_UADDE:
197 case TargetOpcode::G_USUBE:
198 case TargetOpcode::G_SADDE:
199 case TargetOpcode::G_SSUBE: {
221 case AMDGPU::G_BRCOND: {
243 void AMDGPURegisterBankInfo::applyMappingImpl(
256 bool AMDGPURegisterBankInfo::isSALUMapping(
const MachineInstr &
MI)
const {
264 if (Bank->getID() == AMDGPU::VGPRRegBankID)
267 assert(Bank->getID() == AMDGPU::SGPRRegBankID ||
268 Bank->getID() == AMDGPU::SCCRegBankID);
275 AMDGPURegisterBankInfo::getDefaultMappingSOP(
const MachineInstr &MI)
const {
282 unsigned BankID = Size == 1 ? AMDGPU::SCCRegBankID : AMDGPU::SGPRRegBankID;
290 AMDGPURegisterBankInfo::getDefaultMappingVOP(
const MachineInstr &MI)
const {
300 OpdsMapping[OpdIdx++] =
nullptr;
305 unsigned DefaultBankID = Size1 == 1 ?
306 AMDGPU::VCCRegBankID : AMDGPU::VGPRRegBankID;
307 unsigned Bank1 = getRegBankID(Reg1, MRI, *TRI, DefaultBankID);
313 unsigned BankID = Size == 1 ? AMDGPU::VCCRegBankID : AMDGPU::VGPRRegBankID;
322 AMDGPURegisterBankInfo::getDefaultMappingAllVGPR(
const MachineInstr &MI)
const {
337 AMDGPURegisterBankInfo::getInstrMappingForLoad(
const MachineInstr &MI)
const {
358 OpdsMapping[0] = ValMapping;
359 OpdsMapping[1] = PtrMapping;
369 AMDGPURegisterBankInfo::getRegBankID(
unsigned Reg,
401 case AMDGPU::G_XOR: {
404 OpdsMapping[0] = OpdsMapping[1] =
416 case AMDGPU::G_UADDO:
417 case AMDGPU::G_SADDO:
418 case AMDGPU::G_USUBO:
419 case AMDGPU::G_SSUBO:
420 case AMDGPU::G_UADDE:
421 case AMDGPU::G_SADDE:
422 case AMDGPU::G_USUBE:
423 case AMDGPU::G_SSUBE:
424 if (isSALUMapping(MI))
425 return getDefaultMappingSOP(MI);
430 case AMDGPU::G_FPTOSI:
431 case AMDGPU::G_FPTOUI:
434 case AMDGPU::G_SITOFP:
435 case AMDGPU::G_UITOFP:
436 case AMDGPU::G_FPTRUNC:
437 case AMDGPU::G_FEXP2:
438 case AMDGPU::G_FLOG2:
439 case AMDGPU::G_INTRINSIC_TRUNC:
440 case AMDGPU::G_INTRINSIC_ROUND:
441 return getDefaultMappingVOP(MI);
442 case AMDGPU::G_IMPLICIT_DEF: {
447 case AMDGPU::G_FCONSTANT:
448 case AMDGPU::G_CONSTANT:
449 case AMDGPU::G_FRAME_INDEX:
450 case AMDGPU::G_BLOCK_ADDR: {
455 case AMDGPU::G_INSERT: {
456 unsigned BankID = isSALUMapping(MI) ? AMDGPU::SGPRRegBankID :
457 AMDGPU::VGPRRegBankID;
464 OpdsMapping[3] =
nullptr;
467 case AMDGPU::G_EXTRACT: {
473 OpdsMapping[2] =
nullptr;
476 case AMDGPU::G_MERGE_VALUES: {
477 unsigned Bank = isSALUMapping(MI) ?
478 AMDGPU::SGPRRegBankID : AMDGPU::VGPRRegBankID;
488 case AMDGPU::G_BITCAST:
489 case AMDGPU::G_INTTOPTR:
490 case AMDGPU::G_PTRTOINT:
492 case AMDGPU::G_CTLZ_ZERO_UNDEF:
494 case AMDGPU::G_CTTZ_ZERO_UNDEF:
495 case AMDGPU::G_CTPOP:
496 case AMDGPU::G_BSWAP:
498 case AMDGPU::G_FNEG: {
504 case AMDGPU::G_TRUNC: {
507 unsigned Bank = getRegBankID(Src, MRI, *TRI);
516 case AMDGPU::G_ANYEXT: {
521 unsigned SrcBank = getRegBankID(Src, MRI, *TRI,
522 SrcSize == 1 ? AMDGPU::SGPRRegBankID :
523 AMDGPU::VGPRRegBankID);
524 unsigned DstBank = SrcBank;
526 if (SrcBank == AMDGPU::SGPRRegBankID)
527 DstBank = AMDGPU::VGPRRegBankID;
529 DstBank = AMDGPU::SGPRRegBankID;
536 case AMDGPU::G_FCMP: {
540 OpdsMapping[1] =
nullptr;
545 case AMDGPU::G_GEP: {
555 case AMDGPU::G_STORE: {
568 OpdsMapping[0] = ValMapping;
569 OpdsMapping[1] = PtrMapping;
573 case AMDGPU::G_ICMP: {
577 unsigned Op0Bank = Op2Bank == AMDGPU::SGPRRegBankID &&
578 Op3Bank == AMDGPU::SGPRRegBankID ?
579 AMDGPU::SCCRegBankID : AMDGPU::VCCRegBankID;
581 OpdsMapping[1] =
nullptr;
588 case AMDGPU::G_EXTRACT_VECTOR_ELT: {
595 AMDGPU::SGPRRegBankID : AMDGPU::VGPRRegBankID;
605 case AMDGPU::G_INSERT_VECTOR_ELT: {
611 unsigned IdxOp = MI.
getOpcode() == AMDGPU::G_EXTRACT_VECTOR_ELT ? 2 : 3;
613 AMDGPU::SGPRRegBankID : AMDGPU::VGPRRegBankID;
627 case AMDGPU::G_UNMERGE_VALUES: {
628 unsigned Bank = isSALUMapping(MI) ? AMDGPU::SGPRRegBankID :
629 AMDGPU::VGPRRegBankID;
639 case AMDGPU::G_INTRINSIC: {
646 return getDefaultMappingVOP(MI);
654 OpdsMapping[0] = OpdsMapping[2]
661 case AMDGPU::G_INTRINSIC_W_SIDE_EFFECTS: {
666 OpdsMapping[0] =
nullptr;
678 OpdsMapping[0] =
nullptr;
694 case AMDGPU::G_SELECT: {
697 AMDGPU::SGPRRegBankID);
700 bool SGPRSrcs = Op1Bank == AMDGPU::SCCRegBankID &&
701 Op2Bank == AMDGPU::SGPRRegBankID &&
702 Op3Bank == AMDGPU::SGPRRegBankID;
703 unsigned Bank = SGPRSrcs ? AMDGPU::SGPRRegBankID : AMDGPU::VGPRRegBankID;
704 Op1Bank = SGPRSrcs ? AMDGPU::SCCRegBankID : AMDGPU::VCCRegBankID;
713 return getInstrMappingForLoad(MI);
715 case AMDGPU::G_ATOMICRMW_XCHG:
716 case AMDGPU::G_ATOMICRMW_ADD:
717 case AMDGPU::G_ATOMICRMW_SUB:
718 case AMDGPU::G_ATOMICRMW_AND:
719 case AMDGPU::G_ATOMICRMW_OR:
720 case AMDGPU::G_ATOMICRMW_XOR:
721 case AMDGPU::G_ATOMICRMW_MAX:
722 case AMDGPU::G_ATOMICRMW_MIN:
723 case AMDGPU::G_ATOMICRMW_UMAX:
724 case AMDGPU::G_ATOMICRMW_UMIN:
725 case AMDGPU::G_ATOMIC_CMPXCHG: {
726 return getDefaultMappingAllVGPR(MI);
728 case AMDGPU::G_BRCOND: {
730 AMDGPU::SGPRRegBankID);
732 if (Bank != AMDGPU::SCCRegBankID)
733 Bank = AMDGPU::VCCRegBankID;
const InstructionMapping & getInstrMapping(const MachineInstr &MI) const override
This function must return a legal mapping, because AMDGPURegisterBankInfo::getInstrAlternativeMapping...
Interface definition for SIRegisterInfo.
MachineInstr * getParent()
getParent - Return the instruction that this operand belongs to.
const ValueMapping * getOperandsMapping(Iterator Begin, Iterator End) const
Get the uniquely generated array of ValueMapping for the elements of between Begin and End...
GCNRegPressure max(const GCNRegPressure &P1, const GCNRegPressure &P2)
This file declares the targeting of the RegisterBankInfo class for AMDGPU.
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.
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.
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...
unsigned const TargetRegisterInfo * TRI
bool isIntrinsicID() const
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.
A description of a memory reference used in the backend.
unsigned getNumOperands() const
Retuns the total number of operands.
unsigned getOpcode() const
Returns the opcode of this MachineInstr.
static bool isConstant(const MachineOperand &MO, int64_t &C)
bool isSGPRClass(const TargetRegisterClass *RC) const
MachineInstr * getVRegDef(unsigned Reg) const
getVRegDef - Return the machine instr that defines the specified virtual register or null if none is ...
static bool isInstrUniform(const MachineInstr &MI)
unsigned const MachineRegisterInfo * MRI
const InstructionMapping & getInvalidInstructionMapping() const
Method to get a uniquely generated invalid InstructionMapping.
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
This file contains the declarations for the subclasses of Constant, which represent the different fla...
static bool isUniformMMO(const MachineMemOperand *MMO)
bool hasOneMemOperand() const
Return true if this instruction has exactly one MachineMemOperand.
const ValueMapping & getValueMapping(unsigned StartIdx, unsigned Length, const RegisterBank &RegBank) const
The most common ValueMapping consists of a single PartialMapping.
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
bool isValid() const
Check whether this object is valid.
mmo_iterator memoperands_begin() const
Access to memory operands of the instruction.
RegisterBank & getRegBank(unsigned ID)
Get the register bank identified by ID.
MachineOperand class - Representation of each machine instruction operand.
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.
Intrinsic::ID getIntrinsicID() const
This class implements the register bank concept.
Helper struct that represents how a value is mapped through different register banks.
AMDGPURegisterBankInfo(const TargetRegisterInfo &TRI)
InstructionMappings getInstrAlternativeMappings(const MachineInstr &MI) const override
Get the alternative mappings for MI.
const MachineBasicBlock * getParent() const
Contains the definition of a TargetInstrInfo class that is common to all AMD GPUs.
MachineRegisterInfo - Keep track of information for virtual and physical registers, including vreg register classes, use/def chains for registers, etc.
Provides AMDGPU specific target descriptions.
Representation of each machine instruction.
const MachineFunction * getParent() const
Return the MachineFunction containing this basic block.
const RegisterBank & getRegBankFromRegClass(const TargetRegisterClass &RC) const override
Get a register bank that covers RC.
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
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.
This class provides the information for the target register banks.
bool isReg() const
isReg - Tests if this is a MO_Register operand.
Helper struct that represents how a value is mapped through different register banks.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
unsigned getSizeInBits(unsigned Reg, const MachineRegisterInfo &MRI, const TargetRegisterInfo &TRI) const
Get the size in bits of Reg.
int64_t getSExtValue() const
Return the constant as a 64-bit integer value after it has been sign extended as appropriate for the ...
const MachineOperand & getOperand(unsigned i) const
const ConstantInt * getCImm() const
unsigned getID() const
Get the identifier of this register bank.