diff options
author | Nelson Chu <nelson.chu@sifive.com> | 2021-05-21 15:40:33 +0800 |
---|---|---|
committer | Nelson Chu <nelson.chu@sifive.com> | 2021-05-24 11:47:18 +0800 |
commit | 5d0ed830d362fb8bb200a4f52bf973ba30920802 (patch) | |
tree | a25048d16861f86f54b023437e9df0b41c09ab1e /gas | |
parent | d16ce6e4d581bcd25c7d9a402c19824c59f04276 (diff) | |
download | gdb-5d0ed830d362fb8bb200a4f52bf973ba30920802.zip gdb-5d0ed830d362fb8bb200a4f52bf973ba30920802.tar.gz gdb-5d0ed830d362fb8bb200a4f52bf973ba30920802.tar.bz2 |
RISC-V: PR25212, Report errors for invalid march and mabi combinations.
This patch clarify the following invalid combinations of march and mabi,
* ilp32f/lp64f abi without f extension.
* ilp32d/lp64d abi without d extension.
* ilp32q/lp64q abi without q extension.
* e extension with any abi except ilp32e
GNU assembler reports errors when finding the above invalid combinations.
But LLVM-MC reports warnings and ignores these invalid cases. It help to
set the correct ilp32/lp64/ilp32e abi according to rv32/rv64/rve. This
looks good and convenient, so perhaps we can do the same things. However,
if you don't set the mabi, GNU assembler also try to set the suitable
ABI according to march/elf-attribute. Compared to LLVM-MC, we will choose
double/quad abi if d/f extension is set.
gas/
PR 25212
* config/tc-riscv.c (riscv_set_abi_by_arch): If -mabi isn't set, we
will choose ilp32e abi for rv32e. Besides, report errors for the
invalid march and mabi combinations.
* testsuite/gas/riscv/mabi-attr-rv32e.s: New testcase. Only accept
ilp32e abi for rve extension.
* testsuite/gas/riscv/mabi-fail-rv32e-lp64f.d: Likewise.
* testsuite/gas/riscv/mabi-fail-rv32e-lp64f.l: Likewise.
* testsuite/gas/riscv/mabi-fail-rv32e-lp64d.d: Likewise.
* testsuite/gas/riscv/mabi-fail-rv32e-lp64d.l: Likewise.
* testsuite/gas/riscv/mabi-fail-rv32e-lp64d.q: Likewise.
* testsuite/gas/riscv/mabi-fail-rv32e-lp64d.q: Likewise.
Renamed all mabi testcases to their march-mabi settings.
Diffstat (limited to 'gas')
27 files changed, 72 insertions, 16 deletions
diff --git a/gas/ChangeLog b/gas/ChangeLog index cf135d9..bc7a00f 100644 --- a/gas/ChangeLog +++ b/gas/ChangeLog @@ -1,3 +1,19 @@ +2021-05-24 Nelson Chu <nelson.chu@sifive.com> + + PR 25212 + * config/tc-riscv.c (riscv_set_abi_by_arch): If -mabi isn't set, we + will choose ilp32e abi for rv32e. Besides, report errors for the + invalid march and mabi combinations. + * testsuite/gas/riscv/mabi-attr-rv32e.s: New testcase. Only accept + ilp32e abi for rve extension. + * testsuite/gas/riscv/mabi-fail-rv32e-lp64f.d: Likewise. + * testsuite/gas/riscv/mabi-fail-rv32e-lp64f.l: Likewise. + * testsuite/gas/riscv/mabi-fail-rv32e-lp64d.d: Likewise. + * testsuite/gas/riscv/mabi-fail-rv32e-lp64d.l: Likewise. + * testsuite/gas/riscv/mabi-fail-rv32e-lp64d.q: Likewise. + * testsuite/gas/riscv/mabi-fail-rv32e-lp64d.q: Likewise. + Renamed all mabi testcases to their march-mabi settings. + 2021-05-22 Alan Modra <amodra@gmail.com> PR 25599 diff --git a/gas/config/tc-riscv.c b/gas/config/tc-riscv.c index 3fff33e..a76e53d 100644 --- a/gas/config/tc-riscv.c +++ b/gas/config/tc-riscv.c @@ -441,6 +441,8 @@ riscv_set_abi_by_arch (void) riscv_set_abi (xlen, FLOAT_ABI_QUAD, false); else if (riscv_subset_supports ("d")) riscv_set_abi (xlen, FLOAT_ABI_DOUBLE, false); + else if (riscv_subset_supports ("e")) + riscv_set_abi (xlen, FLOAT_ABI_SOFT, true); else riscv_set_abi (xlen, FLOAT_ABI_SOFT, false); } @@ -451,6 +453,22 @@ riscv_set_abi_by_arch (void) as_bad ("can't have %d-bit ABI on %d-bit ISA", abi_xlen, xlen); else if (abi_xlen < xlen) as_bad ("%d-bit ABI not yet supported on %d-bit ISA", abi_xlen, xlen); + + if (riscv_subset_supports ("e") && !rve_abi) + as_bad ("only the ilp32e ABI is supported for e extension"); + + if (float_abi == FLOAT_ABI_SINGLE + && !riscv_subset_supports ("f")) + as_bad ("ilp32f/lp64f ABI can't be used when f extension " + "isn't supported"); + else if (float_abi == FLOAT_ABI_DOUBLE + && !riscv_subset_supports ("d")) + as_bad ("ilp32d/lp64d ABI can't be used when d extension " + "isn't supported"); + else if (float_abi == FLOAT_ABI_QUAD + && !riscv_subset_supports ("q")) + as_bad ("ilp32q/lp64q ABI can't be used when q extension " + "isn't supported"); } /* Update the EF_RISCV_FLOAT_ABI field of elf_flags. */ diff --git a/gas/testsuite/gas/riscv/mabi-attr-rv32e.s b/gas/testsuite/gas/riscv/mabi-attr-rv32e.s new file mode 100644 index 0000000..846c023 --- /dev/null +++ b/gas/testsuite/gas/riscv/mabi-attr-rv32e.s @@ -0,0 +1 @@ + .attribute arch,"rv32e" diff --git a/gas/testsuite/gas/riscv/mabi-attr-01.s b/gas/testsuite/gas/riscv/mabi-attr-rv32i.s index 178f798..178f798 100644 --- a/gas/testsuite/gas/riscv/mabi-attr-01.s +++ b/gas/testsuite/gas/riscv/mabi-attr-rv32i.s diff --git a/gas/testsuite/gas/riscv/mabi-attr-02.s b/gas/testsuite/gas/riscv/mabi-attr-rv32id.s index 667d1a6..667d1a6 100644 --- a/gas/testsuite/gas/riscv/mabi-attr-02.s +++ b/gas/testsuite/gas/riscv/mabi-attr-rv32id.s diff --git a/gas/testsuite/gas/riscv/mabi-attr-03.s b/gas/testsuite/gas/riscv/mabi-attr-rv64iq.s index 6be03e7..6be03e7 100644 --- a/gas/testsuite/gas/riscv/mabi-attr-03.s +++ b/gas/testsuite/gas/riscv/mabi-attr-rv64iq.s diff --git a/gas/testsuite/gas/riscv/mabi-fail-01.d b/gas/testsuite/gas/riscv/mabi-fail-01.d deleted file mode 100644 index 7804934..0000000 --- a/gas/testsuite/gas/riscv/mabi-fail-01.d +++ /dev/null @@ -1,3 +0,0 @@ -#as: -march-attr -mabi=lp64d -#source: mabi-attr-01.s -#error_output: mabi-fail-01.l diff --git a/gas/testsuite/gas/riscv/mabi-fail-02.d b/gas/testsuite/gas/riscv/mabi-fail-02.d deleted file mode 100644 index 2d6cfb0..0000000 --- a/gas/testsuite/gas/riscv/mabi-fail-02.d +++ /dev/null @@ -1,3 +0,0 @@ -#as: -march-attr -mabi=ilp32 -#source: mabi-attr-03.s -#error_output: mabi-fail-02.l diff --git a/gas/testsuite/gas/riscv/mabi-fail-rv32e-lp64d.d b/gas/testsuite/gas/riscv/mabi-fail-rv32e-lp64d.d new file mode 100644 index 0000000..04d402a --- /dev/null +++ b/gas/testsuite/gas/riscv/mabi-fail-rv32e-lp64d.d @@ -0,0 +1,3 @@ +#as: -march-attr -mabi=lp64d +#source: mabi-attr-rv32e.s +#error_output: mabi-fail-rv32e-lp64d.l diff --git a/gas/testsuite/gas/riscv/mabi-fail-rv32e-lp64d.l b/gas/testsuite/gas/riscv/mabi-fail-rv32e-lp64d.l new file mode 100644 index 0000000..f7306cb --- /dev/null +++ b/gas/testsuite/gas/riscv/mabi-fail-rv32e-lp64d.l @@ -0,0 +1,4 @@ +.*Assembler messages: +.*Error: can't have 64-bit ABI on 32-bit ISA +.*Error: only the ilp32e ABI is supported for e extension +.*Error: ilp32d/lp64d ABI can't be used when d extension isn't supported diff --git a/gas/testsuite/gas/riscv/mabi-fail-rv32e-lp64f.d b/gas/testsuite/gas/riscv/mabi-fail-rv32e-lp64f.d new file mode 100644 index 0000000..b7a3464 --- /dev/null +++ b/gas/testsuite/gas/riscv/mabi-fail-rv32e-lp64f.d @@ -0,0 +1,3 @@ +#as: -march-attr -mabi=lp64f +#source: mabi-attr-rv32e.s +#error_output: mabi-fail-rv32e-lp64f.l diff --git a/gas/testsuite/gas/riscv/mabi-fail-rv32e-lp64f.l b/gas/testsuite/gas/riscv/mabi-fail-rv32e-lp64f.l new file mode 100644 index 0000000..706690a --- /dev/null +++ b/gas/testsuite/gas/riscv/mabi-fail-rv32e-lp64f.l @@ -0,0 +1,4 @@ +.*Assembler messages: +.*Error: can't have 64-bit ABI on 32-bit ISA +.*Error: only the ilp32e ABI is supported for e extension +.*Error: ilp32f/lp64f ABI can't be used when f extension isn't supported diff --git a/gas/testsuite/gas/riscv/mabi-fail-rv32e-lp64q.d b/gas/testsuite/gas/riscv/mabi-fail-rv32e-lp64q.d new file mode 100644 index 0000000..e5d3c4e --- /dev/null +++ b/gas/testsuite/gas/riscv/mabi-fail-rv32e-lp64q.d @@ -0,0 +1,3 @@ +#as: -march-attr -mabi=lp64q +#source: mabi-attr-rv32e.s +#error_output: mabi-fail-rv32e-lp64q.l diff --git a/gas/testsuite/gas/riscv/mabi-fail-rv32e-lp64q.l b/gas/testsuite/gas/riscv/mabi-fail-rv32e-lp64q.l new file mode 100644 index 0000000..ab64b15 --- /dev/null +++ b/gas/testsuite/gas/riscv/mabi-fail-rv32e-lp64q.l @@ -0,0 +1,4 @@ +.*Assembler messages: +.*Error: can't have 64-bit ABI on 32-bit ISA +.*Error: only the ilp32e ABI is supported for e extension +.*Error: ilp32q/lp64q ABI can't be used when q extension isn't supported diff --git a/gas/testsuite/gas/riscv/mabi-fail-rv32i-lp64.d b/gas/testsuite/gas/riscv/mabi-fail-rv32i-lp64.d new file mode 100644 index 0000000..469a536 --- /dev/null +++ b/gas/testsuite/gas/riscv/mabi-fail-rv32i-lp64.d @@ -0,0 +1,3 @@ +#as: -march-attr -mabi=lp64 +#source: mabi-attr-rv32i.s +#error_output: mabi-fail-rv32i-lp64.l diff --git a/gas/testsuite/gas/riscv/mabi-fail-01.l b/gas/testsuite/gas/riscv/mabi-fail-rv32i-lp64.l index 65bf0ac..65bf0ac 100644 --- a/gas/testsuite/gas/riscv/mabi-fail-01.l +++ b/gas/testsuite/gas/riscv/mabi-fail-rv32i-lp64.l diff --git a/gas/testsuite/gas/riscv/mabi-fail-rv64iq-ilp32.d b/gas/testsuite/gas/riscv/mabi-fail-rv64iq-ilp32.d new file mode 100644 index 0000000..e3155f4 --- /dev/null +++ b/gas/testsuite/gas/riscv/mabi-fail-rv64iq-ilp32.d @@ -0,0 +1,3 @@ +#as: -march-attr -mabi=ilp32 +#source: mabi-attr-rv64iq.s +#error_output: mabi-fail-rv64iq-ilp32.l diff --git a/gas/testsuite/gas/riscv/mabi-fail-02.l b/gas/testsuite/gas/riscv/mabi-fail-rv64iq-ilp32.l index 8d45a07..8d45a07 100644 --- a/gas/testsuite/gas/riscv/mabi-fail-02.l +++ b/gas/testsuite/gas/riscv/mabi-fail-rv64iq-ilp32.l diff --git a/gas/testsuite/gas/riscv/mabi-noabi-attr-01a.d b/gas/testsuite/gas/riscv/mabi-noabi-attr-rv32i-01.d index 11d3ed9..b58b904 100644 --- a/gas/testsuite/gas/riscv/mabi-noabi-attr-01a.d +++ b/gas/testsuite/gas/riscv/mabi-noabi-attr-rv32i-01.d @@ -1,6 +1,6 @@ -#as: -march-attr -march=rv64ifd +#as: -march-attr -march=rv64id #readelf: -h -#source: mabi-attr-01.s +#source: mabi-attr-rv32i.s ELF Header: #... diff --git a/gas/testsuite/gas/riscv/mabi-noabi-attr-01b.d b/gas/testsuite/gas/riscv/mabi-noabi-attr-rv32i-02.d index b50ac3c..56dcd0f 100644 --- a/gas/testsuite/gas/riscv/mabi-noabi-attr-01b.d +++ b/gas/testsuite/gas/riscv/mabi-noabi-attr-rv32i-02.d @@ -1,6 +1,6 @@ -#as: -march-attr -march=rv64ifd +#as: -march-attr -march=rv64id #objdump: -d -#source: mabi-attr-01.s +#source: mabi-attr-rv32i.s .*:[ ]+file format elf32.* diff --git a/gas/testsuite/gas/riscv/mabi-noabi-attr-02a.d b/gas/testsuite/gas/riscv/mabi-noabi-attr-rv32id-01.d index 9668066..425e5d1 100644 --- a/gas/testsuite/gas/riscv/mabi-noabi-attr-02a.d +++ b/gas/testsuite/gas/riscv/mabi-noabi-attr-rv32id-01.d @@ -1,6 +1,6 @@ #as: -march-attr -march=rv64i #readelf: -h -#source: mabi-attr-02.s +#source: mabi-attr-rv32id.s ELF Header: #... diff --git a/gas/testsuite/gas/riscv/mabi-noabi-attr-02b.d b/gas/testsuite/gas/riscv/mabi-noabi-attr-rv32id-02.d index a69d0bc..8b7ee68 100644 --- a/gas/testsuite/gas/riscv/mabi-noabi-attr-02b.d +++ b/gas/testsuite/gas/riscv/mabi-noabi-attr-rv32id-02.d @@ -1,6 +1,6 @@ #as: -march-attr -march=rv64i #objdump: -d -#source: mabi-attr-02.s +#source: mabi-attr-rv32id.s .*:[ ]+file format elf32.* diff --git a/gas/testsuite/gas/riscv/mabi-noabi-attr-03a.d b/gas/testsuite/gas/riscv/mabi-noabi-attr-rv64iq-01.d index 4392b5c..0251a00 100644 --- a/gas/testsuite/gas/riscv/mabi-noabi-attr-03a.d +++ b/gas/testsuite/gas/riscv/mabi-noabi-attr-rv64iq-01.d @@ -1,6 +1,6 @@ #as: -march-attr -march=rv32i #readelf: -h -#source: mabi-attr-03.s +#source: mabi-attr-rv64iq.s ELF Header: #... diff --git a/gas/testsuite/gas/riscv/mabi-noabi-attr-03b.d b/gas/testsuite/gas/riscv/mabi-noabi-attr-rv64iq-02.d index 917ab8c..6a33ba0 100644 --- a/gas/testsuite/gas/riscv/mabi-noabi-attr-03b.d +++ b/gas/testsuite/gas/riscv/mabi-noabi-attr-rv64iq-02.d @@ -1,6 +1,6 @@ #as: -march-attr -march=rv32i #objdump: -d -#source: mabi-attr-03.s +#source: mabi-attr-rv64iq.s .*:[ ]+file format elf64.* diff --git a/gas/testsuite/gas/riscv/mabi-noabi-march-01.d b/gas/testsuite/gas/riscv/mabi-noabi-march-rv32i.d index 8ca280e..8ca280e 100644 --- a/gas/testsuite/gas/riscv/mabi-noabi-march-01.d +++ b/gas/testsuite/gas/riscv/mabi-noabi-march-rv32i.d diff --git a/gas/testsuite/gas/riscv/mabi-noabi-march-02.d b/gas/testsuite/gas/riscv/mabi-noabi-march-rv32id.d index 453fe7b..9ef28ab 100644 --- a/gas/testsuite/gas/riscv/mabi-noabi-march-02.d +++ b/gas/testsuite/gas/riscv/mabi-noabi-march-rv32id.d @@ -1,4 +1,4 @@ -#as: -march=rv32ifd +#as: -march=rv32id #readelf: -h #source: empty.s diff --git a/gas/testsuite/gas/riscv/mabi-noabi-march-03.d b/gas/testsuite/gas/riscv/mabi-noabi-march-rv64iq.d index ab2ffc3..3de0eb7 100644 --- a/gas/testsuite/gas/riscv/mabi-noabi-march-03.d +++ b/gas/testsuite/gas/riscv/mabi-noabi-march-rv64iq.d @@ -1,4 +1,4 @@ -#as: -march=rv64ifdq +#as: -march=rv64iq #readelf: -h #source: empty.s |