From fa2aaa3f8ad1284f4ca2ae17ad173eb1605fea1a Mon Sep 17 00:00:00 2001 From: Prashanth Mundkur Date: Mon, 26 Mar 2018 12:07:03 -0700 Subject: [PATCH] Add an api to get the name for a CSR. --- riscv/disasm.h | 1 + riscv/regnames.cc | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/riscv/disasm.h b/riscv/disasm.h index e2981d4..94e007a 100644 --- a/riscv/disasm.h +++ b/riscv/disasm.h @@ -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 { diff --git a/riscv/regnames.cc b/riscv/regnames.cc index c574345..0bf8d9c 100644 --- a/riscv/regnames.cc +++ b/riscv/regnames.cc @@ -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"; +} -- 2.30.2