mirror of https://github.com/aamine/cbc
r4942@macbookpro: aamine | 2009-05-24 21:56:17 +0900
* net/loveruby/cflat/compiler/IRGenerator.java: do not use Expr#isConstantAddress, it confuses semantics. * net/loveruby/cflat/sysdep/x86/CodeGenerator.java: ditto. * net/loveruby/cflat/ir/Expr.java: introduce new methods #isVar and #isAddr, instead of #isConstantAddress. * net/loveruby/cflat/ir/Addr.java: override #isAddr. * net/loveruby/cflat/ir/Var.java: override #isVar. git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@4247 1b9489fe-b721-0410-924e-b54b9192deb8
This commit is contained in:
parent
118d27b4ef
commit
b9ad38ef16
14
ChangeLog
14
ChangeLog
|
@ -1,3 +1,17 @@
|
|||
Sun May 24 21:57:04 2009 Minero Aoki <aamine@loveruby.net>
|
||||
|
||||
* net/loveruby/cflat/compiler/IRGenerator.java: do not use
|
||||
Expr#isConstantAddress, it confuses semantics.
|
||||
|
||||
* net/loveruby/cflat/sysdep/x86/CodeGenerator.java: ditto.
|
||||
|
||||
* net/loveruby/cflat/ir/Expr.java: introduce new methods #isVar
|
||||
and #isAddr, instead of #isConstantAddress.
|
||||
|
||||
* net/loveruby/cflat/ir/Addr.java: override #isAddr.
|
||||
|
||||
* net/loveruby/cflat/ir/Var.java: override #isVar.
|
||||
|
||||
Sun May 24 21:54:57 2009 Minero Aoki <aamine@loveruby.net>
|
||||
|
||||
* net/loveruby/cflat/ast: remove useless methods:
|
||||
|
|
|
@ -532,7 +532,7 @@ class IRGenerator implements ASTVisitor<Void, Expr> {
|
|||
transformOpAssign(loc, op, t, expr, imm(t, 1));
|
||||
return null;
|
||||
}
|
||||
else if (expr.isConstantAddress()) {
|
||||
else if (expr.isVar()) {
|
||||
// cont(expr++) -> v = expr; expr = v + 1; cont(v)
|
||||
DefinedVariable v = tmpVar(t);
|
||||
assign(loc, ref(v), expr);
|
||||
|
@ -556,7 +556,7 @@ class IRGenerator implements ASTVisitor<Void, Expr> {
|
|||
// #@@range/transformOpAssign{
|
||||
private Expr transformOpAssign(Location loc,
|
||||
Op op, Type lhsType, Expr lhs, Expr rhs) {
|
||||
if (lhs.isConstantAddress()) {
|
||||
if (lhs.isVar()) {
|
||||
// cont(lhs += rhs) -> lhs = lhs + rhs; cont(lhs)
|
||||
assign(loc, lhs, bin(op, lhsType, lhs, rhs));
|
||||
return isStatement() ? null : lhs;
|
||||
|
|
|
@ -12,7 +12,7 @@ public class Addr extends Expr {
|
|||
this.entity = entity;
|
||||
}
|
||||
|
||||
public boolean isConstantAddress() { return true; }
|
||||
public boolean isAddr() { return true; }
|
||||
|
||||
public Entity entity() { return entity; }
|
||||
|
||||
|
|
|
@ -3,26 +3,23 @@ import net.loveruby.cflat.asm.*;
|
|||
import net.loveruby.cflat.entity.Entity;
|
||||
|
||||
abstract public class Expr implements Dumpable {
|
||||
protected Type type;
|
||||
final Type type;
|
||||
|
||||
protected Expr(Type type) {
|
||||
Expr(Type type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public Type type() { return type; }
|
||||
|
||||
public boolean isConstant() {
|
||||
return false;
|
||||
}
|
||||
public boolean isVar() { return false; }
|
||||
public boolean isAddr() { return false; }
|
||||
|
||||
public boolean isConstant() { return false; }
|
||||
|
||||
public ImmediateValue asmValue() {
|
||||
throw new Error("Expr#asmValue called");
|
||||
}
|
||||
|
||||
public boolean isConstantAddress() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public AsmOperand address() {
|
||||
throw new Error("Expr#address called");
|
||||
}
|
||||
|
|
|
@ -12,6 +12,8 @@ public class Var extends Expr {
|
|||
this.entity = entity;
|
||||
}
|
||||
|
||||
public boolean isVar() { return true; }
|
||||
|
||||
public Type type() {
|
||||
if (super.type() == null) {
|
||||
throw new Error("Var is too big to load by 1 insn");
|
||||
|
|
|
@ -760,7 +760,7 @@ public class CodeGenerator
|
|||
compile(node.left());
|
||||
right = node.right().asmValue();
|
||||
}
|
||||
else if (node.right().isConstantAddress()) {
|
||||
else if (node.right().isVar()) {
|
||||
compile(node.left());
|
||||
loadVariable(((Var)node.right()), cx());
|
||||
right = cx(node.type());
|
||||
|
@ -934,7 +934,7 @@ public class CodeGenerator
|
|||
|
||||
// #@@range/compile_Assign{
|
||||
public Void visit(Assign node) {
|
||||
if (node.lhs().isConstantAddress() && node.lhs().memref() != null) {
|
||||
if (node.lhs().isAddr() && node.lhs().memref() != null) {
|
||||
compile(node.rhs());
|
||||
save(node.lhs().type(), ax(), node.lhs().memref());
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue