Thanks to visit codestin.com
Credit goes to llvm.org

LLVM 22.0.0git
AMDGPUInstructionSelector.cpp File Reference

This file implements the targeting of the InstructionSelector class for AMDGPU. More...

Go to the source code of this file.

Classes

class  SearchOptions
 This is used to control valid status that current MI supports. More...

Macros

#define DEBUG_TYPE   "amdgpu-isel"
#define GET_GLOBALISEL_IMPL
#define AMDGPUSubtarget   GCNSubtarget
#define GET_GLOBALISEL_PREDICATES_INIT
#define GET_GLOBALISEL_TEMPORARIES_INIT

Enumerations

enum class  SrcStatus {
  IS_SAME , IS_UPPER_HALF , IS_LOWER_HALF , IS_UPPER_HALF_NEG ,
  IS_LOWER_HALF_NEG , IS_HI_NEG , IS_LO_NEG , IS_BOTH_NEG ,
  INVALID , NEG_START = IS_UPPER_HALF_NEG , NEG_END = IS_BOTH_NEG , HALF_START = IS_UPPER_HALF ,
  HALF_END = IS_LOWER_HALF_NEG
}
enum class  TypeClass { VECTOR_OF_TWO , SCALAR , NONE_OF_LISTED }

Functions

static Register getWaveAddress (const MachineInstr *Def)
static unsigned getLogicalBitOpcode (unsigned Opc, bool Is64)
static int getV_CMPOpcode (CmpInst::Predicate P, unsigned Size, const GCNSubtarget &ST)
static bool isLaneMaskFromSameBlock (Register Reg, MachineRegisterInfo &MRI, MachineBasicBlock *MBB)
static unsigned gwsIntrinToOpcode (unsigned IntrID)
static bool parseTexFail (uint64_t TexFailCtrl, bool &TFE, bool &LWE, bool &IsTexFail)
static bool shouldUseAndMask (unsigned Size, unsigned &Mask)
static Register stripCopy (Register Reg, MachineRegisterInfo &MRI)
static Register stripBitCast (Register Reg, MachineRegisterInfo &MRI)
static bool isExtractHiElt (MachineRegisterInfo &MRI, Register In, Register &Out)
static bool isConstant (const MachineInstr &MI)
static bool isVCmpResult (Register Reg, MachineRegisterInfo &MRI)
static std::pair< Register, unsignedcomputeIndirectRegIndex (MachineRegisterInfo &MRI, const SIRegisterInfo &TRI, const TargetRegisterClass *SuperRC, Register IdxReg, unsigned EltSize, GISelValueTracking &ValueTracking)
 Return the register to use for the index value, and the subregister to use for the indirectly accessed register.
static std::pair< unsigned, uint8_tBitOp3_Op (Register R, SmallVectorImpl< Register > &Src, const MachineRegisterInfo &MRI)
static bool isTruncHalf (const MachineInstr *MI, const MachineRegisterInfo &MRI)
 Test if the MI is truncating to half, such as reg0:n = G_TRUNC reg1:2n
static bool isLshrHalf (const MachineInstr *MI, const MachineRegisterInfo &MRI)
 Test if the MI is logic shift right with half bits, such as reg0:2n =G_LSHR reg1:2n, CONST(n)
static bool isShlHalf (const MachineInstr *MI, const MachineRegisterInfo &MRI)
 Test if the MI is shift left with half bits, such as reg0:2n =G_SHL reg1:2n, CONST(n)
static bool isUnmergeHalf (const MachineInstr *MI, const MachineRegisterInfo &MRI)
 Test function, if the MI is reg0:n, reg1:n = G_UNMERGE_VALUES reg2:2n
