RISC-V: Add zifencei and prefixed h class extensions.
authorNelson Chu <nelson.chu@sifive.com>
Fri, 20 Nov 2020 07:35:17 +0000 (15:35 +0800)
committerNelson Chu <nelson.chu@sifive.com>
Tue, 1 Dec 2020 07:11:30 +0000 (15:11 +0800)
bfd/
* elfxx-riscv.c (riscv_parse_std_ext): Stop parsing standard
extensions when parsed h keyword.
(riscv_get_prefix_class): Support prefixed h class.
(riscv_std_h_ext_strtab): Likewise.
(riscv_ext_h_valid_p): Likewise.
(parse_config): Likewise.
(riscv_std_z_ext_strtab): Add zifencei.
* elfxx-riscv.h (riscv_isa_ext_class): Add RV_ISA_CLASS_H.

gas/
* testsuite/gas/riscv/march-fail-order-z.d: New testcase, check
orders of prefixed z extensions.
* testsuite/gas/riscv/march-fail-order-z.l: Likewise.
* testsuite/gas/riscv/march-fail-single-char-h.d: New testcase.
* testsuite/gas/riscv/march-fail-single-char.l: Updated.
* testsuite/gas/riscv/march-fail-unknown-h.d: New testcase.
* testsuite/gas/riscv/march-fail-unknown.l: Updated.

opcodes/
* riscv-opc.c (riscv_ext_version_table): Add zifencei.

12 files changed:
bfd/ChangeLog
bfd/elfxx-riscv.c
bfd/elfxx-riscv.h
gas/ChangeLog
gas/testsuite/gas/riscv/march-fail-order-z.d [new file with mode: 0644]
gas/testsuite/gas/riscv/march-fail-order-z.l [new file with mode: 0644]
gas/testsuite/gas/riscv/march-fail-single-char-h.d [new file with mode: 0644]
gas/testsuite/gas/riscv/march-fail-single-char.l
gas/testsuite/gas/riscv/march-fail-unknown-h.d [new file with mode: 0644]
gas/testsuite/gas/riscv/march-fail-unknown.l
opcodes/ChangeLog
opcodes/riscv-opc.c

index 3ac27196bdc4e9a177975c04245782e9aaa91b9e..726a377f74d2bd9f4db1d9da1fa0eb709c941cab 100644 (file)
@@ -1,3 +1,14 @@
+2020-12-01  Nelson Chu  <nelson.chu@sifive.com>
+
+       * elfxx-riscv.c (riscv_parse_std_ext): Stop parsing standard
+       extensions when parsed h keyword.
+       (riscv_get_prefix_class): Support prefixed h class.
+       (riscv_std_h_ext_strtab): Likewise.
+       (riscv_ext_h_valid_p): Likewise.
+       (parse_config): Likewise.
+       (riscv_std_z_ext_strtab): Add zifencei.
+       * elfxx-riscv.h (riscv_isa_ext_class): Add RV_ISA_CLASS_H.
+
 2020-12-01  Nelson Chu  <nelson.chu@sifive.com>
 
        * elfxx-riscv.c (riscv_parse_subset): ISA string cannot contain
