xref: /freebsd/contrib/llvm-project/llvm/lib/Target/RISCV/MCTargetDesc/RISCVInstPrinter.h (revision 162ae9c834f6d9f9cb443bd62cceb23e0b5fef48)
1 //===-- RISCVInstPrinter.h - Convert RISCV MCInst to asm syntax ---*- 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 RISCV MCInst to a .s file.
10 //
11 //===----------------------------------------------------------------------===//
12 
13 #ifndef LLVM_LIB_TARGET_RISCV_MCTARGETDESC_RISCVINSTPRINTER_H
14 #define LLVM_LIB_TARGET_RISCV_MCTARGETDESC_RISCVINSTPRINTER_H
15 
16 #include "MCTargetDesc/RISCVMCTargetDesc.h"
17 #include "llvm/MC/MCInstPrinter.h"
18 
19 namespace llvm {
20 class MCOperand;
21 
22 class RISCVInstPrinter : public MCInstPrinter {
23 public:
24   RISCVInstPrinter(const MCAsmInfo &MAI, const MCInstrInfo &MII,
25                    const MCRegisterInfo &MRI)
26       : MCInstPrinter(MAI, MII, MRI) {}
27 
28   void printInst(const MCInst *MI, raw_ostream &O, StringRef Annot,
29                  const MCSubtargetInfo &STI) override;
30   void printRegName(raw_ostream &O, unsigned RegNo) const override;
31 
32   void printOperand(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
33                     raw_ostream &O, const char *Modifier = nullptr);
34   void printCSRSystemRegister(const MCInst *MI, unsigned OpNo,
35                               const MCSubtargetInfo &STI, raw_ostream &O);
36   void printFenceArg(const MCInst *MI, unsigned OpNo,
37                      const MCSubtargetInfo &STI, raw_ostream &O);
38   void printFRMArg(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
39                    raw_ostream &O);
40   void printAtomicMemOp(const MCInst *MI, unsigned OpNo,
41                         const MCSubtargetInfo &STI, raw_ostream &O);
42 
43   // Autogenerated by tblgen.
44   void printInstruction(const MCInst *MI, const MCSubtargetInfo &STI,
45                         raw_ostream &O);
46   bool printAliasInstr(const MCInst *MI, const MCSubtargetInfo &STI,
47                        raw_ostream &O);
48   void printCustomAliasOperand(const MCInst *MI, unsigned OpIdx,
49                                unsigned PrintMethodIdx,
50                                const MCSubtargetInfo &STI, raw_ostream &O);
51   static const char *getRegisterName(unsigned RegNo,
52                                      unsigned AltIdx = RISCV::ABIRegAltName);
53 };
54 } // namespace llvm
55 
56 #endif
57