<div><div dir="auto">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.</div><div dir="auto"><br></div><div dir="auto">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.</div></div><div><div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Dec 31, 2020 at 10:22 AM Paul C. Anagnostopoulos via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;padding-left:1ex;border-left-color:rgb(204,204,204)">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.<br>
<br>
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.<br>
<br>
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.)<br>
<br>
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?<br>
<br>
_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
</blockquote></div></div>
</div>-- <br><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature">~Craig</div>