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 | |
jessicahandojo | 0576575 | 2016-09-09 19:01:32 -0700 | [diff] [blame] | 47 | // TODO: Implement reading (length + compression) for String compression feature from |
| 48 | // negative offset (count_offset - data_offset). Thumb2Assembler does not support T4 |
| 49 | // encoding of "LDR (immediate)" at the moment. |
| 50 | // Don't move array pointer if it is charAt because we need to take the count first. |
| 51 | if (mirror::kUseStringCompression && instruction->IsStringCharAt()) { |
| 52 | return; |
| 53 | } |
| 54 | |
Artem Serov | 328429f | 2016-07-06 16:23:04 +0100 | [diff] [blame] | 55 | if (type == Primitive::kPrimLong |
| 56 | || type == Primitive::kPrimFloat |
| 57 | || type == Primitive::kPrimDouble) { |
| 58 | // T32 doesn't support ShiftedRegOffset mem address mode for these types |
| 59 | // to enable optimization. |
| 60 | return; |
| 61 | } |
| 62 | |
| 63 | if (TryExtractArrayAccessAddress(instruction, |
| 64 | instruction->GetArray(), |
| 65 | instruction->GetIndex(), |
| 66 | data_offset)) { |
| 67 | RecordSimplification(); |
| 68 | } |
| 69 | } |
| 70 | |
| 71 | void InstructionSimplifierArmVisitor::VisitArraySet(HArraySet* instruction) { |
| 72 | size_t access_size = Primitive::ComponentSize(instruction->GetComponentType()); |
| 73 | size_t data_offset = mirror::Array::DataOffset(access_size).Uint32Value(); |
| 74 | Primitive::Type type = instruction->GetComponentType(); |
| 75 | |
| 76 | if (type == Primitive::kPrimLong |
| 77 | || type == Primitive::kPrimFloat |
| 78 | || type == Primitive::kPrimDouble) { |
| 79 | // T32 doesn't support ShiftedRegOffset mem address mode for these types |
| 80 | // to enable optimization. |
| 81 | return; |
| 82 | } |
| 83 | |
| 84 | if (TryExtractArrayAccessAddress(instruction, |
| 85 | instruction->GetArray(), |
| 86 | instruction->GetIndex(), |
| 87 | data_offset)) { |
| 88 | RecordSimplification(); |
| 89 | } |
| 90 | } |
Artem Serov | 7fc6350 | 2016-02-09 17:15:29 +0000 | [diff] [blame] | 91 | |
Artem Udovichenko | 4a0dad6 | 2016-01-26 12:28:31 +0300 | [diff] [blame] | 92 | } // namespace arm |
| 93 | } // namespace art |