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

45
midend/llvm/instr/JumpInstr.java Normal file → Executable file
View File

@@ -1,20 +1,25 @@
package midend.llvm.instr;
import midend.llvm.value.IrBasicBlock;
import midend.llvm.type.IrInterType;
public class JumpInstr extends IrInstr {
public JumpInstr(IrBasicBlock targetBlock) {
super(IrInterType.VOID, "jump", IrInstrType.JUMP);
addUse(targetBlock);
}
public IrBasicBlock getTargetBlock() {
return (IrBasicBlock) getUse(0);
}
public String toString() {
return "br label " + "%" + getTargetBlock().getName();
}
}
// TODO:所有的指令的基本块设置还需完善
package midend.llvm.instr;
import midend.llvm.value.IrBasicBlock;
import backend.mips.instr.MipsJump;
import backend.mips.instr.type.MipsJumpType;
import midend.llvm.type.IrInterType;
public class JumpInstr extends IrInstr {
public JumpInstr(IrBasicBlock targetBlock) {
super(IrInterType.VOID, "jump", IrInstrType.JUMP);
addUse(targetBlock);
}
public IrBasicBlock getTargetBlock() {
return (IrBasicBlock) getUse(0);
}
public String toString() {
return "br label " + "%" + getTargetBlock().getName();
}
public void toMips() {
new MipsJump(MipsJumpType.J, getTargetBlock().getMipsLabel()); //TODO: 该用JAL吗
}
}