From 33b2a4a1e8c50a97d52de0c6286aa67e47634ec5 Mon Sep 17 00:00:00 2001 From: Joel Dice Date: Tue, 11 Dec 2007 17:27:04 -0700 Subject: [PATCH] support absolute operands on virtual stack and absolute to memory movs --- src/compiler.cpp | 28 ++++++++++++++++++++++++++++ test/Misc.java | 2 +- 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/src/compiler.cpp b/src/compiler.cpp index f4f763c0da..a57eeeff97 100644 --- a/src/compiler.cpp +++ b/src/compiler.cpp @@ -262,6 +262,8 @@ class AbsoluteOperand: public MyOperand { value(value) { } + virtual StackOperand* logicalPush(Context* c); + virtual void apply(Context* c, Operation operation); virtual void apply(Context* c, Operation operation, MyOperand* operand) { @@ -295,6 +297,7 @@ class MemoryOperand: public MyOperand { virtual void accept(Context*, Operation, RegisterOperand*); virtual void accept(Context*, Operation, ImmediateOperand*); + virtual void accept(Context*, Operation, AbsoluteOperand*); MyOperand* base; int displacement; @@ -851,6 +854,13 @@ ImmediateOperand::apply(Context* c, Operation operation) } } +StackOperand* +AbsoluteOperand::logicalPush(Context* c) +{ + return c->stack = new (c->zone.allocate(sizeof(StackOperand))) + StackOperand(this, c->stack); +} + void AbsoluteOperand::apply(Context* c, Operation operation) { @@ -914,6 +924,24 @@ MemoryOperand::accept(Context* c, Operation operation, } } +void +MemoryOperand::accept(Context* c, Operation operation, + AbsoluteOperand* operand) +{ + switch (operation) { + case mov: { + RegisterOperand* tmp = temporary(c, true); + + tmp->accept(c, mov, operand); + accept(c, mov, tmp); + + tmp->release(c); + } break; + + default: abort(c); + } +} + unsigned PoolPromise::value(Context* c) { diff --git a/test/Misc.java b/test/Misc.java index f96d04e2b4..292b9c8b1a 100644 --- a/test/Misc.java +++ b/test/Misc.java @@ -24,7 +24,7 @@ public class Misc { int c = a + b; Misc m = new Misc(); -// String s = "hello"; + String s = "hello"; // m.foo(s); // m.bar(s); // baz(s);