location_descriptor: Provide operator<< string overload (#24)
This commit is contained in:
parent
5c8bf5a15d
commit
b40d19c3b7
4 changed files with 39 additions and 13 deletions
|
@ -12,6 +12,7 @@ set(SRCS
|
||||||
frontend/disassembler/disassembler_thumb.cpp
|
frontend/disassembler/disassembler_thumb.cpp
|
||||||
frontend/ir/basic_block.cpp
|
frontend/ir/basic_block.cpp
|
||||||
frontend/ir/ir_emitter.cpp
|
frontend/ir/ir_emitter.cpp
|
||||||
|
frontend/ir/location_descriptor.cpp
|
||||||
frontend/ir/microinstruction.cpp
|
frontend/ir/microinstruction.cpp
|
||||||
frontend/ir/opcodes.cpp
|
frontend/ir/opcodes.cpp
|
||||||
frontend/ir/value.cpp
|
frontend/ir/value.cpp
|
||||||
|
|
|
@ -91,30 +91,22 @@ const size_t& Block::CycleCount() const {
|
||||||
return cycle_count;
|
return cycle_count;
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::string LocDescToString(const LocationDescriptor& loc) {
|
|
||||||
return fmt::format("{{{},{},{},{}}}",
|
|
||||||
loc.PC(),
|
|
||||||
loc.TFlag() ? "T" : "!T",
|
|
||||||
loc.EFlag() ? "E" : "!E",
|
|
||||||
loc.FPSCR().Value());
|
|
||||||
}
|
|
||||||
|
|
||||||
static std::string TerminalToString(const Terminal& terminal_variant) {
|
static std::string TerminalToString(const Terminal& terminal_variant) {
|
||||||
switch (terminal_variant.which()) {
|
switch (terminal_variant.which()) {
|
||||||
case 1: {
|
case 1: {
|
||||||
auto terminal = boost::get<IR::Term::Interpret>(terminal_variant);
|
auto terminal = boost::get<IR::Term::Interpret>(terminal_variant);
|
||||||
return fmt::format("Interpret{{{}}}", LocDescToString(terminal.next));
|
return fmt::format("Interpret{{{}}}", terminal.next);
|
||||||
}
|
}
|
||||||
case 2: {
|
case 2: {
|
||||||
return "ReturnToDispatch{}";
|
return "ReturnToDispatch{}";
|
||||||
}
|
}
|
||||||
case 3: {
|
case 3: {
|
||||||
auto terminal = boost::get<IR::Term::LinkBlock>(terminal_variant);
|
auto terminal = boost::get<IR::Term::LinkBlock>(terminal_variant);
|
||||||
return fmt::format("LinkBlock{{{}}}", LocDescToString(terminal.next));
|
return fmt::format("LinkBlock{{{}}}", terminal.next);
|
||||||
}
|
}
|
||||||
case 4: {
|
case 4: {
|
||||||
auto terminal = boost::get<IR::Term::LinkBlockFast>(terminal_variant);
|
auto terminal = boost::get<IR::Term::LinkBlockFast>(terminal_variant);
|
||||||
return fmt::format("LinkBlockFast{{{}}}", LocDescToString(terminal.next));
|
return fmt::format("LinkBlockFast{{{}}}", terminal.next);
|
||||||
}
|
}
|
||||||
case 5: {
|
case 5: {
|
||||||
return "PopRSBHint{}";
|
return "PopRSBHint{}";
|
||||||
|
@ -135,11 +127,11 @@ static std::string TerminalToString(const Terminal& terminal_variant) {
|
||||||
std::string DumpBlock(const IR::Block& block) {
|
std::string DumpBlock(const IR::Block& block) {
|
||||||
std::string ret;
|
std::string ret;
|
||||||
|
|
||||||
ret += fmt::format("Block: location={}\n", LocDescToString(block.Location()));
|
ret += fmt::format("Block: location={}\n", block.Location());
|
||||||
ret += fmt::format("cycles={}", block.CycleCount());
|
ret += fmt::format("cycles={}", block.CycleCount());
|
||||||
ret += fmt::format(", entry_cond={}", Arm::CondToString(block.GetCondition(), true));
|
ret += fmt::format(", entry_cond={}", Arm::CondToString(block.GetCondition(), true));
|
||||||
if (block.GetCondition() != Arm::Cond::AL) {
|
if (block.GetCondition() != Arm::Cond::AL) {
|
||||||
ret += fmt::format(", cond_fail={}", LocDescToString(block.ConditionFailedLocation()));
|
ret += fmt::format(", cond_fail={}", block.ConditionFailedLocation());
|
||||||
}
|
}
|
||||||
ret += '\n';
|
ret += '\n';
|
||||||
|
|
||||||
|
|
24
src/frontend/ir/location_descriptor.cpp
Normal file
24
src/frontend/ir/location_descriptor.cpp
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
/* This file is part of the dynarmic project.
|
||||||
|
* Copyright (c) 2016 MerryMage
|
||||||
|
* This software may be used and distributed according to the terms of the GNU
|
||||||
|
* General Public License version 2 or any later version.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <ostream>
|
||||||
|
#include <fmt/format.h>
|
||||||
|
#include "frontend/ir/location_descriptor.h"
|
||||||
|
|
||||||
|
namespace Dynarmic {
|
||||||
|
namespace IR {
|
||||||
|
|
||||||
|
std::ostream& operator<<(std::ostream& o, const LocationDescriptor& loc) {
|
||||||
|
o << fmt::format("{{{},{},{},{}}}",
|
||||||
|
loc.PC(),
|
||||||
|
loc.TFlag() ? "T" : "!T",
|
||||||
|
loc.EFlag() ? "E" : "!E",
|
||||||
|
loc.FPSCR().Value());
|
||||||
|
return o;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace IR
|
||||||
|
} // namespace Dynarmic
|
|
@ -7,6 +7,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
#include <iosfwd>
|
||||||
#include <tuple>
|
#include <tuple>
|
||||||
#include "common/common_types.h"
|
#include "common/common_types.h"
|
||||||
#include "frontend/arm/FPSCR.h"
|
#include "frontend/arm/FPSCR.h"
|
||||||
|
@ -87,6 +88,14 @@ private:
|
||||||
Arm::FPSCR fpscr; ///< Floating point status control register.
|
Arm::FPSCR fpscr; ///< Floating point status control register.
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides a string representation of a LocationDescriptor.
|
||||||
|
*
|
||||||
|
* @param o Output stream
|
||||||
|
* @param descriptor The descriptor to get a string representation of
|
||||||
|
*/
|
||||||
|
std::ostream& operator<<(std::ostream& o, const LocationDescriptor& descriptor);
|
||||||
|
|
||||||
} // namespace IR
|
} // namespace IR
|
||||||
} // namespace Dynarmic
|
} // namespace Dynarmic
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue