16#ifndef LLVM_LIB_TARGET_SPIRV_SPIRVTYPEMANAGER_H
17#define LLVM_LIB_TARGET_SPIRV_SPIRVTYPEMANAGER_H
71 const unsigned PointerSize;
88 SPIRV::AccessQualifier::AccessQualifier AQ =
89 SPIRV::AccessQualifier::ReadWrite,
92 SPIRV::AccessQualifier::AccessQualifier accessQual =
93 SPIRV::AccessQualifier::ReadWrite,
97 SPIRV::AccessQualifier::AccessQualifier AccessQual,
130 return DT.
find(
C, MF);
134 return DT.
find(GV, MF);
138 return DT.
find(
F, MF);
151 FunResPointerTypes[ArgF] = DerivedTy;
155 auto It = FunResPointerTypes.
find(ArgF);
156 return It == FunResPointerTypes.
end() ? nullptr : It->second;
162 AssignPtrTypeInstr[Val] = AssignPtrTyCI;
166 auto It = AssignPtrTypeInstr.
find(Val);
167 return It == AssignPtrTypeInstr.
end() ? nullptr : It->second;
176 auto It = MutatedAggRet.
find(Val);
177 return It == MutatedAggRet.
end() ? nullptr : It->second;
185 auto It = DeducedElTys.
find(Val);
186 return It == DeducedElTys.
end() ? nullptr : It->second;
190 DeducedNestedTys[Val] = Ty;
194 auto It = DeducedNestedTys.
find(Val);
195 return It == DeducedNestedTys.
end() ? nullptr : It->second;
204 if (
Value *GlobalElem =
205 Global->getNumOperands() > 0 ?
Global->getOperand(0) :
nullptr)
208 return ElementTy ? ElementTy :
Global->getValueType();
216 auto ResF = InstrToFunction.
find(
Use);
217 if (ResF == InstrToFunction.
end())
219 auto ResReg = FunctionToInstr.
find(ResF->second);
220 return ResReg == FunctionToInstr.
end() ? nullptr : ResReg->second;
228 auto MOIt = FunctionToInstr.
find(
F);
229 return MOIt == FunctionToInstr.
end() ? nullptr : MOIt->second->getParent();
237 auto FIt = FunctionToInstrRev.
find(
MI);
238 return FIt == FunctionToInstrRev.
end() ? nullptr : FIt->second;
244 InstrToFunction[MO] =
F;
249 FunctionToInstr[
F] = MO;
258 auto It = ForwardCalls.
find(
F);
259 if (It == ForwardCalls.
end())
260 ForwardCalls[
F] = {
MI};
262 It->second.insert(
MI);
268 auto It = ForwardCalls.
find(
F);
269 return It == ForwardCalls.
end() ? nullptr : &It->second;
276 SPIRV::AccessQualifier::AccessQualifier AQ =
277 SPIRV::AccessQualifier::ReadWrite,
299 SPIRV::AccessQualifier::AccessQualifier AQ =
300 SPIRV::AccessQualifier::ReadWrite,
304 auto Res = SPIRVToLLVMType.
find(Ty);
319 SPIRV::StorageClass::StorageClass SC = SPIRV::StorageClass::Function,
320 SPIRV::AccessQualifier::AccessQualifier AQ =
321 SPIRV::AccessQualifier::ReadWrite);
348 return Type && (
Type->getOpcode() == SPIRV::OpTypeStruct &&
349 Type->getOpcode() == SPIRV::OpTypeArray);
396 const Type *adjustIntTypeByWidth(
const Type *Ty)
const;
397 unsigned adjustOpTypeIntWidth(
unsigned Width)
const;
400 bool IsSigned =
false);
418 SPIRVType *getOpTypePointer(SPIRV::StorageClass::StorageClass SC,
422 SPIRVType *getOpTypeForwardPointer(SPIRV::StorageClass::StorageClass SC,
431 SPIRV::AccessQualifier::AccessQualifier AccQual);
433 std::tuple<Register, ConstantInt *, bool> getOrCreateConstIntReg(
436 std::tuple<Register, ConstantFP *, bool, unsigned> getOrCreateConstFloatReg(
447 unsigned BitWidth,
unsigned ElemCnt,
448 bool ZeroAsNull =
true);
458 SPIRVType *SpvType =
nullptr,
bool EmitIR =
true);
461 bool ZeroAsNull =
true);
464 bool ZeroAsNull =
true);
470 bool ZeroAsNull =
true);
473 bool ZeroAsNull =
true);
489 SPIRV::StorageClass::StorageClass Storage,
492 SPIRV::LinkageType::LinkageType LinkageType,
494 bool IsInstSelector);
503 unsigned SPIRVOPcode,
Type *LLVMTy);
510 unsigned NumElements,
521 SPIRV::StorageClass::StorageClass SClass = SPIRV::StorageClass::Function);
524 SPIRV::StorageClass::StorageClass SClass = SPIRV::StorageClass::Function);
530 SPIRV::ImageFormat::ImageFormat ImageFormat,
531 SPIRV::AccessQualifier::AccessQualifier AccQual);
544 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.
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)
void addAssignPtrTypeInstr(Value *Val, CallInst *AssignPtrTyCI)
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)
SPIRVType * getPointeeType(SPIRVType *PtrType)
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 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)
Type * findMutated(const Value *Val)
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 isAggregateType(SPIRVType *Type) const
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 * getOrCreateSPIRVVectorType(SPIRVType *BaseType, unsigned NumElements, MachineIRBuilder &MIRBuilder)
SPIRVType * getOrCreateSPIRVIntegerType(unsigned BitWidth, MachineIRBuilder &MIRBuilder)
Type * getDeducedGlobalValueType(const GlobalValue *Global)
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)
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.
@ 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