先将SCCP中重构IR的部分移植到backend

This commit is contained in:
rain2133
2025-07-19 15:00:04 +08:00
parent c8308047df
commit 36cfd2f64d
3 changed files with 342 additions and 74 deletions

View File

@@ -333,15 +333,11 @@ class IRBuilder {
block->getInstructions().emplace(position, inst);
return inst;
} ///< 创建store指令
PhiInst * createPhiInst(Type *type, Value *lhs, BasicBlock *parent, const std::string &name = "") {
auto predNum = parent->getNumPredecessors();
std::vector<Value *> rhs;
for (size_t i = 0; i < predNum; i++) {
rhs.push_back(lhs);
}
auto inst = new PhiInst(type, lhs, rhs, lhs, parent, name);
PhiInst * createPhiInst(Type *type, const std::vector<Value*> &vals = {}, const std::vector<BasicBlock*> &blks = {}, const std::string &name = "") {
auto predNum = block->getNumPredecessors();
auto inst = new PhiInst(type, vals, blks, block, name);
assert(inst);
parent->getInstructions().emplace(parent->begin(), inst);
block->getInstructions().emplace(block->begin(), inst);
return inst;
} ///< 创建Phi指令
};