Roland Levillain | 75be283 | 2014-10-17 17:02:00 +0100 | [diff] [blame] | 1 | /* |
| 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 Levillain | 75be283 | 2014-10-17 17:02:00 +0100 | [diff] [blame] | 20 | #include "nodes.h" |
| 21 | |
| 22 | namespace art { |
| 23 | |
David Brazdil | 5e8b137 | 2015-01-23 14:39:08 +0000 | [diff] [blame] | 24 | static const char* kBuilderPassName = "builder"; |
| 25 | static const char* kSsaBuilderPassName = "ssa_builder"; |
Nicolas Geoffray | 82091da | 2015-01-26 10:02:45 +0000 | [diff] [blame] | 26 | static const char* kLivenessPassName = "liveness"; |
| 27 | static const char* kRegisterAllocatorPassName = "register"; |
| 28 | static const char* kLoopInvariantCodeMotionPassName = "licm"; |
| 29 | |
Roland Levillain | 75be283 | 2014-10-17 17:02:00 +0100 | [diff] [blame] | 30 | /** |
| 31 | * Abstraction to implement an optimization pass. |
| 32 | */ |
| 33 | class HOptimization : public ValueObject { |
| 34 | public: |
| 35 | HOptimization(HGraph* graph, |
| 36 | bool is_in_ssa_form, |
Nicolas Geoffray | 5e6916c | 2014-11-18 16:53:35 +0000 | [diff] [blame] | 37 | const char* pass_name) |
Roland Levillain | 75be283 | 2014-10-17 17:02:00 +0100 | [diff] [blame] | 38 | : graph_(graph), |
| 39 | is_in_ssa_form_(is_in_ssa_form), |
Nicolas Geoffray | 5e6916c | 2014-11-18 16:53:35 +0000 | [diff] [blame] | 40 | pass_name_(pass_name) {} |
Roland Levillain | 75be283 | 2014-10-17 17:02:00 +0100 | [diff] [blame] | 41 | |
| 42 | virtual ~HOptimization() {} |
| 43 | |
Roland Levillain | 75be283 | 2014-10-17 17:02:00 +0100 | [diff] [blame] | 44 | // 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 Levillain | 75be283 | 2014-10-17 17:02:00 +0100 | [diff] [blame] | 50 | // 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 Levillain | 75be283 | 2014-10-17 17:02:00 +0100 | [diff] [blame] | 61 | |
| 62 | DISALLOW_COPY_AND_ASSIGN(HOptimization); |
| 63 | }; |
| 64 | |
| 65 | } // namespace art |
| 66 | |
| 67 | #endif // ART_COMPILER_OPTIMIZING_OPTIMIZATION_H_ |