[LLVMdev] llvm "iword" type

Eugene Toder eltoder at gmail.com
Mon Aug 9 11:37:21 PDT 2010


Small nitpick: size_t is not guaranteed to be large enough to hold a
pointer (only an array index, which can be less; though such platforms
are pretty exotic now). [u]intptr_t are the types.

Eugene

On Mon, Aug 9, 2010 at 5:44 PM, Joshua Warner <joshuawarner32 at gmail.com> wrote:
> Hi,
>
> I'm generating some LLVM IR that has to mask out the lower bits two bits of
> a certain pointers.  I expect this should be done like so (on a 32-bit
> architecture)
>
> ...
> %classPointer = ...
> %classPointer1 = ptrtoint i8** %classPointer to i32
> %classPointer2 = and i32 -4, %classPointer1
> %realClassPointer = inttoptr i32 %classPointer2 to i8**
> ...
>
> Ideally, I'd like to generate completely architecture-independent code,
> which brings me to my question: Does LLVM have some sort of
> i<target_ptr_size> type that I can cast to to do this masking (like size_t
> in C), instead of generating different LLVM IR for 32- and 64- bit
> architectures?
>
> Thanks,
>
> Joshua
>
>
>
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>
>




More information about the llvm-dev mailing list