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)
82 if (Size == 1 && Dst.
getID() == AMDGPU::SCCRegBankID &&
83 Src.
getID() == AMDGPU::SGPRRegBankID)
108 case TargetOpcode::G_LOAD: {
137 case TargetOpcode::G_ICMP: {
179 void AMDGPURegisterBankInfo::applyMappingImpl(
192 bool AMDGPURegisterBankInfo::isSALUMapping(
const MachineInstr &
MI)
const {
198 if (Bank && Bank->
getID() != AMDGPU::SGPRRegBankID)
205 AMDGPURegisterBankInfo::getDefaultMappingSOP(
const MachineInstr &MI)
const {
219 AMDGPURegisterBankInfo::getDefaultMappingVOP(
const MachineInstr &MI)
const {
229 OpdsMapping[OpdIdx++] =
nullptr;
233 unsigned Bank1 = getRegBankID(Reg1, MRI, *TRI);
246 AMDGPURegisterBankInfo::getInstrMappingForLoad(
const MachineInstr &MI)
const {
267 OpdsMapping[0] = ValMapping;
268 OpdsMapping[1] = PtrMapping;
278 AMDGPURegisterBankInfo::getRegBankID(
unsigned Reg,
314 if (isSALUMapping(MI))
315 return getDefaultMappingSOP(MI);
319 case AMDGPU::G_FPTOSI:
320 case AMDGPU::G_FPTOUI:
322 return getDefaultMappingVOP(MI);
323 case AMDGPU::G_IMPLICIT_DEF: {
328 case AMDGPU::G_FCONSTANT:
329 case AMDGPU::G_CONSTANT: {
334 case AMDGPU::G_EXTRACT: {
340 OpdsMapping[2] =
nullptr;
343 case AMDGPU::G_MERGE_VALUES: {
344 unsigned Bank = isSALUMapping(MI) ?
345 AMDGPU::SGPRRegBankID : AMDGPU::VGPRRegBankID;
355 case AMDGPU::G_BITCAST: {
361 case AMDGPU::G_TRUNC: {
364 unsigned Bank = getRegBankID(Src, MRI, *TRI);
371 case AMDGPU::G_ZEXT: {
376 unsigned SrcBank = getRegBankID(Src, MRI, *TRI,
377 SrcSize == 1 ? AMDGPU::SGPRRegBankID :
378 AMDGPU::VGPRRegBankID);
379 unsigned DstBank = SrcBank;
381 if (SrcBank == AMDGPU::SGPRRegBankID)
382 DstBank = AMDGPU::VGPRRegBankID;
384 DstBank = AMDGPU::SGPRRegBankID;
391 case AMDGPU::G_FCMP: {
395 OpdsMapping[1] =
nullptr;
400 case AMDGPU::G_GEP: {
410 case AMDGPU::G_STORE: {
423 OpdsMapping[0] = ValMapping;
424 OpdsMapping[1] = PtrMapping;
428 case AMDGPU::G_ICMP: {
432 unsigned Op0Bank = Op2Bank == AMDGPU::SGPRRegBankID &&
433 Op3Bank == AMDGPU::SGPRRegBankID ?
434 AMDGPU::SCCRegBankID : AMDGPU::VGPRRegBankID;
436 OpdsMapping[1] =
nullptr;
443 case AMDGPU::G_EXTRACT_VECTOR_ELT: {
450 AMDGPU::SGPRRegBankID : AMDGPU::VGPRRegBankID;
460 case AMDGPU::G_INSERT_VECTOR_ELT: {
466 unsigned IdxOp = MI.
getOpcode() == AMDGPU::G_EXTRACT_VECTOR_ELT ? 2 : 3;
468 AMDGPU::SGPRRegBankID : AMDGPU::VGPRRegBankID;
482 case AMDGPU::G_INTRINSIC: {
488 case Intrinsic::amdgcn_cvt_pkrtz:
489 return getDefaultMappingVOP(MI);
490 case Intrinsic::amdgcn_kernarg_segment_ptr: {
498 case AMDGPU::G_INTRINSIC_W_SIDE_EFFECTS: {
502 case Intrinsic::amdgcn_exp_compr:
503 OpdsMapping[0] =
nullptr;
514 case Intrinsic::amdgcn_exp:
515 OpdsMapping[0] =
nullptr;
532 return getInstrMappingForLoad(MI);
const InstructionMapping & getInstrMapping(const MachineInstr &MI) const override
This function must return a legal mapping, because AMDGPURegisterBankInfo::getInstrAlternativeMapping...
void push_back(const T &Elt)
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.
Compute iterated dominance frontiers using a linear time algorithm.
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...
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
Access to explicit operands of the instruction.
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.
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...
LLVM_READONLY APFloat maxnum(const APFloat &A, const APFloat &B)
Implements IEEE maxNum semantics.
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.
constexpr char Size[]
Key for Kernel::Arg::Metadata::mSize.
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
LLVM_READONLY APFloat minnum(const APFloat &A, const APFloat &B)
Implements IEEE minNum semantics.
unsigned getID() const
Get the identifier of this register bank.