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!");
93 auto MIB = MIRBuilder.
buildInstr(SPIRV::OpTypeInt)
102 auto MIB = MIRBuilder.
buildInstr(SPIRV::OpTypeFloat)
109 return MIRBuilder.
buildInstr(SPIRV::OpTypeVoid)
117 assert((EleOpc == SPIRV::OpTypeInt || EleOpc == SPIRV::OpTypeFloat ||
118 EleOpc == SPIRV::OpTypeBool) &&
119 "Invalid vector element type");
121 auto MIB = MIRBuilder.
buildInstr(SPIRV::OpTypeVector)
128std::tuple<Register, ConstantInt *, bool>
138 bool NewInstr =
false;
154 return std::make_tuple(Res, CI, NewInstr);
164 std::tie(Res, CI, New) =
165 getOrCreateConstIntReg(Val, SpvType,
nullptr, &
I, &
TII);
168 if (!New && (!
I.getOperand(0).isReg() || Res !=
I.getOperand(0).getReg()))
173 MIB =
BuildMI(BB,
I,
I.getDebugLoc(),
TII.get(SPIRV::OpConstantI))
178 MIB =
BuildMI(BB,
I,
I.getDebugLoc(),
TII.get(SPIRV::OpConstantNull))
184 *ST.getRegisterInfo(), *ST.getRegBankInfo());
192 auto &MF = MIRBuilder.
getMF();
199 const auto ConstInt =
205 Res = MF.getRegInfo().createGenericVirtualRegister(LLTy);
206 MF.getRegInfo().setRegClass(Res, &SPIRV::IDRegClass);
208 SPIRV::AccessQualifier::ReadWrite, EmitIR);
209 DT.
add(ConstInt, &MIRBuilder.
getMF(), Res);
216 MIB = MIRBuilder.
buildInstr(SPIRV::OpConstantI)
222 MIB = MIRBuilder.
buildInstr(SPIRV::OpConstantNull)
228 *Subtarget.getRegisterInfo(),
229 *Subtarget.getRegBankInfo());
238 auto &MF = MIRBuilder.
getMF();
239 const Type *LLVMFPTy;
252 MF.getRegInfo().setRegClass(Res, &SPIRV::IDRegClass);
254 DT.
add(ConstFP, &MF, Res);
260Register SPIRVGlobalRegistry::getOrCreateIntCompositeOrNull(
284 MIB =
BuildMI(BB,
I,
I.getDebugLoc(),
TII.get(SPIRV::OpConstantComposite))
287 for (
unsigned i = 0; i < ElemCnt; ++i)
290 MIB =
BuildMI(BB,
I,
I.getDebugLoc(),
TII.get(SPIRV::OpConstantNull))
296 *Subtarget.getRegisterInfo(),
297 *Subtarget.getRegBankInfo());
315 return getOrCreateIntCompositeOrNull(Val,
I, SpvType,
TII, ConstVec, BW,
325 const ArrayType *LLVMArrTy = cast<ArrayType>(LLVMTy);
332 return getOrCreateIntCompositeOrNull(Val,
I, SpvType,
TII, ConstArr, BW,
336Register SPIRVGlobalRegistry::getOrCreateIntCompositeOrNull(
357 auto MIB = MIRBuilder.
buildInstr(SPIRV::OpConstantComposite)
360 for (
unsigned i = 0; i < ElemCnt; ++i)
385 return getOrCreateIntCompositeOrNull(Val, MIRBuilder, SpvType, EmitIR,
396 const ArrayType *LLVMArrTy = cast<ArrayType>(LLVMTy);
403 return getOrCreateIntCompositeOrNull(Val, MIRBuilder, SpvType, EmitIR,
412 const PointerType *LLVMPtrTy = cast<PointerType>(LLVMTy);
442 auto Res = MIRBuilder.
buildInstr(SPIRV::OpConstantSampler)
448 assert(Res->getOperand(0).isReg());
449 return Res->getOperand(0).getReg();
454 const GlobalValue *GV, SPIRV::StorageClass::StorageClass Storage,
457 bool IsInstSelector) {
460 GVar = cast<const GlobalVariable>(GV);
465 GVar = M->getGlobalVariable(
Name);
466 if (GVar ==
nullptr) {
481 auto MIB = MIRBuilder.
buildInstr(SPIRV::OpVariable)
492 if (IsInstSelector) {
495 *Subtarget.getRegisterInfo(),
496 *Subtarget.getRegBankInfo());
499 DT.
add(GVar, &MIRBuilder.
getMF(), Reg);
503 assert(
MRI->getType(ResVReg).isPointer() &&
"Pointer type is expected");
504 if (Reg != ResVReg) {
506 MRI->setType(Reg, RegLLTy);
521 buildOpDecorate(Reg, MIRBuilder, SPIRV::Decoration::Alignment, {Alignment});
528 SPIRV::BuiltIn::BuiltIn BuiltInId;
531 {
static_cast<uint32_t>(BuiltInId)});
541 "Invalid array element type");
544 auto MIB = MIRBuilder.
buildInstr(SPIRV::OpTypeArray)
566 for (
const auto &Elem : Ty->
elements()) {
567 SPIRVType *ElemTy = findSPIRVType(Elem, MIRBuilder);
569 "Invalid struct element type");
574 for (
const auto &Ty : FieldTypes)
583SPIRVType *SPIRVGlobalRegistry::getOrCreateSpecialType(
585 SPIRV::AccessQualifier::AccessQualifier AccQual) {
588 if (
auto PType = dyn_cast<PointerType>(Ty)) {
589 assert(!PType->isOpaque());
596SPIRVType *SPIRVGlobalRegistry::getOpTypePointer(
597 SPIRV::StorageClass::StorageClass SC,
SPIRVType *ElemType,
601 return MIRBuilder.
buildInstr(SPIRV::OpTypePointer)
607SPIRVType *SPIRVGlobalRegistry::getOpTypeForwardPointer(
609 return MIRBuilder.
buildInstr(SPIRV::OpTypeForwardPointer)
614SPIRVType *SPIRVGlobalRegistry::getOpTypeFunction(
617 auto MIB = MIRBuilder.
buildInstr(SPIRV::OpTypeFunction)
620 for (
const SPIRVType *ArgType : ArgTypes)
632 SPIRVType *SpirvType = getOpTypeFunction(RetType, ArgTypes, MIRBuilder);
633 return finishCreatingSPIRVType(Ty, SpirvType);
636SPIRVType *SPIRVGlobalRegistry::findSPIRVType(
638 SPIRV::AccessQualifier::AccessQualifier AccQual,
bool EmitIR) {
642 if (ForwardPointerTypes.find(Ty) != ForwardPointerTypes.end())
643 return ForwardPointerTypes[Ty];
644 return restOfCreateSPIRVType(Ty, MIRBuilder, AccQual, EmitIR);
648 assert(SpirvType &&
"Attempting to get type id for nullptr type.");
649 if (SpirvType->
getOpcode() == SPIRV::OpTypeForwardPointer)
650 return SpirvType->
uses().begin()->getReg();
651 return SpirvType->
defs().begin()->getReg();
654SPIRVType *SPIRVGlobalRegistry::createSPIRVType(
656 SPIRV::AccessQualifier::AccessQualifier AccQual,
bool EmitIR) {
658 return getOrCreateSpecialType(Ty, MIRBuilder, AccQual);
659 auto &TypeToSPIRVTypeMap = DT.
getTypes()->getAllUses();
660 auto t = TypeToSPIRVTypeMap.find(Ty);
661 if (t != TypeToSPIRVTypeMap.end()) {
662 auto tt = t->second.find(&MIRBuilder.
getMF());
663 if (tt != t->second.end())
667 if (
auto IType = dyn_cast<IntegerType>(Ty)) {
668 const unsigned Width = IType->getBitWidth();
669 return Width == 1 ? getOpTypeBool(MIRBuilder)
670 : getOpTypeInt(Width, MIRBuilder,
false);
675 return getOpTypeVoid(MIRBuilder);
678 findSPIRVType(cast<FixedVectorType>(Ty)->getElementType(), MIRBuilder);
679 return getOpTypeVector(cast<FixedVectorType>(Ty)->getNumElements(), El,
686 if (
auto SType = dyn_cast<StructType>(Ty)) {
687 if (SType->isOpaque())
688 return getOpTypeOpaque(SType, MIRBuilder);
689 return getOpTypeStruct(SType, MIRBuilder, EmitIR);
691 if (
auto FType = dyn_cast<FunctionType>(Ty)) {
692 SPIRVType *
RetTy = findSPIRVType(FType->getReturnType(), MIRBuilder);
694 for (
const auto &t : FType->params()) {
695 ParamTypes.
push_back(findSPIRVType(t, MIRBuilder));
697 return getOpTypeFunction(
RetTy, ParamTypes, MIRBuilder);
699 if (
auto PType = dyn_cast<PointerType>(Ty)) {
704 if (PType->isOpaque())
708 findSPIRVType(PType->getNonOpaquePointerElementType(), MIRBuilder,
709 SPIRV::AccessQualifier::ReadWrite, EmitIR);
713 if (SpvElementType ==
nullptr) {
714 if (ForwardPointerTypes.find(Ty) == ForwardPointerTypes.end())
715 ForwardPointerTypes[PType] = getOpTypeForwardPointer(SC, MIRBuilder);
716 return ForwardPointerTypes[PType];
721 if (ForwardPointerTypes.find(PType) != ForwardPointerTypes.end())
724 return getOpTypePointer(SC, SpvElementType, MIRBuilder, Reg);
729SPIRVType *SPIRVGlobalRegistry::restOfCreateSPIRVType(
731 SPIRV::AccessQualifier::AccessQualifier AccessQual,
bool EmitIR) {
732 if (TypesInProcessing.count(Ty) && !Ty->
isPointerTy())
734 TypesInProcessing.insert(Ty);
735 SPIRVType *SpirvType = createSPIRVType(Ty, MIRBuilder, AccessQual, EmitIR);
736 TypesInProcessing.erase(Ty);
738 SPIRVToLLVMType[SpirvType] = Ty;
742 if (SpirvType->
getOpcode() != SPIRV::OpTypeForwardPointer && !
Reg.isValid() &&
750 auto t = VRegToTypeMap.find(
CurMF);
751 if (t != VRegToTypeMap.end()) {
752 auto tt = t->second.find(VReg);
753 if (tt != t->second.end())
761 SPIRV::AccessQualifier::AccessQualifier AccessQual,
bool EmitIR) {
765 TypesInProcessing.clear();
766 SPIRVType *STy = restOfCreateSPIRVType(Ty, MIRBuilder, AccessQual, EmitIR);
768 for (
auto &
CU : ForwardPointerTypes) {
769 const Type *Ty2 =
CU.first;
771 if ((Reg = DT.
find(Ty2, &MIRBuilder.
getMF())).isValid())
774 STy2 = restOfCreateSPIRVType(Ty2, MIRBuilder, AccessQual, EmitIR);
778 ForwardPointerTypes.clear();
783 unsigned TypeOpcode)
const {
785 assert(
Type &&
"isScalarOfType VReg has no type assigned");
786 return Type->getOpcode() == TypeOpcode;
790 unsigned TypeOpcode)
const {
792 assert(
Type &&
"isScalarOrVectorOfType VReg has no type assigned");
793 if (
Type->getOpcode() == TypeOpcode)
795 if (
Type->getOpcode() == SPIRV::OpTypeVector) {
798 return ScalarType->
getOpcode() == TypeOpcode;
806 if (
Type->getOpcode() == SPIRV::OpTypeVector) {
807 auto EleTypeReg =
Type->getOperand(1).getReg();
810 if (
Type->getOpcode() == SPIRV::OpTypeInt ||
811 Type->getOpcode() == SPIRV::OpTypeFloat)
812 return Type->getOperand(1).getImm();
813 if (
Type->getOpcode() == SPIRV::OpTypeBool)
820 if (
Type->getOpcode() == SPIRV::OpTypeVector) {
821 auto EleTypeReg =
Type->getOperand(1).getReg();
824 if (
Type->getOpcode() == SPIRV::OpTypeInt)
825 return Type->getOperand(2).getImm() != 0;
829SPIRV::StorageClass::StorageClass
833 Type->getOperand(1).isImm() &&
"Pointer type is expected");
834 return static_cast<SPIRV::StorageClass::StorageClass
>(
835 Type->getOperand(1).getImm());
841 SPIRV::ImageFormat::ImageFormat ImageFormat,
842 SPIRV::AccessQualifier::AccessQualifier AccessQual) {
844 Arrayed, Multisampled, Sampled, ImageFormat,
846 if (
auto *Res = checkSpecialInstr(TD, MIRBuilder))
849 DT.
add(TD, &MIRBuilder.
getMF(), ResVReg);
850 return MIRBuilder.
buildInstr(SPIRV::OpTypeImage)
865 if (
auto *Res = checkSpecialInstr(TD, MIRBuilder))
868 DT.
add(TD, &MIRBuilder.
getMF(), ResVReg);
874 SPIRV::AccessQualifier::AccessQualifier AccessQual) {
876 if (
auto *Res = checkSpecialInstr(TD, MIRBuilder))
879 DT.
add(TD, &MIRBuilder.
getMF(), ResVReg);
880 return MIRBuilder.
buildInstr(SPIRV::OpTypePipe)
888 if (
auto *Res = checkSpecialInstr(TD, MIRBuilder))
891 DT.
add(TD, &MIRBuilder.
getMF(), ResVReg);
901 if (
auto *Res = checkSpecialInstr(TD, MIRBuilder))
904 DT.
add(TD, &MIRBuilder.
getMF(), ResVReg);
905 return MIRBuilder.
buildInstr(SPIRV::OpTypeSampledImage)
916 DT.
add(Ty, &MIRBuilder.
getMF(), ResVReg);
933 unsigned VecElts = 0;
941 TypeStr = TypeStr.
substr(strlen(
"void"));
945 : TypeStr.
substr(strlen(
"uint"));
948 TypeStr = TypeStr.
substr(strlen(
"float"));
951 TypeStr = TypeStr.
substr(strlen(
"half"));
952 }
else if (TypeStr.
startswith(
"opencl.sampler_t")) {
957 TypeStr = TypeStr.
substr(strlen(
" vector["));
958 TypeStr = TypeStr.
substr(0, TypeStr.
find(
']'));
975SPIRVType *SPIRVGlobalRegistry::finishCreatingSPIRVType(
const Type *LLVMTy,
979 SPIRVToLLVMType[SpirvType] = LLVMTy;
991 auto MIB =
BuildMI(BB,
I,
I.getDebugLoc(),
TII.get(SPIRV::OpTypeInt))
995 return finishCreatingSPIRVType(LLVMTy, MIB);
1013 auto MIB =
BuildMI(BB,
I,
I.getDebugLoc(),
TII.get(SPIRV::OpTypeBool))
1015 return finishCreatingSPIRVType(LLVMTy, MIB);
1035 auto MIB =
BuildMI(BB,
I,
I.getDebugLoc(),
TII.get(SPIRV::OpTypeVector))
1039 return finishCreatingSPIRVType(LLVMTy, MIB);
1053 auto MIB =
BuildMI(BB,
I,
I.getDebugLoc(),
TII.get(SPIRV::OpTypeArray))
1057 return finishCreatingSPIRVType(LLVMTy, MIB);
1062 SPIRV::StorageClass::StorageClass SClass) {
1071 SPIRV::StorageClass::StorageClass SC) {
1079 auto MIB =
BuildMI(BB,
I,
I.getDebugLoc(),
TII.get(SPIRV::OpTypePointer))
1083 return finishCreatingSPIRVType(LLVMTy, MIB);
1104 MIB =
BuildMI(*
I.getParent(),
I,
I.getDebugLoc(),
TII.get(SPIRV::OpUndef))
1109 *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 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.
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.
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.
const SPIRVDuplicatesTracker< Type > * getTypes()
void add(const Type *T, const MachineFunction *MF, Register R)
Register find(const Type *T, const MachineFunction *MF)
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...
uint64_t getArrayNumElements() const
static Type * getVoidTy(LLVMContext &C)
LLVMContext & getContext() const
Return the LLVMContext in which this type was uniqued.
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 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.