fp: Extract common RoundingMode enum
This commit is contained in:
parent
1bfac4aed0
commit
c277e6f988
@ -17,6 +17,7 @@ add_library(dynarmic
|
|||||||
common/crc32.cpp
|
common/crc32.cpp
|
||||||
common/crc32.h
|
common/crc32.h
|
||||||
common/fp_util.h
|
common/fp_util.h
|
||||||
|
common/fp/rounding_mode.h
|
||||||
common/intrusive_list.h
|
common/intrusive_list.h
|
||||||
common/iterator_util.h
|
common/iterator_util.h
|
||||||
common/llvm_disassemble.cpp
|
common/llvm_disassemble.cpp
|
||||||
|
@ -59,7 +59,7 @@ A32::LocationDescriptor A32EmitContext::Location() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool A32EmitContext::FPSCR_RoundTowardsZero() const {
|
bool A32EmitContext::FPSCR_RoundTowardsZero() const {
|
||||||
return Location().FPSCR().RMode() != A32::FPSCR::RoundingMode::TowardsZero;
|
return Location().FPSCR().RMode() != FP::RoundingMode::TowardsZero;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool A32EmitContext::FPSCR_FTZ() const {
|
bool A32EmitContext::FPSCR_FTZ() const {
|
||||||
|
@ -41,7 +41,7 @@ A64::LocationDescriptor A64EmitContext::Location() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool A64EmitContext::FPSCR_RoundTowardsZero() const {
|
bool A64EmitContext::FPSCR_RoundTowardsZero() const {
|
||||||
return Location().FPCR().RMode() != A64::FPCR::RoundingMode::TowardsZero;
|
return Location().FPCR().RMode() != FP::RoundingMode::TowardsZero;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool A64EmitContext::FPSCR_FTZ() const {
|
bool A64EmitContext::FPSCR_FTZ() const {
|
||||||
|
30
src/common/fp/rounding_mode.h
Normal file
30
src/common/fp/rounding_mode.h
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
/* This file is part of the dynarmic project.
|
||||||
|
* Copyright (c) 2018 MerryMage
|
||||||
|
* This software may be used and distributed according to the terms of the GNU
|
||||||
|
* General Public License version 2 or any later version.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "common/common_types.h"
|
||||||
|
|
||||||
|
namespace Dynarmic::FP {
|
||||||
|
|
||||||
|
/// Ordering of first four values is important as they correspond to bits in FPCR.
|
||||||
|
enum class RoundingMode {
|
||||||
|
/// Round to nearest floating point. If there is a tie, round to nearest even digit in required position.
|
||||||
|
ToNearest_TieEven,
|
||||||
|
/// Round up towards positive infinity.
|
||||||
|
TowardsPlusInfinity,
|
||||||
|
/// Round downwards towards negative infinity.
|
||||||
|
TowardsMinusInfinity,
|
||||||
|
/// Truncate towards zero.
|
||||||
|
TowardsZero,
|
||||||
|
/// Round to nearest floating point. If there is a tie, round away from zero.
|
||||||
|
ToNearest_TieAwayFromZero,
|
||||||
|
/// Von Neumann rounding (as modified by Brent). Also known as sticky rounding.
|
||||||
|
/// Set the least significant bit to 1 if the result is not exact.
|
||||||
|
ToOdd,
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace Dynarmic::FP
|
@ -10,6 +10,7 @@
|
|||||||
|
|
||||||
#include "common/bit_util.h"
|
#include "common/bit_util.h"
|
||||||
#include "common/common_types.h"
|
#include "common/common_types.h"
|
||||||
|
#include "common/fp/rounding_mode.h"
|
||||||
|
|
||||||
namespace Dynarmic::A32 {
|
namespace Dynarmic::A32 {
|
||||||
|
|
||||||
@ -19,13 +20,6 @@ namespace Dynarmic::A32 {
|
|||||||
class FPSCR final
|
class FPSCR final
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
enum class RoundingMode {
|
|
||||||
ToNearest,
|
|
||||||
TowardsPlusInfinity,
|
|
||||||
TowardsMinusInfinity,
|
|
||||||
TowardsZero
|
|
||||||
};
|
|
||||||
|
|
||||||
FPSCR() = default;
|
FPSCR() = default;
|
||||||
FPSCR(const FPSCR&) = default;
|
FPSCR(const FPSCR&) = default;
|
||||||
FPSCR(FPSCR&&) = default;
|
FPSCR(FPSCR&&) = default;
|
||||||
@ -79,8 +73,8 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Rounding mode control field.
|
/// Rounding mode control field.
|
||||||
RoundingMode RMode() const {
|
FP::RoundingMode RMode() const {
|
||||||
return static_cast<RoundingMode>(Common::Bits<22, 23>(value));
|
return static_cast<FP::RoundingMode>(Common::Bits<22, 23>(value));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Indicates the stride of a vector.
|
/// Indicates the stride of a vector.
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
|
|
||||||
#include "common/bit_util.h"
|
#include "common/bit_util.h"
|
||||||
#include "common/common_types.h"
|
#include "common/common_types.h"
|
||||||
|
#include "common/fp/rounding_mode.h"
|
||||||
|
|
||||||
namespace Dynarmic::A64 {
|
namespace Dynarmic::A64 {
|
||||||
|
|
||||||
@ -19,13 +20,6 @@ namespace Dynarmic::A64 {
|
|||||||
class FPCR final
|
class FPCR final
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
enum class RoundingMode {
|
|
||||||
ToNearest,
|
|
||||||
TowardsPlusInfinity,
|
|
||||||
TowardsMinusInfinity,
|
|
||||||
TowardsZero
|
|
||||||
};
|
|
||||||
|
|
||||||
FPCR() = default;
|
FPCR() = default;
|
||||||
FPCR(const FPCR&) = default;
|
FPCR(const FPCR&) = default;
|
||||||
FPCR(FPCR&&) = default;
|
FPCR(FPCR&&) = default;
|
||||||
@ -54,8 +48,8 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Rounding mode control field.
|
/// Rounding mode control field.
|
||||||
RoundingMode RMode() const {
|
FP::RoundingMode RMode() const {
|
||||||
return static_cast<RoundingMode>(Common::Bits<22, 23>(value));
|
return static_cast<FP::RoundingMode>(Common::Bits<22, 23>(value));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Input denormal exception trap enable flag.
|
/// Input denormal exception trap enable flag.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user