LLVM  16.0.0git
Classes | Namespaces | Macros | Functions
SPIRVBuiltins.cpp File Reference
#include "SPIRVBuiltins.h"
#include "SPIRV.h"
#include "SPIRVUtils.h"
#include "llvm/Analysis/ValueTracking.h"
#include "llvm/IR/IntrinsicsSPIRV.h"
#include <string>
#include <tuple>
#include "SPIRVGenTables.inc"
Include dependency graph for SPIRVBuiltins.cpp:

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::GetBuiltin
 
struct  llvm::SPIRV::ImageQueryBuiltin
 
struct  llvm::SPIRV::ConvertBuiltin
 
struct  llvm::SPIRV::VectorLoadStoreBuiltin
 
struct  llvm::SPIRV::DemangledType
 
struct  llvm::SPIRV::ImageType
 
struct  llvm::SPIRV::PipeType
 

Namespaces

 llvm
 This is an optimization pass for GlobalISel generic memory operations.
 
 llvm::SPIRV
 Lowers a builtin funtion call using the provided DemangledCall skeleton and external instruction Set.
 

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_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_DemangledTypes_DECL
 
#define GET_DemangledTypes_IMPL
 
#define GET_ImageTypes_DECL
 
#define GET_ImageTypes_IMPL
 
#define GET_PipeTypes_DECL
 
#define GET_PipeTypes_IMPL
 

Functions

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. More...
 
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. More...
 
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. More...
 
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. More...
 
static Register llvm::buildBuiltinVariableLoad (MachineIRBuilder &MIRBuilder, SPIRVType *VariableType, SPIRVGlobalRegistry *GR, SPIRV::BuiltIn::BuiltIn BuiltinValue, LLT LLType, Register Reg=Register(0))
 Helper function for building a load instruction for loading a builtin global variable of BuiltinValue value. More...
 
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. More...
 
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 bool llvm::buildAtomicInitInst (const SPIRV::IncomingCall *Call, MachineIRBuilder &MIRBuilder)
 Helper function for translating atomic init to OpStore. More...
 
static bool llvm::buildAtomicLoadInst (const SPIRV::IncomingCall *Call, MachineIRBuilder &MIRBuilder, SPIRVGlobalRegistry *GR)
 Helper function for building an atomic load instruction. More...
 
static bool llvm::buildAtomicStoreInst (const SPIRV::IncomingCall *Call, MachineIRBuilder &MIRBuilder, SPIRVGlobalRegistry *GR)
 Helper function for building an atomic store instruction. More...
 
static bool llvm::buildAtomicCompareExchangeInst (const SPIRV::IncomingCall *Call, MachineIRBuilder &MIRBuilder, SPIRVGlobalRegistry *GR)
 Helper function for building an atomic compare-exchange instruction. More...
 
static bool llvm::buildAtomicRMWInst (const SPIRV::IncomingCall *Call, unsigned Opcode, MachineIRBuilder &MIRBuilder, SPIRVGlobalRegistry *GR)
 Helper function for building an atomic load instruction. More...
 
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. More...
 
static unsigned llvm::getNumComponentsForDim (SPIRV::Dim::Dim dim)
 
static unsigned llvm::getNumSizeComponents (SPIRVType *imgType)
 Helper function for obtaining the number of size components. More...
 
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::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::generateBarrierInst (const SPIRV::IncomingCall *Call, MachineIRBuilder &MIRBuilder, SPIRVGlobalRegistry *GR)
 
static bool llvm::generateDotOrFMulInst (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::generateSpecConstantInst (const SPIRV::IncomingCall *Call, MachineIRBuilder &MIRBuilder, SPIRVGlobalRegistry *GR)
 
static MachineInstr * llvm::getBlockStructInstr (Register ParamReg, MachineRegisterInfo *MRI)
 
static const Type * llvm::getMachineInstrType (MachineInstr *MI)
 
static const Type * llvm::getBlockStructType (Register ParamReg, MachineRegisterInfo *MRI)
 
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)
 
Optional< bool > llvm::SPIRV::lowerBuiltin (const StringRef DemangledCall, SPIRV::InstructionSet::InstructionSet Set, MachineIRBuilder &MIRBuilder, const Register OrigRet, const Type *OrigRetTy, const SmallVectorImpl< Register > &Args, SPIRVGlobalRegistry *GR)
 
static const SPIRV::DemangledType * llvm::findBuiltinType (StringRef Name)
 
static std::unique_ptr< const SPIRV::ImageType > llvm::lookupOrParseBuiltinImageType (StringRef Name)
 
static std::unique_ptr< const SPIRV::PipeType > llvm::lookupOrParseBuiltinPipeType (StringRef Name)
 
static SPIRVType * llvm::getNonParametrizedType (const StructType *OpaqueType, const SPIRV::DemangledType *TypeRecord, MachineIRBuilder &MIRBuilder, SPIRVGlobalRegistry *GR)
 
static SPIRVType * llvm::getSamplerType (MachineIRBuilder &MIRBuilder, SPIRVGlobalRegistry *GR)
 
