Parse debug info attached with an instruction.
authorDevang Patel <dpatel@apple.com>
Wed, 16 Sep 2009 18:18:06 +0000 (18:18 +0000)
committerDevang Patel <dpatel@apple.com>
Wed, 16 Sep 2009 18:18:06 +0000 (18:18 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@82063 91177308-0d34-0410-b5e6-96231b3b80d8

lib/AsmParser/LLLexer.cpp
lib/AsmParser/LLParser.cpp
lib/AsmParser/LLToken.h

index 23d7f19bbce725d89692b50595f253743bfcb267..315048c748a8edd8f8c22bc0cbe6614f04f37c84 100644 (file)
@@ -530,6 +530,7 @@ lltok::Kind LLLexer::LexIdentifier() {
   KEYWORD(asm);
   KEYWORD(sideeffect);
   KEYWORD(gc);
+  KEYWORD(dbg);
 
   KEYWORD(ccc);
   KEYWORD(fastcc);
index b7b95d7ecf059a39b63f5030f27ed7b70e0b6bf4..3c125a01b19d6bf028a5630d281e021088dbdfcf 100644 (file)
@@ -2624,6 +2624,23 @@ bool LLParser::ParseBasicBlock(PerFunctionState &PFS) {
     
     if (ParseInstruction(Inst, BB, PFS)) return true;
     
+    // Parse optional debug info
+    if (Lex.getKind() == lltok::comma) {
+      Lex.Lex();
+      if (Lex.getKind() == lltok::kw_dbg) {
+       Lex.Lex();
+       if (Lex.getKind() != lltok::Metadata)
+         return TokError("Expected '!' here");
+       Lex.Lex();
+       MetadataBase *N = 0;
+       if (ParseMDNode(N)) return true;
+       Metadata &TheMetadata = M->getContext().getMetadata();
+       unsigned MDDbgKind = TheMetadata.getMDKind("dbg");
+       if (!MDDbgKind)
+         MDDbgKind = TheMetadata.RegisterMDKind("dbg");
+       TheMetadata.setMD(MDDbgKind, cast<MDNode>(N), Inst);
+      }
+    }
     BB->getInstList().push_back(Inst);
 
     // Set the name on the instruction.
index b053cca18a710e1693501ff8732f0b697629b844..dd6359a630b4c32ef481c7f32be517c2ea228fd4 100644 (file)
@@ -63,6 +63,7 @@ namespace lltok {
     kw_asm,
     kw_sideeffect,
     kw_gc,
+    kw_dbg,
     kw_c,
 
     kw_cc, kw_ccc, kw_fastcc, kw_coldcc,