[LLVMdev] Metadata

David Greene dag at cray.com
Thu Feb 11 14:54:51 PST 2010

On Thursday 11 February 2010 16:31:16 Garrison Venn wrote:
> I don't think the lang ref metadata grammar section
> (http://llvm.org/docs/LangRef.html#metadata) has been fully updated with
> how !dbg metadata is used in
> http://llvm.org/docs/SourceLevelDebugging.html. At least to me it is not
> clear. In my mind I translate the phrase "LLVM IR allows metadata to be
> attached to instructions " into a grammar depicted in
> SourceLevelDebugging.html. I was going to ask about this, but I'll let you
> instead. :-)

But that's not even a grammar.

I simply want to know what the syntax is for specifying metadata on an 
instruction.  From what I gather, it is this:

<instruction> ',' <MetadataSpec>

<MetadataSpec>: '!' <ID> '!' <ID>

<ID>: [a-zA-Z_][a-zA-Z0-9_]*

And the second <ID> needs to be the name of a metadata node:

'!' <ID> '=' METADATA '!' '{' <MDNodeList> '}'

And MDNodeList contains a list of stuff like integer values, strings and so 

Is that basically right?  So I would have to do this:

	%r8 = load <2 x double>* %r6, align 16, !nontemporal !0
!0 = metadata !{ i32 1 }

I would really rather not have to specify the entirely redundant !0.  Just the 
fact that the instruction has metadata with index/name "nontemporal" should
be enough.


More information about the llvm-dev mailing list