diff options
| author | Cliff Click <cliffc@acm.org> | 2025-02-07 09:12:14 -0800 |
|---|---|---|
| committer | Cliff Click <cliffc@acm.org> | 2025-02-07 09:12:14 -0800 |
| commit | ed22ac30eaf0dd2d0347637ac4f8d598c087fab1 (patch) | |
| tree | 133bf327e982d50adbc95739122f52db85ba0058 /src | |
| parent | 8818754a41d12063ed5ff68a47a0adf2b80c24b7 (diff) | |
| download | Simple-ed22ac30eaf0dd2d0347637ac4f8d598c087fab1.tar.gz Simple-ed22ac30eaf0dd2d0347637ac4f8d598c087fab1.zip | |
Chapter 20: Graph Coloring Register Allocationlinear-chapter20
Diffstat (limited to 'src')
| -rw-r--r-- | src/main/java/com/seaofnodes/simple/node/LoadNode.java | 8 | ||||
| -rw-r--r-- | src/test/java/com/seaofnodes/simple/Chapter20Test.java | 17 |
2 files changed, 21 insertions, 4 deletions
diff --git a/src/main/java/com/seaofnodes/simple/node/LoadNode.java b/src/main/java/com/seaofnodes/simple/node/LoadNode.java index 4004f87f..6c74042b 100644 --- a/src/main/java/com/seaofnodes/simple/node/LoadNode.java +++ b/src/main/java/com/seaofnodes/simple/node/LoadNode.java @@ -201,10 +201,10 @@ public class LoadNode extends MemOpNode { return new AndNode(null,val,con(ti._max)); // Signed extension int shift = Long.numberOfLeadingZeros(ti._max)-1; - if( shift==0 ) - return val; Node shf = con(shift); - Node shl = new ShlNode(null,val,shf.keep()).peephole(); - return new SarNode(null,shl,shf.unkeep()); + if( shf._type==TypeInteger.ZERO ) + return val; + //return peep(new SarNode(null,peep(new ShlNode(null,val,shf.keep())),shf.unkeep())); + throw Utils.TODO(); } } diff --git a/src/test/java/com/seaofnodes/simple/Chapter20Test.java b/src/test/java/com/seaofnodes/simple/Chapter20Test.java new file mode 100644 index 00000000..48458f95 --- /dev/null +++ b/src/test/java/com/seaofnodes/simple/Chapter20Test.java @@ -0,0 +1,17 @@ +package com.seaofnodes.simple; + +import org.junit.Test; +import static org.junit.Assert.*; + +public class Chapter20Test { + + @Test + public void testJig() { + CodeGen code = new CodeGen(""" +return 0; +"""); + code.parse().opto().typeCheck(); + assertEquals("return 0;", code._stop.toString()); + assertEquals("0", Eval2.eval(code, 2)); + } +} |
