diff options
author | Nirav Dave <niravd@google.com> | 2016-09-16 18:30:20 +0000 |
---|---|---|
committer | Nirav Dave <niravd@google.com> | 2016-09-16 18:30:20 +0000 |
commit | 2364748a49ec7d4dbec42bfa669f31305007e9e9 (patch) | |
tree | 9919e6d827d1b9d814b0f0ad97af11c85c7f7f38 /llvm/lib/Target/Sparc/AsmParser/SparcAsmParser.cpp | |
parent | e0e0ed13f44b350b20c62d91e154540c5fd07648 (diff) | |
download | bcm5719-llvm-2364748a49ec7d4dbec42bfa669f31305007e9e9.tar.gz bcm5719-llvm-2364748a49ec7d4dbec42bfa669f31305007e9e9.zip |
Defer asm errors to post-statement failure
Recommitting after fixing AsmParser initialization and X86 inline asm
error cleanup.
Allow errors to be deferred and emitted as part of clean up to simplify
and shorten Assembly parser code. This will allow error messages to be
emitted in helper functions and be modified by the caller which has
better context.
As part of this many minor cleanups to the Parser:
* Unify parser cleanup on error
* Add Workaround for incorrect return values in ParseDirective instances
* Tighten checks on error-signifying return values for parser functions
and fix in-tree TargetParsers to be more consistent with the changes.
* Fix AArch64 test cases checking for spurious error messages that are
now fixed.
These changes should be backwards compatible with current Target Parsers
so long as the error status are correctly returned in appropriate
functions.
Reviewers: rnk, majnemer
Subscribers: aemerson, jyknight, llvm-commits
Differential Revision: https://reviews.llvm.org/D24047
llvm-svn: 281762
Diffstat (limited to 'llvm/lib/Target/Sparc/AsmParser/SparcAsmParser.cpp')
-rw-r--r-- | llvm/lib/Target/Sparc/AsmParser/SparcAsmParser.cpp | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/llvm/lib/Target/Sparc/AsmParser/SparcAsmParser.cpp b/llvm/lib/Target/Sparc/AsmParser/SparcAsmParser.cpp index b2003b8f101..288f3c10ce9 100644 --- a/llvm/lib/Target/Sparc/AsmParser/SparcAsmParser.cpp +++ b/llvm/lib/Target/Sparc/AsmParser/SparcAsmParser.cpp @@ -84,7 +84,7 @@ class SparcAsmParser : public MCTargetAsmParser { return getSTI().getTargetTriple().getArch() == Triple::sparcv9; } - void expandSET(MCInst &Inst, SMLoc IDLoc, + bool expandSET(MCInst &Inst, SMLoc IDLoc, SmallVectorImpl<MCInst> &Instructions); public: @@ -466,7 +466,7 @@ public: } // end namespace -void SparcAsmParser::expandSET(MCInst &Inst, SMLoc IDLoc, +bool SparcAsmParser::expandSET(MCInst &Inst, SMLoc IDLoc, SmallVectorImpl<MCInst> &Instructions) { MCOperand MCRegOp = Inst.getOperand(0); MCOperand MCValOp = Inst.getOperand(1); @@ -479,8 +479,8 @@ void SparcAsmParser::expandSET(MCInst &Inst, SMLoc IDLoc, // Allow either a signed or unsigned 32-bit immediate. if (RawImmValue < -2147483648LL || RawImmValue > 4294967295LL) { - Error(IDLoc, "set: argument must be between -2147483648 and 4294967295"); - return; + return Error(IDLoc, + "set: argument must be between -2147483648 and 4294967295"); } // If the value was expressed as a large unsigned number, that's ok. @@ -537,6 +537,7 @@ void SparcAsmParser::expandSET(MCInst &Inst, SMLoc IDLoc, TmpInst.addOperand(MCOperand::createExpr(Expr)); Instructions.push_back(TmpInst); } + return false; } bool SparcAsmParser::MatchAndEmitInstruction(SMLoc IDLoc, unsigned &Opcode, @@ -556,7 +557,8 @@ bool SparcAsmParser::MatchAndEmitInstruction(SMLoc IDLoc, unsigned &Opcode, Instructions.push_back(Inst); break; case SP::SET: - expandSET(Inst, IDLoc, Instructions); + if (expandSET(Inst, IDLoc, Instructions)) + return true; break; } @@ -626,13 +628,11 @@ bool SparcAsmParser::ParseInstruction(ParseInstructionInfo &Info, if (getLexer().is(AsmToken::Comma)) { if (parseBranchModifiers(Operands) != MatchOperand_Success) { SMLoc Loc = getLexer().getLoc(); - Parser.eatToEndOfStatement(); return Error(Loc, "unexpected token"); } } if (parseOperand(Operands, Name) != MatchOperand_Success) { SMLoc Loc = getLexer().getLoc(); - Parser.eatToEndOfStatement(); return Error(Loc, "unexpected token"); } @@ -645,14 +645,12 @@ bool SparcAsmParser::ParseInstruction(ParseInstructionInfo &Info, // Parse and remember the operand. if (parseOperand(Operands, Name) != MatchOperand_Success) { SMLoc Loc = getLexer().getLoc(); - Parser.eatToEndOfStatement(); return Error(Loc, "unexpected token"); } } } if (getLexer().isNot(AsmToken::EndOfStatement)) { SMLoc Loc = getLexer().getLoc(); - Parser.eatToEndOfStatement(); return Error(Loc, "unexpected token"); } Parser.Lex(); // Consume the EndOfStatement. |