Skip to content

Commit 5fe731d

Browse files
committed
8349835: C2: Simplify IGV property printing
Reviewed-by: rcastanedalo, dfenacci, chagedorn
1 parent 275cb9f commit 5fe731d

File tree

2 files changed

+98
-116
lines changed

2 files changed

+98
-116
lines changed

src/hotspot/share/opto/idealGraphPrinter.cpp

Lines changed: 96 additions & 115 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,96 @@
3535

3636
#ifndef PRODUCT
3737

38+
// Support for printing properties
39+
class PrintProperties
40+
{
41+
private:
42+
IdealGraphPrinter* _printer;
43+
44+
public:
45+
PrintProperties(IdealGraphPrinter* printer) : _printer(printer) {}
46+
void print_node_properties(Node* node);
47+
void print_lrg_properties(const LRG& lrg, const char* buffer);
48+
void print_property(int flag, const char* name);
49+
void print_property(int flag, const char* name, const char* val);
50+
void print_property(int flag, const char* name, int val);
51+
};
52+
53+
void PrintProperties::print_node_properties(Node* node) {
54+
const jushort flags = node->flags();
55+
print_property((flags & Node::Flag_is_Copy), "is_copy");
56+
print_property((flags & Node::Flag_rematerialize), "rematerialize");
57+
print_property((flags & Node::Flag_needs_anti_dependence_check), "needs_anti_dependence_check");
58+
print_property((flags & Node::Flag_is_macro), "is_macro");
59+
print_property((flags & Node::Flag_is_Con), "is_con");
60+
print_property((flags & Node::Flag_is_cisc_alternate), "is_cisc_alternate");
61+
print_property((flags & Node::Flag_is_dead_loop_safe), "is_dead_loop_safe");
62+
print_property((flags & Node::Flag_may_be_short_branch), "may_be_short_branch");
63+
print_property((flags & Node::Flag_has_call), "has_call");
64+
print_property((flags & Node::Flag_has_swapped_edges), "has_swapped_edges");
65+
Matcher* matcher = _printer->C->matcher();
66+
if (matcher != nullptr) {
67+
print_property(matcher->is_shared(node),"is_shared");
68+
print_property(!(matcher->is_shared(node)), "is_shared", IdealGraphPrinter::FALSE_VALUE);
69+
print_property(matcher->is_dontcare(node), "is_dontcare");
70+
print_property(!(matcher->is_dontcare(node)),"is_dontcare", IdealGraphPrinter::FALSE_VALUE);
71+
Node* old = matcher->find_old_node(node);
72+
if (old != nullptr) {
73+
print_property(true, "old_node_idx", old->_idx);
74+
}
75+
}
76+
}
77+
78+
void PrintProperties::print_lrg_properties(const LRG &lrg, const char *buffer) {
79+
print_property(true, "mask", buffer);
80+
print_property(true, "mask_size", lrg.mask_size());
81+
if (lrg._degree_valid) {
82+
print_property(true, "degree", lrg.degree());
83+
}
84+
print_property(true, "num_regs", lrg.num_regs());
85+
print_property(true, "reg_pressure", lrg.reg_pressure());
86+
print_property(true, "cost", lrg._cost);
87+
print_property(true, "area", lrg._area);
88+
print_property(true, "score", lrg.score());
89+
print_property((lrg._risk_bias != 0), "risk_bias", lrg._risk_bias);
90+
print_property((lrg._copy_bias != 0), "copy_bias", lrg._copy_bias);
91+
print_property(lrg.is_singledef(), "is_singledef");
92+
print_property(lrg.is_multidef(), "is_multidef");
93+
print_property(lrg._is_oop, "is_oop");
94+
print_property(lrg._is_float, "is_float");
95+
print_property(lrg._is_vector, "is_vector");
96+
print_property(lrg._is_predicate, "is_predicate");
97+
print_property(lrg._is_scalable, "is_scalable");
98+
print_property(lrg._was_spilled1, "was_spilled1");
99+
print_property(lrg._was_spilled2, "was_spilled2");
100+
print_property(lrg._direct_conflict, "direct_conflict");
101+
print_property(lrg._fat_proj, "fat_proj");
102+
print_property(lrg._was_lo, "_was_lo");
103+
print_property(lrg._has_copy, "has_copy");
104+
print_property(lrg._at_risk, "at_risk");
105+
print_property(lrg._must_spill, "must_spill");
106+
print_property(lrg._is_bound, "is_bound");
107+
print_property((lrg._msize_valid && lrg._degree_valid && lrg.lo_degree()), "trivial");
108+
}
109+
110+
void PrintProperties::print_property(int flag, const char* name) {
111+
if (flag != 0) {
112+
_printer->print_prop(name, IdealGraphPrinter::TRUE_VALUE);
113+
}
114+
}
115+
116+
void PrintProperties::print_property(int flag, const char* name, const char* val) {
117+
if (flag != 0) {
118+
_printer->print_prop(name, val);
119+
}
120+
}
121+
122+
void PrintProperties::print_property(int flag, const char* name, int val) {
123+
if (flag != 0) {
124+
_printer->print_prop(name, val);
125+
}
126+
}
127+
38128
// Constants
39129
// Keep consistent with Java constants
40130
const char *IdealGraphPrinter::INDENT = " ";
@@ -522,54 +612,8 @@ void IdealGraphPrinter::visit_node(Node* n, bool edges) {
522612
print_prop("jvms", buffer);
523613
}
524614

