From 7c193485e18f0c4e966e0736471a283a037d4830 Mon Sep 17 00:00:00 2001 From: MerryMage Date: Sun, 18 Feb 2018 13:04:45 +0000 Subject: [PATCH] a64/config: Allow NaN emulation accuracy to be set --- include/dynarmic/A64/config.h | 12 ++++++++++++ src/backend_x64/a64_emit_x64.cpp | 6 +++++- src/backend_x64/a64_emit_x64.h | 1 + 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/include/dynarmic/A64/config.h b/include/dynarmic/A64/config.h index c63d7f69..ffe5aa9b 100644 --- a/include/dynarmic/A64/config.h +++ b/include/dynarmic/A64/config.h @@ -126,6 +126,18 @@ struct UserConfig { /// This is only used if page_table is not nullptr. bool silently_mirror_page_table = true; + // The below options relate to accuracy of floating-point emulation. + + /// Determines how accurate NaN handling is. + enum class NaNAccuracy { + /// Results of operations with NaNs will exactly match hardware. + Accurate, + /// Behave as if FPCR.DN is always set. + AlwaysForceDefaultNaN, + /// No special handling of NaN, other than setting default NaN when FPCR.DN is set. + NoChecks, + } floating_point_nan_accuracy = NaNAccuracy::Accurate; + // Determines whether AddTicks and GetTicksRemaining are called. // If false, execution will continue until soon after Jit::HaltExecution is called. // bool enable_ticks = true; // TODO diff --git a/src/backend_x64/a64_emit_x64.cpp b/src/backend_x64/a64_emit_x64.cpp index dc691795..6630fc3a 100644 --- a/src/backend_x64/a64_emit_x64.cpp +++ b/src/backend_x64/a64_emit_x64.cpp @@ -48,7 +48,11 @@ bool A64EmitContext::FPSCR_FTZ() const { } bool A64EmitContext::FPSCR_DN() const { - return Location().FPCR().DN(); + return Location().FPCR().DN() || conf.floating_point_nan_accuracy == A64::UserConfig::NaNAccuracy::AlwaysForceDefaultNaN; +} + +bool A64EmitContext::AccurateNaN() const { + return conf.floating_point_nan_accuracy == A64::UserConfig::NaNAccuracy::Accurate; } A64EmitX64::A64EmitX64(BlockOfCode& code, A64::UserConfig conf) diff --git a/src/backend_x64/a64_emit_x64.h b/src/backend_x64/a64_emit_x64.h index 664ba5c1..8108bda7 100644 --- a/src/backend_x64/a64_emit_x64.h +++ b/src/backend_x64/a64_emit_x64.h @@ -26,6 +26,7 @@ struct A64EmitContext final : public EmitContext { bool FPSCR_RoundTowardsZero() const override; bool FPSCR_FTZ() const override; bool FPSCR_DN() const override; + bool AccurateNaN() const override; const A64::UserConfig& conf; };