13c04974a90b0e03f4b509010bff49f0b2a3da57fNicolas Geoffray/*
23c04974a90b0e03f4b509010bff49f0b2a3da57fNicolas Geoffray * Copyright (C) 2014 The Android Open Source Project
33c04974a90b0e03f4b509010bff49f0b2a3da57fNicolas Geoffray *
43c04974a90b0e03f4b509010bff49f0b2a3da57fNicolas Geoffray * Licensed under the Apache License, Version 2.0 (the "License");
53c04974a90b0e03f4b509010bff49f0b2a3da57fNicolas Geoffray * you may not use this file except in compliance with the License.
63c04974a90b0e03f4b509010bff49f0b2a3da57fNicolas Geoffray * You may obtain a copy of the License at
73c04974a90b0e03f4b509010bff49f0b2a3da57fNicolas Geoffray *
83c04974a90b0e03f4b509010bff49f0b2a3da57fNicolas Geoffray *      http://www.apache.org/licenses/LICENSE-2.0
93c04974a90b0e03f4b509010bff49f0b2a3da57fNicolas Geoffray *
103c04974a90b0e03f4b509010bff49f0b2a3da57fNicolas Geoffray * Unless required by applicable law or agreed to in writing, software
113c04974a90b0e03f4b509010bff49f0b2a3da57fNicolas Geoffray * distributed under the License is distributed on an "AS IS" BASIS,
123c04974a90b0e03f4b509010bff49f0b2a3da57fNicolas Geoffray * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
133c04974a90b0e03f4b509010bff49f0b2a3da57fNicolas Geoffray * See the License for the specific language governing permissions and
143c04974a90b0e03f4b509010bff49f0b2a3da57fNicolas Geoffray * limitations under the License.
153c04974a90b0e03f4b509010bff49f0b2a3da57fNicolas Geoffray */
163c04974a90b0e03f4b509010bff49f0b2a3da57fNicolas Geoffray
173c04974a90b0e03f4b509010bff49f0b2a3da57fNicolas Geoffray#ifndef ART_COMPILER_OPTIMIZING_INSTRUCTION_SIMPLIFIER_H_
183c04974a90b0e03f4b509010bff49f0b2a3da57fNicolas Geoffray#define ART_COMPILER_OPTIMIZING_INSTRUCTION_SIMPLIFIER_H_
193c04974a90b0e03f4b509010bff49f0b2a3da57fNicolas Geoffray
203c04974a90b0e03f4b509010bff49f0b2a3da57fNicolas Geoffray#include "nodes.h"
215e6916cea259897baaca019c5c7a5d05746306edNicolas Geoffray#include "optimization.h"
22acf735c13998ad2a175f5a17e7bfce220073279dCalin Juravle#include "optimizing_compiler_stats.h"
233c04974a90b0e03f4b509010bff49f0b2a3da57fNicolas Geoffray
243c04974a90b0e03f4b509010bff49f0b2a3da57fNicolas Geoffraynamespace art {
253c04974a90b0e03f4b509010bff49f0b2a3da57fNicolas Geoffray
263c04974a90b0e03f4b509010bff49f0b2a3da57fNicolas Geoffray/**
273c04974a90b0e03f4b509010bff49f0b2a3da57fNicolas Geoffray * Implements optimizations specific to each instruction.
281252e976b972231a84b36e4bb73cf513bb7799d1Roland Levillain *
291252e976b972231a84b36e4bb73cf513bb7799d1Roland Levillain * Note that graph simplifications producing a constant should be
301252e976b972231a84b36e4bb73cf513bb7799d1Roland Levillain * implemented in art::HConstantFolding, while graph simplifications
311252e976b972231a84b36e4bb73cf513bb7799d1Roland Levillain * not producing constants should be implemented in
321252e976b972231a84b36e4bb73cf513bb7799d1Roland Levillain * art::InstructionSimplifier.  (This convention is a choice that was
331252e976b972231a84b36e4bb73cf513bb7799d1Roland Levillain * made during the development of these parts of the compiler and is
341252e976b972231a84b36e4bb73cf513bb7799d1Roland Levillain * not bound by any technical requirement.)
353c04974a90b0e03f4b509010bff49f0b2a3da57fNicolas Geoffray */
365e6916cea259897baaca019c5c7a5d05746306edNicolas Geoffrayclass InstructionSimplifier : public HOptimization {
373c04974a90b0e03f4b509010bff49f0b2a3da57fNicolas Geoffray public:
38acf735c13998ad2a175f5a17e7bfce220073279dCalin Juravle  InstructionSimplifier(HGraph* graph,
39acf735c13998ad2a175f5a17e7bfce220073279dCalin Juravle                        OptimizingCompilerStats* stats = nullptr,
407c3952f423b8213083d60596a5f0bf4237ca3f7bAndreas Gampe                        const char* name = kInstructionSimplifierPassName)
414fa13f65ece3b68fe3d8722d679ebab8656bbf99Roland Levillain      : HOptimization(graph, name, stats) {}
423c04974a90b0e03f4b509010bff49f0b2a3da57fNicolas Geoffray
437c3952f423b8213083d60596a5f0bf4237ca3f7bAndreas Gampe  static constexpr const char* kInstructionSimplifierPassName = "instruction_simplifier";
447c3952f423b8213083d60596a5f0bf4237ca3f7bAndreas Gampe
455e6916cea259897baaca019c5c7a5d05746306edNicolas Geoffray  void Run() OVERRIDE;
46a3a3c5943522e7325d60cfcbdd17aff1e138f53dVladimir Marko
47a3a3c5943522e7325d60cfcbdd17aff1e138f53dVladimir Marko private:
48a3a3c5943522e7325d60cfcbdd17aff1e138f53dVladimir Marko  DISALLOW_COPY_AND_ASSIGN(InstructionSimplifier);
493c04974a90b0e03f4b509010bff49f0b2a3da57fNicolas Geoffray};
503c04974a90b0e03f4b509010bff49f0b2a3da57fNicolas Geoffray
513c04974a90b0e03f4b509010bff49f0b2a3da57fNicolas Geoffray}  // namespace art
523c04974a90b0e03f4b509010bff49f0b2a3da57fNicolas Geoffray
533c04974a90b0e03f4b509010bff49f0b2a3da57fNicolas Geoffray#endif  // ART_COMPILER_OPTIMIZING_INSTRUCTION_SIMPLIFIER_H_
54