Fix histogram for RVC
authorAndrew Waterman <waterman@cs.berkeley.edu>
Mon, 26 Oct 2015 20:07:30 +0000 (13:07 -0700)
committerAndrew Waterman <waterman@cs.berkeley.edu>
Mon, 26 Oct 2015 20:07:30 +0000 (13:07 -0700)
No need to right-shift PC by 2.  It's a map, so this is a false economy.

riscv/execute.cc
riscv/processor.cc
riscv/processor.h

index 249d6aefe0eb22ba6efeb8fe0e720387a38ed8f4..4711b49b958b2b1e545b7ba59b9b2326306084ea 100644 (file)
@@ -32,11 +32,10 @@ static void commit_log_print_insn(state_t* state, reg_t pc, insn_t insn)
 #endif
 }
 
-inline void processor_t::update_histogram(size_t pc)
+inline void processor_t::update_histogram(reg_t pc)
 {
 #ifdef RISCV_ENABLE_HISTOGRAM
-  size_t idx = pc >> 2;
-  pc_histogram[idx]++;
+  pc_histogram[pc]++;
 #endif
 }
 
index 8870cc99c9548aa217f714bf6e5f373db01bd7f6..37b77c538f03fb905a0a06c18edb7b679002d6df 100644 (file)
@@ -38,10 +38,9 @@ processor_t::~processor_t()
 #ifdef RISCV_ENABLE_HISTOGRAM
   if (histogram_enabled)
   {
-    fprintf(stderr, "PC Histogram size:%lu\n", pc_histogram.size());
-    for(auto iterator = pc_histogram.begin(); iterator != pc_histogram.end(); ++iterator) {
-      fprintf(stderr, "%0lx %lu\n", (iterator->first << 2), iterator->second);
-    }
+    fprintf(stderr, "PC Histogram size:%zu\n", pc_histogram.size());
+    for (auto it : pc_histogram)
+      fprintf(stderr, "%0" PRIx64 " %" PRIu64 "\n", it.first, it.second);
   }
 #endif
 
index f1de05efb00c0c56d8b4d3b6fd02639694df940b..fe0a1214673aedd13400a9a61cb4e3c19009ea16 100644 (file)
@@ -96,7 +96,7 @@ public:
   void push_privilege_stack();
   void pop_privilege_stack();
   void yield_load_reservation() { state.load_reservation = (reg_t)-1; }
-  void update_histogram(size_t pc);
+  void update_histogram(reg_t pc);
 
   void register_insn(insn_desc_t);
   void register_extension(extension_t*);
@@ -116,7 +116,7 @@ private:
   bool histogram_enabled;
 
   std::vector<insn_desc_t> instructions;
-  std::map<size_t,size_t> pc_histogram;
+  std::map<reg_t,uint64_t> pc_histogram;
 
   static const size_t OPCODE_CACHE_SIZE = 8191;
   insn_desc_t opcode_cache[OPCODE_CACHE_SIZE];