Subject: Re: [boost] Interest request for pointer+bit compressionoptimization
From: Doug Gregor (doug.gregor_at_[hidden])
Date: 2009-09-08 11:22:28
On Tue, Sep 8, 2009 at 3:51 AM, troy d. straszheim<troy_at_[hidden]> wrote:
> David Abrahams wrote:
>> on Tue Sep 08 2009, Vicente Botet Escriba <vicente.botet-AT-wanadoo.fr>
>>> Do you have a specific pointer for CLang related to this usage?
>> Nope, this is hearsay. Doug?
> If I remember Doug's explanation correctly, one of the
> optimizations inside clang is: There is a global table of 'plain'
> types, e.g. int, bool, float, std::string. Clang internally represents
> CV qualified types by e.g. creating a pointer to the type 'int',
> then using the small bits of the pointer to tag const and volatile. I
> don't recall whether they used more than two bits (for, say reference,
> static, pointer, etc.) Sebastian Redl gave a great intro to clang @
> boostcon, I'd bet he knows the details as well.
Clang's QualType smart pointer uses three bits, for const, volatile,
and restrict, so we have to force 8-byte alignment when we allocate
Type structures. There's a tiny bit of explanation of this part of the
type system here:
The actual QualType class is here:
We use this bit-mangling trick a *lot* in Clang. The general
infrastructure is "PointerIntPair", which is what it says it is: a
pointer and an integer mangled together, with accessors for each. The
code is here:
We build most of our bit-mangled structures on top of PointerIntPair
or PointerUnion, a union of two (distinct) pointer types:
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk