58 lines · c
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-exception6//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_H14#define LLVM_LIB_TARGET_SPIRV_INSTPRINTER_SPIRVINSTPRINTER_H15 16#include "MCTargetDesc/SPIRVBaseInfo.h"17#include "llvm/ADT/DenseSet.h"18#include "llvm/MC/MCInstPrinter.h"19#include "llvm/MC/MCRegister.h"20 21namespace llvm {22class SPIRVInstPrinter : public MCInstPrinter {23private:24 SmallDenseMap<MCRegister, SPIRV::InstructionSet::InstructionSet> ExtInstSetIDs;25 void recordOpExtInstImport(const MCInst *MI);26 27public:28 using MCInstPrinter::MCInstPrinter;29 30 void printInst(const MCInst *MI, uint64_t Address, StringRef Annot,31 const MCSubtargetInfo &STI, raw_ostream &OS) override;32 void printOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O);33 34 void printStringImm(const MCInst *MI, unsigned OpNo, raw_ostream &O);35 36 void printOpDecorate(const MCInst *MI, raw_ostream &O);37 void printOpExtInst(const MCInst *MI, raw_ostream &O);38 void printUnknownType(const MCInst *MI, raw_ostream &O);39 void printRemainingVariableOps(const MCInst *MI, unsigned StartIndex,40 raw_ostream &O, bool SkipFirstSpace = false,41 bool SkipImmediates = false);42 void printOpConstantVarOps(const MCInst *MI, unsigned StartIndex,43 raw_ostream &O);44 45 void printExtension(const MCInst *MI, unsigned OpNo, raw_ostream &O);46 template <SPIRV::OperandCategory::OperandCategory category>47 void printSymbolicOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O);48 49 // Autogenerated by tblgen.50 std::pair<const char *, uint64_t>51 getMnemonic(const MCInst &MI) const override;52 void printInstruction(const MCInst *MI, uint64_t Address, raw_ostream &O);53 static const char *getRegisterName(MCRegister Reg);54};55} // namespace llvm56 57#endif // LLVM_LIB_TARGET_SPIRV_INSTPRINTER_SPIRVINSTPRINTER_H58