26 : PointerSize(PointerSize) {}
48 SPIRV::AccessQualifier::AccessQualifier AccessQual,
bool EmitIR) {
59 VRegToTypeMap[&MF][VReg] = SpirvType;
65 MRI.setRegClass(Res, &SPIRV::TYPERegClass);
71 MRI.setRegClass(Res, &SPIRV::TYPERegClass);
76 return MIRBuilder.
buildInstr(SPIRV::OpTypeBool)
83 assert(Width <= 64 &&
"Unsupported integer width!");
86 if (
ST.canUseExtension(
87 SPIRV::Extension::SPV_INTEL_arbitrary_precision_integers)) {
89 .
addImm(SPIRV::Extension::SPV_INTEL_arbitrary_precision_integers);
91 .
addImm(SPIRV::Capability::ArbitraryPrecisionIntegersINTEL);
92 }
else if (Width <= 8)
101 auto MIB = MIRBuilder.
buildInstr(SPIRV::OpTypeInt)
104 .
addImm(IsSigned ? 1 : 0);
110 auto MIB = MIRBuilder.
buildInstr(SPIRV::OpTypeFloat)
117 return MIRBuilder.
buildInstr(SPIRV::OpTypeVoid)
125 assert((EleOpc == SPIRV::OpTypeInt || EleOpc == SPIRV::OpTypeFloat ||
126 EleOpc == SPIRV::OpTypeBool) &&
127 "Invalid vector element type");
129 auto MIB = MIRBuilder.
buildInstr(SPIRV::OpTypeVector)
136std::tuple<Register, ConstantInt *, bool>
146 bool NewInstr =
false;
162 return std::make_tuple(Res, CI, NewInstr);
172 std::tie(Res, CI, New) =
173 getOrCreateConstIntReg(Val, SpvType,
nullptr, &
I, &
TII);
176 if (!New && (!
I.getOperand(0).isReg() || Res !=
I.getOperand(0).getReg()))
181 MIB =
BuildMI(BB,
I,
I.getDebugLoc(),
TII.get(SPIRV::OpConstantI))
186 MIB =
BuildMI(BB,
I,
I.getDebugLoc(),
TII.get(SPIRV::OpConstantNull))
192 *ST.getRegisterInfo(), *ST.getRegBankInfo());
200 auto &MF = MIRBuilder.
getMF();
207 const auto ConstInt =
213 Res = MF.getRegInfo().createGenericVirtualRegister(LLTy);
214 MF.getRegInfo().setRegClass(Res, &SPIRV::IDRegClass);
216 SPIRV::AccessQualifier::ReadWrite, EmitIR);
217 DT.
add(ConstInt, &MIRBuilder.
getMF(), Res);
224 MIB = MIRBuilder.
buildInstr(SPIRV::OpConstantI)
230 MIB = MIRBuilder.
buildInstr(SPIRV::OpConstantNull)
236 *Subtarget.getRegisterInfo(),
237 *Subtarget.getRegBankInfo());
246 auto &MF = MIRBuilder.
getMF();
247 const Type *LLVMFPTy;
260 MF.getRegInfo().setRegClass(Res, &SPIRV::IDRegClass);
262 DT.
add(ConstFP, &MF, Res);
268Register SPIRVGlobalRegistry::getOrCreateIntCompositeOrNull(
292 MIB =
BuildMI(BB,
I,
I.getDebugLoc(),
TII.get(SPIRV::OpConstantComposite))
295 for (
unsigned i = 0; i < ElemCnt; ++i)
298 MIB =
BuildMI(BB,
I,
I.getDebugLoc(),
TII.get(SPIRV::OpConstantNull))
304 *Subtarget.getRegisterInfo(),
305 *Subtarget.getRegBankInfo());
323 return getOrCreateIntCompositeOrNull(Val,
I, SpvType,
TII, ConstVec, BW,
333 const ArrayType *LLVMArrTy = cast<ArrayType>(LLVMTy);
340 return getOrCreateIntCompositeOrNull(Val,
I, SpvType,
TII, ConstArr, BW,
344Register SPIRVGlobalRegistry::getOrCreateIntCompositeOrNull(
365 auto MIB = MIRBuilder.
buildInstr(SPIRV::OpConstantComposite)
368 for (
unsigned i = 0; i < ElemCnt; ++i)
393 return getOrCreateIntCompositeOrNull(Val, MIRBuilder, SpvType, EmitIR,
404 const ArrayType *LLVMArrTy = cast<ArrayType>(LLVMTy);
411 return getOrCreateIntCompositeOrNull(Val, MIRBuilder, SpvType, EmitIR,
420 const PointerType *LLVMPtrTy = cast<PointerType>(LLVMTy);
450 auto Res = MIRBuilder.
buildInstr(SPIRV::OpConstantSampler)
456 assert(Res->getOperand(0).isReg());
457 return Res->getOperand(0).getReg();
462 const GlobalValue *GV, SPIRV::StorageClass::StorageClass Storage,
465 bool IsInstSelector) {
468 GVar = cast<const GlobalVariable>(GV);
473 GVar = M->getGlobalVariable(
Name);
474 if (GVar ==
nullptr) {
489 auto MIB = MIRBuilder.
buildInstr(SPIRV::OpVariable)
500 if (IsInstSelector) {
503 *Subtarget.getRegisterInfo(),
504 *Subtarget.getRegBankInfo());
507 DT.
add(GVar, &MIRBuilder.
getMF(), Reg);
511 assert(
MRI->getType(ResVReg).isPointer() &&
"Pointer type is expected");
512 if (Reg != ResVReg) {
514 MRI->setType(Reg, RegLLTy);
529 buildOpDecorate(Reg, MIRBuilder, SPIRV::Decoration::Alignment, {Alignment});
536 SPIRV::BuiltIn::BuiltIn BuiltInId;
539 {
static_cast<uint32_t>(BuiltInId)});
549 "Invalid array element type");
552 auto MIB = MIRBuilder.
buildInstr(SPIRV::OpTypeArray)
574 for (
const auto &Elem : Ty->
elements()) {
575 SPIRVType *ElemTy = findSPIRVType(Elem, MIRBuilder);
577 "Invalid struct element type");
582 for (
const auto &Ty : FieldTypes)
591SPIRVType *SPIRVGlobalRegistry::getOrCreateSpecialType(
593 SPIRV::AccessQualifier::AccessQualifier AccQual) {
596 if (
auto PType = dyn_cast<PointerType>(Ty)) {
597 assert(!PType->isOpaque());
604SPIRVType *SPIRVGlobalRegistry::getOpTypePointer(
605 SPIRV::StorageClass::StorageClass SC,
SPIRVType *ElemType,
609 return MIRBuilder.
buildInstr(SPIRV::OpTypePointer)
615SPIRVType *SPIRVGlobalRegistry::getOpTypeForwardPointer(
617 return MIRBuilder.
buildInstr(SPIRV::OpTypeForwardPointer)
622SPIRVType *SPIRVGlobalRegistry::getOpTypeFunction(
625 auto MIB = MIRBuilder.
buildInstr(SPIRV::OpTypeFunction)
628 for (
const SPIRVType *ArgType : ArgTypes)
640 SPIRVType *SpirvType = getOpTypeFunction(RetType, ArgTypes, MIRBuilder);
642 return finishCreatingSPIRVType(Ty, SpirvType);
645SPIRVType *SPIRVGlobalRegistry::findSPIRVType(
647 SPIRV::AccessQualifier::AccessQualifier AccQual,
bool EmitIR) {
651 if (ForwardPointerTypes.find(Ty) != ForwardPointerTypes.end())
652 return ForwardPointerTypes[Ty];
653 return restOfCreateSPIRVType(Ty, MIRBuilder, AccQual, EmitIR);
657 assert(SpirvType &&
"Attempting to get type id for nullptr type.");
658 if (SpirvType->
getOpcode() == SPIRV::OpTypeForwardPointer)
659 return SpirvType->
uses().begin()->getReg();
660 return SpirvType->
defs().begin()->getReg();
663SPIRVType *SPIRVGlobalRegistry::createSPIRVType(
665 SPIRV::AccessQualifier::AccessQualifier AccQual,
bool EmitIR) {
667 return getOrCreateSpecialType(Ty, MIRBuilder, AccQual);
668 auto &TypeToSPIRVTypeMap = DT.
getTypes()->getAllUses();
669 auto t = TypeToSPIRVTypeMap.find(Ty);
670 if (t != TypeToSPIRVTypeMap.end()) {
671 auto tt = t->second.find(&MIRBuilder.
getMF());
672 if (tt != t->second.end())
676 if (
auto IType = dyn_cast<IntegerType>(Ty)) {
677 const unsigned Width = IType->getBitWidth();
678 return Width == 1 ? getOpTypeBool(MIRBuilder)
679 : getOpTypeInt(Width, MIRBuilder,
false);
684 return getOpTypeVoid(MIRBuilder);
687 findSPIRVType(cast<FixedVectorType>(Ty)->getElementType(), MIRBuilder);
688 return getOpTypeVector(cast<FixedVectorType>(Ty)->getNumElements(), El,
695 if (
auto SType = dyn_cast<StructType>(Ty)) {
696 if (SType->isOpaque())
697 return getOpTypeOpaque(SType, MIRBuilder);
698 return getOpTypeStruct(SType, MIRBuilder, EmitIR);
700 if (
auto FType = dyn_cast<FunctionType>(Ty)) {
701 SPIRVType *
RetTy = findSPIRVType(FType->getReturnType(), MIRBuilder);
703 for (
const auto &t : FType->params()) {
704 ParamTypes.
push_back(findSPIRVType(t, MIRBuilder));
706 return getOpTypeFunction(
RetTy, ParamTypes, MIRBuilder);
708 if (
auto PType = dyn_cast<PointerType>(Ty)) {
713 if (PType->isOpaque())
717 findSPIRVType(PType->getNonOpaquePointerElementType(), MIRBuilder,
718 SPIRV::AccessQualifier::ReadWrite, EmitIR);
722 if (SpvElementType ==
nullptr) {
723 if (ForwardPointerTypes.find(Ty) == ForwardPointerTypes.end())
724 ForwardPointerTypes[PType] = getOpTypeForwardPointer(SC, MIRBuilder);
725 return ForwardPointerTypes[PType];
730 if (ForwardPointerTypes.find(PType) != ForwardPointerTypes.end())
733 return getOpTypePointer(SC, SpvElementType, MIRBuilder, Reg);
738SPIRVType *SPIRVGlobalRegistry::restOfCreateSPIRVType(
740 SPIRV::AccessQualifier::AccessQualifier AccessQual,
bool EmitIR) {
741 if (TypesInProcessing.count(Ty) && !Ty->
isPointerTy())
743 TypesInProcessing.insert(Ty);
744 SPIRVType *SpirvType = createSPIRVType(Ty, MIRBuilder, AccessQual, EmitIR);
745 TypesInProcessing.erase(Ty);
747 SPIRVToLLVMType[SpirvType] = Ty;
751 if (SpirvType->
getOpcode() != SPIRV::OpTypeForwardPointer && !
Reg.isValid() &&
768 auto t = VRegToTypeMap.find(
CurMF);
769 if (t != VRegToTypeMap.end()) {
770 auto tt = t->second.find(VReg);
771 if (tt != t->second.end())
779 SPIRV::AccessQualifier::AccessQualifier AccessQual,
bool EmitIR) {
790 TypesInProcessing.clear();
791 SPIRVType *STy = restOfCreateSPIRVType(Ty, MIRBuilder, AccessQual, EmitIR);
793 for (
auto &
CU : ForwardPointerTypes) {
794 const Type *Ty2 =
CU.first;
796 if ((Reg = DT.
find(Ty2, &MIRBuilder.
getMF())).isValid())
799 STy2 = restOfCreateSPIRVType(Ty2, MIRBuilder, AccessQual, EmitIR);
803 ForwardPointerTypes.clear();
808 unsigned TypeOpcode)
const {
810 assert(
Type &&
"isScalarOfType VReg has no type assigned");
811 return Type->getOpcode() == TypeOpcode;
815 unsigned TypeOpcode)
const {
817 assert(
Type &&
"isScalarOrVectorOfType VReg has no type assigned");
818 if (
Type->getOpcode() == TypeOpcode)
820 if (
Type->getOpcode() == SPIRV::OpTypeVector) {
823 return ScalarType->
getOpcode() == TypeOpcode;
831 if (
Type->getOpcode() == SPIRV::OpTypeVector) {
832 auto EleTypeReg =
Type->getOperand(1).getReg();
835 if (
Type->getOpcode() == SPIRV::OpTypeInt ||
836 Type->getOpcode() == SPIRV::OpTypeFloat)
837 return Type->getOperand(1).getImm();
838 if (
Type->getOpcode() == SPIRV::OpTypeBool)
845 if (
Type->getOpcode() == SPIRV::OpTypeVector) {
846 auto EleTypeReg =
Type->getOperand(1).getReg();
849 if (
Type->getOpcode() == SPIRV::OpTypeInt)
850 return Type->getOperand(2).getImm() != 0;
854SPIRV::StorageClass::StorageClass
858 Type->getOperand(1).isImm() &&
"Pointer type is expected");
859 return static_cast<SPIRV::StorageClass::StorageClass
>(
860 Type->getOperand(1).getImm());
866 SPIRV::ImageFormat::ImageFormat ImageFormat,
867 SPIRV::AccessQualifier::AccessQualifier AccessQual) {
869 Arrayed, Multisampled, Sampled, ImageFormat,
871 if (
auto *Res = checkSpecialInstr(TD, MIRBuilder))
874 DT.
add(TD, &MIRBuilder.
getMF(), ResVReg);
875 return MIRBuilder.
buildInstr(SPIRV::OpTypeImage)
890 if (
auto *Res = checkSpecialInstr(TD, MIRBuilder))
893 DT.
add(TD, &MIRBuilder.
getMF(), ResVReg);
899 SPIRV::AccessQualifier::AccessQualifier AccessQual) {
901 if (
auto *Res = checkSpecialInstr(TD, MIRBuilder))
904 DT.
add(TD, &MIRBuilder.
getMF(), ResVReg);
905 return MIRBuilder.
buildInstr(SPIRV::OpTypePipe)
913 if (
auto *Res = checkSpecialInstr(TD, MIRBuilder))
916 DT.
add(TD, &MIRBuilder.
getMF(), ResVReg);
926 if (
auto *Res = checkSpecialInstr(TD, MIRBuilder))
929 DT.
add(TD, &MIRBuilder.
getMF(), ResVReg);
930 return MIRBuilder.
buildInstr(SPIRV::OpTypeSampledImage)
942 DT.
add(Ty, &MIRBuilder.
getMF(), ResVReg);
959 unsigned VecElts = 0;
967 TypeStr = TypeStr.
substr(strlen(
"void"));
971 : TypeStr.
substr(strlen(
"uint"));
974 TypeStr = TypeStr.
substr(strlen(
"float"));
977 TypeStr = TypeStr.
substr(strlen(
"half"));
978 }
else if (TypeStr.
startswith(
"opencl.sampler_t")) {
983 TypeStr = TypeStr.
substr(strlen(
" vector["));
984 TypeStr = TypeStr.
substr(0, TypeStr.
find(
']'));
1001SPIRVType *SPIRVGlobalRegistry::finishCreatingSPIRVType(
const Type *LLVMTy,
1005 SPIRVToLLVMType[SpirvType] = LLVMTy;
1016 auto MIB =
BuildMI(BB,
I,
I.getDebugLoc(),
TII.get(SPIRV::OpTypeInt))
1021 return finishCreatingSPIRVType(LLVMTy, MIB);
1039 auto MIB =
BuildMI(BB,
I,
I.getDebugLoc(),
TII.get(SPIRV::OpTypeBool))
1042 return finishCreatingSPIRVType(LLVMTy, MIB);
1062 auto MIB =
BuildMI(BB,
I,
I.getDebugLoc(),
TII.get(SPIRV::OpTypeVector))
1067 return finishCreatingSPIRVType(LLVMTy, MIB);
1081 auto MIB =
BuildMI(BB,
I,
I.getDebugLoc(),
TII.get(SPIRV::OpTypeArray))
1086 return finishCreatingSPIRVType(LLVMTy, MIB);
1091 SPIRV::StorageClass::StorageClass SC) {
1101 MIRBuilder.
getTII().
get(SPIRV::OpTypePointer))
1106 return finishCreatingSPIRVType(LLVMTy, MIB);
1111 SPIRV::StorageClass::StorageClass SC) {
1120 auto MIB =
BuildMI(BB,
I,
I.getDebugLoc(),
TII.get(SPIRV::OpTypePointer))
1125 return finishCreatingSPIRVType(LLVMTy, MIB);
1146 MIB =
BuildMI(*
I.getParent(),
I,
I.getDebugLoc(),
TII.get(SPIRV::OpUndef))
1151 *ST.getRegisterInfo(), *ST.getRegBankInfo());
unsigned const MachineRegisterInfo * MRI
const HexagonInstrInfo * TII
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
static Register createTypeVReg(MachineIRBuilder &MIRBuilder)
Class for arbitrary precision integers.
Class to represent array types.
uint64_t getNumElements() const
static ArrayType * get(Type *ElementType, uint64_t NumElements)
This static method is the primary way to construct an ArrayType.
Type * getElementType() const
static Constant * get(ArrayType *T, ArrayRef< Constant * > V)
static Constant * get(Type *Ty, double V)
This returns a ConstantFP, or a vector containing a splat of a ConstantFP, for the specified value in...
This is the shared class of boolean and integer constants.
static Constant * get(Type *Ty, uint64_t V, bool IsSigned=false)
If Ty is a vector type, return a Constant with a splat of the given value.
static ConstantPointerNull * get(PointerType *T)
Static factory methods - Return objects of the specified value.
static Constant * getSplat(ElementCount EC, Constant *Elt)
Return a ConstantVector with the specified constant in each element.
This is an important base class in LLVM.
Class to represent fixed width SIMD vectors.
static FixedVectorType * get(Type *ElementType, unsigned NumElts)
LLVMContext & getContext() const
getContext - Return a reference to the LLVMContext associated with this function.
MaybeAlign getAlign() const
Returns the alignment of the given variable or function.
Module * getParent()
Get the module that this global value is contained inside of...
@ ExternalLinkage
Externally visible function.
Class to represent integer types.
static IntegerType * get(LLVMContext &C, unsigned NumBits)
This static method is the primary way of constructing an IntegerType.
static constexpr LLT scalar(unsigned SizeInBits)
Get a low-level scalar or aggregate "bag of bits".
static constexpr LLT pointer(unsigned AddressSpace, unsigned SizeInBits)
Get a low-level pointer in the given address space.
static constexpr LLT fixed_vector(unsigned NumElements, unsigned ScalarSizeInBits)
Get a low-level fixed-width vector of some number of elements and element width.
const MCInstrDesc & get(unsigned Opcode) const
Return the machine instruction descriptor that corresponds to the specified instruction opcode.
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
Function & getFunction()
Return the LLVM function that this machine code represents.
Helper class to build MachineInstr.
const TargetInstrInfo & getTII()
MachineBasicBlock::iterator getInsertPt()
Current insertion point for new instructions.
virtual MachineInstrBuilder buildFConstant(const DstOp &Res, const ConstantFP &Val)
Build and insert Res = G_FCONSTANT Val.
MachineInstrBuilder buildInstr(unsigned Opcode)
Build and insert <empty> = Opcode <empty>.
MachineFunction & getMF()
Getter for the function we currently build.
MachineInstrBuilder buildSplatVector(const DstOp &Res, const SrcOp &Src)
Build and insert Res = G_BUILD_VECTOR with Src replicated to fill the number of elements.
const MachineBasicBlock & getMBB() const
Getter for the basic block we currently build.
const DebugLoc & getDebugLoc()
Get the current instruction's debug location.
MachineRegisterInfo * getMRI()
Getter for MRI.
MachineInstrBuilder buildCopy(const DstOp &Res, const SrcOp &Op)
Build and insert Res = COPY Op.
virtual MachineInstrBuilder buildConstant(const DstOp &Res, const ConstantInt &Val)
Build and insert Res = G_CONSTANT Val.
const MachineInstrBuilder & addImm(int64_t Val) const
Add a new immediate operand.
const MachineInstrBuilder & addUse(Register RegNo, unsigned Flags=0, unsigned SubReg=0) const
Add a virtual register use operand.
const MachineInstrBuilder & addDef(Register RegNo, unsigned Flags=0, unsigned SubReg=0) const
Add a virtual register definition operand.
Representation of each machine instruction.
unsigned getOpcode() const
Returns the opcode of this MachineInstr.
iterator_range< mop_iterator > uses()
Returns a range that includes all operands that are register uses.
iterator_range< mop_iterator > defs()
Returns a range over all explicit operands that are register definitions.
const MachineFunction * getMF() const
Return the function that contains the basic block that this instruction belongs to.
const MachineOperand & getOperand(unsigned i) const
Register getReg() const
getReg - Returns the register number.
MachineRegisterInfo - Keep track of information for virtual and physical registers,...
MachineInstr * getVRegDef(Register Reg) const
getVRegDef - Return the machine instr that defines the specified virtual register or null if none is ...
Register createVirtualRegister(const TargetRegisterClass *RegClass, StringRef Name="")
createVirtualRegister - Create and return a new virtual register in the function with the specified r...
void setRegClass(Register Reg, const TargetRegisterClass *RC)
setRegClass - Set the register class of the specified virtual register.
Register createGenericVirtualRegister(LLT Ty, StringRef Name="")
Create and return a new generic virtual register with low-level type Ty.
MachineInstr * getUniqueVRegDef(Register Reg) const
getUniqueVRegDef - Return the unique machine instr that defines the specified virtual register or nul...
A Module instance is used to store all the information related to an LLVM module.
Class to represent pointers.
static PointerType * get(Type *ElementType, unsigned AddressSpace)
This constructs a pointer to an object of the specified type in a numbered address space.
unsigned getAddressSpace() const
Return the address space of the Pointer type.
Wrapper class representing virtual and physical registers.
constexpr bool isValid() const
void add(const Type *Ty, const MachineFunction *MF, Register R)
Register find(const Type *Ty, const MachineFunction *MF)
const SPIRVDuplicatesTracker< Type > * getTypes()
SPIRVType * getOrCreateOpTypePipe(MachineIRBuilder &MIRBuilder, SPIRV::AccessQualifier::AccessQualifier AccQual)
Register getOrCreateConsIntVector(uint64_t Val, MachineInstr &I, SPIRVType *SpvType, const SPIRVInstrInfo &TII)
SPIRVType * getOrCreateSPIRVTypeByName(StringRef TypeStr, MachineIRBuilder &MIRBuilder)
SPIRVType * assignVectTypeToVReg(SPIRVType *BaseType, unsigned NumElements, Register VReg, MachineInstr &I, const SPIRVInstrInfo &TII)
Register getOrCreateUndef(MachineInstr &I, SPIRVType *SpvType, const SPIRVInstrInfo &TII)
SPIRVType * getOrCreateSPIRVBoolType(MachineIRBuilder &MIRBuilder)
const Type * getTypeForSPIRVType(const SPIRVType *Ty) const
Register buildConstantSampler(Register Res, unsigned AddrMode, unsigned Param, unsigned FilerMode, MachineIRBuilder &MIRBuilder, SPIRVType *SpvType)
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
SPIRVType * getSPIRVTypeForVReg(Register VReg) const
SPIRVGlobalRegistry(unsigned PointerSize)
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 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)
SPIRVType * getOrCreateOpTypeSampledImage(SPIRVType *ImageType, MachineIRBuilder &MIRBuilder)
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)
bool isScalarOrVectorOfType(Register VReg, unsigned TypeOpcode) const
SPIRVType * getOrCreateOpTypeDeviceEvent(MachineIRBuilder &MIRBuilder)
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)
Register getOrCreateConsIntArray(uint64_t Val, MachineInstr &I, SPIRVType *SpvType, const SPIRVInstrInfo &TII)
SPIRVType * getOrCreateSPIRVArrayType(SPIRVType *BaseType, unsigned NumElements, MachineInstr &I, const SPIRVInstrInfo &TII)
SPIRV::StorageClass::StorageClass getPointerStorageClass(Register VReg) const
SPIRVType * getOrCreateOpTypeSampler(MachineIRBuilder &MIRBuilder)
Register buildConstantInt(uint64_t Val, MachineIRBuilder &MIRBuilder, SPIRVType *SpvType=nullptr, bool EmitIR=true)
Register getOrCreateConstNullPtr(MachineIRBuilder &MIRBuilder, SPIRVType *SpvType)
unsigned getScalarOrVectorBitWidth(const SPIRVType *Type) const
Register getOrCreateConstInt(uint64_t Val, MachineInstr &I, SPIRVType *SpvType, const SPIRVInstrInfo &TII)
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
StringRef - Represent a constant reference to a string, i.e.
bool getAsInteger(unsigned Radix, T &Result) const
Parse the current string as an integer of the specified radix.
constexpr StringRef substr(size_t Start, size_t N=npos) const
Return a reference to the substring from [Start, Start + N).
bool startswith(StringRef Prefix) const
size_t find(char C, size_t From=0) const
Search for the first character C in the string.
Class to represent struct types.
ArrayRef< Type * > elements() const
static StructType * create(LLVMContext &Context, StringRef Name)
This creates an identified struct.
bool hasName() const
Return true if this is a named struct that has a non-empty name.
StringRef getName() const
Return the name for this struct type if it has an identity.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
The instances of the Type class are immutable: once they are created, they are never changed.
static Type * getHalfTy(LLVMContext &C)
bool isVectorTy() const
True if this is an instance of VectorType.
bool isArrayTy() const
True if this is an instance of ArrayType.
bool isPointerTy() const
True if this is an instance of PointerType.
Type * getArrayElementType() const
Type * getNonOpaquePointerElementType() const
Only use this method in code that is not reachable with opaque pointers, or part of deprecated method...
unsigned getPointerAddressSpace() const
Get the address space of this pointer or pointer vector type.
uint64_t getArrayNumElements() const
static Type * getVoidTy(LLVMContext &C)
LLVMContext & getContext() const
Return the LLVMContext in which this type was uniqued.
static IntegerType * getInt8Ty(LLVMContext &C)
bool isFloatingPointTy() const
Return true if this is one of the floating-point types.
static IntegerType * getInt32Ty(LLVMContext &C)
static Type * getFloatTy(LLVMContext &C)
TypeSize getPrimitiveSizeInBits() const LLVM_READONLY
Return the basic size of this type if it is a primitive type.
bool isOpaquePointerTy() const
True if this is an instance of an opaque PointerType.
bool isVoidTy() const
Return true if this is 'void'.
'undef' values are things that do not have specified contents.
static UndefValue * get(Type *T)
Static factory methods - Return an 'undef' object of the specified type.
StringRef getName() const
Return a constant reference to the value's name.
ElementCount getElementCount() const
Return an ElementCount instance to represent the (possibly scalable) number of elements in the vector...
Type * getElementType() const
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
@ SC
CHAIN = SC CHAIN, Imm128 - System call.
SPIRVType * lowerBuiltinType(const Type *OpaqueType, SPIRV::AccessQualifier::AccessQualifier AccessQual, MachineIRBuilder &MIRBuilder, SPIRVGlobalRegistry *GR)
Reg
All possible values of the reg field in the ModR/M byte.
This is an optimization pass for GlobalISel generic memory operations.
void buildOpName(Register Target, const StringRef &Name, MachineIRBuilder &MIRBuilder)
unsigned storageClassToAddressSpace(SPIRV::StorageClass::StorageClass SC)
MachineInstrBuilder BuildMI(MachineFunction &MF, const MIMetadata &MIMD, const MCInstrDesc &MCID)
Builder interface. Specify how to create the initial instruction itself.
void addNumImm(const APInt &Imm, MachineInstrBuilder &MIB)
bool constrainSelectedInstRegOperands(MachineInstr &I, const TargetInstrInfo &TII, const TargetRegisterInfo &TRI, const RegisterBankInfo &RBI)
Mutate the newly-selected instruction I to constrain its (possibly generic) virtual register operands...
bool getSpirvBuiltInIdByName(llvm::StringRef Name, SPIRV::BuiltIn::BuiltIn &BI)
void buildOpDecorate(Register Reg, MachineIRBuilder &MIRBuilder, SPIRV::Decoration::Decoration Dec, const std::vector< uint32_t > &DecArgs, StringRef StrImm)
SPIRV::StorageClass::StorageClass addressSpaceToStorageClass(unsigned AddrSpace)
bool isSpecialOpaqueType(const Type *Ty)
constexpr unsigned BitWidth
void addStringImm(const StringRef &Str, MCInst &Inst)
uint64_t value() const
This is a hole in the type system and should not be abused.
Align valueOrOne() const
For convenience, returns a valid alignment or 1 if undefined.