https://gcc.gnu.org/g:243e634f5bee3912685756f31d3648df73fa6938
commit r14-11456-g243e634f5bee3912685756f31d3648df73fa6938 Author: Lulu Cheng <chengl...@loongson.cn> Date: Sat Mar 22 14:37:01 2025 +0800 LoongArch: Support Q suffix for __float128. In r14-3635 supports `__float128`, but does not support the 'q/Q' suffix. PR target/119408 gcc/ChangeLog: * config/loongarch/loongarch.cc (loongarch_c_mode_for_suffix): New. (TARGET_C_MODE_FOR_SUFFIX): Define. gcc/testsuite/ChangeLog: * gcc.target/loongarch/pr119408.c: New test. (cherry picked from commit 7c8da04c412ed4f54596f10434aa46592d000fbf) Diff: --- gcc/config/loongarch/loongarch.cc | 13 +++++++++++++ gcc/testsuite/gcc.target/loongarch/pr119408.c | 12 ++++++++++++ 2 files changed, 25 insertions(+) diff --git a/gcc/config/loongarch/loongarch.cc b/gcc/config/loongarch/loongarch.cc index 4b456e3ef1f5..afedc8e33e44 100644 --- a/gcc/config/loongarch/loongarch.cc +++ b/gcc/config/loongarch/loongarch.cc @@ -11004,6 +11004,16 @@ loongarch_asm_code_end (void) #undef DUMP_FEATURE } +/* Target hook for c_mode_for_suffix. */ +static machine_mode +loongarch_c_mode_for_suffix (char suffix) +{ + if (suffix == 'q') + return TFmode; + + return VOIDmode; +} + /* Initialize the GCC target structure. */ #undef TARGET_ASM_ALIGNED_HI_OP #define TARGET_ASM_ALIGNED_HI_OP "\t.half\t" @@ -11263,6 +11273,9 @@ loongarch_asm_code_end (void) #define TARGET_VECTORIZE_SUPPORT_VECTOR_MISALIGNMENT \ loongarch_builtin_support_vector_misalignment +#undef TARGET_C_MODE_FOR_SUFFIX +#define TARGET_C_MODE_FOR_SUFFIX loongarch_c_mode_for_suffix + struct gcc_target targetm = TARGET_INITIALIZER; #include "gt-loongarch.h" diff --git a/gcc/testsuite/gcc.target/loongarch/pr119408.c b/gcc/testsuite/gcc.target/loongarch/pr119408.c new file mode 100644 index 000000000000..f46399aa0b59 --- /dev/null +++ b/gcc/testsuite/gcc.target/loongarch/pr119408.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -Wno-pedantic" } */ + +__float128 a; +__float128 b; +void +test (void) +{ + a = 1.11111111Q; + b = 1.434345q; +} +