[LLVMdev] Struct Types and GCC compatibility

Mike Emmel mike.emmel at gmail.com
Tue Dec 20 16:27:41 PST 2005


On 12/20/05, Chris Lattner <sabre at nondot.org> wrote:
> 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.
>
> Great!
>
> > 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.
>
> Yes.
>
> > 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.
>
> Ok.
>
> > 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.
>
Okay that sounds reasonable I think its pretty close to what GCC has by default
of course I've never compeletely figured out GCC struct packing it
seems to be more exceptions then rules, the Gnu ObjectiveC
runtime has code to determine the packing at runtime from a string
type definition btw I don't think its complete though.

I'll go ahead and go with the default for the time being.  It was more
of a long term issue then short term i.e later integration with C/C++
.
I'm going to try and match the layout of the C++ abi if I can but
there may be problems here.
The idea is to be compatible with the C++ gcj cni api if possible.

Finally Does the llvm gcc backend support C++  ?

> I hope this is the information you are looking for.  If you have more
> specific questions, please feel free to ask.
>
Yep thanks for the information. I'll keep plugging away.

Mike

> -Chris
>
> --
> http://nondot.org/sabre/
> http://llvm.org/
>
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>




More information about the llvm-dev mailing list