fixed bugs brought out by merging
This commit is contained in:
@@ -35,16 +35,16 @@ std::string RISCv32CodeGen::code_gen() {
|
||||
std::string RISCv32CodeGen::module_gen() {
|
||||
std::stringstream ss;
|
||||
// 生成全局变量(数据段)
|
||||
for (const auto& global : *module->getGlobalValues()) {
|
||||
for (const auto& global : module->getGlobals()) {
|
||||
ss << ".data\n";
|
||||
ss << ".globl " << global.second->getName() << "\n";
|
||||
ss << global.second->getName() << ":\n";
|
||||
ss << ".globl " << global->getName() << "\n";
|
||||
ss << global->getName() << ":\n";
|
||||
ss << " .word 0\n"; // 假设初始化为0
|
||||
}
|
||||
// 生成函数
|
||||
// 生成函数(文本段)
|
||||
ss << ".text\n";
|
||||
for (const auto& func : *module->getFunctions()) {
|
||||
ss << function_gen(func.second);
|
||||
for (const auto& func : module->getFunctions()) {
|
||||
ss << function_gen(func.second.get());
|
||||
}
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user