Re: [PATCH v2 5/9] RISC-V: Support version checking for CSR according to privilege spec version.

Nelson Chu
2020-05-19T09:08:18Z

PING :)

On Wed, May 6, 2020 at 10:55 AM Nelson Chu <nelson.chu@sifive.com> wrote:
>
> Support new GAS option -mpriv-spec to choose the privilege spec version, and
> then assembler will generates the correct CSR address. If the obselete CSR
> name is used, then report the warning message when the -mcsr-check is set,
> and use the latest defined address for the CSR (Since we build hash table by
> the DECLARE_CSR first, and then use the DECLARE_CSR_ALIAS). Maybe we can
> insert the CSR hash entries in version's order, then we probably don't need
> the DECLARE_CSR_ALIAS any more.
>
> * -mpriv-spec=[1.9|1.9.1|1.10|1.11]
> This is used to set the privileged spec version, and we can decide whether
> the CSR is valid or not.
>
> gas/
> * config/tc-riscv.c (default_priv_spec): Static variable which is
> used to check if the CSR is valid for the chosen privilege spec. You
> can use -mpriv-spec to set it.
> (enum reg_class): We now get the CSR address from csr_extra_hash rather
> than reg_names_hash. Therefore, move RCLASS_CSR behind RCLASS_MAX.
> (riscv_init_csr_hashes): Only need to initialize one hash table
> csr_extra_hash.
> (riscv_csr_class_check): Change the return type to void. Don't check
> the ISA dependency if -mcsr-check isn't set.
> (riscv_csr_version_check): New function. Check and find the CSR address
> from csr_extra_hash, according to default_priv_spec. Report warning
> for the invalid CSR if -mcsr-check is set.
> (reg_csr_lookup_internal): Updated.
> (reg_lookup_internal): Likewise.
> (md_begin): Updated since DECLARE_CSR and DECLARE_CSR_ALIAS are changed.
> (enum options, struct option md_longopts): Add new GAS option -mpriv-spec.
> (md_parse_option): Call riscv_set_default_priv_version to set
> default_priv_spec.
> (riscv_after_parse_args): If -mpriv-spec isn't set, then set the default
> privilege spec to the newest one.
> (enum riscv_csr_class, struct riscv_csr_extra): Move them to
> include/opcode/riscv.h.
>
> * testsuite/gas/riscv/priv-reg-fail-fext.d: This test case just want
> to check the ISA dependency for CSR, so fix the spec version by adding
> -mpriv-spec=1.11.
> * testsuite/gas/riscv/priv-reg-fail-fext.l: Likewise. There are some
> version warnings for the test case.
> * gas/testsuite/gas/riscv/priv-reg-fail-read-only-01.d: Likewise.
> * gas/testsuite/gas/riscv/priv-reg-fail-read-only-01.l: Likewise.
> * gas/testsuite/gas/riscv/priv-reg-fail-read-only-02.d: Likewise.
> * gas/testsuite/gas/riscv/priv-reg-fail-rv32-only.d: Likewise.
> * gas/testsuite/gas/riscv/priv-reg-fail-rv32-only.l: Likewise.
> * gas/testsuite/gas/riscv/priv-reg-fail-version-1p9.d: New test case.
> Check whether the CSR is valid when privilege version 1.9 is choosed.
> * gas/testsuite/gas/riscv/priv-reg-fail-version-1p9.l: Likewise.
> * gas/testsuite/gas/riscv/priv-reg-fail-version-1p9p1.d: New test case.
> Check whether the CSR is valid when privilege version 1.9.1 is choosed.
> * gas/testsuite/gas/riscv/priv-reg-fail-version-1p9p1.l: Likewise.
> * gas/testsuite/gas/riscv/priv-reg-fail-version-1p10.d: New test case.
> Check whether the CSR is valid when privilege version 1.10 is choosed.
> * gas/testsuite/gas/riscv/priv-reg-fail-version-1p10.l: Likewise.
> * gas/testsuite/gas/riscv/priv-reg-fail-version-1p11.d: New test case.
> Check whether the CSR is valid when privilege version 1.11 is choosed.
> * gas/testsuite/gas/riscv/priv-reg-fail-version-1p11.l: Likewise.
>
> include/
> * opcode/riscv-opc.h (DECLARE_CSR): There are two version information,
> define_version and abort_version. The define_version means which
> privilege spec is started to define the CSR, and the abort_version
> means which privilege spec is started to abort the CSR. If the CSR is
> valid for the newest spec, then the abort_version should be
> PRIV_SPEC_CLASS_DRAFT.
> (DECLARE_CSR_ALIAS): Same as DECLARE_CSR, but only for the obselete CSR.
>
> * opcode/riscv.h (enum riscv_priv_spec_class): New enum class. Define
> the current supported privilege spec versions.
> (struct riscv_csr_extra): Add new fields to store more information
> about the CSR. We use these information to find the suitable CSR
> address when user choosing a specific privilege spec.
>
> opcodes/
> * riscv-opc.c (struct priv_spec_t): New structure.
> (struct priv_spec_t priv_specs): List for all supported privilege spec
> classes and the corresponding strings.
> (riscv_get_priv_spec_class): New function. Get the corresponding
> privilege spec class by giving a spec string.
> (riscv_get_priv_spec_name): New function. Get the corresponding
> privilege spec string by giving a CSR version class.
> * riscv-dis.c: Updated since DECLARE_CSR is changed.
>
> gdb/
> * riscv-tdep.c: Updated since DECLARE_CSR is changed.
> * riscv-tdep.h: Likewise.
>
> binutils/
> * dwarf.c: Updated since DECLARE_CSR is changed.
> ---
> binutils/dwarf.c | 3 +-
> gas/config/tc-riscv.c | 200 +++++---
> gas/testsuite/gas/riscv/priv-reg-fail-fext.d | 2 +-
> gas/testsuite/gas/riscv/priv-reg-fail-fext.l | 25 +
> .../gas/riscv/priv-reg-fail-read-only-01.d | 2 +-
> .../gas/riscv/priv-reg-fail-read-only-01.l | 25 +
> .../gas/riscv/priv-reg-fail-read-only-02.d | 2 +-
> gas/testsuite/gas/riscv/priv-reg-fail-rv32-only.d | 2 +-
> gas/testsuite/gas/riscv/priv-reg-fail-rv32-only.l | 25 +
> .../gas/riscv/priv-reg-fail-version-1p10.d | 3 +
> .../gas/riscv/priv-reg-fail-version-1p10.l | 27 ++
> .../gas/riscv/priv-reg-fail-version-1p11.d | 3 +
> .../gas/riscv/priv-reg-fail-version-1p11.l | 25 +
> .../gas/riscv/priv-reg-fail-version-1p9.d | 3 +
> .../gas/riscv/priv-reg-fail-version-1p9.l | 30 ++
> .../gas/riscv/priv-reg-fail-version-1p9p1.d | 3 +
> .../gas/riscv/priv-reg-fail-version-1p9p1.l | 30 ++
> gdb/riscv-tdep.c | 6 +-
> gdb/riscv-tdep.h | 2 +-
> include/opcode/riscv-opc.h | 509 ++++++++++-----------
> include/opcode/riscv.h | 50 ++
> opcodes/riscv-dis.c | 3 +-
> opcodes/riscv-opc.c | 51 +++
> 23 files changed, 700 insertions(+), 331 deletions(-)
> create mode 100644 gas/testsuite/gas/riscv/priv-reg-fail-version-1p10.d
> create mode 100644 gas/testsuite/gas/riscv/priv-reg-fail-version-1p10.l
> create mode 100644 gas/testsuite/gas/riscv/priv-reg-fail-version-1p11.d
> create mode 100644 gas/testsuite/gas/riscv/priv-reg-fail-version-1p11.l
> create mode 100644 gas/testsuite/gas/riscv/priv-reg-fail-version-1p9.d
> create mode 100644 gas/testsuite/gas/riscv/priv-reg-fail-version-1p9.l
> create mode 100644 gas/testsuite/gas/riscv/priv-reg-fail-version-1p9p1.d
> create mode 100644 gas/testsuite/gas/riscv/priv-reg-fail-version-1p9p1.l
>
> diff --git a/binutils/dwarf.c b/binutils/dwarf.c
> index 7b5f7af..598f856 100644
> --- a/binutils/dwarf.c
> +++ b/binutils/dwarf.c
> @@ -7409,7 +7409,8 @@ regname_internal_riscv (unsigned int regno)
> document. */
> switch (regno)
> {
> -#define DECLARE_CSR(NAME,VALUE,CLASS) case VALUE + 4096: name = #NAME; break;
> +#define DECLARE_CSR(NAME,VALUE,CLASS,DEFINE_VER,ABORT_VER) \
> + case VALUE + 4096: name = #NAME; break;
> #include "opcode/riscv-opc.h"
> #undef DECLARE_CSR
>
> diff --git a/gas/config/tc-riscv.c b/gas/config/tc-riscv.c
> index 3b6c429..743e4bb 100644
> --- a/gas/config/tc-riscv.c
> +++ b/gas/config/tc-riscv.c
> @@ -82,6 +82,7 @@ struct riscv_cl_insn
> static const char default_arch[] = DEFAULT_ARCH;
> static const char *default_arch_with_ext = DEFAULT_RISCV_ARCH_WITH_EXT;
> static enum riscv_isa_spec_class default_isa_spec = ISA_SPEC_CLASS_NONE;
> +static enum riscv_priv_spec_class default_priv_spec = PRIV_SPEC_CLASS_NONE;
>
> static unsigned xlen = 0; /* width of an x-register */
> static unsigned abi_xlen = 0; /* width of a pointer in the ABI */
> @@ -553,8 +554,9 @@ enum reg_class
> {
> RCLASS_GPR,
> RCLASS_FPR,
> - RCLASS_CSR,
> - RCLASS_MAX
> + RCLASS_MAX,
> +
> + RCLASS_CSR
> };
>
> static struct hash_control *reg_names_hash = NULL;
> @@ -584,102 +586,163 @@ hash_reg_names (enum reg_class class, const char * const names[], unsigned n)
> hash_reg_name (class, names[i], i);
> }
>
> -/* All RISC-V CSRs belong to one of these classes. */
> -
> -enum riscv_csr_class
> -{
> - CSR_CLASS_NONE,
> +/* Init hash table csr_extra_hash to handle CSR. */
>
> - CSR_CLASS_I,
> - CSR_CLASS_I_32, /* rv32 only */
> - CSR_CLASS_F, /* f-ext only */
> -};
> +static void
> +riscv_init_csr_hash (const char *name,
> + unsigned address,
> + enum riscv_csr_class class,
> + enum riscv_priv_spec_class define_version,
> + enum riscv_priv_spec_class abort_version)
> +{
> + struct riscv_csr_extra *entry, *pre_entry;
> + const char *hash_error = NULL;
> + bfd_boolean need_enrty = TRUE;
> +
> + pre_entry = NULL;
> + entry = (struct riscv_csr_extra *) hash_find (csr_extra_hash, name);
> + while (need_enrty && entry != NULL)
> + {
> + if (entry->csr_class == class
> + && entry->address == address
> + && entry->define_version == define_version
> + && entry->abort_version == abort_version)
> + need_enrty = FALSE;
> + pre_entry = entry;
> + entry = entry->next;
> + }
>
> -/* This structure holds all restricted conditions for a CSR. */
> + /* Duplicate setting for the CSR, just return and do nothing. */
> + if (!need_enrty)
> + return;
>
> -struct riscv_csr_extra
> -{
> - /* Class to which this CSR belongs. Used to decide whether or
> - not this CSR is legal in the current -march context. */
> - enum riscv_csr_class csr_class;
> -};
> + entry = XNEW (struct riscv_csr_extra);
> + entry->csr_class = class;
> + entry->address = address;
> + entry->define_version = define_version;
> + entry->abort_version = abort_version;
> +
> + /* If the CSR hasn't been inserted in the hash table, then insert it.
> + Otherwise, attach the extra information to the entry which is already
> + in the hash table. */
> + if (pre_entry == NULL)
> + {
> + hash_error = hash_insert (csr_extra_hash, name, (void *) entry);
> + if (hash_error != NULL)
> + {
> + fprintf (stderr, _("internal error: can't hash `%s': %s\n"),
> + name, hash_error);
> + /* Probably a memory allocation problem? Give up now. */
> + as_fatal (_("Broken assembler. No assembly attempted."));
> + }
> + }
> + else
> + pre_entry->next = entry;
> +}
>
> -/* Init two hashes, csr_extra_hash and reg_names_hash, for CSR. */
> +/* Check wether the CSR is valid according to the ISA. */
>
> static void
> -riscv_init_csr_hashes (const char *name,
> - unsigned address,
> - enum riscv_csr_class class)
> +riscv_csr_class_check (const char *s,
> + enum riscv_csr_class csr_class)
> {
> - struct riscv_csr_extra *entry = XNEW (struct riscv_csr_extra);
> - entry->csr_class = class;
> + bfd_boolean result = TRUE;
>
> - const char *hash_error =
> - hash_insert (csr_extra_hash, name, (void *) entry);
> - if (hash_error != NULL)
> + /* Don't check the ISA dependency when -mcsr-check isn't set. */
> + if (!riscv_opts.csr_check)
> + return;
> +
> + switch (csr_class)
> {
> - fprintf (stderr, _("internal error: can't hash `%s': %s\n"),
> - name, hash_error);
> - /* Probably a memory allocation problem? Give up now. */
> - as_fatal (_("Broken assembler. No assembly attempted."));
> + case CSR_CLASS_I:
> + result = riscv_subset_supports ("i");
> + break;
> + case CSR_CLASS_F:
> + result = riscv_subset_supports ("f");
> + break;
> + case CSR_CLASS_I_32:
> + result = (xlen == 32 && riscv_subset_supports ("i"));
> + break;
> + default:
> + as_bad (_("internal: bad RISC-V CSR class (0x%x)"), csr_class);
> }
> -
> - hash_reg_name (RCLASS_CSR, name, address);
> + if (!result)
> + as_warn (_("Invalid CSR `%s' for the current ISA"), s);
> }
>
> -/* Check wether the CSR is valid according to the ISA. */
> +/* Check and find the CSR address according to the privilege spec version. */
>
> -static bfd_boolean
> -riscv_csr_class_check (enum riscv_csr_class csr_class)
> +static void
> +riscv_csr_version_check (const char *csr_name,
> + struct riscv_csr_extra **entryP)
> {
> - switch (csr_class)
> + struct riscv_csr_extra *entry = *entryP;
> + while (entry != NULL)
> {
> - case CSR_CLASS_I: return riscv_subset_supports ("i");
> - case CSR_CLASS_F: return riscv_subset_supports ("f");
> - case CSR_CLASS_I_32:
> - return (xlen == 32 && riscv_subset_supports ("i"));
> + if (default_priv_spec >= entry->define_version
> + && default_priv_spec < entry->abort_version)
> + {
> + /* Find the suitable CSR according to the specific version. */
> + *entryP = entry;
> + return;
> + }
> + entry = entry->next;
> + }
>
> - default:
> - return FALSE;
> + /* We can not find the suitable CSR address according to the privilege
> + version. Therefore, we use the last defined value. Report the warning
> + only when the -mcsr-check is set. Enable the -mcsr-check is recommended,
> + otherwise, you may get the unexpected CSR address. */
> + if (riscv_opts.csr_check)
> + {
> + const char *priv_name = riscv_get_priv_spec_name (default_priv_spec);
> + if (priv_name != NULL)
> + as_warn (_("Invalid CSR `%s' for the privilege spec `%s'"),
> + csr_name, priv_name);
> }
> }
>
> -/* If the CSR is defined, then we call `riscv_csr_class_check` to do the
> - further checking. Return FALSE if the CSR is not defined. Otherwise,
> - return TRUE. */
> +/* Once the CSR is defined, including the old privilege spec, then we call
> + riscv_csr_class_check and riscv_csr_version_check to do the further checking
> + and get the corresponding address. Return -1 if the CSR is never been
> + defined. Otherwise, return the address. */
>
> -static bfd_boolean
> +static unsigned int
> reg_csr_lookup_internal (const char *s)
> {
> struct riscv_csr_extra *r =
> (struct riscv_csr_extra *) hash_find (csr_extra_hash, s);
>
> if (r == NULL)
> - return FALSE;
> + return -1;
>
> - /* We just report the warning when the CSR is invalid. */
> - if (!riscv_csr_class_check (r->csr_class))
> - as_warn (_("Invalid CSR `%s' for the current ISA"), s);
> + /* We just report the warning when the CSR is invalid. "Invalid CSR" means
> + the CSR was defined, but isn't allowed for the current ISA setting or
> + the privilege spec. If the CSR is never been defined, then assembler
> + will regard it as a "Unknown CSR" and report error. If user use number
> + to set the CSR, but over the range (> 0xfff), then assembler will report
> + "Improper CSR" error for it. */
> + riscv_csr_class_check (s, r->csr_class);
> + riscv_csr_version_check (s, &r);
>
> - return TRUE;
> + return r->address;
> }
>
> static unsigned int
> reg_lookup_internal (const char *s, enum reg_class class)
> {
> - void *r = hash_find (reg_names_hash, s);
> + void *r;
> +
> + if (class == RCLASS_CSR)
> + return reg_csr_lookup_internal (s);
>
> + r = hash_find (reg_names_hash, s);
> if (r == NULL || DECODE_REG_CLASS (r) != class)
> return -1;
>
> if (riscv_opts.rve && class == RCLASS_GPR && DECODE_REG_NUM (r) > 15)
> return -1;
>
> - if (class == RCLASS_CSR
> - && riscv_opts.csr_check
> - && !reg_csr_lookup_internal (s))
> - return -1;
> -
> return DECODE_REG_NUM (r);
> }
>
> @@ -963,8 +1026,10 @@ md_begin (void)
>
> /* Create and insert CSR hash tables. */
> csr_extra_hash = hash_new ();
> -#define DECLARE_CSR(name, num, class) riscv_init_csr_hashes (#name, num, class);
> -#define DECLARE_CSR_ALIAS(name, num, class) DECLARE_CSR(name, num, class);
> +#define DECLARE_CSR(name, num, class, define_version, abort_version) \
> + riscv_init_csr_hash (#name, num, class, define_version, abort_version);
> +#define DECLARE_CSR_ALIAS(name, num, class, define_version, abort_version) \
> + DECLARE_CSR(name, num, class, define_version, abort_version);
> #include "opcode/riscv-opc.h"
> #undef DECLARE_CSR
>
> @@ -2450,6 +2515,7 @@ enum options
> OPTION_CSR_CHECK,
> OPTION_NO_CSR_CHECK,
> OPTION_MISA_SPEC,
> + OPTION_MPRIV_SPEC,
> OPTION_END_OF_ENUM
> };
>
> @@ -2467,6 +2533,7 @@ struct option md_longopts[] =
> {"mcsr-check", no_argument, NULL, OPTION_CSR_CHECK},
> {"mno-csr-check", no_argument, NULL, OPTION_NO_CSR_CHECK},
> {"misa-spec", required_argument, NULL, OPTION_MISA_SPEC},
> + {"mpriv-spec", required_argument, NULL, OPTION_MPRIV_SPEC},
>
> {NULL, no_argument, NULL, 0}
> };
> @@ -2558,6 +2625,15 @@ md_parse_option (int c, const char *arg)
> case OPTION_MISA_SPEC:
> return riscv_set_default_isa_spec (arg);
>
> + case OPTION_MPRIV_SPEC:
> + if (!riscv_get_priv_spec_class (arg, &default_priv_spec))
> + {
> + as_bad ("Unknown default privilege spec `%s' set by "
> + "-mpriv-spec", arg);
> + return 0;
> + }
> + break;
> +
> default:
> return 0;
> }
> @@ -2605,6 +2681,10 @@ riscv_after_parse_args (void)
> if (riscv_subset_supports ("e"))
> riscv_set_rve (TRUE);
>
> + /* Set the default privilege spec to the newest one. */
> + if (default_priv_spec == PRIV_SPEC_CLASS_NONE)
> + default_priv_spec = PRIV_SPEC_CLASS_1P11;
> +
> /* Infer ABI from ISA if not specified on command line. */
> if (abi_xlen == 0)
> abi_xlen = xlen;
> diff --git a/gas/testsuite/gas/riscv/priv-reg-fail-fext.d b/gas/testsuite/gas/riscv/priv-reg-fail-fext.d
> index da53566..d9939eb 100644
> --- a/gas/testsuite/gas/riscv/priv-reg-fail-fext.d
> +++ b/gas/testsuite/gas/riscv/priv-reg-fail-fext.d
> @@ -1,3 +1,3 @@
> -#as: -march=rv32i -mcsr-check
> +#as: -march=rv32i -mcsr-check -mpriv-spec=1.11
> #source: priv-reg.s
> #warning_output: priv-reg-fail-fext.l
> diff --git a/gas/testsuite/gas/riscv/priv-reg-fail-fext.l b/gas/testsuite/gas/riscv/priv-reg-fail-fext.l
> index 76818c8..d74863e 100644
> --- a/gas/testsuite/gas/riscv/priv-reg-fail-fext.l
> +++ b/gas/testsuite/gas/riscv/priv-reg-fail-fext.l
> @@ -2,3 +2,28 @@
> .*Warning: Invalid CSR `fflags' for the current ISA
> .*Warning: Invalid CSR `frm' for the current ISA
> .*Warning: Invalid CSR `fcsr' for the current ISA
> +
> +.*Warning: Invalid CSR `ubadaddr' for the privilege spec `1.11'
> +.*Warning: Invalid CSR `sbadaddr' for the privilege spec `1.11'
> +.*Warning: Invalid CSR `sptbr' for the privilege spec `1.11'
> +.*Warning: Invalid CSR `mbadaddr' for the privilege spec `1.11'
> +.*Warning: Invalid CSR `mucounteren' for the privilege spec `1.11'
> +.*Warning: Invalid CSR `dscratch' for the privilege spec `1.11'
> +.*Warning: Invalid CSR `hstatus' for the privilege spec `1.11'
> +.*Warning: Invalid CSR `hedeleg' for the privilege spec `1.11'
> +.*Warning: Invalid CSR `hideleg' for the privilege spec `1.11'
> +.*Warning: Invalid CSR `hie' for the privilege spec `1.11'
> +.*Warning: Invalid CSR `htvec' for the privilege spec `1.11'
> +.*Warning: Invalid CSR `hscratch' for the privilege spec `1.11'
> +.*Warning: Invalid CSR `hepc' for the privilege spec `1.11'
> +.*Warning: Invalid CSR `hcause' for the privilege spec `1.11'
> +.*Warning: Invalid CSR `hbadaddr' for the privilege spec `1.11'
> +.*Warning: Invalid CSR `hip' for the privilege spec `1.11'
> +.*Warning: Invalid CSR `mbase' for the privilege spec `1.11'
> +.*Warning: Invalid CSR `mbound' for the privilege spec `1.11'
> +.*Warning: Invalid CSR `mibase' for the privilege spec `1.11'
> +.*Warning: Invalid CSR `mibound' for the privilege spec `1.11'
> +.*Warning: Invalid CSR `mdbase' for the privilege spec `1.11'
> +.*Warning: Invalid CSR `mdbound' for the privilege spec `1.11'
> +.*Warning: Invalid CSR `mscounteren' for the privilege spec `1.11'
> +.*Warning: Invalid CSR `mhcounteren' for the privilege spec `1.11'
> diff --git a/gas/testsuite/gas/riscv/priv-reg-fail-read-only-01.d b/gas/testsuite/gas/riscv/priv-reg-fail-read-only-01.d
> index ae190c0..b0f6726 100644
> --- a/gas/testsuite/gas/riscv/priv-reg-fail-read-only-01.d
> +++ b/gas/testsuite/gas/riscv/priv-reg-fail-read-only-01.d
> @@ -1,3 +1,3 @@
> -#as: -march=rv32if -mcsr-check
> +#as: -march=rv32if -mcsr-check -mpriv-spec=1.11
> #source: priv-reg-fail-read-only-01.s
> #warning_output: priv-reg-fail-read-only-01.l
> diff --git a/gas/testsuite/gas/riscv/priv-reg-fail-read-only-01.l b/gas/testsuite/gas/riscv/priv-reg-fail-read-only-01.l
> index 7e52bd7..2dc82f4 100644
> --- a/gas/testsuite/gas/riscv/priv-reg-fail-read-only-01.l
> +++ b/gas/testsuite/gas/riscv/priv-reg-fail-read-only-01.l
> @@ -67,3 +67,28 @@
> .*Warning: Read-only CSR is written `csrw marchid,a1'
> .*Warning: Read-only CSR is written `csrw mimpid,a1'
> .*Warning: Read-only CSR is written `csrw mhartid,a1'
> +
> +.*Warning: Invalid CSR `ubadaddr' for the privilege spec `1.11'
> +.*Warning: Invalid CSR `sbadaddr' for the privilege spec `1.11'
> +.*Warning: Invalid CSR `sptbr' for the privilege spec `1.11'
> +.*Warning: Invalid CSR `mbadaddr' for the privilege spec `1.11'
> +.*Warning: Invalid CSR `mucounteren' for the privilege spec `1.11'
> +.*Warning: Invalid CSR `dscratch' for the privilege spec `1.11'
> +.*Warning: Invalid CSR `hstatus' for the privilege spec `1.11'
> +.*Warning: Invalid CSR `hedeleg' for the privilege spec `1.11'
> +.*Warning: Invalid CSR `hideleg' for the privilege spec `1.11'
> +.*Warning: Invalid CSR `hie' for the privilege spec `1.11'
> +.*Warning: Invalid CSR `htvec' for the privilege spec `1.11'
> +.*Warning: Invalid CSR `hscratch' for the privilege spec `1.11'
> +.*Warning: Invalid CSR `hepc' for the privilege spec `1.11'
> +.*Warning: Invalid CSR `hcause' for the privilege spec `1.11'
> +.*Warning: Invalid CSR `hbadaddr' for the privilege spec `1.11'
> +.*Warning: Invalid CSR `hip' for the privilege spec `1.11'
> +.*Warning: Invalid CSR `mbase' for the privilege spec `1.11'
> +.*Warning: Invalid CSR `mbound' for the privilege spec `1.11'
> +.*Warning: Invalid CSR `mibase' for the privilege spec `1.11'
> +.*Warning: Invalid CSR `mibound' for the privilege spec `1.11'
> +.*Warning: Invalid CSR `mdbase' for the privilege spec `1.11'
> +.*Warning: Invalid CSR `mdbound' for the privilege spec `1.11'
> +.*Warning: Invalid CSR `mscounteren' for the privilege spec `1.11'
> +.*Warning: Invalid CSR `mhcounteren' for the privilege spec `1.11'
> diff --git a/gas/testsuite/gas/riscv/priv-reg-fail-read-only-02.d b/gas/testsuite/gas/riscv/priv-reg-fail-read-only-02.d
> index 3c4715f..ec206e4 100644
> --- a/gas/testsuite/gas/riscv/priv-reg-fail-read-only-02.d
> +++ b/gas/testsuite/gas/riscv/priv-reg-fail-read-only-02.d
> @@ -1,3 +1,3 @@
> -#as: -march=rv32if -mcsr-check
> +#as: -march=rv32if -mcsr-check -mpriv-spec=1.11
> #source: priv-reg-fail-read-only-02.s
> #warning_output: priv-reg-fail-read-only-02.l
> diff --git a/gas/testsuite/gas/riscv/priv-reg-fail-rv32-only.d b/gas/testsuite/gas/riscv/priv-reg-fail-rv32-only.d
> index d71b261..eced438 100644
> --- a/gas/testsuite/gas/riscv/priv-reg-fail-rv32-only.d
> +++ b/gas/testsuite/gas/riscv/priv-reg-fail-rv32-only.d
> @@ -1,3 +1,3 @@
> -#as: -march=rv64if -mcsr-check
> +#as: -march=rv64if -mcsr-check -mpriv-spec=1.11
> #source: priv-reg.s
> #warning_output: priv-reg-fail-rv32-only.l
> diff --git a/gas/testsuite/gas/riscv/priv-reg-fail-rv32-only.l b/gas/testsuite/gas/riscv/priv-reg-fail-rv32-only.l
> index fa5a1b4..19f13a0 100644
> --- a/gas/testsuite/gas/riscv/priv-reg-fail-rv32-only.l
> +++ b/gas/testsuite/gas/riscv/priv-reg-fail-rv32-only.l
> @@ -64,3 +64,28 @@
> .*Warning: Invalid CSR `mhpmcounter29h' for the current ISA
> .*Warning: Invalid CSR `mhpmcounter30h' for the current ISA
> .*Warning: Invalid CSR `mhpmcounter31h' for the current ISA
> +
> +.*Warning: Invalid CSR `ubadaddr' for the privilege spec `1.11'
> +.*Warning: Invalid CSR `sbadaddr' for the privilege spec `1.11'
> +.*Warning: Invalid CSR `sptbr' for the privilege spec `1.11'
> +.*Warning: Invalid CSR `mbadaddr' for the privilege spec `1.11'
> +.*Warning: Invalid CSR `mucounteren' for the privilege spec `1.11'
> +.*Warning: Invalid CSR `dscratch' for the privilege spec `1.11'
> +.*Warning: Invalid CSR `hstatus' for the privilege spec `1.11'
> +.*Warning: Invalid CSR `hedeleg' for the privilege spec `1.11'
> +.*Warning: Invalid CSR `hideleg' for the privilege spec `1.11'
> +.*Warning: Invalid CSR `hie' for the privilege spec `1.11'
> +.*Warning: Invalid CSR `htvec' for the privilege spec `1.11'
> +.*Warning: Invalid CSR `hscratch' for the privilege spec `1.11'
> +.*Warning: Invalid CSR `hepc' for the privilege spec `1.11'
> +.*Warning: Invalid CSR `hcause' for the privilege spec `1.11'
> +.*Warning: Invalid CSR `hbadaddr' for the privilege spec `1.11'
> +.*Warning: Invalid CSR `hip' for the privilege spec `1.11'
> +.*Warning: Invalid CSR `mbase' for the privilege spec `1.11'
> +.*Warning: Invalid CSR `mbound' for the privilege spec `1.11'
> +.*Warning: Invalid CSR `mibase' for the privilege spec `1.11'
> +.*Warning: Invalid CSR `mibound' for the privilege spec `1.11'
> +.*Warning: Invalid CSR `mdbase' for the privilege spec `1.11'
> +.*Warning: Invalid CSR `mdbound' for the privilege spec `1.11'
> +.*Warning: Invalid CSR `mscounteren' for the privilege spec `1.11'
> +.*Warning: Invalid CSR `mhcounteren' for the privilege spec `1.11'
> diff --git a/gas/testsuite/gas/riscv/priv-reg-fail-version-1p10.d b/gas/testsuite/gas/riscv/priv-reg-fail-version-1p10.d
> new file mode 100644
> index 0000000..8dc2a10
> --- /dev/null
> +++ b/gas/testsuite/gas/riscv/priv-reg-fail-version-1p10.d
> @@ -0,0 +1,3 @@
> +#as: -march=rv32if -mcsr-check -mpriv-spec=1.10
> +#source: priv-reg.s
> +#warning_output: priv-reg-fail-version-1p10.l
> diff --git a/gas/testsuite/gas/riscv/priv-reg-fail-version-1p10.l b/gas/testsuite/gas/riscv/priv-reg-fail-version-1p10.l
> new file mode 100644
> index 0000000..4146174
> --- /dev/null
> +++ b/gas/testsuite/gas/riscv/priv-reg-fail-version-1p10.l
> @@ -0,0 +1,27 @@
> +.*Assembler messages:
> +.*Warning: Invalid CSR `mcountinhibit' for the privilege spec `1.10'
> +.*Warning: Invalid CSR `dscratch0' for the privilege spec `1.10'
> +.*Warning: Invalid CSR `dscratch1' for the privilege spec `1.10'
> +.*Warning: Invalid CSR `ubadaddr' for the privilege spec `1.10'
> +.*Warning: Invalid CSR `sbadaddr' for the privilege spec `1.10'
> +.*Warning: Invalid CSR `sptbr' for the privilege spec `1.10'
> +.*Warning: Invalid CSR `mbadaddr' for the privilege spec `1.10'
> +.*Warning: Invalid CSR `mucounteren' for the privilege spec `1.10'
> +.*Warning: Invalid CSR `hstatus' for the privilege spec `1.10'
> +.*Warning: Invalid CSR `hedeleg' for the privilege spec `1.10'
> +.*Warning: Invalid CSR `hideleg' for the privilege spec `1.10'
> +.*Warning: Invalid CSR `hie' for the privilege spec `1.10'
> +.*Warning: Invalid CSR `htvec' for the privilege spec `1.10'
> +.*Warning: Invalid CSR `hscratch' for the privilege spec `1.10'
> +.*Warning: Invalid CSR `hepc' for the privilege spec `1.10'
> +.*Warning: Invalid CSR `hcause' for the privilege spec `1.10'
> +.*Warning: Invalid CSR `hbadaddr' for the privilege spec `1.10'
> +.*Warning: Invalid CSR `hip' for the privilege spec `1.10'
> +.*Warning: Invalid CSR `mbase' for the privilege spec `1.10'
> +.*Warning: Invalid CSR `mbound' for the privilege spec `1.10'
> +.*Warning: Invalid CSR `mibase' for the privilege spec `1.10'
> +.*Warning: Invalid CSR `mibound' for the privilege spec `1.10'
> +.*Warning: Invalid CSR `mdbase' for the privilege spec `1.10'
> +.*Warning: Invalid CSR `mdbound' for the privilege spec `1.10'
> +.*Warning: Invalid CSR `mscounteren' for the privilege spec `1.10'
> +.*Warning: Invalid CSR `mhcounteren' for the privilege spec `1.10'
> diff --git a/gas/testsuite/gas/riscv/priv-reg-fail-version-1p11.d b/gas/testsuite/gas/riscv/priv-reg-fail-version-1p11.d
> new file mode 100644
> index 0000000..7d2406c
> --- /dev/null
> +++ b/gas/testsuite/gas/riscv/priv-reg-fail-version-1p11.d
> @@ -0,0 +1,3 @@
> +#as: -march=rv32if -mcsr-check -mpriv-spec=1.11
> +#source: priv-reg.s
> +#warning_output: priv-reg-fail-version-1p11.l
> diff --git a/gas/testsuite/gas/riscv/priv-reg-fail-version-1p11.l b/gas/testsuite/gas/riscv/priv-reg-fail-version-1p11.l
> new file mode 100644
> index 0000000..eadcb5c
> --- /dev/null
> +++ b/gas/testsuite/gas/riscv/priv-reg-fail-version-1p11.l
> @@ -0,0 +1,25 @@
> +.*Assembler messages:
> +.*Warning: Invalid CSR `ubadaddr' for the privilege spec `1.11'
> +.*Warning: Invalid CSR `sbadaddr' for the privilege spec `1.11'
> +.*Warning: Invalid CSR `sptbr' for the privilege spec `1.11'
> +.*Warning: Invalid CSR `mbadaddr' for the privilege spec `1.11'
> +.*Warning: Invalid CSR `mucounteren' for the privilege spec `1.11'
> +.*Warning: Invalid CSR `dscratch' for the privilege spec `1.11'
> +.*Warning: Invalid CSR `hstatus' for the privilege spec `1.11'
> +.*Warning: Invalid CSR `hedeleg' for the privilege spec `1.11'
> +.*Warning: Invalid CSR `hideleg' for the privilege spec `1.11'
> +.*Warning: Invalid CSR `hie' for the privilege spec `1.11'
> +.*Warning: Invalid CSR `htvec' for the privilege spec `1.11'
> +.*Warning: Invalid CSR `hscratch' for the privilege spec `1.11'
> +.*Warning: Invalid CSR `hepc' for the privilege spec `1.11'
> +.*Warning: Invalid CSR `hcause' for the privilege spec `1.11'
> +.*Warning: Invalid CSR `hbadaddr' for the privilege spec `1.11'
> +.*Warning: Invalid CSR `hip' for the privilege spec `1.11'
> +.*Warning: Invalid CSR `mbase' for the privilege spec `1.11'
> +.*Warning: Invalid CSR `mbound' for the privilege spec `1.11'
> +.*Warning: Invalid CSR `mibase' for the privilege spec `1.11'
> +.*Warning: Invalid CSR `mibound' for the privilege spec `1.11'
> +.*Warning: Invalid CSR `mdbase' for the privilege spec `1.11'
> +.*Warning: Invalid CSR `mdbound' for the privilege spec `1.11'
> +.*Warning: Invalid CSR `mscounteren' for the privilege spec `1.11'
> +.*Warning: Invalid CSR `mhcounteren' for the privilege spec `1.11'
> diff --git a/gas/testsuite/gas/riscv/priv-reg-fail-version-1p9.d b/gas/testsuite/gas/riscv/priv-reg-fail-version-1p9.d
> new file mode 100644
> index 0000000..a2db291
> --- /dev/null
> +++ b/gas/testsuite/gas/riscv/priv-reg-fail-version-1p9.d
> @@ -0,0 +1,3 @@
> +#as: -march=rv32if -mcsr-check -mpriv-spec=1.9
> +#source: priv-reg.s
> +#warning_output: priv-reg-fail-version-1p9.l
> diff --git a/gas/testsuite/gas/riscv/priv-reg-fail-version-1p9.l b/gas/testsuite/gas/riscv/priv-reg-fail-version-1p9.l
> new file mode 100644
> index 0000000..d7cee80
> --- /dev/null
> +++ b/gas/testsuite/gas/riscv/priv-reg-fail-version-1p9.l
> @@ -0,0 +1,30 @@
> +.*Assembler messages:
> +.*Warning: Invalid CSR `utval' for the privilege spec `1.9'
> +.*Warning: Invalid CSR `scounteren' for the privilege spec `1.9'
> +.*Warning: Invalid CSR `stval' for the privilege spec `1.9'
> +.*Warning: Invalid CSR `satp' for the privilege spec `1.9'
> +.*Warning: Invalid CSR `mcounteren' for the privilege spec `1.9'
> +.*Warning: Invalid CSR `mtval' for the privilege spec `1.9'
> +.*Warning: Invalid CSR `pmpcfg0' for the privilege spec `1.9'
> +.*Warning: Invalid CSR `pmpcfg1' for the privilege spec `1.9'
> +.*Warning: Invalid CSR `pmpcfg2' for the privilege spec `1.9'
> +.*Warning: Invalid CSR `pmpcfg3' for the privilege spec `1.9'
> +.*Warning: Invalid CSR `pmpaddr0' for the privilege spec `1.9'
> +.*Warning: Invalid CSR `pmpaddr1' for the privilege spec `1.9'
> +.*Warning: Invalid CSR `pmpaddr2' for the privilege spec `1.9'
> +.*Warning: Invalid CSR `pmpaddr3' for the privilege spec `1.9'
> +.*Warning: Invalid CSR `pmpaddr4' for the privilege spec `1.9'
> +.*Warning: Invalid CSR `pmpaddr5' for the privilege spec `1.9'
> +.*Warning: Invalid CSR `pmpaddr6' for the privilege spec `1.9'
> +.*Warning: Invalid CSR `pmpaddr7' for the privilege spec `1.9'
> +.*Warning: Invalid CSR `pmpaddr8' for the privilege spec `1.9'
> +.*Warning: Invalid CSR `pmpaddr9' for the privilege spec `1.9'
> +.*Warning: Invalid CSR `pmpaddr10' for the privilege spec `1.9'
> +.*Warning: Invalid CSR `pmpaddr11' for the privilege spec `1.9'
> +.*Warning: Invalid CSR `pmpaddr12' for the privilege spec `1.9'
> +.*Warning: Invalid CSR `pmpaddr13' for the privilege spec `1.9'
> +.*Warning: Invalid CSR `pmpaddr14' for the privilege spec `1.9'
> +.*Warning: Invalid CSR `pmpaddr15' for the privilege spec `1.9'
> +.*Warning: Invalid CSR `mcountinhibit' for the privilege spec `1.9'
> +.*Warning: Invalid CSR `dscratch0' for the privilege spec `1.9'
> +.*Warning: Invalid CSR `dscratch1' for the privilege spec `1.9'
> diff --git a/gas/testsuite/gas/riscv/priv-reg-fail-version-1p9p1.d b/gas/testsuite/gas/riscv/priv-reg-fail-version-1p9p1.d
> new file mode 100644
> index 0000000..e870cf5
> --- /dev/null
> +++ b/gas/testsuite/gas/riscv/priv-reg-fail-version-1p9p1.d
> @@ -0,0 +1,3 @@
> +#as: -march=rv32if -mcsr-check -mpriv-spec=1.9.1
> +#source: priv-reg.s
> +#warning_output: priv-reg-fail-version-1p9p1.l
> diff --git a/gas/testsuite/gas/riscv/priv-reg-fail-version-1p9p1.l b/gas/testsuite/gas/riscv/priv-reg-fail-version-1p9p1.l
> new file mode 100644
> index 0000000..907ed73
> --- /dev/null
> +++ b/gas/testsuite/gas/riscv/priv-reg-fail-version-1p9p1.l
> @@ -0,0 +1,30 @@
> +.*Assembler messages:
> +.*Warning: Invalid CSR `utval' for the privilege spec `1.9.1'
> +.*Warning: Invalid CSR `scounteren' for the privilege spec `1.9.1'
> +.*Warning: Invalid CSR `stval' for the privilege spec `1.9.1'
> +.*Warning: Invalid CSR `satp' for the privilege spec `1.9.1'
> +.*Warning: Invalid CSR `mcounteren' for the privilege spec `1.9.1'
> +.*Warning: Invalid CSR `mtval' for the privilege spec `1.9.1'
> +.*Warning: Invalid CSR `pmpcfg0' for the privilege spec `1.9.1'
> +.*Warning: Invalid CSR `pmpcfg1' for the privilege spec `1.9.1'
> +.*Warning: Invalid CSR `pmpcfg2' for the privilege spec `1.9.1'
> +.*Warning: Invalid CSR `pmpcfg3' for the privilege spec `1.9.1'
> +.*Warning: Invalid CSR `pmpaddr0' for the privilege spec `1.9.1'
> +.*Warning: Invalid CSR `pmpaddr1' for the privilege spec `1.9.1'
> +.*Warning: Invalid CSR `pmpaddr2' for the privilege spec `1.9.1'
> +.*Warning: Invalid CSR `pmpaddr3' for the privilege spec `1.9.1'
> +.*Warning: Invalid CSR `pmpaddr4' for the privilege spec `1.9.1'
> +.*Warning: Invalid CSR `pmpaddr5' for the privilege spec `1.9.1'
> +.*Warning: Invalid CSR `pmpaddr6' for the privilege spec `1.9.1'
> +.*Warning: Invalid CSR `pmpaddr7' for the privilege spec `1.9.1'
> +.*Warning: Invalid CSR `pmpaddr8' for the privilege spec `1.9.1'
> +.*Warning: Invalid CSR `pmpaddr9' for the privilege spec `1.9.1'
> +.*Warning: Invalid CSR `pmpaddr10' for the privilege spec `1.9.1'
> +.*Warning: Invalid CSR `pmpaddr11' for the privilege spec `1.9.1'
> +.*Warning: Invalid CSR `pmpaddr12' for the privilege spec `1.9.1'
> +.*Warning: Invalid CSR `pmpaddr13' for the privilege spec `1.9.1'
> +.*Warning: Invalid CSR `pmpaddr14' for the privilege spec `1.9.1'
> +.*Warning: Invalid CSR `pmpaddr15' for the privilege spec `1.9.1'
> +.*Warning: Invalid CSR `mcountinhibit' for the privilege spec `1.9.1'
> +.*Warning: Invalid CSR `dscratch0' for the privilege spec `1.9.1'
> +.*Warning: Invalid CSR `dscratch1' for the privilege spec `1.9.1'
> diff --git a/gdb/riscv-tdep.c b/gdb/riscv-tdep.c
> index 1bb824e..e67f661 100644
> --- a/gdb/riscv-tdep.c
> +++ b/gdb/riscv-tdep.c
> @@ -240,7 +240,7 @@ static struct riscv_register_feature riscv_csr_feature =
> {
> "org.gnu.gdb.riscv.csr",
> {
> -#define DECLARE_CSR(NAME,VALUE,CLASS) \
> +#define DECLARE_CSR(NAME,VALUE,CLASS,DEFINE_VER,ABORT_VER) \
> { RISCV_ ## VALUE ## _REGNUM, { # NAME }, false },
> #include "opcode/riscv-opc.h"
> #undef DECLARE_CSR
> @@ -498,7 +498,7 @@ riscv_register_name (struct gdbarch *gdbarch, int regnum)
>
> if (regnum >= RISCV_FIRST_CSR_REGNUM && regnum <= RISCV_LAST_CSR_REGNUM)
> {
> -#define DECLARE_CSR(NAME,VALUE,CLASS) \
> +#define DECLARE_CSR(NAME,VALUE,CLASS,DEFINE_VER,ABORT_VER) \
> case RISCV_ ## VALUE ## _REGNUM: return # NAME;
>
> switch (regnum)
> @@ -828,7 +828,7 @@ riscv_is_regnum_a_named_csr (int regnum)
>
> switch (regnum)
> {
> -#define DECLARE_CSR(name, num, class) case RISCV_ ## num ## _REGNUM:
> +#define DECLARE_CSR(name, num, class, define_ver, abort_ver) case RISCV_ ## num ## _REGNUM:
> #include "opcode/riscv-opc.h"
> #undef DECLARE_CSR
> return true;
> diff --git a/gdb/riscv-tdep.h b/gdb/riscv-tdep.h
> index 90bae08..e415fb4 100644
> --- a/gdb/riscv-tdep.h
> +++ b/gdb/riscv-tdep.h
> @@ -44,7 +44,7 @@ enum
> RISCV_LAST_FP_REGNUM = 64, /* Last Floating Point Register */
>
> RISCV_FIRST_CSR_REGNUM = 65, /* First CSR */
> -#define DECLARE_CSR(name, num, class) \
> +#define DECLARE_CSR(name, num, class, define_version, abort_version) \
> RISCV_ ## num ## _REGNUM = RISCV_FIRST_CSR_REGNUM + num,
> #include "opcode/riscv-opc.h"
> #undef DECLARE_CSR
> diff --git a/include/opcode/riscv-opc.h b/include/opcode/riscv-opc.h
> index fe00bb6..a6a5de3 100644
> --- a/include/opcode/riscv-opc.h
> +++ b/include/opcode/riscv-opc.h
> @@ -656,7 +656,6 @@
> #define CSR_SIDELEG 0x103
> #define CSR_SIE 0x104
> #define CSR_STVEC 0x105
> -/* scounteren is present int priv spec 1.10. */
> #define CSR_SCOUNTEREN 0x106
> #define CSR_SSCRATCH 0x140
> #define CSR_SEPC 0x141
> @@ -669,20 +668,17 @@
> #define CSR_MIMPID 0xf13
> #define CSR_MHARTID 0xf14
> #define CSR_MSTATUS 0x300
> -/* misa is 0xf10 in 1.9, but 0x301 in 1.9.1. */
> #define CSR_MISA 0x301
> #define CSR_MEDELEG 0x302
> #define CSR_MIDELEG 0x303
> #define CSR_MIE 0x304
> #define CSR_MTVEC 0x305
> -/* mcounteren is present in priv spec 1.10. */
> #define CSR_MCOUNTEREN 0x306
> #define CSR_MSCRATCH 0x340
> #define CSR_MEPC 0x341
> #define CSR_MCAUSE 0x342
> #define CSR_MTVAL 0x343
> #define CSR_MIP 0x344
> -/* pmpcfg0 to pmpcfg3, pmpaddr0 to pmpaddr15 are present in priv spec 1.10. */
> #define CSR_PMPCFG0 0x3a0
> #define CSR_PMPCFG1 0x3a1
> #define CSR_PMPCFG2 0x3a2
> @@ -765,7 +761,6 @@
> #define CSR_MHPMCOUNTER29H 0xb9d
> #define CSR_MHPMCOUNTER30H 0xb9e
> #define CSR_MHPMCOUNTER31H 0xb9f
> -/* mcountinhibit is present in priv spec 1.11. */
> #define CSR_MCOUNTINHIBIT 0x320
> #define CSR_MHPMEVENT3 0x323
> #define CSR_MHPMEVENT4 0x324
> @@ -802,10 +797,8 @@
> #define CSR_TDATA3 0x7a3
> #define CSR_DCSR 0x7b0
> #define CSR_DPC 0x7b1
> -/* dscratch0 and dscratch1 are present in priv spec 1.11. */
> #define CSR_DSCRATCH0 0x7b2
> #define CSR_DSCRATCH1 0x7b3
> -/* These registers are present in priv spec 1.9.1, but are dropped in 1.10. */
> #define CSR_HSTATUS 0x200
> #define CSR_HEDELEG 0x202
> #define CSR_HIDELEG 0x203
> @@ -1124,262 +1117,256 @@ DECLARE_INSN(custom3_rd_rs1, MATCH_CUSTOM3_RD_RS1, MASK_CUSTOM3_RD_RS1)
> DECLARE_INSN(custom3_rd_rs1_rs2, MATCH_CUSTOM3_RD_RS1_RS2, MASK_CUSTOM3_RD_RS1_RS2)
> #endif
> #ifdef DECLARE_CSR
> -DECLARE_CSR(ustatus, CSR_USTATUS, CSR_CLASS_I)
> -DECLARE_CSR(uie, CSR_UIE, CSR_CLASS_I)
> -DECLARE_CSR(utvec, CSR_UTVEC, CSR_CLASS_I)
> -DECLARE_CSR(uscratch, CSR_USCRATCH, CSR_CLASS_I)
> -DECLARE_CSR(uepc, CSR_UEPC, CSR_CLASS_I)
> -DECLARE_CSR(ucause, CSR_UCAUSE, CSR_CLASS_I)
> -DECLARE_CSR(utval, CSR_UTVAL, CSR_CLASS_I)
> -DECLARE_CSR(uip, CSR_UIP, CSR_CLASS_I)
> -DECLARE_CSR(fflags, CSR_FFLAGS, CSR_CLASS_F)
> -DECLARE_CSR(frm, CSR_FRM, CSR_CLASS_F)
> -DECLARE_CSR(fcsr, CSR_FCSR, CSR_CLASS_F)
> -DECLARE_CSR(cycle, CSR_CYCLE, CSR_CLASS_I)
> -DECLARE_CSR(time, CSR_TIME, CSR_CLASS_I)
> -DECLARE_CSR(instret, CSR_INSTRET, CSR_CLASS_I)
> -DECLARE_CSR(hpmcounter3, CSR_HPMCOUNTER3, CSR_CLASS_I)
> -DECLARE_CSR(hpmcounter4, CSR_HPMCOUNTER4, CSR_CLASS_I)
> -DECLARE_CSR(hpmcounter5, CSR_HPMCOUNTER5, CSR_CLASS_I)
> -DECLARE_CSR(hpmcounter6, CSR_HPMCOUNTER6, CSR_CLASS_I)
> -DECLARE_CSR(hpmcounter7, CSR_HPMCOUNTER7, CSR_CLASS_I)
> -DECLARE_CSR(hpmcounter8, CSR_HPMCOUNTER8, CSR_CLASS_I)
> -DECLARE_CSR(hpmcounter9, CSR_HPMCOUNTER9, CSR_CLASS_I)
> -DECLARE_CSR(hpmcounter10, CSR_HPMCOUNTER10, CSR_CLASS_I)
> -DECLARE_CSR(hpmcounter11, CSR_HPMCOUNTER11, CSR_CLASS_I)
> -DECLARE_CSR(hpmcounter12, CSR_HPMCOUNTER12, CSR_CLASS_I)
> -DECLARE_CSR(hpmcounter13, CSR_HPMCOUNTER13, CSR_CLASS_I)
> -DECLARE_CSR(hpmcounter14, CSR_HPMCOUNTER14, CSR_CLASS_I)
> -DECLARE_CSR(hpmcounter15, CSR_HPMCOUNTER15, CSR_CLASS_I)
> -DECLARE_CSR(hpmcounter16, CSR_HPMCOUNTER16, CSR_CLASS_I)
> -DECLARE_CSR(hpmcounter17, CSR_HPMCOUNTER17, CSR_CLASS_I)
> -DECLARE_CSR(hpmcounter18, CSR_HPMCOUNTER18, CSR_CLASS_I)
> -DECLARE_CSR(hpmcounter19, CSR_HPMCOUNTER19, CSR_CLASS_I)
> -DECLARE_CSR(hpmcounter20, CSR_HPMCOUNTER20, CSR_CLASS_I)
> -DECLARE_CSR(hpmcounter21, CSR_HPMCOUNTER21, CSR_CLASS_I)
> -DECLARE_CSR(hpmcounter22, CSR_HPMCOUNTER22, CSR_CLASS_I)
> -DECLARE_CSR(hpmcounter23, CSR_HPMCOUNTER23, CSR_CLASS_I)
> -DECLARE_CSR(hpmcounter24, CSR_HPMCOUNTER24, CSR_CLASS_I)
> -DECLARE_CSR(hpmcounter25, CSR_HPMCOUNTER25, CSR_CLASS_I)
> -DECLARE_CSR(hpmcounter26, CSR_HPMCOUNTER26, CSR_CLASS_I)
> -DECLARE_CSR(hpmcounter27, CSR_HPMCOUNTER27, CSR_CLASS_I)
> -DECLARE_CSR(hpmcounter28, CSR_HPMCOUNTER28, CSR_CLASS_I)
> -DECLARE_CSR(hpmcounter29, CSR_HPMCOUNTER29, CSR_CLASS_I)
> -DECLARE_CSR(hpmcounter30, CSR_HPMCOUNTER30, CSR_CLASS_I)
> -DECLARE_CSR(hpmcounter31, CSR_HPMCOUNTER31, CSR_CLASS_I)
> -DECLARE_CSR(cycleh, CSR_CYCLEH, CSR_CLASS_I_32)
> -DECLARE_CSR(timeh, CSR_TIMEH, CSR_CLASS_I_32)
> -DECLARE_CSR(instreth, CSR_INSTRETH, CSR_CLASS_I_32)
> -DECLARE_CSR(hpmcounter3h, CSR_HPMCOUNTER3H, CSR_CLASS_I_32)
> -DECLARE_CSR(hpmcounter4h, CSR_HPMCOUNTER4H, CSR_CLASS_I_32)
> -DECLARE_CSR(hpmcounter5h, CSR_HPMCOUNTER5H, CSR_CLASS_I_32)
> -DECLARE_CSR(hpmcounter6h, CSR_HPMCOUNTER6H, CSR_CLASS_I_32)
> -DECLARE_CSR(hpmcounter7h, CSR_HPMCOUNTER7H, CSR_CLASS_I_32)
> -DECLARE_CSR(hpmcounter8h, CSR_HPMCOUNTER8H, CSR_CLASS_I_32)
> -DECLARE_CSR(hpmcounter9h, CSR_HPMCOUNTER9H, CSR_CLASS_I_32)
> -DECLARE_CSR(hpmcounter10h, CSR_HPMCOUNTER10H, CSR_CLASS_I_32)
> -DECLARE_CSR(hpmcounter11h, CSR_HPMCOUNTER11H, CSR_CLASS_I_32)
> -DECLARE_CSR(hpmcounter12h, CSR_HPMCOUNTER12H, CSR_CLASS_I_32)
> -DECLARE_CSR(hpmcounter13h, CSR_HPMCOUNTER13H, CSR_CLASS_I_32)
> -DECLARE_CSR(hpmcounter14h, CSR_HPMCOUNTER14H, CSR_CLASS_I_32)
> -DECLARE_CSR(hpmcounter15h, CSR_HPMCOUNTER15H, CSR_CLASS_I_32)
> -DECLARE_CSR(hpmcounter16h, CSR_HPMCOUNTER16H, CSR_CLASS_I_32)
> -DECLARE_CSR(hpmcounter17h, CSR_HPMCOUNTER17H, CSR_CLASS_I_32)
> -DECLARE_CSR(hpmcounter18h, CSR_HPMCOUNTER18H, CSR_CLASS_I_32)
> -DECLARE_CSR(hpmcounter19h, CSR_HPMCOUNTER19H, CSR_CLASS_I_32)
> -DECLARE_CSR(hpmcounter20h, CSR_HPMCOUNTER20H, CSR_CLASS_I_32)
> -DECLARE_CSR(hpmcounter21h, CSR_HPMCOUNTER21H, CSR_CLASS_I_32)
> -DECLARE_CSR(hpmcounter22h, CSR_HPMCOUNTER22H, CSR_CLASS_I_32)
> -DECLARE_CSR(hpmcounter23h, CSR_HPMCOUNTER23H, CSR_CLASS_I_32)
> -DECLARE_CSR(hpmcounter24h, CSR_HPMCOUNTER24H, CSR_CLASS_I_32)
> -DECLARE_CSR(hpmcounter25h, CSR_HPMCOUNTER25H, CSR_CLASS_I_32)
> -DECLARE_CSR(hpmcounter26h, CSR_HPMCOUNTER26H, CSR_CLASS_I_32)
> -DECLARE_CSR(hpmcounter27h, CSR_HPMCOUNTER27H, CSR_CLASS_I_32)
> -DECLARE_CSR(hpmcounter28h, CSR_HPMCOUNTER28H, CSR_CLASS_I_32)
> -DECLARE_CSR(hpmcounter29h, CSR_HPMCOUNTER29H, CSR_CLASS_I_32)
> -DECLARE_CSR(hpmcounter30h, CSR_HPMCOUNTER30H, CSR_CLASS_I_32)
> -DECLARE_CSR(hpmcounter31h, CSR_HPMCOUNTER31H, CSR_CLASS_I_32)
> -DECLARE_CSR(sstatus, CSR_SSTATUS, CSR_CLASS_I)
> -DECLARE_CSR(sedeleg, CSR_SEDELEG, CSR_CLASS_I)
> -DECLARE_CSR(sideleg, CSR_SIDELEG, CSR_CLASS_I)
> -DECLARE_CSR(sie, CSR_SIE, CSR_CLASS_I)
> -DECLARE_CSR(stvec, CSR_STVEC, CSR_CLASS_I)
> -DECLARE_CSR(scounteren, CSR_SCOUNTEREN, CSR_CLASS_I)
> -DECLARE_CSR(sscratch, CSR_SSCRATCH, CSR_CLASS_I)
> -DECLARE_CSR(sepc, CSR_SEPC, CSR_CLASS_I)
> -DECLARE_CSR(scause, CSR_SCAUSE, CSR_CLASS_I)
> -DECLARE_CSR(stval, CSR_STVAL, CSR_CLASS_I)
> -DECLARE_CSR(sip, CSR_SIP, CSR_CLASS_I)
> -DECLARE_CSR(satp, CSR_SATP, CSR_CLASS_I)
> -DECLARE_CSR(mvendorid, CSR_MVENDORID, CSR_CLASS_I)
> -DECLARE_CSR(marchid, CSR_MARCHID, CSR_CLASS_I)
> -DECLARE_CSR(mimpid, CSR_MIMPID, CSR_CLASS_I)
> -DECLARE_CSR(mhartid, CSR_MHARTID, CSR_CLASS_I)
> -DECLARE_CSR(mstatus, CSR_MSTATUS, CSR_CLASS_I)
> -DECLARE_CSR(misa, CSR_MISA, CSR_CLASS_I)
> -DECLARE_CSR(medeleg, CSR_MEDELEG, CSR_CLASS_I)
> -DECLARE_CSR(mideleg, CSR_MIDELEG, CSR_CLASS_I)
> -DECLARE_CSR(mie, CSR_MIE, CSR_CLASS_I)
> -DECLARE_CSR(mtvec, CSR_MTVEC, CSR_CLASS_I)
> -DECLARE_CSR(mcounteren, CSR_MCOUNTEREN, CSR_CLASS_I)
> -DECLARE_CSR(mscratch, CSR_MSCRATCH, CSR_CLASS_I)
> -DECLARE_CSR(mepc, CSR_MEPC, CSR_CLASS_I)
> -DECLARE_CSR(mcause, CSR_MCAUSE, CSR_CLASS_I)
> -DECLARE_CSR(mtval, CSR_MTVAL, CSR_CLASS_I)
> -DECLARE_CSR(mip, CSR_MIP, CSR_CLASS_I)
> -DECLARE_CSR(pmpcfg0, CSR_PMPCFG0, CSR_CLASS_I)
> -DECLARE_CSR(pmpcfg1, CSR_PMPCFG1, CSR_CLASS_I_32)
> -DECLARE_CSR(pmpcfg2, CSR_PMPCFG2, CSR_CLASS_I)
> -DECLARE_CSR(pmpcfg3, CSR_PMPCFG3, CSR_CLASS_I_32)
> -DECLARE_CSR(pmpaddr0, CSR_PMPADDR0, CSR_CLASS_I)
> -DECLARE_CSR(pmpaddr1, CSR_PMPADDR1, CSR_CLASS_I)
> -DECLARE_CSR(pmpaddr2, CSR_PMPADDR2, CSR_CLASS_I)
> -DECLARE_CSR(pmpaddr3, CSR_PMPADDR3, CSR_CLASS_I)
> -DECLARE_CSR(pmpaddr4, CSR_PMPADDR4, CSR_CLASS_I)
> -DECLARE_CSR(pmpaddr5, CSR_PMPADDR5, CSR_CLASS_I)
> -DECLARE_CSR(pmpaddr6, CSR_PMPADDR6, CSR_CLASS_I)
> -DECLARE_CSR(pmpaddr7, CSR_PMPADDR7, CSR_CLASS_I)
> -DECLARE_CSR(pmpaddr8, CSR_PMPADDR8, CSR_CLASS_I)
> -DECLARE_CSR(pmpaddr9, CSR_PMPADDR9, CSR_CLASS_I)
> -DECLARE_CSR(pmpaddr10, CSR_PMPADDR10, CSR_CLASS_I)
> -DECLARE_CSR(pmpaddr11, CSR_PMPADDR11, CSR_CLASS_I)
> -DECLARE_CSR(pmpaddr12, CSR_PMPADDR12, CSR_CLASS_I)
> -DECLARE_CSR(pmpaddr13, CSR_PMPADDR13, CSR_CLASS_I)
> -DECLARE_CSR(pmpaddr14, CSR_PMPADDR14, CSR_CLASS_I)
> -DECLARE_CSR(pmpaddr15, CSR_PMPADDR15, CSR_CLASS_I)
> -DECLARE_CSR(mcycle, CSR_MCYCLE, CSR_CLASS_I)
> -DECLARE_CSR(minstret, CSR_MINSTRET, CSR_CLASS_I)
> -DECLARE_CSR(mhpmcounter3, CSR_MHPMCOUNTER3, CSR_CLASS_I)
> -DECLARE_CSR(mhpmcounter4, CSR_MHPMCOUNTER4, CSR_CLASS_I)
> -DECLARE_CSR(mhpmcounter5, CSR_MHPMCOUNTER5, CSR_CLASS_I)
> -DECLARE_CSR(mhpmcounter6, CSR_MHPMCOUNTER6, CSR_CLASS_I)
> -DECLARE_CSR(mhpmcounter7, CSR_MHPMCOUNTER7, CSR_CLASS_I)
> -DECLARE_CSR(mhpmcounter8, CSR_MHPMCOUNTER8, CSR_CLASS_I)
> -DECLARE_CSR(mhpmcounter9, CSR_MHPMCOUNTER9, CSR_CLASS_I)
> -DECLARE_CSR(mhpmcounter10, CSR_MHPMCOUNTER10, CSR_CLASS_I)
> -DECLARE_CSR(mhpmcounter11, CSR_MHPMCOUNTER11, CSR_CLASS_I)
> -DECLARE_CSR(mhpmcounter12, CSR_MHPMCOUNTER12, CSR_CLASS_I)
> -DECLARE_CSR(mhpmcounter13, CSR_MHPMCOUNTER13, CSR_CLASS_I)
> -DECLARE_CSR(mhpmcounter14, CSR_MHPMCOUNTER14, CSR_CLASS_I)
> -DECLARE_CSR(mhpmcounter15, CSR_MHPMCOUNTER15, CSR_CLASS_I)
> -DECLARE_CSR(mhpmcounter16, CSR_MHPMCOUNTER16, CSR_CLASS_I)
> -DECLARE_CSR(mhpmcounter17, CSR_MHPMCOUNTER17, CSR_CLASS_I)
> -DECLARE_CSR(mhpmcounter18, CSR_MHPMCOUNTER18, CSR_CLASS_I)
> -DECLARE_CSR(mhpmcounter19, CSR_MHPMCOUNTER19, CSR_CLASS_I)
> -DECLARE_CSR(mhpmcounter20, CSR_MHPMCOUNTER20, CSR_CLASS_I)
> -DECLARE_CSR(mhpmcounter21, CSR_MHPMCOUNTER21, CSR_CLASS_I)
> -DECLARE_CSR(mhpmcounter22, CSR_MHPMCOUNTER22, CSR_CLASS_I)
> -DECLARE_CSR(mhpmcounter23, CSR_MHPMCOUNTER23, CSR_CLASS_I)
> -DECLARE_CSR(mhpmcounter24, CSR_MHPMCOUNTER24, CSR_CLASS_I)
> -DECLARE_CSR(mhpmcounter25, CSR_MHPMCOUNTER25, CSR_CLASS_I)
> -DECLARE_CSR(mhpmcounter26, CSR_MHPMCOUNTER26, CSR_CLASS_I)
> -DECLARE_CSR(mhpmcounter27, CSR_MHPMCOUNTER27, CSR_CLASS_I)
> -DECLARE_CSR(mhpmcounter28, CSR_MHPMCOUNTER28, CSR_CLASS_I)
> -DECLARE_CSR(mhpmcounter29, CSR_MHPMCOUNTER29, CSR_CLASS_I)
> -DECLARE_CSR(mhpmcounter30, CSR_MHPMCOUNTER30, CSR_CLASS_I)
> -DECLARE_CSR(mhpmcounter31, CSR_MHPMCOUNTER31, CSR_CLASS_I)
> -DECLARE_CSR(mcycleh, CSR_MCYCLEH, CSR_CLASS_I_32)
> -DECLARE_CSR(minstreth, CSR_MINSTRETH, CSR_CLASS_I_32)
> -DECLARE_CSR(mhpmcounter3h, CSR_MHPMCOUNTER3H, CSR_CLASS_I_32)
> -DECLARE_CSR(mhpmcounter4h, CSR_MHPMCOUNTER4H, CSR_CLASS_I_32)
> -DECLARE_CSR(mhpmcounter5h, CSR_MHPMCOUNTER5H, CSR_CLASS_I_32)
> -DECLARE_CSR(mhpmcounter6h, CSR_MHPMCOUNTER6H, CSR_CLASS_I_32)
> -DECLARE_CSR(mhpmcounter7h, CSR_MHPMCOUNTER7H, CSR_CLASS_I_32)
> -DECLARE_CSR(mhpmcounter8h, CSR_MHPMCOUNTER8H, CSR_CLASS_I_32)
> -DECLARE_CSR(mhpmcounter9h, CSR_MHPMCOUNTER9H, CSR_CLASS_I_32)
> -DECLARE_CSR(mhpmcounter10h, CSR_MHPMCOUNTER10H, CSR_CLASS_I_32)
> -DECLARE_CSR(mhpmcounter11h, CSR_MHPMCOUNTER11H, CSR_CLASS_I_32)
> -DECLARE_CSR(mhpmcounter12h, CSR_MHPMCOUNTER12H, CSR_CLASS_I_32)
> -DECLARE_CSR(mhpmcounter13h, CSR_MHPMCOUNTER13H, CSR_CLASS_I_32)
> -DECLARE_CSR(mhpmcounter14h, CSR_MHPMCOUNTER14H, CSR_CLASS_I_32)
> -DECLARE_CSR(mhpmcounter15h, CSR_MHPMCOUNTER15H, CSR_CLASS_I_32)
> -DECLARE_CSR(mhpmcounter16h, CSR_MHPMCOUNTER16H, CSR_CLASS_I_32)
> -DECLARE_CSR(mhpmcounter17h, CSR_MHPMCOUNTER17H, CSR_CLASS_I_32)
> -DECLARE_CSR(mhpmcounter18h, CSR_MHPMCOUNTER18H, CSR_CLASS_I_32)
> -DECLARE_CSR(mhpmcounter19h, CSR_MHPMCOUNTER19H, CSR_CLASS_I_32)
> -DECLARE_CSR(mhpmcounter20h, CSR_MHPMCOUNTER20H, CSR_CLASS_I_32)
> -DECLARE_CSR(mhpmcounter21h, CSR_MHPMCOUNTER21H, CSR_CLASS_I_32)
> -DECLARE_CSR(mhpmcounter22h, CSR_MHPMCOUNTER22H, CSR_CLASS_I_32)
> -DECLARE_CSR(mhpmcounter23h, CSR_MHPMCOUNTER23H, CSR_CLASS_I_32)
> -DECLARE_CSR(mhpmcounter24h, CSR_MHPMCOUNTER24H, CSR_CLASS_I_32)
> -DECLARE_CSR(mhpmcounter25h, CSR_MHPMCOUNTER25H, CSR_CLASS_I_32)
> -DECLARE_CSR(mhpmcounter26h, CSR_MHPMCOUNTER26H, CSR_CLASS_I_32)
> -DECLARE_CSR(mhpmcounter27h, CSR_MHPMCOUNTER27H, CSR_CLASS_I_32)
> -DECLARE_CSR(mhpmcounter28h, CSR_MHPMCOUNTER28H, CSR_CLASS_I_32)
> -DECLARE_CSR(mhpmcounter29h, CSR_MHPMCOUNTER29H, CSR_CLASS_I_32)
> -DECLARE_CSR(mhpmcounter30h, CSR_MHPMCOUNTER30H, CSR_CLASS_I_32)
> -DECLARE_CSR(mhpmcounter31h, CSR_MHPMCOUNTER31H, CSR_CLASS_I_32)
> -DECLARE_CSR(mcountinhibit, CSR_MCOUNTINHIBIT, CSR_CLASS_I)
> -DECLARE_CSR(mhpmevent3, CSR_MHPMEVENT3, CSR_CLASS_I)
> -DECLARE_CSR(mhpmevent4, CSR_MHPMEVENT4, CSR_CLASS_I)
> -DECLARE_CSR(mhpmevent5, CSR_MHPMEVENT5, CSR_CLASS_I)
> -DECLARE_CSR(mhpmevent6, CSR_MHPMEVENT6, CSR_CLASS_I)
> -DECLARE_CSR(mhpmevent7, CSR_MHPMEVENT7, CSR_CLASS_I)
> -DECLARE_CSR(mhpmevent8, CSR_MHPMEVENT8, CSR_CLASS_I)
> -DECLARE_CSR(mhpmevent9, CSR_MHPMEVENT9, CSR_CLASS_I)
> -DECLARE_CSR(mhpmevent10, CSR_MHPMEVENT10, CSR_CLASS_I)
> -DECLARE_CSR(mhpmevent11, CSR_MHPMEVENT11, CSR_CLASS_I)
> -DECLARE_CSR(mhpmevent12, CSR_MHPMEVENT12, CSR_CLASS_I)
> -DECLARE_CSR(mhpmevent13, CSR_MHPMEVENT13, CSR_CLASS_I)
> -DECLARE_CSR(mhpmevent14, CSR_MHPMEVENT14, CSR_CLASS_I)
> -DECLARE_CSR(mhpmevent15, CSR_MHPMEVENT15, CSR_CLASS_I)
> -DECLARE_CSR(mhpmevent16, CSR_MHPMEVENT16, CSR_CLASS_I)
> -DECLARE_CSR(mhpmevent17, CSR_MHPMEVENT17, CSR_CLASS_I)
> -DECLARE_CSR(mhpmevent18, CSR_MHPMEVENT18, CSR_CLASS_I)
> -DECLARE_CSR(mhpmevent19, CSR_MHPMEVENT19, CSR_CLASS_I)
> -DECLARE_CSR(mhpmevent20, CSR_MHPMEVENT20, CSR_CLASS_I)
> -DECLARE_CSR(mhpmevent21, CSR_MHPMEVENT21, CSR_CLASS_I)
> -DECLARE_CSR(mhpmevent22, CSR_MHPMEVENT22, CSR_CLASS_I)
> -DECLARE_CSR(mhpmevent23, CSR_MHPMEVENT23, CSR_CLASS_I)
> -DECLARE_CSR(mhpmevent24, CSR_MHPMEVENT24, CSR_CLASS_I)
> -DECLARE_CSR(mhpmevent25, CSR_MHPMEVENT25, CSR_CLASS_I)
> -DECLARE_CSR(mhpmevent26, CSR_MHPMEVENT26, CSR_CLASS_I)
> -DECLARE_CSR(mhpmevent27, CSR_MHPMEVENT27, CSR_CLASS_I)
> -DECLARE_CSR(mhpmevent28, CSR_MHPMEVENT28, CSR_CLASS_I)
> -DECLARE_CSR(mhpmevent29, CSR_MHPMEVENT29, CSR_CLASS_I)
> -DECLARE_CSR(mhpmevent30, CSR_MHPMEVENT30, CSR_CLASS_I)
> -DECLARE_CSR(mhpmevent31, CSR_MHPMEVENT31, CSR_CLASS_I)
> -DECLARE_CSR(tselect, CSR_TSELECT, CSR_CLASS_I)
> -DECLARE_CSR(tdata1, CSR_TDATA1, CSR_CLASS_I)
> -DECLARE_CSR(tdata2, CSR_TDATA2, CSR_CLASS_I)
> -DECLARE_CSR(tdata3, CSR_TDATA3, CSR_CLASS_I)
> -DECLARE_CSR(dcsr, CSR_DCSR, CSR_CLASS_I)
> -DECLARE_CSR(dpc, CSR_DPC, CSR_CLASS_I)
> -DECLARE_CSR(dscratch0, CSR_DSCRATCH0, CSR_CLASS_I)
> -DECLARE_CSR(dscratch1, CSR_DSCRATCH1, CSR_CLASS_I)
> -/* These registers are present in priv spec 1.9.1, dropped in 1.10. */
> -DECLARE_CSR(hstatus, CSR_HSTATUS, CSR_CLASS_I)
> -DECLARE_CSR(hedeleg, CSR_HEDELEG, CSR_CLASS_I)
> -DECLARE_CSR(hideleg, CSR_HIDELEG, CSR_CLASS_I)
> -DECLARE_CSR(hie, CSR_HIE, CSR_CLASS_I)
> -DECLARE_CSR(htvec, CSR_HTVEC, CSR_CLASS_I)
> -DECLARE_CSR(hscratch, CSR_HSCRATCH, CSR_CLASS_I)
> -DECLARE_CSR(hepc, CSR_HEPC, CSR_CLASS_I)
> -DECLARE_CSR(hcause, CSR_HCAUSE, CSR_CLASS_I)
> -DECLARE_CSR(hbadaddr, CSR_HBADADDR, CSR_CLASS_I)
> -DECLARE_CSR(hip, CSR_HIP, CSR_CLASS_I)
> -DECLARE_CSR(mbase, CSR_MBASE, CSR_CLASS_I)
> -DECLARE_CSR(mbound, CSR_MBOUND, CSR_CLASS_I)
> -DECLARE_CSR(mibase, CSR_MIBASE, CSR_CLASS_I)
> -DECLARE_CSR(mibound, CSR_MIBOUND, CSR_CLASS_I)
> -DECLARE_CSR(mdbase, CSR_MDBASE, CSR_CLASS_I)
> -DECLARE_CSR(mdbound, CSR_MDBOUND, CSR_CLASS_I)
> -DECLARE_CSR(mscounteren, CSR_MSCOUNTEREN, CSR_CLASS_I)
> -DECLARE_CSR(mhcounteren, CSR_MHCOUNTEREN, CSR_CLASS_I)
> +DECLARE_CSR(ustatus, CSR_USTATUS, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(uie, CSR_UIE, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(utvec, CSR_UTVEC, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(uscratch, CSR_USCRATCH, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(uepc, CSR_UEPC, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(ucause, CSR_UCAUSE, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(utval, CSR_UTVAL, CSR_CLASS_I, PRIV_SPEC_CLASS_1P10, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(uip, CSR_UIP, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(fflags, CSR_FFLAGS, CSR_CLASS_F, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(frm, CSR_FRM, CSR_CLASS_F, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(fcsr, CSR_FCSR, CSR_CLASS_F, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(cycle, CSR_CYCLE, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(time, CSR_TIME, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(instret, CSR_INSTRET, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(hpmcounter3, CSR_HPMCOUNTER3, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(hpmcounter4, CSR_HPMCOUNTER4, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(hpmcounter5, CSR_HPMCOUNTER5, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(hpmcounter6, CSR_HPMCOUNTER6, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(hpmcounter7, CSR_HPMCOUNTER7, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(hpmcounter8, CSR_HPMCOUNTER8, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(hpmcounter9, CSR_HPMCOUNTER9, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(hpmcounter10, CSR_HPMCOUNTER10, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(hpmcounter11, CSR_HPMCOUNTER11, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(hpmcounter12, CSR_HPMCOUNTER12, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(hpmcounter13, CSR_HPMCOUNTER13, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(hpmcounter14, CSR_HPMCOUNTER14, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(hpmcounter15, CSR_HPMCOUNTER15, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(hpmcounter16, CSR_HPMCOUNTER16, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(hpmcounter17, CSR_HPMCOUNTER17, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(hpmcounter18, CSR_HPMCOUNTER18, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(hpmcounter19, CSR_HPMCOUNTER19, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(hpmcounter20, CSR_HPMCOUNTER20, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(hpmcounter21, CSR_HPMCOUNTER21, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(hpmcounter22, CSR_HPMCOUNTER22, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(hpmcounter23, CSR_HPMCOUNTER23, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(hpmcounter24, CSR_HPMCOUNTER24, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(hpmcounter25, CSR_HPMCOUNTER25, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(hpmcounter26, CSR_HPMCOUNTER26, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(hpmcounter27, CSR_HPMCOUNTER27, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(hpmcounter28, CSR_HPMCOUNTER28, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(hpmcounter29, CSR_HPMCOUNTER29, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(hpmcounter30, CSR_HPMCOUNTER30, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(hpmcounter31, CSR_HPMCOUNTER31, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(cycleh, CSR_CYCLEH, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(timeh, CSR_TIMEH, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(instreth, CSR_INSTRETH, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(hpmcounter3h, CSR_HPMCOUNTER3H, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(hpmcounter4h, CSR_HPMCOUNTER4H, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(hpmcounter5h, CSR_HPMCOUNTER5H, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(hpmcounter6h, CSR_HPMCOUNTER6H, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(hpmcounter7h, CSR_HPMCOUNTER7H, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(hpmcounter8h, CSR_HPMCOUNTER8H, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(hpmcounter9h, CSR_HPMCOUNTER9H, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(hpmcounter10h, CSR_HPMCOUNTER10H, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(hpmcounter11h, CSR_HPMCOUNTER11H, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(hpmcounter12h, CSR_HPMCOUNTER12H, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(hpmcounter13h, CSR_HPMCOUNTER13H, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(hpmcounter14h, CSR_HPMCOUNTER14H, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(hpmcounter15h, CSR_HPMCOUNTER15H, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(hpmcounter16h, CSR_HPMCOUNTER16H, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(hpmcounter17h, CSR_HPMCOUNTER17H, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(hpmcounter18h, CSR_HPMCOUNTER18H, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(hpmcounter19h, CSR_HPMCOUNTER19H, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(hpmcounter20h, CSR_HPMCOUNTER20H, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(hpmcounter21h, CSR_HPMCOUNTER21H, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(hpmcounter22h, CSR_HPMCOUNTER22H, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(hpmcounter23h, CSR_HPMCOUNTER23H, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(hpmcounter24h, CSR_HPMCOUNTER24H, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(hpmcounter25h, CSR_HPMCOUNTER25H, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(hpmcounter26h, CSR_HPMCOUNTER26H, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(hpmcounter27h, CSR_HPMCOUNTER27H, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(hpmcounter28h, CSR_HPMCOUNTER28H, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(hpmcounter29h, CSR_HPMCOUNTER29H, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(hpmcounter30h, CSR_HPMCOUNTER30H, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(hpmcounter31h, CSR_HPMCOUNTER31H, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(sstatus, CSR_SSTATUS, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(sedeleg, CSR_SEDELEG, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(sideleg, CSR_SIDELEG, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(sie, CSR_SIE, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(stvec, CSR_STVEC, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(scounteren, CSR_SCOUNTEREN, CSR_CLASS_I, PRIV_SPEC_CLASS_1P10, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(sscratch, CSR_SSCRATCH, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(sepc, CSR_SEPC, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(scause, CSR_SCAUSE, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(stval, CSR_STVAL, CSR_CLASS_I, PRIV_SPEC_CLASS_1P10, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(sip, CSR_SIP, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(satp, CSR_SATP, CSR_CLASS_I, PRIV_SPEC_CLASS_1P10, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(mvendorid, CSR_MVENDORID, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(marchid, CSR_MARCHID, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(mimpid, CSR_MIMPID, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(mhartid, CSR_MHARTID, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(mstatus, CSR_MSTATUS, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(misa, CSR_MISA, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(medeleg, CSR_MEDELEG, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(mideleg, CSR_MIDELEG, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(mie, CSR_MIE, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(mtvec, CSR_MTVEC, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(mcounteren, CSR_MCOUNTEREN, CSR_CLASS_I, PRIV_SPEC_CLASS_1P10, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(mscratch, CSR_MSCRATCH, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(mepc, CSR_MEPC, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(mcause, CSR_MCAUSE, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(mtval, CSR_MTVAL, CSR_CLASS_I, PRIV_SPEC_CLASS_1P10, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(mip, CSR_MIP, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(pmpcfg0, CSR_PMPCFG0, CSR_CLASS_I, PRIV_SPEC_CLASS_1P10, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(pmpcfg1, CSR_PMPCFG1, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P10, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(pmpcfg2, CSR_PMPCFG2, CSR_CLASS_I, PRIV_SPEC_CLASS_1P10, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(pmpcfg3, CSR_PMPCFG3, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P10, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(pmpaddr0, CSR_PMPADDR0, CSR_CLASS_I, PRIV_SPEC_CLASS_1P10, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(pmpaddr1, CSR_PMPADDR1, CSR_CLASS_I, PRIV_SPEC_CLASS_1P10, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(pmpaddr2, CSR_PMPADDR2, CSR_CLASS_I, PRIV_SPEC_CLASS_1P10, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(pmpaddr3, CSR_PMPADDR3, CSR_CLASS_I, PRIV_SPEC_CLASS_1P10, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(pmpaddr4, CSR_PMPADDR4, CSR_CLASS_I, PRIV_SPEC_CLASS_1P10, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(pmpaddr5, CSR_PMPADDR5, CSR_CLASS_I, PRIV_SPEC_CLASS_1P10, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(pmpaddr6, CSR_PMPADDR6, CSR_CLASS_I, PRIV_SPEC_CLASS_1P10, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(pmpaddr7, CSR_PMPADDR7, CSR_CLASS_I, PRIV_SPEC_CLASS_1P10, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(pmpaddr8, CSR_PMPADDR8, CSR_CLASS_I, PRIV_SPEC_CLASS_1P10, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(pmpaddr9, CSR_PMPADDR9, CSR_CLASS_I, PRIV_SPEC_CLASS_1P10, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(pmpaddr10, CSR_PMPADDR10, CSR_CLASS_I, PRIV_SPEC_CLASS_1P10, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(pmpaddr11, CSR_PMPADDR11, CSR_CLASS_I, PRIV_SPEC_CLASS_1P10, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(pmpaddr12, CSR_PMPADDR12, CSR_CLASS_I, PRIV_SPEC_CLASS_1P10, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(pmpaddr13, CSR_PMPADDR13, CSR_CLASS_I, PRIV_SPEC_CLASS_1P10, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(pmpaddr14, CSR_PMPADDR14, CSR_CLASS_I, PRIV_SPEC_CLASS_1P10, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(pmpaddr15, CSR_PMPADDR15, CSR_CLASS_I, PRIV_SPEC_CLASS_1P10, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(mcycle, CSR_MCYCLE, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(minstret, CSR_MINSTRET, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(mhpmcounter3, CSR_MHPMCOUNTER3, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(mhpmcounter4, CSR_MHPMCOUNTER4, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(mhpmcounter5, CSR_MHPMCOUNTER5, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(mhpmcounter6, CSR_MHPMCOUNTER6, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(mhpmcounter7, CSR_MHPMCOUNTER7, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(mhpmcounter8, CSR_MHPMCOUNTER8, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(mhpmcounter9, CSR_MHPMCOUNTER9, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(mhpmcounter10, CSR_MHPMCOUNTER10, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(mhpmcounter11, CSR_MHPMCOUNTER11, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(mhpmcounter12, CSR_MHPMCOUNTER12, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(mhpmcounter13, CSR_MHPMCOUNTER13, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(mhpmcounter14, CSR_MHPMCOUNTER14, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(mhpmcounter15, CSR_MHPMCOUNTER15, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(mhpmcounter16, CSR_MHPMCOUNTER16, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(mhpmcounter17, CSR_MHPMCOUNTER17, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(mhpmcounter18, CSR_MHPMCOUNTER18, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(mhpmcounter19, CSR_MHPMCOUNTER19, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(mhpmcounter20, CSR_MHPMCOUNTER20, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(mhpmcounter21, CSR_MHPMCOUNTER21, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(mhpmcounter22, CSR_MHPMCOUNTER22, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(mhpmcounter23, CSR_MHPMCOUNTER23, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(mhpmcounter24, CSR_MHPMCOUNTER24, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(mhpmcounter25, CSR_MHPMCOUNTER25, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(mhpmcounter26, CSR_MHPMCOUNTER26, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(mhpmcounter27, CSR_MHPMCOUNTER27, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(mhpmcounter28, CSR_MHPMCOUNTER28, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(mhpmcounter29, CSR_MHPMCOUNTER29, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(mhpmcounter30, CSR_MHPMCOUNTER30, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(mhpmcounter31, CSR_MHPMCOUNTER31, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(mcycleh, CSR_MCYCLEH, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(minstreth, CSR_MINSTRETH, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(mhpmcounter3h, CSR_MHPMCOUNTER3H, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(mhpmcounter4h, CSR_MHPMCOUNTER4H, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(mhpmcounter5h, CSR_MHPMCOUNTER5H, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(mhpmcounter6h, CSR_MHPMCOUNTER6H, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(mhpmcounter7h, CSR_MHPMCOUNTER7H, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(mhpmcounter8h, CSR_MHPMCOUNTER8H, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(mhpmcounter9h, CSR_MHPMCOUNTER9H, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(mhpmcounter10h, CSR_MHPMCOUNTER10H, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(mhpmcounter11h, CSR_MHPMCOUNTER11H, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(mhpmcounter12h, CSR_MHPMCOUNTER12H, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(mhpmcounter13h, CSR_MHPMCOUNTER13H, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(mhpmcounter14h, CSR_MHPMCOUNTER14H, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(mhpmcounter15h, CSR_MHPMCOUNTER15H, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(mhpmcounter16h, CSR_MHPMCOUNTER16H, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(mhpmcounter17h, CSR_MHPMCOUNTER17H, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(mhpmcounter18h, CSR_MHPMCOUNTER18H, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(mhpmcounter19h, CSR_MHPMCOUNTER19H, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(mhpmcounter20h, CSR_MHPMCOUNTER20H, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(mhpmcounter21h, CSR_MHPMCOUNTER21H, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(mhpmcounter22h, CSR_MHPMCOUNTER22H, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(mhpmcounter23h, CSR_MHPMCOUNTER23H, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(mhpmcounter24h, CSR_MHPMCOUNTER24H, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(mhpmcounter25h, CSR_MHPMCOUNTER25H, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(mhpmcounter26h, CSR_MHPMCOUNTER26H, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(mhpmcounter27h, CSR_MHPMCOUNTER27H, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(mhpmcounter28h, CSR_MHPMCOUNTER28H, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(mhpmcounter29h, CSR_MHPMCOUNTER29H, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(mhpmcounter30h, CSR_MHPMCOUNTER30H, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(mhpmcounter31h, CSR_MHPMCOUNTER31H, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(mcountinhibit, CSR_MCOUNTINHIBIT, CSR_CLASS_I, PRIV_SPEC_CLASS_1P11, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(mhpmevent3, CSR_MHPMEVENT3, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(mhpmevent4, CSR_MHPMEVENT4, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(mhpmevent5, CSR_MHPMEVENT5, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(mhpmevent6, CSR_MHPMEVENT6, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(mhpmevent7, CSR_MHPMEVENT7, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(mhpmevent8, CSR_MHPMEVENT8, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(mhpmevent9, CSR_MHPMEVENT9, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(mhpmevent10, CSR_MHPMEVENT10, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(mhpmevent11, CSR_MHPMEVENT11, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(mhpmevent12, CSR_MHPMEVENT12, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(mhpmevent13, CSR_MHPMEVENT13, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(mhpmevent14, CSR_MHPMEVENT14, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(mhpmevent15, CSR_MHPMEVENT15, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(mhpmevent16, CSR_MHPMEVENT16, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(mhpmevent17, CSR_MHPMEVENT17, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(mhpmevent18, CSR_MHPMEVENT18, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(mhpmevent19, CSR_MHPMEVENT19, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(mhpmevent20, CSR_MHPMEVENT20, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(mhpmevent21, CSR_MHPMEVENT21, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(mhpmevent22, CSR_MHPMEVENT22, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(mhpmevent23, CSR_MHPMEVENT23, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(mhpmevent24, CSR_MHPMEVENT24, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(mhpmevent25, CSR_MHPMEVENT25, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(mhpmevent26, CSR_MHPMEVENT26, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(mhpmevent27, CSR_MHPMEVENT27, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(mhpmevent28, CSR_MHPMEVENT28, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(mhpmevent29, CSR_MHPMEVENT29, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(mhpmevent30, CSR_MHPMEVENT30, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(mhpmevent31, CSR_MHPMEVENT31, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(tselect, CSR_TSELECT, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(tdata1, CSR_TDATA1, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(tdata2, CSR_TDATA2, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(tdata3, CSR_TDATA3, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(dcsr, CSR_DCSR, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(dpc, CSR_DPC, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(dscratch0, CSR_DSCRATCH0, CSR_CLASS_I, PRIV_SPEC_CLASS_1P11, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(dscratch1, CSR_DSCRATCH1, CSR_CLASS_I, PRIV_SPEC_CLASS_1P11, PRIV_SPEC_CLASS_DRAFT)
> +DECLARE_CSR(hstatus, CSR_HSTATUS, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_1P10)
> +DECLARE_CSR(hedeleg, CSR_HEDELEG, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_1P10)
> +DECLARE_CSR(hideleg, CSR_HIDELEG, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_1P10)
> +DECLARE_CSR(hie, CSR_HIE, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_1P10)
> +DECLARE_CSR(htvec, CSR_HTVEC, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_1P10)
> +DECLARE_CSR(hscratch, CSR_HSCRATCH, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_1P10)
> +DECLARE_CSR(hepc, CSR_HEPC, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_1P10)
> +DECLARE_CSR(hcause, CSR_HCAUSE, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_1P10)
> +DECLARE_CSR(hbadaddr, CSR_HBADADDR, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_1P10)
> +DECLARE_CSR(hip, CSR_HIP, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_1P10)
> +DECLARE_CSR(mbase, CSR_MBASE, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_1P10)
> +DECLARE_CSR(mbound, CSR_MBOUND, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_1P10)
> +DECLARE_CSR(mibase, CSR_MIBASE, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_1P10)
> +DECLARE_CSR(mibound, CSR_MIBOUND, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_1P10)
> +DECLARE_CSR(mdbase, CSR_MDBASE, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_1P10)
> +DECLARE_CSR(mdbound, CSR_MDBOUND, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_1P10)
> +DECLARE_CSR(mscounteren, CSR_MSCOUNTEREN, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_1P10)
> +DECLARE_CSR(mhcounteren, CSR_MHCOUNTEREN, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_1P10)
> #endif
> #ifdef DECLARE_CSR_ALIAS
> -/* Ubadaddr is 0x043 in 1.9.1, but 0x043 is utval in 1.10. */
> -DECLARE_CSR_ALIAS(ubadaddr, CSR_UTVAL, CSR_CLASS_I)
> -/* Sbadaddr is 0x143 in 1.9.1, but 0x143 is stval in 1.10. */
> -DECLARE_CSR_ALIAS(sbadaddr, CSR_STVAL, CSR_CLASS_I)
> -/* Sptbr is 0x180 in 1.9.1, but 0x180 is satp in 1.10. */
> -DECLARE_CSR_ALIAS(sptbr, CSR_SATP, CSR_CLASS_I)
> -/* Mbadaddr is 0x343 in 1.9.1, but 0x343 is mtval in 1.10. */
> -DECLARE_CSR_ALIAS(mbadaddr, CSR_MTVAL, CSR_CLASS_I)
> -/* Mucounteren is 0x320 in 1.10, but 0x320 is mcountinhibit in 1.11. */
> -DECLARE_CSR_ALIAS(mucounteren, CSR_MCOUNTINHIBIT, CSR_CLASS_I)
> -/* Dscratch is 0x7b2 in 1.10, but 0x7b2 is dscratch0 in 1.11. */
> -DECLARE_CSR_ALIAS(dscratch, CSR_DSCRATCH0, CSR_CLASS_I)
> +DECLARE_CSR_ALIAS(misa, 0xf10, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_1P9P1)
> +DECLARE_CSR_ALIAS(ubadaddr, CSR_UTVAL, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_1P10)
> +DECLARE_CSR_ALIAS(sbadaddr, CSR_STVAL, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_1P10)
> +DECLARE_CSR_ALIAS(sptbr, CSR_SATP, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_1P10)
> +DECLARE_CSR_ALIAS(mbadaddr, CSR_MTVAL, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_1P10)
> +DECLARE_CSR_ALIAS(mucounteren, CSR_MCOUNTINHIBIT, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_1P10)
> +DECLARE_CSR_ALIAS(dscratch, CSR_DSCRATCH0, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_1P11)
> #endif
> #ifdef DECLARE_CAUSE
> DECLARE_CAUSE("misaligned fetch", CAUSE_MISALIGNED_FETCH)
> diff --git a/include/opcode/riscv.h b/include/opcode/riscv.h
> index d83e9ca..84f7c2a 100644
> --- a/include/opcode/riscv.h
> +++ b/include/opcode/riscv.h
> @@ -365,6 +365,52 @@ struct riscv_ext_version
> unsigned int minor_version;
> };
>
> +/* All RISC-V CSR belong to one of these classes. */
> +
> +enum riscv_csr_class
> +{
> + CSR_CLASS_NONE,
> +
> + CSR_CLASS_I,
> + CSR_CLASS_I_32, /* rv32 only */
> + CSR_CLASS_F, /* f-ext only */
> +};
> +
> +/* The current supported privilege spec versions. */
> +
> +enum riscv_priv_spec_class
> +{
> + PRIV_SPEC_CLASS_NONE,
> +
> + PRIV_SPEC_CLASS_1P9,
> + PRIV_SPEC_CLASS_1P9P1,
> + PRIV_SPEC_CLASS_1P10,
> + PRIV_SPEC_CLASS_1P11,
> + PRIV_SPEC_CLASS_DRAFT
> +};
> +
> +/* This structure holds all restricted conditions for a CSR. */
> +
> +struct riscv_csr_extra
> +{
> + /* Class to which this CSR belongs. Used to decide whether or
> + not this CSR is legal in the current -march context. */
> + enum riscv_csr_class csr_class;
> +
> + /* CSR may have differnet numbers in the previous priv spec. */
> + unsigned address;
> +
> + /* Record the CSR is defined/valid in which versions. */
> + enum riscv_priv_spec_class define_version;
> +
> + /* Record the CSR is aborted/invalid from which versions. If it isn't
> + aborted in the current version, then it should be CSR_CLASS_VDRAFT. */
> + enum riscv_priv_spec_class abort_version;
> +
> + /* The CSR may have more than one setting. */
> + struct riscv_csr_extra *next;
> +};
> +
> /* Instruction is a simple alias (e.g. "mv" for "addi"). */
> #define INSN_ALIAS 0x00000001
>
> @@ -446,5 +492,9 @@ extern const struct riscv_ext_version riscv_ext_version_table[];
>
> extern bfd_boolean
> riscv_get_isa_spec_class (const char *, enum riscv_isa_spec_class *);
> +extern bfd_boolean
> +riscv_get_priv_spec_class (const char *, enum riscv_priv_spec_class *);
> +extern const char *
> +riscv_get_priv_spec_name (enum riscv_priv_spec_class);
>
> #endif /* _RISCV_H_ */
> diff --git a/opcodes/riscv-dis.c b/opcodes/riscv-dis.c
> index d7a184c..98302ff 100644
> --- a/opcodes/riscv-dis.c
> +++ b/opcodes/riscv-dis.c
> @@ -326,7 +326,8 @@ print_insn_args (const char *d, insn_t l, bfd_vma pc, disassemble_info *info)
> unsigned int csr = EXTRACT_OPERAND (CSR, l);
> switch (csr)
> {
> -#define DECLARE_CSR(name, num, class) case num: csr_name = #name; break;
> +#define DECLARE_CSR(name, num, class, define_version, abort_version) \
> + case num: csr_name = #name; break;
> #include "opcode/riscv-opc.h"
> #undef DECLARE_CSR
> }
> diff --git a/opcodes/riscv-opc.c b/opcodes/riscv-opc.c
> index f08b15e..da376ad 100644
> --- a/opcodes/riscv-opc.c
> +++ b/opcodes/riscv-opc.c
> @@ -977,3 +977,54 @@ riscv_get_isa_spec_class (const char *s,
> /* Can not find the supported ISA spec. */
> return FALSE;
> }
> +
> +struct priv_spec_t
> +{
> + const char *name;
> + enum riscv_priv_spec_class class;
> +};
> +
> +/* List for all supported privilege versions. */
> +static const struct priv_spec_t priv_specs[] =
> +{
> + {"1.9", PRIV_SPEC_CLASS_1P9},
> + {"1.9.1", PRIV_SPEC_CLASS_1P9P1},
> + {"1.10", PRIV_SPEC_CLASS_1P10},
> + {"1.11", PRIV_SPEC_CLASS_1P11},
> +
> +/* Terminate the list. */
> + {NULL, 0}
> +};
> +
> +/* Get the corresponding CSR version class by giving a privilege
> + version string. */
> +
> +bfd_boolean
> +riscv_get_priv_spec_class (const char *s,
> + enum riscv_priv_spec_class *class)
> +{
> + const struct priv_spec_t *version;
> +
> + if (s == NULL)
> + return FALSE;
> +
> + for (version = &priv_specs[0]; version->name != NULL; ++version)
> + if (strcmp (version->name, s) == 0)
> + {
> + *class = version->class;
> + return TRUE;
> + }
> +
> + /* Can not find the supported privilege version. */
> + return FALSE;
> +}
> +
> +/* Get the corresponding privilege version string by giving a CSR
> + version class. */
> +
> +const char *
> +riscv_get_priv_spec_name (enum riscv_priv_spec_class class)
> +{
> + /* The first enum is PRIV_SPEC_CLASS_NONE. */
> + return priv_specs[class - 1].name;
> +}
> --
> 2.7.4
>