Backend for Harvard Architecture


On a recent discussion on the cfe-dev mailing list[1] it was asked how
easy it was to create a backend to an Harvard Arch chip: different
data/function pointer sizes and 16 bit chars (main issues of the
targeted arch). Ken Dyck has posted a patch (which solved at least the
second problem of 16bit char) on which I have been working on and
Douglas Gregor said that different pointer sizes are already supported
by Clang, but what about llvm? When creating a backend, I have created
the DataLayout string but this string only allows me (as far as the
docs I found are concerned) to specify a pointer size (not several
pointer sizes). Is this something that Clang already supports but has
not yet managed to get into llvm or am I missing some configuration?

Moreover, I can't find a detailed description of this string anywhere
besides whats mentioned on the backend tutorial. Any pointers to this
would be excellent!

[1] -


Not supported at the moment in LLVM. Probably the easiest way to deal
with it would be to make pointers the larger of data/function
pointers, make the in-memory representation of the smaller an int of
the appropriate width, and do some casting to "fix" the pointers.
Properly supporting different data/function pointer sizes would
require messing with the current system of casts; currently LLVM
assumes casting between function and data pointers is lossless (using
the "bitcast" instruction).