summaryrefslogtreecommitdiff
path: root/src/test/java/com/seaofnodes/simple/Chapter07Test.java
diff options
context:
space:
mode:
authorCliff Click <cliffc@acm.org>2024-11-26 11:01:47 -0800
committerCliff Click <cliffc@acm.org>2025-01-14 15:17:03 -0800
commiteee5b806fabae0b480ff7d41159369c5a457d014 (patch)
tree576e6ed318eea76aa9e0de9e95af7616a0b8475a /src/test/java/com/seaofnodes/simple/Chapter07Test.java
parentc07510c1d75020d23d688f7f184149c57b13a39a (diff)
downloadSimple-linear-chapter18.tar.gz
Simple-linear-chapter18.zip
Chapter 18: Functionslinear-chapter18
Diffstat (limited to 'src/test/java/com/seaofnodes/simple/Chapter07Test.java')
-rw-r--r--src/test/java/com/seaofnodes/simple/Chapter07Test.java100
1 files changed, 50 insertions, 50 deletions
diff --git a/src/test/java/com/seaofnodes/simple/Chapter07Test.java b/src/test/java/com/seaofnodes/simple/Chapter07Test.java
index 355bbba4..7cef0d9c 100644
--- a/src/test/java/com/seaofnodes/simple/Chapter07Test.java
+++ b/src/test/java/com/seaofnodes/simple/Chapter07Test.java
@@ -9,7 +9,7 @@ public class Chapter07Test {
@Test
public void testExample() {
- Parser parser = new Parser(
+ CodeGen code = new CodeGen(
"""
while(arg < 10) {
arg = arg + 1;
@@ -17,15 +17,15 @@ while(arg < 10) {
return arg;
""");
Node._disablePeephole = true;
- StopNode stop = parser.parse();
- assertEquals("return Phi(Loop,arg,(Phi_arg+1));", stop.toString());
- assertTrue(stop.ret().ctrl() instanceof CProjNode);
+ code.parse();
+ assertEquals("return Phi(Loop,arg,(Phi_arg+1));", code.print());
+ assertTrue(code.ctrl() instanceof CProjNode);
Node._disablePeephole = false;
}
@Test
public void testRegression() {
- Parser parser = new Parser(
+ CodeGen code = new CodeGen(
"""
int a = 1;
if(arg){}else{
@@ -35,13 +35,13 @@ if(arg){}else{
}
return a;
""");
- StopNode stop = parser.parse().iterate();
- assertEquals("return Phi(Region,1,Phi(Loop,1,(Phi_a+1)));", stop.toString());
+ code.parse().opto();
+ assertEquals("return Phi(Region,1,Phi(Loop,1,(Phi_a+1)));", code.print());
}
@Test
public void testWhileNested() {
- Parser parser = new Parser(
+ CodeGen code = new CodeGen(
"""
int sum = 0;
int i = 0;
@@ -55,13 +55,13 @@ while(i < arg) {
}
return sum;
""");
- StopNode stop = parser.parse().iterate();
- assertEquals("return Phi(Loop,0,Phi(Loop,Phi_sum,(Phi_sum+Phi(Loop,0,(Phi_j+1)))));", stop.toString());
+ code.parse().opto();
+ assertEquals("return Phi(Loop,0,Phi(Loop,Phi_sum,(Phi_sum+Phi(Loop,0,(Phi_j+1)))));", code.print());
}
@Test
public void testWhileScope() {
- Parser parser = new Parser(
+ CodeGen code = new CodeGen(
"""
int a = 1;
int b = 2;
@@ -72,15 +72,15 @@ while(a < 10) {
return b;
""");
Node._disablePeephole = true;
- StopNode stop = parser.parse();
- assertEquals("return Phi(Loop,2,Phi(Region,Phi_b,4));", stop.toString());
- assertTrue(stop.ret().ctrl() instanceof CProjNode);
+ code.parse();
+ assertEquals("return Phi(Loop,2,Phi(Region,Phi_b,4));", code.print());
+ assertTrue(code.ctrl() instanceof CProjNode);
Node._disablePeephole = false;
}
@Test
public void testWhileNestedIfAndInc() {
- Parser parser = new Parser(
+ CodeGen code = new CodeGen(
"""
int a = 1;
int b = 2;
@@ -92,15 +92,15 @@ while(a < 10) {
}
return b;
""");
- StopNode stop = parser.parse().iterate();
- assertEquals("return Phi(Loop,2,(Phi(Region,Phi_b,4)+1));", stop.toString());
- assertTrue(stop.ret().ctrl() instanceof CProjNode);
+ code.parse().opto();
+ assertEquals("return Phi(Loop,2,(Phi(Region,Phi_b,4)+1));", code.print());
+ assertTrue(code.ctrl() instanceof CProjNode);
}
@Test
public void testWhile() {
- Parser parser = new Parser(
+ CodeGen code = new CodeGen(
"""
int a = 1;
while(a < 10) {
@@ -110,15 +110,15 @@ while(a < 10) {
return a;
""");
Node._disablePeephole = true;
- StopNode stop = parser.parse();
- assertEquals("return Phi(Loop,1,((Phi_a+1)+2));", stop.toString());
- assertTrue(stop.ret().ctrl() instanceof CProjNode);
+ code.parse();
+ assertEquals("return Phi(Loop,1,(Phi_a+3));", code.print());
+ assertTrue(code.ctrl() instanceof CProjNode);
Node._disablePeephole = false;
}
@Test
public void testWhilePeep() {
- Parser parser = new Parser(
+ CodeGen code = new CodeGen(
"""
int a = 1;
while(a < 10) {
@@ -127,42 +127,42 @@ while(a < 10) {
}
return a;
""");
- StopNode stop = parser.parse().iterate();
- assertEquals("return Phi(Loop,1,(Phi_a+3));", stop.toString());
- assertTrue(stop.ret().ctrl() instanceof CProjNode);
+ code.parse().opto();
+ assertEquals("return Phi(Loop,1,(Phi_a+3));", code.print());
+ assertTrue(code.ctrl() instanceof CProjNode);
}
@Test
public void testWhile2() {
- Parser parser = new Parser(
+ CodeGen code = new CodeGen(
"""
int a = 1;
while(arg) a = 2;
return a;
""");
Node._disablePeephole = true;
- StopNode stop = parser.parse();
- assertEquals("return Phi(Loop,1,2);", stop.toString());
- assertTrue(stop.ret().ctrl() instanceof CProjNode);
+ code.parse();
+ assertEquals("return Phi(Loop,1,2);", code.print());
+ assertTrue(code.ctrl() instanceof CProjNode);
Node._disablePeephole = false;
}
@Test
public void testWhile2Peep() {
- Parser parser = new Parser(
+ CodeGen code = new CodeGen(
"""
int a = 1;
while(arg) a = 2;
return a;
""");
- StopNode stop = parser.parse().iterate();
- assertEquals("return Phi(Loop,1,2);", stop.toString());
- assertTrue(stop.ret().ctrl() instanceof CProjNode);
+ code.parse().opto();
+ assertEquals("return Phi(Loop,1,2);", code.print());
+ assertTrue(code.ctrl() instanceof CProjNode);
}
@Test
public void testWhile3() {
- Parser parser = new Parser(
+ CodeGen code = new CodeGen(
"""
int a = 1;
while(a < 10) {
@@ -172,15 +172,15 @@ while(a < 10) {
return a;
""");
Node._disablePeephole = true;
- StopNode stop = parser.parse();
- assertEquals("return Phi(Loop,1,((Phi_a+1)+2));", stop.toString());
- assertTrue(stop.ret().ctrl() instanceof CProjNode);
+ code.parse();
+ assertEquals("return Phi(Loop,1,(Phi_a+3));", code.print());
+ assertTrue(code.ctrl() instanceof CProjNode);
Node._disablePeephole = false;
}
@Test
public void testWhile3Peep() {
- Parser parser = new Parser(
+ CodeGen code = new CodeGen(
"""
int a = 1;
while(a < 10) {
@@ -189,14 +189,14 @@ while(a < 10) {
}
return a;
""");
- StopNode stop = parser.parse().iterate();
- assertEquals("return Phi(Loop,1,(Phi_a+3));", stop.toString());
- assertTrue(stop.ret().ctrl() instanceof CProjNode);
+ code.parse().opto();
+ assertEquals("return Phi(Loop,1,(Phi_a+3));", code.print());
+ assertTrue(code.ctrl() instanceof CProjNode);
}
@Test
public void testWhile4() {
- Parser parser = new Parser(
+ CodeGen code = new CodeGen(
"""
int a = 1;
int b = 2;
@@ -207,15 +207,15 @@ while(a < 10) {
return a;
""");
Node._disablePeephole = true;
- StopNode stop = parser.parse();
- assertEquals("return Phi(Loop,1,((Phi_a+1)+2));", stop.toString());
- assertTrue(stop.ret().ctrl() instanceof CProjNode);
+ code.parse();
+ assertEquals("return Phi(Loop,1,(Phi_a+3));", code.print());
+ assertTrue(code.ctrl() instanceof CProjNode);
Node._disablePeephole = false;
}
@Test
public void testWhile4Peep() {
- Parser parser = new Parser(
+ CodeGen code = new CodeGen(
"""
int a = 1;
int b = 2;
@@ -225,9 +225,9 @@ while(a < 10) {
}
return a;
""");
- StopNode stop = parser.parse().iterate();
- assertEquals("return Phi(Loop,1,(Phi_a+3));", stop.toString());
- assertTrue(stop.ret().ctrl() instanceof CProjNode);
+ code.parse().opto();
+ assertEquals("return Phi(Loop,1,(Phi_a+3));", code.print());
+ assertTrue(code.ctrl() instanceof CProjNode);
}
}