From aed4577490dd4034caf864fb62328586368f9cac Mon Sep 17 00:00:00 2001 From: rain2133 <1370973498@qq.com> Date: Thu, 31 Jul 2025 19:57:19 +0800 Subject: [PATCH] =?UTF-8?q?[midend]=E5=90=8C=E4=B8=8A,=E5=88=A0=E9=99=A4?= =?UTF-8?q?=E4=BA=86=E6=89=93=E5=8D=B0=E5=87=BD=E6=95=B0=E5=AF=B9=E7=BB=B4?= =?UTF-8?q?=E5=BA=A6=E4=BF=A1=E6=81=AF=E7=9A=84=E9=94=99=E8=AF=AF=E8=AE=BF?= =?UTF-8?q?=E9=97=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/include/midend/IR.h | 9 --------- src/midend/IR.cpp | 6 +++--- src/midend/SysYIRPrinter.cpp | 32 -------------------------------- 3 files changed, 3 insertions(+), 44 deletions(-) diff --git a/src/include/midend/IR.h b/src/include/midend/IR.h index 1335e97..43a3a89 100644 --- a/src/include/midend/IR.h +++ b/src/include/midend/IR.h @@ -1148,7 +1148,6 @@ public: Type* getAllocatedType() const { return getType()->as()->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; } ///< 获取初始值 }; diff --git a/src/midend/IR.cpp b/src/midend/IR.cpp index e434ced..bee9968 100644 --- a/src/midend/IR.cpp +++ b/src/midend/IR.cpp @@ -462,9 +462,9 @@ Function * Function::clone(const std::string &suffix) const { newPointer = oldNewValueMap.at(oldPointer); std::vector 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()); diff --git a/src/midend/SysYIRPrinter.cpp b/src/midend/SysYIRPrinter.cpp index e2c5e17..61b9a6f 100644 --- a/src/midend/SysYIRPrinter.cpp +++ b/src/midend/SysYIRPrinter.cpp @@ -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;