Merge branch 'backend' into deploy-20250820

This commit is contained in:
Lixuanwang
2025-08-20 03:17:50 +08:00
16 changed files with 378 additions and 79 deletions

View File

@@ -6,6 +6,7 @@
extern int DEBUG;
extern int DEEPDEBUG;
extern int optLevel;
namespace sysy {

View File

@@ -326,12 +326,19 @@ public:
void addBlock(std::unique_ptr<MachineBasicBlock> block) {
blocks.push_back(std::move(block));
}
void addProtectedArgumentVReg(unsigned vreg) {
protected_argument_vregs.insert(vreg);
}
const std::set<unsigned>& getProtectedArgumentVRegs() const {
return protected_argument_vregs;
}
private:
Function* F;
RISCv64ISel* isel; // 指向创建它的ISel用于获取vreg映射等信息
std::string name;
std::vector<std::unique_ptr<MachineBasicBlock>> blocks;
StackFrameInfo frame_info;
std::set<unsigned> protected_argument_vregs;
};
inline bool isMemoryOp(RVOpcodes opcode) {
switch (opcode) {

View File

@@ -45,12 +45,11 @@ private:
void rewriteProgram();
bool doAllocation();
void applyColoring();
void dumpState(const std::string &stage);
void precolorByCallingConvention();
void protectCrossCallVRegs();
// --- 辅助函数 ---
void dumpState(const std::string &stage);
void getInstrUseDef(const MachineInstr* instr, VRegSet& use, VRegSet& def);
void getInstrUseDef_Liveness(const MachineInstr *instr, VRegSet &use, VRegSet &def);
void addEdge(unsigned u, unsigned v);