feat: complete Lab3 instruction selection and assembly generation
This commit is contained in:
@@ -4,10 +4,12 @@
|
||||
|
||||
namespace mir {
|
||||
|
||||
Operand::Operand(Kind kind, PhysReg reg, int imm)
|
||||
: kind_(kind), reg_(reg), imm_(imm) {}
|
||||
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::Reg(PhysReg reg) {
|
||||
return Operand(Kind::Reg, reg, 0);
|
||||
}
|
||||
|
||||
Operand Operand::Imm(int value) {
|
||||
return Operand(Kind::Imm, PhysReg::W0, value);
|
||||
@@ -17,6 +19,18 @@ 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)) {}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user