[PATCH] AsmParser: add support for .end directive

Saleem Abdulrasool compnerd at compnerd.org
Mon Dec 16 18:11:30 PST 2013


On Mon, Dec 16, 2013 at 10:24 AM, David Peixotto <dpeixott at codeaurora.org>wrote:

> 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.
>
>
Yes, the behaviour would be that.  The includes are handled by the
preprocessor, and the lexer would consume the rest of the tokens, behaving
as gas does.  I suppose I can add additional tests.


> -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
> > +
>
>


-- 
Saleem Abdulrasool
compnerd (at) compnerd (dot) org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20131216/67baf31f/attachment.html>


More information about the llvm-commits mailing list