diff options
author | Nelson Chu <nelson.chu@sifive.com> | 2021-04-07 12:50:19 +0800 |
---|---|---|
committer | Nelson Chu <nelson.chu@sifive.com> | 2021-04-12 10:05:37 +0800 |
commit | e601909a3287bf541c6a7d82214bb387d2c76d82 (patch) | |
tree | b007c2468451cb6e85531e60b22bc9aa1cb5e94d /gas | |
parent | 6803e1cb210ea0662afe8e783a9e8dd08a7dca9d (diff) | |
download | gdb-e601909a3287bf541c6a7d82214bb387d2c76d82.zip gdb-e601909a3287bf541c6a7d82214bb387d2c76d82.tar.gz gdb-e601909a3287bf541c6a7d82214bb387d2c76d82.tar.bz2 |
RISC-V: Support to parse the multi-letter prefix in the architecture string.
The original discussion is as follows,
https://github.com/riscv/riscv-isa-manual/issues/637
I never considered the prefixes may have multiple letters, like zxm.
But the ISA spec has been updated for a long time that I haven't noticed.
This patch rewrites the part of architecture parser to support parsing
the multi-letter prefixes. Besides, I also improve the parser to report
errors in details. One of the most obvious improvement is - Do not parse
the prefixed extensions according to the orders in the parse_config.
If we do so, then we used to get "unexpected ISA string at end" errors,
but the message is a little bit hard to know what is happening. I Remove
the confused message, and let riscv_parse_prefixed_ext to report the details.
bfd/
* elfxx-riscv.c (riscv_std_z_ext_strtab): Moved forward.
(riscv_std_s_ext_strtab): Likewise.
(riscv_std_h_ext_strtab): Likewise.
(riscv_std_zxm_ext_strtab): Added for the zxm prefix.
(enum riscv_prefix_ext_class): Moved forward and renamed from
riscv_isa_ext_class. Reorder them according to the parsing order,
since the enum values are used to check the orders in the
riscv_compare_subsets.
(struct riscv_parse_prefix_config): Moved forward and renamed from
riscv_parse_config_t. Also removed the ext_valid_p field, the
related functions are replaced by riscv_valid_prefixed_ext.
(parse_config): Moved forward and updated. The more letters of the
prefix string, the more forward it must be defined. Otherwise, we
will get the wrong mapping when using strncmp in riscv_get_prefix_class.
(riscv_get_prefix_class): Moved forward. Support to parse the
multi-letter prefix, like zxm.
(riscv_known_prefixed_ext): New function, check if the prefixed
extension is supported according to the right riscv_std_*_ext_strtab.
(riscv_valid_prefixed_ext): New function, used to replace the
riscv_ext_*_valid_p functions.
(riscv_init_ext_order): Do not set the values for prefix keywords
since they may have multiple letters for now.
(riscv_compare_subsets): Set the order values of prefix keywords
to negative numbers according to the riscv_prefix_ext_class.
(riscv_parse_std_ext): Call riscv_get_prefix_class to see if we
have parsed the prefixed extensions.
(riscv_parse_prefixed_ext): Updated and removed the parameter config.
Report error when the prefix is unknown.
(riscv_parse_subset): Do not parse the prefixed extensions according
to the orders in the parse_config. Remove the confused message and
let riscv_parse_prefixed_ext to report the details.
* elfxx-riscv.h (enum riscv_isa_ext_class): Moved to elfxx-riscv.c.
(riscv_get_prefix_class): Removed to static.
gas/
* testsuite/gas/riscv/march-fail-order-x-std.d: Renamed from
march-fail-porder-x-std.d.
* testsuite/gas/riscv/march-fail-order-z-std.d: Renamed from
march-fail-porder-z-std.d.
* testsuite/gas/riscv/march-fail-order-x-z.d: Renamed from
march-fail-porder-x-z.d.
* testsuite/gas/riscv/march-fail-order-zx-std.l: Added to replace
march-fail-porder.l.
* testsuite/gas/riscv/march-fail-order-x-z.l: Likewise.
* testsuite/gas/riscv/march-fail-order-x.l: Updated.
* testsuite/gas/riscv/march-fail-order-z.l: Likewise.
* testsuite/gas/riscv/march-fail-single-prefix-h.d: Renamed from
march-fail-single-char-h.d.
* testsuite/gas/riscv/march-fail-single-prefix-s.d: Renamed from
march-fail-single-char-s.d.
* testsuite/gas/riscv/march-fail-single-prefix-x.d: Renamed from
march-fail-single-char-x.d.
* testsuite/gas/riscv/march-fail-single-prefix-z.d: Renamed from
march-fail-single-char-z.d.
* testsuite/gas/riscv/march-fail-single-prefix-zmx.d: Added.
* testsuite/gas/riscv/march-fail-single-prefix.l: Added to replace
march-fail-single-prefix.l.
* testsuite/gas/riscv/march-fail-unknown-zxm.d: Added.
* testsuite/gas/riscv/march-fail-unknown-std.l: Updated.
* testsuite/gas/riscv/march-fail-unknown.l: Likewise.
Diffstat (limited to 'gas')
23 files changed, 59 insertions, 23 deletions
diff --git a/gas/ChangeLog b/gas/ChangeLog index 13e4272..15e4c07 100644 --- a/gas/ChangeLog +++ b/gas/ChangeLog @@ -1,3 +1,31 @@ +2021-04-12 Nelson Chu <nelson.chu@sifive.com> + + * testsuite/gas/riscv/march-fail-order-x-std.d: Renamed from + march-fail-porder-x-std.d. + * testsuite/gas/riscv/march-fail-order-z-std.d: Renamed from + march-fail-porder-z-std.d. + * testsuite/gas/riscv/march-fail-order-x-z.d: Renamed from + march-fail-porder-x-z.d. + * testsuite/gas/riscv/march-fail-order-zx-std.l: Added to replace + march-fail-porder.l. + * testsuite/gas/riscv/march-fail-order-x-z.l: Likewise. + * testsuite/gas/riscv/march-fail-order-x.l: Updated. + * testsuite/gas/riscv/march-fail-order-z.l: Likewise. + * testsuite/gas/riscv/march-fail-single-prefix-h.d: Renamed from + march-fail-single-char-h.d. + * testsuite/gas/riscv/march-fail-single-prefix-s.d: Renamed from + march-fail-single-char-s.d. + * testsuite/gas/riscv/march-fail-single-prefix-x.d: Renamed from + march-fail-single-char-x.d. + * testsuite/gas/riscv/march-fail-single-prefix-z.d: Renamed from + march-fail-single-char-z.d. + * testsuite/gas/riscv/march-fail-single-prefix-zmx.d: Added. + * testsuite/gas/riscv/march-fail-single-prefix.l: Added to replace + march-fail-single-prefix.l. + * testsuite/gas/riscv/march-fail-unknown-zxm.d: Added. + * testsuite/gas/riscv/march-fail-unknown-std.l: Updated. + * testsuite/gas/riscv/march-fail-unknown.l: Likewise. + 2021-04-09 Tejas Belagod <tejas.belagod@arm.com> * config/tc-aarch64.c (warn_unpredictable_ldst): Clean-up diagnostic messages diff --git a/gas/testsuite/gas/riscv/march-fail-porder-x-std.d b/gas/testsuite/gas/riscv/march-fail-order-x-std.d index 2bef073..4762f3d 100644 --- a/gas/testsuite/gas/riscv/march-fail-porder-x-std.d +++ b/gas/testsuite/gas/riscv/march-fail-order-x-std.d @@ -1,3 +1,3 @@ #as: -march=rv32i_xargle2p0_mafd #source: empty.s -#error_output: march-fail-porder.l +#error_output: march-fail-order-zx-std.l diff --git a/gas/testsuite/gas/riscv/march-fail-porder-x-z.d b/gas/testsuite/gas/riscv/march-fail-order-x-z.d index 094180d..7245e68 100644 --- a/gas/testsuite/gas/riscv/march-fail-porder-x-z.d +++ b/gas/testsuite/gas/riscv/march-fail-order-x-z.d @@ -1,3 +1,3 @@ #as: -march=rv32i_xargle2p0_zicsr2p0 #source: empty.s -#error_output: march-fail-porder.l +#error_output: march-fail-order-x-z.l diff --git a/gas/testsuite/gas/riscv/march-fail-order-x-z.l b/gas/testsuite/gas/riscv/march-fail-order-x-z.l new file mode 100644 index 0000000..53ea820 --- /dev/null +++ b/gas/testsuite/gas/riscv/march-fail-order-x-z.l @@ -0,0 +1,2 @@ +.*Assembler messages: +.*Error: .*prefixed ISA extension `zicsr' is not in expected order. It must come before `xargle' diff --git a/gas/testsuite/gas/riscv/march-fail-order-x.l b/gas/testsuite/gas/riscv/march-fail-order-x.l index 025db14..cfb1185 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: -.*Error: .*x ISA extension `xargle' is not in alphabetical order. It must come before `xbargle' +.*Error: .*prefixed ISA extension `xargle' is not in expected order. It must come before `xbargle' diff --git a/gas/testsuite/gas/riscv/march-fail-porder-z-std.d b/gas/testsuite/gas/riscv/march-fail-order-z-std.d index 1fa1a15..42526de 100644 --- a/gas/testsuite/gas/riscv/march-fail-porder-z-std.d +++ b/gas/testsuite/gas/riscv/march-fail-order-z-std.d @@ -1,3 +1,3 @@ #as: -march=rv32i_zicsr2p0_mafd #source: empty.s -#error_output: march-fail-porder.l +#error_output: march-fail-order-zx-std.l diff --git a/gas/testsuite/gas/riscv/march-fail-order-z.l b/gas/testsuite/gas/riscv/march-fail-order-z.l index a98c53a..468c412 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: -.*Error: .*z ISA extension `zicsr' is not in alphabetical order. It must come before `zifencei' +.*Error: .*prefixed ISA extension `zicsr' is not in expected order. It must come before `zifencei' diff --git a/gas/testsuite/gas/riscv/march-fail-order-zx-std.l b/gas/testsuite/gas/riscv/march-fail-order-zx-std.l new file mode 100644 index 0000000..4f6b98c --- /dev/null +++ b/gas/testsuite/gas/riscv/march-fail-order-zx-std.l @@ -0,0 +1,2 @@ +.*Assembler messages: +.*Error: .*unknown prefix class for the ISA extension `mafd' diff --git a/gas/testsuite/gas/riscv/march-fail-porder.l b/gas/testsuite/gas/riscv/march-fail-porder.l deleted file mode 100644 index c5496ea..0000000 --- a/gas/testsuite/gas/riscv/march-fail-porder.l +++ /dev/null @@ -1,2 +0,0 @@ -.*Assembler messages: -.*Error: .*unexpected ISA string at end:.* diff --git a/gas/testsuite/gas/riscv/march-fail-single-char-h.d b/gas/testsuite/gas/riscv/march-fail-single-char-h.d deleted file mode 100644 index 7fca957..0000000 --- a/gas/testsuite/gas/riscv/march-fail-single-char-h.d +++ /dev/null @@ -1,3 +0,0 @@ -#as: -march=rv32ih -#source: empty.s -#error_output: march-fail-single-char.l diff --git a/gas/testsuite/gas/riscv/march-fail-single-char-s.d b/gas/testsuite/gas/riscv/march-fail-single-char-s.d deleted file mode 100644 index b3aace9..0000000 --- a/gas/testsuite/gas/riscv/march-fail-single-char-s.d +++ /dev/null @@ -1,3 +0,0 @@ -#as: -march=rv32is -#source: empty.s -#error_output: march-fail-single-char.l diff --git a/gas/testsuite/gas/riscv/march-fail-single-char-x.d b/gas/testsuite/gas/riscv/march-fail-single-char-x.d deleted file mode 100644 index 585608c..0000000 --- a/gas/testsuite/gas/riscv/march-fail-single-char-x.d +++ /dev/null @@ -1,3 +0,0 @@ -#as: -march=rv32ix -#source: empty.s -#error_output: march-fail-single-char.l diff --git a/gas/testsuite/gas/riscv/march-fail-single-char-z.d b/gas/testsuite/gas/riscv/march-fail-single-char-z.d deleted file mode 100644 index daf96d2..0000000 --- a/gas/testsuite/gas/riscv/march-fail-single-char-z.d +++ /dev/null @@ -1,3 +0,0 @@ -#as: -march=rv32iz -#source: empty.s -#error_output: march-fail-single-char.l diff --git a/gas/testsuite/gas/riscv/march-fail-single-char.l b/gas/testsuite/gas/riscv/march-fail-single-char.l deleted file mode 100644 index 435d0b2..0000000 --- a/gas/testsuite/gas/riscv/march-fail-single-char.l +++ /dev/null @@ -1,2 +0,0 @@ -.*Assembler messages: -.*Error: .*unknown (s|h|z|x) ISA extension `(s|h|z|x)' diff --git a/gas/testsuite/gas/riscv/march-fail-single-prefix-h.d b/gas/testsuite/gas/riscv/march-fail-single-prefix-h.d new file mode 100644 index 0000000..eb101bd --- /dev/null +++ b/gas/testsuite/gas/riscv/march-fail-single-prefix-h.d @@ -0,0 +1,3 @@ +#as: -march=rv32ih +#source: empty.s +#error_output: march-fail-single-prefix.l diff --git a/gas/testsuite/gas/riscv/march-fail-single-prefix-s.d b/gas/testsuite/gas/riscv/march-fail-single-prefix-s.d new file mode 100644 index 0000000..8b6b0d0 --- /dev/null +++ b/gas/testsuite/gas/riscv/march-fail-single-prefix-s.d @@ -0,0 +1,3 @@ +#as: -march=rv32is +#source: empty.s +#error_output: march-fail-single-prefix.l diff --git a/gas/testsuite/gas/riscv/march-fail-single-prefix-x.d b/gas/testsuite/gas/riscv/march-fail-single-prefix-x.d new file mode 100644 index 0000000..9e87801 --- /dev/null +++ b/gas/testsuite/gas/riscv/march-fail-single-prefix-x.d @@ -0,0 +1,3 @@ +#as: -march=rv32ix +#source: empty.s +#error_output: march-fail-single-prefix.l diff --git a/gas/testsuite/gas/riscv/march-fail-single-prefix-z.d b/gas/testsuite/gas/riscv/march-fail-single-prefix-z.d new file mode 100644 index 0000000..4ae2692 --- /dev/null +++ b/gas/testsuite/gas/riscv/march-fail-single-prefix-z.d @@ -0,0 +1,3 @@ +#as: -march=rv32iz +#source: empty.s +#error_output: march-fail-single-prefix.l diff --git a/gas/testsuite/gas/riscv/march-fail-single-prefix-zxm.d b/gas/testsuite/gas/riscv/march-fail-single-prefix-zxm.d new file mode 100644 index 0000000..bdf6f86 --- /dev/null +++ b/gas/testsuite/gas/riscv/march-fail-single-prefix-zxm.d @@ -0,0 +1,3 @@ +#as: -march=rv32izxm +#source: empty.s +#error_output: march-fail-single-prefix.l diff --git a/gas/testsuite/gas/riscv/march-fail-single-prefix.l b/gas/testsuite/gas/riscv/march-fail-single-prefix.l new file mode 100644 index 0000000..13942ed --- /dev/null +++ b/gas/testsuite/gas/riscv/march-fail-single-prefix.l @@ -0,0 +1,2 @@ +.*Assembler messages: +.*Error: .*unknown prefixed ISA extension `(s|h|z|x|zxm)' diff --git a/gas/testsuite/gas/riscv/march-fail-unknown-std.l b/gas/testsuite/gas/riscv/march-fail-unknown-std.l index 75cdda3..0e9add7 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: -.*Error: .*unknown standard ISA extension `[^eimafdqiglcbjtpvn]' +.*Error: .*unknown standard and prefixed ISA extension `y' diff --git a/gas/testsuite/gas/riscv/march-fail-unknown-zxm.d b/gas/testsuite/gas/riscv/march-fail-unknown-zxm.d new file mode 100644 index 0000000..b3d4603 --- /dev/null +++ b/gas/testsuite/gas/riscv/march-fail-unknown-zxm.d @@ -0,0 +1,3 @@ +#as: -march=rv32izxmfoo2p0 +#source: empty.s +#error_output: march-fail-unknown.l diff --git a/gas/testsuite/gas/riscv/march-fail-unknown.l b/gas/testsuite/gas/riscv/march-fail-unknown.l index 874b8d4..0cc8096 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: -.*Error: .*unknown (s|h|z) ISA extension `(s|h|z)foo' +.*Error: .*unknown prefixed ISA extension `(s|h|z|zxm)foo' |