16#ifndef LLVM_LIB_TARGET_SPIRV_SPIRVTYPEMANAGER_H
17#define LLVM_LIB_TARGET_SPIRV_SPIRVTYPEMANAGER_H
70 const unsigned PointerSize;
89 std::unordered_map<const MDNode *, MachineInstr *> AliasInstMDMap;
93 SPIRV::AccessQualifier::AccessQualifier AQ,
94 bool ExplicitLayoutRequired,
bool EmitIR);
96 SPIRV::AccessQualifier::AccessQualifier accessQual,
97 bool ExplicitLayoutRequired,
bool EmitIR);
100 SPIRV::AccessQualifier::AccessQualifier AccessQual,
101 bool ExplicitLayoutRequired,
bool EmitIR);
119 Reg2GO[std::make_pair(MF, R)] = V;
122 auto It = Reg2GO.
find(std::make_pair(MF, R));
123 return It == Reg2GO.
end() ? nullptr : It->second;
128 FunResPointerTypes[ArgF] = DerivedTy;
132 auto It = FunResPointerTypes.
find(ArgF);
133 return It == FunResPointerTypes.
end() ? nullptr : It->second;
139 AssignPtrTypeInstr[Val] = AssignPtrTyCI;
143 auto It = AssignPtrTypeInstr.
find(Val);
144 return It == AssignPtrTypeInstr.
end() ? nullptr : It->second;
151 AssignPtrTypeInstr.
erase(OldVal);
152 AssignPtrTypeInstr[NewVal] = CI;
162 auto It = MutatedAggRet.
find(Val);
163 return It == MutatedAggRet.
end() ? nullptr : It->second;
169 ValueAttrs[Key] = Val;
173 auto It = ValueAttrs.
find(Key);
174 if (It == ValueAttrs.
end())
176 Ty = It->second.first;
177 Name = It->second.second;
186 auto It = DeducedElTys.
find(Val);
187 return It == DeducedElTys.
end() ? nullptr : It->second;
194 DeducedElTys.
erase(OldVal);
195 DeducedElTys[NewVal] = Ty;
200 DeducedNestedTys[Val] = Ty;
204 auto It = DeducedNestedTys.
find(Val);
205 return It == DeducedNestedTys.
end() ? nullptr : It->second;
214 if (
Value *GlobalElem =
215 Global->getNumOperands() > 0 ?
Global->getOperand(0) :
nullptr)
218 return ElementTy ? ElementTy :
Global->getValueType();
226 auto ResF = InstrToFunction.
find(
Use);
227 if (ResF == InstrToFunction.
end())
229 auto ResReg = FunctionToInstr.
find(ResF->second);
230 return ResReg == FunctionToInstr.
end() ? nullptr : ResReg->second;
238 auto MOIt = FunctionToInstr.
find(
F);
239 return MOIt == FunctionToInstr.
end() ? nullptr : MOIt->second->getParent();
247 auto FIt = FunctionToInstrRev.
find(
MI);
248 return FIt == FunctionToInstrRev.
end() ? nullptr : FIt->second;
254 InstrToFunction[MO] =
F;
259 FunctionToInstr[
F] = MO;
274 auto It = ForwardCalls.
find(
F);
275 return It == ForwardCalls.
end() ? nullptr : &It->second;
282 SPIRV::AccessQualifier::AccessQualifier AQ,
303 SPIRV::AccessQualifier::AccessQualifier AQ,
311 SPIRV::AccessQualifier::AccessQualifier AQ,
317 auto Res = SPIRVToLLVMType.
find(Ty);
332 SPIRV::StorageClass::StorageClass SC = SPIRV::StorageClass::Function,
333 SPIRV::AccessQualifier::AccessQualifier AQ =
334 SPIRV::AccessQualifier::ReadWrite);
364 return Type && (
Type->getOpcode() == SPIRV::OpTypeStruct &&
365 Type->getOpcode() == SPIRV::OpTypeArray);
410 SPIRV::StorageClass::StorageClass
428 const Type *adjustIntTypeByWidth(
const Type *Ty)
const;
429 unsigned adjustOpTypeIntWidth(
unsigned Width)
const;
433 SPIRV::AccessQualifier::AccessQualifier AQ,
434 bool ExplicitLayoutRequired,
bool EmitIR);
437 bool IsSigned =
false);
448 bool ExplicitLayoutRequired,
bool EmitIR);
454 SPIRV::AccessQualifier::AccessQualifier AccQual,
457 SPIRVType *getOpTypePointer(SPIRV::StorageClass::StorageClass SC,
461 SPIRVType *getOpTypeForwardPointer(SPIRV::StorageClass::StorageClass SC,
470 SPIRV::AccessQualifier::AccessQualifier AccQual);
480 unsigned BitWidth,
unsigned ElemCnt,
481 bool ZeroAsNull =
true);
496 SPIRV::StorageClass::StorageClass SC);
508 SPIRV::ImageFormat::ImageFormat ImageFormat,
509 SPIRV::AccessQualifier::AccessQualifier AccQual);
514 bool ZeroAsNull =
true);
517 bool ZeroAsNull =
true);
523 bool ZeroAsNull =
true);
532 bool ZeroAsNull =
true);
535 bool ZeroAsNull =
true);
550 SPIRV::StorageClass::StorageClass Storage,
553 SPIRV::LinkageType::LinkageType LinkageType,
555 bool IsInstSelector);
568 unsigned SPIRVOPcode,
Type *LLVMTy);
576 unsigned NumElements,
588 SPIRV::StorageClass::StorageClass SC);
590 SPIRV::StorageClass::StorageClass SC);
598 SPIRV::StorageClass::StorageClass SC);
605 SPIRV::StorageClass::StorageClass SC,
610 SPIRV::StorageClass::StorageClass SC,
611 bool IsWritable,
bool EmitIr =
false);
618 const SPIRV::AccessQualifier::AccessQualifier Qualifier,
633 SPIRV::AccessQualifier::AccessQualifier AccQual);
652 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
mir Rename Register Operands
This file declares the MachineIRBuilder class.
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.
This class represents an Operation in the Expression.
iterator find(const_arg_type_t< KeyT > Val)
bool erase(const KeyT &Val)
std::pair< iterator, bool > insert(const std::pair< KeyT, ValueT > &KV)
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.
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.
SPIRVType * getOrCreateOpTypePipe(MachineIRBuilder &MIRBuilder, SPIRV::AccessQualifier::AccessQualifier AccQual)
void recordFunctionDefinition(const Function *F, const MachineOperand *MO)
unsigned getNumScalarOrVectorTotalBitWidth(const SPIRVType *Type) const
SPIRVType * getSPIRVTypeForVReg(Register VReg, const MachineFunction *MF=nullptr) const
const TypedPointerType * findReturnType(const Function *ArgF)
void addForwardCall(const Function *F, MachineInstr *MI)
Register getOrCreateConstInt(uint64_t Val, MachineInstr &I, SPIRVType *SpvType, const SPIRVInstrInfo &TII, bool ZeroAsNull=true)
SPIRVType * getResultType(Register VReg, MachineFunction *MF=nullptr)
void addAssignPtrTypeInstr(Value *Val, CallInst *AssignPtrTyCI)
SPIRVType * getOrCreateSPIRVBoolType(MachineIRBuilder &MIRBuilder, bool EmitIR)
const Value * getGlobalObject(const MachineFunction *MF, Register R)
void buildAssignPtr(IRBuilder<> &B, Type *ElemTy, Value *Arg)
SPIRVType * assignFloatTypeToVReg(unsigned BitWidth, Register VReg, MachineInstr &I, const SPIRVInstrInfo &TII)
MachineInstr * getOrAddMemAliasingINTELInst(MachineIRBuilder &MIRBuilder, const MDNode *AliasingListMD)
void assignSPIRVTypeToVReg(SPIRVType *Type, Register VReg, const MachineFunction &MF)
void setBound(unsigned V)
SPIRVType * assignVectTypeToVReg(SPIRVType *BaseType, unsigned NumElements, Register VReg, MachineInstr &I, const SPIRVInstrInfo &TII)
Register getOrCreateUndef(MachineInstr &I, SPIRVType *SpvType, const SPIRVInstrInfo &TII)
Type * findDeducedCompositeType(const Value *Val)
void replaceAllUsesWith(Value *Old, Value *New, bool DeleteOld=true)
SPIRVType * changePointerStorageClass(SPIRVType *PtrType, SPIRV::StorageClass::StorageClass SC, MachineInstr &I)
const Type * getTypeForSPIRVType(const SPIRVType *Ty) const
SPIRVType * getOrCreateUnknownType(const Type *Ty, MachineIRBuilder &MIRBuilder, unsigned Opcode, const ArrayRef< MCOperand > Operands)
bool isBitcastCompatible(const SPIRVType *Type1, const SPIRVType *Type2) const
unsigned getScalarOrVectorComponentCount(Register VReg) const
Register createConstInt(const ConstantInt *CI, MachineInstr &I, SPIRVType *SpvType, const SPIRVInstrInfo &TII, bool ZeroAsNull)
SPIRVType * getOrCreateSPIRVFloatType(unsigned BitWidth, MachineInstr &I, const SPIRVInstrInfo &TII)
bool isScalarOrVectorSigned(const SPIRVType *Type) const
void addDeducedElementType(Value *Val, Type *Ty)
Register getOrCreateGlobalVariableWithBinding(const SPIRVType *VarType, uint32_t Set, uint32_t Binding, StringRef Name, MachineIRBuilder &MIRBuilder)
SPIRVType * getOrCreateSPIRVType(const Type *Type, MachineInstr &I, SPIRV::AccessQualifier::AccessQualifier AQ, bool EmitIR)
unsigned getPointerSize() const
SPIRVType * getOrCreateSPIRVPointerType(const Type *BaseType, MachineIRBuilder &MIRBuilder, SPIRV::StorageClass::StorageClass SC)
const MachineInstr * getFunctionDefinition(const Function *F)
void addReturnType(const Function *ArgF, TypedPointerType *DerivedTy)
const MachineOperand * getFunctionDefinitionByUse(const MachineOperand *Use)
SPIRVType * getOrCreateOpTypeByOpcode(const Type *Ty, MachineIRBuilder &MIRBuilder, unsigned Opcode)
Register buildConstantFP(APFloat Val, MachineIRBuilder &MIRBuilder, SPIRVType *SpvType=nullptr)
SPIRVType * getPointeeType(SPIRVType *PtrType)
void invalidateMachineInstr(MachineInstr *MI)
Register getSPIRVTypeID(const SPIRVType *SpirvType) const
void addMutated(Value *Val, Type *Ty)
Register createConstFP(const ConstantFP *CF, MachineInstr &I, SPIRVType *SpvType, const SPIRVInstrInfo &TII, bool ZeroAsNull)
void updateIfExistDeducedElementType(Value *OldVal, Value *NewVal, bool DeleteOld)
bool isScalarOfType(Register VReg, unsigned TypeOpcode) const
Register buildGlobalVariable(Register Reg, SPIRVType *BaseType, StringRef Name, const GlobalValue *GV, SPIRV::StorageClass::StorageClass Storage, const MachineInstr *Init, bool IsConst, bool HasLinkageTy, SPIRV::LinkageType::LinkageType LinkageType, MachineIRBuilder &MIRBuilder, bool IsInstSelector)
SPIRVType * assignIntTypeToVReg(unsigned BitWidth, Register VReg, MachineInstr &I, const SPIRVInstrInfo &TII)
bool findValueAttrs(const MachineInstr *Key, Type *&Ty, StringRef &Name)
unsigned getPointeeTypeOp(Register PtrReg)
SPIRVType * getOrCreateOpTypeSampledImage(SPIRVType *ImageType, MachineIRBuilder &MIRBuilder)
SPIRVType * getOrCreateVulkanBufferType(MachineIRBuilder &MIRBuilder, Type *ElemType, SPIRV::StorageClass::StorageClass SC, bool IsWritable, bool EmitIr=false)
SPIRVType * getOrCreateSPIRVTypeByName(StringRef TypeStr, MachineIRBuilder &MIRBuilder, bool EmitIR, SPIRV::StorageClass::StorageClass SC=SPIRV::StorageClass::Function, SPIRV::AccessQualifier::AccessQualifier AQ=SPIRV::AccessQualifier::ReadWrite)
Type * findMutated(const Value *Val)
SPIRVType * getOrCreateLayoutType(MachineIRBuilder &MIRBuilder, const TargetExtType *T, bool EmitIr=false)
void addGlobalObject(const Value *V, const MachineFunction *MF, Register R)
SPIRVType * getScalarOrVectorComponentType(Register VReg) const
bool hasSPIRVTypeForVReg(Register VReg) const
void addDeducedCompositeType(Value *Val, Type *Ty)
SPIRVType * getOrCreateOpTypeFunctionWithArgs(const Type *Ty, SPIRVType *RetType, const SmallVectorImpl< SPIRVType * > &ArgTypes, MachineIRBuilder &MIRBuilder)
void buildAssignType(IRBuilder<> &B, Type *Ty, Value *Arg)
void recordFunctionPointer(const MachineOperand *MO, const Function *F)
Register getOrCreateConsIntVector(uint64_t Val, MachineIRBuilder &MIRBuilder, SPIRVType *SpvType, bool EmitIR)
SmallPtrSet< MachineInstr *, 8 > * getForwardCalls(const Function *F)
bool isAggregateType(SPIRVType *Type) const
const TargetRegisterClass * getRegClass(SPIRVType *SpvType) const
void updateIfExistAssignPtrTypeInstr(Value *OldVal, Value *NewVal, bool DeleteOld)
SPIRVType * getOrCreateSPIRVVectorType(SPIRVType *BaseType, unsigned NumElements, MachineIRBuilder &MIRBuilder, bool EmitIR)
SPIRVType * getOrCreateOpTypeCoopMatr(MachineIRBuilder &MIRBuilder, const TargetExtType *ExtensionType, const SPIRVType *ElemType, uint32_t Scope, uint32_t Rows, uint32_t Columns, uint32_t Use, bool EmitIR)
bool isScalarOrVectorOfType(Register VReg, unsigned TypeOpcode) const
Register getOrCreateConstIntArray(uint64_t Val, size_t Num, MachineInstr &I, SPIRVType *SpvType, const SPIRVInstrInfo &TII)
MachineFunction * setCurrentFunc(MachineFunction &MF)
Register getOrCreateConstVector(uint64_t Val, MachineInstr &I, SPIRVType *SpvType, const SPIRVInstrInfo &TII, bool ZeroAsNull=true)
SPIRVType * getOrCreateOpTypeDeviceEvent(MachineIRBuilder &MIRBuilder)
SPIRVType * getOrCreateSPIRVType(const Type *Type, MachineIRBuilder &MIRBuilder, SPIRV::AccessQualifier::AccessQualifier AQ, bool EmitIR)
SPIRVType * getImageType(const TargetExtType *ExtensionType, const SPIRV::AccessQualifier::AccessQualifier Qualifier, MachineIRBuilder &MIRBuilder)
bool isResourceType(SPIRVType *Type) const
SPIRVType * getOrCreateSPIRVIntegerType(unsigned BitWidth, MachineIRBuilder &MIRBuilder)
Register buildConstantInt(uint64_t Val, MachineIRBuilder &MIRBuilder, SPIRVType *SpvType, bool EmitIR, bool ZeroAsNull=true)
Type * getDeducedGlobalValueType(const GlobalValue *Global)
SPIRVType * assignTypeToVReg(const Type *Type, Register VReg, MachineIRBuilder &MIRBuilder, SPIRV::AccessQualifier::AccessQualifier AQ, bool EmitIR)
LLT getRegType(SPIRVType *SpvType) const
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
SPIRVType * getOrCreateOpTypeSampler(MachineIRBuilder &MIRBuilder)
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)
Register getOrCreateConstFP(APFloat Val, MachineInstr &I, SPIRVType *SpvType, const SPIRVInstrInfo &TII, bool ZeroAsNull=true)
CallInst * findAssignPtrTypeInstr(const Value *Val)
Register getOrCreateConstNullPtr(MachineIRBuilder &MIRBuilder, SPIRVType *SpvType)
unsigned getScalarOrVectorBitWidth(const SPIRVType *Type) const
const SPIRVType * retrieveScalarOrVectorIntType(const SPIRVType *Type) const
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.
This is an optimization pass for GlobalISel generic memory operations.
@ Global
Append to llvm.global_dtors.
constexpr unsigned BitWidth
std::function< void(Register)> StructOffsetDecorator