public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc(refs/users/meissner/heads/work096)] Use _Float128 type for __float128.
@ 2022-08-02 21:32 Michael Meissner
0 siblings, 0 replies; only message in thread
From: Michael Meissner @ 2022-08-02 21:32 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:09c4ceba5be8f811ee4680c0401f5f0b43d0e428
commit 09c4ceba5be8f811ee4680c0401f5f0b43d0e428
Author: Michael Meissner <meissner@linux.ibm.com>
Date: Tue Aug 2 17:32:18 2022 -0400
Use _Float128 type for __float128.
In the past if the long double type was IEEE 128-bit, the __float128 type would
use the long double type, and TFmode would be used for the mode for both
_Float128 and long double types.
This patch always uses the _Float128 type for __float128, and it always uses
KFmode for the mode. Right now, a similar change for __ibm128 has not been
made.
In making these changes, I noticed that there was an internal tree for holding
the __float128 type. This code removes that internal tree variable.
2022-08-02 Michael Meissner <meissner@linux.ibm.com>
gcc/
* config/rs6000/rs6000-builtin.cc (rs6000_type_string): Use
float128_type_node, not ieee128_float_type_mode.
(rs6000_init_builtins): Always use the _Float128 type for the __float128
keyword.
(rs6000_expand_builtin): Remove code that mapped the KFmode built-in
functions to TFmode functions if long double was IEEE 128-bit, and use
built-in function overloading instead. Also remove the conversion of
IBM 128-bit built-in functions from IFmode to TFmode if long double is
IBM 128-bit.
* config/rs6000/rs6000-c.cc (rs6000_target_modify_macros): Use
float128_type_node, not ieee128_float_type_mode.
(rs6000_cpu_cpp_builtins): Delete ieee128_float_type_mode.
(is_float128_p): Delete.
(rs6000_builtin_type_compatible): Don't consider 128-bit floating point
types to be compatible if they use the same encoding. Use built-in
function overloading instead.
(rs6000_libgcc_floating_mode_supported_p): Use KFmode for _Float128 and
__float128, not TFmode.
(rs6000_floatn_mode): Likewise.
(rs6000_c_mode_for_suffix): Likewise.
* config/rs6000/rs6000.h (RS6000_BTI_ieee128_float): Delete.
(ieee128_float_type_node): Likewise.
* config/rs6000/rs6000.md (IFKF): Delete.
(IFKF_reg): Delete.
(extendkfif2): New define_expand.
(trunckfif2): New define_expand.
(extend<mode>tf2_internal): Split into extendiftf2_internal and
extendkftf2_internal. Update the insns to use the correct insn type and
length attributes based on whether KFmode or IFmode is used.
(extendiftf2_internal): Likewise.
(extendkftf2_internal): Likewise.
(extendtf<mode>2_internal): Split into extendtfif2_internal and
extendtfkf2_internal. Update the insns to use the correct insn type and
length attributes based on whether KFmode or IFmode is used.
(extendtfif2_internal): Likewise.
(extendtfkf2_internal): Likewise.
Diff:
---
gcc/config/rs6000/rs6000-builtin.cc | 107 ++----------------------------------
gcc/config/rs6000/rs6000-c.cc | 35 ++++--------
gcc/config/rs6000/rs6000.cc | 28 +++++-----
gcc/config/rs6000/rs6000.h | 2 -
gcc/config/rs6000/rs6000.md | 94 ++++++++++++++++++++++++-------
5 files changed, 103 insertions(+), 163 deletions(-)
diff --git a/gcc/config/rs6000/rs6000-builtin.cc b/gcc/config/rs6000/rs6000-builtin.cc
index 14bfc007720..f796110c14d 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,12 +713,10 @@ 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. */
+ __ieee128. Use the standard _Float128 type even if long double uses IEEE
+ 128-bit. */
if (TARGET_IBM128)
{
if (!TARGET_IEEEQUAD)
@@ -739,16 +737,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 +3294,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 +3443,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 c128845506c..437b39f23af 100644
--- a/gcc/config/rs6000/rs6000-c.cc
+++ b/gcc/config/rs6000/rs6000-c.cc
@@ -581,7 +581,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__");
@@ -621,11 +621,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
@@ -806,23 +807,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)
{
@@ -832,10 +823,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 eddf8c8afe7..6dfdfebd7a6 100644
--- a/gcc/config/rs6000/rs6000.cc
+++ b/gcc/config/rs6000/rs6000.cc
@@ -23678,15 +23678,17 @@ rs6000_eh_return_filter_mode (void)
return TARGET_32BIT ? SImode : word_mode;
}
-/* Target hook for translate_mode_attribute. */
+/* Target hook for translate_mode_attribute. The __float128 and _Float128
+ types always have a separate type and mode from the long double types.
+
+ Currently __ibm128 shares the type and mode with long double if long double
+ uses the IBM 128-bit encoding. */
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;
+ if (FLOAT128_IEEE_P (mode))
+ return COMPLEX_MODE_P (mode) ? E_KCmode : E_KFmode;
+
return mode;
}
@@ -23724,13 +23726,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;
@@ -23764,7 +23762,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 ();
@@ -23788,7 +23786,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 ();
@@ -23806,7 +23804,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 f58f5f3f355..4a1f6875747 100644
--- a/gcc/config/rs6000/rs6000.h
+++ b/gcc/config/rs6000/rs6000.h
@@ -2268,7 +2268,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). */
@@ -2363,7 +2362,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 "*extend<mode>tf2_internal"
- [(set (match_operand:TF 0 "gpc_reg_operand" "=<IFKF_reg>")
+;; 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" "<IFKF_reg>")))]
- "TARGET_FLOAT128_TYPE
- && FLOAT128_IBM_P (TFmode) == FLOAT128_IBM_P (<MODE>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 "*extendtf<mode>2_internal"
- [(set (match_operand:IFKF 0 "gpc_reg_operand" "=<IFKF_reg>")
- (float_extend:IFKF
- (match_operand:TF 1 "gpc_reg_operand" "<IFKF_reg>")))]
- "TARGET_FLOAT128_TYPE
- && FLOAT128_IBM_P (TFmode) == FLOAT128_IBM_P (<MODE>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>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")])
\f
;; Reload helper functions used by rs6000_secondary_reload. The patterns all
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-08-02 21:32 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-02 21:32 [gcc(refs/users/meissner/heads/work096)] Use _Float128 type for __float128 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).