修复IR函数参数输出,变量命名
This commit is contained in:
@@ -598,11 +598,11 @@ auto SymbolTable::addVariable(const std::string &name, User *variable) -> User *
|
||||
std::stringstream ss;
|
||||
auto iter = variableIndex.find(name);
|
||||
if (iter != variableIndex.end()) {
|
||||
ss << name << "(" << iter->second << ")";
|
||||
ss << name << iter->second ;
|
||||
iter->second += 1;
|
||||
} else {
|
||||
variableIndex.emplace(name, 1);
|
||||
ss << name << "(" << 0 << ")";
|
||||
ss << name << 0 ;
|
||||
}
|
||||
|
||||
variable->setName(ss.str());
|
||||
|
||||
@@ -128,12 +128,15 @@ void SysYPrinter::printFunction(Function *function) {
|
||||
std::cout << " @" << function->getName() << "(";
|
||||
|
||||
auto entryBlock = function->getEntryBlock();
|
||||
const auto &args_types = function->getParamTypes();
|
||||
auto &args = entryBlock->getArguments();
|
||||
|
||||
for (size_t i = 0; i < args.size(); i++) {
|
||||
int i = 0;
|
||||
for (const auto &args_type : args_types) {
|
||||
if (i > 0) std::cout << ", ";
|
||||
printType(args[i]->getType());
|
||||
printType(args_type);
|
||||
std::cout << " %" << args[i]->getName();
|
||||
i++;
|
||||
}
|
||||
|
||||
std::cout << ") {" << std::endl;
|
||||
|
||||
Reference in New Issue
Block a user