[v2,02/14] LoongArch: Fix default ISA setting
Checks
Commit Message
When loongarch_arch_target is called, la_target has not been
initialized, thus the macro LARCH_ACTUAL_ARCH always equals to zero.
This commit fixes by expanding the macro and reading the latest value.
It permits -march=loongarch64 when the default target is loongarch32 and
vice versa.
gcc/ChangeLog:
* config/loongarch/loongarch-opts.cc (loongarch_config_target):
Fix -march detection.
gcc/testsuite/ChangeLog:
* gcc.target/loongarch/arch-1.c: New test.
* gcc.target/loongarch/arch-2.c: New test.
---
gcc/config/loongarch/loongarch-opts.cc | 5 ++++-
gcc/testsuite/gcc.target/loongarch/arch-1.c | 5 +++++
gcc/testsuite/gcc.target/loongarch/arch-2.c | 5 +++++
3 files changed, 14 insertions(+), 1 deletion(-)
create mode 100644 gcc/testsuite/gcc.target/loongarch/arch-1.c
create mode 100644 gcc/testsuite/gcc.target/loongarch/arch-2.c
@@ -246,7 +246,10 @@ loongarch_config_target (struct loongarch_target *target,
config_target_isa:
/* Get default ISA from "-march" or its default value. */
- t.isa = loongarch_cpu_default_isa[LARCH_ACTUAL_ARCH];
+ if (t.cpu_arch == TARGET_ARCH_NATIVE)
+ t.isa = loongarch_cpu_default_isa[t.cpu_native];
+ else
+ t.isa = loongarch_cpu_default_isa[t.cpu_arch];
/* Apply incremental changes. */
/* "-march=native" overrides the default FPU type. */
new file mode 100644
@@ -0,0 +1,5 @@
+/* { dg-do compile } */
+/* { dg-options "-march=loongarch64 -mabi=lp64d" } */
+int foo()
+{
+}
new file mode 100644
@@ -0,0 +1,5 @@
+/* { dg-do compile } */
+/* { dg-options "-march=loongarch32 -mabi=ilp32d" } */
+int foo()
+{
+}