blob: e36ef198b6069b8803312c875051583612798373 [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
Roland Levillain75be2832014-10-17 17:02:00 +010020#include "nodes.h"
21
22namespace art {
23
24/**
25 * Abstraction to implement an optimization pass.
26 */
27class HOptimization : public ValueObject {
28 public:
29 HOptimization(HGraph* graph,
30 bool is_in_ssa_form,
Nicolas Geoffray5e6916c2014-11-18 16:53:35 +000031 const char* pass_name)
Roland Levillain75be2832014-10-17 17:02:00 +010032 : graph_(graph),
33 is_in_ssa_form_(is_in_ssa_form),
Nicolas Geoffray5e6916c2014-11-18 16:53:35 +000034 pass_name_(pass_name) {}
Roland Levillain75be2832014-10-17 17:02:00 +010035
36 virtual ~HOptimization() {}
37
Roland Levillain75be2832014-10-17 17:02:00 +010038 // Return the name of the pass.
39 const char* GetPassName() const { return pass_name_; }
40
41 // Peform the analysis itself.
42 virtual void Run() = 0;
43
Roland Levillain75be2832014-10-17 17:02:00 +010044 // Verify the graph; abort if it is not valid.
45 void Check();
46
47 protected:
48 HGraph* const graph_;
49
50 private:
51 // Does the analyzed graph use the SSA form?
52 const bool is_in_ssa_form_;
53 // Optimization pass name.
54 const char* pass_name_;
Roland Levillain75be2832014-10-17 17:02:00 +010055
56 DISALLOW_COPY_AND_ASSIGN(HOptimization);
57};
58
59} // namespace art
60
61#endif // ART_COMPILER_OPTIMIZING_OPTIMIZATION_H_