diff options
| author | Cliff Click <cliffc@acm.org> | 2025-04-05 13:58:07 -0700 |
|---|---|---|
| committer | Cliff Click <cliffc@acm.org> | 2025-04-05 13:58:07 -0700 |
| commit | 7277ab049ab9cae5fa64cd5ea958f69278f773a4 (patch) | |
| tree | 55289107814ed0dac39288dd55520aed9a5d66e5 /chapter21/src/test | |
| parent | fc7d2bce649854982a3c16de164bbaafec11bc27 (diff) | |
| download | Simple-7277ab049ab9cae5fa64cd5ea958f69278f773a4.tar.gz Simple-7277ab049ab9cae5fa64cd5ea958f69278f773a4.zip | |
Fix elf constants
Record more relocation info in the machine-specific encodings. Use it when building ELF.
Switch to simpler Newtons; some encoding bug in the complex one.
Diffstat (limited to 'chapter21/src/test')
4 files changed, 14 insertions, 14 deletions
diff --git a/chapter21/src/test/java/com/seaofnodes/simple/Chapter19Test.java b/chapter21/src/test/java/com/seaofnodes/simple/Chapter19Test.java index fbc3c662..a8850630 100644 --- a/chapter21/src/test/java/com/seaofnodes/simple/Chapter19Test.java +++ b/chapter21/src/test/java/com/seaofnodes/simple/Chapter19Test.java @@ -293,7 +293,7 @@ return A[1]; @Test public void testNewton() throws IOException { String src = Files.readString(Path.of("src/test/java/com/seaofnodes/simple/progs/newtonFloat.smp")) - + "flt farg = arg; return sqrt(farg);"; + + "flt farg = arg; return test_sqrt(farg);"; CodeGen code = new CodeGen(src).parse().opto().typeCheck().instSelect("x86_64_v2", "SystemV").GCM().localSched(); assertEquals("return Phi(Loop,(cvtf,arg),(mulf,(addf,(divf,cvtf,Phi_guess),Phi_guess),0.5f));", code.print()); }; diff --git a/chapter21/src/test/java/com/seaofnodes/simple/Chapter20Test.java b/chapter21/src/test/java/com/seaofnodes/simple/Chapter20Test.java index 73e0ae56..da58b76e 100644 --- a/chapter21/src/test/java/com/seaofnodes/simple/Chapter20Test.java +++ b/chapter21/src/test/java/com/seaofnodes/simple/Chapter20Test.java @@ -73,8 +73,8 @@ return sqrt(arg) + sqrt(arg+2); @Test public void testNewtonFloat() throws IOException { String src = Files.readString(Path.of("src/test/java/com/seaofnodes/simple/progs/newtonFloat.smp")) - + "flt farg = arg; return sqrt(farg) + sqrt(farg+2.0);"; - testCPU(src,"x86_64_v2", "SystemV",39,null); + + "flt farg = arg; return test_sqrt(farg) + test_sqrt(farg+2.0);"; + testCPU(src,"x86_64_v2", "SystemV",23,null); testCPU(src,"riscv" , "SystemV",17,null); testCPU(src,"arm" , "SystemV",18,null); } @@ -101,7 +101,7 @@ return sqrt(arg) + sqrt(arg+2); @Test public void testString() throws IOException { String src = Files.readString(Path.of("src/test/java/com/seaofnodes/simple/progs/stringHash.smp")); - testCPU(src,"x86_64_v2", "SystemV",18,null); + testCPU(src,"x86_64_v2", "SystemV", 9,null); testCPU(src,"riscv" , "SystemV",20,null); testCPU(src,"arm" , "SystemV",16,null); } diff --git a/chapter21/src/test/java/com/seaofnodes/simple/Chapter21Test.java b/chapter21/src/test/java/com/seaofnodes/simple/Chapter21Test.java index 08b7c9d5..c3f9193e 100644 --- a/chapter21/src/test/java/com/seaofnodes/simple/Chapter21Test.java +++ b/chapter21/src/test/java/com/seaofnodes/simple/Chapter21Test.java @@ -46,8 +46,8 @@ public class Chapter21Test { @Test public void testNewtonFloat() throws IOException { String src = Files.readString(Path.of("src/test/java/com/seaofnodes/simple/progs/newtonFloat.smp")) - + "flt farg = arg; return sqrt(farg) + sqrt(farg+2.0);"; - testCPU(src,"x86_64_v2", "SystemV",39,null); + + "flt farg = arg; return test_sqrt(farg) + test_sqrt(farg+2.0);"; + testCPU(src,"x86_64_v2", "SystemV",23,null); testCPU(src,"riscv" , "SystemV",18,null); testCPU(src,"arm" , "SystemV",19,null); } @@ -55,7 +55,7 @@ public class Chapter21Test { @Test public void testString() throws IOException { String src = Files.readString(Path.of("src/test/java/com/seaofnodes/simple/progs/stringHash.smp")); - testCPU(src,"x86_64_v2", "SystemV",18,null); + testCPU(src,"x86_64_v2", "SystemV", 9,null); testCPU(src,"riscv" , "SystemV",18,null); testCPU(src,"arm" , "SystemV",17,null); } @@ -79,7 +79,6 @@ public class Chapter21Test { @Test public void testExport() throws IOException { String src = Files.readString(Path.of("src/test/java/com/seaofnodes/simple/progs/newtonFloat.smp")); - //+ "flt farg = arg; return sqrt(farg) + sqrt(farg+2.0);"; CodeGen code = new CodeGen(src); code.parse().opto().typeCheck().instSelect( "x86_64_v2", "SystemV").GCM().localSched().regAlloc().encode().exportELF("build/objs/newton.o"); } diff --git a/chapter21/src/test/java/com/seaofnodes/simple/progs/newtonFloat.smp b/chapter21/src/test/java/com/seaofnodes/simple/progs/newtonFloat.smp index 50419959..1389e12d 100644 --- a/chapter21/src/test/java/com/seaofnodes/simple/progs/newtonFloat.smp +++ b/chapter21/src/test/java/com/seaofnodes/simple/progs/newtonFloat.smp @@ -1,11 +1,12 @@ // -*- mode: java; -*- // Newtons approximation to the square root val test_sqrt = { flt x -> - flt epsilon = 1e-57; - flt guess = x; - while( 1 ) { + //flt epsilon = 1e-57; + flt guess = x; + while( 1 ) { flt next = (x/guess + guess)/2; - if( guess-epsilon <= next & next <= guess+epsilon ) return guess; + //if( guess-epsilon <= next & next <= guess+epsilon ) return guess; + if( guess==next ) return guess; guess = next; - } -};
\ No newline at end of file + } +}; |
