]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
LoongArch: Support Q suffix for __float128.
authorLulu Cheng <chenglulu@loongson.cn>
Sat, 22 Mar 2025 06:37:01 +0000 (14:37 +0800)
committerLulu Cheng <chenglulu@loongson.cn>
Thu, 27 Mar 2025 06:59:02 +0000 (14:59 +0800)
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.

gcc/config/loongarch/loongarch.cc
gcc/testsuite/gcc.target/loongarch/pr119408.c [new file with mode: 0644]

index 01f048664b55eeea3201b4265b96c2092e2bef3d..7533e53839f43c7f82f2d36b00c05fd2de1384e2 100644 (file)
@@ -11206,6 +11206,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"
@@ -11477,6 +11487,9 @@ loongarch_asm_code_end (void)
 #undef TARGET_OPTION_VALID_ATTRIBUTE_P
 #define TARGET_OPTION_VALID_ATTRIBUTE_P loongarch_option_valid_attribute_p
 
+#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 (file)
index 0000000..f46399a
--- /dev/null
@@ -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;       
+}
+