LLVM 23.0.0git
SPIRVAsmPrinter.cpp
Go to the documentation of this file.
1//===-- SPIRVAsmPrinter.cpp - SPIR-V LLVM assembly writer ------*- C++ -*--===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// This file contains a printer that converts from our internal representation
10// of machine-dependent LLVM code to the SPIR-V assembly language.
11//
12//===----------------------------------------------------------------------===//
13
15#include "SPIRV.h"
16#include "SPIRVInstrInfo.h"
17#include "SPIRVMCInstLower.h"
18#include "SPIRVModuleAnalysis.h"
20#include "SPIRVSubtarget.h"
21#include "SPIRVTargetMachine.h"
22#include "SPIRVUtils.h"
24#include "llvm/ADT/DenseMap.h"
31#include "llvm/MC/MCAsmInfo.h"
32#include "llvm/MC/MCAssembler.h"
33#include "llvm/MC/MCInst.h"
36#include "llvm/MC/MCStreamer.h"
37#include "llvm/MC/MCSymbol.h"
41
42using namespace llvm;
43
44#define DEBUG_TYPE "asm-printer"
45
46namespace {
47class SPIRVAsmPrinter : public AsmPrinter {
48 unsigned NLabels = 0;
50
51public:
52 explicit SPIRVAsmPrinter(TargetMachine &TM,
53 std::unique_ptr<MCStreamer> Streamer)
54 : AsmPrinter(TM, std::move(Streamer), ID), ModuleSectionsEmitted(false),
55 ST(nullptr), TII(nullptr), MAI(nullptr) {}
56 static char ID;
57 bool ModuleSectionsEmitted;
58 const SPIRVSubtarget *ST;
59 const SPIRVInstrInfo *TII;
60
61 StringRef getPassName() const override { return "SPIRV Assembly Printer"; }
62 void printOperand(const MachineInstr *MI, int OpNum, raw_ostream &O);
63 bool PrintAsmOperand(const MachineInstr *MI, unsigned OpNo,
64 const char *ExtraCode, raw_ostream &O) override;
65
66 void outputMCInst(MCInst &Inst);
67 void outputInstruction(const MachineInstr *MI);
68 void outputModuleSection(SPIRV::ModuleSectionType MSType);
69 void outputGlobalRequirements();
70 void outputEntryPoints();
71 void outputDebugSourceAndStrings(const Module &M);
72 void outputOpExtInstImports(const Module &M);
73 void outputOpMemoryModel();
74 void outputOpFunctionEnd();
75 void outputExtFuncDecls();
76 void outputExecutionModeFromMDNode(MCRegister Reg, MDNode *Node,
77 SPIRV::ExecutionMode::ExecutionMode EM,
78 unsigned ExpectMDOps, int64_t DefVal);
79 void outputExecutionModeFromNumthreadsAttribute(
80 const MCRegister &Reg, const Attribute &Attr,
81 SPIRV::ExecutionMode::ExecutionMode EM);
82 void outputExecutionModeFromEnableMaximalReconvergenceAttr(
83 const MCRegister &Reg, const SPIRVSubtarget &ST);
84 void outputExecutionMode(const Module &M);
85 void outputAnnotations(const Module &M);
86 void outputModuleSections();
87 void outputFPFastMathDefaultInfo();
88 bool isHidden() {
89 return MF->getFunction()
90 .getFnAttribute(SPIRV_BACKEND_SERVICE_FUN_NAME)
91 .isValid();
92 }
93
94 void emitInstruction(const MachineInstr *MI) override;
95 void emitFunctionEntryLabel() override {}
96 void emitFunctionHeader() override;
97 void emitFunctionBodyStart() override {}
98 void emitFunctionBodyEnd() override;
99 void emitBasicBlockStart(const MachineBasicBlock &MBB) override;
100 void emitBasicBlockEnd(const MachineBasicBlock &MBB) override {}
101 void emitGlobalVariable(const GlobalVariable *GV) override {}
102 void emitOpLabel(const MachineBasicBlock &MBB);
103 void emitEndOfAsmFile(Module &M) override;
104 bool doInitialization(Module &M) override;
105
106 void getAnalysisUsage(AnalysisUsage &AU) const override;
108
109 // Non-owning pointer to the NSDI handler registered via addAsmPrinterHandler.
110 // The handler's lifetime is managed by AsmPrinter (the base class of this
111 // object), so this pointer cannot dangle.
112 SPIRVNonSemanticDebugHandler *NSDebugHandler = nullptr;
113
114protected:
115 void cleanUp(Module &M);
116};
117} // namespace
118
119void SPIRVAsmPrinter::getAnalysisUsage(AnalysisUsage &AU) const {
120 AU.addRequired<SPIRVModuleAnalysis>();
121 AU.addPreserved<SPIRVModuleAnalysis>();
123}
124
125// If the module has no functions, we need output global info anyway.
126void SPIRVAsmPrinter::emitEndOfAsmFile(Module &M) {
127 if (!ModuleSectionsEmitted) {
128 outputModuleSections();
129 ModuleSectionsEmitted = true;
130 }
131
132 ST = static_cast<const SPIRVTargetMachine &>(TM).getSubtargetImpl();
133 // SPIRVModuleAnalysis sets GR->Bound = MAI->MaxID before printing. Any IDs
134 // allocated by AsmPrinter handlers (e.g. SPIRVNonSemanticDebugHandler) during
135 // outputModuleSections() are not counted. Refresh the bound here so the
136 // formula below sees the final allocation count.
137 if (MAI)
138 ST->getSPIRVGlobalRegistry()->setBound(MAI->MaxID);
139 VersionTuple SPIRVVersion = ST->getSPIRVVersion();
140 uint32_t Major = SPIRVVersion.getMajor();
141 uint32_t Minor = SPIRVVersion.getMinor().value_or(0);
142 // Bound is an approximation that accounts for the maximum used register
143 // number and number of generated OpLabels
144 unsigned Bound = 2 * (ST->getBound() + 1) + NLabels;
145 if (MCAssembler *Asm = OutStreamer->getAssemblerPtr())
146 static_cast<SPIRVObjectWriter &>(Asm->getWriter())
147 .setBuildVersion(Major, Minor, Bound);
148
149 cleanUp(M);
150}
151
152// Any cleanup actions with the Module after we don't care about its content
153// anymore.
154void SPIRVAsmPrinter::cleanUp(Module &M) {
155 // Verifier disallows uses of intrinsic global variables.
156 for (StringRef GVName :
157 {"llvm.global_ctors", "llvm.global_dtors", "llvm.used"}) {
158 if (GlobalVariable *GV = M.getNamedGlobal(GVName))
159 GV->setName("");
160 }
161}
162
163void SPIRVAsmPrinter::emitFunctionHeader() {
164 if (!ModuleSectionsEmitted) {
165 outputModuleSections();
166 ModuleSectionsEmitted = true;
167 }
168 // Get the subtarget from the current MachineFunction.
169 ST = &MF->getSubtarget<SPIRVSubtarget>();
170 TII = ST->getInstrInfo();
171 const Function &F = MF->getFunction();
172
173 if (isVerbose() && !isHidden()) {
174 OutStreamer->getCommentOS()
175 << "-- Begin function "
176 << GlobalValue::dropLLVMManglingEscape(F.getName()) << '\n';
177 }
178
179 auto Section = getObjFileLowering().SectionForGlobal(&F, TM);
180 MF->setSection(Section);
181
182 // SPIRVAsmPrinter::emitFunctionHeader() does not call the base class,
183 // so handlers never receive beginFunction() from the normal path. Drive the
184 // per-function lifecycle here, matching what AsmPrinter::emitFunctionHeader()
185 // does for other targets.
186 for (auto &Handler : Handlers) {
187 Handler->beginFunction(MF);
188 Handler->beginBasicBlockSection(MF->front());
189 }
190}
191
192void SPIRVAsmPrinter::outputOpFunctionEnd() {
193 MCInst FunctionEndInst;
194 FunctionEndInst.setOpcode(SPIRV::OpFunctionEnd);
195 outputMCInst(FunctionEndInst);
196}
197
198void SPIRVAsmPrinter::emitFunctionBodyEnd() {
199 if (!isHidden())
200 outputOpFunctionEnd();
201}
202
203void SPIRVAsmPrinter::emitOpLabel(const MachineBasicBlock &MBB) {
204 // Do not emit anything if it's an internal service function.
205 if (isHidden())
206 return;
207
208 MCInst LabelInst;
209 LabelInst.setOpcode(SPIRV::OpLabel);
210 LabelInst.addOperand(MCOperand::createReg(MAI->getOrCreateMBBRegister(MBB)));
211 outputMCInst(LabelInst);
212 ++NLabels;
213 LabeledMBB.insert(&MBB);
214}
215
216void SPIRVAsmPrinter::emitBasicBlockStart(const MachineBasicBlock &MBB) {
217 // Do not emit anything if it's an internal service function.
218 if (MBB.empty() || isHidden())
219 return;
220
221 // If it's the first MBB in MF, it has OpFunction and OpFunctionParameter, so
222 // OpLabel should be output after them.
223 if (MBB.getNumber() == MF->front().getNumber()) {
224 for (const MachineInstr &MI : MBB)
225 if (MI.getOpcode() == SPIRV::OpFunction)
226 return;
227 // TODO: this case should be checked by the verifier.
228 report_fatal_error("OpFunction is expected in the front MBB of MF");
229 }
230 emitOpLabel(MBB);
231}
232
233void SPIRVAsmPrinter::printOperand(const MachineInstr *MI, int OpNum,
234 raw_ostream &O) {
235 const MachineOperand &MO = MI->getOperand(OpNum);
236
237 switch (MO.getType()) {
240 break;
241
243 O << MO.getImm();
244 break;
245
247 O << MO.getFPImm();
248 break;
249
251 O << *MO.getMBB()->getSymbol();
252 break;
253
255 O << *getSymbol(MO.getGlobal());
256 break;
257
259 MCSymbol *BA = GetBlockAddressSymbol(MO.getBlockAddress());
260 O << BA->getName();
261 break;
262 }
263
265 O << *GetExternalSymbolSymbol(MO.getSymbolName());
266 break;
267
270 default:
271 llvm_unreachable("<unknown operand type>");
272 }
273}
274
275bool SPIRVAsmPrinter::PrintAsmOperand(const MachineInstr *MI, unsigned OpNo,
276 const char *ExtraCode, raw_ostream &O) {
277 if (ExtraCode && ExtraCode[0])
278 return true; // Invalid instruction - SPIR-V does not have special modifiers
279
280 printOperand(MI, OpNo, O);
281 return false;
282}
283
285 const SPIRVInstrInfo *TII) {
286 return TII->isHeaderInstr(*MI) || MI->getOpcode() == SPIRV::OpFunction ||
287 MI->getOpcode() == SPIRV::OpFunctionParameter;
288}
289
290void SPIRVAsmPrinter::outputMCInst(MCInst &Inst) {
291 OutStreamer->emitInstruction(Inst, *OutContext.getSubtargetInfo());
292}
293
294void SPIRVAsmPrinter::outputInstruction(const MachineInstr *MI) {
295 SPIRVMCInstLower MCInstLowering;
296 MCInst TmpInst;
297 MCInstLowering.lower(MI, TmpInst, MAI);
298 outputMCInst(TmpInst);
299}
300
301void SPIRVAsmPrinter::emitInstruction(const MachineInstr *MI) {
302 SPIRV_MC::verifyInstructionPredicates(MI->getOpcode(),
303 getSubtargetInfo().getFeatureBits());
304
305 if (!MAI->getSkipEmission(MI))
306 outputInstruction(MI);
307
308 // Output OpLabel after OpFunction and OpFunctionParameter in the first MBB.
309 const MachineInstr *NextMI = MI->getNextNode();
310 if (!LabeledMBB.contains(MI->getParent()) && isFuncOrHeaderInstr(MI, TII) &&
311 (!NextMI || !isFuncOrHeaderInstr(NextMI, TII))) {
312 assert(MI->getParent()->getNumber() == MF->front().getNumber() &&
313 "OpFunction is not in the front MBB of MF");
314 emitOpLabel(*MI->getParent());
315 }
316}
317
318void SPIRVAsmPrinter::outputModuleSection(SPIRV::ModuleSectionType MSType) {
319 for (const MachineInstr *MI : MAI->getMSInstrs(MSType))
320 outputInstruction(MI);
321}
322
323void SPIRVAsmPrinter::outputDebugSourceAndStrings(const Module &M) {
324 // Output OpSourceExtensions.
325 for (auto &Str : MAI->SrcExt) {
326 MCInst Inst;
327 Inst.setOpcode(SPIRV::OpSourceExtension);
328 addStringImm(Str.first(), Inst);
329 outputMCInst(Inst);
330 }
331 // Output OpString.
332 outputModuleSection(SPIRV::MB_DebugStrings);
333 // Output OpSource.
334 MCInst Inst;
335 Inst.setOpcode(SPIRV::OpSource);
336 Inst.addOperand(MCOperand::createImm(static_cast<unsigned>(MAI->SrcLang)));
337 Inst.addOperand(
338 MCOperand::createImm(static_cast<unsigned>(MAI->SrcLangVersion)));
339 outputMCInst(Inst);
340 // Emit OpString instructions for NSDI file paths and type names here, in
341 // section 7. OpString must precede type/constant declarations per the SPIR-V
342 // module layout (section 2.4). The OpExtInst instructions that reference
343 // these strings are emitted later at section 10 by
344 // emitNonSemanticGlobalDebugInfo().
345 if (NSDebugHandler)
346 NSDebugHandler->emitNonSemanticDebugStrings(*MAI);
347}
348
349void SPIRVAsmPrinter::outputOpExtInstImports(const Module &M) {
350 for (auto &CU : MAI->ExtInstSetMap) {
351 unsigned Set = CU.first;
352 MCRegister Reg = CU.second;
353 MCInst Inst;
354 Inst.setOpcode(SPIRV::OpExtInstImport);
357 static_cast<SPIRV::InstructionSet::InstructionSet>(Set)),
358 Inst);
359 outputMCInst(Inst);
360 }
361}
362
363void SPIRVAsmPrinter::outputOpMemoryModel() {
364 MCInst Inst;
365 Inst.setOpcode(SPIRV::OpMemoryModel);
366 Inst.addOperand(MCOperand::createImm(static_cast<unsigned>(MAI->Addr)));
367 Inst.addOperand(MCOperand::createImm(static_cast<unsigned>(MAI->Mem)));
368 outputMCInst(Inst);
369}
370
371// Before the OpEntryPoints' output, we need to add the entry point's
372// interfaces. The interface is a list of IDs of global OpVariable instructions.
373// These declare the set of global variables from a module that form
374// the interface of this entry point.
375void SPIRVAsmPrinter::outputEntryPoints() {
376 // Find all OpVariable IDs with required StorageClass.
377 DenseSet<MCRegister> InterfaceIDs;
378 for (const MachineInstr *MI : MAI->GlobalVarList) {
379 assert(MI->getOpcode() == SPIRV::OpVariable);
380 auto SC = static_cast<SPIRV::StorageClass::StorageClass>(
381 MI->getOperand(2).getImm());
382 // Before version 1.4, the interface's storage classes are limited to
383 // the Input and Output storage classes. Starting with version 1.4,
384 // the interface's storage classes are all storage classes used in
385 // declaring all global variables referenced by the entry point call tree.
386 if (ST->isAtLeastSPIRVVer(VersionTuple(1, 4)) ||
387 SC == SPIRV::StorageClass::Input || SC == SPIRV::StorageClass::Output) {
388 const MachineFunction *MF = MI->getMF();
389 MCRegister Reg = MAI->getRegisterAlias(MF, MI->getOperand(0).getReg());
390 InterfaceIDs.insert(Reg);
391 }
392 }
393
394 // Output OpEntryPoints adding interface args to all of them.
395 for (const MachineInstr *MI : MAI->getMSInstrs(SPIRV::MB_EntryPoints)) {
396 SPIRVMCInstLower MCInstLowering;
397 MCInst TmpInst;
398 MCInstLowering.lower(MI, TmpInst, MAI);
399 for (MCRegister Reg : InterfaceIDs) {
400 assert(Reg.isValid());
402 }
403 outputMCInst(TmpInst);
404 }
405}
406
407// Create global OpCapability instructions for the required capabilities.
408void SPIRVAsmPrinter::outputGlobalRequirements() {
409 // Abort here if not all requirements can be satisfied.
410 MAI->Reqs.checkSatisfiable(*ST);
411
412 for (const auto &Cap : MAI->Reqs.getMinimalCapabilities()) {
413 MCInst Inst;
414 Inst.setOpcode(SPIRV::OpCapability);
416 outputMCInst(Inst);
417 }
418
419 // Generate the final OpExtensions with strings instead of enums.
420 for (const auto &Ext : MAI->Reqs.getExtensions()) {
421 MCInst Inst;
422 Inst.setOpcode(SPIRV::OpExtension);
424 SPIRV::OperandCategory::ExtensionOperand, Ext),
425 Inst);
426 outputMCInst(Inst);
427 }
428 // TODO add a pseudo instr for version number.
429}
430
431void SPIRVAsmPrinter::outputExtFuncDecls() {
432 // Insert OpFunctionEnd after each declaration.
433 auto I = MAI->getMSInstrs(SPIRV::MB_ExtFuncDecls).begin(),
434 E = MAI->getMSInstrs(SPIRV::MB_ExtFuncDecls).end();
435 for (; I != E; ++I) {
436 outputInstruction(*I);
437 if ((I + 1) == E || (*(I + 1))->getOpcode() == SPIRV::OpFunction)
438 outputOpFunctionEnd();
439 }
440}
441
442// Encode LLVM type by SPIR-V execution mode VecTypeHint.
443static unsigned encodeVecTypeHint(Type *Ty) {
444 if (Ty->isHalfTy())
445 return 4;
446 if (Ty->isFloatTy())
447 return 5;
448 if (Ty->isDoubleTy())
449 return 6;
450 if (IntegerType *IntTy = dyn_cast<IntegerType>(Ty)) {
451 switch (IntTy->getIntegerBitWidth()) {
452 case 8:
453 return 0;
454 case 16:
455 return 1;
456 case 32:
457 return 2;
458 case 64:
459 return 3;
460 default:
461 llvm_unreachable("invalid integer type");
462 }
463 }
465 Type *EleTy = VecTy->getElementType();
466 unsigned Size = VecTy->getNumElements();
467 return Size << 16 | encodeVecTypeHint(EleTy);
468 }
469 llvm_unreachable("invalid type");
470}
471
472static void addOpsFromMDNode(MDNode *MDN, MCInst &Inst,
474 for (const MDOperand &MDOp : MDN->operands()) {
475 if (auto *CMeta = dyn_cast<ConstantAsMetadata>(MDOp)) {
476 Constant *C = CMeta->getValue();
477 if (ConstantInt *Const = dyn_cast<ConstantInt>(C)) {
478 Inst.addOperand(MCOperand::createImm(Const->getZExtValue()));
479 } else if (auto *CE = dyn_cast<Function>(C)) {
480 MCRegister FuncReg = MAI->getGlobalObjReg(CE);
481 assert(FuncReg.isValid());
482 Inst.addOperand(MCOperand::createReg(FuncReg));
483 }
484 }
485 }
486}
487
488void SPIRVAsmPrinter::outputExecutionModeFromMDNode(
489 MCRegister Reg, MDNode *Node, SPIRV::ExecutionMode::ExecutionMode EM,
490 unsigned ExpectMDOps, int64_t DefVal) {
491 MCInst Inst;
492 Inst.setOpcode(SPIRV::OpExecutionMode);
494 Inst.addOperand(MCOperand::createImm(static_cast<unsigned>(EM)));
495 addOpsFromMDNode(Node, Inst, MAI);
496 // reqd_work_group_size and work_group_size_hint require 3 operands,
497 // if metadata contains less operands, just add a default value
498 unsigned NodeSz = Node->getNumOperands();
499 if (ExpectMDOps > 0 && NodeSz < ExpectMDOps)
500 for (unsigned i = NodeSz; i < ExpectMDOps; ++i)
501 Inst.addOperand(MCOperand::createImm(DefVal));
502 outputMCInst(Inst);
503}
504
505void SPIRVAsmPrinter::outputExecutionModeFromNumthreadsAttribute(
506 const MCRegister &Reg, const Attribute &Attr,
507 SPIRV::ExecutionMode::ExecutionMode EM) {
508 assert(Attr.isValid() && "Function called with an invalid attribute.");
509
510 MCInst Inst;
511 Inst.setOpcode(SPIRV::OpExecutionMode);
513 Inst.addOperand(MCOperand::createImm(static_cast<unsigned>(EM)));
514
515 SmallVector<StringRef> NumThreads;
516 Attr.getValueAsString().split(NumThreads, ',');
517 assert(NumThreads.size() == 3 && "invalid numthreads");
518 for (uint32_t i = 0; i < 3; ++i) {
519 uint32_t V;
520 [[maybe_unused]] bool Result = NumThreads[i].getAsInteger(10, V);
521 assert(!Result && "Failed to parse numthreads");
523 }
524
525 outputMCInst(Inst);
526}
527
528void SPIRVAsmPrinter::outputExecutionModeFromEnableMaximalReconvergenceAttr(
529 const MCRegister &Reg, const SPIRVSubtarget &ST) {
530 assert(ST.canUseExtension(SPIRV::Extension::SPV_KHR_maximal_reconvergence) &&
531 "Function called when SPV_KHR_maximal_reconvergence is not enabled.");
532
533 MCInst Inst;
534 Inst.setOpcode(SPIRV::OpExecutionMode);
536 unsigned EM =
537 static_cast<unsigned>(SPIRV::ExecutionMode::MaximallyReconvergesKHR);
539 outputMCInst(Inst);
540}
541
542void SPIRVAsmPrinter::outputExecutionMode(const Module &M) {
543 NamedMDNode *Node = M.getNamedMetadata("spirv.ExecutionMode");
544 if (Node) {
545 for (unsigned i = 0; i < Node->getNumOperands(); i++) {
546 // If SPV_KHR_float_controls2 is enabled and we find any of
547 // FPFastMathDefault, ContractionOff or SignedZeroInfNanPreserve execution
548 // modes, skip it, it'll be done somewhere else.
549 if (ST->canUseExtension(SPIRV::Extension::SPV_KHR_float_controls2)) {
550 const auto EM =
552 cast<ConstantAsMetadata>((Node->getOperand(i))->getOperand(1))
553 ->getValue())
554 ->getZExtValue();
555 if (EM == SPIRV::ExecutionMode::FPFastMathDefault ||
556 EM == SPIRV::ExecutionMode::ContractionOff ||
557 EM == SPIRV::ExecutionMode::SignedZeroInfNanPreserve)
558 continue;
559 }
560
561 MCInst Inst;
562 Inst.setOpcode(SPIRV::OpExecutionMode);
563 addOpsFromMDNode(cast<MDNode>(Node->getOperand(i)), Inst, MAI);
564 outputMCInst(Inst);
565 }
566 outputFPFastMathDefaultInfo();
567 }
568 for (auto FI = M.begin(), E = M.end(); FI != E; ++FI) {
569 const Function &F = *FI;
570 // Only operands of OpEntryPoint instructions are allowed to be
571 // <Entry Point> operands of OpExecutionMode
572 if (F.isDeclaration() || !isEntryPoint(F))
573 continue;
574 MCRegister FReg = MAI->getGlobalObjReg(&F);
575 assert(FReg.isValid());
576
577 if (Attribute Attr = F.getFnAttribute("hlsl.shader"); Attr.isValid()) {
578 // SPIR-V common validation: Fragment requires OriginUpperLeft or
579 // OriginLowerLeft.
580 // VUID-StandaloneSpirv-OriginLowerLeft-04653: Fragment must declare
581 // OriginUpperLeft.
582 if (Attr.getValueAsString() == "pixel") {
583 MCInst Inst;
584 Inst.setOpcode(SPIRV::OpExecutionMode);
586 unsigned EM =
587 static_cast<unsigned>(SPIRV::ExecutionMode::OriginUpperLeft);
589 outputMCInst(Inst);
590 }
591 }
592 if (MDNode *Node = F.getMetadata("reqd_work_group_size"))
593 outputExecutionModeFromMDNode(FReg, Node, SPIRV::ExecutionMode::LocalSize,
594 3, 1);
595 if (Attribute Attr = F.getFnAttribute("hlsl.numthreads"); Attr.isValid())
596 outputExecutionModeFromNumthreadsAttribute(
597 FReg, Attr, SPIRV::ExecutionMode::LocalSize);
598 if (Attribute Attr = F.getFnAttribute("enable-maximal-reconvergence");
599 Attr.getValueAsBool()) {
600 outputExecutionModeFromEnableMaximalReconvergenceAttr(FReg, *ST);
601 }
602 if (MDNode *Node = F.getMetadata("work_group_size_hint"))
603 outputExecutionModeFromMDNode(FReg, Node,
604 SPIRV::ExecutionMode::LocalSizeHint, 3, 1);
605 if (MDNode *Node = F.getMetadata("intel_reqd_sub_group_size"))
606 outputExecutionModeFromMDNode(FReg, Node,
607 SPIRV::ExecutionMode::SubgroupSize, 0, 0);
608 if (MDNode *Node = F.getMetadata("max_work_group_size")) {
609 if (ST->canUseExtension(SPIRV::Extension::SPV_INTEL_kernel_attributes))
610 outputExecutionModeFromMDNode(
611 FReg, Node, SPIRV::ExecutionMode::MaxWorkgroupSizeINTEL, 3, 1);
612 }
613 if (MDNode *Node = F.getMetadata("vec_type_hint")) {
614 MCInst Inst;
615 Inst.setOpcode(SPIRV::OpExecutionMode);
617 unsigned EM = static_cast<unsigned>(SPIRV::ExecutionMode::VecTypeHint);
619 unsigned TypeCode = encodeVecTypeHint(getMDOperandAsType(Node, 0));
620 Inst.addOperand(MCOperand::createImm(TypeCode));
621 outputMCInst(Inst);
622 }
623 if (ST->isKernel() && !M.getNamedMetadata("spirv.ExecutionMode") &&
624 !M.getNamedMetadata("opencl.enable.FP_CONTRACT")) {
625 if (ST->canUseExtension(SPIRV::Extension::SPV_KHR_float_controls2)) {
626 // When SPV_KHR_float_controls2 is enabled, ContractionOff is
627 // deprecated. We need to use FPFastMathDefault with the appropriate
628 // flags instead. Since FPFastMathDefault takes a target type, we need
629 // to emit it for each floating-point type that exists in the module
630 // to match the effect of ContractionOff. As of now, there are 3 FP
631 // types: fp16, fp32 and fp64.
632
633 // We only end up here because there is no "spirv.ExecutionMode"
634 // metadata, so that means no FPFastMathDefault. Therefore, we only
635 // need to make sure AllowContract is set to 0, as the rest of flags.
636 // We still need to emit the OpExecutionMode instruction, otherwise
637 // it's up to the client API to define the flags. Therefore, we need
638 // to find the constant with 0 value.
639
640 // Collect the SPIRVTypes for fp16, fp32, and fp64 and the constant of
641 // type int32 with 0 value to represent the FP Fast Math Mode.
642 std::vector<const MachineInstr *> SPIRVFloatTypes;
643 const MachineInstr *ConstZeroInt32 = nullptr;
644 for (const MachineInstr *MI :
645 MAI->getMSInstrs(SPIRV::MB_TypeConstVars)) {
646 unsigned OpCode = MI->getOpcode();
647
648 // Collect the SPIRV type if it's a float.
649 if (OpCode == SPIRV::OpTypeFloat) {
650 // Skip if the target type is not fp16, fp32, fp64.
651 const unsigned OpTypeFloatSize = MI->getOperand(1).getImm();
652 if (OpTypeFloatSize != 16 && OpTypeFloatSize != 32 &&
653 OpTypeFloatSize != 64) {
654 continue;
655 }
656 SPIRVFloatTypes.push_back(MI);
657 continue;
658 }
659
660 if (OpCode == SPIRV::OpConstantNull) {
661 // Check if the constant is int32, if not skip it.
662 const MachineRegisterInfo &MRI = MI->getMF()->getRegInfo();
663 MachineInstr *TypeMI = MRI.getVRegDef(MI->getOperand(1).getReg());
664 bool IsInt32Ty = TypeMI &&
665 TypeMI->getOpcode() == SPIRV::OpTypeInt &&
666 TypeMI->getOperand(1).getImm() == 32;
667 if (IsInt32Ty)
668 ConstZeroInt32 = MI;
669 }
670 }
671
672 // When SPV_KHR_float_controls2 is enabled, ContractionOff is
673 // deprecated. We need to use FPFastMathDefault with the appropriate
674 // flags instead. Since FPFastMathDefault takes a target type, we need
675 // to emit it for each floating-point type that exists in the module
676 // to match the effect of ContractionOff. As of now, there are 3 FP
677 // types: fp16, fp32 and fp64.
678 for (const MachineInstr *MI : SPIRVFloatTypes) {
679 MCInst Inst;
680 Inst.setOpcode(SPIRV::OpExecutionModeId);
682 unsigned EM =
683 static_cast<unsigned>(SPIRV::ExecutionMode::FPFastMathDefault);
685 const MachineFunction *MF = MI->getMF();
686 MCRegister TypeReg =
687 MAI->getRegisterAlias(MF, MI->getOperand(0).getReg());
688 Inst.addOperand(MCOperand::createReg(TypeReg));
689 assert(ConstZeroInt32 && "There should be a constant zero.");
690 MCRegister ConstReg = MAI->getRegisterAlias(
691 ConstZeroInt32->getMF(), ConstZeroInt32->getOperand(0).getReg());
692 Inst.addOperand(MCOperand::createReg(ConstReg));
693 outputMCInst(Inst);
694 }
695 } else {
696 MCInst Inst;
697 Inst.setOpcode(SPIRV::OpExecutionMode);
699 unsigned EM =
700 static_cast<unsigned>(SPIRV::ExecutionMode::ContractionOff);
702 outputMCInst(Inst);
703 }
704 }
705 }
706}
707
708void SPIRVAsmPrinter::outputAnnotations(const Module &M) {
709 outputModuleSection(SPIRV::MB_Annotations);
710 // Process llvm.global.annotations special global variable.
711 for (auto F = M.global_begin(), E = M.global_end(); F != E; ++F) {
712 if ((*F).getName() != "llvm.global.annotations")
713 continue;
714 const GlobalVariable *V = &(*F);
715 const ConstantArray *CA = cast<ConstantArray>(V->getOperand(0));
716 for (Value *Op : CA->operands()) {
717 ConstantStruct *CS = cast<ConstantStruct>(Op);
718 // The first field of the struct contains a pointer to
719 // the annotated variable.
720 Value *AnnotatedVar = CS->getOperand(0)->stripPointerCasts();
721 auto *GO = dyn_cast<GlobalObject>(AnnotatedVar);
722 MCRegister Reg = GO ? MAI->getGlobalObjReg(GO) : MCRegister();
723 if (!Reg.isValid()) {
724 std::string DiagMsg;
725 raw_string_ostream OS(DiagMsg);
726 AnnotatedVar->print(OS);
727 DiagMsg = "Unsupported value in llvm.global.annotations: " + DiagMsg;
728 report_fatal_error(DiagMsg.c_str());
729 }
730
731 // The second field contains a pointer to a global annotation string.
732 GlobalVariable *GV =
734
735 StringRef AnnotationString;
736 [[maybe_unused]] bool Success =
737 getConstantStringInfo(GV, AnnotationString);
738 assert(Success && "Failed to get annotation string");
739 MCInst Inst;
740 Inst.setOpcode(SPIRV::OpDecorate);
742 unsigned Dec = static_cast<unsigned>(SPIRV::Decoration::UserSemantic);
744 addStringImm(AnnotationString, Inst);
745 outputMCInst(Inst);
746 }
747 }
748}
749
750void SPIRVAsmPrinter::outputFPFastMathDefaultInfo() {
751 // Collect the SPIRVTypes that are OpTypeFloat and the constants of type
752 // int32, that might be used as FP Fast Math Mode.
753 std::vector<const MachineInstr *> SPIRVFloatTypes;
754 // Hashtable to associate immediate values with the constant holding them.
755 std::unordered_map<int, const MachineInstr *> ConstMap;
756 for (const MachineInstr *MI : MAI->getMSInstrs(SPIRV::MB_TypeConstVars)) {
757 // Skip if the instruction is not OpTypeFloat or OpConstant.
758 unsigned OpCode = MI->getOpcode();
759 if (OpCode != SPIRV::OpTypeFloat && OpCode != SPIRV::OpConstantI &&
760 OpCode != SPIRV::OpConstantNull)
761 continue;
762
763 // Collect the SPIRV type if it's a float.
764 if (OpCode == SPIRV::OpTypeFloat) {
765 SPIRVFloatTypes.push_back(MI);
766 } else {
767 // Check if the constant is int32, if not skip it.
768 const MachineRegisterInfo &MRI = MI->getMF()->getRegInfo();
769 MachineInstr *TypeMI = MRI.getVRegDef(MI->getOperand(1).getReg());
770 if (!TypeMI || TypeMI->getOpcode() != SPIRV::OpTypeInt ||
771 TypeMI->getOperand(1).getImm() != 32)
772 continue;
773
774 if (OpCode == SPIRV::OpConstantI)
775 ConstMap[MI->getOperand(2).getImm()] = MI;
776 else
777 ConstMap[0] = MI;
778 }
779 }
780
781 for (const auto &[Func, FPFastMathDefaultInfoVec] :
782 MAI->FPFastMathDefaultInfoMap) {
783 if (FPFastMathDefaultInfoVec.empty())
784 continue;
785
786 for (const MachineInstr *MI : SPIRVFloatTypes) {
787 unsigned OpTypeFloatSize = MI->getOperand(1).getImm();
790 assert(Index < FPFastMathDefaultInfoVec.size() &&
791 "Index out of bounds for FPFastMathDefaultInfoVec");
792 const auto &FPFastMathDefaultInfo = FPFastMathDefaultInfoVec[Index];
793 assert(FPFastMathDefaultInfo.Ty &&
794 "Expected target type for FPFastMathDefaultInfo");
795 assert(FPFastMathDefaultInfo.Ty->getScalarSizeInBits() ==
796 OpTypeFloatSize &&
797 "Mismatched float type size");
798 MCInst Inst;
799 Inst.setOpcode(SPIRV::OpExecutionModeId);
800 MCRegister FuncReg = MAI->getGlobalObjReg(Func);
801 assert(FuncReg.isValid());
802 Inst.addOperand(MCOperand::createReg(FuncReg));
803 Inst.addOperand(
804 MCOperand::createImm(SPIRV::ExecutionMode::FPFastMathDefault));
805 MCRegister TypeReg =
806 MAI->getRegisterAlias(MI->getMF(), MI->getOperand(0).getReg());
807 Inst.addOperand(MCOperand::createReg(TypeReg));
808 unsigned Flags = FPFastMathDefaultInfo.FastMathFlags;
809 if (FPFastMathDefaultInfo.ContractionOff &&
810 (Flags & SPIRV::FPFastMathMode::AllowContract))
812 "Conflicting FPFastMathFlags: ContractionOff and AllowContract");
813
814 if (FPFastMathDefaultInfo.SignedZeroInfNanPreserve &&
815 !(Flags &
816 (SPIRV::FPFastMathMode::NotNaN | SPIRV::FPFastMathMode::NotInf |
817 SPIRV::FPFastMathMode::NSZ))) {
818 if (FPFastMathDefaultInfo.FPFastMathDefault)
819 report_fatal_error("Conflicting FPFastMathFlags: "
820 "SignedZeroInfNanPreserve but at least one of "
821 "NotNaN/NotInf/NSZ is enabled.");
822 }
823
824 // Don't emit if none of the execution modes was used.
825 if (Flags == SPIRV::FPFastMathMode::None &&
826 !FPFastMathDefaultInfo.ContractionOff &&
827 !FPFastMathDefaultInfo.SignedZeroInfNanPreserve &&
828 !FPFastMathDefaultInfo.FPFastMathDefault)
829 continue;
830
831 // Retrieve the constant instruction for the immediate value.
832 auto It = ConstMap.find(Flags);
833 if (It == ConstMap.end())
834 report_fatal_error("Expected constant instruction for FP Fast Math "
835 "Mode operand of FPFastMathDefault execution mode.");
836 const MachineInstr *ConstMI = It->second;
837 MCRegister ConstReg = MAI->getRegisterAlias(
838 ConstMI->getMF(), ConstMI->getOperand(0).getReg());
839 Inst.addOperand(MCOperand::createReg(ConstReg));
840 outputMCInst(Inst);
841 }
842 }
843}
844
845void SPIRVAsmPrinter::outputModuleSections() {
846 const Module *M = MMI->getModule();
847 // Get the global subtarget to output module-level info.
848 ST = static_cast<const SPIRVTargetMachine &>(TM).getSubtargetImpl();
849 TII = ST->getInstrInfo();
850 MAI = &getAnalysis<SPIRVModuleAnalysis>().MAI;
851 assert(ST && TII && MAI && M && "Module analysis is required");
852
853 // Let the NSDI handler add its extension and ext inst import entry to MAI
854 // before the module header sections are emitted.
855 if (NSDebugHandler)
856 NSDebugHandler->prepareModuleOutput(*ST, *MAI);
857
858 // Output instructions according to the Logical Layout of a Module:
859 // 1,2. All OpCapability instructions, then optional OpExtension
860 // instructions.
861 outputGlobalRequirements();
862 // 3. Optional OpExtInstImport instructions.
863 outputOpExtInstImports(*M);
864 // 4. The single required OpMemoryModel instruction.
865 outputOpMemoryModel();
866 // 5. All entry point declarations, using OpEntryPoint.
867 outputEntryPoints();
868 // 6. Execution-mode declarations, using OpExecutionMode or
869 // OpExecutionModeId.
870 outputExecutionMode(*M);
871 // 7a. Debug: all OpString, OpSourceExtension, OpSource, and
872 // OpSourceContinued, without forward references.
873 outputDebugSourceAndStrings(*M);
874 // 7b. Debug: all OpName and all OpMemberName.
875 outputModuleSection(SPIRV::MB_DebugNames);
876 // 7c. Debug: all OpModuleProcessed instructions.
877 outputModuleSection(SPIRV::MB_DebugModuleProcessed);
878 // xxx. SPV_INTEL_memory_access_aliasing instructions go before 8.
879 // "All annotation instructions"
880 outputModuleSection(SPIRV::MB_AliasingInsts);
881 // 8. All annotation instructions (all decorations).
882 outputAnnotations(*M);
883 // 9. All type declarations (OpTypeXXX instructions), all constant
884 // instructions, and all global variable declarations. This section is
885 // the first section to allow use of: OpLine and OpNoLine debug information;
886 // non-semantic instructions with OpExtInst.
887 outputModuleSection(SPIRV::MB_TypeConstVars);
888 // 10. All global NonSemantic.Shader.DebugInfo.100 instructions. The
889 // SPIRVNonSemanticDebugHandler emits these directly as MCInsts; the
890 // MB_NonSemanticGlobalDI section in MAI is intentionally left empty.
891 if (NSDebugHandler)
892 NSDebugHandler->emitNonSemanticGlobalDebugInfo(*MAI);
893 // 11. All function declarations (functions without a body).
894 outputExtFuncDecls();
895 // 12. All function definitions (functions with a body).
896 // This is done in regular function output.
897}
898
899bool SPIRVAsmPrinter::doInitialization(Module &M) {
900 ModuleSectionsEmitted = false;
901 // Register the NSDI handler before calling the base class so that
902 // AsmPrinter::doInitialization() calls Handler->beginModule(M) for it.
903 if (M.getNamedMetadata("llvm.dbg.cu")) {
904 auto Handler = std::make_unique<SPIRVNonSemanticDebugHandler>(*this);
905 NSDebugHandler = Handler.get();
906 addAsmPrinterHandler(std::move(Handler));
907 }
908 // We need to call the parent's one explicitly.
910}
911
912char SPIRVAsmPrinter::ID = 0;
913
914INITIALIZE_PASS(SPIRVAsmPrinter, "spirv-asm-printer", "SPIRV Assembly Printer",
915 false, false)
916
917// Force static initialization.
919LLVMInitializeSPIRVAsmPrinter() {
923}
#define Success
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
MachineBasicBlock & MBB
#define X(NUM, ENUM, NAME)
Definition ELF.h:851
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
#define LLVM_ABI
Definition Compiler.h:213
#define LLVM_EXTERNAL_VISIBILITY
Definition Compiler.h:132
This file defines the DenseMap class.
const HexagonInstrInfo * TII
IRTranslator LLVM IR MI
#define F(x, y, z)
Definition MD5.cpp:54
#define I(x, y, z)
Definition MD5.cpp:57
Machine Check Debug Module
This file declares the MachineConstantPool class which is an abstract constant pool to keep track of ...
Register Reg
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
Definition PassSupport.h:56
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
Definition SPIRVUtils.h:533
static bool printOperand(raw_ostream &OS, const SelectionDAG *G, const SDValue Value)
static TableGen::Emitter::Opt Y("gen-skeleton-entry", EmitSkeleton, "Generate example skeleton entry")
static std::optional< unsigned > getOpcode(ArrayRef< VPValue * > Values)
Returns the opcode of Values or ~0 if they do not all agree.
Definition VPlanSLP.cpp:247
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.
Definition AsmPrinter.h:91
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.
Functions, function parameters, and return types can have attributes to indicate how they should be t...
Definition Attributes.h:105
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.
Definition Attributes.h:261
This is the shared class of boolean and integer constants.
Definition Constants.h:87
This is an important base class in LLVM.
Definition Constant.h:43
iterator find(const_arg_type_t< KeyT > Val)
Definition DenseMap.h:178
iterator end()
Definition DenseMap.h:81
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.
Definition MCInst.h:188
void addOperand(const MCOperand Op)
Definition MCInst.h:215
void setOpcode(unsigned Op)
Definition MCInst.h:201
static MCOperand createReg(MCRegister Reg)
Definition MCInst.h:138
static MCOperand createImm(int64_t Val)
Definition MCInst.h:145
Wrapper class representing physical registers. Should be passed by value.
Definition MCRegister.h:41
constexpr bool isValid() const
Definition MCRegister.h:84
StringRef getName() const
getName - Get the symbol name.
Definition MCSymbol.h:188
Metadata node.
Definition Metadata.h:1080
ArrayRef< MDOperand > operands() const
Definition Metadata.h:1442
Tracking metadata reference owned by Metadata.
Definition Metadata.h:902
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...
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
int64_t getImm() 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 MachineInstr * getVRegDef(Register Reg) const
getVRegDef - Return the machine instr that defines the specified virtual register or null if none is ...
A Module instance is used to store all the information related to an LLVM module.
Definition Module.h:67
constexpr bool isValid() const
Definition Register.h:112
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...
const SPIRVInstrInfo * getInstrInfo() const override
bool isAtLeastSPIRVVer(VersionTuple VerToCompareTo) const
SPIRVGlobalRegistry * getSPIRVGlobalRegistry() const
VersionTuple getSPIRVVersion() const
unsigned getBound() 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.
StringRef - Represent a constant reference to a string, i.e.
Definition StringRef.h:55
std::pair< StringRef, StringRef > split(char Separator) const
Split into two substrings around the first occurrence of a separator character.
Definition StringRef.h:730
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.
Definition Type.h:46
op_range operands()
Definition User.h:267
Value * getOperand(unsigned i) const
Definition User.h:207
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.
Definition Value.cpp:709
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)
Definition DenseSet.h:202
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition raw_ostream.h:53
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
Definition CallingConv.h:24
@ C
The default llvm calling convention, compatible with C.
Definition CallingConv.h:34
NodeAddr< NodeBase * > Node
Definition RDFGraph.h:381
This is an optimization pass for GlobalISel generic memory operations.
FunctionAddr VTableAddr Value
Definition InstrProf.h:137
Target & getTheSPIRV32Target()
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
Definition Casting.h:643
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)
MachineInstr * getImm(const MachineOperand &MO, const MachineRegisterInfo *MRI)
LLVM_ABI void report_fatal_error(Error Err, bool gen_crash_diag=true)
Definition Error.cpp:163
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
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
Definition Casting.h:559
Type * getMDOperandAsType(const MDNode *N, unsigned I)
void addStringImm(const StringRef &Str, MCInst &Inst)
RegisterAsmPrinter - Helper template for registering a target specific assembly printer,...
static size_t computeFPFastMathDefaultInfoVecIndex(size_t BitWidth)
Definition SPIRVUtils.h:150
MCRegister getGlobalObjReg(const GlobalObject *GO)