diff options
author | bd-912 <bdunahu@colostate.edu> | 2024-05-07 18:37:10 -0600 |
---|---|---|
committer | bd-912 <bdunahu@colostate.edu> | 2024-05-07 18:37:10 -0600 |
commit | 9a025aeaeb4104d6a66baaa575c669231d5d76bc (patch) | |
tree | cbab00685ecb99dad37f89d207c38c0991523324 /condense/CondenseVisitor.java | |
parent | 9f24d0511a89379bb3326ee1b62eeaabe589571b (diff) |
Fix indexing for MemRead/MemWrite in Condense, almost all tests pass
Diffstat (limited to 'condense/CondenseVisitor.java')
-rw-r--r-- | condense/CondenseVisitor.java | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/condense/CondenseVisitor.java b/condense/CondenseVisitor.java index fd337d9..5713ded 100644 --- a/condense/CondenseVisitor.java +++ b/condense/CondenseVisitor.java @@ -180,9 +180,9 @@ public class CondenseVisitor extends VInstr.Visitor<RuntimeException>{ else if (op.equals("MulS")) ret += " mul"; else if (op.equals("Eq")) - ret += "NULL"; // fixme + ret += " and"; else if (op.equals("Lt")) - ; + ret += " slt"; else if (op.equals("LtS")) ret += " slt"; else if (op.equals("PrintIntS")) { @@ -223,12 +223,18 @@ public class CondenseVisitor extends VInstr.Visitor<RuntimeException>{ n.sourcePos.toString())); /////////////////////////////////////////////////////////////// String source = n.source.toString(); + if (this.isNumeric(source)) { + this.addMIPS(String.format(" li $t9 %s", + source)); + source = "$t9"; + } String dest; if (n.dest instanceof VMemRef.Stack) dest = this.curr.get(((VMemRef.Stack) n.dest)); else - dest = String.format("0(%s)", + dest = String.format("%d(%s)", + ((VMemRef.Global) n.dest).byteOffset, ((VMemRef.Global) n.dest).base.toString()); if (source.contains(":")) { this.addMIPS(String.format(" la $t9 %s", @@ -252,11 +258,15 @@ public class CondenseVisitor extends VInstr.Visitor<RuntimeException>{ String dest = n.dest.toString(); String source; - if (n.source instanceof VMemRef.Stack) + if (n.source instanceof VMemRef.Stack) { + MinimalLogger.info("Loading from stack..."); source = this.curr.get(((VMemRef.Stack) n.source)); - else - source = String.format("0(%s)", + } else { + MinimalLogger.info("Loading a const..."); + source = String.format("%d(%s)", + ((VMemRef.Global) n.source).byteOffset, ((VMemRef.Global) n.source).base.toString()); + } this.addMIPS(String.format(" lw %s %s", dest, source)); |