public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc(refs/users/meissner/heads/work092)] Iterate on getting long double complex multiply and divide working.
@ 2022-06-23 18:35 Michael Meissner
0 siblings, 0 replies; 2+ messages in thread
From: Michael Meissner @ 2022-06-23 18:35 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:b9e7eb58e577057fb288bfe202bb7a2563289083
commit b9e7eb58e577057fb288bfe202bb7a2563289083
Author: Michael Meissner <meissner@linux.ibm.com>
Date: Thu Jun 23 14:34:49 2022 -0400
Iterate on getting long double complex multiply and divide working.
2022-06-23 Michael Meissner <meissner@linux.ibm.com>
gcc/
* config/rs6000/rs6000-builtin.cc (rs6000_type_string): The type
for __float128 is __float128, not __ieee128.
* config/rs6000/rs6000.cc (create_complex_muldiv): Add function
back in.
(rs6000_init_libfuncs): Move the IEEE 128-bit complex long double
multiply and divide support here. Use the names __multc3_ieee128
and __divtc3_ieee128.
libgcc/
* config/rs6000/float128-ifunc.c (__multc3_ieee128): Add
ifunc support.
(__divtc3_ieee128): Likewise.
* config/rs6000/quad-float128.h (__multc3_ieee128): Add
Declaration.
(__divtc3_ieee128): Likewise.
Diff:
---
gcc/config/rs6000/rs6000-builtin.cc | 2 +-
gcc/config/rs6000/rs6000.cc | 60 +++++++++++++++++++++++++++++++++++
libgcc/config/rs6000/float128-ifunc.c | 6 ++++
libgcc/config/rs6000/quad-float128.h | 5 +++
4 files changed, 72 insertions(+), 1 deletion(-)
diff --git a/gcc/config/rs6000/rs6000-builtin.cc b/gcc/config/rs6000/rs6000-builtin.cc
index b43a8039ad6..70cbca98e57 100644
--- a/gcc/config/rs6000/rs6000-builtin.cc
+++ b/gcc/config/rs6000/rs6000-builtin.cc
@@ -435,7 +435,7 @@ const char *rs6000_type_string (tree type_node)
else if (type_node == ibm128_float_type_node)
return "__ibm128";
else if (type_node == ieee128_float_type_node)
- return "__ieee128";
+ return "__float128";
else if (type_node == opaque_V4SI_type_node)
return "opaque";
else if (POINTER_TYPE_P (type_node))
diff --git a/gcc/config/rs6000/rs6000.cc b/gcc/config/rs6000/rs6000.cc
index c036b05a077..17cb9bf7729 100644
--- a/gcc/config/rs6000/rs6000.cc
+++ b/gcc/config/rs6000/rs6000.cc
@@ -11034,6 +11034,26 @@ init_float128_ibm (machine_mode mode)
}
}
+/* Create a decl for either complex long double multiply or complex long double
+ divide when long double is IEEE 128-bit floating point. We can't use
+ __multc3 and __divtc3 because the original long double using IBM extended
+ double used those names. The complex multiply/divide functions are encoded
+ as builtin functions with a complex result and 4 scalar inputs. */
+
+static void
+create_complex_muldiv (const char *name, built_in_function fncode, tree fntype)
+{
+ tree fndecl = add_builtin_function (name, fntype, fncode, BUILT_IN_NORMAL,
+ name, NULL_TREE);
+
+ set_builtin_decl (fncode, fndecl, true);
+
+ if (TARGET_DEBUG_BUILTIN)
+ fprintf (stderr, "create complex %s, fncode: %d\n", name, (int) fncode);
+
+ return;
+}
+
/* Set up IEEE 128-bit floating point routines. Use different names if the
arguments can be passed in a vector register. The historical PowerPC
implementation of IEEE 128-bit floating point used _q_<op> for the names, so
@@ -11149,6 +11169,46 @@ rs6000_init_libfuncs (void)
else
init_float128_ieee (TFmode);
}
+
+ /* Set up to call __mulkc3 and __divkc3 when long double uses the IEEE
+ 128-bit encoding. We cannot use the same name (__mulkc3 or __divkc3 for
+ both IEEE long double and for explicit _Float128/__float128) because
+ c_builtin_function will complain if we create two built-in functions with
+ the same name. Instead we use an alias name for the case when long double
+ uses the IEEE 128-bit encoding. Libgcc will create a weak alias reference
+ for this name.
+
+ We need to only execute this once. If we have clone or target attributes,
+ this will be called a second time. We need to create the built-in
+ function only once. */
+ static bool complex_muldiv_init_p = false;
+
+ if (TARGET_FLOAT128_TYPE && TARGET_IEEEQUAD && TARGET_LONG_DOUBLE_128
+ && !complex_muldiv_init_p)
+ {
+ complex_muldiv_init_p = true;
+
+ tree fntype = build_function_type_list (complex_long_double_type_node,
+ long_double_type_node,
+ long_double_type_node,
+ long_double_type_node,
+ long_double_type_node,
+ NULL_TREE);
+
+ /* Create complex multiply. */
+ built_in_function mul_fncode =
+ (built_in_function) (BUILT_IN_COMPLEX_MUL_MIN + TCmode
+ - MIN_MODE_COMPLEX_FLOAT);
+
+ create_complex_muldiv ("__multc3_ieee128", mul_fncode, fntype);
+
+ /* Create complex divide. */
+ built_in_function div_fncode =
+ (built_in_function) (BUILT_IN_COMPLEX_DIV_MIN + TCmode
+ - MIN_MODE_COMPLEX_FLOAT);
+
+ create_complex_muldiv ("__divtc3_ieee128", div_fncode, fntype);
+ }
}
/* Emit a potentially record-form instruction, setting DST from SRC.
diff --git a/libgcc/config/rs6000/float128-ifunc.c b/libgcc/config/rs6000/float128-ifunc.c
index 73cbca2fc9a..30d46bcb233 100644
--- a/libgcc/config/rs6000/float128-ifunc.c
+++ b/libgcc/config/rs6000/float128-ifunc.c
@@ -359,3 +359,9 @@ TCtype __mulkc3 (TFtype, TFtype, TFtype, TFtype)
TCtype __divkc3 (TFtype, TFtype, TFtype, TFtype)
__attribute__ ((__ifunc__ ("__divkc3_resolve")));
+
+TCtype __multc3_ieee128 (TFtype, TFtype, TFtype, TFtype)
+ __attribute__ ((__ifunc__ ("__mulkc3_resolve")));
+
+TCtype __divtc3_ieee128 (TFtype, TFtype, TFtype, TFtype)
+ __attribute__ ((__ifunc__ ("__divkc3_resolve")));
diff --git a/libgcc/config/rs6000/quad-float128.h b/libgcc/config/rs6000/quad-float128.h
index ae0622c744c..a684d0e1bcf 100644
--- a/libgcc/config/rs6000/quad-float128.h
+++ b/libgcc/config/rs6000/quad-float128.h
@@ -191,6 +191,11 @@ extern TFtype __trunctfkf2 (IBM128_TYPE);
extern TCtype __mulkc3 (TFtype, TFtype, TFtype, TFtype);
extern TCtype __divkc3 (TFtype, TFtype, TFtype, TFtype);
+/* Complex long double multiply/divide if long double uses the IEEE 128-bit
+ encoding. */
+extern TCtype __multc3_ieee128 (TFtype, TFtype, TFtype, TFtype);
+extern TCtype __divtc3_ieee128 (TFtype, TFtype, TFtype, TFtype);
+
/* Convert IEEE 128-bit floating point to/from string. We explicitly use
_Float128 instead of TFmode because _strtokf and _strfromkf must be compiled
with long double being IBM 128. */
^ permalink raw reply [flat|nested] 2+ messages in thread
* [gcc(refs/users/meissner/heads/work092)] Iterate on getting long double complex multiply and divide working.
@ 2022-06-23 18:36 Michael Meissner
0 siblings, 0 replies; 2+ messages in thread
From: Michael Meissner @ 2022-06-23 18:36 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:3bf9eb89527d1093b6ada42982054dfd520a1c6b
commit 3bf9eb89527d1093b6ada42982054dfd520a1c6b
Author: Michael Meissner <meissner@linux.ibm.com>
Date: Thu Jun 23 14:36:06 2022 -0400
Iterate on getting long double complex multiply and divide working.
2022-06-23 Michael Meissner <meissner@linux.ibm.com>
gcc/
* config/rs6000/rs6000-builtin.cc (rs6000_type_string): The type
for __float128 is __float128, not __ieee128.
* config/rs6000/rs6000.cc (create_complex_muldiv): Add function
back in.
(rs6000_init_libfuncs): Move the IEEE 128-bit complex long double
multiply and divide support here. Use the names __multc3_ieee128
and __divtc3_ieee128.
libgcc/
* config/rs6000/float128-ifunc.c (__multc3_ieee128): Add
ifunc support.
(__divtc3_ieee128): Likewise.
* config/rs6000/quad-float128.h (__multc3_ieee128): Add
Declaration.
(__divtc3_ieee128): Likewise.
Diff:
---
gcc/ChangeLog.meissner | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)
diff --git a/gcc/ChangeLog.meissner b/gcc/ChangeLog.meissner
index be6ca55473e..76d9bb695d9 100644
--- a/gcc/ChangeLog.meissner
+++ b/gcc/ChangeLog.meissner
@@ -1,3 +1,26 @@
+==================== Work092, patch #2
+
+Iterate on getting long double complex multiply and divide working.
+
+2022-06-23 Michael Meissner <meissner@linux.ibm.com>
+
+gcc/
+ * config/rs6000/rs6000-builtin.cc (rs6000_type_string): The type
+ for __float128 is __float128, not __ieee128.
+ * config/rs6000/rs6000.cc (create_complex_muldiv): Add function
+ back in.
+ (rs6000_init_libfuncs): Move the IEEE 128-bit complex long double
+ multiply and divide support here. Use the names __multc3_ieee128
+ and __divtc3_ieee128.
+
+libgcc/
+ * config/rs6000/float128-ifunc.c (__multc3_ieee128): Add
+ ifunc support.
+ (__divtc3_ieee128): Likewise.
+ * config/rs6000/quad-float128.h (__multc3_ieee128): Add
+ Declaration.
+ (__divtc3_ieee128): Likewise.
+
==================== Work092, patch #1
__float128 and __ibm128 always gets different internal types.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-06-23 18:36 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-23 18:35 [gcc(refs/users/meissner/heads/work092)] Iterate on getting long double complex multiply and divide working Michael Meissner
2022-06-23 18:36 Michael Meissner
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).