diff --git a/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp b/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp --- a/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp +++ b/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp @@ -45,10 +45,6 @@ #define DEBUG_TYPE "riscv-asm-parser" -// Include the auto-generated portion of the compress emitter. -#define GEN_COMPRESS_INSTR -#include "RISCVGenCompressInstEmitter.inc" - STATISTIC(RISCVNumInstrsCompressed, "Number of RISC-V Compressed instructions emitted"); @@ -2316,7 +2312,7 @@ void RISCVAsmParser::emitToStreamer(MCStreamer &S, const MCInst &Inst) { MCInst CInst; - bool Res = compressInst(CInst, Inst, getSTI()); + bool Res = RISCVRVC::compress(CInst, Inst, getSTI()); if (Res) ++RISCVNumInstrsCompressed; S.emitInstruction((Res ? CInst : Inst), getSTI()); diff --git a/llvm/lib/Target/RISCV/MCTargetDesc/RISCVBaseInfo.h b/llvm/lib/Target/RISCV/MCTargetDesc/RISCVBaseInfo.h --- a/llvm/lib/Target/RISCV/MCTargetDesc/RISCVBaseInfo.h +++ b/llvm/lib/Target/RISCV/MCTargetDesc/RISCVBaseInfo.h @@ -467,6 +467,11 @@ } // namespace RISCVVType +namespace RISCVRVC { +bool compress(MCInst &OutInst, const MCInst &MI, const MCSubtargetInfo &STI); +bool uncompress(MCInst &OutInst, const MCInst &MI, const MCSubtargetInfo &STI); +} // namespace RISCVRVC + } // namespace llvm #endif diff --git a/llvm/lib/Target/RISCV/MCTargetDesc/RISCVBaseInfo.cpp b/llvm/lib/Target/RISCV/MCTargetDesc/RISCVBaseInfo.cpp --- a/llvm/lib/Target/RISCV/MCTargetDesc/RISCVBaseInfo.cpp +++ b/llvm/lib/Target/RISCV/MCTargetDesc/RISCVBaseInfo.cpp @@ -14,6 +14,8 @@ #include "RISCVBaseInfo.h" #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/Triple.h" +#include "llvm/MC/MCInst.h" +#include "llvm/MC/MCRegisterInfo.h" #include "llvm/MC/MCSubtargetInfo.h" #include "llvm/Support/RISCVISAInfo.h" #include "llvm/Support/TargetParser.h" @@ -197,4 +199,19 @@ return (SEW * 8) / LMul; } +// Include the auto-generated portion of the compress emitter. +#define GEN_UNCOMPRESS_INSTR +#define GEN_COMPRESS_INSTR +#include "RISCVGenCompressInstEmitter.inc" + +bool RISCVRVC::compress(MCInst &OutInst, const MCInst &MI, + const MCSubtargetInfo &STI) { + return compressInst(OutInst, MI, STI); +} + +bool RISCVRVC::uncompress(MCInst &OutInst, const MCInst &MI, + const MCSubtargetInfo &STI) { + return uncompressInst(OutInst, MI, STI); +} + } // namespace llvm diff --git a/llvm/lib/Target/RISCV/MCTargetDesc/RISCVInstPrinter.cpp b/llvm/lib/Target/RISCV/MCTargetDesc/RISCVInstPrinter.cpp --- a/llvm/lib/Target/RISCV/MCTargetDesc/RISCVInstPrinter.cpp +++ b/llvm/lib/Target/RISCV/MCTargetDesc/RISCVInstPrinter.cpp @@ -30,10 +30,6 @@ #define PRINT_ALIAS_INSTR #include "RISCVGenAsmWriter.inc" -// Include the auto-generated portion of the compress emitter. -#define GEN_UNCOMPRESS_INSTR -#include "RISCVGenCompressInstEmitter.inc" - static cl::opt NoAliases("riscv-no-aliases", cl::desc("Disable the emission of assembler pseudo instructions"), @@ -70,7 +66,7 @@ const MCInst *NewMI = MI; MCInst UncompressedMI; if (PrintAliases && !NoAliases) - Res = uncompressInst(UncompressedMI, *MI, STI); + Res = RISCVRVC::uncompress(UncompressedMI, *MI, STI); if (Res) NewMI = const_cast(&UncompressedMI); if (!PrintAliases || NoAliases || !printAliasInstr(NewMI, Address, STI, O)) diff --git a/llvm/lib/Target/RISCV/RISCVAsmPrinter.cpp b/llvm/lib/Target/RISCV/RISCVAsmPrinter.cpp --- a/llvm/lib/Target/RISCV/RISCVAsmPrinter.cpp +++ b/llvm/lib/Target/RISCV/RISCVAsmPrinter.cpp @@ -89,11 +89,9 @@ }; } -#define GEN_COMPRESS_INSTR -#include "RISCVGenCompressInstEmitter.inc" void RISCVAsmPrinter::EmitToStreamer(MCStreamer &S, const MCInst &Inst) { MCInst CInst; - bool Res = compressInst(CInst, Inst, *STI); + bool Res = RISCVRVC::compress(CInst, Inst, *STI); if (Res) ++RISCVNumInstrsCompressed; AsmPrinter::EmitToStreamer(*OutStreamer, Res ? CInst : Inst);