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. :-) Garrison On Feb 11, 2010, at 16:42, David Greene wrote:> On Thursday 11 February 2010 14:56:16 Chris Lattner wrote: > >>> I give up! What is the syntax for attaching metadata to instructions? >>> The documentation is very unclear. >> >> Some examples are in llvm/test/Feature/md_on_instruction.ll >> >> Or you could just compile a file with -g. > > But neither of these explains what the grammar is. It looks like gibberish to > me... > > -Dave > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
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 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. -Dave
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
On Feb 11, 2010, at 2:54 PM, David Greene wrote:> > 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 }Yes.> 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.Why? These are uniqued anyway, it won't matter for performance and "!nontermporal !0" is not substantially worse than "!nontermporal". I'd rather keep the metadata model simple than optimize it for nullary metadata. -Chris