refactor(dev): 统一 IR/MIR 接口命名风格

This commit is contained in:
Lane0218
2026-03-12 15:17:02 +08:00
parent f26551a896
commit b1155d8fa9
18 changed files with 170 additions and 167 deletions

View File

@@ -41,10 +41,10 @@ class Operand {
static Operand Imm(int value);
static Operand FrameIndex(int index);
Kind kind() const { return kind_; }
PhysReg reg() const { return reg_; }
int imm() const { return imm_; }
int frame_index() const { return imm_; }
Kind GetKind() const { return kind_; }
PhysReg GetReg() const { return reg_; }
int GetImm() const { return imm_; }
int GetFrameIndex() const { return imm_; }
private:
Operand(Kind kind, PhysReg reg, int imm);
@@ -58,8 +58,8 @@ class MachineInstr {
public:
MachineInstr(Opcode opcode, std::vector<Operand> operands = {});
Opcode opcode() const { return opcode_; }
const std::vector<Operand>& operands() const { return operands_; }
Opcode GetOpcode() const { return opcode_; }
const std::vector<Operand>& GetOperands() const { return operands_; }
private:
Opcode opcode_;
@@ -76,9 +76,9 @@ class MachineBasicBlock {
public:
explicit MachineBasicBlock(std::string name);
const std::string& name() const { return name_; }
std::vector<MachineInstr>& instructions() { return instructions_; }
const std::vector<MachineInstr>& instructions() const { return instructions_; }
const std::string& GetName() const { return name_; }
std::vector<MachineInstr>& GetInstructions() { return instructions_; }
const std::vector<MachineInstr>& GetInstructions() const { return instructions_; }
MachineInstr& Append(Opcode opcode,
std::initializer_list<Operand> operands = {});
@@ -92,17 +92,17 @@ class MachineFunction {
public:
explicit MachineFunction(std::string name);
const std::string& name() const { return name_; }
MachineBasicBlock& entry() { return entry_; }
const MachineBasicBlock& entry() const { return entry_; }
const std::string& GetName() const { return name_; }
MachineBasicBlock& GetEntry() { return entry_; }
const MachineBasicBlock& GetEntry() const { return entry_; }
int CreateFrameIndex(int size = 4);
FrameSlot& frame_slot(int index);
const FrameSlot& frame_slot(int index) const;
const std::vector<FrameSlot>& frame_slots() const { return frame_slots_; }
FrameSlot& GetFrameSlot(int index);
const FrameSlot& GetFrameSlot(int index) const;
const std::vector<FrameSlot>& GetFrameSlots() const { return frame_slots_; }
int frame_size() const { return frame_size_; }
void set_frame_size(int size) { frame_size_ = size; }
int GetFrameSize() const { return frame_size_; }
void SetFrameSize(int size) { frame_size_ = size; }
private:
std::string name_;