#include "mir/MIR.h" #include #include "utils/Log.h" namespace mir { const char* PhysRegName(PhysReg reg) { switch (reg) { // 32位寄存器 case PhysReg::W0: return "w0"; case PhysReg::W1: return "w1"; case PhysReg::W2: return "w2"; case PhysReg::W3: return "w3"; case PhysReg::W4: return "w4"; case PhysReg::W5: return "w5"; case PhysReg::W6: return "w6"; case PhysReg::W7: return "w7"; case PhysReg::W8: return "w8"; case PhysReg::W9: return "w9"; case PhysReg::W10: return "w10"; case PhysReg::W11: return "w11"; case PhysReg::W12: return "w12"; case PhysReg::W13: return "w13"; case PhysReg::W14: return "w14"; case PhysReg::W15: return "w15"; case PhysReg::W16: return "w16"; // 添加 case PhysReg::W17: return "w17"; // 添加 case PhysReg::W18: return "w18"; // 添加 case PhysReg::W19: return "w19"; // 添加 case PhysReg::W20: return "w20"; // 添加 case PhysReg::W21: return "w21"; // 添加 case PhysReg::W22: return "w22"; // 添加 case PhysReg::W23: return "w23"; // 添加 case PhysReg::W24: return "w24"; // 添加 case PhysReg::W25: return "w25"; // 添加 case PhysReg::W26: return "w26"; // 添加 case PhysReg::W27: return "w27"; // 添加 case PhysReg::W28: return "w28"; // 添加 case PhysReg::W29: return "w29"; case PhysReg::W30: return "w30"; // 64位寄存器 case PhysReg::X0: return "x0"; case PhysReg::X1: return "x1"; case PhysReg::X2: return "x2"; case PhysReg::X3: return "x3"; case PhysReg::X4: return "x4"; case PhysReg::X5: return "x5"; case PhysReg::X6: return "x6"; case PhysReg::X7: return "x7"; case PhysReg::X8: return "x8"; case PhysReg::X9: return "x9"; case PhysReg::X10: return "x10"; // 添加 case PhysReg::X11: return "x11"; // 添加 case PhysReg::X12: return "x12"; // 添加 case PhysReg::X13: return "x13"; // 添加 case PhysReg::X14: return "x14"; // 添加 case PhysReg::X15: return "x15"; // 添加 case PhysReg::X16: return "x16"; // 添加 case PhysReg::X17: return "x17"; // 添加 case PhysReg::X18: return "x18"; // 添加 case PhysReg::X19: return "x19"; // 添加 case PhysReg::X20: return "x20"; // 添加 case PhysReg::X21: return "x21"; // 添加 case PhysReg::X22: return "x22"; // 添加 case PhysReg::X23: return "x23"; // 添加 case PhysReg::X24: return "x24"; // 添加 case PhysReg::X25: return "x25"; // 添加 case PhysReg::X26: return "x26"; // 添加 case PhysReg::X27: return "x27"; // 添加 case PhysReg::X28: return "x28"; // 添加 case PhysReg::X29: return "x29"; case PhysReg::X30: return "x30"; // 浮点寄存器 case PhysReg::S0: return "s0"; case PhysReg::S1: return "s1"; case PhysReg::S2: return "s2"; case PhysReg::S3: return "s3"; case PhysReg::S4: return "s4"; case PhysReg::S5: return "s5"; case PhysReg::S6: return "s6"; case PhysReg::S7: return "s7"; case PhysReg::S8: return "s8"; case PhysReg::S9: return "s9"; case PhysReg::S10: return "s10"; case PhysReg::S11: return "s11"; case PhysReg::S12: return "s12"; case PhysReg::S13: return "s13"; case PhysReg::S14: return "s14"; case PhysReg::S15: return "s15"; case PhysReg::S16: return "s16"; case PhysReg::S17: return "s17"; case PhysReg::S18: return "s18"; case PhysReg::S19: return "s19"; case PhysReg::S20: return "s20"; case PhysReg::S21: return "s21"; case PhysReg::S22: return "s22"; case PhysReg::S23: return "s23"; case PhysReg::S24: return "s24"; case PhysReg::S25: return "s25"; case PhysReg::S26: return "s26"; case PhysReg::S27: return "s27"; case PhysReg::S28: return "s28"; case PhysReg::S29: return "s29"; case PhysReg::S30: return "s30"; case PhysReg::S31: return "s31"; // 特殊寄存器 case PhysReg::SP: return "sp"; case PhysReg::ZR: return "xzr"; default: return "unknown"; } throw std::runtime_error(FormatError("mir", "未知物理寄存器")); } const char* CondCodeName(CondCode cc) { switch (cc) { case CondCode::EQ: return "eq"; case CondCode::NE: return "ne"; case CondCode::CS: return "cs"; case CondCode::CC: return "cc"; case CondCode::MI: return "mi"; case CondCode::PL: return "pl"; case CondCode::VS: return "vs"; case CondCode::VC: return "vc"; case CondCode::HI: return "hi"; case CondCode::LS: return "ls"; case CondCode::GE: return "ge"; case CondCode::LT: return "lt"; case CondCode::GT: return "gt"; case CondCode::LE: return "le"; case CondCode::AL: return "al"; default: return "unknown"; } throw std::runtime_error(FormatError("mir", "未知条件码")); } } // namespace mir