On Sun, 2023-08-06 at 20:49 +0800, Jiajie Chen via Gcc-patches wrote: > 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.
Nit: the first letter 'F' of the second line should align with '*' of the first line, not 'c'. /* snip */ > diff --git a/gcc/testsuite/gcc.target/loongarch/arch-3.c > b/gcc/testsuite/gcc.target/loongarch/arch-3.c > new file mode 100644 > index 00000000000..543b93883bd > --- /dev/null > +++ b/gcc/testsuite/gcc.target/loongarch/arch-3.c > @@ -0,0 +1,6 @@ > +/* { dg-do compile } */ > +/* { dg-options "-march=loongarch64 -mabi=ilp32d" } */ > +int foo() > +{ > +} > +/* { dg-error "unable to implement ABI 'ilp32d' with instruction set > 'la64/fpu64'" "" { target *-*-* } 0 } */ This is just wrong. It's absolutely possible to implement ilp32d with la64/fpu64. LoongArch *.w instructions are always 32-bit operations, no matter on LA32 or LA64. They are different from RISC-V where many instructions operate on 32-bit integers on RV32 but 64-bit integers on RV64. If you don't want to spend your time to implement it you should use `sorry ("%<-mabi=ilp32d%> is not implemented for la64");` instead. Yes, I know there is some (mis)uses of TARGET_64BIT in the config/loongarch code where TARGET_ABI_LP64 should be actually used instead. They are bugs preventing us from implementing -mabi=ilp32d - march=loongarch64 and they should be fixed. They are not our excuse to blindly "simulate" what RISC-V has. -- Xi Ruoyao <xry...@xry111.site> School of Aerospace Science and Technology, Xidian University