From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1005) id 3716E38582A7; Tue, 2 Aug 2022 18:08:46 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3716E38582A7 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/work096)] Revert patch. X-Act-Checkin: gcc X-Git-Author: Michael Meissner X-Git-Refname: refs/users/meissner/heads/work096 X-Git-Oldrev: 24371f3904ec916001745f6ac8bc012113940304 X-Git-Newrev: 3c09dc57a78a25094b9caa51a2f4d24ea7d29d3e Message-Id: <20220802180846.3716E38582A7@sourceware.org> Date: Tue, 2 Aug 2022 18:08:46 +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: Tue, 02 Aug 2022 18:08:46 -0000 https://gcc.gnu.org/g:3c09dc57a78a25094b9caa51a2f4d24ea7d29d3e commit 3c09dc57a78a25094b9caa51a2f4d24ea7d29d3e Author: Michael Meissner Date: Tue Aug 2 14:08:09 2022 -0400 Revert patch. 2022-08-02 Michael Meissner gcc/ Revert patch. * config/rs6000/rs6000.cc (create_complex_muldiv): Delete. (init_float128_ieee): Delete code to switch complex multiply and divide for long double. (complex_multiply_name): New helper function. (complex_divide_name): Likewise. (rs6000_mangle_decl_assembler_name): Add support for mangling the name of complex 128-bit multiply and divide built-in functions. Diff: --- gcc/config/rs6000/rs6000.cc | 109 +++++++++++++++++++------------------------- 1 file changed, 47 insertions(+), 62 deletions(-) diff --git a/gcc/config/rs6000/rs6000.cc b/gcc/config/rs6000/rs6000.cc index fe70da93be6..a6ec4c71ac0 100644 --- a/gcc/config/rs6000/rs6000.cc +++ b/gcc/config/rs6000/rs6000.cc @@ -10966,6 +10966,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 @@ -10977,6 +10997,32 @@ init_float128_ieee (machine_mode mode) { if (FLOAT128_VECTOR_P (mode)) { + static bool complex_muldiv_init_p = false; + + /* Set up to call __mulkc3 and __divkc3 under -mabi=ieeelongdouble. If + we have clone or target attributes, this will be called a second + time. We want to create the built-in function only once. */ + if (mode == TFmode && TARGET_IEEEQUAD && !complex_muldiv_init_p) + { + complex_muldiv_init_p = true; + built_in_function fncode_mul = + (built_in_function) (BUILT_IN_COMPLEX_MUL_MIN + TCmode + - MIN_MODE_COMPLEX_FLOAT); + built_in_function fncode_div = + (built_in_function) (BUILT_IN_COMPLEX_DIV_MIN + TCmode + - MIN_MODE_COMPLEX_FLOAT); + + 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_muldiv ("__mulkc3", fncode_mul, fntype); + create_complex_muldiv ("__divkc3", fncode_div, fntype); + } + set_optab_libfunc (add_optab, mode, "__addkf3"); set_optab_libfunc (sub_optab, mode, "__subkf3"); set_optab_libfunc (neg_optab, mode, "__negkf2"); @@ -27924,25 +27970,6 @@ rs6000_starting_frame_offset (void) return RS6000_STARTING_FRAME_OFFSET; } -/* Internal function to return the built-in function id for the complex - multiply operation for a given mode. */ - -static inline built_in_function -complex_multiply_name (machine_mode mode) -{ - return (built_in_function) (BUILT_IN_COMPLEX_DIV_MIN + mode - - MIN_MODE_COMPLEX_FLOAT); -} - -/* Internal function to return the built-in function id for the complex divide - operation for a given mode. */ - -static inline built_in_function -complex_divide_name (machine_mode mode) -{ - return (built_in_function) (BUILT_IN_COMPLEX_DIV_MIN + mode - - MIN_MODE_COMPLEX_FLOAT); -} /* On 64-bit Linux and Freebsd systems, possibly switch the long double library function names from l to f128 if the default long double type is @@ -27961,53 +27988,11 @@ complex_divide_name (machine_mode mode) only do this transformation if the __float128 type is enabled. This prevents us from doing the transformation on older 32-bit ports that might have enabled using IEEE 128-bit floating point as the default long double - type. - - We also use the TARGET_MANGLE_DECL_ASSEMBLER_NAME hook to change the - function names used for complex multiply and divide to the appropriate - names. */ + type. */ static tree rs6000_mangle_decl_assembler_name (tree decl, tree id) { - /* Handle complex multiply/divide. For IEEE 128-bit, use __mulkc3 or - __divkc3 and for IBM 128-bit use __multc3 and __divtc3. */ - if ((TARGET_FLOAT128_TYPE || TARGET_IBM128) - && TREE_CODE (decl) == FUNCTION_DECL - && DECL_IS_UNDECLARED_BUILTIN (decl) - && DECL_BUILT_IN_CLASS (decl) == BUILT_IN_NORMAL) - { - built_in_function id = DECL_FUNCTION_CODE (decl); - const char *newname = NULL; - - if (id == complex_multiply_name (KCmode)) - newname = "__mulkc3"; - - else if (id == complex_multiply_name (ICmode)) - newname = "__multc3"; - - else if (id == complex_multiply_name (TCmode)) - newname = (TARGET_IEEEQUAD) ? "__mulkc3" : "__multc3"; - - else if (id == complex_divide_name (KCmode)) - newname = "__divkc3"; - - else if (id == complex_divide_name (ICmode)) - newname = "__divtc3"; - - else if (id == complex_divide_name (TCmode)) - newname = (TARGET_IEEEQUAD) ? "__divkc3" : "__divtc3"; - - if (newname) - { - if (TARGET_DEBUG_BUILTIN) - fprintf (stderr, "Map complex mul/div => %s\n", newname); - - return get_identifier (newname); - } - } - - /* Map long double built-in functions if long double is IEEE 128-bit. */ if (TARGET_FLOAT128_TYPE && TARGET_IEEEQUAD && TARGET_LONG_DOUBLE_128 && TREE_CODE (decl) == FUNCTION_DECL && DECL_IS_UNDECLARED_BUILTIN (decl)