Artem Udovichenko | 4a0dad6 | 2016-01-26 12:28:31 +0300 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2015 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
Artem Serov | 328429f | 2016-07-06 16:23:04 +0100 | [diff] [blame] | 17 | #include "code_generator.h" |
Artem Udovichenko | 4a0dad6 | 2016-01-26 12:28:31 +0300 | [diff] [blame] | 18 | #include "instruction_simplifier_arm.h" |
| 19 | #include "instruction_simplifier_shared.h" |
Artem Serov | 328429f | 2016-07-06 16:23:04 +0100 | [diff] [blame] | 20 | #include "mirror/array-inl.h" |
Artem Udovichenko | 4a0dad6 | 2016-01-26 12:28:31 +0300 | [diff] [blame] | 21 | |
| 22 | namespace art { |
| 23 | namespace arm { |
| 24 | |
| 25 | void InstructionSimplifierArmVisitor::VisitMul(HMul* instruction) { |
| 26 | if (TryCombineMultiplyAccumulate(instruction, kArm)) { |
| 27 | RecordSimplification(); |
| 28 | } |
| 29 | } |
| 30 | |
Artem Serov | 7fc6350 | 2016-02-09 17:15:29 +0000 | [diff] [blame] | 31 | void InstructionSimplifierArmVisitor::VisitOr(HOr* instruction) { |
| 32 | if (TryMergeNegatedInput(instruction)) { |
| 33 | RecordSimplification(); |
| 34 | } |
| 35 | } |
| 36 | |
| 37 | void InstructionSimplifierArmVisitor::VisitAnd(HAnd* instruction) { |
| 38 | if (TryMergeNegatedInput(instruction)) { |
| 39 | RecordSimplification(); |
| 40 | } |
| 41 | } |
| 42 | |
Artem Serov | 328429f | 2016-07-06 16:23:04 +0100 | [diff] [blame] | 43 | void InstructionSimplifierArmVisitor::VisitArrayGet(HArrayGet* instruction) { |
| 44 | size_t data_offset = CodeGenerator::GetArrayDataOffset(instruction); |
| 45 | Primitive::Type type = instruction->GetType(); |
| 46 | |
| 47 | if (type == Primitive::kPrimLong |
| 48 | || type == Primitive::kPrimFloat |
| 49 | || type == Primitive::kPrimDouble) { |
| 50 | // T32 doesn't support ShiftedRegOffset mem address mode for these types |
| 51 | // to enable optimization. |
| 52 | return; |
| 53 | } |
| 54 | |
| 55 | if (TryExtractArrayAccessAddress(instruction, |
| 56 | instruction->GetArray(), |
| 57 | instruction->GetIndex(), |
| 58 | data_offset)) { |
| 59 | RecordSimplification(); |
| 60 | } |
| 61 | } |
| 62 | |
| 63 | void InstructionSimplifierArmVisitor::VisitArraySet(HArraySet* instruction) { |
| 64 | size_t access_size = Primitive::ComponentSize(instruction->GetComponentType()); |
| 65 | size_t data_offset = mirror::Array::DataOffset(access_size).Uint32Value(); |
| 66 | Primitive::Type type = instruction->GetComponentType(); |
| 67 | |
| 68 | if (type == Primitive::kPrimLong |
| 69 | || type == Primitive::kPrimFloat |
| 70 | || type == Primitive::kPrimDouble) { |
| 71 | // T32 doesn't support ShiftedRegOffset mem address mode for these types |
| 72 | // to enable optimization. |
| 73 | return; |
| 74 | } |
| 75 | |
| 76 | if (TryExtractArrayAccessAddress(instruction, |
| 77 | instruction->GetArray(), |
| 78 | instruction->GetIndex(), |
| 79 | data_offset)) { |
| 80 | RecordSimplification(); |
| 81 | } |
| 82 | } |
Artem Serov | 7fc6350 | 2016-02-09 17:15:29 +0000 | [diff] [blame] | 83 | |
Artem Udovichenko | 4a0dad6 | 2016-01-26 12:28:31 +0300 | [diff] [blame] | 84 | } // namespace arm |
| 85 | } // namespace art |