diff options
| author | Darrick Wiebe <darrickw@gmail.com> | 2025-04-12 13:40:20 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-04-12 10:40:20 -0700 |
| commit | 798bd959410eb6c2e0b9f7ae1222181ac2b295d4 (patch) | |
| tree | 94400ba51862663d02a2eac3a58b585ef749108a /chapter21/src/test/java/com/seaofnodes | |
| parent | 47711b81ea915eeeb46b2ad8ebb291fb21cbaf6e (diff) | |
| download | Simple-798bd959410eb6c2e0b9f7ae1222181ac2b295d4.tar.gz Simple-798bd959410eb6c2e0b9f7ae1222181ac2b295d4.zip | |
MemStore interface (#201)
* Hook for pre-encoding work needed by M2
* Add MemStore interface
* Add both MemLoad and MemStore interfaces
* Fix NPE printing StopNode
* Attach merged mem to return when forcing a loop exit
* Made requested changes. This breaks a few tests, possibly because...
...I am not sure whether some X86 ops are loads or stores.
* Mach ops need anti-deps too
MemOp subclasses are either "Load-like" or "Store-like" based on a flag, and not on subclassing LoadNode nor StoreNode.
Mach ops pick up anti-deps, no reg mask for those.
x86 bug: do not allow "dst = [mem] + #imm", no such instruction
Empty merge-mem folds away.
x86 add-to-mem works both ways
---------
Co-authored-by: Cliff Click <cliffc@acm.org>
Diffstat (limited to 'chapter21/src/test/java/com/seaofnodes')
| -rw-r--r-- | chapter21/src/test/java/com/seaofnodes/simple/BrainFuckTest.java | 2 | ||||
| -rw-r--r-- | chapter21/src/test/java/com/seaofnodes/simple/evaluator/Scheduler.java | 16 |
2 files changed, 9 insertions, 9 deletions
diff --git a/chapter21/src/test/java/com/seaofnodes/simple/BrainFuckTest.java b/chapter21/src/test/java/com/seaofnodes/simple/BrainFuckTest.java index ba852c9e..991a2f66 100644 --- a/chapter21/src/test/java/com/seaofnodes/simple/BrainFuckTest.java +++ b/chapter21/src/test/java/com/seaofnodes/simple/BrainFuckTest.java @@ -63,7 +63,7 @@ for( int pc = 0; pc < program#; pc++ ) { return output; """; Chapter21Test.testCPU(src,"x86_64_v2", "SystemV",40,null); - Chapter21Test.testCPU(src,"riscv" , "SystemV",30,null); + Chapter21Test.testCPU(src,"riscv" , "SystemV",44,null); Chapter21Test.testCPU(src,"arm" , "SystemV",26,null); //assertEquals("Hello World!\n", Eval2.eval(code, 0, 10000)); } diff --git a/chapter21/src/test/java/com/seaofnodes/simple/evaluator/Scheduler.java b/chapter21/src/test/java/com/seaofnodes/simple/evaluator/Scheduler.java index 4bfa7628..7ba9272f 100644 --- a/chapter21/src/test/java/com/seaofnodes/simple/evaluator/Scheduler.java +++ b/chapter21/src/test/java/com/seaofnodes/simple/evaluator/Scheduler.java @@ -248,20 +248,20 @@ public class Scheduler { assert data.block != null; assert data.users == 0; - if (data.node instanceof LoadNode l) { + if (data.node instanceof MemOpNode l && l._isLoad) { assert isValid(data); // Handle anti-deps of load nodes. // At this point all anti-dep nodes are scheduled, // but they did not refine the placement // so do that now. - var mem = l.in(1); + var mem = data.node.in(1); for(var out : mem._outputs) { if (out instanceof PhiNode p) { var r = p.in(0); for (int i = 1; i < p.nIns(); i++) { if (p.in(i) == mem) optionalRefinePlacement(data, r.in(i)); } - } else if (!(out instanceof LoadNode)) { + } else if (!(out instanceof MemOpNode ld && ld._isLoad)) { optionalRefinePlacement(data, out); } } @@ -273,11 +273,11 @@ public class Scheduler { for(var in:data.node._inputs) { if (in!=null) update(d(in), data.block); } - if (data.node instanceof StoreNode s) { + if (data.node instanceof MemOpNode s && !s._isLoad) { // Store nodes have anti-deps to load nodes. // So decrease the uses of these loads when the store is placed. - for (var out: s.in(1)._outputs) { - if (out instanceof LoadNode) od(out).ifPresent(this::decUsers); + for (var out: ((Node)s).in(1)._outputs) { + if (out instanceof MemOpNode ld && ld._isLoad) od(out).ifPresent(this::decUsers); } } } @@ -471,14 +471,14 @@ public class Scheduler { } else { for (var in : node._inputs) if (in != null && !(in instanceof CFGNode)) markAlive(dataQueue, in, false); } - if (node instanceof StoreNode) mem.push(data); + if (node instanceof MemOpNode s && !s._isLoad) mem.push(data); } // Handle store nodes and increase load with an anti-dep to the store. while (!mem.isEmpty()) { var data = mem.pop(); node = data.node; for(var out:node.in(1)._outputs) { - if (out instanceof LoadNode) od(out).ifPresent(d->d.users++); + if (out instanceof MemOpNode ld && ld._isLoad) od(out).ifPresent(d->d.users++); } } } |
