[llvm-dev] PointerIntPair

Craig Topper via llvm-dev llvm-dev at lists.llvm.org
Thu Dec 31 10:51:16 PST 2020


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.

On Thu, Dec 31, 2020 at 10:22 AM Paul C. Anagnostopoulos via llvm-dev <
llvm-dev at lists.llvm.org> wrote:

> The TableGen field value (RecordVal) class includes a PointerIntPair. The
> integer is a boolean that specifies whether the field was defined with the
> 'field' prefix.
>
> I'd like to add another boolean to RecordVal to specify whether the field
> is actually a template argument. I could make the Int an enum instead, with
> three elements. That would require 2 bits. I see this has been done
> elsewhere.
>
> What do people think about PointerIntPair? Is it a good thing to use? I
> could simply add the enum as a new data item in the RecordVal, but I
> estimate this could add 10--12 MB to the memory requirement of TableGen.
> (The AMDGPU target's TableGen files result in about 3 million record
> fields.)
>
> While I'm here, let me ask how the PointerIntPair works at all. Does every
> target guarantee at least 4-byte alignment of stack/heap objects?
>
> _______________________________________________
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
>
-- 
~Craig
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20201231/d5d104b0/attachment.html>


More information about the llvm-dev mailing list