diff options
author | Johnny Chen <johnny.chen@apple.com> | 2011-04-12 23:31:00 +0000 |
---|---|---|
committer | Johnny Chen <johnny.chen@apple.com> | 2011-04-12 23:31:00 +0000 |
commit | 3c2f74c9f30013ae5885f3e0a80798cf5ea6d253 (patch) | |
tree | a7b085501139839dd39d7c23d5e6df24ebb5e5d6 /llvm/lib | |
parent | 9c8cd4c0978d59f53f6f3e42e478e6aa2985e346 (diff) | |
download | bcm5719-llvm-3c2f74c9f30013ae5885f3e0a80798cf5ea6d253.tar.gz bcm5719-llvm-3c2f74c9f30013ae5885f3e0a80798cf5ea6d253.zip |
Add sanity check for Ld/St Dual forms of Thumb2 instructions.
rdar://problem/9273947
llvm-svn: 129411
Diffstat (limited to 'llvm/lib')
-rw-r--r-- | llvm/lib/Target/ARM/Disassembler/ThumbDisassemblerCore.h | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/llvm/lib/Target/ARM/Disassembler/ThumbDisassemblerCore.h b/llvm/lib/Target/ARM/Disassembler/ThumbDisassemblerCore.h index e29d84604ec..42d7a73bf5f 100644 --- a/llvm/lib/Target/ARM/Disassembler/ThumbDisassemblerCore.h +++ b/llvm/lib/Target/ARM/Disassembler/ThumbDisassemblerCore.h @@ -1275,6 +1275,35 @@ static bool DisassembleThumb2LdStDual(MCInst &MI, unsigned Opcode, && OpInfo[3].RegClass < 0 && "Expect >= 4 operands and first 3 as reg operands"); + // Thumnb allows for specifying Rt and Rt2, unlike ARM (which has Rt2==Rt+1). + unsigned Rt = decodeRd(insn); + unsigned Rt2 = decodeRs(insn); + unsigned Rn = decodeRn(insn); + + // Some sanity checking first. + + // A8.6.67 LDRD (literal) has its W bit as (0). + if (Opcode == ARM::t2LDRDi8 || Opcode == ARM::t2LDRD_PRE || Opcode == ARM::t2LDRD_POST) { + if (Rn == 15 && slice(insn, 21, 21) != 0) + return false; + } else { + // For Dual Store, PC cannot be used as the base register. + if (Rn == 15) { + DEBUG(errs() << "if n == 15 then UNPREDICTABLE\n"); + return false; + } + } + if (Rt == Rt2) { + DEBUG(errs() << "if t == t2 then UNPREDICTABLE\n"); + return false; + } + if (Opcode != ARM::t2LDRDi8 && Opcode != ARM::t2STRDi8) { + if (Rn == Rt || Rn == Rt2) { + DEBUG(errs() << "if wback && (n == t || n == t2) then UNPREDICTABLE\n"); + return false; + } + } + // Add the <Rt> <Rt2> operands. unsigned RegClassPair = OpInfo[0].RegClass; unsigned RegClassBase = OpInfo[2].RegClass; |