2017-06-04 20:38:34 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <array>
|
|
|
|
#include <cstdint>
|
|
|
|
|
2017-06-05 21:39:15 +00:00
|
|
|
namespace EightBit {
|
2017-06-19 16:37:41 +00:00
|
|
|
|
|
|
|
class Disassembler;
|
|
|
|
class Z80;
|
|
|
|
|
2017-06-05 21:39:15 +00:00
|
|
|
class Profiler {
|
|
|
|
public:
|
2017-06-19 16:37:41 +00:00
|
|
|
Profiler(Z80& cpu, Disassembler& disassembler);
|
2017-06-05 21:39:15 +00:00
|
|
|
~Profiler();
|
2017-06-04 20:38:34 +00:00
|
|
|
|
2017-06-05 21:39:15 +00:00
|
|
|
void addInstruction(uint8_t instruction);
|
|
|
|
void addAddress(uint16_t address);
|
2017-06-04 20:38:34 +00:00
|
|
|
|
2017-06-05 21:39:15 +00:00
|
|
|
void dump() const;
|
2017-06-04 20:38:34 +00:00
|
|
|
|
2017-06-05 21:39:15 +00:00
|
|
|
private:
|
|
|
|
std::array<uint64_t, 0x100> m_instructions;
|
|
|
|
std::array<uint64_t, 0x10000> m_addresses;
|
2017-06-19 16:37:41 +00:00
|
|
|
Z80& m_cpu;
|
2017-10-29 20:15:49 +00:00
|
|
|
Disassembler& m_disassembler;
|
2017-06-04 20:38:34 +00:00
|
|
|
|
2021-12-30 12:32:34 +00:00
|
|
|
[[nodiscard]] constexpr const auto& instructions() const { return m_instructions; }
|
|
|
|
[[nodiscard]] constexpr const auto& addresses() const { return m_addresses; }
|
|
|
|
|
|
|
|
[[nodiscard]] constexpr auto instructions_available() const noexcept {
|
|
|
|
const auto found = std::find_if(
|
|
|
|
instructions().begin(), instructions().end(),
|
|
|
|
[](const auto& value) { return value != 0; });
|
|
|
|
return found != instructions().end();
|
|
|
|
}
|
|
|
|
|
|
|
|
[[nodiscard]] constexpr auto addresses_available() const noexcept {
|
|
|
|
const auto found = std::find_if(
|
|
|
|
addresses().begin(), addresses().end(),
|
|
|
|
[](const auto& value) { return value != 0; });
|
|
|
|
return found != addresses().end();
|
|
|
|
}
|
|
|
|
|
|
|
|
[[nodiscard]] constexpr auto available() const noexcept {
|
|
|
|
return instructions_available() || addresses_available();
|
|
|
|
}
|
|
|
|
|
2017-06-05 21:39:15 +00:00
|
|
|
void dumpInstructionProfiles() const;
|
|
|
|
void dumpAddressProfiles() const;
|
|
|
|
};
|
|
|
|
}
|