LLVM 20.0.0git
Classes | Namespaces | Macros | Functions
SPIRVBuiltins.cpp File Reference
#include "SPIRVBuiltins.h"
#include "SPIRV.h"
#include "SPIRVSubtarget.h"
#include "SPIRVUtils.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/Analysis/ValueTracking.h"
#include "llvm/IR/IntrinsicsSPIRV.h"
#include <string>
#include <tuple>
#include "SPIRVGenTables.inc"

Go to the source code of this file.

Classes

struct  llvm::SPIRV::DemangledBuiltin
 
struct  llvm::SPIRV::IncomingCall
 
struct  llvm::SPIRV::NativeBuiltin
 
struct  llvm::SPIRV::GroupBuiltin
 
struct  llvm::SPIRV::IntelSubgroupsBuiltin
 
struct  llvm::SPIRV::AtomicFloatingBuiltin
 
struct  llvm::SPIRV::GroupUniformBuiltin
 
struct  llvm::SPIRV::GetBuiltin
 
struct  llvm::SPIRV::ImageQueryBuiltin
 
struct  llvm::SPIRV::ConvertBuiltin
 
struct  llvm::SPIRV::VectorLoadStoreBuiltin
 
struct  llvm::SPIRV::BuiltinType
 
struct  llvm::SPIRV::OpenCLType
 

Namespaces

namespace  llvm
 This is an optimization pass for GlobalISel generic memory operations.
 
namespace  llvm::SPIRV
 

Macros

#define DEBUG_TYPE   "spirv-builtins"
 
#define GET_BuiltinGroup_DECL
 
#define GET_DemangledBuiltins_DECL
 
#define GET_DemangledBuiltins_IMPL
 
#define GET_NativeBuiltins_DECL
 
#define GET_NativeBuiltins_IMPL
 
#define GET_GroupBuiltins_DECL
 
#define GET_GroupBuiltins_IMPL
 
#define GET_IntelSubgroupsBuiltins_DECL
 
#define GET_IntelSubgroupsBuiltins_IMPL
 
#define GET_AtomicFloatingBuiltins_DECL
 
#define GET_AtomicFloatingBuiltins_IMPL
 
#define GET_GroupUniformBuiltins_DECL
 
#define GET_GroupUniformBuiltins_IMPL
 
#define GET_GetBuiltins_DECL
 
#define GET_GetBuiltins_IMPL
 
#define GET_ImageQueryBuiltins_DECL
 
#define GET_ImageQueryBuiltins_IMPL
 
#define GET_ConvertBuiltins_DECL
 
#define GET_ConvertBuiltins_IMPL
 
#define GET_VectorLoadStoreBuiltins_DECL
 
#define GET_VectorLoadStoreBuiltins_IMPL
 
#define GET_CLMemoryScope_DECL
 
#define GET_CLSamplerAddressingMode_DECL
 
#define GET_CLMemoryFenceFlags_DECL
 
#define GET_ExtendedBuiltins_DECL
 
#define GET_BuiltinTypes_DECL
 
#define GET_BuiltinTypes_IMPL
 
#define GET_OpenCLTypes_DECL
 
#define GET_OpenCLTypes_IMPL
 

Functions

std::string llvm::SPIRV::lookupBuiltinNameHelper (StringRef DemangledCall)
 Parses the name part of the demangled builtin call.
 
static std::unique_ptr< const SPIRV::IncomingCall > llvm::lookupBuiltin (StringRef DemangledCall, SPIRV::InstructionSet::InstructionSet Set, Register ReturnRegister, const SPIRVType *ReturnType, const SmallVectorImpl< Register > &Arguments)
 Looks up the demangled builtin call in the SPIRVBuiltins.td records using the provided DemangledCall and specified Set.
 
static MachineInstr * llvm::getBlockStructInstr (Register ParamReg, MachineRegisterInfo *MRI)
 
