[llvm-commits] [Review] Attributes Documentation

Bill Wendling wendling at apple.com
Thu Dec 6 12:51:53 PST 2012


On Dec 6, 2012, at 6:52 AM, Meador Inge <meadori at codesourcery.com> wrote:

> On Dec 5, 2012, at 7:53 PM, Bill Wendling wrote:
> 
>>> ====
>>> 
>>> Why is the syntax backwards? Metadata are defined like this:
>>> 
>>> !x = metadata { ... }
>>> 
>>> whereas attributes are defined like this:
>>> 
>>> attributes #0 = { ... }
>>> 
>>> This seems weird. Can we not standardise it?
>>> 
>> I actually based this off of the module-level asm syntax. (In an earlier version, there was a 'module' keyword before the 'attributes' keyword.)
>> 
>> I'm not a big fan of the metadata syntax. One reason I can think of for why metadata is written that way is because metadata lets one metadata object reference another. So there's a 'metadata' keyword placed in front of it. I'm not going to allow attribute groups to reference each other.
> 
> FWIW, most things in LLVM assembly language that involve defining names
> for things do have the "type information" after the equals sign:
> 
>   %struct.T = type { i32 }
> 
>   @y = global i32 12, align 4
> 
>   !0 = metadata !{metadata !"zero"}
> 
>   @foo = alias @bar
> 
> I think James' suggestion is a good one and is more consistent with
> other language elements that introduce named objects.  'module asm'
> isn't necessarily a good model because it doesn't introduce a named
> object -- it is more of a directive for inlining assembly.
> 

So would you suggest this as a possible syntax?

	#<name> = attributes { a1 a2 a3=val }

Or should we follow the metadata method:

	#<name> = attributes #{ a1, a2, a3=val, #"a4" }

(To be honest, I've never understood the reason behind the '!{' syntax for metadata...)

-bw




More information about the llvm-commits mailing list