From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1005) id 28EE03858D32; Sat, 30 Jul 2022 02:15:22 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 28EE03858D32 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/work095)] Make __float128 use a different type from long double. X-Act-Checkin: gcc X-Git-Author: Michael Meissner X-Git-Refname: refs/users/meissner/heads/work095 X-Git-Oldrev: dd6f750133ca1f3f8aa39f02f03f2bd09c43f790 X-Git-Newrev: a043922c8e13ba5df761f8fcbca564a943ab8541 Message-Id: <20220730021522.28EE03858D32@sourceware.org> Date: Sat, 30 Jul 2022 02:15:22 +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: Sat, 30 Jul 2022 02:15:22 -0000 https://gcc.gnu.org/g:a043922c8e13ba5df761f8fcbca564a943ab8541 commit a043922c8e13ba5df761f8fcbca564a943ab8541 Author: Michael Meissner Date: Fri Jul 29 22:15:04 2022 -0400 Make __float128 use a different type from long double. This patch changes GCC so that __float128 use different types internally than long double. In the past, GCC would use the long double type for __float128 if -mabi=ieeelongdouble was used. Currently we are not changing __ibm128 to have a separate type. There are some complications that need to be addressed (such as C++ mangling) before we can make the change for __ibm128. The rs6000 internal ieee128_float_type_node is deleted in favor of using the standard float128_type_node. I deleted the code in rs6000_expand_builtin which used to convert some built-in functions that used KFmode arguments to the equivalent built-in functions that used TFmode arguments if -mabi=ieeelongdouble. I also deleted the code that converted the built-ins that used IFmode arguments to the equivalant functions that used TFmode arguments if -mabi=ibmlongdouble. I deleted the code in rs6000_builtin_type_compatible that said two 128-bit floating point types are compatible if they have the same encoding. With overloading support we don't need this any longer. I deleted the translate mode attribute hook which is no longer need with these changes. I changed how complex 128-bit long double multiply and divide are done. The previous code indrectly depended on the type mode for __float128 being long double, and it no longer works when __float128 always has a unique type. To do this, I had to create two new functions (__multc3_ieee128 and divtc3_ieee128) which are called in this case. I added support in libgcc to make the ifunc support for these functions use the __mulkc3 and __divkc3 functions. I split the define_insn_and_splits for converting between two IEEE 128-bit types or two IBM 128-bit types into separate insns, one for converting between IEEE 128-bit types, and the other for converting between IBM 128-bit types. One benefit of doing this is that we can get the type and length attributes correct for each move. 2022-07-29 Michael Meissner gcc/ * config/rs6000/rs6000-builtin.cc (rs6000_type_string): Replace ieee128_float_type_node with float128_type_node. (rs6000_init_builtins): Use the float128_type_node for __float128 even if long double uses the IEEE 128-bit encoding. The type node for __ibm128 is a unqiue type node even if long double uses the IBM 128-bit encoding. (rs6000_expand_builtin): Delete code that converted built-in functions using KFmode to the equivalant built-in function using TFmode if -mabi=ieeelongdouble. Delete code that coverted built-in functions using IFmode to the equivalent built-in function using TFmode if -mabi=ibmlongdouble. * config/rs6000/rs6000-c.c (rs6000_target_modify_macros): Delete reference to ieee128_float_type_node. (rs6000_cpu_cpp_builtins): Delete reference to ieee128_float_type_node. Use TARGET_IBM128 for checking if __ibm128 is supported. (is_float128_p): Delete. (rs6000_builtin_type_compatible): For 128-bit floating point, check if both types have the same encoding. * config/rs6000/rs6000.cc (TARGET_TRANSLATE_MODE_ATTRIBUTE): Delete. (init_float128_ieee): Delete creation of complex long double multiply and divide here and move the implemention to rs6000_init_libfuncs. (rs6000_init_libfuncs): Rework complex long double multiply and divide support here if long double uses IEEE 128-bit encoding. (rs6000_translate_mode_attribute): Delete. (rs6000_libgcc_floating_mode_supported_p): Remove code that used TFmode if long double used the IEEE 128-bit encoding. (rs6000_floatn_mode): Likewise. (rs6000_c_mode_for_suffix): Likewise. * config/rs6000/rs6000.h (RS6000_BTI_ieee128_float): Delete. (ieee128_float_type_node): Delete. * config/rs6000/rs6000.md (IFKF): Delete. (IFKF_reg): Delete. (extendkfif2): New insn. (trunckfif2): New insn. (extendtf2_internal): Delete combined extend mode, and split it into separate insns that either just handle IEEE 128-bit to IEEE 128-bit conversions or IBM 128-bit to IBM 128-bit conversions. (extendtf2_internal): Likewise. (extendkftf2_internal): New insn. (extendtfkf2_internal): New insn. (extendiftf2_internal): New insn. (extendtfif2_internal): New insn. gcc/testsuite/ * gcc.target/powerpc/divkc3-2: Update test to track compiler changes. * gcc.target/powerpc/mulkc3-2: Likewise. libgcc/ * config/rs6000/float128-ifunc.c (__multc3_ieee128): New ifunc handler. (__divtc3_ieee128): Likewise. * config/rs6000/quad-float128.h (__multc3_ieee128): Add declaration. (__divtc3_ieee128): Likewise. Diff: --- gcc/config/rs6000/rs6000-builtin.cc | 138 ++++++---------------------- gcc/config/rs6000/rs6000-c.cc | 35 +++---- gcc/config/rs6000/rs6000.cc | 95 +++++++++---------- gcc/config/rs6000/rs6000.h | 2 - gcc/config/rs6000/rs6000.md | 94 +++++++++++++++---- 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 + 9 files changed, 170 insertions(+), 209 deletions(-) diff --git a/gcc/config/rs6000/rs6000-builtin.cc b/gcc/config/rs6000/rs6000-builtin.cc index 14bfc007720..312f9cfe0a7 100644 --- a/gcc/config/rs6000/rs6000-builtin.cc +++ b/gcc/config/rs6000/rs6000-builtin.cc @@ -440,7 +440,7 @@ const char *rs6000_type_string (tree type_node) return "ss"; else if (type_node == ibm128_float_type_node) return "__ibm128"; - else if (type_node == ieee128_float_type_node) + else if (type_node == float128_type_node) return "__ieee128"; else if (type_node == opaque_V4SI_type_node) return "opaque"; @@ -713,23 +713,34 @@ rs6000_init_builtins (void) floating point, we need make sure the type is non-zero or else self-test fails during bootstrap. - Always create __ibm128 as a separate type, even if the current long double - format is IBM extended double. - - For IEEE 128-bit floating point, always create the type __ieee128. If the - user used -mfloat128, rs6000-c.cc will create a define from __float128 to - __ieee128. */ + At the moment, if the long double format is IBM 128-bit, share the type + entry between __ibm128 and long double. If the long double format is IEEE + 128-bit or 64-bit, then we need to create a new type. There ar some + implications such as C++ mangling if we always make __ibm128 a separate + type for long double. + + For IEEE 128-bit floating point, always create the type __ieee128 and use + the _Float128 type node. Do not use the long double type node, even if + long double is IEEE 128-bit. Rs6000-c.cc will create a define from + __float128 to __ieee128 unless IEEE 128-bit types are turned off. + + Originally we used the long double type node for __float128/__ieee128 if + -mabi=ieeelongdouble was used. But this breaks code that calls the + various 'Q' or 'F128' functions, such as building a signaling NaN. For + example, in doing the conversion between KFmode and TFmode, the machine + indepentent parts of the compiler converts a signalling NaN into a quiet + NaN. */ if (TARGET_IBM128) { if (!TARGET_IEEEQUAD) - ibm128_float_type_node = long_double_type_node; + ibm128_float_type_node = long_double_type_node; else - { - ibm128_float_type_node = make_node (REAL_TYPE); - TYPE_PRECISION (ibm128_float_type_node) = 128; - SET_TYPE_MODE (ibm128_float_type_node, IFmode); - layout_type (ibm128_float_type_node); - } + { + ibm128_float_type_node = make_node (REAL_TYPE); + TYPE_PRECISION (ibm128_float_type_node) = 128; + SET_TYPE_MODE (ibm128_float_type_node, IFmode); + layout_type (ibm128_float_type_node); + } t = build_qualified_type (ibm128_float_type_node, TYPE_QUAL_CONST); lang_hooks.types.register_builtin_type (ibm128_float_type_node, "__ibm128"); @@ -739,16 +750,10 @@ rs6000_init_builtins (void) if (TARGET_FLOAT128_TYPE) { - if (TARGET_IEEEQUAD && TARGET_LONG_DOUBLE_128) - ieee128_float_type_node = long_double_type_node; - else - ieee128_float_type_node = float128_type_node; - t = build_qualified_type (ieee128_float_type_node, TYPE_QUAL_CONST); - lang_hooks.types.register_builtin_type (ieee128_float_type_node, + t = build_qualified_type (float128_type_node, TYPE_QUAL_CONST); + lang_hooks.types.register_builtin_type (float128_type_node, "__ieee128"); } - else - ieee128_float_type_node = NULL_TREE; /* Vector pair and vector quad support. */ vector_pair_type_node = make_node (OPAQUE_TYPE); @@ -3302,79 +3307,6 @@ rs6000_expand_builtin (tree exp, rtx target, rtx /* subtarget */, size_t uns_fcode = (size_t)fcode; enum insn_code icode = rs6000_builtin_info[uns_fcode].icode; - /* TODO: The following commentary and code is inherited from the original - builtin processing code. The commentary is a bit confusing, with the - intent being that KFmode is always IEEE-128, IFmode is always IBM - double-double, and TFmode is the current long double. The code is - confusing in that it converts from KFmode to TFmode pattern names, - when the other direction is more intuitive. Try to address this. */ - - /* We have two different modes (KFmode, TFmode) that are the IEEE - 128-bit floating point type, depending on whether long double is the - IBM extended double (KFmode) or long double is IEEE 128-bit (TFmode). - It is simpler if we only define one variant of the built-in function, - and switch the code when defining it, rather than defining two built- - ins and using the overload table in rs6000-c.cc to switch between the - two. If we don't have the proper assembler, don't do this switch - because CODE_FOR_*kf* and CODE_FOR_*tf* will be CODE_FOR_nothing. */ - if (FLOAT128_IEEE_P (TFmode)) - switch (icode) - { - case CODE_FOR_sqrtkf2_odd: - icode = CODE_FOR_sqrttf2_odd; - break; - case CODE_FOR_trunckfdf2_odd: - icode = CODE_FOR_trunctfdf2_odd; - break; - case CODE_FOR_addkf3_odd: - icode = CODE_FOR_addtf3_odd; - break; - case CODE_FOR_subkf3_odd: - icode = CODE_FOR_subtf3_odd; - break; - case CODE_FOR_mulkf3_odd: - icode = CODE_FOR_multf3_odd; - break; - case CODE_FOR_divkf3_odd: - icode = CODE_FOR_divtf3_odd; - break; - case CODE_FOR_fmakf4_odd: - icode = CODE_FOR_fmatf4_odd; - break; - case CODE_FOR_xsxexpqp_kf: - icode = CODE_FOR_xsxexpqp_tf; - break; - case CODE_FOR_xsxsigqp_kf: - icode = CODE_FOR_xsxsigqp_tf; - break; - case CODE_FOR_xststdcnegqp_kf: - icode = CODE_FOR_xststdcnegqp_tf; - break; - case CODE_FOR_xsiexpqp_kf: - icode = CODE_FOR_xsiexpqp_tf; - break; - case CODE_FOR_xsiexpqpf_kf: - icode = CODE_FOR_xsiexpqpf_tf; - break; - case CODE_FOR_xststdcqp_kf: - icode = CODE_FOR_xststdcqp_tf; - break; - case CODE_FOR_xscmpexpqp_eq_kf: - icode = CODE_FOR_xscmpexpqp_eq_tf; - break; - case CODE_FOR_xscmpexpqp_lt_kf: - icode = CODE_FOR_xscmpexpqp_lt_tf; - break; - case CODE_FOR_xscmpexpqp_gt_kf: - icode = CODE_FOR_xscmpexpqp_gt_tf; - break; - case CODE_FOR_xscmpexpqp_unordered_kf: - icode = CODE_FOR_xscmpexpqp_unordered_tf; - break; - default: - break; - } - /* In case of "#pragma target" changes, we initialize all builtins but check for actual availability now, during expand time. For invalid builtins, generate a normal call. */ @@ -3524,22 +3456,6 @@ rs6000_expand_builtin (tree exp, rtx target, rtx /* subtarget */, gcc_unreachable (); } - if (bif_is_ibm128 (*bifaddr) && TARGET_LONG_DOUBLE_128 && !TARGET_IEEEQUAD) - { - if (fcode == RS6000_BIF_PACK_IF) - { - icode = CODE_FOR_packtf; - fcode = RS6000_BIF_PACK_TF; - uns_fcode = (size_t) fcode; - } - else if (fcode == RS6000_BIF_UNPACK_IF) - { - icode = CODE_FOR_unpacktf; - fcode = RS6000_BIF_UNPACK_TF; - uns_fcode = (size_t) fcode; - } - } - /* TRUE iff the built-in function returns void. */ bool void_func = TREE_TYPE (TREE_TYPE (fndecl)) == void_type_node; /* Position of first argument (0 for void-returning functions, else 1). */ diff --git a/gcc/config/rs6000/rs6000-c.cc b/gcc/config/rs6000/rs6000-c.cc index 4532cb4624b..efe87e16200 100644 --- a/gcc/config/rs6000/rs6000-c.cc +++ b/gcc/config/rs6000/rs6000-c.cc @@ -585,7 +585,7 @@ rs6000_target_modify_macros (bool define_p, HOST_WIDE_INT flags, rs6000_define_or_undefine_macro (true, "__float128=__ieee128"); else rs6000_define_or_undefine_macro (false, "__float128"); - if (ieee128_float_type_node && define_p) + if (define_p) rs6000_define_or_undefine_macro (true, "__SIZEOF_FLOAT128__=16"); else rs6000_define_or_undefine_macro (false, "__SIZEOF_FLOAT128__"); @@ -628,11 +628,12 @@ rs6000_cpu_cpp_builtins (cpp_reader *pfile) if (TARGET_FRSQRTES) builtin_define ("__RSQRTEF__"); if (TARGET_FLOAT128_TYPE) - builtin_define ("__FLOAT128_TYPE__"); - if (ibm128_float_type_node) + { + builtin_define ("__FLOAT128_TYPE__"); + builtin_define ("__SIZEOF_IEEE128__=16"); + } + if (TARGET_IBM128) builtin_define ("__SIZEOF_IBM128__=16"); - if (ieee128_float_type_node) - builtin_define ("__SIZEOF_IEEE128__=16"); #ifdef TARGET_LIBC_PROVIDES_HWCAP_IN_TCB builtin_define ("__BUILTIN_CPU_SUPPORTS__"); #endif @@ -805,23 +806,13 @@ rs6000_builtin_type (int id) return id < 0 ? build_pointer_type (t) : t; } -/* Check whether the type of an argument, T, is compatible with a type ID - stored into a struct altivec_builtin_types. Integer types are considered - compatible; otherwise, the language hook lang_hooks.types_compatible_p makes - the decision. Also allow long double and _Float128 to be compatible if - -mabi=ieeelongdouble. */ +/* Return true iff ARGTYPE can be compatibly passed as PARMTYPE. -static inline bool -is_float128_p (tree t) -{ - return (t == float128_type_node - || (TARGET_IEEEQUAD - && TARGET_LONG_DOUBLE_128 - && t == long_double_type_node)); -} - + We used to consider two 128-bit floating point types to be compatible if + they used the same encoding (such as _Float128 and long double if + -mabi=ieeelongdouble). Now tht we have overload support for the 128-bit + floating point types, we no longer consider these to be compatible. */ -/* Return true iff ARGTYPE can be compatibly passed as PARMTYPE. */ static bool rs6000_builtin_type_compatible (tree parmtype, tree argtype) { @@ -831,10 +822,6 @@ rs6000_builtin_type_compatible (tree parmtype, tree argtype) if (INTEGRAL_TYPE_P (parmtype) && INTEGRAL_TYPE_P (argtype)) return true; - if (TARGET_IEEEQUAD && TARGET_LONG_DOUBLE_128 - && is_float128_p (parmtype) && is_float128_p (argtype)) - return true; - if (POINTER_TYPE_P (parmtype) && POINTER_TYPE_P (argtype)) { parmtype = TREE_TYPE (parmtype); diff --git a/gcc/config/rs6000/rs6000.cc b/gcc/config/rs6000/rs6000.cc index 94f84e26f7a..cf1b1816ebd 100644 --- a/gcc/config/rs6000/rs6000.cc +++ b/gcc/config/rs6000/rs6000.cc @@ -1545,9 +1545,6 @@ static const struct attribute_spec rs6000_attribute_table[] = #undef TARGET_EH_RETURN_FILTER_MODE #define TARGET_EH_RETURN_FILTER_MODE rs6000_eh_return_filter_mode -#undef TARGET_TRANSLATE_MODE_ATTRIBUTE -#define TARGET_TRANSLATE_MODE_ATTRIBUTE rs6000_translate_mode_attribute - #undef TARGET_SCALAR_MODE_SUPPORTED_P #define TARGET_SCALAR_MODE_SUPPORTED_P rs6000_scalar_mode_supported_p @@ -11064,32 +11061,6 @@ 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"); @@ -11195,6 +11166,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. @@ -23791,18 +23802,6 @@ rs6000_eh_return_filter_mode (void) return TARGET_32BIT ? SImode : word_mode; } -/* Target hook for translate_mode_attribute. */ -static machine_mode -rs6000_translate_mode_attribute (machine_mode mode) -{ - if ((FLOAT128_IEEE_P (mode) - && ieee128_float_type_node == long_double_type_node) - || (FLOAT128_IBM_P (mode) - && ibm128_float_type_node == long_double_type_node)) - return COMPLEX_MODE_P (mode) ? E_TCmode : E_TFmode; - return mode; -} - /* Target hook for scalar_mode_supported_p. */ static bool rs6000_scalar_mode_supported_p (scalar_mode mode) @@ -23837,13 +23836,9 @@ rs6000_libgcc_floating_mode_supported_p (scalar_float_mode mode) case E_TFmode: return true; - /* We only return true for KFmode if IEEE 128-bit types are supported, and - if long double does not use the IEEE 128-bit format. If long double - uses the IEEE 128-bit format, it will use TFmode and not KFmode. - Because the code will not use KFmode in that case, there will be aborts - because it can't find KFmode in the Floatn types. */ + /* We only return true for KFmode if IEEE 128-bit types are supported. */ case E_KFmode: - return TARGET_FLOAT128_TYPE && !TARGET_IEEEQUAD; + return TARGET_FLOAT128_TYPE; default: return false; @@ -23877,7 +23872,7 @@ rs6000_floatn_mode (int n, bool extended) case 64: if (TARGET_FLOAT128_TYPE) - return (FLOAT128_IEEE_P (TFmode)) ? TFmode : KFmode; + return KFmode; else return opt_scalar_float_mode (); @@ -23901,7 +23896,7 @@ rs6000_floatn_mode (int n, bool extended) case 128: if (TARGET_FLOAT128_TYPE) - return (FLOAT128_IEEE_P (TFmode)) ? TFmode : KFmode; + return KFmode; else return opt_scalar_float_mode (); @@ -23919,7 +23914,7 @@ rs6000_c_mode_for_suffix (char suffix) if (TARGET_FLOAT128_TYPE) { if (suffix == 'q' || suffix == 'Q') - return (FLOAT128_IEEE_P (TFmode)) ? TFmode : KFmode; + return KFmode; /* At the moment, we are not defining a suffix for IBM extended double. If/when the default for -mabi=ieeelongdouble is changed, and we want diff --git a/gcc/config/rs6000/rs6000.h b/gcc/config/rs6000/rs6000.h index 7bbd9ab5238..c16b35fd9b1 100644 --- a/gcc/config/rs6000/rs6000.h +++ b/gcc/config/rs6000/rs6000.h @@ -2265,7 +2265,6 @@ enum rs6000_builtin_type_index RS6000_BTI_dfloat64, /* dfloat64_type_node */ RS6000_BTI_dfloat128, /* dfloat128_type_node */ RS6000_BTI_void, /* void_type_node */ - RS6000_BTI_ieee128_float, /* ieee 128-bit floating point */ RS6000_BTI_ibm128_float, /* IBM 128-bit floating point */ RS6000_BTI_const_str, /* pointer to const char * */ RS6000_BTI_vector_pair, /* unsigned 256-bit types (vector pair). */ @@ -2360,7 +2359,6 @@ enum rs6000_builtin_type_index #define dfloat64_type_internal_node (rs6000_builtin_types[RS6000_BTI_dfloat64]) #define dfloat128_type_internal_node (rs6000_builtin_types[RS6000_BTI_dfloat128]) #define void_type_internal_node (rs6000_builtin_types[RS6000_BTI_void]) -#define ieee128_float_type_node (rs6000_builtin_types[RS6000_BTI_ieee128_float]) #define ibm128_float_type_node (rs6000_builtin_types[RS6000_BTI_ibm128_float]) #define const_str_type_node (rs6000_builtin_types[RS6000_BTI_const_str]) #define vector_pair_type_node (rs6000_builtin_types[RS6000_BTI_vector_pair]) diff --git a/gcc/config/rs6000/rs6000.md b/gcc/config/rs6000/rs6000.md index f942597c3b4..e17252bb8de 100644 --- a/gcc/config/rs6000/rs6000.md +++ b/gcc/config/rs6000/rs6000.md @@ -543,12 +543,6 @@ ; Iterator for 128-bit VSX types for pack/unpack (define_mode_iterator FMOVE128_VSX [V1TI KF]) -; Iterators for converting to/from TFmode -(define_mode_iterator IFKF [IF KF]) - -; Constraints for moving IF/KFmode. -(define_mode_attr IFKF_reg [(IF "d") (KF "wa")]) - ; Whether a floating point move is ok, don't allow SD without hardware FP (define_mode_attr fmove_ok [(SF "") (DF "") @@ -9075,6 +9069,15 @@ DONE; }) +(define_expand "extendkfif2" + [(set (match_operand:IF 0 "gpc_reg_operand") + (float_extend:IF (match_operand:KF 1 "gpc_reg_operand")))] + "TARGET_FLOAT128_TYPE" +{ + rs6000_expand_float128_convert (operands[0], operands[1], false); + DONE; +}) + (define_expand "extendtfkf2" [(set (match_operand:KF 0 "gpc_reg_operand") (float_extend:KF (match_operand:TF 1 "gpc_reg_operand")))] @@ -9111,6 +9114,15 @@ DONE; }) +(define_expand "trunckfif2" + [(set (match_operand:IF 0 "gpc_reg_operand") + (float_truncate:IF (match_operand:KF 1 "gpc_reg_operand")))] + "TARGET_FLOAT128_TYPE" +{ + rs6000_expand_float128_convert (operands[0], operands[1], false); + DONE; +}) + (define_expand "trunckftf2" [(set (match_operand:TF 0 "gpc_reg_operand") (float_truncate:TF (match_operand:KF 1 "gpc_reg_operand")))] @@ -9129,31 +9141,73 @@ DONE; }) -(define_insn_and_split "*extendtf2_internal" - [(set (match_operand:TF 0 "gpc_reg_operand" "=") +;; Convert between KFmode and TFmode when -mabi=ieeelongdouble +(define_insn_and_split "*extendkftf2_internal" + [(set (match_operand:TF 0 "gpc_reg_operand" "=wa,wa") (float_extend:TF - (match_operand:IFKF 1 "gpc_reg_operand" "")))] - "TARGET_FLOAT128_TYPE - && FLOAT128_IBM_P (TFmode) == FLOAT128_IBM_P (mode)" + (match_operand:KF 1 "gpc_reg_operand" "0,wa")))] + "FLOAT128_IEEE_P (TFmode)" "#" "&& reload_completed" [(set (match_dup 0) (match_dup 2))] { operands[2] = gen_rtx_REG (TFmode, REGNO (operands[1])); -}) +} + [(set_attr "type" "vecsimple")]) -(define_insn_and_split "*extendtf2_internal" - [(set (match_operand:IFKF 0 "gpc_reg_operand" "=") - (float_extend:IFKF - (match_operand:TF 1 "gpc_reg_operand" "")))] - "TARGET_FLOAT128_TYPE - && FLOAT128_IBM_P (TFmode) == FLOAT128_IBM_P (mode)" +(define_insn_and_split "*extendtfkf2_internal" + [(set (match_operand:KF 0 "gpc_reg_operand" "=wa,wa") + (float_extend:KF + (match_operand:TF 1 "gpc_reg_operand" "0,wa")))] + "FLOAT128_IEEE_P (TFmode)" "#" "&& reload_completed" [(set (match_dup 0) (match_dup 2))] { - operands[2] = gen_rtx_REG (mode, REGNO (operands[1])); -}) + operands[2] = gen_rtx_REG (KFmode, REGNO (operands[1])); +} + [(set_attr "type" "vecsimple")]) + +;; Convert between IFmode and TFmode when -mabi=ibmlongdouble +(define_insn_and_split "*extendiftf2_internal" + [(set (match_operand:TF 0 "gpc_reg_operand" "=d,&d") + (float_extend:TF + (match_operand:IF 1 "input_operand" "0,d")))] + "FLOAT128_IBM_P (TFmode)" + "#" + "&& reload_completed" + [(set (match_dup 2) (match_dup 3)) + (set (match_dup 4) (match_dup 5))] +{ + unsigned int op0_regno = reg_or_subregno (operands[0]); + unsigned int op1_regno = reg_or_subregno (operands[1]); + operands[2] = gen_rtx_REG (DFmode, op0_regno); + operands[3] = gen_rtx_REG (DFmode, op1_regno); + operands[4] = gen_rtx_REG (DFmode, op0_regno + 1); + operands[5] = gen_rtx_REG (DFmode, op1_regno + 1); +} + [(set_attr "type" "two") + (set_attr "num_insns" "2")]) + +(define_insn_and_split "*extendtfif2_internal" + [(set (match_operand:IF 0 "gpc_reg_operand" "=d,&d") + (float_extend:IF + (match_operand:TF 1 "input_operand" "0,d")))] + "FLOAT128_IBM_P (TFmode)" + "#" + "&& reload_completed" + [(set (match_dup 2) (match_dup 3)) + (set (match_dup 4) (match_dup 5))] +{ + unsigned int op0_regno = reg_or_subregno (operands[0]); + unsigned int op1_regno = reg_or_subregno (operands[1]); + operands[2] = gen_rtx_REG (DFmode, op0_regno); + operands[3] = gen_rtx_REG (DFmode, op1_regno); + operands[4] = gen_rtx_REG (DFmode, op0_regno + 1); + operands[5] = gen_rtx_REG (DFmode, op1_regno + 1); +} + [(set_attr "type" "two") + (set_attr "num_insns" "2")]) ;; Reload helper functions used by rs6000_secondary_reload. The patterns all 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. */