106c3fb27SDimitry Andric //===-- RISCVInstPrinter.h - Convert RISC-V MCInst to asm syntax --*- C++ -*--// 20b57cec5SDimitry Andric // 30b57cec5SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 40b57cec5SDimitry Andric // See https://llvm.org/LICENSE.txt for license information. 50b57cec5SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 60b57cec5SDimitry Andric // 70b57cec5SDimitry Andric //===----------------------------------------------------------------------===// 80b57cec5SDimitry Andric // 906c3fb27SDimitry Andric // This class prints a RISC-V MCInst to a .s file. 100b57cec5SDimitry Andric // 110b57cec5SDimitry Andric //===----------------------------------------------------------------------===// 120b57cec5SDimitry Andric 130b57cec5SDimitry Andric #ifndef LLVM_LIB_TARGET_RISCV_MCTARGETDESC_RISCVINSTPRINTER_H 140b57cec5SDimitry Andric #define LLVM_LIB_TARGET_RISCV_MCTARGETDESC_RISCVINSTPRINTER_H 150b57cec5SDimitry Andric 160b57cec5SDimitry Andric #include "MCTargetDesc/RISCVMCTargetDesc.h" 170b57cec5SDimitry Andric #include "llvm/MC/MCInstPrinter.h" 180b57cec5SDimitry Andric 190b57cec5SDimitry Andric namespace llvm { 200b57cec5SDimitry Andric 210b57cec5SDimitry Andric class RISCVInstPrinter : public MCInstPrinter { 220b57cec5SDimitry Andric public: RISCVInstPrinter(const MCAsmInfo & MAI,const MCInstrInfo & MII,const MCRegisterInfo & MRI)230b57cec5SDimitry Andric RISCVInstPrinter(const MCAsmInfo &MAI, const MCInstrInfo &MII, 240b57cec5SDimitry Andric const MCRegisterInfo &MRI) 250b57cec5SDimitry Andric : MCInstPrinter(MAI, MII, MRI) {} 260b57cec5SDimitry Andric 278bcb0991SDimitry Andric bool applyTargetSpecificCLOption(StringRef Opt) override; 288bcb0991SDimitry Andric 29480093f4SDimitry Andric void printInst(const MCInst *MI, uint64_t Address, StringRef Annot, 30480093f4SDimitry Andric const MCSubtargetInfo &STI, raw_ostream &O) override; 31bdd1243dSDimitry Andric void printRegName(raw_ostream &O, MCRegister Reg) const override; 320b57cec5SDimitry Andric 330b57cec5SDimitry Andric void printOperand(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI, 340b57cec5SDimitry Andric raw_ostream &O, const char *Modifier = nullptr); 35e8d8bef9SDimitry Andric void printBranchOperand(const MCInst *MI, uint64_t Address, unsigned OpNo, 36e8d8bef9SDimitry Andric const MCSubtargetInfo &STI, raw_ostream &O); 370b57cec5SDimitry Andric void printCSRSystemRegister(const MCInst *MI, unsigned OpNo, 380b57cec5SDimitry Andric const MCSubtargetInfo &STI, raw_ostream &O); 390b57cec5SDimitry Andric void printFenceArg(const MCInst *MI, unsigned OpNo, 400b57cec5SDimitry Andric const MCSubtargetInfo &STI, raw_ostream &O); 410b57cec5SDimitry Andric void printFRMArg(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI, 420b57cec5SDimitry Andric raw_ostream &O); 435f757f3fSDimitry Andric void printFRMArgLegacy(const MCInst *MI, unsigned OpNo, 445f757f3fSDimitry Andric const MCSubtargetInfo &STI, raw_ostream &O); 4506c3fb27SDimitry Andric void printFPImmOperand(const MCInst *MI, unsigned OpNo, 4606c3fb27SDimitry Andric const MCSubtargetInfo &STI, raw_ostream &O); 4781ad6265SDimitry Andric void printZeroOffsetMemOp(const MCInst *MI, unsigned OpNo, 480b57cec5SDimitry Andric const MCSubtargetInfo &STI, raw_ostream &O); 495ffd83dbSDimitry Andric void printVTypeI(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI, 505ffd83dbSDimitry Andric raw_ostream &O); 515ffd83dbSDimitry Andric void printVMaskReg(const MCInst *MI, unsigned OpNo, 525ffd83dbSDimitry Andric const MCSubtargetInfo &STI, raw_ostream &O); 5306c3fb27SDimitry Andric void printRlist(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI, 5406c3fb27SDimitry Andric raw_ostream &O); 55*0fca6ea1SDimitry Andric void printStackAdj(const MCInst *MI, unsigned OpNo, 56*0fca6ea1SDimitry Andric const MCSubtargetInfo &STI, raw_ostream &O, 57*0fca6ea1SDimitry Andric bool Negate = false); printNegStackAdj(const MCInst * MI,unsigned OpNo,const MCSubtargetInfo & STI,raw_ostream & O)58*0fca6ea1SDimitry Andric void printNegStackAdj(const MCInst *MI, unsigned OpNo, 59*0fca6ea1SDimitry Andric const MCSubtargetInfo &STI, raw_ostream &O) { 60*0fca6ea1SDimitry Andric return printStackAdj(MI, OpNo, STI, O, /*Negate*/ true); 61*0fca6ea1SDimitry Andric } 625f757f3fSDimitry Andric void printRegReg(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI, 635f757f3fSDimitry Andric raw_ostream &O); 640b57cec5SDimitry Andric // Autogenerated by tblgen. 65e8d8bef9SDimitry Andric std::pair<const char *, uint64_t> getMnemonic(const MCInst *MI) override; 66480093f4SDimitry Andric void printInstruction(const MCInst *MI, uint64_t Address, 67480093f4SDimitry Andric const MCSubtargetInfo &STI, raw_ostream &O); 685ffd83dbSDimitry Andric bool printAliasInstr(const MCInst *MI, uint64_t Address, 695ffd83dbSDimitry Andric const MCSubtargetInfo &STI, raw_ostream &O); 705ffd83dbSDimitry Andric void printCustomAliasOperand(const MCInst *MI, uint64_t Address, 715ffd83dbSDimitry Andric unsigned OpIdx, unsigned PrintMethodIdx, 720b57cec5SDimitry Andric const MCSubtargetInfo &STI, raw_ostream &O); 73bdd1243dSDimitry Andric static const char *getRegisterName(MCRegister Reg); 74bdd1243dSDimitry Andric static const char *getRegisterName(MCRegister Reg, unsigned AltIdx); 750b57cec5SDimitry Andric }; 760b57cec5SDimitry Andric } // namespace llvm 770b57cec5SDimitry Andric 780b57cec5SDimitry Andric #endif 79