}
break;
+ case ARM::t2ADDri:
+ case ARM::t2ADDri12:
+ case ARM::t2ADDrr:
+ case ARM::t2ADDrs:
+ case ARM::t2SUBri:
+ case ARM::t2SUBri12:
+ case ARM::t2SUBrr:
+ case ARM::t2SUBrs:
+ if (Inst.getOperand(0).getReg() == ARM::SP &&
+ Inst.getOperand(1).getReg() != ARM::SP)
+ return Error(Operands[4]->getStartLoc(),
+ "source register must be sp if destination is sp");
+ break;
+
// Final range checking for Thumb unconditional branch instructions.
case ARM::tB:
if (!(static_cast<ARMOperand &>(*Operands[2])).isSignedOffset<11, 1>())
return MCDisassembler::SoftFail;
return Result;
}
+ case ARM::t2ADDri:
+ case ARM::t2ADDri12:
+ case ARM::t2ADDrr:
+ case ARM::t2ADDrs:
+ case ARM::t2SUBri:
+ case ARM::t2SUBri12:
+ case ARM::t2SUBrr:
+ case ARM::t2SUBrs:
+ if (MI.getOperand(0).getReg() == ARM::SP &&
+ MI.getOperand(1).getReg() != ARM::SP)
+ return MCDisassembler::SoftFail;
+ return Result;
default: return Result;
}
}
if (Result != MCDisassembler::Fail) {
Size = 4;
Check(Result, AddThumbPredicate(MI));
- return Result;
+ return checkDecodedInstruction(MI, Size, Address, OS, CS, Insn32, Result);
}
if (fieldFromInstruction(Insn32, 28, 4) == 0xE) {
--- /dev/null
+@ RUN: not llvm-mc -triple thumbv7-apple-ios %s -o - 2>&1 | FileCheck %s
+
+@ CHECK: error: source register must be sp if destination is sp
+@ CHECK: error: source register must be sp if destination is sp
+@ CHECK: error: source register must be sp if destination is sp
+@ CHECK: error: source register must be sp if destination is sp
+add sp, r5, #1
+addw sp, r7, #4
+add sp, r3, r2
+add sp, r3, r5, lsl #3
+
+
+@ CHECK: error: source register must be sp if destination is sp
+@ CHECK: error: source register must be sp if destination is sp
+@ CHECK: error: source register must be sp if destination is sp
+@ CHECK: error: source register must be sp if destination is sp
+sub sp, r5, #1
+subw sp, r7, #4
+sub sp, r3, r2
+sub sp, r3, r5, lsl #3
[0xff,0xf3,0x30,0x80]
# CHECK: invalid instruction encoding
# CHECK-NEXT: [0xff,0xf3,0x30,0x80]
+
+#------------------------------------------------------------------------------
+# If dest is sp then source must be in T2 add/sub
+#------------------------------------------------------------------------------
+
+[0x05,0xf1,0x01,0x0d]
+[0x07,0xf2,0x04,0x0d]
+[0x03,0xeb,0x02,0x0d]
+[0x03,0xeb,0xc5,0x0d]
+# CHECK-V7: warning: potentially undefined instruction encoding
+# CHECK-V7-NEXT: [0x05,0xf1,0x01,0x0d]
+# CHECK-V7: warning: potentially undefined instruction encoding
+# CHECK-V7-NEXT: [0x07,0xf2,0x04,0x0d]
+# CHECK-V7: warning: potentially undefined instruction encoding
+# CHECK-V7-NEXT: [0x03,0xeb,0x02,0x0d]
+# CHECK-V7: warning: potentially undefined instruction encoding
+# CHECK-V7-NEXT: [0x03,0xeb,0xc5,0x0d]
+
+
+[0xa5,0xf1,0x01,0x0d]
+[0xa7,0xf2,0x04,0x0d]
+[0xa3,0xeb,0x02,0x0d]
+[0xa3,0xeb,0xc5,0x0d]
+# CHECK-V7: warning: potentially undefined instruction encoding
+# CHECK-V7-NEXT: [0xa5,0xf1,0x01,0x0d]
+# CHECK-V7: warning: potentially undefined instruction encoding
+# CHECK-V7-NEXT: [0xa7,0xf2,0x04,0x0d]
+# CHECK-V7: warning: potentially undefined instruction encoding
+# CHECK-V7-NEXT: [0xa3,0xeb,0x02,0x0d]
+# CHECK-V7: warning: potentially undefined instruction encoding
+# CHECK-V7-NEXT: [0xa3,0xeb,0xc5,0x0d]