On Fri, Aug 05, 2022 at 01:19:05PM -0500, Segher Boessenkool wrote: > On Thu, Jul 28, 2022 at 12:43:49AM -0400, Michael Meissner wrote: > > These patches lay the foundation for a set of follow-on patches that will > > change the internal handling of 128-bit floating point types in GCC. In the > > future patches, I hope to change the compiler to always use KFmode for the > > explicit _Float128/__float128 types, to always use TFmode for the long > > double > > type, no matter which 128-bit floating point type is used, and IFmode for > > the > > explicit __ibm128 type. > > Making TFmode different from KFmode and IFmode is not an improvement. > NAK. > > > Segher
First of all, it already IS different from KFmode and IFmode, as we've talked about. I'm trying to clean this mess up. Having explicit __float128's being converted to TFmode if -mabi=ieeelongdouble is just as bad, and it means that _Float128 and __float128 are not the same type. What I'm trying to eliminate is the code in rs6000-builtin.cc that overrides the builtin ops (i.e. it does the equivalent of an overloaded function): /* 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; } // ... other code 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; } } In particular, without overloaded built-ins, we likely have something similar to the above to cover all of the built-ins for both modes. I tend to think overloading is more natural in this case. -- Michael Meissner, IBM PO Box 98, Ayer, Massachusetts, USA, 01432 email: meiss...@linux.ibm.com