[LLVMdev] Request documentation for global var syntax

Schimmel, Mark mark.schimmel at windriver.com
Thu Feb 1 08:54:00 PST 2007


Does anyone have any good ideas to verify that the layout of a struct
from the front end (field offsets and alignment) exactly match LLVM's
interpretation of that struct?  I want to support packing of structs and
pragmas/attributes for alignment and validate that the front end and
back end match.  [ This is a different front end (ie. Not GNU based). ]

For example:
	__packed struct S1 {
		char c;
		double d;
	};

If I wanted c at byte offset 0 and d at byte offset 1, how would I
communicate that to LLVM?  If the user applied another pragma/attribute
which aligned d at offset 2, how would I communicate that and validate
it?  The assumption here is that the user could declare a struct type
whose layout doesn't match the default layout from LLVM.

Perhaps I could extend llvm-as to accept additional annotations in type
declarations?

	%S1 = type align 1 { sbyte at 0, double at 2 }

I don't see anything like this in the 1.9 grammar.

-----Original Message-----
From: llvmdev-bounces at cs.uiuc.edu [mailto:llvmdev-bounces at cs.uiuc.edu]
On Behalf Of Chris Lattner
Sent: Saturday, January 13, 2007 4:35 PM
To: LLVM Developers Mailing List
Subject: Re: [LLVMdev] Request documentation for global var syntax

On Thu, 11 Jan 2007, Schimmel, Mark wrote:
> file://docs/LangRef.html#globalvars
>
> The section describing the definition of global vars discusses that
you
> can specify an alignment and can also specify a section.  Could
someone
> provide an example that works in gccas in release 1.9 for both
defining
> which section the var is assigned to and defining the variables
> alignment?

They are just comma separated:

%G = constant float 1.000000e+00, section "foo", align 4

> Also, is there another document that describes how you define sections
> and their attributes?

sections are target-specific, usually defined by the linker.

-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