summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Target/Hexagon/AsmParser/HexagonAsmParser.cpp
diff options
context:
space:
mode:
authorNirav Dave <niravd@google.com>2016-09-16 18:30:20 +0000
committerNirav Dave <niravd@google.com>2016-09-16 18:30:20 +0000
commit2364748a49ec7d4dbec42bfa669f31305007e9e9 (patch)
tree9919e6d827d1b9d814b0f0ad97af11c85c7f7f38 /llvm/lib/Target/Hexagon/AsmParser/HexagonAsmParser.cpp
parente0e0ed13f44b350b20c62d91e154540c5fd07648 (diff)
downloadbcm5719-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/Hexagon/AsmParser/HexagonAsmParser.cpp')
-rw-r--r--llvm/lib/Target/Hexagon/AsmParser/HexagonAsmParser.cpp54
1 files changed, 29 insertions, 25 deletions
diff --git a/llvm/lib/Target/Hexagon/AsmParser/HexagonAsmParser.cpp b/llvm/lib/Target/Hexagon/AsmParser/HexagonAsmParser.cpp
index ba4dfab4629..9ce858f29c5 100644
--- a/llvm/lib/Target/Hexagon/AsmParser/HexagonAsmParser.cpp
+++ b/llvm/lib/Target/Hexagon/AsmParser/HexagonAsmParser.cpp
@@ -114,7 +114,7 @@ class HexagonAsmParser : public MCTargetAsmParser {
uint64_t &ErrorInfo, bool MatchingInlineAsm) override;
unsigned validateTargetOperandClass(MCParsedAsmOperand &Op, unsigned Kind) override;
- void OutOfRange(SMLoc IDLoc, long long Val, long long Max);
+ bool OutOfRange(SMLoc IDLoc, long long Val, long long Max);
int processInstruction(MCInst &Inst, OperandVector const &Operands,
SMLoc IDLoc);
@@ -637,60 +637,63 @@ bool HexagonAsmParser::finishBundle(SMLoc IDLoc, MCStreamer &Out) {
uint64_t Err = Check.getError();
if (Err != HexagonMCErrInfo::CHECK_SUCCESS) {
if (HexagonMCErrInfo::CHECK_ERROR_BRANCHES & Err)
- Error(IDLoc,
- "unconditional branch cannot precede another branch in packet");
+ return Error(
+ IDLoc,
+ "unconditional branch cannot precede another branch in packet");
if (HexagonMCErrInfo::CHECK_ERROR_NEWP & Err ||
HexagonMCErrInfo::CHECK_ERROR_NEWV & Err)
- Error(IDLoc, "register `" + R +
- "' used with `.new' "
- "but not validly modified in the same packet");
+ return Error(IDLoc, "register `" + R +
+ "' used with `.new' "
+ "but not validly modified in the same packet");
if (HexagonMCErrInfo::CHECK_ERROR_REGISTERS & Err)
- Error(IDLoc, "register `" + R + "' modified more than once");
+ return Error(IDLoc, "register `" + R + "' modified more than once");
if (HexagonMCErrInfo::CHECK_ERROR_READONLY & Err)
- Error(IDLoc, "cannot write to read-only register `" + R + "'");
+ return Error(IDLoc, "cannot write to read-only register `" + R + "'");
if (HexagonMCErrInfo::CHECK_ERROR_LOOP & Err)
- Error(IDLoc, "loop-setup and some branch instructions "
- "cannot be in the same packet");
+ return Error(IDLoc, "loop-setup and some branch instructions "
+ "cannot be in the same packet");
if (HexagonMCErrInfo::CHECK_ERROR_ENDLOOP & Err) {
Twine N(HexagonMCInstrInfo::isInnerLoop(MCB) ? '0' : '1');
- Error(IDLoc, "packet marked with `:endloop" + N + "' " +
+ return Error(IDLoc,
+ "packet marked with `:endloop" + N + "' " +
"cannot contain instructions that modify register " +
"`" + R + "'");
}
if (HexagonMCErrInfo::CHECK_ERROR_SOLO & Err)
- Error(IDLoc,
- "instruction cannot appear in packet with other instructions");
+ return Error(
+ IDLoc,
+ "instruction cannot appear in packet with other instructions");
if (HexagonMCErrInfo::CHECK_ERROR_NOSLOTS & Err)
- Error(IDLoc, "too many slots used in packet");
+ return Error(IDLoc, "too many slots used in packet");
if (Err & HexagonMCErrInfo::CHECK_ERROR_SHUFFLE) {
uint64_t Erm = Check.getShuffleError();
if (HexagonShuffler::SHUFFLE_ERROR_INVALID == Erm)
- Error(IDLoc, "invalid instruction packet");
+ return Error(IDLoc, "invalid instruction packet");
else if (HexagonShuffler::SHUFFLE_ERROR_STORES == Erm)
- Error(IDLoc, "invalid instruction packet: too many stores");
+ return Error(IDLoc, "invalid instruction packet: too many stores");
else if (HexagonShuffler::SHUFFLE_ERROR_LOADS == Erm)
- Error(IDLoc, "invalid instruction packet: too many loads");
+ return Error(IDLoc, "invalid instruction packet: too many loads");
else if (HexagonShuffler::SHUFFLE_ERROR_BRANCHES == Erm)
- Error(IDLoc, "too many branches in packet");
+ return Error(IDLoc, "too many branches in packet");
else if (HexagonShuffler::SHUFFLE_ERROR_NOSLOTS == Erm)
- Error(IDLoc, "invalid instruction packet: out of slots");
+ return Error(IDLoc, "invalid instruction packet: out of slots");
else if (HexagonShuffler::SHUFFLE_ERROR_SLOTS == Erm)
- Error(IDLoc, "invalid instruction packet: slot error");
+ return Error(IDLoc, "invalid instruction packet: slot error");
else if (HexagonShuffler::SHUFFLE_ERROR_ERRATA2 == Erm)
- Error(IDLoc, "v60 packet violation");
+ return Error(IDLoc, "v60 packet violation");
else if (HexagonShuffler::SHUFFLE_ERROR_STORE_LOAD_CONFLICT == Erm)
- Error(IDLoc, "slot 0 instruction does not allow slot 1 store");
+ return Error(IDLoc, "slot 0 instruction does not allow slot 1 store");
else
- Error(IDLoc, "unknown error in instruction packet");
+ return Error(IDLoc, "unknown error in instruction packet");
}
}
@@ -1508,7 +1511,8 @@ unsigned HexagonAsmParser::validateTargetOperandClass(MCParsedAsmOperand &AsmOp,
return Match_InvalidOperand;
}
-void HexagonAsmParser::OutOfRange(SMLoc IDLoc, long long Val, long long Max) {
+// FIXME: Calls to OutOfRange shoudl propagate failure up to parseStatement.
+bool HexagonAsmParser::OutOfRange(SMLoc IDLoc, long long Val, long long Max) {
std::string errStr;
raw_string_ostream ES(errStr);
ES << "value " << Val << "(" << format_hex(Val, 0) << ") out of range: ";
@@ -1516,7 +1520,7 @@ void HexagonAsmParser::OutOfRange(SMLoc IDLoc, long long Val, long long Max) {
ES << "0-" << Max;
else
ES << Max << "-" << (-Max - 1);
- Error(IDLoc, ES.str().c_str());
+ return Parser.printError(IDLoc, ES.str().c_str());
}
int HexagonAsmParser::processInstruction(MCInst &Inst,
OpenPOWER on IntegriCloud