38 lines
935 B
C++
38 lines
935 B
C++
#include "mir/MIR.h"
|
|
|
|
#include <utility>
|
|
|
|
namespace mir {
|
|
|
|
Operand::Operand(Kind kind, PhysReg reg, int imm, std::string str)
|
|
: kind_(kind), reg_(reg), imm_(imm), str_(std::move(str)) {}
|
|
|
|
Operand Operand::Reg(PhysReg reg) {
|
|
return Operand(Kind::Reg, reg, 0);
|
|
}
|
|
|
|
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::Global(std::string name) {
|
|
return Operand(Kind::Global, PhysReg::W0, 0, std::move(name));
|
|
}
|
|
|
|
Operand Operand::Label(std::string name) {
|
|
return Operand(Kind::Label, PhysReg::W0, 0, std::move(name));
|
|
}
|
|
|
|
Operand Operand::Cond(std::string cond) {
|
|
return Operand(Kind::Cond, PhysReg::W0, 0, std::move(cond));
|
|
}
|
|
|
|
MachineInstr::MachineInstr(Opcode opcode, std::vector<Operand> operands)
|
|
: opcode_(opcode), operands_(std::move(operands)) {}
|
|
|
|
} // namespace mir
|