I looked through the "intp" thread.  <br><br>I don't really want to start that argument up again, but my immediate thought would be to create a new class of "picked-by-the-target" integer types (equivelents of size_t, intptr_t, etc...), and two new instructions, zcast and scast, which are only valid in the context of casting to / from integer types of unknown sizes.  To begin with, most passes could probably ignore (or otherwise pass pass over) these instructions.  The resolution of these types would only happen in the legalize phase in the SelectionDAG.<br>
<br>Just my two cents...<br><br>For now, I'll settle for a little architecture dependence in my front-end.<br><br>Joshua<br><br><div class="gmail_quote">On Mon, Aug 9, 2010 at 1:14 PM, Kenneth Uildriks <span dir="ltr"><<a href="mailto:kennethuil@gmail.com">kennethuil@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">That and the possibility of differently sized pointers made me<br>
hesitate to dive into implementing this.  I guess nailing it down to<br>
be the platform equivalent of size_t would be sensible here.<br>
<div><div></div><div class="h5"><br>
On Mon, Aug 9, 2010 at 1:37 PM, Eugene Toder <<a href="mailto:eltoder@gmail.com">eltoder@gmail.com</a>> wrote:<br>
> Small nitpick: size_t is not guaranteed to be large enough to hold a<br>
> pointer (only an array index, which can be less; though such platforms<br>
> are pretty exotic now). [u]intptr_t are the types.<br>
><br>
> Eugene<br>
><br>
> On Mon, Aug 9, 2010 at 5:44 PM, Joshua Warner <<a href="mailto:joshuawarner32@gmail.com">joshuawarner32@gmail.com</a>> wrote:<br>
>> Hi,<br>
>><br>
>> I'm generating some LLVM IR that has to mask out the lower bits two bits of<br>
>> a certain pointers.  I expect this should be done like so (on a 32-bit<br>
>> architecture)<br>
>><br>
>> ...<br>
>> %classPointer = ...<br>
>> %classPointer1 = ptrtoint i8** %classPointer to i32<br>
>> %classPointer2 = and i32 -4, %classPointer1<br>
>> %realClassPointer = inttoptr i32 %classPointer2 to i8**<br>
>> ...<br>
>><br>
>> Ideally, I'd like to generate completely architecture-independent code,<br>
>> which brings me to my question: Does LLVM have some sort of<br>
>> i<target_ptr_size> type that I can cast to to do this masking (like size_t<br>
>> in C), instead of generating different LLVM IR for 32- and 64- bit<br>
>> architectures?<br>
>><br>
>> Thanks,<br>
>><br>
>> Joshua<br>
>><br>
>><br>
>><br>
>> _______________________________________________<br>
>> LLVM Developers mailing list<br>
>> <a href="mailto:LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</a>         <a href="http://llvm.cs.uiuc.edu" target="_blank">http://llvm.cs.uiuc.edu</a><br>
>> <a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br>
>><br>
>><br>
><br>
> _______________________________________________<br>
> LLVM Developers mailing list<br>
> <a href="mailto:LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</a>         <a href="http://llvm.cs.uiuc.edu" target="_blank">http://llvm.cs.uiuc.edu</a><br>
> <a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br>
><br>
</div></div></blockquote></div><br>