|
|
|
|
@ -2,6 +2,7 @@
|
|
|
|
|
|
|
|
|
|
#include <ostream>
|
|
|
|
|
#include <stdexcept>
|
|
|
|
|
#include <set>
|
|
|
|
|
|
|
|
|
|
#include "utils/Log.h"
|
|
|
|
|
|
|
|
|
|
@ -447,10 +448,21 @@ void PrintAsm(const MachineModule& module, std::ostream& os) {
|
|
|
|
|
os << ".size " << g.name << ", " << g.size << "\n\n";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static const std::set<std::string> externalFuncs = {
|
|
|
|
|
"getint", "getch", "getarray", "putint", "putch", "putarray", "puts",
|
|
|
|
|
"_sysy_starttime", "_sysy_stoptime", "starttime", "stoptime",
|
|
|
|
|
"getfloat", "putfloat", "getfarray", "putfarray", "memset",
|
|
|
|
|
"sysy_alloc_i32", "sysy_alloc_f32", "sysy_free_i32", "sysy_free_f32",
|
|
|
|
|
"sysy_zero_i32", "sysy_zero_f32"
|
|
|
|
|
};
|
|
|
|
|
DEBUG_MSG("module");
|
|
|
|
|
// 遍历所有函数,输出汇编
|
|
|
|
|
for (const auto& func : module.GetFunctions()) {
|
|
|
|
|
|
|
|
|
|
if (externalFuncs.count(func->GetName())) {
|
|
|
|
|
continue; // 跳过库函数桩
|
|
|
|
|
}
|
|
|
|
|
DEBUG_MSG("func");
|
|
|
|
|
PrintAsm(*func, os);
|
|
|
|
|
os << "\n";
|
|
|
|
|
|