refactor(furlang/ir): add version to register_operand

Refs: #2
This commit is contained in:
2026-06-12 14:07:09 +02:00
parent 865691df26
commit 6b92e19b23
2 changed files with 29 additions and 7 deletions
+26 -4
View File
@@ -19,11 +19,33 @@ enum class operand_t {
String, /**< String */
};
/**
* @brief Alias to a register type.
*/
using register_t = std::uint32_t;
/**
* @brief Register operand alias.
* @see operand_t::Register
*/
using register_operand = std::uint32_t;
struct register_operand {
register_t reg;
std::uint32_t ver = 0;
register_operand(register_t reg)
: reg(reg) {}
register_operand(register_t reg, std::uint32_t ver)
: reg(reg), ver(ver) {}
operator std::uint32_t&() { return reg; }
operator const std::uint32_t&() const { return reg; }
friend std::ostream& operator<<(std::ostream& os, const register_operand& op) {
return os << op.reg << '_' << op.ver;
}
};
/**
* @brief Variable operand alias.
* @see operand_t::Variable
@@ -108,10 +130,10 @@ public:
* @param value Value of the new register operand.
* @return The register operand.
*/
static operand new_reg(register_operand value) {
static operand new_reg(register_t value) {
operand operand;
operand.m_type = operand_t::Register;
operand.m_value.reg = value;
operand.m_value.reg = { value, 0 };
return operand;
}
@@ -228,4 +250,4 @@ private:
} // namespace ir
} // namespace furlang
#endif // FURLANG_IR_OPERAND_HPP
#endif // FURLANG_IR_OPERAND_HPP