/* This file is part of the dynarmic project. * Copyright (c) 2019 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/fp/fpcr.h" #include "common/fp/fpsr.h" #include "common/fp/op/FPCompare.h" #include "common/fp/process_exception.h" #include "common/fp/unpacked.h" namespace Dynarmic::FP { template bool FPCompareEQ(FPT lhs, FPT rhs, FPCR fpcr, FPSR& fpsr) { const auto unpacked1 = FPUnpack(lhs, fpcr, fpsr); const auto unpacked2 = FPUnpack(rhs, fpcr, fpsr); const auto type1 = std::get(unpacked1); const auto type2 = std::get(unpacked2); const auto& value1 = std::get(unpacked1); const auto& value2 = std::get(unpacked2); if (type1 == FPType::QNaN || type1 == FPType::SNaN || type2 == FPType::QNaN || type2 == FPType::SNaN) { if (type1 == FPType::SNaN || type2 == FPType::SNaN) { FPProcessException(FPExc::InvalidOp, fpcr, fpsr); } // Comparisons against NaN are never equal. return false; } return value1 == value2 || (type1 == FPType::Zero && type2 == FPType::Zero); } template bool FPCompareEQ(u16 lhs, u16 rhs, FPCR fpcr, FPSR& fpsr); template bool FPCompareEQ(u32 lhs, u32 rhs, FPCR fpcr, FPSR& fpsr); template bool FPCompareEQ(u64 lhs, u64 rhs, FPCR fpcr, FPSR& fpsr); } // namespace Dynarmic::FP