summaryrefslogtreecommitdiff
path: root/chapter23/src/test/java
diff options
context:
space:
mode:
authorCliff Click <cliffc@acm.org>2026-09-22 11:25:05 -0700
committerCliff Click <cliffc@acm.org>2026-09-22 11:25:05 -0700
commit29fb671e69f90ad3b04c6fa8d746caf857f89e77 (patch)
tree2f39d082f8a6de6a2b60b66406f8c9f0190d25c2 /chapter23/src/test/java
parent1d961838cff168a101069d08a8ab6594f49f0911 (diff)
downloadSimple-29fb671e69f90ad3b04c6fa8d746caf857f89e77.tar.gz
Simple-29fb671e69f90ad3b04c6fa8d746caf857f89e77.zip
Add shared graph viewer to all chapters
Diffstat (limited to 'chapter23/src/test/java')
-rw-r--r--chapter23/src/test/java/com/seaofnodes/simple/Simple.java58
1 files changed, 17 insertions, 41 deletions
diff --git a/chapter23/src/test/java/com/seaofnodes/simple/Simple.java b/chapter23/src/test/java/com/seaofnodes/simple/Simple.java
index f765d939..aef810d1 100644
--- a/chapter23/src/test/java/com/seaofnodes/simple/Simple.java
+++ b/chapter23/src/test/java/com/seaofnodes/simple/Simple.java
@@ -25,10 +25,8 @@ public class Simple {
static final int DUMP_FINAL = 1<<16;
- static final int DUMP_DOT = 1<<29;
static final int DUMP_PASS_NAME = 1<<30;
static final int DUMP_AFTER_ALL = 0xff | DUMP_PASS_NAME;
- static final int DUMP_DOT_AFTER_ALL = 0xff | DUMP_DOT;
static final int DUMP_DISASSEMBLE = 1<<31;
@@ -47,7 +45,6 @@ Options:
--dump-after-reg-alloc - dump intermediate representation after register allocation pass
--dump-after-encode - dump intermediate representation after encoding pass
--dump-after-all - dump intermediate representation after all passes
- --dot - dump grapical representation of intermediate code into *.dot file(s)
-S - dump generated assembler code
--eval - evaluate the compiled code in emulator
--run - run the compiled code natively; this is the default
@@ -78,44 +75,24 @@ Options:
static void dump(CodeGen code, int dump, int pass) {
if ((dump & pass) != 0) {
- if ((dump & DUMP_DOT) != 0) {
- String fn = switch (pass) {
- case DUMP_AFTER_PARSE -> "01-parse.dot";
- case DUMP_AFTER_OPTO -> "02-opto.dot";
- case DUMP_AFTER_TYPE_CHECK -> "03-type_check.dot";
- case DUMP_AFTER_LOOP_TREE -> "04-loop_tree.dot";
- case DUMP_AFTER_SELECT -> "05-instr_select.dot";
- case DUMP_AFTER_GCM -> "06-gcm.dot";
- case DUMP_AFTER_LOCAL_SCHED -> "07-local_sched.dot";
- case DUMP_AFTER_REG_ALLOC -> "08-reg_allos.dot";
- case DUMP_AFTER_ENCODE -> "09-local_sched.dot";
- case DUMP_FINAL -> "10-final.dot";
- default -> throw Utils.TODO();
- };
-
- try {
- Files.writeString(Path.of(fn),
- new GraphVisualizer().generateDotOutput(code._stop, null, null));
- } catch(IOException e) { throw bad("Cannot write DOT file"); }
- } else {
- if ((dump & DUMP_PASS_NAME) != 0) {
- System.err.println(switch (pass) {
- case DUMP_AFTER_PARSE -> "After Parse:";
- case DUMP_AFTER_OPTO -> "After OPTO:";
- case DUMP_AFTER_TYPE_CHECK -> "After Type Check:";
- case DUMP_AFTER_LOOP_TREE -> "After Loop Tree:";
- case DUMP_AFTER_SELECT -> "After Code Selection:";
- case DUMP_AFTER_GCM -> "After GCM:";
- case DUMP_AFTER_LOCAL_SCHED -> "After Local Scheduling:";
- case DUMP_AFTER_REG_ALLOC -> "After Register Allocation:";
- case DUMP_AFTER_ENCODE -> "After Encoding:";
- case DUMP_FINAL -> "Final:";
- default -> throw Utils.TODO();
- });
- }
-
- System.err.println(IRPrinter.prettyPrint(code._stop, 9999));
+ if ((dump & DUMP_PASS_NAME) != 0) {
+ System.err.println(switch (pass) {
+ case DUMP_AFTER_PARSE -> "After Parse:";
+ case DUMP_AFTER_OPTO -> "After OPTO:";
+ case DUMP_AFTER_TYPE_CHECK -> "After Type Check:";
+ case DUMP_AFTER_LOOP_TREE -> "After Loop Tree:";
+ case DUMP_AFTER_SELECT -> "After Code Selection:";
+ case DUMP_AFTER_GCM -> "After GCM:";
+ case DUMP_AFTER_LOCAL_SCHED -> "After Local Scheduling:";
+ case DUMP_AFTER_REG_ALLOC -> "After Register Allocation:";
+ case DUMP_AFTER_ENCODE -> "After Encoding:";
+ case DUMP_FINAL -> "Final:";
+ default -> throw Utils.TODO();
+ });
}
+
+ System.err.println(IRPrinter.prettyPrint(code._stop, 9999));
+
}
}
@@ -183,7 +160,6 @@ Options:
case "--dump-after-reg-alloc": dump |= DUMP_AFTER_REG_ALLOC; break;
case "--dump-after-encode": dump |= DUMP_AFTER_ENCODE; break;
case "--dump-after-all": dump |= DUMP_AFTER_ALL; break;
- case "--dot": dump |= DUMP_DOT; break;
case "-S": dump |= DUMP_DISASSEMBLE; break;
case "--eval": do_eval = true ; do_run = false; break;
case "--run": do_run = true ; break;