static TypeClass isVectorOfTwoOrScalar (Register Reg, const MachineRegisterInfo &MRI)
static SrcStatus getNegStatus (Register Reg, SrcStatus S, const MachineRegisterInfo &MRI)
static std::optional< std::pair< Register, SrcStatus > > calcNextStatus (std::pair< Register, SrcStatus > Curr, const MachineRegisterInfo &MRI)
static SmallVector< std::pair< Register, SrcStatus > > getSrcStats (Register Reg, const MachineRegisterInfo &MRI, SearchOptions SO, int MaxDepth=3)
static std::pair< Register, SrcStatusgetLastSameOrNeg (Register Reg, const MachineRegisterInfo &MRI, SearchOptions SO, int MaxDepth=3)
static bool isSameBitWidth (Register Reg1, Register Reg2, const MachineRegisterInfo &MRI)
static unsigned updateMods (SrcStatus HiStat, SrcStatus LoStat, unsigned Mods)
static bool isValidToPack (SrcStatus HiStat, SrcStatus LoStat, Register NewReg, Register RootReg, const SIInstrInfo &TII, const MachineRegisterInfo &MRI)
static bool checkRB (Register Reg, unsigned int RBNo, const AMDGPURegisterBankInfo &RBI, const MachineRegisterInfo &MRI, const TargetRegisterInfo &TRI)
static Register getLegalRegBank (Register NewReg, Register RootReg, const AMDGPURegisterBankInfo &RBI, MachineRegisterInfo &MRI, const TargetRegisterInfo &TRI, const SIInstrInfo &TII)
static Register buildRegSequence (SmallVectorImpl< Register > &Elts, MachineInstr *InsertPt, MachineRegisterInfo &MRI)
static void selectWMMAModsNegAbs (unsigned ModOpcode, unsigned &Mods, SmallVectorImpl< Register > &Elts, Register &Src, MachineInstr *InsertPt, MachineRegisterInfo &MRI)
static bool isNoUnsignedWrap (MachineInstr *Addr)
static void addZeroImm (MachineInstrBuilder &MIB)
static Register buildRSRC (MachineIRBuilder &B, MachineRegisterInfo &MRI, uint32_t FormatLo, uint32_t FormatHi, Register BasePtr)
 Return a resource descriptor for use with an arbitrary 64-bit pointer.
static Register buildAddr64RSrc (MachineIRBuilder &B, MachineRegisterInfo &MRI, const SIInstrInfo &TII, Register BasePtr)
static Register buildOffsetSrc (MachineIRBuilder &B, MachineRegisterInfo &MRI, const SIInstrInfo &TII, Register BasePtr)
static std::optional< uint64_tgetConstantZext32Val (Register Reg, const MachineRegisterInfo &MRI)
 Get an immediate that must be 32-bits, and treated as zero extended.
unsigned getNamedBarrierOp (bool HasInlineConst, Intrinsic::ID IntrID)

Detailed Description

This file implements the targeting of the InstructionSelector class for AMDGPU.

Todo
This should be generated by TableGen.

Definition in file AMDGPUInstructionSelector.cpp.

Macro Definition Documentation

◆ AMDGPUSubtarget

Definition at line 38 of file AMDGPUInstructionSelector.cpp.

◆ DEBUG_TYPE

#define DEBUG_TYPE   "amdgpu-isel"

Definition at line 32 of file AMDGPUInstructionSelector.cpp.

◆ GET_GLOBALISEL_IMPL

#define GET_GLOBALISEL_IMPL

Definition at line 37 of file AMDGPUInstructionSelector.cpp.

◆ GET_GLOBALISEL_PREDICATES_INIT

#define GET_GLOBALISEL_PREDICATES_INIT

◆ GET_GLOBALISEL_TEMPORARIES_INIT

#define GET_GLOBALISEL_TEMPORARIES_INIT

Enumeration Type Documentation

◆ SrcStatus

enum class SrcStatus
strong
Enumerator
IS_SAME 
IS_UPPER_HALF 
IS_LOWER_HALF 
IS_UPPER_HALF_NEG 
IS_LOWER_HALF_NEG 
IS_HI_NEG 
IS_LO_NEG 
IS_BOTH_NEG 
INVALID 
NEG_START 
NEG_END 
HALF_START 
HALF_END 

Definition at line 4379 of file AMDGPUInstructionSelector.cpp.

◆ TypeClass

enum class TypeClass
strong
Enumerator
VECTOR_OF_TWO 
SCALAR 
NONE_OF_LISTED 

