mips without optimize

This commit is contained in:
colden
2025-12-12 20:14:00 +08:00
parent 84827838e2
commit c94bebf37b
130 changed files with 5462 additions and 4182 deletions

47
midend/llvm/instr/PutIntInstr.java Normal file → Executable file
View 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();
}
}