r4985@macbookpro: aamine | 2009-05-26 15:16:21 +0900

* net/loveruby/cflat/sysdep/x86/AssemblyFile.java: refactoring: apply strict visibility.
 


git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@4263 1b9489fe-b721-0410-924e-b54b9192deb8
This commit is contained in:
Minero Aoki 2009-05-26 07:52:42 +00:00
parent 1729dbaac0
commit 144393f6d4
2 changed files with 92 additions and 87 deletions

View File

@ -1,3 +1,8 @@
Tue May 26 15:16:04 2009 Minero Aoki <aamine@loveruby.net>
* net/loveruby/cflat/sysdep/x86/AssemblyFile.java: refactoring:
apply strict visibility.
Tue May 26 15:11:19 2009 Minero Aoki <aamine@loveruby.net>
* net/loveruby/cflat/compiler/Compiler.java: change CodeGenerator

View File

@ -7,13 +7,13 @@ import java.io.PrintStream;
public class AssemblyFile implements net.loveruby.cflat.sysdep.AssemblyFile {
private final List<Assembly> assemblies;
private final Type naturalType;
private final long stackWordSize;
private final SymbolTable labelSymbols;
private final boolean verbose;
final Type naturalType;
final long stackWordSize;
final SymbolTable labelSymbols;
final boolean verbose;
private int commentIndentLevel;
public AssemblyFile(Type naturalType, long stackWordSize,
AssemblyFile(Type naturalType, long stackWordSize,
SymbolTable labelSymbols, boolean verbose) {
this.naturalType = naturalType;
this.stackWordSize = stackWordSize;
@ -24,11 +24,11 @@ public class AssemblyFile implements net.loveruby.cflat.sysdep.AssemblyFile {
initVirtualStack();
}
public List<Assembly> assemblies() {
List<Assembly> assemblies() {
return this.assemblies;
}
public void addAll(List<Assembly> assemblies) {
void addAll(List<Assembly> assemblies) {
this.assemblies.addAll(assemblies);
}
@ -49,23 +49,23 @@ public class AssemblyFile implements net.loveruby.cflat.sysdep.AssemblyFile {
// FIXME
}
public void comment(String str) {
void comment(String str) {
assemblies.add(new Comment(str, commentIndentLevel));
}
public void indentComment() {
void indentComment() {
commentIndentLevel++;
}
public void unindentComment() {
void unindentComment() {
commentIndentLevel--;
}
public void label(Symbol sym) {
void label(Symbol sym) {
assemblies.add(new Label(sym));
}
public void label(Label label) {
void label(Label label) {
assemblies.add(label);
}
@ -116,91 +116,91 @@ public class AssemblyFile implements net.loveruby.cflat.sysdep.AssemblyFile {
// directives
//
public void _file(String name) {
void _file(String name) {
directive(".file\t" + TextUtils.dumpString(name));
}
public void _text() {
void _text() {
directive("\t.text");
}
public void _data() {
void _data() {
directive("\t.data");
}
public void _section(String name) {
void _section(String name) {
directive("\t.section\t" + name);
}
public void _section(String name, String flags, String type, String group, String linkage) {
void _section(String name, String flags, String type, String group, String linkage) {
directive("\t.section\t" + name + "," + flags + "," + type + "," + group + "," + linkage);
}
public void _globl(Symbol sym) {
void _globl(Symbol sym) {
directive(".globl " + sym.name());
}
public void _local(Symbol sym) {
void _local(Symbol sym) {
directive(".local " + sym.name());
}
public void _hidden(Symbol sym) {
void _hidden(Symbol sym) {
directive("\t.hidden\t" + sym.name());
}
public void _comm(Symbol sym, long size, long alignment) {
void _comm(Symbol sym, long size, long alignment) {
directive("\t.comm\t" + sym.name() + "," + size + "," + alignment);
}
public void _align(long n) {
void _align(long n) {
directive("\t.align\t" + n);
}
public void _type(Symbol sym, String type) {
void _type(Symbol sym, String type) {
directive("\t.type\t" + sym.name() + "," + type);
}
public void _size(Symbol sym, long size) {
void _size(Symbol sym, long size) {
_size(sym, new Long(size).toString());
}
public void _size(Symbol sym, String size) {
void _size(Symbol sym, String size) {
directive("\t.size\t" + sym.name() + "," + size);
}
public void _byte(long val) {
void _byte(long val) {
directive(".byte\t" + new IntegerLiteral((byte)val).toSource());
}
public void _value(long val) {
void _value(long val) {
directive(".value\t" + new IntegerLiteral((short)val).toSource());
}
public void _long(long val) {
void _long(long val) {
directive(".long\t" + new IntegerLiteral((int)val).toSource());
}
public void _quad(long val) {
void _quad(long val) {
directive(".quad\t" + new IntegerLiteral(val).toSource());
}
public void _byte(Literal val) {
void _byte(Literal val) {
directive(".byte\t" + val.toSource());
}
public void _value(Literal val) {
void _value(Literal val) {
directive(".value\t" + val.toSource());
}
public void _long(Literal val) {
void _long(Literal val) {
directive(".long\t" + val.toSource());
}
public void _quad(Literal val) {
void _quad(Literal val) {
directive(".quad\t" + val.toSource());
}
public void _string(String str) {
void _string(String str) {
directive("\t.string\t" + TextUtils.dumpString(str));
}
@ -271,218 +271,218 @@ public class AssemblyFile implements net.loveruby.cflat.sysdep.AssemblyFile {
// Instructions
//
public void jmp(Label label) {
void jmp(Label label) {
insn("jmp", new DirectMemoryReference(label.symbol()));
}
public void jz(Label label) {
void jz(Label label) {
insn("jz", new DirectMemoryReference(label.symbol()));
}
public void jnz(Label label) {
void jnz(Label label) {
insn("jnz", new DirectMemoryReference(label.symbol()));
}
public void je(Label label) {
void je(Label label) {
insn("je", new DirectMemoryReference(label.symbol()));
}
public void jne(Label label) {
void jne(Label label) {
insn("jne", new DirectMemoryReference(label.symbol()));
}
public void cmp(Type t, Operand a, Register b) {
void cmp(Type t, Operand a, Register b) {
insn(t, "cmp", a, b);
}
public void sete(Register reg) {
void sete(Register reg) {
insn("sete", reg);
}
public void setne(Register reg) {
void setne(Register reg) {
insn("setne", reg);
}
public void seta(Register reg) {
void seta(Register reg) {
insn("seta", reg);
}
public void setae(Register reg) {
void setae(Register reg) {
insn("setae", reg);
}
public void setb(Register reg) {
void setb(Register reg) {
insn("setb", reg);
}
public void setbe(Register reg) {
void setbe(Register reg) {
insn("setbe", reg);
}
public void setg(Register reg) {
void setg(Register reg) {
insn("setg", reg);
}
public void setge(Register reg) {
void setge(Register reg) {
insn("setge", reg);
}
public void setl(Register reg) {
void setl(Register reg) {
insn("setl", reg);
}
public void setle(Register reg) {
void setle(Register reg) {
insn("setle", reg);
}
public void test(Type type, Register a, Register b) {
void test(Type type, Register a, Register b) {
insn(type, "test", a, b);
}
public void push(Register reg) {
void push(Register reg) {
insn("push", typeSuffix(naturalType), reg);
}
public void pop(Register reg) {
void pop(Register reg) {
insn("pop", typeSuffix(naturalType), reg);
}
// call function by relative address
public void call(Symbol sym) {
void call(Symbol sym) {
insn("call", new DirectMemoryReference(sym));
}
// call function by absolute address
public void callAbsolute(Register reg) {
void callAbsolute(Register reg) {
insn("call", new AbsoluteAddress(reg));
}
public void ret() {
void ret() {
insn("ret");
}
public void mov(Operand src, Operand dest) {
void mov(Operand src, Operand dest) {
mov(naturalType, src, dest);
}
// for stack access
public void relocatableMov(Operand src, Operand dest) {
void relocatableMov(Operand src, Operand dest) {
assemblies.add(new Instruction("mov", typeSuffix(naturalType), src, dest, true));
}
public void mov(Type type, Operand src, Operand dest) {
void mov(Type type, Operand src, Operand dest) {
insn(type, "mov", src, dest);
}
public void movsx(Type t1, Type t2, Operand src, Operand dest) {
void movsx(Type t1, Type t2, Operand src, Operand dest) {
insn("movs", typeSuffix(t1, t2), src, dest);
}
public void movsbl(Operand src, Operand dest) {
void movsbl(Operand src, Operand dest) {
insn("movs", "bl", src, dest);
}
public void movswl(Operand src, Operand dest) {
void movswl(Operand src, Operand dest) {
insn("movs", "wl", src, dest);
}
public void movzx(Type t1, Type t2, Operand src, Operand dest) {
void movzx(Type t1, Type t2, Operand src, Operand dest) {
insn("movz", typeSuffix(t1, t2), src, dest);
}
public void movzb(Type t, Operand src, Operand dest) {
void movzb(Type t, Operand src, Operand dest) {
insn("movz", "b" + typeSuffix(t), src, dest);
}
public void movzbl(Operand src, Operand dest) {
void movzbl(Operand src, Operand dest) {
insn("movz", "bl", src, dest);
}
public void movzwl(Operand src, Operand dest) {
void movzwl(Operand src, Operand dest) {
insn("movz", "wl", src, dest);
}
public void lea(Operand src, Operand dest) {
void lea(Operand src, Operand dest) {
lea(naturalType, src, dest);
}
public void lea(Type type, Operand src, Operand dest) {
void lea(Type type, Operand src, Operand dest) {
insn(type, "lea", src, dest);
}
public void neg(Type type, Register reg) {
void neg(Type type, Register reg) {
insn(type, "neg", reg);
}
public void inc(Type type, Operand reg) {
void inc(Type type, Operand reg) {
insn(type, "inc", reg);
}
public void dec(Type type, Operand reg) {
void dec(Type type, Operand reg) {
insn(type, "dec", reg);
}
public void add(Operand diff, Operand base) {
void add(Operand diff, Operand base) {
add(naturalType, diff, base);
}
public void add(Type type, Operand diff, Operand base) {
void add(Type type, Operand diff, Operand base) {
insn(type, "add", diff, base);
}
public void sub(Operand diff, Operand base) {
void sub(Operand diff, Operand base) {
sub(naturalType, diff, base);
}
public void sub(Type type, Operand diff, Operand base) {
void sub(Type type, Operand diff, Operand base) {
insn(type, "sub", diff, base);
}
public void imul(Operand m, Register base) {
void imul(Operand m, Register base) {
imul(naturalType, m, base);
}
public void imul(Type type, Operand m, Register base) {
void imul(Type type, Operand m, Register base) {
insn(type, "imul", m, base);
}
public void cltd() {
void cltd() {
insn("cltd");
}
public void div(Type type, Register base) {
void div(Type type, Register base) {
insn(type, "div", base);
}
public void idiv(Type type, Register base) {
void idiv(Type type, Register base) {
insn(type, "idiv", base);
}
public void not(Type type, Register reg) {
void not(Type type, Register reg) {
insn(type, "not", reg);
}
public void and(Type type, Operand bits, Register base) {
void and(Type type, Operand bits, Register base) {
insn(type, "and", bits, base);
}
public void or(Type type, Operand bits, Register base) {
void or(Type type, Operand bits, Register base) {
insn(type, "or", bits, base);
}
public void xor(Type type, Operand bits, Register base) {
void xor(Type type, Operand bits, Register base) {
insn(type, "xor", bits, base);
}
public void sar(Type type, Register bits, Register base) {
void sar(Type type, Register bits, Register base) {
insn(type, "sar", bits, base);
}
public void sal(Type type, Register bits, Register base) {
void sal(Type type, Register bits, Register base) {
insn(type, "sal", bits, base);
}
public void shr(Type type, Register bits, Register base) {
void shr(Type type, Register bits, Register base) {
insn(type, "shr", bits, base);
}
}