[LLVMdev] Struct Types and GCC compatibility
sabre at nondot.org
Tue Dec 20 12:04:15 PST 2005
On Tue, 20 Dec 2005, Mike Emmel wrote:
> Hi all I'm writing a direct llvm backend for gcjx a new java fronted for gcc.
> I'm now ready to tackle creating the structures to represnt classes I
> read the gcc 4.0 patches and it seems that the llvm struct is padded
> and aligned using the info from the gcc tree.
> In my case I don't have this information. I'm willing to intially let
> llvm align and pad the struct but its not clear what the natural
> values are since it seems to be packed.
> In any case some helpful hints on what the right route is here would
> be appreciated. It would be nice to get compatibility with gcc.
I think that just letting LLVM do the packing will probably be what you
want. The cases where the C front-end needs to manually hack on things
are for bigfields, explicit alignment attributes, etc, which I don't think
Java has (correct me if I'm wrong)! LLVM uses very simple layout rules,
basically inserting padding before each structure element to bring it to
its natural alignment. The alignment of a struct is the maximum of the
alignment of its elements, and the size of the struct is always a multiple
of the alignment.
I hope this is the information you are looking for. If you have more
specific questions, please feel free to ask.
More information about the llvm-dev