diff options
author | zack <zack@138bc75d-0d04-0410-961f-82ee72b054a4> | 2003-03-21 17:10:02 +0000 |
---|---|---|
committer | zack <zack@138bc75d-0d04-0410-961f-82ee72b054a4> | 2003-03-21 17:10:02 +0000 |
commit | 778ba491062e7454fdec2fe4e7667f3500b10c44 (patch) | |
tree | f92bcd0dd5b17043f1634195bcbf18c4df1df8da /gcc/java/javaop.h | |
parent | 7f6007b45f71f43498b27d8fa69bc151fe9976f5 (diff) | |
download | gcc-778ba491062e7454fdec2fe4e7667f3500b10c44.tar.gz |
* javaop.h (jfloat, jdouble): Make them structures mirroring
the bit fields of IEEE float and double respectively.
(JFLOAT_FINITE, JFLOAT_QNAN_MASK, JFLOAT_EXP_BIAS,
JDOUBLE_FINITE, JDOUBLE_QNAN_MASK, JDOUBLE_EXP_BIAS): New.
(union Word, union DWord): Delete.
(WORD_TO_FLOAT, WORDS_TO_DOUBLE): Update to match.
* gjavah.c (java_float_finite, java_double_finite, F_NAN_MASK,
D_NAN_MASK): Delete.
(jni_print_float, jni_print_double): New. Generate
hexadecimal floating constants.
(print_field_info): Use jni_print_float/double.
* jcf-dump.c: Include math.h. Use ldexp/frexp to assemble
finite floating point numbers for output; special case
non-finite floats.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@64671 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/java/javaop.h')
-rw-r--r-- | gcc/java/javaop.h | 68 |
1 files changed, 37 insertions, 31 deletions
diff --git a/gcc/java/javaop.h b/gcc/java/javaop.h index da09254ad10..bdf3fa6e41f 100644 --- a/gcc/java/javaop.h +++ b/gcc/java/javaop.h @@ -55,21 +55,26 @@ typedef int32 jint; typedef int64 jlong; typedef void* jref; -/* A 32-bit IEEE single-precision float. */ -#ifndef jfloat -#define jfloat float -#endif - -/* A 32-bit IEEE double-precision float. */ -#ifndef jdouble -#define jdouble double -#endif - -union Word { - jint i; - jfloat f; - void *p; -}; +/* A 32-bit big-endian IEEE single-precision float. */ +typedef struct _jfloat { + unsigned int negative : 1; + unsigned int exponent : 8; + unsigned int mantissa : 23; +} jfloat; +#define JFLOAT_FINITE(f) ((f).exponent != 0xFF) +#define JFLOAT_QNAN_MASK 0x400000 +#define JFLOAT_EXP_BIAS 0x7f + +/* A 32-bit big-endian IEEE double-precision float. */ +typedef struct _jdouble { + unsigned int negative : 1; + unsigned int exponent : 11; + unsigned int mantissa0: 20; + unsigned int mantissa1: 32; +} jdouble; +#define JDOUBLE_FINITE(f) ((f).exponent != 0x7FF) +#define JDOUBLE_QNAN_MASK 0x80000 /* apply to mantissa0 */ +#define JDOUBLE_EXP_BIAS 0x3ff /* A jword is an unsigned integral type big enough for a 32-bit jint or jfloat *or* a pointer. It is the type appropriate for stack @@ -102,9 +107,14 @@ union Word { static inline jfloat WORD_TO_FLOAT(jword w) -{ union Word wu; - wu.i = w; - return wu.f; +{ + jfloat f; + + f.negative = (w & 0x80000000) >> 31; + f.exponent = (w & 0x7f800000) >> 23; + f.mantissa = (w & 0x007fffff); + + return f; } /* Sign extend w. If the host on which this cross-compiler runs uses @@ -126,21 +136,17 @@ WORDS_TO_LONG(jword hi, jword lo) return ((jlong) hi << 32) | ((jlong)lo & (((jlong)1 << 32) -1)); } -union DWord { - jdouble d; - jlong l; - jword w[2]; -}; - static inline jdouble WORDS_TO_DOUBLE(jword hi, jword lo) -{ union DWord wu; -#if (1 == HOST_FLOAT_WORDS_BIG_ENDIAN) - wu.l = WORDS_TO_LONG(lo, hi); -#else - wu.l = WORDS_TO_LONG(hi, lo); -#endif - return wu.d; +{ + jdouble d; + + d.negative = (hi & 0x80000000) >> 31; + d.exponent = (hi & 0x7ff00000) >> 20; + d.mantissa0 = (hi & 0x000fffff); + d.mantissa1 = lo; + + return d; } /* If PREFIX_CHAR is the first character of the Utf8 encoding of a character, |