static unsigned llvm::getConstFromIntrinsic (Register Reg, MachineRegisterInfo *MRI)
 
static const Typellvm::getMachineInstrType (MachineInstr *MI)
 
static const Typellvm::getBlockStructType (Register ParamReg, MachineRegisterInfo *MRI)
 
static std::tuple< Register, SPIRVType * > llvm::buildBoolRegister (MachineIRBuilder &MIRBuilder, const SPIRVType *ResultType, SPIRVGlobalRegistry *GR)
 Helper function building either a resulting scalar or vector bool register depending on the expected ResultType.
 
static bool llvm::buildSelectInst (MachineIRBuilder &MIRBuilder, Register ReturnRegister, Register SourceRegister, const SPIRVType *ReturnType, SPIRVGlobalRegistry *GR)
 Helper function for building either a vector or scalar select instruction depending on the expected ResultType.
 
static Register llvm::buildLoadInst (SPIRVType *BaseType, Register PtrRegister, MachineIRBuilder &MIRBuilder, SPIRVGlobalRegistry *GR, LLT LowLevelType, Register DestinationReg=Register(0))
 Helper function for building a load instruction loading into the DestinationReg.
 
static Register llvm::buildBuiltinVariableLoad (MachineIRBuilder &MIRBuilder, SPIRVType *VariableType, SPIRVGlobalRegistry *GR, SPIRV::BuiltIn::BuiltIn BuiltinValue, LLT LLType, Register Reg=Register(0), bool isConst=true, bool hasLinkageTy=true)
 Helper function for building a load instruction for loading a builtin global variable of BuiltinValue value.
 
Register llvm::insertAssignInstr (Register Reg, Type *Ty, SPIRVType *SpirvTy, SPIRVGlobalRegistry *GR, MachineIRBuilder &MIB, MachineRegisterInfo &MRI)
 Helper external function for inserting ASSIGN_TYPE instuction between Reg and its definition, set the new register as a destination of the definition, assign SPIRVType to both registers.
 
static SPIRV::MemorySemantics::MemorySemantics llvm::getSPIRVMemSemantics (std::memory_order MemOrder)
 
static SPIRV::Scope::Scope llvm::getSPIRVScope (SPIRV::CLMemoryScope ClScope)
 
static Register llvm::buildConstantIntReg (uint64_t Val, MachineIRBuilder &MIRBuilder, SPIRVGlobalRegistry *GR, unsigned BitWidth=32)
 
static Register llvm::buildScopeReg (Register CLScopeRegister, SPIRV::Scope::Scope Scope, MachineIRBuilder &MIRBuilder, SPIRVGlobalRegistry *GR, MachineRegisterInfo *MRI)
 
static Register llvm::buildMemSemanticsReg (Register SemanticsRegister, Register PtrRegister, unsigned &Semantics, MachineIRBuilder &MIRBuilder, SPIRVGlobalRegistry *GR)
 
static bool llvm::buildOpFromWrapper (MachineIRBuilder &MIRBuilder, unsigned Opcode, const SPIRV::IncomingCall *Call, Register TypeReg, ArrayRef< uint32_t > ImmArgs={})
 
static bool llvm::buildAtomicInitInst (const SPIRV::IncomingCall *Call, MachineIRBuilder &MIRBuilder)
 Helper function for translating atomic init to OpStore.
 
static bool llvm::buildAtomicLoadInst (const SPIRV::IncomingCall *Call, MachineIRBuilder &MIRBuilder, SPIRVGlobalRegistry *GR)
 Helper function for building an atomic load instruction.
 
static bool llvm::buildAtomicStoreInst (const SPIRV::IncomingCall *Call, MachineIRBuilder &MIRBuilder, SPIRVGlobalRegistry *GR)
 Helper function for building an atomic store instruction.
 
