diff options
| author | Simon Atanasyan <simon@atanasyan.com> | 2018-07-25 07:07:43 +0000 | 
|---|---|---|
| committer | Simon Atanasyan <simon@atanasyan.com> | 2018-07-25 07:07:43 +0000 | 
| commit | b5244592882f296097bcd5508630b73311d0ddde (patch) | |
| tree | a5a4a22d0466ba76dcc8202f37313c80cd97e8ab /llvm/lib/Target/Mips/AsmParser | |
| parent | 4eab1ba6196b9d5dd8b5980d076e52b0672cb3bd (diff) | |
| download | bcm5719-llvm-b5244592882f296097bcd5508630b73311d0ddde.tar.gz bcm5719-llvm-b5244592882f296097bcd5508630b73311d0ddde.zip  | |
[mips] Replace custom parsing logic for data directives by the `addAliasForDirective`
The target independent AsmParser doesn't recognise .hword, .word, .dword
which are required for Mips. Currently MipsAsmParser recognises these
through dispatch to MipsAsmParser::parseDataDirective. This contains
equivalent logic to AsmParser::parseDirectiveValue. This patch allows
reuse of AsmParser::parseDirectiveValue by making use of
addAliasForDirective to support .hword, .word and .dword.
Original patch provided by Alex Bradbury at D47001 was modified to fix
handling of microMIPS symbols. The `AsmParser::parseDirectiveValue`
calls either `EmitIntValue` or `EmitValue`. In this patch we override
`EmitIntValue` in the `MipsELFStreamer` to clear a pending set of
microMIPS symbols.
Differential revision: https://reviews.llvm.org/D49539
llvm-svn: 337893
Diffstat (limited to 'llvm/lib/Target/Mips/AsmParser')
| -rw-r--r-- | llvm/lib/Target/Mips/AsmParser/MipsAsmParser.cpp | 43 | 
1 files changed, 3 insertions, 40 deletions
diff --git a/llvm/lib/Target/Mips/AsmParser/MipsAsmParser.cpp b/llvm/lib/Target/Mips/AsmParser/MipsAsmParser.cpp index 5ee7d0ac4e2..2acf701b43c 100644 --- a/llvm/lib/Target/Mips/AsmParser/MipsAsmParser.cpp +++ b/llvm/lib/Target/Mips/AsmParser/MipsAsmParser.cpp @@ -355,7 +355,6 @@ class MipsAsmParser : public MCTargetAsmParser {    bool parseSetAssignment(); -  bool parseDataDirective(unsigned Size, SMLoc L);    bool parseDirectiveGpWord();    bool parseDirectiveGpDWord();    bool parseDirectiveDtpRelWord(); @@ -487,6 +486,9 @@ public:      MCAsmParserExtension::Initialize(parser);      parser.addAliasForDirective(".asciiz", ".asciz"); +    parser.addAliasForDirective(".hword", ".2byte"); +    parser.addAliasForDirective(".word", ".4byte"); +    parser.addAliasForDirective(".dword", ".8byte");      // Initialize the set of available features.      setAvailableFeatures(ComputeAvailableFeatures(getSTI().getFeatureBits())); @@ -7357,31 +7359,6 @@ bool MipsAsmParser::parseDirectiveSet() {    return parseSetAssignment();  } -/// parseDataDirective -///  ::= .word [ expression (, expression)* ] -bool MipsAsmParser::parseDataDirective(unsigned Size, SMLoc L) { -  MCAsmParser &Parser = getParser(); -  if (getLexer().isNot(AsmToken::EndOfStatement)) { -    while (true) { -      const MCExpr *Value; -      if (getParser().parseExpression(Value)) -        return true; - -      getParser().getStreamer().EmitValue(Value, Size); - -      if (getLexer().is(AsmToken::EndOfStatement)) -        break; - -      if (getLexer().isNot(AsmToken::Comma)) -        return Error(L, "unexpected token, expected comma"); -      Parser.Lex(); -    } -  } - -  Parser.Lex(); -  return false; -} -  /// parseDirectiveGpWord  ///  ::= .gpword local_sym  bool MipsAsmParser::parseDirectiveGpWord() { @@ -7961,10 +7938,6 @@ bool MipsAsmParser::ParseDirective(AsmToken DirectiveID) {      parseDirectiveCpRestore(DirectiveID.getLoc());      return false;    } -  if (IDVal == ".dword") { -    parseDataDirective(8, DirectiveID.getLoc()); -    return false; -  }    if (IDVal == ".ent") {      StringRef SymbolName; @@ -8212,16 +8185,6 @@ bool MipsAsmParser::ParseDirective(AsmToken DirectiveID) {      return false;    } -  if (IDVal == ".word") { -    parseDataDirective(4, DirectiveID.getLoc()); -    return false; -  } - -  if (IDVal == ".hword") { -    parseDataDirective(2, DirectiveID.getLoc()); -    return false; -  } -    if (IDVal == ".option") {      parseDirectiveOption();      return false;  | 

