[backend] debugging segmentation fault caused by branch instr

This commit is contained in:
Lixuanwang
2025-06-23 17:02:29 +08:00
parent 7d37bd7528
commit ab3eb253f9
2 changed files with 248 additions and 90 deletions

View File

@@ -7,6 +7,7 @@
#include <map>
#include <set>
#include <memory>
#include <iostream>
namespace sysy {
@@ -19,7 +20,7 @@ public:
// Move DAGNode and RegAllocResult to public section
struct DAGNode {
enum NodeKind { CONSTANT, LOAD, STORE, BINARY, CALL, RETURN };
enum NodeKind { CONSTANT, LOAD, STORE, BINARY, CALL, RETURN, BRANCH };
NodeKind kind;
Value* value = nullptr;
std::string inst;
@@ -52,6 +53,7 @@ public:
RegAllocResult register_allocation(Function* func);
void eliminate_phi(Function* func);
std::string reg_to_string(PhysicalReg reg);
void print_dag(const std::vector<std::unique_ptr<DAGNode>>& dag, const std::string& bb_name);
private:
static const std::vector<PhysicalReg> allocable_regs;