[ARM] Fix handling of zero offsets in LOB instructions.
authorSimon Tatham <simon.tatham@arm.com>
Thu, 27 Jun 2019 12:41:07 +0000 (12:41 +0000)
committerSimon Tatham <simon.tatham@arm.com>
Thu, 27 Jun 2019 12:41:07 +0000 (12:41 +0000)
commitffb2b347ffbdc667169af4f4627cfdf7d64be6a0
treef04139e40336f33dda0c5a1294acc891445390fb
parente5ce56fb950bb27f6934f670b9916a50d2b8cfb2
[ARM] Fix handling of zero offsets in LOB instructions.

The BF and WLS/WLSTP instructions have various branch-offset fields
occupying different positions and lengths in the instruction encoding,
and all of them were decoded at disassembly time by the function
DecodeBFLabelOffset() which returned SoftFail if the offset was zero.

In fact, it's perfectly fine and not even a SoftFail for most of those
offset fields to be zero. The only one that can't be zero is the 4-bit
field labelled `boff` in the architecture spec, occupying bits {26-23}
of the BF instruction family. If that one is zero, the encoding
overlaps other instructions (WLS, DLS, LETP, VCTP), so it ought to be
a full Fail.

Fixed by adding an extra template parameter to DecodeBFLabelOffset
which controls whether a zero offset is accepted or rejected. Adjusted
existing tests (only in error messages for bad disassemblies); added
extra tests to demonstrate zero offsets being accepted in all the
right places, and a few demonstrating rejection of zero `boff`.

Reviewers: DavidSpickett, ostannard

Subscribers: javed.absar, kristof.beyls, hiraditya, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D63864

llvm-svn: 364533
llvm/lib/Target/ARM/ARMInstrThumb2.td
llvm/lib/Target/ARM/Disassembler/ARMDisassembler.cpp
llvm/test/MC/ARM/mve-misc.s
llvm/test/MC/ARM/thumbv8.1m.s
llvm/test/MC/Disassembler/ARM/mve-misc.txt
llvm/test/MC/Disassembler/ARM/mve-qdest-rsrc.txt
llvm/test/MC/Disassembler/ARM/thumb2-v8.1m.txt