[cfe-dev] [LLVMdev] Non-standard byte sizes

Ken Dyck kd at kendyck.com
Fri Jan 28 06:14:14 PST 2011

On Fri, Jan 28, 2011 at 6:29 AM, David Given <dg at cowlark.com> wrote:
> For a hypothetical Evil Project(tm), I would like to do a LLVM backend
> for a virtual machine that does not use 8-bit bytes. Does LLVM support
> this sort of thing?

Not without some modification.

I've developed an LLVM back end for a DSP with 24-bit word-addressable
memory, basically by defining the alignment of i8 to be the word size
of the machine. So it _is_ possible.

There are a bunch of places in clang/llvm that assume that the
alignment of i8 is 8, and these all need to be generalized to respect
the specified alignment. Then in your instruction lowering code you
need to convert all the offsets in memory accesses from 8-bit units to
word-sized ones so that addressing is correct.

Of course, this approach only works if you are willing to specify
chars as i8 in clang.

FWIW, I'm working towards properly generalizing the size of char in
clang in my spare time, but that work is not nearly complete. I plan
to someday extend that work into llvm.

I can send you a patch of the changes that I made to clang/llvm
release 2.8, if you'd like. Be warned that it also contains support
for non-power-of-2 machine types.


More information about the cfe-dev mailing list