Nicolas Geoffray | f635e63 | 2014-05-14 09:43:38 +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_GRAPH_VISUALIZER_H_ |
| 18 | #define ART_COMPILER_OPTIMIZING_GRAPH_VISUALIZER_H_ |
| 19 | |
Ian Rogers | cf7f191 | 2014-10-22 22:06:39 -0700 | [diff] [blame] | 20 | #include <ostream> |
| 21 | |
Ian Rogers | 0279ebb | 2014-10-08 17:27:48 -0700 | [diff] [blame] | 22 | #include "base/value_object.h" |
Nicolas Geoffray | f635e63 | 2014-05-14 09:43:38 +0100 | [diff] [blame] | 23 | |
| 24 | namespace art { |
| 25 | |
Nicolas Geoffray | a7062e0 | 2014-05-22 12:50:17 +0100 | [diff] [blame] | 26 | class CodeGenerator; |
Nicolas Geoffray | f635e63 | 2014-05-14 09:43:38 +0100 | [diff] [blame] | 27 | class DexCompilationUnit; |
| 28 | class HGraph; |
| 29 | |
Nicolas Geoffray | d31cf3d | 2014-09-08 17:30:24 +0100 | [diff] [blame] | 30 | // TODO: Create an analysis/optimization abstraction. |
Nicolas Geoffray | 86dbb9a | 2014-06-04 11:12:39 +0100 | [diff] [blame] | 31 | static const char* kLivenessPassName = "liveness"; |
| 32 | static const char* kRegisterAllocatorPassName = "register"; |
| 33 | |
Nicolas Geoffray | f635e63 | 2014-05-14 09:43:38 +0100 | [diff] [blame] | 34 | /** |
| 35 | * If enabled, emits compilation information suitable for the c1visualizer tool |
| 36 | * and IRHydra. |
| 37 | * Currently only works if the compiler is single threaded. |
| 38 | */ |
| 39 | class HGraphVisualizer : public ValueObject { |
| 40 | public: |
| 41 | /** |
| 42 | * If output is not null, and the method name of the dex compilation |
| 43 | * unit contains `string_filter`, the compilation information will be |
| 44 | * emitted. |
| 45 | */ |
| 46 | HGraphVisualizer(std::ostream* output, |
| 47 | HGraph* graph, |
| 48 | const char* string_filter, |
Nicolas Geoffray | a7062e0 | 2014-05-22 12:50:17 +0100 | [diff] [blame] | 49 | const CodeGenerator& codegen, |
Nicolas Geoffray | f635e63 | 2014-05-14 09:43:38 +0100 | [diff] [blame] | 50 | const DexCompilationUnit& cu); |
| 51 | |
| 52 | /** |
Nicolas Geoffray | 0d3f578 | 2014-05-14 09:43:38 +0100 | [diff] [blame] | 53 | * Version of `HGraphVisualizer` for unit testing, that is when a |
| 54 | * `DexCompilationUnit` is not available. |
| 55 | */ |
Nicolas Geoffray | a7062e0 | 2014-05-22 12:50:17 +0100 | [diff] [blame] | 56 | HGraphVisualizer(std::ostream* output, |
| 57 | HGraph* graph, |
| 58 | const CodeGenerator& codegen, |
| 59 | const char* name); |
Nicolas Geoffray | 0d3f578 | 2014-05-14 09:43:38 +0100 | [diff] [blame] | 60 | |
| 61 | /** |
Nicolas Geoffray | f635e63 | 2014-05-14 09:43:38 +0100 | [diff] [blame] | 62 | * If this visualizer is enabled, emit the compilation information |
| 63 | * in `output_`. |
| 64 | */ |
Roland Levillain | 75be283 | 2014-10-17 17:02:00 +0100 | [diff] [blame] | 65 | void DumpGraph(const char* pass_name) const; |
Nicolas Geoffray | f635e63 | 2014-05-14 09:43:38 +0100 | [diff] [blame] | 66 | |
| 67 | private: |
| 68 | std::ostream* const output_; |
| 69 | HGraph* const graph_; |
Nicolas Geoffray | a7062e0 | 2014-05-22 12:50:17 +0100 | [diff] [blame] | 70 | const CodeGenerator& codegen_; |
Nicolas Geoffray | f635e63 | 2014-05-14 09:43:38 +0100 | [diff] [blame] | 71 | |
| 72 | // Is true when `output_` is not null, and the compiled method's name |
| 73 | // contains the string_filter given in the constructor. |
| 74 | bool is_enabled_; |
| 75 | |
| 76 | DISALLOW_COPY_AND_ASSIGN(HGraphVisualizer); |
| 77 | }; |
| 78 | |
| 79 | } // namespace art |
| 80 | |
| 81 | #endif // ART_COMPILER_OPTIMIZING_GRAPH_VISUALIZER_H_ |