| 
    LLVM 22.0.0git
    
   | 
 
This file implements the targeting of the InstructionSelector class for AMDGPU. More...
#include "AMDGPUInstructionSelector.h"#include "AMDGPU.h"#include "AMDGPUGlobalISelUtils.h"#include "AMDGPUInstrInfo.h"#include "AMDGPURegisterBankInfo.h"#include "AMDGPUTargetMachine.h"#include "SIMachineFunctionInfo.h"#include "Utils/AMDGPUBaseInfo.h"#include "llvm/CodeGen/GlobalISel/GIMatchTableExecutorImpl.h"#include "llvm/CodeGen/GlobalISel/GISelValueTracking.h"#include "llvm/CodeGen/GlobalISel/GenericMachineInstrs.h"#include "llvm/CodeGen/GlobalISel/MIPatternMatch.h"#include "llvm/CodeGen/GlobalISel/MachineIRBuilder.h"#include "llvm/CodeGen/MachineFrameInfo.h"#include "llvm/IR/DiagnosticInfo.h"#include "llvm/IR/IntrinsicsAMDGPU.h"#include <optional>#include "AMDGPUGenGlobalISel.inc"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 } | 
This file implements the targeting of the InstructionSelector class for AMDGPU.
Definition in file AMDGPUInstructionSelector.cpp.
| #define AMDGPUSubtarget GCNSubtarget | 
Definition at line 38 of file AMDGPUInstructionSelector.cpp.
| #define DEBUG_TYPE "amdgpu-isel" | 
Definition at line 32 of file AMDGPUInstructionSelector.cpp.
| #define GET_GLOBALISEL_IMPL | 
Definition at line 37 of file AMDGPUInstructionSelector.cpp.
| #define GET_GLOBALISEL_PREDICATES_INIT | 
| #define GET_GLOBALISEL_TEMPORARIES_INIT | 
      
  | 
  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 4406 of file AMDGPUInstructionSelector.cpp.
      
  | 
  strong | 
| Enumerator | |
|---|---|
| VECTOR_OF_TWO | |
| SCALAR | |
| NONE_OF_LISTED | |
Definition at line 4478 of file AMDGPUInstructionSelector.cpp.
      
  | 
  static | 
Definition at line 6313 of file AMDGPUInstructionSelector.cpp.
References llvm::MachineInstrBuilder::addImm().
      
  | 
  static | 
Definition at line 3846 of file AMDGPUInstructionSelector.cpp.
References BitOp3_Op(), llvm::getSrcRegIgnoringCopies(), I, LHS, llvm::MIPatternMatch::m_AllOnesInt(), llvm::MIPatternMatch::m_Not(), llvm::MIPatternMatch::m_Reg(), llvm::MIPatternMatch::m_ZeroInt(), MI, llvm::MIPatternMatch::mi_match(), MRI, and RHS.
Referenced by BitOp3_Op(), and BitOp3_Op().
      
  | 
  static | 
Definition at line 6362 of file AMDGPUInstructionSelector.cpp.
References B(), buildRSRC(), llvm::Hi_32(), MRI, and TII.
      
  | 
  static | 
Definition at line 6371 of file AMDGPUInstructionSelector.cpp.
References B(), buildRSRC(), llvm::Hi_32(), MRI, and TII.
      
  | 
  static | 
Definition at line 4997 of file AMDGPUInstructionSelector.cpp.
References llvm::MachineInstrBuilder::addImm(), llvm::MachineInstrBuilder::addReg(), B(), llvm::MachineInstr::getOperand(), llvm::MachineOperand::getReg(), llvm::SIRegisterInfo::getSubRegFromChannel(), llvm_unreachable, MRI, and llvm::SmallVectorTemplateCommon< T, typename >::size().
Referenced by selectWMMAModsNegAbs(), and selectWMMAModsNegAbs().
      
  | 
  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 6319 of file AMDGPUInstructionSelector.cpp.
Referenced by buildAddr64RSrc(), and buildOffsetSrc().
      
  | 
  static | 
Definition at line 4646 of file AMDGPUInstructionSelector.cpp.
References getNegStatus(), INVALID, IS_HI_NEG, IS_LOWER_HALF, IS_LOWER_HALF_NEG, IS_SAME, IS_UPPER_HALF, IS_UPPER_HALF_NEG, isLshrHalf(), isShlHalf(), isTruncHalf(), isUnmergeHalf(), MI, MRI, and Opc.
Referenced by getLastSameOrNeg(), and getSrcStats().
      
  | 
  static | 
Definition at line 4913 of file AMDGPUInstructionSelector.cpp.
References llvm::RegisterBank::getID(), llvm::RegisterBankInfo::getRegBank(), MRI, Reg, and TRI.
Referenced by getLegalRegBank().
      
  | 
  static | 
