16#ifndef LLVM_LIB_TARGET_SPIRV_SPIRVTYPEMANAGER_H
17#define LLVM_LIB_TARGET_SPIRV_SPIRVTYPEMANAGER_H
71 const unsigned PointerSize;
90 std::unordered_map<const MDNode *, MachineInstr *> AliasInstMDMap;
94 SPIRV::AccessQualifier::AccessQualifier AQ,
95 bool ExplicitLayoutRequired,
bool EmitIR);
98 SPIRV::AccessQualifier::AccessQualifier accessQual,
99 bool ExplicitLayoutRequired,
bool EmitIR);
102 SPIRV::AccessQualifier::AccessQualifier AccessQual,
103 bool ExplicitLayoutRequired,
bool EmitIR);
123 Reg2GO[std::make_pair(MF, R)] = V;
126 auto It = Reg2GO.find(std::make_pair(MF, R));
127 return It == Reg2GO.end() ? nullptr : It->second;
132 FunResPointerTypes[ArgF] = DerivedTy;
136 auto It = FunResPointerTypes.find(ArgF);
137 return It == FunResPointerTypes.end() ? nullptr : It->second;
143 AssignPtrTypeInstr[Val] = AssignPtrTyCI;
147 auto It = AssignPtrTypeInstr.find(Val);
148 return It == AssignPtrTypeInstr.end() ? nullptr : It->second;
155 AssignPtrTypeInstr.erase(OldVal);
156 AssignPtrTypeInstr[NewVal] = CI;
166 auto It = MutatedAggRet.find(Val);
167 return It == MutatedAggRet.end() ? nullptr : It->second;
173 ValueAttrs[
Key] = Val;
177 auto It = ValueAttrs.find(
Key);
178 if (It == ValueAttrs.end())
180 Ty = It->second.first;
181 Name = It->second.second;
190 auto It = DeducedElTys.find(Val);
191 return It == DeducedElTys.end() ? nullptr : It->second;
198 DeducedElTys.erase(OldVal);
199 DeducedElTys[NewVal] = Ty;
204 DeducedNestedTys[Val] = Ty;
208 auto It = DeducedNestedTys.find(Val);
209 return It == DeducedNestedTys.end() ? nullptr : It->second;
218 if (
Value *GlobalElem =
219 Global->getNumOperands() > 0 ?
Global->getOperand(0) :
nullptr)
224 return ElementTy ? ElementTy :
Global->getValueType();
232 auto ResF = InstrToFunction.find(
Use);
233 if (ResF == InstrToFunction.end())
235 auto ResReg = FunctionToInstr.find(ResF->second);
236 return ResReg == FunctionToInstr.end() ? nullptr : ResReg->second;
244 auto MOIt = FunctionToInstr.find(
F);
245 return MOIt == FunctionToInstr.end() ? nullptr : MOIt->second->
getParent();
253 auto FIt = FunctionToInstrRev.find(
MI);
254 return FIt == FunctionToInstrRev.
end() ? nullptr : FIt->second;
260 InstrToFunction[MO] =
F;
265 FunctionToInstr[
F] = MO;
274 ForwardCalls[
F].insert(
MI);
280 auto It = ForwardCalls.find(
F);
281 return It == ForwardCalls.end() ? nullptr : &It->second;
288 SPIRV::AccessQualifier::AccessQualifier AQ,
296 unsigned NumElements,
Register VReg,
311 SPIRV::AccessQualifier::AccessQualifier AQ,
319 SPIRV::AccessQualifier::AccessQualifier AQ,
325 auto Res = SPIRVToLLVMType.find(Ty);
326 assert(Res != SPIRVToLLVMType.end());
340 SPIRV::StorageClass::StorageClass SC = SPIRV::StorageClass::Function,
341 SPIRV::AccessQualifier::AccessQualifier AQ =
342 SPIRV::AccessQualifier::ReadWrite);
372 return Type && (
Type->getOpcode() == SPIRV::OpTypeStruct &&
373 Type->getOpcode() == SPIRV::OpTypeArray);
417 SPIRV::StorageClass::StorageClass
434 const Type *adjustIntTypeByWidth(
const Type *Ty)
const;
435 unsigned adjustOpTypeIntWidth(
unsigned Width)
const;
439 SPIRV::AccessQualifier::AccessQualifier AQ,
440 bool ExplicitLayoutRequired,
bool EmitIR);
443 bool IsSigned =
false);
448 SPIRV::FPEncoding::FPEncoding FPEncode);
457 bool ExplicitLayoutRequired,
bool EmitIR);
464 SPIRV::AccessQualifier::AccessQualifier AccQual,
467 SPIRVTypeInst getOpTypePointer(SPIRV::StorageClass::StorageClass SC,
471 SPIRVTypeInst getOpTypeForwardPointer(SPIRV::StorageClass::StorageClass SC,
481 SPIRV::AccessQualifier::AccessQualifier AccQual);
492 unsigned BitWidth,
unsigned ElemCnt,
493 bool ZeroAsNull =
true);
508 SPIRV::StorageClass::StorageClass SC);
521 SPIRV::ImageFormat::ImageFormat ImageFormat,
522 SPIRV::AccessQualifier::AccessQualifier AccQual);
527 bool ZeroAsNull =
true);
530 bool ZeroAsNull =
true);
533 bool ZeroAsNull =
true);
539 bool ZeroAsNull =
true);
549 bool ZeroAsNull =
true);
553 bool ZeroAsNull =
true);
557 bool ZeroAsNull =
true);
572 const GlobalValue *GV, SPIRV::StorageClass::StorageClass Storage,
574 const std::optional<SPIRV::LinkageType::LinkageType> &LinkageType,
588 unsigned SPIRVOPcode,
Type *LLVMTy);
596 unsigned NumElements,
600 unsigned NumElements,
610 SPIRV::StorageClass::StorageClass SC);
613 SPIRV::StorageClass::StorageClass SC);
622 SPIRV::StorageClass::StorageClass SC);
629 SPIRV::StorageClass::StorageClass SC,
634 SPIRV::StorageClass::StorageClass SC,
635 bool IsWritable,
bool EmitIr =
false);
644 bool EmitIr =
false);
648 const SPIRV::AccessQualifier::AccessQualifier Qualifier,
663 SPIRV::AccessQualifier::AccessQualifier AccQual);
682 const MDNode *AliasingListMD);
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
DXIL Resource Implicit Binding
const HexagonInstrInfo * TII
This file declares the MachineIRBuilder class.
BaseType
A given derived pointer can have multiple base pointers through phi/selects.
Class for arbitrary precision integers.
ArrayRef - 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.
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 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 getOrCreateSPIRVType(const Type *Type, MachineIRBuilder &MIRBuilder, SPIRV::AccessQualifier::AccessQualifier AQ, bool EmitIR)
SPIRVTypeInst assignVectTypeToVReg(SPIRVTypeInst BaseType, unsigned NumElements, Register VReg, MachineInstr &I, const SPIRVInstrInfo &TII)
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
MachineInstr * getOrAddMemAliasingINTELInst(MachineIRBuilder &MIRBuilder, const MDNode *AliasingListMD)
bool isAggregateType(SPIRVTypeInst Type) const
void setBound(unsigned V)
unsigned getScalarOrVectorBitWidth(SPIRVTypeInst Type) const
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
SPIRVTypeInst assignFloatTypeToVReg(unsigned BitWidth, Register VReg, MachineInstr &I, const SPIRVInstrInfo &TII)
const Type * getTypeForSPIRVType(SPIRVTypeInst Ty) const
bool isBitcastCompatible(SPIRVTypeInst Type1, SPIRVTypeInst Type2) const
void addDeducedElementType(Value *Val, Type *Ty)
SPIRVGlobalRegistry(unsigned PointerSize)
SPIRVTypeInst getOrCreatePaddingType(MachineIRBuilder &MIRBuilder)
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)
const MachineOperand * getFunctionDefinitionByUse(const MachineOperand *Use)
void invalidateMachineInstr(MachineInstr *MI)
bool isResourceType(SPIRVTypeInst Type) const
SPIRVTypeInst getOrCreateSPIRVBoolType(MachineIRBuilder &MIRBuilder, bool EmitIR)
SPIRVTypeInst getOrCreateSPIRVPointerType(const Type *BaseType, MachineIRBuilder &MIRBuilder, SPIRV::StorageClass::StorageClass SC)
void addMutated(Value *Val, Type *Ty)
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 getPointeeTypeOp(Register PtrReg)
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)
SPIRVTypeInst getOrCreateUnknownType(const Type *Ty, MachineIRBuilder &MIRBuilder, unsigned Opcode, const ArrayRef< MCOperand > Operands)
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
bool hasSPIRVTypeForVReg(Register VReg) const
void addDeducedCompositeType(Value *Val, Type *Ty)
void buildAssignType(IRBuilder<> &B, Type *Ty, Value *Arg)
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)
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
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
Type * findDeducedElementType(const Value *Val)
Register buildConstantSampler(Register Res, unsigned AddrMode, unsigned Param, unsigned FilerMode, MachineIRBuilder &MIRBuilder)
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...
StringRef - 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_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