MCPcopy Create free account
hub / github.com/SeaOfNodes/Simple / dump

Method dump

chapter24/src/test/java/com/seaofnodes/simple/Simple.java:79–120  ·  view source on GitHub ↗
(CodeGen code, int dump, int pass)

Source from the content-addressed store, hash-verified

77 }
78
79 static void dump(CodeGen code, int dump, int pass) {
80 if ((dump & pass) != 0) {
81 if ((dump & DUMP_DOT) != 0) {
82 String fn = switch (pass) {
83 case DUMP_AFTER_PARSE -> "01-parse.dot";
84 case DUMP_AFTER_OPTO -> "02-opto.dot";
85 case DUMP_AFTER_TYPE_CHECK -> "03-type_check.dot";
86 case DUMP_AFTER_LOOP_TREE -> "04-loop_tree.dot";
87 case DUMP_AFTER_SELECT -> "05-instr_select.dot";
88 case DUMP_AFTER_GCM -> "06-gcm.dot";
89 case DUMP_AFTER_LOCAL_SCHED -> "07-local_sched.dot";
90 case DUMP_AFTER_REG_ALLOC -> "08-reg_allos.dot";
91 case DUMP_AFTER_ENCODE -> "09-local_sched.dot";
92 case DUMP_FINAL -> "10-final.dot";
93 default -> throw Utils.TODO();
94 };
95
96 try {
97 Files.writeString(Path.of(fn),
98 new GraphVisualizer().generateDotOutput(code._stop, null, null));
99 } catch(IOException e) { throw bad("Cannot write DOT file"); }
100 } else {
101 if ((dump & DUMP_PASS_NAME) != 0) {
102 System.err.println(switch (pass) {
103 case DUMP_AFTER_PARSE -> "After Parse:";
104 case DUMP_AFTER_OPTO -> "After OPTO:";
105 case DUMP_AFTER_TYPE_CHECK -> "After Type Check:";
106 case DUMP_AFTER_LOOP_TREE -> "After Loop Tree:";
107 case DUMP_AFTER_SELECT -> "After Code Selection:";
108 case DUMP_AFTER_GCM -> "After GCM:";
109 case DUMP_AFTER_LOCAL_SCHED -> "After Local Scheduling:";
110 case DUMP_AFTER_REG_ALLOC -> "After Register Allocation:";
111 case DUMP_AFTER_ENCODE -> "After Encoding:";
112 case DUMP_FINAL -> "Final:";
113 default -> throw Utils.TODO();
114 });
115 }
116
117 System.err.println(IRPrinter.prettyPrint(code._stop, 9999));
118 }
119 }
120 }
121
122 static void print_compilation_times(CodeGen code) {
123 double t, total = 0;

Callers 1

mainMethod · 0.95

Calls 4

TODOMethod · 0.95
badMethod · 0.95
prettyPrintMethod · 0.95
generateDotOutputMethod · 0.45

Tested by

no test coverage detected