Return the register to use for the index value, and the subregister to use for the indirectly accessed register.
Definition at line 3198 of file AMDGPUInstructionSelector.cpp.
References assert(), llvm::AMDGPU::getBaseWithConstantOffset(), MRI, llvm::Offset, llvm::ArrayRef< T >::size(), and TRI.
      
  | 
  static | 
Get an immediate that must be 32-bits, and treated as zero extended.
Definition at line 6592 of file AMDGPUInstructionSelector.cpp.
References llvm::getIConstantVRegSExtVal(), llvm::isInt(), llvm::Lo_32(), MRI, and Reg.
      
  | 
  static | 
Definition at line 4789 of file AMDGPUInstructionSelector.cpp.
References calcNextStatus(), SearchOptions::checkOptions(), llvm::Depth, IS_BOTH_NEG, IS_HI_NEG, IS_LO_NEG, IS_SAME, MRI, and Reg.
      
  | 
  static | 
Definition at line 4928 of file AMDGPUInstructionSelector.cpp.
References llvm::MachineInstrBuilder::addReg(), llvm::BuildMI(), checkRB(), llvm::MachineInstr::getOperand(), llvm::MachineOperand::getReg(), MI, MRI, TII, and TRI.
Definition at line 384 of file AMDGPUInstructionSelector.cpp.
References llvm_unreachable, and Opc.
| unsigned getNamedBarrierOp | ( | bool | HasInlineConst, | 
| Intrinsic::ID | IntrID ) | 
Definition at line 6783 of file AMDGPUInstructionSelector.cpp.
References llvm_unreachable.
      
  | 
  static | 
Definition at line 4490 of file AMDGPUInstructionSelector.cpp.
References INVALID, IS_BOTH_NEG, IS_HI_NEG, IS_LO_NEG, IS_LOWER_HALF, IS_LOWER_HALF_NEG, IS_SAME, IS_UPPER_HALF, IS_UPPER_HALF_NEG, isVectorOfTwoOrScalar(), llvm_unreachable, MRI, Reg, SCALAR, and VECTOR_OF_TWO.
Referenced by calcNextStatus().
      
  | 
  static | 
Definition at line 4772 of file AMDGPUInstructionSelector.cpp.
References calcNextStatus(), SearchOptions::checkOptions(), llvm::Depth, IS_SAME, MRI, and Reg.
      
  | 
  static | 
Definition at line 1217 of file AMDGPUInstructionSelector.cpp.
References llvm::CmpInst::FCMP_FALSE, llvm::CmpInst::FCMP_OEQ, llvm::CmpInst::FCMP_OGE, llvm::CmpInst::FCMP_OGT, llvm::CmpInst::FCMP_OLE, llvm::CmpInst::FCMP_OLT, llvm::CmpInst::FCMP_ONE, llvm::CmpInst::FCMP_ORD, llvm::CmpInst::FCMP_TRUE, llvm::CmpInst::FCMP_UEQ, llvm::CmpInst::FCMP_UGE, llvm::CmpInst::FCMP_UGT, llvm::CmpInst::FCMP_ULE, llvm::CmpInst::FCMP_ULT, llvm::CmpInst::FCMP_UNE, llvm::CmpInst::FCMP_UNO, llvm::CmpInst::ICMP_EQ, llvm::CmpInst::ICMP_NE, llvm::CmpInst::ICMP_SGE, llvm::CmpInst::ICMP_SGT, llvm::CmpInst::ICMP_SLE, llvm::CmpInst::ICMP_SLT, llvm::CmpInst::ICMP_UGE, llvm::CmpInst::ICMP_UGT, llvm::CmpInst::ICMP_ULE, llvm::CmpInst::ICMP_ULT, llvm_unreachable, P, Select, and Size.
      
  | 
  static | 
Definition at line 71 of file AMDGPUInstructionSelector.cpp.
References Register.
Definition at line 1851 of file AMDGPUInstructionSelector.cpp.
References llvm_unreachable.
      
  | 
  static | 
Definition at line 2896 of file AMDGPUInstructionSelector.cpp.
References MI.
Referenced by allConstant(), arePointersCompatible(), llvm::buildModuleSummaryIndex(), llvm::MDBuilder::createTBAANode(), llvm::HexagonInstrInfo::expandPostRAPseudo(), llvm::slpvectorizer::BoUpSLP::findReusedOrderedScalars(), getMemcpyLoadsAndStores(), llvm::slpvectorizer::BoUpSLP::getReorderingData(), isSimpleVIDSequence(), llvm::slpvectorizer::BoUpSLP::reorderBottomToTop(), tryFoldHelper(), and tryToFindDuplicates().
      
  | 
  static | 
