aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVictor Hernandez <vhernandez@apple.com>2009-12-03 23:40:58 +0000
committerVictor Hernandez <vhernandez@apple.com>2009-12-03 23:40:58 +0000
commit1971556cc271710b683bc3ca8327c903791c910f (patch)
tree835d4cbbe52ff5fb78192438d7322e3426aa0ce4
parent4dc4a61c0c47611fef23e06145ece9f63b2a8dc6 (diff)
Add ParseInlineMetadata() which can parses metadata that refers to an instruction. Extend ParseParameterList() to use this new function so that calls to llvm.dbg.declare can pass inline metadata
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@90497 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/AsmParser/LLParser.cpp53
-rw-r--r--lib/AsmParser/LLParser.h4
2 files changed, 49 insertions, 8 deletions
diff --git a/lib/AsmParser/LLParser.cpp b/lib/AsmParser/LLParser.cpp
index a92dbf82a0..193e8ddbc0 100644
--- a/lib/AsmParser/LLParser.cpp
+++ b/lib/AsmParser/LLParser.cpp
@@ -581,6 +581,37 @@ bool LLParser::ParseStandaloneMetadata() {
return false;
}
+/// ParseInlineMetadata:
+/// !{type %instr}
+/// !{...} MDNode
+/// !"foo" MDString
+bool LLParser::ParseInlineMetadata(Value *&V, PerFunctionState &PFS) {
+ assert(Lex.getKind() == lltok::Metadata && "Only for Metadata");
+ V = 0;
+
+ Lex.Lex();
+ if (Lex.getKind() == lltok::lbrace) {
+ Lex.Lex();
+ if (ParseTypeAndValue(V, PFS) ||
+ ParseToken(lltok::rbrace, "expected end of metadata node"))
+ return true;
+
+ Value *Vals[] = { V };
+ V = MDNode::get(Context, Vals, 1);
+ return false;
+ }
+
+ // Standalone metadata reference
+ // !{ ..., !42, ... }
+ if (!ParseMDNode((MetadataBase *&)V))
+ return false;
+
+ // MDString:
+ // '!' STRINGCONSTANT
+ if (ParseMDString((MetadataBase *&)V)) return true;
+ return false;
+}
+
/// ParseAlias:
/// ::= GlobalVar '=' OptionalVisibility 'alias' OptionalLinkage Aliasee
/// Aliasee
@@ -1377,15 +1408,23 @@ bool LLParser::ParseParameterList(SmallVectorImpl<ParamInfo> &ArgList,
// Parse the argument.
LocTy ArgLoc;
PATypeHolder ArgTy(Type::getVoidTy(Context));
- unsigned ArgAttrs1, ArgAttrs2;
+ unsigned ArgAttrs1 = Attribute::None;
+ unsigned ArgAttrs2 = Attribute::None;
Value *V;
- if (ParseType(ArgTy, ArgLoc) ||
- ParseOptionalAttrs(ArgAttrs1, 0) ||
- ParseValue(ArgTy, V, PFS) ||
- // FIXME: Should not allow attributes after the argument, remove this in
- // LLVM 3.0.
- ParseOptionalAttrs(ArgAttrs2, 3))
+ if (ParseType(ArgTy, ArgLoc))
return true;
+
+ if (Lex.getKind() == lltok::Metadata) {
+ if (ParseInlineMetadata(V, PFS))
+ return true;
+ } else {
+ if (ParseOptionalAttrs(ArgAttrs1, 0) ||
+ ParseValue(ArgTy, V, PFS) ||
+ // FIXME: Should not allow attributes after the argument, remove this
+ // in LLVM 3.0.
+ ParseOptionalAttrs(ArgAttrs2, 3))
+ return true;
+ }
ArgList.push_back(ParamInfo(ArgLoc, V, ArgAttrs1|ArgAttrs2));
}
diff --git a/lib/AsmParser/LLParser.h b/lib/AsmParser/LLParser.h
index 1112dc494c..d14b1cb362 100644
--- a/lib/AsmParser/LLParser.h
+++ b/lib/AsmParser/LLParser.h
@@ -279,7 +279,9 @@ namespace llvm {
LocTy Loc;
return ParseTypeAndBasicBlock(BB, Loc, PFS);
}
-
+
+ bool ParseInlineMetadata(Value *&V, PerFunctionState &PFS);
+
struct ParamInfo {
LocTy Loc;
Value *V;