From 9929bca5617c2b0134ae16fb174df8d247443af8 Mon Sep 17 00:00:00 2001 From: Yasser Arguelles Snape Date: Mon, 17 Mar 2025 14:59:33 -0700 Subject: ELF exporting (but in Chapter 21) (#173) * Updated ELF exporting code, added function relocations * added big constants (only floats currently) --- .../java/com/seaofnodes/simple/Chapter21Test.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'chapter21/src/test/java/com') 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(); + } } -- cgit v1.2.3