Add facility to instrument specific opcodes
authorAndrew Waterman <waterman@cs.berkeley.edu>
Tue, 8 Sep 2015 22:05:31 +0000 (15:05 -0700)
committerAndrew Waterman <waterman@cs.berkeley.edu>
Tue, 8 Sep 2015 22:05:31 +0000 (15:05 -0700)
It's not ideal, because it requires modifying tracer.h.  A more general
facility would allow overriding the instruction execution function for
a given opcode dynamically.

riscv/insn_template.cc
riscv/insn_template.h
riscv/tracer.h [new file with mode: 0644]

index 35f67a0d3cb57798850789343f083ea53543487e..1e79326c462446a94f6a16aa2b0cf7384ef45d16 100644 (file)
@@ -7,6 +7,7 @@ reg_t rv32_NAME(processor_t* p, insn_t insn, reg_t pc)
   int xlen = 32;
   reg_t npc = sext_xlen(pc + insn_length(OPCODE));
   #include "insns/NAME.h"
+  trace_opcode(p, OPCODE, insn);
   return npc;
 }
 
@@ -15,5 +16,6 @@ reg_t rv64_NAME(processor_t* p, insn_t insn, reg_t pc)
   int xlen = 64;
   reg_t npc = sext_xlen(pc + insn_length(OPCODE));
   #include "insns/NAME.h"
+  trace_opcode(p, OPCODE, insn);
   return npc;
 }
index 1a0fd2ee1cf67b61aa25680d72119e546437a15b..f63287298e60fe330822c23fcc641fd87e30e269 100644 (file)
@@ -3,6 +3,7 @@
 #include "mmu.h"
 #include "mulhi.h"
 #include "softfloat.h"
+#include "tracer.h"
 #include "platform.h" // softfloat isNaNF32UI, etc.
 #include "internals.h" // ditto
 #include <assert.h>
diff --git a/riscv/tracer.h b/riscv/tracer.h
new file mode 100644 (file)
index 0000000..9f1bc78
--- /dev/null
@@ -0,0 +1,11 @@
+// See LICENSE for license details.
+
+#ifndef _RISCV_TRACER_H
+#define _RISCV_TRACER_H
+
+#include "processor.h"
+
+static inline void trace_opcode(processor_t* p, insn_bits_t opc, insn_t insn) {
+}
+
+#endif