1 /*
2 * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
46 };
47
48
49 outputStream* output() { assert(_output != NULL, ""); return _output; }
50
51 void inc_indent();
52 void dec_indent();
53 void print(const char* format, ...) ATTRIBUTE_PRINTF(2, 3);
54 void print_begin(const char* tag);
55 void print_end(const char* tag);
56
57 char* method_name(ciMethod* method, bool short_name = false);
58
59 public:
60 CFGPrinterOutput();
61
62 void set_compilation(Compilation* compilation) { _compilation = compilation; }
63 void set_print_flags(bool do_print_HIR, bool do_print_LIR) { _do_print_HIR = do_print_HIR; _do_print_LIR = do_print_LIR; }
64
65 void print_compilation();
66 void print_intervals(IntervalList* intervals, const char* name);
67
68 void print_state(BlockBegin* block);
69 void print_operand(Value instr);
70 void print_HIR(Value instr);
71 void print_HIR(BlockBegin* block);
72 void print_LIR(BlockBegin* block);
73 void print_block(BlockBegin* block);
74 void print_cfg(BlockList* blocks, const char* name);
75 void print_cfg(IR* blocks, const char* name);
76 };
77
78 CFGPrinterOutput* CFGPrinter::_output = NULL;
79
80
81
82
83 void CFGPrinter::print_compilation(Compilation* compilation) {
84 if (_output == NULL) {
85 _output = new CFGPrinterOutput();
86 }
87 output()->set_compilation(compilation);
88 output()->print_compilation();
89 }
90
91 void CFGPrinter::print_cfg(BlockList* blocks, const char* name, bool do_print_HIR, bool do_print_LIR) {
92 output()->set_print_flags(do_print_HIR, do_print_LIR);
93 output()->print_cfg(blocks, name);
94 }
95
96 void CFGPrinter::print_cfg(IR* blocks, const char* name, bool do_print_HIR, bool do_print_LIR) {
97 output()->set_print_flags(do_print_HIR, do_print_LIR);
98 output()->print_cfg(blocks, name);
99 }
100
101
102 void CFGPrinter::print_intervals(IntervalList* intervals, const char* name) {
103 output()->print_intervals(intervals, name);
104 }
105
106
107
108 CFGPrinterOutput::CFGPrinterOutput()
109 : _output(new(ResourceObj::C_HEAP, mtCompiler) fileStream("output.cfg"))
110 {
111 }
112
113
114
115 void CFGPrinterOutput::inc_indent() {
116 output()->inc();
117 output()->inc();
118 }
119
120 void CFGPrinterOutput::dec_indent() {
121 output()->dec();
122 output()->dec();
351 blocks->iterate_forward(&print_block);
352
353 print_end("cfg");
354 output()->flush();
355 }
356
357 void CFGPrinterOutput::print_cfg(IR* blocks, const char* name) {
358 print_begin("cfg");
359 print("name \"%s\"", name);
360
361 PrintBlockClosure print_block;
362 blocks->iterate_preorder(&print_block);
363
364 print_end("cfg");
365 output()->flush();
366 }
367
368
369
370
371 void CFGPrinterOutput::print_intervals(IntervalList* intervals, const char* name) {
372 print_begin("intervals");
373 print("name \"%s\"", name);
374
375 for (int i = 0; i < intervals->length(); i++) {
376 if (intervals->at(i) != NULL) {
377 intervals->at(i)->print(output());
378 }
379 }
380
381 print_end("intervals");
382 output()->flush();
383 }
384
385
386 #endif
|
1 /*
2 * Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
46 };
47
48
49 outputStream* output() { assert(_output != NULL, ""); return _output; }
50
51 void inc_indent();
52 void dec_indent();
53 void print(const char* format, ...) ATTRIBUTE_PRINTF(2, 3);
54 void print_begin(const char* tag);
55 void print_end(const char* tag);
56
57 char* method_name(ciMethod* method, bool short_name = false);
58
59 public:
60 CFGPrinterOutput();
61
62 void set_compilation(Compilation* compilation) { _compilation = compilation; }
63 void set_print_flags(bool do_print_HIR, bool do_print_LIR) { _do_print_HIR = do_print_HIR; _do_print_LIR = do_print_LIR; }
64
65 void print_compilation();
66 void print_intervals(GrowableArray<Interval*>* intervals, const char* name);
67
68 void print_state(BlockBegin* block);
69 void print_operand(Value instr);
70 void print_HIR(Value instr);
71 void print_HIR(BlockBegin* block);
72 void print_LIR(BlockBegin* block);
73 void print_block(BlockBegin* block);
74 void print_cfg(BlockList* blocks, const char* name);
75 void print_cfg(IR* blocks, const char* name);
76 };
77
78 CFGPrinterOutput* CFGPrinter::_output = NULL;
79
80
81
82
83 void CFGPrinter::print_compilation(Compilation* compilation) {
84 if (_output == NULL) {
85 _output = new CFGPrinterOutput();
86 }
87 output()->set_compilation(compilation);
88 output()->print_compilation();
89 }
90
91 void CFGPrinter::print_cfg(BlockList* blocks, const char* name, bool do_print_HIR, bool do_print_LIR) {
92 output()->set_print_flags(do_print_HIR, do_print_LIR);
93 output()->print_cfg(blocks, name);
94 }
95
96 void CFGPrinter::print_cfg(IR* blocks, const char* name, bool do_print_HIR, bool do_print_LIR) {
97 output()->set_print_flags(do_print_HIR, do_print_LIR);
98 output()->print_cfg(blocks, name);
99 }
100
101
102 void CFGPrinter::print_intervals(GrowableArray<Interval*>* intervals, const char* name) {
103 output()->print_intervals(intervals, name);
104 }
105
106
107
108 CFGPrinterOutput::CFGPrinterOutput()
109 : _output(new(ResourceObj::C_HEAP, mtCompiler) fileStream("output.cfg"))
110 {
111 }
112
113
114
115 void CFGPrinterOutput::inc_indent() {
116 output()->inc();
117 output()->inc();
118 }
119
120 void CFGPrinterOutput::dec_indent() {
121 output()->dec();
122 output()->dec();
351 blocks->iterate_forward(&print_block);
352
353 print_end("cfg");
354 output()->flush();
355 }
356
357 void CFGPrinterOutput::print_cfg(IR* blocks, const char* name) {
358 print_begin("cfg");
359 print("name \"%s\"", name);
360
361 PrintBlockClosure print_block;
362 blocks->iterate_preorder(&print_block);
363
364 print_end("cfg");
365 output()->flush();
366 }
367
368
369
370
371 void CFGPrinterOutput::print_intervals(GrowableArray<Interval*>* intervals, const char* name) {
372 print_begin("intervals");
373 print("name \"%s\"", name);
374
375 for (int i = 0; i < intervals->length(); i++) {
376 if (intervals->at(i) != NULL) {
377 intervals->at(i)->print(output());
378 }
379 }
380
381 print_end("intervals");
382 output()->flush();
383 }
384
385
386 #endif
|