summaryrefslogtreecommitdiffstats
path: root/llvm/lib/AsmParser/LLParser.cpp
diff options
context:
space:
mode:
authorDevang Patel <dpatel@apple.com>2009-07-29 00:34:02 +0000
committerDevang Patel <dpatel@apple.com>2009-07-29 00:34:02 +0000
commitbe62697e6b72468d4332c296cac32022815bb6c7 (patch)
tree788e313f2346a7749b051b5f23e5a9aebc04dc87 /llvm/lib/AsmParser/LLParser.cpp
parent05a26fb6dd575a654c5eab7ac8bcd9f8ac6c0726 (diff)
downloadbcm5719-llvm-be62697e6b72468d4332c296cac32022815bb6c7.tar.gz
bcm5719-llvm-be62697e6b72468d4332c296cac32022815bb6c7.zip
Parse named metadata.
llvm-svn: 77410
Diffstat (limited to 'llvm/lib/AsmParser/LLParser.cpp')
-rw-r--r--llvm/lib/AsmParser/LLParser.cpp36
1 files changed, 36 insertions, 0 deletions
diff --git a/llvm/lib/AsmParser/LLParser.cpp b/llvm/lib/AsmParser/LLParser.cpp
index b2d2b51b6c7..36f714b38e3 100644
--- a/llvm/lib/AsmParser/LLParser.cpp
+++ b/llvm/lib/AsmParser/LLParser.cpp
@@ -121,6 +121,7 @@ bool LLParser::ParseTopLevelEntities() {
case lltok::LocalVar: if (ParseNamedType()) return true; break;
case lltok::GlobalVar: if (ParseNamedGlobal()) return true; break;
case lltok::Metadata: if (ParseStandaloneMetadata()) return true; break;
+ case lltok::NamedMD: if (ParseNamedMetadata()) return true; break;
// The Global variable production with no name can have many different
// optional leading prefixes, the production is:
@@ -409,6 +410,41 @@ bool LLParser::ParseMDNode(MetadataBase *&Node) {
return false;
}
+///ParseNamedMetadata:
+/// !foo = !{ !1, !2 }
+bool LLParser::ParseNamedMetadata() {
+ assert(Lex.getKind() == lltok::NamedMD);
+ Lex.Lex();
+ std::string Name = Lex.getStrVal();
+
+ if (ParseToken(lltok::equal, "expected '=' here"))
+ return true;
+
+ if (Lex.getKind() != lltok::Metadata)
+ return TokError("Expected '!' here");
+ Lex.Lex();
+
+ if (Lex.getKind() != lltok::lbrace)
+ return TokError("Expected '{' here");
+ Lex.Lex();
+ SmallVector<MetadataBase *, 8> Elts;
+ do {
+ if (Lex.getKind() != lltok::Metadata)
+ return TokError("Expected '!' here");
+ Lex.Lex();
+ MetadataBase *N = 0;
+ if (ParseMDNode(N)) return true;
+ Elts.push_back(N);
+ } while (EatIfPresent(lltok::comma));
+
+ if (ParseToken(lltok::rbrace, "expected end of metadata node"))
+ return true;
+
+ NamedMDNode::Create(Name.c_str(), Name.length(),
+ Elts.data(), Elts.size(), M);
+ return false;
+}
+
/// ParseStandaloneMetadata:
/// !42 = !{...}
bool LLParser::ParseStandaloneMetadata() {
OpenPOWER on IntegriCloud