Bitfield mask instructions are unpredictable if the encoded LSB is higher than the...
authorOwen Anderson <resistor@mac.com>
Fri, 16 Sep 2011 23:30:01 +0000 (23:30 +0000)
committerOwen Anderson <resistor@mac.com>
Fri, 16 Sep 2011 23:30:01 +0000 (23:30 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@139972 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/ARM/Disassembler/ARMDisassembler.cpp

index 4e9c3e58a5f3cbeb59bff60c783af782a2fb76af..d76fb93d156e4a7d1c699b48b3819e7c29312470 100644 (file)
@@ -1004,12 +1004,15 @@ static DecodeStatus DecodeBitfieldMaskOperand(llvm::MCInst &Inst, unsigned Val,
   unsigned msb = fieldFromInstruction32(Val, 5, 5);
   unsigned lsb = fieldFromInstruction32(Val, 0, 5);
 
+  DecodeStatus S = MCDisassembler::Success;
+  if (lsb > msb) Check(S, MCDisassembler::SoftFail);
+
   uint32_t msb_mask = 0xFFFFFFFF;
   if (msb != 31) msb_mask = (1U << (msb+1)) - 1;
   uint32_t lsb_mask = (1U << lsb) - 1;
 
   Inst.addOperand(MCOperand::CreateImm(~(msb_mask ^ lsb_mask)));
-  return MCDisassembler::Success;
+  return S;
 }
 
 static DecodeStatus DecodeCopMemInstruction(llvm::MCInst &Inst, unsigned Insn,