ARM: check predicate bits for thumb instructions

When encoded to thumb, VFP instruction and VMOV/VDUP between scalar and
core registers, must have their predicate bit to 0b1110.

llvm-svn: 184707
This commit is contained in:
Amaury de la Vieuville 2013-06-24 09:15:01 +00:00
parent 8175bda3db
commit 8449c0d5ed
3 changed files with 35 additions and 13 deletions

View File

@ -754,21 +754,25 @@ DecodeStatus ThumbDisassembler::getInstruction(MCInst &MI, uint64_t &Size,
return result; return result;
} }
MI.clear(); if (fieldFromInstruction(insn32, 28, 4) == 0xE) {
result = decodeInstruction(DecoderTableVFP32, MI, insn32, Address, this, STI); MI.clear();
if (result != MCDisassembler::Fail) { result = decodeInstruction(DecoderTableVFP32, MI, insn32, Address, this, STI);
Size = 4; if (result != MCDisassembler::Fail) {
UpdateThumbVFPPredicate(MI); Size = 4;
return result; UpdateThumbVFPPredicate(MI);
return result;
}
} }
MI.clear(); if (fieldFromInstruction(insn32, 28, 4) == 0xE) {
result = decodeInstruction(DecoderTableNEONDup32, MI, insn32, Address, MI.clear();
this, STI); result = decodeInstruction(DecoderTableNEONDup32, MI, insn32, Address,
if (result != MCDisassembler::Fail) { this, STI);
Size = 4; if (result != MCDisassembler::Fail) {
Check(result, AddThumbPredicate(MI)); Size = 4;
return result; Check(result, AddThumbPredicate(MI));
return result;
}
} }
if (fieldFromInstruction(insn32, 24, 8) == 0xF9) { if (fieldFromInstruction(insn32, 24, 8) == 0xF9) {

View File

@ -0,0 +1,9 @@
# VMOV/VDUP between scalar and core registers with invalid predicate bits (pred != 0b1110)
# VMOV
# RUN: echo "0x00 0xde 0x10 0x0b" | llvm-mc -triple thumbv7 -disassemble 2>&1 | FileCheck %s
# VDUP
# RUN: echo "0xff 0xde 0xf0 0xfb" | llvm-mc -triple thumbv7 -disassemble 2>&1 | FileCheck %s
# CHECK: invalid instruction encoding

View File

@ -0,0 +1,9 @@
# VFP instructions with invalid predicate bits (pred != 0b1110)
# VABS
# RUN: echo "0x40 0xde 0x00 0x0a" | llvm-mc -triple thumbv7 -disassemble 2>&1 | FileCheck %s
# VMLA
# RUN: echo "0xf0 0xde 0xe0 0x0b" | llvm-mc -triple thumbv7 -disassemble 2>&1 | FileCheck %s
# CHECK: invalid instruction encoding