instruction_simplifier_arm64.h revision 418318f4d50e0cfc2d54330d7623ee030d4d727d
144b9cf937836bb33139123e15ca8b586b5853268Alexandre Rames/*
244b9cf937836bb33139123e15ca8b586b5853268Alexandre Rames * Copyright (C) 2015 The Android Open Source Project
344b9cf937836bb33139123e15ca8b586b5853268Alexandre Rames *
444b9cf937836bb33139123e15ca8b586b5853268Alexandre Rames * Licensed under the Apache License, Version 2.0 (the "License");
544b9cf937836bb33139123e15ca8b586b5853268Alexandre Rames * you may not use this file except in compliance with the License.
644b9cf937836bb33139123e15ca8b586b5853268Alexandre Rames * You may obtain a copy of the License at
744b9cf937836bb33139123e15ca8b586b5853268Alexandre Rames *
844b9cf937836bb33139123e15ca8b586b5853268Alexandre Rames *      http://www.apache.org/licenses/LICENSE-2.0
944b9cf937836bb33139123e15ca8b586b5853268Alexandre Rames *
1044b9cf937836bb33139123e15ca8b586b5853268Alexandre Rames * Unless required by applicable law or agreed to in writing, software
1144b9cf937836bb33139123e15ca8b586b5853268Alexandre Rames * distributed under the License is distributed on an "AS IS" BASIS,
1244b9cf937836bb33139123e15ca8b586b5853268Alexandre Rames * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1344b9cf937836bb33139123e15ca8b586b5853268Alexandre Rames * See the License for the specific language governing permissions and
1444b9cf937836bb33139123e15ca8b586b5853268Alexandre Rames * limitations under the License.
1544b9cf937836bb33139123e15ca8b586b5853268Alexandre Rames */
1644b9cf937836bb33139123e15ca8b586b5853268Alexandre Rames
1744b9cf937836bb33139123e15ca8b586b5853268Alexandre Rames#ifndef ART_COMPILER_OPTIMIZING_INSTRUCTION_SIMPLIFIER_ARM64_H_
1844b9cf937836bb33139123e15ca8b586b5853268Alexandre Rames#define ART_COMPILER_OPTIMIZING_INSTRUCTION_SIMPLIFIER_ARM64_H_
1944b9cf937836bb33139123e15ca8b586b5853268Alexandre Rames
2044b9cf937836bb33139123e15ca8b586b5853268Alexandre Rames#include "nodes.h"
2144b9cf937836bb33139123e15ca8b586b5853268Alexandre Rames#include "optimization.h"
2244b9cf937836bb33139123e15ca8b586b5853268Alexandre Rames
2344b9cf937836bb33139123e15ca8b586b5853268Alexandre Ramesnamespace art {
2444b9cf937836bb33139123e15ca8b586b5853268Alexandre Ramesnamespace arm64 {
2544b9cf937836bb33139123e15ca8b586b5853268Alexandre Rames
2644b9cf937836bb33139123e15ca8b586b5853268Alexandre Ramesclass InstructionSimplifierArm64Visitor : public HGraphVisitor {
2744b9cf937836bb33139123e15ca8b586b5853268Alexandre Rames public:
2844b9cf937836bb33139123e15ca8b586b5853268Alexandre Rames  InstructionSimplifierArm64Visitor(HGraph* graph, OptimizingCompilerStats* stats)
2944b9cf937836bb33139123e15ca8b586b5853268Alexandre Rames      : HGraphVisitor(graph), stats_(stats) {}
3044b9cf937836bb33139123e15ca8b586b5853268Alexandre Rames
3144b9cf937836bb33139123e15ca8b586b5853268Alexandre Rames private:
3244b9cf937836bb33139123e15ca8b586b5853268Alexandre Rames  void RecordSimplification() {
3344b9cf937836bb33139123e15ca8b586b5853268Alexandre Rames    if (stats_ != nullptr) {
3444b9cf937836bb33139123e15ca8b586b5853268Alexandre Rames      stats_->RecordStat(kInstructionSimplificationsArch);
3544b9cf937836bb33139123e15ca8b586b5853268Alexandre Rames    }
3644b9cf937836bb33139123e15ca8b586b5853268Alexandre Rames  }
3744b9cf937836bb33139123e15ca8b586b5853268Alexandre Rames
38e6dbf48d7a549e58a3d798bbbdc391e4d091b432Alexandre Rames  void TryExtractArrayAccessAddress(HInstruction* access,
39e6dbf48d7a549e58a3d798bbbdc391e4d091b432Alexandre Rames                                    HInstruction* array,
40e6dbf48d7a549e58a3d798bbbdc391e4d091b432Alexandre Rames                                    HInstruction* index,
41e6dbf48d7a549e58a3d798bbbdc391e4d091b432Alexandre Rames                                    int access_size);
42e6dbf48d7a549e58a3d798bbbdc391e4d091b432Alexandre Rames
43418318f4d50e0cfc2d54330d7623ee030d4d727dAlexandre Rames  bool TrySimpleMultiplyAccumulatePatterns(HMul* mul,
44418318f4d50e0cfc2d54330d7623ee030d4d727dAlexandre Rames                                           HBinaryOperation* input_binop,
45418318f4d50e0cfc2d54330d7623ee030d4d727dAlexandre Rames                                           HInstruction* input_other);
46418318f4d50e0cfc2d54330d7623ee030d4d727dAlexandre Rames
47418318f4d50e0cfc2d54330d7623ee030d4d727dAlexandre Rames  // HInstruction visitors, sorted alphabetically.
48e6dbf48d7a549e58a3d798bbbdc391e4d091b432Alexandre Rames  void VisitArrayGet(HArrayGet* instruction) OVERRIDE;
49e6dbf48d7a549e58a3d798bbbdc391e4d091b432Alexandre Rames  void VisitArraySet(HArraySet* instruction) OVERRIDE;
50418318f4d50e0cfc2d54330d7623ee030d4d727dAlexandre Rames  void VisitMul(HMul* instruction) OVERRIDE;
51e6dbf48d7a549e58a3d798bbbdc391e4d091b432Alexandre Rames
5244b9cf937836bb33139123e15ca8b586b5853268Alexandre Rames  OptimizingCompilerStats* stats_;
5344b9cf937836bb33139123e15ca8b586b5853268Alexandre Rames};
5444b9cf937836bb33139123e15ca8b586b5853268Alexandre Rames
5544b9cf937836bb33139123e15ca8b586b5853268Alexandre Rames
5644b9cf937836bb33139123e15ca8b586b5853268Alexandre Ramesclass InstructionSimplifierArm64 : public HOptimization {
5744b9cf937836bb33139123e15ca8b586b5853268Alexandre Rames public:
5844b9cf937836bb33139123e15ca8b586b5853268Alexandre Rames  InstructionSimplifierArm64(HGraph* graph, OptimizingCompilerStats* stats)
5944b9cf937836bb33139123e15ca8b586b5853268Alexandre Rames    : HOptimization(graph, "instruction_simplifier_arm64", stats) {}
6044b9cf937836bb33139123e15ca8b586b5853268Alexandre Rames
6144b9cf937836bb33139123e15ca8b586b5853268Alexandre Rames  void Run() OVERRIDE {
6244b9cf937836bb33139123e15ca8b586b5853268Alexandre Rames    InstructionSimplifierArm64Visitor visitor(graph_, stats_);
6344b9cf937836bb33139123e15ca8b586b5853268Alexandre Rames    visitor.VisitReversePostOrder();
6444b9cf937836bb33139123e15ca8b586b5853268Alexandre Rames  }
6544b9cf937836bb33139123e15ca8b586b5853268Alexandre Rames};
6644b9cf937836bb33139123e15ca8b586b5853268Alexandre Rames
6744b9cf937836bb33139123e15ca8b586b5853268Alexandre Rames}  // namespace arm64
6844b9cf937836bb33139123e15ca8b586b5853268Alexandre Rames}  // namespace art
6944b9cf937836bb33139123e15ca8b586b5853268Alexandre Rames
7044b9cf937836bb33139123e15ca8b586b5853268Alexandre Rames#endif  // ART_COMPILER_OPTIMIZING_INSTRUCTION_SIMPLIFIER_ARM64_H_
71