From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1005) id BE5393857342; Fri, 8 Jul 2022 20:18:27 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org BE5393857342 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/work093)] Revert patch. X-Act-Checkin: gcc X-Git-Author: Michael Meissner X-Git-Refname: refs/users/meissner/heads/work093 X-Git-Oldrev: 5e59c98a91e04ac5991c80db899b6470e24ade37 X-Git-Newrev: 767468d9636f3def94db004d7e97d2fb626640e8 Message-Id: <20220708201827.BE5393857342@sourceware.org> Date: Fri, 8 Jul 2022 20:18:27 +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: Fri, 08 Jul 2022 20:18:27 -0000 https://gcc.gnu.org/g:767468d9636f3def94db004d7e97d2fb626640e8 commit 767468d9636f3def94db004d7e97d2fb626640e8 Author: Michael Meissner Date: Fri Jul 8 16:17:47 2022 -0400 Revert patch. 2022-07-08 Michael Meissner gcc/ Revert patch. * config/rs6000/rs600.cc (create_complex_muldiv_inner): New function. (create_complex_muldiv): Rewrite function to handle both multiply and divide. Set the decl assembler name to change the name to the external function. gcc/testsuite/ Revert patch. * gcc.target/powerpc/mulkc3-2.c: Revert patch #7. * gcc.target/powerpc/divkc3-2.c: Likewise. libgcc/ Revert patch. * config/rs6000/float128-ifunc.c: Revert patch #7. * config/rs6000/quad-float128.h: Likewise. Diff: --- gcc/config/rs6000/rs6000.cc | 160 +++++++++------------------- gcc/testsuite/gcc.target/powerpc/divkc3-2.c | 2 +- gcc/testsuite/gcc.target/powerpc/mulkc3-2.c | 2 +- libgcc/config/rs6000/float128-ifunc.c | 6 ++ libgcc/config/rs6000/quad-float128.h | 5 + 5 files changed, 61 insertions(+), 114 deletions(-) diff --git a/gcc/config/rs6000/rs6000.cc b/gcc/config/rs6000/rs6000.cc index b482f5eee99..541b4679907 100644 --- a/gcc/config/rs6000/rs6000.cc +++ b/gcc/config/rs6000/rs6000.cc @@ -11031,6 +11031,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 @@ -11126,107 +11146,6 @@ init_float128_ieee (machine_mode mode) } } -/* Create a decls for complex long double multiply and complex long double - divide for the 128-bit floating point types. - - 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. - - Similarly for __ibm128, we want to use __multc3 and __divtc3. - - For these cases, we create a decl with a different name, and then set the - ASM name so that we don't have to change libgcc to provide these extra - names. We can't just use the same name because we will get an abort if a - built-in function uses the same name. - - The complex multiply/divide functions are encoded as builtin functions with - a complex result and 4 scalar inputs. */ - -/* Inner function to create a single complex multiply or complex divide - function. - - Mul_or_div is either "mul" or "div" depending on whether we are creating - multiply or divide. - - Lib_mode_name is "ic", "kc", or "tc" (i.e. the 2 letter mode for the complex - type being created). - - Asm_mode_name is "kc" or "tc" (i.e. the 2 letter mode for the function that - will be called). - - Fncode is the function code of the multiply/divide built-in function. - - Fntype is the tree type node of the function. */ - -static void -create_complex_muldiv_inner (const char *mul_or_div, - const char *lib_mode_name, - const char *asm_mode_name, - built_in_function fncode, - tree fntype) -{ - char *asm_name = ACONCAT (("__", mul_or_div, asm_mode_name, "3", NULL)); - char *name = ACONCAT (("__", mul_or_div, lib_mode_name, "3_", asm_mode_name, - NULL)); - - tree fndecl = add_builtin_function (name, fntype, fncode, BUILT_IN_NORMAL, - asm_name, NULL_TREE); - - set_builtin_decl (fncode, fndecl, true); - - if (TARGET_DEBUG_BUILTIN) - fprintf (stderr, "create complex %s (%s), fncode: %d\n", name, asm_name, - (int) fncode); - - return; -} - -/* Create both complex multiply and complex divide for a given 128-bit floating - point type. - - Lib_mode_name is "ic", "kc", or "tc" (i.e. the 2 letter mode for the complex - type being created). - - Asm_mode_name is "kc" or "tc" (i.e. the 2 letter mode for the function that - will be called). - - Complex_mode is the mode of the complex type (i.e. KCmode, ICmode, or - TCmode). - - Arg_type is the type of scalar 128-bit floating point type (i.e. the - _Float128, __ibm128, or long double type nodes). */ - -static void -create_complex_muldiv (const char *lib_mode_name, - const char *asm_mode_name, - machine_mode complex_mode, - tree arg_type) -{ - tree complex_type = (arg_type == long_double_type_node - ? complex_long_double_type_node - : build_complex_type (arg_type)); - tree fntype = build_function_type_list (complex_type, arg_type, arg_type, - arg_type, arg_type, NULL_TREE); - - /* Build complex multiply. */ - built_in_function mul_fncode = - (built_in_function) (BUILT_IN_COMPLEX_MUL_MIN + complex_mode - - MIN_MODE_COMPLEX_FLOAT); - - create_complex_muldiv_inner ("mul", lib_mode_name, asm_mode_name, mul_fncode, - fntype); - - /* Build complex divide. */ - built_in_function div_fncode = - (built_in_function) (BUILT_IN_COMPLEX_DIV_MIN + complex_mode - - MIN_MODE_COMPLEX_FLOAT); - - create_complex_muldiv_inner ("div", lib_mode_name, asm_mode_name, div_fncode, - fntype); - return; -} - static void rs6000_init_libfuncs (void) { @@ -11249,27 +11168,44 @@ rs6000_init_libfuncs (void) init_float128_ieee (TFmode); } - /* Set up to call the appropriate __mul{kc,tc}3 and __div{kc,tc}3 for the - 128-bit floating point types, using kc3 for IEEE 128-bit and tc3 for IBM - 128-bit. We only call this for the functions that don't use the default - names. + /* 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 (!complex_muldiv_init_p - && (TARGET_FLOAT128_TYPE || TARGET_LONG_DOUBLE_128)) + if (TARGET_FLOAT128_TYPE && TARGET_IEEEQUAD && TARGET_LONG_DOUBLE_128 + && !complex_muldiv_init_p) { complex_muldiv_init_p = true; - /* Create __ibm128 complex multiply divide. */ - create_complex_muldiv ("ic", "tc", ICmode, ibm128_float_type_node); + 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); - if (TARGET_LONG_DOUBLE_128 && TARGET_IEEEQUAD) - /* Create long double (IEEE 128-bit) complex multiply/divide. */ - create_complex_muldiv ("tc", "kc", TCmode, long_double_type_node); + create_complex_muldiv ("__divtc3_ieee128", div_fncode, fntype); } } diff --git a/gcc/testsuite/gcc.target/powerpc/divkc3-2.c b/gcc/testsuite/gcc.target/powerpc/divkc3-2.c index e34ed40bac2..0cfcea837ed 100644 --- a/gcc/testsuite/gcc.target/powerpc/divkc3-2.c +++ b/gcc/testsuite/gcc.target/powerpc/divkc3-2.c @@ -14,4 +14,4 @@ divide (cld_t *p, cld_t *q, cld_t *r) *p = *q / *r; } -/* { dg-final { scan-assembler "bl __divkc3" } } */ +/* { dg-final { scan-assembler "bl __divtc3_ieee128" } } */ diff --git a/gcc/testsuite/gcc.target/powerpc/mulkc3-2.c b/gcc/testsuite/gcc.target/powerpc/mulkc3-2.c index eee6de9e2a5..78ef1dc00f0 100644 --- a/gcc/testsuite/gcc.target/powerpc/mulkc3-2.c +++ b/gcc/testsuite/gcc.target/powerpc/mulkc3-2.c @@ -14,4 +14,4 @@ multiply (cld_t *p, cld_t *q, cld_t *r) *p = *q * *r; } -/* { dg-final { scan-assembler "bl __mulkc3" } } */ +/* { dg-final { scan-assembler "bl __multc3_ieee128" } } */ 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. */