diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 0a722b13..0f311f91 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -18,6 +18,8 @@ add_library(dynarmic common/crc32.h common/fp/fpsr.h common/fp/info.h + common/fp/process_exception.cpp + common/fp/process_exception.h common/fp/rounding_mode.h common/fp/util.h common/intrusive_list.h diff --git a/src/common/fp/process_exception.cpp b/src/common/fp/process_exception.cpp new file mode 100644 index 00000000..9bb5a8a6 --- /dev/null +++ b/src/common/fp/process_exception.cpp @@ -0,0 +1,58 @@ +/* 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/fp/fpsr.h" +#include "common/fp/process_exception.h" +#include "frontend/A64/FPCR.h" + +namespace Dynarmic::FP { + +void FPProcessException(FPExc exception, FPCR fpcr, FPSR& fpsr) { + switch (exception) { + case FPExc::InvalidOp: + if (fpcr.IOE()) { + UNIMPLEMENTED(); + } + fpsr.IOC(true); + break; + case FPExc::DivideByZero: + if (fpcr.DZE()) { + UNIMPLEMENTED(); + } + fpsr.DZC(true); + break; + case FPExc::Overflow: + if (fpcr.OFE()) { + UNIMPLEMENTED(); + } + fpsr.OFC(true); + break; + case FPExc::Underflow: + if (fpcr.UFE()) { + UNIMPLEMENTED(); + } + fpsr.UFC(true); + break; + case FPExc::Inexact: + if (fpcr.IXE()) { + UNIMPLEMENTED(); + } + fpsr.IXC(true); + break; + case FPExc::InputDenorm: + if (fpcr.IDE()) { + UNIMPLEMENTED(); + } + fpsr.IDC(true); + break; + default: + UNREACHABLE(); + break; + } +} + +} // namespace Dynarmic::FP diff --git a/src/common/fp/process_exception.h b/src/common/fp/process_exception.h new file mode 100644 index 00000000..637f1d77 --- /dev/null +++ b/src/common/fp/process_exception.h @@ -0,0 +1,27 @@ +/* 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 "frontend/A64/FPCR.h" + +namespace Dynarmic::FP { + +using FPCR = A64::FPCR; + +enum class FPExc { + InvalidOp, + DivideByZero, + Overflow, + Underflow, + Inexact, + InputDenorm, +}; + +void FPProcessException(FPExc exception, FPCR fpcr, FPSR& fpsr); + +} // namespace Dynarmic::FP