fp: Implement FPProcessNaN
This commit is contained in:
parent
591adee443
commit
f876e4afa2
3 changed files with 62 additions and 0 deletions
|
@ -24,6 +24,8 @@ add_library(dynarmic
|
||||||
common/fp/op/FPToFixed.h
|
common/fp/op/FPToFixed.h
|
||||||
common/fp/process_exception.cpp
|
common/fp/process_exception.cpp
|
||||||
common/fp/process_exception.h
|
common/fp/process_exception.h
|
||||||
|
common/fp/process_nan.cpp
|
||||||
|
common/fp/process_nan.h
|
||||||
common/fp/rounding_mode.h
|
common/fp/rounding_mode.h
|
||||||
common/fp/unpacked.cpp
|
common/fp/unpacked.cpp
|
||||||
common/fp/unpacked.h
|
common/fp/unpacked.h
|
||||||
|
|
40
src/common/fp/process_nan.cpp
Normal file
40
src/common/fp/process_nan.cpp
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
/* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "common/assert.h"
|
||||||
|
#include "common/bit_util.h"
|
||||||
|
#include "common/fp/fpsr.h"
|
||||||
|
#include "common/fp/info.h"
|
||||||
|
#include "common/fp/process_exception.h"
|
||||||
|
#include "common/fp/process_nan.h"
|
||||||
|
#include "frontend/A64/FPCR.h"
|
||||||
|
|
||||||
|
namespace Dynarmic::FP {
|
||||||
|
|
||||||
|
template<typename FPT>
|
||||||
|
FPT FPProcessNaN(FPType type, FPT op, FPCR fpcr, FPSR& fpsr) {
|
||||||
|
ASSERT(type == FPType::QNaN || type == FPType::SNaN);
|
||||||
|
|
||||||
|
constexpr size_t topfrac = FPInfo<FPT>::explicit_mantissa_width - 1;
|
||||||
|
|
||||||
|
FPT result = op;
|
||||||
|
|
||||||
|
if (type == FPType::SNaN) {
|
||||||
|
result = Common::ModifyBit<topfrac>(op, true);
|
||||||
|
FPProcessException(FPExc::InvalidOp, fpcr, fpsr);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fpcr.DN()) {
|
||||||
|
result = FPInfo<FPT>::DefaultNaN();
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
template u32 FPProcessNaN<u32>(FPType type, u32 op, FPCR fpcr, FPSR& fpsr);
|
||||||
|
template u64 FPProcessNaN<u64>(FPType type, u64 op, FPCR fpcr, FPSR& fpsr);
|
||||||
|
|
||||||
|
} // namespace Dynarmic::FP
|
20
src/common/fp/process_nan.h
Normal file
20
src/common/fp/process_nan.h
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
/* 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/fp/fpsr.h"
|
||||||
|
#include "common/fp/unpacked.h"
|
||||||
|
#include "frontend/A64/FPCR.h"
|
||||||
|
|
||||||
|
namespace Dynarmic::FP {
|
||||||
|
|
||||||
|
using FPCR = A64::FPCR;
|
||||||
|
|
||||||
|
template<typename FPT>
|
||||||
|
FPT FPProcessNaN(FPType type, FPT op, FPCR fpcr, FPSR& fpsr);
|
||||||
|
|
||||||
|
} // namespace Dynarmic::FP
|
Loading…
Reference in a new issue