From db3ca780c26b78cbe129a5c1bdf0d8ff7d867d1b Mon Sep 17 00:00:00 2001 From: Cliff Click Date: Sun, 20 Sep 2026 10:04:48 -0700 Subject: Unify GCM across chapters Remove the _anti field. Remove the isPinned() call. Add a copyEmpty call. --- .../com/seaofnodes/simple/codegen/CodeGen.java | 23 --- .../simple/codegen/GlobalCodeMotion.java | 223 +++++++-------------- .../java/com/seaofnodes/simple/node/CFGNode.java | 3 - .../com/seaofnodes/simple/node/FunPtrNode.java | 1 - .../java/com/seaofnodes/simple/node/GuardNode.java | 1 - .../main/java/com/seaofnodes/simple/node/Node.java | 8 +- .../java/com/seaofnodes/simple/node/PhiNode.java | 1 - .../java/com/seaofnodes/simple/node/ProjNode.java | 1 - .../simple/node/cpus/x86_64_v2/TFPX86.java | 4 - 9 files changed, 79 insertions(+), 186 deletions(-) (limited to 'chapter25/src/main') diff --git a/chapter25/src/main/java/com/seaofnodes/simple/codegen/CodeGen.java b/chapter25/src/main/java/com/seaofnodes/simple/codegen/CodeGen.java index 317fff71..aafaf7ed 100644 --- a/chapter25/src/main/java/com/seaofnodes/simple/codegen/CodeGen.java +++ b/chapter25/src/main/java/com/seaofnodes/simple/codegen/CodeGen.java @@ -733,7 +733,6 @@ public class CodeGen { if( n instanceof MachNode ) { for( int i=0; i < n.nIns(); i++ ) n._inputs.set(i, _instSelect(n.in(i),map) ); - pinGlobalValue(n); return n; } @@ -747,7 +746,6 @@ public class CodeGen { // Walk machine op and replace inputs with mapped inputs for( int i=0; i < x.nIns(); i++ ) x._inputs.set(i, _instSelect(x.in(i),map) ); - pinGlobalValue(x); // Post selection action if( x instanceof MachNode mach ) { if( n instanceof ReturnNode ret ) @@ -759,27 +757,6 @@ public class CodeGen { } - // Some machine values are Start-pinned globals or zero-code wrappers around - // them, e.g. pointer/function constants and PtrToInt/ReadOnly-style adapters. - // Before output edges are rebuilt, make ownership explicit: every global value - // chain member is Start-pinned in slot 0 and data-linked in later slots. - private void pinGlobalValue(Node n) { - if( n instanceof CFGNode || !(n instanceof MachNode mach) || mach.outregmap()==null || n.isPinned() ) - return; - if( n.nIns()==0 ) - return; - if( !(n.in(0)==null || n.in(0)==_start) ) - return; - for( int i=1; i