Struct Types and GCC compatibility

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Struct Types and GCC compatibility

Mike Emmel
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.

Mike

_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: Struct Types and GCC compatibility

Chris Lattner
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.

I hope this is the information you are looking for.  If you have more
specific questions, please feel free to ask.

-Chris

--
http://nondot.org/sabre/
http://llvm.org/

_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: Struct Types and GCC compatibility

Mike Emmel
On 12/20/05, Chris Lattner <[hidden email]> 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
> [hidden email]         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>

_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: Struct Types and GCC compatibility

Chris Lattner
On Tue, 20 Dec 2005, Mike Emmel wrote:
> 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++

sounds good.

> Finally Does the llvm gcc backend support C++  ?

It does in my tree, except that exceptions are not implemented yet.  I'll
push a new patch out to the GCC list soon.  The old "llvm-gcc" does
support C++, including exceptions.

-Chris

--
http://nondot.org/sabre/
http://llvm.org/

_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev