23#include "llvm/IR/IntrinsicsSPIRV.h"
25#define DEBUG_TYPE "spirv-prelegalizer"
39void SPIRVPreLegalizer::getAnalysisUsage(
AnalysisUsage &AU)
const {
59 MI.getOperand(3).getMetadata()->getOperand(0))
64 GR->
add(GV,
MRI.getVRegDef(SrcReg));
67 RegsAlreadyAddedToDT[&
MI] =
Reg;
72 auto *BuildVec =
MRI.getVRegDef(SrcReg);
74 BuildVec->getOpcode() == TargetOpcode::G_BUILD_VECTOR);
75 GR->
add(Const, BuildVec);
76 for (
unsigned i = 0; i < ConstVec->getNumElements(); ++i) {
79 Constant *ElemConst = ConstVec->getElementAsConstant(i);
83 MRI.getVRegDef(BuildVec->getOperand(1 + i).getReg()));
85 BuildVec->getOperand(1 + i).setReg(ElemReg);
88 if (Const->getType()->isTargetExtTy()) {
92 GR->
add(Const, SrcMI);
93 if (SrcMI && (SrcMI->
getOpcode() == TargetOpcode::G_CONSTANT ||
94 SrcMI->
getOpcode() == TargetOpcode::G_IMPLICIT_DEF))
95 TargetExtConstTypes[SrcMI] = Const->getType();
96 if (Const->isNullValue()) {
100 Const->getType(), MIB, SPIRV::AccessQualifier::ReadWrite,
102 assert(SrcMI &&
"Expected source instruction to be valid");
109 RegsAlreadyAddedToDT[&
MI] =
Reg;
112 assert(
MI.getOperand(2).isReg() &&
"Reg operand is expected");
114 if (SrcMI &&
isSpvIntrinsic(*SrcMI, Intrinsic::spv_const_composite))
122 auto It = RegsAlreadyAddedToDT.
find(
MI);
123 if (It != RegsAlreadyAddedToDT.
end())
125 auto *RC =
MRI.getRegClassOrNull(
MI->getOperand(0).getReg());
126 if (!
MRI.getRegClassOrNull(
Reg) && RC)
128 MRI.replaceRegWith(
MI->getOperand(0).getReg(),
Reg);
130 MI->eraseFromParent();
134 MI->eraseFromParent();
146 const MDNode *MD =
MI.getOperand(2).getMetadata();
156 MI->eraseFromParent();
165 IE =
MRI->use_instr_end();
170 UseMI->getOperand(1).getReg() ==
Reg)
180 assert(ResType && OpType &&
"Operand types are expected");
184 if (!
MRI->getRegClassOrNull(ResVReg))
186 if (ResType == OpType)
217 "Expected destination SPIR-V type to have been assigned already.");
220 "Expected source SPIR-V type to have been assigned already.");
221 if (DstType == SrcType) {
229 if (
MI.getOpcode() != TargetOpcode::G_BITCAST)
234 MI.getOperand(1).getReg());
240 MI->eraseFromParent();
262 ? SPIRV::StorageClass::CodeSectionINTEL
274 MRI->replaceRegWith(Def, Source);
284 MI->eraseFromParent();
307 assert(
MI &&
"Machine instr is expected");
308 if (
MI->getOperand(0).isReg()) {
312 switch (
MI->getOpcode()) {
313 case TargetOpcode::G_FCONSTANT:
314 case TargetOpcode::G_CONSTANT: {
316 Type *Ty =
MI->getOperand(1).getCImm()->getType();
318 Ty, MIB, SPIRV::AccessQualifier::ReadWrite,
true);
321 case TargetOpcode::G_GLOBAL_VALUE: {
326 Global->getType()->getAddressSpace());
328 Ty, MIB, SPIRV::AccessQualifier::ReadWrite,
true);
331 case TargetOpcode::G_ANYEXT:
332 case TargetOpcode::G_SEXT:
333 case TargetOpcode::G_ZEXT: {
334 if (
MI->getOperand(1).isReg()) {
336 MRI.getVRegDef(
MI->getOperand(1).getReg())) {
340 unsigned ExpectedBW =
341 std::max(
MRI.getType(
Reg).getScalarSizeInBits(), CurrentBW);
352 case TargetOpcode::G_PTRTOINT:
354 MRI.getType(
Reg).getScalarSizeInBits(), MIB);
356 case TargetOpcode::G_TRUNC:
357 case TargetOpcode::G_ADDRSPACE_CAST:
358 case TargetOpcode::G_PTR_ADD:
359 case TargetOpcode::COPY: {
372 if (SpvType->
getOpcode() == SPIRV::OpTypePointer &&
383 if (!
MRI.getRegClassOrNull(
Reg))
385 : &SPIRV::iIDRegClass);
406 if (NewWidth != CurrentWidth)
414 if (NewWidth != CurrentWidth) {
424 Def->getNextNode() ? Def->getNextNode()->getIterator() :
MBB.end();
426 while (DefIt !=
MBB.end() &&
427 (DefIt->isPHI() || DefIt->isDebugOrPseudoInstr()))
428 DefIt = std::next(DefIt);
436 assert((Ty || SpvType) &&
"Either LLVM or SPIRV type is expected.");
441 SPIRV::AccessQualifier::ReadWrite,
true);
442 if (!
MRI.getRegClassOrNull(Reg))
444 if (!
MRI.getType(Reg).isValid())
453 for (
auto &
Op :
MI.operands()) {
454 if (!
Op.isReg() ||
Op.isDef())
458 if (!SpvType && KnownResType) {
459 SpvType = KnownResType;
463 if (!
MRI.getRegClassOrNull(OpReg))
465 if (!
MRI.getType(OpReg).isValid())
483 bool IsExtendedInts =
485 SPIRV::Extension::SPV_ALTERA_arbitrary_precision_integers) ||
486 ST->canUseExtension(SPIRV::Extension::SPV_KHR_bit_instructions) ||
487 ST->canUseExtension(SPIRV::Extension::SPV_INTEL_int4);
493 bool ReachedBegin =
false;
494 for (
auto MII = std::prev(
MBB->end()), Begin =
MBB->begin();
497 unsigned MIOp =
MI.getOpcode();
499 if (!IsExtendedInts) {
501 for (
auto &MOP :
MI.operands()) {
504 else if (MOP.isCImm())
517 assert(Def &&
"Expecting an instruction that defines the register");
519 if (Def->getOpcode() != TargetOpcode::G_GLOBAL_VALUE)
527 assert(Def &&
"Expecting an instruction that defines the register");
529 if (Def->getOpcode() != TargetOpcode::G_GLOBAL_VALUE)
532 }
else if (MIOp == TargetOpcode::FAKE_USE &&
MI.getNumOperands() > 0) {
537 for (
unsigned I = 1,
E =
MI.getNumOperands();
I !=
E && Def; ++
I)
551 }
else if (MIOp == TargetOpcode::G_CONSTANT ||
552 MIOp == TargetOpcode::G_FCONSTANT ||
553 MIOp == TargetOpcode::G_BUILD_VECTOR) {
559 if (MIOp == TargetOpcode::G_CONSTANT) {
560 auto TargetExtIt = TargetExtConstTypes.
find(&
MI);
561 Ty = TargetExtIt == TargetExtConstTypes.
end()
562 ?
MI.getOperand(1).getCImm()->getType()
563 : TargetExtIt->second;
576 }
else if (PrimaryReg !=
Reg &&
577 MRI.getType(
Reg) ==
MRI.getType(PrimaryReg)) {
578 auto *RCReg =
MRI.getRegClassOrNull(
Reg);
579 auto *RCPrimary =
MRI.getRegClassOrNull(PrimaryReg);
580 if (!RCReg || RCPrimary == RCReg) {
581 RegsAlreadyAddedToDT[&
MI] = PrimaryReg;
583 NeedAssignType =
false;
586 }
else if (MIOp == TargetOpcode::G_FCONSTANT) {
587 Ty =
MI.getOperand(1).getFPImm()->getType();
589 assert(MIOp == TargetOpcode::G_BUILD_VECTOR);
590 Type *ElemTy =
nullptr;
594 if (ElemMI->
getOpcode() == TargetOpcode::G_CONSTANT) {
596 }
else if (ElemMI->
getOpcode() == TargetOpcode::G_FCONSTANT) {
605 ElemTy,
MI.getNumExplicitOperands() -
MI.getNumExplicitDefs(),
608 NeedAssignType =
false;
612 }
else if (MIOp == TargetOpcode::G_GLOBAL_VALUE) {
623 auto It = RegsAlreadyAddedToDT.
find(
MI);
624 if (It != RegsAlreadyAddedToDT.
end())
625 MRI.replaceRegWith(
MI->getOperand(0).getReg(), It->second);
627 MI->eraseFromParent();
634 switch (
MI.getOpcode()) {
635 case TargetOpcode::G_TRUNC:
636 case TargetOpcode::G_ANYEXT:
637 case TargetOpcode::G_SEXT:
638 case TargetOpcode::G_ZEXT:
639 case TargetOpcode::G_PTRTOINT:
640 case TargetOpcode::COPY:
641 case TargetOpcode::G_ADDRSPACE_CAST:
665 for (
unsigned Idx = StartOp, MISz =
MI->getNumOperands(); Idx != MISz;
670 if (Idx == AsmDescOp && MO.
isImm()) {
673 AsmDescOp += 1 +
F.getNumOperandRegisters();
694 for (
unsigned i = 0, Sz = ToProcess.
size(); i + 1 < Sz; i += 2) {
695 MachineInstr *I1 = ToProcess[i], *I2 = ToProcess[i + 1];
702 MRI.setRegClass(AsmTargetReg, &SPIRV::iIDRegClass);
706 GR->
add(AsmTargetMIB.getInstr(), AsmTargetMIB);
710 const MDNode *IAMD = I1->getOperand(1).getMetadata();
713 for (
const auto &ArgTy : FTy->params())
715 ArgTy, MIRBuilder, SPIRV::AccessQualifier::ReadWrite,
true));
718 SPIRV::AccessQualifier::ReadWrite,
true);
720 FTy, RetType, ArgTypes, MIRBuilder);
724 MRI.setRegClass(AsmReg, &SPIRV::iIDRegClass);
725 auto AsmMIB = MIRBuilder.
buildInstr(SPIRV::OpAsmINTEL)
737 GR->
add(AsmMIB.getInstr(), AsmMIB);
744 .
addImm(
static_cast<uint32_t>(SPIRV::Decoration::SideEffectsINTEL));
749 MRI.setRegClass(DefReg, &SPIRV::iIDRegClass);
752 SPIRV::AccessQualifier::ReadWrite,
true);
756 auto AsmCall = MIRBuilder.
buildInstr(SPIRV::OpAsmCallINTEL)
760 for (
unsigned IntrIdx = 3; IntrIdx < I1->getNumOperands(); ++IntrIdx)
761 AsmCall.
addUse(I1->getOperand(IntrIdx).getReg());
765 MI->eraseFromParent();
776 MI.getOpcode() == TargetOpcode::INLINEASM)
780 if (ToProcess.
size() == 0)
783 if (!ST.canUseExtension(SPIRV::Extension::SPV_INTEL_inline_assembly))
785 "following SPIR-V extension: SPV_INTEL_inline_assembly",
797 return FPMaxError.Spir;
813 MI.getOperand(2).getMetadata(), ST);
815 Intrinsic::spv_assign_fpmaxerror_decoration)) {
817 MI.getOperand(2).getMetadata()->getOperand(0));
822 SPIRV::Decoration::FPMaxErrorDecorationINTEL,
826 MI.getOperand(2).getImm(),
827 MI.getOperand(3).getMetadata());
835 MI->eraseFromParent();
855 for (
unsigned i = 3; i <
MI.getNumOperands(); i += 2) {
865 while (
MI.getNumOperands() > 0)
867 for (
auto &MO : NewOperands)
881 MI.getOpcode() == TargetOpcode::G_BRINDIRECT)
888 MI->eraseFromParent();
899 BB2MBB[
MBB.getBasicBlock()] = &
MBB;
921 for (
unsigned i = 0; i <
MI->getNumOperands(); ++i) {
923 if (!
MI->getOperand(i).isReg()) {
931 if (!BuildMBB || BuildMBB->
getOpcode() != TargetOpcode::G_BLOCK_ADDR) {
936 assert(BuildMBB && BuildMBB->
getOpcode() == TargetOpcode::G_BLOCK_ADDR &&
941 auto It = BB2MBB.
find(BB);
942 if (It == BB2MBB.
end())
944 "in a switch statement");
948 ClearAddressTaken.
insert(ReferencedBlock);
949 ToEraseMI.
insert(BuildMBB);
954 while (
MI->getNumOperands() > 0)
955 MI->removeOperand(0);
956 for (
auto &MO : NewOps)
964 if (
Next &&
Next->getOpcode() == TargetOpcode::G_BRINDIRECT)
973 Succ->setAddressTakenIRBlock(
nullptr);
984 if (BlockAddrI->getOpcode() == TargetOpcode::G_BLOCK_ADDR) {
986 BlockAddrI->getOperand(1).getBlockAddress());
992 BlockAddrI->eraseFromParent();
1002 if (!
MBB.canFallThrough())
1029bool SPIRVPreLegalizer::runOnMachineFunction(MachineFunction &MF) {
1032 SPIRVGlobalRegistry *GR =
ST.getSPIRVGlobalRegistry();
1033 GR->setCurrentFunc(MF);
1034 MachineIRBuilder MIB(MF);
1036 DenseMap<MachineInstr *, Type *> TargetExtConstTypes;
1059char SPIRVPreLegalizer::
ID = 0;
1062 return new SPIRVPreLegalizer();
unsigned const MachineRegisterInfo * MRI
MachineInstrBuilder & UseMI
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
This file contains the simple types necessary to represent the attributes associated with functions a...
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
Provides analysis for continuously CSEing during GISel passes.
This file contains the declarations for the subclasses of Constant, which represent the different fla...
Provides analysis for querying information about KnownBits during GISel passes.
const AbstractManglingParser< Derived, Alloc >::OperatorInfo AbstractManglingParser< Derived, Alloc >::Ops[]
Promote Memory to Register
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
This file builds on the ADT/GraphTraits.h file to build a generic graph post order iterator.
static Register collectInlineAsmInstrOperands(MachineInstr *MI, SmallVector< unsigned, 4 > *Ops=nullptr)
static void insertInlineAsm(MachineFunction &MF, SPIRVGlobalRegistry *GR, const SPIRVSubtarget &ST, MachineIRBuilder MIRBuilder)
static void cleanupHelperInstructions(MachineFunction &MF, SPIRVGlobalRegistry *GR)
static void insertInlineAsmProcess(MachineFunction &MF, SPIRVGlobalRegistry *GR, const SPIRVSubtarget &ST, MachineIRBuilder MIRBuilder, const SmallVector< MachineInstr * > &ToProcess)
static void removeImplicitFallthroughs(MachineFunction &MF, MachineIRBuilder MIB)
static unsigned widenBitWidthToNextPow2(unsigned BitWidth)
static void setInsertPtAfterDef(MachineIRBuilder &MIB, MachineInstr *Def)
static bool isImplicitFallthrough(MachineBasicBlock &MBB)
static void insertSpirvDecorations(MachineFunction &MF, SPIRVGlobalRegistry *GR, MachineIRBuilder MIB)
static void insertBitcasts(MachineFunction &MF, SPIRVGlobalRegistry *GR, MachineIRBuilder MIB)
static void processInstrsWithTypeFolding(MachineFunction &MF, SPIRVGlobalRegistry *GR, MachineIRBuilder MIB)
static void processSwitchesConstants(MachineFunction &MF, SPIRVGlobalRegistry *GR, MachineIRBuilder MIB)
static void lowerBitcasts(MachineFunction &MF, SPIRVGlobalRegistry *GR, MachineIRBuilder MIB)
static MachineInstr * findAssignTypeInstr(Register Reg, MachineRegisterInfo *MRI)
static void widenCImmType(MachineOperand &MOP)
static void buildOpBitcast(SPIRVGlobalRegistry *GR, MachineIRBuilder &MIB, Register ResVReg, Register OpReg)
static void processBlockAddr(MachineFunction &MF, SPIRVGlobalRegistry *GR, MachineIRBuilder MIB)
static void widenScalarType(Register Reg, MachineRegisterInfo &MRI)
static void foldConstantsIntoIntrinsics(MachineFunction &MF, SPIRVGlobalRegistry *GR, MachineIRBuilder MIB)
static void addConstantsToTrack(MachineFunction &MF, SPIRVGlobalRegistry *GR, const SPIRVSubtarget &STI, DenseMap< MachineInstr *, Type * > &TargetExtConstTypes)
static uint32_t convertFloatToSPIRVWord(float F)
static SPIRVTypeInst propagateSPIRVType(MachineInstr *MI, SPIRVGlobalRegistry *GR, MachineRegisterInfo &MRI, MachineIRBuilder &MIB)
static void generateAssignInstrs(MachineFunction &MF, SPIRVGlobalRegistry *GR, MachineIRBuilder MIB, DenseMap< MachineInstr *, Type * > &TargetExtConstTypes)
LLVM_ABI float convertToFloat() const
Converts this APFloat to host float value.
LLVM_ABI APInt zextOrTrunc(unsigned width) const
Zero extend or truncate to width.
Represent the analysis usage information of a pass.
AnalysisUsage & addPreserved()
Add the specified Pass class to the set of analyses preserved by this pass.
LLVM Basic Block Representation.
The address of a basic block.
BasicBlock * getBasicBlock() const
static LLVM_ABI Constant * getIntToPtr(Constant *C, Type *Ty, bool OnlyIfReduced=false)
ConstantFP - Floating Point Values [float, double].
const APFloat & getValueAPF() const
This is the shared class of boolean and integer constants.
unsigned getBitWidth() const
getBitWidth - Return the scalar bitwidth of this constant.
const APInt & getValue() const
Return the constant as an APInt value reference.
This is an important base class in LLVM.
LLVM_ABI void destroyConstant()
Called if some element of this constant is no longer valid.
iterator find(const_arg_type_t< KeyT > Val)
LLVMContext & getContext() const
getContext - Return a reference to the LLVMContext associated with this function.
constexpr unsigned getScalarSizeInBits() const
constexpr bool isScalar() const
static constexpr LLT scalar(unsigned SizeInBits)
Get a low-level scalar or aggregate "bag of bits".
constexpr bool isPointer() const
constexpr unsigned getAddressSpace() const
const MDOperand & getOperand(unsigned I) const
LLVM_ABI iterator getFirstNonPHI()
Returns a pointer to the first instruction in this block that is not a PHINode instruction.
MachineInstrBundleIterator< MachineInstr, true > reverse_iterator
MachineInstrBundleIterator< MachineInstr > iterator
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - Subclasses that override getAnalysisUsage must call this.
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.
const MachineBasicBlock & front() const
Helper class to build MachineInstr.
MachineInstrBuilder buildBr(MachineBasicBlock &Dest)
Build and insert G_BR Dest.
void setInsertPt(MachineBasicBlock &MBB, MachineBasicBlock::iterator II)
Set the insertion point before the specified position.
MachineInstrBuilder buildInstr(unsigned Opcode)
Build and insert <empty> = Opcode <empty>.
MachineFunction & getMF()
Getter for the function we currently build.
MachineInstrBuilder buildBitcast(const DstOp &Dst, const SrcOp &Src)
Build and insert Dst = G_BITCAST Src.
MachineRegisterInfo * getMRI()
Getter for MRI.
MachineInstrBuilder buildCopy(const DstOp &Res, const SrcOp &Op)
Build and insert Res = COPY Op.
const MachineInstrBuilder & addUse(Register RegNo, RegState Flags={}, unsigned SubReg=0) const
Add a virtual register use operand.
const MachineInstrBuilder & addImm(int64_t Val) const
Add a new immediate operand.
const MachineInstrBuilder & addDef(Register RegNo, RegState Flags={}, unsigned SubReg=0) const
Add a virtual register definition operand.
Representation of each machine instruction.
unsigned getOpcode() const
Returns the opcode of this MachineInstr.
LLVM_ABI void addOperand(MachineFunction &MF, const MachineOperand &Op)
Add the specified operand to the instruction.
LLVM_ABI void setDesc(const MCInstrDesc &TID)
Replace the instruction descriptor (thus opcode) of the current instruction with a new one.
const MachineOperand & getOperand(unsigned i) const
MachineOperand class - Representation of each machine instruction operand.
const ConstantInt * getCImm() const
bool isReg() const
isReg - Tests if this is a MO_Register operand.
const MDNode * getMetadata() const
static MachineOperand CreateCImm(const ConstantInt *CI)
bool isImm() const
isImm - Tests if this is a MO_Immediate operand.
bool isMetadata() const
isMetadata - Tests if this is a MO_Metadata operand.
const BlockAddress * getBlockAddress() const
void setCImm(const ConstantInt *CI)
bool isBlockAddress() const
isBlockAddress - Tests if this is a MO_BlockAddress operand.
Register getReg() const
getReg - Returns the register number.
const ConstantFP * getFPImm() const
static MachineOperand CreateReg(Register Reg, bool isDef, bool isImp=false, bool isKill=false, bool isDead=false, bool isUndef=false, bool isEarlyClobber=false, unsigned SubReg=0, bool isDebug=false, bool isInternalRead=false, bool isRenamable=false)
static MachineOperand CreateMBB(MachineBasicBlock *MBB, unsigned TargetFlags=0)
MachineRegisterInfo - Keep track of information for virtual and physical registers,...
defusechain_instr_iterator< true, false, false, true > use_instr_iterator
use_instr_iterator/use_instr_begin/use_instr_end - Walk all uses of the specified register,...
Wrapper class representing virtual and physical registers.
constexpr bool isValid() const
void assignSPIRVTypeToVReg(SPIRVTypeInst Type, Register VReg, const MachineFunction &MF)
SPIRVTypeInst getOrCreateOpTypeFunctionWithArgs(const Type *Ty, SPIRVTypeInst RetType, const SmallVectorImpl< SPIRVTypeInst > &ArgTypes, MachineIRBuilder &MIRBuilder)
const TargetRegisterClass * getRegClass(SPIRVTypeInst SpvType) const
unsigned getScalarOrVectorBitWidth(SPIRVTypeInst Type) const
SPIRVTypeInst getOrCreateSPIRVIntegerType(unsigned BitWidth, MachineIRBuilder &MIRBuilder)
SPIRVTypeInst getOrCreateSPIRVVectorType(SPIRVTypeInst BaseType, unsigned NumElements, MachineIRBuilder &MIRBuilder, bool EmitIR)
unsigned getScalarOrVectorComponentCount(Register VReg) const
const Type * getTypeForSPIRVType(SPIRVTypeInst Ty) const
bool isBitcastCompatible(SPIRVTypeInst Type1, SPIRVTypeInst Type2) const
LLT getRegType(SPIRVTypeInst SpvType) const
void invalidateMachineInstr(MachineInstr *MI)
SPIRVTypeInst getOrCreateSPIRVPointerType(const Type *BaseType, MachineIRBuilder &MIRBuilder, SPIRV::StorageClass::StorageClass SC)
Register getSPIRVTypeID(SPIRVTypeInst SpirvType) const
SPIRVTypeInst changePointerStorageClass(SPIRVTypeInst PtrType, SPIRV::StorageClass::StorageClass SC, MachineInstr &I)
void addGlobalObject(const Value *V, const MachineFunction *MF, Register R)
SPIRVTypeInst getOrCreateSPIRVType(const Type *Type, MachineInstr &I, SPIRV::AccessQualifier::AccessQualifier AQ, bool EmitIR)
SPIRVTypeInst getSPIRVTypeForVReg(Register VReg, const MachineFunction *MF=nullptr) const
Type * getDeducedGlobalValueType(const GlobalValue *Global)
void addValueAttrs(MachineInstr *Key, std::pair< Type *, std::string > Val)
void buildMemAliasingOpDecorate(Register Reg, MachineIRBuilder &MIRBuilder, uint32_t Dec, const MDNode *GVarMD)
SPIRV::StorageClass::StorageClass getPointerStorageClass(Register VReg) const
bool add(SPIRV::IRHandle Handle, const MachineInstr *MI)
Register find(SPIRV::IRHandle Handle, const MachineFunction *MF)
const SPIRVInstrInfo * getInstrInfo() const override
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements.
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.
The instances of the Type class are immutable: once they are created, they are never changed.
static LLVM_ABI IntegerType * getInt32Ty(LLVMContext &C)
static LLVM_ABI Type * getVoidTy(LLVMContext &C)
LLVMContext & getContext() const
Return the LLVMContext in which this type was uniqued.
static LLVM_ABI TypedPointerType * get(Type *ElementType, unsigned AddressSpace)
This constructs a pointer to an object of the specified type in a numbered address space.
Type * getType() const
All values are typed, get the type of this value.
LLVM_ABI void replaceAllUsesWith(Value *V)
Change all uses of this to point to a new Value.
static LLVM_ABI VectorType * get(Type *ElementType, ElementCount EC)
This static method is the primary way to construct an VectorType.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
std::enable_if_t< detail::IsValidPointer< X, Y >::value, X * > dyn_extract(Y &&MD)
Extract a Value from Metadata, if any.
This is an optimization pass for GlobalISel generic memory operations.
void buildOpName(Register Target, const StringRef &Name, MachineIRBuilder &MIRBuilder)
unsigned Log2_32_Ceil(uint32_t Value)
Return the ceil log base 2 of the specified value, 32 if the value is zero.
StringMapEntry< Value * > ValueName
bool isTypeFoldingSupported(unsigned Opcode)
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
FunctionPass * createSPIRVPreLegalizerPass()
iterator_range< po_iterator< T > > post_order(const T &G)
void updateRegType(Register Reg, Type *Ty, SPIRVTypeInst SpirvTy, SPIRVGlobalRegistry *GR, MachineIRBuilder &MIB, MachineRegisterInfo &MRI)
Helper external function for assigning a SPIRV type to a register, ensuring the register class and ty...
constexpr unsigned storageClassToAddressSpace(SPIRV::StorageClass::StorageClass SC)
void buildOpDecorate(Register Reg, MachineIRBuilder &MIRBuilder, SPIRV::Decoration::Decoration Dec, const std::vector< uint32_t > &DecArgs, StringRef StrImm)
Type * toTypedPointer(Type *Ty)
LLVM_ABI void report_fatal_error(Error Err, bool gen_crash_diag=true)
bool isa(const From &Val)
isa<X> - Return true if the parameter to the template is an instance of one of the template type argu...
@ Global
Append to llvm.global_dtors.
SPIRV::StorageClass::StorageClass addressSpaceToStorageClass(unsigned AddrSpace, const SPIRVSubtarget &STI)
void buildOpSpirvDecorations(Register Reg, MachineIRBuilder &MIRBuilder, const MDNode *GVarMD, const SPIRVSubtarget &ST)
void processInstr(MachineInstr &MI, MachineIRBuilder &MIB, MachineRegisterInfo &MRI, SPIRVGlobalRegistry *GR, SPIRVTypeInst KnownResType)
FunctionAddr VTableAddr Next
DWARFExpression::Operation Op
MachineInstr * getDefInstrMaybeConstant(Register &ConstReg, const MachineRegisterInfo *MRI)
constexpr unsigned BitWidth
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
Type * getMDOperandAsType(const MDNode *N, unsigned I)
bool isSpvIntrinsic(const MachineInstr &MI, Intrinsic::ID IntrinsicID)
void addStringImm(const StringRef &Str, MCInst &Inst)
MachineInstr * getVRegDef(MachineRegisterInfo &MRI, Register Reg)