ir/basic_block: Add FastDispatchHint to TerminalToString

Use a boost::static_visitor to ensure this is caught at compile-time in the future.
This commit is contained in:
MerryMage 2020-03-21 13:17:43 +00:00
parent af3614553b
commit e10985d179

View file

@ -123,40 +123,40 @@ const size_t& Block::CycleCount() const {
} }
static std::string TerminalToString(const Terminal& terminal_variant) { static std::string TerminalToString(const Terminal& terminal_variant) {
switch (terminal_variant.which()) { struct : boost::static_visitor<std::string> {
case 1: { std::string operator()(const Term::Invalid&) const {
auto terminal = boost::get<IR::Term::Interpret>(terminal_variant); return "<invalid terminal>";
return fmt::format("Interpret{{{}}}", terminal.next); }
} std::string operator()(const Term::Interpret& terminal) const {
case 2: { return fmt::format("Interpret{{{}}}", terminal.next);
return "ReturnToDispatch{}"; }
} std::string operator()(const Term::ReturnToDispatch&) const {
case 3: { return "ReturnToDispatch{}";
auto terminal = boost::get<IR::Term::LinkBlock>(terminal_variant); }
return fmt::format("LinkBlock{{{}}}", terminal.next); std::string operator()(const Term::LinkBlock& terminal) const {
} return fmt::format("LinkBlock{{{}}}", terminal.next);
case 4: { }
auto terminal = boost::get<IR::Term::LinkBlockFast>(terminal_variant); std::string operator()(const Term::LinkBlockFast& terminal) const {
return fmt::format("LinkBlockFast{{{}}}", terminal.next); return fmt::format("LinkBlockFast{{{}}}", terminal.next);
} }
case 5: { std::string operator()(const Term::PopRSBHint&) const {
return "PopRSBHint{}"; return "PopRSBHint{}";
} }
case 6: { std::string operator()(const Term::FastDispatchHint&) const {
auto terminal = boost::get<IR::Term::If>(terminal_variant); return "FastDispatchHint{}";
return fmt::format("If{{{}, {}, {}}}", A64::CondToString(terminal.if_), TerminalToString(terminal.then_), TerminalToString(terminal.else_)); }
} std::string operator()(const Term::If& terminal) const {
case 7: { return fmt::format("If{{{}, {}, {}}}", A64::CondToString(terminal.if_), TerminalToString(terminal.then_), TerminalToString(terminal.else_));
auto terminal = boost::get<IR::Term::CheckBit>(terminal_variant); }
return fmt::format("CheckBit{{{}, {}}}", TerminalToString(terminal.then_), TerminalToString(terminal.else_)); std::string operator()(const Term::CheckBit& terminal) const {
} return fmt::format("CheckBit{{{}, {}}}", TerminalToString(terminal.then_), TerminalToString(terminal.else_));
case 8: { }
auto terminal = boost::get<IR::Term::CheckHalt>(terminal_variant); std::string operator()(const Term::CheckHalt& terminal) const {
return fmt::format("CheckHalt{{{}}}", TerminalToString(terminal.else_)); return fmt::format("CheckHalt{{{}}}", TerminalToString(terminal.else_));
} }
default: } visitor;
return "<invalid terminal>";
} return boost::apply_visitor(visitor, terminal_variant);
} }
std::string DumpBlock(const IR::Block& block) { std::string DumpBlock(const IR::Block& block) {