#include "mir/MIR.h"

#include <stdexcept>
#include <string>

#include "utils/Log.h"

namespace mir {

const char* PhysRegName(PhysReg reg) {
  switch (reg) {
    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::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::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::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::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::X29: return "x29";
    case PhysReg::X30: return "x30";
    case PhysReg::SP: return "sp";
  }
  throw std::runtime_error(FormatError("mir", "未知物理寄存器"));
}

}  // namespace mir
