Skip to content

Commit

Permalink
[RISCV] Make EmitToStreamer return whether Inst is compressed
Browse files Browse the repository at this point in the history
This is helpful to reduce calls of `RISCVRVC::compress` in llvm#77337.

Reviewers: asb, lukel97, topperc

Reviewed By: topperc

Pull Request: llvm#88120
  • Loading branch information
wangpc-pp committed Apr 10, 2024
1 parent bcf849b commit 8dc006e
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions llvm/lib/Target/RISCV/RISCVAsmPrinter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ class RISCVAsmPrinter : public AsmPrinter {
bool PrintAsmMemoryOperand(const MachineInstr *MI, unsigned OpNo,
const char *ExtraCode, raw_ostream &OS) override;

void EmitToStreamer(MCStreamer &S, const MCInst &Inst);
// Returns whether Inst is compressed.
bool EmitToStreamer(MCStreamer &S, const MCInst &Inst);
bool emitPseudoExpansionLowering(MCStreamer &OutStreamer,
const MachineInstr *MI);

Expand Down Expand Up @@ -180,12 +181,13 @@ void RISCVAsmPrinter::LowerSTATEPOINT(MCStreamer &OutStreamer, StackMaps &SM,
SM.recordStatepoint(*MILabel, MI);
}

void RISCVAsmPrinter::EmitToStreamer(MCStreamer &S, const MCInst &Inst) {
bool RISCVAsmPrinter::EmitToStreamer(MCStreamer &S, const MCInst &Inst) {
MCInst CInst;
bool Res = RISCVRVC::compress(CInst, Inst, *STI);
if (Res)
++RISCVNumInstrsCompressed;
AsmPrinter::EmitToStreamer(*OutStreamer, Res ? CInst : Inst);
return Res;
}

// Simple pseudo-instructions have their lowering (with expansion to real
Expand Down

0 comments on commit 8dc006e

Please sign in to comment.