Port-vax archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: pbulk bootstrap: `awk` running into FP overflow during bison build (Grater picture: How to bootstrap pkgsrc / pbulk?)



Den 2023-08-07 kl. 14:43, skrev Maciej W. Rozycki:
On Mon, 7 Aug 2023, Anders Magnusson wrote:

   Though, hmm, it has struck me that the program might expect the IEEE 754
exponent range of the double FP type, which raises a question: which of
D_floating and G_floating format has our port chosen?  If it's G_floating,
then I'd expect the very narrow difference from IEEE 754 double highly
unlikely to hit, however with D_floating where the width of the exponent
is the same as with F_floating, i.e. the single FP type, it's actually
very likely.
The vax port uses FD floats.
  I have thought so, but wanted to double-check.

   Overall I think we ought to support both, but it might be a bit tricky on
the toolchain side, as it's an ABI issue to sort out.  Did any machine
actually implement H_floating in hardware, or was it only ever emulated?
The 780 had H-float in hardware.  Actually, it had all instructions in
hardware (microcode).
  Do we actually support or intend to support that model?  If not, then I
would yet need to verify if that's actually legal by the ISO C language
standard (which I reckon has certain requirements as to the ranges of the
real data types defined), but I think it would be a reasonable idea to map
F_floating, D_floating and G_floating quantities respectively to the
`float', `double' and `long double' data types.
Not that I have checked in the standard, but having a data type that narrows the mantissa when converted to a larger type sounds not especially good :-)
  This might not immediately help the case at hand, but would lay grounds
for the ABI (think C++ symbol name mangling), and then with a clever
arrangement we might be able to make most things designed with IEEE 754 in
mind work as expected.  I.e. we could have a compilation flag that makes
the `double' and `long double' data types both map to G_floating, but
encoded as `long double' at the ABI level, so that interlinking with code
that uses the D_floating data type works.  I think it can be made seamless
as hardware supports the four FP data types all at once without the need
to switch modes or suchlike.
Note that this would require to rewrite a bunch of the libm stuff.
Vax uses the old tailored libm which is not the same as the ieee libm.

I would rather fix code that use its own builtin constants instead of the size constants provided by the header files.

Besides that, I looked at doing things in a different way a few years ago; namely to use the native floating point formats as IEEE formats and just add an extra instruction that for each math operation compensate for the different bias :-) 99% of all floating point calculations would not know the difference, and when getting in the outskirts of what vax can handle letting the over/underflow traps deal with it (and do it in software).

Haven't thought much about it but I think it could be doable.

-- R



Home | Main Index | Thread Index | Old Index