[backend]重构了后端

This commit is contained in:
Lixuanwang
2025-07-19 16:06:35 +08:00
parent 75e61bf274
commit d4a6996d74
10 changed files with 1336 additions and 1564 deletions

View File

@@ -0,0 +1,38 @@
#ifndef RISCV64_ASMPRINTER_H
#define RISCV64_ASMPRINTER_H
#include "RISCv64LLIR.h"
#include <iostream>
namespace sysy {
class RISCv64AsmPrinter {
public:
// 主入口将整个MachineFunction打印到指定的输出流
void runOnMachineFunction(MachineFunction* mfunc, std::ostream& os);
private:
// 打印单个基本块
void printBasicBlock(MachineBasicBlock* mbb);
// 打印单条指令
void printInstruction(MachineInstr* instr, MachineBasicBlock* parent_bb);
// 打印函数序言
void printPrologue(MachineFunction* mfunc);
// 打印函数尾声
void printEpilogue(MachineFunction* mfunc);
// 将物理寄存器枚举转换为字符串 (从原RISCv64Backend迁移)
std::string regToString(PhysicalReg reg);
// 打印单个操作数
void printOperand(MachineOperand* op);
std::ostream* OS; // 指向当前输出流
};
} // namespace sysy
#endif // RISCV64_ASMPRINTER_H