blob: d281248f4a0b5beabad21083cc35008e91fddf2a [file] [log] [blame]
Roland Levillain75be2832014-10-17 17:02:00 +01001/*
2 * Copyright (C) 2014 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
17#ifndef ART_COMPILER_OPTIMIZING_OPTIMIZATION_H_
18#define ART_COMPILER_OPTIMIZING_OPTIMIZATION_H_
19
20#include "graph_visualizer.h"
21#include "nodes.h"
22
23namespace art {
24
25/**
26 * Abstraction to implement an optimization pass.
27 */
28class HOptimization : public ValueObject {
29 public:
30 HOptimization(HGraph* graph,
31 bool is_in_ssa_form,
Nicolas Geoffray5e6916c2014-11-18 16:53:35 +000032 const char* pass_name)
Roland Levillain75be2832014-10-17 17:02:00 +010033 : graph_(graph),
34 is_in_ssa_form_(is_in_ssa_form),
Nicolas Geoffray5e6916c2014-11-18 16:53:35 +000035 pass_name_(pass_name) {}
Roland Levillain75be2832014-10-17 17:02:00 +010036
37 virtual ~HOptimization() {}
38
Roland Levillain75be2832014-10-17 17:02:00 +010039 // Return the name of the pass.
40 const char* GetPassName() const { return pass_name_; }
41
42 // Peform the analysis itself.
43 virtual void Run() = 0;
44
Roland Levillain75be2832014-10-17 17:02:00 +010045 // Verify the graph; abort if it is not valid.
46 void Check();
47
48 protected:
49 HGraph* const graph_;
50
51 private:
52 // Does the analyzed graph use the SSA form?
53 const bool is_in_ssa_form_;
54 // Optimization pass name.
55 const char* pass_name_;
Roland Levillain75be2832014-10-17 17:02:00 +010056
57 DISALLOW_COPY_AND_ASSIGN(HOptimization);
58};
59
60} // namespace art
61
62#endif // ART_COMPILER_OPTIMIZING_OPTIMIZATION_H_