From 9c6ab3380367e013def4fb2a41da0eac4798ba08 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Wed, 21 Jun 2000 23:11:54 +0000 Subject: [PATCH] Distinguish between cl_word_size and the ABI's pointer size. --- ChangeLog | 9 +++++++++ include/cl_object.h | 14 +++++++------- include/cl_types.h | 11 ++++++++++- src/float/sfloat/cl_SF.h | 4 ++-- src/integer/cl_I.h | 12 ++++++------ src/integer/elem/cl_I_compare.cc | 2 +- src/integer/elem/cl_I_equal.cc | 2 +- src/integer/elem/cl_I_minus1.cc | 2 +- src/integer/elem/cl_I_plus1.cc | 2 +- 9 files changed, 38 insertions(+), 20 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0aeb758..3f72f40 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2000-06-22 Bruno Haible + + * include/cl_object.h: Rename cl_word_size to cl_pointer_size. + * include/cl_types.h (HAVE_FAST_LONGLONG): Also define on Irix6 + with N32 ABI. + (cl_word_size): New macro. + * src/float/sfloat/cl_SF.h: Use cl_pointer_size instead of + cl_word_size. + 2000-06-05 Richard Kreckel * doc/*, INSTALL: Mention that both shared and static library are diff --git a/include/cl_object.h b/include/cl_object.h index 328c36c..605ea26 100644 --- a/include/cl_object.h +++ b/include/cl_object.h @@ -62,9 +62,9 @@ // Immediate data is a word, as wide as a pointer. typedef sintP cl_sint; typedef uintP cl_uint; // This ought to be called `cl_word'. -#define cl_word_size intPsize -// NB: (cl_word_size==64) implies defined(HAVE_FAST_LONGLONG) -#if (cl_word_size==64) +#define cl_pointer_size intPsize +// NB: (cl_pointer_size==64) implies defined(HAVE_FAST_LONGLONG) +#if (cl_pointer_size==64) #define CL_WIDE_POINTERS #endif @@ -90,12 +90,12 @@ inline cl_boolean cl_immediate_p (cl_uint word) #define cl_tag_len 3 #endif #define cl_tag_shift 0 -#if (cl_word_size == 64) +#if (cl_pointer_size == 64) #define cl_value_shift 32 #else #define cl_value_shift (cl_tag_len+cl_tag_shift) #endif -#define cl_value_len (cl_word_size - cl_value_shift) +#define cl_value_len (cl_pointer_size - cl_value_shift) #define cl_tag_mask (((1UL << cl_tag_len) - 1) << cl_tag_shift) #define cl_value_mask (((1UL << cl_value_len) - 1) << cl_value_shift) @@ -108,7 +108,7 @@ inline cl_uint cl_tag (cl_uint word) // Return the value (unsigned) of a word. inline cl_uint cl_value (cl_uint word) { - // This assumes cl_value_shift + cl_value_len == cl_word_size. + // This assumes cl_value_shift + cl_value_len == cl_pointer_size. return word >> cl_value_shift; } @@ -119,7 +119,7 @@ inline cl_uint cl_combine (cl_uint tag, cl_uint value) } inline cl_uint cl_combine (cl_uint tag, cl_sint value) { - // This assumes cl_value_shift + cl_value_len == cl_word_size. + // This assumes cl_value_shift + cl_value_len == cl_pointer_size. return (value << cl_value_shift) + (tag << cl_tag_shift); } // Keep the compiler happy. diff --git a/include/cl_types.h b/include/cl_types.h index 5e402e7..aba536c 100644 --- a/include/cl_types.h +++ b/include/cl_types.h @@ -48,7 +48,7 @@ #undef HAVE_LONGLONG #endif #endif - #if defined(HAVE_LONGLONG) && (defined(__alpha__) || defined(__mips64__) || defined(__sparc64__)) + #if defined(HAVE_LONGLONG) && (defined(__alpha__) || defined(__mips64__) || (defined(__mips__) && defined(_ABIN32)) || defined(__sparc64__)) // 64 bit registers in hardware #define HAVE_FAST_LONGLONG #endif @@ -101,6 +101,15 @@ typedef long sintP; typedef unsigned long uintP; +// Largest integer type which can be manipulated as efficiently as a pointer. +// This is normally the same as the hardware register size. +// Assumption: cl_word_size >= intPsize + #ifdef HAVE_FAST_LONGLONG + #define cl_word_size 64 + #else + #define cl_word_size 32 + #endif + // Numbers in the heap are stored as "digit" sequences. // A digit is an unsigned int with intDsize bits. // intDsize should be 8 or 16 or 32 or 64. diff --git a/src/float/sfloat/cl_SF.h b/src/float/sfloat/cl_SF.h index f871d56..07e6ef9 100644 --- a/src/float/sfloat/cl_SF.h +++ b/src/float/sfloat/cl_SF.h @@ -21,7 +21,7 @@ #define SF_exp_high (bit(SF_exp_len)-1) // maximum exponent #define SF_exp_shift (SF_mant_len+SF_mant_shift) // lowest exponent bit #define SF_mant_shift SF_value_shift // lowest mantissa bit - #define SF_sign_shift (cl_word_size - 1) + #define SF_sign_shift (cl_pointer_size - 1) // Builds a float from the immediate word. inline cl_SF::cl_SF (struct cl_sfloat * null, cl_uint w) @@ -71,7 +71,7 @@ inline uintL SF_uexp (const cl_SF& x) } inline cl_signean SF_sign (const cl_SF& x) { - return ((cl_sint)x.word << (cl_word_size-1 - SF_sign_shift)) >> (cl_word_size-1); + return ((cl_sint)x.word << (cl_pointer_size-1 - SF_sign_shift)) >> (cl_pointer_size-1); } inline uintL SF_mant (const cl_SF& x) { diff --git a/src/integer/cl_I.h b/src/integer/cl_I.h index 9349fa6..44df5eb 100644 --- a/src/integer/cl_I.h +++ b/src/integer/cl_I.h @@ -89,7 +89,7 @@ inline cl_boolean bignump (const cl_I& x) inline cl_boolean minusp (const cl_I& x) { if (fixnump(x)) - // This assumes cl_value_shift + cl_value_len == cl_word_size. + // This assumes cl_value_shift + cl_value_len == cl_pointer_size. return (cl_boolean)((cl_sint) x.word < 0); else return (cl_boolean)((sintD)mspref(arrayMSDptr(TheBignum(x)->data,TheBignum(x)->length),0) < 0); @@ -116,7 +116,7 @@ inline cl_boolean eq (const cl_I& x, sint32 y) // < ergebnis: der Wert des Fixnum als 32-Bit-Zahl. inline uint32 FN_to_UL (const cl_I& x) { - // This assumes cl_value_shift + cl_value_len == cl_word_size. + // This assumes cl_value_shift + cl_value_len == cl_pointer_size. return (cl_uint)(x.word) >> cl_value_shift; } @@ -126,7 +126,7 @@ inline uint32 FN_to_UL (const cl_I& x) // < ergebnis: der Wert des Fixnum als 32-Bit-Zahl. inline sint32 FN_to_L (const cl_I& x) { - // This assumes cl_value_shift + cl_value_len == cl_word_size. + // This assumes cl_value_shift + cl_value_len == cl_pointer_size. return (cl_sint)(x.word) >> cl_value_shift; } @@ -146,7 +146,7 @@ inline sint32 FN_to_L (const cl_I& x) // < ergebnis: der Wert des Fixnum als 64-Bit-Zahl. inline sint64 FN_to_Q (const cl_I& x) { - // This assumes cl_value_shift + cl_value_len == cl_word_size. + // This assumes cl_value_shift + cl_value_len == cl_pointer_size. return (cl_sint)(x.word) >> cl_value_shift; } @@ -362,7 +362,7 @@ inline uint64 pFN_maxlength_digits_at (const uintD* ptr) inline sintD FN_MSD (cl_uint word) { - // This assumes cl_value_shift + cl_value_len == cl_word_size. + // This assumes cl_value_shift + cl_value_len == cl_pointer_size. return (cl_sint)word >> (cl_value_shift + (FN_maxlength-1)*intDsize); } @@ -629,7 +629,7 @@ inline cl_boolean bignump (const cl_FN& x) inline cl_boolean minusp (const cl_FN& x) { - // This assumes cl_value_shift + cl_value_len == cl_word_size. + // This assumes cl_value_shift + cl_value_len == cl_pointer_size. return (cl_boolean)((cl_sint) x.word < 0); } diff --git a/src/integer/elem/cl_I_compare.cc b/src/integer/elem/cl_I_compare.cc index 5e6e42e..f9b8adb 100644 --- a/src/integer/elem/cl_I_compare.cc +++ b/src/integer/elem/cl_I_compare.cc @@ -38,7 +38,7 @@ cl_signean cl_compare (const cl_I& x, const cl_I& y) // x Fixnum if (fixnump(y)) // x Fixnum, y Fixnum - { // This assumes cl_value_shift + cl_value_len == cl_word_size. + { // This assumes cl_value_shift + cl_value_len == cl_pointer_size. if ((cl_sint)x.word == (cl_sint)y.word) return signean_null; else if ((cl_sint)x.word > (cl_sint)y.word) return signean_plus; else return signean_minus; diff --git a/src/integer/elem/cl_I_equal.cc b/src/integer/elem/cl_I_equal.cc index 4bcc646..3476f5f 100644 --- a/src/integer/elem/cl_I_equal.cc +++ b/src/integer/elem/cl_I_equal.cc @@ -27,7 +27,7 @@ cl_boolean cl_equal (const cl_I& x, const cl_I& y) // x Fixnum if (fixnump(y)) // x Fixnum, y Fixnum - { // This assumes cl_value_shift + cl_value_len == cl_word_size. + { // This assumes cl_value_shift + cl_value_len == cl_pointer_size. return (cl_boolean) ((cl_sint)x.word == (cl_sint)y.word); } else diff --git a/src/integer/elem/cl_I_minus1.cc b/src/integer/elem/cl_I_minus1.cc index 38aa660..e7fd54a 100644 --- a/src/integer/elem/cl_I_minus1.cc +++ b/src/integer/elem/cl_I_minus1.cc @@ -18,7 +18,7 @@ const cl_I minus1 (const cl_I& x) { // x ist Fixnum if (x.word != cl_combine(cl_FN_tag,bit(cl_value_len-1))) // bleibt Fixnum: direkt 1 subtrahieren - // This assumes cl_value_shift + cl_value_len == cl_word_size. + // This assumes cl_value_shift + cl_value_len == cl_pointer_size. { return cl_I_from_word(x.word - cl_combine(0,1)); } } // die sichere Methode diff --git a/src/integer/elem/cl_I_plus1.cc b/src/integer/elem/cl_I_plus1.cc index 58c90d7..bc73cfc 100644 --- a/src/integer/elem/cl_I_plus1.cc +++ b/src/integer/elem/cl_I_plus1.cc @@ -18,7 +18,7 @@ const cl_I plus1 (const cl_I& x) { // x ist Fixnum if (x.word != cl_combine(cl_FN_tag,bit(cl_value_len-1)-1)) // bleibt Fixnum: direkt 1 addieren - // This assumes cl_value_shift + cl_value_len == cl_word_size. + // This assumes cl_value_shift + cl_value_len == cl_pointer_size. { return cl_I_from_word(x.word + cl_combine(0,1)); } } // die sichere Methode