2003-11-23 15:55:54 +01:00
|
|
|
/*
|
2005-07-02 22:59:34 +02:00
|
|
|
* PowerPC emulation for qemu: main translation routines.
|
2007-09-16 23:08:06 +02:00
|
|
|
*
|
2007-03-07 09:32:30 +01:00
|
|
|
* Copyright (c) 2003-2007 Jocelyn Mayer
|
2011-04-30 00:10:23 +02:00
|
|
|
* Copyright (C) 2011 Freescale Semiconductor, Inc.
|
2003-11-23 15:55:54 +01: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
|
2009-07-16 22:47:01 +02:00
|
|
|
* License along with this library; if not, see <http://www.gnu.org/licenses/>.
|
2003-11-23 15:55:54 +01:00
|
|
|
*/
|
2004-05-20 15:10:49 +02:00
|
|
|
|
2016-01-26 19:16:58 +01:00
|
|
|
#include "qemu/osdep.h"
|
2003-11-23 15:55:54 +01:00
|
|
|
#include "cpu.h"
|
2012-10-24 11:12:21 +02:00
|
|
|
#include "disas/disas.h"
|
2008-02-01 11:50:11 +01:00
|
|
|
#include "tcg-op.h"
|
2012-12-17 18:20:00 +01:00
|
|
|
#include "qemu/host-utils.h"
|
2014-03-28 19:42:10 +01:00
|
|
|
#include "exec/cpu_ldst.h"
|
2003-11-23 15:55:54 +01:00
|
|
|
|
2014-04-08 07:31:41 +02:00
|
|
|
#include "exec/helper-proto.h"
|
|
|
|
#include "exec/helper-gen.h"
|
2008-11-17 15:43:54 +01:00
|
|
|
|
2014-05-30 14:12:25 +02:00
|
|
|
#include "trace-tcg.h"
|
2016-01-07 14:55:28 +01:00
|
|
|
#include "exec/log.h"
|
2014-05-30 14:12:25 +02:00
|
|
|
|
|
|
|
|
2008-05-11 01:28:14 +02:00
|
|
|
#define CPU_SINGLE_STEP 0x1
|
|
|
|
#define CPU_BRANCH_STEP 0x2
|
|
|
|
#define GDBSTUB_SINGLE_STEP 0x4
|
|
|
|
|
Great rework and cleanups to ease PowerPC implementations definitions.
* cleanup cpu.h, removing definitions used only in translate.c/translate_init.c
* add new flags to define instructions sets more precisely
* various changes in MMU models definitions
* add definitions for PowerPC 440/460 support (insns and SPRs).
* add definitions for PowerPC 401/403 and 620 input pins model
* Fix definitions for most PowerPC 401, 403, 405, 440, 601, 602, 603 and 7x0
* Preliminary support for PowerPC 74xx (aka G4) without altivec.
* Code provision for other PowerPC support (7x5, 970, ...).
* New SPR and PVR defined, from PowerPC 2.04 specification and other sources
* Misc code bugs, error messages and styles fixes.
* Update status files for PowerPC cores support.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3244 c046a42c-6fe2-441c-8c8c-71466251a162
2007-09-27 01:54:22 +02:00
|
|
|
/* Include definitions for instructions classes and implementations flags */
|
2004-05-21 14:59:32 +02:00
|
|
|
//#define PPC_DEBUG_DISAS
|
2007-03-07 09:32:30 +01:00
|
|
|
//#define DO_PPC_STATISTICS
|
2003-11-23 15:55:54 +01:00
|
|
|
|
2009-01-15 22:48:06 +01:00
|
|
|
#ifdef PPC_DEBUG_DISAS
|
2009-01-15 23:34:14 +01:00
|
|
|
# define LOG_DISAS(...) qemu_log_mask(CPU_LOG_TB_IN_ASM, ## __VA_ARGS__)
|
2009-01-15 22:48:06 +01:00
|
|
|
#else
|
|
|
|
# define LOG_DISAS(...) do { } while (0)
|
|
|
|
#endif
|
Great rework and cleanups to ease PowerPC implementations definitions.
* cleanup cpu.h, removing definitions used only in translate.c/translate_init.c
* add new flags to define instructions sets more precisely
* various changes in MMU models definitions
* add definitions for PowerPC 440/460 support (insns and SPRs).
* add definitions for PowerPC 401/403 and 620 input pins model
* Fix definitions for most PowerPC 401, 403, 405, 440, 601, 602, 603 and 7x0
* Preliminary support for PowerPC 74xx (aka G4) without altivec.
* Code provision for other PowerPC support (7x5, 970, ...).
* New SPR and PVR defined, from PowerPC 2.04 specification and other sources
* Misc code bugs, error messages and styles fixes.
* Update status files for PowerPC cores support.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3244 c046a42c-6fe2-441c-8c8c-71466251a162
2007-09-27 01:54:22 +02:00
|
|
|
/*****************************************************************************/
|
|
|
|
/* Code translation helpers */
|
2005-10-30 22:39:19 +01:00
|
|
|
|
2008-09-04 07:25:47 +02:00
|
|
|
/* global register indexes */
|
2016-02-25 17:43:15 +01:00
|
|
|
static TCGv_env cpu_env;
|
2008-09-04 16:43:45 +02:00
|
|
|
static char cpu_reg_names[10*3 + 22*4 /* GPR */
|
|
|
|
+ 10*4 + 22*5 /* SPE GPRh */
|
2008-09-04 16:43:54 +02:00
|
|
|
+ 10*4 + 22*5 /* FPR */
|
2008-09-04 19:06:47 +02:00
|
|
|
+ 2*(10*6 + 22*7) /* AVRh, AVRl */
|
2013-10-22 13:07:41 +02:00
|
|
|
+ 10*5 + 22*6 /* VSR */
|
2008-09-04 19:06:47 +02:00
|
|
|
+ 8*5 /* CRF */];
|
2008-09-04 07:25:47 +02:00
|
|
|
static TCGv cpu_gpr[32];
|
|
|
|
static TCGv cpu_gprh[32];
|
2008-11-17 15:43:54 +01:00
|
|
|
static TCGv_i64 cpu_fpr[32];
|
|
|
|
static TCGv_i64 cpu_avrh[32], cpu_avrl[32];
|
2013-10-22 13:07:41 +02:00
|
|
|
static TCGv_i64 cpu_vsr[32];
|
2008-11-17 15:43:54 +01:00
|
|
|
static TCGv_i32 cpu_crf[8];
|
2008-09-04 20:06:03 +02:00
|
|
|
static TCGv cpu_nip;
|
2008-12-06 14:03:35 +01:00
|
|
|
static TCGv cpu_msr;
|
2008-09-14 20:30:23 +02:00
|
|
|
static TCGv cpu_ctr;
|
|
|
|
static TCGv cpu_lr;
|
2011-08-31 17:45:10 +02:00
|
|
|
#if defined(TARGET_PPC64)
|
|
|
|
static TCGv cpu_cfar;
|
|
|
|
#endif
|
2013-02-20 08:52:13 +01:00
|
|
|
static TCGv cpu_xer, cpu_so, cpu_ov, cpu_ca;
|
2008-11-30 17:24:39 +01:00
|
|
|
static TCGv cpu_reserve;
|
2012-10-29 18:24:59 +01:00
|
|
|
static TCGv cpu_fpscr;
|
2008-11-23 17:30:40 +01:00
|
|
|
static TCGv_i32 cpu_access_type;
|
2008-09-04 07:25:47 +02:00
|
|
|
|
2012-12-17 18:19:49 +01:00
|
|
|
#include "exec/gen-icount.h"
|
2008-06-29 03:03:05 +02:00
|
|
|
|
|
|
|
void ppc_translate_init(void)
|
|
|
|
{
|
2008-09-04 07:25:47 +02:00
|
|
|
int i;
|
|
|
|
char* p;
|
2009-04-13 18:06:19 +02:00
|
|
|
size_t cpu_reg_names_size;
|
2008-06-29 14:29:56 +02:00
|
|
|
static int done_init = 0;
|
2008-09-04 07:25:47 +02:00
|
|
|
|
2008-06-29 03:03:05 +02:00
|
|
|
if (done_init)
|
|
|
|
return;
|
2008-09-04 07:25:47 +02:00
|
|
|
|
2008-11-17 15:43:54 +01:00
|
|
|
cpu_env = tcg_global_reg_new_ptr(TCG_AREG0, "env");
|
|
|
|
|
2008-09-04 07:25:47 +02:00
|
|
|
p = cpu_reg_names;
|
2009-04-13 18:06:19 +02:00
|
|
|
cpu_reg_names_size = sizeof(cpu_reg_names);
|
2008-09-04 19:06:47 +02:00
|
|
|
|
|
|
|
for (i = 0; i < 8; i++) {
|
2009-04-13 18:06:19 +02:00
|
|
|
snprintf(p, cpu_reg_names_size, "crf%d", i);
|
2013-09-18 21:53:09 +02:00
|
|
|
cpu_crf[i] = tcg_global_mem_new_i32(cpu_env,
|
2012-03-14 01:38:22 +01:00
|
|
|
offsetof(CPUPPCState, crf[i]), p);
|
2008-09-04 19:06:47 +02:00
|
|
|
p += 5;
|
2009-04-13 18:06:19 +02:00
|
|
|
cpu_reg_names_size -= 5;
|
2008-09-04 19:06:47 +02:00
|
|
|
}
|
|
|
|
|
2008-09-04 07:25:47 +02:00
|
|
|
for (i = 0; i < 32; i++) {
|
2009-04-13 18:06:19 +02:00
|
|
|
snprintf(p, cpu_reg_names_size, "r%d", i);
|
2013-09-18 21:53:09 +02:00
|
|
|
cpu_gpr[i] = tcg_global_mem_new(cpu_env,
|
2012-03-14 01:38:22 +01:00
|
|
|
offsetof(CPUPPCState, gpr[i]), p);
|
2008-09-04 07:25:47 +02:00
|
|
|
p += (i < 10) ? 3 : 4;
|
2009-04-13 18:06:19 +02:00
|
|
|
cpu_reg_names_size -= (i < 10) ? 3 : 4;
|
|
|
|
snprintf(p, cpu_reg_names_size, "r%dH", i);
|
2013-09-18 21:53:09 +02:00
|
|
|
cpu_gprh[i] = tcg_global_mem_new(cpu_env,
|
2014-06-04 22:58:50 +02:00
|
|
|
offsetof(CPUPPCState, gprh[i]), p);
|
2008-09-04 07:25:47 +02:00
|
|
|
p += (i < 10) ? 4 : 5;
|
2009-04-13 18:06:19 +02:00
|
|
|
cpu_reg_names_size -= (i < 10) ? 4 : 5;
|
2008-09-04 16:43:45 +02:00
|
|
|
|
2009-04-13 18:06:19 +02:00
|
|
|
snprintf(p, cpu_reg_names_size, "fp%d", i);
|
2013-09-18 21:53:09 +02:00
|
|
|
cpu_fpr[i] = tcg_global_mem_new_i64(cpu_env,
|
2012-03-14 01:38:22 +01:00
|
|
|
offsetof(CPUPPCState, fpr[i]), p);
|
2008-09-04 17:49:12 +02:00
|
|
|
p += (i < 10) ? 4 : 5;
|
2009-04-13 18:06:19 +02:00
|
|
|
cpu_reg_names_size -= (i < 10) ? 4 : 5;
|
2008-09-04 16:43:54 +02:00
|
|
|
|
2009-04-13 18:06:19 +02:00
|
|
|
snprintf(p, cpu_reg_names_size, "avr%dH", i);
|
2009-07-27 16:13:06 +02:00
|
|
|
#ifdef HOST_WORDS_BIGENDIAN
|
2013-09-18 21:53:09 +02:00
|
|
|
cpu_avrh[i] = tcg_global_mem_new_i64(cpu_env,
|
2012-03-14 01:38:22 +01:00
|
|
|
offsetof(CPUPPCState, avr[i].u64[0]), p);
|
2008-11-24 09:47:21 +01:00
|
|
|
#else
|
2013-09-18 21:53:09 +02:00
|
|
|
cpu_avrh[i] = tcg_global_mem_new_i64(cpu_env,
|
2012-03-14 01:38:22 +01:00
|
|
|
offsetof(CPUPPCState, avr[i].u64[1]), p);
|
2008-11-24 09:47:21 +01:00
|
|
|
#endif
|
2008-09-04 16:43:45 +02:00
|
|
|
p += (i < 10) ? 6 : 7;
|
2009-04-13 18:06:19 +02:00
|
|
|
cpu_reg_names_size -= (i < 10) ? 6 : 7;
|
2008-09-04 17:49:12 +02:00
|
|
|
|
2009-04-13 18:06:19 +02:00
|
|
|
snprintf(p, cpu_reg_names_size, "avr%dL", i);
|
2009-07-27 16:13:06 +02:00
|
|
|
#ifdef HOST_WORDS_BIGENDIAN
|
2013-09-18 21:53:09 +02:00
|
|
|
cpu_avrl[i] = tcg_global_mem_new_i64(cpu_env,
|
2012-03-14 01:38:22 +01:00
|
|
|
offsetof(CPUPPCState, avr[i].u64[1]), p);
|
2008-11-24 09:47:21 +01:00
|
|
|
#else
|
2013-09-18 21:53:09 +02:00
|
|
|
cpu_avrl[i] = tcg_global_mem_new_i64(cpu_env,
|
2012-03-14 01:38:22 +01:00
|
|
|
offsetof(CPUPPCState, avr[i].u64[0]), p);
|
2008-11-24 09:47:21 +01:00
|
|
|
#endif
|
2008-09-04 16:43:45 +02:00
|
|
|
p += (i < 10) ? 6 : 7;
|
2009-04-13 18:06:19 +02:00
|
|
|
cpu_reg_names_size -= (i < 10) ? 6 : 7;
|
2013-10-22 13:07:41 +02:00
|
|
|
snprintf(p, cpu_reg_names_size, "vsr%d", i);
|
2013-09-18 21:53:09 +02:00
|
|
|
cpu_vsr[i] = tcg_global_mem_new_i64(cpu_env,
|
|
|
|
offsetof(CPUPPCState, vsr[i]), p);
|
2013-10-22 13:07:41 +02:00
|
|
|
p += (i < 10) ? 5 : 6;
|
|
|
|
cpu_reg_names_size -= (i < 10) ? 5 : 6;
|
2008-09-04 07:25:47 +02:00
|
|
|
}
|
2008-08-28 23:01:45 +02:00
|
|
|
|
2013-09-18 21:53:09 +02:00
|
|
|
cpu_nip = tcg_global_mem_new(cpu_env,
|
2012-03-14 01:38:22 +01:00
|
|
|
offsetof(CPUPPCState, nip), "nip");
|
2008-09-04 20:06:03 +02:00
|
|
|
|
2013-09-18 21:53:09 +02:00
|
|
|
cpu_msr = tcg_global_mem_new(cpu_env,
|
2012-03-14 01:38:22 +01:00
|
|
|
offsetof(CPUPPCState, msr), "msr");
|
2008-12-06 14:03:35 +01:00
|
|
|
|
2013-09-18 21:53:09 +02:00
|
|
|
cpu_ctr = tcg_global_mem_new(cpu_env,
|
2012-03-14 01:38:22 +01:00
|
|
|
offsetof(CPUPPCState, ctr), "ctr");
|
2008-09-14 20:30:23 +02:00
|
|
|
|
2013-09-18 21:53:09 +02:00
|
|
|
cpu_lr = tcg_global_mem_new(cpu_env,
|
2012-03-14 01:38:22 +01:00
|
|
|
offsetof(CPUPPCState, lr), "lr");
|
2008-09-14 20:30:23 +02:00
|
|
|
|
2011-08-31 17:45:10 +02:00
|
|
|
#if defined(TARGET_PPC64)
|
2013-09-18 21:53:09 +02:00
|
|
|
cpu_cfar = tcg_global_mem_new(cpu_env,
|
2012-03-14 01:38:22 +01:00
|
|
|
offsetof(CPUPPCState, cfar), "cfar");
|
2011-08-31 17:45:10 +02:00
|
|
|
#endif
|
|
|
|
|
2013-09-18 21:53:09 +02:00
|
|
|
cpu_xer = tcg_global_mem_new(cpu_env,
|
2012-03-14 01:38:22 +01:00
|
|
|
offsetof(CPUPPCState, xer), "xer");
|
2013-09-18 21:53:09 +02:00
|
|
|
cpu_so = tcg_global_mem_new(cpu_env,
|
2013-02-20 08:52:13 +01:00
|
|
|
offsetof(CPUPPCState, so), "SO");
|
2013-09-18 21:53:09 +02:00
|
|
|
cpu_ov = tcg_global_mem_new(cpu_env,
|
2013-02-20 08:52:13 +01:00
|
|
|
offsetof(CPUPPCState, ov), "OV");
|
2013-09-18 21:53:09 +02:00
|
|
|
cpu_ca = tcg_global_mem_new(cpu_env,
|
2013-02-20 08:52:13 +01:00
|
|
|
offsetof(CPUPPCState, ca), "CA");
|
2008-10-21 13:28:46 +02:00
|
|
|
|
2013-09-18 21:53:09 +02:00
|
|
|
cpu_reserve = tcg_global_mem_new(cpu_env,
|
2012-03-14 01:38:22 +01:00
|
|
|
offsetof(CPUPPCState, reserve_addr),
|
2009-08-03 17:43:25 +02:00
|
|
|
"reserve_addr");
|
2008-11-30 17:24:39 +01:00
|
|
|
|
2013-09-18 21:53:09 +02:00
|
|
|
cpu_fpscr = tcg_global_mem_new(cpu_env,
|
2012-10-29 18:24:59 +01:00
|
|
|
offsetof(CPUPPCState, fpscr), "fpscr");
|
2008-10-21 13:31:14 +02:00
|
|
|
|
2013-09-18 21:53:09 +02:00
|
|
|
cpu_access_type = tcg_global_mem_new_i32(cpu_env,
|
2012-03-14 01:38:22 +01:00
|
|
|
offsetof(CPUPPCState, access_type), "access_type");
|
2008-11-23 17:30:40 +01:00
|
|
|
|
2008-06-29 03:03:05 +02:00
|
|
|
done_init = 1;
|
|
|
|
}
|
|
|
|
|
2003-11-23 15:55:54 +01:00
|
|
|
/* internal defines */
|
2014-11-26 11:39:48 +01:00
|
|
|
struct DisasContext {
|
2003-11-23 15:55:54 +01:00
|
|
|
struct TranslationBlock *tb;
|
2005-01-04 00:43:32 +01:00
|
|
|
target_ulong nip;
|
2003-11-23 15:55:54 +01:00
|
|
|
uint32_t opcode;
|
2004-01-04 23:58:38 +01:00
|
|
|
uint32_t exception;
|
2005-02-16 00:06:19 +01:00
|
|
|
/* Routine used to access memory */
|
2014-09-15 17:03:28 +02:00
|
|
|
bool pr, hv;
|
2005-02-16 00:06:19 +01:00
|
|
|
int mem_idx;
|
2008-12-08 19:11:21 +01:00
|
|
|
int access_type;
|
2005-02-16 00:06:19 +01:00
|
|
|
/* Translation flags */
|
2008-12-08 19:11:21 +01:00
|
|
|
int le_mode;
|
2014-05-29 16:12:20 +02:00
|
|
|
TCGMemOp default_tcg_memop_mask;
|
2007-03-17 15:02:15 +01:00
|
|
|
#if defined(TARGET_PPC64)
|
|
|
|
int sf_mode;
|
2011-08-31 17:45:10 +02:00
|
|
|
int has_cfar;
|
2004-01-04 23:58:38 +01:00
|
|
|
#endif
|
2005-02-16 00:06:19 +01:00
|
|
|
int fpu_enabled;
|
2007-10-07 20:19:26 +02:00
|
|
|
int altivec_enabled;
|
2013-10-22 13:06:17 +02:00
|
|
|
int vsx_enabled;
|
2007-03-20 23:11:31 +01:00
|
|
|
int spe_enabled;
|
2014-12-18 17:34:31 +01:00
|
|
|
int tm_enabled;
|
2009-10-01 23:12:16 +02:00
|
|
|
ppc_spr_t *spr_cb; /* Needed to check rights for mfspr/mtspr */
|
2006-05-22 23:50:20 +02:00
|
|
|
int singlestep_enabled;
|
2013-04-20 10:56:22 +02:00
|
|
|
uint64_t insns_flags;
|
|
|
|
uint64_t insns_flags2;
|
2014-11-26 11:39:48 +01:00
|
|
|
};
|
2003-11-23 15:55:54 +01:00
|
|
|
|
2014-05-29 16:12:20 +02:00
|
|
|
/* Return true iff byteswap is needed in a scalar memop */
|
|
|
|
static inline bool need_byteswap(const DisasContext *ctx)
|
|
|
|
{
|
|
|
|
#if defined(TARGET_WORDS_BIGENDIAN)
|
|
|
|
return ctx->le_mode;
|
|
|
|
#else
|
|
|
|
return !ctx->le_mode;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2013-03-21 11:01:45 +01:00
|
|
|
/* True when active word size < size of target_long. */
|
|
|
|
#ifdef TARGET_PPC64
|
|
|
|
# define NARROW_MODE(C) (!(C)->sf_mode)
|
|
|
|
#else
|
|
|
|
# define NARROW_MODE(C) 0
|
|
|
|
#endif
|
|
|
|
|
2009-10-01 23:12:16 +02:00
|
|
|
struct opc_handler_t {
|
2011-09-28 07:54:05 +02:00
|
|
|
/* invalid bits for instruction 1 (Rc(opcode) == 0) */
|
|
|
|
uint32_t inval1;
|
|
|
|
/* invalid bits for instruction 2 (Rc(opcode) == 1) */
|
|
|
|
uint32_t inval2;
|
2004-01-04 23:58:38 +01:00
|
|
|
/* instruction type */
|
2007-03-20 23:11:31 +01:00
|
|
|
uint64_t type;
|
2011-05-01 00:00:58 +02:00
|
|
|
/* extended instruction type */
|
|
|
|
uint64_t type2;
|
2003-11-23 15:55:54 +01:00
|
|
|
/* handler */
|
|
|
|
void (*handler)(DisasContext *ctx);
|
Great rework and cleanups to ease PowerPC implementations definitions.
* cleanup cpu.h, removing definitions used only in translate.c/translate_init.c
* add new flags to define instructions sets more precisely
* various changes in MMU models definitions
* add definitions for PowerPC 440/460 support (insns and SPRs).
* add definitions for PowerPC 401/403 and 620 input pins model
* Fix definitions for most PowerPC 401, 403, 405, 440, 601, 602, 603 and 7x0
* Preliminary support for PowerPC 74xx (aka G4) without altivec.
* Code provision for other PowerPC support (7x5, 970, ...).
* New SPR and PVR defined, from PowerPC 2.04 specification and other sources
* Misc code bugs, error messages and styles fixes.
* Update status files for PowerPC cores support.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3244 c046a42c-6fe2-441c-8c8c-71466251a162
2007-09-27 01:54:22 +02:00
|
|
|
#if defined(DO_PPC_STATISTICS) || defined(PPC_DUMP_CPU)
|
2008-09-20 10:07:15 +02:00
|
|
|
const char *oname;
|
Great rework and cleanups to ease PowerPC implementations definitions.
* cleanup cpu.h, removing definitions used only in translate.c/translate_init.c
* add new flags to define instructions sets more precisely
* various changes in MMU models definitions
* add definitions for PowerPC 440/460 support (insns and SPRs).
* add definitions for PowerPC 401/403 and 620 input pins model
* Fix definitions for most PowerPC 401, 403, 405, 440, 601, 602, 603 and 7x0
* Preliminary support for PowerPC 74xx (aka G4) without altivec.
* Code provision for other PowerPC support (7x5, 970, ...).
* New SPR and PVR defined, from PowerPC 2.04 specification and other sources
* Misc code bugs, error messages and styles fixes.
* Update status files for PowerPC cores support.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3244 c046a42c-6fe2-441c-8c8c-71466251a162
2007-09-27 01:54:22 +02:00
|
|
|
#endif
|
|
|
|
#if defined(DO_PPC_STATISTICS)
|
2007-03-07 09:32:30 +01:00
|
|
|
uint64_t count;
|
|
|
|
#endif
|
2005-07-02 22:59:34 +02:00
|
|
|
};
|
2003-11-23 15:55:54 +01:00
|
|
|
|
2009-08-16 11:06:54 +02:00
|
|
|
static inline void gen_reset_fpstatus(void)
|
2007-10-27 19:54:30 +02:00
|
|
|
{
|
2012-05-30 06:23:27 +02:00
|
|
|
gen_helper_reset_fpstatus(cpu_env);
|
2007-10-27 19:54:30 +02:00
|
|
|
}
|
|
|
|
|
2014-11-12 22:46:03 +01:00
|
|
|
static inline void gen_compute_fprf(TCGv_i64 arg)
|
2007-10-27 19:54:30 +02:00
|
|
|
{
|
2014-11-12 22:46:04 +01:00
|
|
|
gen_helper_compute_fprf(cpu_env, arg);
|
2014-11-12 22:46:03 +01:00
|
|
|
gen_helper_float_check_status(cpu_env);
|
2007-10-27 19:54:30 +02:00
|
|
|
}
|
|
|
|
|
2009-08-16 11:06:54 +02:00
|
|
|
static inline void gen_set_access_type(DisasContext *ctx, int access_type)
|
2008-11-23 17:30:40 +01:00
|
|
|
{
|
2008-12-08 19:11:21 +01:00
|
|
|
if (ctx->access_type != access_type) {
|
|
|
|
tcg_gen_movi_i32(cpu_access_type, access_type);
|
|
|
|
ctx->access_type = access_type;
|
|
|
|
}
|
2008-11-23 17:30:40 +01:00
|
|
|
}
|
|
|
|
|
2009-08-16 11:06:54 +02:00
|
|
|
static inline void gen_update_nip(DisasContext *ctx, target_ulong nip)
|
2007-03-17 15:02:15 +01:00
|
|
|
{
|
2013-03-21 11:01:46 +01:00
|
|
|
if (NARROW_MODE(ctx)) {
|
|
|
|
nip = (uint32_t)nip;
|
|
|
|
}
|
|
|
|
tcg_gen_movi_tl(cpu_nip, nip);
|
2007-03-17 15:02:15 +01:00
|
|
|
}
|
|
|
|
|
2014-06-04 14:50:56 +02:00
|
|
|
void gen_update_current_nip(void *opaque)
|
|
|
|
{
|
|
|
|
DisasContext *ctx = opaque;
|
|
|
|
|
|
|
|
tcg_gen_movi_tl(cpu_nip, ctx->nip);
|
|
|
|
}
|
|
|
|
|
2009-08-16 11:06:54 +02:00
|
|
|
static inline void gen_exception_err(DisasContext *ctx, uint32_t excp, uint32_t error)
|
2008-12-11 23:42:14 +01:00
|
|
|
{
|
|
|
|
TCGv_i32 t0, t1;
|
|
|
|
if (ctx->exception == POWERPC_EXCP_NONE) {
|
|
|
|
gen_update_nip(ctx, ctx->nip);
|
|
|
|
}
|
|
|
|
t0 = tcg_const_i32(excp);
|
|
|
|
t1 = tcg_const_i32(error);
|
2012-05-30 06:23:23 +02:00
|
|
|
gen_helper_raise_exception_err(cpu_env, t0, t1);
|
2008-12-11 23:42:14 +01:00
|
|
|
tcg_temp_free_i32(t0);
|
|
|
|
tcg_temp_free_i32(t1);
|
|
|
|
ctx->exception = (excp);
|
|
|
|
}
|
2007-09-29 15:06:16 +02:00
|
|
|
|
2009-08-16 11:06:54 +02:00
|
|
|
static inline void gen_exception(DisasContext *ctx, uint32_t excp)
|
2008-12-11 23:42:14 +01:00
|
|
|
{
|
|
|
|
TCGv_i32 t0;
|
|
|
|
if (ctx->exception == POWERPC_EXCP_NONE) {
|
|
|
|
gen_update_nip(ctx, ctx->nip);
|
|
|
|
}
|
|
|
|
t0 = tcg_const_i32(excp);
|
2012-05-30 06:23:23 +02:00
|
|
|
gen_helper_raise_exception(cpu_env, t0);
|
2008-12-11 23:42:14 +01:00
|
|
|
tcg_temp_free_i32(t0);
|
|
|
|
ctx->exception = (excp);
|
|
|
|
}
|
2007-09-29 15:06:16 +02:00
|
|
|
|
2009-08-16 11:06:54 +02:00
|
|
|
static inline void gen_debug_exception(DisasContext *ctx)
|
2008-12-11 23:42:14 +01:00
|
|
|
{
|
|
|
|
TCGv_i32 t0;
|
2009-02-19 21:17:09 +01:00
|
|
|
|
2011-08-10 03:41:48 +02:00
|
|
|
if ((ctx->exception != POWERPC_EXCP_BRANCH) &&
|
|
|
|
(ctx->exception != POWERPC_EXCP_SYNC)) {
|
2009-02-19 21:17:09 +01:00
|
|
|
gen_update_nip(ctx, ctx->nip);
|
2011-08-10 03:41:48 +02:00
|
|
|
}
|
2008-12-11 23:42:14 +01:00
|
|
|
t0 = tcg_const_i32(EXCP_DEBUG);
|
2012-05-30 06:23:23 +02:00
|
|
|
gen_helper_raise_exception(cpu_env, t0);
|
2008-12-11 23:42:14 +01:00
|
|
|
tcg_temp_free_i32(t0);
|
|
|
|
}
|
2004-01-04 23:58:38 +01:00
|
|
|
|
2009-08-16 11:06:54 +02:00
|
|
|
static inline void gen_inval_exception(DisasContext *ctx, uint32_t error)
|
2008-12-11 23:42:14 +01:00
|
|
|
{
|
|
|
|
gen_exception_err(ctx, POWERPC_EXCP_PROGRAM, POWERPC_EXCP_INVAL | error);
|
|
|
|
}
|
2007-10-07 20:19:26 +02:00
|
|
|
|
2005-11-23 22:36:30 +01:00
|
|
|
/* Stop translation */
|
2009-08-16 11:06:54 +02:00
|
|
|
static inline void gen_stop_exception(DisasContext *ctx)
|
2005-07-02 22:59:34 +02:00
|
|
|
{
|
2007-03-17 15:02:15 +01:00
|
|
|
gen_update_nip(ctx, ctx->nip);
|
2007-09-29 15:06:16 +02:00
|
|
|
ctx->exception = POWERPC_EXCP_STOP;
|
2005-07-02 22:59:34 +02:00
|
|
|
}
|
|
|
|
|
2014-12-23 23:22:15 +01:00
|
|
|
#ifndef CONFIG_USER_ONLY
|
2005-11-23 22:36:30 +01:00
|
|
|
/* No need to update nip here, as execution flow will change */
|
2009-08-16 11:06:54 +02:00
|
|
|
static inline void gen_sync_exception(DisasContext *ctx)
|
2005-07-03 00:09:27 +02:00
|
|
|
{
|
2007-09-29 15:06:16 +02:00
|
|
|
ctx->exception = POWERPC_EXCP_SYNC;
|
2005-07-03 00:09:27 +02:00
|
|
|
}
|
2014-12-23 23:22:15 +01:00
|
|
|
#endif
|
2005-07-03 00:09:27 +02:00
|
|
|
|
2003-11-23 15:55:54 +01:00
|
|
|
#define GEN_HANDLER(name, opc1, opc2, opc3, inval, type) \
|
2011-05-01 00:00:58 +02:00
|
|
|
GEN_OPCODE(name, opc1, opc2, opc3, inval, type, PPC_NONE)
|
|
|
|
|
|
|
|
#define GEN_HANDLER_E(name, opc1, opc2, opc3, inval, type, type2) \
|
|
|
|
GEN_OPCODE(name, opc1, opc2, opc3, inval, type, type2)
|
2003-11-23 15:55:54 +01:00
|
|
|
|
2007-10-26 02:46:07 +02:00
|
|
|
#define GEN_HANDLER2(name, onam, opc1, opc2, opc3, inval, type) \
|
2011-05-01 00:00:58 +02:00
|
|
|
GEN_OPCODE2(name, onam, opc1, opc2, opc3, inval, type, PPC_NONE)
|
|
|
|
|
|
|
|
#define GEN_HANDLER2_E(name, onam, opc1, opc2, opc3, inval, type, type2) \
|
|
|
|
GEN_OPCODE2(name, onam, opc1, opc2, opc3, inval, type, type2)
|
2007-10-26 02:46:07 +02:00
|
|
|
|
2009-10-01 23:12:16 +02:00
|
|
|
typedef struct opcode_t {
|
2003-11-23 15:55:54 +01:00
|
|
|
unsigned char opc1, opc2, opc3;
|
2008-06-03 21:51:57 +02:00
|
|
|
#if HOST_LONG_BITS == 64 /* Explicitly align to 64 bits */
|
2005-02-08 22:24:36 +01:00
|
|
|
unsigned char pad[5];
|
|
|
|
#else
|
|
|
|
unsigned char pad[1];
|
|
|
|
#endif
|
2009-10-01 23:12:16 +02:00
|
|
|
opc_handler_t handler;
|
2008-09-20 10:07:15 +02:00
|
|
|
const char *oname;
|
2009-10-01 23:12:16 +02:00
|
|
|
} opcode_t;
|
2003-11-23 15:55:54 +01:00
|
|
|
|
Great rework and cleanups to ease PowerPC implementations definitions.
* cleanup cpu.h, removing definitions used only in translate.c/translate_init.c
* add new flags to define instructions sets more precisely
* various changes in MMU models definitions
* add definitions for PowerPC 440/460 support (insns and SPRs).
* add definitions for PowerPC 401/403 and 620 input pins model
* Fix definitions for most PowerPC 401, 403, 405, 440, 601, 602, 603 and 7x0
* Preliminary support for PowerPC 74xx (aka G4) without altivec.
* Code provision for other PowerPC support (7x5, 970, ...).
* New SPR and PVR defined, from PowerPC 2.04 specification and other sources
* Misc code bugs, error messages and styles fixes.
* Update status files for PowerPC cores support.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3244 c046a42c-6fe2-441c-8c8c-71466251a162
2007-09-27 01:54:22 +02:00
|
|
|
/*****************************************************************************/
|
2003-11-23 15:55:54 +01:00
|
|
|
/*** Instruction decoding ***/
|
|
|
|
#define EXTRACT_HELPER(name, shift, nb) \
|
2009-08-16 11:06:54 +02:00
|
|
|
static inline uint32_t name(uint32_t opcode) \
|
2003-11-23 15:55:54 +01:00
|
|
|
{ \
|
|
|
|
return (opcode >> (shift)) & ((1 << (nb)) - 1); \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define EXTRACT_SHELPER(name, shift, nb) \
|
2009-08-16 11:06:54 +02:00
|
|
|
static inline int32_t name(uint32_t opcode) \
|
2003-11-23 15:55:54 +01:00
|
|
|
{ \
|
2005-02-08 22:24:36 +01:00
|
|
|
return (int16_t)((opcode >> (shift)) & ((1 << (nb)) - 1)); \
|
2003-11-23 15:55:54 +01:00
|
|
|
}
|
|
|
|
|
2013-10-22 13:06:46 +02:00
|
|
|
#define EXTRACT_HELPER_SPLIT(name, shift1, nb1, shift2, nb2) \
|
|
|
|
static inline uint32_t name(uint32_t opcode) \
|
|
|
|
{ \
|
|
|
|
return (((opcode >> (shift1)) & ((1 << (nb1)) - 1)) << nb2) | \
|
|
|
|
((opcode >> (shift2)) & ((1 << (nb2)) - 1)); \
|
|
|
|
}
|
2003-11-23 15:55:54 +01:00
|
|
|
/* Opcode part 1 */
|
|
|
|
EXTRACT_HELPER(opc1, 26, 6);
|
|
|
|
/* Opcode part 2 */
|
|
|
|
EXTRACT_HELPER(opc2, 1, 5);
|
|
|
|
/* Opcode part 3 */
|
|
|
|
EXTRACT_HELPER(opc3, 6, 5);
|
|
|
|
/* Update Cr0 flags */
|
|
|
|
EXTRACT_HELPER(Rc, 0, 1);
|
2014-02-12 22:22:57 +01:00
|
|
|
/* Update Cr6 flags (Altivec) */
|
|
|
|
EXTRACT_HELPER(Rc21, 10, 1);
|
2003-11-23 15:55:54 +01:00
|
|
|
/* Destination */
|
|
|
|
EXTRACT_HELPER(rD, 21, 5);
|
|
|
|
/* Source */
|
|
|
|
EXTRACT_HELPER(rS, 21, 5);
|
|
|
|
/* First operand */
|
|
|
|
EXTRACT_HELPER(rA, 16, 5);
|
|
|
|
/* Second operand */
|
|
|
|
EXTRACT_HELPER(rB, 11, 5);
|
|
|
|
/* Third operand */
|
|
|
|
EXTRACT_HELPER(rC, 6, 5);
|
|
|
|
/*** Get CRn ***/
|
|
|
|
EXTRACT_HELPER(crfD, 23, 3);
|
|
|
|
EXTRACT_HELPER(crfS, 18, 3);
|
|
|
|
EXTRACT_HELPER(crbD, 21, 5);
|
|
|
|
EXTRACT_HELPER(crbA, 16, 5);
|
|
|
|
EXTRACT_HELPER(crbB, 11, 5);
|
|
|
|
/* SPR / TBL */
|
2005-07-02 22:59:34 +02:00
|
|
|
EXTRACT_HELPER(_SPR, 11, 10);
|
2009-08-16 11:06:54 +02:00
|
|
|
static inline uint32_t SPR(uint32_t opcode)
|
2005-07-02 22:59:34 +02:00
|
|
|
{
|
|
|
|
uint32_t sprn = _SPR(opcode);
|
|
|
|
|
|
|
|
return ((sprn >> 5) & 0x1F) | ((sprn & 0x1F) << 5);
|
|
|
|
}
|
2003-11-23 15:55:54 +01:00
|
|
|
/*** Get constants ***/
|
|
|
|
/* 16 bits signed immediate value */
|
|
|
|
EXTRACT_SHELPER(SIMM, 0, 16);
|
|
|
|
/* 16 bits unsigned immediate value */
|
|
|
|
EXTRACT_HELPER(UIMM, 0, 16);
|
2009-01-04 23:10:28 +01:00
|
|
|
/* 5 bits signed immediate value */
|
|
|
|
EXTRACT_HELPER(SIMM5, 16, 5);
|
2009-01-04 23:10:40 +01:00
|
|
|
/* 5 bits signed immediate value */
|
|
|
|
EXTRACT_HELPER(UIMM5, 16, 5);
|
2003-11-23 15:55:54 +01:00
|
|
|
/* Bit count */
|
|
|
|
EXTRACT_HELPER(NB, 11, 5);
|
|
|
|
/* Shift count */
|
|
|
|
EXTRACT_HELPER(SH, 11, 5);
|
2009-01-04 23:10:09 +01:00
|
|
|
/* Vector shift count */
|
|
|
|
EXTRACT_HELPER(VSH, 6, 4);
|
2003-11-23 15:55:54 +01:00
|
|
|
/* Mask start */
|
|
|
|
EXTRACT_HELPER(MB, 6, 5);
|
|
|
|
/* Mask end */
|
|
|
|
EXTRACT_HELPER(ME, 1, 5);
|
2004-01-04 15:57:11 +01:00
|
|
|
/* Trap operand */
|
|
|
|
EXTRACT_HELPER(TO, 21, 5);
|
2003-11-23 15:55:54 +01:00
|
|
|
|
|
|
|
EXTRACT_HELPER(CRM, 12, 8);
|
2014-12-23 23:22:15 +01:00
|
|
|
|
|
|
|
#ifndef CONFIG_USER_ONLY
|
2003-11-23 15:55:54 +01:00
|
|
|
EXTRACT_HELPER(SR, 16, 4);
|
2014-12-23 23:22:15 +01:00
|
|
|
#endif
|
2013-04-20 10:56:22 +02:00
|
|
|
|
|
|
|
/* mtfsf/mtfsfi */
|
2013-08-15 13:32:38 +02:00
|
|
|
EXTRACT_HELPER(FPBF, 23, 3);
|
2008-06-19 00:10:12 +02:00
|
|
|
EXTRACT_HELPER(FPIMM, 12, 4);
|
2013-08-15 13:32:38 +02:00
|
|
|
EXTRACT_HELPER(FPL, 25, 1);
|
2013-04-20 10:56:22 +02:00
|
|
|
EXTRACT_HELPER(FPFLM, 17, 8);
|
|
|
|
EXTRACT_HELPER(FPW, 16, 1);
|
2004-01-04 15:57:11 +01:00
|
|
|
|
2003-11-23 15:55:54 +01:00
|
|
|
/*** Jump target decoding ***/
|
|
|
|
/* Immediate address */
|
2009-08-16 11:06:54 +02:00
|
|
|
static inline target_ulong LI(uint32_t opcode)
|
2003-11-23 15:55:54 +01:00
|
|
|
{
|
|
|
|
return (opcode >> 0) & 0x03FFFFFC;
|
|
|
|
}
|
|
|
|
|
2009-08-16 11:06:54 +02:00
|
|
|
static inline uint32_t BD(uint32_t opcode)
|
2003-11-23 15:55:54 +01:00
|
|
|
{
|
|
|
|
return (opcode >> 0) & 0xFFFC;
|
|
|
|
}
|
|
|
|
|
|
|
|
EXTRACT_HELPER(BO, 21, 5);
|
|
|
|
EXTRACT_HELPER(BI, 16, 5);
|
|
|
|
/* Absolute/relative address */
|
|
|
|
EXTRACT_HELPER(AA, 1, 1);
|
|
|
|
/* Link */
|
|
|
|
EXTRACT_HELPER(LK, 0, 1);
|
|
|
|
|
2014-04-21 22:54:57 +02:00
|
|
|
/* DFP Z22-form */
|
|
|
|
EXTRACT_HELPER(DCM, 10, 6)
|
|
|
|
|
|
|
|
/* DFP Z23-form */
|
|
|
|
EXTRACT_HELPER(RMC, 9, 2)
|
|
|
|
|
2003-11-23 15:55:54 +01:00
|
|
|
/* Create a mask between <start> and <end> bits */
|
2009-08-16 11:06:54 +02:00
|
|
|
static inline target_ulong MASK(uint32_t start, uint32_t end)
|
2003-11-23 15:55:54 +01:00
|
|
|
{
|
2007-03-07 09:32:30 +01:00
|
|
|
target_ulong ret;
|
2003-11-23 15:55:54 +01:00
|
|
|
|
2007-03-07 09:32:30 +01:00
|
|
|
#if defined(TARGET_PPC64)
|
|
|
|
if (likely(start == 0)) {
|
2007-11-12 01:04:48 +01:00
|
|
|
ret = UINT64_MAX << (63 - end);
|
2007-03-07 09:32:30 +01:00
|
|
|
} else if (likely(end == 63)) {
|
2007-11-12 01:04:48 +01:00
|
|
|
ret = UINT64_MAX >> start;
|
2007-03-07 09:32:30 +01:00
|
|
|
}
|
|
|
|
#else
|
|
|
|
if (likely(start == 0)) {
|
2007-11-12 01:04:48 +01:00
|
|
|
ret = UINT32_MAX << (31 - end);
|
2007-03-07 09:32:30 +01:00
|
|
|
} else if (likely(end == 31)) {
|
2007-11-12 01:04:48 +01:00
|
|
|
ret = UINT32_MAX >> start;
|
2007-03-07 09:32:30 +01:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
else {
|
|
|
|
ret = (((target_ulong)(-1ULL)) >> (start)) ^
|
|
|
|
(((target_ulong)(-1ULL) >> (end)) >> 1);
|
|
|
|
if (unlikely(start > end))
|
|
|
|
return ~ret;
|
|
|
|
}
|
2003-11-23 15:55:54 +01:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2013-10-22 13:06:46 +02:00
|
|
|
EXTRACT_HELPER_SPLIT(xT, 0, 1, 21, 5);
|
|
|
|
EXTRACT_HELPER_SPLIT(xS, 0, 1, 21, 5);
|
|
|
|
EXTRACT_HELPER_SPLIT(xA, 2, 1, 16, 5);
|
|
|
|
EXTRACT_HELPER_SPLIT(xB, 1, 1, 11, 5);
|
2013-11-01 14:21:21 +01:00
|
|
|
EXTRACT_HELPER_SPLIT(xC, 3, 1, 6, 5);
|
2013-10-22 13:06:46 +02:00
|
|
|
EXTRACT_HELPER(DM, 8, 2);
|
2013-11-01 14:21:22 +01:00
|
|
|
EXTRACT_HELPER(UIM, 16, 2);
|
2013-11-01 14:21:23 +01:00
|
|
|
EXTRACT_HELPER(SHW, 8, 2);
|
2014-04-21 22:54:57 +02:00
|
|
|
EXTRACT_HELPER(SP, 19, 2);
|
Great rework and cleanups to ease PowerPC implementations definitions.
* cleanup cpu.h, removing definitions used only in translate.c/translate_init.c
* add new flags to define instructions sets more precisely
* various changes in MMU models definitions
* add definitions for PowerPC 440/460 support (insns and SPRs).
* add definitions for PowerPC 401/403 and 620 input pins model
* Fix definitions for most PowerPC 401, 403, 405, 440, 601, 602, 603 and 7x0
* Preliminary support for PowerPC 74xx (aka G4) without altivec.
* Code provision for other PowerPC support (7x5, 970, ...).
* New SPR and PVR defined, from PowerPC 2.04 specification and other sources
* Misc code bugs, error messages and styles fixes.
* Update status files for PowerPC cores support.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3244 c046a42c-6fe2-441c-8c8c-71466251a162
2007-09-27 01:54:22 +02:00
|
|
|
/*****************************************************************************/
|
|
|
|
/* PowerPC instructions table */
|
2004-07-10 17:33:29 +02:00
|
|
|
|
2007-03-07 09:32:30 +01:00
|
|
|
#if defined(DO_PPC_STATISTICS)
|
2011-05-01 00:00:58 +02:00
|
|
|
#define GEN_OPCODE(name, op1, op2, op3, invl, _typ, _typ2) \
|
2009-06-17 17:22:31 +02:00
|
|
|
{ \
|
2003-11-23 15:55:54 +01:00
|
|
|
.opc1 = op1, \
|
|
|
|
.opc2 = op2, \
|
|
|
|
.opc3 = op3, \
|
2005-02-08 22:24:36 +01:00
|
|
|
.pad = { 0, }, \
|
2003-11-23 15:55:54 +01:00
|
|
|
.handler = { \
|
2011-09-28 07:54:05 +02:00
|
|
|
.inval1 = invl, \
|
|
|
|
.type = _typ, \
|
|
|
|
.type2 = _typ2, \
|
|
|
|
.handler = &gen_##name, \
|
|
|
|
.oname = stringify(name), \
|
|
|
|
}, \
|
|
|
|
.oname = stringify(name), \
|
|
|
|
}
|
|
|
|
#define GEN_OPCODE_DUAL(name, op1, op2, op3, invl1, invl2, _typ, _typ2) \
|
|
|
|
{ \
|
|
|
|
.opc1 = op1, \
|
|
|
|
.opc2 = op2, \
|
|
|
|
.opc3 = op3, \
|
|
|
|
.pad = { 0, }, \
|
|
|
|
.handler = { \
|
|
|
|
.inval1 = invl1, \
|
|
|
|
.inval2 = invl2, \
|
2004-01-04 23:58:38 +01:00
|
|
|
.type = _typ, \
|
2011-05-01 00:00:58 +02:00
|
|
|
.type2 = _typ2, \
|
2003-11-23 15:55:54 +01:00
|
|
|
.handler = &gen_##name, \
|
2007-03-07 09:32:30 +01:00
|
|
|
.oname = stringify(name), \
|
2003-11-23 15:55:54 +01:00
|
|
|
}, \
|
2005-07-02 22:59:34 +02:00
|
|
|
.oname = stringify(name), \
|
2003-11-23 15:55:54 +01:00
|
|
|
}
|
2011-05-01 00:00:58 +02:00
|
|
|
#define GEN_OPCODE2(name, onam, op1, op2, op3, invl, _typ, _typ2) \
|
2009-06-17 17:22:31 +02:00
|
|
|
{ \
|
2007-10-26 02:46:07 +02:00
|
|
|
.opc1 = op1, \
|
|
|
|
.opc2 = op2, \
|
|
|
|
.opc3 = op3, \
|
|
|
|
.pad = { 0, }, \
|
|
|
|
.handler = { \
|
2011-09-28 07:54:05 +02:00
|
|
|
.inval1 = invl, \
|
2007-10-26 02:46:07 +02:00
|
|
|
.type = _typ, \
|
2011-05-01 00:00:58 +02:00
|
|
|
.type2 = _typ2, \
|
2007-10-26 02:46:07 +02:00
|
|
|
.handler = &gen_##name, \
|
|
|
|
.oname = onam, \
|
|
|
|
}, \
|
|
|
|
.oname = onam, \
|
|
|
|
}
|
2007-03-07 09:32:30 +01:00
|
|
|
#else
|
2011-05-01 00:00:58 +02:00
|
|
|
#define GEN_OPCODE(name, op1, op2, op3, invl, _typ, _typ2) \
|
2009-06-17 17:22:31 +02:00
|
|
|
{ \
|
2007-10-26 02:46:07 +02:00
|
|
|
.opc1 = op1, \
|
|
|
|
.opc2 = op2, \
|
|
|
|
.opc3 = op3, \
|
|
|
|
.pad = { 0, }, \
|
|
|
|
.handler = { \
|
2011-09-28 07:54:05 +02:00
|
|
|
.inval1 = invl, \
|
|
|
|
.type = _typ, \
|
|
|
|
.type2 = _typ2, \
|
|
|
|
.handler = &gen_##name, \
|
|
|
|
}, \
|
|
|
|
.oname = stringify(name), \
|
|
|
|
}
|
|
|
|
#define GEN_OPCODE_DUAL(name, op1, op2, op3, invl1, invl2, _typ, _typ2) \
|
|
|
|
{ \
|
|
|
|
.opc1 = op1, \
|
|
|
|
.opc2 = op2, \
|
|
|
|
.opc3 = op3, \
|
|
|
|
.pad = { 0, }, \
|
|
|
|
.handler = { \
|
|
|
|
.inval1 = invl1, \
|
|
|
|
.inval2 = invl2, \
|
2007-10-26 02:46:07 +02:00
|
|
|
.type = _typ, \
|
2011-05-01 00:00:58 +02:00
|
|
|
.type2 = _typ2, \
|
2007-10-26 02:46:07 +02:00
|
|
|
.handler = &gen_##name, \
|
2009-06-17 17:22:31 +02:00
|
|
|
}, \
|
|
|
|
.oname = stringify(name), \
|
|
|
|
}
|
2011-05-01 00:00:58 +02:00
|
|
|
#define GEN_OPCODE2(name, onam, op1, op2, op3, invl, _typ, _typ2) \
|
2009-06-17 17:22:31 +02:00
|
|
|
{ \
|
|
|
|
.opc1 = op1, \
|
|
|
|
.opc2 = op2, \
|
|
|
|
.opc3 = op3, \
|
|
|
|
.pad = { 0, }, \
|
|
|
|
.handler = { \
|
2011-09-28 07:54:05 +02:00
|
|
|
.inval1 = invl, \
|
2009-06-17 17:22:31 +02:00
|
|
|
.type = _typ, \
|
2011-05-01 00:00:58 +02:00
|
|
|
.type2 = _typ2, \
|
2009-06-17 17:22:31 +02:00
|
|
|
.handler = &gen_##name, \
|
|
|
|
}, \
|
|
|
|
.oname = onam, \
|
|
|
|
}
|
|
|
|
#endif
|
2009-06-17 17:22:24 +02:00
|
|
|
|
2009-06-17 17:22:31 +02:00
|
|
|
/* SPR load/store helpers */
|
2009-08-16 11:06:54 +02:00
|
|
|
static inline void gen_load_spr(TCGv t, int reg)
|
2009-06-17 17:22:31 +02:00
|
|
|
{
|
2012-03-14 01:38:22 +01:00
|
|
|
tcg_gen_ld_tl(t, cpu_env, offsetof(CPUPPCState, spr[reg]));
|
2009-06-17 17:22:31 +02:00
|
|
|
}
|
2009-06-17 17:22:24 +02:00
|
|
|
|
2009-08-16 11:06:54 +02:00
|
|
|
static inline void gen_store_spr(int reg, TCGv t)
|
2009-06-17 17:22:31 +02:00
|
|
|
{
|
2012-03-14 01:38:22 +01:00
|
|
|
tcg_gen_st_tl(t, cpu_env, offsetof(CPUPPCState, spr[reg]));
|
2009-06-17 17:22:31 +02:00
|
|
|
}
|
2009-06-17 17:22:24 +02:00
|
|
|
|
2009-06-17 17:22:19 +02:00
|
|
|
/* Invalid instruction */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_invalid(DisasContext *ctx)
|
2004-01-04 23:58:38 +01:00
|
|
|
{
|
2008-12-11 23:42:14 +01:00
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_INVAL_INVAL);
|
2004-01-04 23:58:38 +01:00
|
|
|
}
|
|
|
|
|
2009-10-01 23:12:16 +02:00
|
|
|
static opc_handler_t invalid_handler = {
|
2011-09-28 07:54:05 +02:00
|
|
|
.inval1 = 0xFFFFFFFF,
|
|
|
|
.inval2 = 0xFFFFFFFF,
|
2004-01-04 23:58:38 +01:00
|
|
|
.type = PPC_NONE,
|
2011-05-01 00:00:58 +02:00
|
|
|
.type2 = PPC_NONE,
|
2003-11-23 15:55:54 +01:00
|
|
|
.handler = gen_invalid,
|
|
|
|
};
|
|
|
|
|
2008-10-21 13:31:14 +02:00
|
|
|
/*** Integer comparison ***/
|
|
|
|
|
2009-08-16 11:06:54 +02:00
|
|
|
static inline void gen_op_cmp(TCGv arg0, TCGv arg1, int s, int crf)
|
2008-10-21 13:31:14 +02:00
|
|
|
{
|
2013-02-20 08:52:14 +01:00
|
|
|
TCGv t0 = tcg_temp_new();
|
|
|
|
TCGv_i32 t1 = tcg_temp_new_i32();
|
2008-10-21 13:31:14 +02:00
|
|
|
|
2013-02-20 08:52:13 +01:00
|
|
|
tcg_gen_trunc_tl_i32(cpu_crf[crf], cpu_so);
|
2008-10-21 13:31:14 +02:00
|
|
|
|
2013-02-20 08:52:14 +01:00
|
|
|
tcg_gen_setcond_tl((s ? TCG_COND_LT: TCG_COND_LTU), t0, arg0, arg1);
|
|
|
|
tcg_gen_trunc_tl_i32(t1, t0);
|
|
|
|
tcg_gen_shli_i32(t1, t1, CRF_LT);
|
|
|
|
tcg_gen_or_i32(cpu_crf[crf], cpu_crf[crf], t1);
|
|
|
|
|
|
|
|
tcg_gen_setcond_tl((s ? TCG_COND_GT: TCG_COND_GTU), t0, arg0, arg1);
|
|
|
|
tcg_gen_trunc_tl_i32(t1, t0);
|
|
|
|
tcg_gen_shli_i32(t1, t1, CRF_GT);
|
|
|
|
tcg_gen_or_i32(cpu_crf[crf], cpu_crf[crf], t1);
|
|
|
|
|
|
|
|
tcg_gen_setcond_tl(TCG_COND_EQ, t0, arg0, arg1);
|
|
|
|
tcg_gen_trunc_tl_i32(t1, t0);
|
|
|
|
tcg_gen_shli_i32(t1, t1, CRF_EQ);
|
|
|
|
tcg_gen_or_i32(cpu_crf[crf], cpu_crf[crf], t1);
|
|
|
|
|
|
|
|
tcg_temp_free(t0);
|
|
|
|
tcg_temp_free_i32(t1);
|
2008-10-21 13:31:14 +02:00
|
|
|
}
|
|
|
|
|
2009-08-16 11:06:54 +02:00
|
|
|
static inline void gen_op_cmpi(TCGv arg0, target_ulong arg1, int s, int crf)
|
2008-10-21 13:31:14 +02:00
|
|
|
{
|
2013-02-20 08:52:14 +01:00
|
|
|
TCGv t0 = tcg_const_tl(arg1);
|
2008-10-27 23:50:39 +01:00
|
|
|
gen_op_cmp(arg0, t0, s, crf);
|
|
|
|
tcg_temp_free(t0);
|
2008-10-21 13:31:14 +02:00
|
|
|
}
|
|
|
|
|
2009-08-16 11:06:54 +02:00
|
|
|
static inline void gen_op_cmp32(TCGv arg0, TCGv arg1, int s, int crf)
|
2008-10-21 13:31:14 +02:00
|
|
|
{
|
2008-10-27 23:50:39 +01:00
|
|
|
TCGv t0, t1;
|
2013-02-20 08:52:14 +01:00
|
|
|
t0 = tcg_temp_new();
|
|
|
|
t1 = tcg_temp_new();
|
2008-10-21 13:31:14 +02:00
|
|
|
if (s) {
|
2008-10-27 23:50:39 +01:00
|
|
|
tcg_gen_ext32s_tl(t0, arg0);
|
|
|
|
tcg_gen_ext32s_tl(t1, arg1);
|
2008-10-21 13:31:14 +02:00
|
|
|
} else {
|
2008-10-27 23:50:39 +01:00
|
|
|
tcg_gen_ext32u_tl(t0, arg0);
|
|
|
|
tcg_gen_ext32u_tl(t1, arg1);
|
2008-10-21 13:31:14 +02:00
|
|
|
}
|
2008-10-27 23:50:39 +01:00
|
|
|
gen_op_cmp(t0, t1, s, crf);
|
|
|
|
tcg_temp_free(t1);
|
|
|
|
tcg_temp_free(t0);
|
2008-10-21 13:31:14 +02:00
|
|
|
}
|
|
|
|
|
2009-08-16 11:06:54 +02:00
|
|
|
static inline void gen_op_cmpi32(TCGv arg0, target_ulong arg1, int s, int crf)
|
2008-10-21 13:31:14 +02:00
|
|
|
{
|
2013-02-20 08:52:14 +01:00
|
|
|
TCGv t0 = tcg_const_tl(arg1);
|
2008-10-27 23:50:39 +01:00
|
|
|
gen_op_cmp32(arg0, t0, s, crf);
|
|
|
|
tcg_temp_free(t0);
|
2008-10-21 13:31:14 +02:00
|
|
|
}
|
|
|
|
|
2009-08-16 11:06:54 +02:00
|
|
|
static inline void gen_set_Rc0(DisasContext *ctx, TCGv reg)
|
2008-10-21 13:31:14 +02:00
|
|
|
{
|
2013-03-21 11:01:47 +01:00
|
|
|
if (NARROW_MODE(ctx)) {
|
2008-10-21 13:31:14 +02:00
|
|
|
gen_op_cmpi32(reg, 0, 1, 0);
|
2013-03-21 11:01:47 +01:00
|
|
|
} else {
|
2008-10-21 13:31:14 +02:00
|
|
|
gen_op_cmpi(reg, 0, 1, 0);
|
2013-03-21 11:01:47 +01:00
|
|
|
}
|
2008-10-21 13:31:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* cmp */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_cmp(DisasContext *ctx)
|
2008-10-21 13:31:14 +02:00
|
|
|
{
|
2013-05-08 15:19:14 +02:00
|
|
|
if ((ctx->opcode & 0x00200000) && (ctx->insns_flags & PPC_64B)) {
|
2008-10-21 13:31:14 +02:00
|
|
|
gen_op_cmp(cpu_gpr[rA(ctx->opcode)], cpu_gpr[rB(ctx->opcode)],
|
|
|
|
1, crfD(ctx->opcode));
|
2013-05-08 15:19:14 +02:00
|
|
|
} else {
|
|
|
|
gen_op_cmp32(cpu_gpr[rA(ctx->opcode)], cpu_gpr[rB(ctx->opcode)],
|
|
|
|
1, crfD(ctx->opcode));
|
2013-03-21 11:01:47 +01:00
|
|
|
}
|
2008-10-21 13:31:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* cmpi */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_cmpi(DisasContext *ctx)
|
2008-10-21 13:31:14 +02:00
|
|
|
{
|
2013-05-08 15:19:14 +02:00
|
|
|
if ((ctx->opcode & 0x00200000) && (ctx->insns_flags & PPC_64B)) {
|
2008-10-21 13:31:14 +02:00
|
|
|
gen_op_cmpi(cpu_gpr[rA(ctx->opcode)], SIMM(ctx->opcode),
|
|
|
|
1, crfD(ctx->opcode));
|
2013-05-08 15:19:14 +02:00
|
|
|
} else {
|
|
|
|
gen_op_cmpi32(cpu_gpr[rA(ctx->opcode)], SIMM(ctx->opcode),
|
|
|
|
1, crfD(ctx->opcode));
|
2013-03-21 11:01:47 +01:00
|
|
|
}
|
2008-10-21 13:31:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* cmpl */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_cmpl(DisasContext *ctx)
|
2008-10-21 13:31:14 +02:00
|
|
|
{
|
2013-05-08 15:19:14 +02:00
|
|
|
if ((ctx->opcode & 0x00200000) && (ctx->insns_flags & PPC_64B)) {
|
2008-10-21 13:31:14 +02:00
|
|
|
gen_op_cmp(cpu_gpr[rA(ctx->opcode)], cpu_gpr[rB(ctx->opcode)],
|
|
|
|
0, crfD(ctx->opcode));
|
2013-05-08 15:19:14 +02:00
|
|
|
} else {
|
|
|
|
gen_op_cmp32(cpu_gpr[rA(ctx->opcode)], cpu_gpr[rB(ctx->opcode)],
|
|
|
|
0, crfD(ctx->opcode));
|
2013-03-21 11:01:47 +01:00
|
|
|
}
|
2008-10-21 13:31:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* cmpli */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_cmpli(DisasContext *ctx)
|
2008-10-21 13:31:14 +02:00
|
|
|
{
|
2013-05-08 15:19:14 +02:00
|
|
|
if ((ctx->opcode & 0x00200000) && (ctx->insns_flags & PPC_64B)) {
|
2008-10-21 13:31:14 +02:00
|
|
|
gen_op_cmpi(cpu_gpr[rA(ctx->opcode)], UIMM(ctx->opcode),
|
|
|
|
0, crfD(ctx->opcode));
|
2013-05-08 15:19:14 +02:00
|
|
|
} else {
|
|
|
|
gen_op_cmpi32(cpu_gpr[rA(ctx->opcode)], UIMM(ctx->opcode),
|
|
|
|
0, crfD(ctx->opcode));
|
2013-03-21 11:01:47 +01:00
|
|
|
}
|
2008-10-21 13:31:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* isel (PowerPC 2.03 specification) */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_isel(DisasContext *ctx)
|
2008-10-21 13:31:14 +02:00
|
|
|
{
|
2015-02-13 21:51:55 +01:00
|
|
|
TCGLabel *l1, *l2;
|
2008-10-21 13:31:14 +02:00
|
|
|
uint32_t bi = rC(ctx->opcode);
|
|
|
|
uint32_t mask;
|
2008-11-17 15:43:54 +01:00
|
|
|
TCGv_i32 t0;
|
2008-10-21 13:31:14 +02:00
|
|
|
|
|
|
|
l1 = gen_new_label();
|
|
|
|
l2 = gen_new_label();
|
|
|
|
|
2014-08-28 19:15:09 +02:00
|
|
|
mask = 0x08 >> (bi & 0x03);
|
2008-11-17 15:43:54 +01:00
|
|
|
t0 = tcg_temp_new_i32();
|
2008-11-02 09:22:34 +01:00
|
|
|
tcg_gen_andi_i32(t0, cpu_crf[bi >> 2], mask);
|
|
|
|
tcg_gen_brcondi_i32(TCG_COND_EQ, t0, 0, l1);
|
2008-10-21 13:31:14 +02:00
|
|
|
if (rA(ctx->opcode) == 0)
|
|
|
|
tcg_gen_movi_tl(cpu_gpr[rD(ctx->opcode)], 0);
|
|
|
|
else
|
|
|
|
tcg_gen_mov_tl(cpu_gpr[rD(ctx->opcode)], cpu_gpr[rA(ctx->opcode)]);
|
|
|
|
tcg_gen_br(l2);
|
|
|
|
gen_set_label(l1);
|
|
|
|
tcg_gen_mov_tl(cpu_gpr[rD(ctx->opcode)], cpu_gpr[rB(ctx->opcode)]);
|
|
|
|
gen_set_label(l2);
|
2008-11-17 15:43:54 +01:00
|
|
|
tcg_temp_free_i32(t0);
|
2008-10-21 13:31:14 +02:00
|
|
|
}
|
|
|
|
|
2013-04-20 10:56:16 +02:00
|
|
|
/* cmpb: PowerPC 2.05 specification */
|
|
|
|
static void gen_cmpb(DisasContext *ctx)
|
|
|
|
{
|
|
|
|
gen_helper_cmpb(cpu_gpr[rA(ctx->opcode)], cpu_gpr[rS(ctx->opcode)],
|
|
|
|
cpu_gpr[rB(ctx->opcode)]);
|
|
|
|
}
|
|
|
|
|
2003-11-23 15:55:54 +01:00
|
|
|
/*** Integer arithmetic ***/
|
|
|
|
|
2009-08-16 11:06:54 +02:00
|
|
|
static inline void gen_op_arith_compute_ov(DisasContext *ctx, TCGv arg0,
|
|
|
|
TCGv arg1, TCGv arg2, int sub)
|
2008-11-01 01:54:12 +01:00
|
|
|
{
|
2013-02-20 08:52:15 +01:00
|
|
|
TCGv t0 = tcg_temp_new();
|
2003-11-23 15:55:54 +01:00
|
|
|
|
2013-03-31 16:33:16 +02:00
|
|
|
tcg_gen_xor_tl(cpu_ov, arg0, arg2);
|
2008-11-01 01:54:12 +01:00
|
|
|
tcg_gen_xor_tl(t0, arg1, arg2);
|
2013-02-20 08:52:15 +01:00
|
|
|
if (sub) {
|
|
|
|
tcg_gen_and_tl(cpu_ov, cpu_ov, t0);
|
|
|
|
} else {
|
|
|
|
tcg_gen_andc_tl(cpu_ov, cpu_ov, t0);
|
|
|
|
}
|
|
|
|
tcg_temp_free(t0);
|
2013-03-21 11:01:47 +01:00
|
|
|
if (NARROW_MODE(ctx)) {
|
2013-02-20 08:52:15 +01:00
|
|
|
tcg_gen_ext32s_tl(cpu_ov, cpu_ov);
|
|
|
|
}
|
|
|
|
tcg_gen_shri_tl(cpu_ov, cpu_ov, TARGET_LONG_BITS - 1);
|
|
|
|
tcg_gen_or_tl(cpu_so, cpu_so, cpu_ov);
|
2003-11-23 15:55:54 +01:00
|
|
|
}
|
|
|
|
|
2008-11-01 01:54:12 +01:00
|
|
|
/* Common add function */
|
2009-08-16 11:06:54 +02:00
|
|
|
static inline void gen_op_arith_add(DisasContext *ctx, TCGv ret, TCGv arg1,
|
2013-02-20 08:52:17 +01:00
|
|
|
TCGv arg2, bool add_ca, bool compute_ca,
|
|
|
|
bool compute_ov, bool compute_rc0)
|
2008-11-01 01:54:12 +01:00
|
|
|
{
|
2013-02-20 08:52:17 +01:00
|
|
|
TCGv t0 = ret;
|
2007-03-17 15:02:15 +01:00
|
|
|
|
2013-04-03 12:56:45 +02:00
|
|
|
if (compute_ca || compute_ov) {
|
2013-02-20 08:52:16 +01:00
|
|
|
t0 = tcg_temp_new();
|
2008-11-01 01:54:12 +01:00
|
|
|
}
|
2003-11-23 15:55:54 +01:00
|
|
|
|
2013-02-20 08:52:13 +01:00
|
|
|
if (compute_ca) {
|
2013-03-21 11:01:45 +01:00
|
|
|
if (NARROW_MODE(ctx)) {
|
2013-04-03 12:56:45 +02:00
|
|
|
/* Caution: a non-obvious corner case of the spec is that we
|
|
|
|
must produce the *entire* 64-bit addition, but produce the
|
|
|
|
carry into bit 32. */
|
2013-03-21 11:01:45 +01:00
|
|
|
TCGv t1 = tcg_temp_new();
|
2013-04-03 12:56:45 +02:00
|
|
|
tcg_gen_xor_tl(t1, arg1, arg2); /* add without carry */
|
|
|
|
tcg_gen_add_tl(t0, arg1, arg2);
|
2013-03-21 11:01:45 +01:00
|
|
|
if (add_ca) {
|
|
|
|
tcg_gen_add_tl(t0, t0, cpu_ca);
|
|
|
|
}
|
2013-04-03 12:56:45 +02:00
|
|
|
tcg_gen_xor_tl(cpu_ca, t0, t1); /* bits changed w/ carry */
|
|
|
|
tcg_temp_free(t1);
|
|
|
|
tcg_gen_shri_tl(cpu_ca, cpu_ca, 32); /* extract bit 32 */
|
|
|
|
tcg_gen_andi_tl(cpu_ca, cpu_ca, 1);
|
2013-02-20 08:52:17 +01:00
|
|
|
} else {
|
2013-03-21 11:01:45 +01:00
|
|
|
TCGv zero = tcg_const_tl(0);
|
|
|
|
if (add_ca) {
|
|
|
|
tcg_gen_add2_tl(t0, cpu_ca, arg1, zero, cpu_ca, zero);
|
|
|
|
tcg_gen_add2_tl(t0, cpu_ca, t0, cpu_ca, arg2, zero);
|
|
|
|
} else {
|
|
|
|
tcg_gen_add2_tl(t0, cpu_ca, arg1, zero, arg2, zero);
|
|
|
|
}
|
|
|
|
tcg_temp_free(zero);
|
2013-02-20 08:52:17 +01:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
tcg_gen_add_tl(t0, arg1, arg2);
|
|
|
|
if (add_ca) {
|
|
|
|
tcg_gen_add_tl(t0, t0, cpu_ca);
|
|
|
|
}
|
2013-02-20 08:52:13 +01:00
|
|
|
}
|
2003-11-23 15:55:54 +01:00
|
|
|
|
2008-11-01 01:54:12 +01:00
|
|
|
if (compute_ov) {
|
|
|
|
gen_op_arith_compute_ov(ctx, t0, arg1, arg2, 0);
|
|
|
|
}
|
2013-02-20 08:52:17 +01:00
|
|
|
if (unlikely(compute_rc0)) {
|
2008-11-01 01:54:12 +01:00
|
|
|
gen_set_Rc0(ctx, t0);
|
2013-02-20 08:52:17 +01:00
|
|
|
}
|
2008-11-01 01:54:12 +01:00
|
|
|
|
2008-11-17 15:43:54 +01:00
|
|
|
if (!TCGV_EQUAL(t0, ret)) {
|
2008-11-01 01:54:12 +01:00
|
|
|
tcg_gen_mov_tl(ret, t0);
|
|
|
|
tcg_temp_free(t0);
|
|
|
|
}
|
2008-09-05 16:19:43 +02:00
|
|
|
}
|
2008-11-01 01:54:12 +01:00
|
|
|
/* Add functions with two operands */
|
|
|
|
#define GEN_INT_ARITH_ADD(name, opc3, add_ca, compute_ca, compute_ov) \
|
2013-02-20 08:52:17 +01:00
|
|
|
static void glue(gen_, name)(DisasContext *ctx) \
|
2008-11-01 01:54:12 +01:00
|
|
|
{ \
|
|
|
|
gen_op_arith_add(ctx, cpu_gpr[rD(ctx->opcode)], \
|
|
|
|
cpu_gpr[rA(ctx->opcode)], cpu_gpr[rB(ctx->opcode)], \
|
2013-02-20 08:52:17 +01:00
|
|
|
add_ca, compute_ca, compute_ov, Rc(ctx->opcode)); \
|
2008-11-01 01:54:12 +01:00
|
|
|
}
|
|
|
|
/* Add functions with one operand and one immediate */
|
|
|
|
#define GEN_INT_ARITH_ADD_CONST(name, opc3, const_val, \
|
|
|
|
add_ca, compute_ca, compute_ov) \
|
2013-02-20 08:52:17 +01:00
|
|
|
static void glue(gen_, name)(DisasContext *ctx) \
|
2008-11-01 01:54:12 +01:00
|
|
|
{ \
|
2013-02-20 08:52:17 +01:00
|
|
|
TCGv t0 = tcg_const_tl(const_val); \
|
2008-11-01 01:54:12 +01:00
|
|
|
gen_op_arith_add(ctx, cpu_gpr[rD(ctx->opcode)], \
|
|
|
|
cpu_gpr[rA(ctx->opcode)], t0, \
|
2013-02-20 08:52:17 +01:00
|
|
|
add_ca, compute_ca, compute_ov, Rc(ctx->opcode)); \
|
2008-11-01 01:54:12 +01:00
|
|
|
tcg_temp_free(t0); \
|
|
|
|
}
|
|
|
|
|
|
|
|
/* add add. addo addo. */
|
|
|
|
GEN_INT_ARITH_ADD(add, 0x08, 0, 0, 0)
|
|
|
|
GEN_INT_ARITH_ADD(addo, 0x18, 0, 0, 1)
|
|
|
|
/* addc addc. addco addco. */
|
|
|
|
GEN_INT_ARITH_ADD(addc, 0x00, 0, 1, 0)
|
|
|
|
GEN_INT_ARITH_ADD(addco, 0x10, 0, 1, 1)
|
|
|
|
/* adde adde. addeo addeo. */
|
|
|
|
GEN_INT_ARITH_ADD(adde, 0x04, 1, 1, 0)
|
|
|
|
GEN_INT_ARITH_ADD(addeo, 0x14, 1, 1, 1)
|
|
|
|
/* addme addme. addmeo addmeo. */
|
|
|
|
GEN_INT_ARITH_ADD_CONST(addme, 0x07, -1LL, 1, 1, 0)
|
|
|
|
GEN_INT_ARITH_ADD_CONST(addmeo, 0x17, -1LL, 1, 1, 1)
|
|
|
|
/* addze addze. addzeo addzeo.*/
|
|
|
|
GEN_INT_ARITH_ADD_CONST(addze, 0x06, 0, 1, 1, 0)
|
|
|
|
GEN_INT_ARITH_ADD_CONST(addzeo, 0x16, 0, 1, 1, 1)
|
|
|
|
/* addi */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_addi(DisasContext *ctx)
|
2007-03-17 15:02:15 +01:00
|
|
|
{
|
2008-11-01 01:54:12 +01:00
|
|
|
target_long simm = SIMM(ctx->opcode);
|
|
|
|
|
|
|
|
if (rA(ctx->opcode) == 0) {
|
|
|
|
/* li case */
|
|
|
|
tcg_gen_movi_tl(cpu_gpr[rD(ctx->opcode)], simm);
|
|
|
|
} else {
|
2013-02-20 08:52:17 +01:00
|
|
|
tcg_gen_addi_tl(cpu_gpr[rD(ctx->opcode)],
|
|
|
|
cpu_gpr[rA(ctx->opcode)], simm);
|
2008-11-01 01:54:12 +01:00
|
|
|
}
|
2007-03-17 15:02:15 +01:00
|
|
|
}
|
2008-11-01 01:54:12 +01:00
|
|
|
/* addic addic.*/
|
2013-02-20 08:52:17 +01:00
|
|
|
static inline void gen_op_addic(DisasContext *ctx, bool compute_rc0)
|
2007-03-17 15:02:15 +01:00
|
|
|
{
|
2013-02-20 08:52:17 +01:00
|
|
|
TCGv c = tcg_const_tl(SIMM(ctx->opcode));
|
|
|
|
gen_op_arith_add(ctx, cpu_gpr[rD(ctx->opcode)], cpu_gpr[rA(ctx->opcode)],
|
|
|
|
c, 0, 1, 0, compute_rc0);
|
|
|
|
tcg_temp_free(c);
|
2007-03-17 15:02:15 +01:00
|
|
|
}
|
2009-06-17 17:22:09 +02:00
|
|
|
|
|
|
|
static void gen_addic(DisasContext *ctx)
|
2007-03-17 15:02:15 +01:00
|
|
|
{
|
2013-02-20 08:52:17 +01:00
|
|
|
gen_op_addic(ctx, 0);
|
2007-03-17 15:02:15 +01:00
|
|
|
}
|
2009-06-17 17:22:14 +02:00
|
|
|
|
|
|
|
static void gen_addic_(DisasContext *ctx)
|
2007-03-17 15:02:15 +01:00
|
|
|
{
|
2013-02-20 08:52:17 +01:00
|
|
|
gen_op_addic(ctx, 1);
|
2007-03-17 15:02:15 +01:00
|
|
|
}
|
2009-06-17 17:22:09 +02:00
|
|
|
|
2009-06-17 17:22:19 +02:00
|
|
|
/* addis */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_addis(DisasContext *ctx)
|
2007-03-17 15:02:15 +01:00
|
|
|
{
|
2008-11-01 01:54:12 +01:00
|
|
|
target_long simm = SIMM(ctx->opcode);
|
|
|
|
|
|
|
|
if (rA(ctx->opcode) == 0) {
|
|
|
|
/* lis case */
|
|
|
|
tcg_gen_movi_tl(cpu_gpr[rD(ctx->opcode)], simm << 16);
|
|
|
|
} else {
|
2013-02-20 08:52:17 +01:00
|
|
|
tcg_gen_addi_tl(cpu_gpr[rD(ctx->opcode)],
|
|
|
|
cpu_gpr[rA(ctx->opcode)], simm << 16);
|
2008-11-01 01:54:12 +01:00
|
|
|
}
|
2007-03-17 15:02:15 +01:00
|
|
|
}
|
2008-11-01 01:54:12 +01:00
|
|
|
|
2009-08-16 11:06:54 +02:00
|
|
|
static inline void gen_op_arith_divw(DisasContext *ctx, TCGv ret, TCGv arg1,
|
|
|
|
TCGv arg2, int sign, int compute_ov)
|
2007-03-17 15:02:15 +01:00
|
|
|
{
|
2015-02-13 21:51:55 +01:00
|
|
|
TCGLabel *l1 = gen_new_label();
|
|
|
|
TCGLabel *l2 = gen_new_label();
|
2008-11-17 15:43:54 +01:00
|
|
|
TCGv_i32 t0 = tcg_temp_local_new_i32();
|
|
|
|
TCGv_i32 t1 = tcg_temp_local_new_i32();
|
2008-11-01 01:54:12 +01:00
|
|
|
|
2008-11-09 18:27:19 +01:00
|
|
|
tcg_gen_trunc_tl_i32(t0, arg1);
|
|
|
|
tcg_gen_trunc_tl_i32(t1, arg2);
|
|
|
|
tcg_gen_brcondi_i32(TCG_COND_EQ, t1, 0, l1);
|
2008-11-01 01:54:12 +01:00
|
|
|
if (sign) {
|
2015-02-13 21:51:55 +01:00
|
|
|
TCGLabel *l3 = gen_new_label();
|
2008-11-09 18:27:19 +01:00
|
|
|
tcg_gen_brcondi_i32(TCG_COND_NE, t1, -1, l3);
|
|
|
|
tcg_gen_brcondi_i32(TCG_COND_EQ, t0, INT32_MIN, l1);
|
2008-11-01 01:54:12 +01:00
|
|
|
gen_set_label(l3);
|
2008-11-09 18:27:19 +01:00
|
|
|
tcg_gen_div_i32(t0, t0, t1);
|
2008-11-01 01:54:12 +01:00
|
|
|
} else {
|
2008-11-09 18:27:19 +01:00
|
|
|
tcg_gen_divu_i32(t0, t0, t1);
|
2008-11-01 01:54:12 +01:00
|
|
|
}
|
|
|
|
if (compute_ov) {
|
2013-02-20 08:52:13 +01:00
|
|
|
tcg_gen_movi_tl(cpu_ov, 0);
|
2008-11-01 01:54:12 +01:00
|
|
|
}
|
|
|
|
tcg_gen_br(l2);
|
|
|
|
gen_set_label(l1);
|
|
|
|
if (sign) {
|
2008-11-09 18:27:19 +01:00
|
|
|
tcg_gen_sari_i32(t0, t0, 31);
|
2008-11-01 01:54:12 +01:00
|
|
|
} else {
|
|
|
|
tcg_gen_movi_i32(t0, 0);
|
|
|
|
}
|
|
|
|
if (compute_ov) {
|
2013-02-20 08:52:13 +01:00
|
|
|
tcg_gen_movi_tl(cpu_ov, 1);
|
|
|
|
tcg_gen_movi_tl(cpu_so, 1);
|
2008-11-01 01:54:12 +01:00
|
|
|
}
|
|
|
|
gen_set_label(l2);
|
2008-11-09 18:27:19 +01:00
|
|
|
tcg_gen_extu_i32_tl(ret, t0);
|
2008-11-17 15:43:54 +01:00
|
|
|
tcg_temp_free_i32(t0);
|
|
|
|
tcg_temp_free_i32(t1);
|
2008-11-01 01:54:12 +01:00
|
|
|
if (unlikely(Rc(ctx->opcode) != 0))
|
|
|
|
gen_set_Rc0(ctx, ret);
|
2007-03-17 15:02:15 +01:00
|
|
|
}
|
2008-11-01 01:54:12 +01:00
|
|
|
/* Div functions */
|
|
|
|
#define GEN_INT_ARITH_DIVW(name, opc3, sign, compute_ov) \
|
2009-06-17 17:22:09 +02:00
|
|
|
static void glue(gen_, name)(DisasContext *ctx) \
|
2008-11-01 01:54:12 +01:00
|
|
|
{ \
|
|
|
|
gen_op_arith_divw(ctx, cpu_gpr[rD(ctx->opcode)], \
|
|
|
|
cpu_gpr[rA(ctx->opcode)], cpu_gpr[rB(ctx->opcode)], \
|
|
|
|
sign, compute_ov); \
|
|
|
|
}
|
|
|
|
/* divwu divwu. divwuo divwuo. */
|
|
|
|
GEN_INT_ARITH_DIVW(divwu, 0x0E, 0, 0);
|
|
|
|
GEN_INT_ARITH_DIVW(divwuo, 0x1E, 0, 1);
|
|
|
|
/* divw divw. divwo divwo. */
|
|
|
|
GEN_INT_ARITH_DIVW(divw, 0x0F, 1, 0);
|
|
|
|
GEN_INT_ARITH_DIVW(divwo, 0x1F, 1, 1);
|
2014-01-07 17:05:51 +01:00
|
|
|
|
|
|
|
/* div[wd]eu[o][.] */
|
|
|
|
#define GEN_DIVE(name, hlpr, compute_ov) \
|
|
|
|
static void gen_##name(DisasContext *ctx) \
|
|
|
|
{ \
|
|
|
|
TCGv_i32 t0 = tcg_const_i32(compute_ov); \
|
|
|
|
gen_helper_##hlpr(cpu_gpr[rD(ctx->opcode)], cpu_env, \
|
|
|
|
cpu_gpr[rA(ctx->opcode)], cpu_gpr[rB(ctx->opcode)], t0); \
|
|
|
|
tcg_temp_free_i32(t0); \
|
|
|
|
if (unlikely(Rc(ctx->opcode) != 0)) { \
|
|
|
|
gen_set_Rc0(ctx, cpu_gpr[rD(ctx->opcode)]); \
|
|
|
|
} \
|
|
|
|
}
|
|
|
|
|
2014-01-07 17:05:53 +01:00
|
|
|
GEN_DIVE(divweu, divweu, 0);
|
|
|
|
GEN_DIVE(divweuo, divweu, 1);
|
2014-01-07 17:05:54 +01:00
|
|
|
GEN_DIVE(divwe, divwe, 0);
|
|
|
|
GEN_DIVE(divweo, divwe, 1);
|
2014-01-07 17:05:53 +01:00
|
|
|
|
2007-03-17 15:02:15 +01:00
|
|
|
#if defined(TARGET_PPC64)
|
2009-08-16 11:06:54 +02:00
|
|
|
static inline void gen_op_arith_divd(DisasContext *ctx, TCGv ret, TCGv arg1,
|
|
|
|
TCGv arg2, int sign, int compute_ov)
|
2007-03-17 15:02:15 +01:00
|
|
|
{
|
2015-02-13 21:51:55 +01:00
|
|
|
TCGLabel *l1 = gen_new_label();
|
|
|
|
TCGLabel *l2 = gen_new_label();
|
2008-11-01 01:54:12 +01:00
|
|
|
|
|
|
|
tcg_gen_brcondi_i64(TCG_COND_EQ, arg2, 0, l1);
|
|
|
|
if (sign) {
|
2015-02-13 21:51:55 +01:00
|
|
|
TCGLabel *l3 = gen_new_label();
|
2008-11-01 01:54:12 +01:00
|
|
|
tcg_gen_brcondi_i64(TCG_COND_NE, arg2, -1, l3);
|
|
|
|
tcg_gen_brcondi_i64(TCG_COND_EQ, arg1, INT64_MIN, l1);
|
|
|
|
gen_set_label(l3);
|
|
|
|
tcg_gen_div_i64(ret, arg1, arg2);
|
|
|
|
} else {
|
|
|
|
tcg_gen_divu_i64(ret, arg1, arg2);
|
|
|
|
}
|
|
|
|
if (compute_ov) {
|
2013-02-20 08:52:13 +01:00
|
|
|
tcg_gen_movi_tl(cpu_ov, 0);
|
2008-11-01 01:54:12 +01:00
|
|
|
}
|
|
|
|
tcg_gen_br(l2);
|
|
|
|
gen_set_label(l1);
|
|
|
|
if (sign) {
|
|
|
|
tcg_gen_sari_i64(ret, arg1, 63);
|
|
|
|
} else {
|
|
|
|
tcg_gen_movi_i64(ret, 0);
|
|
|
|
}
|
|
|
|
if (compute_ov) {
|
2013-02-20 08:52:13 +01:00
|
|
|
tcg_gen_movi_tl(cpu_ov, 1);
|
|
|
|
tcg_gen_movi_tl(cpu_so, 1);
|
2008-11-01 01:54:12 +01:00
|
|
|
}
|
|
|
|
gen_set_label(l2);
|
|
|
|
if (unlikely(Rc(ctx->opcode) != 0))
|
|
|
|
gen_set_Rc0(ctx, ret);
|
2007-03-17 15:02:15 +01:00
|
|
|
}
|
2008-11-01 01:54:12 +01:00
|
|
|
#define GEN_INT_ARITH_DIVD(name, opc3, sign, compute_ov) \
|
2009-06-17 17:22:09 +02:00
|
|
|
static void glue(gen_, name)(DisasContext *ctx) \
|
2008-11-01 01:54:12 +01:00
|
|
|
{ \
|
2008-11-09 18:27:19 +01:00
|
|
|
gen_op_arith_divd(ctx, cpu_gpr[rD(ctx->opcode)], \
|
|
|
|
cpu_gpr[rA(ctx->opcode)], cpu_gpr[rB(ctx->opcode)], \
|
|
|
|
sign, compute_ov); \
|
2008-11-01 01:54:12 +01:00
|
|
|
}
|
|
|
|
/* divwu divwu. divwuo divwuo. */
|
|
|
|
GEN_INT_ARITH_DIVD(divdu, 0x0E, 0, 0);
|
|
|
|
GEN_INT_ARITH_DIVD(divduo, 0x1E, 0, 1);
|
|
|
|
/* divw divw. divwo divwo. */
|
|
|
|
GEN_INT_ARITH_DIVD(divd, 0x0F, 1, 0);
|
|
|
|
GEN_INT_ARITH_DIVD(divdo, 0x1F, 1, 1);
|
2014-01-07 17:05:51 +01:00
|
|
|
|
|
|
|
GEN_DIVE(divdeu, divdeu, 0);
|
|
|
|
GEN_DIVE(divdeuo, divdeu, 1);
|
2014-01-07 17:05:52 +01:00
|
|
|
GEN_DIVE(divde, divde, 0);
|
|
|
|
GEN_DIVE(divdeo, divde, 1);
|
2007-03-17 15:02:15 +01:00
|
|
|
#endif
|
2008-11-01 01:54:12 +01:00
|
|
|
|
|
|
|
/* mulhw mulhw. */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_mulhw(DisasContext *ctx)
|
2007-03-17 15:02:15 +01:00
|
|
|
{
|
2013-02-20 08:52:12 +01:00
|
|
|
TCGv_i32 t0 = tcg_temp_new_i32();
|
|
|
|
TCGv_i32 t1 = tcg_temp_new_i32();
|
2008-11-01 01:54:12 +01:00
|
|
|
|
2013-02-20 08:52:12 +01:00
|
|
|
tcg_gen_trunc_tl_i32(t0, cpu_gpr[rA(ctx->opcode)]);
|
|
|
|
tcg_gen_trunc_tl_i32(t1, cpu_gpr[rB(ctx->opcode)]);
|
|
|
|
tcg_gen_muls2_i32(t0, t1, t0, t1);
|
|
|
|
tcg_gen_extu_i32_tl(cpu_gpr[rD(ctx->opcode)], t1);
|
|
|
|
tcg_temp_free_i32(t0);
|
|
|
|
tcg_temp_free_i32(t1);
|
2008-11-01 01:54:12 +01:00
|
|
|
if (unlikely(Rc(ctx->opcode) != 0))
|
|
|
|
gen_set_Rc0(ctx, cpu_gpr[rD(ctx->opcode)]);
|
2007-03-17 15:02:15 +01:00
|
|
|
}
|
2009-06-17 17:22:09 +02:00
|
|
|
|
2009-06-17 17:22:19 +02:00
|
|
|
/* mulhwu mulhwu. */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_mulhwu(DisasContext *ctx)
|
2007-03-17 15:02:15 +01:00
|
|
|
{
|
2013-02-20 08:52:12 +01:00
|
|
|
TCGv_i32 t0 = tcg_temp_new_i32();
|
|
|
|
TCGv_i32 t1 = tcg_temp_new_i32();
|
2008-11-01 01:54:12 +01:00
|
|
|
|
2013-02-20 08:52:12 +01:00
|
|
|
tcg_gen_trunc_tl_i32(t0, cpu_gpr[rA(ctx->opcode)]);
|
|
|
|
tcg_gen_trunc_tl_i32(t1, cpu_gpr[rB(ctx->opcode)]);
|
|
|
|
tcg_gen_mulu2_i32(t0, t1, t0, t1);
|
|
|
|
tcg_gen_extu_i32_tl(cpu_gpr[rD(ctx->opcode)], t1);
|
|
|
|
tcg_temp_free_i32(t0);
|
|
|
|
tcg_temp_free_i32(t1);
|
2008-11-01 01:54:12 +01:00
|
|
|
if (unlikely(Rc(ctx->opcode) != 0))
|
|
|
|
gen_set_Rc0(ctx, cpu_gpr[rD(ctx->opcode)]);
|
2007-03-17 15:02:15 +01:00
|
|
|
}
|
2009-06-17 17:22:09 +02:00
|
|
|
|
2009-06-17 17:22:19 +02:00
|
|
|
/* mullw mullw. */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_mullw(DisasContext *ctx)
|
2007-03-17 15:02:15 +01:00
|
|
|
{
|
2014-08-12 15:45:06 +02:00
|
|
|
#if defined(TARGET_PPC64)
|
|
|
|
TCGv_i64 t0, t1;
|
|
|
|
t0 = tcg_temp_new_i64();
|
|
|
|
t1 = tcg_temp_new_i64();
|
|
|
|
tcg_gen_ext32s_tl(t0, cpu_gpr[rA(ctx->opcode)]);
|
|
|
|
tcg_gen_ext32s_tl(t1, cpu_gpr[rB(ctx->opcode)]);
|
|
|
|
tcg_gen_mul_i64(cpu_gpr[rD(ctx->opcode)], t0, t1);
|
|
|
|
tcg_temp_free(t0);
|
|
|
|
tcg_temp_free(t1);
|
|
|
|
#else
|
2014-08-25 21:25:42 +02:00
|
|
|
tcg_gen_mul_i32(cpu_gpr[rD(ctx->opcode)], cpu_gpr[rA(ctx->opcode)],
|
|
|
|
cpu_gpr[rB(ctx->opcode)]);
|
2014-08-12 15:45:06 +02:00
|
|
|
#endif
|
2008-11-01 01:54:12 +01:00
|
|
|
if (unlikely(Rc(ctx->opcode) != 0))
|
|
|
|
gen_set_Rc0(ctx, cpu_gpr[rD(ctx->opcode)]);
|
2007-03-17 15:02:15 +01:00
|
|
|
}
|
2009-06-17 17:22:09 +02:00
|
|
|
|
2009-06-17 17:22:19 +02:00
|
|
|
/* mullwo mullwo. */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_mullwo(DisasContext *ctx)
|
2007-03-17 15:02:15 +01:00
|
|
|
{
|
2013-02-20 08:52:20 +01:00
|
|
|
TCGv_i32 t0 = tcg_temp_new_i32();
|
|
|
|
TCGv_i32 t1 = tcg_temp_new_i32();
|
2008-11-01 01:54:12 +01:00
|
|
|
|
2013-02-20 08:52:20 +01:00
|
|
|
tcg_gen_trunc_tl_i32(t0, cpu_gpr[rA(ctx->opcode)]);
|
|
|
|
tcg_gen_trunc_tl_i32(t1, cpu_gpr[rB(ctx->opcode)]);
|
|
|
|
tcg_gen_muls2_i32(t0, t1, t0, t1);
|
2014-08-12 15:45:07 +02:00
|
|
|
#if defined(TARGET_PPC64)
|
2014-08-25 21:25:43 +02:00
|
|
|
tcg_gen_concat_i32_i64(cpu_gpr[rD(ctx->opcode)], t0, t1);
|
|
|
|
#else
|
|
|
|
tcg_gen_mov_i32(cpu_gpr[rD(ctx->opcode)], t0);
|
2014-08-12 15:45:07 +02:00
|
|
|
#endif
|
2013-02-20 08:52:20 +01:00
|
|
|
|
|
|
|
tcg_gen_sari_i32(t0, t0, 31);
|
|
|
|
tcg_gen_setcond_i32(TCG_COND_NE, t0, t0, t1);
|
|
|
|
tcg_gen_extu_i32_tl(cpu_ov, t0);
|
|
|
|
tcg_gen_or_tl(cpu_so, cpu_so, cpu_ov);
|
|
|
|
|
|
|
|
tcg_temp_free_i32(t0);
|
|
|
|
tcg_temp_free_i32(t1);
|
2008-11-01 01:54:12 +01:00
|
|
|
if (unlikely(Rc(ctx->opcode) != 0))
|
|
|
|
gen_set_Rc0(ctx, cpu_gpr[rD(ctx->opcode)]);
|
2007-03-17 15:02:15 +01:00
|
|
|
}
|
2009-06-17 17:22:09 +02:00
|
|
|
|
2009-06-17 17:22:19 +02:00
|
|
|
/* mulli */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_mulli(DisasContext *ctx)
|
2007-03-17 15:02:15 +01:00
|
|
|
{
|
2008-11-01 01:54:12 +01:00
|
|
|
tcg_gen_muli_tl(cpu_gpr[rD(ctx->opcode)], cpu_gpr[rA(ctx->opcode)],
|
|
|
|
SIMM(ctx->opcode));
|
2007-03-17 15:02:15 +01:00
|
|
|
}
|
2013-02-20 08:52:12 +01:00
|
|
|
|
2007-03-17 15:02:15 +01:00
|
|
|
#if defined(TARGET_PPC64)
|
2008-11-01 01:54:12 +01:00
|
|
|
/* mulhd mulhd. */
|
2013-02-20 08:52:12 +01:00
|
|
|
static void gen_mulhd(DisasContext *ctx)
|
|
|
|
{
|
|
|
|
TCGv lo = tcg_temp_new();
|
|
|
|
tcg_gen_muls2_tl(lo, cpu_gpr[rD(ctx->opcode)],
|
|
|
|
cpu_gpr[rA(ctx->opcode)], cpu_gpr[rB(ctx->opcode)]);
|
|
|
|
tcg_temp_free(lo);
|
|
|
|
if (unlikely(Rc(ctx->opcode) != 0)) {
|
|
|
|
gen_set_Rc0(ctx, cpu_gpr[rD(ctx->opcode)]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-11-01 01:54:12 +01:00
|
|
|
/* mulhdu mulhdu. */
|
2013-02-20 08:52:12 +01:00
|
|
|
static void gen_mulhdu(DisasContext *ctx)
|
|
|
|
{
|
|
|
|
TCGv lo = tcg_temp_new();
|
|
|
|
tcg_gen_mulu2_tl(lo, cpu_gpr[rD(ctx->opcode)],
|
|
|
|
cpu_gpr[rA(ctx->opcode)], cpu_gpr[rB(ctx->opcode)]);
|
|
|
|
tcg_temp_free(lo);
|
|
|
|
if (unlikely(Rc(ctx->opcode) != 0)) {
|
|
|
|
gen_set_Rc0(ctx, cpu_gpr[rD(ctx->opcode)]);
|
|
|
|
}
|
|
|
|
}
|
2009-06-17 17:22:09 +02:00
|
|
|
|
2009-06-17 17:22:19 +02:00
|
|
|
/* mulld mulld. */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_mulld(DisasContext *ctx)
|
2007-03-17 15:02:15 +01:00
|
|
|
{
|
2008-11-01 01:54:12 +01:00
|
|
|
tcg_gen_mul_tl(cpu_gpr[rD(ctx->opcode)], cpu_gpr[rA(ctx->opcode)],
|
|
|
|
cpu_gpr[rB(ctx->opcode)]);
|
|
|
|
if (unlikely(Rc(ctx->opcode) != 0))
|
|
|
|
gen_set_Rc0(ctx, cpu_gpr[rD(ctx->opcode)]);
|
2007-03-17 15:02:15 +01:00
|
|
|
}
|
2012-05-30 06:23:29 +02:00
|
|
|
|
2008-11-01 01:54:12 +01:00
|
|
|
/* mulldo mulldo. */
|
2012-05-30 06:23:29 +02:00
|
|
|
static void gen_mulldo(DisasContext *ctx)
|
|
|
|
{
|
2014-08-25 21:25:44 +02:00
|
|
|
TCGv_i64 t0 = tcg_temp_new_i64();
|
|
|
|
TCGv_i64 t1 = tcg_temp_new_i64();
|
|
|
|
|
|
|
|
tcg_gen_muls2_i64(t0, t1, cpu_gpr[rA(ctx->opcode)],
|
|
|
|
cpu_gpr[rB(ctx->opcode)]);
|
|
|
|
tcg_gen_mov_i64(cpu_gpr[rD(ctx->opcode)], t0);
|
|
|
|
|
|
|
|
tcg_gen_sari_i64(t0, t0, 63);
|
|
|
|
tcg_gen_setcond_i64(TCG_COND_NE, cpu_ov, t0, t1);
|
|
|
|
tcg_gen_or_tl(cpu_so, cpu_so, cpu_ov);
|
|
|
|
|
|
|
|
tcg_temp_free_i64(t0);
|
|
|
|
tcg_temp_free_i64(t1);
|
|
|
|
|
2012-05-30 06:23:29 +02:00
|
|
|
if (unlikely(Rc(ctx->opcode) != 0)) {
|
|
|
|
gen_set_Rc0(ctx, cpu_gpr[rD(ctx->opcode)]);
|
|
|
|
}
|
|
|
|
}
|
2007-03-17 15:02:15 +01:00
|
|
|
#endif
|
2008-11-01 01:54:12 +01:00
|
|
|
|
|
|
|
/* Common subf function */
|
2009-08-16 11:06:54 +02:00
|
|
|
static inline void gen_op_arith_subf(DisasContext *ctx, TCGv ret, TCGv arg1,
|
2013-02-20 08:52:17 +01:00
|
|
|
TCGv arg2, bool add_ca, bool compute_ca,
|
|
|
|
bool compute_ov, bool compute_rc0)
|
2003-11-23 15:55:54 +01:00
|
|
|
{
|
2013-02-20 08:52:17 +01:00
|
|
|
TCGv t0 = ret;
|
2003-11-23 15:55:54 +01:00
|
|
|
|
2013-04-03 12:56:45 +02:00
|
|
|
if (compute_ca || compute_ov) {
|
2013-02-20 08:52:17 +01:00
|
|
|
t0 = tcg_temp_new();
|
2013-02-20 08:52:13 +01:00
|
|
|
}
|
2008-11-01 01:54:12 +01:00
|
|
|
|
2013-03-21 11:01:45 +01:00
|
|
|
if (compute_ca) {
|
|
|
|
/* dest = ~arg1 + arg2 [+ ca]. */
|
|
|
|
if (NARROW_MODE(ctx)) {
|
2013-04-03 12:56:45 +02:00
|
|
|
/* Caution: a non-obvious corner case of the spec is that we
|
|
|
|
must produce the *entire* 64-bit addition, but produce the
|
|
|
|
carry into bit 32. */
|
2013-03-21 11:01:45 +01:00
|
|
|
TCGv inv1 = tcg_temp_new();
|
2013-04-03 12:56:45 +02:00
|
|
|
TCGv t1 = tcg_temp_new();
|
2013-03-21 11:01:45 +01:00
|
|
|
tcg_gen_not_tl(inv1, arg1);
|
|
|
|
if (add_ca) {
|
2013-04-03 12:56:45 +02:00
|
|
|
tcg_gen_add_tl(t0, arg2, cpu_ca);
|
2013-03-21 11:01:45 +01:00
|
|
|
} else {
|
2013-04-03 12:56:45 +02:00
|
|
|
tcg_gen_addi_tl(t0, arg2, 1);
|
2013-03-21 11:01:45 +01:00
|
|
|
}
|
2013-04-03 12:56:45 +02:00
|
|
|
tcg_gen_xor_tl(t1, arg2, inv1); /* add without carry */
|
2013-03-21 11:01:45 +01:00
|
|
|
tcg_gen_add_tl(t0, t0, inv1);
|
2014-01-19 17:26:33 +01:00
|
|
|
tcg_temp_free(inv1);
|
2013-04-03 12:56:45 +02:00
|
|
|
tcg_gen_xor_tl(cpu_ca, t0, t1); /* bits changes w/ carry */
|
|
|
|
tcg_temp_free(t1);
|
|
|
|
tcg_gen_shri_tl(cpu_ca, cpu_ca, 32); /* extract bit 32 */
|
|
|
|
tcg_gen_andi_tl(cpu_ca, cpu_ca, 1);
|
2013-03-21 11:01:45 +01:00
|
|
|
} else if (add_ca) {
|
2013-02-25 20:41:40 +01:00
|
|
|
TCGv zero, inv1 = tcg_temp_new();
|
|
|
|
tcg_gen_not_tl(inv1, arg1);
|
2013-02-20 08:52:17 +01:00
|
|
|
zero = tcg_const_tl(0);
|
|
|
|
tcg_gen_add2_tl(t0, cpu_ca, arg2, zero, cpu_ca, zero);
|
2013-02-25 20:41:40 +01:00
|
|
|
tcg_gen_add2_tl(t0, cpu_ca, t0, cpu_ca, inv1, zero);
|
2013-02-20 08:52:17 +01:00
|
|
|
tcg_temp_free(zero);
|
2013-02-25 20:41:40 +01:00
|
|
|
tcg_temp_free(inv1);
|
2013-02-20 08:52:17 +01:00
|
|
|
} else {
|
2013-03-21 11:01:45 +01:00
|
|
|
tcg_gen_setcond_tl(TCG_COND_GEU, cpu_ca, arg2, arg1);
|
2013-02-20 08:52:17 +01:00
|
|
|
tcg_gen_sub_tl(t0, arg2, arg1);
|
|
|
|
}
|
2013-03-21 11:01:45 +01:00
|
|
|
} else if (add_ca) {
|
|
|
|
/* Since we're ignoring carry-out, we can simplify the
|
|
|
|
standard ~arg1 + arg2 + ca to arg2 - arg1 + ca - 1. */
|
|
|
|
tcg_gen_sub_tl(t0, arg2, arg1);
|
|
|
|
tcg_gen_add_tl(t0, t0, cpu_ca);
|
|
|
|
tcg_gen_subi_tl(t0, t0, 1);
|
2003-11-23 15:55:54 +01:00
|
|
|
} else {
|
2013-02-20 08:52:17 +01:00
|
|
|
tcg_gen_sub_tl(t0, arg2, arg1);
|
2008-11-01 01:54:12 +01:00
|
|
|
}
|
2013-02-20 08:52:17 +01:00
|
|
|
|
2008-11-01 01:54:12 +01:00
|
|
|
if (compute_ov) {
|
|
|
|
gen_op_arith_compute_ov(ctx, t0, arg1, arg2, 1);
|
|
|
|
}
|
2013-02-20 08:52:17 +01:00
|
|
|
if (unlikely(compute_rc0)) {
|
2008-11-01 01:54:12 +01:00
|
|
|
gen_set_Rc0(ctx, t0);
|
2013-02-20 08:52:17 +01:00
|
|
|
}
|
2008-11-01 01:54:12 +01:00
|
|
|
|
2008-11-17 15:43:54 +01:00
|
|
|
if (!TCGV_EQUAL(t0, ret)) {
|
2008-11-01 01:54:12 +01:00
|
|
|
tcg_gen_mov_tl(ret, t0);
|
|
|
|
tcg_temp_free(t0);
|
2003-11-23 15:55:54 +01:00
|
|
|
}
|
|
|
|
}
|
2008-11-01 01:54:12 +01:00
|
|
|
/* Sub functions with Two operands functions */
|
|
|
|
#define GEN_INT_ARITH_SUBF(name, opc3, add_ca, compute_ca, compute_ov) \
|
2013-02-20 08:52:17 +01:00
|
|
|
static void glue(gen_, name)(DisasContext *ctx) \
|
2008-11-01 01:54:12 +01:00
|
|
|
{ \
|
|
|
|
gen_op_arith_subf(ctx, cpu_gpr[rD(ctx->opcode)], \
|
|
|
|
cpu_gpr[rA(ctx->opcode)], cpu_gpr[rB(ctx->opcode)], \
|
2013-02-20 08:52:17 +01:00
|
|
|
add_ca, compute_ca, compute_ov, Rc(ctx->opcode)); \
|
2008-11-01 01:54:12 +01:00
|
|
|
}
|
|
|
|
/* Sub functions with one operand and one immediate */
|
|
|
|
#define GEN_INT_ARITH_SUBF_CONST(name, opc3, const_val, \
|
|
|
|
add_ca, compute_ca, compute_ov) \
|
2013-02-20 08:52:17 +01:00
|
|
|
static void glue(gen_, name)(DisasContext *ctx) \
|
2008-11-01 01:54:12 +01:00
|
|
|
{ \
|
2013-02-20 08:52:17 +01:00
|
|
|
TCGv t0 = tcg_const_tl(const_val); \
|
2008-11-01 01:54:12 +01:00
|
|
|
gen_op_arith_subf(ctx, cpu_gpr[rD(ctx->opcode)], \
|
|
|
|
cpu_gpr[rA(ctx->opcode)], t0, \
|
2013-02-20 08:52:17 +01:00
|
|
|
add_ca, compute_ca, compute_ov, Rc(ctx->opcode)); \
|
2008-11-01 01:54:12 +01:00
|
|
|
tcg_temp_free(t0); \
|
|
|
|
}
|
|
|
|
/* subf subf. subfo subfo. */
|
|
|
|
GEN_INT_ARITH_SUBF(subf, 0x01, 0, 0, 0)
|
|
|
|
GEN_INT_ARITH_SUBF(subfo, 0x11, 0, 0, 1)
|
|
|
|
/* subfc subfc. subfco subfco. */
|
|
|
|
GEN_INT_ARITH_SUBF(subfc, 0x00, 0, 1, 0)
|
|
|
|
GEN_INT_ARITH_SUBF(subfco, 0x10, 0, 1, 1)
|
|
|
|
/* subfe subfe. subfeo subfo. */
|
|
|
|
GEN_INT_ARITH_SUBF(subfe, 0x04, 1, 1, 0)
|
|
|
|
GEN_INT_ARITH_SUBF(subfeo, 0x14, 1, 1, 1)
|
|
|
|
/* subfme subfme. subfmeo subfmeo. */
|
|
|
|
GEN_INT_ARITH_SUBF_CONST(subfme, 0x07, -1LL, 1, 1, 0)
|
|
|
|
GEN_INT_ARITH_SUBF_CONST(subfmeo, 0x17, -1LL, 1, 1, 1)
|
|
|
|
/* subfze subfze. subfzeo subfzeo.*/
|
|
|
|
GEN_INT_ARITH_SUBF_CONST(subfze, 0x06, 0, 1, 1, 0)
|
|
|
|
GEN_INT_ARITH_SUBF_CONST(subfzeo, 0x16, 0, 1, 1, 1)
|
2009-06-17 17:22:09 +02:00
|
|
|
|
2009-06-17 17:22:19 +02:00
|
|
|
/* subfic */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_subfic(DisasContext *ctx)
|
2003-11-23 15:55:54 +01:00
|
|
|
{
|
2013-02-20 08:52:17 +01:00
|
|
|
TCGv c = tcg_const_tl(SIMM(ctx->opcode));
|
|
|
|
gen_op_arith_subf(ctx, cpu_gpr[rD(ctx->opcode)], cpu_gpr[rA(ctx->opcode)],
|
|
|
|
c, 0, 1, 0, 0);
|
|
|
|
tcg_temp_free(c);
|
2003-11-23 15:55:54 +01:00
|
|
|
}
|
|
|
|
|
2013-02-20 08:52:18 +01:00
|
|
|
/* neg neg. nego nego. */
|
|
|
|
static inline void gen_op_arith_neg(DisasContext *ctx, bool compute_ov)
|
|
|
|
{
|
|
|
|
TCGv zero = tcg_const_tl(0);
|
|
|
|
gen_op_arith_subf(ctx, cpu_gpr[rD(ctx->opcode)], cpu_gpr[rA(ctx->opcode)],
|
|
|
|
zero, 0, 0, compute_ov, Rc(ctx->opcode));
|
|
|
|
tcg_temp_free(zero);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void gen_neg(DisasContext *ctx)
|
|
|
|
{
|
|
|
|
gen_op_arith_neg(ctx, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void gen_nego(DisasContext *ctx)
|
|
|
|
{
|
|
|
|
gen_op_arith_neg(ctx, 1);
|
|
|
|
}
|
|
|
|
|
2003-11-23 15:55:54 +01:00
|
|
|
/*** Integer logical ***/
|
2008-10-21 13:31:27 +02:00
|
|
|
#define GEN_LOGICAL2(name, tcg_op, opc, type) \
|
2009-06-17 17:22:09 +02:00
|
|
|
static void glue(gen_, name)(DisasContext *ctx) \
|
2003-11-23 15:55:54 +01:00
|
|
|
{ \
|
2008-10-21 13:31:27 +02:00
|
|
|
tcg_op(cpu_gpr[rA(ctx->opcode)], cpu_gpr[rS(ctx->opcode)], \
|
|
|
|
cpu_gpr[rB(ctx->opcode)]); \
|
2007-03-07 09:32:30 +01:00
|
|
|
if (unlikely(Rc(ctx->opcode) != 0)) \
|
2008-10-21 13:31:27 +02:00
|
|
|
gen_set_Rc0(ctx, cpu_gpr[rA(ctx->opcode)]); \
|
2003-11-23 15:55:54 +01:00
|
|
|
}
|
|
|
|
|
2008-10-21 13:31:27 +02:00
|
|
|
#define GEN_LOGICAL1(name, tcg_op, opc, type) \
|
2009-06-17 17:22:09 +02:00
|
|
|
static void glue(gen_, name)(DisasContext *ctx) \
|
2003-11-23 15:55:54 +01:00
|
|
|
{ \
|
2008-10-21 13:31:27 +02:00
|
|
|
tcg_op(cpu_gpr[rA(ctx->opcode)], cpu_gpr[rS(ctx->opcode)]); \
|
2007-03-07 09:32:30 +01:00
|
|
|
if (unlikely(Rc(ctx->opcode) != 0)) \
|
2008-10-21 13:31:27 +02:00
|
|
|
gen_set_Rc0(ctx, cpu_gpr[rA(ctx->opcode)]); \
|
2003-11-23 15:55:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* and & and. */
|
2008-10-21 13:31:27 +02:00
|
|
|
GEN_LOGICAL2(and, tcg_gen_and_tl, 0x00, PPC_INTEGER);
|
2003-11-23 15:55:54 +01:00
|
|
|
/* andc & andc. */
|
2008-10-21 13:31:27 +02:00
|
|
|
GEN_LOGICAL2(andc, tcg_gen_andc_tl, 0x01, PPC_INTEGER);
|
2009-06-17 17:22:14 +02:00
|
|
|
|
2009-06-17 17:22:19 +02:00
|
|
|
/* andi. */
|
2009-06-17 17:22:14 +02:00
|
|
|
static void gen_andi_(DisasContext *ctx)
|
2003-11-23 15:55:54 +01:00
|
|
|
{
|
2008-10-21 13:31:27 +02:00
|
|
|
tcg_gen_andi_tl(cpu_gpr[rA(ctx->opcode)], cpu_gpr[rS(ctx->opcode)], UIMM(ctx->opcode));
|
|
|
|
gen_set_Rc0(ctx, cpu_gpr[rA(ctx->opcode)]);
|
2003-11-23 15:55:54 +01:00
|
|
|
}
|
2009-06-17 17:22:14 +02:00
|
|
|
|
2009-06-17 17:22:19 +02:00
|
|
|
/* andis. */
|
2009-06-17 17:22:14 +02:00
|
|
|
static void gen_andis_(DisasContext *ctx)
|
2003-11-23 15:55:54 +01:00
|
|
|
{
|
2008-10-21 13:31:27 +02:00
|
|
|
tcg_gen_andi_tl(cpu_gpr[rA(ctx->opcode)], cpu_gpr[rS(ctx->opcode)], UIMM(ctx->opcode) << 16);
|
|
|
|
gen_set_Rc0(ctx, cpu_gpr[rA(ctx->opcode)]);
|
2003-11-23 15:55:54 +01:00
|
|
|
}
|
2009-06-17 17:22:09 +02:00
|
|
|
|
2009-06-17 17:22:19 +02:00
|
|
|
/* cntlzw */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_cntlzw(DisasContext *ctx)
|
2008-10-21 13:31:27 +02:00
|
|
|
{
|
2008-11-17 15:43:54 +01:00
|
|
|
gen_helper_cntlzw(cpu_gpr[rA(ctx->opcode)], cpu_gpr[rS(ctx->opcode)]);
|
2008-10-21 13:31:27 +02:00
|
|
|
if (unlikely(Rc(ctx->opcode) != 0))
|
2008-10-24 14:03:16 +02:00
|
|
|
gen_set_Rc0(ctx, cpu_gpr[rA(ctx->opcode)]);
|
2008-10-21 13:31:27 +02:00
|
|
|
}
|
2003-11-23 15:55:54 +01:00
|
|
|
/* eqv & eqv. */
|
2008-10-21 13:31:27 +02:00
|
|
|
GEN_LOGICAL2(eqv, tcg_gen_eqv_tl, 0x08, PPC_INTEGER);
|
2003-11-23 15:55:54 +01:00
|
|
|
/* extsb & extsb. */
|
2008-10-21 13:31:27 +02:00
|
|
|
GEN_LOGICAL1(extsb, tcg_gen_ext8s_tl, 0x1D, PPC_INTEGER);
|
2003-11-23 15:55:54 +01:00
|
|
|
/* extsh & extsh. */
|
2008-10-21 13:31:27 +02:00
|
|
|
GEN_LOGICAL1(extsh, tcg_gen_ext16s_tl, 0x1C, PPC_INTEGER);
|
2003-11-23 15:55:54 +01:00
|
|
|
/* nand & nand. */
|
2008-10-21 13:31:27 +02:00
|
|
|
GEN_LOGICAL2(nand, tcg_gen_nand_tl, 0x0E, PPC_INTEGER);
|
2003-11-23 15:55:54 +01:00
|
|
|
/* nor & nor. */
|
2008-10-21 13:31:27 +02:00
|
|
|
GEN_LOGICAL2(nor, tcg_gen_nor_tl, 0x03, PPC_INTEGER);
|
2009-06-17 17:22:09 +02:00
|
|
|
|
2009-06-17 17:22:19 +02:00
|
|
|
/* or & or. */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_or(DisasContext *ctx)
|
2004-01-04 23:58:38 +01:00
|
|
|
{
|
2007-03-07 09:32:30 +01:00
|
|
|
int rs, ra, rb;
|
|
|
|
|
|
|
|
rs = rS(ctx->opcode);
|
|
|
|
ra = rA(ctx->opcode);
|
|
|
|
rb = rB(ctx->opcode);
|
|
|
|
/* Optimisation for mr. ri case */
|
|
|
|
if (rs != ra || rs != rb) {
|
2008-10-21 13:31:27 +02:00
|
|
|
if (rs != rb)
|
|
|
|
tcg_gen_or_tl(cpu_gpr[ra], cpu_gpr[rs], cpu_gpr[rb]);
|
|
|
|
else
|
|
|
|
tcg_gen_mov_tl(cpu_gpr[ra], cpu_gpr[rs]);
|
2007-03-07 09:32:30 +01:00
|
|
|
if (unlikely(Rc(ctx->opcode) != 0))
|
2008-10-21 13:31:27 +02:00
|
|
|
gen_set_Rc0(ctx, cpu_gpr[ra]);
|
2007-03-07 09:32:30 +01:00
|
|
|
} else if (unlikely(Rc(ctx->opcode) != 0)) {
|
2008-10-21 13:31:27 +02:00
|
|
|
gen_set_Rc0(ctx, cpu_gpr[rs]);
|
2007-09-30 03:18:26 +02:00
|
|
|
#if defined(TARGET_PPC64)
|
|
|
|
} else {
|
2008-10-21 13:31:27 +02:00
|
|
|
int prio = 0;
|
|
|
|
|
2007-09-30 03:18:26 +02:00
|
|
|
switch (rs) {
|
|
|
|
case 1:
|
|
|
|
/* Set process priority to low */
|
2008-10-21 13:31:27 +02:00
|
|
|
prio = 2;
|
2007-09-30 03:18:26 +02:00
|
|
|
break;
|
|
|
|
case 6:
|
|
|
|
/* Set process priority to medium-low */
|
2008-10-21 13:31:27 +02:00
|
|
|
prio = 3;
|
2007-09-30 03:18:26 +02:00
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
/* Set process priority to normal */
|
2008-10-21 13:31:27 +02:00
|
|
|
prio = 4;
|
2007-09-30 03:18:26 +02:00
|
|
|
break;
|
2007-09-30 15:03:23 +02:00
|
|
|
#if !defined(CONFIG_USER_ONLY)
|
|
|
|
case 31:
|
2014-09-15 17:03:28 +02:00
|
|
|
if (!ctx->pr) {
|
2007-09-30 15:03:23 +02:00
|
|
|
/* Set process priority to very low */
|
2008-10-21 13:31:27 +02:00
|
|
|
prio = 1;
|
2007-09-30 15:03:23 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 5:
|
2014-09-15 17:03:28 +02:00
|
|
|
if (!ctx->pr) {
|
2007-09-30 15:03:23 +02:00
|
|
|
/* Set process priority to medium-hight */
|
2008-10-21 13:31:27 +02:00
|
|
|
prio = 5;
|
2007-09-30 15:03:23 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 3:
|
2014-09-15 17:03:28 +02:00
|
|
|
if (!ctx->pr) {
|
2007-09-30 15:03:23 +02:00
|
|
|
/* Set process priority to high */
|
2008-10-21 13:31:27 +02:00
|
|
|
prio = 6;
|
2007-09-30 15:03:23 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 7:
|
2014-09-15 17:03:28 +02:00
|
|
|
if (ctx->hv) {
|
2007-09-30 15:03:23 +02:00
|
|
|
/* Set process priority to very high */
|
2008-10-21 13:31:27 +02:00
|
|
|
prio = 7;
|
2007-09-30 15:03:23 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
#endif
|
2007-09-30 03:18:26 +02:00
|
|
|
default:
|
|
|
|
/* nop */
|
|
|
|
break;
|
|
|
|
}
|
2008-10-21 13:31:27 +02:00
|
|
|
if (prio) {
|
2008-11-17 15:43:54 +01:00
|
|
|
TCGv t0 = tcg_temp_new();
|
2008-12-05 08:21:31 +01:00
|
|
|
gen_load_spr(t0, SPR_PPR);
|
2008-10-27 23:50:39 +01:00
|
|
|
tcg_gen_andi_tl(t0, t0, ~0x001C000000000000ULL);
|
|
|
|
tcg_gen_ori_tl(t0, t0, ((uint64_t)prio) << 50);
|
2008-12-05 08:21:31 +01:00
|
|
|
gen_store_spr(SPR_PPR, t0);
|
2008-10-27 23:50:39 +01:00
|
|
|
tcg_temp_free(t0);
|
2008-10-21 13:31:27 +02:00
|
|
|
}
|
2007-09-30 03:18:26 +02:00
|
|
|
#endif
|
2004-01-04 23:58:38 +01:00
|
|
|
}
|
|
|
|
}
|
2003-11-23 15:55:54 +01:00
|
|
|
/* orc & orc. */
|
2008-10-21 13:31:27 +02:00
|
|
|
GEN_LOGICAL2(orc, tcg_gen_orc_tl, 0x0C, PPC_INTEGER);
|
2009-06-17 17:22:09 +02:00
|
|
|
|
2009-06-17 17:22:19 +02:00
|
|
|
/* xor & xor. */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_xor(DisasContext *ctx)
|
2004-01-04 23:58:38 +01:00
|
|
|
{
|
|
|
|
/* Optimisation for "set to zero" case */
|
2008-10-21 13:31:27 +02:00
|
|
|
if (rS(ctx->opcode) != rB(ctx->opcode))
|
2008-10-27 23:50:31 +01:00
|
|
|
tcg_gen_xor_tl(cpu_gpr[rA(ctx->opcode)], cpu_gpr[rS(ctx->opcode)], cpu_gpr[rB(ctx->opcode)]);
|
2008-10-21 13:31:27 +02:00
|
|
|
else
|
|
|
|
tcg_gen_movi_tl(cpu_gpr[rA(ctx->opcode)], 0);
|
2007-03-07 09:32:30 +01:00
|
|
|
if (unlikely(Rc(ctx->opcode) != 0))
|
2008-10-21 13:31:27 +02:00
|
|
|
gen_set_Rc0(ctx, cpu_gpr[rA(ctx->opcode)]);
|
2004-01-04 23:58:38 +01:00
|
|
|
}
|
2009-06-17 17:22:09 +02:00
|
|
|
|
2009-06-17 17:22:19 +02:00
|
|
|
/* ori */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_ori(DisasContext *ctx)
|
2003-11-23 15:55:54 +01:00
|
|
|
{
|
2007-03-07 09:32:30 +01:00
|
|
|
target_ulong uimm = UIMM(ctx->opcode);
|
2003-11-23 15:55:54 +01:00
|
|
|
|
2004-01-04 23:58:38 +01:00
|
|
|
if (rS(ctx->opcode) == rA(ctx->opcode) && uimm == 0) {
|
|
|
|
/* NOP */
|
2007-03-07 09:32:30 +01:00
|
|
|
/* XXX: should handle special NOPs for POWER series */
|
2004-01-04 23:58:38 +01:00
|
|
|
return;
|
2007-03-07 09:32:30 +01:00
|
|
|
}
|
2008-10-21 13:31:27 +02:00
|
|
|
tcg_gen_ori_tl(cpu_gpr[rA(ctx->opcode)], cpu_gpr[rS(ctx->opcode)], uimm);
|
2003-11-23 15:55:54 +01:00
|
|
|
}
|
2009-06-17 17:22:09 +02:00
|
|
|
|
2009-06-17 17:22:19 +02:00
|
|
|
/* oris */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_oris(DisasContext *ctx)
|
2003-11-23 15:55:54 +01:00
|
|
|
{
|
2007-03-07 09:32:30 +01:00
|
|
|
target_ulong uimm = UIMM(ctx->opcode);
|
2003-11-23 15:55:54 +01:00
|
|
|
|
2004-01-04 23:58:38 +01:00
|
|
|
if (rS(ctx->opcode) == rA(ctx->opcode) && uimm == 0) {
|
|
|
|
/* NOP */
|
|
|
|
return;
|
2007-03-07 09:32:30 +01:00
|
|
|
}
|
2008-10-21 13:31:27 +02:00
|
|
|
tcg_gen_ori_tl(cpu_gpr[rA(ctx->opcode)], cpu_gpr[rS(ctx->opcode)], uimm << 16);
|
2003-11-23 15:55:54 +01:00
|
|
|
}
|
2009-06-17 17:22:09 +02:00
|
|
|
|
2009-06-17 17:22:19 +02:00
|
|
|
/* xori */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_xori(DisasContext *ctx)
|
2003-11-23 15:55:54 +01:00
|
|
|
{
|
2007-03-07 09:32:30 +01:00
|
|
|
target_ulong uimm = UIMM(ctx->opcode);
|
2004-01-04 23:58:38 +01:00
|
|
|
|
|
|
|
if (rS(ctx->opcode) == rA(ctx->opcode) && uimm == 0) {
|
|
|
|
/* NOP */
|
|
|
|
return;
|
|
|
|
}
|
2008-10-21 13:31:27 +02:00
|
|
|
tcg_gen_xori_tl(cpu_gpr[rA(ctx->opcode)], cpu_gpr[rS(ctx->opcode)], uimm);
|
2003-11-23 15:55:54 +01:00
|
|
|
}
|
2009-06-17 17:22:09 +02:00
|
|
|
|
2009-06-17 17:22:19 +02:00
|
|
|
/* xoris */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_xoris(DisasContext *ctx)
|
2003-11-23 15:55:54 +01:00
|
|
|
{
|
2007-03-07 09:32:30 +01:00
|
|
|
target_ulong uimm = UIMM(ctx->opcode);
|
2004-01-04 23:58:38 +01:00
|
|
|
|
|
|
|
if (rS(ctx->opcode) == rA(ctx->opcode) && uimm == 0) {
|
|
|
|
/* NOP */
|
|
|
|
return;
|
|
|
|
}
|
2008-10-21 13:31:27 +02:00
|
|
|
tcg_gen_xori_tl(cpu_gpr[rA(ctx->opcode)], cpu_gpr[rS(ctx->opcode)], uimm << 16);
|
2003-11-23 15:55:54 +01:00
|
|
|
}
|
2009-06-17 17:22:09 +02:00
|
|
|
|
2009-06-17 17:22:19 +02:00
|
|
|
/* popcntb : PowerPC 2.03 specification */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_popcntb(DisasContext *ctx)
|
2007-03-17 15:02:15 +01:00
|
|
|
{
|
2011-04-01 06:15:13 +02:00
|
|
|
gen_helper_popcntb(cpu_gpr[rA(ctx->opcode)], cpu_gpr[rS(ctx->opcode)]);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void gen_popcntw(DisasContext *ctx)
|
|
|
|
{
|
|
|
|
gen_helper_popcntw(cpu_gpr[rA(ctx->opcode)], cpu_gpr[rS(ctx->opcode)]);
|
|
|
|
}
|
|
|
|
|
2007-03-17 15:02:15 +01:00
|
|
|
#if defined(TARGET_PPC64)
|
2011-04-01 06:15:13 +02:00
|
|
|
/* popcntd: PowerPC 2.06 specification */
|
|
|
|
static void gen_popcntd(DisasContext *ctx)
|
|
|
|
{
|
|
|
|
gen_helper_popcntd(cpu_gpr[rA(ctx->opcode)], cpu_gpr[rS(ctx->opcode)]);
|
2007-03-17 15:02:15 +01:00
|
|
|
}
|
2011-04-01 06:15:13 +02:00
|
|
|
#endif
|
2007-03-17 15:02:15 +01:00
|
|
|
|
2013-04-20 10:56:17 +02:00
|
|
|
/* prtyw: PowerPC 2.05 specification */
|
|
|
|
static void gen_prtyw(DisasContext *ctx)
|
|
|
|
{
|
|
|
|
TCGv ra = cpu_gpr[rA(ctx->opcode)];
|
|
|
|
TCGv rs = cpu_gpr[rS(ctx->opcode)];
|
|
|
|
TCGv t0 = tcg_temp_new();
|
|
|
|
tcg_gen_shri_tl(t0, rs, 16);
|
|
|
|
tcg_gen_xor_tl(ra, rs, t0);
|
|
|
|
tcg_gen_shri_tl(t0, ra, 8);
|
|
|
|
tcg_gen_xor_tl(ra, ra, t0);
|
|
|
|
tcg_gen_andi_tl(ra, ra, (target_ulong)0x100000001ULL);
|
|
|
|
tcg_temp_free(t0);
|
|
|
|
}
|
|
|
|
|
|
|
|
#if defined(TARGET_PPC64)
|
|
|
|
/* prtyd: PowerPC 2.05 specification */
|
|
|
|
static void gen_prtyd(DisasContext *ctx)
|
|
|
|
{
|
|
|
|
TCGv ra = cpu_gpr[rA(ctx->opcode)];
|
|
|
|
TCGv rs = cpu_gpr[rS(ctx->opcode)];
|
|
|
|
TCGv t0 = tcg_temp_new();
|
|
|
|
tcg_gen_shri_tl(t0, rs, 32);
|
|
|
|
tcg_gen_xor_tl(ra, rs, t0);
|
|
|
|
tcg_gen_shri_tl(t0, ra, 16);
|
|
|
|
tcg_gen_xor_tl(ra, ra, t0);
|
|
|
|
tcg_gen_shri_tl(t0, ra, 8);
|
|
|
|
tcg_gen_xor_tl(ra, ra, t0);
|
|
|
|
tcg_gen_andi_tl(ra, ra, 1);
|
|
|
|
tcg_temp_free(t0);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2014-01-07 17:05:49 +01:00
|
|
|
#if defined(TARGET_PPC64)
|
|
|
|
/* bpermd */
|
|
|
|
static void gen_bpermd(DisasContext *ctx)
|
|
|
|
{
|
|
|
|
gen_helper_bpermd(cpu_gpr[rA(ctx->opcode)],
|
|
|
|
cpu_gpr[rS(ctx->opcode)], cpu_gpr[rB(ctx->opcode)]);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2007-03-17 15:02:15 +01:00
|
|
|
#if defined(TARGET_PPC64)
|
|
|
|
/* extsw & extsw. */
|
2008-10-21 13:31:27 +02:00
|
|
|
GEN_LOGICAL1(extsw, tcg_gen_ext32s_tl, 0x1E, PPC_64B);
|
2009-06-17 17:22:09 +02:00
|
|
|
|
2009-06-17 17:22:19 +02:00
|
|
|
/* cntlzd */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_cntlzd(DisasContext *ctx)
|
2008-10-21 13:31:27 +02:00
|
|
|
{
|
2008-11-17 15:43:54 +01:00
|
|
|
gen_helper_cntlzd(cpu_gpr[rA(ctx->opcode)], cpu_gpr[rS(ctx->opcode)]);
|
2008-10-21 13:31:27 +02:00
|
|
|
if (unlikely(Rc(ctx->opcode) != 0))
|
|
|
|
gen_set_Rc0(ctx, cpu_gpr[rA(ctx->opcode)]);
|
|
|
|
}
|
2007-03-17 15:02:15 +01:00
|
|
|
#endif
|
|
|
|
|
2003-11-23 15:55:54 +01:00
|
|
|
/*** Integer rotate ***/
|
2009-06-17 17:22:09 +02:00
|
|
|
|
2009-06-17 17:22:19 +02:00
|
|
|
/* rlwimi & rlwimi. */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_rlwimi(DisasContext *ctx)
|
2003-11-23 15:55:54 +01:00
|
|
|
{
|
2007-03-07 09:32:30 +01:00
|
|
|
uint32_t mb, me, sh;
|
2003-11-23 15:55:54 +01:00
|
|
|
|
|
|
|
mb = MB(ctx->opcode);
|
|
|
|
me = ME(ctx->opcode);
|
2007-03-07 09:32:30 +01:00
|
|
|
sh = SH(ctx->opcode);
|
2014-08-25 21:25:39 +02:00
|
|
|
if (likely(sh == (31-me) && mb <= me)) {
|
|
|
|
tcg_gen_deposit_tl(cpu_gpr[rA(ctx->opcode)], cpu_gpr[rA(ctx->opcode)],
|
|
|
|
cpu_gpr[rS(ctx->opcode)], sh, me - mb + 1);
|
2008-10-27 23:50:22 +01:00
|
|
|
} else {
|
|
|
|
target_ulong mask;
|
2008-11-17 15:43:54 +01:00
|
|
|
TCGv t1;
|
|
|
|
TCGv t0 = tcg_temp_new();
|
2008-11-03 08:08:44 +01:00
|
|
|
#if defined(TARGET_PPC64)
|
target-ppc: Bug Fix: rlwimi
The rlwimi specification includes the ROTL32 operation, which is defined
to be a left rotation of two copies of the least significant 32 bits of
the source GPR.
The current implementation is incorrect on 64-bit implementations in that
it rotates a single copy of the least significant 32 bits, padding with
zeroes in the most significant bits.
Fix the code to properly implement this ROTL32 operation.
Also fix the special case of MB=31 and ME=0 to copy the entire contents
of the source GPR.
Examples:
R3 FFFFFFFFFFFFFFF0
rlwimi 3,3,29,14,1
R3 expected : 1FFFFFFE3FFFFFFE
R3 actual : 000000003FFFFFFE (without this patch)
R3 ED7EB4DD824F0853
rlwimi 3,3,10,31,0
R3 expected : 3C214E09024F0853
R3 actual : 00000000024F0853 (without this patch)
Signed-off-by: Tom Musta <tommusta@gmail.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
2014-08-12 15:45:05 +02:00
|
|
|
tcg_gen_deposit_i64(t0, cpu_gpr[rS(ctx->opcode)],
|
|
|
|
cpu_gpr[rS(ctx->opcode)], 32, 32);
|
|
|
|
tcg_gen_rotli_i64(t0, t0, sh);
|
2008-11-03 08:08:44 +01:00
|
|
|
#else
|
|
|
|
tcg_gen_rotli_i32(t0, cpu_gpr[rS(ctx->opcode)], sh);
|
|
|
|
#endif
|
2007-03-07 09:32:30 +01:00
|
|
|
#if defined(TARGET_PPC64)
|
2008-10-27 23:50:22 +01:00
|
|
|
mb += 32;
|
|
|
|
me += 32;
|
2007-03-07 09:32:30 +01:00
|
|
|
#endif
|
2008-10-27 23:50:22 +01:00
|
|
|
mask = MASK(mb, me);
|
2008-11-17 15:43:54 +01:00
|
|
|
t1 = tcg_temp_new();
|
2008-10-27 23:50:22 +01:00
|
|
|
tcg_gen_andi_tl(t0, t0, mask);
|
|
|
|
tcg_gen_andi_tl(t1, cpu_gpr[rA(ctx->opcode)], ~mask);
|
|
|
|
tcg_gen_or_tl(cpu_gpr[rA(ctx->opcode)], t0, t1);
|
|
|
|
tcg_temp_free(t0);
|
|
|
|
tcg_temp_free(t1);
|
|
|
|
}
|
2007-03-07 09:32:30 +01:00
|
|
|
if (unlikely(Rc(ctx->opcode) != 0))
|
2008-10-27 23:50:22 +01:00
|
|
|
gen_set_Rc0(ctx, cpu_gpr[rA(ctx->opcode)]);
|
2003-11-23 15:55:54 +01:00
|
|
|
}
|
2009-06-17 17:22:09 +02:00
|
|
|
|
2009-06-17 17:22:19 +02:00
|
|
|
/* rlwinm & rlwinm. */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_rlwinm(DisasContext *ctx)
|
2003-11-23 15:55:54 +01:00
|
|
|
{
|
|
|
|
uint32_t mb, me, sh;
|
2007-09-17 10:09:54 +02:00
|
|
|
|
2003-11-23 15:55:54 +01:00
|
|
|
sh = SH(ctx->opcode);
|
|
|
|
mb = MB(ctx->opcode);
|
|
|
|
me = ME(ctx->opcode);
|
2008-10-27 23:50:22 +01:00
|
|
|
|
|
|
|
if (likely(mb == 0 && me == (31 - sh))) {
|
|
|
|
if (likely(sh == 0)) {
|
|
|
|
tcg_gen_ext32u_tl(cpu_gpr[rA(ctx->opcode)], cpu_gpr[rS(ctx->opcode)]);
|
|
|
|
} else {
|
2008-11-17 15:43:54 +01:00
|
|
|
TCGv t0 = tcg_temp_new();
|
2008-10-27 23:50:22 +01:00
|
|
|
tcg_gen_ext32u_tl(t0, cpu_gpr[rS(ctx->opcode)]);
|
|
|
|
tcg_gen_shli_tl(t0, t0, sh);
|
|
|
|
tcg_gen_ext32u_tl(cpu_gpr[rA(ctx->opcode)], t0);
|
|
|
|
tcg_temp_free(t0);
|
2003-11-23 15:55:54 +01:00
|
|
|
}
|
2008-10-27 23:50:22 +01:00
|
|
|
} else if (likely(sh != 0 && me == 31 && sh == (32 - mb))) {
|
2008-11-17 15:43:54 +01:00
|
|
|
TCGv t0 = tcg_temp_new();
|
2008-10-27 23:50:22 +01:00
|
|
|
tcg_gen_ext32u_tl(t0, cpu_gpr[rS(ctx->opcode)]);
|
|
|
|
tcg_gen_shri_tl(t0, t0, mb);
|
|
|
|
tcg_gen_ext32u_tl(cpu_gpr[rA(ctx->opcode)], t0);
|
|
|
|
tcg_temp_free(t0);
|
2014-08-25 21:25:40 +02:00
|
|
|
} else if (likely(mb == 0 && me == 31)) {
|
|
|
|
TCGv_i32 t0 = tcg_temp_new_i32();
|
|
|
|
tcg_gen_trunc_tl_i32(t0, cpu_gpr[rS(ctx->opcode)]);
|
|
|
|
tcg_gen_rotli_i32(t0, t0, sh);
|
|
|
|
tcg_gen_extu_i32_tl(cpu_gpr[rA(ctx->opcode)], t0);
|
|
|
|
tcg_temp_free_i32(t0);
|
2008-10-27 23:50:22 +01:00
|
|
|
} else {
|
2008-11-17 15:43:54 +01:00
|
|
|
TCGv t0 = tcg_temp_new();
|
2008-11-03 08:08:44 +01:00
|
|
|
#if defined(TARGET_PPC64)
|
2014-08-12 15:45:03 +02:00
|
|
|
tcg_gen_deposit_i64(t0, cpu_gpr[rS(ctx->opcode)],
|
|
|
|
cpu_gpr[rS(ctx->opcode)], 32, 32);
|
|
|
|
tcg_gen_rotli_i64(t0, t0, sh);
|
2008-11-03 08:08:44 +01:00
|
|
|
#else
|
|
|
|
tcg_gen_rotli_i32(t0, cpu_gpr[rS(ctx->opcode)], sh);
|
|
|
|
#endif
|
2007-03-07 09:32:30 +01:00
|
|
|
#if defined(TARGET_PPC64)
|
2008-10-27 23:50:22 +01:00
|
|
|
mb += 32;
|
|
|
|
me += 32;
|
2007-03-07 09:32:30 +01:00
|
|
|
#endif
|
2008-10-27 23:50:22 +01:00
|
|
|
tcg_gen_andi_tl(cpu_gpr[rA(ctx->opcode)], t0, MASK(mb, me));
|
|
|
|
tcg_temp_free(t0);
|
|
|
|
}
|
2007-03-07 09:32:30 +01:00
|
|
|
if (unlikely(Rc(ctx->opcode) != 0))
|
2008-10-27 23:50:22 +01:00
|
|
|
gen_set_Rc0(ctx, cpu_gpr[rA(ctx->opcode)]);
|
2003-11-23 15:55:54 +01:00
|
|
|
}
|
2009-06-17 17:22:09 +02:00
|
|
|
|
2009-06-17 17:22:19 +02:00
|
|
|
/* rlwnm & rlwnm. */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_rlwnm(DisasContext *ctx)
|
2003-11-23 15:55:54 +01:00
|
|
|
{
|
|
|
|
uint32_t mb, me;
|
|
|
|
mb = MB(ctx->opcode);
|
|
|
|
me = ME(ctx->opcode);
|
2014-08-25 21:25:41 +02:00
|
|
|
|
|
|
|
if (likely(mb == 0 && me == 31)) {
|
|
|
|
TCGv_i32 t0, t1;
|
|
|
|
t0 = tcg_temp_new_i32();
|
|
|
|
t1 = tcg_temp_new_i32();
|
|
|
|
tcg_gen_trunc_tl_i32(t0, cpu_gpr[rB(ctx->opcode)]);
|
|
|
|
tcg_gen_trunc_tl_i32(t1, cpu_gpr[rS(ctx->opcode)]);
|
|
|
|
tcg_gen_andi_i32(t0, t0, 0x1f);
|
|
|
|
tcg_gen_rotl_i32(t1, t1, t0);
|
|
|
|
tcg_gen_extu_i32_tl(cpu_gpr[rA(ctx->opcode)], t1);
|
|
|
|
tcg_temp_free_i32(t0);
|
|
|
|
tcg_temp_free_i32(t1);
|
|
|
|
} else {
|
|
|
|
TCGv t0;
|
2008-11-03 08:08:44 +01:00
|
|
|
#if defined(TARGET_PPC64)
|
2014-08-25 21:25:41 +02:00
|
|
|
TCGv t1;
|
2008-11-03 08:08:44 +01:00
|
|
|
#endif
|
2014-08-25 21:25:41 +02:00
|
|
|
|
|
|
|
t0 = tcg_temp_new();
|
|
|
|
tcg_gen_andi_tl(t0, cpu_gpr[rB(ctx->opcode)], 0x1f);
|
2007-03-07 09:32:30 +01:00
|
|
|
#if defined(TARGET_PPC64)
|
2014-08-25 21:25:41 +02:00
|
|
|
t1 = tcg_temp_new_i64();
|
|
|
|
tcg_gen_deposit_i64(t1, cpu_gpr[rS(ctx->opcode)],
|
|
|
|
cpu_gpr[rS(ctx->opcode)], 32, 32);
|
|
|
|
tcg_gen_rotl_i64(t0, t1, t0);
|
|
|
|
tcg_temp_free_i64(t1);
|
|
|
|
#else
|
|
|
|
tcg_gen_rotl_i32(t0, cpu_gpr[rS(ctx->opcode)], t0);
|
2007-03-07 09:32:30 +01:00
|
|
|
#endif
|
2014-08-25 21:25:41 +02:00
|
|
|
if (unlikely(mb != 0 || me != 31)) {
|
2014-08-12 15:45:04 +02:00
|
|
|
#if defined(TARGET_PPC64)
|
2014-08-25 21:25:41 +02:00
|
|
|
mb += 32;
|
|
|
|
me += 32;
|
2014-08-12 15:45:04 +02:00
|
|
|
#endif
|
2014-08-25 21:25:41 +02:00
|
|
|
tcg_gen_andi_tl(cpu_gpr[rA(ctx->opcode)], t0, MASK(mb, me));
|
|
|
|
} else {
|
|
|
|
tcg_gen_andi_tl(t0, t0, MASK(32, 63));
|
|
|
|
tcg_gen_mov_tl(cpu_gpr[rA(ctx->opcode)], t0);
|
|
|
|
}
|
|
|
|
tcg_temp_free(t0);
|
2003-11-23 15:55:54 +01:00
|
|
|
}
|
2007-03-07 09:32:30 +01:00
|
|
|
if (unlikely(Rc(ctx->opcode) != 0))
|
2008-10-27 23:50:22 +01:00
|
|
|
gen_set_Rc0(ctx, cpu_gpr[rA(ctx->opcode)]);
|
2003-11-23 15:55:54 +01:00
|
|
|
}
|
|
|
|
|
2007-03-17 15:02:15 +01:00
|
|
|
#if defined(TARGET_PPC64)
|
|
|
|
#define GEN_PPC64_R2(name, opc1, opc2) \
|
2009-06-17 17:22:14 +02:00
|
|
|
static void glue(gen_, name##0)(DisasContext *ctx) \
|
2007-03-17 15:02:15 +01:00
|
|
|
{ \
|
|
|
|
gen_##name(ctx, 0); \
|
|
|
|
} \
|
2009-06-17 17:22:14 +02:00
|
|
|
\
|
|
|
|
static void glue(gen_, name##1)(DisasContext *ctx) \
|
2007-03-17 15:02:15 +01:00
|
|
|
{ \
|
|
|
|
gen_##name(ctx, 1); \
|
|
|
|
}
|
|
|
|
#define GEN_PPC64_R4(name, opc1, opc2) \
|
2009-06-17 17:22:14 +02:00
|
|
|
static void glue(gen_, name##0)(DisasContext *ctx) \
|
2007-03-17 15:02:15 +01:00
|
|
|
{ \
|
|
|
|
gen_##name(ctx, 0, 0); \
|
|
|
|
} \
|
2009-06-17 17:22:14 +02:00
|
|
|
\
|
|
|
|
static void glue(gen_, name##1)(DisasContext *ctx) \
|
2007-03-17 15:02:15 +01:00
|
|
|
{ \
|
|
|
|
gen_##name(ctx, 0, 1); \
|
|
|
|
} \
|
2009-06-17 17:22:14 +02:00
|
|
|
\
|
|
|
|
static void glue(gen_, name##2)(DisasContext *ctx) \
|
2007-03-17 15:02:15 +01:00
|
|
|
{ \
|
|
|
|
gen_##name(ctx, 1, 0); \
|
|
|
|
} \
|
2009-06-17 17:22:14 +02:00
|
|
|
\
|
|
|
|
static void glue(gen_, name##3)(DisasContext *ctx) \
|
2007-03-17 15:02:15 +01:00
|
|
|
{ \
|
|
|
|
gen_##name(ctx, 1, 1); \
|
|
|
|
}
|
2007-03-22 23:41:50 +01:00
|
|
|
|
2009-08-16 11:06:54 +02:00
|
|
|
static inline void gen_rldinm(DisasContext *ctx, uint32_t mb, uint32_t me,
|
|
|
|
uint32_t sh)
|
2007-03-22 23:41:50 +01:00
|
|
|
{
|
2008-10-27 23:50:22 +01:00
|
|
|
if (likely(sh != 0 && mb == 0 && me == (63 - sh))) {
|
|
|
|
tcg_gen_shli_tl(cpu_gpr[rA(ctx->opcode)], cpu_gpr[rS(ctx->opcode)], sh);
|
|
|
|
} else if (likely(sh != 0 && me == 63 && sh == (64 - mb))) {
|
|
|
|
tcg_gen_shri_tl(cpu_gpr[rA(ctx->opcode)], cpu_gpr[rS(ctx->opcode)], mb);
|
|
|
|
} else {
|
2008-11-17 15:43:54 +01:00
|
|
|
TCGv t0 = tcg_temp_new();
|
2008-11-03 08:08:44 +01:00
|
|
|
tcg_gen_rotli_tl(t0, cpu_gpr[rS(ctx->opcode)], sh);
|
2008-10-27 23:50:22 +01:00
|
|
|
if (likely(mb == 0 && me == 63)) {
|
2008-11-03 08:08:44 +01:00
|
|
|
tcg_gen_mov_tl(cpu_gpr[rA(ctx->opcode)], t0);
|
2008-10-27 23:50:22 +01:00
|
|
|
} else {
|
|
|
|
tcg_gen_andi_tl(cpu_gpr[rA(ctx->opcode)], t0, MASK(mb, me));
|
2007-03-22 23:41:50 +01:00
|
|
|
}
|
2008-10-27 23:50:22 +01:00
|
|
|
tcg_temp_free(t0);
|
2007-03-22 23:41:50 +01:00
|
|
|
}
|
|
|
|
if (unlikely(Rc(ctx->opcode) != 0))
|
2008-10-27 23:50:22 +01:00
|
|
|
gen_set_Rc0(ctx, cpu_gpr[rA(ctx->opcode)]);
|
2007-03-22 23:41:50 +01:00
|
|
|
}
|
2007-03-17 15:02:15 +01:00
|
|
|
/* rldicl - rldicl. */
|
2009-08-16 11:06:54 +02:00
|
|
|
static inline void gen_rldicl(DisasContext *ctx, int mbn, int shn)
|
2007-03-17 15:02:15 +01:00
|
|
|
{
|
2007-03-22 23:41:50 +01:00
|
|
|
uint32_t sh, mb;
|
2007-03-17 15:02:15 +01:00
|
|
|
|
2007-04-06 09:59:47 +02:00
|
|
|
sh = SH(ctx->opcode) | (shn << 5);
|
|
|
|
mb = MB(ctx->opcode) | (mbn << 5);
|
2007-03-22 23:41:50 +01:00
|
|
|
gen_rldinm(ctx, mb, 63, sh);
|
2007-03-17 15:02:15 +01:00
|
|
|
}
|
2007-03-22 23:41:50 +01:00
|
|
|
GEN_PPC64_R4(rldicl, 0x1E, 0x00);
|
2007-03-17 15:02:15 +01:00
|
|
|
/* rldicr - rldicr. */
|
2009-08-16 11:06:54 +02:00
|
|
|
static inline void gen_rldicr(DisasContext *ctx, int men, int shn)
|
2007-03-17 15:02:15 +01:00
|
|
|
{
|
2007-03-22 23:41:50 +01:00
|
|
|
uint32_t sh, me;
|
2007-03-17 15:02:15 +01:00
|
|
|
|
2007-04-06 09:59:47 +02:00
|
|
|
sh = SH(ctx->opcode) | (shn << 5);
|
|
|
|
me = MB(ctx->opcode) | (men << 5);
|
2007-03-22 23:41:50 +01:00
|
|
|
gen_rldinm(ctx, 0, me, sh);
|
2007-03-17 15:02:15 +01:00
|
|
|
}
|
2007-03-22 23:41:50 +01:00
|
|
|
GEN_PPC64_R4(rldicr, 0x1E, 0x02);
|
2007-03-17 15:02:15 +01:00
|
|
|
/* rldic - rldic. */
|
2009-08-16 11:06:54 +02:00
|
|
|
static inline void gen_rldic(DisasContext *ctx, int mbn, int shn)
|
2007-03-17 15:02:15 +01:00
|
|
|
{
|
2007-03-22 23:41:50 +01:00
|
|
|
uint32_t sh, mb;
|
2007-03-17 15:02:15 +01:00
|
|
|
|
2007-04-06 09:59:47 +02:00
|
|
|
sh = SH(ctx->opcode) | (shn << 5);
|
|
|
|
mb = MB(ctx->opcode) | (mbn << 5);
|
2007-03-22 23:41:50 +01:00
|
|
|
gen_rldinm(ctx, mb, 63 - sh, sh);
|
|
|
|
}
|
|
|
|
GEN_PPC64_R4(rldic, 0x1E, 0x04);
|
|
|
|
|
2009-08-16 11:06:54 +02:00
|
|
|
static inline void gen_rldnm(DisasContext *ctx, uint32_t mb, uint32_t me)
|
2007-03-22 23:41:50 +01:00
|
|
|
{
|
2008-11-03 08:08:44 +01:00
|
|
|
TCGv t0;
|
2008-10-27 23:50:22 +01:00
|
|
|
|
2008-11-17 15:43:54 +01:00
|
|
|
t0 = tcg_temp_new();
|
2008-10-27 23:50:22 +01:00
|
|
|
tcg_gen_andi_tl(t0, cpu_gpr[rB(ctx->opcode)], 0x3f);
|
2008-11-03 08:08:44 +01:00
|
|
|
tcg_gen_rotl_tl(t0, cpu_gpr[rS(ctx->opcode)], t0);
|
2007-03-22 23:41:50 +01:00
|
|
|
if (unlikely(mb != 0 || me != 63)) {
|
2008-11-03 08:08:44 +01:00
|
|
|
tcg_gen_andi_tl(cpu_gpr[rA(ctx->opcode)], t0, MASK(mb, me));
|
|
|
|
} else {
|
|
|
|
tcg_gen_mov_tl(cpu_gpr[rA(ctx->opcode)], t0);
|
|
|
|
}
|
|
|
|
tcg_temp_free(t0);
|
2007-03-22 23:41:50 +01:00
|
|
|
if (unlikely(Rc(ctx->opcode) != 0))
|
2008-10-27 23:50:22 +01:00
|
|
|
gen_set_Rc0(ctx, cpu_gpr[rA(ctx->opcode)]);
|
2007-03-17 15:02:15 +01:00
|
|
|
}
|
2007-03-22 23:41:50 +01:00
|
|
|
|
2007-03-17 15:02:15 +01:00
|
|
|
/* rldcl - rldcl. */
|
2009-08-16 11:06:54 +02:00
|
|
|
static inline void gen_rldcl(DisasContext *ctx, int mbn)
|
2007-03-17 15:02:15 +01:00
|
|
|
{
|
2007-03-22 23:41:50 +01:00
|
|
|
uint32_t mb;
|
2007-03-17 15:02:15 +01:00
|
|
|
|
2007-04-06 09:59:47 +02:00
|
|
|
mb = MB(ctx->opcode) | (mbn << 5);
|
2007-03-22 23:41:50 +01:00
|
|
|
gen_rldnm(ctx, mb, 63);
|
2007-03-17 15:02:15 +01:00
|
|
|
}
|
2007-09-17 10:21:54 +02:00
|
|
|
GEN_PPC64_R2(rldcl, 0x1E, 0x08);
|
2007-03-17 15:02:15 +01:00
|
|
|
/* rldcr - rldcr. */
|
2009-08-16 11:06:54 +02:00
|
|
|
static inline void gen_rldcr(DisasContext *ctx, int men)
|
2007-03-17 15:02:15 +01:00
|
|
|
{
|
2007-03-22 23:41:50 +01:00
|
|
|
uint32_t me;
|
2007-03-17 15:02:15 +01:00
|
|
|
|
2007-04-06 09:59:47 +02:00
|
|
|
me = MB(ctx->opcode) | (men << 5);
|
2007-03-22 23:41:50 +01:00
|
|
|
gen_rldnm(ctx, 0, me);
|
2007-03-17 15:02:15 +01:00
|
|
|
}
|
2007-09-17 10:21:54 +02:00
|
|
|
GEN_PPC64_R2(rldcr, 0x1E, 0x09);
|
2007-03-17 15:02:15 +01:00
|
|
|
/* rldimi - rldimi. */
|
2009-08-16 11:06:54 +02:00
|
|
|
static inline void gen_rldimi(DisasContext *ctx, int mbn, int shn)
|
2007-03-17 15:02:15 +01:00
|
|
|
{
|
2007-11-14 06:26:46 +01:00
|
|
|
uint32_t sh, mb, me;
|
2007-03-17 15:02:15 +01:00
|
|
|
|
2007-04-06 09:59:47 +02:00
|
|
|
sh = SH(ctx->opcode) | (shn << 5);
|
|
|
|
mb = MB(ctx->opcode) | (mbn << 5);
|
2007-11-14 06:26:46 +01:00
|
|
|
me = 63 - sh;
|
2008-10-27 23:50:22 +01:00
|
|
|
if (unlikely(sh == 0 && mb == 0)) {
|
|
|
|
tcg_gen_mov_tl(cpu_gpr[rA(ctx->opcode)], cpu_gpr[rS(ctx->opcode)]);
|
|
|
|
} else {
|
|
|
|
TCGv t0, t1;
|
|
|
|
target_ulong mask;
|
|
|
|
|
2008-11-17 15:43:54 +01:00
|
|
|
t0 = tcg_temp_new();
|
2008-11-03 08:08:44 +01:00
|
|
|
tcg_gen_rotli_tl(t0, cpu_gpr[rS(ctx->opcode)], sh);
|
2008-11-17 15:43:54 +01:00
|
|
|
t1 = tcg_temp_new();
|
2008-10-27 23:50:22 +01:00
|
|
|
mask = MASK(mb, me);
|
|
|
|
tcg_gen_andi_tl(t0, t0, mask);
|
|
|
|
tcg_gen_andi_tl(t1, cpu_gpr[rA(ctx->opcode)], ~mask);
|
|
|
|
tcg_gen_or_tl(cpu_gpr[rA(ctx->opcode)], t0, t1);
|
|
|
|
tcg_temp_free(t0);
|
|
|
|
tcg_temp_free(t1);
|
2007-03-22 23:41:50 +01:00
|
|
|
}
|
|
|
|
if (unlikely(Rc(ctx->opcode) != 0))
|
2008-10-27 23:50:22 +01:00
|
|
|
gen_set_Rc0(ctx, cpu_gpr[rA(ctx->opcode)]);
|
2007-03-17 15:02:15 +01:00
|
|
|
}
|
2007-09-17 10:21:54 +02:00
|
|
|
GEN_PPC64_R4(rldimi, 0x1E, 0x06);
|
2007-03-17 15:02:15 +01:00
|
|
|
#endif
|
|
|
|
|
2003-11-23 15:55:54 +01:00
|
|
|
/*** Integer shift ***/
|
2009-06-17 17:22:09 +02:00
|
|
|
|
2009-06-17 17:22:19 +02:00
|
|
|
/* slw & slw. */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_slw(DisasContext *ctx)
|
2008-10-21 13:31:27 +02:00
|
|
|
{
|
2009-09-18 16:56:30 +02:00
|
|
|
TCGv t0, t1;
|
2008-10-21 13:31:27 +02:00
|
|
|
|
2009-09-18 16:56:30 +02:00
|
|
|
t0 = tcg_temp_new();
|
|
|
|
/* AND rS with a mask that is 0 when rB >= 0x20 */
|
|
|
|
#if defined(TARGET_PPC64)
|
|
|
|
tcg_gen_shli_tl(t0, cpu_gpr[rB(ctx->opcode)], 0x3a);
|
|
|
|
tcg_gen_sari_tl(t0, t0, 0x3f);
|
|
|
|
#else
|
|
|
|
tcg_gen_shli_tl(t0, cpu_gpr[rB(ctx->opcode)], 0x1a);
|
|
|
|
tcg_gen_sari_tl(t0, t0, 0x1f);
|
|
|
|
#endif
|
|
|
|
tcg_gen_andc_tl(t0, cpu_gpr[rS(ctx->opcode)], t0);
|
|
|
|
t1 = tcg_temp_new();
|
|
|
|
tcg_gen_andi_tl(t1, cpu_gpr[rB(ctx->opcode)], 0x1f);
|
|
|
|
tcg_gen_shl_tl(cpu_gpr[rA(ctx->opcode)], t0, t1);
|
|
|
|
tcg_temp_free(t1);
|
2008-11-02 09:22:34 +01:00
|
|
|
tcg_temp_free(t0);
|
2009-09-18 16:56:30 +02:00
|
|
|
tcg_gen_ext32u_tl(cpu_gpr[rA(ctx->opcode)], cpu_gpr[rA(ctx->opcode)]);
|
2008-10-21 13:31:27 +02:00
|
|
|
if (unlikely(Rc(ctx->opcode) != 0))
|
|
|
|
gen_set_Rc0(ctx, cpu_gpr[rA(ctx->opcode)]);
|
|
|
|
}
|
2009-06-17 17:22:09 +02:00
|
|
|
|
2009-06-17 17:22:19 +02:00
|
|
|
/* sraw & sraw. */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_sraw(DisasContext *ctx)
|
2008-10-21 13:31:27 +02:00
|
|
|
{
|
2012-05-30 06:23:29 +02:00
|
|
|
gen_helper_sraw(cpu_gpr[rA(ctx->opcode)], cpu_env,
|
2008-11-17 15:43:54 +01:00
|
|
|
cpu_gpr[rS(ctx->opcode)], cpu_gpr[rB(ctx->opcode)]);
|
2008-10-21 13:31:27 +02:00
|
|
|
if (unlikely(Rc(ctx->opcode) != 0))
|
|
|
|
gen_set_Rc0(ctx, cpu_gpr[rA(ctx->opcode)]);
|
|
|
|
}
|
2009-06-17 17:22:09 +02:00
|
|
|
|
2009-06-17 17:22:19 +02:00
|
|
|
/* srawi & srawi. */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_srawi(DisasContext *ctx)
|
2003-11-23 15:55:54 +01:00
|
|
|
{
|
2008-10-21 13:31:27 +02:00
|
|
|
int sh = SH(ctx->opcode);
|
2013-02-20 08:52:19 +01:00
|
|
|
TCGv dst = cpu_gpr[rA(ctx->opcode)];
|
|
|
|
TCGv src = cpu_gpr[rS(ctx->opcode)];
|
|
|
|
if (sh == 0) {
|
2014-08-12 15:45:09 +02:00
|
|
|
tcg_gen_ext32s_tl(dst, src);
|
2013-02-20 08:52:13 +01:00
|
|
|
tcg_gen_movi_tl(cpu_ca, 0);
|
2008-10-21 13:31:27 +02:00
|
|
|
} else {
|
2013-02-20 08:52:19 +01:00
|
|
|
TCGv t0;
|
|
|
|
tcg_gen_ext32s_tl(dst, src);
|
|
|
|
tcg_gen_andi_tl(cpu_ca, dst, (1ULL << sh) - 1);
|
|
|
|
t0 = tcg_temp_new();
|
|
|
|
tcg_gen_sari_tl(t0, dst, TARGET_LONG_BITS - 1);
|
|
|
|
tcg_gen_and_tl(cpu_ca, cpu_ca, t0);
|
|
|
|
tcg_temp_free(t0);
|
|
|
|
tcg_gen_setcondi_tl(TCG_COND_NE, cpu_ca, cpu_ca, 0);
|
|
|
|
tcg_gen_sari_tl(dst, dst, sh);
|
|
|
|
}
|
|
|
|
if (unlikely(Rc(ctx->opcode) != 0)) {
|
|
|
|
gen_set_Rc0(ctx, dst);
|
2007-03-17 15:02:15 +01:00
|
|
|
}
|
2003-11-23 15:55:54 +01:00
|
|
|
}
|
2009-06-17 17:22:09 +02:00
|
|
|
|
2009-06-17 17:22:19 +02:00
|
|
|
/* srw & srw. */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_srw(DisasContext *ctx)
|
2008-10-21 13:31:27 +02:00
|
|
|
{
|
2008-11-02 09:22:34 +01:00
|
|
|
TCGv t0, t1;
|
2007-03-17 15:02:15 +01:00
|
|
|
|
2009-09-18 16:56:30 +02:00
|
|
|
t0 = tcg_temp_new();
|
|
|
|
/* AND rS with a mask that is 0 when rB >= 0x20 */
|
|
|
|
#if defined(TARGET_PPC64)
|
|
|
|
tcg_gen_shli_tl(t0, cpu_gpr[rB(ctx->opcode)], 0x3a);
|
|
|
|
tcg_gen_sari_tl(t0, t0, 0x3f);
|
|
|
|
#else
|
|
|
|
tcg_gen_shli_tl(t0, cpu_gpr[rB(ctx->opcode)], 0x1a);
|
|
|
|
tcg_gen_sari_tl(t0, t0, 0x1f);
|
|
|
|
#endif
|
|
|
|
tcg_gen_andc_tl(t0, cpu_gpr[rS(ctx->opcode)], t0);
|
|
|
|
tcg_gen_ext32u_tl(t0, t0);
|
2008-11-17 15:43:54 +01:00
|
|
|
t1 = tcg_temp_new();
|
2009-09-18 16:56:30 +02:00
|
|
|
tcg_gen_andi_tl(t1, cpu_gpr[rB(ctx->opcode)], 0x1f);
|
|
|
|
tcg_gen_shr_tl(cpu_gpr[rA(ctx->opcode)], t0, t1);
|
2008-11-02 09:22:34 +01:00
|
|
|
tcg_temp_free(t1);
|
|
|
|
tcg_temp_free(t0);
|
2008-10-21 13:31:27 +02:00
|
|
|
if (unlikely(Rc(ctx->opcode) != 0))
|
|
|
|
gen_set_Rc0(ctx, cpu_gpr[rA(ctx->opcode)]);
|
|
|
|
}
|
2009-06-17 17:22:19 +02:00
|
|
|
|
2007-03-17 15:02:15 +01:00
|
|
|
#if defined(TARGET_PPC64)
|
|
|
|
/* sld & sld. */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_sld(DisasContext *ctx)
|
2008-10-21 13:31:27 +02:00
|
|
|
{
|
2009-09-18 16:56:30 +02:00
|
|
|
TCGv t0, t1;
|
2008-10-21 13:31:27 +02:00
|
|
|
|
2009-09-18 16:56:30 +02:00
|
|
|
t0 = tcg_temp_new();
|
|
|
|
/* AND rS with a mask that is 0 when rB >= 0x40 */
|
|
|
|
tcg_gen_shli_tl(t0, cpu_gpr[rB(ctx->opcode)], 0x39);
|
|
|
|
tcg_gen_sari_tl(t0, t0, 0x3f);
|
|
|
|
tcg_gen_andc_tl(t0, cpu_gpr[rS(ctx->opcode)], t0);
|
|
|
|
t1 = tcg_temp_new();
|
|
|
|
tcg_gen_andi_tl(t1, cpu_gpr[rB(ctx->opcode)], 0x3f);
|
|
|
|
tcg_gen_shl_tl(cpu_gpr[rA(ctx->opcode)], t0, t1);
|
|
|
|
tcg_temp_free(t1);
|
2008-11-02 09:22:34 +01:00
|
|
|
tcg_temp_free(t0);
|
2008-10-21 13:31:27 +02:00
|
|
|
if (unlikely(Rc(ctx->opcode) != 0))
|
|
|
|
gen_set_Rc0(ctx, cpu_gpr[rA(ctx->opcode)]);
|
|
|
|
}
|
2009-06-17 17:22:09 +02:00
|
|
|
|
2009-06-17 17:22:19 +02:00
|
|
|
/* srad & srad. */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_srad(DisasContext *ctx)
|
2008-10-21 13:31:27 +02:00
|
|
|
{
|
2012-05-30 06:23:29 +02:00
|
|
|
gen_helper_srad(cpu_gpr[rA(ctx->opcode)], cpu_env,
|
2008-11-17 15:43:54 +01:00
|
|
|
cpu_gpr[rS(ctx->opcode)], cpu_gpr[rB(ctx->opcode)]);
|
2008-10-21 13:31:27 +02:00
|
|
|
if (unlikely(Rc(ctx->opcode) != 0))
|
|
|
|
gen_set_Rc0(ctx, cpu_gpr[rA(ctx->opcode)]);
|
|
|
|
}
|
2007-03-17 15:02:15 +01:00
|
|
|
/* sradi & sradi. */
|
2009-08-16 11:06:54 +02:00
|
|
|
static inline void gen_sradi(DisasContext *ctx, int n)
|
2007-03-17 15:02:15 +01:00
|
|
|
{
|
2008-10-21 13:31:27 +02:00
|
|
|
int sh = SH(ctx->opcode) + (n << 5);
|
2013-02-20 08:52:19 +01:00
|
|
|
TCGv dst = cpu_gpr[rA(ctx->opcode)];
|
|
|
|
TCGv src = cpu_gpr[rS(ctx->opcode)];
|
|
|
|
if (sh == 0) {
|
|
|
|
tcg_gen_mov_tl(dst, src);
|
2013-02-20 08:52:13 +01:00
|
|
|
tcg_gen_movi_tl(cpu_ca, 0);
|
2008-10-21 13:31:27 +02:00
|
|
|
} else {
|
2013-02-20 08:52:19 +01:00
|
|
|
TCGv t0;
|
|
|
|
tcg_gen_andi_tl(cpu_ca, src, (1ULL << sh) - 1);
|
|
|
|
t0 = tcg_temp_new();
|
|
|
|
tcg_gen_sari_tl(t0, src, TARGET_LONG_BITS - 1);
|
|
|
|
tcg_gen_and_tl(cpu_ca, cpu_ca, t0);
|
|
|
|
tcg_temp_free(t0);
|
|
|
|
tcg_gen_setcondi_tl(TCG_COND_NE, cpu_ca, cpu_ca, 0);
|
|
|
|
tcg_gen_sari_tl(dst, src, sh);
|
|
|
|
}
|
|
|
|
if (unlikely(Rc(ctx->opcode) != 0)) {
|
|
|
|
gen_set_Rc0(ctx, dst);
|
2007-03-17 15:02:15 +01:00
|
|
|
}
|
|
|
|
}
|
2009-06-17 17:22:14 +02:00
|
|
|
|
|
|
|
static void gen_sradi0(DisasContext *ctx)
|
2007-03-17 15:02:15 +01:00
|
|
|
{
|
|
|
|
gen_sradi(ctx, 0);
|
|
|
|
}
|
2009-06-17 17:22:14 +02:00
|
|
|
|
|
|
|
static void gen_sradi1(DisasContext *ctx)
|
2007-03-17 15:02:15 +01:00
|
|
|
{
|
|
|
|
gen_sradi(ctx, 1);
|
|
|
|
}
|
2009-06-17 17:22:09 +02:00
|
|
|
|
2009-06-17 17:22:19 +02:00
|
|
|
/* srd & srd. */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_srd(DisasContext *ctx)
|
2008-10-21 13:31:27 +02:00
|
|
|
{
|
2009-09-18 16:56:30 +02:00
|
|
|
TCGv t0, t1;
|
2008-10-21 13:31:27 +02:00
|
|
|
|
2009-09-18 16:56:30 +02:00
|
|
|
t0 = tcg_temp_new();
|
|
|
|
/* AND rS with a mask that is 0 when rB >= 0x40 */
|
|
|
|
tcg_gen_shli_tl(t0, cpu_gpr[rB(ctx->opcode)], 0x39);
|
|
|
|
tcg_gen_sari_tl(t0, t0, 0x3f);
|
|
|
|
tcg_gen_andc_tl(t0, cpu_gpr[rS(ctx->opcode)], t0);
|
|
|
|
t1 = tcg_temp_new();
|
|
|
|
tcg_gen_andi_tl(t1, cpu_gpr[rB(ctx->opcode)], 0x3f);
|
|
|
|
tcg_gen_shr_tl(cpu_gpr[rA(ctx->opcode)], t0, t1);
|
|
|
|
tcg_temp_free(t1);
|
2008-11-02 09:22:34 +01:00
|
|
|
tcg_temp_free(t0);
|
2008-10-21 13:31:27 +02:00
|
|
|
if (unlikely(Rc(ctx->opcode) != 0))
|
|
|
|
gen_set_Rc0(ctx, cpu_gpr[rA(ctx->opcode)]);
|
|
|
|
}
|
2007-03-17 15:02:15 +01:00
|
|
|
#endif
|
2003-11-23 15:55:54 +01:00
|
|
|
|
2014-11-12 22:46:00 +01:00
|
|
|
#if defined(TARGET_PPC64)
|
|
|
|
static void gen_set_cr1_from_fpscr(DisasContext *ctx)
|
|
|
|
{
|
|
|
|
TCGv_i32 tmp = tcg_temp_new_i32();
|
|
|
|
tcg_gen_trunc_tl_i32(tmp, cpu_fpscr);
|
|
|
|
tcg_gen_shri_i32(cpu_crf[1], tmp, 28);
|
|
|
|
tcg_temp_free_i32(tmp);
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
static void gen_set_cr1_from_fpscr(DisasContext *ctx)
|
|
|
|
{
|
|
|
|
tcg_gen_shri_tl(cpu_crf[1], cpu_fpscr, 28);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2003-11-23 15:55:54 +01:00
|
|
|
/*** Floating-Point arithmetic ***/
|
2007-10-27 19:54:30 +02:00
|
|
|
#define _GEN_FLOAT_ACB(name, op, op1, op2, isfloat, set_fprf, type) \
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_f##name(DisasContext *ctx) \
|
2004-01-04 23:58:38 +01:00
|
|
|
{ \
|
2007-03-07 09:32:30 +01:00
|
|
|
if (unlikely(!ctx->fpu_enabled)) { \
|
2008-12-11 23:42:14 +01:00
|
|
|
gen_exception(ctx, POWERPC_EXCP_FPU); \
|
2005-02-16 00:06:19 +01:00
|
|
|
return; \
|
|
|
|
} \
|
2008-12-15 18:13:39 +01:00
|
|
|
/* NIP cannot be restored if the memory exception comes from an helper */ \
|
|
|
|
gen_update_nip(ctx, ctx->nip - 4); \
|
2007-10-27 19:54:30 +02:00
|
|
|
gen_reset_fpstatus(); \
|
2012-05-30 06:23:27 +02:00
|
|
|
gen_helper_f##op(cpu_fpr[rD(ctx->opcode)], cpu_env, \
|
|
|
|
cpu_fpr[rA(ctx->opcode)], \
|
2008-11-19 17:10:23 +01:00
|
|
|
cpu_fpr[rC(ctx->opcode)], cpu_fpr[rB(ctx->opcode)]); \
|
2005-03-13 18:01:22 +01:00
|
|
|
if (isfloat) { \
|
2012-05-30 06:23:27 +02:00
|
|
|
gen_helper_frsp(cpu_fpr[rD(ctx->opcode)], cpu_env, \
|
|
|
|
cpu_fpr[rD(ctx->opcode)]); \
|
2005-03-13 18:01:22 +01:00
|
|
|
} \
|
2014-11-12 22:46:03 +01:00
|
|
|
if (set_fprf) { \
|
|
|
|
gen_compute_fprf(cpu_fpr[rD(ctx->opcode)]); \
|
|
|
|
} \
|
2014-11-12 22:46:02 +01:00
|
|
|
if (unlikely(Rc(ctx->opcode) != 0)) { \
|
|
|
|
gen_set_cr1_from_fpscr(ctx); \
|
|
|
|
} \
|
2004-01-04 23:58:38 +01:00
|
|
|
}
|
|
|
|
|
2007-10-27 19:54:30 +02:00
|
|
|
#define GEN_FLOAT_ACB(name, op2, set_fprf, type) \
|
|
|
|
_GEN_FLOAT_ACB(name, name, 0x3F, op2, 0, set_fprf, type); \
|
|
|
|
_GEN_FLOAT_ACB(name##s, name, 0x3B, op2, 1, set_fprf, type);
|
2004-01-04 23:58:38 +01:00
|
|
|
|
2007-10-27 19:54:30 +02:00
|
|
|
#define _GEN_FLOAT_AB(name, op, op1, op2, inval, isfloat, set_fprf, type) \
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_f##name(DisasContext *ctx) \
|
2004-01-04 23:58:38 +01:00
|
|
|
{ \
|
2007-03-07 09:32:30 +01:00
|
|
|
if (unlikely(!ctx->fpu_enabled)) { \
|
2008-12-11 23:42:14 +01:00
|
|
|
gen_exception(ctx, POWERPC_EXCP_FPU); \
|
2005-02-16 00:06:19 +01:00
|
|
|
return; \
|
|
|
|
} \
|
2008-12-15 18:13:39 +01:00
|
|
|
/* NIP cannot be restored if the memory exception comes from an helper */ \
|
|
|
|
gen_update_nip(ctx, ctx->nip - 4); \
|
2007-10-27 19:54:30 +02:00
|
|
|
gen_reset_fpstatus(); \
|
2012-05-30 06:23:27 +02:00
|
|
|
gen_helper_f##op(cpu_fpr[rD(ctx->opcode)], cpu_env, \
|
|
|
|
cpu_fpr[rA(ctx->opcode)], \
|
2008-11-19 17:10:23 +01:00
|
|
|
cpu_fpr[rB(ctx->opcode)]); \
|
2005-03-13 18:01:22 +01:00
|
|
|
if (isfloat) { \
|
2012-05-30 06:23:27 +02:00
|
|
|
gen_helper_frsp(cpu_fpr[rD(ctx->opcode)], cpu_env, \
|
|
|
|
cpu_fpr[rD(ctx->opcode)]); \
|
2005-03-13 18:01:22 +01:00
|
|
|
} \
|
2014-11-12 22:46:03 +01:00
|
|
|
if (set_fprf) { \
|
|
|
|
gen_compute_fprf(cpu_fpr[rD(ctx->opcode)]); \
|
|
|
|
} \
|
2014-11-12 22:46:02 +01:00
|
|
|
if (unlikely(Rc(ctx->opcode) != 0)) { \
|
|
|
|
gen_set_cr1_from_fpscr(ctx); \
|
|
|
|
} \
|
2004-01-04 23:58:38 +01:00
|
|
|
}
|
2007-10-27 19:54:30 +02:00
|
|
|
#define GEN_FLOAT_AB(name, op2, inval, set_fprf, type) \
|
|
|
|
_GEN_FLOAT_AB(name, name, 0x3F, op2, inval, 0, set_fprf, type); \
|
|
|
|
_GEN_FLOAT_AB(name##s, name, 0x3B, op2, inval, 1, set_fprf, type);
|
2004-01-04 23:58:38 +01:00
|
|
|
|
2007-10-27 19:54:30 +02:00
|
|
|
#define _GEN_FLOAT_AC(name, op, op1, op2, inval, isfloat, set_fprf, type) \
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_f##name(DisasContext *ctx) \
|
2004-01-04 23:58:38 +01:00
|
|
|
{ \
|
2007-03-07 09:32:30 +01:00
|
|
|
if (unlikely(!ctx->fpu_enabled)) { \
|
2008-12-11 23:42:14 +01:00
|
|
|
gen_exception(ctx, POWERPC_EXCP_FPU); \
|
2005-02-16 00:06:19 +01:00
|
|
|
return; \
|
|
|
|
} \
|
2008-12-15 18:13:39 +01:00
|
|
|
/* NIP cannot be restored if the memory exception comes from an helper */ \
|
|
|
|
gen_update_nip(ctx, ctx->nip - 4); \
|
2007-10-27 19:54:30 +02:00
|
|
|
gen_reset_fpstatus(); \
|
2012-05-30 06:23:27 +02:00
|
|
|
gen_helper_f##op(cpu_fpr[rD(ctx->opcode)], cpu_env, \
|
|
|
|
cpu_fpr[rA(ctx->opcode)], \
|
|
|
|
cpu_fpr[rC(ctx->opcode)]); \
|
2005-03-13 18:01:22 +01:00
|
|
|
if (isfloat) { \
|
2012-05-30 06:23:27 +02:00
|
|
|
gen_helper_frsp(cpu_fpr[rD(ctx->opcode)], cpu_env, \
|
|
|
|
cpu_fpr[rD(ctx->opcode)]); \
|
2005-03-13 18:01:22 +01:00
|
|
|
} \
|
2014-11-12 22:46:03 +01:00
|
|
|
if (set_fprf) { \
|
|
|
|
gen_compute_fprf(cpu_fpr[rD(ctx->opcode)]); \
|
|
|
|
} \
|
2014-11-12 22:46:02 +01:00
|
|
|
if (unlikely(Rc(ctx->opcode) != 0)) { \
|
|
|
|
gen_set_cr1_from_fpscr(ctx); \
|
|
|
|
} \
|
2004-01-04 23:58:38 +01:00
|
|
|
}
|
2007-10-27 19:54:30 +02:00
|
|
|
#define GEN_FLOAT_AC(name, op2, inval, set_fprf, type) \
|
|
|
|
_GEN_FLOAT_AC(name, name, 0x3F, op2, inval, 0, set_fprf, type); \
|
|
|
|
_GEN_FLOAT_AC(name##s, name, 0x3B, op2, inval, 1, set_fprf, type);
|
2004-01-04 23:58:38 +01:00
|
|
|
|
2007-10-27 19:54:30 +02:00
|
|
|
#define GEN_FLOAT_B(name, op2, op3, set_fprf, type) \
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_f##name(DisasContext *ctx) \
|
2004-01-04 23:58:38 +01:00
|
|
|
{ \
|
2007-03-07 09:32:30 +01:00
|
|
|
if (unlikely(!ctx->fpu_enabled)) { \
|
2008-12-11 23:42:14 +01:00
|
|
|
gen_exception(ctx, POWERPC_EXCP_FPU); \
|
2005-02-16 00:06:19 +01:00
|
|
|
return; \
|
|
|
|
} \
|
2008-12-15 18:13:39 +01:00
|
|
|
/* NIP cannot be restored if the memory exception comes from an helper */ \
|
|
|
|
gen_update_nip(ctx, ctx->nip - 4); \
|
2007-10-27 19:54:30 +02:00
|
|
|
gen_reset_fpstatus(); \
|
2012-05-30 06:23:27 +02:00
|
|
|
gen_helper_f##name(cpu_fpr[rD(ctx->opcode)], cpu_env, \
|
|
|
|
cpu_fpr[rB(ctx->opcode)]); \
|
2014-11-12 22:46:03 +01:00
|
|
|
if (set_fprf) { \
|
|
|
|
gen_compute_fprf(cpu_fpr[rD(ctx->opcode)]); \
|
|
|
|
} \
|
2014-11-12 22:46:02 +01:00
|
|
|
if (unlikely(Rc(ctx->opcode) != 0)) { \
|
|
|
|
gen_set_cr1_from_fpscr(ctx); \
|
|
|
|
} \
|
2003-11-23 15:55:54 +01:00
|
|
|
}
|
|
|
|
|
2007-10-27 19:54:30 +02:00
|
|
|
#define GEN_FLOAT_BS(name, op1, op2, set_fprf, type) \
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_f##name(DisasContext *ctx) \
|
2004-01-04 23:58:38 +01:00
|
|
|
{ \
|
2007-03-07 09:32:30 +01:00
|
|
|
if (unlikely(!ctx->fpu_enabled)) { \
|
2008-12-11 23:42:14 +01:00
|
|
|
gen_exception(ctx, POWERPC_EXCP_FPU); \
|
2005-02-16 00:06:19 +01:00
|
|
|
return; \
|
|
|
|
} \
|
2008-12-15 18:13:39 +01:00
|
|
|
/* NIP cannot be restored if the memory exception comes from an helper */ \
|
|
|
|
gen_update_nip(ctx, ctx->nip - 4); \
|
2007-10-27 19:54:30 +02:00
|
|
|
gen_reset_fpstatus(); \
|
2012-05-30 06:23:27 +02:00
|
|
|
gen_helper_f##name(cpu_fpr[rD(ctx->opcode)], cpu_env, \
|
|
|
|
cpu_fpr[rB(ctx->opcode)]); \
|
2014-11-12 22:46:03 +01:00
|
|
|
if (set_fprf) { \
|
|
|
|
gen_compute_fprf(cpu_fpr[rD(ctx->opcode)]); \
|
|
|
|
} \
|
2014-11-12 22:46:02 +01:00
|
|
|
if (unlikely(Rc(ctx->opcode) != 0)) { \
|
|
|
|
gen_set_cr1_from_fpscr(ctx); \
|
|
|
|
} \
|
2003-11-23 15:55:54 +01:00
|
|
|
}
|
|
|
|
|
2004-01-04 23:58:38 +01:00
|
|
|
/* fadd - fadds */
|
2007-10-27 19:54:30 +02:00
|
|
|
GEN_FLOAT_AB(add, 0x15, 0x000007C0, 1, PPC_FLOAT);
|
2005-03-13 18:01:22 +01:00
|
|
|
/* fdiv - fdivs */
|
2007-10-27 19:54:30 +02:00
|
|
|
GEN_FLOAT_AB(div, 0x12, 0x000007C0, 1, PPC_FLOAT);
|
2005-03-13 18:01:22 +01:00
|
|
|
/* fmul - fmuls */
|
2007-10-27 19:54:30 +02:00
|
|
|
GEN_FLOAT_AC(mul, 0x19, 0x0000F800, 1, PPC_FLOAT);
|
2003-11-23 15:55:54 +01:00
|
|
|
|
2007-09-30 03:11:48 +02:00
|
|
|
/* fre */
|
2007-10-27 19:54:30 +02:00
|
|
|
GEN_FLOAT_BS(re, 0x3F, 0x18, 1, PPC_FLOAT_EXT);
|
2007-09-30 03:11:48 +02:00
|
|
|
|
Great rework and cleanups to ease PowerPC implementations definitions.
* cleanup cpu.h, removing definitions used only in translate.c/translate_init.c
* add new flags to define instructions sets more precisely
* various changes in MMU models definitions
* add definitions for PowerPC 440/460 support (insns and SPRs).
* add definitions for PowerPC 401/403 and 620 input pins model
* Fix definitions for most PowerPC 401, 403, 405, 440, 601, 602, 603 and 7x0
* Preliminary support for PowerPC 74xx (aka G4) without altivec.
* Code provision for other PowerPC support (7x5, 970, ...).
* New SPR and PVR defined, from PowerPC 2.04 specification and other sources
* Misc code bugs, error messages and styles fixes.
* Update status files for PowerPC cores support.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3244 c046a42c-6fe2-441c-8c8c-71466251a162
2007-09-27 01:54:22 +02:00
|
|
|
/* fres */
|
2007-10-27 19:54:30 +02:00
|
|
|
GEN_FLOAT_BS(res, 0x3B, 0x18, 1, PPC_FLOAT_FRES);
|
2003-11-23 15:55:54 +01:00
|
|
|
|
Great rework and cleanups to ease PowerPC implementations definitions.
* cleanup cpu.h, removing definitions used only in translate.c/translate_init.c
* add new flags to define instructions sets more precisely
* various changes in MMU models definitions
* add definitions for PowerPC 440/460 support (insns and SPRs).
* add definitions for PowerPC 401/403 and 620 input pins model
* Fix definitions for most PowerPC 401, 403, 405, 440, 601, 602, 603 and 7x0
* Preliminary support for PowerPC 74xx (aka G4) without altivec.
* Code provision for other PowerPC support (7x5, 970, ...).
* New SPR and PVR defined, from PowerPC 2.04 specification and other sources
* Misc code bugs, error messages and styles fixes.
* Update status files for PowerPC cores support.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3244 c046a42c-6fe2-441c-8c8c-71466251a162
2007-09-27 01:54:22 +02:00
|
|
|
/* frsqrte */
|
2007-10-27 19:54:30 +02:00
|
|
|
GEN_FLOAT_BS(rsqrte, 0x3F, 0x1A, 1, PPC_FLOAT_FRSQRTE);
|
|
|
|
|
|
|
|
/* frsqrtes */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_frsqrtes(DisasContext *ctx)
|
2007-10-27 19:54:30 +02:00
|
|
|
{
|
2008-11-19 17:10:23 +01:00
|
|
|
if (unlikely(!ctx->fpu_enabled)) {
|
2008-12-11 23:42:14 +01:00
|
|
|
gen_exception(ctx, POWERPC_EXCP_FPU);
|
2008-11-19 17:10:23 +01:00
|
|
|
return;
|
|
|
|
}
|
2008-12-15 18:13:39 +01:00
|
|
|
/* NIP cannot be restored if the memory exception comes from an helper */
|
|
|
|
gen_update_nip(ctx, ctx->nip - 4);
|
2008-11-19 17:10:23 +01:00
|
|
|
gen_reset_fpstatus();
|
2012-05-30 06:23:27 +02:00
|
|
|
gen_helper_frsqrte(cpu_fpr[rD(ctx->opcode)], cpu_env,
|
|
|
|
cpu_fpr[rB(ctx->opcode)]);
|
|
|
|
gen_helper_frsp(cpu_fpr[rD(ctx->opcode)], cpu_env,
|
|
|
|
cpu_fpr[rD(ctx->opcode)]);
|
2014-11-12 22:46:03 +01:00
|
|
|
gen_compute_fprf(cpu_fpr[rD(ctx->opcode)]);
|
2014-11-12 22:46:02 +01:00
|
|
|
if (unlikely(Rc(ctx->opcode) != 0)) {
|
|
|
|
gen_set_cr1_from_fpscr(ctx);
|
|
|
|
}
|
2007-10-27 19:54:30 +02:00
|
|
|
}
|
2003-11-23 15:55:54 +01:00
|
|
|
|
Great rework and cleanups to ease PowerPC implementations definitions.
* cleanup cpu.h, removing definitions used only in translate.c/translate_init.c
* add new flags to define instructions sets more precisely
* various changes in MMU models definitions
* add definitions for PowerPC 440/460 support (insns and SPRs).
* add definitions for PowerPC 401/403 and 620 input pins model
* Fix definitions for most PowerPC 401, 403, 405, 440, 601, 602, 603 and 7x0
* Preliminary support for PowerPC 74xx (aka G4) without altivec.
* Code provision for other PowerPC support (7x5, 970, ...).
* New SPR and PVR defined, from PowerPC 2.04 specification and other sources
* Misc code bugs, error messages and styles fixes.
* Update status files for PowerPC cores support.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3244 c046a42c-6fe2-441c-8c8c-71466251a162
2007-09-27 01:54:22 +02:00
|
|
|
/* fsel */
|
2007-10-27 19:54:30 +02:00
|
|
|
_GEN_FLOAT_ACB(sel, sel, 0x3F, 0x17, 0, 0, PPC_FLOAT_FSEL);
|
2005-03-13 18:01:22 +01:00
|
|
|
/* fsub - fsubs */
|
2007-10-27 19:54:30 +02:00
|
|
|
GEN_FLOAT_AB(sub, 0x14, 0x000007C0, 1, PPC_FLOAT);
|
2003-11-23 15:55:54 +01:00
|
|
|
/* Optional: */
|
2009-06-17 17:22:09 +02:00
|
|
|
|
2009-06-17 17:22:19 +02:00
|
|
|
/* fsqrt */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_fsqrt(DisasContext *ctx)
|
2005-04-23 20:05:46 +02:00
|
|
|
{
|
2007-03-07 09:32:30 +01:00
|
|
|
if (unlikely(!ctx->fpu_enabled)) {
|
2008-12-11 23:42:14 +01:00
|
|
|
gen_exception(ctx, POWERPC_EXCP_FPU);
|
2005-04-23 20:05:46 +02:00
|
|
|
return;
|
|
|
|
}
|
2008-12-15 18:13:39 +01:00
|
|
|
/* NIP cannot be restored if the memory exception comes from an helper */
|
|
|
|
gen_update_nip(ctx, ctx->nip - 4);
|
2007-10-27 19:54:30 +02:00
|
|
|
gen_reset_fpstatus();
|
2012-05-30 06:23:27 +02:00
|
|
|
gen_helper_fsqrt(cpu_fpr[rD(ctx->opcode)], cpu_env,
|
|
|
|
cpu_fpr[rB(ctx->opcode)]);
|
2014-11-12 22:46:03 +01:00
|
|
|
gen_compute_fprf(cpu_fpr[rD(ctx->opcode)]);
|
2014-11-12 22:46:02 +01:00
|
|
|
if (unlikely(Rc(ctx->opcode) != 0)) {
|
|
|
|
gen_set_cr1_from_fpscr(ctx);
|
|
|
|
}
|
2005-04-23 20:05:46 +02:00
|
|
|
}
|
2003-11-23 15:55:54 +01:00
|
|
|
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_fsqrts(DisasContext *ctx)
|
2003-11-23 15:55:54 +01:00
|
|
|
{
|
2007-03-07 09:32:30 +01:00
|
|
|
if (unlikely(!ctx->fpu_enabled)) {
|
2008-12-11 23:42:14 +01:00
|
|
|
gen_exception(ctx, POWERPC_EXCP_FPU);
|
2005-02-16 00:06:19 +01:00
|
|
|
return;
|
|
|
|
}
|
2008-12-15 18:13:39 +01:00
|
|
|
/* NIP cannot be restored if the memory exception comes from an helper */
|
|
|
|
gen_update_nip(ctx, ctx->nip - 4);
|
2007-10-27 19:54:30 +02:00
|
|
|
gen_reset_fpstatus();
|
2012-05-30 06:23:27 +02:00
|
|
|
gen_helper_fsqrt(cpu_fpr[rD(ctx->opcode)], cpu_env,
|
|
|
|
cpu_fpr[rB(ctx->opcode)]);
|
|
|
|
gen_helper_frsp(cpu_fpr[rD(ctx->opcode)], cpu_env,
|
|
|
|
cpu_fpr[rD(ctx->opcode)]);
|
2014-11-12 22:46:03 +01:00
|
|
|
gen_compute_fprf(cpu_fpr[rD(ctx->opcode)]);
|
2014-11-12 22:46:02 +01:00
|
|
|
if (unlikely(Rc(ctx->opcode) != 0)) {
|
|
|
|
gen_set_cr1_from_fpscr(ctx);
|
|
|
|
}
|
2003-11-23 15:55:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*** Floating-Point multiply-and-add ***/
|
2005-03-13 18:01:22 +01:00
|
|
|
/* fmadd - fmadds */
|
2007-10-27 19:54:30 +02:00
|
|
|
GEN_FLOAT_ACB(madd, 0x1D, 1, PPC_FLOAT);
|
2005-03-13 18:01:22 +01:00
|
|
|
/* fmsub - fmsubs */
|
2007-10-27 19:54:30 +02:00
|
|
|
GEN_FLOAT_ACB(msub, 0x1C, 1, PPC_FLOAT);
|
2005-03-13 18:01:22 +01:00
|
|
|
/* fnmadd - fnmadds */
|
2007-10-27 19:54:30 +02:00
|
|
|
GEN_FLOAT_ACB(nmadd, 0x1F, 1, PPC_FLOAT);
|
2005-03-13 18:01:22 +01:00
|
|
|
/* fnmsub - fnmsubs */
|
2007-10-27 19:54:30 +02:00
|
|
|
GEN_FLOAT_ACB(nmsub, 0x1E, 1, PPC_FLOAT);
|
2003-11-23 15:55:54 +01:00
|
|
|
|
|
|
|
/*** Floating-Point round & convert ***/
|
|
|
|
/* fctiw */
|
2007-10-27 19:54:30 +02:00
|
|
|
GEN_FLOAT_B(ctiw, 0x0E, 0x00, 0, PPC_FLOAT);
|
2014-01-07 17:05:59 +01:00
|
|
|
/* fctiwu */
|
|
|
|
GEN_FLOAT_B(ctiwu, 0x0E, 0x04, 0, PPC2_FP_CVT_ISA206);
|
2003-11-23 15:55:54 +01:00
|
|
|
/* fctiwz */
|
2007-10-27 19:54:30 +02:00
|
|
|
GEN_FLOAT_B(ctiwz, 0x0F, 0x00, 0, PPC_FLOAT);
|
2014-01-07 17:05:59 +01:00
|
|
|
/* fctiwuz */
|
|
|
|
GEN_FLOAT_B(ctiwuz, 0x0F, 0x04, 0, PPC2_FP_CVT_ISA206);
|
2003-11-23 15:55:54 +01:00
|
|
|
/* frsp */
|
2007-10-27 19:54:30 +02:00
|
|
|
GEN_FLOAT_B(rsp, 0x0C, 0x00, 1, PPC_FLOAT);
|
2007-03-23 10:45:27 +01:00
|
|
|
/* fcfid */
|
2014-09-12 21:31:32 +02:00
|
|
|
GEN_FLOAT_B(cfid, 0x0E, 0x1A, 1, PPC2_FP_CVT_S64);
|
2014-01-07 17:06:00 +01:00
|
|
|
/* fcfids */
|
|
|
|
GEN_FLOAT_B(cfids, 0x0E, 0x1A, 0, PPC2_FP_CVT_ISA206);
|
|
|
|
/* fcfidu */
|
|
|
|
GEN_FLOAT_B(cfidu, 0x0E, 0x1E, 0, PPC2_FP_CVT_ISA206);
|
|
|
|
/* fcfidus */
|
|
|
|
GEN_FLOAT_B(cfidus, 0x0E, 0x1E, 0, PPC2_FP_CVT_ISA206);
|
2007-03-23 10:45:27 +01:00
|
|
|
/* fctid */
|
2014-09-12 21:31:32 +02:00
|
|
|
GEN_FLOAT_B(ctid, 0x0E, 0x19, 0, PPC2_FP_CVT_S64);
|
2014-01-07 17:05:59 +01:00
|
|
|
/* fctidu */
|
|
|
|
GEN_FLOAT_B(ctidu, 0x0E, 0x1D, 0, PPC2_FP_CVT_ISA206);
|
2007-03-23 10:45:27 +01:00
|
|
|
/* fctidz */
|
2014-09-12 21:31:32 +02:00
|
|
|
GEN_FLOAT_B(ctidz, 0x0F, 0x19, 0, PPC2_FP_CVT_S64);
|
2014-01-07 17:05:59 +01:00
|
|
|
/* fctidu */
|
|
|
|
GEN_FLOAT_B(ctiduz, 0x0F, 0x1D, 0, PPC2_FP_CVT_ISA206);
|
2003-11-23 15:55:54 +01:00
|
|
|
|
2007-09-30 03:11:48 +02:00
|
|
|
/* frin */
|
2007-10-27 19:54:30 +02:00
|
|
|
GEN_FLOAT_B(rin, 0x08, 0x0C, 1, PPC_FLOAT_EXT);
|
2007-09-30 03:11:48 +02:00
|
|
|
/* friz */
|
2007-10-27 19:54:30 +02:00
|
|
|
GEN_FLOAT_B(riz, 0x08, 0x0D, 1, PPC_FLOAT_EXT);
|
2007-09-30 03:11:48 +02:00
|
|
|
/* frip */
|
2007-10-27 19:54:30 +02:00
|
|
|
GEN_FLOAT_B(rip, 0x08, 0x0E, 1, PPC_FLOAT_EXT);
|
2007-09-30 03:11:48 +02:00
|
|
|
/* frim */
|
2007-10-27 19:54:30 +02:00
|
|
|
GEN_FLOAT_B(rim, 0x08, 0x0F, 1, PPC_FLOAT_EXT);
|
2007-09-30 03:11:48 +02:00
|
|
|
|
2014-01-07 17:06:07 +01:00
|
|
|
static void gen_ftdiv(DisasContext *ctx)
|
|
|
|
{
|
|
|
|
if (unlikely(!ctx->fpu_enabled)) {
|
|
|
|
gen_exception(ctx, POWERPC_EXCP_FPU);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
gen_helper_ftdiv(cpu_crf[crfD(ctx->opcode)], cpu_fpr[rA(ctx->opcode)],
|
|
|
|
cpu_fpr[rB(ctx->opcode)]);
|
|
|
|
}
|
|
|
|
|
2014-01-07 17:06:08 +01:00
|
|
|
static void gen_ftsqrt(DisasContext *ctx)
|
|
|
|
{
|
|
|
|
if (unlikely(!ctx->fpu_enabled)) {
|
|
|
|
gen_exception(ctx, POWERPC_EXCP_FPU);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
gen_helper_ftsqrt(cpu_crf[crfD(ctx->opcode)], cpu_fpr[rB(ctx->opcode)]);
|
|
|
|
}
|
|
|
|
|
2014-01-07 17:06:07 +01:00
|
|
|
|
|
|
|
|
2003-11-23 15:55:54 +01:00
|
|
|
/*** Floating-Point compare ***/
|
2009-06-17 17:22:09 +02:00
|
|
|
|
2009-06-17 17:22:19 +02:00
|
|
|
/* fcmpo */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_fcmpo(DisasContext *ctx)
|
2003-11-23 15:55:54 +01:00
|
|
|
{
|
2008-12-15 18:13:31 +01:00
|
|
|
TCGv_i32 crf;
|
2007-03-07 09:32:30 +01:00
|
|
|
if (unlikely(!ctx->fpu_enabled)) {
|
2008-12-11 23:42:14 +01:00
|
|
|
gen_exception(ctx, POWERPC_EXCP_FPU);
|
2005-02-16 00:06:19 +01:00
|
|
|
return;
|
|
|
|
}
|
2008-12-15 18:13:39 +01:00
|
|
|
/* NIP cannot be restored if the memory exception comes from an helper */
|
|
|
|
gen_update_nip(ctx, ctx->nip - 4);
|
2007-10-27 19:54:30 +02:00
|
|
|
gen_reset_fpstatus();
|
2008-12-14 20:34:09 +01:00
|
|
|
crf = tcg_const_i32(crfD(ctx->opcode));
|
2012-05-30 06:23:27 +02:00
|
|
|
gen_helper_fcmpo(cpu_env, cpu_fpr[rA(ctx->opcode)],
|
|
|
|
cpu_fpr[rB(ctx->opcode)], crf);
|
2008-12-15 18:13:31 +01:00
|
|
|
tcg_temp_free_i32(crf);
|
2012-05-30 06:23:27 +02:00
|
|
|
gen_helper_float_check_status(cpu_env);
|
2003-11-23 15:55:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* fcmpu */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_fcmpu(DisasContext *ctx)
|
2003-11-23 15:55:54 +01:00
|
|
|
{
|
2008-12-15 18:13:31 +01:00
|
|
|
TCGv_i32 crf;
|
2007-03-07 09:32:30 +01:00
|
|
|
if (unlikely(!ctx->fpu_enabled)) {
|
2008-12-11 23:42:14 +01:00
|
|
|
gen_exception(ctx, POWERPC_EXCP_FPU);
|
2005-02-16 00:06:19 +01:00
|
|
|
return;
|
|
|
|
}
|
2008-12-15 18:13:39 +01:00
|
|
|
/* NIP cannot be restored if the memory exception comes from an helper */
|
|
|
|
gen_update_nip(ctx, ctx->nip - 4);
|
2007-10-27 19:54:30 +02:00
|
|
|
gen_reset_fpstatus();
|
2008-12-14 20:34:09 +01:00
|
|
|
crf = tcg_const_i32(crfD(ctx->opcode));
|
2012-05-30 06:23:27 +02:00
|
|
|
gen_helper_fcmpu(cpu_env, cpu_fpr[rA(ctx->opcode)],
|
|
|
|
cpu_fpr[rB(ctx->opcode)], crf);
|
2008-12-15 18:13:31 +01:00
|
|
|
tcg_temp_free_i32(crf);
|
2012-05-30 06:23:27 +02:00
|
|
|
gen_helper_float_check_status(cpu_env);
|
2003-11-23 15:55:54 +01:00
|
|
|
}
|
|
|
|
|
2004-01-04 23:58:38 +01:00
|
|
|
/*** Floating-point move ***/
|
|
|
|
/* fabs */
|
2007-10-27 19:54:30 +02:00
|
|
|
/* XXX: beware that fabs never checks for NaNs nor update FPSCR */
|
2013-04-20 10:56:13 +02:00
|
|
|
static void gen_fabs(DisasContext *ctx)
|
|
|
|
{
|
|
|
|
if (unlikely(!ctx->fpu_enabled)) {
|
|
|
|
gen_exception(ctx, POWERPC_EXCP_FPU);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
tcg_gen_andi_i64(cpu_fpr[rD(ctx->opcode)], cpu_fpr[rB(ctx->opcode)],
|
|
|
|
~(1ULL << 63));
|
2014-11-12 22:46:00 +01:00
|
|
|
if (unlikely(Rc(ctx->opcode))) {
|
|
|
|
gen_set_cr1_from_fpscr(ctx);
|
|
|
|
}
|
2013-04-20 10:56:13 +02:00
|
|
|
}
|
2004-01-04 23:58:38 +01:00
|
|
|
|
|
|
|
/* fmr - fmr. */
|
2007-10-27 19:54:30 +02:00
|
|
|
/* XXX: beware that fmr never checks for NaNs nor update FPSCR */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_fmr(DisasContext *ctx)
|
2004-01-04 23:58:38 +01:00
|
|
|
{
|
2007-03-07 09:32:30 +01:00
|
|
|
if (unlikely(!ctx->fpu_enabled)) {
|
2008-12-11 23:42:14 +01:00
|
|
|
gen_exception(ctx, POWERPC_EXCP_FPU);
|
2005-02-16 00:06:19 +01:00
|
|
|
return;
|
|
|
|
}
|
2008-11-19 17:10:23 +01:00
|
|
|
tcg_gen_mov_i64(cpu_fpr[rD(ctx->opcode)], cpu_fpr[rB(ctx->opcode)]);
|
2014-11-12 22:46:00 +01:00
|
|
|
if (unlikely(Rc(ctx->opcode))) {
|
|
|
|
gen_set_cr1_from_fpscr(ctx);
|
|
|
|
}
|
2004-01-04 23:58:38 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* fnabs */
|
2007-10-27 19:54:30 +02:00
|
|
|
/* XXX: beware that fnabs never checks for NaNs nor update FPSCR */
|
2013-04-20 10:56:13 +02:00
|
|
|
static void gen_fnabs(DisasContext *ctx)
|
|
|
|
{
|
|
|
|
if (unlikely(!ctx->fpu_enabled)) {
|
|
|
|
gen_exception(ctx, POWERPC_EXCP_FPU);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
tcg_gen_ori_i64(cpu_fpr[rD(ctx->opcode)], cpu_fpr[rB(ctx->opcode)],
|
|
|
|
1ULL << 63);
|
2014-11-12 22:46:00 +01:00
|
|
|
if (unlikely(Rc(ctx->opcode))) {
|
|
|
|
gen_set_cr1_from_fpscr(ctx);
|
|
|
|
}
|
2013-04-20 10:56:13 +02:00
|
|
|
}
|
|
|
|
|
2004-01-04 23:58:38 +01:00
|
|
|
/* fneg */
|
2007-10-27 19:54:30 +02:00
|
|
|
/* XXX: beware that fneg never checks for NaNs nor update FPSCR */
|
2013-04-20 10:56:13 +02:00
|
|
|
static void gen_fneg(DisasContext *ctx)
|
|
|
|
{
|
|
|
|
if (unlikely(!ctx->fpu_enabled)) {
|
|
|
|
gen_exception(ctx, POWERPC_EXCP_FPU);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
tcg_gen_xori_i64(cpu_fpr[rD(ctx->opcode)], cpu_fpr[rB(ctx->opcode)],
|
|
|
|
1ULL << 63);
|
2014-11-12 22:46:00 +01:00
|
|
|
if (unlikely(Rc(ctx->opcode))) {
|
|
|
|
gen_set_cr1_from_fpscr(ctx);
|
|
|
|
}
|
2013-04-20 10:56:13 +02:00
|
|
|
}
|
2004-01-04 23:58:38 +01:00
|
|
|
|
2013-04-20 10:56:18 +02:00
|
|
|
/* fcpsgn: PowerPC 2.05 specification */
|
|
|
|
/* XXX: beware that fcpsgn never checks for NaNs nor update FPSCR */
|
|
|
|
static void gen_fcpsgn(DisasContext *ctx)
|
|
|
|
{
|
|
|
|
if (unlikely(!ctx->fpu_enabled)) {
|
|
|
|
gen_exception(ctx, POWERPC_EXCP_FPU);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
tcg_gen_deposit_i64(cpu_fpr[rD(ctx->opcode)], cpu_fpr[rA(ctx->opcode)],
|
|
|
|
cpu_fpr[rB(ctx->opcode)], 0, 63);
|
2014-11-12 22:46:00 +01:00
|
|
|
if (unlikely(Rc(ctx->opcode))) {
|
|
|
|
gen_set_cr1_from_fpscr(ctx);
|
|
|
|
}
|
2013-04-20 10:56:18 +02:00
|
|
|
}
|
|
|
|
|
2014-01-15 15:10:43 +01:00
|
|
|
static void gen_fmrgew(DisasContext *ctx)
|
|
|
|
{
|
|
|
|
TCGv_i64 b0;
|
|
|
|
if (unlikely(!ctx->fpu_enabled)) {
|
|
|
|
gen_exception(ctx, POWERPC_EXCP_FPU);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
b0 = tcg_temp_new_i64();
|
|
|
|
tcg_gen_shri_i64(b0, cpu_fpr[rB(ctx->opcode)], 32);
|
|
|
|
tcg_gen_deposit_i64(cpu_fpr[rD(ctx->opcode)], cpu_fpr[rA(ctx->opcode)],
|
|
|
|
b0, 0, 32);
|
|
|
|
tcg_temp_free_i64(b0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void gen_fmrgow(DisasContext *ctx)
|
|
|
|
{
|
|
|
|
if (unlikely(!ctx->fpu_enabled)) {
|
|
|
|
gen_exception(ctx, POWERPC_EXCP_FPU);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
tcg_gen_deposit_i64(cpu_fpr[rD(ctx->opcode)],
|
|
|
|
cpu_fpr[rB(ctx->opcode)],
|
|
|
|
cpu_fpr[rA(ctx->opcode)],
|
|
|
|
32, 32);
|
|
|
|
}
|
|
|
|
|
2003-11-23 15:55:54 +01:00
|
|
|
/*** Floating-Point status & ctrl register ***/
|
2009-06-17 17:22:09 +02:00
|
|
|
|
2009-06-17 17:22:19 +02:00
|
|
|
/* mcrfs */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_mcrfs(DisasContext *ctx)
|
2003-11-23 15:55:54 +01:00
|
|
|
{
|
2012-10-29 18:24:59 +01:00
|
|
|
TCGv tmp = tcg_temp_new();
|
target-ppc: mcrfs should always update FEX/VX and only clear exception bits
Here is the description of the mcrfs instruction from the PowerPC Architecture
Book, Version 2.02, Book I: PowerPC User Instruction Set Architecture
(http://www.ibm.com/developerworks/systems/library/es-archguide-v2.html), found
on page 120:
The contents of FPSCR field BFA are copied to Condition Register field BF.
All exception bits copied are set to 0 in the FPSCR. If the FX bit is
copied, it is set to 0 in the FPSCR.
Special Registers Altered:
CR field BF
FX OX (if BFA=0)
UX ZX XX VXSNAN (if BFA=1)
VXISI VXIDI VXZDZ VXIMZ (if BFA=2)
VXVC (if BFA=3)
VXSOFT VXSQRT VXCVI (if BFA=5)
However, currently every bit in FPSCR field BFA is set to 0, including ones not
on that list.
This can be seen in the following simple C program:
#include <fenv.h>
#include <stdio.h>
int main(int argc, char **argv) {
int ret;
ret = fegetround();
printf("Current rounding: %d\n", ret);
ret = fesetround(FE_UPWARD);
printf("Setting to FE_UPWARD (%d): %d\n", FE_UPWARD, ret);
ret = fegetround();
printf("Current rounding: %d\n", ret);
ret = fegetround();
printf("Current rounding: %d\n", ret);
return 0;
}
which gave the output (before this commit):
Current rounding: 0
Setting to FE_UPWARD (2): 0
Current rounding: 2
Current rounding: 0
instead of (after this commit):
Current rounding: 0
Setting to FE_UPWARD (2): 0
Current rounding: 2
Current rounding: 2
The relevant disassembly is in fegetround(), which, on my system, is:
__GI___fegetround:
<+0>: mcrfs cr7, cr7
<+4>: mfcr r3
<+8>: clrldi r3, r3, 62
<+12>: blr
What happens is that, the first time fegetround() is called, FPSCR field 7 is
retrieved. However, because of the bug in mcrfs, the entirety of field 7 is set
to 0, which includes the rounding mode.
There are other issues this will fix, such as condition flags not persisting
when they should if read, and if you were to read a specific field with some
exception bits set, but no others were set in the entire register, then the
bits would be cleared correctly, but FEX/VX would not be updated to 0 as they
should be.
Signed-off-by: James Clarke <jrtc27@jrtc27.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2016-01-29 19:40:21 +01:00
|
|
|
TCGv_i32 tmask;
|
|
|
|
TCGv_i64 tnew_fpscr = tcg_temp_new_i64();
|
2007-10-27 19:54:30 +02:00
|
|
|
int bfa;
|
target-ppc: mcrfs should always update FEX/VX and only clear exception bits
Here is the description of the mcrfs instruction from the PowerPC Architecture
Book, Version 2.02, Book I: PowerPC User Instruction Set Architecture
(http://www.ibm.com/developerworks/systems/library/es-archguide-v2.html), found
on page 120:
The contents of FPSCR field BFA are copied to Condition Register field BF.
All exception bits copied are set to 0 in the FPSCR. If the FX bit is
copied, it is set to 0 in the FPSCR.
Special Registers Altered:
CR field BF
FX OX (if BFA=0)
UX ZX XX VXSNAN (if BFA=1)
VXISI VXIDI VXZDZ VXIMZ (if BFA=2)
VXVC (if BFA=3)
VXSOFT VXSQRT VXCVI (if BFA=5)
However, currently every bit in FPSCR field BFA is set to 0, including ones not
on that list.
This can be seen in the following simple C program:
#include <fenv.h>
#include <stdio.h>
int main(int argc, char **argv) {
int ret;
ret = fegetround();
printf("Current rounding: %d\n", ret);
ret = fesetround(FE_UPWARD);
printf("Setting to FE_UPWARD (%d): %d\n", FE_UPWARD, ret);
ret = fegetround();
printf("Current rounding: %d\n", ret);
ret = fegetround();
printf("Current rounding: %d\n", ret);
return 0;
}
which gave the output (before this commit):
Current rounding: 0
Setting to FE_UPWARD (2): 0
Current rounding: 2
Current rounding: 0
instead of (after this commit):
Current rounding: 0
Setting to FE_UPWARD (2): 0
Current rounding: 2
Current rounding: 2
The relevant disassembly is in fegetround(), which, on my system, is:
__GI___fegetround:
<+0>: mcrfs cr7, cr7
<+4>: mfcr r3
<+8>: clrldi r3, r3, 62
<+12>: blr
What happens is that, the first time fegetround() is called, FPSCR field 7 is
retrieved. However, because of the bug in mcrfs, the entirety of field 7 is set
to 0, which includes the rounding mode.
There are other issues this will fix, such as condition flags not persisting
when they should if read, and if you were to read a specific field with some
exception bits set, but no others were set in the entire register, then the
bits would be cleared correctly, but FEX/VX would not be updated to 0 as they
should be.
Signed-off-by: James Clarke <jrtc27@jrtc27.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2016-01-29 19:40:21 +01:00
|
|
|
int nibble;
|
|
|
|
int shift;
|
2007-10-27 19:54:30 +02:00
|
|
|
|
2007-03-07 09:32:30 +01:00
|
|
|
if (unlikely(!ctx->fpu_enabled)) {
|
2008-12-11 23:42:14 +01:00
|
|
|
gen_exception(ctx, POWERPC_EXCP_FPU);
|
2005-02-16 00:06:19 +01:00
|
|
|
return;
|
|
|
|
}
|
target-ppc: mcrfs should always update FEX/VX and only clear exception bits
Here is the description of the mcrfs instruction from the PowerPC Architecture
Book, Version 2.02, Book I: PowerPC User Instruction Set Architecture
(http://www.ibm.com/developerworks/systems/library/es-archguide-v2.html), found
on page 120:
The contents of FPSCR field BFA are copied to Condition Register field BF.
All exception bits copied are set to 0 in the FPSCR. If the FX bit is
copied, it is set to 0 in the FPSCR.
Special Registers Altered:
CR field BF
FX OX (if BFA=0)
UX ZX XX VXSNAN (if BFA=1)
VXISI VXIDI VXZDZ VXIMZ (if BFA=2)
VXVC (if BFA=3)
VXSOFT VXSQRT VXCVI (if BFA=5)
However, currently every bit in FPSCR field BFA is set to 0, including ones not
on that list.
This can be seen in the following simple C program:
#include <fenv.h>
#include <stdio.h>
int main(int argc, char **argv) {
int ret;
ret = fegetround();
printf("Current rounding: %d\n", ret);
ret = fesetround(FE_UPWARD);
printf("Setting to FE_UPWARD (%d): %d\n", FE_UPWARD, ret);
ret = fegetround();
printf("Current rounding: %d\n", ret);
ret = fegetround();
printf("Current rounding: %d\n", ret);
return 0;
}
which gave the output (before this commit):
Current rounding: 0
Setting to FE_UPWARD (2): 0
Current rounding: 2
Current rounding: 0
instead of (after this commit):
Current rounding: 0
Setting to FE_UPWARD (2): 0
Current rounding: 2
Current rounding: 2
The relevant disassembly is in fegetround(), which, on my system, is:
__GI___fegetround:
<+0>: mcrfs cr7, cr7
<+4>: mfcr r3
<+8>: clrldi r3, r3, 62
<+12>: blr
What happens is that, the first time fegetround() is called, FPSCR field 7 is
retrieved. However, because of the bug in mcrfs, the entirety of field 7 is set
to 0, which includes the rounding mode.
There are other issues this will fix, such as condition flags not persisting
when they should if read, and if you were to read a specific field with some
exception bits set, but no others were set in the entire register, then the
bits would be cleared correctly, but FEX/VX would not be updated to 0 as they
should be.
Signed-off-by: James Clarke <jrtc27@jrtc27.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2016-01-29 19:40:21 +01:00
|
|
|
bfa = crfS(ctx->opcode);
|
|
|
|
nibble = 7 - bfa;
|
|
|
|
shift = 4 * nibble;
|
|
|
|
tcg_gen_shri_tl(tmp, cpu_fpscr, shift);
|
2012-10-29 18:24:59 +01:00
|
|
|
tcg_gen_trunc_tl_i32(cpu_crf[crfD(ctx->opcode)], tmp);
|
2008-10-21 13:31:14 +02:00
|
|
|
tcg_gen_andi_i32(cpu_crf[crfD(ctx->opcode)], cpu_crf[crfD(ctx->opcode)], 0xf);
|
target-ppc: mcrfs should always update FEX/VX and only clear exception bits
Here is the description of the mcrfs instruction from the PowerPC Architecture
Book, Version 2.02, Book I: PowerPC User Instruction Set Architecture
(http://www.ibm.com/developerworks/systems/library/es-archguide-v2.html), found
on page 120:
The contents of FPSCR field BFA are copied to Condition Register field BF.
All exception bits copied are set to 0 in the FPSCR. If the FX bit is
copied, it is set to 0 in the FPSCR.
Special Registers Altered:
CR field BF
FX OX (if BFA=0)
UX ZX XX VXSNAN (if BFA=1)
VXISI VXIDI VXZDZ VXIMZ (if BFA=2)
VXVC (if BFA=3)
VXSOFT VXSQRT VXCVI (if BFA=5)
However, currently every bit in FPSCR field BFA is set to 0, including ones not
on that list.
This can be seen in the following simple C program:
#include <fenv.h>
#include <stdio.h>
int main(int argc, char **argv) {
int ret;
ret = fegetround();
printf("Current rounding: %d\n", ret);
ret = fesetround(FE_UPWARD);
printf("Setting to FE_UPWARD (%d): %d\n", FE_UPWARD, ret);
ret = fegetround();
printf("Current rounding: %d\n", ret);
ret = fegetround();
printf("Current rounding: %d\n", ret);
return 0;
}
which gave the output (before this commit):
Current rounding: 0
Setting to FE_UPWARD (2): 0
Current rounding: 2
Current rounding: 0
instead of (after this commit):
Current rounding: 0
Setting to FE_UPWARD (2): 0
Current rounding: 2
Current rounding: 2
The relevant disassembly is in fegetround(), which, on my system, is:
__GI___fegetround:
<+0>: mcrfs cr7, cr7
<+4>: mfcr r3
<+8>: clrldi r3, r3, 62
<+12>: blr
What happens is that, the first time fegetround() is called, FPSCR field 7 is
retrieved. However, because of the bug in mcrfs, the entirety of field 7 is set
to 0, which includes the rounding mode.
There are other issues this will fix, such as condition flags not persisting
when they should if read, and if you were to read a specific field with some
exception bits set, but no others were set in the entire register, then the
bits would be cleared correctly, but FEX/VX would not be updated to 0 as they
should be.
Signed-off-by: James Clarke <jrtc27@jrtc27.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2016-01-29 19:40:21 +01:00
|
|
|
tcg_temp_free(tmp);
|
|
|
|
tcg_gen_extu_tl_i64(tnew_fpscr, cpu_fpscr);
|
|
|
|
/* Only the exception bits (including FX) should be cleared if read */
|
|
|
|
tcg_gen_andi_i64(tnew_fpscr, tnew_fpscr, ~((0xF << shift) & FP_EX_CLEAR_BITS));
|
|
|
|
/* FEX and VX need to be updated, so don't set fpscr directly */
|
|
|
|
tmask = tcg_const_i32(1 << nibble);
|
|
|
|
gen_helper_store_fpscr(cpu_env, tnew_fpscr, tmask);
|
|
|
|
tcg_temp_free_i32(tmask);
|
|
|
|
tcg_temp_free_i64(tnew_fpscr);
|
2003-11-23 15:55:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* mffs */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_mffs(DisasContext *ctx)
|
2003-11-23 15:55:54 +01:00
|
|
|
{
|
2007-03-07 09:32:30 +01:00
|
|
|
if (unlikely(!ctx->fpu_enabled)) {
|
2008-12-11 23:42:14 +01:00
|
|
|
gen_exception(ctx, POWERPC_EXCP_FPU);
|
2005-02-16 00:06:19 +01:00
|
|
|
return;
|
|
|
|
}
|
2007-10-27 19:54:30 +02:00
|
|
|
gen_reset_fpstatus();
|
2012-10-29 18:24:59 +01:00
|
|
|
tcg_gen_extu_tl_i64(cpu_fpr[rD(ctx->opcode)], cpu_fpscr);
|
2014-11-12 22:46:01 +01:00
|
|
|
if (unlikely(Rc(ctx->opcode))) {
|
|
|
|
gen_set_cr1_from_fpscr(ctx);
|
|
|
|
}
|
2003-11-23 15:55:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* mtfsb0 */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_mtfsb0(DisasContext *ctx)
|
2003-11-23 15:55:54 +01:00
|
|
|
{
|
2004-01-04 15:57:11 +01:00
|
|
|
uint8_t crb;
|
2007-09-17 10:09:54 +02:00
|
|
|
|
2007-03-07 09:32:30 +01:00
|
|
|
if (unlikely(!ctx->fpu_enabled)) {
|
2008-12-11 23:42:14 +01:00
|
|
|
gen_exception(ctx, POWERPC_EXCP_FPU);
|
2005-02-16 00:06:19 +01:00
|
|
|
return;
|
|
|
|
}
|
2008-12-14 19:40:58 +01:00
|
|
|
crb = 31 - crbD(ctx->opcode);
|
2007-10-27 19:54:30 +02:00
|
|
|
gen_reset_fpstatus();
|
2008-12-14 19:40:58 +01:00
|
|
|
if (likely(crb != FPSCR_FEX && crb != FPSCR_VX)) {
|
2008-12-15 18:13:39 +01:00
|
|
|
TCGv_i32 t0;
|
|
|
|
/* NIP cannot be restored if the memory exception comes from an helper */
|
|
|
|
gen_update_nip(ctx, ctx->nip - 4);
|
|
|
|
t0 = tcg_const_i32(crb);
|
2012-05-30 06:23:27 +02:00
|
|
|
gen_helper_fpscr_clrbit(cpu_env, t0);
|
2008-12-14 19:40:58 +01:00
|
|
|
tcg_temp_free_i32(t0);
|
|
|
|
}
|
2007-10-27 19:54:30 +02:00
|
|
|
if (unlikely(Rc(ctx->opcode) != 0)) {
|
2012-10-29 18:24:59 +01:00
|
|
|
tcg_gen_trunc_tl_i32(cpu_crf[1], cpu_fpscr);
|
|
|
|
tcg_gen_shri_i32(cpu_crf[1], cpu_crf[1], FPSCR_OX);
|
2007-10-27 19:54:30 +02:00
|
|
|
}
|
2003-11-23 15:55:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* mtfsb1 */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_mtfsb1(DisasContext *ctx)
|
2003-11-23 15:55:54 +01:00
|
|
|
{
|
2004-01-04 15:57:11 +01:00
|
|
|
uint8_t crb;
|
2007-09-17 10:09:54 +02:00
|
|
|
|
2007-03-07 09:32:30 +01:00
|
|
|
if (unlikely(!ctx->fpu_enabled)) {
|
2008-12-11 23:42:14 +01:00
|
|
|
gen_exception(ctx, POWERPC_EXCP_FPU);
|
2005-02-16 00:06:19 +01:00
|
|
|
return;
|
|
|
|
}
|
2008-12-14 19:40:58 +01:00
|
|
|
crb = 31 - crbD(ctx->opcode);
|
2007-10-27 19:54:30 +02:00
|
|
|
gen_reset_fpstatus();
|
|
|
|
/* XXX: we pretend we can only do IEEE floating-point computations */
|
2008-11-19 17:10:23 +01:00
|
|
|
if (likely(crb != FPSCR_FEX && crb != FPSCR_VX && crb != FPSCR_NI)) {
|
2008-12-15 18:13:39 +01:00
|
|
|
TCGv_i32 t0;
|
|
|
|
/* NIP cannot be restored if the memory exception comes from an helper */
|
|
|
|
gen_update_nip(ctx, ctx->nip - 4);
|
|
|
|
t0 = tcg_const_i32(crb);
|
2012-05-30 06:23:27 +02:00
|
|
|
gen_helper_fpscr_setbit(cpu_env, t0);
|
2008-11-19 18:54:49 +01:00
|
|
|
tcg_temp_free_i32(t0);
|
2008-11-19 17:10:23 +01:00
|
|
|
}
|
2007-10-27 19:54:30 +02:00
|
|
|
if (unlikely(Rc(ctx->opcode) != 0)) {
|
2012-10-29 18:24:59 +01:00
|
|
|
tcg_gen_trunc_tl_i32(cpu_crf[1], cpu_fpscr);
|
|
|
|
tcg_gen_shri_i32(cpu_crf[1], cpu_crf[1], FPSCR_OX);
|
2007-10-27 19:54:30 +02:00
|
|
|
}
|
|
|
|
/* We can raise a differed exception */
|
2012-05-30 06:23:27 +02:00
|
|
|
gen_helper_float_check_status(cpu_env);
|
2003-11-23 15:55:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* mtfsf */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_mtfsf(DisasContext *ctx)
|
2003-11-23 15:55:54 +01:00
|
|
|
{
|
2008-11-19 18:54:49 +01:00
|
|
|
TCGv_i32 t0;
|
2013-04-20 10:56:22 +02:00
|
|
|
int flm, l, w;
|
2008-11-19 17:10:23 +01:00
|
|
|
|
2007-03-07 09:32:30 +01:00
|
|
|
if (unlikely(!ctx->fpu_enabled)) {
|
2008-12-11 23:42:14 +01:00
|
|
|
gen_exception(ctx, POWERPC_EXCP_FPU);
|
2005-02-16 00:06:19 +01:00
|
|
|
return;
|
|
|
|
}
|
2013-04-20 10:56:22 +02:00
|
|
|
flm = FPFLM(ctx->opcode);
|
|
|
|
l = FPL(ctx->opcode);
|
|
|
|
w = FPW(ctx->opcode);
|
|
|
|
if (unlikely(w & !(ctx->insns_flags2 & PPC2_ISA205))) {
|
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_INVAL_INVAL);
|
|
|
|
return;
|
|
|
|
}
|
2008-12-15 18:13:39 +01:00
|
|
|
/* NIP cannot be restored if the memory exception comes from an helper */
|
|
|
|
gen_update_nip(ctx, ctx->nip - 4);
|
2007-10-27 19:54:30 +02:00
|
|
|
gen_reset_fpstatus();
|
2013-04-20 10:56:22 +02:00
|
|
|
if (l) {
|
|
|
|
t0 = tcg_const_i32((ctx->insns_flags2 & PPC2_ISA205) ? 0xffff : 0xff);
|
|
|
|
} else {
|
|
|
|
t0 = tcg_const_i32(flm << (w * 8));
|
|
|
|
}
|
2012-05-30 06:23:27 +02:00
|
|
|
gen_helper_store_fpscr(cpu_env, cpu_fpr[rB(ctx->opcode)], t0);
|
2008-11-19 18:54:49 +01:00
|
|
|
tcg_temp_free_i32(t0);
|
2007-10-27 19:54:30 +02:00
|
|
|
if (unlikely(Rc(ctx->opcode) != 0)) {
|
2012-10-29 18:24:59 +01:00
|
|
|
tcg_gen_trunc_tl_i32(cpu_crf[1], cpu_fpscr);
|
|
|
|
tcg_gen_shri_i32(cpu_crf[1], cpu_crf[1], FPSCR_OX);
|
2007-10-27 19:54:30 +02:00
|
|
|
}
|
|
|
|
/* We can raise a differed exception */
|
2012-05-30 06:23:27 +02:00
|
|
|
gen_helper_float_check_status(cpu_env);
|
2003-11-23 15:55:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* mtfsfi */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_mtfsfi(DisasContext *ctx)
|
2003-11-23 15:55:54 +01:00
|
|
|
{
|
2013-04-20 10:56:22 +02:00
|
|
|
int bf, sh, w;
|
2008-11-19 18:54:49 +01:00
|
|
|
TCGv_i64 t0;
|
|
|
|
TCGv_i32 t1;
|
2007-10-27 19:54:30 +02:00
|
|
|
|
2007-03-07 09:32:30 +01:00
|
|
|
if (unlikely(!ctx->fpu_enabled)) {
|
2008-12-11 23:42:14 +01:00
|
|
|
gen_exception(ctx, POWERPC_EXCP_FPU);
|
2005-02-16 00:06:19 +01:00
|
|
|
return;
|
|
|
|
}
|
2013-04-20 10:56:22 +02:00
|
|
|
w = FPW(ctx->opcode);
|
|
|
|
bf = FPBF(ctx->opcode);
|
|
|
|
if (unlikely(w & !(ctx->insns_flags2 & PPC2_ISA205))) {
|
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_INVAL_INVAL);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
sh = (8 * w) + 7 - bf;
|
2008-12-15 18:13:39 +01:00
|
|
|
/* NIP cannot be restored if the memory exception comes from an helper */
|
|
|
|
gen_update_nip(ctx, ctx->nip - 4);
|
2007-10-27 19:54:30 +02:00
|
|
|
gen_reset_fpstatus();
|
2013-04-20 10:56:22 +02:00
|
|
|
t0 = tcg_const_i64(((uint64_t)FPIMM(ctx->opcode)) << (4 * sh));
|
2008-11-19 17:10:23 +01:00
|
|
|
t1 = tcg_const_i32(1 << sh);
|
2012-05-30 06:23:27 +02:00
|
|
|
gen_helper_store_fpscr(cpu_env, t0, t1);
|
2008-11-19 18:54:49 +01:00
|
|
|
tcg_temp_free_i64(t0);
|
|
|
|
tcg_temp_free_i32(t1);
|
2007-10-27 19:54:30 +02:00
|
|
|
if (unlikely(Rc(ctx->opcode) != 0)) {
|
2012-10-29 18:24:59 +01:00
|
|
|
tcg_gen_trunc_tl_i32(cpu_crf[1], cpu_fpscr);
|
|
|
|
tcg_gen_shri_i32(cpu_crf[1], cpu_crf[1], FPSCR_OX);
|
2007-10-27 19:54:30 +02:00
|
|
|
}
|
|
|
|
/* We can raise a differed exception */
|
2012-05-30 06:23:27 +02:00
|
|
|
gen_helper_float_check_status(cpu_env);
|
2003-11-23 15:55:54 +01:00
|
|
|
}
|
|
|
|
|
2007-03-07 09:32:30 +01:00
|
|
|
/*** Addressing modes ***/
|
|
|
|
/* Register indirect with immediate index : EA = (rA|0) + SIMM */
|
2009-08-16 11:06:54 +02:00
|
|
|
static inline void gen_addr_imm_index(DisasContext *ctx, TCGv EA,
|
|
|
|
target_long maskl)
|
2007-03-07 09:32:30 +01:00
|
|
|
{
|
|
|
|
target_long simm = SIMM(ctx->opcode);
|
|
|
|
|
2007-09-30 15:03:23 +02:00
|
|
|
simm &= ~maskl;
|
2008-12-08 19:11:21 +01:00
|
|
|
if (rA(ctx->opcode) == 0) {
|
2013-03-21 11:01:48 +01:00
|
|
|
if (NARROW_MODE(ctx)) {
|
|
|
|
simm = (uint32_t)simm;
|
|
|
|
}
|
2008-10-14 21:55:54 +02:00
|
|
|
tcg_gen_movi_tl(EA, simm);
|
2008-12-08 19:11:21 +01:00
|
|
|
} else if (likely(simm != 0)) {
|
2008-10-14 21:55:54 +02:00
|
|
|
tcg_gen_addi_tl(EA, cpu_gpr[rA(ctx->opcode)], simm);
|
2013-03-21 11:01:48 +01:00
|
|
|
if (NARROW_MODE(ctx)) {
|
2008-12-08 19:11:21 +01:00
|
|
|
tcg_gen_ext32u_tl(EA, EA);
|
|
|
|
}
|
|
|
|
} else {
|
2013-03-21 11:01:48 +01:00
|
|
|
if (NARROW_MODE(ctx)) {
|
2008-12-08 19:11:21 +01:00
|
|
|
tcg_gen_ext32u_tl(EA, cpu_gpr[rA(ctx->opcode)]);
|
2013-03-21 11:01:48 +01:00
|
|
|
} else {
|
|
|
|
tcg_gen_mov_tl(EA, cpu_gpr[rA(ctx->opcode)]);
|
|
|
|
}
|
2008-12-08 19:11:21 +01:00
|
|
|
}
|
2007-03-07 09:32:30 +01:00
|
|
|
}
|
|
|
|
|
2009-08-16 11:06:54 +02:00
|
|
|
static inline void gen_addr_reg_index(DisasContext *ctx, TCGv EA)
|
2007-03-07 09:32:30 +01:00
|
|
|
{
|
2008-12-08 19:11:21 +01:00
|
|
|
if (rA(ctx->opcode) == 0) {
|
2013-03-21 11:01:48 +01:00
|
|
|
if (NARROW_MODE(ctx)) {
|
2008-12-08 19:11:21 +01:00
|
|
|
tcg_gen_ext32u_tl(EA, cpu_gpr[rB(ctx->opcode)]);
|
2013-03-21 11:01:48 +01:00
|
|
|
} else {
|
|
|
|
tcg_gen_mov_tl(EA, cpu_gpr[rB(ctx->opcode)]);
|
|
|
|
}
|
2008-12-08 19:11:21 +01:00
|
|
|
} else {
|
2008-10-14 21:55:54 +02:00
|
|
|
tcg_gen_add_tl(EA, cpu_gpr[rA(ctx->opcode)], cpu_gpr[rB(ctx->opcode)]);
|
2013-03-21 11:01:48 +01:00
|
|
|
if (NARROW_MODE(ctx)) {
|
2008-12-08 19:11:21 +01:00
|
|
|
tcg_gen_ext32u_tl(EA, EA);
|
|
|
|
}
|
|
|
|
}
|
2007-03-07 09:32:30 +01:00
|
|
|
}
|
|
|
|
|
2009-08-16 11:06:54 +02:00
|
|
|
static inline void gen_addr_register(DisasContext *ctx, TCGv EA)
|
2007-03-07 09:32:30 +01:00
|
|
|
{
|
2008-12-08 19:11:21 +01:00
|
|
|
if (rA(ctx->opcode) == 0) {
|
2008-10-14 21:55:54 +02:00
|
|
|
tcg_gen_movi_tl(EA, 0);
|
2013-03-21 11:01:48 +01:00
|
|
|
} else if (NARROW_MODE(ctx)) {
|
|
|
|
tcg_gen_ext32u_tl(EA, cpu_gpr[rA(ctx->opcode)]);
|
2008-12-08 19:11:21 +01:00
|
|
|
} else {
|
2013-03-21 11:01:48 +01:00
|
|
|
tcg_gen_mov_tl(EA, cpu_gpr[rA(ctx->opcode)]);
|
2008-12-08 19:11:21 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-08-16 11:06:54 +02:00
|
|
|
static inline void gen_addr_add(DisasContext *ctx, TCGv ret, TCGv arg1,
|
|
|
|
target_long val)
|
2008-12-08 19:11:21 +01:00
|
|
|
{
|
|
|
|
tcg_gen_addi_tl(ret, arg1, val);
|
2013-03-21 11:01:48 +01:00
|
|
|
if (NARROW_MODE(ctx)) {
|
2008-12-08 19:11:21 +01:00
|
|
|
tcg_gen_ext32u_tl(ret, ret);
|
|
|
|
}
|
2007-03-07 09:32:30 +01:00
|
|
|
}
|
|
|
|
|
2009-08-16 11:06:54 +02:00
|
|
|
static inline void gen_check_align(DisasContext *ctx, TCGv EA, int mask)
|
2008-11-30 17:24:39 +01:00
|
|
|
{
|
2015-02-13 21:51:55 +01:00
|
|
|
TCGLabel *l1 = gen_new_label();
|
2008-11-30 17:24:39 +01:00
|
|
|
TCGv t0 = tcg_temp_new();
|
|
|
|
TCGv_i32 t1, t2;
|
|
|
|
/* NIP cannot be restored if the memory exception comes from an helper */
|
|
|
|
gen_update_nip(ctx, ctx->nip - 4);
|
|
|
|
tcg_gen_andi_tl(t0, EA, mask);
|
|
|
|
tcg_gen_brcondi_tl(TCG_COND_EQ, t0, 0, l1);
|
|
|
|
t1 = tcg_const_i32(POWERPC_EXCP_ALIGN);
|
|
|
|
t2 = tcg_const_i32(0);
|
2012-05-30 06:23:23 +02:00
|
|
|
gen_helper_raise_exception_err(cpu_env, t1, t2);
|
2008-11-30 17:24:39 +01:00
|
|
|
tcg_temp_free_i32(t1);
|
|
|
|
tcg_temp_free_i32(t2);
|
|
|
|
gen_set_label(l1);
|
|
|
|
tcg_temp_free(t0);
|
|
|
|
}
|
|
|
|
|
2007-11-16 15:11:28 +01:00
|
|
|
/*** Integer load ***/
|
2009-08-16 11:06:54 +02:00
|
|
|
static inline void gen_qemu_ld8u(DisasContext *ctx, TCGv arg1, TCGv arg2)
|
2008-12-08 19:11:21 +01:00
|
|
|
{
|
|
|
|
tcg_gen_qemu_ld8u(arg1, arg2, ctx->mem_idx);
|
|
|
|
}
|
|
|
|
|
2009-08-16 11:06:54 +02:00
|
|
|
static inline void gen_qemu_ld16u(DisasContext *ctx, TCGv arg1, TCGv arg2)
|
2008-12-08 19:11:21 +01:00
|
|
|
{
|
2014-05-29 16:12:20 +02:00
|
|
|
TCGMemOp op = MO_UW | ctx->default_tcg_memop_mask;
|
|
|
|
tcg_gen_qemu_ld_tl(arg1, arg2, ctx->mem_idx, op);
|
2008-10-15 19:00:37 +02:00
|
|
|
}
|
|
|
|
|
2009-08-16 11:06:54 +02:00
|
|
|
static inline void gen_qemu_ld16s(DisasContext *ctx, TCGv arg1, TCGv arg2)
|
2008-10-15 19:00:37 +02:00
|
|
|
{
|
2014-05-29 16:12:20 +02:00
|
|
|
TCGMemOp op = MO_SW | ctx->default_tcg_memop_mask;
|
|
|
|
tcg_gen_qemu_ld_tl(arg1, arg2, ctx->mem_idx, op);
|
2008-10-15 19:00:37 +02:00
|
|
|
}
|
|
|
|
|
2009-08-16 11:06:54 +02:00
|
|
|
static inline void gen_qemu_ld32u(DisasContext *ctx, TCGv arg1, TCGv arg2)
|
2008-10-15 19:00:37 +02:00
|
|
|
{
|
2014-05-29 16:12:20 +02:00
|
|
|
TCGMemOp op = MO_UL | ctx->default_tcg_memop_mask;
|
|
|
|
tcg_gen_qemu_ld_tl(arg1, arg2, ctx->mem_idx, op);
|
2008-10-15 19:00:37 +02:00
|
|
|
}
|
|
|
|
|
2013-12-20 11:01:50 +01:00
|
|
|
static void gen_qemu_ld32u_i64(DisasContext *ctx, TCGv_i64 val, TCGv addr)
|
|
|
|
{
|
|
|
|
TCGv tmp = tcg_temp_new();
|
|
|
|
gen_qemu_ld32u(ctx, tmp, addr);
|
|
|
|
tcg_gen_extu_tl_i64(val, tmp);
|
|
|
|
tcg_temp_free(tmp);
|
|
|
|
}
|
|
|
|
|
2009-08-16 11:06:54 +02:00
|
|
|
static inline void gen_qemu_ld32s(DisasContext *ctx, TCGv arg1, TCGv arg2)
|
2008-10-15 19:00:37 +02:00
|
|
|
{
|
2014-05-29 16:12:20 +02:00
|
|
|
TCGMemOp op = MO_SL | ctx->default_tcg_memop_mask;
|
|
|
|
tcg_gen_qemu_ld_tl(arg1, arg2, ctx->mem_idx, op);
|
2008-10-15 19:00:37 +02:00
|
|
|
}
|
|
|
|
|
2014-01-15 15:10:30 +01:00
|
|
|
static void gen_qemu_ld32s_i64(DisasContext *ctx, TCGv_i64 val, TCGv addr)
|
|
|
|
{
|
|
|
|
TCGv tmp = tcg_temp_new();
|
|
|
|
gen_qemu_ld32s(ctx, tmp, addr);
|
|
|
|
tcg_gen_ext_tl_i64(val, tmp);
|
|
|
|
tcg_temp_free(tmp);
|
|
|
|
}
|
|
|
|
|
2009-08-16 11:06:54 +02:00
|
|
|
static inline void gen_qemu_ld64(DisasContext *ctx, TCGv_i64 arg1, TCGv arg2)
|
2008-10-15 19:00:37 +02:00
|
|
|
{
|
2014-05-29 16:12:20 +02:00
|
|
|
TCGMemOp op = MO_Q | ctx->default_tcg_memop_mask;
|
|
|
|
tcg_gen_qemu_ld_i64(arg1, arg2, ctx->mem_idx, op);
|
2008-10-15 19:00:37 +02:00
|
|
|
}
|
|
|
|
|
2009-08-16 11:06:54 +02:00
|
|
|
static inline void gen_qemu_st8(DisasContext *ctx, TCGv arg1, TCGv arg2)
|
2008-10-15 19:00:37 +02:00
|
|
|
{
|
2008-12-08 19:11:21 +01:00
|
|
|
tcg_gen_qemu_st8(arg1, arg2, ctx->mem_idx);
|
2008-10-15 19:00:37 +02:00
|
|
|
}
|
|
|
|
|
2009-08-16 11:06:54 +02:00
|
|
|
static inline void gen_qemu_st16(DisasContext *ctx, TCGv arg1, TCGv arg2)
|
2008-10-15 19:00:37 +02:00
|
|
|
{
|
2014-05-29 16:12:20 +02:00
|
|
|
TCGMemOp op = MO_UW | ctx->default_tcg_memop_mask;
|
|
|
|
tcg_gen_qemu_st_tl(arg1, arg2, ctx->mem_idx, op);
|
2008-10-15 19:00:37 +02:00
|
|
|
}
|
|
|
|
|
2009-08-16 11:06:54 +02:00
|
|
|
static inline void gen_qemu_st32(DisasContext *ctx, TCGv arg1, TCGv arg2)
|
2008-10-15 19:00:37 +02:00
|
|
|
{
|
2014-05-29 16:12:20 +02:00
|
|
|
TCGMemOp op = MO_UL | ctx->default_tcg_memop_mask;
|
|
|
|
tcg_gen_qemu_st_tl(arg1, arg2, ctx->mem_idx, op);
|
2008-10-15 19:00:37 +02:00
|
|
|
}
|
|
|
|
|
2013-12-20 11:01:50 +01:00
|
|
|
static void gen_qemu_st32_i64(DisasContext *ctx, TCGv_i64 val, TCGv addr)
|
|
|
|
{
|
|
|
|
TCGv tmp = tcg_temp_new();
|
|
|
|
tcg_gen_trunc_i64_tl(tmp, val);
|
|
|
|
gen_qemu_st32(ctx, tmp, addr);
|
|
|
|
tcg_temp_free(tmp);
|
|
|
|
}
|
|
|
|
|
2009-08-16 11:06:54 +02:00
|
|
|
static inline void gen_qemu_st64(DisasContext *ctx, TCGv_i64 arg1, TCGv arg2)
|
2008-10-15 19:00:37 +02:00
|
|
|
{
|
2014-05-29 16:12:20 +02:00
|
|
|
TCGMemOp op = MO_Q | ctx->default_tcg_memop_mask;
|
|
|
|
tcg_gen_qemu_st_i64(arg1, arg2, ctx->mem_idx, op);
|
2008-10-15 19:00:37 +02:00
|
|
|
}
|
|
|
|
|
2008-11-23 17:30:28 +01:00
|
|
|
#define GEN_LD(name, ldop, opc, type) \
|
2009-06-17 17:22:09 +02:00
|
|
|
static void glue(gen_, name)(DisasContext *ctx) \
|
2003-11-23 15:55:54 +01:00
|
|
|
{ \
|
2008-12-08 19:11:21 +01:00
|
|
|
TCGv EA; \
|
|
|
|
gen_set_access_type(ctx, ACCESS_INT); \
|
|
|
|
EA = tcg_temp_new(); \
|
|
|
|
gen_addr_imm_index(ctx, EA, 0); \
|
|
|
|
gen_qemu_##ldop(ctx, cpu_gpr[rD(ctx->opcode)], EA); \
|
2008-10-15 19:00:37 +02:00
|
|
|
tcg_temp_free(EA); \
|
2003-11-23 15:55:54 +01:00
|
|
|
}
|
|
|
|
|
2008-11-23 17:30:28 +01:00
|
|
|
#define GEN_LDU(name, ldop, opc, type) \
|
2009-06-17 17:22:09 +02:00
|
|
|
static void glue(gen_, name##u)(DisasContext *ctx) \
|
2003-11-23 15:55:54 +01:00
|
|
|
{ \
|
2008-10-15 19:00:37 +02:00
|
|
|
TCGv EA; \
|
2007-03-07 09:32:30 +01:00
|
|
|
if (unlikely(rA(ctx->opcode) == 0 || \
|
|
|
|
rA(ctx->opcode) == rD(ctx->opcode))) { \
|
2008-12-11 23:42:14 +01:00
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_INVAL_INVAL); \
|
2004-05-21 14:59:32 +02:00
|
|
|
return; \
|
2004-01-04 23:58:38 +01:00
|
|
|
} \
|
2008-12-08 19:11:21 +01:00
|
|
|
gen_set_access_type(ctx, ACCESS_INT); \
|
2008-11-23 17:30:28 +01:00
|
|
|
EA = tcg_temp_new(); \
|
2007-04-06 09:59:47 +02:00
|
|
|
if (type == PPC_64B) \
|
2008-12-08 19:11:21 +01:00
|
|
|
gen_addr_imm_index(ctx, EA, 0x03); \
|
2007-04-06 09:59:47 +02:00
|
|
|
else \
|
2008-12-08 19:11:21 +01:00
|
|
|
gen_addr_imm_index(ctx, EA, 0); \
|
|
|
|
gen_qemu_##ldop(ctx, cpu_gpr[rD(ctx->opcode)], EA); \
|
2008-10-15 19:00:37 +02:00
|
|
|
tcg_gen_mov_tl(cpu_gpr[rA(ctx->opcode)], EA); \
|
|
|
|
tcg_temp_free(EA); \
|
2003-11-23 15:55:54 +01:00
|
|
|
}
|
|
|
|
|
2008-11-23 17:30:28 +01:00
|
|
|
#define GEN_LDUX(name, ldop, opc2, opc3, type) \
|
2009-06-17 17:22:09 +02:00
|
|
|
static void glue(gen_, name##ux)(DisasContext *ctx) \
|
2003-11-23 15:55:54 +01:00
|
|
|
{ \
|
2008-10-15 19:00:37 +02:00
|
|
|
TCGv EA; \
|
2007-03-07 09:32:30 +01:00
|
|
|
if (unlikely(rA(ctx->opcode) == 0 || \
|
|
|
|
rA(ctx->opcode) == rD(ctx->opcode))) { \
|
2008-12-11 23:42:14 +01:00
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_INVAL_INVAL); \
|
2004-05-21 14:59:32 +02:00
|
|
|
return; \
|
2004-01-04 23:58:38 +01:00
|
|
|
} \
|
2008-12-08 19:11:21 +01:00
|
|
|
gen_set_access_type(ctx, ACCESS_INT); \
|
2008-11-23 17:30:28 +01:00
|
|
|
EA = tcg_temp_new(); \
|
2008-12-08 19:11:21 +01:00
|
|
|
gen_addr_reg_index(ctx, EA); \
|
|
|
|
gen_qemu_##ldop(ctx, cpu_gpr[rD(ctx->opcode)], EA); \
|
2008-10-15 19:00:37 +02:00
|
|
|
tcg_gen_mov_tl(cpu_gpr[rA(ctx->opcode)], EA); \
|
|
|
|
tcg_temp_free(EA); \
|
2003-11-23 15:55:54 +01:00
|
|
|
}
|
|
|
|
|
2012-02-27 18:18:08 +01:00
|
|
|
#define GEN_LDX_E(name, ldop, opc2, opc3, type, type2) \
|
2009-06-17 17:22:09 +02:00
|
|
|
static void glue(gen_, name##x)(DisasContext *ctx) \
|
2003-11-23 15:55:54 +01:00
|
|
|
{ \
|
2008-12-08 19:11:21 +01:00
|
|
|
TCGv EA; \
|
|
|
|
gen_set_access_type(ctx, ACCESS_INT); \
|
|
|
|
EA = tcg_temp_new(); \
|
|
|
|
gen_addr_reg_index(ctx, EA); \
|
|
|
|
gen_qemu_##ldop(ctx, cpu_gpr[rD(ctx->opcode)], EA); \
|
2008-10-15 19:00:37 +02:00
|
|
|
tcg_temp_free(EA); \
|
2003-11-23 15:55:54 +01:00
|
|
|
}
|
2012-02-27 18:18:08 +01:00
|
|
|
#define GEN_LDX(name, ldop, opc2, opc3, type) \
|
|
|
|
GEN_LDX_E(name, ldop, opc2, opc3, type, PPC_NONE)
|
2003-11-23 15:55:54 +01:00
|
|
|
|
2008-11-23 17:30:28 +01:00
|
|
|
#define GEN_LDS(name, ldop, op, type) \
|
|
|
|
GEN_LD(name, ldop, op | 0x20, type); \
|
|
|
|
GEN_LDU(name, ldop, op | 0x21, type); \
|
|
|
|
GEN_LDUX(name, ldop, 0x17, op | 0x01, type); \
|
|
|
|
GEN_LDX(name, ldop, 0x17, op | 0x00, type)
|
2003-11-23 15:55:54 +01:00
|
|
|
|
|
|
|
/* lbz lbzu lbzux lbzx */
|
2008-11-23 17:30:28 +01:00
|
|
|
GEN_LDS(lbz, ld8u, 0x02, PPC_INTEGER);
|
2003-11-23 15:55:54 +01:00
|
|
|
/* lha lhau lhaux lhax */
|
2008-11-23 17:30:28 +01:00
|
|
|
GEN_LDS(lha, ld16s, 0x0A, PPC_INTEGER);
|
2003-11-23 15:55:54 +01:00
|
|
|
/* lhz lhzu lhzux lhzx */
|
2008-11-23 17:30:28 +01:00
|
|
|
GEN_LDS(lhz, ld16u, 0x08, PPC_INTEGER);
|
2003-11-23 15:55:54 +01:00
|
|
|
/* lwz lwzu lwzux lwzx */
|
2008-11-23 17:30:28 +01:00
|
|
|
GEN_LDS(lwz, ld32u, 0x00, PPC_INTEGER);
|
2007-03-17 15:02:15 +01:00
|
|
|
#if defined(TARGET_PPC64)
|
|
|
|
/* lwaux */
|
2008-11-23 17:30:28 +01:00
|
|
|
GEN_LDUX(lwa, ld32s, 0x15, 0x0B, PPC_64B);
|
2007-03-17 15:02:15 +01:00
|
|
|
/* lwax */
|
2008-11-23 17:30:28 +01:00
|
|
|
GEN_LDX(lwa, ld32s, 0x15, 0x0A, PPC_64B);
|
2007-03-17 15:02:15 +01:00
|
|
|
/* ldux */
|
2008-11-23 17:30:28 +01:00
|
|
|
GEN_LDUX(ld, ld64, 0x15, 0x01, PPC_64B);
|
2007-03-17 15:02:15 +01:00
|
|
|
/* ldx */
|
2008-11-23 17:30:28 +01:00
|
|
|
GEN_LDX(ld, ld64, 0x15, 0x00, PPC_64B);
|
2009-06-17 17:22:09 +02:00
|
|
|
|
|
|
|
static void gen_ld(DisasContext *ctx)
|
2007-03-17 15:02:15 +01:00
|
|
|
{
|
2008-10-15 19:00:37 +02:00
|
|
|
TCGv EA;
|
2007-03-17 15:02:15 +01:00
|
|
|
if (Rc(ctx->opcode)) {
|
|
|
|
if (unlikely(rA(ctx->opcode) == 0 ||
|
|
|
|
rA(ctx->opcode) == rD(ctx->opcode))) {
|
2008-12-11 23:42:14 +01:00
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_INVAL_INVAL);
|
2007-03-17 15:02:15 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2008-12-08 19:11:21 +01:00
|
|
|
gen_set_access_type(ctx, ACCESS_INT);
|
2008-11-17 15:43:54 +01:00
|
|
|
EA = tcg_temp_new();
|
2008-12-08 19:11:21 +01:00
|
|
|
gen_addr_imm_index(ctx, EA, 0x03);
|
2007-03-17 15:02:15 +01:00
|
|
|
if (ctx->opcode & 0x02) {
|
|
|
|
/* lwa (lwau is undefined) */
|
2008-12-08 19:11:21 +01:00
|
|
|
gen_qemu_ld32s(ctx, cpu_gpr[rD(ctx->opcode)], EA);
|
2007-03-17 15:02:15 +01:00
|
|
|
} else {
|
|
|
|
/* ld - ldu */
|
2008-12-08 19:11:21 +01:00
|
|
|
gen_qemu_ld64(ctx, cpu_gpr[rD(ctx->opcode)], EA);
|
2007-03-17 15:02:15 +01:00
|
|
|
}
|
|
|
|
if (Rc(ctx->opcode))
|
2008-10-15 19:00:37 +02:00
|
|
|
tcg_gen_mov_tl(cpu_gpr[rA(ctx->opcode)], EA);
|
|
|
|
tcg_temp_free(EA);
|
2007-03-17 15:02:15 +01:00
|
|
|
}
|
2009-06-17 17:22:09 +02:00
|
|
|
|
2009-06-17 17:22:19 +02:00
|
|
|
/* lq */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_lq(DisasContext *ctx)
|
2007-09-30 15:03:23 +02:00
|
|
|
{
|
|
|
|
int ra, rd;
|
2008-10-15 19:00:37 +02:00
|
|
|
TCGv EA;
|
2007-09-30 15:03:23 +02:00
|
|
|
|
2014-02-10 18:26:58 +01:00
|
|
|
/* lq is a legal user mode instruction starting in ISA 2.07 */
|
|
|
|
bool legal_in_user_mode = (ctx->insns_flags2 & PPC2_LSQ_ISA207) != 0;
|
|
|
|
bool le_is_supported = (ctx->insns_flags2 & PPC2_LSQ_ISA207) != 0;
|
|
|
|
|
2014-09-15 17:03:28 +02:00
|
|
|
if (!legal_in_user_mode && ctx->pr) {
|
2008-12-11 23:42:14 +01:00
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);
|
2007-09-30 15:03:23 +02:00
|
|
|
return;
|
|
|
|
}
|
2014-02-10 18:26:58 +01:00
|
|
|
|
|
|
|
if (!le_is_supported && ctx->le_mode) {
|
|
|
|
gen_exception_err(ctx, POWERPC_EXCP_ALIGN, POWERPC_EXCP_ALIGN_LE);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2007-09-30 15:03:23 +02:00
|
|
|
ra = rA(ctx->opcode);
|
|
|
|
rd = rD(ctx->opcode);
|
|
|
|
if (unlikely((rd & 1) || rd == ra)) {
|
2008-12-11 23:42:14 +01:00
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_INVAL_INVAL);
|
2007-09-30 15:03:23 +02:00
|
|
|
return;
|
|
|
|
}
|
2014-02-10 18:26:58 +01:00
|
|
|
|
2008-12-08 19:11:21 +01:00
|
|
|
gen_set_access_type(ctx, ACCESS_INT);
|
2008-11-17 15:43:54 +01:00
|
|
|
EA = tcg_temp_new();
|
2008-12-08 19:11:21 +01:00
|
|
|
gen_addr_imm_index(ctx, EA, 0x0F);
|
2014-02-10 18:26:58 +01:00
|
|
|
|
2014-05-29 16:12:20 +02:00
|
|
|
/* We only need to swap high and low halves. gen_qemu_ld64 does necessary
|
|
|
|
64-bit byteswap already. */
|
2014-02-10 18:26:58 +01:00
|
|
|
if (unlikely(ctx->le_mode)) {
|
|
|
|
gen_qemu_ld64(ctx, cpu_gpr[rd+1], EA);
|
|
|
|
gen_addr_add(ctx, EA, EA, 8);
|
|
|
|
gen_qemu_ld64(ctx, cpu_gpr[rd], EA);
|
|
|
|
} else {
|
|
|
|
gen_qemu_ld64(ctx, cpu_gpr[rd], EA);
|
|
|
|
gen_addr_add(ctx, EA, EA, 8);
|
|
|
|
gen_qemu_ld64(ctx, cpu_gpr[rd+1], EA);
|
|
|
|
}
|
2008-10-15 19:00:37 +02:00
|
|
|
tcg_temp_free(EA);
|
2007-09-30 15:03:23 +02:00
|
|
|
}
|
2007-03-17 15:02:15 +01:00
|
|
|
#endif
|
2003-11-23 15:55:54 +01:00
|
|
|
|
|
|
|
/*** Integer store ***/
|
2008-11-23 17:30:28 +01:00
|
|
|
#define GEN_ST(name, stop, opc, type) \
|
2009-06-17 17:22:09 +02:00
|
|
|
static void glue(gen_, name)(DisasContext *ctx) \
|
2003-11-23 15:55:54 +01:00
|
|
|
{ \
|
2008-12-08 19:11:21 +01:00
|
|
|
TCGv EA; \
|
|
|
|
gen_set_access_type(ctx, ACCESS_INT); \
|
|
|
|
EA = tcg_temp_new(); \
|
|
|
|
gen_addr_imm_index(ctx, EA, 0); \
|
|
|
|
gen_qemu_##stop(ctx, cpu_gpr[rS(ctx->opcode)], EA); \
|
2008-10-15 19:00:37 +02:00
|
|
|
tcg_temp_free(EA); \
|
2003-11-23 15:55:54 +01:00
|
|
|
}
|
|
|
|
|
2008-11-23 17:30:28 +01:00
|
|
|
#define GEN_STU(name, stop, opc, type) \
|
2009-06-17 17:22:09 +02:00
|
|
|
static void glue(gen_, stop##u)(DisasContext *ctx) \
|
2003-11-23 15:55:54 +01:00
|
|
|
{ \
|
2008-10-15 19:00:37 +02:00
|
|
|
TCGv EA; \
|
2007-03-07 09:32:30 +01:00
|
|
|
if (unlikely(rA(ctx->opcode) == 0)) { \
|
2008-12-11 23:42:14 +01:00
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_INVAL_INVAL); \
|
2004-05-21 14:59:32 +02:00
|
|
|
return; \
|
2004-01-04 23:58:38 +01:00
|
|
|
} \
|
2008-12-08 19:11:21 +01:00
|
|
|
gen_set_access_type(ctx, ACCESS_INT); \
|
2008-11-23 17:30:28 +01:00
|
|
|
EA = tcg_temp_new(); \
|
2007-04-06 09:59:47 +02:00
|
|
|
if (type == PPC_64B) \
|
2008-12-08 19:11:21 +01:00
|
|
|
gen_addr_imm_index(ctx, EA, 0x03); \
|
2007-04-06 09:59:47 +02:00
|
|
|
else \
|
2008-12-08 19:11:21 +01:00
|
|
|
gen_addr_imm_index(ctx, EA, 0); \
|
|
|
|
gen_qemu_##stop(ctx, cpu_gpr[rS(ctx->opcode)], EA); \
|
2008-10-15 19:00:37 +02:00
|
|
|
tcg_gen_mov_tl(cpu_gpr[rA(ctx->opcode)], EA); \
|
|
|
|
tcg_temp_free(EA); \
|
2003-11-23 15:55:54 +01:00
|
|
|
}
|
|
|
|
|
2008-11-23 17:30:28 +01:00
|
|
|
#define GEN_STUX(name, stop, opc2, opc3, type) \
|
2009-06-17 17:22:09 +02:00
|
|
|
static void glue(gen_, name##ux)(DisasContext *ctx) \
|
2003-11-23 15:55:54 +01:00
|
|
|
{ \
|
2008-10-15 19:00:37 +02:00
|
|
|
TCGv EA; \
|
2007-03-07 09:32:30 +01:00
|
|
|
if (unlikely(rA(ctx->opcode) == 0)) { \
|
2008-12-11 23:42:14 +01:00
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_INVAL_INVAL); \
|
2004-05-21 14:59:32 +02:00
|
|
|
return; \
|
2004-01-04 23:58:38 +01:00
|
|
|
} \
|
2008-12-08 19:11:21 +01:00
|
|
|
gen_set_access_type(ctx, ACCESS_INT); \
|
2008-11-23 17:30:28 +01:00
|
|
|
EA = tcg_temp_new(); \
|
2008-12-08 19:11:21 +01:00
|
|
|
gen_addr_reg_index(ctx, EA); \
|
|
|
|
gen_qemu_##stop(ctx, cpu_gpr[rS(ctx->opcode)], EA); \
|
2008-10-15 19:00:37 +02:00
|
|
|
tcg_gen_mov_tl(cpu_gpr[rA(ctx->opcode)], EA); \
|
|
|
|
tcg_temp_free(EA); \
|
2003-11-23 15:55:54 +01:00
|
|
|
}
|
|
|
|
|
2012-02-27 18:18:08 +01:00
|
|
|
#define GEN_STX_E(name, stop, opc2, opc3, type, type2) \
|
|
|
|
static void glue(gen_, name##x)(DisasContext *ctx) \
|
2003-11-23 15:55:54 +01:00
|
|
|
{ \
|
2008-12-08 19:11:21 +01:00
|
|
|
TCGv EA; \
|
|
|
|
gen_set_access_type(ctx, ACCESS_INT); \
|
|
|
|
EA = tcg_temp_new(); \
|
|
|
|
gen_addr_reg_index(ctx, EA); \
|
|
|
|
gen_qemu_##stop(ctx, cpu_gpr[rS(ctx->opcode)], EA); \
|
2008-10-15 19:00:37 +02:00
|
|
|
tcg_temp_free(EA); \
|
2003-11-23 15:55:54 +01:00
|
|
|
}
|
2012-02-27 18:18:08 +01:00
|
|
|
#define GEN_STX(name, stop, opc2, opc3, type) \
|
|
|
|
GEN_STX_E(name, stop, opc2, opc3, type, PPC_NONE)
|
2003-11-23 15:55:54 +01:00
|
|
|
|
2008-11-23 17:30:28 +01:00
|
|
|
#define GEN_STS(name, stop, op, type) \
|
|
|
|
GEN_ST(name, stop, op | 0x20, type); \
|
|
|
|
GEN_STU(name, stop, op | 0x21, type); \
|
|
|
|
GEN_STUX(name, stop, 0x17, op | 0x01, type); \
|
|
|
|
GEN_STX(name, stop, 0x17, op | 0x00, type)
|
2003-11-23 15:55:54 +01:00
|
|
|
|
|
|
|
/* stb stbu stbux stbx */
|
2008-11-23 17:30:28 +01:00
|
|
|
GEN_STS(stb, st8, 0x06, PPC_INTEGER);
|
2003-11-23 15:55:54 +01:00
|
|
|
/* sth sthu sthux sthx */
|
2008-11-23 17:30:28 +01:00
|
|
|
GEN_STS(sth, st16, 0x0C, PPC_INTEGER);
|
2003-11-23 15:55:54 +01:00
|
|
|
/* stw stwu stwux stwx */
|
2008-11-23 17:30:28 +01:00
|
|
|
GEN_STS(stw, st32, 0x04, PPC_INTEGER);
|
2007-03-17 15:02:15 +01:00
|
|
|
#if defined(TARGET_PPC64)
|
2008-11-23 17:30:28 +01:00
|
|
|
GEN_STUX(std, st64, 0x15, 0x05, PPC_64B);
|
|
|
|
GEN_STX(std, st64, 0x15, 0x04, PPC_64B);
|
2009-06-17 17:22:09 +02:00
|
|
|
|
|
|
|
static void gen_std(DisasContext *ctx)
|
2007-03-17 15:02:15 +01:00
|
|
|
{
|
2007-09-30 15:03:23 +02:00
|
|
|
int rs;
|
2008-10-15 19:00:37 +02:00
|
|
|
TCGv EA;
|
2007-09-30 15:03:23 +02:00
|
|
|
|
|
|
|
rs = rS(ctx->opcode);
|
2014-02-10 18:26:59 +01:00
|
|
|
if ((ctx->opcode & 0x3) == 0x2) { /* stq */
|
|
|
|
|
|
|
|
bool legal_in_user_mode = (ctx->insns_flags2 & PPC2_LSQ_ISA207) != 0;
|
|
|
|
bool le_is_supported = (ctx->insns_flags2 & PPC2_LSQ_ISA207) != 0;
|
|
|
|
|
2014-09-15 17:03:28 +02:00
|
|
|
if (!legal_in_user_mode && ctx->pr) {
|
2008-12-11 23:42:14 +01:00
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);
|
2007-09-30 15:03:23 +02:00
|
|
|
return;
|
|
|
|
}
|
2014-02-10 18:26:59 +01:00
|
|
|
|
|
|
|
if (!le_is_supported && ctx->le_mode) {
|
|
|
|
gen_exception_err(ctx, POWERPC_EXCP_ALIGN, POWERPC_EXCP_ALIGN_LE);
|
2007-03-17 15:02:15 +01:00
|
|
|
return;
|
|
|
|
}
|
2014-02-10 18:26:59 +01:00
|
|
|
|
|
|
|
if (unlikely(rs & 1)) {
|
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_INVAL_INVAL);
|
2007-09-30 15:03:23 +02:00
|
|
|
return;
|
|
|
|
}
|
2008-12-08 19:11:21 +01:00
|
|
|
gen_set_access_type(ctx, ACCESS_INT);
|
2008-11-17 15:43:54 +01:00
|
|
|
EA = tcg_temp_new();
|
2008-12-08 19:11:21 +01:00
|
|
|
gen_addr_imm_index(ctx, EA, 0x03);
|
2014-02-10 18:26:59 +01:00
|
|
|
|
2014-05-29 16:12:20 +02:00
|
|
|
/* We only need to swap high and low halves. gen_qemu_st64 does
|
|
|
|
necessary 64-bit byteswap already. */
|
2014-02-10 18:26:59 +01:00
|
|
|
if (unlikely(ctx->le_mode)) {
|
|
|
|
gen_qemu_st64(ctx, cpu_gpr[rs+1], EA);
|
|
|
|
gen_addr_add(ctx, EA, EA, 8);
|
|
|
|
gen_qemu_st64(ctx, cpu_gpr[rs], EA);
|
|
|
|
} else {
|
|
|
|
gen_qemu_st64(ctx, cpu_gpr[rs], EA);
|
|
|
|
gen_addr_add(ctx, EA, EA, 8);
|
|
|
|
gen_qemu_st64(ctx, cpu_gpr[rs+1], EA);
|
|
|
|
}
|
2008-10-15 19:00:37 +02:00
|
|
|
tcg_temp_free(EA);
|
2007-09-30 15:03:23 +02:00
|
|
|
} else {
|
2014-02-10 18:26:59 +01:00
|
|
|
/* std / stdu*/
|
2007-09-30 15:03:23 +02:00
|
|
|
if (Rc(ctx->opcode)) {
|
|
|
|
if (unlikely(rA(ctx->opcode) == 0)) {
|
2008-12-11 23:42:14 +01:00
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_INVAL_INVAL);
|
2007-09-30 15:03:23 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2008-12-08 19:11:21 +01:00
|
|
|
gen_set_access_type(ctx, ACCESS_INT);
|
2008-11-17 15:43:54 +01:00
|
|
|
EA = tcg_temp_new();
|
2008-12-08 19:11:21 +01:00
|
|
|
gen_addr_imm_index(ctx, EA, 0x03);
|
|
|
|
gen_qemu_st64(ctx, cpu_gpr[rs], EA);
|
2007-09-30 15:03:23 +02:00
|
|
|
if (Rc(ctx->opcode))
|
2008-10-15 19:00:37 +02:00
|
|
|
tcg_gen_mov_tl(cpu_gpr[rA(ctx->opcode)], EA);
|
|
|
|
tcg_temp_free(EA);
|
2007-03-17 15:02:15 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
2003-11-23 15:55:54 +01:00
|
|
|
/*** Integer load and store with byte reverse ***/
|
2014-05-29 16:12:20 +02:00
|
|
|
|
2003-11-23 15:55:54 +01:00
|
|
|
/* lhbrx */
|
2009-09-23 01:19:00 +02:00
|
|
|
static inline void gen_qemu_ld16ur(DisasContext *ctx, TCGv arg1, TCGv arg2)
|
2008-10-15 19:00:37 +02:00
|
|
|
{
|
2014-05-29 16:12:20 +02:00
|
|
|
TCGMemOp op = MO_UW | (ctx->default_tcg_memop_mask ^ MO_BSWAP);
|
|
|
|
tcg_gen_qemu_ld_tl(arg1, arg2, ctx->mem_idx, op);
|
2008-10-15 19:00:37 +02:00
|
|
|
}
|
2008-11-23 17:30:28 +01:00
|
|
|
GEN_LDX(lhbr, ld16ur, 0x16, 0x18, PPC_INTEGER);
|
2008-10-15 19:00:37 +02:00
|
|
|
|
2003-11-23 15:55:54 +01:00
|
|
|
/* lwbrx */
|
2009-09-23 01:19:00 +02:00
|
|
|
static inline void gen_qemu_ld32ur(DisasContext *ctx, TCGv arg1, TCGv arg2)
|
2008-10-15 19:00:37 +02:00
|
|
|
{
|
2014-05-29 16:12:20 +02:00
|
|
|
TCGMemOp op = MO_UL | (ctx->default_tcg_memop_mask ^ MO_BSWAP);
|
|
|
|
tcg_gen_qemu_ld_tl(arg1, arg2, ctx->mem_idx, op);
|
2008-10-15 19:00:37 +02:00
|
|
|
}
|
2008-11-23 17:30:28 +01:00
|
|
|
GEN_LDX(lwbr, ld32ur, 0x16, 0x10, PPC_INTEGER);
|
2008-10-15 19:00:37 +02:00
|
|
|
|
2012-02-27 18:18:08 +01:00
|
|
|
#if defined(TARGET_PPC64)
|
|
|
|
/* ldbrx */
|
|
|
|
static inline void gen_qemu_ld64ur(DisasContext *ctx, TCGv arg1, TCGv arg2)
|
|
|
|
{
|
2014-05-29 16:12:20 +02:00
|
|
|
TCGMemOp op = MO_Q | (ctx->default_tcg_memop_mask ^ MO_BSWAP);
|
|
|
|
tcg_gen_qemu_ld_i64(arg1, arg2, ctx->mem_idx, op);
|
2012-02-27 18:18:08 +01:00
|
|
|
}
|
|
|
|
GEN_LDX_E(ldbr, ld64ur, 0x14, 0x10, PPC_NONE, PPC2_DBRX);
|
|
|
|
#endif /* TARGET_PPC64 */
|
|
|
|
|
2003-11-23 15:55:54 +01:00
|
|
|
/* sthbrx */
|
2009-09-23 01:19:00 +02:00
|
|
|
static inline void gen_qemu_st16r(DisasContext *ctx, TCGv arg1, TCGv arg2)
|
2008-10-15 19:00:37 +02:00
|
|
|
{
|
2014-05-29 16:12:20 +02:00
|
|
|
TCGMemOp op = MO_UW | (ctx->default_tcg_memop_mask ^ MO_BSWAP);
|
|
|
|
tcg_gen_qemu_st_tl(arg1, arg2, ctx->mem_idx, op);
|
2008-10-15 19:00:37 +02:00
|
|
|
}
|
2008-11-23 17:30:28 +01:00
|
|
|
GEN_STX(sthbr, st16r, 0x16, 0x1C, PPC_INTEGER);
|
2008-10-15 19:00:37 +02:00
|
|
|
|
2003-11-23 15:55:54 +01:00
|
|
|
/* stwbrx */
|
2009-09-23 01:19:00 +02:00
|
|
|
static inline void gen_qemu_st32r(DisasContext *ctx, TCGv arg1, TCGv arg2)
|
2008-10-15 19:00:37 +02:00
|
|
|
{
|
2014-05-29 16:12:20 +02:00
|
|
|
TCGMemOp op = MO_UL | (ctx->default_tcg_memop_mask ^ MO_BSWAP);
|
|
|
|
tcg_gen_qemu_st_tl(arg1, arg2, ctx->mem_idx, op);
|
2008-10-15 19:00:37 +02:00
|
|
|
}
|
2008-11-23 17:30:28 +01:00
|
|
|
GEN_STX(stwbr, st32r, 0x16, 0x14, PPC_INTEGER);
|
2003-11-23 15:55:54 +01:00
|
|
|
|
2012-02-27 18:18:08 +01:00
|
|
|
#if defined(TARGET_PPC64)
|
|
|
|
/* stdbrx */
|
|
|
|
static inline void gen_qemu_st64r(DisasContext *ctx, TCGv arg1, TCGv arg2)
|
|
|
|
{
|
2014-05-29 16:12:20 +02:00
|
|
|
TCGMemOp op = MO_Q | (ctx->default_tcg_memop_mask ^ MO_BSWAP);
|
|
|
|
tcg_gen_qemu_st_i64(arg1, arg2, ctx->mem_idx, op);
|
2012-02-27 18:18:08 +01:00
|
|
|
}
|
|
|
|
GEN_STX_E(stdbr, st64r, 0x14, 0x14, PPC_NONE, PPC2_DBRX);
|
|
|
|
#endif /* TARGET_PPC64 */
|
|
|
|
|
2003-11-23 15:55:54 +01:00
|
|
|
/*** Integer load and store multiple ***/
|
2009-06-17 17:22:09 +02:00
|
|
|
|
2009-06-17 17:22:19 +02:00
|
|
|
/* lmw */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_lmw(DisasContext *ctx)
|
2003-11-23 15:55:54 +01:00
|
|
|
{
|
2008-12-08 19:11:21 +01:00
|
|
|
TCGv t0;
|
|
|
|
TCGv_i32 t1;
|
|
|
|
gen_set_access_type(ctx, ACCESS_INT);
|
2007-03-07 09:32:30 +01:00
|
|
|
/* NIP cannot be restored if the memory exception comes from an helper */
|
2007-03-17 15:02:15 +01:00
|
|
|
gen_update_nip(ctx, ctx->nip - 4);
|
2008-12-08 19:11:21 +01:00
|
|
|
t0 = tcg_temp_new();
|
|
|
|
t1 = tcg_const_i32(rD(ctx->opcode));
|
|
|
|
gen_addr_imm_index(ctx, t0, 0);
|
2012-05-30 06:23:40 +02:00
|
|
|
gen_helper_lmw(cpu_env, t0, t1);
|
2008-11-30 17:23:56 +01:00
|
|
|
tcg_temp_free(t0);
|
|
|
|
tcg_temp_free_i32(t1);
|
2003-11-23 15:55:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* stmw */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_stmw(DisasContext *ctx)
|
2003-11-23 15:55:54 +01:00
|
|
|
{
|
2008-12-08 19:11:21 +01:00
|
|
|
TCGv t0;
|
|
|
|
TCGv_i32 t1;
|
|
|
|
gen_set_access_type(ctx, ACCESS_INT);
|
2007-03-07 09:32:30 +01:00
|
|
|
/* NIP cannot be restored if the memory exception comes from an helper */
|
2007-03-17 15:02:15 +01:00
|
|
|
gen_update_nip(ctx, ctx->nip - 4);
|
2008-12-08 19:11:21 +01:00
|
|
|
t0 = tcg_temp_new();
|
|
|
|
t1 = tcg_const_i32(rS(ctx->opcode));
|
|
|
|
gen_addr_imm_index(ctx, t0, 0);
|
2012-05-30 06:23:40 +02:00
|
|
|
gen_helper_stmw(cpu_env, t0, t1);
|
2008-11-30 17:23:56 +01:00
|
|
|
tcg_temp_free(t0);
|
|
|
|
tcg_temp_free_i32(t1);
|
2003-11-23 15:55:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*** Integer load and store strings ***/
|
2009-06-17 17:22:19 +02:00
|
|
|
|
2003-11-23 15:55:54 +01:00
|
|
|
/* lswi */
|
2005-07-02 22:59:34 +02:00
|
|
|
/* PowerPC32 specification says we must generate an exception if
|
2004-01-04 23:58:38 +01:00
|
|
|
* rA is in the range of registers to be loaded.
|
|
|
|
* In an other hand, IBM says this is valid, but rA won't be loaded.
|
|
|
|
* For now, I'll follow the spec...
|
|
|
|
*/
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_lswi(DisasContext *ctx)
|
2003-11-23 15:55:54 +01:00
|
|
|
{
|
2008-11-30 17:24:21 +01:00
|
|
|
TCGv t0;
|
|
|
|
TCGv_i32 t1, t2;
|
2003-11-23 15:55:54 +01:00
|
|
|
int nb = NB(ctx->opcode);
|
|
|
|
int start = rD(ctx->opcode);
|
2004-01-04 23:58:38 +01:00
|
|
|
int ra = rA(ctx->opcode);
|
2003-11-23 15:55:54 +01:00
|
|
|
int nr;
|
|
|
|
|
|
|
|
if (nb == 0)
|
|
|
|
nb = 32;
|
2016-04-14 17:14:52 +02:00
|
|
|
nr = (nb + 3) / 4;
|
|
|
|
if (unlikely(lsw_reg_in_range(start, nr, ra))) {
|
2008-12-11 23:42:14 +01:00
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_INVAL_LSWX);
|
2004-05-21 14:59:32 +02:00
|
|
|
return;
|
2004-02-21 15:11:27 +01:00
|
|
|
}
|
2008-12-08 19:11:21 +01:00
|
|
|
gen_set_access_type(ctx, ACCESS_INT);
|
2005-06-05 00:22:27 +02:00
|
|
|
/* NIP cannot be restored if the memory exception comes from an helper */
|
2007-03-17 15:02:15 +01:00
|
|
|
gen_update_nip(ctx, ctx->nip - 4);
|
2008-11-30 17:24:21 +01:00
|
|
|
t0 = tcg_temp_new();
|
2008-12-08 19:11:21 +01:00
|
|
|
gen_addr_register(ctx, t0);
|
2008-11-30 17:24:21 +01:00
|
|
|
t1 = tcg_const_i32(nb);
|
|
|
|
t2 = tcg_const_i32(start);
|
2012-05-30 06:23:40 +02:00
|
|
|
gen_helper_lsw(cpu_env, t0, t1, t2);
|
2008-11-30 17:24:21 +01:00
|
|
|
tcg_temp_free(t0);
|
|
|
|
tcg_temp_free_i32(t1);
|
|
|
|
tcg_temp_free_i32(t2);
|
2003-11-23 15:55:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* lswx */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_lswx(DisasContext *ctx)
|
2003-11-23 15:55:54 +01:00
|
|
|
{
|
2008-12-08 19:11:21 +01:00
|
|
|
TCGv t0;
|
|
|
|
TCGv_i32 t1, t2, t3;
|
|
|
|
gen_set_access_type(ctx, ACCESS_INT);
|
2007-03-07 09:32:30 +01:00
|
|
|
/* NIP cannot be restored if the memory exception comes from an helper */
|
2007-03-17 15:02:15 +01:00
|
|
|
gen_update_nip(ctx, ctx->nip - 4);
|
2008-12-08 19:11:21 +01:00
|
|
|
t0 = tcg_temp_new();
|
|
|
|
gen_addr_reg_index(ctx, t0);
|
|
|
|
t1 = tcg_const_i32(rD(ctx->opcode));
|
|
|
|
t2 = tcg_const_i32(rA(ctx->opcode));
|
|
|
|
t3 = tcg_const_i32(rB(ctx->opcode));
|
2012-05-30 06:23:40 +02:00
|
|
|
gen_helper_lswx(cpu_env, t0, t1, t2, t3);
|
2008-11-30 17:24:21 +01:00
|
|
|
tcg_temp_free(t0);
|
|
|
|
tcg_temp_free_i32(t1);
|
|
|
|
tcg_temp_free_i32(t2);
|
|
|
|
tcg_temp_free_i32(t3);
|
2003-11-23 15:55:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* stswi */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_stswi(DisasContext *ctx)
|
2003-11-23 15:55:54 +01:00
|
|
|
{
|
2008-12-08 19:11:21 +01:00
|
|
|
TCGv t0;
|
|
|
|
TCGv_i32 t1, t2;
|
2004-05-24 00:18:12 +02:00
|
|
|
int nb = NB(ctx->opcode);
|
2008-12-08 19:11:21 +01:00
|
|
|
gen_set_access_type(ctx, ACCESS_INT);
|
2007-03-07 09:32:30 +01:00
|
|
|
/* NIP cannot be restored if the memory exception comes from an helper */
|
2007-03-17 15:02:15 +01:00
|
|
|
gen_update_nip(ctx, ctx->nip - 4);
|
2008-12-08 19:11:21 +01:00
|
|
|
t0 = tcg_temp_new();
|
|
|
|
gen_addr_register(ctx, t0);
|
2004-05-24 00:18:12 +02:00
|
|
|
if (nb == 0)
|
|
|
|
nb = 32;
|
2008-11-30 17:24:21 +01:00
|
|
|
t1 = tcg_const_i32(nb);
|
2008-12-08 19:11:21 +01:00
|
|
|
t2 = tcg_const_i32(rS(ctx->opcode));
|
2012-05-30 06:23:40 +02:00
|
|
|
gen_helper_stsw(cpu_env, t0, t1, t2);
|
2008-11-30 17:24:21 +01:00
|
|
|
tcg_temp_free(t0);
|
|
|
|
tcg_temp_free_i32(t1);
|
|
|
|
tcg_temp_free_i32(t2);
|
2003-11-23 15:55:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* stswx */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_stswx(DisasContext *ctx)
|
2003-11-23 15:55:54 +01:00
|
|
|
{
|
2008-12-08 19:11:21 +01:00
|
|
|
TCGv t0;
|
|
|
|
TCGv_i32 t1, t2;
|
|
|
|
gen_set_access_type(ctx, ACCESS_INT);
|
2005-06-05 00:22:27 +02:00
|
|
|
/* NIP cannot be restored if the memory exception comes from an helper */
|
2007-09-16 23:08:06 +02:00
|
|
|
gen_update_nip(ctx, ctx->nip - 4);
|
2008-12-08 19:11:21 +01:00
|
|
|
t0 = tcg_temp_new();
|
|
|
|
gen_addr_reg_index(ctx, t0);
|
|
|
|
t1 = tcg_temp_new_i32();
|
2008-11-30 17:24:21 +01:00
|
|
|
tcg_gen_trunc_tl_i32(t1, cpu_xer);
|
|
|
|
tcg_gen_andi_i32(t1, t1, 0x7F);
|
2008-12-08 19:11:21 +01:00
|
|
|
t2 = tcg_const_i32(rS(ctx->opcode));
|
2012-05-30 06:23:40 +02:00
|
|
|
gen_helper_stsw(cpu_env, t0, t1, t2);
|
2008-11-30 17:24:21 +01:00
|
|
|
tcg_temp_free(t0);
|
|
|
|
tcg_temp_free_i32(t1);
|
|
|
|
tcg_temp_free_i32(t2);
|
2003-11-23 15:55:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*** Memory synchronisation ***/
|
|
|
|
/* eieio */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_eieio(DisasContext *ctx)
|
2003-11-23 15:55:54 +01:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
/* isync */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_isync(DisasContext *ctx)
|
2003-11-23 15:55:54 +01:00
|
|
|
{
|
2008-12-11 23:42:14 +01:00
|
|
|
gen_stop_exception(ctx);
|
2003-11-23 15:55:54 +01:00
|
|
|
}
|
|
|
|
|
2014-01-07 17:05:56 +01:00
|
|
|
#define LARX(name, len, loadop) \
|
|
|
|
static void gen_##name(DisasContext *ctx) \
|
|
|
|
{ \
|
|
|
|
TCGv t0; \
|
|
|
|
TCGv gpr = cpu_gpr[rD(ctx->opcode)]; \
|
|
|
|
gen_set_access_type(ctx, ACCESS_RES); \
|
|
|
|
t0 = tcg_temp_local_new(); \
|
|
|
|
gen_addr_reg_index(ctx, t0); \
|
|
|
|
if ((len) > 1) { \
|
|
|
|
gen_check_align(ctx, t0, (len)-1); \
|
|
|
|
} \
|
|
|
|
gen_qemu_##loadop(ctx, gpr, t0); \
|
|
|
|
tcg_gen_mov_tl(cpu_reserve, t0); \
|
|
|
|
tcg_gen_st_tl(gpr, cpu_env, offsetof(CPUPPCState, reserve_val)); \
|
|
|
|
tcg_temp_free(t0); \
|
2003-11-23 15:55:54 +01:00
|
|
|
}
|
|
|
|
|
2014-01-07 17:05:56 +01:00
|
|
|
/* lwarx */
|
|
|
|
LARX(lbarx, 1, ld8u);
|
|
|
|
LARX(lharx, 2, ld16u);
|
|
|
|
LARX(lwarx, 4, ld32u);
|
|
|
|
|
|
|
|
|
2009-08-03 17:43:26 +02:00
|
|
|
#if defined(CONFIG_USER_ONLY)
|
2014-01-07 17:05:57 +01:00
|
|
|
static void gen_conditional_store(DisasContext *ctx, TCGv EA,
|
|
|
|
int reg, int size)
|
2009-08-03 17:43:26 +02:00
|
|
|
{
|
|
|
|
TCGv t0 = tcg_temp_new();
|
|
|
|
uint32_t save_exception = ctx->exception;
|
|
|
|
|
2012-03-14 01:38:22 +01:00
|
|
|
tcg_gen_st_tl(EA, cpu_env, offsetof(CPUPPCState, reserve_ea));
|
2009-08-03 17:43:26 +02:00
|
|
|
tcg_gen_movi_tl(t0, (size << 5) | reg);
|
2012-03-14 01:38:22 +01:00
|
|
|
tcg_gen_st_tl(t0, cpu_env, offsetof(CPUPPCState, reserve_info));
|
2009-08-03 17:43:26 +02:00
|
|
|
tcg_temp_free(t0);
|
|
|
|
gen_update_nip(ctx, ctx->nip-4);
|
|
|
|
ctx->exception = POWERPC_EXCP_BRANCH;
|
|
|
|
gen_exception(ctx, POWERPC_EXCP_STCX);
|
|
|
|
ctx->exception = save_exception;
|
|
|
|
}
|
|
|
|
#else
|
2014-01-07 17:05:57 +01:00
|
|
|
static void gen_conditional_store(DisasContext *ctx, TCGv EA,
|
|
|
|
int reg, int size)
|
|
|
|
{
|
2015-02-13 21:51:55 +01:00
|
|
|
TCGLabel *l1;
|
2009-08-03 17:43:26 +02:00
|
|
|
|
2014-01-07 17:05:57 +01:00
|
|
|
tcg_gen_trunc_tl_i32(cpu_crf[0], cpu_so);
|
|
|
|
l1 = gen_new_label();
|
|
|
|
tcg_gen_brcond_tl(TCG_COND_NE, EA, cpu_reserve, l1);
|
|
|
|
tcg_gen_ori_i32(cpu_crf[0], cpu_crf[0], 1 << CRF_EQ);
|
|
|
|
#if defined(TARGET_PPC64)
|
|
|
|
if (size == 8) {
|
|
|
|
gen_qemu_st64(ctx, cpu_gpr[reg], EA);
|
|
|
|
} else
|
|
|
|
#endif
|
|
|
|
if (size == 4) {
|
|
|
|
gen_qemu_st32(ctx, cpu_gpr[reg], EA);
|
|
|
|
} else if (size == 2) {
|
|
|
|
gen_qemu_st16(ctx, cpu_gpr[reg], EA);
|
2014-02-10 18:27:01 +01:00
|
|
|
#if defined(TARGET_PPC64)
|
|
|
|
} else if (size == 16) {
|
2014-02-24 15:16:16 +01:00
|
|
|
TCGv gpr1, gpr2 , EA8;
|
2014-02-10 18:27:01 +01:00
|
|
|
if (unlikely(ctx->le_mode)) {
|
|
|
|
gpr1 = cpu_gpr[reg+1];
|
|
|
|
gpr2 = cpu_gpr[reg];
|
|
|
|
} else {
|
|
|
|
gpr1 = cpu_gpr[reg];
|
|
|
|
gpr2 = cpu_gpr[reg+1];
|
|
|
|
}
|
|
|
|
gen_qemu_st64(ctx, gpr1, EA);
|
2014-02-24 15:16:16 +01:00
|
|
|
EA8 = tcg_temp_local_new();
|
|
|
|
gen_addr_add(ctx, EA8, EA, 8);
|
|
|
|
gen_qemu_st64(ctx, gpr2, EA8);
|
|
|
|
tcg_temp_free(EA8);
|
2014-02-10 18:27:01 +01:00
|
|
|
#endif
|
2014-01-07 17:05:57 +01:00
|
|
|
} else {
|
|
|
|
gen_qemu_st8(ctx, cpu_gpr[reg], EA);
|
2009-08-03 17:43:26 +02:00
|
|
|
}
|
2014-01-07 17:05:57 +01:00
|
|
|
gen_set_label(l1);
|
|
|
|
tcg_gen_movi_tl(cpu_reserve, -1);
|
|
|
|
}
|
2009-08-03 17:43:26 +02:00
|
|
|
#endif
|
2014-01-07 17:05:57 +01:00
|
|
|
|
|
|
|
#define STCX(name, len) \
|
|
|
|
static void gen_##name(DisasContext *ctx) \
|
|
|
|
{ \
|
|
|
|
TCGv t0; \
|
2014-02-10 18:27:01 +01:00
|
|
|
if (unlikely((len == 16) && (rD(ctx->opcode) & 1))) { \
|
|
|
|
gen_inval_exception(ctx, \
|
|
|
|
POWERPC_EXCP_INVAL_INVAL); \
|
|
|
|
return; \
|
|
|
|
} \
|
2014-01-07 17:05:57 +01:00
|
|
|
gen_set_access_type(ctx, ACCESS_RES); \
|
|
|
|
t0 = tcg_temp_local_new(); \
|
|
|
|
gen_addr_reg_index(ctx, t0); \
|
|
|
|
if (len > 1) { \
|
|
|
|
gen_check_align(ctx, t0, (len)-1); \
|
|
|
|
} \
|
|
|
|
gen_conditional_store(ctx, t0, rS(ctx->opcode), len); \
|
|
|
|
tcg_temp_free(t0); \
|
2003-11-23 15:55:54 +01:00
|
|
|
}
|
|
|
|
|
2014-01-07 17:05:57 +01:00
|
|
|
STCX(stbcx_, 1);
|
|
|
|
STCX(sthcx_, 2);
|
|
|
|
STCX(stwcx_, 4);
|
|
|
|
|
2007-03-23 10:45:27 +01:00
|
|
|
#if defined(TARGET_PPC64)
|
|
|
|
/* ldarx */
|
2014-01-07 17:05:56 +01:00
|
|
|
LARX(ldarx, 8, ld64);
|
2007-03-23 10:45:27 +01:00
|
|
|
|
2014-02-10 18:27:00 +01:00
|
|
|
/* lqarx */
|
|
|
|
static void gen_lqarx(DisasContext *ctx)
|
|
|
|
{
|
|
|
|
TCGv EA;
|
|
|
|
int rd = rD(ctx->opcode);
|
|
|
|
TCGv gpr1, gpr2;
|
|
|
|
|
|
|
|
if (unlikely((rd & 1) || (rd == rA(ctx->opcode)) ||
|
|
|
|
(rd == rB(ctx->opcode)))) {
|
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_INVAL_INVAL);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
gen_set_access_type(ctx, ACCESS_RES);
|
|
|
|
EA = tcg_temp_local_new();
|
|
|
|
gen_addr_reg_index(ctx, EA);
|
|
|
|
gen_check_align(ctx, EA, 15);
|
|
|
|
if (unlikely(ctx->le_mode)) {
|
|
|
|
gpr1 = cpu_gpr[rd+1];
|
|
|
|
gpr2 = cpu_gpr[rd];
|
|
|
|
} else {
|
|
|
|
gpr1 = cpu_gpr[rd];
|
|
|
|
gpr2 = cpu_gpr[rd+1];
|
|
|
|
}
|
|
|
|
gen_qemu_ld64(ctx, gpr1, EA);
|
|
|
|
tcg_gen_mov_tl(cpu_reserve, EA);
|
|
|
|
|
|
|
|
gen_addr_add(ctx, EA, EA, 8);
|
|
|
|
gen_qemu_ld64(ctx, gpr2, EA);
|
|
|
|
|
|
|
|
tcg_gen_st_tl(gpr1, cpu_env, offsetof(CPUPPCState, reserve_val));
|
|
|
|
tcg_gen_st_tl(gpr2, cpu_env, offsetof(CPUPPCState, reserve_val2));
|
|
|
|
|
|
|
|
tcg_temp_free(EA);
|
|
|
|
}
|
|
|
|
|
2007-03-23 10:45:27 +01:00
|
|
|
/* stdcx. */
|
2014-01-07 17:05:57 +01:00
|
|
|
STCX(stdcx_, 8);
|
2014-02-10 18:27:01 +01:00
|
|
|
STCX(stqcx_, 16);
|
2007-03-23 10:45:27 +01:00
|
|
|
#endif /* defined(TARGET_PPC64) */
|
|
|
|
|
2003-11-23 15:55:54 +01:00
|
|
|
/* sync */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_sync(DisasContext *ctx)
|
2003-11-23 15:55:54 +01:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2007-09-30 05:46:38 +02:00
|
|
|
/* wait */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_wait(DisasContext *ctx)
|
2007-09-30 05:46:38 +02:00
|
|
|
{
|
2008-11-30 17:23:46 +01:00
|
|
|
TCGv_i32 t0 = tcg_temp_new_i32();
|
2013-01-17 18:51:17 +01:00
|
|
|
tcg_gen_st_i32(t0, cpu_env,
|
|
|
|
-offsetof(PowerPCCPU, env) + offsetof(CPUState, halted));
|
2008-11-30 17:23:46 +01:00
|
|
|
tcg_temp_free_i32(t0);
|
2007-09-30 05:46:38 +02:00
|
|
|
/* Stop translation, as the CPU is supposed to sleep from now */
|
2008-12-11 23:42:14 +01:00
|
|
|
gen_exception_err(ctx, EXCP_HLT, 1);
|
2007-09-30 05:46:38 +02:00
|
|
|
}
|
|
|
|
|
2003-11-23 15:55:54 +01:00
|
|
|
/*** Floating-point load ***/
|
2008-11-23 17:30:50 +01:00
|
|
|
#define GEN_LDF(name, ldop, opc, type) \
|
2009-06-17 17:22:09 +02:00
|
|
|
static void glue(gen_, name)(DisasContext *ctx) \
|
2003-11-23 15:55:54 +01:00
|
|
|
{ \
|
2008-11-23 17:30:50 +01:00
|
|
|
TCGv EA; \
|
2007-03-07 09:32:30 +01:00
|
|
|
if (unlikely(!ctx->fpu_enabled)) { \
|
2008-12-11 23:42:14 +01:00
|
|
|
gen_exception(ctx, POWERPC_EXCP_FPU); \
|
2005-03-13 18:01:22 +01:00
|
|
|
return; \
|
|
|
|
} \
|
2008-12-08 19:11:21 +01:00
|
|
|
gen_set_access_type(ctx, ACCESS_FLOAT); \
|
2008-11-23 17:30:50 +01:00
|
|
|
EA = tcg_temp_new(); \
|
2008-12-08 19:11:21 +01:00
|
|
|
gen_addr_imm_index(ctx, EA, 0); \
|
|
|
|
gen_qemu_##ldop(ctx, cpu_fpr[rD(ctx->opcode)], EA); \
|
2008-11-23 17:30:50 +01:00
|
|
|
tcg_temp_free(EA); \
|
2003-11-23 15:55:54 +01:00
|
|
|
}
|
|
|
|
|
2008-11-23 17:30:50 +01:00
|
|
|
#define GEN_LDUF(name, ldop, opc, type) \
|
2009-06-17 17:22:09 +02:00
|
|
|
static void glue(gen_, name##u)(DisasContext *ctx) \
|
2003-11-23 15:55:54 +01:00
|
|
|
{ \
|
2008-11-23 17:30:50 +01:00
|
|
|
TCGv EA; \
|
2007-03-07 09:32:30 +01:00
|
|
|
if (unlikely(!ctx->fpu_enabled)) { \
|
2008-12-11 23:42:14 +01:00
|
|
|
gen_exception(ctx, POWERPC_EXCP_FPU); \
|
2005-03-13 18:01:22 +01:00
|
|
|
return; \
|
|
|
|
} \
|
2007-03-07 09:32:30 +01:00
|
|
|
if (unlikely(rA(ctx->opcode) == 0)) { \
|
2008-12-11 23:42:14 +01:00
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_INVAL_INVAL); \
|
2004-05-21 14:59:32 +02:00
|
|
|
return; \
|
2004-01-04 23:58:38 +01:00
|
|
|
} \
|
2008-12-08 19:11:21 +01:00
|
|
|
gen_set_access_type(ctx, ACCESS_FLOAT); \
|
2008-11-23 17:30:50 +01:00
|
|
|
EA = tcg_temp_new(); \
|
2008-12-08 19:11:21 +01:00
|
|
|
gen_addr_imm_index(ctx, EA, 0); \
|
|
|
|
gen_qemu_##ldop(ctx, cpu_fpr[rD(ctx->opcode)], EA); \
|
2008-11-23 17:30:50 +01:00
|
|
|
tcg_gen_mov_tl(cpu_gpr[rA(ctx->opcode)], EA); \
|
|
|
|
tcg_temp_free(EA); \
|
2003-11-23 15:55:54 +01:00
|
|
|
}
|
|
|
|
|
2008-11-23 17:30:50 +01:00
|
|
|
#define GEN_LDUXF(name, ldop, opc, type) \
|
2009-06-17 17:22:09 +02:00
|
|
|
static void glue(gen_, name##ux)(DisasContext *ctx) \
|
2003-11-23 15:55:54 +01:00
|
|
|
{ \
|
2008-11-23 17:30:50 +01:00
|
|
|
TCGv EA; \
|
2007-03-07 09:32:30 +01:00
|
|
|
if (unlikely(!ctx->fpu_enabled)) { \
|
2008-12-11 23:42:14 +01:00
|
|
|
gen_exception(ctx, POWERPC_EXCP_FPU); \
|
2005-03-13 18:01:22 +01:00
|
|
|
return; \
|
|
|
|
} \
|
2007-03-07 09:32:30 +01:00
|
|
|
if (unlikely(rA(ctx->opcode) == 0)) { \
|
2008-12-11 23:42:14 +01:00
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_INVAL_INVAL); \
|
2004-05-21 14:59:32 +02:00
|
|
|
return; \
|
2004-01-04 23:58:38 +01:00
|
|
|
} \
|
2008-12-08 19:11:21 +01:00
|
|
|
gen_set_access_type(ctx, ACCESS_FLOAT); \
|
2008-11-23 17:30:50 +01:00
|
|
|
EA = tcg_temp_new(); \
|
2008-12-08 19:11:21 +01:00
|
|
|
gen_addr_reg_index(ctx, EA); \
|
|
|
|
gen_qemu_##ldop(ctx, cpu_fpr[rD(ctx->opcode)], EA); \
|
2008-11-23 17:30:50 +01:00
|
|
|
tcg_gen_mov_tl(cpu_gpr[rA(ctx->opcode)], EA); \
|
|
|
|
tcg_temp_free(EA); \
|
2003-11-23 15:55:54 +01:00
|
|
|
}
|
|
|
|
|
2008-11-23 17:30:50 +01:00
|
|
|
#define GEN_LDXF(name, ldop, opc2, opc3, type) \
|
2009-06-17 17:22:09 +02:00
|
|
|
static void glue(gen_, name##x)(DisasContext *ctx) \
|
2003-11-23 15:55:54 +01:00
|
|
|
{ \
|
2008-11-23 17:30:50 +01:00
|
|
|
TCGv EA; \
|
2007-03-07 09:32:30 +01:00
|
|
|
if (unlikely(!ctx->fpu_enabled)) { \
|
2008-12-11 23:42:14 +01:00
|
|
|
gen_exception(ctx, POWERPC_EXCP_FPU); \
|
2005-03-13 18:01:22 +01:00
|
|
|
return; \
|
|
|
|
} \
|
2008-12-08 19:11:21 +01:00
|
|
|
gen_set_access_type(ctx, ACCESS_FLOAT); \
|
2008-11-23 17:30:50 +01:00
|
|
|
EA = tcg_temp_new(); \
|
2008-12-08 19:11:21 +01:00
|
|
|
gen_addr_reg_index(ctx, EA); \
|
|
|
|
gen_qemu_##ldop(ctx, cpu_fpr[rD(ctx->opcode)], EA); \
|
2008-11-23 17:30:50 +01:00
|
|
|
tcg_temp_free(EA); \
|
2003-11-23 15:55:54 +01:00
|
|
|
}
|
|
|
|
|
2008-11-23 17:30:50 +01:00
|
|
|
#define GEN_LDFS(name, ldop, op, type) \
|
|
|
|
GEN_LDF(name, ldop, op | 0x20, type); \
|
|
|
|
GEN_LDUF(name, ldop, op | 0x21, type); \
|
|
|
|
GEN_LDUXF(name, ldop, op | 0x01, type); \
|
|
|
|
GEN_LDXF(name, ldop, 0x17, op | 0x00, type)
|
|
|
|
|
2009-08-16 11:06:54 +02:00
|
|
|
static inline void gen_qemu_ld32fs(DisasContext *ctx, TCGv_i64 arg1, TCGv arg2)
|
2008-11-23 17:30:50 +01:00
|
|
|
{
|
|
|
|
TCGv t0 = tcg_temp_new();
|
|
|
|
TCGv_i32 t1 = tcg_temp_new_i32();
|
2008-12-08 19:11:21 +01:00
|
|
|
gen_qemu_ld32u(ctx, t0, arg2);
|
2008-11-23 17:30:50 +01:00
|
|
|
tcg_gen_trunc_tl_i32(t1, t0);
|
|
|
|
tcg_temp_free(t0);
|
2012-05-30 06:23:27 +02:00
|
|
|
gen_helper_float32_to_float64(arg1, cpu_env, t1);
|
2008-11-23 17:30:50 +01:00
|
|
|
tcg_temp_free_i32(t1);
|
|
|
|
}
|
2003-11-23 15:55:54 +01:00
|
|
|
|
2008-11-23 17:30:50 +01:00
|
|
|
/* lfd lfdu lfdux lfdx */
|
|
|
|
GEN_LDFS(lfd, ld64, 0x12, PPC_FLOAT);
|
|
|
|
/* lfs lfsu lfsux lfsx */
|
|
|
|
GEN_LDFS(lfs, ld32fs, 0x10, PPC_FLOAT);
|
2003-11-23 15:55:54 +01:00
|
|
|
|
2013-04-20 10:56:20 +02:00
|
|
|
/* lfdp */
|
|
|
|
static void gen_lfdp(DisasContext *ctx)
|
|
|
|
{
|
|
|
|
TCGv EA;
|
|
|
|
if (unlikely(!ctx->fpu_enabled)) {
|
|
|
|
gen_exception(ctx, POWERPC_EXCP_FPU);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
gen_set_access_type(ctx, ACCESS_FLOAT);
|
|
|
|
EA = tcg_temp_new();
|
2014-05-29 16:12:20 +02:00
|
|
|
gen_addr_imm_index(ctx, EA, 0);
|
|
|
|
/* We only need to swap high and low halves. gen_qemu_ld64 does necessary
|
|
|
|
64-bit byteswap already. */
|
2013-04-20 10:56:20 +02:00
|
|
|
if (unlikely(ctx->le_mode)) {
|
|
|
|
gen_qemu_ld64(ctx, cpu_fpr[rD(ctx->opcode) + 1], EA);
|
|
|
|
tcg_gen_addi_tl(EA, EA, 8);
|
|
|
|
gen_qemu_ld64(ctx, cpu_fpr[rD(ctx->opcode)], EA);
|
|
|
|
} else {
|
|
|
|
gen_qemu_ld64(ctx, cpu_fpr[rD(ctx->opcode)], EA);
|
|
|
|
tcg_gen_addi_tl(EA, EA, 8);
|
|
|
|
gen_qemu_ld64(ctx, cpu_fpr[rD(ctx->opcode) + 1], EA);
|
|
|
|
}
|
|
|
|
tcg_temp_free(EA);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* lfdpx */
|
|
|
|
static void gen_lfdpx(DisasContext *ctx)
|
|
|
|
{
|
|
|
|
TCGv EA;
|
|
|
|
if (unlikely(!ctx->fpu_enabled)) {
|
|
|
|
gen_exception(ctx, POWERPC_EXCP_FPU);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
gen_set_access_type(ctx, ACCESS_FLOAT);
|
|
|
|
EA = tcg_temp_new();
|
|
|
|
gen_addr_reg_index(ctx, EA);
|
2014-05-29 16:12:20 +02:00
|
|
|
/* We only need to swap high and low halves. gen_qemu_ld64 does necessary
|
|
|
|
64-bit byteswap already. */
|
2013-04-20 10:56:20 +02:00
|
|
|
if (unlikely(ctx->le_mode)) {
|
|
|
|
gen_qemu_ld64(ctx, cpu_fpr[rD(ctx->opcode) + 1], EA);
|
|
|
|
tcg_gen_addi_tl(EA, EA, 8);
|
|
|
|
gen_qemu_ld64(ctx, cpu_fpr[rD(ctx->opcode)], EA);
|
|
|
|
} else {
|
|
|
|
gen_qemu_ld64(ctx, cpu_fpr[rD(ctx->opcode)], EA);
|
|
|
|
tcg_gen_addi_tl(EA, EA, 8);
|
|
|
|
gen_qemu_ld64(ctx, cpu_fpr[rD(ctx->opcode) + 1], EA);
|
|
|
|
}
|
|
|
|
tcg_temp_free(EA);
|
|
|
|
}
|
|
|
|
|
2013-04-20 10:56:19 +02:00
|
|
|
/* lfiwax */
|
|
|
|
static void gen_lfiwax(DisasContext *ctx)
|
|
|
|
{
|
|
|
|
TCGv EA;
|
|
|
|
TCGv t0;
|
|
|
|
if (unlikely(!ctx->fpu_enabled)) {
|
|
|
|
gen_exception(ctx, POWERPC_EXCP_FPU);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
gen_set_access_type(ctx, ACCESS_FLOAT);
|
|
|
|
EA = tcg_temp_new();
|
|
|
|
t0 = tcg_temp_new();
|
|
|
|
gen_addr_reg_index(ctx, EA);
|
2013-04-27 00:37:46 +02:00
|
|
|
gen_qemu_ld32s(ctx, t0, EA);
|
2013-04-20 10:56:19 +02:00
|
|
|
tcg_gen_ext_tl_i64(cpu_fpr[rD(ctx->opcode)], t0);
|
|
|
|
tcg_temp_free(EA);
|
|
|
|
tcg_temp_free(t0);
|
|
|
|
}
|
|
|
|
|
2014-01-07 17:06:10 +01:00
|
|
|
/* lfiwzx */
|
|
|
|
static void gen_lfiwzx(DisasContext *ctx)
|
|
|
|
{
|
|
|
|
TCGv EA;
|
|
|
|
if (unlikely(!ctx->fpu_enabled)) {
|
|
|
|
gen_exception(ctx, POWERPC_EXCP_FPU);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
gen_set_access_type(ctx, ACCESS_FLOAT);
|
|
|
|
EA = tcg_temp_new();
|
|
|
|
gen_addr_reg_index(ctx, EA);
|
|
|
|
gen_qemu_ld32u_i64(ctx, cpu_fpr[rD(ctx->opcode)], EA);
|
|
|
|
tcg_temp_free(EA);
|
|
|
|
}
|
2003-11-23 15:55:54 +01:00
|
|
|
/*** Floating-point store ***/
|
2008-11-23 17:30:50 +01:00
|
|
|
#define GEN_STF(name, stop, opc, type) \
|
2009-06-17 17:22:09 +02:00
|
|
|
static void glue(gen_, name)(DisasContext *ctx) \
|
2003-11-23 15:55:54 +01:00
|
|
|
{ \
|
2008-11-23 17:30:50 +01:00
|
|
|
TCGv EA; \
|
2007-03-07 09:32:30 +01:00
|
|
|
if (unlikely(!ctx->fpu_enabled)) { \
|
2008-12-11 23:42:14 +01:00
|
|
|
gen_exception(ctx, POWERPC_EXCP_FPU); \
|
2005-03-13 18:01:22 +01:00
|
|
|
return; \
|
|
|
|
} \
|
2008-12-08 19:11:21 +01:00
|
|
|
gen_set_access_type(ctx, ACCESS_FLOAT); \
|
2008-11-23 17:30:50 +01:00
|
|
|
EA = tcg_temp_new(); \
|
2008-12-08 19:11:21 +01:00
|
|
|
gen_addr_imm_index(ctx, EA, 0); \
|
|
|
|
gen_qemu_##stop(ctx, cpu_fpr[rS(ctx->opcode)], EA); \
|
2008-11-23 17:30:50 +01:00
|
|
|
tcg_temp_free(EA); \
|
2003-11-23 15:55:54 +01:00
|
|
|
}
|
|
|
|
|
2008-11-23 17:30:50 +01:00
|
|
|
#define GEN_STUF(name, stop, opc, type) \
|
2009-06-17 17:22:09 +02:00
|
|
|
static void glue(gen_, name##u)(DisasContext *ctx) \
|
2003-11-23 15:55:54 +01:00
|
|
|
{ \
|
2008-11-23 17:30:50 +01:00
|
|
|
TCGv EA; \
|
2007-03-07 09:32:30 +01:00
|
|
|
if (unlikely(!ctx->fpu_enabled)) { \
|
2008-12-11 23:42:14 +01:00
|
|
|
gen_exception(ctx, POWERPC_EXCP_FPU); \
|
2005-03-13 18:01:22 +01:00
|
|
|
return; \
|
|
|
|
} \
|
2007-03-07 09:32:30 +01:00
|
|
|
if (unlikely(rA(ctx->opcode) == 0)) { \
|
2008-12-11 23:42:14 +01:00
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_INVAL_INVAL); \
|
2004-05-21 14:59:32 +02:00
|
|
|
return; \
|
2004-01-04 23:58:38 +01:00
|
|
|
} \
|
2008-12-08 19:11:21 +01:00
|
|
|
gen_set_access_type(ctx, ACCESS_FLOAT); \
|
2008-11-23 17:30:50 +01:00
|
|
|
EA = tcg_temp_new(); \
|
2008-12-08 19:11:21 +01:00
|
|
|
gen_addr_imm_index(ctx, EA, 0); \
|
|
|
|
gen_qemu_##stop(ctx, cpu_fpr[rS(ctx->opcode)], EA); \
|
2008-11-23 17:30:50 +01:00
|
|
|
tcg_gen_mov_tl(cpu_gpr[rA(ctx->opcode)], EA); \
|
|
|
|
tcg_temp_free(EA); \
|
2003-11-23 15:55:54 +01:00
|
|
|
}
|
|
|
|
|
2008-11-23 17:30:50 +01:00
|
|
|
#define GEN_STUXF(name, stop, opc, type) \
|
2009-06-17 17:22:09 +02:00
|
|
|
static void glue(gen_, name##ux)(DisasContext *ctx) \
|
2003-11-23 15:55:54 +01:00
|
|
|
{ \
|
2008-11-23 17:30:50 +01:00
|
|
|
TCGv EA; \
|
2007-03-07 09:32:30 +01:00
|
|
|
if (unlikely(!ctx->fpu_enabled)) { \
|
2008-12-11 23:42:14 +01:00
|
|
|
gen_exception(ctx, POWERPC_EXCP_FPU); \
|
2005-03-13 18:01:22 +01:00
|
|
|
return; \
|
|
|
|
} \
|
2007-03-07 09:32:30 +01:00
|
|
|
if (unlikely(rA(ctx->opcode) == 0)) { \
|
2008-12-11 23:42:14 +01:00
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_INVAL_INVAL); \
|
2004-05-21 14:59:32 +02:00
|
|
|
return; \
|
2004-01-04 23:58:38 +01:00
|
|
|
} \
|
2008-12-08 19:11:21 +01:00
|
|
|
gen_set_access_type(ctx, ACCESS_FLOAT); \
|
2008-11-23 17:30:50 +01:00
|
|
|
EA = tcg_temp_new(); \
|
2008-12-08 19:11:21 +01:00
|
|
|
gen_addr_reg_index(ctx, EA); \
|
|
|
|
gen_qemu_##stop(ctx, cpu_fpr[rS(ctx->opcode)], EA); \
|
2008-11-23 17:30:50 +01:00
|
|
|
tcg_gen_mov_tl(cpu_gpr[rA(ctx->opcode)], EA); \
|
|
|
|
tcg_temp_free(EA); \
|
2003-11-23 15:55:54 +01:00
|
|
|
}
|
|
|
|
|
2008-11-23 17:30:50 +01:00
|
|
|
#define GEN_STXF(name, stop, opc2, opc3, type) \
|
2009-06-17 17:22:09 +02:00
|
|
|
static void glue(gen_, name##x)(DisasContext *ctx) \
|
2003-11-23 15:55:54 +01:00
|
|
|
{ \
|
2008-11-23 17:30:50 +01:00
|
|
|
TCGv EA; \
|
2007-03-07 09:32:30 +01:00
|
|
|
if (unlikely(!ctx->fpu_enabled)) { \
|
2008-12-11 23:42:14 +01:00
|
|
|
gen_exception(ctx, POWERPC_EXCP_FPU); \
|
2005-03-13 18:01:22 +01:00
|
|
|
return; \
|
|
|
|
} \
|
2008-12-08 19:11:21 +01:00
|
|
|
gen_set_access_type(ctx, ACCESS_FLOAT); \
|
2008-11-23 17:30:50 +01:00
|
|
|
EA = tcg_temp_new(); \
|
2008-12-08 19:11:21 +01:00
|
|
|
gen_addr_reg_index(ctx, EA); \
|
|
|
|
gen_qemu_##stop(ctx, cpu_fpr[rS(ctx->opcode)], EA); \
|
2008-11-23 17:30:50 +01:00
|
|
|
tcg_temp_free(EA); \
|
2003-11-23 15:55:54 +01:00
|
|
|
}
|
|
|
|
|
2008-11-23 17:30:50 +01:00
|
|
|
#define GEN_STFS(name, stop, op, type) \
|
|
|
|
GEN_STF(name, stop, op | 0x20, type); \
|
|
|
|
GEN_STUF(name, stop, op | 0x21, type); \
|
|
|
|
GEN_STUXF(name, stop, op | 0x01, type); \
|
|
|
|
GEN_STXF(name, stop, 0x17, op | 0x00, type)
|
|
|
|
|
2009-08-16 11:06:54 +02:00
|
|
|
static inline void gen_qemu_st32fs(DisasContext *ctx, TCGv_i64 arg1, TCGv arg2)
|
2008-11-23 17:30:50 +01:00
|
|
|
{
|
|
|
|
TCGv_i32 t0 = tcg_temp_new_i32();
|
|
|
|
TCGv t1 = tcg_temp_new();
|
2012-05-30 06:23:27 +02:00
|
|
|
gen_helper_float64_to_float32(t0, cpu_env, arg1);
|
2008-11-23 17:30:50 +01:00
|
|
|
tcg_gen_extu_i32_tl(t1, t0);
|
|
|
|
tcg_temp_free_i32(t0);
|
2008-12-08 19:11:21 +01:00
|
|
|
gen_qemu_st32(ctx, t1, arg2);
|
2008-11-23 17:30:50 +01:00
|
|
|
tcg_temp_free(t1);
|
|
|
|
}
|
2003-11-23 15:55:54 +01:00
|
|
|
|
|
|
|
/* stfd stfdu stfdux stfdx */
|
2008-11-23 17:30:50 +01:00
|
|
|
GEN_STFS(stfd, st64, 0x16, PPC_FLOAT);
|
2003-11-23 15:55:54 +01:00
|
|
|
/* stfs stfsu stfsux stfsx */
|
2008-11-23 17:30:50 +01:00
|
|
|
GEN_STFS(stfs, st32fs, 0x14, PPC_FLOAT);
|
2003-11-23 15:55:54 +01:00
|
|
|
|
2013-04-20 10:56:21 +02:00
|
|
|
/* stfdp */
|
|
|
|
static void gen_stfdp(DisasContext *ctx)
|
|
|
|
{
|
|
|
|
TCGv EA;
|
|
|
|
if (unlikely(!ctx->fpu_enabled)) {
|
|
|
|
gen_exception(ctx, POWERPC_EXCP_FPU);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
gen_set_access_type(ctx, ACCESS_FLOAT);
|
|
|
|
EA = tcg_temp_new();
|
2014-05-29 16:12:20 +02:00
|
|
|
gen_addr_imm_index(ctx, EA, 0);
|
|
|
|
/* We only need to swap high and low halves. gen_qemu_st64 does necessary
|
|
|
|
64-bit byteswap already. */
|
2013-04-20 10:56:21 +02:00
|
|
|
if (unlikely(ctx->le_mode)) {
|
|
|
|
gen_qemu_st64(ctx, cpu_fpr[rD(ctx->opcode) + 1], EA);
|
|
|
|
tcg_gen_addi_tl(EA, EA, 8);
|
|
|
|
gen_qemu_st64(ctx, cpu_fpr[rD(ctx->opcode)], EA);
|
|
|
|
} else {
|
|
|
|
gen_qemu_st64(ctx, cpu_fpr[rD(ctx->opcode)], EA);
|
|
|
|
tcg_gen_addi_tl(EA, EA, 8);
|
|
|
|
gen_qemu_st64(ctx, cpu_fpr[rD(ctx->opcode) + 1], EA);
|
|
|
|
}
|
|
|
|
tcg_temp_free(EA);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* stfdpx */
|
|
|
|
static void gen_stfdpx(DisasContext *ctx)
|
|
|
|
{
|
|
|
|
TCGv EA;
|
|
|
|
if (unlikely(!ctx->fpu_enabled)) {
|
|
|
|
gen_exception(ctx, POWERPC_EXCP_FPU);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
gen_set_access_type(ctx, ACCESS_FLOAT);
|
|
|
|
EA = tcg_temp_new();
|
|
|
|
gen_addr_reg_index(ctx, EA);
|
2014-05-29 16:12:20 +02:00
|
|
|
/* We only need to swap high and low halves. gen_qemu_st64 does necessary
|
|
|
|
64-bit byteswap already. */
|
2013-04-20 10:56:21 +02:00
|
|
|
if (unlikely(ctx->le_mode)) {
|
|
|
|
gen_qemu_st64(ctx, cpu_fpr[rD(ctx->opcode) + 1], EA);
|
|
|
|
tcg_gen_addi_tl(EA, EA, 8);
|
|
|
|
gen_qemu_st64(ctx, cpu_fpr[rD(ctx->opcode)], EA);
|
|
|
|
} else {
|
|
|
|
gen_qemu_st64(ctx, cpu_fpr[rD(ctx->opcode)], EA);
|
|
|
|
tcg_gen_addi_tl(EA, EA, 8);
|
|
|
|
gen_qemu_st64(ctx, cpu_fpr[rD(ctx->opcode) + 1], EA);
|
|
|
|
}
|
|
|
|
tcg_temp_free(EA);
|
|
|
|
}
|
|
|
|
|
2003-11-23 15:55:54 +01:00
|
|
|
/* Optional: */
|
2009-08-16 11:06:54 +02:00
|
|
|
static inline void gen_qemu_st32fiw(DisasContext *ctx, TCGv_i64 arg1, TCGv arg2)
|
2008-11-23 17:30:50 +01:00
|
|
|
{
|
|
|
|
TCGv t0 = tcg_temp_new();
|
|
|
|
tcg_gen_trunc_i64_tl(t0, arg1),
|
2008-12-08 19:11:21 +01:00
|
|
|
gen_qemu_st32(ctx, t0, arg2);
|
2008-11-23 17:30:50 +01:00
|
|
|
tcg_temp_free(t0);
|
|
|
|
}
|
2003-11-23 15:55:54 +01:00
|
|
|
/* stfiwx */
|
2008-11-23 17:30:50 +01:00
|
|
|
GEN_STXF(stfiw, st32fiw, 0x17, 0x1E, PPC_FLOAT_STFIWX);
|
2003-11-23 15:55:54 +01:00
|
|
|
|
2011-08-31 17:45:10 +02:00
|
|
|
static inline void gen_update_cfar(DisasContext *ctx, target_ulong nip)
|
|
|
|
{
|
|
|
|
#if defined(TARGET_PPC64)
|
|
|
|
if (ctx->has_cfar)
|
|
|
|
tcg_gen_movi_tl(cpu_cfar, nip);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2016-04-09 00:00:23 +02:00
|
|
|
static inline bool use_goto_tb(DisasContext *ctx, target_ulong dest)
|
|
|
|
{
|
|
|
|
if (unlikely(ctx->singlestep_enabled)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifndef CONFIG_USER_ONLY
|
|
|
|
return (ctx->tb->pc & TARGET_PAGE_MASK) == (dest & TARGET_PAGE_MASK);
|
|
|
|
#else
|
|
|
|
return true;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2003-11-23 15:55:54 +01:00
|
|
|
/*** Branch ***/
|
2009-08-16 11:06:54 +02:00
|
|
|
static inline void gen_goto_tb(DisasContext *ctx, int n, target_ulong dest)
|
2005-11-20 11:31:08 +01:00
|
|
|
{
|
2013-03-21 11:01:46 +01:00
|
|
|
if (NARROW_MODE(ctx)) {
|
2008-10-21 18:31:31 +02:00
|
|
|
dest = (uint32_t) dest;
|
2013-03-21 11:01:46 +01:00
|
|
|
}
|
2016-04-09 00:00:23 +02:00
|
|
|
if (use_goto_tb(ctx, dest)) {
|
2008-02-01 11:50:11 +01:00
|
|
|
tcg_gen_goto_tb(n);
|
2008-10-21 18:31:31 +02:00
|
|
|
tcg_gen_movi_tl(cpu_nip, dest & ~3);
|
2016-04-09 00:00:23 +02:00
|
|
|
tcg_gen_exit_tb((uintptr_t)ctx->tb + n);
|
2005-11-20 11:31:08 +01:00
|
|
|
} else {
|
2008-10-21 18:31:31 +02:00
|
|
|
tcg_gen_movi_tl(cpu_nip, dest & ~3);
|
2008-05-11 01:28:14 +02:00
|
|
|
if (unlikely(ctx->singlestep_enabled)) {
|
|
|
|
if ((ctx->singlestep_enabled &
|
2008-11-09 18:27:03 +01:00
|
|
|
(CPU_BRANCH_STEP | CPU_SINGLE_STEP)) &&
|
PPC: Fix missing TRACE exception
This patch fixes bug 1031698 :
https://bugs.launchpad.net/qemu/+bug/1031698
If we look at the (truncated) translation of the conditional branch
instruction in the test submitted in the bug post, the call to the
exception helper is missing in the "bne-false" chunk of translated
code :
IN:
bne- 0x1800278
OUT:
0xb544236d: jne 0xb5442396
0xb5442373: mov %ebp,(%esp)
0xb5442376: mov $0x44,%ebx
0xb544237b: mov %ebx,0x4(%esp)
0xb544237f: mov $0x1800278,%ebx
0xb5442384: mov %ebx,0x25c(%ebp)
0xb544238a: call 0x827475a
^^^^^^^^^^^^^^^^^^
0xb5442396: mov %ebp,(%esp)
0xb5442399: mov $0x44,%ebx
0xb544239e: mov %ebx,0x4(%esp)
0xb54423a2: mov $0x1800270,%ebx
0xb54423a7: mov %ebx,0x25c(%ebp)
Indeed, gen_exception(ctx, excp) called by gen_goto_tb (called by
gen_bcond) changes ctx->exception's value to excp's :
gen_bcond()
{
gen_goto_tb(ctx, 0, ctx->nip + li - 4);
/* ctx->exception value is POWERPC_EXCP_BRANCH */
gen_goto_tb(ctx, 1, ctx->nip);
/* ctx->exception now value is POWERPC_EXCP_TRACE */
}
Making the following gen_goto_tb()'s test false during the second call :
if ((ctx->singlestep_enabled &
(CPU_BRANCH_STEP | CPU_SINGLE_STEP)) &&
ctx->exception == POWERPC_EXCP_BRANCH /* false...*/) {
target_ulong tmp = ctx->nip;
ctx->nip = dest;
/* ... and this is the missing call */
gen_exception(ctx, POWERPC_EXCP_TRACE);
ctx->nip = tmp;
}
So the patch simply adds the missing matching case, fixing our problem.
Signed-off-by: Julio Guerra <guerr@julio.in>
Signed-off-by: Alexander Graf <agraf@suse.de>
2012-10-19 02:17:13 +02:00
|
|
|
(ctx->exception == POWERPC_EXCP_BRANCH ||
|
|
|
|
ctx->exception == POWERPC_EXCP_TRACE)) {
|
2008-05-11 01:28:14 +02:00
|
|
|
target_ulong tmp = ctx->nip;
|
|
|
|
ctx->nip = dest;
|
2008-12-11 23:42:14 +01:00
|
|
|
gen_exception(ctx, POWERPC_EXCP_TRACE);
|
2008-05-11 01:28:14 +02:00
|
|
|
ctx->nip = tmp;
|
|
|
|
}
|
|
|
|
if (ctx->singlestep_enabled & GDBSTUB_SINGLE_STEP) {
|
2008-12-11 23:42:14 +01:00
|
|
|
gen_debug_exception(ctx);
|
2008-05-11 01:28:14 +02:00
|
|
|
}
|
|
|
|
}
|
2008-02-01 11:50:11 +01:00
|
|
|
tcg_gen_exit_tb(0);
|
2005-11-20 11:31:08 +01:00
|
|
|
}
|
2005-10-30 22:39:19 +01:00
|
|
|
}
|
|
|
|
|
2009-08-16 11:06:54 +02:00
|
|
|
static inline void gen_setlr(DisasContext *ctx, target_ulong nip)
|
2007-09-29 15:06:16 +02:00
|
|
|
{
|
2013-03-21 11:01:46 +01:00
|
|
|
if (NARROW_MODE(ctx)) {
|
|
|
|
nip = (uint32_t)nip;
|
|
|
|
}
|
|
|
|
tcg_gen_movi_tl(cpu_lr, nip);
|
2007-09-29 15:06:16 +02:00
|
|
|
}
|
|
|
|
|
2003-11-23 15:55:54 +01:00
|
|
|
/* b ba bl bla */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_b(DisasContext *ctx)
|
2003-11-23 15:55:54 +01:00
|
|
|
{
|
2007-03-07 09:32:30 +01:00
|
|
|
target_ulong li, target;
|
2004-07-08 00:06:01 +02:00
|
|
|
|
2008-05-11 01:28:14 +02:00
|
|
|
ctx->exception = POWERPC_EXCP_BRANCH;
|
2004-07-08 00:06:01 +02:00
|
|
|
/* sign extend LI */
|
2013-03-21 11:01:46 +01:00
|
|
|
li = LI(ctx->opcode);
|
|
|
|
li = (li ^ 0x02000000) - 0x02000000;
|
|
|
|
if (likely(AA(ctx->opcode) == 0)) {
|
2004-04-25 23:15:35 +02:00
|
|
|
target = ctx->nip + li - 4;
|
2013-03-21 11:01:46 +01:00
|
|
|
} else {
|
2004-01-04 23:58:38 +01:00
|
|
|
target = li;
|
2013-03-21 11:01:46 +01:00
|
|
|
}
|
|
|
|
if (LK(ctx->opcode)) {
|
2007-09-29 15:06:16 +02:00
|
|
|
gen_setlr(ctx, ctx->nip);
|
2013-03-21 11:01:46 +01:00
|
|
|
}
|
2011-08-31 17:45:10 +02:00
|
|
|
gen_update_cfar(ctx, ctx->nip);
|
2005-11-20 11:31:08 +01:00
|
|
|
gen_goto_tb(ctx, 0, target);
|
2003-11-23 15:55:54 +01:00
|
|
|
}
|
|
|
|
|
2004-02-21 16:35:00 +01:00
|
|
|
#define BCOND_IM 0
|
|
|
|
#define BCOND_LR 1
|
|
|
|
#define BCOND_CTR 2
|
2014-02-10 18:26:55 +01:00
|
|
|
#define BCOND_TAR 3
|
2004-02-21 16:35:00 +01:00
|
|
|
|
2009-08-16 11:06:54 +02:00
|
|
|
static inline void gen_bcond(DisasContext *ctx, int type)
|
2007-03-17 15:02:15 +01:00
|
|
|
{
|
|
|
|
uint32_t bo = BO(ctx->opcode);
|
2015-02-13 21:51:55 +01:00
|
|
|
TCGLabel *l1;
|
2008-10-21 18:31:31 +02:00
|
|
|
TCGv target;
|
2004-02-21 16:35:00 +01:00
|
|
|
|
2008-05-11 01:28:14 +02:00
|
|
|
ctx->exception = POWERPC_EXCP_BRANCH;
|
2014-02-10 18:26:55 +01:00
|
|
|
if (type == BCOND_LR || type == BCOND_CTR || type == BCOND_TAR) {
|
2008-11-17 15:43:54 +01:00
|
|
|
target = tcg_temp_local_new();
|
2008-10-21 18:31:31 +02:00
|
|
|
if (type == BCOND_CTR)
|
|
|
|
tcg_gen_mov_tl(target, cpu_ctr);
|
2014-02-10 18:26:55 +01:00
|
|
|
else if (type == BCOND_TAR)
|
|
|
|
gen_load_spr(target, SPR_TAR);
|
2008-10-21 18:31:31 +02:00
|
|
|
else
|
|
|
|
tcg_gen_mov_tl(target, cpu_lr);
|
2009-06-20 03:51:47 +02:00
|
|
|
} else {
|
|
|
|
TCGV_UNUSED(target);
|
2004-02-21 16:35:00 +01:00
|
|
|
}
|
2007-09-29 15:06:16 +02:00
|
|
|
if (LK(ctx->opcode))
|
|
|
|
gen_setlr(ctx, ctx->nip);
|
2008-10-21 18:31:31 +02:00
|
|
|
l1 = gen_new_label();
|
|
|
|
if ((bo & 0x4) == 0) {
|
|
|
|
/* Decrement and test CTR */
|
2008-11-17 15:43:54 +01:00
|
|
|
TCGv temp = tcg_temp_new();
|
2008-10-21 18:31:31 +02:00
|
|
|
if (unlikely(type == BCOND_CTR)) {
|
2008-12-11 23:42:14 +01:00
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_INVAL_INVAL);
|
2008-10-21 18:31:31 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
tcg_gen_subi_tl(cpu_ctr, cpu_ctr, 1);
|
2013-03-21 11:01:46 +01:00
|
|
|
if (NARROW_MODE(ctx)) {
|
2008-10-21 18:31:31 +02:00
|
|
|
tcg_gen_ext32u_tl(temp, cpu_ctr);
|
2013-03-21 11:01:46 +01:00
|
|
|
} else {
|
2008-10-21 18:31:31 +02:00
|
|
|
tcg_gen_mov_tl(temp, cpu_ctr);
|
2013-03-21 11:01:46 +01:00
|
|
|
}
|
2008-10-21 18:31:31 +02:00
|
|
|
if (bo & 0x2) {
|
|
|
|
tcg_gen_brcondi_tl(TCG_COND_NE, temp, 0, l1);
|
|
|
|
} else {
|
|
|
|
tcg_gen_brcondi_tl(TCG_COND_EQ, temp, 0, l1);
|
2004-02-21 16:35:00 +01:00
|
|
|
}
|
2008-11-17 15:43:54 +01:00
|
|
|
tcg_temp_free(temp);
|
2008-10-21 18:31:31 +02:00
|
|
|
}
|
|
|
|
if ((bo & 0x10) == 0) {
|
|
|
|
/* Test CR */
|
|
|
|
uint32_t bi = BI(ctx->opcode);
|
2014-08-28 19:15:09 +02:00
|
|
|
uint32_t mask = 0x08 >> (bi & 0x03);
|
2008-11-17 15:43:54 +01:00
|
|
|
TCGv_i32 temp = tcg_temp_new_i32();
|
2008-10-21 18:31:31 +02:00
|
|
|
|
2007-03-17 15:02:15 +01:00
|
|
|
if (bo & 0x8) {
|
2008-10-21 18:31:31 +02:00
|
|
|
tcg_gen_andi_i32(temp, cpu_crf[bi >> 2], mask);
|
|
|
|
tcg_gen_brcondi_i32(TCG_COND_EQ, temp, 0, l1);
|
2007-03-17 15:02:15 +01:00
|
|
|
} else {
|
2008-10-21 18:31:31 +02:00
|
|
|
tcg_gen_andi_i32(temp, cpu_crf[bi >> 2], mask);
|
|
|
|
tcg_gen_brcondi_i32(TCG_COND_NE, temp, 0, l1);
|
2007-03-17 15:02:15 +01:00
|
|
|
}
|
2008-11-17 15:43:54 +01:00
|
|
|
tcg_temp_free_i32(temp);
|
2007-03-17 15:02:15 +01:00
|
|
|
}
|
2011-08-31 17:45:10 +02:00
|
|
|
gen_update_cfar(ctx, ctx->nip);
|
2004-02-21 16:35:00 +01:00
|
|
|
if (type == BCOND_IM) {
|
2008-10-21 18:31:31 +02:00
|
|
|
target_ulong li = (target_long)((int16_t)(BD(ctx->opcode)));
|
|
|
|
if (likely(AA(ctx->opcode) == 0)) {
|
|
|
|
gen_goto_tb(ctx, 0, ctx->nip + li - 4);
|
|
|
|
} else {
|
|
|
|
gen_goto_tb(ctx, 0, li);
|
|
|
|
}
|
2005-10-30 22:39:19 +01:00
|
|
|
gen_set_label(l1);
|
2005-11-20 11:31:08 +01:00
|
|
|
gen_goto_tb(ctx, 1, ctx->nip);
|
2004-02-21 16:35:00 +01:00
|
|
|
} else {
|
2013-03-21 11:01:46 +01:00
|
|
|
if (NARROW_MODE(ctx)) {
|
2008-10-21 18:31:31 +02:00
|
|
|
tcg_gen_andi_tl(cpu_nip, target, (uint32_t)~3);
|
2013-03-21 11:01:46 +01:00
|
|
|
} else {
|
2008-10-21 18:31:31 +02:00
|
|
|
tcg_gen_andi_tl(cpu_nip, target, ~3);
|
2013-03-21 11:01:46 +01:00
|
|
|
}
|
2008-10-21 18:31:31 +02:00
|
|
|
tcg_gen_exit_tb(0);
|
|
|
|
gen_set_label(l1);
|
2013-03-21 11:01:46 +01:00
|
|
|
gen_update_nip(ctx, ctx->nip);
|
2008-02-01 11:50:11 +01:00
|
|
|
tcg_gen_exit_tb(0);
|
2007-04-16 09:18:42 +02:00
|
|
|
}
|
2014-06-04 19:26:02 +02:00
|
|
|
if (type == BCOND_LR || type == BCOND_CTR || type == BCOND_TAR) {
|
2014-01-19 17:26:33 +01:00
|
|
|
tcg_temp_free(target);
|
|
|
|
}
|
2004-02-21 16:35:00 +01:00
|
|
|
}
|
|
|
|
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_bc(DisasContext *ctx)
|
2007-09-17 10:09:54 +02:00
|
|
|
{
|
2004-02-21 16:35:00 +01:00
|
|
|
gen_bcond(ctx, BCOND_IM);
|
|
|
|
}
|
|
|
|
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_bcctr(DisasContext *ctx)
|
2007-09-17 10:09:54 +02:00
|
|
|
{
|
2004-02-21 16:35:00 +01:00
|
|
|
gen_bcond(ctx, BCOND_CTR);
|
|
|
|
}
|
|
|
|
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_bclr(DisasContext *ctx)
|
2007-09-17 10:09:54 +02:00
|
|
|
{
|
2004-02-21 16:35:00 +01:00
|
|
|
gen_bcond(ctx, BCOND_LR);
|
|
|
|
}
|
2003-11-23 15:55:54 +01:00
|
|
|
|
2014-02-10 18:26:55 +01:00
|
|
|
static void gen_bctar(DisasContext *ctx)
|
|
|
|
{
|
|
|
|
gen_bcond(ctx, BCOND_TAR);
|
|
|
|
}
|
|
|
|
|
2003-11-23 15:55:54 +01:00
|
|
|
/*** Condition register logical ***/
|
2008-10-21 13:31:14 +02:00
|
|
|
#define GEN_CRLOGIC(name, tcg_op, opc) \
|
2009-06-17 17:22:09 +02:00
|
|
|
static void glue(gen_, name)(DisasContext *ctx) \
|
2003-11-23 15:55:54 +01:00
|
|
|
{ \
|
2007-10-31 23:02:17 +01:00
|
|
|
uint8_t bitmask; \
|
|
|
|
int sh; \
|
2008-11-17 15:43:54 +01:00
|
|
|
TCGv_i32 t0, t1; \
|
2007-10-31 23:02:17 +01:00
|
|
|
sh = (crbD(ctx->opcode) & 0x03) - (crbA(ctx->opcode) & 0x03); \
|
2008-11-17 15:43:54 +01:00
|
|
|
t0 = tcg_temp_new_i32(); \
|
2007-10-31 23:02:17 +01:00
|
|
|
if (sh > 0) \
|
2008-11-02 09:22:34 +01:00
|
|
|
tcg_gen_shri_i32(t0, cpu_crf[crbA(ctx->opcode) >> 2], sh); \
|
2007-10-31 23:02:17 +01:00
|
|
|
else if (sh < 0) \
|
2008-11-02 09:22:34 +01:00
|
|
|
tcg_gen_shli_i32(t0, cpu_crf[crbA(ctx->opcode) >> 2], -sh); \
|
2008-10-21 13:31:14 +02:00
|
|
|
else \
|
2008-11-02 09:22:34 +01:00
|
|
|
tcg_gen_mov_i32(t0, cpu_crf[crbA(ctx->opcode) >> 2]); \
|
2008-11-17 15:43:54 +01:00
|
|
|
t1 = tcg_temp_new_i32(); \
|
2007-10-31 23:02:17 +01:00
|
|
|
sh = (crbD(ctx->opcode) & 0x03) - (crbB(ctx->opcode) & 0x03); \
|
|
|
|
if (sh > 0) \
|
2008-11-02 09:22:34 +01:00
|
|
|
tcg_gen_shri_i32(t1, cpu_crf[crbB(ctx->opcode) >> 2], sh); \
|
2007-10-31 23:02:17 +01:00
|
|
|
else if (sh < 0) \
|
2008-11-02 09:22:34 +01:00
|
|
|
tcg_gen_shli_i32(t1, cpu_crf[crbB(ctx->opcode) >> 2], -sh); \
|
2008-10-21 13:31:14 +02:00
|
|
|
else \
|
2008-11-02 09:22:34 +01:00
|
|
|
tcg_gen_mov_i32(t1, cpu_crf[crbB(ctx->opcode) >> 2]); \
|
|
|
|
tcg_op(t0, t0, t1); \
|
2014-08-28 19:15:09 +02:00
|
|
|
bitmask = 0x08 >> (crbD(ctx->opcode) & 0x03); \
|
2008-11-02 09:22:34 +01:00
|
|
|
tcg_gen_andi_i32(t0, t0, bitmask); \
|
|
|
|
tcg_gen_andi_i32(t1, cpu_crf[crbD(ctx->opcode) >> 2], ~bitmask); \
|
|
|
|
tcg_gen_or_i32(cpu_crf[crbD(ctx->opcode) >> 2], t0, t1); \
|
2008-11-17 15:43:54 +01:00
|
|
|
tcg_temp_free_i32(t0); \
|
|
|
|
tcg_temp_free_i32(t1); \
|
2003-11-23 15:55:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* crand */
|
2008-10-21 13:31:14 +02:00
|
|
|
GEN_CRLOGIC(crand, tcg_gen_and_i32, 0x08);
|
2003-11-23 15:55:54 +01:00
|
|
|
/* crandc */
|
2008-10-21 13:31:14 +02:00
|
|
|
GEN_CRLOGIC(crandc, tcg_gen_andc_i32, 0x04);
|
2003-11-23 15:55:54 +01:00
|
|
|
/* creqv */
|
2008-10-21 13:31:14 +02:00
|
|
|
GEN_CRLOGIC(creqv, tcg_gen_eqv_i32, 0x09);
|
2003-11-23 15:55:54 +01:00
|
|
|
/* crnand */
|
2008-10-21 13:31:14 +02:00
|
|
|
GEN_CRLOGIC(crnand, tcg_gen_nand_i32, 0x07);
|
2003-11-23 15:55:54 +01:00
|
|
|
/* crnor */
|
2008-10-21 13:31:14 +02:00
|
|
|
GEN_CRLOGIC(crnor, tcg_gen_nor_i32, 0x01);
|
2003-11-23 15:55:54 +01:00
|
|
|
/* cror */
|
2008-10-21 13:31:14 +02:00
|
|
|
GEN_CRLOGIC(cror, tcg_gen_or_i32, 0x0E);
|
2003-11-23 15:55:54 +01:00
|
|
|
/* crorc */
|
2008-10-21 13:31:14 +02:00
|
|
|
GEN_CRLOGIC(crorc, tcg_gen_orc_i32, 0x0D);
|
2003-11-23 15:55:54 +01:00
|
|
|
/* crxor */
|
2008-10-21 13:31:14 +02:00
|
|
|
GEN_CRLOGIC(crxor, tcg_gen_xor_i32, 0x06);
|
2009-06-17 17:22:09 +02:00
|
|
|
|
2009-06-17 17:22:19 +02:00
|
|
|
/* mcrf */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_mcrf(DisasContext *ctx)
|
2003-11-23 15:55:54 +01:00
|
|
|
{
|
2008-09-04 19:06:47 +02:00
|
|
|
tcg_gen_mov_i32(cpu_crf[crfD(ctx->opcode)], cpu_crf[crfS(ctx->opcode)]);
|
2003-11-23 15:55:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*** System linkage ***/
|
2009-06-17 17:22:09 +02:00
|
|
|
|
2014-09-15 17:03:28 +02:00
|
|
|
/* rfi (supervisor only) */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_rfi(DisasContext *ctx)
|
2003-11-23 15:55:54 +01:00
|
|
|
{
|
2004-01-04 23:58:38 +01:00
|
|
|
#if defined(CONFIG_USER_ONLY)
|
2008-12-11 23:42:14 +01:00
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);
|
2004-01-04 23:58:38 +01:00
|
|
|
#else
|
|
|
|
/* Restore CPU state */
|
2014-09-15 17:03:28 +02:00
|
|
|
if (unlikely(ctx->pr)) {
|
2008-12-11 23:42:14 +01:00
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);
|
2004-05-21 14:59:32 +02:00
|
|
|
return;
|
2004-01-04 23:58:38 +01:00
|
|
|
}
|
2011-08-31 17:45:10 +02:00
|
|
|
gen_update_cfar(ctx, ctx->nip);
|
2012-05-30 06:23:23 +02:00
|
|
|
gen_helper_rfi(cpu_env);
|
2008-12-11 23:42:14 +01:00
|
|
|
gen_sync_exception(ctx);
|
2004-01-04 23:58:38 +01:00
|
|
|
#endif
|
2003-11-23 15:55:54 +01:00
|
|
|
}
|
|
|
|
|
2007-03-23 10:45:27 +01:00
|
|
|
#if defined(TARGET_PPC64)
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_rfid(DisasContext *ctx)
|
2007-03-23 10:45:27 +01:00
|
|
|
{
|
|
|
|
#if defined(CONFIG_USER_ONLY)
|
2008-12-11 23:42:14 +01:00
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);
|
2007-03-23 10:45:27 +01:00
|
|
|
#else
|
|
|
|
/* Restore CPU state */
|
2014-09-15 17:03:28 +02:00
|
|
|
if (unlikely(ctx->pr)) {
|
2008-12-11 23:42:14 +01:00
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);
|
2007-03-23 10:45:27 +01:00
|
|
|
return;
|
|
|
|
}
|
2011-08-31 17:45:10 +02:00
|
|
|
gen_update_cfar(ctx, ctx->nip);
|
2012-05-30 06:23:23 +02:00
|
|
|
gen_helper_rfid(cpu_env);
|
2008-12-11 23:42:14 +01:00
|
|
|
gen_sync_exception(ctx);
|
2007-03-23 10:45:27 +01:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_hrfid(DisasContext *ctx)
|
2007-09-30 15:03:23 +02:00
|
|
|
{
|
|
|
|
#if defined(CONFIG_USER_ONLY)
|
2008-12-11 23:42:14 +01:00
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);
|
2007-09-30 15:03:23 +02:00
|
|
|
#else
|
|
|
|
/* Restore CPU state */
|
2014-09-15 17:03:28 +02:00
|
|
|
if (unlikely(!ctx->hv)) {
|
2008-12-11 23:42:14 +01:00
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);
|
2007-09-30 15:03:23 +02:00
|
|
|
return;
|
|
|
|
}
|
2012-05-30 06:23:23 +02:00
|
|
|
gen_helper_hrfid(cpu_env);
|
2008-12-11 23:42:14 +01:00
|
|
|
gen_sync_exception(ctx);
|
2007-09-30 15:03:23 +02:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2003-11-23 15:55:54 +01:00
|
|
|
/* sc */
|
2007-10-08 01:10:08 +02:00
|
|
|
#if defined(CONFIG_USER_ONLY)
|
|
|
|
#define POWERPC_SYSCALL POWERPC_EXCP_SYSCALL_USER
|
|
|
|
#else
|
|
|
|
#define POWERPC_SYSCALL POWERPC_EXCP_SYSCALL
|
|
|
|
#endif
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_sc(DisasContext *ctx)
|
2003-11-23 15:55:54 +01:00
|
|
|
{
|
2007-09-29 15:06:16 +02:00
|
|
|
uint32_t lev;
|
|
|
|
|
|
|
|
lev = (ctx->opcode >> 5) & 0x7F;
|
2008-12-11 23:42:14 +01:00
|
|
|
gen_exception_err(ctx, POWERPC_SYSCALL, lev);
|
2003-11-23 15:55:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*** Trap ***/
|
2009-06-17 17:22:09 +02:00
|
|
|
|
2009-06-17 17:22:19 +02:00
|
|
|
/* tw */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_tw(DisasContext *ctx)
|
2003-11-23 15:55:54 +01:00
|
|
|
{
|
2008-11-24 12:28:19 +01:00
|
|
|
TCGv_i32 t0 = tcg_const_i32(TO(ctx->opcode));
|
2010-02-28 16:02:28 +01:00
|
|
|
/* Update the nip since this might generate a trap exception */
|
|
|
|
gen_update_nip(ctx, ctx->nip);
|
2012-05-30 06:23:23 +02:00
|
|
|
gen_helper_tw(cpu_env, cpu_gpr[rA(ctx->opcode)], cpu_gpr[rB(ctx->opcode)],
|
|
|
|
t0);
|
2008-11-24 12:28:19 +01:00
|
|
|
tcg_temp_free_i32(t0);
|
2003-11-23 15:55:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* twi */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_twi(DisasContext *ctx)
|
2003-11-23 15:55:54 +01:00
|
|
|
{
|
2008-11-24 12:28:19 +01:00
|
|
|
TCGv t0 = tcg_const_tl(SIMM(ctx->opcode));
|
|
|
|
TCGv_i32 t1 = tcg_const_i32(TO(ctx->opcode));
|
2010-02-28 16:02:28 +01:00
|
|
|
/* Update the nip since this might generate a trap exception */
|
|
|
|
gen_update_nip(ctx, ctx->nip);
|
2012-05-30 06:23:23 +02:00
|
|
|
gen_helper_tw(cpu_env, cpu_gpr[rA(ctx->opcode)], t0, t1);
|
2008-11-24 12:28:19 +01:00
|
|
|
tcg_temp_free(t0);
|
|
|
|
tcg_temp_free_i32(t1);
|
2003-11-23 15:55:54 +01:00
|
|
|
}
|
|
|
|
|
2007-03-17 15:02:15 +01:00
|
|
|
#if defined(TARGET_PPC64)
|
|
|
|
/* td */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_td(DisasContext *ctx)
|
2007-03-17 15:02:15 +01:00
|
|
|
{
|
2008-11-24 12:28:19 +01:00
|
|
|
TCGv_i32 t0 = tcg_const_i32(TO(ctx->opcode));
|
2010-02-28 16:02:28 +01:00
|
|
|
/* Update the nip since this might generate a trap exception */
|
|
|
|
gen_update_nip(ctx, ctx->nip);
|
2012-05-30 06:23:23 +02:00
|
|
|
gen_helper_td(cpu_env, cpu_gpr[rA(ctx->opcode)], cpu_gpr[rB(ctx->opcode)],
|
|
|
|
t0);
|
2008-11-24 12:28:19 +01:00
|
|
|
tcg_temp_free_i32(t0);
|
2007-03-17 15:02:15 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* tdi */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_tdi(DisasContext *ctx)
|
2007-03-17 15:02:15 +01:00
|
|
|
{
|
2008-11-24 12:28:19 +01:00
|
|
|
TCGv t0 = tcg_const_tl(SIMM(ctx->opcode));
|
|
|
|
TCGv_i32 t1 = tcg_const_i32(TO(ctx->opcode));
|
2010-02-28 16:02:28 +01:00
|
|
|
/* Update the nip since this might generate a trap exception */
|
|
|
|
gen_update_nip(ctx, ctx->nip);
|
2012-05-30 06:23:23 +02:00
|
|
|
gen_helper_td(cpu_env, cpu_gpr[rA(ctx->opcode)], t0, t1);
|
2008-11-24 12:28:19 +01:00
|
|
|
tcg_temp_free(t0);
|
|
|
|
tcg_temp_free_i32(t1);
|
2007-03-17 15:02:15 +01:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2003-11-23 15:55:54 +01:00
|
|
|
/*** Processor control ***/
|
2009-06-17 17:22:09 +02:00
|
|
|
|
2013-02-20 08:52:13 +01:00
|
|
|
static void gen_read_xer(TCGv dst)
|
|
|
|
{
|
|
|
|
TCGv t0 = tcg_temp_new();
|
|
|
|
TCGv t1 = tcg_temp_new();
|
|
|
|
TCGv t2 = tcg_temp_new();
|
|
|
|
tcg_gen_mov_tl(dst, cpu_xer);
|
|
|
|
tcg_gen_shli_tl(t0, cpu_so, XER_SO);
|
|
|
|
tcg_gen_shli_tl(t1, cpu_ov, XER_OV);
|
|
|
|
tcg_gen_shli_tl(t2, cpu_ca, XER_CA);
|
|
|
|
tcg_gen_or_tl(t0, t0, t1);
|
|
|
|
tcg_gen_or_tl(dst, dst, t2);
|
|
|
|
tcg_gen_or_tl(dst, dst, t0);
|
|
|
|
tcg_temp_free(t0);
|
|
|
|
tcg_temp_free(t1);
|
|
|
|
tcg_temp_free(t2);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void gen_write_xer(TCGv src)
|
|
|
|
{
|
|
|
|
tcg_gen_andi_tl(cpu_xer, src,
|
|
|
|
~((1u << XER_SO) | (1u << XER_OV) | (1u << XER_CA)));
|
|
|
|
tcg_gen_shri_tl(cpu_so, src, XER_SO);
|
|
|
|
tcg_gen_shri_tl(cpu_ov, src, XER_OV);
|
|
|
|
tcg_gen_shri_tl(cpu_ca, src, XER_CA);
|
|
|
|
tcg_gen_andi_tl(cpu_so, cpu_so, 1);
|
|
|
|
tcg_gen_andi_tl(cpu_ov, cpu_ov, 1);
|
|
|
|
tcg_gen_andi_tl(cpu_ca, cpu_ca, 1);
|
|
|
|
}
|
|
|
|
|
2009-06-17 17:22:19 +02:00
|
|
|
/* mcrxr */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_mcrxr(DisasContext *ctx)
|
2003-11-23 15:55:54 +01:00
|
|
|
{
|
2013-02-20 08:52:13 +01:00
|
|
|
TCGv_i32 t0 = tcg_temp_new_i32();
|
|
|
|
TCGv_i32 t1 = tcg_temp_new_i32();
|
|
|
|
TCGv_i32 dst = cpu_crf[crfD(ctx->opcode)];
|
|
|
|
|
|
|
|
tcg_gen_trunc_tl_i32(t0, cpu_so);
|
|
|
|
tcg_gen_trunc_tl_i32(t1, cpu_ov);
|
|
|
|
tcg_gen_trunc_tl_i32(dst, cpu_ca);
|
2014-06-17 07:54:02 +02:00
|
|
|
tcg_gen_shli_i32(t0, t0, 3);
|
|
|
|
tcg_gen_shli_i32(t1, t1, 2);
|
|
|
|
tcg_gen_shli_i32(dst, dst, 1);
|
2013-02-20 08:52:13 +01:00
|
|
|
tcg_gen_or_i32(dst, dst, t0);
|
|
|
|
tcg_gen_or_i32(dst, dst, t1);
|
|
|
|
tcg_temp_free_i32(t0);
|
|
|
|
tcg_temp_free_i32(t1);
|
|
|
|
|
|
|
|
tcg_gen_movi_tl(cpu_so, 0);
|
|
|
|
tcg_gen_movi_tl(cpu_ov, 0);
|
|
|
|
tcg_gen_movi_tl(cpu_ca, 0);
|
2003-11-23 15:55:54 +01:00
|
|
|
}
|
|
|
|
|
2009-03-03 07:12:14 +01:00
|
|
|
/* mfcr mfocrf */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_mfcr(DisasContext *ctx)
|
2003-11-23 15:55:54 +01:00
|
|
|
{
|
2007-03-07 09:32:30 +01:00
|
|
|
uint32_t crm, crn;
|
2007-09-17 10:09:54 +02:00
|
|
|
|
2007-03-07 09:32:30 +01:00
|
|
|
if (likely(ctx->opcode & 0x00100000)) {
|
|
|
|
crm = CRM(ctx->opcode);
|
2009-03-02 23:39:39 +01:00
|
|
|
if (likely(crm && ((crm & (crm - 1)) == 0))) {
|
2009-03-03 07:12:14 +01:00
|
|
|
crn = ctz32 (crm);
|
2008-10-21 13:31:14 +02:00
|
|
|
tcg_gen_extu_i32_tl(cpu_gpr[rD(ctx->opcode)], cpu_crf[7 - crn]);
|
2009-03-07 21:57:47 +01:00
|
|
|
tcg_gen_shli_tl(cpu_gpr[rD(ctx->opcode)],
|
|
|
|
cpu_gpr[rD(ctx->opcode)], crn * 4);
|
2007-03-07 09:32:30 +01:00
|
|
|
}
|
2007-03-17 15:02:15 +01:00
|
|
|
} else {
|
2009-03-09 19:50:24 +01:00
|
|
|
TCGv_i32 t0 = tcg_temp_new_i32();
|
|
|
|
tcg_gen_mov_i32(t0, cpu_crf[0]);
|
|
|
|
tcg_gen_shli_i32(t0, t0, 4);
|
|
|
|
tcg_gen_or_i32(t0, t0, cpu_crf[1]);
|
|
|
|
tcg_gen_shli_i32(t0, t0, 4);
|
|
|
|
tcg_gen_or_i32(t0, t0, cpu_crf[2]);
|
|
|
|
tcg_gen_shli_i32(t0, t0, 4);
|
|
|
|
tcg_gen_or_i32(t0, t0, cpu_crf[3]);
|
|
|
|
tcg_gen_shli_i32(t0, t0, 4);
|
|
|
|
tcg_gen_or_i32(t0, t0, cpu_crf[4]);
|
|
|
|
tcg_gen_shli_i32(t0, t0, 4);
|
|
|
|
tcg_gen_or_i32(t0, t0, cpu_crf[5]);
|
|
|
|
tcg_gen_shli_i32(t0, t0, 4);
|
|
|
|
tcg_gen_or_i32(t0, t0, cpu_crf[6]);
|
|
|
|
tcg_gen_shli_i32(t0, t0, 4);
|
|
|
|
tcg_gen_or_i32(t0, t0, cpu_crf[7]);
|
|
|
|
tcg_gen_extu_i32_tl(cpu_gpr[rD(ctx->opcode)], t0);
|
|
|
|
tcg_temp_free_i32(t0);
|
2007-03-17 15:02:15 +01:00
|
|
|
}
|
2003-11-23 15:55:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* mfmsr */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_mfmsr(DisasContext *ctx)
|
2003-11-23 15:55:54 +01:00
|
|
|
{
|
2004-01-04 23:58:38 +01:00
|
|
|
#if defined(CONFIG_USER_ONLY)
|
2008-12-11 23:42:14 +01:00
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG);
|
2004-01-04 23:58:38 +01:00
|
|
|
#else
|
2014-09-15 17:03:28 +02:00
|
|
|
if (unlikely(ctx->pr)) {
|
2008-12-11 23:42:14 +01:00
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG);
|
2004-05-21 14:59:32 +02:00
|
|
|
return;
|
2004-01-04 23:58:38 +01:00
|
|
|
}
|
2008-12-06 14:03:35 +01:00
|
|
|
tcg_gen_mov_tl(cpu_gpr[rD(ctx->opcode)], cpu_msr);
|
2004-01-04 23:58:38 +01:00
|
|
|
#endif
|
2003-11-23 15:55:54 +01:00
|
|
|
}
|
|
|
|
|
2014-11-26 11:39:48 +01:00
|
|
|
static void spr_noaccess(DisasContext *ctx, int gprn, int sprn)
|
2005-07-02 22:59:34 +02:00
|
|
|
{
|
2010-04-18 16:26:51 +02:00
|
|
|
#if 0
|
2005-07-02 22:59:34 +02:00
|
|
|
sprn = ((sprn >> 5) & 0x1F) | ((sprn & 0x1F) << 5);
|
|
|
|
printf("ERROR: try to access SPR %d !\n", sprn);
|
2010-04-18 16:26:51 +02:00
|
|
|
#endif
|
2005-07-02 22:59:34 +02:00
|
|
|
}
|
|
|
|
#define SPR_NOACCESS (&spr_noaccess)
|
|
|
|
|
2003-11-23 15:55:54 +01:00
|
|
|
/* mfspr */
|
2009-08-16 11:06:54 +02:00
|
|
|
static inline void gen_op_mfspr(DisasContext *ctx)
|
2003-11-23 15:55:54 +01:00
|
|
|
{
|
2014-11-26 11:39:48 +01:00
|
|
|
void (*read_cb)(DisasContext *ctx, int gprn, int sprn);
|
2003-11-23 15:55:54 +01:00
|
|
|
uint32_t sprn = SPR(ctx->opcode);
|
|
|
|
|
2016-03-21 13:52:32 +01:00
|
|
|
#if defined(CONFIG_USER_ONLY)
|
|
|
|
read_cb = ctx->spr_cb[sprn].uea_read;
|
|
|
|
#else
|
|
|
|
if (ctx->pr) {
|
|
|
|
read_cb = ctx->spr_cb[sprn].uea_read;
|
|
|
|
} else if (ctx->hv) {
|
2007-09-30 15:03:23 +02:00
|
|
|
read_cb = ctx->spr_cb[sprn].hea_read;
|
2016-03-21 13:52:32 +01:00
|
|
|
} else {
|
2005-07-02 22:59:34 +02:00
|
|
|
read_cb = ctx->spr_cb[sprn].oea_read;
|
2016-03-21 13:52:32 +01:00
|
|
|
}
|
2004-01-04 23:58:38 +01:00
|
|
|
#endif
|
2007-03-07 09:32:30 +01:00
|
|
|
if (likely(read_cb != NULL)) {
|
|
|
|
if (likely(read_cb != SPR_NOACCESS)) {
|
2008-12-07 14:40:29 +01:00
|
|
|
(*read_cb)(ctx, rD(ctx->opcode), sprn);
|
2005-07-02 22:59:34 +02:00
|
|
|
} else {
|
|
|
|
/* Privilege exception */
|
2007-11-02 23:47:50 +01:00
|
|
|
/* This is a hack to avoid warnings when running Linux:
|
|
|
|
* this OS breaks the PowerPC virtualisation model,
|
|
|
|
* allowing userland application to read the PVR
|
|
|
|
*/
|
|
|
|
if (sprn != SPR_PVR) {
|
2015-11-13 13:16:27 +01:00
|
|
|
fprintf(stderr, "Trying to read privileged spr %d (0x%03x) at "
|
|
|
|
TARGET_FMT_lx "\n", sprn, sprn, ctx->nip - 4);
|
|
|
|
if (qemu_log_separate()) {
|
|
|
|
qemu_log("Trying to read privileged spr %d (0x%03x) at "
|
|
|
|
TARGET_FMT_lx "\n", sprn, sprn, ctx->nip - 4);
|
|
|
|
}
|
2005-11-23 22:36:30 +01:00
|
|
|
}
|
2008-12-11 23:42:14 +01:00
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG);
|
2003-11-23 15:55:54 +01:00
|
|
|
}
|
2005-07-02 22:59:34 +02:00
|
|
|
} else {
|
|
|
|
/* Not defined */
|
2015-11-13 13:16:27 +01:00
|
|
|
fprintf(stderr, "Trying to read invalid spr %d (0x%03x) at "
|
|
|
|
TARGET_FMT_lx "\n", sprn, sprn, ctx->nip - 4);
|
|
|
|
if (qemu_log_separate()) {
|
|
|
|
qemu_log("Trying to read invalid spr %d (0x%03x) at "
|
|
|
|
TARGET_FMT_lx "\n", sprn, sprn, ctx->nip - 4);
|
|
|
|
}
|
2008-12-11 23:42:14 +01:00
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_INVAL_SPR);
|
2003-11-23 15:55:54 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_mfspr(DisasContext *ctx)
|
2003-11-23 15:55:54 +01:00
|
|
|
{
|
2005-07-02 22:59:34 +02:00
|
|
|
gen_op_mfspr(ctx);
|
2007-03-07 09:32:30 +01:00
|
|
|
}
|
2005-07-02 22:59:34 +02:00
|
|
|
|
|
|
|
/* mftb */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_mftb(DisasContext *ctx)
|
2005-07-02 22:59:34 +02:00
|
|
|
{
|
|
|
|
gen_op_mfspr(ctx);
|
2003-11-23 15:55:54 +01:00
|
|
|
}
|
|
|
|
|
2009-03-03 07:12:14 +01:00
|
|
|
/* mtcrf mtocrf*/
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_mtcrf(DisasContext *ctx)
|
2003-11-23 15:55:54 +01:00
|
|
|
{
|
2007-03-07 09:32:30 +01:00
|
|
|
uint32_t crm, crn;
|
2007-09-17 10:09:54 +02:00
|
|
|
|
2007-03-07 09:32:30 +01:00
|
|
|
crm = CRM(ctx->opcode);
|
2009-03-02 23:39:39 +01:00
|
|
|
if (likely((ctx->opcode & 0x00100000))) {
|
|
|
|
if (crm && ((crm & (crm - 1)) == 0)) {
|
|
|
|
TCGv_i32 temp = tcg_temp_new_i32();
|
2009-03-03 07:12:14 +01:00
|
|
|
crn = ctz32 (crm);
|
2009-03-02 23:39:39 +01:00
|
|
|
tcg_gen_trunc_tl_i32(temp, cpu_gpr[rS(ctx->opcode)]);
|
2009-03-03 07:12:14 +01:00
|
|
|
tcg_gen_shri_i32(temp, temp, crn * 4);
|
|
|
|
tcg_gen_andi_i32(cpu_crf[7 - crn], temp, 0xf);
|
2009-03-02 23:39:39 +01:00
|
|
|
tcg_temp_free_i32(temp);
|
|
|
|
}
|
2007-03-07 09:32:30 +01:00
|
|
|
} else {
|
2009-03-09 19:50:24 +01:00
|
|
|
TCGv_i32 temp = tcg_temp_new_i32();
|
|
|
|
tcg_gen_trunc_tl_i32(temp, cpu_gpr[rS(ctx->opcode)]);
|
|
|
|
for (crn = 0 ; crn < 8 ; crn++) {
|
|
|
|
if (crm & (1 << crn)) {
|
|
|
|
tcg_gen_shri_i32(cpu_crf[7 - crn], temp, crn * 4);
|
|
|
|
tcg_gen_andi_i32(cpu_crf[7 - crn], cpu_crf[7 - crn], 0xf);
|
|
|
|
}
|
|
|
|
}
|
2008-11-17 15:43:54 +01:00
|
|
|
tcg_temp_free_i32(temp);
|
2007-03-07 09:32:30 +01:00
|
|
|
}
|
2003-11-23 15:55:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* mtmsr */
|
2007-03-23 10:45:27 +01:00
|
|
|
#if defined(TARGET_PPC64)
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_mtmsrd(DisasContext *ctx)
|
2007-03-23 10:45:27 +01:00
|
|
|
{
|
|
|
|
#if defined(CONFIG_USER_ONLY)
|
2008-12-11 23:42:14 +01:00
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG);
|
2007-03-23 10:45:27 +01:00
|
|
|
#else
|
2014-09-15 17:03:28 +02:00
|
|
|
if (unlikely(ctx->pr)) {
|
2008-12-11 23:42:14 +01:00
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG);
|
2007-03-23 10:45:27 +01:00
|
|
|
return;
|
|
|
|
}
|
2007-09-30 15:03:23 +02:00
|
|
|
if (ctx->opcode & 0x00010000) {
|
|
|
|
/* Special form that does not need any synchronisation */
|
2008-12-06 14:03:35 +01:00
|
|
|
TCGv t0 = tcg_temp_new();
|
|
|
|
tcg_gen_andi_tl(t0, cpu_gpr[rS(ctx->opcode)], (1 << MSR_RI) | (1 << MSR_EE));
|
|
|
|
tcg_gen_andi_tl(cpu_msr, cpu_msr, ~((1 << MSR_RI) | (1 << MSR_EE)));
|
|
|
|
tcg_gen_or_tl(cpu_msr, cpu_msr, t0);
|
|
|
|
tcg_temp_free(t0);
|
2007-09-30 15:03:23 +02:00
|
|
|
} else {
|
2007-10-01 05:03:51 +02:00
|
|
|
/* XXX: we need to update nip before the store
|
|
|
|
* if we enter power saving mode, we will exit the loop
|
|
|
|
* directly from ppc_store_msr
|
|
|
|
*/
|
2007-09-30 15:03:23 +02:00
|
|
|
gen_update_nip(ctx, ctx->nip);
|
2012-05-30 06:23:23 +02:00
|
|
|
gen_helper_store_msr(cpu_env, cpu_gpr[rS(ctx->opcode)]);
|
2007-09-30 15:03:23 +02:00
|
|
|
/* Must stop the translation as machine state (may have) changed */
|
|
|
|
/* Note that mtmsr is not always defined as context-synchronizing */
|
2008-12-11 23:42:14 +01:00
|
|
|
gen_stop_exception(ctx);
|
2007-09-30 15:03:23 +02:00
|
|
|
}
|
2007-03-23 10:45:27 +01:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_mtmsr(DisasContext *ctx)
|
2003-11-23 15:55:54 +01:00
|
|
|
{
|
2004-01-04 23:58:38 +01:00
|
|
|
#if defined(CONFIG_USER_ONLY)
|
2008-12-11 23:42:14 +01:00
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG);
|
2004-01-04 23:58:38 +01:00
|
|
|
#else
|
2014-09-15 17:03:28 +02:00
|
|
|
if (unlikely(ctx->pr)) {
|
2008-12-11 23:42:14 +01:00
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG);
|
2004-05-21 14:59:32 +02:00
|
|
|
return;
|
2004-01-04 23:58:38 +01:00
|
|
|
}
|
2007-09-30 15:03:23 +02:00
|
|
|
if (ctx->opcode & 0x00010000) {
|
|
|
|
/* Special form that does not need any synchronisation */
|
2008-12-06 14:03:35 +01:00
|
|
|
TCGv t0 = tcg_temp_new();
|
|
|
|
tcg_gen_andi_tl(t0, cpu_gpr[rS(ctx->opcode)], (1 << MSR_RI) | (1 << MSR_EE));
|
|
|
|
tcg_gen_andi_tl(cpu_msr, cpu_msr, ~((1 << MSR_RI) | (1 << MSR_EE)));
|
|
|
|
tcg_gen_or_tl(cpu_msr, cpu_msr, t0);
|
|
|
|
tcg_temp_free(t0);
|
2007-09-30 15:03:23 +02:00
|
|
|
} else {
|
2011-06-16 10:44:23 +02:00
|
|
|
TCGv msr = tcg_temp_new();
|
|
|
|
|
2007-10-01 05:03:51 +02:00
|
|
|
/* XXX: we need to update nip before the store
|
|
|
|
* if we enter power saving mode, we will exit the loop
|
|
|
|
* directly from ppc_store_msr
|
|
|
|
*/
|
2007-09-30 15:03:23 +02:00
|
|
|
gen_update_nip(ctx, ctx->nip);
|
2007-03-17 15:02:15 +01:00
|
|
|
#if defined(TARGET_PPC64)
|
2011-06-16 10:44:23 +02:00
|
|
|
tcg_gen_deposit_tl(msr, cpu_msr, cpu_gpr[rS(ctx->opcode)], 0, 32);
|
|
|
|
#else
|
|
|
|
tcg_gen_mov_tl(msr, cpu_gpr[rS(ctx->opcode)]);
|
2007-03-17 15:02:15 +01:00
|
|
|
#endif
|
2012-05-30 06:23:23 +02:00
|
|
|
gen_helper_store_msr(cpu_env, msr);
|
2014-01-19 17:26:33 +01:00
|
|
|
tcg_temp_free(msr);
|
2007-09-30 15:03:23 +02:00
|
|
|
/* Must stop the translation as machine state (may have) changed */
|
2008-12-06 14:03:35 +01:00
|
|
|
/* Note that mtmsr is not always defined as context-synchronizing */
|
2008-12-11 23:42:14 +01:00
|
|
|
gen_stop_exception(ctx);
|
2007-09-30 15:03:23 +02:00
|
|
|
}
|
2004-01-04 23:58:38 +01:00
|
|
|
#endif
|
2003-11-23 15:55:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* mtspr */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_mtspr(DisasContext *ctx)
|
2003-11-23 15:55:54 +01:00
|
|
|
{
|
2014-11-26 11:39:48 +01:00
|
|
|
void (*write_cb)(DisasContext *ctx, int sprn, int gprn);
|
2003-11-23 15:55:54 +01:00
|
|
|
uint32_t sprn = SPR(ctx->opcode);
|
|
|
|
|
2016-03-21 13:52:32 +01:00
|
|
|
#if defined(CONFIG_USER_ONLY)
|
|
|
|
write_cb = ctx->spr_cb[sprn].uea_write;
|
|
|
|
#else
|
|
|
|
if (ctx->pr) {
|
|
|
|
write_cb = ctx->spr_cb[sprn].uea_write;
|
|
|
|
} else if (ctx->hv) {
|
2007-09-30 15:03:23 +02:00
|
|
|
write_cb = ctx->spr_cb[sprn].hea_write;
|
2016-03-21 13:52:32 +01:00
|
|
|
} else {
|
2005-07-02 22:59:34 +02:00
|
|
|
write_cb = ctx->spr_cb[sprn].oea_write;
|
2016-03-21 13:52:32 +01:00
|
|
|
}
|
2004-01-04 23:58:38 +01:00
|
|
|
#endif
|
2007-03-07 09:32:30 +01:00
|
|
|
if (likely(write_cb != NULL)) {
|
|
|
|
if (likely(write_cb != SPR_NOACCESS)) {
|
2008-12-07 14:40:29 +01:00
|
|
|
(*write_cb)(ctx, sprn, rS(ctx->opcode));
|
2005-07-02 22:59:34 +02:00
|
|
|
} else {
|
|
|
|
/* Privilege exception */
|
2015-11-13 13:16:27 +01:00
|
|
|
fprintf(stderr, "Trying to write privileged spr %d (0x%03x) at "
|
|
|
|
TARGET_FMT_lx "\n", sprn, sprn, ctx->nip - 4);
|
|
|
|
if (qemu_log_separate()) {
|
|
|
|
qemu_log("Trying to write privileged spr %d (0x%03x) at "
|
|
|
|
TARGET_FMT_lx "\n", sprn, sprn, ctx->nip - 4);
|
|
|
|
}
|
2008-12-11 23:42:14 +01:00
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG);
|
2007-03-07 09:32:30 +01:00
|
|
|
}
|
2005-07-02 22:59:34 +02:00
|
|
|
} else {
|
|
|
|
/* Not defined */
|
2015-11-13 13:16:27 +01:00
|
|
|
if (qemu_log_separate()) {
|
|
|
|
qemu_log("Trying to write invalid spr %d (0x%03x) at "
|
|
|
|
TARGET_FMT_lx "\n", sprn, sprn, ctx->nip - 4);
|
|
|
|
}
|
|
|
|
fprintf(stderr, "Trying to write invalid spr %d (0x%03x) at "
|
|
|
|
TARGET_FMT_lx "\n", sprn, sprn, ctx->nip - 4);
|
2008-12-11 23:42:14 +01:00
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_INVAL_SPR);
|
2003-11-23 15:55:54 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*** Cache management ***/
|
2009-06-17 17:22:09 +02:00
|
|
|
|
2009-06-17 17:22:19 +02:00
|
|
|
/* dcbf */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_dcbf(DisasContext *ctx)
|
2003-11-23 15:55:54 +01:00
|
|
|
{
|
2007-10-26 02:48:00 +02:00
|
|
|
/* XXX: specification says this is treated as a load by the MMU */
|
2008-12-08 19:11:21 +01:00
|
|
|
TCGv t0;
|
|
|
|
gen_set_access_type(ctx, ACCESS_CACHE);
|
|
|
|
t0 = tcg_temp_new();
|
|
|
|
gen_addr_reg_index(ctx, t0);
|
|
|
|
gen_qemu_ld8u(ctx, t0, t0);
|
2008-11-02 09:22:34 +01:00
|
|
|
tcg_temp_free(t0);
|
2003-11-23 15:55:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* dcbi (Supervisor only) */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_dcbi(DisasContext *ctx)
|
2003-11-23 15:55:54 +01:00
|
|
|
{
|
2004-04-12 22:39:29 +02:00
|
|
|
#if defined(CONFIG_USER_ONLY)
|
2008-12-11 23:42:14 +01:00
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);
|
2004-04-12 22:39:29 +02:00
|
|
|
#else
|
2008-10-15 19:00:37 +02:00
|
|
|
TCGv EA, val;
|
2014-09-15 17:03:28 +02:00
|
|
|
if (unlikely(ctx->pr)) {
|
2008-12-11 23:42:14 +01:00
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);
|
2004-05-21 14:59:32 +02:00
|
|
|
return;
|
2004-01-04 23:58:38 +01:00
|
|
|
}
|
2008-11-17 15:43:54 +01:00
|
|
|
EA = tcg_temp_new();
|
2008-12-08 19:11:21 +01:00
|
|
|
gen_set_access_type(ctx, ACCESS_CACHE);
|
|
|
|
gen_addr_reg_index(ctx, EA);
|
2008-11-17 15:43:54 +01:00
|
|
|
val = tcg_temp_new();
|
2007-03-07 09:32:30 +01:00
|
|
|
/* XXX: specification says this should be treated as a store by the MMU */
|
2008-12-08 19:11:21 +01:00
|
|
|
gen_qemu_ld8u(ctx, val, EA);
|
|
|
|
gen_qemu_st8(ctx, val, EA);
|
2008-10-15 19:00:37 +02:00
|
|
|
tcg_temp_free(val);
|
|
|
|
tcg_temp_free(EA);
|
2004-04-12 22:39:29 +02:00
|
|
|
#endif
|
2003-11-23 15:55:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* dcdst */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_dcbst(DisasContext *ctx)
|
2003-11-23 15:55:54 +01:00
|
|
|
{
|
2007-03-07 09:32:30 +01:00
|
|
|
/* XXX: specification say this is treated as a load by the MMU */
|
2008-12-08 19:11:21 +01:00
|
|
|
TCGv t0;
|
|
|
|
gen_set_access_type(ctx, ACCESS_CACHE);
|
|
|
|
t0 = tcg_temp_new();
|
|
|
|
gen_addr_reg_index(ctx, t0);
|
|
|
|
gen_qemu_ld8u(ctx, t0, t0);
|
2008-11-02 09:22:34 +01:00
|
|
|
tcg_temp_free(t0);
|
2003-11-23 15:55:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* dcbt */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_dcbt(DisasContext *ctx)
|
2003-11-23 15:55:54 +01:00
|
|
|
{
|
2007-09-30 05:46:38 +02:00
|
|
|
/* interpreted as no-op */
|
2007-03-07 09:32:30 +01:00
|
|
|
/* XXX: specification say this is treated as a load by the MMU
|
|
|
|
* but does not generate any exception
|
|
|
|
*/
|
2003-11-23 15:55:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* dcbtst */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_dcbtst(DisasContext *ctx)
|
2003-11-23 15:55:54 +01:00
|
|
|
{
|
2007-09-30 05:46:38 +02:00
|
|
|
/* interpreted as no-op */
|
2007-03-07 09:32:30 +01:00
|
|
|
/* XXX: specification say this is treated as a load by the MMU
|
|
|
|
* but does not generate any exception
|
|
|
|
*/
|
2003-11-23 15:55:54 +01:00
|
|
|
}
|
|
|
|
|
2014-01-19 17:50:09 +01:00
|
|
|
/* dcbtls */
|
|
|
|
static void gen_dcbtls(DisasContext *ctx)
|
|
|
|
{
|
|
|
|
/* Always fails locking the cache */
|
|
|
|
TCGv t0 = tcg_temp_new();
|
|
|
|
gen_load_spr(t0, SPR_Exxx_L1CSR0);
|
|
|
|
tcg_gen_ori_tl(t0, t0, L1CSR0_CUL);
|
|
|
|
gen_store_spr(SPR_Exxx_L1CSR0, t0);
|
|
|
|
tcg_temp_free(t0);
|
|
|
|
}
|
|
|
|
|
2003-11-23 15:55:54 +01:00
|
|
|
/* dcbz */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_dcbz(DisasContext *ctx)
|
2003-11-23 15:55:54 +01:00
|
|
|
{
|
2013-01-29 13:36:02 +01:00
|
|
|
TCGv tcgv_addr;
|
|
|
|
TCGv_i32 tcgv_is_dcbzl;
|
|
|
|
int is_dcbzl = ctx->opcode & 0x00200000 ? 1 : 0;
|
2007-10-04 02:51:58 +02:00
|
|
|
|
2008-12-08 19:11:21 +01:00
|
|
|
gen_set_access_type(ctx, ACCESS_CACHE);
|
2008-11-30 17:24:05 +01:00
|
|
|
/* NIP cannot be restored if the memory exception comes from an helper */
|
|
|
|
gen_update_nip(ctx, ctx->nip - 4);
|
2013-01-29 13:36:02 +01:00
|
|
|
tcgv_addr = tcg_temp_new();
|
|
|
|
tcgv_is_dcbzl = tcg_const_i32(is_dcbzl);
|
|
|
|
|
|
|
|
gen_addr_reg_index(ctx, tcgv_addr);
|
|
|
|
gen_helper_dcbz(cpu_env, tcgv_addr, tcgv_is_dcbzl);
|
|
|
|
|
|
|
|
tcg_temp_free(tcgv_addr);
|
|
|
|
tcg_temp_free_i32(tcgv_is_dcbzl);
|
2003-11-23 15:55:54 +01:00
|
|
|
}
|
|
|
|
|
2009-01-12 22:33:02 +01:00
|
|
|
/* dst / dstt */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_dst(DisasContext *ctx)
|
2009-01-12 22:33:02 +01:00
|
|
|
{
|
|
|
|
if (rA(ctx->opcode) == 0) {
|
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_INVAL_LSWX);
|
|
|
|
} else {
|
|
|
|
/* interpreted as no-op */
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* dstst /dststt */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_dstst(DisasContext *ctx)
|
2009-01-12 22:33:02 +01:00
|
|
|
{
|
|
|
|
if (rA(ctx->opcode) == 0) {
|
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_INVAL_LSWX);
|
|
|
|
} else {
|
|
|
|
/* interpreted as no-op */
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/* dss / dssall */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_dss(DisasContext *ctx)
|
2009-01-12 22:33:02 +01:00
|
|
|
{
|
|
|
|
/* interpreted as no-op */
|
|
|
|
}
|
|
|
|
|
2003-11-23 15:55:54 +01:00
|
|
|
/* icbi */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_icbi(DisasContext *ctx)
|
2003-11-23 15:55:54 +01:00
|
|
|
{
|
2008-12-08 19:11:21 +01:00
|
|
|
TCGv t0;
|
|
|
|
gen_set_access_type(ctx, ACCESS_CACHE);
|
2007-10-01 07:22:17 +02:00
|
|
|
/* NIP cannot be restored if the memory exception comes from an helper */
|
|
|
|
gen_update_nip(ctx, ctx->nip - 4);
|
2008-12-08 19:11:21 +01:00
|
|
|
t0 = tcg_temp_new();
|
|
|
|
gen_addr_reg_index(ctx, t0);
|
2012-05-30 06:23:40 +02:00
|
|
|
gen_helper_icbi(cpu_env, t0);
|
2008-11-30 17:24:13 +01:00
|
|
|
tcg_temp_free(t0);
|
2003-11-23 15:55:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Optional: */
|
|
|
|
/* dcba */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_dcba(DisasContext *ctx)
|
2003-11-23 15:55:54 +01:00
|
|
|
{
|
2007-09-30 05:46:38 +02:00
|
|
|
/* interpreted as no-op */
|
|
|
|
/* XXX: specification say this is treated as a store by the MMU
|
|
|
|
* but does not generate any exception
|
|
|
|
*/
|
2003-11-23 15:55:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*** Segment register manipulation ***/
|
|
|
|
/* Supervisor only: */
|
2009-06-17 17:22:09 +02:00
|
|
|
|
2009-06-17 17:22:19 +02:00
|
|
|
/* mfsr */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_mfsr(DisasContext *ctx)
|
2003-11-23 15:55:54 +01:00
|
|
|
{
|
2004-01-04 23:58:38 +01:00
|
|
|
#if defined(CONFIG_USER_ONLY)
|
2008-12-11 23:42:14 +01:00
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG);
|
2004-01-04 23:58:38 +01:00
|
|
|
#else
|
2008-12-06 22:46:17 +01:00
|
|
|
TCGv t0;
|
2014-09-15 17:03:28 +02:00
|
|
|
if (unlikely(ctx->pr)) {
|
2008-12-11 23:42:14 +01:00
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG);
|
2004-05-21 14:59:32 +02:00
|
|
|
return;
|
2004-01-04 23:58:38 +01:00
|
|
|
}
|
2008-12-06 22:46:17 +01:00
|
|
|
t0 = tcg_const_tl(SR(ctx->opcode));
|
2012-05-30 06:23:31 +02:00
|
|
|
gen_helper_load_sr(cpu_gpr[rD(ctx->opcode)], cpu_env, t0);
|
2008-12-06 22:46:17 +01:00
|
|
|
tcg_temp_free(t0);
|
2004-01-04 23:58:38 +01:00
|
|
|
#endif
|
2003-11-23 15:55:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* mfsrin */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_mfsrin(DisasContext *ctx)
|
2003-11-23 15:55:54 +01:00
|
|
|
{
|
2004-01-04 23:58:38 +01:00
|
|
|
#if defined(CONFIG_USER_ONLY)
|
2008-12-11 23:42:14 +01:00
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG);
|
2004-01-04 23:58:38 +01:00
|
|
|
#else
|
2008-12-06 22:46:17 +01:00
|
|
|
TCGv t0;
|
2014-09-15 17:03:28 +02:00
|
|
|
if (unlikely(ctx->pr)) {
|
2008-12-11 23:42:14 +01:00
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG);
|
2004-05-21 14:59:32 +02:00
|
|
|
return;
|
2004-01-04 23:58:38 +01:00
|
|
|
}
|
2008-12-06 22:46:17 +01:00
|
|
|
t0 = tcg_temp_new();
|
|
|
|
tcg_gen_shri_tl(t0, cpu_gpr[rB(ctx->opcode)], 28);
|
|
|
|
tcg_gen_andi_tl(t0, t0, 0xF);
|
2012-05-30 06:23:31 +02:00
|
|
|
gen_helper_load_sr(cpu_gpr[rD(ctx->opcode)], cpu_env, t0);
|
2008-12-06 22:46:17 +01:00
|
|
|
tcg_temp_free(t0);
|
2004-01-04 23:58:38 +01:00
|
|
|
#endif
|
2003-11-23 15:55:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* mtsr */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_mtsr(DisasContext *ctx)
|
2003-11-23 15:55:54 +01:00
|
|
|
{
|
2004-01-04 23:58:38 +01:00
|
|
|
#if defined(CONFIG_USER_ONLY)
|
2008-12-11 23:42:14 +01:00
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG);
|
2004-01-04 23:58:38 +01:00
|
|
|
#else
|
2008-12-06 22:46:17 +01:00
|
|
|
TCGv t0;
|
2014-09-15 17:03:28 +02:00
|
|
|
if (unlikely(ctx->pr)) {
|
2008-12-11 23:42:14 +01:00
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG);
|
2004-05-21 14:59:32 +02:00
|
|
|
return;
|
2004-01-04 23:58:38 +01:00
|
|
|
}
|
2008-12-06 22:46:17 +01:00
|
|
|
t0 = tcg_const_tl(SR(ctx->opcode));
|
2012-05-30 06:23:31 +02:00
|
|
|
gen_helper_store_sr(cpu_env, t0, cpu_gpr[rS(ctx->opcode)]);
|
2008-12-06 22:46:17 +01:00
|
|
|
tcg_temp_free(t0);
|
2004-01-04 23:58:38 +01:00
|
|
|
#endif
|
2003-11-23 15:55:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* mtsrin */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_mtsrin(DisasContext *ctx)
|
2003-11-23 15:55:54 +01:00
|
|
|
{
|
2004-01-04 23:58:38 +01:00
|
|
|
#if defined(CONFIG_USER_ONLY)
|
2008-12-11 23:42:14 +01:00
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG);
|
2004-01-04 23:58:38 +01:00
|
|
|
#else
|
2008-12-06 22:46:17 +01:00
|
|
|
TCGv t0;
|
2014-09-15 17:03:28 +02:00
|
|
|
if (unlikely(ctx->pr)) {
|
2008-12-11 23:42:14 +01:00
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG);
|
2004-05-21 14:59:32 +02:00
|
|
|
return;
|
2004-01-04 23:58:38 +01:00
|
|
|
}
|
2008-12-06 22:46:17 +01:00
|
|
|
t0 = tcg_temp_new();
|
|
|
|
tcg_gen_shri_tl(t0, cpu_gpr[rB(ctx->opcode)], 28);
|
|
|
|
tcg_gen_andi_tl(t0, t0, 0xF);
|
2012-05-30 06:23:31 +02:00
|
|
|
gen_helper_store_sr(cpu_env, t0, cpu_gpr[rD(ctx->opcode)]);
|
2008-12-06 22:46:17 +01:00
|
|
|
tcg_temp_free(t0);
|
2004-01-04 23:58:38 +01:00
|
|
|
#endif
|
2003-11-23 15:55:54 +01:00
|
|
|
}
|
|
|
|
|
2007-10-06 00:06:02 +02:00
|
|
|
#if defined(TARGET_PPC64)
|
|
|
|
/* Specific implementation for PowerPC 64 "bridge" emulation using SLB */
|
2009-06-17 17:22:14 +02:00
|
|
|
|
2009-06-17 17:22:19 +02:00
|
|
|
/* mfsr */
|
2009-06-17 17:22:14 +02:00
|
|
|
static void gen_mfsr_64b(DisasContext *ctx)
|
2007-10-06 00:06:02 +02:00
|
|
|
{
|
|
|
|
#if defined(CONFIG_USER_ONLY)
|
2008-12-11 23:42:14 +01:00
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG);
|
2007-10-06 00:06:02 +02:00
|
|
|
#else
|
2008-12-06 22:46:17 +01:00
|
|
|
TCGv t0;
|
2014-09-15 17:03:28 +02:00
|
|
|
if (unlikely(ctx->pr)) {
|
2008-12-11 23:42:14 +01:00
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG);
|
2007-10-06 00:06:02 +02:00
|
|
|
return;
|
|
|
|
}
|
2008-12-06 22:46:17 +01:00
|
|
|
t0 = tcg_const_tl(SR(ctx->opcode));
|
2012-05-30 06:23:31 +02:00
|
|
|
gen_helper_load_sr(cpu_gpr[rD(ctx->opcode)], cpu_env, t0);
|
2008-12-06 22:46:17 +01:00
|
|
|
tcg_temp_free(t0);
|
2007-10-06 00:06:02 +02:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
/* mfsrin */
|
2009-06-17 17:22:14 +02:00
|
|
|
static void gen_mfsrin_64b(DisasContext *ctx)
|
2007-10-06 00:06:02 +02:00
|
|
|
{
|
|
|
|
#if defined(CONFIG_USER_ONLY)
|
2008-12-11 23:42:14 +01:00
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG);
|
2007-10-06 00:06:02 +02:00
|
|
|
#else
|
2008-12-06 22:46:17 +01:00
|
|
|
TCGv t0;
|
2014-09-15 17:03:28 +02:00
|
|
|
if (unlikely(ctx->pr)) {
|
2008-12-11 23:42:14 +01:00
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG);
|
2007-10-06 00:06:02 +02:00
|
|
|
return;
|
|
|
|
}
|
2008-12-06 22:46:17 +01:00
|
|
|
t0 = tcg_temp_new();
|
|
|
|
tcg_gen_shri_tl(t0, cpu_gpr[rB(ctx->opcode)], 28);
|
|
|
|
tcg_gen_andi_tl(t0, t0, 0xF);
|
2012-05-30 06:23:31 +02:00
|
|
|
gen_helper_load_sr(cpu_gpr[rD(ctx->opcode)], cpu_env, t0);
|
2008-12-06 22:46:17 +01:00
|
|
|
tcg_temp_free(t0);
|
2007-10-06 00:06:02 +02:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
/* mtsr */
|
2009-06-17 17:22:14 +02:00
|
|
|
static void gen_mtsr_64b(DisasContext *ctx)
|
2007-10-06 00:06:02 +02:00
|
|
|
{
|
|
|
|
#if defined(CONFIG_USER_ONLY)
|
2008-12-11 23:42:14 +01:00
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG);
|
2007-10-06 00:06:02 +02:00
|
|
|
#else
|
2008-12-06 22:46:17 +01:00
|
|
|
TCGv t0;
|
2014-09-15 17:03:28 +02:00
|
|
|
if (unlikely(ctx->pr)) {
|
2008-12-11 23:42:14 +01:00
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG);
|
2007-10-06 00:06:02 +02:00
|
|
|
return;
|
|
|
|
}
|
2008-12-06 22:46:17 +01:00
|
|
|
t0 = tcg_const_tl(SR(ctx->opcode));
|
2012-05-30 06:23:31 +02:00
|
|
|
gen_helper_store_sr(cpu_env, t0, cpu_gpr[rS(ctx->opcode)]);
|
2008-12-06 22:46:17 +01:00
|
|
|
tcg_temp_free(t0);
|
2007-10-06 00:06:02 +02:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
/* mtsrin */
|
2009-06-17 17:22:14 +02:00
|
|
|
static void gen_mtsrin_64b(DisasContext *ctx)
|
2007-10-06 00:06:02 +02:00
|
|
|
{
|
|
|
|
#if defined(CONFIG_USER_ONLY)
|
2008-12-11 23:42:14 +01:00
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG);
|
2007-10-06 00:06:02 +02:00
|
|
|
#else
|
2008-12-06 22:46:17 +01:00
|
|
|
TCGv t0;
|
2014-09-15 17:03:28 +02:00
|
|
|
if (unlikely(ctx->pr)) {
|
2008-12-11 23:42:14 +01:00
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG);
|
2007-10-06 00:06:02 +02:00
|
|
|
return;
|
|
|
|
}
|
2008-12-06 22:46:17 +01:00
|
|
|
t0 = tcg_temp_new();
|
|
|
|
tcg_gen_shri_tl(t0, cpu_gpr[rB(ctx->opcode)], 28);
|
|
|
|
tcg_gen_andi_tl(t0, t0, 0xF);
|
2012-05-30 06:23:31 +02:00
|
|
|
gen_helper_store_sr(cpu_env, t0, cpu_gpr[rS(ctx->opcode)]);
|
2008-12-06 22:46:17 +01:00
|
|
|
tcg_temp_free(t0);
|
2007-10-06 00:06:02 +02:00
|
|
|
#endif
|
|
|
|
}
|
2009-03-07 21:50:01 +01:00
|
|
|
|
|
|
|
/* slbmte */
|
2009-06-17 17:22:14 +02:00
|
|
|
static void gen_slbmte(DisasContext *ctx)
|
2009-03-07 21:50:01 +01:00
|
|
|
{
|
|
|
|
#if defined(CONFIG_USER_ONLY)
|
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG);
|
|
|
|
#else
|
2014-09-15 17:03:28 +02:00
|
|
|
if (unlikely(ctx->pr)) {
|
2009-03-07 21:50:01 +01:00
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG);
|
|
|
|
return;
|
|
|
|
}
|
2012-05-30 06:23:31 +02:00
|
|
|
gen_helper_store_slb(cpu_env, cpu_gpr[rB(ctx->opcode)],
|
|
|
|
cpu_gpr[rS(ctx->opcode)]);
|
2009-03-07 21:50:01 +01:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2011-04-01 06:15:11 +02:00
|
|
|
static void gen_slbmfee(DisasContext *ctx)
|
|
|
|
{
|
|
|
|
#if defined(CONFIG_USER_ONLY)
|
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG);
|
|
|
|
#else
|
2014-09-15 17:03:28 +02:00
|
|
|
if (unlikely(ctx->pr)) {
|
2011-04-01 06:15:11 +02:00
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG);
|
|
|
|
return;
|
|
|
|
}
|
2012-05-30 06:23:31 +02:00
|
|
|
gen_helper_load_slb_esid(cpu_gpr[rS(ctx->opcode)], cpu_env,
|
2011-04-01 06:15:11 +02:00
|
|
|
cpu_gpr[rB(ctx->opcode)]);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
static void gen_slbmfev(DisasContext *ctx)
|
|
|
|
{
|
|
|
|
#if defined(CONFIG_USER_ONLY)
|
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG);
|
|
|
|
#else
|
2014-09-15 17:03:28 +02:00
|
|
|
if (unlikely(ctx->pr)) {
|
2011-04-01 06:15:11 +02:00
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG);
|
|
|
|
return;
|
|
|
|
}
|
2012-05-30 06:23:31 +02:00
|
|
|
gen_helper_load_slb_vsid(cpu_gpr[rS(ctx->opcode)], cpu_env,
|
2011-04-01 06:15:11 +02:00
|
|
|
cpu_gpr[rB(ctx->opcode)]);
|
|
|
|
#endif
|
|
|
|
}
|
2007-10-06 00:06:02 +02:00
|
|
|
#endif /* defined(TARGET_PPC64) */
|
|
|
|
|
2003-11-23 15:55:54 +01:00
|
|
|
/*** Lookaside buffer management ***/
|
2014-09-15 17:03:28 +02:00
|
|
|
/* Optional & supervisor only: */
|
2009-06-17 17:22:09 +02:00
|
|
|
|
2009-06-17 17:22:19 +02:00
|
|
|
/* tlbia */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_tlbia(DisasContext *ctx)
|
2003-11-23 15:55:54 +01:00
|
|
|
{
|
2004-01-04 23:58:38 +01:00
|
|
|
#if defined(CONFIG_USER_ONLY)
|
2008-12-11 23:42:14 +01:00
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);
|
2004-01-04 23:58:38 +01:00
|
|
|
#else
|
2014-09-15 17:03:28 +02:00
|
|
|
if (unlikely(ctx->pr)) {
|
2008-12-11 23:42:14 +01:00
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);
|
2004-05-21 14:59:32 +02:00
|
|
|
return;
|
2004-01-04 23:58:38 +01:00
|
|
|
}
|
2012-05-30 06:23:31 +02:00
|
|
|
gen_helper_tlbia(cpu_env);
|
2004-01-04 23:58:38 +01:00
|
|
|
#endif
|
2003-11-23 15:55:54 +01:00
|
|
|
}
|
|
|
|
|
2009-03-07 21:52:22 +01:00
|
|
|
/* tlbiel */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_tlbiel(DisasContext *ctx)
|
2009-03-07 21:52:22 +01:00
|
|
|
{
|
|
|
|
#if defined(CONFIG_USER_ONLY)
|
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);
|
|
|
|
#else
|
2014-09-15 17:03:28 +02:00
|
|
|
if (unlikely(ctx->pr)) {
|
2009-03-07 21:52:22 +01:00
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);
|
|
|
|
return;
|
|
|
|
}
|
2012-05-30 06:23:31 +02:00
|
|
|
gen_helper_tlbie(cpu_env, cpu_gpr[rB(ctx->opcode)]);
|
2009-03-07 21:52:22 +01:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2003-11-23 15:55:54 +01:00
|
|
|
/* tlbie */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_tlbie(DisasContext *ctx)
|
2003-11-23 15:55:54 +01:00
|
|
|
{
|
2004-01-04 23:58:38 +01:00
|
|
|
#if defined(CONFIG_USER_ONLY)
|
2008-12-11 23:42:14 +01:00
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);
|
2004-01-04 23:58:38 +01:00
|
|
|
#else
|
2014-09-15 17:03:28 +02:00
|
|
|
if (unlikely(ctx->pr)) {
|
2008-12-11 23:42:14 +01:00
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);
|
2004-05-21 14:59:32 +02:00
|
|
|
return;
|
2004-01-04 23:58:38 +01:00
|
|
|
}
|
2013-03-21 11:01:49 +01:00
|
|
|
if (NARROW_MODE(ctx)) {
|
2008-12-06 22:46:17 +01:00
|
|
|
TCGv t0 = tcg_temp_new();
|
|
|
|
tcg_gen_ext32u_tl(t0, cpu_gpr[rB(ctx->opcode)]);
|
2012-05-30 06:23:31 +02:00
|
|
|
gen_helper_tlbie(cpu_env, t0);
|
2008-12-06 22:46:17 +01:00
|
|
|
tcg_temp_free(t0);
|
2013-03-21 11:01:49 +01:00
|
|
|
} else {
|
2012-05-30 06:23:31 +02:00
|
|
|
gen_helper_tlbie(cpu_env, cpu_gpr[rB(ctx->opcode)]);
|
2013-03-21 11:01:49 +01:00
|
|
|
}
|
2004-01-04 23:58:38 +01:00
|
|
|
#endif
|
2003-11-23 15:55:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* tlbsync */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_tlbsync(DisasContext *ctx)
|
2003-11-23 15:55:54 +01:00
|
|
|
{
|
2004-01-04 23:58:38 +01:00
|
|
|
#if defined(CONFIG_USER_ONLY)
|
2008-12-11 23:42:14 +01:00
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);
|
2004-01-04 23:58:38 +01:00
|
|
|
#else
|
2014-09-15 17:03:28 +02:00
|
|
|
if (unlikely(ctx->pr)) {
|
2008-12-11 23:42:14 +01:00
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);
|
2004-05-21 14:59:32 +02:00
|
|
|
return;
|
2004-01-04 23:58:38 +01:00
|
|
|
}
|
|
|
|
/* This has no effect: it should ensure that all previous
|
|
|
|
* tlbie have completed
|
|
|
|
*/
|
2008-12-11 23:42:14 +01:00
|
|
|
gen_stop_exception(ctx);
|
2004-01-04 23:58:38 +01:00
|
|
|
#endif
|
2003-11-23 15:55:54 +01:00
|
|
|
}
|
|
|
|
|
2007-03-23 10:45:27 +01:00
|
|
|
#if defined(TARGET_PPC64)
|
|
|
|
/* slbia */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_slbia(DisasContext *ctx)
|
2007-03-23 10:45:27 +01:00
|
|
|
{
|
|
|
|
#if defined(CONFIG_USER_ONLY)
|
2008-12-11 23:42:14 +01:00
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);
|
2007-03-23 10:45:27 +01:00
|
|
|
#else
|
2014-09-15 17:03:28 +02:00
|
|
|
if (unlikely(ctx->pr)) {
|
2008-12-11 23:42:14 +01:00
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);
|
2007-03-23 10:45:27 +01:00
|
|
|
return;
|
|
|
|
}
|
2012-05-30 06:23:31 +02:00
|
|
|
gen_helper_slbia(cpu_env);
|
2007-03-23 10:45:27 +01:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
/* slbie */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_slbie(DisasContext *ctx)
|
2007-03-23 10:45:27 +01:00
|
|
|
{
|
|
|
|
#if defined(CONFIG_USER_ONLY)
|
2008-12-11 23:42:14 +01:00
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);
|
2007-03-23 10:45:27 +01:00
|
|
|
#else
|
2014-09-15 17:03:28 +02:00
|
|
|
if (unlikely(ctx->pr)) {
|
2008-12-11 23:42:14 +01:00
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);
|
2007-03-23 10:45:27 +01:00
|
|
|
return;
|
|
|
|
}
|
2012-05-30 06:23:31 +02:00
|
|
|
gen_helper_slbie(cpu_env, cpu_gpr[rB(ctx->opcode)]);
|
2007-03-23 10:45:27 +01:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2003-11-23 15:55:54 +01:00
|
|
|
/*** External control ***/
|
|
|
|
/* Optional: */
|
2009-06-17 17:22:09 +02:00
|
|
|
|
2009-06-17 17:22:19 +02:00
|
|
|
/* eciwx */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_eciwx(DisasContext *ctx)
|
2003-11-23 15:55:54 +01:00
|
|
|
{
|
2008-12-08 19:11:21 +01:00
|
|
|
TCGv t0;
|
2008-11-30 17:24:47 +01:00
|
|
|
/* Should check EAR[E] ! */
|
2008-12-08 19:11:21 +01:00
|
|
|
gen_set_access_type(ctx, ACCESS_EXT);
|
|
|
|
t0 = tcg_temp_new();
|
|
|
|
gen_addr_reg_index(ctx, t0);
|
2008-11-30 17:24:47 +01:00
|
|
|
gen_check_align(ctx, t0, 0x03);
|
2008-12-08 19:11:21 +01:00
|
|
|
gen_qemu_ld32u(ctx, cpu_gpr[rD(ctx->opcode)], t0);
|
2008-11-30 17:24:47 +01:00
|
|
|
tcg_temp_free(t0);
|
2007-03-07 09:32:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ecowx */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_ecowx(DisasContext *ctx)
|
2007-03-07 09:32:30 +01:00
|
|
|
{
|
2008-12-08 19:11:21 +01:00
|
|
|
TCGv t0;
|
2008-11-30 17:24:47 +01:00
|
|
|
/* Should check EAR[E] ! */
|
2008-12-08 19:11:21 +01:00
|
|
|
gen_set_access_type(ctx, ACCESS_EXT);
|
|
|
|
t0 = tcg_temp_new();
|
|
|
|
gen_addr_reg_index(ctx, t0);
|
2008-11-30 17:24:47 +01:00
|
|
|
gen_check_align(ctx, t0, 0x03);
|
2008-12-08 19:11:21 +01:00
|
|
|
gen_qemu_st32(ctx, cpu_gpr[rD(ctx->opcode)], t0);
|
2008-11-30 17:24:47 +01:00
|
|
|
tcg_temp_free(t0);
|
2007-03-07 09:32:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* PowerPC 601 specific instructions */
|
2009-06-17 17:22:09 +02:00
|
|
|
|
2009-06-17 17:22:19 +02:00
|
|
|
/* abs - abs. */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_abs(DisasContext *ctx)
|
2007-03-07 09:32:30 +01:00
|
|
|
{
|
2015-02-13 21:51:55 +01:00
|
|
|
TCGLabel *l1 = gen_new_label();
|
|
|
|
TCGLabel *l2 = gen_new_label();
|
2008-12-06 13:19:14 +01:00
|
|
|
tcg_gen_brcondi_tl(TCG_COND_GE, cpu_gpr[rA(ctx->opcode)], 0, l1);
|
|
|
|
tcg_gen_neg_tl(cpu_gpr[rD(ctx->opcode)], cpu_gpr[rA(ctx->opcode)]);
|
|
|
|
tcg_gen_br(l2);
|
|
|
|
gen_set_label(l1);
|
|
|
|
tcg_gen_mov_tl(cpu_gpr[rD(ctx->opcode)], cpu_gpr[rA(ctx->opcode)]);
|
|
|
|
gen_set_label(l2);
|
2007-03-07 09:32:30 +01:00
|
|
|
if (unlikely(Rc(ctx->opcode) != 0))
|
2008-12-06 13:19:14 +01:00
|
|
|
gen_set_Rc0(ctx, cpu_gpr[rD(ctx->opcode)]);
|
2007-03-07 09:32:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* abso - abso. */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_abso(DisasContext *ctx)
|
2007-03-07 09:32:30 +01:00
|
|
|
{
|
2015-02-13 21:51:55 +01:00
|
|
|
TCGLabel *l1 = gen_new_label();
|
|
|
|
TCGLabel *l2 = gen_new_label();
|
|
|
|
TCGLabel *l3 = gen_new_label();
|
2008-12-06 13:19:14 +01:00
|
|
|
/* Start with XER OV disabled, the most likely case */
|
2013-02-20 08:52:13 +01:00
|
|
|
tcg_gen_movi_tl(cpu_ov, 0);
|
2008-12-06 13:19:14 +01:00
|
|
|
tcg_gen_brcondi_tl(TCG_COND_GE, cpu_gpr[rA(ctx->opcode)], 0, l2);
|
|
|
|
tcg_gen_brcondi_tl(TCG_COND_NE, cpu_gpr[rA(ctx->opcode)], 0x80000000, l1);
|
2013-02-20 08:52:13 +01:00
|
|
|
tcg_gen_movi_tl(cpu_ov, 1);
|
|
|
|
tcg_gen_movi_tl(cpu_so, 1);
|
2008-12-06 13:19:14 +01:00
|
|
|
tcg_gen_br(l2);
|
|
|
|
gen_set_label(l1);
|
|
|
|
tcg_gen_neg_tl(cpu_gpr[rD(ctx->opcode)], cpu_gpr[rA(ctx->opcode)]);
|
|
|
|
tcg_gen_br(l3);
|
|
|
|
gen_set_label(l2);
|
|
|
|
tcg_gen_mov_tl(cpu_gpr[rD(ctx->opcode)], cpu_gpr[rA(ctx->opcode)]);
|
|
|
|
gen_set_label(l3);
|
2007-03-07 09:32:30 +01:00
|
|
|
if (unlikely(Rc(ctx->opcode) != 0))
|
2008-12-06 13:19:14 +01:00
|
|
|
gen_set_Rc0(ctx, cpu_gpr[rD(ctx->opcode)]);
|
2007-03-07 09:32:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* clcs */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_clcs(DisasContext *ctx)
|
2007-03-07 09:32:30 +01:00
|
|
|
{
|
2008-12-06 13:19:14 +01:00
|
|
|
TCGv_i32 t0 = tcg_const_i32(rA(ctx->opcode));
|
2012-05-30 06:23:38 +02:00
|
|
|
gen_helper_clcs(cpu_gpr[rD(ctx->opcode)], cpu_env, t0);
|
2008-12-06 13:19:14 +01:00
|
|
|
tcg_temp_free_i32(t0);
|
2007-10-26 02:46:07 +02:00
|
|
|
/* Rc=1 sets CR0 to an undefined state */
|
2007-03-07 09:32:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* div - div. */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_div(DisasContext *ctx)
|
2007-03-07 09:32:30 +01:00
|
|
|
{
|
2012-05-30 06:23:29 +02:00
|
|
|
gen_helper_div(cpu_gpr[rD(ctx->opcode)], cpu_env, cpu_gpr[rA(ctx->opcode)],
|
|
|
|
cpu_gpr[rB(ctx->opcode)]);
|
2007-03-07 09:32:30 +01:00
|
|
|
if (unlikely(Rc(ctx->opcode) != 0))
|
2008-12-06 13:19:14 +01:00
|
|
|
gen_set_Rc0(ctx, cpu_gpr[rD(ctx->opcode)]);
|
2007-03-07 09:32:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* divo - divo. */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_divo(DisasContext *ctx)
|
2007-03-07 09:32:30 +01:00
|
|
|
{
|
2012-05-30 06:23:29 +02:00
|
|
|
gen_helper_divo(cpu_gpr[rD(ctx->opcode)], cpu_env, cpu_gpr[rA(ctx->opcode)],
|
|
|
|
cpu_gpr[rB(ctx->opcode)]);
|
2007-03-07 09:32:30 +01:00
|
|
|
if (unlikely(Rc(ctx->opcode) != 0))
|
2008-12-06 13:19:14 +01:00
|
|
|
gen_set_Rc0(ctx, cpu_gpr[rD(ctx->opcode)]);
|
2007-03-07 09:32:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* divs - divs. */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_divs(DisasContext *ctx)
|
2007-03-07 09:32:30 +01:00
|
|
|
{
|
2012-05-30 06:23:29 +02:00
|
|
|
gen_helper_divs(cpu_gpr[rD(ctx->opcode)], cpu_env, cpu_gpr[rA(ctx->opcode)],
|
|
|
|
cpu_gpr[rB(ctx->opcode)]);
|
2007-03-07 09:32:30 +01:00
|
|
|
if (unlikely(Rc(ctx->opcode) != 0))
|
2008-12-06 13:19:14 +01:00
|
|
|
gen_set_Rc0(ctx, cpu_gpr[rD(ctx->opcode)]);
|
2007-03-07 09:32:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* divso - divso. */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_divso(DisasContext *ctx)
|
2007-03-07 09:32:30 +01:00
|
|
|
{
|
2012-05-30 06:23:29 +02:00
|
|
|
gen_helper_divso(cpu_gpr[rD(ctx->opcode)], cpu_env,
|
|
|
|
cpu_gpr[rA(ctx->opcode)], cpu_gpr[rB(ctx->opcode)]);
|
2007-03-07 09:32:30 +01:00
|
|
|
if (unlikely(Rc(ctx->opcode) != 0))
|
2008-12-06 13:19:14 +01:00
|
|
|
gen_set_Rc0(ctx, cpu_gpr[rD(ctx->opcode)]);
|
2007-03-07 09:32:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* doz - doz. */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_doz(DisasContext *ctx)
|
2007-03-07 09:32:30 +01:00
|
|
|
{
|
2015-02-13 21:51:55 +01:00
|
|
|
TCGLabel *l1 = gen_new_label();
|
|
|
|
TCGLabel *l2 = gen_new_label();
|
2008-12-06 13:19:14 +01:00
|
|
|
tcg_gen_brcond_tl(TCG_COND_GE, cpu_gpr[rB(ctx->opcode)], cpu_gpr[rA(ctx->opcode)], l1);
|
|
|
|
tcg_gen_sub_tl(cpu_gpr[rD(ctx->opcode)], cpu_gpr[rB(ctx->opcode)], cpu_gpr[rA(ctx->opcode)]);
|
|
|
|
tcg_gen_br(l2);
|
|
|
|
gen_set_label(l1);
|
|
|
|
tcg_gen_movi_tl(cpu_gpr[rD(ctx->opcode)], 0);
|
|
|
|
gen_set_label(l2);
|
2007-03-07 09:32:30 +01:00
|
|
|
if (unlikely(Rc(ctx->opcode) != 0))
|
2008-12-06 13:19:14 +01:00
|
|
|
gen_set_Rc0(ctx, cpu_gpr[rD(ctx->opcode)]);
|
2007-03-07 09:32:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* dozo - dozo. */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_dozo(DisasContext *ctx)
|
2007-03-07 09:32:30 +01:00
|
|
|
{
|
2015-02-13 21:51:55 +01:00
|
|
|
TCGLabel *l1 = gen_new_label();
|
|
|
|
TCGLabel *l2 = gen_new_label();
|
2008-12-06 13:19:14 +01:00
|
|
|
TCGv t0 = tcg_temp_new();
|
|
|
|
TCGv t1 = tcg_temp_new();
|
|
|
|
TCGv t2 = tcg_temp_new();
|
|
|
|
/* Start with XER OV disabled, the most likely case */
|
2013-02-20 08:52:13 +01:00
|
|
|
tcg_gen_movi_tl(cpu_ov, 0);
|
2008-12-06 13:19:14 +01:00
|
|
|
tcg_gen_brcond_tl(TCG_COND_GE, cpu_gpr[rB(ctx->opcode)], cpu_gpr[rA(ctx->opcode)], l1);
|
|
|
|
tcg_gen_sub_tl(t0, cpu_gpr[rB(ctx->opcode)], cpu_gpr[rA(ctx->opcode)]);
|
|
|
|
tcg_gen_xor_tl(t1, cpu_gpr[rB(ctx->opcode)], cpu_gpr[rA(ctx->opcode)]);
|
|
|
|
tcg_gen_xor_tl(t2, cpu_gpr[rA(ctx->opcode)], t0);
|
|
|
|
tcg_gen_andc_tl(t1, t1, t2);
|
|
|
|
tcg_gen_mov_tl(cpu_gpr[rD(ctx->opcode)], t0);
|
|
|
|
tcg_gen_brcondi_tl(TCG_COND_GE, t1, 0, l2);
|
2013-02-20 08:52:13 +01:00
|
|
|
tcg_gen_movi_tl(cpu_ov, 1);
|
|
|
|
tcg_gen_movi_tl(cpu_so, 1);
|
2008-12-06 13:19:14 +01:00
|
|
|
tcg_gen_br(l2);
|
|
|
|
gen_set_label(l1);
|
|
|
|
tcg_gen_movi_tl(cpu_gpr[rD(ctx->opcode)], 0);
|
|
|
|
gen_set_label(l2);
|
|
|
|
tcg_temp_free(t0);
|
|
|
|
tcg_temp_free(t1);
|
|
|
|
tcg_temp_free(t2);
|
2007-03-07 09:32:30 +01:00
|
|
|
if (unlikely(Rc(ctx->opcode) != 0))
|
2008-12-06 13:19:14 +01:00
|
|
|
gen_set_Rc0(ctx, cpu_gpr[rD(ctx->opcode)]);
|
2007-03-07 09:32:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* dozi */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_dozi(DisasContext *ctx)
|
2007-03-07 09:32:30 +01:00
|
|
|
{
|
2008-12-06 13:19:14 +01:00
|
|
|
target_long simm = SIMM(ctx->opcode);
|
2015-02-13 21:51:55 +01:00
|
|
|
TCGLabel *l1 = gen_new_label();
|
|
|
|
TCGLabel *l2 = gen_new_label();
|
2008-12-06 13:19:14 +01:00
|
|
|
tcg_gen_brcondi_tl(TCG_COND_LT, cpu_gpr[rA(ctx->opcode)], simm, l1);
|
|
|
|
tcg_gen_subfi_tl(cpu_gpr[rD(ctx->opcode)], simm, cpu_gpr[rA(ctx->opcode)]);
|
|
|
|
tcg_gen_br(l2);
|
|
|
|
gen_set_label(l1);
|
|
|
|
tcg_gen_movi_tl(cpu_gpr[rD(ctx->opcode)], 0);
|
|
|
|
gen_set_label(l2);
|
|
|
|
if (unlikely(Rc(ctx->opcode) != 0))
|
|
|
|
gen_set_Rc0(ctx, cpu_gpr[rD(ctx->opcode)]);
|
2007-03-07 09:32:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* lscbx - lscbx. */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_lscbx(DisasContext *ctx)
|
2007-03-07 09:32:30 +01:00
|
|
|
{
|
2008-11-30 17:24:30 +01:00
|
|
|
TCGv t0 = tcg_temp_new();
|
|
|
|
TCGv_i32 t1 = tcg_const_i32(rD(ctx->opcode));
|
|
|
|
TCGv_i32 t2 = tcg_const_i32(rA(ctx->opcode));
|
|
|
|
TCGv_i32 t3 = tcg_const_i32(rB(ctx->opcode));
|
2007-03-07 09:32:30 +01:00
|
|
|
|
2008-12-08 19:11:21 +01:00
|
|
|
gen_addr_reg_index(ctx, t0);
|
2007-03-07 09:32:30 +01:00
|
|
|
/* NIP cannot be restored if the memory exception comes from an helper */
|
2007-03-17 15:02:15 +01:00
|
|
|
gen_update_nip(ctx, ctx->nip - 4);
|
2012-05-30 06:23:40 +02:00
|
|
|
gen_helper_lscbx(t0, cpu_env, t0, t1, t2, t3);
|
2008-11-30 17:24:30 +01:00
|
|
|
tcg_temp_free_i32(t1);
|
|
|
|
tcg_temp_free_i32(t2);
|
|
|
|
tcg_temp_free_i32(t3);
|
2008-10-21 13:28:46 +02:00
|
|
|
tcg_gen_andi_tl(cpu_xer, cpu_xer, ~0x7F);
|
2008-11-30 17:24:30 +01:00
|
|
|
tcg_gen_or_tl(cpu_xer, cpu_xer, t0);
|
2007-03-07 09:32:30 +01:00
|
|
|
if (unlikely(Rc(ctx->opcode) != 0))
|
2008-11-30 17:24:30 +01:00
|
|
|
gen_set_Rc0(ctx, t0);
|
|
|
|
tcg_temp_free(t0);
|
2007-03-07 09:32:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* maskg - maskg. */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_maskg(DisasContext *ctx)
|
2007-03-07 09:32:30 +01:00
|
|
|
{
|
2015-02-13 21:51:55 +01:00
|
|
|
TCGLabel *l1 = gen_new_label();
|
2008-12-06 13:19:14 +01:00
|
|
|
TCGv t0 = tcg_temp_new();
|
|
|
|
TCGv t1 = tcg_temp_new();
|
|
|
|
TCGv t2 = tcg_temp_new();
|
|
|
|
TCGv t3 = tcg_temp_new();
|
|
|
|
tcg_gen_movi_tl(t3, 0xFFFFFFFF);
|
|
|
|
tcg_gen_andi_tl(t0, cpu_gpr[rB(ctx->opcode)], 0x1F);
|
|
|
|
tcg_gen_andi_tl(t1, cpu_gpr[rS(ctx->opcode)], 0x1F);
|
|
|
|
tcg_gen_addi_tl(t2, t0, 1);
|
|
|
|
tcg_gen_shr_tl(t2, t3, t2);
|
|
|
|
tcg_gen_shr_tl(t3, t3, t1);
|
|
|
|
tcg_gen_xor_tl(cpu_gpr[rA(ctx->opcode)], t2, t3);
|
|
|
|
tcg_gen_brcond_tl(TCG_COND_GE, t0, t1, l1);
|
|
|
|
tcg_gen_neg_tl(cpu_gpr[rA(ctx->opcode)], cpu_gpr[rA(ctx->opcode)]);
|
|
|
|
gen_set_label(l1);
|
|
|
|
tcg_temp_free(t0);
|
|
|
|
tcg_temp_free(t1);
|
|
|
|
tcg_temp_free(t2);
|
|
|
|
tcg_temp_free(t3);
|
2007-03-07 09:32:30 +01:00
|
|
|
if (unlikely(Rc(ctx->opcode) != 0))
|
2008-12-06 13:19:14 +01:00
|
|
|
gen_set_Rc0(ctx, cpu_gpr[rA(ctx->opcode)]);
|
2007-03-07 09:32:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* maskir - maskir. */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_maskir(DisasContext *ctx)
|
2007-03-07 09:32:30 +01:00
|
|
|
{
|
2008-12-06 13:19:14 +01:00
|
|
|
TCGv t0 = tcg_temp_new();
|
|
|
|
TCGv t1 = tcg_temp_new();
|
|
|
|
tcg_gen_and_tl(t0, cpu_gpr[rS(ctx->opcode)], cpu_gpr[rB(ctx->opcode)]);
|
|
|
|
tcg_gen_andc_tl(t1, cpu_gpr[rA(ctx->opcode)], cpu_gpr[rB(ctx->opcode)]);
|
|
|
|
tcg_gen_or_tl(cpu_gpr[rA(ctx->opcode)], t0, t1);
|
|
|
|
tcg_temp_free(t0);
|
|
|
|
tcg_temp_free(t1);
|
2007-03-07 09:32:30 +01:00
|
|
|
if (unlikely(Rc(ctx->opcode) != 0))
|
2008-12-06 13:19:14 +01:00
|
|
|
gen_set_Rc0(ctx, cpu_gpr[rA(ctx->opcode)]);
|
2007-03-07 09:32:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* mul - mul. */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_mul(DisasContext *ctx)
|
2007-03-07 09:32:30 +01:00
|
|
|
{
|
2008-12-06 13:19:14 +01:00
|
|
|
TCGv_i64 t0 = tcg_temp_new_i64();
|
|
|
|
TCGv_i64 t1 = tcg_temp_new_i64();
|
|
|
|
TCGv t2 = tcg_temp_new();
|
|
|
|
tcg_gen_extu_tl_i64(t0, cpu_gpr[rA(ctx->opcode)]);
|
|
|
|
tcg_gen_extu_tl_i64(t1, cpu_gpr[rB(ctx->opcode)]);
|
|
|
|
tcg_gen_mul_i64(t0, t0, t1);
|
|
|
|
tcg_gen_trunc_i64_tl(t2, t0);
|
|
|
|
gen_store_spr(SPR_MQ, t2);
|
|
|
|
tcg_gen_shri_i64(t1, t0, 32);
|
|
|
|
tcg_gen_trunc_i64_tl(cpu_gpr[rD(ctx->opcode)], t1);
|
|
|
|
tcg_temp_free_i64(t0);
|
|
|
|
tcg_temp_free_i64(t1);
|
|
|
|
tcg_temp_free(t2);
|
2007-03-07 09:32:30 +01:00
|
|
|
if (unlikely(Rc(ctx->opcode) != 0))
|
2008-12-06 13:19:14 +01:00
|
|
|
gen_set_Rc0(ctx, cpu_gpr[rD(ctx->opcode)]);
|
2007-03-07 09:32:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* mulo - mulo. */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_mulo(DisasContext *ctx)
|
2007-03-07 09:32:30 +01:00
|
|
|
{
|
2015-02-13 21:51:55 +01:00
|
|
|
TCGLabel *l1 = gen_new_label();
|
2008-12-06 13:19:14 +01:00
|
|
|
TCGv_i64 t0 = tcg_temp_new_i64();
|
|
|
|
TCGv_i64 t1 = tcg_temp_new_i64();
|
|
|
|
TCGv t2 = tcg_temp_new();
|
|
|
|
/* Start with XER OV disabled, the most likely case */
|
2013-02-20 08:52:13 +01:00
|
|
|
tcg_gen_movi_tl(cpu_ov, 0);
|
2008-12-06 13:19:14 +01:00
|
|
|
tcg_gen_extu_tl_i64(t0, cpu_gpr[rA(ctx->opcode)]);
|
|
|
|
tcg_gen_extu_tl_i64(t1, cpu_gpr[rB(ctx->opcode)]);
|
|
|
|
tcg_gen_mul_i64(t0, t0, t1);
|
|
|
|
tcg_gen_trunc_i64_tl(t2, t0);
|
|
|
|
gen_store_spr(SPR_MQ, t2);
|
|
|
|
tcg_gen_shri_i64(t1, t0, 32);
|
|
|
|
tcg_gen_trunc_i64_tl(cpu_gpr[rD(ctx->opcode)], t1);
|
|
|
|
tcg_gen_ext32s_i64(t1, t0);
|
|
|
|
tcg_gen_brcond_i64(TCG_COND_EQ, t0, t1, l1);
|
2013-02-20 08:52:13 +01:00
|
|
|
tcg_gen_movi_tl(cpu_ov, 1);
|
|
|
|
tcg_gen_movi_tl(cpu_so, 1);
|
2008-12-06 13:19:14 +01:00
|
|
|
gen_set_label(l1);
|
|
|
|
tcg_temp_free_i64(t0);
|
|
|
|
tcg_temp_free_i64(t1);
|
|
|
|
tcg_temp_free(t2);
|
2007-03-07 09:32:30 +01:00
|
|
|
if (unlikely(Rc(ctx->opcode) != 0))
|
2008-12-06 13:19:14 +01:00
|
|
|
gen_set_Rc0(ctx, cpu_gpr[rD(ctx->opcode)]);
|
2007-03-07 09:32:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* nabs - nabs. */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_nabs(DisasContext *ctx)
|
2007-03-07 09:32:30 +01:00
|
|
|
{
|
2015-02-13 21:51:55 +01:00
|
|
|
TCGLabel *l1 = gen_new_label();
|
|
|
|
TCGLabel *l2 = gen_new_label();
|
2008-12-06 13:19:14 +01:00
|
|
|
tcg_gen_brcondi_tl(TCG_COND_GT, cpu_gpr[rA(ctx->opcode)], 0, l1);
|
|
|
|
tcg_gen_mov_tl(cpu_gpr[rD(ctx->opcode)], cpu_gpr[rA(ctx->opcode)]);
|
|
|
|
tcg_gen_br(l2);
|
|
|
|
gen_set_label(l1);
|
|
|
|
tcg_gen_neg_tl(cpu_gpr[rD(ctx->opcode)], cpu_gpr[rA(ctx->opcode)]);
|
|
|
|
gen_set_label(l2);
|
2007-03-07 09:32:30 +01:00
|
|
|
if (unlikely(Rc(ctx->opcode) != 0))
|
2008-12-06 13:19:14 +01:00
|
|
|
gen_set_Rc0(ctx, cpu_gpr[rD(ctx->opcode)]);
|
2007-03-07 09:32:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* nabso - nabso. */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_nabso(DisasContext *ctx)
|
2007-03-07 09:32:30 +01:00
|
|
|
{
|
2015-02-13 21:51:55 +01:00
|
|
|
TCGLabel *l1 = gen_new_label();
|
|
|
|
TCGLabel *l2 = gen_new_label();
|
2008-12-06 13:19:14 +01:00
|
|
|
tcg_gen_brcondi_tl(TCG_COND_GT, cpu_gpr[rA(ctx->opcode)], 0, l1);
|
|
|
|
tcg_gen_mov_tl(cpu_gpr[rD(ctx->opcode)], cpu_gpr[rA(ctx->opcode)]);
|
|
|
|
tcg_gen_br(l2);
|
|
|
|
gen_set_label(l1);
|
|
|
|
tcg_gen_neg_tl(cpu_gpr[rD(ctx->opcode)], cpu_gpr[rA(ctx->opcode)]);
|
|
|
|
gen_set_label(l2);
|
|
|
|
/* nabs never overflows */
|
2013-02-20 08:52:13 +01:00
|
|
|
tcg_gen_movi_tl(cpu_ov, 0);
|
2007-03-07 09:32:30 +01:00
|
|
|
if (unlikely(Rc(ctx->opcode) != 0))
|
2008-12-06 13:19:14 +01:00
|
|
|
gen_set_Rc0(ctx, cpu_gpr[rD(ctx->opcode)]);
|
2007-03-07 09:32:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* rlmi - rlmi. */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_rlmi(DisasContext *ctx)
|
2007-03-07 09:32:30 +01:00
|
|
|
{
|
2008-12-05 08:21:44 +01:00
|
|
|
uint32_t mb = MB(ctx->opcode);
|
|
|
|
uint32_t me = ME(ctx->opcode);
|
|
|
|
TCGv t0 = tcg_temp_new();
|
|
|
|
tcg_gen_andi_tl(t0, cpu_gpr[rB(ctx->opcode)], 0x1F);
|
|
|
|
tcg_gen_rotl_tl(t0, cpu_gpr[rS(ctx->opcode)], t0);
|
|
|
|
tcg_gen_andi_tl(t0, t0, MASK(mb, me));
|
|
|
|
tcg_gen_andi_tl(cpu_gpr[rA(ctx->opcode)], cpu_gpr[rA(ctx->opcode)], ~MASK(mb, me));
|
|
|
|
tcg_gen_or_tl(cpu_gpr[rA(ctx->opcode)], cpu_gpr[rA(ctx->opcode)], t0);
|
|
|
|
tcg_temp_free(t0);
|
2007-03-07 09:32:30 +01:00
|
|
|
if (unlikely(Rc(ctx->opcode) != 0))
|
2008-12-05 08:21:44 +01:00
|
|
|
gen_set_Rc0(ctx, cpu_gpr[rA(ctx->opcode)]);
|
2007-03-07 09:32:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* rrib - rrib. */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_rrib(DisasContext *ctx)
|
2007-03-07 09:32:30 +01:00
|
|
|
{
|
2008-12-05 08:21:44 +01:00
|
|
|
TCGv t0 = tcg_temp_new();
|
|
|
|
TCGv t1 = tcg_temp_new();
|
|
|
|
tcg_gen_andi_tl(t0, cpu_gpr[rB(ctx->opcode)], 0x1F);
|
|
|
|
tcg_gen_movi_tl(t1, 0x80000000);
|
|
|
|
tcg_gen_shr_tl(t1, t1, t0);
|
|
|
|
tcg_gen_shr_tl(t0, cpu_gpr[rS(ctx->opcode)], t0);
|
|
|
|
tcg_gen_and_tl(t0, t0, t1);
|
|
|
|
tcg_gen_andc_tl(t1, cpu_gpr[rA(ctx->opcode)], t1);
|
|
|
|
tcg_gen_or_tl(cpu_gpr[rA(ctx->opcode)], t0, t1);
|
|
|
|
tcg_temp_free(t0);
|
|
|
|
tcg_temp_free(t1);
|
2007-03-07 09:32:30 +01:00
|
|
|
if (unlikely(Rc(ctx->opcode) != 0))
|
2008-12-05 08:21:44 +01:00
|
|
|
gen_set_Rc0(ctx, cpu_gpr[rA(ctx->opcode)]);
|
2007-03-07 09:32:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* sle - sle. */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_sle(DisasContext *ctx)
|
2007-03-07 09:32:30 +01:00
|
|
|
{
|
2008-12-05 08:21:44 +01:00
|
|
|
TCGv t0 = tcg_temp_new();
|
|
|
|
TCGv t1 = tcg_temp_new();
|
|
|
|
tcg_gen_andi_tl(t1, cpu_gpr[rB(ctx->opcode)], 0x1F);
|
|
|
|
tcg_gen_shl_tl(t0, cpu_gpr[rS(ctx->opcode)], t1);
|
|
|
|
tcg_gen_subfi_tl(t1, 32, t1);
|
|
|
|
tcg_gen_shr_tl(t1, cpu_gpr[rS(ctx->opcode)], t1);
|
|
|
|
tcg_gen_or_tl(t1, t0, t1);
|
|
|
|
tcg_gen_mov_tl(cpu_gpr[rA(ctx->opcode)], t0);
|
|
|
|
gen_store_spr(SPR_MQ, t1);
|
|
|
|
tcg_temp_free(t0);
|
|
|
|
tcg_temp_free(t1);
|
2007-03-07 09:32:30 +01:00
|
|
|
if (unlikely(Rc(ctx->opcode) != 0))
|
2008-12-05 08:21:44 +01:00
|
|
|
gen_set_Rc0(ctx, cpu_gpr[rA(ctx->opcode)]);
|
2007-03-07 09:32:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* sleq - sleq. */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_sleq(DisasContext *ctx)
|
2007-03-07 09:32:30 +01:00
|
|
|
{
|
2008-12-05 08:21:44 +01:00
|
|
|
TCGv t0 = tcg_temp_new();
|
|
|
|
TCGv t1 = tcg_temp_new();
|
|
|
|
TCGv t2 = tcg_temp_new();
|
|
|
|
tcg_gen_andi_tl(t0, cpu_gpr[rB(ctx->opcode)], 0x1F);
|
|
|
|
tcg_gen_movi_tl(t2, 0xFFFFFFFF);
|
|
|
|
tcg_gen_shl_tl(t2, t2, t0);
|
|
|
|
tcg_gen_rotl_tl(t0, cpu_gpr[rS(ctx->opcode)], t0);
|
|
|
|
gen_load_spr(t1, SPR_MQ);
|
|
|
|
gen_store_spr(SPR_MQ, t0);
|
|
|
|
tcg_gen_and_tl(t0, t0, t2);
|
|
|
|
tcg_gen_andc_tl(t1, t1, t2);
|
|
|
|
tcg_gen_or_tl(cpu_gpr[rA(ctx->opcode)], t0, t1);
|
|
|
|
tcg_temp_free(t0);
|
|
|
|
tcg_temp_free(t1);
|
|
|
|
tcg_temp_free(t2);
|
2007-03-07 09:32:30 +01:00
|
|
|
if (unlikely(Rc(ctx->opcode) != 0))
|
2008-12-05 08:21:44 +01:00
|
|
|
gen_set_Rc0(ctx, cpu_gpr[rA(ctx->opcode)]);
|
2007-03-07 09:32:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* sliq - sliq. */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_sliq(DisasContext *ctx)
|
2007-03-07 09:32:30 +01:00
|
|
|
{
|
2008-12-05 08:21:44 +01:00
|
|
|
int sh = SH(ctx->opcode);
|
|
|
|
TCGv t0 = tcg_temp_new();
|
|
|
|
TCGv t1 = tcg_temp_new();
|
|
|
|
tcg_gen_shli_tl(t0, cpu_gpr[rS(ctx->opcode)], sh);
|
|
|
|
tcg_gen_shri_tl(t1, cpu_gpr[rS(ctx->opcode)], 32 - sh);
|
|
|
|
tcg_gen_or_tl(t1, t0, t1);
|
|
|
|
tcg_gen_mov_tl(cpu_gpr[rA(ctx->opcode)], t0);
|
|
|
|
gen_store_spr(SPR_MQ, t1);
|
|
|
|
tcg_temp_free(t0);
|
|
|
|
tcg_temp_free(t1);
|
2007-03-07 09:32:30 +01:00
|
|
|
if (unlikely(Rc(ctx->opcode) != 0))
|
2008-12-05 08:21:44 +01:00
|
|
|
gen_set_Rc0(ctx, cpu_gpr[rA(ctx->opcode)]);
|
2007-03-07 09:32:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* slliq - slliq. */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_slliq(DisasContext *ctx)
|
2007-03-07 09:32:30 +01:00
|
|
|
{
|
2008-12-05 08:21:44 +01:00
|
|
|
int sh = SH(ctx->opcode);
|
|
|
|
TCGv t0 = tcg_temp_new();
|
|
|
|
TCGv t1 = tcg_temp_new();
|
|
|
|
tcg_gen_rotli_tl(t0, cpu_gpr[rS(ctx->opcode)], sh);
|
|
|
|
gen_load_spr(t1, SPR_MQ);
|
|
|
|
gen_store_spr(SPR_MQ, t0);
|
|
|
|
tcg_gen_andi_tl(t0, t0, (0xFFFFFFFFU << sh));
|
|
|
|
tcg_gen_andi_tl(t1, t1, ~(0xFFFFFFFFU << sh));
|
|
|
|
tcg_gen_or_tl(cpu_gpr[rA(ctx->opcode)], t0, t1);
|
|
|
|
tcg_temp_free(t0);
|
|
|
|
tcg_temp_free(t1);
|
2007-03-07 09:32:30 +01:00
|
|
|
if (unlikely(Rc(ctx->opcode) != 0))
|
2008-12-05 08:21:44 +01:00
|
|
|
gen_set_Rc0(ctx, cpu_gpr[rA(ctx->opcode)]);
|
2007-03-07 09:32:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* sllq - sllq. */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_sllq(DisasContext *ctx)
|
2007-03-07 09:32:30 +01:00
|
|
|
{
|
2015-02-13 21:51:55 +01:00
|
|
|
TCGLabel *l1 = gen_new_label();
|
|
|
|
TCGLabel *l2 = gen_new_label();
|
2008-12-05 08:21:44 +01:00
|
|
|
TCGv t0 = tcg_temp_local_new();
|
|
|
|
TCGv t1 = tcg_temp_local_new();
|
|
|
|
TCGv t2 = tcg_temp_local_new();
|
|
|
|
tcg_gen_andi_tl(t2, cpu_gpr[rB(ctx->opcode)], 0x1F);
|
|
|
|
tcg_gen_movi_tl(t1, 0xFFFFFFFF);
|
|
|
|
tcg_gen_shl_tl(t1, t1, t2);
|
|
|
|
tcg_gen_andi_tl(t0, cpu_gpr[rB(ctx->opcode)], 0x20);
|
|
|
|
tcg_gen_brcondi_tl(TCG_COND_EQ, t0, 0, l1);
|
|
|
|
gen_load_spr(t0, SPR_MQ);
|
|
|
|
tcg_gen_and_tl(cpu_gpr[rA(ctx->opcode)], t0, t1);
|
|
|
|
tcg_gen_br(l2);
|
|
|
|
gen_set_label(l1);
|
|
|
|
tcg_gen_shl_tl(t0, cpu_gpr[rS(ctx->opcode)], t2);
|
|
|
|
gen_load_spr(t2, SPR_MQ);
|
|
|
|
tcg_gen_andc_tl(t1, t2, t1);
|
|
|
|
tcg_gen_or_tl(cpu_gpr[rA(ctx->opcode)], t0, t1);
|
|
|
|
gen_set_label(l2);
|
|
|
|
tcg_temp_free(t0);
|
|
|
|
tcg_temp_free(t1);
|
|
|
|
tcg_temp_free(t2);
|
2007-03-07 09:32:30 +01:00
|
|
|
if (unlikely(Rc(ctx->opcode) != 0))
|
2008-12-05 08:21:44 +01:00
|
|
|
gen_set_Rc0(ctx, cpu_gpr[rA(ctx->opcode)]);
|
2007-03-07 09:32:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* slq - slq. */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_slq(DisasContext *ctx)
|
2007-03-07 09:32:30 +01:00
|
|
|
{
|
2015-02-13 21:51:55 +01:00
|
|
|
TCGLabel *l1 = gen_new_label();
|
2008-12-05 08:21:44 +01:00
|
|
|
TCGv t0 = tcg_temp_new();
|
|
|
|
TCGv t1 = tcg_temp_new();
|
|
|
|
tcg_gen_andi_tl(t1, cpu_gpr[rB(ctx->opcode)], 0x1F);
|
|
|
|
tcg_gen_shl_tl(t0, cpu_gpr[rS(ctx->opcode)], t1);
|
|
|
|
tcg_gen_subfi_tl(t1, 32, t1);
|
|
|
|
tcg_gen_shr_tl(t1, cpu_gpr[rS(ctx->opcode)], t1);
|
|
|
|
tcg_gen_or_tl(t1, t0, t1);
|
|
|
|
gen_store_spr(SPR_MQ, t1);
|
|
|
|
tcg_gen_andi_tl(t1, cpu_gpr[rB(ctx->opcode)], 0x20);
|
|
|
|
tcg_gen_mov_tl(cpu_gpr[rA(ctx->opcode)], t0);
|
|
|
|
tcg_gen_brcondi_tl(TCG_COND_EQ, t1, 0, l1);
|
|
|
|
tcg_gen_movi_tl(cpu_gpr[rA(ctx->opcode)], 0);
|
|
|
|
gen_set_label(l1);
|
|
|
|
tcg_temp_free(t0);
|
|
|
|
tcg_temp_free(t1);
|
2007-03-07 09:32:30 +01:00
|
|
|
if (unlikely(Rc(ctx->opcode) != 0))
|
2008-12-05 08:21:44 +01:00
|
|
|
gen_set_Rc0(ctx, cpu_gpr[rA(ctx->opcode)]);
|
2007-03-07 09:32:30 +01:00
|
|
|
}
|
|
|
|
|
2007-03-17 15:02:15 +01:00
|
|
|
/* sraiq - sraiq. */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_sraiq(DisasContext *ctx)
|
2007-03-07 09:32:30 +01:00
|
|
|
{
|
2008-12-05 08:21:44 +01:00
|
|
|
int sh = SH(ctx->opcode);
|
2015-02-13 21:51:55 +01:00
|
|
|
TCGLabel *l1 = gen_new_label();
|
2008-12-05 08:21:44 +01:00
|
|
|
TCGv t0 = tcg_temp_new();
|
|
|
|
TCGv t1 = tcg_temp_new();
|
|
|
|
tcg_gen_shri_tl(t0, cpu_gpr[rS(ctx->opcode)], sh);
|
|
|
|
tcg_gen_shli_tl(t1, cpu_gpr[rS(ctx->opcode)], 32 - sh);
|
|
|
|
tcg_gen_or_tl(t0, t0, t1);
|
|
|
|
gen_store_spr(SPR_MQ, t0);
|
2013-02-20 08:52:13 +01:00
|
|
|
tcg_gen_movi_tl(cpu_ca, 0);
|
2008-12-05 08:21:44 +01:00
|
|
|
tcg_gen_brcondi_tl(TCG_COND_EQ, t1, 0, l1);
|
|
|
|
tcg_gen_brcondi_tl(TCG_COND_GE, cpu_gpr[rS(ctx->opcode)], 0, l1);
|
2013-02-20 08:52:13 +01:00
|
|
|
tcg_gen_movi_tl(cpu_ca, 1);
|
2008-12-05 08:21:44 +01:00
|
|
|
gen_set_label(l1);
|
|
|
|
tcg_gen_sari_tl(cpu_gpr[rA(ctx->opcode)], cpu_gpr[rS(ctx->opcode)], sh);
|
|
|
|
tcg_temp_free(t0);
|
|
|
|
tcg_temp_free(t1);
|
2007-03-07 09:32:30 +01:00
|
|
|
if (unlikely(Rc(ctx->opcode) != 0))
|
2008-12-05 08:21:44 +01:00
|
|
|
gen_set_Rc0(ctx, cpu_gpr[rA(ctx->opcode)]);
|
2007-03-07 09:32:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* sraq - sraq. */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_sraq(DisasContext *ctx)
|
2007-03-07 09:32:30 +01:00
|
|
|
{
|
2015-02-13 21:51:55 +01:00
|
|
|
TCGLabel *l1 = gen_new_label();
|
|
|
|
TCGLabel *l2 = gen_new_label();
|
2008-12-05 08:21:44 +01:00
|
|
|
TCGv t0 = tcg_temp_new();
|
|
|
|
TCGv t1 = tcg_temp_local_new();
|
|
|
|
TCGv t2 = tcg_temp_local_new();
|
|
|
|
tcg_gen_andi_tl(t2, cpu_gpr[rB(ctx->opcode)], 0x1F);
|
|
|
|
tcg_gen_shr_tl(t0, cpu_gpr[rS(ctx->opcode)], t2);
|
|
|
|
tcg_gen_sar_tl(t1, cpu_gpr[rS(ctx->opcode)], t2);
|
|
|
|
tcg_gen_subfi_tl(t2, 32, t2);
|
|
|
|
tcg_gen_shl_tl(t2, cpu_gpr[rS(ctx->opcode)], t2);
|
|
|
|
tcg_gen_or_tl(t0, t0, t2);
|
|
|
|
gen_store_spr(SPR_MQ, t0);
|
|
|
|
tcg_gen_andi_tl(t0, cpu_gpr[rB(ctx->opcode)], 0x20);
|
|
|
|
tcg_gen_brcondi_tl(TCG_COND_EQ, t2, 0, l1);
|
|
|
|
tcg_gen_mov_tl(t2, cpu_gpr[rS(ctx->opcode)]);
|
|
|
|
tcg_gen_sari_tl(t1, cpu_gpr[rS(ctx->opcode)], 31);
|
|
|
|
gen_set_label(l1);
|
|
|
|
tcg_temp_free(t0);
|
|
|
|
tcg_gen_mov_tl(cpu_gpr[rA(ctx->opcode)], t1);
|
2013-02-20 08:52:13 +01:00
|
|
|
tcg_gen_movi_tl(cpu_ca, 0);
|
2008-12-05 08:21:44 +01:00
|
|
|
tcg_gen_brcondi_tl(TCG_COND_GE, t1, 0, l2);
|
|
|
|
tcg_gen_brcondi_tl(TCG_COND_EQ, t2, 0, l2);
|
2013-02-20 08:52:13 +01:00
|
|
|
tcg_gen_movi_tl(cpu_ca, 1);
|
2008-12-05 08:21:44 +01:00
|
|
|
gen_set_label(l2);
|
|
|
|
tcg_temp_free(t1);
|
|
|
|
tcg_temp_free(t2);
|
2007-03-07 09:32:30 +01:00
|
|
|
if (unlikely(Rc(ctx->opcode) != 0))
|
2008-12-05 08:21:44 +01:00
|
|
|
gen_set_Rc0(ctx, cpu_gpr[rA(ctx->opcode)]);
|
2007-03-07 09:32:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* sre - sre. */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_sre(DisasContext *ctx)
|
2007-03-07 09:32:30 +01:00
|
|
|
{
|
2008-12-05 08:21:44 +01:00
|
|
|
TCGv t0 = tcg_temp_new();
|
|
|
|
TCGv t1 = tcg_temp_new();
|
|
|
|
tcg_gen_andi_tl(t1, cpu_gpr[rB(ctx->opcode)], 0x1F);
|
|
|
|
tcg_gen_shr_tl(t0, cpu_gpr[rS(ctx->opcode)], t1);
|
|
|
|
tcg_gen_subfi_tl(t1, 32, t1);
|
|
|
|
tcg_gen_shl_tl(t1, cpu_gpr[rS(ctx->opcode)], t1);
|
|
|
|
tcg_gen_or_tl(t1, t0, t1);
|
|
|
|
tcg_gen_mov_tl(cpu_gpr[rA(ctx->opcode)], t0);
|
|
|
|
gen_store_spr(SPR_MQ, t1);
|
|
|
|
tcg_temp_free(t0);
|
|
|
|
tcg_temp_free(t1);
|
2007-03-07 09:32:30 +01:00
|
|
|
if (unlikely(Rc(ctx->opcode) != 0))
|
2008-12-05 08:21:44 +01:00
|
|
|
gen_set_Rc0(ctx, cpu_gpr[rA(ctx->opcode)]);
|
2007-03-07 09:32:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* srea - srea. */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_srea(DisasContext *ctx)
|
2007-03-07 09:32:30 +01:00
|
|
|
{
|
2008-12-05 08:21:44 +01:00
|
|
|
TCGv t0 = tcg_temp_new();
|
|
|
|
TCGv t1 = tcg_temp_new();
|
|
|
|
tcg_gen_andi_tl(t1, cpu_gpr[rB(ctx->opcode)], 0x1F);
|
|
|
|
tcg_gen_rotr_tl(t0, cpu_gpr[rS(ctx->opcode)], t1);
|
|
|
|
gen_store_spr(SPR_MQ, t0);
|
|
|
|
tcg_gen_sar_tl(cpu_gpr[rA(ctx->opcode)], cpu_gpr[rS(ctx->opcode)], t1);
|
|
|
|
tcg_temp_free(t0);
|
|
|
|
tcg_temp_free(t1);
|
2007-03-07 09:32:30 +01:00
|
|
|
if (unlikely(Rc(ctx->opcode) != 0))
|
2008-12-05 08:21:44 +01:00
|
|
|
gen_set_Rc0(ctx, cpu_gpr[rA(ctx->opcode)]);
|
2007-03-07 09:32:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* sreq */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_sreq(DisasContext *ctx)
|
2007-03-07 09:32:30 +01:00
|
|
|
{
|
2008-12-05 08:21:44 +01:00
|
|
|
TCGv t0 = tcg_temp_new();
|
|
|
|
TCGv t1 = tcg_temp_new();
|
|
|
|
TCGv t2 = tcg_temp_new();
|
|
|
|
tcg_gen_andi_tl(t0, cpu_gpr[rB(ctx->opcode)], 0x1F);
|
|
|
|
tcg_gen_movi_tl(t1, 0xFFFFFFFF);
|
|
|
|
tcg_gen_shr_tl(t1, t1, t0);
|
|
|
|
tcg_gen_rotr_tl(t0, cpu_gpr[rS(ctx->opcode)], t0);
|
|
|
|
gen_load_spr(t2, SPR_MQ);
|
|
|
|
gen_store_spr(SPR_MQ, t0);
|
|
|
|
tcg_gen_and_tl(t0, t0, t1);
|
|
|
|
tcg_gen_andc_tl(t2, t2, t1);
|
|
|
|
tcg_gen_or_tl(cpu_gpr[rA(ctx->opcode)], t0, t2);
|
|
|
|
tcg_temp_free(t0);
|
|
|
|
tcg_temp_free(t1);
|
|
|
|
tcg_temp_free(t2);
|
2007-03-07 09:32:30 +01:00
|
|
|
if (unlikely(Rc(ctx->opcode) != 0))
|
2008-12-05 08:21:44 +01:00
|
|
|
gen_set_Rc0(ctx, cpu_gpr[rA(ctx->opcode)]);
|
2007-03-07 09:32:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* sriq */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_sriq(DisasContext *ctx)
|
2007-03-07 09:32:30 +01:00
|
|
|
{
|
2008-12-05 08:21:44 +01:00
|
|
|
int sh = SH(ctx->opcode);
|
|
|
|
TCGv t0 = tcg_temp_new();
|
|
|
|
TCGv t1 = tcg_temp_new();
|
|
|
|
tcg_gen_shri_tl(t0, cpu_gpr[rS(ctx->opcode)], sh);
|
|
|
|
tcg_gen_shli_tl(t1, cpu_gpr[rS(ctx->opcode)], 32 - sh);
|
|
|
|
tcg_gen_or_tl(t1, t0, t1);
|
|
|
|
tcg_gen_mov_tl(cpu_gpr[rA(ctx->opcode)], t0);
|
|
|
|
gen_store_spr(SPR_MQ, t1);
|
|
|
|
tcg_temp_free(t0);
|
|
|
|
tcg_temp_free(t1);
|
2007-03-07 09:32:30 +01:00
|
|
|
if (unlikely(Rc(ctx->opcode) != 0))
|
2008-12-05 08:21:44 +01:00
|
|
|
gen_set_Rc0(ctx, cpu_gpr[rA(ctx->opcode)]);
|
2007-03-07 09:32:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* srliq */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_srliq(DisasContext *ctx)
|
2007-03-07 09:32:30 +01:00
|
|
|
{
|
2008-12-05 08:21:44 +01:00
|
|
|
int sh = SH(ctx->opcode);
|
|
|
|
TCGv t0 = tcg_temp_new();
|
|
|
|
TCGv t1 = tcg_temp_new();
|
|
|
|
tcg_gen_rotri_tl(t0, cpu_gpr[rS(ctx->opcode)], sh);
|
|
|
|
gen_load_spr(t1, SPR_MQ);
|
|
|
|
gen_store_spr(SPR_MQ, t0);
|
|
|
|
tcg_gen_andi_tl(t0, t0, (0xFFFFFFFFU >> sh));
|
|
|
|
tcg_gen_andi_tl(t1, t1, ~(0xFFFFFFFFU >> sh));
|
|
|
|
tcg_gen_or_tl(cpu_gpr[rA(ctx->opcode)], t0, t1);
|
|
|
|
tcg_temp_free(t0);
|
|
|
|
tcg_temp_free(t1);
|
2007-03-07 09:32:30 +01:00
|
|
|
if (unlikely(Rc(ctx->opcode) != 0))
|
2008-12-05 08:21:44 +01:00
|
|
|
gen_set_Rc0(ctx, cpu_gpr[rA(ctx->opcode)]);
|
2007-03-07 09:32:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* srlq */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_srlq(DisasContext *ctx)
|
2007-03-07 09:32:30 +01:00
|
|
|
{
|
2015-02-13 21:51:55 +01:00
|
|
|
TCGLabel *l1 = gen_new_label();
|
|
|
|
TCGLabel *l2 = gen_new_label();
|
2008-12-05 08:21:44 +01:00
|
|
|
TCGv t0 = tcg_temp_local_new();
|
|
|
|
TCGv t1 = tcg_temp_local_new();
|
|
|
|
TCGv t2 = tcg_temp_local_new();
|
|
|
|
tcg_gen_andi_tl(t2, cpu_gpr[rB(ctx->opcode)], 0x1F);
|
|
|
|
tcg_gen_movi_tl(t1, 0xFFFFFFFF);
|
|
|
|
tcg_gen_shr_tl(t2, t1, t2);
|
|
|
|
tcg_gen_andi_tl(t0, cpu_gpr[rB(ctx->opcode)], 0x20);
|
|
|
|
tcg_gen_brcondi_tl(TCG_COND_EQ, t0, 0, l1);
|
|
|
|
gen_load_spr(t0, SPR_MQ);
|
|
|
|
tcg_gen_and_tl(cpu_gpr[rA(ctx->opcode)], t0, t2);
|
|
|
|
tcg_gen_br(l2);
|
|
|
|
gen_set_label(l1);
|
|
|
|
tcg_gen_shr_tl(t0, cpu_gpr[rS(ctx->opcode)], t2);
|
|
|
|
tcg_gen_and_tl(t0, t0, t2);
|
|
|
|
gen_load_spr(t1, SPR_MQ);
|
|
|
|
tcg_gen_andc_tl(t1, t1, t2);
|
|
|
|
tcg_gen_or_tl(cpu_gpr[rA(ctx->opcode)], t0, t1);
|
|
|
|
gen_set_label(l2);
|
|
|
|
tcg_temp_free(t0);
|
|
|
|
tcg_temp_free(t1);
|
|
|
|
tcg_temp_free(t2);
|
2007-03-07 09:32:30 +01:00
|
|
|
if (unlikely(Rc(ctx->opcode) != 0))
|
2008-12-05 08:21:44 +01:00
|
|
|
gen_set_Rc0(ctx, cpu_gpr[rA(ctx->opcode)]);
|
2007-03-07 09:32:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* srq */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_srq(DisasContext *ctx)
|
2007-03-07 09:32:30 +01:00
|
|
|
{
|
2015-02-13 21:51:55 +01:00
|
|
|
TCGLabel *l1 = gen_new_label();
|
2008-12-05 08:21:44 +01:00
|
|
|
TCGv t0 = tcg_temp_new();
|
|
|
|
TCGv t1 = tcg_temp_new();
|
|
|
|
tcg_gen_andi_tl(t1, cpu_gpr[rB(ctx->opcode)], 0x1F);
|
|
|
|
tcg_gen_shr_tl(t0, cpu_gpr[rS(ctx->opcode)], t1);
|
|
|
|
tcg_gen_subfi_tl(t1, 32, t1);
|
|
|
|
tcg_gen_shl_tl(t1, cpu_gpr[rS(ctx->opcode)], t1);
|
|
|
|
tcg_gen_or_tl(t1, t0, t1);
|
|
|
|
gen_store_spr(SPR_MQ, t1);
|
|
|
|
tcg_gen_andi_tl(t1, cpu_gpr[rB(ctx->opcode)], 0x20);
|
|
|
|
tcg_gen_mov_tl(cpu_gpr[rA(ctx->opcode)], t0);
|
|
|
|
tcg_gen_brcondi_tl(TCG_COND_EQ, t0, 0, l1);
|
|
|
|
tcg_gen_movi_tl(cpu_gpr[rA(ctx->opcode)], 0);
|
|
|
|
gen_set_label(l1);
|
|
|
|
tcg_temp_free(t0);
|
|
|
|
tcg_temp_free(t1);
|
2007-03-07 09:32:30 +01:00
|
|
|
if (unlikely(Rc(ctx->opcode) != 0))
|
2008-12-05 08:21:44 +01:00
|
|
|
gen_set_Rc0(ctx, cpu_gpr[rA(ctx->opcode)]);
|
2007-03-07 09:32:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* PowerPC 602 specific instructions */
|
2009-06-17 17:22:09 +02:00
|
|
|
|
2009-06-17 17:22:19 +02:00
|
|
|
/* dsa */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_dsa(DisasContext *ctx)
|
2007-03-07 09:32:30 +01:00
|
|
|
{
|
|
|
|
/* XXX: TODO */
|
2008-12-11 23:42:14 +01:00
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_INVAL_INVAL);
|
2007-03-07 09:32:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* esa */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_esa(DisasContext *ctx)
|
2007-03-07 09:32:30 +01:00
|
|
|
{
|
|
|
|
/* XXX: TODO */
|
2008-12-11 23:42:14 +01:00
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_INVAL_INVAL);
|
2007-03-07 09:32:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* mfrom */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_mfrom(DisasContext *ctx)
|
2007-03-07 09:32:30 +01:00
|
|
|
{
|
|
|
|
#if defined(CONFIG_USER_ONLY)
|
2008-12-11 23:42:14 +01:00
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);
|
2007-03-07 09:32:30 +01:00
|
|
|
#else
|
2014-09-15 17:03:28 +02:00
|
|
|
if (unlikely(ctx->pr)) {
|
2008-12-11 23:42:14 +01:00
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);
|
2007-03-07 09:32:30 +01:00
|
|
|
return;
|
|
|
|
}
|
2008-11-30 17:23:35 +01:00
|
|
|
gen_helper_602_mfrom(cpu_gpr[rD(ctx->opcode)], cpu_gpr[rA(ctx->opcode)]);
|
2007-03-07 09:32:30 +01:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
/* 602 - 603 - G2 TLB management */
|
2009-06-17 17:22:14 +02:00
|
|
|
|
2009-06-17 17:22:19 +02:00
|
|
|
/* tlbld */
|
2009-06-17 17:22:14 +02:00
|
|
|
static void gen_tlbld_6xx(DisasContext *ctx)
|
2007-03-07 09:32:30 +01:00
|
|
|
{
|
|
|
|
#if defined(CONFIG_USER_ONLY)
|
2008-12-11 23:42:14 +01:00
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);
|
2007-03-07 09:32:30 +01:00
|
|
|
#else
|
2014-09-15 17:03:28 +02:00
|
|
|
if (unlikely(ctx->pr)) {
|
2008-12-11 23:42:14 +01:00
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);
|
2007-03-07 09:32:30 +01:00
|
|
|
return;
|
|
|
|
}
|
2012-05-30 06:23:31 +02:00
|
|
|
gen_helper_6xx_tlbd(cpu_env, cpu_gpr[rB(ctx->opcode)]);
|
2007-03-07 09:32:30 +01:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
/* tlbli */
|
2009-06-17 17:22:14 +02:00
|
|
|
static void gen_tlbli_6xx(DisasContext *ctx)
|
2007-03-07 09:32:30 +01:00
|
|
|
{
|
|
|
|
#if defined(CONFIG_USER_ONLY)
|
2008-12-11 23:42:14 +01:00
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);
|
2007-03-07 09:32:30 +01:00
|
|
|
#else
|
2014-09-15 17:03:28 +02:00
|
|
|
if (unlikely(ctx->pr)) {
|
2008-12-11 23:42:14 +01:00
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);
|
2007-03-07 09:32:30 +01:00
|
|
|
return;
|
|
|
|
}
|
2012-05-30 06:23:31 +02:00
|
|
|
gen_helper_6xx_tlbi(cpu_env, cpu_gpr[rB(ctx->opcode)]);
|
2007-03-07 09:32:30 +01:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2007-10-01 07:16:57 +02:00
|
|
|
/* 74xx TLB management */
|
2009-06-17 17:22:14 +02:00
|
|
|
|
2009-06-17 17:22:19 +02:00
|
|
|
/* tlbld */
|
2009-06-17 17:22:14 +02:00
|
|
|
static void gen_tlbld_74xx(DisasContext *ctx)
|
2007-10-01 07:16:57 +02:00
|
|
|
{
|
|
|
|
#if defined(CONFIG_USER_ONLY)
|
2008-12-11 23:42:14 +01:00
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);
|
2007-10-01 07:16:57 +02:00
|
|
|
#else
|
2014-09-15 17:03:28 +02:00
|
|
|
if (unlikely(ctx->pr)) {
|
2008-12-11 23:42:14 +01:00
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);
|
2007-10-01 07:16:57 +02:00
|
|
|
return;
|
|
|
|
}
|
2012-05-30 06:23:31 +02:00
|
|
|
gen_helper_74xx_tlbd(cpu_env, cpu_gpr[rB(ctx->opcode)]);
|
2007-10-01 07:16:57 +02:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
/* tlbli */
|
2009-06-17 17:22:14 +02:00
|
|
|
static void gen_tlbli_74xx(DisasContext *ctx)
|
2007-10-01 07:16:57 +02:00
|
|
|
{
|
|
|
|
#if defined(CONFIG_USER_ONLY)
|
2008-12-11 23:42:14 +01:00
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);
|
2007-10-01 07:16:57 +02:00
|
|
|
#else
|
2014-09-15 17:03:28 +02:00
|
|
|
if (unlikely(ctx->pr)) {
|
2008-12-11 23:42:14 +01:00
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);
|
2007-10-01 07:16:57 +02:00
|
|
|
return;
|
|
|
|
}
|
2012-05-30 06:23:31 +02:00
|
|
|
gen_helper_74xx_tlbi(cpu_env, cpu_gpr[rB(ctx->opcode)]);
|
2007-10-01 07:16:57 +02:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2007-03-07 09:32:30 +01:00
|
|
|
/* POWER instructions not in PowerPC 601 */
|
2009-06-17 17:22:09 +02:00
|
|
|
|
2009-06-17 17:22:19 +02:00
|
|
|
/* clf */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_clf(DisasContext *ctx)
|
2007-03-07 09:32:30 +01:00
|
|
|
{
|
|
|
|
/* Cache line flush: implemented as no-op */
|
|
|
|
}
|
|
|
|
|
|
|
|
/* cli */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_cli(DisasContext *ctx)
|
2007-03-07 09:32:30 +01:00
|
|
|
{
|
2007-05-27 21:39:27 +02:00
|
|
|
/* Cache line invalidate: privileged and treated as no-op */
|
2007-03-07 09:32:30 +01:00
|
|
|
#if defined(CONFIG_USER_ONLY)
|
2008-12-11 23:42:14 +01:00
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);
|
2007-03-07 09:32:30 +01:00
|
|
|
#else
|
2014-09-15 17:03:28 +02:00
|
|
|
if (unlikely(ctx->pr)) {
|
2008-12-11 23:42:14 +01:00
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);
|
2007-03-07 09:32:30 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
/* dclst */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_dclst(DisasContext *ctx)
|
2007-03-07 09:32:30 +01:00
|
|
|
{
|
|
|
|
/* Data cache line store: treated as no-op */
|
|
|
|
}
|
|
|
|
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_mfsri(DisasContext *ctx)
|
2007-03-07 09:32:30 +01:00
|
|
|
{
|
|
|
|
#if defined(CONFIG_USER_ONLY)
|
2008-12-11 23:42:14 +01:00
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);
|
2007-03-07 09:32:30 +01:00
|
|
|
#else
|
2008-12-06 22:46:17 +01:00
|
|
|
int ra = rA(ctx->opcode);
|
|
|
|
int rd = rD(ctx->opcode);
|
|
|
|
TCGv t0;
|
2014-09-15 17:03:28 +02:00
|
|
|
if (unlikely(ctx->pr)) {
|
2008-12-11 23:42:14 +01:00
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);
|
2007-03-07 09:32:30 +01:00
|
|
|
return;
|
|
|
|
}
|
2008-12-06 22:46:17 +01:00
|
|
|
t0 = tcg_temp_new();
|
2008-12-08 19:11:21 +01:00
|
|
|
gen_addr_reg_index(ctx, t0);
|
2008-12-06 22:46:17 +01:00
|
|
|
tcg_gen_shri_tl(t0, t0, 28);
|
|
|
|
tcg_gen_andi_tl(t0, t0, 0xF);
|
2012-05-30 06:23:31 +02:00
|
|
|
gen_helper_load_sr(cpu_gpr[rd], cpu_env, t0);
|
2008-12-06 22:46:17 +01:00
|
|
|
tcg_temp_free(t0);
|
2007-03-07 09:32:30 +01:00
|
|
|
if (ra != 0 && ra != rd)
|
2008-12-06 22:46:17 +01:00
|
|
|
tcg_gen_mov_tl(cpu_gpr[ra], cpu_gpr[rd]);
|
2007-03-07 09:32:30 +01:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_rac(DisasContext *ctx)
|
2007-03-07 09:32:30 +01:00
|
|
|
{
|
|
|
|
#if defined(CONFIG_USER_ONLY)
|
2008-12-11 23:42:14 +01:00
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);
|
2007-03-07 09:32:30 +01:00
|
|
|
#else
|
2008-12-06 13:19:14 +01:00
|
|
|
TCGv t0;
|
2014-09-15 17:03:28 +02:00
|
|
|
if (unlikely(ctx->pr)) {
|
2008-12-11 23:42:14 +01:00
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);
|
2007-03-07 09:32:30 +01:00
|
|
|
return;
|
|
|
|
}
|
2008-12-06 13:19:14 +01:00
|
|
|
t0 = tcg_temp_new();
|
2008-12-08 19:11:21 +01:00
|
|
|
gen_addr_reg_index(ctx, t0);
|
2012-05-30 06:23:31 +02:00
|
|
|
gen_helper_rac(cpu_gpr[rD(ctx->opcode)], cpu_env, t0);
|
2008-12-06 13:19:14 +01:00
|
|
|
tcg_temp_free(t0);
|
2007-03-07 09:32:30 +01:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_rfsvc(DisasContext *ctx)
|
2007-03-07 09:32:30 +01:00
|
|
|
{
|
|
|
|
#if defined(CONFIG_USER_ONLY)
|
2008-12-11 23:42:14 +01:00
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);
|
2007-03-07 09:32:30 +01:00
|
|
|
#else
|
2014-09-15 17:03:28 +02:00
|
|
|
if (unlikely(ctx->pr)) {
|
2008-12-11 23:42:14 +01:00
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);
|
2007-03-07 09:32:30 +01:00
|
|
|
return;
|
|
|
|
}
|
2012-05-30 06:23:23 +02:00
|
|
|
gen_helper_rfsvc(cpu_env);
|
2008-12-11 23:42:14 +01:00
|
|
|
gen_sync_exception(ctx);
|
2007-03-07 09:32:30 +01:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
/* svc is not implemented for now */
|
|
|
|
|
|
|
|
/* POWER2 specific instructions */
|
|
|
|
/* Quad manipulation (load/store two floats at a time) */
|
|
|
|
|
|
|
|
/* lfq */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_lfq(DisasContext *ctx)
|
2007-03-07 09:32:30 +01:00
|
|
|
{
|
2008-11-27 20:30:56 +01:00
|
|
|
int rd = rD(ctx->opcode);
|
2008-12-08 19:11:21 +01:00
|
|
|
TCGv t0;
|
|
|
|
gen_set_access_type(ctx, ACCESS_FLOAT);
|
|
|
|
t0 = tcg_temp_new();
|
|
|
|
gen_addr_imm_index(ctx, t0, 0);
|
|
|
|
gen_qemu_ld64(ctx, cpu_fpr[rd], t0);
|
|
|
|
gen_addr_add(ctx, t0, t0, 8);
|
|
|
|
gen_qemu_ld64(ctx, cpu_fpr[(rd + 1) % 32], t0);
|
2008-11-27 20:30:56 +01:00
|
|
|
tcg_temp_free(t0);
|
2007-03-07 09:32:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* lfqu */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_lfqu(DisasContext *ctx)
|
2007-03-07 09:32:30 +01:00
|
|
|
{
|
|
|
|
int ra = rA(ctx->opcode);
|
2008-11-27 20:30:56 +01:00
|
|
|
int rd = rD(ctx->opcode);
|
2008-12-08 19:11:21 +01:00
|
|
|
TCGv t0, t1;
|
|
|
|
gen_set_access_type(ctx, ACCESS_FLOAT);
|
|
|
|
t0 = tcg_temp_new();
|
|
|
|
t1 = tcg_temp_new();
|
|
|
|
gen_addr_imm_index(ctx, t0, 0);
|
|
|
|
gen_qemu_ld64(ctx, cpu_fpr[rd], t0);
|
|
|
|
gen_addr_add(ctx, t1, t0, 8);
|
|
|
|
gen_qemu_ld64(ctx, cpu_fpr[(rd + 1) % 32], t1);
|
2007-03-07 09:32:30 +01:00
|
|
|
if (ra != 0)
|
2008-11-27 20:30:56 +01:00
|
|
|
tcg_gen_mov_tl(cpu_gpr[ra], t0);
|
|
|
|
tcg_temp_free(t0);
|
|
|
|
tcg_temp_free(t1);
|
2007-03-07 09:32:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* lfqux */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_lfqux(DisasContext *ctx)
|
2007-03-07 09:32:30 +01:00
|
|
|
{
|
|
|
|
int ra = rA(ctx->opcode);
|
2008-11-27 20:30:56 +01:00
|
|
|
int rd = rD(ctx->opcode);
|
2008-12-08 19:11:21 +01:00
|
|
|
gen_set_access_type(ctx, ACCESS_FLOAT);
|
|
|
|
TCGv t0, t1;
|
|
|
|
t0 = tcg_temp_new();
|
|
|
|
gen_addr_reg_index(ctx, t0);
|
|
|
|
gen_qemu_ld64(ctx, cpu_fpr[rd], t0);
|
|
|
|
t1 = tcg_temp_new();
|
|
|
|
gen_addr_add(ctx, t1, t0, 8);
|
|
|
|
gen_qemu_ld64(ctx, cpu_fpr[(rd + 1) % 32], t1);
|
|
|
|
tcg_temp_free(t1);
|
2007-03-07 09:32:30 +01:00
|
|
|
if (ra != 0)
|
2008-11-27 20:30:56 +01:00
|
|
|
tcg_gen_mov_tl(cpu_gpr[ra], t0);
|
|
|
|
tcg_temp_free(t0);
|
2007-03-07 09:32:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* lfqx */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_lfqx(DisasContext *ctx)
|
2007-03-07 09:32:30 +01:00
|
|
|
{
|
2008-11-27 20:30:56 +01:00
|
|
|
int rd = rD(ctx->opcode);
|
2008-12-08 19:11:21 +01:00
|
|
|
TCGv t0;
|
|
|
|
gen_set_access_type(ctx, ACCESS_FLOAT);
|
|
|
|
t0 = tcg_temp_new();
|
|
|
|
gen_addr_reg_index(ctx, t0);
|
|
|
|
gen_qemu_ld64(ctx, cpu_fpr[rd], t0);
|
|
|
|
gen_addr_add(ctx, t0, t0, 8);
|
|
|
|
gen_qemu_ld64(ctx, cpu_fpr[(rd + 1) % 32], t0);
|
2008-11-27 20:30:56 +01:00
|
|
|
tcg_temp_free(t0);
|
2007-03-07 09:32:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* stfq */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_stfq(DisasContext *ctx)
|
2007-03-07 09:32:30 +01:00
|
|
|
{
|
2008-11-27 20:30:56 +01:00
|
|
|
int rd = rD(ctx->opcode);
|
2008-12-08 19:11:21 +01:00
|
|
|
TCGv t0;
|
|
|
|
gen_set_access_type(ctx, ACCESS_FLOAT);
|
|
|
|
t0 = tcg_temp_new();
|
|
|
|
gen_addr_imm_index(ctx, t0, 0);
|
|
|
|
gen_qemu_st64(ctx, cpu_fpr[rd], t0);
|
|
|
|
gen_addr_add(ctx, t0, t0, 8);
|
|
|
|
gen_qemu_st64(ctx, cpu_fpr[(rd + 1) % 32], t0);
|
2008-11-27 20:30:56 +01:00
|
|
|
tcg_temp_free(t0);
|
2007-03-07 09:32:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* stfqu */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_stfqu(DisasContext *ctx)
|
2007-03-07 09:32:30 +01:00
|
|
|
{
|
|
|
|
int ra = rA(ctx->opcode);
|
2008-11-27 20:30:56 +01:00
|
|
|
int rd = rD(ctx->opcode);
|
2008-12-08 19:11:21 +01:00
|
|
|
TCGv t0, t1;
|
|
|
|
gen_set_access_type(ctx, ACCESS_FLOAT);
|
|
|
|
t0 = tcg_temp_new();
|
|
|
|
gen_addr_imm_index(ctx, t0, 0);
|
|
|
|
gen_qemu_st64(ctx, cpu_fpr[rd], t0);
|
|
|
|
t1 = tcg_temp_new();
|
|
|
|
gen_addr_add(ctx, t1, t0, 8);
|
|
|
|
gen_qemu_st64(ctx, cpu_fpr[(rd + 1) % 32], t1);
|
|
|
|
tcg_temp_free(t1);
|
2007-03-07 09:32:30 +01:00
|
|
|
if (ra != 0)
|
2008-11-27 20:30:56 +01:00
|
|
|
tcg_gen_mov_tl(cpu_gpr[ra], t0);
|
|
|
|
tcg_temp_free(t0);
|
2007-03-07 09:32:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* stfqux */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_stfqux(DisasContext *ctx)
|
2007-03-07 09:32:30 +01:00
|
|
|
{
|
|
|
|
int ra = rA(ctx->opcode);
|
2008-11-27 20:30:56 +01:00
|
|
|
int rd = rD(ctx->opcode);
|
2008-12-08 19:11:21 +01:00
|
|
|
TCGv t0, t1;
|
|
|
|
gen_set_access_type(ctx, ACCESS_FLOAT);
|
|
|
|
t0 = tcg_temp_new();
|
|
|
|
gen_addr_reg_index(ctx, t0);
|
|
|
|
gen_qemu_st64(ctx, cpu_fpr[rd], t0);
|
|
|
|
t1 = tcg_temp_new();
|
|
|
|
gen_addr_add(ctx, t1, t0, 8);
|
|
|
|
gen_qemu_st64(ctx, cpu_fpr[(rd + 1) % 32], t1);
|
|
|
|
tcg_temp_free(t1);
|
2007-03-07 09:32:30 +01:00
|
|
|
if (ra != 0)
|
2008-11-27 20:30:56 +01:00
|
|
|
tcg_gen_mov_tl(cpu_gpr[ra], t0);
|
|
|
|
tcg_temp_free(t0);
|
2007-03-07 09:32:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* stfqx */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_stfqx(DisasContext *ctx)
|
2007-03-07 09:32:30 +01:00
|
|
|
{
|
2008-11-27 20:30:56 +01:00
|
|
|
int rd = rD(ctx->opcode);
|
2008-12-08 19:11:21 +01:00
|
|
|
TCGv t0;
|
|
|
|
gen_set_access_type(ctx, ACCESS_FLOAT);
|
|
|
|
t0 = tcg_temp_new();
|
|
|
|
gen_addr_reg_index(ctx, t0);
|
|
|
|
gen_qemu_st64(ctx, cpu_fpr[rd], t0);
|
|
|
|
gen_addr_add(ctx, t0, t0, 8);
|
|
|
|
gen_qemu_st64(ctx, cpu_fpr[(rd + 1) % 32], t0);
|
2008-11-27 20:30:56 +01:00
|
|
|
tcg_temp_free(t0);
|
2007-03-07 09:32:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* BookE specific instructions */
|
2009-06-17 17:22:09 +02:00
|
|
|
|
2009-06-17 17:22:19 +02:00
|
|
|
/* XXX: not implemented on 440 ? */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_mfapidi(DisasContext *ctx)
|
2007-03-07 09:32:30 +01:00
|
|
|
{
|
|
|
|
/* XXX: TODO */
|
2008-12-11 23:42:14 +01:00
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_INVAL_INVAL);
|
2007-03-07 09:32:30 +01:00
|
|
|
}
|
|
|
|
|
2007-09-21 07:50:37 +02:00
|
|
|
/* XXX: not implemented on 440 ? */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_tlbiva(DisasContext *ctx)
|
2007-03-07 09:32:30 +01:00
|
|
|
{
|
|
|
|
#if defined(CONFIG_USER_ONLY)
|
2008-12-11 23:42:14 +01:00
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);
|
2007-03-07 09:32:30 +01:00
|
|
|
#else
|
2008-12-06 22:46:17 +01:00
|
|
|
TCGv t0;
|
2014-09-15 17:03:28 +02:00
|
|
|
if (unlikely(ctx->pr)) {
|
2008-12-11 23:42:14 +01:00
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);
|
2007-03-07 09:32:30 +01:00
|
|
|
return;
|
|
|
|
}
|
2008-12-07 16:45:15 +01:00
|
|
|
t0 = tcg_temp_new();
|
2008-12-08 19:11:21 +01:00
|
|
|
gen_addr_reg_index(ctx, t0);
|
2016-01-28 00:31:04 +01:00
|
|
|
gen_helper_tlbiva(cpu_env, cpu_gpr[rB(ctx->opcode)]);
|
2008-12-06 22:46:17 +01:00
|
|
|
tcg_temp_free(t0);
|
2007-03-07 09:32:30 +01:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
/* All 405 MAC instructions are translated here */
|
2009-08-16 11:06:54 +02:00
|
|
|
static inline void gen_405_mulladd_insn(DisasContext *ctx, int opc2, int opc3,
|
|
|
|
int ra, int rb, int rt, int Rc)
|
2007-03-07 09:32:30 +01:00
|
|
|
{
|
2008-11-01 01:54:23 +01:00
|
|
|
TCGv t0, t1;
|
|
|
|
|
2008-11-17 15:43:54 +01:00
|
|
|
t0 = tcg_temp_local_new();
|
|
|
|
t1 = tcg_temp_local_new();
|
2008-11-01 01:54:23 +01:00
|
|
|
|
2007-03-07 09:32:30 +01:00
|
|
|
switch (opc3 & 0x0D) {
|
|
|
|
case 0x05:
|
|
|
|
/* macchw - macchw. - macchwo - macchwo. */
|
|
|
|
/* macchws - macchws. - macchwso - macchwso. */
|
|
|
|
/* nmacchw - nmacchw. - nmacchwo - nmacchwo. */
|
|
|
|
/* nmacchws - nmacchws. - nmacchwso - nmacchwso. */
|
|
|
|
/* mulchw - mulchw. */
|
2008-11-01 01:54:23 +01:00
|
|
|
tcg_gen_ext16s_tl(t0, cpu_gpr[ra]);
|
|
|
|
tcg_gen_sari_tl(t1, cpu_gpr[rb], 16);
|
|
|
|
tcg_gen_ext16s_tl(t1, t1);
|
2007-03-07 09:32:30 +01:00
|
|
|
break;
|
|
|
|
case 0x04:
|
|
|
|
/* macchwu - macchwu. - macchwuo - macchwuo. */
|
|
|
|
/* macchwsu - macchwsu. - macchwsuo - macchwsuo. */
|
|
|
|
/* mulchwu - mulchwu. */
|
2008-11-01 01:54:23 +01:00
|
|
|
tcg_gen_ext16u_tl(t0, cpu_gpr[ra]);
|
|
|
|
tcg_gen_shri_tl(t1, cpu_gpr[rb], 16);
|
|
|
|
tcg_gen_ext16u_tl(t1, t1);
|
2007-03-07 09:32:30 +01:00
|
|
|
break;
|
|
|
|
case 0x01:
|
|
|
|
/* machhw - machhw. - machhwo - machhwo. */
|
|
|
|
/* machhws - machhws. - machhwso - machhwso. */
|
|
|
|
/* nmachhw - nmachhw. - nmachhwo - nmachhwo. */
|
|
|
|
/* nmachhws - nmachhws. - nmachhwso - nmachhwso. */
|
|
|
|
/* mulhhw - mulhhw. */
|
2008-11-01 01:54:23 +01:00
|
|
|
tcg_gen_sari_tl(t0, cpu_gpr[ra], 16);
|
|
|
|
tcg_gen_ext16s_tl(t0, t0);
|
|
|
|
tcg_gen_sari_tl(t1, cpu_gpr[rb], 16);
|
|
|
|
tcg_gen_ext16s_tl(t1, t1);
|
2007-03-07 09:32:30 +01:00
|
|
|
break;
|
|
|
|
case 0x00:
|
|
|
|
/* machhwu - machhwu. - machhwuo - machhwuo. */
|
|
|
|
/* machhwsu - machhwsu. - machhwsuo - machhwsuo. */
|
|
|
|
/* mulhhwu - mulhhwu. */
|
2008-11-01 01:54:23 +01:00
|
|
|
tcg_gen_shri_tl(t0, cpu_gpr[ra], 16);
|
|
|
|
tcg_gen_ext16u_tl(t0, t0);
|
|
|
|
tcg_gen_shri_tl(t1, cpu_gpr[rb], 16);
|
|
|
|
tcg_gen_ext16u_tl(t1, t1);
|
2007-03-07 09:32:30 +01:00
|
|
|
break;
|
|
|
|
case 0x0D:
|
|
|
|
/* maclhw - maclhw. - maclhwo - maclhwo. */
|
|
|
|
/* maclhws - maclhws. - maclhwso - maclhwso. */
|
|
|
|
/* nmaclhw - nmaclhw. - nmaclhwo - nmaclhwo. */
|
|
|
|
/* nmaclhws - nmaclhws. - nmaclhwso - nmaclhwso. */
|
|
|
|
/* mullhw - mullhw. */
|
2008-11-01 01:54:23 +01:00
|
|
|
tcg_gen_ext16s_tl(t0, cpu_gpr[ra]);
|
|
|
|
tcg_gen_ext16s_tl(t1, cpu_gpr[rb]);
|
2007-03-07 09:32:30 +01:00
|
|
|
break;
|
|
|
|
case 0x0C:
|
|
|
|
/* maclhwu - maclhwu. - maclhwuo - maclhwuo. */
|
|
|
|
/* maclhwsu - maclhwsu. - maclhwsuo - maclhwsuo. */
|
|
|
|
/* mullhwu - mullhwu. */
|
2008-11-01 01:54:23 +01:00
|
|
|
tcg_gen_ext16u_tl(t0, cpu_gpr[ra]);
|
|
|
|
tcg_gen_ext16u_tl(t1, cpu_gpr[rb]);
|
2007-03-07 09:32:30 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (opc2 & 0x04) {
|
2008-11-01 01:54:23 +01:00
|
|
|
/* (n)multiply-and-accumulate (0x0C / 0x0E) */
|
|
|
|
tcg_gen_mul_tl(t1, t0, t1);
|
|
|
|
if (opc2 & 0x02) {
|
|
|
|
/* nmultiply-and-accumulate (0x0E) */
|
|
|
|
tcg_gen_sub_tl(t0, cpu_gpr[rt], t1);
|
|
|
|
} else {
|
|
|
|
/* multiply-and-accumulate (0x0C) */
|
|
|
|
tcg_gen_add_tl(t0, cpu_gpr[rt], t1);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (opc3 & 0x12) {
|
|
|
|
/* Check overflow and/or saturate */
|
2015-02-13 21:51:55 +01:00
|
|
|
TCGLabel *l1 = gen_new_label();
|
2008-11-01 01:54:23 +01:00
|
|
|
|
|
|
|
if (opc3 & 0x10) {
|
|
|
|
/* Start with XER OV disabled, the most likely case */
|
2013-02-20 08:52:13 +01:00
|
|
|
tcg_gen_movi_tl(cpu_ov, 0);
|
2008-11-01 01:54:23 +01:00
|
|
|
}
|
|
|
|
if (opc3 & 0x01) {
|
|
|
|
/* Signed */
|
|
|
|
tcg_gen_xor_tl(t1, cpu_gpr[rt], t1);
|
|
|
|
tcg_gen_brcondi_tl(TCG_COND_GE, t1, 0, l1);
|
|
|
|
tcg_gen_xor_tl(t1, cpu_gpr[rt], t0);
|
|
|
|
tcg_gen_brcondi_tl(TCG_COND_LT, t1, 0, l1);
|
2008-11-09 18:27:03 +01:00
|
|
|
if (opc3 & 0x02) {
|
2008-11-01 01:54:23 +01:00
|
|
|
/* Saturate */
|
|
|
|
tcg_gen_sari_tl(t0, cpu_gpr[rt], 31);
|
|
|
|
tcg_gen_xori_tl(t0, t0, 0x7fffffff);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
/* Unsigned */
|
|
|
|
tcg_gen_brcond_tl(TCG_COND_GEU, t0, t1, l1);
|
2008-11-09 18:27:03 +01:00
|
|
|
if (opc3 & 0x02) {
|
2008-11-01 01:54:23 +01:00
|
|
|
/* Saturate */
|
|
|
|
tcg_gen_movi_tl(t0, UINT32_MAX);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (opc3 & 0x10) {
|
|
|
|
/* Check overflow */
|
2013-02-20 08:52:13 +01:00
|
|
|
tcg_gen_movi_tl(cpu_ov, 1);
|
|
|
|
tcg_gen_movi_tl(cpu_so, 1);
|
2008-11-01 01:54:23 +01:00
|
|
|
}
|
|
|
|
gen_set_label(l1);
|
|
|
|
tcg_gen_mov_tl(cpu_gpr[rt], t0);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
tcg_gen_mul_tl(cpu_gpr[rt], t0, t1);
|
2007-03-07 09:32:30 +01:00
|
|
|
}
|
2008-11-01 01:54:23 +01:00
|
|
|
tcg_temp_free(t0);
|
|
|
|
tcg_temp_free(t1);
|
2007-03-07 09:32:30 +01:00
|
|
|
if (unlikely(Rc) != 0) {
|
|
|
|
/* Update Rc0 */
|
2008-11-01 01:54:23 +01:00
|
|
|
gen_set_Rc0(ctx, cpu_gpr[rt]);
|
2007-03-07 09:32:30 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
Great rework and cleanups to ease PowerPC implementations definitions.
* cleanup cpu.h, removing definitions used only in translate.c/translate_init.c
* add new flags to define instructions sets more precisely
* various changes in MMU models definitions
* add definitions for PowerPC 440/460 support (insns and SPRs).
* add definitions for PowerPC 401/403 and 620 input pins model
* Fix definitions for most PowerPC 401, 403, 405, 440, 601, 602, 603 and 7x0
* Preliminary support for PowerPC 74xx (aka G4) without altivec.
* Code provision for other PowerPC support (7x5, 970, ...).
* New SPR and PVR defined, from PowerPC 2.04 specification and other sources
* Misc code bugs, error messages and styles fixes.
* Update status files for PowerPC cores support.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3244 c046a42c-6fe2-441c-8c8c-71466251a162
2007-09-27 01:54:22 +02:00
|
|
|
#define GEN_MAC_HANDLER(name, opc2, opc3) \
|
2009-06-17 17:22:09 +02:00
|
|
|
static void glue(gen_, name)(DisasContext *ctx) \
|
2007-03-07 09:32:30 +01:00
|
|
|
{ \
|
|
|
|
gen_405_mulladd_insn(ctx, opc2, opc3, rA(ctx->opcode), rB(ctx->opcode), \
|
|
|
|
rD(ctx->opcode), Rc(ctx->opcode)); \
|
|
|
|
}
|
|
|
|
|
|
|
|
/* macchw - macchw. */
|
Great rework and cleanups to ease PowerPC implementations definitions.
* cleanup cpu.h, removing definitions used only in translate.c/translate_init.c
* add new flags to define instructions sets more precisely
* various changes in MMU models definitions
* add definitions for PowerPC 440/460 support (insns and SPRs).
* add definitions for PowerPC 401/403 and 620 input pins model
* Fix definitions for most PowerPC 401, 403, 405, 440, 601, 602, 603 and 7x0
* Preliminary support for PowerPC 74xx (aka G4) without altivec.
* Code provision for other PowerPC support (7x5, 970, ...).
* New SPR and PVR defined, from PowerPC 2.04 specification and other sources
* Misc code bugs, error messages and styles fixes.
* Update status files for PowerPC cores support.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3244 c046a42c-6fe2-441c-8c8c-71466251a162
2007-09-27 01:54:22 +02:00
|
|
|
GEN_MAC_HANDLER(macchw, 0x0C, 0x05);
|
2007-03-07 09:32:30 +01:00
|
|
|
/* macchwo - macchwo. */
|
Great rework and cleanups to ease PowerPC implementations definitions.
* cleanup cpu.h, removing definitions used only in translate.c/translate_init.c
* add new flags to define instructions sets more precisely
* various changes in MMU models definitions
* add definitions for PowerPC 440/460 support (insns and SPRs).
* add definitions for PowerPC 401/403 and 620 input pins model
* Fix definitions for most PowerPC 401, 403, 405, 440, 601, 602, 603 and 7x0
* Preliminary support for PowerPC 74xx (aka G4) without altivec.
* Code provision for other PowerPC support (7x5, 970, ...).
* New SPR and PVR defined, from PowerPC 2.04 specification and other sources
* Misc code bugs, error messages and styles fixes.
* Update status files for PowerPC cores support.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3244 c046a42c-6fe2-441c-8c8c-71466251a162
2007-09-27 01:54:22 +02:00
|
|
|
GEN_MAC_HANDLER(macchwo, 0x0C, 0x15);
|
2007-03-07 09:32:30 +01:00
|
|
|
/* macchws - macchws. */
|
Great rework and cleanups to ease PowerPC implementations definitions.
* cleanup cpu.h, removing definitions used only in translate.c/translate_init.c
* add new flags to define instructions sets more precisely
* various changes in MMU models definitions
* add definitions for PowerPC 440/460 support (insns and SPRs).
* add definitions for PowerPC 401/403 and 620 input pins model
* Fix definitions for most PowerPC 401, 403, 405, 440, 601, 602, 603 and 7x0
* Preliminary support for PowerPC 74xx (aka G4) without altivec.
* Code provision for other PowerPC support (7x5, 970, ...).
* New SPR and PVR defined, from PowerPC 2.04 specification and other sources
* Misc code bugs, error messages and styles fixes.
* Update status files for PowerPC cores support.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3244 c046a42c-6fe2-441c-8c8c-71466251a162
2007-09-27 01:54:22 +02:00
|
|
|
GEN_MAC_HANDLER(macchws, 0x0C, 0x07);
|
2007-03-07 09:32:30 +01:00
|
|
|
/* macchwso - macchwso. */
|
Great rework and cleanups to ease PowerPC implementations definitions.
* cleanup cpu.h, removing definitions used only in translate.c/translate_init.c
* add new flags to define instructions sets more precisely
* various changes in MMU models definitions
* add definitions for PowerPC 440/460 support (insns and SPRs).
* add definitions for PowerPC 401/403 and 620 input pins model
* Fix definitions for most PowerPC 401, 403, 405, 440, 601, 602, 603 and 7x0
* Preliminary support for PowerPC 74xx (aka G4) without altivec.
* Code provision for other PowerPC support (7x5, 970, ...).
* New SPR and PVR defined, from PowerPC 2.04 specification and other sources
* Misc code bugs, error messages and styles fixes.
* Update status files for PowerPC cores support.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3244 c046a42c-6fe2-441c-8c8c-71466251a162
2007-09-27 01:54:22 +02:00
|
|
|
GEN_MAC_HANDLER(macchwso, 0x0C, 0x17);
|
2007-03-07 09:32:30 +01:00
|
|
|
/* macchwsu - macchwsu. */
|
Great rework and cleanups to ease PowerPC implementations definitions.
* cleanup cpu.h, removing definitions used only in translate.c/translate_init.c
* add new flags to define instructions sets more precisely
* various changes in MMU models definitions
* add definitions for PowerPC 440/460 support (insns and SPRs).
* add definitions for PowerPC 401/403 and 620 input pins model
* Fix definitions for most PowerPC 401, 403, 405, 440, 601, 602, 603 and 7x0
* Preliminary support for PowerPC 74xx (aka G4) without altivec.
* Code provision for other PowerPC support (7x5, 970, ...).
* New SPR and PVR defined, from PowerPC 2.04 specification and other sources
* Misc code bugs, error messages and styles fixes.
* Update status files for PowerPC cores support.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3244 c046a42c-6fe2-441c-8c8c-71466251a162
2007-09-27 01:54:22 +02:00
|
|
|
GEN_MAC_HANDLER(macchwsu, 0x0C, 0x06);
|
2007-03-07 09:32:30 +01:00
|
|
|
/* macchwsuo - macchwsuo. */
|
Great rework and cleanups to ease PowerPC implementations definitions.
* cleanup cpu.h, removing definitions used only in translate.c/translate_init.c
* add new flags to define instructions sets more precisely
* various changes in MMU models definitions
* add definitions for PowerPC 440/460 support (insns and SPRs).
* add definitions for PowerPC 401/403 and 620 input pins model
* Fix definitions for most PowerPC 401, 403, 405, 440, 601, 602, 603 and 7x0
* Preliminary support for PowerPC 74xx (aka G4) without altivec.
* Code provision for other PowerPC support (7x5, 970, ...).
* New SPR and PVR defined, from PowerPC 2.04 specification and other sources
* Misc code bugs, error messages and styles fixes.
* Update status files for PowerPC cores support.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3244 c046a42c-6fe2-441c-8c8c-71466251a162
2007-09-27 01:54:22 +02:00
|
|
|
GEN_MAC_HANDLER(macchwsuo, 0x0C, 0x16);
|
2007-03-07 09:32:30 +01:00
|
|
|
/* macchwu - macchwu. */
|
Great rework and cleanups to ease PowerPC implementations definitions.
* cleanup cpu.h, removing definitions used only in translate.c/translate_init.c
* add new flags to define instructions sets more precisely
* various changes in MMU models definitions
* add definitions for PowerPC 440/460 support (insns and SPRs).
* add definitions for PowerPC 401/403 and 620 input pins model
* Fix definitions for most PowerPC 401, 403, 405, 440, 601, 602, 603 and 7x0
* Preliminary support for PowerPC 74xx (aka G4) without altivec.
* Code provision for other PowerPC support (7x5, 970, ...).
* New SPR and PVR defined, from PowerPC 2.04 specification and other sources
* Misc code bugs, error messages and styles fixes.
* Update status files for PowerPC cores support.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3244 c046a42c-6fe2-441c-8c8c-71466251a162
2007-09-27 01:54:22 +02:00
|
|
|
GEN_MAC_HANDLER(macchwu, 0x0C, 0x04);
|
2007-03-07 09:32:30 +01:00
|
|
|
/* macchwuo - macchwuo. */
|
Great rework and cleanups to ease PowerPC implementations definitions.
* cleanup cpu.h, removing definitions used only in translate.c/translate_init.c
* add new flags to define instructions sets more precisely
* various changes in MMU models definitions
* add definitions for PowerPC 440/460 support (insns and SPRs).
* add definitions for PowerPC 401/403 and 620 input pins model
* Fix definitions for most PowerPC 401, 403, 405, 440, 601, 602, 603 and 7x0
* Preliminary support for PowerPC 74xx (aka G4) without altivec.
* Code provision for other PowerPC support (7x5, 970, ...).
* New SPR and PVR defined, from PowerPC 2.04 specification and other sources
* Misc code bugs, error messages and styles fixes.
* Update status files for PowerPC cores support.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3244 c046a42c-6fe2-441c-8c8c-71466251a162
2007-09-27 01:54:22 +02:00
|
|
|
GEN_MAC_HANDLER(macchwuo, 0x0C, 0x14);
|
2007-03-07 09:32:30 +01:00
|
|
|
/* machhw - machhw. */
|
Great rework and cleanups to ease PowerPC implementations definitions.
* cleanup cpu.h, removing definitions used only in translate.c/translate_init.c
* add new flags to define instructions sets more precisely
* various changes in MMU models definitions
* add definitions for PowerPC 440/460 support (insns and SPRs).
* add definitions for PowerPC 401/403 and 620 input pins model
* Fix definitions for most PowerPC 401, 403, 405, 440, 601, 602, 603 and 7x0
* Preliminary support for PowerPC 74xx (aka G4) without altivec.
* Code provision for other PowerPC support (7x5, 970, ...).
* New SPR and PVR defined, from PowerPC 2.04 specification and other sources
* Misc code bugs, error messages and styles fixes.
* Update status files for PowerPC cores support.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3244 c046a42c-6fe2-441c-8c8c-71466251a162
2007-09-27 01:54:22 +02:00
|
|
|
GEN_MAC_HANDLER(machhw, 0x0C, 0x01);
|
2007-03-07 09:32:30 +01:00
|
|
|
/* machhwo - machhwo. */
|
Great rework and cleanups to ease PowerPC implementations definitions.
* cleanup cpu.h, removing definitions used only in translate.c/translate_init.c
* add new flags to define instructions sets more precisely
* various changes in MMU models definitions
* add definitions for PowerPC 440/460 support (insns and SPRs).
* add definitions for PowerPC 401/403 and 620 input pins model
* Fix definitions for most PowerPC 401, 403, 405, 440, 601, 602, 603 and 7x0
* Preliminary support for PowerPC 74xx (aka G4) without altivec.
* Code provision for other PowerPC support (7x5, 970, ...).
* New SPR and PVR defined, from PowerPC 2.04 specification and other sources
* Misc code bugs, error messages and styles fixes.
* Update status files for PowerPC cores support.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3244 c046a42c-6fe2-441c-8c8c-71466251a162
2007-09-27 01:54:22 +02:00
|
|
|
GEN_MAC_HANDLER(machhwo, 0x0C, 0x11);
|
2007-03-07 09:32:30 +01:00
|
|
|
/* machhws - machhws. */
|
Great rework and cleanups to ease PowerPC implementations definitions.
* cleanup cpu.h, removing definitions used only in translate.c/translate_init.c
* add new flags to define instructions sets more precisely
* various changes in MMU models definitions
* add definitions for PowerPC 440/460 support (insns and SPRs).
* add definitions for PowerPC 401/403 and 620 input pins model
* Fix definitions for most PowerPC 401, 403, 405, 440, 601, 602, 603 and 7x0
* Preliminary support for PowerPC 74xx (aka G4) without altivec.
* Code provision for other PowerPC support (7x5, 970, ...).
* New SPR and PVR defined, from PowerPC 2.04 specification and other sources
* Misc code bugs, error messages and styles fixes.
* Update status files for PowerPC cores support.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3244 c046a42c-6fe2-441c-8c8c-71466251a162
2007-09-27 01:54:22 +02:00
|
|
|
GEN_MAC_HANDLER(machhws, 0x0C, 0x03);
|
2007-03-07 09:32:30 +01:00
|
|
|
/* machhwso - machhwso. */
|
Great rework and cleanups to ease PowerPC implementations definitions.
* cleanup cpu.h, removing definitions used only in translate.c/translate_init.c
* add new flags to define instructions sets more precisely
* various changes in MMU models definitions
* add definitions for PowerPC 440/460 support (insns and SPRs).
* add definitions for PowerPC 401/403 and 620 input pins model
* Fix definitions for most PowerPC 401, 403, 405, 440, 601, 602, 603 and 7x0
* Preliminary support for PowerPC 74xx (aka G4) without altivec.
* Code provision for other PowerPC support (7x5, 970, ...).
* New SPR and PVR defined, from PowerPC 2.04 specification and other sources
* Misc code bugs, error messages and styles fixes.
* Update status files for PowerPC cores support.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3244 c046a42c-6fe2-441c-8c8c-71466251a162
2007-09-27 01:54:22 +02:00
|
|
|
GEN_MAC_HANDLER(machhwso, 0x0C, 0x13);
|
2007-03-07 09:32:30 +01:00
|
|
|
/* machhwsu - machhwsu. */
|
Great rework and cleanups to ease PowerPC implementations definitions.
* cleanup cpu.h, removing definitions used only in translate.c/translate_init.c
* add new flags to define instructions sets more precisely
* various changes in MMU models definitions
* add definitions for PowerPC 440/460 support (insns and SPRs).
* add definitions for PowerPC 401/403 and 620 input pins model
* Fix definitions for most PowerPC 401, 403, 405, 440, 601, 602, 603 and 7x0
* Preliminary support for PowerPC 74xx (aka G4) without altivec.
* Code provision for other PowerPC support (7x5, 970, ...).
* New SPR and PVR defined, from PowerPC 2.04 specification and other sources
* Misc code bugs, error messages and styles fixes.
* Update status files for PowerPC cores support.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3244 c046a42c-6fe2-441c-8c8c-71466251a162
2007-09-27 01:54:22 +02:00
|
|
|
GEN_MAC_HANDLER(machhwsu, 0x0C, 0x02);
|
2007-03-07 09:32:30 +01:00
|
|
|
/* machhwsuo - machhwsuo. */
|
Great rework and cleanups to ease PowerPC implementations definitions.
* cleanup cpu.h, removing definitions used only in translate.c/translate_init.c
* add new flags to define instructions sets more precisely
* various changes in MMU models definitions
* add definitions for PowerPC 440/460 support (insns and SPRs).
* add definitions for PowerPC 401/403 and 620 input pins model
* Fix definitions for most PowerPC 401, 403, 405, 440, 601, 602, 603 and 7x0
* Preliminary support for PowerPC 74xx (aka G4) without altivec.
* Code provision for other PowerPC support (7x5, 970, ...).
* New SPR and PVR defined, from PowerPC 2.04 specification and other sources
* Misc code bugs, error messages and styles fixes.
* Update status files for PowerPC cores support.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3244 c046a42c-6fe2-441c-8c8c-71466251a162
2007-09-27 01:54:22 +02:00
|
|
|
GEN_MAC_HANDLER(machhwsuo, 0x0C, 0x12);
|
2007-03-07 09:32:30 +01:00
|
|
|
/* machhwu - machhwu. */
|
Great rework and cleanups to ease PowerPC implementations definitions.
* cleanup cpu.h, removing definitions used only in translate.c/translate_init.c
* add new flags to define instructions sets more precisely
* various changes in MMU models definitions
* add definitions for PowerPC 440/460 support (insns and SPRs).
* add definitions for PowerPC 401/403 and 620 input pins model
* Fix definitions for most PowerPC 401, 403, 405, 440, 601, 602, 603 and 7x0
* Preliminary support for PowerPC 74xx (aka G4) without altivec.
* Code provision for other PowerPC support (7x5, 970, ...).
* New SPR and PVR defined, from PowerPC 2.04 specification and other sources
* Misc code bugs, error messages and styles fixes.
* Update status files for PowerPC cores support.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3244 c046a42c-6fe2-441c-8c8c-71466251a162
2007-09-27 01:54:22 +02:00
|
|
|
GEN_MAC_HANDLER(machhwu, 0x0C, 0x00);
|
2007-03-07 09:32:30 +01:00
|
|
|
/* machhwuo - machhwuo. */
|
Great rework and cleanups to ease PowerPC implementations definitions.
* cleanup cpu.h, removing definitions used only in translate.c/translate_init.c
* add new flags to define instructions sets more precisely
* various changes in MMU models definitions
* add definitions for PowerPC 440/460 support (insns and SPRs).
* add definitions for PowerPC 401/403 and 620 input pins model
* Fix definitions for most PowerPC 401, 403, 405, 440, 601, 602, 603 and 7x0
* Preliminary support for PowerPC 74xx (aka G4) without altivec.
* Code provision for other PowerPC support (7x5, 970, ...).
* New SPR and PVR defined, from PowerPC 2.04 specification and other sources
* Misc code bugs, error messages and styles fixes.
* Update status files for PowerPC cores support.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3244 c046a42c-6fe2-441c-8c8c-71466251a162
2007-09-27 01:54:22 +02:00
|
|
|
GEN_MAC_HANDLER(machhwuo, 0x0C, 0x10);
|
2007-03-07 09:32:30 +01:00
|
|
|
/* maclhw - maclhw. */
|
Great rework and cleanups to ease PowerPC implementations definitions.
* cleanup cpu.h, removing definitions used only in translate.c/translate_init.c
* add new flags to define instructions sets more precisely
* various changes in MMU models definitions
* add definitions for PowerPC 440/460 support (insns and SPRs).
* add definitions for PowerPC 401/403 and 620 input pins model
* Fix definitions for most PowerPC 401, 403, 405, 440, 601, 602, 603 and 7x0
* Preliminary support for PowerPC 74xx (aka G4) without altivec.
* Code provision for other PowerPC support (7x5, 970, ...).
* New SPR and PVR defined, from PowerPC 2.04 specification and other sources
* Misc code bugs, error messages and styles fixes.
* Update status files for PowerPC cores support.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3244 c046a42c-6fe2-441c-8c8c-71466251a162
2007-09-27 01:54:22 +02:00
|
|
|
GEN_MAC_HANDLER(maclhw, 0x0C, 0x0D);
|
2007-03-07 09:32:30 +01:00
|
|
|
/* maclhwo - maclhwo. */
|
Great rework and cleanups to ease PowerPC implementations definitions.
* cleanup cpu.h, removing definitions used only in translate.c/translate_init.c
* add new flags to define instructions sets more precisely
* various changes in MMU models definitions
* add definitions for PowerPC 440/460 support (insns and SPRs).
* add definitions for PowerPC 401/403 and 620 input pins model
* Fix definitions for most PowerPC 401, 403, 405, 440, 601, 602, 603 and 7x0
* Preliminary support for PowerPC 74xx (aka G4) without altivec.
* Code provision for other PowerPC support (7x5, 970, ...).
* New SPR and PVR defined, from PowerPC 2.04 specification and other sources
* Misc code bugs, error messages and styles fixes.
* Update status files for PowerPC cores support.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3244 c046a42c-6fe2-441c-8c8c-71466251a162
2007-09-27 01:54:22 +02:00
|
|
|
GEN_MAC_HANDLER(maclhwo, 0x0C, 0x1D);
|
2007-03-07 09:32:30 +01:00
|
|
|
/* maclhws - maclhws. */
|
Great rework and cleanups to ease PowerPC implementations definitions.
* cleanup cpu.h, removing definitions used only in translate.c/translate_init.c
* add new flags to define instructions sets more precisely
* various changes in MMU models definitions
* add definitions for PowerPC 440/460 support (insns and SPRs).
* add definitions for PowerPC 401/403 and 620 input pins model
* Fix definitions for most PowerPC 401, 403, 405, 440, 601, 602, 603 and 7x0
* Preliminary support for PowerPC 74xx (aka G4) without altivec.
* Code provision for other PowerPC support (7x5, 970, ...).
* New SPR and PVR defined, from PowerPC 2.04 specification and other sources
* Misc code bugs, error messages and styles fixes.
* Update status files for PowerPC cores support.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3244 c046a42c-6fe2-441c-8c8c-71466251a162
2007-09-27 01:54:22 +02:00
|
|
|
GEN_MAC_HANDLER(maclhws, 0x0C, 0x0F);
|
2007-03-07 09:32:30 +01:00
|
|
|
/* maclhwso - maclhwso. */
|
Great rework and cleanups to ease PowerPC implementations definitions.
* cleanup cpu.h, removing definitions used only in translate.c/translate_init.c
* add new flags to define instructions sets more precisely
* various changes in MMU models definitions
* add definitions for PowerPC 440/460 support (insns and SPRs).
* add definitions for PowerPC 401/403 and 620 input pins model
* Fix definitions for most PowerPC 401, 403, 405, 440, 601, 602, 603 and 7x0
* Preliminary support for PowerPC 74xx (aka G4) without altivec.
* Code provision for other PowerPC support (7x5, 970, ...).
* New SPR and PVR defined, from PowerPC 2.04 specification and other sources
* Misc code bugs, error messages and styles fixes.
* Update status files for PowerPC cores support.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3244 c046a42c-6fe2-441c-8c8c-71466251a162
2007-09-27 01:54:22 +02:00
|
|
|
GEN_MAC_HANDLER(maclhwso, 0x0C, 0x1F);
|
2007-03-07 09:32:30 +01:00
|
|
|
/* maclhwu - maclhwu. */
|
Great rework and cleanups to ease PowerPC implementations definitions.
* cleanup cpu.h, removing definitions used only in translate.c/translate_init.c
* add new flags to define instructions sets more precisely
* various changes in MMU models definitions
* add definitions for PowerPC 440/460 support (insns and SPRs).
* add definitions for PowerPC 401/403 and 620 input pins model
* Fix definitions for most PowerPC 401, 403, 405, 440, 601, 602, 603 and 7x0
* Preliminary support for PowerPC 74xx (aka G4) without altivec.
* Code provision for other PowerPC support (7x5, 970, ...).
* New SPR and PVR defined, from PowerPC 2.04 specification and other sources
* Misc code bugs, error messages and styles fixes.
* Update status files for PowerPC cores support.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3244 c046a42c-6fe2-441c-8c8c-71466251a162
2007-09-27 01:54:22 +02:00
|
|
|
GEN_MAC_HANDLER(maclhwu, 0x0C, 0x0C);
|
2007-03-07 09:32:30 +01:00
|
|
|
/* maclhwuo - maclhwuo. */
|
Great rework and cleanups to ease PowerPC implementations definitions.
* cleanup cpu.h, removing definitions used only in translate.c/translate_init.c
* add new flags to define instructions sets more precisely
* various changes in MMU models definitions
* add definitions for PowerPC 440/460 support (insns and SPRs).
* add definitions for PowerPC 401/403 and 620 input pins model
* Fix definitions for most PowerPC 401, 403, 405, 440, 601, 602, 603 and 7x0
* Preliminary support for PowerPC 74xx (aka G4) without altivec.
* Code provision for other PowerPC support (7x5, 970, ...).
* New SPR and PVR defined, from PowerPC 2.04 specification and other sources
* Misc code bugs, error messages and styles fixes.
* Update status files for PowerPC cores support.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3244 c046a42c-6fe2-441c-8c8c-71466251a162
2007-09-27 01:54:22 +02:00
|
|
|
GEN_MAC_HANDLER(maclhwuo, 0x0C, 0x1C);
|
2007-03-07 09:32:30 +01:00
|
|
|
/* maclhwsu - maclhwsu. */
|
Great rework and cleanups to ease PowerPC implementations definitions.
* cleanup cpu.h, removing definitions used only in translate.c/translate_init.c
* add new flags to define instructions sets more precisely
* various changes in MMU models definitions
* add definitions for PowerPC 440/460 support (insns and SPRs).
* add definitions for PowerPC 401/403 and 620 input pins model
* Fix definitions for most PowerPC 401, 403, 405, 440, 601, 602, 603 and 7x0
* Preliminary support for PowerPC 74xx (aka G4) without altivec.
* Code provision for other PowerPC support (7x5, 970, ...).
* New SPR and PVR defined, from PowerPC 2.04 specification and other sources
* Misc code bugs, error messages and styles fixes.
* Update status files for PowerPC cores support.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3244 c046a42c-6fe2-441c-8c8c-71466251a162
2007-09-27 01:54:22 +02:00
|
|
|
GEN_MAC_HANDLER(maclhwsu, 0x0C, 0x0E);
|
2007-03-07 09:32:30 +01:00
|
|
|
/* maclhwsuo - maclhwsuo. */
|
Great rework and cleanups to ease PowerPC implementations definitions.
* cleanup cpu.h, removing definitions used only in translate.c/translate_init.c
* add new flags to define instructions sets more precisely
* various changes in MMU models definitions
* add definitions for PowerPC 440/460 support (insns and SPRs).
* add definitions for PowerPC 401/403 and 620 input pins model
* Fix definitions for most PowerPC 401, 403, 405, 440, 601, 602, 603 and 7x0
* Preliminary support for PowerPC 74xx (aka G4) without altivec.
* Code provision for other PowerPC support (7x5, 970, ...).
* New SPR and PVR defined, from PowerPC 2.04 specification and other sources
* Misc code bugs, error messages and styles fixes.
* Update status files for PowerPC cores support.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3244 c046a42c-6fe2-441c-8c8c-71466251a162
2007-09-27 01:54:22 +02:00
|
|
|
GEN_MAC_HANDLER(maclhwsuo, 0x0C, 0x1E);
|
2007-03-07 09:32:30 +01:00
|
|
|
/* nmacchw - nmacchw. */
|
Great rework and cleanups to ease PowerPC implementations definitions.
* cleanup cpu.h, removing definitions used only in translate.c/translate_init.c
* add new flags to define instructions sets more precisely
* various changes in MMU models definitions
* add definitions for PowerPC 440/460 support (insns and SPRs).
* add definitions for PowerPC 401/403 and 620 input pins model
* Fix definitions for most PowerPC 401, 403, 405, 440, 601, 602, 603 and 7x0
* Preliminary support for PowerPC 74xx (aka G4) without altivec.
* Code provision for other PowerPC support (7x5, 970, ...).
* New SPR and PVR defined, from PowerPC 2.04 specification and other sources
* Misc code bugs, error messages and styles fixes.
* Update status files for PowerPC cores support.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3244 c046a42c-6fe2-441c-8c8c-71466251a162
2007-09-27 01:54:22 +02:00
|
|
|
GEN_MAC_HANDLER(nmacchw, 0x0E, 0x05);
|
2007-03-07 09:32:30 +01:00
|
|
|
/* nmacchwo - nmacchwo. */
|
Great rework and cleanups to ease PowerPC implementations definitions.
* cleanup cpu.h, removing definitions used only in translate.c/translate_init.c
* add new flags to define instructions sets more precisely
* various changes in MMU models definitions
* add definitions for PowerPC 440/460 support (insns and SPRs).
* add definitions for PowerPC 401/403 and 620 input pins model
* Fix definitions for most PowerPC 401, 403, 405, 440, 601, 602, 603 and 7x0
* Preliminary support for PowerPC 74xx (aka G4) without altivec.
* Code provision for other PowerPC support (7x5, 970, ...).
* New SPR and PVR defined, from PowerPC 2.04 specification and other sources
* Misc code bugs, error messages and styles fixes.
* Update status files for PowerPC cores support.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3244 c046a42c-6fe2-441c-8c8c-71466251a162
2007-09-27 01:54:22 +02:00
|
|
|
GEN_MAC_HANDLER(nmacchwo, 0x0E, 0x15);
|
2007-03-07 09:32:30 +01:00
|
|
|
/* nmacchws - nmacchws. */
|
Great rework and cleanups to ease PowerPC implementations definitions.
* cleanup cpu.h, removing definitions used only in translate.c/translate_init.c
* add new flags to define instructions sets more precisely
* various changes in MMU models definitions
* add definitions for PowerPC 440/460 support (insns and SPRs).
* add definitions for PowerPC 401/403 and 620 input pins model
* Fix definitions for most PowerPC 401, 403, 405, 440, 601, 602, 603 and 7x0
* Preliminary support for PowerPC 74xx (aka G4) without altivec.
* Code provision for other PowerPC support (7x5, 970, ...).
* New SPR and PVR defined, from PowerPC 2.04 specification and other sources
* Misc code bugs, error messages and styles fixes.
* Update status files for PowerPC cores support.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3244 c046a42c-6fe2-441c-8c8c-71466251a162
2007-09-27 01:54:22 +02:00
|
|
|
GEN_MAC_HANDLER(nmacchws, 0x0E, 0x07);
|
2007-03-07 09:32:30 +01:00
|
|
|
/* nmacchwso - nmacchwso. */
|
Great rework and cleanups to ease PowerPC implementations definitions.
* cleanup cpu.h, removing definitions used only in translate.c/translate_init.c
* add new flags to define instructions sets more precisely
* various changes in MMU models definitions
* add definitions for PowerPC 440/460 support (insns and SPRs).
* add definitions for PowerPC 401/403 and 620 input pins model
* Fix definitions for most PowerPC 401, 403, 405, 440, 601, 602, 603 and 7x0
* Preliminary support for PowerPC 74xx (aka G4) without altivec.
* Code provision for other PowerPC support (7x5, 970, ...).
* New SPR and PVR defined, from PowerPC 2.04 specification and other sources
* Misc code bugs, error messages and styles fixes.
* Update status files for PowerPC cores support.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3244 c046a42c-6fe2-441c-8c8c-71466251a162
2007-09-27 01:54:22 +02:00
|
|
|
GEN_MAC_HANDLER(nmacchwso, 0x0E, 0x17);
|
2007-03-07 09:32:30 +01:00
|
|
|
/* nmachhw - nmachhw. */
|
Great rework and cleanups to ease PowerPC implementations definitions.
* cleanup cpu.h, removing definitions used only in translate.c/translate_init.c
* add new flags to define instructions sets more precisely
* various changes in MMU models definitions
* add definitions for PowerPC 440/460 support (insns and SPRs).
* add definitions for PowerPC 401/403 and 620 input pins model
* Fix definitions for most PowerPC 401, 403, 405, 440, 601, 602, 603 and 7x0
* Preliminary support for PowerPC 74xx (aka G4) without altivec.
* Code provision for other PowerPC support (7x5, 970, ...).
* New SPR and PVR defined, from PowerPC 2.04 specification and other sources
* Misc code bugs, error messages and styles fixes.
* Update status files for PowerPC cores support.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3244 c046a42c-6fe2-441c-8c8c-71466251a162
2007-09-27 01:54:22 +02:00
|
|
|
GEN_MAC_HANDLER(nmachhw, 0x0E, 0x01);
|
2007-03-07 09:32:30 +01:00
|
|
|
/* nmachhwo - nmachhwo. */
|
Great rework and cleanups to ease PowerPC implementations definitions.
* cleanup cpu.h, removing definitions used only in translate.c/translate_init.c
* add new flags to define instructions sets more precisely
* various changes in MMU models definitions
* add definitions for PowerPC 440/460 support (insns and SPRs).
* add definitions for PowerPC 401/403 and 620 input pins model
* Fix definitions for most PowerPC 401, 403, 405, 440, 601, 602, 603 and 7x0
* Preliminary support for PowerPC 74xx (aka G4) without altivec.
* Code provision for other PowerPC support (7x5, 970, ...).
* New SPR and PVR defined, from PowerPC 2.04 specification and other sources
* Misc code bugs, error messages and styles fixes.
* Update status files for PowerPC cores support.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3244 c046a42c-6fe2-441c-8c8c-71466251a162
2007-09-27 01:54:22 +02:00
|
|
|
GEN_MAC_HANDLER(nmachhwo, 0x0E, 0x11);
|
2007-03-07 09:32:30 +01:00
|
|
|
/* nmachhws - nmachhws. */
|
Great rework and cleanups to ease PowerPC implementations definitions.
* cleanup cpu.h, removing definitions used only in translate.c/translate_init.c
* add new flags to define instructions sets more precisely
* various changes in MMU models definitions
* add definitions for PowerPC 440/460 support (insns and SPRs).
* add definitions for PowerPC 401/403 and 620 input pins model
* Fix definitions for most PowerPC 401, 403, 405, 440, 601, 602, 603 and 7x0
* Preliminary support for PowerPC 74xx (aka G4) without altivec.
* Code provision for other PowerPC support (7x5, 970, ...).
* New SPR and PVR defined, from PowerPC 2.04 specification and other sources
* Misc code bugs, error messages and styles fixes.
* Update status files for PowerPC cores support.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3244 c046a42c-6fe2-441c-8c8c-71466251a162
2007-09-27 01:54:22 +02:00
|
|
|
GEN_MAC_HANDLER(nmachhws, 0x0E, 0x03);
|
2007-03-07 09:32:30 +01:00
|
|
|
/* nmachhwso - nmachhwso. */
|
Great rework and cleanups to ease PowerPC implementations definitions.
* cleanup cpu.h, removing definitions used only in translate.c/translate_init.c
* add new flags to define instructions sets more precisely
* various changes in MMU models definitions
* add definitions for PowerPC 440/460 support (insns and SPRs).
* add definitions for PowerPC 401/403 and 620 input pins model
* Fix definitions for most PowerPC 401, 403, 405, 440, 601, 602, 603 and 7x0
* Preliminary support for PowerPC 74xx (aka G4) without altivec.
* Code provision for other PowerPC support (7x5, 970, ...).
* New SPR and PVR defined, from PowerPC 2.04 specification and other sources
* Misc code bugs, error messages and styles fixes.
* Update status files for PowerPC cores support.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3244 c046a42c-6fe2-441c-8c8c-71466251a162
2007-09-27 01:54:22 +02:00
|
|
|
GEN_MAC_HANDLER(nmachhwso, 0x0E, 0x13);
|
2007-03-07 09:32:30 +01:00
|
|
|
/* nmaclhw - nmaclhw. */
|
Great rework and cleanups to ease PowerPC implementations definitions.
* cleanup cpu.h, removing definitions used only in translate.c/translate_init.c
* add new flags to define instructions sets more precisely
* various changes in MMU models definitions
* add definitions for PowerPC 440/460 support (insns and SPRs).
* add definitions for PowerPC 401/403 and 620 input pins model
* Fix definitions for most PowerPC 401, 403, 405, 440, 601, 602, 603 and 7x0
* Preliminary support for PowerPC 74xx (aka G4) without altivec.
* Code provision for other PowerPC support (7x5, 970, ...).
* New SPR and PVR defined, from PowerPC 2.04 specification and other sources
* Misc code bugs, error messages and styles fixes.
* Update status files for PowerPC cores support.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3244 c046a42c-6fe2-441c-8c8c-71466251a162
2007-09-27 01:54:22 +02:00
|
|
|
GEN_MAC_HANDLER(nmaclhw, 0x0E, 0x0D);
|
2007-03-07 09:32:30 +01:00
|
|
|
/* nmaclhwo - nmaclhwo. */
|
Great rework and cleanups to ease PowerPC implementations definitions.
* cleanup cpu.h, removing definitions used only in translate.c/translate_init.c
* add new flags to define instructions sets more precisely
* various changes in MMU models definitions
* add definitions for PowerPC 440/460 support (insns and SPRs).
* add definitions for PowerPC 401/403 and 620 input pins model
* Fix definitions for most PowerPC 401, 403, 405, 440, 601, 602, 603 and 7x0
* Preliminary support for PowerPC 74xx (aka G4) without altivec.
* Code provision for other PowerPC support (7x5, 970, ...).
* New SPR and PVR defined, from PowerPC 2.04 specification and other sources
* Misc code bugs, error messages and styles fixes.
* Update status files for PowerPC cores support.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3244 c046a42c-6fe2-441c-8c8c-71466251a162
2007-09-27 01:54:22 +02:00
|
|
|
GEN_MAC_HANDLER(nmaclhwo, 0x0E, 0x1D);
|
2007-03-07 09:32:30 +01:00
|
|
|
/* nmaclhws - nmaclhws. */
|
Great rework and cleanups to ease PowerPC implementations definitions.
* cleanup cpu.h, removing definitions used only in translate.c/translate_init.c
* add new flags to define instructions sets more precisely
* various changes in MMU models definitions
* add definitions for PowerPC 440/460 support (insns and SPRs).
* add definitions for PowerPC 401/403 and 620 input pins model
* Fix definitions for most PowerPC 401, 403, 405, 440, 601, 602, 603 and 7x0
* Preliminary support for PowerPC 74xx (aka G4) without altivec.
* Code provision for other PowerPC support (7x5, 970, ...).
* New SPR and PVR defined, from PowerPC 2.04 specification and other sources
* Misc code bugs, error messages and styles fixes.
* Update status files for PowerPC cores support.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3244 c046a42c-6fe2-441c-8c8c-71466251a162
2007-09-27 01:54:22 +02:00
|
|
|
GEN_MAC_HANDLER(nmaclhws, 0x0E, 0x0F);
|
2007-03-07 09:32:30 +01:00
|
|
|
/* nmaclhwso - nmaclhwso. */
|
Great rework and cleanups to ease PowerPC implementations definitions.
* cleanup cpu.h, removing definitions used only in translate.c/translate_init.c
* add new flags to define instructions sets more precisely
* various changes in MMU models definitions
* add definitions for PowerPC 440/460 support (insns and SPRs).
* add definitions for PowerPC 401/403 and 620 input pins model
* Fix definitions for most PowerPC 401, 403, 405, 440, 601, 602, 603 and 7x0
* Preliminary support for PowerPC 74xx (aka G4) without altivec.
* Code provision for other PowerPC support (7x5, 970, ...).
* New SPR and PVR defined, from PowerPC 2.04 specification and other sources
* Misc code bugs, error messages and styles fixes.
* Update status files for PowerPC cores support.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3244 c046a42c-6fe2-441c-8c8c-71466251a162
2007-09-27 01:54:22 +02:00
|
|
|
GEN_MAC_HANDLER(nmaclhwso, 0x0E, 0x1F);
|
2007-03-07 09:32:30 +01:00
|
|
|
|
|
|
|
/* mulchw - mulchw. */
|
Great rework and cleanups to ease PowerPC implementations definitions.
* cleanup cpu.h, removing definitions used only in translate.c/translate_init.c
* add new flags to define instructions sets more precisely
* various changes in MMU models definitions
* add definitions for PowerPC 440/460 support (insns and SPRs).
* add definitions for PowerPC 401/403 and 620 input pins model
* Fix definitions for most PowerPC 401, 403, 405, 440, 601, 602, 603 and 7x0
* Preliminary support for PowerPC 74xx (aka G4) without altivec.
* Code provision for other PowerPC support (7x5, 970, ...).
* New SPR and PVR defined, from PowerPC 2.04 specification and other sources
* Misc code bugs, error messages and styles fixes.
* Update status files for PowerPC cores support.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3244 c046a42c-6fe2-441c-8c8c-71466251a162
2007-09-27 01:54:22 +02:00
|
|
|
GEN_MAC_HANDLER(mulchw, 0x08, 0x05);
|
2007-03-07 09:32:30 +01:00
|
|
|
/* mulchwu - mulchwu. */
|
Great rework and cleanups to ease PowerPC implementations definitions.
* cleanup cpu.h, removing definitions used only in translate.c/translate_init.c
* add new flags to define instructions sets more precisely
* various changes in MMU models definitions
* add definitions for PowerPC 440/460 support (insns and SPRs).
* add definitions for PowerPC 401/403 and 620 input pins model
* Fix definitions for most PowerPC 401, 403, 405, 440, 601, 602, 603 and 7x0
* Preliminary support for PowerPC 74xx (aka G4) without altivec.
* Code provision for other PowerPC support (7x5, 970, ...).
* New SPR and PVR defined, from PowerPC 2.04 specification and other sources
* Misc code bugs, error messages and styles fixes.
* Update status files for PowerPC cores support.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3244 c046a42c-6fe2-441c-8c8c-71466251a162
2007-09-27 01:54:22 +02:00
|
|
|
GEN_MAC_HANDLER(mulchwu, 0x08, 0x04);
|
2007-03-07 09:32:30 +01:00
|
|
|
/* mulhhw - mulhhw. */
|
Great rework and cleanups to ease PowerPC implementations definitions.
* cleanup cpu.h, removing definitions used only in translate.c/translate_init.c
* add new flags to define instructions sets more precisely
* various changes in MMU models definitions
* add definitions for PowerPC 440/460 support (insns and SPRs).
* add definitions for PowerPC 401/403 and 620 input pins model
* Fix definitions for most PowerPC 401, 403, 405, 440, 601, 602, 603 and 7x0
* Preliminary support for PowerPC 74xx (aka G4) without altivec.
* Code provision for other PowerPC support (7x5, 970, ...).
* New SPR and PVR defined, from PowerPC 2.04 specification and other sources
* Misc code bugs, error messages and styles fixes.
* Update status files for PowerPC cores support.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3244 c046a42c-6fe2-441c-8c8c-71466251a162
2007-09-27 01:54:22 +02:00
|
|
|
GEN_MAC_HANDLER(mulhhw, 0x08, 0x01);
|
2007-03-07 09:32:30 +01:00
|
|
|
/* mulhhwu - mulhhwu. */
|
Great rework and cleanups to ease PowerPC implementations definitions.
* cleanup cpu.h, removing definitions used only in translate.c/translate_init.c
* add new flags to define instructions sets more precisely
* various changes in MMU models definitions
* add definitions for PowerPC 440/460 support (insns and SPRs).
* add definitions for PowerPC 401/403 and 620 input pins model
* Fix definitions for most PowerPC 401, 403, 405, 440, 601, 602, 603 and 7x0
* Preliminary support for PowerPC 74xx (aka G4) without altivec.
* Code provision for other PowerPC support (7x5, 970, ...).
* New SPR and PVR defined, from PowerPC 2.04 specification and other sources
* Misc code bugs, error messages and styles fixes.
* Update status files for PowerPC cores support.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3244 c046a42c-6fe2-441c-8c8c-71466251a162
2007-09-27 01:54:22 +02:00
|
|
|
GEN_MAC_HANDLER(mulhhwu, 0x08, 0x00);
|
2007-03-07 09:32:30 +01:00
|
|
|
/* mullhw - mullhw. */
|
Great rework and cleanups to ease PowerPC implementations definitions.
* cleanup cpu.h, removing definitions used only in translate.c/translate_init.c
* add new flags to define instructions sets more precisely
* various changes in MMU models definitions
* add definitions for PowerPC 440/460 support (insns and SPRs).
* add definitions for PowerPC 401/403 and 620 input pins model
* Fix definitions for most PowerPC 401, 403, 405, 440, 601, 602, 603 and 7x0
* Preliminary support for PowerPC 74xx (aka G4) without altivec.
* Code provision for other PowerPC support (7x5, 970, ...).
* New SPR and PVR defined, from PowerPC 2.04 specification and other sources
* Misc code bugs, error messages and styles fixes.
* Update status files for PowerPC cores support.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3244 c046a42c-6fe2-441c-8c8c-71466251a162
2007-09-27 01:54:22 +02:00
|
|
|
GEN_MAC_HANDLER(mullhw, 0x08, 0x0D);
|
2007-03-07 09:32:30 +01:00
|
|
|
/* mullhwu - mullhwu. */
|
Great rework and cleanups to ease PowerPC implementations definitions.
* cleanup cpu.h, removing definitions used only in translate.c/translate_init.c
* add new flags to define instructions sets more precisely
* various changes in MMU models definitions
* add definitions for PowerPC 440/460 support (insns and SPRs).
* add definitions for PowerPC 401/403 and 620 input pins model
* Fix definitions for most PowerPC 401, 403, 405, 440, 601, 602, 603 and 7x0
* Preliminary support for PowerPC 74xx (aka G4) without altivec.
* Code provision for other PowerPC support (7x5, 970, ...).
* New SPR and PVR defined, from PowerPC 2.04 specification and other sources
* Misc code bugs, error messages and styles fixes.
* Update status files for PowerPC cores support.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3244 c046a42c-6fe2-441c-8c8c-71466251a162
2007-09-27 01:54:22 +02:00
|
|
|
GEN_MAC_HANDLER(mullhwu, 0x08, 0x0C);
|
2007-03-07 09:32:30 +01:00
|
|
|
|
|
|
|
/* mfdcr */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_mfdcr(DisasContext *ctx)
|
2007-03-07 09:32:30 +01:00
|
|
|
{
|
|
|
|
#if defined(CONFIG_USER_ONLY)
|
2008-12-11 23:42:14 +01:00
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG);
|
2007-03-07 09:32:30 +01:00
|
|
|
#else
|
2008-12-06 17:37:18 +01:00
|
|
|
TCGv dcrn;
|
2014-09-15 17:03:28 +02:00
|
|
|
if (unlikely(ctx->pr)) {
|
2008-12-11 23:42:14 +01:00
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG);
|
2007-03-07 09:32:30 +01:00
|
|
|
return;
|
|
|
|
}
|
2008-12-06 17:37:18 +01:00
|
|
|
/* NIP cannot be restored if the memory exception comes from an helper */
|
|
|
|
gen_update_nip(ctx, ctx->nip - 4);
|
|
|
|
dcrn = tcg_const_tl(SPR(ctx->opcode));
|
2012-05-30 06:23:36 +02:00
|
|
|
gen_helper_load_dcr(cpu_gpr[rD(ctx->opcode)], cpu_env, dcrn);
|
2008-12-06 17:37:18 +01:00
|
|
|
tcg_temp_free(dcrn);
|
2007-03-07 09:32:30 +01:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
/* mtdcr */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_mtdcr(DisasContext *ctx)
|
2007-03-07 09:32:30 +01:00
|
|
|
{
|
|
|
|
#if defined(CONFIG_USER_ONLY)
|
2008-12-11 23:42:14 +01:00
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG);
|
2007-03-07 09:32:30 +01:00
|
|
|
#else
|
2008-12-06 17:37:18 +01:00
|
|
|
TCGv dcrn;
|
2014-09-15 17:03:28 +02:00
|
|
|
if (unlikely(ctx->pr)) {
|
2008-12-11 23:42:14 +01:00
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG);
|
2007-03-07 09:32:30 +01:00
|
|
|
return;
|
|
|
|
}
|
2008-12-06 17:37:18 +01:00
|
|
|
/* NIP cannot be restored if the memory exception comes from an helper */
|
|
|
|
gen_update_nip(ctx, ctx->nip - 4);
|
|
|
|
dcrn = tcg_const_tl(SPR(ctx->opcode));
|
2012-05-30 06:23:36 +02:00
|
|
|
gen_helper_store_dcr(cpu_env, dcrn, cpu_gpr[rS(ctx->opcode)]);
|
2008-12-06 17:37:18 +01:00
|
|
|
tcg_temp_free(dcrn);
|
2007-03-30 12:22:46 +02:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
/* mfdcrx */
|
2007-09-21 07:50:37 +02:00
|
|
|
/* XXX: not implemented on 440 ? */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_mfdcrx(DisasContext *ctx)
|
2007-03-30 12:22:46 +02:00
|
|
|
{
|
|
|
|
#if defined(CONFIG_USER_ONLY)
|
2008-12-11 23:42:14 +01:00
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG);
|
2007-03-30 12:22:46 +02:00
|
|
|
#else
|
2014-09-15 17:03:28 +02:00
|
|
|
if (unlikely(ctx->pr)) {
|
2008-12-11 23:42:14 +01:00
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG);
|
2007-03-30 12:22:46 +02:00
|
|
|
return;
|
|
|
|
}
|
2008-12-06 17:37:18 +01:00
|
|
|
/* NIP cannot be restored if the memory exception comes from an helper */
|
|
|
|
gen_update_nip(ctx, ctx->nip - 4);
|
2012-05-30 06:23:36 +02:00
|
|
|
gen_helper_load_dcr(cpu_gpr[rD(ctx->opcode)], cpu_env,
|
|
|
|
cpu_gpr[rA(ctx->opcode)]);
|
Great rework and cleanups to ease PowerPC implementations definitions.
* cleanup cpu.h, removing definitions used only in translate.c/translate_init.c
* add new flags to define instructions sets more precisely
* various changes in MMU models definitions
* add definitions for PowerPC 440/460 support (insns and SPRs).
* add definitions for PowerPC 401/403 and 620 input pins model
* Fix definitions for most PowerPC 401, 403, 405, 440, 601, 602, 603 and 7x0
* Preliminary support for PowerPC 74xx (aka G4) without altivec.
* Code provision for other PowerPC support (7x5, 970, ...).
* New SPR and PVR defined, from PowerPC 2.04 specification and other sources
* Misc code bugs, error messages and styles fixes.
* Update status files for PowerPC cores support.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3244 c046a42c-6fe2-441c-8c8c-71466251a162
2007-09-27 01:54:22 +02:00
|
|
|
/* Note: Rc update flag set leads to undefined state of Rc0 */
|
2007-03-30 12:22:46 +02:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
/* mtdcrx */
|
2007-09-21 07:50:37 +02:00
|
|
|
/* XXX: not implemented on 440 ? */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_mtdcrx(DisasContext *ctx)
|
2007-03-30 12:22:46 +02:00
|
|
|
{
|
|
|
|
#if defined(CONFIG_USER_ONLY)
|
2008-12-11 23:42:14 +01:00
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG);
|
2007-03-30 12:22:46 +02:00
|
|
|
#else
|
2014-09-15 17:03:28 +02:00
|
|
|
if (unlikely(ctx->pr)) {
|
2008-12-11 23:42:14 +01:00
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG);
|
2007-03-30 12:22:46 +02:00
|
|
|
return;
|
|
|
|
}
|
2008-12-06 17:37:18 +01:00
|
|
|
/* NIP cannot be restored if the memory exception comes from an helper */
|
|
|
|
gen_update_nip(ctx, ctx->nip - 4);
|
2012-05-30 06:23:36 +02:00
|
|
|
gen_helper_store_dcr(cpu_env, cpu_gpr[rA(ctx->opcode)],
|
|
|
|
cpu_gpr[rS(ctx->opcode)]);
|
Great rework and cleanups to ease PowerPC implementations definitions.
* cleanup cpu.h, removing definitions used only in translate.c/translate_init.c
* add new flags to define instructions sets more precisely
* various changes in MMU models definitions
* add definitions for PowerPC 440/460 support (insns and SPRs).
* add definitions for PowerPC 401/403 and 620 input pins model
* Fix definitions for most PowerPC 401, 403, 405, 440, 601, 602, 603 and 7x0
* Preliminary support for PowerPC 74xx (aka G4) without altivec.
* Code provision for other PowerPC support (7x5, 970, ...).
* New SPR and PVR defined, from PowerPC 2.04 specification and other sources
* Misc code bugs, error messages and styles fixes.
* Update status files for PowerPC cores support.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3244 c046a42c-6fe2-441c-8c8c-71466251a162
2007-09-27 01:54:22 +02:00
|
|
|
/* Note: Rc update flag set leads to undefined state of Rc0 */
|
2007-03-07 09:32:30 +01:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
Great rework and cleanups to ease PowerPC implementations definitions.
* cleanup cpu.h, removing definitions used only in translate.c/translate_init.c
* add new flags to define instructions sets more precisely
* various changes in MMU models definitions
* add definitions for PowerPC 440/460 support (insns and SPRs).
* add definitions for PowerPC 401/403 and 620 input pins model
* Fix definitions for most PowerPC 401, 403, 405, 440, 601, 602, 603 and 7x0
* Preliminary support for PowerPC 74xx (aka G4) without altivec.
* Code provision for other PowerPC support (7x5, 970, ...).
* New SPR and PVR defined, from PowerPC 2.04 specification and other sources
* Misc code bugs, error messages and styles fixes.
* Update status files for PowerPC cores support.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3244 c046a42c-6fe2-441c-8c8c-71466251a162
2007-09-27 01:54:22 +02:00
|
|
|
/* mfdcrux (PPC 460) : user-mode access to DCR */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_mfdcrux(DisasContext *ctx)
|
Great rework and cleanups to ease PowerPC implementations definitions.
* cleanup cpu.h, removing definitions used only in translate.c/translate_init.c
* add new flags to define instructions sets more precisely
* various changes in MMU models definitions
* add definitions for PowerPC 440/460 support (insns and SPRs).
* add definitions for PowerPC 401/403 and 620 input pins model
* Fix definitions for most PowerPC 401, 403, 405, 440, 601, 602, 603 and 7x0
* Preliminary support for PowerPC 74xx (aka G4) without altivec.
* Code provision for other PowerPC support (7x5, 970, ...).
* New SPR and PVR defined, from PowerPC 2.04 specification and other sources
* Misc code bugs, error messages and styles fixes.
* Update status files for PowerPC cores support.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3244 c046a42c-6fe2-441c-8c8c-71466251a162
2007-09-27 01:54:22 +02:00
|
|
|
{
|
2008-12-06 17:37:18 +01:00
|
|
|
/* NIP cannot be restored if the memory exception comes from an helper */
|
|
|
|
gen_update_nip(ctx, ctx->nip - 4);
|
2012-05-30 06:23:36 +02:00
|
|
|
gen_helper_load_dcr(cpu_gpr[rD(ctx->opcode)], cpu_env,
|
|
|
|
cpu_gpr[rA(ctx->opcode)]);
|
Great rework and cleanups to ease PowerPC implementations definitions.
* cleanup cpu.h, removing definitions used only in translate.c/translate_init.c
* add new flags to define instructions sets more precisely
* various changes in MMU models definitions
* add definitions for PowerPC 440/460 support (insns and SPRs).
* add definitions for PowerPC 401/403 and 620 input pins model
* Fix definitions for most PowerPC 401, 403, 405, 440, 601, 602, 603 and 7x0
* Preliminary support for PowerPC 74xx (aka G4) without altivec.
* Code provision for other PowerPC support (7x5, 970, ...).
* New SPR and PVR defined, from PowerPC 2.04 specification and other sources
* Misc code bugs, error messages and styles fixes.
* Update status files for PowerPC cores support.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3244 c046a42c-6fe2-441c-8c8c-71466251a162
2007-09-27 01:54:22 +02:00
|
|
|
/* Note: Rc update flag set leads to undefined state of Rc0 */
|
|
|
|
}
|
|
|
|
|
|
|
|
/* mtdcrux (PPC 460) : user-mode access to DCR */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_mtdcrux(DisasContext *ctx)
|
Great rework and cleanups to ease PowerPC implementations definitions.
* cleanup cpu.h, removing definitions used only in translate.c/translate_init.c
* add new flags to define instructions sets more precisely
* various changes in MMU models definitions
* add definitions for PowerPC 440/460 support (insns and SPRs).
* add definitions for PowerPC 401/403 and 620 input pins model
* Fix definitions for most PowerPC 401, 403, 405, 440, 601, 602, 603 and 7x0
* Preliminary support for PowerPC 74xx (aka G4) without altivec.
* Code provision for other PowerPC support (7x5, 970, ...).
* New SPR and PVR defined, from PowerPC 2.04 specification and other sources
* Misc code bugs, error messages and styles fixes.
* Update status files for PowerPC cores support.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3244 c046a42c-6fe2-441c-8c8c-71466251a162
2007-09-27 01:54:22 +02:00
|
|
|
{
|
2008-12-06 17:37:18 +01:00
|
|
|
/* NIP cannot be restored if the memory exception comes from an helper */
|
|
|
|
gen_update_nip(ctx, ctx->nip - 4);
|
2012-06-24 06:04:17 +02:00
|
|
|
gen_helper_store_dcr(cpu_env, cpu_gpr[rA(ctx->opcode)],
|
2012-05-30 06:23:36 +02:00
|
|
|
cpu_gpr[rS(ctx->opcode)]);
|
Great rework and cleanups to ease PowerPC implementations definitions.
* cleanup cpu.h, removing definitions used only in translate.c/translate_init.c
* add new flags to define instructions sets more precisely
* various changes in MMU models definitions
* add definitions for PowerPC 440/460 support (insns and SPRs).
* add definitions for PowerPC 401/403 and 620 input pins model
* Fix definitions for most PowerPC 401, 403, 405, 440, 601, 602, 603 and 7x0
* Preliminary support for PowerPC 74xx (aka G4) without altivec.
* Code provision for other PowerPC support (7x5, 970, ...).
* New SPR and PVR defined, from PowerPC 2.04 specification and other sources
* Misc code bugs, error messages and styles fixes.
* Update status files for PowerPC cores support.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3244 c046a42c-6fe2-441c-8c8c-71466251a162
2007-09-27 01:54:22 +02:00
|
|
|
/* Note: Rc update flag set leads to undefined state of Rc0 */
|
|
|
|
}
|
|
|
|
|
2007-03-07 09:32:30 +01:00
|
|
|
/* dccci */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_dccci(DisasContext *ctx)
|
2007-03-07 09:32:30 +01:00
|
|
|
{
|
|
|
|
#if defined(CONFIG_USER_ONLY)
|
2008-12-11 23:42:14 +01:00
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);
|
2007-03-07 09:32:30 +01:00
|
|
|
#else
|
2014-09-15 17:03:28 +02:00
|
|
|
if (unlikely(ctx->pr)) {
|
2008-12-11 23:42:14 +01:00
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);
|
2007-03-07 09:32:30 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
/* interpreted as no-op */
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
/* dcread */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_dcread(DisasContext *ctx)
|
2007-03-07 09:32:30 +01:00
|
|
|
{
|
|
|
|
#if defined(CONFIG_USER_ONLY)
|
2008-12-11 23:42:14 +01:00
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);
|
2007-03-07 09:32:30 +01:00
|
|
|
#else
|
2008-10-15 19:00:37 +02:00
|
|
|
TCGv EA, val;
|
2014-09-15 17:03:28 +02:00
|
|
|
if (unlikely(ctx->pr)) {
|
2008-12-11 23:42:14 +01:00
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);
|
2007-03-07 09:32:30 +01:00
|
|
|
return;
|
|
|
|
}
|
2008-12-08 19:11:21 +01:00
|
|
|
gen_set_access_type(ctx, ACCESS_CACHE);
|
2008-11-17 15:43:54 +01:00
|
|
|
EA = tcg_temp_new();
|
2008-12-08 19:11:21 +01:00
|
|
|
gen_addr_reg_index(ctx, EA);
|
2008-11-17 15:43:54 +01:00
|
|
|
val = tcg_temp_new();
|
2008-12-08 19:11:21 +01:00
|
|
|
gen_qemu_ld32u(ctx, val, EA);
|
2008-10-15 19:00:37 +02:00
|
|
|
tcg_temp_free(val);
|
|
|
|
tcg_gen_mov_tl(cpu_gpr[rD(ctx->opcode)], EA);
|
|
|
|
tcg_temp_free(EA);
|
2007-03-07 09:32:30 +01:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
/* icbt */
|
2009-06-17 17:22:14 +02:00
|
|
|
static void gen_icbt_40x(DisasContext *ctx)
|
2007-03-07 09:32:30 +01:00
|
|
|
{
|
|
|
|
/* interpreted as no-op */
|
|
|
|
/* XXX: specification say this is treated as a load by the MMU
|
|
|
|
* but does not generate any exception
|
|
|
|
*/
|
|
|
|
}
|
|
|
|
|
|
|
|
/* iccci */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_iccci(DisasContext *ctx)
|
2007-03-07 09:32:30 +01:00
|
|
|
{
|
|
|
|
#if defined(CONFIG_USER_ONLY)
|
2008-12-11 23:42:14 +01:00
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);
|
2007-03-07 09:32:30 +01:00
|
|
|
#else
|
2014-09-15 17:03:28 +02:00
|
|
|
if (unlikely(ctx->pr)) {
|
2008-12-11 23:42:14 +01:00
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);
|
2007-03-07 09:32:30 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
/* interpreted as no-op */
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
/* icread */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_icread(DisasContext *ctx)
|
2007-03-07 09:32:30 +01:00
|
|
|
{
|
|
|
|
#if defined(CONFIG_USER_ONLY)
|
2008-12-11 23:42:14 +01:00
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);
|
2007-03-07 09:32:30 +01:00
|
|
|
#else
|
2014-09-15 17:03:28 +02:00
|
|
|
if (unlikely(ctx->pr)) {
|
2008-12-11 23:42:14 +01:00
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);
|
2007-03-07 09:32:30 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
/* interpreted as no-op */
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2014-09-15 17:03:28 +02:00
|
|
|
/* rfci (supervisor only) */
|
2009-06-17 17:22:14 +02:00
|
|
|
static void gen_rfci_40x(DisasContext *ctx)
|
2007-03-30 12:22:46 +02:00
|
|
|
{
|
|
|
|
#if defined(CONFIG_USER_ONLY)
|
2008-12-11 23:42:14 +01:00
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);
|
2007-03-30 12:22:46 +02:00
|
|
|
#else
|
2014-09-15 17:03:28 +02:00
|
|
|
if (unlikely(ctx->pr)) {
|
2008-12-11 23:42:14 +01:00
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);
|
2007-03-30 12:22:46 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
/* Restore CPU state */
|
2012-05-30 06:23:23 +02:00
|
|
|
gen_helper_40x_rfci(cpu_env);
|
2008-12-11 23:42:14 +01:00
|
|
|
gen_sync_exception(ctx);
|
2007-03-30 12:22:46 +02:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_rfci(DisasContext *ctx)
|
2007-03-30 12:22:46 +02:00
|
|
|
{
|
|
|
|
#if defined(CONFIG_USER_ONLY)
|
2008-12-11 23:42:14 +01:00
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);
|
2007-03-30 12:22:46 +02:00
|
|
|
#else
|
2014-09-15 17:03:28 +02:00
|
|
|
if (unlikely(ctx->pr)) {
|
2008-12-11 23:42:14 +01:00
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);
|
2007-03-30 12:22:46 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
/* Restore CPU state */
|
2012-05-30 06:23:23 +02:00
|
|
|
gen_helper_rfci(cpu_env);
|
2008-12-11 23:42:14 +01:00
|
|
|
gen_sync_exception(ctx);
|
2007-03-30 12:22:46 +02:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
/* BookE specific */
|
2009-06-17 17:22:09 +02:00
|
|
|
|
2009-06-17 17:22:19 +02:00
|
|
|
/* XXX: not implemented on 440 ? */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_rfdi(DisasContext *ctx)
|
2007-03-07 09:32:30 +01:00
|
|
|
{
|
|
|
|
#if defined(CONFIG_USER_ONLY)
|
2008-12-11 23:42:14 +01:00
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);
|
2007-03-07 09:32:30 +01:00
|
|
|
#else
|
2014-09-15 17:03:28 +02:00
|
|
|
if (unlikely(ctx->pr)) {
|
2008-12-11 23:42:14 +01:00
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);
|
2007-03-07 09:32:30 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
/* Restore CPU state */
|
2012-05-30 06:23:23 +02:00
|
|
|
gen_helper_rfdi(cpu_env);
|
2008-12-11 23:42:14 +01:00
|
|
|
gen_sync_exception(ctx);
|
2007-03-07 09:32:30 +01:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2007-09-21 07:50:37 +02:00
|
|
|
/* XXX: not implemented on 440 ? */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_rfmci(DisasContext *ctx)
|
2007-03-30 12:22:46 +02:00
|
|
|
{
|
|
|
|
#if defined(CONFIG_USER_ONLY)
|
2008-12-11 23:42:14 +01:00
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);
|
2007-03-30 12:22:46 +02:00
|
|
|
#else
|
2014-09-15 17:03:28 +02:00
|
|
|
if (unlikely(ctx->pr)) {
|
2008-12-11 23:42:14 +01:00
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);
|
2007-03-30 12:22:46 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
/* Restore CPU state */
|
2012-05-30 06:23:23 +02:00
|
|
|
gen_helper_rfmci(cpu_env);
|
2008-12-11 23:42:14 +01:00
|
|
|
gen_sync_exception(ctx);
|
2007-03-30 12:22:46 +02:00
|
|
|
#endif
|
|
|
|
}
|
2007-09-19 07:44:04 +02:00
|
|
|
|
2007-03-17 15:02:15 +01:00
|
|
|
/* TLB management - PowerPC 405 implementation */
|
2009-06-17 17:22:14 +02:00
|
|
|
|
2009-06-17 17:22:19 +02:00
|
|
|
/* tlbre */
|
2009-06-17 17:22:14 +02:00
|
|
|
static void gen_tlbre_40x(DisasContext *ctx)
|
2007-03-07 09:32:30 +01:00
|
|
|
{
|
|
|
|
#if defined(CONFIG_USER_ONLY)
|
2008-12-11 23:42:14 +01:00
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);
|
2007-03-07 09:32:30 +01:00
|
|
|
#else
|
2014-09-15 17:03:28 +02:00
|
|
|
if (unlikely(ctx->pr)) {
|
2008-12-11 23:42:14 +01:00
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);
|
2007-03-07 09:32:30 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
switch (rB(ctx->opcode)) {
|
|
|
|
case 0:
|
2012-05-30 06:23:31 +02:00
|
|
|
gen_helper_4xx_tlbre_hi(cpu_gpr[rD(ctx->opcode)], cpu_env,
|
|
|
|
cpu_gpr[rA(ctx->opcode)]);
|
2007-03-07 09:32:30 +01:00
|
|
|
break;
|
|
|
|
case 1:
|
2012-05-30 06:23:31 +02:00
|
|
|
gen_helper_4xx_tlbre_lo(cpu_gpr[rD(ctx->opcode)], cpu_env,
|
|
|
|
cpu_gpr[rA(ctx->opcode)]);
|
2007-03-07 09:32:30 +01:00
|
|
|
break;
|
|
|
|
default:
|
2008-12-11 23:42:14 +01:00
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_INVAL_INVAL);
|
2007-03-07 09:32:30 +01:00
|
|
|
break;
|
2004-01-04 23:58:38 +01:00
|
|
|
}
|
2007-03-07 09:32:30 +01:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2007-03-17 15:02:15 +01:00
|
|
|
/* tlbsx - tlbsx. */
|
2009-06-17 17:22:14 +02:00
|
|
|
static void gen_tlbsx_40x(DisasContext *ctx)
|
2007-03-07 09:32:30 +01:00
|
|
|
{
|
|
|
|
#if defined(CONFIG_USER_ONLY)
|
2008-12-11 23:42:14 +01:00
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);
|
2007-03-07 09:32:30 +01:00
|
|
|
#else
|
2008-12-06 22:46:17 +01:00
|
|
|
TCGv t0;
|
2014-09-15 17:03:28 +02:00
|
|
|
if (unlikely(ctx->pr)) {
|
2008-12-11 23:42:14 +01:00
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);
|
2007-03-07 09:32:30 +01:00
|
|
|
return;
|
|
|
|
}
|
2008-12-06 22:46:17 +01:00
|
|
|
t0 = tcg_temp_new();
|
2008-12-08 19:11:21 +01:00
|
|
|
gen_addr_reg_index(ctx, t0);
|
2012-05-30 06:23:31 +02:00
|
|
|
gen_helper_4xx_tlbsx(cpu_gpr[rD(ctx->opcode)], cpu_env, t0);
|
2008-12-06 22:46:17 +01:00
|
|
|
tcg_temp_free(t0);
|
|
|
|
if (Rc(ctx->opcode)) {
|
2015-02-13 21:51:55 +01:00
|
|
|
TCGLabel *l1 = gen_new_label();
|
2013-02-20 08:52:13 +01:00
|
|
|
tcg_gen_trunc_tl_i32(cpu_crf[0], cpu_so);
|
2008-12-06 22:46:17 +01:00
|
|
|
tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_gpr[rD(ctx->opcode)], -1, l1);
|
|
|
|
tcg_gen_ori_i32(cpu_crf[0], cpu_crf[0], 0x02);
|
|
|
|
gen_set_label(l1);
|
|
|
|
}
|
2007-03-07 09:32:30 +01:00
|
|
|
#endif
|
2003-11-23 15:55:54 +01:00
|
|
|
}
|
|
|
|
|
2007-03-07 09:32:30 +01:00
|
|
|
/* tlbwe */
|
2009-06-17 17:22:14 +02:00
|
|
|
static void gen_tlbwe_40x(DisasContext *ctx)
|
2003-11-23 15:55:54 +01:00
|
|
|
{
|
2007-03-07 09:32:30 +01:00
|
|
|
#if defined(CONFIG_USER_ONLY)
|
2008-12-11 23:42:14 +01:00
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);
|
2007-03-07 09:32:30 +01:00
|
|
|
#else
|
2014-09-15 17:03:28 +02:00
|
|
|
if (unlikely(ctx->pr)) {
|
2008-12-11 23:42:14 +01:00
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);
|
2007-03-07 09:32:30 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
switch (rB(ctx->opcode)) {
|
|
|
|
case 0:
|
2012-05-30 06:23:31 +02:00
|
|
|
gen_helper_4xx_tlbwe_hi(cpu_env, cpu_gpr[rA(ctx->opcode)],
|
|
|
|
cpu_gpr[rS(ctx->opcode)]);
|
2007-03-07 09:32:30 +01:00
|
|
|
break;
|
|
|
|
case 1:
|
2012-05-30 06:23:31 +02:00
|
|
|
gen_helper_4xx_tlbwe_lo(cpu_env, cpu_gpr[rA(ctx->opcode)],
|
|
|
|
cpu_gpr[rS(ctx->opcode)]);
|
2007-03-07 09:32:30 +01:00
|
|
|
break;
|
|
|
|
default:
|
2008-12-11 23:42:14 +01:00
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_INVAL_INVAL);
|
2007-03-07 09:32:30 +01:00
|
|
|
break;
|
2004-01-04 23:58:38 +01:00
|
|
|
}
|
2007-03-07 09:32:30 +01:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2007-09-21 07:28:33 +02:00
|
|
|
/* TLB management - PowerPC 440 implementation */
|
2009-06-17 17:22:14 +02:00
|
|
|
|
2009-06-17 17:22:19 +02:00
|
|
|
/* tlbre */
|
2009-06-17 17:22:14 +02:00
|
|
|
static void gen_tlbre_440(DisasContext *ctx)
|
2007-09-19 07:44:04 +02:00
|
|
|
{
|
|
|
|
#if defined(CONFIG_USER_ONLY)
|
2008-12-11 23:42:14 +01:00
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);
|
2007-09-19 07:44:04 +02:00
|
|
|
#else
|
2014-09-15 17:03:28 +02:00
|
|
|
if (unlikely(ctx->pr)) {
|
2008-12-11 23:42:14 +01:00
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);
|
2007-09-19 07:44:04 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
switch (rB(ctx->opcode)) {
|
|
|
|
case 0:
|
|
|
|
case 1:
|
|
|
|
case 2:
|
2008-12-06 22:46:17 +01:00
|
|
|
{
|
|
|
|
TCGv_i32 t0 = tcg_const_i32(rB(ctx->opcode));
|
2012-05-30 06:23:31 +02:00
|
|
|
gen_helper_440_tlbre(cpu_gpr[rD(ctx->opcode)], cpu_env,
|
|
|
|
t0, cpu_gpr[rA(ctx->opcode)]);
|
2008-12-06 22:46:17 +01:00
|
|
|
tcg_temp_free_i32(t0);
|
|
|
|
}
|
2007-09-19 07:44:04 +02:00
|
|
|
break;
|
|
|
|
default:
|
2008-12-11 23:42:14 +01:00
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_INVAL_INVAL);
|
2007-09-19 07:44:04 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
/* tlbsx - tlbsx. */
|
2009-06-17 17:22:14 +02:00
|
|
|
static void gen_tlbsx_440(DisasContext *ctx)
|
2007-09-19 07:44:04 +02:00
|
|
|
{
|
|
|
|
#if defined(CONFIG_USER_ONLY)
|
2008-12-11 23:42:14 +01:00
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);
|
2007-09-19 07:44:04 +02:00
|
|
|
#else
|
2008-12-06 22:46:17 +01:00
|
|
|
TCGv t0;
|
2014-09-15 17:03:28 +02:00
|
|
|
if (unlikely(ctx->pr)) {
|
2008-12-11 23:42:14 +01:00
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);
|
2007-09-19 07:44:04 +02:00
|
|
|
return;
|
|
|
|
}
|
2008-12-06 22:46:17 +01:00
|
|
|
t0 = tcg_temp_new();
|
2008-12-08 19:11:21 +01:00
|
|
|
gen_addr_reg_index(ctx, t0);
|
2012-05-30 06:23:31 +02:00
|
|
|
gen_helper_440_tlbsx(cpu_gpr[rD(ctx->opcode)], cpu_env, t0);
|
2008-12-06 22:46:17 +01:00
|
|
|
tcg_temp_free(t0);
|
|
|
|
if (Rc(ctx->opcode)) {
|
2015-02-13 21:51:55 +01:00
|
|
|
TCGLabel *l1 = gen_new_label();
|
2013-02-20 08:52:13 +01:00
|
|
|
tcg_gen_trunc_tl_i32(cpu_crf[0], cpu_so);
|
2008-12-06 22:46:17 +01:00
|
|
|
tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_gpr[rD(ctx->opcode)], -1, l1);
|
|
|
|
tcg_gen_ori_i32(cpu_crf[0], cpu_crf[0], 0x02);
|
|
|
|
gen_set_label(l1);
|
|
|
|
}
|
2007-09-19 07:44:04 +02:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
/* tlbwe */
|
2009-06-17 17:22:14 +02:00
|
|
|
static void gen_tlbwe_440(DisasContext *ctx)
|
2007-09-19 07:44:04 +02:00
|
|
|
{
|
|
|
|
#if defined(CONFIG_USER_ONLY)
|
2008-12-11 23:42:14 +01:00
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);
|
2007-09-19 07:44:04 +02:00
|
|
|
#else
|
2014-09-15 17:03:28 +02:00
|
|
|
if (unlikely(ctx->pr)) {
|
2008-12-11 23:42:14 +01:00
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);
|
2007-09-19 07:44:04 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
switch (rB(ctx->opcode)) {
|
|
|
|
case 0:
|
|
|
|
case 1:
|
|
|
|
case 2:
|
2008-12-06 22:46:17 +01:00
|
|
|
{
|
|
|
|
TCGv_i32 t0 = tcg_const_i32(rB(ctx->opcode));
|
2012-05-30 06:23:31 +02:00
|
|
|
gen_helper_440_tlbwe(cpu_env, t0, cpu_gpr[rA(ctx->opcode)],
|
|
|
|
cpu_gpr[rS(ctx->opcode)]);
|
2008-12-06 22:46:17 +01:00
|
|
|
tcg_temp_free_i32(t0);
|
|
|
|
}
|
2007-09-19 07:44:04 +02:00
|
|
|
break;
|
|
|
|
default:
|
2008-12-11 23:42:14 +01:00
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_INVAL_INVAL);
|
2007-09-19 07:44:04 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2011-04-30 23:34:58 +02:00
|
|
|
/* TLB management - PowerPC BookE 2.06 implementation */
|
|
|
|
|
|
|
|
/* tlbre */
|
|
|
|
static void gen_tlbre_booke206(DisasContext *ctx)
|
|
|
|
{
|
|
|
|
#if defined(CONFIG_USER_ONLY)
|
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);
|
|
|
|
#else
|
2014-09-15 17:03:28 +02:00
|
|
|
if (unlikely(ctx->pr)) {
|
2011-04-30 23:34:58 +02:00
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-05-30 06:23:31 +02:00
|
|
|
gen_helper_booke206_tlbre(cpu_env);
|
2011-04-30 23:34:58 +02:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
/* tlbsx - tlbsx. */
|
|
|
|
static void gen_tlbsx_booke206(DisasContext *ctx)
|
|
|
|
{
|
|
|
|
#if defined(CONFIG_USER_ONLY)
|
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);
|
|
|
|
#else
|
|
|
|
TCGv t0;
|
2014-09-15 17:03:28 +02:00
|
|
|
if (unlikely(ctx->pr)) {
|
2011-04-30 23:34:58 +02:00
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (rA(ctx->opcode)) {
|
|
|
|
t0 = tcg_temp_new();
|
|
|
|
tcg_gen_mov_tl(t0, cpu_gpr[rD(ctx->opcode)]);
|
|
|
|
} else {
|
|
|
|
t0 = tcg_const_tl(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
tcg_gen_add_tl(t0, t0, cpu_gpr[rB(ctx->opcode)]);
|
2012-05-30 06:23:31 +02:00
|
|
|
gen_helper_booke206_tlbsx(cpu_env, t0);
|
2014-01-19 17:26:33 +01:00
|
|
|
tcg_temp_free(t0);
|
2011-04-30 23:34:58 +02:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
/* tlbwe */
|
|
|
|
static void gen_tlbwe_booke206(DisasContext *ctx)
|
|
|
|
{
|
|
|
|
#if defined(CONFIG_USER_ONLY)
|
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);
|
|
|
|
#else
|
2014-09-15 17:03:28 +02:00
|
|
|
if (unlikely(ctx->pr)) {
|
2011-04-30 23:34:58 +02:00
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);
|
|
|
|
return;
|
|
|
|
}
|
2012-01-25 16:27:26 +01:00
|
|
|
gen_update_nip(ctx, ctx->nip - 4);
|
2012-05-30 06:23:31 +02:00
|
|
|
gen_helper_booke206_tlbwe(cpu_env);
|
2011-04-30 23:34:58 +02:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
static void gen_tlbivax_booke206(DisasContext *ctx)
|
|
|
|
{
|
|
|
|
#if defined(CONFIG_USER_ONLY)
|
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);
|
|
|
|
#else
|
|
|
|
TCGv t0;
|
2014-09-15 17:03:28 +02:00
|
|
|
if (unlikely(ctx->pr)) {
|
2011-04-30 23:34:58 +02:00
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
t0 = tcg_temp_new();
|
|
|
|
gen_addr_reg_index(ctx, t0);
|
|
|
|
|
2012-05-30 06:23:31 +02:00
|
|
|
gen_helper_booke206_tlbivax(cpu_env, t0);
|
2014-01-19 17:26:33 +01:00
|
|
|
tcg_temp_free(t0);
|
2011-04-30 23:34:58 +02:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2012-01-20 04:09:15 +01:00
|
|
|
static void gen_tlbilx_booke206(DisasContext *ctx)
|
|
|
|
{
|
|
|
|
#if defined(CONFIG_USER_ONLY)
|
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);
|
|
|
|
#else
|
|
|
|
TCGv t0;
|
2014-09-15 17:03:28 +02:00
|
|
|
if (unlikely(ctx->pr)) {
|
2012-01-20 04:09:15 +01:00
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
t0 = tcg_temp_new();
|
|
|
|
gen_addr_reg_index(ctx, t0);
|
|
|
|
|
|
|
|
switch((ctx->opcode >> 21) & 0x3) {
|
|
|
|
case 0:
|
2012-05-30 06:23:31 +02:00
|
|
|
gen_helper_booke206_tlbilx0(cpu_env, t0);
|
2012-01-20 04:09:15 +01:00
|
|
|
break;
|
|
|
|
case 1:
|
2012-05-30 06:23:31 +02:00
|
|
|
gen_helper_booke206_tlbilx1(cpu_env, t0);
|
2012-01-20 04:09:15 +01:00
|
|
|
break;
|
|
|
|
case 3:
|
2012-05-30 06:23:31 +02:00
|
|
|
gen_helper_booke206_tlbilx3(cpu_env, t0);
|
2012-01-20 04:09:15 +01:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_INVAL_INVAL);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
tcg_temp_free(t0);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2011-04-30 23:34:58 +02:00
|
|
|
|
2007-03-07 09:32:30 +01:00
|
|
|
/* wrtee */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_wrtee(DisasContext *ctx)
|
2007-03-07 09:32:30 +01:00
|
|
|
{
|
|
|
|
#if defined(CONFIG_USER_ONLY)
|
2008-12-11 23:42:14 +01:00
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);
|
2007-03-07 09:32:30 +01:00
|
|
|
#else
|
2008-12-06 14:03:35 +01:00
|
|
|
TCGv t0;
|
2014-09-15 17:03:28 +02:00
|
|
|
if (unlikely(ctx->pr)) {
|
2008-12-11 23:42:14 +01:00
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);
|
2007-03-07 09:32:30 +01:00
|
|
|
return;
|
|
|
|
}
|
2008-12-06 14:03:35 +01:00
|
|
|
t0 = tcg_temp_new();
|
|
|
|
tcg_gen_andi_tl(t0, cpu_gpr[rD(ctx->opcode)], (1 << MSR_EE));
|
|
|
|
tcg_gen_andi_tl(cpu_msr, cpu_msr, ~(1 << MSR_EE));
|
|
|
|
tcg_gen_or_tl(cpu_msr, cpu_msr, t0);
|
|
|
|
tcg_temp_free(t0);
|
2007-09-29 17:02:38 +02:00
|
|
|
/* Stop translation to have a chance to raise an exception
|
|
|
|
* if we just set msr_ee to 1
|
|
|
|
*/
|
2008-12-11 23:42:14 +01:00
|
|
|
gen_stop_exception(ctx);
|
2007-03-07 09:32:30 +01:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
/* wrteei */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_wrteei(DisasContext *ctx)
|
2007-03-07 09:32:30 +01:00
|
|
|
{
|
|
|
|
#if defined(CONFIG_USER_ONLY)
|
2008-12-11 23:42:14 +01:00
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);
|
2007-03-07 09:32:30 +01:00
|
|
|
#else
|
2014-09-15 17:03:28 +02:00
|
|
|
if (unlikely(ctx->pr)) {
|
2008-12-11 23:42:14 +01:00
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);
|
2007-03-07 09:32:30 +01:00
|
|
|
return;
|
|
|
|
}
|
2009-07-03 12:56:57 +02:00
|
|
|
if (ctx->opcode & 0x00008000) {
|
2008-12-06 14:03:35 +01:00
|
|
|
tcg_gen_ori_tl(cpu_msr, cpu_msr, (1 << MSR_EE));
|
|
|
|
/* Stop translation to have a chance to raise an exception */
|
2008-12-11 23:42:14 +01:00
|
|
|
gen_stop_exception(ctx);
|
2008-12-06 14:03:35 +01:00
|
|
|
} else {
|
2009-01-14 20:40:54 +01:00
|
|
|
tcg_gen_andi_tl(cpu_msr, cpu_msr, ~(1 << MSR_EE));
|
2008-12-06 14:03:35 +01:00
|
|
|
}
|
2007-03-07 09:32:30 +01:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2007-04-16 09:18:42 +02:00
|
|
|
/* PowerPC 440 specific instructions */
|
2009-06-17 17:22:09 +02:00
|
|
|
|
2009-06-17 17:22:19 +02:00
|
|
|
/* dlmzb */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_dlmzb(DisasContext *ctx)
|
2007-03-07 09:32:30 +01:00
|
|
|
{
|
2008-11-30 18:26:29 +01:00
|
|
|
TCGv_i32 t0 = tcg_const_i32(Rc(ctx->opcode));
|
2012-05-30 06:23:29 +02:00
|
|
|
gen_helper_dlmzb(cpu_gpr[rA(ctx->opcode)], cpu_env,
|
|
|
|
cpu_gpr[rS(ctx->opcode)], cpu_gpr[rB(ctx->opcode)], t0);
|
2008-11-30 18:26:29 +01:00
|
|
|
tcg_temp_free_i32(t0);
|
2007-03-07 09:32:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* mbar replaces eieio on 440 */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_mbar(DisasContext *ctx)
|
2007-03-07 09:32:30 +01:00
|
|
|
{
|
|
|
|
/* interpreted as no-op */
|
|
|
|
}
|
|
|
|
|
|
|
|
/* msync replaces sync on 440 */
|
2012-01-21 03:48:58 +01:00
|
|
|
static void gen_msync_4xx(DisasContext *ctx)
|
2007-03-07 09:32:30 +01:00
|
|
|
{
|
|
|
|
/* interpreted as no-op */
|
|
|
|
}
|
|
|
|
|
|
|
|
/* icbt */
|
2009-06-17 17:22:14 +02:00
|
|
|
static void gen_icbt_440(DisasContext *ctx)
|
2007-03-07 09:32:30 +01:00
|
|
|
{
|
|
|
|
/* interpreted as no-op */
|
|
|
|
/* XXX: specification say this is treated as a load by the MMU
|
|
|
|
* but does not generate any exception
|
|
|
|
*/
|
2003-11-23 15:55:54 +01:00
|
|
|
}
|
|
|
|
|
2012-01-31 03:18:35 +01:00
|
|
|
/* Embedded.Processor Control */
|
|
|
|
|
|
|
|
static void gen_msgclr(DisasContext *ctx)
|
|
|
|
{
|
|
|
|
#if defined(CONFIG_USER_ONLY)
|
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);
|
|
|
|
#else
|
2014-09-15 17:03:28 +02:00
|
|
|
if (unlikely(ctx->pr)) {
|
2012-01-31 03:18:35 +01:00
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-05-30 06:23:23 +02:00
|
|
|
gen_helper_msgclr(cpu_env, cpu_gpr[rB(ctx->opcode)]);
|
2012-01-31 03:18:35 +01:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2012-01-31 03:19:23 +01:00
|
|
|
static void gen_msgsnd(DisasContext *ctx)
|
|
|
|
{
|
|
|
|
#if defined(CONFIG_USER_ONLY)
|
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);
|
|
|
|
#else
|
2014-09-15 17:03:28 +02:00
|
|
|
if (unlikely(ctx->pr)) {
|
2012-01-31 03:19:23 +01:00
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
gen_helper_msgsnd(cpu_gpr[rB(ctx->opcode)]);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2007-10-07 20:19:26 +02:00
|
|
|
/*** Altivec vector extension ***/
|
|
|
|
/* Altivec registers moves */
|
|
|
|
|
2009-08-16 11:06:54 +02:00
|
|
|
static inline TCGv_ptr gen_avr_ptr(int reg)
|
2008-12-18 23:51:31 +01:00
|
|
|
{
|
2009-01-03 14:31:10 +01:00
|
|
|
TCGv_ptr r = tcg_temp_new_ptr();
|
2008-12-18 23:51:31 +01:00
|
|
|
tcg_gen_addi_ptr(r, cpu_env, offsetof(CPUPPCState, avr[reg]));
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
2007-10-07 20:19:26 +02:00
|
|
|
#define GEN_VR_LDX(name, opc2, opc3) \
|
2009-06-17 17:22:09 +02:00
|
|
|
static void glue(gen_, name)(DisasContext *ctx) \
|
2007-10-07 20:19:26 +02:00
|
|
|
{ \
|
2008-11-24 09:47:21 +01:00
|
|
|
TCGv EA; \
|
2007-10-07 20:19:26 +02:00
|
|
|
if (unlikely(!ctx->altivec_enabled)) { \
|
2008-12-11 23:42:14 +01:00
|
|
|
gen_exception(ctx, POWERPC_EXCP_VPU); \
|
2007-10-07 20:19:26 +02:00
|
|
|
return; \
|
|
|
|
} \
|
2008-12-08 19:11:21 +01:00
|
|
|
gen_set_access_type(ctx, ACCESS_INT); \
|
2008-11-24 09:47:21 +01:00
|
|
|
EA = tcg_temp_new(); \
|
2008-12-08 19:11:21 +01:00
|
|
|
gen_addr_reg_index(ctx, EA); \
|
2008-11-24 09:47:21 +01:00
|
|
|
tcg_gen_andi_tl(EA, EA, ~0xf); \
|
2014-05-29 16:12:20 +02:00
|
|
|
/* We only need to swap high and low halves. gen_qemu_ld64 does necessary \
|
|
|
|
64-bit byteswap already. */ \
|
2008-12-08 19:11:21 +01:00
|
|
|
if (ctx->le_mode) { \
|
|
|
|
gen_qemu_ld64(ctx, cpu_avrl[rD(ctx->opcode)], EA); \
|
2008-11-24 09:47:21 +01:00
|
|
|
tcg_gen_addi_tl(EA, EA, 8); \
|
2008-12-08 19:11:21 +01:00
|
|
|
gen_qemu_ld64(ctx, cpu_avrh[rD(ctx->opcode)], EA); \
|
2008-11-24 09:47:21 +01:00
|
|
|
} else { \
|
2008-12-08 19:11:21 +01:00
|
|
|
gen_qemu_ld64(ctx, cpu_avrh[rD(ctx->opcode)], EA); \
|
2008-11-24 09:47:21 +01:00
|
|
|
tcg_gen_addi_tl(EA, EA, 8); \
|
2008-12-08 19:11:21 +01:00
|
|
|
gen_qemu_ld64(ctx, cpu_avrl[rD(ctx->opcode)], EA); \
|
2008-11-24 09:47:21 +01:00
|
|
|
} \
|
|
|
|
tcg_temp_free(EA); \
|
2007-10-07 20:19:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
#define GEN_VR_STX(name, opc2, opc3) \
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_st##name(DisasContext *ctx) \
|
2007-10-07 20:19:26 +02:00
|
|
|
{ \
|
2008-11-24 09:47:21 +01:00
|
|
|
TCGv EA; \
|
2007-10-07 20:19:26 +02:00
|
|
|
if (unlikely(!ctx->altivec_enabled)) { \
|
2008-12-11 23:42:14 +01:00
|
|
|
gen_exception(ctx, POWERPC_EXCP_VPU); \
|
2007-10-07 20:19:26 +02:00
|
|
|
return; \
|
|
|
|
} \
|
2008-12-08 19:11:21 +01:00
|
|
|
gen_set_access_type(ctx, ACCESS_INT); \
|
2008-11-24 09:47:21 +01:00
|
|
|
EA = tcg_temp_new(); \
|
2008-12-08 19:11:21 +01:00
|
|
|
gen_addr_reg_index(ctx, EA); \
|
2008-11-24 09:47:21 +01:00
|
|
|
tcg_gen_andi_tl(EA, EA, ~0xf); \
|
2014-05-29 16:12:20 +02:00
|
|
|
/* We only need to swap high and low halves. gen_qemu_st64 does necessary \
|
|
|
|
64-bit byteswap already. */ \
|
2008-12-08 19:11:21 +01:00
|
|
|
if (ctx->le_mode) { \
|
|
|
|
gen_qemu_st64(ctx, cpu_avrl[rD(ctx->opcode)], EA); \
|
2008-11-24 09:47:21 +01:00
|
|
|
tcg_gen_addi_tl(EA, EA, 8); \
|
2008-12-08 19:11:21 +01:00
|
|
|
gen_qemu_st64(ctx, cpu_avrh[rD(ctx->opcode)], EA); \
|
2008-11-24 09:47:21 +01:00
|
|
|
} else { \
|
2008-12-08 19:11:21 +01:00
|
|
|
gen_qemu_st64(ctx, cpu_avrh[rD(ctx->opcode)], EA); \
|
2008-11-24 09:47:21 +01:00
|
|
|
tcg_gen_addi_tl(EA, EA, 8); \
|
2008-12-08 19:11:21 +01:00
|
|
|
gen_qemu_st64(ctx, cpu_avrl[rD(ctx->opcode)], EA); \
|
2008-11-24 09:47:21 +01:00
|
|
|
} \
|
|
|
|
tcg_temp_free(EA); \
|
2007-10-07 20:19:26 +02:00
|
|
|
}
|
|
|
|
|
2014-11-17 21:58:31 +01:00
|
|
|
#define GEN_VR_LVE(name, opc2, opc3, size) \
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_lve##name(DisasContext *ctx) \
|
2009-01-04 23:13:10 +01:00
|
|
|
{ \
|
|
|
|
TCGv EA; \
|
|
|
|
TCGv_ptr rs; \
|
|
|
|
if (unlikely(!ctx->altivec_enabled)) { \
|
|
|
|
gen_exception(ctx, POWERPC_EXCP_VPU); \
|
|
|
|
return; \
|
|
|
|
} \
|
|
|
|
gen_set_access_type(ctx, ACCESS_INT); \
|
|
|
|
EA = tcg_temp_new(); \
|
|
|
|
gen_addr_reg_index(ctx, EA); \
|
2014-11-17 21:58:31 +01:00
|
|
|
if (size > 1) { \
|
|
|
|
tcg_gen_andi_tl(EA, EA, ~(size - 1)); \
|
|
|
|
} \
|
2009-01-04 23:13:10 +01:00
|
|
|
rs = gen_avr_ptr(rS(ctx->opcode)); \
|
2012-05-30 06:23:40 +02:00
|
|
|
gen_helper_lve##name(cpu_env, rs, EA); \
|
2009-01-04 23:13:10 +01:00
|
|
|
tcg_temp_free(EA); \
|
|
|
|
tcg_temp_free_ptr(rs); \
|
|
|
|
}
|
|
|
|
|
2014-11-17 21:58:31 +01:00
|
|
|
#define GEN_VR_STVE(name, opc2, opc3, size) \
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_stve##name(DisasContext *ctx) \
|
2009-01-04 23:13:10 +01:00
|
|
|
{ \
|
|
|
|
TCGv EA; \
|
|
|
|
TCGv_ptr rs; \
|
|
|
|
if (unlikely(!ctx->altivec_enabled)) { \
|
|
|
|
gen_exception(ctx, POWERPC_EXCP_VPU); \
|
|
|
|
return; \
|
|
|
|
} \
|
|
|
|
gen_set_access_type(ctx, ACCESS_INT); \
|
|
|
|
EA = tcg_temp_new(); \
|
|
|
|
gen_addr_reg_index(ctx, EA); \
|
2014-11-17 21:58:31 +01:00
|
|
|
if (size > 1) { \
|
|
|
|
tcg_gen_andi_tl(EA, EA, ~(size - 1)); \
|
|
|
|
} \
|
2009-01-04 23:13:10 +01:00
|
|
|
rs = gen_avr_ptr(rS(ctx->opcode)); \
|
2012-05-30 06:23:40 +02:00
|
|
|
gen_helper_stve##name(cpu_env, rs, EA); \
|
2009-01-04 23:13:10 +01:00
|
|
|
tcg_temp_free(EA); \
|
|
|
|
tcg_temp_free_ptr(rs); \
|
|
|
|
}
|
|
|
|
|
2008-11-24 09:47:21 +01:00
|
|
|
GEN_VR_LDX(lvx, 0x07, 0x03);
|
2007-10-07 20:19:26 +02:00
|
|
|
/* As we don't emulate the cache, lvxl is stricly equivalent to lvx */
|
2008-11-24 09:47:21 +01:00
|
|
|
GEN_VR_LDX(lvxl, 0x07, 0x0B);
|
2007-10-07 20:19:26 +02:00
|
|
|
|
2014-11-17 21:58:31 +01:00
|
|
|
GEN_VR_LVE(bx, 0x07, 0x00, 1);
|
|
|
|
GEN_VR_LVE(hx, 0x07, 0x01, 2);
|
|
|
|
GEN_VR_LVE(wx, 0x07, 0x02, 4);
|
2009-01-04 23:13:10 +01:00
|
|
|
|
2008-11-24 09:47:21 +01:00
|
|
|
GEN_VR_STX(svx, 0x07, 0x07);
|
2007-10-07 20:19:26 +02:00
|
|
|
/* As we don't emulate the cache, stvxl is stricly equivalent to stvx */
|
2008-11-24 09:47:21 +01:00
|
|
|
GEN_VR_STX(svxl, 0x07, 0x0F);
|
2007-10-07 20:19:26 +02:00
|
|
|
|
2014-11-17 21:58:31 +01:00
|
|
|
GEN_VR_STVE(bx, 0x07, 0x04, 1);
|
|
|
|
GEN_VR_STVE(hx, 0x07, 0x05, 2);
|
|
|
|
GEN_VR_STVE(wx, 0x07, 0x06, 4);
|
2009-01-04 23:13:10 +01:00
|
|
|
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_lvsl(DisasContext *ctx)
|
2009-01-04 23:09:42 +01:00
|
|
|
{
|
|
|
|
TCGv_ptr rd;
|
|
|
|
TCGv EA;
|
|
|
|
if (unlikely(!ctx->altivec_enabled)) {
|
|
|
|
gen_exception(ctx, POWERPC_EXCP_VPU);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
EA = tcg_temp_new();
|
|
|
|
gen_addr_reg_index(ctx, EA);
|
|
|
|
rd = gen_avr_ptr(rD(ctx->opcode));
|
|
|
|
gen_helper_lvsl(rd, EA);
|
|
|
|
tcg_temp_free(EA);
|
|
|
|
tcg_temp_free_ptr(rd);
|
|
|
|
}
|
|
|
|
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_lvsr(DisasContext *ctx)
|
2009-01-04 23:09:42 +01:00
|
|
|
{
|
|
|
|
TCGv_ptr rd;
|
|
|
|
TCGv EA;
|
|
|
|
if (unlikely(!ctx->altivec_enabled)) {
|
|
|
|
gen_exception(ctx, POWERPC_EXCP_VPU);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
EA = tcg_temp_new();
|
|
|
|
gen_addr_reg_index(ctx, EA);
|
|
|
|
rd = gen_avr_ptr(rD(ctx->opcode));
|
|
|
|
gen_helper_lvsr(rd, EA);
|
|
|
|
tcg_temp_free(EA);
|
|
|
|
tcg_temp_free_ptr(rd);
|
|
|
|
}
|
|
|
|
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_mfvscr(DisasContext *ctx)
|
2009-01-04 23:51:59 +01:00
|
|
|
{
|
|
|
|
TCGv_i32 t;
|
|
|
|
if (unlikely(!ctx->altivec_enabled)) {
|
|
|
|
gen_exception(ctx, POWERPC_EXCP_VPU);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
tcg_gen_movi_i64(cpu_avrh[rD(ctx->opcode)], 0);
|
|
|
|
t = tcg_temp_new_i32();
|
2012-03-14 01:38:22 +01:00
|
|
|
tcg_gen_ld_i32(t, cpu_env, offsetof(CPUPPCState, vscr));
|
2009-01-04 23:51:59 +01:00
|
|
|
tcg_gen_extu_i32_i64(cpu_avrl[rD(ctx->opcode)], t);
|
2009-02-03 20:55:13 +01:00
|
|
|
tcg_temp_free_i32(t);
|
2009-01-04 23:51:59 +01:00
|
|
|
}
|
|
|
|
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_mtvscr(DisasContext *ctx)
|
2009-01-04 23:51:59 +01:00
|
|
|
{
|
2009-02-03 20:56:09 +01:00
|
|
|
TCGv_ptr p;
|
2009-01-04 23:51:59 +01:00
|
|
|
if (unlikely(!ctx->altivec_enabled)) {
|
|
|
|
gen_exception(ctx, POWERPC_EXCP_VPU);
|
|
|
|
return;
|
|
|
|
}
|
2014-11-14 21:01:41 +01:00
|
|
|
p = gen_avr_ptr(rB(ctx->opcode));
|
2012-05-30 06:23:29 +02:00
|
|
|
gen_helper_mtvscr(cpu_env, p);
|
2009-02-03 20:56:09 +01:00
|
|
|
tcg_temp_free_ptr(p);
|
2009-01-04 23:51:59 +01:00
|
|
|
}
|
|
|
|
|
2008-12-18 23:42:58 +01:00
|
|
|
/* Logical operations */
|
|
|
|
#define GEN_VX_LOGICAL(name, tcg_op, opc2, opc3) \
|
2009-06-17 17:22:09 +02:00
|
|
|
static void glue(gen_, name)(DisasContext *ctx) \
|
2008-12-18 23:42:58 +01:00
|
|
|
{ \
|
|
|
|
if (unlikely(!ctx->altivec_enabled)) { \
|
|
|
|
gen_exception(ctx, POWERPC_EXCP_VPU); \
|
|
|
|
return; \
|
|
|
|
} \
|
|
|
|
tcg_op(cpu_avrh[rD(ctx->opcode)], cpu_avrh[rA(ctx->opcode)], cpu_avrh[rB(ctx->opcode)]); \
|
|
|
|
tcg_op(cpu_avrl[rD(ctx->opcode)], cpu_avrl[rA(ctx->opcode)], cpu_avrl[rB(ctx->opcode)]); \
|
|
|
|
}
|
|
|
|
|
|
|
|
GEN_VX_LOGICAL(vand, tcg_gen_and_i64, 2, 16);
|
|
|
|
GEN_VX_LOGICAL(vandc, tcg_gen_andc_i64, 2, 17);
|
|
|
|
GEN_VX_LOGICAL(vor, tcg_gen_or_i64, 2, 18);
|
|
|
|
GEN_VX_LOGICAL(vxor, tcg_gen_xor_i64, 2, 19);
|
|
|
|
GEN_VX_LOGICAL(vnor, tcg_gen_nor_i64, 2, 20);
|
2014-02-12 22:22:58 +01:00
|
|
|
GEN_VX_LOGICAL(veqv, tcg_gen_eqv_i64, 2, 26);
|
|
|
|
GEN_VX_LOGICAL(vnand, tcg_gen_nand_i64, 2, 22);
|
|
|
|
GEN_VX_LOGICAL(vorc, tcg_gen_orc_i64, 2, 21);
|
2008-12-18 23:42:58 +01:00
|
|
|
|
2009-01-03 14:31:30 +01:00
|
|
|
#define GEN_VXFORM(name, opc2, opc3) \
|
2009-06-17 17:22:09 +02:00
|
|
|
static void glue(gen_, name)(DisasContext *ctx) \
|
2009-01-03 14:31:30 +01:00
|
|
|
{ \
|
|
|
|
TCGv_ptr ra, rb, rd; \
|
|
|
|
if (unlikely(!ctx->altivec_enabled)) { \
|
|
|
|
gen_exception(ctx, POWERPC_EXCP_VPU); \
|
|
|
|
return; \
|
|
|
|
} \
|
|
|
|
ra = gen_avr_ptr(rA(ctx->opcode)); \
|
|
|
|
rb = gen_avr_ptr(rB(ctx->opcode)); \
|
|
|
|
rd = gen_avr_ptr(rD(ctx->opcode)); \
|
|
|
|
gen_helper_##name (rd, ra, rb); \
|
|
|
|
tcg_temp_free_ptr(ra); \
|
|
|
|
tcg_temp_free_ptr(rb); \
|
|
|
|
tcg_temp_free_ptr(rd); \
|
|
|
|
}
|
|
|
|
|
2012-05-30 06:23:29 +02:00
|
|
|
#define GEN_VXFORM_ENV(name, opc2, opc3) \
|
|
|
|
static void glue(gen_, name)(DisasContext *ctx) \
|
|
|
|
{ \
|
|
|
|
TCGv_ptr ra, rb, rd; \
|
|
|
|
if (unlikely(!ctx->altivec_enabled)) { \
|
|
|
|
gen_exception(ctx, POWERPC_EXCP_VPU); \
|
|
|
|
return; \
|
|
|
|
} \
|
|
|
|
ra = gen_avr_ptr(rA(ctx->opcode)); \
|
|
|
|
rb = gen_avr_ptr(rB(ctx->opcode)); \
|
|
|
|
rd = gen_avr_ptr(rD(ctx->opcode)); \
|
2012-08-26 16:12:03 +02:00
|
|
|
gen_helper_##name(cpu_env, rd, ra, rb); \
|
2012-05-30 06:23:29 +02:00
|
|
|
tcg_temp_free_ptr(ra); \
|
|
|
|
tcg_temp_free_ptr(rb); \
|
|
|
|
tcg_temp_free_ptr(rd); \
|
2014-02-12 22:22:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
#define GEN_VXFORM3(name, opc2, opc3) \
|
|
|
|
static void glue(gen_, name)(DisasContext *ctx) \
|
|
|
|
{ \
|
|
|
|
TCGv_ptr ra, rb, rc, rd; \
|
|
|
|
if (unlikely(!ctx->altivec_enabled)) { \
|
|
|
|
gen_exception(ctx, POWERPC_EXCP_VPU); \
|
|
|
|
return; \
|
|
|
|
} \
|
|
|
|
ra = gen_avr_ptr(rA(ctx->opcode)); \
|
|
|
|
rb = gen_avr_ptr(rB(ctx->opcode)); \
|
|
|
|
rc = gen_avr_ptr(rC(ctx->opcode)); \
|
|
|
|
rd = gen_avr_ptr(rD(ctx->opcode)); \
|
|
|
|
gen_helper_##name(rd, ra, rb, rc); \
|
|
|
|
tcg_temp_free_ptr(ra); \
|
|
|
|
tcg_temp_free_ptr(rb); \
|
|
|
|
tcg_temp_free_ptr(rc); \
|
|
|
|
tcg_temp_free_ptr(rd); \
|
2012-05-30 06:23:29 +02:00
|
|
|
}
|
|
|
|
|
2014-02-12 22:22:55 +01:00
|
|
|
/*
|
|
|
|
* Support for Altivec instruction pairs that use bit 31 (Rc) as
|
|
|
|
* an opcode bit. In general, these pairs come from different
|
|
|
|
* versions of the ISA, so we must also support a pair of flags for
|
|
|
|
* each instruction.
|
|
|
|
*/
|
|
|
|
#define GEN_VXFORM_DUAL(name0, flg0, flg2_0, name1, flg1, flg2_1) \
|
|
|
|
static void glue(gen_, name0##_##name1)(DisasContext *ctx) \
|
|
|
|
{ \
|
|
|
|
if ((Rc(ctx->opcode) == 0) && \
|
|
|
|
((ctx->insns_flags & flg0) || (ctx->insns_flags2 & flg2_0))) { \
|
|
|
|
gen_##name0(ctx); \
|
|
|
|
} else if ((Rc(ctx->opcode) == 1) && \
|
|
|
|
((ctx->insns_flags & flg1) || (ctx->insns_flags2 & flg2_1))) { \
|
|
|
|
gen_##name1(ctx); \
|
|
|
|
} else { \
|
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_INVAL_INVAL); \
|
|
|
|
} \
|
|
|
|
}
|
|
|
|
|
2009-01-03 14:31:40 +01:00
|
|
|
GEN_VXFORM(vaddubm, 0, 0);
|
|
|
|
GEN_VXFORM(vadduhm, 0, 1);
|
|
|
|
GEN_VXFORM(vadduwm, 0, 2);
|
2014-02-12 22:22:59 +01:00
|
|
|
GEN_VXFORM(vaddudm, 0, 3);
|
2009-01-03 14:31:40 +01:00
|
|
|
GEN_VXFORM(vsububm, 0, 16);
|
|
|
|
GEN_VXFORM(vsubuhm, 0, 17);
|
|
|
|
GEN_VXFORM(vsubuwm, 0, 18);
|
2014-02-12 22:22:59 +01:00
|
|
|
GEN_VXFORM(vsubudm, 0, 19);
|
2009-01-03 14:31:58 +01:00
|
|
|
GEN_VXFORM(vmaxub, 1, 0);
|
|
|
|
GEN_VXFORM(vmaxuh, 1, 1);
|
|
|
|
GEN_VXFORM(vmaxuw, 1, 2);
|
2014-02-12 22:23:05 +01:00
|
|
|
GEN_VXFORM(vmaxud, 1, 3);
|
2009-01-03 14:31:58 +01:00
|
|
|
GEN_VXFORM(vmaxsb, 1, 4);
|
|
|
|
GEN_VXFORM(vmaxsh, 1, 5);
|
|
|
|
GEN_VXFORM(vmaxsw, 1, 6);
|
2014-02-12 22:23:05 +01:00
|
|
|
GEN_VXFORM(vmaxsd, 1, 7);
|
2009-01-03 14:31:58 +01:00
|
|
|
GEN_VXFORM(vminub, 1, 8);
|
|
|
|
GEN_VXFORM(vminuh, 1, 9);
|
|
|
|
GEN_VXFORM(vminuw, 1, 10);
|
2014-02-12 22:23:05 +01:00
|
|
|
GEN_VXFORM(vminud, 1, 11);
|
2009-01-03 14:31:58 +01:00
|
|
|
GEN_VXFORM(vminsb, 1, 12);
|
|
|
|
GEN_VXFORM(vminsh, 1, 13);
|
|
|
|
GEN_VXFORM(vminsw, 1, 14);
|
2014-02-12 22:23:05 +01:00
|
|
|
GEN_VXFORM(vminsd, 1, 15);
|
2009-01-03 14:31:49 +01:00
|
|
|
GEN_VXFORM(vavgub, 1, 16);
|
|
|
|
GEN_VXFORM(vavguh, 1, 17);
|
|
|
|
GEN_VXFORM(vavguw, 1, 18);
|
|
|
|
GEN_VXFORM(vavgsb, 1, 20);
|
|
|
|
GEN_VXFORM(vavgsh, 1, 21);
|
|
|
|
GEN_VXFORM(vavgsw, 1, 22);
|
2009-01-04 23:08:38 +01:00
|
|
|
GEN_VXFORM(vmrghb, 6, 0);
|
|
|
|
GEN_VXFORM(vmrghh, 6, 1);
|
|
|
|
GEN_VXFORM(vmrghw, 6, 2);
|
|
|
|
GEN_VXFORM(vmrglb, 6, 4);
|
|
|
|
GEN_VXFORM(vmrglh, 6, 5);
|
|
|
|
GEN_VXFORM(vmrglw, 6, 6);
|
2014-02-12 22:23:08 +01:00
|
|
|
|
|
|
|
static void gen_vmrgew(DisasContext *ctx)
|
|
|
|
{
|
|
|
|
TCGv_i64 tmp;
|
|
|
|
int VT, VA, VB;
|
|
|
|
if (unlikely(!ctx->altivec_enabled)) {
|
|
|
|
gen_exception(ctx, POWERPC_EXCP_VPU);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
VT = rD(ctx->opcode);
|
|
|
|
VA = rA(ctx->opcode);
|
|
|
|
VB = rB(ctx->opcode);
|
|
|
|
tmp = tcg_temp_new_i64();
|
|
|
|
tcg_gen_shri_i64(tmp, cpu_avrh[VB], 32);
|
|
|
|
tcg_gen_deposit_i64(cpu_avrh[VT], cpu_avrh[VA], tmp, 0, 32);
|
|
|
|
tcg_gen_shri_i64(tmp, cpu_avrl[VB], 32);
|
|
|
|
tcg_gen_deposit_i64(cpu_avrl[VT], cpu_avrl[VA], tmp, 0, 32);
|
|
|
|
tcg_temp_free_i64(tmp);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void gen_vmrgow(DisasContext *ctx)
|
|
|
|
{
|
|
|
|
int VT, VA, VB;
|
|
|
|
if (unlikely(!ctx->altivec_enabled)) {
|
|
|
|
gen_exception(ctx, POWERPC_EXCP_VPU);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
VT = rD(ctx->opcode);
|
|
|
|
VA = rA(ctx->opcode);
|
|
|
|
VB = rB(ctx->opcode);
|
|
|
|
|
|
|
|
tcg_gen_deposit_i64(cpu_avrh[VT], cpu_avrh[VB], cpu_avrh[VA], 32, 32);
|
|
|
|
tcg_gen_deposit_i64(cpu_avrl[VT], cpu_avrl[VB], cpu_avrl[VA], 32, 32);
|
|
|
|
}
|
|
|
|
|
2009-01-04 23:08:48 +01:00
|
|
|
GEN_VXFORM(vmuloub, 4, 0);
|
|
|
|
GEN_VXFORM(vmulouh, 4, 1);
|
2014-02-12 22:23:01 +01:00
|
|
|
GEN_VXFORM(vmulouw, 4, 2);
|
2014-02-12 22:23:02 +01:00
|
|
|
GEN_VXFORM(vmuluwm, 4, 2);
|
|
|
|
GEN_VXFORM_DUAL(vmulouw, PPC_ALTIVEC, PPC_NONE,
|
|
|
|
vmuluwm, PPC_NONE, PPC2_ALTIVEC_207)
|
2009-01-04 23:08:48 +01:00
|
|
|
GEN_VXFORM(vmulosb, 4, 4);
|
|
|
|
GEN_VXFORM(vmulosh, 4, 5);
|
2014-02-12 22:23:01 +01:00
|
|
|
GEN_VXFORM(vmulosw, 4, 6);
|
2009-01-04 23:08:48 +01:00
|
|
|
GEN_VXFORM(vmuleub, 4, 8);
|
|
|
|
GEN_VXFORM(vmuleuh, 4, 9);
|
2014-02-12 22:23:01 +01:00
|
|
|
GEN_VXFORM(vmuleuw, 4, 10);
|
2009-01-04 23:08:48 +01:00
|
|
|
GEN_VXFORM(vmulesb, 4, 12);
|
|
|
|
GEN_VXFORM(vmulesh, 4, 13);
|
2014-02-12 22:23:01 +01:00
|
|
|
GEN_VXFORM(vmulesw, 4, 14);
|
2009-01-04 23:09:08 +01:00
|
|
|
GEN_VXFORM(vslb, 2, 4);
|
|
|
|
GEN_VXFORM(vslh, 2, 5);
|
|
|
|
GEN_VXFORM(vslw, 2, 6);
|
2014-02-12 22:23:10 +01:00
|
|
|
GEN_VXFORM(vsld, 2, 23);
|
2009-01-04 23:08:58 +01:00
|
|
|
GEN_VXFORM(vsrb, 2, 8);
|
|
|
|
GEN_VXFORM(vsrh, 2, 9);
|
|
|
|
GEN_VXFORM(vsrw, 2, 10);
|
2014-02-12 22:23:10 +01:00
|
|
|
GEN_VXFORM(vsrd, 2, 27);
|
2009-01-04 23:08:58 +01:00
|
|
|
GEN_VXFORM(vsrab, 2, 12);
|
|
|
|
GEN_VXFORM(vsrah, 2, 13);
|
|
|
|
GEN_VXFORM(vsraw, 2, 14);
|
2014-02-12 22:23:10 +01:00
|
|
|
GEN_VXFORM(vsrad, 2, 15);
|
2009-01-04 23:09:19 +01:00
|
|
|
GEN_VXFORM(vslo, 6, 16);
|
|
|
|
GEN_VXFORM(vsro, 6, 17);
|
2009-01-04 23:09:31 +01:00
|
|
|
GEN_VXFORM(vaddcuw, 0, 6);
|
|
|
|
GEN_VXFORM(vsubcuw, 0, 22);
|
2012-05-30 06:23:29 +02:00
|
|
|
GEN_VXFORM_ENV(vaddubs, 0, 8);
|
|
|
|
GEN_VXFORM_ENV(vadduhs, 0, 9);
|
|
|
|
GEN_VXFORM_ENV(vadduws, 0, 10);
|
|
|
|
GEN_VXFORM_ENV(vaddsbs, 0, 12);
|
|
|
|
GEN_VXFORM_ENV(vaddshs, 0, 13);
|
|
|
|
GEN_VXFORM_ENV(vaddsws, 0, 14);
|
|
|
|
GEN_VXFORM_ENV(vsububs, 0, 24);
|
|
|
|
GEN_VXFORM_ENV(vsubuhs, 0, 25);
|
|
|
|
GEN_VXFORM_ENV(vsubuws, 0, 26);
|
|
|
|
GEN_VXFORM_ENV(vsubsbs, 0, 28);
|
|
|
|
GEN_VXFORM_ENV(vsubshs, 0, 29);
|
|
|
|
GEN_VXFORM_ENV(vsubsws, 0, 30);
|
2014-02-12 22:23:11 +01:00
|
|
|
GEN_VXFORM(vadduqm, 0, 4);
|
|
|
|
GEN_VXFORM(vaddcuq, 0, 5);
|
|
|
|
GEN_VXFORM3(vaddeuqm, 30, 0);
|
|
|
|
GEN_VXFORM3(vaddecuq, 30, 0);
|
|
|
|
GEN_VXFORM_DUAL(vaddeuqm, PPC_NONE, PPC2_ALTIVEC_207, \
|
|
|
|
vaddecuq, PPC_NONE, PPC2_ALTIVEC_207)
|
|
|
|
GEN_VXFORM(vsubuqm, 0, 20);
|
|
|
|
GEN_VXFORM(vsubcuq, 0, 21);
|
|
|
|
GEN_VXFORM3(vsubeuqm, 31, 0);
|
|
|
|
GEN_VXFORM3(vsubecuq, 31, 0);
|
|
|
|
GEN_VXFORM_DUAL(vsubeuqm, PPC_NONE, PPC2_ALTIVEC_207, \
|
|
|
|
vsubecuq, PPC_NONE, PPC2_ALTIVEC_207)
|
2009-01-04 23:09:52 +01:00
|
|
|
GEN_VXFORM(vrlb, 2, 0);
|
|
|
|
GEN_VXFORM(vrlh, 2, 1);
|
|
|
|
GEN_VXFORM(vrlw, 2, 2);
|
2014-02-12 22:23:10 +01:00
|
|
|
GEN_VXFORM(vrld, 2, 3);
|
2009-01-08 19:54:48 +01:00
|
|
|
GEN_VXFORM(vsl, 2, 7);
|
|
|
|
GEN_VXFORM(vsr, 2, 11);
|
2012-05-30 06:23:29 +02:00
|
|
|
GEN_VXFORM_ENV(vpkuhum, 7, 0);
|
|
|
|
GEN_VXFORM_ENV(vpkuwum, 7, 1);
|
2014-02-12 22:23:06 +01:00
|
|
|
GEN_VXFORM_ENV(vpkudum, 7, 17);
|
2012-05-30 06:23:29 +02:00
|
|
|
GEN_VXFORM_ENV(vpkuhus, 7, 2);
|
|
|
|
GEN_VXFORM_ENV(vpkuwus, 7, 3);
|
2014-02-12 22:23:06 +01:00
|
|
|
GEN_VXFORM_ENV(vpkudus, 7, 19);
|
2012-05-30 06:23:29 +02:00
|
|
|
GEN_VXFORM_ENV(vpkshus, 7, 4);
|
|
|
|
GEN_VXFORM_ENV(vpkswus, 7, 5);
|
2014-02-12 22:23:06 +01:00
|
|
|
GEN_VXFORM_ENV(vpksdus, 7, 21);
|
2012-05-30 06:23:29 +02:00
|
|
|
GEN_VXFORM_ENV(vpkshss, 7, 6);
|
|
|
|
GEN_VXFORM_ENV(vpkswss, 7, 7);
|
2014-02-12 22:23:06 +01:00
|
|
|
GEN_VXFORM_ENV(vpksdss, 7, 23);
|
2009-01-04 23:12:19 +01:00
|
|
|
GEN_VXFORM(vpkpx, 7, 12);
|
2012-05-30 06:23:29 +02:00
|
|
|
GEN_VXFORM_ENV(vsum4ubs, 4, 24);
|
|
|
|
GEN_VXFORM_ENV(vsum4sbs, 4, 28);
|
|
|
|
GEN_VXFORM_ENV(vsum4shs, 4, 25);
|
|
|
|
GEN_VXFORM_ENV(vsum2sws, 4, 26);
|
|
|
|
GEN_VXFORM_ENV(vsumsws, 4, 30);
|
|
|
|
GEN_VXFORM_ENV(vaddfp, 5, 0);
|
|
|
|
GEN_VXFORM_ENV(vsubfp, 5, 1);
|
|
|
|
GEN_VXFORM_ENV(vmaxfp, 5, 16);
|
|
|
|
GEN_VXFORM_ENV(vminfp, 5, 17);
|
2009-01-03 14:31:49 +01:00
|
|
|
|
2009-01-08 19:54:26 +01:00
|
|
|
#define GEN_VXRFORM1(opname, name, str, opc2, opc3) \
|
2009-06-17 17:22:14 +02:00
|
|
|
static void glue(gen_, name)(DisasContext *ctx) \
|
2009-01-08 19:54:26 +01:00
|
|
|
{ \
|
|
|
|
TCGv_ptr ra, rb, rd; \
|
|
|
|
if (unlikely(!ctx->altivec_enabled)) { \
|
|
|
|
gen_exception(ctx, POWERPC_EXCP_VPU); \
|
|
|
|
return; \
|
|
|
|
} \
|
|
|
|
ra = gen_avr_ptr(rA(ctx->opcode)); \
|
|
|
|
rb = gen_avr_ptr(rB(ctx->opcode)); \
|
|
|
|
rd = gen_avr_ptr(rD(ctx->opcode)); \
|
2012-05-30 06:23:29 +02:00
|
|
|
gen_helper_##opname(cpu_env, rd, ra, rb); \
|
2009-01-08 19:54:26 +01:00
|
|
|
tcg_temp_free_ptr(ra); \
|
|
|
|
tcg_temp_free_ptr(rb); \
|
|
|
|
tcg_temp_free_ptr(rd); \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define GEN_VXRFORM(name, opc2, opc3) \
|
|
|
|
GEN_VXRFORM1(name, name, #name, opc2, opc3) \
|
|
|
|
GEN_VXRFORM1(name##_dot, name##_, #name ".", opc2, (opc3 | (0x1 << 4)))
|
|
|
|
|
2014-02-12 22:22:57 +01:00
|
|
|
/*
|
|
|
|
* Support for Altivec instructions that use bit 31 (Rc) as an opcode
|
|
|
|
* bit but also use bit 21 as an actual Rc bit. In general, thse pairs
|
|
|
|
* come from different versions of the ISA, so we must also support a
|
|
|
|
* pair of flags for each instruction.
|
|
|
|
*/
|
|
|
|
#define GEN_VXRFORM_DUAL(name0, flg0, flg2_0, name1, flg1, flg2_1) \
|
|
|
|
static void glue(gen_, name0##_##name1)(DisasContext *ctx) \
|
|
|
|
{ \
|
|
|
|
if ((Rc(ctx->opcode) == 0) && \
|
|
|
|
((ctx->insns_flags & flg0) || (ctx->insns_flags2 & flg2_0))) { \
|
|
|
|
if (Rc21(ctx->opcode) == 0) { \
|
|
|
|
gen_##name0(ctx); \
|
|
|
|
} else { \
|
|
|
|
gen_##name0##_(ctx); \
|
|
|
|
} \
|
|
|
|
} else if ((Rc(ctx->opcode) == 1) && \
|
|
|
|
((ctx->insns_flags & flg1) || (ctx->insns_flags2 & flg2_1))) { \
|
|
|
|
if (Rc21(ctx->opcode) == 0) { \
|
|
|
|
gen_##name1(ctx); \
|
|
|
|
} else { \
|
|
|
|
gen_##name1##_(ctx); \
|
|
|
|
} \
|
|
|
|
} else { \
|
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_INVAL_INVAL); \
|
|
|
|
} \
|
|
|
|
}
|
|
|
|
|
2009-01-08 19:54:38 +01:00
|
|
|
GEN_VXRFORM(vcmpequb, 3, 0)
|
|
|
|
GEN_VXRFORM(vcmpequh, 3, 1)
|
|
|
|
GEN_VXRFORM(vcmpequw, 3, 2)
|
2014-02-12 22:23:13 +01:00
|
|
|
GEN_VXRFORM(vcmpequd, 3, 3)
|
2009-01-08 19:54:38 +01:00
|
|
|
GEN_VXRFORM(vcmpgtsb, 3, 12)
|
|
|
|
GEN_VXRFORM(vcmpgtsh, 3, 13)
|
|
|
|
GEN_VXRFORM(vcmpgtsw, 3, 14)
|
2014-02-12 22:23:13 +01:00
|
|
|
GEN_VXRFORM(vcmpgtsd, 3, 15)
|
2009-01-08 19:54:38 +01:00
|
|
|
GEN_VXRFORM(vcmpgtub, 3, 8)
|
|
|
|
GEN_VXRFORM(vcmpgtuh, 3, 9)
|
|
|
|
GEN_VXRFORM(vcmpgtuw, 3, 10)
|
2014-02-12 22:23:13 +01:00
|
|
|
GEN_VXRFORM(vcmpgtud, 3, 11)
|
2009-02-09 17:49:10 +01:00
|
|
|
GEN_VXRFORM(vcmpeqfp, 3, 3)
|
|
|
|
GEN_VXRFORM(vcmpgefp, 3, 7)
|
|
|
|
GEN_VXRFORM(vcmpgtfp, 3, 11)
|
|
|
|
GEN_VXRFORM(vcmpbfp, 3, 15)
|
2009-01-08 19:54:38 +01:00
|
|
|
|
2014-02-12 22:23:13 +01:00
|
|
|
GEN_VXRFORM_DUAL(vcmpeqfp, PPC_ALTIVEC, PPC_NONE, \
|
|
|
|
vcmpequd, PPC_NONE, PPC2_ALTIVEC_207)
|
|
|
|
GEN_VXRFORM_DUAL(vcmpbfp, PPC_ALTIVEC, PPC_NONE, \
|
|
|
|
vcmpgtsd, PPC_NONE, PPC2_ALTIVEC_207)
|
|
|
|
GEN_VXRFORM_DUAL(vcmpgtfp, PPC_ALTIVEC, PPC_NONE, \
|
|
|
|
vcmpgtud, PPC_NONE, PPC2_ALTIVEC_207)
|
|
|
|
|
2009-01-08 19:54:57 +01:00
|
|
|
#define GEN_VXFORM_SIMM(name, opc2, opc3) \
|
2009-06-17 17:22:09 +02:00
|
|
|
static void glue(gen_, name)(DisasContext *ctx) \
|
2009-01-08 19:54:57 +01:00
|
|
|
{ \
|
|
|
|
TCGv_ptr rd; \
|
|
|
|
TCGv_i32 simm; \
|
|
|
|
if (unlikely(!ctx->altivec_enabled)) { \
|
|
|
|
gen_exception(ctx, POWERPC_EXCP_VPU); \
|
|
|
|
return; \
|
|
|
|
} \
|
|
|
|
simm = tcg_const_i32(SIMM5(ctx->opcode)); \
|
|
|
|
rd = gen_avr_ptr(rD(ctx->opcode)); \
|
|
|
|
gen_helper_##name (rd, simm); \
|
|
|
|
tcg_temp_free_i32(simm); \
|
|
|
|
tcg_temp_free_ptr(rd); \
|
|
|
|
}
|
|
|
|
|
|
|
|
GEN_VXFORM_SIMM(vspltisb, 6, 12);
|
|
|
|
GEN_VXFORM_SIMM(vspltish, 6, 13);
|
|
|
|
GEN_VXFORM_SIMM(vspltisw, 6, 14);
|
|
|
|
|
2009-01-04 23:10:59 +01:00
|
|
|
#define GEN_VXFORM_NOA(name, opc2, opc3) \
|
2009-06-17 17:22:09 +02:00
|
|
|
static void glue(gen_, name)(DisasContext *ctx) \
|
2009-01-04 23:10:59 +01:00
|
|
|
{ \
|
|
|
|
TCGv_ptr rb, rd; \
|
|
|
|
if (unlikely(!ctx->altivec_enabled)) { \
|
|
|
|
gen_exception(ctx, POWERPC_EXCP_VPU); \
|
|
|
|
return; \
|
|
|
|
} \
|
|
|
|
rb = gen_avr_ptr(rB(ctx->opcode)); \
|
|
|
|
rd = gen_avr_ptr(rD(ctx->opcode)); \
|
|
|
|
gen_helper_##name (rd, rb); \
|
|
|
|
tcg_temp_free_ptr(rb); \
|
|
|
|
tcg_temp_free_ptr(rd); \
|
|
|
|
}
|
|
|
|
|
2012-05-30 06:23:29 +02:00
|
|
|
#define GEN_VXFORM_NOA_ENV(name, opc2, opc3) \
|
|
|
|
static void glue(gen_, name)(DisasContext *ctx) \
|
|
|
|
{ \
|
|
|
|
TCGv_ptr rb, rd; \
|
|
|
|
\
|
|
|
|
if (unlikely(!ctx->altivec_enabled)) { \
|
|
|
|
gen_exception(ctx, POWERPC_EXCP_VPU); \
|
|
|
|
return; \
|
|
|
|
} \
|
|
|
|
rb = gen_avr_ptr(rB(ctx->opcode)); \
|
|
|
|
rd = gen_avr_ptr(rD(ctx->opcode)); \
|
|
|
|
gen_helper_##name(cpu_env, rd, rb); \
|
|
|
|
tcg_temp_free_ptr(rb); \
|
|
|
|
tcg_temp_free_ptr(rd); \
|
|
|
|
}
|
|
|
|
|
2009-01-04 23:11:20 +01:00
|
|
|
GEN_VXFORM_NOA(vupkhsb, 7, 8);
|
|
|
|
GEN_VXFORM_NOA(vupkhsh, 7, 9);
|
2014-02-12 22:23:07 +01:00
|
|
|
GEN_VXFORM_NOA(vupkhsw, 7, 25);
|
2009-01-04 23:11:20 +01:00
|
|
|
GEN_VXFORM_NOA(vupklsb, 7, 10);
|
|
|
|
GEN_VXFORM_NOA(vupklsh, 7, 11);
|
2014-02-12 22:23:07 +01:00
|
|
|
GEN_VXFORM_NOA(vupklsw, 7, 27);
|
2009-01-04 23:11:10 +01:00
|
|
|
GEN_VXFORM_NOA(vupkhpx, 7, 13);
|
|
|
|
GEN_VXFORM_NOA(vupklpx, 7, 15);
|
2012-05-30 06:23:29 +02:00
|
|
|
GEN_VXFORM_NOA_ENV(vrefp, 5, 4);
|
|
|
|
GEN_VXFORM_NOA_ENV(vrsqrtefp, 5, 5);
|
|
|
|
GEN_VXFORM_NOA_ENV(vexptefp, 5, 6);
|
|
|
|
GEN_VXFORM_NOA_ENV(vlogefp, 5, 7);
|
2014-10-31 17:06:15 +01:00
|
|
|
GEN_VXFORM_NOA_ENV(vrfim, 5, 11);
|
|
|
|
GEN_VXFORM_NOA_ENV(vrfin, 5, 8);
|
2012-05-30 06:23:29 +02:00
|
|
|
GEN_VXFORM_NOA_ENV(vrfip, 5, 10);
|
2014-10-31 17:06:15 +01:00
|
|
|
GEN_VXFORM_NOA_ENV(vrfiz, 5, 9);
|
2009-01-04 23:11:10 +01:00
|
|
|
|
2009-01-04 23:10:28 +01:00
|
|
|
#define GEN_VXFORM_SIMM(name, opc2, opc3) \
|
2009-06-17 17:22:09 +02:00
|
|
|
static void glue(gen_, name)(DisasContext *ctx) \
|
2009-01-04 23:10:28 +01:00
|
|
|
{ \
|
|
|
|
TCGv_ptr rd; \
|
|
|
|
TCGv_i32 simm; \
|
|
|
|
if (unlikely(!ctx->altivec_enabled)) { \
|
|
|
|
gen_exception(ctx, POWERPC_EXCP_VPU); \
|
|
|
|
return; \
|
|
|
|
} \
|
|
|
|
simm = tcg_const_i32(SIMM5(ctx->opcode)); \
|
|
|
|
rd = gen_avr_ptr(rD(ctx->opcode)); \
|
|
|
|
gen_helper_##name (rd, simm); \
|
|
|
|
tcg_temp_free_i32(simm); \
|
|
|
|
tcg_temp_free_ptr(rd); \
|
|
|
|
}
|
|
|
|
|
2009-01-04 23:10:40 +01:00
|
|
|
#define GEN_VXFORM_UIMM(name, opc2, opc3) \
|
2009-06-17 17:22:09 +02:00
|
|
|
static void glue(gen_, name)(DisasContext *ctx) \
|
2009-01-04 23:10:40 +01:00
|
|
|
{ \
|
|
|
|
TCGv_ptr rb, rd; \
|
|
|
|
TCGv_i32 uimm; \
|
|
|
|
if (unlikely(!ctx->altivec_enabled)) { \
|
|
|
|
gen_exception(ctx, POWERPC_EXCP_VPU); \
|
|
|
|
return; \
|
|
|
|
} \
|
|
|
|
uimm = tcg_const_i32(UIMM5(ctx->opcode)); \
|
|
|
|
rb = gen_avr_ptr(rB(ctx->opcode)); \
|
|
|
|
rd = gen_avr_ptr(rD(ctx->opcode)); \
|
|
|
|
gen_helper_##name (rd, rb, uimm); \
|
|
|
|
tcg_temp_free_i32(uimm); \
|
|
|
|
tcg_temp_free_ptr(rb); \
|
|
|
|
tcg_temp_free_ptr(rd); \
|
|
|
|
}
|
|
|
|
|
2012-05-30 06:23:29 +02:00
|
|
|
#define GEN_VXFORM_UIMM_ENV(name, opc2, opc3) \
|
|
|
|
static void glue(gen_, name)(DisasContext *ctx) \
|
|
|
|
{ \
|
|
|
|
TCGv_ptr rb, rd; \
|
|
|
|
TCGv_i32 uimm; \
|
|
|
|
\
|
|
|
|
if (unlikely(!ctx->altivec_enabled)) { \
|
|
|
|
gen_exception(ctx, POWERPC_EXCP_VPU); \
|
|
|
|
return; \
|
|
|
|
} \
|
|
|
|
uimm = tcg_const_i32(UIMM5(ctx->opcode)); \
|
|
|
|
rb = gen_avr_ptr(rB(ctx->opcode)); \
|
|
|
|
rd = gen_avr_ptr(rD(ctx->opcode)); \
|
|
|
|
gen_helper_##name(cpu_env, rd, rb, uimm); \
|
|
|
|
tcg_temp_free_i32(uimm); \
|
|
|
|
tcg_temp_free_ptr(rb); \
|
|
|
|
tcg_temp_free_ptr(rd); \
|
|
|
|
}
|
|
|
|
|
2009-01-04 23:10:49 +01:00
|
|
|
GEN_VXFORM_UIMM(vspltb, 6, 8);
|
|
|
|
GEN_VXFORM_UIMM(vsplth, 6, 9);
|
|
|
|
GEN_VXFORM_UIMM(vspltw, 6, 10);
|
2012-05-30 06:23:29 +02:00
|
|
|
GEN_VXFORM_UIMM_ENV(vcfux, 5, 12);
|
|
|
|
GEN_VXFORM_UIMM_ENV(vcfsx, 5, 13);
|
|
|
|
GEN_VXFORM_UIMM_ENV(vctuxs, 5, 14);
|
|
|
|
GEN_VXFORM_UIMM_ENV(vctsxs, 5, 15);
|
2009-01-04 23:10:49 +01:00
|
|
|
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_vsldoi(DisasContext *ctx)
|
2009-01-04 23:10:09 +01:00
|
|
|
{
|
|
|
|
TCGv_ptr ra, rb, rd;
|
2009-02-03 20:55:13 +01:00
|
|
|
TCGv_i32 sh;
|
2009-01-04 23:10:09 +01:00
|
|
|
if (unlikely(!ctx->altivec_enabled)) {
|
|
|
|
gen_exception(ctx, POWERPC_EXCP_VPU);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
ra = gen_avr_ptr(rA(ctx->opcode));
|
|
|
|
rb = gen_avr_ptr(rB(ctx->opcode));
|
|
|
|
rd = gen_avr_ptr(rD(ctx->opcode));
|
|
|
|
sh = tcg_const_i32(VSH(ctx->opcode));
|
|
|
|
gen_helper_vsldoi (rd, ra, rb, sh);
|
|
|
|
tcg_temp_free_ptr(ra);
|
|
|
|
tcg_temp_free_ptr(rb);
|
|
|
|
tcg_temp_free_ptr(rd);
|
2009-02-03 20:55:13 +01:00
|
|
|
tcg_temp_free_i32(sh);
|
2009-01-04 23:10:09 +01:00
|
|
|
}
|
|
|
|
|
2009-01-04 23:11:29 +01:00
|
|
|
#define GEN_VAFORM_PAIRED(name0, name1, opc2) \
|
2012-05-30 06:23:29 +02:00
|
|
|
static void glue(gen_, name0##_##name1)(DisasContext *ctx) \
|
2009-01-04 23:11:29 +01:00
|
|
|
{ \
|
|
|
|
TCGv_ptr ra, rb, rc, rd; \
|
|
|
|
if (unlikely(!ctx->altivec_enabled)) { \
|
|
|
|
gen_exception(ctx, POWERPC_EXCP_VPU); \
|
|
|
|
return; \
|
|
|
|
} \
|
|
|
|
ra = gen_avr_ptr(rA(ctx->opcode)); \
|
|
|
|
rb = gen_avr_ptr(rB(ctx->opcode)); \
|
|
|
|
rc = gen_avr_ptr(rC(ctx->opcode)); \
|
|
|
|
rd = gen_avr_ptr(rD(ctx->opcode)); \
|
|
|
|
if (Rc(ctx->opcode)) { \
|
2012-05-30 06:23:29 +02:00
|
|
|
gen_helper_##name1(cpu_env, rd, ra, rb, rc); \
|
2009-01-04 23:11:29 +01:00
|
|
|
} else { \
|
2012-05-30 06:23:29 +02:00
|
|
|
gen_helper_##name0(cpu_env, rd, ra, rb, rc); \
|
2009-01-04 23:11:29 +01:00
|
|
|
} \
|
|
|
|
tcg_temp_free_ptr(ra); \
|
|
|
|
tcg_temp_free_ptr(rb); \
|
|
|
|
tcg_temp_free_ptr(rc); \
|
|
|
|
tcg_temp_free_ptr(rd); \
|
|
|
|
}
|
|
|
|
|
2009-01-04 23:12:29 +01:00
|
|
|
GEN_VAFORM_PAIRED(vmhaddshs, vmhraddshs, 16)
|
|
|
|
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_vmladduhm(DisasContext *ctx)
|
2009-01-04 23:13:00 +01:00
|
|
|
{
|
|
|
|
TCGv_ptr ra, rb, rc, rd;
|
|
|
|
if (unlikely(!ctx->altivec_enabled)) {
|
|
|
|
gen_exception(ctx, POWERPC_EXCP_VPU);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
ra = gen_avr_ptr(rA(ctx->opcode));
|
|
|
|
rb = gen_avr_ptr(rB(ctx->opcode));
|
|
|
|
rc = gen_avr_ptr(rC(ctx->opcode));
|
|
|
|
rd = gen_avr_ptr(rD(ctx->opcode));
|
|
|
|
gen_helper_vmladduhm(rd, ra, rb, rc);
|
|
|
|
tcg_temp_free_ptr(ra);
|
|
|
|
tcg_temp_free_ptr(rb);
|
|
|
|
tcg_temp_free_ptr(rc);
|
|
|
|
tcg_temp_free_ptr(rd);
|
|
|
|
}
|
|
|
|
|
2009-01-04 23:11:39 +01:00
|
|
|
GEN_VAFORM_PAIRED(vmsumubm, vmsummbm, 18)
|
2009-01-04 23:12:39 +01:00
|
|
|
GEN_VAFORM_PAIRED(vmsumuhm, vmsumuhs, 19)
|
2009-01-04 23:12:49 +01:00
|
|
|
GEN_VAFORM_PAIRED(vmsumshm, vmsumshs, 20)
|
2009-01-04 23:11:49 +01:00
|
|
|
GEN_VAFORM_PAIRED(vsel, vperm, 21)
|
2009-02-09 17:48:59 +01:00
|
|
|
GEN_VAFORM_PAIRED(vmaddfp, vnmsubfp, 23)
|
2009-01-04 23:11:39 +01:00
|
|
|
|
2014-02-12 22:23:03 +01:00
|
|
|
GEN_VXFORM_NOA(vclzb, 1, 28)
|
|
|
|
GEN_VXFORM_NOA(vclzh, 1, 29)
|
|
|
|
GEN_VXFORM_NOA(vclzw, 1, 30)
|
|
|
|
GEN_VXFORM_NOA(vclzd, 1, 31)
|
2014-02-12 22:23:04 +01:00
|
|
|
GEN_VXFORM_NOA(vpopcntb, 1, 28)
|
|
|
|
GEN_VXFORM_NOA(vpopcnth, 1, 29)
|
|
|
|
GEN_VXFORM_NOA(vpopcntw, 1, 30)
|
|
|
|
GEN_VXFORM_NOA(vpopcntd, 1, 31)
|
|
|
|
GEN_VXFORM_DUAL(vclzb, PPC_NONE, PPC2_ALTIVEC_207, \
|
|
|
|
vpopcntb, PPC_NONE, PPC2_ALTIVEC_207)
|
|
|
|
GEN_VXFORM_DUAL(vclzh, PPC_NONE, PPC2_ALTIVEC_207, \
|
|
|
|
vpopcnth, PPC_NONE, PPC2_ALTIVEC_207)
|
|
|
|
GEN_VXFORM_DUAL(vclzw, PPC_NONE, PPC2_ALTIVEC_207, \
|
|
|
|
vpopcntw, PPC_NONE, PPC2_ALTIVEC_207)
|
|
|
|
GEN_VXFORM_DUAL(vclzd, PPC_NONE, PPC2_ALTIVEC_207, \
|
|
|
|
vpopcntd, PPC_NONE, PPC2_ALTIVEC_207)
|
2014-02-12 22:23:12 +01:00
|
|
|
GEN_VXFORM(vbpermq, 6, 21);
|
2014-02-12 22:23:14 +01:00
|
|
|
GEN_VXFORM_NOA(vgbbd, 6, 20);
|
2014-02-12 22:23:15 +01:00
|
|
|
GEN_VXFORM(vpmsumb, 4, 16)
|
|
|
|
GEN_VXFORM(vpmsumh, 4, 17)
|
|
|
|
GEN_VXFORM(vpmsumw, 4, 18)
|
|
|
|
GEN_VXFORM(vpmsumd, 4, 19)
|
2014-02-12 22:23:04 +01:00
|
|
|
|
2014-02-12 22:23:16 +01:00
|
|
|
#define GEN_BCD(op) \
|
|
|
|
static void gen_##op(DisasContext *ctx) \
|
|
|
|
{ \
|
|
|
|
TCGv_ptr ra, rb, rd; \
|
|
|
|
TCGv_i32 ps; \
|
|
|
|
\
|
|
|
|
if (unlikely(!ctx->altivec_enabled)) { \
|
|
|
|
gen_exception(ctx, POWERPC_EXCP_VPU); \
|
|
|
|
return; \
|
|
|
|
} \
|
|
|
|
\
|
|
|
|
ra = gen_avr_ptr(rA(ctx->opcode)); \
|
|
|
|
rb = gen_avr_ptr(rB(ctx->opcode)); \
|
|
|
|
rd = gen_avr_ptr(rD(ctx->opcode)); \
|
|
|
|
\
|
|
|
|
ps = tcg_const_i32((ctx->opcode & 0x200) != 0); \
|
|
|
|
\
|
|
|
|
gen_helper_##op(cpu_crf[6], rd, ra, rb, ps); \
|
|
|
|
\
|
|
|
|
tcg_temp_free_ptr(ra); \
|
|
|
|
tcg_temp_free_ptr(rb); \
|
|
|
|
tcg_temp_free_ptr(rd); \
|
|
|
|
tcg_temp_free_i32(ps); \
|
|
|
|
}
|
|
|
|
|
|
|
|
GEN_BCD(bcdadd)
|
|
|
|
GEN_BCD(bcdsub)
|
|
|
|
|
|
|
|
GEN_VXFORM_DUAL(vsububm, PPC_ALTIVEC, PPC_NONE, \
|
|
|
|
bcdadd, PPC_NONE, PPC2_ALTIVEC_207)
|
|
|
|
GEN_VXFORM_DUAL(vsububs, PPC_ALTIVEC, PPC_NONE, \
|
|
|
|
bcdadd, PPC_NONE, PPC2_ALTIVEC_207)
|
|
|
|
GEN_VXFORM_DUAL(vsubuhm, PPC_ALTIVEC, PPC_NONE, \
|
|
|
|
bcdsub, PPC_NONE, PPC2_ALTIVEC_207)
|
|
|
|
GEN_VXFORM_DUAL(vsubuhs, PPC_ALTIVEC, PPC_NONE, \
|
|
|
|
bcdsub, PPC_NONE, PPC2_ALTIVEC_207)
|
|
|
|
|
2014-02-12 22:23:17 +01:00
|
|
|
static void gen_vsbox(DisasContext *ctx)
|
|
|
|
{
|
|
|
|
TCGv_ptr ra, rd;
|
|
|
|
if (unlikely(!ctx->altivec_enabled)) {
|
|
|
|
gen_exception(ctx, POWERPC_EXCP_VPU);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
ra = gen_avr_ptr(rA(ctx->opcode));
|
|
|
|
rd = gen_avr_ptr(rD(ctx->opcode));
|
|
|
|
gen_helper_vsbox(rd, ra);
|
|
|
|
tcg_temp_free_ptr(ra);
|
|
|
|
tcg_temp_free_ptr(rd);
|
|
|
|
}
|
|
|
|
|
|
|
|
GEN_VXFORM(vcipher, 4, 20)
|
|
|
|
GEN_VXFORM(vcipherlast, 4, 20)
|
|
|
|
GEN_VXFORM(vncipher, 4, 21)
|
|
|
|
GEN_VXFORM(vncipherlast, 4, 21)
|
|
|
|
|
|
|
|
GEN_VXFORM_DUAL(vcipher, PPC_NONE, PPC2_ALTIVEC_207,
|
|
|
|
vcipherlast, PPC_NONE, PPC2_ALTIVEC_207)
|
|
|
|
GEN_VXFORM_DUAL(vncipher, PPC_NONE, PPC2_ALTIVEC_207,
|
|
|
|
vncipherlast, PPC_NONE, PPC2_ALTIVEC_207)
|
|
|
|
|
2014-02-12 22:23:18 +01:00
|
|
|
#define VSHASIGMA(op) \
|
|
|
|
static void gen_##op(DisasContext *ctx) \
|
|
|
|
{ \
|
|
|
|
TCGv_ptr ra, rd; \
|
|
|
|
TCGv_i32 st_six; \
|
|
|
|
if (unlikely(!ctx->altivec_enabled)) { \
|
|
|
|
gen_exception(ctx, POWERPC_EXCP_VPU); \
|
|
|
|
return; \
|
|
|
|
} \
|
|
|
|
ra = gen_avr_ptr(rA(ctx->opcode)); \
|
|
|
|
rd = gen_avr_ptr(rD(ctx->opcode)); \
|
|
|
|
st_six = tcg_const_i32(rB(ctx->opcode)); \
|
|
|
|
gen_helper_##op(rd, ra, st_six); \
|
|
|
|
tcg_temp_free_ptr(ra); \
|
|
|
|
tcg_temp_free_ptr(rd); \
|
|
|
|
tcg_temp_free_i32(st_six); \
|
|
|
|
}
|
|
|
|
|
|
|
|
VSHASIGMA(vshasigmaw)
|
|
|
|
VSHASIGMA(vshasigmad)
|
|
|
|
|
2014-02-12 22:23:19 +01:00
|
|
|
GEN_VXFORM3(vpermxor, 22, 0xFF)
|
|
|
|
GEN_VXFORM_DUAL(vsldoi, PPC_ALTIVEC, PPC_NONE,
|
|
|
|
vpermxor, PPC_NONE, PPC2_ALTIVEC_207)
|
|
|
|
|
2013-10-22 13:07:41 +02:00
|
|
|
/*** VSX extension ***/
|
|
|
|
|
|
|
|
static inline TCGv_i64 cpu_vsrh(int n)
|
|
|
|
{
|
|
|
|
if (n < 32) {
|
|
|
|
return cpu_fpr[n];
|
|
|
|
} else {
|
|
|
|
return cpu_avrh[n-32];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline TCGv_i64 cpu_vsrl(int n)
|
|
|
|
{
|
|
|
|
if (n < 32) {
|
|
|
|
return cpu_vsr[n];
|
|
|
|
} else {
|
|
|
|
return cpu_avrl[n-32];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-01-15 15:10:29 +01:00
|
|
|
#define VSX_LOAD_SCALAR(name, operation) \
|
|
|
|
static void gen_##name(DisasContext *ctx) \
|
|
|
|
{ \
|
|
|
|
TCGv EA; \
|
|
|
|
if (unlikely(!ctx->vsx_enabled)) { \
|
|
|
|
gen_exception(ctx, POWERPC_EXCP_VSXU); \
|
|
|
|
return; \
|
|
|
|
} \
|
|
|
|
gen_set_access_type(ctx, ACCESS_INT); \
|
|
|
|
EA = tcg_temp_new(); \
|
|
|
|
gen_addr_reg_index(ctx, EA); \
|
|
|
|
gen_qemu_##operation(ctx, cpu_vsrh(xT(ctx->opcode)), EA); \
|
|
|
|
/* NOTE: cpu_vsrl is undefined */ \
|
|
|
|
tcg_temp_free(EA); \
|
|
|
|
}
|
|
|
|
|
|
|
|
VSX_LOAD_SCALAR(lxsdx, ld64)
|
2014-01-15 15:10:30 +01:00
|
|
|
VSX_LOAD_SCALAR(lxsiwax, ld32s_i64)
|
|
|
|
VSX_LOAD_SCALAR(lxsiwzx, ld32u_i64)
|
|
|
|
VSX_LOAD_SCALAR(lxsspx, ld32fs)
|
2013-11-01 14:21:12 +01:00
|
|
|
|
2013-10-22 13:08:32 +02:00
|
|
|
static void gen_lxvd2x(DisasContext *ctx)
|
|
|
|
{
|
|
|
|
TCGv EA;
|
|
|
|
if (unlikely(!ctx->vsx_enabled)) {
|
|
|
|
gen_exception(ctx, POWERPC_EXCP_VSXU);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
gen_set_access_type(ctx, ACCESS_INT);
|
|
|
|
EA = tcg_temp_new();
|
|
|
|
gen_addr_reg_index(ctx, EA);
|
|
|
|
gen_qemu_ld64(ctx, cpu_vsrh(xT(ctx->opcode)), EA);
|
|
|
|
tcg_gen_addi_tl(EA, EA, 8);
|
|
|
|
gen_qemu_ld64(ctx, cpu_vsrl(xT(ctx->opcode)), EA);
|
|
|
|
tcg_temp_free(EA);
|
|
|
|
}
|
|
|
|
|
2013-11-01 14:21:13 +01:00
|
|
|
static void gen_lxvdsx(DisasContext *ctx)
|
|
|
|
{
|
|
|
|
TCGv EA;
|
|
|
|
if (unlikely(!ctx->vsx_enabled)) {
|
|
|
|
gen_exception(ctx, POWERPC_EXCP_VSXU);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
gen_set_access_type(ctx, ACCESS_INT);
|
|
|
|
EA = tcg_temp_new();
|
|
|
|
gen_addr_reg_index(ctx, EA);
|
|
|
|
gen_qemu_ld64(ctx, cpu_vsrh(xT(ctx->opcode)), EA);
|
2013-12-20 11:01:50 +01:00
|
|
|
tcg_gen_mov_i64(cpu_vsrl(xT(ctx->opcode)), cpu_vsrh(xT(ctx->opcode)));
|
2013-11-01 14:21:13 +01:00
|
|
|
tcg_temp_free(EA);
|
|
|
|
}
|
|
|
|
|
2013-11-01 14:21:14 +01:00
|
|
|
static void gen_lxvw4x(DisasContext *ctx)
|
|
|
|
{
|
2013-12-20 11:01:50 +01:00
|
|
|
TCGv EA;
|
|
|
|
TCGv_i64 tmp;
|
2013-11-01 14:21:14 +01:00
|
|
|
TCGv_i64 xth = cpu_vsrh(xT(ctx->opcode));
|
|
|
|
TCGv_i64 xtl = cpu_vsrl(xT(ctx->opcode));
|
|
|
|
if (unlikely(!ctx->vsx_enabled)) {
|
|
|
|
gen_exception(ctx, POWERPC_EXCP_VSXU);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
gen_set_access_type(ctx, ACCESS_INT);
|
|
|
|
EA = tcg_temp_new();
|
2013-12-20 11:01:50 +01:00
|
|
|
tmp = tcg_temp_new_i64();
|
|
|
|
|
2013-11-01 14:21:14 +01:00
|
|
|
gen_addr_reg_index(ctx, EA);
|
2013-12-20 11:01:50 +01:00
|
|
|
gen_qemu_ld32u_i64(ctx, tmp, EA);
|
2013-11-01 14:21:14 +01:00
|
|
|
tcg_gen_addi_tl(EA, EA, 4);
|
2013-12-20 11:01:50 +01:00
|
|
|
gen_qemu_ld32u_i64(ctx, xth, EA);
|
2013-11-01 14:21:14 +01:00
|
|
|
tcg_gen_deposit_i64(xth, xth, tmp, 32, 32);
|
|
|
|
|
|
|
|
tcg_gen_addi_tl(EA, EA, 4);
|
2013-12-20 11:01:50 +01:00
|
|
|
gen_qemu_ld32u_i64(ctx, tmp, EA);
|
2013-11-01 14:21:14 +01:00
|
|
|
tcg_gen_addi_tl(EA, EA, 4);
|
2013-12-20 11:01:50 +01:00
|
|
|
gen_qemu_ld32u_i64(ctx, xtl, EA);
|
2013-11-01 14:21:14 +01:00
|
|
|
tcg_gen_deposit_i64(xtl, xtl, tmp, 32, 32);
|
|
|
|
|
|
|
|
tcg_temp_free(EA);
|
2013-12-20 11:01:50 +01:00
|
|
|
tcg_temp_free_i64(tmp);
|
2013-11-01 14:21:14 +01:00
|
|
|
}
|
|
|
|
|
2014-01-15 15:10:31 +01:00
|
|
|
#define VSX_STORE_SCALAR(name, operation) \
|
|
|
|
static void gen_##name(DisasContext *ctx) \
|
|
|
|
{ \
|
|
|
|
TCGv EA; \
|
|
|
|
if (unlikely(!ctx->vsx_enabled)) { \
|
|
|
|
gen_exception(ctx, POWERPC_EXCP_VSXU); \
|
|
|
|
return; \
|
|
|
|
} \
|
|
|
|
gen_set_access_type(ctx, ACCESS_INT); \
|
|
|
|
EA = tcg_temp_new(); \
|
|
|
|
gen_addr_reg_index(ctx, EA); \
|
|
|
|
gen_qemu_##operation(ctx, cpu_vsrh(xS(ctx->opcode)), EA); \
|
|
|
|
tcg_temp_free(EA); \
|
2013-11-01 14:21:15 +01:00
|
|
|
}
|
|
|
|
|
2014-01-15 15:10:31 +01:00
|
|
|
VSX_STORE_SCALAR(stxsdx, st64)
|
2014-01-15 15:10:32 +01:00
|
|
|
VSX_STORE_SCALAR(stxsiwx, st32_i64)
|
|
|
|
VSX_STORE_SCALAR(stxsspx, st32fs)
|
2014-01-15 15:10:31 +01:00
|
|
|
|
2013-10-22 13:09:00 +02:00
|
|
|
static void gen_stxvd2x(DisasContext *ctx)
|
|
|
|
{
|
|
|
|
TCGv EA;
|
|
|
|
if (unlikely(!ctx->vsx_enabled)) {
|
|
|
|
gen_exception(ctx, POWERPC_EXCP_VSXU);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
gen_set_access_type(ctx, ACCESS_INT);
|
|
|
|
EA = tcg_temp_new();
|
|
|
|
gen_addr_reg_index(ctx, EA);
|
|
|
|
gen_qemu_st64(ctx, cpu_vsrh(xS(ctx->opcode)), EA);
|
|
|
|
tcg_gen_addi_tl(EA, EA, 8);
|
|
|
|
gen_qemu_st64(ctx, cpu_vsrl(xS(ctx->opcode)), EA);
|
|
|
|
tcg_temp_free(EA);
|
|
|
|
}
|
|
|
|
|
2013-11-01 14:21:16 +01:00
|
|
|
static void gen_stxvw4x(DisasContext *ctx)
|
|
|
|
{
|
2013-12-20 11:01:50 +01:00
|
|
|
TCGv_i64 tmp;
|
|
|
|
TCGv EA;
|
2013-11-01 14:21:16 +01:00
|
|
|
if (unlikely(!ctx->vsx_enabled)) {
|
|
|
|
gen_exception(ctx, POWERPC_EXCP_VSXU);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
gen_set_access_type(ctx, ACCESS_INT);
|
|
|
|
EA = tcg_temp_new();
|
|
|
|
gen_addr_reg_index(ctx, EA);
|
2013-12-20 11:01:50 +01:00
|
|
|
tmp = tcg_temp_new_i64();
|
2013-11-01 14:21:16 +01:00
|
|
|
|
|
|
|
tcg_gen_shri_i64(tmp, cpu_vsrh(xS(ctx->opcode)), 32);
|
2013-12-20 11:01:50 +01:00
|
|
|
gen_qemu_st32_i64(ctx, tmp, EA);
|
2013-11-01 14:21:16 +01:00
|
|
|
tcg_gen_addi_tl(EA, EA, 4);
|
2013-12-20 11:01:50 +01:00
|
|
|
gen_qemu_st32_i64(ctx, cpu_vsrh(xS(ctx->opcode)), EA);
|
2013-11-01 14:21:16 +01:00
|
|
|
|
|
|
|
tcg_gen_shri_i64(tmp, cpu_vsrl(xS(ctx->opcode)), 32);
|
|
|
|
tcg_gen_addi_tl(EA, EA, 4);
|
2013-12-20 11:01:50 +01:00
|
|
|
gen_qemu_st32_i64(ctx, tmp, EA);
|
2013-11-01 14:21:16 +01:00
|
|
|
tcg_gen_addi_tl(EA, EA, 4);
|
2013-12-20 11:01:50 +01:00
|
|
|
gen_qemu_st32_i64(ctx, cpu_vsrl(xS(ctx->opcode)), EA);
|
2013-11-01 14:21:16 +01:00
|
|
|
|
|
|
|
tcg_temp_free(EA);
|
2013-12-20 11:01:50 +01:00
|
|
|
tcg_temp_free_i64(tmp);
|
2013-11-01 14:21:16 +01:00
|
|
|
}
|
|
|
|
|
2014-01-15 15:10:42 +01:00
|
|
|
#define MV_VSRW(name, tcgop1, tcgop2, target, source) \
|
|
|
|
static void gen_##name(DisasContext *ctx) \
|
|
|
|
{ \
|
|
|
|
if (xS(ctx->opcode) < 32) { \
|
|
|
|
if (unlikely(!ctx->fpu_enabled)) { \
|
|
|
|
gen_exception(ctx, POWERPC_EXCP_FPU); \
|
|
|
|
return; \
|
|
|
|
} \
|
|
|
|
} else { \
|
|
|
|
if (unlikely(!ctx->altivec_enabled)) { \
|
|
|
|
gen_exception(ctx, POWERPC_EXCP_VPU); \
|
|
|
|
return; \
|
|
|
|
} \
|
|
|
|
} \
|
|
|
|
TCGv_i64 tmp = tcg_temp_new_i64(); \
|
|
|
|
tcg_gen_##tcgop1(tmp, source); \
|
|
|
|
tcg_gen_##tcgop2(target, tmp); \
|
|
|
|
tcg_temp_free_i64(tmp); \
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
MV_VSRW(mfvsrwz, ext32u_i64, trunc_i64_tl, cpu_gpr[rA(ctx->opcode)], \
|
|
|
|
cpu_vsrh(xS(ctx->opcode)))
|
|
|
|
MV_VSRW(mtvsrwa, extu_tl_i64, ext32s_i64, cpu_vsrh(xT(ctx->opcode)), \
|
|
|
|
cpu_gpr[rA(ctx->opcode)])
|
|
|
|
MV_VSRW(mtvsrwz, extu_tl_i64, ext32u_i64, cpu_vsrh(xT(ctx->opcode)), \
|
|
|
|
cpu_gpr[rA(ctx->opcode)])
|
|
|
|
|
|
|
|
#if defined(TARGET_PPC64)
|
|
|
|
#define MV_VSRD(name, target, source) \
|
|
|
|
static void gen_##name(DisasContext *ctx) \
|
|
|
|
{ \
|
|
|
|
if (xS(ctx->opcode) < 32) { \
|
|
|
|
if (unlikely(!ctx->fpu_enabled)) { \
|
|
|
|
gen_exception(ctx, POWERPC_EXCP_FPU); \
|
|
|
|
return; \
|
|
|
|
} \
|
|
|
|
} else { \
|
|
|
|
if (unlikely(!ctx->altivec_enabled)) { \
|
|
|
|
gen_exception(ctx, POWERPC_EXCP_VPU); \
|
|
|
|
return; \
|
|
|
|
} \
|
|
|
|
} \
|
|
|
|
tcg_gen_mov_i64(target, source); \
|
|
|
|
}
|
|
|
|
|
|
|
|
MV_VSRD(mfvsrd, cpu_gpr[rA(ctx->opcode)], cpu_vsrh(xS(ctx->opcode)))
|
|
|
|
MV_VSRD(mtvsrd, cpu_vsrh(xT(ctx->opcode)), cpu_gpr[rA(ctx->opcode)])
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2013-10-22 13:09:35 +02:00
|
|
|
static void gen_xxpermdi(DisasContext *ctx)
|
|
|
|
{
|
|
|
|
if (unlikely(!ctx->vsx_enabled)) {
|
|
|
|
gen_exception(ctx, POWERPC_EXCP_VSXU);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-02-10 18:25:09 +01:00
|
|
|
if (unlikely((xT(ctx->opcode) == xA(ctx->opcode)) ||
|
|
|
|
(xT(ctx->opcode) == xB(ctx->opcode)))) {
|
|
|
|
TCGv_i64 xh, xl;
|
|
|
|
|
|
|
|
xh = tcg_temp_new_i64();
|
|
|
|
xl = tcg_temp_new_i64();
|
|
|
|
|
|
|
|
if ((DM(ctx->opcode) & 2) == 0) {
|
|
|
|
tcg_gen_mov_i64(xh, cpu_vsrh(xA(ctx->opcode)));
|
|
|
|
} else {
|
|
|
|
tcg_gen_mov_i64(xh, cpu_vsrl(xA(ctx->opcode)));
|
|
|
|
}
|
|
|
|
if ((DM(ctx->opcode) & 1) == 0) {
|
|
|
|
tcg_gen_mov_i64(xl, cpu_vsrh(xB(ctx->opcode)));
|
|
|
|
} else {
|
|
|
|
tcg_gen_mov_i64(xl, cpu_vsrl(xB(ctx->opcode)));
|
|
|
|
}
|
|
|
|
|
|
|
|
tcg_gen_mov_i64(cpu_vsrh(xT(ctx->opcode)), xh);
|
|
|
|
tcg_gen_mov_i64(cpu_vsrl(xT(ctx->opcode)), xl);
|
|
|
|
|
|
|
|
tcg_temp_free_i64(xh);
|
|
|
|
tcg_temp_free_i64(xl);
|
2013-10-22 13:09:35 +02:00
|
|
|
} else {
|
2014-02-10 18:25:09 +01:00
|
|
|
if ((DM(ctx->opcode) & 2) == 0) {
|
|
|
|
tcg_gen_mov_i64(cpu_vsrh(xT(ctx->opcode)), cpu_vsrh(xA(ctx->opcode)));
|
|
|
|
} else {
|
|
|
|
tcg_gen_mov_i64(cpu_vsrh(xT(ctx->opcode)), cpu_vsrl(xA(ctx->opcode)));
|
|
|
|
}
|
|
|
|
if ((DM(ctx->opcode) & 1) == 0) {
|
|
|
|
tcg_gen_mov_i64(cpu_vsrl(xT(ctx->opcode)), cpu_vsrh(xB(ctx->opcode)));
|
|
|
|
} else {
|
|
|
|
tcg_gen_mov_i64(cpu_vsrl(xT(ctx->opcode)), cpu_vsrl(xB(ctx->opcode)));
|
|
|
|
}
|
2013-10-22 13:09:35 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-11-01 14:21:17 +01:00
|
|
|
#define OP_ABS 1
|
|
|
|
#define OP_NABS 2
|
|
|
|
#define OP_NEG 3
|
|
|
|
#define OP_CPSGN 4
|
2014-02-20 20:47:27 +01:00
|
|
|
#define SGN_MASK_DP 0x8000000000000000ull
|
|
|
|
#define SGN_MASK_SP 0x8000000080000000ull
|
2013-11-01 14:21:17 +01:00
|
|
|
|
|
|
|
#define VSX_SCALAR_MOVE(name, op, sgn_mask) \
|
|
|
|
static void glue(gen_, name)(DisasContext * ctx) \
|
|
|
|
{ \
|
|
|
|
TCGv_i64 xb, sgm; \
|
|
|
|
if (unlikely(!ctx->vsx_enabled)) { \
|
|
|
|
gen_exception(ctx, POWERPC_EXCP_VSXU); \
|
|
|
|
return; \
|
|
|
|
} \
|
2013-12-20 11:01:50 +01:00
|
|
|
xb = tcg_temp_new_i64(); \
|
|
|
|
sgm = tcg_temp_new_i64(); \
|
2013-11-01 14:21:17 +01:00
|
|
|
tcg_gen_mov_i64(xb, cpu_vsrh(xB(ctx->opcode))); \
|
|
|
|
tcg_gen_movi_i64(sgm, sgn_mask); \
|
|
|
|
switch (op) { \
|
|
|
|
case OP_ABS: { \
|
|
|
|
tcg_gen_andc_i64(xb, xb, sgm); \
|
|
|
|
break; \
|
|
|
|
} \
|
|
|
|
case OP_NABS: { \
|
|
|
|
tcg_gen_or_i64(xb, xb, sgm); \
|
|
|
|
break; \
|
|
|
|
} \
|
|
|
|
case OP_NEG: { \
|
|
|
|
tcg_gen_xor_i64(xb, xb, sgm); \
|
|
|
|
break; \
|
|
|
|
} \
|
|
|
|
case OP_CPSGN: { \
|
2013-12-20 11:01:50 +01:00
|
|
|
TCGv_i64 xa = tcg_temp_new_i64(); \
|
2013-11-01 14:21:17 +01:00
|
|
|
tcg_gen_mov_i64(xa, cpu_vsrh(xA(ctx->opcode))); \
|
|
|
|
tcg_gen_and_i64(xa, xa, sgm); \
|
|
|
|
tcg_gen_andc_i64(xb, xb, sgm); \
|
|
|
|
tcg_gen_or_i64(xb, xb, xa); \
|
2013-12-20 11:01:50 +01:00
|
|
|
tcg_temp_free_i64(xa); \
|
2013-11-01 14:21:17 +01:00
|
|
|
break; \
|
|
|
|
} \
|
|
|
|
} \
|
|
|
|
tcg_gen_mov_i64(cpu_vsrh(xT(ctx->opcode)), xb); \
|
2013-12-20 11:01:50 +01:00
|
|
|
tcg_temp_free_i64(xb); \
|
|
|
|
tcg_temp_free_i64(sgm); \
|
2013-11-01 14:21:17 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
VSX_SCALAR_MOVE(xsabsdp, OP_ABS, SGN_MASK_DP)
|
|
|
|
VSX_SCALAR_MOVE(xsnabsdp, OP_NABS, SGN_MASK_DP)
|
|
|
|
VSX_SCALAR_MOVE(xsnegdp, OP_NEG, SGN_MASK_DP)
|
|
|
|
VSX_SCALAR_MOVE(xscpsgndp, OP_CPSGN, SGN_MASK_DP)
|
|
|
|
|
2013-11-01 14:21:18 +01:00
|
|
|
#define VSX_VECTOR_MOVE(name, op, sgn_mask) \
|
|
|
|
static void glue(gen_, name)(DisasContext * ctx) \
|
|
|
|
{ \
|
|
|
|
TCGv_i64 xbh, xbl, sgm; \
|
|
|
|
if (unlikely(!ctx->vsx_enabled)) { \
|
|
|
|
gen_exception(ctx, POWERPC_EXCP_VSXU); \
|
|
|
|
return; \
|
|
|
|
} \
|
2013-12-20 11:01:50 +01:00
|
|
|
xbh = tcg_temp_new_i64(); \
|
|
|
|
xbl = tcg_temp_new_i64(); \
|
|
|
|
sgm = tcg_temp_new_i64(); \
|
2013-11-01 14:21:18 +01:00
|
|
|
tcg_gen_mov_i64(xbh, cpu_vsrh(xB(ctx->opcode))); \
|
|
|
|
tcg_gen_mov_i64(xbl, cpu_vsrl(xB(ctx->opcode))); \
|
|
|
|
tcg_gen_movi_i64(sgm, sgn_mask); \
|
|
|
|
switch (op) { \
|
|
|
|
case OP_ABS: { \
|
|
|
|
tcg_gen_andc_i64(xbh, xbh, sgm); \
|
|
|
|
tcg_gen_andc_i64(xbl, xbl, sgm); \
|
|
|
|
break; \
|
|
|
|
} \
|
|
|
|
case OP_NABS: { \
|
|
|
|
tcg_gen_or_i64(xbh, xbh, sgm); \
|
|
|
|
tcg_gen_or_i64(xbl, xbl, sgm); \
|
|
|
|
break; \
|
|
|
|
} \
|
|
|
|
case OP_NEG: { \
|
|
|
|
tcg_gen_xor_i64(xbh, xbh, sgm); \
|
|
|
|
tcg_gen_xor_i64(xbl, xbl, sgm); \
|
|
|
|
break; \
|
|
|
|
} \
|
|
|
|
case OP_CPSGN: { \
|
2013-12-20 11:01:50 +01:00
|
|
|
TCGv_i64 xah = tcg_temp_new_i64(); \
|
|
|
|
TCGv_i64 xal = tcg_temp_new_i64(); \
|
2013-11-01 14:21:18 +01:00
|
|
|
tcg_gen_mov_i64(xah, cpu_vsrh(xA(ctx->opcode))); \
|
|
|
|
tcg_gen_mov_i64(xal, cpu_vsrl(xA(ctx->opcode))); \
|
|
|
|
tcg_gen_and_i64(xah, xah, sgm); \
|
|
|
|
tcg_gen_and_i64(xal, xal, sgm); \
|
|
|
|
tcg_gen_andc_i64(xbh, xbh, sgm); \
|
|
|
|
tcg_gen_andc_i64(xbl, xbl, sgm); \
|
|
|
|
tcg_gen_or_i64(xbh, xbh, xah); \
|
|
|
|
tcg_gen_or_i64(xbl, xbl, xal); \
|
2013-12-20 11:01:50 +01:00
|
|
|
tcg_temp_free_i64(xah); \
|
|
|
|
tcg_temp_free_i64(xal); \
|
2013-11-01 14:21:18 +01:00
|
|
|
break; \
|
|
|
|
} \
|
|
|
|
} \
|
|
|
|
tcg_gen_mov_i64(cpu_vsrh(xT(ctx->opcode)), xbh); \
|
|
|
|
tcg_gen_mov_i64(cpu_vsrl(xT(ctx->opcode)), xbl); \
|
2013-12-20 11:01:50 +01:00
|
|
|
tcg_temp_free_i64(xbh); \
|
|
|
|
tcg_temp_free_i64(xbl); \
|
|
|
|
tcg_temp_free_i64(sgm); \
|
2013-11-01 14:21:18 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
VSX_VECTOR_MOVE(xvabsdp, OP_ABS, SGN_MASK_DP)
|
|
|
|
VSX_VECTOR_MOVE(xvnabsdp, OP_NABS, SGN_MASK_DP)
|
|
|
|
VSX_VECTOR_MOVE(xvnegdp, OP_NEG, SGN_MASK_DP)
|
|
|
|
VSX_VECTOR_MOVE(xvcpsgndp, OP_CPSGN, SGN_MASK_DP)
|
|
|
|
VSX_VECTOR_MOVE(xvabssp, OP_ABS, SGN_MASK_SP)
|
|
|
|
VSX_VECTOR_MOVE(xvnabssp, OP_NABS, SGN_MASK_SP)
|
|
|
|
VSX_VECTOR_MOVE(xvnegsp, OP_NEG, SGN_MASK_SP)
|
|
|
|
VSX_VECTOR_MOVE(xvcpsgnsp, OP_CPSGN, SGN_MASK_SP)
|
|
|
|
|
2014-01-02 23:21:20 +01:00
|
|
|
#define GEN_VSX_HELPER_2(name, op1, op2, inval, type) \
|
|
|
|
static void gen_##name(DisasContext * ctx) \
|
|
|
|
{ \
|
|
|
|
TCGv_i32 opc; \
|
|
|
|
if (unlikely(!ctx->vsx_enabled)) { \
|
|
|
|
gen_exception(ctx, POWERPC_EXCP_VSXU); \
|
|
|
|
return; \
|
|
|
|
} \
|
|
|
|
/* NIP cannot be restored if the memory exception comes from an helper */ \
|
|
|
|
gen_update_nip(ctx, ctx->nip - 4); \
|
|
|
|
opc = tcg_const_i32(ctx->opcode); \
|
|
|
|
gen_helper_##name(cpu_env, opc); \
|
|
|
|
tcg_temp_free_i32(opc); \
|
|
|
|
}
|
2013-11-01 14:21:18 +01:00
|
|
|
|
2014-01-15 15:10:44 +01:00
|
|
|
#define GEN_VSX_HELPER_XT_XB_ENV(name, op1, op2, inval, type) \
|
|
|
|
static void gen_##name(DisasContext * ctx) \
|
|
|
|
{ \
|
|
|
|
if (unlikely(!ctx->vsx_enabled)) { \
|
|
|
|
gen_exception(ctx, POWERPC_EXCP_VSXU); \
|
|
|
|
return; \
|
|
|
|
} \
|
|
|
|
/* NIP cannot be restored if the exception comes */ \
|
|
|
|
/* from a helper. */ \
|
|
|
|
gen_update_nip(ctx, ctx->nip - 4); \
|
|
|
|
\
|
|
|
|
gen_helper_##name(cpu_vsrh(xT(ctx->opcode)), cpu_env, \
|
|
|
|
cpu_vsrh(xB(ctx->opcode))); \
|
|
|
|
}
|
|
|
|
|
2014-01-02 23:21:21 +01:00
|
|
|
GEN_VSX_HELPER_2(xsadddp, 0x00, 0x04, 0, PPC2_VSX)
|
|
|
|
GEN_VSX_HELPER_2(xssubdp, 0x00, 0x05, 0, PPC2_VSX)
|
2014-01-02 23:21:22 +01:00
|
|
|
GEN_VSX_HELPER_2(xsmuldp, 0x00, 0x06, 0, PPC2_VSX)
|
2014-01-02 23:21:23 +01:00
|
|
|
GEN_VSX_HELPER_2(xsdivdp, 0x00, 0x07, 0, PPC2_VSX)
|
2014-01-02 23:21:24 +01:00
|
|
|
GEN_VSX_HELPER_2(xsredp, 0x14, 0x05, 0, PPC2_VSX)
|
2014-01-02 23:21:25 +01:00
|
|
|
GEN_VSX_HELPER_2(xssqrtdp, 0x16, 0x04, 0, PPC2_VSX)
|
2014-01-02 23:21:26 +01:00
|
|
|
GEN_VSX_HELPER_2(xsrsqrtedp, 0x14, 0x04, 0, PPC2_VSX)
|
2014-01-02 23:21:27 +01:00
|
|
|
GEN_VSX_HELPER_2(xstdivdp, 0x14, 0x07, 0, PPC2_VSX)
|
2014-01-02 23:21:28 +01:00
|
|
|
GEN_VSX_HELPER_2(xstsqrtdp, 0x14, 0x06, 0, PPC2_VSX)
|
target-ppc: Add VSX ISA2.06 Multiply Add Instructions
This patch adds the VSX floating point multiply/add instructions
defined by V2.06 of the PowerPC ISA:
- xsmaddadp, xvmaddadp, xvmaddasp
- xsmaddmdp, xvmaddmdp, xvmaddmsp
- xsmsubadp, xvmsubadp, xvmsubasp
- xsmsubmdp, xvmsubmdp, xvmsubmsp
- xsnmaddadp, xvnmaddadp, xvnmaddasp
- xsnmaddmdp, xvnmaddmdp, xvnmaddmsp
- xsnmsubadp, xvnmsubadp, xvnmsubasp
- xsnmsubmdp, xvnmsubmdp, xvnmsubmsp
Signed-off-by: Tom Musta <tommusta@gmail.com>
Reviewed-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Alexander Graf <agraf@suse.de>
2014-01-02 23:21:29 +01:00
|
|
|
GEN_VSX_HELPER_2(xsmaddadp, 0x04, 0x04, 0, PPC2_VSX)
|
|
|
|
GEN_VSX_HELPER_2(xsmaddmdp, 0x04, 0x05, 0, PPC2_VSX)
|
|
|
|
GEN_VSX_HELPER_2(xsmsubadp, 0x04, 0x06, 0, PPC2_VSX)
|
|
|
|
GEN_VSX_HELPER_2(xsmsubmdp, 0x04, 0x07, 0, PPC2_VSX)
|
|
|
|
GEN_VSX_HELPER_2(xsnmaddadp, 0x04, 0x14, 0, PPC2_VSX)
|
|
|
|
GEN_VSX_HELPER_2(xsnmaddmdp, 0x04, 0x15, 0, PPC2_VSX)
|
|
|
|
GEN_VSX_HELPER_2(xsnmsubadp, 0x04, 0x16, 0, PPC2_VSX)
|
|
|
|
GEN_VSX_HELPER_2(xsnmsubmdp, 0x04, 0x17, 0, PPC2_VSX)
|
2014-01-02 23:21:30 +01:00
|
|
|
GEN_VSX_HELPER_2(xscmpodp, 0x0C, 0x05, 0, PPC2_VSX)
|
|
|
|
GEN_VSX_HELPER_2(xscmpudp, 0x0C, 0x04, 0, PPC2_VSX)
|
2014-01-02 23:21:31 +01:00
|
|
|
GEN_VSX_HELPER_2(xsmaxdp, 0x00, 0x14, 0, PPC2_VSX)
|
|
|
|
GEN_VSX_HELPER_2(xsmindp, 0x00, 0x15, 0, PPC2_VSX)
|
2014-01-02 23:21:33 +01:00
|
|
|
GEN_VSX_HELPER_2(xscvdpsp, 0x12, 0x10, 0, PPC2_VSX)
|
2014-01-15 15:10:45 +01:00
|
|
|
GEN_VSX_HELPER_XT_XB_ENV(xscvdpspn, 0x16, 0x10, 0, PPC2_VSX207)
|
2014-01-02 23:21:33 +01:00
|
|
|
GEN_VSX_HELPER_2(xscvspdp, 0x12, 0x14, 0, PPC2_VSX)
|
2014-01-15 15:10:45 +01:00
|
|
|
GEN_VSX_HELPER_XT_XB_ENV(xscvspdpn, 0x16, 0x14, 0, PPC2_VSX207)
|
target-ppc: Add VSX ISA2.06 Integer Conversion Instructions
This patch adds the VSX Integer Conversion instructions defined by
V2.06 of the PowerPC ISA:
- xscvdpsxds, xscvdpsxws, xscvdpuxds, xscvdpuxws
- xvcvdpsxds, xvcvdpsxws, xvcvdpuxds, xvcvdpuxws
- xvcvspsxds, xvcvspsxws, xvcvspuxds, xvcvspuxws
- xscvsxddp, xscvuxddp
- xvcvsxddp, xscvsxwdp, xvcvuxddp, xvcvuxwdp
- xvcvsxdsp, xscvsxwsp, xvcvuxdsp, xvcvuxwsp
Signed-off-by: Tom Musta <tommusta@gmail.com>
Reviewed-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Alexander Graf <agraf@suse.de>
2014-01-02 23:21:34 +01:00
|
|
|
GEN_VSX_HELPER_2(xscvdpsxds, 0x10, 0x15, 0, PPC2_VSX)
|
|
|
|
GEN_VSX_HELPER_2(xscvdpsxws, 0x10, 0x05, 0, PPC2_VSX)
|
|
|
|
GEN_VSX_HELPER_2(xscvdpuxds, 0x10, 0x14, 0, PPC2_VSX)
|
|
|
|
GEN_VSX_HELPER_2(xscvdpuxws, 0x10, 0x04, 0, PPC2_VSX)
|
|
|
|
GEN_VSX_HELPER_2(xscvsxddp, 0x10, 0x17, 0, PPC2_VSX)
|
|
|
|
GEN_VSX_HELPER_2(xscvuxddp, 0x10, 0x16, 0, PPC2_VSX)
|
target-ppc: Add VSX Rounding Instructions
This patch adds the VSX Round to Floating Point Integer instructions:
- xsrdpi, xsrdpic, xsrdpim, xsrdpip, xsrdpiz
- xvrdpi, xvrdpic, xvrdpim, xvrdpip, xvrdpiz
- xvrspi, xvrspic, xvrspim, xvrspip, xvrspiz
Signed-off-by: Tom Musta <tommusta@gmail.com>
Reviewed-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Alexander Graf <agraf@suse.de>
2014-01-02 23:21:35 +01:00
|
|
|
GEN_VSX_HELPER_2(xsrdpi, 0x12, 0x04, 0, PPC2_VSX)
|
|
|
|
GEN_VSX_HELPER_2(xsrdpic, 0x16, 0x06, 0, PPC2_VSX)
|
|
|
|
GEN_VSX_HELPER_2(xsrdpim, 0x12, 0x07, 0, PPC2_VSX)
|
|
|
|
GEN_VSX_HELPER_2(xsrdpip, 0x12, 0x06, 0, PPC2_VSX)
|
|
|
|
GEN_VSX_HELPER_2(xsrdpiz, 0x12, 0x05, 0, PPC2_VSX)
|
2014-01-15 15:10:44 +01:00
|
|
|
GEN_VSX_HELPER_XT_XB_ENV(xsrsp, 0x12, 0x11, 0, PPC2_VSX207)
|
2014-01-02 23:21:21 +01:00
|
|
|
|
2014-01-15 15:10:33 +01:00
|
|
|
GEN_VSX_HELPER_2(xsaddsp, 0x00, 0x00, 0, PPC2_VSX207)
|
|
|
|
GEN_VSX_HELPER_2(xssubsp, 0x00, 0x01, 0, PPC2_VSX207)
|
2014-01-15 15:10:34 +01:00
|
|
|
GEN_VSX_HELPER_2(xsmulsp, 0x00, 0x02, 0, PPC2_VSX207)
|
2014-01-15 15:10:35 +01:00
|
|
|
GEN_VSX_HELPER_2(xsdivsp, 0x00, 0x03, 0, PPC2_VSX207)
|
2014-01-15 15:10:36 +01:00
|
|
|
GEN_VSX_HELPER_2(xsresp, 0x14, 0x01, 0, PPC2_VSX207)
|
2014-01-15 15:10:37 +01:00
|
|
|
GEN_VSX_HELPER_2(xssqrtsp, 0x16, 0x00, 0, PPC2_VSX207)
|
2014-01-15 15:10:38 +01:00
|
|
|
GEN_VSX_HELPER_2(xsrsqrtesp, 0x14, 0x00, 0, PPC2_VSX207)
|
2014-01-15 15:10:39 +01:00
|
|
|
GEN_VSX_HELPER_2(xsmaddasp, 0x04, 0x00, 0, PPC2_VSX207)
|
|
|
|
GEN_VSX_HELPER_2(xsmaddmsp, 0x04, 0x01, 0, PPC2_VSX207)
|
|
|
|
GEN_VSX_HELPER_2(xsmsubasp, 0x04, 0x02, 0, PPC2_VSX207)
|
|
|
|
GEN_VSX_HELPER_2(xsmsubmsp, 0x04, 0x03, 0, PPC2_VSX207)
|
|
|
|
GEN_VSX_HELPER_2(xsnmaddasp, 0x04, 0x10, 0, PPC2_VSX207)
|
|
|
|
GEN_VSX_HELPER_2(xsnmaddmsp, 0x04, 0x11, 0, PPC2_VSX207)
|
|
|
|
GEN_VSX_HELPER_2(xsnmsubasp, 0x04, 0x12, 0, PPC2_VSX207)
|
|
|
|
GEN_VSX_HELPER_2(xsnmsubmsp, 0x04, 0x13, 0, PPC2_VSX207)
|
2014-01-15 15:10:40 +01:00
|
|
|
GEN_VSX_HELPER_2(xscvsxdsp, 0x10, 0x13, 0, PPC2_VSX207)
|
|
|
|
GEN_VSX_HELPER_2(xscvuxdsp, 0x10, 0x12, 0, PPC2_VSX207)
|
2014-01-15 15:10:33 +01:00
|
|
|
|
2014-01-02 23:21:21 +01:00
|
|
|
GEN_VSX_HELPER_2(xvadddp, 0x00, 0x0C, 0, PPC2_VSX)
|
|
|
|
GEN_VSX_HELPER_2(xvsubdp, 0x00, 0x0D, 0, PPC2_VSX)
|
2014-01-02 23:21:22 +01:00
|
|
|
GEN_VSX_HELPER_2(xvmuldp, 0x00, 0x0E, 0, PPC2_VSX)
|
2014-01-02 23:21:23 +01:00
|
|
|
GEN_VSX_HELPER_2(xvdivdp, 0x00, 0x0F, 0, PPC2_VSX)
|
2014-01-02 23:21:24 +01:00
|
|
|
GEN_VSX_HELPER_2(xvredp, 0x14, 0x0D, 0, PPC2_VSX)
|
2014-01-02 23:21:25 +01:00
|
|
|
GEN_VSX_HELPER_2(xvsqrtdp, 0x16, 0x0C, 0, PPC2_VSX)
|
2014-01-02 23:21:26 +01:00
|
|
|
GEN_VSX_HELPER_2(xvrsqrtedp, 0x14, 0x0C, 0, PPC2_VSX)
|
2014-01-02 23:21:27 +01:00
|
|
|
GEN_VSX_HELPER_2(xvtdivdp, 0x14, 0x0F, 0, PPC2_VSX)
|
2014-01-02 23:21:28 +01:00
|
|
|
GEN_VSX_HELPER_2(xvtsqrtdp, 0x14, 0x0E, 0, PPC2_VSX)
|
target-ppc: Add VSX ISA2.06 Multiply Add Instructions
This patch adds the VSX floating point multiply/add instructions
defined by V2.06 of the PowerPC ISA:
- xsmaddadp, xvmaddadp, xvmaddasp
- xsmaddmdp, xvmaddmdp, xvmaddmsp
- xsmsubadp, xvmsubadp, xvmsubasp
- xsmsubmdp, xvmsubmdp, xvmsubmsp
- xsnmaddadp, xvnmaddadp, xvnmaddasp
- xsnmaddmdp, xvnmaddmdp, xvnmaddmsp
- xsnmsubadp, xvnmsubadp, xvnmsubasp
- xsnmsubmdp, xvnmsubmdp, xvnmsubmsp
Signed-off-by: Tom Musta <tommusta@gmail.com>
Reviewed-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Alexander Graf <agraf@suse.de>
2014-01-02 23:21:29 +01:00
|
|
|
GEN_VSX_HELPER_2(xvmaddadp, 0x04, 0x0C, 0, PPC2_VSX)
|
|
|
|
GEN_VSX_HELPER_2(xvmaddmdp, 0x04, 0x0D, 0, PPC2_VSX)
|
|
|
|
GEN_VSX_HELPER_2(xvmsubadp, 0x04, 0x0E, 0, PPC2_VSX)
|
|
|
|
GEN_VSX_HELPER_2(xvmsubmdp, 0x04, 0x0F, 0, PPC2_VSX)
|
|
|
|
GEN_VSX_HELPER_2(xvnmaddadp, 0x04, 0x1C, 0, PPC2_VSX)
|
|
|
|
GEN_VSX_HELPER_2(xvnmaddmdp, 0x04, 0x1D, 0, PPC2_VSX)
|
|
|
|
GEN_VSX_HELPER_2(xvnmsubadp, 0x04, 0x1E, 0, PPC2_VSX)
|
|
|
|
GEN_VSX_HELPER_2(xvnmsubmdp, 0x04, 0x1F, 0, PPC2_VSX)
|
2014-01-02 23:21:31 +01:00
|
|
|
GEN_VSX_HELPER_2(xvmaxdp, 0x00, 0x1C, 0, PPC2_VSX)
|
|
|
|
GEN_VSX_HELPER_2(xvmindp, 0x00, 0x1D, 0, PPC2_VSX)
|
2014-01-02 23:21:32 +01:00
|
|
|
GEN_VSX_HELPER_2(xvcmpeqdp, 0x0C, 0x0C, 0, PPC2_VSX)
|
|
|
|
GEN_VSX_HELPER_2(xvcmpgtdp, 0x0C, 0x0D, 0, PPC2_VSX)
|
|
|
|
GEN_VSX_HELPER_2(xvcmpgedp, 0x0C, 0x0E, 0, PPC2_VSX)
|
2014-01-02 23:21:33 +01:00
|
|
|
GEN_VSX_HELPER_2(xvcvdpsp, 0x12, 0x18, 0, PPC2_VSX)
|
target-ppc: Add VSX ISA2.06 Integer Conversion Instructions
This patch adds the VSX Integer Conversion instructions defined by
V2.06 of the PowerPC ISA:
- xscvdpsxds, xscvdpsxws, xscvdpuxds, xscvdpuxws
- xvcvdpsxds, xvcvdpsxws, xvcvdpuxds, xvcvdpuxws
- xvcvspsxds, xvcvspsxws, xvcvspuxds, xvcvspuxws
- xscvsxddp, xscvuxddp
- xvcvsxddp, xscvsxwdp, xvcvuxddp, xvcvuxwdp
- xvcvsxdsp, xscvsxwsp, xvcvuxdsp, xvcvuxwsp
Signed-off-by: Tom Musta <tommusta@gmail.com>
Reviewed-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Alexander Graf <agraf@suse.de>
2014-01-02 23:21:34 +01:00
|
|
|
GEN_VSX_HELPER_2(xvcvdpsxds, 0x10, 0x1D, 0, PPC2_VSX)
|
|
|
|
GEN_VSX_HELPER_2(xvcvdpsxws, 0x10, 0x0D, 0, PPC2_VSX)
|
|
|
|
GEN_VSX_HELPER_2(xvcvdpuxds, 0x10, 0x1C, 0, PPC2_VSX)
|
|
|
|
GEN_VSX_HELPER_2(xvcvdpuxws, 0x10, 0x0C, 0, PPC2_VSX)
|
|
|
|
GEN_VSX_HELPER_2(xvcvsxddp, 0x10, 0x1F, 0, PPC2_VSX)
|
|
|
|
GEN_VSX_HELPER_2(xvcvuxddp, 0x10, 0x1E, 0, PPC2_VSX)
|
|
|
|
GEN_VSX_HELPER_2(xvcvsxwdp, 0x10, 0x0F, 0, PPC2_VSX)
|
|
|
|
GEN_VSX_HELPER_2(xvcvuxwdp, 0x10, 0x0E, 0, PPC2_VSX)
|
target-ppc: Add VSX Rounding Instructions
This patch adds the VSX Round to Floating Point Integer instructions:
- xsrdpi, xsrdpic, xsrdpim, xsrdpip, xsrdpiz
- xvrdpi, xvrdpic, xvrdpim, xvrdpip, xvrdpiz
- xvrspi, xvrspic, xvrspim, xvrspip, xvrspiz
Signed-off-by: Tom Musta <tommusta@gmail.com>
Reviewed-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Alexander Graf <agraf@suse.de>
2014-01-02 23:21:35 +01:00
|
|
|
GEN_VSX_HELPER_2(xvrdpi, 0x12, 0x0C, 0, PPC2_VSX)
|
|
|
|
GEN_VSX_HELPER_2(xvrdpic, 0x16, 0x0E, 0, PPC2_VSX)
|
|
|
|
GEN_VSX_HELPER_2(xvrdpim, 0x12, 0x0F, 0, PPC2_VSX)
|
|
|
|
GEN_VSX_HELPER_2(xvrdpip, 0x12, 0x0E, 0, PPC2_VSX)
|
|
|
|
GEN_VSX_HELPER_2(xvrdpiz, 0x12, 0x0D, 0, PPC2_VSX)
|
2014-01-02 23:21:21 +01:00
|
|
|
|
|
|
|
GEN_VSX_HELPER_2(xvaddsp, 0x00, 0x08, 0, PPC2_VSX)
|
|
|
|
GEN_VSX_HELPER_2(xvsubsp, 0x00, 0x09, 0, PPC2_VSX)
|
2014-01-02 23:21:22 +01:00
|
|
|
GEN_VSX_HELPER_2(xvmulsp, 0x00, 0x0A, 0, PPC2_VSX)
|
2014-01-02 23:21:23 +01:00
|
|
|
GEN_VSX_HELPER_2(xvdivsp, 0x00, 0x0B, 0, PPC2_VSX)
|
2014-01-02 23:21:24 +01:00
|
|
|
GEN_VSX_HELPER_2(xvresp, 0x14, 0x09, 0, PPC2_VSX)
|
2014-01-02 23:21:25 +01:00
|
|
|
GEN_VSX_HELPER_2(xvsqrtsp, 0x16, 0x08, 0, PPC2_VSX)
|
2014-01-02 23:21:26 +01:00
|
|
|
GEN_VSX_HELPER_2(xvrsqrtesp, 0x14, 0x08, 0, PPC2_VSX)
|
2014-01-02 23:21:27 +01:00
|
|
|
GEN_VSX_HELPER_2(xvtdivsp, 0x14, 0x0B, 0, PPC2_VSX)
|
2014-01-02 23:21:28 +01:00
|
|
|
GEN_VSX_HELPER_2(xvtsqrtsp, 0x14, 0x0A, 0, PPC2_VSX)
|
target-ppc: Add VSX ISA2.06 Multiply Add Instructions
This patch adds the VSX floating point multiply/add instructions
defined by V2.06 of the PowerPC ISA:
- xsmaddadp, xvmaddadp, xvmaddasp
- xsmaddmdp, xvmaddmdp, xvmaddmsp
- xsmsubadp, xvmsubadp, xvmsubasp
- xsmsubmdp, xvmsubmdp, xvmsubmsp
- xsnmaddadp, xvnmaddadp, xvnmaddasp
- xsnmaddmdp, xvnmaddmdp, xvnmaddmsp
- xsnmsubadp, xvnmsubadp, xvnmsubasp
- xsnmsubmdp, xvnmsubmdp, xvnmsubmsp
Signed-off-by: Tom Musta <tommusta@gmail.com>
Reviewed-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Alexander Graf <agraf@suse.de>
2014-01-02 23:21:29 +01:00
|
|
|
GEN_VSX_HELPER_2(xvmaddasp, 0x04, 0x08, 0, PPC2_VSX)
|
|
|
|
GEN_VSX_HELPER_2(xvmaddmsp, 0x04, 0x09, 0, PPC2_VSX)
|
|
|
|
GEN_VSX_HELPER_2(xvmsubasp, 0x04, 0x0A, 0, PPC2_VSX)
|
|
|
|
GEN_VSX_HELPER_2(xvmsubmsp, 0x04, 0x0B, 0, PPC2_VSX)
|
|
|
|
GEN_VSX_HELPER_2(xvnmaddasp, 0x04, 0x18, 0, PPC2_VSX)
|
|
|
|
GEN_VSX_HELPER_2(xvnmaddmsp, 0x04, 0x19, 0, PPC2_VSX)
|
|
|
|
GEN_VSX_HELPER_2(xvnmsubasp, 0x04, 0x1A, 0, PPC2_VSX)
|
|
|
|
GEN_VSX_HELPER_2(xvnmsubmsp, 0x04, 0x1B, 0, PPC2_VSX)
|
2014-01-02 23:21:31 +01:00
|
|
|
GEN_VSX_HELPER_2(xvmaxsp, 0x00, 0x18, 0, PPC2_VSX)
|
|
|
|
GEN_VSX_HELPER_2(xvminsp, 0x00, 0x19, 0, PPC2_VSX)
|
2014-01-02 23:21:32 +01:00
|
|
|
GEN_VSX_HELPER_2(xvcmpeqsp, 0x0C, 0x08, 0, PPC2_VSX)
|
|
|
|
GEN_VSX_HELPER_2(xvcmpgtsp, 0x0C, 0x09, 0, PPC2_VSX)
|
|
|
|
GEN_VSX_HELPER_2(xvcmpgesp, 0x0C, 0x0A, 0, PPC2_VSX)
|
2014-01-02 23:21:33 +01:00
|
|
|
GEN_VSX_HELPER_2(xvcvspdp, 0x12, 0x1C, 0, PPC2_VSX)
|
target-ppc: Add VSX ISA2.06 Integer Conversion Instructions
This patch adds the VSX Integer Conversion instructions defined by
V2.06 of the PowerPC ISA:
- xscvdpsxds, xscvdpsxws, xscvdpuxds, xscvdpuxws
- xvcvdpsxds, xvcvdpsxws, xvcvdpuxds, xvcvdpuxws
- xvcvspsxds, xvcvspsxws, xvcvspuxds, xvcvspuxws
- xscvsxddp, xscvuxddp
- xvcvsxddp, xscvsxwdp, xvcvuxddp, xvcvuxwdp
- xvcvsxdsp, xscvsxwsp, xvcvuxdsp, xvcvuxwsp
Signed-off-by: Tom Musta <tommusta@gmail.com>
Reviewed-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Alexander Graf <agraf@suse.de>
2014-01-02 23:21:34 +01:00
|
|
|
GEN_VSX_HELPER_2(xvcvspsxds, 0x10, 0x19, 0, PPC2_VSX)
|
|
|
|
GEN_VSX_HELPER_2(xvcvspsxws, 0x10, 0x09, 0, PPC2_VSX)
|
|
|
|
GEN_VSX_HELPER_2(xvcvspuxds, 0x10, 0x18, 0, PPC2_VSX)
|
|
|
|
GEN_VSX_HELPER_2(xvcvspuxws, 0x10, 0x08, 0, PPC2_VSX)
|
|
|
|
GEN_VSX_HELPER_2(xvcvsxdsp, 0x10, 0x1B, 0, PPC2_VSX)
|
|
|
|
GEN_VSX_HELPER_2(xvcvuxdsp, 0x10, 0x1A, 0, PPC2_VSX)
|
|
|
|
GEN_VSX_HELPER_2(xvcvsxwsp, 0x10, 0x0B, 0, PPC2_VSX)
|
|
|
|
GEN_VSX_HELPER_2(xvcvuxwsp, 0x10, 0x0A, 0, PPC2_VSX)
|
target-ppc: Add VSX Rounding Instructions
This patch adds the VSX Round to Floating Point Integer instructions:
- xsrdpi, xsrdpic, xsrdpim, xsrdpip, xsrdpiz
- xvrdpi, xvrdpic, xvrdpim, xvrdpip, xvrdpiz
- xvrspi, xvrspic, xvrspim, xvrspip, xvrspiz
Signed-off-by: Tom Musta <tommusta@gmail.com>
Reviewed-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Alexander Graf <agraf@suse.de>
2014-01-02 23:21:35 +01:00
|
|
|
GEN_VSX_HELPER_2(xvrspi, 0x12, 0x08, 0, PPC2_VSX)
|
|
|
|
GEN_VSX_HELPER_2(xvrspic, 0x16, 0x0A, 0, PPC2_VSX)
|
|
|
|
GEN_VSX_HELPER_2(xvrspim, 0x12, 0x0B, 0, PPC2_VSX)
|
|
|
|
GEN_VSX_HELPER_2(xvrspip, 0x12, 0x0A, 0, PPC2_VSX)
|
|
|
|
GEN_VSX_HELPER_2(xvrspiz, 0x12, 0x09, 0, PPC2_VSX)
|
2014-01-02 23:21:21 +01:00
|
|
|
|
2013-11-01 14:21:19 +01:00
|
|
|
#define VSX_LOGICAL(name, tcg_op) \
|
|
|
|
static void glue(gen_, name)(DisasContext * ctx) \
|
|
|
|
{ \
|
|
|
|
if (unlikely(!ctx->vsx_enabled)) { \
|
|
|
|
gen_exception(ctx, POWERPC_EXCP_VSXU); \
|
|
|
|
return; \
|
|
|
|
} \
|
|
|
|
tcg_op(cpu_vsrh(xT(ctx->opcode)), cpu_vsrh(xA(ctx->opcode)), \
|
|
|
|
cpu_vsrh(xB(ctx->opcode))); \
|
|
|
|
tcg_op(cpu_vsrl(xT(ctx->opcode)), cpu_vsrl(xA(ctx->opcode)), \
|
|
|
|
cpu_vsrl(xB(ctx->opcode))); \
|
|
|
|
}
|
|
|
|
|
2013-12-20 11:01:50 +01:00
|
|
|
VSX_LOGICAL(xxland, tcg_gen_and_i64)
|
|
|
|
VSX_LOGICAL(xxlandc, tcg_gen_andc_i64)
|
|
|
|
VSX_LOGICAL(xxlor, tcg_gen_or_i64)
|
|
|
|
VSX_LOGICAL(xxlxor, tcg_gen_xor_i64)
|
|
|
|
VSX_LOGICAL(xxlnor, tcg_gen_nor_i64)
|
2014-01-15 15:10:41 +01:00
|
|
|
VSX_LOGICAL(xxleqv, tcg_gen_eqv_i64)
|
|
|
|
VSX_LOGICAL(xxlnand, tcg_gen_nand_i64)
|
|
|
|
VSX_LOGICAL(xxlorc, tcg_gen_orc_i64)
|
2013-11-01 14:21:17 +01:00
|
|
|
|
2013-11-01 14:21:20 +01:00
|
|
|
#define VSX_XXMRG(name, high) \
|
|
|
|
static void glue(gen_, name)(DisasContext * ctx) \
|
|
|
|
{ \
|
|
|
|
TCGv_i64 a0, a1, b0, b1; \
|
|
|
|
if (unlikely(!ctx->vsx_enabled)) { \
|
|
|
|
gen_exception(ctx, POWERPC_EXCP_VSXU); \
|
|
|
|
return; \
|
|
|
|
} \
|
2013-12-20 11:01:50 +01:00
|
|
|
a0 = tcg_temp_new_i64(); \
|
|
|
|
a1 = tcg_temp_new_i64(); \
|
|
|
|
b0 = tcg_temp_new_i64(); \
|
|
|
|
b1 = tcg_temp_new_i64(); \
|
2013-11-01 14:21:20 +01:00
|
|
|
if (high) { \
|
|
|
|
tcg_gen_mov_i64(a0, cpu_vsrh(xA(ctx->opcode))); \
|
|
|
|
tcg_gen_mov_i64(a1, cpu_vsrh(xA(ctx->opcode))); \
|
|
|
|
tcg_gen_mov_i64(b0, cpu_vsrh(xB(ctx->opcode))); \
|
|
|
|
tcg_gen_mov_i64(b1, cpu_vsrh(xB(ctx->opcode))); \
|
|
|
|
} else { \
|
|
|
|
tcg_gen_mov_i64(a0, cpu_vsrl(xA(ctx->opcode))); \
|
|
|
|
tcg_gen_mov_i64(a1, cpu_vsrl(xA(ctx->opcode))); \
|
|
|
|
tcg_gen_mov_i64(b0, cpu_vsrl(xB(ctx->opcode))); \
|
|
|
|
tcg_gen_mov_i64(b1, cpu_vsrl(xB(ctx->opcode))); \
|
|
|
|
} \
|
|
|
|
tcg_gen_shri_i64(a0, a0, 32); \
|
|
|
|
tcg_gen_shri_i64(b0, b0, 32); \
|
|
|
|
tcg_gen_deposit_i64(cpu_vsrh(xT(ctx->opcode)), \
|
|
|
|
b0, a0, 32, 32); \
|
|
|
|
tcg_gen_deposit_i64(cpu_vsrl(xT(ctx->opcode)), \
|
|
|
|
b1, a1, 32, 32); \
|
2013-12-20 11:01:50 +01:00
|
|
|
tcg_temp_free_i64(a0); \
|
|
|
|
tcg_temp_free_i64(a1); \
|
|
|
|
tcg_temp_free_i64(b0); \
|
|
|
|
tcg_temp_free_i64(b1); \
|
2013-11-01 14:21:20 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
VSX_XXMRG(xxmrghw, 1)
|
|
|
|
VSX_XXMRG(xxmrglw, 0)
|
|
|
|
|
2013-11-01 14:21:21 +01:00
|
|
|
static void gen_xxsel(DisasContext * ctx)
|
|
|
|
{
|
|
|
|
TCGv_i64 a, b, c;
|
|
|
|
if (unlikely(!ctx->vsx_enabled)) {
|
|
|
|
gen_exception(ctx, POWERPC_EXCP_VSXU);
|
|
|
|
return;
|
|
|
|
}
|
2013-12-20 11:01:50 +01:00
|
|
|
a = tcg_temp_new_i64();
|
|
|
|
b = tcg_temp_new_i64();
|
|
|
|
c = tcg_temp_new_i64();
|
2013-11-01 14:21:21 +01:00
|
|
|
|
|
|
|
tcg_gen_mov_i64(a, cpu_vsrh(xA(ctx->opcode)));
|
|
|
|
tcg_gen_mov_i64(b, cpu_vsrh(xB(ctx->opcode)));
|
|
|
|
tcg_gen_mov_i64(c, cpu_vsrh(xC(ctx->opcode)));
|
|
|
|
|
|
|
|
tcg_gen_and_i64(b, b, c);
|
|
|
|
tcg_gen_andc_i64(a, a, c);
|
|
|
|
tcg_gen_or_i64(cpu_vsrh(xT(ctx->opcode)), a, b);
|
|
|
|
|
|
|
|
tcg_gen_mov_i64(a, cpu_vsrl(xA(ctx->opcode)));
|
|
|
|
tcg_gen_mov_i64(b, cpu_vsrl(xB(ctx->opcode)));
|
|
|
|
tcg_gen_mov_i64(c, cpu_vsrl(xC(ctx->opcode)));
|
|
|
|
|
|
|
|
tcg_gen_and_i64(b, b, c);
|
|
|
|
tcg_gen_andc_i64(a, a, c);
|
|
|
|
tcg_gen_or_i64(cpu_vsrl(xT(ctx->opcode)), a, b);
|
|
|
|
|
2013-12-20 11:01:50 +01:00
|
|
|
tcg_temp_free_i64(a);
|
|
|
|
tcg_temp_free_i64(b);
|
|
|
|
tcg_temp_free_i64(c);
|
2013-11-01 14:21:21 +01:00
|
|
|
}
|
|
|
|
|
2013-11-01 14:21:22 +01:00
|
|
|
static void gen_xxspltw(DisasContext *ctx)
|
|
|
|
{
|
|
|
|
TCGv_i64 b, b2;
|
|
|
|
TCGv_i64 vsr = (UIM(ctx->opcode) & 2) ?
|
|
|
|
cpu_vsrl(xB(ctx->opcode)) :
|
|
|
|
cpu_vsrh(xB(ctx->opcode));
|
|
|
|
|
|
|
|
if (unlikely(!ctx->vsx_enabled)) {
|
|
|
|
gen_exception(ctx, POWERPC_EXCP_VSXU);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-12-20 11:01:50 +01:00
|
|
|
b = tcg_temp_new_i64();
|
|
|
|
b2 = tcg_temp_new_i64();
|
2013-11-01 14:21:22 +01:00
|
|
|
|
|
|
|
if (UIM(ctx->opcode) & 1) {
|
|
|
|
tcg_gen_ext32u_i64(b, vsr);
|
|
|
|
} else {
|
|
|
|
tcg_gen_shri_i64(b, vsr, 32);
|
|
|
|
}
|
|
|
|
|
|
|
|
tcg_gen_shli_i64(b2, b, 32);
|
|
|
|
tcg_gen_or_i64(cpu_vsrh(xT(ctx->opcode)), b, b2);
|
|
|
|
tcg_gen_mov_i64(cpu_vsrl(xT(ctx->opcode)), cpu_vsrh(xT(ctx->opcode)));
|
|
|
|
|
2013-12-20 11:01:50 +01:00
|
|
|
tcg_temp_free_i64(b);
|
|
|
|
tcg_temp_free_i64(b2);
|
2013-11-01 14:21:22 +01:00
|
|
|
}
|
|
|
|
|
2013-11-01 14:21:23 +01:00
|
|
|
static void gen_xxsldwi(DisasContext *ctx)
|
|
|
|
{
|
|
|
|
TCGv_i64 xth, xtl;
|
|
|
|
if (unlikely(!ctx->vsx_enabled)) {
|
|
|
|
gen_exception(ctx, POWERPC_EXCP_VSXU);
|
|
|
|
return;
|
|
|
|
}
|
2013-12-20 11:01:50 +01:00
|
|
|
xth = tcg_temp_new_i64();
|
|
|
|
xtl = tcg_temp_new_i64();
|
2013-11-01 14:21:23 +01:00
|
|
|
|
|
|
|
switch (SHW(ctx->opcode)) {
|
|
|
|
case 0: {
|
|
|
|
tcg_gen_mov_i64(xth, cpu_vsrh(xA(ctx->opcode)));
|
|
|
|
tcg_gen_mov_i64(xtl, cpu_vsrl(xA(ctx->opcode)));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 1: {
|
2013-12-20 11:01:50 +01:00
|
|
|
TCGv_i64 t0 = tcg_temp_new_i64();
|
2013-11-01 14:21:23 +01:00
|
|
|
tcg_gen_mov_i64(xth, cpu_vsrh(xA(ctx->opcode)));
|
|
|
|
tcg_gen_shli_i64(xth, xth, 32);
|
|
|
|
tcg_gen_mov_i64(t0, cpu_vsrl(xA(ctx->opcode)));
|
|
|
|
tcg_gen_shri_i64(t0, t0, 32);
|
|
|
|
tcg_gen_or_i64(xth, xth, t0);
|
|
|
|
tcg_gen_mov_i64(xtl, cpu_vsrl(xA(ctx->opcode)));
|
|
|
|
tcg_gen_shli_i64(xtl, xtl, 32);
|
|
|
|
tcg_gen_mov_i64(t0, cpu_vsrh(xB(ctx->opcode)));
|
|
|
|
tcg_gen_shri_i64(t0, t0, 32);
|
|
|
|
tcg_gen_or_i64(xtl, xtl, t0);
|
2013-12-20 11:01:50 +01:00
|
|
|
tcg_temp_free_i64(t0);
|
2013-11-01 14:21:23 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 2: {
|
|
|
|
tcg_gen_mov_i64(xth, cpu_vsrl(xA(ctx->opcode)));
|
|
|
|
tcg_gen_mov_i64(xtl, cpu_vsrh(xB(ctx->opcode)));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 3: {
|
2013-12-20 11:01:50 +01:00
|
|
|
TCGv_i64 t0 = tcg_temp_new_i64();
|
2013-11-01 14:21:23 +01:00
|
|
|
tcg_gen_mov_i64(xth, cpu_vsrl(xA(ctx->opcode)));
|
|
|
|
tcg_gen_shli_i64(xth, xth, 32);
|
|
|
|
tcg_gen_mov_i64(t0, cpu_vsrh(xB(ctx->opcode)));
|
|
|
|
tcg_gen_shri_i64(t0, t0, 32);
|
|
|
|
tcg_gen_or_i64(xth, xth, t0);
|
|
|
|
tcg_gen_mov_i64(xtl, cpu_vsrh(xB(ctx->opcode)));
|
|
|
|
tcg_gen_shli_i64(xtl, xtl, 32);
|
|
|
|
tcg_gen_mov_i64(t0, cpu_vsrl(xB(ctx->opcode)));
|
|
|
|
tcg_gen_shri_i64(t0, t0, 32);
|
|
|
|
tcg_gen_or_i64(xtl, xtl, t0);
|
2013-12-20 11:01:50 +01:00
|
|
|
tcg_temp_free_i64(t0);
|
2013-11-01 14:21:23 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
tcg_gen_mov_i64(cpu_vsrh(xT(ctx->opcode)), xth);
|
|
|
|
tcg_gen_mov_i64(cpu_vsrl(xT(ctx->opcode)), xtl);
|
|
|
|
|
2013-12-20 11:01:50 +01:00
|
|
|
tcg_temp_free_i64(xth);
|
|
|
|
tcg_temp_free_i64(xtl);
|
2013-11-01 14:21:23 +01:00
|
|
|
}
|
|
|
|
|
2014-04-21 22:54:57 +02:00
|
|
|
/*** Decimal Floating Point ***/
|
|
|
|
|
|
|
|
static inline TCGv_ptr gen_fprp_ptr(int reg)
|
|
|
|
{
|
|
|
|
TCGv_ptr r = tcg_temp_new_ptr();
|
|
|
|
tcg_gen_addi_ptr(r, cpu_env, offsetof(CPUPPCState, fpr[reg]));
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
|
|
|
#define GEN_DFP_T_A_B_Rc(name) \
|
|
|
|
static void gen_##name(DisasContext *ctx) \
|
|
|
|
{ \
|
|
|
|
TCGv_ptr rd, ra, rb; \
|
|
|
|
if (unlikely(!ctx->fpu_enabled)) { \
|
|
|
|
gen_exception(ctx, POWERPC_EXCP_FPU); \
|
|
|
|
return; \
|
|
|
|
} \
|
|
|
|
gen_update_nip(ctx, ctx->nip - 4); \
|
|
|
|
rd = gen_fprp_ptr(rD(ctx->opcode)); \
|
|
|
|
ra = gen_fprp_ptr(rA(ctx->opcode)); \
|
|
|
|
rb = gen_fprp_ptr(rB(ctx->opcode)); \
|
|
|
|
gen_helper_##name(cpu_env, rd, ra, rb); \
|
|
|
|
if (unlikely(Rc(ctx->opcode) != 0)) { \
|
2014-08-28 19:15:07 +02:00
|
|
|
gen_set_cr1_from_fpscr(ctx); \
|
2014-04-21 22:54:57 +02:00
|
|
|
} \
|
|
|
|
tcg_temp_free_ptr(rd); \
|
|
|
|
tcg_temp_free_ptr(ra); \
|
|
|
|
tcg_temp_free_ptr(rb); \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define GEN_DFP_BF_A_B(name) \
|
|
|
|
static void gen_##name(DisasContext *ctx) \
|
|
|
|
{ \
|
|
|
|
TCGv_ptr ra, rb; \
|
|
|
|
if (unlikely(!ctx->fpu_enabled)) { \
|
|
|
|
gen_exception(ctx, POWERPC_EXCP_FPU); \
|
|
|
|
return; \
|
|
|
|
} \
|
|
|
|
gen_update_nip(ctx, ctx->nip - 4); \
|
|
|
|
ra = gen_fprp_ptr(rA(ctx->opcode)); \
|
|
|
|
rb = gen_fprp_ptr(rB(ctx->opcode)); \
|
|
|
|
gen_helper_##name(cpu_crf[crfD(ctx->opcode)], \
|
|
|
|
cpu_env, ra, rb); \
|
|
|
|
tcg_temp_free_ptr(ra); \
|
|
|
|
tcg_temp_free_ptr(rb); \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define GEN_DFP_BF_A_DCM(name) \
|
|
|
|
static void gen_##name(DisasContext *ctx) \
|
|
|
|
{ \
|
|
|
|
TCGv_ptr ra; \
|
|
|
|
TCGv_i32 dcm; \
|
|
|
|
if (unlikely(!ctx->fpu_enabled)) { \
|
|
|
|
gen_exception(ctx, POWERPC_EXCP_FPU); \
|
|
|
|
return; \
|
|
|
|
} \
|
|
|
|
gen_update_nip(ctx, ctx->nip - 4); \
|
|
|
|
ra = gen_fprp_ptr(rA(ctx->opcode)); \
|
|
|
|
dcm = tcg_const_i32(DCM(ctx->opcode)); \
|
|
|
|
gen_helper_##name(cpu_crf[crfD(ctx->opcode)], \
|
|
|
|
cpu_env, ra, dcm); \
|
|
|
|
tcg_temp_free_ptr(ra); \
|
|
|
|
tcg_temp_free_i32(dcm); \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define GEN_DFP_T_B_U32_U32_Rc(name, u32f1, u32f2) \
|
|
|
|
static void gen_##name(DisasContext *ctx) \
|
|
|
|
{ \
|
|
|
|
TCGv_ptr rt, rb; \
|
|
|
|
TCGv_i32 u32_1, u32_2; \
|
|
|
|
if (unlikely(!ctx->fpu_enabled)) { \
|
|
|
|
gen_exception(ctx, POWERPC_EXCP_FPU); \
|
|
|
|
return; \
|
|
|
|
} \
|
|
|
|
gen_update_nip(ctx, ctx->nip - 4); \
|
|
|
|
rt = gen_fprp_ptr(rD(ctx->opcode)); \
|
|
|
|
rb = gen_fprp_ptr(rB(ctx->opcode)); \
|
|
|
|
u32_1 = tcg_const_i32(u32f1(ctx->opcode)); \
|
|
|
|
u32_2 = tcg_const_i32(u32f2(ctx->opcode)); \
|
|
|
|
gen_helper_##name(cpu_env, rt, rb, u32_1, u32_2); \
|
|
|
|
if (unlikely(Rc(ctx->opcode) != 0)) { \
|
2014-08-28 19:15:07 +02:00
|
|
|
gen_set_cr1_from_fpscr(ctx); \
|
2014-04-21 22:54:57 +02:00
|
|
|
} \
|
|
|
|
tcg_temp_free_ptr(rt); \
|
|
|
|
tcg_temp_free_ptr(rb); \
|
|
|
|
tcg_temp_free_i32(u32_1); \
|
|
|
|
tcg_temp_free_i32(u32_2); \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define GEN_DFP_T_A_B_I32_Rc(name, i32fld) \
|
|
|
|
static void gen_##name(DisasContext *ctx) \
|
|
|
|
{ \
|
|
|
|
TCGv_ptr rt, ra, rb; \
|
|
|
|
TCGv_i32 i32; \
|
|
|
|
if (unlikely(!ctx->fpu_enabled)) { \
|
|
|
|
gen_exception(ctx, POWERPC_EXCP_FPU); \
|
|
|
|
return; \
|
|
|
|
} \
|
|
|
|
gen_update_nip(ctx, ctx->nip - 4); \
|
|
|
|
rt = gen_fprp_ptr(rD(ctx->opcode)); \
|
|
|
|
ra = gen_fprp_ptr(rA(ctx->opcode)); \
|
|
|
|
rb = gen_fprp_ptr(rB(ctx->opcode)); \
|
|
|
|
i32 = tcg_const_i32(i32fld(ctx->opcode)); \
|
|
|
|
gen_helper_##name(cpu_env, rt, ra, rb, i32); \
|
|
|
|
if (unlikely(Rc(ctx->opcode) != 0)) { \
|
2014-08-28 19:15:07 +02:00
|
|
|
gen_set_cr1_from_fpscr(ctx); \
|
2014-04-21 22:54:57 +02:00
|
|
|
} \
|
|
|
|
tcg_temp_free_ptr(rt); \
|
|
|
|
tcg_temp_free_ptr(rb); \
|
|
|
|
tcg_temp_free_ptr(ra); \
|
|
|
|
tcg_temp_free_i32(i32); \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define GEN_DFP_T_B_Rc(name) \
|
|
|
|
static void gen_##name(DisasContext *ctx) \
|
|
|
|
{ \
|
|
|
|
TCGv_ptr rt, rb; \
|
|
|
|
if (unlikely(!ctx->fpu_enabled)) { \
|
|
|
|
gen_exception(ctx, POWERPC_EXCP_FPU); \
|
|
|
|
return; \
|
|
|
|
} \
|
|
|
|
gen_update_nip(ctx, ctx->nip - 4); \
|
|
|
|
rt = gen_fprp_ptr(rD(ctx->opcode)); \
|
|
|
|
rb = gen_fprp_ptr(rB(ctx->opcode)); \
|
|
|
|
gen_helper_##name(cpu_env, rt, rb); \
|
|
|
|
if (unlikely(Rc(ctx->opcode) != 0)) { \
|
2014-08-28 19:15:07 +02:00
|
|
|
gen_set_cr1_from_fpscr(ctx); \
|
2014-04-21 22:54:57 +02:00
|
|
|
} \
|
|
|
|
tcg_temp_free_ptr(rt); \
|
|
|
|
tcg_temp_free_ptr(rb); \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define GEN_DFP_T_FPR_I32_Rc(name, fprfld, i32fld) \
|
|
|
|
static void gen_##name(DisasContext *ctx) \
|
|
|
|
{ \
|
|
|
|
TCGv_ptr rt, rs; \
|
|
|
|
TCGv_i32 i32; \
|
|
|
|
if (unlikely(!ctx->fpu_enabled)) { \
|
|
|
|
gen_exception(ctx, POWERPC_EXCP_FPU); \
|
|
|
|
return; \
|
|
|
|
} \
|
|
|
|
gen_update_nip(ctx, ctx->nip - 4); \
|
|
|
|
rt = gen_fprp_ptr(rD(ctx->opcode)); \
|
|
|
|
rs = gen_fprp_ptr(fprfld(ctx->opcode)); \
|
|
|
|
i32 = tcg_const_i32(i32fld(ctx->opcode)); \
|
|
|
|
gen_helper_##name(cpu_env, rt, rs, i32); \
|
|
|
|
if (unlikely(Rc(ctx->opcode) != 0)) { \
|
2014-08-28 19:15:07 +02:00
|
|
|
gen_set_cr1_from_fpscr(ctx); \
|
2014-04-21 22:54:57 +02:00
|
|
|
} \
|
|
|
|
tcg_temp_free_ptr(rt); \
|
|
|
|
tcg_temp_free_ptr(rs); \
|
|
|
|
tcg_temp_free_i32(i32); \
|
|
|
|
}
|
2013-11-01 14:21:20 +01:00
|
|
|
|
2014-04-21 22:55:01 +02:00
|
|
|
GEN_DFP_T_A_B_Rc(dadd)
|
|
|
|
GEN_DFP_T_A_B_Rc(daddq)
|
2014-04-21 22:55:02 +02:00
|
|
|
GEN_DFP_T_A_B_Rc(dsub)
|
|
|
|
GEN_DFP_T_A_B_Rc(dsubq)
|
2014-04-21 22:55:03 +02:00
|
|
|
GEN_DFP_T_A_B_Rc(dmul)
|
|
|
|
GEN_DFP_T_A_B_Rc(dmulq)
|
2014-04-21 22:55:04 +02:00
|
|
|
GEN_DFP_T_A_B_Rc(ddiv)
|
|
|
|
GEN_DFP_T_A_B_Rc(ddivq)
|
2014-04-21 22:55:05 +02:00
|
|
|
GEN_DFP_BF_A_B(dcmpu)
|
|
|
|
GEN_DFP_BF_A_B(dcmpuq)
|
|
|
|
GEN_DFP_BF_A_B(dcmpo)
|
|
|
|
GEN_DFP_BF_A_B(dcmpoq)
|
2014-04-21 22:55:06 +02:00
|
|
|
GEN_DFP_BF_A_DCM(dtstdc)
|
|
|
|
GEN_DFP_BF_A_DCM(dtstdcq)
|
2014-04-21 22:55:07 +02:00
|
|
|
GEN_DFP_BF_A_DCM(dtstdg)
|
|
|
|
GEN_DFP_BF_A_DCM(dtstdgq)
|
2014-04-21 22:55:08 +02:00
|
|
|
GEN_DFP_BF_A_B(dtstex)
|
|
|
|
GEN_DFP_BF_A_B(dtstexq)
|
2014-04-21 22:55:09 +02:00
|
|
|
GEN_DFP_BF_A_B(dtstsf)
|
|
|
|
GEN_DFP_BF_A_B(dtstsfq)
|
2014-04-21 22:55:10 +02:00
|
|
|
GEN_DFP_T_B_U32_U32_Rc(dquai, SIMM5, RMC)
|
|
|
|
GEN_DFP_T_B_U32_U32_Rc(dquaiq, SIMM5, RMC)
|
|
|
|
GEN_DFP_T_A_B_I32_Rc(dqua, RMC)
|
|
|
|
GEN_DFP_T_A_B_I32_Rc(dquaq, RMC)
|
2014-04-21 22:55:11 +02:00
|
|
|
GEN_DFP_T_A_B_I32_Rc(drrnd, RMC)
|
|
|
|
GEN_DFP_T_A_B_I32_Rc(drrndq, RMC)
|
2014-04-21 22:55:12 +02:00
|
|
|
GEN_DFP_T_B_U32_U32_Rc(drintx, FPW, RMC)
|
|
|
|
GEN_DFP_T_B_U32_U32_Rc(drintxq, FPW, RMC)
|
|
|
|
GEN_DFP_T_B_U32_U32_Rc(drintn, FPW, RMC)
|
|
|
|
GEN_DFP_T_B_U32_U32_Rc(drintnq, FPW, RMC)
|
2014-04-21 22:55:13 +02:00
|
|
|
GEN_DFP_T_B_Rc(dctdp)
|
|
|
|
GEN_DFP_T_B_Rc(dctqpq)
|
2014-04-21 22:55:14 +02:00
|
|
|
GEN_DFP_T_B_Rc(drsp)
|
|
|
|
GEN_DFP_T_B_Rc(drdpq)
|
2014-04-21 22:55:15 +02:00
|
|
|
GEN_DFP_T_B_Rc(dcffix)
|
|
|
|
GEN_DFP_T_B_Rc(dcffixq)
|
2014-04-21 22:55:16 +02:00
|
|
|
GEN_DFP_T_B_Rc(dctfix)
|
|
|
|
GEN_DFP_T_B_Rc(dctfixq)
|
2014-04-21 22:55:17 +02:00
|
|
|
GEN_DFP_T_FPR_I32_Rc(ddedpd, rB, SP)
|
|
|
|
GEN_DFP_T_FPR_I32_Rc(ddedpdq, rB, SP)
|
2014-04-21 22:55:18 +02:00
|
|
|
GEN_DFP_T_FPR_I32_Rc(denbcd, rB, SP)
|
|
|
|
GEN_DFP_T_FPR_I32_Rc(denbcdq, rB, SP)
|
2014-04-21 22:55:19 +02:00
|
|
|
GEN_DFP_T_B_Rc(dxex)
|
|
|
|
GEN_DFP_T_B_Rc(dxexq)
|
2014-04-21 22:55:20 +02:00
|
|
|
GEN_DFP_T_A_B_Rc(diex)
|
|
|
|
GEN_DFP_T_A_B_Rc(diexq)
|
2014-04-21 22:55:21 +02:00
|
|
|
GEN_DFP_T_FPR_I32_Rc(dscli, rA, DCM)
|
|
|
|
GEN_DFP_T_FPR_I32_Rc(dscliq, rA, DCM)
|
|
|
|
GEN_DFP_T_FPR_I32_Rc(dscri, rA, DCM)
|
|
|
|
GEN_DFP_T_FPR_I32_Rc(dscriq, rA, DCM)
|
|
|
|
|
2007-03-20 23:11:31 +01:00
|
|
|
/*** SPE extension ***/
|
|
|
|
/* Register moves */
|
2007-11-12 02:56:18 +01:00
|
|
|
|
2011-03-16 11:21:22 +01:00
|
|
|
static inline void gen_evmra(DisasContext *ctx)
|
|
|
|
{
|
|
|
|
|
|
|
|
if (unlikely(!ctx->spe_enabled)) {
|
2011-08-23 06:55:43 +02:00
|
|
|
gen_exception(ctx, POWERPC_EXCP_SPEU);
|
2011-03-16 11:21:22 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
TCGv_i64 tmp = tcg_temp_new_i64();
|
|
|
|
|
|
|
|
/* tmp := rA_lo + rA_hi << 32 */
|
2014-06-04 22:58:50 +02:00
|
|
|
tcg_gen_concat_tl_i64(tmp, cpu_gpr[rA(ctx->opcode)], cpu_gprh[rA(ctx->opcode)]);
|
2011-03-16 11:21:22 +01:00
|
|
|
|
|
|
|
/* spe_acc := tmp */
|
2012-03-14 01:38:22 +01:00
|
|
|
tcg_gen_st_i64(tmp, cpu_env, offsetof(CPUPPCState, spe_acc));
|
2011-03-16 11:21:22 +01:00
|
|
|
tcg_temp_free_i64(tmp);
|
|
|
|
|
|
|
|
/* rD := rA */
|
2014-06-04 22:58:50 +02:00
|
|
|
tcg_gen_mov_tl(cpu_gpr[rD(ctx->opcode)], cpu_gpr[rA(ctx->opcode)]);
|
|
|
|
tcg_gen_mov_tl(cpu_gprh[rD(ctx->opcode)], cpu_gprh[rA(ctx->opcode)]);
|
2011-03-16 11:21:22 +01:00
|
|
|
}
|
|
|
|
|
2009-08-16 11:06:54 +02:00
|
|
|
static inline void gen_load_gpr64(TCGv_i64 t, int reg)
|
|
|
|
{
|
2014-06-04 22:58:50 +02:00
|
|
|
tcg_gen_concat_tl_i64(t, cpu_gpr[reg], cpu_gprh[reg]);
|
2008-09-04 07:25:47 +02:00
|
|
|
}
|
2007-11-12 02:56:18 +01:00
|
|
|
|
2009-08-16 11:06:54 +02:00
|
|
|
static inline void gen_store_gpr64(int reg, TCGv_i64 t)
|
|
|
|
{
|
2014-06-04 22:58:50 +02:00
|
|
|
tcg_gen_extr_i64_tl(cpu_gpr[reg], cpu_gprh[reg], t);
|
2008-09-04 07:25:47 +02:00
|
|
|
}
|
2007-11-12 02:56:18 +01:00
|
|
|
|
2011-09-28 07:54:05 +02:00
|
|
|
#define GEN_SPE(name0, name1, opc2, opc3, inval0, inval1, type) \
|
2009-06-17 17:22:09 +02:00
|
|
|
static void glue(gen_, name0##_##name1)(DisasContext *ctx) \
|
2007-03-20 23:11:31 +01:00
|
|
|
{ \
|
|
|
|
if (Rc(ctx->opcode)) \
|
|
|
|
gen_##name1(ctx); \
|
|
|
|
else \
|
|
|
|
gen_##name0(ctx); \
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Handler for undefined SPE opcodes */
|
2009-08-16 11:06:54 +02:00
|
|
|
static inline void gen_speundef(DisasContext *ctx)
|
2007-03-20 23:11:31 +01:00
|
|
|
{
|
2008-12-11 23:42:14 +01:00
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_INVAL_INVAL);
|
2007-03-20 23:11:31 +01:00
|
|
|
}
|
|
|
|
|
2008-11-10 12:10:23 +01:00
|
|
|
/* SPE logic */
|
|
|
|
#define GEN_SPEOP_LOGIC2(name, tcg_op) \
|
2009-08-16 11:06:54 +02:00
|
|
|
static inline void gen_##name(DisasContext *ctx) \
|
2008-11-10 12:10:23 +01:00
|
|
|
{ \
|
|
|
|
if (unlikely(!ctx->spe_enabled)) { \
|
2011-08-23 06:55:43 +02:00
|
|
|
gen_exception(ctx, POWERPC_EXCP_SPEU); \
|
2008-11-10 12:10:23 +01:00
|
|
|
return; \
|
|
|
|
} \
|
|
|
|
tcg_op(cpu_gpr[rD(ctx->opcode)], cpu_gpr[rA(ctx->opcode)], \
|
|
|
|
cpu_gpr[rB(ctx->opcode)]); \
|
|
|
|
tcg_op(cpu_gprh[rD(ctx->opcode)], cpu_gprh[rA(ctx->opcode)], \
|
|
|
|
cpu_gprh[rB(ctx->opcode)]); \
|
2007-03-20 23:11:31 +01:00
|
|
|
}
|
2008-11-10 12:10:23 +01:00
|
|
|
|
|
|
|
GEN_SPEOP_LOGIC2(evand, tcg_gen_and_tl);
|
|
|
|
GEN_SPEOP_LOGIC2(evandc, tcg_gen_andc_tl);
|
|
|
|
GEN_SPEOP_LOGIC2(evxor, tcg_gen_xor_tl);
|
|
|
|
GEN_SPEOP_LOGIC2(evor, tcg_gen_or_tl);
|
|
|
|
GEN_SPEOP_LOGIC2(evnor, tcg_gen_nor_tl);
|
|
|
|
GEN_SPEOP_LOGIC2(eveqv, tcg_gen_eqv_tl);
|
|
|
|
GEN_SPEOP_LOGIC2(evorc, tcg_gen_orc_tl);
|
|
|
|
GEN_SPEOP_LOGIC2(evnand, tcg_gen_nand_tl);
|
2007-03-20 23:11:31 +01:00
|
|
|
|
2008-11-10 12:10:23 +01:00
|
|
|
/* SPE logic immediate */
|
|
|
|
#define GEN_SPEOP_TCG_LOGIC_IMM2(name, tcg_opi) \
|
2009-08-16 11:06:54 +02:00
|
|
|
static inline void gen_##name(DisasContext *ctx) \
|
2008-10-15 19:00:45 +02:00
|
|
|
{ \
|
2014-06-04 22:58:50 +02:00
|
|
|
TCGv_i32 t0; \
|
2008-10-15 19:00:45 +02:00
|
|
|
if (unlikely(!ctx->spe_enabled)) { \
|
2011-08-23 06:55:43 +02:00
|
|
|
gen_exception(ctx, POWERPC_EXCP_SPEU); \
|
2008-10-15 19:00:45 +02:00
|
|
|
return; \
|
|
|
|
} \
|
2014-06-04 22:58:50 +02:00
|
|
|
t0 = tcg_temp_new_i32(); \
|
|
|
|
\
|
|
|
|
tcg_gen_trunc_tl_i32(t0, cpu_gpr[rA(ctx->opcode)]); \
|
|
|
|
tcg_opi(t0, t0, rB(ctx->opcode)); \
|
|
|
|
tcg_gen_extu_i32_tl(cpu_gpr[rD(ctx->opcode)], t0); \
|
|
|
|
\
|
|
|
|
tcg_gen_trunc_tl_i32(t0, cpu_gprh[rA(ctx->opcode)]); \
|
2008-11-10 12:10:23 +01:00
|
|
|
tcg_opi(t0, t0, rB(ctx->opcode)); \
|
2014-06-04 22:58:50 +02:00
|
|
|
tcg_gen_extu_i32_tl(cpu_gprh[rD(ctx->opcode)], t0); \
|
|
|
|
\
|
2008-11-17 15:43:54 +01:00
|
|
|
tcg_temp_free_i32(t0); \
|
2008-10-15 19:00:45 +02:00
|
|
|
}
|
2008-11-10 12:10:23 +01:00
|
|
|
GEN_SPEOP_TCG_LOGIC_IMM2(evslwi, tcg_gen_shli_i32);
|
|
|
|
GEN_SPEOP_TCG_LOGIC_IMM2(evsrwiu, tcg_gen_shri_i32);
|
|
|
|
GEN_SPEOP_TCG_LOGIC_IMM2(evsrwis, tcg_gen_sari_i32);
|
|
|
|
GEN_SPEOP_TCG_LOGIC_IMM2(evrlwi, tcg_gen_rotli_i32);
|
2007-03-20 23:11:31 +01:00
|
|
|
|
2008-11-10 12:10:23 +01:00
|
|
|
/* SPE arithmetic */
|
|
|
|
#define GEN_SPEOP_ARITH1(name, tcg_op) \
|
2009-08-16 11:06:54 +02:00
|
|
|
static inline void gen_##name(DisasContext *ctx) \
|
2007-03-20 23:11:31 +01:00
|
|
|
{ \
|
2014-06-04 22:58:50 +02:00
|
|
|
TCGv_i32 t0; \
|
2007-03-20 23:11:31 +01:00
|
|
|
if (unlikely(!ctx->spe_enabled)) { \
|
2011-08-23 06:55:43 +02:00
|
|
|
gen_exception(ctx, POWERPC_EXCP_SPEU); \
|
2007-03-20 23:11:31 +01:00
|
|
|
return; \
|
|
|
|
} \
|
2014-06-04 22:58:50 +02:00
|
|
|
t0 = tcg_temp_new_i32(); \
|
|
|
|
\
|
|
|
|
tcg_gen_trunc_tl_i32(t0, cpu_gpr[rA(ctx->opcode)]); \
|
2008-11-10 12:10:23 +01:00
|
|
|
tcg_op(t0, t0); \
|
2014-06-04 22:58:50 +02:00
|
|
|
tcg_gen_extu_i32_tl(cpu_gpr[rD(ctx->opcode)], t0); \
|
|
|
|
\
|
|
|
|
tcg_gen_trunc_tl_i32(t0, cpu_gprh[rA(ctx->opcode)]); \
|
|
|
|
tcg_op(t0, t0); \
|
|
|
|
tcg_gen_extu_i32_tl(cpu_gprh[rD(ctx->opcode)], t0); \
|
|
|
|
\
|
2008-11-17 15:43:54 +01:00
|
|
|
tcg_temp_free_i32(t0); \
|
2008-11-10 12:10:23 +01:00
|
|
|
}
|
2007-03-20 23:11:31 +01:00
|
|
|
|
2009-08-16 11:06:54 +02:00
|
|
|
static inline void gen_op_evabs(TCGv_i32 ret, TCGv_i32 arg1)
|
2008-11-10 12:10:23 +01:00
|
|
|
{
|
2015-02-13 21:51:55 +01:00
|
|
|
TCGLabel *l1 = gen_new_label();
|
|
|
|
TCGLabel *l2 = gen_new_label();
|
2007-03-20 23:11:31 +01:00
|
|
|
|
2008-11-10 12:10:23 +01:00
|
|
|
tcg_gen_brcondi_i32(TCG_COND_GE, arg1, 0, l1);
|
|
|
|
tcg_gen_neg_i32(ret, arg1);
|
|
|
|
tcg_gen_br(l2);
|
|
|
|
gen_set_label(l1);
|
2008-11-17 15:43:54 +01:00
|
|
|
tcg_gen_mov_i32(ret, arg1);
|
2008-11-10 12:10:23 +01:00
|
|
|
gen_set_label(l2);
|
|
|
|
}
|
|
|
|
GEN_SPEOP_ARITH1(evabs, gen_op_evabs);
|
|
|
|
GEN_SPEOP_ARITH1(evneg, tcg_gen_neg_i32);
|
|
|
|
GEN_SPEOP_ARITH1(evextsb, tcg_gen_ext8s_i32);
|
|
|
|
GEN_SPEOP_ARITH1(evextsh, tcg_gen_ext16s_i32);
|
2009-08-16 11:06:54 +02:00
|
|
|
static inline void gen_op_evrndw(TCGv_i32 ret, TCGv_i32 arg1)
|
2007-03-20 23:11:31 +01:00
|
|
|
{
|
2008-11-10 12:10:23 +01:00
|
|
|
tcg_gen_addi_i32(ret, arg1, 0x8000);
|
|
|
|
tcg_gen_ext16u_i32(ret, ret);
|
|
|
|
}
|
|
|
|
GEN_SPEOP_ARITH1(evrndw, gen_op_evrndw);
|
2008-11-17 15:43:54 +01:00
|
|
|
GEN_SPEOP_ARITH1(evcntlsw, gen_helper_cntlsw32);
|
|
|
|
GEN_SPEOP_ARITH1(evcntlzw, gen_helper_cntlzw32);
|
2007-03-20 23:11:31 +01:00
|
|
|
|
2008-11-10 12:10:23 +01:00
|
|
|
#define GEN_SPEOP_ARITH2(name, tcg_op) \
|
2009-08-16 11:06:54 +02:00
|
|
|
static inline void gen_##name(DisasContext *ctx) \
|
2007-03-20 23:11:31 +01:00
|
|
|
{ \
|
2014-06-04 22:58:50 +02:00
|
|
|
TCGv_i32 t0, t1; \
|
2007-03-20 23:11:31 +01:00
|
|
|
if (unlikely(!ctx->spe_enabled)) { \
|
2011-08-23 06:55:43 +02:00
|
|
|
gen_exception(ctx, POWERPC_EXCP_SPEU); \
|
2007-03-20 23:11:31 +01:00
|
|
|
return; \
|
|
|
|
} \
|
2014-06-04 22:58:50 +02:00
|
|
|
t0 = tcg_temp_new_i32(); \
|
|
|
|
t1 = tcg_temp_new_i32(); \
|
|
|
|
\
|
|
|
|
tcg_gen_trunc_tl_i32(t0, cpu_gpr[rA(ctx->opcode)]); \
|
|
|
|
tcg_gen_trunc_tl_i32(t1, cpu_gpr[rB(ctx->opcode)]); \
|
|
|
|
tcg_op(t0, t0, t1); \
|
|
|
|
tcg_gen_extu_i32_tl(cpu_gpr[rD(ctx->opcode)], t0); \
|
|
|
|
\
|
|
|
|
tcg_gen_trunc_tl_i32(t0, cpu_gprh[rA(ctx->opcode)]); \
|
|
|
|
tcg_gen_trunc_tl_i32(t1, cpu_gprh[rB(ctx->opcode)]); \
|
|
|
|
tcg_op(t0, t0, t1); \
|
|
|
|
tcg_gen_extu_i32_tl(cpu_gprh[rD(ctx->opcode)], t0); \
|
|
|
|
\
|
2008-11-17 15:43:54 +01:00
|
|
|
tcg_temp_free_i32(t0); \
|
|
|
|
tcg_temp_free_i32(t1); \
|
2007-03-20 23:11:31 +01:00
|
|
|
}
|
|
|
|
|
2009-08-16 11:06:54 +02:00
|
|
|
static inline void gen_op_evsrwu(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2)
|
2008-11-10 12:10:23 +01:00
|
|
|
{
|
2015-02-13 21:51:55 +01:00
|
|
|
TCGLabel *l1 = gen_new_label();
|
|
|
|
TCGLabel *l2 = gen_new_label();
|
|
|
|
TCGv_i32 t0 = tcg_temp_local_new_i32();
|
2007-03-20 23:11:31 +01:00
|
|
|
|
2008-11-10 12:10:23 +01:00
|
|
|
/* No error here: 6 bits are used */
|
|
|
|
tcg_gen_andi_i32(t0, arg2, 0x3F);
|
|
|
|
tcg_gen_brcondi_i32(TCG_COND_GE, t0, 32, l1);
|
|
|
|
tcg_gen_shr_i32(ret, arg1, t0);
|
|
|
|
tcg_gen_br(l2);
|
|
|
|
gen_set_label(l1);
|
|
|
|
tcg_gen_movi_i32(ret, 0);
|
2010-03-11 21:29:42 +01:00
|
|
|
gen_set_label(l2);
|
2008-11-17 15:43:54 +01:00
|
|
|
tcg_temp_free_i32(t0);
|
2008-11-10 12:10:23 +01:00
|
|
|
}
|
|
|
|
GEN_SPEOP_ARITH2(evsrwu, gen_op_evsrwu);
|
2009-08-16 11:06:54 +02:00
|
|
|
static inline void gen_op_evsrws(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2)
|
2008-11-10 12:10:23 +01:00
|
|
|
{
|
2015-02-13 21:51:55 +01:00
|
|
|
TCGLabel *l1 = gen_new_label();
|
|
|
|
TCGLabel *l2 = gen_new_label();
|
|
|
|
TCGv_i32 t0 = tcg_temp_local_new_i32();
|
2008-11-10 12:10:23 +01:00
|
|
|
|
|
|
|
/* No error here: 6 bits are used */
|
|
|
|
tcg_gen_andi_i32(t0, arg2, 0x3F);
|
|
|
|
tcg_gen_brcondi_i32(TCG_COND_GE, t0, 32, l1);
|
|
|
|
tcg_gen_sar_i32(ret, arg1, t0);
|
|
|
|
tcg_gen_br(l2);
|
|
|
|
gen_set_label(l1);
|
|
|
|
tcg_gen_movi_i32(ret, 0);
|
2010-03-11 21:29:42 +01:00
|
|
|
gen_set_label(l2);
|
2008-11-17 15:43:54 +01:00
|
|
|
tcg_temp_free_i32(t0);
|
2008-11-10 12:10:23 +01:00
|
|
|
}
|
|
|
|
GEN_SPEOP_ARITH2(evsrws, gen_op_evsrws);
|
2009-08-16 11:06:54 +02:00
|
|
|
static inline void gen_op_evslw(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2)
|
2008-11-10 12:10:23 +01:00
|
|
|
{
|
2015-02-13 21:51:55 +01:00
|
|
|
TCGLabel *l1 = gen_new_label();
|
|
|
|
TCGLabel *l2 = gen_new_label();
|
|
|
|
TCGv_i32 t0 = tcg_temp_local_new_i32();
|
2008-11-10 12:10:23 +01:00
|
|
|
|
|
|
|
/* No error here: 6 bits are used */
|
|
|
|
tcg_gen_andi_i32(t0, arg2, 0x3F);
|
|
|
|
tcg_gen_brcondi_i32(TCG_COND_GE, t0, 32, l1);
|
|
|
|
tcg_gen_shl_i32(ret, arg1, t0);
|
|
|
|
tcg_gen_br(l2);
|
|
|
|
gen_set_label(l1);
|
|
|
|
tcg_gen_movi_i32(ret, 0);
|
2010-03-11 21:14:47 +01:00
|
|
|
gen_set_label(l2);
|
2008-11-17 15:43:54 +01:00
|
|
|
tcg_temp_free_i32(t0);
|
2008-11-10 12:10:23 +01:00
|
|
|
}
|
|
|
|
GEN_SPEOP_ARITH2(evslw, gen_op_evslw);
|
2009-08-16 11:06:54 +02:00
|
|
|
static inline void gen_op_evrlw(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2)
|
2008-11-10 12:10:23 +01:00
|
|
|
{
|
2008-11-17 15:43:54 +01:00
|
|
|
TCGv_i32 t0 = tcg_temp_new_i32();
|
2008-11-10 12:10:23 +01:00
|
|
|
tcg_gen_andi_i32(t0, arg2, 0x1F);
|
|
|
|
tcg_gen_rotl_i32(ret, arg1, t0);
|
2008-11-17 15:43:54 +01:00
|
|
|
tcg_temp_free_i32(t0);
|
2008-11-10 12:10:23 +01:00
|
|
|
}
|
|
|
|
GEN_SPEOP_ARITH2(evrlw, gen_op_evrlw);
|
2009-08-16 11:06:54 +02:00
|
|
|
static inline void gen_evmergehi(DisasContext *ctx)
|
2008-11-10 12:10:23 +01:00
|
|
|
{
|
|
|
|
if (unlikely(!ctx->spe_enabled)) {
|
2011-08-23 06:55:43 +02:00
|
|
|
gen_exception(ctx, POWERPC_EXCP_SPEU);
|
2008-11-10 12:10:23 +01:00
|
|
|
return;
|
|
|
|
}
|
2014-06-04 22:58:50 +02:00
|
|
|
tcg_gen_mov_tl(cpu_gpr[rD(ctx->opcode)], cpu_gprh[rB(ctx->opcode)]);
|
|
|
|
tcg_gen_mov_tl(cpu_gprh[rD(ctx->opcode)], cpu_gprh[rA(ctx->opcode)]);
|
2008-11-10 12:10:23 +01:00
|
|
|
}
|
|
|
|
GEN_SPEOP_ARITH2(evaddw, tcg_gen_add_i32);
|
2009-08-16 11:06:54 +02:00
|
|
|
static inline void gen_op_evsubf(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2)
|
2007-03-20 23:11:31 +01:00
|
|
|
{
|
2008-11-10 12:10:23 +01:00
|
|
|
tcg_gen_sub_i32(ret, arg2, arg1);
|
|
|
|
}
|
|
|
|
GEN_SPEOP_ARITH2(evsubfw, gen_op_evsubf);
|
2007-03-20 23:11:31 +01:00
|
|
|
|
2008-11-10 12:10:23 +01:00
|
|
|
/* SPE arithmetic immediate */
|
|
|
|
#define GEN_SPEOP_ARITH_IMM2(name, tcg_op) \
|
2009-08-16 11:06:54 +02:00
|
|
|
static inline void gen_##name(DisasContext *ctx) \
|
2008-11-10 12:10:23 +01:00
|
|
|
{ \
|
2014-06-04 22:58:50 +02:00
|
|
|
TCGv_i32 t0; \
|
2008-11-10 12:10:23 +01:00
|
|
|
if (unlikely(!ctx->spe_enabled)) { \
|
2011-08-23 06:55:43 +02:00
|
|
|
gen_exception(ctx, POWERPC_EXCP_SPEU); \
|
2008-11-10 12:10:23 +01:00
|
|
|
return; \
|
|
|
|
} \
|
2014-06-04 22:58:50 +02:00
|
|
|
t0 = tcg_temp_new_i32(); \
|
|
|
|
\
|
|
|
|
tcg_gen_trunc_tl_i32(t0, cpu_gpr[rB(ctx->opcode)]); \
|
2008-11-10 12:10:23 +01:00
|
|
|
tcg_op(t0, t0, rA(ctx->opcode)); \
|
2014-06-04 22:58:50 +02:00
|
|
|
tcg_gen_extu_i32_tl(cpu_gpr[rD(ctx->opcode)], t0); \
|
|
|
|
\
|
|
|
|
tcg_gen_trunc_tl_i32(t0, cpu_gprh[rB(ctx->opcode)]); \
|
|
|
|
tcg_op(t0, t0, rA(ctx->opcode)); \
|
|
|
|
tcg_gen_extu_i32_tl(cpu_gprh[rD(ctx->opcode)], t0); \
|
|
|
|
\
|
2008-11-17 15:43:54 +01:00
|
|
|
tcg_temp_free_i32(t0); \
|
2008-11-10 12:10:23 +01:00
|
|
|
}
|
|
|
|
GEN_SPEOP_ARITH_IMM2(evaddiw, tcg_gen_addi_i32);
|
|
|
|
GEN_SPEOP_ARITH_IMM2(evsubifw, tcg_gen_subi_i32);
|
|
|
|
|
|
|
|
/* SPE comparison */
|
|
|
|
#define GEN_SPEOP_COMP(name, tcg_cond) \
|
2009-08-16 11:06:54 +02:00
|
|
|
static inline void gen_##name(DisasContext *ctx) \
|
2008-11-10 12:10:23 +01:00
|
|
|
{ \
|
|
|
|
if (unlikely(!ctx->spe_enabled)) { \
|
2011-08-23 06:55:43 +02:00
|
|
|
gen_exception(ctx, POWERPC_EXCP_SPEU); \
|
2008-11-10 12:10:23 +01:00
|
|
|
return; \
|
|
|
|
} \
|
2015-02-13 21:51:55 +01:00
|
|
|
TCGLabel *l1 = gen_new_label(); \
|
|
|
|
TCGLabel *l2 = gen_new_label(); \
|
|
|
|
TCGLabel *l3 = gen_new_label(); \
|
|
|
|
TCGLabel *l4 = gen_new_label(); \
|
2008-11-10 12:10:23 +01:00
|
|
|
\
|
2014-06-04 22:58:50 +02:00
|
|
|
tcg_gen_ext32s_tl(cpu_gpr[rA(ctx->opcode)], cpu_gpr[rA(ctx->opcode)]); \
|
|
|
|
tcg_gen_ext32s_tl(cpu_gpr[rB(ctx->opcode)], cpu_gpr[rB(ctx->opcode)]); \
|
|
|
|
tcg_gen_ext32s_tl(cpu_gprh[rA(ctx->opcode)], cpu_gprh[rA(ctx->opcode)]); \
|
|
|
|
tcg_gen_ext32s_tl(cpu_gprh[rB(ctx->opcode)], cpu_gprh[rB(ctx->opcode)]); \
|
|
|
|
\
|
|
|
|
tcg_gen_brcond_tl(tcg_cond, cpu_gpr[rA(ctx->opcode)], \
|
2008-11-10 12:10:23 +01:00
|
|
|
cpu_gpr[rB(ctx->opcode)], l1); \
|
2014-06-04 22:58:50 +02:00
|
|
|
tcg_gen_movi_i32(cpu_crf[crfD(ctx->opcode)], 0); \
|
2008-11-10 12:10:23 +01:00
|
|
|
tcg_gen_br(l2); \
|
|
|
|
gen_set_label(l1); \
|
|
|
|
tcg_gen_movi_i32(cpu_crf[crfD(ctx->opcode)], \
|
|
|
|
CRF_CL | CRF_CH_OR_CL | CRF_CH_AND_CL); \
|
|
|
|
gen_set_label(l2); \
|
2014-06-04 22:58:50 +02:00
|
|
|
tcg_gen_brcond_tl(tcg_cond, cpu_gprh[rA(ctx->opcode)], \
|
2008-11-10 12:10:23 +01:00
|
|
|
cpu_gprh[rB(ctx->opcode)], l3); \
|
|
|
|
tcg_gen_andi_i32(cpu_crf[crfD(ctx->opcode)], cpu_crf[crfD(ctx->opcode)], \
|
|
|
|
~(CRF_CH | CRF_CH_AND_CL)); \
|
|
|
|
tcg_gen_br(l4); \
|
|
|
|
gen_set_label(l3); \
|
|
|
|
tcg_gen_ori_i32(cpu_crf[crfD(ctx->opcode)], cpu_crf[crfD(ctx->opcode)], \
|
|
|
|
CRF_CH | CRF_CH_OR_CL); \
|
|
|
|
gen_set_label(l4); \
|
|
|
|
}
|
|
|
|
GEN_SPEOP_COMP(evcmpgtu, TCG_COND_GTU);
|
|
|
|
GEN_SPEOP_COMP(evcmpgts, TCG_COND_GT);
|
|
|
|
GEN_SPEOP_COMP(evcmpltu, TCG_COND_LTU);
|
|
|
|
GEN_SPEOP_COMP(evcmplts, TCG_COND_LT);
|
|
|
|
GEN_SPEOP_COMP(evcmpeq, TCG_COND_EQ);
|
|
|
|
|
|
|
|
/* SPE misc */
|
2009-08-16 11:06:54 +02:00
|
|
|
static inline void gen_brinc(DisasContext *ctx)
|
2008-11-10 12:10:23 +01:00
|
|
|
{
|
|
|
|
/* Note: brinc is usable even if SPE is disabled */
|
2008-11-17 15:43:54 +01:00
|
|
|
gen_helper_brinc(cpu_gpr[rD(ctx->opcode)],
|
|
|
|
cpu_gpr[rA(ctx->opcode)], cpu_gpr[rB(ctx->opcode)]);
|
2007-03-20 23:11:31 +01:00
|
|
|
}
|
2009-08-16 11:06:54 +02:00
|
|
|
static inline void gen_evmergelo(DisasContext *ctx)
|
2008-11-10 12:10:23 +01:00
|
|
|
{
|
|
|
|
if (unlikely(!ctx->spe_enabled)) {
|
2011-08-23 06:55:43 +02:00
|
|
|
gen_exception(ctx, POWERPC_EXCP_SPEU);
|
2008-11-10 12:10:23 +01:00
|
|
|
return;
|
|
|
|
}
|
2014-06-04 22:58:50 +02:00
|
|
|
tcg_gen_mov_tl(cpu_gprh[rD(ctx->opcode)], cpu_gpr[rA(ctx->opcode)]);
|
|
|
|
tcg_gen_mov_tl(cpu_gpr[rD(ctx->opcode)], cpu_gpr[rB(ctx->opcode)]);
|
2008-11-10 12:10:23 +01:00
|
|
|
}
|
2009-08-16 11:06:54 +02:00
|
|
|
static inline void gen_evmergehilo(DisasContext *ctx)
|
2008-11-10 12:10:23 +01:00
|
|
|
{
|
|
|
|
if (unlikely(!ctx->spe_enabled)) {
|
2011-08-23 06:55:43 +02:00
|
|
|
gen_exception(ctx, POWERPC_EXCP_SPEU);
|
2008-11-10 12:10:23 +01:00
|
|
|
return;
|
|
|
|
}
|
2014-06-04 22:58:50 +02:00
|
|
|
tcg_gen_mov_tl(cpu_gpr[rD(ctx->opcode)], cpu_gpr[rB(ctx->opcode)]);
|
|
|
|
tcg_gen_mov_tl(cpu_gprh[rD(ctx->opcode)], cpu_gprh[rA(ctx->opcode)]);
|
2008-11-10 12:10:23 +01:00
|
|
|
}
|
2009-08-16 11:06:54 +02:00
|
|
|
static inline void gen_evmergelohi(DisasContext *ctx)
|
2008-11-10 12:10:23 +01:00
|
|
|
{
|
|
|
|
if (unlikely(!ctx->spe_enabled)) {
|
2011-08-23 06:55:43 +02:00
|
|
|
gen_exception(ctx, POWERPC_EXCP_SPEU);
|
2008-11-10 12:10:23 +01:00
|
|
|
return;
|
|
|
|
}
|
target-ppc: fix evmergelo and evmergelohi
For 32-bit PPC targets, we translated:
evmergelo rX, rX, rY
as:
rX-lo = rY-lo
rX-hi = rX-lo
which is wrong, because we should be transferring rX-lo first. This
problem is fixed by swapping the order in which we write the parts of
rX.
Similarly, we translated:
evmergelohi rX, rX, rY
as:
rX-lo = rY-hi
rX-hi = rX-lo
In this case, we can't swap the assignment statements, because that
would just cause problems for:
evmergelohi rX, rY, rX
Instead, we detect the first case and save rX-lo in a temporary
variable:
tmp = rX-lo
rX-lo = rY-hi
rX-hi = tmp
These problems don't occur on PPC64 targets because we don't split the
SPE registers into hi/lo parts for such targets.
Signed-off-by: Nathan Froyd <froydnj@codesourcery.com>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2009-06-04 22:46:41 +02:00
|
|
|
if (rD(ctx->opcode) == rA(ctx->opcode)) {
|
2014-06-04 22:58:50 +02:00
|
|
|
TCGv tmp = tcg_temp_new();
|
|
|
|
tcg_gen_mov_tl(tmp, cpu_gpr[rA(ctx->opcode)]);
|
|
|
|
tcg_gen_mov_tl(cpu_gpr[rD(ctx->opcode)], cpu_gprh[rB(ctx->opcode)]);
|
|
|
|
tcg_gen_mov_tl(cpu_gprh[rD(ctx->opcode)], tmp);
|
|
|
|
tcg_temp_free(tmp);
|
target-ppc: fix evmergelo and evmergelohi
For 32-bit PPC targets, we translated:
evmergelo rX, rX, rY
as:
rX-lo = rY-lo
rX-hi = rX-lo
which is wrong, because we should be transferring rX-lo first. This
problem is fixed by swapping the order in which we write the parts of
rX.
Similarly, we translated:
evmergelohi rX, rX, rY
as:
rX-lo = rY-hi
rX-hi = rX-lo
In this case, we can't swap the assignment statements, because that
would just cause problems for:
evmergelohi rX, rY, rX
Instead, we detect the first case and save rX-lo in a temporary
variable:
tmp = rX-lo
rX-lo = rY-hi
rX-hi = tmp
These problems don't occur on PPC64 targets because we don't split the
SPE registers into hi/lo parts for such targets.
Signed-off-by: Nathan Froyd <froydnj@codesourcery.com>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2009-06-04 22:46:41 +02:00
|
|
|
} else {
|
2014-06-04 22:58:50 +02:00
|
|
|
tcg_gen_mov_tl(cpu_gpr[rD(ctx->opcode)], cpu_gprh[rB(ctx->opcode)]);
|
|
|
|
tcg_gen_mov_tl(cpu_gprh[rD(ctx->opcode)], cpu_gpr[rA(ctx->opcode)]);
|
target-ppc: fix evmergelo and evmergelohi
For 32-bit PPC targets, we translated:
evmergelo rX, rX, rY
as:
rX-lo = rY-lo
rX-hi = rX-lo
which is wrong, because we should be transferring rX-lo first. This
problem is fixed by swapping the order in which we write the parts of
rX.
Similarly, we translated:
evmergelohi rX, rX, rY
as:
rX-lo = rY-hi
rX-hi = rX-lo
In this case, we can't swap the assignment statements, because that
would just cause problems for:
evmergelohi rX, rY, rX
Instead, we detect the first case and save rX-lo in a temporary
variable:
tmp = rX-lo
rX-lo = rY-hi
rX-hi = tmp
These problems don't occur on PPC64 targets because we don't split the
SPE registers into hi/lo parts for such targets.
Signed-off-by: Nathan Froyd <froydnj@codesourcery.com>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2009-06-04 22:46:41 +02:00
|
|
|
}
|
2008-11-10 12:10:23 +01:00
|
|
|
}
|
2009-08-16 11:06:54 +02:00
|
|
|
static inline void gen_evsplati(DisasContext *ctx)
|
2008-11-10 12:10:23 +01:00
|
|
|
{
|
2010-02-23 21:21:31 +01:00
|
|
|
uint64_t imm = ((int32_t)(rA(ctx->opcode) << 27)) >> 27;
|
2007-03-20 23:11:31 +01:00
|
|
|
|
2014-06-04 22:58:50 +02:00
|
|
|
tcg_gen_movi_tl(cpu_gpr[rD(ctx->opcode)], imm);
|
|
|
|
tcg_gen_movi_tl(cpu_gprh[rD(ctx->opcode)], imm);
|
2008-11-10 12:10:23 +01:00
|
|
|
}
|
2009-08-16 11:06:54 +02:00
|
|
|
static inline void gen_evsplatfi(DisasContext *ctx)
|
2007-03-20 23:11:31 +01:00
|
|
|
{
|
2010-02-23 21:21:31 +01:00
|
|
|
uint64_t imm = rA(ctx->opcode) << 27;
|
2007-03-20 23:11:31 +01:00
|
|
|
|
2014-06-04 22:58:50 +02:00
|
|
|
tcg_gen_movi_tl(cpu_gpr[rD(ctx->opcode)], imm);
|
|
|
|
tcg_gen_movi_tl(cpu_gprh[rD(ctx->opcode)], imm);
|
2007-03-20 23:11:31 +01:00
|
|
|
}
|
|
|
|
|
2009-08-16 11:06:54 +02:00
|
|
|
static inline void gen_evsel(DisasContext *ctx)
|
2008-11-10 12:10:23 +01:00
|
|
|
{
|
2015-02-13 21:51:55 +01:00
|
|
|
TCGLabel *l1 = gen_new_label();
|
|
|
|
TCGLabel *l2 = gen_new_label();
|
|
|
|
TCGLabel *l3 = gen_new_label();
|
|
|
|
TCGLabel *l4 = gen_new_label();
|
2008-11-17 15:43:54 +01:00
|
|
|
TCGv_i32 t0 = tcg_temp_local_new_i32();
|
2015-02-13 21:51:55 +01:00
|
|
|
|
2008-11-10 12:10:23 +01:00
|
|
|
tcg_gen_andi_i32(t0, cpu_crf[ctx->opcode & 0x07], 1 << 3);
|
|
|
|
tcg_gen_brcondi_i32(TCG_COND_EQ, t0, 0, l1);
|
|
|
|
tcg_gen_mov_tl(cpu_gprh[rD(ctx->opcode)], cpu_gprh[rA(ctx->opcode)]);
|
|
|
|
tcg_gen_br(l2);
|
|
|
|
gen_set_label(l1);
|
|
|
|
tcg_gen_mov_tl(cpu_gprh[rD(ctx->opcode)], cpu_gprh[rB(ctx->opcode)]);
|
|
|
|
gen_set_label(l2);
|
|
|
|
tcg_gen_andi_i32(t0, cpu_crf[ctx->opcode & 0x07], 1 << 2);
|
|
|
|
tcg_gen_brcondi_i32(TCG_COND_EQ, t0, 0, l3);
|
|
|
|
tcg_gen_mov_tl(cpu_gpr[rD(ctx->opcode)], cpu_gpr[rA(ctx->opcode)]);
|
|
|
|
tcg_gen_br(l4);
|
|
|
|
gen_set_label(l3);
|
|
|
|
tcg_gen_mov_tl(cpu_gpr[rD(ctx->opcode)], cpu_gpr[rB(ctx->opcode)]);
|
|
|
|
gen_set_label(l4);
|
2008-11-17 15:43:54 +01:00
|
|
|
tcg_temp_free_i32(t0);
|
2008-11-10 12:10:23 +01:00
|
|
|
}
|
2009-06-17 17:22:14 +02:00
|
|
|
|
|
|
|
static void gen_evsel0(DisasContext *ctx)
|
2008-11-10 12:10:23 +01:00
|
|
|
{
|
|
|
|
gen_evsel(ctx);
|
|
|
|
}
|
2009-06-17 17:22:14 +02:00
|
|
|
|
|
|
|
static void gen_evsel1(DisasContext *ctx)
|
2008-11-10 12:10:23 +01:00
|
|
|
{
|
|
|
|
gen_evsel(ctx);
|
|
|
|
}
|
2009-06-17 17:22:14 +02:00
|
|
|
|
|
|
|
static void gen_evsel2(DisasContext *ctx)
|
2008-11-10 12:10:23 +01:00
|
|
|
{
|
|
|
|
gen_evsel(ctx);
|
|
|
|
}
|
2009-06-17 17:22:14 +02:00
|
|
|
|
|
|
|
static void gen_evsel3(DisasContext *ctx)
|
2008-11-10 12:10:23 +01:00
|
|
|
{
|
|
|
|
gen_evsel(ctx);
|
|
|
|
}
|
2007-03-20 23:11:31 +01:00
|
|
|
|
2011-03-16 11:21:22 +01:00
|
|
|
/* Multiply */
|
|
|
|
|
|
|
|
static inline void gen_evmwumi(DisasContext *ctx)
|
|
|
|
{
|
|
|
|
TCGv_i64 t0, t1;
|
|
|
|
|
|
|
|
if (unlikely(!ctx->spe_enabled)) {
|
2011-08-23 06:55:43 +02:00
|
|
|
gen_exception(ctx, POWERPC_EXCP_SPEU);
|
2011-03-16 11:21:22 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
t0 = tcg_temp_new_i64();
|
|
|
|
t1 = tcg_temp_new_i64();
|
|
|
|
|
|
|
|
/* t0 := rA; t1 := rB */
|
|
|
|
tcg_gen_extu_tl_i64(t0, cpu_gpr[rA(ctx->opcode)]);
|
2014-06-04 22:58:50 +02:00
|
|
|
tcg_gen_ext32u_i64(t0, t0);
|
2011-03-16 11:21:22 +01:00
|
|
|
tcg_gen_extu_tl_i64(t1, cpu_gpr[rB(ctx->opcode)]);
|
2014-06-04 22:58:50 +02:00
|
|
|
tcg_gen_ext32u_i64(t1, t1);
|
2011-03-16 11:21:22 +01:00
|
|
|
|
|
|
|
tcg_gen_mul_i64(t0, t0, t1); /* t0 := rA * rB */
|
|
|
|
|
|
|
|
gen_store_gpr64(rD(ctx->opcode), t0); /* rD := t0 */
|
|
|
|
|
|
|
|
tcg_temp_free_i64(t0);
|
|
|
|
tcg_temp_free_i64(t1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void gen_evmwumia(DisasContext *ctx)
|
|
|
|
{
|
|
|
|
TCGv_i64 tmp;
|
|
|
|
|
|
|
|
if (unlikely(!ctx->spe_enabled)) {
|
2011-08-23 06:55:43 +02:00
|
|
|
gen_exception(ctx, POWERPC_EXCP_SPEU);
|
2011-03-16 11:21:22 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
gen_evmwumi(ctx); /* rD := rA * rB */
|
|
|
|
|
|
|
|
tmp = tcg_temp_new_i64();
|
|
|
|
|
|
|
|
/* acc := rD */
|
|
|
|
gen_load_gpr64(tmp, rD(ctx->opcode));
|
2012-03-14 01:38:22 +01:00
|
|
|
tcg_gen_st_i64(tmp, cpu_env, offsetof(CPUPPCState, spe_acc));
|
2011-03-16 11:21:22 +01:00
|
|
|
tcg_temp_free_i64(tmp);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void gen_evmwumiaa(DisasContext *ctx)
|
|
|
|
{
|
|
|
|
TCGv_i64 acc;
|
|
|
|
TCGv_i64 tmp;
|
|
|
|
|
|
|
|
if (unlikely(!ctx->spe_enabled)) {
|
2011-08-23 06:55:43 +02:00
|
|
|
gen_exception(ctx, POWERPC_EXCP_SPEU);
|
2011-03-16 11:21:22 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
gen_evmwumi(ctx); /* rD := rA * rB */
|
|
|
|
|
|
|
|
acc = tcg_temp_new_i64();
|
|
|
|
tmp = tcg_temp_new_i64();
|
|
|
|
|
|
|
|
/* tmp := rD */
|
|
|
|
gen_load_gpr64(tmp, rD(ctx->opcode));
|
|
|
|
|
|
|
|
/* Load acc */
|
2012-03-14 01:38:22 +01:00
|
|
|
tcg_gen_ld_i64(acc, cpu_env, offsetof(CPUPPCState, spe_acc));
|
2011-03-16 11:21:22 +01:00
|
|
|
|
|
|
|
/* acc := tmp + acc */
|
|
|
|
tcg_gen_add_i64(acc, acc, tmp);
|
|
|
|
|
|
|
|
/* Store acc */
|
2012-03-14 01:38:22 +01:00
|
|
|
tcg_gen_st_i64(acc, cpu_env, offsetof(CPUPPCState, spe_acc));
|
2011-03-16 11:21:22 +01:00
|
|
|
|
|
|
|
/* rD := acc */
|
|
|
|
gen_store_gpr64(rD(ctx->opcode), acc);
|
|
|
|
|
|
|
|
tcg_temp_free_i64(acc);
|
|
|
|
tcg_temp_free_i64(tmp);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void gen_evmwsmi(DisasContext *ctx)
|
|
|
|
{
|
|
|
|
TCGv_i64 t0, t1;
|
|
|
|
|
|
|
|
if (unlikely(!ctx->spe_enabled)) {
|
2011-08-23 06:55:43 +02:00
|
|
|
gen_exception(ctx, POWERPC_EXCP_SPEU);
|
2011-03-16 11:21:22 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
t0 = tcg_temp_new_i64();
|
|
|
|
t1 = tcg_temp_new_i64();
|
|
|
|
|
|
|
|
/* t0 := rA; t1 := rB */
|
2014-06-04 22:58:50 +02:00
|
|
|
tcg_gen_extu_tl_i64(t0, cpu_gpr[rA(ctx->opcode)]);
|
|
|
|
tcg_gen_ext32s_i64(t0, t0);
|
|
|
|
tcg_gen_extu_tl_i64(t1, cpu_gpr[rB(ctx->opcode)]);
|
|
|
|
tcg_gen_ext32s_i64(t1, t1);
|
2011-03-16 11:21:22 +01:00
|
|
|
|
|
|
|
tcg_gen_mul_i64(t0, t0, t1); /* t0 := rA * rB */
|
|
|
|
|
|
|
|
gen_store_gpr64(rD(ctx->opcode), t0); /* rD := t0 */
|
|
|
|
|
|
|
|
tcg_temp_free_i64(t0);
|
|
|
|
tcg_temp_free_i64(t1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void gen_evmwsmia(DisasContext *ctx)
|
|
|
|
{
|
|
|
|
TCGv_i64 tmp;
|
|
|
|
|
|
|
|
gen_evmwsmi(ctx); /* rD := rA * rB */
|
|
|
|
|
|
|
|
tmp = tcg_temp_new_i64();
|
|
|
|
|
|
|
|
/* acc := rD */
|
|
|
|
gen_load_gpr64(tmp, rD(ctx->opcode));
|
2012-03-14 01:38:22 +01:00
|
|
|
tcg_gen_st_i64(tmp, cpu_env, offsetof(CPUPPCState, spe_acc));
|
2011-03-16 11:21:22 +01:00
|
|
|
|
|
|
|
tcg_temp_free_i64(tmp);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void gen_evmwsmiaa(DisasContext *ctx)
|
|
|
|
{
|
|
|
|
TCGv_i64 acc = tcg_temp_new_i64();
|
|
|
|
TCGv_i64 tmp = tcg_temp_new_i64();
|
|
|
|
|
|
|
|
gen_evmwsmi(ctx); /* rD := rA * rB */
|
|
|
|
|
|
|
|
acc = tcg_temp_new_i64();
|
|
|
|
tmp = tcg_temp_new_i64();
|
|
|
|
|
|
|
|
/* tmp := rD */
|
|
|
|
gen_load_gpr64(tmp, rD(ctx->opcode));
|
|
|
|
|
|
|
|
/* Load acc */
|
2012-03-14 01:38:22 +01:00
|
|
|
tcg_gen_ld_i64(acc, cpu_env, offsetof(CPUPPCState, spe_acc));
|
2011-03-16 11:21:22 +01:00
|
|
|
|
|
|
|
/* acc := tmp + acc */
|
|
|
|
tcg_gen_add_i64(acc, acc, tmp);
|
|
|
|
|
|
|
|
/* Store acc */
|
2012-03-14 01:38:22 +01:00
|
|
|
tcg_gen_st_i64(acc, cpu_env, offsetof(CPUPPCState, spe_acc));
|
2011-03-16 11:21:22 +01:00
|
|
|
|
|
|
|
/* rD := acc */
|
|
|
|
gen_store_gpr64(rD(ctx->opcode), acc);
|
|
|
|
|
|
|
|
tcg_temp_free_i64(acc);
|
|
|
|
tcg_temp_free_i64(tmp);
|
|
|
|
}
|
|
|
|
|
2011-09-28 07:54:05 +02:00
|
|
|
GEN_SPE(evaddw, speundef, 0x00, 0x08, 0x00000000, 0xFFFFFFFF, PPC_SPE); ////
|
|
|
|
GEN_SPE(evaddiw, speundef, 0x01, 0x08, 0x00000000, 0xFFFFFFFF, PPC_SPE);
|
|
|
|
GEN_SPE(evsubfw, speundef, 0x02, 0x08, 0x00000000, 0xFFFFFFFF, PPC_SPE); ////
|
|
|
|
GEN_SPE(evsubifw, speundef, 0x03, 0x08, 0x00000000, 0xFFFFFFFF, PPC_SPE);
|
|
|
|
GEN_SPE(evabs, evneg, 0x04, 0x08, 0x0000F800, 0x0000F800, PPC_SPE); ////
|
|
|
|
GEN_SPE(evextsb, evextsh, 0x05, 0x08, 0x0000F800, 0x0000F800, PPC_SPE); ////
|
|
|
|
GEN_SPE(evrndw, evcntlzw, 0x06, 0x08, 0x0000F800, 0x0000F800, PPC_SPE); ////
|
|
|
|
GEN_SPE(evcntlsw, brinc, 0x07, 0x08, 0x0000F800, 0x00000000, PPC_SPE); //
|
|
|
|
GEN_SPE(evmra, speundef, 0x02, 0x13, 0x0000F800, 0xFFFFFFFF, PPC_SPE);
|
|
|
|
GEN_SPE(speundef, evand, 0x08, 0x08, 0xFFFFFFFF, 0x00000000, PPC_SPE); ////
|
|
|
|
GEN_SPE(evandc, speundef, 0x09, 0x08, 0x00000000, 0xFFFFFFFF, PPC_SPE); ////
|
|
|
|
GEN_SPE(evxor, evor, 0x0B, 0x08, 0x00000000, 0x00000000, PPC_SPE); ////
|
|
|
|
GEN_SPE(evnor, eveqv, 0x0C, 0x08, 0x00000000, 0x00000000, PPC_SPE); ////
|
|
|
|
GEN_SPE(evmwumi, evmwsmi, 0x0C, 0x11, 0x00000000, 0x00000000, PPC_SPE);
|
|
|
|
GEN_SPE(evmwumia, evmwsmia, 0x1C, 0x11, 0x00000000, 0x00000000, PPC_SPE);
|
|
|
|
GEN_SPE(evmwumiaa, evmwsmiaa, 0x0C, 0x15, 0x00000000, 0x00000000, PPC_SPE);
|
|
|
|
GEN_SPE(speundef, evorc, 0x0D, 0x08, 0xFFFFFFFF, 0x00000000, PPC_SPE); ////
|
|
|
|
GEN_SPE(evnand, speundef, 0x0F, 0x08, 0x00000000, 0xFFFFFFFF, PPC_SPE); ////
|
|
|
|
GEN_SPE(evsrwu, evsrws, 0x10, 0x08, 0x00000000, 0x00000000, PPC_SPE); ////
|
|
|
|
GEN_SPE(evsrwiu, evsrwis, 0x11, 0x08, 0x00000000, 0x00000000, PPC_SPE);
|
|
|
|
GEN_SPE(evslw, speundef, 0x12, 0x08, 0x00000000, 0xFFFFFFFF, PPC_SPE); ////
|
|
|
|
GEN_SPE(evslwi, speundef, 0x13, 0x08, 0x00000000, 0xFFFFFFFF, PPC_SPE);
|
|
|
|
GEN_SPE(evrlw, evsplati, 0x14, 0x08, 0x00000000, 0x0000F800, PPC_SPE); //
|
|
|
|
GEN_SPE(evrlwi, evsplatfi, 0x15, 0x08, 0x00000000, 0x0000F800, PPC_SPE);
|
|
|
|
GEN_SPE(evmergehi, evmergelo, 0x16, 0x08, 0x00000000, 0x00000000, PPC_SPE); ////
|
|
|
|
GEN_SPE(evmergehilo, evmergelohi, 0x17, 0x08, 0x00000000, 0x00000000, PPC_SPE); ////
|
|
|
|
GEN_SPE(evcmpgtu, evcmpgts, 0x18, 0x08, 0x00600000, 0x00600000, PPC_SPE); ////
|
|
|
|
GEN_SPE(evcmpltu, evcmplts, 0x19, 0x08, 0x00600000, 0x00600000, PPC_SPE); ////
|
|
|
|
GEN_SPE(evcmpeq, speundef, 0x1A, 0x08, 0x00600000, 0xFFFFFFFF, PPC_SPE); ////
|
2007-03-20 23:11:31 +01:00
|
|
|
|
2008-11-27 20:30:47 +01:00
|
|
|
/* SPE load and stores */
|
2009-08-16 11:06:54 +02:00
|
|
|
static inline void gen_addr_spe_imm_index(DisasContext *ctx, TCGv EA, int sh)
|
2008-11-27 20:30:47 +01:00
|
|
|
{
|
|
|
|
target_ulong uimm = rB(ctx->opcode);
|
|
|
|
|
2008-12-08 19:11:21 +01:00
|
|
|
if (rA(ctx->opcode) == 0) {
|
2008-11-27 20:30:47 +01:00
|
|
|
tcg_gen_movi_tl(EA, uimm << sh);
|
2008-12-08 19:11:21 +01:00
|
|
|
} else {
|
2008-11-27 20:30:47 +01:00
|
|
|
tcg_gen_addi_tl(EA, cpu_gpr[rA(ctx->opcode)], uimm << sh);
|
2013-03-21 11:01:48 +01:00
|
|
|
if (NARROW_MODE(ctx)) {
|
2008-12-08 19:11:21 +01:00
|
|
|
tcg_gen_ext32u_tl(EA, EA);
|
|
|
|
}
|
|
|
|
}
|
2007-03-20 23:11:31 +01:00
|
|
|
}
|
2008-11-27 20:30:47 +01:00
|
|
|
|
2009-08-16 11:06:54 +02:00
|
|
|
static inline void gen_op_evldd(DisasContext *ctx, TCGv addr)
|
2008-11-27 20:30:47 +01:00
|
|
|
{
|
|
|
|
TCGv_i64 t0 = tcg_temp_new_i64();
|
2008-12-08 19:11:21 +01:00
|
|
|
gen_qemu_ld64(ctx, t0, addr);
|
2014-06-04 22:58:50 +02:00
|
|
|
gen_store_gpr64(rD(ctx->opcode), t0);
|
2008-11-27 20:30:47 +01:00
|
|
|
tcg_temp_free_i64(t0);
|
2007-03-20 23:11:31 +01:00
|
|
|
}
|
2008-11-27 20:30:47 +01:00
|
|
|
|
2009-08-16 11:06:54 +02:00
|
|
|
static inline void gen_op_evldw(DisasContext *ctx, TCGv addr)
|
2008-11-27 20:30:47 +01:00
|
|
|
{
|
2008-12-08 19:11:21 +01:00
|
|
|
gen_qemu_ld32u(ctx, cpu_gprh[rD(ctx->opcode)], addr);
|
|
|
|
gen_addr_add(ctx, addr, addr, 4);
|
|
|
|
gen_qemu_ld32u(ctx, cpu_gpr[rD(ctx->opcode)], addr);
|
2007-03-20 23:11:31 +01:00
|
|
|
}
|
2008-11-27 20:30:47 +01:00
|
|
|
|
2009-08-16 11:06:54 +02:00
|
|
|
static inline void gen_op_evldh(DisasContext *ctx, TCGv addr)
|
2008-11-27 20:30:47 +01:00
|
|
|
{
|
|
|
|
TCGv t0 = tcg_temp_new();
|
2008-12-08 19:11:21 +01:00
|
|
|
gen_qemu_ld16u(ctx, t0, addr);
|
2008-11-27 20:30:47 +01:00
|
|
|
tcg_gen_shli_tl(cpu_gprh[rD(ctx->opcode)], t0, 16);
|
2008-12-08 19:11:21 +01:00
|
|
|
gen_addr_add(ctx, addr, addr, 2);
|
|
|
|
gen_qemu_ld16u(ctx, t0, addr);
|
2008-11-27 20:30:47 +01:00
|
|
|
tcg_gen_or_tl(cpu_gprh[rD(ctx->opcode)], cpu_gprh[rD(ctx->opcode)], t0);
|
2008-12-08 19:11:21 +01:00
|
|
|
gen_addr_add(ctx, addr, addr, 2);
|
|
|
|
gen_qemu_ld16u(ctx, t0, addr);
|
2008-11-27 20:30:47 +01:00
|
|
|
tcg_gen_shli_tl(cpu_gprh[rD(ctx->opcode)], t0, 16);
|
2008-12-08 19:11:21 +01:00
|
|
|
gen_addr_add(ctx, addr, addr, 2);
|
|
|
|
gen_qemu_ld16u(ctx, t0, addr);
|
2008-11-27 20:30:47 +01:00
|
|
|
tcg_gen_or_tl(cpu_gpr[rD(ctx->opcode)], cpu_gpr[rD(ctx->opcode)], t0);
|
|
|
|
tcg_temp_free(t0);
|
2007-03-20 23:11:31 +01:00
|
|
|
}
|
|
|
|
|
2009-08-16 11:06:54 +02:00
|
|
|
static inline void gen_op_evlhhesplat(DisasContext *ctx, TCGv addr)
|
2008-11-27 20:30:47 +01:00
|
|
|
{
|
|
|
|
TCGv t0 = tcg_temp_new();
|
2008-12-08 19:11:21 +01:00
|
|
|
gen_qemu_ld16u(ctx, t0, addr);
|
2008-11-27 20:30:47 +01:00
|
|
|
tcg_gen_shli_tl(t0, t0, 16);
|
|
|
|
tcg_gen_mov_tl(cpu_gprh[rD(ctx->opcode)], t0);
|
|
|
|
tcg_gen_mov_tl(cpu_gpr[rD(ctx->opcode)], t0);
|
|
|
|
tcg_temp_free(t0);
|
2007-03-20 23:11:31 +01:00
|
|
|
}
|
|
|
|
|
2009-08-16 11:06:54 +02:00
|
|
|
static inline void gen_op_evlhhousplat(DisasContext *ctx, TCGv addr)
|
2008-11-27 20:30:47 +01:00
|
|
|
{
|
|
|
|
TCGv t0 = tcg_temp_new();
|
2008-12-08 19:11:21 +01:00
|
|
|
gen_qemu_ld16u(ctx, t0, addr);
|
2008-11-27 20:30:47 +01:00
|
|
|
tcg_gen_mov_tl(cpu_gprh[rD(ctx->opcode)], t0);
|
|
|
|
tcg_gen_mov_tl(cpu_gpr[rD(ctx->opcode)], t0);
|
|
|
|
tcg_temp_free(t0);
|
2007-03-20 23:11:31 +01:00
|
|
|
}
|
|
|
|
|
2009-08-16 11:06:54 +02:00
|
|
|
static inline void gen_op_evlhhossplat(DisasContext *ctx, TCGv addr)
|
2008-11-27 20:30:47 +01:00
|
|
|
{
|
|
|
|
TCGv t0 = tcg_temp_new();
|
2008-12-08 19:11:21 +01:00
|
|
|
gen_qemu_ld16s(ctx, t0, addr);
|
2008-11-27 20:30:47 +01:00
|
|
|
tcg_gen_mov_tl(cpu_gprh[rD(ctx->opcode)], t0);
|
|
|
|
tcg_gen_mov_tl(cpu_gpr[rD(ctx->opcode)], t0);
|
|
|
|
tcg_temp_free(t0);
|
|
|
|
}
|
|
|
|
|
2009-08-16 11:06:54 +02:00
|
|
|
static inline void gen_op_evlwhe(DisasContext *ctx, TCGv addr)
|
2008-11-27 20:30:47 +01:00
|
|
|
{
|
|
|
|
TCGv t0 = tcg_temp_new();
|
2008-12-08 19:11:21 +01:00
|
|
|
gen_qemu_ld16u(ctx, t0, addr);
|
2008-11-27 20:30:47 +01:00
|
|
|
tcg_gen_shli_tl(cpu_gprh[rD(ctx->opcode)], t0, 16);
|
2008-12-08 19:11:21 +01:00
|
|
|
gen_addr_add(ctx, addr, addr, 2);
|
|
|
|
gen_qemu_ld16u(ctx, t0, addr);
|
2008-11-27 20:30:47 +01:00
|
|
|
tcg_gen_shli_tl(cpu_gpr[rD(ctx->opcode)], t0, 16);
|
|
|
|
tcg_temp_free(t0);
|
|
|
|
}
|
|
|
|
|
2009-08-16 11:06:54 +02:00
|
|
|
static inline void gen_op_evlwhou(DisasContext *ctx, TCGv addr)
|
2008-11-27 20:30:47 +01:00
|
|
|
{
|
2008-12-08 19:11:21 +01:00
|
|
|
gen_qemu_ld16u(ctx, cpu_gprh[rD(ctx->opcode)], addr);
|
|
|
|
gen_addr_add(ctx, addr, addr, 2);
|
|
|
|
gen_qemu_ld16u(ctx, cpu_gpr[rD(ctx->opcode)], addr);
|
2008-11-27 20:30:47 +01:00
|
|
|
}
|
|
|
|
|
2009-08-16 11:06:54 +02:00
|
|
|
static inline void gen_op_evlwhos(DisasContext *ctx, TCGv addr)
|
2008-11-27 20:30:47 +01:00
|
|
|
{
|
2008-12-08 19:11:21 +01:00
|
|
|
gen_qemu_ld16s(ctx, cpu_gprh[rD(ctx->opcode)], addr);
|
|
|
|
gen_addr_add(ctx, addr, addr, 2);
|
|
|
|
gen_qemu_ld16s(ctx, cpu_gpr[rD(ctx->opcode)], addr);
|
2008-11-27 20:30:47 +01:00
|
|
|
}
|
|
|
|
|
2009-08-16 11:06:54 +02:00
|
|
|
static inline void gen_op_evlwwsplat(DisasContext *ctx, TCGv addr)
|
2008-11-27 20:30:47 +01:00
|
|
|
{
|
|
|
|
TCGv t0 = tcg_temp_new();
|
2008-12-08 19:11:21 +01:00
|
|
|
gen_qemu_ld32u(ctx, t0, addr);
|
2008-11-27 20:30:47 +01:00
|
|
|
tcg_gen_mov_tl(cpu_gprh[rD(ctx->opcode)], t0);
|
|
|
|
tcg_gen_mov_tl(cpu_gpr[rD(ctx->opcode)], t0);
|
|
|
|
tcg_temp_free(t0);
|
|
|
|
}
|
|
|
|
|
2009-08-16 11:06:54 +02:00
|
|
|
static inline void gen_op_evlwhsplat(DisasContext *ctx, TCGv addr)
|
2008-11-27 20:30:47 +01:00
|
|
|
{
|
|
|
|
TCGv t0 = tcg_temp_new();
|
2008-12-08 19:11:21 +01:00
|
|
|
gen_qemu_ld16u(ctx, t0, addr);
|
2008-11-27 20:30:47 +01:00
|
|
|
tcg_gen_shli_tl(cpu_gprh[rD(ctx->opcode)], t0, 16);
|
|
|
|
tcg_gen_or_tl(cpu_gprh[rD(ctx->opcode)], cpu_gprh[rD(ctx->opcode)], t0);
|
2008-12-08 19:11:21 +01:00
|
|
|
gen_addr_add(ctx, addr, addr, 2);
|
|
|
|
gen_qemu_ld16u(ctx, t0, addr);
|
2008-11-27 20:30:47 +01:00
|
|
|
tcg_gen_shli_tl(cpu_gpr[rD(ctx->opcode)], t0, 16);
|
|
|
|
tcg_gen_or_tl(cpu_gpr[rD(ctx->opcode)], cpu_gprh[rD(ctx->opcode)], t0);
|
|
|
|
tcg_temp_free(t0);
|
|
|
|
}
|
|
|
|
|
2009-08-16 11:06:54 +02:00
|
|
|
static inline void gen_op_evstdd(DisasContext *ctx, TCGv addr)
|
2008-11-27 20:30:47 +01:00
|
|
|
{
|
|
|
|
TCGv_i64 t0 = tcg_temp_new_i64();
|
2014-06-04 22:58:50 +02:00
|
|
|
gen_load_gpr64(t0, rS(ctx->opcode));
|
2008-12-08 19:11:21 +01:00
|
|
|
gen_qemu_st64(ctx, t0, addr);
|
2008-11-27 20:30:47 +01:00
|
|
|
tcg_temp_free_i64(t0);
|
|
|
|
}
|
|
|
|
|
2009-08-16 11:06:54 +02:00
|
|
|
static inline void gen_op_evstdw(DisasContext *ctx, TCGv addr)
|
2008-11-27 20:30:47 +01:00
|
|
|
{
|
2008-12-08 19:11:21 +01:00
|
|
|
gen_qemu_st32(ctx, cpu_gprh[rS(ctx->opcode)], addr);
|
|
|
|
gen_addr_add(ctx, addr, addr, 4);
|
|
|
|
gen_qemu_st32(ctx, cpu_gpr[rS(ctx->opcode)], addr);
|
2008-11-27 20:30:47 +01:00
|
|
|
}
|
|
|
|
|
2009-08-16 11:06:54 +02:00
|
|
|
static inline void gen_op_evstdh(DisasContext *ctx, TCGv addr)
|
2008-11-27 20:30:47 +01:00
|
|
|
{
|
|
|
|
TCGv t0 = tcg_temp_new();
|
|
|
|
tcg_gen_shri_tl(t0, cpu_gprh[rS(ctx->opcode)], 16);
|
2008-12-08 19:11:21 +01:00
|
|
|
gen_qemu_st16(ctx, t0, addr);
|
|
|
|
gen_addr_add(ctx, addr, addr, 2);
|
|
|
|
gen_qemu_st16(ctx, cpu_gprh[rS(ctx->opcode)], addr);
|
|
|
|
gen_addr_add(ctx, addr, addr, 2);
|
2008-11-27 20:30:47 +01:00
|
|
|
tcg_gen_shri_tl(t0, cpu_gpr[rS(ctx->opcode)], 16);
|
2008-12-08 19:11:21 +01:00
|
|
|
gen_qemu_st16(ctx, t0, addr);
|
2008-11-27 20:30:47 +01:00
|
|
|
tcg_temp_free(t0);
|
2008-12-08 19:11:21 +01:00
|
|
|
gen_addr_add(ctx, addr, addr, 2);
|
|
|
|
gen_qemu_st16(ctx, cpu_gpr[rS(ctx->opcode)], addr);
|
2008-11-27 20:30:47 +01:00
|
|
|
}
|
|
|
|
|
2009-08-16 11:06:54 +02:00
|
|
|
static inline void gen_op_evstwhe(DisasContext *ctx, TCGv addr)
|
2008-11-27 20:30:47 +01:00
|
|
|
{
|
|
|
|
TCGv t0 = tcg_temp_new();
|
|
|
|
tcg_gen_shri_tl(t0, cpu_gprh[rS(ctx->opcode)], 16);
|
2008-12-08 19:11:21 +01:00
|
|
|
gen_qemu_st16(ctx, t0, addr);
|
|
|
|
gen_addr_add(ctx, addr, addr, 2);
|
2008-11-27 20:30:47 +01:00
|
|
|
tcg_gen_shri_tl(t0, cpu_gpr[rS(ctx->opcode)], 16);
|
2008-12-08 19:11:21 +01:00
|
|
|
gen_qemu_st16(ctx, t0, addr);
|
2008-11-27 20:30:47 +01:00
|
|
|
tcg_temp_free(t0);
|
|
|
|
}
|
|
|
|
|
2009-08-16 11:06:54 +02:00
|
|
|
static inline void gen_op_evstwho(DisasContext *ctx, TCGv addr)
|
2008-11-27 20:30:47 +01:00
|
|
|
{
|
2008-12-08 19:11:21 +01:00
|
|
|
gen_qemu_st16(ctx, cpu_gprh[rS(ctx->opcode)], addr);
|
|
|
|
gen_addr_add(ctx, addr, addr, 2);
|
|
|
|
gen_qemu_st16(ctx, cpu_gpr[rS(ctx->opcode)], addr);
|
2008-11-27 20:30:47 +01:00
|
|
|
}
|
|
|
|
|
2009-08-16 11:06:54 +02:00
|
|
|
static inline void gen_op_evstwwe(DisasContext *ctx, TCGv addr)
|
2008-11-27 20:30:47 +01:00
|
|
|
{
|
2008-12-08 19:11:21 +01:00
|
|
|
gen_qemu_st32(ctx, cpu_gprh[rS(ctx->opcode)], addr);
|
2008-11-27 20:30:47 +01:00
|
|
|
}
|
|
|
|
|
2009-08-16 11:06:54 +02:00
|
|
|
static inline void gen_op_evstwwo(DisasContext *ctx, TCGv addr)
|
2008-11-27 20:30:47 +01:00
|
|
|
{
|
2008-12-08 19:11:21 +01:00
|
|
|
gen_qemu_st32(ctx, cpu_gpr[rS(ctx->opcode)], addr);
|
2008-11-27 20:30:47 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
#define GEN_SPEOP_LDST(name, opc2, sh) \
|
2009-06-17 17:22:09 +02:00
|
|
|
static void glue(gen_, name)(DisasContext *ctx) \
|
2008-11-27 20:30:47 +01:00
|
|
|
{ \
|
|
|
|
TCGv t0; \
|
|
|
|
if (unlikely(!ctx->spe_enabled)) { \
|
2011-08-23 06:55:43 +02:00
|
|
|
gen_exception(ctx, POWERPC_EXCP_SPEU); \
|
2008-11-27 20:30:47 +01:00
|
|
|
return; \
|
|
|
|
} \
|
2008-12-08 19:11:21 +01:00
|
|
|
gen_set_access_type(ctx, ACCESS_INT); \
|
2008-11-27 20:30:47 +01:00
|
|
|
t0 = tcg_temp_new(); \
|
|
|
|
if (Rc(ctx->opcode)) { \
|
2008-12-08 19:11:21 +01:00
|
|
|
gen_addr_spe_imm_index(ctx, t0, sh); \
|
2008-11-27 20:30:47 +01:00
|
|
|
} else { \
|
2008-12-08 19:11:21 +01:00
|
|
|
gen_addr_reg_index(ctx, t0); \
|
2008-11-27 20:30:47 +01:00
|
|
|
} \
|
|
|
|
gen_op_##name(ctx, t0); \
|
|
|
|
tcg_temp_free(t0); \
|
|
|
|
}
|
|
|
|
|
|
|
|
GEN_SPEOP_LDST(evldd, 0x00, 3);
|
|
|
|
GEN_SPEOP_LDST(evldw, 0x01, 3);
|
|
|
|
GEN_SPEOP_LDST(evldh, 0x02, 3);
|
|
|
|
GEN_SPEOP_LDST(evlhhesplat, 0x04, 1);
|
|
|
|
GEN_SPEOP_LDST(evlhhousplat, 0x06, 1);
|
|
|
|
GEN_SPEOP_LDST(evlhhossplat, 0x07, 1);
|
|
|
|
GEN_SPEOP_LDST(evlwhe, 0x08, 2);
|
|
|
|
GEN_SPEOP_LDST(evlwhou, 0x0A, 2);
|
|
|
|
GEN_SPEOP_LDST(evlwhos, 0x0B, 2);
|
|
|
|
GEN_SPEOP_LDST(evlwwsplat, 0x0C, 2);
|
|
|
|
GEN_SPEOP_LDST(evlwhsplat, 0x0E, 2);
|
|
|
|
|
|
|
|
GEN_SPEOP_LDST(evstdd, 0x10, 3);
|
|
|
|
GEN_SPEOP_LDST(evstdw, 0x11, 3);
|
|
|
|
GEN_SPEOP_LDST(evstdh, 0x12, 3);
|
|
|
|
GEN_SPEOP_LDST(evstwhe, 0x18, 2);
|
|
|
|
GEN_SPEOP_LDST(evstwho, 0x1A, 2);
|
|
|
|
GEN_SPEOP_LDST(evstwwe, 0x1C, 2);
|
|
|
|
GEN_SPEOP_LDST(evstwwo, 0x1E, 2);
|
2007-03-20 23:11:31 +01:00
|
|
|
|
|
|
|
/* Multiply and add - TODO */
|
|
|
|
#if 0
|
2011-09-28 07:54:05 +02:00
|
|
|
GEN_SPE(speundef, evmhessf, 0x01, 0x10, 0xFFFFFFFF, 0x00000000, PPC_SPE);//
|
|
|
|
GEN_SPE(speundef, evmhossf, 0x03, 0x10, 0xFFFFFFFF, 0x00000000, PPC_SPE);
|
|
|
|
GEN_SPE(evmheumi, evmhesmi, 0x04, 0x10, 0x00000000, 0x00000000, PPC_SPE);
|
|
|
|
GEN_SPE(speundef, evmhesmf, 0x05, 0x10, 0xFFFFFFFF, 0x00000000, PPC_SPE);
|
|
|
|
GEN_SPE(evmhoumi, evmhosmi, 0x06, 0x10, 0x00000000, 0x00000000, PPC_SPE);
|
|
|
|
GEN_SPE(speundef, evmhosmf, 0x07, 0x10, 0xFFFFFFFF, 0x00000000, PPC_SPE);
|
|
|
|
GEN_SPE(speundef, evmhessfa, 0x11, 0x10, 0xFFFFFFFF, 0x00000000, PPC_SPE);
|
|
|
|
GEN_SPE(speundef, evmhossfa, 0x13, 0x10, 0xFFFFFFFF, 0x00000000, PPC_SPE);
|
|
|
|
GEN_SPE(evmheumia, evmhesmia, 0x14, 0x10, 0x00000000, 0x00000000, PPC_SPE);
|
|
|
|
GEN_SPE(speundef, evmhesmfa, 0x15, 0x10, 0xFFFFFFFF, 0x00000000, PPC_SPE);
|
|
|
|
GEN_SPE(evmhoumia, evmhosmia, 0x16, 0x10, 0x00000000, 0x00000000, PPC_SPE);
|
|
|
|
GEN_SPE(speundef, evmhosmfa, 0x17, 0x10, 0xFFFFFFFF, 0x00000000, PPC_SPE);
|
|
|
|
|
|
|
|
GEN_SPE(speundef, evmwhssf, 0x03, 0x11, 0xFFFFFFFF, 0x00000000, PPC_SPE);
|
|
|
|
GEN_SPE(evmwlumi, speundef, 0x04, 0x11, 0x00000000, 0xFFFFFFFF, PPC_SPE);
|
|
|
|
GEN_SPE(evmwhumi, evmwhsmi, 0x06, 0x11, 0x00000000, 0x00000000, PPC_SPE);
|
|
|
|
GEN_SPE(speundef, evmwhsmf, 0x07, 0x11, 0xFFFFFFFF, 0x00000000, PPC_SPE);
|
|
|
|
GEN_SPE(speundef, evmwssf, 0x09, 0x11, 0xFFFFFFFF, 0x00000000, PPC_SPE);
|
|
|
|
GEN_SPE(speundef, evmwsmf, 0x0D, 0x11, 0xFFFFFFFF, 0x00000000, PPC_SPE);
|
|
|
|
GEN_SPE(speundef, evmwhssfa, 0x13, 0x11, 0xFFFFFFFF, 0x00000000, PPC_SPE);
|
|
|
|
GEN_SPE(evmwlumia, speundef, 0x14, 0x11, 0x00000000, 0xFFFFFFFF, PPC_SPE);
|
|
|
|
GEN_SPE(evmwhumia, evmwhsmia, 0x16, 0x11, 0x00000000, 0x00000000, PPC_SPE);
|
|
|
|
GEN_SPE(speundef, evmwhsmfa, 0x17, 0x11, 0xFFFFFFFF, 0x00000000, PPC_SPE);
|
|
|
|
GEN_SPE(speundef, evmwssfa, 0x19, 0x11, 0xFFFFFFFF, 0x00000000, PPC_SPE);
|
|
|
|
GEN_SPE(speundef, evmwsmfa, 0x1D, 0x11, 0xFFFFFFFF, 0x00000000, PPC_SPE);
|
|
|
|
|
|
|
|
GEN_SPE(evadduiaaw, evaddsiaaw, 0x00, 0x13, 0x0000F800, 0x0000F800, PPC_SPE);
|
|
|
|
GEN_SPE(evsubfusiaaw, evsubfssiaaw, 0x01, 0x13, 0x0000F800, 0x0000F800, PPC_SPE);
|
|
|
|
GEN_SPE(evaddumiaaw, evaddsmiaaw, 0x04, 0x13, 0x0000F800, 0x0000F800, PPC_SPE);
|
|
|
|
GEN_SPE(evsubfumiaaw, evsubfsmiaaw, 0x05, 0x13, 0x0000F800, 0x0000F800, PPC_SPE);
|
|
|
|
GEN_SPE(evdivws, evdivwu, 0x06, 0x13, 0x00000000, 0x00000000, PPC_SPE);
|
|
|
|
|
|
|
|
GEN_SPE(evmheusiaaw, evmhessiaaw, 0x00, 0x14, 0x00000000, 0x00000000, PPC_SPE);
|
|
|
|
GEN_SPE(speundef, evmhessfaaw, 0x01, 0x14, 0xFFFFFFFF, 0x00000000, PPC_SPE);
|
|
|
|
GEN_SPE(evmhousiaaw, evmhossiaaw, 0x02, 0x14, 0x00000000, 0x00000000, PPC_SPE);
|
|
|
|
GEN_SPE(speundef, evmhossfaaw, 0x03, 0x14, 0xFFFFFFFF, 0x00000000, PPC_SPE);
|
|
|
|
GEN_SPE(evmheumiaaw, evmhesmiaaw, 0x04, 0x14, 0x00000000, 0x00000000, PPC_SPE);
|
|
|
|
GEN_SPE(speundef, evmhesmfaaw, 0x05, 0x14, 0xFFFFFFFF, 0x00000000, PPC_SPE);
|
|
|
|
GEN_SPE(evmhoumiaaw, evmhosmiaaw, 0x06, 0x14, 0x00000000, 0x00000000, PPC_SPE);
|
|
|
|
GEN_SPE(speundef, evmhosmfaaw, 0x07, 0x14, 0xFFFFFFFF, 0x00000000, PPC_SPE);
|
|
|
|
GEN_SPE(evmhegumiaa, evmhegsmiaa, 0x14, 0x14, 0x00000000, 0x00000000, PPC_SPE);
|
|
|
|
GEN_SPE(speundef, evmhegsmfaa, 0x15, 0x14, 0xFFFFFFFF, 0x00000000, PPC_SPE);
|
|
|
|
GEN_SPE(evmhogumiaa, evmhogsmiaa, 0x16, 0x14, 0x00000000, 0x00000000, PPC_SPE);
|
|
|
|
GEN_SPE(speundef, evmhogsmfaa, 0x17, 0x14, 0xFFFFFFFF, 0x00000000, PPC_SPE);
|
|
|
|
|
|
|
|
GEN_SPE(evmwlusiaaw, evmwlssiaaw, 0x00, 0x15, 0x00000000, 0x00000000, PPC_SPE);
|
|
|
|
GEN_SPE(evmwlumiaaw, evmwlsmiaaw, 0x04, 0x15, 0x00000000, 0x00000000, PPC_SPE);
|
|
|
|
GEN_SPE(speundef, evmwssfaa, 0x09, 0x15, 0xFFFFFFFF, 0x00000000, PPC_SPE);
|
|
|
|
GEN_SPE(speundef, evmwsmfaa, 0x0D, 0x15, 0xFFFFFFFF, 0x00000000, PPC_SPE);
|
|
|
|
|
|
|
|
GEN_SPE(evmheusianw, evmhessianw, 0x00, 0x16, 0x00000000, 0x00000000, PPC_SPE);
|
|
|
|
GEN_SPE(speundef, evmhessfanw, 0x01, 0x16, 0xFFFFFFFF, 0x00000000, PPC_SPE);
|
|
|
|
GEN_SPE(evmhousianw, evmhossianw, 0x02, 0x16, 0x00000000, 0x00000000, PPC_SPE);
|
|
|
|
GEN_SPE(speundef, evmhossfanw, 0x03, 0x16, 0xFFFFFFFF, 0x00000000, PPC_SPE);
|
|
|
|
GEN_SPE(evmheumianw, evmhesmianw, 0x04, 0x16, 0x00000000, 0x00000000, PPC_SPE);
|
|
|
|
GEN_SPE(speundef, evmhesmfanw, 0x05, 0x16, 0xFFFFFFFF, 0x00000000, PPC_SPE);
|
|
|
|
GEN_SPE(evmhoumianw, evmhosmianw, 0x06, 0x16, 0x00000000, 0x00000000, PPC_SPE);
|
|
|
|
GEN_SPE(speundef, evmhosmfanw, 0x07, 0x16, 0xFFFFFFFF, 0x00000000, PPC_SPE);
|
|
|
|
GEN_SPE(evmhegumian, evmhegsmian, 0x14, 0x16, 0x00000000, 0x00000000, PPC_SPE);
|
|
|
|
GEN_SPE(speundef, evmhegsmfan, 0x15, 0x16, 0xFFFFFFFF, 0x00000000, PPC_SPE);
|
|
|
|
GEN_SPE(evmhigumian, evmhigsmian, 0x16, 0x16, 0x00000000, 0x00000000, PPC_SPE);
|
|
|
|
GEN_SPE(speundef, evmhogsmfan, 0x17, 0x16, 0xFFFFFFFF, 0x00000000, PPC_SPE);
|
|
|
|
|
|
|
|
GEN_SPE(evmwlusianw, evmwlssianw, 0x00, 0x17, 0x00000000, 0x00000000, PPC_SPE);
|
|
|
|
GEN_SPE(evmwlumianw, evmwlsmianw, 0x04, 0x17, 0x00000000, 0x00000000, PPC_SPE);
|
|
|
|
GEN_SPE(speundef, evmwssfan, 0x09, 0x17, 0xFFFFFFFF, 0x00000000, PPC_SPE);
|
|
|
|
GEN_SPE(evmwumian, evmwsmian, 0x0C, 0x17, 0x00000000, 0x00000000, PPC_SPE);
|
|
|
|
GEN_SPE(speundef, evmwsmfan, 0x0D, 0x17, 0xFFFFFFFF, 0x00000000, PPC_SPE);
|
2007-03-20 23:11:31 +01:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/*** SPE floating-point extension ***/
|
2008-11-23 11:54:04 +01:00
|
|
|
#define GEN_SPEFPUOP_CONV_32_32(name) \
|
2009-08-16 11:06:54 +02:00
|
|
|
static inline void gen_##name(DisasContext *ctx) \
|
2008-11-23 11:54:04 +01:00
|
|
|
{ \
|
|
|
|
TCGv_i32 t0 = tcg_temp_new_i32(); \
|
|
|
|
tcg_gen_trunc_tl_i32(t0, cpu_gpr[rB(ctx->opcode)]); \
|
2014-06-04 22:58:50 +02:00
|
|
|
gen_helper_##name(t0, cpu_env, t0); \
|
|
|
|
tcg_gen_extu_i32_tl(cpu_gpr[rD(ctx->opcode)], t0); \
|
2008-11-23 11:54:04 +01:00
|
|
|
tcg_temp_free_i32(t0); \
|
2008-11-10 12:10:23 +01:00
|
|
|
}
|
2008-11-23 11:54:04 +01:00
|
|
|
#define GEN_SPEFPUOP_CONV_32_64(name) \
|
2009-08-16 11:06:54 +02:00
|
|
|
static inline void gen_##name(DisasContext *ctx) \
|
2008-11-23 11:54:04 +01:00
|
|
|
{ \
|
|
|
|
TCGv_i64 t0 = tcg_temp_new_i64(); \
|
2014-06-04 22:58:50 +02:00
|
|
|
TCGv_i32 t1 = tcg_temp_new_i32(); \
|
2008-11-23 11:54:04 +01:00
|
|
|
gen_load_gpr64(t0, rB(ctx->opcode)); \
|
2014-06-04 22:58:50 +02:00
|
|
|
gen_helper_##name(t1, cpu_env, t0); \
|
|
|
|
tcg_gen_extu_i32_tl(cpu_gpr[rD(ctx->opcode)], t1); \
|
2008-11-23 11:54:04 +01:00
|
|
|
tcg_temp_free_i64(t0); \
|
2014-06-04 22:58:50 +02:00
|
|
|
tcg_temp_free_i32(t1); \
|
2008-11-23 11:54:04 +01:00
|
|
|
}
|
|
|
|
#define GEN_SPEFPUOP_CONV_64_32(name) \
|
2009-08-16 11:06:54 +02:00
|
|
|
static inline void gen_##name(DisasContext *ctx) \
|
2008-11-23 11:54:04 +01:00
|
|
|
{ \
|
|
|
|
TCGv_i64 t0 = tcg_temp_new_i64(); \
|
2014-06-04 22:58:50 +02:00
|
|
|
TCGv_i32 t1 = tcg_temp_new_i32(); \
|
|
|
|
tcg_gen_trunc_tl_i32(t1, cpu_gpr[rB(ctx->opcode)]); \
|
|
|
|
gen_helper_##name(t0, cpu_env, t1); \
|
2008-11-23 11:54:04 +01:00
|
|
|
gen_store_gpr64(rD(ctx->opcode), t0); \
|
|
|
|
tcg_temp_free_i64(t0); \
|
2014-06-04 22:58:50 +02:00
|
|
|
tcg_temp_free_i32(t1); \
|
2008-11-23 11:54:04 +01:00
|
|
|
}
|
|
|
|
#define GEN_SPEFPUOP_CONV_64_64(name) \
|
2009-08-16 11:06:54 +02:00
|
|
|
static inline void gen_##name(DisasContext *ctx) \
|
2008-11-23 11:54:04 +01:00
|
|
|
{ \
|
|
|
|
TCGv_i64 t0 = tcg_temp_new_i64(); \
|
|
|
|
gen_load_gpr64(t0, rB(ctx->opcode)); \
|
2012-05-30 06:23:27 +02:00
|
|
|
gen_helper_##name(t0, cpu_env, t0); \
|
2008-11-23 11:54:04 +01:00
|
|
|
gen_store_gpr64(rD(ctx->opcode), t0); \
|
|
|
|
tcg_temp_free_i64(t0); \
|
|
|
|
}
|
|
|
|
#define GEN_SPEFPUOP_ARITH2_32_32(name) \
|
2009-08-16 11:06:54 +02:00
|
|
|
static inline void gen_##name(DisasContext *ctx) \
|
2008-11-23 11:54:04 +01:00
|
|
|
{ \
|
2014-06-04 22:58:50 +02:00
|
|
|
TCGv_i32 t0, t1; \
|
2008-11-23 11:54:04 +01:00
|
|
|
if (unlikely(!ctx->spe_enabled)) { \
|
2011-08-23 06:55:43 +02:00
|
|
|
gen_exception(ctx, POWERPC_EXCP_SPEU); \
|
2008-11-23 11:54:04 +01:00
|
|
|
return; \
|
|
|
|
} \
|
2014-06-04 22:58:50 +02:00
|
|
|
t0 = tcg_temp_new_i32(); \
|
|
|
|
t1 = tcg_temp_new_i32(); \
|
|
|
|
tcg_gen_trunc_tl_i32(t0, cpu_gpr[rA(ctx->opcode)]); \
|
|
|
|
tcg_gen_trunc_tl_i32(t1, cpu_gpr[rB(ctx->opcode)]); \
|
|
|
|
gen_helper_##name(t0, cpu_env, t0, t1); \
|
|
|
|
tcg_gen_extu_i32_tl(cpu_gpr[rD(ctx->opcode)], t0); \
|
|
|
|
\
|
|
|
|
tcg_temp_free_i32(t0); \
|
|
|
|
tcg_temp_free_i32(t1); \
|
2008-11-23 11:54:04 +01:00
|
|
|
}
|
|
|
|
#define GEN_SPEFPUOP_ARITH2_64_64(name) \
|
2009-08-16 11:06:54 +02:00
|
|
|
static inline void gen_##name(DisasContext *ctx) \
|
2008-11-23 11:54:04 +01:00
|
|
|
{ \
|
|
|
|
TCGv_i64 t0, t1; \
|
|
|
|
if (unlikely(!ctx->spe_enabled)) { \
|
2011-08-23 06:55:43 +02:00
|
|
|
gen_exception(ctx, POWERPC_EXCP_SPEU); \
|
2008-11-23 11:54:04 +01:00
|
|
|
return; \
|
|
|
|
} \
|
|
|
|
t0 = tcg_temp_new_i64(); \
|
|
|
|
t1 = tcg_temp_new_i64(); \
|
|
|
|
gen_load_gpr64(t0, rA(ctx->opcode)); \
|
|
|
|
gen_load_gpr64(t1, rB(ctx->opcode)); \
|
2012-05-30 06:23:27 +02:00
|
|
|
gen_helper_##name(t0, cpu_env, t0, t1); \
|
2008-11-23 11:54:04 +01:00
|
|
|
gen_store_gpr64(rD(ctx->opcode), t0); \
|
|
|
|
tcg_temp_free_i64(t0); \
|
|
|
|
tcg_temp_free_i64(t1); \
|
|
|
|
}
|
|
|
|
#define GEN_SPEFPUOP_COMP_32(name) \
|
2009-08-16 11:06:54 +02:00
|
|
|
static inline void gen_##name(DisasContext *ctx) \
|
2008-11-23 11:54:04 +01:00
|
|
|
{ \
|
2014-06-04 22:58:50 +02:00
|
|
|
TCGv_i32 t0, t1; \
|
2008-11-23 11:54:04 +01:00
|
|
|
if (unlikely(!ctx->spe_enabled)) { \
|
2011-08-23 06:55:43 +02:00
|
|
|
gen_exception(ctx, POWERPC_EXCP_SPEU); \
|
2008-11-23 11:54:04 +01:00
|
|
|
return; \
|
|
|
|
} \
|
2014-06-04 22:58:50 +02:00
|
|
|
t0 = tcg_temp_new_i32(); \
|
|
|
|
t1 = tcg_temp_new_i32(); \
|
|
|
|
\
|
|
|
|
tcg_gen_trunc_tl_i32(t0, cpu_gpr[rA(ctx->opcode)]); \
|
|
|
|
tcg_gen_trunc_tl_i32(t1, cpu_gpr[rB(ctx->opcode)]); \
|
|
|
|
gen_helper_##name(cpu_crf[crfD(ctx->opcode)], cpu_env, t0, t1); \
|
|
|
|
\
|
|
|
|
tcg_temp_free_i32(t0); \
|
|
|
|
tcg_temp_free_i32(t1); \
|
2008-11-23 11:54:04 +01:00
|
|
|
}
|
|
|
|
#define GEN_SPEFPUOP_COMP_64(name) \
|
2009-08-16 11:06:54 +02:00
|
|
|
static inline void gen_##name(DisasContext *ctx) \
|
2008-11-23 11:54:04 +01:00
|
|
|
{ \
|
|
|
|
TCGv_i64 t0, t1; \
|
|
|
|
if (unlikely(!ctx->spe_enabled)) { \
|
2011-08-23 06:55:43 +02:00
|
|
|
gen_exception(ctx, POWERPC_EXCP_SPEU); \
|
2008-11-23 11:54:04 +01:00
|
|
|
return; \
|
|
|
|
} \
|
|
|
|
t0 = tcg_temp_new_i64(); \
|
|
|
|
t1 = tcg_temp_new_i64(); \
|
|
|
|
gen_load_gpr64(t0, rA(ctx->opcode)); \
|
|
|
|
gen_load_gpr64(t1, rB(ctx->opcode)); \
|
2012-05-30 06:23:27 +02:00
|
|
|
gen_helper_##name(cpu_crf[crfD(ctx->opcode)], cpu_env, t0, t1); \
|
2008-11-23 11:54:04 +01:00
|
|
|
tcg_temp_free_i64(t0); \
|
|
|
|
tcg_temp_free_i64(t1); \
|
|
|
|
}
|
2008-11-10 12:10:23 +01:00
|
|
|
|
2007-03-20 23:11:31 +01:00
|
|
|
/* Single precision floating-point vectors operations */
|
|
|
|
/* Arithmetic */
|
2008-11-23 11:54:04 +01:00
|
|
|
GEN_SPEFPUOP_ARITH2_64_64(evfsadd);
|
|
|
|
GEN_SPEFPUOP_ARITH2_64_64(evfssub);
|
|
|
|
GEN_SPEFPUOP_ARITH2_64_64(evfsmul);
|
|
|
|
GEN_SPEFPUOP_ARITH2_64_64(evfsdiv);
|
2009-08-16 11:06:54 +02:00
|
|
|
static inline void gen_evfsabs(DisasContext *ctx)
|
2008-11-23 11:54:04 +01:00
|
|
|
{
|
|
|
|
if (unlikely(!ctx->spe_enabled)) {
|
2011-08-23 06:55:43 +02:00
|
|
|
gen_exception(ctx, POWERPC_EXCP_SPEU);
|
2008-11-23 11:54:04 +01:00
|
|
|
return;
|
|
|
|
}
|
2014-06-04 22:58:50 +02:00
|
|
|
tcg_gen_andi_tl(cpu_gpr[rD(ctx->opcode)], cpu_gpr[rA(ctx->opcode)],
|
|
|
|
~0x80000000);
|
|
|
|
tcg_gen_andi_tl(cpu_gprh[rD(ctx->opcode)], cpu_gprh[rA(ctx->opcode)],
|
|
|
|
~0x80000000);
|
2008-11-23 11:54:04 +01:00
|
|
|
}
|
2009-08-16 11:06:54 +02:00
|
|
|
static inline void gen_evfsnabs(DisasContext *ctx)
|
2008-11-23 11:54:04 +01:00
|
|
|
{
|
|
|
|
if (unlikely(!ctx->spe_enabled)) {
|
2011-08-23 06:55:43 +02:00
|
|
|
gen_exception(ctx, POWERPC_EXCP_SPEU);
|
2008-11-23 11:54:04 +01:00
|
|
|
return;
|
|
|
|
}
|
2014-06-04 22:58:50 +02:00
|
|
|
tcg_gen_ori_tl(cpu_gpr[rD(ctx->opcode)], cpu_gpr[rA(ctx->opcode)],
|
|
|
|
0x80000000);
|
|
|
|
tcg_gen_ori_tl(cpu_gprh[rD(ctx->opcode)], cpu_gprh[rA(ctx->opcode)],
|
|
|
|
0x80000000);
|
2008-11-23 11:54:04 +01:00
|
|
|
}
|
2009-08-16 11:06:54 +02:00
|
|
|
static inline void gen_evfsneg(DisasContext *ctx)
|
2008-11-23 11:54:04 +01:00
|
|
|
{
|
|
|
|
if (unlikely(!ctx->spe_enabled)) {
|
2011-08-23 06:55:43 +02:00
|
|
|
gen_exception(ctx, POWERPC_EXCP_SPEU);
|
2008-11-23 11:54:04 +01:00
|
|
|
return;
|
|
|
|
}
|
2014-06-04 22:58:50 +02:00
|
|
|
tcg_gen_xori_tl(cpu_gpr[rD(ctx->opcode)], cpu_gpr[rA(ctx->opcode)],
|
|
|
|
0x80000000);
|
|
|
|
tcg_gen_xori_tl(cpu_gprh[rD(ctx->opcode)], cpu_gprh[rA(ctx->opcode)],
|
|
|
|
0x80000000);
|
2008-11-23 11:54:04 +01:00
|
|
|
}
|
|
|
|
|
2007-03-20 23:11:31 +01:00
|
|
|
/* Conversion */
|
2008-11-23 11:54:04 +01:00
|
|
|
GEN_SPEFPUOP_CONV_64_64(evfscfui);
|
|
|
|
GEN_SPEFPUOP_CONV_64_64(evfscfsi);
|
|
|
|
GEN_SPEFPUOP_CONV_64_64(evfscfuf);
|
|
|
|
GEN_SPEFPUOP_CONV_64_64(evfscfsf);
|
|
|
|
GEN_SPEFPUOP_CONV_64_64(evfsctui);
|
|
|
|
GEN_SPEFPUOP_CONV_64_64(evfsctsi);
|
|
|
|
GEN_SPEFPUOP_CONV_64_64(evfsctuf);
|
|
|
|
GEN_SPEFPUOP_CONV_64_64(evfsctsf);
|
|
|
|
GEN_SPEFPUOP_CONV_64_64(evfsctuiz);
|
|
|
|
GEN_SPEFPUOP_CONV_64_64(evfsctsiz);
|
|
|
|
|
2007-03-20 23:11:31 +01:00
|
|
|
/* Comparison */
|
2008-11-23 11:54:04 +01:00
|
|
|
GEN_SPEFPUOP_COMP_64(evfscmpgt);
|
|
|
|
GEN_SPEFPUOP_COMP_64(evfscmplt);
|
|
|
|
GEN_SPEFPUOP_COMP_64(evfscmpeq);
|
|
|
|
GEN_SPEFPUOP_COMP_64(evfststgt);
|
|
|
|
GEN_SPEFPUOP_COMP_64(evfststlt);
|
|
|
|
GEN_SPEFPUOP_COMP_64(evfststeq);
|
2007-03-20 23:11:31 +01:00
|
|
|
|
|
|
|
/* Opcodes definitions */
|
2011-09-28 07:54:05 +02:00
|
|
|
GEN_SPE(evfsadd, evfssub, 0x00, 0x0A, 0x00000000, 0x00000000, PPC_SPE_SINGLE); //
|
|
|
|
GEN_SPE(evfsabs, evfsnabs, 0x02, 0x0A, 0x0000F800, 0x0000F800, PPC_SPE_SINGLE); //
|
|
|
|
GEN_SPE(evfsneg, speundef, 0x03, 0x0A, 0x0000F800, 0xFFFFFFFF, PPC_SPE_SINGLE); //
|
|
|
|
GEN_SPE(evfsmul, evfsdiv, 0x04, 0x0A, 0x00000000, 0x00000000, PPC_SPE_SINGLE); //
|
|
|
|
GEN_SPE(evfscmpgt, evfscmplt, 0x06, 0x0A, 0x00600000, 0x00600000, PPC_SPE_SINGLE); //
|
|
|
|
GEN_SPE(evfscmpeq, speundef, 0x07, 0x0A, 0x00600000, 0xFFFFFFFF, PPC_SPE_SINGLE); //
|
|
|
|
GEN_SPE(evfscfui, evfscfsi, 0x08, 0x0A, 0x00180000, 0x00180000, PPC_SPE_SINGLE); //
|
|
|
|
GEN_SPE(evfscfuf, evfscfsf, 0x09, 0x0A, 0x00180000, 0x00180000, PPC_SPE_SINGLE); //
|
|
|
|
GEN_SPE(evfsctui, evfsctsi, 0x0A, 0x0A, 0x00180000, 0x00180000, PPC_SPE_SINGLE); //
|
|
|
|
GEN_SPE(evfsctuf, evfsctsf, 0x0B, 0x0A, 0x00180000, 0x00180000, PPC_SPE_SINGLE); //
|
|
|
|
GEN_SPE(evfsctuiz, speundef, 0x0C, 0x0A, 0x00180000, 0xFFFFFFFF, PPC_SPE_SINGLE); //
|
|
|
|
GEN_SPE(evfsctsiz, speundef, 0x0D, 0x0A, 0x00180000, 0xFFFFFFFF, PPC_SPE_SINGLE); //
|
|
|
|
GEN_SPE(evfststgt, evfststlt, 0x0E, 0x0A, 0x00600000, 0x00600000, PPC_SPE_SINGLE); //
|
|
|
|
GEN_SPE(evfststeq, speundef, 0x0F, 0x0A, 0x00600000, 0xFFFFFFFF, PPC_SPE_SINGLE); //
|
2007-03-20 23:11:31 +01:00
|
|
|
|
|
|
|
/* Single precision floating-point operations */
|
|
|
|
/* Arithmetic */
|
2008-11-23 11:54:04 +01:00
|
|
|
GEN_SPEFPUOP_ARITH2_32_32(efsadd);
|
|
|
|
GEN_SPEFPUOP_ARITH2_32_32(efssub);
|
|
|
|
GEN_SPEFPUOP_ARITH2_32_32(efsmul);
|
|
|
|
GEN_SPEFPUOP_ARITH2_32_32(efsdiv);
|
2009-08-16 11:06:54 +02:00
|
|
|
static inline void gen_efsabs(DisasContext *ctx)
|
2008-11-23 11:54:04 +01:00
|
|
|
{
|
|
|
|
if (unlikely(!ctx->spe_enabled)) {
|
2011-08-23 06:55:43 +02:00
|
|
|
gen_exception(ctx, POWERPC_EXCP_SPEU);
|
2008-11-23 11:54:04 +01:00
|
|
|
return;
|
|
|
|
}
|
2010-12-31 21:17:53 +01:00
|
|
|
tcg_gen_andi_tl(cpu_gpr[rD(ctx->opcode)], cpu_gpr[rA(ctx->opcode)], (target_long)~0x80000000LL);
|
2008-11-23 11:54:04 +01:00
|
|
|
}
|
2009-08-16 11:06:54 +02:00
|
|
|
static inline void gen_efsnabs(DisasContext *ctx)
|
2008-11-23 11:54:04 +01:00
|
|
|
{
|
|
|
|
if (unlikely(!ctx->spe_enabled)) {
|
2011-08-23 06:55:43 +02:00
|
|
|
gen_exception(ctx, POWERPC_EXCP_SPEU);
|
2008-11-23 11:54:04 +01:00
|
|
|
return;
|
|
|
|
}
|
2010-12-31 21:17:53 +01:00
|
|
|
tcg_gen_ori_tl(cpu_gpr[rD(ctx->opcode)], cpu_gpr[rA(ctx->opcode)], 0x80000000);
|
2008-11-23 11:54:04 +01:00
|
|
|
}
|
2009-08-16 11:06:54 +02:00
|
|
|
static inline void gen_efsneg(DisasContext *ctx)
|
2008-11-23 11:54:04 +01:00
|
|
|
{
|
|
|
|
if (unlikely(!ctx->spe_enabled)) {
|
2011-08-23 06:55:43 +02:00
|
|
|
gen_exception(ctx, POWERPC_EXCP_SPEU);
|
2008-11-23 11:54:04 +01:00
|
|
|
return;
|
|
|
|
}
|
2010-12-31 21:17:53 +01:00
|
|
|
tcg_gen_xori_tl(cpu_gpr[rD(ctx->opcode)], cpu_gpr[rA(ctx->opcode)], 0x80000000);
|
2008-11-23 11:54:04 +01:00
|
|
|
}
|
|
|
|
|
2007-03-20 23:11:31 +01:00
|
|
|
/* Conversion */
|
2008-11-23 11:54:04 +01:00
|
|
|
GEN_SPEFPUOP_CONV_32_32(efscfui);
|
|
|
|
GEN_SPEFPUOP_CONV_32_32(efscfsi);
|
|
|
|
GEN_SPEFPUOP_CONV_32_32(efscfuf);
|
|
|
|
GEN_SPEFPUOP_CONV_32_32(efscfsf);
|
|
|
|
GEN_SPEFPUOP_CONV_32_32(efsctui);
|
|
|
|
GEN_SPEFPUOP_CONV_32_32(efsctsi);
|
|
|
|
GEN_SPEFPUOP_CONV_32_32(efsctuf);
|
|
|
|
GEN_SPEFPUOP_CONV_32_32(efsctsf);
|
|
|
|
GEN_SPEFPUOP_CONV_32_32(efsctuiz);
|
|
|
|
GEN_SPEFPUOP_CONV_32_32(efsctsiz);
|
|
|
|
GEN_SPEFPUOP_CONV_32_64(efscfd);
|
|
|
|
|
2007-03-20 23:11:31 +01:00
|
|
|
/* Comparison */
|
2008-11-23 11:54:04 +01:00
|
|
|
GEN_SPEFPUOP_COMP_32(efscmpgt);
|
|
|
|
GEN_SPEFPUOP_COMP_32(efscmplt);
|
|
|
|
GEN_SPEFPUOP_COMP_32(efscmpeq);
|
|
|
|
GEN_SPEFPUOP_COMP_32(efststgt);
|
|
|
|
GEN_SPEFPUOP_COMP_32(efststlt);
|
|
|
|
GEN_SPEFPUOP_COMP_32(efststeq);
|
2007-03-20 23:11:31 +01:00
|
|
|
|
|
|
|
/* Opcodes definitions */
|
2011-09-28 07:54:05 +02:00
|
|
|
GEN_SPE(efsadd, efssub, 0x00, 0x0B, 0x00000000, 0x00000000, PPC_SPE_SINGLE); //
|
|
|
|
GEN_SPE(efsabs, efsnabs, 0x02, 0x0B, 0x0000F800, 0x0000F800, PPC_SPE_SINGLE); //
|
|
|
|
GEN_SPE(efsneg, speundef, 0x03, 0x0B, 0x0000F800, 0xFFFFFFFF, PPC_SPE_SINGLE); //
|
|
|
|
GEN_SPE(efsmul, efsdiv, 0x04, 0x0B, 0x00000000, 0x00000000, PPC_SPE_SINGLE); //
|
|
|
|
GEN_SPE(efscmpgt, efscmplt, 0x06, 0x0B, 0x00600000, 0x00600000, PPC_SPE_SINGLE); //
|
|
|
|
GEN_SPE(efscmpeq, efscfd, 0x07, 0x0B, 0x00600000, 0x00180000, PPC_SPE_SINGLE); //
|
|
|
|
GEN_SPE(efscfui, efscfsi, 0x08, 0x0B, 0x00180000, 0x00180000, PPC_SPE_SINGLE); //
|
|
|
|
GEN_SPE(efscfuf, efscfsf, 0x09, 0x0B, 0x00180000, 0x00180000, PPC_SPE_SINGLE); //
|
|
|
|
GEN_SPE(efsctui, efsctsi, 0x0A, 0x0B, 0x00180000, 0x00180000, PPC_SPE_SINGLE); //
|
|
|
|
GEN_SPE(efsctuf, efsctsf, 0x0B, 0x0B, 0x00180000, 0x00180000, PPC_SPE_SINGLE); //
|
|
|
|
GEN_SPE(efsctuiz, speundef, 0x0C, 0x0B, 0x00180000, 0xFFFFFFFF, PPC_SPE_SINGLE); //
|
|
|
|
GEN_SPE(efsctsiz, speundef, 0x0D, 0x0B, 0x00180000, 0xFFFFFFFF, PPC_SPE_SINGLE); //
|
|
|
|
GEN_SPE(efststgt, efststlt, 0x0E, 0x0B, 0x00600000, 0x00600000, PPC_SPE_SINGLE); //
|
|
|
|
GEN_SPE(efststeq, speundef, 0x0F, 0x0B, 0x00600000, 0xFFFFFFFF, PPC_SPE_SINGLE); //
|
2007-03-20 23:11:31 +01:00
|
|
|
|
|
|
|
/* Double precision floating-point operations */
|
|
|
|
/* Arithmetic */
|
2008-11-23 11:54:04 +01:00
|
|
|
GEN_SPEFPUOP_ARITH2_64_64(efdadd);
|
|
|
|
GEN_SPEFPUOP_ARITH2_64_64(efdsub);
|
|
|
|
GEN_SPEFPUOP_ARITH2_64_64(efdmul);
|
|
|
|
GEN_SPEFPUOP_ARITH2_64_64(efddiv);
|
2009-08-16 11:06:54 +02:00
|
|
|
static inline void gen_efdabs(DisasContext *ctx)
|
2008-11-23 11:54:04 +01:00
|
|
|
{
|
|
|
|
if (unlikely(!ctx->spe_enabled)) {
|
2011-08-23 06:55:43 +02:00
|
|
|
gen_exception(ctx, POWERPC_EXCP_SPEU);
|
2008-11-23 11:54:04 +01:00
|
|
|
return;
|
|
|
|
}
|
2010-12-31 21:17:53 +01:00
|
|
|
tcg_gen_mov_tl(cpu_gpr[rD(ctx->opcode)], cpu_gpr[rA(ctx->opcode)]);
|
2014-06-04 22:58:50 +02:00
|
|
|
tcg_gen_andi_tl(cpu_gprh[rD(ctx->opcode)], cpu_gprh[rA(ctx->opcode)],
|
|
|
|
~0x80000000);
|
2008-11-23 11:54:04 +01:00
|
|
|
}
|
2009-08-16 11:06:54 +02:00
|
|
|
static inline void gen_efdnabs(DisasContext *ctx)
|
2008-11-23 11:54:04 +01:00
|
|
|
{
|
|
|
|
if (unlikely(!ctx->spe_enabled)) {
|
2011-08-23 06:55:43 +02:00
|
|
|
gen_exception(ctx, POWERPC_EXCP_SPEU);
|
2008-11-23 11:54:04 +01:00
|
|
|
return;
|
|
|
|
}
|
2010-12-31 21:17:53 +01:00
|
|
|
tcg_gen_mov_tl(cpu_gpr[rD(ctx->opcode)], cpu_gpr[rA(ctx->opcode)]);
|
2014-06-04 22:58:50 +02:00
|
|
|
tcg_gen_ori_tl(cpu_gprh[rD(ctx->opcode)], cpu_gprh[rA(ctx->opcode)],
|
|
|
|
0x80000000);
|
2008-11-23 11:54:04 +01:00
|
|
|
}
|
2009-08-16 11:06:54 +02:00
|
|
|
static inline void gen_efdneg(DisasContext *ctx)
|
2008-11-23 11:54:04 +01:00
|
|
|
{
|
|
|
|
if (unlikely(!ctx->spe_enabled)) {
|
2011-08-23 06:55:43 +02:00
|
|
|
gen_exception(ctx, POWERPC_EXCP_SPEU);
|
2008-11-23 11:54:04 +01:00
|
|
|
return;
|
|
|
|
}
|
2010-12-31 21:17:53 +01:00
|
|
|
tcg_gen_mov_tl(cpu_gpr[rD(ctx->opcode)], cpu_gpr[rA(ctx->opcode)]);
|
2014-06-04 22:58:50 +02:00
|
|
|
tcg_gen_xori_tl(cpu_gprh[rD(ctx->opcode)], cpu_gprh[rA(ctx->opcode)],
|
|
|
|
0x80000000);
|
2008-11-23 11:54:04 +01:00
|
|
|
}
|
|
|
|
|
2007-03-20 23:11:31 +01:00
|
|
|
/* Conversion */
|
2008-11-23 11:54:04 +01:00
|
|
|
GEN_SPEFPUOP_CONV_64_32(efdcfui);
|
|
|
|
GEN_SPEFPUOP_CONV_64_32(efdcfsi);
|
|
|
|
GEN_SPEFPUOP_CONV_64_32(efdcfuf);
|
|
|
|
GEN_SPEFPUOP_CONV_64_32(efdcfsf);
|
|
|
|
GEN_SPEFPUOP_CONV_32_64(efdctui);
|
|
|
|
GEN_SPEFPUOP_CONV_32_64(efdctsi);
|
|
|
|
GEN_SPEFPUOP_CONV_32_64(efdctuf);
|
|
|
|
GEN_SPEFPUOP_CONV_32_64(efdctsf);
|
|
|
|
GEN_SPEFPUOP_CONV_32_64(efdctuiz);
|
|
|
|
GEN_SPEFPUOP_CONV_32_64(efdctsiz);
|
|
|
|
GEN_SPEFPUOP_CONV_64_32(efdcfs);
|
|
|
|
GEN_SPEFPUOP_CONV_64_64(efdcfuid);
|
|
|
|
GEN_SPEFPUOP_CONV_64_64(efdcfsid);
|
|
|
|
GEN_SPEFPUOP_CONV_64_64(efdctuidz);
|
|
|
|
GEN_SPEFPUOP_CONV_64_64(efdctsidz);
|
2007-03-20 23:11:31 +01:00
|
|
|
|
|
|
|
/* Comparison */
|
2008-11-23 11:54:04 +01:00
|
|
|
GEN_SPEFPUOP_COMP_64(efdcmpgt);
|
|
|
|
GEN_SPEFPUOP_COMP_64(efdcmplt);
|
|
|
|
GEN_SPEFPUOP_COMP_64(efdcmpeq);
|
|
|
|
GEN_SPEFPUOP_COMP_64(efdtstgt);
|
|
|
|
GEN_SPEFPUOP_COMP_64(efdtstlt);
|
|
|
|
GEN_SPEFPUOP_COMP_64(efdtsteq);
|
2007-03-20 23:11:31 +01:00
|
|
|
|
|
|
|
/* Opcodes definitions */
|
2011-09-28 07:54:05 +02:00
|
|
|
GEN_SPE(efdadd, efdsub, 0x10, 0x0B, 0x00000000, 0x00000000, PPC_SPE_DOUBLE); //
|
|
|
|
GEN_SPE(efdcfuid, efdcfsid, 0x11, 0x0B, 0x00180000, 0x00180000, PPC_SPE_DOUBLE); //
|
|
|
|
GEN_SPE(efdabs, efdnabs, 0x12, 0x0B, 0x0000F800, 0x0000F800, PPC_SPE_DOUBLE); //
|
|
|
|
GEN_SPE(efdneg, speundef, 0x13, 0x0B, 0x0000F800, 0xFFFFFFFF, PPC_SPE_DOUBLE); //
|
|
|
|
GEN_SPE(efdmul, efddiv, 0x14, 0x0B, 0x00000000, 0x00000000, PPC_SPE_DOUBLE); //
|
|
|
|
GEN_SPE(efdctuidz, efdctsidz, 0x15, 0x0B, 0x00180000, 0x00180000, PPC_SPE_DOUBLE); //
|
|
|
|
GEN_SPE(efdcmpgt, efdcmplt, 0x16, 0x0B, 0x00600000, 0x00600000, PPC_SPE_DOUBLE); //
|
|
|
|
GEN_SPE(efdcmpeq, efdcfs, 0x17, 0x0B, 0x00600000, 0x00180000, PPC_SPE_DOUBLE); //
|
|
|
|
GEN_SPE(efdcfui, efdcfsi, 0x18, 0x0B, 0x00180000, 0x00180000, PPC_SPE_DOUBLE); //
|
|
|
|
GEN_SPE(efdcfuf, efdcfsf, 0x19, 0x0B, 0x00180000, 0x00180000, PPC_SPE_DOUBLE); //
|
|
|
|
GEN_SPE(efdctui, efdctsi, 0x1A, 0x0B, 0x00180000, 0x00180000, PPC_SPE_DOUBLE); //
|
|
|
|
GEN_SPE(efdctuf, efdctsf, 0x1B, 0x0B, 0x00180000, 0x00180000, PPC_SPE_DOUBLE); //
|
|
|
|
GEN_SPE(efdctuiz, speundef, 0x1C, 0x0B, 0x00180000, 0xFFFFFFFF, PPC_SPE_DOUBLE); //
|
|
|
|
GEN_SPE(efdctsiz, speundef, 0x1D, 0x0B, 0x00180000, 0xFFFFFFFF, PPC_SPE_DOUBLE); //
|
|
|
|
GEN_SPE(efdtstgt, efdtstlt, 0x1E, 0x0B, 0x00600000, 0x00600000, PPC_SPE_DOUBLE); //
|
|
|
|
GEN_SPE(efdtsteq, speundef, 0x1F, 0x0B, 0x00600000, 0xFFFFFFFF, PPC_SPE_DOUBLE); //
|
2007-03-20 23:11:31 +01:00
|
|
|
|
2014-12-18 17:34:34 +01:00
|
|
|
static void gen_tbegin(DisasContext *ctx)
|
|
|
|
{
|
|
|
|
if (unlikely(!ctx->tm_enabled)) {
|
|
|
|
gen_exception_err(ctx, POWERPC_EXCP_FU, FSCR_IC_TM);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
gen_helper_tbegin(cpu_env);
|
|
|
|
}
|
|
|
|
|
2014-12-18 17:34:35 +01:00
|
|
|
#define GEN_TM_NOOP(name) \
|
|
|
|
static inline void gen_##name(DisasContext *ctx) \
|
|
|
|
{ \
|
|
|
|
if (unlikely(!ctx->tm_enabled)) { \
|
|
|
|
gen_exception_err(ctx, POWERPC_EXCP_FU, FSCR_IC_TM); \
|
|
|
|
return; \
|
|
|
|
} \
|
|
|
|
/* Because tbegin always fails in QEMU, these user \
|
|
|
|
* space instructions all have a simple implementation: \
|
|
|
|
* \
|
|
|
|
* CR[0] = 0b0 || MSR[TS] || 0b0 \
|
|
|
|
* = 0b0 || 0b00 || 0b0 \
|
|
|
|
*/ \
|
|
|
|
tcg_gen_movi_i32(cpu_crf[0], 0); \
|
|
|
|
}
|
|
|
|
|
|
|
|
GEN_TM_NOOP(tend);
|
|
|
|
GEN_TM_NOOP(tabort);
|
|
|
|
GEN_TM_NOOP(tabortwc);
|
|
|
|
GEN_TM_NOOP(tabortwci);
|
|
|
|
GEN_TM_NOOP(tabortdc);
|
|
|
|
GEN_TM_NOOP(tabortdci);
|
|
|
|
GEN_TM_NOOP(tsr);
|
|
|
|
|
2014-12-18 17:34:36 +01:00
|
|
|
static void gen_tcheck(DisasContext *ctx)
|
|
|
|
{
|
|
|
|
if (unlikely(!ctx->tm_enabled)) {
|
|
|
|
gen_exception_err(ctx, POWERPC_EXCP_FU, FSCR_IC_TM);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
/* Because tbegin always fails, the tcheck implementation
|
|
|
|
* is simple:
|
|
|
|
*
|
|
|
|
* CR[CRF] = TDOOMED || MSR[TS] || 0b0
|
|
|
|
* = 0b1 || 0b00 || 0b0
|
|
|
|
*/
|
|
|
|
tcg_gen_movi_i32(cpu_crf[crfD(ctx->opcode)], 0x8);
|
|
|
|
}
|
|
|
|
|
2014-12-18 17:34:37 +01:00
|
|
|
#if defined(CONFIG_USER_ONLY)
|
|
|
|
#define GEN_TM_PRIV_NOOP(name) \
|
|
|
|
static inline void gen_##name(DisasContext *ctx) \
|
|
|
|
{ \
|
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC); \
|
|
|
|
}
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
#define GEN_TM_PRIV_NOOP(name) \
|
|
|
|
static inline void gen_##name(DisasContext *ctx) \
|
|
|
|
{ \
|
|
|
|
if (unlikely(ctx->pr)) { \
|
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC); \
|
|
|
|
return; \
|
|
|
|
} \
|
|
|
|
if (unlikely(!ctx->tm_enabled)) { \
|
|
|
|
gen_exception_err(ctx, POWERPC_EXCP_FU, FSCR_IC_TM); \
|
|
|
|
return; \
|
|
|
|
} \
|
|
|
|
/* Because tbegin always fails, the implementation is \
|
|
|
|
* simple: \
|
|
|
|
* \
|
|
|
|
* CR[0] = 0b0 || MSR[TS] || 0b0 \
|
|
|
|
* = 0b0 || 0b00 | 0b0 \
|
|
|
|
*/ \
|
|
|
|
tcg_gen_movi_i32(cpu_crf[0], 0); \
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
GEN_TM_PRIV_NOOP(treclaim);
|
|
|
|
GEN_TM_PRIV_NOOP(trechkpt);
|
|
|
|
|
2009-10-01 23:12:16 +02:00
|
|
|
static opcode_t opcodes[] = {
|
2009-06-17 17:22:31 +02:00
|
|
|
GEN_HANDLER(invalid, 0x00, 0x00, 0x00, 0xFFFFFFFF, PPC_NONE),
|
|
|
|
GEN_HANDLER(cmp, 0x1F, 0x00, 0x00, 0x00400000, PPC_INTEGER),
|
|
|
|
GEN_HANDLER(cmpi, 0x0B, 0xFF, 0xFF, 0x00400000, PPC_INTEGER),
|
|
|
|
GEN_HANDLER(cmpl, 0x1F, 0x00, 0x01, 0x00400000, PPC_INTEGER),
|
|
|
|
GEN_HANDLER(cmpli, 0x0A, 0xFF, 0xFF, 0x00400000, PPC_INTEGER),
|
2013-04-20 10:56:16 +02:00
|
|
|
GEN_HANDLER_E(cmpb, 0x1F, 0x1C, 0x0F, 0x00000001, PPC_NONE, PPC2_ISA205),
|
2009-06-17 17:22:31 +02:00
|
|
|
GEN_HANDLER(isel, 0x1F, 0x0F, 0xFF, 0x00000001, PPC_ISEL),
|
|
|
|
GEN_HANDLER(addi, 0x0E, 0xFF, 0xFF, 0x00000000, PPC_INTEGER),
|
|
|
|
GEN_HANDLER(addic, 0x0C, 0xFF, 0xFF, 0x00000000, PPC_INTEGER),
|
|
|
|
GEN_HANDLER2(addic_, "addic.", 0x0D, 0xFF, 0xFF, 0x00000000, PPC_INTEGER),
|
|
|
|
GEN_HANDLER(addis, 0x0F, 0xFF, 0xFF, 0x00000000, PPC_INTEGER),
|
|
|
|
GEN_HANDLER(mulhw, 0x1F, 0x0B, 0x02, 0x00000400, PPC_INTEGER),
|
|
|
|
GEN_HANDLER(mulhwu, 0x1F, 0x0B, 0x00, 0x00000400, PPC_INTEGER),
|
|
|
|
GEN_HANDLER(mullw, 0x1F, 0x0B, 0x07, 0x00000000, PPC_INTEGER),
|
|
|
|
GEN_HANDLER(mullwo, 0x1F, 0x0B, 0x17, 0x00000000, PPC_INTEGER),
|
|
|
|
GEN_HANDLER(mulli, 0x07, 0xFF, 0xFF, 0x00000000, PPC_INTEGER),
|
|
|
|
#if defined(TARGET_PPC64)
|
|
|
|
GEN_HANDLER(mulld, 0x1F, 0x09, 0x07, 0x00000000, PPC_64B),
|
|
|
|
#endif
|
|
|
|
GEN_HANDLER(neg, 0x1F, 0x08, 0x03, 0x0000F800, PPC_INTEGER),
|
|
|
|
GEN_HANDLER(nego, 0x1F, 0x08, 0x13, 0x0000F800, PPC_INTEGER),
|
|
|
|
GEN_HANDLER(subfic, 0x08, 0xFF, 0xFF, 0x00000000, PPC_INTEGER),
|
|
|
|
GEN_HANDLER2(andi_, "andi.", 0x1C, 0xFF, 0xFF, 0x00000000, PPC_INTEGER),
|
|
|
|
GEN_HANDLER2(andis_, "andis.", 0x1D, 0xFF, 0xFF, 0x00000000, PPC_INTEGER),
|
|
|
|
GEN_HANDLER(cntlzw, 0x1F, 0x1A, 0x00, 0x00000000, PPC_INTEGER),
|
|
|
|
GEN_HANDLER(or, 0x1F, 0x1C, 0x0D, 0x00000000, PPC_INTEGER),
|
|
|
|
GEN_HANDLER(xor, 0x1F, 0x1C, 0x09, 0x00000000, PPC_INTEGER),
|
|
|
|
GEN_HANDLER(ori, 0x18, 0xFF, 0xFF, 0x00000000, PPC_INTEGER),
|
|
|
|
GEN_HANDLER(oris, 0x19, 0xFF, 0xFF, 0x00000000, PPC_INTEGER),
|
|
|
|
GEN_HANDLER(xori, 0x1A, 0xFF, 0xFF, 0x00000000, PPC_INTEGER),
|
|
|
|
GEN_HANDLER(xoris, 0x1B, 0xFF, 0xFF, 0x00000000, PPC_INTEGER),
|
2014-05-14 19:14:42 +02:00
|
|
|
GEN_HANDLER(popcntb, 0x1F, 0x1A, 0x03, 0x0000F801, PPC_POPCNTB),
|
2011-04-01 06:15:13 +02:00
|
|
|
GEN_HANDLER(popcntw, 0x1F, 0x1A, 0x0b, 0x0000F801, PPC_POPCNTWD),
|
2013-04-20 10:56:17 +02:00
|
|
|
GEN_HANDLER_E(prtyw, 0x1F, 0x1A, 0x04, 0x0000F801, PPC_NONE, PPC2_ISA205),
|
2009-06-17 17:22:31 +02:00
|
|
|
#if defined(TARGET_PPC64)
|
2011-04-01 06:15:13 +02:00
|
|
|
GEN_HANDLER(popcntd, 0x1F, 0x1A, 0x0F, 0x0000F801, PPC_POPCNTWD),
|
2009-06-17 17:22:31 +02:00
|
|
|
GEN_HANDLER(cntlzd, 0x1F, 0x1A, 0x01, 0x00000000, PPC_64B),
|
2013-04-20 10:56:17 +02:00
|
|
|
GEN_HANDLER_E(prtyd, 0x1F, 0x1A, 0x05, 0x0000F801, PPC_NONE, PPC2_ISA205),
|
2014-01-07 17:05:49 +01:00
|
|
|
GEN_HANDLER_E(bpermd, 0x1F, 0x1C, 0x07, 0x00000001, PPC_NONE, PPC2_PERM_ISA206),
|
2009-06-17 17:22:31 +02:00
|
|
|
#endif
|
|
|
|
GEN_HANDLER(rlwimi, 0x14, 0xFF, 0xFF, 0x00000000, PPC_INTEGER),
|
|
|
|
GEN_HANDLER(rlwinm, 0x15, 0xFF, 0xFF, 0x00000000, PPC_INTEGER),
|
|
|
|
GEN_HANDLER(rlwnm, 0x17, 0xFF, 0xFF, 0x00000000, PPC_INTEGER),
|
|
|
|
GEN_HANDLER(slw, 0x1F, 0x18, 0x00, 0x00000000, PPC_INTEGER),
|
|
|
|
GEN_HANDLER(sraw, 0x1F, 0x18, 0x18, 0x00000000, PPC_INTEGER),
|
|
|
|
GEN_HANDLER(srawi, 0x1F, 0x18, 0x19, 0x00000000, PPC_INTEGER),
|
|
|
|
GEN_HANDLER(srw, 0x1F, 0x18, 0x10, 0x00000000, PPC_INTEGER),
|
|
|
|
#if defined(TARGET_PPC64)
|
|
|
|
GEN_HANDLER(sld, 0x1F, 0x1B, 0x00, 0x00000000, PPC_64B),
|
|
|
|
GEN_HANDLER(srad, 0x1F, 0x1A, 0x18, 0x00000000, PPC_64B),
|
|
|
|
GEN_HANDLER2(sradi0, "sradi", 0x1F, 0x1A, 0x19, 0x00000000, PPC_64B),
|
|
|
|
GEN_HANDLER2(sradi1, "sradi", 0x1F, 0x1B, 0x19, 0x00000000, PPC_64B),
|
|
|
|
GEN_HANDLER(srd, 0x1F, 0x1B, 0x10, 0x00000000, PPC_64B),
|
|
|
|
#endif
|
|
|
|
GEN_HANDLER(frsqrtes, 0x3B, 0x1A, 0xFF, 0x001F07C0, PPC_FLOAT_FRSQRTES),
|
|
|
|
GEN_HANDLER(fsqrt, 0x3F, 0x16, 0xFF, 0x001F07C0, PPC_FLOAT_FSQRT),
|
|
|
|
GEN_HANDLER(fsqrts, 0x3B, 0x16, 0xFF, 0x001F07C0, PPC_FLOAT_FSQRT),
|
|
|
|
GEN_HANDLER(fcmpo, 0x3F, 0x00, 0x01, 0x00600001, PPC_FLOAT),
|
|
|
|
GEN_HANDLER(fcmpu, 0x3F, 0x00, 0x00, 0x00600001, PPC_FLOAT),
|
2013-04-20 10:56:13 +02:00
|
|
|
GEN_HANDLER(fabs, 0x3F, 0x08, 0x08, 0x001F0000, PPC_FLOAT),
|
2009-06-17 17:22:31 +02:00
|
|
|
GEN_HANDLER(fmr, 0x3F, 0x08, 0x02, 0x001F0000, PPC_FLOAT),
|
2013-04-20 10:56:13 +02:00
|
|
|
GEN_HANDLER(fnabs, 0x3F, 0x08, 0x04, 0x001F0000, PPC_FLOAT),
|
|
|
|
GEN_HANDLER(fneg, 0x3F, 0x08, 0x01, 0x001F0000, PPC_FLOAT),
|
2013-04-20 10:56:18 +02:00
|
|
|
GEN_HANDLER_E(fcpsgn, 0x3F, 0x08, 0x00, 0x00000000, PPC_NONE, PPC2_ISA205),
|
2014-01-15 15:10:43 +01:00
|
|
|
GEN_HANDLER_E(fmrgew, 0x3F, 0x06, 0x1E, 0x00000001, PPC_NONE, PPC2_VSX207),
|
|
|
|
GEN_HANDLER_E(fmrgow, 0x3F, 0x06, 0x1A, 0x00000001, PPC_NONE, PPC2_VSX207),
|
2009-06-17 17:22:31 +02:00
|
|
|
GEN_HANDLER(mcrfs, 0x3F, 0x00, 0x02, 0x0063F801, PPC_FLOAT),
|
|
|
|
GEN_HANDLER(mffs, 0x3F, 0x07, 0x12, 0x001FF800, PPC_FLOAT),
|
|
|
|
GEN_HANDLER(mtfsb0, 0x3F, 0x06, 0x02, 0x001FF800, PPC_FLOAT),
|
|
|
|
GEN_HANDLER(mtfsb1, 0x3F, 0x06, 0x01, 0x001FF800, PPC_FLOAT),
|
2013-04-20 10:56:22 +02:00
|
|
|
GEN_HANDLER(mtfsf, 0x3F, 0x07, 0x16, 0x00000000, PPC_FLOAT),
|
|
|
|
GEN_HANDLER(mtfsfi, 0x3F, 0x06, 0x04, 0x006e0800, PPC_FLOAT),
|
2009-06-17 17:22:31 +02:00
|
|
|
#if defined(TARGET_PPC64)
|
|
|
|
GEN_HANDLER(ld, 0x3A, 0xFF, 0xFF, 0x00000000, PPC_64B),
|
|
|
|
GEN_HANDLER(lq, 0x38, 0xFF, 0xFF, 0x00000000, PPC_64BX),
|
|
|
|
GEN_HANDLER(std, 0x3E, 0xFF, 0xFF, 0x00000000, PPC_64B),
|
|
|
|
#endif
|
|
|
|
GEN_HANDLER(lmw, 0x2E, 0xFF, 0xFF, 0x00000000, PPC_INTEGER),
|
|
|
|
GEN_HANDLER(stmw, 0x2F, 0xFF, 0xFF, 0x00000000, PPC_INTEGER),
|
|
|
|
GEN_HANDLER(lswi, 0x1F, 0x15, 0x12, 0x00000001, PPC_STRING),
|
|
|
|
GEN_HANDLER(lswx, 0x1F, 0x15, 0x10, 0x00000001, PPC_STRING),
|
|
|
|
GEN_HANDLER(stswi, 0x1F, 0x15, 0x16, 0x00000001, PPC_STRING),
|
|
|
|
GEN_HANDLER(stswx, 0x1F, 0x15, 0x14, 0x00000001, PPC_STRING),
|
|
|
|
GEN_HANDLER(eieio, 0x1F, 0x16, 0x1A, 0x03FFF801, PPC_MEM_EIEIO),
|
|
|
|
GEN_HANDLER(isync, 0x13, 0x16, 0x04, 0x03FFF801, PPC_MEM),
|
2014-01-07 17:05:56 +01:00
|
|
|
GEN_HANDLER_E(lbarx, 0x1F, 0x14, 0x01, 0, PPC_NONE, PPC2_ATOMIC_ISA206),
|
|
|
|
GEN_HANDLER_E(lharx, 0x1F, 0x14, 0x03, 0, PPC_NONE, PPC2_ATOMIC_ISA206),
|
2010-09-10 17:08:33 +02:00
|
|
|
GEN_HANDLER(lwarx, 0x1F, 0x14, 0x00, 0x00000000, PPC_RES),
|
2014-01-07 17:05:57 +01:00
|
|
|
GEN_HANDLER_E(stbcx_, 0x1F, 0x16, 0x15, 0, PPC_NONE, PPC2_ATOMIC_ISA206),
|
|
|
|
GEN_HANDLER_E(sthcx_, 0x1F, 0x16, 0x16, 0, PPC_NONE, PPC2_ATOMIC_ISA206),
|
2009-06-17 17:22:31 +02:00
|
|
|
GEN_HANDLER2(stwcx_, "stwcx.", 0x1F, 0x16, 0x04, 0x00000000, PPC_RES),
|
|
|
|
#if defined(TARGET_PPC64)
|
2010-09-10 17:08:33 +02:00
|
|
|
GEN_HANDLER(ldarx, 0x1F, 0x14, 0x02, 0x00000000, PPC_64B),
|
2014-02-10 18:27:00 +01:00
|
|
|
GEN_HANDLER_E(lqarx, 0x1F, 0x14, 0x08, 0, PPC_NONE, PPC2_LSQ_ISA207),
|
2009-06-17 17:22:31 +02:00
|
|
|
GEN_HANDLER2(stdcx_, "stdcx.", 0x1F, 0x16, 0x06, 0x00000000, PPC_64B),
|
2014-02-10 18:27:01 +01:00
|
|
|
GEN_HANDLER_E(stqcx_, 0x1F, 0x16, 0x05, 0, PPC_NONE, PPC2_LSQ_ISA207),
|
2009-06-17 17:22:31 +02:00
|
|
|
#endif
|
|
|
|
GEN_HANDLER(sync, 0x1F, 0x16, 0x12, 0x039FF801, PPC_MEM_SYNC),
|
|
|
|
GEN_HANDLER(wait, 0x1F, 0x1E, 0x01, 0x03FFF801, PPC_WAIT),
|
|
|
|
GEN_HANDLER(b, 0x12, 0xFF, 0xFF, 0x00000000, PPC_FLOW),
|
|
|
|
GEN_HANDLER(bc, 0x10, 0xFF, 0xFF, 0x00000000, PPC_FLOW),
|
|
|
|
GEN_HANDLER(bcctr, 0x13, 0x10, 0x10, 0x00000000, PPC_FLOW),
|
|
|
|
GEN_HANDLER(bclr, 0x13, 0x10, 0x00, 0x00000000, PPC_FLOW),
|
2014-02-10 18:26:55 +01:00
|
|
|
GEN_HANDLER_E(bctar, 0x13, 0x10, 0x11, 0, PPC_NONE, PPC2_BCTAR_ISA207),
|
2009-06-17 17:22:31 +02:00
|
|
|
GEN_HANDLER(mcrf, 0x13, 0x00, 0xFF, 0x00000001, PPC_INTEGER),
|
|
|
|
GEN_HANDLER(rfi, 0x13, 0x12, 0x01, 0x03FF8001, PPC_FLOW),
|
|
|
|
#if defined(TARGET_PPC64)
|
|
|
|
GEN_HANDLER(rfid, 0x13, 0x12, 0x00, 0x03FF8001, PPC_64B),
|
|
|
|
GEN_HANDLER(hrfid, 0x13, 0x12, 0x08, 0x03FF8001, PPC_64H),
|
|
|
|
#endif
|
|
|
|
GEN_HANDLER(sc, 0x11, 0xFF, 0xFF, 0x03FFF01D, PPC_FLOW),
|
|
|
|
GEN_HANDLER(tw, 0x1F, 0x04, 0x00, 0x00000001, PPC_FLOW),
|
|
|
|
GEN_HANDLER(twi, 0x03, 0xFF, 0xFF, 0x00000000, PPC_FLOW),
|
|
|
|
#if defined(TARGET_PPC64)
|
|
|
|
GEN_HANDLER(td, 0x1F, 0x04, 0x02, 0x00000001, PPC_64B),
|
|
|
|
GEN_HANDLER(tdi, 0x02, 0xFF, 0xFF, 0x00000000, PPC_64B),
|
|
|
|
#endif
|
|
|
|
GEN_HANDLER(mcrxr, 0x1F, 0x00, 0x10, 0x007FF801, PPC_MISC),
|
|
|
|
GEN_HANDLER(mfcr, 0x1F, 0x13, 0x00, 0x00000801, PPC_MISC),
|
|
|
|
GEN_HANDLER(mfmsr, 0x1F, 0x13, 0x02, 0x001FF801, PPC_MISC),
|
|
|
|
GEN_HANDLER(mfspr, 0x1F, 0x13, 0x0A, 0x00000001, PPC_MISC),
|
|
|
|
GEN_HANDLER(mftb, 0x1F, 0x13, 0x0B, 0x00000001, PPC_MFTB),
|
|
|
|
GEN_HANDLER(mtcrf, 0x1F, 0x10, 0x04, 0x00000801, PPC_MISC),
|
|
|
|
#if defined(TARGET_PPC64)
|
|
|
|
GEN_HANDLER(mtmsrd, 0x1F, 0x12, 0x05, 0x001EF801, PPC_64B),
|
|
|
|
#endif
|
|
|
|
GEN_HANDLER(mtmsr, 0x1F, 0x12, 0x04, 0x001FF801, PPC_MISC),
|
2015-11-11 23:49:39 +01:00
|
|
|
GEN_HANDLER(mtspr, 0x1F, 0x13, 0x0E, 0x00000000, PPC_MISC),
|
2009-06-17 17:22:31 +02:00
|
|
|
GEN_HANDLER(dcbf, 0x1F, 0x16, 0x02, 0x03C00001, PPC_CACHE),
|
|
|
|
GEN_HANDLER(dcbi, 0x1F, 0x16, 0x0E, 0x03E00001, PPC_CACHE),
|
|
|
|
GEN_HANDLER(dcbst, 0x1F, 0x16, 0x01, 0x03E00001, PPC_CACHE),
|
target-ppc: add extended opcodes for dcbt/dcbtst
The latest glibc provides a memrchr routine using an extended opcode
of the 'dcbt' instruction :
00000000000a7cc0 <memrchr>:
a7cc0: 11 00 4c 3c addis r2,r12,17
a7cc4: b8 f8 42 38 addi r2,r2,-1864
a7cc8: 14 2a e3 7c add r7,r3,r5
a7ccc: d0 00 07 7c neg r0,r7
a7cd0: ff ff e7 38 addi r7,r7,-1
a7cd4: 78 1b 6a 7c mr r10,r3
a7cd8: 24 06 e6 78 rldicr r6,r7,0,56
a7cdc: 60 00 20 39 li r9,96
a7ce0: 2c 32 09 7e dcbtt r9,r6
....
which breaks grep, and other commands, in TCG mode :
invalid bits: 02000000 for opcode: 1f - 16 - 08 (7e09322c) 00003fff799feca0
This patch adds the extended opcodes for dcbt/dcbtst as no-ops just
like the 'dcbt' instruction.
Signed-off-by: Cédric Le Goater <clg@fr.ibm.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
2014-02-20 14:20:35 +01:00
|
|
|
GEN_HANDLER(dcbt, 0x1F, 0x16, 0x08, 0x00000001, PPC_CACHE),
|
|
|
|
GEN_HANDLER(dcbtst, 0x1F, 0x16, 0x07, 0x00000001, PPC_CACHE),
|
2014-01-19 17:50:09 +01:00
|
|
|
GEN_HANDLER_E(dcbtls, 0x1F, 0x06, 0x05, 0x02000001, PPC_BOOKE, PPC2_BOOKE206),
|
2013-01-29 13:36:02 +01:00
|
|
|
GEN_HANDLER(dcbz, 0x1F, 0x16, 0x1F, 0x03C00001, PPC_CACHE_DCBZ),
|
2009-06-17 17:22:31 +02:00
|
|
|
GEN_HANDLER(dst, 0x1F, 0x16, 0x0A, 0x01800001, PPC_ALTIVEC),
|
|
|
|
GEN_HANDLER(dstst, 0x1F, 0x16, 0x0B, 0x02000001, PPC_ALTIVEC),
|
|
|
|
GEN_HANDLER(dss, 0x1F, 0x16, 0x19, 0x019FF801, PPC_ALTIVEC),
|
|
|
|
GEN_HANDLER(icbi, 0x1F, 0x16, 0x1E, 0x03E00001, PPC_CACHE_ICBI),
|
|
|
|
GEN_HANDLER(dcba, 0x1F, 0x16, 0x17, 0x03E00001, PPC_CACHE_DCBA),
|
|
|
|
GEN_HANDLER(mfsr, 0x1F, 0x13, 0x12, 0x0010F801, PPC_SEGMENT),
|
|
|
|
GEN_HANDLER(mfsrin, 0x1F, 0x13, 0x14, 0x001F0001, PPC_SEGMENT),
|
|
|
|
GEN_HANDLER(mtsr, 0x1F, 0x12, 0x06, 0x0010F801, PPC_SEGMENT),
|
|
|
|
GEN_HANDLER(mtsrin, 0x1F, 0x12, 0x07, 0x001F0001, PPC_SEGMENT),
|
|
|
|
#if defined(TARGET_PPC64)
|
|
|
|
GEN_HANDLER2(mfsr_64b, "mfsr", 0x1F, 0x13, 0x12, 0x0010F801, PPC_SEGMENT_64B),
|
|
|
|
GEN_HANDLER2(mfsrin_64b, "mfsrin", 0x1F, 0x13, 0x14, 0x001F0001,
|
|
|
|
PPC_SEGMENT_64B),
|
|
|
|
GEN_HANDLER2(mtsr_64b, "mtsr", 0x1F, 0x12, 0x06, 0x0010F801, PPC_SEGMENT_64B),
|
|
|
|
GEN_HANDLER2(mtsrin_64b, "mtsrin", 0x1F, 0x12, 0x07, 0x001F0001,
|
|
|
|
PPC_SEGMENT_64B),
|
2011-04-01 06:15:11 +02:00
|
|
|
GEN_HANDLER2(slbmte, "slbmte", 0x1F, 0x12, 0x0C, 0x001F0001, PPC_SEGMENT_64B),
|
|
|
|
GEN_HANDLER2(slbmfee, "slbmfee", 0x1F, 0x13, 0x1C, 0x001F0001, PPC_SEGMENT_64B),
|
|
|
|
GEN_HANDLER2(slbmfev, "slbmfev", 0x1F, 0x13, 0x1A, 0x001F0001, PPC_SEGMENT_64B),
|
2009-06-17 17:22:31 +02:00
|
|
|
#endif
|
|
|
|
GEN_HANDLER(tlbia, 0x1F, 0x12, 0x0B, 0x03FFFC01, PPC_MEM_TLBIA),
|
|
|
|
GEN_HANDLER(tlbiel, 0x1F, 0x12, 0x08, 0x03FF0001, PPC_MEM_TLBIE),
|
|
|
|
GEN_HANDLER(tlbie, 0x1F, 0x12, 0x09, 0x03FF0001, PPC_MEM_TLBIE),
|
|
|
|
GEN_HANDLER(tlbsync, 0x1F, 0x16, 0x11, 0x03FFF801, PPC_MEM_TLBSYNC),
|
|
|
|
#if defined(TARGET_PPC64)
|
|
|
|
GEN_HANDLER(slbia, 0x1F, 0x12, 0x0F, 0x03FFFC01, PPC_SLBI),
|
|
|
|
GEN_HANDLER(slbie, 0x1F, 0x12, 0x0D, 0x03FF0001, PPC_SLBI),
|
|
|
|
#endif
|
|
|
|
GEN_HANDLER(eciwx, 0x1F, 0x16, 0x0D, 0x00000001, PPC_EXTERN),
|
|
|
|
GEN_HANDLER(ecowx, 0x1F, 0x16, 0x09, 0x00000001, PPC_EXTERN),
|
|
|
|
GEN_HANDLER(abs, 0x1F, 0x08, 0x0B, 0x0000F800, PPC_POWER_BR),
|
|
|
|
GEN_HANDLER(abso, 0x1F, 0x08, 0x1B, 0x0000F800, PPC_POWER_BR),
|
|
|
|
GEN_HANDLER(clcs, 0x1F, 0x10, 0x13, 0x0000F800, PPC_POWER_BR),
|
|
|
|
GEN_HANDLER(div, 0x1F, 0x0B, 0x0A, 0x00000000, PPC_POWER_BR),
|
|
|
|
GEN_HANDLER(divo, 0x1F, 0x0B, 0x1A, 0x00000000, PPC_POWER_BR),
|
|
|
|
GEN_HANDLER(divs, 0x1F, 0x0B, 0x0B, 0x00000000, PPC_POWER_BR),
|
|
|
|
GEN_HANDLER(divso, 0x1F, 0x0B, 0x1B, 0x00000000, PPC_POWER_BR),
|
|
|
|
GEN_HANDLER(doz, 0x1F, 0x08, 0x08, 0x00000000, PPC_POWER_BR),
|
|
|
|
GEN_HANDLER(dozo, 0x1F, 0x08, 0x18, 0x00000000, PPC_POWER_BR),
|
|
|
|
GEN_HANDLER(dozi, 0x09, 0xFF, 0xFF, 0x00000000, PPC_POWER_BR),
|
|
|
|
GEN_HANDLER(lscbx, 0x1F, 0x15, 0x08, 0x00000000, PPC_POWER_BR),
|
|
|
|
GEN_HANDLER(maskg, 0x1F, 0x1D, 0x00, 0x00000000, PPC_POWER_BR),
|
|
|
|
GEN_HANDLER(maskir, 0x1F, 0x1D, 0x10, 0x00000000, PPC_POWER_BR),
|
|
|
|
GEN_HANDLER(mul, 0x1F, 0x0B, 0x03, 0x00000000, PPC_POWER_BR),
|
|
|
|
GEN_HANDLER(mulo, 0x1F, 0x0B, 0x13, 0x00000000, PPC_POWER_BR),
|
|
|
|
GEN_HANDLER(nabs, 0x1F, 0x08, 0x0F, 0x00000000, PPC_POWER_BR),
|
|
|
|
GEN_HANDLER(nabso, 0x1F, 0x08, 0x1F, 0x00000000, PPC_POWER_BR),
|
|
|
|
GEN_HANDLER(rlmi, 0x16, 0xFF, 0xFF, 0x00000000, PPC_POWER_BR),
|
|
|
|
GEN_HANDLER(rrib, 0x1F, 0x19, 0x10, 0x00000000, PPC_POWER_BR),
|
|
|
|
GEN_HANDLER(sle, 0x1F, 0x19, 0x04, 0x00000000, PPC_POWER_BR),
|
|
|
|
GEN_HANDLER(sleq, 0x1F, 0x19, 0x06, 0x00000000, PPC_POWER_BR),
|
|
|
|
GEN_HANDLER(sliq, 0x1F, 0x18, 0x05, 0x00000000, PPC_POWER_BR),
|
|
|
|
GEN_HANDLER(slliq, 0x1F, 0x18, 0x07, 0x00000000, PPC_POWER_BR),
|
|
|
|
GEN_HANDLER(sllq, 0x1F, 0x18, 0x06, 0x00000000, PPC_POWER_BR),
|
|
|
|
GEN_HANDLER(slq, 0x1F, 0x18, 0x04, 0x00000000, PPC_POWER_BR),
|
|
|
|
GEN_HANDLER(sraiq, 0x1F, 0x18, 0x1D, 0x00000000, PPC_POWER_BR),
|
|
|
|
GEN_HANDLER(sraq, 0x1F, 0x18, 0x1C, 0x00000000, PPC_POWER_BR),
|
|
|
|
GEN_HANDLER(sre, 0x1F, 0x19, 0x14, 0x00000000, PPC_POWER_BR),
|
|
|
|
GEN_HANDLER(srea, 0x1F, 0x19, 0x1C, 0x00000000, PPC_POWER_BR),
|
|
|
|
GEN_HANDLER(sreq, 0x1F, 0x19, 0x16, 0x00000000, PPC_POWER_BR),
|
|
|
|
GEN_HANDLER(sriq, 0x1F, 0x18, 0x15, 0x00000000, PPC_POWER_BR),
|
|
|
|
GEN_HANDLER(srliq, 0x1F, 0x18, 0x17, 0x00000000, PPC_POWER_BR),
|
|
|
|
GEN_HANDLER(srlq, 0x1F, 0x18, 0x16, 0x00000000, PPC_POWER_BR),
|
|
|
|
GEN_HANDLER(srq, 0x1F, 0x18, 0x14, 0x00000000, PPC_POWER_BR),
|
|
|
|
GEN_HANDLER(dsa, 0x1F, 0x14, 0x13, 0x03FFF801, PPC_602_SPEC),
|
|
|
|
GEN_HANDLER(esa, 0x1F, 0x14, 0x12, 0x03FFF801, PPC_602_SPEC),
|
|
|
|
GEN_HANDLER(mfrom, 0x1F, 0x09, 0x08, 0x03E0F801, PPC_602_SPEC),
|
|
|
|
GEN_HANDLER2(tlbld_6xx, "tlbld", 0x1F, 0x12, 0x1E, 0x03FF0001, PPC_6xx_TLB),
|
|
|
|
GEN_HANDLER2(tlbli_6xx, "tlbli", 0x1F, 0x12, 0x1F, 0x03FF0001, PPC_6xx_TLB),
|
|
|
|
GEN_HANDLER2(tlbld_74xx, "tlbld", 0x1F, 0x12, 0x1E, 0x03FF0001, PPC_74xx_TLB),
|
|
|
|
GEN_HANDLER2(tlbli_74xx, "tlbli", 0x1F, 0x12, 0x1F, 0x03FF0001, PPC_74xx_TLB),
|
|
|
|
GEN_HANDLER(clf, 0x1F, 0x16, 0x03, 0x03E00000, PPC_POWER),
|
|
|
|
GEN_HANDLER(cli, 0x1F, 0x16, 0x0F, 0x03E00000, PPC_POWER),
|
|
|
|
GEN_HANDLER(dclst, 0x1F, 0x16, 0x13, 0x03E00000, PPC_POWER),
|
|
|
|
GEN_HANDLER(mfsri, 0x1F, 0x13, 0x13, 0x00000001, PPC_POWER),
|
|
|
|
GEN_HANDLER(rac, 0x1F, 0x12, 0x19, 0x00000001, PPC_POWER),
|
|
|
|
GEN_HANDLER(rfsvc, 0x13, 0x12, 0x02, 0x03FFF0001, PPC_POWER),
|
|
|
|
GEN_HANDLER(lfq, 0x38, 0xFF, 0xFF, 0x00000003, PPC_POWER2),
|
|
|
|
GEN_HANDLER(lfqu, 0x39, 0xFF, 0xFF, 0x00000003, PPC_POWER2),
|
|
|
|
GEN_HANDLER(lfqux, 0x1F, 0x17, 0x19, 0x00000001, PPC_POWER2),
|
|
|
|
GEN_HANDLER(lfqx, 0x1F, 0x17, 0x18, 0x00000001, PPC_POWER2),
|
|
|
|
GEN_HANDLER(stfq, 0x3C, 0xFF, 0xFF, 0x00000003, PPC_POWER2),
|
|
|
|
GEN_HANDLER(stfqu, 0x3D, 0xFF, 0xFF, 0x00000003, PPC_POWER2),
|
|
|
|
GEN_HANDLER(stfqux, 0x1F, 0x17, 0x1D, 0x00000001, PPC_POWER2),
|
|
|
|
GEN_HANDLER(stfqx, 0x1F, 0x17, 0x1C, 0x00000001, PPC_POWER2),
|
|
|
|
GEN_HANDLER(mfapidi, 0x1F, 0x13, 0x08, 0x0000F801, PPC_MFAPIDI),
|
|
|
|
GEN_HANDLER(tlbiva, 0x1F, 0x12, 0x18, 0x03FFF801, PPC_TLBIVA),
|
|
|
|
GEN_HANDLER(mfdcr, 0x1F, 0x03, 0x0A, 0x00000001, PPC_DCR),
|
|
|
|
GEN_HANDLER(mtdcr, 0x1F, 0x03, 0x0E, 0x00000001, PPC_DCR),
|
|
|
|
GEN_HANDLER(mfdcrx, 0x1F, 0x03, 0x08, 0x00000000, PPC_DCRX),
|
|
|
|
GEN_HANDLER(mtdcrx, 0x1F, 0x03, 0x0C, 0x00000000, PPC_DCRX),
|
|
|
|
GEN_HANDLER(mfdcrux, 0x1F, 0x03, 0x09, 0x00000000, PPC_DCRUX),
|
|
|
|
GEN_HANDLER(mtdcrux, 0x1F, 0x03, 0x0D, 0x00000000, PPC_DCRUX),
|
|
|
|
GEN_HANDLER(dccci, 0x1F, 0x06, 0x0E, 0x03E00001, PPC_4xx_COMMON),
|
|
|
|
GEN_HANDLER(dcread, 0x1F, 0x06, 0x0F, 0x00000001, PPC_4xx_COMMON),
|
|
|
|
GEN_HANDLER2(icbt_40x, "icbt", 0x1F, 0x06, 0x08, 0x03E00001, PPC_40x_ICBT),
|
|
|
|
GEN_HANDLER(iccci, 0x1F, 0x06, 0x1E, 0x00000001, PPC_4xx_COMMON),
|
|
|
|
GEN_HANDLER(icread, 0x1F, 0x06, 0x1F, 0x03E00001, PPC_4xx_COMMON),
|
|
|
|
GEN_HANDLER2(rfci_40x, "rfci", 0x13, 0x13, 0x01, 0x03FF8001, PPC_40x_EXCP),
|
2011-04-30 23:34:58 +02:00
|
|
|
GEN_HANDLER_E(rfci, 0x13, 0x13, 0x01, 0x03FF8001, PPC_BOOKE, PPC2_BOOKE206),
|
2009-06-17 17:22:31 +02:00
|
|
|
GEN_HANDLER(rfdi, 0x13, 0x07, 0x01, 0x03FF8001, PPC_RFDI),
|
|
|
|
GEN_HANDLER(rfmci, 0x13, 0x06, 0x01, 0x03FF8001, PPC_RFMCI),
|
|
|
|
GEN_HANDLER2(tlbre_40x, "tlbre", 0x1F, 0x12, 0x1D, 0x00000001, PPC_40x_TLB),
|
|
|
|
GEN_HANDLER2(tlbsx_40x, "tlbsx", 0x1F, 0x12, 0x1C, 0x00000000, PPC_40x_TLB),
|
|
|
|
GEN_HANDLER2(tlbwe_40x, "tlbwe", 0x1F, 0x12, 0x1E, 0x00000001, PPC_40x_TLB),
|
|
|
|
GEN_HANDLER2(tlbre_440, "tlbre", 0x1F, 0x12, 0x1D, 0x00000001, PPC_BOOKE),
|
|
|
|
GEN_HANDLER2(tlbsx_440, "tlbsx", 0x1F, 0x12, 0x1C, 0x00000000, PPC_BOOKE),
|
|
|
|
GEN_HANDLER2(tlbwe_440, "tlbwe", 0x1F, 0x12, 0x1E, 0x00000001, PPC_BOOKE),
|
2011-04-30 23:34:58 +02:00
|
|
|
GEN_HANDLER2_E(tlbre_booke206, "tlbre", 0x1F, 0x12, 0x1D, 0x00000001,
|
|
|
|
PPC_NONE, PPC2_BOOKE206),
|
|
|
|
GEN_HANDLER2_E(tlbsx_booke206, "tlbsx", 0x1F, 0x12, 0x1C, 0x00000000,
|
|
|
|
PPC_NONE, PPC2_BOOKE206),
|
|
|
|
GEN_HANDLER2_E(tlbwe_booke206, "tlbwe", 0x1F, 0x12, 0x1E, 0x00000001,
|
|
|
|
PPC_NONE, PPC2_BOOKE206),
|
|
|
|
GEN_HANDLER2_E(tlbivax_booke206, "tlbivax", 0x1F, 0x12, 0x18, 0x00000001,
|
|
|
|
PPC_NONE, PPC2_BOOKE206),
|
2012-01-20 04:09:15 +01:00
|
|
|
GEN_HANDLER2_E(tlbilx_booke206, "tlbilx", 0x1F, 0x12, 0x00, 0x03800001,
|
|
|
|
PPC_NONE, PPC2_BOOKE206),
|
2012-01-31 03:19:23 +01:00
|
|
|
GEN_HANDLER2_E(msgsnd, "msgsnd", 0x1F, 0x0E, 0x06, 0x03ff0001,
|
|
|
|
PPC_NONE, PPC2_PRCNTL),
|
2012-01-31 03:18:35 +01:00
|
|
|
GEN_HANDLER2_E(msgclr, "msgclr", 0x1F, 0x0E, 0x07, 0x03ff0001,
|
|
|
|
PPC_NONE, PPC2_PRCNTL),
|
2009-06-17 17:22:31 +02:00
|
|
|
GEN_HANDLER(wrtee, 0x1F, 0x03, 0x04, 0x000FFC01, PPC_WRTEE),
|
2009-07-03 12:56:57 +02:00
|
|
|
GEN_HANDLER(wrteei, 0x1F, 0x03, 0x05, 0x000E7C01, PPC_WRTEE),
|
2009-06-17 17:22:31 +02:00
|
|
|
GEN_HANDLER(dlmzb, 0x1F, 0x0E, 0x02, 0x00000000, PPC_440_SPEC),
|
2011-04-30 23:34:58 +02:00
|
|
|
GEN_HANDLER_E(mbar, 0x1F, 0x16, 0x1a, 0x001FF801,
|
|
|
|
PPC_BOOKE, PPC2_BOOKE206),
|
2012-01-21 03:48:58 +01:00
|
|
|
GEN_HANDLER(msync_4xx, 0x1F, 0x16, 0x12, 0x03FFF801, PPC_BOOKE),
|
2011-04-30 23:34:58 +02:00
|
|
|
GEN_HANDLER2_E(icbt_440, "icbt", 0x1F, 0x16, 0x00, 0x03E00001,
|
|
|
|
PPC_BOOKE, PPC2_BOOKE206),
|
2009-06-17 17:22:31 +02:00
|
|
|
GEN_HANDLER(lvsl, 0x1f, 0x06, 0x00, 0x00000001, PPC_ALTIVEC),
|
|
|
|
GEN_HANDLER(lvsr, 0x1f, 0x06, 0x01, 0x00000001, PPC_ALTIVEC),
|
|
|
|
GEN_HANDLER(mfvscr, 0x04, 0x2, 0x18, 0x001ff800, PPC_ALTIVEC),
|
|
|
|
GEN_HANDLER(mtvscr, 0x04, 0x2, 0x19, 0x03ff0000, PPC_ALTIVEC),
|
|
|
|
GEN_HANDLER(vmladduhm, 0x04, 0x11, 0xFF, 0x00000000, PPC_ALTIVEC),
|
|
|
|
GEN_HANDLER2(evsel0, "evsel", 0x04, 0x1c, 0x09, 0x00000000, PPC_SPE),
|
|
|
|
GEN_HANDLER2(evsel1, "evsel", 0x04, 0x1d, 0x09, 0x00000000, PPC_SPE),
|
|
|
|
GEN_HANDLER2(evsel2, "evsel", 0x04, 0x1e, 0x09, 0x00000000, PPC_SPE),
|
|
|
|
GEN_HANDLER2(evsel3, "evsel", 0x04, 0x1f, 0x09, 0x00000000, PPC_SPE),
|
|
|
|
|
|
|
|
#undef GEN_INT_ARITH_ADD
|
|
|
|
#undef GEN_INT_ARITH_ADD_CONST
|
|
|
|
#define GEN_INT_ARITH_ADD(name, opc3, add_ca, compute_ca, compute_ov) \
|
|
|
|
GEN_HANDLER(name, 0x1F, 0x0A, opc3, 0x00000000, PPC_INTEGER),
|
|
|
|
#define GEN_INT_ARITH_ADD_CONST(name, opc3, const_val, \
|
|
|
|
add_ca, compute_ca, compute_ov) \
|
|
|
|
GEN_HANDLER(name, 0x1F, 0x0A, opc3, 0x0000F800, PPC_INTEGER),
|
|
|
|
GEN_INT_ARITH_ADD(add, 0x08, 0, 0, 0)
|
|
|
|
GEN_INT_ARITH_ADD(addo, 0x18, 0, 0, 1)
|
|
|
|
GEN_INT_ARITH_ADD(addc, 0x00, 0, 1, 0)
|
|
|
|
GEN_INT_ARITH_ADD(addco, 0x10, 0, 1, 1)
|
|
|
|
GEN_INT_ARITH_ADD(adde, 0x04, 1, 1, 0)
|
|
|
|
GEN_INT_ARITH_ADD(addeo, 0x14, 1, 1, 1)
|
|
|
|
GEN_INT_ARITH_ADD_CONST(addme, 0x07, -1LL, 1, 1, 0)
|
|
|
|
GEN_INT_ARITH_ADD_CONST(addmeo, 0x17, -1LL, 1, 1, 1)
|
|
|
|
GEN_INT_ARITH_ADD_CONST(addze, 0x06, 0, 1, 1, 0)
|
|
|
|
GEN_INT_ARITH_ADD_CONST(addzeo, 0x16, 0, 1, 1, 1)
|
|
|
|
|
|
|
|
#undef GEN_INT_ARITH_DIVW
|
|
|
|
#define GEN_INT_ARITH_DIVW(name, opc3, sign, compute_ov) \
|
|
|
|
GEN_HANDLER(name, 0x1F, 0x0B, opc3, 0x00000000, PPC_INTEGER)
|
|
|
|
GEN_INT_ARITH_DIVW(divwu, 0x0E, 0, 0),
|
|
|
|
GEN_INT_ARITH_DIVW(divwuo, 0x1E, 0, 1),
|
|
|
|
GEN_INT_ARITH_DIVW(divw, 0x0F, 1, 0),
|
|
|
|
GEN_INT_ARITH_DIVW(divwo, 0x1F, 1, 1),
|
2014-01-07 17:05:54 +01:00
|
|
|
GEN_HANDLER_E(divwe, 0x1F, 0x0B, 0x0D, 0, PPC_NONE, PPC2_DIVE_ISA206),
|
|
|
|
GEN_HANDLER_E(divweo, 0x1F, 0x0B, 0x1D, 0, PPC_NONE, PPC2_DIVE_ISA206),
|
2014-01-07 17:05:53 +01:00
|
|
|
GEN_HANDLER_E(divweu, 0x1F, 0x0B, 0x0C, 0, PPC_NONE, PPC2_DIVE_ISA206),
|
|
|
|
GEN_HANDLER_E(divweuo, 0x1F, 0x0B, 0x1C, 0, PPC_NONE, PPC2_DIVE_ISA206),
|
2009-06-17 17:22:31 +02:00
|
|
|
|
|
|
|
#if defined(TARGET_PPC64)
|
|
|
|
#undef GEN_INT_ARITH_DIVD
|
|
|
|
#define GEN_INT_ARITH_DIVD(name, opc3, sign, compute_ov) \
|
|
|
|
GEN_HANDLER(name, 0x1F, 0x09, opc3, 0x00000000, PPC_64B)
|
|
|
|
GEN_INT_ARITH_DIVD(divdu, 0x0E, 0, 0),
|
|
|
|
GEN_INT_ARITH_DIVD(divduo, 0x1E, 0, 1),
|
|
|
|
GEN_INT_ARITH_DIVD(divd, 0x0F, 1, 0),
|
|
|
|
GEN_INT_ARITH_DIVD(divdo, 0x1F, 1, 1),
|
|
|
|
|
2014-01-07 17:05:51 +01:00
|
|
|
GEN_HANDLER_E(divdeu, 0x1F, 0x09, 0x0C, 0, PPC_NONE, PPC2_DIVE_ISA206),
|
|
|
|
GEN_HANDLER_E(divdeuo, 0x1F, 0x09, 0x1C, 0, PPC_NONE, PPC2_DIVE_ISA206),
|
2014-01-07 17:05:52 +01:00
|
|
|
GEN_HANDLER_E(divde, 0x1F, 0x09, 0x0D, 0, PPC_NONE, PPC2_DIVE_ISA206),
|
|
|
|
GEN_HANDLER_E(divdeo, 0x1F, 0x09, 0x1D, 0, PPC_NONE, PPC2_DIVE_ISA206),
|
2014-01-07 17:05:51 +01:00
|
|
|
|
2009-06-17 17:22:31 +02:00
|
|
|
#undef GEN_INT_ARITH_MUL_HELPER
|
|
|
|
#define GEN_INT_ARITH_MUL_HELPER(name, opc3) \
|
|
|
|
GEN_HANDLER(name, 0x1F, 0x09, opc3, 0x00000000, PPC_64B)
|
|
|
|
GEN_INT_ARITH_MUL_HELPER(mulhdu, 0x00),
|
|
|
|
GEN_INT_ARITH_MUL_HELPER(mulhd, 0x02),
|
|
|
|
GEN_INT_ARITH_MUL_HELPER(mulldo, 0x17),
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#undef GEN_INT_ARITH_SUBF
|
|
|
|
#undef GEN_INT_ARITH_SUBF_CONST
|
|
|
|
#define GEN_INT_ARITH_SUBF(name, opc3, add_ca, compute_ca, compute_ov) \
|
|
|
|
GEN_HANDLER(name, 0x1F, 0x08, opc3, 0x00000000, PPC_INTEGER),
|
|
|
|
#define GEN_INT_ARITH_SUBF_CONST(name, opc3, const_val, \
|
|
|
|
add_ca, compute_ca, compute_ov) \
|
|
|
|
GEN_HANDLER(name, 0x1F, 0x08, opc3, 0x0000F800, PPC_INTEGER),
|
|
|
|
GEN_INT_ARITH_SUBF(subf, 0x01, 0, 0, 0)
|
|
|
|
GEN_INT_ARITH_SUBF(subfo, 0x11, 0, 0, 1)
|
|
|
|
GEN_INT_ARITH_SUBF(subfc, 0x00, 0, 1, 0)
|
|
|
|
GEN_INT_ARITH_SUBF(subfco, 0x10, 0, 1, 1)
|
|
|
|
GEN_INT_ARITH_SUBF(subfe, 0x04, 1, 1, 0)
|
|
|
|
GEN_INT_ARITH_SUBF(subfeo, 0x14, 1, 1, 1)
|
|
|
|
GEN_INT_ARITH_SUBF_CONST(subfme, 0x07, -1LL, 1, 1, 0)
|
|
|
|
GEN_INT_ARITH_SUBF_CONST(subfmeo, 0x17, -1LL, 1, 1, 1)
|
|
|
|
GEN_INT_ARITH_SUBF_CONST(subfze, 0x06, 0, 1, 1, 0)
|
|
|
|
GEN_INT_ARITH_SUBF_CONST(subfzeo, 0x16, 0, 1, 1, 1)
|
|
|
|
|
|
|
|
#undef GEN_LOGICAL1
|
|
|
|
#undef GEN_LOGICAL2
|
|
|
|
#define GEN_LOGICAL2(name, tcg_op, opc, type) \
|
|
|
|
GEN_HANDLER(name, 0x1F, 0x1C, opc, 0x00000000, type)
|
|
|
|
#define GEN_LOGICAL1(name, tcg_op, opc, type) \
|
|
|
|
GEN_HANDLER(name, 0x1F, 0x1A, opc, 0x00000000, type)
|
|
|
|
GEN_LOGICAL2(and, tcg_gen_and_tl, 0x00, PPC_INTEGER),
|
|
|
|
GEN_LOGICAL2(andc, tcg_gen_andc_tl, 0x01, PPC_INTEGER),
|
|
|
|
GEN_LOGICAL2(eqv, tcg_gen_eqv_tl, 0x08, PPC_INTEGER),
|
|
|
|
GEN_LOGICAL1(extsb, tcg_gen_ext8s_tl, 0x1D, PPC_INTEGER),
|
|
|
|
GEN_LOGICAL1(extsh, tcg_gen_ext16s_tl, 0x1C, PPC_INTEGER),
|
|
|
|
GEN_LOGICAL2(nand, tcg_gen_nand_tl, 0x0E, PPC_INTEGER),
|
|
|
|
GEN_LOGICAL2(nor, tcg_gen_nor_tl, 0x03, PPC_INTEGER),
|
|
|
|
GEN_LOGICAL2(orc, tcg_gen_orc_tl, 0x0C, PPC_INTEGER),
|
|
|
|
#if defined(TARGET_PPC64)
|
|
|
|
GEN_LOGICAL1(extsw, tcg_gen_ext32s_tl, 0x1E, PPC_64B),
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(TARGET_PPC64)
|
|
|
|
#undef GEN_PPC64_R2
|
|
|
|
#undef GEN_PPC64_R4
|
|
|
|
#define GEN_PPC64_R2(name, opc1, opc2) \
|
|
|
|
GEN_HANDLER2(name##0, stringify(name), opc1, opc2, 0xFF, 0x00000000, PPC_64B),\
|
|
|
|
GEN_HANDLER2(name##1, stringify(name), opc1, opc2 | 0x10, 0xFF, 0x00000000, \
|
|
|
|
PPC_64B)
|
|
|
|
#define GEN_PPC64_R4(name, opc1, opc2) \
|
|
|
|
GEN_HANDLER2(name##0, stringify(name), opc1, opc2, 0xFF, 0x00000000, PPC_64B),\
|
|
|
|
GEN_HANDLER2(name##1, stringify(name), opc1, opc2 | 0x01, 0xFF, 0x00000000, \
|
|
|
|
PPC_64B), \
|
|
|
|
GEN_HANDLER2(name##2, stringify(name), opc1, opc2 | 0x10, 0xFF, 0x00000000, \
|
|
|
|
PPC_64B), \
|
|
|
|
GEN_HANDLER2(name##3, stringify(name), opc1, opc2 | 0x11, 0xFF, 0x00000000, \
|
|
|
|
PPC_64B)
|
|
|
|
GEN_PPC64_R4(rldicl, 0x1E, 0x00),
|
|
|
|
GEN_PPC64_R4(rldicr, 0x1E, 0x02),
|
|
|
|
GEN_PPC64_R4(rldic, 0x1E, 0x04),
|
|
|
|
GEN_PPC64_R2(rldcl, 0x1E, 0x08),
|
|
|
|
GEN_PPC64_R2(rldcr, 0x1E, 0x09),
|
|
|
|
GEN_PPC64_R4(rldimi, 0x1E, 0x06),
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#undef _GEN_FLOAT_ACB
|
|
|
|
#undef GEN_FLOAT_ACB
|
|
|
|
#undef _GEN_FLOAT_AB
|
|
|
|
#undef GEN_FLOAT_AB
|
|
|
|
#undef _GEN_FLOAT_AC
|
|
|
|
#undef GEN_FLOAT_AC
|
|
|
|
#undef GEN_FLOAT_B
|
|
|
|
#undef GEN_FLOAT_BS
|
|
|
|
#define _GEN_FLOAT_ACB(name, op, op1, op2, isfloat, set_fprf, type) \
|
|
|
|
GEN_HANDLER(f##name, op1, op2, 0xFF, 0x00000000, type)
|
|
|
|
#define GEN_FLOAT_ACB(name, op2, set_fprf, type) \
|
|
|
|
_GEN_FLOAT_ACB(name, name, 0x3F, op2, 0, set_fprf, type), \
|
|
|
|
_GEN_FLOAT_ACB(name##s, name, 0x3B, op2, 1, set_fprf, type)
|
|
|
|
#define _GEN_FLOAT_AB(name, op, op1, op2, inval, isfloat, set_fprf, type) \
|
|
|
|
GEN_HANDLER(f##name, op1, op2, 0xFF, inval, type)
|
|
|
|
#define GEN_FLOAT_AB(name, op2, inval, set_fprf, type) \
|
|
|
|
_GEN_FLOAT_AB(name, name, 0x3F, op2, inval, 0, set_fprf, type), \
|
|
|
|
_GEN_FLOAT_AB(name##s, name, 0x3B, op2, inval, 1, set_fprf, type)
|
|
|
|
#define _GEN_FLOAT_AC(name, op, op1, op2, inval, isfloat, set_fprf, type) \
|
|
|
|
GEN_HANDLER(f##name, op1, op2, 0xFF, inval, type)
|
|
|
|
#define GEN_FLOAT_AC(name, op2, inval, set_fprf, type) \
|
|
|
|
_GEN_FLOAT_AC(name, name, 0x3F, op2, inval, 0, set_fprf, type), \
|
|
|
|
_GEN_FLOAT_AC(name##s, name, 0x3B, op2, inval, 1, set_fprf, type)
|
|
|
|
#define GEN_FLOAT_B(name, op2, op3, set_fprf, type) \
|
|
|
|
GEN_HANDLER(f##name, 0x3F, op2, op3, 0x001F0000, type)
|
|
|
|
#define GEN_FLOAT_BS(name, op1, op2, set_fprf, type) \
|
|
|
|
GEN_HANDLER(f##name, op1, op2, 0xFF, 0x001F07C0, type)
|
|
|
|
|
|
|
|
GEN_FLOAT_AB(add, 0x15, 0x000007C0, 1, PPC_FLOAT),
|
|
|
|
GEN_FLOAT_AB(div, 0x12, 0x000007C0, 1, PPC_FLOAT),
|
|
|
|
GEN_FLOAT_AC(mul, 0x19, 0x0000F800, 1, PPC_FLOAT),
|
|
|
|
GEN_FLOAT_BS(re, 0x3F, 0x18, 1, PPC_FLOAT_EXT),
|
|
|
|
GEN_FLOAT_BS(res, 0x3B, 0x18, 1, PPC_FLOAT_FRES),
|
|
|
|
GEN_FLOAT_BS(rsqrte, 0x3F, 0x1A, 1, PPC_FLOAT_FRSQRTE),
|
|
|
|
_GEN_FLOAT_ACB(sel, sel, 0x3F, 0x17, 0, 0, PPC_FLOAT_FSEL),
|
|
|
|
GEN_FLOAT_AB(sub, 0x14, 0x000007C0, 1, PPC_FLOAT),
|
|
|
|
GEN_FLOAT_ACB(madd, 0x1D, 1, PPC_FLOAT),
|
|
|
|
GEN_FLOAT_ACB(msub, 0x1C, 1, PPC_FLOAT),
|
|
|
|
GEN_FLOAT_ACB(nmadd, 0x1F, 1, PPC_FLOAT),
|
|
|
|
GEN_FLOAT_ACB(nmsub, 0x1E, 1, PPC_FLOAT),
|
2014-01-07 17:06:07 +01:00
|
|
|
GEN_HANDLER_E(ftdiv, 0x3F, 0x00, 0x04, 1, PPC_NONE, PPC2_FP_TST_ISA206),
|
2014-01-07 17:06:08 +01:00
|
|
|
GEN_HANDLER_E(ftsqrt, 0x3F, 0x00, 0x05, 1, PPC_NONE, PPC2_FP_TST_ISA206),
|
2009-06-17 17:22:31 +02:00
|
|
|
GEN_FLOAT_B(ctiw, 0x0E, 0x00, 0, PPC_FLOAT),
|
2014-01-07 17:05:59 +01:00
|
|
|
GEN_HANDLER_E(fctiwu, 0x3F, 0x0E, 0x04, 0, PPC_NONE, PPC2_FP_CVT_ISA206),
|
2009-06-17 17:22:31 +02:00
|
|
|
GEN_FLOAT_B(ctiwz, 0x0F, 0x00, 0, PPC_FLOAT),
|
2014-01-07 17:05:59 +01:00
|
|
|
GEN_HANDLER_E(fctiwuz, 0x3F, 0x0F, 0x04, 0, PPC_NONE, PPC2_FP_CVT_ISA206),
|
2009-06-17 17:22:31 +02:00
|
|
|
GEN_FLOAT_B(rsp, 0x0C, 0x00, 1, PPC_FLOAT),
|
2014-09-12 21:31:32 +02:00
|
|
|
GEN_HANDLER_E(fcfid, 0x3F, 0x0E, 0x1A, 0x001F0000, PPC_NONE, PPC2_FP_CVT_S64),
|
2014-01-07 17:06:00 +01:00
|
|
|
GEN_HANDLER_E(fcfids, 0x3B, 0x0E, 0x1A, 0, PPC_NONE, PPC2_FP_CVT_ISA206),
|
|
|
|
GEN_HANDLER_E(fcfidu, 0x3F, 0x0E, 0x1E, 0, PPC_NONE, PPC2_FP_CVT_ISA206),
|
|
|
|
GEN_HANDLER_E(fcfidus, 0x3B, 0x0E, 0x1E, 0, PPC_NONE, PPC2_FP_CVT_ISA206),
|
2014-09-12 21:31:32 +02:00
|
|
|
GEN_HANDLER_E(fctid, 0x3F, 0x0E, 0x19, 0x001F0000, PPC_NONE, PPC2_FP_CVT_S64),
|
2014-01-07 17:05:59 +01:00
|
|
|
GEN_HANDLER_E(fctidu, 0x3F, 0x0E, 0x1D, 0, PPC_NONE, PPC2_FP_CVT_ISA206),
|
2014-09-12 21:31:32 +02:00
|
|
|
GEN_HANDLER_E(fctidz, 0x3F, 0x0F, 0x19, 0x001F0000, PPC_NONE, PPC2_FP_CVT_S64),
|
2014-01-07 17:05:59 +01:00
|
|
|
GEN_HANDLER_E(fctiduz, 0x3F, 0x0F, 0x1D, 0, PPC_NONE, PPC2_FP_CVT_ISA206),
|
2009-06-17 17:22:31 +02:00
|
|
|
GEN_FLOAT_B(rin, 0x08, 0x0C, 1, PPC_FLOAT_EXT),
|
|
|
|
GEN_FLOAT_B(riz, 0x08, 0x0D, 1, PPC_FLOAT_EXT),
|
|
|
|
GEN_FLOAT_B(rip, 0x08, 0x0E, 1, PPC_FLOAT_EXT),
|
|
|
|
GEN_FLOAT_B(rim, 0x08, 0x0F, 1, PPC_FLOAT_EXT),
|
|
|
|
|
|
|
|
#undef GEN_LD
|
|
|
|
#undef GEN_LDU
|
|
|
|
#undef GEN_LDUX
|
2012-02-27 18:18:08 +01:00
|
|
|
#undef GEN_LDX_E
|
2009-06-17 17:22:31 +02:00
|
|
|
#undef GEN_LDS
|
|
|
|
#define GEN_LD(name, ldop, opc, type) \
|
|
|
|
GEN_HANDLER(name, opc, 0xFF, 0xFF, 0x00000000, type),
|
|
|
|
#define GEN_LDU(name, ldop, opc, type) \
|
|
|
|
GEN_HANDLER(name##u, opc, 0xFF, 0xFF, 0x00000000, type),
|
|
|
|
#define GEN_LDUX(name, ldop, opc2, opc3, type) \
|
|
|
|
GEN_HANDLER(name##ux, 0x1F, opc2, opc3, 0x00000001, type),
|
2012-02-27 18:18:08 +01:00
|
|
|
#define GEN_LDX_E(name, ldop, opc2, opc3, type, type2) \
|
|
|
|
GEN_HANDLER_E(name##x, 0x1F, opc2, opc3, 0x00000001, type, type2),
|
2009-06-17 17:22:31 +02:00
|
|
|
#define GEN_LDS(name, ldop, op, type) \
|
|
|
|
GEN_LD(name, ldop, op | 0x20, type) \
|
|
|
|
GEN_LDU(name, ldop, op | 0x21, type) \
|
|
|
|
GEN_LDUX(name, ldop, 0x17, op | 0x01, type) \
|
|
|
|
GEN_LDX(name, ldop, 0x17, op | 0x00, type)
|
|
|
|
|
|
|
|
GEN_LDS(lbz, ld8u, 0x02, PPC_INTEGER)
|
|
|
|
GEN_LDS(lha, ld16s, 0x0A, PPC_INTEGER)
|
|
|
|
GEN_LDS(lhz, ld16u, 0x08, PPC_INTEGER)
|
|
|
|
GEN_LDS(lwz, ld32u, 0x00, PPC_INTEGER)
|
|
|
|
#if defined(TARGET_PPC64)
|
|
|
|
GEN_LDUX(lwa, ld32s, 0x15, 0x0B, PPC_64B)
|
|
|
|
GEN_LDX(lwa, ld32s, 0x15, 0x0A, PPC_64B)
|
|
|
|
GEN_LDUX(ld, ld64, 0x15, 0x01, PPC_64B)
|
|
|
|
GEN_LDX(ld, ld64, 0x15, 0x00, PPC_64B)
|
2012-02-27 18:18:08 +01:00
|
|
|
GEN_LDX_E(ldbr, ld64ur, 0x14, 0x10, PPC_NONE, PPC2_DBRX)
|
2009-06-17 17:22:31 +02:00
|
|
|
#endif
|
|
|
|
GEN_LDX(lhbr, ld16ur, 0x16, 0x18, PPC_INTEGER)
|
|
|
|
GEN_LDX(lwbr, ld32ur, 0x16, 0x10, PPC_INTEGER)
|
|
|
|
|
|
|
|
#undef GEN_ST
|
|
|
|
#undef GEN_STU
|
|
|
|
#undef GEN_STUX
|
2012-02-27 18:18:08 +01:00
|
|
|
#undef GEN_STX_E
|
2009-06-17 17:22:31 +02:00
|
|
|
#undef GEN_STS
|
|
|
|
#define GEN_ST(name, stop, opc, type) \
|
|
|
|
GEN_HANDLER(name, opc, 0xFF, 0xFF, 0x00000000, type),
|
|
|
|
#define GEN_STU(name, stop, opc, type) \
|
|
|
|
GEN_HANDLER(stop##u, opc, 0xFF, 0xFF, 0x00000000, type),
|
|
|
|
#define GEN_STUX(name, stop, opc2, opc3, type) \
|
|
|
|
GEN_HANDLER(name##ux, 0x1F, opc2, opc3, 0x00000001, type),
|
2012-02-27 18:18:08 +01:00
|
|
|
#define GEN_STX_E(name, stop, opc2, opc3, type, type2) \
|
|
|
|
GEN_HANDLER_E(name##x, 0x1F, opc2, opc3, 0x00000001, type, type2),
|
2009-06-17 17:22:31 +02:00
|
|
|
#define GEN_STS(name, stop, op, type) \
|
|
|
|
GEN_ST(name, stop, op | 0x20, type) \
|
|
|
|
GEN_STU(name, stop, op | 0x21, type) \
|
|
|
|
GEN_STUX(name, stop, 0x17, op | 0x01, type) \
|
|
|
|
GEN_STX(name, stop, 0x17, op | 0x00, type)
|
|
|
|
|
|
|
|
GEN_STS(stb, st8, 0x06, PPC_INTEGER)
|
|
|
|
GEN_STS(sth, st16, 0x0C, PPC_INTEGER)
|
|
|
|
GEN_STS(stw, st32, 0x04, PPC_INTEGER)
|
|
|
|
#if defined(TARGET_PPC64)
|
|
|
|
GEN_STUX(std, st64, 0x15, 0x05, PPC_64B)
|
|
|
|
GEN_STX(std, st64, 0x15, 0x04, PPC_64B)
|
2012-02-27 18:18:08 +01:00
|
|
|
GEN_STX_E(stdbr, st64r, 0x14, 0x14, PPC_NONE, PPC2_DBRX)
|
2009-06-17 17:22:31 +02:00
|
|
|
#endif
|
|
|
|
GEN_STX(sthbr, st16r, 0x16, 0x1C, PPC_INTEGER)
|
|
|
|
GEN_STX(stwbr, st32r, 0x16, 0x14, PPC_INTEGER)
|
|
|
|
|
|
|
|
#undef GEN_LDF
|
|
|
|
#undef GEN_LDUF
|
|
|
|
#undef GEN_LDUXF
|
|
|
|
#undef GEN_LDXF
|
|
|
|
#undef GEN_LDFS
|
|
|
|
#define GEN_LDF(name, ldop, opc, type) \
|
|
|
|
GEN_HANDLER(name, opc, 0xFF, 0xFF, 0x00000000, type),
|
|
|
|
#define GEN_LDUF(name, ldop, opc, type) \
|
|
|
|
GEN_HANDLER(name##u, opc, 0xFF, 0xFF, 0x00000000, type),
|
|
|
|
#define GEN_LDUXF(name, ldop, opc, type) \
|
|
|
|
GEN_HANDLER(name##ux, 0x1F, 0x17, opc, 0x00000001, type),
|
|
|
|
#define GEN_LDXF(name, ldop, opc2, opc3, type) \
|
|
|
|
GEN_HANDLER(name##x, 0x1F, opc2, opc3, 0x00000001, type),
|
|
|
|
#define GEN_LDFS(name, ldop, op, type) \
|
|
|
|
GEN_LDF(name, ldop, op | 0x20, type) \
|
|
|
|
GEN_LDUF(name, ldop, op | 0x21, type) \
|
|
|
|
GEN_LDUXF(name, ldop, op | 0x01, type) \
|
|
|
|
GEN_LDXF(name, ldop, 0x17, op | 0x00, type)
|
|
|
|
|
|
|
|
GEN_LDFS(lfd, ld64, 0x12, PPC_FLOAT)
|
|
|
|
GEN_LDFS(lfs, ld32fs, 0x10, PPC_FLOAT)
|
2013-04-20 10:56:19 +02:00
|
|
|
GEN_HANDLER_E(lfiwax, 0x1f, 0x17, 0x1a, 0x00000001, PPC_NONE, PPC2_ISA205),
|
2014-01-07 17:06:10 +01:00
|
|
|
GEN_HANDLER_E(lfiwzx, 0x1f, 0x17, 0x1b, 0x1, PPC_NONE, PPC2_FP_CVT_ISA206),
|
2013-04-20 10:56:20 +02:00
|
|
|
GEN_HANDLER_E(lfdp, 0x39, 0xFF, 0xFF, 0x00200003, PPC_NONE, PPC2_ISA205),
|
|
|
|
GEN_HANDLER_E(lfdpx, 0x1F, 0x17, 0x18, 0x00200001, PPC_NONE, PPC2_ISA205),
|
2009-06-17 17:22:31 +02:00
|
|
|
|
|
|
|
#undef GEN_STF
|
|
|
|
#undef GEN_STUF
|
|
|
|
#undef GEN_STUXF
|
|
|
|
#undef GEN_STXF
|
|
|
|
#undef GEN_STFS
|
|
|
|
#define GEN_STF(name, stop, opc, type) \
|
|
|
|
GEN_HANDLER(name, opc, 0xFF, 0xFF, 0x00000000, type),
|
|
|
|
#define GEN_STUF(name, stop, opc, type) \
|
|
|
|
GEN_HANDLER(name##u, opc, 0xFF, 0xFF, 0x00000000, type),
|
|
|
|
#define GEN_STUXF(name, stop, opc, type) \
|
|
|
|
GEN_HANDLER(name##ux, 0x1F, 0x17, opc, 0x00000001, type),
|
|
|
|
#define GEN_STXF(name, stop, opc2, opc3, type) \
|
|
|
|
GEN_HANDLER(name##x, 0x1F, opc2, opc3, 0x00000001, type),
|
|
|
|
#define GEN_STFS(name, stop, op, type) \
|
|
|
|
GEN_STF(name, stop, op | 0x20, type) \
|
|
|
|
GEN_STUF(name, stop, op | 0x21, type) \
|
|
|
|
GEN_STUXF(name, stop, op | 0x01, type) \
|
|
|
|
GEN_STXF(name, stop, 0x17, op | 0x00, type)
|
|
|
|
|
|
|
|
GEN_STFS(stfd, st64, 0x16, PPC_FLOAT)
|
|
|
|
GEN_STFS(stfs, st32fs, 0x14, PPC_FLOAT)
|
|
|
|
GEN_STXF(stfiw, st32fiw, 0x17, 0x1E, PPC_FLOAT_STFIWX)
|
2013-04-20 10:56:21 +02:00
|
|
|
GEN_HANDLER_E(stfdp, 0x3D, 0xFF, 0xFF, 0x00200003, PPC_NONE, PPC2_ISA205),
|
|
|
|
GEN_HANDLER_E(stfdpx, 0x1F, 0x17, 0x1C, 0x00200001, PPC_NONE, PPC2_ISA205),
|
2009-06-17 17:22:31 +02:00
|
|
|
|
|
|
|
#undef GEN_CRLOGIC
|
|
|
|
#define GEN_CRLOGIC(name, tcg_op, opc) \
|
|
|
|
GEN_HANDLER(name, 0x13, 0x01, opc, 0x00000001, PPC_INTEGER)
|
|
|
|
GEN_CRLOGIC(crand, tcg_gen_and_i32, 0x08),
|
|
|
|
GEN_CRLOGIC(crandc, tcg_gen_andc_i32, 0x04),
|
|
|
|
GEN_CRLOGIC(creqv, tcg_gen_eqv_i32, 0x09),
|
|
|
|
GEN_CRLOGIC(crnand, tcg_gen_nand_i32, 0x07),
|
|
|
|
GEN_CRLOGIC(crnor, tcg_gen_nor_i32, 0x01),
|
|
|
|
GEN_CRLOGIC(cror, tcg_gen_or_i32, 0x0E),
|
|
|
|
GEN_CRLOGIC(crorc, tcg_gen_orc_i32, 0x0D),
|
|
|
|
GEN_CRLOGIC(crxor, tcg_gen_xor_i32, 0x06),
|
|
|
|
|
|
|
|
#undef GEN_MAC_HANDLER
|
|
|
|
#define GEN_MAC_HANDLER(name, opc2, opc3) \
|
|
|
|
GEN_HANDLER(name, 0x04, opc2, opc3, 0x00000000, PPC_405_MAC)
|
|
|
|
GEN_MAC_HANDLER(macchw, 0x0C, 0x05),
|
|
|
|
GEN_MAC_HANDLER(macchwo, 0x0C, 0x15),
|
|
|
|
GEN_MAC_HANDLER(macchws, 0x0C, 0x07),
|
|
|
|
GEN_MAC_HANDLER(macchwso, 0x0C, 0x17),
|
|
|
|
GEN_MAC_HANDLER(macchwsu, 0x0C, 0x06),
|
|
|
|
GEN_MAC_HANDLER(macchwsuo, 0x0C, 0x16),
|
|
|
|
GEN_MAC_HANDLER(macchwu, 0x0C, 0x04),
|
|
|
|
GEN_MAC_HANDLER(macchwuo, 0x0C, 0x14),
|
|
|
|
GEN_MAC_HANDLER(machhw, 0x0C, 0x01),
|
|
|
|
GEN_MAC_HANDLER(machhwo, 0x0C, 0x11),
|
|
|
|
GEN_MAC_HANDLER(machhws, 0x0C, 0x03),
|
|
|
|
GEN_MAC_HANDLER(machhwso, 0x0C, 0x13),
|
|
|
|
GEN_MAC_HANDLER(machhwsu, 0x0C, 0x02),
|
|
|
|
GEN_MAC_HANDLER(machhwsuo, 0x0C, 0x12),
|
|
|
|
GEN_MAC_HANDLER(machhwu, 0x0C, 0x00),
|
|
|
|
GEN_MAC_HANDLER(machhwuo, 0x0C, 0x10),
|
|
|
|
GEN_MAC_HANDLER(maclhw, 0x0C, 0x0D),
|
|
|
|
GEN_MAC_HANDLER(maclhwo, 0x0C, 0x1D),
|
|
|
|
GEN_MAC_HANDLER(maclhws, 0x0C, 0x0F),
|
|
|
|
GEN_MAC_HANDLER(maclhwso, 0x0C, 0x1F),
|
|
|
|
GEN_MAC_HANDLER(maclhwu, 0x0C, 0x0C),
|
|
|
|
GEN_MAC_HANDLER(maclhwuo, 0x0C, 0x1C),
|
|
|
|
GEN_MAC_HANDLER(maclhwsu, 0x0C, 0x0E),
|
|
|
|
GEN_MAC_HANDLER(maclhwsuo, 0x0C, 0x1E),
|
|
|
|
GEN_MAC_HANDLER(nmacchw, 0x0E, 0x05),
|
|
|
|
GEN_MAC_HANDLER(nmacchwo, 0x0E, 0x15),
|
|
|
|
GEN_MAC_HANDLER(nmacchws, 0x0E, 0x07),
|
|
|
|
GEN_MAC_HANDLER(nmacchwso, 0x0E, 0x17),
|
|
|
|
GEN_MAC_HANDLER(nmachhw, 0x0E, 0x01),
|
|
|
|
GEN_MAC_HANDLER(nmachhwo, 0x0E, 0x11),
|
|
|
|
GEN_MAC_HANDLER(nmachhws, 0x0E, 0x03),
|
|
|
|
GEN_MAC_HANDLER(nmachhwso, 0x0E, 0x13),
|
|
|
|
GEN_MAC_HANDLER(nmaclhw, 0x0E, 0x0D),
|
|
|
|
GEN_MAC_HANDLER(nmaclhwo, 0x0E, 0x1D),
|
|
|
|
GEN_MAC_HANDLER(nmaclhws, 0x0E, 0x0F),
|
|
|
|
GEN_MAC_HANDLER(nmaclhwso, 0x0E, 0x1F),
|
|
|
|
GEN_MAC_HANDLER(mulchw, 0x08, 0x05),
|
|
|
|
GEN_MAC_HANDLER(mulchwu, 0x08, 0x04),
|
|
|
|
GEN_MAC_HANDLER(mulhhw, 0x08, 0x01),
|
|
|
|
GEN_MAC_HANDLER(mulhhwu, 0x08, 0x00),
|
|
|
|
GEN_MAC_HANDLER(mullhw, 0x08, 0x0D),
|
|
|
|
GEN_MAC_HANDLER(mullhwu, 0x08, 0x0C),
|
|
|
|
|
|
|
|
#undef GEN_VR_LDX
|
|
|
|
#undef GEN_VR_STX
|
|
|
|
#undef GEN_VR_LVE
|
|
|
|
#undef GEN_VR_STVE
|
|
|
|
#define GEN_VR_LDX(name, opc2, opc3) \
|
|
|
|
GEN_HANDLER(name, 0x1F, opc2, opc3, 0x00000001, PPC_ALTIVEC)
|
|
|
|
#define GEN_VR_STX(name, opc2, opc3) \
|
|
|
|
GEN_HANDLER(st##name, 0x1F, opc2, opc3, 0x00000001, PPC_ALTIVEC)
|
|
|
|
#define GEN_VR_LVE(name, opc2, opc3) \
|
|
|
|
GEN_HANDLER(lve##name, 0x1F, opc2, opc3, 0x00000001, PPC_ALTIVEC)
|
|
|
|
#define GEN_VR_STVE(name, opc2, opc3) \
|
|
|
|
GEN_HANDLER(stve##name, 0x1F, opc2, opc3, 0x00000001, PPC_ALTIVEC)
|
|
|
|
GEN_VR_LDX(lvx, 0x07, 0x03),
|
|
|
|
GEN_VR_LDX(lvxl, 0x07, 0x0B),
|
|
|
|
GEN_VR_LVE(bx, 0x07, 0x00),
|
|
|
|
GEN_VR_LVE(hx, 0x07, 0x01),
|
|
|
|
GEN_VR_LVE(wx, 0x07, 0x02),
|
|
|
|
GEN_VR_STX(svx, 0x07, 0x07),
|
|
|
|
GEN_VR_STX(svxl, 0x07, 0x0F),
|
|
|
|
GEN_VR_STVE(bx, 0x07, 0x04),
|
|
|
|
GEN_VR_STVE(hx, 0x07, 0x05),
|
|
|
|
GEN_VR_STVE(wx, 0x07, 0x06),
|
|
|
|
|
|
|
|
#undef GEN_VX_LOGICAL
|
|
|
|
#define GEN_VX_LOGICAL(name, tcg_op, opc2, opc3) \
|
|
|
|
GEN_HANDLER(name, 0x04, opc2, opc3, 0x00000000, PPC_ALTIVEC)
|
2014-02-12 22:22:58 +01:00
|
|
|
|
|
|
|
#undef GEN_VX_LOGICAL_207
|
|
|
|
#define GEN_VX_LOGICAL_207(name, tcg_op, opc2, opc3) \
|
|
|
|
GEN_HANDLER_E(name, 0x04, opc2, opc3, 0x00000000, PPC_NONE, PPC2_ALTIVEC_207)
|
|
|
|
|
2009-06-17 17:22:31 +02:00
|
|
|
GEN_VX_LOGICAL(vand, tcg_gen_and_i64, 2, 16),
|
|
|
|
GEN_VX_LOGICAL(vandc, tcg_gen_andc_i64, 2, 17),
|
|
|
|
GEN_VX_LOGICAL(vor, tcg_gen_or_i64, 2, 18),
|
|
|
|
GEN_VX_LOGICAL(vxor, tcg_gen_xor_i64, 2, 19),
|
|
|
|
GEN_VX_LOGICAL(vnor, tcg_gen_nor_i64, 2, 20),
|
2014-02-12 22:22:58 +01:00
|
|
|
GEN_VX_LOGICAL_207(veqv, tcg_gen_eqv_i64, 2, 26),
|
|
|
|
GEN_VX_LOGICAL_207(vnand, tcg_gen_nand_i64, 2, 22),
|
|
|
|
GEN_VX_LOGICAL_207(vorc, tcg_gen_orc_i64, 2, 21),
|
2009-06-17 17:22:31 +02:00
|
|
|
|
|
|
|
#undef GEN_VXFORM
|
|
|
|
#define GEN_VXFORM(name, opc2, opc3) \
|
|
|
|
GEN_HANDLER(name, 0x04, opc2, opc3, 0x00000000, PPC_ALTIVEC)
|
2014-02-12 22:22:56 +01:00
|
|
|
|
|
|
|
#undef GEN_VXFORM_207
|
|
|
|
#define GEN_VXFORM_207(name, opc2, opc3) \
|
|
|
|
GEN_HANDLER_E(name, 0x04, opc2, opc3, 0x00000000, PPC_NONE, PPC2_ALTIVEC_207)
|
|
|
|
|
2014-02-12 22:22:55 +01:00
|
|
|
#undef GEN_VXFORM_DUAL
|
|
|
|
#define GEN_VXFORM_DUAL(name0, name1, opc2, opc3, type0, type1) \
|
|
|
|
GEN_HANDLER_E(name0##_##name1, 0x4, opc2, opc3, 0x00000000, type0, type1)
|
|
|
|
|
2014-02-12 22:22:57 +01:00
|
|
|
#undef GEN_VXRFORM_DUAL
|
|
|
|
#define GEN_VXRFORM_DUAL(name0, name1, opc2, opc3, tp0, tp1) \
|
|
|
|
GEN_HANDLER_E(name0##_##name1, 0x4, opc2, opc3, 0x00000000, tp0, tp1), \
|
|
|
|
GEN_HANDLER_E(name0##_##name1, 0x4, opc2, (opc3 | 0x10), 0x00000000, tp0, tp1),
|
|
|
|
|
2009-06-17 17:22:31 +02:00
|
|
|
GEN_VXFORM(vaddubm, 0, 0),
|
|
|
|
GEN_VXFORM(vadduhm, 0, 1),
|
|
|
|
GEN_VXFORM(vadduwm, 0, 2),
|
2014-02-12 22:22:59 +01:00
|
|
|
GEN_VXFORM_207(vaddudm, 0, 3),
|
2014-02-12 22:23:16 +01:00
|
|
|
GEN_VXFORM_DUAL(vsububm, bcdadd, 0, 16, PPC_ALTIVEC, PPC_NONE),
|
|
|
|
GEN_VXFORM_DUAL(vsubuhm, bcdsub, 0, 17, PPC_ALTIVEC, PPC_NONE),
|
2009-06-17 17:22:31 +02:00
|
|
|
GEN_VXFORM(vsubuwm, 0, 18),
|
2014-02-12 22:22:59 +01:00
|
|
|
GEN_VXFORM_207(vsubudm, 0, 19),
|
2009-06-17 17:22:31 +02:00
|
|
|
GEN_VXFORM(vmaxub, 1, 0),
|
|
|
|
GEN_VXFORM(vmaxuh, 1, 1),
|
|
|
|
GEN_VXFORM(vmaxuw, 1, 2),
|
2014-02-12 22:23:05 +01:00
|
|
|
GEN_VXFORM_207(vmaxud, 1, 3),
|
2009-06-17 17:22:31 +02:00
|
|
|
GEN_VXFORM(vmaxsb, 1, 4),
|
|
|
|
GEN_VXFORM(vmaxsh, 1, 5),
|
|
|
|
GEN_VXFORM(vmaxsw, 1, 6),
|
2014-02-12 22:23:05 +01:00
|
|
|
GEN_VXFORM_207(vmaxsd, 1, 7),
|
2009-06-17 17:22:31 +02:00
|
|
|
GEN_VXFORM(vminub, 1, 8),
|
|
|
|
GEN_VXFORM(vminuh, 1, 9),
|
|
|
|
GEN_VXFORM(vminuw, 1, 10),
|
2014-02-12 22:23:05 +01:00
|
|
|
GEN_VXFORM_207(vminud, 1, 11),
|
2009-06-17 17:22:31 +02:00
|
|
|
GEN_VXFORM(vminsb, 1, 12),
|
|
|
|
GEN_VXFORM(vminsh, 1, 13),
|
|
|
|
GEN_VXFORM(vminsw, 1, 14),
|
2014-02-12 22:23:05 +01:00
|
|
|
GEN_VXFORM_207(vminsd, 1, 15),
|
2009-06-17 17:22:31 +02:00
|
|
|
GEN_VXFORM(vavgub, 1, 16),
|
|
|
|
GEN_VXFORM(vavguh, 1, 17),
|
|
|
|
GEN_VXFORM(vavguw, 1, 18),
|
|
|
|
GEN_VXFORM(vavgsb, 1, 20),
|
|
|
|
GEN_VXFORM(vavgsh, 1, 21),
|
|
|
|
GEN_VXFORM(vavgsw, 1, 22),
|
|
|
|
GEN_VXFORM(vmrghb, 6, 0),
|
|
|
|
GEN_VXFORM(vmrghh, 6, 1),
|
|
|
|
GEN_VXFORM(vmrghw, 6, 2),
|
|
|
|
GEN_VXFORM(vmrglb, 6, 4),
|
|
|
|
GEN_VXFORM(vmrglh, 6, 5),
|
|
|
|
GEN_VXFORM(vmrglw, 6, 6),
|
2014-02-12 22:23:08 +01:00
|
|
|
GEN_VXFORM_207(vmrgew, 6, 30),
|
|
|
|
GEN_VXFORM_207(vmrgow, 6, 26),
|
2009-06-17 17:22:31 +02:00
|
|
|
GEN_VXFORM(vmuloub, 4, 0),
|
|
|
|
GEN_VXFORM(vmulouh, 4, 1),
|
2014-02-12 22:23:02 +01:00
|
|
|
GEN_VXFORM_DUAL(vmulouw, vmuluwm, 4, 2, PPC_ALTIVEC, PPC_NONE),
|
2009-06-17 17:22:31 +02:00
|
|
|
GEN_VXFORM(vmulosb, 4, 4),
|
|
|
|
GEN_VXFORM(vmulosh, 4, 5),
|
2014-02-12 22:23:01 +01:00
|
|
|
GEN_VXFORM_207(vmulosw, 4, 6),
|
2009-06-17 17:22:31 +02:00
|
|
|
GEN_VXFORM(vmuleub, 4, 8),
|
|
|
|
GEN_VXFORM(vmuleuh, 4, 9),
|
2014-02-12 22:23:01 +01:00
|
|
|
GEN_VXFORM_207(vmuleuw, 4, 10),
|
2009-06-17 17:22:31 +02:00
|
|
|
GEN_VXFORM(vmulesb, 4, 12),
|
|
|
|
GEN_VXFORM(vmulesh, 4, 13),
|
2014-02-12 22:23:01 +01:00
|
|
|
GEN_VXFORM_207(vmulesw, 4, 14),
|
2009-06-17 17:22:31 +02:00
|
|
|
GEN_VXFORM(vslb, 2, 4),
|
|
|
|
GEN_VXFORM(vslh, 2, 5),
|
|
|
|
GEN_VXFORM(vslw, 2, 6),
|
2014-02-12 22:23:10 +01:00
|
|
|
GEN_VXFORM_207(vsld, 2, 23),
|
2009-06-17 17:22:31 +02:00
|
|
|
GEN_VXFORM(vsrb, 2, 8),
|
|
|
|
GEN_VXFORM(vsrh, 2, 9),
|
|
|
|
GEN_VXFORM(vsrw, 2, 10),
|
2014-02-12 22:23:10 +01:00
|
|
|
GEN_VXFORM_207(vsrd, 2, 27),
|
2009-06-17 17:22:31 +02:00
|
|
|
GEN_VXFORM(vsrab, 2, 12),
|
|
|
|
GEN_VXFORM(vsrah, 2, 13),
|
|
|
|
GEN_VXFORM(vsraw, 2, 14),
|
2014-02-12 22:23:10 +01:00
|
|
|
GEN_VXFORM_207(vsrad, 2, 15),
|
2009-06-17 17:22:31 +02:00
|
|
|
GEN_VXFORM(vslo, 6, 16),
|
|
|
|
GEN_VXFORM(vsro, 6, 17),
|
|
|
|
GEN_VXFORM(vaddcuw, 0, 6),
|
|
|
|
GEN_VXFORM(vsubcuw, 0, 22),
|
|
|
|
GEN_VXFORM(vaddubs, 0, 8),
|
|
|
|
GEN_VXFORM(vadduhs, 0, 9),
|
|
|
|
GEN_VXFORM(vadduws, 0, 10),
|
|
|
|
GEN_VXFORM(vaddsbs, 0, 12),
|
|
|
|
GEN_VXFORM(vaddshs, 0, 13),
|
|
|
|
GEN_VXFORM(vaddsws, 0, 14),
|
2014-02-12 22:23:16 +01:00
|
|
|
GEN_VXFORM_DUAL(vsububs, bcdadd, 0, 24, PPC_ALTIVEC, PPC_NONE),
|
|
|
|
GEN_VXFORM_DUAL(vsubuhs, bcdsub, 0, 25, PPC_ALTIVEC, PPC_NONE),
|
2009-06-17 17:22:31 +02:00
|
|
|
GEN_VXFORM(vsubuws, 0, 26),
|
|
|
|
GEN_VXFORM(vsubsbs, 0, 28),
|
|
|
|
GEN_VXFORM(vsubshs, 0, 29),
|
|
|
|
GEN_VXFORM(vsubsws, 0, 30),
|
2014-02-12 22:23:11 +01:00
|
|
|
GEN_VXFORM_207(vadduqm, 0, 4),
|
|
|
|
GEN_VXFORM_207(vaddcuq, 0, 5),
|
|
|
|
GEN_VXFORM_DUAL(vaddeuqm, vaddecuq, 30, 0xFF, PPC_NONE, PPC2_ALTIVEC_207),
|
|
|
|
GEN_VXFORM_207(vsubuqm, 0, 20),
|
|
|
|
GEN_VXFORM_207(vsubcuq, 0, 21),
|
|
|
|
GEN_VXFORM_DUAL(vsubeuqm, vsubecuq, 31, 0xFF, PPC_NONE, PPC2_ALTIVEC_207),
|
2009-06-17 17:22:31 +02:00
|
|
|
GEN_VXFORM(vrlb, 2, 0),
|
|
|
|
GEN_VXFORM(vrlh, 2, 1),
|
|
|
|
GEN_VXFORM(vrlw, 2, 2),
|
2014-02-12 22:23:10 +01:00
|
|
|
GEN_VXFORM_207(vrld, 2, 3),
|
2009-06-17 17:22:31 +02:00
|
|
|
GEN_VXFORM(vsl, 2, 7),
|
|
|
|
GEN_VXFORM(vsr, 2, 11),
|
|
|
|
GEN_VXFORM(vpkuhum, 7, 0),
|
|
|
|
GEN_VXFORM(vpkuwum, 7, 1),
|
2014-02-12 22:23:06 +01:00
|
|
|
GEN_VXFORM_207(vpkudum, 7, 17),
|
2009-06-17 17:22:31 +02:00
|
|
|
GEN_VXFORM(vpkuhus, 7, 2),
|
|
|
|
GEN_VXFORM(vpkuwus, 7, 3),
|
2014-02-12 22:23:06 +01:00
|
|
|
GEN_VXFORM_207(vpkudus, 7, 19),
|
2009-06-17 17:22:31 +02:00
|
|
|
GEN_VXFORM(vpkshus, 7, 4),
|
|
|
|
GEN_VXFORM(vpkswus, 7, 5),
|
2014-02-12 22:23:06 +01:00
|
|
|
GEN_VXFORM_207(vpksdus, 7, 21),
|
2009-06-17 17:22:31 +02:00
|
|
|
GEN_VXFORM(vpkshss, 7, 6),
|
|
|
|
GEN_VXFORM(vpkswss, 7, 7),
|
2014-02-12 22:23:06 +01:00
|
|
|
GEN_VXFORM_207(vpksdss, 7, 23),
|
2009-06-17 17:22:31 +02:00
|
|
|
GEN_VXFORM(vpkpx, 7, 12),
|
|
|
|
GEN_VXFORM(vsum4ubs, 4, 24),
|
|
|
|
GEN_VXFORM(vsum4sbs, 4, 28),
|
|
|
|
GEN_VXFORM(vsum4shs, 4, 25),
|
|
|
|
GEN_VXFORM(vsum2sws, 4, 26),
|
|
|
|
GEN_VXFORM(vsumsws, 4, 30),
|
|
|
|
GEN_VXFORM(vaddfp, 5, 0),
|
|
|
|
GEN_VXFORM(vsubfp, 5, 1),
|
|
|
|
GEN_VXFORM(vmaxfp, 5, 16),
|
|
|
|
GEN_VXFORM(vminfp, 5, 17),
|
|
|
|
|
|
|
|
#undef GEN_VXRFORM1
|
|
|
|
#undef GEN_VXRFORM
|
|
|
|
#define GEN_VXRFORM1(opname, name, str, opc2, opc3) \
|
|
|
|
GEN_HANDLER2(name, str, 0x4, opc2, opc3, 0x00000000, PPC_ALTIVEC),
|
|
|
|
#define GEN_VXRFORM(name, opc2, opc3) \
|
|
|
|
GEN_VXRFORM1(name, name, #name, opc2, opc3) \
|
|
|
|
GEN_VXRFORM1(name##_dot, name##_, #name ".", opc2, (opc3 | (0x1 << 4)))
|
|
|
|
GEN_VXRFORM(vcmpequb, 3, 0)
|
|
|
|
GEN_VXRFORM(vcmpequh, 3, 1)
|
|
|
|
GEN_VXRFORM(vcmpequw, 3, 2)
|
|
|
|
GEN_VXRFORM(vcmpgtsb, 3, 12)
|
|
|
|
GEN_VXRFORM(vcmpgtsh, 3, 13)
|
|
|
|
GEN_VXRFORM(vcmpgtsw, 3, 14)
|
|
|
|
GEN_VXRFORM(vcmpgtub, 3, 8)
|
|
|
|
GEN_VXRFORM(vcmpgtuh, 3, 9)
|
|
|
|
GEN_VXRFORM(vcmpgtuw, 3, 10)
|
2014-02-12 22:23:13 +01:00
|
|
|
GEN_VXRFORM_DUAL(vcmpeqfp, vcmpequd, 3, 3, PPC_ALTIVEC, PPC_NONE)
|
2009-06-17 17:22:31 +02:00
|
|
|
GEN_VXRFORM(vcmpgefp, 3, 7)
|
2014-02-12 22:23:13 +01:00
|
|
|
GEN_VXRFORM_DUAL(vcmpgtfp, vcmpgtud, 3, 11, PPC_ALTIVEC, PPC_NONE)
|
|
|
|
GEN_VXRFORM_DUAL(vcmpbfp, vcmpgtsd, 3, 15, PPC_ALTIVEC, PPC_NONE)
|
2009-06-17 17:22:31 +02:00
|
|
|
|
|
|
|
#undef GEN_VXFORM_SIMM
|
|
|
|
#define GEN_VXFORM_SIMM(name, opc2, opc3) \
|
|
|
|
GEN_HANDLER(name, 0x04, opc2, opc3, 0x00000000, PPC_ALTIVEC)
|
|
|
|
GEN_VXFORM_SIMM(vspltisb, 6, 12),
|
|
|
|
GEN_VXFORM_SIMM(vspltish, 6, 13),
|
|
|
|
GEN_VXFORM_SIMM(vspltisw, 6, 14),
|
|
|
|
|
|
|
|
#undef GEN_VXFORM_NOA
|
|
|
|
#define GEN_VXFORM_NOA(name, opc2, opc3) \
|
|
|
|
GEN_HANDLER(name, 0x04, opc2, opc3, 0x001f0000, PPC_ALTIVEC)
|
|
|
|
GEN_VXFORM_NOA(vupkhsb, 7, 8),
|
|
|
|
GEN_VXFORM_NOA(vupkhsh, 7, 9),
|
2014-02-12 22:23:07 +01:00
|
|
|
GEN_VXFORM_207(vupkhsw, 7, 25),
|
2009-06-17 17:22:31 +02:00
|
|
|
GEN_VXFORM_NOA(vupklsb, 7, 10),
|
|
|
|
GEN_VXFORM_NOA(vupklsh, 7, 11),
|
2014-02-12 22:23:07 +01:00
|
|
|
GEN_VXFORM_207(vupklsw, 7, 27),
|
2009-06-17 17:22:31 +02:00
|
|
|
GEN_VXFORM_NOA(vupkhpx, 7, 13),
|
|
|
|
GEN_VXFORM_NOA(vupklpx, 7, 15),
|
|
|
|
GEN_VXFORM_NOA(vrefp, 5, 4),
|
|
|
|
GEN_VXFORM_NOA(vrsqrtefp, 5, 5),
|
2009-02-09 12:20:50 +01:00
|
|
|
GEN_VXFORM_NOA(vexptefp, 5, 6),
|
2009-06-17 17:22:31 +02:00
|
|
|
GEN_VXFORM_NOA(vlogefp, 5, 7),
|
2014-10-31 17:06:15 +01:00
|
|
|
GEN_VXFORM_NOA(vrfim, 5, 11),
|
|
|
|
GEN_VXFORM_NOA(vrfin, 5, 8),
|
2009-06-17 17:22:31 +02:00
|
|
|
GEN_VXFORM_NOA(vrfip, 5, 10),
|
2014-10-31 17:06:15 +01:00
|
|
|
GEN_VXFORM_NOA(vrfiz, 5, 9),
|
2009-06-17 17:22:31 +02:00
|
|
|
|
|
|
|
#undef GEN_VXFORM_UIMM
|
|
|
|
#define GEN_VXFORM_UIMM(name, opc2, opc3) \
|
|
|
|
GEN_HANDLER(name, 0x04, opc2, opc3, 0x00000000, PPC_ALTIVEC)
|
|
|
|
GEN_VXFORM_UIMM(vspltb, 6, 8),
|
|
|
|
GEN_VXFORM_UIMM(vsplth, 6, 9),
|
|
|
|
GEN_VXFORM_UIMM(vspltw, 6, 10),
|
|
|
|
GEN_VXFORM_UIMM(vcfux, 5, 12),
|
|
|
|
GEN_VXFORM_UIMM(vcfsx, 5, 13),
|
|
|
|
GEN_VXFORM_UIMM(vctuxs, 5, 14),
|
|
|
|
GEN_VXFORM_UIMM(vctsxs, 5, 15),
|
|
|
|
|
|
|
|
#undef GEN_VAFORM_PAIRED
|
|
|
|
#define GEN_VAFORM_PAIRED(name0, name1, opc2) \
|
|
|
|
GEN_HANDLER(name0##_##name1, 0x04, opc2, 0xFF, 0x00000000, PPC_ALTIVEC)
|
|
|
|
GEN_VAFORM_PAIRED(vmhaddshs, vmhraddshs, 16),
|
|
|
|
GEN_VAFORM_PAIRED(vmsumubm, vmsummbm, 18),
|
|
|
|
GEN_VAFORM_PAIRED(vmsumuhm, vmsumuhs, 19),
|
|
|
|
GEN_VAFORM_PAIRED(vmsumshm, vmsumshs, 20),
|
|
|
|
GEN_VAFORM_PAIRED(vsel, vperm, 21),
|
|
|
|
GEN_VAFORM_PAIRED(vmaddfp, vnmsubfp, 23),
|
|
|
|
|
2014-02-12 22:23:04 +01:00
|
|
|
GEN_VXFORM_DUAL(vclzb, vpopcntb, 1, 28, PPC_NONE, PPC2_ALTIVEC_207),
|
|
|
|
GEN_VXFORM_DUAL(vclzh, vpopcnth, 1, 29, PPC_NONE, PPC2_ALTIVEC_207),
|
|
|
|
GEN_VXFORM_DUAL(vclzw, vpopcntw, 1, 30, PPC_NONE, PPC2_ALTIVEC_207),
|
|
|
|
GEN_VXFORM_DUAL(vclzd, vpopcntd, 1, 31, PPC_NONE, PPC2_ALTIVEC_207),
|
|
|
|
|
2014-02-12 22:23:12 +01:00
|
|
|
GEN_VXFORM_207(vbpermq, 6, 21),
|
2014-02-12 22:23:14 +01:00
|
|
|
GEN_VXFORM_207(vgbbd, 6, 20),
|
2014-02-12 22:23:15 +01:00
|
|
|
GEN_VXFORM_207(vpmsumb, 4, 16),
|
|
|
|
GEN_VXFORM_207(vpmsumh, 4, 17),
|
|
|
|
GEN_VXFORM_207(vpmsumw, 4, 18),
|
|
|
|
GEN_VXFORM_207(vpmsumd, 4, 19),
|
2014-02-12 22:23:03 +01:00
|
|
|
|
2014-02-12 22:23:17 +01:00
|
|
|
GEN_VXFORM_207(vsbox, 4, 23),
|
|
|
|
|
|
|
|
GEN_VXFORM_DUAL(vcipher, vcipherlast, 4, 20, PPC_NONE, PPC2_ALTIVEC_207),
|
|
|
|
GEN_VXFORM_DUAL(vncipher, vncipherlast, 4, 21, PPC_NONE, PPC2_ALTIVEC_207),
|
|
|
|
|
2014-02-12 22:23:18 +01:00
|
|
|
GEN_VXFORM_207(vshasigmaw, 1, 26),
|
|
|
|
GEN_VXFORM_207(vshasigmad, 1, 27),
|
|
|
|
|
2014-02-12 22:23:19 +01:00
|
|
|
GEN_VXFORM_DUAL(vsldoi, vpermxor, 22, 0xFF, PPC_ALTIVEC, PPC_NONE),
|
|
|
|
|
2013-11-01 14:21:12 +01:00
|
|
|
GEN_HANDLER_E(lxsdx, 0x1F, 0x0C, 0x12, 0, PPC_NONE, PPC2_VSX),
|
2014-01-15 15:10:30 +01:00
|
|
|
GEN_HANDLER_E(lxsiwax, 0x1F, 0x0C, 0x02, 0, PPC_NONE, PPC2_VSX207),
|
|
|
|
GEN_HANDLER_E(lxsiwzx, 0x1F, 0x0C, 0x00, 0, PPC_NONE, PPC2_VSX207),
|
|
|
|
GEN_HANDLER_E(lxsspx, 0x1F, 0x0C, 0x10, 0, PPC_NONE, PPC2_VSX207),
|
2013-10-22 13:08:32 +02:00
|
|
|
GEN_HANDLER_E(lxvd2x, 0x1F, 0x0C, 0x1A, 0, PPC_NONE, PPC2_VSX),
|
2013-11-01 14:21:13 +01:00
|
|
|
GEN_HANDLER_E(lxvdsx, 0x1F, 0x0C, 0x0A, 0, PPC_NONE, PPC2_VSX),
|
2013-11-01 14:21:14 +01:00
|
|
|
GEN_HANDLER_E(lxvw4x, 0x1F, 0x0C, 0x18, 0, PPC_NONE, PPC2_VSX),
|
2013-10-22 13:08:32 +02:00
|
|
|
|
2013-11-01 14:21:15 +01:00
|
|
|
GEN_HANDLER_E(stxsdx, 0x1F, 0xC, 0x16, 0, PPC_NONE, PPC2_VSX),
|
2014-01-15 15:10:32 +01:00
|
|
|
GEN_HANDLER_E(stxsiwx, 0x1F, 0xC, 0x04, 0, PPC_NONE, PPC2_VSX207),
|
|
|
|
GEN_HANDLER_E(stxsspx, 0x1F, 0xC, 0x14, 0, PPC_NONE, PPC2_VSX207),
|
2013-10-22 13:09:00 +02:00
|
|
|
GEN_HANDLER_E(stxvd2x, 0x1F, 0xC, 0x1E, 0, PPC_NONE, PPC2_VSX),
|
2013-11-01 14:21:16 +01:00
|
|
|
GEN_HANDLER_E(stxvw4x, 0x1F, 0xC, 0x1C, 0, PPC_NONE, PPC2_VSX),
|
2013-10-22 13:09:00 +02:00
|
|
|
|
2014-01-15 15:10:42 +01:00
|
|
|
GEN_HANDLER_E(mfvsrwz, 0x1F, 0x13, 0x03, 0x0000F800, PPC_NONE, PPC2_VSX207),
|
|
|
|
GEN_HANDLER_E(mtvsrwa, 0x1F, 0x13, 0x06, 0x0000F800, PPC_NONE, PPC2_VSX207),
|
|
|
|
GEN_HANDLER_E(mtvsrwz, 0x1F, 0x13, 0x07, 0x0000F800, PPC_NONE, PPC2_VSX207),
|
|
|
|
#if defined(TARGET_PPC64)
|
|
|
|
GEN_HANDLER_E(mfvsrd, 0x1F, 0x13, 0x01, 0x0000F800, PPC_NONE, PPC2_VSX207),
|
|
|
|
GEN_HANDLER_E(mtvsrd, 0x1F, 0x13, 0x05, 0x0000F800, PPC_NONE, PPC2_VSX207),
|
|
|
|
#endif
|
|
|
|
|
2013-11-01 14:21:17 +01:00
|
|
|
#undef GEN_XX2FORM
|
|
|
|
#define GEN_XX2FORM(name, opc2, opc3, fl2) \
|
|
|
|
GEN_HANDLER2_E(name, #name, 0x3C, opc2 | 0, opc3, 0, PPC_NONE, fl2), \
|
|
|
|
GEN_HANDLER2_E(name, #name, 0x3C, opc2 | 1, opc3, 0, PPC_NONE, fl2)
|
|
|
|
|
|
|
|
#undef GEN_XX3FORM
|
|
|
|
#define GEN_XX3FORM(name, opc2, opc3, fl2) \
|
|
|
|
GEN_HANDLER2_E(name, #name, 0x3C, opc2 | 0, opc3, 0, PPC_NONE, fl2), \
|
|
|
|
GEN_HANDLER2_E(name, #name, 0x3C, opc2 | 1, opc3, 0, PPC_NONE, fl2), \
|
|
|
|
GEN_HANDLER2_E(name, #name, 0x3C, opc2 | 2, opc3, 0, PPC_NONE, fl2), \
|
|
|
|
GEN_HANDLER2_E(name, #name, 0x3C, opc2 | 3, opc3, 0, PPC_NONE, fl2)
|
|
|
|
|
2015-09-13 23:03:45 +02:00
|
|
|
#undef GEN_XX2IFORM
|
|
|
|
#define GEN_XX2IFORM(name, opc2, opc3, fl2) \
|
|
|
|
GEN_HANDLER2_E(name, #name, 0x3C, opc2 | 0, opc3, 1, PPC_NONE, fl2), \
|
|
|
|
GEN_HANDLER2_E(name, #name, 0x3C, opc2 | 1, opc3, 1, PPC_NONE, fl2), \
|
|
|
|
GEN_HANDLER2_E(name, #name, 0x3C, opc2 | 2, opc3, 1, PPC_NONE, fl2), \
|
|
|
|
GEN_HANDLER2_E(name, #name, 0x3C, opc2 | 3, opc3, 1, PPC_NONE, fl2)
|
|
|
|
|
2014-01-02 23:21:32 +01:00
|
|
|
#undef GEN_XX3_RC_FORM
|
|
|
|
#define GEN_XX3_RC_FORM(name, opc2, opc3, fl2) \
|
|
|
|
GEN_HANDLER2_E(name, #name, 0x3C, opc2 | 0x00, opc3 | 0x00, 0, PPC_NONE, fl2), \
|
|
|
|
GEN_HANDLER2_E(name, #name, 0x3C, opc2 | 0x01, opc3 | 0x00, 0, PPC_NONE, fl2), \
|
|
|
|
GEN_HANDLER2_E(name, #name, 0x3C, opc2 | 0x02, opc3 | 0x00, 0, PPC_NONE, fl2), \
|
|
|
|
GEN_HANDLER2_E(name, #name, 0x3C, opc2 | 0x03, opc3 | 0x00, 0, PPC_NONE, fl2), \
|
|
|
|
GEN_HANDLER2_E(name, #name, 0x3C, opc2 | 0x00, opc3 | 0x10, 0, PPC_NONE, fl2), \
|
|
|
|
GEN_HANDLER2_E(name, #name, 0x3C, opc2 | 0x01, opc3 | 0x10, 0, PPC_NONE, fl2), \
|
|
|
|
GEN_HANDLER2_E(name, #name, 0x3C, opc2 | 0x02, opc3 | 0x10, 0, PPC_NONE, fl2), \
|
|
|
|
GEN_HANDLER2_E(name, #name, 0x3C, opc2 | 0x03, opc3 | 0x10, 0, PPC_NONE, fl2)
|
|
|
|
|
2013-10-22 13:09:35 +02:00
|
|
|
#undef GEN_XX3FORM_DM
|
|
|
|
#define GEN_XX3FORM_DM(name, opc2, opc3) \
|
|
|
|
GEN_HANDLER2_E(name, #name, 0x3C, opc2|0x00, opc3|0x00, 0, PPC_NONE, PPC2_VSX),\
|
|
|
|
GEN_HANDLER2_E(name, #name, 0x3C, opc2|0x01, opc3|0x00, 0, PPC_NONE, PPC2_VSX),\
|
|
|
|
GEN_HANDLER2_E(name, #name, 0x3C, opc2|0x02, opc3|0x00, 0, PPC_NONE, PPC2_VSX),\
|
|
|
|
GEN_HANDLER2_E(name, #name, 0x3C, opc2|0x03, opc3|0x00, 0, PPC_NONE, PPC2_VSX),\
|
|
|
|
GEN_HANDLER2_E(name, #name, 0x3C, opc2|0x00, opc3|0x04, 0, PPC_NONE, PPC2_VSX),\
|
|
|
|
GEN_HANDLER2_E(name, #name, 0x3C, opc2|0x01, opc3|0x04, 0, PPC_NONE, PPC2_VSX),\
|
|
|
|
GEN_HANDLER2_E(name, #name, 0x3C, opc2|0x02, opc3|0x04, 0, PPC_NONE, PPC2_VSX),\
|
|
|
|
GEN_HANDLER2_E(name, #name, 0x3C, opc2|0x03, opc3|0x04, 0, PPC_NONE, PPC2_VSX),\
|
|
|
|
GEN_HANDLER2_E(name, #name, 0x3C, opc2|0x00, opc3|0x08, 0, PPC_NONE, PPC2_VSX),\
|
|
|
|
GEN_HANDLER2_E(name, #name, 0x3C, opc2|0x01, opc3|0x08, 0, PPC_NONE, PPC2_VSX),\
|
|
|
|
GEN_HANDLER2_E(name, #name, 0x3C, opc2|0x02, opc3|0x08, 0, PPC_NONE, PPC2_VSX),\
|
|
|
|
GEN_HANDLER2_E(name, #name, 0x3C, opc2|0x03, opc3|0x08, 0, PPC_NONE, PPC2_VSX),\
|
|
|
|
GEN_HANDLER2_E(name, #name, 0x3C, opc2|0x00, opc3|0x0C, 0, PPC_NONE, PPC2_VSX),\
|
|
|
|
GEN_HANDLER2_E(name, #name, 0x3C, opc2|0x01, opc3|0x0C, 0, PPC_NONE, PPC2_VSX),\
|
|
|
|
GEN_HANDLER2_E(name, #name, 0x3C, opc2|0x02, opc3|0x0C, 0, PPC_NONE, PPC2_VSX),\
|
|
|
|
GEN_HANDLER2_E(name, #name, 0x3C, opc2|0x03, opc3|0x0C, 0, PPC_NONE, PPC2_VSX)
|
|
|
|
|
2013-11-01 14:21:17 +01:00
|
|
|
GEN_XX2FORM(xsabsdp, 0x12, 0x15, PPC2_VSX),
|
|
|
|
GEN_XX2FORM(xsnabsdp, 0x12, 0x16, PPC2_VSX),
|
|
|
|
GEN_XX2FORM(xsnegdp, 0x12, 0x17, PPC2_VSX),
|
|
|
|
GEN_XX3FORM(xscpsgndp, 0x00, 0x16, PPC2_VSX),
|
|
|
|
|
2013-11-01 14:21:18 +01:00
|
|
|
GEN_XX2FORM(xvabsdp, 0x12, 0x1D, PPC2_VSX),
|
|
|
|
GEN_XX2FORM(xvnabsdp, 0x12, 0x1E, PPC2_VSX),
|
|
|
|
GEN_XX2FORM(xvnegdp, 0x12, 0x1F, PPC2_VSX),
|
|
|
|
GEN_XX3FORM(xvcpsgndp, 0x00, 0x1E, PPC2_VSX),
|
|
|
|
GEN_XX2FORM(xvabssp, 0x12, 0x19, PPC2_VSX),
|
|
|
|
GEN_XX2FORM(xvnabssp, 0x12, 0x1A, PPC2_VSX),
|
|
|
|
GEN_XX2FORM(xvnegsp, 0x12, 0x1B, PPC2_VSX),
|
|
|
|
GEN_XX3FORM(xvcpsgnsp, 0x00, 0x1A, PPC2_VSX),
|
2013-11-01 14:21:19 +01:00
|
|
|
|
2014-01-02 23:21:21 +01:00
|
|
|
GEN_XX3FORM(xsadddp, 0x00, 0x04, PPC2_VSX),
|
|
|
|
GEN_XX3FORM(xssubdp, 0x00, 0x05, PPC2_VSX),
|
2014-01-02 23:21:22 +01:00
|
|
|
GEN_XX3FORM(xsmuldp, 0x00, 0x06, PPC2_VSX),
|
2014-01-02 23:21:23 +01:00
|
|
|
GEN_XX3FORM(xsdivdp, 0x00, 0x07, PPC2_VSX),
|
2014-01-02 23:21:24 +01:00
|
|
|
GEN_XX2FORM(xsredp, 0x14, 0x05, PPC2_VSX),
|
2014-01-02 23:21:25 +01:00
|
|
|
GEN_XX2FORM(xssqrtdp, 0x16, 0x04, PPC2_VSX),
|
2014-01-02 23:21:26 +01:00
|
|
|
GEN_XX2FORM(xsrsqrtedp, 0x14, 0x04, PPC2_VSX),
|
2014-01-02 23:21:27 +01:00
|
|
|
GEN_XX3FORM(xstdivdp, 0x14, 0x07, PPC2_VSX),
|
2014-01-02 23:21:28 +01:00
|
|
|
GEN_XX2FORM(xstsqrtdp, 0x14, 0x06, PPC2_VSX),
|
target-ppc: Add VSX ISA2.06 Multiply Add Instructions
This patch adds the VSX floating point multiply/add instructions
defined by V2.06 of the PowerPC ISA:
- xsmaddadp, xvmaddadp, xvmaddasp
- xsmaddmdp, xvmaddmdp, xvmaddmsp
- xsmsubadp, xvmsubadp, xvmsubasp
- xsmsubmdp, xvmsubmdp, xvmsubmsp
- xsnmaddadp, xvnmaddadp, xvnmaddasp
- xsnmaddmdp, xvnmaddmdp, xvnmaddmsp
- xsnmsubadp, xvnmsubadp, xvnmsubasp
- xsnmsubmdp, xvnmsubmdp, xvnmsubmsp
Signed-off-by: Tom Musta <tommusta@gmail.com>
Reviewed-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Alexander Graf <agraf@suse.de>
2014-01-02 23:21:29 +01:00
|
|
|
GEN_XX3FORM(xsmaddadp, 0x04, 0x04, PPC2_VSX),
|
|
|
|
GEN_XX3FORM(xsmaddmdp, 0x04, 0x05, PPC2_VSX),
|
|
|
|
GEN_XX3FORM(xsmsubadp, 0x04, 0x06, PPC2_VSX),
|
|
|
|
GEN_XX3FORM(xsmsubmdp, 0x04, 0x07, PPC2_VSX),
|
|
|
|
GEN_XX3FORM(xsnmaddadp, 0x04, 0x14, PPC2_VSX),
|
|
|
|
GEN_XX3FORM(xsnmaddmdp, 0x04, 0x15, PPC2_VSX),
|
|
|
|
GEN_XX3FORM(xsnmsubadp, 0x04, 0x16, PPC2_VSX),
|
|
|
|
GEN_XX3FORM(xsnmsubmdp, 0x04, 0x17, PPC2_VSX),
|
2015-09-13 23:03:45 +02:00
|
|
|
GEN_XX2IFORM(xscmpodp, 0x0C, 0x05, PPC2_VSX),
|
|
|
|
GEN_XX2IFORM(xscmpudp, 0x0C, 0x04, PPC2_VSX),
|
2014-01-02 23:21:31 +01:00
|
|
|
GEN_XX3FORM(xsmaxdp, 0x00, 0x14, PPC2_VSX),
|
|
|
|
GEN_XX3FORM(xsmindp, 0x00, 0x15, PPC2_VSX),
|
2014-01-02 23:21:33 +01:00
|
|
|
GEN_XX2FORM(xscvdpsp, 0x12, 0x10, PPC2_VSX),
|
2014-01-15 15:10:45 +01:00
|
|
|
GEN_XX2FORM(xscvdpspn, 0x16, 0x10, PPC2_VSX207),
|
2014-01-02 23:21:33 +01:00
|
|
|
GEN_XX2FORM(xscvspdp, 0x12, 0x14, PPC2_VSX),
|
2014-01-15 15:10:45 +01:00
|
|
|
GEN_XX2FORM(xscvspdpn, 0x16, 0x14, PPC2_VSX207),
|
target-ppc: Add VSX ISA2.06 Integer Conversion Instructions
This patch adds the VSX Integer Conversion instructions defined by
V2.06 of the PowerPC ISA:
- xscvdpsxds, xscvdpsxws, xscvdpuxds, xscvdpuxws
- xvcvdpsxds, xvcvdpsxws, xvcvdpuxds, xvcvdpuxws
- xvcvspsxds, xvcvspsxws, xvcvspuxds, xvcvspuxws
- xscvsxddp, xscvuxddp
- xvcvsxddp, xscvsxwdp, xvcvuxddp, xvcvuxwdp
- xvcvsxdsp, xscvsxwsp, xvcvuxdsp, xvcvuxwsp
Signed-off-by: Tom Musta <tommusta@gmail.com>
Reviewed-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Alexander Graf <agraf@suse.de>
2014-01-02 23:21:34 +01:00
|
|
|
GEN_XX2FORM(xscvdpsxds, 0x10, 0x15, PPC2_VSX),
|
|
|
|
GEN_XX2FORM(xscvdpsxws, 0x10, 0x05, PPC2_VSX),
|
|
|
|
GEN_XX2FORM(xscvdpuxds, 0x10, 0x14, PPC2_VSX),
|
|
|
|
GEN_XX2FORM(xscvdpuxws, 0x10, 0x04, PPC2_VSX),
|
|
|
|
GEN_XX2FORM(xscvsxddp, 0x10, 0x17, PPC2_VSX),
|
|
|
|
GEN_XX2FORM(xscvuxddp, 0x10, 0x16, PPC2_VSX),
|
target-ppc: Add VSX Rounding Instructions
This patch adds the VSX Round to Floating Point Integer instructions:
- xsrdpi, xsrdpic, xsrdpim, xsrdpip, xsrdpiz
- xvrdpi, xvrdpic, xvrdpim, xvrdpip, xvrdpiz
- xvrspi, xvrspic, xvrspim, xvrspip, xvrspiz
Signed-off-by: Tom Musta <tommusta@gmail.com>
Reviewed-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Alexander Graf <agraf@suse.de>
2014-01-02 23:21:35 +01:00
|
|
|
GEN_XX2FORM(xsrdpi, 0x12, 0x04, PPC2_VSX),
|
|
|
|
GEN_XX2FORM(xsrdpic, 0x16, 0x06, PPC2_VSX),
|
|
|
|
GEN_XX2FORM(xsrdpim, 0x12, 0x07, PPC2_VSX),
|
|
|
|
GEN_XX2FORM(xsrdpip, 0x12, 0x06, PPC2_VSX),
|
|
|
|
GEN_XX2FORM(xsrdpiz, 0x12, 0x05, PPC2_VSX),
|
2014-01-02 23:21:21 +01:00
|
|
|
|
2014-01-15 15:10:33 +01:00
|
|
|
GEN_XX3FORM(xsaddsp, 0x00, 0x00, PPC2_VSX207),
|
|
|
|
GEN_XX3FORM(xssubsp, 0x00, 0x01, PPC2_VSX207),
|
2014-01-15 15:10:34 +01:00
|
|
|
GEN_XX3FORM(xsmulsp, 0x00, 0x02, PPC2_VSX207),
|
2014-01-15 15:10:35 +01:00
|
|
|
GEN_XX3FORM(xsdivsp, 0x00, 0x03, PPC2_VSX207),
|
2014-01-15 15:10:36 +01:00
|
|
|
GEN_XX2FORM(xsresp, 0x14, 0x01, PPC2_VSX207),
|
2014-01-15 15:10:44 +01:00
|
|
|
GEN_XX2FORM(xsrsp, 0x12, 0x11, PPC2_VSX207),
|
2014-01-15 15:10:37 +01:00
|
|
|
GEN_XX2FORM(xssqrtsp, 0x16, 0x00, PPC2_VSX207),
|
2014-01-15 15:10:38 +01:00
|
|
|
GEN_XX2FORM(xsrsqrtesp, 0x14, 0x00, PPC2_VSX207),
|
2014-01-15 15:10:39 +01:00
|
|
|
GEN_XX3FORM(xsmaddasp, 0x04, 0x00, PPC2_VSX207),
|
|
|
|
GEN_XX3FORM(xsmaddmsp, 0x04, 0x01, PPC2_VSX207),
|
|
|
|
GEN_XX3FORM(xsmsubasp, 0x04, 0x02, PPC2_VSX207),
|
|
|
|
GEN_XX3FORM(xsmsubmsp, 0x04, 0x03, PPC2_VSX207),
|
|
|
|
GEN_XX3FORM(xsnmaddasp, 0x04, 0x10, PPC2_VSX207),
|
|
|
|
GEN_XX3FORM(xsnmaddmsp, 0x04, 0x11, PPC2_VSX207),
|
|
|
|
GEN_XX3FORM(xsnmsubasp, 0x04, 0x12, PPC2_VSX207),
|
|
|
|
GEN_XX3FORM(xsnmsubmsp, 0x04, 0x13, PPC2_VSX207),
|
2014-01-15 15:10:40 +01:00
|
|
|
GEN_XX2FORM(xscvsxdsp, 0x10, 0x13, PPC2_VSX207),
|
|
|
|
GEN_XX2FORM(xscvuxdsp, 0x10, 0x12, PPC2_VSX207),
|
2014-01-15 15:10:33 +01:00
|
|
|
|
2014-01-02 23:21:21 +01:00
|
|
|
GEN_XX3FORM(xvadddp, 0x00, 0x0C, PPC2_VSX),
|
|
|
|
GEN_XX3FORM(xvsubdp, 0x00, 0x0D, PPC2_VSX),
|
2014-01-02 23:21:22 +01:00
|
|
|
GEN_XX3FORM(xvmuldp, 0x00, 0x0E, PPC2_VSX),
|
2014-01-02 23:21:23 +01:00
|
|
|
GEN_XX3FORM(xvdivdp, 0x00, 0x0F, PPC2_VSX),
|
2014-01-02 23:21:24 +01:00
|
|
|
GEN_XX2FORM(xvredp, 0x14, 0x0D, PPC2_VSX),
|
2014-01-02 23:21:25 +01:00
|
|
|
GEN_XX2FORM(xvsqrtdp, 0x16, 0x0C, PPC2_VSX),
|
2014-01-02 23:21:26 +01:00
|
|
|
GEN_XX2FORM(xvrsqrtedp, 0x14, 0x0C, PPC2_VSX),
|
2014-01-02 23:21:27 +01:00
|
|
|
GEN_XX3FORM(xvtdivdp, 0x14, 0x0F, PPC2_VSX),
|
2014-01-02 23:21:28 +01:00
|
|
|
GEN_XX2FORM(xvtsqrtdp, 0x14, 0x0E, PPC2_VSX),
|
target-ppc: Add VSX ISA2.06 Multiply Add Instructions
This patch adds the VSX floating point multiply/add instructions
defined by V2.06 of the PowerPC ISA:
- xsmaddadp, xvmaddadp, xvmaddasp
- xsmaddmdp, xvmaddmdp, xvmaddmsp
- xsmsubadp, xvmsubadp, xvmsubasp
- xsmsubmdp, xvmsubmdp, xvmsubmsp
- xsnmaddadp, xvnmaddadp, xvnmaddasp
- xsnmaddmdp, xvnmaddmdp, xvnmaddmsp
- xsnmsubadp, xvnmsubadp, xvnmsubasp
- xsnmsubmdp, xvnmsubmdp, xvnmsubmsp
Signed-off-by: Tom Musta <tommusta@gmail.com>
Reviewed-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Alexander Graf <agraf@suse.de>
2014-01-02 23:21:29 +01:00
|
|
|
GEN_XX3FORM(xvmaddadp, 0x04, 0x0C, PPC2_VSX),
|
|
|
|
GEN_XX3FORM(xvmaddmdp, 0x04, 0x0D, PPC2_VSX),
|
|
|
|
GEN_XX3FORM(xvmsubadp, 0x04, 0x0E, PPC2_VSX),
|
|
|
|
GEN_XX3FORM(xvmsubmdp, 0x04, 0x0F, PPC2_VSX),
|
|
|
|
GEN_XX3FORM(xvnmaddadp, 0x04, 0x1C, PPC2_VSX),
|
|
|
|
GEN_XX3FORM(xvnmaddmdp, 0x04, 0x1D, PPC2_VSX),
|
|
|
|
GEN_XX3FORM(xvnmsubadp, 0x04, 0x1E, PPC2_VSX),
|
|
|
|
GEN_XX3FORM(xvnmsubmdp, 0x04, 0x1F, PPC2_VSX),
|
2014-01-02 23:21:31 +01:00
|
|
|
GEN_XX3FORM(xvmaxdp, 0x00, 0x1C, PPC2_VSX),
|
|
|
|
GEN_XX3FORM(xvmindp, 0x00, 0x1D, PPC2_VSX),
|
2014-01-02 23:21:32 +01:00
|
|
|
GEN_XX3_RC_FORM(xvcmpeqdp, 0x0C, 0x0C, PPC2_VSX),
|
|
|
|
GEN_XX3_RC_FORM(xvcmpgtdp, 0x0C, 0x0D, PPC2_VSX),
|
|
|
|
GEN_XX3_RC_FORM(xvcmpgedp, 0x0C, 0x0E, PPC2_VSX),
|
2014-01-02 23:21:33 +01:00
|
|
|
GEN_XX2FORM(xvcvdpsp, 0x12, 0x18, PPC2_VSX),
|
target-ppc: Add VSX ISA2.06 Integer Conversion Instructions
This patch adds the VSX Integer Conversion instructions defined by
V2.06 of the PowerPC ISA:
- xscvdpsxds, xscvdpsxws, xscvdpuxds, xscvdpuxws
- xvcvdpsxds, xvcvdpsxws, xvcvdpuxds, xvcvdpuxws
- xvcvspsxds, xvcvspsxws, xvcvspuxds, xvcvspuxws
- xscvsxddp, xscvuxddp
- xvcvsxddp, xscvsxwdp, xvcvuxddp, xvcvuxwdp
- xvcvsxdsp, xscvsxwsp, xvcvuxdsp, xvcvuxwsp
Signed-off-by: Tom Musta <tommusta@gmail.com>
Reviewed-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Alexander Graf <agraf@suse.de>
2014-01-02 23:21:34 +01:00
|
|
|
GEN_XX2FORM(xvcvdpsxds, 0x10, 0x1D, PPC2_VSX),
|
|
|
|
GEN_XX2FORM(xvcvdpsxws, 0x10, 0x0D, PPC2_VSX),
|
|
|
|
GEN_XX2FORM(xvcvdpuxds, 0x10, 0x1C, PPC2_VSX),
|
|
|
|
GEN_XX2FORM(xvcvdpuxws, 0x10, 0x0C, PPC2_VSX),
|
|
|
|
GEN_XX2FORM(xvcvsxddp, 0x10, 0x1F, PPC2_VSX),
|
|
|
|
GEN_XX2FORM(xvcvuxddp, 0x10, 0x1E, PPC2_VSX),
|
|
|
|
GEN_XX2FORM(xvcvsxwdp, 0x10, 0x0F, PPC2_VSX),
|
|
|
|
GEN_XX2FORM(xvcvuxwdp, 0x10, 0x0E, PPC2_VSX),
|
target-ppc: Add VSX Rounding Instructions
This patch adds the VSX Round to Floating Point Integer instructions:
- xsrdpi, xsrdpic, xsrdpim, xsrdpip, xsrdpiz
- xvrdpi, xvrdpic, xvrdpim, xvrdpip, xvrdpiz
- xvrspi, xvrspic, xvrspim, xvrspip, xvrspiz
Signed-off-by: Tom Musta <tommusta@gmail.com>
Reviewed-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Alexander Graf <agraf@suse.de>
2014-01-02 23:21:35 +01:00
|
|
|
GEN_XX2FORM(xvrdpi, 0x12, 0x0C, PPC2_VSX),
|
|
|
|
GEN_XX2FORM(xvrdpic, 0x16, 0x0E, PPC2_VSX),
|
|
|
|
GEN_XX2FORM(xvrdpim, 0x12, 0x0F, PPC2_VSX),
|
|
|
|
GEN_XX2FORM(xvrdpip, 0x12, 0x0E, PPC2_VSX),
|
|
|
|
GEN_XX2FORM(xvrdpiz, 0x12, 0x0D, PPC2_VSX),
|
2014-01-02 23:21:21 +01:00
|
|
|
|
|
|
|
GEN_XX3FORM(xvaddsp, 0x00, 0x08, PPC2_VSX),
|
|
|
|
GEN_XX3FORM(xvsubsp, 0x00, 0x09, PPC2_VSX),
|
2014-01-02 23:21:22 +01:00
|
|
|
GEN_XX3FORM(xvmulsp, 0x00, 0x0A, PPC2_VSX),
|
2014-01-02 23:21:23 +01:00
|
|
|
GEN_XX3FORM(xvdivsp, 0x00, 0x0B, PPC2_VSX),
|
2014-01-02 23:21:24 +01:00
|
|
|
GEN_XX2FORM(xvresp, 0x14, 0x09, PPC2_VSX),
|
2014-01-02 23:21:25 +01:00
|
|
|
GEN_XX2FORM(xvsqrtsp, 0x16, 0x08, PPC2_VSX),
|
2014-01-02 23:21:26 +01:00
|
|
|
GEN_XX2FORM(xvrsqrtesp, 0x14, 0x08, PPC2_VSX),
|
2014-01-02 23:21:27 +01:00
|
|
|
GEN_XX3FORM(xvtdivsp, 0x14, 0x0B, PPC2_VSX),
|
2014-01-02 23:21:28 +01:00
|
|
|
GEN_XX2FORM(xvtsqrtsp, 0x14, 0x0A, PPC2_VSX),
|
target-ppc: Add VSX ISA2.06 Multiply Add Instructions
This patch adds the VSX floating point multiply/add instructions
defined by V2.06 of the PowerPC ISA:
- xsmaddadp, xvmaddadp, xvmaddasp
- xsmaddmdp, xvmaddmdp, xvmaddmsp
- xsmsubadp, xvmsubadp, xvmsubasp
- xsmsubmdp, xvmsubmdp, xvmsubmsp
- xsnmaddadp, xvnmaddadp, xvnmaddasp
- xsnmaddmdp, xvnmaddmdp, xvnmaddmsp
- xsnmsubadp, xvnmsubadp, xvnmsubasp
- xsnmsubmdp, xvnmsubmdp, xvnmsubmsp
Signed-off-by: Tom Musta <tommusta@gmail.com>
Reviewed-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Alexander Graf <agraf@suse.de>
2014-01-02 23:21:29 +01:00
|
|
|
GEN_XX3FORM(xvmaddasp, 0x04, 0x08, PPC2_VSX),
|
|
|
|
GEN_XX3FORM(xvmaddmsp, 0x04, 0x09, PPC2_VSX),
|
|
|
|
GEN_XX3FORM(xvmsubasp, 0x04, 0x0A, PPC2_VSX),
|
|
|
|
GEN_XX3FORM(xvmsubmsp, 0x04, 0x0B, PPC2_VSX),
|
|
|
|
GEN_XX3FORM(xvnmaddasp, 0x04, 0x18, PPC2_VSX),
|
|
|
|
GEN_XX3FORM(xvnmaddmsp, 0x04, 0x19, PPC2_VSX),
|
|
|
|
GEN_XX3FORM(xvnmsubasp, 0x04, 0x1A, PPC2_VSX),
|
|
|
|
GEN_XX3FORM(xvnmsubmsp, 0x04, 0x1B, PPC2_VSX),
|
2014-01-02 23:21:31 +01:00
|
|
|
GEN_XX3FORM(xvmaxsp, 0x00, 0x18, PPC2_VSX),
|
|
|
|
GEN_XX3FORM(xvminsp, 0x00, 0x19, PPC2_VSX),
|
2014-01-02 23:21:32 +01:00
|
|
|
GEN_XX3_RC_FORM(xvcmpeqsp, 0x0C, 0x08, PPC2_VSX),
|
|
|
|
GEN_XX3_RC_FORM(xvcmpgtsp, 0x0C, 0x09, PPC2_VSX),
|
|
|
|
GEN_XX3_RC_FORM(xvcmpgesp, 0x0C, 0x0A, PPC2_VSX),
|
2014-01-02 23:21:33 +01:00
|
|
|
GEN_XX2FORM(xvcvspdp, 0x12, 0x1C, PPC2_VSX),
|
target-ppc: Add VSX ISA2.06 Integer Conversion Instructions
This patch adds the VSX Integer Conversion instructions defined by
V2.06 of the PowerPC ISA:
- xscvdpsxds, xscvdpsxws, xscvdpuxds, xscvdpuxws
- xvcvdpsxds, xvcvdpsxws, xvcvdpuxds, xvcvdpuxws
- xvcvspsxds, xvcvspsxws, xvcvspuxds, xvcvspuxws
- xscvsxddp, xscvuxddp
- xvcvsxddp, xscvsxwdp, xvcvuxddp, xvcvuxwdp
- xvcvsxdsp, xscvsxwsp, xvcvuxdsp, xvcvuxwsp
Signed-off-by: Tom Musta <tommusta@gmail.com>
Reviewed-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Alexander Graf <agraf@suse.de>
2014-01-02 23:21:34 +01:00
|
|
|
GEN_XX2FORM(xvcvspsxds, 0x10, 0x19, PPC2_VSX),
|
|
|
|
GEN_XX2FORM(xvcvspsxws, 0x10, 0x09, PPC2_VSX),
|
|
|
|
GEN_XX2FORM(xvcvspuxds, 0x10, 0x18, PPC2_VSX),
|
|
|
|
GEN_XX2FORM(xvcvspuxws, 0x10, 0x08, PPC2_VSX),
|
|
|
|
GEN_XX2FORM(xvcvsxdsp, 0x10, 0x1B, PPC2_VSX),
|
|
|
|
GEN_XX2FORM(xvcvuxdsp, 0x10, 0x1A, PPC2_VSX),
|
|
|
|
GEN_XX2FORM(xvcvsxwsp, 0x10, 0x0B, PPC2_VSX),
|
|
|
|
GEN_XX2FORM(xvcvuxwsp, 0x10, 0x0A, PPC2_VSX),
|
target-ppc: Add VSX Rounding Instructions
This patch adds the VSX Round to Floating Point Integer instructions:
- xsrdpi, xsrdpic, xsrdpim, xsrdpip, xsrdpiz
- xvrdpi, xvrdpic, xvrdpim, xvrdpip, xvrdpiz
- xvrspi, xvrspic, xvrspim, xvrspip, xvrspiz
Signed-off-by: Tom Musta <tommusta@gmail.com>
Reviewed-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Alexander Graf <agraf@suse.de>
2014-01-02 23:21:35 +01:00
|
|
|
GEN_XX2FORM(xvrspi, 0x12, 0x08, PPC2_VSX),
|
|
|
|
GEN_XX2FORM(xvrspic, 0x16, 0x0A, PPC2_VSX),
|
|
|
|
GEN_XX2FORM(xvrspim, 0x12, 0x0B, PPC2_VSX),
|
|
|
|
GEN_XX2FORM(xvrspip, 0x12, 0x0A, PPC2_VSX),
|
|
|
|
GEN_XX2FORM(xvrspiz, 0x12, 0x09, PPC2_VSX),
|
2014-01-02 23:21:21 +01:00
|
|
|
|
2013-11-01 14:21:19 +01:00
|
|
|
#undef VSX_LOGICAL
|
|
|
|
#define VSX_LOGICAL(name, opc2, opc3, fl2) \
|
|
|
|
GEN_XX3FORM(name, opc2, opc3, fl2)
|
|
|
|
|
|
|
|
VSX_LOGICAL(xxland, 0x8, 0x10, PPC2_VSX),
|
|
|
|
VSX_LOGICAL(xxlandc, 0x8, 0x11, PPC2_VSX),
|
|
|
|
VSX_LOGICAL(xxlor, 0x8, 0x12, PPC2_VSX),
|
|
|
|
VSX_LOGICAL(xxlxor, 0x8, 0x13, PPC2_VSX),
|
|
|
|
VSX_LOGICAL(xxlnor, 0x8, 0x14, PPC2_VSX),
|
2014-01-15 15:10:41 +01:00
|
|
|
VSX_LOGICAL(xxleqv, 0x8, 0x17, PPC2_VSX207),
|
|
|
|
VSX_LOGICAL(xxlnand, 0x8, 0x16, PPC2_VSX207),
|
|
|
|
VSX_LOGICAL(xxlorc, 0x8, 0x15, PPC2_VSX207),
|
2013-11-01 14:21:20 +01:00
|
|
|
GEN_XX3FORM(xxmrghw, 0x08, 0x02, PPC2_VSX),
|
|
|
|
GEN_XX3FORM(xxmrglw, 0x08, 0x06, PPC2_VSX),
|
2013-11-01 14:21:22 +01:00
|
|
|
GEN_XX2FORM(xxspltw, 0x08, 0x0A, PPC2_VSX),
|
2013-11-01 14:21:23 +01:00
|
|
|
GEN_XX3FORM_DM(xxsldwi, 0x08, 0x00),
|
2013-11-01 14:21:19 +01:00
|
|
|
|
2013-11-01 14:21:21 +01:00
|
|
|
#define GEN_XXSEL_ROW(opc3) \
|
|
|
|
GEN_HANDLER2_E(xxsel, "xxsel", 0x3C, 0x18, opc3, 0, PPC_NONE, PPC2_VSX), \
|
|
|
|
GEN_HANDLER2_E(xxsel, "xxsel", 0x3C, 0x19, opc3, 0, PPC_NONE, PPC2_VSX), \
|
|
|
|
GEN_HANDLER2_E(xxsel, "xxsel", 0x3C, 0x1A, opc3, 0, PPC_NONE, PPC2_VSX), \
|
|
|
|
GEN_HANDLER2_E(xxsel, "xxsel", 0x3C, 0x1B, opc3, 0, PPC_NONE, PPC2_VSX), \
|
|
|
|
GEN_HANDLER2_E(xxsel, "xxsel", 0x3C, 0x1C, opc3, 0, PPC_NONE, PPC2_VSX), \
|
|
|
|
GEN_HANDLER2_E(xxsel, "xxsel", 0x3C, 0x1D, opc3, 0, PPC_NONE, PPC2_VSX), \
|
|
|
|
GEN_HANDLER2_E(xxsel, "xxsel", 0x3C, 0x1E, opc3, 0, PPC_NONE, PPC2_VSX), \
|
|
|
|
GEN_HANDLER2_E(xxsel, "xxsel", 0x3C, 0x1F, opc3, 0, PPC_NONE, PPC2_VSX), \
|
|
|
|
|
|
|
|
GEN_XXSEL_ROW(0x00)
|
|
|
|
GEN_XXSEL_ROW(0x01)
|
|
|
|
GEN_XXSEL_ROW(0x02)
|
|
|
|
GEN_XXSEL_ROW(0x03)
|
|
|
|
GEN_XXSEL_ROW(0x04)
|
|
|
|
GEN_XXSEL_ROW(0x05)
|
|
|
|
GEN_XXSEL_ROW(0x06)
|
|
|
|
GEN_XXSEL_ROW(0x07)
|
|
|
|
GEN_XXSEL_ROW(0x08)
|
|
|
|
GEN_XXSEL_ROW(0x09)
|
|
|
|
GEN_XXSEL_ROW(0x0A)
|
|
|
|
GEN_XXSEL_ROW(0x0B)
|
|
|
|
GEN_XXSEL_ROW(0x0C)
|
|
|
|
GEN_XXSEL_ROW(0x0D)
|
|
|
|
GEN_XXSEL_ROW(0x0E)
|
|
|
|
GEN_XXSEL_ROW(0x0F)
|
|
|
|
GEN_XXSEL_ROW(0x10)
|
|
|
|
GEN_XXSEL_ROW(0x11)
|
|
|
|
GEN_XXSEL_ROW(0x12)
|
|
|
|
GEN_XXSEL_ROW(0x13)
|
|
|
|
GEN_XXSEL_ROW(0x14)
|
|
|
|
GEN_XXSEL_ROW(0x15)
|
|
|
|
GEN_XXSEL_ROW(0x16)
|
|
|
|
GEN_XXSEL_ROW(0x17)
|
|
|
|
GEN_XXSEL_ROW(0x18)
|
|
|
|
GEN_XXSEL_ROW(0x19)
|
|
|
|
GEN_XXSEL_ROW(0x1A)
|
|
|
|
GEN_XXSEL_ROW(0x1B)
|
|
|
|
GEN_XXSEL_ROW(0x1C)
|
|
|
|
GEN_XXSEL_ROW(0x1D)
|
|
|
|
GEN_XXSEL_ROW(0x1E)
|
|
|
|
GEN_XXSEL_ROW(0x1F)
|
|
|
|
|
2013-10-22 13:09:35 +02:00
|
|
|
GEN_XX3FORM_DM(xxpermdi, 0x08, 0x01),
|
|
|
|
|
2014-04-21 22:54:58 +02:00
|
|
|
#undef GEN_DFP_T_A_B_Rc
|
|
|
|
#undef GEN_DFP_BF_A_B
|
|
|
|
#undef GEN_DFP_BF_A_DCM
|
|
|
|
#undef GEN_DFP_T_B_U32_U32_Rc
|
|
|
|
#undef GEN_DFP_T_A_B_I32_Rc
|
|
|
|
#undef GEN_DFP_T_B_Rc
|
|
|
|
#undef GEN_DFP_T_FPR_I32_Rc
|
|
|
|
|
|
|
|
#define _GEN_DFP_LONG(name, op1, op2, mask) \
|
|
|
|
GEN_HANDLER_E(name, 0x3B, op1, op2, mask, PPC_NONE, PPC2_DFP)
|
|
|
|
|
|
|
|
#define _GEN_DFP_LONGx2(name, op1, op2, mask) \
|
|
|
|
GEN_HANDLER_E(name, 0x3B, op1, 0x00 | op2, mask, PPC_NONE, PPC2_DFP), \
|
|
|
|
GEN_HANDLER_E(name, 0x3B, op1, 0x10 | op2, mask, PPC_NONE, PPC2_DFP)
|
|
|
|
|
|
|
|
#define _GEN_DFP_LONGx4(name, op1, op2, mask) \
|
|
|
|
GEN_HANDLER_E(name, 0x3B, op1, 0x00 | op2, mask, PPC_NONE, PPC2_DFP), \
|
|
|
|
GEN_HANDLER_E(name, 0x3B, op1, 0x08 | op2, mask, PPC_NONE, PPC2_DFP), \
|
|
|
|
GEN_HANDLER_E(name, 0x3B, op1, 0x10 | op2, mask, PPC_NONE, PPC2_DFP), \
|
|
|
|
GEN_HANDLER_E(name, 0x3B, op1, 0x18 | op2, mask, PPC_NONE, PPC2_DFP)
|
|
|
|
|
|
|
|
#define _GEN_DFP_QUAD(name, op1, op2, mask) \
|
|
|
|
GEN_HANDLER_E(name, 0x3F, op1, op2, mask, PPC_NONE, PPC2_DFP)
|
|
|
|
|
|
|
|
#define _GEN_DFP_QUADx2(name, op1, op2, mask) \
|
|
|
|
GEN_HANDLER_E(name, 0x3F, op1, 0x00 | op2, mask, PPC_NONE, PPC2_DFP), \
|
|
|
|
GEN_HANDLER_E(name, 0x3F, op1, 0x10 | op2, mask, PPC_NONE, PPC2_DFP)
|
|
|
|
|
|
|
|
#define _GEN_DFP_QUADx4(name, op1, op2, mask) \
|
|
|
|
GEN_HANDLER_E(name, 0x3F, op1, 0x00 | op2, mask, PPC_NONE, PPC2_DFP), \
|
|
|
|
GEN_HANDLER_E(name, 0x3F, op1, 0x08 | op2, mask, PPC_NONE, PPC2_DFP), \
|
|
|
|
GEN_HANDLER_E(name, 0x3F, op1, 0x10 | op2, mask, PPC_NONE, PPC2_DFP), \
|
|
|
|
GEN_HANDLER_E(name, 0x3F, op1, 0x18 | op2, mask, PPC_NONE, PPC2_DFP)
|
|
|
|
|
|
|
|
#define GEN_DFP_T_A_B_Rc(name, op1, op2) \
|
|
|
|
_GEN_DFP_LONG(name, op1, op2, 0x00000000)
|
|
|
|
|
|
|
|
#define GEN_DFP_Tp_Ap_Bp_Rc(name, op1, op2) \
|
|
|
|
_GEN_DFP_QUAD(name, op1, op2, 0x00210800)
|
|
|
|
|
|
|
|
#define GEN_DFP_Tp_A_Bp_Rc(name, op1, op2) \
|
|
|
|
_GEN_DFP_QUAD(name, op1, op2, 0x00200800)
|
|
|
|
|
|
|
|
#define GEN_DFP_T_B_Rc(name, op1, op2) \
|
|
|
|
_GEN_DFP_LONG(name, op1, op2, 0x001F0000)
|
|
|
|
|
|
|
|
#define GEN_DFP_Tp_Bp_Rc(name, op1, op2) \
|
|
|
|
_GEN_DFP_QUAD(name, op1, op2, 0x003F0800)
|
|
|
|
|
|
|
|
#define GEN_DFP_Tp_B_Rc(name, op1, op2) \
|
|
|
|
_GEN_DFP_QUAD(name, op1, op2, 0x003F0000)
|
|
|
|
|
|
|
|
#define GEN_DFP_T_Bp_Rc(name, op1, op2) \
|
|
|
|
_GEN_DFP_QUAD(name, op1, op2, 0x001F0800)
|
|
|
|
|
|
|
|
#define GEN_DFP_BF_A_B(name, op1, op2) \
|
|
|
|
_GEN_DFP_LONG(name, op1, op2, 0x00000001)
|
|
|
|
|
|
|
|
#define GEN_DFP_BF_Ap_Bp(name, op1, op2) \
|
|
|
|
_GEN_DFP_QUAD(name, op1, op2, 0x00610801)
|
|
|
|
|
|
|
|
#define GEN_DFP_BF_A_Bp(name, op1, op2) \
|
|
|
|
_GEN_DFP_QUAD(name, op1, op2, 0x00600801)
|
|
|
|
|
|
|
|
#define GEN_DFP_BF_A_DCM(name, op1, op2) \
|
|
|
|
_GEN_DFP_LONGx2(name, op1, op2, 0x00600001)
|
|
|
|
|
|
|
|
#define GEN_DFP_BF_Ap_DCM(name, op1, op2) \
|
|
|
|
_GEN_DFP_QUADx2(name, op1, op2, 0x00610001)
|
|
|
|
|
|
|
|
#define GEN_DFP_T_A_B_RMC_Rc(name, op1, op2) \
|
|
|
|
_GEN_DFP_LONGx4(name, op1, op2, 0x00000000)
|
|
|
|
|
|
|
|
#define GEN_DFP_Tp_Ap_Bp_RMC_Rc(name, op1, op2) \
|
|
|
|
_GEN_DFP_QUADx4(name, op1, op2, 0x02010800)
|
|
|
|
|
|
|
|
#define GEN_DFP_Tp_A_Bp_RMC_Rc(name, op1, op2) \
|
|
|
|
_GEN_DFP_QUADx4(name, op1, op2, 0x02000800)
|
|
|
|
|
|
|
|
#define GEN_DFP_TE_T_B_RMC_Rc(name, op1, op2) \
|
|
|
|
_GEN_DFP_LONGx4(name, op1, op2, 0x00000000)
|
|
|
|
|
|
|
|
#define GEN_DFP_TE_Tp_Bp_RMC_Rc(name, op1, op2) \
|
|
|
|
_GEN_DFP_QUADx4(name, op1, op2, 0x00200800)
|
|
|
|
|
|
|
|
#define GEN_DFP_R_T_B_RMC_Rc(name, op1, op2) \
|
|
|
|
_GEN_DFP_LONGx4(name, op1, op2, 0x001E0000)
|
|
|
|
|
|
|
|
#define GEN_DFP_R_Tp_Bp_RMC_Rc(name, op1, op2) \
|
|
|
|
_GEN_DFP_QUADx4(name, op1, op2, 0x003E0800)
|
|
|
|
|
|
|
|
#define GEN_DFP_SP_T_B_Rc(name, op1, op2) \
|
|
|
|
_GEN_DFP_LONG(name, op1, op2, 0x00070000)
|
|
|
|
|
|
|
|
#define GEN_DFP_SP_Tp_Bp_Rc(name, op1, op2) \
|
|
|
|
_GEN_DFP_QUAD(name, op1, op2, 0x00270800)
|
|
|
|
|
|
|
|
#define GEN_DFP_S_T_B_Rc(name, op1, op2) \
|
|
|
|
_GEN_DFP_LONG(name, op1, op2, 0x000F0000)
|
|
|
|
|
|
|
|
#define GEN_DFP_S_Tp_Bp_Rc(name, op1, op2) \
|
|
|
|
_GEN_DFP_QUAD(name, op1, op2, 0x002F0800)
|
|
|
|
|
|
|
|
#define GEN_DFP_T_A_SH_Rc(name, op1, op2) \
|
|
|
|
_GEN_DFP_LONGx2(name, op1, op2, 0x00000000)
|
|
|
|
|
|
|
|
#define GEN_DFP_Tp_Ap_SH_Rc(name, op1, op2) \
|
|
|
|
_GEN_DFP_QUADx2(name, op1, op2, 0x00210000)
|
|
|
|
|
2014-04-21 22:55:01 +02:00
|
|
|
GEN_DFP_T_A_B_Rc(dadd, 0x02, 0x00),
|
|
|
|
GEN_DFP_Tp_Ap_Bp_Rc(daddq, 0x02, 0x00),
|
2014-04-21 22:55:02 +02:00
|
|
|
GEN_DFP_T_A_B_Rc(dsub, 0x02, 0x10),
|
|
|
|
GEN_DFP_Tp_Ap_Bp_Rc(dsubq, 0x02, 0x10),
|
2014-04-21 22:55:03 +02:00
|
|
|
GEN_DFP_T_A_B_Rc(dmul, 0x02, 0x01),
|
|
|
|
GEN_DFP_Tp_Ap_Bp_Rc(dmulq, 0x02, 0x01),
|
2014-04-21 22:55:04 +02:00
|
|
|
GEN_DFP_T_A_B_Rc(ddiv, 0x02, 0x11),
|
|
|
|
GEN_DFP_Tp_Ap_Bp_Rc(ddivq, 0x02, 0x11),
|
2014-04-21 22:55:05 +02:00
|
|
|
GEN_DFP_BF_A_B(dcmpu, 0x02, 0x14),
|
|
|
|
GEN_DFP_BF_Ap_Bp(dcmpuq, 0x02, 0x14),
|
|
|
|
GEN_DFP_BF_A_B(dcmpo, 0x02, 0x04),
|
|
|
|
GEN_DFP_BF_Ap_Bp(dcmpoq, 0x02, 0x04),
|
2014-04-21 22:55:06 +02:00
|
|
|
GEN_DFP_BF_A_DCM(dtstdc, 0x02, 0x06),
|
|
|
|
GEN_DFP_BF_Ap_DCM(dtstdcq, 0x02, 0x06),
|
2014-04-21 22:55:07 +02:00
|
|
|
GEN_DFP_BF_A_DCM(dtstdg, 0x02, 0x07),
|
|
|
|
GEN_DFP_BF_Ap_DCM(dtstdgq, 0x02, 0x07),
|
2014-04-21 22:55:08 +02:00
|
|
|
GEN_DFP_BF_A_B(dtstex, 0x02, 0x05),
|
|
|
|
GEN_DFP_BF_Ap_Bp(dtstexq, 0x02, 0x05),
|
2014-04-21 22:55:09 +02:00
|
|
|
GEN_DFP_BF_A_B(dtstsf, 0x02, 0x15),
|
|
|
|
GEN_DFP_BF_A_Bp(dtstsfq, 0x02, 0x15),
|
2014-04-21 22:55:10 +02:00
|
|
|
GEN_DFP_TE_T_B_RMC_Rc(dquai, 0x03, 0x02),
|
|
|
|
GEN_DFP_TE_Tp_Bp_RMC_Rc(dquaiq, 0x03, 0x02),
|
|
|
|
GEN_DFP_T_A_B_RMC_Rc(dqua, 0x03, 0x00),
|
|
|
|
GEN_DFP_Tp_Ap_Bp_RMC_Rc(dquaq, 0x03, 0x00),
|
2014-04-21 22:55:11 +02:00
|
|
|
GEN_DFP_T_A_B_RMC_Rc(drrnd, 0x03, 0x01),
|
|
|
|
GEN_DFP_Tp_A_Bp_RMC_Rc(drrndq, 0x03, 0x01),
|
2014-04-21 22:55:12 +02:00
|
|
|
GEN_DFP_R_T_B_RMC_Rc(drintx, 0x03, 0x03),
|
|
|
|
GEN_DFP_R_Tp_Bp_RMC_Rc(drintxq, 0x03, 0x03),
|
|
|
|
GEN_DFP_R_T_B_RMC_Rc(drintn, 0x03, 0x07),
|
|
|
|
GEN_DFP_R_Tp_Bp_RMC_Rc(drintnq, 0x03, 0x07),
|
2014-04-21 22:55:13 +02:00
|
|
|
GEN_DFP_T_B_Rc(dctdp, 0x02, 0x08),
|
|
|
|
GEN_DFP_Tp_B_Rc(dctqpq, 0x02, 0x08),
|
2014-04-21 22:55:14 +02:00
|
|
|
GEN_DFP_T_B_Rc(drsp, 0x02, 0x18),
|
|
|
|
GEN_DFP_Tp_Bp_Rc(drdpq, 0x02, 0x18),
|
2014-04-21 22:55:15 +02:00
|
|
|
GEN_DFP_T_B_Rc(dcffix, 0x02, 0x19),
|
|
|
|
GEN_DFP_Tp_B_Rc(dcffixq, 0x02, 0x19),
|
2014-04-21 22:55:16 +02:00
|
|
|
GEN_DFP_T_B_Rc(dctfix, 0x02, 0x09),
|
|
|
|
GEN_DFP_T_Bp_Rc(dctfixq, 0x02, 0x09),
|
2014-04-21 22:55:17 +02:00
|
|
|
GEN_DFP_SP_T_B_Rc(ddedpd, 0x02, 0x0a),
|
|
|
|
GEN_DFP_SP_Tp_Bp_Rc(ddedpdq, 0x02, 0x0a),
|
2014-04-21 22:55:18 +02:00
|
|
|
GEN_DFP_S_T_B_Rc(denbcd, 0x02, 0x1a),
|
|
|
|
GEN_DFP_S_Tp_Bp_Rc(denbcdq, 0x02, 0x1a),
|
2014-04-21 22:55:19 +02:00
|
|
|
GEN_DFP_T_B_Rc(dxex, 0x02, 0x0b),
|
|
|
|
GEN_DFP_T_Bp_Rc(dxexq, 0x02, 0x0b),
|
2014-04-21 22:55:20 +02:00
|
|
|
GEN_DFP_T_A_B_Rc(diex, 0x02, 0x1b),
|
|
|
|
GEN_DFP_Tp_A_Bp_Rc(diexq, 0x02, 0x1b),
|
2014-04-21 22:55:21 +02:00
|
|
|
GEN_DFP_T_A_SH_Rc(dscli, 0x02, 0x02),
|
|
|
|
GEN_DFP_Tp_Ap_SH_Rc(dscliq, 0x02, 0x02),
|
|
|
|
GEN_DFP_T_A_SH_Rc(dscri, 0x02, 0x03),
|
|
|
|
GEN_DFP_Tp_Ap_SH_Rc(dscriq, 0x02, 0x03),
|
|
|
|
|
2009-06-17 17:22:31 +02:00
|
|
|
#undef GEN_SPE
|
2011-09-28 07:54:05 +02:00
|
|
|
#define GEN_SPE(name0, name1, opc2, opc3, inval0, inval1, type) \
|
|
|
|
GEN_OPCODE_DUAL(name0##_##name1, 0x04, opc2, opc3, inval0, inval1, type, PPC_NONE)
|
|
|
|
GEN_SPE(evaddw, speundef, 0x00, 0x08, 0x00000000, 0xFFFFFFFF, PPC_SPE),
|
|
|
|
GEN_SPE(evaddiw, speundef, 0x01, 0x08, 0x00000000, 0xFFFFFFFF, PPC_SPE),
|
|
|
|
GEN_SPE(evsubfw, speundef, 0x02, 0x08, 0x00000000, 0xFFFFFFFF, PPC_SPE),
|
|
|
|
GEN_SPE(evsubifw, speundef, 0x03, 0x08, 0x00000000, 0xFFFFFFFF, PPC_SPE),
|
|
|
|
GEN_SPE(evabs, evneg, 0x04, 0x08, 0x0000F800, 0x0000F800, PPC_SPE),
|
|
|
|
GEN_SPE(evextsb, evextsh, 0x05, 0x08, 0x0000F800, 0x0000F800, PPC_SPE),
|
|
|
|
GEN_SPE(evrndw, evcntlzw, 0x06, 0x08, 0x0000F800, 0x0000F800, PPC_SPE),
|
|
|
|
GEN_SPE(evcntlsw, brinc, 0x07, 0x08, 0x0000F800, 0x00000000, PPC_SPE),
|
|
|
|
GEN_SPE(evmra, speundef, 0x02, 0x13, 0x0000F800, 0xFFFFFFFF, PPC_SPE),
|
|
|
|
GEN_SPE(speundef, evand, 0x08, 0x08, 0xFFFFFFFF, 0x00000000, PPC_SPE),
|
|
|
|
GEN_SPE(evandc, speundef, 0x09, 0x08, 0x00000000, 0xFFFFFFFF, PPC_SPE),
|
|
|
|
GEN_SPE(evxor, evor, 0x0B, 0x08, 0x00000000, 0x00000000, PPC_SPE),
|
|
|
|
GEN_SPE(evnor, eveqv, 0x0C, 0x08, 0x00000000, 0x00000000, PPC_SPE),
|
|
|
|
GEN_SPE(evmwumi, evmwsmi, 0x0C, 0x11, 0x00000000, 0x00000000, PPC_SPE),
|
|
|
|
GEN_SPE(evmwumia, evmwsmia, 0x1C, 0x11, 0x00000000, 0x00000000, PPC_SPE),
|
|
|
|
GEN_SPE(evmwumiaa, evmwsmiaa, 0x0C, 0x15, 0x00000000, 0x00000000, PPC_SPE),
|
|
|
|
GEN_SPE(speundef, evorc, 0x0D, 0x08, 0xFFFFFFFF, 0x00000000, PPC_SPE),
|
|
|
|
GEN_SPE(evnand, speundef, 0x0F, 0x08, 0x00000000, 0xFFFFFFFF, PPC_SPE),
|
|
|
|
GEN_SPE(evsrwu, evsrws, 0x10, 0x08, 0x00000000, 0x00000000, PPC_SPE),
|
|
|
|
GEN_SPE(evsrwiu, evsrwis, 0x11, 0x08, 0x00000000, 0x00000000, PPC_SPE),
|
|
|
|
GEN_SPE(evslw, speundef, 0x12, 0x08, 0x00000000, 0xFFFFFFFF, PPC_SPE),
|
|
|
|
GEN_SPE(evslwi, speundef, 0x13, 0x08, 0x00000000, 0xFFFFFFFF, PPC_SPE),
|
|
|
|
GEN_SPE(evrlw, evsplati, 0x14, 0x08, 0x00000000, 0x0000F800, PPC_SPE),
|
|
|
|
GEN_SPE(evrlwi, evsplatfi, 0x15, 0x08, 0x00000000, 0x0000F800, PPC_SPE),
|
|
|
|
GEN_SPE(evmergehi, evmergelo, 0x16, 0x08, 0x00000000, 0x00000000, PPC_SPE),
|
|
|
|
GEN_SPE(evmergehilo, evmergelohi, 0x17, 0x08, 0x00000000, 0x00000000, PPC_SPE),
|
|
|
|
GEN_SPE(evcmpgtu, evcmpgts, 0x18, 0x08, 0x00600000, 0x00600000, PPC_SPE),
|
|
|
|
GEN_SPE(evcmpltu, evcmplts, 0x19, 0x08, 0x00600000, 0x00600000, PPC_SPE),
|
|
|
|
GEN_SPE(evcmpeq, speundef, 0x1A, 0x08, 0x00600000, 0xFFFFFFFF, PPC_SPE),
|
|
|
|
|
|
|
|
GEN_SPE(evfsadd, evfssub, 0x00, 0x0A, 0x00000000, 0x00000000, PPC_SPE_SINGLE),
|
|
|
|
GEN_SPE(evfsabs, evfsnabs, 0x02, 0x0A, 0x0000F800, 0x0000F800, PPC_SPE_SINGLE),
|
|
|
|
GEN_SPE(evfsneg, speundef, 0x03, 0x0A, 0x0000F800, 0xFFFFFFFF, PPC_SPE_SINGLE),
|
|
|
|
GEN_SPE(evfsmul, evfsdiv, 0x04, 0x0A, 0x00000000, 0x00000000, PPC_SPE_SINGLE),
|
|
|
|
GEN_SPE(evfscmpgt, evfscmplt, 0x06, 0x0A, 0x00600000, 0x00600000, PPC_SPE_SINGLE),
|
|
|
|
GEN_SPE(evfscmpeq, speundef, 0x07, 0x0A, 0x00600000, 0xFFFFFFFF, PPC_SPE_SINGLE),
|
|
|
|
GEN_SPE(evfscfui, evfscfsi, 0x08, 0x0A, 0x00180000, 0x00180000, PPC_SPE_SINGLE),
|
|
|
|
GEN_SPE(evfscfuf, evfscfsf, 0x09, 0x0A, 0x00180000, 0x00180000, PPC_SPE_SINGLE),
|
|
|
|
GEN_SPE(evfsctui, evfsctsi, 0x0A, 0x0A, 0x00180000, 0x00180000, PPC_SPE_SINGLE),
|
|
|
|
GEN_SPE(evfsctuf, evfsctsf, 0x0B, 0x0A, 0x00180000, 0x00180000, PPC_SPE_SINGLE),
|
|
|
|
GEN_SPE(evfsctuiz, speundef, 0x0C, 0x0A, 0x00180000, 0xFFFFFFFF, PPC_SPE_SINGLE),
|
|
|
|
GEN_SPE(evfsctsiz, speundef, 0x0D, 0x0A, 0x00180000, 0xFFFFFFFF, PPC_SPE_SINGLE),
|
|
|
|
GEN_SPE(evfststgt, evfststlt, 0x0E, 0x0A, 0x00600000, 0x00600000, PPC_SPE_SINGLE),
|
|
|
|
GEN_SPE(evfststeq, speundef, 0x0F, 0x0A, 0x00600000, 0xFFFFFFFF, PPC_SPE_SINGLE),
|
|
|
|
|
|
|
|
GEN_SPE(efsadd, efssub, 0x00, 0x0B, 0x00000000, 0x00000000, PPC_SPE_SINGLE),
|
|
|
|
GEN_SPE(efsabs, efsnabs, 0x02, 0x0B, 0x0000F800, 0x0000F800, PPC_SPE_SINGLE),
|
|
|
|
GEN_SPE(efsneg, speundef, 0x03, 0x0B, 0x0000F800, 0xFFFFFFFF, PPC_SPE_SINGLE),
|
|
|
|
GEN_SPE(efsmul, efsdiv, 0x04, 0x0B, 0x00000000, 0x00000000, PPC_SPE_SINGLE),
|
|
|
|
GEN_SPE(efscmpgt, efscmplt, 0x06, 0x0B, 0x00600000, 0x00600000, PPC_SPE_SINGLE),
|
|
|
|
GEN_SPE(efscmpeq, efscfd, 0x07, 0x0B, 0x00600000, 0x00180000, PPC_SPE_SINGLE),
|
|
|
|
GEN_SPE(efscfui, efscfsi, 0x08, 0x0B, 0x00180000, 0x00180000, PPC_SPE_SINGLE),
|
|
|
|
GEN_SPE(efscfuf, efscfsf, 0x09, 0x0B, 0x00180000, 0x00180000, PPC_SPE_SINGLE),
|
|
|
|
GEN_SPE(efsctui, efsctsi, 0x0A, 0x0B, 0x00180000, 0x00180000, PPC_SPE_SINGLE),
|
|
|
|
GEN_SPE(efsctuf, efsctsf, 0x0B, 0x0B, 0x00180000, 0x00180000, PPC_SPE_SINGLE),
|
|
|
|
GEN_SPE(efsctuiz, speundef, 0x0C, 0x0B, 0x00180000, 0xFFFFFFFF, PPC_SPE_SINGLE),
|
|
|
|
GEN_SPE(efsctsiz, speundef, 0x0D, 0x0B, 0x00180000, 0xFFFFFFFF, PPC_SPE_SINGLE),
|
|
|
|
GEN_SPE(efststgt, efststlt, 0x0E, 0x0B, 0x00600000, 0x00600000, PPC_SPE_SINGLE),
|
|
|
|
GEN_SPE(efststeq, speundef, 0x0F, 0x0B, 0x00600000, 0xFFFFFFFF, PPC_SPE_SINGLE),
|
|
|
|
|
|
|
|
GEN_SPE(efdadd, efdsub, 0x10, 0x0B, 0x00000000, 0x00000000, PPC_SPE_DOUBLE),
|
|
|
|
GEN_SPE(efdcfuid, efdcfsid, 0x11, 0x0B, 0x00180000, 0x00180000, PPC_SPE_DOUBLE),
|
|
|
|
GEN_SPE(efdabs, efdnabs, 0x12, 0x0B, 0x0000F800, 0x0000F800, PPC_SPE_DOUBLE),
|
|
|
|
GEN_SPE(efdneg, speundef, 0x13, 0x0B, 0x0000F800, 0xFFFFFFFF, PPC_SPE_DOUBLE),
|
|
|
|
GEN_SPE(efdmul, efddiv, 0x14, 0x0B, 0x00000000, 0x00000000, PPC_SPE_DOUBLE),
|
|
|
|
GEN_SPE(efdctuidz, efdctsidz, 0x15, 0x0B, 0x00180000, 0x00180000, PPC_SPE_DOUBLE),
|
|
|
|
GEN_SPE(efdcmpgt, efdcmplt, 0x16, 0x0B, 0x00600000, 0x00600000, PPC_SPE_DOUBLE),
|
|
|
|
GEN_SPE(efdcmpeq, efdcfs, 0x17, 0x0B, 0x00600000, 0x00180000, PPC_SPE_DOUBLE),
|
|
|
|
GEN_SPE(efdcfui, efdcfsi, 0x18, 0x0B, 0x00180000, 0x00180000, PPC_SPE_DOUBLE),
|
|
|
|
GEN_SPE(efdcfuf, efdcfsf, 0x19, 0x0B, 0x00180000, 0x00180000, PPC_SPE_DOUBLE),
|
|
|
|
GEN_SPE(efdctui, efdctsi, 0x1A, 0x0B, 0x00180000, 0x00180000, PPC_SPE_DOUBLE),
|
|
|
|
GEN_SPE(efdctuf, efdctsf, 0x1B, 0x0B, 0x00180000, 0x00180000, PPC_SPE_DOUBLE),
|
|
|
|
GEN_SPE(efdctuiz, speundef, 0x1C, 0x0B, 0x00180000, 0xFFFFFFFF, PPC_SPE_DOUBLE),
|
|
|
|
GEN_SPE(efdctsiz, speundef, 0x1D, 0x0B, 0x00180000, 0xFFFFFFFF, PPC_SPE_DOUBLE),
|
|
|
|
GEN_SPE(efdtstgt, efdtstlt, 0x1E, 0x0B, 0x00600000, 0x00600000, PPC_SPE_DOUBLE),
|
|
|
|
GEN_SPE(efdtsteq, speundef, 0x1F, 0x0B, 0x00600000, 0xFFFFFFFF, PPC_SPE_DOUBLE),
|
2009-06-17 17:22:31 +02:00
|
|
|
|
|
|
|
#undef GEN_SPEOP_LDST
|
|
|
|
#define GEN_SPEOP_LDST(name, opc2, sh) \
|
|
|
|
GEN_HANDLER(name, 0x04, opc2, 0x0C, 0x00000000, PPC_SPE)
|
|
|
|
GEN_SPEOP_LDST(evldd, 0x00, 3),
|
|
|
|
GEN_SPEOP_LDST(evldw, 0x01, 3),
|
|
|
|
GEN_SPEOP_LDST(evldh, 0x02, 3),
|
|
|
|
GEN_SPEOP_LDST(evlhhesplat, 0x04, 1),
|
|
|
|
GEN_SPEOP_LDST(evlhhousplat, 0x06, 1),
|
|
|
|
GEN_SPEOP_LDST(evlhhossplat, 0x07, 1),
|
|
|
|
GEN_SPEOP_LDST(evlwhe, 0x08, 2),
|
|
|
|
GEN_SPEOP_LDST(evlwhou, 0x0A, 2),
|
|
|
|
GEN_SPEOP_LDST(evlwhos, 0x0B, 2),
|
|
|
|
GEN_SPEOP_LDST(evlwwsplat, 0x0C, 2),
|
|
|
|
GEN_SPEOP_LDST(evlwhsplat, 0x0E, 2),
|
|
|
|
|
|
|
|
GEN_SPEOP_LDST(evstdd, 0x10, 3),
|
|
|
|
GEN_SPEOP_LDST(evstdw, 0x11, 3),
|
|
|
|
GEN_SPEOP_LDST(evstdh, 0x12, 3),
|
|
|
|
GEN_SPEOP_LDST(evstwhe, 0x18, 2),
|
|
|
|
GEN_SPEOP_LDST(evstwho, 0x1A, 2),
|
|
|
|
GEN_SPEOP_LDST(evstwwe, 0x1C, 2),
|
|
|
|
GEN_SPEOP_LDST(evstwwo, 0x1E, 2),
|
2014-12-18 17:34:34 +01:00
|
|
|
|
|
|
|
GEN_HANDLER2_E(tbegin, "tbegin", 0x1F, 0x0E, 0x14, 0x01DFF800, \
|
|
|
|
PPC_NONE, PPC2_TM),
|
2014-12-18 17:34:35 +01:00
|
|
|
GEN_HANDLER2_E(tend, "tend", 0x1F, 0x0E, 0x15, 0x01FFF800, \
|
|
|
|
PPC_NONE, PPC2_TM),
|
|
|
|
GEN_HANDLER2_E(tabort, "tabort", 0x1F, 0x0E, 0x1C, 0x03E0F800, \
|
|
|
|
PPC_NONE, PPC2_TM),
|
|
|
|
GEN_HANDLER2_E(tabortwc, "tabortwc", 0x1F, 0x0E, 0x18, 0x00000000, \
|
|
|
|
PPC_NONE, PPC2_TM),
|
|
|
|
GEN_HANDLER2_E(tabortwci, "tabortwci", 0x1F, 0x0E, 0x1A, 0x00000000, \
|
|
|
|
PPC_NONE, PPC2_TM),
|
|
|
|
GEN_HANDLER2_E(tabortdc, "tabortdc", 0x1F, 0x0E, 0x19, 0x00000000, \
|
|
|
|
PPC_NONE, PPC2_TM),
|
|
|
|
GEN_HANDLER2_E(tabortdci, "tabortdci", 0x1F, 0x0E, 0x1B, 0x00000000, \
|
|
|
|
PPC_NONE, PPC2_TM),
|
|
|
|
GEN_HANDLER2_E(tsr, "tsr", 0x1F, 0x0E, 0x17, 0x03DFF800, \
|
|
|
|
PPC_NONE, PPC2_TM),
|
2014-12-18 17:34:36 +01:00
|
|
|
GEN_HANDLER2_E(tcheck, "tcheck", 0x1F, 0x0E, 0x16, 0x007FF800, \
|
|
|
|
PPC_NONE, PPC2_TM),
|
2014-12-18 17:34:37 +01:00
|
|
|
GEN_HANDLER2_E(treclaim, "treclaim", 0x1F, 0x0E, 0x1D, 0x03E0F800, \
|
|
|
|
PPC_NONE, PPC2_TM),
|
|
|
|
GEN_HANDLER2_E(trechkpt, "trechkpt", 0x1F, 0x0E, 0x1F, 0x03FFF800, \
|
|
|
|
PPC_NONE, PPC2_TM),
|
2009-06-17 17:22:31 +02:00
|
|
|
};
|
|
|
|
|
2007-10-25 23:35:50 +02:00
|
|
|
#include "helper_regs.h"
|
2012-04-06 15:35:34 +02:00
|
|
|
#include "translate_init.c"
|
2003-11-23 15:55:54 +01:00
|
|
|
|
2004-01-04 23:58:38 +01:00
|
|
|
/*****************************************************************************/
|
2005-07-02 22:59:34 +02:00
|
|
|
/* Misc PowerPC helpers */
|
2013-05-27 01:33:50 +02:00
|
|
|
void ppc_cpu_dump_state(CPUState *cs, FILE *f, fprintf_function cpu_fprintf,
|
|
|
|
int flags)
|
2003-11-23 15:55:54 +01:00
|
|
|
{
|
2005-07-02 22:59:34 +02:00
|
|
|
#define RGPL 4
|
|
|
|
#define RFPL 4
|
|
|
|
|
2013-05-27 01:33:50 +02:00
|
|
|
PowerPCCPU *cpu = POWERPC_CPU(cs);
|
|
|
|
CPUPPCState *env = &cpu->env;
|
2003-11-23 15:55:54 +01:00
|
|
|
int i;
|
|
|
|
|
2009-08-16 13:13:18 +02:00
|
|
|
cpu_fprintf(f, "NIP " TARGET_FMT_lx " LR " TARGET_FMT_lx " CTR "
|
2015-02-25 10:39:25 +01:00
|
|
|
TARGET_FMT_lx " XER " TARGET_FMT_lx " CPU#%d\n",
|
|
|
|
env->nip, env->lr, env->ctr, cpu_read_xer(env),
|
|
|
|
cs->cpu_index);
|
2009-08-16 13:13:18 +02:00
|
|
|
cpu_fprintf(f, "MSR " TARGET_FMT_lx " HID0 " TARGET_FMT_lx " HF "
|
|
|
|
TARGET_FMT_lx " idx %d\n", env->msr, env->spr[SPR_HID0],
|
|
|
|
env->hflags, env->mmu_idx);
|
2007-03-17 15:02:15 +01:00
|
|
|
#if !defined(NO_TIMER_DUMP)
|
2010-10-22 23:03:33 +02:00
|
|
|
cpu_fprintf(f, "TB %08" PRIu32 " %08" PRIu64
|
2007-03-07 09:32:30 +01:00
|
|
|
#if !defined(CONFIG_USER_ONLY)
|
2010-10-22 23:03:33 +02:00
|
|
|
" DECR %08" PRIu32
|
2007-03-07 09:32:30 +01:00
|
|
|
#endif
|
|
|
|
"\n",
|
2007-11-04 02:57:29 +01:00
|
|
|
cpu_ppc_load_tbu(env), cpu_ppc_load_tbl(env)
|
2007-03-07 09:32:30 +01:00
|
|
|
#if !defined(CONFIG_USER_ONLY)
|
|
|
|
, cpu_ppc_load_decr(env)
|
|
|
|
#endif
|
|
|
|
);
|
2007-11-04 02:57:29 +01:00
|
|
|
#endif
|
2007-03-07 09:32:30 +01:00
|
|
|
for (i = 0; i < 32; i++) {
|
2005-07-02 22:59:34 +02:00
|
|
|
if ((i & (RGPL - 1)) == 0)
|
|
|
|
cpu_fprintf(f, "GPR%02d", i);
|
2009-08-16 13:54:37 +02:00
|
|
|
cpu_fprintf(f, " %016" PRIx64, ppc_dump_gpr(env, i));
|
2005-07-02 22:59:34 +02:00
|
|
|
if ((i & (RGPL - 1)) == (RGPL - 1))
|
2004-10-09 20:08:01 +02:00
|
|
|
cpu_fprintf(f, "\n");
|
2007-03-07 09:32:30 +01:00
|
|
|
}
|
2005-07-02 22:59:34 +02:00
|
|
|
cpu_fprintf(f, "CR ");
|
2007-03-07 09:32:30 +01:00
|
|
|
for (i = 0; i < 8; i++)
|
2004-10-09 20:08:01 +02:00
|
|
|
cpu_fprintf(f, "%01x", env->crf[i]);
|
|
|
|
cpu_fprintf(f, " [");
|
2007-03-07 09:32:30 +01:00
|
|
|
for (i = 0; i < 8; i++) {
|
|
|
|
char a = '-';
|
|
|
|
if (env->crf[i] & 0x08)
|
|
|
|
a = 'L';
|
|
|
|
else if (env->crf[i] & 0x04)
|
|
|
|
a = 'G';
|
|
|
|
else if (env->crf[i] & 0x02)
|
|
|
|
a = 'E';
|
2004-10-09 20:08:01 +02:00
|
|
|
cpu_fprintf(f, " %c%c", a, env->crf[i] & 0x01 ? 'O' : ' ');
|
2007-03-07 09:32:30 +01:00
|
|
|
}
|
2009-08-16 13:13:18 +02:00
|
|
|
cpu_fprintf(f, " ] RES " TARGET_FMT_lx "\n",
|
|
|
|
env->reserve_addr);
|
2005-07-02 22:59:34 +02:00
|
|
|
for (i = 0; i < 32; i++) {
|
|
|
|
if ((i & (RFPL - 1)) == 0)
|
|
|
|
cpu_fprintf(f, "FPR%02d", i);
|
2006-06-25 20:15:32 +02:00
|
|
|
cpu_fprintf(f, " %016" PRIx64, *((uint64_t *)&env->fpr[i]));
|
2005-07-02 22:59:34 +02:00
|
|
|
if ((i & (RFPL - 1)) == (RFPL - 1))
|
2004-10-09 20:08:01 +02:00
|
|
|
cpu_fprintf(f, "\n");
|
2003-11-23 15:55:54 +01:00
|
|
|
}
|
2012-10-29 18:24:59 +01:00
|
|
|
cpu_fprintf(f, "FPSCR " TARGET_FMT_lx "\n", env->fpscr);
|
2007-10-07 17:43:50 +02:00
|
|
|
#if !defined(CONFIG_USER_ONLY)
|
2011-04-30 00:10:23 +02:00
|
|
|
cpu_fprintf(f, " SRR0 " TARGET_FMT_lx " SRR1 " TARGET_FMT_lx
|
|
|
|
" PVR " TARGET_FMT_lx " VRSAVE " TARGET_FMT_lx "\n",
|
|
|
|
env->spr[SPR_SRR0], env->spr[SPR_SRR1],
|
|
|
|
env->spr[SPR_PVR], env->spr[SPR_VRSAVE]);
|
|
|
|
|
|
|
|
cpu_fprintf(f, "SPRG0 " TARGET_FMT_lx " SPRG1 " TARGET_FMT_lx
|
|
|
|
" SPRG2 " TARGET_FMT_lx " SPRG3 " TARGET_FMT_lx "\n",
|
|
|
|
env->spr[SPR_SPRG0], env->spr[SPR_SPRG1],
|
|
|
|
env->spr[SPR_SPRG2], env->spr[SPR_SPRG3]);
|
|
|
|
|
|
|
|
cpu_fprintf(f, "SPRG4 " TARGET_FMT_lx " SPRG5 " TARGET_FMT_lx
|
|
|
|
" SPRG6 " TARGET_FMT_lx " SPRG7 " TARGET_FMT_lx "\n",
|
|
|
|
env->spr[SPR_SPRG4], env->spr[SPR_SPRG5],
|
|
|
|
env->spr[SPR_SPRG6], env->spr[SPR_SPRG7]);
|
|
|
|
|
|
|
|
if (env->excp_model == POWERPC_EXCP_BOOKE) {
|
|
|
|
cpu_fprintf(f, "CSRR0 " TARGET_FMT_lx " CSRR1 " TARGET_FMT_lx
|
|
|
|
" MCSRR0 " TARGET_FMT_lx " MCSRR1 " TARGET_FMT_lx "\n",
|
|
|
|
env->spr[SPR_BOOKE_CSRR0], env->spr[SPR_BOOKE_CSRR1],
|
|
|
|
env->spr[SPR_BOOKE_MCSRR0], env->spr[SPR_BOOKE_MCSRR1]);
|
|
|
|
|
|
|
|
cpu_fprintf(f, " TCR " TARGET_FMT_lx " TSR " TARGET_FMT_lx
|
|
|
|
" ESR " TARGET_FMT_lx " DEAR " TARGET_FMT_lx "\n",
|
|
|
|
env->spr[SPR_BOOKE_TCR], env->spr[SPR_BOOKE_TSR],
|
|
|
|
env->spr[SPR_BOOKE_ESR], env->spr[SPR_BOOKE_DEAR]);
|
|
|
|
|
|
|
|
cpu_fprintf(f, " PIR " TARGET_FMT_lx " DECAR " TARGET_FMT_lx
|
|
|
|
" IVPR " TARGET_FMT_lx " EPCR " TARGET_FMT_lx "\n",
|
|
|
|
env->spr[SPR_BOOKE_PIR], env->spr[SPR_BOOKE_DECAR],
|
|
|
|
env->spr[SPR_BOOKE_IVPR], env->spr[SPR_BOOKE_EPCR]);
|
|
|
|
|
|
|
|
cpu_fprintf(f, " MCSR " TARGET_FMT_lx " SPRG8 " TARGET_FMT_lx
|
|
|
|
" EPR " TARGET_FMT_lx "\n",
|
|
|
|
env->spr[SPR_BOOKE_MCSR], env->spr[SPR_BOOKE_SPRG8],
|
|
|
|
env->spr[SPR_BOOKE_EPR]);
|
|
|
|
|
|
|
|
/* FSL-specific */
|
|
|
|
cpu_fprintf(f, " MCAR " TARGET_FMT_lx " PID1 " TARGET_FMT_lx
|
|
|
|
" PID2 " TARGET_FMT_lx " SVR " TARGET_FMT_lx "\n",
|
|
|
|
env->spr[SPR_Exxx_MCAR], env->spr[SPR_BOOKE_PID1],
|
|
|
|
env->spr[SPR_BOOKE_PID2], env->spr[SPR_E500_SVR]);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* IVORs are left out as they are large and do not change often --
|
|
|
|
* they can be read with "p $ivor0", "p $ivor1", etc.
|
|
|
|
*/
|
|
|
|
}
|
|
|
|
|
2011-08-31 17:45:10 +02:00
|
|
|
#if defined(TARGET_PPC64)
|
|
|
|
if (env->flags & POWERPC_FLAG_CFAR) {
|
|
|
|
cpu_fprintf(f, " CFAR " TARGET_FMT_lx"\n", env->cfar);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2011-04-30 00:10:23 +02:00
|
|
|
switch (env->mmu_model) {
|
|
|
|
case POWERPC_MMU_32B:
|
|
|
|
case POWERPC_MMU_601:
|
|
|
|
case POWERPC_MMU_SOFT_6xx:
|
|
|
|
case POWERPC_MMU_SOFT_74xx:
|
|
|
|
#if defined(TARGET_PPC64)
|
|
|
|
case POWERPC_MMU_64B:
|
2015-10-22 09:30:58 +02:00
|
|
|
case POWERPC_MMU_2_03:
|
2013-12-24 02:17:24 +01:00
|
|
|
case POWERPC_MMU_2_06:
|
2016-02-09 00:28:43 +01:00
|
|
|
case POWERPC_MMU_2_06a:
|
2015-10-22 09:30:58 +02:00
|
|
|
case POWERPC_MMU_2_07:
|
2016-02-09 00:28:43 +01:00
|
|
|
case POWERPC_MMU_2_07a:
|
2011-04-30 00:10:23 +02:00
|
|
|
#endif
|
2013-12-24 02:17:24 +01:00
|
|
|
cpu_fprintf(f, " SDR1 " TARGET_FMT_lx " DAR " TARGET_FMT_lx
|
|
|
|
" DSISR " TARGET_FMT_lx "\n", env->spr[SPR_SDR1],
|
|
|
|
env->spr[SPR_DAR], env->spr[SPR_DSISR]);
|
2011-04-30 00:10:23 +02:00
|
|
|
break;
|
2011-04-30 23:34:58 +02:00
|
|
|
case POWERPC_MMU_BOOKE206:
|
2011-04-30 00:10:23 +02:00
|
|
|
cpu_fprintf(f, " MAS0 " TARGET_FMT_lx " MAS1 " TARGET_FMT_lx
|
|
|
|
" MAS2 " TARGET_FMT_lx " MAS3 " TARGET_FMT_lx "\n",
|
|
|
|
env->spr[SPR_BOOKE_MAS0], env->spr[SPR_BOOKE_MAS1],
|
|
|
|
env->spr[SPR_BOOKE_MAS2], env->spr[SPR_BOOKE_MAS3]);
|
|
|
|
|
|
|
|
cpu_fprintf(f, " MAS4 " TARGET_FMT_lx " MAS6 " TARGET_FMT_lx
|
|
|
|
" MAS7 " TARGET_FMT_lx " PID " TARGET_FMT_lx "\n",
|
|
|
|
env->spr[SPR_BOOKE_MAS4], env->spr[SPR_BOOKE_MAS6],
|
|
|
|
env->spr[SPR_BOOKE_MAS7], env->spr[SPR_BOOKE_PID]);
|
|
|
|
|
|
|
|
cpu_fprintf(f, "MMUCFG " TARGET_FMT_lx " TLB0CFG " TARGET_FMT_lx
|
|
|
|
" TLB1CFG " TARGET_FMT_lx "\n",
|
|
|
|
env->spr[SPR_MMUCFG], env->spr[SPR_BOOKE_TLB0CFG],
|
|
|
|
env->spr[SPR_BOOKE_TLB1CFG]);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2007-10-07 17:43:50 +02:00
|
|
|
#endif
|
2003-11-23 15:55:54 +01:00
|
|
|
|
2005-07-02 22:59:34 +02:00
|
|
|
#undef RGPL
|
|
|
|
#undef RFPL
|
2003-11-23 15:55:54 +01:00
|
|
|
}
|
|
|
|
|
2013-05-27 01:33:50 +02:00
|
|
|
void ppc_cpu_dump_statistics(CPUState *cs, FILE*f,
|
|
|
|
fprintf_function cpu_fprintf, int flags)
|
2007-03-07 09:32:30 +01:00
|
|
|
{
|
|
|
|
#if defined(DO_PPC_STATISTICS)
|
2013-05-27 01:33:50 +02:00
|
|
|
PowerPCCPU *cpu = POWERPC_CPU(cs);
|
2009-10-01 23:12:16 +02:00
|
|
|
opc_handler_t **t1, **t2, **t3, *handler;
|
2007-03-07 09:32:30 +01:00
|
|
|
int op1, op2, op3;
|
|
|
|
|
2013-05-27 01:33:50 +02:00
|
|
|
t1 = cpu->env.opcodes;
|
2007-03-07 09:32:30 +01:00
|
|
|
for (op1 = 0; op1 < 64; op1++) {
|
|
|
|
handler = t1[op1];
|
|
|
|
if (is_indirect_opcode(handler)) {
|
|
|
|
t2 = ind_table(handler);
|
|
|
|
for (op2 = 0; op2 < 32; op2++) {
|
|
|
|
handler = t2[op2];
|
|
|
|
if (is_indirect_opcode(handler)) {
|
|
|
|
t3 = ind_table(handler);
|
|
|
|
for (op3 = 0; op3 < 32; op3++) {
|
|
|
|
handler = t3[op3];
|
|
|
|
if (handler->count == 0)
|
|
|
|
continue;
|
|
|
|
cpu_fprintf(f, "%02x %02x %02x (%02x %04d) %16s: "
|
2010-05-22 10:02:12 +02:00
|
|
|
"%016" PRIx64 " %" PRId64 "\n",
|
2007-03-07 09:32:30 +01:00
|
|
|
op1, op2, op3, op1, (op3 << 5) | op2,
|
|
|
|
handler->oname,
|
|
|
|
handler->count, handler->count);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (handler->count == 0)
|
|
|
|
continue;
|
|
|
|
cpu_fprintf(f, "%02x %02x (%02x %04d) %16s: "
|
2010-05-22 10:02:12 +02:00
|
|
|
"%016" PRIx64 " %" PRId64 "\n",
|
2007-03-07 09:32:30 +01:00
|
|
|
op1, op2, op1, op2, handler->oname,
|
|
|
|
handler->count, handler->count);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (handler->count == 0)
|
|
|
|
continue;
|
2010-05-22 10:02:12 +02:00
|
|
|
cpu_fprintf(f, "%02x (%02x ) %16s: %016" PRIx64
|
|
|
|
" %" PRId64 "\n",
|
2007-03-07 09:32:30 +01:00
|
|
|
op1, op1, handler->oname,
|
|
|
|
handler->count, handler->count);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2004-01-04 23:58:38 +01:00
|
|
|
/*****************************************************************************/
|
2015-09-02 05:01:40 +02:00
|
|
|
void gen_intermediate_code(CPUPPCState *env, struct TranslationBlock *tb)
|
2003-11-23 15:55:54 +01:00
|
|
|
{
|
2015-09-02 05:01:40 +02:00
|
|
|
PowerPCCPU *cpu = ppc_env_get_cpu(env);
|
2013-06-21 20:20:45 +02:00
|
|
|
CPUState *cs = CPU(cpu);
|
2004-05-21 14:59:32 +02:00
|
|
|
DisasContext ctx, *ctxp = &ctx;
|
2009-10-01 23:12:16 +02:00
|
|
|
opc_handler_t **table, *handler;
|
2005-01-04 00:43:32 +01:00
|
|
|
target_ulong pc_start;
|
2008-06-29 03:03:05 +02:00
|
|
|
int num_insns;
|
|
|
|
int max_insns;
|
2003-11-23 15:55:54 +01:00
|
|
|
|
|
|
|
pc_start = tb->pc;
|
2004-04-25 23:15:35 +02:00
|
|
|
ctx.nip = pc_start;
|
2003-11-23 15:55:54 +01:00
|
|
|
ctx.tb = tb;
|
2007-09-29 15:06:16 +02:00
|
|
|
ctx.exception = POWERPC_EXCP_NONE;
|
2005-07-02 22:59:34 +02:00
|
|
|
ctx.spr_cb = env->spr_cb;
|
2014-09-15 17:03:28 +02:00
|
|
|
ctx.pr = msr_pr;
|
|
|
|
ctx.hv = !msr_pr && msr_hv;
|
2008-12-08 19:11:21 +01:00
|
|
|
ctx.mem_idx = env->mmu_idx;
|
2013-04-20 10:56:22 +02:00
|
|
|
ctx.insns_flags = env->insns_flags;
|
|
|
|
ctx.insns_flags2 = env->insns_flags2;
|
2008-12-08 19:11:21 +01:00
|
|
|
ctx.access_type = -1;
|
|
|
|
ctx.le_mode = env->hflags & (1 << MSR_LE) ? 1 : 0;
|
2014-05-29 16:12:20 +02:00
|
|
|
ctx.default_tcg_memop_mask = ctx.le_mode ? MO_LE : MO_BE;
|
2007-03-17 15:02:15 +01:00
|
|
|
#if defined(TARGET_PPC64)
|
2012-06-20 21:20:29 +02:00
|
|
|
ctx.sf_mode = msr_is_64bit(env, env->msr);
|
2011-08-31 17:45:10 +02:00
|
|
|
ctx.has_cfar = !!(env->flags & POWERPC_FLAG_CFAR);
|
2004-01-04 23:58:38 +01:00
|
|
|
#endif
|
2005-02-16 00:06:19 +01:00
|
|
|
ctx.fpu_enabled = msr_fp;
|
2007-10-07 20:19:26 +02:00
|
|
|
if ((env->flags & POWERPC_FLAG_SPE) && msr_spe)
|
2007-10-07 16:41:00 +02:00
|
|
|
ctx.spe_enabled = msr_spe;
|
|
|
|
else
|
|
|
|
ctx.spe_enabled = 0;
|
2007-10-07 20:19:26 +02:00
|
|
|
if ((env->flags & POWERPC_FLAG_VRE) && msr_vr)
|
|
|
|
ctx.altivec_enabled = msr_vr;
|
|
|
|
else
|
|
|
|
ctx.altivec_enabled = 0;
|
2013-10-22 13:06:17 +02:00
|
|
|
if ((env->flags & POWERPC_FLAG_VSX) && msr_vsx) {
|
|
|
|
ctx.vsx_enabled = msr_vsx;
|
|
|
|
} else {
|
|
|
|
ctx.vsx_enabled = 0;
|
|
|
|
}
|
2014-12-18 17:34:31 +01:00
|
|
|
#if defined(TARGET_PPC64)
|
|
|
|
if ((env->flags & POWERPC_FLAG_TM) && msr_tm) {
|
|
|
|
ctx.tm_enabled = msr_tm;
|
|
|
|
} else {
|
|
|
|
ctx.tm_enabled = 0;
|
|
|
|
}
|
|
|
|
#endif
|
2007-10-07 16:41:00 +02:00
|
|
|
if ((env->flags & POWERPC_FLAG_SE) && msr_se)
|
2008-05-11 01:28:14 +02:00
|
|
|
ctx.singlestep_enabled = CPU_SINGLE_STEP;
|
2007-10-07 16:41:00 +02:00
|
|
|
else
|
2008-05-11 01:28:14 +02:00
|
|
|
ctx.singlestep_enabled = 0;
|
2007-10-07 16:41:00 +02:00
|
|
|
if ((env->flags & POWERPC_FLAG_BE) && msr_be)
|
2008-05-11 01:28:14 +02:00
|
|
|
ctx.singlestep_enabled |= CPU_BRANCH_STEP;
|
2013-06-21 20:20:45 +02:00
|
|
|
if (unlikely(cs->singlestep_enabled)) {
|
2008-05-11 01:28:14 +02:00
|
|
|
ctx.singlestep_enabled |= GDBSTUB_SINGLE_STEP;
|
2013-06-21 20:20:45 +02:00
|
|
|
}
|
2005-07-02 22:59:34 +02:00
|
|
|
#if defined (DO_SINGLE_STEP) && 0
|
2004-01-04 23:58:38 +01:00
|
|
|
/* Single step trace mode */
|
|
|
|
msr_se = 1;
|
|
|
|
#endif
|
2008-06-29 03:03:05 +02:00
|
|
|
num_insns = 0;
|
|
|
|
max_insns = tb->cflags & CF_COUNT_MASK;
|
2015-08-31 23:34:41 +02:00
|
|
|
if (max_insns == 0) {
|
2008-06-29 03:03:05 +02:00
|
|
|
max_insns = CF_COUNT_MASK;
|
2015-08-31 23:34:41 +02:00
|
|
|
}
|
|
|
|
if (max_insns > TCG_MAX_INSNS) {
|
|
|
|
max_insns = TCG_MAX_INSNS;
|
|
|
|
}
|
2008-06-29 03:03:05 +02:00
|
|
|
|
2014-11-26 11:40:05 +01:00
|
|
|
gen_tb_start(tb);
|
2014-01-19 17:28:33 +01:00
|
|
|
tcg_clear_temp_count();
|
2004-01-04 23:58:38 +01:00
|
|
|
/* Set env in case of segfault during code fetch */
|
2014-03-31 00:36:56 +02:00
|
|
|
while (ctx.exception == POWERPC_EXCP_NONE && !tcg_op_buf_full()) {
|
2015-08-29 21:59:29 +02:00
|
|
|
tcg_gen_insn_start(ctx.nip);
|
2015-09-17 23:25:46 +02:00
|
|
|
num_insns++;
|
2015-08-29 21:59:29 +02:00
|
|
|
|
2015-09-18 00:58:10 +02:00
|
|
|
if (unlikely(cpu_breakpoint_test(cs, ctx.nip, BP_ANY))) {
|
|
|
|
gen_debug_exception(ctxp);
|
2015-10-14 00:07:49 +02:00
|
|
|
/* The address covered by the breakpoint must be included in
|
|
|
|
[tb->pc, tb->pc + tb->size) in order to for it to be
|
|
|
|
properly cleared -- thus we increment the PC here so that
|
|
|
|
the logic setting tb->size below does the right thing. */
|
|
|
|
ctx.nip += 4;
|
2015-09-18 00:58:10 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2009-01-15 22:48:06 +01:00
|
|
|
LOG_DISAS("----------------\n");
|
2009-08-16 13:13:18 +02:00
|
|
|
LOG_DISAS("nip=" TARGET_FMT_lx " super=%d ir=%d\n",
|
2009-01-15 22:48:06 +01:00
|
|
|
ctx.nip, ctx.mem_idx, (int)msr_ir);
|
2015-09-17 23:25:46 +02:00
|
|
|
if (num_insns == max_insns && (tb->cflags & CF_LAST_IO))
|
2008-06-29 03:03:05 +02:00
|
|
|
gen_io_start();
|
2014-05-29 16:12:20 +02:00
|
|
|
if (unlikely(need_byteswap(&ctx))) {
|
2012-05-30 06:23:40 +02:00
|
|
|
ctx.opcode = bswap32(cpu_ldl_code(env, ctx.nip));
|
2007-11-04 03:55:33 +01:00
|
|
|
} else {
|
2012-05-30 06:23:40 +02:00
|
|
|
ctx.opcode = cpu_ldl_code(env, ctx.nip);
|
2005-04-23 20:16:07 +02:00
|
|
|
}
|
2009-01-15 22:48:06 +01:00
|
|
|
LOG_DISAS("translate opcode %08x (%02x %02x %02x) (%s)\n",
|
2004-01-04 23:58:38 +01:00
|
|
|
ctx.opcode, opc1(ctx.opcode), opc2(ctx.opcode),
|
2013-01-27 04:32:02 +01:00
|
|
|
opc3(ctx.opcode), ctx.le_mode ? "little" : "big");
|
2004-04-25 23:15:35 +02:00
|
|
|
ctx.nip += 4;
|
2005-07-02 22:59:34 +02:00
|
|
|
table = env->opcodes;
|
2003-11-23 15:55:54 +01:00
|
|
|
handler = table[opc1(ctx.opcode)];
|
|
|
|
if (is_indirect_opcode(handler)) {
|
|
|
|
table = ind_table(handler);
|
|
|
|
handler = table[opc2(ctx.opcode)];
|
|
|
|
if (is_indirect_opcode(handler)) {
|
|
|
|
table = ind_table(handler);
|
|
|
|
handler = table[opc3(ctx.opcode)];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* Is opcode *REALLY* valid ? */
|
2007-03-07 09:32:30 +01:00
|
|
|
if (unlikely(handler->handler == &gen_invalid)) {
|
2015-11-13 13:34:23 +01:00
|
|
|
qemu_log_mask(LOG_GUEST_ERROR, "invalid/unsupported opcode: "
|
|
|
|
"%02x - %02x - %02x (%08x) " TARGET_FMT_lx " %d\n",
|
|
|
|
opc1(ctx.opcode), opc2(ctx.opcode),
|
|
|
|
opc3(ctx.opcode), ctx.opcode, ctx.nip - 4, (int)msr_ir);
|
2007-03-07 09:32:30 +01:00
|
|
|
} else {
|
2011-09-28 07:54:05 +02:00
|
|
|
uint32_t inval;
|
|
|
|
|
|
|
|
if (unlikely(handler->type & (PPC_SPE | PPC_SPE_SINGLE | PPC_SPE_DOUBLE) && Rc(ctx.opcode))) {
|
|
|
|
inval = handler->inval2;
|
|
|
|
} else {
|
|
|
|
inval = handler->inval1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (unlikely((ctx.opcode & inval) != 0)) {
|
2015-11-13 13:34:23 +01:00
|
|
|
qemu_log_mask(LOG_GUEST_ERROR, "invalid bits: %08x for opcode: "
|
|
|
|
"%02x - %02x - %02x (%08x) " TARGET_FMT_lx "\n",
|
|
|
|
ctx.opcode & inval, opc1(ctx.opcode),
|
|
|
|
opc2(ctx.opcode), opc3(ctx.opcode),
|
|
|
|
ctx.opcode, ctx.nip - 4);
|
2008-12-11 23:42:14 +01:00
|
|
|
gen_inval_exception(ctxp, POWERPC_EXCP_INVAL_INVAL);
|
2004-05-24 00:18:12 +02:00
|
|
|
break;
|
2003-11-23 15:55:54 +01:00
|
|
|
}
|
|
|
|
}
|
2004-05-24 00:18:12 +02:00
|
|
|
(*(handler->handler))(&ctx);
|
2007-03-07 09:32:30 +01:00
|
|
|
#if defined(DO_PPC_STATISTICS)
|
|
|
|
handler->count++;
|
|
|
|
#endif
|
2004-01-04 23:58:38 +01:00
|
|
|
/* Check trace mode exceptions */
|
2008-05-11 01:28:14 +02:00
|
|
|
if (unlikely(ctx.singlestep_enabled & CPU_SINGLE_STEP &&
|
|
|
|
(ctx.nip <= 0x100 || ctx.nip > 0xF00) &&
|
|
|
|
ctx.exception != POWERPC_SYSCALL &&
|
|
|
|
ctx.exception != POWERPC_EXCP_TRAP &&
|
|
|
|
ctx.exception != POWERPC_EXCP_BRANCH)) {
|
2008-12-11 23:42:14 +01:00
|
|
|
gen_exception(ctxp, POWERPC_EXCP_TRACE);
|
2007-10-07 16:41:00 +02:00
|
|
|
} else if (unlikely(((ctx.nip & (TARGET_PAGE_SIZE - 1)) == 0) ||
|
2013-06-21 20:20:45 +02:00
|
|
|
(cs->singlestep_enabled) ||
|
2009-04-05 22:08:59 +02:00
|
|
|
singlestep ||
|
2008-06-29 03:03:05 +02:00
|
|
|
num_insns >= max_insns)) {
|
2007-10-07 16:41:00 +02:00
|
|
|
/* if we reach a page boundary or are single stepping, stop
|
|
|
|
* generation
|
|
|
|
*/
|
2005-06-05 00:22:27 +02:00
|
|
|
break;
|
2007-03-07 09:32:30 +01:00
|
|
|
}
|
2014-01-19 17:28:33 +01:00
|
|
|
if (tcg_check_temp_count()) {
|
|
|
|
fprintf(stderr, "Opcode %02x %02x %02x (%08x) leaked temporaries\n",
|
|
|
|
opc1(ctx.opcode), opc2(ctx.opcode), opc3(ctx.opcode),
|
|
|
|
ctx.opcode);
|
|
|
|
exit(1);
|
|
|
|
}
|
2005-07-02 22:59:34 +02:00
|
|
|
}
|
2008-06-29 03:03:05 +02:00
|
|
|
if (tb->cflags & CF_LAST_IO)
|
|
|
|
gen_io_end();
|
2007-09-29 15:06:16 +02:00
|
|
|
if (ctx.exception == POWERPC_EXCP_NONE) {
|
2005-11-20 11:31:08 +01:00
|
|
|
gen_goto_tb(&ctx, 0, ctx.nip);
|
2007-09-29 15:06:16 +02:00
|
|
|
} else if (ctx.exception != POWERPC_EXCP_BRANCH) {
|
2013-06-21 20:20:45 +02:00
|
|
|
if (unlikely(cs->singlestep_enabled)) {
|
2008-12-11 23:42:14 +01:00
|
|
|
gen_debug_exception(ctxp);
|
2008-05-11 01:28:14 +02:00
|
|
|
}
|
2007-03-07 09:32:30 +01:00
|
|
|
/* Generate the return instruction */
|
2008-02-01 11:50:11 +01:00
|
|
|
tcg_gen_exit_tb(0);
|
2004-01-04 23:58:38 +01:00
|
|
|
}
|
2013-02-22 19:10:05 +01:00
|
|
|
gen_tb_end(tb, num_insns);
|
2014-03-30 23:50:30 +02:00
|
|
|
|
2015-09-02 05:01:40 +02:00
|
|
|
tb->size = ctx.nip - pc_start;
|
|
|
|
tb->icount = num_insns;
|
|
|
|
|
2007-03-17 15:02:15 +01:00
|
|
|
#if defined(DEBUG_DISAS)
|
2009-01-15 23:36:53 +01:00
|
|
|
if (qemu_loglevel_mask(CPU_LOG_TB_IN_ASM)) {
|
2007-03-07 09:32:30 +01:00
|
|
|
int flags;
|
2007-09-29 14:01:46 +02:00
|
|
|
flags = env->bfd_mach;
|
2008-12-08 19:11:21 +01:00
|
|
|
flags |= ctx.le_mode << 16;
|
2009-01-15 23:34:14 +01:00
|
|
|
qemu_log("IN: %s\n", lookup_symbol(pc_start));
|
2015-05-24 23:20:41 +02:00
|
|
|
log_target_disas(cs, pc_start, ctx.nip - pc_start, flags);
|
2009-01-15 23:34:14 +01:00
|
|
|
qemu_log("\n");
|
2004-05-21 14:59:32 +02:00
|
|
|
}
|
2003-11-23 15:55:54 +01:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2015-09-02 00:51:12 +02:00
|
|
|
void restore_state_to_opc(CPUPPCState *env, TranslationBlock *tb,
|
|
|
|
target_ulong *data)
|
2008-04-28 02:32:32 +02:00
|
|
|
{
|
2015-09-02 00:51:12 +02:00
|
|
|
env->nip = data[0];
|
2008-04-28 02:32:32 +02:00
|
|
|
}
|