Definition at line 2738 of file AMDGPUInstructionSelector.cpp.
References assert(), llvm::LLT::fixed_vector(), llvm::MachineInstr::getOpcode(), llvm::MachineInstr::getOperand(), llvm::MachineOperand::getReg(), llvm::MachineOperand::getShuffleMask(), llvm::MIPatternMatch::m_GLShr(), llvm::MIPatternMatch::m_GTrunc(), llvm::MIPatternMatch::m_Reg(), llvm::MIPatternMatch::m_SpecificICst(), llvm::MIPatternMatch::mi_match(), MRI, stripBitCast(), and stripCopy().
Referenced by buildRegSequence16().
      
  | 
  static | 
Definition at line 1578 of file AMDGPUInstructionSelector.cpp.
References llvm::RegisterBank::getID(), llvm::isa(), isLaneMaskFromSameBlock(), LHS, llvm::MIPatternMatch::m_GAnd(), llvm::MIPatternMatch::m_Reg(), MBB, MI, llvm::MIPatternMatch::mi_match(), MRI, Reg, and RHS.
Referenced by isLaneMaskFromSameBlock().
      
  | 
  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 4437 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().
      
  | 
  static | 
Definition at line 6034 of file AMDGPUInstructionSelector.cpp.
References llvm::MachineInstr::getFlag(), llvm::MachineInstr::getOpcode(), and llvm::MachineInstr::NoUWrap.
      
  | 
  static | 
Definition at line 4809 of file AMDGPUInstructionSelector.cpp.
References MRI.
Referenced by isValidToPack().
      
  | 
  static | 
Test if the MI is shift left with half bits, such as reg0:2n =G_SHL reg1:2n, CONST(n)
Definition at line 4454 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().
      
  | 
  static | 
Test if the MI is truncating to half, such as reg0:n = G_TRUNC reg1:2n
Definition at line 4425 of file AMDGPUInstructionSelector.cpp.
Referenced by calcNextStatus().
      
  | 
  static | 
Test function, if the MI is reg0:n, reg1:n = G_UNMERGE_VALUES reg2:2n
Definition at line 4470 of file AMDGPUInstructionSelector.cpp.
Referenced by calcNextStatus().
      
  | 
  static | 
Definition at line 4841 of file AMDGPUInstructionSelector.cpp.
References IS_LOWER_HALF, IS_LOWER_HALF_NEG, IS_UPPER_HALF, IS_UPPER_HALF_NEG, isSameBitWidth(), MRI, and TII.
      
  | 
  static | 
Definition at line 2992 of file AMDGPUInstructionSelector.cpp.
References llvm::dyn_cast(), isVCmpResult(), MI, MRI, and Reg.
Referenced by isVCmpResult().
      
  | 
  static | 
Definition at line 4480 of file AMDGPUInstructionSelector.cpp.
References llvm::LLT::getNumElements(), llvm::LLT::isScalar(), llvm::LLT::isVector(), MRI, NONE_OF_LISTED, Reg, SCALAR, and VECTOR_OF_TWO.
Referenced by getNegStatus().
Definition at line 2001 of file AMDGPUInstructionSelector.cpp.
      
  | 
  static | 
Definition at line 5025 of file AMDGPUInstructionSelector.cpp.
References assert(), buildRegSequence(), llvm::MIPatternMatch::m_GFabs(), llvm::MIPatternMatch::m_Reg(), llvm::MIPatternMatch::mi_match(), MRI, llvm::SISrcMods::NEG, llvm::SISrcMods::NEG_HI, llvm::SmallVectorTemplateBase< T, bool >::push_back(), and llvm::SmallVectorTemplateCommon< T, typename >::size().
Size bits will be an inline immediate. Definition at line 2557 of file AMDGPUInstructionSelector.cpp.
References llvm::maskTrailingOnes(), and Size.
      
  | 
  static | 
Definition at line 2731 of file AMDGPUInstructionSelector.cpp.
References llvm::MIPatternMatch::m_GBitcast(), llvm::MIPatternMatch::m_Reg(), llvm::MIPatternMatch::mi_match(), MRI, and Reg.
Referenced by isExtractHiElt().
      
  | 
  static | 
Definition at line 2727 of file AMDGPUInstructionSelector.cpp.
References llvm::getDefSrcRegIgnoringCopies(), MRI, and Reg.
Referenced by isExtractHiElt().
Definition at line 4816 of file AMDGPUInstructionSelector.cpp.
References IS_HI_NEG, IS_LOWER_HALF_NEG, IS_UPPER_HALF, IS_UPPER_HALF_NEG, llvm::SISrcMods::NEG, llvm::SISrcMods::NEG_HI, llvm::SISrcMods::OP_SEL_0, and llvm::SISrcMods::OP_SEL_1.