/* * m68k FPU helpers * * Copyright (c) 2006-2007 CodeSourcery * Written by Paul Brook * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, see . */ #include "qemu/osdep.h" #include "cpu.h" #include "exec/helper-proto.h" #include "exec/exec-all.h" int32_t HELPER(reds32)(CPUM68KState *env, FPReg *val) { return floatx80_to_int32(val->d, &env->fp_status); } float32 HELPER(redf32)(CPUM68KState *env, FPReg *val) { return floatx80_to_float32(val->d, &env->fp_status); } void HELPER(exts32)(CPUM68KState *env, FPReg *res, int32_t val) { res->d = int32_to_floatx80(val, &env->fp_status); } void HELPER(extf32)(CPUM68KState *env, FPReg *res, float32 val) { res->d = float32_to_floatx80(val, &env->fp_status); } void HELPER(extf64)(CPUM68KState *env, FPReg *res, float64 val) { res->d = float64_to_floatx80(val, &env->fp_status); } float64 HELPER(redf64)(CPUM68KState *env, FPReg *val) { return floatx80_to_float64(val->d, &env->fp_status); } void HELPER(firound)(CPUM68KState *env, FPReg *res, FPReg *val) { res->d = floatx80_round_to_int(val->d, &env->fp_status); } void HELPER(fitrunc)(CPUM68KState *env, FPReg *res, FPReg *val) { res->d = floatx80_round_to_int(val->d, &env->fp_status); } void HELPER(fsqrt)(CPUM68KState *env, FPReg *res, FPReg *val) { res->d = floatx80_sqrt(val->d, &env->fp_status); } void HELPER(fabs)(CPUM68KState *env, FPReg *res, FPReg *val) { res->d = floatx80_abs(val->d); } void HELPER(fchs)(CPUM68KState *env, FPReg *res, FPReg *val) { res->d = floatx80_chs(val->d); } void HELPER(fadd)(CPUM68KState *env, FPReg *res, FPReg *val0, FPReg *val1) { res->d = floatx80_add(val0->d, val1->d, &env->fp_status); } void HELPER(fsub)(CPUM68KState *env, FPReg *res, FPReg *val0, FPReg *val1) { res->d = floatx80_sub(val1->d, val0->d, &env->fp_status); } void HELPER(fmul)(CPUM68KState *env, FPReg *res, FPReg *val0, FPReg *val1) { res->d = floatx80_mul(val0->d, val1->d, &env->fp_status); } void HELPER(fdiv)(CPUM68KState *env, FPReg *res, FPReg *val0, FPReg *val1) { res->d = floatx80_div(val1->d, val0->d, &env->fp_status); } void HELPER(fsub_cmp)(CPUM68KState *env, FPReg *res, FPReg *val0, FPReg *val1) { /* ??? This may incorrectly raise exceptions. */ /* ??? Should flush denormals to zero. */ res->d = floatx80_sub(val0->d, val1->d, &env->fp_status); if (floatx80_is_quiet_nan(res->d, &env->fp_status)) { /* +/-inf compares equal against itself, but sub returns nan. */ if (!floatx80_is_quiet_nan(val0->d, &env->fp_status) && !floatx80_is_quiet_nan(val1->d, &env->fp_status)) { res->d = floatx80_zero; if (floatx80_lt_quiet(val0->d, res->d, &env->fp_status)) { res->d = floatx80_chs(res->d); } } } } uint32_t HELPER(fcompare)(CPUM68KState *env, FPReg *val) { return floatx80_compare_quiet(val->d, floatx80_zero, &env->fp_status); }