Browse Source
This patch adds a file for all the FPU related helpers with all the includes, useful defines, and a function to update the status bits. Additionally it adds a mask for the rounding mode bits of PSW as well as all the opcodes for the FPU instructions. Reviewed-by: Richard Henderson <rth@twiddle.net> Signed-off-by: Bastian Koppelmann <kbastian@mail.uni-paderborn.de> Message-Id: <1457708597-3025-2-git-send-email-kbastian@mail.uni-paderborn.de>pull/7/merge
7 changed files with 116 additions and 4 deletions
@ -1 +1 @@ |
|||
obj-y += translate.o helper.o cpu.o op_helper.o |
|||
obj-y += translate.o helper.o cpu.o op_helper.o fpu_helper.o |
|||
|
|||
@ -0,0 +1,81 @@ |
|||
/*
|
|||
* TriCore emulation for qemu: fpu helper. |
|||
* |
|||
* Copyright (c) 2016 Bastian Koppelmann University of Paderborn |
|||
* |
|||
* 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 |
|||
* Lesser 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 <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
|
|||
#include "qemu/osdep.h" |
|||
#include "cpu.h" |
|||
#include "exec/helper-proto.h" |
|||
|
|||
#define ADD_NAN 0x7cf00001 |
|||
#define DIV_NAN 0x7fc00008 |
|||
#define MUL_NAN 0x7fc00002 |
|||
#define FPU_FS PSW_USB_C |
|||
#define FPU_FI PSW_USB_V |
|||
#define FPU_FV PSW_USB_SV |
|||
#define FPU_FZ PSW_USB_AV |
|||
#define FPU_FU PSW_USB_SAV |
|||
|
|||
/* we don't care about input_denormal */ |
|||
static inline uint8_t f_get_excp_flags(CPUTriCoreState *env) |
|||
{ |
|||
return get_float_exception_flags(&env->fp_status) |
|||
& (float_flag_invalid |
|||
| float_flag_overflow |
|||
| float_flag_underflow |
|||
| float_flag_output_denormal |
|||
| float_flag_divbyzero |
|||
| float_flag_inexact); |
|||
} |
|||
|
|||
static inline bool f_is_denormal(float32 arg) |
|||
{ |
|||
return float32_is_zero_or_denormal(arg) && !float32_is_zero(arg); |
|||
} |
|||
|
|||
static inline void f_update_psw_flags(CPUTriCoreState *env, uint8_t flags) |
|||
{ |
|||
uint8_t some_excp = 0; |
|||
set_float_exception_flags(0, &env->fp_status); |
|||
|
|||
if (flags & float_flag_invalid) { |
|||
env->FPU_FI = 1 << 31; |
|||
some_excp = 1; |
|||
} |
|||
|
|||
if (flags & float_flag_overflow) { |
|||
env->FPU_FV = 1 << 31; |
|||
some_excp = 1; |
|||
} |
|||
|
|||
if (flags & float_flag_underflow || flags & float_flag_output_denormal) { |
|||
env->FPU_FU = 1 << 31; |
|||
some_excp = 1; |
|||
} |
|||
|
|||
if (flags & float_flag_divbyzero) { |
|||
env->FPU_FZ = 1 << 31; |
|||
some_excp = 1; |
|||
} |
|||
|
|||
if (flags & float_flag_inexact || flags & float_flag_output_denormal) { |
|||
env->PSW |= 1 << 26; |
|||
some_excp = 1; |
|||
} |
|||
|
|||
env->FPU_FS = some_excp; |
|||
} |
|||
Loading…
Reference in new issue