52#define DEBUG_TYPE "asm-printer"
55enum class SPIRVFPContractMode { On, Off,
Fast };
59 cl::desc(
"Override FP contraction policy for SPIR-V kernel entry points"),
62 "Follow IR metadata (default)"),
64 "Force ContractionOff on all kernel entry points"),
66 "Suppress ContractionOff on all kernel entry points")),
75 std::unique_ptr<MCStreamer>
Streamer)
77 ST(
nullptr),
TII(
nullptr), MAI(
nullptr) {}
79 bool ModuleSectionsEmitted;
83 StringRef getPassName()
const override {
return "SPIRV Assembly Printer"; }
88 void outputMCInst(
MCInst &Inst);
91 void outputGlobalRequirements();
92 void outputEntryPoints();
93 void outputDebugSourceAndStrings(
const Module &M);
94 void outputOpExtInstImports(
const Module &M);
95 void outputOpMemoryModel();
96 void outputOpFunctionEnd();
97 void outputExtFuncDecls();
99 SPIRV::ExecutionMode::ExecutionMode EM,
100 unsigned ExpectMDOps, int64_t DefVal);
101 void outputExecutionModeFromNumthreadsAttribute(
103 SPIRV::ExecutionMode::ExecutionMode EM);
104 void outputExecutionModeFromEnableMaximalReconvergenceAttr(
107 SPIRV::ExecutionMode::ExecutionMode EM);
108 void outputExecutionMode(
const Module &M);
109 void outputAnnotations(
const Module &M);
110 void outputModuleSections();
111 void outputFPFastMathDefaultInfo();
113 return MF->getFunction()
119 void emitFunctionEntryLabel()
override {}
120 void emitFunctionHeader()
override;
121 void emitFunctionBodyStart()
override {}
122 void emitFunctionBodyEnd()
override;
127 void emitEndOfAsmFile(
Module &M)
override;
128 bool doInitialization(
Module &M)
override;
138 std::unique_ptr<SPIRVAuxDataHandler> AuxDataHandler;
145void SPIRVAsmPrinter::getAnalysisUsage(
AnalysisUsage &AU)
const {
152void SPIRVAsmPrinter::emitEndOfAsmFile(
Module &M) {
153 if (!ModuleSectionsEmitted) {
154 outputModuleSections();
155 ModuleSectionsEmitted =
true;
158 ST =
static_cast<const SPIRVTargetMachine &
>(TM).getSubtargetImpl();
166 uint32_t Major = SPIRVVersion.
getMajor();
167 uint32_t Minor = SPIRVVersion.
getMinor().value_or(0);
170 unsigned Bound = 2 * (ST->
getBound() + 1) + NLabels;
171 if (MCAssembler *Asm = OutStreamer->getAssemblerPtr())
172 static_cast<SPIRVObjectWriter &
>(
Asm->getWriter())
173 .setBuildVersion(Major, Minor, Bound);
180void SPIRVAsmPrinter::cleanUp(
Module &M) {
182 for (StringRef GVName :
183 {
"llvm.global_ctors",
"llvm.global_dtors",
"llvm.used"}) {
184 if (GlobalVariable *GV =
M.getNamedGlobal(GVName))
189void SPIRVAsmPrinter::emitFunctionHeader() {
190 if (!ModuleSectionsEmitted) {
191 outputModuleSections();
192 ModuleSectionsEmitted =
true;
195 ST = &MF->getSubtarget<SPIRVSubtarget>();
199 if (isVerbose() && !isHidden()) {
200 OutStreamer->getCommentOS()
201 <<
"-- Begin function "
205 auto Section = getObjFileLowering().SectionForGlobal(&
F, TM);
206 MF->setSection(Section);
212 for (
auto &Handler : Handlers) {
213 Handler->beginFunction(MF);
214 Handler->beginBasicBlockSection(MF->front());
218void SPIRVAsmPrinter::outputOpFunctionEnd() {
219 MCInst FunctionEndInst;
220 FunctionEndInst.
setOpcode(SPIRV::OpFunctionEnd);
221 outputMCInst(FunctionEndInst);
224void SPIRVAsmPrinter::emitFunctionBodyEnd() {
226 outputOpFunctionEnd();
229void SPIRVAsmPrinter::emitOpLabel(
const MachineBasicBlock &
MBB) {
237 outputMCInst(LabelInst);
242void SPIRVAsmPrinter::emitBasicBlockStart(
const MachineBasicBlock &
MBB) {
250 for (
const MachineInstr &
MI :
MBB)
251 if (
MI.getOpcode() == SPIRV::OpFunction)
259void SPIRVAsmPrinter::printOperand(
const MachineInstr *
MI,
int OpNum,
261 const MachineOperand &MO =
MI->getOperand(OpNum);
301bool SPIRVAsmPrinter::PrintAsmOperand(
const MachineInstr *
MI,
unsigned OpNo,
302 const char *ExtraCode, raw_ostream &O) {
303 if (ExtraCode && ExtraCode[0])
312 return TII->isHeaderInstr(*
MI) ||
MI->getOpcode() == SPIRV::OpFunction ||
313 MI->getOpcode() == SPIRV::OpFunctionParameter;
316void SPIRVAsmPrinter::outputMCInst(MCInst &Inst) {
317 OutStreamer->emitInstruction(Inst, *OutContext.getSubtargetInfo());
320void SPIRVAsmPrinter::outputInstruction(
const MachineInstr *
MI) {
321 SPIRVMCInstLower MCInstLowering;
323 MCInstLowering.
lower(
MI, TmpInst, MAI);
324 outputMCInst(TmpInst);
327void SPIRVAsmPrinter::emitInstruction(
const MachineInstr *
MI) {
328 SPIRV_MC::verifyInstructionPredicates(
MI->getOpcode(),
329 getSubtargetInfo().getFeatureBits());
331 bool InstructionEmitted = !MAI->getSkipEmission(
MI);
332 if (InstructionEmitted)
333 outputInstruction(
MI);
336 const MachineInstr *NextMI =
MI->getNextNode();
337 bool BlockHasLabel = LabeledMBB.
contains(
MI->getParent());
339 bool IsNextInstructionFunctionPreamble =
341 bool ShouldEmitEntryLabel = !BlockHasLabel && IsFunctionPreambleInstruction &&
342 !IsNextInstructionFunctionPreamble;
343 if (ShouldEmitEntryLabel) {
344 assert(
MI->getParent()->getNumber() == MF->front().getNumber() &&
345 "OpFunction is not in the front MBB of MF");
346 emitOpLabel(*
MI->getParent());
347 if (NSDebugHandler && !isHidden())
352void SPIRVAsmPrinter::outputModuleSection(SPIRV::ModuleSectionType MSType) {
353 for (
const MachineInstr *
MI : MAI->getMSInstrs(MSType))
354 outputInstruction(
MI);
357void SPIRVAsmPrinter::outputDebugSourceAndStrings(
const Module &M) {
359 for (
auto &Str : MAI->SrcExt) {
361 Inst.
setOpcode(SPIRV::OpSourceExtension);
366 outputModuleSection(SPIRV::MB_DebugStrings);
382 AuxDataHandler->emitAuxDataStrings(*MAI);
385void SPIRVAsmPrinter::outputOpExtInstImports(
const Module &M) {
386 for (
auto &CU : MAI->ExtInstSetMap) {
387 unsigned Set = CU.first;
388 MCRegister
Reg = CU.second;
393 static_cast<SPIRV::InstructionSet::InstructionSet
>(Set)),
399void SPIRVAsmPrinter::outputOpMemoryModel() {
411void SPIRVAsmPrinter::outputEntryPoints() {
413 DenseSet<MCRegister> InterfaceIDs;
414 for (
const MachineInstr *
MI : MAI->GlobalVarList) {
415 assert(
MI->getOpcode() == SPIRV::OpVariable ||
416 MI->getOpcode() == SPIRV::OpUntypedVariableKHR);
417 auto SC =
static_cast<SPIRV::StorageClass::StorageClass
>(
424 SC == SPIRV::StorageClass::Input || SC == SPIRV::StorageClass::Output) {
426 MCRegister
Reg = MAI->getRegisterAlias(MF,
MI->getOperand(0).getReg());
432 for (
const MachineInstr *
MI : MAI->getMSInstrs(SPIRV::MB_EntryPoints)) {
433 SPIRVMCInstLower MCInstLowering;
435 MCInstLowering.
lower(
MI, TmpInst, MAI);
436 for (MCRegister
Reg : InterfaceIDs) {
440 outputMCInst(TmpInst);
445void SPIRVAsmPrinter::outputGlobalRequirements() {
447 MAI->Reqs.checkSatisfiable(*ST);
449 for (
const auto &Cap : MAI->Reqs.getMinimalCapabilities()) {
457 for (
const auto &Ext : MAI->Reqs.getExtensions()) {
461 SPIRV::OperandCategory::ExtensionOperand, Ext),
468void SPIRVAsmPrinter::outputExtFuncDecls() {
470 auto I = MAI->getMSInstrs(SPIRV::MB_ExtFuncDecls).begin(),
471 E = MAI->getMSInstrs(SPIRV::MB_ExtFuncDecls).end();
472 for (;
I !=
E; ++
I) {
473 outputInstruction(*
I);
474 if ((
I + 1) ==
E || (*(
I + 1))->
getOpcode() == SPIRV::OpFunction)
475 outputOpFunctionEnd();
485 if (Ty->isDoubleTy())
488 switch (IntTy->getIntegerBitWidth()) {
502 Type *EleTy = VecTy->getElementType();
503 unsigned Size = VecTy->getNumElements();
525void SPIRVAsmPrinter::outputExecutionModeFromMDNode(
526 MCRegister
Reg, MDNode *Node, SPIRV::ExecutionMode::ExecutionMode EM,
527 unsigned ExpectMDOps, int64_t DefVal) {
535 unsigned NodeSz =
Node->getNumOperands();
536 if (ExpectMDOps > 0 && NodeSz < ExpectMDOps)
537 for (
unsigned i = NodeSz; i < ExpectMDOps; ++i)
542void SPIRVAsmPrinter::outputExecutionModeFromNumthreadsAttribute(
544 SPIRV::ExecutionMode::ExecutionMode EM) {
545 assert(Attr.
isValid() &&
"Function called with an invalid attribute.");
554 assert(NumThreads.size() == 3 &&
"invalid numthreads");
555 for (uint32_t i = 0; i < 3; ++i) {
557 [[maybe_unused]]
bool Result = NumThreads[i].getAsInteger(10, V);
558 assert(!Result &&
"Failed to parse numthreads");
565void SPIRVAsmPrinter::emitSimpleExecutionMode(
566 MCRegister
Reg, SPIRV::ExecutionMode::ExecutionMode EM) {
574void SPIRVAsmPrinter::outputExecutionModeFromEnableMaximalReconvergenceAttr(
575 const MCRegister &
Reg,
const SPIRVSubtarget &ST) {
576 assert(
ST.canUseExtension(SPIRV::Extension::SPV_KHR_maximal_reconvergence) &&
577 "Function called when SPV_KHR_maximal_reconvergence is not enabled.");
579 emitSimpleExecutionMode(
Reg, SPIRV::ExecutionMode::MaximallyReconvergesKHR);
582void SPIRVAsmPrinter::outputExecutionMode(
const Module &M) {
583 NamedMDNode *
Node =
M.getNamedMetadata(
"spirv.ExecutionMode");
585 for (
unsigned i = 0; i <
Node->getNumOperands(); i++) {
592 if (EM == SPIRV::ExecutionMode::ArithmeticPoisonKHR)
598 if (EM == SPIRV::ExecutionMode::FPFastMathDefault ||
599 EM == SPIRV::ExecutionMode::ContractionOff ||
600 EM == SPIRV::ExecutionMode::SignedZeroInfNanPreserve)
609 outputFPFastMathDefaultInfo();
611 for (
auto FI =
M.begin(),
E =
M.end(); FI !=
E; ++FI) {
617 MCRegister FReg = MAI->getGlobalObjReg(&
F);
626 emitSimpleExecutionMode(FReg, SPIRV::ExecutionMode::OriginUpperLeft);
629 if (MDNode *Node =
F.getMetadata(
"reqd_work_group_size"))
630 outputExecutionModeFromMDNode(FReg, Node, SPIRV::ExecutionMode::LocalSize,
633 outputExecutionModeFromNumthreadsAttribute(
634 FReg, Attr, SPIRV::ExecutionMode::LocalSize);
635 if (
Attribute Attr =
F.getFnAttribute(
"enable-maximal-reconvergence");
637 outputExecutionModeFromEnableMaximalReconvergenceAttr(FReg, *ST);
639 if (MDNode *Node =
F.getMetadata(
"work_group_size_hint"))
640 outputExecutionModeFromMDNode(FReg, Node,
641 SPIRV::ExecutionMode::LocalSizeHint, 3, 1);
642 if (MDNode *Node =
F.getMetadata(
"reqd_sub_group_size"))
643 outputExecutionModeFromMDNode(FReg, Node,
644 SPIRV::ExecutionMode::SubgroupSize, 0, 0);
645 if (MDNode *Node =
F.getMetadata(
"intel_reqd_sub_group_size"))
646 outputExecutionModeFromMDNode(FReg, Node,
647 SPIRV::ExecutionMode::SubgroupSize, 0, 0);
648 if (MDNode *Node =
F.getMetadata(
"max_work_group_size")) {
649 if (ST->
canUseExtension(SPIRV::Extension::SPV_INTEL_kernel_attributes))
650 outputExecutionModeFromMDNode(
651 FReg, Node, SPIRV::ExecutionMode::MaxWorkgroupSizeINTEL, 3, 1);
653 if (MDNode *Node =
F.getMetadata(
"vec_type_hint")) {
657 unsigned EM =
static_cast<unsigned>(SPIRV::ExecutionMode::VecTypeHint);
666 SPIRV::Capability::PoisonFreezeKHR)) {
667 emitSimpleExecutionMode(FReg, SPIRV::ExecutionMode::ArithmeticPoisonKHR);
671 bool EmitContractionOff =
672 ST->
isKernel() && !
M.getNamedMetadata(
"spirv.ExecutionMode") &&
673 SPIRVFPContract != SPIRVFPContractMode::Fast &&
674 (SPIRVFPContract == SPIRVFPContractMode::Off ||
675 !
M.getNamedMetadata(
"opencl.enable.FP_CONTRACT"));
676 if (EmitContractionOff) {
694 std::vector<const MachineInstr *> SPIRVFloatTypes;
695 const MachineInstr *ConstZeroInt32 =
nullptr;
696 for (
const MachineInstr *
MI :
697 MAI->getMSInstrs(SPIRV::MB_TypeConstVars)) {
701 if (OpCode == SPIRV::OpTypeFloat) {
703 const unsigned OpTypeFloatSize =
MI->getOperand(1).getImm();
704 if (OpTypeFloatSize != 16 && OpTypeFloatSize != 32 &&
705 OpTypeFloatSize != 64) {
708 SPIRVFloatTypes.push_back(
MI);
712 if (OpCode == SPIRV::OpConstantNull) {
714 const MachineRegisterInfo &MRI =
MI->getMF()->getRegInfo();
715 MachineInstr *TypeMI = MRI.
getVRegDef(
MI->getOperand(1).getReg());
716 bool IsInt32Ty = TypeMI &&
717 TypeMI->
getOpcode() == SPIRV::OpTypeInt &&
730 for (
const MachineInstr *
MI : SPIRVFloatTypes) {
732 Inst.
setOpcode(SPIRV::OpExecutionModeId);
735 static_cast<unsigned>(SPIRV::ExecutionMode::FPFastMathDefault);
739 MAI->getRegisterAlias(MF,
MI->getOperand(0).getReg());
741 assert(ConstZeroInt32 &&
"There should be a constant zero.");
742 MCRegister ConstReg = MAI->getRegisterAlias(
748 emitSimpleExecutionMode(FReg, SPIRV::ExecutionMode::ContractionOff);
754void SPIRVAsmPrinter::outputAnnotations(
const Module &M) {
755 outputModuleSection(SPIRV::MB_Annotations);
757 if (
const GlobalVariable *V =
M.getNamedGlobal(
"llvm.global.annotations")) {
765 MCRegister
Reg = GO ? MAI->getGlobalObjReg(GO) : MCRegister();
768 raw_string_ostream OS(DiagMsg);
769 AnnotatedVar->
print(OS);
770 DiagMsg =
"Unsupported value in llvm.global.annotations: " + DiagMsg;
778 StringRef AnnotationString;
779 [[maybe_unused]]
bool Success =
785 unsigned Dec =
static_cast<unsigned>(SPIRV::Decoration::UserSemantic);
793void SPIRVAsmPrinter::outputFPFastMathDefaultInfo() {
796 std::vector<const MachineInstr *> SPIRVFloatTypes;
798 DenseMap<int, const MachineInstr *>
ConstMap;
799 for (
const MachineInstr *
MI : MAI->getMSInstrs(SPIRV::MB_TypeConstVars)) {
802 if (OpCode != SPIRV::OpTypeFloat && OpCode != SPIRV::OpConstantI &&
803 OpCode != SPIRV::OpConstantNull)
807 if (OpCode == SPIRV::OpTypeFloat) {
808 SPIRVFloatTypes.push_back(
MI);
812 MachineInstr *TypeMI = MRI.
getVRegDef(
MI->getOperand(1).getReg());
813 if (!TypeMI || TypeMI->
getOpcode() != SPIRV::OpTypeInt ||
817 if (OpCode == SPIRV::OpConstantI)
824 for (
const auto &[Func, FPFastMathDefaultInfoVec] :
825 MAI->FPFastMathDefaultInfoMap) {
826 if (FPFastMathDefaultInfoVec.empty())
829 for (
const MachineInstr *
MI : SPIRVFloatTypes) {
830 unsigned OpTypeFloatSize =
MI->getOperand(1).getImm();
833 assert(Index < FPFastMathDefaultInfoVec.size() &&
834 "Index out of bounds for FPFastMathDefaultInfoVec");
835 const auto &FPFastMathDefaultInfo = FPFastMathDefaultInfoVec[
Index];
836 assert(FPFastMathDefaultInfo.Ty &&
837 "Expected target type for FPFastMathDefaultInfo");
838 assert(FPFastMathDefaultInfo.Ty->getScalarSizeInBits() ==
840 "Mismatched float type size");
842 Inst.
setOpcode(SPIRV::OpExecutionModeId);
843 MCRegister FuncReg = MAI->getGlobalObjReg(Func);
849 MAI->getRegisterAlias(
MI->getMF(),
MI->getOperand(0).getReg());
851 unsigned Flags = FPFastMathDefaultInfo.FastMathFlags;
852 if (FPFastMathDefaultInfo.ContractionOff &&
853 (Flags & SPIRV::FPFastMathMode::AllowContract))
855 "Conflicting FPFastMathFlags: ContractionOff and AllowContract");
857 if (FPFastMathDefaultInfo.SignedZeroInfNanPreserve &&
859 (SPIRV::FPFastMathMode::NotNaN | SPIRV::FPFastMathMode::NotInf |
860 SPIRV::FPFastMathMode::NSZ))) {
861 if (FPFastMathDefaultInfo.FPFastMathDefault)
863 "SignedZeroInfNanPreserve but at least one of "
864 "NotNaN/NotInf/NSZ is enabled.");
868 if (Flags == SPIRV::FPFastMathMode::None &&
869 !FPFastMathDefaultInfo.ContractionOff &&
870 !FPFastMathDefaultInfo.SignedZeroInfNanPreserve &&
871 !FPFastMathDefaultInfo.FPFastMathDefault)
878 "Mode operand of FPFastMathDefault execution mode.");
879 const MachineInstr *ConstMI = It->second;
880 MCRegister ConstReg = MAI->getRegisterAlias(
888void SPIRVAsmPrinter::outputModuleSections() {
889 const Module *
M = MMI->getModule();
891 ST =
static_cast<const SPIRVTargetMachine &
>(TM).getSubtargetImpl();
893 MAI = &getAnalysis<SPIRVModuleAnalysis>().MAI;
894 assert(ST &&
TII && MAI && M &&
"Module analysis is required");
896 if (!AuxDataHandler) {
897 auto Handler = std::make_unique<SPIRVAuxDataHandler>(*
this, *M);
898 if (Handler->hasWork())
899 AuxDataHandler = std::move(Handler);
907 AuxDataHandler->prepareModuleOutput(*ST, *MAI);
912 outputGlobalRequirements();
914 outputOpExtInstImports(*M);
916 outputOpMemoryModel();
921 outputExecutionMode(*M);
924 outputDebugSourceAndStrings(*M);
926 outputModuleSection(SPIRV::MB_DebugNames);
928 outputModuleSection(SPIRV::MB_DebugModuleProcessed);
931 outputModuleSection(SPIRV::MB_AliasingInsts);
933 outputAnnotations(*M);
938 outputModuleSection(SPIRV::MB_TypeConstVars);
945 AuxDataHandler->emitAuxData(*MAI);
947 outputExtFuncDecls();
952bool SPIRVAsmPrinter::doInitialization(
Module &M) {
953 ModuleSectionsEmitted =
false;
954 if (!
M.getModuleInlineAsm().empty()) {
955 M.getContext().emitError(
956 "SPIR-V does not support module-level inline assembly");
957 M.removeModuleInlineAsm();
962 if (
M.getNamedMetadata(
"llvm.dbg.cu")) {
963 auto Handler = std::make_unique<SPIRVNonSemanticDebugHandler>(*
this);
964 NSDebugHandler = Handler.get();
965 addAsmPrinterHandler(std::move(Handler));
971char SPIRVAsmPrinter::ID = 0;
978LLVMInitializeSPIRVAsmPrinter() {
986 SPIRVAsmPrinter &
AsmPrinter =
static_cast<SPIRVAsmPrinter &
>(
996 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 clEnumValN(ENUMVAL, FLAGNAME, DESC)
#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)
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',...
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
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.
ValuesClass values(OptsTy... Options)
Helper to build a ValuesClass by forwarding a variable number of arguments as an initializer list to ...
initializer< Ty > init(const Ty &Val)
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()
@ Fast
Assign the register banks as fast as possible (default).
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.
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)