diff options
author | Calin Juravle <calin@google.com> | 2014-11-06 17:09:03 +0000 |
---|---|---|
committer | Calin Juravle <calin@google.com> | 2014-11-06 17:21:16 +0000 |
commit | 865fc88fdfd006ce0362c2c0d55c66a7bffdab61 (patch) | |
tree | 35670296d924c9619a18a4149134e069de6ae48d | |
parent | d375fabd9e8cbb805fd12a33d94aa0729432ff3a (diff) | |
download | android_art-865fc88fdfd006ce0362c2c0d55c66a7bffdab61.tar.gz android_art-865fc88fdfd006ce0362c2c0d55c66a7bffdab61.tar.bz2 android_art-865fc88fdfd006ce0362c2c0d55c66a7bffdab61.zip |
[optimizing compiler] Add DIV_INT_2ADDR
Change-Id: I38fc7e216f820d8ccc8bbf8b8e7a67b75fb9de87
-rw-r--r-- | compiler/optimizing/builder.cc | 24 | ||||
-rw-r--r-- | compiler/optimizing/builder.h | 4 | ||||
-rw-r--r-- | compiler/optimizing/codegen_test.cc | 14 |
3 files changed, 33 insertions, 9 deletions
diff --git a/compiler/optimizing/builder.cc b/compiler/optimizing/builder.cc index e43841a03d..6ee236ea29 100644 --- a/compiler/optimizing/builder.cc +++ b/compiler/optimizing/builder.cc @@ -537,16 +537,16 @@ bool HGraphBuilder::BuildStaticFieldAccess(const Instruction& instruction, return true; } -void HGraphBuilder::BuildCheckedDiv(const Instruction& instruction, +void HGraphBuilder::BuildCheckedDiv(uint16_t out_reg, + uint16_t first_reg, + uint16_t second_reg, uint32_t dex_offset, Primitive::Type type, bool second_is_lit) { DCHECK(type == Primitive::kPrimInt); - HInstruction* first = LoadLocal(instruction.VRegB(), type); - HInstruction* second = second_is_lit - ? GetIntConstant(instruction.VRegC()) - : LoadLocal(instruction.VRegC(), type); + HInstruction* first = LoadLocal(first_reg, type); + HInstruction* second = second_is_lit ? GetIntConstant(second_reg) : LoadLocal(second_reg, type); if (!second->IsIntConstant() || (second->AsIntConstant()->GetValue() == 0)) { second = new (arena_) HDivZeroCheck(second, dex_offset); Temporaries temps(graph_, 1); @@ -555,7 +555,7 @@ void HGraphBuilder::BuildCheckedDiv(const Instruction& instruction, } current_block_->AddInstruction(new (arena_) HDiv(type, first, second)); - UpdateLocal(instruction.VRegA(), current_block_->GetLastInstruction()); + UpdateLocal(out_reg, current_block_->GetLastInstruction()); } void HGraphBuilder::BuildArrayAccess(const Instruction& instruction, @@ -977,7 +977,8 @@ bool HGraphBuilder::AnalyzeDexInstruction(const Instruction& instruction, uint32 } case Instruction::DIV_INT: { - BuildCheckedDiv(instruction, dex_offset, Primitive::kPrimInt, false); + BuildCheckedDiv(instruction.VRegA(), instruction.VRegB(), instruction.VRegC(), + dex_offset, Primitive::kPrimInt, false); break; } @@ -1046,6 +1047,12 @@ bool HGraphBuilder::AnalyzeDexInstruction(const Instruction& instruction, uint32 break; } + case Instruction::DIV_INT_2ADDR: { + BuildCheckedDiv(instruction.VRegA(), instruction.VRegA(), instruction.VRegB(), + dex_offset, Primitive::kPrimInt, false); + break; + } + case Instruction::DIV_FLOAT_2ADDR: { Binop_12x<HDiv>(instruction, Primitive::kPrimFloat); break; @@ -1088,7 +1095,8 @@ bool HGraphBuilder::AnalyzeDexInstruction(const Instruction& instruction, uint32 case Instruction::DIV_INT_LIT16: case Instruction::DIV_INT_LIT8: { - BuildCheckedDiv(instruction, dex_offset, Primitive::kPrimInt, true); + BuildCheckedDiv(instruction.VRegA(), instruction.VRegB(), instruction.VRegC(), + dex_offset, Primitive::kPrimInt, true); break; } diff --git a/compiler/optimizing/builder.h b/compiler/optimizing/builder.h index f09f729549..78ed035f65 100644 --- a/compiler/optimizing/builder.h +++ b/compiler/optimizing/builder.h @@ -120,7 +120,9 @@ class HGraphBuilder : public ValueObject { Primitive::Type input_type, Primitive::Type result_type); - void BuildCheckedDiv(const Instruction& instruction, + void BuildCheckedDiv(uint16_t out_reg, + uint16_t first_reg, + uint16_t second_reg, uint32_t dex_offset, Primitive::Type type, bool second_is_lit); diff --git a/compiler/optimizing/codegen_test.cc b/compiler/optimizing/codegen_test.cc index 6d4514f0ea..be3f5f3d05 100644 --- a/compiler/optimizing/codegen_test.cc +++ b/compiler/optimizing/codegen_test.cc @@ -552,4 +552,18 @@ TEST(CodegenTest, ReturnDivIntLit8) { TestCode(data, true, 1); } +#if defined(__aarch64__) +TEST(CodegenTest, DISABLED_ReturnDivInt2Addr) { +#else +TEST(CodegenTest, ReturnDivInt2Addr) { +#endif + const uint16_t data[] = TWO_REGISTERS_CODE_ITEM( + Instruction::CONST_4 | 4 << 12 | 0, + Instruction::CONST_4 | 2 << 12 | 1 << 8, + Instruction::DIV_INT_2ADDR | 1 << 12, + Instruction::RETURN); + + TestCode(data, true, 2); +} + } // namespace art |