blob: 495f3fd23274a402e517b431ca393959ada86818 [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
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
63void 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 Serov7fc63502016-02-09 17:15:29 +000083
Artem Udovichenko4a0dad62016-01-26 12:28:31 +030084} // namespace arm
85} // namespace art