[4/7] RISC-V: Support version checking for CSR according to privilege version.

Message ID 1587208075-2462-5-git-send-email-nelson.chu@sifive.com
State New
Headers show
Series
  • RISC-V: Support version controling for ISA standard extensions and CSR
Related show

Commit Message

Nelson Chu April 18, 2020, 11:07 a.m.
Support new gas option -mpriv-spec and configure option --with-priv-spec. You
can use these options 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.

New Assembler Options,

* -mpriv-spec=[1p9|1p9p1|1p10|1p11]
This is used to set the privileged spec’s version, and we can decide whether
the CSR is valid or not.

New Default Configure Options,

* --with-priv-spec = [1p9|1p9p1|1p10|1p11]
The syntax is same as -mpriv-spec option.  Assembler will check this setting
if -mpriv-spec option isn’t set.

	gas/
	* config/tc-riscv.c (DEFAULT_PRIV_SPEC): Default configure option.
	You can set it by new configure option --with-priv-spec.
	(enum riscv_csr_vclass default_priv_spec): You can set gas option
	-mpriv-spec or --with-priv-spec, and then assembler will call
	riscv_set_default_priv_version to set the default_priv_spec.
	(riscv_set_default_priv_version): New function.  Set the
	default_priv_spec.  Return 0 if the input privilege name isn't
	supported.  Otherwise, return 1.

	(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 version.
	(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 call
	riscv_set_default_priv_version with DEFAULT_PRIV_SPEC to set the default
	privilege verison.

	* testsuite/gas/riscv/priv-reg-fail-fext.d: This test case just want
	to check the ISA dependency for CSR, so fix the version by adding
	-mpriv-spec=1p11.
	* 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-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.

	* configure.ac: Add new configure option --with-priv-spec.
	* configure: Regenerated.
	* config.in: Regenerated.

	include/
	* opcode/riscv-opc.h (DECLARE_CSR): Store two version information,
	define_version and abort_version for the CSR, which is valid in the
	current privilege spec.  The define_version means which privilege spec
	started to define the CSR, and the abort_version means which privilege
	spec started to abort the CSR.  If the CSR is valid for the newest spec,
	then the abort_version is set to CSR_CLASS_VDRAFT.
	(DECLARE_CSR_ALIAS): Same as DECLARE_CSR, but only for the obselete CSR.
	* opcode/riscv.h: Include "bfd.h" to define bfd_boolean type.
	(enum riscv_csr_vclass): New enum classes.  Define the current supported
	privilege versions.

	opcodes/
	* riscv-opc.c (struct priv_version_t): New structure.
	(struct priv_version_t priv_versions): Store the supported privilege
	versions' classes and their corresponding version string.
	(riscv_get_priv_version_class): New function.  Get the corresponding
	CSR version class by giving a privilege version string.
	(riscv_get_priv_version_name): New function.  Get the corresponding
	privilege version 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.in                                      |   3 +
 gas/config/tc-riscv.c                              | 213 +++++++--
 gas/configure                                      |  13 +
 gas/configure.ac                                   |   8 +
 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/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                             |  19 +
 opcodes/riscv-dis.c                                |   3 +-
 opcodes/riscv-opc.c                                |  55 +++
 25 files changed, 728 insertions(+), 311 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

-- 
2.7.4

Comments

Nelson Chu April 18, 2020, 11:18 a.m. | #1
CC Palmer.

Thanks
Nelson

On Sat, Apr 18, 2020 at 7:08 PM Nelson Chu <nelson.chu@sifive.com> wrote:
>

> Support new gas option -mpriv-spec and configure option --with-priv-spec. You

> can use these options 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.

>

> New Assembler Options,

>

> * -mpriv-spec=[1p9|1p9p1|1p10|1p11]

> This is used to set the privileged spec’s version, and we can decide whether

> the CSR is valid or not.

>

> New Default Configure Options,

>

> * --with-priv-spec = [1p9|1p9p1|1p10|1p11]

> The syntax is same as -mpriv-spec option.  Assembler will check this setting

> if -mpriv-spec option isn’t set.

>

>         gas/

>         * config/tc-riscv.c (DEFAULT_PRIV_SPEC): Default configure option.

>         You can set it by new configure option --with-priv-spec.

>         (enum riscv_csr_vclass default_priv_spec): You can set gas option

>         -mpriv-spec or --with-priv-spec, and then assembler will call

>         riscv_set_default_priv_version to set the default_priv_spec.

>         (riscv_set_default_priv_version): New function.  Set the

>         default_priv_spec.  Return 0 if the input privilege name isn't

>         supported.  Otherwise, return 1.

>

>         (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 version.

>         (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 call

>         riscv_set_default_priv_version with DEFAULT_PRIV_SPEC to set the default

>         privilege verison.

>

>         * testsuite/gas/riscv/priv-reg-fail-fext.d: This test case just want

>         to check the ISA dependency for CSR, so fix the version by adding

>         -mpriv-spec=1p11.

>         * 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-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.

>

>         * configure.ac: Add new configure option --with-priv-spec.

>         * configure: Regenerated.

>         * config.in: Regenerated.

>

>         include/

>         * opcode/riscv-opc.h (DECLARE_CSR): Store two version information,

>         define_version and abort_version for the CSR, which is valid in the

>         current privilege spec.  The define_version means which privilege spec

>         started to define the CSR, and the abort_version means which privilege

>         spec started to abort the CSR.  If the CSR is valid for the newest spec,

>         then the abort_version is set to CSR_CLASS_VDRAFT.

>         (DECLARE_CSR_ALIAS): Same as DECLARE_CSR, but only for the obselete CSR.

>         * opcode/riscv.h: Include "bfd.h" to define bfd_boolean type.

>         (enum riscv_csr_vclass): New enum classes.  Define the current supported

>         privilege versions.

>

>         opcodes/

>         * riscv-opc.c (struct priv_version_t): New structure.

>         (struct priv_version_t priv_versions): Store the supported privilege

>         versions' classes and their corresponding version string.

>         (riscv_get_priv_version_class): New function.  Get the corresponding

>         CSR version class by giving a privilege version string.

>         (riscv_get_priv_version_name): New function.  Get the corresponding

>         privilege version 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.in                                      |   3 +

>  gas/config/tc-riscv.c                              | 213 +++++++--

>  gas/configure                                      |  13 +

>  gas/configure.ac                                   |   8 +

>  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/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                             |  19 +

>  opcodes/riscv-dis.c                                |   3 +-

>  opcodes/riscv-opc.c                                |  55 +++

>  25 files changed, 728 insertions(+), 311 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 c75059b..a972c60 100644

> --- a/binutils/dwarf.c

> +++ b/binutils/dwarf.c

> @@ -7378,7 +7378,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.in b/gas/config.in

> index 935bd9b..093f474 100644

> --- a/gas/config.in

> +++ b/gas/config.in

> @@ -59,6 +59,9 @@

>  /* Define to 1 if you want to fix Loongson3 LLSC Errata by default. */

>  #undef DEFAULT_MIPS_FIX_LOONGSON3_LLSC

>

> +/* Define default value for -mpriv-spec */

> +#undef DEFAULT_PRIV_SPEC

> +

>  /* Define to 1 if you want to generate RISC-V arch attribute by default. */

>  #undef DEFAULT_RISCV_ATTR

>

> diff --git a/gas/config/tc-riscv.c b/gas/config/tc-riscv.c

> index bfcf2f0..6528a03 100644

> --- a/gas/config/tc-riscv.c

> +++ b/gas/config/tc-riscv.c

> @@ -75,10 +75,15 @@ struct riscv_cl_insn

>  #define DEFAULT_RISCV_ISA_VERSION NULL

>  #endif

>

> +#ifndef DEFAULT_PRIV_SPEC

> +#define DEFAULT_PRIV_SPEC "1p11"

> +#endif

> +

>  static const char default_arch[] = DEFAULT_ARCH;

>  static const char *default_arch_with_ext = DEFAULT_ARCH_WITH_EXT;

>  static const char *default_isa_spec = DEFAULT_ISA_SPEC;

>  static const char *default_riscv_isa_version = DEFAULT_RISCV_ISA_VERSION;

> +static enum riscv_csr_vclass default_priv_spec = CSR_CLASS_VNONE;

>

>  static unsigned xlen = 0; /* width of an x-register */

>  static unsigned abi_xlen = 0; /* width of a pointer in the ABI */

> @@ -536,8 +541,9 @@ enum reg_class

>  {

>    RCLASS_GPR,

>    RCLASS_FPR,

> -  RCLASS_CSR,

> -  RCLASS_MAX

> +  RCLASS_MAX,

> +

> +  RCLASS_CSR

>  };

>

>  static struct hash_control *reg_names_hash = NULL;

> @@ -585,84 +591,197 @@ 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_csr_vclass 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_csr_vclass abort_version;

> +

> +  /* The CSR may have more than one setting.  */

> +  struct riscv_csr_extra *next;

>  };

>

> -/* Init two hashes, csr_extra_hash and reg_names_hash, for CSR.  */

> +/* Set the default_priv_spec, assembler will find the suitable CSR address

> +   according to default_priv_spec.  Return 0 if the input priv name isn't

> +   supported.  Otherwise, return 1.  */

>

> -static void

> -riscv_init_csr_hashes (const char *name,

> -                      unsigned address,

> -                      enum riscv_csr_class class)

> +static int

> +riscv_set_default_priv_version (const char *s)

>  {

> -  struct riscv_csr_extra *entry = XNEW (struct riscv_csr_extra);

> -  entry->csr_class = class;

> +  enum riscv_csr_vclass class;

> +  if (!riscv_get_priv_version_class (s, &class))

> +    {

> +      as_bad (_("Unsupported RISC-V privilege version set by "

> +               "-mpriv-spec=%s."), s);

> +      return 0;

> +    }

> +  else

> +    default_priv_spec = class;

> +  return 1;

> +}

> +

> +/* Init hash table csr_extra_hash to handle CSR.  */

>

> -  const char *hash_error =

> -    hash_insert (csr_extra_hash, name, (void *) entry);

> -  if (hash_error != NULL)

> +static void

> +riscv_init_csr_hash (const char *name,

> +                    unsigned address,

> +                    enum riscv_csr_class class,

> +                    enum riscv_csr_vclass define_version,

> +                    enum riscv_csr_vclass 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)

>      {

> -      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."));

> +      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;

>      }

>

> -  hash_reg_name (RCLASS_CSR, name, address);

> +  /* Duplicate setting for the CSR, just return and do nothing.  */

> +  if (!need_enrty)

> +    return;

> +

> +  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;

>  }

>

>  /* Check wether the CSR is valid according to the ISA.  */

>

> -static bfd_boolean

> -riscv_csr_class_check (enum riscv_csr_class csr_class)

> +static void

> +riscv_csr_class_check (const char *s,

> +                      enum riscv_csr_class csr_class)

>  {

> +  bfd_boolean result = TRUE;

> +

> +  /* Don't check the ISA dependency when -mcsr-check isn't set.  */

> +  if (!riscv_opts.csr_check)

> +    return;

> +

>    switch (csr_class)

>      {

> -    case CSR_CLASS_I: return riscv_subset_supports ("i");

> -    case CSR_CLASS_F: return riscv_subset_supports ("f");

> +    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:

> -      return (xlen == 32 && riscv_subset_supports ("i"));

> -

> +      result = (xlen == 32 && riscv_subset_supports ("i"));

> +      break;

>      default:

> -      return FALSE;

> +      as_bad (_("internal: bad RISC-V CSR class (0x%x)"), csr_class);

>      }

> +  if (!result)

> +    as_warn (_("Invalid CSR `%s' for the current ISA"), s);

>  }

>

> -/* 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.  */

> +/* Check and find the CSR address according to the privilege spec version.  */

>

> -static bfd_boolean

> +static void

> +riscv_csr_version_check (const char *csr_name,

> +                        struct riscv_csr_extra **entryP)

> +{

> +  struct riscv_csr_extra *entry = *entryP;

> +  while (entry != NULL)

> +    {

> +      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;

> +    }

> +

> +  /* 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_version_name (default_priv_spec);

> +      if (priv_name != NULL)

> +       as_warn (_("Invalid CSR `%s' for the privilege version `%s'"),

> +                csr_name, priv_name);

> +    }

> +}

> +

> +/* 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 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 version.  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);

>  }

>

> @@ -946,8 +1065,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

>

> @@ -2434,6 +2555,7 @@ enum options

>    OPTION_NO_CSR_CHECK,

>    OPTION_MISA_SPEC,

>    OPTION_MRISCV_ISA_VERSION,

> +  OPTION_MPRIV_SPEC,

>    OPTION_END_OF_ENUM

>  };

>

> @@ -2452,6 +2574,7 @@ struct option md_longopts[] =

>    {"mno-csr-check", no_argument, NULL, OPTION_NO_CSR_CHECK},

>    {"misa-spec", required_argument, NULL, OPTION_MISA_SPEC},

>    {"mriscv-isa-version", required_argument, NULL, OPTION_MRISCV_ISA_VERSION},

> +  {"mpriv-spec", required_argument, NULL, OPTION_MPRIV_SPEC},

>

>    {NULL, no_argument, NULL, 0}

>  };

> @@ -2548,6 +2671,9 @@ md_parse_option (int c, const char *arg)

>        default_riscv_isa_version = arg;

>        break;

>

> +    case OPTION_MPRIV_SPEC:

> +      return riscv_set_default_priv_version (arg);

> +

>      default:

>        return 0;

>      }

> @@ -2594,6 +2720,11 @@ riscv_after_parse_args (void)

>    if (riscv_subset_supports ("e"))

>      riscv_set_rve (TRUE);

>

> +  /* If the -mpriv-spec isn't set, then we set the default privilege version

> +     according to DEFAULT_PRIV_SPEC,  */

> +  if (default_priv_spec == CSR_CLASS_VNONE)

> +    riscv_set_default_priv_version (DEFAULT_PRIV_SPEC);

> +

>    /* Infer ABI from ISA if not specified on command line.  */

>    if (abi_xlen == 0)

>      abi_xlen = xlen;

> diff --git a/gas/configure b/gas/configure

> index bce847a..0911152 100755

> --- a/gas/configure

> +++ b/gas/configure

> @@ -13068,6 +13068,19 @@ _ACEOF

>         fi

>         { $as_echo "$as_me:${as_lineno-$LINENO}: result: $with_riscv_isa_version" >&5

>  $as_echo "$with_riscv_isa_version" >&6; }

> +

> +        # --with-priv-spec=[1p9p1|1p10|1p11].

> +       { $as_echo "$as_me:${as_lineno-$LINENO}: checking for default configuration of --with-priv-spec" >&5

> +$as_echo_n "checking for default configuration of --with-priv-spec... " >&6; }

> +       if test "x${with_priv_spec}" != x; then

> +

> +cat >>confdefs.h <<_ACEOF

> +#define DEFAULT_PRIV_SPEC "$with_priv_spec"

> +_ACEOF

> +

> +       fi

> +       { $as_echo "$as_me:${as_lineno-$LINENO}: result: $with_priv_spec" >&5

> +$as_echo "$with_priv_spec" >&6; }

>         ;;

>

>        rl78)

> diff --git a/gas/configure.ac b/gas/configure.ac

> index be4ba20..c3d3639 100644

> --- a/gas/configure.ac

> +++ b/gas/configure.ac

> @@ -606,6 +606,14 @@ changequote([,])dnl

>                               covered by --with-isa-spec])

>         fi

>         AC_MSG_RESULT($with_riscv_isa_version)

> +

> +        # --with-priv-spec=[1p9p1|1p10|1p11].

> +       AC_MSG_CHECKING(for default configuration of --with-priv-spec)

> +       if test "x${with_priv_spec}" != x; then

> +         AC_DEFINE_UNQUOTED(DEFAULT_PRIV_SPEC, "$with_priv_spec",

> +                            [Define default value for -mpriv-spec])

> +       fi

> +       AC_MSG_RESULT($with_priv_spec)

>         ;;

>

>        rl78)

> diff --git a/gas/testsuite/gas/riscv/priv-reg-fail-fext.d b/gas/testsuite/gas/riscv/priv-reg-fail-fext.d

> index da53566..0033e3c 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=1p11

>  #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..d3b1bad 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 version `1p11'

> +.*Warning: Invalid CSR `sbadaddr' for the privilege version `1p11'

> +.*Warning: Invalid CSR `sptbr' for the privilege version `1p11'

> +.*Warning: Invalid CSR `mbadaddr' for the privilege version `1p11'

> +.*Warning: Invalid CSR `mucounteren' for the privilege version `1p11'

> +.*Warning: Invalid CSR `dscratch' for the privilege version `1p11'

> +.*Warning: Invalid CSR `hstatus' for the privilege version `1p11'

> +.*Warning: Invalid CSR `hedeleg' for the privilege version `1p11'

> +.*Warning: Invalid CSR `hideleg' for the privilege version `1p11'

> +.*Warning: Invalid CSR `hie' for the privilege version `1p11'

> +.*Warning: Invalid CSR `htvec' for the privilege version `1p11'

> +.*Warning: Invalid CSR `hscratch' for the privilege version `1p11'

> +.*Warning: Invalid CSR `hepc' for the privilege version `1p11'

> +.*Warning: Invalid CSR `hcause' for the privilege version `1p11'

> +.*Warning: Invalid CSR `hbadaddr' for the privilege version `1p11'

> +.*Warning: Invalid CSR `hip' for the privilege version `1p11'

> +.*Warning: Invalid CSR `mbase' for the privilege version `1p11'

> +.*Warning: Invalid CSR `mbound' for the privilege version `1p11'

> +.*Warning: Invalid CSR `mibase' for the privilege version `1p11'

> +.*Warning: Invalid CSR `mibound' for the privilege version `1p11'

> +.*Warning: Invalid CSR `mdbase' for the privilege version `1p11'

> +.*Warning: Invalid CSR `mdbound' for the privilege version `1p11'

> +.*Warning: Invalid CSR `mscounteren' for the privilege version `1p11'

> +.*Warning: Invalid CSR `mhcounteren' for the privilege version `1p11'

> 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..bbf83b5 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=1p11

>  #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..e8355f1 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 version `1p11'

> +.*Warning: Invalid CSR `sbadaddr' for the privilege version `1p11'

> +.*Warning: Invalid CSR `sptbr' for the privilege version `1p11'

> +.*Warning: Invalid CSR `mbadaddr' for the privilege version `1p11'

> +.*Warning: Invalid CSR `mucounteren' for the privilege version `1p11'

> +.*Warning: Invalid CSR `dscratch' for the privilege version `1p11'

> +.*Warning: Invalid CSR `hstatus' for the privilege version `1p11'

> +.*Warning: Invalid CSR `hedeleg' for the privilege version `1p11'

> +.*Warning: Invalid CSR `hideleg' for the privilege version `1p11'

> +.*Warning: Invalid CSR `hie' for the privilege version `1p11'

> +.*Warning: Invalid CSR `htvec' for the privilege version `1p11'

> +.*Warning: Invalid CSR `hscratch' for the privilege version `1p11'

> +.*Warning: Invalid CSR `hepc' for the privilege version `1p11'

> +.*Warning: Invalid CSR `hcause' for the privilege version `1p11'

> +.*Warning: Invalid CSR `hbadaddr' for the privilege version `1p11'

> +.*Warning: Invalid CSR `hip' for the privilege version `1p11'

> +.*Warning: Invalid CSR `mbase' for the privilege version `1p11'

> +.*Warning: Invalid CSR `mbound' for the privilege version `1p11'

> +.*Warning: Invalid CSR `mibase' for the privilege version `1p11'

> +.*Warning: Invalid CSR `mibound' for the privilege version `1p11'

> +.*Warning: Invalid CSR `mdbase' for the privilege version `1p11'

> +.*Warning: Invalid CSR `mdbound' for the privilege version `1p11'

> +.*Warning: Invalid CSR `mscounteren' for the privilege version `1p11'

> +.*Warning: Invalid CSR `mhcounteren' for the privilege version `1p11'

> 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..a0b88cf 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=1p11

>  #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..5e96a85 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 version `1p11'

> +.*Warning: Invalid CSR `sbadaddr' for the privilege version `1p11'

> +.*Warning: Invalid CSR `sptbr' for the privilege version `1p11'

> +.*Warning: Invalid CSR `mbadaddr' for the privilege version `1p11'

> +.*Warning: Invalid CSR `mucounteren' for the privilege version `1p11'

> +.*Warning: Invalid CSR `dscratch' for the privilege version `1p11'

> +.*Warning: Invalid CSR `hstatus' for the privilege version `1p11'

> +.*Warning: Invalid CSR `hedeleg' for the privilege version `1p11'

> +.*Warning: Invalid CSR `hideleg' for the privilege version `1p11'

> +.*Warning: Invalid CSR `hie' for the privilege version `1p11'

> +.*Warning: Invalid CSR `htvec' for the privilege version `1p11'

> +.*Warning: Invalid CSR `hscratch' for the privilege version `1p11'

> +.*Warning: Invalid CSR `hepc' for the privilege version `1p11'

> +.*Warning: Invalid CSR `hcause' for the privilege version `1p11'

> +.*Warning: Invalid CSR `hbadaddr' for the privilege version `1p11'

> +.*Warning: Invalid CSR `hip' for the privilege version `1p11'

> +.*Warning: Invalid CSR `mbase' for the privilege version `1p11'

> +.*Warning: Invalid CSR `mbound' for the privilege version `1p11'

> +.*Warning: Invalid CSR `mibase' for the privilege version `1p11'

> +.*Warning: Invalid CSR `mibound' for the privilege version `1p11'

> +.*Warning: Invalid CSR `mdbase' for the privilege version `1p11'

> +.*Warning: Invalid CSR `mdbound' for the privilege version `1p11'

> +.*Warning: Invalid CSR `mscounteren' for the privilege version `1p11'

> +.*Warning: Invalid CSR `mhcounteren' for the privilege version `1p11'

> 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..d7a788a

> --- /dev/null

> +++ b/gas/testsuite/gas/riscv/priv-reg-fail-version-1p10.d

> @@ -0,0 +1,3 @@

> +#as: -march=rv32if -mcsr-check -mpriv-spec=1p10

> +#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..f532962

> --- /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 version `1p10'

> +.*Warning: Invalid CSR `dscratch0' for the privilege version `1p10'

> +.*Warning: Invalid CSR `dscratch1' for the privilege version `1p10'

> +.*Warning: Invalid CSR `ubadaddr' for the privilege version `1p10'

> +.*Warning: Invalid CSR `sbadaddr' for the privilege version `1p10'

> +.*Warning: Invalid CSR `sptbr' for the privilege version `1p10'

> +.*Warning: Invalid CSR `mbadaddr' for the privilege version `1p10'

> +.*Warning: Invalid CSR `mucounteren' for the privilege version `1p10'

> +.*Warning: Invalid CSR `hstatus' for the privilege version `1p10'

> +.*Warning: Invalid CSR `hedeleg' for the privilege version `1p10'

> +.*Warning: Invalid CSR `hideleg' for the privilege version `1p10'

> +.*Warning: Invalid CSR `hie' for the privilege version `1p10'

> +.*Warning: Invalid CSR `htvec' for the privilege version `1p10'

> +.*Warning: Invalid CSR `hscratch' for the privilege version `1p10'

> +.*Warning: Invalid CSR `hepc' for the privilege version `1p10'

> +.*Warning: Invalid CSR `hcause' for the privilege version `1p10'

> +.*Warning: Invalid CSR `hbadaddr' for the privilege version `1p10'

> +.*Warning: Invalid CSR `hip' for the privilege version `1p10'

> +.*Warning: Invalid CSR `mbase' for the privilege version `1p10'

> +.*Warning: Invalid CSR `mbound' for the privilege version `1p10'

> +.*Warning: Invalid CSR `mibase' for the privilege version `1p10'

> +.*Warning: Invalid CSR `mibound' for the privilege version `1p10'

> +.*Warning: Invalid CSR `mdbase' for the privilege version `1p10'

> +.*Warning: Invalid CSR `mdbound' for the privilege version `1p10'

> +.*Warning: Invalid CSR `mscounteren' for the privilege version `1p10'

> +.*Warning: Invalid CSR `mhcounteren' for the privilege version `1p10'

> 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..2830c83

> --- /dev/null

> +++ b/gas/testsuite/gas/riscv/priv-reg-fail-version-1p11.d

> @@ -0,0 +1,3 @@

> +#as: -march=rv32if -mcsr-check -mpriv-spec=1p11

> +#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..252f96a

> --- /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 version `1p11'

> +.*Warning: Invalid CSR `sbadaddr' for the privilege version `1p11'

> +.*Warning: Invalid CSR `sptbr' for the privilege version `1p11'

> +.*Warning: Invalid CSR `mbadaddr' for the privilege version `1p11'

