blob: 9315d89a4a0d92bbff27e6baa2062e9627772024 [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
Nicolas Geoffray82091da2015-01-26 10:02:45 +000024static const char* kLivenessPassName = "liveness";
25static const char* kRegisterAllocatorPassName = "register";
26static const char* kLoopInvariantCodeMotionPassName = "licm";
27
Roland Levillain75be2832014-10-17 17:02:00 +010028/**
29 * Abstraction to implement an optimization pass.
30 */
31class HOptimization : public ValueObject {
32 public:
33 HOptimization(HGraph* graph,
34 bool is_in_ssa_form,
Nicolas Geoffray5e6916c2014-11-18 16:53:35 +000035 const char* pass_name)
Roland Levillain75be2832014-10-17 17:02:00 +010036 : graph_(graph),
37 is_in_ssa_form_(is_in_ssa_form),
Nicolas Geoffray5e6916c2014-11-18 16:53:35 +000038 pass_name_(pass_name) {}
Roland Levillain75be2832014-10-17 17:02:00 +010039
40 virtual ~HOptimization() {}
41
Roland Levillain75be2832014-10-17 17:02:00 +010042 // Return the name of the pass.
43 const char* GetPassName() const { return pass_name_; }
44
45 // Peform the analysis itself.
46 virtual void Run() = 0;
47
Roland Levillain75be2832014-10-17 17:02:00 +010048 // Verify the graph; abort if it is not valid.
49 void Check();
50
51 protected:
52 HGraph* const graph_;
53
54 private:
55 // Does the analyzed graph use the SSA form?
56 const bool is_in_ssa_form_;
57 // Optimization pass name.
58 const char* pass_name_;
Roland Levillain75be2832014-10-17 17:02:00 +010059
60 DISALLOW_COPY_AND_ASSIGN(HOptimization);
61};
62
63} // namespace art
64
65#endif // ART_COMPILER_OPTIMIZING_OPTIMIZATION_H_