static SPIRVType * llvm::getPipeType (const StructType *OpaqueType, MachineIRBuilder &MIRBuilder, SPIRVGlobalRegistry *GR)
 
static SPIRVType * llvm::getImageType (const StructType *OpaqueType, SPIRV::AccessQualifier::AccessQualifier AccessQual, MachineIRBuilder &MIRBuilder, SPIRVGlobalRegistry *GR)
 
static SPIRVType * llvm::getSampledImageType (const StructType *OpaqueType, MachineIRBuilder &MIRBuilder, SPIRVGlobalRegistry *GR)
 
SPIRVType * llvm::SPIRV::lowerBuiltinType (const StructType *OpaqueType, SPIRV::AccessQualifier::AccessQualifier AccessQual, MachineIRBuilder &MIRBuilder, SPIRVGlobalRegistry *GR)
 

Macro Definition Documentation

◆ DEBUG_TYPE

#define DEBUG_TYPE   "spirv-builtins"

Definition at line 22 of file SPIRVBuiltins.cpp.

◆ GET_BuiltinGroup_DECL

#define GET_BuiltinGroup_DECL

Definition at line 26 of file SPIRVBuiltins.cpp.

◆ GET_CLMemoryFenceFlags_DECL

#define GET_CLMemoryFenceFlags_DECL

Definition at line 130 of file SPIRVBuiltins.cpp.

◆ GET_CLMemoryScope_DECL

#define GET_CLMemoryScope_DECL

Definition at line 128 of file SPIRVBuiltins.cpp.

◆ GET_CLSamplerAddressingMode_DECL

#define GET_CLSamplerAddressingMode_DECL

Definition at line 129 of file SPIRVBuiltins.cpp.

◆ GET_ConvertBuiltins_DECL

#define GET_ConvertBuiltins_DECL

Definition at line 121 of file SPIRVBuiltins.cpp.

◆ GET_ConvertBuiltins_IMPL

#define GET_ConvertBuiltins_IMPL

Definition at line 122 of file SPIRVBuiltins.cpp.

◆ GET_DemangledBuiltins_DECL

#define GET_DemangledBuiltins_DECL

Definition at line 37 of file SPIRVBuiltins.cpp.

◆ GET_DemangledBuiltins_IMPL

#define GET_DemangledBuiltins_IMPL

Definition at line 38 of file SPIRVBuiltins.cpp.

◆ GET_DemangledTypes_DECL

#define GET_DemangledTypes_DECL

Definition at line 1807 of file SPIRVBuiltins.cpp.

◆ GET_DemangledTypes_IMPL

#define GET_DemangledTypes_IMPL

Definition at line 1808 of file SPIRVBuiltins.cpp.

◆ GET_ExtendedBuiltins_DECL

#define GET_ExtendedBuiltins_DECL

Definition at line 131 of file SPIRVBuiltins.cpp.

◆ GET_GetBuiltins_DECL

#define GET_GetBuiltins_DECL

Definition at line 91 of file SPIRVBuiltins.cpp.

◆ GET_GetBuiltins_IMPL

#define GET_GetBuiltins_IMPL

Definition at line 92 of file SPIRVBuiltins.cpp.

◆ GET_GroupBuiltins_DECL

#define GET_GroupBuiltins_DECL

Definition at line 81 of file SPIRVBuiltins.cpp.

◆ GET_GroupBuiltins_IMPL

#define GET_GroupBuiltins_IMPL

Definition at line 82 of file SPIRVBuiltins.cpp.

◆ GET_ImageQueryBuiltins_DECL

#define GET_ImageQueryBuiltins_DECL

Definition at line 100 of file SPIRVBuiltins.cpp.

◆ GET_ImageQueryBuiltins_IMPL

#define GET_ImageQueryBuiltins_IMPL

Definition at line 101 of file SPIRVBuiltins.cpp.

◆ GET_ImageTypes_DECL

#define GET_ImageTypes_DECL

Definition at line 1830 of file SPIRVBuiltins.cpp.

◆ GET_ImageTypes_IMPL

#define GET_ImageTypes_IMPL

Definition at line 1831 of file SPIRVBuiltins.cpp.

◆ GET_NativeBuiltins_DECL

#define GET_NativeBuiltins_DECL

Definition at line 62 of file SPIRVBuiltins.cpp.

◆ GET_NativeBuiltins_IMPL

#define GET_NativeBuiltins_IMPL

Definition at line 63 of file SPIRVBuiltins.cpp.

◆ GET_PipeTypes_DECL

#define GET_PipeTypes_DECL

Definition at line 1832 of file SPIRVBuiltins.cpp.

◆ GET_PipeTypes_IMPL

#define GET_PipeTypes_IMPL

Definition at line 1833 of file SPIRVBuiltins.cpp.

◆ GET_VectorLoadStoreBuiltins_DECL

#define GET_VectorLoadStoreBuiltins_DECL

Definition at line 125 of file SPIRVBuiltins.cpp.

◆ GET_VectorLoadStoreBuiltins_IMPL

#define GET_VectorLoadStoreBuiltins_IMPL

Definition at line 126 of file SPIRVBuiltins.cpp.