[midend]同上,删除了打印函数对维度信息的错误访问
This commit is contained in:
@ -1148,7 +1148,6 @@ public:
|
||||
Type* getAllocatedType() const {
|
||||
return getType()->as<PointerType>()->getBaseType();
|
||||
} ///< 获取分配的类型
|
||||
int getNumDims() const { return getNumOperands(); }
|
||||
|
||||
}; // class AllocaInst
|
||||
|
||||
@ -1203,12 +1202,7 @@ protected:
|
||||
}
|
||||
|
||||
public:
|
||||
int getNumIndices() const { return getNumOperands() - 1; }
|
||||
Value* getPointer() const { return getOperand(0); }
|
||||
auto getIndices() const {
|
||||
return make_range(std::next(operand_begin()), operand_end());
|
||||
}
|
||||
Value* getIndex(int index) const { return getOperand(index + 1); }
|
||||
|
||||
}; // class LoadInst
|
||||
|
||||
@ -1474,9 +1468,6 @@ class ConstantVariable : public Value {
|
||||
|
||||
return getByIndex(index);
|
||||
} ///< 通过多维索引indices获取初始值
|
||||
// unsigned getNumDims() const { return numDims; } ///< 获取维度数量
|
||||
// Value* getDim(unsigned index) const { return getOperand(index); } ///< 获取位置为index的维度
|
||||
// auto getDims() const { return getOperands(); } ///< 获取维度列表
|
||||
const ValueCounter& getInitValues() const { return initValues; } ///< 获取初始值
|
||||
};
|
||||
|
||||
|
||||
@ -462,9 +462,9 @@ Function * Function::clone(const std::string &suffix) const {
|
||||
newPointer = oldNewValueMap.at(oldPointer);
|
||||
|
||||
std::vector<Value *> newIndices;
|
||||
for (const auto &index : oldLoadInst->getIndices()) {
|
||||
newIndices.emplace_back(oldNewValueMap.at(index->getValue()));
|
||||
}
|
||||
// for (const auto &index : oldLoadInst->getIndices()) {
|
||||
// newIndices.emplace_back(oldNewValueMap.at(index->getValue()));
|
||||
// }
|
||||
ss << oldLoadInst->getName() << suffix;
|
||||
// TODO : 这里的newLoadInst的类型需要根据oldLoadInst的类型来推断
|
||||
auto newLoadInst = new LoadInst(newPointer, oldNewBlockMap.at(oldLoadInst->getParent()), ss.str());
|
||||
|
||||
@ -411,17 +411,6 @@ void SysYPrinter::printInst(Instruction *pInst) {
|
||||
auto allocatedType = allocaInst->getAllocatedType();
|
||||
printType(allocatedType);
|
||||
|
||||
// 仍然打印维度信息,如果存在的话
|
||||
if (allocaInst->getNumDims() > 0) {
|
||||
std::cout << ", ";
|
||||
for (size_t i = 0; i < allocaInst->getNumDims(); i++) {
|
||||
if (i > 0) std::cout << ", ";
|
||||
printType(Type::getIntType()); // 维度大小通常是 i32 类型
|
||||
std::cout << " ";
|
||||
printValue(allocaInst->getDim(i));
|
||||
}
|
||||
}
|
||||
|
||||
std::cout << ", align 4" << std::endl;
|
||||
} break;
|
||||
|
||||
@ -434,17 +423,6 @@ void SysYPrinter::printInst(Instruction *pInst) {
|
||||
std::cout << " ";
|
||||
printValue(loadInst->getPointer()); // 要加载的地址
|
||||
|
||||
// 仍然打印索引信息,如果存在的话
|
||||
if (loadInst->getNumIndices() > 0) {
|
||||
std::cout << ", indices "; // 或者其他分隔符,取决于你期望的格式
|
||||
for (size_t i = 0; i < loadInst->getNumIndices(); i++) {
|
||||
if (i > 0) std::cout << ", ";
|
||||
printType(loadInst->getIndex(i)->getType());
|
||||
std::cout << " ";
|
||||
printValue(loadInst->getIndex(i));
|
||||
}
|
||||
}
|
||||
|
||||
std::cout << ", align 4" << std::endl;
|
||||
} break;
|
||||
|
||||
@ -459,16 +437,6 @@ void SysYPrinter::printInst(Instruction *pInst) {
|
||||
std::cout << " ";
|
||||
printValue(storeInst->getPointer()); // 目标地址
|
||||
|
||||
// 仍然打印索引信息,如果存在的话
|
||||
if (storeInst->getNumIndices() > 0) {
|
||||
std::cout << ", indices "; // 或者其他分隔符
|
||||
for (size_t i = 0; i < storeInst->getNumIndices(); i++) {
|
||||
if (i > 0) std::cout << ", ";
|
||||
printType(storeInst->getIndex(i)->getType());
|
||||
std::cout << " ";
|
||||
printValue(storeInst->getIndex(i));
|
||||
}
|
||||
}
|
||||
|
||||
std::cout << ", align 4" << std::endl;
|
||||
} break;
|
||||
|
||||
Reference in New Issue
Block a user