Message ID | 20220402050041.21302-3-palmer@rivosinc.com (mailing list archive) |
---|---|
State | Mainlined, archived |
Headers | show |
Series | RISC-V -march handling improvements | expand |
On Fri, Apr 01, 2022 at 10:00:37PM -0700, Palmer Dabbelt wrote: > GCC's semantics for "-march=X -march=Y" are that Y entirely overrides X, > but sparse takes the union of these two ISA strings. OK, but then I prefer to explicitly clear riscv_flags at the start of the function, like: diff --git a/target-riscv.c b/target-riscv.c index 3bba7c15ff1f..ca38d76e6465 100644 --- a/target-riscv.c +++ b/target-riscv.c @@ -54,6 +54,9 @@ static void parse_march_riscv(const char *arg) }; int i; + // Each -march=.. options entirely overrides previous ones + riscv_flags = 0; + for (i = 0; i < ARRAY_SIZE(basic_sets); i++) { const char *pat = basic_sets[i].pattern; size_t len = strlen(pat); -- Luc
diff --git a/target-riscv.c b/target-riscv.c index f5cc6cc3..494c08db 100644 --- a/target-riscv.c +++ b/target-riscv.c @@ -56,7 +56,7 @@ static void parse_march_riscv(const char *arg) size_t len = strlen(pat); if (!strncmp(arg, pat, len)) { - riscv_flags |= basic_sets[i].flags; + riscv_flags = basic_sets[i].flags; arg += len; goto ext; }
GCC's semantics for "-march=X -march=Y" are that Y entirely overrides X, but sparse takes the union of these two ISA strings. This fixes the behavior by setting, instead of oring, the flags whenever a base ISA is encountered. RISC-V ISA strings can only have a single base ISA, it's not like x86 where the 64-bit ISA is an extension of the 32-bit ISA. Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com> --- target-riscv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)