51#define DEBUG_TYPE "asm-printer"
60 std::unique_ptr<MCStreamer>
Streamer)
62 ST(
nullptr),
TII(
nullptr), MAI(
nullptr) {
64 return &getAnalysis<SPIRVModuleAnalysisWrapperPass>().MAI;
68 bool ModuleSectionsEmitted;
72 StringRef getPassName()
const override {
return "SPIRV Assembly Printer"; }
77 void outputMCInst(
MCInst &Inst);
80 void outputGlobalRequirements();
81 void outputEntryPoints();
82 void outputDebugSourceAndStrings(
const Module &M);
83 void outputOpExtInstImports(
const Module &M);
84 void outputOpMemoryModel();
85 void outputOpFunctionEnd();
86 void outputExtFuncDecls();
88 SPIRV::ExecutionMode::ExecutionMode EM,
89 unsigned ExpectMDOps, int64_t DefVal);
90 void outputExecutionModeFromNumthreadsAttribute(
92 SPIRV::ExecutionMode::ExecutionMode EM);
93 void outputExecutionModeFromEnableMaximalReconvergenceAttr(
96 SPIRV::ExecutionMode::ExecutionMode EM);
97 void outputExecutionMode(
const Module &M);
98 void outputAnnotations(
const Module &M);
99 void outputModuleSections();
100 void outputFPFastMathDefaultInfo();
102 return MF->getFunction()
108 void emitFunctionEntryLabel()
override {}
109 void emitFunctionHeader()
override;
110 void emitFunctionBodyStart()
override {}
111 void emitFunctionBodyEnd()
override;
116 void emitEndOfAsmFile(
Module &M)
override;
117 bool doInitialization(
Module &M)
override;
128 std::unique_ptr<SPIRVAuxDataHandler> AuxDataHandler;
135void SPIRVAsmPrinter::getAnalysisUsage(
AnalysisUsage &AU)
const {
142void SPIRVAsmPrinter::emitEndOfAsmFile(
Module &M) {
143 if (!ModuleSectionsEmitted) {
144 outputModuleSections();
145 ModuleSectionsEmitted =
true;
148 ST =
static_cast<const SPIRVTargetMachine &
>(TM).getSubtargetImpl();
156 uint32_t Major = SPIRVVersion.
getMajor();
157 uint32_t Minor = SPIRVVersion.
getMinor().value_or(0);
160 unsigned Bound = 2 * (ST->
getBound() + 1) + NLabels;
161 if (MCAssembler *Asm = OutStreamer->getAssemblerPtr())
162 static_cast<SPIRVObjectWriter &
>(
Asm->getWriter())
163 .setBuildVersion(Major, Minor, Bound);
170void SPIRVAsmPrinter::cleanUp(
Module &M) {
172 for (StringRef GVName :
173 {
"llvm.global_ctors",
"llvm.global_dtors",
"llvm.used"}) {
174 if (GlobalVariable *GV =
M.getNamedGlobal(GVName))
179void SPIRVAsmPrinter::emitFunctionHeader() {
180 if (!ModuleSectionsEmitted) {
181 outputModuleSections();
182 ModuleSectionsEmitted =
true;
185 ST = &MF->getSubtarget<SPIRVSubtarget>();
189 if (isVerbose() && !isHidden()) {
190 OutStreamer->getCommentOS()
191 <<
"-- Begin function "
195 auto Section = getObjFileLowering().SectionForGlobal(&
F, TM);
196 MF->setSection(Section);
202 for (
auto &Handler : Handlers) {
203 Handler->beginFunction(MF);
204 Handler->beginBasicBlockSection(MF->front());
208void SPIRVAsmPrinter::outputOpFunctionEnd() {
209 MCInst FunctionEndInst;
210 FunctionEndInst.
setOpcode(SPIRV::OpFunctionEnd);
211 outputMCInst(FunctionEndInst);
214void SPIRVAsmPrinter::emitFunctionBodyEnd() {
216 outputOpFunctionEnd();
219void SPIRVAsmPrinter::emitOpLabel(
const MachineBasicBlock &
MBB) {
227 outputMCInst(LabelInst);
232void SPIRVAsmPrinter::emitBasicBlockStart(
const MachineBasicBlock &
MBB) {
240 for (
const MachineInstr &
MI :
MBB)
241 if (
MI.getOpcode() == SPIRV::OpFunction)
249void SPIRVAsmPrinter::printOperand(
const MachineInstr *
MI,
int OpNum,
251 const MachineOperand &MO =
MI->getOperand(OpNum);
291bool SPIRVAsmPrinter::PrintAsmOperand(
const MachineInstr *
MI,
unsigned OpNo,
292 const char *ExtraCode, raw_ostream &O) {
293 if (ExtraCode && ExtraCode[0])
302 return TII->isHeaderInstr(*
MI) ||
MI->getOpcode() == SPIRV::OpFunction ||
303 MI->getOpcode() == SPIRV::OpFunctionParameter;
306void SPIRVAsmPrinter::outputMCInst(MCInst &Inst) {
307 OutStreamer->emitInstruction(Inst, *OutContext.getSubtargetInfo());
310void SPIRVAsmPrinter::outputInstruction(
const MachineInstr *
MI) {
311 SPIRVMCInstLower MCInstLowering;
313 MCInstLowering.
lower(
MI, TmpInst, MAI);
314 outputMCInst(TmpInst);
317void SPIRVAsmPrinter::emitInstruction(
const MachineInstr *
MI) {
318 SPIRV_MC::verifyInstructionPredicates(
MI->getOpcode(),
319 getSubtargetInfo().getFeatureBits());
321 bool InstructionEmitted = !MAI->getSkipEmission(
MI);
322 if (InstructionEmitted)
323 outputInstruction(
MI);
326 const MachineInstr *NextMI =
MI->getNextNode();
327 bool BlockHasLabel = LabeledMBB.
contains(
MI->getParent());
329 bool IsNextInstructionFunctionPreamble =
331 bool ShouldEmitEntryLabel = !BlockHasLabel && IsFunctionPreambleInstruction &&
332 !IsNextInstructionFunctionPreamble;
333 if (ShouldEmitEntryLabel) {
334 assert(
MI->getParent()->getNumber() == MF->front().getNumber() &&
335 "OpFunction is not in the front MBB of MF");
336 emitOpLabel(*
MI->getParent());
337 if (NSDebugHandler && !isHidden())
342void SPIRVAsmPrinter::outputModuleSection(SPIRV::ModuleSectionType MSType) {
343 for (
const MachineInstr *
MI : MAI->getMSInstrs(MSType))
344 outputInstruction(
MI);
347void SPIRVAsmPrinter::outputDebugSourceAndStrings(
const Module &M) {
349 for (
auto &Str : MAI->SrcExt) {
351 Inst.
setOpcode(SPIRV::OpSourceExtension);
356 outputModuleSection(SPIRV::MB_DebugStrings);
372 AuxDataHandler->emitAuxDataStrings(*MAI);
375void SPIRVAsmPrinter::outputOpExtInstImports(
const Module &M) {
376 for (
auto &CU : MAI->ExtInstSetMap) {
377 unsigned Set = CU.first;
378 MCRegister
Reg = CU.second;
383 static_cast<SPIRV::InstructionSet::InstructionSet
>(Set)),
389void SPIRVAsmPrinter::outputOpMemoryModel() {
401void SPIRVAsmPrinter::outputEntryPoints() {
403 DenseSet<MCRegister> InterfaceIDs;
404 for (
const MachineInstr *
MI : MAI->GlobalVarList) {
405 assert(
MI->getOpcode() == SPIRV::OpVariable ||
406 MI->getOpcode() == SPIRV::OpUntypedVariableKHR);
407 auto SC =
static_cast<SPIRV::StorageClass::StorageClass
>(
414 SC == SPIRV::StorageClass::Input || SC == SPIRV::StorageClass::Output) {
416 MCRegister
Reg = MAI->getRegisterAlias(MF,
MI->getOperand(0).getReg());
422 for (
const MachineInstr *
MI : MAI->getMSInstrs(SPIRV::MB_EntryPoints)) {
423 SPIRVMCInstLower MCInstLowering;
425 MCInstLowering.
lower(
MI, TmpInst, MAI);
426 for (MCRegister
Reg : InterfaceIDs) {
430 outputMCInst(TmpInst);
435void SPIRVAsmPrinter::outputGlobalRequirements() {
437 MAI->Reqs.checkSatisfiable(*ST);
439 for (
const auto &Cap : MAI->Reqs.getMinimalCapabilities()) {
447 for (
const auto &Ext : MAI->Reqs.getExtensions()) {
451 SPIRV::OperandCategory::ExtensionOperand, Ext),
458void SPIRVAsmPrinter::outputExtFuncDecls() {
460 auto I = MAI->getMSInstrs(SPIRV::MB_ExtFuncDecls).begin(),
461 E = MAI->getMSInstrs(SPIRV::MB_ExtFuncDecls).end();
462 for (;
I !=
E; ++
I) {
463 outputInstruction(*
I);
464 if ((
I + 1) ==
E || (*(
I + 1))->
getOpcode() == SPIRV::OpFunction)
465 outputOpFunctionEnd();
475 if (Ty->isDoubleTy())
478 switch (IntTy->getIntegerBitWidth()) {
492 Type *EleTy = VecTy->getElementType();
493 unsigned Size = VecTy->getNumElements();
515void SPIRVAsmPrinter::outputExecutionModeFromMDNode(
516 MCRegister
Reg, MDNode *Node, SPIRV::ExecutionMode::ExecutionMode EM,
517 unsigned ExpectMDOps, int64_t DefVal) {
525 unsigned NodeSz =
Node->getNumOperands();
526 if (ExpectMDOps > 0 && NodeSz < ExpectMDOps)
527 for (
unsigned i = NodeSz; i < ExpectMDOps; ++i)
532void SPIRVAsmPrinter::outputExecutionModeFromNumthreadsAttribute(
534 SPIRV::ExecutionMode::ExecutionMode EM) {
535 assert(Attr.
isValid() &&
"Function called with an invalid attribute.");
544 assert(NumThreads.size() == 3 &&
"invalid numthreads");
545 for (uint32_t i = 0; i < 3; ++i) {
547 [[maybe_unused]]
bool Result = NumThreads[i].getAsInteger(10,
V);
548 assert(!Result &&
"Failed to parse numthreads");
555void SPIRVAsmPrinter::emitSimpleExecutionMode(
556 MCRegister
Reg, SPIRV::ExecutionMode::ExecutionMode EM) {
564void SPIRVAsmPrinter::outputExecutionModeFromEnableMaximalReconvergenceAttr(
565 const MCRegister &
Reg,
const SPIRVSubtarget &ST) {
566 assert(
ST.canUseExtension(SPIRV::Extension::SPV_KHR_maximal_reconvergence) &&
567 "Function called when SPV_KHR_maximal_reconvergence is not enabled.");
569 emitSimpleExecutionMode(
Reg, SPIRV::ExecutionMode::MaximallyReconvergesKHR);
572void SPIRVAsmPrinter::outputExecutionMode(
const Module &M) {
573 NamedMDNode *
Node =
M.getNamedMetadata(
"spirv.ExecutionMode");
575 for (
unsigned i = 0; i <
Node->getNumOperands(); i++) {
582 if (EM == SPIRV::ExecutionMode::ArithmeticPoisonKHR)
588 if (EM == SPIRV::ExecutionMode::FPFastMathDefault ||
589 EM == SPIRV::ExecutionMode::ContractionOff ||
590 EM == SPIRV::ExecutionMode::SignedZeroInfNanPreserve)
599 outputFPFastMathDefaultInfo();
601 for (
auto FI =
M.begin(),
E =
M.end(); FI !=
E; ++FI) {
607 MCRegister FReg = MAI->getGlobalObjReg(&
F);
616 emitSimpleExecutionMode(FReg, SPIRV::ExecutionMode::OriginUpperLeft);
619 if (MDNode *Node =
F.getMetadata(
"reqd_work_group_size"))
620 outputExecutionModeFromMDNode(FReg, Node, SPIRV::ExecutionMode::LocalSize,
623 outputExecutionModeFromNumthreadsAttribute(
624 FReg, Attr, SPIRV::ExecutionMode::LocalSize);
625 if (
Attribute Attr =
F.getFnAttribute(
"enable-maximal-reconvergence");
627 outputExecutionModeFromEnableMaximalReconvergenceAttr(FReg, *ST);
629 if (MDNode *Node =
F.getMetadata(
"work_group_size_hint"))
630 outputExecutionModeFromMDNode(FReg, Node,
631 SPIRV::ExecutionMode::LocalSizeHint, 3, 1);
632 if (MDNode *Node =
F.getMetadata(
"reqd_sub_group_size"))
633 outputExecutionModeFromMDNode(FReg, Node,
634 SPIRV::ExecutionMode::SubgroupSize, 0, 0);
635 if (MDNode *Node =
F.getMetadata(
"intel_reqd_sub_group_size"))
636 outputExecutionModeFromMDNode(FReg, Node,
637 SPIRV::ExecutionMode::SubgroupSize, 0, 0);
638 if (MDNode *Node =
F.getMetadata(
"max_work_group_size")) {
639 if (ST->
canUseExtension(SPIRV::Extension::SPV_INTEL_kernel_attributes))
640 outputExecutionModeFromMDNode(
641 FReg, Node, SPIRV::ExecutionMode::MaxWorkgroupSizeINTEL, 3, 1);
643 if (MDNode *Node =
F.getMetadata(
"vec_type_hint")) {
647 unsigned EM =
static_cast<unsigned>(SPIRV::ExecutionMode::VecTypeHint);
656 SPIRV::Capability::PoisonFreezeKHR)) {
657 emitSimpleExecutionMode(FReg, SPIRV::ExecutionMode::ArithmeticPoisonKHR);
662 bool EmitContractionOff =
663 ST->
isKernel() && !
M.getNamedMetadata(
"spirv.ExecutionMode") &&
664 FPContract != SPIRVFPContractMode::Fast &&
665 (FPContract == SPIRVFPContractMode::Off ||
666 !
M.getNamedMetadata(
"opencl.enable.FP_CONTRACT"));
667 if (EmitContractionOff) {
685 std::vector<const MachineInstr *> SPIRVFloatTypes;
686 const MachineInstr *ConstZeroInt32 =
nullptr;
687 for (
const MachineInstr *
MI :
688 MAI->getMSInstrs(SPIRV::MB_TypeConstVars)) {
692 if (OpCode == SPIRV::OpTypeFloat) {
694 const unsigned OpTypeFloatSize =
MI->getOperand(1).getImm();
695 if (OpTypeFloatSize != 16 && OpTypeFloatSize != 32 &&
696 OpTypeFloatSize != 64) {
699 SPIRVFloatTypes.push_back(
MI);
703 if (OpCode == SPIRV::OpConstantNull) {
707 bool IsInt32Ty = TypeMI &&
708 TypeMI->
getOpcode() == SPIRV::OpTypeInt &&
721 for (
const MachineInstr *
MI : SPIRVFloatTypes) {
723 Inst.
setOpcode(SPIRV::OpExecutionModeId);
726 static_cast<unsigned>(SPIRV::ExecutionMode::FPFastMathDefault);
730 MAI->getRegisterAlias(MF,
MI->getOperand(0).getReg());
732 assert(ConstZeroInt32 &&
"There should be a constant zero.");
733 MCRegister ConstReg = MAI->getRegisterAlias(
739 emitSimpleExecutionMode(FReg, SPIRV::ExecutionMode::ContractionOff);
745void SPIRVAsmPrinter::outputAnnotations(
const Module &M) {
746 outputModuleSection(SPIRV::MB_Annotations);
748 if (
const GlobalVariable *
V =
M.getNamedGlobal(
"llvm.global.annotations")) {
756 MCRegister
Reg = GO ? MAI->getGlobalObjReg(GO) : MCRegister();
759 raw_string_ostream OS(DiagMsg);
760 AnnotatedVar->
print(OS);
761 DiagMsg =
"Unsupported value in llvm.global.annotations: " + DiagMsg;
769 StringRef AnnotationString;
770 [[maybe_unused]]
bool Success =
776 unsigned Dec =
static_cast<unsigned>(SPIRV::Decoration::UserSemantic);
784void SPIRVAsmPrinter::outputFPFastMathDefaultInfo() {
787 std::vector<const MachineInstr *> SPIRVFloatTypes;
789 DenseMap<int, const MachineInstr *>
ConstMap;
790 for (
const MachineInstr *
MI : MAI->getMSInstrs(SPIRV::MB_TypeConstVars)) {
793 if (OpCode != SPIRV::OpTypeFloat && OpCode != SPIRV::OpConstantI &&
794 OpCode != SPIRV::OpConstantNull)
798 if (OpCode == SPIRV::OpTypeFloat) {
799 SPIRVFloatTypes.push_back(
MI);
804 if (!TypeMI || TypeMI->
getOpcode() != SPIRV::OpTypeInt ||
808 if (OpCode == SPIRV::OpConstantI)
815 for (
const auto &[Func, FPFastMathDefaultInfoVec] :
816 MAI->FPFastMathDefaultInfoMap) {
817 if (FPFastMathDefaultInfoVec.empty())
820 for (
const MachineInstr *
MI : SPIRVFloatTypes) {
821 unsigned OpTypeFloatSize =
MI->getOperand(1).getImm();
824 assert(Index < FPFastMathDefaultInfoVec.size() &&
825 "Index out of bounds for FPFastMathDefaultInfoVec");
826 const auto &FPFastMathDefaultInfo = FPFastMathDefaultInfoVec[
Index];
827 assert(FPFastMathDefaultInfo.Ty &&
828 "Expected target type for FPFastMathDefaultInfo");
829 assert(FPFastMathDefaultInfo.Ty->getScalarSizeInBits() ==
831 "Mismatched float type size");
833 Inst.
setOpcode(SPIRV::OpExecutionModeId);
834 MCRegister FuncReg = MAI->getGlobalObjReg(Func);
840 MAI->getRegisterAlias(
MI->getMF(),
MI->getOperand(0).getReg());
842 unsigned Flags = FPFastMathDefaultInfo.FastMathFlags;
843 if (FPFastMathDefaultInfo.ContractionOff &&
844 (Flags & SPIRV::FPFastMathMode::AllowContract))
846 "Conflicting FPFastMathFlags: ContractionOff and AllowContract");
848 if (FPFastMathDefaultInfo.SignedZeroInfNanPreserve &&
850 (SPIRV::FPFastMathMode::NotNaN | SPIRV::FPFastMathMode::NotInf |
851 SPIRV::FPFastMathMode::NSZ))) {
852 if (FPFastMathDefaultInfo.FPFastMathDefault)
854 "SignedZeroInfNanPreserve but at least one of "
855 "NotNaN/NotInf/NSZ is enabled.");
859 if (Flags == SPIRV::FPFastMathMode::None &&
860 !FPFastMathDefaultInfo.ContractionOff &&
861 !FPFastMathDefaultInfo.SignedZeroInfNanPreserve &&
862 !FPFastMathDefaultInfo.FPFastMathDefault)
869 "Mode operand of FPFastMathDefault execution mode.");
870 const MachineInstr *ConstMI = It->second;
871 MCRegister ConstReg = MAI->getRegisterAlias(
879void SPIRVAsmPrinter::outputModuleSections() {
880 const Module *
M = MMI->getModule();
882 ST =
static_cast<const SPIRVTargetMachine &
>(TM).getSubtargetImpl();
885 assert(ST &&
TII && MAI && M &&
"Module analysis is required");
887 if (!AuxDataHandler &&
889 AuxDataHandler = std::make_unique<SPIRVAuxDataHandler>(*
this, *M);
896 AuxDataHandler->prepareModuleOutput(*ST, *MAI);
901 outputGlobalRequirements();
903 outputOpExtInstImports(*M);
905 outputOpMemoryModel();
910 outputExecutionMode(*M);
913 outputDebugSourceAndStrings(*M);
915 outputModuleSection(SPIRV::MB_DebugNames);
916 for (
const auto &[
Reg, Name] : MAI->MBBNames) {
924 outputModuleSection(SPIRV::MB_DebugModuleProcessed);
927 outputModuleSection(SPIRV::MB_AliasingInsts);
929 outputAnnotations(*M);
934 outputModuleSection(SPIRV::MB_TypeConstVars);
941 AuxDataHandler->emitAuxData(*MAI);
943 outputExtFuncDecls();
948bool SPIRVAsmPrinter::doInitialization(
Module &M) {
949 ModuleSectionsEmitted =
false;
950 if (!
M.getModuleInlineAsm().empty()) {
951 M.getContext().emitError(
952 "SPIR-V does not support module-level inline assembly");
953 M.removeModuleInlineAsm();
958 if (
M.getNamedMetadata(
"llvm.dbg.cu")) {
959 auto Handler = std::make_unique<SPIRVNonSemanticDebugHandler>(*
this);
960 NSDebugHandler = Handler.get();
961 addAsmPrinterHandler(std::move(Handler));
967char SPIRVAsmPrinter::ID = 0;
974LLVMInitializeSPIRVAsmPrinter() {
982 SPIRVAsmPrinter &
AsmPrinter =
static_cast<SPIRVAsmPrinter &
>(
992 SPIRVAsmPrinter &
AsmPrinter =
static_cast<SPIRVAsmPrinter &
>(
1007 SPIRVAsmPrinter &
AsmPrinter =
static_cast<SPIRVAsmPrinter &
>(
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static const Function * getParent(const Value *V)
static GCRegistry::Add< ShadowStackGC > C("shadow-stack", "Very portable GC for uncooperative code generators")
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
#define LLVM_EXTERNAL_VISIBILITY
This file defines the DenseMap class.
const HexagonInstrInfo * TII
This header defines various interfaces for pass management in LLVM.
Machine Check Debug Module
This file declares the MachineConstantPool class which is an abstract constant pool to keep track of ...
ModuleAnalysisManager MAM
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
MachineRegisterInfo & MRI
static void addOpsFromMDNode(MDNode *MDN, MCInst &Inst, SPIRV::ModuleAnalysisInfo *MAI)
static bool isFuncOrHeaderInstr(const MachineInstr *MI, const SPIRVInstrInfo *TII)
static unsigned encodeVecTypeHint(Type *Ty)
#define SPIRV_BACKEND_SERVICE_FUN_NAME
static bool printOperand(raw_ostream &OS, const SelectionDAG *G, const SDValue Value)
std::unique_ptr< MCStreamer > && Streamer
static TableGen::Emitter::Opt Y("gen-skeleton-entry", EmitSkeleton, "Generate example skeleton entry")
PassT::Result & getResult(IRUnitT &IR, ExtraArgTs... ExtraArgs)
Get the result of an analysis pass for a given IR unit.
Represent the analysis usage information of a pass.
AnalysisUsage & addRequired()
AnalysisUsage & addPreserved()
Add the specified Pass class to the set of analyses preserved by this pass.
This class is intended to be used as a driving class for all asm writers.
bool doInitialization(Module &M) override
Set up the AsmPrinter when we are working on a new module.
void getAnalysisUsage(AnalysisUsage &AU) const override
Record analysis usage.
bool doFinalization(Module &M) override
Shut down the asmprinter.
bool runOnMachineFunction(MachineFunction &MF) override
Emit the specified function out to the OutStreamer.
Functions, function parameters, and return types can have attributes to indicate how they should be t...
LLVM_ABI bool getValueAsBool() const
Return the attribute's value as a boolean.
LLVM_ABI StringRef getValueAsString() const
Return the attribute's value as a string.
bool isValid() const
Return true if the attribute is any kind of attribute.
This is the shared class of boolean and integer constants.
This is an important base class in LLVM.
iterator find(const_arg_type_t< KeyT > Val)
Class to represent fixed width SIMD vectors.
static StringRef dropLLVMManglingEscape(StringRef Name)
If the given string begins with the GlobalValue name mangling escape character '\1',...
Module * getParent()
Get the module that this global value is contained inside of...
Class to represent integer types.
Instances of this class represent a single low-level machine instruction.
void addOperand(const MCOperand Op)
void setOpcode(unsigned Op)
static MCOperand createReg(MCRegister Reg)
static MCOperand createImm(int64_t Val)
Wrapper class representing physical registers. Should be passed by value.
constexpr bool isValid() const
StringRef getName() const
getName - Get the symbol name.
ArrayRef< MDOperand > operands() const
Tracking metadata reference owned by Metadata.
LLVM_ABI MCSymbol * getSymbol() const
Return the MCSymbol for this basic block.
int getNumber() const
MachineBasicBlocks are uniquely numbered at the function level, unless they're not in a MachineFuncti...
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
Function & getFunction()
Return the LLVM function that this machine code represents.
Representation of each machine instruction.
unsigned getOpcode() const
Returns the opcode of this MachineInstr.
LLVM_ABI const MachineFunction * getMF() const
Return the function that contains the basic block that this instruction belongs to.
const MachineOperand & getOperand(unsigned i) const
const GlobalValue * getGlobal() const
MachineBasicBlock * getMBB() const
const BlockAddress * getBlockAddress() const
MachineOperandType getType() const
getType - Returns the MachineOperandType for this operand.
const char * getSymbolName() const
Register getReg() const
getReg - Returns the register number.
const ConstantFP * getFPImm() const
@ MO_Immediate
Immediate operand.
@ MO_ConstantPoolIndex
Address of indexed Constant in Constant Pool.
@ MO_GlobalAddress
Address of a global value.
@ MO_BlockAddress
Address of a basic block.
@ MO_MachineBasicBlock
MachineBasicBlock reference.
@ MO_Register
Register operand.
@ MO_ExternalSymbol
Name of external global symbol.
@ MO_JumpTableIndex
Address of indexed Jump Table for switch.
@ MO_FPImmediate
Floating-point immediate operand.
LLVM_ABI LLVM_READONLY MachineInstr * getVRegDef(Register Reg) const
getVRegDef - Return the machine instr that defines the specified virtual register or null if none is ...
const MachineFunction & getMF() const
A Module instance is used to store all the information related to an LLVM module.
A set of analyses that are preserved following a run of a transformation pass.
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
constexpr bool isValid() const
PreservedAnalyses run(Module &M, ModuleAnalysisManager &MAM)
PreservedAnalyses run(Module &M, ModuleAnalysisManager &MAM)
PreservedAnalyses run(MachineFunction &MF, MachineFunctionAnalysisManager &MFAM)
void setBound(unsigned V)
static const char * getRegisterName(MCRegister Reg)
void lower(const MachineInstr *MI, MCInst &OutMI, SPIRV::ModuleAnalysisInfo *MAI) const
AsmPrinter handler that emits NonSemantic.Shader.DebugInfo.100 (NSDI) instructions for the SPIR-V bac...
void emitNonSemanticDebugStrings(SPIRV::ModuleAnalysisInfo &MAI)
Emit OpString instructions for all NSDI file paths and basic type names into the debug section (secti...
void emitNonSemanticGlobalDebugInfo(SPIRV::ModuleAnalysisInfo &MAI)
Emit module-scope NSDI instructions (DebugSource, DebugCompilationUnit, DebugTypeBasic,...
void prepareModuleOutput(const SPIRVSubtarget &ST, SPIRV::ModuleAnalysisInfo &MAI)
Add SPV_KHR_non_semantic_info extension and NonSemantic.Shader.DebugInfo.100 ext inst set entry to MA...
void notifyEntryLabelEmitted(const MachineFunction &MF)
Called after the synthesized entry OpLabel has been emitted.
const SPIRVInstrInfo * getInstrInfo() const override
bool isAtLeastSPIRVVer(VersionTuple VerToCompareTo) const
SPIRVGlobalRegistry * getSPIRVGlobalRegistry() const
const SPIRVOptions & getCLOpts() const
VersionTuple getSPIRVVersion() const
unsigned getBound() const
bool canUseExtension(SPIRV::Extension::Extension E) const
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.
bool contains(ConstPtrType Ptr) const
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements.
Represent a constant reference to a string, i.e.
std::pair< StringRef, StringRef > split(char Separator) const
Split into two substrings around the first occurrence of a separator character.
Primary interface to the complete machine description for the target machine.
The instances of the Type class are immutable: once they are created, they are never changed.
Value * getOperand(unsigned i) const
LLVM_ABI void print(raw_ostream &O, bool IsForDebug=false) const
Implement operator<< on Value.
LLVM_ABI const Value * stripPointerCasts() const
Strip off pointer casts, all-zero GEPs and address space casts.
unsigned getMajor() const
Retrieve the major version number.
std::optional< unsigned > getMinor() const
Retrieve the minor version number, if provided.
std::pair< iterator, bool > insert(const ValueT &V)
This class implements an extremely fast bulk output stream that can only output to a stream.
Pass manager infrastructure for declaring and invalidating analyses.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
NodeAddr< NodeBase * > Node
unsigned getOpcode(const VPValue *V)
Return the instruction opcode for the recipe defining V or 0 for unsupported recipes and VPValues not...
This is an optimization pass for GlobalISel generic memory operations.
OuterAnalysisManagerProxy< ModuleAnalysisManager, MachineFunction > ModuleAnalysisManagerMachineFunctionProxy
Provide the ModuleAnalysisManager to Function proxy.
void addStringImm(StringRef Str, MCInst &Inst)
Target & getTheSPIRV32Target()
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
DenseMap< Value *, Constant * > ConstMap
LLVM_ABI bool getConstantStringInfo(const Value *V, StringRef &Str, bool TrimAtNul=true)
This function computes the length of a null-terminated C string pointed to by V.
std::string getExtInstSetName(SPIRV::InstructionSet::InstructionSet Set)
AnalysisManager< MachineFunction > MachineFunctionAnalysisManager
RelativeUniformCounterPtr ValuesPtrExpr VTableAddr Value
MachineInstr * getImm(const MachineOperand &MO, const MachineRegisterInfo *MRI)
LLVM_ABI void setupModuleAsmPrinter(Module &M, ModuleAnalysisManager &MAM, AsmPrinter &AsmPrinter)
LLVM_ABI void report_fatal_error(Error Err, bool gen_crash_diag=true)
class LLVM_GSL_OWNER SmallVector
Forward declaration of SmallVector so that calculateSmallVectorDefaultInlinedElements can reference s...
std::string getSymbolicOperandMnemonic(SPIRV::OperandCategory::OperandCategory Category, int32_t Value)
bool isEntryPoint(const Function &F)
Target & getTheSPIRV64Target()
Target & getTheSPIRVLogicalTarget()
DWARFExpression::Operation Op
LLVM_ABI void setupMachineFunctionAsmPrinter(MachineFunctionAnalysisManager &MFAM, MachineFunction &MF, AsmPrinter &AsmPrinter)
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 is_contained(R &&Range, const E &Element)
Returns true if Element is found in Range.
bool spirvPreserveAuxData(const SPIRVOptions &CLOpts, const Triple &TT)
AnalysisManager< Module > ModuleAnalysisManager
Convenience typedef for the Module analysis manager.
RegisterAsmPrinter - Helper template for registering a target specific assembly printer,...
static size_t computeFPFastMathDefaultInfoVecIndex(size_t BitWidth)
MCRegister getGlobalObjReg(const GlobalObject *GO)