This commit is contained in:
邓智航
2025-12-25 15:07:20 +08:00
parent c94bebf37b
commit a9b8e82fd5
12 changed files with 483 additions and 13 deletions

View File

@@ -35,6 +35,27 @@ public class IrBasicBlock extends IrValue {
instr.setBBlock(this);
}
public void addInstr(IrInstr instr, int index) {
instrs.add(index, instr);
instr.setBBlock(this);
}
public void deleteInstr(IrInstr instr) {
instrs.remove(instr);
instr.setBBlock(null);
instr.clearUses();
instr.clearUsers();
}
public void clearAllInstrs() {
for (IrInstr instr : instrs) {
instr.setBBlock(null);
instr.clearUses();
instr.clearUsers();
}
instrs.clear();
}
public IrFuncValue getFunc() {
return func;
}
@@ -87,6 +108,20 @@ public class IrBasicBlock extends IrValue {
return instrs;
}
public IrInstr getFirstInstr() {
if (instrs.isEmpty()) {
return null;
}
return instrs.get(0);
}
public IrInstr getLastInstr() {
if (instrs.isEmpty()) {
return null;
}
return instrs.get(instrs.size() - 1);
}
public void addPred(IrBasicBlock bb) {
this.preds.add(bb);
}
@@ -119,6 +154,14 @@ public class IrBasicBlock extends IrValue {
return this.directDomi;
}
public HashSet<IrBasicBlock> getDirectDomies() {
return directDomies;
}
public HashSet<IrBasicBlock> getDomiFrontier() {
return domiFrontier;
}
public void toMips() {
new MipsLabel(getMipsLabel());
for (IrInstr instr : instrs) {