diff --git a/furc/src/front/ssa.cpp b/furc/src/front/ssa.cpp index 34603ff..47c70d3 100644 --- a/furc/src/front/ssa.cpp +++ b/furc/src/front/ssa.cpp @@ -22,8 +22,8 @@ void ssa::optimize(const std::unique_ptr& func) { block_map_t predecessors; block_map_t successors; - std::unordered_map> regSites; - std::unordered_map> regUses; + std::unordered_map> regSites; + std::unordered_map> regUses; std::unordered_map idoms; @@ -139,7 +139,7 @@ void ssa::optimize(const std::unique_ptr& func) { } } - std::unordered_map> phis; + std::unordered_map> phis; for (const auto& [reg, blocks] : regSites) { std::vector worklist(blocks.begin(), blocks.end()); diff --git a/furlang/include/furlang/ir/operand.hpp b/furlang/include/furlang/ir/operand.hpp index dff75f3..e866123 100644 --- a/furlang/include/furlang/ir/operand.hpp +++ b/furlang/include/furlang/ir/operand.hpp @@ -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 \ No newline at end of file +#endif // FURLANG_IR_OPERAND_HPP