diff options
| author | Cliff Click <cliffc@acm.org> | 2026-10-18 22:09:58 -0700 |
|---|---|---|
| committer | Cliff Click <cliffc@acm.org> | 2026-10-18 22:09:58 -0700 |
| commit | 300d2a9c3672acacc8bdd8d5370a424651a00571 (patch) | |
| tree | f33d895f6ec4e08692efa4c090c681257553097d /chapter20/src/test/java/com/seaofnodes/simple/PhaseTest.java | |
| parent | 0be52f8dd82f70d4c557fe916d47dc425401f848 (diff) | |
| download | Simple-clinit.tar.gz Simple-clinit.zip | |
Cleanup & backportclinit
The phase rework, made new phases explicit and add them to the CodeGen driver. Fix the flag-spilling on X86 and ARM. Fix the GCM conservative anti-deps and backport.
Diffstat (limited to 'chapter20/src/test/java/com/seaofnodes/simple/PhaseTest.java')
| -rw-r--r-- | chapter20/src/test/java/com/seaofnodes/simple/PhaseTest.java | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/chapter20/src/test/java/com/seaofnodes/simple/PhaseTest.java b/chapter20/src/test/java/com/seaofnodes/simple/PhaseTest.java new file mode 100644 index 00000000..1214ffeb --- /dev/null +++ b/chapter20/src/test/java/com/seaofnodes/simple/PhaseTest.java @@ -0,0 +1,41 @@ +package com.seaofnodes.simple; + +import com.seaofnodes.graph.GraphObserver; +import com.seaofnodes.simple.codegen.CodeGen; +import com.seaofnodes.simple.codegen.CodeGen.Phase; +import com.seaofnodes.simple.node.Node; +import java.util.ArrayList; +import org.junit.Test; +import static org.junit.Assert.*; + +public class PhaseTest { + private static final String SRC = "int sum=0; for(int i=0; i<arg; i++) sum+=i; return sum;"; + + @Test public void testStopAndResume() { + ArrayList<String> phases = new ArrayList<>(); + CodeGen code = new CodeGen(SRC); + code._obs = new GraphObserver<Node>() { + @Override public void before(Node n) {} + @Override public void after(Node n, Node repl, boolean applied) {} + @Override public void phase(String phase) { phases.add(phase); } + }; + code.driver(Phase.Iter); + assertEquals(Phase.Iter,code._phase); + assertEquals("Parse Iter",String.join(" ",phases)); + code.driver(Phase.TypeCheck); + code.driver(Phase.TypeCheck); // Repeated requests do not rerun phases. + code.driver(Phase.LoopTree); + assertEquals(Phase.LoopTree,code._phase); + code.driver(Phase.LocalSched); + assertEquals("Parse Iter TypeCheck LoopTree Schedule LocalSched",String.join(" ",phases)); + assertEquals("45",Eval2.eval(code,10)); + } + + @Test public void testResumeMachineCompilation() { + CodeGen staged = new CodeGen(SRC).driver(Phase.TypeCheck); + staged.driver(Phase.InstSelect,"x86_64_v2","SystemV"); + staged.driver(Phase.RegAlloc,"x86_64_v2","SystemV"); + assertEquals(Phase.RegAlloc,staged._phase); + assertNotNull(staged._mach); + } +} |
