SIL: fix APIs for (re)moving instructions

Instructions can only be moved and erased, but never _removed_ from a block.
This commit is contained in:
Erik Eckstein
2022-12-02 14:36:42 +01:00
parent a7726f19aa
commit 2ca9a3b9ce
5 changed files with 22 additions and 28 deletions

View File

@@ -91,10 +91,6 @@ void SILBasicBlock::push_front(SILInstruction *I) {
InstList.push_front(I);
}
void SILBasicBlock::remove(SILInstruction *I) {
InstList.remove(I);
}
void SILBasicBlock::eraseAllInstructions(SILModule &module) {
while (!empty()) {
erase(&*begin(), module);
@@ -112,6 +108,21 @@ void SILBasicBlock::erase(SILInstruction *I, SILModule &module) {
module.scheduleForDeletion(I);
}
void SILBasicBlock::moveInstruction(SILInstruction *inst,
SILInstruction *beforeInst) {
if (inst == beforeInst)
return;
inst->getParent()->InstList.remove(inst);
inst->ParentBB = nullptr;
beforeInst->getParent()->insert(beforeInst->getIterator(), inst);
}
void SILBasicBlock::moveInstructionToFront(SILInstruction *inst) {
inst->getParent()->InstList.remove(inst);
inst->ParentBB = nullptr;
push_front(inst);
}
/// This method unlinks 'self' from the containing SILFunction and deletes it.
void SILBasicBlock::eraseFromParent() {
getParent()->eraseBlock(this);