diff options
| author | Yasser Arguelles Snape <yasserarguelles2506@gmail.com> | 2025-03-17 14:59:33 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-03-17 14:59:33 -0700 |
| commit | 9929bca5617c2b0134ae16fb174df8d247443af8 (patch) | |
| tree | 20fddc5881856e490e505392a234abe3564a173b /chapter21/src/test/java/com | |
| parent | 65ff94cc06005208d454b6759503b8604135e607 (diff) | |
| download | Simple-9929bca5617c2b0134ae16fb174df8d247443af8.tar.gz Simple-9929bca5617c2b0134ae16fb174df8d247443af8.zip | |
ELF exporting (but in Chapter 21) (#173)
* Updated ELF exporting code, added function relocations
* added big constants (only floats currently)
Diffstat (limited to 'chapter21/src/test/java/com')
| -rw-r--r-- | chapter21/src/test/java/com/seaofnodes/simple/Chapter21Test.java | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/chapter21/src/test/java/com/seaofnodes/simple/Chapter21Test.java b/chapter21/src/test/java/com/seaofnodes/simple/Chapter21Test.java index 648edbe1..ad1f39b2 100644 --- a/chapter21/src/test/java/com/seaofnodes/simple/Chapter21Test.java +++ b/chapter21/src/test/java/com/seaofnodes/simple/Chapter21Test.java @@ -80,4 +80,23 @@ return sqrt(farg) + sqrt(farg+2.0); testCPU(src,"riscv" , "SystemV",1,"return (add,.[],(mul,.[],1000));"); testCPU(src,"arm" , "SystemV",1,"return (add,.[],(mul,.[],1000));"); } + + @Test + public void testExport() { + CodeGen code = new CodeGen( + """ +// Newtons approximation to the square root +val sqrt = { flt x -> + flt guess = x; + while( 1 ) { + flt next = (x/guess + guess)/2; + if( next == guess ) return guess; + guess = next; + } +}; +flt farg = arg; +return sqrt(farg) + sqrt(farg+2.0); + """); + code.parse().opto().typeCheck().instSelect(PORTS, "x86_64_v2", "SystemV").GCM().localSched().regAlloc().encode().exportELF(); + } } |
