From f4bd723d929e53475f7990374dca7b7dfcbbdc42 Mon Sep 17 00:00:00 2001 From: Cliff Click Date: Sun, 1 Nov 2026 10:33:55 -0800 Subject: Add Chapter 29 for tech debt cleanup with the parser split Keep Chapter 28b intact and carry the grammar-oriented parser package, Var move, IterPeeps move, and parser regression tests into Chapter 29. Defer privacy and exclude its experimental tests and fixture changes. Register the chapter in the indexes, IntelliJ modules and run configurations, Maven reactor, roadmap, and linear-history publisher. Windows and Linux each pass 573 tests, release builds, 199 allocation replays, and 29 native checks. --- .../test/java/com/seaofnodes/simple/TestArm64.java | 53 ++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 chapter29/src/test/java/com/seaofnodes/simple/TestArm64.java (limited to 'chapter29/src/test/java/com/seaofnodes/simple/TestArm64.java') diff --git a/chapter29/src/test/java/com/seaofnodes/simple/TestArm64.java b/chapter29/src/test/java/com/seaofnodes/simple/TestArm64.java new file mode 100644 index 00000000..f1089cf0 --- /dev/null +++ b/chapter29/src/test/java/com/seaofnodes/simple/TestArm64.java @@ -0,0 +1,53 @@ +package com.seaofnodes.simple; + +import com.seaofnodes.isa.eval.EvalArm64; + +import com.seaofnodes.simple.codegen.RegAllocTestSupport.CheckedCodeGen; +import com.seaofnodes.simple.codegen.CodeGen; +import com.seaofnodes.simple.node.FunNode; +import com.seaofnodes.simple.node.cpus.arm.arm; +import com.seaofnodes.simple.util.BAOS; +import java.io.IOException; + +import static org.junit.Assert.assertEquals; + +// Runs 32-bit ARM code in an emulator + +public class TestArm64 { + + public static EvalArm64 build( String main, String src, int arg, int spills, boolean print ) throws IOException { + // Compile and export Simple + CodeGen code = new CheckedCodeGen(src).driver("arm", "SystemV",true,false); + + // Allocation quality not degraded + int delta = spills>>3; + if( delta == 0 ) delta =1; + if( spills != -1 && !CodeGen.iterSeedOverridden() ) assertEquals("Expect spills:", spills, code._regAlloc._spillScaled, delta); + + // Image + byte[] image = new byte[1<<20]; // A megabyte (1024*1024 bytes) + EvalArm64 ARM = new EvalArm64(image, 1<<16); + int start = 0; // Code at offset 0 + int cpool = fill(code._encoding._bits ,image,start); + int sdata = fill(code._encoding._cpool,image,cpool); + int end = fill(code._encoding._sdata,image,sdata); + + // Initial incoming int arg + ARM.regs[arm.X0] = arg; + // malloc memory starts at 64K and goes up + + // Look up starting PC or zero if not given + if( main!=null ) + for( FunNode fun : code._linker ) + if( fun != null && !fun.isDead() && fun._compunit == code.compunit() && main.equals(fun._name) ) + ARM._pc = code._encoding.opStart(fun); + + return ARM; + } + + // Fill bits into image; return end point rounded up. + private static int fill( BAOS bits, byte[] image, int off) { + System.arraycopy(bits.buf(), 0, image, off, bits.size()); + return (off+bits.size() + 15) & -16; + } +} -- cgit v1.2.3