[LLVMdev] 32bit pointers on a (pure) 64bit architecture
David Chisnall
David.Chisnall at cl.cam.ac.uk
Fri Apr 4 02:02:06 PDT 2014
On 3 Apr 2014, at 23:44, Hal Finkel <hfinkel at anl.gov> wrote:
> 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.
Presumably pointers are also only 32 bits in memory. I'm not quite sure what the issue here is though, because the DataLayout string just defines in-memory representations. In particular, it *doesn't* differentiate between the size and the range of a pointer[1].
When you get to the back end, you can just do zero extension of pointer loads. This is slightly tricky, because SelectionDAG is very keen on throwing away the fact that something is a pointer, but the same type legalisation that works for unsigned 32-bit integers should apply to pointers...
David
[1] I have some patches that do this, for fat pointer support.
More information about the llvm-dev
mailing list