The current order of gcc and binutils parsing extensions is inconsistent.
According to latest risc-v spec, the canonical order in which extension names must
appear in the name string specified in Table 29.1 is different from before.
In the latest table, non-standard extensions must be listed after all standard
extensions. To keep consistent, we now change the parsing order.
Related llvm patch links:
https://reviews.llvm.org/
D148315
gcc/ChangeLog:
* common/config/riscv/riscv-common.cc (multi_letter_subset_rank): Swap the order
of z-extensions and s-extensions.
(riscv_subset_list::parse): Likewise.
gcc/testsuite/ChangeLog:
* gcc.target/riscv/arch-5.c: Likewise.
char multiletter_class = subset[0];
switch (multiletter_class)
{
- case 's':
+ case 'z':
high_order = 0;
break;
- case 'z':
+ case 's':
high_order = 1;
break;
case 'x':
if (p == NULL)
goto fail;
- /* Parsing supervisor extension. */
- p = subset_list->parse_multiletter_ext (p, "s", "supervisor extension");
+ /* Parsing sub-extensions. */
+ p = subset_list->parse_multiletter_ext (p, "z", "sub-extension");
if (p == NULL)
goto fail;
- /* Parsing sub-extensions. */
- p = subset_list->parse_multiletter_ext (p, "z", "sub-extension");
+ /* Parsing supervisor extension. */
+ p = subset_list->parse_multiletter_ext (p, "s", "supervisor extension");
if (p == NULL)
goto fail;
/* { dg-do compile } */
-/* { dg-options "-march=rv32isabc_zfoo_xbar -mabi=ilp32" } */
+/* { dg-options "-march=rv32i_zfoo_sabc_xbar -mabi=ilp32" } */
int foo()
{
}