Add an api to get the name for a CSR.
[riscv-isa-sim.git] / riscv / regnames.cc
index 5a696b36925a6209cc855a0dbe9b0075a373356f..0bf8d9c6e990f0424a1c2cb3dc07f9e0364d5d72 100644 (file)
@@ -1,3 +1,5 @@
+// See LICENSE for license details.
+
 #include "disasm.h"
 
 const char* xpr_name[] = {
@@ -13,3 +15,12 @@ const char* fpr_name[] = {
   "fa6", "fa7", "fs2",  "fs3",  "fs4", "fs5", "fs6",  "fs7",
   "fs8", "fs9", "fs10", "fs11", "ft8", "ft9", "ft10", "ft11"
 };
+
+const char* csr_name(int which) {
+  switch (which) {
+    #define DECLARE_CSR(name, number)  case number: return #name;
+    #include "encoding.h"
+    #undef DECLARE_CSR
+  }
+  return "unknown-csr";
+}