public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* [RFC PATCH 0/2] RISC-V: Add 'Zicntr' and 'Zihpm' support with compatibility measures
@ 2023-08-08  3:17 Tsukasa OI
  2023-08-08  3:17 ` [RFC PATCH 1/2] RISC-V: Base for complex extension implications Tsukasa OI
                   ` (3 more replies)
  0 siblings, 4 replies; 10+ messages in thread
From: Tsukasa OI @ 2023-08-08  3:17 UTC (permalink / raw)
  To: Tsukasa OI, Palmer Dabbelt, Andrew Waterman, Jim Wilson,
	Nelson Chu, Kito Cheng
  Cc: binutils

Hi,

The role of this patch set is very simple: implement recently ratified
'Zicntr' (basic counters and timers) and 'Zihpm' (hardware performance
counters) extensions, formerly a part of the 'I' extension, version 2.0.

Since some draft extensions depend on those extensions, implementing counter
extensions (as a part of data structure) is becoming mandatory.

However, we need to be *very* careful to the implementation.  Because
CSRs and pseudoinstructions for those extensions were a part of 'I' and
more importantly, the first version which separated counters from the 'I'
extension, did not give counters extension names.  So, we needed to
implement such CSRs and pseudoinstructions as a part of 'I' (continuously).


Not breaking the compatibility here is vital (the only exception might be
the new ratified ISA after version 20191213).  So, I implemented those
extensions not to break anything as possible.

The basic idea is, an extension (riscv_subset_t) with an unknown version is
not emitted to an object file (ELF attributes, mapping symbols etc...).

The default mode for existing ISAs is the compatibility mode (Option 1).


[Option 1: Compatibility Mode]

In the compatibility mode (as default),

1.  'I' implies 'Zicntr' and 'Zihpm'.
2.  'Zicntr' and 'Zihpm' DO NOT imply 'Zicsr'.
3.  'Zicntr' and 'Zihpm' don't have version information.

(2.) is the point.  The ratified document says 'Zicntr' and 'Zihpm' depend
on the 'Zicsr' extension but if we do it unconditionally, that would mean
that the 'I' extension indirectly depends on 'Zicsr' (because of 1.), making
a difference from the ratified 'I' extension version 2.1.  In order to keep
the compatibility, making 'Zicntr' and 'Zihpm' against the documentation was
(sadly) necessary.

In the compatibility mode, code like:

> riscv_subset_supports(&rps, "zicntr")

will return true.  Because, even that the version information is missing,
the 'Zicntr' extension exists in the riscv_subset_list_t.  But an extension
with no version means, it will not be a part of the architectural string
emitted as a part of an object file.


[Option 2: Compliant Mode]

We can continue this forever but we have another option.  Break false
dependency when a new ISA (with its version) is ratified and in that time,
require those extensions separately like -march=..._zicntr_zihpm.

In the compliant mode:

1.  'I' DOES NOT imply 'Zicntr' and 'Zihpm'.
2.  'Zicntr' and 'Zihpm' DO imply 'Zicsr'.
3.  'Zicntr' and 'Zihpm' have its version information
    (ratified version 2.0 or possibly a later version)

Note that (1.) and (2.) are very opposite from the compatibility mode.

In this mode, it is compliant to the specification completely.




[Implementing an Option on future ISAs]

Assume that we have a new ISA specification class, ISA_SPEC_CLASS_2024XXXX.
We can choose which option to implement as follows.


[Option 1: Compatibility Mode]

1. Change the contents of check_implicit_compat_counter_from_i.

>  /* Old.  */
>  return *rps->isa_spec <= ISA_SPEC_CLASS_20191213;

>  /* New.  */
>  return *rps->isa_spec <= ISA_SPEC_CLASS_2024XXXX;

Note that the reason we are looking for the ISA specification (instead of
the version of the 'I' extension) is, the 'I' extension version 2.1 is
unlikely to change even when the new ISA specification is ratified.
I assume that two behaviors (option 1 and 2) share the same 'I' version 2.1.

If the version of the 'I' extension changes (even if no *actual* changes
are made) in the new unprivileged ISA version, that would be a bit simpler.

2. Add following entries to riscv_supported_std_z_ext.

Make sure that they don't have the version number.

>  /* ...  */
>  {"zicntr",		ISA_SPEC_CLASS_2024XXXX,	RISCV_UNKNOWN_VERSION, RISCV_UNKNOWN_VERSION,  0 }, /* Compat.  */
>  /* ...  */
>  {"zihpm",		ISA_SPEC_CLASS_2024XXXX,	RISCV_UNKNOWN_VERSION, RISCV_UNKNOWN_VERSION,  0 }, /* Compat.  */


[Option 2: Compliant Mode]

1. DO NOT change the contents of check_implicit_compat_counter_from_i.
2. Add following entries to riscv_supported_std_z_ext.

Make sure that they DO have the version number.

>  /* ...  */
>  {"zicntr",		ISA_SPEC_CLASS_2024XXXX,	2, 0,  0 },
>  /* ...  */
>  {"zihpm",		ISA_SPEC_CLASS_2024XXXX,	2, 0,  0 },

...and for compatibility, we need to slightly modify riscv-dis.c.  The
disassembler defaults to the latest non-draft ISA and there's currently no
ways to change it.  We need to make changes to riscv-dis.c by either:

1.  Entering special compatibility mode (even on the latest ISA, enable
    'Zicntr' extension ['Zihpm' is not necessary on the disassembler]) or
2.  Enabling to change the ISA version from disassembler options.
    Like my long proposed disassembler changes: adding overridable "arch"
    and "priv-spec" options, we have an option to change the ISA using the
    disassembler option.
    <https://github.com/a4lg/binutils-gdb/wiki/riscv_dis_arch_priv_spec>


In either case, this patch set leaves both options to implement yet
supporting 'Zicntr' and 'Zihpm' extensions directly.




Along with those changes (in PATCH 2), PATCH 1 makes possible to consider
implication by using *more* information than before.  This is practically
the same as:
<https://sourceware.org/pipermail/binutils/2023-July/128715.html>,
a patch to demonstrate how to implement the 'Zce' superset extension
('Zcf' must be implied by 'Zce' ONLY IF 'F' is ALSO enabled).

The only difference is a minor type change as follows (to enable using
the "riscv_subset_supports" function).

*   Before: "const riscv_parse_subset_t *"
*   After:  "      riscv_parse_subset_t *"




Is there any other options?  Should I simplify the patch assuming we choose
the compatibility mode (Option 1) forever?

In any case, I would like to hear your thoughts.

Thanks,
Tsukasa




Tsukasa OI (2):
  RISC-V: Base for complex extension implications
  RISC-V: Add 'Zicntr' and 'Zihpm' support with compatibility measures

 bfd/elfxx-riscv.c                       |  86 +++++--
 gas/config/tc-riscv.c                   |  16 ++
 gas/testsuite/gas/riscv/march-imply-i.s |   8 +
 include/opcode/riscv-opc.h              | 310 ++++++++++++------------
 include/opcode/riscv.h                  |   1 +
 opcodes/riscv-opc.c                     |  12 +-
 6 files changed, 256 insertions(+), 177 deletions(-)


base-commit: d734d43a048b33ee12df2c06c2e782887e9715f6
-- 
2.41.0


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [RFC PATCH 1/2] RISC-V: Base for complex extension implications
  2023-08-08  3:17 [RFC PATCH 0/2] RISC-V: Add 'Zicntr' and 'Zihpm' support with compatibility measures Tsukasa OI
@ 2023-08-08  3:17 ` Tsukasa OI
  2023-08-08  3:17 ` [RFC PATCH 2/2] RISC-V: Add 'Zicntr' and 'Zihpm' support with compatibility measures Tsukasa OI
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 10+ messages in thread
From: Tsukasa OI @ 2023-08-08  3:17 UTC (permalink / raw)
  To: Tsukasa OI, Palmer Dabbelt, Andrew Waterman, Jim Wilson,
	Nelson Chu, Kito Cheng
  Cc: binutils

From: Tsukasa OI <research_trasio@irq.a4lg.com>

