[LLVMdev] 32bit pointers on a (pure) 64bit architecture

Hal Finkel
Thu, 03 Apr 2014 22:44:38 -0000

----- Original Message -----
> From: "Jeroen Dobbelaere" <jeroen.dobbelaere at gmail.com>
> To: LLVMdev at cs.uiuc.edu
> Sent: Thursday, April 3, 2014 5:31:13 PM
> Subject: [LLVMdev] 32bit pointers on a (pure) 64bit architecture
>
> Hi,
>
> I am trying to get llvm working for an architecture that has 64bit
> registers, but 32bit addresses.
> Because of that, I want the pointers to also be 32bit, although they
> will live in a 64 bit register.
>
>
> On the frontend, I do not encounter any issues, but when I provide a
> ...
> "p:32:32:32"
> ...
>
> DataLayout specification to the backend, things get ugly:
>
> - SelectionDag is producing a mix of 64bit and 32bit nodes, and it
> seems that a number of
> necessary legalizations/promotions are missing.

I don't understand why you're doing this. If the pointers live in 64-bit
registers, why don't you just consider them to be 64-bit pointers? The fact
that the upper 32 bits will always be zero does not seem like something
you'd need to worry about (although there are certainly some optimizations
that can be done later). Frontend issues, like the fact that ptrdiff_t is only
32 bits, seem like an independent concern.

 -Hal

>
>
> After adding support for 'PromoteIntRes_GlobalAddress(...)', I get
a
> failure, because a 'store' node now has a mix of operands:
>
> - some of the operands were already 'i64' from the beginning,
>
> - others were 'i32' (due to the 32bit pointers) and have been
> promoted to 'i64'
>
>
> Because of the latter, the 'PromoteIntOp_STORE' is called. This
uses
> 'GetPromotedInteger' to access the operands.
>
> But, GetPromotedInteger fails if the operand was not promoted. So it
> fails on the operands of the 'store' that were already legal (i64).
>
>
> What would be the recommended way to fix this ?
>
> (Or did I miss something, and should 32bit pointers on a 64bit
> architecture be done in a completely different way)
>
>
>
> Greetings,
> Jeroen Dobbelaere
>
>
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>

--
Hal Finkel
Assistant Computational Scientist
Leadership Computing Facility
Argonne National Laboratory