Elide repeated register operand in Thumb1 instructions
authorRenato Golin <renato.golin@linaro.org>
Fri, 26 Sep 2014 16:14:29 +0000 (16:14 +0000)
committerRenato Golin <renato.golin@linaro.org>
Fri, 26 Sep 2014 16:14:29 +0000 (16:14 +0000)
commit6215f78195740ff37cf14f7d03c64847750d9f90
tree4ce07a91a57867a008a7d5efe82614b89dca04ee
parenta5ab9baf8319dfef200bef6898039f8d7c3286e3
Elide repeated register operand in Thumb1 instructions

This patch makes the ARM backend transform 3 operand instructions such as
'adds/subs' to the 2 operand version of the same instruction if the first
two register operands are the same.

Example: 'adds r0, r0, #1' will is transformed to 'adds r0, #1'.

Currently for some instructions such as 'adds' if you try to assemble
'adds r0, r0, #8' for thumb v6m the assembler would throw an error message
because the immediate cannot be encoded using 3 bits.

The backend should be smart enough to transform the instruction to
'adds r0, #8', which allows for larger immediate constants.

Patch by Ranjeet Singh.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@218521 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Target/ARM/AsmParser/ARMAsmParser.cpp
test/MC/ARM/thumb_rewrites.s [new file with mode: 0644]