[PATCH] Fix assembling of Thumb2 branch instructions.

Mihail Popa mihail.popa at gmail.com
Tue Aug 6 07:01:42 PDT 2013


Hello.

The long encoding for Thumb2 unconditional branches is broken.
Additionally, there is no range checking for target operands; as such
for instructions originating in assembly code, only short Thumb encodings
are generated, regardless of the bitsize needed for the offset.

Adding range checking is non trivial due to the representation of Thumb
branch instructions. There is no true difference between conditional and
unconditional branches in terms of operands and syntax - even unconditional
branches have a predicate which is expected to match that of the IT block
they are in. Yet, the encodings and the permitted size of the offset differ.

Due to this, for any mnemonic there are really 4 encodings to choose for.

The problem cannot be handled in the parser alone or by manipulating td
files.
Because the parser builds first a set of match candidates and then checks
them
one by one, whatever tablegen-only solution might be found will ultimately
be
dependent of the parser's evaluation order. What's worse is that due to the
fact
that all branches have the same syntax and the same kinds of operands, that
order is governed by the lexicographical ordering of the names of operand
classes...

To circumvent all this, any necessary disambiguation is added to the
instruction
validation pass.

Please review the attached patch.

Thanks,

Mihai
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130806/4262e6b1/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: LLVM-820.t2b.patch
Type: application/octet-stream
Size: 15047 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130806/4262e6b1/attachment.obj>


More information about the llvm-commits mailing list