This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Chill vs. Pascal sets (was: undefined reference to `__setbits')


Peter Gerwinski <peter@gerwinski.de> writes:

> There are yet other problems with the existing Chill
> implementation of sets.  At the moment, re-implementing Pascal
> sets using the existing Chill support in the backend would mean
> a serious drawback.

No-body claims the existing Chill run-time implementation is very good.
However, I think the support in the compiler is reasonable,
though it needs some work.

For a better low-level bitstring library, check out the "Bitstring
Primitives" section of http://www.bothner.com/~per/software/.

A recent message I wrote explained that we were constrained to be
binary compatible with an older implementation, and also
discusses the issues you mention in depth.  Unfortunately, I can't
find the message in the archives; it would have been in August
or early September this year (based on other evidence).

>   * Sets are a sequence of bits.  Chill is bundling them
>     to 8-bit bytes.  For efficiency reasons, this should
>     be generalized to allow for 32/64-bit words instead.
>     We could introduce a constant `BITS_PER_SET_UNIT' or
>     similar that could be set to `BITS_PER_UNIT' in Chill
>     and to `BITS_PER_WORD' in Pascal.

Yes.  See my previous message, as well as the above URL.

>   * Chill sets are not aligned; a `set of 4..7' fills the
>     _lower_ half of a byte.  In Pascal, the lower bound is
>     rounded down to a multiple of `BITS_PER_SET_UNIT', so
>     `set of 4..7' fills the _upper_ half of a byte.
>     If we introduce a new constant `SET_ALIGNMENT'
>     holding zero in Chill and `BITS_PER_WORD' in Pascal,
>     `get_set_constructor_bits()' (tree.c) can easily handle
>     both cases.

This was also discussed in my previous message. Basically, in
Chill there is no need to align "powersets" (the Chill term for
Pascal "sets"), because you cannot do operations on powersets
with incompatible domains.  However, if Pascal needs sets to be
aligned there is no reason not to align Chill powersets as well.
Simplicity and binary compatibility between the languages
would argue in favor doing that.  The only downside is infrequent
allocation of an extra word.  I suspect if there is anyone
using the public version of GNU Chill, they would be happy to
sacrifice that for compatibility with Pascal.

>   * What's the issue with `BYTES_BIG_ENDIAN'?  Why don't we
>     consistently use the mask `1 << bitpos' on all machines to
>     access the `bitpos'th bit in a word?

My previous message discusses this in depth.  For true big-endian
consistency on a big-endian machine, one should define the 0'th bit
as the *high-order* bit.  However, I doubt the consistency is
worth the extra complication, so I agree we should just use
1<<bitpos.

>   * In `store_constructor()' (expr.c) there should be a
>     comment indicating that the `__setbits()' function has to
>     be supported by the language-specific run time library.
>     (Since there are different values of `BITS_PER_SET_UNIT'
>     and `SET_ALIGNMENT', this is indeed language-specific.)

But if we agree that Pascal and Chill shoudl use the same values for
BITS_PER_SET_UNIT and SET_ALIGNMENT (which should probably be the same),
there is no problem, is there?
-- 
	--Per Bothner
bothner@pacbell.net  per@bothner.com   http://www.bothner.com/~per/

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]