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 return &getAnalysis<SPIRVModuleAnalysisWrapperPass>().MAI;
83 bool ModuleSectionsEmitted;
87 StringRef getPassName()
const override {
return "SPIRV Assembly Printer"; }
92 void outputMCInst(
MCInst &Inst);
95 void outputGlobalRequirements();
96 void outputEntryPoints();
97 void outputDebugSourceAndStrings(
const Module &M);
98 void outputOpExtInstImports(
const Module &M);
99 void outputOpMemoryModel();
100 void outputOpFunctionEnd();
101 void outputExtFuncDecls();
103 SPIRV::ExecutionMode::ExecutionMode EM,
104 unsigned ExpectMDOps, int64_t DefVal);
105 void outputExecutionModeFromNumthreadsAttribute(
107 SPIRV::ExecutionMode::ExecutionMode EM);
108 void outputExecutionModeFromEnableMaximalReconvergenceAttr(
111 SPIRV::ExecutionMode::ExecutionMode EM);
112 void outputExecutionMode(
const Module &M);
113 void outputAnnotations(
const Module &M);
114 void outputModuleSections();
115 void outputFPFastMathDefaultInfo();
117 return MF->getFunction()
123 void emitFunctionEntryLabel()
override {}
124 void emitFunctionHeader()
override;
125 void emitFunctionBodyStart()
override {}
126 void emitFunctionBodyEnd()
override;
131 void emitEndOfAsmFile(
Module &M)
override;
132 bool doInitialization(
Module &M)
override;
143 std::unique_ptr<SPIRVAuxDataHandler> AuxDataHandler;
150void SPIRVAsmPrinter::getAnalysisUsage(
AnalysisUsage &AU)
const {
157void SPIRVAsmPrinter::emitEndOfAsmFile(
Module &M) {
158 if (!ModuleSectionsEmitted) {
159 outputModuleSections();
160 ModuleSectionsEmitted =
true;
163 ST =
static_cast<const SPIRVTargetMachine &
>(TM).getSubtargetImpl();
171 uint32_t Major = SPIRVVersion.
getMajor();
172 uint32_t Minor = SPIRVVersion.
getMinor().value_or(0);
175 unsigned Bound = 2 * (ST->
getBound() + 1) + NLabels;
176 if (MCAssembler *Asm = OutStreamer->getAssemblerPtr())
177 static_cast<SPIRVObjectWriter &
>(
Asm->getWriter())
178 .setBuildVersion(Major, Minor, Bound);
185void SPIRVAsmPrinter::cleanUp(
Module &M) {
187 for (StringRef GVName :
188 {
"llvm.global_ctors",
"llvm.global_dtors",
"llvm.used"}) {
189 if (GlobalVariable *GV =
M.getNamedGlobal(GVName))
194void SPIRVAsmPrinter::emitFunctionHeader() {
195 if (!ModuleSectionsEmitted) {
196 outputModuleSections();
197 ModuleSectionsEmitted =
true;
200 ST = &MF->getSubtarget<SPIRVSubtarget>();
204 if (isVerbose() && !isHidden()) {
205 OutStreamer->getCommentOS()
206 <<
"-- Begin function "
210 auto Section = getObjFileLowering().SectionForGlobal(&
F, TM);
211 MF->setSection(Section);
217 for (
auto &Handler : Handlers) {
218 Handler->beginFunction(MF);
219 Handler->beginBasicBlockSection(MF->front());
223void SPIRVAsmPrinter::outputOpFunctionEnd() {
224 MCInst FunctionEndInst;
225 FunctionEndInst.
setOpcode(SPIRV::OpFunctionEnd);
226 outputMCInst(FunctionEndInst);
229void SPIRVAsmPrinter::emitFunctionBodyEnd() {
231 outputOpFunctionEnd();
234void SPIRVAsmPrinter::emitOpLabel(
const MachineBasicBlock &
MBB) {
242 outputMCInst(LabelInst);
247void SPIRVAsmPrinter::emitBasicBlockStart(
const MachineBasicBlock &
MBB) {
255 for (
const MachineInstr &
MI :
MBB)
256 if (
MI.getOpcode() == SPIRV::OpFunction)
264void SPIRVAsmPrinter::printOperand(
const MachineInstr *
MI,
int OpNum,
266 const MachineOperand &MO =
MI->getOperand(OpNum);
306bool SPIRVAsmPrinter::PrintAsmOperand(
const MachineInstr *
MI,
unsigned OpNo,
307 const char *ExtraCode, raw_ostream &O) {
308 if (ExtraCode && ExtraCode[0])
317 return TII->isHeaderInstr(*
MI) ||
MI->getOpcode() == SPIRV::OpFunction ||
318 MI->getOpcode() == SPIRV::OpFunctionParameter;
321void SPIRVAsmPrinter::outputMCInst(MCInst &Inst) {
322 OutStreamer->emitInstruction(Inst, *OutContext.getSubtargetInfo());
325void SPIRVAsmPrinter::outputInstruction(
const MachineInstr *
MI) {
326 SPIRVMCInstLower MCInstLowering;
328 MCInstLowering.
lower(
MI, TmpInst, MAI);
329 outputMCInst(TmpInst);
332void SPIRVAsmPrinter::emitInstruction(
const MachineInstr *
MI) {
333 SPIRV_MC::verifyInstructionPredicates(
MI->getOpcode(),
334 getSubtargetInfo().getFeatureBits());
336 bool InstructionEmitted = !MAI->getSkipEmission(
MI);
337 if (InstructionEmitted)
338 outputInstruction(
MI);
341 const MachineInstr *NextMI =
MI->getNextNode();
342 bool BlockHasLabel = LabeledMBB.
contains(
MI->getParent());
344 bool IsNextInstructionFunctionPreamble =
346 bool ShouldEmitEntryLabel = !BlockHasLabel && IsFunctionPreambleInstruction &&
347 !IsNextInstructionFunctionPreamble;
348 if (ShouldEmitEntryLabel) {
349 assert(
MI->getParent()->getNumber() == MF->front().getNumber() &&
350 "OpFunction is not in the front MBB of MF");
351 emitOpLabel(*
MI->getParent());
352 if (NSDebugHandler && !isHidden())
357void SPIRVAsmPrinter::outputModuleSection(SPIRV::ModuleSectionType MSType) {
358 for (
const MachineInstr *
MI : MAI->getMSInstrs(MSType))
359 outputInstruction(
MI);
362void SPIRVAsmPrinter::outputDebugSourceAndStrings(
const Module &M) {
364 for (
auto &Str : MAI->SrcExt) {
366 Inst.
setOpcode(SPIRV::OpSourceExtension);
371 outputModuleSection(SPIRV::MB_DebugStrings);
387 AuxDataHandler->emitAuxDataStrings(*MAI);
390void SPIRVAsmPrinter::outputOpExtInstImports(
const Module &M) {
391 for (
auto &CU : MAI->ExtInstSetMap) {
392 unsigned Set = CU.first;
393 MCRegister
Reg = CU.second;
398 static_cast<SPIRV::InstructionSet::InstructionSet
>(Set)),
404void SPIRVAsmPrinter::outputOpMemoryModel() {
416void SPIRVAsmPrinter::outputEntryPoints() {
418 DenseSet<MCRegister> InterfaceIDs;
419 for (
const MachineInstr *
MI : MAI->GlobalVarList) {
420 assert(
MI->getOpcode() == SPIRV::OpVariable ||
421 MI->getOpcode() == SPIRV::OpUntypedVariableKHR);
422 auto SC =
static_cast<SPIRV::StorageClass::StorageClass
>(
429 SC == SPIRV::StorageClass::Input || SC == SPIRV::StorageClass::Output) {
431 MCRegister
Reg = MAI->getRegisterAlias(MF,
MI->getOperand(0).getReg());
437 for (
const MachineInstr *
MI : MAI->getMSInstrs(SPIRV::MB_EntryPoints)) {
438 SPIRVMCInstLower MCInstLowering;
440 MCInstLowering.
lower(
MI, TmpInst, MAI);
441 for (MCRegister
Reg : InterfaceIDs) {
445 outputMCInst(TmpInst);
450void SPIRVAsmPrinter::outputGlobalRequirements() {
452 MAI->Reqs.checkSatisfiable(*ST);
454 for (
const auto &Cap : MAI->Reqs.getMinimalCapabilities()) {
462 for (
const auto &Ext : MAI->Reqs.getExtensions()) {
466 SPIRV::OperandCategory::ExtensionOperand, Ext),
473void SPIRVAsmPrinter::outputExtFuncDecls() {
475 auto I = MAI->getMSInstrs(SPIRV::MB_ExtFuncDecls).begin(),
476 E = MAI->getMSInstrs(SPIRV::MB_ExtFuncDecls).end();
477 for (;
I !=
E; ++
I) {
478 outputInstruction(*
I);
479 if ((
I + 1) ==
E || (*(
I + 1))->
getOpcode() == SPIRV::OpFunction)
480 outputOpFunctionEnd();
490 if (Ty->isDoubleTy())
493 switch (IntTy->getIntegerBitWidth()) {
507 Type *EleTy = VecTy->getElementType();
508 unsigned Size = VecTy->getNumElements();
530void SPIRVAsmPrinter::outputExecutionModeFromMDNode(
531 MCRegister
Reg, MDNode *Node, SPIRV::ExecutionMode::ExecutionMode EM,
532 unsigned ExpectMDOps, int64_t DefVal) {
540 unsigned NodeSz =
Node->getNumOperands();
541 if (ExpectMDOps > 0 && NodeSz < ExpectMDOps)
542 for (
unsigned i = NodeSz; i < ExpectMDOps; ++i)
547void SPIRVAsmPrinter::outputExecutionModeFromNumthreadsAttribute(
549 SPIRV::ExecutionMode::ExecutionMode EM) {
550 assert(Attr.
isValid() &&
"Function called with an invalid attribute.");
559 assert(NumThreads.size() == 3 &&
"invalid numthreads");
560 for (uint32_t i = 0; i < 3; ++i) {
562 [[maybe_unused]]
bool Result = NumThreads[i].getAsInteger(10, V);
563 assert(!Result &&
"Failed to parse numthreads");
570void SPIRVAsmPrinter::emitSimpleExecutionMode(
571 MCRegister
Reg, SPIRV::ExecutionMode::ExecutionMode EM) {
579void SPIRVAsmPrinter::outputExecutionModeFromEnableMaximalReconvergenceAttr(
580 const MCRegister &
Reg,
const SPIRVSubtarget &ST) {
581 assert(
ST.canUseExtension(SPIRV::Extension::SPV_KHR_maximal_reconvergence) &&
582 "Function called when SPV_KHR_maximal_reconvergence is not enabled.");
584 emitSimpleExecutionMode(
Reg, SPIRV::ExecutionMode::MaximallyReconvergesKHR);
587void SPIRVAsmPrinter::outputExecutionMode(
const Module &M) {
588 NamedMDNode *
Node =
M.getNamedMetadata(
"spirv.ExecutionMode");
590 for (
unsigned i = 0; i <
Node->getNumOperands(); i++) {
597 if (EM == SPIRV::ExecutionMode::ArithmeticPoisonKHR)
603 if (EM == SPIRV::ExecutionMode::FPFastMathDefault ||
604 EM == SPIRV::ExecutionMode::ContractionOff ||
605 EM == SPIRV::ExecutionMode::SignedZeroInfNanPreserve)
614 outputFPFastMathDefaultInfo();
616 for (
auto FI =
M.begin(),
E =
M.end(); FI !=
E; ++FI) {
622 MCRegister FReg = MAI->getGlobalObjReg(&
F);
631 emitSimpleExecutionMode(FReg, SPIRV::ExecutionMode::OriginUpperLeft);
634 if (MDNode *Node =
F.getMetadata(
"reqd_work_group_size"))
635 outputExecutionModeFromMDNode(FReg, Node, SPIRV::ExecutionMode::LocalSize,
638 outputExecutionModeFromNumthreadsAttribute(
639 FReg, Attr, SPIRV::ExecutionMode::LocalSize);
640 if (
Attribute Attr =
F.getFnAttribute(
"enable-maximal-reconvergence");
642 outputExecutionModeFromEnableMaximalReconvergenceAttr(FReg, *ST);
644 if (MDNode *Node =
F.getMetadata(
"work_group_size_hint"))
645 outputExecutionModeFromMDNode(FReg, Node,
646 SPIRV::ExecutionMode::LocalSizeHint, 3, 1);
647 if (MDNode *Node =
F.getMetadata(
"reqd_sub_group_size"))
648 outputExecutionModeFromMDNode(FReg, Node,
649 SPIRV::ExecutionMode::SubgroupSize, 0, 0);
650 if (MDNode *Node =
F.getMetadata(
"intel_reqd_sub_group_size"))
651 outputExecutionModeFromMDNode(FReg, Node,
652 SPIRV::ExecutionMode::SubgroupSize, 0, 0);
653 if (MDNode *Node =
F.getMetadata(
"max_work_group_size")) {
654 if (ST->
canUseExtension(SPIRV::Extension::SPV_INTEL_kernel_attributes))
655 outputExecutionModeFromMDNode(
656 FReg, Node, SPIRV::ExecutionMode::MaxWorkgroupSizeINTEL, 3, 1);
658 if (MDNode *Node =
F.getMetadata(
"vec_type_hint")) {
662 unsigned EM =
static_cast<unsigned>(SPIRV::ExecutionMode::VecTypeHint);
671 SPIRV::Capability::PoisonFreezeKHR)) {
672 emitSimpleExecutionMode(FReg, SPIRV::ExecutionMode::ArithmeticPoisonKHR);
676 bool EmitContractionOff =
677 ST->
isKernel() && !
M.getNamedMetadata(
"spirv.ExecutionMode") &&
678 SPIRVFPContract != SPIRVFPContractMode::Fast &&
679 (SPIRVFPContract == SPIRVFPContractMode::Off ||
680 !
M.getNamedMetadata(
"opencl.enable.FP_CONTRACT"));
681 if (EmitContractionOff) {
699 std::vector<const MachineInstr *> SPIRVFloatTypes;
700 const MachineInstr *ConstZeroInt32 =
nullptr;
701 for (
const MachineInstr *
MI :
702 MAI->getMSInstrs(SPIRV::MB_TypeConstVars)) {
706 if (OpCode == SPIRV::OpTypeFloat) {
708 const unsigned OpTypeFloatSize =
MI->getOperand(1).getImm();
709 if (OpTypeFloatSize != 16 && OpTypeFloatSize != 32 &&
710 OpTypeFloatSize != 64) {
713 SPIRVFloatTypes.push_back(
MI);
717 if (OpCode == SPIRV::OpConstantNull) {
719 const MachineRegisterInfo &MRI =
MI->getMF()->getRegInfo();
720 MachineInstr *TypeMI = MRI.
getVRegDef(
MI->getOperand(1).getReg());
721 bool IsInt32Ty = TypeMI &&
722 TypeMI->
getOpcode() == SPIRV::OpTypeInt &&
735 for (
const MachineInstr *
MI : SPIRVFloatTypes) {
737 Inst.
setOpcode(SPIRV::OpExecutionModeId);
740 static_cast<unsigned>(SPIRV::ExecutionMode::FPFastMathDefault);
744 MAI->getRegisterAlias(MF,
MI->getOperand(0).getReg());
746 assert(ConstZeroInt32 &&
"There should be a constant zero.");
747 MCRegister ConstReg = MAI->getRegisterAlias(
753 emitSimpleExecutionMode(FReg, SPIRV::ExecutionMode::ContractionOff);
759void SPIRVAsmPrinter::outputAnnotations(
const Module &M) {
760 outputModuleSection(SPIRV::MB_Annotations);
762 if (
const GlobalVariable *V =
M.getNamedGlobal(
"llvm.global.annotations")) {
770 MCRegister
Reg = GO ? MAI->getGlobalObjReg(GO) : MCRegister();
773 raw_string_ostream OS(DiagMsg);
774 AnnotatedVar->
print(OS);
775 DiagMsg =
"Unsupported value in llvm.global.annotations: " + DiagMsg;
783 StringRef AnnotationString;
784 [[maybe_unused]]
bool Success =
790 unsigned Dec =
static_cast<unsigned>(SPIRV::Decoration::UserSemantic);
798void SPIRVAsmPrinter::outputFPFastMathDefaultInfo() {
801 std::vector<const MachineInstr *> SPIRVFloatTypes;
803 DenseMap<int, const MachineInstr *>
ConstMap;
804 for (
const MachineInstr *
MI : MAI->getMSInstrs(SPIRV::MB_TypeConstVars)) {
807 if (OpCode != SPIRV::OpTypeFloat && OpCode != SPIRV::OpConstantI &&
808 OpCode != SPIRV::OpConstantNull)
812 if (OpCode == SPIRV::OpTypeFloat) {
813 SPIRVFloatTypes.push_back(
MI);
817 MachineInstr *TypeMI = MRI.
getVRegDef(
MI->getOperand(1).getReg());
818 if (!TypeMI || TypeMI->
getOpcode() != SPIRV::OpTypeInt ||
822 if (OpCode == SPIRV::OpConstantI)
829 for (
const auto &[Func, FPFastMathDefaultInfoVec] :
830 MAI->FPFastMathDefaultInfoMap) {
831 if (FPFastMathDefaultInfoVec.empty())
834 for (
const MachineInstr *
MI : SPIRVFloatTypes) {
835 unsigned OpTypeFloatSize =
MI->getOperand(1).getImm();
838 assert(Index < FPFastMathDefaultInfoVec.size() &&
839 "Index out of bounds for FPFastMathDefaultInfoVec");
840 const auto &FPFastMathDefaultInfo = FPFastMathDefaultInfoVec[
Index];
841 assert(FPFastMathDefaultInfo.Ty &&
842 "Expected target type for FPFastMathDefaultInfo");
843 assert(FPFastMathDefaultInfo.Ty->getScalarSizeInBits() ==
845 "Mismatched float type size");
847 Inst.
setOpcode(SPIRV::OpExecutionModeId);
848 MCRegister FuncReg = MAI->getGlobalObjReg(Func);
854 MAI->getRegisterAlias(
MI->getMF(),
MI->getOperand(0).getReg());
856 unsigned Flags = FPFastMathDefaultInfo.FastMathFlags;
857 if (FPFastMathDefaultInfo.ContractionOff &&
858 (Flags & SPIRV::FPFastMathMode::AllowContract))
860 "Conflicting FPFastMathFlags: ContractionOff and AllowContract");
862 if (FPFastMathDefaultInfo.SignedZeroInfNanPreserve &&
864 (SPIRV::FPFastMathMode::NotNaN | SPIRV::FPFastMathMode::NotInf |
865 SPIRV::FPFastMathMode::NSZ))) {
866 if (FPFastMathDefaultInfo.FPFastMathDefault)
868 "SignedZeroInfNanPreserve but at least one of "
869 "NotNaN/NotInf/NSZ is enabled.");
873 if (Flags == SPIRV::FPFastMathMode::None &&
874 !FPFastMathDefaultInfo.ContractionOff &&
875 !FPFastMathDefaultInfo.SignedZeroInfNanPreserve &&
876 !FPFastMathDefaultInfo.FPFastMathDefault)
883 "Mode operand of FPFastMathDefault execution mode.");
884 const MachineInstr *ConstMI = It->second;
885 MCRegister ConstReg = MAI->getRegisterAlias(
893void SPIRVAsmPrinter::outputModuleSections() {
894 const Module *
M = MMI->getModule();
896 ST =
static_cast<const SPIRVTargetMachine &
>(TM).getSubtargetImpl();
899 assert(ST &&
TII && MAI && M &&
"Module analysis is required");
901 if (!AuxDataHandler) {
902 auto Handler = std::make_unique<SPIRVAuxDataHandler>(*
this, *M);
903 if (Handler->hasWork())
904 AuxDataHandler = std::move(Handler);
912 AuxDataHandler->prepareModuleOutput(*ST, *MAI);
917 outputGlobalRequirements();
919 outputOpExtInstImports(*M);
921 outputOpMemoryModel();
926 outputExecutionMode(*M);
929 outputDebugSourceAndStrings(*M);
931 outputModuleSection(SPIRV::MB_DebugNames);
933 outputModuleSection(SPIRV::MB_DebugModuleProcessed);
936 outputModuleSection(SPIRV::MB_AliasingInsts);
938 outputAnnotations(*M);
943 outputModuleSection(SPIRV::MB_TypeConstVars);
950 AuxDataHandler->emitAuxData(*MAI);
952 outputExtFuncDecls();
957bool SPIRVAsmPrinter::doInitialization(
Module &M) {
958 ModuleSectionsEmitted =
false;
959 if (!
M.getModuleInlineAsm().empty()) {
960 M.getContext().emitError(
961 "SPIR-V does not support module-level inline assembly");
962 M.removeModuleInlineAsm();
967 if (
M.getNamedMetadata(
"llvm.dbg.cu")) {
968 auto Handler = std::make_unique<SPIRVNonSemanticDebugHandler>(*
this);
969 NSDebugHandler = Handler.get();
970 addAsmPrinterHandler(std::move(Handler));
976char SPIRVAsmPrinter::ID = 0;
983LLVMInitializeSPIRVAsmPrinter() {
991 SPIRVAsmPrinter &
AsmPrinter =
static_cast<SPIRVAsmPrinter &
>(
1001 SPIRVAsmPrinter &
AsmPrinter =
static_cast<SPIRVAsmPrinter &
>(
1016 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',...
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
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)