On Wed, Mar 19, 2025 at 06:03:16PM -0400, James K. Lowden wrote:
> I'm not convinced this effort is either good or necessary. I'm a 
> afraid of ending up with code no one including me understands, for the
> sake of portability to architectures no one will ever use.  I think
> you're assuming I understand things I don't, and possibly assuming
> something to be necessary that isn't, in this context.  

I think Richard already posted some reasons.
Add to that that if the compiler uses host math library for floating
point computations during compilation, then code generation is dependent
on the ulp errors of the exact implementation.  So you might get
different compiled code from the same source on say Linux x86_64 host with 
glibc,
another on Linux x86_64 host with musl, another on Linux aarch64 host
with glibc, ...  If it was e.g. float rather than _Float128, it would also
depend on excess precision (ia32 would evaluate those as long double
sometimes and as float at other times, s390x would evaluate those as double
sometimes and float at other times, ...).  Also, _Float128 is implemented
differently on different hosts, sometimes in hardware (e.g. s390x,
powerpc64le), often in software emulation, while the basic arithmetics
ideally should have ultimate precision, bugs could affect that.
And more importantly, _Float128 and __int128 are only available on small
subsets of hosts.  Many of the __int128 uses in the COBOL FE are just
wrong because they lose the upper 64 bits when turning it into a tree,
so just using wide_int there designed for arbitrary precision arithmetics
at compile time fixes that.

> On the 3rd hand, it's very nice while debugging the parser to see
> these numbers as numbers, not as some abstract tree type.  

When you have a tree REAL_CST instead of _Float128, you can just
pt var_or_expression
in the debugger (which calls debug_tree on var_or_expression),
or
pgs var_or_expression
(which calls debug_generic_stmt on it).
Or generally, for many types like REAL_VALUE_TYPE, there is just
overloaded debug function, so you can
call debug (var)
and it will DTRT.

        Jakub

Reply via email to