forked from NUDT-compiler/nudt-compiler-cpp
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.
32 lines
897 B
32 lines
897 B
#include "mir/MIR.h"
|
|
|
|
#include <utility>
|
|
|
|
namespace mir {
|
|
|
|
Operand::Operand(Kind kind, PhysReg reg, int imm, CondCode cc, const std::string& label)
|
|
: kind_(kind), reg_(reg), imm_(imm), cc_(cc), label_(label) {}
|
|
|
|
Operand Operand::Reg(PhysReg reg) { return Operand(Kind::Reg, reg, 0, CondCode::EQ, ""); }
|
|
|
|
Operand Operand::Imm(int value) {
|
|
return Operand(Kind::Imm, PhysReg::W0, value, CondCode::EQ, "");
|
|
}
|
|
|
|
Operand Operand::FrameIndex(int index) {
|
|
return Operand(Kind::FrameIndex, PhysReg::W0, index, CondCode::EQ, "");
|
|
}
|
|
|
|
Operand Operand::Cond(CondCode cc) {
|
|
return Operand(Kind::Cond, PhysReg::W0, 0, cc, "");
|
|
}
|
|
|
|
Operand Operand::Label(const std::string& label) {
|
|
return Operand(Kind::Label, PhysReg::W0, 0, CondCode::EQ, label);
|
|
}
|
|
|
|
MachineInstr::MachineInstr(Opcode opcode, std::vector<Operand> operands)
|
|
: opcode_(opcode), operands_(std::move(operands)) {}
|
|
|
|
} // namespace mir
|