diff options
author | rth <rth@138bc75d-0d04-0410-961f-82ee72b054a4> | 2002-09-20 17:50:48 +0000 |
---|---|---|
committer | rth <rth@138bc75d-0d04-0410-961f-82ee72b054a4> | 2002-09-20 17:50:48 +0000 |
commit | 3393215f16466fcf4b25c247e195c5b96761a93a (patch) | |
tree | 89d914be5aa639096dbd44d7f9d3e884503d85a0 /gcc/real.c | |
parent | cfea3820a45c72304bfb7887b39f032f065045c2 (diff) | |
download | gcc-3393215f16466fcf4b25c247e195c5b96761a93a.tar.gz |
* real.c (real_hash): New.
* real.h: Declare it.
* cse.c (canon_hash): Use it.
* cselib.c (hash_rtx): Likewise.
* emit-rtl.c (const_double_htab_hash): Likewise.
* rtl.h (CONST_DOUBLE_REAL_VALUE): New.
* varasm.c (struct rtx_const): Reduce vector size; separate
integer and fp vectors.
(HASHBITS): Remove.
(const_hash_1): Rename from const_hash. Use real_hash. Do not
take modulus MAX_HASH_TABLE.
(const_hash): New. Do take modulus MAX_HASH_TABLE.
(output_constant_def): Do not take modulus MAX_HASH_TABLE.
(SYMHASH): Don't use HASHBITS.
(decode_rtx_const): Copy only active bits from REAL_VALUE_TYPE.
Fix CONST_VECTOR thinko wrt fp vectors. Fix kind comparison.
(simplify_subtraction): Fix kind comparison.
(const_hash_rtx): Return unsigned int. Don't use HASHBITS.
Use a union to pun integer array.
* config/rs6000/rs6000.c (rs6000_hash_constant): Use real_hash;
only hash two words of integral CONST_DOUBLE.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@57356 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/real.c')
-rw-r--r-- | gcc/real.c | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/gcc/real.c b/gcc/real.c index 2c28135c171..d746ab61223 100644 --- a/gcc/real.c +++ b/gcc/real.c @@ -2311,6 +2311,47 @@ significand_size (mode) return fmt->p * fmt->log2_b; } + +/* Return a hash value for the given real value. */ +/* ??? The "unsigned int" return value is intended to be hashval_t, + but I didn't want to pull hashtab.h into real.h. */ + +unsigned int +real_hash (r) + const REAL_VALUE_TYPE *r; +{ + unsigned int h; + size_t i; + + h = r->class | (r->sign << 2); + switch (r->class) + { + case rvc_zero: + case rvc_inf: + break; + + case rvc_normal: + h |= r->exp << 3; + /* FALLTHRU */ + + case rvc_nan: + if (sizeof(unsigned long) > sizeof(unsigned int)) + for (i = 0; i < SIGSZ; ++i) + { + unsigned long s = r->sig[i]; + h ^= s ^ (s >> (HOST_BITS_PER_LONG / 2)); + } + else + for (i = 0; i < SIGSZ; ++i) + h ^= r->sig[i]; + break; + + default: + abort (); + } + + return h; +} /* IEEE single-precision format. */ |