52#define DEBUG_TYPE "asm-printer"
61 std::unique_ptr<MCStreamer>
Streamer)
63 ST(
nullptr),
TII(
nullptr), MAI(
nullptr) {
65 return &getAnalysis<SPIRVModuleAnalysisWrapperPass>().MAI;
69 bool ModuleSectionsEmitted;
73 StringRef getPassName()
const override {
return "SPIRV Assembly Printer"; }
78 void outputMCInst(
MCInst &Inst);
81 void outputGlobalRequirements();
82 void outputEntryPoints();
83 void outputDebugSourceAndStrings(
const Module &M);
84 void outputOpExtInstImports(
const Module &M);
85 void outputOpMemoryModel();
86 void outputOpFunctionEnd();
87 void outputExtFuncDecls();
89 SPIRV::ExecutionMode::ExecutionMode EM,
90 unsigned ExpectMDOps, int64_t DefVal);
91 void outputExecutionModeFromNumthreadsAttribute(
93 SPIRV::ExecutionMode::ExecutionMode EM);
94 void outputExecutionModeFromEnableMaximalReconvergenceAttr(
97 SPIRV::ExecutionMode::ExecutionMode EM);
98 void outputExecutionMode(
const Module &M);
99 void outputAnnotations(
const Module &M);
100 void outputModuleSections();
101 void outputFPFastMathDefaultInfo();
103 return MF->getFunction()
109 void emitFunctionEntryLabel()
override {}
110 void emitFunctionHeader()
override;
111 void emitFunctionBodyStart()
override {}
112 void emitFunctionBodyEnd()
override;
117 void emitEndOfAsmFile(
Module &M)
override;
118 bool doInitialization(
Module &M)
override;
129 std::unique_ptr<SPIRVAuxDataHandler> AuxDataHandler;
133void SPIRVAsmPrinter::getAnalysisUsage(
AnalysisUsage &AU)
const {
140void SPIRVAsmPrinter::emitEndOfAsmFile(
Module &M) {
141 if (!ModuleSectionsEmitted) {
142 outputModuleSections();
143 ModuleSectionsEmitted =
true;
146 ST =
static_cast<const SPIRVTargetMachine &
>(TM).getSubtargetImpl();
154 uint32_t Major = SPIRVVersion.
getMajor();
155 uint32_t Minor = SPIRVVersion.
getMinor().value_or(0);
158 unsigned Bound = 2 * (ST->
getBound() + 1) + NLabels;
159 if (MCAssembler *Asm = OutStreamer->getAssemblerPtr())
160 static_cast<SPIRVObjectWriter &
>(
Asm->getWriter())
161 .setBuildVersion(Major, Minor, Bound);
164void SPIRVAsmPrinter::emitFunctionHeader() {
165 if (!ModuleSectionsEmitted) {
166 outputModuleSections();
167 ModuleSectionsEmitted =
true;
170 ST = &MF->getSubtarget<SPIRVSubtarget>();
174 if (isVerbose() && !isHidden()) {
175 OutStreamer->getCommentOS()
176 <<
"-- Begin function "
180 auto Section = getObjFileLowering().SectionForGlobal(&
F, TM);
181 MF->setSection(Section);
187 for (
auto &Handler : Handlers) {
188 Handler->beginFunction(MF);
189 Handler->beginBasicBlockSection(MF->front());
193void SPIRVAsmPrinter::outputOpFunctionEnd() {
194 MCInst FunctionEndInst;
195 FunctionEndInst.
setOpcode(SPIRV::OpFunctionEnd);
196 outputMCInst(FunctionEndInst);
199void SPIRVAsmPrinter::emitFunctionBodyEnd() {
201 outputOpFunctionEnd();
204void SPIRVAsmPrinter::emitOpLabel(
const MachineBasicBlock &
MBB) {
212 outputMCInst(LabelInst);
217void SPIRVAsmPrinter::emitBasicBlockStart(
const MachineBasicBlock &
MBB) {
225 for (
const MachineInstr &
MI :
MBB)
226 if (
MI.getOpcode() == SPIRV::OpFunction)
234void SPIRVAsmPrinter::printOperand(
const MachineInstr *
MI,
int OpNum,
236 const MachineOperand &MO =
MI->getOperand(OpNum);
276bool SPIRVAsmPrinter::PrintAsmOperand(
const MachineInstr *
MI,
unsigned OpNo,
277 const char *ExtraCode, raw_ostream &O) {
278 if (ExtraCode && ExtraCode[0])
287 return TII->isHeaderInstr(*
MI) ||
MI->getOpcode() == SPIRV::OpFunction ||
288 MI->getOpcode() == SPIRV::OpFunctionParameter;
291void SPIRVAsmPrinter::outputMCInst(MCInst &Inst) {
292 OutStreamer->emitInstruction(Inst, *OutContext.getSubtargetInfo());
295void SPIRVAsmPrinter::outputInstruction(
const MachineInstr *
MI) {
296 SPIRVMCInstLower MCInstLowering;
298 MCInstLowering.
lower(
MI, TmpInst, MAI);
299 outputMCInst(TmpInst);
302void SPIRVAsmPrinter::emitInstruction(
const MachineInstr *
MI) {
303 SPIRV_MC::verifyInstructionPredicates(
MI->getOpcode(),
304 getSubtargetInfo().getFeatureBits());
306 bool InstructionEmitted = !MAI->getSkipEmission(
MI);
307 if (InstructionEmitted)
308 outputInstruction(
MI);
311 const MachineInstr *NextMI =
MI->getNextNode();
312 bool BlockHasLabel = LabeledMBB.
contains(
MI->getParent());
314 bool IsNextInstructionFunctionPreamble =
316 bool ShouldEmitEntryLabel = !BlockHasLabel && IsFunctionPreambleInstruction &&
317 !IsNextInstructionFunctionPreamble;
318 if (ShouldEmitEntryLabel) {
319 assert(
MI->getParent()->getNumber() == MF->front().getNumber() &&
320 "OpFunction is not in the front MBB of MF");
321 emitOpLabel(*
MI->getParent());
322 if (NSDebugHandler && !isHidden())
327void SPIRVAsmPrinter::outputModuleSection(SPIRV::ModuleSectionType MSType) {
328 for (
const MachineInstr *
MI : MAI->getMSInstrs(MSType))
329 outputInstruction(
MI);
332void SPIRVAsmPrinter::outputDebugSourceAndStrings(
const Module &M) {
334 for (
auto &Str : MAI->SrcExt) {
336 Inst.
setOpcode(SPIRV::OpSourceExtension);
341 outputModuleSection(SPIRV::MB_DebugStrings);
357 AuxDataHandler->emitAuxDataStrings(*MAI);
360void SPIRVAsmPrinter::outputOpExtInstImports(
const Module &M) {
361 for (
auto &CU : MAI->ExtInstSetMap) {
362 unsigned Set = CU.first;
363 MCRegister
Reg = CU.second;
368 static_cast<SPIRV::InstructionSet::InstructionSet
>(Set)),
374void SPIRVAsmPrinter::outputOpMemoryModel() {
386void SPIRVAsmPrinter::outputEntryPoints() {
388 DenseSet<MCRegister> InterfaceIDs;
389 for (
const MachineInstr *
MI : MAI->GlobalVarList) {
390 assert(
MI->getOpcode() == SPIRV::OpVariable ||
391 MI->getOpcode() == SPIRV::OpUntypedVariableKHR);
392 auto SC =
static_cast<SPIRV::StorageClass::StorageClass
>(
399 SC == SPIRV::StorageClass::Input || SC == SPIRV::StorageClass::Output) {
401 MCRegister
Reg = MAI->getRegisterAlias(MF,
MI->getOperand(0).getReg());
407 for (
const MachineInstr *
MI : MAI->getMSInstrs(SPIRV::MB_EntryPoints)) {
408 SPIRVMCInstLower MCInstLowering;
410 MCInstLowering.
lower(
MI, TmpInst, MAI);
411 for (MCRegister
Reg : InterfaceIDs) {
415 outputMCInst(TmpInst);
420void SPIRVAsmPrinter::outputGlobalRequirements() {
422 MAI->Reqs.checkSatisfiable(*ST);
424 for (
const auto &Cap : MAI->Reqs.getMinimalCapabilities()) {
432 for (
const auto &Ext : MAI->Reqs.getExtensions()) {
436 SPIRV::OperandCategory::ExtensionOperand, Ext),
443void SPIRVAsmPrinter::outputExtFuncDecls() {
445 auto I = MAI->getMSInstrs(SPIRV::MB_ExtFuncDecls).begin(),
446 E = MAI->getMSInstrs(SPIRV::MB_ExtFuncDecls).end();
447 for (;
I !=
E; ++
I) {
448 outputInstruction(*
I);
449 if ((
I + 1) ==
E || (*(
I + 1))->
getOpcode() == SPIRV::OpFunction)
450 outputOpFunctionEnd();
460 if (Ty->isDoubleTy())
463 switch (IntTy->getIntegerBitWidth()) {
477 Type *EleTy = VecTy->getElementType();
478 unsigned Size = VecTy->getNumElements();
500void SPIRVAsmPrinter::outputExecutionModeFromMDNode(
501 MCRegister
Reg, MDNode *Node, SPIRV::ExecutionMode::ExecutionMode EM,
502 unsigned ExpectMDOps, int64_t DefVal) {
510 unsigned NodeSz =
Node->getNumOperands();
511 if (ExpectMDOps > 0 && NodeSz < ExpectMDOps)
512 for (
unsigned i = NodeSz; i < ExpectMDOps; ++i)
517void SPIRVAsmPrinter::outputExecutionModeFromNumthreadsAttribute(
519 SPIRV::ExecutionMode::ExecutionMode EM) {
520 assert(Attr.
isValid() &&
"Function called with an invalid attribute.");
536void SPIRVAsmPrinter::emitSimpleExecutionMode(
537 MCRegister
Reg, SPIRV::ExecutionMode::ExecutionMode EM) {
545void SPIRVAsmPrinter::outputExecutionModeFromEnableMaximalReconvergenceAttr(
546 const MCRegister &
Reg,
const SPIRVSubtarget &ST) {
547 assert(
ST.canUseExtension(SPIRV::Extension::SPV_KHR_maximal_reconvergence) &&
548 "Function called when SPV_KHR_maximal_reconvergence is not enabled.");
550 emitSimpleExecutionMode(
Reg, SPIRV::ExecutionMode::MaximallyReconvergesKHR);
553void SPIRVAsmPrinter::outputExecutionMode(
const Module &M) {
554 NamedMDNode *
Node =
M.getNamedMetadata(
"spirv.ExecutionMode");
556 for (
unsigned i = 0; i <
Node->getNumOperands(); i++) {
563 if (EM == SPIRV::ExecutionMode::ArithmeticPoisonKHR)
569 if (EM == SPIRV::ExecutionMode::FPFastMathDefault ||
570 EM == SPIRV::ExecutionMode::ContractionOff ||
571 EM == SPIRV::ExecutionMode::SignedZeroInfNanPreserve)
580 outputFPFastMathDefaultInfo();
582 for (
auto FI =
M.begin(),
E =
M.end(); FI !=
E; ++FI) {
588 MCRegister FReg = MAI->getGlobalObjReg(&
F);
597 emitSimpleExecutionMode(FReg, SPIRV::ExecutionMode::OriginUpperLeft);
602 SPIRV::Capability::StencilExportEXT))
603 emitSimpleExecutionMode(FReg,
604 SPIRV::ExecutionMode::StencilRefReplacingEXT);
607 if (MDNode *Node =
F.getMetadata(
"reqd_work_group_size"))
608 outputExecutionModeFromMDNode(FReg, Node, SPIRV::ExecutionMode::LocalSize,
611 outputExecutionModeFromNumthreadsAttribute(
612 FReg, Attr, SPIRV::ExecutionMode::LocalSize);
613 if (
Attribute Attr =
F.getFnAttribute(
"enable-maximal-reconvergence");
615 outputExecutionModeFromEnableMaximalReconvergenceAttr(FReg, *ST);
617 if (MDNode *Node =
F.getMetadata(
"work_group_size_hint"))
618 outputExecutionModeFromMDNode(FReg, Node,
619 SPIRV::ExecutionMode::LocalSizeHint, 3, 1);
620 if (MDNode *Node =
F.getMetadata(
"reqd_sub_group_size"))
621 outputExecutionModeFromMDNode(FReg, Node,
622 SPIRV::ExecutionMode::SubgroupSize, 0, 0);
623 if (MDNode *Node =
F.getMetadata(
"intel_reqd_sub_group_size"))
624 outputExecutionModeFromMDNode(FReg, Node,
625 SPIRV::ExecutionMode::SubgroupSize, 0, 0);
626 if (MDNode *Node =
F.getMetadata(
"max_work_group_size")) {
627 if (ST->
canUseExtension(SPIRV::Extension::SPV_INTEL_kernel_attributes))
628 outputExecutionModeFromMDNode(
629 FReg, Node, SPIRV::ExecutionMode::MaxWorkgroupSizeINTEL, 3, 1);
631 if (MDNode *Node =
F.getMetadata(
"vec_type_hint")) {
635 unsigned EM =
static_cast<unsigned>(SPIRV::ExecutionMode::VecTypeHint);
644 SPIRV::Capability::PoisonFreezeKHR)) {
645 emitSimpleExecutionMode(FReg, SPIRV::ExecutionMode::ArithmeticPoisonKHR);
650 bool EmitContractionOff =
651 ST->
isKernel() && !
M.getNamedMetadata(
"spirv.ExecutionMode") &&
652 FPContract != SPIRVFPContractMode::Fast &&
653 (FPContract == SPIRVFPContractMode::Off ||
654 !
M.getNamedMetadata(
"opencl.enable.FP_CONTRACT"));
655 if (EmitContractionOff) {
673 std::vector<const MachineInstr *> SPIRVFloatTypes;
674 const MachineInstr *ConstZeroInt32 =
nullptr;
675 for (
const MachineInstr *
MI :
676 MAI->getMSInstrs(SPIRV::MB_TypeConstVars)) {
680 if (OpCode == SPIRV::OpTypeFloat) {
682 const unsigned OpTypeFloatSize =
MI->getOperand(1).getImm();
683 if (OpTypeFloatSize != 16 && OpTypeFloatSize != 32 &&
684 OpTypeFloatSize != 64) {
687 SPIRVFloatTypes.push_back(
MI);
691 if (OpCode == SPIRV::OpConstantNull) {
695 bool IsInt32Ty = TypeMI &&
696 TypeMI->
getOpcode() == SPIRV::OpTypeInt &&
709 for (
const MachineInstr *
MI : SPIRVFloatTypes) {
711 Inst.
setOpcode(SPIRV::OpExecutionModeId);
714 static_cast<unsigned>(SPIRV::ExecutionMode::FPFastMathDefault);
718 MAI->getRegisterAlias(MF,
MI->getOperand(0).getReg());
720 assert(ConstZeroInt32 &&
"There should be a constant zero.");
721 MCRegister ConstReg = MAI->getRegisterAlias(
727 emitSimpleExecutionMode(FReg, SPIRV::ExecutionMode::ContractionOff);
733void SPIRVAsmPrinter::outputAnnotations(
const Module &M) {
734 outputModuleSection(SPIRV::MB_Annotations);
736 if (
const GlobalVariable *
V =
M.getNamedGlobal(
"llvm.global.annotations")) {
744 MCRegister
Reg = GO ? MAI->getGlobalObjReg(GO) : MCRegister();
747 raw_string_ostream OS(DiagMsg);
748 AnnotatedVar->
print(OS);
749 DiagMsg =
"Unsupported value in llvm.global.annotations: " + DiagMsg;
757 StringRef AnnotationString;
758 [[maybe_unused]]
bool Success =
764 unsigned Dec =
static_cast<unsigned>(SPIRV::Decoration::UserSemantic);
772void SPIRVAsmPrinter::outputFPFastMathDefaultInfo() {
775 std::vector<const MachineInstr *> SPIRVFloatTypes;
777 DenseMap<int, const MachineInstr *>
ConstMap;
778 for (
const MachineInstr *
MI : MAI->getMSInstrs(SPIRV::MB_TypeConstVars)) {
781 if (OpCode != SPIRV::OpTypeFloat && OpCode != SPIRV::OpConstantI &&
782 OpCode != SPIRV::OpConstantNull)
786 if (OpCode == SPIRV::OpTypeFloat) {
787 SPIRVFloatTypes.push_back(
MI);
792 if (!TypeMI || TypeMI->
getOpcode() != SPIRV::OpTypeInt ||
796 if (OpCode == SPIRV::OpConstantI)
803 for (
const auto &[Func, FPFastMathDefaultInfoVec] :
804 MAI->FPFastMathDefaultInfoMap) {
805 if (FPFastMathDefaultInfoVec.empty())
808 for (
const MachineInstr *
MI : SPIRVFloatTypes) {
809 unsigned OpTypeFloatSize =
MI->getOperand(1).getImm();
812 assert(Index < FPFastMathDefaultInfoVec.size() &&
813 "Index out of bounds for FPFastMathDefaultInfoVec");
814 const auto &FPFastMathDefaultInfo = FPFastMathDefaultInfoVec[
Index];
815 assert(FPFastMathDefaultInfo.Ty &&
816 "Expected target type for FPFastMathDefaultInfo");
817 assert(FPFastMathDefaultInfo.Ty->getScalarSizeInBits() ==
819 "Mismatched float type size");
821 Inst.
setOpcode(SPIRV::OpExecutionModeId);
822 MCRegister FuncReg = MAI->getGlobalObjReg(Func);
828 MAI->getRegisterAlias(
MI->getMF(),
MI->getOperand(0).getReg());
830 unsigned Flags = FPFastMathDefaultInfo.FastMathFlags;
831 if (FPFastMathDefaultInfo.ContractionOff &&
832 (Flags & SPIRV::FPFastMathMode::AllowContract))
834 "Conflicting FPFastMathFlags: ContractionOff and AllowContract");
836 if (FPFastMathDefaultInfo.SignedZeroInfNanPreserve &&
838 (SPIRV::FPFastMathMode::NotNaN | SPIRV::FPFastMathMode::NotInf |
839 SPIRV::FPFastMathMode::NSZ))) {
840 if (FPFastMathDefaultInfo.FPFastMathDefault)
842 "SignedZeroInfNanPreserve but at least one of "
843 "NotNaN/NotInf/NSZ is enabled.");
847 if (Flags == SPIRV::FPFastMathMode::None &&
848 !FPFastMathDefaultInfo.ContractionOff &&
849 !FPFastMathDefaultInfo.SignedZeroInfNanPreserve &&
850 !FPFastMathDefaultInfo.FPFastMathDefault)
857 "Mode operand of FPFastMathDefault execution mode.");
858 const MachineInstr *ConstMI = It->second;
859 MCRegister ConstReg = MAI->getRegisterAlias(
867void SPIRVAsmPrinter::outputModuleSections() {
868 const Module *
M = MMI->getModule();
870 ST =
static_cast<const SPIRVTargetMachine &
>(TM).getSubtargetImpl();
873 assert(ST &&
TII && MAI && M &&
"Module analysis is required");
875 if (!AuxDataHandler &&
877 AuxDataHandler = std::make_unique<SPIRVAuxDataHandler>(*
this, *M);
884 AuxDataHandler->prepareModuleOutput(*ST, *MAI);
893 outputGlobalRequirements();
895 outputOpExtInstImports(*M);
897 outputOpMemoryModel();
902 outputExecutionMode(*M);
905 outputDebugSourceAndStrings(*M);
907 outputModuleSection(SPIRV::MB_DebugNames);
908 for (
const auto &[
Reg, Name] : MAI->MBBNames) {
916 outputModuleSection(SPIRV::MB_DebugModuleProcessed);
919 outputModuleSection(SPIRV::MB_AliasingInsts);
921 outputAnnotations(*M);
926 outputModuleSection(SPIRV::MB_TypeConstVars);
933 AuxDataHandler->emitAuxData(*MAI);
935 outputExtFuncDecls();
940bool SPIRVAsmPrinter::doInitialization(
Module &M) {
941 ModuleSectionsEmitted =
false;
942 if (!
M.getModuleInlineAsm().empty()) {
943 M.getContext().emitError(
944 "SPIR-V does not support module-level inline assembly");
945 M.removeModuleInlineAsm();
950 if (
M.getNamedMetadata(
"llvm.dbg.cu")) {
951 auto Handler = std::make_unique<SPIRVNonSemanticDebugHandler>(*
this);
952 NSDebugHandler = Handler.get();
953 addAsmPrinterHandler(std::move(Handler));
959char SPIRVAsmPrinter::ID = 0;
966LLVMInitializeSPIRVAsmPrinter() {
974 SPIRVAsmPrinter &
AsmPrinter =
static_cast<SPIRVAsmPrinter &
>(
984 SPIRVAsmPrinter &
AsmPrinter =
static_cast<SPIRVAsmPrinter &
>(
999 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 and target specific virtual registers.
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 emitNonSemanticGlobalDebugInfo(SPIRV::ModuleAnalysisInfo &)
Output the module-scope NSDI built by generateModuleDebugInfo().
void emitNonSemanticDebugStrings(SPIRV::ModuleAnalysisInfo &)
Output the NSDI OpStrings built by generateModuleDebugInfo() into the debug section (section 7 of the...
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 generateModuleDebugInfo(SPIRV::ModuleAnalysisInfo &MAI)
Buffer the module-scope NSDI and add SPV_KHR_relaxed_extended_instruction to MAI if a forward referen...
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.
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.
LLVM_ABI void parseThreadCounts(StringRef Str, unsigned &Count1, unsigned &Count2, unsigned &Count3)
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)
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)