On Wed, Oct 06, 2021 at 10:03:59PM +0000, Joseph Myers wrote: > On Wed, 6 Oct 2021, Segher Boessenkool wrote: > > With "not in any" I mean: not for other architectures either! All archs > > that do not say anything about floating point in their machine > > description get a working sofware floating point (for binary32 and > > binary64 currently). > > Any architecture that supports a software floating-point ABI (i.e. one > that does argument passing and return for floating-point in integer > registers) should specify it in its ABI documents. For example, > https://github.com/riscv-non-isa/riscv-elf-psabi-doc/blob/master/riscv-cc.adoc > > describes both "Integer Calling Convention" and "Hardware Floating-point > Calling Convention", with a series of named ABIs based on those such as > LP64, LP64F, etc. (like on (32-bit) Arm, but unlike Power or MIPS, RISC-V > GCC also supports building programs that use hardware floating-point > instructions but the software floating-point ABI).
But many CPUs do not have hardware floating point in any variant, and their ABIs / calling conventions do not mention floating point at all. Still, this works with GCC just fine: it passes floats and doubles the same as 32-bit resp. 64-bit integers. binary16 and bfloat16 would be easy to support the same way, but it is a bit harder for binary128, because we do not have a 128-bit integer type on all systems. That should be fixed first probably. It doesn't have to be very good machine code, but having it supported everywhere would simplify things a lot. > That's how the (unified) 32-bit powerpc ABI documents things: both > hardware and software floating-point ABI variants. Yes. I am not saying this isn't good or desirable, but simply how things are now. > If the architecture doesn't support hardware floating point, or doesn't > have separate registers for it, the software floating-point ABI is just > "the ABI" and there's no separate hardware floating-point ABI, of course. Right, and many architectures neglect to even mention anything to do with floating point, although this is and always was a standard C feature :-/ Segher