Add an api to get the name for a CSR.
authorPrashanth Mundkur <prashanth.mundkur@gmail.com>
Mon, 26 Mar 2018 19:07:03 +0000 (12:07 -0700)
committerPrashanth Mundkur <prashanth.mundkur@gmail.com>
Mon, 26 Mar 2018 19:07:03 +0000 (12:07 -0700)
riscv/disasm.h
riscv/regnames.cc

index e2981d4a75ef0b2c506e9ba30e118a79a5ad42c9..94e007a12d32ff254a079313f9b798594cd2e0f2 100644 (file)
@@ -10,6 +10,7 @@
 
 extern const char* xpr_name[NXPR];
 extern const char* fpr_name[NFPR];
+extern const char* csr_name(int which);
 
 class arg_t
 {
index c5743454b79cb7e1cca2e6f0a97106997d98a73f..0bf8d9c6e990f0424a1c2cb3dc07f9e0364d5d72 100644 (file)
@@ -15,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";
+}