aboutsummaryrefslogtreecommitdiff
path: root/gas
diff options
context:
space:
mode:
authorNelson Chu <nelson.chu@sifive.com>2020-11-20 17:26:04 +0800
committerNelson Chu <nelson.chu@sifive.com>2020-12-01 15:16:25 +0800
commit7ef19aa616aee98f0a5c7c948d0db56a9f3c5e57 (patch)
tree8ff81db254acc00537a32bbc16b79dc8f22889dc /gas
parent27a46348cb409fb2d5064c5686625f5323525c27 (diff)
downloadfsf-binutils-gdb-7ef19aa616aee98f0a5c7c948d0db56a9f3c5e57.zip
fsf-binutils-gdb-7ef19aa616aee98f0a5c7c948d0db56a9f3c5e57.tar.gz
fsf-binutils-gdb-7ef19aa616aee98f0a5c7c948d0db56a9f3c5e57.tar.bz2
RISC-V: Improve the version parsing for arch string.
Keep the riscv_add_subset to do the same thing, and use a new function, riscv_parse_add_subset, to cover most of the things when parsing, including find the default versions for extensions, and check whether the versions are valid. The version 0p0 should be an invalid version, that is the mistake I made before. This patch clarify the version rules as follows, * We accept any version of extensions set by users, except 0p0. * The non-standard x extensions must be set with versions in arch string. * If user don't set the versions, or set 0p0 for the extensions, then try to find the supported versions according to the chosen ISA spec. Otherwise, report errors rather than output 0p0 for them. Besides, we use as_bad rather than as_fatal to report more errors for assembler. bfd/ * elfxx-riscv.c (riscv_lookup_subset): Moved to front. (riscv_add_subset): Likewise. (riscv_release_subset_list): Likewise. (riscv_parse_add_subset): New function. Find and check the versions before adding them by riscv_add_subset. (riscv_parsing_subset_version): Remove use_default_version and change the version type from unsigned to int. Set the versions to RISCV_UNKNOWN_VERSION if we can not find them in the arch string. (riscv_parse_std_ext): Updated. (riscv_parse_prefixed_ext): Updated. Since we use as_bad rather than as_fatal to report more errors, return NULL string if the parsed end_of_version is NULL, too. (riscv_parse_subset): Use a new boolean, no_conflict, to report more errors when we have more than one ISA conflicts. * elfxx-riscv.h (RISCV_DONT_CARE_VERSION): Changed to RISCV_UNKNOWN_VERSION. (riscv_lookup_subset_version): Removed. (riscv_parse_subset_t): Updated. gas/ * config/tc-riscv.c (riscv_get_default_ext_version): Change the version type from unsigned to int. (riscv_set_arch): Use as_bad rather than as_fatal to report more errors. * testsuite/gas/riscv/attribute-02.d: Updated since x must be set with versions. * testsuite/gas/riscv/attribute-03.d: Likewise. * testsuite/gas/riscv/march-ok-two-nse.d: Likewise. * testsuite/gas/riscv/attribute-09.d: zicsr wasn't supported in the spec 2.2, so choose the newer spec. * testsuite/gas/riscv/march-fail-base-01.l: Updated since as_bad. * testsuite/gas/riscv/march-fail-base-02.l: Likewise. * testsuite/gas/riscv/march-fail-order-std.l: Likewise. * testsuite/gas/riscv/march-fail-order-x.l: Likewise. * testsuite/gas/riscv/march-fail-order-z.l: Likewise. * testsuite/gas/riscv/march-fail-porder.l: Likewise. * testsuite/gas/riscv/march-fail-rv32ef.l: Likewise. * testsuite/gas/riscv/march-fail-rv32id.l: Likewise. * testsuite/gas/riscv/march-fail-rv32iq.l: Likewise. * testsuite/gas/riscv/march-fail-rv64iq.l: Likewise. * testsuite/gas/riscv/march-fail-single-char.l: Likewise. * testsuite/gas/riscv/march-fail-unknown-std.l: Likewise. * testsuite/gas/riscv/march-fail-unknown.l: Likewise. * testsuite/gas/riscv/march-fail-uppercase.l: Likewise. * testsuite/gas/riscv/march-fail-version.l: Likewise. * testsuite/gas/riscv/march-fail-isa-spec.d: Likewise. * testsuite/gas/riscv/march-fail-isa-spec.l: Likewise. include/ * opcode/riscv.h (riscv_ext_version): Change the version type from unsigned to int.
Diffstat (limited to 'gas')
-rw-r--r--gas/ChangeLog30
-rw-r--r--gas/config/tc-riscv.c23
-rw-r--r--gas/testsuite/gas/riscv/attribute-02.d4
-rw-r--r--gas/testsuite/gas/riscv/attribute-03.d4
-rw-r--r--gas/testsuite/gas/riscv/attribute-09.d4
-rw-r--r--gas/testsuite/gas/riscv/march-fail-base-01.l2
-rw-r--r--gas/testsuite/gas/riscv/march-fail-base-02.l2
-rw-r--r--gas/testsuite/gas/riscv/march-fail-isa-spec.d3
-rw-r--r--gas/testsuite/gas/riscv/march-fail-isa-spec.l5
-rw-r--r--gas/testsuite/gas/riscv/march-fail-order-std.l2
-rw-r--r--gas/testsuite/gas/riscv/march-fail-order-x.l2
-rw-r--r--gas/testsuite/gas/riscv/march-fail-order-z.l2
-rw-r--r--gas/testsuite/gas/riscv/march-fail-porder.l2
-rw-r--r--gas/testsuite/gas/riscv/march-fail-rv32ef.l2
-rw-r--r--gas/testsuite/gas/riscv/march-fail-rv32id.l2
-rw-r--r--gas/testsuite/gas/riscv/march-fail-rv32iq.l3
-rw-r--r--gas/testsuite/gas/riscv/march-fail-rv64iq.l2
-rw-r--r--gas/testsuite/gas/riscv/march-fail-single-char.l2
-rw-r--r--gas/testsuite/gas/riscv/march-fail-unknown-std.l2
-rw-r--r--gas/testsuite/gas/riscv/march-fail-unknown.l2
-rw-r--r--gas/testsuite/gas/riscv/march-fail-uppercase.l2
-rw-r--r--gas/testsuite/gas/riscv/march-fail-version.l3
-rw-r--r--gas/testsuite/gas/riscv/march-ok-two-nse.d2
23 files changed, 72 insertions, 35 deletions
diff --git a/gas/ChangeLog b/gas/ChangeLog
index 64d2fa7..2b45509 100644
--- a/gas/ChangeLog
+++ b/gas/ChangeLog
@@ -1,5 +1,35 @@
2020-12-01 Nelson Chu <nelson.chu@sifive.com>
+ * config/tc-riscv.c (riscv_get_default_ext_version):
+ Change the version type from unsigned to int.
+ (riscv_set_arch): Use as_bad rather than as_fatal to
+ report more errors.
+ * testsuite/gas/riscv/attribute-02.d: Updated since x must be
+ set with versions.
+ * testsuite/gas/riscv/attribute-03.d: Likewise.
+ * testsuite/gas/riscv/march-ok-two-nse.d: Likewise.
+ * testsuite/gas/riscv/attribute-09.d: zicsr wasn't supported
+ in the spec 2.2, so choose the newer spec.
+ * testsuite/gas/riscv/march-fail-base-01.l: Updated since as_bad.
+ * testsuite/gas/riscv/march-fail-base-02.l: Likewise.
+ * testsuite/gas/riscv/march-fail-order-std.l: Likewise.
+ * testsuite/gas/riscv/march-fail-order-x.l: Likewise.
+ * testsuite/gas/riscv/march-fail-order-z.l: Likewise.
+ * testsuite/gas/riscv/march-fail-porder.l: Likewise.
+ * testsuite/gas/riscv/march-fail-rv32ef.l: Likewise.
+ * testsuite/gas/riscv/march-fail-rv32id.l: Likewise.
+ * testsuite/gas/riscv/march-fail-rv32iq.l: Likewise.
+ * testsuite/gas/riscv/march-fail-rv64iq.l: Likewise.
+ * testsuite/gas/riscv/march-fail-single-char.l: Likewise.
+ * testsuite/gas/riscv/march-fail-unknown-std.l: Likewise.
+ * testsuite/gas/riscv/march-fail-unknown.l: Likewise.
+ * testsuite/gas/riscv/march-fail-uppercase.l: Likewise.
+ * testsuite/gas/riscv/march-fail-version.l: Likewise.
+ * testsuite/gas/riscv/march-fail-isa-spec.d: Likewise.
+ * testsuite/gas/riscv/march-fail-isa-spec.l: Likewise.
+
+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.
diff --git a/gas/config/tc-riscv.c b/gas/config/tc-riscv.c
index 2340ff5..236a858 100644
--- a/gas/config/tc-riscv.c
+++ b/gas/config/tc-riscv.c
@@ -275,28 +275,25 @@ init_ext_version_hash (const struct riscv_ext_version *table)
static void
riscv_get_default_ext_version (const char *name,
- unsigned int *major_version,
- unsigned int *minor_version)
+ int *major_version,
+ int *minor_version)
{
struct riscv_ext_version *ext;
- *major_version = 0;
- *minor_version = 0;
-
if (name == NULL || default_isa_spec == ISA_SPEC_CLASS_NONE)
return;
ext = (struct riscv_ext_version *) str_hash_find (ext_version_hash, name);
while (ext
- && ext->name
- && strcmp (ext->name, name) == 0)
+ && ext->name
+ && strcmp (ext->name, name) == 0)
{
if (ext->isa_spec_class == default_isa_spec)
- {
- *major_version = ext->major_version;
- *minor_version = ext->minor_version;
- return;
- }
+ {
+ *major_version = ext->major_version;
+ *minor_version = ext->minor_version;
+ return;
+ }
ext++;
}
}
@@ -308,7 +305,7 @@ riscv_set_arch (const char *s)
{
riscv_parse_subset_t rps;
rps.subset_list = &riscv_subsets;
- rps.error_handler = as_fatal;
+ rps.error_handler = as_bad;
rps.xlen = &xlen;
rps.get_default_version = riscv_get_default_ext_version;
diff --git a/gas/testsuite/gas/riscv/attribute-02.d b/gas/testsuite/gas/riscv/attribute-02.d
index ae0195e..45b89f2 100644
--- a/gas/testsuite/gas/riscv/attribute-02.d
+++ b/gas/testsuite/gas/riscv/attribute-02.d
@@ -1,6 +1,6 @@
-#as: -march=rv32gxargle -march-attr -misa-spec=2.2
+#as: -march=rv32gxargle2p0 -march-attr -misa-spec=2.2
#readelf: -A
#source: empty.s
Attribute Section: riscv
File Attributes
- Tag_RISCV_arch: "rv32i2p0_m2p0_a2p0_f2p0_d2p0_xargle0p0"
+ Tag_RISCV_arch: "rv32i2p0_m2p0_a2p0_f2p0_d2p0_xargle2p0"
diff --git a/gas/testsuite/gas/riscv/attribute-03.d b/gas/testsuite/gas/riscv/attribute-03.d
index 9916ff6..11416d6 100644
--- a/gas/testsuite/gas/riscv/attribute-03.d
+++ b/gas/testsuite/gas/riscv/attribute-03.d
@@ -1,6 +1,6 @@
-#as: -march=rv32gxargle_xfoo -march-attr -misa-spec=2.2
+#as: -march=rv32gxargle2p0_xfoo3p0 -march-attr -misa-spec=2.2
#readelf: -A
#source: empty.s
Attribute Section: riscv
File Attributes
- Tag_RISCV_arch: "rv32i2p0_m2p0_a2p0_f2p0_d2p0_xargle0p0_xfoo0p0"
+ Tag_RISCV_arch: "rv32i2p0_m2p0_a2p0_f2p0_d2p0_xargle2p0_xfoo3p0"
diff --git a/gas/testsuite/gas/riscv/attribute-09.d b/gas/testsuite/gas/riscv/attribute-09.d
index cad1713..fc87f82 100644
--- a/gas/testsuite/gas/riscv/attribute-09.d
+++ b/gas/testsuite/gas/riscv/attribute-09.d
@@ -1,6 +1,6 @@
-#as: -march-attr -march=rv32i2p1m_zicsr -misa-spec=2.2
+#as: -march-attr -march=rv32i2p2m_zicsr -misa-spec=20191213
#readelf: -A
#source: empty.s
Attribute Section: riscv
File Attributes
- Tag_RISCV_arch: "rv32i2p1_m2p0_zicsr0p0"
+ Tag_RISCV_arch: "rv32i2p2_m2p0_zicsr2p0"
diff --git a/gas/testsuite/gas/riscv/march-fail-base-01.l b/gas/testsuite/gas/riscv/march-fail-base-01.l
index 9fa071f..45d5c9a 100644
--- a/gas/testsuite/gas/riscv/march-fail-base-01.l
+++ b/gas/testsuite/gas/riscv/march-fail-base-01.l
@@ -1,2 +1,2 @@
.*Assembler messages:
-.*Fatal error: .*first ISA extension must be `e', `i' or `g'
+.*Error: .*first ISA extension must be `e', `i' or `g'
diff --git a/gas/testsuite/gas/riscv/march-fail-base-02.l b/gas/testsuite/gas/riscv/march-fail-base-02.l
index 6fc4dfa..f6a3c1d 100644
--- a/gas/testsuite/gas/riscv/march-fail-base-02.l
+++ b/gas/testsuite/gas/riscv/march-fail-base-02.l
@@ -1,2 +1,2 @@
.*Assembler messages:
-.*Fatal error: .*rv64e is not a valid base ISA
+.*Error: .*rv64e is not a valid base ISA
diff --git a/gas/testsuite/gas/riscv/march-fail-isa-spec.d b/gas/testsuite/gas/riscv/march-fail-isa-spec.d
new file mode 100644
index 0000000..af707e2
--- /dev/null
+++ b/gas/testsuite/gas/riscv/march-fail-isa-spec.d
@@ -0,0 +1,3 @@
+#as: -march=rv32iln_zicsr_xargle_xbargle -misa-spec=20191213
+#source: empty.s
+#error_output: march-fail-isa-spec.l
diff --git a/gas/testsuite/gas/riscv/march-fail-isa-spec.l b/gas/testsuite/gas/riscv/march-fail-isa-spec.l
new file mode 100644
index 0000000..e714ddf
--- /dev/null
+++ b/gas/testsuite/gas/riscv/march-fail-isa-spec.l
@@ -0,0 +1,5 @@
+.*Assembler messages:
+.*Error: cannot find default versions of the ISA extension `l'
+.*Error: cannot find default versions of the ISA extension `n'
+.*Error: x ISA extension `xargle' must be set with the versions
+.*Error: x ISA extension `xbargle' must be set with the versions
diff --git a/gas/testsuite/gas/riscv/march-fail-order-std.l b/gas/testsuite/gas/riscv/march-fail-order-std.l
index 666a8c0..9e3ce5e 100644
--- a/gas/testsuite/gas/riscv/march-fail-order-std.l
+++ b/gas/testsuite/gas/riscv/march-fail-order-std.l
@@ -1,2 +1,2 @@
.*Assembler messages:
-.*Fatal error: .*standard ISA extension `m' is not in canonical order
+.*Error: .*standard ISA extension `m' is not in canonical order
diff --git a/gas/testsuite/gas/riscv/march-fail-order-x.l b/gas/testsuite/gas/riscv/march-fail-order-x.l
index f7b383d..025db14 100644
--- a/gas/testsuite/gas/riscv/march-fail-order-x.l
+++ b/gas/testsuite/gas/riscv/march-fail-order-x.l
@@ -1,2 +1,2 @@
.*Assembler messages:
-.*Fatal error: .*x ISA extension `xargle' is not in alphabetical order. It must come before `xbargle'
+.*Error: .*x ISA extension `xargle' is not in alphabetical order. It must come before `xbargle'
diff --git a/gas/testsuite/gas/riscv/march-fail-order-z.l b/gas/testsuite/gas/riscv/march-fail-order-z.l
index 1129219..a98c53a 100644
--- a/gas/testsuite/gas/riscv/march-fail-order-z.l
+++ b/gas/testsuite/gas/riscv/march-fail-order-z.l
@@ -1,2 +1,2 @@
.*Assembler messages:
-.*Fatal error: .*z ISA extension `zicsr' is not in alphabetical order. It must come before `zifencei'
+.*Error: .*z ISA extension `zicsr' is not in alphabetical order. It must come before `zifencei'
diff --git a/gas/testsuite/gas/riscv/march-fail-porder.l b/gas/testsuite/gas/riscv/march-fail-porder.l
index a06d586..c5496ea 100644
--- a/gas/testsuite/gas/riscv/march-fail-porder.l
+++ b/gas/testsuite/gas/riscv/march-fail-porder.l
@@ -1,2 +1,2 @@
.*Assembler messages:
-.*Fatal error: .*unexpected ISA string at end:.*
+.*Error: .*unexpected ISA string at end:.*
diff --git a/gas/testsuite/gas/riscv/march-fail-rv32ef.l b/gas/testsuite/gas/riscv/march-fail-rv32ef.l
index d2d915d..e6d93f2 100644
--- a/gas/testsuite/gas/riscv/march-fail-rv32ef.l
+++ b/gas/testsuite/gas/riscv/march-fail-rv32ef.l
@@ -1,2 +1,2 @@
.*Assembler messages:
-.*Fatal error: .*rv32e does not support the `f' extension
+.*Error: .*rv32e does not support the `f' extension
diff --git a/gas/testsuite/gas/riscv/march-fail-rv32id.l b/gas/testsuite/gas/riscv/march-fail-rv32id.l
index 29b2717..c5f990c 100644
--- a/gas/testsuite/gas/riscv/march-fail-rv32id.l
+++ b/gas/testsuite/gas/riscv/march-fail-rv32id.l
@@ -1,2 +1,2 @@
.*Assembler messages:
-.*Fatal error: .*`d' extension requires `f' extension
+.*Error: .*`d' extension requires `f' extension
diff --git a/gas/testsuite/gas/riscv/march-fail-rv32iq.l b/gas/testsuite/gas/riscv/march-fail-rv32iq.l
index 361c381..8143dd4 100644
--- a/gas/testsuite/gas/riscv/march-fail-rv32iq.l
+++ b/gas/testsuite/gas/riscv/march-fail-rv32iq.l
@@ -1,2 +1,3 @@
.*Assembler messages:
-.*Fatal error: .*rv32 does not support the `q' extension
+.*Error: .*rv32 does not support the `q' extension
+.*Error: .*`q' extension requires `d' extension
diff --git a/gas/testsuite/gas/riscv/march-fail-rv64iq.l b/gas/testsuite/gas/riscv/march-fail-rv64iq.l
index 76a4104..787f46d 100644
--- a/gas/testsuite/gas/riscv/march-fail-rv64iq.l
+++ b/gas/testsuite/gas/riscv/march-fail-rv64iq.l
@@ -1,2 +1,2 @@
.*Assembler messages:
-.*Fatal error: .*`q' extension requires `d' extension
+.*Error: .*`q' extension requires `d' extension
diff --git a/gas/testsuite/gas/riscv/march-fail-single-char.l b/gas/testsuite/gas/riscv/march-fail-single-char.l
index 6466e16..435d0b2 100644
--- a/gas/testsuite/gas/riscv/march-fail-single-char.l
+++ b/gas/testsuite/gas/riscv/march-fail-single-char.l
@@ -1,2 +1,2 @@
.*Assembler messages:
-.*Fatal error: .*unknown (s|h|z|x) ISA extension `(s|h|z|x)'
+.*Error: .*unknown (s|h|z|x) ISA extension `(s|h|z|x)'
diff --git a/gas/testsuite/gas/riscv/march-fail-unknown-std.l b/gas/testsuite/gas/riscv/march-fail-unknown-std.l
index cb85637..75cdda3 100644
--- a/gas/testsuite/gas/riscv/march-fail-unknown-std.l
+++ b/gas/testsuite/gas/riscv/march-fail-unknown-std.l
@@ -1,2 +1,2 @@
.*Assembler messages:
-.*Fatal error: .*unknown standard ISA extension `[^eimafdqiglcbjtpvn]'
+.*Error: .*unknown standard ISA extension `[^eimafdqiglcbjtpvn]'
diff --git a/gas/testsuite/gas/riscv/march-fail-unknown.l b/gas/testsuite/gas/riscv/march-fail-unknown.l
index 28a864d..874b8d4 100644
--- a/gas/testsuite/gas/riscv/march-fail-unknown.l
+++ b/gas/testsuite/gas/riscv/march-fail-unknown.l
@@ -1,2 +1,2 @@
.*Assembler messages:
-.*Fatal error: .*unknown (s|h|z) ISA extension `(s|h|z)foo'
+.*Error: .*unknown (s|h|z) ISA extension `(s|h|z)foo'
diff --git a/gas/testsuite/gas/riscv/march-fail-uppercase.l b/gas/testsuite/gas/riscv/march-fail-uppercase.l
index 292c18a..14f03d6 100644
--- a/gas/testsuite/gas/riscv/march-fail-uppercase.l
+++ b/gas/testsuite/gas/riscv/march-fail-uppercase.l
@@ -1,2 +1,2 @@
.*Assembler messages:
-.*Fatal error: .*ISA string cannot contain uppercase letters
+.*Error: .*ISA string cannot contain uppercase letters
diff --git a/gas/testsuite/gas/riscv/march-fail-version.l b/gas/testsuite/gas/riscv/march-fail-version.l
index b5d0b91..c7f8a4d 100644
--- a/gas/testsuite/gas/riscv/march-fail-version.l
+++ b/gas/testsuite/gas/riscv/march-fail-version.l
@@ -1,2 +1,3 @@
.*Assembler messages:
-.*Fatal error: .*expect number after `2p'
+.*Error: cannot find default versions of the ISA extension `p'
+.*Error: .*expect number after `2p'
diff --git a/gas/testsuite/gas/riscv/march-ok-two-nse.d b/gas/testsuite/gas/riscv/march-ok-two-nse.d
index 0fe5037..e78cf9d 100644
--- a/gas/testsuite/gas/riscv/march-ok-two-nse.d
+++ b/gas/testsuite/gas/riscv/march-ok-two-nse.d
@@ -1,4 +1,4 @@
-#as: -march=rv32imafd_xargle_xbargle
+#as: -march=rv32imafd_xargle2p0_xbargle3p0
#objdump: -dr
#source: empty.s