[PATCH] AsmParser: add support for .end directive
David Peixotto
dpeixott at codeaurora.org
Mon Dec 16 10:24:51 PST 2013
Hi Saleem,
Thank you for implementing support for this directive. I think it is nice to have for completness with gas.
My main question is how does this directive interact with .include'd files. If we have .end in a file that is being processed because of a .include will it stop processing everything, or only that file. I think gas will stop processing everything, even the original file.
Please add a test case that shows the behavior to expect when processing a .end directive in a .include file. I think it is ok to follow what gas does here.
-David
> -----Original Message-----
> From: llvm-commits-bounces at cs.uiuc.edu [mailto:llvm-commits-
> bounces at cs.uiuc.edu] On Behalf Of Saleem Abdulrasool
> Sent: Sunday, December 15, 2013 7:28 PM
> To: compnerd at compnerd.org
> Cc: llvm-commits at cs.uiuc.edu
> Subject: Re: [PATCH] AsmParser: add support for .end directive
>
> Fix for target specific handling of end directive (e.g. MIPS).
>
> http://llvm-reviews.chandlerc.com/D2414
>
> CHANGE SINCE LAST DIFF
> http://llvm-reviews.chandlerc.com/D2414?vs=6109&id=6112#toc
>
> Files:
> lib/MC/MCParser/AsmParser.cpp
> test/MC/AsmParser/directive_end.s
>
> Index: lib/MC/MCParser/AsmParser.cpp
> ===================================================================
> --- lib/MC/MCParser/AsmParser.cpp
> +++ lib/MC/MCParser/AsmParser.cpp
> @@ -358,7 +358,8 @@
> DK_CFI_RESTORE, DK_CFI_ESCAPE, DK_CFI_SIGNAL_FRAME, DK_CFI_UNDEFINED,
> DK_CFI_REGISTER, DK_CFI_WINDOW_SAVE,
> DK_MACROS_ON, DK_MACROS_OFF, DK_MACRO, DK_ENDM, DK_ENDMACRO,
> DK_PURGEM,
> - DK_SLEB128, DK_ULEB128
> + DK_SLEB128, DK_ULEB128,
> + DK_END
> };
>
> /// \brief Maps directive name --> DirectiveKind enum, for @@ -464,6
> +465,9 @@
> // "align"
> bool parseDirectiveMSAlign(SMLoc DirectiveLoc, ParseStatementInfo
> &Info);
>
> + // "end"
> + bool parseDirectiveEnd(SMLoc DirectiveLoc);
> +
> void initializeDirectiveKindMap();
> };
> }
> @@ -1516,6 +1520,8 @@
> return parseDirectiveEndMacro(IDVal);
> case DK_PURGEM:
> return parseDirectivePurgeMacro(IDLoc);
> + case DK_END:
> + return parseDirectiveEnd(IDLoc);
> }
>
> return Error(IDLoc, "unknown directive"); @@ -3751,6 +3757,20 @@
> return false;
> }
>
> +/// parseDirectiveEnd
> +/// ::= .end
> +bool AsmParser::parseDirectiveEnd(SMLoc DirectiveLoc) {
> + if (getLexer().isNot(AsmToken::EndOfStatement))
> + return TokError("unexpected token in '.end' directive");
> +
> + Lex();
> +
> + while (Lexer.isNot(AsmToken::Eof))
> + Lex();
> +
> + return false;
> +}
> +
> /// parseDirectiveEndIf
> /// ::= .endif
> bool AsmParser::parseDirectiveEndIf(SMLoc DirectiveLoc) { @@ -3836,6
> +3856,7 @@
> DirectiveKindMap[".ifnotdef"] = DK_IFNOTDEF;
> DirectiveKindMap[".elseif"] = DK_ELSEIF;
> DirectiveKindMap[".else"] = DK_ELSE;
> + DirectiveKindMap[".end"] = DK_END;
> DirectiveKindMap[".endif"] = DK_ENDIF;
> DirectiveKindMap[".skip"] = DK_SKIP;
> DirectiveKindMap[".space"] = DK_SPACE;
> Index: test/MC/AsmParser/directive_end.s
> ===================================================================
> --- /dev/null
> +++ test/MC/AsmParser/directive_end.s
> @@ -0,0 +1,11 @@
> +# RUN: llvm-mc -triple i386-unknown-unknown %s -filetype obj -o - \
> +# RUN: | llvm-readobj -t | FileCheck %s
> +
> + .end
> +
> +its_a_tarp:
> + int $0x3
> +
> +# CHECK: Symbol {
> +# CHECK-NOT: Name: its_a_tarp
> +
More information about the llvm-commits
mailing list