Definition at line 4451 of file AMDGPUInstructionSelector.cpp.

Function Documentation

◆ addZeroImm()

void addZeroImm ( MachineInstrBuilder & MIB)
static

◆ BitOp3_Op()

◆ buildAddr64RSrc()

Register buildAddr64RSrc ( MachineIRBuilder & B,
MachineRegisterInfo & MRI,
const SIInstrInfo & TII,
Register BasePtr )
static

Definition at line 6335 of file AMDGPUInstructionSelector.cpp.

References B(), buildRSRC(), llvm::Hi_32(), MRI, and TII.

◆ buildOffsetSrc()

Register buildOffsetSrc ( MachineIRBuilder & B,
MachineRegisterInfo & MRI,
const SIInstrInfo & TII,
Register BasePtr )
static

Definition at line 6344 of file AMDGPUInstructionSelector.cpp.

References B(), buildRSRC(), llvm::Hi_32(), MRI, and TII.

◆ buildRegSequence()

◆ buildRSRC()

Register buildRSRC ( MachineIRBuilder & B,
MachineRegisterInfo & MRI,
uint32_t FormatLo,
uint32_t FormatHi,
Register BasePtr )
static

Return a resource descriptor for use with an arbitrary 64-bit pointer.

If BasePtr is not valid, a null base pointer will be used.

Definition at line 6292 of file AMDGPUInstructionSelector.cpp.

References B(), and MRI.

Referenced by buildAddr64RSrc(), and buildOffsetSrc().

◆ calcNextStatus()

std::optional< std::pair< Register, SrcStatus > > calcNextStatus ( std::pair< Register, SrcStatus > Curr,
const MachineRegisterInfo & MRI )
static

◆ checkRB()

◆ computeIndirectRegIndex()

std::pair< Register, unsigned > computeIndirectRegIndex ( MachineRegisterInfo & MRI,
const SIRegisterInfo & TRI,
const TargetRegisterClass * SuperRC,
Register IdxReg,
unsigned EltSize,
GISelValueTracking & ValueTracking )
static

Return the register to use for the index value, and the subregister to use for the indirectly accessed register.

Definition at line 3179 of file AMDGPUInstructionSelector.cpp.

References assert(), llvm::AMDGPU::getBaseWithConstantOffset(), MRI, llvm::Offset, llvm::ArrayRef< T >::size(), and TRI.

◆ getConstantZext32Val()

std::optional< uint64_t > getConstantZext32Val ( Register Reg,
const MachineRegisterInfo & MRI )
static

Get an immediate that must be 32-bits, and treated as zero extended.

Definition at line 6565 of file AMDGPUInstructionSelector.cpp.

References llvm::getIConstantVRegSExtVal(), llvm::isInt(), llvm::Lo_32(), MRI, and Reg.

◆ getLastSameOrNeg()

std::pair< Register, SrcStatus > getLastSameOrNeg ( Register Reg,
const MachineRegisterInfo & MRI,
SearchOptions SO,
int MaxDepth = 3 )
static

◆ getLegalRegBank()

◆ getLogicalBitOpcode()

unsigned getLogicalBitOpcode ( unsigned Opc,
bool Is64 )
static

Definition at line 375 of file AMDGPUInstructionSelector.cpp.

References llvm_unreachable, and Opc.

◆ getNamedBarrierOp()

unsigned getNamedBarrierOp ( bool HasInlineConst,
Intrinsic::ID IntrID )

Definition at line 6756 of file AMDGPUInstructionSelector.cpp.

References llvm_unreachable.

◆ getNegStatus()

◆ getSrcStats()

SmallVector< std::pair< Register, SrcStatus > > getSrcStats ( Register Reg,
const MachineRegisterInfo & MRI,
SearchOptions SO,
int MaxDepth = 3 )
static

◆ getV_CMPOpcode()

◆ getWaveAddress()

Register getWaveAddress ( const MachineInstr * Def)
static

Definition at line 71 of file AMDGPUInstructionSelector.cpp.

References Register.

◆ gwsIntrinToOpcode()