Thanks to the commit 48558a5e5471 ("RISC-V: Allow nested implications for
extensions"), we can write complex extension implications in theory.
However, to actually do that, we need to pass more information to
check_func.

For example, we want to imply 'Zcf' from 'F' if and only if the 'Zce'
extension is also enabled and XLEN is 32.  Passing rps is a way to
enable this.

This commit prepares for such complex extension implications.

bfd/ChangeLog:

	* elfxx-riscv.c (struct riscv_implicit_subset) Move around and
	change check_func function prototype.
	(check_implicit_always): New arguments.
	(check_implicit_for_i): Likewise.
	(riscv_implicit_subsets): Add comment for this variable.
	(riscv_parse_add_implicit_subsets): Call check_func with
	new arguments.
---
 bfd/elfxx-riscv.c | 39 ++++++++++++++++++++++++---------------
 1 file changed, 24 insertions(+), 15 deletions(-)

diff --git a/bfd/elfxx-riscv.c b/bfd/elfxx-riscv.c
index ee4598729480..b166e8d9c3c2 100644
--- a/bfd/elfxx-riscv.c
+++ b/bfd/elfxx-riscv.c
@@ -1064,11 +1064,25 @@ riscv_elf_ignore_reloc (bfd *abfd ATTRIBUTE_UNUSED,
   return bfd_reloc_ok;
 }
 
+/* Record all implicit information for the subsets.  */
+
+typedef struct riscv_implicit_subset
+{
+  const char *subset_name;
+  const char *implicit_name;
+  /* A function to determine if we need to add the implicit subset.  */
+  bool (*check_func) (riscv_parse_subset_t *,
+		      const struct riscv_implicit_subset *,
+		      const riscv_subset_t *);
+} riscv_implicit_subset_t;
+
 /* Always add the IMPLICIT for the SUBSET.  */
 
 static bool
-check_implicit_always (const char *implicit ATTRIBUTE_UNUSED,
-		       riscv_subset_t *subset ATTRIBUTE_UNUSED)
+check_implicit_always (riscv_parse_subset_t *rps ATTRIBUTE_UNUSED,
+		       const riscv_implicit_subset_t *implicit
+			   ATTRIBUTE_UNUSED,
+		       const riscv_subset_t *subset ATTRIBUTE_UNUSED)
 {
   return true;
 }
@@ -1076,23 +1090,18 @@ check_implicit_always (const char *implicit ATTRIBUTE_UNUSED,
 /* Add the IMPLICIT only when the version of SUBSET less than 2.1.  */
 
 static bool
-check_implicit_for_i (const char *implicit ATTRIBUTE_UNUSED,
-		      riscv_subset_t *subset)
+check_implicit_for_i (riscv_parse_subset_t *rps ATTRIBUTE_UNUSED,
+		      const riscv_implicit_subset_t *implicit ATTRIBUTE_UNUSED,
+		      const riscv_subset_t *subset)
 {
   return (subset->major_version < 2
 	  || (subset->major_version == 2
 	      && subset->minor_version < 1));
 }
 
-/* Record all implicit information for the subsets.  */
-struct riscv_implicit_subset
-{
-  const char *subset_name;
-  const char *implicit_name;
-  /* A function to determine if we need to add the implicit subset.  */
-  bool (*check_func) (const char *, riscv_subset_t *);
-};
-static struct riscv_implicit_subset riscv_implicit_subsets[] =
+/* All extension implications.  */
+
+static riscv_implicit_subset_t riscv_implicit_subsets[] =
 {
   {"e", "i",		check_implicit_always},
   {"i", "zicsr",	check_implicit_for_i},
@@ -1906,7 +1915,7 @@ riscv_parse_extensions (riscv_parse_subset_t *rps,
 static void
 riscv_parse_add_implicit_subsets (riscv_parse_subset_t *rps)
 {
-  struct riscv_implicit_subset *t = riscv_implicit_subsets;
+  riscv_implicit_subset_t *t = riscv_implicit_subsets;
   bool finished = false;
   while (!finished)
     {
@@ -1918,7 +1927,7 @@ riscv_parse_add_implicit_subsets (riscv_parse_subset_t *rps)
 	  if (riscv_lookup_subset (rps->subset_list, t->subset_name, &subset)
 	      && !riscv_lookup_subset (rps->subset_list, t->implicit_name,
 				       &implicit_subset)
-	      && t->check_func (t->implicit_name, subset))
+	      && t->check_func (rps, t, subset))
 	    {
 	      riscv_parse_add_subset (rps, t->implicit_name,
 				      RISCV_UNKNOWN_VERSION,
-- 
2.41.0


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [RFC PATCH 2/2] RISC-V: Add 'Zicntr' and 'Zihpm' support with compatibility measures
  2023-08-08  3:17 [RFC PATCH 0/2] RISC-V: Add 'Zicntr' and 'Zihpm' support with compatibility measures Tsukasa OI
  2023-08-08  3:17 ` [RFC PATCH 1/2] RISC-V: Base for complex extension implications Tsukasa OI
@ 2023-08-08  3:17 ` Tsukasa OI
  2023-10-19  7:57 ` [PING^1][RFC PATCH 0/2] " Tsukasa OI
  2023-10-21  0:45 ` [PATCH 0/1] " Tsukasa OI
  3 siblings, 0 replies; 10+ messages in thread
From: Tsukasa OI @ 2023-08-08  3:17 UTC (permalink / raw)
  To: Tsukasa OI, Palmer Dabbelt, Andrew Waterman, Jim Wilson,
	Nelson Chu, Kito Cheng
  Cc: binutils

From: Tsukasa OI <research_trasio@irq.a4lg.com>

This commit adds support for 'Zicntr' and 'Zihpm' extensions (version 2.0).

However, because GNU Binutils handled those as a part of 'I' and there was
a time when a ratified specification did split counters from the 'I'
extension without separate extension names.

To preserve maximum compatibility, this commit implements as follows:

*   For RISC-V ISA version 20191213 or less (all current non-draft ones),
    imply counter extensions from 'I' and DO NOT imply the 'Zicsr' extension
    from counter extensions.  We also suppress outputting the existence of
    counter extensions unless the version number is explicitly specified.
*   For future ratified ISAs, leave two options (each require minor edits):
    *   Continue previous behaviors or
    *   DO NOT imply counter extensions from 'I'.  DO imply the 'Zicsr'
        extension from counter extensions.  DO NOT suppress outputting the
        existence of such counter extensions by having a known
        version number (version 2.0 or [though unlikely] later).
        Make small changes to the disassembler to keep compatibility when
        disassembling old files.

bfd/ChangeLog:

	* elfxx-riscv.c (check_implicit_compat_counter_from_i): New function
	for counter compatibility from 'I' to counter extensions.
	(check_implicit_compat_counter_to_zicsr): New function for counter
	compatibility from counter extensions to the 'Zicsr' extension.
	(riscv_implicit_subsets): Add implications related to counter
	extensions with compatibility measures.
	(riscv_supported_std_z_ext): Add 'Zicntr' and 'Zihpm' extensions.
	But make version "unknown" to suppress outputting implicit
	dependencies on older ISAs.
	(riscv_parse_add_subset): Add "zicntr" and "zihpm" to exceptions
	to recognize on older ISAs if there's no version number.
	(riscv_multi_subset_supports): Add support for 'Zicntr'.
	(riscv_multi_subset_supports_ext): Likewise.

gas/ChangeLog:

	* config/tc-riscv.c (enum riscv_csr_class): Add CSR classes for
	'Zicntr' and 'Zihpm' extensions.
	(riscv_csr_address): Add handling for new CSR classes.
	* testsuite/gas/riscv/march-imply-i.s: Add 'Zicntr' instructions.

include/ChangeLog:

	* opcode/riscv-opc.h: Change CSR classes for counter CSRs.
	* opcode/riscv.h (enum riscv_insn_class): Add INSN_CLASS_ZICNTR
	for 'Zicntr' pseudoinstructions.

opcodes/ChangeLog:

	* riscv-opc.c (riscv_opcodes): Recategorize counter
	pseudoinstructions to the 'Zicntr' extension.
---
 bfd/elfxx-riscv.c                       |  49 +++-
 gas/config/tc-riscv.c                   |  16 ++
 gas/testsuite/gas/riscv/march-imply-i.s |   8 +
 include/opcode/riscv-opc.h              | 310 ++++++++++++------------
 include/opcode/riscv.h                  |   1 +
 opcodes/riscv-opc.c                     |  12 +-
 6 files changed, 233 insertions(+), 163 deletions(-)

diff --git a/bfd/elfxx-riscv.c b/bfd/elfxx-riscv.c
index b166e8d9c3c2..ed38fcb37b97 100644
--- a/bfd/elfxx-riscv.c
+++ b/bfd/elfxx-riscv.c
@@ -1099,6 +1099,32 @@ check_implicit_for_i (riscv_parse_subset_t *rps ATTRIBUTE_UNUSED,
 	      && subset->minor_version < 1));
 }
 
+/* Compatibility measure for counters (Zicntr and Zihpm):
+   Do or do not add the IMPLICIT only when the ISA version is
+   less than the border.  */
+
+static bool
+check_implicit_compat_counter_from_i (riscv_parse_subset_t *rps,
+				      const riscv_implicit_subset_t *implicit
+					  ATTRIBUTE_UNUSED,
+				      const riscv_subset_t *subset
+					  ATTRIBUTE_UNUSED)
+{
+  /* When rps->isa_spec is NULL, we don't need to care about implicit
+     extensions because the caller is the linker.  */
+  return rps->isa_spec && *rps->isa_spec <= ISA_SPEC_CLASS_20191213;
+}
+
+static bool
+check_implicit_compat_counter_to_zicsr (riscv_parse_subset_t *rps,
+					const riscv_implicit_subset_t
+					    *implicit,
+					const riscv_subset_t *subset)
+{
+  return (rps->isa_spec
+	  && !check_implicit_compat_counter_from_i (rps, implicit, subset));
+}
+
 /* All extension implications.  */
 
 static riscv_implicit_subset_t riscv_implicit_subsets[] =
@@ -1106,6 +1132,8 @@ static riscv_implicit_subset_t riscv_implicit_subsets[] =
   {"e", "i",		check_implicit_always},
   {"i", "zicsr",	check_implicit_for_i},
   {"i", "zifencei",	check_implicit_for_i},
+  {"i", "zicntr",	check_implicit_compat_counter_from_i},
+  {"i", "zihpm",	check_implicit_compat_counter_from_i},
   {"g", "i",		check_implicit_always},
   {"g", "m",		check_implicit_always},
   {"g", "a",		check_implicit_always},
@@ -1191,6 +1219,8 @@ static riscv_implicit_subset_t riscv_implicit_subsets[] =
   {"zcf", "zca",	check_implicit_always},
   {"zcd", "zca",	check_implicit_always},
   {"zcb", "zca",	check_implicit_always},
+  {"zicntr", "zicsr",	check_implicit_compat_counter_to_zicsr},
+  {"zihpm", "zicsr",	check_implicit_compat_counter_to_zicsr},
   {"smaia", "ssaia",		check_implicit_always},
   {"smstateen", "ssstateen",	check_implicit_always},
   {"smepmp", "zicsr",		check_implicit_always},
@@ -1258,12 +1288,20 @@ static struct riscv_supported_ext riscv_supported_std_z_ext[] =
   {"zicbom",		ISA_SPEC_CLASS_DRAFT,		1, 0,  0 },
   {"zicbop",		ISA_SPEC_CLASS_DRAFT,		1, 0,  0 },
   {"zicboz",		ISA_SPEC_CLASS_DRAFT,		1, 0,  0 },
+  {"zicntr",		ISA_SPEC_CLASS_2P2,		RISCV_UNKNOWN_VERSION, RISCV_UNKNOWN_VERSION,  0 }, /* Compat.  */
+  {"zicntr",		ISA_SPEC_CLASS_20190608,	RISCV_UNKNOWN_VERSION, RISCV_UNKNOWN_VERSION,  0 }, /* Compat.  */
+  {"zicntr",		ISA_SPEC_CLASS_20191213,	RISCV_UNKNOWN_VERSION, RISCV_UNKNOWN_VERSION,  0 }, /* Compat.  */
+  {"zicntr",		ISA_SPEC_CLASS_DRAFT,		2, 0,  0 },
   {"zicond",		ISA_SPEC_CLASS_DRAFT,		1, 0,  0 },
   {"zicsr",		ISA_SPEC_CLASS_20191213,	2, 0,  0 },
   {"zicsr",		ISA_SPEC_CLASS_20190608,	2, 0,  0 },
   {"zifencei",		ISA_SPEC_CLASS_20191213,	2, 0,  0 },
   {"zifencei",		ISA_SPEC_CLASS_20190608,	2, 0,  0 },
   {"zihintpause",	ISA_SPEC_CLASS_DRAFT,		2, 0,  0 },
+  {"zihpm",		ISA_SPEC_CLASS_2P2,		RISCV_UNKNOWN_VERSION, RISCV_UNKNOWN_VERSION,  0 }, /* Compat.  */
+  {"zihpm",		ISA_SPEC_CLASS_20190608,	RISCV_UNKNOWN_VERSION, RISCV_UNKNOWN_VERSION,  0 }, /* Compat.  */
+  {"zihpm",		ISA_SPEC_CLASS_20191213,	RISCV_UNKNOWN_VERSION, RISCV_UNKNOWN_VERSION,  0 }, /* Compat.  */
+  {"zihpm",		ISA_SPEC_CLASS_DRAFT,		2, 0,  0 },
   {"zmmul",		ISA_SPEC_CLASS_DRAFT,		1, 0,  0 },
   {"zawrs",		ISA_SPEC_CLASS_DRAFT,		1, 0,  0 },
   {"zfa",		ISA_SPEC_CLASS_DRAFT,		0, 1,  0 },
@@ -1683,9 +1721,12 @@ riscv_parse_add_subset (riscv_parse_subset_t *rps,
 	rps->error_handler
 	  (_("x ISA extension `%s' must be set with the versions"),
 	   subset);
-      /* Allow old ISA spec can recognize zicsr and zifencei.  */
+      /* Allow old ISA spec (version 2.2) can recognize extensions
+	 effectively split from the base 'I' extension version 2.0.  */
       else if (strcmp (subset, "zicsr") != 0
-	       && strcmp (subset, "zifencei") != 0)
+	       && strcmp (subset, "zifencei") != 0
+	       && strcmp (subset, "zicntr") != 0
+	       && strcmp (subset, "zihpm") != 0)
 	rps->error_handler
 	  (_("cannot find default versions of the ISA extension `%s'"),
 	   subset);
@@ -2395,6 +2436,8 @@ riscv_multi_subset_supports (riscv_parse_subset_t *rps,
       return riscv_subset_supports (rps, "zicbop");
     case INSN_CLASS_ZICBOZ:
       return riscv_subset_supports (rps, "zicboz");
+    case INSN_CLASS_ZICNTR:
+      return riscv_subset_supports (rps, "zicntr");
     case INSN_CLASS_ZICOND:
       return riscv_subset_supports (rps, "zicond");
     case INSN_CLASS_ZICSR:
@@ -2588,6 +2631,8 @@ riscv_multi_subset_supports_ext (riscv_parse_subset_t *rps,
       return "zicbop";
     case INSN_CLASS_ZICBOZ:
       return "zicboz";
+    case INSN_CLASS_ZICNTR:
+      return "zicntr";
     case INSN_CLASS_ZICOND:
       return "zicond";
     case INSN_CLASS_ZICSR:
diff --git a/gas/config/tc-riscv.c b/gas/config/tc-riscv.c
index aaf8b9be64fd..b0bc3febb0fc 100644
--- a/gas/config/tc-riscv.c
+++ b/gas/config/tc-riscv.c
@@ -66,6 +66,10 @@ enum riscv_csr_class
 
   CSR_CLASS_I,
   CSR_CLASS_I_32,	/* rv32 only */
+  CSR_CLASS_ZICNTR,	/* basic hardware perf counter */
+  CSR_CLASS_ZICNTR_32,	/* basic hardware perf counter, rv32 only */
+  CSR_CLASS_ZIHPM,	/* additional hardware perf counter */
+  CSR_CLASS_ZIHPM_32,	/* additional hardware perf counter, rv32 only */
   CSR_CLASS_F,		/* f-ext only */
   CSR_CLASS_ZKR,	/* zkr only */
   CSR_CLASS_V,		/* rvv only */
@@ -1031,6 +1035,18 @@ riscv_csr_address (const char *csr_name,
       need_check_version = true;
       extension = "i";
       break;
+    case CSR_CLASS_ZICNTR_32:
+      is_rv32_only = true;
+      /* Fall through.  */
+    case CSR_CLASS_ZICNTR:
+      extension = "zicntr";
+      break;
+    case CSR_CLASS_ZIHPM_32:
+      is_rv32_only = true;
+      /* Fall through.  */
+    case CSR_CLASS_ZIHPM:
+      extension = "zihpm";
+      break;
     case CSR_CLASS_H_32:
       is_rv32_only = true;
       /* Fall through.  */
diff --git a/gas/testsuite/gas/riscv/march-imply-i.s b/gas/testsuite/gas/riscv/march-imply-i.s
index b65c3c32aa63..a225aaf72ae3 100644
--- a/gas/testsuite/gas/riscv/march-imply-i.s
+++ b/gas/testsuite/gas/riscv/march-imply-i.s
@@ -22,3 +22,11 @@ target:
 
 	# zifencei
 	fence.i
+
+	# zicntr
+	rdcycle		t0
+	rdtime		t0
+	rdinstret	t0
+	rdcycleh	t0
+	rdtimeh		t0
+	rdinstreth	t0
diff --git a/include/opcode/riscv-opc.h b/include/opcode/riscv-opc.h
index 53f5f2005085..d486da4b862c 100644
--- a/include/opcode/riscv-opc.h
+++ b/include/opcode/riscv-opc.h
@@ -3529,70 +3529,70 @@ DECLARE_INSN(vt_maskcn, MATCH_VT_MASKCN, MASK_VT_MASKCN)
 #endif /* DECLARE_INSN */
 #ifdef DECLARE_CSR
 /* Unprivileged Counter/Timers CSRs.  */
-DECLARE_CSR(cycle, CSR_CYCLE, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(time, CSR_TIME, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(instret, CSR_INSTRET, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(hpmcounter3, CSR_HPMCOUNTER3, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(hpmcounter4, CSR_HPMCOUNTER4, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(hpmcounter5, CSR_HPMCOUNTER5, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(hpmcounter6, CSR_HPMCOUNTER6, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(hpmcounter7, CSR_HPMCOUNTER7, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(hpmcounter8, CSR_HPMCOUNTER8, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(hpmcounter9, CSR_HPMCOUNTER9, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(hpmcounter10, CSR_HPMCOUNTER10, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(hpmcounter11, CSR_HPMCOUNTER11, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(hpmcounter12, CSR_HPMCOUNTER12, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(hpmcounter13, CSR_HPMCOUNTER13, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(hpmcounter14, CSR_HPMCOUNTER14, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(hpmcounter15, CSR_HPMCOUNTER15, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(hpmcounter16, CSR_HPMCOUNTER16, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(hpmcounter17, CSR_HPMCOUNTER17, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(hpmcounter18, CSR_HPMCOUNTER18, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(hpmcounter19, CSR_HPMCOUNTER19, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(hpmcounter20, CSR_HPMCOUNTER20, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(hpmcounter21, CSR_HPMCOUNTER21, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(hpmcounter22, CSR_HPMCOUNTER22, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(hpmcounter23, CSR_HPMCOUNTER23, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(hpmcounter24, CSR_HPMCOUNTER24, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(hpmcounter25, CSR_HPMCOUNTER25, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(hpmcounter26, CSR_HPMCOUNTER26, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(hpmcounter27, CSR_HPMCOUNTER27, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(hpmcounter28, CSR_HPMCOUNTER28, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(hpmcounter29, CSR_HPMCOUNTER29, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(hpmcounter30, CSR_HPMCOUNTER30, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(hpmcounter31, CSR_HPMCOUNTER31, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(cycleh, CSR_CYCLEH, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(timeh, CSR_TIMEH, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(instreth, CSR_INSTRETH, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(hpmcounter3h, CSR_HPMCOUNTER3H, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(hpmcounter4h, CSR_HPMCOUNTER4H, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(hpmcounter5h, CSR_HPMCOUNTER5H, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(hpmcounter6h, CSR_HPMCOUNTER6H, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(hpmcounter7h, CSR_HPMCOUNTER7H, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(hpmcounter8h, CSR_HPMCOUNTER8H, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(hpmcounter9h, CSR_HPMCOUNTER9H, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(hpmcounter10h, CSR_HPMCOUNTER10H, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(hpmcounter11h, CSR_HPMCOUNTER11H, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(hpmcounter12h, CSR_HPMCOUNTER12H, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(hpmcounter13h, CSR_HPMCOUNTER13H, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(hpmcounter14h, CSR_HPMCOUNTER14H, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(hpmcounter15h, CSR_HPMCOUNTER15H, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(hpmcounter16h, CSR_HPMCOUNTER16H, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(hpmcounter17h, CSR_HPMCOUNTER17H, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(hpmcounter18h, CSR_HPMCOUNTER18H, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(hpmcounter19h, CSR_HPMCOUNTER19H, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(hpmcounter20h, CSR_HPMCOUNTER20H, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(hpmcounter21h, CSR_HPMCOUNTER21H, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(hpmcounter22h, CSR_HPMCOUNTER22H, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(hpmcounter23h, CSR_HPMCOUNTER23H, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(hpmcounter24h, CSR_HPMCOUNTER24H, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(hpmcounter25h, CSR_HPMCOUNTER25H, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(hpmcounter26h, CSR_HPMCOUNTER26H, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(hpmcounter27h, CSR_HPMCOUNTER27H, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(hpmcounter28h, CSR_HPMCOUNTER28H, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(hpmcounter29h, CSR_HPMCOUNTER29H, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(hpmcounter30h, CSR_HPMCOUNTER30H, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(hpmcounter31h, CSR_HPMCOUNTER31H, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
+DECLARE_CSR(cycle, CSR_CYCLE, CSR_CLASS_ZICNTR, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(time, CSR_TIME, CSR_CLASS_ZICNTR, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(instret, CSR_INSTRET, CSR_CLASS_ZICNTR, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(hpmcounter3, CSR_HPMCOUNTER3, CSR_CLASS_ZIHPM, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(hpmcounter4, CSR_HPMCOUNTER4, CSR_CLASS_ZIHPM, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(hpmcounter5, CSR_HPMCOUNTER5, CSR_CLASS_ZIHPM, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(hpmcounter6, CSR_HPMCOUNTER6, CSR_CLASS_ZIHPM, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(hpmcounter7, CSR_HPMCOUNTER7, CSR_CLASS_ZIHPM, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(hpmcounter8, CSR_HPMCOUNTER8, CSR_CLASS_ZIHPM, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(hpmcounter9, CSR_HPMCOUNTER9, CSR_CLASS_ZIHPM, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(hpmcounter10, CSR_HPMCOUNTER10, CSR_CLASS_ZIHPM, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(hpmcounter11, CSR_HPMCOUNTER11, CSR_CLASS_ZIHPM, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(hpmcounter12, CSR_HPMCOUNTER12, CSR_CLASS_ZIHPM, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(hpmcounter13, CSR_HPMCOUNTER13, CSR_CLASS_ZIHPM, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(hpmcounter14, CSR_HPMCOUNTER14, CSR_CLASS_ZIHPM, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(hpmcounter15, CSR_HPMCOUNTER15, CSR_CLASS_ZIHPM, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(hpmcounter16, CSR_HPMCOUNTER16, CSR_CLASS_ZIHPM, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(hpmcounter17, CSR_HPMCOUNTER17, CSR_CLASS_ZIHPM, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(hpmcounter18, CSR_HPMCOUNTER18, CSR_CLASS_ZIHPM, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(hpmcounter19, CSR_HPMCOUNTER19, CSR_CLASS_ZIHPM, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(hpmcounter20, CSR_HPMCOUNTER20, CSR_CLASS_ZIHPM, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(hpmcounter21, CSR_HPMCOUNTER21, CSR_CLASS_ZIHPM, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(hpmcounter22, CSR_HPMCOUNTER22, CSR_CLASS_ZIHPM, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(hpmcounter23, CSR_HPMCOUNTER23, CSR_CLASS_ZIHPM, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(hpmcounter24, CSR_HPMCOUNTER24, CSR_CLASS_ZIHPM, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(hpmcounter25, CSR_HPMCOUNTER25, CSR_CLASS_ZIHPM, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(hpmcounter26, CSR_HPMCOUNTER26, CSR_CLASS_ZIHPM, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(hpmcounter27, CSR_HPMCOUNTER27, CSR_CLASS_ZIHPM, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(hpmcounter28, CSR_HPMCOUNTER28, CSR_CLASS_ZIHPM, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(hpmcounter29, CSR_HPMCOUNTER29, CSR_CLASS_ZIHPM, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(hpmcounter30, CSR_HPMCOUNTER30, CSR_CLASS_ZIHPM, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(hpmcounter31, CSR_HPMCOUNTER31, CSR_CLASS_ZIHPM, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(cycleh, CSR_CYCLEH, CSR_CLASS_ZICNTR_32, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(timeh, CSR_TIMEH, CSR_CLASS_ZICNTR_32, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(instreth, CSR_INSTRETH, CSR_CLASS_ZICNTR_32, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(hpmcounter3h, CSR_HPMCOUNTER3H, CSR_CLASS_ZIHPM_32, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(hpmcounter4h, CSR_HPMCOUNTER4H, CSR_CLASS_ZIHPM_32, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(hpmcounter5h, CSR_HPMCOUNTER5H, CSR_CLASS_ZIHPM_32, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(hpmcounter6h, CSR_HPMCOUNTER6H, CSR_CLASS_ZIHPM_32, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(hpmcounter7h, CSR_HPMCOUNTER7H, CSR_CLASS_ZIHPM_32, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(hpmcounter8h, CSR_HPMCOUNTER8H, CSR_CLASS_ZIHPM_32, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(hpmcounter9h, CSR_HPMCOUNTER9H, CSR_CLASS_ZIHPM_32, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(hpmcounter10h, CSR_HPMCOUNTER10H, CSR_CLASS_ZIHPM_32, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(hpmcounter11h, CSR_HPMCOUNTER11H, CSR_CLASS_ZIHPM_32, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(hpmcounter12h, CSR_HPMCOUNTER12H, CSR_CLASS_ZIHPM_32, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(hpmcounter13h, CSR_HPMCOUNTER13H, CSR_CLASS_ZIHPM_32, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(hpmcounter14h, CSR_HPMCOUNTER14H, CSR_CLASS_ZIHPM_32, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(hpmcounter15h, CSR_HPMCOUNTER15H, CSR_CLASS_ZIHPM_32, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(hpmcounter16h, CSR_HPMCOUNTER16H, CSR_CLASS_ZIHPM_32, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(hpmcounter17h, CSR_HPMCOUNTER17H, CSR_CLASS_ZIHPM_32, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(hpmcounter18h, CSR_HPMCOUNTER18H, CSR_CLASS_ZIHPM_32, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(hpmcounter19h, CSR_HPMCOUNTER19H, CSR_CLASS_ZIHPM_32, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(hpmcounter20h, CSR_HPMCOUNTER20H, CSR_CLASS_ZIHPM_32, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(hpmcounter21h, CSR_HPMCOUNTER21H, CSR_CLASS_ZIHPM_32, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(hpmcounter22h, CSR_HPMCOUNTER22H, CSR_CLASS_ZIHPM_32, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(hpmcounter23h, CSR_HPMCOUNTER23H, CSR_CLASS_ZIHPM_32, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(hpmcounter24h, CSR_HPMCOUNTER24H, CSR_CLASS_ZIHPM_32, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(hpmcounter25h, CSR_HPMCOUNTER25H, CSR_CLASS_ZIHPM_32, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(hpmcounter26h, CSR_HPMCOUNTER26H, CSR_CLASS_ZIHPM_32, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(hpmcounter27h, CSR_HPMCOUNTER27H, CSR_CLASS_ZIHPM_32, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(hpmcounter28h, CSR_HPMCOUNTER28H, CSR_CLASS_ZIHPM_32, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(hpmcounter29h, CSR_HPMCOUNTER29H, CSR_CLASS_ZIHPM_32, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(hpmcounter30h, CSR_HPMCOUNTER30H, CSR_CLASS_ZIHPM_32, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(hpmcounter31h, CSR_HPMCOUNTER31H, CSR_CLASS_ZIHPM_32, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
 /* Privileged Supervisor CSRs.  */
 DECLARE_CSR(sstatus, CSR_SSTATUS, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
 DECLARE_CSR(sie, CSR_SIE, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
@@ -3710,98 +3710,98 @@ DECLARE_CSR(pmpaddr60, CSR_PMPADDR60, CSR_CLASS_I, PRIV_SPEC_CLASS_1P12, PRIV_SP
 DECLARE_CSR(pmpaddr61, CSR_PMPADDR61, CSR_CLASS_I, PRIV_SPEC_CLASS_1P12, PRIV_SPEC_CLASS_DRAFT)
 DECLARE_CSR(pmpaddr62, CSR_PMPADDR62, CSR_CLASS_I, PRIV_SPEC_CLASS_1P12, PRIV_SPEC_CLASS_DRAFT)
 DECLARE_CSR(pmpaddr63, CSR_PMPADDR63, CSR_CLASS_I, PRIV_SPEC_CLASS_1P12, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(mcycle, CSR_MCYCLE, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(minstret, CSR_MINSTRET, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(mhpmcounter3, CSR_MHPMCOUNTER3, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(mhpmcounter4, CSR_MHPMCOUNTER4, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(mhpmcounter5, CSR_MHPMCOUNTER5, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(mhpmcounter6, CSR_MHPMCOUNTER6, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(mhpmcounter7, CSR_MHPMCOUNTER7, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(mhpmcounter8, CSR_MHPMCOUNTER8, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(mhpmcounter9, CSR_MHPMCOUNTER9, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(mhpmcounter10, CSR_MHPMCOUNTER10, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(mhpmcounter11, CSR_MHPMCOUNTER11, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(mhpmcounter12, CSR_MHPMCOUNTER12, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(mhpmcounter13, CSR_MHPMCOUNTER13, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(mhpmcounter14, CSR_MHPMCOUNTER14, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(mhpmcounter15, CSR_MHPMCOUNTER15, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(mhpmcounter16, CSR_MHPMCOUNTER16, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(mhpmcounter17, CSR_MHPMCOUNTER17, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(mhpmcounter18, CSR_MHPMCOUNTER18, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(mhpmcounter19, CSR_MHPMCOUNTER19, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(mhpmcounter20, CSR_MHPMCOUNTER20, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(mhpmcounter21, CSR_MHPMCOUNTER21, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(mhpmcounter22, CSR_MHPMCOUNTER22, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(mhpmcounter23, CSR_MHPMCOUNTER23, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(mhpmcounter24, CSR_MHPMCOUNTER24, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(mhpmcounter25, CSR_MHPMCOUNTER25, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(mhpmcounter26, CSR_MHPMCOUNTER26, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(mhpmcounter27, CSR_MHPMCOUNTER27, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(mhpmcounter28, CSR_MHPMCOUNTER28, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(mhpmcounter29, CSR_MHPMCOUNTER29, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(mhpmcounter30, CSR_MHPMCOUNTER30, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(mhpmcounter31, CSR_MHPMCOUNTER31, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(mcycleh, CSR_MCYCLEH, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(minstreth, CSR_MINSTRETH, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(mhpmcounter3h, CSR_MHPMCOUNTER3H, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(mhpmcounter4h, CSR_MHPMCOUNTER4H, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(mhpmcounter5h, CSR_MHPMCOUNTER5H, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(mhpmcounter6h, CSR_MHPMCOUNTER6H, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(mhpmcounter7h, CSR_MHPMCOUNTER7H, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(mhpmcounter8h, CSR_MHPMCOUNTER8H, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(mhpmcounter9h, CSR_MHPMCOUNTER9H, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(mhpmcounter10h, CSR_MHPMCOUNTER10H, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(mhpmcounter11h, CSR_MHPMCOUNTER11H, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(mhpmcounter12h, CSR_MHPMCOUNTER12H, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(mhpmcounter13h, CSR_MHPMCOUNTER13H, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(mhpmcounter14h, CSR_MHPMCOUNTER14H, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(mhpmcounter15h, CSR_MHPMCOUNTER15H, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(mhpmcounter16h, CSR_MHPMCOUNTER16H, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(mhpmcounter17h, CSR_MHPMCOUNTER17H, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(mhpmcounter18h, CSR_MHPMCOUNTER18H, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(mhpmcounter19h, CSR_MHPMCOUNTER19H, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(mhpmcounter20h, CSR_MHPMCOUNTER20H, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(mhpmcounter21h, CSR_MHPMCOUNTER21H, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(mhpmcounter22h, CSR_MHPMCOUNTER22H, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(mhpmcounter23h, CSR_MHPMCOUNTER23H, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(mhpmcounter24h, CSR_MHPMCOUNTER24H, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(mhpmcounter25h, CSR_MHPMCOUNTER25H, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(mhpmcounter26h, CSR_MHPMCOUNTER26H, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(mhpmcounter27h, CSR_MHPMCOUNTER27H, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(mhpmcounter28h, CSR_MHPMCOUNTER28H, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(mhpmcounter29h, CSR_MHPMCOUNTER29H, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(mhpmcounter30h, CSR_MHPMCOUNTER30H, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(mhpmcounter31h, CSR_MHPMCOUNTER31H, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
+DECLARE_CSR(mcycle, CSR_MCYCLE, CSR_CLASS_ZICNTR, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(minstret, CSR_MINSTRET, CSR_CLASS_ZICNTR, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(mhpmcounter3, CSR_MHPMCOUNTER3, CSR_CLASS_ZIHPM, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(mhpmcounter4, CSR_MHPMCOUNTER4, CSR_CLASS_ZIHPM, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(mhpmcounter5, CSR_MHPMCOUNTER5, CSR_CLASS_ZIHPM, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(mhpmcounter6, CSR_MHPMCOUNTER6, CSR_CLASS_ZIHPM, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(mhpmcounter7, CSR_MHPMCOUNTER7, CSR_CLASS_ZIHPM, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(mhpmcounter8, CSR_MHPMCOUNTER8, CSR_CLASS_ZIHPM, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(mhpmcounter9, CSR_MHPMCOUNTER9, CSR_CLASS_ZIHPM, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(mhpmcounter10, CSR_MHPMCOUNTER10, CSR_CLASS_ZIHPM, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(mhpmcounter11, CSR_MHPMCOUNTER11, CSR_CLASS_ZIHPM, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(mhpmcounter12, CSR_MHPMCOUNTER12, CSR_CLASS_ZIHPM, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(mhpmcounter13, CSR_MHPMCOUNTER13, CSR_CLASS_ZIHPM, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(mhpmcounter14, CSR_MHPMCOUNTER14, CSR_CLASS_ZIHPM, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(mhpmcounter15, CSR_MHPMCOUNTER15, CSR_CLASS_ZIHPM, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(mhpmcounter16, CSR_MHPMCOUNTER16, CSR_CLASS_ZIHPM, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(mhpmcounter17, CSR_MHPMCOUNTER17, CSR_CLASS_ZIHPM, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(mhpmcounter18, CSR_MHPMCOUNTER18, CSR_CLASS_ZIHPM, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(mhpmcounter19, CSR_MHPMCOUNTER19, CSR_CLASS_ZIHPM, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(mhpmcounter20, CSR_MHPMCOUNTER20, CSR_CLASS_ZIHPM, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(mhpmcounter21, CSR_MHPMCOUNTER21, CSR_CLASS_ZIHPM, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(mhpmcounter22, CSR_MHPMCOUNTER22, CSR_CLASS_ZIHPM, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(mhpmcounter23, CSR_MHPMCOUNTER23, CSR_CLASS_ZIHPM, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(mhpmcounter24, CSR_MHPMCOUNTER24, CSR_CLASS_ZIHPM, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(mhpmcounter25, CSR_MHPMCOUNTER25, CSR_CLASS_ZIHPM, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(mhpmcounter26, CSR_MHPMCOUNTER26, CSR_CLASS_ZIHPM, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(mhpmcounter27, CSR_MHPMCOUNTER27, CSR_CLASS_ZIHPM, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(mhpmcounter28, CSR_MHPMCOUNTER28, CSR_CLASS_ZIHPM, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(mhpmcounter29, CSR_MHPMCOUNTER29, CSR_CLASS_ZIHPM, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(mhpmcounter30, CSR_MHPMCOUNTER30, CSR_CLASS_ZIHPM, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(mhpmcounter31, CSR_MHPMCOUNTER31, CSR_CLASS_ZIHPM, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(mcycleh, CSR_MCYCLEH, CSR_CLASS_ZICNTR_32, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(minstreth, CSR_MINSTRETH, CSR_CLASS_ZICNTR_32, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(mhpmcounter3h, CSR_MHPMCOUNTER3H, CSR_CLASS_ZIHPM_32, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(mhpmcounter4h, CSR_MHPMCOUNTER4H, CSR_CLASS_ZIHPM_32, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(mhpmcounter5h, CSR_MHPMCOUNTER5H, CSR_CLASS_ZIHPM_32, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(mhpmcounter6h, CSR_MHPMCOUNTER6H, CSR_CLASS_ZIHPM_32, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(mhpmcounter7h, CSR_MHPMCOUNTER7H, CSR_CLASS_ZIHPM_32, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(mhpmcounter8h, CSR_MHPMCOUNTER8H, CSR_CLASS_ZIHPM_32, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(mhpmcounter9h, CSR_MHPMCOUNTER9H, CSR_CLASS_ZIHPM_32, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(mhpmcounter10h, CSR_MHPMCOUNTER10H, CSR_CLASS_ZIHPM_32, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(mhpmcounter11h, CSR_MHPMCOUNTER11H, CSR_CLASS_ZIHPM_32, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(mhpmcounter12h, CSR_MHPMCOUNTER12H, CSR_CLASS_ZIHPM_32, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(mhpmcounter13h, CSR_MHPMCOUNTER13H, CSR_CLASS_ZIHPM_32, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(mhpmcounter14h, CSR_MHPMCOUNTER14H, CSR_CLASS_ZIHPM_32, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(mhpmcounter15h, CSR_MHPMCOUNTER15H, CSR_CLASS_ZIHPM_32, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(mhpmcounter16h, CSR_MHPMCOUNTER16H, CSR_CLASS_ZIHPM_32, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(mhpmcounter17h, CSR_MHPMCOUNTER17H, CSR_CLASS_ZIHPM_32, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(mhpmcounter18h, CSR_MHPMCOUNTER18H, CSR_CLASS_ZIHPM_32, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(mhpmcounter19h, CSR_MHPMCOUNTER19H, CSR_CLASS_ZIHPM_32, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(mhpmcounter20h, CSR_MHPMCOUNTER20H, CSR_CLASS_ZIHPM_32, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(mhpmcounter21h, CSR_MHPMCOUNTER21H, CSR_CLASS_ZIHPM_32, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(mhpmcounter22h, CSR_MHPMCOUNTER22H, CSR_CLASS_ZIHPM_32, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(mhpmcounter23h, CSR_MHPMCOUNTER23H, CSR_CLASS_ZIHPM_32, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(mhpmcounter24h, CSR_MHPMCOUNTER24H, CSR_CLASS_ZIHPM_32, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(mhpmcounter25h, CSR_MHPMCOUNTER25H, CSR_CLASS_ZIHPM_32, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(mhpmcounter26h, CSR_MHPMCOUNTER26H, CSR_CLASS_ZIHPM_32, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(mhpmcounter27h, CSR_MHPMCOUNTER27H, CSR_CLASS_ZIHPM_32, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(mhpmcounter28h, CSR_MHPMCOUNTER28H, CSR_CLASS_ZIHPM_32, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(mhpmcounter29h, CSR_MHPMCOUNTER29H, CSR_CLASS_ZIHPM_32, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(mhpmcounter30h, CSR_MHPMCOUNTER30H, CSR_CLASS_ZIHPM_32, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(mhpmcounter31h, CSR_MHPMCOUNTER31H, CSR_CLASS_ZIHPM_32, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
 DECLARE_CSR(mcountinhibit, CSR_MCOUNTINHIBIT, CSR_CLASS_I, PRIV_SPEC_CLASS_1P11, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(mhpmevent3, CSR_MHPMEVENT3, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(mhpmevent4, CSR_MHPMEVENT4, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(mhpmevent5, CSR_MHPMEVENT5, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(mhpmevent6, CSR_MHPMEVENT6, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(mhpmevent7, CSR_MHPMEVENT7, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(mhpmevent8, CSR_MHPMEVENT8, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(mhpmevent9, CSR_MHPMEVENT9, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(mhpmevent10, CSR_MHPMEVENT10, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(mhpmevent11, CSR_MHPMEVENT11, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(mhpmevent12, CSR_MHPMEVENT12, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(mhpmevent13, CSR_MHPMEVENT13, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(mhpmevent14, CSR_MHPMEVENT14, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(mhpmevent15, CSR_MHPMEVENT15, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(mhpmevent16, CSR_MHPMEVENT16, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(mhpmevent17, CSR_MHPMEVENT17, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(mhpmevent18, CSR_MHPMEVENT18, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(mhpmevent19, CSR_MHPMEVENT19, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(mhpmevent20, CSR_MHPMEVENT20, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(mhpmevent21, CSR_MHPMEVENT21, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(mhpmevent22, CSR_MHPMEVENT22, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(mhpmevent23, CSR_MHPMEVENT23, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(mhpmevent24, CSR_MHPMEVENT24, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(mhpmevent25, CSR_MHPMEVENT25, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(mhpmevent26, CSR_MHPMEVENT26, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(mhpmevent27, CSR_MHPMEVENT27, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(mhpmevent28, CSR_MHPMEVENT28, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(mhpmevent29, CSR_MHPMEVENT29, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(mhpmevent30, CSR_MHPMEVENT30, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(mhpmevent31, CSR_MHPMEVENT31, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
+DECLARE_CSR(mhpmevent3, CSR_MHPMEVENT3, CSR_CLASS_ZIHPM, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(mhpmevent4, CSR_MHPMEVENT4, CSR_CLASS_ZIHPM, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(mhpmevent5, CSR_MHPMEVENT5, CSR_CLASS_ZIHPM, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(mhpmevent6, CSR_MHPMEVENT6, CSR_CLASS_ZIHPM, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(mhpmevent7, CSR_MHPMEVENT7, CSR_CLASS_ZIHPM, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(mhpmevent8, CSR_MHPMEVENT8, CSR_CLASS_ZIHPM, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(mhpmevent9, CSR_MHPMEVENT9, CSR_CLASS_ZIHPM, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(mhpmevent10, CSR_MHPMEVENT10, CSR_CLASS_ZIHPM, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(mhpmevent11, CSR_MHPMEVENT11, CSR_CLASS_ZIHPM, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(mhpmevent12, CSR_MHPMEVENT12, CSR_CLASS_ZIHPM, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(mhpmevent13, CSR_MHPMEVENT13, CSR_CLASS_ZIHPM, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(mhpmevent14, CSR_MHPMEVENT14, CSR_CLASS_ZIHPM, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(mhpmevent15, CSR_MHPMEVENT15, CSR_CLASS_ZIHPM, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(mhpmevent16, CSR_MHPMEVENT16, CSR_CLASS_ZIHPM, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(mhpmevent17, CSR_MHPMEVENT17, CSR_CLASS_ZIHPM, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(mhpmevent18, CSR_MHPMEVENT18, CSR_CLASS_ZIHPM, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(mhpmevent19, CSR_MHPMEVENT19, CSR_CLASS_ZIHPM, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(mhpmevent20, CSR_MHPMEVENT20, CSR_CLASS_ZIHPM, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(mhpmevent21, CSR_MHPMEVENT21, CSR_CLASS_ZIHPM, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(mhpmevent22, CSR_MHPMEVENT22, CSR_CLASS_ZIHPM, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(mhpmevent23, CSR_MHPMEVENT23, CSR_CLASS_ZIHPM, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(mhpmevent24, CSR_MHPMEVENT24, CSR_CLASS_ZIHPM, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(mhpmevent25, CSR_MHPMEVENT25, CSR_CLASS_ZIHPM, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(mhpmevent26, CSR_MHPMEVENT26, CSR_CLASS_ZIHPM, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(mhpmevent27, CSR_MHPMEVENT27, CSR_CLASS_ZIHPM, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(mhpmevent28, CSR_MHPMEVENT28, CSR_CLASS_ZIHPM, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(mhpmevent29, CSR_MHPMEVENT29, CSR_CLASS_ZIHPM, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(mhpmevent30, CSR_MHPMEVENT30, CSR_CLASS_ZIHPM, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(mhpmevent31, CSR_MHPMEVENT31, CSR_CLASS_ZIHPM, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
 /* Privileged Hypervisor CSRs.  */
 DECLARE_CSR(hstatus, CSR_HSTATUS, CSR_CLASS_H, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
 DECLARE_CSR(hedeleg, CSR_HEDELEG, CSR_CLASS_H, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
diff --git a/include/opcode/riscv.h b/include/opcode/riscv.h
index 808f36573030..62635f5a3962 100644
--- a/include/opcode/riscv.h
+++ b/include/opcode/riscv.h
@@ -389,6 +389,7 @@ enum riscv_insn_class
   INSN_CLASS_Q,
   INSN_CLASS_F_AND_C,
   INSN_CLASS_D_AND_C,
+  INSN_CLASS_ZICNTR,
   INSN_CLASS_ZICOND,
   INSN_CLASS_ZICSR,
   INSN_CLASS_ZIFENCEI,
diff --git a/opcodes/riscv-opc.c b/opcodes/riscv-opc.c
index 3efab9a407d2..67aca686b95c 100644
--- a/opcodes/riscv-opc.c
+++ b/opcodes/riscv-opc.c
@@ -498,12 +498,12 @@ const struct riscv_opcode riscv_opcodes[] =
 {"fence",       0, INSN_CLASS_I, "P,Q",       MATCH_FENCE, MASK_FENCE|MASK_RD|MASK_RS1|(MASK_IMM & ~MASK_PRED & ~MASK_SUCC), match_opcode, 0 },
 {"fence.i",     0, INSN_CLASS_ZIFENCEI, "",   MATCH_FENCE_I, MASK_FENCE|MASK_RD|MASK_RS1|MASK_IMM, match_opcode, 0 },
 {"fence.tso",   0, INSN_CLASS_I, "",          MATCH_FENCE_TSO, MASK_FENCE_TSO|MASK_RD|MASK_RS1, match_opcode, 0 },
-{"rdcycle",     0, INSN_CLASS_I, "d",         MATCH_RDCYCLE, MASK_RDCYCLE, match_opcode, INSN_ALIAS },
-{"rdinstret",   0, INSN_CLASS_I, "d",         MATCH_RDINSTRET, MASK_RDINSTRET, match_opcode, INSN_ALIAS },
-{"rdtime",      0, INSN_CLASS_I, "d",         MATCH_RDTIME, MASK_RDTIME, match_opcode, INSN_ALIAS },
-{"rdcycleh",   32, INSN_CLASS_I, "d",         MATCH_RDCYCLEH, MASK_RDCYCLEH, match_opcode, INSN_ALIAS },
-{"rdinstreth", 32, INSN_CLASS_I, "d",         MATCH_RDINSTRETH, MASK_RDINSTRETH, match_opcode, INSN_ALIAS },
-{"rdtimeh",    32, INSN_CLASS_I, "d",         MATCH_RDTIMEH, MASK_RDTIMEH, match_opcode, INSN_ALIAS },
+{"rdcycle",     0, INSN_CLASS_ZICNTR, "d",    MATCH_RDCYCLE, MASK_RDCYCLE, match_opcode, INSN_ALIAS },
+{"rdinstret",   0, INSN_CLASS_ZICNTR, "d",    MATCH_RDINSTRET, MASK_RDINSTRET, match_opcode, INSN_ALIAS },
+{"rdtime",      0, INSN_CLASS_ZICNTR, "d",    MATCH_RDTIME, MASK_RDTIME, match_opcode, INSN_ALIAS },
+{"rdcycleh",   32, INSN_CLASS_ZICNTR, "d",    MATCH_RDCYCLEH, MASK_RDCYCLEH, match_opcode, INSN_ALIAS },
+{"rdinstreth", 32, INSN_CLASS_ZICNTR, "d",    MATCH_RDINSTRETH, MASK_RDINSTRETH, match_opcode, INSN_ALIAS },
+{"rdtimeh",    32, INSN_CLASS_ZICNTR, "d",    MATCH_RDTIMEH, MASK_RDTIMEH, match_opcode, INSN_ALIAS },
 {"ecall",       0, INSN_CLASS_I, "",          MATCH_SCALL, MASK_SCALL, match_opcode, 0 },
 {"scall",       0, INSN_CLASS_I, "",          MATCH_SCALL, MASK_SCALL, match_opcode, 0 },
 {"xor",         0, INSN_CLASS_I, "d,s,j",     MATCH_XORI, MASK_XORI, match_opcode, INSN_ALIAS },
-- 
2.41.0


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PING^1][RFC PATCH 0/2] RISC-V: Add 'Zicntr' and 'Zihpm' support with compatibility measures
  2023-08-08  3:17 [RFC PATCH 0/2] RISC-V: Add 'Zicntr' and 'Zihpm' support with compatibility measures Tsukasa OI
  2023-08-08  3:17 ` [RFC PATCH 1/2] RISC-V: Base for complex extension implications Tsukasa OI
  2023-08-08  3:17 ` [RFC PATCH 2/2] RISC-V: Add 'Zicntr' and 'Zihpm' support with compatibility measures Tsukasa OI
@ 2023-10-19  7:57 ` Tsukasa OI
  2023-10-19  8:33   ` Nelson Chu
  2023-10-21  0:45 ` [PATCH 0/1] " Tsukasa OI
  3 siblings, 1 reply; 10+ messages in thread
From: Tsukasa OI @ 2023-10-19  7:57 UTC (permalink / raw)
  To: binutils

Ping to all RISC-V folks,

Though there are more possible ways than described in the original
e-mail, at least I would like to hear from you all what do you want when
we are going to support now ratified 'Zicntr' and 'Zihpm' extensions.


Additional Note 1. When "zicntr" and/or "zihpm" are explicitly stated?

My initial RFC PATCH suppresses output of Zicntr and Zihpm extensions
unless the version number is specified explicitly (there's room to fix
this issue).

Additional Note 2. Warn, instead of making errors?

We have an option to make warnings when 'Zicntr' instructions are used
without the 'Zicntr' extension (when we are going to "compliant mode").
That will add a special code path but can be less breaking for users.


Sincerely,
Tsukasa

On 2023/08/08 12:17, Tsukasa OI wrote:
> Hi,
> 
> The role of this patch set is very simple: implement recently ratified
> 'Zicntr' (basic counters and timers) and 'Zihpm' (hardware performance
> counters) extensions, formerly a part of the 'I' extension, version 2.0.
> 
> Since some draft extensions depend on those extensions, implementing counter
> extensions (as a part of data structure) is becoming mandatory.
> 
> However, we need to be *very* careful to the implementation.  Because
> CSRs and pseudoinstructions for those extensions were a part of 'I' and
> more importantly, the first version which separated counters from the 'I'
> extension, did not give counters extension names.  So, we needed to
> implement such CSRs and pseudoinstructions as a part of 'I' (continuously).
> 
> 
> Not breaking the compatibility here is vital (the only exception might be
> the new ratified ISA after version 20191213).  So, I implemented those
> extensions not to break anything as possible.
> 
> The basic idea is, an extension (riscv_subset_t) with an unknown version is
> not emitted to an object file (ELF attributes, mapping symbols etc...).
> 
> The default mode for existing ISAs is the compatibility mode (Option 1).
> 
> 
> [Option 1: Compatibility Mode]
> 
> In the compatibility mode (as default),
> 
> 1.  'I' implies 'Zicntr' and 'Zihpm'.
> 2.  'Zicntr' and 'Zihpm' DO NOT imply 'Zicsr'.
> 3.  'Zicntr' and 'Zihpm' don't have version information.
> 
> (2.) is the point.  The ratified document says 'Zicntr' and 'Zihpm' depend
> on the 'Zicsr' extension but if we do it unconditionally, that would mean
> that the 'I' extension indirectly depends on 'Zicsr' (because of 1.), making
> a difference from the ratified 'I' extension version 2.1.  In order to keep
> the compatibility, making 'Zicntr' and 'Zihpm' against the documentation was
> (sadly) necessary.
> 
> In the compatibility mode, code like:
> 
>> riscv_subset_supports(&rps, "zicntr")
> 
> will return true.  Because, even that the version information is missing,
> the 'Zicntr' extension exists in the riscv_subset_list_t.  But an extension
> with no version means, it will not be a part of the architectural string
> emitted as a part of an object file.
> 
> 
> [Option 2: Compliant Mode]
> 
> We can continue this forever but we have another option.  Break false
> dependency when a new ISA (with its version) is ratified and in that time,
> require those extensions separately like -march=..._zicntr_zihpm.
> 
> In the compliant mode:
> 
> 1.  'I' DOES NOT imply 'Zicntr' and 'Zihpm'.
> 2.  'Zicntr' and 'Zihpm' DO imply 'Zicsr'.
> 3.  'Zicntr' and 'Zihpm' have its version information
>     (ratified version 2.0 or possibly a later version)
> 
> Note that (1.) and (2.) are very opposite from the compatibility mode.
> 
> In this mode, it is compliant to the specification completely.
> 
> 
> 
> 
> [Implementing an Option on future ISAs]
> 
> Assume that we have a new ISA specification class, ISA_SPEC_CLASS_2024XXXX.
> We can choose which option to implement as follows.
> 
> 
> [Option 1: Compatibility Mode]
> 
> 1. Change the contents of check_implicit_compat_counter_from_i.
> 
>>  /* Old.  */
>>  return *rps->isa_spec <= ISA_SPEC_CLASS_20191213;
> 
>>  /* New.  */
>>  return *rps->isa_spec <= ISA_SPEC_CLASS_2024XXXX;
> 
> Note that the reason we are looking for the ISA specification (instead of
> the version of the 'I' extension) is, the 'I' extension version 2.1 is
> unlikely to change even when the new ISA specification is ratified.
> I assume that two behaviors (option 1 and 2) share the same 'I' version 2.1.
> 
> If the version of the 'I' extension changes (even if no *actual* changes
> are made) in the new unprivileged ISA version, that would be a bit simpler.
> 
> 2. Add following entries to riscv_supported_std_z_ext.
> 
> Make sure that they don't have the version number.
> 
>>  /* ...  */
>>  {"zicntr",		ISA_SPEC_CLASS_2024XXXX,	RISCV_UNKNOWN_VERSION, RISCV_UNKNOWN_VERSION,  0 }, /* Compat.  */
>>  /* ...  */
>>  {"zihpm",		ISA_SPEC_CLASS_2024XXXX,	RISCV_UNKNOWN_VERSION, RISCV_UNKNOWN_VERSION,  0 }, /* Compat.  */
> 
> 
> [Option 2: Compliant Mode]
> 
> 1. DO NOT change the contents of check_implicit_compat_counter_from_i.
> 2. Add following entries to riscv_supported_std_z_ext.
> 
> Make sure that they DO have the version number.
> 
>>  /* ...  */
>>  {"zicntr",		ISA_SPEC_CLASS_2024XXXX,	2, 0,  0 },
>>  /* ...  */
>>  {"zihpm",		ISA_SPEC_CLASS_2024XXXX,	2, 0,  0 },
> 
> ...and for compatibility, we need to slightly modify riscv-dis.c.  The
> disassembler defaults to the latest non-draft ISA and there's currently no
> ways to change it.  We need to make changes to riscv-dis.c by either:
> 
> 1.  Entering special compatibility mode (even on the latest ISA, enable
>     'Zicntr' extension ['Zihpm' is not necessary on the disassembler]) or
> 2.  Enabling to change the ISA version from disassembler options.
>     Like my long proposed disassembler changes: adding overridable "arch"
>     and "priv-spec" options, we have an option to change the ISA using the
>     disassembler option.
>     <https://github.com/a4lg/binutils-gdb/wiki/riscv_dis_arch_priv_spec>
> 
> 
> In either case, this patch set leaves both options to implement yet
> supporting 'Zicntr' and 'Zihpm' extensions directly.
> 
> 
> 
> 
> Along with those changes (in PATCH 2), PATCH 1 makes possible to consider
> implication by using *more* information than before.  This is practically
> the same as:
> <https://sourceware.org/pipermail/binutils/2023-July/128715.html>,
> a patch to demonstrate how to implement the 'Zce' superset extension
> ('Zcf' must be implied by 'Zce' ONLY IF 'F' is ALSO enabled).
> 
> The only difference is a minor type change as follows (to enable using
> the "riscv_subset_supports" function).
> 
> *   Before: "const riscv_parse_subset_t *"
> *   After:  "      riscv_parse_subset_t *"
> 
> 
> 
> 
> Is there any other options?  Should I simplify the patch assuming we choose
> the compatibility mode (Option 1) forever?
> 
> In any case, I would like to hear your thoughts.
> 
> Thanks,
> Tsukasa
> 
> 
> 
> 
> Tsukasa OI (2):
>   RISC-V: Base for complex extension implications
>   RISC-V: Add 'Zicntr' and 'Zihpm' support with compatibility measures
> 
>  bfd/elfxx-riscv.c                       |  86 +++++--
>  gas/config/tc-riscv.c                   |  16 ++
>  gas/testsuite/gas/riscv/march-imply-i.s |   8 +
>  include/opcode/riscv-opc.h              | 310 ++++++++++++------------
>  include/opcode/riscv.h                  |   1 +
>  opcodes/riscv-opc.c                     |  12 +-
>  6 files changed, 256 insertions(+), 177 deletions(-)
> 
> 
> base-commit: d734d43a048b33ee12df2c06c2e782887e9715f6

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PING^1][RFC PATCH 0/2] RISC-V: Add 'Zicntr' and 'Zihpm' support with compatibility measures
  2023-10-19  7:57 ` [PING^1][RFC PATCH 0/2] " Tsukasa OI
@ 2023-10-19  8:33   ` Nelson Chu
  2023-10-20  2:52     ` Tsukasa OI
  0 siblings, 1 reply; 10+ messages in thread
From: Nelson Chu @ 2023-10-19  8:33 UTC (permalink / raw)
  To: Tsukasa OI; +Cc: binutils

[-- Attachment #1: Type: text/plain, Size: 8802 bytes --]

I hope we can remove the support of -misa-spec and -mpriv-spec from
binutils, and then simply support the newest extension versions and CSRs by
default.  These features are good until spec 20191213 and privileged spec
2.2, but they are harmful later, since spec no longer needs its own
versions.  Continuing to build on all this mistake will make it all look
worse, so I hope we can stop supporting -misa-spec/-mpriv-spec to take care
of the compatibility issues.  Only in this way can we prevent us from
wasting time on these faults caused by me many years ago.

Thanks
Nelson

On Thu, Oct 19, 2023 at 3:58 PM Tsukasa OI <research_trasio@irq.a4lg.com>
wrote:

> Ping to all RISC-V folks,
>
> Though there are more possible ways than described in the original
> e-mail, at least I would like to hear from you all what do you want when
> we are going to support now ratified 'Zicntr' and 'Zihpm' extensions.
>
>
> Additional Note 1. When "zicntr" and/or "zihpm" are explicitly stated?
>
> My initial RFC PATCH suppresses output of Zicntr and Zihpm extensions
> unless the version number is specified explicitly (there's room to fix
> this issue).
>
> Additional Note 2. Warn, instead of making errors?
>
> We have an option to make warnings when 'Zicntr' instructions are used
> without the 'Zicntr' extension (when we are going to "compliant mode").
> That will add a special code path but can be less breaking for users.
>
>
> Sincerely,
> Tsukasa
>
> On 2023/08/08 12:17, Tsukasa OI wrote:
> > Hi,
> >
> > The role of this patch set is very simple: implement recently ratified
> > 'Zicntr' (basic counters and timers) and 'Zihpm' (hardware performance
> > counters) extensions, formerly a part of the 'I' extension, version 2.0.
> >
> > Since some draft extensions depend on those extensions, implementing
> counter
> > extensions (as a part of data structure) is becoming mandatory.
> >
> > However, we need to be *very* careful to the implementation.  Because
> > CSRs and pseudoinstructions for those extensions were a part of 'I' and
> > more importantly, the first version which separated counters from the 'I'
> > extension, did not give counters extension names.  So, we needed to
> > implement such CSRs and pseudoinstructions as a part of 'I'
> (continuously).
> >
> >
> > Not breaking the compatibility here is vital (the only exception might be
> > the new ratified ISA after version 20191213).  So, I implemented those
> > extensions not to break anything as possible.
> >
> > The basic idea is, an extension (riscv_subset_t) with an unknown version
> is
> > not emitted to an object file (ELF attributes, mapping symbols etc...).
> >
> > The default mode for existing ISAs is the compatibility mode (Option 1).
> >
> >
> > [Option 1: Compatibility Mode]
> >
> > In the compatibility mode (as default),
> >
> > 1.  'I' implies 'Zicntr' and 'Zihpm'.
> > 2.  'Zicntr' and 'Zihpm' DO NOT imply 'Zicsr'.
> > 3.  'Zicntr' and 'Zihpm' don't have version information.
> >
> > (2.) is the point.  The ratified document says 'Zicntr' and 'Zihpm'
> depend
> > on the 'Zicsr' extension but if we do it unconditionally, that would mean
> > that the 'I' extension indirectly depends on 'Zicsr' (because of 1.),
> making
> > a difference from the ratified 'I' extension version 2.1.  In order to
> keep
> > the compatibility, making 'Zicntr' and 'Zihpm' against the documentation
> was
> > (sadly) necessary.
> >
> > In the compatibility mode, code like:
> >
> >> riscv_subset_supports(&rps, "zicntr")
> >
> > will return true.  Because, even that the version information is missing,
> > the 'Zicntr' extension exists in the riscv_subset_list_t.  But an
> extension
> > with no version means, it will not be a part of the architectural string
> > emitted as a part of an object file.
> >
> >
> > [Option 2: Compliant Mode]
> >
> > We can continue this forever but we have another option.  Break false
> > dependency when a new ISA (with its version) is ratified and in that
> time,
> > require those extensions separately like -march=..._zicntr_zihpm.
> >
> > In the compliant mode:
> >
> > 1.  'I' DOES NOT imply 'Zicntr' and 'Zihpm'.
> > 2.  'Zicntr' and 'Zihpm' DO imply 'Zicsr'.
> > 3.  'Zicntr' and 'Zihpm' have its version information
> >     (ratified version 2.0 or possibly a later version)
> >
> > Note that (1.) and (2.) are very opposite from the compatibility mode.
> >
> > In this mode, it is compliant to the specification completely.
> >
> >
> >
> >
> > [Implementing an Option on future ISAs]
> >
> > Assume that we have a new ISA specification class,
> ISA_SPEC_CLASS_2024XXXX.
> > We can choose which option to implement as follows.
> >
> >
> > [Option 1: Compatibility Mode]
> >
> > 1. Change the contents of check_implicit_compat_counter_from_i.
> >
> >>  /* Old.  */
> >>  return *rps->isa_spec <= ISA_SPEC_CLASS_20191213;
> >
> >>  /* New.  */
> >>  return *rps->isa_spec <= ISA_SPEC_CLASS_2024XXXX;
> >
> > Note that the reason we are looking for the ISA specification (instead of
> > the version of the 'I' extension) is, the 'I' extension version 2.1 is
> > unlikely to change even when the new ISA specification is ratified.
> > I assume that two behaviors (option 1 and 2) share the same 'I' version
> 2.1.
> >
> > If the version of the 'I' extension changes (even if no *actual* changes
> > are made) in the new unprivileged ISA version, that would be a bit
> simpler.
> >
> > 2. Add following entries to riscv_supported_std_z_ext.
> >
> > Make sure that they don't have the version number.
> >
> >>  /* ...  */
> >>  {"zicntr",          ISA_SPEC_CLASS_2024XXXX,
> RISCV_UNKNOWN_VERSION, RISCV_UNKNOWN_VERSION,  0 }, /* Compat.  */
> >>  /* ...  */
> >>  {"zihpm",           ISA_SPEC_CLASS_2024XXXX,
> RISCV_UNKNOWN_VERSION, RISCV_UNKNOWN_VERSION,  0 }, /* Compat.  */
> >
> >
> > [Option 2: Compliant Mode]
> >
> > 1. DO NOT change the contents of check_implicit_compat_counter_from_i.
> > 2. Add following entries to riscv_supported_std_z_ext.
> >
> > Make sure that they DO have the version number.
> >
> >>  /* ...  */
> >>  {"zicntr",          ISA_SPEC_CLASS_2024XXXX,        2, 0,  0 },
> >>  /* ...  */
> >>  {"zihpm",           ISA_SPEC_CLASS_2024XXXX,        2, 0,  0 },
> >
> > ...and for compatibility, we need to slightly modify riscv-dis.c.  The
> > disassembler defaults to the latest non-draft ISA and there's currently
> no
> > ways to change it.  We need to make changes to riscv-dis.c by either:
> >
> > 1.  Entering special compatibility mode (even on the latest ISA, enable
> >     'Zicntr' extension ['Zihpm' is not necessary on the disassembler]) or
> > 2.  Enabling to change the ISA version from disassembler options.
> >     Like my long proposed disassembler changes: adding overridable "arch"
> >     and "priv-spec" options, we have an option to change the ISA using
> the
> >     disassembler option.
> >     <https://github.com/a4lg/binutils-gdb/wiki/riscv_dis_arch_priv_spec>
> >
> >
> > In either case, this patch set leaves both options to implement yet
> > supporting 'Zicntr' and 'Zihpm' extensions directly.
> >
> >
> >
> >
> > Along with those changes (in PATCH 2), PATCH 1 makes possible to consider
> > implication by using *more* information than before.  This is practically
> > the same as:
> > <https://sourceware.org/pipermail/binutils/2023-July/128715.html>,
> > a patch to demonstrate how to implement the 'Zce' superset extension
> > ('Zcf' must be implied by 'Zce' ONLY IF 'F' is ALSO enabled).
> >
> > The only difference is a minor type change as follows (to enable using
> > the "riscv_subset_supports" function).
> >
> > *   Before: "const riscv_parse_subset_t *"
> > *   After:  "      riscv_parse_subset_t *"
> >
> >
> >
> >
> > Is there any other options?  Should I simplify the patch assuming we
> choose
> > the compatibility mode (Option 1) forever?
> >
> > In any case, I would like to hear your thoughts.
> >
> > Thanks,
> > Tsukasa
> >
> >
> >
> >
> > Tsukasa OI (2):
> >   RISC-V: Base for complex extension implications
> >   RISC-V: Add 'Zicntr' and 'Zihpm' support with compatibility measures
> >
> >  bfd/elfxx-riscv.c                       |  86 +++++--
> >  gas/config/tc-riscv.c                   |  16 ++
> >  gas/testsuite/gas/riscv/march-imply-i.s |   8 +
> >  include/opcode/riscv-opc.h              | 310 ++++++++++++------------
> >  include/opcode/riscv.h                  |   1 +
> >  opcodes/riscv-opc.c                     |  12 +-
> >  6 files changed, 256 insertions(+), 177 deletions(-)
> >
> >
> > base-commit: d734d43a048b33ee12df2c06c2e782887e9715f6
>

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PING^1][RFC PATCH 0/2] RISC-V: Add 'Zicntr' and 'Zihpm' support with compatibility measures
  2023-10-19  8:33   ` Nelson Chu
@ 2023-10-20  2:52     ` Tsukasa OI
  0 siblings, 0 replies; 10+ messages in thread
From: Tsukasa OI @ 2023-10-20  2:52 UTC (permalink / raw)
  To: Nelson Chu, Binutils

On 2023/10/19 17:33, Nelson Chu wrote:
> I hope we can remove the support of -misa-spec and -mpriv-spec from
> binutils, and then simply support the newest extension versions and CSRs
> by default.  These features are good until spec 20191213 and privileged
> spec 2.2, but they are harmful later, since spec no longer needs its own
> versions.  Continuing to build on all this mistake will make it all look
> worse, so I hope we can stop supporting -misa-spec/-mpriv-spec to take
> care of the compatibility issues.  Only in this way can we prevent us
> from wasting time on these faults caused by me many years ago.
> 
> Thanks
> Nelson

I could not be more appreciative of your input.

I mean, I must thank you because I can get rid of my garbage and make
another better one from scratch.  It's better if we don't have to depend
on -misa-spec and I think... softer approach works.

I'm making the new version based on the following concept:

1.  'I' does not imply 'Zicntr' and 'Zihpm' in any ISA spec.
2.  Using 'Zicntr' pseudoinstructions without the extension causes
    a warning (but not an error; this is new).  Using 'Zihpm' CSRs
    without the extension causes a warning when -mcsr-check is
    enabled (as usual).
3.  We have one extension version entry for each of them
    ('Zicntr' and 'Zihpm': ISA_SPEC_DRAFT, version 2.0)

So, my next approach will be, compliant as possible, except its
violation does not make a hard error (to avoid compatibility issues; I
don't want to repeat 'Zicsr' mess again).

Do this work for you?

Thanks,
Tsukasa

> 
> On Thu, Oct 19, 2023 at 3:58 PM Tsukasa OI <research_trasio@irq.a4lg.com
> <mailto:research_trasio@irq.a4lg.com>> wrote:
> 
>     Ping to all RISC-V folks,
> 
>     Though there are more possible ways than described in the original
>     e-mail, at least I would like to hear from you all what do you want when
>     we are going to support now ratified 'Zicntr' and 'Zihpm' extensions.
> 
> 
>     Additional Note 1. When "zicntr" and/or "zihpm" are explicitly stated?
> 
>     My initial RFC PATCH suppresses output of Zicntr and Zihpm extensions
>     unless the version number is specified explicitly (there's room to fix
>     this issue).
> 
>     Additional Note 2. Warn, instead of making errors?
> 
>     We have an option to make warnings when 'Zicntr' instructions are used
>     without the 'Zicntr' extension (when we are going to "compliant mode").
>     That will add a special code path but can be less breaking for users.
> 
> 
>     Sincerely,
>     Tsukasa
> 
>     On 2023/08/08 12:17, Tsukasa OI wrote:
>     > Hi,
>     >
>     > The role of this patch set is very simple: implement recently ratified
>     > 'Zicntr' (basic counters and timers) and 'Zihpm' (hardware performance
>     > counters) extensions, formerly a part of the 'I' extension,
>     version 2.0.
>     >
>     > Since some draft extensions depend on those extensions,
>     implementing counter
>     > extensions (as a part of data structure) is becoming mandatory.
>     >
>     > However, we need to be *very* careful to the implementation.  Because
>     > CSRs and pseudoinstructions for those extensions were a part of
>     'I' and
>     > more importantly, the first version which separated counters from
>     the 'I'
>     > extension, did not give counters extension names.  So, we needed to
>     > implement such CSRs and pseudoinstructions as a part of 'I'
>     (continuously).
>     >
>     >
>     > Not breaking the compatibility here is vital (the only exception
>     might be
>     > the new ratified ISA after version 20191213).  So, I implemented those
>     > extensions not to break anything as possible.
>     >
>     > The basic idea is, an extension (riscv_subset_t) with an unknown
>     version is
>     > not emitted to an object file (ELF attributes, mapping symbols
>     etc...).
>     >
>     > The default mode for existing ISAs is the compatibility mode
>     (Option 1).
>     >
>     >
>     > [Option 1: Compatibility Mode]
>     >
>     > In the compatibility mode (as default),
>     >
>     > 1.  'I' implies 'Zicntr' and 'Zihpm'.
>     > 2.  'Zicntr' and 'Zihpm' DO NOT imply 'Zicsr'.
>     > 3.  'Zicntr' and 'Zihpm' don't have version information.
>     >
>     > (2.) is the point.  The ratified document says 'Zicntr' and
>     'Zihpm' depend
>     > on the 'Zicsr' extension but if we do it unconditionally, that
>     would mean
>     > that the 'I' extension indirectly depends on 'Zicsr' (because of
>     1.), making
>     > a difference from the ratified 'I' extension version 2.1.  In
>     order to keep
>     > the compatibility, making 'Zicntr' and 'Zihpm' against the
>     documentation was
>     > (sadly) necessary.
>     >
>     > In the compatibility mode, code like:
>     >
>     >> riscv_subset_supports(&rps, "zicntr")
>     >
>     > will return true.  Because, even that the version information is
>     missing,
>     > the 'Zicntr' extension exists in the riscv_subset_list_t.  But an
>     extension
>     > with no version means, it will not be a part of the architectural
>     string
>     > emitted as a part of an object file.
>     >
>     >
>     > [Option 2: Compliant Mode]
>     >
>     > We can continue this forever but we have another option.  Break false
>     > dependency when a new ISA (with its version) is ratified and in
>     that time,
>     > require those extensions separately like -march=..._zicntr_zihpm.
>     >
>     > In the compliant mode:
>     >
>     > 1.  'I' DOES NOT imply 'Zicntr' and 'Zihpm'.
>     > 2.  'Zicntr' and 'Zihpm' DO imply 'Zicsr'.
>     > 3.  'Zicntr' and 'Zihpm' have its version information
>     >     (ratified version 2.0 or possibly a later version)
>     >
>     > Note that (1.) and (2.) are very opposite from the compatibility mode.
>     >
>     > In this mode, it is compliant to the specification completely.
>     >
>     >
>     >
>     >
>     > [Implementing an Option on future ISAs]
>     >
>     > Assume that we have a new ISA specification class,
>     ISA_SPEC_CLASS_2024XXXX.
>     > We can choose which option to implement as follows.
>     >
>     >
>     > [Option 1: Compatibility Mode]
>     >
>     > 1. Change the contents of check_implicit_compat_counter_from_i.
>     >
>     >>  /* Old.  */
>     >>  return *rps->isa_spec <= ISA_SPEC_CLASS_20191213;
>     >
>     >>  /* New.  */
>     >>  return *rps->isa_spec <= ISA_SPEC_CLASS_2024XXXX;
>     >
>     > Note that the reason we are looking for the ISA specification
>     (instead of
>     > the version of the 'I' extension) is, the 'I' extension version 2.1 is
>     > unlikely to change even when the new ISA specification is ratified.
>     > I assume that two behaviors (option 1 and 2) share the same 'I'
>     version 2.1.
>     >
>     > If the version of the 'I' extension changes (even if no *actual*
>     changes
>     > are made) in the new unprivileged ISA version, that would be a bit
>     simpler.
>     >
>     > 2. Add following entries to riscv_supported_std_z_ext.
>     >
>     > Make sure that they don't have the version number.
>     >
>     >>  /* ...  */
>     >>  {"zicntr",          ISA_SPEC_CLASS_2024XXXX,       
>     RISCV_UNKNOWN_VERSION, RISCV_UNKNOWN_VERSION,  0 }, /* Compat.  */
>     >>  /* ...  */
>     >>  {"zihpm",           ISA_SPEC_CLASS_2024XXXX,       
>     RISCV_UNKNOWN_VERSION, RISCV_UNKNOWN_VERSION,  0 }, /* Compat.  */
>     >
>     >
>     > [Option 2: Compliant Mode]
>     >
>     > 1. DO NOT change the contents of check_implicit_compat_counter_from_i.
>     > 2. Add following entries to riscv_supported_std_z_ext.
>     >
>     > Make sure that they DO have the version number.
>     >
>     >>  /* ...  */
>     >>  {"zicntr",          ISA_SPEC_CLASS_2024XXXX,        2, 0,  0 },
>     >>  /* ...  */
>     >>  {"zihpm",           ISA_SPEC_CLASS_2024XXXX,        2, 0,  0 },
>     >
>     > ...and for compatibility, we need to slightly modify riscv-dis.c.  The
>     > disassembler defaults to the latest non-draft ISA and there's
>     currently no
>     > ways to change it.  We need to make changes to riscv-dis.c by either:
>     >
>     > 1.  Entering special compatibility mode (even on the latest ISA,
>     enable
>     >     'Zicntr' extension ['Zihpm' is not necessary on the
>     disassembler]) or
>     > 2.  Enabling to change the ISA version from disassembler options.
>     >     Like my long proposed disassembler changes: adding overridable
>     "arch"
>     >     and "priv-spec" options, we have an option to change the ISA
>     using the
>     >     disassembler option.
>     >   
>      <https://github.com/a4lg/binutils-gdb/wiki/riscv_dis_arch_priv_spec
>     <https://github.com/a4lg/binutils-gdb/wiki/riscv_dis_arch_priv_spec>>
>     >
>     >
>     > In either case, this patch set leaves both options to implement yet
>     > supporting 'Zicntr' and 'Zihpm' extensions directly.
>     >
>     >
>     >
>     >
>     > Along with those changes (in PATCH 2), PATCH 1 makes possible to
>     consider
>     > implication by using *more* information than before.  This is
>     practically
>     > the same as:
>     > <https://sourceware.org/pipermail/binutils/2023-July/128715.html
>     <https://sourceware.org/pipermail/binutils/2023-July/128715.html>>,
>     > a patch to demonstrate how to implement the 'Zce' superset extension
>     > ('Zcf' must be implied by 'Zce' ONLY IF 'F' is ALSO enabled).
>     >
>     > The only difference is a minor type change as follows (to enable using
>     > the "riscv_subset_supports" function).
>     >
>     > *   Before: "const riscv_parse_subset_t *"
>     > *   After:  "      riscv_parse_subset_t *"
>     >
>     >
>     >
>     >
>     > Is there any other options?  Should I simplify the patch assuming
>     we choose
>     > the compatibility mode (Option 1) forever?
>     >
>     > In any case, I would like to hear your thoughts.
>     >
>     > Thanks,
>     > Tsukasa
>     >
>     >
>     >
>     >
>     > Tsukasa OI (2):
>     >   RISC-V: Base for complex extension implications
>     >   RISC-V: Add 'Zicntr' and 'Zihpm' support with compatibility measures
>     >
>     >  bfd/elfxx-riscv.c                       |  86 +++++--
>     >  gas/config/tc-riscv.c                   |  16 ++
>     >  gas/testsuite/gas/riscv/march-imply-i.s |   8 +
>     >  include/opcode/riscv-opc.h              | 310
>     ++++++++++++------------
>     >  include/opcode/riscv.h                  |   1 +
>     >  opcodes/riscv-opc.c                     |  12 +-
>     >  6 files changed, 256 insertions(+), 177 deletions(-)
>     >
>     >
>     > base-commit: d734d43a048b33ee12df2c06c2e782887e9715f6
> 

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH 0/1] RISC-V: Add 'Zicntr' and 'Zihpm' support with compatibility measures
  2023-08-08  3:17 [RFC PATCH 0/2] RISC-V: Add 'Zicntr' and 'Zihpm' support with compatibility measures Tsukasa OI
                   ` (2 preceding siblings ...)
  2023-10-19  7:57 ` [PING^1][RFC PATCH 0/2] " Tsukasa OI
@ 2023-10-21  0:45 ` Tsukasa OI
  2023-10-21  0:45   ` [PATCH 1/1] " Tsukasa OI
  2023-10-21  2:17   ` [PATCH v2 0/1] " Tsukasa OI
  3 siblings, 2 replies; 10+ messages in thread
From: Tsukasa OI @ 2023-10-21  0:45 UTC (permalink / raw)
  To: Tsukasa OI, Palmer Dabbelt, Andrew Waterman, Jim Wilson,
	Nelson Chu, Kito Cheng
  Cc: binutils

Hi,

This patch adds support for two extensions, split from the RISC-V
Unprivileged ISA version 2.2:

1.  `Zicntr`
    Basic hardware performance counters
2.  `Zihpm`
    Platform-specific configurable hardware performance counters

but the compatibility is vital.  This patch set tries to deal with the
compatibility issues as possible.


RFC PATCH v1:
<https://sourceware.org/pipermail/binutils/2023-August/128895.html>


Unlike RFC PATCH v1, this (PATCH v1) tries to resolve most of compatibility
issues by following concepts:

1.  Implement 'Zicntr' and 'Zihpm' as in the latest RISC-V ISA Manual
    documentation (draft) except...
2.  even if a 'Zicntr' pseudoinstruction is used without that extension,
    generate a warning instead of an error.

This is much simpler than before (though increases differences in tests)
and almost completely ISA specification agnostic.  I hope this patch
resolves most of concerns raised by Nelson.

The hardest part was to move handling of *the ISA version 2.2* to
*the 'I' extension version 2.0 (or less)*.  If the 'I' extension version is
2.0 or less and its subset (e.g. 'Zicsr' or 'Zicntr') is being added, it
disables inferring the default version number.  If the ISA is either RV32E
or RV64E and 'I' 2.0 subsets (but 'I' itself) are explicitly specified, the
default handling is the same as 'I' >= 2.1 because non-draft 'E' extension
does not have 'I' 2.0 subsets.


Thanks,
Tsukasa




Tsukasa OI (1):
  RISC-V: Add 'Zicntr' and 'Zihpm' support with compatibility measures

 bfd/elfxx-riscv.c                             |  52 +++-
 gas/config/tc-riscv.c                         |  25 ++
 .../gas/riscv/csr-insns-pseudo-noalias.d      |   2 +-
 .../gas/riscv/csr-insns-pseudo-nozicntr.d     |  37 +++
 .../gas/riscv/csr-insns-pseudo-nozicntr.l     |   7 +
 .../gas/riscv/csr-insns-pseudo-zfinx.d        |   2 +-
 gas/testsuite/gas/riscv/csr-insns-pseudo.d    |   2 +-
 gas/testsuite/gas/riscv/csr-insns-pseudo.s    |   3 +-
 gas/testsuite/gas/riscv/csr-insns-read-only.d |   2 +-
 gas/testsuite/gas/riscv/csr-version-1p10.l    | 256 ++++++++++++++++++
 gas/testsuite/gas/riscv/csr-version-1p11.l    | 256 ++++++++++++++++++
 gas/testsuite/gas/riscv/csr-version-1p12.l    | 256 ++++++++++++++++++
 gas/testsuite/gas/riscv/csr-version-1p9p1.l   | 256 ++++++++++++++++++
 include/opcode/riscv-opc.h                    | 128 ++++-----
 include/opcode/riscv.h                        |   1 +
 opcodes/riscv-opc.c                           |  12 +-
 16 files changed, 1217 insertions(+), 80 deletions(-)
 create mode 100644 gas/testsuite/gas/riscv/csr-insns-pseudo-nozicntr.d
 create mode 100644 gas/testsuite/gas/riscv/csr-insns-pseudo-nozicntr.l


base-commit: 4a6daabb94982ccc17ea45ebb6f6e8efa8f86399
-- 
2.42.0


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH 1/1] RISC-V: Add 'Zicntr' and 'Zihpm' support with compatibility measures
  2023-10-21  0:45 ` [PATCH 0/1] " Tsukasa OI
@ 2023-10-21  0:45   ` Tsukasa OI
  2023-10-21  2:17   ` [PATCH v2 0/1] " Tsukasa OI
  1 sibling, 0 replies; 10+ messages in thread
From: Tsukasa OI @ 2023-10-21  0:45 UTC (permalink / raw)
  To: Tsukasa OI, Palmer Dabbelt, Andrew Waterman, Jim Wilson,
	Nelson Chu, Kito Cheng
  Cc: binutils

From: Tsukasa OI <research_trasio@irq.a4lg.com>

This commit adds support for 'Zicntr' and 'Zihpm' extensions (version 2.0).

However, because GNU Binutils handled those as a part of 'I' and there was
a time when a ratified specification did split counters from the 'I'
extension without separate extension names, we need to take care of
possible compatibility issues.

So, if 'Zicntr' pseudoinstructions are used without that extension,
it generates not an error but a warning.

bfd/ChangeLog:

	* elfxx-riscv.c (riscv_implicit_subsets): Add implications related
	to counter extensions.
	(riscv_supported_std_z_ext): Add 'Zicntr' and 'Zihpm' extensions.
	Define default versions of 'Zicsr' and 'Zifencei' on the draft ISA
	because they might be used on the 'E' extension handling.
	(riscv_is_subset_of_i_2p0): New function.
	(riscv_parse_add_subset): If a subset of the 'I' extension version
	2.0 is being added, check the version of 'I' and allow its version
	unknown when the 'I' extension version is less than 2.1.
	(riscv_multi_subset_supports, riscv_multi_subset_supports_ext):
	Add support for the 'Zicntr' extension with compatibility measure.

gas/ChangeLog:

	* config/tc-riscv.c (enum riscv_csr_class): Add new CSR classes
	corresponding 'Zicntr' and 'Zihpm' extensions.
	(riscv_csr_address): Add handling for new CSR classes.
	(riscv_ip): Raise a warning if a 'Zicntr' pseudoinstruction is
	used without that extension.
	* testsuite/gas/riscv/csr-insns-pseudo.s: Rename section names
	to indicate that the extension 'Zicntr' is needed.
	* testsuite/gas/riscv/csr-insns-pseudo.d: Add "zicntr" to arch.
	* testsuite/gas/riscv/csr-insns-pseudo-noalias.d: Likewise.
	* testsuite/gas/riscv/csr-insns-pseudo-zfinx.d: Likewise.
	* testsuite/gas/riscv/csr-insns-read-only.d: Likewise.
	* testsuite/gas/riscv/csr-version-1p9p1.l: Add warnings regarding
	'Zicntr' and 'Zihpm' extension recategorization.
	* testsuite/gas/riscv/csr-version-1p10.l: Likewise.
	* testsuite/gas/riscv/csr-version-1p11.l: Likewise.
	* testsuite/gas/riscv/csr-version-1p12.l: Likewise.
	* testsuite/gas/riscv/csr-insns-pseudo-nozicntr.d: New test to
	see warnings are generated when the 'Zicntr' extension is not
	specified.
	* testsuite/gas/riscv/csr-insns-pseudo-nozicntr.l: Likewise.

include/ChangeLog:

	* opcode/riscv-opc.h: Recategorize user counter CSRs.
	* opcode/riscv.h (enum riscv_insn_class): Add INSN_CLASS_ZICNTR
	for 'Zicntr' pseudoinstructions.

opcodes/ChangeLog:

	* riscv-opc.c (riscv_opcodes): Recategorize counter
	pseudoinstructions to the 'Zicntr' extension.
---
 bfd/elfxx-riscv.c                             |  52 +++-
 gas/config/tc-riscv.c                         |  25 ++
 .../gas/riscv/csr-insns-pseudo-noalias.d      |   2 +-
 .../gas/riscv/csr-insns-pseudo-nozicntr.d     |  37 +++
 .../gas/riscv/csr-insns-pseudo-nozicntr.l     |   7 +
 .../gas/riscv/csr-insns-pseudo-zfinx.d        |   2 +-
 gas/testsuite/gas/riscv/csr-insns-pseudo.d    |   2 +-
 gas/testsuite/gas/riscv/csr-insns-pseudo.s    |   3 +-
 gas/testsuite/gas/riscv/csr-insns-read-only.d |   2 +-
 gas/testsuite/gas/riscv/csr-version-1p10.l    | 256 ++++++++++++++++++
 gas/testsuite/gas/riscv/csr-version-1p11.l    | 256 ++++++++++++++++++
 gas/testsuite/gas/riscv/csr-version-1p12.l    | 256 ++++++++++++++++++
 gas/testsuite/gas/riscv/csr-version-1p9p1.l   | 256 ++++++++++++++++++
 include/opcode/riscv-opc.h                    | 128 ++++-----
 include/opcode/riscv.h                        |   1 +
 opcodes/riscv-opc.c                           |  12 +-
 16 files changed, 1217 insertions(+), 80 deletions(-)
 create mode 100644 gas/testsuite/gas/riscv/csr-insns-pseudo-nozicntr.d
 create mode 100644 gas/testsuite/gas/riscv/csr-insns-pseudo-nozicntr.l

diff --git a/bfd/elfxx-riscv.c b/bfd/elfxx-riscv.c
index c070394a3667..446cc6128bab 100644
--- a/bfd/elfxx-riscv.c
+++ b/bfd/elfxx-riscv.c
@@ -1097,6 +1097,8 @@ static struct riscv_implicit_subset riscv_implicit_subsets[] =
   {"e", "i",		check_implicit_always},
   {"i", "zicsr",	check_implicit_for_i},
   {"i", "zifencei",	check_implicit_for_i},
+  {"i", "zicntr",	check_implicit_for_i},
+  {"i", "zihpm",	check_implicit_for_i},
   {"g", "i",		check_implicit_always},
   {"g", "m",		check_implicit_always},
   {"g", "a",		check_implicit_always},
@@ -1148,6 +1150,8 @@ static struct riscv_implicit_subset riscv_implicit_subsets[] =
   {"zhinx", "zhinxmin",	check_implicit_always},
   {"zhinxmin", "zfinx",	check_implicit_always},
   {"zfinx", "zicsr",	check_implicit_always},
+  {"zicntr", "zicsr",	check_implicit_always},
+  {"zihpm", "zicsr",	check_implicit_always},
   {"zk", "zkn",		check_implicit_always},
   {"zk", "zkr",		check_implicit_always},
   {"zk", "zkt",		check_implicit_always},
@@ -1251,13 +1255,17 @@ static struct riscv_supported_ext riscv_supported_std_z_ext[] =
   {"zicbom",		ISA_SPEC_CLASS_DRAFT,		1, 0,  0 },
   {"zicbop",		ISA_SPEC_CLASS_DRAFT,		1, 0,  0 },
   {"zicboz",		ISA_SPEC_CLASS_DRAFT,		1, 0,  0 },
+  {"zicntr",		ISA_SPEC_CLASS_DRAFT,		2, 0,  0 },
   {"zicond",		ISA_SPEC_CLASS_DRAFT,		1, 0,  0 },
   {"zicsr",		ISA_SPEC_CLASS_20191213,	2, 0,  0 },
   {"zicsr",		ISA_SPEC_CLASS_20190608,	2, 0,  0 },
+  {"zicsr",		ISA_SPEC_CLASS_DRAFT,		2, 0,  0 },
   {"zifencei",		ISA_SPEC_CLASS_20191213,	2, 0,  0 },
   {"zifencei",		ISA_SPEC_CLASS_20190608,	2, 0,  0 },
+  {"zifencei",		ISA_SPEC_CLASS_DRAFT,		2, 0,  0 },
   {"zihintntl",		ISA_SPEC_CLASS_DRAFT,		1, 0,  0 },
   {"zihintpause",	ISA_SPEC_CLASS_DRAFT,		2, 0,  0 },
+  {"zihpm",		ISA_SPEC_CLASS_DRAFT,		2, 0,  0 },
   {"zmmul",		ISA_SPEC_CLASS_DRAFT,		1, 0,  0 },
   {"zawrs",		ISA_SPEC_CLASS_DRAFT,		1, 0,  0 },
   {"zfa",		ISA_SPEC_CLASS_DRAFT,		0, 1,  0 },
@@ -1649,6 +1657,18 @@ riscv_get_default_ext_version (enum riscv_spec_class *default_isa_spec,
     }
 }
 
+/* Check if the subset is one of the extensions split from
+   the 'I' extension version 2.0.  */
+
+static bool
+riscv_is_subset_of_i_2p0 (const char *subset)
+{
+  return (strcmp (subset, "zicsr") == 0
+	  || strcmp (subset, "zifencei") == 0
+	  || strcmp (subset, "zicntr") == 0
+	  || strcmp (subset, "zihpm") == 0);
+}
+
 /* Find the default versions for the extension before adding them to
    the subset list, if their versions are RISCV_UNKNOWN_VERSION.
    Afterwards, report errors if we can not find their default versions.  */
@@ -1662,9 +1682,26 @@ riscv_parse_add_subset (riscv_parse_subset_t *rps,
 {
   int major_version = major;
   int minor_version = minor;
+  bool handle_subset_of_i_2p0 = false;
+
+  /* If a subset of the 'I' extension version 2.0 is being added,
+     check the version of 'I' and allow its version unknown when the
+     'I' extension version is less than 2.1.
+     Draft 'E' is arbitrarily handled since it's a draft but the default
+     handling is the same as 'I' >= 2.1 because non-draft 'E' extension
+     does not have 'I' version 2.0 subsets.  */
+  if (riscv_is_subset_of_i_2p0 (subset))
+    {
+      riscv_subset_t *ext_i;
+      if (riscv_lookup_subset (rps->subset_list, "i", &ext_i)
+	  && (ext_i->major_version < 2
+	      || (ext_i->major_version == 2 && ext_i->minor_version < 1)))
+	handle_subset_of_i_2p0 = true;
+    }
 
-  if (major_version == RISCV_UNKNOWN_VERSION
-       || minor_version == RISCV_UNKNOWN_VERSION)
+  if (!handle_subset_of_i_2p0
+      && (major_version == RISCV_UNKNOWN_VERSION
+	  || minor_version == RISCV_UNKNOWN_VERSION))
     riscv_get_default_ext_version (rps->isa_spec, subset,
 				   &major_version, &minor_version);
 
@@ -1677,9 +1714,9 @@ riscv_parse_add_subset (riscv_parse_subset_t *rps,
 	rps->error_handler
 	  (_("x ISA extension `%s' must be set with the versions"),
 	   subset);
-      /* Allow old ISA spec can recognize zicsr and zifencei.  */
-      else if (strcmp (subset, "zicsr") != 0
-	       && strcmp (subset, "zifencei") != 0)
+      /* Allow old ISA spec (version 2.2) can recognize extensions
+	 effectively split from the base 'I' extension version 2.0.  */
+      else if (!riscv_is_subset_of_i_2p0 (subset))
 	rps->error_handler
 	  (_("cannot find default versions of the ISA extension `%s'"),
 	   subset);
@@ -2389,6 +2426,9 @@ riscv_multi_subset_supports (riscv_parse_subset_t *rps,
       return riscv_subset_supports (rps, "zicbop");
     case INSN_CLASS_ZICBOZ:
       return riscv_subset_supports (rps, "zicboz");
+    case INSN_CLASS_ZICNTR:
+      /* Instead of 'Zicntr', query for 'I' for compatibility.  */
+      return riscv_subset_supports (rps, "i");
     case INSN_CLASS_ZICOND:
       return riscv_subset_supports (rps, "zicond");
     case INSN_CLASS_ZICSR:
@@ -2592,6 +2632,8 @@ riscv_multi_subset_supports_ext (riscv_parse_subset_t *rps,
       return "zicbop";
     case INSN_CLASS_ZICBOZ:
       return "zicboz";
+    case INSN_CLASS_ZICNTR:
+      return "zicntr";
     case INSN_CLASS_ZICOND:
       return "zicond";
     case INSN_CLASS_ZICSR:
diff --git a/gas/config/tc-riscv.c b/gas/config/tc-riscv.c
index 5759d3a5fc4e..aa88cec881e4 100644
--- a/gas/config/tc-riscv.c
+++ b/gas/config/tc-riscv.c
@@ -66,6 +66,10 @@ enum riscv_csr_class
 
   CSR_CLASS_I,
   CSR_CLASS_I_32,	/* rv32 only */
+  CSR_CLASS_ZICNTR,	/* basic hardware perf counter */
+  CSR_CLASS_ZICNTR_32,	/* basic hardware perf counter, rv32 only */
+  CSR_CLASS_ZIHPM,	/* additional hardware perf counter */
+  CSR_CLASS_ZIHPM_32,	/* additional hardware perf counter, rv32 only */
   CSR_CLASS_F,		/* f-ext only */
   CSR_CLASS_ZKR,	/* zkr only */
   CSR_CLASS_V,		/* rvv only */
@@ -1033,6 +1037,18 @@ riscv_csr_address (const char *csr_name,
       need_check_version = true;
       extension = "i";
       break;
+    case CSR_CLASS_ZICNTR_32:
+      is_rv32_only = true;
+      /* Fall through.  */
+    case CSR_CLASS_ZICNTR:
+      extension = "zicntr";
+      break;
+    case CSR_CLASS_ZIHPM_32:
+      is_rv32_only = true;
+      /* Fall through.  */
+    case CSR_CLASS_ZIHPM:
+      extension = "zihpm";
+      break;
     case CSR_CLASS_H_32:
       is_rv32_only = true;
       /* Fall through.  */
@@ -2611,6 +2627,15 @@ riscv_ip (char *str, struct riscv_cl_insn *ip, expressionS *imm_expr,
 		      insn_with_csr = false;
 		    }
 
+		  /* Check if we are using a 'Zicntr' pseudoinstruction
+		     without the 'Zicntr' extension.  */
+		  if (insn->insn_class == INSN_CLASS_ZICNTR
+		      && !riscv_subset_supports (&riscv_rps_as, "zicntr"))
+		    {
+		      as_warn (_("`%s' needs `zicntr' extension"),
+			       insn->name);
+		    }
+
 		  /* The (segmant) load and store with EEW 64 cannot be used
 		     when zve32x is enabled.  */
 		  if (ip->insn_mo->pinfo & INSN_V_EEW64
diff --git a/gas/testsuite/gas/riscv/csr-insns-pseudo-noalias.d b/gas/testsuite/gas/riscv/csr-insns-pseudo-noalias.d
index b9300cea6f9f..36a0db4d379e 100644
--- a/gas/testsuite/gas/riscv/csr-insns-pseudo-noalias.d
+++ b/gas/testsuite/gas/riscv/csr-insns-pseudo-noalias.d
@@ -1,5 +1,5 @@
 #source: csr-insns-pseudo.s
-#as: -march=rv32if
+#as: -march=rv32if_zicntr
 #objdump: -dr -Mno-aliases
 
 .*:[ 	]+file format .*
diff --git a/gas/testsuite/gas/riscv/csr-insns-pseudo-nozicntr.d b/gas/testsuite/gas/riscv/csr-insns-pseudo-nozicntr.d
new file mode 100644
index 000000000000..482b62301508
--- /dev/null
+++ b/gas/testsuite/gas/riscv/csr-insns-pseudo-nozicntr.d
@@ -0,0 +1,37 @@
+#source: csr-insns-pseudo.s
+#as: -march=rv32if
+#warning_output: csr-insns-pseudo-nozicntr.l
+#objdump: -dr
+
+.*:[ 	]+file format .*
+
+
+Disassembly of section .text:
+
+0+000 <pseudo_csr_insn>:
+[ 	]+[0-9a-f]+:[ 	]+000022f3[ 	]+csrr[ 	]+t0,ustatus
+[ 	]+[0-9a-f]+:[ 	]+00029073[ 	]+csrw[ 	]+ustatus,t0
+[ 	]+[0-9a-f]+:[ 	]+0002a073[ 	]+csrs[ 	]+ustatus,t0
+[ 	]+[0-9a-f]+:[ 	]+0002b073[ 	]+csrc[ 	]+ustatus,t0
+[ 	]+[0-9a-f]+:[ 	]+000fd073[ 	]+csrwi[ 	]+ustatus,31
+[ 	]+[0-9a-f]+:[ 	]+000fe073[ 	]+csrsi[ 	]+ustatus,31
+[ 	]+[0-9a-f]+:[ 	]+000ff073[ 	]+csrci[ 	]+ustatus,31
+[ 	]+[0-9a-f]+:[ 	]+c00022f3[ 	]+rdcycle[ 	]+t0
+[ 	]+[0-9a-f]+:[ 	]+c01022f3[ 	]+rdtime[ 	]+t0
+[ 	]+[0-9a-f]+:[ 	]+c02022f3[ 	]+rdinstret[ 	]+t0
+[ 	]+[0-9a-f]+:[ 	]+c80022f3[ 	]+rdcycleh[ 	]+t0
+[ 	]+[0-9a-f]+:[ 	]+c81022f3[ 	]+rdtimeh[ 	]+t0
+[ 	]+[0-9a-f]+:[ 	]+c82022f3[ 	]+rdinstreth[ 	]+t0
+[ 	]+[0-9a-f]+:[ 	]+003022f3[ 	]+frcsr[ 	]+t0
+[ 	]+[0-9a-f]+:[ 	]+003392f3[ 	]+fscsr[ 	]+t0,t2
+[ 	]+[0-9a-f]+:[ 	]+00339073[ 	]+fscsr[ 	]+t2
+[ 	]+[0-9a-f]+:[ 	]+002022f3[ 	]+frrm[ 	]+t0
+[ 	]+[0-9a-f]+:[ 	]+002312f3[ 	]+fsrm[ 	]+t0,t1
+[ 	]+[0-9a-f]+:[ 	]+00231073[ 	]+fsrm[ 	]+t1
+[ 	]+[0-9a-f]+:[ 	]+002fd2f3[ 	]+fsrmi[ 	]+t0,31
+[ 	]+[0-9a-f]+:[ 	]+002fd073[ 	]+fsrmi[ 	]+zero,31
+[ 	]+[0-9a-f]+:[ 	]+001022f3[ 	]+frflags[ 	]+t0
+[ 	]+[0-9a-f]+:[ 	]+001312f3[ 	]+fsflags[ 	]+t0,t1
+[ 	]+[0-9a-f]+:[ 	]+00131073[ 	]+fsflags[ 	]+t1
+[ 	]+[0-9a-f]+:[ 	]+001fd2f3[ 	]+fsflagsi[ 	]+t0,31
+[ 	]+[0-9a-f]+:[ 	]+001fd073[ 	]+fsflagsi[ 	]+zero,31
diff --git a/gas/testsuite/gas/riscv/csr-insns-pseudo-nozicntr.l b/gas/testsuite/gas/riscv/csr-insns-pseudo-nozicntr.l
new file mode 100644
index 000000000000..457499f82713
--- /dev/null
+++ b/gas/testsuite/gas/riscv/csr-insns-pseudo-nozicntr.l
@@ -0,0 +1,7 @@
+.*Assembler messages:
+.*Warning: `rdcycle' needs `zicntr' extension
+.*Warning: `rdtime' needs `zicntr' extension
+.*Warning: `rdinstret' needs `zicntr' extension
+.*Warning: `rdcycleh' needs `zicntr' extension
+.*Warning: `rdtimeh' needs `zicntr' extension
+.*Warning: `rdinstreth' needs `zicntr' extension
diff --git a/gas/testsuite/gas/riscv/csr-insns-pseudo-zfinx.d b/gas/testsuite/gas/riscv/csr-insns-pseudo-zfinx.d
index 6e86398cf7b6..52a4f4d8d2ed 100644
--- a/gas/testsuite/gas/riscv/csr-insns-pseudo-zfinx.d
+++ b/gas/testsuite/gas/riscv/csr-insns-pseudo-zfinx.d
@@ -1,5 +1,5 @@
 #source: csr-insns-pseudo.s
-#as: -march=rv32i_zfinx
+#as: -march=rv32i_zicntr_zfinx
 #objdump: -dr
 
 .*:[ 	]+file format .*
diff --git a/gas/testsuite/gas/riscv/csr-insns-pseudo.d b/gas/testsuite/gas/riscv/csr-insns-pseudo.d
index 3df7b4b112af..cdb72152e8c9 100644
--- a/gas/testsuite/gas/riscv/csr-insns-pseudo.d
+++ b/gas/testsuite/gas/riscv/csr-insns-pseudo.d
@@ -1,5 +1,5 @@
 #source: csr-insns-pseudo.s
-#as: -march=rv32if
+#as: -march=rv32if_zicntr
 #objdump: -dr
 
 .*:[ 	]+file format .*
diff --git a/gas/testsuite/gas/riscv/csr-insns-pseudo.s b/gas/testsuite/gas/riscv/csr-insns-pseudo.s
index 8efaa4eadd98..01adff70294a 100644
--- a/gas/testsuite/gas/riscv/csr-insns-pseudo.s
+++ b/gas/testsuite/gas/riscv/csr-insns-pseudo.s
@@ -8,11 +8,12 @@ pseudo_csr_insn:
 	csrsi 0x0, 31
 	csrci 0x0, 31
 
+	# Zicntr
 	rdcycle t0
 	rdtime t0
 	rdinstret t0
 
-	# rv32i-ext
+	# Zicntr (RV32)
 	rdcycleh t0
 	rdtimeh t0
 	rdinstreth t0
diff --git a/gas/testsuite/gas/riscv/csr-insns-read-only.d b/gas/testsuite/gas/riscv/csr-insns-read-only.d
index 6b3549b875ac..1a7e2caddf10 100644
--- a/gas/testsuite/gas/riscv/csr-insns-read-only.d
+++ b/gas/testsuite/gas/riscv/csr-insns-read-only.d
@@ -1,3 +1,3 @@
-#as: -march=rv32if -mcsr-check -mpriv-spec=1.11
+#as: -march=rv32if_zicntr -mcsr-check -mpriv-spec=1.11
 #source: csr-insns-read-only.s
 #warning_output: csr-insns-read-only.l
diff --git a/gas/testsuite/gas/riscv/csr-version-1p10.l b/gas/testsuite/gas/riscv/csr-version-1p10.l
index 054179a416db..d0cc295d3900 100644
--- a/gas/testsuite/gas/riscv/csr-version-1p10.l
+++ b/gas/testsuite/gas/riscv/csr-version-1p10.l
@@ -1,258 +1,514 @@
 .*Assembler messages:
+.*Warning: invalid CSR `cycle', needs `zicntr' extension
+.*Info: macro .*
+.*Warning: invalid CSR `cycle', needs `zicntr' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw cycle,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `time', needs `zicntr' extension
+.*Info: macro .*
+.*Warning: invalid CSR `time', needs `zicntr' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw time,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `instret', needs `zicntr' extension
+.*Info: macro .*
+.*Warning: invalid CSR `instret', needs `zicntr' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw instret,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter3', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter3', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter3,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter4', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter4', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter4,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter5', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter5', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter5,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter6', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter6', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter6,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter7', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter7', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter7,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter8', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter8', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter8,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter9', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter9', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter9,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter10', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter10', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter10,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter11', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter11', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter11,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter12', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter12', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter12,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter13', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter13', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter13,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter14', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter14', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter14,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter15', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter15', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter15,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter16', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter16', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter16,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter17', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter17', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter17,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter18', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter18', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter18,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter19', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter19', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter19,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter20', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter20', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter20,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter21', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter21', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter21,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter22', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter22', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter22,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter23', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter23', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter23,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter24', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter24', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter24,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter25', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter25', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter25,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter26', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter26', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter26,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter27', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter27', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter27,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter28', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter28', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter28,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter29', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter29', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter29,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter30', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter30', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter30,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter31', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter31', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter31,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `cycleh', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `cycleh', needs `zicntr' extension
+.*Info: macro .*
 .*Warning: invalid CSR `cycleh', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `cycleh', needs `zicntr' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw cycleh,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `timeh', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `timeh', needs `zicntr' extension
+.*Info: macro .*
 .*Warning: invalid CSR `timeh', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `timeh', needs `zicntr' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw timeh,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `instreth', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `instreth', needs `zicntr' extension
+.*Info: macro .*
 .*Warning: invalid CSR `instreth', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `instreth', needs `zicntr' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw instreth,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter3h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter3h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter3h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter3h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter3h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter4h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter4h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter4h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter4h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter4h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter5h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter5h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter5h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter5h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter5h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter6h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter6h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter6h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter6h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter6h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter7h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter7h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter7h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter7h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter7h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter8h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter8h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter8h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter8h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter8h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter9h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter9h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter9h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter9h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter9h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter10h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter10h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter10h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter10h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter10h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter11h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter11h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter11h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter11h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter11h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter12h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter12h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter12h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter12h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter12h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter13h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter13h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter13h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter13h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter13h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter14h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter14h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter14h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter14h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter14h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter15h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter15h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter15h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter15h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter15h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter16h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter16h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter16h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter16h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter16h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter17h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter17h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter17h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter17h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter17h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter18h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter18h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter18h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter18h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter18h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter19h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter19h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter19h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter19h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter19h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter20h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter20h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter20h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter20h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter20h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter21h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter21h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter21h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter21h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter21h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter22h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter22h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter22h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter22h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter22h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter23h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter23h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter23h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter23h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter23h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter24h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter24h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter24h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter24h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter24h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter25h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter25h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter25h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter25h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter25h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter26h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter26h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter26h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter26h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter26h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter27h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter27h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter27h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter27h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter27h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter28h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter28h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter28h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter28h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter28h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter29h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter29h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter29h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter29h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter29h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter30h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter30h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter30h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter30h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter30h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter31h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter31h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter31h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter31h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter31h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `senvcfg' for the privileged spec `1.10'
diff --git a/gas/testsuite/gas/riscv/csr-version-1p11.l b/gas/testsuite/gas/riscv/csr-version-1p11.l
index cc365f1df415..4765f61c72b3 100644
--- a/gas/testsuite/gas/riscv/csr-version-1p11.l
+++ b/gas/testsuite/gas/riscv/csr-version-1p11.l
@@ -1,258 +1,514 @@
 .*Assembler messages:
+.*Warning: invalid CSR `cycle', needs `zicntr' extension
+.*Info: macro .*
+.*Warning: invalid CSR `cycle', needs `zicntr' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw cycle,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `time', needs `zicntr' extension
+.*Info: macro .*
+.*Warning: invalid CSR `time', needs `zicntr' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw time,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `instret', needs `zicntr' extension
+.*Info: macro .*
+.*Warning: invalid CSR `instret', needs `zicntr' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw instret,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter3', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter3', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter3,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter4', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter4', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter4,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter5', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter5', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter5,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter6', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter6', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter6,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter7', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter7', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter7,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter8', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter8', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter8,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter9', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter9', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter9,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter10', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter10', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter10,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter11', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter11', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter11,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter12', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter12', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter12,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter13', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter13', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter13,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter14', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter14', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter14,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter15', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter15', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter15,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter16', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter16', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter16,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter17', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter17', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter17,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter18', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter18', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter18,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter19', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter19', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter19,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter20', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter20', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter20,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter21', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter21', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter21,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter22', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter22', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter22,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter23', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter23', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter23,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter24', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter24', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter24,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter25', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter25', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter25,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter26', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter26', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter26,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter27', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter27', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter27,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter28', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter28', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter28,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter29', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter29', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter29,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter30', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter30', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter30,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter31', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter31', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter31,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `cycleh', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `cycleh', needs `zicntr' extension
+.*Info: macro .*
 .*Warning: invalid CSR `cycleh', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `cycleh', needs `zicntr' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw cycleh,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `timeh', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `timeh', needs `zicntr' extension
+.*Info: macro .*
 .*Warning: invalid CSR `timeh', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `timeh', needs `zicntr' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw timeh,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `instreth', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `instreth', needs `zicntr' extension
+.*Info: macro .*
 .*Warning: invalid CSR `instreth', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `instreth', needs `zicntr' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw instreth,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter3h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter3h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter3h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter3h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter3h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter4h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter4h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter4h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter4h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter4h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter5h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter5h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter5h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter5h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter5h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter6h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter6h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter6h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter6h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter6h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter7h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter7h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter7h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter7h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter7h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter8h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter8h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter8h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter8h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter8h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter9h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter9h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter9h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter9h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter9h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter10h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter10h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter10h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter10h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter10h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter11h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter11h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter11h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter11h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter11h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter12h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter12h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter12h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter12h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter12h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter13h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter13h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter13h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter13h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter13h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter14h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter14h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter14h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter14h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter14h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter15h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter15h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter15h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter15h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter15h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter16h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter16h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter16h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter16h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter16h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter17h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter17h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter17h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter17h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter17h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter18h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter18h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter18h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter18h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter18h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter19h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter19h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter19h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter19h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter19h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter20h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter20h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter20h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter20h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter20h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter21h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter21h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter21h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter21h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter21h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter22h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter22h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter22h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter22h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter22h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter23h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter23h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter23h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter23h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter23h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter24h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter24h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter24h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter24h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter24h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter25h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter25h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter25h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter25h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter25h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter26h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter26h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter26h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter26h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter26h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter27h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter27h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter27h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter27h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter27h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter28h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter28h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter28h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter28h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter28h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter29h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter29h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter29h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter29h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter29h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter30h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter30h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter30h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter30h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter30h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter31h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter31h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter31h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter31h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter31h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `senvcfg' for the privileged spec `1.11'
diff --git a/gas/testsuite/gas/riscv/csr-version-1p12.l b/gas/testsuite/gas/riscv/csr-version-1p12.l
index 7a7f5f717c52..c1fe4b062631 100644
--- a/gas/testsuite/gas/riscv/csr-version-1p12.l
+++ b/gas/testsuite/gas/riscv/csr-version-1p12.l
@@ -1,258 +1,514 @@
 .*Assembler messages:
+.*Warning: invalid CSR `cycle', needs `zicntr' extension
+.*Info: macro .*
+.*Warning: invalid CSR `cycle', needs `zicntr' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw cycle,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `time', needs `zicntr' extension
+.*Info: macro .*
+.*Warning: invalid CSR `time', needs `zicntr' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw time,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `instret', needs `zicntr' extension
+.*Info: macro .*
+.*Warning: invalid CSR `instret', needs `zicntr' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw instret,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter3', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter3', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter3,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter4', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter4', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter4,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter5', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter5', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter5,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter6', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter6', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter6,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter7', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter7', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter7,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter8', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter8', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter8,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter9', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter9', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter9,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter10', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter10', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter10,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter11', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter11', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter11,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter12', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter12', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter12,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter13', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter13', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter13,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter14', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter14', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter14,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter15', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter15', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter15,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter16', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter16', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter16,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter17', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter17', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter17,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter18', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter18', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter18,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter19', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter19', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter19,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter20', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter20', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter20,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter21', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter21', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter21,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter22', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter22', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter22,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter23', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter23', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter23,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter24', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter24', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter24,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter25', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter25', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter25,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter26', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter26', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter26,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter27', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter27', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter27,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter28', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter28', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter28,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter29', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter29', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter29,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter30', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter30', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter30,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter31', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter31', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter31,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `cycleh', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `cycleh', needs `zicntr' extension
+.*Info: macro .*
 .*Warning: invalid CSR `cycleh', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `cycleh', needs `zicntr' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw cycleh,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `timeh', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `timeh', needs `zicntr' extension
+.*Info: macro .*
 .*Warning: invalid CSR `timeh', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `timeh', needs `zicntr' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw timeh,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `instreth', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `instreth', needs `zicntr' extension
+.*Info: macro .*
 .*Warning: invalid CSR `instreth', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `instreth', needs `zicntr' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw instreth,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter3h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter3h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter3h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter3h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter3h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter4h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter4h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter4h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter4h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter4h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter5h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter5h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter5h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter5h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter5h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter6h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter6h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter6h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter6h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter6h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter7h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter7h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter7h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter7h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter7h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter8h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter8h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter8h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter8h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter8h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter9h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter9h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter9h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter9h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter9h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter10h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter10h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter10h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter10h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter10h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter11h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter11h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter11h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter11h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter11h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter12h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter12h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter12h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter12h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter12h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter13h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter13h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter13h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter13h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter13h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter14h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter14h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter14h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter14h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter14h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter15h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter15h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter15h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter15h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter15h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter16h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter16h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter16h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter16h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter16h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter17h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter17h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter17h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter17h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter17h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter18h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter18h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter18h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter18h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter18h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter19h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter19h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter19h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter19h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter19h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter20h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter20h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter20h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter20h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter20h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter21h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter21h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter21h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter21h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter21h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter22h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter22h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter22h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter22h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter22h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter23h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter23h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter23h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter23h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter23h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter24h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter24h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter24h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter24h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter24h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter25h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter25h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter25h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter25h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter25h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter26h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter26h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter26h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter26h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter26h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter27h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter27h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter27h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter27h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter27h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter28h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter28h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter28h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter28h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter28h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter29h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter29h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter29h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter29h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter29h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter30h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter30h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter30h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter30h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter30h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter31h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter31h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter31h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter31h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter31h,a1'
 .*Info: macro .*
 .*Warning: read-only CSR is written `csrw mvendorid,a1'
diff --git a/gas/testsuite/gas/riscv/csr-version-1p9p1.l b/gas/testsuite/gas/riscv/csr-version-1p9p1.l
index 7fcd73ab7ddd..4a42f0d5f272 100644
--- a/gas/testsuite/gas/riscv/csr-version-1p9p1.l
+++ b/gas/testsuite/gas/riscv/csr-version-1p9p1.l
@@ -1,258 +1,514 @@
 .*Assembler messages:
+.*Warning: invalid CSR `cycle', needs `zicntr' extension
+.*Info: macro .*
+.*Warning: invalid CSR `cycle', needs `zicntr' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw cycle,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `time', needs `zicntr' extension
+.*Info: macro .*
+.*Warning: invalid CSR `time', needs `zicntr' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw time,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `instret', needs `zicntr' extension
+.*Info: macro .*
+.*Warning: invalid CSR `instret', needs `zicntr' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw instret,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter3', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter3', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter3,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter4', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter4', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter4,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter5', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter5', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter5,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter6', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter6', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter6,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter7', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter7', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter7,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter8', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter8', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter8,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter9', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter9', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter9,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter10', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter10', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter10,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter11', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter11', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter11,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter12', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter12', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter12,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter13', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter13', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter13,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter14', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter14', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter14,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter15', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter15', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter15,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter16', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter16', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter16,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter17', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter17', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter17,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter18', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter18', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter18,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter19', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter19', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter19,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter20', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter20', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter20,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter21', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter21', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter21,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter22', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter22', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter22,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter23', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter23', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter23,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter24', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter24', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter24,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter25', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter25', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter25,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter26', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter26', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter26,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter27', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter27', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter27,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter28', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter28', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter28,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter29', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter29', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter29,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter30', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter30', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter30,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter31', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter31', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter31,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `cycleh', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `cycleh', needs `zicntr' extension
+.*Info: macro .*
 .*Warning: invalid CSR `cycleh', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `cycleh', needs `zicntr' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw cycleh,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `timeh', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `timeh', needs `zicntr' extension
+.*Info: macro .*
 .*Warning: invalid CSR `timeh', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `timeh', needs `zicntr' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw timeh,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `instreth', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `instreth', needs `zicntr' extension
+.*Info: macro .*
 .*Warning: invalid CSR `instreth', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `instreth', needs `zicntr' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw instreth,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter3h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter3h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter3h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter3h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter3h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter4h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter4h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter4h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter4h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter4h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter5h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter5h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter5h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter5h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter5h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter6h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter6h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter6h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter6h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter6h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter7h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter7h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter7h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter7h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter7h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter8h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter8h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter8h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter8h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter8h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter9h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter9h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter9h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter9h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter9h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter10h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter10h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter10h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter10h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter10h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter11h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter11h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter11h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter11h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter11h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter12h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter12h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter12h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter12h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter12h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter13h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter13h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter13h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter13h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter13h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter14h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter14h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter14h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter14h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter14h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter15h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter15h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter15h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter15h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter15h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter16h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter16h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter16h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter16h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter16h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter17h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter17h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter17h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter17h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter17h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter18h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter18h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter18h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter18h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter18h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter19h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter19h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter19h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter19h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter19h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter20h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter20h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter20h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter20h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter20h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter21h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter21h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter21h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter21h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter21h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter22h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter22h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter22h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter22h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter22h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter23h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter23h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter23h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter23h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter23h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter24h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter24h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter24h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter24h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter24h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter25h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter25h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter25h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter25h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter25h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter26h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter26h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter26h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter26h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter26h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter27h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter27h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter27h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter27h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter27h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter28h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter28h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter28h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter28h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter28h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter29h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter29h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter29h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter29h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter29h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter30h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter30h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter30h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter30h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter30h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter31h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter31h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter31h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter31h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter31h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `scounteren' for the privileged spec `1.9.1'
diff --git a/include/opcode/riscv-opc.h b/include/opcode/riscv-opc.h
index 375483500e2a..dbb061ddf7f9 100644
--- a/include/opcode/riscv-opc.h
+++ b/include/opcode/riscv-opc.h
@@ -3558,70 +3558,70 @@ DECLARE_INSN(vt_maskcn, MATCH_VT_MASKCN, MASK_VT_MASKCN)
 #endif /* DECLARE_INSN */
 #ifdef DECLARE_CSR
 /* Unprivileged Counter/Timers CSRs.  */
-DECLARE_CSR(cycle, CSR_CYCLE, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(time, CSR_TIME, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(instret, CSR_INSTRET, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(hpmcounter3, CSR_HPMCOUNTER3, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(hpmcounter4, CSR_HPMCOUNTER4, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(hpmcounter5, CSR_HPMCOUNTER5, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(hpmcounter6, CSR_HPMCOUNTER6, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(hpmcounter7, CSR_HPMCOUNTER7, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(hpmcounter8, CSR_HPMCOUNTER8, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(hpmcounter9, CSR_HPMCOUNTER9, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(hpmcounter10, CSR_HPMCOUNTER10, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(hpmcounter11, CSR_HPMCOUNTER11, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(hpmcounter12, CSR_HPMCOUNTER12, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(hpmcounter13, CSR_HPMCOUNTER13, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(hpmcounter14, CSR_HPMCOUNTER14, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(hpmcounter15, CSR_HPMCOUNTER15, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(hpmcounter16, CSR_HPMCOUNTER16, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(hpmcounter17, CSR_HPMCOUNTER17, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(hpmcounter18, CSR_HPMCOUNTER18, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(hpmcounter19, CSR_HPMCOUNTER19, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(hpmcounter20, CSR_HPMCOUNTER20, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(hpmcounter21, CSR_HPMCOUNTER21, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(hpmcounter22, CSR_HPMCOUNTER22, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(hpmcounter23, CSR_HPMCOUNTER23, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(hpmcounter24, CSR_HPMCOUNTER24, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(hpmcounter25, CSR_HPMCOUNTER25, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(hpmcounter26, CSR_HPMCOUNTER26, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(hpmcounter27, CSR_HPMCOUNTER27, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(hpmcounter28, CSR_HPMCOUNTER28, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(hpmcounter29, CSR_HPMCOUNTER29, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(hpmcounter30, CSR_HPMCOUNTER30, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(hpmcounter31, CSR_HPMCOUNTER31, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(cycleh, CSR_CYCLEH, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(timeh, CSR_TIMEH, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(instreth, CSR_INSTRETH, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(hpmcounter3h, CSR_HPMCOUNTER3H, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(hpmcounter4h, CSR_HPMCOUNTER4H, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(hpmcounter5h, CSR_HPMCOUNTER5H, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(hpmcounter6h, CSR_HPMCOUNTER6H, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(hpmcounter7h, CSR_HPMCOUNTER7H, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(hpmcounter8h, CSR_HPMCOUNTER8H, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(hpmcounter9h, CSR_HPMCOUNTER9H, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(hpmcounter10h, CSR_HPMCOUNTER10H, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(hpmcounter11h, CSR_HPMCOUNTER11H, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(hpmcounter12h, CSR_HPMCOUNTER12H, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(hpmcounter13h, CSR_HPMCOUNTER13H, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(hpmcounter14h, CSR_HPMCOUNTER14H, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(hpmcounter15h, CSR_HPMCOUNTER15H, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(hpmcounter16h, CSR_HPMCOUNTER16H, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(hpmcounter17h, CSR_HPMCOUNTER17H, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(hpmcounter18h, CSR_HPMCOUNTER18H, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(hpmcounter19h, CSR_HPMCOUNTER19H, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(hpmcounter20h, CSR_HPMCOUNTER20H, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(hpmcounter21h, CSR_HPMCOUNTER21H, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(hpmcounter22h, CSR_HPMCOUNTER22H, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(hpmcounter23h, CSR_HPMCOUNTER23H, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(hpmcounter24h, CSR_HPMCOUNTER24H, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(hpmcounter25h, CSR_HPMCOUNTER25H, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(hpmcounter26h, CSR_HPMCOUNTER26H, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(hpmcounter27h, CSR_HPMCOUNTER27H, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(hpmcounter28h, CSR_HPMCOUNTER28H, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(hpmcounter29h, CSR_HPMCOUNTER29H, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(hpmcounter30h, CSR_HPMCOUNTER30H, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(hpmcounter31h, CSR_HPMCOUNTER31H, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
+DECLARE_CSR(cycle, CSR_CYCLE, CSR_CLASS_ZICNTR, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(time, CSR_TIME, CSR_CLASS_ZICNTR, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(instret, CSR_INSTRET, CSR_CLASS_ZICNTR, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(hpmcounter3, CSR_HPMCOUNTER3, CSR_CLASS_ZIHPM, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(hpmcounter4, CSR_HPMCOUNTER4, CSR_CLASS_ZIHPM, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(hpmcounter5, CSR_HPMCOUNTER5, CSR_CLASS_ZIHPM, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(hpmcounter6, CSR_HPMCOUNTER6, CSR_CLASS_ZIHPM, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(hpmcounter7, CSR_HPMCOUNTER7, CSR_CLASS_ZIHPM, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(hpmcounter8, CSR_HPMCOUNTER8, CSR_CLASS_ZIHPM, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(hpmcounter9, CSR_HPMCOUNTER9, CSR_CLASS_ZIHPM, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(hpmcounter10, CSR_HPMCOUNTER10, CSR_CLASS_ZIHPM, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(hpmcounter11, CSR_HPMCOUNTER11, CSR_CLASS_ZIHPM, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(hpmcounter12, CSR_HPMCOUNTER12, CSR_CLASS_ZIHPM, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(hpmcounter13, CSR_HPMCOUNTER13, CSR_CLASS_ZIHPM, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(hpmcounter14, CSR_HPMCOUNTER14, CSR_CLASS_ZIHPM, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(hpmcounter15, CSR_HPMCOUNTER15, CSR_CLASS_ZIHPM, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(hpmcounter16, CSR_HPMCOUNTER16, CSR_CLASS_ZIHPM, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(hpmcounter17, CSR_HPMCOUNTER17, CSR_CLASS_ZIHPM, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(hpmcounter18, CSR_HPMCOUNTER18, CSR_CLASS_ZIHPM, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(hpmcounter19, CSR_HPMCOUNTER19, CSR_CLASS_ZIHPM, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(hpmcounter20, CSR_HPMCOUNTER20, CSR_CLASS_ZIHPM, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(hpmcounter21, CSR_HPMCOUNTER21, CSR_CLASS_ZIHPM, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(hpmcounter22, CSR_HPMCOUNTER22, CSR_CLASS_ZIHPM, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(hpmcounter23, CSR_HPMCOUNTER23, CSR_CLASS_ZIHPM, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(hpmcounter24, CSR_HPMCOUNTER24, CSR_CLASS_ZIHPM, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(hpmcounter25, CSR_HPMCOUNTER25, CSR_CLASS_ZIHPM, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(hpmcounter26, CSR_HPMCOUNTER26, CSR_CLASS_ZIHPM, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(hpmcounter27, CSR_HPMCOUNTER27, CSR_CLASS_ZIHPM, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(hpmcounter28, CSR_HPMCOUNTER28, CSR_CLASS_ZIHPM, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(hpmcounter29, CSR_HPMCOUNTER29, CSR_CLASS_ZIHPM, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(hpmcounter30, CSR_HPMCOUNTER30, CSR_CLASS_ZIHPM, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(hpmcounter31, CSR_HPMCOUNTER31, CSR_CLASS_ZIHPM, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(cycleh, CSR_CYCLEH, CSR_CLASS_ZICNTR_32, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(timeh, CSR_TIMEH, CSR_CLASS_ZICNTR_32, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(instreth, CSR_INSTRETH, CSR_CLASS_ZICNTR_32, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(hpmcounter3h, CSR_HPMCOUNTER3H, CSR_CLASS_ZIHPM_32, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(hpmcounter4h, CSR_HPMCOUNTER4H, CSR_CLASS_ZIHPM_32, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(hpmcounter5h, CSR_HPMCOUNTER5H, CSR_CLASS_ZIHPM_32, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(hpmcounter6h, CSR_HPMCOUNTER6H, CSR_CLASS_ZIHPM_32, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(hpmcounter7h, CSR_HPMCOUNTER7H, CSR_CLASS_ZIHPM_32, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(hpmcounter8h, CSR_HPMCOUNTER8H, CSR_CLASS_ZIHPM_32, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(hpmcounter9h, CSR_HPMCOUNTER9H, CSR_CLASS_ZIHPM_32, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(hpmcounter10h, CSR_HPMCOUNTER10H, CSR_CLASS_ZIHPM_32, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(hpmcounter11h, CSR_HPMCOUNTER11H, CSR_CLASS_ZIHPM_32, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(hpmcounter12h, CSR_HPMCOUNTER12H, CSR_CLASS_ZIHPM_32, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(hpmcounter13h, CSR_HPMCOUNTER13H, CSR_CLASS_ZIHPM_32, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(hpmcounter14h, CSR_HPMCOUNTER14H, CSR_CLASS_ZIHPM_32, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(hpmcounter15h, CSR_HPMCOUNTER15H, CSR_CLASS_ZIHPM_32, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(hpmcounter16h, CSR_HPMCOUNTER16H, CSR_CLASS_ZIHPM_32, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(hpmcounter17h, CSR_HPMCOUNTER17H, CSR_CLASS_ZIHPM_32, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(hpmcounter18h, CSR_HPMCOUNTER18H, CSR_CLASS_ZIHPM_32, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(hpmcounter19h, CSR_HPMCOUNTER19H, CSR_CLASS_ZIHPM_32, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(hpmcounter20h, CSR_HPMCOUNTER20H, CSR_CLASS_ZIHPM_32, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(hpmcounter21h, CSR_HPMCOUNTER21H, CSR_CLASS_ZIHPM_32, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(hpmcounter22h, CSR_HPMCOUNTER22H, CSR_CLASS_ZIHPM_32, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(hpmcounter23h, CSR_HPMCOUNTER23H, CSR_CLASS_ZIHPM_32, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(hpmcounter24h, CSR_HPMCOUNTER24H, CSR_CLASS_ZIHPM_32, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(hpmcounter25h, CSR_HPMCOUNTER25H, CSR_CLASS_ZIHPM_32, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(hpmcounter26h, CSR_HPMCOUNTER26H, CSR_CLASS_ZIHPM_32, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(hpmcounter27h, CSR_HPMCOUNTER27H, CSR_CLASS_ZIHPM_32, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(hpmcounter28h, CSR_HPMCOUNTER28H, CSR_CLASS_ZIHPM_32, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(hpmcounter29h, CSR_HPMCOUNTER29H, CSR_CLASS_ZIHPM_32, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(hpmcounter30h, CSR_HPMCOUNTER30H, CSR_CLASS_ZIHPM_32, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(hpmcounter31h, CSR_HPMCOUNTER31H, CSR_CLASS_ZIHPM_32, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
 /* Privileged Supervisor CSRs.  */
 DECLARE_CSR(sstatus, CSR_SSTATUS, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
 DECLARE_CSR(sie, CSR_SIE, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
diff --git a/include/opcode/riscv.h b/include/opcode/riscv.h
index 93dd5169ebce..847a5a04f5ae 100644
--- a/include/opcode/riscv.h
+++ b/include/opcode/riscv.h
@@ -389,6 +389,7 @@ enum riscv_insn_class
   INSN_CLASS_Q,
   INSN_CLASS_F_AND_C,
   INSN_CLASS_D_AND_C,
+  INSN_CLASS_ZICNTR,
   INSN_CLASS_ZICOND,
   INSN_CLASS_ZICSR,
   INSN_CLASS_ZIFENCEI,
diff --git a/opcodes/riscv-opc.c b/opcodes/riscv-opc.c
index 8e0ae85eb064..5da55ab9e322 100644
--- a/opcodes/riscv-opc.c
+++ b/opcodes/riscv-opc.c
@@ -510,12 +510,12 @@ const struct riscv_opcode riscv_opcodes[] =
 {"fence",       0, INSN_CLASS_I, "P,Q",       MATCH_FENCE, MASK_FENCE|MASK_RD|MASK_RS1|(MASK_IMM & ~MASK_PRED & ~MASK_SUCC), match_opcode, 0 },
 {"fence.i",     0, INSN_CLASS_ZIFENCEI, "",   MATCH_FENCE_I, MASK_FENCE|MASK_RD|MASK_RS1|MASK_IMM, match_opcode, 0 },
 {"fence.tso",   0, INSN_CLASS_I, "",          MATCH_FENCE_TSO, MASK_FENCE_TSO|MASK_RD|MASK_RS1, match_opcode, 0 },
-{"rdcycle",     0, INSN_CLASS_I, "d",         MATCH_RDCYCLE, MASK_RDCYCLE, match_opcode, INSN_ALIAS },
-{"rdinstret",   0, INSN_CLASS_I, "d",         MATCH_RDINSTRET, MASK_RDINSTRET, match_opcode, INSN_ALIAS },
-{"rdtime",      0, INSN_CLASS_I, "d",         MATCH_RDTIME, MASK_RDTIME, match_opcode, INSN_ALIAS },
-{"rdcycleh",   32, INSN_CLASS_I, "d",         MATCH_RDCYCLEH, MASK_RDCYCLEH, match_opcode, INSN_ALIAS },
-{"rdinstreth", 32, INSN_CLASS_I, "d",         MATCH_RDINSTRETH, MASK_RDINSTRETH, match_opcode, INSN_ALIAS },
-{"rdtimeh",    32, INSN_CLASS_I, "d",         MATCH_RDTIMEH, MASK_RDTIMEH, match_opcode, INSN_ALIAS },
+{"rdcycle",     0, INSN_CLASS_ZICNTR, "d",    MATCH_RDCYCLE, MASK_RDCYCLE, match_opcode, INSN_ALIAS },
+{"rdinstret",   0, INSN_CLASS_ZICNTR, "d",    MATCH_RDINSTRET, MASK_RDINSTRET, match_opcode, INSN_ALIAS },
+{"rdtime",      0, INSN_CLASS_ZICNTR, "d",    MATCH_RDTIME, MASK_RDTIME, match_opcode, INSN_ALIAS },
+{"rdcycleh",   32, INSN_CLASS_ZICNTR, "d",    MATCH_RDCYCLEH, MASK_RDCYCLEH, match_opcode, INSN_ALIAS },
+{"rdinstreth", 32, INSN_CLASS_ZICNTR, "d",    MATCH_RDINSTRETH, MASK_RDINSTRETH, match_opcode, INSN_ALIAS },
+{"rdtimeh",    32, INSN_CLASS_ZICNTR, "d",    MATCH_RDTIMEH, MASK_RDTIMEH, match_opcode, INSN_ALIAS },
 {"ecall",       0, INSN_CLASS_I, "",          MATCH_SCALL, MASK_SCALL, match_opcode, 0 },
 {"scall",       0, INSN_CLASS_I, "",          MATCH_SCALL, MASK_SCALL, match_opcode, 0 },
 {"xori",        0, INSN_CLASS_I, "d,s,j",     MATCH_XORI, MASK_XORI, match_opcode, 0 },
-- 
2.42.0


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH v2 0/1] RISC-V: Add 'Zicntr' and 'Zihpm' support with compatibility measures
  2023-10-21  0:45 ` [PATCH 0/1] " Tsukasa OI
  2023-10-21  0:45   ` [PATCH 1/1] " Tsukasa OI
@ 2023-10-21  2:17   ` Tsukasa OI
  2023-10-21  2:17     ` [PATCH v2 1/1] " Tsukasa OI
  1 sibling, 1 reply; 10+ messages in thread
From: Tsukasa OI @ 2023-10-21  2:17 UTC (permalink / raw)
  To: Tsukasa OI, Palmer Dabbelt, Andrew Waterman, Jim Wilson,
	Nelson Chu, Kito Cheng
  Cc: binutils

Hi,

This patch adds support for two extensions, split from the RISC-V
Unprivileged ISA version 2.2:

1.  `Zicntr`
    Basic hardware performance counters
2.  `Zihpm`
    Platform-specific configurable hardware performance counters

but the compatibility is vital.  This patch set tries to deal with the
compatibility issues as possible.


RFC PATCH v1:
<https://sourceware.org/pipermail/binutils/2023-August/128895.html>
PATCH v1 (the implementation is detailed in this cover letter):
<https://sourceware.org/pipermail/binutils/2023-October/130091.html>


PATCH v2 fixes some test failures when compiled with -with-isa-spec=2.2
just like Nelson found some test failures and fixed in the commit
4352c0ac04a6 ("RISC-V: Make sure rv32q conflict won't affect the zfa gas
testcases.").

csr-insns-pseudo-nozicntr.d
    Specified the extension version (without any -misa-spec option)
    to make sure that we test "no subset" behavior on 'I' >= version 2.1.
csr-version-{1p9p1,1p10,1p11,1p12}.d
    Specified the extension versions to make sure that
    we are working on the 'I' >= version 2.1 (also specified the version of
    'Zicsr' but this is only for consistency).
march-imply-i2p0-01.d
    'I' version 2.0 effectively imples 'Zicsr' and 'Zifencei' but should not
    be reflected to the expanded architectural string because features of
    'Zicsr' and 'Zifencei' are parts of 'I' version 2.0.
    This change make sures that we removed the dependency to -misa-spec
    option and the behavior only depends on the version of 'I'
    (despite that -misa-spec=20191213).
march-ok-reorder.d
    Use 'I' version 2.1.  To test ordering of 'Zi*' extensions, PATCH v2
    specifies "zifencei_zicsr" (intentionally reverse of the canonical
    order) to make sure that the expanded architectural string has
    "zicsr2p0_zifencei2p0".

It also fixes a minor grammar error on the commit message.


Thanks,
Tsukasa




Tsukasa OI (1):
  RISC-V: Add 'Zicntr' and 'Zihpm' support with compatibility measures

 bfd/elfxx-riscv.c                             |  52 +++-
 gas/config/tc-riscv.c                         |  25 ++
 .../gas/riscv/csr-insns-pseudo-noalias.d      |   2 +-
 .../gas/riscv/csr-insns-pseudo-nozicntr.d     |  37 +++
 .../gas/riscv/csr-insns-pseudo-nozicntr.l     |   7 +
 .../gas/riscv/csr-insns-pseudo-zfinx.d        |   2 +-
 gas/testsuite/gas/riscv/csr-insns-pseudo.d    |   2 +-
 gas/testsuite/gas/riscv/csr-insns-pseudo.s    |   3 +-
 gas/testsuite/gas/riscv/csr-insns-read-only.d |   2 +-
 gas/testsuite/gas/riscv/csr-version-1p10.d    |   2 +-
 gas/testsuite/gas/riscv/csr-version-1p10.l    | 256 ++++++++++++++++++
 gas/testsuite/gas/riscv/csr-version-1p11.d    |   2 +-
 gas/testsuite/gas/riscv/csr-version-1p11.l    | 256 ++++++++++++++++++
 gas/testsuite/gas/riscv/csr-version-1p12.d    |   2 +-
 gas/testsuite/gas/riscv/csr-version-1p12.l    | 256 ++++++++++++++++++
 gas/testsuite/gas/riscv/csr-version-1p9p1.d   |   2 +-
 gas/testsuite/gas/riscv/csr-version-1p9p1.l   | 256 ++++++++++++++++++
 gas/testsuite/gas/riscv/march-imply-i2p0-01.d |   2 +-
 gas/testsuite/gas/riscv/march-ok-reorder.d    |   4 +-
 include/opcode/riscv-opc.h                    | 128 ++++-----
 include/opcode/riscv.h                        |   1 +
 opcodes/riscv-opc.c                           |  12 +-
 22 files changed, 1224 insertions(+), 87 deletions(-)
 create mode 100644 gas/testsuite/gas/riscv/csr-insns-pseudo-nozicntr.d
 create mode 100644 gas/testsuite/gas/riscv/csr-insns-pseudo-nozicntr.l


base-commit: 0e17d3fc080f543d81e6c2520ba0bd8046ea3a95
-- 
2.42.0


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH v2 1/1] RISC-V: Add 'Zicntr' and 'Zihpm' support with compatibility measures
  2023-10-21  2:17   ` [PATCH v2 0/1] " Tsukasa OI
@ 2023-10-21  2:17     ` Tsukasa OI
  0 siblings, 0 replies; 10+ messages in thread
From: Tsukasa OI @ 2023-10-21  2:17 UTC (permalink / raw)
  To: Tsukasa OI, Palmer Dabbelt, Andrew Waterman, Jim Wilson,
	Nelson Chu, Kito Cheng
  Cc: binutils

From: Tsukasa OI <research_trasio@irq.a4lg.com>

This commit adds support for 'Zicntr' and 'Zihpm' extensions (version 2.0).

However, because GNU Binutils handled those as a part of 'I' and there was
a time when a ratified specification did split counters from the 'I'
extension without separate extension names, we need to take care of
possible compatibility issues.

So, if a 'Zicntr' pseudoinstruction is used without that extension,
it generates not an error but a warning.

bfd/ChangeLog:

	* elfxx-riscv.c (riscv_implicit_subsets): Add implications related
	to counter extensions.
	(riscv_supported_std_z_ext): Add 'Zicntr' and 'Zihpm' extensions.
	Define default versions of 'Zicsr' and 'Zifencei' on the draft ISA
	because they might be used on the 'E' extension handling.
	(riscv_is_subset_of_i_2p0): New function.
	(riscv_parse_add_subset): If a subset of the 'I' extension version
	2.0 is being added, check the version of 'I' and allow its version
	unknown when the 'I' extension version is less than 2.1.
	(riscv_multi_subset_supports, riscv_multi_subset_supports_ext):
	Add support for the 'Zicntr' extension with compatibility measure.

gas/ChangeLog:

	* config/tc-riscv.c (enum riscv_csr_class): Add new CSR classes
	corresponding 'Zicntr' and 'Zihpm' extensions.
	(riscv_csr_address): Add handling for new CSR classes.
	(riscv_ip): Raise a warning if a 'Zicntr' pseudoinstruction is
	used without that extension.
	* testsuite/gas/riscv/csr-insns-pseudo.s: Rename section names
	to indicate that the extension 'Zicntr' is needed.
	* testsuite/gas/riscv/csr-insns-pseudo.d: Add "zicntr" to arch.
	* testsuite/gas/riscv/csr-insns-pseudo-noalias.d: Likewise.
	* testsuite/gas/riscv/csr-insns-pseudo-zfinx.d: Likewise.
	* testsuite/gas/riscv/csr-insns-read-only.d: Likewise.
	* testsuite/gas/riscv/csr-version-1p9p1.d: Specify versions.
	* testsuite/gas/riscv/csr-version-1p10.d: Likewise.
	* testsuite/gas/riscv/csr-version-1p11.d: Likewise.
	* testsuite/gas/riscv/csr-version-1p12.d: Likewise.
	* testsuite/gas/riscv/csr-version-1p9p1.l: Add warnings regarding
	'Zicntr' and 'Zihpm' extension recategorization.
	* testsuite/gas/riscv/csr-version-1p10.l: Likewise.
	* testsuite/gas/riscv/csr-version-1p11.l: Likewise.
	* testsuite/gas/riscv/csr-version-1p12.l: Likewise.
	* testsuite/gas/riscv/march-imply-i2p0-01.d: 'I' version 2.0
	effectively imples 'Zicsr' and 'Zifencei' but should not be
	reflected to the expanded architectural string.
	* testsuite/gas/riscv/march-ok-reorder.d: Use 'I' version 2.1 and
	use other extensions to test proper ordering.
	* testsuite/gas/riscv/csr-insns-pseudo-nozicntr.d: New test to
	see warnings are generated when the 'Zicntr' extension is not
	specified.
	* testsuite/gas/riscv/csr-insns-pseudo-nozicntr.l: Likewise.

include/ChangeLog:

	* opcode/riscv-opc.h: Recategorize user counter CSRs.
	* opcode/riscv.h (enum riscv_insn_class): Add INSN_CLASS_ZICNTR
	for 'Zicntr' pseudoinstructions.

opcodes/ChangeLog:

	* riscv-opc.c (riscv_opcodes): Recategorize counter
	pseudoinstructions to the 'Zicntr' extension.
---
 bfd/elfxx-riscv.c                             |  52 +++-
 gas/config/tc-riscv.c                         |  25 ++
 .../gas/riscv/csr-insns-pseudo-noalias.d      |   2 +-
 .../gas/riscv/csr-insns-pseudo-nozicntr.d     |  37 +++
 .../gas/riscv/csr-insns-pseudo-nozicntr.l     |   7 +
 .../gas/riscv/csr-insns-pseudo-zfinx.d        |   2 +-
 gas/testsuite/gas/riscv/csr-insns-pseudo.d    |   2 +-
 gas/testsuite/gas/riscv/csr-insns-pseudo.s    |   3 +-
 gas/testsuite/gas/riscv/csr-insns-read-only.d |   2 +-
 gas/testsuite/gas/riscv/csr-version-1p10.d    |   2 +-
 gas/testsuite/gas/riscv/csr-version-1p10.l    | 256 ++++++++++++++++++
 gas/testsuite/gas/riscv/csr-version-1p11.d    |   2 +-
 gas/testsuite/gas/riscv/csr-version-1p11.l    | 256 ++++++++++++++++++
 gas/testsuite/gas/riscv/csr-version-1p12.d    |   2 +-
 gas/testsuite/gas/riscv/csr-version-1p12.l    | 256 ++++++++++++++++++
 gas/testsuite/gas/riscv/csr-version-1p9p1.d   |   2 +-
 gas/testsuite/gas/riscv/csr-version-1p9p1.l   | 256 ++++++++++++++++++
 gas/testsuite/gas/riscv/march-imply-i2p0-01.d |   2 +-
 gas/testsuite/gas/riscv/march-ok-reorder.d    |   4 +-
 include/opcode/riscv-opc.h                    | 128 ++++-----
 include/opcode/riscv.h                        |   1 +
 opcodes/riscv-opc.c                           |  12 +-
 22 files changed, 1224 insertions(+), 87 deletions(-)
 create mode 100644 gas/testsuite/gas/riscv/csr-insns-pseudo-nozicntr.d
 create mode 100644 gas/testsuite/gas/riscv/csr-insns-pseudo-nozicntr.l

diff --git a/bfd/elfxx-riscv.c b/bfd/elfxx-riscv.c
index c070394a3667..446cc6128bab 100644
--- a/bfd/elfxx-riscv.c
+++ b/bfd/elfxx-riscv.c
@@ -1097,6 +1097,8 @@ static struct riscv_implicit_subset riscv_implicit_subsets[] =
   {"e", "i",		check_implicit_always},
   {"i", "zicsr",	check_implicit_for_i},
   {"i", "zifencei",	check_implicit_for_i},
+  {"i", "zicntr",	check_implicit_for_i},
+  {"i", "zihpm",	check_implicit_for_i},
   {"g", "i",		check_implicit_always},
   {"g", "m",		check_implicit_always},
   {"g", "a",		check_implicit_always},
@@ -1148,6 +1150,8 @@ static struct riscv_implicit_subset riscv_implicit_subsets[] =
   {"zhinx", "zhinxmin",	check_implicit_always},
   {"zhinxmin", "zfinx",	check_implicit_always},
   {"zfinx", "zicsr",	check_implicit_always},
+  {"zicntr", "zicsr",	check_implicit_always},
+  {"zihpm", "zicsr",	check_implicit_always},
   {"zk", "zkn",		check_implicit_always},
   {"zk", "zkr",		check_implicit_always},
   {"zk", "zkt",		check_implicit_always},
@@ -1251,13 +1255,17 @@ static struct riscv_supported_ext riscv_supported_std_z_ext[] =
   {"zicbom",		ISA_SPEC_CLASS_DRAFT,		1, 0,  0 },
   {"zicbop",		ISA_SPEC_CLASS_DRAFT,		1, 0,  0 },
   {"zicboz",		ISA_SPEC_CLASS_DRAFT,		1, 0,  0 },
+  {"zicntr",		ISA_SPEC_CLASS_DRAFT,		2, 0,  0 },
   {"zicond",		ISA_SPEC_CLASS_DRAFT,		1, 0,  0 },
   {"zicsr",		ISA_SPEC_CLASS_20191213,	2, 0,  0 },
   {"zicsr",		ISA_SPEC_CLASS_20190608,	2, 0,  0 },
+  {"zicsr",		ISA_SPEC_CLASS_DRAFT,		2, 0,  0 },
   {"zifencei",		ISA_SPEC_CLASS_20191213,	2, 0,  0 },
   {"zifencei",		ISA_SPEC_CLASS_20190608,	2, 0,  0 },
+  {"zifencei",		ISA_SPEC_CLASS_DRAFT,		2, 0,  0 },
   {"zihintntl",		ISA_SPEC_CLASS_DRAFT,		1, 0,  0 },
   {"zihintpause",	ISA_SPEC_CLASS_DRAFT,		2, 0,  0 },
+  {"zihpm",		ISA_SPEC_CLASS_DRAFT,		2, 0,  0 },
   {"zmmul",		ISA_SPEC_CLASS_DRAFT,		1, 0,  0 },
   {"zawrs",		ISA_SPEC_CLASS_DRAFT,		1, 0,  0 },
   {"zfa",		ISA_SPEC_CLASS_DRAFT,		0, 1,  0 },
@@ -1649,6 +1657,18 @@ riscv_get_default_ext_version (enum riscv_spec_class *default_isa_spec,
     }
 }
 
+/* Check if the subset is one of the extensions split from
+   the 'I' extension version 2.0.  */
+
+static bool
+riscv_is_subset_of_i_2p0 (const char *subset)
+{
+  return (strcmp (subset, "zicsr") == 0
+	  || strcmp (subset, "zifencei") == 0
+	  || strcmp (subset, "zicntr") == 0
+	  || strcmp (subset, "zihpm") == 0);
+}
+
 /* Find the default versions for the extension before adding them to
    the subset list, if their versions are RISCV_UNKNOWN_VERSION.
    Afterwards, report errors if we can not find their default versions.  */
@@ -1662,9 +1682,26 @@ riscv_parse_add_subset (riscv_parse_subset_t *rps,
 {
   int major_version = major;
   int minor_version = minor;
+  bool handle_subset_of_i_2p0 = false;
+
+  /* If a subset of the 'I' extension version 2.0 is being added,
+     check the version of 'I' and allow its version unknown when the
+     'I' extension version is less than 2.1.
+     Draft 'E' is arbitrarily handled since it's a draft but the default
+     handling is the same as 'I' >= 2.1 because non-draft 'E' extension
+     does not have 'I' version 2.0 subsets.  */
+  if (riscv_is_subset_of_i_2p0 (subset))
+    {
+      riscv_subset_t *ext_i;
+      if (riscv_lookup_subset (rps->subset_list, "i", &ext_i)
+	  && (ext_i->major_version < 2
+	      || (ext_i->major_version == 2 && ext_i->minor_version < 1)))
+	handle_subset_of_i_2p0 = true;
+    }
 
-  if (major_version == RISCV_UNKNOWN_VERSION
-       || minor_version == RISCV_UNKNOWN_VERSION)
+  if (!handle_subset_of_i_2p0
+      && (major_version == RISCV_UNKNOWN_VERSION
+	  || minor_version == RISCV_UNKNOWN_VERSION))
     riscv_get_default_ext_version (rps->isa_spec, subset,
 				   &major_version, &minor_version);
 
@@ -1677,9 +1714,9 @@ riscv_parse_add_subset (riscv_parse_subset_t *rps,
 	rps->error_handler
 	  (_("x ISA extension `%s' must be set with the versions"),
 	   subset);
-      /* Allow old ISA spec can recognize zicsr and zifencei.  */
-      else if (strcmp (subset, "zicsr") != 0
-	       && strcmp (subset, "zifencei") != 0)
+      /* Allow old ISA spec (version 2.2) can recognize extensions
+	 effectively split from the base 'I' extension version 2.0.  */
+      else if (!riscv_is_subset_of_i_2p0 (subset))
 	rps->error_handler
 	  (_("cannot find default versions of the ISA extension `%s'"),
 	   subset);
@@ -2389,6 +2426,9 @@ riscv_multi_subset_supports (riscv_parse_subset_t *rps,
       return riscv_subset_supports (rps, "zicbop");
     case INSN_CLASS_ZICBOZ:
       return riscv_subset_supports (rps, "zicboz");
+    case INSN_CLASS_ZICNTR:
+      /* Instead of 'Zicntr', query for 'I' for compatibility.  */
+      return riscv_subset_supports (rps, "i");
     case INSN_CLASS_ZICOND:
       return riscv_subset_supports (rps, "zicond");
     case INSN_CLASS_ZICSR:
@@ -2592,6 +2632,8 @@ riscv_multi_subset_supports_ext (riscv_parse_subset_t *rps,
       return "zicbop";
     case INSN_CLASS_ZICBOZ:
       return "zicboz";
+    case INSN_CLASS_ZICNTR:
+      return "zicntr";
     case INSN_CLASS_ZICOND:
       return "zicond";
     case INSN_CLASS_ZICSR:
diff --git a/gas/config/tc-riscv.c b/gas/config/tc-riscv.c
index 5759d3a5fc4e..aa88cec881e4 100644
--- a/gas/config/tc-riscv.c
+++ b/gas/config/tc-riscv.c
@@ -66,6 +66,10 @@ enum riscv_csr_class
 
   CSR_CLASS_I,
   CSR_CLASS_I_32,	/* rv32 only */
+  CSR_CLASS_ZICNTR,	/* basic hardware perf counter */
+  CSR_CLASS_ZICNTR_32,	/* basic hardware perf counter, rv32 only */
+  CSR_CLASS_ZIHPM,	/* additional hardware perf counter */
+  CSR_CLASS_ZIHPM_32,	/* additional hardware perf counter, rv32 only */
   CSR_CLASS_F,		/* f-ext only */
   CSR_CLASS_ZKR,	/* zkr only */
   CSR_CLASS_V,		/* rvv only */
@@ -1033,6 +1037,18 @@ riscv_csr_address (const char *csr_name,
       need_check_version = true;
       extension = "i";
       break;
+    case CSR_CLASS_ZICNTR_32:
+      is_rv32_only = true;
+      /* Fall through.  */
+    case CSR_CLASS_ZICNTR:
+      extension = "zicntr";
+      break;
+    case CSR_CLASS_ZIHPM_32:
+      is_rv32_only = true;
+      /* Fall through.  */
+    case CSR_CLASS_ZIHPM:
+      extension = "zihpm";
+      break;
     case CSR_CLASS_H_32:
       is_rv32_only = true;
       /* Fall through.  */
@@ -2611,6 +2627,15 @@ riscv_ip (char *str, struct riscv_cl_insn *ip, expressionS *imm_expr,
 		      insn_with_csr = false;
 		    }
 
+		  /* Check if we are using a 'Zicntr' pseudoinstruction
+		     without the 'Zicntr' extension.  */
+		  if (insn->insn_class == INSN_CLASS_ZICNTR
+		      && !riscv_subset_supports (&riscv_rps_as, "zicntr"))
+		    {
+		      as_warn (_("`%s' needs `zicntr' extension"),
+			       insn->name);
+		    }
+
 		  /* The (segmant) load and store with EEW 64 cannot be used
 		     when zve32x is enabled.  */
 		  if (ip->insn_mo->pinfo & INSN_V_EEW64
diff --git a/gas/testsuite/gas/riscv/csr-insns-pseudo-noalias.d b/gas/testsuite/gas/riscv/csr-insns-pseudo-noalias.d
index b9300cea6f9f..36a0db4d379e 100644
--- a/gas/testsuite/gas/riscv/csr-insns-pseudo-noalias.d
+++ b/gas/testsuite/gas/riscv/csr-insns-pseudo-noalias.d
@@ -1,5 +1,5 @@
 #source: csr-insns-pseudo.s
-#as: -march=rv32if
+#as: -march=rv32if_zicntr
 #objdump: -dr -Mno-aliases
 
 .*:[ 	]+file format .*
diff --git a/gas/testsuite/gas/riscv/csr-insns-pseudo-nozicntr.d b/gas/testsuite/gas/riscv/csr-insns-pseudo-nozicntr.d
new file mode 100644
index 000000000000..340ab487cb95
--- /dev/null
+++ b/gas/testsuite/gas/riscv/csr-insns-pseudo-nozicntr.d
@@ -0,0 +1,37 @@
+#source: csr-insns-pseudo.s
+#as: -march=rv32i2p1_f2p2
+#warning_output: csr-insns-pseudo-nozicntr.l
+#objdump: -dr
+
+.*:[ 	]+file format .*
+
+
+Disassembly of section .text:
+
+0+000 <pseudo_csr_insn>:
+[ 	]+[0-9a-f]+:[ 	]+000022f3[ 	]+csrr[ 	]+t0,ustatus
+[ 	]+[0-9a-f]+:[ 	]+00029073[ 	]+csrw[ 	]+ustatus,t0
+[ 	]+[0-9a-f]+:[ 	]+0002a073[ 	]+csrs[ 	]+ustatus,t0
+[ 	]+[0-9a-f]+:[ 	]+0002b073[ 	]+csrc[ 	]+ustatus,t0
+[ 	]+[0-9a-f]+:[ 	]+000fd073[ 	]+csrwi[ 	]+ustatus,31
+[ 	]+[0-9a-f]+:[ 	]+000fe073[ 	]+csrsi[ 	]+ustatus,31
+[ 	]+[0-9a-f]+:[ 	]+000ff073[ 	]+csrci[ 	]+ustatus,31
+[ 	]+[0-9a-f]+:[ 	]+c00022f3[ 	]+rdcycle[ 	]+t0
+[ 	]+[0-9a-f]+:[ 	]+c01022f3[ 	]+rdtime[ 	]+t0
+[ 	]+[0-9a-f]+:[ 	]+c02022f3[ 	]+rdinstret[ 	]+t0
+[ 	]+[0-9a-f]+:[ 	]+c80022f3[ 	]+rdcycleh[ 	]+t0
+[ 	]+[0-9a-f]+:[ 	]+c81022f3[ 	]+rdtimeh[ 	]+t0
+[ 	]+[0-9a-f]+:[ 	]+c82022f3[ 	]+rdinstreth[ 	]+t0
+[ 	]+[0-9a-f]+:[ 	]+003022f3[ 	]+frcsr[ 	]+t0
+[ 	]+[0-9a-f]+:[ 	]+003392f3[ 	]+fscsr[ 	]+t0,t2
+[ 	]+[0-9a-f]+:[ 	]+00339073[ 	]+fscsr[ 	]+t2
+[ 	]+[0-9a-f]+:[ 	]+002022f3[ 	]+frrm[ 	]+t0
+[ 	]+[0-9a-f]+:[ 	]+002312f3[ 	]+fsrm[ 	]+t0,t1
+[ 	]+[0-9a-f]+:[ 	]+00231073[ 	]+fsrm[ 	]+t1
+[ 	]+[0-9a-f]+:[ 	]+002fd2f3[ 	]+fsrmi[ 	]+t0,31
+[ 	]+[0-9a-f]+:[ 	]+002fd073[ 	]+fsrmi[ 	]+zero,31
+[ 	]+[0-9a-f]+:[ 	]+001022f3[ 	]+frflags[ 	]+t0
+[ 	]+[0-9a-f]+:[ 	]+001312f3[ 	]+fsflags[ 	]+t0,t1
+[ 	]+[0-9a-f]+:[ 	]+00131073[ 	]+fsflags[ 	]+t1
+[ 	]+[0-9a-f]+:[ 	]+001fd2f3[ 	]+fsflagsi[ 	]+t0,31
+[ 	]+[0-9a-f]+:[ 	]+001fd073[ 	]+fsflagsi[ 	]+zero,31
diff --git a/gas/testsuite/gas/riscv/csr-insns-pseudo-nozicntr.l b/gas/testsuite/gas/riscv/csr-insns-pseudo-nozicntr.l
new file mode 100644
index 000000000000..457499f82713
--- /dev/null
+++ b/gas/testsuite/gas/riscv/csr-insns-pseudo-nozicntr.l
@@ -0,0 +1,7 @@
+.*Assembler messages:
+.*Warning: `rdcycle' needs `zicntr' extension
+.*Warning: `rdtime' needs `zicntr' extension
+.*Warning: `rdinstret' needs `zicntr' extension
+.*Warning: `rdcycleh' needs `zicntr' extension
+.*Warning: `rdtimeh' needs `zicntr' extension
+.*Warning: `rdinstreth' needs `zicntr' extension
diff --git a/gas/testsuite/gas/riscv/csr-insns-pseudo-zfinx.d b/gas/testsuite/gas/riscv/csr-insns-pseudo-zfinx.d
index 6e86398cf7b6..52a4f4d8d2ed 100644
--- a/gas/testsuite/gas/riscv/csr-insns-pseudo-zfinx.d
+++ b/gas/testsuite/gas/riscv/csr-insns-pseudo-zfinx.d
@@ -1,5 +1,5 @@
 #source: csr-insns-pseudo.s
-#as: -march=rv32i_zfinx
+#as: -march=rv32i_zicntr_zfinx
 #objdump: -dr
 
 .*:[ 	]+file format .*
diff --git a/gas/testsuite/gas/riscv/csr-insns-pseudo.d b/gas/testsuite/gas/riscv/csr-insns-pseudo.d
index 3df7b4b112af..cdb72152e8c9 100644
--- a/gas/testsuite/gas/riscv/csr-insns-pseudo.d
+++ b/gas/testsuite/gas/riscv/csr-insns-pseudo.d
@@ -1,5 +1,5 @@
 #source: csr-insns-pseudo.s
-#as: -march=rv32if
+#as: -march=rv32if_zicntr
 #objdump: -dr
 
 .*:[ 	]+file format .*
diff --git a/gas/testsuite/gas/riscv/csr-insns-pseudo.s b/gas/testsuite/gas/riscv/csr-insns-pseudo.s
index 8efaa4eadd98..01adff70294a 100644
--- a/gas/testsuite/gas/riscv/csr-insns-pseudo.s
+++ b/gas/testsuite/gas/riscv/csr-insns-pseudo.s
@@ -8,11 +8,12 @@ pseudo_csr_insn:
 	csrsi 0x0, 31
 	csrci 0x0, 31
 
+	# Zicntr
 	rdcycle t0
 	rdtime t0
 	rdinstret t0
 
-	# rv32i-ext
+	# Zicntr (RV32)
 	rdcycleh t0
 	rdtimeh t0
 	rdinstreth t0
diff --git a/gas/testsuite/gas/riscv/csr-insns-read-only.d b/gas/testsuite/gas/riscv/csr-insns-read-only.d
index 6b3549b875ac..1a7e2caddf10 100644
--- a/gas/testsuite/gas/riscv/csr-insns-read-only.d
+++ b/gas/testsuite/gas/riscv/csr-insns-read-only.d
@@ -1,3 +1,3 @@
-#as: -march=rv32if -mcsr-check -mpriv-spec=1.11
+#as: -march=rv32if_zicntr -mcsr-check -mpriv-spec=1.11
 #source: csr-insns-read-only.s
 #warning_output: csr-insns-read-only.l
diff --git a/gas/testsuite/gas/riscv/csr-version-1p10.d b/gas/testsuite/gas/riscv/csr-version-1p10.d
index dbdc077adac8..41d07da065b1 100644
--- a/gas/testsuite/gas/riscv/csr-version-1p10.d
+++ b/gas/testsuite/gas/riscv/csr-version-1p10.d
@@ -1,4 +1,4 @@
-#as: -march=rv64i_zicsr -mcsr-check -mpriv-spec=1.10
+#as: -march=rv64i2p1_zicsr2p0 -mcsr-check -mpriv-spec=1.10
 #source: csr.s
 #warning_output: csr-version-1p10.l
 #objdump: -dr -Mpriv-spec=1.10
diff --git a/gas/testsuite/gas/riscv/csr-version-1p10.l b/gas/testsuite/gas/riscv/csr-version-1p10.l
index 054179a416db..d0cc295d3900 100644
--- a/gas/testsuite/gas/riscv/csr-version-1p10.l
+++ b/gas/testsuite/gas/riscv/csr-version-1p10.l
@@ -1,258 +1,514 @@
 .*Assembler messages:
+.*Warning: invalid CSR `cycle', needs `zicntr' extension
+.*Info: macro .*
+.*Warning: invalid CSR `cycle', needs `zicntr' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw cycle,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `time', needs `zicntr' extension
+.*Info: macro .*
+.*Warning: invalid CSR `time', needs `zicntr' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw time,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `instret', needs `zicntr' extension
+.*Info: macro .*
+.*Warning: invalid CSR `instret', needs `zicntr' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw instret,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter3', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter3', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter3,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter4', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter4', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter4,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter5', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter5', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter5,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter6', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter6', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter6,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter7', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter7', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter7,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter8', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter8', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter8,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter9', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter9', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter9,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter10', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter10', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter10,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter11', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter11', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter11,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter12', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter12', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter12,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter13', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter13', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter13,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter14', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter14', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter14,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter15', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter15', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter15,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter16', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter16', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter16,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter17', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter17', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter17,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter18', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter18', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter18,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter19', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter19', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter19,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter20', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter20', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter20,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter21', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter21', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter21,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter22', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter22', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter22,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter23', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter23', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter23,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter24', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter24', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter24,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter25', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter25', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter25,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter26', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter26', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter26,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter27', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter27', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter27,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter28', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter28', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter28,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter29', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter29', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter29,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter30', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter30', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter30,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter31', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter31', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter31,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `cycleh', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `cycleh', needs `zicntr' extension
+.*Info: macro .*
 .*Warning: invalid CSR `cycleh', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `cycleh', needs `zicntr' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw cycleh,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `timeh', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `timeh', needs `zicntr' extension
+.*Info: macro .*
 .*Warning: invalid CSR `timeh', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `timeh', needs `zicntr' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw timeh,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `instreth', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `instreth', needs `zicntr' extension
+.*Info: macro .*
 .*Warning: invalid CSR `instreth', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `instreth', needs `zicntr' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw instreth,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter3h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter3h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter3h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter3h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter3h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter4h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter4h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter4h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter4h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter4h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter5h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter5h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter5h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter5h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter5h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter6h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter6h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter6h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter6h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter6h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter7h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter7h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter7h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter7h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter7h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter8h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter8h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter8h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter8h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter8h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter9h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter9h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter9h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter9h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter9h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter10h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter10h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter10h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter10h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter10h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter11h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter11h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter11h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter11h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter11h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter12h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter12h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter12h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter12h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter12h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter13h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter13h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter13h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter13h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter13h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter14h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter14h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter14h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter14h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter14h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter15h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter15h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter15h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter15h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter15h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter16h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter16h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter16h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter16h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter16h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter17h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter17h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter17h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter17h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter17h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter18h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter18h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter18h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter18h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter18h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter19h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter19h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter19h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter19h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter19h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter20h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter20h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter20h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter20h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter20h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter21h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter21h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter21h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter21h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter21h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter22h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter22h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter22h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter22h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter22h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter23h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter23h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter23h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter23h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter23h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter24h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter24h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter24h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter24h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter24h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter25h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter25h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter25h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter25h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter25h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter26h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter26h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter26h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter26h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter26h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter27h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter27h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter27h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter27h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter27h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter28h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter28h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter28h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter28h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter28h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter29h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter29h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter29h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter29h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter29h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter30h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter30h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter30h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter30h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter30h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter31h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter31h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter31h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter31h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter31h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `senvcfg' for the privileged spec `1.10'
diff --git a/gas/testsuite/gas/riscv/csr-version-1p11.d b/gas/testsuite/gas/riscv/csr-version-1p11.d
index 7ba88b6d1d53..90e75079eb3f 100644
--- a/gas/testsuite/gas/riscv/csr-version-1p11.d
+++ b/gas/testsuite/gas/riscv/csr-version-1p11.d
@@ -1,4 +1,4 @@
-#as: -march=rv64i_zicsr -mcsr-check -mpriv-spec=1.11
+#as: -march=rv64i2p1_zicsr2p0 -mcsr-check -mpriv-spec=1.11
 #source: csr.s
 #warning_output: csr-version-1p11.l
 #objdump: -dr -Mpriv-spec=1.11
diff --git a/gas/testsuite/gas/riscv/csr-version-1p11.l b/gas/testsuite/gas/riscv/csr-version-1p11.l
index cc365f1df415..4765f61c72b3 100644
--- a/gas/testsuite/gas/riscv/csr-version-1p11.l
+++ b/gas/testsuite/gas/riscv/csr-version-1p11.l
@@ -1,258 +1,514 @@
 .*Assembler messages:
+.*Warning: invalid CSR `cycle', needs `zicntr' extension
+.*Info: macro .*
+.*Warning: invalid CSR `cycle', needs `zicntr' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw cycle,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `time', needs `zicntr' extension
+.*Info: macro .*
+.*Warning: invalid CSR `time', needs `zicntr' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw time,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `instret', needs `zicntr' extension
+.*Info: macro .*
+.*Warning: invalid CSR `instret', needs `zicntr' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw instret,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter3', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter3', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter3,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter4', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter4', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter4,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter5', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter5', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter5,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter6', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter6', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter6,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter7', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter7', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter7,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter8', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter8', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter8,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter9', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter9', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter9,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter10', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter10', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter10,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter11', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter11', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter11,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter12', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter12', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter12,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter13', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter13', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter13,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter14', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter14', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter14,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter15', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter15', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter15,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter16', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter16', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter16,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter17', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter17', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter17,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter18', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter18', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter18,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter19', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter19', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter19,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter20', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter20', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter20,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter21', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter21', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter21,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter22', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter22', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter22,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter23', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter23', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter23,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter24', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter24', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter24,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter25', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter25', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter25,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter26', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter26', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter26,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter27', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter27', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter27,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter28', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter28', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter28,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter29', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter29', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter29,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter30', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter30', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter30,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter31', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter31', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter31,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `cycleh', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `cycleh', needs `zicntr' extension
+.*Info: macro .*
 .*Warning: invalid CSR `cycleh', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `cycleh', needs `zicntr' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw cycleh,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `timeh', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `timeh', needs `zicntr' extension
+.*Info: macro .*
 .*Warning: invalid CSR `timeh', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `timeh', needs `zicntr' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw timeh,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `instreth', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `instreth', needs `zicntr' extension
+.*Info: macro .*
 .*Warning: invalid CSR `instreth', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `instreth', needs `zicntr' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw instreth,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter3h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter3h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter3h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter3h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter3h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter4h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter4h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter4h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter4h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter4h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter5h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter5h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter5h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter5h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter5h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter6h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter6h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter6h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter6h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter6h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter7h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter7h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter7h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter7h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter7h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter8h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter8h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter8h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter8h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter8h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter9h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter9h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter9h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter9h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter9h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter10h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter10h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter10h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter10h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter10h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter11h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter11h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter11h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter11h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter11h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter12h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter12h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter12h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter12h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter12h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter13h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter13h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter13h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter13h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter13h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter14h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter14h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter14h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter14h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter14h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter15h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter15h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter15h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter15h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter15h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter16h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter16h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter16h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter16h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter16h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter17h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter17h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter17h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter17h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter17h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter18h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter18h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter18h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter18h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter18h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter19h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter19h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter19h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter19h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter19h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter20h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter20h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter20h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter20h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter20h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter21h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter21h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter21h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter21h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter21h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter22h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter22h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter22h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter22h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter22h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter23h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter23h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter23h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter23h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter23h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter24h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter24h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter24h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter24h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter24h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter25h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter25h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter25h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter25h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter25h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter26h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter26h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter26h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter26h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter26h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter27h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter27h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter27h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter27h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter27h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter28h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter28h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter28h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter28h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter28h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter29h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter29h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter29h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter29h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter29h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter30h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter30h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter30h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter30h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter30h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter31h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter31h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter31h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter31h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter31h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `senvcfg' for the privileged spec `1.11'
diff --git a/gas/testsuite/gas/riscv/csr-version-1p12.d b/gas/testsuite/gas/riscv/csr-version-1p12.d
index 677820b95265..9e29d7ac3c32 100644
--- a/gas/testsuite/gas/riscv/csr-version-1p12.d
+++ b/gas/testsuite/gas/riscv/csr-version-1p12.d
@@ -1,4 +1,4 @@
-#as: -march=rv64i_zicsr -mcsr-check -mpriv-spec=1.12
+#as: -march=rv64i2p1_zicsr2p0 -mcsr-check -mpriv-spec=1.12
 #source: csr.s
 #warning_output: csr-version-1p12.l
 #objdump: -dr -Mpriv-spec=1.12
diff --git a/gas/testsuite/gas/riscv/csr-version-1p12.l b/gas/testsuite/gas/riscv/csr-version-1p12.l
index 7a7f5f717c52..c1fe4b062631 100644
--- a/gas/testsuite/gas/riscv/csr-version-1p12.l
+++ b/gas/testsuite/gas/riscv/csr-version-1p12.l
@@ -1,258 +1,514 @@
 .*Assembler messages:
+.*Warning: invalid CSR `cycle', needs `zicntr' extension
+.*Info: macro .*
+.*Warning: invalid CSR `cycle', needs `zicntr' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw cycle,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `time', needs `zicntr' extension
+.*Info: macro .*
+.*Warning: invalid CSR `time', needs `zicntr' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw time,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `instret', needs `zicntr' extension
+.*Info: macro .*
+.*Warning: invalid CSR `instret', needs `zicntr' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw instret,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter3', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter3', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter3,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter4', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter4', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter4,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter5', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter5', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter5,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter6', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter6', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter6,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter7', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter7', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter7,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter8', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter8', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter8,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter9', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter9', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter9,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter10', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter10', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter10,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter11', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter11', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter11,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter12', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter12', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter12,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter13', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter13', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter13,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter14', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter14', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter14,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter15', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter15', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter15,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter16', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter16', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter16,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter17', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter17', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter17,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter18', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter18', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter18,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter19', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter19', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter19,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter20', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter20', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter20,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter21', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter21', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter21,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter22', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter22', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter22,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter23', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter23', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter23,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter24', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter24', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter24,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter25', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter25', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter25,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter26', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter26', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter26,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter27', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter27', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter27,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter28', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter28', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter28,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter29', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter29', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter29,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter30', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter30', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter30,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter31', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter31', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter31,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `cycleh', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `cycleh', needs `zicntr' extension
+.*Info: macro .*
 .*Warning: invalid CSR `cycleh', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `cycleh', needs `zicntr' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw cycleh,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `timeh', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `timeh', needs `zicntr' extension
+.*Info: macro .*
 .*Warning: invalid CSR `timeh', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `timeh', needs `zicntr' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw timeh,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `instreth', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `instreth', needs `zicntr' extension
+.*Info: macro .*
 .*Warning: invalid CSR `instreth', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `instreth', needs `zicntr' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw instreth,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter3h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter3h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter3h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter3h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter3h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter4h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter4h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter4h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter4h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter4h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter5h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter5h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter5h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter5h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter5h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter6h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter6h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter6h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter6h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter6h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter7h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter7h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter7h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter7h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter7h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter8h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter8h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter8h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter8h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter8h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter9h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter9h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter9h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter9h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter9h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter10h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter10h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter10h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter10h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter10h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter11h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter11h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter11h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter11h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter11h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter12h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter12h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter12h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter12h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter12h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter13h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter13h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter13h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter13h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter13h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter14h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter14h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter14h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter14h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter14h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter15h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter15h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter15h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter15h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter15h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter16h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter16h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter16h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter16h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter16h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter17h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter17h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter17h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter17h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter17h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter18h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter18h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter18h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter18h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter18h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter19h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter19h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter19h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter19h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter19h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter20h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter20h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter20h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter20h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter20h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter21h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter21h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter21h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter21h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter21h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter22h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter22h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter22h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter22h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter22h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter23h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter23h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter23h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter23h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter23h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter24h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter24h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter24h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter24h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter24h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter25h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter25h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter25h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter25h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter25h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter26h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter26h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter26h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter26h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter26h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter27h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter27h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter27h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter27h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter27h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter28h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter28h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter28h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter28h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter28h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter29h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter29h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter29h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter29h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter29h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter30h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter30h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter30h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter30h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter30h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter31h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter31h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter31h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter31h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter31h,a1'
 .*Info: macro .*
 .*Warning: read-only CSR is written `csrw mvendorid,a1'
diff --git a/gas/testsuite/gas/riscv/csr-version-1p9p1.d b/gas/testsuite/gas/riscv/csr-version-1p9p1.d
index f4d2b04ca6a4..2127e0f633b2 100644
--- a/gas/testsuite/gas/riscv/csr-version-1p9p1.d
+++ b/gas/testsuite/gas/riscv/csr-version-1p9p1.d
@@ -1,4 +1,4 @@
-#as: -march=rv64i_zicsr -mcsr-check -mpriv-spec=1.9.1
+#as: -march=rv64i2p1_zicsr2p0 -mcsr-check -mpriv-spec=1.9.1
 #source: csr.s
 #warning_output: csr-version-1p9p1.l
 #objdump: -dr -Mpriv-spec=1.9.1
diff --git a/gas/testsuite/gas/riscv/csr-version-1p9p1.l b/gas/testsuite/gas/riscv/csr-version-1p9p1.l
index 7fcd73ab7ddd..4a42f0d5f272 100644
--- a/gas/testsuite/gas/riscv/csr-version-1p9p1.l
+++ b/gas/testsuite/gas/riscv/csr-version-1p9p1.l
@@ -1,258 +1,514 @@
 .*Assembler messages:
+.*Warning: invalid CSR `cycle', needs `zicntr' extension
+.*Info: macro .*
+.*Warning: invalid CSR `cycle', needs `zicntr' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw cycle,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `time', needs `zicntr' extension
+.*Info: macro .*
+.*Warning: invalid CSR `time', needs `zicntr' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw time,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `instret', needs `zicntr' extension
+.*Info: macro .*
+.*Warning: invalid CSR `instret', needs `zicntr' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw instret,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter3', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter3', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter3,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter4', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter4', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter4,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter5', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter5', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter5,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter6', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter6', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter6,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter7', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter7', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter7,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter8', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter8', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter8,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter9', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter9', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter9,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter10', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter10', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter10,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter11', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter11', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter11,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter12', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter12', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter12,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter13', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter13', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter13,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter14', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter14', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter14,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter15', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter15', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter15,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter16', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter16', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter16,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter17', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter17', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter17,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter18', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter18', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter18,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter19', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter19', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter19,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter20', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter20', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter20,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter21', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter21', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter21,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter22', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter22', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter22,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter23', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter23', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter23,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter24', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter24', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter24,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter25', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter25', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter25,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter26', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter26', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter26,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter27', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter27', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter27,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter28', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter28', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter28,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter29', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter29', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter29,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter30', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter30', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter30,a1'
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter31', needs `zihpm' extension
+.*Info: macro .*
+.*Warning: invalid CSR `hpmcounter31', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter31,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `cycleh', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `cycleh', needs `zicntr' extension
+.*Info: macro .*
 .*Warning: invalid CSR `cycleh', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `cycleh', needs `zicntr' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw cycleh,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `timeh', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `timeh', needs `zicntr' extension
+.*Info: macro .*
 .*Warning: invalid CSR `timeh', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `timeh', needs `zicntr' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw timeh,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `instreth', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `instreth', needs `zicntr' extension
+.*Info: macro .*
 .*Warning: invalid CSR `instreth', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `instreth', needs `zicntr' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw instreth,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter3h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter3h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter3h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter3h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter3h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter4h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter4h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter4h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter4h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter4h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter5h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter5h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter5h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter5h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter5h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter6h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter6h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter6h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter6h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter6h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter7h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter7h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter7h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter7h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter7h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter8h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter8h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter8h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter8h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter8h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter9h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter9h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter9h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter9h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter9h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter10h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter10h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter10h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter10h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter10h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter11h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter11h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter11h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter11h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter11h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter12h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter12h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter12h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter12h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter12h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter13h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter13h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter13h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter13h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter13h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter14h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter14h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter14h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter14h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter14h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter15h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter15h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter15h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter15h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter15h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter16h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter16h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter16h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter16h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter16h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter17h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter17h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter17h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter17h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter17h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter18h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter18h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter18h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter18h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter18h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter19h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter19h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter19h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter19h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter19h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter20h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter20h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter20h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter20h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter20h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter21h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter21h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter21h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter21h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter21h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter22h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter22h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter22h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter22h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter22h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter23h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter23h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter23h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter23h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter23h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter24h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter24h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter24h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter24h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter24h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter25h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter25h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter25h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter25h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter25h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter26h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter26h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter26h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter26h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter26h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter27h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter27h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter27h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter27h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter27h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter28h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter28h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter28h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter28h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter28h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter29h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter29h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter29h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter29h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter29h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter30h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter30h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter30h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter30h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter30h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `hpmcounter31h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter31h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: invalid CSR `hpmcounter31h', needs rv32i extension
 .*Info: macro .*
+.*Warning: invalid CSR `hpmcounter31h', needs `zihpm' extension
+.*Info: macro .*
 .*Warning: read-only CSR is written `csrw hpmcounter31h,a1'
 .*Info: macro .*
 .*Warning: invalid CSR `scounteren' for the privileged spec `1.9.1'
diff --git a/gas/testsuite/gas/riscv/march-imply-i2p0-01.d b/gas/testsuite/gas/riscv/march-imply-i2p0-01.d
index 6d86034f8c7c..1b716debbcdf 100644
--- a/gas/testsuite/gas/riscv/march-imply-i2p0-01.d
+++ b/gas/testsuite/gas/riscv/march-imply-i2p0-01.d
@@ -3,5 +3,5 @@
 #source: march-imply-i.s
 Attribute Section: riscv
 File Attributes
-  Tag_RISCV_arch: "rv32i2p0_zicsr2p0_zifencei2p0"
+  Tag_RISCV_arch: "rv32i2p0"
 #...
diff --git a/gas/testsuite/gas/riscv/march-ok-reorder.d b/gas/testsuite/gas/riscv/march-ok-reorder.d
index 030f8b150189..f602bb5492a0 100644
--- a/gas/testsuite/gas/riscv/march-ok-reorder.d
+++ b/gas/testsuite/gas/riscv/march-ok-reorder.d
@@ -1,7 +1,7 @@
-#as: -misa-spec=20191213 -march=rv32i2azicsr_fc2p0dxfoo2p0_m1_xbar2p0_zba
+#as: -misa-spec=20191213 -march=rv32i2p1a_zifencei_zicsr_fc2p0dxfoo2p0_m1_xbar2p0_zba
 #source: empty.s
 #readelf: -A
 
 Attribute Section: riscv
 File Attributes
-  Tag_RISCV_arch: "rv32i2p0_m1p0_a2p1_f2p2_d2p2_c2p0_zicsr2p0_zifencei2p0_zmmul1p0_zba1p0_xbar2p0_xfoo2p0"
+  Tag_RISCV_arch: "rv32i2p1_m1p0_a2p1_f2p2_d2p2_c2p0_zicsr2p0_zifencei2p0_zmmul1p0_zba1p0_xbar2p0_xfoo2p0"
diff --git a/include/opcode/riscv-opc.h b/include/opcode/riscv-opc.h
index 375483500e2a..dbb061ddf7f9 100644
--- a/include/opcode/riscv-opc.h
+++ b/include/opcode/riscv-opc.h
@@ -3558,70 +3558,70 @@ DECLARE_INSN(vt_maskcn, MATCH_VT_MASKCN, MASK_VT_MASKCN)
 #endif /* DECLARE_INSN */
 #ifdef DECLARE_CSR
 /* Unprivileged Counter/Timers CSRs.  */
-DECLARE_CSR(cycle, CSR_CYCLE, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(time, CSR_TIME, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(instret, CSR_INSTRET, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(hpmcounter3, CSR_HPMCOUNTER3, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(hpmcounter4, CSR_HPMCOUNTER4, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(hpmcounter5, CSR_HPMCOUNTER5, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(hpmcounter6, CSR_HPMCOUNTER6, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(hpmcounter7, CSR_HPMCOUNTER7, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(hpmcounter8, CSR_HPMCOUNTER8, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(hpmcounter9, CSR_HPMCOUNTER9, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(hpmcounter10, CSR_HPMCOUNTER10, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(hpmcounter11, CSR_HPMCOUNTER11, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(hpmcounter12, CSR_HPMCOUNTER12, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(hpmcounter13, CSR_HPMCOUNTER13, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(hpmcounter14, CSR_HPMCOUNTER14, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(hpmcounter15, CSR_HPMCOUNTER15, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(hpmcounter16, CSR_HPMCOUNTER16, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(hpmcounter17, CSR_HPMCOUNTER17, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(hpmcounter18, CSR_HPMCOUNTER18, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(hpmcounter19, CSR_HPMCOUNTER19, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(hpmcounter20, CSR_HPMCOUNTER20, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(hpmcounter21, CSR_HPMCOUNTER21, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(hpmcounter22, CSR_HPMCOUNTER22, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(hpmcounter23, CSR_HPMCOUNTER23, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(hpmcounter24, CSR_HPMCOUNTER24, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(hpmcounter25, CSR_HPMCOUNTER25, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(hpmcounter26, CSR_HPMCOUNTER26, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(hpmcounter27, CSR_HPMCOUNTER27, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(hpmcounter28, CSR_HPMCOUNTER28, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(hpmcounter29, CSR_HPMCOUNTER29, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(hpmcounter30, CSR_HPMCOUNTER30, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(hpmcounter31, CSR_HPMCOUNTER31, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(cycleh, CSR_CYCLEH, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(timeh, CSR_TIMEH, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(instreth, CSR_INSTRETH, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(hpmcounter3h, CSR_HPMCOUNTER3H, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(hpmcounter4h, CSR_HPMCOUNTER4H, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(hpmcounter5h, CSR_HPMCOUNTER5H, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(hpmcounter6h, CSR_HPMCOUNTER6H, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(hpmcounter7h, CSR_HPMCOUNTER7H, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(hpmcounter8h, CSR_HPMCOUNTER8H, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(hpmcounter9h, CSR_HPMCOUNTER9H, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(hpmcounter10h, CSR_HPMCOUNTER10H, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(hpmcounter11h, CSR_HPMCOUNTER11H, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(hpmcounter12h, CSR_HPMCOUNTER12H, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(hpmcounter13h, CSR_HPMCOUNTER13H, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(hpmcounter14h, CSR_HPMCOUNTER14H, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(hpmcounter15h, CSR_HPMCOUNTER15H, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(hpmcounter16h, CSR_HPMCOUNTER16H, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(hpmcounter17h, CSR_HPMCOUNTER17H, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(hpmcounter18h, CSR_HPMCOUNTER18H, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(hpmcounter19h, CSR_HPMCOUNTER19H, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(hpmcounter20h, CSR_HPMCOUNTER20H, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(hpmcounter21h, CSR_HPMCOUNTER21H, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(hpmcounter22h, CSR_HPMCOUNTER22H, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(hpmcounter23h, CSR_HPMCOUNTER23H, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(hpmcounter24h, CSR_HPMCOUNTER24H, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(hpmcounter25h, CSR_HPMCOUNTER25H, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(hpmcounter26h, CSR_HPMCOUNTER26H, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(hpmcounter27h, CSR_HPMCOUNTER27H, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(hpmcounter28h, CSR_HPMCOUNTER28H, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(hpmcounter29h, CSR_HPMCOUNTER29H, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(hpmcounter30h, CSR_HPMCOUNTER30H, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
-DECLARE_CSR(hpmcounter31h, CSR_HPMCOUNTER31H, CSR_CLASS_I_32, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
+DECLARE_CSR(cycle, CSR_CYCLE, CSR_CLASS_ZICNTR, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(time, CSR_TIME, CSR_CLASS_ZICNTR, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(instret, CSR_INSTRET, CSR_CLASS_ZICNTR, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(hpmcounter3, CSR_HPMCOUNTER3, CSR_CLASS_ZIHPM, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(hpmcounter4, CSR_HPMCOUNTER4, CSR_CLASS_ZIHPM, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(hpmcounter5, CSR_HPMCOUNTER5, CSR_CLASS_ZIHPM, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(hpmcounter6, CSR_HPMCOUNTER6, CSR_CLASS_ZIHPM, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(hpmcounter7, CSR_HPMCOUNTER7, CSR_CLASS_ZIHPM, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(hpmcounter8, CSR_HPMCOUNTER8, CSR_CLASS_ZIHPM, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(hpmcounter9, CSR_HPMCOUNTER9, CSR_CLASS_ZIHPM, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(hpmcounter10, CSR_HPMCOUNTER10, CSR_CLASS_ZIHPM, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(hpmcounter11, CSR_HPMCOUNTER11, CSR_CLASS_ZIHPM, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(hpmcounter12, CSR_HPMCOUNTER12, CSR_CLASS_ZIHPM, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(hpmcounter13, CSR_HPMCOUNTER13, CSR_CLASS_ZIHPM, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(hpmcounter14, CSR_HPMCOUNTER14, CSR_CLASS_ZIHPM, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(hpmcounter15, CSR_HPMCOUNTER15, CSR_CLASS_ZIHPM, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(hpmcounter16, CSR_HPMCOUNTER16, CSR_CLASS_ZIHPM, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(hpmcounter17, CSR_HPMCOUNTER17, CSR_CLASS_ZIHPM, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(hpmcounter18, CSR_HPMCOUNTER18, CSR_CLASS_ZIHPM, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(hpmcounter19, CSR_HPMCOUNTER19, CSR_CLASS_ZIHPM, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(hpmcounter20, CSR_HPMCOUNTER20, CSR_CLASS_ZIHPM, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(hpmcounter21, CSR_HPMCOUNTER21, CSR_CLASS_ZIHPM, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(hpmcounter22, CSR_HPMCOUNTER22, CSR_CLASS_ZIHPM, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(hpmcounter23, CSR_HPMCOUNTER23, CSR_CLASS_ZIHPM, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(hpmcounter24, CSR_HPMCOUNTER24, CSR_CLASS_ZIHPM, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(hpmcounter25, CSR_HPMCOUNTER25, CSR_CLASS_ZIHPM, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(hpmcounter26, CSR_HPMCOUNTER26, CSR_CLASS_ZIHPM, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(hpmcounter27, CSR_HPMCOUNTER27, CSR_CLASS_ZIHPM, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(hpmcounter28, CSR_HPMCOUNTER28, CSR_CLASS_ZIHPM, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(hpmcounter29, CSR_HPMCOUNTER29, CSR_CLASS_ZIHPM, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(hpmcounter30, CSR_HPMCOUNTER30, CSR_CLASS_ZIHPM, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(hpmcounter31, CSR_HPMCOUNTER31, CSR_CLASS_ZIHPM, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(cycleh, CSR_CYCLEH, CSR_CLASS_ZICNTR_32, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(timeh, CSR_TIMEH, CSR_CLASS_ZICNTR_32, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(instreth, CSR_INSTRETH, CSR_CLASS_ZICNTR_32, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(hpmcounter3h, CSR_HPMCOUNTER3H, CSR_CLASS_ZIHPM_32, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(hpmcounter4h, CSR_HPMCOUNTER4H, CSR_CLASS_ZIHPM_32, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(hpmcounter5h, CSR_HPMCOUNTER5H, CSR_CLASS_ZIHPM_32, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(hpmcounter6h, CSR_HPMCOUNTER6H, CSR_CLASS_ZIHPM_32, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(hpmcounter7h, CSR_HPMCOUNTER7H, CSR_CLASS_ZIHPM_32, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(hpmcounter8h, CSR_HPMCOUNTER8H, CSR_CLASS_ZIHPM_32, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(hpmcounter9h, CSR_HPMCOUNTER9H, CSR_CLASS_ZIHPM_32, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(hpmcounter10h, CSR_HPMCOUNTER10H, CSR_CLASS_ZIHPM_32, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(hpmcounter11h, CSR_HPMCOUNTER11H, CSR_CLASS_ZIHPM_32, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(hpmcounter12h, CSR_HPMCOUNTER12H, CSR_CLASS_ZIHPM_32, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(hpmcounter13h, CSR_HPMCOUNTER13H, CSR_CLASS_ZIHPM_32, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(hpmcounter14h, CSR_HPMCOUNTER14H, CSR_CLASS_ZIHPM_32, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(hpmcounter15h, CSR_HPMCOUNTER15H, CSR_CLASS_ZIHPM_32, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(hpmcounter16h, CSR_HPMCOUNTER16H, CSR_CLASS_ZIHPM_32, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(hpmcounter17h, CSR_HPMCOUNTER17H, CSR_CLASS_ZIHPM_32, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(hpmcounter18h, CSR_HPMCOUNTER18H, CSR_CLASS_ZIHPM_32, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(hpmcounter19h, CSR_HPMCOUNTER19H, CSR_CLASS_ZIHPM_32, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(hpmcounter20h, CSR_HPMCOUNTER20H, CSR_CLASS_ZIHPM_32, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(hpmcounter21h, CSR_HPMCOUNTER21H, CSR_CLASS_ZIHPM_32, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(hpmcounter22h, CSR_HPMCOUNTER22H, CSR_CLASS_ZIHPM_32, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(hpmcounter23h, CSR_HPMCOUNTER23H, CSR_CLASS_ZIHPM_32, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(hpmcounter24h, CSR_HPMCOUNTER24H, CSR_CLASS_ZIHPM_32, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(hpmcounter25h, CSR_HPMCOUNTER25H, CSR_CLASS_ZIHPM_32, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(hpmcounter26h, CSR_HPMCOUNTER26H, CSR_CLASS_ZIHPM_32, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(hpmcounter27h, CSR_HPMCOUNTER27H, CSR_CLASS_ZIHPM_32, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(hpmcounter28h, CSR_HPMCOUNTER28H, CSR_CLASS_ZIHPM_32, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(hpmcounter29h, CSR_HPMCOUNTER29H, CSR_CLASS_ZIHPM_32, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(hpmcounter30h, CSR_HPMCOUNTER30H, CSR_CLASS_ZIHPM_32, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
+DECLARE_CSR(hpmcounter31h, CSR_HPMCOUNTER31H, CSR_CLASS_ZIHPM_32, PRIV_SPEC_CLASS_NONE, PRIV_SPEC_CLASS_NONE)
 /* Privileged Supervisor CSRs.  */
 DECLARE_CSR(sstatus, CSR_SSTATUS, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
 DECLARE_CSR(sie, CSR_SIE, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9P1, PRIV_SPEC_CLASS_DRAFT)
diff --git a/include/opcode/riscv.h b/include/opcode/riscv.h
index 93dd5169ebce..847a5a04f5ae 100644
--- a/include/opcode/riscv.h
+++ b/include/opcode/riscv.h
@@ -389,6 +389,7 @@ enum riscv_insn_class
   INSN_CLASS_Q,
   INSN_CLASS_F_AND_C,
   INSN_CLASS_D_AND_C,
+  INSN_CLASS_ZICNTR,
   INSN_CLASS_ZICOND,
   INSN_CLASS_ZICSR,
   INSN_CLASS_ZIFENCEI,
diff --git a/opcodes/riscv-opc.c b/opcodes/riscv-opc.c
index 8e0ae85eb064..5da55ab9e322 100644
--- a/opcodes/riscv-opc.c
+++ b/opcodes/riscv-opc.c
@@ -510,12 +510,12 @@ const struct riscv_opcode riscv_opcodes[] =
 {"fence",       0, INSN_CLASS_I, "P,Q",       MATCH_FENCE, MASK_FENCE|MASK_RD|MASK_RS1|(MASK_IMM & ~MASK_PRED & ~MASK_SUCC), match_opcode, 0 },
 {"fence.i",     0, INSN_CLASS_ZIFENCEI, "",   MATCH_FENCE_I, MASK_FENCE|MASK_RD|MASK_RS1|MASK_IMM, match_opcode, 0 },
 {"fence.tso",   0, INSN_CLASS_I, "",          MATCH_FENCE_TSO, MASK_FENCE_TSO|MASK_RD|MASK_RS1, match_opcode, 0 },
-{"rdcycle",     0, INSN_CLASS_I, "d",         MATCH_RDCYCLE, MASK_RDCYCLE, match_opcode, INSN_ALIAS },
-{"rdinstret",   0, INSN_CLASS_I, "d",         MATCH_RDINSTRET, MASK_RDINSTRET, match_opcode, INSN_ALIAS },
-{"rdtime",      0, INSN_CLASS_I, "d",         MATCH_RDTIME, MASK_RDTIME, match_opcode, INSN_ALIAS },
-{"rdcycleh",   32, INSN_CLASS_I, "d",         MATCH_RDCYCLEH, MASK_RDCYCLEH, match_opcode, INSN_ALIAS },
-{"rdinstreth", 32, INSN_CLASS_I, "d",         MATCH_RDINSTRETH, MASK_RDINSTRETH, match_opcode, INSN_ALIAS },
-{"rdtimeh",    32, INSN_CLASS_I, "d",         MATCH_RDTIMEH, MASK_RDTIMEH, match_opcode, INSN_ALIAS },
+{"rdcycle",     0, INSN_CLASS_ZICNTR, "d",    MATCH_RDCYCLE, MASK_RDCYCLE, match_opcode, INSN_ALIAS },
+{"rdinstret",   0, INSN_CLASS_ZICNTR, "d",    MATCH_RDINSTRET, MASK_RDINSTRET, match_opcode, INSN_ALIAS },
+{"rdtime",      0, INSN_CLASS_ZICNTR, "d",    MATCH_RDTIME, MASK_RDTIME, match_opcode, INSN_ALIAS },
+{"rdcycleh",   32, INSN_CLASS_ZICNTR, "d",    MATCH_RDCYCLEH, MASK_RDCYCLEH, match_opcode, INSN_ALIAS },
+{"rdinstreth", 32, INSN_CLASS_ZICNTR, "d",    MATCH_RDINSTRETH, MASK_RDINSTRETH, match_opcode, INSN_ALIAS },
+{"rdtimeh",    32, INSN_CLASS_ZICNTR, "d",    MATCH_RDTIMEH, MASK_RDTIMEH, match_opcode, INSN_ALIAS },
 {"ecall",       0, INSN_CLASS_I, "",          MATCH_SCALL, MASK_SCALL, match_opcode, 0 },
 {"scall",       0, INSN_CLASS_I, "",          MATCH_SCALL, MASK_SCALL, match_opcode, 0 },
 {"xori",        0, INSN_CLASS_I, "d,s,j",     MATCH_XORI, MASK_XORI, match_opcode, 0 },
-- 
2.42.0


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2023-10-21  2:17 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-08  3:17 [RFC PATCH 0/2] RISC-V: Add 'Zicntr' and 'Zihpm' support with compatibility measures Tsukasa OI
2023-08-08  3:17 ` [RFC PATCH 1/2] RISC-V: Base for complex extension implications Tsukasa OI
2023-08-08  3:17 ` [RFC PATCH 2/2] RISC-V: Add 'Zicntr' and 'Zihpm' support with compatibility measures Tsukasa OI
2023-10-19  7:57 ` [PING^1][RFC PATCH 0/2] " Tsukasa OI
2023-10-19  8:33   ` Nelson Chu
2023-10-20  2:52     ` Tsukasa OI
2023-10-21  0:45 ` [PATCH 0/1] " Tsukasa OI
2023-10-21  0:45   ` [PATCH 1/1] " Tsukasa OI
2023-10-21  2:17   ` [PATCH v2 0/1] " Tsukasa OI
2023-10-21  2:17     ` [PATCH v2 1/1] " Tsukasa OI

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).