Skip to content
This repository was archived by the owner on Mar 28, 2020. It is now read-only.

Commit 91bc1bb

Browse files
committed
[ARM] Better error message for invalid flag-preserving Thumb1 insts
When we see a non flag-setting instruction for which only the flag-setting version is available in Thumb1, we should give a better error message than "invalid instruction". Differential Revision: https://reviews.llvm.org/D27414 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@288805 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent c700b40 commit 91bc1bb

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

lib/Target/ARM/AsmParser/ARMAsmParser.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -523,6 +523,7 @@ class ARMAsmParser : public MCTargetAsmParser {
523523
Match_RequiresV6,
524524
Match_RequiresThumb2,
525525
Match_RequiresV8,
526+
Match_RequiresFlagSetting,
526527
#define GET_OPERAND_DIAGNOSTIC_TYPES
527528
#include "ARMGenAsmMatcher.inc"
528529

@@ -8905,7 +8906,7 @@ unsigned ARMAsmParser::checkTargetMatchPredicate(MCInst &Inst) {
89058906
;
89068907
// If we're parsing Thumb1, reject it completely.
89078908
if (isThumbOne() && Inst.getOperand(OpNo).getReg() != ARM::CPSR)
8908-
return Match_MnemonicFail;
8909+
return Match_RequiresFlagSetting;
89098910
// If we're parsing Thumb2, which form is legal depends on whether we're
89108911
// in an IT block.
89118912
if (isThumbTwo() && Inst.getOperand(OpNo).getReg() != ARM::CPSR &&
@@ -9171,6 +9172,8 @@ bool ARMAsmParser::MatchAndEmitInstruction(SMLoc IDLoc, unsigned &Opcode,
91719172
return Error(IDLoc, "instruction variant requires Thumb2");
91729173
case Match_RequiresV8:
91739174
return Error(IDLoc, "instruction variant requires ARMv8 or later");
9175+
case Match_RequiresFlagSetting:
9176+
return Error(IDLoc, "no flag-preserving variant of this instruction available");
91749177
case Match_ImmRange0_15: {
91759178
SMLoc ErrorLoc = ((ARMOperand &)*Operands[ErrorInfo]).getStartLoc();
91769179
if (ErrorLoc == SMLoc()) ErrorLoc = IDLoc;

test/MC/ARM/thumb-diagnostics.s

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
@ ADD instruction w/o 'S' suffix.
1313
add r1, r2, r3
14-
@ CHECK-ERRORS: error: invalid instruction
14+
@ CHECK-ERRORS: error: no flag-preserving variant of this instruction available
1515
@ CHECK-ERRORS: add r1, r2, r3
1616
@ CHECK-ERRORS: ^
1717

0 commit comments

Comments
 (0)