blob: 56e4c7a9c245adcf9af2e732f8138b468b2d37ec [file] [log] [blame]
Artem Udovichenko4a0dad62016-01-26 12:28:31 +03001/*
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 Serov328429f2016-07-06 16:23:04 +010017#include "code_generator.h"
Artem Udovichenko4a0dad62016-01-26 12:28:31 +030018#include "instruction_simplifier_arm.h"
19#include "instruction_simplifier_shared.h"
Artem Serov328429f2016-07-06 16:23:04 +010020#include "mirror/array-inl.h"
Artem Udovichenko4a0dad62016-01-26 12:28:31 +030021
22namespace art {
23namespace arm {
24
25void InstructionSimplifierArmVisitor::VisitMul(HMul* instruction) {
26 if (TryCombineMultiplyAccumulate(instruction, kArm)) {
27 RecordSimplification();
28 }
29}
30
Artem Serov7fc63502016-02-09 17:15:29 +000031void InstructionSimplifierArmVisitor::VisitOr(HOr* instruction) {
32 if (TryMergeNegatedInput(instruction)) {
33 RecordSimplification();
34 }
35}
36
37void InstructionSimplifierArmVisitor::VisitAnd(HAnd* instruction) {
38 if (TryMergeNegatedInput(instruction)) {
39 RecordSimplification();
40 }
41}
42
Artem Serov328429f2016-07-06 16:23:04 +010043void InstructionSimplifierArmVisitor::VisitArrayGet(HArrayGet* instruction) {
44 size_t data_offset = CodeGenerator::GetArrayDataOffset(instruction);
45 Primitive::Type type = instruction->GetType();
46
jessicahandojo05765752016-09-09 19:01:32 -070047 // 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 Serov328429f2016-07-06 16:23:04 +010055 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
71void 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 Serov7fc63502016-02-09 17:15:29 +000091
Artem Udovichenko4a0dad62016-01-26 12:28:31 +030092} // namespace arm
93} // namespace art