static bool llvm::buildAtomicCompareExchangeInst (const SPIRV::IncomingCall *Call, const SPIRV::DemangledBuiltin *Builtin, unsigned Opcode, MachineIRBuilder &MIRBuilder, SPIRVGlobalRegistry *GR)
 Helper function for building an atomic compare-exchange instruction.
 
static bool llvm::buildAtomicRMWInst (const SPIRV::IncomingCall *Call, unsigned Opcode, MachineIRBuilder &MIRBuilder, SPIRVGlobalRegistry *GR)
 Helper function for building atomic instructions.
 
static bool llvm::buildAtomicFloatingRMWInst (const SPIRV::IncomingCall *Call, unsigned Opcode, MachineIRBuilder &MIRBuilder, SPIRVGlobalRegistry *GR)
 Helper function for building an atomic floating-type instruction.
 
static bool llvm::buildAtomicFlagInst (const SPIRV::IncomingCall *Call, unsigned Opcode, MachineIRBuilder &MIRBuilder, SPIRVGlobalRegistry *GR)
 Helper function for building atomic flag instructions (e.g.
 
static bool llvm::buildBarrierInst (const SPIRV::IncomingCall *Call, unsigned Opcode, MachineIRBuilder &MIRBuilder, SPIRVGlobalRegistry *GR)
 Helper function for building barriers, i.e., memory/control ordering operations.
 
static unsigned llvm::getNumComponentsForDim (SPIRV::Dim::Dim dim)
 
static unsigned llvm::getNumSizeComponents (SPIRVType *imgType)
 Helper function for obtaining the number of size components.
 
static bool llvm::generateExtInst (const SPIRV::IncomingCall *Call, MachineIRBuilder &MIRBuilder, SPIRVGlobalRegistry *GR)
 
static bool llvm::generateRelationalInst (const SPIRV::IncomingCall *Call, MachineIRBuilder &MIRBuilder, SPIRVGlobalRegistry *GR)
 
static bool llvm::generateGroupInst (const SPIRV::IncomingCall *Call, MachineIRBuilder &MIRBuilder, SPIRVGlobalRegistry *GR)
 
static bool llvm::generateIntelSubgroupsInst (const SPIRV::IncomingCall *Call, MachineIRBuilder &MIRBuilder, SPIRVGlobalRegistry *GR)
 
static bool llvm::generateGroupUniformInst (const SPIRV::IncomingCall *Call, MachineIRBuilder &MIRBuilder, SPIRVGlobalRegistry *GR)
 
static bool llvm::generateKernelClockInst (const SPIRV::IncomingCall *Call, MachineIRBuilder &MIRBuilder, SPIRVGlobalRegistry *GR)
 
static bool llvm::genWorkgroupQuery (const SPIRV::IncomingCall *Call, MachineIRBuilder &MIRBuilder, SPIRVGlobalRegistry *GR, SPIRV::BuiltIn::BuiltIn BuiltinValue, uint64_t DefaultValue)
 
static bool llvm::generateBuiltinVar (const SPIRV::IncomingCall *Call, MachineIRBuilder &MIRBuilder, SPIRVGlobalRegistry *GR)
 
static bool llvm::generateAtomicInst (const SPIRV::IncomingCall *Call, MachineIRBuilder &MIRBuilder, SPIRVGlobalRegistry *GR)
 
static bool llvm::generateAtomicFloatingInst (const SPIRV::IncomingCall *Call, MachineIRBuilder &MIRBuilder, SPIRVGlobalRegistry *GR)
 
static bool llvm::generateBarrierInst (const SPIRV::IncomingCall *Call, MachineIRBuilder &MIRBuilder, SPIRVGlobalRegistry *GR)
 
static bool llvm::generateCastToPtrInst (const SPIRV::IncomingCall *Call, MachineIRBuilder &MIRBuilder)
 
static bool llvm::generateDotOrFMulInst (const SPIRV::IncomingCall *Call, MachineIRBuilder &MIRBuilder, SPIRVGlobalRegistry *GR)
 
static bool llvm::generateWaveInst (const SPIRV::IncomingCall *Call, MachineIRBuilder &MIRBuilder, SPIRVGlobalRegistry *GR)
 
static bool llvm::generateGetQueryInst (const SPIRV::IncomingCall *Call, MachineIRBuilder &MIRBuilder, SPIRVGlobalRegistry *GR)
 
static bool llvm::generateImageSizeQueryInst (const SPIRV::IncomingCall *Call, MachineIRBuilder &MIRBuilder, SPIRVGlobalRegistry *GR)
 
static bool llvm::generateImageMiscQueryInst (const SPIRV::IncomingCall *Call, MachineIRBuilder &MIRBuilder, SPIRVGlobalRegistry *GR)
 
static SPIRV::SamplerAddressingMode::SamplerAddressingMode llvm::getSamplerAddressingModeFromBitmask (unsigned Bitmask)
 
static unsigned llvm::getSamplerParamFromBitmask (unsigned Bitmask)
 
static SPIRV::SamplerFilterMode::SamplerFilterMode llvm::getSamplerFilterModeFromBitmask (unsigned Bitmask)
 
static bool llvm::generateReadImageInst (const StringRef DemangledCall, const SPIRV::IncomingCall *Call, MachineIRBuilder &MIRBuilder, SPIRVGlobalRegistry *GR)
 
static bool llvm::generateWriteImageInst (const SPIRV::IncomingCall *Call, MachineIRBuilder &MIRBuilder, SPIRVGlobalRegistry *GR)
 
static bool llvm::generateSampleImageInst (const StringRef DemangledCall, const SPIRV::IncomingCall *Call, MachineIRBuilder &MIRBuilder, SPIRVGlobalRegistry *GR)
 
static bool llvm::generateSelectInst (const SPIRV::IncomingCall *Call, MachineIRBuilder &MIRBuilder)
 
static bool llvm::generateConstructInst (const SPIRV::IncomingCall *Call, MachineIRBuilder &MIRBuilder, SPIRVGlobalRegistry *GR)
 
static bool llvm::generateCoopMatrInst (const SPIRV::IncomingCall *Call, MachineIRBuilder &MIRBuilder, SPIRVGlobalRegistry *GR)
 
static bool llvm::generateSpecConstantInst (const SPIRV::IncomingCall *Call, MachineIRBuilder &MIRBuilder, SPIRVGlobalRegistry *GR)
 
static bool llvm::buildNDRange (const SPIRV::IncomingCall *Call, MachineIRBuilder &MIRBuilder, SPIRVGlobalRegistry *GR)
 
static SPIRVType * llvm::getOrCreateSPIRVDeviceEventPointer (MachineIRBuilder &MIRBuilder, SPIRVGlobalRegistry *GR)
 
static bool llvm::buildEnqueueKernel (const SPIRV::IncomingCall *Call, MachineIRBuilder &MIRBuilder, SPIRVGlobalRegistry *GR)
 
static bool llvm::generateEnqueueInst (const SPIRV::IncomingCall *Call, MachineIRBuilder &MIRBuilder, SPIRVGlobalRegistry *GR)
 
static bool llvm::generateAsyncCopy (const SPIRV::IncomingCall *Call, MachineIRBuilder &MIRBuilder, SPIRVGlobalRegistry *GR)
 
static bool llvm::generateConvertInst (const StringRef DemangledCall, const SPIRV::IncomingCall *Call, MachineIRBuilder &MIRBuilder, SPIRVGlobalRegistry *GR)
 
static bool llvm::generateVectorLoadStoreInst (const SPIRV::IncomingCall *Call, MachineIRBuilder &MIRBuilder, SPIRVGlobalRegistry *GR)
 
static bool llvm::generateLoadStoreInst (const SPIRV::IncomingCall *Call, MachineIRBuilder &MIRBuilder, SPIRVGlobalRegistry *GR)
 
std::tuple< int, unsigned, unsignedllvm::SPIRV::mapBuiltinToOpcode (const StringRef DemangledCall, SPIRV::InstructionSet::InstructionSet Set)
 Helper function for finding a builtin function attributes by a demangled function name.
 
std::optional< boolllvm::SPIRV::lowerBuiltin (const StringRef DemangledCall, SPIRV::InstructionSet::InstructionSet Set, MachineIRBuilder &MIRBuilder, const Register OrigRet, const Type *OrigRetTy, const SmallVectorImpl< Register > &Args, SPIRVGlobalRegistry *GR)
 
Typellvm::SPIRV::parseBuiltinCallArgumentBaseType (const StringRef DemangledCall, unsigned ArgIdx, LLVMContext &Ctx)
 Parses the provided ArgIdx argument base type in the DemangledCall skeleton.
 
static Typellvm::parseTypeString (const StringRef Name, LLVMContext &Context)
 
static SPIRVType * llvm::getNonParameterizedType (const TargetExtType *ExtensionType, const SPIRV::BuiltinType *TypeRecord, MachineIRBuilder &MIRBuilder, SPIRVGlobalRegistry *GR)
 
static SPIRVType * llvm::getSamplerType (MachineIRBuilder &MIRBuilder, SPIRVGlobalRegistry *GR)
 
static SPIRVType * llvm::getPipeType (const TargetExtType *ExtensionType, MachineIRBuilder &MIRBuilder, SPIRVGlobalRegistry *GR)
 
static SPIRVType * llvm::getCoopMatrType (const TargetExtType *ExtensionType, MachineIRBuilder &MIRBuilder, SPIRVGlobalRegistry *GR)
 
static SPIRVType * llvm::getImageType (const TargetExtType *ExtensionType, const SPIRV::AccessQualifier::AccessQualifier Qualifier, MachineIRBuilder &MIRBuilder, SPIRVGlobalRegistry *GR)
 
static SPIRVType * llvm::getSampledImageType (const TargetExtType *OpaqueType, MachineIRBuilder &MIRBuilder, SPIRVGlobalRegistry *GR)
 
TargetExtType * llvm::SPIRV::parseBuiltinTypeNameToTargetExtType (std::string TypeName, LLVMContext &Context)
 Translates a string representing a SPIR-V or OpenCL builtin type to a TargetExtType that can be further lowered with lowerBuiltinType().
 
SPIRVType * llvm::SPIRV::lowerBuiltinType (const Type *OpaqueType, SPIRV::AccessQualifier::AccessQualifier AccessQual, MachineIRBuilder &MIRBuilder, SPIRVGlobalRegistry *GR)
 

Macro Definition Documentation

◆ DEBUG_TYPE

#define DEBUG_TYPE   "spirv-builtins"

Definition at line 24 of file SPIRVBuiltins.cpp.

◆ GET_AtomicFloatingBuiltins_DECL

#define GET_AtomicFloatingBuiltins_DECL

Definition at line 103 of file SPIRVBuiltins.cpp.

◆ GET_AtomicFloatingBuiltins_IMPL

#define GET_AtomicFloatingBuiltins_IMPL

Definition at line 104 of file SPIRVBuiltins.cpp.

◆ GET_BuiltinGroup_DECL

#define GET_BuiltinGroup_DECL

Definition at line 28 of file SPIRVBuiltins.cpp.

◆ GET_BuiltinTypes_DECL

#define GET_BuiltinTypes_DECL

Definition at line 2687 of file SPIRVBuiltins.cpp.

◆ GET_BuiltinTypes_IMPL

#define GET_BuiltinTypes_IMPL

Definition at line 2688 of file SPIRVBuiltins.cpp.

◆ GET_CLMemoryFenceFlags_DECL

#define GET_CLMemoryFenceFlags_DECL

Definition at line 162 of file SPIRVBuiltins.cpp.

◆ GET_CLMemoryScope_DECL

#define GET_CLMemoryScope_DECL

Definition at line 160 of file SPIRVBuiltins.cpp.

◆ GET_CLSamplerAddressingMode_DECL

#define GET_CLSamplerAddressingMode_DECL

Definition at line 161 of file SPIRVBuiltins.cpp.

◆ GET_ConvertBuiltins_DECL

#define GET_ConvertBuiltins_DECL

Definition at line 153 of file SPIRVBuiltins.cpp.

◆ GET_ConvertBuiltins_IMPL

#define GET_ConvertBuiltins_IMPL

Definition at line 154 of file SPIRVBuiltins.cpp.

◆ GET_DemangledBuiltins_DECL

#define GET_DemangledBuiltins_DECL

Definition at line 39 of file SPIRVBuiltins.cpp.

◆ GET_DemangledBuiltins_IMPL

#define GET_DemangledBuiltins_IMPL

Definition at line 40 of file SPIRVBuiltins.cpp.

◆ GET_ExtendedBuiltins_DECL

#define GET_ExtendedBuiltins_DECL

Definition at line 163 of file SPIRVBuiltins.cpp.

◆ GET_GetBuiltins_DECL

#define GET_GetBuiltins_DECL

Definition at line 121 of file SPIRVBuiltins.cpp.

◆ GET_GetBuiltins_IMPL

#define GET_GetBuiltins_IMPL

Definition at line 122 of file SPIRVBuiltins.cpp.

◆ GET_GroupBuiltins_DECL

#define GET_GroupBuiltins_DECL

Definition at line 85 of file SPIRVBuiltins.cpp.

◆ GET_GroupBuiltins_IMPL

#define GET_GroupBuiltins_IMPL

Definition at line 86 of file SPIRVBuiltins.cpp.

◆ GET_GroupUniformBuiltins_DECL

#define GET_GroupUniformBuiltins_DECL

Definition at line 111 of file SPIRVBuiltins.cpp.

◆ GET_GroupUniformBuiltins_IMPL

#define GET_GroupUniformBuiltins_IMPL

Definition at line 112 of file SPIRVBuiltins.cpp.

◆ GET_ImageQueryBuiltins_DECL

#define GET_ImageQueryBuiltins_DECL

Definition at line 130 of file SPIRVBuiltins.cpp.

◆ GET_ImageQueryBuiltins_IMPL

#define GET_ImageQueryBuiltins_IMPL

Definition at line 131 of file SPIRVBuiltins.cpp.

◆ GET_IntelSubgroupsBuiltins_DECL

#define GET_IntelSubgroupsBuiltins_DECL

Definition at line 95 of file SPIRVBuiltins.cpp.

◆ GET_IntelSubgroupsBuiltins_IMPL

#define GET_IntelSubgroupsBuiltins_IMPL

Definition at line 96 of file SPIRVBuiltins.cpp.

◆ GET_NativeBuiltins_DECL

#define GET_NativeBuiltins_DECL

Definition at line 66 of file SPIRVBuiltins.cpp.

◆ GET_NativeBuiltins_IMPL

#define GET_NativeBuiltins_IMPL

Definition at line 67 of file SPIRVBuiltins.cpp.

◆ GET_OpenCLTypes_DECL

#define GET_OpenCLTypes_DECL

Definition at line 2695 of file SPIRVBuiltins.cpp.

◆ GET_OpenCLTypes_IMPL

#define GET_OpenCLTypes_IMPL

Definition at line 2696 of file SPIRVBuiltins.cpp.

◆ GET_VectorLoadStoreBuiltins_DECL

#define GET_VectorLoadStoreBuiltins_DECL

Definition at line 157 of file SPIRVBuiltins.cpp.

◆ GET_VectorLoadStoreBuiltins_IMPL

#define GET_VectorLoadStoreBuiltins_IMPL

Definition at line 158 of file SPIRVBuiltins.cpp.