16#ifndef LLVM_LIB_TARGET_SPIRV_SPIRVGLOBALREGISTRY_H
17#define LLVM_LIB_TARGET_SPIRV_SPIRVGLOBALREGISTRY_H
92 UntypedPointerElementTypes;
108 SPIRV::AccessQualifier::AccessQualifier AQ,
109 bool ExplicitLayoutRequired,
bool EmitIR);
112 SPIRV::AccessQualifier::AccessQualifier accessQual,
113 bool ExplicitLayoutRequired,
bool EmitIR);
116 SPIRV::AccessQualifier::AccessQualifier AccessQual,
117 bool ExplicitLayoutRequired,
bool EmitIR);
119 void addTypeKey(
const Type *Ty,
bool ExplicitLayoutRequired,
140 Reg2GO[std::make_pair(MF, R)] =
V;
143 auto It = Reg2GO.find(std::make_pair(MF, R));
144 return It == Reg2GO.end() ? nullptr : It->second;
149 FunResPointerTypes[ArgF] = DerivedTy;
153 auto It = FunResPointerTypes.find(ArgF);
154 return It == FunResPointerTypes.end() ? nullptr : It->second;
160 AssignPtrTypeInstr[Val] = AssignPtrTyCI;
164 AssignPtrTypeInstr.erase(OldVal);
168 auto It = AssignPtrTypeInstr.find(Val);
169 return It == AssignPtrTypeInstr.end() ? nullptr : It->second;
176 AssignPtrTypeInstr.erase(OldVal);
177 AssignPtrTypeInstr[NewVal] = CI;
187 auto It = MutatedAggRet.find(Val);
188 return It == MutatedAggRet.end() ? nullptr : It->second;
194 ValueAttrs[
Key] = Val;
198 auto It = ValueAttrs.find(
Key);
199 if (It == ValueAttrs.end())
201 Ty = It->second.first;
202 Name = It->second.second;
211 auto It = DeducedElTys.find(Val);
212 return It == DeducedElTys.end() ? nullptr : It->second;
219 DeducedElTys.erase(OldVal);
220 DeducedElTys[NewVal] = Ty;
225 DeducedNestedTys[Val] = Ty;
229 auto It = DeducedNestedTys.find(Val);
230 return It == DeducedNestedTys.end() ? nullptr : It->second;
235 UntypedPointerElementTypes[{
CurMF,
Reg}] = ElemType;
239 auto It = UntypedPointerElementTypes.find({
CurMF,
Reg});
240 return It == UntypedPointerElementTypes.end() ? nullptr : It->second;
249 if (
Value *GlobalElem =
250 Global->getNumOperands() > 0 ?
Global->getOperand(0) :
nullptr)
255 return ElementTy ? ElementTy :
Global->getValueType();
263 auto ResF = InstrToFunction.find(
Use);
264 if (ResF == InstrToFunction.end())
266 auto ResReg = FunctionToInstr.find(ResF->second);
267 return ResReg == FunctionToInstr.end() ? nullptr : ResReg->second;
275 auto MOIt = FunctionToInstr.find(
F);
276 return MOIt == FunctionToInstr.end() ? nullptr : MOIt->second->
getParent();
284 auto FIt = FunctionToInstrRev.find(
MI);
285 return FIt == FunctionToInstrRev.
end() ? nullptr : FIt->second;
291 InstrToFunction[MO] =
F;
296 FunctionToInstr[
F] = MO;
305 ForwardCalls[
F].insert(
MI);
311 auto It = ForwardCalls.find(
F);
312 return It == ForwardCalls.end() ? nullptr : &It->second;
319 SPIRV::AccessQualifier::AccessQualifier AQ,
335 SPIRV::AccessQualifier::AccessQualifier AQ,
343 SPIRV::AccessQualifier::AccessQualifier AQ,
349 auto Res = SPIRVToLLVMType.find(Ty);
350 assert(Res != SPIRVToLLVMType.end());
362 SPIRV::StorageClass::StorageClass SC = SPIRV::StorageClass::Function,
363 SPIRV::AccessQualifier::AccessQualifier AQ =
364 SPIRV::AccessQualifier::ReadWrite);
389 return Type && (
Type->getOpcode() == SPIRV::OpTypeStruct ||
390 Type->getOpcode() == SPIRV::OpTypeArray);
441 return DL.getTypeAllocSize(
ElemTy).getFixedValue();
455 SPIRV::StorageClass::StorageClass
460 return DL.getPointerSizeInBits( 0);
486 const Type *adjustIntTypeByWidth(
const Type *Ty)
const;
487 unsigned adjustOpTypeIntWidth(
unsigned Width)
const;
491 SPIRV::AccessQualifier::AccessQualifier AQ,
492 bool ExplicitLayoutRequired,
bool EmitIR);
495 bool IsSigned =
false);
500 SPIRV::FPEncoding::FPEncoding FPEncode);
504 bool IsLongVectorEXT =
false);
514 bool ExplicitLayoutRequired,
bool EmitIR);
521 SPIRV::AccessQualifier::AccessQualifier AccQual,
524 SPIRVTypeInst getOpTypePointer(SPIRV::StorageClass::StorageClass SC,
535 SPIRV::AccessQualifier::AccessQualifier AccQual);
546 unsigned BitWidth,
unsigned ElemCnt,
547 bool ZeroAsNull =
true);
564 SPIRV::StorageClass::StorageClass SC,
bool ForceTyped =
false);
578 SPIRV::ImageFormat::ImageFormat ImageFormat,
579 SPIRV::AccessQualifier::AccessQualifier AccQual);
584 bool ZeroAsNull =
true);
587 bool ZeroAsNull =
true);
590 bool ZeroAsNull =
true);
596 bool ZeroAsNull =
true);
606 bool ZeroAsNull =
true);
610 bool ZeroAsNull =
true);
614 bool ZeroAsNull =
true);
629 const GlobalValue *GV, SPIRV::StorageClass::StorageClass Storage,
631 const std::optional<SPIRV::LinkageType::LinkageType> &LinkageType,
645 unsigned SPIRVOPcode,
Type *LLVMTy);
653 unsigned NumElements,
657 unsigned NumElements,
669 SPIRV::StorageClass::StorageClass SC,
670 bool ForceTyped =
false,
bool EmitIR =
true);
673 SPIRV::StorageClass::StorageClass SC,
674 bool ForceTyped =
false);
682 SPIRV::StorageClass::StorageClass SC) {
693 SPIRV::StorageClass::StorageClass SC,
bool EmitIR =
true);
700 SPIRV::StorageClass::StorageClass SC,
710 SPIRV::StorageClass::StorageClass SC,
711 bool IsWritable,
bool EmitIr =
false);
722 bool EmitIr =
false);
726 const SPIRV::AccessQualifier::AccessQualifier Qualifier,
741 SPIRV::AccessQualifier::AccessQualifier AccQual);
760 const MDNode *AliasingListMD);
768 bool CanUseAnyVectorRank);
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
const AArch64InstrInfo & TII
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
DXIL Resource Implicit Binding
This file defines the DenseSet and SmallDenseSet classes.
This file declares the MachineIRBuilder class.
BaseType
A given derived pointer can have multiple base pointers through phi/selects.
Class for arbitrary precision integers.
Represent a constant reference to an array (0 or more elements consecutively in memory),...
This class represents a function call, abstracting a target machine's calling convention.
ConstantFP - Floating Point Values [float, double].
This is the shared class of boolean and integer constants.
This is an important base class in LLVM.
A parsed version of the target data layout string in and methods for querying it.
Implements a dense probed hash-table based set.
Class to represent function types.
This provides a uniform API for creating instructions and inserting them into a basic block: either a...
Helper class to build MachineInstr.
Representation of each machine instruction.
const MachineBasicBlock * getParent() const
MachineOperand class - Representation of each machine instruction operand.
MachineInstr * getParent()
getParent - Return the instruction that this operand belongs to.
Wrapper class representing virtual and physical registers.
void buildAssignType(IRBuilder<> &B, Type *Ty, Value *Arg, bool CanUseAnyVectorRank)
void recordFunctionDefinition(const Function *F, const MachineOperand *MO)
SPIRVTypeInst getImageType(const TargetExtType *ExtensionType, const SPIRV::AccessQualifier::AccessQualifier Qualifier, MachineIRBuilder &MIRBuilder)
const TypedPointerType * findReturnType(const Function *ArgF)
bool isScalarOrVectorSigned(SPIRVTypeInst Type) const
void addForwardCall(const Function *F, MachineInstr *MI)
void addAssignPtrTypeInstr(Value *Val, CallInst *AssignPtrTyCI)
const Value * getGlobalObject(const MachineFunction *MF, Register R)
SPIRVTypeInst getOrCreateOpTypeSampledImage(SPIRVTypeInst ImageType, MachineIRBuilder &MIRBuilder)
unsigned getNumScalarOrVectorTotalBitWidth(SPIRVTypeInst Type) const
SPIRVTypeInst getOrCreateUnknownType(const Type *Ty, MachineIRBuilder &MIRBuilder, unsigned Opcode, const ArrayRef< MachineOperand > Operands)
SPIRVTypeInst getOrCreateSPIRVType(const Type *Type, MachineIRBuilder &MIRBuilder, SPIRV::AccessQualifier::AccessQualifier AQ, bool EmitIR)
void assignSPIRVTypeToVReg(SPIRVTypeInst Type, Register VReg, const MachineFunction &MF)
SPIRVTypeInst getOrCreateOpTypeFunctionWithArgs(const Type *Ty, SPIRVTypeInst RetType, const SmallVectorImpl< SPIRVTypeInst > &ArgTypes, MachineIRBuilder &MIRBuilder)
void buildAssignPtr(IRBuilder<> &B, Type *ElemTy, Value *Arg)
const TargetRegisterClass * getRegClass(SPIRVTypeInst SpvType) const
SPIRVTypeInst getOrCreateSPIRVPointerType(const Type *BaseType, MachineIRBuilder &MIRBuilder, SPIRV::StorageClass::StorageClass SC, bool ForceTyped=false, bool EmitIR=true)
MachineInstr * getOrAddMemAliasingINTELInst(MachineIRBuilder &MIRBuilder, const MDNode *AliasingListMD)
bool isAggregateType(SPIRVTypeInst Type) const
void setBound(unsigned V)
SPIRVTypeInst getOrCreateSPIRVTypedPointerType(const Type *BaseType, MachineIRBuilder &MIRBuilder, SPIRV::StorageClass::StorageClass SC)
unsigned getScalarOrVectorBitWidth(SPIRVTypeInst Type) const
void setUntypedPtrElementType(Register Reg, SPIRVTypeInst ElemType)
SPIRVTypeInst getOrCreateSPIRVIntegerType(unsigned BitWidth, MachineIRBuilder &MIRBuilder)
SPIRVTypeInst getOrCreateSPIRVVectorType(SPIRVTypeInst BaseType, unsigned NumElements, MachineIRBuilder &MIRBuilder, bool EmitIR)
SPIRVTypeInst getOrCreateSPIRVTypeByName(StringRef TypeStr, MachineIRBuilder &MIRBuilder, bool EmitIR, SPIRV::StorageClass::StorageClass SC=SPIRV::StorageClass::Function, SPIRV::AccessQualifier::AccessQualifier AQ=SPIRV::AccessQualifier::ReadWrite)
Register buildGlobalVariable(Register Reg, SPIRVTypeInst BaseType, StringRef Name, const GlobalValue *GV, SPIRV::StorageClass::StorageClass Storage, const MachineInstr *Init, bool IsConst, const std::optional< SPIRV::LinkageType::LinkageType > &LinkageType, MachineIRBuilder &MIRBuilder, bool IsInstSelector)
SPIRVTypeInst assignIntTypeToVReg(unsigned BitWidth, Register VReg, MachineInstr &I, const SPIRVInstrInfo &TII)
SPIRVTypeInst getResultType(Register VReg, MachineFunction *MF=nullptr)
Type * findDeducedCompositeType(const Value *Val)
void replaceAllUsesWith(Value *Old, Value *New, bool DeleteOld=true)
SPIRVTypeInst getOrCreateOpTypeByOpcode(const Type *Ty, MachineIRBuilder &MIRBuilder, unsigned Opcode)
unsigned getScalarOrVectorComponentCount(Register VReg) const
const Type * getTypeForSPIRVType(SPIRVTypeInst Ty) const
bool isBitcastCompatible(SPIRVTypeInst Type1, SPIRVTypeInst Type2) const
void addDeducedElementType(Value *Val, Type *Ty)
bool shouldKeepTypedPtrType(SPIRVTypeInst ElemType) const
unsigned getPointerSize() const
Register getOrCreateConstFP(APFloat Val, MachineInstr &I, SPIRVTypeInst SpvType, const SPIRVInstrInfo &TII, bool ZeroAsNull=true)
const MachineInstr * getFunctionDefinition(const Function *F)
LLT getRegType(SPIRVTypeInst SpvType) const
void addReturnType(const Function *ArgF, TypedPointerType *DerivedTy)
SPIRVGlobalRegistry(DataLayout DL)
const MachineOperand * getFunctionDefinitionByUse(const MachineOperand *Use)
Register getLastInsertedTypeReg(const MachineFunction &MF) const
SPIRVTypeInst getOpTypeVoid(MachineIRBuilder &MIRBuilder)
void invalidateMachineInstr(MachineInstr *MI)
bool isResourceType(SPIRVTypeInst Type) const
SPIRVTypeInst getOrCreateSPIRVBoolType(MachineIRBuilder &MIRBuilder, bool EmitIR)
void addMutated(Value *Val, Type *Ty)
void setLastInsertedType(const MachineFunction &MF, MachineInstr *MI)
void updateIfExistDeducedElementType(Value *OldVal, Value *NewVal, bool DeleteOld)
bool isScalarOfType(Register VReg, unsigned TypeOpcode) const
Register getSPIRVTypeID(SPIRVTypeInst SpirvType) const
Register getOrCreateConstInt(uint64_t Val, MachineInstr &I, SPIRVTypeInst SpvType, const SPIRVInstrInfo &TII, bool ZeroAsNull=true)
Register getOrCreateConstIntArray(uint64_t Val, size_t Num, MachineInstr &I, SPIRVTypeInst SpvType, const SPIRVInstrInfo &TII)
bool findValueAttrs(const MachineInstr *Key, Type *&Ty, StringRef &Name)
unsigned getDeducedPointeeByteSize(const Value *PtrVal)
SPIRVTypeInst retrieveScalarOrVectorIntType(SPIRVTypeInst Type) const
Register getOrCreateGlobalVariableWithBinding(SPIRVTypeInst VarType, uint32_t Set, uint32_t Binding, StringRef Name, MachineIRBuilder &MIRBuilder)
SPIRVTypeInst getOrCreateOpTypeCoopMatr(MachineIRBuilder &MIRBuilder, const TargetExtType *ExtensionType, SPIRVTypeInst ElemType, uint32_t Scope, uint32_t Rows, uint32_t Columns, uint32_t Use, bool EmitIR)
SPIRVTypeInst changePointerStorageClass(SPIRVTypeInst PtrType, SPIRV::StorageClass::StorageClass SC, MachineInstr &I)
Type * findMutated(const Value *Val)
Register getOrCreateConstVector(uint64_t Val, MachineInstr &I, SPIRVTypeInst SpvType, const SPIRVInstrInfo &TII, bool ZeroAsNull=true)
Register buildConstantFP(APFloat Val, MachineIRBuilder &MIRBuilder, SPIRVTypeInst SpvType=nullptr)
SPIRVTypeInst getOrCreateOpTypePipe(MachineIRBuilder &MIRBuilder, SPIRV::AccessQualifier::AccessQualifier AccQual)
void addGlobalObject(const Value *V, const MachineFunction *MF, Register R)
SPIRVTypeInst getScalarOrVectorComponentType(SPIRVTypeInst Type) const
void addDeducedCompositeType(Value *Val, Type *Ty)
void recordFunctionPointer(const MachineOperand *MO, const Function *F)
SPIRVTypeInst getOrCreateSPIRVFloatType(unsigned BitWidth, MachineInstr &I, const SPIRVInstrInfo &TII)
SPIRVTypeInst getOrCreateVulkanBufferType(MachineIRBuilder &MIRBuilder, Type *ElemType, SPIRV::StorageClass::StorageClass SC, bool IsWritable, bool EmitIr=false)
SPIRVTypeInst getPointeeType(SPIRVTypeInst PtrType)
SmallPtrSet< MachineInstr *, 8 > * getForwardCalls(const Function *F)
SPIRVTypeInst getOrCreateSPIRVType(const Type *Type, MachineInstr &I, SPIRV::AccessQualifier::AccessQualifier AQ, bool EmitIR)
Register getOrCreateConsIntVector(uint64_t Val, MachineIRBuilder &MIRBuilder, SPIRVTypeInst SpvType, bool EmitIR)
void updateIfExistAssignPtrTypeInstr(Value *OldVal, Value *NewVal, bool DeleteOld)
SPIRVTypeInst assignTypeToVReg(const Type *Type, Register VReg, MachineIRBuilder &MIRBuilder, SPIRV::AccessQualifier::AccessQualifier AQ, bool EmitIR)
bool isScalarOrVectorOfType(Register VReg, unsigned TypeOpcode) const
SPIRVTypeInst getOrCreateLayoutType(MachineIRBuilder &MIRBuilder, const TargetExtType *T, bool EmitIr=false)
MachineFunction * setCurrentFunc(MachineFunction &MF)
void restoreFromMIR(const MachineFunction &MF)
SPIRVTypeInst getOrCreatePaddingType(MachineIRBuilder &MIRBuilder, uint64_t PaddingSizeInBytes, uint64_t OffsetInBytes=0)
Register createConstInt(const ConstantInt *CI, MachineInstr &I, SPIRVTypeInst SpvType, const SPIRVInstrInfo &TII, bool ZeroAsNull)
Register getOrCreateConstNullPtr(MachineIRBuilder &MIRBuilder, SPIRVTypeInst SpvType)
SPIRVTypeInst getSPIRVTypeForVReg(Register VReg, const MachineFunction *MF=nullptr) const
SPIRVTypeInst getOrCreateSPIRVUntypedPointerType(SPIRV::StorageClass::StorageClass SC, MachineIRBuilder &MIRBuilder)
Type * getDeducedGlobalValueType(const GlobalValue *Global)
Register getOrCreateUndef(MachineInstr &I, SPIRVTypeInst SpvType, const SPIRVInstrInfo &TII)
SPIRVTypeInst getOrCreateOpTypeSampler(MachineIRBuilder &MIRBuilder)
void addValueAttrs(MachineInstr *Key, std::pair< Type *, std::string > Val)
const Function * getFunctionByDefinition(const MachineInstr *MI)
void buildMemAliasingOpDecorate(Register Reg, MachineIRBuilder &MIRBuilder, uint32_t Dec, const MDNode *GVarMD)
SPIRV::StorageClass::StorageClass getPointerStorageClass(Register VReg) const
void removeAssignPtrTypeInstr(Value *OldVal)
bool shouldUseUntypedPointer(SPIRVTypeInst ElemType, const SPIRVSubtarget &ST) const
Type * findDeducedElementType(const Value *Val)
Register buildConstantSampler(Register Res, unsigned AddrMode, unsigned Param, unsigned FilerMode, MachineIRBuilder &MIRBuilder)
SmallVector< std::pair< Register, Register > > getVRegTypeIDs(const MachineFunction &MF) const
SPIRVTypeInst getUntypedPtrElementType(Register Reg) const
void updateAssignType(CallInst *AssignCI, Value *Arg, Value *OfType)
CallInst * findAssignPtrTypeInstr(const Value *Val)
Register buildConstantInt(uint64_t Val, MachineIRBuilder &MIRBuilder, SPIRVTypeInst SpvType, bool EmitIR, bool ZeroAsNull=true)
SPIRVTypeInst getOrCreateVulkanPushConstantType(MachineIRBuilder &MIRBuilder, Type *ElemType)
Register createConstFP(const ConstantFP *CF, MachineInstr &I, SPIRVTypeInst SpvType, const SPIRVInstrInfo &TII, bool ZeroAsNull)
SPIRVTypeInst getOrCreateOpTypeDeviceEvent(MachineIRBuilder &MIRBuilder)
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Represent a constant reference to a string, i.e.
Class to represent struct types.
Class to represent target extensions types, which are generally unintrospectable from target-independ...
The instances of the Type class are immutable: once they are created, they are never changed.
A few GPU targets, such as DXIL and SPIR-V, have typed pointers.
A Use represents the edge between a Value definition and its users.
LLVM Value Representation.
FunctionType * getOriginalFunctionType(const Function &F)
This is an optimization pass for GlobalISel generic memory operations.
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
LLVM_ABI void constrainSelectedInstRegOperands(MachineInstr &I, const TargetInstrInfo &TII, const TargetRegisterInfo &TRI, const RegisterBankInfo &RBI)
Mutate the newly-selected instruction I to constrain its (possibly generic) virtual register operands...
LLVM_ATTRIBUTE_VISIBILITY_DEFAULT AnalysisKey InnerAnalysisManagerProxy< AnalysisManagerT, IRUnitT, ExtraArgTs... >::Key
std::function< void(Register)> StructOffsetDecorator
@ Global
Append to llvm.global_dtors.
DWARFExpression::Operation Op
constexpr unsigned BitWidth
MCRegisterClass TargetRegisterClass