mips without optimize
This commit is contained in:
47
midend/llvm/instr/PutIntInstr.java
Normal file → Executable file
47
midend/llvm/instr/PutIntInstr.java
Normal file → Executable file
@@ -1,19 +1,28 @@
|
||||
package midend.llvm.instr;
|
||||
|
||||
import midend.llvm.type.IrInterType;
|
||||
import midend.llvm.value.IrValue;
|
||||
|
||||
public class PutIntInstr extends IrInstr {
|
||||
public PutIntInstr(String name, IrValue putValue) {
|
||||
super(IrInterType.VOID, name, IrInstrType.IO);
|
||||
addUse(putValue);
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "call void @putint(i32 " + getUses().get(0).getName() + ")";
|
||||
}
|
||||
|
||||
public static String putIntDecl() {
|
||||
return "declare void @putint(i32)";
|
||||
}
|
||||
}
|
||||
package midend.llvm.instr;
|
||||
|
||||
import midend.llvm.type.IrInterType;
|
||||
import midend.llvm.value.IrValue;
|
||||
import backend.mips.Register;
|
||||
import backend.mips.instr.fake.MipsLi;
|
||||
import backend.mips.instr.MipsSyscall;
|
||||
|
||||
public class PutIntInstr extends IrInstr {
|
||||
public PutIntInstr(String name, IrValue putValue) {
|
||||
super(IrInterType.VOID, name, IrInstrType.IO);
|
||||
addUse(putValue);
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "call void @putint(i32 " + getUses().get(0).getName() + ")";
|
||||
}
|
||||
|
||||
public static String putIntDecl() {
|
||||
return "declare void @putint(i32)";
|
||||
}
|
||||
|
||||
public void toMips() {
|
||||
loadValueToReg(getUse(0), Register.A0);
|
||||
new MipsLi(Register.V0, 1);
|
||||
new MipsSyscall();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user