blob: d9e082a7f3fb6c2acad2d17300c70fde0e2a9239 [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
David Brazdil5e8b1372015-01-23 14:39:08 +000024static const char* kBuilderPassName = "builder";
25static const char* kSsaBuilderPassName = "ssa_builder";
Nicolas Geoffray82091da2015-01-26 10:02:45 +000026static const char* kLivenessPassName = "liveness";
27static const char* kRegisterAllocatorPassName = "register";
28static const char* kLoopInvariantCodeMotionPassName = "licm";
29
Roland Levillain75be2832014-10-17 17:02:00 +010030/**
31 * Abstraction to implement an optimization pass.
32 */
33class HOptimization : public ValueObject {
34 public:
35 HOptimization(HGraph* graph,
36 bool is_in_ssa_form,
Nicolas Geoffray5e6916c2014-11-18 16:53:35 +000037 const char* pass_name)
Roland Levillain75be2832014-10-17 17:02:00 +010038 : graph_(graph),
39 is_in_ssa_form_(is_in_ssa_form),
Nicolas Geoffray5e6916c2014-11-18 16:53:35 +000040 pass_name_(pass_name) {}
Roland Levillain75be2832014-10-17 17:02:00 +010041
42 virtual ~HOptimization() {}
43
Roland Levillain75be2832014-10-17 17:02:00 +010044 // Return the name of the pass.
45 const char* GetPassName() const { return pass_name_; }
46
47 // Peform the analysis itself.
48 virtual void Run() = 0;
49
Roland Levillain75be2832014-10-17 17:02:00 +010050 // Verify the graph; abort if it is not valid.
51 void Check();
52
53 protected:
54 HGraph* const graph_;
55
56 private:
57 // Does the analyzed graph use the SSA form?
58 const bool is_in_ssa_form_;
59 // Optimization pass name.
60 const char* pass_name_;
Roland Levillain75be2832014-10-17 17:02:00 +010061
62 DISALLOW_COPY_AND_ASSIGN(HOptimization);
63};
64
65} // namespace art
66
67#endif // ART_COMPILER_OPTIMIZING_OPTIMIZATION_H_