blob: 4d8bec2422c2e7ea789f6c1f915b8da068b54be7 [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 Rogerscf7f1912014-10-22 22:06:39 -070020#include <ostream>
21
Ian Rogers0279ebb2014-10-08 17:27:48 -070022#include "base/value_object.h"
Nicolas Geoffrayf635e632014-05-14 09:43:38 +010023
24namespace art {
25
Nicolas Geoffraya7062e02014-05-22 12:50:17 +010026class CodeGenerator;
Nicolas Geoffrayf635e632014-05-14 09:43:38 +010027class DexCompilationUnit;
28class HGraph;
29
Nicolas Geoffrayd31cf3d2014-09-08 17:30:24 +010030// TODO: Create an analysis/optimization abstraction.
Nicolas Geoffray86dbb9a2014-06-04 11:12:39 +010031static const char* kLivenessPassName = "liveness";
32static const char* kRegisterAllocatorPassName = "register";
Nicolas Geoffrayd31cf3d2014-09-08 17:30:24 +010033static const char* kGVNPassName = "gvn";
Nicolas Geoffray86dbb9a2014-06-04 11:12:39 +010034
Nicolas Geoffrayf635e632014-05-14 09:43:38 +010035/**
36 * If enabled, emits compilation information suitable for the c1visualizer tool
37 * and IRHydra.
38 * Currently only works if the compiler is single threaded.
39 */
40class HGraphVisualizer : public ValueObject {
41 public:
42 /**
43 * If output is not null, and the method name of the dex compilation
44 * unit contains `string_filter`, the compilation information will be
45 * emitted.
46 */
47 HGraphVisualizer(std::ostream* output,
48 HGraph* graph,
49 const char* string_filter,
Nicolas Geoffraya7062e02014-05-22 12:50:17 +010050 const CodeGenerator& codegen,
Nicolas Geoffrayf635e632014-05-14 09:43:38 +010051 const DexCompilationUnit& cu);
52
53 /**
Nicolas Geoffray0d3f5782014-05-14 09:43:38 +010054 * Version of `HGraphVisualizer` for unit testing, that is when a
55 * `DexCompilationUnit` is not available.
56 */
Nicolas Geoffraya7062e02014-05-22 12:50:17 +010057 HGraphVisualizer(std::ostream* output,
58 HGraph* graph,
59 const CodeGenerator& codegen,
60 const char* name);
Nicolas Geoffray0d3f5782014-05-14 09:43:38 +010061
62 /**
Nicolas Geoffrayf635e632014-05-14 09:43:38 +010063 * If this visualizer is enabled, emit the compilation information
64 * in `output_`.
65 */
Roland Levillain75be2832014-10-17 17:02:00 +010066 void DumpGraph(const char* pass_name) const;
Nicolas Geoffrayf635e632014-05-14 09:43:38 +010067
68 private:
69 std::ostream* const output_;
70 HGraph* const graph_;
Nicolas Geoffraya7062e02014-05-22 12:50:17 +010071 const CodeGenerator& codegen_;
Nicolas Geoffrayf635e632014-05-14 09:43:38 +010072
73 // Is true when `output_` is not null, and the compiled method's name
74 // contains the string_filter given in the constructor.
75 bool is_enabled_;
76
77 DISALLOW_COPY_AND_ASSIGN(HGraphVisualizer);
78};
79
80} // namespace art
81
82#endif // ART_COMPILER_OPTIMIZING_GRAPH_VISUALIZER_H_