diff --git a/src/backend_x64/a32_emit_x64.cpp b/src/backend_x64/a32_emit_x64.cpp index 0fc0e290..bf9fadcf 100644 --- a/src/backend_x64/a32_emit_x64.cpp +++ b/src/backend_x64/a32_emit_x64.cpp @@ -58,6 +58,10 @@ A32::LocationDescriptor A32EmitContext::Location() const { return A32::LocationDescriptor{block.Location()}; } +FP::RoundingMode A32EmitContext::FPSCR_RMode() const { + return Location().FPSCR().RMode(); +} + bool A32EmitContext::FPSCR_RoundTowardsZero() const { return Location().FPSCR().RMode() != FP::RoundingMode::TowardsZero; } diff --git a/src/backend_x64/a32_emit_x64.h b/src/backend_x64/a32_emit_x64.h index 5237eec7..bec1663d 100644 --- a/src/backend_x64/a32_emit_x64.h +++ b/src/backend_x64/a32_emit_x64.h @@ -23,6 +23,7 @@ class RegAlloc; struct A32EmitContext final : public EmitContext { A32EmitContext(RegAlloc& reg_alloc, IR::Block& block); A32::LocationDescriptor Location() const; + FP::RoundingMode FPSCR_RMode() const override; bool FPSCR_RoundTowardsZero() const override; bool FPSCR_FTZ() const override; bool FPSCR_DN() const override; diff --git a/src/backend_x64/a64_emit_x64.cpp b/src/backend_x64/a64_emit_x64.cpp index e5f8f22f..2c30b9f7 100644 --- a/src/backend_x64/a64_emit_x64.cpp +++ b/src/backend_x64/a64_emit_x64.cpp @@ -40,6 +40,10 @@ A64::LocationDescriptor A64EmitContext::Location() const { return A64::LocationDescriptor{block.Location()}; } +FP::RoundingMode A64EmitContext::FPSCR_RMode() const { + return Location().FPCR().RMode(); +} + bool A64EmitContext::FPSCR_RoundTowardsZero() const { return Location().FPCR().RMode() != FP::RoundingMode::TowardsZero; } diff --git a/src/backend_x64/a64_emit_x64.h b/src/backend_x64/a64_emit_x64.h index 53e25853..2ecf0883 100644 --- a/src/backend_x64/a64_emit_x64.h +++ b/src/backend_x64/a64_emit_x64.h @@ -23,6 +23,7 @@ class RegAlloc; struct A64EmitContext final : public EmitContext { A64EmitContext(const A64::UserConfig& conf, RegAlloc& reg_alloc, IR::Block& block); A64::LocationDescriptor Location() const; + FP::RoundingMode FPSCR_RMode() const override; bool FPSCR_RoundTowardsZero() const override; bool FPSCR_FTZ() const override; bool FPSCR_DN() const override; diff --git a/src/backend_x64/emit_x64.h b/src/backend_x64/emit_x64.h index 9494cc93..47f47bd3 100644 --- a/src/backend_x64/emit_x64.h +++ b/src/backend_x64/emit_x64.h @@ -16,6 +16,7 @@ #include "backend_x64/reg_alloc.h" #include "common/address_range.h" +#include "common/fp/rounding_mode.h" #include "frontend/ir/location_descriptor.h" #include "frontend/ir/terminal.h" @@ -33,6 +34,7 @@ struct EmitContext { void EraseInstruction(IR::Inst* inst); + virtual FP::RoundingMode FPSCR_RMode() const = 0; virtual bool FPSCR_RoundTowardsZero() const = 0; virtual bool FPSCR_FTZ() const = 0; virtual bool FPSCR_DN() const = 0;