[llvm-commits] [llvm] r82063 - in /llvm/trunk/lib/AsmParser: LLLexer.cpp LLParser.cpp LLToken.h

Chris Lattner clattner at apple.com
Sun Sep 27 17:36:21 CDT 2009


On Sep 16, 2009, at 11:18 AM, Devang Patel wrote:
> URL: http://llvm.org/viewvc/llvm-project?rev=82063&view=rev
> Log:
> Parse debug info attached with an instruction.

Why is debug info a special case here?  Arbitrarily extensible  
metadata can't be extensible if you have to hack the parser :)

-Chris

>
> Modified:
>    llvm/trunk/lib/AsmParser/LLLexer.cpp
>    llvm/trunk/lib/AsmParser/LLParser.cpp
>    llvm/trunk/lib/AsmParser/LLToken.h
>
> Modified: llvm/trunk/lib/AsmParser/LLLexer.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/AsmParser/LLLexer.cpp?rev=82063&r1=82062&r2=82063&view=diff
>
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> ======================================================================
> --- llvm/trunk/lib/AsmParser/LLLexer.cpp (original)
> +++ llvm/trunk/lib/AsmParser/LLLexer.cpp Wed Sep 16 13:18:06 2009
> @@ -530,6 +530,7 @@
>   KEYWORD(asm);
>   KEYWORD(sideeffect);
>   KEYWORD(gc);
> +  KEYWORD(dbg);
>
>   KEYWORD(ccc);
>   KEYWORD(fastcc);
>
> Modified: llvm/trunk/lib/AsmParser/LLParser.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/AsmParser/LLParser.cpp?rev=82063&r1=82062&r2=82063&view=diff
>
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> ======================================================================
> --- llvm/trunk/lib/AsmParser/LLParser.cpp (original)
> +++ llvm/trunk/lib/AsmParser/LLParser.cpp Wed Sep 16 13:18:06 2009
> @@ -2624,6 +2624,23 @@
>
>     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.
>
> Modified: llvm/trunk/lib/AsmParser/LLToken.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/AsmParser/LLToken.h?rev=82063&r1=82062&r2=82063&view=diff
>
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> ======================================================================
> --- llvm/trunk/lib/AsmParser/LLToken.h (original)
> +++ llvm/trunk/lib/AsmParser/LLToken.h Wed Sep 16 13:18:06 2009
> @@ -63,6 +63,7 @@
>     kw_asm,
>     kw_sideeffect,
>     kw_gc,
> +    kw_dbg,
>     kw_c,
>
>     kw_cc, kw_ccc, kw_fastcc, kw_coldcc,
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits




More information about the llvm-commits mailing list