unsigned gwsIntrinToOpcode ( unsigned IntrID)
static

Definition at line 1842 of file AMDGPUInstructionSelector.cpp.

References llvm_unreachable.

◆ isConstant()

◆ isExtractHiElt()

◆ isLaneMaskFromSameBlock()

◆ isLshrHalf()

bool isLshrHalf ( const MachineInstr * MI,
const MachineRegisterInfo & MRI )
static

Test if the MI is logic shift right with half bits, such as reg0:2n =G_LSHR reg1:2n, CONST(n)

Definition at line 4410 of file AMDGPUInstructionSelector.cpp.

References llvm::MIPatternMatch::m_GCst(), llvm::MIPatternMatch::m_GLShr(), llvm::MIPatternMatch::m_Reg(), MI, llvm::MIPatternMatch::mi_match(), and MRI.

Referenced by calcNextStatus().

◆ isNoUnsignedWrap()

◆ isSameBitWidth()

bool isSameBitWidth ( Register Reg1,
Register Reg2,
const MachineRegisterInfo & MRI )
static

Definition at line 4782 of file AMDGPUInstructionSelector.cpp.

References MRI.

Referenced by isValidToPack().

◆ isShlHalf()

bool isShlHalf ( const MachineInstr * MI,
const MachineRegisterInfo & MRI )
static

Test if the MI is shift left with half bits, such as reg0:2n =G_SHL reg1:2n, CONST(n)

Definition at line 4427 of file AMDGPUInstructionSelector.cpp.

References llvm::MIPatternMatch::m_GCst(), llvm::MIPatternMatch::m_GShl(), llvm::MIPatternMatch::m_Reg(), MI, llvm::MIPatternMatch::mi_match(), and MRI.

Referenced by calcNextStatus().

◆ isTruncHalf()

bool isTruncHalf ( const MachineInstr * MI,
const MachineRegisterInfo & MRI )
static

Test if the MI is truncating to half, such as reg0:n = G_TRUNC reg1:2n

Definition at line 4398 of file AMDGPUInstructionSelector.cpp.

References MI, and MRI.

Referenced by calcNextStatus().

◆ isUnmergeHalf()

bool isUnmergeHalf ( const MachineInstr * MI,
const MachineRegisterInfo & MRI )
static

Test function, if the MI is reg0:n, reg1:n = G_UNMERGE_VALUES reg2:2n

Definition at line 4443 of file AMDGPUInstructionSelector.cpp.

References MI, and MRI.

Referenced by calcNextStatus().

◆ isValidToPack()

bool isValidToPack ( SrcStatus HiStat,
SrcStatus LoStat,
Register NewReg,
Register RootReg,
const SIInstrInfo & TII,
const MachineRegisterInfo & MRI )
static

◆ isVCmpResult()

bool isVCmpResult ( Register Reg,
MachineRegisterInfo & MRI )
static

Definition at line 2973 of file AMDGPUInstructionSelector.cpp.

References llvm::dyn_cast(), isVCmpResult(), MI, MRI, and Reg.

Referenced by isVCmpResult().

◆ isVectorOfTwoOrScalar()

◆ parseTexFail()

bool parseTexFail ( uint64_t TexFailCtrl,
bool & TFE,
bool & LWE,
bool & IsTexFail )
static

Definition at line 1992 of file AMDGPUInstructionSelector.cpp.

◆ selectWMMAModsNegAbs()

◆ shouldUseAndMask()

bool shouldUseAndMask ( unsigned Size,
unsigned & Mask )
static
Returns
true if a bitmask for Size bits will be an inline immediate.

Definition at line 2538 of file AMDGPUInstructionSelector.cpp.

References llvm::maskTrailingOnes(), and Size.

◆ stripBitCast()

◆ stripCopy()

Register stripCopy ( Register Reg,
MachineRegisterInfo & MRI )
static

Definition at line 2708 of file AMDGPUInstructionSelector.cpp.

References llvm::getDefSrcRegIgnoringCopies(), MRI, and Reg.

Referenced by isExtractHiElt().

◆ updateMods()