525-
const jushort flags = node->flags();
526-
if (flags & Node::Flag_is_Copy) {
527-
print_prop("is_copy", "true");
528-
}
529-
if (flags & Node::Flag_rematerialize) {
530-
print_prop("rematerialize", "true");
531-
}
532-
if (flags & Node::Flag_needs_anti_dependence_check) {
533-
print_prop("needs_anti_dependence_check", "true");
534-
}
535-
if (flags & Node::Flag_is_macro) {
536-
print_prop("is_macro", "true");
537-
}
538-
if (flags & Node::Flag_is_Con) {
539-
print_prop("is_con", "true");
540-
}
541-
if (flags & Node::Flag_is_cisc_alternate) {
542-
print_prop("is_cisc_alternate", "true");
543-
}
544-
if (flags & Node::Flag_is_dead_loop_safe) {
545-
print_prop("is_dead_loop_safe", "true");
546-
}
547-
if (flags & Node::Flag_may_be_short_branch) {
548-
print_prop("may_be_short_branch", "true");
549-
}
550-
if (flags & Node::Flag_has_call) {
551-
print_prop("has_call", "true");
552-
}
553-
if (flags & Node::Flag_has_swapped_edges) {
554-
print_prop("has_swapped_edges", "true");
555-
}
556-
557-
if (C->matcher() != nullptr) {
558-
if (C->matcher()->is_shared(node)) {
559-
print_prop("is_shared", "true");
560-
} else {
561-
print_prop("is_shared", "false");
562-
}
563-
if (C->matcher()->is_dontcare(node)) {
564-
print_prop("is_dontcare", "true");
565-
} else {
566-
print_prop("is_dontcare", "false");
567-
}
568-
Node* old = C->matcher()->find_old_node(node);
569-
if (old != nullptr) {
570-
print_prop("old_node_idx", old->_idx);
571-
}
572-
}
615+
PrintProperties print_node(this);
616+
print_node.print_node_properties(node);
573617

574618
if (node->is_Proj()) {
575619
print_prop("con", (int)node->as_Proj()->_con);
@@ -1145,73 +1189,10 @@ void IdealGraphPrinter::print(const char* name, Node* node, GrowableArray<const
11451189
buffer[0] = 0;
11461190
stringStream lrg_mask_stream(buffer, sizeof(buffer) - 1);
11471191
lrg.mask().dump(&lrg_mask_stream);
1148-
print_prop("mask", buffer);
1149-
print_prop("mask_size", lrg.mask_size());
1150-
if (lrg._degree_valid) {
1151-
print_prop("degree", lrg.degree());
1152-
}
1153-
print_prop("num_regs", lrg.num_regs());
1154-
print_prop("reg_pressure", lrg.reg_pressure());
1155-
print_prop("cost", lrg._cost);
1156-
print_prop("area", lrg._area);
1157-
print_prop("score", lrg.score());
1158-
if (lrg._risk_bias != 0) {
1159-
print_prop("risk_bias", lrg._risk_bias);
1160-
}
1161-
if (lrg._copy_bias != 0) {
1162-
print_prop("copy_bias", lrg._copy_bias);
1163-
}
1164-
if (lrg.is_singledef()) {
1165-
print_prop("is_singledef", TRUE_VALUE);
1166-
}
1167-
if (lrg.is_multidef()) {
1168-
print_prop("is_multidef", TRUE_VALUE);
1169-
}
1170-
if (lrg._is_oop) {
1171-
print_prop("is_oop", TRUE_VALUE);
1172-
}
1173-
if (lrg._is_float) {
1174-
print_prop("is_float", TRUE_VALUE);
1175-
}
1176-
if (lrg._is_vector) {
1177-
print_prop("is_vector", TRUE_VALUE);
1178-
}
1179-
if (lrg._is_predicate) {
1180-
print_prop("is_predicate", TRUE_VALUE);
1181-
}
1182-
if (lrg._is_scalable) {
1183-
print_prop("is_scalable", TRUE_VALUE);
1184-
}
1185-
if (lrg._was_spilled1) {
1186-
print_prop("was_spilled1", TRUE_VALUE);
1187-
}
1188-
if (lrg._was_spilled2) {
1189-
print_prop("was_spilled2", TRUE_VALUE);
1190-
}
1191-
if (lrg._direct_conflict) {
1192-
print_prop("direct_conflict", TRUE_VALUE);
1193-
}
1194-
if (lrg._fat_proj) {
1195-
print_prop("fat_proj", TRUE_VALUE);
1196-
}
1197-
if (lrg._was_lo) {
1198-
print_prop("_was_lo", TRUE_VALUE);
1199-
}
1200-
if (lrg._has_copy) {
1201-
print_prop("has_copy", TRUE_VALUE);
1202-
}
1203-
if (lrg._at_risk) {
1204-
print_prop("at_risk", TRUE_VALUE);
1205-
}
1206-
if (lrg._must_spill) {
1207-
print_prop("must_spill", TRUE_VALUE);
1208-
}
1209-
if (lrg._is_bound) {
1210-
print_prop("is_bound", TRUE_VALUE);
1211-
}
1212-
if (lrg._msize_valid && lrg._degree_valid && lrg.lo_degree()) {
1213-
print_prop("trivial", TRUE_VALUE);
1214-
}
1192+
1193+
PrintProperties print_node(this);
1194+
print_node.print_lrg_properties(lrg, buffer);
1195+
12151196
tail(PROPERTIES_ELEMENT);
12161197
tail(LIVE_RANGE_ELEMENT);
12171198
}

src/hotspot/share/opto/idealGraphPrinter.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,9 @@ class ConnectionGraph;
4646
class Parse;
4747

4848
class IdealGraphPrinter : public CHeapObj<mtCompiler> {
49-
private:
49+
friend class PrintProperties;
5050

51+
private:
5152
static const char *INDENT;
5253
static const char *TOP_ELEMENT;
5354
static const char *GROUP_ELEMENT;

0 commit comments

Comments
 (0)