xref: /freebsd/contrib/llvm-project/llvm/lib/Target/SPIRV/MCTargetDesc/SPIRVInstPrinter.h (revision e6bfd18d21b225af6a0ed67ceeaf1293b7b9eba5)
1 //===-- SPIRVInstPrinter.h - Output SPIR-V MCInsts as ASM -------*- 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 class prints a SPIR-V MCInst to a .s file.
10 //
11 //===----------------------------------------------------------------------===//
12 
13 #ifndef LLVM_LIB_TARGET_SPIRV_INSTPRINTER_SPIRVINSTPRINTER_H
14 #define LLVM_LIB_TARGET_SPIRV_INSTPRINTER_SPIRVINSTPRINTER_H
15 
16 #include "llvm/MC/MCInstPrinter.h"
17 
18 namespace llvm {
19 class SPIRVInstPrinter : public MCInstPrinter {
20 private:
21   void recordOpExtInstImport(const MCInst *MI);
22 
23 public:
24   using MCInstPrinter::MCInstPrinter;
25 
26   void printInst(const MCInst *MI, uint64_t Address, StringRef Annot,
27                  const MCSubtargetInfo &STI, raw_ostream &OS) override;
28   void printOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O,
29                     const char *Modifier = nullptr);
30 
31   void printStringImm(const MCInst *MI, unsigned OpNo, raw_ostream &O);
32 
33   void printOpDecorate(const MCInst *MI, raw_ostream &O);
34   void printOpExtInst(const MCInst *MI, raw_ostream &O);
35   void printRemainingVariableOps(const MCInst *MI, unsigned StartIndex,
36                                  raw_ostream &O, bool SkipFirstSpace = false,
37                                  bool SkipImmediates = false);
38   void printOpConstantVarOps(const MCInst *MI, unsigned StartIndex,
39                              raw_ostream &O);
40 
41   void printExtInst(const MCInst *MI, unsigned OpNo, raw_ostream &O);
42 
43   // SPIR-V enumerations printing.
44   void printCapability(const MCInst *MI, unsigned OpNo, raw_ostream &O);
45   void printSourceLanguage(const MCInst *MI, unsigned OpNo, raw_ostream &O);
46   void printExecutionModel(const MCInst *MI, unsigned OpNo, raw_ostream &O);
47   void printAddressingModel(const MCInst *MI, unsigned OpNo, raw_ostream &O);
48   void printMemoryModel(const MCInst *MI, unsigned OpNo, raw_ostream &O);
49   void printExecutionMode(const MCInst *MI, unsigned OpNo, raw_ostream &O);
50   void printStorageClass(const MCInst *MI, unsigned OpNo, raw_ostream &O);
51   void printDim(const MCInst *MI, unsigned OpNo, raw_ostream &O);
52 
53   void printSamplerAddressingMode(const MCInst *MI, unsigned OpNo,
54                                   raw_ostream &O);
55   void printSamplerFilterMode(const MCInst *MI, unsigned OpNo, raw_ostream &O);
56 
57   void printImageFormat(const MCInst *MI, unsigned OpNo, raw_ostream &O);
58   void printImageChannelOrder(const MCInst *MI, unsigned OpNo, raw_ostream &O);
59   void printImageChannelDataType(const MCInst *MI, unsigned OpNo,
60                                  raw_ostream &O);
61   void printImageOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O);
62 
63   void printFPFastMathMode(const MCInst *MI, unsigned OpNo, raw_ostream &O);
64   void printFPRoundingMode(const MCInst *MI, unsigned OpNo, raw_ostream &O);
65 
66   void printLinkageType(const MCInst *MI, unsigned OpNo, raw_ostream &O);
67   void printAccessQualifier(const MCInst *MI, unsigned OpNo, raw_ostream &O);
68   void printFunctionParameterAttribute(const MCInst *MI, unsigned OpNo,
69                                        raw_ostream &O);
70 
71   void printDecoration(const MCInst *MI, unsigned OpNo, raw_ostream &O);
72   void printBuiltIn(const MCInst *MI, unsigned OpNo, raw_ostream &O);
73 
74   void printSelectionControl(const MCInst *MI, unsigned OpNo, raw_ostream &O);
75   void printLoopControl(const MCInst *MI, unsigned OpNo, raw_ostream &O);
76   void printFunctionControl(const MCInst *MI, unsigned OpNo, raw_ostream &O);
77 
78   void printMemorySemantics(const MCInst *MI, unsigned OpNo, raw_ostream &O);
79   void printMemoryOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O);
80 
81   void printScope(const MCInst *MI, unsigned OpNo, raw_ostream &O);
82   void printGroupOperation(const MCInst *MI, unsigned OpNo, raw_ostream &O);
83 
84   void printKernelEnqueueFlags(const MCInst *MI, unsigned OpNo, raw_ostream &O);
85   void printKernelProfilingInfo(const MCInst *MI, unsigned OpNo,
86                                 raw_ostream &O);
87   // Autogenerated by tblgen.
88   std::pair<const char *, uint64_t> getMnemonic(const MCInst *MI) override;
89   void printInstruction(const MCInst *MI, uint64_t Address, raw_ostream &O);
90   static const char *getRegisterName(unsigned RegNo);
91 };
92 } // namespace llvm
93 
94 #endif // LLVM_LIB_TARGET_SPIRV_INSTPRINTER_SPIRVINSTPRINTER_H
95