xref: /freebsd/contrib/llvm-project/llvm/lib/Target/SPIRV/MCTargetDesc/SPIRVInstPrinter.h (revision bdd1243df58e60e85101c09001d9812a789b6bc4)
181ad6265SDimitry Andric //===-- SPIRVInstPrinter.h - Output SPIR-V MCInsts as ASM -------*- C++ -*-===//
281ad6265SDimitry Andric //
381ad6265SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
481ad6265SDimitry Andric // See https://llvm.org/LICENSE.txt for license information.
581ad6265SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
681ad6265SDimitry Andric //
781ad6265SDimitry Andric //===----------------------------------------------------------------------===//
881ad6265SDimitry Andric //
981ad6265SDimitry Andric // This class prints a SPIR-V MCInst to a .s file.
1081ad6265SDimitry Andric //
1181ad6265SDimitry Andric //===----------------------------------------------------------------------===//
1281ad6265SDimitry Andric 
1381ad6265SDimitry Andric #ifndef LLVM_LIB_TARGET_SPIRV_INSTPRINTER_SPIRVINSTPRINTER_H
1481ad6265SDimitry Andric #define LLVM_LIB_TARGET_SPIRV_INSTPRINTER_SPIRVINSTPRINTER_H
1581ad6265SDimitry Andric 
16*bdd1243dSDimitry Andric #include "MCTargetDesc/SPIRVBaseInfo.h"
17*bdd1243dSDimitry Andric #include "llvm/ADT/DenseSet.h"
1881ad6265SDimitry Andric #include "llvm/MC/MCInstPrinter.h"
1981ad6265SDimitry Andric 
2081ad6265SDimitry Andric namespace llvm {
2181ad6265SDimitry Andric class SPIRVInstPrinter : public MCInstPrinter {
2281ad6265SDimitry Andric private:
23*bdd1243dSDimitry Andric   SmallDenseMap<unsigned, SPIRV::InstructionSet::InstructionSet> ExtInstSetIDs;
2481ad6265SDimitry Andric   void recordOpExtInstImport(const MCInst *MI);
2581ad6265SDimitry Andric 
2681ad6265SDimitry Andric public:
2781ad6265SDimitry Andric   using MCInstPrinter::MCInstPrinter;
2881ad6265SDimitry Andric 
2981ad6265SDimitry Andric   void printInst(const MCInst *MI, uint64_t Address, StringRef Annot,
3081ad6265SDimitry Andric                  const MCSubtargetInfo &STI, raw_ostream &OS) override;
3181ad6265SDimitry Andric   void printOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O,
3281ad6265SDimitry Andric                     const char *Modifier = nullptr);
3381ad6265SDimitry Andric 
3481ad6265SDimitry Andric   void printStringImm(const MCInst *MI, unsigned OpNo, raw_ostream &O);
3581ad6265SDimitry Andric 
3681ad6265SDimitry Andric   void printOpDecorate(const MCInst *MI, raw_ostream &O);
3781ad6265SDimitry Andric   void printOpExtInst(const MCInst *MI, raw_ostream &O);
3881ad6265SDimitry Andric   void printRemainingVariableOps(const MCInst *MI, unsigned StartIndex,
3981ad6265SDimitry Andric                                  raw_ostream &O, bool SkipFirstSpace = false,
4081ad6265SDimitry Andric                                  bool SkipImmediates = false);
4181ad6265SDimitry Andric   void printOpConstantVarOps(const MCInst *MI, unsigned StartIndex,
4281ad6265SDimitry Andric                              raw_ostream &O);
4381ad6265SDimitry Andric 
44*bdd1243dSDimitry Andric   void printExtension(const MCInst *MI, unsigned OpNo, raw_ostream &O);
45*bdd1243dSDimitry Andric   template <SPIRV::OperandCategory::OperandCategory category>
46*bdd1243dSDimitry Andric   void printSymbolicOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O);
4781ad6265SDimitry Andric 
4881ad6265SDimitry Andric   // Autogenerated by tblgen.
4981ad6265SDimitry Andric   std::pair<const char *, uint64_t> getMnemonic(const MCInst *MI) override;
5081ad6265SDimitry Andric   void printInstruction(const MCInst *MI, uint64_t Address, raw_ostream &O);
51*bdd1243dSDimitry Andric   static const char *getRegisterName(MCRegister Reg);
5281ad6265SDimitry Andric };
5381ad6265SDimitry Andric } // namespace llvm
5481ad6265SDimitry Andric 
5581ad6265SDimitry Andric #endif // LLVM_LIB_TARGET_SPIRV_INSTPRINTER_SPIRVINSTPRINTER_H
56