forked from OSchip/llvm-project
[RISCV] Collect Statistics on Compressed Instructions
Summary: It is useful to keep statistics on how many instructions we have compressed, so we can see if future changes are increasing or decreasing this number. Reviewers: asb, luismarques Reviewed By: asb, luismarques Subscribers: xbolva00, sameer.abuasal, hiraditya, rbar, johnrusso, simoncook, apazos, sabuasal, niosHD, kito-cheng, shiva0217, jrtc27, MaskRay, zzheng, edward-jones, rogfer01, MartinMosbeck, brucehoult, the_o, rkruppe, PkmX, jocewei, psnobl, benna, Jim, s.egerton, pzheng, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D67495
This commit is contained in:
parent
ddf044290e
commit
c9babcbda7
|
@ -15,6 +15,7 @@
|
|||
#include "Utils/RISCVMatInt.h"
|
||||
#include "llvm/ADT/STLExtras.h"
|
||||
#include "llvm/ADT/SmallVector.h"
|
||||
#include "llvm/ADT/Statistic.h"
|
||||
#include "llvm/ADT/StringSwitch.h"
|
||||
#include "llvm/CodeGen/Register.h"
|
||||
#include "llvm/MC/MCAssembler.h"
|
||||
|
@ -37,10 +38,15 @@
|
|||
|
||||
using namespace llvm;
|
||||
|
||||
#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");
|
||||
|
||||
namespace {
|
||||
struct RISCVOperand;
|
||||
|
||||
|
@ -1615,6 +1621,8 @@ bool RISCVAsmParser::parseDirectiveOption() {
|
|||
void RISCVAsmParser::emitToStreamer(MCStreamer &S, const MCInst &Inst) {
|
||||
MCInst CInst;
|
||||
bool Res = compressInst(CInst, Inst, getSTI(), S.getContext());
|
||||
if (Res)
|
||||
++RISCVNumInstrsCompressed;
|
||||
S.EmitInstruction((Res ? CInst : Inst), getSTI());
|
||||
}
|
||||
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
#include "MCTargetDesc/RISCVMCExpr.h"
|
||||
#include "RISCVTargetMachine.h"
|
||||
#include "TargetInfo/RISCVTargetInfo.h"
|
||||
#include "llvm/ADT/Statistic.h"
|
||||
#include "llvm/CodeGen/AsmPrinter.h"
|
||||
#include "llvm/CodeGen/MachineConstantPool.h"
|
||||
#include "llvm/CodeGen/MachineFunctionPass.h"
|
||||
|
@ -31,6 +32,9 @@ using namespace llvm;
|
|||
|
||||
#define DEBUG_TYPE "asm-printer"
|
||||
|
||||
STATISTIC(RISCVNumInstrsCompressed,
|
||||
"Number of RISC-V Compressed instructions emitted");
|
||||
|
||||
namespace {
|
||||
class RISCVAsmPrinter : public AsmPrinter {
|
||||
public:
|
||||
|
@ -64,6 +68,8 @@ void RISCVAsmPrinter::EmitToStreamer(MCStreamer &S, const MCInst &Inst) {
|
|||
MCInst CInst;
|
||||
bool Res = compressInst(CInst, Inst, *TM.getMCSubtargetInfo(),
|
||||
OutStreamer->getContext());
|
||||
if (Res)
|
||||
++RISCVNumInstrsCompressed;
|
||||
AsmPrinter::EmitToStreamer(*OutStreamer, Res ? CInst : Inst);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue