1//===-- RISCVInstPrinter.h - Convert RISC-V 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 RISC-V 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/RISCVMCOptions.h"
17#include "MCTargetDesc/RISCVMCTargetDesc.h"
18#include "llvm/MC/MCInstPrinter.h"
19
20namespace llvm {
21
22class RISCVInstPrinter : public MCInstPrinter {
23 const RISCVMCOptions &CLOpts;
24
25public:
26 RISCVInstPrinter(const MCAsmInfo &MAI, const MCInstrInfo &MII,
27 const MCRegisterInfo &MRI);
28
29 bool applyTargetSpecificCLOption(StringRef Opt) override;
30
31 void printInst(const MCInst *MI, uint64_t Address, StringRef Annot,
32 const MCSubtargetInfo &STI, raw_ostream &O) override;
33 void printRegName(raw_ostream &O, MCRegister Reg) override;
34
35 void printOperand(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
36 raw_ostream &O);
37 void printBranchOperand(const MCInst *MI, uint64_t Address, unsigned OpNo,
38 const MCSubtargetInfo &STI, raw_ostream &O);
39 void printCSRSystemRegister(const MCInst *MI, unsigned OpNo,
40 const MCSubtargetInfo &STI, raw_ostream &O);
41 void printFenceArg(const MCInst *MI, unsigned OpNo,
42 const MCSubtargetInfo &STI, raw_ostream &O);
43 void printSMTVType(const MCInst *MI, unsigned OpNo,
44 const MCSubtargetInfo &STI, raw_ostream &O);
45 void printFRMArg(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
46 raw_ostream &O);
47 void printFRMArgLegacy(const MCInst *MI, unsigned OpNo,
48 const MCSubtargetInfo &STI, raw_ostream &O);
49 void printFPImmOperand(const MCInst *MI, unsigned OpNo,
50 const MCSubtargetInfo &STI, raw_ostream &O);
51 void printZeroOffsetMemOp(const MCInst *MI, unsigned OpNo,
52 const MCSubtargetInfo &STI, raw_ostream &O);
53 void printVTypeI(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
54 raw_ostream &O);
55 void printXSfmmVType(const MCInst *MI, unsigned OpNo,
56 const MCSubtargetInfo &STI, raw_ostream &O);
57 void printVMaskReg(const MCInst *MI, unsigned OpNo,
58 const MCSubtargetInfo &STI, raw_ostream &O);
59 void printVScaleReg(const MCInst *MI, unsigned OpNo,
60 const MCSubtargetInfo &STI, raw_ostream &O);
61 void printTileLambda(const MCInst *MI, unsigned OpNo,
62 const MCSubtargetInfo &STI, raw_ostream &O);
63 void printImm(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
64 raw_ostream &O);
65 void printRegList(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
66 raw_ostream &O);
67 void printStackAdj(const MCInst *MI, unsigned OpNo,
68 const MCSubtargetInfo &STI, raw_ostream &O,
69 bool Negate = false);
70 void printNegStackAdj(const MCInst *MI, unsigned OpNo,
71 const MCSubtargetInfo &STI, raw_ostream &O) {
72 return printStackAdj(MI, OpNo, STI, O, /*Negate*/ Negate: true);
73 }
74 void printRegReg(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
75 raw_ostream &O);
76 // Autogenerated by tblgen.
77 std::pair<const char *, uint64_t>
78 getMnemonic(const MCInst &MI) const override;
79 void printInstruction(const MCInst *MI, uint64_t Address,
80 const MCSubtargetInfo &STI, raw_ostream &O);
81 bool printAliasInstr(const MCInst *MI, uint64_t Address,
82 const MCSubtargetInfo &STI, raw_ostream &O);
83 void printCustomAliasOperand(const MCInst *MI, uint64_t Address,
84 unsigned OpIdx, unsigned PrintMethodIdx,
85 const MCSubtargetInfo &STI, raw_ostream &O);
86 static const char *getRegisterName(const RISCVMCOptions &CLOpts,
87 MCRegister Reg);
88 static const char *getRegisterName(MCRegister Reg, unsigned AltIdx);
89};
90} // namespace llvm
91
92#endif
93