[llvm] r318770 - [Asm] Improve "too few operands" errors
Oliver Stannard via llvm-commits
llvm-commits at lists.llvm.org
Tue Nov 21 07:16:50 PST 2017
Author: olista01
Date: Tue Nov 21 07:16:50 2017
New Revision: 318770
URL: http://llvm.org/viewvc/llvm-project?rev=318770&view=rev
Log:
[Asm] Improve "too few operands" errors
- We can still emit this error if the actual instruction has two or more
operands missing compared to the expected one.
- We should only emit this error once per instruction.
Differential revision: https://reviews.llvm.org/D36746
Modified:
llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp
llvm/trunk/test/MC/ARM/diagnostics.s
llvm/trunk/test/MC/ARM/ldrd-strd-gnu-bad-inst.s
llvm/trunk/test/MC/ARM/thumb-diagnostics.s
llvm/trunk/test/MC/ARM/thumb2-diagnostics.s
llvm/trunk/utils/TableGen/AsmMatcherEmitter.cpp
Modified: llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp?rev=318770&r1=318769&r2=318770&view=diff
==============================================================================
--- llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp (original)
+++ llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp Tue Nov 21 07:16:50 2017
@@ -10168,6 +10168,7 @@ ARMAsmParser::FilterNearMisses(SmallVect
// to only report the widest one.
std::multimap<unsigned, unsigned> OperandMissesSeen;
SmallSet<uint64_t, 4> FeatureMissesSeen;
+ bool ReportedTooFewOperands = false;
// Process the near-misses in reverse order, so that we see more general ones
// first, and so can avoid emitting more specific ones.
@@ -10288,9 +10289,12 @@ ARMAsmParser::FilterNearMisses(SmallVect
break;
}
case NearMissInfo::NearMissTooFewOperands: {
- SMLoc EndLoc = ((ARMOperand &)*Operands.back()).getEndLoc();
- NearMissesOut.emplace_back(
- NearMissMessage{ EndLoc, StringRef("too few operands for instruction") });
+ if (!ReportedTooFewOperands) {
+ SMLoc EndLoc = ((ARMOperand &)*Operands.back()).getEndLoc();
+ NearMissesOut.emplace_back(NearMissMessage{
+ EndLoc, StringRef("too few operands for instruction")});
+ ReportedTooFewOperands = true;
+ }
break;
}
case NearMissInfo::NoNearMiss:
Modified: llvm/trunk/test/MC/ARM/diagnostics.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/ARM/diagnostics.s?rev=318770&r1=318769&r2=318770&view=diff
==============================================================================
--- llvm/trunk/test/MC/ARM/diagnostics.s (original)
+++ llvm/trunk/test/MC/ARM/diagnostics.s Tue Nov 21 07:16:50 2017
@@ -736,3 +736,9 @@ foo2:
@ CHECK-ERRORS: error: immediate operand must an even number in the range [0, 30]
@ CHECK-ERRORS: error: immediate operand must a number in the range [0, 255]
@ CHECK-ERRORS: error: immediate operand must an even number in the range [0, 30]
+
+ @ Generic error for too few operands
+ adds
+ adds r0
+@ CHECK-ERRORS: error: too few operands for instruction
+@ CHECK-ERRORS: error: too few operands for instruction
Modified: llvm/trunk/test/MC/ARM/ldrd-strd-gnu-bad-inst.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/ARM/ldrd-strd-gnu-bad-inst.s?rev=318770&r1=318769&r2=318770&view=diff
==============================================================================
--- llvm/trunk/test/MC/ARM/ldrd-strd-gnu-bad-inst.s (original)
+++ llvm/trunk/test/MC/ARM/ldrd-strd-gnu-bad-inst.s Tue Nov 21 07:16:50 2017
@@ -2,26 +2,26 @@
.text
.thumb
-@ CHECK: error: invalid instruction
+@ CHECK: error: too few operands for instruction
strd
-@ CHECK: error: invalid instruction
+@ CHECK: error: too few operands for instruction
ldrd
-@ CHECK: error: invalid instruction
+@ CHECK: error: too few operands for instruction
strd r0
-@ CHECK: error: invalid instruction
+@ CHECK: error: too few operands for instruction
ldrd r0
@ CHECK: error: invalid instruction
strd s0, [r0]
@ CHECK: error: invalid instruction
ldrd s0, [r0]
.arm
-@ CHECK: error: invalid instruction
+@ CHECK: error: too few operands for instruction
strd
-@ CHECK: error: invalid instruction
+@ CHECK: error: too few operands for instruction
ldrd
-@ CHECK: error: invalid instruction
+@ CHECK: error: too few operands for instruction
strd r0
-@ CHECK: error: invalid instruction
+@ CHECK: error: too few operands for instruction
ldrd r0
@ CHECK: error: invalid instruction
strd s0, [r0]
Modified: llvm/trunk/test/MC/ARM/thumb-diagnostics.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/ARM/thumb-diagnostics.s?rev=318770&r1=318769&r2=318770&view=diff
==============================================================================
--- llvm/trunk/test/MC/ARM/thumb-diagnostics.s (original)
+++ llvm/trunk/test/MC/ARM/thumb-diagnostics.s Tue Nov 21 07:16:50 2017
@@ -351,3 +351,12 @@
@ CHECK-ERRORS: error: invalid instruction
@ CHECK-ERRORS: error: invalid instruction
@ CHECK-ERRORS: error: invalid instruction
+
+ at ------------------------------------------------------------------------------
+@ Generic error for too few operands
+ at ------------------------------------------------------------------------------
+
+ adds
+ adds r0
+@ CHECK-ERRORS: error: too few operands for instruction
+@ CHECK-ERRORS: error: too few operands for instruction
Modified: llvm/trunk/test/MC/ARM/thumb2-diagnostics.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/ARM/thumb2-diagnostics.s?rev=318770&r1=318769&r2=318770&view=diff
==============================================================================
--- llvm/trunk/test/MC/ARM/thumb2-diagnostics.s (original)
+++ llvm/trunk/test/MC/ARM/thumb2-diagnostics.s Tue Nov 21 07:16:50 2017
@@ -145,3 +145,9 @@ foo2:
@ CHECK-ERRORS-V7: error: instruction requires: arm-mode
@ CHECK-ERRORS-V8: error: invalid instruction
@ CHECK-ERRORS-V8: error: invalid instruction
+
+ @ Generic error for too few operands
+ adds
+ adds r0
+@ CHECK-ERRORS: error: too few operands for instruction
+@ CHECK-ERRORS: error: too few operands for instruction
Modified: llvm/trunk/utils/TableGen/AsmMatcherEmitter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/AsmMatcherEmitter.cpp?rev=318770&r1=318769&r2=318770&view=diff
==============================================================================
--- llvm/trunk/utils/TableGen/AsmMatcherEmitter.cpp (original)
+++ llvm/trunk/utils/TableGen/AsmMatcherEmitter.cpp Tue Nov 21 07:16:50 2017
@@ -3313,7 +3313,7 @@ void AsmMatcherEmitter::run(raw_ostream
OS << " DEBUG_WITH_TYPE(\"asm-matcher\", dbgs() << \"recording too-few-operands near miss\\n\");\n";
OS << " OperandNearMiss =\n";
OS << " NearMissInfo::getTooFewOperands(Formal, it->Opcode);\n";
- OS << " } else {\n";
+ OS << " } else if (OperandNearMiss.getKind() != NearMissInfo::NearMissTooFewOperands) {\n";
OS << " // If more than one operand is invalid, give up on this match entry.\n";
OS << " DEBUG_WITH_TYPE(\n";
OS << " \"asm-matcher\",\n";
More information about the llvm-commits
mailing list