2003-11-23 17:55:54 +03:00
|
|
|
/*
|
2005-07-03 00:59:34 +04:00
|
|
|
* PowerPC emulation for qemu: main translation routines.
|
2007-09-17 01:08:06 +04:00
|
|
|
*
|
2007-03-07 11:32:30 +03:00
|
|
|
* Copyright (c) 2003-2007 Jocelyn Mayer
|
2011-04-30 02:10:23 +04:00
|
|
|
* Copyright (C) 2011 Freescale Semiconductor, Inc.
|
2003-11-23 17:55:54 +03: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-17 00:47:01 +04:00
|
|
|
* License along with this library; if not, see <http://www.gnu.org/licenses/>.
|
2003-11-23 17:55:54 +03:00
|
|
|
*/
|
2004-05-20 17:10:49 +04:00
|
|
|
|
2016-01-26 21:16:58 +03:00
|
|
|
#include "qemu/osdep.h"
|
2003-11-23 17:55:54 +03:00
|
|
|
#include "cpu.h"
|
2012-10-24 13:12:21 +04:00
|
|
|
#include "disas/disas.h"
|
2016-03-15 15:18:37 +03:00
|
|
|
#include "exec/exec-all.h"
|
2008-02-01 13:50:11 +03:00
|
|
|
#include "tcg-op.h"
|
2012-12-17 21:20:00 +04:00
|
|
|
#include "qemu/host-utils.h"
|
2014-03-28 22:42:10 +04:00
|
|
|
#include "exec/cpu_ldst.h"
|
2003-11-23 17:55:54 +03:00
|
|
|
|
2014-04-08 09:31:41 +04:00
|
|
|
#include "exec/helper-proto.h"
|
|
|
|
#include "exec/helper-gen.h"
|
2008-11-17 17:43:54 +03:00
|
|
|
|
2014-05-30 16:12:25 +04:00
|
|
|
#include "trace-tcg.h"
|
2016-01-07 16:55:28 +03:00
|
|
|
#include "exec/log.h"
|
2014-05-30 16:12:25 +04:00
|
|
|
|
|
|
|
|
2008-05-11 03:28:14 +04: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 03:54:22 +04:00
|
|
|
/* Include definitions for instructions classes and implementations flags */
|
2004-05-21 16:59:32 +04:00
|
|
|
//#define PPC_DEBUG_DISAS
|
2007-03-07 11:32:30 +03:00
|
|
|
//#define DO_PPC_STATISTICS
|
2003-11-23 17:55:54 +03:00
|
|
|
|
2009-01-16 00:48:06 +03:00
|
|
|
#ifdef PPC_DEBUG_DISAS
|
2009-01-16 01:34:14 +03:00
|
|
|
# define LOG_DISAS(...) qemu_log_mask(CPU_LOG_TB_IN_ASM, ## __VA_ARGS__)
|
2009-01-16 00:48:06 +03: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 03:54:22 +04:00
|
|
|
/*****************************************************************************/
|
|
|
|
/* Code translation helpers */
|
2005-10-31 00:39:19 +03:00
|
|
|
|
2008-09-04 09:25:47 +04:00
|
|
|
/* global register indexes */
|
2016-02-25 19:43:15 +03:00
|
|
|
static TCGv_env cpu_env;
|
2008-09-04 18:43:45 +04:00
|
|
|
static char cpu_reg_names[10*3 + 22*4 /* GPR */
|
|
|
|
+ 10*4 + 22*5 /* SPE GPRh */
|
2008-09-04 18:43:54 +04:00
|
|
|
+ 10*4 + 22*5 /* FPR */
|
2008-09-04 21:06:47 +04:00
|
|
|
+ 2*(10*6 + 22*7) /* AVRh, AVRl */
|
2013-10-22 15:07:41 +04:00
|
|
|
+ 10*5 + 22*6 /* VSR */
|
2008-09-04 21:06:47 +04:00
|
|
|
+ 8*5 /* CRF */];
|
2008-09-04 09:25:47 +04:00
|
|
|
static TCGv cpu_gpr[32];
|
|
|
|
static TCGv cpu_gprh[32];
|
2008-11-17 17:43:54 +03:00
|
|
|
static TCGv_i64 cpu_fpr[32];
|
|
|
|
static TCGv_i64 cpu_avrh[32], cpu_avrl[32];
|
2013-10-22 15:07:41 +04:00
|
|
|
static TCGv_i64 cpu_vsr[32];
|
2008-11-17 17:43:54 +03:00
|
|
|
static TCGv_i32 cpu_crf[8];
|
2008-09-04 22:06:03 +04:00
|
|
|
static TCGv cpu_nip;
|
2008-12-06 16:03:35 +03:00
|
|
|
static TCGv cpu_msr;
|
2008-09-14 22:30:23 +04:00
|
|
|
static TCGv cpu_ctr;
|
|
|
|
static TCGv cpu_lr;
|
2011-08-31 19:45:10 +04:00
|
|
|
#if defined(TARGET_PPC64)
|
|
|
|
static TCGv cpu_cfar;
|
|
|
|
#endif
|
2013-02-20 11:52:13 +04:00
|
|
|
static TCGv cpu_xer, cpu_so, cpu_ov, cpu_ca;
|
2008-11-30 19:24:39 +03:00
|
|
|
static TCGv cpu_reserve;
|
2012-10-29 21:24:59 +04:00
|
|
|
static TCGv cpu_fpscr;
|
2008-11-23 19:30:40 +03:00
|
|
|
static TCGv_i32 cpu_access_type;
|
2008-09-04 09:25:47 +04:00
|
|
|
|
2012-12-17 21:19:49 +04:00
|
|
|
#include "exec/gen-icount.h"
|
2008-06-29 05:03:05 +04:00
|
|
|
|
|
|
|
void ppc_translate_init(void)
|
|
|
|
{
|
2008-09-04 09:25:47 +04:00
|
|
|
int i;
|
|
|
|
char* p;
|
2009-04-13 20:06:19 +04:00
|
|
|
size_t cpu_reg_names_size;
|
2008-06-29 16:29:56 +04:00
|
|
|
static int done_init = 0;
|
2008-09-04 09:25:47 +04:00
|
|
|
|
2008-06-29 05:03:05 +04:00
|
|
|
if (done_init)
|
|
|
|
return;
|
2008-09-04 09:25:47 +04:00
|
|
|
|
2008-11-17 17:43:54 +03:00
|
|
|
cpu_env = tcg_global_reg_new_ptr(TCG_AREG0, "env");
|
2016-06-09 20:31:41 +03:00
|
|
|
tcg_ctx.tcg_env = cpu_env;
|
2008-11-17 17:43:54 +03:00
|
|
|
|
2008-09-04 09:25:47 +04:00
|
|
|
p = cpu_reg_names;
|
2009-04-13 20:06:19 +04:00
|
|
|
cpu_reg_names_size = sizeof(cpu_reg_names);
|
2008-09-04 21:06:47 +04:00
|
|
|
|
|
|
|
for (i = 0; i < 8; i++) {
|
2009-04-13 20:06:19 +04:00
|
|
|
snprintf(p, cpu_reg_names_size, "crf%d", i);
|
2013-09-18 23:53:09 +04:00
|
|
|
cpu_crf[i] = tcg_global_mem_new_i32(cpu_env,
|
2012-03-14 04:38:22 +04:00
|
|
|
offsetof(CPUPPCState, crf[i]), p);
|
2008-09-04 21:06:47 +04:00
|
|
|
p += 5;
|
2009-04-13 20:06:19 +04:00
|
|
|
cpu_reg_names_size -= 5;
|
2008-09-04 21:06:47 +04:00
|
|
|
}
|
|
|
|
|
2008-09-04 09:25:47 +04:00
|
|
|
for (i = 0; i < 32; i++) {
|
2009-04-13 20:06:19 +04:00
|
|
|
snprintf(p, cpu_reg_names_size, "r%d", i);
|
2013-09-18 23:53:09 +04:00
|
|
|
cpu_gpr[i] = tcg_global_mem_new(cpu_env,
|
2012-03-14 04:38:22 +04:00
|
|
|
offsetof(CPUPPCState, gpr[i]), p);
|
2008-09-04 09:25:47 +04:00
|
|
|
p += (i < 10) ? 3 : 4;
|
2009-04-13 20:06:19 +04:00
|
|
|
cpu_reg_names_size -= (i < 10) ? 3 : 4;
|
|
|
|
snprintf(p, cpu_reg_names_size, "r%dH", i);
|
2013-09-18 23:53:09 +04:00
|
|
|
cpu_gprh[i] = tcg_global_mem_new(cpu_env,
|
2014-06-05 00:58:50 +04:00
|
|
|
offsetof(CPUPPCState, gprh[i]), p);
|
2008-09-04 09:25:47 +04:00
|
|
|
p += (i < 10) ? 4 : 5;
|
2009-04-13 20:06:19 +04:00
|
|
|
cpu_reg_names_size -= (i < 10) ? 4 : 5;
|
2008-09-04 18:43:45 +04:00
|
|
|
|
2009-04-13 20:06:19 +04:00
|
|
|
snprintf(p, cpu_reg_names_size, "fp%d", i);
|
2013-09-18 23:53:09 +04:00
|
|
|
cpu_fpr[i] = tcg_global_mem_new_i64(cpu_env,
|
2012-03-14 04:38:22 +04:00
|
|
|
offsetof(CPUPPCState, fpr[i]), p);
|
2008-09-04 19:49:12 +04:00
|
|
|
p += (i < 10) ? 4 : 5;
|
2009-04-13 20:06:19 +04:00
|
|
|
cpu_reg_names_size -= (i < 10) ? 4 : 5;
|
2008-09-04 18:43:54 +04:00
|
|
|
|
2009-04-13 20:06:19 +04:00
|
|
|
snprintf(p, cpu_reg_names_size, "avr%dH", i);
|
2009-07-27 18:13:06 +04:00
|
|
|
#ifdef HOST_WORDS_BIGENDIAN
|
2013-09-18 23:53:09 +04:00
|
|
|
cpu_avrh[i] = tcg_global_mem_new_i64(cpu_env,
|
2012-03-14 04:38:22 +04:00
|
|
|
offsetof(CPUPPCState, avr[i].u64[0]), p);
|
2008-11-24 11:47:21 +03:00
|
|
|
#else
|
2013-09-18 23:53:09 +04:00
|
|
|
cpu_avrh[i] = tcg_global_mem_new_i64(cpu_env,
|
2012-03-14 04:38:22 +04:00
|
|
|
offsetof(CPUPPCState, avr[i].u64[1]), p);
|
2008-11-24 11:47:21 +03:00
|
|
|
#endif
|
2008-09-04 18:43:45 +04:00
|
|
|
p += (i < 10) ? 6 : 7;
|
2009-04-13 20:06:19 +04:00
|
|
|
cpu_reg_names_size -= (i < 10) ? 6 : 7;
|
2008-09-04 19:49:12 +04:00
|
|
|
|
2009-04-13 20:06:19 +04:00
|
|
|
snprintf(p, cpu_reg_names_size, "avr%dL", i);
|
2009-07-27 18:13:06 +04:00
|
|
|
#ifdef HOST_WORDS_BIGENDIAN
|
2013-09-18 23:53:09 +04:00
|
|
|
cpu_avrl[i] = tcg_global_mem_new_i64(cpu_env,
|
2012-03-14 04:38:22 +04:00
|
|
|
offsetof(CPUPPCState, avr[i].u64[1]), p);
|
2008-11-24 11:47:21 +03:00
|
|
|
#else
|
2013-09-18 23:53:09 +04:00
|
|
|
cpu_avrl[i] = tcg_global_mem_new_i64(cpu_env,
|
2012-03-14 04:38:22 +04:00
|
|
|
offsetof(CPUPPCState, avr[i].u64[0]), p);
|
2008-11-24 11:47:21 +03:00
|
|
|
#endif
|
2008-09-04 18:43:45 +04:00
|
|
|
p += (i < 10) ? 6 : 7;
|
2009-04-13 20:06:19 +04:00
|
|
|
cpu_reg_names_size -= (i < 10) ? 6 : 7;
|
2013-10-22 15:07:41 +04:00
|
|
|
snprintf(p, cpu_reg_names_size, "vsr%d", i);
|
2013-09-18 23:53:09 +04:00
|
|
|
cpu_vsr[i] = tcg_global_mem_new_i64(cpu_env,
|
|
|
|
offsetof(CPUPPCState, vsr[i]), p);
|
2013-10-22 15:07:41 +04:00
|
|
|
p += (i < 10) ? 5 : 6;
|
|
|
|
cpu_reg_names_size -= (i < 10) ? 5 : 6;
|
2008-09-04 09:25:47 +04:00
|
|
|
}
|
2008-08-29 01:01:45 +04:00
|
|
|
|
2013-09-18 23:53:09 +04:00
|
|
|
cpu_nip = tcg_global_mem_new(cpu_env,
|
2012-03-14 04:38:22 +04:00
|
|
|
offsetof(CPUPPCState, nip), "nip");
|
2008-09-04 22:06:03 +04:00
|
|
|
|
2013-09-18 23:53:09 +04:00
|
|
|
cpu_msr = tcg_global_mem_new(cpu_env,
|
2012-03-14 04:38:22 +04:00
|
|
|
offsetof(CPUPPCState, msr), "msr");
|
2008-12-06 16:03:35 +03:00
|
|
|
|
2013-09-18 23:53:09 +04:00
|
|
|
cpu_ctr = tcg_global_mem_new(cpu_env,
|
2012-03-14 04:38:22 +04:00
|
|
|
offsetof(CPUPPCState, ctr), "ctr");
|
2008-09-14 22:30:23 +04:00
|
|
|
|
2013-09-18 23:53:09 +04:00
|
|
|
cpu_lr = tcg_global_mem_new(cpu_env,
|
2012-03-14 04:38:22 +04:00
|
|
|
offsetof(CPUPPCState, lr), "lr");
|
2008-09-14 22:30:23 +04:00
|
|
|
|
2011-08-31 19:45:10 +04:00
|
|
|
#if defined(TARGET_PPC64)
|
2013-09-18 23:53:09 +04:00
|
|
|
cpu_cfar = tcg_global_mem_new(cpu_env,
|
2012-03-14 04:38:22 +04:00
|
|
|
offsetof(CPUPPCState, cfar), "cfar");
|
2011-08-31 19:45:10 +04:00
|
|
|
#endif
|
|
|
|
|
2013-09-18 23:53:09 +04:00
|
|
|
cpu_xer = tcg_global_mem_new(cpu_env,
|
2012-03-14 04:38:22 +04:00
|
|
|
offsetof(CPUPPCState, xer), "xer");
|
2013-09-18 23:53:09 +04:00
|
|
|
cpu_so = tcg_global_mem_new(cpu_env,
|
2013-02-20 11:52:13 +04:00
|
|
|
offsetof(CPUPPCState, so), "SO");
|
2013-09-18 23:53:09 +04:00
|
|
|
cpu_ov = tcg_global_mem_new(cpu_env,
|
2013-02-20 11:52:13 +04:00
|
|
|
offsetof(CPUPPCState, ov), "OV");
|
2013-09-18 23:53:09 +04:00
|
|
|
cpu_ca = tcg_global_mem_new(cpu_env,
|
2013-02-20 11:52:13 +04:00
|
|
|
offsetof(CPUPPCState, ca), "CA");
|
2008-10-21 15:28:46 +04:00
|
|
|
|
2013-09-18 23:53:09 +04:00
|
|
|
cpu_reserve = tcg_global_mem_new(cpu_env,
|
2012-03-14 04:38:22 +04:00
|
|
|
offsetof(CPUPPCState, reserve_addr),
|
2009-08-03 19:43:25 +04:00
|
|
|
"reserve_addr");
|
2008-11-30 19:24:39 +03:00
|
|
|
|
2013-09-18 23:53:09 +04:00
|
|
|
cpu_fpscr = tcg_global_mem_new(cpu_env,
|
2012-10-29 21:24:59 +04:00
|
|
|
offsetof(CPUPPCState, fpscr), "fpscr");
|
2008-10-21 15:31:14 +04:00
|
|
|
|
2013-09-18 23:53:09 +04:00
|
|
|
cpu_access_type = tcg_global_mem_new_i32(cpu_env,
|
2012-03-14 04:38:22 +04:00
|
|
|
offsetof(CPUPPCState, access_type), "access_type");
|
2008-11-23 19:30:40 +03:00
|
|
|
|
2008-06-29 05:03:05 +04:00
|
|
|
done_init = 1;
|
|
|
|
}
|
|
|
|
|
2003-11-23 17:55:54 +03:00
|
|
|
/* internal defines */
|
2014-11-26 13:39:48 +03:00
|
|
|
struct DisasContext {
|
2003-11-23 17:55:54 +03:00
|
|
|
struct TranslationBlock *tb;
|
2005-01-04 02:43:32 +03:00
|
|
|
target_ulong nip;
|
2003-11-23 17:55:54 +03:00
|
|
|
uint32_t opcode;
|
2004-01-05 01:58:38 +03:00
|
|
|
uint32_t exception;
|
2005-02-16 02:06:19 +03:00
|
|
|
/* Routine used to access memory */
|
2016-06-22 00:48:53 +03:00
|
|
|
bool pr, hv, dr, le_mode;
|
2016-06-07 05:50:22 +03:00
|
|
|
bool lazy_tlb_flush;
|
2016-07-27 09:56:46 +03:00
|
|
|
bool need_access_type;
|
2005-02-16 02:06:19 +03:00
|
|
|
int mem_idx;
|
2008-12-08 21:11:21 +03:00
|
|
|
int access_type;
|
2005-02-16 02:06:19 +03:00
|
|
|
/* Translation flags */
|
2014-05-29 18:12:20 +04:00
|
|
|
TCGMemOp default_tcg_memop_mask;
|
2007-03-17 17:02:15 +03:00
|
|
|
#if defined(TARGET_PPC64)
|
2016-06-22 00:48:53 +03:00
|
|
|
bool sf_mode;
|
|
|
|
bool has_cfar;
|
2004-01-05 01:58:38 +03:00
|
|
|
#endif
|
2016-06-22 00:48:53 +03:00
|
|
|
bool fpu_enabled;
|
|
|
|
bool altivec_enabled;
|
|
|
|
bool vsx_enabled;
|
|
|
|
bool spe_enabled;
|
|
|
|
bool tm_enabled;
|
2009-10-02 01:12:16 +04:00
|
|
|
ppc_spr_t *spr_cb; /* Needed to check rights for mfspr/mtspr */
|
2006-05-23 01:50:20 +04:00
|
|
|
int singlestep_enabled;
|
2013-04-20 12:56:22 +04:00
|
|
|
uint64_t insns_flags;
|
|
|
|
uint64_t insns_flags2;
|
2014-11-26 13:39:48 +03:00
|
|
|
};
|
2003-11-23 17:55:54 +03:00
|
|
|
|
2014-05-29 18:12:20 +04: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 14:01:45 +04: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-02 01:12:16 +04:00
|
|
|
struct opc_handler_t {
|
2011-09-28 09:54:05 +04: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-05 01:58:38 +03:00
|
|
|
/* instruction type */
|
2007-03-21 01:11:31 +03:00
|
|
|
uint64_t type;
|
2011-05-01 02:00:58 +04:00
|
|
|
/* extended instruction type */
|
|
|
|
uint64_t type2;
|
2003-11-23 17:55:54 +03: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 03:54:22 +04:00
|
|
|
#if defined(DO_PPC_STATISTICS) || defined(PPC_DUMP_CPU)
|
2008-09-20 12:07:15 +04: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 03:54:22 +04:00
|
|
|
#endif
|
|
|
|
#if defined(DO_PPC_STATISTICS)
|
2007-03-07 11:32:30 +03:00
|
|
|
uint64_t count;
|
|
|
|
#endif
|
2005-07-03 00:59:34 +04:00
|
|
|
};
|
2003-11-23 17:55:54 +03:00
|
|
|
|
2009-08-16 13:06:54 +04:00
|
|
|
static inline void gen_set_access_type(DisasContext *ctx, int access_type)
|
2008-11-23 19:30:40 +03:00
|
|
|
{
|
2016-07-27 09:56:46 +03:00
|
|
|
if (ctx->need_access_type && ctx->access_type != access_type) {
|
2008-12-08 21:11:21 +03:00
|
|
|
tcg_gen_movi_i32(cpu_access_type, access_type);
|
|
|
|
ctx->access_type = access_type;
|
|
|
|
}
|
2008-11-23 19:30:40 +03:00
|
|
|
}
|
|
|
|
|
2009-08-16 13:06:54 +04:00
|
|
|
static inline void gen_update_nip(DisasContext *ctx, target_ulong nip)
|
2007-03-17 17:02:15 +03:00
|
|
|
{
|
2013-03-21 14:01:46 +04:00
|
|
|
if (NARROW_MODE(ctx)) {
|
|
|
|
nip = (uint32_t)nip;
|
|
|
|
}
|
|
|
|
tcg_gen_movi_tl(cpu_nip, nip);
|
2007-03-17 17:02:15 +03:00
|
|
|
}
|
|
|
|
|
2016-06-22 00:48:54 +03:00
|
|
|
static void gen_exception_err(DisasContext *ctx, uint32_t excp, uint32_t error)
|
2008-12-12 01:42:14 +03:00
|
|
|
{
|
|
|
|
TCGv_i32 t0, t1;
|
2016-07-27 09:56:32 +03:00
|
|
|
|
|
|
|
/* These are all synchronous exceptions, we set the PC back to
|
|
|
|
* the faulting instruction
|
|
|
|
*/
|
2008-12-12 01:42:14 +03:00
|
|
|
if (ctx->exception == POWERPC_EXCP_NONE) {
|
2016-07-27 09:56:32 +03:00
|
|
|
gen_update_nip(ctx, ctx->nip - 4);
|
2008-12-12 01:42:14 +03:00
|
|
|
}
|
|
|
|
t0 = tcg_const_i32(excp);
|
|
|
|
t1 = tcg_const_i32(error);
|
2012-05-30 08:23:23 +04:00
|
|
|
gen_helper_raise_exception_err(cpu_env, t0, t1);
|
2008-12-12 01:42:14 +03:00
|
|
|
tcg_temp_free_i32(t0);
|
|
|
|
tcg_temp_free_i32(t1);
|
|
|
|
ctx->exception = (excp);
|
|
|
|
}
|
2007-09-29 17:06:16 +04:00
|
|
|
|
2016-06-22 00:48:54 +03:00
|
|
|
static void gen_exception(DisasContext *ctx, uint32_t excp)
|
2008-12-12 01:42:14 +03:00
|
|
|
{
|
|
|
|
TCGv_i32 t0;
|
2016-07-27 09:56:32 +03:00
|
|
|
|
|
|
|
/* These are all synchronous exceptions, we set the PC back to
|
|
|
|
* the faulting instruction
|
|
|
|
*/
|
2008-12-12 01:42:14 +03:00
|
|
|
if (ctx->exception == POWERPC_EXCP_NONE) {
|
2016-07-27 09:56:32 +03:00
|
|
|
gen_update_nip(ctx, ctx->nip - 4);
|
2008-12-12 01:42:14 +03:00
|
|
|
}
|
|
|
|
t0 = tcg_const_i32(excp);
|
2012-05-30 08:23:23 +04:00
|
|
|
gen_helper_raise_exception(cpu_env, t0);
|
2008-12-12 01:42:14 +03:00
|
|
|
tcg_temp_free_i32(t0);
|
|
|
|
ctx->exception = (excp);
|
|
|
|
}
|
2007-09-29 17:06:16 +04:00
|
|
|
|
2016-07-27 09:56:32 +03:00
|
|
|
static void gen_exception_nip(DisasContext *ctx, uint32_t excp,
|
|
|
|
target_ulong nip)
|
|
|
|
{
|
|
|
|
TCGv_i32 t0;
|
|
|
|
|
|
|
|
gen_update_nip(ctx, nip);
|
|
|
|
t0 = tcg_const_i32(excp);
|
|
|
|
gen_helper_raise_exception(cpu_env, t0);
|
|
|
|
tcg_temp_free_i32(t0);
|
|
|
|
ctx->exception = (excp);
|
|
|
|
}
|
|
|
|
|
2016-06-22 00:48:54 +03:00
|
|
|
static void gen_debug_exception(DisasContext *ctx)
|
2008-12-12 01:42:14 +03:00
|
|
|
{
|
|
|
|
TCGv_i32 t0;
|
2009-02-19 23:17:09 +03:00
|
|
|
|
2016-07-27 09:56:32 +03:00
|
|
|
/* These are all synchronous exceptions, we set the PC back to
|
|
|
|
* the faulting instruction
|
|
|
|
*/
|
2011-08-10 05:41:48 +04:00
|
|
|
if ((ctx->exception != POWERPC_EXCP_BRANCH) &&
|
|
|
|
(ctx->exception != POWERPC_EXCP_SYNC)) {
|
2016-07-27 09:56:32 +03:00
|
|
|
gen_update_nip(ctx, ctx->nip - 4);
|
2011-08-10 05:41:48 +04:00
|
|
|
}
|
2008-12-12 01:42:14 +03:00
|
|
|
t0 = tcg_const_i32(EXCP_DEBUG);
|
2012-05-30 08:23:23 +04:00
|
|
|
gen_helper_raise_exception(cpu_env, t0);
|
2008-12-12 01:42:14 +03:00
|
|
|
tcg_temp_free_i32(t0);
|
|
|
|
}
|
2004-01-05 01:58:38 +03:00
|
|
|
|
2009-08-16 13:06:54 +04:00
|
|
|
static inline void gen_inval_exception(DisasContext *ctx, uint32_t error)
|
2008-12-12 01:42:14 +03:00
|
|
|
{
|
2016-06-22 00:48:51 +03:00
|
|
|
/* Will be converted to program check if needed */
|
|
|
|
gen_exception_err(ctx, POWERPC_EXCP_HV_EMU, POWERPC_EXCP_INVAL | error);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void gen_priv_exception(DisasContext *ctx, uint32_t error)
|
|
|
|
{
|
|
|
|
gen_exception_err(ctx, POWERPC_EXCP_PROGRAM, POWERPC_EXCP_PRIV | error);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void gen_hvpriv_exception(DisasContext *ctx, uint32_t error)
|
|
|
|
{
|
|
|
|
/* Will be converted to program check if needed */
|
|
|
|
gen_exception_err(ctx, POWERPC_EXCP_HV_EMU, POWERPC_EXCP_PRIV | error);
|
2008-12-12 01:42:14 +03:00
|
|
|
}
|
2007-10-07 22:19:26 +04:00
|
|
|
|
2005-11-24 00:36:30 +03:00
|
|
|
/* Stop translation */
|
2009-08-16 13:06:54 +04:00
|
|
|
static inline void gen_stop_exception(DisasContext *ctx)
|
2005-07-03 00:59:34 +04:00
|
|
|
{
|
2007-03-17 17:02:15 +03:00
|
|
|
gen_update_nip(ctx, ctx->nip);
|
2007-09-29 17:06:16 +04:00
|
|
|
ctx->exception = POWERPC_EXCP_STOP;
|
2005-07-03 00:59:34 +04:00
|
|
|
}
|
|
|
|
|
2014-12-24 01:22:15 +03:00
|
|
|
#ifndef CONFIG_USER_ONLY
|
2005-11-24 00:36:30 +03:00
|
|
|
/* No need to update nip here, as execution flow will change */
|
2009-08-16 13:06:54 +04:00
|
|
|
static inline void gen_sync_exception(DisasContext *ctx)
|
2005-07-03 02:09:27 +04:00
|
|
|
{
|
2007-09-29 17:06:16 +04:00
|
|
|
ctx->exception = POWERPC_EXCP_SYNC;
|
2005-07-03 02:09:27 +04:00
|
|
|
}
|
2014-12-24 01:22:15 +03:00
|
|
|
#endif
|
2005-07-03 02:09:27 +04:00
|
|
|
|
2003-11-23 17:55:54 +03:00
|
|
|
#define GEN_HANDLER(name, opc1, opc2, opc3, inval, type) \
|
2011-05-01 02:00:58 +04: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 17:55:54 +03:00
|
|
|
|
2007-10-26 04:46:07 +04:00
|
|
|
#define GEN_HANDLER2(name, onam, opc1, opc2, opc3, inval, type) \
|
2011-05-01 02:00:58 +04: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 04:46:07 +04:00
|
|
|
|
2016-07-26 14:58:38 +03:00
|
|
|
#define GEN_HANDLER_E_2(name, opc1, opc2, opc3, opc4, inval, type, type2) \
|
|
|
|
GEN_OPCODE3(name, opc1, opc2, opc3, opc4, inval, type, type2)
|
|
|
|
|
2009-10-02 01:12:16 +04:00
|
|
|
typedef struct opcode_t {
|
2016-07-26 14:58:38 +03:00
|
|
|
unsigned char opc1, opc2, opc3, opc4;
|
2008-06-03 23:51:57 +04:00
|
|
|
#if HOST_LONG_BITS == 64 /* Explicitly align to 64 bits */
|
2016-07-26 14:58:38 +03:00
|
|
|
unsigned char pad[4];
|
2005-02-09 00:24:36 +03:00
|
|
|
#endif
|
2009-10-02 01:12:16 +04:00
|
|
|
opc_handler_t handler;
|
2008-09-20 12:07:15 +04:00
|
|
|
const char *oname;
|
2009-10-02 01:12:16 +04:00
|
|
|
} opcode_t;
|
2003-11-23 17:55:54 +03:00
|
|
|
|
2016-06-22 00:48:51 +03:00
|
|
|
/* Helpers for priv. check */
|
|
|
|
#define GEN_PRIV \
|
|
|
|
do { \
|
|
|
|
gen_priv_exception(ctx, POWERPC_EXCP_PRIV_OPC); return; \
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
#if defined(CONFIG_USER_ONLY)
|
|
|
|
#define CHK_HV GEN_PRIV
|
|
|
|
#define CHK_SV GEN_PRIV
|
2016-06-22 00:48:52 +03:00
|
|
|
#define CHK_HVRM GEN_PRIV
|
2016-06-22 00:48:51 +03:00
|
|
|
#else
|
|
|
|
#define CHK_HV \
|
|
|
|
do { \
|
|
|
|
if (unlikely(ctx->pr || !ctx->hv)) { \
|
|
|
|
GEN_PRIV; \
|
|
|
|
} \
|
|
|
|
} while (0)
|
|
|
|
#define CHK_SV \
|
|
|
|
do { \
|
|
|
|
if (unlikely(ctx->pr)) { \
|
|
|
|
GEN_PRIV; \
|
|
|
|
} \
|
|
|
|
} while (0)
|
2016-06-22 00:48:52 +03:00
|
|
|
#define CHK_HVRM \
|
|
|
|
do { \
|
|
|
|
if (unlikely(ctx->pr || !ctx->hv || ctx->dr)) { \
|
|
|
|
GEN_PRIV; \
|
|
|
|
} \
|
|
|
|
} while (0)
|
2016-06-22 00:48:51 +03:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#define CHK_NONE
|
|
|
|
|
|
|
|
|
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 03:54:22 +04:00
|
|
|
/*****************************************************************************/
|
2003-11-23 17:55:54 +03:00
|
|
|
/*** Instruction decoding ***/
|
|
|
|
#define EXTRACT_HELPER(name, shift, nb) \
|
2009-08-16 13:06:54 +04:00
|
|
|
static inline uint32_t name(uint32_t opcode) \
|
2003-11-23 17:55:54 +03:00
|
|
|
{ \
|
|
|
|
return (opcode >> (shift)) & ((1 << (nb)) - 1); \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define EXTRACT_SHELPER(name, shift, nb) \
|
2009-08-16 13:06:54 +04:00
|
|
|
static inline int32_t name(uint32_t opcode) \
|
2003-11-23 17:55:54 +03:00
|
|
|
{ \
|
2005-02-09 00:24:36 +03:00
|
|
|
return (int16_t)((opcode >> (shift)) & ((1 << (nb)) - 1)); \
|
2003-11-23 17:55:54 +03:00
|
|
|
}
|
|
|
|
|
2013-10-22 15:06:46 +04: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)); \
|
|
|
|
}
|
2016-07-26 14:58:26 +03:00
|
|
|
|
|
|
|
#define EXTRACT_HELPER_DXFORM(name, \
|
|
|
|
d0_bits, shift_op_d0, shift_d0, \
|
|
|
|
d1_bits, shift_op_d1, shift_d1, \
|
|
|
|
d2_bits, shift_op_d2, shift_d2) \
|
|
|
|
static inline int16_t name(uint32_t opcode) \
|
|
|
|
{ \
|
|
|
|
return \
|
|
|
|
(((opcode >> (shift_op_d0)) & ((1 << (d0_bits)) - 1)) << (shift_d0)) | \
|
|
|
|
(((opcode >> (shift_op_d1)) & ((1 << (d1_bits)) - 1)) << (shift_d1)) | \
|
|
|
|
(((opcode >> (shift_op_d2)) & ((1 << (d2_bits)) - 1)) << (shift_d2)); \
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-11-23 17:55:54 +03: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);
|
2016-07-26 14:58:38 +03:00
|
|
|
/* Opcode part 4 */
|
|
|
|
EXTRACT_HELPER(opc4, 16, 5);
|
2003-11-23 17:55:54 +03:00
|
|
|
/* Update Cr0 flags */
|
|
|
|
EXTRACT_HELPER(Rc, 0, 1);
|
2014-02-13 01:22:57 +04:00
|
|
|
/* Update Cr6 flags (Altivec) */
|
|
|
|
EXTRACT_HELPER(Rc21, 10, 1);
|
2003-11-23 17:55:54 +03: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-03 00:59:34 +04:00
|
|
|
EXTRACT_HELPER(_SPR, 11, 10);
|
2009-08-16 13:06:54 +04:00
|
|
|
static inline uint32_t SPR(uint32_t opcode)
|
2005-07-03 00:59:34 +04:00
|
|
|
{
|
|
|
|
uint32_t sprn = _SPR(opcode);
|
|
|
|
|
|
|
|
return ((sprn >> 5) & 0x1F) | ((sprn & 0x1F) << 5);
|
|
|
|
}
|
2003-11-23 17:55:54 +03: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-05 01:10:28 +03:00
|
|
|
/* 5 bits signed immediate value */
|
|
|
|
EXTRACT_HELPER(SIMM5, 16, 5);
|
2009-01-05 01:10:40 +03:00
|
|
|
/* 5 bits signed immediate value */
|
|
|
|
EXTRACT_HELPER(UIMM5, 16, 5);
|
2003-11-23 17:55:54 +03:00
|
|
|
/* Bit count */
|
|
|
|
EXTRACT_HELPER(NB, 11, 5);
|
|
|
|
/* Shift count */
|
|
|
|
EXTRACT_HELPER(SH, 11, 5);
|
2009-01-05 01:10:09 +03:00
|
|
|
/* Vector shift count */
|
|
|
|
EXTRACT_HELPER(VSH, 6, 4);
|
2003-11-23 17:55:54 +03:00
|
|
|
/* Mask start */
|
|
|
|
EXTRACT_HELPER(MB, 6, 5);
|
|
|
|
/* Mask end */
|
|
|
|
EXTRACT_HELPER(ME, 1, 5);
|
2004-01-04 17:57:11 +03:00
|
|
|
/* Trap operand */
|
|
|
|
EXTRACT_HELPER(TO, 21, 5);
|
2003-11-23 17:55:54 +03:00
|
|
|
|
|
|
|
EXTRACT_HELPER(CRM, 12, 8);
|
2014-12-24 01:22:15 +03:00
|
|
|
|
|
|
|
#ifndef CONFIG_USER_ONLY
|
2003-11-23 17:55:54 +03:00
|
|
|
EXTRACT_HELPER(SR, 16, 4);
|
2014-12-24 01:22:15 +03:00
|
|
|
#endif
|
2013-04-20 12:56:22 +04:00
|
|
|
|
|
|
|
/* mtfsf/mtfsfi */
|
2013-08-15 15:32:38 +04:00
|
|
|
EXTRACT_HELPER(FPBF, 23, 3);
|
2008-06-19 02:10:12 +04:00
|
|
|
EXTRACT_HELPER(FPIMM, 12, 4);
|
2013-08-15 15:32:38 +04:00
|
|
|
EXTRACT_HELPER(FPL, 25, 1);
|
2013-04-20 12:56:22 +04:00
|
|
|
EXTRACT_HELPER(FPFLM, 17, 8);
|
|
|
|
EXTRACT_HELPER(FPW, 16, 1);
|
2004-01-04 17:57:11 +03:00
|
|
|
|
2016-07-26 14:58:26 +03:00
|
|
|
/* addpcis */
|
|
|
|
EXTRACT_HELPER_DXFORM(DX, 10, 6, 6, 5, 16, 1, 1, 0, 0)
|
|
|
|
|
2003-11-23 17:55:54 +03:00
|
|
|
/*** Jump target decoding ***/
|
|
|
|
/* Immediate address */
|
2009-08-16 13:06:54 +04:00
|
|
|
static inline target_ulong LI(uint32_t opcode)
|
2003-11-23 17:55:54 +03:00
|
|
|
{
|
|
|
|
return (opcode >> 0) & 0x03FFFFFC;
|
|
|
|
}
|
|
|
|
|
2009-08-16 13:06:54 +04:00
|
|
|
static inline uint32_t BD(uint32_t opcode)
|
2003-11-23 17:55:54 +03: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-22 00:54:57 +04:00
|
|
|
/* DFP Z22-form */
|
|
|
|
EXTRACT_HELPER(DCM, 10, 6)
|
|
|
|
|
|
|
|
/* DFP Z23-form */
|
|
|
|
EXTRACT_HELPER(RMC, 9, 2)
|
|
|
|
|
2003-11-23 17:55:54 +03:00
|
|
|
/* Create a mask between <start> and <end> bits */
|
2009-08-16 13:06:54 +04:00
|
|
|
static inline target_ulong MASK(uint32_t start, uint32_t end)
|
2003-11-23 17:55:54 +03:00
|
|
|
{
|
2007-03-07 11:32:30 +03:00
|
|
|
target_ulong ret;
|
2003-11-23 17:55:54 +03:00
|
|
|
|
2007-03-07 11:32:30 +03:00
|
|
|
#if defined(TARGET_PPC64)
|
|
|
|
if (likely(start == 0)) {
|
2007-11-12 03:04:48 +03:00
|
|
|
ret = UINT64_MAX << (63 - end);
|
2007-03-07 11:32:30 +03:00
|
|
|
} else if (likely(end == 63)) {
|
2007-11-12 03:04:48 +03:00
|
|
|
ret = UINT64_MAX >> start;
|
2007-03-07 11:32:30 +03:00
|
|
|
}
|
|
|
|
#else
|
|
|
|
if (likely(start == 0)) {
|
2007-11-12 03:04:48 +03:00
|
|
|
ret = UINT32_MAX << (31 - end);
|
2007-03-07 11:32:30 +03:00
|
|
|
} else if (likely(end == 31)) {
|
2007-11-12 03:04:48 +03:00
|
|
|
ret = UINT32_MAX >> start;
|
2007-03-07 11:32:30 +03:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
else {
|
|
|
|
ret = (((target_ulong)(-1ULL)) >> (start)) ^
|
|
|
|
(((target_ulong)(-1ULL) >> (end)) >> 1);
|
|
|
|
if (unlikely(start > end))
|
|
|
|
return ~ret;
|
|
|
|
}
|
2003-11-23 17:55:54 +03:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2013-10-22 15:06:46 +04: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 17:21:21 +04:00
|
|
|
EXTRACT_HELPER_SPLIT(xC, 3, 1, 6, 5);
|
2013-10-22 15:06:46 +04:00
|
|
|
EXTRACT_HELPER(DM, 8, 2);
|
2013-11-01 17:21:22 +04:00
|
|
|
EXTRACT_HELPER(UIM, 16, 2);
|
2013-11-01 17:21:23 +04:00
|
|
|
EXTRACT_HELPER(SHW, 8, 2);
|
2014-04-22 00:54:57 +04: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 03:54:22 +04:00
|
|
|
/*****************************************************************************/
|
|
|
|
/* PowerPC instructions table */
|
2004-07-10 19:33:29 +04:00
|
|
|
|
2007-03-07 11:32:30 +03:00
|
|
|
#if defined(DO_PPC_STATISTICS)
|
2011-05-01 02:00:58 +04:00
|
|
|
#define GEN_OPCODE(name, op1, op2, op3, invl, _typ, _typ2) \
|
2009-06-17 19:22:31 +04:00
|
|
|
{ \
|
2003-11-23 17:55:54 +03:00
|
|
|
.opc1 = op1, \
|
|
|
|
.opc2 = op2, \
|
|
|
|
.opc3 = op3, \
|
2016-07-26 14:58:38 +03:00
|
|
|
.opc4 = 0xff, \
|
2003-11-23 17:55:54 +03:00
|
|
|
.handler = { \
|
2011-09-28 09:54:05 +04: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, \
|
2016-07-26 14:58:38 +03:00
|
|
|
.opc4 = 0xff, \
|
2011-09-28 09:54:05 +04:00
|
|
|
.handler = { \
|
|
|
|
.inval1 = invl1, \
|
|
|
|
.inval2 = invl2, \
|
2004-01-05 01:58:38 +03:00
|
|
|
.type = _typ, \
|
2011-05-01 02:00:58 +04:00
|
|
|
.type2 = _typ2, \
|
2003-11-23 17:55:54 +03:00
|
|
|
.handler = &gen_##name, \
|
2007-03-07 11:32:30 +03:00
|
|
|
.oname = stringify(name), \
|
2003-11-23 17:55:54 +03:00
|
|
|
}, \
|
2005-07-03 00:59:34 +04:00
|
|
|
.oname = stringify(name), \
|
2003-11-23 17:55:54 +03:00
|
|
|
}
|
2011-05-01 02:00:58 +04:00
|
|
|
#define GEN_OPCODE2(name, onam, op1, op2, op3, invl, _typ, _typ2) \
|
2009-06-17 19:22:31 +04:00
|
|
|
{ \
|
2007-10-26 04:46:07 +04:00
|
|
|
.opc1 = op1, \
|
|
|
|
.opc2 = op2, \
|
|
|
|
.opc3 = op3, \
|
2016-07-26 14:58:38 +03:00
|
|
|
.opc4 = 0xff, \
|
2007-10-26 04:46:07 +04:00
|
|
|
.handler = { \
|
2011-09-28 09:54:05 +04:00
|
|
|
.inval1 = invl, \
|
2007-10-26 04:46:07 +04:00
|
|
|
.type = _typ, \
|
2011-05-01 02:00:58 +04:00
|
|
|
.type2 = _typ2, \
|
2007-10-26 04:46:07 +04:00
|
|
|
.handler = &gen_##name, \
|
|
|
|
.oname = onam, \
|
|
|
|
}, \
|
|
|
|
.oname = onam, \
|
|
|
|
}
|
2016-07-26 14:58:38 +03:00
|
|
|
#define GEN_OPCODE3(name, op1, op2, op3, op4, invl, _typ, _typ2) \
|
|
|
|
{ \
|
|
|
|
.opc1 = op1, \
|
|
|
|
.opc2 = op2, \
|
|
|
|
.opc3 = op3, \
|
|
|
|
.opc4 = op4, \
|
|
|
|
.handler = { \
|
|
|
|
.inval1 = invl, \
|
|
|
|
.type = _typ, \
|
|
|
|
.type2 = _typ2, \
|
|
|
|
.handler = &gen_##name, \
|
|
|
|
.oname = stringify(name), \
|
|
|
|
}, \
|
|
|
|
.oname = stringify(name), \
|
|
|
|
}
|
2007-03-07 11:32:30 +03:00
|
|
|
#else
|
2011-05-01 02:00:58 +04:00
|
|
|
#define GEN_OPCODE(name, op1, op2, op3, invl, _typ, _typ2) \
|
2009-06-17 19:22:31 +04:00
|
|
|
{ \
|
2007-10-26 04:46:07 +04:00
|
|
|
.opc1 = op1, \
|
|
|
|
.opc2 = op2, \
|
|
|
|
.opc3 = op3, \
|
2016-07-26 14:58:38 +03:00
|
|
|
.opc4 = 0xff, \
|
2007-10-26 04:46:07 +04:00
|
|
|
.handler = { \
|
2011-09-28 09:54:05 +04: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, \
|
2016-07-26 14:58:38 +03:00
|
|
|
.opc4 = 0xff, \
|
2011-09-28 09:54:05 +04:00
|
|
|
.handler = { \
|
|
|
|
.inval1 = invl1, \
|
|
|
|
.inval2 = invl2, \
|
2007-10-26 04:46:07 +04:00
|
|
|
.type = _typ, \
|
2011-05-01 02:00:58 +04:00
|
|
|
.type2 = _typ2, \
|
2007-10-26 04:46:07 +04:00
|
|
|
.handler = &gen_##name, \
|
2009-06-17 19:22:31 +04:00
|
|
|
}, \
|
|
|
|
.oname = stringify(name), \
|
|
|
|
}
|
2011-05-01 02:00:58 +04:00
|
|
|
#define GEN_OPCODE2(name, onam, op1, op2, op3, invl, _typ, _typ2) \
|
2009-06-17 19:22:31 +04:00
|
|
|
{ \
|
|
|
|
.opc1 = op1, \
|
|
|
|
.opc2 = op2, \
|
|
|
|
.opc3 = op3, \
|
2016-07-26 14:58:38 +03:00
|
|
|
.opc4 = 0xff, \
|
2009-06-17 19:22:31 +04:00
|
|
|
.handler = { \
|
2011-09-28 09:54:05 +04:00
|
|
|
.inval1 = invl, \
|
2009-06-17 19:22:31 +04:00
|
|
|
.type = _typ, \
|
2011-05-01 02:00:58 +04:00
|
|
|
.type2 = _typ2, \
|
2009-06-17 19:22:31 +04:00
|
|
|
.handler = &gen_##name, \
|
|
|
|
}, \
|
|
|
|
.oname = onam, \
|
|
|
|
}
|
2016-07-26 14:58:38 +03:00
|
|
|
#define GEN_OPCODE3(name, op1, op2, op3, op4, invl, _typ, _typ2) \
|
|
|
|
{ \
|
|
|
|
.opc1 = op1, \
|
|
|
|
.opc2 = op2, \
|
|
|
|
.opc3 = op3, \
|
|
|
|
.opc4 = op4, \
|
|
|
|
.handler = { \
|
|
|
|
.inval1 = invl, \
|
|
|
|
.type = _typ, \
|
|
|
|
.type2 = _typ2, \
|
|
|
|
.handler = &gen_##name, \
|
|
|
|
}, \
|
|
|
|
.oname = stringify(name), \
|
|
|
|
}
|
2009-06-17 19:22:31 +04:00
|
|
|
#endif
|
2009-06-17 19:22:24 +04:00
|
|
|
|
2009-06-17 19:22:31 +04:00
|
|
|
/* SPR load/store helpers */
|
2009-08-16 13:06:54 +04:00
|
|
|
static inline void gen_load_spr(TCGv t, int reg)
|
2009-06-17 19:22:31 +04:00
|
|
|
{
|
2012-03-14 04:38:22 +04:00
|
|
|
tcg_gen_ld_tl(t, cpu_env, offsetof(CPUPPCState, spr[reg]));
|
2009-06-17 19:22:31 +04:00
|
|
|
}
|
2009-06-17 19:22:24 +04:00
|
|
|
|
2009-08-16 13:06:54 +04:00
|
|
|
static inline void gen_store_spr(int reg, TCGv t)
|
2009-06-17 19:22:31 +04:00
|
|
|
{
|
2012-03-14 04:38:22 +04:00
|
|
|
tcg_gen_st_tl(t, cpu_env, offsetof(CPUPPCState, spr[reg]));
|
2009-06-17 19:22:31 +04:00
|
|
|
}
|
2009-06-17 19:22:24 +04:00
|
|
|
|
2009-06-17 19:22:19 +04:00
|
|
|
/* Invalid instruction */
|
2009-06-17 19:22:09 +04:00
|
|
|
static void gen_invalid(DisasContext *ctx)
|
2004-01-05 01:58:38 +03:00
|
|
|
{
|
2008-12-12 01:42:14 +03:00
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_INVAL_INVAL);
|
2004-01-05 01:58:38 +03:00
|
|
|
}
|
|
|
|
|
2009-10-02 01:12:16 +04:00
|
|
|
static opc_handler_t invalid_handler = {
|
2011-09-28 09:54:05 +04:00
|
|
|
.inval1 = 0xFFFFFFFF,
|
|
|
|
.inval2 = 0xFFFFFFFF,
|
2004-01-05 01:58:38 +03:00
|
|
|
.type = PPC_NONE,
|
2011-05-01 02:00:58 +04:00
|
|
|
.type2 = PPC_NONE,
|
2003-11-23 17:55:54 +03:00
|
|
|
.handler = gen_invalid,
|
|
|
|
};
|
|
|
|
|
2008-10-21 15:31:14 +04:00
|
|
|
/*** Integer comparison ***/
|
|
|
|
|
2009-08-16 13:06:54 +04:00
|
|
|
static inline void gen_op_cmp(TCGv arg0, TCGv arg1, int s, int crf)
|
2008-10-21 15:31:14 +04:00
|
|
|
{
|
2013-02-20 11:52:14 +04:00
|
|
|
TCGv t0 = tcg_temp_new();
|
|
|
|
TCGv_i32 t1 = tcg_temp_new_i32();
|
2008-10-21 15:31:14 +04:00
|
|
|
|
2013-02-20 11:52:13 +04:00
|
|
|
tcg_gen_trunc_tl_i32(cpu_crf[crf], cpu_so);
|
2008-10-21 15:31:14 +04:00
|
|
|
|
2013-02-20 11:52:14 +04: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 15:31:14 +04:00
|
|
|
}
|
|
|
|
|
2009-08-16 13:06:54 +04:00
|
|
|
static inline void gen_op_cmpi(TCGv arg0, target_ulong arg1, int s, int crf)
|
2008-10-21 15:31:14 +04:00
|
|
|
{
|
2013-02-20 11:52:14 +04:00
|
|
|
TCGv t0 = tcg_const_tl(arg1);
|
2008-10-28 01:50:39 +03:00
|
|
|
gen_op_cmp(arg0, t0, s, crf);
|
|
|
|
tcg_temp_free(t0);
|
2008-10-21 15:31:14 +04:00
|
|
|
}
|
|
|
|
|
2009-08-16 13:06:54 +04:00
|
|
|
static inline void gen_op_cmp32(TCGv arg0, TCGv arg1, int s, int crf)
|
2008-10-21 15:31:14 +04:00
|
|
|
{
|
2008-10-28 01:50:39 +03:00
|
|
|
TCGv t0, t1;
|
2013-02-20 11:52:14 +04:00
|
|
|
t0 = tcg_temp_new();
|
|
|
|
t1 = tcg_temp_new();
|
2008-10-21 15:31:14 +04:00
|
|
|
if (s) {
|
2008-10-28 01:50:39 +03:00
|
|
|
tcg_gen_ext32s_tl(t0, arg0);
|
|
|
|
tcg_gen_ext32s_tl(t1, arg1);
|
2008-10-21 15:31:14 +04:00
|
|
|
} else {
|
2008-10-28 01:50:39 +03:00
|
|
|
tcg_gen_ext32u_tl(t0, arg0);
|
|
|
|
tcg_gen_ext32u_tl(t1, arg1);
|
2008-10-21 15:31:14 +04:00
|
|
|
}
|
2008-10-28 01:50:39 +03:00
|
|
|
gen_op_cmp(t0, t1, s, crf);
|
|
|
|
tcg_temp_free(t1);
|
|
|
|
tcg_temp_free(t0);
|
2008-10-21 15:31:14 +04:00
|
|
|
}
|
|
|
|
|
2009-08-16 13:06:54 +04:00
|
|
|
static inline void gen_op_cmpi32(TCGv arg0, target_ulong arg1, int s, int crf)
|
2008-10-21 15:31:14 +04:00
|
|
|
{
|
2013-02-20 11:52:14 +04:00
|
|
|
TCGv t0 = tcg_const_tl(arg1);
|
2008-10-28 01:50:39 +03:00
|
|
|
gen_op_cmp32(arg0, t0, s, crf);
|
|
|
|
tcg_temp_free(t0);
|
2008-10-21 15:31:14 +04:00
|
|
|
}
|
|
|
|
|
2009-08-16 13:06:54 +04:00
|
|
|
static inline void gen_set_Rc0(DisasContext *ctx, TCGv reg)
|
2008-10-21 15:31:14 +04:00
|
|
|
{
|
2013-03-21 14:01:47 +04:00
|
|
|
if (NARROW_MODE(ctx)) {
|
2008-10-21 15:31:14 +04:00
|
|
|
gen_op_cmpi32(reg, 0, 1, 0);
|
2013-03-21 14:01:47 +04:00
|
|
|
} else {
|
2008-10-21 15:31:14 +04:00
|
|
|
gen_op_cmpi(reg, 0, 1, 0);
|
2013-03-21 14:01:47 +04:00
|
|
|
}
|
2008-10-21 15:31:14 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* cmp */
|
2009-06-17 19:22:09 +04:00
|
|
|
static void gen_cmp(DisasContext *ctx)
|
2008-10-21 15:31:14 +04:00
|
|
|
{
|
2013-05-08 17:19:14 +04:00
|
|
|
if ((ctx->opcode & 0x00200000) && (ctx->insns_flags & PPC_64B)) {
|
2008-10-21 15:31:14 +04:00
|
|
|
gen_op_cmp(cpu_gpr[rA(ctx->opcode)], cpu_gpr[rB(ctx->opcode)],
|
|
|
|
1, crfD(ctx->opcode));
|
2013-05-08 17:19:14 +04:00
|
|
|
} else {
|
|
|
|
gen_op_cmp32(cpu_gpr[rA(ctx->opcode)], cpu_gpr[rB(ctx->opcode)],
|
|
|
|
1, crfD(ctx->opcode));
|
2013-03-21 14:01:47 +04:00
|
|
|
}
|
2008-10-21 15:31:14 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* cmpi */
|
2009-06-17 19:22:09 +04:00
|
|
|
static void gen_cmpi(DisasContext *ctx)
|
2008-10-21 15:31:14 +04:00
|
|
|
{
|
2013-05-08 17:19:14 +04:00
|
|
|
if ((ctx->opcode & 0x00200000) && (ctx->insns_flags & PPC_64B)) {
|
2008-10-21 15:31:14 +04:00
|
|
|
gen_op_cmpi(cpu_gpr[rA(ctx->opcode)], SIMM(ctx->opcode),
|
|
|
|
1, crfD(ctx->opcode));
|
2013-05-08 17:19:14 +04:00
|
|
|
} else {
|
|
|
|
gen_op_cmpi32(cpu_gpr[rA(ctx->opcode)], SIMM(ctx->opcode),
|
|
|
|
1, crfD(ctx->opcode));
|
2013-03-21 14:01:47 +04:00
|
|
|
}
|
2008-10-21 15:31:14 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* cmpl */
|
2009-06-17 19:22:09 +04:00
|
|
|
static void gen_cmpl(DisasContext *ctx)
|
2008-10-21 15:31:14 +04:00
|
|
|
{
|
2013-05-08 17:19:14 +04:00
|
|
|
if ((ctx->opcode & 0x00200000) && (ctx->insns_flags & PPC_64B)) {
|
2008-10-21 15:31:14 +04:00
|
|
|
gen_op_cmp(cpu_gpr[rA(ctx->opcode)], cpu_gpr[rB(ctx->opcode)],
|
|
|
|
0, crfD(ctx->opcode));
|
2013-05-08 17:19:14 +04:00
|
|
|
} else {
|
|
|
|
gen_op_cmp32(cpu_gpr[rA(ctx->opcode)], cpu_gpr[rB(ctx->opcode)],
|
|
|
|
0, crfD(ctx->opcode));
|
2013-03-21 14:01:47 +04:00
|
|
|
}
|
2008-10-21 15:31:14 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* cmpli */
|
2009-06-17 19:22:09 +04:00
|
|
|
static void gen_cmpli(DisasContext *ctx)
|
2008-10-21 15:31:14 +04:00
|
|
|
{
|
2013-05-08 17:19:14 +04:00
|
|
|
if ((ctx->opcode & 0x00200000) && (ctx->insns_flags & PPC_64B)) {
|
2008-10-21 15:31:14 +04:00
|
|
|
gen_op_cmpi(cpu_gpr[rA(ctx->opcode)], UIMM(ctx->opcode),
|
|
|
|
0, crfD(ctx->opcode));
|
2013-05-08 17:19:14 +04:00
|
|
|
} else {
|
|
|
|
gen_op_cmpi32(cpu_gpr[rA(ctx->opcode)], UIMM(ctx->opcode),
|
|
|
|
0, crfD(ctx->opcode));
|
2013-03-21 14:01:47 +04:00
|
|
|
}
|
2008-10-21 15:31:14 +04:00
|
|
|
}
|
|
|
|
|
2016-07-26 14:58:27 +03:00
|
|
|
/* cmprb - range comparison: isupper, isaplha, islower*/
|
|
|
|
static void gen_cmprb(DisasContext *ctx)
|
|
|
|
{
|
|
|
|
TCGv_i32 src1 = tcg_temp_new_i32();
|
|
|
|
TCGv_i32 src2 = tcg_temp_new_i32();
|
|
|
|
TCGv_i32 src2lo = tcg_temp_new_i32();
|
|
|
|
TCGv_i32 src2hi = tcg_temp_new_i32();
|
|
|
|
TCGv_i32 crf = cpu_crf[crfD(ctx->opcode)];
|
|
|
|
|
|
|
|
tcg_gen_trunc_tl_i32(src1, cpu_gpr[rA(ctx->opcode)]);
|
|
|
|
tcg_gen_trunc_tl_i32(src2, cpu_gpr[rB(ctx->opcode)]);
|
|
|
|
|
|
|
|
tcg_gen_andi_i32(src1, src1, 0xFF);
|
|
|
|
tcg_gen_ext8u_i32(src2lo, src2);
|
|
|
|
tcg_gen_shri_i32(src2, src2, 8);
|
|
|
|
tcg_gen_ext8u_i32(src2hi, src2);
|
|
|
|
|
|
|
|
tcg_gen_setcond_i32(TCG_COND_LEU, src2lo, src2lo, src1);
|
|
|
|
tcg_gen_setcond_i32(TCG_COND_LEU, src2hi, src1, src2hi);
|
|
|
|
tcg_gen_and_i32(crf, src2lo, src2hi);
|
|
|
|
|
|
|
|
if (ctx->opcode & 0x00200000) {
|
|
|
|
tcg_gen_shri_i32(src2, src2, 8);
|
|
|
|
tcg_gen_ext8u_i32(src2lo, src2);
|
|
|
|
tcg_gen_shri_i32(src2, src2, 8);
|
|
|
|
tcg_gen_ext8u_i32(src2hi, src2);
|
|
|
|
tcg_gen_setcond_i32(TCG_COND_LEU, src2lo, src2lo, src1);
|
|
|
|
tcg_gen_setcond_i32(TCG_COND_LEU, src2hi, src1, src2hi);
|
|
|
|
tcg_gen_and_i32(src2lo, src2lo, src2hi);
|
|
|
|
tcg_gen_or_i32(crf, crf, src2lo);
|
|
|
|
}
|
|
|
|
tcg_gen_shli_i32(crf, crf, CRF_GT);
|
|
|
|
tcg_temp_free_i32(src1);
|
|
|
|
tcg_temp_free_i32(src2);
|
|
|
|
tcg_temp_free_i32(src2lo);
|
|
|
|
tcg_temp_free_i32(src2hi);
|
|
|
|
}
|
|
|
|
|
2016-07-26 14:58:34 +03:00
|
|
|
#if defined(TARGET_PPC64)
|
|
|
|
/* cmpeqb */
|
|
|
|
static void gen_cmpeqb(DisasContext *ctx)
|
|
|
|
{
|
|
|
|
gen_helper_cmpeqb(cpu_crf[crfD(ctx->opcode)], cpu_gpr[rA(ctx->opcode)],
|
|
|
|
cpu_gpr[rB(ctx->opcode)]);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2008-10-21 15:31:14 +04:00
|
|
|
/* isel (PowerPC 2.03 specification) */
|
2009-06-17 19:22:09 +04:00
|
|
|
static void gen_isel(DisasContext *ctx)
|
2008-10-21 15:31:14 +04:00
|
|
|
{
|
|
|
|
uint32_t bi = rC(ctx->opcode);
|
2016-02-24 04:18:34 +03:00
|
|
|
uint32_t mask = 0x08 >> (bi & 0x03);
|
|
|
|
TCGv t0 = tcg_temp_new();
|
|
|
|
TCGv zr;
|
2008-10-21 15:31:14 +04:00
|
|
|
|
2016-02-24 04:18:34 +03:00
|
|
|
tcg_gen_extu_i32_tl(t0, cpu_crf[bi >> 2]);
|
|
|
|
tcg_gen_andi_tl(t0, t0, mask);
|
|
|
|
|
|
|
|
zr = tcg_const_tl(0);
|
|
|
|
tcg_gen_movcond_tl(TCG_COND_NE, cpu_gpr[rD(ctx->opcode)], t0, zr,
|
|
|
|
rA(ctx->opcode) ? cpu_gpr[rA(ctx->opcode)] : zr,
|
|
|
|
cpu_gpr[rB(ctx->opcode)]);
|
|
|
|
tcg_temp_free(zr);
|
|
|
|
tcg_temp_free(t0);
|
2008-10-21 15:31:14 +04:00
|
|
|
}
|
|
|
|
|
2013-04-20 12:56:16 +04: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 17:55:54 +03:00
|
|
|
/*** Integer arithmetic ***/
|
|
|
|
|
2009-08-16 13:06:54 +04:00
|
|
|
static inline void gen_op_arith_compute_ov(DisasContext *ctx, TCGv arg0,
|
|
|
|
TCGv arg1, TCGv arg2, int sub)
|
2008-11-01 03:54:12 +03:00
|
|
|
{
|
2013-02-20 11:52:15 +04:00
|
|
|
TCGv t0 = tcg_temp_new();
|
2003-11-23 17:55:54 +03:00
|
|
|
|
2013-03-31 18:33:16 +04:00
|
|
|
tcg_gen_xor_tl(cpu_ov, arg0, arg2);
|
2008-11-01 03:54:12 +03:00
|
|
|
tcg_gen_xor_tl(t0, arg1, arg2);
|
2013-02-20 11:52:15 +04: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 14:01:47 +04:00
|
|
|
if (NARROW_MODE(ctx)) {
|
2013-02-20 11:52:15 +04: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 17:55:54 +03:00
|
|
|
}
|
|
|
|
|
2008-11-01 03:54:12 +03:00
|
|
|
/* Common add function */
|
2009-08-16 13:06:54 +04:00
|
|
|
static inline void gen_op_arith_add(DisasContext *ctx, TCGv ret, TCGv arg1,
|
2013-02-20 11:52:17 +04:00
|
|
|
TCGv arg2, bool add_ca, bool compute_ca,
|
|
|
|
bool compute_ov, bool compute_rc0)
|
2008-11-01 03:54:12 +03:00
|
|
|
{
|
2013-02-20 11:52:17 +04:00
|
|
|
TCGv t0 = ret;
|
2007-03-17 17:02:15 +03:00
|
|
|
|
2013-04-03 14:56:45 +04:00
|
|
|
if (compute_ca || compute_ov) {
|
2013-02-20 11:52:16 +04:00
|
|
|
t0 = tcg_temp_new();
|
2008-11-01 03:54:12 +03:00
|
|
|
}
|
2003-11-23 17:55:54 +03:00
|
|
|
|
2013-02-20 11:52:13 +04:00
|
|
|
if (compute_ca) {
|
2013-03-21 14:01:45 +04:00
|
|
|
if (NARROW_MODE(ctx)) {
|
2013-04-03 14:56:45 +04: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 14:01:45 +04:00
|
|
|
TCGv t1 = tcg_temp_new();
|
2013-04-03 14:56:45 +04:00
|
|
|
tcg_gen_xor_tl(t1, arg1, arg2); /* add without carry */
|
|
|
|
tcg_gen_add_tl(t0, arg1, arg2);
|
2013-03-21 14:01:45 +04:00
|
|
|
if (add_ca) {
|
|
|
|
tcg_gen_add_tl(t0, t0, cpu_ca);
|
|
|
|
}
|
2013-04-03 14:56:45 +04: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 11:52:17 +04:00
|
|
|
} else {
|
2013-03-21 14:01:45 +04: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 11:52:17 +04:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
tcg_gen_add_tl(t0, arg1, arg2);
|
|
|
|
if (add_ca) {
|
|
|
|
tcg_gen_add_tl(t0, t0, cpu_ca);
|
|
|
|
}
|
2013-02-20 11:52:13 +04:00
|
|
|
}
|
2003-11-23 17:55:54 +03:00
|
|
|
|
2008-11-01 03:54:12 +03:00
|
|
|
if (compute_ov) {
|
|
|
|
gen_op_arith_compute_ov(ctx, t0, arg1, arg2, 0);
|
|
|
|
}
|
2013-02-20 11:52:17 +04:00
|
|
|
if (unlikely(compute_rc0)) {
|
2008-11-01 03:54:12 +03:00
|
|
|
gen_set_Rc0(ctx, t0);
|
2013-02-20 11:52:17 +04:00
|
|
|
}
|
2008-11-01 03:54:12 +03:00
|
|
|
|
2008-11-17 17:43:54 +03:00
|
|
|
if (!TCGV_EQUAL(t0, ret)) {
|
2008-11-01 03:54:12 +03:00
|
|
|
tcg_gen_mov_tl(ret, t0);
|
|
|
|
tcg_temp_free(t0);
|
|
|
|
}
|
2008-09-05 18:19:43 +04:00
|
|
|
}
|
2008-11-01 03:54:12 +03:00
|
|
|
/* Add functions with two operands */
|
|
|
|
#define GEN_INT_ARITH_ADD(name, opc3, add_ca, compute_ca, compute_ov) \
|
2013-02-20 11:52:17 +04:00
|
|
|
static void glue(gen_, name)(DisasContext *ctx) \
|
2008-11-01 03:54:12 +03:00
|
|
|
{ \
|
|
|
|
gen_op_arith_add(ctx, cpu_gpr[rD(ctx->opcode)], \
|
|
|
|
cpu_gpr[rA(ctx->opcode)], cpu_gpr[rB(ctx->opcode)], \
|
2013-02-20 11:52:17 +04:00
|
|
|
add_ca, compute_ca, compute_ov, Rc(ctx->opcode)); \
|
2008-11-01 03:54:12 +03: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 11:52:17 +04:00
|
|
|
static void glue(gen_, name)(DisasContext *ctx) \
|
2008-11-01 03:54:12 +03:00
|
|
|
{ \
|
2013-02-20 11:52:17 +04:00
|
|
|
TCGv t0 = tcg_const_tl(const_val); \
|
2008-11-01 03:54:12 +03:00
|
|
|
gen_op_arith_add(ctx, cpu_gpr[rD(ctx->opcode)], \
|
|
|
|
cpu_gpr[rA(ctx->opcode)], t0, \
|
2013-02-20 11:52:17 +04:00
|
|
|
add_ca, compute_ca, compute_ov, Rc(ctx->opcode)); \
|
2008-11-01 03:54:12 +03: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 19:22:09 +04:00
|
|
|
static void gen_addi(DisasContext *ctx)
|
2007-03-17 17:02:15 +03:00
|
|
|
{
|
2008-11-01 03:54:12 +03: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 11:52:17 +04:00
|
|
|
tcg_gen_addi_tl(cpu_gpr[rD(ctx->opcode)],
|
|
|
|
cpu_gpr[rA(ctx->opcode)], simm);
|
2008-11-01 03:54:12 +03:00
|
|
|
}
|
2007-03-17 17:02:15 +03:00
|
|
|
}
|
2008-11-01 03:54:12 +03:00
|
|
|
/* addic addic.*/
|
2013-02-20 11:52:17 +04:00
|
|
|
static inline void gen_op_addic(DisasContext *ctx, bool compute_rc0)
|
2007-03-17 17:02:15 +03:00
|
|
|
{
|
2013-02-20 11:52:17 +04: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 17:02:15 +03:00
|
|
|
}
|
2009-06-17 19:22:09 +04:00
|
|
|
|
|
|
|
static void gen_addic(DisasContext *ctx)
|
2007-03-17 17:02:15 +03:00
|
|
|
{
|
2013-02-20 11:52:17 +04:00
|
|
|
gen_op_addic(ctx, 0);
|
2007-03-17 17:02:15 +03:00
|
|
|
}
|
2009-06-17 19:22:14 +04:00
|
|
|
|
|
|
|
static void gen_addic_(DisasContext *ctx)
|
2007-03-17 17:02:15 +03:00
|
|
|
{
|
2013-02-20 11:52:17 +04:00
|
|
|
gen_op_addic(ctx, 1);
|
2007-03-17 17:02:15 +03:00
|
|
|
}
|
2009-06-17 19:22:09 +04:00
|
|
|
|
2009-06-17 19:22:19 +04:00
|
|
|
/* addis */
|
2009-06-17 19:22:09 +04:00
|
|
|
static void gen_addis(DisasContext *ctx)
|
2007-03-17 17:02:15 +03:00
|
|
|
{
|
2008-11-01 03:54:12 +03: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 11:52:17 +04:00
|
|
|
tcg_gen_addi_tl(cpu_gpr[rD(ctx->opcode)],
|
|
|
|
cpu_gpr[rA(ctx->opcode)], simm << 16);
|
2008-11-01 03:54:12 +03:00
|
|
|
}
|
2007-03-17 17:02:15 +03:00
|
|
|
}
|
2008-11-01 03:54:12 +03:00
|
|
|
|
2016-07-26 14:58:26 +03:00
|
|
|
/* addpcis */
|
|
|
|
static void gen_addpcis(DisasContext *ctx)
|
|
|
|
{
|
|
|
|
target_long d = DX(ctx->opcode);
|
|
|
|
|
|
|
|
tcg_gen_movi_tl(cpu_gpr[rD(ctx->opcode)], ctx->nip + (d << 16));
|
|
|
|
}
|
|
|
|
|
2009-08-16 13:06:54 +04:00
|
|
|
static inline void gen_op_arith_divw(DisasContext *ctx, TCGv ret, TCGv arg1,
|
|
|
|
TCGv arg2, int sign, int compute_ov)
|
2007-03-17 17:02:15 +03:00
|
|
|
{
|
2016-07-28 21:14:11 +03:00
|
|
|
TCGv_i32 t0 = tcg_temp_new_i32();
|
|
|
|
TCGv_i32 t1 = tcg_temp_new_i32();
|
|
|
|
TCGv_i32 t2 = tcg_temp_new_i32();
|
|
|
|
TCGv_i32 t3 = tcg_temp_new_i32();
|
2008-11-01 03:54:12 +03:00
|
|
|
|
2008-11-09 20:27:19 +03:00
|
|
|
tcg_gen_trunc_tl_i32(t0, arg1);
|
|
|
|
tcg_gen_trunc_tl_i32(t1, arg2);
|
2008-11-01 03:54:12 +03:00
|
|
|
if (sign) {
|
2016-07-28 21:14:11 +03:00
|
|
|
tcg_gen_setcondi_i32(TCG_COND_EQ, t2, t0, INT_MIN);
|
|
|
|
tcg_gen_setcondi_i32(TCG_COND_EQ, t3, t1, -1);
|
|
|
|
tcg_gen_and_i32(t2, t2, t3);
|
|
|
|
tcg_gen_setcondi_i32(TCG_COND_EQ, t3, t1, 0);
|
|
|
|
tcg_gen_or_i32(t2, t2, t3);
|
|
|
|
tcg_gen_movi_i32(t3, 0);
|
|
|
|
tcg_gen_movcond_i32(TCG_COND_NE, t1, t2, t3, t2, t1);
|
|
|
|
tcg_gen_div_i32(t3, t0, t1);
|
|
|
|
tcg_gen_extu_i32_tl(ret, t3);
|
2008-11-01 03:54:12 +03:00
|
|
|
} else {
|
2016-07-28 21:14:11 +03:00
|
|
|
tcg_gen_setcondi_i32(TCG_COND_EQ, t2, t1, 0);
|
|
|
|
tcg_gen_movi_i32(t3, 0);
|
|
|
|
tcg_gen_movcond_i32(TCG_COND_NE, t1, t2, t3, t2, t1);
|
|
|
|
tcg_gen_divu_i32(t3, t0, t1);
|
|
|
|
tcg_gen_extu_i32_tl(ret, t3);
|
2008-11-01 03:54:12 +03:00
|
|
|
}
|
|
|
|
if (compute_ov) {
|
2016-07-28 21:14:11 +03:00
|
|
|
tcg_gen_extu_i32_tl(cpu_ov, t2);
|
|
|
|
tcg_gen_or_tl(cpu_so, cpu_so, cpu_ov);
|
2008-11-01 03:54:12 +03:00
|
|
|
}
|
2008-11-17 17:43:54 +03:00
|
|
|
tcg_temp_free_i32(t0);
|
|
|
|
tcg_temp_free_i32(t1);
|
2016-07-28 21:14:11 +03:00
|
|
|
tcg_temp_free_i32(t2);
|
|
|
|
tcg_temp_free_i32(t3);
|
|
|
|
|
2008-11-01 03:54:12 +03:00
|
|
|
if (unlikely(Rc(ctx->opcode) != 0))
|
|
|
|
gen_set_Rc0(ctx, ret);
|
2007-03-17 17:02:15 +03:00
|
|
|
}
|
2008-11-01 03:54:12 +03:00
|
|
|
/* Div functions */
|
|
|
|
#define GEN_INT_ARITH_DIVW(name, opc3, sign, compute_ov) \
|
2009-06-17 19:22:09 +04:00
|
|
|
static void glue(gen_, name)(DisasContext *ctx) \
|
2008-11-01 03:54:12 +03: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 20:05:51 +04: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 20:05:53 +04:00
|
|
|
GEN_DIVE(divweu, divweu, 0);
|
|
|
|
GEN_DIVE(divweuo, divweu, 1);
|
2014-01-07 20:05:54 +04:00
|
|
|
GEN_DIVE(divwe, divwe, 0);
|
|
|
|
GEN_DIVE(divweo, divwe, 1);
|
2014-01-07 20:05:53 +04:00
|
|
|
|
2007-03-17 17:02:15 +03:00
|
|
|
#if defined(TARGET_PPC64)
|
2009-08-16 13:06:54 +04:00
|
|
|
static inline void gen_op_arith_divd(DisasContext *ctx, TCGv ret, TCGv arg1,
|
|
|
|
TCGv arg2, int sign, int compute_ov)
|
2007-03-17 17:02:15 +03:00
|
|
|
{
|
2016-07-28 21:14:12 +03:00
|
|
|
TCGv_i64 t0 = tcg_temp_new_i64();
|
|
|
|
TCGv_i64 t1 = tcg_temp_new_i64();
|
|
|
|
TCGv_i64 t2 = tcg_temp_new_i64();
|
|
|
|
TCGv_i64 t3 = tcg_temp_new_i64();
|
2008-11-01 03:54:12 +03:00
|
|
|
|
2016-07-28 21:14:12 +03:00
|
|
|
tcg_gen_mov_i64(t0, arg1);
|
|
|
|
tcg_gen_mov_i64(t1, arg2);
|
2008-11-01 03:54:12 +03:00
|
|
|
if (sign) {
|
2016-07-28 21:14:12 +03:00
|
|
|
tcg_gen_setcondi_i64(TCG_COND_EQ, t2, t0, INT64_MIN);
|
|
|
|
tcg_gen_setcondi_i64(TCG_COND_EQ, t3, t1, -1);
|
|
|
|
tcg_gen_and_i64(t2, t2, t3);
|
|
|
|
tcg_gen_setcondi_i64(TCG_COND_EQ, t3, t1, 0);
|
|
|
|
tcg_gen_or_i64(t2, t2, t3);
|
|
|
|
tcg_gen_movi_i64(t3, 0);
|
|
|
|
tcg_gen_movcond_i64(TCG_COND_NE, t1, t2, t3, t2, t1);
|
|
|
|
tcg_gen_div_i64(ret, t0, t1);
|
2008-11-01 03:54:12 +03:00
|
|
|
} else {
|
2016-07-28 21:14:12 +03:00
|
|
|
tcg_gen_setcondi_i64(TCG_COND_EQ, t2, t1, 0);
|
|
|
|
tcg_gen_movi_i64(t3, 0);
|
|
|
|
tcg_gen_movcond_i64(TCG_COND_NE, t1, t2, t3, t2, t1);
|
|
|
|
tcg_gen_divu_i64(ret, t0, t1);
|
2008-11-01 03:54:12 +03:00
|
|
|
}
|
|
|
|
if (compute_ov) {
|
2016-07-28 21:14:12 +03:00
|
|
|
tcg_gen_mov_tl(cpu_ov, t2);
|
|
|
|
tcg_gen_or_tl(cpu_so, cpu_so, cpu_ov);
|
2008-11-01 03:54:12 +03:00
|
|
|
}
|
2016-07-28 21:14:12 +03:00
|
|
|
tcg_temp_free_i64(t0);
|
|
|
|
tcg_temp_free_i64(t1);
|
|
|
|
tcg_temp_free_i64(t2);
|
|
|
|
tcg_temp_free_i64(t3);
|
|
|
|
|
2008-11-01 03:54:12 +03:00
|
|
|
if (unlikely(Rc(ctx->opcode) != 0))
|
|
|
|
gen_set_Rc0(ctx, ret);
|
2007-03-17 17:02:15 +03:00
|
|
|
}
|
2016-07-28 21:14:12 +03:00
|
|
|
|
2008-11-01 03:54:12 +03:00
|
|
|
#define GEN_INT_ARITH_DIVD(name, opc3, sign, compute_ov) \
|
2009-06-17 19:22:09 +04:00
|
|
|
static void glue(gen_, name)(DisasContext *ctx) \
|
2008-11-01 03:54:12 +03:00
|
|
|
{ \
|
2008-11-09 20:27:19 +03: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 03:54:12 +03: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 20:05:51 +04:00
|
|
|
|
|
|
|
GEN_DIVE(divdeu, divdeu, 0);
|
|
|
|
GEN_DIVE(divdeuo, divdeu, 1);
|
2014-01-07 20:05:52 +04:00
|
|
|
GEN_DIVE(divde, divde, 0);
|
|
|
|
GEN_DIVE(divdeo, divde, 1);
|
2007-03-17 17:02:15 +03:00
|
|
|
#endif
|
2008-11-01 03:54:12 +03:00
|
|
|
|
2016-07-26 14:58:28 +03:00
|
|
|
static inline void gen_op_arith_modw(DisasContext *ctx, TCGv ret, TCGv arg1,
|
|
|
|
TCGv arg2, int sign)
|
|
|
|
{
|
|
|
|
TCGv_i32 t0 = tcg_temp_new_i32();
|
|
|
|
TCGv_i32 t1 = tcg_temp_new_i32();
|
|
|
|
|
|
|
|
tcg_gen_trunc_tl_i32(t0, arg1);
|
|
|
|
tcg_gen_trunc_tl_i32(t1, arg2);
|
|
|
|
if (sign) {
|
|
|
|
TCGv_i32 t2 = tcg_temp_new_i32();
|
|
|
|
TCGv_i32 t3 = tcg_temp_new_i32();
|
|
|
|
tcg_gen_setcondi_i32(TCG_COND_EQ, t2, t0, INT_MIN);
|
|
|
|
tcg_gen_setcondi_i32(TCG_COND_EQ, t3, t1, -1);
|
|
|
|
tcg_gen_and_i32(t2, t2, t3);
|
|
|
|
tcg_gen_setcondi_i32(TCG_COND_EQ, t3, t1, 0);
|
|
|
|
tcg_gen_or_i32(t2, t2, t3);
|
|
|
|
tcg_gen_movi_i32(t3, 0);
|
|
|
|
tcg_gen_movcond_i32(TCG_COND_NE, t1, t2, t3, t2, t1);
|
|
|
|
tcg_gen_rem_i32(t3, t0, t1);
|
|
|
|
tcg_gen_ext_i32_tl(ret, t3);
|
|
|
|
tcg_temp_free_i32(t2);
|
|
|
|
tcg_temp_free_i32(t3);
|
|
|
|
} else {
|
|
|
|
TCGv_i32 t2 = tcg_const_i32(1);
|
|
|
|
TCGv_i32 t3 = tcg_const_i32(0);
|
|
|
|
tcg_gen_movcond_i32(TCG_COND_EQ, t1, t1, t3, t2, t1);
|
|
|
|
tcg_gen_remu_i32(t3, t0, t1);
|
|
|
|
tcg_gen_extu_i32_tl(ret, t3);
|
|
|
|
tcg_temp_free_i32(t2);
|
|
|
|
tcg_temp_free_i32(t3);
|
|
|
|
}
|
|
|
|
tcg_temp_free_i32(t0);
|
|
|
|
tcg_temp_free_i32(t1);
|
|
|
|
}
|
|
|
|
|
|
|
|
#define GEN_INT_ARITH_MODW(name, opc3, sign) \
|
|
|
|
static void glue(gen_, name)(DisasContext *ctx) \
|
|
|
|
{ \
|
|
|
|
gen_op_arith_modw(ctx, cpu_gpr[rD(ctx->opcode)], \
|
|
|
|
cpu_gpr[rA(ctx->opcode)], cpu_gpr[rB(ctx->opcode)], \
|
|
|
|
sign); \
|
|
|
|
}
|
|
|
|
|
|
|
|
GEN_INT_ARITH_MODW(moduw, 0x08, 0);
|
|
|
|
GEN_INT_ARITH_MODW(modsw, 0x18, 1);
|
|
|
|
|
2016-07-26 14:58:29 +03:00
|
|
|
#if defined(TARGET_PPC64)
|
|
|
|
static inline void gen_op_arith_modd(DisasContext *ctx, TCGv ret, TCGv arg1,
|
|
|
|
TCGv arg2, int sign)
|
|
|
|
{
|
|
|
|
TCGv_i64 t0 = tcg_temp_new_i64();
|
|
|
|
TCGv_i64 t1 = tcg_temp_new_i64();
|
|
|
|
|
|
|
|
tcg_gen_mov_i64(t0, arg1);
|
|
|
|
tcg_gen_mov_i64(t1, arg2);
|
|
|
|
if (sign) {
|
|
|
|
TCGv_i64 t2 = tcg_temp_new_i64();
|
|
|
|
TCGv_i64 t3 = tcg_temp_new_i64();
|
|
|
|
tcg_gen_setcondi_i64(TCG_COND_EQ, t2, t0, INT64_MIN);
|
|
|
|
tcg_gen_setcondi_i64(TCG_COND_EQ, t3, t1, -1);
|
|
|
|
tcg_gen_and_i64(t2, t2, t3);
|
|
|
|
tcg_gen_setcondi_i64(TCG_COND_EQ, t3, t1, 0);
|
|
|
|
tcg_gen_or_i64(t2, t2, t3);
|
|
|
|
tcg_gen_movi_i64(t3, 0);
|
|
|
|
tcg_gen_movcond_i64(TCG_COND_NE, t1, t2, t3, t2, t1);
|
|
|
|
tcg_gen_rem_i64(ret, t0, t1);
|
|
|
|
tcg_temp_free_i64(t2);
|
|
|
|
tcg_temp_free_i64(t3);
|
|
|
|
} else {
|
|
|
|
TCGv_i64 t2 = tcg_const_i64(1);
|
|
|
|
TCGv_i64 t3 = tcg_const_i64(0);
|
|
|
|
tcg_gen_movcond_i64(TCG_COND_EQ, t1, t1, t3, t2, t1);
|
|
|
|
tcg_gen_remu_i64(ret, t0, t1);
|
|
|
|
tcg_temp_free_i64(t2);
|
|
|
|
tcg_temp_free_i64(t3);
|
|
|
|
}
|
|
|
|
tcg_temp_free_i64(t0);
|
|
|
|
tcg_temp_free_i64(t1);
|
|
|
|
}
|
|
|
|
|
|
|
|
#define GEN_INT_ARITH_MODD(name, opc3, sign) \
|
|
|
|
static void glue(gen_, name)(DisasContext *ctx) \
|
|
|
|
{ \
|
|
|
|
gen_op_arith_modd(ctx, cpu_gpr[rD(ctx->opcode)], \
|
|
|
|
cpu_gpr[rA(ctx->opcode)], cpu_gpr[rB(ctx->opcode)], \
|
|
|
|
sign); \
|
|
|
|
}
|
|
|
|
|
|
|
|
GEN_INT_ARITH_MODD(modud, 0x08, 0);
|
|
|
|
GEN_INT_ARITH_MODD(modsd, 0x18, 1);
|
|
|
|
#endif
|
|
|
|
|
2008-11-01 03:54:12 +03:00
|
|
|
/* mulhw mulhw. */
|
2009-06-17 19:22:09 +04:00
|
|
|
static void gen_mulhw(DisasContext *ctx)
|
2007-03-17 17:02:15 +03:00
|
|
|
{
|
2013-02-20 11:52:12 +04:00
|
|
|
TCGv_i32 t0 = tcg_temp_new_i32();
|
|
|
|
TCGv_i32 t1 = tcg_temp_new_i32();
|
2008-11-01 03:54:12 +03:00
|
|
|
|
2013-02-20 11:52:12 +04: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 03:54:12 +03:00
|
|
|
if (unlikely(Rc(ctx->opcode) != 0))
|
|
|
|
gen_set_Rc0(ctx, cpu_gpr[rD(ctx->opcode)]);
|
2007-03-17 17:02:15 +03:00
|
|
|
}
|
2009-06-17 19:22:09 +04:00
|
|
|
|
2009-06-17 19:22:19 +04:00
|
|
|
/* mulhwu mulhwu. */
|
2009-06-17 19:22:09 +04:00
|
|
|
static void gen_mulhwu(DisasContext *ctx)
|
2007-03-17 17:02:15 +03:00
|
|
|
{
|
2013-02-20 11:52:12 +04:00
|
|
|
TCGv_i32 t0 = tcg_temp_new_i32();
|
|
|
|
TCGv_i32 t1 = tcg_temp_new_i32();
|
2008-11-01 03:54:12 +03:00
|
|
|
|
2013-02-20 11:52:12 +04: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 03:54:12 +03:00
|
|
|
if (unlikely(Rc(ctx->opcode) != 0))
|
|
|
|
gen_set_Rc0(ctx, cpu_gpr[rD(ctx->opcode)]);
|
2007-03-17 17:02:15 +03:00
|
|
|
}
|
2009-06-17 19:22:09 +04:00
|
|
|
|
2009-06-17 19:22:19 +04:00
|
|
|
/* mullw mullw. */
|
2009-06-17 19:22:09 +04:00
|
|
|
static void gen_mullw(DisasContext *ctx)
|
2007-03-17 17:02:15 +03:00
|
|
|
{
|
2014-08-12 17:45:06 +04: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 23:25:42 +04:00
|
|
|
tcg_gen_mul_i32(cpu_gpr[rD(ctx->opcode)], cpu_gpr[rA(ctx->opcode)],
|
|
|
|
cpu_gpr[rB(ctx->opcode)]);
|
2014-08-12 17:45:06 +04:00
|
|
|
#endif
|
2008-11-01 03:54:12 +03:00
|
|
|
if (unlikely(Rc(ctx->opcode) != 0))
|
|
|
|
gen_set_Rc0(ctx, cpu_gpr[rD(ctx->opcode)]);
|
2007-03-17 17:02:15 +03:00
|
|
|
}
|
2009-06-17 19:22:09 +04:00
|
|
|
|
2009-06-17 19:22:19 +04:00
|
|
|
/* mullwo mullwo. */
|
2009-06-17 19:22:09 +04:00
|
|
|
static void gen_mullwo(DisasContext *ctx)
|
2007-03-17 17:02:15 +03:00
|
|
|
{
|
2013-02-20 11:52:20 +04:00
|
|
|
TCGv_i32 t0 = tcg_temp_new_i32();
|
|
|
|
TCGv_i32 t1 = tcg_temp_new_i32();
|
2008-11-01 03:54:12 +03:00
|
|
|
|
2013-02-20 11:52:20 +04: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 17:45:07 +04:00
|
|
|
#if defined(TARGET_PPC64)
|
2014-08-25 23:25:43 +04: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 17:45:07 +04:00
|
|
|
#endif
|
2013-02-20 11:52:20 +04: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 03:54:12 +03:00
|
|
|
if (unlikely(Rc(ctx->opcode) != 0))
|
|
|
|
gen_set_Rc0(ctx, cpu_gpr[rD(ctx->opcode)]);
|
2007-03-17 17:02:15 +03:00
|
|
|
}
|
2009-06-17 19:22:09 +04:00
|
|
|
|
2009-06-17 19:22:19 +04:00
|
|
|
/* mulli */
|
2009-06-17 19:22:09 +04:00
|
|
|
static void gen_mulli(DisasContext *ctx)
|
2007-03-17 17:02:15 +03:00
|
|
|
{
|
2008-11-01 03:54:12 +03:00
|
|
|
tcg_gen_muli_tl(cpu_gpr[rD(ctx->opcode)], cpu_gpr[rA(ctx->opcode)],
|
|
|
|
SIMM(ctx->opcode));
|
2007-03-17 17:02:15 +03:00
|
|
|
}
|
2013-02-20 11:52:12 +04:00
|
|
|
|
2007-03-17 17:02:15 +03:00
|
|
|
#if defined(TARGET_PPC64)
|
2008-11-01 03:54:12 +03:00
|
|
|
/* mulhd mulhd. */
|
2013-02-20 11:52:12 +04: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 03:54:12 +03:00
|
|
|
/* mulhdu mulhdu. */
|
2013-02-20 11:52:12 +04: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 19:22:09 +04:00
|
|
|
|
2009-06-17 19:22:19 +04:00
|
|
|
/* mulld mulld. */
|
2009-06-17 19:22:09 +04:00
|
|
|
static void gen_mulld(DisasContext *ctx)
|
2007-03-17 17:02:15 +03:00
|
|
|
{
|
2008-11-01 03:54:12 +03: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 17:02:15 +03:00
|
|
|
}
|
2012-05-30 08:23:29 +04:00
|
|
|
|
2008-11-01 03:54:12 +03:00
|
|
|
/* mulldo mulldo. */
|
2012-05-30 08:23:29 +04:00
|
|
|
static void gen_mulldo(DisasContext *ctx)
|
|
|
|
{
|
2014-08-25 23:25:44 +04: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 08:23:29 +04:00
|
|
|
if (unlikely(Rc(ctx->opcode) != 0)) {
|
|
|
|
gen_set_Rc0(ctx, cpu_gpr[rD(ctx->opcode)]);
|
|
|
|
}
|
|
|
|
}
|
2007-03-17 17:02:15 +03:00
|
|
|
#endif
|
2008-11-01 03:54:12 +03:00
|
|
|
|
|
|
|
/* Common subf function */
|
2009-08-16 13:06:54 +04:00
|
|
|
static inline void gen_op_arith_subf(DisasContext *ctx, TCGv ret, TCGv arg1,
|
2013-02-20 11:52:17 +04:00
|
|
|
TCGv arg2, bool add_ca, bool compute_ca,
|
|
|
|
bool compute_ov, bool compute_rc0)
|
2003-11-23 17:55:54 +03:00
|
|
|
{
|
2013-02-20 11:52:17 +04:00
|
|
|
TCGv t0 = ret;
|
2003-11-23 17:55:54 +03:00
|
|
|
|
2013-04-03 14:56:45 +04:00
|
|
|
if (compute_ca || compute_ov) {
|
2013-02-20 11:52:17 +04:00
|
|
|
t0 = tcg_temp_new();
|
2013-02-20 11:52:13 +04:00
|
|
|
}
|
2008-11-01 03:54:12 +03:00
|
|
|
|
2013-03-21 14:01:45 +04:00
|
|
|
if (compute_ca) {
|
|
|
|
/* dest = ~arg1 + arg2 [+ ca]. */
|
|
|
|
if (NARROW_MODE(ctx)) {
|
2013-04-03 14:56:45 +04: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 14:01:45 +04:00
|
|
|
TCGv inv1 = tcg_temp_new();
|
2013-04-03 14:56:45 +04:00
|
|
|
TCGv t1 = tcg_temp_new();
|
2013-03-21 14:01:45 +04:00
|
|
|
tcg_gen_not_tl(inv1, arg1);
|
|
|
|
if (add_ca) {
|
2013-04-03 14:56:45 +04:00
|
|
|
tcg_gen_add_tl(t0, arg2, cpu_ca);
|
2013-03-21 14:01:45 +04:00
|
|
|
} else {
|
2013-04-03 14:56:45 +04:00
|
|
|
tcg_gen_addi_tl(t0, arg2, 1);
|
2013-03-21 14:01:45 +04:00
|
|
|
}
|
2013-04-03 14:56:45 +04:00
|
|
|
tcg_gen_xor_tl(t1, arg2, inv1); /* add without carry */
|
2013-03-21 14:01:45 +04:00
|
|
|
tcg_gen_add_tl(t0, t0, inv1);
|
2014-01-19 20:26:33 +04:00
|
|
|
tcg_temp_free(inv1);
|
2013-04-03 14:56:45 +04: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 14:01:45 +04:00
|
|
|
} else if (add_ca) {
|
2013-02-25 23:41:40 +04:00
|
|
|
TCGv zero, inv1 = tcg_temp_new();
|
|
|
|
tcg_gen_not_tl(inv1, arg1);
|
2013-02-20 11:52:17 +04:00
|
|
|
zero = tcg_const_tl(0);
|
|
|
|
tcg_gen_add2_tl(t0, cpu_ca, arg2, zero, cpu_ca, zero);
|
2013-02-25 23:41:40 +04:00
|
|
|
tcg_gen_add2_tl(t0, cpu_ca, t0, cpu_ca, inv1, zero);
|
2013-02-20 11:52:17 +04:00
|
|
|
tcg_temp_free(zero);
|
2013-02-25 23:41:40 +04:00
|
|
|
tcg_temp_free(inv1);
|
2013-02-20 11:52:17 +04:00
|
|
|
} else {
|
2013-03-21 14:01:45 +04:00
|
|
|
tcg_gen_setcond_tl(TCG_COND_GEU, cpu_ca, arg2, arg1);
|
2013-02-20 11:52:17 +04:00
|
|
|
tcg_gen_sub_tl(t0, arg2, arg1);
|
|
|
|
}
|
2013-03-21 14:01:45 +04: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 17:55:54 +03:00
|
|
|
} else {
|
2013-02-20 11:52:17 +04:00
|
|
|
tcg_gen_sub_tl(t0, arg2, arg1);
|
2008-11-01 03:54:12 +03:00
|
|
|
}
|
2013-02-20 11:52:17 +04:00
|
|
|
|
2008-11-01 03:54:12 +03:00
|
|
|
if (compute_ov) {
|
|
|
|
gen_op_arith_compute_ov(ctx, t0, arg1, arg2, 1);
|
|
|
|
}
|
2013-02-20 11:52:17 +04:00
|
|
|
if (unlikely(compute_rc0)) {
|
2008-11-01 03:54:12 +03:00
|
|
|
gen_set_Rc0(ctx, t0);
|
2013-02-20 11:52:17 +04:00
|
|
|
}
|
2008-11-01 03:54:12 +03:00
|
|
|
|
2008-11-17 17:43:54 +03:00
|
|
|
if (!TCGV_EQUAL(t0, ret)) {
|
2008-11-01 03:54:12 +03:00
|
|
|
tcg_gen_mov_tl(ret, t0);
|
|
|
|
tcg_temp_free(t0);
|
2003-11-23 17:55:54 +03:00
|
|
|
}
|
|
|
|
}
|
2008-11-01 03:54:12 +03:00
|
|
|
/* Sub functions with Two operands functions */
|
|
|
|
#define GEN_INT_ARITH_SUBF(name, opc3, add_ca, compute_ca, compute_ov) \
|
2013-02-20 11:52:17 +04:00
|
|
|
static void glue(gen_, name)(DisasContext *ctx) \
|
2008-11-01 03:54:12 +03:00
|
|
|
{ \
|
|
|
|
gen_op_arith_subf(ctx, cpu_gpr[rD(ctx->opcode)], \
|
|
|
|
cpu_gpr[rA(ctx->opcode)], cpu_gpr[rB(ctx->opcode)], \
|
2013-02-20 11:52:17 +04:00
|
|
|
add_ca, compute_ca, compute_ov, Rc(ctx->opcode)); \
|
2008-11-01 03:54:12 +03: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 11:52:17 +04:00
|
|
|
static void glue(gen_, name)(DisasContext *ctx) \
|
2008-11-01 03:54:12 +03:00
|
|
|
{ \
|
2013-02-20 11:52:17 +04:00
|
|
|
TCGv t0 = tcg_const_tl(const_val); \
|
2008-11-01 03:54:12 +03:00
|
|
|
gen_op_arith_subf(ctx, cpu_gpr[rD(ctx->opcode)], \
|
|
|
|
cpu_gpr[rA(ctx->opcode)], t0, \
|
2013-02-20 11:52:17 +04:00
|
|
|
add_ca, compute_ca, compute_ov, Rc(ctx->opcode)); \
|
2008-11-01 03:54:12 +03: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 19:22:09 +04:00
|
|
|
|
2009-06-17 19:22:19 +04:00
|
|
|
/* subfic */
|
2009-06-17 19:22:09 +04:00
|
|
|
static void gen_subfic(DisasContext *ctx)
|
2003-11-23 17:55:54 +03:00
|
|
|
{
|
2013-02-20 11:52:17 +04: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 17:55:54 +03:00
|
|
|
}
|
|
|
|
|
2013-02-20 11:52:18 +04: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 17:55:54 +03:00
|
|
|
/*** Integer logical ***/
|
2008-10-21 15:31:27 +04:00
|
|
|
#define GEN_LOGICAL2(name, tcg_op, opc, type) \
|
2009-06-17 19:22:09 +04:00
|
|
|
static void glue(gen_, name)(DisasContext *ctx) \
|
2003-11-23 17:55:54 +03:00
|
|
|
{ \
|
2008-10-21 15:31:27 +04:00
|
|
|
tcg_op(cpu_gpr[rA(ctx->opcode)], cpu_gpr[rS(ctx->opcode)], \
|
|
|
|
cpu_gpr[rB(ctx->opcode)]); \
|
2007-03-07 11:32:30 +03:00
|
|
|
if (unlikely(Rc(ctx->opcode) != 0)) \
|
2008-10-21 15:31:27 +04:00
|
|
|
gen_set_Rc0(ctx, cpu_gpr[rA(ctx->opcode)]); \
|
2003-11-23 17:55:54 +03:00
|
|
|
}
|
|
|
|
|
2008-10-21 15:31:27 +04:00
|
|
|
#define GEN_LOGICAL1(name, tcg_op, opc, type) \
|
2009-06-17 19:22:09 +04:00
|
|
|
static void glue(gen_, name)(DisasContext *ctx) \
|
2003-11-23 17:55:54 +03:00
|
|
|
{ \
|
2008-10-21 15:31:27 +04:00
|
|
|
tcg_op(cpu_gpr[rA(ctx->opcode)], cpu_gpr[rS(ctx->opcode)]); \
|
2007-03-07 11:32:30 +03:00
|
|
|
if (unlikely(Rc(ctx->opcode) != 0)) \
|
2008-10-21 15:31:27 +04:00
|
|
|
gen_set_Rc0(ctx, cpu_gpr[rA(ctx->opcode)]); \
|
2003-11-23 17:55:54 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/* and & and. */
|
2008-10-21 15:31:27 +04:00
|
|
|
GEN_LOGICAL2(and, tcg_gen_and_tl, 0x00, PPC_INTEGER);
|
2003-11-23 17:55:54 +03:00
|
|
|
/* andc & andc. */
|
2008-10-21 15:31:27 +04:00
|
|
|
GEN_LOGICAL2(andc, tcg_gen_andc_tl, 0x01, PPC_INTEGER);
|
2009-06-17 19:22:14 +04:00
|
|
|
|
2009-06-17 19:22:19 +04:00
|
|
|
/* andi. */
|
2009-06-17 19:22:14 +04:00
|
|
|
static void gen_andi_(DisasContext *ctx)
|
2003-11-23 17:55:54 +03:00
|
|
|
{
|
2008-10-21 15:31:27 +04: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 17:55:54 +03:00
|
|
|
}
|
2009-06-17 19:22:14 +04:00
|
|
|
|
2009-06-17 19:22:19 +04:00
|
|
|
/* andis. */
|
2009-06-17 19:22:14 +04:00
|
|
|
static void gen_andis_(DisasContext *ctx)
|
2003-11-23 17:55:54 +03:00
|
|
|
{
|
2008-10-21 15:31:27 +04: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 17:55:54 +03:00
|
|
|
}
|
2009-06-17 19:22:09 +04:00
|
|
|
|
2009-06-17 19:22:19 +04:00
|
|
|
/* cntlzw */
|
2009-06-17 19:22:09 +04:00
|
|
|
static void gen_cntlzw(DisasContext *ctx)
|
2008-10-21 15:31:27 +04:00
|
|
|
{
|
2008-11-17 17:43:54 +03:00
|
|
|
gen_helper_cntlzw(cpu_gpr[rA(ctx->opcode)], cpu_gpr[rS(ctx->opcode)]);
|
2008-10-21 15:31:27 +04:00
|
|
|
if (unlikely(Rc(ctx->opcode) != 0))
|
2008-10-24 16:03:16 +04:00
|
|
|
gen_set_Rc0(ctx, cpu_gpr[rA(ctx->opcode)]);
|
2008-10-21 15:31:27 +04:00
|
|
|
}
|
2016-07-26 14:58:33 +03:00
|
|
|
|
|
|
|
/* cnttzw */
|
|
|
|
static void gen_cnttzw(DisasContext *ctx)
|
|
|
|
{
|
|
|
|
gen_helper_cnttzw(cpu_gpr[rA(ctx->opcode)], cpu_gpr[rS(ctx->opcode)]);
|
|
|
|
if (unlikely(Rc(ctx->opcode) != 0)) {
|
|
|
|
gen_set_Rc0(ctx, cpu_gpr[rA(ctx->opcode)]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-11-23 17:55:54 +03:00
|
|
|
/* eqv & eqv. */
|
2008-10-21 15:31:27 +04:00
|
|
|
GEN_LOGICAL2(eqv, tcg_gen_eqv_tl, 0x08, PPC_INTEGER);
|
2003-11-23 17:55:54 +03:00
|
|
|
/* extsb & extsb. */
|
2008-10-21 15:31:27 +04:00
|
|
|
GEN_LOGICAL1(extsb, tcg_gen_ext8s_tl, 0x1D, PPC_INTEGER);
|
2003-11-23 17:55:54 +03:00
|
|
|
/* extsh & extsh. */
|
2008-10-21 15:31:27 +04:00
|
|
|
GEN_LOGICAL1(extsh, tcg_gen_ext16s_tl, 0x1C, PPC_INTEGER);
|
2003-11-23 17:55:54 +03:00
|
|
|
/* nand & nand. */
|
2008-10-21 15:31:27 +04:00
|
|
|
GEN_LOGICAL2(nand, tcg_gen_nand_tl, 0x0E, PPC_INTEGER);
|
2003-11-23 17:55:54 +03:00
|
|
|
/* nor & nor. */
|
2008-10-21 15:31:27 +04:00
|
|
|
GEN_LOGICAL2(nor, tcg_gen_nor_tl, 0x03, PPC_INTEGER);
|
2009-06-17 19:22:09 +04:00
|
|
|
|
2016-06-19 22:19:24 +03:00
|
|
|
#if defined(TARGET_PPC64) && !defined(CONFIG_USER_ONLY)
|
2016-05-03 19:03:33 +03:00
|
|
|
static void gen_pause(DisasContext *ctx)
|
|
|
|
{
|
|
|
|
TCGv_i32 t0 = tcg_const_i32(0);
|
|
|
|
tcg_gen_st_i32(t0, cpu_env,
|
|
|
|
-offsetof(PowerPCCPU, env) + offsetof(CPUState, halted));
|
|
|
|
tcg_temp_free_i32(t0);
|
|
|
|
|
|
|
|
/* Stop translation, this gives other CPUs a chance to run */
|
2016-07-27 09:56:32 +03:00
|
|
|
gen_exception_nip(ctx, EXCP_HLT, ctx->nip);
|
2016-05-03 19:03:33 +03:00
|
|
|
}
|
|
|
|
#endif /* defined(TARGET_PPC64) */
|
|
|
|
|
2009-06-17 19:22:19 +04:00
|
|
|
/* or & or. */
|
2009-06-17 19:22:09 +04:00
|
|
|
static void gen_or(DisasContext *ctx)
|
2004-01-05 01:58:38 +03:00
|
|
|
{
|
2007-03-07 11:32:30 +03: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 15:31:27 +04: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 11:32:30 +03:00
|
|
|
if (unlikely(Rc(ctx->opcode) != 0))
|
2008-10-21 15:31:27 +04:00
|
|
|
gen_set_Rc0(ctx, cpu_gpr[ra]);
|
2007-03-07 11:32:30 +03:00
|
|
|
} else if (unlikely(Rc(ctx->opcode) != 0)) {
|
2008-10-21 15:31:27 +04:00
|
|
|
gen_set_Rc0(ctx, cpu_gpr[rs]);
|
2007-09-30 05:18:26 +04:00
|
|
|
#if defined(TARGET_PPC64)
|
2016-06-24 23:18:28 +03:00
|
|
|
} else if (rs != 0) { /* 0 is nop */
|
2008-10-21 15:31:27 +04:00
|
|
|
int prio = 0;
|
|
|
|
|
2007-09-30 05:18:26 +04:00
|
|
|
switch (rs) {
|
|
|
|
case 1:
|
|
|
|
/* Set process priority to low */
|
2008-10-21 15:31:27 +04:00
|
|
|
prio = 2;
|
2007-09-30 05:18:26 +04:00
|
|
|
break;
|
|
|
|
case 6:
|
|
|
|
/* Set process priority to medium-low */
|
2008-10-21 15:31:27 +04:00
|
|
|
prio = 3;
|
2007-09-30 05:18:26 +04:00
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
/* Set process priority to normal */
|
2008-10-21 15:31:27 +04:00
|
|
|
prio = 4;
|
2007-09-30 05:18:26 +04:00
|
|
|
break;
|
2007-09-30 17:03:23 +04:00
|
|
|
#if !defined(CONFIG_USER_ONLY)
|
|
|
|
case 31:
|
2014-09-15 19:03:28 +04:00
|
|
|
if (!ctx->pr) {
|
2007-09-30 17:03:23 +04:00
|
|
|
/* Set process priority to very low */
|
2008-10-21 15:31:27 +04:00
|
|
|
prio = 1;
|
2007-09-30 17:03:23 +04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 5:
|
2014-09-15 19:03:28 +04:00
|
|
|
if (!ctx->pr) {
|
2007-09-30 17:03:23 +04:00
|
|
|
/* Set process priority to medium-hight */
|
2008-10-21 15:31:27 +04:00
|
|
|
prio = 5;
|
2007-09-30 17:03:23 +04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 3:
|
2014-09-15 19:03:28 +04:00
|
|
|
if (!ctx->pr) {
|
2007-09-30 17:03:23 +04:00
|
|
|
/* Set process priority to high */
|
2008-10-21 15:31:27 +04:00
|
|
|
prio = 6;
|
2007-09-30 17:03:23 +04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 7:
|
2016-05-03 19:03:33 +03:00
|
|
|
if (ctx->hv && !ctx->pr) {
|
2007-09-30 17:03:23 +04:00
|
|
|
/* Set process priority to very high */
|
2008-10-21 15:31:27 +04:00
|
|
|
prio = 7;
|
2007-09-30 17:03:23 +04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
#endif
|
2007-09-30 05:18:26 +04:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2008-10-21 15:31:27 +04:00
|
|
|
if (prio) {
|
2008-11-17 17:43:54 +03:00
|
|
|
TCGv t0 = tcg_temp_new();
|
2008-12-05 10:21:31 +03:00
|
|
|
gen_load_spr(t0, SPR_PPR);
|
2008-10-28 01:50:39 +03:00
|
|
|
tcg_gen_andi_tl(t0, t0, ~0x001C000000000000ULL);
|
|
|
|
tcg_gen_ori_tl(t0, t0, ((uint64_t)prio) << 50);
|
2008-12-05 10:21:31 +03:00
|
|
|
gen_store_spr(SPR_PPR, t0);
|
2008-10-28 01:50:39 +03:00
|
|
|
tcg_temp_free(t0);
|
2016-06-24 23:18:28 +03:00
|
|
|
}
|
2016-06-19 22:19:24 +03:00
|
|
|
#if !defined(CONFIG_USER_ONLY)
|
2016-06-24 23:18:28 +03:00
|
|
|
/* Pause out of TCG otherwise spin loops with smt_low eat too much
|
|
|
|
* CPU and the kernel hangs. This applies to all encodings other
|
|
|
|
* than no-op, e.g., miso(rs=26), yield(27), mdoio(29), mdoom(30),
|
|
|
|
* and all currently undefined.
|
|
|
|
*/
|
|
|
|
gen_pause(ctx);
|
2016-06-19 22:19:24 +03:00
|
|
|
#endif
|
2007-09-30 05:18:26 +04:00
|
|
|
#endif
|
2004-01-05 01:58:38 +03:00
|
|
|
}
|
|
|
|
}
|
2003-11-23 17:55:54 +03:00
|
|
|
/* orc & orc. */
|
2008-10-21 15:31:27 +04:00
|
|
|
GEN_LOGICAL2(orc, tcg_gen_orc_tl, 0x0C, PPC_INTEGER);
|
2009-06-17 19:22:09 +04:00
|
|
|
|
2009-06-17 19:22:19 +04:00
|
|
|
/* xor & xor. */
|
2009-06-17 19:22:09 +04:00
|
|
|
static void gen_xor(DisasContext *ctx)
|
2004-01-05 01:58:38 +03:00
|
|
|
{
|
|
|
|
/* Optimisation for "set to zero" case */
|
2008-10-21 15:31:27 +04:00
|
|
|
if (rS(ctx->opcode) != rB(ctx->opcode))
|
2008-10-28 01:50:31 +03:00
|
|
|
tcg_gen_xor_tl(cpu_gpr[rA(ctx->opcode)], cpu_gpr[rS(ctx->opcode)], cpu_gpr[rB(ctx->opcode)]);
|
2008-10-21 15:31:27 +04:00
|
|
|
else
|
|
|
|
tcg_gen_movi_tl(cpu_gpr[rA(ctx->opcode)], 0);
|
2007-03-07 11:32:30 +03:00
|
|
|
if (unlikely(Rc(ctx->opcode) != 0))
|
2008-10-21 15:31:27 +04:00
|
|
|
gen_set_Rc0(ctx, cpu_gpr[rA(ctx->opcode)]);
|
2004-01-05 01:58:38 +03:00
|
|
|
}
|
2009-06-17 19:22:09 +04:00
|
|
|
|
2009-06-17 19:22:19 +04:00
|
|
|
/* ori */
|
2009-06-17 19:22:09 +04:00
|
|
|
static void gen_ori(DisasContext *ctx)
|
2003-11-23 17:55:54 +03:00
|
|
|
{
|
2007-03-07 11:32:30 +03:00
|
|
|
target_ulong uimm = UIMM(ctx->opcode);
|
2003-11-23 17:55:54 +03:00
|
|
|
|
2004-01-05 01:58:38 +03:00
|
|
|
if (rS(ctx->opcode) == rA(ctx->opcode) && uimm == 0) {
|
|
|
|
return;
|
2007-03-07 11:32:30 +03:00
|
|
|
}
|
2008-10-21 15:31:27 +04:00
|
|
|
tcg_gen_ori_tl(cpu_gpr[rA(ctx->opcode)], cpu_gpr[rS(ctx->opcode)], uimm);
|
2003-11-23 17:55:54 +03:00
|
|
|
}
|
2009-06-17 19:22:09 +04:00
|
|
|
|
2009-06-17 19:22:19 +04:00
|
|
|
/* oris */
|
2009-06-17 19:22:09 +04:00
|
|
|
static void gen_oris(DisasContext *ctx)
|
2003-11-23 17:55:54 +03:00
|
|
|
{
|
2007-03-07 11:32:30 +03:00
|
|
|
target_ulong uimm = UIMM(ctx->opcode);
|
2003-11-23 17:55:54 +03:00
|
|
|
|
2004-01-05 01:58:38 +03:00
|
|
|
if (rS(ctx->opcode) == rA(ctx->opcode) && uimm == 0) {
|
|
|
|
/* NOP */
|
|
|
|
return;
|
2007-03-07 11:32:30 +03:00
|
|
|
}
|
2008-10-21 15:31:27 +04:00
|
|
|
tcg_gen_ori_tl(cpu_gpr[rA(ctx->opcode)], cpu_gpr[rS(ctx->opcode)], uimm << 16);
|
2003-11-23 17:55:54 +03:00
|
|
|
}
|
2009-06-17 19:22:09 +04:00
|
|
|
|
2009-06-17 19:22:19 +04:00
|
|
|
/* xori */
|
2009-06-17 19:22:09 +04:00
|
|
|
static void gen_xori(DisasContext *ctx)
|
2003-11-23 17:55:54 +03:00
|
|
|
{
|
2007-03-07 11:32:30 +03:00
|
|
|
target_ulong uimm = UIMM(ctx->opcode);
|
2004-01-05 01:58:38 +03:00
|
|
|
|
|
|
|
if (rS(ctx->opcode) == rA(ctx->opcode) && uimm == 0) {
|
|
|
|
/* NOP */
|
|
|
|
return;
|
|
|
|
}
|
2008-10-21 15:31:27 +04:00
|
|
|
tcg_gen_xori_tl(cpu_gpr[rA(ctx->opcode)], cpu_gpr[rS(ctx->opcode)], uimm);
|
2003-11-23 17:55:54 +03:00
|
|
|
}
|
2009-06-17 19:22:09 +04:00
|
|
|
|
2009-06-17 19:22:19 +04:00
|
|
|
/* xoris */
|
2009-06-17 19:22:09 +04:00
|
|
|
static void gen_xoris(DisasContext *ctx)
|
2003-11-23 17:55:54 +03:00
|
|
|
{
|
2007-03-07 11:32:30 +03:00
|
|
|
target_ulong uimm = UIMM(ctx->opcode);
|
2004-01-05 01:58:38 +03:00
|
|
|
|
|
|
|
if (rS(ctx->opcode) == rA(ctx->opcode) && uimm == 0) {
|
|
|
|
/* NOP */
|
|
|
|
return;
|
|
|
|
}
|
2008-10-21 15:31:27 +04:00
|
|
|
tcg_gen_xori_tl(cpu_gpr[rA(ctx->opcode)], cpu_gpr[rS(ctx->opcode)], uimm << 16);
|
2003-11-23 17:55:54 +03:00
|
|
|
}
|
2009-06-17 19:22:09 +04:00
|
|
|
|
2009-06-17 19:22:19 +04:00
|
|
|
/* popcntb : PowerPC 2.03 specification */
|
2009-06-17 19:22:09 +04:00
|
|
|
static void gen_popcntb(DisasContext *ctx)
|
2007-03-17 17:02:15 +03:00
|
|
|
{
|
2011-04-01 08:15:13 +04: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 17:02:15 +03:00
|
|
|
#if defined(TARGET_PPC64)
|
2011-04-01 08:15:13 +04: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 17:02:15 +03:00
|
|
|
}
|
2011-04-01 08:15:13 +04:00
|
|
|
#endif
|
2007-03-17 17:02:15 +03:00
|
|
|
|
2013-04-20 12:56:17 +04: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 20:05:49 +04: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 17:02:15 +03:00
|
|
|
#if defined(TARGET_PPC64)
|
|
|
|
/* extsw & extsw. */
|
2008-10-21 15:31:27 +04:00
|
|
|
GEN_LOGICAL1(extsw, tcg_gen_ext32s_tl, 0x1E, PPC_64B);
|
2009-06-17 19:22:09 +04:00
|
|
|
|
2009-06-17 19:22:19 +04:00
|
|
|
/* cntlzd */
|
2009-06-17 19:22:09 +04:00
|
|
|
static void gen_cntlzd(DisasContext *ctx)
|
2008-10-21 15:31:27 +04:00
|
|
|
{
|
2008-11-17 17:43:54 +03:00
|
|
|
gen_helper_cntlzd(cpu_gpr[rA(ctx->opcode)], cpu_gpr[rS(ctx->opcode)]);
|
2008-10-21 15:31:27 +04:00
|
|
|
if (unlikely(Rc(ctx->opcode) != 0))
|
|
|
|
gen_set_Rc0(ctx, cpu_gpr[rA(ctx->opcode)]);
|
|
|
|
}
|
2016-07-26 14:58:32 +03:00
|
|
|
|
|
|
|
/* cnttzd */
|
|
|
|
static void gen_cnttzd(DisasContext *ctx)
|
|
|
|
{
|
|
|
|
gen_helper_cnttzd(cpu_gpr[rA(ctx->opcode)], cpu_gpr[rS(ctx->opcode)]);
|
|
|
|
if (unlikely(Rc(ctx->opcode) != 0)) {
|
|
|
|
gen_set_Rc0(ctx, cpu_gpr[rA(ctx->opcode)]);
|
|
|
|
}
|
|
|
|
}
|
2007-03-17 17:02:15 +03:00
|
|
|
#endif
|
|
|
|
|
2003-11-23 17:55:54 +03:00
|
|
|
/*** Integer rotate ***/
|
2009-06-17 19:22:09 +04:00
|
|
|
|
2009-06-17 19:22:19 +04:00
|
|
|
/* rlwimi & rlwimi. */
|
2009-06-17 19:22:09 +04:00
|
|
|
static void gen_rlwimi(DisasContext *ctx)
|
2003-11-23 17:55:54 +03:00
|
|
|
{
|
2016-02-24 04:18:35 +03:00
|
|
|
TCGv t_ra = cpu_gpr[rA(ctx->opcode)];
|
|
|
|
TCGv t_rs = cpu_gpr[rS(ctx->opcode)];
|
|
|
|
uint32_t sh = SH(ctx->opcode);
|
|
|
|
uint32_t mb = MB(ctx->opcode);
|
|
|
|
uint32_t me = ME(ctx->opcode);
|
|
|
|
|
|
|
|
if (sh == (31-me) && mb <= me) {
|
|
|
|
tcg_gen_deposit_tl(t_ra, t_ra, t_rs, sh, me - mb + 1);
|
2008-10-28 01:50:22 +03:00
|
|
|
} else {
|
|
|
|
target_ulong mask;
|
2008-11-17 17:43:54 +03:00
|
|
|
TCGv t1;
|
2016-02-24 04:18:35 +03:00
|
|
|
|
2007-03-07 11:32:30 +03:00
|
|
|
#if defined(TARGET_PPC64)
|
2008-10-28 01:50:22 +03:00
|
|
|
mb += 32;
|
|
|
|
me += 32;
|
2007-03-07 11:32:30 +03:00
|
|
|
#endif
|
2008-10-28 01:50:22 +03:00
|
|
|
mask = MASK(mb, me);
|
2016-02-24 04:18:35 +03:00
|
|
|
|
2008-11-17 17:43:54 +03:00
|
|
|
t1 = tcg_temp_new();
|
2016-06-16 22:04:04 +03:00
|
|
|
if (mask <= 0xffffffffu) {
|
|
|
|
TCGv_i32 t0 = tcg_temp_new_i32();
|
|
|
|
tcg_gen_trunc_tl_i32(t0, t_rs);
|
|
|
|
tcg_gen_rotli_i32(t0, t0, sh);
|
|
|
|
tcg_gen_extu_i32_tl(t1, t0);
|
|
|
|
tcg_temp_free_i32(t0);
|
|
|
|
} else {
|
|
|
|
#if defined(TARGET_PPC64)
|
|
|
|
tcg_gen_deposit_i64(t1, t_rs, t_rs, 32, 32);
|
|
|
|
tcg_gen_rotli_i64(t1, t1, sh);
|
|
|
|
#else
|
|
|
|
g_assert_not_reached();
|
|
|
|
#endif
|
|
|
|
}
|
2016-02-24 04:18:35 +03:00
|
|
|
|
|
|
|
tcg_gen_andi_tl(t1, t1, mask);
|
|
|
|
tcg_gen_andi_tl(t_ra, t_ra, ~mask);
|
|
|
|
tcg_gen_or_tl(t_ra, t_ra, t1);
|
2008-10-28 01:50:22 +03:00
|
|
|
tcg_temp_free(t1);
|
|
|
|
}
|
2016-02-24 04:18:35 +03:00
|
|
|
if (unlikely(Rc(ctx->opcode) != 0)) {
|
|
|
|
gen_set_Rc0(ctx, t_ra);
|
|
|
|
}
|
2003-11-23 17:55:54 +03:00
|
|
|
}
|
2009-06-17 19:22:09 +04:00
|
|
|
|
2009-06-17 19:22:19 +04:00
|
|
|
/* rlwinm & rlwinm. */
|
2009-06-17 19:22:09 +04:00
|
|
|
static void gen_rlwinm(DisasContext *ctx)
|
2003-11-23 17:55:54 +03:00
|
|
|
{
|
2016-02-24 04:18:35 +03:00
|
|
|
TCGv t_ra = cpu_gpr[rA(ctx->opcode)];
|
|
|
|
TCGv t_rs = cpu_gpr[rS(ctx->opcode)];
|
|
|
|
uint32_t sh = SH(ctx->opcode);
|
|
|
|
uint32_t mb = MB(ctx->opcode);
|
|
|
|
uint32_t me = ME(ctx->opcode);
|
|
|
|
|
|
|
|
if (mb == 0 && me == (31 - sh)) {
|
|
|
|
tcg_gen_shli_tl(t_ra, t_rs, sh);
|
|
|
|
tcg_gen_ext32u_tl(t_ra, t_ra);
|
|
|
|
} else if (sh != 0 && me == 31 && sh == (32 - mb)) {
|
|
|
|
tcg_gen_ext32u_tl(t_ra, t_rs);
|
|
|
|
tcg_gen_shri_tl(t_ra, t_ra, mb);
|
2008-10-28 01:50:22 +03:00
|
|
|
} else {
|
2016-06-16 22:04:04 +03:00
|
|
|
target_ulong mask;
|
2007-03-07 11:32:30 +03:00
|
|
|
#if defined(TARGET_PPC64)
|
2008-10-28 01:50:22 +03:00
|
|
|
mb += 32;
|
|
|
|
me += 32;
|
2007-03-07 11:32:30 +03:00
|
|
|
#endif
|
2016-06-16 22:04:04 +03:00
|
|
|
mask = MASK(mb, me);
|
|
|
|
|
2016-06-20 04:03:37 +03:00
|
|
|
if (mask <= 0xffffffffu) {
|
2016-02-24 04:18:35 +03:00
|
|
|
TCGv_i32 t0 = tcg_temp_new_i32();
|
|
|
|
tcg_gen_trunc_tl_i32(t0, t_rs);
|
|
|
|
tcg_gen_rotli_i32(t0, t0, sh);
|
2016-06-16 22:04:04 +03:00
|
|
|
tcg_gen_andi_i32(t0, t0, mask);
|
2016-02-24 04:18:35 +03:00
|
|
|
tcg_gen_extu_i32_tl(t_ra, t0);
|
|
|
|
tcg_temp_free_i32(t0);
|
2016-06-16 22:04:04 +03:00
|
|
|
} else {
|
|
|
|
#if defined(TARGET_PPC64)
|
|
|
|
tcg_gen_deposit_i64(t_ra, t_rs, t_rs, 32, 32);
|
|
|
|
tcg_gen_rotli_i64(t_ra, t_ra, sh);
|
|
|
|
tcg_gen_andi_i64(t_ra, t_ra, mask);
|
|
|
|
#else
|
|
|
|
g_assert_not_reached();
|
|
|
|
#endif
|
2016-02-24 04:18:35 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (unlikely(Rc(ctx->opcode) != 0)) {
|
|
|
|
gen_set_Rc0(ctx, t_ra);
|
2008-10-28 01:50:22 +03:00
|
|
|
}
|
2003-11-23 17:55:54 +03:00
|
|
|
}
|
2009-06-17 19:22:09 +04:00
|
|
|
|
2009-06-17 19:22:19 +04:00
|
|
|
/* rlwnm & rlwnm. */
|
2009-06-17 19:22:09 +04:00
|
|
|
static void gen_rlwnm(DisasContext *ctx)
|
2003-11-23 17:55:54 +03:00
|
|
|
{
|
2016-02-24 04:18:35 +03:00
|
|
|
TCGv t_ra = cpu_gpr[rA(ctx->opcode)];
|
|
|
|
TCGv t_rs = cpu_gpr[rS(ctx->opcode)];
|
|
|
|
TCGv t_rb = cpu_gpr[rB(ctx->opcode)];
|
|
|
|
uint32_t mb = MB(ctx->opcode);
|
|
|
|
uint32_t me = ME(ctx->opcode);
|
2016-06-16 22:04:04 +03:00
|
|
|
target_ulong mask;
|
2014-08-25 23:25:41 +04:00
|
|
|
|
2008-11-03 10:08:44 +03:00
|
|
|
#if defined(TARGET_PPC64)
|
2016-02-24 04:18:35 +03:00
|
|
|
mb += 32;
|
|
|
|
me += 32;
|
2008-11-03 10:08:44 +03:00
|
|
|
#endif
|
2016-06-16 22:04:04 +03:00
|
|
|
mask = MASK(mb, me);
|
|
|
|
|
|
|
|
if (mask <= 0xffffffffu) {
|
|
|
|
TCGv_i32 t0 = tcg_temp_new_i32();
|
|
|
|
TCGv_i32 t1 = tcg_temp_new_i32();
|
|
|
|
tcg_gen_trunc_tl_i32(t0, t_rb);
|
|
|
|
tcg_gen_trunc_tl_i32(t1, t_rs);
|
|
|
|
tcg_gen_andi_i32(t0, t0, 0x1f);
|
|
|
|
tcg_gen_rotl_i32(t1, t1, t0);
|
|
|
|
tcg_gen_extu_i32_tl(t_ra, t1);
|
|
|
|
tcg_temp_free_i32(t0);
|
|
|
|
tcg_temp_free_i32(t1);
|
|
|
|
} else {
|
|
|
|
#if defined(TARGET_PPC64)
|
|
|
|
TCGv_i64 t0 = tcg_temp_new_i64();
|
|
|
|
tcg_gen_andi_i64(t0, t_rb, 0x1f);
|
|
|
|
tcg_gen_deposit_i64(t_ra, t_rs, t_rs, 32, 32);
|
|
|
|
tcg_gen_rotl_i64(t_ra, t_ra, t0);
|
|
|
|
tcg_temp_free_i64(t0);
|
|
|
|
#else
|
|
|
|
g_assert_not_reached();
|
|
|
|
#endif
|
|
|
|
}
|
2014-08-25 23:25:41 +04:00
|
|
|
|
2016-06-16 22:04:04 +03:00
|
|
|
tcg_gen_andi_tl(t_ra, t_ra, mask);
|
2016-02-24 04:18:35 +03:00
|
|
|
|
|
|
|
if (unlikely(Rc(ctx->opcode) != 0)) {
|
|
|
|
gen_set_Rc0(ctx, t_ra);
|
2003-11-23 17:55:54 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-03-17 17:02:15 +03:00
|
|
|
#if defined(TARGET_PPC64)
|
|
|
|
#define GEN_PPC64_R2(name, opc1, opc2) \
|
2009-06-17 19:22:14 +04:00
|
|
|
static void glue(gen_, name##0)(DisasContext *ctx) \
|
2007-03-17 17:02:15 +03:00
|
|
|
{ \
|
|
|
|
gen_##name(ctx, 0); \
|
|
|
|
} \
|
2009-06-17 19:22:14 +04:00
|
|
|
\
|
|
|
|
static void glue(gen_, name##1)(DisasContext *ctx) \
|
2007-03-17 17:02:15 +03:00
|
|
|
{ \
|
|
|
|
gen_##name(ctx, 1); \
|
|
|
|
}
|
|
|
|
#define GEN_PPC64_R4(name, opc1, opc2) \
|
2009-06-17 19:22:14 +04:00
|
|
|
static void glue(gen_, name##0)(DisasContext *ctx) \
|
2007-03-17 17:02:15 +03:00
|
|
|
{ \
|
|
|
|
gen_##name(ctx, 0, 0); \
|
|
|
|
} \
|
2009-06-17 19:22:14 +04:00
|
|
|
\
|
|
|
|
static void glue(gen_, name##1)(DisasContext *ctx) \
|
2007-03-17 17:02:15 +03:00
|
|
|
{ \
|
|
|
|
gen_##name(ctx, 0, 1); \
|
|
|
|
} \
|
2009-06-17 19:22:14 +04:00
|
|
|
\
|
|
|
|
static void glue(gen_, name##2)(DisasContext *ctx) \
|
2007-03-17 17:02:15 +03:00
|
|
|
{ \
|
|
|
|
gen_##name(ctx, 1, 0); \
|
|
|
|
} \
|
2009-06-17 19:22:14 +04:00
|
|
|
\
|
|
|
|
static void glue(gen_, name##3)(DisasContext *ctx) \
|
2007-03-17 17:02:15 +03:00
|
|
|
{ \
|
|
|
|
gen_##name(ctx, 1, 1); \
|
|
|
|
}
|
2007-03-23 01:41:50 +03:00
|
|
|
|
2016-02-24 04:18:36 +03:00
|
|
|
static void gen_rldinm(DisasContext *ctx, int mb, int me, int sh)
|
2007-03-23 01:41:50 +03:00
|
|
|
{
|
2016-02-24 04:18:36 +03:00
|
|
|
TCGv t_ra = cpu_gpr[rA(ctx->opcode)];
|
|
|
|
TCGv t_rs = cpu_gpr[rS(ctx->opcode)];
|
|
|
|
|
|
|
|
if (sh != 0 && mb == 0 && me == (63 - sh)) {
|
|
|
|
tcg_gen_shli_tl(t_ra, t_rs, sh);
|
|
|
|
} else if (sh != 0 && me == 63 && sh == (64 - mb)) {
|
|
|
|
tcg_gen_shri_tl(t_ra, t_rs, mb);
|
2008-10-28 01:50:22 +03:00
|
|
|
} else {
|
2016-02-24 04:18:36 +03:00
|
|
|
tcg_gen_rotli_tl(t_ra, t_rs, sh);
|
|
|
|
tcg_gen_andi_tl(t_ra, t_ra, MASK(mb, me));
|
|
|
|
}
|
|
|
|
if (unlikely(Rc(ctx->opcode) != 0)) {
|
|
|
|
gen_set_Rc0(ctx, t_ra);
|
2007-03-23 01:41:50 +03:00
|
|
|
}
|
|
|
|
}
|
2016-02-24 04:18:36 +03:00
|
|
|
|
2007-03-17 17:02:15 +03:00
|
|
|
/* rldicl - rldicl. */
|
2009-08-16 13:06:54 +04:00
|
|
|
static inline void gen_rldicl(DisasContext *ctx, int mbn, int shn)
|
2007-03-17 17:02:15 +03:00
|
|
|
{
|
2007-03-23 01:41:50 +03:00
|
|
|
uint32_t sh, mb;
|
2007-03-17 17:02:15 +03:00
|
|
|
|
2007-04-06 11:59:47 +04:00
|
|
|
sh = SH(ctx->opcode) | (shn << 5);
|
|
|
|
mb = MB(ctx->opcode) | (mbn << 5);
|
2007-03-23 01:41:50 +03:00
|
|
|
gen_rldinm(ctx, mb, 63, sh);
|
2007-03-17 17:02:15 +03:00
|
|
|
}
|
2007-03-23 01:41:50 +03:00
|
|
|
GEN_PPC64_R4(rldicl, 0x1E, 0x00);
|
2016-02-24 04:18:36 +03:00
|
|
|
|
2007-03-17 17:02:15 +03:00
|
|
|
/* rldicr - rldicr. */
|
2009-08-16 13:06:54 +04:00
|
|
|
static inline void gen_rldicr(DisasContext *ctx, int men, int shn)
|
2007-03-17 17:02:15 +03:00
|
|
|
{
|
2007-03-23 01:41:50 +03:00
|
|
|
uint32_t sh, me;
|
2007-03-17 17:02:15 +03:00
|
|
|
|
2007-04-06 11:59:47 +04:00
|
|
|
sh = SH(ctx->opcode) | (shn << 5);
|
|
|
|
me = MB(ctx->opcode) | (men << 5);
|
2007-03-23 01:41:50 +03:00
|
|
|
gen_rldinm(ctx, 0, me, sh);
|
2007-03-17 17:02:15 +03:00
|
|
|
}
|
2007-03-23 01:41:50 +03:00
|
|
|
GEN_PPC64_R4(rldicr, 0x1E, 0x02);
|
2016-02-24 04:18:36 +03:00
|
|
|
|
2007-03-17 17:02:15 +03:00
|
|
|
/* rldic - rldic. */
|
2009-08-16 13:06:54 +04:00
|
|
|
static inline void gen_rldic(DisasContext *ctx, int mbn, int shn)
|
2007-03-17 17:02:15 +03:00
|
|
|
{
|
2007-03-23 01:41:50 +03:00
|
|
|
uint32_t sh, mb;
|
2007-03-17 17:02:15 +03:00
|
|
|
|
2007-04-06 11:59:47 +04:00
|
|
|
sh = SH(ctx->opcode) | (shn << 5);
|
|
|
|
mb = MB(ctx->opcode) | (mbn << 5);
|
2007-03-23 01:41:50 +03:00
|
|
|
gen_rldinm(ctx, mb, 63 - sh, sh);
|
|
|
|
}
|
|
|
|
GEN_PPC64_R4(rldic, 0x1E, 0x04);
|
|
|
|
|
2016-02-24 04:18:36 +03:00
|
|
|
static void gen_rldnm(DisasContext *ctx, int mb, int me)
|
2007-03-23 01:41:50 +03:00
|
|
|
{
|
2016-02-24 04:18:36 +03:00
|
|
|
TCGv t_ra = cpu_gpr[rA(ctx->opcode)];
|
|
|
|
TCGv t_rs = cpu_gpr[rS(ctx->opcode)];
|
|
|
|
TCGv t_rb = cpu_gpr[rB(ctx->opcode)];
|
2008-11-03 10:08:44 +03:00
|
|
|
TCGv t0;
|
2008-10-28 01:50:22 +03:00
|
|
|
|
2008-11-17 17:43:54 +03:00
|
|
|
t0 = tcg_temp_new();
|
2016-02-24 04:18:36 +03:00
|
|
|
tcg_gen_andi_tl(t0, t_rb, 0x3f);
|
|
|
|
tcg_gen_rotl_tl(t_ra, t_rs, t0);
|
2008-11-03 10:08:44 +03:00
|
|
|
tcg_temp_free(t0);
|
2016-02-24 04:18:36 +03:00
|
|
|
|
|
|
|
tcg_gen_andi_tl(t_ra, t_ra, MASK(mb, me));
|
|
|
|
if (unlikely(Rc(ctx->opcode) != 0)) {
|
|
|
|
gen_set_Rc0(ctx, t_ra);
|
|
|
|
}
|
2007-03-17 17:02:15 +03:00
|
|
|
}
|
2007-03-23 01:41:50 +03:00
|
|
|
|
2007-03-17 17:02:15 +03:00
|
|
|
/* rldcl - rldcl. */
|
2009-08-16 13:06:54 +04:00
|
|
|
static inline void gen_rldcl(DisasContext *ctx, int mbn)
|
2007-03-17 17:02:15 +03:00
|
|
|
{
|
2007-03-23 01:41:50 +03:00
|
|
|
uint32_t mb;
|
2007-03-17 17:02:15 +03:00
|
|
|
|
2007-04-06 11:59:47 +04:00
|
|
|
mb = MB(ctx->opcode) | (mbn << 5);
|
2007-03-23 01:41:50 +03:00
|
|
|
gen_rldnm(ctx, mb, 63);
|
2007-03-17 17:02:15 +03:00
|
|
|
}
|
2007-09-17 12:21:54 +04:00
|
|
|
GEN_PPC64_R2(rldcl, 0x1E, 0x08);
|
2016-02-24 04:18:36 +03:00
|
|
|
|
2007-03-17 17:02:15 +03:00
|
|
|
/* rldcr - rldcr. */
|
2009-08-16 13:06:54 +04:00
|
|
|
static inline void gen_rldcr(DisasContext *ctx, int men)
|
2007-03-17 17:02:15 +03:00
|
|
|
{
|
2007-03-23 01:41:50 +03:00
|
|
|
uint32_t me;
|
2007-03-17 17:02:15 +03:00
|
|
|
|
2007-04-06 11:59:47 +04:00
|
|
|
me = MB(ctx->opcode) | (men << 5);
|
2007-03-23 01:41:50 +03:00
|
|
|
gen_rldnm(ctx, 0, me);
|
2007-03-17 17:02:15 +03:00
|
|
|
}
|
2007-09-17 12:21:54 +04:00
|
|
|
GEN_PPC64_R2(rldcr, 0x1E, 0x09);
|
2016-02-24 04:18:36 +03:00
|
|
|
|
2007-03-17 17:02:15 +03:00
|
|
|
/* rldimi - rldimi. */
|
2016-02-24 04:18:36 +03:00
|
|
|
static void gen_rldimi(DisasContext *ctx, int mbn, int shn)
|
2007-03-17 17:02:15 +03:00
|
|
|
{
|
2016-02-24 04:18:36 +03:00
|
|
|
TCGv t_ra = cpu_gpr[rA(ctx->opcode)];
|
|
|
|
TCGv t_rs = cpu_gpr[rS(ctx->opcode)];
|
|
|
|
uint32_t sh = SH(ctx->opcode) | (shn << 5);
|
|
|
|
uint32_t mb = MB(ctx->opcode) | (mbn << 5);
|
|
|
|
uint32_t me = 63 - sh;
|
2007-03-17 17:02:15 +03:00
|
|
|
|
2016-02-24 04:18:36 +03:00
|
|
|
if (mb <= me) {
|
|
|
|
tcg_gen_deposit_tl(t_ra, t_ra, t_rs, sh, me - mb + 1);
|
2008-10-28 01:50:22 +03:00
|
|
|
} else {
|
2016-02-24 04:18:36 +03:00
|
|
|
target_ulong mask = MASK(mb, me);
|
|
|
|
TCGv t1 = tcg_temp_new();
|
2008-10-28 01:50:22 +03:00
|
|
|
|
2016-02-24 04:18:36 +03:00
|
|
|
tcg_gen_rotli_tl(t1, t_rs, sh);
|
|
|
|
tcg_gen_andi_tl(t1, t1, mask);
|
|
|
|
tcg_gen_andi_tl(t_ra, t_ra, ~mask);
|
|
|
|
tcg_gen_or_tl(t_ra, t_ra, t1);
|
2008-10-28 01:50:22 +03:00
|
|
|
tcg_temp_free(t1);
|
2007-03-23 01:41:50 +03:00
|
|
|
}
|
2016-02-24 04:18:36 +03:00
|
|
|
if (unlikely(Rc(ctx->opcode) != 0)) {
|
|
|
|
gen_set_Rc0(ctx, t_ra);
|
|
|
|
}
|
2007-03-17 17:02:15 +03:00
|
|
|
}
|
2007-09-17 12:21:54 +04:00
|
|
|
GEN_PPC64_R4(rldimi, 0x1E, 0x06);
|
2007-03-17 17:02:15 +03:00
|
|
|
#endif
|
|
|
|
|
2003-11-23 17:55:54 +03:00
|
|
|
/*** Integer shift ***/
|
2009-06-17 19:22:09 +04:00
|
|
|
|
2009-06-17 19:22:19 +04:00
|
|
|
/* slw & slw. */
|
2009-06-17 19:22:09 +04:00
|
|
|
static void gen_slw(DisasContext *ctx)
|
2008-10-21 15:31:27 +04:00
|
|
|
{
|
2009-09-18 18:56:30 +04:00
|
|
|
TCGv t0, t1;
|
2008-10-21 15:31:27 +04:00
|
|
|
|
2009-09-18 18:56:30 +04: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 11:22:34 +03:00
|
|
|
tcg_temp_free(t0);
|
2009-09-18 18:56:30 +04:00
|
|
|
tcg_gen_ext32u_tl(cpu_gpr[rA(ctx->opcode)], cpu_gpr[rA(ctx->opcode)]);
|
2008-10-21 15:31:27 +04:00
|
|
|
if (unlikely(Rc(ctx->opcode) != 0))
|
|
|
|
gen_set_Rc0(ctx, cpu_gpr[rA(ctx->opcode)]);
|
|
|
|
}
|
2009-06-17 19:22:09 +04:00
|
|
|
|
2009-06-17 19:22:19 +04:00
|
|
|
/* sraw & sraw. */
|
2009-06-17 19:22:09 +04:00
|
|
|
static void gen_sraw(DisasContext *ctx)
|
2008-10-21 15:31:27 +04:00
|
|
|
{
|
2012-05-30 08:23:29 +04:00
|
|
|
gen_helper_sraw(cpu_gpr[rA(ctx->opcode)], cpu_env,
|
2008-11-17 17:43:54 +03:00
|
|
|
cpu_gpr[rS(ctx->opcode)], cpu_gpr[rB(ctx->opcode)]);
|
2008-10-21 15:31:27 +04:00
|
|
|
if (unlikely(Rc(ctx->opcode) != 0))
|
|
|
|
gen_set_Rc0(ctx, cpu_gpr[rA(ctx->opcode)]);
|
|
|
|
}
|
2009-06-17 19:22:09 +04:00
|
|
|
|
2009-06-17 19:22:19 +04:00
|
|
|
/* srawi & srawi. */
|
2009-06-17 19:22:09 +04:00
|
|
|
static void gen_srawi(DisasContext *ctx)
|
2003-11-23 17:55:54 +03:00
|
|
|
{
|
2008-10-21 15:31:27 +04:00
|
|
|
int sh = SH(ctx->opcode);
|
2013-02-20 11:52:19 +04:00
|
|
|
TCGv dst = cpu_gpr[rA(ctx->opcode)];
|
|
|
|
TCGv src = cpu_gpr[rS(ctx->opcode)];
|
|
|
|
if (sh == 0) {
|
2014-08-12 17:45:09 +04:00
|
|
|
tcg_gen_ext32s_tl(dst, src);
|
2013-02-20 11:52:13 +04:00
|
|
|
tcg_gen_movi_tl(cpu_ca, 0);
|
2008-10-21 15:31:27 +04:00
|
|
|
} else {
|
2013-02-20 11:52:19 +04: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 17:02:15 +03:00
|
|
|
}
|
2003-11-23 17:55:54 +03:00
|
|
|
}
|
2009-06-17 19:22:09 +04:00
|
|
|
|
2009-06-17 19:22:19 +04:00
|
|
|
/* srw & srw. */
|
2009-06-17 19:22:09 +04:00
|
|
|
static void gen_srw(DisasContext *ctx)
|
2008-10-21 15:31:27 +04:00
|
|
|
{
|
2008-11-02 11:22:34 +03:00
|
|
|
TCGv t0, t1;
|
2007-03-17 17:02:15 +03:00
|
|
|
|
2009-09-18 18:56:30 +04: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 17:43:54 +03:00
|
|
|
t1 = tcg_temp_new();
|
2009-09-18 18:56:30 +04: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 11:22:34 +03:00
|
|
|
tcg_temp_free(t1);
|
|
|
|
tcg_temp_free(t0);
|
2008-10-21 15:31:27 +04:00
|
|
|
if (unlikely(Rc(ctx->opcode) != 0))
|
|
|
|
gen_set_Rc0(ctx, cpu_gpr[rA(ctx->opcode)]);
|
|
|
|
}
|
2009-06-17 19:22:19 +04:00
|
|
|
|
2007-03-17 17:02:15 +03:00
|
|
|
#if defined(TARGET_PPC64)
|
|
|
|
/* sld & sld. */
|
2009-06-17 19:22:09 +04:00
|
|
|
static void gen_sld(DisasContext *ctx)
|
2008-10-21 15:31:27 +04:00
|
|
|
{
|
2009-09-18 18:56:30 +04:00
|
|
|
TCGv t0, t1;
|
2008-10-21 15:31:27 +04:00
|
|
|
|
2009-09-18 18:56:30 +04: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 11:22:34 +03:00
|
|
|
tcg_temp_free(t0);
|
2008-10-21 15:31:27 +04:00
|
|
|
if (unlikely(Rc(ctx->opcode) != 0))
|
|
|
|
gen_set_Rc0(ctx, cpu_gpr[rA(ctx->opcode)]);
|
|
|
|
}
|
2009-06-17 19:22:09 +04:00
|
|
|
|
2009-06-17 19:22:19 +04:00
|
|
|
/* srad & srad. */
|
2009-06-17 19:22:09 +04:00
|
|
|
static void gen_srad(DisasContext *ctx)
|
2008-10-21 15:31:27 +04:00
|
|
|
{
|
2012-05-30 08:23:29 +04:00
|
|
|
gen_helper_srad(cpu_gpr[rA(ctx->opcode)], cpu_env,
|
2008-11-17 17:43:54 +03:00
|
|
|
cpu_gpr[rS(ctx->opcode)], cpu_gpr[rB(ctx->opcode)]);
|
2008-10-21 15:31:27 +04:00
|
|
|
if (unlikely(Rc(ctx->opcode) != 0))
|
|
|
|
gen_set_Rc0(ctx, cpu_gpr[rA(ctx->opcode)]);
|
|
|
|
}
|
2007-03-17 17:02:15 +03:00
|
|
|
/* sradi & sradi. */
|
2009-08-16 13:06:54 +04:00
|
|
|
static inline void gen_sradi(DisasContext *ctx, int n)
|
2007-03-17 17:02:15 +03:00
|
|
|
{
|
2008-10-21 15:31:27 +04:00
|
|
|
int sh = SH(ctx->opcode) + (n << 5);
|
2013-02-20 11:52:19 +04: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 11:52:13 +04:00
|
|
|
tcg_gen_movi_tl(cpu_ca, 0);
|
2008-10-21 15:31:27 +04:00
|
|
|
} else {
|
2013-02-20 11:52:19 +04: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 17:02:15 +03:00
|
|
|
}
|
|
|
|
}
|
2009-06-17 19:22:14 +04:00
|
|
|
|
|
|
|
static void gen_sradi0(DisasContext *ctx)
|
2007-03-17 17:02:15 +03:00
|
|
|
{
|
|
|
|
gen_sradi(ctx, 0);
|
|
|
|
}
|
2009-06-17 19:22:14 +04:00
|
|
|
|
|
|
|
static void gen_sradi1(DisasContext *ctx)
|
2007-03-17 17:02:15 +03:00
|
|
|
{
|
|
|
|
gen_sradi(ctx, 1);
|
|
|
|
}
|
2009-06-17 19:22:09 +04:00
|
|
|
|
2016-07-28 21:14:18 +03:00
|
|
|
/* extswsli & extswsli. */
|
|
|
|
static inline void gen_extswsli(DisasContext *ctx, int n)
|
|
|
|
{
|
|
|
|
int sh = SH(ctx->opcode) + (n << 5);
|
|
|
|
TCGv dst = cpu_gpr[rA(ctx->opcode)];
|
|
|
|
TCGv src = cpu_gpr[rS(ctx->opcode)];
|
|
|
|
|
|
|
|
tcg_gen_ext32s_tl(dst, src);
|
|
|
|
tcg_gen_shli_tl(dst, dst, sh);
|
|
|
|
if (unlikely(Rc(ctx->opcode) != 0)) {
|
|
|
|
gen_set_Rc0(ctx, dst);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void gen_extswsli0(DisasContext *ctx)
|
|
|
|
{
|
|
|
|
gen_extswsli(ctx, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void gen_extswsli1(DisasContext *ctx)
|
|
|
|
{
|
|
|
|
gen_extswsli(ctx, 1);
|
|
|
|
}
|
|
|
|
|
2009-06-17 19:22:19 +04:00
|
|
|
/* srd & srd. */
|
2009-06-17 19:22:09 +04:00
|
|
|
static void gen_srd(DisasContext *ctx)
|
2008-10-21 15:31:27 +04:00
|
|
|
{
|
2009-09-18 18:56:30 +04:00
|
|
|
TCGv t0, t1;
|
2008-10-21 15:31:27 +04:00
|
|
|
|
2009-09-18 18:56:30 +04: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 11:22:34 +03:00
|
|
|
tcg_temp_free(t0);
|
2008-10-21 15:31:27 +04:00
|
|
|
if (unlikely(Rc(ctx->opcode) != 0))
|
|
|
|
gen_set_Rc0(ctx, cpu_gpr[rA(ctx->opcode)]);
|
|
|
|
}
|
2007-03-17 17:02:15 +03:00
|
|
|
#endif
|
2003-11-23 17:55:54 +03:00
|
|
|
|
2007-03-07 11:32:30 +03:00
|
|
|
/*** Addressing modes ***/
|
|
|
|
/* Register indirect with immediate index : EA = (rA|0) + SIMM */
|
2009-08-16 13:06:54 +04:00
|
|
|
static inline void gen_addr_imm_index(DisasContext *ctx, TCGv EA,
|
|
|
|
target_long maskl)
|
2007-03-07 11:32:30 +03:00
|
|
|
{
|
|
|
|
target_long simm = SIMM(ctx->opcode);
|
|
|
|
|
2007-09-30 17:03:23 +04:00
|
|
|
simm &= ~maskl;
|
2008-12-08 21:11:21 +03:00
|
|
|
if (rA(ctx->opcode) == 0) {
|
2013-03-21 14:01:48 +04:00
|
|
|
if (NARROW_MODE(ctx)) {
|
|
|
|
simm = (uint32_t)simm;
|
|
|
|
}
|
2008-10-14 23:55:54 +04:00
|
|
|
tcg_gen_movi_tl(EA, simm);
|
2008-12-08 21:11:21 +03:00
|
|
|
} else if (likely(simm != 0)) {
|
2008-10-14 23:55:54 +04:00
|
|
|
tcg_gen_addi_tl(EA, cpu_gpr[rA(ctx->opcode)], simm);
|
2013-03-21 14:01:48 +04:00
|
|
|
if (NARROW_MODE(ctx)) {
|
2008-12-08 21:11:21 +03:00
|
|
|
tcg_gen_ext32u_tl(EA, EA);
|
|
|
|
}
|
|
|
|
} else {
|
2013-03-21 14:01:48 +04:00
|
|
|
if (NARROW_MODE(ctx)) {
|
2008-12-08 21:11:21 +03:00
|
|
|
tcg_gen_ext32u_tl(EA, cpu_gpr[rA(ctx->opcode)]);
|
2013-03-21 14:01:48 +04:00
|
|
|
} else {
|
|
|
|
tcg_gen_mov_tl(EA, cpu_gpr[rA(ctx->opcode)]);
|
|
|
|
}
|
2008-12-08 21:11:21 +03:00
|
|
|
}
|
2007-03-07 11:32:30 +03:00
|
|
|
}
|
|
|
|
|
2009-08-16 13:06:54 +04:00
|
|
|
static inline void gen_addr_reg_index(DisasContext *ctx, TCGv EA)
|
2007-03-07 11:32:30 +03:00
|
|
|
{
|
2008-12-08 21:11:21 +03:00
|
|
|
if (rA(ctx->opcode) == 0) {
|
2013-03-21 14:01:48 +04:00
|
|
|
if (NARROW_MODE(ctx)) {
|
2008-12-08 21:11:21 +03:00
|
|
|
tcg_gen_ext32u_tl(EA, cpu_gpr[rB(ctx->opcode)]);
|
2013-03-21 14:01:48 +04:00
|
|
|
} else {
|
|
|
|
tcg_gen_mov_tl(EA, cpu_gpr[rB(ctx->opcode)]);
|
|
|
|
}
|
2008-12-08 21:11:21 +03:00
|
|
|
} else {
|
2008-10-14 23:55:54 +04:00
|
|
|
tcg_gen_add_tl(EA, cpu_gpr[rA(ctx->opcode)], cpu_gpr[rB(ctx->opcode)]);
|
2013-03-21 14:01:48 +04:00
|
|
|
if (NARROW_MODE(ctx)) {
|
2008-12-08 21:11:21 +03:00
|
|
|
tcg_gen_ext32u_tl(EA, EA);
|
|
|
|
}
|
|
|
|
}
|
2007-03-07 11:32:30 +03:00
|
|
|
}
|
|
|
|
|
2009-08-16 13:06:54 +04:00
|
|
|
static inline void gen_addr_register(DisasContext *ctx, TCGv EA)
|
2007-03-07 11:32:30 +03:00
|
|
|
{
|
2008-12-08 21:11:21 +03:00
|
|
|
if (rA(ctx->opcode) == 0) {
|
2008-10-14 23:55:54 +04:00
|
|
|
tcg_gen_movi_tl(EA, 0);
|
2013-03-21 14:01:48 +04:00
|
|
|
} else if (NARROW_MODE(ctx)) {
|
|
|
|
tcg_gen_ext32u_tl(EA, cpu_gpr[rA(ctx->opcode)]);
|
2008-12-08 21:11:21 +03:00
|
|
|
} else {
|
2013-03-21 14:01:48 +04:00
|
|
|
tcg_gen_mov_tl(EA, cpu_gpr[rA(ctx->opcode)]);
|
2008-12-08 21:11:21 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-08-16 13:06:54 +04:00
|
|
|
static inline void gen_addr_add(DisasContext *ctx, TCGv ret, TCGv arg1,
|
|
|
|
target_long val)
|
2008-12-08 21:11:21 +03:00
|
|
|
{
|
|
|
|
tcg_gen_addi_tl(ret, arg1, val);
|
2013-03-21 14:01:48 +04:00
|
|
|
if (NARROW_MODE(ctx)) {
|
2008-12-08 21:11:21 +03:00
|
|
|
tcg_gen_ext32u_tl(ret, ret);
|
|
|
|
}
|
2007-03-07 11:32:30 +03:00
|
|
|
}
|
|
|
|
|
2009-08-16 13:06:54 +04:00
|
|
|
static inline void gen_check_align(DisasContext *ctx, TCGv EA, int mask)
|
2008-11-30 19:24:39 +03:00
|
|
|
{
|
2015-02-13 23:51:55 +03:00
|
|
|
TCGLabel *l1 = gen_new_label();
|
2008-11-30 19:24:39 +03:00
|
|
|
TCGv t0 = tcg_temp_new();
|
|
|
|
TCGv_i32 t1, t2;
|
|
|
|
tcg_gen_andi_tl(t0, EA, mask);
|
|
|
|
tcg_gen_brcondi_tl(TCG_COND_EQ, t0, 0, l1);
|
|
|
|
t1 = tcg_const_i32(POWERPC_EXCP_ALIGN);
|
2016-07-27 09:56:41 +03:00
|
|
|
t2 = tcg_const_i32(ctx->opcode & 0x03FF0000);
|
2016-07-27 09:56:39 +03:00
|
|
|
gen_update_nip(ctx, ctx->nip - 4);
|
2012-05-30 08:23:23 +04:00
|
|
|
gen_helper_raise_exception_err(cpu_env, t1, t2);
|
2008-11-30 19:24:39 +03:00
|
|
|
tcg_temp_free_i32(t1);
|
|
|
|
tcg_temp_free_i32(t2);
|
|
|
|
gen_set_label(l1);
|
|
|
|
tcg_temp_free(t0);
|
|
|
|
}
|
|
|
|
|
2016-07-27 09:56:47 +03:00
|
|
|
static inline void gen_align_no_le(DisasContext *ctx)
|
|
|
|
{
|
|
|
|
gen_exception_err(ctx, POWERPC_EXCP_ALIGN,
|
|
|
|
(ctx->opcode & 0x03FF0000) | POWERPC_EXCP_ALIGN_LE);
|
|
|
|
}
|
|
|
|
|
2007-11-16 17:11:28 +03:00
|
|
|
/*** Integer load ***/
|
2009-08-16 13:06:54 +04:00
|
|
|
static inline void gen_qemu_ld8u(DisasContext *ctx, TCGv arg1, TCGv arg2)
|
2008-12-08 21:11:21 +03:00
|
|
|
{
|
|
|
|
tcg_gen_qemu_ld8u(arg1, arg2, ctx->mem_idx);
|
|
|
|
}
|
|
|
|
|
2009-08-16 13:06:54 +04:00
|
|
|
static inline void gen_qemu_ld16u(DisasContext *ctx, TCGv arg1, TCGv arg2)
|
2008-12-08 21:11:21 +03:00
|
|
|
{
|
2014-05-29 18:12:20 +04:00
|
|
|
TCGMemOp op = MO_UW | ctx->default_tcg_memop_mask;
|
|
|
|
tcg_gen_qemu_ld_tl(arg1, arg2, ctx->mem_idx, op);
|
2008-10-15 21:00:37 +04:00
|
|
|
}
|
|
|
|
|
2009-08-16 13:06:54 +04:00
|
|
|
static inline void gen_qemu_ld16s(DisasContext *ctx, TCGv arg1, TCGv arg2)
|
2008-10-15 21:00:37 +04:00
|
|
|
{
|
2014-05-29 18:12:20 +04:00
|
|
|
TCGMemOp op = MO_SW | ctx->default_tcg_memop_mask;
|
|
|
|
tcg_gen_qemu_ld_tl(arg1, arg2, ctx->mem_idx, op);
|
2008-10-15 21:00:37 +04:00
|
|
|
}
|
|
|
|
|
2009-08-16 13:06:54 +04:00
|
|
|
static inline void gen_qemu_ld32u(DisasContext *ctx, TCGv arg1, TCGv arg2)
|
2008-10-15 21:00:37 +04:00
|
|
|
{
|
2014-05-29 18:12:20 +04:00
|
|
|
TCGMemOp op = MO_UL | ctx->default_tcg_memop_mask;
|
|
|
|
tcg_gen_qemu_ld_tl(arg1, arg2, ctx->mem_idx, op);
|
2008-10-15 21:00:37 +04:00
|
|
|
}
|
|
|
|
|
2013-12-20 14:01:50 +04: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 13:06:54 +04:00
|
|
|
static inline void gen_qemu_ld32s(DisasContext *ctx, TCGv arg1, TCGv arg2)
|
2008-10-15 21:00:37 +04:00
|
|
|
{
|
2014-05-29 18:12:20 +04:00
|
|
|
TCGMemOp op = MO_SL | ctx->default_tcg_memop_mask;
|
|
|
|
tcg_gen_qemu_ld_tl(arg1, arg2, ctx->mem_idx, op);
|
2008-10-15 21:00:37 +04:00
|
|
|
}
|
|
|
|
|
2014-01-15 18:10:30 +04: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 13:06:54 +04:00
|
|
|
static inline void gen_qemu_ld64(DisasContext *ctx, TCGv_i64 arg1, TCGv arg2)
|
2008-10-15 21:00:37 +04:00
|
|
|
{
|
2014-05-29 18:12:20 +04:00
|
|
|
TCGMemOp op = MO_Q | ctx->default_tcg_memop_mask;
|
|
|
|
tcg_gen_qemu_ld_i64(arg1, arg2, ctx->mem_idx, op);
|
2008-10-15 21:00:37 +04:00
|
|
|
}
|
|
|
|
|
2009-08-16 13:06:54 +04:00
|
|
|
static inline void gen_qemu_st8(DisasContext *ctx, TCGv arg1, TCGv arg2)
|
2008-10-15 21:00:37 +04:00
|
|
|
{
|
2008-12-08 21:11:21 +03:00
|
|
|
tcg_gen_qemu_st8(arg1, arg2, ctx->mem_idx);
|
2008-10-15 21:00:37 +04:00
|
|
|
}
|
|
|
|
|
2009-08-16 13:06:54 +04:00
|
|
|
static inline void gen_qemu_st16(DisasContext *ctx, TCGv arg1, TCGv arg2)
|
2008-10-15 21:00:37 +04:00
|
|
|
{
|
2014-05-29 18:12:20 +04:00
|
|
|
TCGMemOp op = MO_UW | ctx->default_tcg_memop_mask;
|
|
|
|
tcg_gen_qemu_st_tl(arg1, arg2, ctx->mem_idx, op);
|
2008-10-15 21:00:37 +04:00
|
|
|
}
|
|
|
|
|
2009-08-16 13:06:54 +04:00
|
|
|
static inline void gen_qemu_st32(DisasContext *ctx, TCGv arg1, TCGv arg2)
|
2008-10-15 21:00:37 +04:00
|
|
|
{
|
2014-05-29 18:12:20 +04:00
|
|
|
TCGMemOp op = MO_UL | ctx->default_tcg_memop_mask;
|
|
|
|
tcg_gen_qemu_st_tl(arg1, arg2, ctx->mem_idx, op);
|
2008-10-15 21:00:37 +04:00
|
|
|
}
|
|
|
|
|
2013-12-20 14:01:50 +04: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 13:06:54 +04:00
|
|
|
static inline void gen_qemu_st64(DisasContext *ctx, TCGv_i64 arg1, TCGv arg2)
|
2008-10-15 21:00:37 +04:00
|
|
|
{
|
2014-05-29 18:12:20 +04:00
|
|
|
TCGMemOp op = MO_Q | ctx->default_tcg_memop_mask;
|
|
|
|
tcg_gen_qemu_st_i64(arg1, arg2, ctx->mem_idx, op);
|
2008-10-15 21:00:37 +04:00
|
|
|
}
|
|
|
|
|
2008-11-23 19:30:28 +03:00
|
|
|
#define GEN_LD(name, ldop, opc, type) \
|
2009-06-17 19:22:09 +04:00
|
|
|
static void glue(gen_, name)(DisasContext *ctx) \
|
2003-11-23 17:55:54 +03:00
|
|
|
{ \
|
2008-12-08 21:11:21 +03: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 21:00:37 +04:00
|
|
|
tcg_temp_free(EA); \
|
2003-11-23 17:55:54 +03:00
|
|
|
}
|
|
|
|
|
2008-11-23 19:30:28 +03:00
|
|
|
#define GEN_LDU(name, ldop, opc, type) \
|
2009-06-17 19:22:09 +04:00
|
|
|
static void glue(gen_, name##u)(DisasContext *ctx) \
|
2003-11-23 17:55:54 +03:00
|
|
|
{ \
|
2008-10-15 21:00:37 +04:00
|
|
|
TCGv EA; \
|
2007-03-07 11:32:30 +03:00
|
|
|
if (unlikely(rA(ctx->opcode) == 0 || \
|
|
|
|
rA(ctx->opcode) == rD(ctx->opcode))) { \
|
2008-12-12 01:42:14 +03:00
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_INVAL_INVAL); \
|
2004-05-21 16:59:32 +04:00
|
|
|
return; \
|
2004-01-05 01:58:38 +03:00
|
|
|
} \
|
2008-12-08 21:11:21 +03:00
|
|
|
gen_set_access_type(ctx, ACCESS_INT); \
|
2008-11-23 19:30:28 +03:00
|
|
|
EA = tcg_temp_new(); \
|
2007-04-06 11:59:47 +04:00
|
|
|
if (type == PPC_64B) \
|
2008-12-08 21:11:21 +03:00
|
|
|
gen_addr_imm_index(ctx, EA, 0x03); \
|
2007-04-06 11:59:47 +04:00
|
|
|
else \
|
2008-12-08 21:11:21 +03:00
|
|
|
gen_addr_imm_index(ctx, EA, 0); \
|
|
|
|
gen_qemu_##ldop(ctx, cpu_gpr[rD(ctx->opcode)], EA); \
|
2008-10-15 21:00:37 +04:00
|
|
|
tcg_gen_mov_tl(cpu_gpr[rA(ctx->opcode)], EA); \
|
|
|
|
tcg_temp_free(EA); \
|
2003-11-23 17:55:54 +03:00
|
|
|
}
|
|
|
|
|
2008-11-23 19:30:28 +03:00
|
|
|
#define GEN_LDUX(name, ldop, opc2, opc3, type) \
|
2009-06-17 19:22:09 +04:00
|
|
|
static void glue(gen_, name##ux)(DisasContext *ctx) \
|
2003-11-23 17:55:54 +03:00
|
|
|
{ \
|
2008-10-15 21:00:37 +04:00
|
|
|
TCGv EA; \
|
2007-03-07 11:32:30 +03:00
|
|
|
if (unlikely(rA(ctx->opcode) == 0 || \
|
|
|
|
rA(ctx->opcode) == rD(ctx->opcode))) { \
|
2008-12-12 01:42:14 +03:00
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_INVAL_INVAL); \
|
2004-05-21 16:59:32 +04:00
|
|
|
return; \
|
2004-01-05 01:58:38 +03:00
|
|
|
} \
|
2008-12-08 21:11:21 +03:00
|
|
|
gen_set_access_type(ctx, ACCESS_INT); \
|
2008-11-23 19:30:28 +03:00
|
|
|
EA = tcg_temp_new(); \
|
2008-12-08 21:11:21 +03:00
|
|
|
gen_addr_reg_index(ctx, EA); \
|
|
|
|
gen_qemu_##ldop(ctx, cpu_gpr[rD(ctx->opcode)], EA); \
|
2008-10-15 21:00:37 +04:00
|
|
|
tcg_gen_mov_tl(cpu_gpr[rA(ctx->opcode)], EA); \
|
|
|
|
tcg_temp_free(EA); \
|
2003-11-23 17:55:54 +03:00
|
|
|
}
|
|
|
|
|
2016-06-22 00:48:52 +03:00
|
|
|
#define GEN_LDX_E(name, ldop, opc2, opc3, type, type2, chk) \
|
2009-06-17 19:22:09 +04:00
|
|
|
static void glue(gen_, name##x)(DisasContext *ctx) \
|
2003-11-23 17:55:54 +03:00
|
|
|
{ \
|
2008-12-08 21:11:21 +03:00
|
|
|
TCGv EA; \
|
2016-06-22 00:48:52 +03:00
|
|
|
chk; \
|
2008-12-08 21:11:21 +03:00
|
|
|
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 21:00:37 +04:00
|
|
|
tcg_temp_free(EA); \
|
2003-11-23 17:55:54 +03:00
|
|
|
}
|
2016-06-22 00:48:52 +03:00
|
|
|
|
2012-02-27 21:18:08 +04:00
|
|
|
#define GEN_LDX(name, ldop, opc2, opc3, type) \
|
2016-06-22 00:48:52 +03:00
|
|
|
GEN_LDX_E(name, ldop, opc2, opc3, type, PPC_NONE, CHK_NONE)
|
|
|
|
|
|
|
|
#define GEN_LDX_HVRM(name, ldop, opc2, opc3, type) \
|
|
|
|
GEN_LDX_E(name, ldop, opc2, opc3, type, PPC_NONE, CHK_HVRM)
|
2003-11-23 17:55:54 +03:00
|
|
|
|
2008-11-23 19:30:28 +03: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 17:55:54 +03:00
|
|
|
|
|
|
|
/* lbz lbzu lbzux lbzx */
|
2008-11-23 19:30:28 +03:00
|
|
|
GEN_LDS(lbz, ld8u, 0x02, PPC_INTEGER);
|
2003-11-23 17:55:54 +03:00
|
|
|
/* lha lhau lhaux lhax */
|
2008-11-23 19:30:28 +03:00
|
|
|
GEN_LDS(lha, ld16s, 0x0A, PPC_INTEGER);
|
2003-11-23 17:55:54 +03:00
|
|
|
/* lhz lhzu lhzux lhzx */
|
2008-11-23 19:30:28 +03:00
|
|
|
GEN_LDS(lhz, ld16u, 0x08, PPC_INTEGER);
|
2003-11-23 17:55:54 +03:00
|
|
|
/* lwz lwzu lwzux lwzx */
|
2008-11-23 19:30:28 +03:00
|
|
|
GEN_LDS(lwz, ld32u, 0x00, PPC_INTEGER);
|
2007-03-17 17:02:15 +03:00
|
|
|
#if defined(TARGET_PPC64)
|
|
|
|
/* lwaux */
|
2008-11-23 19:30:28 +03:00
|
|
|
GEN_LDUX(lwa, ld32s, 0x15, 0x0B, PPC_64B);
|
2007-03-17 17:02:15 +03:00
|
|
|
/* lwax */
|
2008-11-23 19:30:28 +03:00
|
|
|
GEN_LDX(lwa, ld32s, 0x15, 0x0A, PPC_64B);
|
2007-03-17 17:02:15 +03:00
|
|
|
/* ldux */
|
2008-11-23 19:30:28 +03:00
|
|
|
GEN_LDUX(ld, ld64, 0x15, 0x01, PPC_64B);
|
2007-03-17 17:02:15 +03:00
|
|
|
/* ldx */
|
2008-11-23 19:30:28 +03:00
|
|
|
GEN_LDX(ld, ld64, 0x15, 0x00, PPC_64B);
|
2009-06-17 19:22:09 +04:00
|
|
|
|
2016-06-22 00:48:52 +03:00
|
|
|
/* CI load/store variants */
|
|
|
|
GEN_LDX_HVRM(ldcix, ld64, 0x15, 0x1b, PPC_CILDST)
|
|
|
|
GEN_LDX_HVRM(lwzcix, ld32u, 0x15, 0x15, PPC_CILDST)
|
|
|
|
GEN_LDX_HVRM(lhzcix, ld16u, 0x15, 0x19, PPC_CILDST)
|
|
|
|
GEN_LDX_HVRM(lbzcix, ld8u, 0x15, 0x1a, PPC_CILDST)
|
|
|
|
|
2009-06-17 19:22:09 +04:00
|
|
|
static void gen_ld(DisasContext *ctx)
|
2007-03-17 17:02:15 +03:00
|
|
|
{
|
2008-10-15 21:00:37 +04:00
|
|
|
TCGv EA;
|
2007-03-17 17:02:15 +03:00
|
|
|
if (Rc(ctx->opcode)) {
|
|
|
|
if (unlikely(rA(ctx->opcode) == 0 ||
|
|
|
|
rA(ctx->opcode) == rD(ctx->opcode))) {
|
2008-12-12 01:42:14 +03:00
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_INVAL_INVAL);
|
2007-03-17 17:02:15 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2008-12-08 21:11:21 +03:00
|
|
|
gen_set_access_type(ctx, ACCESS_INT);
|
2008-11-17 17:43:54 +03:00
|
|
|
EA = tcg_temp_new();
|
2008-12-08 21:11:21 +03:00
|
|
|
gen_addr_imm_index(ctx, EA, 0x03);
|
2007-03-17 17:02:15 +03:00
|
|
|
if (ctx->opcode & 0x02) {
|
|
|
|
/* lwa (lwau is undefined) */
|
2008-12-08 21:11:21 +03:00
|
|
|
gen_qemu_ld32s(ctx, cpu_gpr[rD(ctx->opcode)], EA);
|
2007-03-17 17:02:15 +03:00
|
|
|
} else {
|
|
|
|
/* ld - ldu */
|
2008-12-08 21:11:21 +03:00
|
|
|
gen_qemu_ld64(ctx, cpu_gpr[rD(ctx->opcode)], EA);
|
2007-03-17 17:02:15 +03:00
|
|
|
}
|
|
|
|
if (Rc(ctx->opcode))
|
2008-10-15 21:00:37 +04:00
|
|
|
tcg_gen_mov_tl(cpu_gpr[rA(ctx->opcode)], EA);
|
|
|
|
tcg_temp_free(EA);
|
2007-03-17 17:02:15 +03:00
|
|
|
}
|
2009-06-17 19:22:09 +04:00
|
|
|
|
2009-06-17 19:22:19 +04:00
|
|
|
/* lq */
|
2009-06-17 19:22:09 +04:00
|
|
|
static void gen_lq(DisasContext *ctx)
|
2007-09-30 17:03:23 +04:00
|
|
|
{
|
|
|
|
int ra, rd;
|
2008-10-15 21:00:37 +04:00
|
|
|
TCGv EA;
|
2007-09-30 17:03:23 +04:00
|
|
|
|
2014-02-10 21:26:58 +04: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 19:03:28 +04:00
|
|
|
if (!legal_in_user_mode && ctx->pr) {
|
2016-06-22 00:48:51 +03:00
|
|
|
gen_priv_exception(ctx, POWERPC_EXCP_PRIV_OPC);
|
2007-09-30 17:03:23 +04:00
|
|
|
return;
|
|
|
|
}
|
2014-02-10 21:26:58 +04:00
|
|
|
|
|
|
|
if (!le_is_supported && ctx->le_mode) {
|
2016-07-27 09:56:47 +03:00
|
|
|
gen_align_no_le(ctx);
|
2014-02-10 21:26:58 +04:00
|
|
|
return;
|
|
|
|
}
|
2007-09-30 17:03:23 +04:00
|
|
|
ra = rA(ctx->opcode);
|
|
|
|
rd = rD(ctx->opcode);
|
|
|
|
if (unlikely((rd & 1) || rd == ra)) {
|
2008-12-12 01:42:14 +03:00
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_INVAL_INVAL);
|
2007-09-30 17:03:23 +04:00
|
|
|
return;
|
|
|
|
}
|
2014-02-10 21:26:58 +04:00
|
|
|
|
2008-12-08 21:11:21 +03:00
|
|
|
gen_set_access_type(ctx, ACCESS_INT);
|
2008-11-17 17:43:54 +03:00
|
|
|
EA = tcg_temp_new();
|
2008-12-08 21:11:21 +03:00
|
|
|
gen_addr_imm_index(ctx, EA, 0x0F);
|
2014-02-10 21:26:58 +04:00
|
|
|
|
2014-05-29 18:12:20 +04:00
|
|
|
/* We only need to swap high and low halves. gen_qemu_ld64 does necessary
|
|
|
|
64-bit byteswap already. */
|
2014-02-10 21:26:58 +04: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 21:00:37 +04:00
|
|
|
tcg_temp_free(EA);
|
2007-09-30 17:03:23 +04:00
|
|
|
}
|
2007-03-17 17:02:15 +03:00
|
|
|
#endif
|
2003-11-23 17:55:54 +03:00
|
|
|
|
|
|
|
/*** Integer store ***/
|
2008-11-23 19:30:28 +03:00
|
|
|
#define GEN_ST(name, stop, opc, type) \
|
2009-06-17 19:22:09 +04:00
|
|
|
static void glue(gen_, name)(DisasContext *ctx) \
|
2003-11-23 17:55:54 +03:00
|
|
|
{ \
|
2008-12-08 21:11:21 +03: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 21:00:37 +04:00
|
|
|
tcg_temp_free(EA); \
|
2003-11-23 17:55:54 +03:00
|
|
|
}
|
|
|
|
|
2008-11-23 19:30:28 +03:00
|
|
|
#define GEN_STU(name, stop, opc, type) \
|
2009-06-17 19:22:09 +04:00
|
|
|
static void glue(gen_, stop##u)(DisasContext *ctx) \
|
2003-11-23 17:55:54 +03:00
|
|
|
{ \
|
2008-10-15 21:00:37 +04:00
|
|
|
TCGv EA; \
|
2007-03-07 11:32:30 +03:00
|
|
|
if (unlikely(rA(ctx->opcode) == 0)) { \
|
2008-12-12 01:42:14 +03:00
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_INVAL_INVAL); \
|
2004-05-21 16:59:32 +04:00
|
|
|
return; \
|
2004-01-05 01:58:38 +03:00
|
|
|
} \
|
2008-12-08 21:11:21 +03:00
|
|
|
gen_set_access_type(ctx, ACCESS_INT); \
|
2008-11-23 19:30:28 +03:00
|
|
|
EA = tcg_temp_new(); \
|
2007-04-06 11:59:47 +04:00
|
|
|
if (type == PPC_64B) \
|
2008-12-08 21:11:21 +03:00
|
|
|
gen_addr_imm_index(ctx, EA, 0x03); \
|
2007-04-06 11:59:47 +04:00
|
|
|
else \
|
2008-12-08 21:11:21 +03:00
|
|
|
gen_addr_imm_index(ctx, EA, 0); \
|
|
|
|
gen_qemu_##stop(ctx, cpu_gpr[rS(ctx->opcode)], EA); \
|
2008-10-15 21:00:37 +04:00
|
|
|
tcg_gen_mov_tl(cpu_gpr[rA(ctx->opcode)], EA); \
|
|
|
|
tcg_temp_free(EA); \
|
2003-11-23 17:55:54 +03:00
|
|
|
}
|
|
|
|
|
2008-11-23 19:30:28 +03:00
|
|
|
#define GEN_STUX(name, stop, opc2, opc3, type) \
|
2009-06-17 19:22:09 +04:00
|
|
|
static void glue(gen_, name##ux)(DisasContext *ctx) \
|
2003-11-23 17:55:54 +03:00
|
|
|
{ \
|
2008-10-15 21:00:37 +04:00
|
|
|
TCGv EA; \
|
2007-03-07 11:32:30 +03:00
|
|
|
if (unlikely(rA(ctx->opcode) == 0)) { \
|
2008-12-12 01:42:14 +03:00
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_INVAL_INVAL); \
|
2004-05-21 16:59:32 +04:00
|
|
|
return; \
|
2004-01-05 01:58:38 +03:00
|
|
|
} \
|
2008-12-08 21:11:21 +03:00
|
|
|
gen_set_access_type(ctx, ACCESS_INT); \
|
2008-11-23 19:30:28 +03:00
|
|
|
EA = tcg_temp_new(); \
|
2008-12-08 21:11:21 +03:00
|
|
|
gen_addr_reg_index(ctx, EA); \
|
|
|
|
gen_qemu_##stop(ctx, cpu_gpr[rS(ctx->opcode)], EA); \
|
2008-10-15 21:00:37 +04:00
|
|
|
tcg_gen_mov_tl(cpu_gpr[rA(ctx->opcode)], EA); \
|
|
|
|
tcg_temp_free(EA); \
|
2003-11-23 17:55:54 +03:00
|
|
|
}
|
|
|
|
|
2016-06-22 00:48:52 +03:00
|
|
|
#define GEN_STX_E(name, stop, opc2, opc3, type, type2, chk) \
|
2012-02-27 21:18:08 +04:00
|
|
|
static void glue(gen_, name##x)(DisasContext *ctx) \
|
2003-11-23 17:55:54 +03:00
|
|
|
{ \
|
2008-12-08 21:11:21 +03:00
|
|
|
TCGv EA; \
|
2016-06-22 00:48:52 +03:00
|
|
|
chk; \
|
2008-12-08 21:11:21 +03:00
|
|
|
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 21:00:37 +04:00
|
|
|
tcg_temp_free(EA); \
|
2003-11-23 17:55:54 +03:00
|
|
|
}
|
2012-02-27 21:18:08 +04:00
|
|
|
#define GEN_STX(name, stop, opc2, opc3, type) \
|
2016-06-22 00:48:52 +03:00
|
|
|
GEN_STX_E(name, stop, opc2, opc3, type, PPC_NONE, CHK_NONE)
|
|
|
|
|
|
|
|
#define GEN_STX_HVRM(name, stop, opc2, opc3, type) \
|
|
|
|
GEN_STX_E(name, stop, opc2, opc3, type, PPC_NONE, CHK_HVRM)
|
2003-11-23 17:55:54 +03:00
|
|
|
|
2008-11-23 19:30:28 +03: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 17:55:54 +03:00
|
|
|
|
|
|
|
/* stb stbu stbux stbx */
|
2008-11-23 19:30:28 +03:00
|
|
|
GEN_STS(stb, st8, 0x06, PPC_INTEGER);
|
2003-11-23 17:55:54 +03:00
|
|
|
/* sth sthu sthux sthx */
|
2008-11-23 19:30:28 +03:00
|
|
|
GEN_STS(sth, st16, 0x0C, PPC_INTEGER);
|
2003-11-23 17:55:54 +03:00
|
|
|
/* stw stwu stwux stwx */
|
2008-11-23 19:30:28 +03:00
|
|
|
GEN_STS(stw, st32, 0x04, PPC_INTEGER);
|
2007-03-17 17:02:15 +03:00
|
|
|
#if defined(TARGET_PPC64)
|
2008-11-23 19:30:28 +03:00
|
|
|
GEN_STUX(std, st64, 0x15, 0x05, PPC_64B);
|
|
|
|
GEN_STX(std, st64, 0x15, 0x04, PPC_64B);
|
2016-06-22 00:48:52 +03:00
|
|
|
GEN_STX_HVRM(stdcix, st64, 0x15, 0x1f, PPC_CILDST)
|
|
|
|
GEN_STX_HVRM(stwcix, st32, 0x15, 0x1c, PPC_CILDST)
|
|
|
|
GEN_STX_HVRM(sthcix, st16, 0x15, 0x1d, PPC_CILDST)
|
|
|
|
GEN_STX_HVRM(stbcix, st8, 0x15, 0x1e, PPC_CILDST)
|
2009-06-17 19:22:09 +04:00
|
|
|
|
|
|
|
static void gen_std(DisasContext *ctx)
|
2007-03-17 17:02:15 +03:00
|
|
|
{
|
2007-09-30 17:03:23 +04:00
|
|
|
int rs;
|
2008-10-15 21:00:37 +04:00
|
|
|
TCGv EA;
|
2007-09-30 17:03:23 +04:00
|
|
|
|
|
|
|
rs = rS(ctx->opcode);
|
2014-02-10 21:26:59 +04: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;
|
|
|
|
|
2016-06-07 05:50:24 +03:00
|
|
|
if (!(ctx->insns_flags & PPC_64BX)) {
|
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_INVAL_INVAL);
|
|
|
|
}
|
|
|
|
|
2014-09-15 19:03:28 +04:00
|
|
|
if (!legal_in_user_mode && ctx->pr) {
|
2016-06-22 00:48:51 +03:00
|
|
|
gen_priv_exception(ctx, POWERPC_EXCP_PRIV_OPC);
|
2007-09-30 17:03:23 +04:00
|
|
|
return;
|
|
|
|
}
|
2014-02-10 21:26:59 +04:00
|
|
|
|
|
|
|
if (!le_is_supported && ctx->le_mode) {
|
2016-07-27 09:56:47 +03:00
|
|
|
gen_align_no_le(ctx);
|
2007-03-17 17:02:15 +03:00
|
|
|
return;
|
|
|
|
}
|
2014-02-10 21:26:59 +04:00
|
|
|
|
|
|
|
if (unlikely(rs & 1)) {
|
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_INVAL_INVAL);
|
2007-09-30 17:03:23 +04:00
|
|
|
return;
|
|
|
|
}
|
2008-12-08 21:11:21 +03:00
|
|
|
gen_set_access_type(ctx, ACCESS_INT);
|
2008-11-17 17:43:54 +03:00
|
|
|
EA = tcg_temp_new();
|
2008-12-08 21:11:21 +03:00
|
|
|
gen_addr_imm_index(ctx, EA, 0x03);
|
2014-02-10 21:26:59 +04:00
|
|
|
|
2014-05-29 18:12:20 +04:00
|
|
|
/* We only need to swap high and low halves. gen_qemu_st64 does
|
|
|
|
necessary 64-bit byteswap already. */
|
2014-02-10 21:26:59 +04: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 21:00:37 +04:00
|
|
|
tcg_temp_free(EA);
|
2007-09-30 17:03:23 +04:00
|
|
|
} else {
|
2014-02-10 21:26:59 +04:00
|
|
|
/* std / stdu*/
|
2007-09-30 17:03:23 +04:00
|
|
|
if (Rc(ctx->opcode)) {
|
|
|
|
if (unlikely(rA(ctx->opcode) == 0)) {
|
2008-12-12 01:42:14 +03:00
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_INVAL_INVAL);
|
2007-09-30 17:03:23 +04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2008-12-08 21:11:21 +03:00
|
|
|
gen_set_access_type(ctx, ACCESS_INT);
|
2008-11-17 17:43:54 +03:00
|
|
|
EA = tcg_temp_new();
|
2008-12-08 21:11:21 +03:00
|
|
|
gen_addr_imm_index(ctx, EA, 0x03);
|
|
|
|
gen_qemu_st64(ctx, cpu_gpr[rs], EA);
|
2007-09-30 17:03:23 +04:00
|
|
|
if (Rc(ctx->opcode))
|
2008-10-15 21:00:37 +04:00
|
|
|
tcg_gen_mov_tl(cpu_gpr[rA(ctx->opcode)], EA);
|
|
|
|
tcg_temp_free(EA);
|
2007-03-17 17:02:15 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
2003-11-23 17:55:54 +03:00
|
|
|
/*** Integer load and store with byte reverse ***/
|
2014-05-29 18:12:20 +04:00
|
|
|
|
2003-11-23 17:55:54 +03:00
|
|
|
/* lhbrx */
|
2009-09-23 03:19:00 +04:00
|
|
|
static inline void gen_qemu_ld16ur(DisasContext *ctx, TCGv arg1, TCGv arg2)
|
2008-10-15 21:00:37 +04:00
|
|
|
{
|
2014-05-29 18:12:20 +04: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 21:00:37 +04:00
|
|
|
}
|
2008-11-23 19:30:28 +03:00
|
|
|
GEN_LDX(lhbr, ld16ur, 0x16, 0x18, PPC_INTEGER);
|
2008-10-15 21:00:37 +04:00
|
|
|
|
2003-11-23 17:55:54 +03:00
|
|
|
/* lwbrx */
|
2009-09-23 03:19:00 +04:00
|
|
|
static inline void gen_qemu_ld32ur(DisasContext *ctx, TCGv arg1, TCGv arg2)
|
2008-10-15 21:00:37 +04:00
|
|
|
{
|
2014-05-29 18:12:20 +04: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 21:00:37 +04:00
|
|
|
}
|
2008-11-23 19:30:28 +03:00
|
|
|
GEN_LDX(lwbr, ld32ur, 0x16, 0x10, PPC_INTEGER);
|
2008-10-15 21:00:37 +04:00
|
|
|
|
2012-02-27 21:18:08 +04:00
|
|
|
#if defined(TARGET_PPC64)
|
|
|
|
/* ldbrx */
|
|
|
|
static inline void gen_qemu_ld64ur(DisasContext *ctx, TCGv arg1, TCGv arg2)
|
|
|
|
{
|
2014-05-29 18:12:20 +04: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 21:18:08 +04:00
|
|
|
}
|
2016-06-22 00:48:52 +03:00
|
|
|
GEN_LDX_E(ldbr, ld64ur, 0x14, 0x10, PPC_NONE, PPC2_DBRX, CHK_NONE);
|
2012-02-27 21:18:08 +04:00
|
|
|
#endif /* TARGET_PPC64 */
|
|
|
|
|
2003-11-23 17:55:54 +03:00
|
|
|
/* sthbrx */
|
2009-09-23 03:19:00 +04:00
|
|
|
static inline void gen_qemu_st16r(DisasContext *ctx, TCGv arg1, TCGv arg2)
|
2008-10-15 21:00:37 +04:00
|
|
|
{
|
2014-05-29 18:12:20 +04: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 21:00:37 +04:00
|
|
|
}
|
2008-11-23 19:30:28 +03:00
|
|
|
GEN_STX(sthbr, st16r, 0x16, 0x1C, PPC_INTEGER);
|
2008-10-15 21:00:37 +04:00
|
|
|
|
2003-11-23 17:55:54 +03:00
|
|
|
/* stwbrx */
|
2009-09-23 03:19:00 +04:00
|
|
|
static inline void gen_qemu_st32r(DisasContext *ctx, TCGv arg1, TCGv arg2)
|
2008-10-15 21:00:37 +04:00
|
|
|
{
|
2014-05-29 18:12:20 +04: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 21:00:37 +04:00
|
|
|
}
|
2008-11-23 19:30:28 +03:00
|
|
|
GEN_STX(stwbr, st32r, 0x16, 0x14, PPC_INTEGER);
|
2003-11-23 17:55:54 +03:00
|
|
|
|
2012-02-27 21:18:08 +04:00
|
|
|
#if defined(TARGET_PPC64)
|
|
|
|
/* stdbrx */
|
|
|
|
static inline void gen_qemu_st64r(DisasContext *ctx, TCGv arg1, TCGv arg2)
|
|
|
|
{
|
2014-05-29 18:12:20 +04: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 21:18:08 +04:00
|
|
|
}
|
2016-06-22 00:48:52 +03:00
|
|
|
GEN_STX_E(stdbr, st64r, 0x14, 0x14, PPC_NONE, PPC2_DBRX, CHK_NONE);
|
2012-02-27 21:18:08 +04:00
|
|
|
#endif /* TARGET_PPC64 */
|
|
|
|
|
2003-11-23 17:55:54 +03:00
|
|
|
/*** Integer load and store multiple ***/
|
2009-06-17 19:22:09 +04:00
|
|
|
|
2009-06-17 19:22:19 +04:00
|
|
|
/* lmw */
|
2009-06-17 19:22:09 +04:00
|
|
|
static void gen_lmw(DisasContext *ctx)
|
2003-11-23 17:55:54 +03:00
|
|
|
{
|
2008-12-08 21:11:21 +03:00
|
|
|
TCGv t0;
|
|
|
|
TCGv_i32 t1;
|
2016-07-27 09:56:48 +03:00
|
|
|
|
|
|
|
if (ctx->le_mode) {
|
|
|
|
gen_align_no_le(ctx);
|
|
|
|
return;
|
|
|
|
}
|
2008-12-08 21:11:21 +03:00
|
|
|
gen_set_access_type(ctx, ACCESS_INT);
|
|
|
|
t0 = tcg_temp_new();
|
|
|
|
t1 = tcg_const_i32(rD(ctx->opcode));
|
|
|
|
gen_addr_imm_index(ctx, t0, 0);
|
2012-05-30 08:23:40 +04:00
|
|
|
gen_helper_lmw(cpu_env, t0, t1);
|
2008-11-30 19:23:56 +03:00
|
|
|
tcg_temp_free(t0);
|
|
|
|
tcg_temp_free_i32(t1);
|
2003-11-23 17:55:54 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/* stmw */
|
2009-06-17 19:22:09 +04:00
|
|
|
static void gen_stmw(DisasContext *ctx)
|
2003-11-23 17:55:54 +03:00
|
|
|
{
|
2008-12-08 21:11:21 +03:00
|
|
|
TCGv t0;
|
|
|
|
TCGv_i32 t1;
|
2016-07-27 09:56:48 +03:00
|
|
|
|
|
|
|
if (ctx->le_mode) {
|
|
|
|
gen_align_no_le(ctx);
|
|
|
|
return;
|
|
|
|
}
|
2008-12-08 21:11:21 +03:00
|
|
|
gen_set_access_type(ctx, ACCESS_INT);
|
|
|
|
t0 = tcg_temp_new();
|
|
|
|
t1 = tcg_const_i32(rS(ctx->opcode));
|
|
|
|
gen_addr_imm_index(ctx, t0, 0);
|
2012-05-30 08:23:40 +04:00
|
|
|
gen_helper_stmw(cpu_env, t0, t1);
|
2008-11-30 19:23:56 +03:00
|
|
|
tcg_temp_free(t0);
|
|
|
|
tcg_temp_free_i32(t1);
|
2003-11-23 17:55:54 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/*** Integer load and store strings ***/
|
2009-06-17 19:22:19 +04:00
|
|
|
|
2003-11-23 17:55:54 +03:00
|
|
|
/* lswi */
|
2005-07-03 00:59:34 +04:00
|
|
|
/* PowerPC32 specification says we must generate an exception if
|
2004-01-05 01:58:38 +03: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 19:22:09 +04:00
|
|
|
static void gen_lswi(DisasContext *ctx)
|
2003-11-23 17:55:54 +03:00
|
|
|
{
|
2008-11-30 19:24:21 +03:00
|
|
|
TCGv t0;
|
|
|
|
TCGv_i32 t1, t2;
|
2003-11-23 17:55:54 +03:00
|
|
|
int nb = NB(ctx->opcode);
|
|
|
|
int start = rD(ctx->opcode);
|
2004-01-05 01:58:38 +03:00
|
|
|
int ra = rA(ctx->opcode);
|
2003-11-23 17:55:54 +03:00
|
|
|
int nr;
|
|
|
|
|
2016-07-27 09:56:48 +03:00
|
|
|
if (ctx->le_mode) {
|
|
|
|
gen_align_no_le(ctx);
|
|
|
|
return;
|
|
|
|
}
|
2003-11-23 17:55:54 +03:00
|
|
|
if (nb == 0)
|
|
|
|
nb = 32;
|
2016-04-14 18:14:52 +03:00
|
|
|
nr = (nb + 3) / 4;
|
|
|
|
if (unlikely(lsw_reg_in_range(start, nr, ra))) {
|
2008-12-12 01:42:14 +03:00
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_INVAL_LSWX);
|
2004-05-21 16:59:32 +04:00
|
|
|
return;
|
2004-02-21 17:11:27 +03:00
|
|
|
}
|
2008-12-08 21:11:21 +03:00
|
|
|
gen_set_access_type(ctx, ACCESS_INT);
|
2008-11-30 19:24:21 +03:00
|
|
|
t0 = tcg_temp_new();
|
2008-12-08 21:11:21 +03:00
|
|
|
gen_addr_register(ctx, t0);
|
2008-11-30 19:24:21 +03:00
|
|
|
t1 = tcg_const_i32(nb);
|
|
|
|
t2 = tcg_const_i32(start);
|
2012-05-30 08:23:40 +04:00
|
|
|
gen_helper_lsw(cpu_env, t0, t1, t2);
|
2008-11-30 19:24:21 +03:00
|
|
|
tcg_temp_free(t0);
|
|
|
|
tcg_temp_free_i32(t1);
|
|
|
|
tcg_temp_free_i32(t2);
|
2003-11-23 17:55:54 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/* lswx */
|
2009-06-17 19:22:09 +04:00
|
|
|
static void gen_lswx(DisasContext *ctx)
|
2003-11-23 17:55:54 +03:00
|
|
|
{
|
2008-12-08 21:11:21 +03:00
|
|
|
TCGv t0;
|
|
|
|
TCGv_i32 t1, t2, t3;
|
2016-07-27 09:56:48 +03:00
|
|
|
|
|
|
|
if (ctx->le_mode) {
|
|
|
|
gen_align_no_le(ctx);
|
|
|
|
return;
|
|
|
|
}
|
2008-12-08 21:11:21 +03:00
|
|
|
gen_set_access_type(ctx, ACCESS_INT);
|
|
|
|
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 08:23:40 +04:00
|
|
|
gen_helper_lswx(cpu_env, t0, t1, t2, t3);
|
2008-11-30 19:24:21 +03:00
|
|
|
tcg_temp_free(t0);
|
|
|
|
tcg_temp_free_i32(t1);
|
|
|
|
tcg_temp_free_i32(t2);
|
|
|
|
tcg_temp_free_i32(t3);
|
2003-11-23 17:55:54 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/* stswi */
|
2009-06-17 19:22:09 +04:00
|
|
|
static void gen_stswi(DisasContext *ctx)
|
2003-11-23 17:55:54 +03:00
|
|
|
{
|
2008-12-08 21:11:21 +03:00
|
|
|
TCGv t0;
|
|
|
|
TCGv_i32 t1, t2;
|
2004-05-24 02:18:12 +04:00
|
|
|
int nb = NB(ctx->opcode);
|
2016-07-27 09:56:48 +03:00
|
|
|
|
|
|
|
if (ctx->le_mode) {
|
|
|
|
gen_align_no_le(ctx);
|
|
|
|
return;
|
|
|
|
}
|
2008-12-08 21:11:21 +03:00
|
|
|
gen_set_access_type(ctx, ACCESS_INT);
|
|
|
|
t0 = tcg_temp_new();
|
|
|
|
gen_addr_register(ctx, t0);
|
2004-05-24 02:18:12 +04:00
|
|
|
if (nb == 0)
|
|
|
|
nb = 32;
|
2008-11-30 19:24:21 +03:00
|
|
|
t1 = tcg_const_i32(nb);
|
2008-12-08 21:11:21 +03:00
|
|
|
t2 = tcg_const_i32(rS(ctx->opcode));
|
2012-05-30 08:23:40 +04:00
|
|
|
gen_helper_stsw(cpu_env, t0, t1, t2);
|
2008-11-30 19:24:21 +03:00
|
|
|
tcg_temp_free(t0);
|
|
|
|
tcg_temp_free_i32(t1);
|
|
|
|
tcg_temp_free_i32(t2);
|
2003-11-23 17:55:54 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/* stswx */
|
2009-06-17 19:22:09 +04:00
|
|
|
static void gen_stswx(DisasContext *ctx)
|
2003-11-23 17:55:54 +03:00
|
|
|
{
|
2008-12-08 21:11:21 +03:00
|
|
|
TCGv t0;
|
|
|
|
TCGv_i32 t1, t2;
|
2016-07-27 09:56:48 +03:00
|
|
|
|
|
|
|
if (ctx->le_mode) {
|
|
|
|
gen_align_no_le(ctx);
|
|
|
|
return;
|
|
|
|
}
|
2008-12-08 21:11:21 +03:00
|
|
|
gen_set_access_type(ctx, ACCESS_INT);
|
|
|
|
t0 = tcg_temp_new();
|
|
|
|
gen_addr_reg_index(ctx, t0);
|
|
|
|
t1 = tcg_temp_new_i32();
|
2008-11-30 19:24:21 +03:00
|
|
|
tcg_gen_trunc_tl_i32(t1, cpu_xer);
|
|
|
|
tcg_gen_andi_i32(t1, t1, 0x7F);
|
2008-12-08 21:11:21 +03:00
|
|
|
t2 = tcg_const_i32(rS(ctx->opcode));
|
2012-05-30 08:23:40 +04:00
|
|
|
gen_helper_stsw(cpu_env, t0, t1, t2);
|
2008-11-30 19:24:21 +03:00
|
|
|
tcg_temp_free(t0);
|
|
|
|
tcg_temp_free_i32(t1);
|
|
|
|
tcg_temp_free_i32(t2);
|
2003-11-23 17:55:54 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/*** Memory synchronisation ***/
|
|
|
|
/* eieio */
|
2009-06-17 19:22:09 +04:00
|
|
|
static void gen_eieio(DisasContext *ctx)
|
2003-11-23 17:55:54 +03:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2016-06-07 05:50:22 +03:00
|
|
|
#if !defined(CONFIG_USER_ONLY)
|
ppc: Do some batching of TCG tlb flushes
On ppc64 especially, we flush the tlb on any slbie or tlbie instruction.
However, those instructions often come in bursts of 3 or more (context
switch will favor a series of slbie's for example to an slbia if the
SLB has less than a certain number of entries in it, and tlbie's can
happen in a series, with PAPR, H_BULK_REMOVE can remove up to 4 entries
at a time.
Doing a tlb_flush() each time is a waste of time. We end up doing a memset
of the whole TLB, reloading it for the next instruction, memset'ing again,
etc...
Those instructions don't have to take effect immediately. For slbie, they
can wait for the next context synchronizing event. For tlbie, the next
tlbsync.
This implements batching by keeping a flag that indicates that we have a
TLB in need of flushing. We check it on interrupts, rfi's, isync's and
tlbsync and flush the TLB if needed.
This reduces the number of tlb_flush() on a boot to a ubuntu installer
first dialog screen from roughly 360K down to 36K.
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
[clg: added a 'CPUPPCState *' variable in h_remove() and
h_bulk_remove() ]
Signed-off-by: Cédric Le Goater <clg@kaod.org>
[dwg: removed spurious whitespace change, use 0/1 not true/false
consistently, since tlb_need_flush has int type]
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2016-05-03 19:03:25 +03:00
|
|
|
static inline void gen_check_tlb_flush(DisasContext *ctx)
|
|
|
|
{
|
2016-06-07 05:50:22 +03:00
|
|
|
TCGv_i32 t;
|
|
|
|
TCGLabel *l;
|
ppc: Do some batching of TCG tlb flushes
On ppc64 especially, we flush the tlb on any slbie or tlbie instruction.
However, those instructions often come in bursts of 3 or more (context
switch will favor a series of slbie's for example to an slbia if the
SLB has less than a certain number of entries in it, and tlbie's can
happen in a series, with PAPR, H_BULK_REMOVE can remove up to 4 entries
at a time.
Doing a tlb_flush() each time is a waste of time. We end up doing a memset
of the whole TLB, reloading it for the next instruction, memset'ing again,
etc...
Those instructions don't have to take effect immediately. For slbie, they
can wait for the next context synchronizing event. For tlbie, the next
tlbsync.
This implements batching by keeping a flag that indicates that we have a
TLB in need of flushing. We check it on interrupts, rfi's, isync's and
tlbsync and flush the TLB if needed.
This reduces the number of tlb_flush() on a boot to a ubuntu installer
first dialog screen from roughly 360K down to 36K.
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
[clg: added a 'CPUPPCState *' variable in h_remove() and
h_bulk_remove() ]
Signed-off-by: Cédric Le Goater <clg@kaod.org>
[dwg: removed spurious whitespace change, use 0/1 not true/false
consistently, since tlb_need_flush has int type]
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2016-05-03 19:03:25 +03:00
|
|
|
|
2016-06-07 05:50:22 +03:00
|
|
|
if (!ctx->lazy_tlb_flush) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
l = gen_new_label();
|
|
|
|
t = tcg_temp_new_i32();
|
ppc: Do some batching of TCG tlb flushes
On ppc64 especially, we flush the tlb on any slbie or tlbie instruction.
However, those instructions often come in bursts of 3 or more (context
switch will favor a series of slbie's for example to an slbia if the
SLB has less than a certain number of entries in it, and tlbie's can
happen in a series, with PAPR, H_BULK_REMOVE can remove up to 4 entries
at a time.
Doing a tlb_flush() each time is a waste of time. We end up doing a memset
of the whole TLB, reloading it for the next instruction, memset'ing again,
etc...
Those instructions don't have to take effect immediately. For slbie, they
can wait for the next context synchronizing event. For tlbie, the next
tlbsync.
This implements batching by keeping a flag that indicates that we have a
TLB in need of flushing. We check it on interrupts, rfi's, isync's and
tlbsync and flush the TLB if needed.
This reduces the number of tlb_flush() on a boot to a ubuntu installer
first dialog screen from roughly 360K down to 36K.
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
[clg: added a 'CPUPPCState *' variable in h_remove() and
h_bulk_remove() ]
Signed-off-by: Cédric Le Goater <clg@kaod.org>
[dwg: removed spurious whitespace change, use 0/1 not true/false
consistently, since tlb_need_flush has int type]
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2016-05-03 19:03:25 +03:00
|
|
|
tcg_gen_ld_i32(t, cpu_env, offsetof(CPUPPCState, tlb_need_flush));
|
|
|
|
tcg_gen_brcondi_i32(TCG_COND_EQ, t, 0, l);
|
|
|
|
gen_helper_check_tlb_flush(cpu_env);
|
|
|
|
gen_set_label(l);
|
|
|
|
tcg_temp_free_i32(t);
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
static inline void gen_check_tlb_flush(DisasContext *ctx) { }
|
|
|
|
#endif
|
|
|
|
|
2003-11-23 17:55:54 +03:00
|
|
|
/* isync */
|
2009-06-17 19:22:09 +04:00
|
|
|
static void gen_isync(DisasContext *ctx)
|
2003-11-23 17:55:54 +03:00
|
|
|
{
|
ppc: Do some batching of TCG tlb flushes
On ppc64 especially, we flush the tlb on any slbie or tlbie instruction.
However, those instructions often come in bursts of 3 or more (context
switch will favor a series of slbie's for example to an slbia if the
SLB has less than a certain number of entries in it, and tlbie's can
happen in a series, with PAPR, H_BULK_REMOVE can remove up to 4 entries
at a time.
Doing a tlb_flush() each time is a waste of time. We end up doing a memset
of the whole TLB, reloading it for the next instruction, memset'ing again,
etc...
Those instructions don't have to take effect immediately. For slbie, they
can wait for the next context synchronizing event. For tlbie, the next
tlbsync.
This implements batching by keeping a flag that indicates that we have a
TLB in need of flushing. We check it on interrupts, rfi's, isync's and
tlbsync and flush the TLB if needed.
This reduces the number of tlb_flush() on a boot to a ubuntu installer
first dialog screen from roughly 360K down to 36K.
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
[clg: added a 'CPUPPCState *' variable in h_remove() and
h_bulk_remove() ]
Signed-off-by: Cédric Le Goater <clg@kaod.org>
[dwg: removed spurious whitespace change, use 0/1 not true/false
consistently, since tlb_need_flush has int type]
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2016-05-03 19:03:25 +03:00
|
|
|
/*
|
|
|
|
* We need to check for a pending TLB flush. This can only happen in
|
|
|
|
* kernel mode however so check MSR_PR
|
|
|
|
*/
|
|
|
|
if (!ctx->pr) {
|
|
|
|
gen_check_tlb_flush(ctx);
|
|
|
|
}
|
2008-12-12 01:42:14 +03:00
|
|
|
gen_stop_exception(ctx);
|
2003-11-23 17:55:54 +03:00
|
|
|
}
|
|
|
|
|
2014-01-07 20:05:56 +04: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 17:55:54 +03:00
|
|
|
}
|
|
|
|
|
2014-01-07 20:05:56 +04:00
|
|
|
/* lwarx */
|
|
|
|
LARX(lbarx, 1, ld8u);
|
|
|
|
LARX(lharx, 2, ld16u);
|
|
|
|
LARX(lwarx, 4, ld32u);
|
|
|
|
|
|
|
|
|
2009-08-03 19:43:26 +04:00
|
|
|
#if defined(CONFIG_USER_ONLY)
|
2014-01-07 20:05:57 +04:00
|
|
|
static void gen_conditional_store(DisasContext *ctx, TCGv EA,
|
|
|
|
int reg, int size)
|
2009-08-03 19:43:26 +04:00
|
|
|
{
|
|
|
|
TCGv t0 = tcg_temp_new();
|
|
|
|
|
2012-03-14 04:38:22 +04:00
|
|
|
tcg_gen_st_tl(EA, cpu_env, offsetof(CPUPPCState, reserve_ea));
|
2009-08-03 19:43:26 +04:00
|
|
|
tcg_gen_movi_tl(t0, (size << 5) | reg);
|
2012-03-14 04:38:22 +04:00
|
|
|
tcg_gen_st_tl(t0, cpu_env, offsetof(CPUPPCState, reserve_info));
|
2009-08-03 19:43:26 +04:00
|
|
|
tcg_temp_free(t0);
|
2016-07-27 09:56:32 +03:00
|
|
|
gen_exception_err(ctx, POWERPC_EXCP_STCX, 0);
|
2009-08-03 19:43:26 +04:00
|
|
|
}
|
|
|
|
#else
|
2014-01-07 20:05:57 +04:00
|
|
|
static void gen_conditional_store(DisasContext *ctx, TCGv EA,
|
|
|
|
int reg, int size)
|
|
|
|
{
|
2015-02-13 23:51:55 +03:00
|
|
|
TCGLabel *l1;
|
2009-08-03 19:43:26 +04:00
|
|
|
|
2014-01-07 20:05:57 +04: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 21:27:01 +04:00
|
|
|
#if defined(TARGET_PPC64)
|
|
|
|
} else if (size == 16) {
|
2014-02-24 18:16:16 +04:00
|
|
|
TCGv gpr1, gpr2 , EA8;
|
2014-02-10 21:27:01 +04: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 18:16:16 +04: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 21:27:01 +04:00
|
|
|
#endif
|
2014-01-07 20:05:57 +04:00
|
|
|
} else {
|
|
|
|
gen_qemu_st8(ctx, cpu_gpr[reg], EA);
|
2009-08-03 19:43:26 +04:00
|
|
|
}
|
2014-01-07 20:05:57 +04:00
|
|
|
gen_set_label(l1);
|
|
|
|
tcg_gen_movi_tl(cpu_reserve, -1);
|
|
|
|
}
|
2009-08-03 19:43:26 +04:00
|
|
|
#endif
|
2014-01-07 20:05:57 +04:00
|
|
|
|
|
|
|
#define STCX(name, len) \
|
|
|
|
static void gen_##name(DisasContext *ctx) \
|
|
|
|
{ \
|
|
|
|
TCGv t0; \
|
2014-02-10 21:27:01 +04:00
|
|
|
if (unlikely((len == 16) && (rD(ctx->opcode) & 1))) { \
|
|
|
|
gen_inval_exception(ctx, \
|
|
|
|
POWERPC_EXCP_INVAL_INVAL); \
|
|
|
|
return; \
|
|
|
|
} \
|
2014-01-07 20:05:57 +04: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 17:55:54 +03:00
|
|
|
}
|
|
|
|
|
2014-01-07 20:05:57 +04:00
|
|
|
STCX(stbcx_, 1);
|
|
|
|
STCX(sthcx_, 2);
|
|
|
|
STCX(stwcx_, 4);
|
|
|
|
|
2007-03-23 12:45:27 +03:00
|
|
|
#if defined(TARGET_PPC64)
|
|
|
|
/* ldarx */
|
2014-01-07 20:05:56 +04:00
|
|
|
LARX(ldarx, 8, ld64);
|
2007-03-23 12:45:27 +03:00
|
|
|
|
2014-02-10 21:27:00 +04: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 12:45:27 +03:00
|
|
|
/* stdcx. */
|
2014-01-07 20:05:57 +04:00
|
|
|
STCX(stdcx_, 8);
|
2014-02-10 21:27:01 +04:00
|
|
|
STCX(stqcx_, 16);
|
2007-03-23 12:45:27 +03:00
|
|
|
#endif /* defined(TARGET_PPC64) */
|
|
|
|
|
2003-11-23 17:55:54 +03:00
|
|
|
/* sync */
|
2009-06-17 19:22:09 +04:00
|
|
|
static void gen_sync(DisasContext *ctx)
|
2003-11-23 17:55:54 +03:00
|
|
|
{
|
ppc: Do some batching of TCG tlb flushes
On ppc64 especially, we flush the tlb on any slbie or tlbie instruction.
However, those instructions often come in bursts of 3 or more (context
switch will favor a series of slbie's for example to an slbia if the
SLB has less than a certain number of entries in it, and tlbie's can
happen in a series, with PAPR, H_BULK_REMOVE can remove up to 4 entries
at a time.
Doing a tlb_flush() each time is a waste of time. We end up doing a memset
of the whole TLB, reloading it for the next instruction, memset'ing again,
etc...
Those instructions don't have to take effect immediately. For slbie, they
can wait for the next context synchronizing event. For tlbie, the next
tlbsync.
This implements batching by keeping a flag that indicates that we have a
TLB in need of flushing. We check it on interrupts, rfi's, isync's and
tlbsync and flush the TLB if needed.
This reduces the number of tlb_flush() on a boot to a ubuntu installer
first dialog screen from roughly 360K down to 36K.
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
[clg: added a 'CPUPPCState *' variable in h_remove() and
h_bulk_remove() ]
Signed-off-by: Cédric Le Goater <clg@kaod.org>
[dwg: removed spurious whitespace change, use 0/1 not true/false
consistently, since tlb_need_flush has int type]
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2016-05-03 19:03:25 +03:00
|
|
|
uint32_t l = (ctx->opcode >> 21) & 3;
|
|
|
|
|
|
|
|
/*
|
2016-06-07 05:50:22 +03:00
|
|
|
* We may need to check for a pending TLB flush.
|
|
|
|
*
|
|
|
|
* We do this on ptesync (l == 2) on ppc64 and any sync pn ppc32.
|
|
|
|
*
|
|
|
|
* Additionally, this can only happen in kernel mode however so
|
|
|
|
* check MSR_PR as well.
|
ppc: Do some batching of TCG tlb flushes
On ppc64 especially, we flush the tlb on any slbie or tlbie instruction.
However, those instructions often come in bursts of 3 or more (context
switch will favor a series of slbie's for example to an slbia if the
SLB has less than a certain number of entries in it, and tlbie's can
happen in a series, with PAPR, H_BULK_REMOVE can remove up to 4 entries
at a time.
Doing a tlb_flush() each time is a waste of time. We end up doing a memset
of the whole TLB, reloading it for the next instruction, memset'ing again,
etc...
Those instructions don't have to take effect immediately. For slbie, they
can wait for the next context synchronizing event. For tlbie, the next
tlbsync.
This implements batching by keeping a flag that indicates that we have a
TLB in need of flushing. We check it on interrupts, rfi's, isync's and
tlbsync and flush the TLB if needed.
This reduces the number of tlb_flush() on a boot to a ubuntu installer
first dialog screen from roughly 360K down to 36K.
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
[clg: added a 'CPUPPCState *' variable in h_remove() and
h_bulk_remove() ]
Signed-off-by: Cédric Le Goater <clg@kaod.org>
[dwg: removed spurious whitespace change, use 0/1 not true/false
consistently, since tlb_need_flush has int type]
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2016-05-03 19:03:25 +03:00
|
|
|
*/
|
2016-06-07 05:50:22 +03:00
|
|
|
if (((l == 2) || !(ctx->insns_flags & PPC_64B)) && !ctx->pr) {
|
ppc: Do some batching of TCG tlb flushes
On ppc64 especially, we flush the tlb on any slbie or tlbie instruction.
However, those instructions often come in bursts of 3 or more (context
switch will favor a series of slbie's for example to an slbia if the
SLB has less than a certain number of entries in it, and tlbie's can
happen in a series, with PAPR, H_BULK_REMOVE can remove up to 4 entries
at a time.
Doing a tlb_flush() each time is a waste of time. We end up doing a memset
of the whole TLB, reloading it for the next instruction, memset'ing again,
etc...
Those instructions don't have to take effect immediately. For slbie, they
can wait for the next context synchronizing event. For tlbie, the next
tlbsync.
This implements batching by keeping a flag that indicates that we have a
TLB in need of flushing. We check it on interrupts, rfi's, isync's and
tlbsync and flush the TLB if needed.
This reduces the number of tlb_flush() on a boot to a ubuntu installer
first dialog screen from roughly 360K down to 36K.
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
[clg: added a 'CPUPPCState *' variable in h_remove() and
h_bulk_remove() ]
Signed-off-by: Cédric Le Goater <clg@kaod.org>
[dwg: removed spurious whitespace change, use 0/1 not true/false
consistently, since tlb_need_flush has int type]
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2016-05-03 19:03:25 +03:00
|
|
|
gen_check_tlb_flush(ctx);
|
|
|
|
}
|
2003-11-23 17:55:54 +03:00
|
|
|
}
|
|
|
|
|
2007-09-30 07:46:38 +04:00
|
|
|
/* wait */
|
2009-06-17 19:22:09 +04:00
|
|
|
static void gen_wait(DisasContext *ctx)
|
2007-09-30 07:46:38 +04:00
|
|
|
{
|
2016-06-06 11:47:28 +03:00
|
|
|
TCGv_i32 t0 = tcg_const_i32(1);
|
2013-01-17 21:51:17 +04:00
|
|
|
tcg_gen_st_i32(t0, cpu_env,
|
|
|
|
-offsetof(PowerPCCPU, env) + offsetof(CPUState, halted));
|
2008-11-30 19:23:46 +03:00
|
|
|
tcg_temp_free_i32(t0);
|
2007-09-30 07:46:38 +04:00
|
|
|
/* Stop translation, as the CPU is supposed to sleep from now */
|
2016-07-27 09:56:32 +03:00
|
|
|
gen_exception_nip(ctx, EXCP_HLT, ctx->nip);
|
2007-09-30 07:46:38 +04:00
|
|
|
}
|
|
|
|
|
2016-06-22 00:48:55 +03:00
|
|
|
#if defined(TARGET_PPC64)
|
|
|
|
static void gen_doze(DisasContext *ctx)
|
|
|
|
{
|
|
|
|
#if defined(CONFIG_USER_ONLY)
|
|
|
|
GEN_PRIV;
|
|
|
|
#else
|
|
|
|
TCGv_i32 t;
|
|
|
|
|
|
|
|
CHK_HV;
|
|
|
|
t = tcg_const_i32(PPC_PM_DOZE);
|
|
|
|
gen_helper_pminsn(cpu_env, t);
|
|
|
|
tcg_temp_free_i32(t);
|
|
|
|
gen_stop_exception(ctx);
|
|
|
|
#endif /* defined(CONFIG_USER_ONLY) */
|
|
|
|
}
|
|
|
|
|
|
|
|
static void gen_nap(DisasContext *ctx)
|
|
|
|
{
|
|
|
|
#if defined(CONFIG_USER_ONLY)
|
|
|
|
GEN_PRIV;
|
|
|
|
#else
|
|
|
|
TCGv_i32 t;
|
|
|
|
|
|
|
|
CHK_HV;
|
|
|
|
t = tcg_const_i32(PPC_PM_NAP);
|
|
|
|
gen_helper_pminsn(cpu_env, t);
|
|
|
|
tcg_temp_free_i32(t);
|
|
|
|
gen_stop_exception(ctx);
|
|
|
|
#endif /* defined(CONFIG_USER_ONLY) */
|
|
|
|
}
|
|
|
|
|
|
|
|
static void gen_sleep(DisasContext *ctx)
|
|
|
|
{
|
|
|
|
#if defined(CONFIG_USER_ONLY)
|
|
|
|
GEN_PRIV;
|
|
|
|
#else
|
|
|
|
TCGv_i32 t;
|
|
|
|
|
|
|
|
CHK_HV;
|
|
|
|
t = tcg_const_i32(PPC_PM_SLEEP);
|
|
|
|
gen_helper_pminsn(cpu_env, t);
|
|
|
|
tcg_temp_free_i32(t);
|
|
|
|
gen_stop_exception(ctx);
|
|
|
|
#endif /* defined(CONFIG_USER_ONLY) */
|
|
|
|
}
|
|
|
|
|
|
|
|
static void gen_rvwinkle(DisasContext *ctx)
|
|
|
|
{
|
|
|
|
#if defined(CONFIG_USER_ONLY)
|
|
|
|
GEN_PRIV;
|
|
|
|
#else
|
|
|
|
TCGv_i32 t;
|
|
|
|
|
|
|
|
CHK_HV;
|
|
|
|
t = tcg_const_i32(PPC_PM_RVWINKLE);
|
|
|
|
gen_helper_pminsn(cpu_env, t);
|
|
|
|
tcg_temp_free_i32(t);
|
|
|
|
gen_stop_exception(ctx);
|
|
|
|
#endif /* defined(CONFIG_USER_ONLY) */
|
|
|
|
}
|
|
|
|
#endif /* #if defined(TARGET_PPC64) */
|
|
|
|
|
2011-08-31 19:45:10 +04: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 01:00:23 +03: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 17:55:54 +03:00
|
|
|
/*** Branch ***/
|
2009-08-16 13:06:54 +04:00
|
|
|
static inline void gen_goto_tb(DisasContext *ctx, int n, target_ulong dest)
|
2005-11-20 13:31:08 +03:00
|
|
|
{
|
2013-03-21 14:01:46 +04:00
|
|
|
if (NARROW_MODE(ctx)) {
|
2008-10-21 20:31:31 +04:00
|
|
|
dest = (uint32_t) dest;
|
2013-03-21 14:01:46 +04:00
|
|
|
}
|
2016-04-09 01:00:23 +03:00
|
|
|
if (use_goto_tb(ctx, dest)) {
|
2008-02-01 13:50:11 +03:00
|
|
|
tcg_gen_goto_tb(n);
|
2008-10-21 20:31:31 +04:00
|
|
|
tcg_gen_movi_tl(cpu_nip, dest & ~3);
|
2016-04-09 01:00:23 +03:00
|
|
|
tcg_gen_exit_tb((uintptr_t)ctx->tb + n);
|
2005-11-20 13:31:08 +03:00
|
|
|
} else {
|
2008-10-21 20:31:31 +04:00
|
|
|
tcg_gen_movi_tl(cpu_nip, dest & ~3);
|
2008-05-11 03:28:14 +04:00
|
|
|
if (unlikely(ctx->singlestep_enabled)) {
|
|
|
|
if ((ctx->singlestep_enabled &
|
2008-11-09 20:27:03 +03: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 04:17:13 +04:00
|
|
|
(ctx->exception == POWERPC_EXCP_BRANCH ||
|
|
|
|
ctx->exception == POWERPC_EXCP_TRACE)) {
|
2016-07-27 09:56:32 +03:00
|
|
|
gen_exception_nip(ctx, POWERPC_EXCP_TRACE, dest);
|
2008-05-11 03:28:14 +04:00
|
|
|
}
|
|
|
|
if (ctx->singlestep_enabled & GDBSTUB_SINGLE_STEP) {
|
2008-12-12 01:42:14 +03:00
|
|
|
gen_debug_exception(ctx);
|
2008-05-11 03:28:14 +04:00
|
|
|
}
|
|
|
|
}
|
2008-02-01 13:50:11 +03:00
|
|
|
tcg_gen_exit_tb(0);
|
2005-11-20 13:31:08 +03:00
|
|
|
}
|
2005-10-31 00:39:19 +03:00
|
|
|
}
|
|
|
|
|
2009-08-16 13:06:54 +04:00
|
|
|
static inline void gen_setlr(DisasContext *ctx, target_ulong nip)
|
2007-09-29 17:06:16 +04:00
|
|
|
{
|
2013-03-21 14:01:46 +04:00
|
|
|
if (NARROW_MODE(ctx)) {
|
|
|
|
nip = (uint32_t)nip;
|
|
|
|
}
|
|
|
|
tcg_gen_movi_tl(cpu_lr, nip);
|
2007-09-29 17:06:16 +04:00
|
|
|
}
|
|
|
|
|
2003-11-23 17:55:54 +03:00
|
|
|
/* b ba bl bla */
|
2009-06-17 19:22:09 +04:00
|
|
|
static void gen_b(DisasContext *ctx)
|
2003-11-23 17:55:54 +03:00
|
|
|
{
|
2007-03-07 11:32:30 +03:00
|
|
|
target_ulong li, target;
|
2004-07-08 02:06:01 +04:00
|
|
|
|
2008-05-11 03:28:14 +04:00
|
|
|
ctx->exception = POWERPC_EXCP_BRANCH;
|
2004-07-08 02:06:01 +04:00
|
|
|
/* sign extend LI */
|
2013-03-21 14:01:46 +04:00
|
|
|
li = LI(ctx->opcode);
|
|
|
|
li = (li ^ 0x02000000) - 0x02000000;
|
|
|
|
if (likely(AA(ctx->opcode) == 0)) {
|
2004-04-26 01:15:35 +04:00
|
|
|
target = ctx->nip + li - 4;
|
2013-03-21 14:01:46 +04:00
|
|
|
} else {
|
2004-01-05 01:58:38 +03:00
|
|
|
target = li;
|
2013-03-21 14:01:46 +04:00
|
|
|
}
|
|
|
|
if (LK(ctx->opcode)) {
|
2007-09-29 17:06:16 +04:00
|
|
|
gen_setlr(ctx, ctx->nip);
|
2013-03-21 14:01:46 +04:00
|
|
|
}
|
2016-07-27 09:56:44 +03:00
|
|
|
gen_update_cfar(ctx, ctx->nip - 4);
|
2005-11-20 13:31:08 +03:00
|
|
|
gen_goto_tb(ctx, 0, target);
|
2003-11-23 17:55:54 +03:00
|
|
|
}
|
|
|
|
|
2004-02-21 18:35:00 +03:00
|
|
|
#define BCOND_IM 0
|
|
|
|
#define BCOND_LR 1
|
|
|
|
#define BCOND_CTR 2
|
2014-02-10 21:26:55 +04:00
|
|
|
#define BCOND_TAR 3
|
2004-02-21 18:35:00 +03:00
|
|
|
|
2009-08-16 13:06:54 +04:00
|
|
|
static inline void gen_bcond(DisasContext *ctx, int type)
|
2007-03-17 17:02:15 +03:00
|
|
|
{
|
|
|
|
uint32_t bo = BO(ctx->opcode);
|
2015-02-13 23:51:55 +03:00
|
|
|
TCGLabel *l1;
|
2008-10-21 20:31:31 +04:00
|
|
|
TCGv target;
|
2004-02-21 18:35:00 +03:00
|
|
|
|
2008-05-11 03:28:14 +04:00
|
|
|
ctx->exception = POWERPC_EXCP_BRANCH;
|
2014-02-10 21:26:55 +04:00
|
|
|
if (type == BCOND_LR || type == BCOND_CTR || type == BCOND_TAR) {
|
2008-11-17 17:43:54 +03:00
|
|
|
target = tcg_temp_local_new();
|
2008-10-21 20:31:31 +04:00
|
|
|
if (type == BCOND_CTR)
|
|
|
|
tcg_gen_mov_tl(target, cpu_ctr);
|
2014-02-10 21:26:55 +04:00
|
|
|
else if (type == BCOND_TAR)
|
|
|
|
gen_load_spr(target, SPR_TAR);
|
2008-10-21 20:31:31 +04:00
|
|
|
else
|
|
|
|
tcg_gen_mov_tl(target, cpu_lr);
|
2009-06-20 05:51:47 +04:00
|
|
|
} else {
|
|
|
|
TCGV_UNUSED(target);
|
2004-02-21 18:35:00 +03:00
|
|
|
}
|
2007-09-29 17:06:16 +04:00
|
|
|
if (LK(ctx->opcode))
|
|
|
|
gen_setlr(ctx, ctx->nip);
|
2008-10-21 20:31:31 +04:00
|
|
|
l1 = gen_new_label();
|
|
|
|
if ((bo & 0x4) == 0) {
|
|
|
|
/* Decrement and test CTR */
|
2008-11-17 17:43:54 +03:00
|
|
|
TCGv temp = tcg_temp_new();
|
2008-10-21 20:31:31 +04:00
|
|
|
if (unlikely(type == BCOND_CTR)) {
|
2008-12-12 01:42:14 +03:00
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_INVAL_INVAL);
|
2008-10-21 20:31:31 +04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
tcg_gen_subi_tl(cpu_ctr, cpu_ctr, 1);
|
2013-03-21 14:01:46 +04:00
|
|
|
if (NARROW_MODE(ctx)) {
|
2008-10-21 20:31:31 +04:00
|
|
|
tcg_gen_ext32u_tl(temp, cpu_ctr);
|
2013-03-21 14:01:46 +04:00
|
|
|
} else {
|
2008-10-21 20:31:31 +04:00
|
|
|
tcg_gen_mov_tl(temp, cpu_ctr);
|
2013-03-21 14:01:46 +04:00
|
|
|
}
|
2008-10-21 20:31:31 +04: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 18:35:00 +03:00
|
|
|
}
|
2008-11-17 17:43:54 +03:00
|
|
|
tcg_temp_free(temp);
|
2008-10-21 20:31:31 +04:00
|
|
|
}
|
|
|
|
if ((bo & 0x10) == 0) {
|
|
|
|
/* Test CR */
|
|
|
|
uint32_t bi = BI(ctx->opcode);
|
2014-08-28 21:15:09 +04:00
|
|
|
uint32_t mask = 0x08 >> (bi & 0x03);
|
2008-11-17 17:43:54 +03:00
|
|
|
TCGv_i32 temp = tcg_temp_new_i32();
|
2008-10-21 20:31:31 +04:00
|
|
|
|
2007-03-17 17:02:15 +03:00
|
|
|
if (bo & 0x8) {
|
2008-10-21 20:31:31 +04:00
|
|
|
tcg_gen_andi_i32(temp, cpu_crf[bi >> 2], mask);
|
|
|
|
tcg_gen_brcondi_i32(TCG_COND_EQ, temp, 0, l1);
|
2007-03-17 17:02:15 +03:00
|
|
|
} else {
|
2008-10-21 20:31:31 +04:00
|
|
|
tcg_gen_andi_i32(temp, cpu_crf[bi >> 2], mask);
|
|
|
|
tcg_gen_brcondi_i32(TCG_COND_NE, temp, 0, l1);
|
2007-03-17 17:02:15 +03:00
|
|
|
}
|
2008-11-17 17:43:54 +03:00
|
|
|
tcg_temp_free_i32(temp);
|
2007-03-17 17:02:15 +03:00
|
|
|
}
|
2016-07-27 09:56:44 +03:00
|
|
|
gen_update_cfar(ctx, ctx->nip - 4);
|
2004-02-21 18:35:00 +03:00
|
|
|
if (type == BCOND_IM) {
|
2008-10-21 20:31:31 +04: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);
|
|
|
|
}
|
2016-07-31 08:13:09 +03:00
|
|
|
if ((bo & 0x14) != 0x14) {
|
|
|
|
gen_set_label(l1);
|
|
|
|
gen_goto_tb(ctx, 1, ctx->nip);
|
|
|
|
}
|
2004-02-21 18:35:00 +03:00
|
|
|
} else {
|
2013-03-21 14:01:46 +04:00
|
|
|
if (NARROW_MODE(ctx)) {
|
2008-10-21 20:31:31 +04:00
|
|
|
tcg_gen_andi_tl(cpu_nip, target, (uint32_t)~3);
|
2013-03-21 14:01:46 +04:00
|
|
|
} else {
|
2008-10-21 20:31:31 +04:00
|
|
|
tcg_gen_andi_tl(cpu_nip, target, ~3);
|
2013-03-21 14:01:46 +04:00
|
|
|
}
|
2008-10-21 20:31:31 +04:00
|
|
|
tcg_gen_exit_tb(0);
|
2016-07-31 08:13:09 +03:00
|
|
|
if ((bo & 0x14) != 0x14) {
|
|
|
|
gen_set_label(l1);
|
|
|
|
gen_update_nip(ctx, ctx->nip);
|
|
|
|
tcg_gen_exit_tb(0);
|
|
|
|
}
|
2007-04-16 11:18:42 +04:00
|
|
|
}
|
2014-06-04 21:26:02 +04:00
|
|
|
if (type == BCOND_LR || type == BCOND_CTR || type == BCOND_TAR) {
|
2014-01-19 20:26:33 +04:00
|
|
|
tcg_temp_free(target);
|
|
|
|
}
|
2004-02-21 18:35:00 +03:00
|
|
|
}
|
|
|
|
|
2009-06-17 19:22:09 +04:00
|
|
|
static void gen_bc(DisasContext *ctx)
|
2007-09-17 12:09:54 +04:00
|
|
|
{
|
2004-02-21 18:35:00 +03:00
|
|
|
gen_bcond(ctx, BCOND_IM);
|
|
|
|
}
|
|
|
|
|
2009-06-17 19:22:09 +04:00
|
|
|
static void gen_bcctr(DisasContext *ctx)
|
2007-09-17 12:09:54 +04:00
|
|
|
{
|
2004-02-21 18:35:00 +03:00
|
|
|
gen_bcond(ctx, BCOND_CTR);
|
|
|
|
}
|
|
|
|
|
2009-06-17 19:22:09 +04:00
|
|
|
static void gen_bclr(DisasContext *ctx)
|
2007-09-17 12:09:54 +04:00
|
|
|
{
|
2004-02-21 18:35:00 +03:00
|
|
|
gen_bcond(ctx, BCOND_LR);
|
|
|
|
}
|
2003-11-23 17:55:54 +03:00
|
|
|
|
2014-02-10 21:26:55 +04:00
|
|
|
static void gen_bctar(DisasContext *ctx)
|
|
|
|
{
|
|
|
|
gen_bcond(ctx, BCOND_TAR);
|
|
|
|
}
|
|
|
|
|
2003-11-23 17:55:54 +03:00
|
|
|
/*** Condition register logical ***/
|
2008-10-21 15:31:14 +04:00
|
|
|
#define GEN_CRLOGIC(name, tcg_op, opc) \
|
2009-06-17 19:22:09 +04:00
|
|
|
static void glue(gen_, name)(DisasContext *ctx) \
|
2003-11-23 17:55:54 +03:00
|
|
|
{ \
|
2007-11-01 01:02:17 +03:00
|
|
|
uint8_t bitmask; \
|
|
|
|
int sh; \
|
2008-11-17 17:43:54 +03:00
|
|
|
TCGv_i32 t0, t1; \
|
2007-11-01 01:02:17 +03:00
|
|
|
sh = (crbD(ctx->opcode) & 0x03) - (crbA(ctx->opcode) & 0x03); \
|
2008-11-17 17:43:54 +03:00
|
|
|
t0 = tcg_temp_new_i32(); \
|
2007-11-01 01:02:17 +03:00
|
|
|
if (sh > 0) \
|
2008-11-02 11:22:34 +03:00
|
|
|
tcg_gen_shri_i32(t0, cpu_crf[crbA(ctx->opcode) >> 2], sh); \
|
2007-11-01 01:02:17 +03:00
|
|
|
else if (sh < 0) \
|
2008-11-02 11:22:34 +03:00
|
|
|
tcg_gen_shli_i32(t0, cpu_crf[crbA(ctx->opcode) >> 2], -sh); \
|
2008-10-21 15:31:14 +04:00
|
|
|
else \
|
2008-11-02 11:22:34 +03:00
|
|
|
tcg_gen_mov_i32(t0, cpu_crf[crbA(ctx->opcode) >> 2]); \
|
2008-11-17 17:43:54 +03:00
|
|
|
t1 = tcg_temp_new_i32(); \
|
2007-11-01 01:02:17 +03:00
|
|
|
sh = (crbD(ctx->opcode) & 0x03) - (crbB(ctx->opcode) & 0x03); \
|
|
|
|
if (sh > 0) \
|
2008-11-02 11:22:34 +03:00
|
|
|
tcg_gen_shri_i32(t1, cpu_crf[crbB(ctx->opcode) >> 2], sh); \
|
2007-11-01 01:02:17 +03:00
|
|
|
else if (sh < 0) \
|
2008-11-02 11:22:34 +03:00
|
|
|
tcg_gen_shli_i32(t1, cpu_crf[crbB(ctx->opcode) >> 2], -sh); \
|
2008-10-21 15:31:14 +04:00
|
|
|
else \
|
2008-11-02 11:22:34 +03:00
|
|
|
tcg_gen_mov_i32(t1, cpu_crf[crbB(ctx->opcode) >> 2]); \
|
|
|
|
tcg_op(t0, t0, t1); \
|
2014-08-28 21:15:09 +04:00
|
|
|
bitmask = 0x08 >> (crbD(ctx->opcode) & 0x03); \
|
2008-11-02 11:22:34 +03: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 17:43:54 +03:00
|
|
|
tcg_temp_free_i32(t0); \
|
|
|
|
tcg_temp_free_i32(t1); \
|
2003-11-23 17:55:54 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/* crand */
|
2008-10-21 15:31:14 +04:00
|
|
|
GEN_CRLOGIC(crand, tcg_gen_and_i32, 0x08);
|
2003-11-23 17:55:54 +03:00
|
|
|
/* crandc */
|
2008-10-21 15:31:14 +04:00
|
|
|
GEN_CRLOGIC(crandc, tcg_gen_andc_i32, 0x04);
|
2003-11-23 17:55:54 +03:00
|
|
|
/* creqv */
|
2008-10-21 15:31:14 +04:00
|
|
|
GEN_CRLOGIC(creqv, tcg_gen_eqv_i32, 0x09);
|
2003-11-23 17:55:54 +03:00
|
|
|
/* crnand */
|
2008-10-21 15:31:14 +04:00
|
|
|
GEN_CRLOGIC(crnand, tcg_gen_nand_i32, 0x07);
|
2003-11-23 17:55:54 +03:00
|
|
|
/* crnor */
|
2008-10-21 15:31:14 +04:00
|
|
|
GEN_CRLOGIC(crnor, tcg_gen_nor_i32, 0x01);
|
2003-11-23 17:55:54 +03:00
|
|
|
/* cror */
|
2008-10-21 15:31:14 +04:00
|
|
|
GEN_CRLOGIC(cror, tcg_gen_or_i32, 0x0E);
|
2003-11-23 17:55:54 +03:00
|
|
|
/* crorc */
|
2008-10-21 15:31:14 +04:00
|
|
|
GEN_CRLOGIC(crorc, tcg_gen_orc_i32, 0x0D);
|
2003-11-23 17:55:54 +03:00
|
|
|
/* crxor */
|
2008-10-21 15:31:14 +04:00
|
|
|
GEN_CRLOGIC(crxor, tcg_gen_xor_i32, 0x06);
|
2009-06-17 19:22:09 +04:00
|
|
|
|
2009-06-17 19:22:19 +04:00
|
|
|
/* mcrf */
|
2009-06-17 19:22:09 +04:00
|
|
|
static void gen_mcrf(DisasContext *ctx)
|
2003-11-23 17:55:54 +03:00
|
|
|
{
|
2008-09-04 21:06:47 +04:00
|
|
|
tcg_gen_mov_i32(cpu_crf[crfD(ctx->opcode)], cpu_crf[crfS(ctx->opcode)]);
|
2003-11-23 17:55:54 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/*** System linkage ***/
|
2009-06-17 19:22:09 +04:00
|
|
|
|
2014-09-15 19:03:28 +04:00
|
|
|
/* rfi (supervisor only) */
|
2009-06-17 19:22:09 +04:00
|
|
|
static void gen_rfi(DisasContext *ctx)
|
2003-11-23 17:55:54 +03:00
|
|
|
{
|
2004-01-05 01:58:38 +03:00
|
|
|
#if defined(CONFIG_USER_ONLY)
|
2016-06-22 00:48:51 +03:00
|
|
|
GEN_PRIV;
|
2004-01-05 01:58:38 +03:00
|
|
|
#else
|
2016-06-22 00:48:46 +03:00
|
|
|
/* FIXME: This instruction doesn't exist anymore on 64-bit server
|
|
|
|
* processors compliant with arch 2.x, we should remove it there,
|
|
|
|
* but we need to fix OpenBIOS not to use it on 970 first
|
|
|
|
*/
|
2004-01-05 01:58:38 +03:00
|
|
|
/* Restore CPU state */
|
2016-06-22 00:48:51 +03:00
|
|
|
CHK_SV;
|
2016-07-27 09:56:44 +03:00
|
|
|
gen_update_cfar(ctx, ctx->nip - 4);
|
2012-05-30 08:23:23 +04:00
|
|
|
gen_helper_rfi(cpu_env);
|
2008-12-12 01:42:14 +03:00
|
|
|
gen_sync_exception(ctx);
|
2004-01-05 01:58:38 +03:00
|
|
|
#endif
|
2003-11-23 17:55:54 +03:00
|
|
|
}
|
|
|
|
|
2007-03-23 12:45:27 +03:00
|
|
|
#if defined(TARGET_PPC64)
|
2009-06-17 19:22:09 +04:00
|
|
|
static void gen_rfid(DisasContext *ctx)
|
2007-03-23 12:45:27 +03:00
|
|
|
{
|
|
|
|
#if defined(CONFIG_USER_ONLY)
|
2016-06-22 00:48:51 +03:00
|
|
|
GEN_PRIV;
|
2007-03-23 12:45:27 +03:00
|
|
|
#else
|
|
|
|
/* Restore CPU state */
|
2016-06-22 00:48:51 +03:00
|
|
|
CHK_SV;
|
2016-07-27 09:56:44 +03:00
|
|
|
gen_update_cfar(ctx, ctx->nip - 4);
|
2012-05-30 08:23:23 +04:00
|
|
|
gen_helper_rfid(cpu_env);
|
2008-12-12 01:42:14 +03:00
|
|
|
gen_sync_exception(ctx);
|
2007-03-23 12:45:27 +03:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2009-06-17 19:22:09 +04:00
|
|
|
static void gen_hrfid(DisasContext *ctx)
|
2007-09-30 17:03:23 +04:00
|
|
|
{
|
|
|
|
#if defined(CONFIG_USER_ONLY)
|
2016-06-22 00:48:51 +03:00
|
|
|
GEN_PRIV;
|
2007-09-30 17:03:23 +04:00
|
|
|
#else
|
|
|
|
/* Restore CPU state */
|
2016-06-22 00:48:51 +03:00
|
|
|
CHK_HV;
|
2012-05-30 08:23:23 +04:00
|
|
|
gen_helper_hrfid(cpu_env);
|
2008-12-12 01:42:14 +03:00
|
|
|
gen_sync_exception(ctx);
|
2007-09-30 17:03:23 +04:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2003-11-23 17:55:54 +03:00
|
|
|
/* sc */
|
2007-10-08 03:10:08 +04:00
|
|
|
#if defined(CONFIG_USER_ONLY)
|
|
|
|
#define POWERPC_SYSCALL POWERPC_EXCP_SYSCALL_USER
|
|
|
|
#else
|
|
|
|
#define POWERPC_SYSCALL POWERPC_EXCP_SYSCALL
|
|
|
|
#endif
|
2009-06-17 19:22:09 +04:00
|
|
|
static void gen_sc(DisasContext *ctx)
|
2003-11-23 17:55:54 +03:00
|
|
|
{
|
2007-09-29 17:06:16 +04:00
|
|
|
uint32_t lev;
|
|
|
|
|
|
|
|
lev = (ctx->opcode >> 5) & 0x7F;
|
2008-12-12 01:42:14 +03:00
|
|
|
gen_exception_err(ctx, POWERPC_SYSCALL, lev);
|
2003-11-23 17:55:54 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/*** Trap ***/
|
2009-06-17 19:22:09 +04:00
|
|
|
|
2016-07-27 09:56:42 +03:00
|
|
|
/* Check for unconditional traps (always or never) */
|
|
|
|
static bool check_unconditional_trap(DisasContext *ctx)
|
|
|
|
{
|
|
|
|
/* Trap never */
|
|
|
|
if (TO(ctx->opcode) == 0) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
/* Trap always */
|
|
|
|
if (TO(ctx->opcode) == 31) {
|
|
|
|
gen_exception_err(ctx, POWERPC_EXCP_PROGRAM, POWERPC_EXCP_TRAP);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2009-06-17 19:22:19 +04:00
|
|
|
/* tw */
|
2009-06-17 19:22:09 +04:00
|
|
|
static void gen_tw(DisasContext *ctx)
|
2003-11-23 17:55:54 +03:00
|
|
|
{
|
2016-07-27 09:56:42 +03:00
|
|
|
TCGv_i32 t0;
|
|
|
|
|
|
|
|
if (check_unconditional_trap(ctx)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
t0 = tcg_const_i32(TO(ctx->opcode));
|
2012-05-30 08:23:23 +04:00
|
|
|
gen_helper_tw(cpu_env, cpu_gpr[rA(ctx->opcode)], cpu_gpr[rB(ctx->opcode)],
|
|
|
|
t0);
|
2008-11-24 14:28:19 +03:00
|
|
|
tcg_temp_free_i32(t0);
|
2003-11-23 17:55:54 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/* twi */
|
2009-06-17 19:22:09 +04:00
|
|
|
static void gen_twi(DisasContext *ctx)
|
2003-11-23 17:55:54 +03:00
|
|
|
{
|
2016-07-27 09:56:42 +03:00
|
|
|
TCGv t0;
|
|
|
|
TCGv_i32 t1;
|
|
|
|
|
|
|
|
if (check_unconditional_trap(ctx)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
t0 = tcg_const_tl(SIMM(ctx->opcode));
|
|
|
|
t1 = tcg_const_i32(TO(ctx->opcode));
|
2012-05-30 08:23:23 +04:00
|
|
|
gen_helper_tw(cpu_env, cpu_gpr[rA(ctx->opcode)], t0, t1);
|
2008-11-24 14:28:19 +03:00
|
|
|
tcg_temp_free(t0);
|
|
|
|
tcg_temp_free_i32(t1);
|
2003-11-23 17:55:54 +03:00
|
|
|
}
|
|
|
|
|
2007-03-17 17:02:15 +03:00
|
|
|
#if defined(TARGET_PPC64)
|
|
|
|
/* td */
|
2009-06-17 19:22:09 +04:00
|
|
|
static void gen_td(DisasContext *ctx)
|
2007-03-17 17:02:15 +03:00
|
|
|
{
|
2016-07-27 09:56:42 +03:00
|
|
|
TCGv_i32 t0;
|
|
|
|
|
|
|
|
if (check_unconditional_trap(ctx)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
t0 = tcg_const_i32(TO(ctx->opcode));
|
2012-05-30 08:23:23 +04:00
|
|
|
gen_helper_td(cpu_env, cpu_gpr[rA(ctx->opcode)], cpu_gpr[rB(ctx->opcode)],
|
|
|
|
t0);
|
2008-11-24 14:28:19 +03:00
|
|
|
tcg_temp_free_i32(t0);
|
2007-03-17 17:02:15 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/* tdi */
|
2009-06-17 19:22:09 +04:00
|
|
|
static void gen_tdi(DisasContext *ctx)
|
2007-03-17 17:02:15 +03:00
|
|
|
{
|
2016-07-27 09:56:42 +03:00
|
|
|
TCGv t0;
|
|
|
|
TCGv_i32 t1;
|
|
|
|
|
|
|
|
if (check_unconditional_trap(ctx)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
t0 = tcg_const_tl(SIMM(ctx->opcode));
|
|
|
|
t1 = tcg_const_i32(TO(ctx->opcode));
|
2012-05-30 08:23:23 +04:00
|
|
|
gen_helper_td(cpu_env, cpu_gpr[rA(ctx->opcode)], t0, t1);
|
2008-11-24 14:28:19 +03:00
|
|
|
tcg_temp_free(t0);
|
|
|
|
tcg_temp_free_i32(t1);
|
2007-03-17 17:02:15 +03:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2003-11-23 17:55:54 +03:00
|
|
|
/*** Processor control ***/
|
2009-06-17 19:22:09 +04:00
|
|
|
|
2013-02-20 11:52:13 +04: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 19:22:19 +04:00
|
|
|
/* mcrxr */
|
2009-06-17 19:22:09 +04:00
|
|
|
static void gen_mcrxr(DisasContext *ctx)
|
2003-11-23 17:55:54 +03:00
|
|
|
{
|
2013-02-20 11:52:13 +04: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 09:54:02 +04: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 11:52:13 +04: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 17:55:54 +03:00
|
|
|
}
|
|
|
|
|
2009-03-03 09:12:14 +03:00
|
|
|
/* mfcr mfocrf */
|
2009-06-17 19:22:09 +04:00
|
|
|
static void gen_mfcr(DisasContext *ctx)
|
2003-11-23 17:55:54 +03:00
|
|
|
{
|
2007-03-07 11:32:30 +03:00
|
|
|
uint32_t crm, crn;
|
2007-09-17 12:09:54 +04:00
|
|
|
|
2007-03-07 11:32:30 +03:00
|
|
|
if (likely(ctx->opcode & 0x00100000)) {
|
|
|
|
crm = CRM(ctx->opcode);
|
2009-03-03 01:39:39 +03:00
|
|
|
if (likely(crm && ((crm & (crm - 1)) == 0))) {
|
2009-03-03 09:12:14 +03:00
|
|
|
crn = ctz32 (crm);
|
2008-10-21 15:31:14 +04:00
|
|
|
tcg_gen_extu_i32_tl(cpu_gpr[rD(ctx->opcode)], cpu_crf[7 - crn]);
|
2009-03-07 23:57:47 +03:00
|
|
|
tcg_gen_shli_tl(cpu_gpr[rD(ctx->opcode)],
|
|
|
|
cpu_gpr[rD(ctx->opcode)], crn * 4);
|
2007-03-07 11:32:30 +03:00
|
|
|
}
|
2007-03-17 17:02:15 +03:00
|
|
|
} else {
|
2009-03-09 21:50:24 +03: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 17:02:15 +03:00
|
|
|
}
|
2003-11-23 17:55:54 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/* mfmsr */
|
2009-06-17 19:22:09 +04:00
|
|
|
static void gen_mfmsr(DisasContext *ctx)
|
2003-11-23 17:55:54 +03:00
|
|
|
{
|
2016-06-22 00:48:51 +03:00
|
|
|
CHK_SV;
|
2008-12-06 16:03:35 +03:00
|
|
|
tcg_gen_mov_tl(cpu_gpr[rD(ctx->opcode)], cpu_msr);
|
2003-11-23 17:55:54 +03:00
|
|
|
}
|
|
|
|
|
2014-11-26 13:39:48 +03:00
|
|
|
static void spr_noaccess(DisasContext *ctx, int gprn, int sprn)
|
2005-07-03 00:59:34 +04:00
|
|
|
{
|
2010-04-18 18:26:51 +04:00
|
|
|
#if 0
|
2005-07-03 00:59:34 +04:00
|
|
|
sprn = ((sprn >> 5) & 0x1F) | ((sprn & 0x1F) << 5);
|
|
|
|
printf("ERROR: try to access SPR %d !\n", sprn);
|
2010-04-18 18:26:51 +04:00
|
|
|
#endif
|
2005-07-03 00:59:34 +04:00
|
|
|
}
|
|
|
|
#define SPR_NOACCESS (&spr_noaccess)
|
|
|
|
|
2003-11-23 17:55:54 +03:00
|
|
|
/* mfspr */
|
2009-08-16 13:06:54 +04:00
|
|
|
static inline void gen_op_mfspr(DisasContext *ctx)
|
2003-11-23 17:55:54 +03:00
|
|
|
{
|
2014-11-26 13:39:48 +03:00
|
|
|
void (*read_cb)(DisasContext *ctx, int gprn, int sprn);
|
2003-11-23 17:55:54 +03:00
|
|
|
uint32_t sprn = SPR(ctx->opcode);
|
|
|
|
|
2016-03-21 15:52:32 +03: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 17:03:23 +04:00
|
|
|
read_cb = ctx->spr_cb[sprn].hea_read;
|
2016-03-21 15:52:32 +03:00
|
|
|
} else {
|
2005-07-03 00:59:34 +04:00
|
|
|
read_cb = ctx->spr_cb[sprn].oea_read;
|
2016-03-21 15:52:32 +03:00
|
|
|
}
|
2004-01-05 01:58:38 +03:00
|
|
|
#endif
|
2007-03-07 11:32:30 +03:00
|
|
|
if (likely(read_cb != NULL)) {
|
|
|
|
if (likely(read_cb != SPR_NOACCESS)) {
|
2008-12-07 16:40:29 +03:00
|
|
|
(*read_cb)(ctx, rD(ctx->opcode), sprn);
|
2005-07-03 00:59:34 +04:00
|
|
|
} else {
|
|
|
|
/* Privilege exception */
|
2007-11-03 01:47:50 +03: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 15:16:27 +03: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-24 00:36:30 +03:00
|
|
|
}
|
2016-06-22 00:48:51 +03:00
|
|
|
gen_priv_exception(ctx, POWERPC_EXCP_PRIV_REG);
|
2003-11-23 17:55:54 +03:00
|
|
|
}
|
2005-07-03 00:59:34 +04:00
|
|
|
} else {
|
2016-06-22 00:48:51 +03:00
|
|
|
/* ISA 2.07 defines these as no-ops */
|
|
|
|
if ((ctx->insns_flags2 & PPC2_ISA207S) &&
|
|
|
|
(sprn >= 808 && sprn <= 811)) {
|
|
|
|
/* This is a nop */
|
|
|
|
return;
|
|
|
|
}
|
2005-07-03 00:59:34 +04:00
|
|
|
/* Not defined */
|
2015-11-13 15:16:27 +03: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);
|
|
|
|
}
|
2016-06-22 00:48:51 +03:00
|
|
|
|
|
|
|
/* The behaviour depends on MSR:PR and SPR# bit 0x10,
|
|
|
|
* it can generate a priv, a hv emu or a no-op
|
|
|
|
*/
|
|
|
|
if (sprn & 0x10) {
|
|
|
|
if (ctx->pr) {
|
|
|
|
gen_priv_exception(ctx, POWERPC_EXCP_INVAL_SPR);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (ctx->pr || sprn == 0 || sprn == 4 || sprn == 5 || sprn == 6) {
|
|
|
|
gen_hvpriv_exception(ctx, POWERPC_EXCP_INVAL_SPR);
|
|
|
|
}
|
2016-06-07 05:50:28 +03:00
|
|
|
}
|
2003-11-23 17:55:54 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-06-17 19:22:09 +04:00
|
|
|
static void gen_mfspr(DisasContext *ctx)
|
2003-11-23 17:55:54 +03:00
|
|
|
{
|
2005-07-03 00:59:34 +04:00
|
|
|
gen_op_mfspr(ctx);
|
2007-03-07 11:32:30 +03:00
|
|
|
}
|
2005-07-03 00:59:34 +04:00
|
|
|
|
|
|
|
/* mftb */
|
2009-06-17 19:22:09 +04:00
|
|
|
static void gen_mftb(DisasContext *ctx)
|
2005-07-03 00:59:34 +04:00
|
|
|
{
|
|
|
|
gen_op_mfspr(ctx);
|
2003-11-23 17:55:54 +03:00
|
|
|
}
|
|
|
|
|
2009-03-03 09:12:14 +03:00
|
|
|
/* mtcrf mtocrf*/
|
2009-06-17 19:22:09 +04:00
|
|
|
static void gen_mtcrf(DisasContext *ctx)
|
2003-11-23 17:55:54 +03:00
|
|
|
{
|
2007-03-07 11:32:30 +03:00
|
|
|
uint32_t crm, crn;
|
2007-09-17 12:09:54 +04:00
|
|
|
|
2007-03-07 11:32:30 +03:00
|
|
|
crm = CRM(ctx->opcode);
|
2009-03-03 01:39:39 +03:00
|
|
|
if (likely((ctx->opcode & 0x00100000))) {
|
|
|
|
if (crm && ((crm & (crm - 1)) == 0)) {
|
|
|
|
TCGv_i32 temp = tcg_temp_new_i32();
|
2009-03-03 09:12:14 +03:00
|
|
|
crn = ctz32 (crm);
|
2009-03-03 01:39:39 +03:00
|
|
|
tcg_gen_trunc_tl_i32(temp, cpu_gpr[rS(ctx->opcode)]);
|
2009-03-03 09:12:14 +03:00
|
|
|
tcg_gen_shri_i32(temp, temp, crn * 4);
|
|
|
|
tcg_gen_andi_i32(cpu_crf[7 - crn], temp, 0xf);
|
2009-03-03 01:39:39 +03:00
|
|
|
tcg_temp_free_i32(temp);
|
|
|
|
}
|
2007-03-07 11:32:30 +03:00
|
|
|
} else {
|
2009-03-09 21:50:24 +03: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 17:43:54 +03:00
|
|
|
tcg_temp_free_i32(temp);
|
2007-03-07 11:32:30 +03:00
|
|
|
}
|
2003-11-23 17:55:54 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/* mtmsr */
|
2007-03-23 12:45:27 +03:00
|
|
|
#if defined(TARGET_PPC64)
|
2009-06-17 19:22:09 +04:00
|
|
|
static void gen_mtmsrd(DisasContext *ctx)
|
2007-03-23 12:45:27 +03:00
|
|
|
{
|
2016-06-22 00:48:51 +03:00
|
|
|
CHK_SV;
|
|
|
|
|
|
|
|
#if !defined(CONFIG_USER_ONLY)
|
2007-09-30 17:03:23 +04:00
|
|
|
if (ctx->opcode & 0x00010000) {
|
|
|
|
/* Special form that does not need any synchronisation */
|
2008-12-06 16:03:35 +03:00
|
|
|
TCGv t0 = tcg_temp_new();
|
|
|
|
tcg_gen_andi_tl(t0, cpu_gpr[rS(ctx->opcode)], (1 << MSR_RI) | (1 << MSR_EE));
|
2016-05-03 19:03:32 +03:00
|
|
|
tcg_gen_andi_tl(cpu_msr, cpu_msr, ~(target_ulong)((1 << MSR_RI) | (1 << MSR_EE)));
|
2008-12-06 16:03:35 +03:00
|
|
|
tcg_gen_or_tl(cpu_msr, cpu_msr, t0);
|
|
|
|
tcg_temp_free(t0);
|
2007-09-30 17:03:23 +04:00
|
|
|
} else {
|
2007-10-01 07:03:51 +04: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 17:03:23 +04:00
|
|
|
gen_update_nip(ctx, ctx->nip);
|
2012-05-30 08:23:23 +04:00
|
|
|
gen_helper_store_msr(cpu_env, cpu_gpr[rS(ctx->opcode)]);
|
2007-09-30 17:03:23 +04:00
|
|
|
/* Must stop the translation as machine state (may have) changed */
|
|
|
|
/* Note that mtmsr is not always defined as context-synchronizing */
|
2008-12-12 01:42:14 +03:00
|
|
|
gen_stop_exception(ctx);
|
2007-09-30 17:03:23 +04:00
|
|
|
}
|
2016-06-22 00:48:51 +03:00
|
|
|
#endif /* !defined(CONFIG_USER_ONLY) */
|
2007-03-23 12:45:27 +03:00
|
|
|
}
|
2016-06-22 00:48:51 +03:00
|
|
|
#endif /* defined(TARGET_PPC64) */
|
2007-03-23 12:45:27 +03:00
|
|
|
|
2009-06-17 19:22:09 +04:00
|
|
|
static void gen_mtmsr(DisasContext *ctx)
|
2003-11-23 17:55:54 +03:00
|
|
|
{
|
2016-06-22 00:48:51 +03:00
|
|
|
CHK_SV;
|
|
|
|
|
|
|
|
#if !defined(CONFIG_USER_ONLY)
|
|
|
|
if (ctx->opcode & 0x00010000) {
|
2007-09-30 17:03:23 +04:00
|
|
|
/* Special form that does not need any synchronisation */
|
2008-12-06 16:03:35 +03:00
|
|
|
TCGv t0 = tcg_temp_new();
|
|
|
|
tcg_gen_andi_tl(t0, cpu_gpr[rS(ctx->opcode)], (1 << MSR_RI) | (1 << MSR_EE));
|
2016-05-03 19:03:32 +03:00
|
|
|
tcg_gen_andi_tl(cpu_msr, cpu_msr, ~(target_ulong)((1 << MSR_RI) | (1 << MSR_EE)));
|
2008-12-06 16:03:35 +03:00
|
|
|
tcg_gen_or_tl(cpu_msr, cpu_msr, t0);
|
|
|
|
tcg_temp_free(t0);
|
2007-09-30 17:03:23 +04:00
|
|
|
} else {
|
2011-06-16 12:44:23 +04:00
|
|
|
TCGv msr = tcg_temp_new();
|
|
|
|
|
2007-10-01 07:03:51 +04: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 17:03:23 +04:00
|
|
|
gen_update_nip(ctx, ctx->nip);
|
2007-03-17 17:02:15 +03:00
|
|
|
#if defined(TARGET_PPC64)
|
2011-06-16 12:44:23 +04: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 17:02:15 +03:00
|
|
|
#endif
|
2012-05-30 08:23:23 +04:00
|
|
|
gen_helper_store_msr(cpu_env, msr);
|
2014-01-19 20:26:33 +04:00
|
|
|
tcg_temp_free(msr);
|
2007-09-30 17:03:23 +04:00
|
|
|
/* Must stop the translation as machine state (may have) changed */
|
2008-12-06 16:03:35 +03:00
|
|
|
/* Note that mtmsr is not always defined as context-synchronizing */
|
2008-12-12 01:42:14 +03:00
|
|
|
gen_stop_exception(ctx);
|
2007-09-30 17:03:23 +04:00
|
|
|
}
|
2004-01-05 01:58:38 +03:00
|
|
|
#endif
|
2003-11-23 17:55:54 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/* mtspr */
|
2009-06-17 19:22:09 +04:00
|
|
|
static void gen_mtspr(DisasContext *ctx)
|
2003-11-23 17:55:54 +03:00
|
|
|
{
|
2014-11-26 13:39:48 +03:00
|
|
|
void (*write_cb)(DisasContext *ctx, int sprn, int gprn);
|
2003-11-23 17:55:54 +03:00
|
|
|
uint32_t sprn = SPR(ctx->opcode);
|
|
|
|
|
2016-03-21 15:52:32 +03: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 17:03:23 +04:00
|
|
|
write_cb = ctx->spr_cb[sprn].hea_write;
|
2016-03-21 15:52:32 +03:00
|
|
|
} else {
|
2005-07-03 00:59:34 +04:00
|
|
|
write_cb = ctx->spr_cb[sprn].oea_write;
|
2016-03-21 15:52:32 +03:00
|
|
|
}
|
2004-01-05 01:58:38 +03:00
|
|
|
#endif
|
2007-03-07 11:32:30 +03:00
|
|
|
if (likely(write_cb != NULL)) {
|
|
|
|
if (likely(write_cb != SPR_NOACCESS)) {
|
2008-12-07 16:40:29 +03:00
|
|
|
(*write_cb)(ctx, sprn, rS(ctx->opcode));
|
2005-07-03 00:59:34 +04:00
|
|
|
} else {
|
|
|
|
/* Privilege exception */
|
2015-11-13 15:16:27 +03: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);
|
|
|
|
}
|
2016-06-22 00:48:51 +03:00
|
|
|
gen_priv_exception(ctx, POWERPC_EXCP_PRIV_REG);
|
2007-03-07 11:32:30 +03:00
|
|
|
}
|
2005-07-03 00:59:34 +04:00
|
|
|
} else {
|
2016-06-22 00:48:51 +03:00
|
|
|
/* ISA 2.07 defines these as no-ops */
|
|
|
|
if ((ctx->insns_flags2 & PPC2_ISA207S) &&
|
|
|
|
(sprn >= 808 && sprn <= 811)) {
|
|
|
|
/* This is a nop */
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2005-07-03 00:59:34 +04:00
|
|
|
/* Not defined */
|
2015-11-13 15:16:27 +03: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);
|
2016-06-07 05:50:28 +03:00
|
|
|
|
2016-06-22 00:48:51 +03:00
|
|
|
|
|
|
|
/* The behaviour depends on MSR:PR and SPR# bit 0x10,
|
|
|
|
* it can generate a priv, a hv emu or a no-op
|
|
|
|
*/
|
|
|
|
if (sprn & 0x10) {
|
|
|
|
if (ctx->pr) {
|
|
|
|
gen_priv_exception(ctx, POWERPC_EXCP_INVAL_SPR);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (ctx->pr || sprn == 0) {
|
|
|
|
gen_hvpriv_exception(ctx, POWERPC_EXCP_INVAL_SPR);
|
|
|
|
}
|
2016-06-07 05:50:28 +03:00
|
|
|
}
|
2003-11-23 17:55:54 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-07-26 14:58:35 +03:00
|
|
|
#if defined(TARGET_PPC64)
|
|
|
|
/* setb */
|
|
|
|
static void gen_setb(DisasContext *ctx)
|
|
|
|
{
|
|
|
|
TCGv_i32 t0 = tcg_temp_new_i32();
|
|
|
|
TCGv_i32 t8 = tcg_temp_new_i32();
|
|
|
|
TCGv_i32 tm1 = tcg_temp_new_i32();
|
|
|
|
int crf = crfS(ctx->opcode);
|
|
|
|
|
|
|
|
tcg_gen_setcondi_i32(TCG_COND_GEU, t0, cpu_crf[crf], 4);
|
|
|
|
tcg_gen_movi_i32(t8, 8);
|
|
|
|
tcg_gen_movi_i32(tm1, -1);
|
|
|
|
tcg_gen_movcond_i32(TCG_COND_GEU, t0, cpu_crf[crf], t8, tm1, t0);
|
|
|
|
tcg_gen_ext_i32_tl(cpu_gpr[rD(ctx->opcode)], t0);
|
|
|
|
|
|
|
|
tcg_temp_free_i32(t0);
|
|
|
|
tcg_temp_free_i32(t8);
|
|
|
|
tcg_temp_free_i32(tm1);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2003-11-23 17:55:54 +03:00
|
|
|
/*** Cache management ***/
|
2009-06-17 19:22:09 +04:00
|
|
|
|
2009-06-17 19:22:19 +04:00
|
|
|
/* dcbf */
|
2009-06-17 19:22:09 +04:00
|
|
|
static void gen_dcbf(DisasContext *ctx)
|
2003-11-23 17:55:54 +03:00
|
|
|
{
|
2007-10-26 04:48:00 +04:00
|
|
|
/* XXX: specification says this is treated as a load by the MMU */
|
2008-12-08 21:11:21 +03: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 11:22:34 +03:00
|
|
|
tcg_temp_free(t0);
|
2003-11-23 17:55:54 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/* dcbi (Supervisor only) */
|
2009-06-17 19:22:09 +04:00
|
|
|
static void gen_dcbi(DisasContext *ctx)
|
2003-11-23 17:55:54 +03:00
|
|
|
{
|
2004-04-13 00:39:29 +04:00
|
|
|
#if defined(CONFIG_USER_ONLY)
|
2016-06-22 00:48:51 +03:00
|
|
|
GEN_PRIV;
|
2004-04-13 00:39:29 +04:00
|
|
|
#else
|
2008-10-15 21:00:37 +04:00
|
|
|
TCGv EA, val;
|
2016-06-22 00:48:51 +03:00
|
|
|
|
|
|
|
CHK_SV;
|
2008-11-17 17:43:54 +03:00
|
|
|
EA = tcg_temp_new();
|
2008-12-08 21:11:21 +03:00
|
|
|
gen_set_access_type(ctx, ACCESS_CACHE);
|
|
|
|
gen_addr_reg_index(ctx, EA);
|
2008-11-17 17:43:54 +03:00
|
|
|
val = tcg_temp_new();
|
2007-03-07 11:32:30 +03:00
|
|
|
/* XXX: specification says this should be treated as a store by the MMU */
|
2008-12-08 21:11:21 +03:00
|
|
|
gen_qemu_ld8u(ctx, val, EA);
|
|
|
|
gen_qemu_st8(ctx, val, EA);
|
2008-10-15 21:00:37 +04:00
|
|
|
tcg_temp_free(val);
|
|
|
|
tcg_temp_free(EA);
|
2016-06-22 00:48:51 +03:00
|
|
|
#endif /* defined(CONFIG_USER_ONLY) */
|
2003-11-23 17:55:54 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/* dcdst */
|
2009-06-17 19:22:09 +04:00
|
|
|
static void gen_dcbst(DisasContext *ctx)
|
2003-11-23 17:55:54 +03:00
|
|
|
{
|
2007-03-07 11:32:30 +03:00
|
|
|
/* XXX: specification say this is treated as a load by the MMU */
|
2008-12-08 21:11:21 +03: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 11:22:34 +03:00
|
|
|
tcg_temp_free(t0);
|
2003-11-23 17:55:54 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/* dcbt */
|
2009-06-17 19:22:09 +04:00
|
|
|
static void gen_dcbt(DisasContext *ctx)
|
2003-11-23 17:55:54 +03:00
|
|
|
{
|
2007-09-30 07:46:38 +04:00
|
|
|
/* interpreted as no-op */
|
2007-03-07 11:32:30 +03:00
|
|
|
/* XXX: specification say this is treated as a load by the MMU
|
|
|
|
* but does not generate any exception
|
|
|
|
*/
|
2003-11-23 17:55:54 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/* dcbtst */
|
2009-06-17 19:22:09 +04:00
|
|
|
static void gen_dcbtst(DisasContext *ctx)
|
2003-11-23 17:55:54 +03:00
|
|
|
{
|
2007-09-30 07:46:38 +04:00
|
|
|
/* interpreted as no-op */
|
2007-03-07 11:32:30 +03:00
|
|
|
/* XXX: specification say this is treated as a load by the MMU
|
|
|
|
* but does not generate any exception
|
|
|
|
*/
|
2003-11-23 17:55:54 +03:00
|
|
|
}
|
|
|
|
|
2014-01-19 20:50:09 +04: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 17:55:54 +03:00
|
|
|
/* dcbz */
|
2009-06-17 19:22:09 +04:00
|
|
|
static void gen_dcbz(DisasContext *ctx)
|
2003-11-23 17:55:54 +03:00
|
|
|
{
|
2013-01-29 16:36:02 +04:00
|
|
|
TCGv tcgv_addr;
|
2016-07-27 09:56:43 +03:00
|
|
|
TCGv_i32 tcgv_op;
|
2007-10-04 04:51:58 +04:00
|
|
|
|
2008-12-08 21:11:21 +03:00
|
|
|
gen_set_access_type(ctx, ACCESS_CACHE);
|
2013-01-29 16:36:02 +04:00
|
|
|
tcgv_addr = tcg_temp_new();
|
2016-07-27 09:56:43 +03:00
|
|
|
tcgv_op = tcg_const_i32(ctx->opcode & 0x03FF000);
|
2013-01-29 16:36:02 +04:00
|
|
|
gen_addr_reg_index(ctx, tcgv_addr);
|
2016-07-27 09:56:43 +03:00
|
|
|
gen_helper_dcbz(cpu_env, tcgv_addr, tcgv_op);
|
2013-01-29 16:36:02 +04:00
|
|
|
tcg_temp_free(tcgv_addr);
|
2016-07-27 09:56:43 +03:00
|
|
|
tcg_temp_free_i32(tcgv_op);
|
2003-11-23 17:55:54 +03:00
|
|
|
}
|
|
|
|
|
2009-01-13 00:33:02 +03:00
|
|
|
/* dst / dstt */
|
2009-06-17 19:22:09 +04:00
|
|
|
static void gen_dst(DisasContext *ctx)
|
2009-01-13 00:33:02 +03:00
|
|
|
{
|
|
|
|
if (rA(ctx->opcode) == 0) {
|
2016-07-27 09:56:30 +03:00
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_INVAL_INVAL);
|
2009-01-13 00:33:02 +03:00
|
|
|
} else {
|
|
|
|
/* interpreted as no-op */
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* dstst /dststt */
|
2009-06-17 19:22:09 +04:00
|
|
|
static void gen_dstst(DisasContext *ctx)
|
2009-01-13 00:33:02 +03:00
|
|
|
{
|
|
|
|
if (rA(ctx->opcode) == 0) {
|
2016-07-27 09:56:30 +03:00
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_INVAL_INVAL);
|
2009-01-13 00:33:02 +03:00
|
|
|
} else {
|
|
|
|
/* interpreted as no-op */
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/* dss / dssall */
|
2009-06-17 19:22:09 +04:00
|
|
|
static void gen_dss(DisasContext *ctx)
|
2009-01-13 00:33:02 +03:00
|
|
|
{
|
|
|
|
/* interpreted as no-op */
|
|
|
|
}
|
|
|
|
|
2003-11-23 17:55:54 +03:00
|
|
|
/* icbi */
|
2009-06-17 19:22:09 +04:00
|
|
|
static void gen_icbi(DisasContext *ctx)
|
2003-11-23 17:55:54 +03:00
|
|
|
{
|
2008-12-08 21:11:21 +03:00
|
|
|
TCGv t0;
|
|
|
|
gen_set_access_type(ctx, ACCESS_CACHE);
|
|
|
|
t0 = tcg_temp_new();
|
|
|
|
gen_addr_reg_index(ctx, t0);
|
2012-05-30 08:23:40 +04:00
|
|
|
gen_helper_icbi(cpu_env, t0);
|
2008-11-30 19:24:13 +03:00
|
|
|
tcg_temp_free(t0);
|
2003-11-23 17:55:54 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Optional: */
|
|
|
|
/* dcba */
|
2009-06-17 19:22:09 +04:00
|
|
|
static void gen_dcba(DisasContext *ctx)
|
2003-11-23 17:55:54 +03:00
|
|
|
{
|
2007-09-30 07:46:38 +04: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 17:55:54 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/*** Segment register manipulation ***/
|
|
|
|
/* Supervisor only: */
|
2009-06-17 19:22:09 +04:00
|
|
|
|
2009-06-17 19:22:19 +04:00
|
|
|
/* mfsr */
|
2009-06-17 19:22:09 +04:00
|
|
|
static void gen_mfsr(DisasContext *ctx)
|
2003-11-23 17:55:54 +03:00
|
|
|
{
|
2004-01-05 01:58:38 +03:00
|
|
|
#if defined(CONFIG_USER_ONLY)
|
2016-06-22 00:48:51 +03:00
|
|
|
GEN_PRIV;
|
2004-01-05 01:58:38 +03:00
|
|
|
#else
|
2008-12-07 00:46:17 +03:00
|
|
|
TCGv t0;
|
2016-06-22 00:48:51 +03:00
|
|
|
|
|
|
|
CHK_SV;
|
2008-12-07 00:46:17 +03:00
|
|
|
t0 = tcg_const_tl(SR(ctx->opcode));
|
2012-05-30 08:23:31 +04:00
|
|
|
gen_helper_load_sr(cpu_gpr[rD(ctx->opcode)], cpu_env, t0);
|
2008-12-07 00:46:17 +03:00
|
|
|
tcg_temp_free(t0);
|
2016-06-22 00:48:51 +03:00
|
|
|
#endif /* defined(CONFIG_USER_ONLY) */
|
2003-11-23 17:55:54 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/* mfsrin */
|
2009-06-17 19:22:09 +04:00
|
|
|
static void gen_mfsrin(DisasContext *ctx)
|
2003-11-23 17:55:54 +03:00
|
|
|
{
|
2004-01-05 01:58:38 +03:00
|
|
|
#if defined(CONFIG_USER_ONLY)
|
2016-06-22 00:48:51 +03:00
|
|
|
GEN_PRIV;
|
2004-01-05 01:58:38 +03:00
|
|
|
#else
|
2008-12-07 00:46:17 +03:00
|
|
|
TCGv t0;
|
2016-06-22 00:48:51 +03:00
|
|
|
|
|
|
|
CHK_SV;
|
2008-12-07 00:46:17 +03: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 08:23:31 +04:00
|
|
|
gen_helper_load_sr(cpu_gpr[rD(ctx->opcode)], cpu_env, t0);
|
2008-12-07 00:46:17 +03:00
|
|
|
tcg_temp_free(t0);
|
2016-06-22 00:48:51 +03:00
|
|
|
#endif /* defined(CONFIG_USER_ONLY) */
|
2003-11-23 17:55:54 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/* mtsr */
|
2009-06-17 19:22:09 +04:00
|
|
|
static void gen_mtsr(DisasContext *ctx)
|
2003-11-23 17:55:54 +03:00
|
|
|
{
|
2004-01-05 01:58:38 +03:00
|
|
|
#if defined(CONFIG_USER_ONLY)
|
2016-06-22 00:48:51 +03:00
|
|
|
GEN_PRIV;
|
2004-01-05 01:58:38 +03:00
|
|
|
#else
|
2008-12-07 00:46:17 +03:00
|
|
|
TCGv t0;
|
2016-06-22 00:48:51 +03:00
|
|
|
|
|
|
|
CHK_SV;
|
2008-12-07 00:46:17 +03:00
|
|
|
t0 = tcg_const_tl(SR(ctx->opcode));
|
2012-05-30 08:23:31 +04:00
|
|
|
gen_helper_store_sr(cpu_env, t0, cpu_gpr[rS(ctx->opcode)]);
|
2008-12-07 00:46:17 +03:00
|
|
|
tcg_temp_free(t0);
|
2016-06-22 00:48:51 +03:00
|
|
|
#endif /* defined(CONFIG_USER_ONLY) */
|
2003-11-23 17:55:54 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/* mtsrin */
|
2009-06-17 19:22:09 +04:00
|
|
|
static void gen_mtsrin(DisasContext *ctx)
|
2003-11-23 17:55:54 +03:00
|
|
|
{
|
2004-01-05 01:58:38 +03:00
|
|
|
#if defined(CONFIG_USER_ONLY)
|
2016-06-22 00:48:51 +03:00
|
|
|
GEN_PRIV;
|
2004-01-05 01:58:38 +03:00
|
|
|
#else
|
2008-12-07 00:46:17 +03:00
|
|
|
TCGv t0;
|
2016-06-22 00:48:51 +03:00
|
|
|
CHK_SV;
|
|
|
|
|
2008-12-07 00:46:17 +03: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 08:23:31 +04:00
|
|
|
gen_helper_store_sr(cpu_env, t0, cpu_gpr[rD(ctx->opcode)]);
|
2008-12-07 00:46:17 +03:00
|
|
|
tcg_temp_free(t0);
|
2016-06-22 00:48:51 +03:00
|
|
|
#endif /* defined(CONFIG_USER_ONLY) */
|
2003-11-23 17:55:54 +03:00
|
|
|
}
|
|
|
|
|
2007-10-06 02:06:02 +04:00
|
|
|
#if defined(TARGET_PPC64)
|
|
|
|
/* Specific implementation for PowerPC 64 "bridge" emulation using SLB */
|
2009-06-17 19:22:14 +04:00
|
|
|
|
2009-06-17 19:22:19 +04:00
|
|
|
/* mfsr */
|
2009-06-17 19:22:14 +04:00
|
|
|
static void gen_mfsr_64b(DisasContext *ctx)
|
2007-10-06 02:06:02 +04:00
|
|
|
{
|
|
|
|
#if defined(CONFIG_USER_ONLY)
|
2016-06-22 00:48:51 +03:00
|
|
|
GEN_PRIV;
|
2007-10-06 02:06:02 +04:00
|
|
|
#else
|
2008-12-07 00:46:17 +03:00
|
|
|
TCGv t0;
|
2016-06-22 00:48:51 +03:00
|
|
|
|
|
|
|
CHK_SV;
|
2008-12-07 00:46:17 +03:00
|
|
|
t0 = tcg_const_tl(SR(ctx->opcode));
|
2012-05-30 08:23:31 +04:00
|
|
|
gen_helper_load_sr(cpu_gpr[rD(ctx->opcode)], cpu_env, t0);
|
2008-12-07 00:46:17 +03:00
|
|
|
tcg_temp_free(t0);
|
2016-06-22 00:48:51 +03:00
|
|
|
#endif /* defined(CONFIG_USER_ONLY) */
|
2007-10-06 02:06:02 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* mfsrin */
|
2009-06-17 19:22:14 +04:00
|
|
|
static void gen_mfsrin_64b(DisasContext *ctx)
|
2007-10-06 02:06:02 +04:00
|
|
|
{
|
|
|
|
#if defined(CONFIG_USER_ONLY)
|
2016-06-22 00:48:51 +03:00
|
|
|
GEN_PRIV;
|
2007-10-06 02:06:02 +04:00
|
|
|
#else
|
2008-12-07 00:46:17 +03:00
|
|
|
TCGv t0;
|
2016-06-22 00:48:51 +03:00
|
|
|
|
|
|
|
CHK_SV;
|
2008-12-07 00:46:17 +03: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 08:23:31 +04:00
|
|
|
gen_helper_load_sr(cpu_gpr[rD(ctx->opcode)], cpu_env, t0);
|
2008-12-07 00:46:17 +03:00
|
|
|
tcg_temp_free(t0);
|
2016-06-22 00:48:51 +03:00
|
|
|
#endif /* defined(CONFIG_USER_ONLY) */
|
2007-10-06 02:06:02 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* mtsr */
|
2009-06-17 19:22:14 +04:00
|
|
|
static void gen_mtsr_64b(DisasContext *ctx)
|
2007-10-06 02:06:02 +04:00
|
|
|
{
|
|
|
|
#if defined(CONFIG_USER_ONLY)
|
2016-06-22 00:48:51 +03:00
|
|
|
GEN_PRIV;
|
2007-10-06 02:06:02 +04:00
|
|
|
#else
|
2008-12-07 00:46:17 +03:00
|
|
|
TCGv t0;
|
2016-06-22 00:48:51 +03:00
|
|
|
|
|
|
|
CHK_SV;
|
2008-12-07 00:46:17 +03:00
|
|
|
t0 = tcg_const_tl(SR(ctx->opcode));
|
2012-05-30 08:23:31 +04:00
|
|
|
gen_helper_store_sr(cpu_env, t0, cpu_gpr[rS(ctx->opcode)]);
|
2008-12-07 00:46:17 +03:00
|
|
|
tcg_temp_free(t0);
|
2016-06-22 00:48:51 +03:00
|
|
|
#endif /* defined(CONFIG_USER_ONLY) */
|
2007-10-06 02:06:02 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* mtsrin */
|
2009-06-17 19:22:14 +04:00
|
|
|
static void gen_mtsrin_64b(DisasContext *ctx)
|
2007-10-06 02:06:02 +04:00
|
|
|
{
|
|
|
|
#if defined(CONFIG_USER_ONLY)
|
2016-06-22 00:48:51 +03:00
|
|
|
GEN_PRIV;
|
2007-10-06 02:06:02 +04:00
|
|
|
#else
|
2008-12-07 00:46:17 +03:00
|
|
|
TCGv t0;
|
2016-06-22 00:48:51 +03:00
|
|
|
|
|
|
|
CHK_SV;
|
2008-12-07 00:46:17 +03: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 08:23:31 +04:00
|
|
|
gen_helper_store_sr(cpu_env, t0, cpu_gpr[rS(ctx->opcode)]);
|
2008-12-07 00:46:17 +03:00
|
|
|
tcg_temp_free(t0);
|
2016-06-22 00:48:51 +03:00
|
|
|
#endif /* defined(CONFIG_USER_ONLY) */
|
2007-10-06 02:06:02 +04:00
|
|
|
}
|
2009-03-07 23:50:01 +03:00
|
|
|
|
|
|
|
/* slbmte */
|
2009-06-17 19:22:14 +04:00
|
|
|
static void gen_slbmte(DisasContext *ctx)
|
2009-03-07 23:50:01 +03:00
|
|
|
{
|
|
|
|
#if defined(CONFIG_USER_ONLY)
|
2016-06-22 00:48:51 +03:00
|
|
|
GEN_PRIV;
|
2009-03-07 23:50:01 +03:00
|
|
|
#else
|
2016-06-22 00:48:51 +03:00
|
|
|
CHK_SV;
|
|
|
|
|
2012-05-30 08:23:31 +04:00
|
|
|
gen_helper_store_slb(cpu_env, cpu_gpr[rB(ctx->opcode)],
|
|
|
|
cpu_gpr[rS(ctx->opcode)]);
|
2016-06-22 00:48:51 +03:00
|
|
|
#endif /* defined(CONFIG_USER_ONLY) */
|
2009-03-07 23:50:01 +03:00
|
|
|
}
|
|
|
|
|
2011-04-01 08:15:11 +04:00
|
|
|
static void gen_slbmfee(DisasContext *ctx)
|
|
|
|
{
|
|
|
|
#if defined(CONFIG_USER_ONLY)
|
2016-06-22 00:48:51 +03:00
|
|
|
GEN_PRIV;
|
2011-04-01 08:15:11 +04:00
|
|
|
#else
|
2016-06-22 00:48:51 +03:00
|
|
|
CHK_SV;
|
|
|
|
|
2012-05-30 08:23:31 +04:00
|
|
|
gen_helper_load_slb_esid(cpu_gpr[rS(ctx->opcode)], cpu_env,
|
2011-04-01 08:15:11 +04:00
|
|
|
cpu_gpr[rB(ctx->opcode)]);
|
2016-06-22 00:48:51 +03:00
|
|
|
#endif /* defined(CONFIG_USER_ONLY) */
|
2011-04-01 08:15:11 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void gen_slbmfev(DisasContext *ctx)
|
|
|
|
{
|
|
|
|
#if defined(CONFIG_USER_ONLY)
|
2016-06-22 00:48:51 +03:00
|
|
|
GEN_PRIV;
|
2011-04-01 08:15:11 +04:00
|
|
|
#else
|
2016-06-22 00:48:51 +03:00
|
|
|
CHK_SV;
|
|
|
|
|
2012-05-30 08:23:31 +04:00
|
|
|
gen_helper_load_slb_vsid(cpu_gpr[rS(ctx->opcode)], cpu_env,
|
2011-04-01 08:15:11 +04:00
|
|
|
cpu_gpr[rB(ctx->opcode)]);
|
2016-06-22 00:48:51 +03:00
|
|
|
#endif /* defined(CONFIG_USER_ONLY) */
|
2011-04-01 08:15:11 +04:00
|
|
|
}
|
2016-06-07 05:50:27 +03:00
|
|
|
|
|
|
|
static void gen_slbfee_(DisasContext *ctx)
|
|
|
|
{
|
|
|
|
#if defined(CONFIG_USER_ONLY)
|
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG);
|
|
|
|
#else
|
|
|
|
TCGLabel *l1, *l2;
|
|
|
|
|
|
|
|
if (unlikely(ctx->pr)) {
|
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
gen_helper_find_slb_vsid(cpu_gpr[rS(ctx->opcode)], cpu_env,
|
|
|
|
cpu_gpr[rB(ctx->opcode)]);
|
|
|
|
l1 = gen_new_label();
|
|
|
|
l2 = gen_new_label();
|
|
|
|
tcg_gen_trunc_tl_i32(cpu_crf[0], cpu_so);
|
|
|
|
tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_gpr[rS(ctx->opcode)], -1, l1);
|
|
|
|
tcg_gen_ori_i32(cpu_crf[0], cpu_crf[0], 1 << CRF_EQ);
|
|
|
|
tcg_gen_br(l2);
|
|
|
|
gen_set_label(l1);
|
|
|
|
tcg_gen_movi_tl(cpu_gpr[rS(ctx->opcode)], 0);
|
|
|
|
gen_set_label(l2);
|
|
|
|
#endif
|
|
|
|
}
|
2007-10-06 02:06:02 +04:00
|
|
|
#endif /* defined(TARGET_PPC64) */
|
|
|
|
|
2003-11-23 17:55:54 +03:00
|
|
|
/*** Lookaside buffer management ***/
|
2014-09-15 19:03:28 +04:00
|
|
|
/* Optional & supervisor only: */
|
2009-06-17 19:22:09 +04:00
|
|
|
|
2009-06-17 19:22:19 +04:00
|
|
|
/* tlbia */
|
2009-06-17 19:22:09 +04:00
|
|
|
static void gen_tlbia(DisasContext *ctx)
|
2003-11-23 17:55:54 +03:00
|
|
|
{
|
2004-01-05 01:58:38 +03:00
|
|
|
#if defined(CONFIG_USER_ONLY)
|
2016-06-22 00:48:51 +03:00
|
|
|
GEN_PRIV;
|
2004-01-05 01:58:38 +03:00
|
|
|
#else
|
2016-06-22 00:48:51 +03:00
|
|
|
CHK_HV;
|
|
|
|
|
2012-05-30 08:23:31 +04:00
|
|
|
gen_helper_tlbia(cpu_env);
|
2016-06-22 00:48:51 +03:00
|
|
|
#endif /* defined(CONFIG_USER_ONLY) */
|
2003-11-23 17:55:54 +03:00
|
|
|
}
|
|
|
|
|
2009-03-07 23:52:22 +03:00
|
|
|
/* tlbiel */
|
2009-06-17 19:22:09 +04:00
|
|
|
static void gen_tlbiel(DisasContext *ctx)
|
2009-03-07 23:52:22 +03:00
|
|
|
{
|
|
|
|
#if defined(CONFIG_USER_ONLY)
|
2016-06-22 00:48:51 +03:00
|
|
|
GEN_PRIV;
|
2009-03-07 23:52:22 +03:00
|
|
|
#else
|
2016-06-22 00:48:51 +03:00
|
|
|
CHK_SV;
|
|
|
|
|
2012-05-30 08:23:31 +04:00
|
|
|
gen_helper_tlbie(cpu_env, cpu_gpr[rB(ctx->opcode)]);
|
2016-06-22 00:48:51 +03:00
|
|
|
#endif /* defined(CONFIG_USER_ONLY) */
|
2009-03-07 23:52:22 +03:00
|
|
|
}
|
|
|
|
|
2003-11-23 17:55:54 +03:00
|
|
|
/* tlbie */
|
2009-06-17 19:22:09 +04:00
|
|
|
static void gen_tlbie(DisasContext *ctx)
|
2003-11-23 17:55:54 +03:00
|
|
|
{
|
2004-01-05 01:58:38 +03:00
|
|
|
#if defined(CONFIG_USER_ONLY)
|
2016-06-22 00:48:51 +03:00
|
|
|
GEN_PRIV;
|
2004-01-05 01:58:38 +03:00
|
|
|
#else
|
2016-06-22 00:48:51 +03:00
|
|
|
CHK_HV;
|
|
|
|
|
2013-03-21 14:01:49 +04:00
|
|
|
if (NARROW_MODE(ctx)) {
|
2008-12-07 00:46:17 +03:00
|
|
|
TCGv t0 = tcg_temp_new();
|
|
|
|
tcg_gen_ext32u_tl(t0, cpu_gpr[rB(ctx->opcode)]);
|
2012-05-30 08:23:31 +04:00
|
|
|
gen_helper_tlbie(cpu_env, t0);
|
2008-12-07 00:46:17 +03:00
|
|
|
tcg_temp_free(t0);
|
2013-03-21 14:01:49 +04:00
|
|
|
} else {
|
2012-05-30 08:23:31 +04:00
|
|
|
gen_helper_tlbie(cpu_env, cpu_gpr[rB(ctx->opcode)]);
|
2013-03-21 14:01:49 +04:00
|
|
|
}
|
2016-06-22 00:48:51 +03:00
|
|
|
#endif /* defined(CONFIG_USER_ONLY) */
|
2003-11-23 17:55:54 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/* tlbsync */
|
2009-06-17 19:22:09 +04:00
|
|
|
static void gen_tlbsync(DisasContext *ctx)
|
2003-11-23 17:55:54 +03:00
|
|
|
{
|
2004-01-05 01:58:38 +03:00
|
|
|
#if defined(CONFIG_USER_ONLY)
|
2016-06-22 00:48:51 +03:00
|
|
|
GEN_PRIV;
|
2004-01-05 01:58:38 +03:00
|
|
|
#else
|
2016-06-22 00:48:51 +03:00
|
|
|
CHK_HV;
|
|
|
|
|
ppc: Do some batching of TCG tlb flushes
On ppc64 especially, we flush the tlb on any slbie or tlbie instruction.
However, those instructions often come in bursts of 3 or more (context
switch will favor a series of slbie's for example to an slbia if the
SLB has less than a certain number of entries in it, and tlbie's can
happen in a series, with PAPR, H_BULK_REMOVE can remove up to 4 entries
at a time.
Doing a tlb_flush() each time is a waste of time. We end up doing a memset
of the whole TLB, reloading it for the next instruction, memset'ing again,
etc...
Those instructions don't have to take effect immediately. For slbie, they
can wait for the next context synchronizing event. For tlbie, the next
tlbsync.
This implements batching by keeping a flag that indicates that we have a
TLB in need of flushing. We check it on interrupts, rfi's, isync's and
tlbsync and flush the TLB if needed.
This reduces the number of tlb_flush() on a boot to a ubuntu installer
first dialog screen from roughly 360K down to 36K.
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
[clg: added a 'CPUPPCState *' variable in h_remove() and
h_bulk_remove() ]
Signed-off-by: Cédric Le Goater <clg@kaod.org>
[dwg: removed spurious whitespace change, use 0/1 not true/false
consistently, since tlb_need_flush has int type]
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2016-05-03 19:03:25 +03:00
|
|
|
/* tlbsync is a nop for server, ptesync handles delayed tlb flush,
|
|
|
|
* embedded however needs to deal with tlbsync. We don't try to be
|
|
|
|
* fancy and swallow the overhead of checking for both.
|
2004-01-05 01:58:38 +03:00
|
|
|
*/
|
ppc: Do some batching of TCG tlb flushes
On ppc64 especially, we flush the tlb on any slbie or tlbie instruction.
However, those instructions often come in bursts of 3 or more (context
switch will favor a series of slbie's for example to an slbia if the
SLB has less than a certain number of entries in it, and tlbie's can
happen in a series, with PAPR, H_BULK_REMOVE can remove up to 4 entries
at a time.
Doing a tlb_flush() each time is a waste of time. We end up doing a memset
of the whole TLB, reloading it for the next instruction, memset'ing again,
etc...
Those instructions don't have to take effect immediately. For slbie, they
can wait for the next context synchronizing event. For tlbie, the next
tlbsync.
This implements batching by keeping a flag that indicates that we have a
TLB in need of flushing. We check it on interrupts, rfi's, isync's and
tlbsync and flush the TLB if needed.
This reduces the number of tlb_flush() on a boot to a ubuntu installer
first dialog screen from roughly 360K down to 36K.
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
[clg: added a 'CPUPPCState *' variable in h_remove() and
h_bulk_remove() ]
Signed-off-by: Cédric Le Goater <clg@kaod.org>
[dwg: removed spurious whitespace change, use 0/1 not true/false
consistently, since tlb_need_flush has int type]
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2016-05-03 19:03:25 +03:00
|
|
|
gen_check_tlb_flush(ctx);
|
2016-06-22 00:48:51 +03:00
|
|
|
#endif /* defined(CONFIG_USER_ONLY) */
|
2003-11-23 17:55:54 +03:00
|
|
|
}
|
|
|
|
|
2007-03-23 12:45:27 +03:00
|
|
|
#if defined(TARGET_PPC64)
|
|
|
|
/* slbia */
|
2009-06-17 19:22:09 +04:00
|
|
|
static void gen_slbia(DisasContext *ctx)
|
2007-03-23 12:45:27 +03:00
|
|
|
{
|
|
|
|
#if defined(CONFIG_USER_ONLY)
|
2016-06-22 00:48:51 +03:00
|
|
|
GEN_PRIV;
|
2007-03-23 12:45:27 +03:00
|
|
|
#else
|
2016-06-22 00:48:51 +03:00
|
|
|
CHK_SV;
|
|
|
|
|
2012-05-30 08:23:31 +04:00
|
|
|
gen_helper_slbia(cpu_env);
|
2016-06-22 00:48:51 +03:00
|
|
|
#endif /* defined(CONFIG_USER_ONLY) */
|
2007-03-23 12:45:27 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/* slbie */
|
2009-06-17 19:22:09 +04:00
|
|
|
static void gen_slbie(DisasContext *ctx)
|
2007-03-23 12:45:27 +03:00
|
|
|
{
|
|
|
|
#if defined(CONFIG_USER_ONLY)
|
2016-06-22 00:48:51 +03:00
|
|
|
GEN_PRIV;
|
2007-03-23 12:45:27 +03:00
|
|
|
#else
|
2016-06-22 00:48:51 +03:00
|
|
|
CHK_SV;
|
|
|
|
|
2012-05-30 08:23:31 +04:00
|
|
|
gen_helper_slbie(cpu_env, cpu_gpr[rB(ctx->opcode)]);
|
2016-06-22 00:48:51 +03:00
|
|
|
#endif /* defined(CONFIG_USER_ONLY) */
|
2007-03-23 12:45:27 +03:00
|
|
|
}
|
2016-06-22 00:48:51 +03:00
|
|
|
#endif /* defined(TARGET_PPC64) */
|
2007-03-23 12:45:27 +03:00
|
|
|
|
2003-11-23 17:55:54 +03:00
|
|
|
/*** External control ***/
|
|
|
|
/* Optional: */
|
2009-06-17 19:22:09 +04:00
|
|
|
|
2009-06-17 19:22:19 +04:00
|
|
|
/* eciwx */
|
2009-06-17 19:22:09 +04:00
|
|
|
static void gen_eciwx(DisasContext *ctx)
|
2003-11-23 17:55:54 +03:00
|
|
|
{
|
2008-12-08 21:11:21 +03:00
|
|
|
TCGv t0;
|
2008-11-30 19:24:47 +03:00
|
|
|
/* Should check EAR[E] ! */
|
2008-12-08 21:11:21 +03:00
|
|
|
gen_set_access_type(ctx, ACCESS_EXT);
|
|
|
|
t0 = tcg_temp_new();
|
|
|
|
gen_addr_reg_index(ctx, t0);
|
2008-11-30 19:24:47 +03:00
|
|
|
gen_check_align(ctx, t0, 0x03);
|
2008-12-08 21:11:21 +03:00
|
|
|
gen_qemu_ld32u(ctx, cpu_gpr[rD(ctx->opcode)], t0);
|
2008-11-30 19:24:47 +03:00
|
|
|
tcg_temp_free(t0);
|
2007-03-07 11:32:30 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ecowx */
|
2009-06-17 19:22:09 +04:00
|
|
|
static void gen_ecowx(DisasContext *ctx)
|
2007-03-07 11:32:30 +03:00
|
|
|
{
|
2008-12-08 21:11:21 +03:00
|
|
|
TCGv t0;
|
2008-11-30 19:24:47 +03:00
|
|
|
/* Should check EAR[E] ! */
|
2008-12-08 21:11:21 +03:00
|
|
|
gen_set_access_type(ctx, ACCESS_EXT);
|
|
|
|
t0 = tcg_temp_new();
|
|
|
|
gen_addr_reg_index(ctx, t0);
|
2008-11-30 19:24:47 +03:00
|
|
|
gen_check_align(ctx, t0, 0x03);
|
2008-12-08 21:11:21 +03:00
|
|
|
gen_qemu_st32(ctx, cpu_gpr[rD(ctx->opcode)], t0);
|
2008-11-30 19:24:47 +03:00
|
|
|
tcg_temp_free(t0);
|
2007-03-07 11:32:30 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/* PowerPC 601 specific instructions */
|
2009-06-17 19:22:09 +04:00
|
|
|
|
2009-06-17 19:22:19 +04:00
|
|
|
/* abs - abs. */
|
2009-06-17 19:22:09 +04:00
|
|
|
static void gen_abs(DisasContext *ctx)
|
2007-03-07 11:32:30 +03:00
|
|
|
{
|
2015-02-13 23:51:55 +03:00
|
|
|
TCGLabel *l1 = gen_new_label();
|
|
|
|
TCGLabel *l2 = gen_new_label();
|
2008-12-06 15:19:14 +03: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 11:32:30 +03:00
|
|
|
if (unlikely(Rc(ctx->opcode) != 0))
|
2008-12-06 15:19:14 +03:00
|
|
|
gen_set_Rc0(ctx, cpu_gpr[rD(ctx->opcode)]);
|
2007-03-07 11:32:30 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/* abso - abso. */
|
2009-06-17 19:22:09 +04:00
|
|
|
static void gen_abso(DisasContext *ctx)
|
2007-03-07 11:32:30 +03:00
|
|
|
{
|
2015-02-13 23:51:55 +03:00
|
|
|
TCGLabel *l1 = gen_new_label();
|
|
|
|
TCGLabel *l2 = gen_new_label();
|
|
|
|
TCGLabel *l3 = gen_new_label();
|
2008-12-06 15:19:14 +03:00
|
|
|
/* Start with XER OV disabled, the most likely case */
|
2013-02-20 11:52:13 +04:00
|
|
|
tcg_gen_movi_tl(cpu_ov, 0);
|
2008-12-06 15:19:14 +03: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 11:52:13 +04:00
|
|
|
tcg_gen_movi_tl(cpu_ov, 1);
|
|
|
|
tcg_gen_movi_tl(cpu_so, 1);
|
2008-12-06 15:19:14 +03: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 11:32:30 +03:00
|
|
|
if (unlikely(Rc(ctx->opcode) != 0))
|
2008-12-06 15:19:14 +03:00
|
|
|
gen_set_Rc0(ctx, cpu_gpr[rD(ctx->opcode)]);
|
2007-03-07 11:32:30 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/* clcs */
|
2009-06-17 19:22:09 +04:00
|
|
|
static void gen_clcs(DisasContext *ctx)
|
2007-03-07 11:32:30 +03:00
|
|
|
{
|
2008-12-06 15:19:14 +03:00
|
|
|
TCGv_i32 t0 = tcg_const_i32(rA(ctx->opcode));
|
2012-05-30 08:23:38 +04:00
|
|
|
gen_helper_clcs(cpu_gpr[rD(ctx->opcode)], cpu_env, t0);
|
2008-12-06 15:19:14 +03:00
|
|
|
tcg_temp_free_i32(t0);
|
2007-10-26 04:46:07 +04:00
|
|
|
/* Rc=1 sets CR0 to an undefined state */
|
2007-03-07 11:32:30 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/* div - div. */
|
2009-06-17 19:22:09 +04:00
|
|
|
static void gen_div(DisasContext *ctx)
|
2007-03-07 11:32:30 +03:00
|
|
|
{
|
2012-05-30 08:23:29 +04:00
|
|
|
gen_helper_div(cpu_gpr[rD(ctx->opcode)], cpu_env, cpu_gpr[rA(ctx->opcode)],
|
|
|
|
cpu_gpr[rB(ctx->opcode)]);
|
2007-03-07 11:32:30 +03:00
|
|
|
if (unlikely(Rc(ctx->opcode) != 0))
|
2008-12-06 15:19:14 +03:00
|
|
|
gen_set_Rc0(ctx, cpu_gpr[rD(ctx->opcode)]);
|
2007-03-07 11:32:30 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/* divo - divo. */
|
2009-06-17 19:22:09 +04:00
|
|
|
static void gen_divo(DisasContext *ctx)
|
2007-03-07 11:32:30 +03:00
|
|
|
{
|
2012-05-30 08:23:29 +04:00
|
|
|
gen_helper_divo(cpu_gpr[rD(ctx->opcode)], cpu_env, cpu_gpr[rA(ctx->opcode)],
|
|
|
|
cpu_gpr[rB(ctx->opcode)]);
|
2007-03-07 11:32:30 +03:00
|
|
|
if (unlikely(Rc(ctx->opcode) != 0))
|
2008-12-06 15:19:14 +03:00
|
|
|
gen_set_Rc0(ctx, cpu_gpr[rD(ctx->opcode)]);
|
2007-03-07 11:32:30 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/* divs - divs. */
|
2009-06-17 19:22:09 +04:00
|
|
|
static void gen_divs(DisasContext *ctx)
|
2007-03-07 11:32:30 +03:00
|
|
|
{
|
2012-05-30 08:23:29 +04:00
|
|
|
gen_helper_divs(cpu_gpr[rD(ctx->opcode)], cpu_env, cpu_gpr[rA(ctx->opcode)],
|
|
|
|
cpu_gpr[rB(ctx->opcode)]);
|
2007-03-07 11:32:30 +03:00
|
|
|
if (unlikely(Rc(ctx->opcode) != 0))
|
2008-12-06 15:19:14 +03:00
|
|
|
gen_set_Rc0(ctx, cpu_gpr[rD(ctx->opcode)]);
|
2007-03-07 11:32:30 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/* divso - divso. */
|
2009-06-17 19:22:09 +04:00
|
|
|
static void gen_divso(DisasContext *ctx)
|
2007-03-07 11:32:30 +03:00
|
|
|
{
|
2012-05-30 08:23:29 +04:00
|
|
|
gen_helper_divso(cpu_gpr[rD(ctx->opcode)], cpu_env,
|
|
|
|
cpu_gpr[rA(ctx->opcode)], cpu_gpr[rB(ctx->opcode)]);
|
2007-03-07 11:32:30 +03:00
|
|
|
if (unlikely(Rc(ctx->opcode) != 0))
|
2008-12-06 15:19:14 +03:00
|
|
|
gen_set_Rc0(ctx, cpu_gpr[rD(ctx->opcode)]);
|
2007-03-07 11:32:30 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/* doz - doz. */
|
2009-06-17 19:22:09 +04:00
|
|
|
static void gen_doz(DisasContext *ctx)
|
2007-03-07 11:32:30 +03:00
|
|
|
{
|
2015-02-13 23:51:55 +03:00
|
|
|
TCGLabel *l1 = gen_new_label();
|
|
|
|
TCGLabel *l2 = gen_new_label();
|
2008-12-06 15:19:14 +03: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 11:32:30 +03:00
|
|
|
if (unlikely(Rc(ctx->opcode) != 0))
|
2008-12-06 15:19:14 +03:00
|
|
|
gen_set_Rc0(ctx, cpu_gpr[rD(ctx->opcode)]);
|
2007-03-07 11:32:30 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/* dozo - dozo. */
|
2009-06-17 19:22:09 +04:00
|
|
|
static void gen_dozo(DisasContext *ctx)
|
2007-03-07 11:32:30 +03:00
|
|
|
{
|
2015-02-13 23:51:55 +03:00
|
|
|
TCGLabel *l1 = gen_new_label();
|
|
|
|
TCGLabel *l2 = gen_new_label();
|
2008-12-06 15:19:14 +03: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 11:52:13 +04:00
|
|
|
tcg_gen_movi_tl(cpu_ov, 0);
|
2008-12-06 15:19:14 +03: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 11:52:13 +04:00
|
|
|
tcg_gen_movi_tl(cpu_ov, 1);
|
|
|
|
tcg_gen_movi_tl(cpu_so, 1);
|
2008-12-06 15:19:14 +03: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 11:32:30 +03:00
|
|
|
if (unlikely(Rc(ctx->opcode) != 0))
|
2008-12-06 15:19:14 +03:00
|
|
|
gen_set_Rc0(ctx, cpu_gpr[rD(ctx->opcode)]);
|
2007-03-07 11:32:30 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/* dozi */
|
2009-06-17 19:22:09 +04:00
|
|
|
static void gen_dozi(DisasContext *ctx)
|
2007-03-07 11:32:30 +03:00
|
|
|
{
|
2008-12-06 15:19:14 +03:00
|
|
|
target_long simm = SIMM(ctx->opcode);
|
2015-02-13 23:51:55 +03:00
|
|
|
TCGLabel *l1 = gen_new_label();
|
|
|
|
TCGLabel *l2 = gen_new_label();
|
2008-12-06 15:19:14 +03: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 11:32:30 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/* lscbx - lscbx. */
|
2009-06-17 19:22:09 +04:00
|
|
|
static void gen_lscbx(DisasContext *ctx)
|
2007-03-07 11:32:30 +03:00
|
|
|
{
|
2008-11-30 19:24:30 +03: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 11:32:30 +03:00
|
|
|
|
2008-12-08 21:11:21 +03:00
|
|
|
gen_addr_reg_index(ctx, t0);
|
2012-05-30 08:23:40 +04:00
|
|
|
gen_helper_lscbx(t0, cpu_env, t0, t1, t2, t3);
|
2008-11-30 19:24:30 +03:00
|
|
|
tcg_temp_free_i32(t1);
|
|
|
|
tcg_temp_free_i32(t2);
|
|
|
|
tcg_temp_free_i32(t3);
|
2008-10-21 15:28:46 +04:00
|
|
|
tcg_gen_andi_tl(cpu_xer, cpu_xer, ~0x7F);
|
2008-11-30 19:24:30 +03:00
|
|
|
tcg_gen_or_tl(cpu_xer, cpu_xer, t0);
|
2007-03-07 11:32:30 +03:00
|
|
|
if (unlikely(Rc(ctx->opcode) != 0))
|
2008-11-30 19:24:30 +03:00
|
|
|
gen_set_Rc0(ctx, t0);
|
|
|
|
tcg_temp_free(t0);
|
2007-03-07 11:32:30 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/* maskg - maskg. */
|
2009-06-17 19:22:09 +04:00
|
|
|
static void gen_maskg(DisasContext *ctx)
|
2007-03-07 11:32:30 +03:00
|
|
|
{
|
2015-02-13 23:51:55 +03:00
|
|
|
TCGLabel *l1 = gen_new_label();
|
2008-12-06 15:19:14 +03: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 11:32:30 +03:00
|
|
|
if (unlikely(Rc(ctx->opcode) != 0))
|
2008-12-06 15:19:14 +03:00
|
|
|
gen_set_Rc0(ctx, cpu_gpr[rA(ctx->opcode)]);
|
2007-03-07 11:32:30 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/* maskir - maskir. */
|
2009-06-17 19:22:09 +04:00
|
|
|
static void gen_maskir(DisasContext *ctx)
|
2007-03-07 11:32:30 +03:00
|
|
|
{
|
2008-12-06 15:19:14 +03: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 11:32:30 +03:00
|
|
|
if (unlikely(Rc(ctx->opcode) != 0))
|
2008-12-06 15:19:14 +03:00
|
|
|
gen_set_Rc0(ctx, cpu_gpr[rA(ctx->opcode)]);
|
2007-03-07 11:32:30 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/* mul - mul. */
|
2009-06-17 19:22:09 +04:00
|
|
|
static void gen_mul(DisasContext *ctx)
|
2007-03-07 11:32:30 +03:00
|
|
|
{
|
2008-12-06 15:19:14 +03: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 11:32:30 +03:00
|
|
|
if (unlikely(Rc(ctx->opcode) != 0))
|
2008-12-06 15:19:14 +03:00
|
|
|
gen_set_Rc0(ctx, cpu_gpr[rD(ctx->opcode)]);
|
2007-03-07 11:32:30 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/* mulo - mulo. */
|
2009-06-17 19:22:09 +04:00
|
|
|
static void gen_mulo(DisasContext *ctx)
|
2007-03-07 11:32:30 +03:00
|
|
|
{
|
2015-02-13 23:51:55 +03:00
|
|
|
TCGLabel *l1 = gen_new_label();
|
2008-12-06 15:19:14 +03: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 11:52:13 +04:00
|
|
|
tcg_gen_movi_tl(cpu_ov, 0);
|
2008-12-06 15:19:14 +03: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 11:52:13 +04:00
|
|
|
tcg_gen_movi_tl(cpu_ov, 1);
|
|
|
|
tcg_gen_movi_tl(cpu_so, 1);
|
2008-12-06 15:19:14 +03:00
|
|
|
gen_set_label(l1);
|
|
|
|
tcg_temp_free_i64(t0);
|
|
|
|
tcg_temp_free_i64(t1);
|
|
|
|
tcg_temp_free(t2);
|
2007-03-07 11:32:30 +03:00
|
|
|
if (unlikely(Rc(ctx->opcode) != 0))
|
2008-12-06 15:19:14 +03:00
|
|
|
gen_set_Rc0(ctx, cpu_gpr[rD(ctx->opcode)]);
|
2007-03-07 11:32:30 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/* nabs - nabs. */
|
2009-06-17 19:22:09 +04:00
|
|
|
static void gen_nabs(DisasContext *ctx)
|
2007-03-07 11:32:30 +03:00
|
|
|
{
|
2015-02-13 23:51:55 +03:00
|
|
|
TCGLabel *l1 = gen_new_label();
|
|
|
|
TCGLabel *l2 = gen_new_label();
|
2008-12-06 15:19:14 +03: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 11:32:30 +03:00
|
|
|
if (unlikely(Rc(ctx->opcode) != 0))
|
2008-12-06 15:19:14 +03:00
|
|
|
gen_set_Rc0(ctx, cpu_gpr[rD(ctx->opcode)]);
|
2007-03-07 11:32:30 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/* nabso - nabso. */
|
2009-06-17 19:22:09 +04:00
|
|
|
static void gen_nabso(DisasContext *ctx)
|
2007-03-07 11:32:30 +03:00
|
|
|
{
|
2015-02-13 23:51:55 +03:00
|
|
|
TCGLabel *l1 = gen_new_label();
|
|
|
|
TCGLabel *l2 = gen_new_label();
|
2008-12-06 15:19:14 +03: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 11:52:13 +04:00
|
|
|
tcg_gen_movi_tl(cpu_ov, 0);
|
2007-03-07 11:32:30 +03:00
|
|
|
if (unlikely(Rc(ctx->opcode) != 0))
|
2008-12-06 15:19:14 +03:00
|
|
|
gen_set_Rc0(ctx, cpu_gpr[rD(ctx->opcode)]);
|
2007-03-07 11:32:30 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/* rlmi - rlmi. */
|
2009-06-17 19:22:09 +04:00
|
|
|
static void gen_rlmi(DisasContext *ctx)
|
2007-03-07 11:32:30 +03:00
|
|
|
{
|
2008-12-05 10:21:44 +03: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 11:32:30 +03:00
|
|
|
if (unlikely(Rc(ctx->opcode) != 0))
|
2008-12-05 10:21:44 +03:00
|
|
|
gen_set_Rc0(ctx, cpu_gpr[rA(ctx->opcode)]);
|
2007-03-07 11:32:30 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/* rrib - rrib. */
|
2009-06-17 19:22:09 +04:00
|
|
|
static void gen_rrib(DisasContext *ctx)
|
2007-03-07 11:32:30 +03:00
|
|
|
{
|
2008-12-05 10:21:44 +03: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 11:32:30 +03:00
|
|
|
if (unlikely(Rc(ctx->opcode) != 0))
|
2008-12-05 10:21:44 +03:00
|
|
|
gen_set_Rc0(ctx, cpu_gpr[rA(ctx->opcode)]);
|
2007-03-07 11:32:30 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/* sle - sle. */
|
2009-06-17 19:22:09 +04:00
|
|
|
static void gen_sle(DisasContext *ctx)
|
2007-03-07 11:32:30 +03:00
|
|
|
{
|
2008-12-05 10:21:44 +03: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 11:32:30 +03:00
|
|
|
if (unlikely(Rc(ctx->opcode) != 0))
|
2008-12-05 10:21:44 +03:00
|
|
|
gen_set_Rc0(ctx, cpu_gpr[rA(ctx->opcode)]);
|
2007-03-07 11:32:30 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/* sleq - sleq. */
|
2009-06-17 19:22:09 +04:00
|
|
|
static void gen_sleq(DisasContext *ctx)
|
2007-03-07 11:32:30 +03:00
|
|
|
{
|
2008-12-05 10:21:44 +03: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 11:32:30 +03:00
|
|
|
if (unlikely(Rc(ctx->opcode) != 0))
|
2008-12-05 10:21:44 +03:00
|
|
|
gen_set_Rc0(ctx, cpu_gpr[rA(ctx->opcode)]);
|
2007-03-07 11:32:30 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/* sliq - sliq. */
|
2009-06-17 19:22:09 +04:00
|
|
|
static void gen_sliq(DisasContext *ctx)
|
2007-03-07 11:32:30 +03:00
|
|
|
{
|
2008-12-05 10:21:44 +03: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 11:32:30 +03:00
|
|
|
if (unlikely(Rc(ctx->opcode) != 0))
|
2008-12-05 10:21:44 +03:00
|
|
|
gen_set_Rc0(ctx, cpu_gpr[rA(ctx->opcode)]);
|
2007-03-07 11:32:30 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/* slliq - slliq. */
|
2009-06-17 19:22:09 +04:00
|
|
|
static void gen_slliq(DisasContext *ctx)
|
2007-03-07 11:32:30 +03:00
|
|
|
{
|
2008-12-05 10:21:44 +03: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 11:32:30 +03:00
|
|
|
if (unlikely(Rc(ctx->opcode) != 0))
|
2008-12-05 10:21:44 +03:00
|
|
|
gen_set_Rc0(ctx, cpu_gpr[rA(ctx->opcode)]);
|
2007-03-07 11:32:30 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/* sllq - sllq. */
|
2009-06-17 19:22:09 +04:00
|
|
|
static void gen_sllq(DisasContext *ctx)
|
2007-03-07 11:32:30 +03:00
|
|
|
{
|
2015-02-13 23:51:55 +03:00
|
|
|
TCGLabel *l1 = gen_new_label();
|
|
|
|
TCGLabel *l2 = gen_new_label();
|
2008-12-05 10:21:44 +03: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 11:32:30 +03:00
|
|
|
if (unlikely(Rc(ctx->opcode) != 0))
|
2008-12-05 10:21:44 +03:00
|
|
|
gen_set_Rc0(ctx, cpu_gpr[rA(ctx->opcode)]);
|
2007-03-07 11:32:30 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/* slq - slq. */
|
2009-06-17 19:22:09 +04:00
|
|
|
static void gen_slq(DisasContext *ctx)
|
2007-03-07 11:32:30 +03:00
|
|
|
{
|
2015-02-13 23:51:55 +03:00
|
|
|
TCGLabel *l1 = gen_new_label();
|
2008-12-05 10:21:44 +03: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 11:32:30 +03:00
|
|
|
if (unlikely(Rc(ctx->opcode) != 0))
|
2008-12-05 10:21:44 +03:00
|
|
|
gen_set_Rc0(ctx, cpu_gpr[rA(ctx->opcode)]);
|
2007-03-07 11:32:30 +03:00
|
|
|
}
|
|
|
|
|
2007-03-17 17:02:15 +03:00
|
|
|
/* sraiq - sraiq. */
|
2009-06-17 19:22:09 +04:00
|
|
|
static void gen_sraiq(DisasContext *ctx)
|
2007-03-07 11:32:30 +03:00
|
|
|
{
|
2008-12-05 10:21:44 +03:00
|
|
|
int sh = SH(ctx->opcode);
|
2015-02-13 23:51:55 +03:00
|
|
|
TCGLabel *l1 = gen_new_label();
|
2008-12-05 10:21:44 +03: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 11:52:13 +04:00
|
|
|
tcg_gen_movi_tl(cpu_ca, 0);
|
2008-12-05 10:21:44 +03: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 11:52:13 +04:00
|
|
|
tcg_gen_movi_tl(cpu_ca, 1);
|
2008-12-05 10:21:44 +03: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 11:32:30 +03:00
|
|
|
if (unlikely(Rc(ctx->opcode) != 0))
|
2008-12-05 10:21:44 +03:00
|
|
|
gen_set_Rc0(ctx, cpu_gpr[rA(ctx->opcode)]);
|
2007-03-07 11:32:30 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/* sraq - sraq. */
|
2009-06-17 19:22:09 +04:00
|
|
|
static void gen_sraq(DisasContext *ctx)
|
2007-03-07 11:32:30 +03:00
|
|
|
{
|
2015-02-13 23:51:55 +03:00
|
|
|
TCGLabel *l1 = gen_new_label();
|
|
|
|
TCGLabel *l2 = gen_new_label();
|
2008-12-05 10:21:44 +03: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 11:52:13 +04:00
|
|
|
tcg_gen_movi_tl(cpu_ca, 0);
|
2008-12-05 10:21:44 +03:00
|
|
|
tcg_gen_brcondi_tl(TCG_COND_GE, t1, 0, l2);
|
|
|
|
tcg_gen_brcondi_tl(TCG_COND_EQ, t2, 0, l2);
|
2013-02-20 11:52:13 +04:00
|
|
|
tcg_gen_movi_tl(cpu_ca, 1);
|
2008-12-05 10:21:44 +03:00
|
|
|
gen_set_label(l2);
|
|
|
|
tcg_temp_free(t1);
|
|
|
|
tcg_temp_free(t2);
|
2007-03-07 11:32:30 +03:00
|
|
|
if (unlikely(Rc(ctx->opcode) != 0))
|
2008-12-05 10:21:44 +03:00
|
|
|
gen_set_Rc0(ctx, cpu_gpr[rA(ctx->opcode)]);
|
2007-03-07 11:32:30 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/* sre - sre. */
|
2009-06-17 19:22:09 +04:00
|
|
|
static void gen_sre(DisasContext *ctx)
|
2007-03-07 11:32:30 +03:00
|
|
|
{
|
2008-12-05 10:21:44 +03: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 11:32:30 +03:00
|
|
|
if (unlikely(Rc(ctx->opcode) != 0))
|
2008-12-05 10:21:44 +03:00
|
|
|
gen_set_Rc0(ctx, cpu_gpr[rA(ctx->opcode)]);
|
2007-03-07 11:32:30 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/* srea - srea. */
|
2009-06-17 19:22:09 +04:00
|
|
|
static void gen_srea(DisasContext *ctx)
|
2007-03-07 11:32:30 +03:00
|
|
|
{
|
2008-12-05 10:21:44 +03: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 11:32:30 +03:00
|
|
|
if (unlikely(Rc(ctx->opcode) != 0))
|
2008-12-05 10:21:44 +03:00
|
|
|
gen_set_Rc0(ctx, cpu_gpr[rA(ctx->opcode)]);
|
2007-03-07 11:32:30 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/* sreq */
|
2009-06-17 19:22:09 +04:00
|
|
|
static void gen_sreq(DisasContext *ctx)
|
2007-03-07 11:32:30 +03:00
|
|
|
{
|
2008-12-05 10:21:44 +03: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 11:32:30 +03:00
|
|
|
if (unlikely(Rc(ctx->opcode) != 0))
|
2008-12-05 10:21:44 +03:00
|
|
|
gen_set_Rc0(ctx, cpu_gpr[rA(ctx->opcode)]);
|
2007-03-07 11:32:30 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/* sriq */
|
2009-06-17 19:22:09 +04:00
|
|
|
static void gen_sriq(DisasContext *ctx)
|
2007-03-07 11:32:30 +03:00
|
|
|
{
|
2008-12-05 10:21:44 +03: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 11:32:30 +03:00
|
|
|
if (unlikely(Rc(ctx->opcode) != 0))
|
2008-12-05 10:21:44 +03:00
|
|
|
gen_set_Rc0(ctx, cpu_gpr[rA(ctx->opcode)]);
|
2007-03-07 11:32:30 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/* srliq */
|
2009-06-17 19:22:09 +04:00
|
|
|
static void gen_srliq(DisasContext *ctx)
|
2007-03-07 11:32:30 +03:00
|
|
|
{
|
2008-12-05 10:21:44 +03: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 11:32:30 +03:00
|
|
|
if (unlikely(Rc(ctx->opcode) != 0))
|
2008-12-05 10:21:44 +03:00
|
|
|
gen_set_Rc0(ctx, cpu_gpr[rA(ctx->opcode)]);
|
2007-03-07 11:32:30 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/* srlq */
|
2009-06-17 19:22:09 +04:00
|
|
|
static void gen_srlq(DisasContext *ctx)
|
2007-03-07 11:32:30 +03:00
|
|
|
{
|
2015-02-13 23:51:55 +03:00
|
|
|
TCGLabel *l1 = gen_new_label();
|
|
|
|
TCGLabel *l2 = gen_new_label();
|
2008-12-05 10:21:44 +03: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 11:32:30 +03:00
|
|
|
if (unlikely(Rc(ctx->opcode) != 0))
|
2008-12-05 10:21:44 +03:00
|
|
|
gen_set_Rc0(ctx, cpu_gpr[rA(ctx->opcode)]);
|
2007-03-07 11:32:30 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/* srq */
|
2009-06-17 19:22:09 +04:00
|
|
|
static void gen_srq(DisasContext *ctx)
|
2007-03-07 11:32:30 +03:00
|
|
|
{
|
2015-02-13 23:51:55 +03:00
|
|
|
TCGLabel *l1 = gen_new_label();
|
2008-12-05 10:21:44 +03: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 11:32:30 +03:00
|
|
|
if (unlikely(Rc(ctx->opcode) != 0))
|
2008-12-05 10:21:44 +03:00
|
|
|
gen_set_Rc0(ctx, cpu_gpr[rA(ctx->opcode)]);
|
2007-03-07 11:32:30 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/* PowerPC 602 specific instructions */
|
2009-06-17 19:22:09 +04:00
|
|
|
|
2009-06-17 19:22:19 +04:00
|
|
|
/* dsa */
|
2009-06-17 19:22:09 +04:00
|
|
|
static void gen_dsa(DisasContext *ctx)
|
2007-03-07 11:32:30 +03:00
|
|
|
{
|
|
|
|
/* XXX: TODO */
|
2008-12-12 01:42:14 +03:00
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_INVAL_INVAL);
|
2007-03-07 11:32:30 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/* esa */
|
2009-06-17 19:22:09 +04:00
|
|
|
static void gen_esa(DisasContext *ctx)
|
2007-03-07 11:32:30 +03:00
|
|
|
{
|
|
|
|
/* XXX: TODO */
|
2008-12-12 01:42:14 +03:00
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_INVAL_INVAL);
|
2007-03-07 11:32:30 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/* mfrom */
|
2009-06-17 19:22:09 +04:00
|
|
|
static void gen_mfrom(DisasContext *ctx)
|
2007-03-07 11:32:30 +03:00
|
|
|
{
|
|
|
|
#if defined(CONFIG_USER_ONLY)
|
2016-06-22 00:48:51 +03:00
|
|
|
GEN_PRIV;
|
2007-03-07 11:32:30 +03:00
|
|
|
#else
|
2016-06-22 00:48:51 +03:00
|
|
|
CHK_SV;
|
2008-11-30 19:23:35 +03:00
|
|
|
gen_helper_602_mfrom(cpu_gpr[rD(ctx->opcode)], cpu_gpr[rA(ctx->opcode)]);
|
2016-06-22 00:48:51 +03:00
|
|
|
#endif /* defined(CONFIG_USER_ONLY) */
|
2007-03-07 11:32:30 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/* 602 - 603 - G2 TLB management */
|
2009-06-17 19:22:14 +04:00
|
|
|
|
2009-06-17 19:22:19 +04:00
|
|
|
/* tlbld */
|
2009-06-17 19:22:14 +04:00
|
|
|
static void gen_tlbld_6xx(DisasContext *ctx)
|
2007-03-07 11:32:30 +03:00
|
|
|
{
|
|
|
|
#if defined(CONFIG_USER_ONLY)
|
2016-06-22 00:48:51 +03:00
|
|
|
GEN_PRIV;
|
2007-03-07 11:32:30 +03:00
|
|
|
#else
|
2016-06-22 00:48:51 +03:00
|
|
|
CHK_SV;
|
2012-05-30 08:23:31 +04:00
|
|
|
gen_helper_6xx_tlbd(cpu_env, cpu_gpr[rB(ctx->opcode)]);
|
2016-06-22 00:48:51 +03:00
|
|
|
#endif /* defined(CONFIG_USER_ONLY) */
|
2007-03-07 11:32:30 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/* tlbli */
|
2009-06-17 19:22:14 +04:00
|
|
|
static void gen_tlbli_6xx(DisasContext *ctx)
|
2007-03-07 11:32:30 +03:00
|
|
|
{
|
|
|
|
#if defined(CONFIG_USER_ONLY)
|
2016-06-22 00:48:51 +03:00
|
|
|
GEN_PRIV;
|
2007-03-07 11:32:30 +03:00
|
|
|
#else
|
2016-06-22 00:48:51 +03:00
|
|
|
CHK_SV;
|
2012-05-30 08:23:31 +04:00
|
|
|
gen_helper_6xx_tlbi(cpu_env, cpu_gpr[rB(ctx->opcode)]);
|
2016-06-22 00:48:51 +03:00
|
|
|
#endif /* defined(CONFIG_USER_ONLY) */
|
2007-03-07 11:32:30 +03:00
|
|
|
}
|
|
|
|
|
2007-10-01 09:16:57 +04:00
|
|
|
/* 74xx TLB management */
|
2009-06-17 19:22:14 +04:00
|
|
|
|
2009-06-17 19:22:19 +04:00
|
|
|
/* tlbld */
|
2009-06-17 19:22:14 +04:00
|
|
|
static void gen_tlbld_74xx(DisasContext *ctx)
|
2007-10-01 09:16:57 +04:00
|
|
|
{
|
|
|
|
#if defined(CONFIG_USER_ONLY)
|
2016-06-22 00:48:51 +03:00
|
|
|
GEN_PRIV;
|
2007-10-01 09:16:57 +04:00
|
|
|
#else
|
2016-06-22 00:48:51 +03:00
|
|
|
CHK_SV;
|
2012-05-30 08:23:31 +04:00
|
|
|
gen_helper_74xx_tlbd(cpu_env, cpu_gpr[rB(ctx->opcode)]);
|
2016-06-22 00:48:51 +03:00
|
|
|
#endif /* defined(CONFIG_USER_ONLY) */
|
2007-10-01 09:16:57 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* tlbli */
|
2009-06-17 19:22:14 +04:00
|
|
|
static void gen_tlbli_74xx(DisasContext *ctx)
|
2007-10-01 09:16:57 +04:00
|
|
|
{
|
|
|
|
#if defined(CONFIG_USER_ONLY)
|
2016-06-22 00:48:51 +03:00
|
|
|
GEN_PRIV;
|
2007-10-01 09:16:57 +04:00
|
|
|
#else
|
2016-06-22 00:48:51 +03:00
|
|
|
CHK_SV;
|
2012-05-30 08:23:31 +04:00
|
|
|
gen_helper_74xx_tlbi(cpu_env, cpu_gpr[rB(ctx->opcode)]);
|
2016-06-22 00:48:51 +03:00
|
|
|
#endif /* defined(CONFIG_USER_ONLY) */
|
2007-10-01 09:16:57 +04:00
|
|
|
}
|
|
|
|
|
2007-03-07 11:32:30 +03:00
|
|
|
/* POWER instructions not in PowerPC 601 */
|
2009-06-17 19:22:09 +04:00
|
|
|
|
2009-06-17 19:22:19 +04:00
|
|
|
/* clf */
|
2009-06-17 19:22:09 +04:00
|
|
|
static void gen_clf(DisasContext *ctx)
|
2007-03-07 11:32:30 +03:00
|
|
|
{
|
|
|
|
/* Cache line flush: implemented as no-op */
|
|
|
|
}
|
|
|
|
|
|
|
|
/* cli */
|
2009-06-17 19:22:09 +04:00
|
|
|
static void gen_cli(DisasContext *ctx)
|
2007-03-07 11:32:30 +03:00
|
|
|
{
|
|
|
|
#if defined(CONFIG_USER_ONLY)
|
2016-06-22 00:48:51 +03:00
|
|
|
GEN_PRIV;
|
2007-03-07 11:32:30 +03:00
|
|
|
#else
|
2016-06-22 00:48:51 +03:00
|
|
|
/* Cache line invalidate: privileged and treated as no-op */
|
|
|
|
CHK_SV;
|
|
|
|
#endif /* defined(CONFIG_USER_ONLY) */
|
2007-03-07 11:32:30 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/* dclst */
|
2009-06-17 19:22:09 +04:00
|
|
|
static void gen_dclst(DisasContext *ctx)
|
2007-03-07 11:32:30 +03:00
|
|
|
{
|
|
|
|
/* Data cache line store: treated as no-op */
|
|
|
|
}
|
|
|
|
|
2009-06-17 19:22:09 +04:00
|
|
|
static void gen_mfsri(DisasContext *ctx)
|
2007-03-07 11:32:30 +03:00
|
|
|
{
|
|
|
|
#if defined(CONFIG_USER_ONLY)
|
2016-06-22 00:48:51 +03:00
|
|
|
GEN_PRIV;
|
2007-03-07 11:32:30 +03:00
|
|
|
#else
|
2008-12-07 00:46:17 +03:00
|
|
|
int ra = rA(ctx->opcode);
|
|
|
|
int rd = rD(ctx->opcode);
|
|
|
|
TCGv t0;
|
2016-06-22 00:48:51 +03:00
|
|
|
|
|
|
|
CHK_SV;
|
2008-12-07 00:46:17 +03:00
|
|
|
t0 = tcg_temp_new();
|
2008-12-08 21:11:21 +03:00
|
|
|
gen_addr_reg_index(ctx, t0);
|
2008-12-07 00:46:17 +03:00
|
|
|
tcg_gen_shri_tl(t0, t0, 28);
|
|
|
|
tcg_gen_andi_tl(t0, t0, 0xF);
|
2012-05-30 08:23:31 +04:00
|
|
|
gen_helper_load_sr(cpu_gpr[rd], cpu_env, t0);
|
2008-12-07 00:46:17 +03:00
|
|
|
tcg_temp_free(t0);
|
2007-03-07 11:32:30 +03:00
|
|
|
if (ra != 0 && ra != rd)
|
2008-12-07 00:46:17 +03:00
|
|
|
tcg_gen_mov_tl(cpu_gpr[ra], cpu_gpr[rd]);
|
2016-06-22 00:48:51 +03:00
|
|
|
#endif /* defined(CONFIG_USER_ONLY) */
|
2007-03-07 11:32:30 +03:00
|
|
|
}
|
|
|
|
|
2009-06-17 19:22:09 +04:00
|
|
|
static void gen_rac(DisasContext *ctx)
|
2007-03-07 11:32:30 +03:00
|
|
|
{
|
|
|
|
#if defined(CONFIG_USER_ONLY)
|
2016-06-22 00:48:51 +03:00
|
|
|
GEN_PRIV;
|
2007-03-07 11:32:30 +03:00
|
|
|
#else
|
2008-12-06 15:19:14 +03:00
|
|
|
TCGv t0;
|
2016-06-22 00:48:51 +03:00
|
|
|
|
|
|
|
CHK_SV;
|
2008-12-06 15:19:14 +03:00
|
|
|
t0 = tcg_temp_new();
|
2008-12-08 21:11:21 +03:00
|
|
|
gen_addr_reg_index(ctx, t0);
|
2012-05-30 08:23:31 +04:00
|
|
|
gen_helper_rac(cpu_gpr[rD(ctx->opcode)], cpu_env, t0);
|
2008-12-06 15:19:14 +03:00
|
|
|
tcg_temp_free(t0);
|
2016-06-22 00:48:51 +03:00
|
|
|
#endif /* defined(CONFIG_USER_ONLY) */
|
2007-03-07 11:32:30 +03:00
|
|
|
}
|
|
|
|
|
2009-06-17 19:22:09 +04:00
|
|
|
static void gen_rfsvc(DisasContext *ctx)
|
2007-03-07 11:32:30 +03:00
|
|
|
{
|
|
|
|
#if defined(CONFIG_USER_ONLY)
|
2016-06-22 00:48:51 +03:00
|
|
|
GEN_PRIV;
|
2007-03-07 11:32:30 +03:00
|
|
|
#else
|
2016-06-22 00:48:51 +03:00
|
|
|
CHK_SV;
|
|
|
|
|
2012-05-30 08:23:23 +04:00
|
|
|
gen_helper_rfsvc(cpu_env);
|
2008-12-12 01:42:14 +03:00
|
|
|
gen_sync_exception(ctx);
|
2016-06-22 00:48:51 +03:00
|
|
|
#endif /* defined(CONFIG_USER_ONLY) */
|
2007-03-07 11:32:30 +03:00
|
|
|
}
|
|
|
|
|
2016-07-27 09:56:20 +03:00
|
|
|
/* svc is not implemented for now */
|
2007-03-07 11:32:30 +03:00
|
|
|
|
|
|
|
/* BookE specific instructions */
|
2009-06-17 19:22:09 +04:00
|
|
|
|
2009-06-17 19:22:19 +04:00
|
|
|
/* XXX: not implemented on 440 ? */
|
2009-06-17 19:22:09 +04:00
|
|
|
static void gen_mfapidi(DisasContext *ctx)
|
2007-03-07 11:32:30 +03:00
|
|
|
{
|
|
|
|
/* XXX: TODO */
|
2008-12-12 01:42:14 +03:00
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_INVAL_INVAL);
|
2007-03-07 11:32:30 +03:00
|
|
|
}
|
|
|
|
|
2007-09-21 09:50:37 +04:00
|
|
|
/* XXX: not implemented on 440 ? */
|
2009-06-17 19:22:09 +04:00
|
|
|
static void gen_tlbiva(DisasContext *ctx)
|
2007-03-07 11:32:30 +03:00
|
|
|
{
|
|
|
|
#if defined(CONFIG_USER_ONLY)
|
2016-06-22 00:48:51 +03:00
|
|
|
GEN_PRIV;
|
2007-03-07 11:32:30 +03:00
|
|
|
#else
|
2008-12-07 00:46:17 +03:00
|
|
|
TCGv t0;
|
2016-06-22 00:48:51 +03:00
|
|
|
|
|
|
|
CHK_SV;
|
2008-12-07 18:45:15 +03:00
|
|
|
t0 = tcg_temp_new();
|
2008-12-08 21:11:21 +03:00
|
|
|
gen_addr_reg_index(ctx, t0);
|
2016-01-28 02:31:04 +03:00
|
|
|
gen_helper_tlbiva(cpu_env, cpu_gpr[rB(ctx->opcode)]);
|
2008-12-07 00:46:17 +03:00
|
|
|
tcg_temp_free(t0);
|
2016-06-22 00:48:51 +03:00
|
|
|
#endif /* defined(CONFIG_USER_ONLY) */
|
2007-03-07 11:32:30 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/* All 405 MAC instructions are translated here */
|
2009-08-16 13:06:54 +04: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 11:32:30 +03:00
|
|
|
{
|
2008-11-01 03:54:23 +03:00
|
|
|
TCGv t0, t1;
|
|
|
|
|
2008-11-17 17:43:54 +03:00
|
|
|
t0 = tcg_temp_local_new();
|
|
|
|
t1 = tcg_temp_local_new();
|
2008-11-01 03:54:23 +03:00
|
|
|
|
2007-03-07 11:32:30 +03: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 03:54:23 +03: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 11:32:30 +03:00
|
|
|
break;
|
|
|
|
case 0x04:
|
|
|
|
/* macchwu - macchwu. - macchwuo - macchwuo. */
|
|
|
|
/* macchwsu - macchwsu. - macchwsuo - macchwsuo. */
|
|
|
|
/* mulchwu - mulchwu. */
|
2008-11-01 03:54:23 +03: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 11:32:30 +03: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 03:54:23 +03: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 11:32:30 +03:00
|
|
|
break;
|
|
|
|
case 0x00:
|
|
|
|
/* machhwu - machhwu. - machhwuo - machhwuo. */
|
|
|
|
/* machhwsu - machhwsu. - machhwsuo - machhwsuo. */
|
|
|
|
/* mulhhwu - mulhhwu. */
|
2008-11-01 03:54:23 +03: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 11:32:30 +03: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 03:54:23 +03:00
|
|
|
tcg_gen_ext16s_tl(t0, cpu_gpr[ra]);
|
|
|
|
tcg_gen_ext16s_tl(t1, cpu_gpr[rb]);
|
2007-03-07 11:32:30 +03:00
|
|
|
break;
|
|
|
|
case 0x0C:
|
|
|
|
/* maclhwu - maclhwu. - maclhwuo - maclhwuo. */
|
|
|
|
/* maclhwsu - maclhwsu. - maclhwsuo - maclhwsuo. */
|
|
|
|
/* mullhwu - mullhwu. */
|
2008-11-01 03:54:23 +03:00
|
|
|
tcg_gen_ext16u_tl(t0, cpu_gpr[ra]);
|
|
|
|
tcg_gen_ext16u_tl(t1, cpu_gpr[rb]);
|
2007-03-07 11:32:30 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (opc2 & 0x04) {
|
2008-11-01 03:54:23 +03: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 23:51:55 +03:00
|
|
|
TCGLabel *l1 = gen_new_label();
|
2008-11-01 03:54:23 +03:00
|
|
|
|
|
|
|
if (opc3 & 0x10) {
|
|
|
|
/* Start with XER OV disabled, the most likely case */
|
2013-02-20 11:52:13 +04:00
|
|
|
tcg_gen_movi_tl(cpu_ov, 0);
|
2008-11-01 03:54:23 +03: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 20:27:03 +03:00
|
|
|
if (opc3 & 0x02) {
|
2008-11-01 03:54:23 +03: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 20:27:03 +03:00
|
|
|
if (opc3 & 0x02) {
|
2008-11-01 03:54:23 +03:00
|
|
|
/* Saturate */
|
|
|
|
tcg_gen_movi_tl(t0, UINT32_MAX);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (opc3 & 0x10) {
|
|
|
|
/* Check overflow */
|
2013-02-20 11:52:13 +04:00
|
|
|
tcg_gen_movi_tl(cpu_ov, 1);
|
|
|
|
tcg_gen_movi_tl(cpu_so, 1);
|
2008-11-01 03:54:23 +03: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 11:32:30 +03:00
|
|
|
}
|
2008-11-01 03:54:23 +03:00
|
|
|
tcg_temp_free(t0);
|
|
|
|
tcg_temp_free(t1);
|
2007-03-07 11:32:30 +03:00
|
|
|
if (unlikely(Rc) != 0) {
|
|
|
|
/* Update Rc0 */
|
2008-11-01 03:54:23 +03:00
|
|
|
gen_set_Rc0(ctx, cpu_gpr[rt]);
|
2007-03-07 11:32:30 +03: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 03:54:22 +04:00
|
|
|
#define GEN_MAC_HANDLER(name, opc2, opc3) \
|
2009-06-17 19:22:09 +04:00
|
|
|
static void glue(gen_, name)(DisasContext *ctx) \
|
2007-03-07 11:32:30 +03: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 03:54:22 +04:00
|
|
|
GEN_MAC_HANDLER(macchw, 0x0C, 0x05);
|
2007-03-07 11:32:30 +03: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 03:54:22 +04:00
|
|
|
GEN_MAC_HANDLER(macchwo, 0x0C, 0x15);
|
2007-03-07 11:32:30 +03: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 03:54:22 +04:00
|
|
|
GEN_MAC_HANDLER(macchws, 0x0C, 0x07);
|
2007-03-07 11:32:30 +03: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 03:54:22 +04:00
|
|
|
GEN_MAC_HANDLER(macchwso, 0x0C, 0x17);
|
2007-03-07 11:32:30 +03: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 03:54:22 +04:00
|
|
|
GEN_MAC_HANDLER(macchwsu, 0x0C, 0x06);
|
2007-03-07 11:32:30 +03: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 03:54:22 +04:00
|
|
|
GEN_MAC_HANDLER(macchwsuo, 0x0C, 0x16);
|
2007-03-07 11:32:30 +03: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 03:54:22 +04:00
|
|
|
GEN_MAC_HANDLER(macchwu, 0x0C, 0x04);
|
2007-03-07 11:32:30 +03: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 03:54:22 +04:00
|
|
|
GEN_MAC_HANDLER(macchwuo, 0x0C, 0x14);
|
2007-03-07 11:32:30 +03: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 03:54:22 +04:00
|
|
|
GEN_MAC_HANDLER(machhw, 0x0C, 0x01);
|
2007-03-07 11:32:30 +03: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 03:54:22 +04:00
|
|
|
GEN_MAC_HANDLER(machhwo, 0x0C, 0x11);
|
2007-03-07 11:32:30 +03: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 03:54:22 +04:00
|
|
|
GEN_MAC_HANDLER(machhws, 0x0C, 0x03);
|
2007-03-07 11:32:30 +03: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 03:54:22 +04:00
|
|
|
GEN_MAC_HANDLER(machhwso, 0x0C, 0x13);
|
2007-03-07 11:32:30 +03: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 03:54:22 +04:00
|
|
|
GEN_MAC_HANDLER(machhwsu, 0x0C, 0x02);
|
2007-03-07 11:32:30 +03: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 03:54:22 +04:00
|
|
|
GEN_MAC_HANDLER(machhwsuo, 0x0C, 0x12);
|
2007-03-07 11:32:30 +03: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 03:54:22 +04:00
|
|
|
GEN_MAC_HANDLER(machhwu, 0x0C, 0x00);
|
2007-03-07 11:32:30 +03: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 03:54:22 +04:00
|
|
|
GEN_MAC_HANDLER(machhwuo, 0x0C, 0x10);
|
2007-03-07 11:32:30 +03: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 03:54:22 +04:00
|
|
|
GEN_MAC_HANDLER(maclhw, 0x0C, 0x0D);
|
2007-03-07 11:32:30 +03: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 03:54:22 +04:00
|
|
|
GEN_MAC_HANDLER(maclhwo, 0x0C, 0x1D);
|
2007-03-07 11:32:30 +03: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 03:54:22 +04:00
|
|
|
GEN_MAC_HANDLER(maclhws, 0x0C, 0x0F);
|
2007-03-07 11:32:30 +03: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 03:54:22 +04:00
|
|
|
GEN_MAC_HANDLER(maclhwso, 0x0C, 0x1F);
|
2007-03-07 11:32:30 +03: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 03:54:22 +04:00
|
|
|
GEN_MAC_HANDLER(maclhwu, 0x0C, 0x0C);
|
2007-03-07 11:32:30 +03: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 03:54:22 +04:00
|
|
|
GEN_MAC_HANDLER(maclhwuo, 0x0C, 0x1C);
|
2007-03-07 11:32:30 +03: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 03:54:22 +04:00
|
|
|
GEN_MAC_HANDLER(maclhwsu, 0x0C, 0x0E);
|
2007-03-07 11:32:30 +03: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 03:54:22 +04:00
|
|
|
GEN_MAC_HANDLER(maclhwsuo, 0x0C, 0x1E);
|
2007-03-07 11:32:30 +03: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 03:54:22 +04:00
|
|
|
GEN_MAC_HANDLER(nmacchw, 0x0E, 0x05);
|
2007-03-07 11:32:30 +03: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 03:54:22 +04:00
|
|
|
GEN_MAC_HANDLER(nmacchwo, 0x0E, 0x15);
|
2007-03-07 11:32:30 +03: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 03:54:22 +04:00
|
|
|
GEN_MAC_HANDLER(nmacchws, 0x0E, 0x07);
|
2007-03-07 11:32:30 +03: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 03:54:22 +04:00
|
|
|
GEN_MAC_HANDLER(nmacchwso, 0x0E, 0x17);
|
2007-03-07 11:32:30 +03: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 03:54:22 +04:00
|
|
|
GEN_MAC_HANDLER(nmachhw, 0x0E, 0x01);
|
2007-03-07 11:32:30 +03: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 03:54:22 +04:00
|
|
|
GEN_MAC_HANDLER(nmachhwo, 0x0E, 0x11);
|
2007-03-07 11:32:30 +03: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 03:54:22 +04:00
|
|
|
GEN_MAC_HANDLER(nmachhws, 0x0E, 0x03);
|
2007-03-07 11:32:30 +03: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 03:54:22 +04:00
|
|
|
GEN_MAC_HANDLER(nmachhwso, 0x0E, 0x13);
|
2007-03-07 11:32:30 +03: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 03:54:22 +04:00
|
|
|
GEN_MAC_HANDLER(nmaclhw, 0x0E, 0x0D);
|
2007-03-07 11:32:30 +03: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 03:54:22 +04:00
|
|
|
GEN_MAC_HANDLER(nmaclhwo, 0x0E, 0x1D);
|
2007-03-07 11:32:30 +03: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 03:54:22 +04:00
|
|
|
GEN_MAC_HANDLER(nmaclhws, 0x0E, 0x0F);
|
2007-03-07 11:32:30 +03: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 03:54:22 +04:00
|
|
|
GEN_MAC_HANDLER(nmaclhwso, 0x0E, 0x1F);
|
2007-03-07 11:32:30 +03: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 03:54:22 +04:00
|
|
|
GEN_MAC_HANDLER(mulchw, 0x08, 0x05);
|
2007-03-07 11:32:30 +03: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 03:54:22 +04:00
|
|
|
GEN_MAC_HANDLER(mulchwu, 0x08, 0x04);
|
2007-03-07 11:32:30 +03: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 03:54:22 +04:00
|
|
|
GEN_MAC_HANDLER(mulhhw, 0x08, 0x01);
|
2007-03-07 11:32:30 +03: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 03:54:22 +04:00
|
|
|
GEN_MAC_HANDLER(mulhhwu, 0x08, 0x00);
|
2007-03-07 11:32:30 +03: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 03:54:22 +04:00
|
|
|
GEN_MAC_HANDLER(mullhw, 0x08, 0x0D);
|
2007-03-07 11:32:30 +03: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 03:54:22 +04:00
|
|
|
GEN_MAC_HANDLER(mullhwu, 0x08, 0x0C);
|
2007-03-07 11:32:30 +03:00
|
|
|
|
|
|
|
/* mfdcr */
|
2009-06-17 19:22:09 +04:00
|
|
|
static void gen_mfdcr(DisasContext *ctx)
|
2007-03-07 11:32:30 +03:00
|
|
|
{
|
|
|
|
#if defined(CONFIG_USER_ONLY)
|
2016-06-22 00:48:51 +03:00
|
|
|
GEN_PRIV;
|
2007-03-07 11:32:30 +03:00
|
|
|
#else
|
2008-12-06 19:37:18 +03:00
|
|
|
TCGv dcrn;
|
2016-06-22 00:48:51 +03:00
|
|
|
|
|
|
|
CHK_SV;
|
2008-12-06 19:37:18 +03:00
|
|
|
dcrn = tcg_const_tl(SPR(ctx->opcode));
|
2012-05-30 08:23:36 +04:00
|
|
|
gen_helper_load_dcr(cpu_gpr[rD(ctx->opcode)], cpu_env, dcrn);
|
2008-12-06 19:37:18 +03:00
|
|
|
tcg_temp_free(dcrn);
|
2016-06-22 00:48:51 +03:00
|
|
|
#endif /* defined(CONFIG_USER_ONLY) */
|
2007-03-07 11:32:30 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/* mtdcr */
|
2009-06-17 19:22:09 +04:00
|
|
|
static void gen_mtdcr(DisasContext *ctx)
|
2007-03-07 11:32:30 +03:00
|
|
|
{
|
|
|
|
#if defined(CONFIG_USER_ONLY)
|
2016-06-22 00:48:51 +03:00
|
|
|
GEN_PRIV;
|
2007-03-07 11:32:30 +03:00
|
|
|
#else
|
2008-12-06 19:37:18 +03:00
|
|
|
TCGv dcrn;
|
2016-06-22 00:48:51 +03:00
|
|
|
|
|
|
|
CHK_SV;
|
2008-12-06 19:37:18 +03:00
|
|
|
dcrn = tcg_const_tl(SPR(ctx->opcode));
|
2012-05-30 08:23:36 +04:00
|
|
|
gen_helper_store_dcr(cpu_env, dcrn, cpu_gpr[rS(ctx->opcode)]);
|
2008-12-06 19:37:18 +03:00
|
|
|
tcg_temp_free(dcrn);
|
2016-06-22 00:48:51 +03:00
|
|
|
#endif /* defined(CONFIG_USER_ONLY) */
|
2007-03-30 14:22:46 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* mfdcrx */
|
2007-09-21 09:50:37 +04:00
|
|
|
/* XXX: not implemented on 440 ? */
|
2009-06-17 19:22:09 +04:00
|
|
|
static void gen_mfdcrx(DisasContext *ctx)
|
2007-03-30 14:22:46 +04:00
|
|
|
{
|
|
|
|
#if defined(CONFIG_USER_ONLY)
|
2016-06-22 00:48:51 +03:00
|
|
|
GEN_PRIV;
|
2007-03-30 14:22:46 +04:00
|
|
|
#else
|
2016-06-22 00:48:51 +03:00
|
|
|
CHK_SV;
|
2012-05-30 08:23:36 +04: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 03:54:22 +04:00
|
|
|
/* Note: Rc update flag set leads to undefined state of Rc0 */
|
2016-06-22 00:48:51 +03:00
|
|
|
#endif /* defined(CONFIG_USER_ONLY) */
|
2007-03-30 14:22:46 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* mtdcrx */
|
2007-09-21 09:50:37 +04:00
|
|
|
/* XXX: not implemented on 440 ? */
|
2009-06-17 19:22:09 +04:00
|
|
|
static void gen_mtdcrx(DisasContext *ctx)
|
2007-03-30 14:22:46 +04:00
|
|
|
{
|
|
|
|
#if defined(CONFIG_USER_ONLY)
|
2016-06-22 00:48:51 +03:00
|
|
|
GEN_PRIV;
|
2007-03-30 14:22:46 +04:00
|
|
|
#else
|
2016-06-22 00:48:51 +03:00
|
|
|
CHK_SV;
|
2012-05-30 08:23:36 +04: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 03:54:22 +04:00
|
|
|
/* Note: Rc update flag set leads to undefined state of Rc0 */
|
2016-06-22 00:48:51 +03:00
|
|
|
#endif /* defined(CONFIG_USER_ONLY) */
|
2007-03-07 11:32:30 +03: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 03:54:22 +04:00
|
|
|
/* mfdcrux (PPC 460) : user-mode access to DCR */
|
2009-06-17 19:22:09 +04: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 03:54:22 +04:00
|
|
|
{
|
2012-05-30 08:23:36 +04: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 03:54:22 +04:00
|
|
|
/* Note: Rc update flag set leads to undefined state of Rc0 */
|
|
|
|
}
|
|
|
|
|
|
|
|
/* mtdcrux (PPC 460) : user-mode access to DCR */
|
2009-06-17 19:22:09 +04: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 03:54:22 +04:00
|
|
|
{
|
2012-06-24 08:04:17 +04:00
|
|
|
gen_helper_store_dcr(cpu_env, cpu_gpr[rA(ctx->opcode)],
|
2012-05-30 08:23:36 +04: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 03:54:22 +04:00
|
|
|
/* Note: Rc update flag set leads to undefined state of Rc0 */
|
|
|
|
}
|
|
|
|
|
2007-03-07 11:32:30 +03:00
|
|
|
/* dccci */
|
2009-06-17 19:22:09 +04:00
|
|
|
static void gen_dccci(DisasContext *ctx)
|
2007-03-07 11:32:30 +03:00
|
|
|
{
|
2016-06-22 00:48:51 +03:00
|
|
|
CHK_SV;
|
2007-03-07 11:32:30 +03:00
|
|
|
/* interpreted as no-op */
|
|
|
|
}
|
|
|
|
|
|
|
|
/* dcread */
|
2009-06-17 19:22:09 +04:00
|
|
|
static void gen_dcread(DisasContext *ctx)
|
2007-03-07 11:32:30 +03:00
|
|
|
{
|
|
|
|
#if defined(CONFIG_USER_ONLY)
|
2016-06-22 00:48:51 +03:00
|
|
|
GEN_PRIV;
|
2007-03-07 11:32:30 +03:00
|
|
|
#else
|
2008-10-15 21:00:37 +04:00
|
|
|
TCGv EA, val;
|
2016-06-22 00:48:51 +03:00
|
|
|
|
|
|
|
CHK_SV;
|
2008-12-08 21:11:21 +03:00
|
|
|
gen_set_access_type(ctx, ACCESS_CACHE);
|
2008-11-17 17:43:54 +03:00
|
|
|
EA = tcg_temp_new();
|
2008-12-08 21:11:21 +03:00
|
|
|
gen_addr_reg_index(ctx, EA);
|
2008-11-17 17:43:54 +03:00
|
|
|
val = tcg_temp_new();
|
2008-12-08 21:11:21 +03:00
|
|
|
gen_qemu_ld32u(ctx, val, EA);
|
2008-10-15 21:00:37 +04:00
|
|
|
tcg_temp_free(val);
|
|
|
|
tcg_gen_mov_tl(cpu_gpr[rD(ctx->opcode)], EA);
|
|
|
|
tcg_temp_free(EA);
|
2016-06-22 00:48:51 +03:00
|
|
|
#endif /* defined(CONFIG_USER_ONLY) */
|
2007-03-07 11:32:30 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/* icbt */
|
2009-06-17 19:22:14 +04:00
|
|
|
static void gen_icbt_40x(DisasContext *ctx)
|
2007-03-07 11:32:30 +03: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 19:22:09 +04:00
|
|
|
static void gen_iccci(DisasContext *ctx)
|
2007-03-07 11:32:30 +03:00
|
|
|
{
|
2016-06-22 00:48:51 +03:00
|
|
|
CHK_SV;
|
2007-03-07 11:32:30 +03:00
|
|
|
/* interpreted as no-op */
|
|
|
|
}
|
|
|
|
|
|
|
|
/* icread */
|
2009-06-17 19:22:09 +04:00
|
|
|
static void gen_icread(DisasContext *ctx)
|
2007-03-07 11:32:30 +03:00
|
|
|
{
|
2016-06-22 00:48:51 +03:00
|
|
|
CHK_SV;
|
2007-03-07 11:32:30 +03:00
|
|
|
/* interpreted as no-op */
|
|
|
|
}
|
|
|
|
|
2014-09-15 19:03:28 +04:00
|
|
|
/* rfci (supervisor only) */
|
2009-06-17 19:22:14 +04:00
|
|
|
static void gen_rfci_40x(DisasContext *ctx)
|
2007-03-30 14:22:46 +04:00
|
|
|
{
|
|
|
|
#if defined(CONFIG_USER_ONLY)
|
2016-06-22 00:48:51 +03:00
|
|
|
GEN_PRIV;
|
2007-03-30 14:22:46 +04:00
|
|
|
#else
|
2016-06-22 00:48:51 +03:00
|
|
|
CHK_SV;
|
2007-03-30 14:22:46 +04:00
|
|
|
/* Restore CPU state */
|
2012-05-30 08:23:23 +04:00
|
|
|
gen_helper_40x_rfci(cpu_env);
|
2008-12-12 01:42:14 +03:00
|
|
|
gen_sync_exception(ctx);
|
2016-06-22 00:48:51 +03:00
|
|
|
#endif /* defined(CONFIG_USER_ONLY) */
|
2007-03-30 14:22:46 +04:00
|
|
|
}
|
|
|
|
|
2009-06-17 19:22:09 +04:00
|
|
|
static void gen_rfci(DisasContext *ctx)
|
2007-03-30 14:22:46 +04:00
|
|
|
{
|
|
|
|
#if defined(CONFIG_USER_ONLY)
|
2016-06-22 00:48:51 +03:00
|
|
|
GEN_PRIV;
|
2007-03-30 14:22:46 +04:00
|
|
|
#else
|
2016-06-22 00:48:51 +03:00
|
|
|
CHK_SV;
|
2007-03-30 14:22:46 +04:00
|
|
|
/* Restore CPU state */
|
2012-05-30 08:23:23 +04:00
|
|
|
gen_helper_rfci(cpu_env);
|
2008-12-12 01:42:14 +03:00
|
|
|
gen_sync_exception(ctx);
|
2016-06-22 00:48:51 +03:00
|
|
|
#endif /* defined(CONFIG_USER_ONLY) */
|
2007-03-30 14:22:46 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* BookE specific */
|
2009-06-17 19:22:09 +04:00
|
|
|
|
2009-06-17 19:22:19 +04:00
|
|
|
/* XXX: not implemented on 440 ? */
|
2009-06-17 19:22:09 +04:00
|
|
|
static void gen_rfdi(DisasContext *ctx)
|
2007-03-07 11:32:30 +03:00
|
|
|
{
|
|
|
|
#if defined(CONFIG_USER_ONLY)
|
2016-06-22 00:48:51 +03:00
|
|
|
GEN_PRIV;
|
2007-03-07 11:32:30 +03:00
|
|
|
#else
|
2016-06-22 00:48:51 +03:00
|
|
|
CHK_SV;
|
2007-03-07 11:32:30 +03:00
|
|
|
/* Restore CPU state */
|
2012-05-30 08:23:23 +04:00
|
|
|
gen_helper_rfdi(cpu_env);
|
2008-12-12 01:42:14 +03:00
|
|
|
gen_sync_exception(ctx);
|
2016-06-22 00:48:51 +03:00
|
|
|
#endif /* defined(CONFIG_USER_ONLY) */
|
2007-03-07 11:32:30 +03:00
|
|
|
}
|
|
|
|
|
2007-09-21 09:50:37 +04:00
|
|
|
/* XXX: not implemented on 440 ? */
|
2009-06-17 19:22:09 +04:00
|
|
|
static void gen_rfmci(DisasContext *ctx)
|
2007-03-30 14:22:46 +04:00
|
|
|
{
|
|
|
|
#if defined(CONFIG_USER_ONLY)
|
2016-06-22 00:48:51 +03:00
|
|
|
GEN_PRIV;
|
2007-03-30 14:22:46 +04:00
|
|
|
#else
|
2016-06-22 00:48:51 +03:00
|
|
|
CHK_SV;
|
2007-03-30 14:22:46 +04:00
|
|
|
/* Restore CPU state */
|
2012-05-30 08:23:23 +04:00
|
|
|
gen_helper_rfmci(cpu_env);
|
2008-12-12 01:42:14 +03:00
|
|
|
gen_sync_exception(ctx);
|
2016-06-22 00:48:51 +03:00
|
|
|
#endif /* defined(CONFIG_USER_ONLY) */
|
2007-03-30 14:22:46 +04:00
|
|
|
}
|
2007-09-19 09:44:04 +04:00
|
|
|
|
2007-03-17 17:02:15 +03:00
|
|
|
/* TLB management - PowerPC 405 implementation */
|
2009-06-17 19:22:14 +04:00
|
|
|
|
2009-06-17 19:22:19 +04:00
|
|
|
/* tlbre */
|
2009-06-17 19:22:14 +04:00
|
|
|
static void gen_tlbre_40x(DisasContext *ctx)
|
2007-03-07 11:32:30 +03:00
|
|
|
{
|
|
|
|
#if defined(CONFIG_USER_ONLY)
|
2016-06-22 00:48:51 +03:00
|
|
|
GEN_PRIV;
|
2007-03-07 11:32:30 +03:00
|
|
|
#else
|
2016-06-22 00:48:51 +03:00
|
|
|
CHK_SV;
|
2007-03-07 11:32:30 +03:00
|
|
|
switch (rB(ctx->opcode)) {
|
|
|
|
case 0:
|
2012-05-30 08:23:31 +04:00
|
|
|
gen_helper_4xx_tlbre_hi(cpu_gpr[rD(ctx->opcode)], cpu_env,
|
|
|
|
cpu_gpr[rA(ctx->opcode)]);
|
2007-03-07 11:32:30 +03:00
|
|
|
break;
|
|
|
|
case 1:
|
2012-05-30 08:23:31 +04:00
|
|
|
gen_helper_4xx_tlbre_lo(cpu_gpr[rD(ctx->opcode)], cpu_env,
|
|
|
|
cpu_gpr[rA(ctx->opcode)]);
|
2007-03-07 11:32:30 +03:00
|
|
|
break;
|
|
|
|
default:
|
2008-12-12 01:42:14 +03:00
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_INVAL_INVAL);
|
2007-03-07 11:32:30 +03:00
|
|
|
break;
|
2004-01-05 01:58:38 +03:00
|
|
|
}
|
2016-06-22 00:48:51 +03:00
|
|
|
#endif /* defined(CONFIG_USER_ONLY) */
|
2007-03-07 11:32:30 +03:00
|
|
|
}
|
|
|
|
|
2007-03-17 17:02:15 +03:00
|
|
|
/* tlbsx - tlbsx. */
|
2009-06-17 19:22:14 +04:00
|
|
|
static void gen_tlbsx_40x(DisasContext *ctx)
|
2007-03-07 11:32:30 +03:00
|
|
|
{
|
|
|
|
#if defined(CONFIG_USER_ONLY)
|
2016-06-22 00:48:51 +03:00
|
|
|
GEN_PRIV;
|
2007-03-07 11:32:30 +03:00
|
|
|
#else
|
2008-12-07 00:46:17 +03:00
|
|
|
TCGv t0;
|
2016-06-22 00:48:51 +03:00
|
|
|
|
|
|
|
CHK_SV;
|
2008-12-07 00:46:17 +03:00
|
|
|
t0 = tcg_temp_new();
|
2008-12-08 21:11:21 +03:00
|
|
|
gen_addr_reg_index(ctx, t0);
|
2012-05-30 08:23:31 +04:00
|
|
|
gen_helper_4xx_tlbsx(cpu_gpr[rD(ctx->opcode)], cpu_env, t0);
|
2008-12-07 00:46:17 +03:00
|
|
|
tcg_temp_free(t0);
|
|
|
|
if (Rc(ctx->opcode)) {
|
2015-02-13 23:51:55 +03:00
|
|
|
TCGLabel *l1 = gen_new_label();
|
2013-02-20 11:52:13 +04:00
|
|
|
tcg_gen_trunc_tl_i32(cpu_crf[0], cpu_so);
|
2008-12-07 00:46:17 +03: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);
|
|
|
|
}
|
2016-06-22 00:48:51 +03:00
|
|
|
#endif /* defined(CONFIG_USER_ONLY) */
|
2003-11-23 17:55:54 +03:00
|
|
|
}
|
|
|
|
|
2007-03-07 11:32:30 +03:00
|
|
|
/* tlbwe */
|
2009-06-17 19:22:14 +04:00
|
|
|
static void gen_tlbwe_40x(DisasContext *ctx)
|
2003-11-23 17:55:54 +03:00
|
|
|
{
|
2007-03-07 11:32:30 +03:00
|
|
|
#if defined(CONFIG_USER_ONLY)
|
2016-06-22 00:48:51 +03:00
|
|
|
GEN_PRIV;
|
2007-03-07 11:32:30 +03:00
|
|
|
#else
|
2016-06-22 00:48:51 +03:00
|
|
|
CHK_SV;
|
|
|
|
|
2007-03-07 11:32:30 +03:00
|
|
|
switch (rB(ctx->opcode)) {
|
|
|
|
case 0:
|
2012-05-30 08:23:31 +04:00
|
|
|
gen_helper_4xx_tlbwe_hi(cpu_env, cpu_gpr[rA(ctx->opcode)],
|
|
|
|
cpu_gpr[rS(ctx->opcode)]);
|
2007-03-07 11:32:30 +03:00
|
|
|
break;
|
|
|
|
case 1:
|
2012-05-30 08:23:31 +04:00
|
|
|
gen_helper_4xx_tlbwe_lo(cpu_env, cpu_gpr[rA(ctx->opcode)],
|
|
|
|
cpu_gpr[rS(ctx->opcode)]);
|
2007-03-07 11:32:30 +03:00
|
|
|
break;
|
|
|
|
default:
|
2008-12-12 01:42:14 +03:00
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_INVAL_INVAL);
|
2007-03-07 11:32:30 +03:00
|
|
|
break;
|
2004-01-05 01:58:38 +03:00
|
|
|
}
|
2016-06-22 00:48:51 +03:00
|
|
|
#endif /* defined(CONFIG_USER_ONLY) */
|
2007-03-07 11:32:30 +03:00
|
|
|
}
|
|
|
|
|
2007-09-21 09:28:33 +04:00
|
|
|
/* TLB management - PowerPC 440 implementation */
|
2009-06-17 19:22:14 +04:00
|
|
|
|
2009-06-17 19:22:19 +04:00
|
|
|
/* tlbre */
|
2009-06-17 19:22:14 +04:00
|
|
|
static void gen_tlbre_440(DisasContext *ctx)
|
2007-09-19 09:44:04 +04:00
|
|
|
{
|
|
|
|
#if defined(CONFIG_USER_ONLY)
|
2016-06-22 00:48:51 +03:00
|
|
|
GEN_PRIV;
|
2007-09-19 09:44:04 +04:00
|
|
|
#else
|
2016-06-22 00:48:51 +03:00
|
|
|
CHK_SV;
|
|
|
|
|
2007-09-19 09:44:04 +04:00
|
|
|
switch (rB(ctx->opcode)) {
|
|
|
|
case 0:
|
|
|
|
case 1:
|
|
|
|
case 2:
|
2008-12-07 00:46:17 +03:00
|
|
|
{
|
|
|
|
TCGv_i32 t0 = tcg_const_i32(rB(ctx->opcode));
|
2012-05-30 08:23:31 +04:00
|
|
|
gen_helper_440_tlbre(cpu_gpr[rD(ctx->opcode)], cpu_env,
|
|
|
|
t0, cpu_gpr[rA(ctx->opcode)]);
|
2008-12-07 00:46:17 +03:00
|
|
|
tcg_temp_free_i32(t0);
|
|
|
|
}
|
2007-09-19 09:44:04 +04:00
|
|
|
break;
|
|
|
|
default:
|
2008-12-12 01:42:14 +03:00
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_INVAL_INVAL);
|
2007-09-19 09:44:04 +04:00
|
|
|
break;
|
|
|
|
}
|
2016-06-22 00:48:51 +03:00
|
|
|
#endif /* defined(CONFIG_USER_ONLY) */
|
2007-09-19 09:44:04 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* tlbsx - tlbsx. */
|
2009-06-17 19:22:14 +04:00
|
|
|
static void gen_tlbsx_440(DisasContext *ctx)
|
2007-09-19 09:44:04 +04:00
|
|
|
{
|
|
|
|
#if defined(CONFIG_USER_ONLY)
|
2016-06-22 00:48:51 +03:00
|
|
|
GEN_PRIV;
|
2007-09-19 09:44:04 +04:00
|
|
|
#else
|
2008-12-07 00:46:17 +03:00
|
|
|
TCGv t0;
|
2016-06-22 00:48:51 +03:00
|
|
|
|
|
|
|
CHK_SV;
|
2008-12-07 00:46:17 +03:00
|
|
|
t0 = tcg_temp_new();
|
2008-12-08 21:11:21 +03:00
|
|
|
gen_addr_reg_index(ctx, t0);
|
2012-05-30 08:23:31 +04:00
|
|
|
gen_helper_440_tlbsx(cpu_gpr[rD(ctx->opcode)], cpu_env, t0);
|
2008-12-07 00:46:17 +03:00
|
|
|
tcg_temp_free(t0);
|
|
|
|
if (Rc(ctx->opcode)) {
|
2015-02-13 23:51:55 +03:00
|
|
|
TCGLabel *l1 = gen_new_label();
|
2013-02-20 11:52:13 +04:00
|
|
|
tcg_gen_trunc_tl_i32(cpu_crf[0], cpu_so);
|
2008-12-07 00:46:17 +03: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);
|
|
|
|
}
|
2016-06-22 00:48:51 +03:00
|
|
|
#endif /* defined(CONFIG_USER_ONLY) */
|
2007-09-19 09:44:04 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* tlbwe */
|
2009-06-17 19:22:14 +04:00
|
|
|
static void gen_tlbwe_440(DisasContext *ctx)
|
2007-09-19 09:44:04 +04:00
|
|
|
{
|
|
|
|
#if defined(CONFIG_USER_ONLY)
|
2016-06-22 00:48:51 +03:00
|
|
|
GEN_PRIV;
|
2007-09-19 09:44:04 +04:00
|
|
|
#else
|
2016-06-22 00:48:51 +03:00
|
|
|
CHK_SV;
|
2007-09-19 09:44:04 +04:00
|
|
|
switch (rB(ctx->opcode)) {
|
|
|
|
case 0:
|
|
|
|
case 1:
|
|
|
|
case 2:
|
2008-12-07 00:46:17 +03:00
|
|
|
{
|
|
|
|
TCGv_i32 t0 = tcg_const_i32(rB(ctx->opcode));
|
2012-05-30 08:23:31 +04:00
|
|
|
gen_helper_440_tlbwe(cpu_env, t0, cpu_gpr[rA(ctx->opcode)],
|
|
|
|
cpu_gpr[rS(ctx->opcode)]);
|
2008-12-07 00:46:17 +03:00
|
|
|
tcg_temp_free_i32(t0);
|
|
|
|
}
|
2007-09-19 09:44:04 +04:00
|
|
|
break;
|
|
|
|
default:
|
2008-12-12 01:42:14 +03:00
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_INVAL_INVAL);
|
2007-09-19 09:44:04 +04:00
|
|
|
break;
|
|
|
|
}
|
2016-06-22 00:48:51 +03:00
|
|
|
#endif /* defined(CONFIG_USER_ONLY) */
|
2007-09-19 09:44:04 +04:00
|
|
|
}
|
|
|
|
|
2011-05-01 01:34:58 +04:00
|
|
|
/* TLB management - PowerPC BookE 2.06 implementation */
|
|
|
|
|
|
|
|
/* tlbre */
|
|
|
|
static void gen_tlbre_booke206(DisasContext *ctx)
|
|
|
|
{
|
2016-06-22 00:48:51 +03:00
|
|
|
#if defined(CONFIG_USER_ONLY)
|
|
|
|
GEN_PRIV;
|
2011-05-01 01:34:58 +04:00
|
|
|
#else
|
2016-06-22 00:48:51 +03:00
|
|
|
CHK_SV;
|
2012-05-30 08:23:31 +04:00
|
|
|
gen_helper_booke206_tlbre(cpu_env);
|
2016-06-22 00:48:51 +03:00
|
|
|
#endif /* defined(CONFIG_USER_ONLY) */
|
2011-05-01 01:34:58 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* tlbsx - tlbsx. */
|
|
|
|
static void gen_tlbsx_booke206(DisasContext *ctx)
|
|
|
|
{
|
|
|
|
#if defined(CONFIG_USER_ONLY)
|
2016-06-22 00:48:51 +03:00
|
|
|
GEN_PRIV;
|
2011-05-01 01:34:58 +04:00
|
|
|
#else
|
|
|
|
TCGv t0;
|
|
|
|
|
2016-06-22 00:48:51 +03:00
|
|
|
CHK_SV;
|
2011-05-01 01:34:58 +04:00
|
|
|
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 08:23:31 +04:00
|
|
|
gen_helper_booke206_tlbsx(cpu_env, t0);
|
2014-01-19 20:26:33 +04:00
|
|
|
tcg_temp_free(t0);
|
2016-06-22 00:48:51 +03:00
|
|
|
#endif /* defined(CONFIG_USER_ONLY) */
|
2011-05-01 01:34:58 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* tlbwe */
|
|
|
|
static void gen_tlbwe_booke206(DisasContext *ctx)
|
|
|
|
{
|
|
|
|
#if defined(CONFIG_USER_ONLY)
|
2016-06-22 00:48:51 +03:00
|
|
|
GEN_PRIV;
|
2011-05-01 01:34:58 +04:00
|
|
|
#else
|
2016-06-22 00:48:51 +03:00
|
|
|
CHK_SV;
|
2012-05-30 08:23:31 +04:00
|
|
|
gen_helper_booke206_tlbwe(cpu_env);
|
2016-06-22 00:48:51 +03:00
|
|
|
#endif /* defined(CONFIG_USER_ONLY) */
|
2011-05-01 01:34:58 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void gen_tlbivax_booke206(DisasContext *ctx)
|
|
|
|
{
|
|
|
|
#if defined(CONFIG_USER_ONLY)
|
2016-06-22 00:48:51 +03:00
|
|
|
GEN_PRIV;
|
2011-05-01 01:34:58 +04:00
|
|
|
#else
|
|
|
|
TCGv t0;
|
|
|
|
|
2016-06-22 00:48:51 +03:00
|
|
|
CHK_SV;
|
2011-05-01 01:34:58 +04:00
|
|
|
t0 = tcg_temp_new();
|
|
|
|
gen_addr_reg_index(ctx, t0);
|
2012-05-30 08:23:31 +04:00
|
|
|
gen_helper_booke206_tlbivax(cpu_env, t0);
|
2014-01-19 20:26:33 +04:00
|
|
|
tcg_temp_free(t0);
|
2016-06-22 00:48:51 +03:00
|
|
|
#endif /* defined(CONFIG_USER_ONLY) */
|
2011-05-01 01:34:58 +04:00
|
|
|
}
|
|
|
|
|
2012-01-20 07:09:15 +04:00
|
|
|
static void gen_tlbilx_booke206(DisasContext *ctx)
|
|
|
|
{
|
|
|
|
#if defined(CONFIG_USER_ONLY)
|
2016-06-22 00:48:51 +03:00
|
|
|
GEN_PRIV;
|
2012-01-20 07:09:15 +04:00
|
|
|
#else
|
|
|
|
TCGv t0;
|
|
|
|
|
2016-06-22 00:48:51 +03:00
|
|
|
CHK_SV;
|
2012-01-20 07:09:15 +04:00
|
|
|
t0 = tcg_temp_new();
|
|
|
|
gen_addr_reg_index(ctx, t0);
|
|
|
|
|
|
|
|
switch((ctx->opcode >> 21) & 0x3) {
|
|
|
|
case 0:
|
2012-05-30 08:23:31 +04:00
|
|
|
gen_helper_booke206_tlbilx0(cpu_env, t0);
|
2012-01-20 07:09:15 +04:00
|
|
|
break;
|
|
|
|
case 1:
|
2012-05-30 08:23:31 +04:00
|
|
|
gen_helper_booke206_tlbilx1(cpu_env, t0);
|
2012-01-20 07:09:15 +04:00
|
|
|
break;
|
|
|
|
case 3:
|
2012-05-30 08:23:31 +04:00
|
|
|
gen_helper_booke206_tlbilx3(cpu_env, t0);
|
2012-01-20 07:09:15 +04:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_INVAL_INVAL);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
tcg_temp_free(t0);
|
2016-06-22 00:48:51 +03:00
|
|
|
#endif /* defined(CONFIG_USER_ONLY) */
|
2012-01-20 07:09:15 +04:00
|
|
|
}
|
|
|
|
|
2011-05-01 01:34:58 +04:00
|
|
|
|
2007-03-07 11:32:30 +03:00
|
|
|
/* wrtee */
|
2009-06-17 19:22:09 +04:00
|
|
|
static void gen_wrtee(DisasContext *ctx)
|
2007-03-07 11:32:30 +03:00
|
|
|
{
|
|
|
|
#if defined(CONFIG_USER_ONLY)
|
2016-06-22 00:48:51 +03:00
|
|
|
GEN_PRIV;
|
2007-03-07 11:32:30 +03:00
|
|
|
#else
|
2008-12-06 16:03:35 +03:00
|
|
|
TCGv t0;
|
2016-06-22 00:48:51 +03:00
|
|
|
|
|
|
|
CHK_SV;
|
2008-12-06 16:03:35 +03: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 19:02:38 +04:00
|
|
|
/* Stop translation to have a chance to raise an exception
|
|
|
|
* if we just set msr_ee to 1
|
|
|
|
*/
|
2008-12-12 01:42:14 +03:00
|
|
|
gen_stop_exception(ctx);
|
2016-06-22 00:48:51 +03:00
|
|
|
#endif /* defined(CONFIG_USER_ONLY) */
|
2007-03-07 11:32:30 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/* wrteei */
|
2009-06-17 19:22:09 +04:00
|
|
|
static void gen_wrteei(DisasContext *ctx)
|
2007-03-07 11:32:30 +03:00
|
|
|
{
|
|
|
|
#if defined(CONFIG_USER_ONLY)
|
2016-06-22 00:48:51 +03:00
|
|
|
GEN_PRIV;
|
2007-03-07 11:32:30 +03:00
|
|
|
#else
|
2016-06-22 00:48:51 +03:00
|
|
|
CHK_SV;
|
2009-07-03 14:56:57 +04:00
|
|
|
if (ctx->opcode & 0x00008000) {
|
2008-12-06 16:03:35 +03:00
|
|
|
tcg_gen_ori_tl(cpu_msr, cpu_msr, (1 << MSR_EE));
|
|
|
|
/* Stop translation to have a chance to raise an exception */
|
2008-12-12 01:42:14 +03:00
|
|
|
gen_stop_exception(ctx);
|
2008-12-06 16:03:35 +03:00
|
|
|
} else {
|
2009-01-14 22:40:54 +03:00
|
|
|
tcg_gen_andi_tl(cpu_msr, cpu_msr, ~(1 << MSR_EE));
|
2008-12-06 16:03:35 +03:00
|
|
|
}
|
2016-06-22 00:48:51 +03:00
|
|
|
#endif /* defined(CONFIG_USER_ONLY) */
|
2007-03-07 11:32:30 +03:00
|
|
|
}
|
|
|
|
|
2007-04-16 11:18:42 +04:00
|
|
|
/* PowerPC 440 specific instructions */
|
2009-06-17 19:22:09 +04:00
|
|
|
|
2009-06-17 19:22:19 +04:00
|
|
|
/* dlmzb */
|
2009-06-17 19:22:09 +04:00
|
|
|
static void gen_dlmzb(DisasContext *ctx)
|
2007-03-07 11:32:30 +03:00
|
|
|
{
|
2008-11-30 20:26:29 +03:00
|
|
|
TCGv_i32 t0 = tcg_const_i32(Rc(ctx->opcode));
|
2012-05-30 08:23:29 +04: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 20:26:29 +03:00
|
|
|
tcg_temp_free_i32(t0);
|
2007-03-07 11:32:30 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/* mbar replaces eieio on 440 */
|
2009-06-17 19:22:09 +04:00
|
|
|
static void gen_mbar(DisasContext *ctx)
|
2007-03-07 11:32:30 +03:00
|
|
|
{
|
|
|
|
/* interpreted as no-op */
|
|
|
|
}
|
|
|
|
|
|
|
|
/* msync replaces sync on 440 */
|
2012-01-21 06:48:58 +04:00
|
|
|
static void gen_msync_4xx(DisasContext *ctx)
|
2007-03-07 11:32:30 +03:00
|
|
|
{
|
|
|
|
/* interpreted as no-op */
|
|
|
|
}
|
|
|
|
|
|
|
|
/* icbt */
|
2009-06-17 19:22:14 +04:00
|
|
|
static void gen_icbt_440(DisasContext *ctx)
|
2007-03-07 11:32:30 +03: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 17:55:54 +03:00
|
|
|
}
|
|
|
|
|
2012-01-31 06:18:35 +04:00
|
|
|
/* Embedded.Processor Control */
|
|
|
|
|
|
|
|
static void gen_msgclr(DisasContext *ctx)
|
|
|
|
{
|
|
|
|
#if defined(CONFIG_USER_ONLY)
|
2016-06-22 00:48:51 +03:00
|
|
|
GEN_PRIV;
|
2012-01-31 06:18:35 +04:00
|
|
|
#else
|
2016-06-22 00:48:51 +03:00
|
|
|
CHK_SV;
|
2012-05-30 08:23:23 +04:00
|
|
|
gen_helper_msgclr(cpu_env, cpu_gpr[rB(ctx->opcode)]);
|
2016-06-22 00:48:51 +03:00
|
|
|
#endif /* defined(CONFIG_USER_ONLY) */
|
2012-01-31 06:18:35 +04:00
|
|
|
}
|
|
|
|
|
2012-01-31 06:19:23 +04:00
|
|
|
static void gen_msgsnd(DisasContext *ctx)
|
|
|
|
{
|
|
|
|
#if defined(CONFIG_USER_ONLY)
|
2016-06-22 00:48:51 +03:00
|
|
|
GEN_PRIV;
|
2012-01-31 06:19:23 +04:00
|
|
|
#else
|
2016-06-22 00:48:51 +03:00
|
|
|
CHK_SV;
|
2012-01-31 06:19:23 +04:00
|
|
|
gen_helper_msgsnd(cpu_gpr[rB(ctx->opcode)]);
|
2016-06-22 00:48:51 +03:00
|
|
|
#endif /* defined(CONFIG_USER_ONLY) */
|
2012-01-31 06:19:23 +04:00
|
|
|
}
|
|
|
|
|
2009-01-05 01:11:39 +03:00
|
|
|
|
2016-07-26 14:58:36 +03:00
|
|
|
#if defined(TARGET_PPC64)
|
|
|
|
static void gen_maddld(DisasContext *ctx)
|
|
|
|
{
|
|
|
|
TCGv_i64 t1 = tcg_temp_new_i64();
|
|
|
|
|
|
|
|
tcg_gen_mul_i64(t1, cpu_gpr[rA(ctx->opcode)], cpu_gpr[rB(ctx->opcode)]);
|
|
|
|
tcg_gen_add_i64(cpu_gpr[rD(ctx->opcode)], t1, cpu_gpr[rC(ctx->opcode)]);
|
|
|
|
tcg_temp_free_i64(t1);
|
|
|
|
}
|
2016-07-26 14:58:37 +03:00
|
|
|
|
|
|
|
/* maddhd maddhdu */
|
|
|
|
static void gen_maddhd_maddhdu(DisasContext *ctx)
|
|
|
|
{
|
|
|
|
TCGv_i64 lo = tcg_temp_new_i64();
|
|
|
|
TCGv_i64 hi = tcg_temp_new_i64();
|
|
|
|
TCGv_i64 t1 = tcg_temp_new_i64();
|
|
|
|
|
|
|
|
if (Rc(ctx->opcode)) {
|
|
|
|
tcg_gen_mulu2_i64(lo, hi, cpu_gpr[rA(ctx->opcode)],
|
|
|
|
cpu_gpr[rB(ctx->opcode)]);
|
|
|
|
tcg_gen_movi_i64(t1, 0);
|
|
|
|
} else {
|
|
|
|
tcg_gen_muls2_i64(lo, hi, cpu_gpr[rA(ctx->opcode)],
|
|
|
|
cpu_gpr[rB(ctx->opcode)]);
|
|
|
|
tcg_gen_sari_i64(t1, cpu_gpr[rC(ctx->opcode)], 63);
|
|
|
|
}
|
|
|
|
tcg_gen_add2_i64(t1, cpu_gpr[rD(ctx->opcode)], lo, hi,
|
|
|
|
cpu_gpr[rC(ctx->opcode)], t1);
|
|
|
|
tcg_temp_free_i64(lo);
|
|
|
|
tcg_temp_free_i64(hi);
|
|
|
|
tcg_temp_free_i64(t1);
|
|
|
|
}
|
2016-07-26 14:58:36 +03:00
|
|
|
#endif /* defined(TARGET_PPC64) */
|
|
|
|
|
2014-12-18 19:34:34 +03: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 19:34:35 +03: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 19:34:36 +03: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 19:34:37 +03:00
|
|
|
#if defined(CONFIG_USER_ONLY)
|
|
|
|
#define GEN_TM_PRIV_NOOP(name) \
|
|
|
|
static inline void gen_##name(DisasContext *ctx) \
|
|
|
|
{ \
|
2016-06-22 00:48:51 +03:00
|
|
|
gen_priv_exception(ctx, POWERPC_EXCP_PRIV_OPC); \
|
2014-12-18 19:34:37 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
#define GEN_TM_PRIV_NOOP(name) \
|
|
|
|
static inline void gen_##name(DisasContext *ctx) \
|
|
|
|
{ \
|
2016-06-22 00:48:51 +03:00
|
|
|
CHK_SV; \
|
2014-12-18 19:34:37 +03:00
|
|
|
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);
|
|
|
|
|
2016-08-01 13:17:42 +03:00
|
|
|
#include "translate/fp-impl.inc.c"
|
|
|
|
|
|
|
|
#include "translate/vmx-impl.inc.c"
|
|
|
|
|
|
|
|
#include "translate/vsx-impl.inc.c"
|
|
|
|
|
|
|
|
#include "translate/dfp-impl.inc.c"
|
|
|
|
|
|
|
|
#include "translate/spe-impl.inc.c"
|
|
|
|
|
2009-10-02 01:12:16 +04:00
|
|
|
static opcode_t opcodes[] = {
|
2009-06-17 19:22:31 +04: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),
|
2016-07-26 14:58:34 +03:00
|
|
|
#if defined(TARGET_PPC64)
|
|
|
|
GEN_HANDLER_E(cmpeqb, 0x1F, 0x00, 0x07, 0x00600000, PPC_NONE, PPC2_ISA300),
|
|
|
|
#endif
|
2013-04-20 12:56:16 +04:00
|
|
|
GEN_HANDLER_E(cmpb, 0x1F, 0x1C, 0x0F, 0x00000001, PPC_NONE, PPC2_ISA205),
|
2016-07-26 14:58:27 +03:00
|
|
|
GEN_HANDLER_E(cmprb, 0x1F, 0x00, 0x06, 0x00400001, PPC_NONE, PPC2_ISA300),
|
2009-06-17 19:22:31 +04: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),
|
2016-07-26 14:58:26 +03:00
|
|
|
GEN_HANDLER_E(addpcis, 0x13, 0x2, 0xFF, 0x00000000, PPC_NONE, PPC2_ISA300),
|
2009-06-17 19:22:31 +04:00
|
|
|
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),
|
2016-07-26 14:58:33 +03:00
|
|
|
GEN_HANDLER_E(cnttzw, 0x1F, 0x1A, 0x10, 0x00000000, PPC_NONE, PPC2_ISA300),
|
2009-06-17 19:22:31 +04:00
|
|
|
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 21:14:42 +04:00
|
|
|
GEN_HANDLER(popcntb, 0x1F, 0x1A, 0x03, 0x0000F801, PPC_POPCNTB),
|
2011-04-01 08:15:13 +04:00
|
|
|
GEN_HANDLER(popcntw, 0x1F, 0x1A, 0x0b, 0x0000F801, PPC_POPCNTWD),
|
2013-04-20 12:56:17 +04:00
|
|
|
GEN_HANDLER_E(prtyw, 0x1F, 0x1A, 0x04, 0x0000F801, PPC_NONE, PPC2_ISA205),
|
2009-06-17 19:22:31 +04:00
|
|
|
#if defined(TARGET_PPC64)
|
2011-04-01 08:15:13 +04:00
|
|
|
GEN_HANDLER(popcntd, 0x1F, 0x1A, 0x0F, 0x0000F801, PPC_POPCNTWD),
|
2009-06-17 19:22:31 +04:00
|
|
|
GEN_HANDLER(cntlzd, 0x1F, 0x1A, 0x01, 0x00000000, PPC_64B),
|
2016-07-26 14:58:32 +03:00
|
|
|
GEN_HANDLER_E(cnttzd, 0x1F, 0x1A, 0x11, 0x00000000, PPC_NONE, PPC2_ISA300),
|
2013-04-20 12:56:17 +04:00
|
|
|
GEN_HANDLER_E(prtyd, 0x1F, 0x1A, 0x05, 0x0000F801, PPC_NONE, PPC2_ISA205),
|
2014-01-07 20:05:49 +04:00
|
|
|
GEN_HANDLER_E(bpermd, 0x1F, 0x1C, 0x07, 0x00000001, PPC_NONE, PPC2_PERM_ISA206),
|
2009-06-17 19:22:31 +04: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),
|
2016-07-28 21:14:18 +03:00
|
|
|
GEN_HANDLER2_E(extswsli0, "extswsli", 0x1F, 0x1A, 0x1B, 0x00000000,
|
|
|
|
PPC_NONE, PPC2_ISA300),
|
|
|
|
GEN_HANDLER2_E(extswsli1, "extswsli", 0x1F, 0x1B, 0x1B, 0x00000000,
|
|
|
|
PPC_NONE, PPC2_ISA300),
|
2009-06-17 19:22:31 +04:00
|
|
|
#endif
|
|
|
|
#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 20:05:56 +04: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 19:08:33 +04:00
|
|
|
GEN_HANDLER(lwarx, 0x1F, 0x14, 0x00, 0x00000000, PPC_RES),
|
2014-01-07 20:05:57 +04: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 19:22:31 +04:00
|
|
|
GEN_HANDLER2(stwcx_, "stwcx.", 0x1F, 0x16, 0x04, 0x00000000, PPC_RES),
|
|
|
|
#if defined(TARGET_PPC64)
|
2010-09-10 19:08:33 +04:00
|
|
|
GEN_HANDLER(ldarx, 0x1F, 0x14, 0x02, 0x00000000, PPC_64B),
|
2014-02-10 21:27:00 +04:00
|
|
|
GEN_HANDLER_E(lqarx, 0x1F, 0x14, 0x08, 0, PPC_NONE, PPC2_LSQ_ISA207),
|
2009-06-17 19:22:31 +04:00
|
|
|
GEN_HANDLER2(stdcx_, "stdcx.", 0x1F, 0x16, 0x06, 0x00000000, PPC_64B),
|
2014-02-10 21:27:01 +04:00
|
|
|
GEN_HANDLER_E(stqcx_, 0x1F, 0x16, 0x05, 0, PPC_NONE, PPC2_LSQ_ISA207),
|
2009-06-17 19:22:31 +04: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 21:26:55 +04:00
|
|
|
GEN_HANDLER_E(bctar, 0x13, 0x10, 0x11, 0, PPC_NONE, PPC2_BCTAR_ISA207),
|
2009-06-17 19:22:31 +04: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),
|
2016-06-22 00:48:55 +03:00
|
|
|
GEN_HANDLER_E(doze, 0x13, 0x12, 0x0c, 0x03FFF801, PPC_NONE, PPC2_PM_ISA206),
|
|
|
|
GEN_HANDLER_E(nap, 0x13, 0x12, 0x0d, 0x03FFF801, PPC_NONE, PPC2_PM_ISA206),
|
|
|
|
GEN_HANDLER_E(sleep, 0x13, 0x12, 0x0e, 0x03FFF801, PPC_NONE, PPC2_PM_ISA206),
|
|
|
|
GEN_HANDLER_E(rvwinkle, 0x13, 0x12, 0x0f, 0x03FFF801, PPC_NONE, PPC2_PM_ISA206),
|
2009-06-17 19:22:31 +04:00
|
|
|
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),
|
2016-07-26 14:58:35 +03:00
|
|
|
GEN_HANDLER_E(setb, 0x1F, 0x00, 0x04, 0x0003F801, PPC_NONE, PPC2_ISA300),
|
2009-06-17 19:22:31 +04:00
|
|
|
#endif
|
2016-06-07 05:50:25 +03:00
|
|
|
GEN_HANDLER(mtmsr, 0x1F, 0x12, 0x04, 0x001EF801, PPC_MISC),
|
2015-11-12 01:49:39 +03:00
|
|
|
GEN_HANDLER(mtspr, 0x1F, 0x13, 0x0E, 0x00000000, PPC_MISC),
|
2009-06-17 19:22:31 +04: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 17:20:35 +04:00
|
|
|
GEN_HANDLER(dcbt, 0x1F, 0x16, 0x08, 0x00000001, PPC_CACHE),
|
|
|
|
GEN_HANDLER(dcbtst, 0x1F, 0x16, 0x07, 0x00000001, PPC_CACHE),
|
2014-01-19 20:50:09 +04:00
|
|
|
GEN_HANDLER_E(dcbtls, 0x1F, 0x06, 0x05, 0x02000001, PPC_BOOKE, PPC2_BOOKE206),
|
2013-01-29 16:36:02 +04:00
|
|
|
GEN_HANDLER(dcbz, 0x1F, 0x16, 0x1F, 0x03C00001, PPC_CACHE_DCBZ),
|
2009-06-17 19:22:31 +04: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 08:15:11 +04: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),
|
2016-06-07 05:50:27 +03:00
|
|
|
GEN_HANDLER2(slbfee_, "slbfee.", 0x1F, 0x13, 0x1E, 0x001F0000, PPC_SEGMENT_64B),
|
2009-06-17 19:22:31 +04:00
|
|
|
#endif
|
|
|
|
GEN_HANDLER(tlbia, 0x1F, 0x12, 0x0B, 0x03FFFC01, PPC_MEM_TLBIA),
|
2016-05-03 19:03:31 +03:00
|
|
|
/* XXX Those instructions will need to be handled differently for
|
|
|
|
* different ISA versions */
|
|
|
|
GEN_HANDLER(tlbiel, 0x1F, 0x12, 0x08, 0x001F0001, PPC_MEM_TLBIE),
|
|
|
|
GEN_HANDLER(tlbie, 0x1F, 0x12, 0x09, 0x001F0001, PPC_MEM_TLBIE),
|
2009-06-17 19:22:31 +04:00
|
|
|
GEN_HANDLER(tlbsync, 0x1F, 0x16, 0x11, 0x03FFF801, PPC_MEM_TLBSYNC),
|
|
|
|
#if defined(TARGET_PPC64)
|
2016-06-07 05:50:26 +03:00
|
|
|
GEN_HANDLER(slbia, 0x1F, 0x12, 0x0F, 0x031FFC01, PPC_SLBI),
|
2009-06-17 19:22:31 +04:00
|
|
|
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-05-01 01:34:58 +04:00
|
|
|
GEN_HANDLER_E(rfci, 0x13, 0x13, 0x01, 0x03FF8001, PPC_BOOKE, PPC2_BOOKE206),
|
2009-06-17 19:22:31 +04: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-05-01 01:34:58 +04: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 07:09:15 +04:00
|
|
|
GEN_HANDLER2_E(tlbilx_booke206, "tlbilx", 0x1F, 0x12, 0x00, 0x03800001,
|
|
|
|
PPC_NONE, PPC2_BOOKE206),
|
2012-01-31 06:19:23 +04:00
|
|
|
GEN_HANDLER2_E(msgsnd, "msgsnd", 0x1F, 0x0E, 0x06, 0x03ff0001,
|
|
|
|
PPC_NONE, PPC2_PRCNTL),
|
2012-01-31 06:18:35 +04:00
|
|
|
GEN_HANDLER2_E(msgclr, "msgclr", 0x1F, 0x0E, 0x07, 0x03ff0001,
|
|
|
|
PPC_NONE, PPC2_PRCNTL),
|
2009-06-17 19:22:31 +04:00
|
|
|
GEN_HANDLER(wrtee, 0x1F, 0x03, 0x04, 0x000FFC01, PPC_WRTEE),
|
2009-07-03 14:56:57 +04:00
|
|
|
GEN_HANDLER(wrteei, 0x1F, 0x03, 0x05, 0x000E7C01, PPC_WRTEE),
|
2009-06-17 19:22:31 +04:00
|
|
|
GEN_HANDLER(dlmzb, 0x1F, 0x0E, 0x02, 0x00000000, PPC_440_SPEC),
|
2011-05-01 01:34:58 +04:00
|
|
|
GEN_HANDLER_E(mbar, 0x1F, 0x16, 0x1a, 0x001FF801,
|
|
|
|
PPC_BOOKE, PPC2_BOOKE206),
|
2012-01-21 06:48:58 +04:00
|
|
|
GEN_HANDLER(msync_4xx, 0x1F, 0x16, 0x12, 0x03FFF801, PPC_BOOKE),
|
2011-05-01 01:34:58 +04:00
|
|
|
GEN_HANDLER2_E(icbt_440, "icbt", 0x1F, 0x16, 0x00, 0x03E00001,
|
|
|
|
PPC_BOOKE, PPC2_BOOKE206),
|
2009-06-17 19:22:31 +04: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),
|
2016-07-26 14:58:36 +03:00
|
|
|
#if defined(TARGET_PPC64)
|
2016-07-26 14:58:37 +03:00
|
|
|
GEN_HANDLER_E(maddhd_maddhdu, 0x04, 0x18, 0xFF, 0x00000000, PPC_NONE,
|
|
|
|
PPC2_ISA300),
|
2016-07-26 14:58:36 +03:00
|
|
|
GEN_HANDLER_E(maddld, 0x04, 0x19, 0xFF, 0x00000000, PPC_NONE, PPC2_ISA300),
|
|
|
|
#endif
|
2009-06-17 19:22:31 +04:00
|
|
|
|
|
|
|
#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 20:05:54 +04: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 20:05:53 +04: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),
|
2016-07-26 14:58:28 +03:00
|
|
|
GEN_HANDLER_E(modsw, 0x1F, 0x0B, 0x18, 0x00000001, PPC_NONE, PPC2_ISA300),
|
|
|
|
GEN_HANDLER_E(moduw, 0x1F, 0x0B, 0x08, 0x00000001, PPC_NONE, PPC2_ISA300),
|
2009-06-17 19:22:31 +04: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 20:05:51 +04: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 20:05:52 +04: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),
|
2016-07-26 14:58:29 +03:00
|
|
|
GEN_HANDLER_E(modsd, 0x1F, 0x09, 0x18, 0x00000001, PPC_NONE, PPC2_ISA300),
|
|
|
|
GEN_HANDLER_E(modud, 0x1F, 0x09, 0x08, 0x00000001, PPC_NONE, PPC2_ISA300),
|
2014-01-07 20:05:51 +04:00
|
|
|
|
2009-06-17 19:22:31 +04: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_LD
|
|
|
|
#undef GEN_LDU
|
|
|
|
#undef GEN_LDUX
|
2012-02-27 21:18:08 +04:00
|
|
|
#undef GEN_LDX_E
|
2009-06-17 19:22:31 +04: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),
|
2016-06-22 00:48:52 +03:00
|
|
|
#define GEN_LDX_E(name, ldop, opc2, opc3, type, type2, chk) \
|
2012-02-27 21:18:08 +04:00
|
|
|
GEN_HANDLER_E(name##x, 0x1F, opc2, opc3, 0x00000001, type, type2),
|
2009-06-17 19:22:31 +04: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)
|
2016-06-22 00:48:52 +03:00
|
|
|
GEN_LDX_E(ldbr, ld64ur, 0x14, 0x10, PPC_NONE, PPC2_DBRX, CHK_NONE)
|
|
|
|
|
|
|
|
/* HV/P7 and later only */
|
|
|
|
GEN_LDX_HVRM(ldcix, ld64, 0x15, 0x1b, PPC_CILDST)
|
|
|
|
GEN_LDX_HVRM(lwzcix, ld32u, 0x15, 0x18, PPC_CILDST)
|
|
|
|
GEN_LDX_HVRM(lhzcix, ld16u, 0x15, 0x19, PPC_CILDST)
|
|
|
|
GEN_LDX_HVRM(lbzcix, ld8u, 0x15, 0x1a, PPC_CILDST)
|
2009-06-17 19:22:31 +04: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 21:18:08 +04:00
|
|
|
#undef GEN_STX_E
|
2009-06-17 19:22:31 +04: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),
|
2016-06-22 00:48:52 +03:00
|
|
|
#define GEN_STX_E(name, stop, opc2, opc3, type, type2, chk) \
|
2012-02-27 21:18:08 +04:00
|
|
|
GEN_HANDLER_E(name##x, 0x1F, opc2, opc3, 0x00000001, type, type2),
|
2009-06-17 19:22:31 +04: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)
|
2016-06-22 00:48:52 +03:00
|
|
|
GEN_STX_E(stdbr, st64r, 0x14, 0x14, PPC_NONE, PPC2_DBRX, CHK_NONE)
|
|
|
|
GEN_STX_HVRM(stdcix, st64, 0x15, 0x1f, PPC_CILDST)
|
|
|
|
GEN_STX_HVRM(stwcix, st32, 0x15, 0x1c, PPC_CILDST)
|
|
|
|
GEN_STX_HVRM(sthcix, st16, 0x15, 0x1d, PPC_CILDST)
|
|
|
|
GEN_STX_HVRM(stbcix, st8, 0x15, 0x1e, PPC_CILDST)
|
2009-06-17 19:22:31 +04:00
|
|
|
#endif
|
|
|
|
GEN_STX(sthbr, st16r, 0x16, 0x1C, PPC_INTEGER)
|
|
|
|
GEN_STX(stwbr, st32r, 0x16, 0x14, PPC_INTEGER)
|
|
|
|
|
|
|
|
#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),
|
|
|
|
|
2014-12-18 19:34:34 +03:00
|
|
|
GEN_HANDLER2_E(tbegin, "tbegin", 0x1F, 0x0E, 0x14, 0x01DFF800, \
|
|
|
|
PPC_NONE, PPC2_TM),
|
2014-12-18 19:34:35 +03: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 19:34:36 +03:00
|
|
|
GEN_HANDLER2_E(tcheck, "tcheck", 0x1F, 0x0E, 0x16, 0x007FF800, \
|
|
|
|
PPC_NONE, PPC2_TM),
|
2014-12-18 19:34:37 +03: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),
|
2016-08-01 13:17:42 +03:00
|
|
|
|
|
|
|
#include "translate/fp-ops.inc.c"
|
|
|
|
|
|
|
|
#include "translate/vmx-ops.inc.c"
|
|
|
|
|
|
|
|
#include "translate/vsx-ops.inc.c"
|
|
|
|
|
|
|
|
#include "translate/dfp-ops.inc.c"
|
|
|
|
|
|
|
|
#include "translate/spe-ops.inc.c"
|
2009-06-17 19:22:31 +04:00
|
|
|
};
|
|
|
|
|
2007-10-26 01:35:50 +04:00
|
|
|
#include "helper_regs.h"
|
2012-04-06 17:35:34 +04:00
|
|
|
#include "translate_init.c"
|
2003-11-23 17:55:54 +03:00
|
|
|
|
2004-01-05 01:58:38 +03:00
|
|
|
/*****************************************************************************/
|
2005-07-03 00:59:34 +04:00
|
|
|
/* Misc PowerPC helpers */
|
2013-05-27 03:33:50 +04:00
|
|
|
void ppc_cpu_dump_state(CPUState *cs, FILE *f, fprintf_function cpu_fprintf,
|
|
|
|
int flags)
|
2003-11-23 17:55:54 +03:00
|
|
|
{
|
2005-07-03 00:59:34 +04:00
|
|
|
#define RGPL 4
|
|
|
|
#define RFPL 4
|
|
|
|
|
2013-05-27 03:33:50 +04:00
|
|
|
PowerPCCPU *cpu = POWERPC_CPU(cs);
|
|
|
|
CPUPPCState *env = &cpu->env;
|
2003-11-23 17:55:54 +03:00
|
|
|
int i;
|
|
|
|
|
2009-08-16 15:13:18 +04:00
|
|
|
cpu_fprintf(f, "NIP " TARGET_FMT_lx " LR " TARGET_FMT_lx " CTR "
|
2015-02-25 12:39:25 +03: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 15:13:18 +04:00
|
|
|
cpu_fprintf(f, "MSR " TARGET_FMT_lx " HID0 " TARGET_FMT_lx " HF "
|
2016-05-03 19:03:24 +03:00
|
|
|
TARGET_FMT_lx " iidx %d didx %d\n",
|
|
|
|
env->msr, env->spr[SPR_HID0],
|
|
|
|
env->hflags, env->immu_idx, env->dmmu_idx);
|
2007-03-17 17:02:15 +03:00
|
|
|
#if !defined(NO_TIMER_DUMP)
|
2010-10-23 01:03:33 +04:00
|
|
|
cpu_fprintf(f, "TB %08" PRIu32 " %08" PRIu64
|
2007-03-07 11:32:30 +03:00
|
|
|
#if !defined(CONFIG_USER_ONLY)
|
2010-10-23 01:03:33 +04:00
|
|
|
" DECR %08" PRIu32
|
2007-03-07 11:32:30 +03:00
|
|
|
#endif
|
|
|
|
"\n",
|
2007-11-04 04:57:29 +03:00
|
|
|
cpu_ppc_load_tbu(env), cpu_ppc_load_tbl(env)
|
2007-03-07 11:32:30 +03:00
|
|
|
#if !defined(CONFIG_USER_ONLY)
|
|
|
|
, cpu_ppc_load_decr(env)
|
|
|
|
#endif
|
|
|
|
);
|
2007-11-04 04:57:29 +03:00
|
|
|
#endif
|
2007-03-07 11:32:30 +03:00
|
|
|
for (i = 0; i < 32; i++) {
|
2005-07-03 00:59:34 +04:00
|
|
|
if ((i & (RGPL - 1)) == 0)
|
|
|
|
cpu_fprintf(f, "GPR%02d", i);
|
2009-08-16 15:54:37 +04:00
|
|
|
cpu_fprintf(f, " %016" PRIx64, ppc_dump_gpr(env, i));
|
2005-07-03 00:59:34 +04:00
|
|
|
if ((i & (RGPL - 1)) == (RGPL - 1))
|
2004-10-09 22:08:01 +04:00
|
|
|
cpu_fprintf(f, "\n");
|
2007-03-07 11:32:30 +03:00
|
|
|
}
|
2005-07-03 00:59:34 +04:00
|
|
|
cpu_fprintf(f, "CR ");
|
2007-03-07 11:32:30 +03:00
|
|
|
for (i = 0; i < 8; i++)
|
2004-10-09 22:08:01 +04:00
|
|
|
cpu_fprintf(f, "%01x", env->crf[i]);
|
|
|
|
cpu_fprintf(f, " [");
|
2007-03-07 11:32:30 +03: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 22:08:01 +04:00
|
|
|
cpu_fprintf(f, " %c%c", a, env->crf[i] & 0x01 ? 'O' : ' ');
|
2007-03-07 11:32:30 +03:00
|
|
|
}
|
2009-08-16 15:13:18 +04:00
|
|
|
cpu_fprintf(f, " ] RES " TARGET_FMT_lx "\n",
|
|
|
|
env->reserve_addr);
|
2005-07-03 00:59:34 +04:00
|
|
|
for (i = 0; i < 32; i++) {
|
|
|
|
if ((i & (RFPL - 1)) == 0)
|
|
|
|
cpu_fprintf(f, "FPR%02d", i);
|
2006-06-25 22:15:32 +04:00
|
|
|
cpu_fprintf(f, " %016" PRIx64, *((uint64_t *)&env->fpr[i]));
|
2005-07-03 00:59:34 +04:00
|
|
|
if ((i & (RFPL - 1)) == (RFPL - 1))
|
2004-10-09 22:08:01 +04:00
|
|
|
cpu_fprintf(f, "\n");
|
2003-11-23 17:55:54 +03:00
|
|
|
}
|
2012-10-29 21:24:59 +04:00
|
|
|
cpu_fprintf(f, "FPSCR " TARGET_FMT_lx "\n", env->fpscr);
|
2007-10-07 19:43:50 +04:00
|
|
|
#if !defined(CONFIG_USER_ONLY)
|
2011-04-30 02:10:23 +04: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]);
|
|
|
|
|
2016-06-27 09:55:21 +03:00
|
|
|
#if defined(TARGET_PPC64)
|
|
|
|
if (env->excp_model == POWERPC_EXCP_POWER7 ||
|
|
|
|
env->excp_model == POWERPC_EXCP_POWER8) {
|
|
|
|
cpu_fprintf(f, "HSRR0 " TARGET_FMT_lx " HSRR1 " TARGET_FMT_lx "\n",
|
|
|
|
env->spr[SPR_HSRR0], env->spr[SPR_HSRR1]);
|
|
|
|
}
|
|
|
|
#endif
|
2011-04-30 02:10:23 +04:00
|
|
|
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 19:45:10 +04: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 02:10:23 +04: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 10:30:58 +03:00
|
|
|
case POWERPC_MMU_2_03:
|
2013-12-24 05:17:24 +04:00
|
|
|
case POWERPC_MMU_2_06:
|
2016-02-09 02:28:43 +03:00
|
|
|
case POWERPC_MMU_2_06a:
|
2015-10-22 10:30:58 +03:00
|
|
|
case POWERPC_MMU_2_07:
|
2016-02-09 02:28:43 +03:00
|
|
|
case POWERPC_MMU_2_07a:
|
2011-04-30 02:10:23 +04:00
|
|
|
#endif
|
2013-12-24 05:17:24 +04: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 02:10:23 +04:00
|
|
|
break;
|
2011-05-01 01:34:58 +04:00
|
|
|
case POWERPC_MMU_BOOKE206:
|
2011-04-30 02:10:23 +04: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 19:43:50 +04:00
|
|
|
#endif
|
2003-11-23 17:55:54 +03:00
|
|
|
|
2005-07-03 00:59:34 +04:00
|
|
|
#undef RGPL
|
|
|
|
#undef RFPL
|
2003-11-23 17:55:54 +03:00
|
|
|
}
|
|
|
|
|
2013-05-27 03:33:50 +04:00
|
|
|
void ppc_cpu_dump_statistics(CPUState *cs, FILE*f,
|
|
|
|
fprintf_function cpu_fprintf, int flags)
|
2007-03-07 11:32:30 +03:00
|
|
|
{
|
|
|
|
#if defined(DO_PPC_STATISTICS)
|
2013-05-27 03:33:50 +04:00
|
|
|
PowerPCCPU *cpu = POWERPC_CPU(cs);
|
2009-10-02 01:12:16 +04:00
|
|
|
opc_handler_t **t1, **t2, **t3, *handler;
|
2007-03-07 11:32:30 +03:00
|
|
|
int op1, op2, op3;
|
|
|
|
|
2013-05-27 03:33:50 +04:00
|
|
|
t1 = cpu->env.opcodes;
|
2007-03-07 11:32:30 +03: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 12:02:12 +04:00
|
|
|
"%016" PRIx64 " %" PRId64 "\n",
|
2007-03-07 11:32:30 +03: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 12:02:12 +04:00
|
|
|
"%016" PRIx64 " %" PRId64 "\n",
|
2007-03-07 11:32:30 +03:00
|
|
|
op1, op2, op1, op2, handler->oname,
|
|
|
|
handler->count, handler->count);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (handler->count == 0)
|
|
|
|
continue;
|
2010-05-22 12:02:12 +04:00
|
|
|
cpu_fprintf(f, "%02x (%02x ) %16s: %016" PRIx64
|
|
|
|
" %" PRId64 "\n",
|
2007-03-07 11:32:30 +03:00
|
|
|
op1, op1, handler->oname,
|
|
|
|
handler->count, handler->count);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2004-01-05 01:58:38 +03:00
|
|
|
/*****************************************************************************/
|
2015-09-02 06:01:40 +03:00
|
|
|
void gen_intermediate_code(CPUPPCState *env, struct TranslationBlock *tb)
|
2003-11-23 17:55:54 +03:00
|
|
|
{
|
2015-09-02 06:01:40 +03:00
|
|
|
PowerPCCPU *cpu = ppc_env_get_cpu(env);
|
2013-06-21 22:20:45 +04:00
|
|
|
CPUState *cs = CPU(cpu);
|
2004-05-21 16:59:32 +04:00
|
|
|
DisasContext ctx, *ctxp = &ctx;
|
2009-10-02 01:12:16 +04:00
|
|
|
opc_handler_t **table, *handler;
|
2005-01-04 02:43:32 +03:00
|
|
|
target_ulong pc_start;
|
2008-06-29 05:03:05 +04:00
|
|
|
int num_insns;
|
|
|
|
int max_insns;
|
2003-11-23 17:55:54 +03:00
|
|
|
|
|
|
|
pc_start = tb->pc;
|
2004-04-26 01:15:35 +04:00
|
|
|
ctx.nip = pc_start;
|
2003-11-23 17:55:54 +03:00
|
|
|
ctx.tb = tb;
|
2007-09-29 17:06:16 +04:00
|
|
|
ctx.exception = POWERPC_EXCP_NONE;
|
2005-07-03 00:59:34 +04:00
|
|
|
ctx.spr_cb = env->spr_cb;
|
2014-09-15 19:03:28 +04:00
|
|
|
ctx.pr = msr_pr;
|
2016-05-03 19:03:24 +03:00
|
|
|
ctx.mem_idx = env->dmmu_idx;
|
2016-06-22 00:48:52 +03:00
|
|
|
ctx.dr = msr_dr;
|
2016-06-03 15:11:19 +03:00
|
|
|
#if !defined(CONFIG_USER_ONLY)
|
|
|
|
ctx.hv = msr_hv || !env->has_hv_mode;
|
|
|
|
#endif
|
2013-04-20 12:56:22 +04:00
|
|
|
ctx.insns_flags = env->insns_flags;
|
|
|
|
ctx.insns_flags2 = env->insns_flags2;
|
2008-12-08 21:11:21 +03:00
|
|
|
ctx.access_type = -1;
|
2016-07-27 09:56:46 +03:00
|
|
|
ctx.need_access_type = !(env->mmu_model & POWERPC_MMU_64B);
|
2016-06-22 00:48:53 +03:00
|
|
|
ctx.le_mode = !!(env->hflags & (1 << MSR_LE));
|
2014-05-29 18:12:20 +04:00
|
|
|
ctx.default_tcg_memop_mask = ctx.le_mode ? MO_LE : MO_BE;
|
2007-03-17 17:02:15 +03:00
|
|
|
#if defined(TARGET_PPC64)
|
2012-06-20 23:20:29 +04:00
|
|
|
ctx.sf_mode = msr_is_64bit(env, env->msr);
|
2011-08-31 19:45:10 +04:00
|
|
|
ctx.has_cfar = !!(env->flags & POWERPC_FLAG_CFAR);
|
2004-01-05 01:58:38 +03:00
|
|
|
#endif
|
2016-06-07 05:50:22 +03:00
|
|
|
if (env->mmu_model == POWERPC_MMU_32B ||
|
|
|
|
env->mmu_model == POWERPC_MMU_601 ||
|
|
|
|
(env->mmu_model & POWERPC_MMU_64B))
|
|
|
|
ctx.lazy_tlb_flush = true;
|
|
|
|
|
2016-06-22 00:48:53 +03:00
|
|
|
ctx.fpu_enabled = !!msr_fp;
|
2007-10-07 22:19:26 +04:00
|
|
|
if ((env->flags & POWERPC_FLAG_SPE) && msr_spe)
|
2016-06-22 00:48:53 +03:00
|
|
|
ctx.spe_enabled = !!msr_spe;
|
2007-10-07 18:41:00 +04:00
|
|
|
else
|
2016-06-22 00:48:53 +03:00
|
|
|
ctx.spe_enabled = false;
|
2007-10-07 22:19:26 +04:00
|
|
|
if ((env->flags & POWERPC_FLAG_VRE) && msr_vr)
|
2016-06-22 00:48:53 +03:00
|
|
|
ctx.altivec_enabled = !!msr_vr;
|
2007-10-07 22:19:26 +04:00
|
|
|
else
|
2016-06-22 00:48:53 +03:00
|
|
|
ctx.altivec_enabled = false;
|
2013-10-22 15:06:17 +04:00
|
|
|
if ((env->flags & POWERPC_FLAG_VSX) && msr_vsx) {
|
2016-06-22 00:48:53 +03:00
|
|
|
ctx.vsx_enabled = !!msr_vsx;
|
2013-10-22 15:06:17 +04:00
|
|
|
} else {
|
2016-06-22 00:48:53 +03:00
|
|
|
ctx.vsx_enabled = false;
|
2013-10-22 15:06:17 +04:00
|
|
|
}
|
2014-12-18 19:34:31 +03:00
|
|
|
#if defined(TARGET_PPC64)
|
|
|
|
if ((env->flags & POWERPC_FLAG_TM) && msr_tm) {
|
2016-06-22 00:48:53 +03:00
|
|
|
ctx.tm_enabled = !!msr_tm;
|
2014-12-18 19:34:31 +03:00
|
|
|
} else {
|
2016-06-22 00:48:53 +03:00
|
|
|
ctx.tm_enabled = false;
|
2014-12-18 19:34:31 +03:00
|
|
|
}
|
|
|
|
#endif
|
2007-10-07 18:41:00 +04:00
|
|
|
if ((env->flags & POWERPC_FLAG_SE) && msr_se)
|
2008-05-11 03:28:14 +04:00
|
|
|
ctx.singlestep_enabled = CPU_SINGLE_STEP;
|
2007-10-07 18:41:00 +04:00
|
|
|
else
|
2008-05-11 03:28:14 +04:00
|
|
|
ctx.singlestep_enabled = 0;
|
2007-10-07 18:41:00 +04:00
|
|
|
if ((env->flags & POWERPC_FLAG_BE) && msr_be)
|
2008-05-11 03:28:14 +04:00
|
|
|
ctx.singlestep_enabled |= CPU_BRANCH_STEP;
|
2013-06-21 22:20:45 +04:00
|
|
|
if (unlikely(cs->singlestep_enabled)) {
|
2008-05-11 03:28:14 +04:00
|
|
|
ctx.singlestep_enabled |= GDBSTUB_SINGLE_STEP;
|
2013-06-21 22:20:45 +04:00
|
|
|
}
|
2005-07-03 00:59:34 +04:00
|
|
|
#if defined (DO_SINGLE_STEP) && 0
|
2004-01-05 01:58:38 +03:00
|
|
|
/* Single step trace mode */
|
|
|
|
msr_se = 1;
|
|
|
|
#endif
|
2008-06-29 05:03:05 +04:00
|
|
|
num_insns = 0;
|
|
|
|
max_insns = tb->cflags & CF_COUNT_MASK;
|
2015-09-01 00:34:41 +03:00
|
|
|
if (max_insns == 0) {
|
2008-06-29 05:03:05 +04:00
|
|
|
max_insns = CF_COUNT_MASK;
|
2015-09-01 00:34:41 +03:00
|
|
|
}
|
|
|
|
if (max_insns > TCG_MAX_INSNS) {
|
|
|
|
max_insns = TCG_MAX_INSNS;
|
|
|
|
}
|
2008-06-29 05:03:05 +04:00
|
|
|
|
2014-11-26 13:40:05 +03:00
|
|
|
gen_tb_start(tb);
|
2014-01-19 20:28:33 +04:00
|
|
|
tcg_clear_temp_count();
|
2004-01-05 01:58:38 +03:00
|
|
|
/* Set env in case of segfault during code fetch */
|
2014-03-31 02:36:56 +04:00
|
|
|
while (ctx.exception == POWERPC_EXCP_NONE && !tcg_op_buf_full()) {
|
2015-08-29 22:59:29 +03:00
|
|
|
tcg_gen_insn_start(ctx.nip);
|
2015-09-18 00:25:46 +03:00
|
|
|
num_insns++;
|
2015-08-29 22:59:29 +03:00
|
|
|
|
2015-09-18 01:58:10 +03:00
|
|
|
if (unlikely(cpu_breakpoint_test(cs, ctx.nip, BP_ANY))) {
|
|
|
|
gen_debug_exception(ctxp);
|
2015-10-14 01:07:49 +03: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 01:58:10 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2009-01-16 00:48:06 +03:00
|
|
|
LOG_DISAS("----------------\n");
|
2009-08-16 15:13:18 +04:00
|
|
|
LOG_DISAS("nip=" TARGET_FMT_lx " super=%d ir=%d\n",
|
2009-01-16 00:48:06 +03:00
|
|
|
ctx.nip, ctx.mem_idx, (int)msr_ir);
|
2015-09-18 00:25:46 +03:00
|
|
|
if (num_insns == max_insns && (tb->cflags & CF_LAST_IO))
|
2008-06-29 05:03:05 +04:00
|
|
|
gen_io_start();
|
2014-05-29 18:12:20 +04:00
|
|
|
if (unlikely(need_byteswap(&ctx))) {
|
2012-05-30 08:23:40 +04:00
|
|
|
ctx.opcode = bswap32(cpu_ldl_code(env, ctx.nip));
|
2007-11-04 05:55:33 +03:00
|
|
|
} else {
|
2012-05-30 08:23:40 +04:00
|
|
|
ctx.opcode = cpu_ldl_code(env, ctx.nip);
|
2005-04-23 22:16:07 +04:00
|
|
|
}
|
2016-07-26 14:58:38 +03:00
|
|
|
LOG_DISAS("translate opcode %08x (%02x %02x %02x %02x) (%s)\n",
|
|
|
|
ctx.opcode, opc1(ctx.opcode), opc2(ctx.opcode),
|
|
|
|
opc3(ctx.opcode), opc4(ctx.opcode),
|
|
|
|
ctx.le_mode ? "little" : "big");
|
2004-04-26 01:15:35 +04:00
|
|
|
ctx.nip += 4;
|
2005-07-03 00:59:34 +04:00
|
|
|
table = env->opcodes;
|
2003-11-23 17:55:54 +03: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)];
|
2016-07-26 14:58:38 +03:00
|
|
|
if (is_indirect_opcode(handler)) {
|
|
|
|
table = ind_table(handler);
|
|
|
|
handler = table[opc4(ctx.opcode)];
|
|
|
|
}
|
2003-11-23 17:55:54 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
/* Is opcode *REALLY* valid ? */
|
2007-03-07 11:32:30 +03:00
|
|
|
if (unlikely(handler->handler == &gen_invalid)) {
|
2015-11-13 15:34:23 +03:00
|
|
|
qemu_log_mask(LOG_GUEST_ERROR, "invalid/unsupported opcode: "
|
2016-07-26 14:58:38 +03:00
|
|
|
"%02x - %02x - %02x - %02x (%08x) "
|
|
|
|
TARGET_FMT_lx " %d\n",
|
2015-11-13 15:34:23 +03:00
|
|
|
opc1(ctx.opcode), opc2(ctx.opcode),
|
2016-07-26 14:58:38 +03:00
|
|
|
opc3(ctx.opcode), opc4(ctx.opcode),
|
|
|
|
ctx.opcode, ctx.nip - 4, (int)msr_ir);
|
2007-03-07 11:32:30 +03:00
|
|
|
} else {
|
2011-09-28 09:54:05 +04: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 15:34:23 +03:00
|
|
|
qemu_log_mask(LOG_GUEST_ERROR, "invalid bits: %08x for opcode: "
|
2016-07-26 14:58:38 +03:00
|
|
|
"%02x - %02x - %02x - %02x (%08x) "
|
|
|
|
TARGET_FMT_lx "\n", ctx.opcode & inval,
|
|
|
|
opc1(ctx.opcode), opc2(ctx.opcode),
|
|
|
|
opc3(ctx.opcode), opc4(ctx.opcode),
|
2015-11-13 15:34:23 +03:00
|
|
|
ctx.opcode, ctx.nip - 4);
|
2008-12-12 01:42:14 +03:00
|
|
|
gen_inval_exception(ctxp, POWERPC_EXCP_INVAL_INVAL);
|
2004-05-24 02:18:12 +04:00
|
|
|
break;
|
2003-11-23 17:55:54 +03:00
|
|
|
}
|
|
|
|
}
|
2004-05-24 02:18:12 +04:00
|
|
|
(*(handler->handler))(&ctx);
|
2007-03-07 11:32:30 +03:00
|
|
|
#if defined(DO_PPC_STATISTICS)
|
|
|
|
handler->count++;
|
|
|
|
#endif
|
2004-01-05 01:58:38 +03:00
|
|
|
/* Check trace mode exceptions */
|
2008-05-11 03:28:14 +04: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)) {
|
2016-07-27 09:56:32 +03:00
|
|
|
gen_exception_nip(ctxp, POWERPC_EXCP_TRACE, ctx.nip);
|
2007-10-07 18:41:00 +04:00
|
|
|
} else if (unlikely(((ctx.nip & (TARGET_PAGE_SIZE - 1)) == 0) ||
|
2013-06-21 22:20:45 +04:00
|
|
|
(cs->singlestep_enabled) ||
|
2009-04-06 00:08:59 +04:00
|
|
|
singlestep ||
|
2008-06-29 05:03:05 +04:00
|
|
|
num_insns >= max_insns)) {
|
2007-10-07 18:41:00 +04:00
|
|
|
/* if we reach a page boundary or are single stepping, stop
|
|
|
|
* generation
|
|
|
|
*/
|
2005-06-05 02:22:27 +04:00
|
|
|
break;
|
2007-03-07 11:32:30 +03:00
|
|
|
}
|
2014-01-19 20:28:33 +04:00
|
|
|
if (tcg_check_temp_count()) {
|
2016-07-26 14:58:38 +03:00
|
|
|
fprintf(stderr, "Opcode %02x %02x %02x %02x (%08x) leaked "
|
|
|
|
"temporaries\n", opc1(ctx.opcode), opc2(ctx.opcode),
|
|
|
|
opc3(ctx.opcode), opc4(ctx.opcode), ctx.opcode);
|
2014-01-19 20:28:33 +04:00
|
|
|
exit(1);
|
|
|
|
}
|
2005-07-03 00:59:34 +04:00
|
|
|
}
|
2008-06-29 05:03:05 +04:00
|
|
|
if (tb->cflags & CF_LAST_IO)
|
|
|
|
gen_io_end();
|
2007-09-29 17:06:16 +04:00
|
|
|
if (ctx.exception == POWERPC_EXCP_NONE) {
|
2005-11-20 13:31:08 +03:00
|
|
|
gen_goto_tb(&ctx, 0, ctx.nip);
|
2007-09-29 17:06:16 +04:00
|
|
|
} else if (ctx.exception != POWERPC_EXCP_BRANCH) {
|
2013-06-21 22:20:45 +04:00
|
|
|
if (unlikely(cs->singlestep_enabled)) {
|
2008-12-12 01:42:14 +03:00
|
|
|
gen_debug_exception(ctxp);
|
2008-05-11 03:28:14 +04:00
|
|
|
}
|
2007-03-07 11:32:30 +03:00
|
|
|
/* Generate the return instruction */
|
2008-02-01 13:50:11 +03:00
|
|
|
tcg_gen_exit_tb(0);
|
2004-01-05 01:58:38 +03:00
|
|
|
}
|
2013-02-22 22:10:05 +04:00
|
|
|
gen_tb_end(tb, num_insns);
|
2014-03-31 01:50:30 +04:00
|
|
|
|
2015-09-02 06:01:40 +03:00
|
|
|
tb->size = ctx.nip - pc_start;
|
|
|
|
tb->icount = num_insns;
|
|
|
|
|
2007-03-17 17:02:15 +03:00
|
|
|
#if defined(DEBUG_DISAS)
|
2016-04-20 21:39:35 +03:00
|
|
|
if (qemu_loglevel_mask(CPU_LOG_TB_IN_ASM)
|
|
|
|
&& qemu_log_in_addr_range(pc_start)) {
|
2007-03-07 11:32:30 +03:00
|
|
|
int flags;
|
2007-09-29 16:01:46 +04:00
|
|
|
flags = env->bfd_mach;
|
2008-12-08 21:11:21 +03:00
|
|
|
flags |= ctx.le_mode << 16;
|
2009-01-16 01:34:14 +03:00
|
|
|
qemu_log("IN: %s\n", lookup_symbol(pc_start));
|
2015-05-25 00:20:41 +03:00
|
|
|
log_target_disas(cs, pc_start, ctx.nip - pc_start, flags);
|
2009-01-16 01:34:14 +03:00
|
|
|
qemu_log("\n");
|
2004-05-21 16:59:32 +04:00
|
|
|
}
|
2003-11-23 17:55:54 +03:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2015-09-02 01:51:12 +03:00
|
|
|
void restore_state_to_opc(CPUPPCState *env, TranslationBlock *tb,
|
|
|
|
target_ulong *data)
|
2008-04-28 04:32:32 +04:00
|
|
|
{
|
2015-09-02 01:51:12 +03:00
|
|
|
env->nip = data[0];
|
2008-04-28 04:32:32 +04:00
|
|
|
}
|