[LLVMdev] adjust address calculus for an architecture that does not address bytes

Dan Gohman gohman at apple.com
Wed Apr 1 10:37:16 PDT 2009

On Apr 1, 2009, at 1:40 AM, Christian Sayer wrote:
> I think this would be to subclass TargetData in the backend - I'd  
> appreciate if someone
> could confirm or not that there isn't another option within the  
> current way of designing
> a backend.

(8-bit) byte addressibility is a fairly widespread assumption in LLVM,
reaching beyond just GEP lowering.  Fixing this will require more
work than just adding a subclass, though it ought to be doable.

Go through the TargetData class and generalize anything that works
in terms of bytes to work in terms of address units.  I think you'll  
to extend the datalayout string syntax to support an address unit
size (in bits), and to add an address unit size field to the TargetData
class.  You'll also need to change APIs like getSizeInBytes to

Then, you can change your target datalayout string to be in terms of
16-bit address units instead of 8-bit address units.

Then there are other places in LLVM which hardcode "8" constants
and "i8*" types; these can be fixed once the TargetData changes are
in place.


More information about the llvm-dev mailing list