Add optimization flags to disable specific optimizations

This commit is contained in:
MerryMage 2020-06-28 21:39:26 +01:00
parent 3eed024caf
commit 4ba1f8b9e7
13 changed files with 160 additions and 96 deletions

View file

@ -10,6 +10,8 @@
#include <cstdint>
#include <memory>
#include <dynarmic/optimization_flags.h>
namespace Dynarmic {
class ExclusiveMonitor;
} // namespace Dynarmic
@ -99,13 +101,17 @@ struct UserConfig {
size_t processor_id = 0;
ExclusiveMonitor* global_monitor = nullptr;
/// When set to false, this disables all optimizations than can't otherwise be disabled
/// by setting other configuration options. This includes:
/// This selects other optimizations than can't otherwise be disabled by setting other
/// configuration options. This includes:
/// - IR optimizations
/// - Block linking optimizations
/// - RSB optimizations
/// This is intended to be used for debugging.
bool enable_optimizations = true;
OptimizationFlag optimizations = all_optimizations;
bool HasOptimization(OptimizationFlag f) const {
return (f & optimizations) != no_optimizations;
}
// Page Table
// The page table is used for faster memory access. If an entry in the table is nullptr,
@ -156,9 +162,6 @@ struct UserConfig {
/// to avoid writting certain unnecessary code only needed for cycle timers.
bool wall_clock_cntpct = false;
/// This enables the fast dispatcher.
bool enable_fast_dispatch = true;
/// This option relates to the CPSR.E flag. Enabling this option disables modification
/// of CPSR.E by the emulated program, forcing it to 0.
/// NOTE: Calling Jit::SetCpsr with CPSR.E=1 while this option is enabled may result

View file

@ -10,6 +10,8 @@
#include <cstdint>
#include <memory>
#include <dynarmic/optimization_flags.h>
namespace Dynarmic {
class ExclusiveMonitor;
} // namespace Dynarmic
@ -124,13 +126,17 @@ struct UserConfig {
size_t processor_id = 0;
ExclusiveMonitor* global_monitor = nullptr;
/// When set to false, this disables all optimizations than can't otherwise be disabled
/// by setting other configuration options. This includes:
/// This selects other optimizations than can't otherwise be disabled by setting other
/// configuration options. This includes:
/// - IR optimizations
/// - Block linking optimizations
/// - RSB optimizations
/// This is intended to be used for debugging.
bool enable_optimizations = true;
OptimizationFlag optimizations = all_optimizations;
bool HasOptimization(OptimizationFlag f) const {
return (f & optimizations) != no_optimizations;
}
/// When set to true, UserCallbacks::DataCacheOperationRaised will be called when any
/// data cache instruction is executed. Notably DC ZVA will not implicitly do anything.
@ -206,9 +212,6 @@ struct UserConfig {
/// to avoid writting certain unnecessary code only needed for cycle timers.
bool wall_clock_cntpct = false;
/// This enables the fast dispatcher.
bool enable_fast_dispatch = true;
// Determines whether AddTicks and GetTicksRemaining are called.
// If false, execution will continue until soon after Jit::HaltExecution is called.
// bool enable_ticks = true; // TODO

View file

@ -0,0 +1,48 @@
/* This file is part of the dynarmic project.
* Copyright (c) 2020 MerryMage
* SPDX-License-Identifier: 0BSD
*/
#pragma once
#include <cstdint>
namespace Dynarmic {
enum class OptimizationFlag : std::uint32_t {
BlockLinking = 0x01,
ReturnStackBuffer = 0x02,
FastDispatch = 0x04,
GetSetElimination = 0x08,
ConstProp = 0x10,
MiscIROpt = 0x20,
};
constexpr OptimizationFlag no_optimizations = static_cast<OptimizationFlag>(0);
constexpr OptimizationFlag all_optimizations = static_cast<OptimizationFlag>(~std::uint32_t(0));
constexpr OptimizationFlag operator~(OptimizationFlag f) {
return static_cast<OptimizationFlag>(~static_cast<std::uint32_t>(f));
}
constexpr OptimizationFlag operator|(OptimizationFlag f1, OptimizationFlag f2) {
return static_cast<OptimizationFlag>(static_cast<std::uint32_t>(f1) | static_cast<std::uint32_t>(f2));
}
constexpr OptimizationFlag operator&(OptimizationFlag f1, OptimizationFlag f2) {
return static_cast<OptimizationFlag>(static_cast<std::uint32_t>(f1) & static_cast<std::uint32_t>(f2));
}
constexpr OptimizationFlag operator|=(OptimizationFlag& result, OptimizationFlag f) {
return result = (result | f);
}
constexpr OptimizationFlag operator&=(OptimizationFlag& result, OptimizationFlag f) {
return result = (result & f);
}
constexpr bool operator!(OptimizationFlag f) {
return f == no_optimizations;
}
} // namespace Dynarmic