[llvm-commits] [llvm] r92270 - in /llvm/trunk: lib/AsmParser/LLParser.cpp test/Assembler/metadata.ll
Chris Lattner
sabre at nondot.org
Tue Dec 29 13:25:40 PST 2009
Author: lattner
Date: Tue Dec 29 15:25:40 2009
New Revision: 92270
URL: http://llvm.org/viewvc/llvm-project?rev=92270&view=rev
Log:
Each instruction is allowed to have *multiple* different
metadata objects on them. Though the entire compiler supports this,
the asmparser didn't.
Modified:
llvm/trunk/lib/AsmParser/LLParser.cpp
llvm/trunk/test/Assembler/metadata.ll
Modified: llvm/trunk/lib/AsmParser/LLParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/AsmParser/LLParser.cpp?rev=92270&r1=92269&r2=92270&view=diff
==============================================================================
--- llvm/trunk/lib/AsmParser/LLParser.cpp (original)
+++ llvm/trunk/lib/AsmParser/LLParser.cpp Tue Dec 29 15:25:40 2009
@@ -1105,24 +1105,33 @@
/// ParseOptionalCustomMetadata
/// ::= /* empty */
-/// ::= !dbg !42
+/// ::= !dbg !42 (',' !dbg !57)*
bool LLParser::ParseOptionalCustomMetadata() {
if (Lex.getKind() != lltok::NamedOrCustomMD)
return false;
- std::string Name = Lex.getStrVal();
- Lex.Lex();
+ while (1) {
+ std::string Name = Lex.getStrVal();
+ Lex.Lex();
- if (Lex.getKind() != lltok::Metadata)
- return TokError("Expected '!' here");
- Lex.Lex();
+ if (Lex.getKind() != lltok::Metadata)
+ return TokError("expected '!' here");
+ Lex.Lex();
- MetadataBase *Node;
- if (ParseMDNode(Node)) return true;
+ MetadataBase *Node;
+ if (ParseMDNode(Node)) return true;
- unsigned MDK = M->getMDKindID(Name.c_str());
- MDsOnInst.push_back(std::make_pair(MDK, cast<MDNode>(Node)));
- return false;
+ unsigned MDK = M->getMDKindID(Name.c_str());
+ MDsOnInst.push_back(std::make_pair(MDK, cast<MDNode>(Node)));
+
+ // If this is the end of the list, we're done.
+ if (!EatIfPresent(lltok::comma))
+ return false;
+
+ // The next value must be a custom metadata id.
+ if (Lex.getKind() != lltok::NamedOrCustomMD)
+ return TokError("expected more custom metadata ids");
+ }
}
/// ParseOptionalAlignment
@@ -3008,9 +3017,9 @@
//===----------------------------------------------------------------------===//
/// ParseRet - Parse a return instruction.
-/// ::= 'ret' void (',' !dbg, !1)
-/// ::= 'ret' TypeAndValue (',' !dbg, !1)
-/// ::= 'ret' TypeAndValue (',' TypeAndValue)+ (',' !dbg, !1)
+/// ::= 'ret' void (',' !dbg, !1)*
+/// ::= 'ret' TypeAndValue (',' !dbg, !1)*
+/// ::= 'ret' TypeAndValue (',' TypeAndValue)+ (',' !dbg, !1)*
/// [[obsolete: LLVM 3.0]]
bool LLParser::ParseRet(Instruction *&Inst, BasicBlock *BB,
PerFunctionState &PFS) {
@@ -3031,8 +3040,8 @@
if (ParseOptionalCustomMetadata()) return true;
} else {
// The normal case is one return value.
- // FIXME: LLVM 3.0 remove MRV support for 'ret i32 1, i32 2', requiring use
- // of 'ret {i32,i32} {i32 1, i32 2}'
+ // FIXME: LLVM 3.0 remove MRV support for 'ret i32 1, i32 2', requiring
+ // use of 'ret {i32,i32} {i32 1, i32 2}'
SmallVector<Value*, 8> RVs;
RVs.push_back(RV);
Modified: llvm/trunk/test/Assembler/metadata.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Assembler/metadata.ll?rev=92270&r1=92269&r2=92270&view=diff
==============================================================================
--- llvm/trunk/test/Assembler/metadata.ll (original)
+++ llvm/trunk/test/Assembler/metadata.ll Tue Dec 29 15:25:40 2009
@@ -1,7 +1,8 @@
-; RUN: llvm-as < %s | llvm-dis | llvm-as | llvm-dis | grep {ret void, !foo !0}
+; RUN: llvm-as < %s | llvm-dis | llvm-as | llvm-dis | grep {ret void, !bar !1, !foo !0}
define void @test() {
- ret void, !foo !0
-;, !bar !1
+ add i32 2, 1, !bar !0
+ add i32 1, 2, !foo !1
+ ret void, !foo !0, !bar !1
}
!0 = metadata !{i32 662302, i32 26, metadata !1, null}
More information about the llvm-commits
mailing list