r4971@macbookpro: aamine | 2009-05-26 13:19:10 +0900

* net/loveruby/cflat/asm: refactoring: rename class: AsmOperand -> Operand.
 * net/loveruby/cflat/asm: follow it.
 * net/loveruby/cflat/sysdep/x86: follow it.
 * net/loveruby/cflat/ir: follow it.
 * net/loveruby/cflat/entity: follow it.
 


git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@4259 1b9489fe-b721-0410-924e-b54b9192deb8
This commit is contained in:
Minero Aoki 2009-05-26 04:24:46 +00:00
parent 039483da62
commit aabbca6e13
16 changed files with 85 additions and 65 deletions

View File

@ -1,3 +1,16 @@
Tue May 26 13:18:52 2009 Minero Aoki <aamine@loveruby.net>
* net/loveruby/cflat/asm: refactoring: rename class: AsmOperand ->
Operand.
* net/loveruby/cflat/asm: follow it.
* net/loveruby/cflat/sysdep/x86: follow it.
* net/loveruby/cflat/ir: follow it.
* net/loveruby/cflat/entity: follow it.
Tue May 26 13:11:08 2009 Minero Aoki <aamine@loveruby.net>
* net/loveruby/cflat/asm/AsmComment.java -> Comment.java

View File

@ -1,13 +1,13 @@
package net.loveruby.cflat.asm;
public class AbsoluteAddress extends AsmOperand {
public class AbsoluteAddress extends Operand {
protected Register register;
public AbsoluteAddress(Register reg) {
this.register = reg;
}
public AsmOperand register() {
public Operand register() {
return this.register;
}

View File

@ -1,6 +1,6 @@
package net.loveruby.cflat.asm;
public class ImmediateValue extends AsmOperand {
public class ImmediateValue extends Operand {
protected Literal expr;
public ImmediateValue(long n) {

View File

@ -3,42 +3,42 @@ package net.loveruby.cflat.asm;
public class Instruction extends Assembly {
protected String mnemonic;
protected String suffix;
protected AsmOperand[] operands;
protected Operand[] operands;
protected boolean needRelocation;
public Instruction(String mnemonic) {
this(mnemonic, "", new AsmOperand[0], false);
this(mnemonic, "", new Operand[0], false);
}
public Instruction(String mnemonic, String suffix, AsmOperand a1) {
this(mnemonic, suffix, new AsmOperand[] { a1 }, false);
public Instruction(String mnemonic, String suffix, Operand a1) {
this(mnemonic, suffix, new Operand[] { a1 }, false);
}
public Instruction(String mnemonic, String suffix,
AsmOperand a1, AsmOperand a2) {
this(mnemonic, suffix, new AsmOperand[] { a1, a2 }, false);
Operand a1, Operand a2) {
this(mnemonic, suffix, new Operand[] { a1, a2 }, false);
}
public Instruction(String mnemonic, String suffix,
AsmOperand a1, AsmOperand a2, boolean reloc) {
this(mnemonic, suffix, new AsmOperand[] { a1, a2 }, reloc);
Operand a1, Operand a2, boolean reloc) {
this(mnemonic, suffix, new Operand[] { a1, a2 }, reloc);
}
public Instruction(String mnemonic, String suffix, AsmOperand[] operands, boolean reloc) {
public Instruction(String mnemonic, String suffix, Operand[] operands, boolean reloc) {
this.mnemonic = mnemonic;
this.suffix = suffix;
this.operands = operands;
this.needRelocation = reloc;
}
public Instruction build(String mnemonic, AsmOperand o1) {
public Instruction build(String mnemonic, Operand o1) {
return new Instruction(mnemonic, this.suffix,
new AsmOperand[] { o1 }, needRelocation);
new Operand[] { o1 }, needRelocation);
}
public Instruction build(String mnemonic, AsmOperand o1, AsmOperand o2) {
public Instruction build(String mnemonic, Operand o1, Operand o2) {
return new Instruction(mnemonic, this.suffix,
new AsmOperand[] { o1, o2 }, needRelocation);
new Operand[] { o1, o2 }, needRelocation);
}
public boolean isInstruction() {
@ -64,11 +64,11 @@ public class Instruction extends Assembly {
return this.operands.length;
}
public AsmOperand operand1() {
public Operand operand1() {
return this.operands[0];
}
public AsmOperand operand2() {
public Operand operand2() {
return this.operands[1];
}

View File

@ -1,7 +1,7 @@
package net.loveruby.cflat.asm;
abstract public class MemoryReference
extends AsmOperand implements Comparable<MemoryReference> {
extends Operand implements Comparable<MemoryReference> {
public boolean isMemoryReference() {
return true;
}

View File

@ -1,6 +1,6 @@
package net.loveruby.cflat.asm;
abstract public class AsmOperand implements OperandPattern {
abstract public class Operand implements OperandPattern {
abstract public String toSource(SymbolTable table);
public boolean isRegister() {
@ -18,7 +18,7 @@ abstract public class AsmOperand implements OperandPattern {
abstract public void collectStatistics(AsmStatistics stats);
// default implementation
public boolean match(AsmOperand operand) {
public boolean match(Operand operand) {
return equals(operand);
}

View File

@ -1,5 +1,5 @@
package net.loveruby.cflat.asm;
public interface OperandPattern {
public boolean match(AsmOperand operand);
public boolean match(Operand operand);
}

View File

@ -1,6 +1,6 @@
package net.loveruby.cflat.asm;
abstract public class Register extends AsmOperand {
abstract public class Register extends Operand {
public boolean isRegister() {
return true;
}

View File

@ -4,7 +4,7 @@ import net.loveruby.cflat.ast.TypeNode;
import net.loveruby.cflat.ast.Location;
import net.loveruby.cflat.ast.ExprNode;
import net.loveruby.cflat.asm.Symbol;
import net.loveruby.cflat.asm.AsmOperand;
import net.loveruby.cflat.asm.Operand;
import net.loveruby.cflat.asm.MemoryReference;
abstract public class Entity
@ -83,7 +83,7 @@ abstract public class Entity
this.address = mem;
}
public AsmOperand address() {
public Operand address() {
checkAddress();
return address;
}

View File

@ -1,6 +1,6 @@
package net.loveruby.cflat.ir;
import net.loveruby.cflat.asm.Type;
import net.loveruby.cflat.asm.AsmOperand;
import net.loveruby.cflat.asm.Operand;
import net.loveruby.cflat.asm.MemoryReference;
import net.loveruby.cflat.entity.Entity;
@ -16,7 +16,7 @@ public class Addr extends Expr {
public Entity entity() { return entity; }
public AsmOperand address() {
public Operand address() {
return entity.address();
}

View File

@ -1,5 +1,8 @@
package net.loveruby.cflat.ir;
import net.loveruby.cflat.asm.*;
import net.loveruby.cflat.asm.Type;
import net.loveruby.cflat.asm.Operand;
import net.loveruby.cflat.asm.ImmediateValue;
import net.loveruby.cflat.asm.MemoryReference;
import net.loveruby.cflat.entity.Entity;
abstract public class Expr implements Dumpable {
@ -20,7 +23,7 @@ abstract public class Expr implements Dumpable {
throw new Error("Expr#asmValue called");
}
public AsmOperand address() {
public Operand address() {
throw new Error("Expr#address called");
}

View File

@ -1,6 +1,10 @@
package net.loveruby.cflat.ir;
import net.loveruby.cflat.entity.ConstantEntry;
import net.loveruby.cflat.asm.*;
import net.loveruby.cflat.asm.Type;
import net.loveruby.cflat.asm.Operand;
import net.loveruby.cflat.asm.ImmediateValue;
import net.loveruby.cflat.asm.MemoryReference;
import net.loveruby.cflat.asm.Symbol;
public class Str extends Expr {
protected ConstantEntry entry;
@ -22,7 +26,7 @@ public class Str extends Expr {
return entry.memref();
}
public AsmOperand address() {
public Operand address() {
return entry.address();
}

View File

@ -1,7 +1,7 @@
package net.loveruby.cflat.ir;
import net.loveruby.cflat.entity.Entity;
import net.loveruby.cflat.asm.Type;
import net.loveruby.cflat.asm.AsmOperand;
import net.loveruby.cflat.asm.Operand;
import net.loveruby.cflat.asm.MemoryReference;
public class Var extends Expr {
@ -24,7 +24,7 @@ public class Var extends Expr {
public String name() { return entity.name(); }
public Entity entity() { return entity; }
public AsmOperand address() {
public Operand address() {
return entity.address();
}

View File

@ -65,23 +65,23 @@ public class AssemblyFile {
assemblies.add(new Instruction(op));
}
protected void insn(String op, AsmOperand a) {
protected void insn(String op, Operand a) {
assemblies.add(new Instruction(op, "", a));
}
protected void insn(String op, String suffix, AsmOperand a) {
protected void insn(String op, String suffix, Operand a) {
assemblies.add(new Instruction(op, suffix, a));
}
protected void insn(Type t, String op, AsmOperand a) {
protected void insn(Type t, String op, Operand a) {
assemblies.add(new Instruction(op, typeSuffix(t), a));
}
protected void insn(String op, String suffix, AsmOperand a, AsmOperand b) {
protected void insn(String op, String suffix, Operand a, Operand b) {
assemblies.add(new Instruction(op, suffix, a, b));
}
protected void insn(Type t, String op, AsmOperand a, AsmOperand b) {
protected void insn(Type t, String op, Operand a, Operand b) {
assemblies.add(new Instruction(op, typeSuffix(t), a, b));
}
@ -276,7 +276,7 @@ public class AssemblyFile {
insn("jne", new DirectMemoryReference(label.symbol()));
}
public void cmp(Type t, AsmOperand a, Register b) {
public void cmp(Type t, Operand a, Register b) {
insn(t, "cmp", a, b);
}
@ -346,52 +346,52 @@ public class AssemblyFile {
insn("ret");
}
public void mov(AsmOperand src, AsmOperand dest) {
public void mov(Operand src, Operand dest) {
mov(naturalType, src, dest);
}
// for stack access
public void relocatableMov(AsmOperand src, AsmOperand dest) {
public void relocatableMov(Operand src, Operand dest) {
assemblies.add(new Instruction("mov", typeSuffix(naturalType), src, dest, true));
}
public void mov(Type type, AsmOperand src, AsmOperand dest) {
public void mov(Type type, Operand src, Operand dest) {
insn(type, "mov", src, dest);
}
public void movsx(Type t1, Type t2, AsmOperand src, AsmOperand dest) {
public void movsx(Type t1, Type t2, Operand src, Operand dest) {
insn("movs", typeSuffix(t1, t2), src, dest);
}
public void movsbl(AsmOperand src, AsmOperand dest) {
public void movsbl(Operand src, Operand dest) {
insn("movs", "bl", src, dest);
}
public void movswl(AsmOperand src, AsmOperand dest) {
public void movswl(Operand src, Operand dest) {
insn("movs", "wl", src, dest);
}
public void movzx(Type t1, Type t2, AsmOperand src, AsmOperand dest) {
public void movzx(Type t1, Type t2, Operand src, Operand dest) {
insn("movz", typeSuffix(t1, t2), src, dest);
}
public void movzb(Type t, AsmOperand src, AsmOperand dest) {
public void movzb(Type t, Operand src, Operand dest) {
insn("movz", "b" + typeSuffix(t), src, dest);
}
public void movzbl(AsmOperand src, AsmOperand dest) {
public void movzbl(Operand src, Operand dest) {
insn("movz", "bl", src, dest);
}
public void movzwl(AsmOperand src, AsmOperand dest) {
public void movzwl(Operand src, Operand dest) {
insn("movz", "wl", src, dest);
}
public void lea(AsmOperand src, AsmOperand dest) {
public void lea(Operand src, Operand dest) {
lea(naturalType, src, dest);
}
public void lea(Type type, AsmOperand src, AsmOperand dest) {
public void lea(Type type, Operand src, Operand dest) {
insn(type, "lea", src, dest);
}
@ -399,35 +399,35 @@ public class AssemblyFile {
insn(type, "neg", reg);
}
public void inc(Type type, AsmOperand reg) {
public void inc(Type type, Operand reg) {
insn(type, "inc", reg);
}
public void dec(Type type, AsmOperand reg) {
public void dec(Type type, Operand reg) {
insn(type, "dec", reg);
}
public void add(AsmOperand diff, AsmOperand base) {
public void add(Operand diff, Operand base) {
add(naturalType, diff, base);
}
public void add(Type type, AsmOperand diff, AsmOperand base) {
public void add(Type type, Operand diff, Operand base) {
insn(type, "add", diff, base);
}
public void sub(AsmOperand diff, AsmOperand base) {
public void sub(Operand diff, Operand base) {
sub(naturalType, diff, base);
}
public void sub(Type type, AsmOperand diff, AsmOperand base) {
public void sub(Type type, Operand diff, Operand base) {
insn(type, "sub", diff, base);
}
public void imul(AsmOperand m, Register base) {
public void imul(Operand m, Register base) {
imul(naturalType, m, base);
}
public void imul(Type type, AsmOperand m, Register base) {
public void imul(Type type, Operand m, Register base) {
insn(type, "imul", m, base);
}
@ -447,15 +447,15 @@ public class AssemblyFile {
insn(type, "not", reg);
}
public void and(Type type, AsmOperand bits, Register base) {
public void and(Type type, Operand bits, Register base) {
insn(type, "and", bits, base);
}
public void or(Type type, AsmOperand bits, Register base) {
public void or(Type type, Operand bits, Register base) {
insn(type, "or", bits, base);
}
public void xor(Type type, AsmOperand bits, Register base) {
public void xor(Type type, Operand bits, Register base) {
insn(type, "xor", bits, base);
}

View File

@ -750,7 +750,7 @@ public class CodeGenerator
// #@@range/Bin{
public Void visit(Bin node) {
AsmOperand right = null;
Operand right = null;
if (!doesSpillRegister(node.op()) && node.right().isConstant()){
compile(node.left());
right = node.right().asmValue();
@ -791,7 +791,7 @@ public class CodeGenerator
// #@@range/compileBinaryOp_begin{
private void compileBinaryOp(Type t, Op op,
Register left, AsmOperand right) {
Register left, Operand right) {
// #@@range/compileBinaryOp_arithops{
switch (op) {
case ADD:

View File

@ -234,7 +234,7 @@ public class PeepholeOptimizer {
}
class AnyRegisterPattern implements OperandPattern {
public boolean match(AsmOperand operand) {
public boolean match(Operand operand) {
return operand.isRegister();
}
}