> +.*Warning: Invalid CSR `mucounteren' for the privilege version `1p11'

> +.*Warning: Invalid CSR `dscratch' for the privilege version `1p11'

> +.*Warning: Invalid CSR `hstatus' for the privilege version `1p11'

> +.*Warning: Invalid CSR `hedeleg' for the privilege version `1p11'

> +.*Warning: Invalid CSR `hideleg' for the privilege version `1p11'

> +.*Warning: Invalid CSR `hie' for the privilege version `1p11'

> +.*Warning: Invalid CSR `htvec' for the privilege version `1p11'

> +.*Warning: Invalid CSR `hscratch' for the privilege version `1p11'

> +.*Warning: Invalid CSR `hepc' for the privilege version `1p11'

> +.*Warning: Invalid CSR `hcause' for the privilege version `1p11'

> +.*Warning: Invalid CSR `hbadaddr' for the privilege version `1p11'

> +.*Warning: Invalid CSR `hip' for the privilege version `1p11'

> +.*Warning: Invalid CSR `mbase' for the privilege version `1p11'

> +.*Warning: Invalid CSR `mbound' for the privilege version `1p11'

> +.*Warning: Invalid CSR `mibase' for the privilege version `1p11'

> +.*Warning: Invalid CSR `mibound' for the privilege version `1p11'

> +.*Warning: Invalid CSR `mdbase' for the privilege version `1p11'

> +.*Warning: Invalid CSR `mdbound' for the privilege version `1p11'

> +.*Warning: Invalid CSR `mscounteren' for the privilege version `1p11'

> +.*Warning: Invalid CSR `mhcounteren' for the privilege version `1p11'

> 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..70c405f

> --- /dev/null

> +++ b/gas/testsuite/gas/riscv/priv-reg-fail-version-1p9.d

> @@ -0,0 +1,3 @@

> +#as: -march=rv32if -mcsr-check -mpriv-spec=1p9

> +#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..92e1463

> --- /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 version `1p9'

> +.*Warning: Invalid CSR `scounteren' for the privilege version `1p9'

> +.*Warning: Invalid CSR `stval' for the privilege version `1p9'

> +.*Warning: Invalid CSR `satp' for the privilege version `1p9'

> +.*Warning: Invalid CSR `mcounteren' for the privilege version `1p9'

> +.*Warning: Invalid CSR `mtval' for the privilege version `1p9'

> +.*Warning: Invalid CSR `pmpcfg0' for the privilege version `1p9'

> +.*Warning: Invalid CSR `pmpcfg1' for the privilege version `1p9'

> +.*Warning: Invalid CSR `pmpcfg2' for the privilege version `1p9'

> +.*Warning: Invalid CSR `pmpcfg3' for the privilege version `1p9'

> +.*Warning: Invalid CSR `pmpaddr0' for the privilege version `1p9'

> +.*Warning: Invalid CSR `pmpaddr1' for the privilege version `1p9'

> +.*Warning: Invalid CSR `pmpaddr2' for the privilege version `1p9'

> +.*Warning: Invalid CSR `pmpaddr3' for the privilege version `1p9'

> +.*Warning: Invalid CSR `pmpaddr4' for the privilege version `1p9'

> +.*Warning: Invalid CSR `pmpaddr5' for the privilege version `1p9'

> +.*Warning: Invalid CSR `pmpaddr6' for the privilege version `1p9'

> +.*Warning: Invalid CSR `pmpaddr7' for the privilege version `1p9'

> +.*Warning: Invalid CSR `pmpaddr8' for the privilege version `1p9'

> +.*Warning: Invalid CSR `pmpaddr9' for the privilege version `1p9'

> +.*Warning: Invalid CSR `pmpaddr10' for the privilege version `1p9'

> +.*Warning: Invalid CSR `pmpaddr11' for the privilege version `1p9'

> +.*Warning: Invalid CSR `pmpaddr12' for the privilege version `1p9'

> +.*Warning: Invalid CSR `pmpaddr13' for the privilege version `1p9'

> +.*Warning: Invalid CSR `pmpaddr14' for the privilege version `1p9'

> +.*Warning: Invalid CSR `pmpaddr15' for the privilege version `1p9'

> +.*Warning: Invalid CSR `mcountinhibit' for the privilege version `1p9'

> +.*Warning: Invalid CSR `dscratch0' for the privilege version `1p9'

> +.*Warning: Invalid CSR `dscratch1' for the privilege version `1p9'

> 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..2bd4bbf

> --- /dev/null

> +++ b/gas/testsuite/gas/riscv/priv-reg-fail-version-1p9p1.d

> @@ -0,0 +1,3 @@

> +#as: -march=rv32if -mcsr-check -mpriv-spec=1p9p1

> +#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..6cde0b3

> --- /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 version `1p9p1'

> +.*Warning: Invalid CSR `scounteren' for the privilege version `1p9p1'

> +.*Warning: Invalid CSR `stval' for the privilege version `1p9p1'

> +.*Warning: Invalid CSR `satp' for the privilege version `1p9p1'

> +.*Warning: Invalid CSR `mcounteren' for the privilege version `1p9p1'

> +.*Warning: Invalid CSR `mtval' for the privilege version `1p9p1'

> +.*Warning: Invalid CSR `pmpcfg0' for the privilege version `1p9p1'

> +.*Warning: Invalid CSR `pmpcfg1' for the privilege version `1p9p1'

> +.*Warning: Invalid CSR `pmpcfg2' for the privilege version `1p9p1'

> +.*Warning: Invalid CSR `pmpcfg3' for the privilege version `1p9p1'

> +.*Warning: Invalid CSR `pmpaddr0' for the privilege version `1p9p1'

> +.*Warning: Invalid CSR `pmpaddr1' for the privilege version `1p9p1'

> +.*Warning: Invalid CSR `pmpaddr2' for the privilege version `1p9p1'

> +.*Warning: Invalid CSR `pmpaddr3' for the privilege version `1p9p1'

> +.*Warning: Invalid CSR `pmpaddr4' for the privilege version `1p9p1'

> +.*Warning: Invalid CSR `pmpaddr5' for the privilege version `1p9p1'

> +.*Warning: Invalid CSR `pmpaddr6' for the privilege version `1p9p1'

> +.*Warning: Invalid CSR `pmpaddr7' for the privilege version `1p9p1'

> +.*Warning: Invalid CSR `pmpaddr8' for the privilege version `1p9p1'

> +.*Warning: Invalid CSR `pmpaddr9' for the privilege version `1p9p1'

> +.*Warning: Invalid CSR `pmpaddr10' for the privilege version `1p9p1'

> +.*Warning: Invalid CSR `pmpaddr11' for the privilege version `1p9p1'

> +.*Warning: Invalid CSR `pmpaddr12' for the privilege version `1p9p1'

> +.*Warning: Invalid CSR `pmpaddr13' for the privilege version `1p9p1'

> +.*Warning: Invalid CSR `pmpaddr14' for the privilege version `1p9p1'

> +.*Warning: Invalid CSR `pmpaddr15' for the privilege version `1p9p1'

> +.*Warning: Invalid CSR `mcountinhibit' for the privilege version `1p9p1'

> +.*Warning: Invalid CSR `dscratch0' for the privilege version `1p9p1'

> +.*Warning: Invalid CSR `dscratch1' for the privilege version `1p9p1'

