[midend]修复phi指令接口,优化遍适配
This commit is contained in:
@@ -258,7 +258,7 @@ void User::removeOperand(unsigned index) {
|
||||
* phi相关函数
|
||||
*/
|
||||
|
||||
Value* PhiInst::getvalfromBlk(BasicBlock* blk) {
|
||||
Value* PhiInst::getValfromBlk(BasicBlock* blk) {
|
||||
refreshMap();
|
||||
if( blk2val.find(blk) != blk2val.end()) {
|
||||
return blk2val.at(blk);
|
||||
@@ -294,7 +294,7 @@ void PhiInst::removeIncomingValue(Value* val){
|
||||
void PhiInst::removeIncomingBlock(BasicBlock* blk){
|
||||
//根据Blk删除对应的基本块和值
|
||||
unsigned i = 0;
|
||||
Value* val = getvalfromBlk(blk);
|
||||
Value* val = getValfromBlk(blk);
|
||||
if(val == nullptr) {
|
||||
return; // 如果blk没有对应的值,直接返回
|
||||
}
|
||||
@@ -341,6 +341,21 @@ void PhiInst::replaceIncomingBlock(BasicBlock* newBlk, BasicBlock* oldBlk) {
|
||||
addIncoming(val, newBlk);
|
||||
}
|
||||
|
||||
void PhiInst::replaceIncomingValue(Value *oldValue, Value *newValue, BasicBlock *newBlock) {
|
||||
refreshMap();
|
||||
assert(blk2val.find(getBlkfromVal(oldValue)) != blk2val.end() && "PhiInst: oldValue not found in blk2val");
|
||||
auto oldBlock = getBlkfromVal(oldValue);
|
||||
removeIncomingValue(oldValue);
|
||||
addIncoming(newValue, newBlock);
|
||||
}
|
||||
|
||||
void PhiInst::replaceIncomingBlock(BasicBlock *oldBlock, BasicBlock *newBlock, Value *newValue) {
|
||||
refreshMap();
|
||||
assert(blk2val.find(oldBlock) != blk2val.end() && "PhiInst: oldBlock not found in blk2val");
|
||||
auto oldValue = blk2val[oldBlock];
|
||||
removeIncomingBlock(oldBlock);
|
||||
addIncoming(newValue, newBlock);
|
||||
}
|
||||
|
||||
CallInst::CallInst(Function *callee, const std::vector<Value *> &args, BasicBlock *parent, const std::string &name)
|
||||
: Instruction(kCall, callee->getReturnType(), parent, name) {
|
||||
|
||||
Reference in New Issue
Block a user