blob: 7cd74e9b7a81546a2df2dd97e85e43880dd5c809 [file] [log] [blame]
Nicolas Geoffrayf635e632014-05-14 09:43:38 +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_GRAPH_VISUALIZER_H_
18#define ART_COMPILER_OPTIMIZING_GRAPH_VISUALIZER_H_
19
20#include "utils/allocation.h"
21
22namespace art {
23
Nicolas Geoffraya7062e02014-05-22 12:50:17 +010024class CodeGenerator;
Nicolas Geoffrayf635e632014-05-14 09:43:38 +010025class DexCompilationUnit;
26class HGraph;
27
Nicolas Geoffray86dbb9a2014-06-04 11:12:39 +010028static const char* kLivenessPassName = "liveness";
29static const char* kRegisterAllocatorPassName = "register";
30
Nicolas Geoffrayf635e632014-05-14 09:43:38 +010031/**
32 * If enabled, emits compilation information suitable for the c1visualizer tool
33 * and IRHydra.
34 * Currently only works if the compiler is single threaded.
35 */
36class HGraphVisualizer : public ValueObject {
37 public:
38 /**
39 * If output is not null, and the method name of the dex compilation
40 * unit contains `string_filter`, the compilation information will be
41 * emitted.
42 */
43 HGraphVisualizer(std::ostream* output,
44 HGraph* graph,
45 const char* string_filter,
Nicolas Geoffraya7062e02014-05-22 12:50:17 +010046 const CodeGenerator& codegen,
Nicolas Geoffrayf635e632014-05-14 09:43:38 +010047 const DexCompilationUnit& cu);
48
49 /**
Nicolas Geoffray0d3f5782014-05-14 09:43:38 +010050 * Version of `HGraphVisualizer` for unit testing, that is when a
51 * `DexCompilationUnit` is not available.
52 */
Nicolas Geoffraya7062e02014-05-22 12:50:17 +010053 HGraphVisualizer(std::ostream* output,
54 HGraph* graph,
55 const CodeGenerator& codegen,
56 const char* name);
Nicolas Geoffray0d3f5782014-05-14 09:43:38 +010057
58 /**
Nicolas Geoffrayf635e632014-05-14 09:43:38 +010059 * If this visualizer is enabled, emit the compilation information
60 * in `output_`.
61 */
62 void DumpGraph(const char* pass_name);
63
64 private:
65 std::ostream* const output_;
66 HGraph* const graph_;
Nicolas Geoffraya7062e02014-05-22 12:50:17 +010067 const CodeGenerator& codegen_;
Nicolas Geoffrayf635e632014-05-14 09:43:38 +010068
69 // Is true when `output_` is not null, and the compiled method's name
70 // contains the string_filter given in the constructor.
71 bool is_enabled_;
72
73 DISALLOW_COPY_AND_ASSIGN(HGraphVisualizer);
74};
75
76} // namespace art
77
78#endif // ART_COMPILER_OPTIMIZING_GRAPH_VISUALIZER_H_