index 69f3a4353b9361596afe63a5ee92e999c82c6eea..24eafcd25415431b957026fbd7a7be6d7c04333c 100644 (file)
@@ -1225,7 +1225,7 @@ riscv_parse_std_ext (riscv_parse_subset_t *rps,
 
   while (p != NULL && *p != '\0')
     {
-      if (*p == 'x' || *p == 's' || *p == 'z')
+      if (*p == 'x' || *p == 's' || *p == 'h' || *p == 'z')
        break;
 
       if (*p == '_')
@@ -1281,6 +1281,7 @@ riscv_get_prefix_class (const char *arch)
   switch (*arch)
     {
     case 's': return RV_ISA_CLASS_S;
+    case 'h': return RV_ISA_CLASS_H;
     case 'x': return RV_ISA_CLASS_X;
     case 'z': return RV_ISA_CLASS_Z;
     default: return RV_ISA_CLASS_UNKNOWN;
@@ -1362,6 +1363,7 @@ riscv_parse_prefixed_ext (riscv_parse_subset_t *rps,
       /* Check that the prefix extension is known.
         For 'x', anything goes but it cannot simply be 'x'.
         For 's', it must be known from a list and cannot simply be 's'.
+        For 'h', it must be known from a list and cannot simply be 'h'.
         For 'z', it must be known from a list and cannot simply be 'z'.  */
 
       /* Check that the extension name is well-formed.  */
@@ -1432,7 +1434,7 @@ riscv_parse_prefixed_ext (riscv_parse_subset_t *rps,
 
 static const char * const riscv_std_z_ext_strtab[] =
 {
-  "zicsr", NULL
+  "zicsr", "zifencei", NULL
 };
 
 static const char * const riscv_std_s_ext_strtab[] =
@@ -1440,6 +1442,11 @@ static const char * const riscv_std_s_ext_strtab[] =
   NULL
 };
 
+static const char * const riscv_std_h_ext_strtab[] =
+{
+  NULL
+};
+
 /* For the extension `ext`, search through the list of known extensions
    `known_exts` for a match, and return TRUE if found.  */
 
@@ -1486,12 +1493,22 @@ riscv_ext_s_valid_p (const char *arg)
   return riscv_multi_letter_ext_valid_p (arg, riscv_std_s_ext_strtab);
 }
 
+/* Predicator function for 'h' prefixed extensions.
+   Only known h-extensions are permitted.  */
+
+static bfd_boolean
+riscv_ext_h_valid_p (const char *arg)
+{
+  return riscv_multi_letter_ext_valid_p (arg, riscv_std_h_ext_strtab);
+}
+
 /* Parsing order of the prefixed extensions that is specified by
    the ISA spec.  */
 
 static const riscv_parse_config_t parse_config[] =
 {
   {RV_ISA_CLASS_S, "s", riscv_ext_s_valid_p},
+  {RV_ISA_CLASS_H, "h", riscv_ext_h_valid_p},
   {RV_ISA_CLASS_Z, "z", riscv_ext_z_valid_p},
   {RV_ISA_CLASS_X, "x", riscv_ext_x_valid_p},
   {RV_ISA_CLASS_UNKNOWN, NULL, NULL}
index b5b17d1687bf119616977387d11090922766414b..6b7cc5b0bf99d2e0a802c2216ffef6d9b9d397d3 100644 (file)
@@ -102,6 +102,7 @@ riscv_estimate_digit (unsigned);
 typedef enum riscv_isa_ext_class
 {
   RV_ISA_CLASS_S,
+  RV_ISA_CLASS_H,
   RV_ISA_CLASS_Z,
   RV_ISA_CLASS_X,
   RV_ISA_CLASS_UNKNOWN
index 2a2b593a13f7ba7cd0d496cc9dc2183538fe6fdf..64d2fa7ff1487eaf3ad7a02587185f0e28d43d4a 100644 (file)
@@ -1,3 +1,13 @@
+2020-12-01  Nelson Chu  <nelson.chu@sifive.com>
+
+       * testsuite/gas/riscv/march-fail-order-z.d: New testcase, check
+       orders of prefixed z extensions.
+       * testsuite/gas/riscv/march-fail-order-z.l: Likewise.
+       * testsuite/gas/riscv/march-fail-single-char-h.d: New testcase.
+       * testsuite/gas/riscv/march-fail-single-char.l: Updated.
+       * testsuite/gas/riscv/march-fail-unknown-h.d: New testcase.
+       * testsuite/gas/riscv/march-fail-unknown.l: Updated.
+
 2020-12-01  Nelson Chu  <nelson.chu@sifive.com>
 
        * testsuite/gas/riscv/march-fail-uppercase-base.d: Updated.
diff --git a/gas/testsuite/gas/riscv/march-fail-order-z.d b/gas/testsuite/gas/riscv/march-fail-order-z.d
new file mode 100644 (file)
index 0000000..dd076c6
--- /dev/null
@@ -0,0 +1,3 @@
+#as: -march=rv32i_zifencei2p0_zicsr2p0
+#source: empty.s
+#error_output: march-fail-order-z.l
diff --git a/gas/testsuite/gas/riscv/march-fail-order-z.l b/gas/testsuite/gas/riscv/march-fail-order-z.l
new file mode 100644 (file)
index 0000000..1129219
--- /dev/null
@@ -0,0 +1,2 @@
+.*Assembler messages:
+.*Fatal error: .*z ISA extension `zicsr' is not in alphabetical order.  It must come before `zifencei'
diff --git a/gas/testsuite/gas/riscv/march-fail-single-char-h.d b/gas/testsuite/gas/riscv/march-fail-single-char-h.d
new file mode 100644 (file)
index 0000000..7fca957
--- /dev/null
@@ -0,0 +1,3 @@
+#as: -march=rv32ih
+#source: empty.s
+#error_output: march-fail-single-char.l
index aa87a8db1a3aad379fb5df61dd36efb8f3e70094..6466e164ff8fefd2f7b0954e4ccec20f5da8a609 100644 (file)
@@ -1,2 +1,2 @@
 .*Assembler messages:
-.*Fatal error: .*unknown (s|z|x) ISA extension `(s|z|x)'
+.*Fatal error: .*unknown (s|h|z|x) ISA extension `(s|h|z|x)'
diff --git a/gas/testsuite/gas/riscv/march-fail-unknown-h.d b/gas/testsuite/gas/riscv/march-fail-unknown-h.d
new file mode 100644 (file)
index 0000000..b0b8323
--- /dev/null
@@ -0,0 +1,3 @@
+#as: -march=rv32ihfoo2p0
+#source: empty.s
+#error_output: march-fail-unknown.l
index ac22fe60ebf8e7911a15b146676852d7308d38a7..28a864dbb71de3e0d46ba8d13dbbd4c3a0f640f8 100644 (file)
@@ -1,2 +1,2 @@
 .*Assembler messages:
-.*Fatal error: .*unknown (s|z) ISA extension `(s|z)foo'
+.*Fatal error: .*unknown (s|h|z) ISA extension `(s|h|z)foo'
index 02fd2f5b583701d46ed6f4bb0df1882b980ae400..4f6160d47642598e00b1438991db8b80434adddf 100644 (file)
@@ -1,3 +1,7 @@
+2020-12-01  Nelson Chu  <nelson.chu@sifive.com>
+
+       * riscv-opc.c (riscv_ext_version_table): Add zifencei.
+
 2020-11-28 Borislav Petkov  <bp@suse.de>
 
        * i386-dis.c (print_insn): Set active_seg_prefix for branch hint insns
index 03e3bd7c054500f7e1ae523703143f768d7c137c..121f3fee415bacebcb0d77f44f4253bd90294010 100644 (file)
@@ -935,6 +935,9 @@ const struct riscv_ext_version riscv_ext_version_table[] =
 {"zicsr", ISA_SPEC_CLASS_20191213, 2, 0},
 {"zicsr", ISA_SPEC_CLASS_20190608, 2, 0},
 
+{"zifencei", ISA_SPEC_CLASS_20191213, 2, 0},
+{"zifencei", ISA_SPEC_CLASS_20190608, 2, 0},
+
 /* Terminate the list.  */
 {NULL, 0, 0, 0}
 };