Floating point support

bryce at kampjes.demon.co.uk bryce at kampjes.demon.co.uk
Sun Mar 16 21:37:00 UTC 2008


Igor Stasenko writes:
 > Hello Bryce,
 > 
 > i'd like to ask you, how do you envision adding floating point support
 > to Exupery
 > to make it able to use FPU.
 > 
 > The problem i see, is that it would require adding a type to registers
 > to be able to use float-type values in intermediate code
 > representation.
 > 
 > Or else, how it would look like, when i need to encode floating point
 > operations like:
 > 
 > temp1 := floatValue1.
 > temp2 := floatValue2.
 > temp3 := temp1 + temp2. "here compiler should generate FPU
 > instructions instead of integer addition"
 > 
 > Or maybe i'm looking at problem at wrong angle?
 > Maybe easier to make intermediate in format like:
 > 
 > unaryFloatOp(argmunentAddress, resultAddress)
 > binaryFloatOp(argmunent1Address, argument2Address, resultAddress)
 > compareFloatsOp(arg1address, arg2address)
 > 
 > then compiler don't have to deal with float registers (in register
 > spilling code and other optimization patterns).

I'll probably create floating point operations and have floating point
registers. The operations will be to make instruction selection easy,
the registers to play nicely with the register allocator. Floating
point registers are a separate register bank independent from the
integer registers.

I'm planning on supporting SSE2 first. It should be widely enough
deployed, and it's easier to deal with than the legacy x87 stack based
floating point instruction set. SSE2 is also the default in 64 bit
mode as the number of SSE2 registers was doubled from 8 to 16 but the
x87 register set left unchanged.

 > Another thing, is support of byte-wide operations, like
 > loading/storing byte at specific address. And of course being able to
 > do some operations with byte-sized values.
 > How do you plan to support this?

With an 8 bit mem operation. Make operations that make it easy to load
and store a 8 bit quantity. Operate on it in 32 bit registers.

 > The reason, why i'm asking about this, is that i'm currently busy with
 > this: http://wiki.squeak.org/squeak/6041
 > 
 > As you maybe remember i had plans to do such system before. And now i
 > spent some time to push it to the point, where it can become a reality
 > :)

I remember.

Bryce


More information about the Exupery mailing list