2005-07-02 16:58:51 +02:00
|
|
|
/*
|
|
|
|
* MIPS emulation micro-operations for qemu.
|
2007-09-16 23:08:06 +02:00
|
|
|
*
|
2005-07-02 16:58:51 +02:00
|
|
|
* Copyright (c) 2004-2005 Jocelyn Mayer
|
2006-06-14 14:56:19 +02:00
|
|
|
* Copyright (c) 2006 Marius Groeger (FPU operations)
|
2007-05-20 03:36:29 +02:00
|
|
|
* Copyright (c) 2007 Thiemo Seufer (64-bit FPU support)
|
2005-07-02 16:58:51 +02:00
|
|
|
*
|
|
|
|
* 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, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
#include "exec.h"
|
2007-10-27 15:05:54 +02:00
|
|
|
#include "host-utils.h"
|
2005-07-02 16:58:51 +02:00
|
|
|
|
2005-07-02 17:39:04 +02:00
|
|
|
#ifndef CALL_FROM_TB0
|
2007-05-07 15:55:33 +02:00
|
|
|
#define CALL_FROM_TB0(func) func()
|
2005-07-02 17:39:04 +02:00
|
|
|
#endif
|
|
|
|
#ifndef CALL_FROM_TB1
|
2007-05-07 15:55:33 +02:00
|
|
|
#define CALL_FROM_TB1(func, arg0) func(arg0)
|
2005-07-02 17:39:04 +02:00
|
|
|
#endif
|
|
|
|
#ifndef CALL_FROM_TB1_CONST16
|
2007-05-07 15:55:33 +02:00
|
|
|
#define CALL_FROM_TB1_CONST16(func, arg0) CALL_FROM_TB1(func, arg0)
|
2005-07-02 17:39:04 +02:00
|
|
|
#endif
|
|
|
|
#ifndef CALL_FROM_TB2
|
2007-05-07 15:55:33 +02:00
|
|
|
#define CALL_FROM_TB2(func, arg0, arg1) func(arg0, arg1)
|
2005-07-02 17:39:04 +02:00
|
|
|
#endif
|
|
|
|
#ifndef CALL_FROM_TB2_CONST16
|
|
|
|
#define CALL_FROM_TB2_CONST16(func, arg0, arg1) \
|
2007-05-07 15:55:33 +02:00
|
|
|
CALL_FROM_TB2(func, arg0, arg1)
|
2005-07-02 17:39:04 +02:00
|
|
|
#endif
|
|
|
|
#ifndef CALL_FROM_TB3
|
2007-05-07 15:55:33 +02:00
|
|
|
#define CALL_FROM_TB3(func, arg0, arg1, arg2) func(arg0, arg1, arg2)
|
2005-07-02 17:39:04 +02:00
|
|
|
#endif
|
|
|
|
#ifndef CALL_FROM_TB4
|
|
|
|
#define CALL_FROM_TB4(func, arg0, arg1, arg2, arg3) \
|
2007-05-07 15:55:33 +02:00
|
|
|
func(arg0, arg1, arg2, arg3)
|
2005-07-02 17:39:04 +02:00
|
|
|
#endif
|
|
|
|
|
2005-07-02 16:58:51 +02:00
|
|
|
/* Load and store */
|
|
|
|
#define MEMSUFFIX _raw
|
|
|
|
#include "op_mem.c"
|
|
|
|
#undef MEMSUFFIX
|
|
|
|
#if !defined(CONFIG_USER_ONLY)
|
|
|
|
#define MEMSUFFIX _user
|
|
|
|
#include "op_mem.c"
|
|
|
|
#undef MEMSUFFIX
|
|
|
|
|
2007-10-28 20:45:05 +01:00
|
|
|
#define MEMSUFFIX _super
|
|
|
|
#include "op_mem.c"
|
|
|
|
#undef MEMSUFFIX
|
|
|
|
|
2005-07-02 16:58:51 +02:00
|
|
|
#define MEMSUFFIX _kernel
|
|
|
|
#include "op_mem.c"
|
|
|
|
#undef MEMSUFFIX
|
|
|
|
#endif
|
|
|
|
|
2006-12-21 02:19:56 +01:00
|
|
|
/* 64 bits arithmetic */
|
|
|
|
#if TARGET_LONG_BITS > HOST_LONG_BITS
|
2005-07-02 16:58:51 +02:00
|
|
|
void op_madd (void)
|
|
|
|
{
|
|
|
|
CALL_FROM_TB0(do_madd);
|
2007-11-10 00:09:41 +01:00
|
|
|
FORCE_RET();
|
2005-07-02 16:58:51 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void op_maddu (void)
|
|
|
|
{
|
|
|
|
CALL_FROM_TB0(do_maddu);
|
2007-11-10 00:09:41 +01:00
|
|
|
FORCE_RET();
|
2005-07-02 16:58:51 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void op_msub (void)
|
|
|
|
{
|
|
|
|
CALL_FROM_TB0(do_msub);
|
2007-11-10 00:09:41 +01:00
|
|
|
FORCE_RET();
|
2005-07-02 16:58:51 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void op_msubu (void)
|
|
|
|
{
|
|
|
|
CALL_FROM_TB0(do_msubu);
|
2007-11-10 00:09:41 +01:00
|
|
|
FORCE_RET();
|
2005-07-02 16:58:51 +02:00
|
|
|
}
|
2006-12-21 02:19:56 +01:00
|
|
|
|
2007-12-25 21:46:56 +01:00
|
|
|
/* Multiplication variants of the vr54xx. */
|
|
|
|
void op_muls (void)
|
|
|
|
{
|
|
|
|
CALL_FROM_TB0(do_muls);
|
|
|
|
FORCE_RET();
|
|
|
|
}
|
|
|
|
|
|
|
|
void op_mulsu (void)
|
|
|
|
{
|
|
|
|
CALL_FROM_TB0(do_mulsu);
|
|
|
|
FORCE_RET();
|
|
|
|
}
|
|
|
|
|
|
|
|
void op_macc (void)
|
|
|
|
{
|
|
|
|
CALL_FROM_TB0(do_macc);
|
|
|
|
FORCE_RET();
|
|
|
|
}
|
|
|
|
|
|
|
|
void op_macchi (void)
|
|
|
|
{
|
|
|
|
CALL_FROM_TB0(do_macchi);
|
|
|
|
FORCE_RET();
|
|
|
|
}
|
|
|
|
|
|
|
|
void op_maccu (void)
|
|
|
|
{
|
|
|
|
CALL_FROM_TB0(do_maccu);
|
|
|
|
FORCE_RET();
|
|
|
|
}
|
|
|
|
void op_macchiu (void)
|
|
|
|
{
|
|
|
|
CALL_FROM_TB0(do_macchiu);
|
|
|
|
FORCE_RET();
|
|
|
|
}
|
|
|
|
|
|
|
|
void op_msac (void)
|
|
|
|
{
|
|
|
|
CALL_FROM_TB0(do_msac);
|
|
|
|
FORCE_RET();
|
|
|
|
}
|
|
|
|
|
|
|
|
void op_msachi (void)
|
|
|
|
{
|
|
|
|
CALL_FROM_TB0(do_msachi);
|
|
|
|
FORCE_RET();
|
|
|
|
}
|
|
|
|
|
|
|
|
void op_msacu (void)
|
|
|
|
{
|
|
|
|
CALL_FROM_TB0(do_msacu);
|
|
|
|
FORCE_RET();
|
|
|
|
}
|
|
|
|
|
|
|
|
void op_msachiu (void)
|
|
|
|
{
|
|
|
|
CALL_FROM_TB0(do_msachiu);
|
|
|
|
FORCE_RET();
|
|
|
|
}
|
|
|
|
|
|
|
|
void op_mulhi (void)
|
|
|
|
{
|
|
|
|
CALL_FROM_TB0(do_mulhi);
|
|
|
|
FORCE_RET();
|
|
|
|
}
|
|
|
|
|
|
|
|
void op_mulhiu (void)
|
|
|
|
{
|
|
|
|
CALL_FROM_TB0(do_mulhiu);
|
|
|
|
FORCE_RET();
|
|
|
|
}
|
|
|
|
|
|
|
|
void op_mulshi (void)
|
|
|
|
{
|
|
|
|
CALL_FROM_TB0(do_mulshi);
|
|
|
|
FORCE_RET();
|
|
|
|
}
|
|
|
|
|
|
|
|
void op_mulshiu (void)
|
|
|
|
{
|
|
|
|
CALL_FROM_TB0(do_mulshiu);
|
|
|
|
FORCE_RET();
|
|
|
|
}
|
|
|
|
|
2006-12-21 02:19:56 +01:00
|
|
|
#else /* TARGET_LONG_BITS > HOST_LONG_BITS */
|
|
|
|
|
2007-10-09 05:39:58 +02:00
|
|
|
static always_inline uint64_t get_HILO (void)
|
2006-12-21 02:19:56 +01:00
|
|
|
{
|
2008-02-12 22:01:26 +01:00
|
|
|
return ((uint64_t)env->HI[env->current_tc][0] << 32) |
|
|
|
|
((uint64_t)(uint32_t)env->LO[env->current_tc][0]);
|
2006-12-21 02:19:56 +01:00
|
|
|
}
|
|
|
|
|
2007-10-09 05:39:58 +02:00
|
|
|
static always_inline void set_HILO (uint64_t HILO)
|
2006-12-21 02:19:56 +01:00
|
|
|
{
|
2008-02-12 22:01:26 +01:00
|
|
|
env->LO[env->current_tc][0] = (int32_t)(HILO & 0xFFFFFFFF);
|
|
|
|
env->HI[env->current_tc][0] = (int32_t)(HILO >> 32);
|
2006-12-21 02:19:56 +01:00
|
|
|
}
|
|
|
|
|
2007-12-25 21:46:56 +01:00
|
|
|
static always_inline void set_HIT0_LO (uint64_t HILO)
|
|
|
|
{
|
2008-02-12 22:01:26 +01:00
|
|
|
env->LO[env->current_tc][0] = (int32_t)(HILO & 0xFFFFFFFF);
|
|
|
|
T0 = env->HI[env->current_tc][0] = (int32_t)(HILO >> 32);
|
2007-12-25 21:46:56 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static always_inline void set_HI_LOT0 (uint64_t HILO)
|
|
|
|
{
|
2008-02-12 22:01:26 +01:00
|
|
|
T0 = env->LO[env->current_tc][0] = (int32_t)(HILO & 0xFFFFFFFF);
|
|
|
|
env->HI[env->current_tc][0] = (int32_t)(HILO >> 32);
|
2007-12-25 21:46:56 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Multiplication variants of the vr54xx. */
|
|
|
|
void op_muls (void)
|
|
|
|
{
|
|
|
|
set_HI_LOT0(0 - ((int64_t)(int32_t)T0 * (int64_t)(int32_t)T1));
|
|
|
|
FORCE_RET();
|
|
|
|
}
|
|
|
|
|
|
|
|
void op_mulsu (void)
|
|
|
|
{
|
|
|
|
set_HI_LOT0(0 - ((uint64_t)(uint32_t)T0 * (uint64_t)(uint32_t)T1));
|
|
|
|
FORCE_RET();
|
|
|
|
}
|
|
|
|
|
|
|
|
void op_macc (void)
|
|
|
|
{
|
|
|
|
set_HI_LOT0(get_HILO() + ((int64_t)(int32_t)T0 * (int64_t)(int32_t)T1));
|
|
|
|
FORCE_RET();
|
|
|
|
}
|
|
|
|
|
|
|
|
void op_macchi (void)
|
|
|
|
{
|
|
|
|
set_HIT0_LO(get_HILO() + ((int64_t)(int32_t)T0 * (int64_t)(int32_t)T1));
|
|
|
|
FORCE_RET();
|
|
|
|
}
|
|
|
|
|
|
|
|
void op_maccu (void)
|
|
|
|
{
|
|
|
|
set_HI_LOT0(get_HILO() + ((uint64_t)(uint32_t)T0 * (uint64_t)(uint32_t)T1));
|
|
|
|
FORCE_RET();
|
|
|
|
}
|
|
|
|
|
|
|
|
void op_macchiu (void)
|
|
|
|
{
|
|
|
|
set_HIT0_LO(get_HILO() + ((uint64_t)(uint32_t)T0 * (uint64_t)(uint32_t)T1));
|
|
|
|
FORCE_RET();
|
|
|
|
}
|
|
|
|
|
|
|
|
void op_msac (void)
|
|
|
|
{
|
|
|
|
set_HI_LOT0(get_HILO() - ((int64_t)(int32_t)T0 * (int64_t)(int32_t)T1));
|
|
|
|
FORCE_RET();
|
|
|
|
}
|
|
|
|
|
|
|
|
void op_msachi (void)
|
|
|
|
{
|
|
|
|
set_HIT0_LO(get_HILO() - ((int64_t)(int32_t)T0 * (int64_t)(int32_t)T1));
|
|
|
|
FORCE_RET();
|
|
|
|
}
|
|
|
|
|
|
|
|
void op_msacu (void)
|
|
|
|
{
|
|
|
|
set_HI_LOT0(get_HILO() - ((uint64_t)(uint32_t)T0 * (uint64_t)(uint32_t)T1));
|
|
|
|
FORCE_RET();
|
|
|
|
}
|
|
|
|
|
|
|
|
void op_msachiu (void)
|
|
|
|
{
|
|
|
|
set_HIT0_LO(get_HILO() - ((uint64_t)(uint32_t)T0 * (uint64_t)(uint32_t)T1));
|
|
|
|
FORCE_RET();
|
|
|
|
}
|
|
|
|
|
|
|
|
void op_mulhi (void)
|
|
|
|
{
|
|
|
|
set_HIT0_LO((int64_t)(int32_t)T0 * (int64_t)(int32_t)T1);
|
|
|
|
FORCE_RET();
|
|
|
|
}
|
|
|
|
|
|
|
|
void op_mulhiu (void)
|
|
|
|
{
|
|
|
|
set_HIT0_LO((uint64_t)(uint32_t)T0 * (uint64_t)(uint32_t)T1);
|
|
|
|
FORCE_RET();
|
|
|
|
}
|
|
|
|
|
|
|
|
void op_mulshi (void)
|
|
|
|
{
|
|
|
|
set_HIT0_LO(0 - ((int64_t)(int32_t)T0 * (int64_t)(int32_t)T1));
|
|
|
|
FORCE_RET();
|
|
|
|
}
|
|
|
|
|
|
|
|
void op_mulshiu (void)
|
|
|
|
{
|
|
|
|
set_HIT0_LO(0 - ((uint64_t)(uint32_t)T0 * (uint64_t)(uint32_t)T1));
|
|
|
|
FORCE_RET();
|
|
|
|
}
|
|
|
|
|
2006-12-21 02:19:56 +01:00
|
|
|
#endif /* TARGET_LONG_BITS > HOST_LONG_BITS */
|
|
|
|
|
2007-05-07 15:55:33 +02:00
|
|
|
/* CP1 functions */
|
2006-06-14 14:56:19 +02:00
|
|
|
#if 0
|
|
|
|
# define DEBUG_FPU_STATE() CALL_FROM_TB1(dump_fpu, env)
|
|
|
|
#else
|
|
|
|
# define DEBUG_FPU_STATE() do { } while(0)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* Float support.
|
|
|
|
Single precition routines have a "s" suffix, double precision a
|
2007-05-07 15:55:33 +02:00
|
|
|
"d" suffix, 32bit integer "w", 64bit integer "l", paired singe "ps",
|
|
|
|
paired single lowwer "pl", paired single upper "pu". */
|
2006-06-14 14:56:19 +02:00
|
|
|
|
|
|
|
#define FLOAT_OP(name, p) void OPPROTO op_float_##name##_##p(void)
|
|
|
|
|
2007-05-07 15:55:33 +02:00
|
|
|
FLOAT_OP(pll, ps)
|
|
|
|
{
|
|
|
|
DT2 = ((uint64_t)WT0 << 32) | WT1;
|
|
|
|
DEBUG_FPU_STATE();
|
2007-11-10 00:09:41 +01:00
|
|
|
FORCE_RET();
|
2007-05-07 15:55:33 +02:00
|
|
|
}
|
|
|
|
FLOAT_OP(plu, ps)
|
|
|
|
{
|
|
|
|
DT2 = ((uint64_t)WT0 << 32) | WTH1;
|
|
|
|
DEBUG_FPU_STATE();
|
2007-11-10 00:09:41 +01:00
|
|
|
FORCE_RET();
|
2007-05-07 15:55:33 +02:00
|
|
|
}
|
|
|
|
FLOAT_OP(pul, ps)
|
|
|
|
{
|
|
|
|
DT2 = ((uint64_t)WTH0 << 32) | WT1;
|
|
|
|
DEBUG_FPU_STATE();
|
2007-11-10 00:09:41 +01:00
|
|
|
FORCE_RET();
|
2007-05-07 15:55:33 +02:00
|
|
|
}
|
|
|
|
FLOAT_OP(puu, ps)
|
|
|
|
{
|
|
|
|
DT2 = ((uint64_t)WTH0 << 32) | WTH1;
|
2006-06-14 14:56:19 +02:00
|
|
|
DEBUG_FPU_STATE();
|
2007-11-10 00:09:41 +01:00
|
|
|
FORCE_RET();
|
2006-06-14 14:56:19 +02:00
|
|
|
}
|
|
|
|
|
2007-05-07 15:55:33 +02:00
|
|
|
FLOAT_OP(movf, d)
|
|
|
|
{
|
2007-09-06 02:18:15 +02:00
|
|
|
if (!(env->fpu->fcr31 & PARAM1))
|
2007-05-07 15:55:33 +02:00
|
|
|
DT2 = DT0;
|
|
|
|
DEBUG_FPU_STATE();
|
2007-11-10 00:09:41 +01:00
|
|
|
FORCE_RET();
|
2007-05-07 15:55:33 +02:00
|
|
|
}
|
|
|
|
FLOAT_OP(movf, s)
|
|
|
|
{
|
2007-09-06 02:18:15 +02:00
|
|
|
if (!(env->fpu->fcr31 & PARAM1))
|
2007-05-07 15:55:33 +02:00
|
|
|
WT2 = WT0;
|
|
|
|
DEBUG_FPU_STATE();
|
2007-11-10 00:09:41 +01:00
|
|
|
FORCE_RET();
|
2007-05-07 15:55:33 +02:00
|
|
|
}
|
|
|
|
FLOAT_OP(movf, ps)
|
|
|
|
{
|
2008-05-24 21:46:23 +02:00
|
|
|
unsigned int mask = GET_FP_COND (env->fpu) >> PARAM1;
|
|
|
|
if (!(mask & 1))
|
2007-05-07 15:55:33 +02:00
|
|
|
WT2 = WT0;
|
2008-05-24 21:46:23 +02:00
|
|
|
if (!(mask & 2))
|
2007-05-07 15:55:33 +02:00
|
|
|
WTH2 = WTH0;
|
|
|
|
DEBUG_FPU_STATE();
|
2007-11-10 00:09:41 +01:00
|
|
|
FORCE_RET();
|
2007-05-07 15:55:33 +02:00
|
|
|
}
|
|
|
|
FLOAT_OP(movt, d)
|
|
|
|
{
|
2007-09-06 02:18:15 +02:00
|
|
|
if (env->fpu->fcr31 & PARAM1)
|
2007-05-07 15:55:33 +02:00
|
|
|
DT2 = DT0;
|
|
|
|
DEBUG_FPU_STATE();
|
2007-11-10 00:09:41 +01:00
|
|
|
FORCE_RET();
|
2007-05-07 15:55:33 +02:00
|
|
|
}
|
|
|
|
FLOAT_OP(movt, s)
|
|
|
|
{
|
2007-09-06 02:18:15 +02:00
|
|
|
if (env->fpu->fcr31 & PARAM1)
|
2007-05-07 15:55:33 +02:00
|
|
|
WT2 = WT0;
|
|
|
|
DEBUG_FPU_STATE();
|
2007-11-10 00:09:41 +01:00
|
|
|
FORCE_RET();
|
2007-05-07 15:55:33 +02:00
|
|
|
}
|
|
|
|
FLOAT_OP(movt, ps)
|
|
|
|
{
|
2008-05-24 21:46:23 +02:00
|
|
|
unsigned int mask = GET_FP_COND (env->fpu) >> PARAM1;
|
|
|
|
if (mask & 1)
|
2007-05-07 15:55:33 +02:00
|
|
|
WT2 = WT0;
|
2008-05-24 21:46:23 +02:00
|
|
|
if (mask & 2)
|
2007-05-07 15:55:33 +02:00
|
|
|
WTH2 = WTH0;
|
|
|
|
DEBUG_FPU_STATE();
|
2007-11-10 00:09:41 +01:00
|
|
|
FORCE_RET();
|
2007-05-07 15:55:33 +02:00
|
|
|
}
|
|
|
|
FLOAT_OP(movz, d)
|
|
|
|
{
|
|
|
|
if (!T0)
|
|
|
|
DT2 = DT0;
|
|
|
|
DEBUG_FPU_STATE();
|
2007-11-10 00:09:41 +01:00
|
|
|
FORCE_RET();
|
2007-05-07 15:55:33 +02:00
|
|
|
}
|
|
|
|
FLOAT_OP(movz, s)
|
|
|
|
{
|
|
|
|
if (!T0)
|
|
|
|
WT2 = WT0;
|
|
|
|
DEBUG_FPU_STATE();
|
2007-11-10 00:09:41 +01:00
|
|
|
FORCE_RET();
|
2007-05-07 15:55:33 +02:00
|
|
|
}
|
|
|
|
FLOAT_OP(movz, ps)
|
|
|
|
{
|
|
|
|
if (!T0) {
|
|
|
|
WT2 = WT0;
|
|
|
|
WTH2 = WTH0;
|
|
|
|
}
|
|
|
|
DEBUG_FPU_STATE();
|
2007-11-10 00:09:41 +01:00
|
|
|
FORCE_RET();
|
2007-05-07 15:55:33 +02:00
|
|
|
}
|
|
|
|
FLOAT_OP(movn, d)
|
|
|
|
{
|
|
|
|
if (T0)
|
|
|
|
DT2 = DT0;
|
|
|
|
DEBUG_FPU_STATE();
|
2007-11-10 00:09:41 +01:00
|
|
|
FORCE_RET();
|
2007-05-07 15:55:33 +02:00
|
|
|
}
|
|
|
|
FLOAT_OP(movn, s)
|
|
|
|
{
|
|
|
|
if (T0)
|
|
|
|
WT2 = WT0;
|
|
|
|
DEBUG_FPU_STATE();
|
2007-11-10 00:09:41 +01:00
|
|
|
FORCE_RET();
|
2007-05-07 15:55:33 +02:00
|
|
|
}
|
|
|
|
FLOAT_OP(movn, ps)
|
|
|
|
{
|
|
|
|
if (T0) {
|
|
|
|
WT2 = WT0;
|
|
|
|
WTH2 = WTH0;
|
|
|
|
}
|
|
|
|
DEBUG_FPU_STATE();
|
2007-11-10 00:09:41 +01:00
|
|
|
FORCE_RET();
|
2007-05-07 15:55:33 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ternary operations */
|
|
|
|
#define FLOAT_TERNOP(name1, name2) \
|
|
|
|
FLOAT_OP(name1 ## name2, d) \
|
|
|
|
{ \
|
2007-09-06 02:18:15 +02:00
|
|
|
FDT0 = float64_ ## name1 (FDT0, FDT1, &env->fpu->fp_status); \
|
|
|
|
FDT2 = float64_ ## name2 (FDT0, FDT2, &env->fpu->fp_status); \
|
2007-05-07 15:55:33 +02:00
|
|
|
DEBUG_FPU_STATE(); \
|
2007-11-10 00:09:41 +01:00
|
|
|
FORCE_RET(); \
|
2007-05-07 15:55:33 +02:00
|
|
|
} \
|
|
|
|
FLOAT_OP(name1 ## name2, s) \
|
|
|
|
{ \
|
2007-09-06 02:18:15 +02:00
|
|
|
FST0 = float32_ ## name1 (FST0, FST1, &env->fpu->fp_status); \
|
|
|
|
FST2 = float32_ ## name2 (FST0, FST2, &env->fpu->fp_status); \
|
2007-05-07 15:55:33 +02:00
|
|
|
DEBUG_FPU_STATE(); \
|
2007-11-10 00:09:41 +01:00
|
|
|
FORCE_RET(); \
|
2007-05-07 15:55:33 +02:00
|
|
|
} \
|
|
|
|
FLOAT_OP(name1 ## name2, ps) \
|
|
|
|
{ \
|
2007-09-06 02:18:15 +02:00
|
|
|
FST0 = float32_ ## name1 (FST0, FST1, &env->fpu->fp_status); \
|
|
|
|
FSTH0 = float32_ ## name1 (FSTH0, FSTH1, &env->fpu->fp_status); \
|
|
|
|
FST2 = float32_ ## name2 (FST0, FST2, &env->fpu->fp_status); \
|
|
|
|
FSTH2 = float32_ ## name2 (FSTH0, FSTH2, &env->fpu->fp_status); \
|
2007-05-07 15:55:33 +02:00
|
|
|
DEBUG_FPU_STATE(); \
|
2007-11-10 00:09:41 +01:00
|
|
|
FORCE_RET(); \
|
2007-05-07 15:55:33 +02:00
|
|
|
}
|
|
|
|
FLOAT_TERNOP(mul, add)
|
|
|
|
FLOAT_TERNOP(mul, sub)
|
|
|
|
#undef FLOAT_TERNOP
|
|
|
|
|
2007-05-11 11:59:10 +02:00
|
|
|
/* negated ternary operations */
|
|
|
|
#define FLOAT_NTERNOP(name1, name2) \
|
|
|
|
FLOAT_OP(n ## name1 ## name2, d) \
|
|
|
|
{ \
|
2007-09-06 02:18:15 +02:00
|
|
|
FDT0 = float64_ ## name1 (FDT0, FDT1, &env->fpu->fp_status); \
|
|
|
|
FDT2 = float64_ ## name2 (FDT0, FDT2, &env->fpu->fp_status); \
|
2007-11-17 15:53:06 +01:00
|
|
|
FDT2 = float64_chs(FDT2); \
|
2007-05-11 11:59:10 +02:00
|
|
|
DEBUG_FPU_STATE(); \
|
2007-11-10 00:09:41 +01:00
|
|
|
FORCE_RET(); \
|
2007-05-11 11:59:10 +02:00
|
|
|
} \
|
|
|
|
FLOAT_OP(n ## name1 ## name2, s) \
|
|
|
|
{ \
|
2007-09-06 02:18:15 +02:00
|
|
|
FST0 = float32_ ## name1 (FST0, FST1, &env->fpu->fp_status); \
|
|
|
|
FST2 = float32_ ## name2 (FST0, FST2, &env->fpu->fp_status); \
|
2007-11-17 15:53:06 +01:00
|
|
|
FST2 = float32_chs(FST2); \
|
2007-05-11 11:59:10 +02:00
|
|
|
DEBUG_FPU_STATE(); \
|
2007-11-10 00:09:41 +01:00
|
|
|
FORCE_RET(); \
|
2007-05-11 11:59:10 +02:00
|
|
|
} \
|
|
|
|
FLOAT_OP(n ## name1 ## name2, ps) \
|
|
|
|
{ \
|
2007-09-06 02:18:15 +02:00
|
|
|
FST0 = float32_ ## name1 (FST0, FST1, &env->fpu->fp_status); \
|
|
|
|
FSTH0 = float32_ ## name1 (FSTH0, FSTH1, &env->fpu->fp_status); \
|
|
|
|
FST2 = float32_ ## name2 (FST0, FST2, &env->fpu->fp_status); \
|
|
|
|
FSTH2 = float32_ ## name2 (FSTH0, FSTH2, &env->fpu->fp_status); \
|
2007-11-17 15:53:06 +01:00
|
|
|
FST2 = float32_chs(FST2); \
|
|
|
|
FSTH2 = float32_chs(FSTH2); \
|
2007-05-11 11:59:10 +02:00
|
|
|
DEBUG_FPU_STATE(); \
|
2007-11-10 00:09:41 +01:00
|
|
|
FORCE_RET(); \
|
2007-05-11 11:59:10 +02:00
|
|
|
}
|
|
|
|
FLOAT_NTERNOP(mul, add)
|
|
|
|
FLOAT_NTERNOP(mul, sub)
|
|
|
|
#undef FLOAT_NTERNOP
|
|
|
|
|
2006-06-14 14:56:19 +02:00
|
|
|
/* unary operations, modifying fp status */
|
|
|
|
#define FLOAT_UNOP(name) \
|
|
|
|
FLOAT_OP(name, d) \
|
|
|
|
{ \
|
2007-11-10 00:09:41 +01:00
|
|
|
FDT2 = float64_ ## name(FDT0, &env->fpu->fp_status); \
|
2006-06-14 14:56:19 +02:00
|
|
|
DEBUG_FPU_STATE(); \
|
2007-11-10 00:09:41 +01:00
|
|
|
FORCE_RET(); \
|
2006-06-14 14:56:19 +02:00
|
|
|
} \
|
|
|
|
FLOAT_OP(name, s) \
|
|
|
|
{ \
|
2007-11-10 00:09:41 +01:00
|
|
|
FST2 = float32_ ## name(FST0, &env->fpu->fp_status); \
|
2006-06-14 14:56:19 +02:00
|
|
|
DEBUG_FPU_STATE(); \
|
2007-11-10 00:09:41 +01:00
|
|
|
FORCE_RET(); \
|
2006-06-14 14:56:19 +02:00
|
|
|
}
|
|
|
|
FLOAT_UNOP(sqrt)
|
|
|
|
#undef FLOAT_UNOP
|
|
|
|
|
|
|
|
/* unary operations, not modifying fp status */
|
|
|
|
#define FLOAT_UNOP(name) \
|
|
|
|
FLOAT_OP(name, d) \
|
|
|
|
{ \
|
|
|
|
FDT2 = float64_ ## name(FDT0); \
|
|
|
|
DEBUG_FPU_STATE(); \
|
2007-11-10 00:09:41 +01:00
|
|
|
FORCE_RET(); \
|
2006-06-14 14:56:19 +02:00
|
|
|
} \
|
|
|
|
FLOAT_OP(name, s) \
|
|
|
|
{ \
|
|
|
|
FST2 = float32_ ## name(FST0); \
|
|
|
|
DEBUG_FPU_STATE(); \
|
2007-11-10 00:09:41 +01:00
|
|
|
FORCE_RET(); \
|
2007-05-07 15:55:33 +02:00
|
|
|
} \
|
|
|
|
FLOAT_OP(name, ps) \
|
|
|
|
{ \
|
|
|
|
FST2 = float32_ ## name(FST0); \
|
|
|
|
FSTH2 = float32_ ## name(FSTH0); \
|
|
|
|
DEBUG_FPU_STATE(); \
|
2007-11-10 00:09:41 +01:00
|
|
|
FORCE_RET(); \
|
2006-06-14 14:56:19 +02:00
|
|
|
}
|
|
|
|
FLOAT_UNOP(abs)
|
|
|
|
FLOAT_UNOP(chs)
|
|
|
|
#undef FLOAT_UNOP
|
|
|
|
|
2007-05-07 15:55:33 +02:00
|
|
|
FLOAT_OP(alnv, ps)
|
|
|
|
{
|
|
|
|
switch (T0 & 0x7) {
|
|
|
|
case 0:
|
|
|
|
FST2 = FST0;
|
|
|
|
FSTH2 = FSTH0;
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
#ifdef TARGET_WORDS_BIGENDIAN
|
|
|
|
FSTH2 = FST0;
|
|
|
|
FST2 = FSTH1;
|
|
|
|
#else
|
|
|
|
FSTH2 = FST1;
|
|
|
|
FST2 = FSTH0;
|
|
|
|
#endif
|
|
|
|
break;
|
|
|
|
default: /* unpredictable */
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
DEBUG_FPU_STATE();
|
2007-11-10 00:09:41 +01:00
|
|
|
FORCE_RET();
|
2007-05-07 15:55:33 +02:00
|
|
|
}
|
2006-06-14 14:56:19 +02:00
|
|
|
|
|
|
|
void op_bc1f (void)
|
|
|
|
{
|
2007-09-06 02:18:15 +02:00
|
|
|
T0 = !!(~GET_FP_COND(env->fpu) & (0x1 << PARAM1));
|
2007-05-07 15:55:33 +02:00
|
|
|
DEBUG_FPU_STATE();
|
2007-11-10 00:09:41 +01:00
|
|
|
FORCE_RET();
|
2007-05-07 15:55:33 +02:00
|
|
|
}
|
2007-05-18 13:55:54 +02:00
|
|
|
void op_bc1any2f (void)
|
2007-05-07 15:55:33 +02:00
|
|
|
{
|
2007-09-06 02:18:15 +02:00
|
|
|
T0 = !!(~GET_FP_COND(env->fpu) & (0x3 << PARAM1));
|
2007-05-07 15:55:33 +02:00
|
|
|
DEBUG_FPU_STATE();
|
2007-11-10 00:09:41 +01:00
|
|
|
FORCE_RET();
|
2007-05-07 15:55:33 +02:00
|
|
|
}
|
2007-05-18 13:55:54 +02:00
|
|
|
void op_bc1any4f (void)
|
2007-05-07 15:55:33 +02:00
|
|
|
{
|
2007-09-06 02:18:15 +02:00
|
|
|
T0 = !!(~GET_FP_COND(env->fpu) & (0xf << PARAM1));
|
2006-06-14 14:56:19 +02:00
|
|
|
DEBUG_FPU_STATE();
|
2007-11-10 00:09:41 +01:00
|
|
|
FORCE_RET();
|
2006-06-14 14:56:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void op_bc1t (void)
|
|
|
|
{
|
2007-09-06 02:18:15 +02:00
|
|
|
T0 = !!(GET_FP_COND(env->fpu) & (0x1 << PARAM1));
|
2007-05-07 15:55:33 +02:00
|
|
|
DEBUG_FPU_STATE();
|
2007-11-10 00:09:41 +01:00
|
|
|
FORCE_RET();
|
2007-05-07 15:55:33 +02:00
|
|
|
}
|
2007-05-18 13:55:54 +02:00
|
|
|
void op_bc1any2t (void)
|
2007-05-07 15:55:33 +02:00
|
|
|
{
|
2007-09-06 02:18:15 +02:00
|
|
|
T0 = !!(GET_FP_COND(env->fpu) & (0x3 << PARAM1));
|
2007-05-07 15:55:33 +02:00
|
|
|
DEBUG_FPU_STATE();
|
2007-11-10 00:09:41 +01:00
|
|
|
FORCE_RET();
|
2007-05-07 15:55:33 +02:00
|
|
|
}
|
2007-05-18 13:55:54 +02:00
|
|
|
void op_bc1any4t (void)
|
2007-05-07 15:55:33 +02:00
|
|
|
{
|
2007-09-06 02:18:15 +02:00
|
|
|
T0 = !!(GET_FP_COND(env->fpu) & (0xf << PARAM1));
|
2006-06-14 14:56:19 +02:00
|
|
|
DEBUG_FPU_STATE();
|
2007-11-10 00:09:41 +01:00
|
|
|
FORCE_RET();
|
2006-06-14 14:56:19 +02:00
|
|
|
}
|