16#ifndef LLVM_LIB_TARGET_SPIRV_SPIRVTYPEMANAGER_H
17#define LLVM_LIB_TARGET_SPIRV_SPIRVTYPEMANAGER_H
66 const unsigned PointerSize;
80 SPIRV::AccessQualifier::AccessQualifier AQ =
81 SPIRV::AccessQualifier::ReadWrite,
84 SPIRV::AccessQualifier::AccessQualifier accessQual =
85 SPIRV::AccessQualifier::ReadWrite,
89 SPIRV::AccessQualifier::AccessQualifier AccessQual,
122 return DT.
find(
C, MF);
126 return DT.
find(GV, MF);
130 return DT.
find(
F, MF);
143 FunResPointerTypes[ArgF] = DerivedTy;
147 auto It = FunResPointerTypes.
find(ArgF);
148 return It == FunResPointerTypes.
end() ? nullptr : It->second;
156 auto It = DeducedElTys.
find(Val);
157 return It == DeducedElTys.
end() ? nullptr : It->second;
161 DeducedNestedTys[Val] = Ty;
165 auto It = DeducedNestedTys.
find(Val);
166 return It == DeducedNestedTys.
end() ? nullptr : It->second;
175 if (
Value *GlobalElem =
176 Global->getNumOperands() > 0 ?
Global->getOperand(0) :
nullptr)
179 return ElementTy ? ElementTy :
Global->getValueType();
187 auto ResF = InstrToFunction.
find(
Use);
188 if (ResF == InstrToFunction.
end())
190 auto ResReg = FunctionToInstr.
find(ResF->second);
191 return ResReg == FunctionToInstr.
end() ? nullptr : ResReg->second;
199 auto MOIt = FunctionToInstr.
find(
F);
200 return MOIt == FunctionToInstr.
end() ? nullptr : MOIt->second->getParent();
208 auto FIt = FunctionToInstrRev.
find(
MI);
209 return FIt == FunctionToInstrRev.
end() ? nullptr : FIt->second;
215 InstrToFunction[MO] =
F;
220 FunctionToInstr[
F] = MO;
229 auto It = ForwardCalls.
find(
F);
230 if (It == ForwardCalls.
end())
231 ForwardCalls[
F] = {
MI};
233 It->second.insert(
MI);
239 auto It = ForwardCalls.
find(
F);
240 return It == ForwardCalls.
end() ? nullptr : &It->second;
247 SPIRV::AccessQualifier::AccessQualifier AQ =
248 SPIRV::AccessQualifier::ReadWrite,
270 SPIRV::AccessQualifier::AccessQualifier AQ =
271 SPIRV::AccessQualifier::ReadWrite,
275 auto Res = SPIRVToLLVMType.
find(Ty);
288 SPIRV::StorageClass::StorageClass SC = SPIRV::StorageClass::Function,
289 SPIRV::AccessQualifier::AccessQualifier AQ =
290 SPIRV::AccessQualifier::ReadWrite);
360 bool IsSigned =
false);
378 SPIRVType *getOpTypePointer(SPIRV::StorageClass::StorageClass SC,
382 SPIRVType *getOpTypeForwardPointer(SPIRV::StorageClass::StorageClass SC,
391 SPIRV::AccessQualifier::AccessQualifier AccQual);
393 std::tuple<Register, ConstantInt *, bool> getOrCreateConstIntReg(
396 std::tuple<Register, ConstantFP *, bool, unsigned> getOrCreateConstFloatReg(
407 unsigned BitWidth,
unsigned ElemCnt,
408 bool ZeroAsNull =
true);
418 SPIRVType *SpvType =
nullptr,
bool EmitIR =
true);
421 bool ZeroAsNull =
true);
424 bool ZeroAsNull =
true);
430 bool ZeroAsNull =
true);
433 bool ZeroAsNull =
true);
451 SPIRV::StorageClass::StorageClass Storage,
454 SPIRV::LinkageType::LinkageType LinkageType,
456 bool IsInstSelector);
465 unsigned SPIRVOPcode,
Type *LLVMTy);
472 unsigned NumElements,
483 SPIRV::StorageClass::StorageClass SClass = SPIRV::StorageClass::Function);
486 SPIRV::StorageClass::StorageClass SClass = SPIRV::StorageClass::Function);
492 SPIRV::ImageFormat::ImageFormat ImageFormat,
493 SPIRV::AccessQualifier::AccessQualifier AccQual);
502 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 is an important base class in LLVM.
iterator find(const_arg_type_t< KeyT > Val)
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.
void add(const Type *Ty, const MachineFunction *MF, Register R)
Register find(const Type *Ty, const MachineFunction *MF)
void buildDepsGraph(std::vector< SPIRV::DTSortableEntry * > &Graph, MachineModuleInfo *MMI)
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 * assignFloatTypeToVReg(unsigned BitWidth, Register VReg, MachineInstr &I, const SPIRVInstrInfo &TII)
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)
Register getSPIRVTypeID(const SPIRVType *SpirvType) const
SPIRVType * getOrCreateSPIRVType(const Type *Type, MachineIRBuilder &MIRBuilder, SPIRV::AccessQualifier::AccessQualifier AQ=SPIRV::AccessQualifier::ReadWrite, bool EmitIR=true)
void assignSPIRVTypeToVReg(SPIRVType *Type, Register VReg, MachineFunction &MF)
bool isScalarOfType(Register VReg, unsigned TypeOpcode) const
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)
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)
Register find(const GlobalVariable *GV, MachineFunction *MF)
bool hasSPIRVTypeForVReg(Register VReg) const
void addDeducedCompositeType(Value *Val, Type *Ty)
void buildDepsGraph(std::vector< SPIRV::DTSortableEntry * > &Graph, MachineModuleInfo *MMI=nullptr)
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 isScalarOrVectorOfType(Register VReg, unsigned TypeOpcode) const
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 * getOrCreateSPIRVVectorType(SPIRVType *BaseType, unsigned NumElements, MachineIRBuilder &MIRBuilder)
SPIRVType * getOrCreateSPIRVIntegerType(unsigned BitWidth, MachineIRBuilder &MIRBuilder)
Type * getDeducedGlobalValueType(const GlobalValue *Global)
Register getOrCreateConsIntArray(uint64_t Val, MachineInstr &I, SPIRVType *SpvType, const SPIRVInstrInfo &TII)
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 buildConstantInt(uint64_t Val, MachineIRBuilder &MIRBuilder, SPIRVType *SpvType=nullptr, bool EmitIR=true)
Register getOrCreateConstFP(APFloat Val, MachineInstr &I, SPIRVType *SpvType, const SPIRVInstrInfo &TII, bool ZeroAsNull=true)
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.
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.
This is an optimization pass for GlobalISel generic memory operations.
@ Global
Append to llvm.global_dtors.
constexpr unsigned BitWidth