16#ifndef LLVM_LIB_TARGET_SPIRV_SPIRVTYPEMANAGER_H
17#define LLVM_LIB_TARGET_SPIRV_SPIRVTYPEMANAGER_H
77 const unsigned PointerSize;
94 SPIRV::AccessQualifier::AccessQualifier AQ =
95 SPIRV::AccessQualifier::ReadWrite,
98 SPIRV::AccessQualifier::AccessQualifier accessQual =
99 SPIRV::AccessQualifier::ReadWrite,
103 SPIRV::AccessQualifier::AccessQualifier AccessQual,
139 return DT.find(
MI, MF);
143 return DT.find(
C, MF);
147 return DT.find(GV, MF);
151 return DT.find(
F, MF);
157 DT.buildDepsGraph(Graph,
TII, MMI);
165 FunResPointerTypes[ArgF] = DerivedTy;
169 auto It = FunResPointerTypes.
find(ArgF);
170 return It == FunResPointerTypes.
end() ? nullptr : It->second;
176 AssignPtrTypeInstr[Val] = AssignPtrTyCI;
180 auto It = AssignPtrTypeInstr.
find(Val);
181 return It == AssignPtrTypeInstr.
end() ? nullptr : It->second;
188 AssignPtrTypeInstr.
erase(OldVal);
189 AssignPtrTypeInstr[NewVal] = CI;
199 auto It = MutatedAggRet.
find(Val);
200 return It == MutatedAggRet.
end() ? nullptr : It->second;
206 ValueAttrs[Key] = Val;
210 auto It = ValueAttrs.
find(Key);
211 if (It == ValueAttrs.
end())
213 Ty = It->second.first;
214 Name = It->second.second;
223 auto It = DeducedElTys.
find(Val);
224 return It == DeducedElTys.
end() ? nullptr : It->second;
231 DeducedElTys.
erase(OldVal);
232 DeducedElTys[NewVal] = Ty;
237 DeducedNestedTys[Val] = Ty;
241 auto It = DeducedNestedTys.
find(Val);
242 return It == DeducedNestedTys.
end() ? nullptr : It->second;
251 if (
Value *GlobalElem =
252 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;
311 auto It = ForwardCalls.
find(
F);
312 return It == ForwardCalls.
end() ? nullptr : &It->second;
319 SPIRV::AccessQualifier::AccessQualifier AQ =
320 SPIRV::AccessQualifier::ReadWrite,
342 SPIRV::AccessQualifier::AccessQualifier AQ =
343 SPIRV::AccessQualifier::ReadWrite,
347 auto Res = SPIRVToLLVMType.
find(Ty);
362 SPIRV::StorageClass::StorageClass SC = SPIRV::StorageClass::Function,
363 SPIRV::AccessQualifier::AccessQualifier AQ =
364 SPIRV::AccessQualifier::ReadWrite);
394 return Type && (
Type->getOpcode() == SPIRV::OpTypeStruct &&
395 Type->getOpcode() == SPIRV::OpTypeArray);
436 SPIRV::StorageClass::StorageClass
454 const Type *adjustIntTypeByWidth(
const Type *Ty)
const;
455 unsigned adjustOpTypeIntWidth(
unsigned Width)
const;
458 bool IsSigned =
false);
476 SPIRVType *getOpTypePointer(SPIRV::StorageClass::StorageClass SC,
480 SPIRVType *getOpTypeForwardPointer(SPIRV::StorageClass::StorageClass SC,
489 SPIRV::AccessQualifier::AccessQualifier AccQual);
491 std::tuple<Register, ConstantInt *, bool, unsigned> getOrCreateConstIntReg(
494 std::tuple<Register, ConstantFP *, bool, unsigned> getOrCreateConstFloatReg(
505 unsigned BitWidth,
unsigned ElemCnt,
506 bool ZeroAsNull =
true);
517 bool ZeroAsNull =
true);
520 bool ZeroAsNull =
true);
523 bool ZeroAsNull =
true);
529 bool ZeroAsNull =
true);
532 bool ZeroAsNull =
true);
548 SPIRV::StorageClass::StorageClass Storage,
551 SPIRV::LinkageType::LinkageType LinkageType,
553 bool IsInstSelector);
565 unsigned SPIRVOPcode,
Type *LLVMTy);
572 unsigned NumElements,
583 SPIRV::StorageClass::StorageClass SClass = SPIRV::StorageClass::Function);
586 SPIRV::StorageClass::StorageClass SClass = SPIRV::StorageClass::Function);
592 SPIRV::ImageFormat::ImageFormat ImageFormat,
593 SPIRV::AccessQualifier::AccessQualifier AccQual);
606 SPIRV::AccessQualifier::AccessQualifier AccQual);
const HexagonInstrInfo * TII
This file declares the MachineIRBuilder class.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This class represents an incoming formal argument to a Function.
This class represents a function call, abstracting a target machine's calling convention.
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)
Helper class to build MachineInstr.
Representation of each machine instruction.
This class contains meta information specific to a module.
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)
void addAssignPtrTypeInstr(Value *Val, CallInst *AssignPtrTyCI)
Register getOrCreateGlobalVariableWithBinding(const SPIRVType *VarType, uint32_t Set, uint32_t Binding, MachineIRBuilder &MIRBuilder)
SPIRVType * assignFloatTypeToVReg(unsigned BitWidth, Register VReg, MachineInstr &I, const SPIRVInstrInfo &TII)
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)
void add(const Constant *C, MachineFunction *MF, Register R)
Type * findDeducedCompositeType(const Value *Val)
void add(const MachineInstr *MI, MachineFunction *MF, Register R)
SPIRVType * getOrCreateSPIRVBoolType(MachineIRBuilder &MIRBuilder)
Register getOrCreateConsIntVector(uint64_t Val, MachineIRBuilder &MIRBuilder, SPIRVType *SpvType, bool EmitIR=true)
const Type * getTypeForSPIRVType(const SPIRVType *Ty) const
Register buildConstantSampler(Register Res, unsigned AddrMode, unsigned Param, unsigned FilerMode, MachineIRBuilder &MIRBuilder, SPIRVType *SpvType)
bool isBitcastCompatible(const SPIRVType *Type1, const SPIRVType *Type2) const
unsigned getScalarOrVectorComponentCount(Register VReg) const
SPIRVType * getOrCreateSPIRVFloatType(unsigned BitWidth, MachineInstr &I, const SPIRVInstrInfo &TII)
SPIRVType * getOrCreateOpTypeImage(MachineIRBuilder &MIRBuilder, SPIRVType *SampledType, SPIRV::Dim::Dim Dim, uint32_t Depth, uint32_t Arrayed, uint32_t Multisampled, uint32_t Sampled, SPIRV::ImageFormat::ImageFormat ImageFormat, SPIRV::AccessQualifier::AccessQualifier AccQual)
bool isScalarOrVectorSigned(const SPIRVType *Type) const
void addDeducedElementType(Value *Val, Type *Ty)
void add(const GlobalVariable *GV, MachineFunction *MF, Register R)
Register find(const Constant *C, MachineFunction *MF)
unsigned getPointerSize() const
void add(const Argument *Arg, MachineFunction *MF, Register R)
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
SPIRVType * getOrCreateSPIRVType(const Type *Type, MachineIRBuilder &MIRBuilder, SPIRV::AccessQualifier::AccessQualifier AQ=SPIRV::AccessQualifier::ReadWrite, bool EmitIR=true)
void addMutated(Value *Val, Type *Ty)
void updateIfExistDeducedElementType(Value *OldVal, Value *NewVal, bool DeleteOld)
bool isScalarOfType(Register VReg, unsigned TypeOpcode) const
void buildDepsGraph(std::vector< SPIRV::DTSortableEntry * > &Graph, const SPIRVInstrInfo *TII, MachineModuleInfo *MMI=nullptr)
Register find(const Function *F, MachineFunction *MF)
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)
void add(const Function *F, MachineFunction *MF, Register R)
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 * getOrCreateSPIRVTypeByName(StringRef TypeStr, MachineIRBuilder &MIRBuilder, SPIRV::StorageClass::StorageClass SC=SPIRV::StorageClass::Function, SPIRV::AccessQualifier::AccessQualifier AQ=SPIRV::AccessQualifier::ReadWrite)
Type * findMutated(const Value *Val)
SPIRVType * getScalarOrVectorComponentType(Register VReg) const
Register find(const GlobalVariable *GV, MachineFunction *MF)
bool hasSPIRVTypeForVReg(Register VReg) const
void addDeducedCompositeType(Value *Val, Type *Ty)
SPIRVType * assignTypeToVReg(const Type *Type, Register VReg, MachineIRBuilder &MIRBuilder, SPIRV::AccessQualifier::AccessQualifier AQ=SPIRV::AccessQualifier::ReadWrite, bool EmitIR=true)
SPIRVType * getOrCreateOpTypeFunctionWithArgs(const Type *Ty, SPIRVType *RetType, const SmallVectorImpl< SPIRVType * > &ArgTypes, MachineIRBuilder &MIRBuilder)
void recordFunctionPointer(const MachineOperand *MO, const Function *F)
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)
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)
Register find(const MachineInstr *MI, MachineFunction *MF)
SPIRVType * getOrCreateSPIRVPointerType(SPIRVType *BaseType, MachineIRBuilder &MIRBuilder, SPIRV::StorageClass::StorageClass SClass=SPIRV::StorageClass::Function)
SPIRVType * getOrCreateOpTypeCoopMatr(MachineIRBuilder &MIRBuilder, const TargetExtType *ExtensionType, const SPIRVType *ElemType, uint32_t Scope, uint32_t Rows, uint32_t Columns, uint32_t Use)
SPIRVType * getResultType(Register VReg)
SPIRVType * getOrCreateSPIRVVectorType(SPIRVType *BaseType, unsigned NumElements, MachineIRBuilder &MIRBuilder)
SPIRVType * getOrCreateSPIRVIntegerType(unsigned BitWidth, MachineIRBuilder &MIRBuilder)
Type * getDeducedGlobalValueType(const GlobalValue *Global)
LLT getRegType(SPIRVType *SpvType) const
void addValueAttrs(MachineInstr *Key, std::pair< Type *, std::string > Val)
const Function * getFunctionByDefinition(const MachineInstr *MI)
SPIRVType * getOrCreateSPIRVArrayType(SPIRVType *BaseType, unsigned NumElements, MachineInstr &I, const SPIRVInstrInfo &TII)
SPIRV::StorageClass::StorageClass getPointerStorageClass(Register VReg) const
SPIRVType * getOrCreateOpTypeSampler(MachineIRBuilder &MIRBuilder)
Type * findDeducedElementType(const Value *Val)
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
Register buildConstantInt(uint64_t Val, MachineIRBuilder &MIRBuilder, SPIRVType *SpvType, bool EmitIR=true, bool ZeroAsNull=true)
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.
@ C
The default llvm calling convention, compatible with C.
std::tuple< const Type *, unsigned, unsigned > SpecialTypeDescriptor
This is an optimization pass for GlobalISel generic memory operations.
@ Global
Append to llvm.global_dtors.
constexpr unsigned BitWidth