[LLVMdev] Metadata

Devang Patel devang.patel at gmail.com
Thu Feb 11 15:36:22 PST 2010


On Thu, Feb 11, 2010 at 10:54 PM, David Greene <dag at cray.com> wrote:
> 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
> on.
>
> 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 guess, that's what I described in the example in previous email :).
In this case, your metadata is just an integer one. In my example, my
metadata was a collection of 4 values.

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

-
Devang




More information about the llvm-dev mailing list