[LLVMdev] RFC: Supporting different sized address space arithmetic

Villmow, Micah Micah.Villmow at amd.com
Fri Aug 17 14:53:17 PDT 2012


Currently LLVM only supports address calculations for a single address space(the default). This is problematic when the device pointer type is 32/64bits, but there are small distinct memories that only have 16 bits of addressing(think GPU's with small software controlled memory segments).

I am proposing a modification to a few API's in SelectionDAG that I believe will fix this problem.

In TargetLowering

*         Add getPointerTy to take an argument, the address space, this defaults to 0.

*         Add a virtual API call that returns the default address space for the target, this defaults to returning 0.

*         Have the original getPointerTy implementation with no arguments query for the default address space.
In SelectionDAG

*         Add a new API to getIntPtrConstant that takes an address space as the second argument

*         Modify the implementation of the original getIntPtrConstant function to call the new function with getDefaultAddressSpace().

Modify SelectionDAGBuilder::visitGetElementPtr to get the address space of pointer argument and passing it into the getIntrPtrConstant and getPointerTy calls.

As far as I can tell, this should not affect any backends behavior, but will allow the targets with disjoint address spaces to directly address them in the most efficient manner.

So, what do you think? Is this the correct approach? Or does it actually require more fundamental changes.

Thanks,
Micah
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20120817/27b1b996/attachment.html>


More information about the llvm-dev mailing list