> 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..ab11c31 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, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(uie, CSR_UIE, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(utvec, CSR_UTVEC, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(uscratch, CSR_USCRATCH, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(uepc, CSR_UEPC, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(ucause, CSR_UCAUSE, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(utval, CSR_UTVAL, CSR_CLASS_I, CSR_CLASS_V1P10, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(uip, CSR_UIP, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(fflags, CSR_FFLAGS, CSR_CLASS_F, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(frm, CSR_FRM, CSR_CLASS_F, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(fcsr, CSR_FCSR, CSR_CLASS_F, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(cycle, CSR_CYCLE, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(time, CSR_TIME, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(instret, CSR_INSTRET, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(hpmcounter3, CSR_HPMCOUNTER3, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(hpmcounter4, CSR_HPMCOUNTER4, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(hpmcounter5, CSR_HPMCOUNTER5, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(hpmcounter6, CSR_HPMCOUNTER6, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(hpmcounter7, CSR_HPMCOUNTER7, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(hpmcounter8, CSR_HPMCOUNTER8, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(hpmcounter9, CSR_HPMCOUNTER9, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(hpmcounter10, CSR_HPMCOUNTER10, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(hpmcounter11, CSR_HPMCOUNTER11, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(hpmcounter12, CSR_HPMCOUNTER12, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(hpmcounter13, CSR_HPMCOUNTER13, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(hpmcounter14, CSR_HPMCOUNTER14, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(hpmcounter15, CSR_HPMCOUNTER15, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(hpmcounter16, CSR_HPMCOUNTER16, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(hpmcounter17, CSR_HPMCOUNTER17, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(hpmcounter18, CSR_HPMCOUNTER18, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(hpmcounter19, CSR_HPMCOUNTER19, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(hpmcounter20, CSR_HPMCOUNTER20, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(hpmcounter21, CSR_HPMCOUNTER21, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(hpmcounter22, CSR_HPMCOUNTER22, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(hpmcounter23, CSR_HPMCOUNTER23, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(hpmcounter24, CSR_HPMCOUNTER24, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(hpmcounter25, CSR_HPMCOUNTER25, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(hpmcounter26, CSR_HPMCOUNTER26, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(hpmcounter27, CSR_HPMCOUNTER27, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(hpmcounter28, CSR_HPMCOUNTER28, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(hpmcounter29, CSR_HPMCOUNTER29, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(hpmcounter30, CSR_HPMCOUNTER30, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(hpmcounter31, CSR_HPMCOUNTER31, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(cycleh, CSR_CYCLEH, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(timeh, CSR_TIMEH, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(instreth, CSR_INSTRETH, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(hpmcounter3h, CSR_HPMCOUNTER3H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(hpmcounter4h, CSR_HPMCOUNTER4H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(hpmcounter5h, CSR_HPMCOUNTER5H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(hpmcounter6h, CSR_HPMCOUNTER6H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(hpmcounter7h, CSR_HPMCOUNTER7H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(hpmcounter8h, CSR_HPMCOUNTER8H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(hpmcounter9h, CSR_HPMCOUNTER9H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(hpmcounter10h, CSR_HPMCOUNTER10H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(hpmcounter11h, CSR_HPMCOUNTER11H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(hpmcounter12h, CSR_HPMCOUNTER12H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(hpmcounter13h, CSR_HPMCOUNTER13H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(hpmcounter14h, CSR_HPMCOUNTER14H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(hpmcounter15h, CSR_HPMCOUNTER15H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(hpmcounter16h, CSR_HPMCOUNTER16H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(hpmcounter17h, CSR_HPMCOUNTER17H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(hpmcounter18h, CSR_HPMCOUNTER18H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(hpmcounter19h, CSR_HPMCOUNTER19H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(hpmcounter20h, CSR_HPMCOUNTER20H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(hpmcounter21h, CSR_HPMCOUNTER21H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(hpmcounter22h, CSR_HPMCOUNTER22H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(hpmcounter23h, CSR_HPMCOUNTER23H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(hpmcounter24h, CSR_HPMCOUNTER24H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(hpmcounter25h, CSR_HPMCOUNTER25H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(hpmcounter26h, CSR_HPMCOUNTER26H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(hpmcounter27h, CSR_HPMCOUNTER27H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(hpmcounter28h, CSR_HPMCOUNTER28H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(hpmcounter29h, CSR_HPMCOUNTER29H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(hpmcounter30h, CSR_HPMCOUNTER30H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(hpmcounter31h, CSR_HPMCOUNTER31H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(sstatus, CSR_SSTATUS, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(sedeleg, CSR_SEDELEG, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(sideleg, CSR_SIDELEG, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(sie, CSR_SIE, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(stvec, CSR_STVEC, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(scounteren, CSR_SCOUNTEREN, CSR_CLASS_I, CSR_CLASS_V1P10, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(sscratch, CSR_SSCRATCH, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(sepc, CSR_SEPC, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(scause, CSR_SCAUSE, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(stval, CSR_STVAL, CSR_CLASS_I, CSR_CLASS_V1P10, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(sip, CSR_SIP, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(satp, CSR_SATP, CSR_CLASS_I, CSR_CLASS_V1P10, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mvendorid, CSR_MVENDORID, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(marchid, CSR_MARCHID, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mimpid, CSR_MIMPID, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mhartid, CSR_MHARTID, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mstatus, CSR_MSTATUS, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(misa, CSR_MISA, CSR_CLASS_I, CSR_CLASS_V1P9P1, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(medeleg, CSR_MEDELEG, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mideleg, CSR_MIDELEG, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mie, CSR_MIE, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mtvec, CSR_MTVEC, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mcounteren, CSR_MCOUNTEREN, CSR_CLASS_I, CSR_CLASS_V1P10, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mscratch, CSR_MSCRATCH, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mepc, CSR_MEPC, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mcause, CSR_MCAUSE, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mtval, CSR_MTVAL, CSR_CLASS_I, CSR_CLASS_V1P10, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mip, CSR_MIP, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(pmpcfg0, CSR_PMPCFG0, CSR_CLASS_I, CSR_CLASS_V1P10, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(pmpcfg1, CSR_PMPCFG1, CSR_CLASS_I_32, CSR_CLASS_V1P10, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(pmpcfg2, CSR_PMPCFG2, CSR_CLASS_I, CSR_CLASS_V1P10, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(pmpcfg3, CSR_PMPCFG3, CSR_CLASS_I_32, CSR_CLASS_V1P10, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(pmpaddr0, CSR_PMPADDR0, CSR_CLASS_I, CSR_CLASS_V1P10, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(pmpaddr1, CSR_PMPADDR1, CSR_CLASS_I, CSR_CLASS_V1P10, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(pmpaddr2, CSR_PMPADDR2, CSR_CLASS_I, CSR_CLASS_V1P10, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(pmpaddr3, CSR_PMPADDR3, CSR_CLASS_I, CSR_CLASS_V1P10, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(pmpaddr4, CSR_PMPADDR4, CSR_CLASS_I, CSR_CLASS_V1P10, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(pmpaddr5, CSR_PMPADDR5, CSR_CLASS_I, CSR_CLASS_V1P10, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(pmpaddr6, CSR_PMPADDR6, CSR_CLASS_I, CSR_CLASS_V1P10, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(pmpaddr7, CSR_PMPADDR7, CSR_CLASS_I, CSR_CLASS_V1P10, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(pmpaddr8, CSR_PMPADDR8, CSR_CLASS_I, CSR_CLASS_V1P10, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(pmpaddr9, CSR_PMPADDR9, CSR_CLASS_I, CSR_CLASS_V1P10, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(pmpaddr10, CSR_PMPADDR10, CSR_CLASS_I, CSR_CLASS_V1P10, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(pmpaddr11, CSR_PMPADDR11, CSR_CLASS_I, CSR_CLASS_V1P10, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(pmpaddr12, CSR_PMPADDR12, CSR_CLASS_I, CSR_CLASS_V1P10, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(pmpaddr13, CSR_PMPADDR13, CSR_CLASS_I, CSR_CLASS_V1P10, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(pmpaddr14, CSR_PMPADDR14, CSR_CLASS_I, CSR_CLASS_V1P10, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(pmpaddr15, CSR_PMPADDR15, CSR_CLASS_I, CSR_CLASS_V1P10, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mcycle, CSR_MCYCLE, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(minstret, CSR_MINSTRET, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mhpmcounter3, CSR_MHPMCOUNTER3, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mhpmcounter4, CSR_MHPMCOUNTER4, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mhpmcounter5, CSR_MHPMCOUNTER5, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mhpmcounter6, CSR_MHPMCOUNTER6, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mhpmcounter7, CSR_MHPMCOUNTER7, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mhpmcounter8, CSR_MHPMCOUNTER8, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mhpmcounter9, CSR_MHPMCOUNTER9, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mhpmcounter10, CSR_MHPMCOUNTER10, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mhpmcounter11, CSR_MHPMCOUNTER11, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mhpmcounter12, CSR_MHPMCOUNTER12, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mhpmcounter13, CSR_MHPMCOUNTER13, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mhpmcounter14, CSR_MHPMCOUNTER14, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mhpmcounter15, CSR_MHPMCOUNTER15, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mhpmcounter16, CSR_MHPMCOUNTER16, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mhpmcounter17, CSR_MHPMCOUNTER17, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mhpmcounter18, CSR_MHPMCOUNTER18, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mhpmcounter19, CSR_MHPMCOUNTER19, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mhpmcounter20, CSR_MHPMCOUNTER20, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mhpmcounter21, CSR_MHPMCOUNTER21, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mhpmcounter22, CSR_MHPMCOUNTER22, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mhpmcounter23, CSR_MHPMCOUNTER23, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mhpmcounter24, CSR_MHPMCOUNTER24, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mhpmcounter25, CSR_MHPMCOUNTER25, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mhpmcounter26, CSR_MHPMCOUNTER26, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mhpmcounter27, CSR_MHPMCOUNTER27, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mhpmcounter28, CSR_MHPMCOUNTER28, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mhpmcounter29, CSR_MHPMCOUNTER29, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mhpmcounter30, CSR_MHPMCOUNTER30, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mhpmcounter31, CSR_MHPMCOUNTER31, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mcycleh, CSR_MCYCLEH, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(minstreth, CSR_MINSTRETH, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mhpmcounter3h, CSR_MHPMCOUNTER3H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mhpmcounter4h, CSR_MHPMCOUNTER4H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mhpmcounter5h, CSR_MHPMCOUNTER5H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mhpmcounter6h, CSR_MHPMCOUNTER6H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mhpmcounter7h, CSR_MHPMCOUNTER7H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mhpmcounter8h, CSR_MHPMCOUNTER8H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mhpmcounter9h, CSR_MHPMCOUNTER9H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mhpmcounter10h, CSR_MHPMCOUNTER10H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mhpmcounter11h, CSR_MHPMCOUNTER11H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mhpmcounter12h, CSR_MHPMCOUNTER12H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mhpmcounter13h, CSR_MHPMCOUNTER13H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mhpmcounter14h, CSR_MHPMCOUNTER14H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mhpmcounter15h, CSR_MHPMCOUNTER15H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mhpmcounter16h, CSR_MHPMCOUNTER16H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mhpmcounter17h, CSR_MHPMCOUNTER17H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mhpmcounter18h, CSR_MHPMCOUNTER18H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mhpmcounter19h, CSR_MHPMCOUNTER19H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mhpmcounter20h, CSR_MHPMCOUNTER20H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mhpmcounter21h, CSR_MHPMCOUNTER21H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mhpmcounter22h, CSR_MHPMCOUNTER22H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mhpmcounter23h, CSR_MHPMCOUNTER23H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mhpmcounter24h, CSR_MHPMCOUNTER24H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mhpmcounter25h, CSR_MHPMCOUNTER25H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mhpmcounter26h, CSR_MHPMCOUNTER26H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mhpmcounter27h, CSR_MHPMCOUNTER27H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mhpmcounter28h, CSR_MHPMCOUNTER28H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mhpmcounter29h, CSR_MHPMCOUNTER29H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mhpmcounter30h, CSR_MHPMCOUNTER30H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mhpmcounter31h, CSR_MHPMCOUNTER31H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mcountinhibit, CSR_MCOUNTINHIBIT, CSR_CLASS_I, CSR_CLASS_V1P11, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mhpmevent3, CSR_MHPMEVENT3, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mhpmevent4, CSR_MHPMEVENT4, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mhpmevent5, CSR_MHPMEVENT5, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mhpmevent6, CSR_MHPMEVENT6, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mhpmevent7, CSR_MHPMEVENT7, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mhpmevent8, CSR_MHPMEVENT8, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mhpmevent9, CSR_MHPMEVENT9, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mhpmevent10, CSR_MHPMEVENT10, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mhpmevent11, CSR_MHPMEVENT11, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mhpmevent12, CSR_MHPMEVENT12, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mhpmevent13, CSR_MHPMEVENT13, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mhpmevent14, CSR_MHPMEVENT14, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mhpmevent15, CSR_MHPMEVENT15, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mhpmevent16, CSR_MHPMEVENT16, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mhpmevent17, CSR_MHPMEVENT17, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mhpmevent18, CSR_MHPMEVENT18, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mhpmevent19, CSR_MHPMEVENT19, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mhpmevent20, CSR_MHPMEVENT20, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mhpmevent21, CSR_MHPMEVENT21, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mhpmevent22, CSR_MHPMEVENT22, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mhpmevent23, CSR_MHPMEVENT23, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mhpmevent24, CSR_MHPMEVENT24, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mhpmevent25, CSR_MHPMEVENT25, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mhpmevent26, CSR_MHPMEVENT26, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mhpmevent27, CSR_MHPMEVENT27, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mhpmevent28, CSR_MHPMEVENT28, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mhpmevent29, CSR_MHPMEVENT29, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mhpmevent30, CSR_MHPMEVENT30, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mhpmevent31, CSR_MHPMEVENT31, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(tselect, CSR_TSELECT, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(tdata1, CSR_TDATA1, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(tdata2, CSR_TDATA2, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(tdata3, CSR_TDATA3, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(dcsr, CSR_DCSR, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(dpc, CSR_DPC, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(dscratch0, CSR_DSCRATCH0, CSR_CLASS_I, CSR_CLASS_V1P11, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(dscratch1, CSR_DSCRATCH1, CSR_CLASS_I, CSR_CLASS_V1P11, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(hstatus, CSR_HSTATUS, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_V1P10)

> +DECLARE_CSR(hedeleg, CSR_HEDELEG, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_V1P10)

> +DECLARE_CSR(hideleg, CSR_HIDELEG, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_V1P10)

> +DECLARE_CSR(hie, CSR_HIE, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_V1P10)

> +DECLARE_CSR(htvec, CSR_HTVEC, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_V1P10)

> +DECLARE_CSR(hscratch, CSR_HSCRATCH, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_V1P10)

> +DECLARE_CSR(hepc, CSR_HEPC, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_V1P10)

> +DECLARE_CSR(hcause, CSR_HCAUSE, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_V1P10)

> +DECLARE_CSR(hbadaddr, CSR_HBADADDR, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_V1P10)

> +DECLARE_CSR(hip, CSR_HIP, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_V1P10)

> +DECLARE_CSR(mbase, CSR_MBASE, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_V1P10)

> +DECLARE_CSR(mbound, CSR_MBOUND, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_V1P10)

> +DECLARE_CSR(mibase, CSR_MIBASE, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_V1P10)

> +DECLARE_CSR(mibound, CSR_MIBOUND, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_V1P10)

> +DECLARE_CSR(mdbase, CSR_MDBASE, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_V1P10)

> +DECLARE_CSR(mdbound, CSR_MDBOUND, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_V1P10)

> +DECLARE_CSR(mscounteren, CSR_MSCOUNTEREN, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_V1P10)

> +DECLARE_CSR(mhcounteren, CSR_MHCOUNTEREN, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_V1P10)

>  #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, CSR_CLASS_V1P9, CSR_CLASS_V1P9P1)

> +DECLARE_CSR_ALIAS(ubadaddr, CSR_UTVAL, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_V1P10)

> +DECLARE_CSR_ALIAS(sbadaddr, CSR_STVAL, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_V1P10)

> +DECLARE_CSR_ALIAS(sptbr, CSR_SATP, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_V1P10)

> +DECLARE_CSR_ALIAS(mbadaddr, CSR_MTVAL, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_V1P10)

> +DECLARE_CSR_ALIAS(mucounteren, CSR_MCOUNTINHIBIT, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_V1P10)

> +DECLARE_CSR_ALIAS(dscratch, CSR_DSCRATCH0, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_V1P11)

>  #endif

>  #ifdef DECLARE_CAUSE

>  DECLARE_CAUSE("misaligned fetch", CAUSE_MISALIGNED_FETCH)

> diff --git a/include/opcode/riscv.h b/include/opcode/riscv.h

> index f8b0de3..c36bf69 100644

> --- a/include/opcode/riscv.h

> +++ b/include/opcode/riscv.h

> @@ -24,6 +24,7 @@

>  #include "riscv-opc.h"

>  #include <stdlib.h>

>  #include <stdint.h>

> +#include "bfd.h"

>

>  typedef uint64_t insn_t;

>

> @@ -353,6 +354,19 @@ struct riscv_ext_version

>    unsigned int minor_version;

>  };

>

> +/* The current supported privilege versions.  */

> +

> +enum riscv_csr_vclass

> +{

> +  CSR_CLASS_VNONE,     /* Default value */

> +

> +  CSR_CLASS_V1P9,       /* v1.9 */

> +  CSR_CLASS_V1P9P1,     /* v1.9.1 */

> +  CSR_CLASS_V1P10,      /* v1.10 */

> +  CSR_CLASS_V1P11,      /* v1.11 */

> +  CSR_CLASS_VDRAFT

> +};

> +

>  /* Instruction is a simple alias (e.g. "mv" for "addi").  */

>  #define        INSN_ALIAS              0x00000001

>

> @@ -432,4 +446,9 @@ extern const struct riscv_opcode riscv_opcodes[];

>  extern const struct riscv_opcode riscv_insn_types[];

>  extern const struct riscv_ext_version riscv_ext_version_table[];

>

> +extern bfd_boolean

> +riscv_get_priv_version_class (const char *, enum riscv_csr_vclass *);

> +extern const char *

> +riscv_get_priv_version_name (enum riscv_csr_vclass);

> +

>  #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 7b885bf..cfefd8e 100644

> --- a/opcodes/riscv-opc.c

> +++ b/opcodes/riscv-opc.c

> @@ -937,3 +937,58 @@ const struct riscv_ext_version riscv_ext_version_table[] =

>  /* Terminate the list.  */

>  {NULL, NULL, 0, 0}

>  };

> +

> +struct priv_version_t

> +{

> +  const char *name;

> +  enum riscv_csr_vclass vclass;

> +};

> +

> +/* List for all supported CSR versions.  */

> +static const struct priv_version_t priv_versions[] =

> +{

> +  {"1p9", CSR_CLASS_V1P9},

> +  {"1p9p1", CSR_CLASS_V1P9P1},

> +  {"1p10", CSR_CLASS_V1P10},

> +  {"1p11", CSR_CLASS_V1P11},

> +

> +/* Terminate the list.  */

> +  {NULL, 0}

> +};

> +

> +/* Get the corresponding CSR version class by giving a privilege

> +   version string.  */

> +

> +bfd_boolean

> +riscv_get_priv_version_class (const char *s,

> +                             enum riscv_csr_vclass *class)

> +{

> +  const struct priv_version_t *version;

> +

> +  if (s == NULL)

> +    return FALSE;

> +

> +  for (version = &priv_versions[0]; version->name != NULL; ++version)

> +    if (strcmp (version->name, s) == 0)

> +      {

> +       *class = version->vclass;

> +       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_version_name (enum riscv_csr_vclass class)

> +{

> +  const struct priv_version_t *version;

> +  for (version = &priv_versions[0]; version->name != NULL; ++version)

> +    if (class == version->vclass)

> +      return version->name;

> +  /* This shouldn't happen.  */

> +  return NULL;

> +}

> --

> 2.7.4

>
Andrew Burgess April 24, 2020, 10:21 a.m. | #2
The gdb/* parts of this patch are approved.  I can't approve anything
else.

Thanks,
Andrew


* Nelson Chu <nelson.chu@sifive.com> [2020-04-18 04:07:52 -0700]:

> Support new gas option -mpriv-spec and configure option --with-priv-spec. You

> can use these options 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.

> 

> New Assembler Options,

> 

> * -mpriv-spec=[1p9|1p9p1|1p10|1p11]

> This is used to set the privileged spec’s version, and we can decide whether

> the CSR is valid or not.

> 

> New Default Configure Options,

> 

> * --with-priv-spec = [1p9|1p9p1|1p10|1p11]

> The syntax is same as -mpriv-spec option.  Assembler will check this setting

> if -mpriv-spec option isn’t set.

> 

> 	gas/

> 	* config/tc-riscv.c (DEFAULT_PRIV_SPEC): Default configure option.

> 	You can set it by new configure option --with-priv-spec.

> 	(enum riscv_csr_vclass default_priv_spec): You can set gas option

> 	-mpriv-spec or --with-priv-spec, and then assembler will call

> 	riscv_set_default_priv_version to set the default_priv_spec.

> 	(riscv_set_default_priv_version): New function.  Set the

> 	default_priv_spec.  Return 0 if the input privilege name isn't

> 	supported.  Otherwise, return 1.

> 

> 	(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 version.

> 	(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 call

> 	riscv_set_default_priv_version with DEFAULT_PRIV_SPEC to set the default

> 	privilege verison.

> 

> 	* testsuite/gas/riscv/priv-reg-fail-fext.d: This test case just want

> 	to check the ISA dependency for CSR, so fix the version by adding

> 	-mpriv-spec=1p11.

> 	* 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-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.

> 

> 	* configure.ac: Add new configure option --with-priv-spec.

> 	* configure: Regenerated.

> 	* config.in: Regenerated.

> 

> 	include/

> 	* opcode/riscv-opc.h (DECLARE_CSR): Store two version information,

> 	define_version and abort_version for the CSR, which is valid in the

> 	current privilege spec.  The define_version means which privilege spec

> 	started to define the CSR, and the abort_version means which privilege

> 	spec started to abort the CSR.  If the CSR is valid for the newest spec,

> 	then the abort_version is set to CSR_CLASS_VDRAFT.

> 	(DECLARE_CSR_ALIAS): Same as DECLARE_CSR, but only for the obselete CSR.

> 	* opcode/riscv.h: Include "bfd.h" to define bfd_boolean type.

> 	(enum riscv_csr_vclass): New enum classes.  Define the current supported

> 	privilege versions.

> 

> 	opcodes/

> 	* riscv-opc.c (struct priv_version_t): New structure.

> 	(struct priv_version_t priv_versions): Store the supported privilege

> 	versions' classes and their corresponding version string.

> 	(riscv_get_priv_version_class): New function.  Get the corresponding

> 	CSR version class by giving a privilege version string.

> 	(riscv_get_priv_version_name): New function.  Get the corresponding

> 	privilege version 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.in                                      |   3 +

>  gas/config/tc-riscv.c                              | 213 +++++++--

>  gas/configure                                      |  13 +

>  gas/configure.ac                                   |   8 +

>  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/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                             |  19 +

>  opcodes/riscv-dis.c                                |   3 +-

>  opcodes/riscv-opc.c                                |  55 +++

>  25 files changed, 728 insertions(+), 311 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 c75059b..a972c60 100644

> --- a/binutils/dwarf.c

> +++ b/binutils/dwarf.c

> @@ -7378,7 +7378,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.in b/gas/config.in

> index 935bd9b..093f474 100644

> --- a/gas/config.in

> +++ b/gas/config.in

> @@ -59,6 +59,9 @@

>  /* Define to 1 if you want to fix Loongson3 LLSC Errata by default. */

>  #undef DEFAULT_MIPS_FIX_LOONGSON3_LLSC

>  

> +/* Define default value for -mpriv-spec */

> +#undef DEFAULT_PRIV_SPEC

> +

>  /* Define to 1 if you want to generate RISC-V arch attribute by default. */

>  #undef DEFAULT_RISCV_ATTR

>  

> diff --git a/gas/config/tc-riscv.c b/gas/config/tc-riscv.c

> index bfcf2f0..6528a03 100644

> --- a/gas/config/tc-riscv.c

> +++ b/gas/config/tc-riscv.c

> @@ -75,10 +75,15 @@ struct riscv_cl_insn

>  #define DEFAULT_RISCV_ISA_VERSION NULL

>  #endif

>  

> +#ifndef DEFAULT_PRIV_SPEC

> +#define DEFAULT_PRIV_SPEC "1p11"

> +#endif

> +

>  static const char default_arch[] = DEFAULT_ARCH;

>  static const char *default_arch_with_ext = DEFAULT_ARCH_WITH_EXT;

>  static const char *default_isa_spec = DEFAULT_ISA_SPEC;

>  static const char *default_riscv_isa_version = DEFAULT_RISCV_ISA_VERSION;

> +static enum riscv_csr_vclass default_priv_spec = CSR_CLASS_VNONE;

>  

>  static unsigned xlen = 0; /* width of an x-register */

>  static unsigned abi_xlen = 0; /* width of a pointer in the ABI */

> @@ -536,8 +541,9 @@ enum reg_class

>  {

>    RCLASS_GPR,

>    RCLASS_FPR,

> -  RCLASS_CSR,

> -  RCLASS_MAX

> +  RCLASS_MAX,

> +

> +  RCLASS_CSR

>  };

>  

>  static struct hash_control *reg_names_hash = NULL;

> @@ -585,84 +591,197 @@ 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_csr_vclass 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_csr_vclass abort_version;

> +

> +  /* The CSR may have more than one setting.  */

> +  struct riscv_csr_extra *next;

>  };

>  

> -/* Init two hashes, csr_extra_hash and reg_names_hash, for CSR.  */

> +/* Set the default_priv_spec, assembler will find the suitable CSR address

> +   according to default_priv_spec.  Return 0 if the input priv name isn't

> +   supported.  Otherwise, return 1.  */

>  

> -static void

> -riscv_init_csr_hashes (const char *name,

> -		       unsigned address,

> -		       enum riscv_csr_class class)

> +static int

> +riscv_set_default_priv_version (const char *s)

>  {

> -  struct riscv_csr_extra *entry = XNEW (struct riscv_csr_extra);

> -  entry->csr_class = class;

> +  enum riscv_csr_vclass class;

> +  if (!riscv_get_priv_version_class (s, &class))

> +    {

> +      as_bad (_("Unsupported RISC-V privilege version set by "

> +		"-mpriv-spec=%s."), s);

> +      return 0;

> +    }

> +  else

> +    default_priv_spec = class;

> +  return 1;

> +}

> +

> +/* Init hash table csr_extra_hash to handle CSR.  */

>  

> -  const char *hash_error =

> -    hash_insert (csr_extra_hash, name, (void *) entry);

> -  if (hash_error != NULL)

> +static void

> +riscv_init_csr_hash (const char *name,

> +		     unsigned address,

> +		     enum riscv_csr_class class,

> +		     enum riscv_csr_vclass define_version,

> +		     enum riscv_csr_vclass 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)

>      {

> -      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."));

> +      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;

>      }

>  

> -  hash_reg_name (RCLASS_CSR, name, address);

> +  /* Duplicate setting for the CSR, just return and do nothing.  */

> +  if (!need_enrty)

> +    return;

> +

> +  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;

>  }

>  

>  /* Check wether the CSR is valid according to the ISA.  */

>  

> -static bfd_boolean

> -riscv_csr_class_check (enum riscv_csr_class csr_class)

> +static void

> +riscv_csr_class_check (const char *s,

> +		       enum riscv_csr_class csr_class)

>  {

> +  bfd_boolean result = TRUE;

> +

> +  /* Don't check the ISA dependency when -mcsr-check isn't set.  */

> +  if (!riscv_opts.csr_check)

> +    return;

> +

>    switch (csr_class)

>      {

> -    case CSR_CLASS_I: return riscv_subset_supports ("i");

> -    case CSR_CLASS_F: return riscv_subset_supports ("f");

> +    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:

> -      return (xlen == 32 && riscv_subset_supports ("i"));

> -

> +      result = (xlen == 32 && riscv_subset_supports ("i"));

> +      break;

>      default:

> -      return FALSE;

> +      as_bad (_("internal: bad RISC-V CSR class (0x%x)"), csr_class);

>      }

> +  if (!result)

> +    as_warn (_("Invalid CSR `%s' for the current ISA"), s);

>  }

>  

> -/* 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.  */

> +/* Check and find the CSR address according to the privilege spec version.  */

>  

> -static bfd_boolean

> +static void

> +riscv_csr_version_check (const char *csr_name,

> +			 struct riscv_csr_extra **entryP)

> +{

> +  struct riscv_csr_extra *entry = *entryP;

> +  while (entry != NULL)

> +    {

> +      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;

> +    }

> +

> +  /* 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_version_name (default_priv_spec);

> +      if (priv_name != NULL)

> +	as_warn (_("Invalid CSR `%s' for the privilege version `%s'"),

> +		 csr_name, priv_name);

> +    }

> +}

> +

> +/* 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 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 version.  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);

>  }

>  

> @@ -946,8 +1065,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

>  

> @@ -2434,6 +2555,7 @@ enum options

>    OPTION_NO_CSR_CHECK,

>    OPTION_MISA_SPEC,

>    OPTION_MRISCV_ISA_VERSION,

> +  OPTION_MPRIV_SPEC,

>    OPTION_END_OF_ENUM

>  };

>  

> @@ -2452,6 +2574,7 @@ struct option md_longopts[] =

>    {"mno-csr-check", no_argument, NULL, OPTION_NO_CSR_CHECK},

>    {"misa-spec", required_argument, NULL, OPTION_MISA_SPEC},

>    {"mriscv-isa-version", required_argument, NULL, OPTION_MRISCV_ISA_VERSION},

> +  {"mpriv-spec", required_argument, NULL, OPTION_MPRIV_SPEC},

>  

>    {NULL, no_argument, NULL, 0}

>  };

> @@ -2548,6 +2671,9 @@ md_parse_option (int c, const char *arg)

>        default_riscv_isa_version = arg;

>        break;

>  

> +    case OPTION_MPRIV_SPEC:

> +      return riscv_set_default_priv_version (arg);

> +

>      default:

>        return 0;

>      }

> @@ -2594,6 +2720,11 @@ riscv_after_parse_args (void)

>    if (riscv_subset_supports ("e"))

>      riscv_set_rve (TRUE);

>  

> +  /* If the -mpriv-spec isn't set, then we set the default privilege version

> +     according to DEFAULT_PRIV_SPEC,  */

> +  if (default_priv_spec == CSR_CLASS_VNONE)

> +    riscv_set_default_priv_version (DEFAULT_PRIV_SPEC);

> +

>    /* Infer ABI from ISA if not specified on command line.  */

>    if (abi_xlen == 0)

>      abi_xlen = xlen;

> diff --git a/gas/configure b/gas/configure

> index bce847a..0911152 100755

> --- a/gas/configure

> +++ b/gas/configure

> @@ -13068,6 +13068,19 @@ _ACEOF

>  	fi

>  	{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $with_riscv_isa_version" >&5

>  $as_echo "$with_riscv_isa_version" >&6; }

> +

> +	 # --with-priv-spec=[1p9p1|1p10|1p11].

> +	{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for default configuration of --with-priv-spec" >&5

> +$as_echo_n "checking for default configuration of --with-priv-spec... " >&6; }

> +	if test "x${with_priv_spec}" != x; then

> +

> +cat >>confdefs.h <<_ACEOF

> +#define DEFAULT_PRIV_SPEC "$with_priv_spec"

> +_ACEOF

> +

> +	fi

> +	{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $with_priv_spec" >&5

> +$as_echo "$with_priv_spec" >&6; }

>  	;;

>  

>        rl78)

> diff --git a/gas/configure.ac b/gas/configure.ac

> index be4ba20..c3d3639 100644

> --- a/gas/configure.ac

> +++ b/gas/configure.ac

> @@ -606,6 +606,14 @@ changequote([,])dnl

>  			      covered by --with-isa-spec])

>  	fi

>  	AC_MSG_RESULT($with_riscv_isa_version)

> +

> +	 # --with-priv-spec=[1p9p1|1p10|1p11].

> +	AC_MSG_CHECKING(for default configuration of --with-priv-spec)

> +	if test "x${with_priv_spec}" != x; then

> +	  AC_DEFINE_UNQUOTED(DEFAULT_PRIV_SPEC, "$with_priv_spec",

> +			     [Define default value for -mpriv-spec])

> +	fi

> +	AC_MSG_RESULT($with_priv_spec)

>  	;;

>  

>        rl78)

> diff --git a/gas/testsuite/gas/riscv/priv-reg-fail-fext.d b/gas/testsuite/gas/riscv/priv-reg-fail-fext.d

> index da53566..0033e3c 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=1p11

>  #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..d3b1bad 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 version `1p11'

> +.*Warning: Invalid CSR `sbadaddr' for the privilege version `1p11'

> +.*Warning: Invalid CSR `sptbr' for the privilege version `1p11'

> +.*Warning: Invalid CSR `mbadaddr' for the privilege version `1p11'

> +.*Warning: Invalid CSR `mucounteren' for the privilege version `1p11'

> +.*Warning: Invalid CSR `dscratch' for the privilege version `1p11'

> +.*Warning: Invalid CSR `hstatus' for the privilege version `1p11'

> +.*Warning: Invalid CSR `hedeleg' for the privilege version `1p11'

> +.*Warning: Invalid CSR `hideleg' for the privilege version `1p11'

> +.*Warning: Invalid CSR `hie' for the privilege version `1p11'

> +.*Warning: Invalid CSR `htvec' for the privilege version `1p11'

> +.*Warning: Invalid CSR `hscratch' for the privilege version `1p11'

> +.*Warning: Invalid CSR `hepc' for the privilege version `1p11'

> +.*Warning: Invalid CSR `hcause' for the privilege version `1p11'

> +.*Warning: Invalid CSR `hbadaddr' for the privilege version `1p11'

> +.*Warning: Invalid CSR `hip' for the privilege version `1p11'

> +.*Warning: Invalid CSR `mbase' for the privilege version `1p11'

> +.*Warning: Invalid CSR `mbound' for the privilege version `1p11'

> +.*Warning: Invalid CSR `mibase' for the privilege version `1p11'

> +.*Warning: Invalid CSR `mibound' for the privilege version `1p11'

> +.*Warning: Invalid CSR `mdbase' for the privilege version `1p11'

> +.*Warning: Invalid CSR `mdbound' for the privilege version `1p11'

> +.*Warning: Invalid CSR `mscounteren' for the privilege version `1p11'

> +.*Warning: Invalid CSR `mhcounteren' for the privilege version `1p11'

> 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..bbf83b5 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=1p11

>  #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..e8355f1 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 version `1p11'

> +.*Warning: Invalid CSR `sbadaddr' for the privilege version `1p11'

> +.*Warning: Invalid CSR `sptbr' for the privilege version `1p11'

> +.*Warning: Invalid CSR `mbadaddr' for the privilege version `1p11'

> +.*Warning: Invalid CSR `mucounteren' for the privilege version `1p11'

> +.*Warning: Invalid CSR `dscratch' for the privilege version `1p11'

> +.*Warning: Invalid CSR `hstatus' for the privilege version `1p11'

> +.*Warning: Invalid CSR `hedeleg' for the privilege version `1p11'

> +.*Warning: Invalid CSR `hideleg' for the privilege version `1p11'

> +.*Warning: Invalid CSR `hie' for the privilege version `1p11'

> +.*Warning: Invalid CSR `htvec' for the privilege version `1p11'

> +.*Warning: Invalid CSR `hscratch' for the privilege version `1p11'

> +.*Warning: Invalid CSR `hepc' for the privilege version `1p11'

> +.*Warning: Invalid CSR `hcause' for the privilege version `1p11'

> +.*Warning: Invalid CSR `hbadaddr' for the privilege version `1p11'

> +.*Warning: Invalid CSR `hip' for the privilege version `1p11'

> +.*Warning: Invalid CSR `mbase' for the privilege version `1p11'

> +.*Warning: Invalid CSR `mbound' for the privilege version `1p11'

> +.*Warning: Invalid CSR `mibase' for the privilege version `1p11'

> +.*Warning: Invalid CSR `mibound' for the privilege version `1p11'

> +.*Warning: Invalid CSR `mdbase' for the privilege version `1p11'

> +.*Warning: Invalid CSR `mdbound' for the privilege version `1p11'

> +.*Warning: Invalid CSR `mscounteren' for the privilege version `1p11'

> +.*Warning: Invalid CSR `mhcounteren' for the privilege version `1p11'

> 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..a0b88cf 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=1p11

>  #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..5e96a85 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 version `1p11'

> +.*Warning: Invalid CSR `sbadaddr' for the privilege version `1p11'

> +.*Warning: Invalid CSR `sptbr' for the privilege version `1p11'

> +.*Warning: Invalid CSR `mbadaddr' for the privilege version `1p11'

> +.*Warning: Invalid CSR `mucounteren' for the privilege version `1p11'

> +.*Warning: Invalid CSR `dscratch' for the privilege version `1p11'

> +.*Warning: Invalid CSR `hstatus' for the privilege version `1p11'

> +.*Warning: Invalid CSR `hedeleg' for the privilege version `1p11'

> +.*Warning: Invalid CSR `hideleg' for the privilege version `1p11'

> +.*Warning: Invalid CSR `hie' for the privilege version `1p11'

> +.*Warning: Invalid CSR `htvec' for the privilege version `1p11'

> +.*Warning: Invalid CSR `hscratch' for the privilege version `1p11'

> +.*Warning: Invalid CSR `hepc' for the privilege version `1p11'

> +.*Warning: Invalid CSR `hcause' for the privilege version `1p11'

> +.*Warning: Invalid CSR `hbadaddr' for the privilege version `1p11'

> +.*Warning: Invalid CSR `hip' for the privilege version `1p11'

> +.*Warning: Invalid CSR `mbase' for the privilege version `1p11'

> +.*Warning: Invalid CSR `mbound' for the privilege version `1p11'

> +.*Warning: Invalid CSR `mibase' for the privilege version `1p11'

> +.*Warning: Invalid CSR `mibound' for the privilege version `1p11'

> +.*Warning: Invalid CSR `mdbase' for the privilege version `1p11'

> +.*Warning: Invalid CSR `mdbound' for the privilege version `1p11'

> +.*Warning: Invalid CSR `mscounteren' for the privilege version `1p11'

> +.*Warning: Invalid CSR `mhcounteren' for the privilege version `1p11'

> 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..d7a788a

> --- /dev/null

> +++ b/gas/testsuite/gas/riscv/priv-reg-fail-version-1p10.d

> @@ -0,0 +1,3 @@

> +#as: -march=rv32if -mcsr-check -mpriv-spec=1p10

> +#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..f532962

> --- /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 version `1p10'

> +.*Warning: Invalid CSR `dscratch0' for the privilege version `1p10'

> +.*Warning: Invalid CSR `dscratch1' for the privilege version `1p10'

> +.*Warning: Invalid CSR `ubadaddr' for the privilege version `1p10'

> +.*Warning: Invalid CSR `sbadaddr' for the privilege version `1p10'

> +.*Warning: Invalid CSR `sptbr' for the privilege version `1p10'

> +.*Warning: Invalid CSR `mbadaddr' for the privilege version `1p10'

> +.*Warning: Invalid CSR `mucounteren' for the privilege version `1p10'

> +.*Warning: Invalid CSR `hstatus' for the privilege version `1p10'

> +.*Warning: Invalid CSR `hedeleg' for the privilege version `1p10'

> +.*Warning: Invalid CSR `hideleg' for the privilege version `1p10'

> +.*Warning: Invalid CSR `hie' for the privilege version `1p10'

> +.*Warning: Invalid CSR `htvec' for the privilege version `1p10'

> +.*Warning: Invalid CSR `hscratch' for the privilege version `1p10'

> +.*Warning: Invalid CSR `hepc' for the privilege version `1p10'

> +.*Warning: Invalid CSR `hcause' for the privilege version `1p10'

> +.*Warning: Invalid CSR `hbadaddr' for the privilege version `1p10'

> +.*Warning: Invalid CSR `hip' for the privilege version `1p10'

> +.*Warning: Invalid CSR `mbase' for the privilege version `1p10'

> +.*Warning: Invalid CSR `mbound' for the privilege version `1p10'

> +.*Warning: Invalid CSR `mibase' for the privilege version `1p10'

> +.*Warning: Invalid CSR `mibound' for the privilege version `1p10'

> +.*Warning: Invalid CSR `mdbase' for the privilege version `1p10'

> +.*Warning: Invalid CSR `mdbound' for the privilege version `1p10'

> +.*Warning: Invalid CSR `mscounteren' for the privilege version `1p10'

> +.*Warning: Invalid CSR `mhcounteren' for the privilege version `1p10'

> 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..2830c83

> --- /dev/null

> +++ b/gas/testsuite/gas/riscv/priv-reg-fail-version-1p11.d

> @@ -0,0 +1,3 @@

> +#as: -march=rv32if -mcsr-check -mpriv-spec=1p11

> +#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..252f96a

> --- /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 version `1p11'

> +.*Warning: Invalid CSR `sbadaddr' for the privilege version `1p11'

> +.*Warning: Invalid CSR `sptbr' for the privilege version `1p11'

> +.*Warning: Invalid CSR `mbadaddr' for the privilege version `1p11'

> +.*Warning: Invalid CSR `mucounteren' for the privilege version `1p11'

> +.*Warning: Invalid CSR `dscratch' for the privilege version `1p11'

> +.*Warning: Invalid CSR `hstatus' for the privilege version `1p11'

> +.*Warning: Invalid CSR `hedeleg' for the privilege version `1p11'

> +.*Warning: Invalid CSR `hideleg' for the privilege version `1p11'

> +.*Warning: Invalid CSR `hie' for the privilege version `1p11'

> +.*Warning: Invalid CSR `htvec' for the privilege version `1p11'

> +.*Warning: Invalid CSR `hscratch' for the privilege version `1p11'

> +.*Warning: Invalid CSR `hepc' for the privilege version `1p11'

> +.*Warning: Invalid CSR `hcause' for the privilege version `1p11'

> +.*Warning: Invalid CSR `hbadaddr' for the privilege version `1p11'

> +.*Warning: Invalid CSR `hip' for the privilege version `1p11'

> +.*Warning: Invalid CSR `mbase' for the privilege version `1p11'

> +.*Warning: Invalid CSR `mbound' for the privilege version `1p11'

> +.*Warning: Invalid CSR `mibase' for the privilege version `1p11'

> +.*Warning: Invalid CSR `mibound' for the privilege version `1p11'

> +.*Warning: Invalid CSR `mdbase' for the privilege version `1p11'

> +.*Warning: Invalid CSR `mdbound' for the privilege version `1p11'

> +.*Warning: Invalid CSR `mscounteren' for the privilege version `1p11'

> +.*Warning: Invalid CSR `mhcounteren' for the privilege version `1p11'

> 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..70c405f

> --- /dev/null

> +++ b/gas/testsuite/gas/riscv/priv-reg-fail-version-1p9.d

> @@ -0,0 +1,3 @@

> +#as: -march=rv32if -mcsr-check -mpriv-spec=1p9

> +#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..92e1463

> --- /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 version `1p9'

> +.*Warning: Invalid CSR `scounteren' for the privilege version `1p9'

> +.*Warning: Invalid CSR `stval' for the privilege version `1p9'

> +.*Warning: Invalid CSR `satp' for the privilege version `1p9'

> +.*Warning: Invalid CSR `mcounteren' for the privilege version `1p9'

> +.*Warning: Invalid CSR `mtval' for the privilege version `1p9'

> +.*Warning: Invalid CSR `pmpcfg0' for the privilege version `1p9'

> +.*Warning: Invalid CSR `pmpcfg1' for the privilege version `1p9'

> +.*Warning: Invalid CSR `pmpcfg2' for the privilege version `1p9'

> +.*Warning: Invalid CSR `pmpcfg3' for the privilege version `1p9'

> +.*Warning: Invalid CSR `pmpaddr0' for the privilege version `1p9'

> +.*Warning: Invalid CSR `pmpaddr1' for the privilege version `1p9'

> +.*Warning: Invalid CSR `pmpaddr2' for the privilege version `1p9'

> +.*Warning: Invalid CSR `pmpaddr3' for the privilege version `1p9'

> +.*Warning: Invalid CSR `pmpaddr4' for the privilege version `1p9'

> +.*Warning: Invalid CSR `pmpaddr5' for the privilege version `1p9'

> +.*Warning: Invalid CSR `pmpaddr6' for the privilege version `1p9'

> +.*Warning: Invalid CSR `pmpaddr7' for the privilege version `1p9'

> +.*Warning: Invalid CSR `pmpaddr8' for the privilege version `1p9'

> +.*Warning: Invalid CSR `pmpaddr9' for the privilege version `1p9'

> +.*Warning: Invalid CSR `pmpaddr10' for the privilege version `1p9'

> +.*Warning: Invalid CSR `pmpaddr11' for the privilege version `1p9'

> +.*Warning: Invalid CSR `pmpaddr12' for the privilege version `1p9'

> +.*Warning: Invalid CSR `pmpaddr13' for the privilege version `1p9'

> +.*Warning: Invalid CSR `pmpaddr14' for the privilege version `1p9'

> +.*Warning: Invalid CSR `pmpaddr15' for the privilege version `1p9'

> +.*Warning: Invalid CSR `mcountinhibit' for the privilege version `1p9'

> +.*Warning: Invalid CSR `dscratch0' for the privilege version `1p9'

> +.*Warning: Invalid CSR `dscratch1' for the privilege version `1p9'

> 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..2bd4bbf

> --- /dev/null

> +++ b/gas/testsuite/gas/riscv/priv-reg-fail-version-1p9p1.d

> @@ -0,0 +1,3 @@

> +#as: -march=rv32if -mcsr-check -mpriv-spec=1p9p1

> +#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..6cde0b3

> --- /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 version `1p9p1'

> +.*Warning: Invalid CSR `scounteren' for the privilege version `1p9p1'

> +.*Warning: Invalid CSR `stval' for the privilege version `1p9p1'

> +.*Warning: Invalid CSR `satp' for the privilege version `1p9p1'

> +.*Warning: Invalid CSR `mcounteren' for the privilege version `1p9p1'

> +.*Warning: Invalid CSR `mtval' for the privilege version `1p9p1'

> +.*Warning: Invalid CSR `pmpcfg0' for the privilege version `1p9p1'

> +.*Warning: Invalid CSR `pmpcfg1' for the privilege version `1p9p1'

> +.*Warning: Invalid CSR `pmpcfg2' for the privilege version `1p9p1'

> +.*Warning: Invalid CSR `pmpcfg3' for the privilege version `1p9p1'

> +.*Warning: Invalid CSR `pmpaddr0' for the privilege version `1p9p1'

> +.*Warning: Invalid CSR `pmpaddr1' for the privilege version `1p9p1'

> +.*Warning: Invalid CSR `pmpaddr2' for the privilege version `1p9p1'

> +.*Warning: Invalid CSR `pmpaddr3' for the privilege version `1p9p1'

> +.*Warning: Invalid CSR `pmpaddr4' for the privilege version `1p9p1'

> +.*Warning: Invalid CSR `pmpaddr5' for the privilege version `1p9p1'

> +.*Warning: Invalid CSR `pmpaddr6' for the privilege version `1p9p1'

> +.*Warning: Invalid CSR `pmpaddr7' for the privilege version `1p9p1'

> +.*Warning: Invalid CSR `pmpaddr8' for the privilege version `1p9p1'

> +.*Warning: Invalid CSR `pmpaddr9' for the privilege version `1p9p1'

> +.*Warning: Invalid CSR `pmpaddr10' for the privilege version `1p9p1'

> +.*Warning: Invalid CSR `pmpaddr11' for the privilege version `1p9p1'

> +.*Warning: Invalid CSR `pmpaddr12' for the privilege version `1p9p1'

> +.*Warning: Invalid CSR `pmpaddr13' for the privilege version `1p9p1'

> +.*Warning: Invalid CSR `pmpaddr14' for the privilege version `1p9p1'

> +.*Warning: Invalid CSR `pmpaddr15' for the privilege version `1p9p1'

> +.*Warning: Invalid CSR `mcountinhibit' for the privilege version `1p9p1'

> +.*Warning: Invalid CSR `dscratch0' for the privilege version `1p9p1'

> +.*Warning: Invalid CSR `dscratch1' for the privilege version `1p9p1'

> 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..ab11c31 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, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(uie, CSR_UIE, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(utvec, CSR_UTVEC, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(uscratch, CSR_USCRATCH, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(uepc, CSR_UEPC, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(ucause, CSR_UCAUSE, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(utval, CSR_UTVAL, CSR_CLASS_I, CSR_CLASS_V1P10, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(uip, CSR_UIP, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(fflags, CSR_FFLAGS, CSR_CLASS_F, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(frm, CSR_FRM, CSR_CLASS_F, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(fcsr, CSR_FCSR, CSR_CLASS_F, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(cycle, CSR_CYCLE, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(time, CSR_TIME, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(instret, CSR_INSTRET, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(hpmcounter3, CSR_HPMCOUNTER3, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(hpmcounter4, CSR_HPMCOUNTER4, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(hpmcounter5, CSR_HPMCOUNTER5, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(hpmcounter6, CSR_HPMCOUNTER6, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(hpmcounter7, CSR_HPMCOUNTER7, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(hpmcounter8, CSR_HPMCOUNTER8, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(hpmcounter9, CSR_HPMCOUNTER9, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(hpmcounter10, CSR_HPMCOUNTER10, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(hpmcounter11, CSR_HPMCOUNTER11, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(hpmcounter12, CSR_HPMCOUNTER12, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(hpmcounter13, CSR_HPMCOUNTER13, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(hpmcounter14, CSR_HPMCOUNTER14, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(hpmcounter15, CSR_HPMCOUNTER15, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(hpmcounter16, CSR_HPMCOUNTER16, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(hpmcounter17, CSR_HPMCOUNTER17, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(hpmcounter18, CSR_HPMCOUNTER18, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(hpmcounter19, CSR_HPMCOUNTER19, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(hpmcounter20, CSR_HPMCOUNTER20, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(hpmcounter21, CSR_HPMCOUNTER21, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(hpmcounter22, CSR_HPMCOUNTER22, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(hpmcounter23, CSR_HPMCOUNTER23, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(hpmcounter24, CSR_HPMCOUNTER24, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(hpmcounter25, CSR_HPMCOUNTER25, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(hpmcounter26, CSR_HPMCOUNTER26, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(hpmcounter27, CSR_HPMCOUNTER27, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(hpmcounter28, CSR_HPMCOUNTER28, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(hpmcounter29, CSR_HPMCOUNTER29, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(hpmcounter30, CSR_HPMCOUNTER30, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(hpmcounter31, CSR_HPMCOUNTER31, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(cycleh, CSR_CYCLEH, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(timeh, CSR_TIMEH, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(instreth, CSR_INSTRETH, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(hpmcounter3h, CSR_HPMCOUNTER3H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(hpmcounter4h, CSR_HPMCOUNTER4H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(hpmcounter5h, CSR_HPMCOUNTER5H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(hpmcounter6h, CSR_HPMCOUNTER6H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(hpmcounter7h, CSR_HPMCOUNTER7H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(hpmcounter8h, CSR_HPMCOUNTER8H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(hpmcounter9h, CSR_HPMCOUNTER9H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(hpmcounter10h, CSR_HPMCOUNTER10H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(hpmcounter11h, CSR_HPMCOUNTER11H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(hpmcounter12h, CSR_HPMCOUNTER12H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(hpmcounter13h, CSR_HPMCOUNTER13H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(hpmcounter14h, CSR_HPMCOUNTER14H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(hpmcounter15h, CSR_HPMCOUNTER15H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(hpmcounter16h, CSR_HPMCOUNTER16H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(hpmcounter17h, CSR_HPMCOUNTER17H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(hpmcounter18h, CSR_HPMCOUNTER18H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(hpmcounter19h, CSR_HPMCOUNTER19H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(hpmcounter20h, CSR_HPMCOUNTER20H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(hpmcounter21h, CSR_HPMCOUNTER21H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(hpmcounter22h, CSR_HPMCOUNTER22H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(hpmcounter23h, CSR_HPMCOUNTER23H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(hpmcounter24h, CSR_HPMCOUNTER24H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(hpmcounter25h, CSR_HPMCOUNTER25H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(hpmcounter26h, CSR_HPMCOUNTER26H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(hpmcounter27h, CSR_HPMCOUNTER27H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(hpmcounter28h, CSR_HPMCOUNTER28H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(hpmcounter29h, CSR_HPMCOUNTER29H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(hpmcounter30h, CSR_HPMCOUNTER30H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(hpmcounter31h, CSR_HPMCOUNTER31H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(sstatus, CSR_SSTATUS, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(sedeleg, CSR_SEDELEG, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(sideleg, CSR_SIDELEG, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(sie, CSR_SIE, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(stvec, CSR_STVEC, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(scounteren, CSR_SCOUNTEREN, CSR_CLASS_I, CSR_CLASS_V1P10, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(sscratch, CSR_SSCRATCH, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(sepc, CSR_SEPC, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(scause, CSR_SCAUSE, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(stval, CSR_STVAL, CSR_CLASS_I, CSR_CLASS_V1P10, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(sip, CSR_SIP, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(satp, CSR_SATP, CSR_CLASS_I, CSR_CLASS_V1P10, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mvendorid, CSR_MVENDORID, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(marchid, CSR_MARCHID, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mimpid, CSR_MIMPID, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mhartid, CSR_MHARTID, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mstatus, CSR_MSTATUS, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(misa, CSR_MISA, CSR_CLASS_I, CSR_CLASS_V1P9P1, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(medeleg, CSR_MEDELEG, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mideleg, CSR_MIDELEG, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mie, CSR_MIE, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mtvec, CSR_MTVEC, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mcounteren, CSR_MCOUNTEREN, CSR_CLASS_I, CSR_CLASS_V1P10, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mscratch, CSR_MSCRATCH, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mepc, CSR_MEPC, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mcause, CSR_MCAUSE, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mtval, CSR_MTVAL, CSR_CLASS_I, CSR_CLASS_V1P10, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mip, CSR_MIP, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(pmpcfg0, CSR_PMPCFG0, CSR_CLASS_I, CSR_CLASS_V1P10, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(pmpcfg1, CSR_PMPCFG1, CSR_CLASS_I_32, CSR_CLASS_V1P10, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(pmpcfg2, CSR_PMPCFG2, CSR_CLASS_I, CSR_CLASS_V1P10, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(pmpcfg3, CSR_PMPCFG3, CSR_CLASS_I_32, CSR_CLASS_V1P10, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(pmpaddr0, CSR_PMPADDR0, CSR_CLASS_I, CSR_CLASS_V1P10, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(pmpaddr1, CSR_PMPADDR1, CSR_CLASS_I, CSR_CLASS_V1P10, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(pmpaddr2, CSR_PMPADDR2, CSR_CLASS_I, CSR_CLASS_V1P10, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(pmpaddr3, CSR_PMPADDR3, CSR_CLASS_I, CSR_CLASS_V1P10, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(pmpaddr4, CSR_PMPADDR4, CSR_CLASS_I, CSR_CLASS_V1P10, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(pmpaddr5, CSR_PMPADDR5, CSR_CLASS_I, CSR_CLASS_V1P10, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(pmpaddr6, CSR_PMPADDR6, CSR_CLASS_I, CSR_CLASS_V1P10, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(pmpaddr7, CSR_PMPADDR7, CSR_CLASS_I, CSR_CLASS_V1P10, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(pmpaddr8, CSR_PMPADDR8, CSR_CLASS_I, CSR_CLASS_V1P10, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(pmpaddr9, CSR_PMPADDR9, CSR_CLASS_I, CSR_CLASS_V1P10, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(pmpaddr10, CSR_PMPADDR10, CSR_CLASS_I, CSR_CLASS_V1P10, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(pmpaddr11, CSR_PMPADDR11, CSR_CLASS_I, CSR_CLASS_V1P10, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(pmpaddr12, CSR_PMPADDR12, CSR_CLASS_I, CSR_CLASS_V1P10, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(pmpaddr13, CSR_PMPADDR13, CSR_CLASS_I, CSR_CLASS_V1P10, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(pmpaddr14, CSR_PMPADDR14, CSR_CLASS_I, CSR_CLASS_V1P10, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(pmpaddr15, CSR_PMPADDR15, CSR_CLASS_I, CSR_CLASS_V1P10, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mcycle, CSR_MCYCLE, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(minstret, CSR_MINSTRET, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mhpmcounter3, CSR_MHPMCOUNTER3, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mhpmcounter4, CSR_MHPMCOUNTER4, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mhpmcounter5, CSR_MHPMCOUNTER5, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mhpmcounter6, CSR_MHPMCOUNTER6, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mhpmcounter7, CSR_MHPMCOUNTER7, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mhpmcounter8, CSR_MHPMCOUNTER8, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mhpmcounter9, CSR_MHPMCOUNTER9, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mhpmcounter10, CSR_MHPMCOUNTER10, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mhpmcounter11, CSR_MHPMCOUNTER11, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mhpmcounter12, CSR_MHPMCOUNTER12, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mhpmcounter13, CSR_MHPMCOUNTER13, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mhpmcounter14, CSR_MHPMCOUNTER14, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mhpmcounter15, CSR_MHPMCOUNTER15, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mhpmcounter16, CSR_MHPMCOUNTER16, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mhpmcounter17, CSR_MHPMCOUNTER17, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mhpmcounter18, CSR_MHPMCOUNTER18, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mhpmcounter19, CSR_MHPMCOUNTER19, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mhpmcounter20, CSR_MHPMCOUNTER20, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mhpmcounter21, CSR_MHPMCOUNTER21, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mhpmcounter22, CSR_MHPMCOUNTER22, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mhpmcounter23, CSR_MHPMCOUNTER23, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mhpmcounter24, CSR_MHPMCOUNTER24, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mhpmcounter25, CSR_MHPMCOUNTER25, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mhpmcounter26, CSR_MHPMCOUNTER26, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mhpmcounter27, CSR_MHPMCOUNTER27, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mhpmcounter28, CSR_MHPMCOUNTER28, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mhpmcounter29, CSR_MHPMCOUNTER29, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mhpmcounter30, CSR_MHPMCOUNTER30, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mhpmcounter31, CSR_MHPMCOUNTER31, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mcycleh, CSR_MCYCLEH, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(minstreth, CSR_MINSTRETH, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mhpmcounter3h, CSR_MHPMCOUNTER3H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mhpmcounter4h, CSR_MHPMCOUNTER4H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mhpmcounter5h, CSR_MHPMCOUNTER5H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mhpmcounter6h, CSR_MHPMCOUNTER6H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mhpmcounter7h, CSR_MHPMCOUNTER7H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mhpmcounter8h, CSR_MHPMCOUNTER8H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mhpmcounter9h, CSR_MHPMCOUNTER9H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mhpmcounter10h, CSR_MHPMCOUNTER10H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mhpmcounter11h, CSR_MHPMCOUNTER11H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mhpmcounter12h, CSR_MHPMCOUNTER12H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mhpmcounter13h, CSR_MHPMCOUNTER13H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mhpmcounter14h, CSR_MHPMCOUNTER14H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mhpmcounter15h, CSR_MHPMCOUNTER15H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mhpmcounter16h, CSR_MHPMCOUNTER16H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mhpmcounter17h, CSR_MHPMCOUNTER17H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mhpmcounter18h, CSR_MHPMCOUNTER18H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mhpmcounter19h, CSR_MHPMCOUNTER19H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mhpmcounter20h, CSR_MHPMCOUNTER20H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mhpmcounter21h, CSR_MHPMCOUNTER21H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mhpmcounter22h, CSR_MHPMCOUNTER22H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mhpmcounter23h, CSR_MHPMCOUNTER23H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mhpmcounter24h, CSR_MHPMCOUNTER24H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mhpmcounter25h, CSR_MHPMCOUNTER25H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mhpmcounter26h, CSR_MHPMCOUNTER26H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mhpmcounter27h, CSR_MHPMCOUNTER27H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mhpmcounter28h, CSR_MHPMCOUNTER28H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mhpmcounter29h, CSR_MHPMCOUNTER29H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mhpmcounter30h, CSR_MHPMCOUNTER30H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mhpmcounter31h, CSR_MHPMCOUNTER31H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mcountinhibit, CSR_MCOUNTINHIBIT, CSR_CLASS_I, CSR_CLASS_V1P11, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mhpmevent3, CSR_MHPMEVENT3, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mhpmevent4, CSR_MHPMEVENT4, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mhpmevent5, CSR_MHPMEVENT5, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mhpmevent6, CSR_MHPMEVENT6, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mhpmevent7, CSR_MHPMEVENT7, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mhpmevent8, CSR_MHPMEVENT8, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mhpmevent9, CSR_MHPMEVENT9, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mhpmevent10, CSR_MHPMEVENT10, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mhpmevent11, CSR_MHPMEVENT11, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mhpmevent12, CSR_MHPMEVENT12, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mhpmevent13, CSR_MHPMEVENT13, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mhpmevent14, CSR_MHPMEVENT14, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mhpmevent15, CSR_MHPMEVENT15, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mhpmevent16, CSR_MHPMEVENT16, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mhpmevent17, CSR_MHPMEVENT17, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mhpmevent18, CSR_MHPMEVENT18, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mhpmevent19, CSR_MHPMEVENT19, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mhpmevent20, CSR_MHPMEVENT20, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mhpmevent21, CSR_MHPMEVENT21, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mhpmevent22, CSR_MHPMEVENT22, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mhpmevent23, CSR_MHPMEVENT23, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mhpmevent24, CSR_MHPMEVENT24, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mhpmevent25, CSR_MHPMEVENT25, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mhpmevent26, CSR_MHPMEVENT26, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mhpmevent27, CSR_MHPMEVENT27, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mhpmevent28, CSR_MHPMEVENT28, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mhpmevent29, CSR_MHPMEVENT29, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mhpmevent30, CSR_MHPMEVENT30, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(mhpmevent31, CSR_MHPMEVENT31, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(tselect, CSR_TSELECT, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(tdata1, CSR_TDATA1, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(tdata2, CSR_TDATA2, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(tdata3, CSR_TDATA3, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(dcsr, CSR_DCSR, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(dpc, CSR_DPC, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(dscratch0, CSR_DSCRATCH0, CSR_CLASS_I, CSR_CLASS_V1P11, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(dscratch1, CSR_DSCRATCH1, CSR_CLASS_I, CSR_CLASS_V1P11, CSR_CLASS_VDRAFT)

> +DECLARE_CSR(hstatus, CSR_HSTATUS, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_V1P10)

> +DECLARE_CSR(hedeleg, CSR_HEDELEG, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_V1P10)

> +DECLARE_CSR(hideleg, CSR_HIDELEG, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_V1P10)

> +DECLARE_CSR(hie, CSR_HIE, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_V1P10)

> +DECLARE_CSR(htvec, CSR_HTVEC, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_V1P10)

> +DECLARE_CSR(hscratch, CSR_HSCRATCH, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_V1P10)

> +DECLARE_CSR(hepc, CSR_HEPC, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_V1P10)

> +DECLARE_CSR(hcause, CSR_HCAUSE, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_V1P10)

> +DECLARE_CSR(hbadaddr, CSR_HBADADDR, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_V1P10)

> +DECLARE_CSR(hip, CSR_HIP, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_V1P10)

> +DECLARE_CSR(mbase, CSR_MBASE, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_V1P10)

> +DECLARE_CSR(mbound, CSR_MBOUND, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_V1P10)

> +DECLARE_CSR(mibase, CSR_MIBASE, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_V1P10)

> +DECLARE_CSR(mibound, CSR_MIBOUND, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_V1P10)

> +DECLARE_CSR(mdbase, CSR_MDBASE, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_V1P10)

> +DECLARE_CSR(mdbound, CSR_MDBOUND, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_V1P10)

> +DECLARE_CSR(mscounteren, CSR_MSCOUNTEREN, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_V1P10)

> +DECLARE_CSR(mhcounteren, CSR_MHCOUNTEREN, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_V1P10)

>  #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, CSR_CLASS_V1P9, CSR_CLASS_V1P9P1)

> +DECLARE_CSR_ALIAS(ubadaddr, CSR_UTVAL, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_V1P10)

> +DECLARE_CSR_ALIAS(sbadaddr, CSR_STVAL, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_V1P10)

> +DECLARE_CSR_ALIAS(sptbr, CSR_SATP, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_V1P10)

> +DECLARE_CSR_ALIAS(mbadaddr, CSR_MTVAL, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_V1P10)

> +DECLARE_CSR_ALIAS(mucounteren, CSR_MCOUNTINHIBIT, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_V1P10)

> +DECLARE_CSR_ALIAS(dscratch, CSR_DSCRATCH0, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_V1P11)

>  #endif

>  #ifdef DECLARE_CAUSE

>  DECLARE_CAUSE("misaligned fetch", CAUSE_MISALIGNED_FETCH)

> diff --git a/include/opcode/riscv.h b/include/opcode/riscv.h

> index f8b0de3..c36bf69 100644

> --- a/include/opcode/riscv.h

> +++ b/include/opcode/riscv.h

> @@ -24,6 +24,7 @@

>  #include "riscv-opc.h"

>  #include <stdlib.h>

>  #include <stdint.h>

> +#include "bfd.h"

>  

>  typedef uint64_t insn_t;

>  

> @@ -353,6 +354,19 @@ struct riscv_ext_version

>    unsigned int minor_version;

>  };

>  

> +/* The current supported privilege versions.  */

> +

> +enum riscv_csr_vclass

> +{

> +  CSR_CLASS_VNONE,	/* Default value */

> +

> +  CSR_CLASS_V1P9,       /* v1.9 */

> +  CSR_CLASS_V1P9P1,     /* v1.9.1 */

> +  CSR_CLASS_V1P10,      /* v1.10 */

> +  CSR_CLASS_V1P11,      /* v1.11 */

> +  CSR_CLASS_VDRAFT

> +};

> +

>  /* Instruction is a simple alias (e.g. "mv" for "addi").  */

>  #define	INSN_ALIAS		0x00000001

>  

> @@ -432,4 +446,9 @@ extern const struct riscv_opcode riscv_opcodes[];

>  extern const struct riscv_opcode riscv_insn_types[];

>  extern const struct riscv_ext_version riscv_ext_version_table[];

>  

> +extern bfd_boolean

> +riscv_get_priv_version_class (const char *, enum riscv_csr_vclass *);

> +extern const char *

> +riscv_get_priv_version_name (enum riscv_csr_vclass);

> +

>  #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 7b885bf..cfefd8e 100644

> --- a/opcodes/riscv-opc.c

> +++ b/opcodes/riscv-opc.c

> @@ -937,3 +937,58 @@ const struct riscv_ext_version riscv_ext_version_table[] =

>  /* Terminate the list.  */

>  {NULL, NULL, 0, 0}

>  };

> +

> +struct priv_version_t

> +{

> +  const char *name;

> +  enum riscv_csr_vclass vclass;

> +};

> +

> +/* List for all supported CSR versions.  */

> +static const struct priv_version_t priv_versions[] =

> +{

> +  {"1p9", CSR_CLASS_V1P9},

> +  {"1p9p1", CSR_CLASS_V1P9P1},

> +  {"1p10", CSR_CLASS_V1P10},

> +  {"1p11", CSR_CLASS_V1P11},

> +

> +/* Terminate the list.  */

> +  {NULL, 0}

> +};

> +

> +/* Get the corresponding CSR version class by giving a privilege

> +   version string.  */

> +

> +bfd_boolean

> +riscv_get_priv_version_class (const char *s,

> +			      enum riscv_csr_vclass *class)

> +{

> +  const struct priv_version_t *version;

> +

> +  if (s == NULL)

> +    return FALSE;

> +

> +  for (version = &priv_versions[0]; version->name != NULL; ++version)

> +    if (strcmp (version->name, s) == 0)

> +      {

> +	*class = version->vclass;

> +	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_version_name (enum riscv_csr_vclass class)

> +{

> +  const struct priv_version_t *version;

> +  for (version = &priv_versions[0]; version->name != NULL; ++version)

> +    if (class == version->vclass)

> +      return version->name;

> +  /* This shouldn't happen.  */

> +  return NULL;

> +}

> -- 

> 2.7.4

>
Nelson Chu April 27, 2020, 1:35 a.m. | #3
Thanks Andrew :)
Appreciate your help.

Nelson

On Fri, Apr 24, 2020 at 6:21 PM Andrew Burgess
<andrew.burgess@embecosm.com> wrote:
>

> The gdb/* parts of this patch are approved.  I can't approve anything

> else.

>

> Thanks,

> Andrew

>

>

> * Nelson Chu <nelson.chu@sifive.com> [2020-04-18 04:07:52 -0700]:

>

> > Support new gas option -mpriv-spec and configure option --with-priv-spec. You

> > can use these options 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.

> >

> > New Assembler Options,

> >

> > * -mpriv-spec=[1p9|1p9p1|1p10|1p11]

> > This is used to set the privileged spec’s version, and we can decide whether

> > the CSR is valid or not.

> >

> > New Default Configure Options,

> >

> > * --with-priv-spec = [1p9|1p9p1|1p10|1p11]

> > The syntax is same as -mpriv-spec option.  Assembler will check this setting

> > if -mpriv-spec option isn’t set.

> >

> >       gas/

> >       * config/tc-riscv.c (DEFAULT_PRIV_SPEC): Default configure option.

> >       You can set it by new configure option --with-priv-spec.

> >       (enum riscv_csr_vclass default_priv_spec): You can set gas option

> >       -mpriv-spec or --with-priv-spec, and then assembler will call

> >       riscv_set_default_priv_version to set the default_priv_spec.

> >       (riscv_set_default_priv_version): New function.  Set the

> >       default_priv_spec.  Return 0 if the input privilege name isn't

> >       supported.  Otherwise, return 1.

> >

> >       (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 version.

> >       (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 call

> >       riscv_set_default_priv_version with DEFAULT_PRIV_SPEC to set the default

> >       privilege verison.

> >

> >       * testsuite/gas/riscv/priv-reg-fail-fext.d: This test case just want

> >       to check the ISA dependency for CSR, so fix the version by adding

> >       -mpriv-spec=1p11.

> >       * 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-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.

> >

> >       * configure.ac: Add new configure option --with-priv-spec.

> >       * configure: Regenerated.

> >       * config.in: Regenerated.

> >

> >       include/

> >       * opcode/riscv-opc.h (DECLARE_CSR): Store two version information,

> >       define_version and abort_version for the CSR, which is valid in the

> >       current privilege spec.  The define_version means which privilege spec

> >       started to define the CSR, and the abort_version means which privilege

> >       spec started to abort the CSR.  If the CSR is valid for the newest spec,

> >       then the abort_version is set to CSR_CLASS_VDRAFT.

> >       (DECLARE_CSR_ALIAS): Same as DECLARE_CSR, but only for the obselete CSR.

> >       * opcode/riscv.h: Include "bfd.h" to define bfd_boolean type.

> >       (enum riscv_csr_vclass): New enum classes.  Define the current supported

> >       privilege versions.

> >

> >       opcodes/

> >       * riscv-opc.c (struct priv_version_t): New structure.

> >       (struct priv_version_t priv_versions): Store the supported privilege

> >       versions' classes and their corresponding version string.

> >       (riscv_get_priv_version_class): New function.  Get the corresponding

> >       CSR version class by giving a privilege version string.

> >       (riscv_get_priv_version_name): New function.  Get the corresponding

> >       privilege version 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.in                                      |   3 +

> >  gas/config/tc-riscv.c                              | 213 +++++++--

> >  gas/configure                                      |  13 +

> >  gas/configure.ac                                   |   8 +

> >  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/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                             |  19 +

> >  opcodes/riscv-dis.c                                |   3 +-

> >  opcodes/riscv-opc.c                                |  55 +++

> >  25 files changed, 728 insertions(+), 311 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 c75059b..a972c60 100644

> > --- a/binutils/dwarf.c

> > +++ b/binutils/dwarf.c

> > @@ -7378,7 +7378,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.in b/gas/config.in

> > index 935bd9b..093f474 100644

> > --- a/gas/config.in

> > +++ b/gas/config.in

> > @@ -59,6 +59,9 @@

> >  /* Define to 1 if you want to fix Loongson3 LLSC Errata by default. */

> >  #undef DEFAULT_MIPS_FIX_LOONGSON3_LLSC

> >

> > +/* Define default value for -mpriv-spec */

> > +#undef DEFAULT_PRIV_SPEC

> > +

> >  /* Define to 1 if you want to generate RISC-V arch attribute by default. */

> >  #undef DEFAULT_RISCV_ATTR

> >

> > diff --git a/gas/config/tc-riscv.c b/gas/config/tc-riscv.c

> > index bfcf2f0..6528a03 100644

> > --- a/gas/config/tc-riscv.c

> > +++ b/gas/config/tc-riscv.c

> > @@ -75,10 +75,15 @@ struct riscv_cl_insn

> >  #define DEFAULT_RISCV_ISA_VERSION NULL

> >  #endif

> >

> > +#ifndef DEFAULT_PRIV_SPEC

> > +#define DEFAULT_PRIV_SPEC "1p11"

> > +#endif

> > +

> >  static const char default_arch[] = DEFAULT_ARCH;

> >  static const char *default_arch_with_ext = DEFAULT_ARCH_WITH_EXT;

> >  static const char *default_isa_spec = DEFAULT_ISA_SPEC;

> >  static const char *default_riscv_isa_version = DEFAULT_RISCV_ISA_VERSION;

> > +static enum riscv_csr_vclass default_priv_spec = CSR_CLASS_VNONE;

> >

> >  static unsigned xlen = 0; /* width of an x-register */

> >  static unsigned abi_xlen = 0; /* width of a pointer in the ABI */

> > @@ -536,8 +541,9 @@ enum reg_class

> >  {

> >    RCLASS_GPR,

> >    RCLASS_FPR,

> > -  RCLASS_CSR,

> > -  RCLASS_MAX

> > +  RCLASS_MAX,

> > +

> > +  RCLASS_CSR

> >  };

> >

> >  static struct hash_control *reg_names_hash = NULL;

> > @@ -585,84 +591,197 @@ 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_csr_vclass 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_csr_vclass abort_version;

> > +

> > +  /* The CSR may have more than one setting.  */

> > +  struct riscv_csr_extra *next;

> >  };

> >

> > -/* Init two hashes, csr_extra_hash and reg_names_hash, for CSR.  */

> > +/* Set the default_priv_spec, assembler will find the suitable CSR address

> > +   according to default_priv_spec.  Return 0 if the input priv name isn't

> > +   supported.  Otherwise, return 1.  */

> >

> > -static void

> > -riscv_init_csr_hashes (const char *name,

> > -                    unsigned address,

> > -                    enum riscv_csr_class class)

> > +static int

> > +riscv_set_default_priv_version (const char *s)

> >  {

> > -  struct riscv_csr_extra *entry = XNEW (struct riscv_csr_extra);

> > -  entry->csr_class = class;

> > +  enum riscv_csr_vclass class;

> > +  if (!riscv_get_priv_version_class (s, &class))

> > +    {

> > +      as_bad (_("Unsupported RISC-V privilege version set by "

> > +             "-mpriv-spec=%s."), s);

> > +      return 0;

> > +    }

> > +  else

> > +    default_priv_spec = class;

> > +  return 1;

> > +}

> > +

> > +/* Init hash table csr_extra_hash to handle CSR.  */

> >

> > -  const char *hash_error =

> > -    hash_insert (csr_extra_hash, name, (void *) entry);

> > -  if (hash_error != NULL)

> > +static void

> > +riscv_init_csr_hash (const char *name,

> > +                  unsigned address,

> > +                  enum riscv_csr_class class,

> > +                  enum riscv_csr_vclass define_version,

> > +                  enum riscv_csr_vclass 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)

> >      {

> > -      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."));

> > +      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;

> >      }

> >

> > -  hash_reg_name (RCLASS_CSR, name, address);

> > +  /* Duplicate setting for the CSR, just return and do nothing.  */

> > +  if (!need_enrty)

> > +    return;

> > +

> > +  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;

> >  }

> >

> >  /* Check wether the CSR is valid according to the ISA.  */

> >

> > -static bfd_boolean

> > -riscv_csr_class_check (enum riscv_csr_class csr_class)

> > +static void

> > +riscv_csr_class_check (const char *s,

> > +                    enum riscv_csr_class csr_class)

> >  {

> > +  bfd_boolean result = TRUE;

> > +

> > +  /* Don't check the ISA dependency when -mcsr-check isn't set.  */

> > +  if (!riscv_opts.csr_check)

> > +    return;

> > +

> >    switch (csr_class)

> >      {

> > -    case CSR_CLASS_I: return riscv_subset_supports ("i");

> > -    case CSR_CLASS_F: return riscv_subset_supports ("f");

> > +    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:

> > -      return (xlen == 32 && riscv_subset_supports ("i"));

> > -

> > +      result = (xlen == 32 && riscv_subset_supports ("i"));

> > +      break;

> >      default:

> > -      return FALSE;

> > +      as_bad (_("internal: bad RISC-V CSR class (0x%x)"), csr_class);

> >      }

> > +  if (!result)

> > +    as_warn (_("Invalid CSR `%s' for the current ISA"), s);

> >  }

> >

> > -/* 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.  */

> > +/* Check and find the CSR address according to the privilege spec version.  */

> >

> > -static bfd_boolean

> > +static void

> > +riscv_csr_version_check (const char *csr_name,

> > +                      struct riscv_csr_extra **entryP)

> > +{

> > +  struct riscv_csr_extra *entry = *entryP;

> > +  while (entry != NULL)

> > +    {

> > +      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;

> > +    }

> > +

> > +  /* 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_version_name (default_priv_spec);

> > +      if (priv_name != NULL)

> > +     as_warn (_("Invalid CSR `%s' for the privilege version `%s'"),

> > +              csr_name, priv_name);

> > +    }

> > +}

> > +

> > +/* 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 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 version.  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);

> >  }

> >

> > @@ -946,8 +1065,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

> >

> > @@ -2434,6 +2555,7 @@ enum options

> >    OPTION_NO_CSR_CHECK,

> >    OPTION_MISA_SPEC,

> >    OPTION_MRISCV_ISA_VERSION,

> > +  OPTION_MPRIV_SPEC,

> >    OPTION_END_OF_ENUM

> >  };

> >

> > @@ -2452,6 +2574,7 @@ struct option md_longopts[] =

> >    {"mno-csr-check", no_argument, NULL, OPTION_NO_CSR_CHECK},

> >    {"misa-spec", required_argument, NULL, OPTION_MISA_SPEC},

> >    {"mriscv-isa-version", required_argument, NULL, OPTION_MRISCV_ISA_VERSION},

> > +  {"mpriv-spec", required_argument, NULL, OPTION_MPRIV_SPEC},

> >

> >    {NULL, no_argument, NULL, 0}

> >  };

> > @@ -2548,6 +2671,9 @@ md_parse_option (int c, const char *arg)

> >        default_riscv_isa_version = arg;

> >        break;

> >

> > +    case OPTION_MPRIV_SPEC:

> > +      return riscv_set_default_priv_version (arg);

> > +

> >      default:

> >        return 0;

> >      }

> > @@ -2594,6 +2720,11 @@ riscv_after_parse_args (void)

> >    if (riscv_subset_supports ("e"))

> >      riscv_set_rve (TRUE);

> >

> > +  /* If the -mpriv-spec isn't set, then we set the default privilege version

> > +     according to DEFAULT_PRIV_SPEC,  */

> > +  if (default_priv_spec == CSR_CLASS_VNONE)

> > +    riscv_set_default_priv_version (DEFAULT_PRIV_SPEC);

> > +

> >    /* Infer ABI from ISA if not specified on command line.  */

> >    if (abi_xlen == 0)

> >      abi_xlen = xlen;

> > diff --git a/gas/configure b/gas/configure

> > index bce847a..0911152 100755

> > --- a/gas/configure

> > +++ b/gas/configure

> > @@ -13068,6 +13068,19 @@ _ACEOF

> >       fi

> >       { $as_echo "$as_me:${as_lineno-$LINENO}: result: $with_riscv_isa_version" >&5

> >  $as_echo "$with_riscv_isa_version" >&6; }

> > +

> > +      # --with-priv-spec=[1p9p1|1p10|1p11].

> > +     { $as_echo "$as_me:${as_lineno-$LINENO}: checking for default configuration of --with-priv-spec" >&5

> > +$as_echo_n "checking for default configuration of --with-priv-spec... " >&6; }

> > +     if test "x${with_priv_spec}" != x; then

> > +

> > +cat >>confdefs.h <<_ACEOF

> > +#define DEFAULT_PRIV_SPEC "$with_priv_spec"

> > +_ACEOF

> > +

> > +     fi

> > +     { $as_echo "$as_me:${as_lineno-$LINENO}: result: $with_priv_spec" >&5

> > +$as_echo "$with_priv_spec" >&6; }

> >       ;;

> >

> >        rl78)

> > diff --git a/gas/configure.ac b/gas/configure.ac

> > index be4ba20..c3d3639 100644

> > --- a/gas/configure.ac

> > +++ b/gas/configure.ac

> > @@ -606,6 +606,14 @@ changequote([,])dnl

> >                             covered by --with-isa-spec])

> >       fi

> >       AC_MSG_RESULT($with_riscv_isa_version)

> > +

> > +      # --with-priv-spec=[1p9p1|1p10|1p11].

> > +     AC_MSG_CHECKING(for default configuration of --with-priv-spec)

> > +     if test "x${with_priv_spec}" != x; then

> > +       AC_DEFINE_UNQUOTED(DEFAULT_PRIV_SPEC, "$with_priv_spec",

> > +                          [Define default value for -mpriv-spec])

> > +     fi

> > +     AC_MSG_RESULT($with_priv_spec)

> >       ;;

> >

> >        rl78)

> > diff --git a/gas/testsuite/gas/riscv/priv-reg-fail-fext.d b/gas/testsuite/gas/riscv/priv-reg-fail-fext.d

> > index da53566..0033e3c 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=1p11

> >  #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..d3b1bad 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 version `1p11'

> > +.*Warning: Invalid CSR `sbadaddr' for the privilege version `1p11'

> > +.*Warning: Invalid CSR `sptbr' for the privilege version `1p11'

> > +.*Warning: Invalid CSR `mbadaddr' for the privilege version `1p11'

> > +.*Warning: Invalid CSR `mucounteren' for the privilege version `1p11'

> > +.*Warning: Invalid CSR `dscratch' for the privilege version `1p11'

> > +.*Warning: Invalid CSR `hstatus' for the privilege version `1p11'

> > +.*Warning: Invalid CSR `hedeleg' for the privilege version `1p11'

> > +.*Warning: Invalid CSR `hideleg' for the privilege version `1p11'

> > +.*Warning: Invalid CSR `hie' for the privilege version `1p11'

> > +.*Warning: Invalid CSR `htvec' for the privilege version `1p11'

> > +.*Warning: Invalid CSR `hscratch' for the privilege version `1p11'

> > +.*Warning: Invalid CSR `hepc' for the privilege version `1p11'

> > +.*Warning: Invalid CSR `hcause' for the privilege version `1p11'

> > +.*Warning: Invalid CSR `hbadaddr' for the privilege version `1p11'

> > +.*Warning: Invalid CSR `hip' for the privilege version `1p11'

> > +.*Warning: Invalid CSR `mbase' for the privilege version `1p11'

> > +.*Warning: Invalid CSR `mbound' for the privilege version `1p11'

> > +.*Warning: Invalid CSR `mibase' for the privilege version `1p11'

> > +.*Warning: Invalid CSR `mibound' for the privilege version `1p11'

> > +.*Warning: Invalid CSR `mdbase' for the privilege version `1p11'

> > +.*Warning: Invalid CSR `mdbound' for the privilege version `1p11'

> > +.*Warning: Invalid CSR `mscounteren' for the privilege version `1p11'

> > +.*Warning: Invalid CSR `mhcounteren' for the privilege version `1p11'

> > 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..bbf83b5 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=1p11

> >  #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..e8355f1 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 version `1p11'

> > +.*Warning: Invalid CSR `sbadaddr' for the privilege version `1p11'

> > +.*Warning: Invalid CSR `sptbr' for the privilege version `1p11'

> > +.*Warning: Invalid CSR `mbadaddr' for the privilege version `1p11'

> > +.*Warning: Invalid CSR `mucounteren' for the privilege version `1p11'

> > +.*Warning: Invalid CSR `dscratch' for the privilege version `1p11'

> > +.*Warning: Invalid CSR `hstatus' for the privilege version `1p11'

> > +.*Warning: Invalid CSR `hedeleg' for the privilege version `1p11'

> > +.*Warning: Invalid CSR `hideleg' for the privilege version `1p11'

> > +.*Warning: Invalid CSR `hie' for the privilege version `1p11'

> > +.*Warning: Invalid CSR `htvec' for the privilege version `1p11'

> > +.*Warning: Invalid CSR `hscratch' for the privilege version `1p11'

> > +.*Warning: Invalid CSR `hepc' for the privilege version `1p11'

> > +.*Warning: Invalid CSR `hcause' for the privilege version `1p11'

> > +.*Warning: Invalid CSR `hbadaddr' for the privilege version `1p11'

> > +.*Warning: Invalid CSR `hip' for the privilege version `1p11'

> > +.*Warning: Invalid CSR `mbase' for the privilege version `1p11'

> > +.*Warning: Invalid CSR `mbound' for the privilege version `1p11'

> > +.*Warning: Invalid CSR `mibase' for the privilege version `1p11'

> > +.*Warning: Invalid CSR `mibound' for the privilege version `1p11'

> > +.*Warning: Invalid CSR `mdbase' for the privilege version `1p11'

> > +.*Warning: Invalid CSR `mdbound' for the privilege version `1p11'

> > +.*Warning: Invalid CSR `mscounteren' for the privilege version `1p11'

> > +.*Warning: Invalid CSR `mhcounteren' for the privilege version `1p11'

> > 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..a0b88cf 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=1p11

> >  #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..5e96a85 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 version `1p11'

> > +.*Warning: Invalid CSR `sbadaddr' for the privilege version `1p11'

> > +.*Warning: Invalid CSR `sptbr' for the privilege version `1p11'

> > +.*Warning: Invalid CSR `mbadaddr' for the privilege version `1p11'

> > +.*Warning: Invalid CSR `mucounteren' for the privilege version `1p11'

> > +.*Warning: Invalid CSR `dscratch' for the privilege version `1p11'

> > +.*Warning: Invalid CSR `hstatus' for the privilege version `1p11'

> > +.*Warning: Invalid CSR `hedeleg' for the privilege version `1p11'

> > +.*Warning: Invalid CSR `hideleg' for the privilege version `1p11'

> > +.*Warning: Invalid CSR `hie' for the privilege version `1p11'

> > +.*Warning: Invalid CSR `htvec' for the privilege version `1p11'

> > +.*Warning: Invalid CSR `hscratch' for the privilege version `1p11'

> > +.*Warning: Invalid CSR `hepc' for the privilege version `1p11'

> > +.*Warning: Invalid CSR `hcause' for the privilege version `1p11'

> > +.*Warning: Invalid CSR `hbadaddr' for the privilege version `1p11'

> > +.*Warning: Invalid CSR `hip' for the privilege version `1p11'

> > +.*Warning: Invalid CSR `mbase' for the privilege version `1p11'

> > +.*Warning: Invalid CSR `mbound' for the privilege version `1p11'

> > +.*Warning: Invalid CSR `mibase' for the privilege version `1p11'

> > +.*Warning: Invalid CSR `mibound' for the privilege version `1p11'

> > +.*Warning: Invalid CSR `mdbase' for the privilege version `1p11'

> > +.*Warning: Invalid CSR `mdbound' for the privilege version `1p11'

> > +.*Warning: Invalid CSR `mscounteren' for the privilege version `1p11'

> > +.*Warning: Invalid CSR `mhcounteren' for the privilege version `1p11'

> > 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..d7a788a

> > --- /dev/null

> > +++ b/gas/testsuite/gas/riscv/priv-reg-fail-version-1p10.d

> > @@ -0,0 +1,3 @@

> > +#as: -march=rv32if -mcsr-check -mpriv-spec=1p10

> > +#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..f532962

> > --- /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 version `1p10'

> > +.*Warning: Invalid CSR `dscratch0' for the privilege version `1p10'

> > +.*Warning: Invalid CSR `dscratch1' for the privilege version `1p10'

> > +.*Warning: Invalid CSR `ubadaddr' for the privilege version `1p10'

> > +.*Warning: Invalid CSR `sbadaddr' for the privilege version `1p10'

> > +.*Warning: Invalid CSR `sptbr' for the privilege version `1p10'

> > +.*Warning: Invalid CSR `mbadaddr' for the privilege version `1p10'

> > +.*Warning: Invalid CSR `mucounteren' for the privilege version `1p10'

> > +.*Warning: Invalid CSR `hstatus' for the privilege version `1p10'

> > +.*Warning: Invalid CSR `hedeleg' for the privilege version `1p10'

> > +.*Warning: Invalid CSR `hideleg' for the privilege version `1p10'

> > +.*Warning: Invalid CSR `hie' for the privilege version `1p10'

> > +.*Warning: Invalid CSR `htvec' for the privilege version `1p10'

> > +.*Warning: Invalid CSR `hscratch' for the privilege version `1p10'

> > +.*Warning: Invalid CSR `hepc' for the privilege version `1p10'

> > +.*Warning: Invalid CSR `hcause' for the privilege version `1p10'

> > +.*Warning: Invalid CSR `hbadaddr' for the privilege version `1p10'

> > +.*Warning: Invalid CSR `hip' for the privilege version `1p10'

> > +.*Warning: Invalid CSR `mbase' for the privilege version `1p10'

> > +.*Warning: Invalid CSR `mbound' for the privilege version `1p10'

> > +.*Warning: Invalid CSR `mibase' for the privilege version `1p10'

> > +.*Warning: Invalid CSR `mibound' for the privilege version `1p10'

> > +.*Warning: Invalid CSR `mdbase' for the privilege version `1p10'

> > +.*Warning: Invalid CSR `mdbound' for the privilege version `1p10'

> > +.*Warning: Invalid CSR `mscounteren' for the privilege version `1p10'

> > +.*Warning: Invalid CSR `mhcounteren' for the privilege version `1p10'

> > 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..2830c83

> > --- /dev/null

> > +++ b/gas/testsuite/gas/riscv/priv-reg-fail-version-1p11.d

> > @@ -0,0 +1,3 @@

> > +#as: -march=rv32if -mcsr-check -mpriv-spec=1p11

> > +#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..252f96a

> > --- /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 version `1p11'

> > +.*Warning: Invalid CSR `sbadaddr' for the privilege version `1p11'

> > +.*Warning: Invalid CSR `sptbr' for the privilege version `1p11'

> > +.*Warning: Invalid CSR `mbadaddr' for the privilege version `1p11'

> > +.*Warning: Invalid CSR `mucounteren' for the privilege version `1p11'

> > +.*Warning: Invalid CSR `dscratch' for the privilege version `1p11'

> > +.*Warning: Invalid CSR `hstatus' for the privilege version `1p11'

> > +.*Warning: Invalid CSR `hedeleg' for the privilege version `1p11'

> > +.*Warning: Invalid CSR `hideleg' for the privilege version `1p11'

> > +.*Warning: Invalid CSR `hie' for the privilege version `1p11'

> > +.*Warning: Invalid CSR `htvec' for the privilege version `1p11'

> > +.*Warning: Invalid CSR `hscratch' for the privilege version `1p11'

> > +.*Warning: Invalid CSR `hepc' for the privilege version `1p11'

> > +.*Warning: Invalid CSR `hcause' for the privilege version `1p11'

> > +.*Warning: Invalid CSR `hbadaddr' for the privilege version `1p11'

> > +.*Warning: Invalid CSR `hip' for the privilege version `1p11'

> > +.*Warning: Invalid CSR `mbase' for the privilege version `1p11'

> > +.*Warning: Invalid CSR `mbound' for the privilege version `1p11'

> > +.*Warning: Invalid CSR `mibase' for the privilege version `1p11'

> > +.*Warning: Invalid CSR `mibound' for the privilege version `1p11'

> > +.*Warning: Invalid CSR `mdbase' for the privilege version `1p11'

> > +.*Warning: Invalid CSR `mdbound' for the privilege version `1p11'

> > +.*Warning: Invalid CSR `mscounteren' for the privilege version `1p11'

> > +.*Warning: Invalid CSR `mhcounteren' for the privilege version `1p11'

> > 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..70c405f

> > --- /dev/null

> > +++ b/gas/testsuite/gas/riscv/priv-reg-fail-version-1p9.d

> > @@ -0,0 +1,3 @@

> > +#as: -march=rv32if -mcsr-check -mpriv-spec=1p9

> > +#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..92e1463

> > --- /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 version `1p9'

> > +.*Warning: Invalid CSR `scounteren' for the privilege version `1p9'

> > +.*Warning: Invalid CSR `stval' for the privilege version `1p9'

> > +.*Warning: Invalid CSR `satp' for the privilege version `1p9'

> > +.*Warning: Invalid CSR `mcounteren' for the privilege version `1p9'

> > +.*Warning: Invalid CSR `mtval' for the privilege version `1p9'

> > +.*Warning: Invalid CSR `pmpcfg0' for the privilege version `1p9'

> > +.*Warning: Invalid CSR `pmpcfg1' for the privilege version `1p9'

> > +.*Warning: Invalid CSR `pmpcfg2' for the privilege version `1p9'

> > +.*Warning: Invalid CSR `pmpcfg3' for the privilege version `1p9'

> > +.*Warning: Invalid CSR `pmpaddr0' for the privilege version `1p9'

> > +.*Warning: Invalid CSR `pmpaddr1' for the privilege version `1p9'

> > +.*Warning: Invalid CSR `pmpaddr2' for the privilege version `1p9'

> > +.*Warning: Invalid CSR `pmpaddr3' for the privilege version `1p9'

> > +.*Warning: Invalid CSR `pmpaddr4' for the privilege version `1p9'

> > +.*Warning: Invalid CSR `pmpaddr5' for the privilege version `1p9'

> > +.*Warning: Invalid CSR `pmpaddr6' for the privilege version `1p9'

> > +.*Warning: Invalid CSR `pmpaddr7' for the privilege version `1p9'

> > +.*Warning: Invalid CSR `pmpaddr8' for the privilege version `1p9'

> > +.*Warning: Invalid CSR `pmpaddr9' for the privilege version `1p9'

> > +.*Warning: Invalid CSR `pmpaddr10' for the privilege version `1p9'

> > +.*Warning: Invalid CSR `pmpaddr11' for the privilege version `1p9'

> > +.*Warning: Invalid CSR `pmpaddr12' for the privilege version `1p9'

> > +.*Warning: Invalid CSR `pmpaddr13' for the privilege version `1p9'

> > +.*Warning: Invalid CSR `pmpaddr14' for the privilege version `1p9'

> > +.*Warning: Invalid CSR `pmpaddr15' for the privilege version `1p9'

> > +.*Warning: Invalid CSR `mcountinhibit' for the privilege version `1p9'

> > +.*Warning: Invalid CSR `dscratch0' for the privilege version `1p9'

> > +.*Warning: Invalid CSR `dscratch1' for the privilege version `1p9'

> > 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..2bd4bbf

> > --- /dev/null

> > +++ b/gas/testsuite/gas/riscv/priv-reg-fail-version-1p9p1.d

> > @@ -0,0 +1,3 @@

> > +#as: -march=rv32if -mcsr-check -mpriv-spec=1p9p1

> > +#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..6cde0b3

> > --- /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 version `1p9p1'

> > +.*Warning: Invalid CSR `scounteren' for the privilege version `1p9p1'

> > +.*Warning: Invalid CSR `stval' for the privilege version `1p9p1'

> > +.*Warning: Invalid CSR `satp' for the privilege version `1p9p1'

> > +.*Warning: Invalid CSR `mcounteren' for the privilege version `1p9p1'

> > +.*Warning: Invalid CSR `mtval' for the privilege version `1p9p1'

> > +.*Warning: Invalid CSR `pmpcfg0' for the privilege version `1p9p1'

> > +.*Warning: Invalid CSR `pmpcfg1' for the privilege version `1p9p1'

> > +.*Warning: Invalid CSR `pmpcfg2' for the privilege version `1p9p1'

> > +.*Warning: Invalid CSR `pmpcfg3' for the privilege version `1p9p1'

> > +.*Warning: Invalid CSR `pmpaddr0' for the privilege version `1p9p1'

> > +.*Warning: Invalid CSR `pmpaddr1' for the privilege version `1p9p1'

> > +.*Warning: Invalid CSR `pmpaddr2' for the privilege version `1p9p1'

> > +.*Warning: Invalid CSR `pmpaddr3' for the privilege version `1p9p1'

> > +.*Warning: Invalid CSR `pmpaddr4' for the privilege version `1p9p1'

> > +.*Warning: Invalid CSR `pmpaddr5' for the privilege version `1p9p1'

> > +.*Warning: Invalid CSR `pmpaddr6' for the privilege version `1p9p1'

> > +.*Warning: Invalid CSR `pmpaddr7' for the privilege version `1p9p1'

> > +.*Warning: Invalid CSR `pmpaddr8' for the privilege version `1p9p1'

> > +.*Warning: Invalid CSR `pmpaddr9' for the privilege version `1p9p1'

> > +.*Warning: Invalid CSR `pmpaddr10' for the privilege version `1p9p1'

> > +.*Warning: Invalid CSR `pmpaddr11' for the privilege version `1p9p1'

> > +.*Warning: Invalid CSR `pmpaddr12' for the privilege version `1p9p1'

> > +.*Warning: Invalid CSR `pmpaddr13' for the privilege version `1p9p1'

> > +.*Warning: Invalid CSR `pmpaddr14' for the privilege version `1p9p1'

> > +.*Warning: Invalid CSR `pmpaddr15' for the privilege version `1p9p1'

> > +.*Warning: Invalid CSR `mcountinhibit' for the privilege version `1p9p1'

> > +.*Warning: Invalid CSR `dscratch0' for the privilege version `1p9p1'

> > +.*Warning: Invalid CSR `dscratch1' for the privilege version `1p9p1'

> > 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..ab11c31 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, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(uie, CSR_UIE, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(utvec, CSR_UTVEC, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(uscratch, CSR_USCRATCH, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(uepc, CSR_UEPC, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(ucause, CSR_UCAUSE, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(utval, CSR_UTVAL, CSR_CLASS_I, CSR_CLASS_V1P10, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(uip, CSR_UIP, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(fflags, CSR_FFLAGS, CSR_CLASS_F, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(frm, CSR_FRM, CSR_CLASS_F, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(fcsr, CSR_FCSR, CSR_CLASS_F, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(cycle, CSR_CYCLE, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(time, CSR_TIME, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(instret, CSR_INSTRET, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(hpmcounter3, CSR_HPMCOUNTER3, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(hpmcounter4, CSR_HPMCOUNTER4, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(hpmcounter5, CSR_HPMCOUNTER5, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(hpmcounter6, CSR_HPMCOUNTER6, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(hpmcounter7, CSR_HPMCOUNTER7, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(hpmcounter8, CSR_HPMCOUNTER8, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(hpmcounter9, CSR_HPMCOUNTER9, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(hpmcounter10, CSR_HPMCOUNTER10, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(hpmcounter11, CSR_HPMCOUNTER11, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(hpmcounter12, CSR_HPMCOUNTER12, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(hpmcounter13, CSR_HPMCOUNTER13, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(hpmcounter14, CSR_HPMCOUNTER14, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(hpmcounter15, CSR_HPMCOUNTER15, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(hpmcounter16, CSR_HPMCOUNTER16, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(hpmcounter17, CSR_HPMCOUNTER17, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(hpmcounter18, CSR_HPMCOUNTER18, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(hpmcounter19, CSR_HPMCOUNTER19, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(hpmcounter20, CSR_HPMCOUNTER20, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(hpmcounter21, CSR_HPMCOUNTER21, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(hpmcounter22, CSR_HPMCOUNTER22, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(hpmcounter23, CSR_HPMCOUNTER23, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(hpmcounter24, CSR_HPMCOUNTER24, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(hpmcounter25, CSR_HPMCOUNTER25, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(hpmcounter26, CSR_HPMCOUNTER26, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(hpmcounter27, CSR_HPMCOUNTER27, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(hpmcounter28, CSR_HPMCOUNTER28, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(hpmcounter29, CSR_HPMCOUNTER29, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(hpmcounter30, CSR_HPMCOUNTER30, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(hpmcounter31, CSR_HPMCOUNTER31, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(cycleh, CSR_CYCLEH, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(timeh, CSR_TIMEH, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(instreth, CSR_INSTRETH, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(hpmcounter3h, CSR_HPMCOUNTER3H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(hpmcounter4h, CSR_HPMCOUNTER4H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(hpmcounter5h, CSR_HPMCOUNTER5H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(hpmcounter6h, CSR_HPMCOUNTER6H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(hpmcounter7h, CSR_HPMCOUNTER7H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(hpmcounter8h, CSR_HPMCOUNTER8H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(hpmcounter9h, CSR_HPMCOUNTER9H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(hpmcounter10h, CSR_HPMCOUNTER10H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(hpmcounter11h, CSR_HPMCOUNTER11H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(hpmcounter12h, CSR_HPMCOUNTER12H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(hpmcounter13h, CSR_HPMCOUNTER13H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(hpmcounter14h, CSR_HPMCOUNTER14H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(hpmcounter15h, CSR_HPMCOUNTER15H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(hpmcounter16h, CSR_HPMCOUNTER16H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(hpmcounter17h, CSR_HPMCOUNTER17H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(hpmcounter18h, CSR_HPMCOUNTER18H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(hpmcounter19h, CSR_HPMCOUNTER19H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(hpmcounter20h, CSR_HPMCOUNTER20H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(hpmcounter21h, CSR_HPMCOUNTER21H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(hpmcounter22h, CSR_HPMCOUNTER22H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(hpmcounter23h, CSR_HPMCOUNTER23H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(hpmcounter24h, CSR_HPMCOUNTER24H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(hpmcounter25h, CSR_HPMCOUNTER25H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(hpmcounter26h, CSR_HPMCOUNTER26H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(hpmcounter27h, CSR_HPMCOUNTER27H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(hpmcounter28h, CSR_HPMCOUNTER28H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(hpmcounter29h, CSR_HPMCOUNTER29H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(hpmcounter30h, CSR_HPMCOUNTER30H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(hpmcounter31h, CSR_HPMCOUNTER31H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(sstatus, CSR_SSTATUS, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(sedeleg, CSR_SEDELEG, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(sideleg, CSR_SIDELEG, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(sie, CSR_SIE, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(stvec, CSR_STVEC, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(scounteren, CSR_SCOUNTEREN, CSR_CLASS_I, CSR_CLASS_V1P10, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(sscratch, CSR_SSCRATCH, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(sepc, CSR_SEPC, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(scause, CSR_SCAUSE, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(stval, CSR_STVAL, CSR_CLASS_I, CSR_CLASS_V1P10, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(sip, CSR_SIP, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(satp, CSR_SATP, CSR_CLASS_I, CSR_CLASS_V1P10, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(mvendorid, CSR_MVENDORID, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(marchid, CSR_MARCHID, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(mimpid, CSR_MIMPID, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(mhartid, CSR_MHARTID, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(mstatus, CSR_MSTATUS, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(misa, CSR_MISA, CSR_CLASS_I, CSR_CLASS_V1P9P1, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(medeleg, CSR_MEDELEG, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(mideleg, CSR_MIDELEG, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(mie, CSR_MIE, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(mtvec, CSR_MTVEC, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(mcounteren, CSR_MCOUNTEREN, CSR_CLASS_I, CSR_CLASS_V1P10, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(mscratch, CSR_MSCRATCH, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(mepc, CSR_MEPC, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(mcause, CSR_MCAUSE, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(mtval, CSR_MTVAL, CSR_CLASS_I, CSR_CLASS_V1P10, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(mip, CSR_MIP, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(pmpcfg0, CSR_PMPCFG0, CSR_CLASS_I, CSR_CLASS_V1P10, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(pmpcfg1, CSR_PMPCFG1, CSR_CLASS_I_32, CSR_CLASS_V1P10, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(pmpcfg2, CSR_PMPCFG2, CSR_CLASS_I, CSR_CLASS_V1P10, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(pmpcfg3, CSR_PMPCFG3, CSR_CLASS_I_32, CSR_CLASS_V1P10, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(pmpaddr0, CSR_PMPADDR0, CSR_CLASS_I, CSR_CLASS_V1P10, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(pmpaddr1, CSR_PMPADDR1, CSR_CLASS_I, CSR_CLASS_V1P10, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(pmpaddr2, CSR_PMPADDR2, CSR_CLASS_I, CSR_CLASS_V1P10, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(pmpaddr3, CSR_PMPADDR3, CSR_CLASS_I, CSR_CLASS_V1P10, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(pmpaddr4, CSR_PMPADDR4, CSR_CLASS_I, CSR_CLASS_V1P10, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(pmpaddr5, CSR_PMPADDR5, CSR_CLASS_I, CSR_CLASS_V1P10, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(pmpaddr6, CSR_PMPADDR6, CSR_CLASS_I, CSR_CLASS_V1P10, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(pmpaddr7, CSR_PMPADDR7, CSR_CLASS_I, CSR_CLASS_V1P10, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(pmpaddr8, CSR_PMPADDR8, CSR_CLASS_I, CSR_CLASS_V1P10, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(pmpaddr9, CSR_PMPADDR9, CSR_CLASS_I, CSR_CLASS_V1P10, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(pmpaddr10, CSR_PMPADDR10, CSR_CLASS_I, CSR_CLASS_V1P10, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(pmpaddr11, CSR_PMPADDR11, CSR_CLASS_I, CSR_CLASS_V1P10, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(pmpaddr12, CSR_PMPADDR12, CSR_CLASS_I, CSR_CLASS_V1P10, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(pmpaddr13, CSR_PMPADDR13, CSR_CLASS_I, CSR_CLASS_V1P10, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(pmpaddr14, CSR_PMPADDR14, CSR_CLASS_I, CSR_CLASS_V1P10, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(pmpaddr15, CSR_PMPADDR15, CSR_CLASS_I, CSR_CLASS_V1P10, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(mcycle, CSR_MCYCLE, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(minstret, CSR_MINSTRET, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(mhpmcounter3, CSR_MHPMCOUNTER3, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(mhpmcounter4, CSR_MHPMCOUNTER4, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(mhpmcounter5, CSR_MHPMCOUNTER5, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(mhpmcounter6, CSR_MHPMCOUNTER6, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(mhpmcounter7, CSR_MHPMCOUNTER7, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(mhpmcounter8, CSR_MHPMCOUNTER8, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(mhpmcounter9, CSR_MHPMCOUNTER9, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(mhpmcounter10, CSR_MHPMCOUNTER10, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(mhpmcounter11, CSR_MHPMCOUNTER11, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(mhpmcounter12, CSR_MHPMCOUNTER12, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(mhpmcounter13, CSR_MHPMCOUNTER13, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(mhpmcounter14, CSR_MHPMCOUNTER14, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(mhpmcounter15, CSR_MHPMCOUNTER15, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(mhpmcounter16, CSR_MHPMCOUNTER16, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(mhpmcounter17, CSR_MHPMCOUNTER17, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(mhpmcounter18, CSR_MHPMCOUNTER18, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(mhpmcounter19, CSR_MHPMCOUNTER19, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(mhpmcounter20, CSR_MHPMCOUNTER20, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(mhpmcounter21, CSR_MHPMCOUNTER21, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(mhpmcounter22, CSR_MHPMCOUNTER22, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(mhpmcounter23, CSR_MHPMCOUNTER23, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(mhpmcounter24, CSR_MHPMCOUNTER24, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(mhpmcounter25, CSR_MHPMCOUNTER25, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(mhpmcounter26, CSR_MHPMCOUNTER26, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(mhpmcounter27, CSR_MHPMCOUNTER27, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(mhpmcounter28, CSR_MHPMCOUNTER28, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(mhpmcounter29, CSR_MHPMCOUNTER29, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(mhpmcounter30, CSR_MHPMCOUNTER30, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(mhpmcounter31, CSR_MHPMCOUNTER31, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(mcycleh, CSR_MCYCLEH, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(minstreth, CSR_MINSTRETH, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(mhpmcounter3h, CSR_MHPMCOUNTER3H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(mhpmcounter4h, CSR_MHPMCOUNTER4H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(mhpmcounter5h, CSR_MHPMCOUNTER5H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(mhpmcounter6h, CSR_MHPMCOUNTER6H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(mhpmcounter7h, CSR_MHPMCOUNTER7H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(mhpmcounter8h, CSR_MHPMCOUNTER8H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(mhpmcounter9h, CSR_MHPMCOUNTER9H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(mhpmcounter10h, CSR_MHPMCOUNTER10H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(mhpmcounter11h, CSR_MHPMCOUNTER11H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(mhpmcounter12h, CSR_MHPMCOUNTER12H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(mhpmcounter13h, CSR_MHPMCOUNTER13H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(mhpmcounter14h, CSR_MHPMCOUNTER14H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(mhpmcounter15h, CSR_MHPMCOUNTER15H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(mhpmcounter16h, CSR_MHPMCOUNTER16H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(mhpmcounter17h, CSR_MHPMCOUNTER17H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(mhpmcounter18h, CSR_MHPMCOUNTER18H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(mhpmcounter19h, CSR_MHPMCOUNTER19H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(mhpmcounter20h, CSR_MHPMCOUNTER20H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(mhpmcounter21h, CSR_MHPMCOUNTER21H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(mhpmcounter22h, CSR_MHPMCOUNTER22H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(mhpmcounter23h, CSR_MHPMCOUNTER23H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(mhpmcounter24h, CSR_MHPMCOUNTER24H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(mhpmcounter25h, CSR_MHPMCOUNTER25H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(mhpmcounter26h, CSR_MHPMCOUNTER26H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(mhpmcounter27h, CSR_MHPMCOUNTER27H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(mhpmcounter28h, CSR_MHPMCOUNTER28H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(mhpmcounter29h, CSR_MHPMCOUNTER29H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(mhpmcounter30h, CSR_MHPMCOUNTER30H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(mhpmcounter31h, CSR_MHPMCOUNTER31H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(mcountinhibit, CSR_MCOUNTINHIBIT, CSR_CLASS_I, CSR_CLASS_V1P11, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(mhpmevent3, CSR_MHPMEVENT3, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(mhpmevent4, CSR_MHPMEVENT4, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(mhpmevent5, CSR_MHPMEVENT5, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(mhpmevent6, CSR_MHPMEVENT6, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(mhpmevent7, CSR_MHPMEVENT7, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(mhpmevent8, CSR_MHPMEVENT8, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(mhpmevent9, CSR_MHPMEVENT9, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(mhpmevent10, CSR_MHPMEVENT10, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(mhpmevent11, CSR_MHPMEVENT11, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(mhpmevent12, CSR_MHPMEVENT12, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(mhpmevent13, CSR_MHPMEVENT13, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(mhpmevent14, CSR_MHPMEVENT14, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(mhpmevent15, CSR_MHPMEVENT15, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(mhpmevent16, CSR_MHPMEVENT16, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(mhpmevent17, CSR_MHPMEVENT17, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(mhpmevent18, CSR_MHPMEVENT18, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(mhpmevent19, CSR_MHPMEVENT19, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(mhpmevent20, CSR_MHPMEVENT20, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(mhpmevent21, CSR_MHPMEVENT21, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(mhpmevent22, CSR_MHPMEVENT22, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(mhpmevent23, CSR_MHPMEVENT23, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(mhpmevent24, CSR_MHPMEVENT24, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(mhpmevent25, CSR_MHPMEVENT25, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(mhpmevent26, CSR_MHPMEVENT26, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(mhpmevent27, CSR_MHPMEVENT27, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(mhpmevent28, CSR_MHPMEVENT28, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(mhpmevent29, CSR_MHPMEVENT29, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(mhpmevent30, CSR_MHPMEVENT30, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(mhpmevent31, CSR_MHPMEVENT31, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(tselect, CSR_TSELECT, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(tdata1, CSR_TDATA1, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(tdata2, CSR_TDATA2, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(tdata3, CSR_TDATA3, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(dcsr, CSR_DCSR, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(dpc, CSR_DPC, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(dscratch0, CSR_DSCRATCH0, CSR_CLASS_I, CSR_CLASS_V1P11, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(dscratch1, CSR_DSCRATCH1, CSR_CLASS_I, CSR_CLASS_V1P11, CSR_CLASS_VDRAFT)

> > +DECLARE_CSR(hstatus, CSR_HSTATUS, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_V1P10)

> > +DECLARE_CSR(hedeleg, CSR_HEDELEG, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_V1P10)

> > +DECLARE_CSR(hideleg, CSR_HIDELEG, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_V1P10)

> > +DECLARE_CSR(hie, CSR_HIE, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_V1P10)

> > +DECLARE_CSR(htvec, CSR_HTVEC, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_V1P10)

> > +DECLARE_CSR(hscratch, CSR_HSCRATCH, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_V1P10)

> > +DECLARE_CSR(hepc, CSR_HEPC, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_V1P10)

> > +DECLARE_CSR(hcause, CSR_HCAUSE, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_V1P10)

> > +DECLARE_CSR(hbadaddr, CSR_HBADADDR, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_V1P10)

> > +DECLARE_CSR(hip, CSR_HIP, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_V1P10)

> > +DECLARE_CSR(mbase, CSR_MBASE, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_V1P10)

> > +DECLARE_CSR(mbound, CSR_MBOUND, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_V1P10)

> > +DECLARE_CSR(mibase, CSR_MIBASE, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_V1P10)

> > +DECLARE_CSR(mibound, CSR_MIBOUND, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_V1P10)

> > +DECLARE_CSR(mdbase, CSR_MDBASE, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_V1P10)

> > +DECLARE_CSR(mdbound, CSR_MDBOUND, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_V1P10)

> > +DECLARE_CSR(mscounteren, CSR_MSCOUNTEREN, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_V1P10)

> > +DECLARE_CSR(mhcounteren, CSR_MHCOUNTEREN, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_V1P10)

> >  #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, CSR_CLASS_V1P9, CSR_CLASS_V1P9P1)

> > +DECLARE_CSR_ALIAS(ubadaddr, CSR_UTVAL, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_V1P10)

> > +DECLARE_CSR_ALIAS(sbadaddr, CSR_STVAL, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_V1P10)

> > +DECLARE_CSR_ALIAS(sptbr, CSR_SATP, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_V1P10)

> > +DECLARE_CSR_ALIAS(mbadaddr, CSR_MTVAL, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_V1P10)

> > +DECLARE_CSR_ALIAS(mucounteren, CSR_MCOUNTINHIBIT, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_V1P10)

> > +DECLARE_CSR_ALIAS(dscratch, CSR_DSCRATCH0, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_V1P11)

> >  #endif

> >  #ifdef DECLARE_CAUSE

> >  DECLARE_CAUSE("misaligned fetch", CAUSE_MISALIGNED_FETCH)

> > diff --git a/include/opcode/riscv.h b/include/opcode/riscv.h

> > index f8b0de3..c36bf69 100644

> > --- a/include/opcode/riscv.h

> > +++ b/include/opcode/riscv.h

> > @@ -24,6 +24,7 @@

> >  #include "riscv-opc.h"

> >  #include <stdlib.h>

> >  #include <stdint.h>

> > +#include "bfd.h"

> >

> >  typedef uint64_t insn_t;

> >

> > @@ -353,6 +354,19 @@ struct riscv_ext_version

> >    unsigned int minor_version;

> >  };

> >

> > +/* The current supported privilege versions.  */

> > +

> > +enum riscv_csr_vclass

> > +{

> > +  CSR_CLASS_VNONE,   /* Default value */

> > +

> > +  CSR_CLASS_V1P9,       /* v1.9 */

> > +  CSR_CLASS_V1P9P1,     /* v1.9.1 */

> > +  CSR_CLASS_V1P10,      /* v1.10 */

> > +  CSR_CLASS_V1P11,      /* v1.11 */

> > +  CSR_CLASS_VDRAFT

> > +};

> > +

> >  /* Instruction is a simple alias (e.g. "mv" for "addi").  */

> >  #define      INSN_ALIAS              0x00000001

> >

> > @@ -432,4 +446,9 @@ extern const struct riscv_opcode riscv_opcodes[];

> >  extern const struct riscv_opcode riscv_insn_types[];

> >  extern const struct riscv_ext_version riscv_ext_version_table[];

> >

> > +extern bfd_boolean

> > +riscv_get_priv_version_class (const char *, enum riscv_csr_vclass *);

> > +extern const char *

> > +riscv_get_priv_version_name (enum riscv_csr_vclass);

> > +

> >  #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 7b885bf..cfefd8e 100644

> > --- a/opcodes/riscv-opc.c

> > +++ b/opcodes/riscv-opc.c

> > @@ -937,3 +937,58 @@ const struct riscv_ext_version riscv_ext_version_table[] =

> >  /* Terminate the list.  */

> >  {NULL, NULL, 0, 0}

> >  };

> > +

> > +struct priv_version_t

> > +{

> > +  const char *name;

> > +  enum riscv_csr_vclass vclass;

> > +};

> > +

> > +/* List for all supported CSR versions.  */

> > +static const struct priv_version_t priv_versions[] =

> > +{

> > +  {"1p9", CSR_CLASS_V1P9},

> > +  {"1p9p1", CSR_CLASS_V1P9P1},

> > +  {"1p10", CSR_CLASS_V1P10},

> > +  {"1p11", CSR_CLASS_V1P11},

> > +

> > +/* Terminate the list.  */

> > +  {NULL, 0}

> > +};

> > +

> > +/* Get the corresponding CSR version class by giving a privilege

> > +   version string.  */

> > +

> > +bfd_boolean

> > +riscv_get_priv_version_class (const char *s,

> > +                           enum riscv_csr_vclass *class)

> > +{

> > +  const struct priv_version_t *version;

> > +

> > +  if (s == NULL)

> > +    return FALSE;

> > +

> > +  for (version = &priv_versions[0]; version->name != NULL; ++version)

> > +    if (strcmp (version->name, s) == 0)

> > +      {

> > +     *class = version->vclass;

> > +     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_version_name (enum riscv_csr_vclass class)

> > +{

> > +  const struct priv_version_t *version;

> > +  for (version = &priv_versions[0]; version->name != NULL; ++version)

> > +    if (class == version->vclass)

> > +      return version->name;

> > +  /* This shouldn't happen.  */

> > +  return NULL;

> > +}

> > --

> > 2.7.4

> >

Patch

diff --git a/binutils/dwarf.c b/binutils/dwarf.c
index c75059b..a972c60 100644
--- a/binutils/dwarf.c
+++ b/binutils/dwarf.c
@@ -7378,7 +7378,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.in b/gas/config.in
index 935bd9b..093f474 100644
--- a/gas/config.in
+++ b/gas/config.in
@@ -59,6 +59,9 @@ 
 /* Define to 1 if you want to fix Loongson3 LLSC Errata by default. */
 #undef DEFAULT_MIPS_FIX_LOONGSON3_LLSC
 
+/* Define default value for -mpriv-spec */
+#undef DEFAULT_PRIV_SPEC
+
 /* Define to 1 if you want to generate RISC-V arch attribute by default. */
 #undef DEFAULT_RISCV_ATTR
 
diff --git a/gas/config/tc-riscv.c b/gas/config/tc-riscv.c
index bfcf2f0..6528a03 100644
--- a/gas/config/tc-riscv.c
+++ b/gas/config/tc-riscv.c
@@ -75,10 +75,15 @@  struct riscv_cl_insn
 #define DEFAULT_RISCV_ISA_VERSION NULL
 #endif
 
+#ifndef DEFAULT_PRIV_SPEC
+#define DEFAULT_PRIV_SPEC "1p11"
+#endif
+
 static const char default_arch[] = DEFAULT_ARCH;
 static const char *default_arch_with_ext = DEFAULT_ARCH_WITH_EXT;
 static const char *default_isa_spec = DEFAULT_ISA_SPEC;
 static const char *default_riscv_isa_version = DEFAULT_RISCV_ISA_VERSION;
+static enum riscv_csr_vclass default_priv_spec = CSR_CLASS_VNONE;
 
 static unsigned xlen = 0; /* width of an x-register */
 static unsigned abi_xlen = 0; /* width of a pointer in the ABI */
@@ -536,8 +541,9 @@  enum reg_class
 {
   RCLASS_GPR,
   RCLASS_FPR,
-  RCLASS_CSR,
-  RCLASS_MAX
+  RCLASS_MAX,
+
+  RCLASS_CSR
 };
 
 static struct hash_control *reg_names_hash = NULL;
@@ -585,84 +591,197 @@  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_csr_vclass 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_csr_vclass abort_version;
+
+  /* The CSR may have more than one setting.  */
+  struct riscv_csr_extra *next;
 };
 
-/* Init two hashes, csr_extra_hash and reg_names_hash, for CSR.  */
+/* Set the default_priv_spec, assembler will find the suitable CSR address
+   according to default_priv_spec.  Return 0 if the input priv name isn't
+   supported.  Otherwise, return 1.  */
 
-static void
-riscv_init_csr_hashes (const char *name,
-		       unsigned address,
-		       enum riscv_csr_class class)
+static int
+riscv_set_default_priv_version (const char *s)
 {
-  struct riscv_csr_extra *entry = XNEW (struct riscv_csr_extra);
-  entry->csr_class = class;
+  enum riscv_csr_vclass class;
+  if (!riscv_get_priv_version_class (s, &class))
+    {
+      as_bad (_("Unsupported RISC-V privilege version set by "
+		"-mpriv-spec=%s."), s);
+      return 0;
+    }
+  else
+    default_priv_spec = class;
+  return 1;
+}
+
+/* Init hash table csr_extra_hash to handle CSR.  */
 
-  const char *hash_error =
-    hash_insert (csr_extra_hash, name, (void *) entry);
-  if (hash_error != NULL)
+static void
+riscv_init_csr_hash (const char *name,
+		     unsigned address,
+		     enum riscv_csr_class class,
+		     enum riscv_csr_vclass define_version,
+		     enum riscv_csr_vclass 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)
     {
-      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."));
+      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;
     }
 
-  hash_reg_name (RCLASS_CSR, name, address);
+  /* Duplicate setting for the CSR, just return and do nothing.  */
+  if (!need_enrty)
+    return;
+
+  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;
 }
 
 /* Check wether the CSR is valid according to the ISA.  */
 
-static bfd_boolean
-riscv_csr_class_check (enum riscv_csr_class csr_class)
+static void
+riscv_csr_class_check (const char *s,
+		       enum riscv_csr_class csr_class)
 {
+  bfd_boolean result = TRUE;
+
+  /* Don't check the ISA dependency when -mcsr-check isn't set.  */
+  if (!riscv_opts.csr_check)
+    return;
+
   switch (csr_class)
     {
-    case CSR_CLASS_I: return riscv_subset_supports ("i");
-    case CSR_CLASS_F: return riscv_subset_supports ("f");
+    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:
-      return (xlen == 32 && riscv_subset_supports ("i"));
-
+      result = (xlen == 32 && riscv_subset_supports ("i"));
+      break;
     default:
-      return FALSE;
+      as_bad (_("internal: bad RISC-V CSR class (0x%x)"), csr_class);
     }
+  if (!result)
+    as_warn (_("Invalid CSR `%s' for the current ISA"), s);
 }
 
-/* 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.  */
+/* Check and find the CSR address according to the privilege spec version.  */
 
-static bfd_boolean
+static void
+riscv_csr_version_check (const char *csr_name,
+			 struct riscv_csr_extra **entryP)
+{
+  struct riscv_csr_extra *entry = *entryP;
+  while (entry != NULL)
+    {
+      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;
+    }
+
+  /* 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_version_name (default_priv_spec);
+      if (priv_name != NULL)
+	as_warn (_("Invalid CSR `%s' for the privilege version `%s'"),
+		 csr_name, priv_name);
+    }
+}
+
+/* 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 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 version.  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);
 }
 
@@ -946,8 +1065,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
 
@@ -2434,6 +2555,7 @@  enum options
   OPTION_NO_CSR_CHECK,
   OPTION_MISA_SPEC,
   OPTION_MRISCV_ISA_VERSION,
+  OPTION_MPRIV_SPEC,
   OPTION_END_OF_ENUM
 };
 
@@ -2452,6 +2574,7 @@  struct option md_longopts[] =
   {"mno-csr-check", no_argument, NULL, OPTION_NO_CSR_CHECK},
   {"misa-spec", required_argument, NULL, OPTION_MISA_SPEC},
   {"mriscv-isa-version", required_argument, NULL, OPTION_MRISCV_ISA_VERSION},
+  {"mpriv-spec", required_argument, NULL, OPTION_MPRIV_SPEC},
 
   {NULL, no_argument, NULL, 0}
 };
@@ -2548,6 +2671,9 @@  md_parse_option (int c, const char *arg)
       default_riscv_isa_version = arg;
       break;
 
+    case OPTION_MPRIV_SPEC:
+      return riscv_set_default_priv_version (arg);
+
     default:
       return 0;
     }
@@ -2594,6 +2720,11 @@  riscv_after_parse_args (void)
   if (riscv_subset_supports ("e"))
     riscv_set_rve (TRUE);
 
+  /* If the -mpriv-spec isn't set, then we set the default privilege version
+     according to DEFAULT_PRIV_SPEC,  */
+  if (default_priv_spec == CSR_CLASS_VNONE)
+    riscv_set_default_priv_version (DEFAULT_PRIV_SPEC);
+
   /* Infer ABI from ISA if not specified on command line.  */
   if (abi_xlen == 0)
     abi_xlen = xlen;
diff --git a/gas/configure b/gas/configure
index bce847a..0911152 100755
--- a/gas/configure
+++ b/gas/configure
@@ -13068,6 +13068,19 @@  _ACEOF
 	fi
 	{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $with_riscv_isa_version" >&5
 $as_echo "$with_riscv_isa_version" >&6; }
+
+	 # --with-priv-spec=[1p9p1|1p10|1p11].
+	{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for default configuration of --with-priv-spec" >&5
+$as_echo_n "checking for default configuration of --with-priv-spec... " >&6; }
+	if test "x${with_priv_spec}" != x; then
+
+cat >>confdefs.h <<_ACEOF
+#define DEFAULT_PRIV_SPEC "$with_priv_spec"
+_ACEOF
+
+	fi
+	{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $with_priv_spec" >&5
+$as_echo "$with_priv_spec" >&6; }
 	;;
 
       rl78)
diff --git a/gas/configure.ac b/gas/configure.ac
index be4ba20..c3d3639 100644
--- a/gas/configure.ac
+++ b/gas/configure.ac
@@ -606,6 +606,14 @@  changequote([,])dnl
 			      covered by --with-isa-spec])
 	fi
 	AC_MSG_RESULT($with_riscv_isa_version)
+
+	 # --with-priv-spec=[1p9p1|1p10|1p11].
+	AC_MSG_CHECKING(for default configuration of --with-priv-spec)
+	if test "x${with_priv_spec}" != x; then
+	  AC_DEFINE_UNQUOTED(DEFAULT_PRIV_SPEC, "$with_priv_spec",
+			     [Define default value for -mpriv-spec])
+	fi
+	AC_MSG_RESULT($with_priv_spec)
 	;;
 
       rl78)
diff --git a/gas/testsuite/gas/riscv/priv-reg-fail-fext.d b/gas/testsuite/gas/riscv/priv-reg-fail-fext.d
index da53566..0033e3c 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=1p11
 #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..d3b1bad 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 version `1p11'
+.*Warning: Invalid CSR `sbadaddr' for the privilege version `1p11'
+.*Warning: Invalid CSR `sptbr' for the privilege version `1p11'
+.*Warning: Invalid CSR `mbadaddr' for the privilege version `1p11'
+.*Warning: Invalid CSR `mucounteren' for the privilege version `1p11'
+.*Warning: Invalid CSR `dscratch' for the privilege version `1p11'
+.*Warning: Invalid CSR `hstatus' for the privilege version `1p11'
+.*Warning: Invalid CSR `hedeleg' for the privilege version `1p11'
+.*Warning: Invalid CSR `hideleg' for the privilege version `1p11'
+.*Warning: Invalid CSR `hie' for the privilege version `1p11'
+.*Warning: Invalid CSR `htvec' for the privilege version `1p11'
+.*Warning: Invalid CSR `hscratch' for the privilege version `1p11'
+.*Warning: Invalid CSR `hepc' for the privilege version `1p11'
+.*Warning: Invalid CSR `hcause' for the privilege version `1p11'
+.*Warning: Invalid CSR `hbadaddr' for the privilege version `1p11'
+.*Warning: Invalid CSR `hip' for the privilege version `1p11'
+.*Warning: Invalid CSR `mbase' for the privilege version `1p11'
+.*Warning: Invalid CSR `mbound' for the privilege version `1p11'
+.*Warning: Invalid CSR `mibase' for the privilege version `1p11'
+.*Warning: Invalid CSR `mibound' for the privilege version `1p11'
+.*Warning: Invalid CSR `mdbase' for the privilege version `1p11'
+.*Warning: Invalid CSR `mdbound' for the privilege version `1p11'
+.*Warning: Invalid CSR `mscounteren' for the privilege version `1p11'
+.*Warning: Invalid CSR `mhcounteren' for the privilege version `1p11'
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..bbf83b5 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=1p11
 #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..e8355f1 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 version `1p11'
+.*Warning: Invalid CSR `sbadaddr' for the privilege version `1p11'
+.*Warning: Invalid CSR `sptbr' for the privilege version `1p11'
+.*Warning: Invalid CSR `mbadaddr' for the privilege version `1p11'
+.*Warning: Invalid CSR `mucounteren' for the privilege version `1p11'
+.*Warning: Invalid CSR `dscratch' for the privilege version `1p11'
+.*Warning: Invalid CSR `hstatus' for the privilege version `1p11'
+.*Warning: Invalid CSR `hedeleg' for the privilege version `1p11'
+.*Warning: Invalid CSR `hideleg' for the privilege version `1p11'
+.*Warning: Invalid CSR `hie' for the privilege version `1p11'
+.*Warning: Invalid CSR `htvec' for the privilege version `1p11'
+.*Warning: Invalid CSR `hscratch' for the privilege version `1p11'
+.*Warning: Invalid CSR `hepc' for the privilege version `1p11'
+.*Warning: Invalid CSR `hcause' for the privilege version `1p11'
+.*Warning: Invalid CSR `hbadaddr' for the privilege version `1p11'
+.*Warning: Invalid CSR `hip' for the privilege version `1p11'
+.*Warning: Invalid CSR `mbase' for the privilege version `1p11'
+.*Warning: Invalid CSR `mbound' for the privilege version `1p11'
+.*Warning: Invalid CSR `mibase' for the privilege version `1p11'
+.*Warning: Invalid CSR `mibound' for the privilege version `1p11'
+.*Warning: Invalid CSR `mdbase' for the privilege version `1p11'
+.*Warning: Invalid CSR `mdbound' for the privilege version `1p11'
+.*Warning: Invalid CSR `mscounteren' for the privilege version `1p11'
+.*Warning: Invalid CSR `mhcounteren' for the privilege version `1p11'
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..a0b88cf 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=1p11
 #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..5e96a85 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 version `1p11'
+.*Warning: Invalid CSR `sbadaddr' for the privilege version `1p11'
+.*Warning: Invalid CSR `sptbr' for the privilege version `1p11'
+.*Warning: Invalid CSR `mbadaddr' for the privilege version `1p11'
+.*Warning: Invalid CSR `mucounteren' for the privilege version `1p11'
+.*Warning: Invalid CSR `dscratch' for the privilege version `1p11'
+.*Warning: Invalid CSR `hstatus' for the privilege version `1p11'
+.*Warning: Invalid CSR `hedeleg' for the privilege version `1p11'
+.*Warning: Invalid CSR `hideleg' for the privilege version `1p11'
+.*Warning: Invalid CSR `hie' for the privilege version `1p11'
+.*Warning: Invalid CSR `htvec' for the privilege version `1p11'
+.*Warning: Invalid CSR `hscratch' for the privilege version `1p11'
+.*Warning: Invalid CSR `hepc' for the privilege version `1p11'
+.*Warning: Invalid CSR `hcause' for the privilege version `1p11'
+.*Warning: Invalid CSR `hbadaddr' for the privilege version `1p11'
+.*Warning: Invalid CSR `hip' for the privilege version `1p11'
+.*Warning: Invalid CSR `mbase' for the privilege version `1p11'
+.*Warning: Invalid CSR `mbound' for the privilege version `1p11'
+.*Warning: Invalid CSR `mibase' for the privilege version `1p11'
+.*Warning: Invalid CSR `mibound' for the privilege version `1p11'
+.*Warning: Invalid CSR `mdbase' for the privilege version `1p11'
+.*Warning: Invalid CSR `mdbound' for the privilege version `1p11'
+.*Warning: Invalid CSR `mscounteren' for the privilege version `1p11'
+.*Warning: Invalid CSR `mhcounteren' for the privilege version `1p11'
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..d7a788a
--- /dev/null
+++ b/gas/testsuite/gas/riscv/priv-reg-fail-version-1p10.d
@@ -0,0 +1,3 @@ 
+#as: -march=rv32if -mcsr-check -mpriv-spec=1p10
+#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..f532962
--- /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 version `1p10'
+.*Warning: Invalid CSR `dscratch0' for the privilege version `1p10'
+.*Warning: Invalid CSR `dscratch1' for the privilege version `1p10'
+.*Warning: Invalid CSR `ubadaddr' for the privilege version `1p10'
+.*Warning: Invalid CSR `sbadaddr' for the privilege version `1p10'
+.*Warning: Invalid CSR `sptbr' for the privilege version `1p10'
+.*Warning: Invalid CSR `mbadaddr' for the privilege version `1p10'
+.*Warning: Invalid CSR `mucounteren' for the privilege version `1p10'
+.*Warning: Invalid CSR `hstatus' for the privilege version `1p10'
+.*Warning: Invalid CSR `hedeleg' for the privilege version `1p10'
+.*Warning: Invalid CSR `hideleg' for the privilege version `1p10'
+.*Warning: Invalid CSR `hie' for the privilege version `1p10'
+.*Warning: Invalid CSR `htvec' for the privilege version `1p10'
+.*Warning: Invalid CSR `hscratch' for the privilege version `1p10'
+.*Warning: Invalid CSR `hepc' for the privilege version `1p10'
+.*Warning: Invalid CSR `hcause' for the privilege version `1p10'
+.*Warning: Invalid CSR `hbadaddr' for the privilege version `1p10'
+.*Warning: Invalid CSR `hip' for the privilege version `1p10'
+.*Warning: Invalid CSR `mbase' for the privilege version `1p10'
+.*Warning: Invalid CSR `mbound' for the privilege version `1p10'
+.*Warning: Invalid CSR `mibase' for the privilege version `1p10'
+.*Warning: Invalid CSR `mibound' for the privilege version `1p10'
+.*Warning: Invalid CSR `mdbase' for the privilege version `1p10'
+.*Warning: Invalid CSR `mdbound' for the privilege version `1p10'
+.*Warning: Invalid CSR `mscounteren' for the privilege version `1p10'
+.*Warning: Invalid CSR `mhcounteren' for the privilege version `1p10'
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..2830c83
--- /dev/null
+++ b/gas/testsuite/gas/riscv/priv-reg-fail-version-1p11.d
@@ -0,0 +1,3 @@ 
+#as: -march=rv32if -mcsr-check -mpriv-spec=1p11
+#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..252f96a
--- /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 version `1p11'
+.*Warning: Invalid CSR `sbadaddr' for the privilege version `1p11'
+.*Warning: Invalid CSR `sptbr' for the privilege version `1p11'
+.*Warning: Invalid CSR `mbadaddr' for the privilege version `1p11'
+.*Warning: Invalid CSR `mucounteren' for the privilege version `1p11'
+.*Warning: Invalid CSR `dscratch' for the privilege version `1p11'
+.*Warning: Invalid CSR `hstatus' for the privilege version `1p11'
+.*Warning: Invalid CSR `hedeleg' for the privilege version `1p11'
+.*Warning: Invalid CSR `hideleg' for the privilege version `1p11'
+.*Warning: Invalid CSR `hie' for the privilege version `1p11'
+.*Warning: Invalid CSR `htvec' for the privilege version `1p11'
+.*Warning: Invalid CSR `hscratch' for the privilege version `1p11'
+.*Warning: Invalid CSR `hepc' for the privilege version `1p11'
+.*Warning: Invalid CSR `hcause' for the privilege version `1p11'
+.*Warning: Invalid CSR `hbadaddr' for the privilege version `1p11'
+.*Warning: Invalid CSR `hip' for the privilege version `1p11'
+.*Warning: Invalid CSR `mbase' for the privilege version `1p11'
+.*Warning: Invalid CSR `mbound' for the privilege version `1p11'
+.*Warning: Invalid CSR `mibase' for the privilege version `1p11'
+.*Warning: Invalid CSR `mibound' for the privilege version `1p11'
+.*Warning: Invalid CSR `mdbase' for the privilege version `1p11'
+.*Warning: Invalid CSR `mdbound' for the privilege version `1p11'
+.*Warning: Invalid CSR `mscounteren' for the privilege version `1p11'
+.*Warning: Invalid CSR `mhcounteren' for the privilege version `1p11'
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..70c405f
--- /dev/null
+++ b/gas/testsuite/gas/riscv/priv-reg-fail-version-1p9.d
@@ -0,0 +1,3 @@ 
+#as: -march=rv32if -mcsr-check -mpriv-spec=1p9
+#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..92e1463
--- /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 version `1p9'
+.*Warning: Invalid CSR `scounteren' for the privilege version `1p9'
+.*Warning: Invalid CSR `stval' for the privilege version `1p9'
+.*Warning: Invalid CSR `satp' for the privilege version `1p9'
+.*Warning: Invalid CSR `mcounteren' for the privilege version `1p9'
+.*Warning: Invalid CSR `mtval' for the privilege version `1p9'
+.*Warning: Invalid CSR `pmpcfg0' for the privilege version `1p9'
+.*Warning: Invalid CSR `pmpcfg1' for the privilege version `1p9'
+.*Warning: Invalid CSR `pmpcfg2' for the privilege version `1p9'
+.*Warning: Invalid CSR `pmpcfg3' for the privilege version `1p9'
+.*Warning: Invalid CSR `pmpaddr0' for the privilege version `1p9'
+.*Warning: Invalid CSR `pmpaddr1' for the privilege version `1p9'
+.*Warning: Invalid CSR `pmpaddr2' for the privilege version `1p9'
+.*Warning: Invalid CSR `pmpaddr3' for the privilege version `1p9'
+.*Warning: Invalid CSR `pmpaddr4' for the privilege version `1p9'
+.*Warning: Invalid CSR `pmpaddr5' for the privilege version `1p9'
+.*Warning: Invalid CSR `pmpaddr6' for the privilege version `1p9'
+.*Warning: Invalid CSR `pmpaddr7' for the privilege version `1p9'
+.*Warning: Invalid CSR `pmpaddr8' for the privilege version `1p9'
+.*Warning: Invalid CSR `pmpaddr9' for the privilege version `1p9'
+.*Warning: Invalid CSR `pmpaddr10' for the privilege version `1p9'
+.*Warning: Invalid CSR `pmpaddr11' for the privilege version `1p9'
+.*Warning: Invalid CSR `pmpaddr12' for the privilege version `1p9'
+.*Warning: Invalid CSR `pmpaddr13' for the privilege version `1p9'
+.*Warning: Invalid CSR `pmpaddr14' for the privilege version `1p9'
+.*Warning: Invalid CSR `pmpaddr15' for the privilege version `1p9'
+.*Warning: Invalid CSR `mcountinhibit' for the privilege version `1p9'
+.*Warning: Invalid CSR `dscratch0' for the privilege version `1p9'
+.*Warning: Invalid CSR `dscratch1' for the privilege version `1p9'
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..2bd4bbf
--- /dev/null
+++ b/gas/testsuite/gas/riscv/priv-reg-fail-version-1p9p1.d
@@ -0,0 +1,3 @@ 
+#as: -march=rv32if -mcsr-check -mpriv-spec=1p9p1
+#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..6cde0b3
--- /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 version `1p9p1'
+.*Warning: Invalid CSR `scounteren' for the privilege version `1p9p1'
+.*Warning: Invalid CSR `stval' for the privilege version `1p9p1'
+.*Warning: Invalid CSR `satp' for the privilege version `1p9p1'
+.*Warning: Invalid CSR `mcounteren' for the privilege version `1p9p1'
+.*Warning: Invalid CSR `mtval' for the privilege version `1p9p1'
+.*Warning: Invalid CSR `pmpcfg0' for the privilege version `1p9p1'
+.*Warning: Invalid CSR `pmpcfg1' for the privilege version `1p9p1'
+.*Warning: Invalid CSR `pmpcfg2' for the privilege version `1p9p1'
+.*Warning: Invalid CSR `pmpcfg3' for the privilege version `1p9p1'
+.*Warning: Invalid CSR `pmpaddr0' for the privilege version `1p9p1'
+.*Warning: Invalid CSR `pmpaddr1' for the privilege version `1p9p1'
+.*Warning: Invalid CSR `pmpaddr2' for the privilege version `1p9p1'
+.*Warning: Invalid CSR `pmpaddr3' for the privilege version `1p9p1'
+.*Warning: Invalid CSR `pmpaddr4' for the privilege version `1p9p1'
+.*Warning: Invalid CSR `pmpaddr5' for the privilege version `1p9p1'
+.*Warning: Invalid CSR `pmpaddr6' for the privilege version `1p9p1'
+.*Warning: Invalid CSR `pmpaddr7' for the privilege version `1p9p1'
+.*Warning: Invalid CSR `pmpaddr8' for the privilege version `1p9p1'
+.*Warning: Invalid CSR `pmpaddr9' for the privilege version `1p9p1'
+.*Warning: Invalid CSR `pmpaddr10' for the privilege version `1p9p1'
+.*Warning: Invalid CSR `pmpaddr11' for the privilege version `1p9p1'
+.*Warning: Invalid CSR `pmpaddr12' for the privilege version `1p9p1'
+.*Warning: Invalid CSR `pmpaddr13' for the privilege version `1p9p1'
+.*Warning: Invalid CSR `pmpaddr14' for the privilege version `1p9p1'
+.*Warning: Invalid CSR `pmpaddr15' for the privilege version `1p9p1'
+.*Warning: Invalid CSR `mcountinhibit' for the privilege version `1p9p1'
+.*Warning: Invalid CSR `dscratch0' for the privilege version `1p9p1'
+.*Warning: Invalid CSR `dscratch1' for the privilege version `1p9p1'
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..ab11c31 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, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(uie, CSR_UIE, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(utvec, CSR_UTVEC, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(uscratch, CSR_USCRATCH, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(uepc, CSR_UEPC, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(ucause, CSR_UCAUSE, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(utval, CSR_UTVAL, CSR_CLASS_I, CSR_CLASS_V1P10, CSR_CLASS_VDRAFT)
+DECLARE_CSR(uip, CSR_UIP, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(fflags, CSR_FFLAGS, CSR_CLASS_F, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(frm, CSR_FRM, CSR_CLASS_F, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(fcsr, CSR_FCSR, CSR_CLASS_F, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(cycle, CSR_CYCLE, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(time, CSR_TIME, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(instret, CSR_INSTRET, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(hpmcounter3, CSR_HPMCOUNTER3, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(hpmcounter4, CSR_HPMCOUNTER4, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(hpmcounter5, CSR_HPMCOUNTER5, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(hpmcounter6, CSR_HPMCOUNTER6, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(hpmcounter7, CSR_HPMCOUNTER7, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(hpmcounter8, CSR_HPMCOUNTER8, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(hpmcounter9, CSR_HPMCOUNTER9, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(hpmcounter10, CSR_HPMCOUNTER10, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(hpmcounter11, CSR_HPMCOUNTER11, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(hpmcounter12, CSR_HPMCOUNTER12, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(hpmcounter13, CSR_HPMCOUNTER13, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(hpmcounter14, CSR_HPMCOUNTER14, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(hpmcounter15, CSR_HPMCOUNTER15, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(hpmcounter16, CSR_HPMCOUNTER16, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(hpmcounter17, CSR_HPMCOUNTER17, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(hpmcounter18, CSR_HPMCOUNTER18, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(hpmcounter19, CSR_HPMCOUNTER19, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(hpmcounter20, CSR_HPMCOUNTER20, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(hpmcounter21, CSR_HPMCOUNTER21, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(hpmcounter22, CSR_HPMCOUNTER22, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(hpmcounter23, CSR_HPMCOUNTER23, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(hpmcounter24, CSR_HPMCOUNTER24, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(hpmcounter25, CSR_HPMCOUNTER25, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(hpmcounter26, CSR_HPMCOUNTER26, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(hpmcounter27, CSR_HPMCOUNTER27, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(hpmcounter28, CSR_HPMCOUNTER28, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(hpmcounter29, CSR_HPMCOUNTER29, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(hpmcounter30, CSR_HPMCOUNTER30, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(hpmcounter31, CSR_HPMCOUNTER31, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(cycleh, CSR_CYCLEH, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(timeh, CSR_TIMEH, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(instreth, CSR_INSTRETH, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(hpmcounter3h, CSR_HPMCOUNTER3H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(hpmcounter4h, CSR_HPMCOUNTER4H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(hpmcounter5h, CSR_HPMCOUNTER5H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(hpmcounter6h, CSR_HPMCOUNTER6H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(hpmcounter7h, CSR_HPMCOUNTER7H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(hpmcounter8h, CSR_HPMCOUNTER8H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(hpmcounter9h, CSR_HPMCOUNTER9H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(hpmcounter10h, CSR_HPMCOUNTER10H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(hpmcounter11h, CSR_HPMCOUNTER11H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(hpmcounter12h, CSR_HPMCOUNTER12H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(hpmcounter13h, CSR_HPMCOUNTER13H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(hpmcounter14h, CSR_HPMCOUNTER14H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(hpmcounter15h, CSR_HPMCOUNTER15H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(hpmcounter16h, CSR_HPMCOUNTER16H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(hpmcounter17h, CSR_HPMCOUNTER17H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(hpmcounter18h, CSR_HPMCOUNTER18H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(hpmcounter19h, CSR_HPMCOUNTER19H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(hpmcounter20h, CSR_HPMCOUNTER20H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(hpmcounter21h, CSR_HPMCOUNTER21H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(hpmcounter22h, CSR_HPMCOUNTER22H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(hpmcounter23h, CSR_HPMCOUNTER23H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(hpmcounter24h, CSR_HPMCOUNTER24H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(hpmcounter25h, CSR_HPMCOUNTER25H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(hpmcounter26h, CSR_HPMCOUNTER26H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(hpmcounter27h, CSR_HPMCOUNTER27H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(hpmcounter28h, CSR_HPMCOUNTER28H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(hpmcounter29h, CSR_HPMCOUNTER29H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(hpmcounter30h, CSR_HPMCOUNTER30H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(hpmcounter31h, CSR_HPMCOUNTER31H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(sstatus, CSR_SSTATUS, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(sedeleg, CSR_SEDELEG, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(sideleg, CSR_SIDELEG, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(sie, CSR_SIE, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(stvec, CSR_STVEC, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(scounteren, CSR_SCOUNTEREN, CSR_CLASS_I, CSR_CLASS_V1P10, CSR_CLASS_VDRAFT)
+DECLARE_CSR(sscratch, CSR_SSCRATCH, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(sepc, CSR_SEPC, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(scause, CSR_SCAUSE, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(stval, CSR_STVAL, CSR_CLASS_I, CSR_CLASS_V1P10, CSR_CLASS_VDRAFT)
+DECLARE_CSR(sip, CSR_SIP, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(satp, CSR_SATP, CSR_CLASS_I, CSR_CLASS_V1P10, CSR_CLASS_VDRAFT)
+DECLARE_CSR(mvendorid, CSR_MVENDORID, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(marchid, CSR_MARCHID, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(mimpid, CSR_MIMPID, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(mhartid, CSR_MHARTID, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(mstatus, CSR_MSTATUS, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(misa, CSR_MISA, CSR_CLASS_I, CSR_CLASS_V1P9P1, CSR_CLASS_VDRAFT)
+DECLARE_CSR(medeleg, CSR_MEDELEG, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(mideleg, CSR_MIDELEG, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(mie, CSR_MIE, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(mtvec, CSR_MTVEC, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(mcounteren, CSR_MCOUNTEREN, CSR_CLASS_I, CSR_CLASS_V1P10, CSR_CLASS_VDRAFT)
+DECLARE_CSR(mscratch, CSR_MSCRATCH, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(mepc, CSR_MEPC, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(mcause, CSR_MCAUSE, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(mtval, CSR_MTVAL, CSR_CLASS_I, CSR_CLASS_V1P10, CSR_CLASS_VDRAFT)
+DECLARE_CSR(mip, CSR_MIP, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(pmpcfg0, CSR_PMPCFG0, CSR_CLASS_I, CSR_CLASS_V1P10, CSR_CLASS_VDRAFT)
+DECLARE_CSR(pmpcfg1, CSR_PMPCFG1, CSR_CLASS_I_32, CSR_CLASS_V1P10, CSR_CLASS_VDRAFT)
+DECLARE_CSR(pmpcfg2, CSR_PMPCFG2, CSR_CLASS_I, CSR_CLASS_V1P10, CSR_CLASS_VDRAFT)
+DECLARE_CSR(pmpcfg3, CSR_PMPCFG3, CSR_CLASS_I_32, CSR_CLASS_V1P10, CSR_CLASS_VDRAFT)
+DECLARE_CSR(pmpaddr0, CSR_PMPADDR0, CSR_CLASS_I, CSR_CLASS_V1P10, CSR_CLASS_VDRAFT)
+DECLARE_CSR(pmpaddr1, CSR_PMPADDR1, CSR_CLASS_I, CSR_CLASS_V1P10, CSR_CLASS_VDRAFT)
+DECLARE_CSR(pmpaddr2, CSR_PMPADDR2, CSR_CLASS_I, CSR_CLASS_V1P10, CSR_CLASS_VDRAFT)
+DECLARE_CSR(pmpaddr3, CSR_PMPADDR3, CSR_CLASS_I, CSR_CLASS_V1P10, CSR_CLASS_VDRAFT)
+DECLARE_CSR(pmpaddr4, CSR_PMPADDR4, CSR_CLASS_I, CSR_CLASS_V1P10, CSR_CLASS_VDRAFT)
+DECLARE_CSR(pmpaddr5, CSR_PMPADDR5, CSR_CLASS_I, CSR_CLASS_V1P10, CSR_CLASS_VDRAFT)
+DECLARE_CSR(pmpaddr6, CSR_PMPADDR6, CSR_CLASS_I, CSR_CLASS_V1P10, CSR_CLASS_VDRAFT)
+DECLARE_CSR(pmpaddr7, CSR_PMPADDR7, CSR_CLASS_I, CSR_CLASS_V1P10, CSR_CLASS_VDRAFT)
+DECLARE_CSR(pmpaddr8, CSR_PMPADDR8, CSR_CLASS_I, CSR_CLASS_V1P10, CSR_CLASS_VDRAFT)
+DECLARE_CSR(pmpaddr9, CSR_PMPADDR9, CSR_CLASS_I, CSR_CLASS_V1P10, CSR_CLASS_VDRAFT)
+DECLARE_CSR(pmpaddr10, CSR_PMPADDR10, CSR_CLASS_I, CSR_CLASS_V1P10, CSR_CLASS_VDRAFT)
+DECLARE_CSR(pmpaddr11, CSR_PMPADDR11, CSR_CLASS_I, CSR_CLASS_V1P10, CSR_CLASS_VDRAFT)
+DECLARE_CSR(pmpaddr12, CSR_PMPADDR12, CSR_CLASS_I, CSR_CLASS_V1P10, CSR_CLASS_VDRAFT)
+DECLARE_CSR(pmpaddr13, CSR_PMPADDR13, CSR_CLASS_I, CSR_CLASS_V1P10, CSR_CLASS_VDRAFT)
+DECLARE_CSR(pmpaddr14, CSR_PMPADDR14, CSR_CLASS_I, CSR_CLASS_V1P10, CSR_CLASS_VDRAFT)
+DECLARE_CSR(pmpaddr15, CSR_PMPADDR15, CSR_CLASS_I, CSR_CLASS_V1P10, CSR_CLASS_VDRAFT)
+DECLARE_CSR(mcycle, CSR_MCYCLE, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(minstret, CSR_MINSTRET, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(mhpmcounter3, CSR_MHPMCOUNTER3, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(mhpmcounter4, CSR_MHPMCOUNTER4, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(mhpmcounter5, CSR_MHPMCOUNTER5, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(mhpmcounter6, CSR_MHPMCOUNTER6, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(mhpmcounter7, CSR_MHPMCOUNTER7, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(mhpmcounter8, CSR_MHPMCOUNTER8, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(mhpmcounter9, CSR_MHPMCOUNTER9, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(mhpmcounter10, CSR_MHPMCOUNTER10, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(mhpmcounter11, CSR_MHPMCOUNTER11, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(mhpmcounter12, CSR_MHPMCOUNTER12, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(mhpmcounter13, CSR_MHPMCOUNTER13, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(mhpmcounter14, CSR_MHPMCOUNTER14, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(mhpmcounter15, CSR_MHPMCOUNTER15, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(mhpmcounter16, CSR_MHPMCOUNTER16, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(mhpmcounter17, CSR_MHPMCOUNTER17, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(mhpmcounter18, CSR_MHPMCOUNTER18, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(mhpmcounter19, CSR_MHPMCOUNTER19, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(mhpmcounter20, CSR_MHPMCOUNTER20, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(mhpmcounter21, CSR_MHPMCOUNTER21, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(mhpmcounter22, CSR_MHPMCOUNTER22, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(mhpmcounter23, CSR_MHPMCOUNTER23, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(mhpmcounter24, CSR_MHPMCOUNTER24, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(mhpmcounter25, CSR_MHPMCOUNTER25, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(mhpmcounter26, CSR_MHPMCOUNTER26, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(mhpmcounter27, CSR_MHPMCOUNTER27, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(mhpmcounter28, CSR_MHPMCOUNTER28, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(mhpmcounter29, CSR_MHPMCOUNTER29, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(mhpmcounter30, CSR_MHPMCOUNTER30, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(mhpmcounter31, CSR_MHPMCOUNTER31, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(mcycleh, CSR_MCYCLEH, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(minstreth, CSR_MINSTRETH, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(mhpmcounter3h, CSR_MHPMCOUNTER3H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(mhpmcounter4h, CSR_MHPMCOUNTER4H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(mhpmcounter5h, CSR_MHPMCOUNTER5H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(mhpmcounter6h, CSR_MHPMCOUNTER6H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(mhpmcounter7h, CSR_MHPMCOUNTER7H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(mhpmcounter8h, CSR_MHPMCOUNTER8H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(mhpmcounter9h, CSR_MHPMCOUNTER9H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(mhpmcounter10h, CSR_MHPMCOUNTER10H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(mhpmcounter11h, CSR_MHPMCOUNTER11H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(mhpmcounter12h, CSR_MHPMCOUNTER12H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(mhpmcounter13h, CSR_MHPMCOUNTER13H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(mhpmcounter14h, CSR_MHPMCOUNTER14H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(mhpmcounter15h, CSR_MHPMCOUNTER15H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(mhpmcounter16h, CSR_MHPMCOUNTER16H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(mhpmcounter17h, CSR_MHPMCOUNTER17H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(mhpmcounter18h, CSR_MHPMCOUNTER18H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(mhpmcounter19h, CSR_MHPMCOUNTER19H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(mhpmcounter20h, CSR_MHPMCOUNTER20H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(mhpmcounter21h, CSR_MHPMCOUNTER21H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(mhpmcounter22h, CSR_MHPMCOUNTER22H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(mhpmcounter23h, CSR_MHPMCOUNTER23H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(mhpmcounter24h, CSR_MHPMCOUNTER24H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(mhpmcounter25h, CSR_MHPMCOUNTER25H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(mhpmcounter26h, CSR_MHPMCOUNTER26H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(mhpmcounter27h, CSR_MHPMCOUNTER27H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(mhpmcounter28h, CSR_MHPMCOUNTER28H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(mhpmcounter29h, CSR_MHPMCOUNTER29H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(mhpmcounter30h, CSR_MHPMCOUNTER30H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(mhpmcounter31h, CSR_MHPMCOUNTER31H, CSR_CLASS_I_32, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(mcountinhibit, CSR_MCOUNTINHIBIT, CSR_CLASS_I, CSR_CLASS_V1P11, CSR_CLASS_VDRAFT)
+DECLARE_CSR(mhpmevent3, CSR_MHPMEVENT3, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(mhpmevent4, CSR_MHPMEVENT4, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(mhpmevent5, CSR_MHPMEVENT5, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(mhpmevent6, CSR_MHPMEVENT6, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(mhpmevent7, CSR_MHPMEVENT7, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(mhpmevent8, CSR_MHPMEVENT8, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(mhpmevent9, CSR_MHPMEVENT9, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(mhpmevent10, CSR_MHPMEVENT10, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(mhpmevent11, CSR_MHPMEVENT11, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(mhpmevent12, CSR_MHPMEVENT12, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(mhpmevent13, CSR_MHPMEVENT13, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(mhpmevent14, CSR_MHPMEVENT14, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(mhpmevent15, CSR_MHPMEVENT15, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(mhpmevent16, CSR_MHPMEVENT16, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(mhpmevent17, CSR_MHPMEVENT17, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(mhpmevent18, CSR_MHPMEVENT18, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(mhpmevent19, CSR_MHPMEVENT19, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(mhpmevent20, CSR_MHPMEVENT20, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(mhpmevent21, CSR_MHPMEVENT21, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(mhpmevent22, CSR_MHPMEVENT22, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(mhpmevent23, CSR_MHPMEVENT23, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(mhpmevent24, CSR_MHPMEVENT24, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(mhpmevent25, CSR_MHPMEVENT25, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(mhpmevent26, CSR_MHPMEVENT26, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(mhpmevent27, CSR_MHPMEVENT27, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(mhpmevent28, CSR_MHPMEVENT28, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(mhpmevent29, CSR_MHPMEVENT29, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(mhpmevent30, CSR_MHPMEVENT30, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(mhpmevent31, CSR_MHPMEVENT31, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(tselect, CSR_TSELECT, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(tdata1, CSR_TDATA1, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(tdata2, CSR_TDATA2, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(tdata3, CSR_TDATA3, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(dcsr, CSR_DCSR, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(dpc, CSR_DPC, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_VDRAFT)
+DECLARE_CSR(dscratch0, CSR_DSCRATCH0, CSR_CLASS_I, CSR_CLASS_V1P11, CSR_CLASS_VDRAFT)
+DECLARE_CSR(dscratch1, CSR_DSCRATCH1, CSR_CLASS_I, CSR_CLASS_V1P11, CSR_CLASS_VDRAFT)
+DECLARE_CSR(hstatus, CSR_HSTATUS, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_V1P10)
+DECLARE_CSR(hedeleg, CSR_HEDELEG, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_V1P10)
+DECLARE_CSR(hideleg, CSR_HIDELEG, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_V1P10)
+DECLARE_CSR(hie, CSR_HIE, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_V1P10)
+DECLARE_CSR(htvec, CSR_HTVEC, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_V1P10)
+DECLARE_CSR(hscratch, CSR_HSCRATCH, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_V1P10)
+DECLARE_CSR(hepc, CSR_HEPC, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_V1P10)
+DECLARE_CSR(hcause, CSR_HCAUSE, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_V1P10)
+DECLARE_CSR(hbadaddr, CSR_HBADADDR, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_V1P10)
+DECLARE_CSR(hip, CSR_HIP, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_V1P10)
+DECLARE_CSR(mbase, CSR_MBASE, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_V1P10)
+DECLARE_CSR(mbound, CSR_MBOUND, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_V1P10)
+DECLARE_CSR(mibase, CSR_MIBASE, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_V1P10)
+DECLARE_CSR(mibound, CSR_MIBOUND, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_V1P10)
+DECLARE_CSR(mdbase, CSR_MDBASE, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_V1P10)
+DECLARE_CSR(mdbound, CSR_MDBOUND, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_V1P10)
+DECLARE_CSR(mscounteren, CSR_MSCOUNTEREN, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_V1P10)
+DECLARE_CSR(mhcounteren, CSR_MHCOUNTEREN, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_V1P10)
 #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, CSR_CLASS_V1P9, CSR_CLASS_V1P9P1)
+DECLARE_CSR_ALIAS(ubadaddr, CSR_UTVAL, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_V1P10)
+DECLARE_CSR_ALIAS(sbadaddr, CSR_STVAL, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_V1P10)
+DECLARE_CSR_ALIAS(sptbr, CSR_SATP, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_V1P10)
+DECLARE_CSR_ALIAS(mbadaddr, CSR_MTVAL, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_V1P10)
+DECLARE_CSR_ALIAS(mucounteren, CSR_MCOUNTINHIBIT, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_V1P10)
+DECLARE_CSR_ALIAS(dscratch, CSR_DSCRATCH0, CSR_CLASS_I, CSR_CLASS_V1P9, CSR_CLASS_V1P11)
 #endif
 #ifdef DECLARE_CAUSE
 DECLARE_CAUSE("misaligned fetch", CAUSE_MISALIGNED_FETCH)
diff --git a/include/opcode/riscv.h b/include/opcode/riscv.h
index f8b0de3..c36bf69 100644
--- a/include/opcode/riscv.h
+++ b/include/opcode/riscv.h
@@ -24,6 +24,7 @@ 
 #include "riscv-opc.h"
 #include <stdlib.h>
 #include <stdint.h>
+#include "bfd.h"
 
 typedef uint64_t insn_t;
 
@@ -353,6 +354,19 @@  struct riscv_ext_version
   unsigned int minor_version;
 };
 
+/* The current supported privilege versions.  */
+
+enum riscv_csr_vclass
+{
+  CSR_CLASS_VNONE,	/* Default value */
+
+  CSR_CLASS_V1P9,       /* v1.9 */
+  CSR_CLASS_V1P9P1,     /* v1.9.1 */
+  CSR_CLASS_V1P10,      /* v1.10 */
+  CSR_CLASS_V1P11,      /* v1.11 */
+  CSR_CLASS_VDRAFT
+};
+
 /* Instruction is a simple alias (e.g. "mv" for "addi").  */
 #define	INSN_ALIAS		0x00000001
 
@@ -432,4 +446,9 @@  extern const struct riscv_opcode riscv_opcodes[];
 extern const struct riscv_opcode riscv_insn_types[];
 extern const struct riscv_ext_version riscv_ext_version_table[];
 
+extern bfd_boolean
+riscv_get_priv_version_class (const char *, enum riscv_csr_vclass *);
+extern const char *
+riscv_get_priv_version_name (enum riscv_csr_vclass);
+
 #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 7b885bf..cfefd8e 100644
--- a/opcodes/riscv-opc.c
+++ b/opcodes/riscv-opc.c
@@ -937,3 +937,58 @@  const struct riscv_ext_version riscv_ext_version_table[] =
 /* Terminate the list.  */
 {NULL, NULL, 0, 0}
 };
+
+struct priv_version_t
+{
+  const char *name;
+  enum riscv_csr_vclass vclass;
+};
+
+/* List for all supported CSR versions.  */
+static const struct priv_version_t priv_versions[] =
+{
+  {"1p9", CSR_CLASS_V1P9},
+  {"1p9p1", CSR_CLASS_V1P9P1},
+  {"1p10", CSR_CLASS_V1P10},
+  {"1p11", CSR_CLASS_V1P11},
+
+/* Terminate the list.  */
+  {NULL, 0}
+};
+
+/* Get the corresponding CSR version class by giving a privilege
+   version string.  */
+
+bfd_boolean
+riscv_get_priv_version_class (const char *s,
+			      enum riscv_csr_vclass *class)
+{
+  const struct priv_version_t *version;
+
+  if (s == NULL)
+    return FALSE;
+
+  for (version = &priv_versions[0]; version->name != NULL; ++version)
+    if (strcmp (version->name, s) == 0)
+      {
+	*class = version->vclass;
+	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_version_name (enum riscv_csr_vclass class)
+{
+  const struct priv_version_t *version;
+  for (version = &priv_versions[0]; version->name != NULL; ++version)
+    if (class == version->vclass)
+      return version->name;
+  /* This shouldn't happen.  */
+  return NULL;
+}