[llvm-dev] PointerIntPair

Paul C. Anagnostopoulos via llvm-dev llvm-dev at lists.llvm.org
Thu Dec 31 11:13:04 PST 2020


The bits are orthogonal, so I think an enum makes more sense. I take it from your response that you think a PointerIntPair is a fine thing to use.

There are no alignment requirements on an X86, for example. I presume that compilers impose alignments anyway, but are they consistent enough to rely on?

At 12/31/2020 01:51 PM, Craig Topper wrote:
>A PointerIntPair can be placed in the pointer part of another PointerIntPair. So you can nest them to have 2 booleans without creating an enum. This works because PointerIntPair always puts the bit in the highest bit possible leaving the low bits free to be used by another int.
>
>The number of bits available in a pointer depends on the alignment requirement of the type the pointer points to. If it’s a class/struct it depends on the largest alignment required by its fields. The alignof operator is used to check the alignment.



More information about the llvm-dev mailing list