From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1005) id DBA0A3856268; Thu, 23 Jun 2022 18:35:11 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org DBA0A3856268 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Michael Meissner To: gcc-cvs@gcc.gnu.org Subject: [gcc(refs/users/meissner/heads/work092)] Iterate on getting long double complex multiply and divide working. X-Act-Checkin: gcc X-Git-Author: Michael Meissner X-Git-Refname: refs/users/meissner/heads/work092 X-Git-Oldrev: 035103b88ab819c60160f42fd1b8bda4fae67040 X-Git-Newrev: b9e7eb58e577057fb288bfe202bb7a2563289083 Message-Id: <20220623183511.DBA0A3856268@sourceware.org> Date: Thu, 23 Jun 2022 18:35:11 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 23 Jun 2022 18:35:12 -0000 https://gcc.gnu.org/g:b9e7eb58e577057fb288bfe202bb7a2563289083 commit b9e7eb58e577057fb288bfe202bb7a2563289083 Author: Michael Meissner Date: Thu Jun 23 14:34:49 2022 -0400 Iterate on getting long double complex multiply and divide working. 2022-06-23 Michael Meissner 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_ 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. */