blob: f17ba3bbacd4dc0f81aacbe15e9f73a6a09be730 [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
Ian Rogers0279ebb2014-10-08 17:27:48 -070020#include "base/value_object.h"
Nicolas Geoffrayf635e632014-05-14 09:43:38 +010021
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 Geoffrayd31cf3d2014-09-08 17:30:24 +010028// TODO: Create an analysis/optimization abstraction.
Nicolas Geoffray86dbb9a2014-06-04 11:12:39 +010029static const char* kLivenessPassName = "liveness";
30static const char* kRegisterAllocatorPassName = "register";
Nicolas Geoffrayd31cf3d2014-09-08 17:30:24 +010031static const char* kGVNPassName = "gvn";
Nicolas Geoffray86dbb9a2014-06-04 11:12:39 +010032
Nicolas Geoffrayf635e632014-05-14 09:43:38 +010033/**
34 * If enabled, emits compilation information suitable for the c1visualizer tool
35 * and IRHydra.
36 * Currently only works if the compiler is single threaded.
37 */
38class HGraphVisualizer : public ValueObject {
39 public:
40 /**
41 * If output is not null, and the method name of the dex compilation
42 * unit contains `string_filter`, the compilation information will be
43 * emitted.
44 */
45 HGraphVisualizer(std::ostream* output,
46 HGraph* graph,
47 const char* string_filter,
Nicolas Geoffraya7062e02014-05-22 12:50:17 +010048 const CodeGenerator& codegen,
Nicolas Geoffrayf635e632014-05-14 09:43:38 +010049 const DexCompilationUnit& cu);
50
51 /**
Nicolas Geoffray0d3f5782014-05-14 09:43:38 +010052 * Version of `HGraphVisualizer` for unit testing, that is when a
53 * `DexCompilationUnit` is not available.
54 */
Nicolas Geoffraya7062e02014-05-22 12:50:17 +010055 HGraphVisualizer(std::ostream* output,
56 HGraph* graph,
57 const CodeGenerator& codegen,
58 const char* name);
Nicolas Geoffray0d3f5782014-05-14 09:43:38 +010059
60 /**
Nicolas Geoffrayf635e632014-05-14 09:43:38 +010061 * If this visualizer is enabled, emit the compilation information
62 * in `output_`.
63 */
Nicolas Geoffray1ddbf6d2014-10-01 14:59:23 +000064 void DumpGraph(const char* pass_name);
Nicolas Geoffrayf635e632014-05-14 09:43:38 +010065
66 private:
67 std::ostream* const output_;
68 HGraph* const graph_;
Nicolas Geoffraya7062e02014-05-22 12:50:17 +010069 const CodeGenerator& codegen_;
Nicolas Geoffrayf635e632014-05-14 09:43:38 +010070
71 // Is true when `output_` is not null, and the compiled method's name
72 // contains the string_filter given in the constructor.
73 bool is_enabled_;
74
75 DISALLOW_COPY_AND_ASSIGN(HGraphVisualizer);
76};
77
78} // namespace art
79
80#endif // ART_COMPILER_OPTIMIZING_GRAPH_VISUALIZER_H_