[llvm-commits] [llvm] r138862 - in /llvm/trunk: lib/Target/ARM/AsmParser/ARMAsmParser.cpp test/MC/ARM/basic-thumb-instructions.s
Jim Grosbach
grosbach at apple.com
Wed Aug 31 10:07:33 PDT 2011
Author: grosbach
Date: Wed Aug 31 12:07:33 2011
New Revision: 138862
URL: http://llvm.org/viewvc/llvm-project?rev=138862&view=rev
Log:
Tweak Thumb1 ADD encoding selection a bit.
When the destination register of an add immediate instruction is
explicitly specified, encoding T1 is preferred, else encoding T2 is
preferred.
Modified:
llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp
llvm/trunk/test/MC/ARM/basic-thumb-instructions.s
Modified: llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp?rev=138862&r1=138861&r2=138862&view=diff
==============================================================================
--- llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp (original)
+++ llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp Wed Aug 31 12:07:33 2011
@@ -3473,8 +3473,11 @@
}
break;
case ARM::tADDi8:
- // If the immediate is in the range 0-7, we really wanted tADDi3.
- if (Inst.getOperand(3).getImm() < 8)
+ // If the immediate is in the range 0-7, we want tADDi3 iff Rd was
+ // explicitly specified. From the ARM ARM: "Encoding T1 is preferred
+ // to encoding T2 if <Rd> is specified and encoding T2 is preferred
+ // to encoding T1 if <Rd> is omitted."
+ if (Inst.getOperand(3).getImm() < 8 && Operands.size() == 6)
Inst.setOpcode(ARM::tADDi3);
break;
case ARM::tBcc:
Modified: llvm/trunk/test/MC/ARM/basic-thumb-instructions.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/ARM/basic-thumb-instructions.s?rev=138862&r1=138861&r2=138862&view=diff
==============================================================================
--- llvm/trunk/test/MC/ARM/basic-thumb-instructions.s (original)
+++ llvm/trunk/test/MC/ARM/basic-thumb-instructions.s Wed Aug 31 12:07:33 2011
@@ -26,11 +26,13 @@
@ ADD (immediate)
@------------------------------------------------------------------------------
adds r1, r2, #3
+@ When Rd is not explicitly specified, encoding T2 is preferred even though
+@ the literal is in the range [0,7] which would allow encoding T1.
adds r2, #3
adds r2, #8
@ CHECK: adds r1, r2, #3 @ encoding: [0xd1,0x1c]
-@ CHECK: adds r2, r2, #3 @ encoding: [0xd2,0x1c]
+@ CHECK: adds r2, #3 @ encoding: [0x03,0x32]
@ CHECK: adds r2, #8 @ encoding: [0x08,0x32]
More information about the llvm-commits
mailing list