LLVM 18.0.0git
|
This file implements the targeting of the Machinelegalizer class for AMDGPU. More...
#include "AMDGPULegalizerInfo.h"
#include "AMDGPU.h"
#include "AMDGPUGlobalISelUtils.h"
#include "AMDGPUInstrInfo.h"
#include "AMDGPUTargetMachine.h"
#include "SIMachineFunctionInfo.h"
#include "Utils/AMDGPUBaseInfo.h"
#include "llvm/ADT/ScopeExit.h"
#include "llvm/BinaryFormat/ELF.h"
#include "llvm/CodeGen/GlobalISel/GenericMachineInstrs.h"
#include "llvm/CodeGen/GlobalISel/LegalizerHelper.h"
#include "llvm/CodeGen/GlobalISel/MIPatternMatch.h"
#include "llvm/CodeGen/GlobalISel/MachineIRBuilder.h"
#include "llvm/CodeGen/GlobalISel/Utils.h"
#include "llvm/IR/DiagnosticInfo.h"
#include "llvm/IR/IntrinsicsAMDGPU.h"
#include "llvm/IR/IntrinsicsR600.h"
Go to the source code of this file.
Macros | |
#define | DEBUG_TYPE "amdgpu-legalinfo" |
Variables | |
static cl::opt< bool > | EnableNewLegality ("amdgpu-global-isel-new-legality", cl::desc("Use GlobalISel desired legality, rather than try to use" "rules compatible with selection patterns"), cl::init(false), cl::ReallyHidden) |
static constexpr unsigned | MaxRegisterSize = 1024 |
static const unsigned | SPDenormModeBitField |
This file implements the targeting of the Machinelegalizer class for AMDGPU.
Definition in file AMDGPULegalizerInfo.cpp.
#define DEBUG_TYPE "amdgpu-legalinfo" |
Definition at line 33 of file AMDGPULegalizerInfo.cpp.
|
static |
Definition at line 3061 of file AMDGPULegalizerInfo.cpp.
References llvm::MachineInstr::FmAfn, llvm::MachineFunction::getTarget(), llvm::TargetMachine::Options, and Options.
Referenced by llvm::AMDGPULegalizerInfo::legalizeFExp(), and llvm::AMDGPULegalizerInfo::legalizeFSQRTF32().
|
static |
Definition at line 184 of file AMDGPULegalizerInfo.cpp.
References getBitcastRegisterType().
|
static |
Definition at line 191 of file AMDGPULegalizerInfo.cpp.
References assert(), llvm::ElementCount::getFixed(), llvm::LLT::getSizeInBits(), llvm::LLT::scalarOrVector(), and Size.
|
static |
Definition at line 5559 of file AMDGPULegalizerInfo.cpp.
References B, and llvm::Format.
Referenced by llvm::AMDGPULegalizerInfo::legalizeBufferLoad().
|
static |
Definition at line 557 of file AMDGPULegalizerInfo.cpp.
References B, castBufferRsrcToV4I32(), llvm::MachineOperand::getReg(), hasBufferRsrcWorkaround(), Idx, MI, and llvm::MachineOperand::setReg().
Referenced by llvm::AMDGPULegalizerInfo::legalizeBufferAtomic(), llvm::AMDGPULegalizerInfo::legalizeBufferLoad(), llvm::AMDGPULegalizerInfo::legalizeBufferStore(), and llvm::AMDGPULegalizerInfo::legalizeStore().
|
static |
Mutates IR (typicaly a load instruction) to use a <4 x s32> as the initial type of the operand idx
and then to transform it to a p8
via bitcasts and inttoptr.
In addition, handle vectors of p8. Returns the new type.
Definition at line 497 of file AMDGPULegalizerInfo.cpp.
References B, getBufferRsrcRegisterType(), getBufferRsrcScalarType(), llvm::MachineOperand::getReg(), hasBufferRsrcWorkaround(), I, Idx, MI, MRI, llvm::LLT::scalar(), and llvm::MachineOperand::setReg().
Referenced by llvm::AMDGPULegalizerInfo::legalizeBufferLoad(), llvm::AMDGPULegalizerInfo::legalizeLoad(), and llvm::AMDGPULegalizerInfo::legalizeSBufferLoad().
|
static |
Cast a buffer resource (an address space 8 pointer) into a 4xi32, which is the form in which the value must be in order to be passed to the low-level representations used for MUBUF/MTBUF intrinsics.
This is a hack, which is needed in order to account for the fact that we can't define a register class for s128 without breaking SelectionDAG.
Definition at line 538 of file AMDGPULegalizerInfo.cpp.
References B, getBufferRsrcRegisterType(), getBufferRsrcScalarType(), I, MRI, llvm::SmallVectorTemplateBase< T, bool >::push_back(), and llvm::LLT::scalar().
Referenced by castBufferRsrcArgToV4I32(), and llvm::AMDGPULegalizerInfo::fixStoreSourceType().
|
static |
Convert from separate vaddr components to a single vector address register, and replace the remaining operands with $noreg.
Definition at line 5947 of file AMDGPULegalizerInfo.cpp.
References assert(), B, llvm::LLT::fixed_vector(), llvm::SrcOp::getReg(), I, MI, llvm::SmallVectorTemplateBase< T, bool >::push_back(), llvm::LLT::scalar(), and llvm::SmallVectorBase< Size_T >::size().
Referenced by llvm::AMDGPULegalizerInfo::legalizeImageIntrinsic().
|
static |
Definition at line 265 of file AMDGPULegalizerInfo.cpp.
References llvm::LLT::getElementType(), llvm::LLT::getSizeInBits(), llvm::LLT::isVector(), and llvm::LLT::scalar().
Referenced by llvm::AMDGPULegalizerInfo::AMDGPULegalizerInfo().
|
static |
Definition at line 4280 of file AMDGPULegalizerInfo.cpp.
References B, and llvm::LLT::scalar().
Referenced by llvm::AMDGPULegalizerInfo::legalizeUnsignedDIV_REM64Impl().
|
static |
Definition at line 2357 of file AMDGPULegalizerInfo.cpp.
References B, llvm::Hi, and llvm::LLT::scalar().
|
static |
Definition at line 106 of file AMDGPULegalizerInfo.cpp.
References llvm::LLT::getElementType(), llvm::ElementCount::getFixed(), llvm::LLT::getNumElements(), llvm::LLT::getSizeInBits(), llvm::LLT::scalarOrVector(), and Size.
Referenced by llvm::AMDGPULegalizerInfo::AMDGPULegalizerInfo().
Definition at line 172 of file AMDGPULegalizerInfo.cpp.
References llvm::ElementCount::getFixed(), llvm::LLT::getSizeInBits(), llvm::LLT::scalar(), llvm::LLT::scalarOrVector(), and Size.
Referenced by bitcastToRegisterType(), and llvm::AMDGPULegalizerInfo::legalizeSBufferLoad().
|
static |
Definition at line 5721 of file AMDGPULegalizerInfo.cpp.
References llvm_unreachable.
Referenced by llvm::AMDGPULegalizerInfo::legalizeBufferAtomic().
Definition at line 165 of file AMDGPULegalizerInfo.cpp.
References llvm::LLT::fixed_vector(), llvm::LLT::getElementCount(), llvm::details::FixedOrScalableQuantity< LeafTy, ValueTy >::getFixedValue(), llvm::LLT::isVector(), and llvm::LLT::scalar().
Referenced by castBufferRsrcFromV4I32(), and castBufferRsrcToV4I32().
Definition at line 158 of file AMDGPULegalizerInfo.cpp.
References llvm::LLT::getElementCount(), llvm::LLT::isVector(), llvm::LLT::scalar(), and llvm::LLT::vector().
Referenced by castBufferRsrcFromV4I32(), and castBufferRsrcToV4I32().
|
static |
Definition at line 5176 of file AMDGPULegalizerInfo.cpp.
References llvm_unreachable.
Referenced by llvm::AMDGPULegalizerInfo::legalizeDSAtomicFPIntrinsic().
|
static |
Definition at line 3146 of file AMDGPULegalizerInfo.cpp.
References B, llvm::FMul, X, and Y.
Definition at line 59 of file AMDGPULegalizerInfo.cpp.
References llvm::LLT::getSizeInBits(), llvm::Log2_32_Ceil(), and llvm::LLT::scalar().
Referenced by llvm::AMDGPULegalizerInfo::legalizeSBufferLoad().
Definition at line 52 of file AMDGPULegalizerInfo.cpp.
References llvm::LLT::changeElementCount(), llvm::ElementCount::getFixed(), llvm::LLT::getNumElements(), and llvm::Log2_32_Ceil().
Referenced by llvm::AMDGPULegalizerInfo::legalizeSBufferLoad().
Definition at line 388 of file AMDGPULegalizerInfo.cpp.
References llvm::AMDGPUAS::BUFFER_RESOURCE, llvm::LLT::getAddressSpace(), llvm::LLT::getElementType(), hasBufferRsrcWorkaround(), llvm::LLT::isPointer(), and llvm::LLT::isVector().
Referenced by castBufferRsrcArgToV4I32(), castBufferRsrcFromV4I32(), llvm::AMDGPULegalizerInfo::fixStoreSourceType(), hasBufferRsrcWorkaround(), isLoadStoreLegal(), llvm::AMDGPULegalizerInfo::legalizeBufferLoad(), llvm::AMDGPULegalizerInfo::legalizeLoad(), llvm::AMDGPULegalizerInfo::legalizeSBufferLoad(), llvm::AMDGPULegalizerInfo::legalizeStore(), and loadStoreBitcastWorkaround().
|
static |
Definition at line 257 of file AMDGPULegalizerInfo.cpp.
References llvm::SIRegisterInfo::getSGPRClassForBitWidth(), llvm::LLT::getSizeInBits(), and isRegisterType().
|
static |
Return true if the value is a known valid address, such that a null check is not necessary.
Definition at line 2153 of file AMDGPULegalizerInfo.cpp.
References llvm::ConstantInt::getSExtValue(), MRI, and TM.
Referenced by llvm::AMDGPULegalizerInfo::legalizeAddrSpaceCast().
|
static |
Definition at line 423 of file AMDGPULegalizerInfo.cpp.
References hasBufferRsrcWorkaround(), isLoadStoreSizeLegal(), isRegisterType(), loadStoreBitcastWorkaround(), and llvm::LegalityQuery::Types.
|
static |
Definition at line 315 of file AMDGPULegalizerInfo.cpp.
References llvm::SITargetLowering::allowsMisalignedMemoryAccessesImpl(), assert(), llvm::AMDGPUAS::CONSTANT_ADDRESS_32BIT, llvm::LLT::getSizeInBits(), llvm::LLT::isVector(), maxSizeForAddrSpace(), llvm::LegalityQuery::MMODescrs, llvm::LegalityQuery::Opcode, RegSize, Size, and llvm::LegalityQuery::Types.
Referenced by isLoadStoreLegal().
|
static |
Definition at line 4001 of file AMDGPULegalizerInfo.cpp.
References llvm::getIConstantVRegSExtVal(), MI, and MRI.
Referenced by llvm::MCAsmParserExtension::ParseDirectiveCGProfile(), and verifyCFIntrinsic().
Definition at line 222 of file AMDGPULegalizerInfo.cpp.
References MaxRegisterSize, and Size.
Referenced by isRegisterType(), and shouldBitcastLoadStoreType().
Definition at line 238 of file AMDGPULegalizerInfo.cpp.
References llvm::LLT::getSizeInBits(), isRegisterSize(), isRegisterVectorType(), and llvm::LLT::isVector().
Referenced by llvm::AMDGPULegalizerInfo::AMDGPULegalizerInfo(), isIllegalRegisterType(), isLoadStoreLegal(), isRegisterType(), llvm::AMDGPULegalizerInfo::legalizeLoad(), llvm::PPCLegalizerInfo::PPCLegalizerInfo(), and shouldBitcastLoadStoreType().
|
static |
Definition at line 250 of file AMDGPULegalizerInfo.cpp.
References isRegisterType().
Definition at line 226 of file AMDGPULegalizerInfo.cpp.
References llvm::LLT::getSizeInBits().
Referenced by shouldBitcastLoadStoreType().
Definition at line 231 of file AMDGPULegalizerInfo.cpp.
References llvm::LLT::getElementType(), llvm::LLT::getNumElements(), and llvm::LLT::getSizeInBits().
Referenced by isRegisterType().
|
static |
Definition at line 68 of file AMDGPULegalizerInfo.cpp.
References llvm::LLT::getElementType(), llvm::LLT::getNumElements(), llvm::LLT::getSizeInBits(), and llvm::LLT::isVector().
Referenced by llvm::AMDGPULegalizerInfo::AMDGPULegalizerInfo().
|
static |
Definition at line 277 of file AMDGPULegalizerInfo.cpp.
References llvm::LLT::getSizeInBits(), and llvm::LLT::isVector().
|
static |
Definition at line 89 of file AMDGPULegalizerInfo.cpp.
References llvm::LLT::getNumElements(), llvm::LLT::getScalarType(), and llvm::LLT::getSizeInBits().
Definition at line 402 of file AMDGPULegalizerInfo.cpp.
References EnableNewLegality, llvm::LLT::getElementType(), llvm::LLT::getSizeInBits(), hasBufferRsrcWorkaround(), llvm::LLT::isPointer(), llvm::LLT::isVector(), and Size.
Referenced by isLoadStoreLegal(), and shouldBitcastLoadStoreType().
|
static |
Definition at line 288 of file AMDGPULegalizerInfo.cpp.
References llvm::AMDGPUAS::BUFFER_RESOURCE, llvm::AMDGPUAS::CONSTANT_ADDRESS, llvm::AMDGPUAS::CONSTANT_ADDRESS_32BIT, llvm::AMDGPUAS::GLOBAL_ADDRESS, llvm::AMDGPUAS::LOCAL_ADDRESS, and llvm::AMDGPUAS::PRIVATE_ADDRESS.
Referenced by isLoadStoreSizeLegal(), and shouldWidenLoad().
|
static |
Definition at line 137 of file AMDGPULegalizerInfo.cpp.
References assert(), llvm::LLT::fixed_vector(), llvm::LLT::getElementType(), llvm::LLT::getNumElements(), llvm::SIRegisterInfo::getSGPRClassForBitWidth(), llvm::LLT::getSizeInBits(), and MaxRegisterSize.
|
static |
Definition at line 120 of file AMDGPULegalizerInfo.cpp.
References assert(), llvm::LLT::fixed_vector(), llvm::LLT::getElementType(), llvm::LLT::getSizeInBits(), and Size.
|
static |
Definition at line 3068 of file AMDGPULegalizerInfo.cpp.
References llvm::MachineFunction::getDenormalMode(), llvm::MachineFunction::getRegInfo(), llvm::APFloatBase::IEEEsingle(), llvm::DenormalMode::Input, llvm::DenormalMode::PreserveSign, and valueIsKnownNeverF32Denorm().
Referenced by llvm::AMDGPULegalizerInfo::getScaledLogInput(), llvm::AMDGPULegalizerInfo::legalizeFExp2(), llvm::AMDGPULegalizerInfo::legalizeFExpUnsafe(), and llvm::AMDGPULegalizerInfo::legalizeFSQRTF32().
|
static |
Definition at line 215 of file AMDGPULegalizerInfo.cpp.
References llvm::LLT::getNumElements(), and llvm::LLT::isVector().
|
static |
Definition at line 97 of file AMDGPULegalizerInfo.cpp.
References llvm::LLT::fixed_vector(), llvm::LLT::getElementType(), and llvm::LLT::getNumElements().
Referenced by llvm::AMDGPULegalizerInfo::AMDGPULegalizerInfo().
|
static |
Turn a set of s16 typed registers in AddrRegs
into a dword sized vector with s16 typed elements.
Definition at line 5886 of file AMDGPULegalizerInfo.cpp.
References assert(), B, llvm::LLT::fixed_vector(), llvm::SrcOp::getReg(), I, Intr, MI, llvm::SmallVectorTemplateBase< T, bool >::push_back(), and llvm::LLT::scalar().
Referenced by llvm::AMDGPULegalizerInfo::legalizeImageIntrinsic().
|
static |
Definition at line 4122 of file AMDGPULegalizerInfo.cpp.
References B, llvm::CallingConv::C, and MI.
Referenced by llvm::AMDGPULegalizerInfo::legalizeWorkitemIDIntrinsic().
|
static |
Return true if a load or store of the type should be lowered with a bitcast to a different type.
Definition at line 431 of file AMDGPULegalizerInfo.cpp.
References llvm::LLT::getElementType(), llvm::LLT::getSizeInBits(), isRegisterSize(), isRegisterType(), isRegisterVectorElementType(), llvm::LLT::isVector(), loadStoreBitcastWorkaround(), and Size.
Referenced by llvm::AMDGPULegalizerInfo::legalizeSBufferLoad().
|
static |
Definition at line 484 of file AMDGPULegalizerInfo.cpp.
References llvm::LegalityQuery::MMODescrs, shouldWidenLoad(), and llvm::LegalityQuery::Types.
|
static |
Return true if we should legalize a load by widening an odd sized memory access up to the alignment.
Note this case when the memory access itself changes, not the size of the result register.
Definition at line 450 of file AMDGPULegalizerInfo.cpp.
References llvm::SITargetLowering::allowsMisalignedMemoryAccessesImpl(), llvm::CallingConv::Fast, llvm::LLT::getSizeInBits(), llvm::isPowerOf2_32(), maxSizeForAddrSpace(), llvm::MachineMemOperand::MOLoad, and llvm::NextPowerOf2().
Referenced by llvm::AMDGPULegalizerInfo::legalizeLoad(), and shouldWidenLoad().
|
static |
Definition at line 82 of file AMDGPULegalizerInfo.cpp.
References llvm::LLT::getSizeInBits().
|
static |
Definition at line 3576 of file AMDGPULegalizerInfo.cpp.
References llvm::getOpcodeDef(), and MRI.
Referenced by llvm::AMDGPULegalizerInfo::legalizeFFloor().
|
static |
Definition at line 4672 of file AMDGPULegalizerInfo.cpp.
References B, llvm::Enable, FP_DENORM_FLUSH_NONE, and SPDenormModeBitField.
Referenced by llvm::AMDGPULegalizerInfo::legalizeFDIV32().
|
static |
Return true if it's known that Src
can never be an f32 denormal value.
Definition at line 3032 of file AMDGPULegalizerInfo.cpp.
References DefMI, getIntrinsicID(), llvm::MachineInstr::getOpcode(), llvm::MachineInstr::getOperand(), llvm::MachineOperand::getReg(), MRI, and llvm::LLT::scalar().
|
static |
Definition at line 201 of file AMDGPULegalizerInfo.cpp.
References llvm::LLT::getSizeInBits(), llvm::LLT::isVector(), and Size.
|
static |
Definition at line 208 of file AMDGPULegalizerInfo.cpp.
References llvm::LLT::getSizeInBits(), llvm::LLT::isVector(), and Size.
Referenced by llvm::AMDGPULegalizerInfo::AMDGPULegalizerInfo().
|
static |
Definition at line 4010 of file AMDGPULegalizerInfo.cpp.
References llvm::MachineBasicBlock::end(), llvm::MachineFunction::end(), llvm::eraseInstr(), llvm::ilist_node_impl< OptionsT >::getIterator(), llvm::MachineOperand::getMBB(), llvm::MachineInstr::getOpcode(), llvm::MachineInstr::getOperand(), llvm::MachineBasicBlock::getParent(), llvm::MachineInstr::getParent(), llvm::MachineOperand::getReg(), isNot(), MI, MRI, and UseMI.
Referenced by llvm::AMDGPULegalizerInfo::legalizeIntrinsic().
Definition at line 2868 of file AMDGPULegalizerInfo.cpp.
References llvm::LLT::changeElementCount(), llvm::ElementCount::getFixed(), llvm::LLT::getNumElements(), llvm::LLT::getSizeInBits(), llvm::LLT::isVector(), llvm::PowerOf2Ceil(), and llvm::LLT::scalar().
Referenced by llvm::AMDGPULegalizerInfo::legalizeLoad().
|
static |
Referenced by loadStoreBitcastWorkaround().
|
staticconstexpr |
Definition at line 49 of file AMDGPULegalizerInfo.cpp.
Referenced by llvm::AMDGPULegalizerInfo::AMDGPULegalizerInfo(), isRegisterSize(), and moreElementsToNextExistingRegClass().
Definition at line 4666 of file AMDGPULegalizerInfo.cpp.
Referenced by llvm::AMDGPULegalizerInfo::legalizeFDIV32(), and toggleSPDenormMode().