diff options
author | Calin Juravle <calin@google.com> | 2015-03-17 18:42:26 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2015-03-17 18:42:26 +0000 |
commit | 1d2868c081f6d523d4fe2d88fe321074e53f68e5 (patch) | |
tree | b1f0e65127e4a9ca87f4843490a1993dd250e148 /compiler/utils | |
parent | 3533c45b3411ec9ca3e65d956d5789b6333a0a77 (diff) | |
parent | 8de00e3f5fcb99bfd7e4dc679ab7333549bec2c1 (diff) | |
download | android_art-1d2868c081f6d523d4fe2d88fe321074e53f68e5.tar.gz android_art-1d2868c081f6d523d4fe2d88fe321074e53f68e5.tar.bz2 android_art-1d2868c081f6d523d4fe2d88fe321074e53f68e5.zip |
Merge "Make subs alter flags when rn is an immediate"
Diffstat (limited to 'compiler/utils')
-rw-r--r-- | compiler/utils/arm/assembler_thumb2.cc | 33 | ||||
-rw-r--r-- | compiler/utils/arm/assembler_thumb2_test.cc | 10 |
2 files changed, 28 insertions, 15 deletions
diff --git a/compiler/utils/arm/assembler_thumb2.cc b/compiler/utils/arm/assembler_thumb2.cc index eb5b4540f9..e8eb019af3 100644 --- a/compiler/utils/arm/assembler_thumb2.cc +++ b/compiler/utils/arm/assembler_thumb2.cc @@ -826,7 +826,9 @@ void Thumb2Assembler::Emit32BitDataProcessing(Condition cond ATTRIBUTE_UNUSED, // Check special cases. if ((opcode == SUB || opcode == ADD) && (so.GetImmediate() < (1u << 12))) { if (opcode == SUB) { - thumb_opcode = 5U /* 0b0101 */; + if (!set_cc) { + thumb_opcode = 5U /* 0b0101 */; + } } else { thumb_opcode = 0; } @@ -836,13 +838,14 @@ void Thumb2Assembler::Emit32BitDataProcessing(Condition cond ATTRIBUTE_UNUSED, uint32_t imm3 = (imm >> 8) & 7U /* 0b111 */; uint32_t imm8 = imm & 0xff; - encoding = B31 | B30 | B29 | B28 | B25 | - thumb_opcode << 21 | - rn << 16 | - rd << 8 | - i << 26 | - imm3 << 12 | - imm8; + encoding = B31 | B30 | B29 | B28 | + (set_cc ? B20 : B25) | + thumb_opcode << 21 | + rn << 16 | + rd << 8 | + i << 26 | + imm3 << 12 | + imm8; } else { // Modified immediate. uint32_t imm = ModifiedImmediate(so.encodingThumb()); @@ -858,13 +861,13 @@ void Thumb2Assembler::Emit32BitDataProcessing(Condition cond ATTRIBUTE_UNUSED, imm; } } else if (so.IsRegister()) { - // Register (possibly shifted) - encoding = B31 | B30 | B29 | B27 | B25 | - thumb_opcode << 21 | - (set_cc ? 1 : 0) << 20 | - rn << 16 | - rd << 8 | - so.encodingThumb(); + // Register (possibly shifted) + encoding = B31 | B30 | B29 | B27 | B25 | + thumb_opcode << 21 | + (set_cc ? 1 : 0) << 20 | + rn << 16 | + rd << 8 | + so.encodingThumb(); } Emit32(encoding); } diff --git a/compiler/utils/arm/assembler_thumb2_test.cc b/compiler/utils/arm/assembler_thumb2_test.cc index ebea9d4262..d802852caf 100644 --- a/compiler/utils/arm/assembler_thumb2_test.cc +++ b/compiler/utils/arm/assembler_thumb2_test.cc @@ -227,4 +227,14 @@ TEST_F(AssemblerThumb2Test, eor) { DriverStr(expected, "abs"); } +TEST_F(AssemblerThumb2Test, sub) { + __ subs(arm::R1, arm::R0, arm::ShifterOperand(42)); + __ sub(arm::R1, arm::R0, arm::ShifterOperand(42)); + + const char* expected = + "subs r1, r0, #42\n" + "subw r1, r0, #42\n"; + DriverStr(expected, "sub"); +} + } // namespace art |