llvm.org GIT mirror llvm / f8560e5
[ARM] Handle commutativity when converting to tADDhirr in Thumb2 Also, run thumb_rewrite.s tests in Thumb2 now that they pass. Differential Revision: http://reviews.llvm.org/D11132 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@242036 91177308-0d34-0410-b5e6-96231b3b80d8 Scott Douglass 5 years ago
3 changed file(s) with 14 addition(s) and 3 deletion(s). Raw diff Collapse all Expand all
82148214 // If the destination and first source operand are the same, and
82158215 // there's no setting of the flags, use encoding T2 instead of T3.
82168216 // Note that this is only for ADD, not SUB. This mirrors the system
8217 // 'as' behaviour. Make sure the wide encoding wasn't explicit.
8218 if (Inst.getOperand(0).getReg() != Inst.getOperand(1).getReg() ||
8217 // 'as' behaviour. Also take advantage of ADD being commutative.
8218 // Make sure the wide encoding wasn't explicit.
8219 bool Swap = false;
8220 auto DestReg = Inst.getOperand(0).getReg();
8221 bool Transform = DestReg == Inst.getOperand(1).getReg();
8222 if (!Transform && DestReg == Inst.getOperand(2).getReg()) {
8223 Transform = true;
8224 Swap = true;
8225 }
8226 if (!Transform ||
82198227 Inst.getOperand(5).getReg() != 0 ||
82208228 (static_cast(*Operands[3]).isToken() &&
82218229 static_cast(*Operands[3]).getToken() == ".w"))
82248232 TmpInst.setOpcode(ARM::tADDhirr);
82258233 TmpInst.addOperand(Inst.getOperand(0));
82268234 TmpInst.addOperand(Inst.getOperand(0));
8227 TmpInst.addOperand(Inst.getOperand(2));
8235 TmpInst.addOperand(Inst.getOperand(Swap ? 1 : 2));
82288236 TmpInst.addOperand(Inst.getOperand(3));
82298237 TmpInst.addOperand(Inst.getOperand(4));
82308238 Inst = TmpInst;
4343 // CHECK: adds r0, r2, r1 @ encoding: [0x50,0x18]
4444 ADDS r2, r2, r1 // ADDS has T1 narrow 3 operand
4545 // CHECK: adds r2, r2, r1 @ encoding: [0x52,0x18]
46 ADD r3, r1, r3 // T2
47 // CHECK: add r3, r1 @ encoding: [0x0b,0x44]
4648
4749 IT EQ
4850 // CHECK: it eq @ encoding: [0x08,0xbf]
0 @ RUN: llvm-mc -triple thumbv6m -show-encoding < %s | FileCheck %s
1 @ RUN: llvm-mc -triple thumbv7m -show-encoding < %s | FileCheck %s
12
23 adds r1, r1, #3
34 @ CHECK: adds r1, r1, #3 @ encoding: [0xc9,0x1c]