[Ecls-list] Immediate short-float for ECL
Juan Jose Garcia-Ripoll
juanjose.garciaripoll at googlemail.com
Tue Oct 3 08:30:00 UTC 2006
2006/9/30, Lars Brinkhoff <lars at nocrew.org>:
> [Resend. Note: this is just for review and discussion. I will keep
> working to remove test failures, etc. There are also some stray fixes
> unrelated to floats in this patch.]
>
> Here's a preview of my patch which adds an immediate short-float type,
> temporarily called SI::IMMEDIATE-SHORT-FLOAT, to ECL. It's not 100%
> complete yet, and there are test regressions, but I believe most
> things work.
I had a look at your code. You are clearing some bits in the floating
point number to replace them with the type tag. That does not seem
very safe in 32-bit computers. Isn't the last bits where the exponent
is stored?
I think that your code is much better suited for 64-bit environments,
where one has plenty of bits to spare, but this code wouldn't make use
of those extra bits:
+ ({ \
+ union { float flo; cl_fixnum fix; } _tmp__val_; \
+ _tmp__val_.flo = (n); \
+ _tmp__val_.fix &= ~IMMEDIATE_TAG; \
+ _tmp__val_.fix |= IMM_SHORTFLOAT_TAG; \
+ (cl_object)_tmp__val_.fix; \
Perhaps something like
struct { int32_t fix; float flo } _tmp__val_;
would be better there.
I would also replace the name immediate-floats with short-float and
single-float (t_imm_shortfloat -> t_shortfloat). In 32-bit
environments, when configured with --enable-short-floats they would be
different and have different tags. In 64-bits there would not be
short-floats, all single-floats would be immediate and the tags would
be the same (t_shortfloat == t_singlefloat), so that the compiler
collapses the code for short-floats and single-floats.
What do you think?
Regards,
Juanjo
--
Max-Planck-Institut für Quantenoptik
Hans-Kopfermann-Str. 1, Garching, D-85748, Germany
Phone: +49 89 32905 345 Fax: +49 89 32905 336
http://www.mpq.mpg.de/Theorygroup/CIRAC/
More information about the ecl-devel
mailing list