You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
nudt-compiler-cpp/src/mir/MIRInstr.cpp

44 lines
1.1 KiB

#include "mir/MIR.h"
#include <utility>
namespace mir
{
Operand::Operand(Kind kind, PhysReg reg, int imm,
VRegClass vreg_class, std::string symbol)
: kind_(kind), reg_(reg), imm_(imm),
symbol_(std::move(symbol)), vreg_class_(vreg_class) {}
Operand Operand::Reg(PhysReg reg) { return Operand(Kind::Reg, reg, 0); }
Operand Operand::VReg(int id, VRegClass vreg_class)
{
return Operand(Kind::VReg, PhysReg::W0, id, vreg_class);
}
Operand Operand::Imm(int value)
{
return Operand(Kind::Imm, PhysReg::W0, value);
}
Operand Operand::FrameIndex(int index)
{
return Operand(Kind::FrameIndex, PhysReg::W0, index);
}
Operand Operand::Label(int label_id)
{
return Operand(Kind::Label, PhysReg::W0, label_id);
}
Operand Operand::Symbol(std::string symbol)
{
return Operand(Kind::Symbol, PhysReg::W0, 0, VRegClass::Int, std::move(symbol));
}
MachineInstr::MachineInstr(Opcode opcode, std::vector<Operand> operands)
: opcode_(opcode), operands_(std::move(operands)) {}
} // namespace mir