2003-11-23 15:55:54 +01:00
|
|
|
/*
|
2005-07-02 22:59:34 +02:00
|
|
|
* PowerPC emulation for qemu: main translation routines.
|
2007-09-16 23:08:06 +02:00
|
|
|
*
|
2007-03-07 09:32:30 +01:00
|
|
|
* Copyright (c) 2003-2007 Jocelyn Mayer
|
2011-04-30 00:10:23 +02:00
|
|
|
* Copyright (C) 2011 Freescale Semiconductor, Inc.
|
2003-11-23 15:55:54 +01:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
2020-10-19 08:11:26 +02:00
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
2003-11-23 15:55:54 +01:00
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
2009-07-16 22:47:01 +02:00
|
|
|
* License along with this library; if not, see <http://www.gnu.org/licenses/>.
|
2003-11-23 15:55:54 +01:00
|
|
|
*/
|
2004-05-20 15:10:49 +02:00
|
|
|
|
2016-01-26 19:16:58 +01:00
|
|
|
#include "qemu/osdep.h"
|
2003-11-23 15:55:54 +01:00
|
|
|
#include "cpu.h"
|
2016-10-30 04:14:56 +01:00
|
|
|
#include "internal.h"
|
2012-10-24 11:12:21 +02:00
|
|
|
#include "disas/disas.h"
|
2016-03-15 13:18:37 +01:00
|
|
|
#include "exec/exec-all.h"
|
2020-01-01 12:23:00 +01:00
|
|
|
#include "tcg/tcg-op.h"
|
|
|
|
#include "tcg/tcg-op-gvec.h"
|
2012-12-17 18:20:00 +01:00
|
|
|
#include "qemu/host-utils.h"
|
Include qemu/main-loop.h less
In my "build everything" tree, changing qemu/main-loop.h triggers a
recompile of some 5600 out of 6600 objects (not counting tests and
objects that don't depend on qemu/osdep.h). It includes block/aio.h,
which in turn includes qemu/event_notifier.h, qemu/notify.h,
qemu/processor.h, qemu/qsp.h, qemu/queue.h, qemu/thread-posix.h,
qemu/thread.h, qemu/timer.h, and a few more.
Include qemu/main-loop.h only where it's needed. Touching it now
recompiles only some 1700 objects. For block/aio.h and
qemu/event_notifier.h, these numbers drop from 5600 to 2800. For the
others, they shrink only slightly.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <20190812052359.30071-21-armbru@redhat.com>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com>
2019-08-12 07:23:50 +02:00
|
|
|
#include "qemu/main-loop.h"
|
2014-03-28 19:42:10 +01:00
|
|
|
#include "exec/cpu_ldst.h"
|
2003-11-23 15:55:54 +01:00
|
|
|
|
2014-04-08 07:31:41 +02:00
|
|
|
#include "exec/helper-proto.h"
|
|
|
|
#include "exec/helper-gen.h"
|
2008-11-17 15:43:54 +01:00
|
|
|
|
2014-05-30 14:12:25 +02:00
|
|
|
#include "trace-tcg.h"
|
2018-02-15 20:51:48 +01:00
|
|
|
#include "exec/translator.h"
|
2016-01-07 14:55:28 +01:00
|
|
|
#include "exec/log.h"
|
2018-08-16 02:35:14 +02:00
|
|
|
#include "qemu/atomic128.h"
|
2021-05-07 13:55:12 +02:00
|
|
|
#include "spr_tcg.h"
|
2014-05-30 14:12:25 +02:00
|
|
|
|
2021-05-07 13:55:51 +02:00
|
|
|
#include "qemu/qemu-print.h"
|
|
|
|
#include "qapi/error.h"
|
2014-05-30 14:12:25 +02:00
|
|
|
|
2008-05-11 01:28:14 +02:00
|
|
|
#define CPU_SINGLE_STEP 0x1
|
|
|
|
#define CPU_BRANCH_STEP 0x2
|
|
|
|
#define GDBSTUB_SINGLE_STEP 0x4
|
|
|
|
|
Great rework and cleanups to ease PowerPC implementations definitions.
* cleanup cpu.h, removing definitions used only in translate.c/translate_init.c
* add new flags to define instructions sets more precisely
* various changes in MMU models definitions
* add definitions for PowerPC 440/460 support (insns and SPRs).
* add definitions for PowerPC 401/403 and 620 input pins model
* Fix definitions for most PowerPC 401, 403, 405, 440, 601, 602, 603 and 7x0
* Preliminary support for PowerPC 74xx (aka G4) without altivec.
* Code provision for other PowerPC support (7x5, 970, ...).
* New SPR and PVR defined, from PowerPC 2.04 specification and other sources
* Misc code bugs, error messages and styles fixes.
* Update status files for PowerPC cores support.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3244 c046a42c-6fe2-441c-8c8c-71466251a162
2007-09-27 01:54:22 +02:00
|
|
|
/* Include definitions for instructions classes and implementations flags */
|
2019-03-21 12:57:28 +01:00
|
|
|
/* #define PPC_DEBUG_DISAS */
|
2003-11-23 15:55:54 +01:00
|
|
|
|
2009-01-15 22:48:06 +01:00
|
|
|
#ifdef PPC_DEBUG_DISAS
|
2009-01-15 23:34:14 +01:00
|
|
|
# define LOG_DISAS(...) qemu_log_mask(CPU_LOG_TB_IN_ASM, ## __VA_ARGS__)
|
2009-01-15 22:48:06 +01:00
|
|
|
#else
|
|
|
|
# define LOG_DISAS(...) do { } while (0)
|
|
|
|
#endif
|
Great rework and cleanups to ease PowerPC implementations definitions.
* cleanup cpu.h, removing definitions used only in translate.c/translate_init.c
* add new flags to define instructions sets more precisely
* various changes in MMU models definitions
* add definitions for PowerPC 440/460 support (insns and SPRs).
* add definitions for PowerPC 401/403 and 620 input pins model
* Fix definitions for most PowerPC 401, 403, 405, 440, 601, 602, 603 and 7x0
* Preliminary support for PowerPC 74xx (aka G4) without altivec.
* Code provision for other PowerPC support (7x5, 970, ...).
* New SPR and PVR defined, from PowerPC 2.04 specification and other sources
* Misc code bugs, error messages and styles fixes.
* Update status files for PowerPC cores support.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3244 c046a42c-6fe2-441c-8c8c-71466251a162
2007-09-27 01:54:22 +02:00
|
|
|
/*****************************************************************************/
|
|
|
|
/* Code translation helpers */
|
2005-10-30 22:39:19 +01:00
|
|
|
|
2008-09-04 07:25:47 +02:00
|
|
|
/* global register indexes */
|
2019-03-21 12:57:28 +01:00
|
|
|
static char cpu_reg_names[10 * 3 + 22 * 4 /* GPR */
|
|
|
|
+ 10 * 4 + 22 * 5 /* SPE GPRh */
|
|
|
|
+ 8 * 5 /* CRF */];
|
2008-09-04 07:25:47 +02:00
|
|
|
static TCGv cpu_gpr[32];
|
|
|
|
static TCGv cpu_gprh[32];
|
2008-11-17 15:43:54 +01:00
|
|
|
static TCGv_i32 cpu_crf[8];
|
2008-09-04 20:06:03 +02:00
|
|
|
static TCGv cpu_nip;
|
2008-12-06 14:03:35 +01:00
|
|
|
static TCGv cpu_msr;
|
2008-09-14 20:30:23 +02:00
|
|
|
static TCGv cpu_ctr;
|
|
|
|
static TCGv cpu_lr;
|
2011-08-31 17:45:10 +02:00
|
|
|
#if defined(TARGET_PPC64)
|
|
|
|
static TCGv cpu_cfar;
|
|
|
|
#endif
|
target/ppc: support for 32-bit carry and overflow
POWER ISA 3.0 adds CA32 and OV32 status in 64-bit mode. Add the flags
and corresponding defines.
Moreover, CA32 is updated when CA is updated and OV32 is updated when OV
is updated.
Arithmetic instructions:
* Addition and Substractions:
addic, addic., subfic, addc, subfc, adde, subfe, addme, subfme,
addze, and subfze always updates CA and CA32.
=> CA reflects the carry out of bit 0 in 64-bit mode and out of
bit 32 in 32-bit mode.
=> CA32 reflects the carry out of bit 32 independent of the
mode.
=> SO and OV reflects overflow of the 64-bit result in 64-bit
mode and overflow of the low-order 32-bit result in 32-bit
mode
=> OV32 reflects overflow of the low-order 32-bit independent of
the mode
* Multiply Low and Divide:
For mulld, divd, divde, divdu and divdeu: SO, OV, and OV32 bits
reflects overflow of the 64-bit result
For mullw, divw, divwe, divwu and divweu: SO, OV, and OV32 bits
reflects overflow of the 32-bit result
* Negate with OE=1 (nego)
For 64-bit mode if the register RA contains
0x8000_0000_0000_0000, OV and OV32 are set to 1.
For 32-bit mode if the register RA contains 0x8000_0000, OV and
OV32 are set to 1.
Signed-off-by: Nikunj A Dadhania <nikunj@linux.vnet.ibm.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2017-02-27 05:57:54 +01:00
|
|
|
static TCGv cpu_xer, cpu_so, cpu_ov, cpu_ca, cpu_ov32, cpu_ca32;
|
2008-11-30 17:24:39 +01:00
|
|
|
static TCGv cpu_reserve;
|
2017-04-27 07:18:19 +02:00
|
|
|
static TCGv cpu_reserve_val;
|
2012-10-29 18:24:59 +01:00
|
|
|
static TCGv cpu_fpscr;
|
2008-11-23 17:30:40 +01:00
|
|
|
static TCGv_i32 cpu_access_type;
|
2008-09-04 07:25:47 +02:00
|
|
|
|
2012-12-17 18:19:49 +01:00
|
|
|
#include "exec/gen-icount.h"
|
2008-06-29 03:03:05 +02:00
|
|
|
|
|
|
|
void ppc_translate_init(void)
|
|
|
|
{
|
2008-09-04 07:25:47 +02:00
|
|
|
int i;
|
2019-03-21 12:57:28 +01:00
|
|
|
char *p;
|
2009-04-13 18:06:19 +02:00
|
|
|
size_t cpu_reg_names_size;
|
2008-09-04 07:25:47 +02:00
|
|
|
|
|
|
|
p = cpu_reg_names;
|
2009-04-13 18:06:19 +02:00
|
|
|
cpu_reg_names_size = sizeof(cpu_reg_names);
|
2008-09-04 19:06:47 +02:00
|
|
|
|
|
|
|
for (i = 0; i < 8; i++) {
|
2009-04-13 18:06:19 +02:00
|
|
|
snprintf(p, cpu_reg_names_size, "crf%d", i);
|
2013-09-18 21:53:09 +02:00
|
|
|
cpu_crf[i] = tcg_global_mem_new_i32(cpu_env,
|
2012-03-14 01:38:22 +01:00
|
|
|
offsetof(CPUPPCState, crf[i]), p);
|
2008-09-04 19:06:47 +02:00
|
|
|
p += 5;
|
2009-04-13 18:06:19 +02:00
|
|
|
cpu_reg_names_size -= 5;
|
2008-09-04 19:06:47 +02:00
|
|
|
}
|
|
|
|
|
2008-09-04 07:25:47 +02:00
|
|
|
for (i = 0; i < 32; i++) {
|
2009-04-13 18:06:19 +02:00
|
|
|
snprintf(p, cpu_reg_names_size, "r%d", i);
|
2013-09-18 21:53:09 +02:00
|
|
|
cpu_gpr[i] = tcg_global_mem_new(cpu_env,
|
2012-03-14 01:38:22 +01:00
|
|
|
offsetof(CPUPPCState, gpr[i]), p);
|
2008-09-04 07:25:47 +02:00
|
|
|
p += (i < 10) ? 3 : 4;
|
2009-04-13 18:06:19 +02:00
|
|
|
cpu_reg_names_size -= (i < 10) ? 3 : 4;
|
|
|
|
snprintf(p, cpu_reg_names_size, "r%dH", i);
|
2013-09-18 21:53:09 +02:00
|
|
|
cpu_gprh[i] = tcg_global_mem_new(cpu_env,
|
2014-06-04 22:58:50 +02:00
|
|
|
offsetof(CPUPPCState, gprh[i]), p);
|
2008-09-04 07:25:47 +02:00
|
|
|
p += (i < 10) ? 4 : 5;
|
2009-04-13 18:06:19 +02:00
|
|
|
cpu_reg_names_size -= (i < 10) ? 4 : 5;
|
2008-09-04 07:25:47 +02:00
|
|
|
}
|
2008-08-28 23:01:45 +02:00
|
|
|
|
2013-09-18 21:53:09 +02:00
|
|
|
cpu_nip = tcg_global_mem_new(cpu_env,
|
2012-03-14 01:38:22 +01:00
|
|
|
offsetof(CPUPPCState, nip), "nip");
|
2008-09-04 20:06:03 +02:00
|
|
|
|
2013-09-18 21:53:09 +02:00
|
|
|
cpu_msr = tcg_global_mem_new(cpu_env,
|
2012-03-14 01:38:22 +01:00
|
|
|
offsetof(CPUPPCState, msr), "msr");
|
2008-12-06 14:03:35 +01:00
|
|
|
|
2013-09-18 21:53:09 +02:00
|
|
|
cpu_ctr = tcg_global_mem_new(cpu_env,
|
2012-03-14 01:38:22 +01:00
|
|
|
offsetof(CPUPPCState, ctr), "ctr");
|
2008-09-14 20:30:23 +02:00
|
|
|
|
2013-09-18 21:53:09 +02:00
|
|
|
cpu_lr = tcg_global_mem_new(cpu_env,
|
2012-03-14 01:38:22 +01:00
|
|
|
offsetof(CPUPPCState, lr), "lr");
|
2008-09-14 20:30:23 +02:00
|
|
|
|
2011-08-31 17:45:10 +02:00
|
|
|
#if defined(TARGET_PPC64)
|
2013-09-18 21:53:09 +02:00
|
|
|
cpu_cfar = tcg_global_mem_new(cpu_env,
|
2012-03-14 01:38:22 +01:00
|
|
|
offsetof(CPUPPCState, cfar), "cfar");
|
2011-08-31 17:45:10 +02:00
|
|
|
#endif
|
|
|
|
|
2013-09-18 21:53:09 +02:00
|
|
|
cpu_xer = tcg_global_mem_new(cpu_env,
|
2012-03-14 01:38:22 +01:00
|
|
|
offsetof(CPUPPCState, xer), "xer");
|
2013-09-18 21:53:09 +02:00
|
|
|
cpu_so = tcg_global_mem_new(cpu_env,
|
2013-02-20 08:52:13 +01:00
|
|
|
offsetof(CPUPPCState, so), "SO");
|
2013-09-18 21:53:09 +02:00
|
|
|
cpu_ov = tcg_global_mem_new(cpu_env,
|
2013-02-20 08:52:13 +01:00
|
|
|
offsetof(CPUPPCState, ov), "OV");
|
2013-09-18 21:53:09 +02:00
|
|
|
cpu_ca = tcg_global_mem_new(cpu_env,
|
2013-02-20 08:52:13 +01:00
|
|
|
offsetof(CPUPPCState, ca), "CA");
|
target/ppc: support for 32-bit carry and overflow
POWER ISA 3.0 adds CA32 and OV32 status in 64-bit mode. Add the flags
and corresponding defines.
Moreover, CA32 is updated when CA is updated and OV32 is updated when OV
is updated.
Arithmetic instructions:
* Addition and Substractions:
addic, addic., subfic, addc, subfc, adde, subfe, addme, subfme,
addze, and subfze always updates CA and CA32.
=> CA reflects the carry out of bit 0 in 64-bit mode and out of
bit 32 in 32-bit mode.
=> CA32 reflects the carry out of bit 32 independent of the
mode.
=> SO and OV reflects overflow of the 64-bit result in 64-bit
mode and overflow of the low-order 32-bit result in 32-bit
mode
=> OV32 reflects overflow of the low-order 32-bit independent of
the mode
* Multiply Low and Divide:
For mulld, divd, divde, divdu and divdeu: SO, OV, and OV32 bits
reflects overflow of the 64-bit result
For mullw, divw, divwe, divwu and divweu: SO, OV, and OV32 bits
reflects overflow of the 32-bit result
* Negate with OE=1 (nego)
For 64-bit mode if the register RA contains
0x8000_0000_0000_0000, OV and OV32 are set to 1.
For 32-bit mode if the register RA contains 0x8000_0000, OV and
OV32 are set to 1.
Signed-off-by: Nikunj A Dadhania <nikunj@linux.vnet.ibm.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2017-02-27 05:57:54 +01:00
|
|
|
cpu_ov32 = tcg_global_mem_new(cpu_env,
|
|
|
|
offsetof(CPUPPCState, ov32), "OV32");
|
|
|
|
cpu_ca32 = tcg_global_mem_new(cpu_env,
|
|
|
|
offsetof(CPUPPCState, ca32), "CA32");
|
2008-10-21 13:28:46 +02:00
|
|
|
|
2013-09-18 21:53:09 +02:00
|
|
|
cpu_reserve = tcg_global_mem_new(cpu_env,
|
2012-03-14 01:38:22 +01:00
|
|
|
offsetof(CPUPPCState, reserve_addr),
|
2009-08-03 17:43:25 +02:00
|
|
|
"reserve_addr");
|
2017-04-27 07:18:19 +02:00
|
|
|
cpu_reserve_val = tcg_global_mem_new(cpu_env,
|
|
|
|
offsetof(CPUPPCState, reserve_val),
|
|
|
|
"reserve_val");
|
2008-11-30 17:24:39 +01:00
|
|
|
|
2013-09-18 21:53:09 +02:00
|
|
|
cpu_fpscr = tcg_global_mem_new(cpu_env,
|
2012-10-29 18:24:59 +01:00
|
|
|
offsetof(CPUPPCState, fpscr), "fpscr");
|
2008-10-21 13:31:14 +02:00
|
|
|
|
2013-09-18 21:53:09 +02:00
|
|
|
cpu_access_type = tcg_global_mem_new_i32(cpu_env,
|
2019-03-21 12:57:28 +01:00
|
|
|
offsetof(CPUPPCState, access_type),
|
|
|
|
"access_type");
|
2008-06-29 03:03:05 +02:00
|
|
|
}
|
|
|
|
|
2003-11-23 15:55:54 +01:00
|
|
|
/* internal defines */
|
2014-11-26 11:39:48 +01:00
|
|
|
struct DisasContext {
|
2018-02-15 20:51:48 +01:00
|
|
|
DisasContextBase base;
|
2021-05-12 20:54:11 +02:00
|
|
|
target_ulong cia; /* current instruction address */
|
2003-11-23 15:55:54 +01:00
|
|
|
uint32_t opcode;
|
2005-02-16 00:06:19 +01:00
|
|
|
/* Routine used to access memory */
|
2016-06-21 23:48:53 +02:00
|
|
|
bool pr, hv, dr, le_mode;
|
2016-06-07 04:50:22 +02:00
|
|
|
bool lazy_tlb_flush;
|
2016-07-27 08:56:46 +02:00
|
|
|
bool need_access_type;
|
2005-02-16 00:06:19 +01:00
|
|
|
int mem_idx;
|
2008-12-08 19:11:21 +01:00
|
|
|
int access_type;
|
2005-02-16 00:06:19 +01:00
|
|
|
/* Translation flags */
|
2019-08-23 20:10:58 +02:00
|
|
|
MemOp default_tcg_memop_mask;
|
2007-03-17 15:02:15 +01:00
|
|
|
#if defined(TARGET_PPC64)
|
2016-06-21 23:48:53 +02:00
|
|
|
bool sf_mode;
|
|
|
|
bool has_cfar;
|
2004-01-04 23:58:38 +01:00
|
|
|
#endif
|
2016-06-21 23:48:53 +02:00
|
|
|
bool fpu_enabled;
|
|
|
|
bool altivec_enabled;
|
|
|
|
bool vsx_enabled;
|
|
|
|
bool spe_enabled;
|
|
|
|
bool tm_enabled;
|
2017-05-02 08:37:15 +02:00
|
|
|
bool gtse;
|
2009-10-01 23:12:16 +02:00
|
|
|
ppc_spr_t *spr_cb; /* Needed to check rights for mfspr/mtspr */
|
2006-05-22 23:50:20 +02:00
|
|
|
int singlestep_enabled;
|
2018-08-14 18:09:51 +02:00
|
|
|
uint32_t flags;
|
2013-04-20 10:56:22 +02:00
|
|
|
uint64_t insns_flags;
|
|
|
|
uint64_t insns_flags2;
|
2014-11-26 11:39:48 +01:00
|
|
|
};
|
2003-11-23 15:55:54 +01:00
|
|
|
|
2021-05-12 20:54:17 +02:00
|
|
|
#define DISAS_EXIT DISAS_TARGET_0 /* exit to main loop, pc updated */
|
|
|
|
#define DISAS_EXIT_UPDATE DISAS_TARGET_1 /* exit to main loop, pc stale */
|
|
|
|
#define DISAS_CHAIN DISAS_TARGET_2 /* lookup next tb, pc updated */
|
|
|
|
#define DISAS_CHAIN_UPDATE DISAS_TARGET_3 /* lookup next tb, pc stale */
|
|
|
|
|
2014-05-29 16:12:20 +02:00
|
|
|
/* Return true iff byteswap is needed in a scalar memop */
|
|
|
|
static inline bool need_byteswap(const DisasContext *ctx)
|
|
|
|
{
|
|
|
|
#if defined(TARGET_WORDS_BIGENDIAN)
|
|
|
|
return ctx->le_mode;
|
|
|
|
#else
|
|
|
|
return !ctx->le_mode;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2013-03-21 11:01:45 +01:00
|
|
|
/* True when active word size < size of target_long. */
|
|
|
|
#ifdef TARGET_PPC64
|
|
|
|
# define NARROW_MODE(C) (!(C)->sf_mode)
|
|
|
|
#else
|
|
|
|
# define NARROW_MODE(C) 0
|
|
|
|
#endif
|
|
|
|
|
2009-10-01 23:12:16 +02:00
|
|
|
struct opc_handler_t {
|
2011-09-28 07:54:05 +02:00
|
|
|
/* invalid bits for instruction 1 (Rc(opcode) == 0) */
|
|
|
|
uint32_t inval1;
|
|
|
|
/* invalid bits for instruction 2 (Rc(opcode) == 1) */
|
|
|
|
uint32_t inval2;
|
2004-01-04 23:58:38 +01:00
|
|
|
/* instruction type */
|
2007-03-20 23:11:31 +01:00
|
|
|
uint64_t type;
|
2011-05-01 00:00:58 +02:00
|
|
|
/* extended instruction type */
|
|
|
|
uint64_t type2;
|
2003-11-23 15:55:54 +01:00
|
|
|
/* handler */
|
|
|
|
void (*handler)(DisasContext *ctx);
|
2005-07-02 22:59:34 +02:00
|
|
|
};
|
2003-11-23 15:55:54 +01:00
|
|
|
|
2018-08-14 18:09:51 +02:00
|
|
|
/* SPR load/store helpers */
|
|
|
|
static inline void gen_load_spr(TCGv t, int reg)
|
|
|
|
{
|
|
|
|
tcg_gen_ld_tl(t, cpu_env, offsetof(CPUPPCState, spr[reg]));
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void gen_store_spr(int reg, TCGv t)
|
|
|
|
{
|
|
|
|
tcg_gen_st_tl(t, cpu_env, offsetof(CPUPPCState, spr[reg]));
|
|
|
|
}
|
|
|
|
|
2009-08-16 11:06:54 +02:00
|
|
|
static inline void gen_set_access_type(DisasContext *ctx, int access_type)
|
2008-11-23 17:30:40 +01:00
|
|
|
{
|
2016-07-27 08:56:46 +02:00
|
|
|
if (ctx->need_access_type && ctx->access_type != access_type) {
|
2008-12-08 19:11:21 +01:00
|
|
|
tcg_gen_movi_i32(cpu_access_type, access_type);
|
|
|
|
ctx->access_type = access_type;
|
|
|
|
}
|
2008-11-23 17:30:40 +01:00
|
|
|
}
|
|
|
|
|
2009-08-16 11:06:54 +02:00
|
|
|
static inline void gen_update_nip(DisasContext *ctx, target_ulong nip)
|
2007-03-17 15:02:15 +01:00
|
|
|
{
|
2013-03-21 11:01:46 +01:00
|
|
|
if (NARROW_MODE(ctx)) {
|
|
|
|
nip = (uint32_t)nip;
|
|
|
|
}
|
|
|
|
tcg_gen_movi_tl(cpu_nip, nip);
|
2007-03-17 15:02:15 +01:00
|
|
|
}
|
|
|
|
|
2016-06-21 23:48:54 +02:00
|
|
|
static void gen_exception_err(DisasContext *ctx, uint32_t excp, uint32_t error)
|
2008-12-11 23:42:14 +01:00
|
|
|
{
|
|
|
|
TCGv_i32 t0, t1;
|
2016-07-27 08:56:32 +02:00
|
|
|
|
2019-03-21 12:57:28 +01:00
|
|
|
/*
|
|
|
|
* These are all synchronous exceptions, we set the PC back to the
|
|
|
|
* faulting instruction
|
2016-07-27 08:56:32 +02:00
|
|
|
*/
|
2021-05-17 22:50:06 +02:00
|
|
|
gen_update_nip(ctx, ctx->cia);
|
2008-12-11 23:42:14 +01:00
|
|
|
t0 = tcg_const_i32(excp);
|
|
|
|
t1 = tcg_const_i32(error);
|
2012-05-30 06:23:23 +02:00
|
|
|
gen_helper_raise_exception_err(cpu_env, t0, t1);
|
2008-12-11 23:42:14 +01:00
|
|
|
tcg_temp_free_i32(t0);
|
|
|
|
tcg_temp_free_i32(t1);
|
2021-05-12 20:54:13 +02:00
|
|
|
ctx->base.is_jmp = DISAS_NORETURN;
|
2008-12-11 23:42:14 +01:00
|
|
|
}
|
2007-09-29 15:06:16 +02:00
|
|
|
|
2016-06-21 23:48:54 +02:00
|
|
|
static void gen_exception(DisasContext *ctx, uint32_t excp)
|
2008-12-11 23:42:14 +01:00
|
|
|
{
|
|
|
|
TCGv_i32 t0;
|
2016-07-27 08:56:32 +02:00
|
|
|
|
2019-03-21 12:57:28 +01:00
|
|
|
/*
|
|
|
|
* These are all synchronous exceptions, we set the PC back to the
|
|
|
|
* faulting instruction
|
2016-07-27 08:56:32 +02:00
|
|
|
*/
|
2021-05-17 22:50:06 +02:00
|
|
|
gen_update_nip(ctx, ctx->cia);
|
2008-12-11 23:42:14 +01:00
|
|
|
t0 = tcg_const_i32(excp);
|
2012-05-30 06:23:23 +02:00
|
|
|
gen_helper_raise_exception(cpu_env, t0);
|
2008-12-11 23:42:14 +01:00
|
|
|
tcg_temp_free_i32(t0);
|
2021-05-12 20:54:13 +02:00
|
|
|
ctx->base.is_jmp = DISAS_NORETURN;
|
2008-12-11 23:42:14 +01:00
|
|
|
}
|
2007-09-29 15:06:16 +02:00
|
|
|
|
2016-07-27 08:56:32 +02: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);
|
2021-05-12 20:54:13 +02:00
|
|
|
ctx->base.is_jmp = DISAS_NORETURN;
|
2016-07-27 08:56:32 +02:00
|
|
|
}
|
|
|
|
|
2021-05-17 22:50:03 +02:00
|
|
|
static void gen_icount_io_start(DisasContext *ctx)
|
|
|
|
{
|
|
|
|
if (tb_cflags(ctx->base.tb) & CF_USE_ICOUNT) {
|
|
|
|
gen_io_start();
|
|
|
|
/*
|
|
|
|
* An I/O instruction must be last in the TB.
|
|
|
|
* Chain to the next TB, and let the code from gen_tb_start
|
|
|
|
* decide if we need to return to the main loop.
|
|
|
|
* Doing this first also allows this value to be overridden.
|
|
|
|
*/
|
|
|
|
ctx->base.is_jmp = DISAS_TOO_MANY;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-02-12 13:12:55 +01:00
|
|
|
/*
|
|
|
|
* Tells the caller what is the appropriate exception to generate and prepares
|
|
|
|
* SPR registers for this exception.
|
|
|
|
*
|
|
|
|
* The exception can be either POWERPC_EXCP_TRACE (on most PowerPCs) or
|
|
|
|
* POWERPC_EXCP_DEBUG (on BookE).
|
2018-08-14 18:09:51 +02:00
|
|
|
*/
|
2019-02-12 13:12:55 +01:00
|
|
|
static uint32_t gen_prep_dbgex(DisasContext *ctx)
|
2018-08-14 18:09:51 +02:00
|
|
|
{
|
|
|
|
if (ctx->flags & POWERPC_FLAG_DE) {
|
|
|
|
target_ulong dbsr = 0;
|
2019-02-12 13:12:55 +01:00
|
|
|
if (ctx->singlestep_enabled & CPU_SINGLE_STEP) {
|
2018-08-14 18:09:51 +02:00
|
|
|
dbsr = DBCR0_ICMP;
|
2019-02-12 13:12:55 +01:00
|
|
|
} else {
|
|
|
|
/* Must have been branch */
|
2018-08-14 18:09:51 +02:00
|
|
|
dbsr = DBCR0_BRT;
|
|
|
|
}
|
|
|
|
TCGv t0 = tcg_temp_new();
|
|
|
|
gen_load_spr(t0, SPR_BOOKE_DBSR);
|
|
|
|
tcg_gen_ori_tl(t0, t0, dbsr);
|
|
|
|
gen_store_spr(SPR_BOOKE_DBSR, t0);
|
|
|
|
tcg_temp_free(t0);
|
|
|
|
return POWERPC_EXCP_DEBUG;
|
|
|
|
} else {
|
2019-02-12 13:12:55 +01:00
|
|
|
return POWERPC_EXCP_TRACE;
|
2018-08-14 18:09:51 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-06-21 23:48:54 +02:00
|
|
|
static void gen_debug_exception(DisasContext *ctx)
|
2008-12-11 23:42:14 +01:00
|
|
|
{
|
2021-05-12 20:54:16 +02:00
|
|
|
gen_helper_raise_exception(cpu_env, tcg_constant_i32(EXCP_DEBUG));
|
2021-05-12 20:54:13 +02:00
|
|
|
ctx->base.is_jmp = DISAS_NORETURN;
|
2008-12-11 23:42:14 +01:00
|
|
|
}
|
2004-01-04 23:58:38 +01:00
|
|
|
|
2009-08-16 11:06:54 +02:00
|
|
|
static inline void gen_inval_exception(DisasContext *ctx, uint32_t error)
|
2008-12-11 23:42:14 +01:00
|
|
|
{
|
2016-06-21 23:48:51 +02: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-11 23:42:14 +01:00
|
|
|
}
|
2007-10-07 20:19:26 +02:00
|
|
|
|
2021-05-06 21:08:37 +02:00
|
|
|
/*****************************************************************************/
|
|
|
|
/* SPR READ/WRITE CALLBACKS */
|
|
|
|
|
2021-05-07 13:55:12 +02:00
|
|
|
void spr_noaccess(DisasContext *ctx, int gprn, int sprn)
|
2021-05-06 21:08:37 +02:00
|
|
|
{
|
|
|
|
#if 0
|
|
|
|
sprn = ((sprn >> 5) & 0x1F) | ((sprn & 0x1F) << 5);
|
|
|
|
printf("ERROR: try to access SPR %d !\n", sprn);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
/* #define PPC_DUMP_SPR_ACCESSES */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Generic callbacks:
|
|
|
|
* do nothing but store/retrieve spr value
|
|
|
|
*/
|
|
|
|
static void spr_load_dump_spr(int sprn)
|
|
|
|
{
|
|
|
|
#ifdef PPC_DUMP_SPR_ACCESSES
|
|
|
|
TCGv_i32 t0 = tcg_const_i32(sprn);
|
|
|
|
gen_helper_load_dump_spr(cpu_env, t0);
|
|
|
|
tcg_temp_free_i32(t0);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2021-05-07 13:55:12 +02:00
|
|
|
void spr_read_generic(DisasContext *ctx, int gprn, int sprn)
|
2021-05-06 21:08:37 +02:00
|
|
|
{
|
|
|
|
gen_load_spr(cpu_gpr[gprn], sprn);
|
|
|
|
spr_load_dump_spr(sprn);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void spr_store_dump_spr(int sprn)
|
|
|
|
{
|
|
|
|
#ifdef PPC_DUMP_SPR_ACCESSES
|
|
|
|
TCGv_i32 t0 = tcg_const_i32(sprn);
|
|
|
|
gen_helper_store_dump_spr(cpu_env, t0);
|
|
|
|
tcg_temp_free_i32(t0);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2021-05-07 13:55:12 +02:00
|
|
|
void spr_write_generic(DisasContext *ctx, int sprn, int gprn)
|
2021-05-06 21:08:37 +02:00
|
|
|
{
|
|
|
|
gen_store_spr(sprn, cpu_gpr[gprn]);
|
|
|
|
spr_store_dump_spr(sprn);
|
|
|
|
}
|
|
|
|
|
|
|
|
#if !defined(CONFIG_USER_ONLY)
|
2021-05-07 13:55:12 +02:00
|
|
|
void spr_write_generic32(DisasContext *ctx, int sprn, int gprn)
|
2021-05-06 21:08:37 +02:00
|
|
|
{
|
|
|
|
#ifdef TARGET_PPC64
|
|
|
|
TCGv t0 = tcg_temp_new();
|
|
|
|
tcg_gen_ext32u_tl(t0, cpu_gpr[gprn]);
|
|
|
|
gen_store_spr(sprn, t0);
|
|
|
|
tcg_temp_free(t0);
|
|
|
|
spr_store_dump_spr(sprn);
|
|
|
|
#else
|
|
|
|
spr_write_generic(ctx, sprn, gprn);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2021-05-07 13:55:12 +02:00
|
|
|
void spr_write_clear(DisasContext *ctx, int sprn, int gprn)
|
2021-05-06 21:08:37 +02:00
|
|
|
{
|
|
|
|
TCGv t0 = tcg_temp_new();
|
|
|
|
TCGv t1 = tcg_temp_new();
|
|
|
|
gen_load_spr(t0, sprn);
|
|
|
|
tcg_gen_neg_tl(t1, cpu_gpr[gprn]);
|
|
|
|
tcg_gen_and_tl(t0, t0, t1);
|
|
|
|
gen_store_spr(sprn, t0);
|
|
|
|
tcg_temp_free(t0);
|
|
|
|
tcg_temp_free(t1);
|
|
|
|
}
|
|
|
|
|
2021-05-07 13:55:12 +02:00
|
|
|
void spr_access_nop(DisasContext *ctx, int sprn, int gprn)
|
2021-05-06 21:08:37 +02:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* SPR common to all PowerPC */
|
|
|
|
/* XER */
|
2021-05-07 13:55:12 +02:00
|
|
|
void spr_read_xer(DisasContext *ctx, int gprn, int sprn)
|
2021-05-06 21:08:37 +02:00
|
|
|
{
|
|
|
|
TCGv dst = cpu_gpr[gprn];
|
|
|
|
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);
|
|
|
|
if (is_isa300(ctx)) {
|
|
|
|
tcg_gen_shli_tl(t0, cpu_ov32, XER_OV32);
|
|
|
|
tcg_gen_or_tl(dst, dst, t0);
|
|
|
|
tcg_gen_shli_tl(t0, cpu_ca32, XER_CA32);
|
|
|
|
tcg_gen_or_tl(dst, dst, t0);
|
|
|
|
}
|
|
|
|
tcg_temp_free(t0);
|
|
|
|
tcg_temp_free(t1);
|
|
|
|
tcg_temp_free(t2);
|
|
|
|
}
|
|
|
|
|
2021-05-07 13:55:12 +02:00
|
|
|
void spr_write_xer(DisasContext *ctx, int sprn, int gprn)
|
2021-05-06 21:08:37 +02:00
|
|
|
{
|
|
|
|
TCGv src = cpu_gpr[gprn];
|
|
|
|
/* Write all flags, while reading back check for isa300 */
|
|
|
|
tcg_gen_andi_tl(cpu_xer, src,
|
|
|
|
~((1u << XER_SO) |
|
|
|
|
(1u << XER_OV) | (1u << XER_OV32) |
|
|
|
|
(1u << XER_CA) | (1u << XER_CA32)));
|
|
|
|
tcg_gen_extract_tl(cpu_ov32, src, XER_OV32, 1);
|
|
|
|
tcg_gen_extract_tl(cpu_ca32, src, XER_CA32, 1);
|
|
|
|
tcg_gen_extract_tl(cpu_so, src, XER_SO, 1);
|
|
|
|
tcg_gen_extract_tl(cpu_ov, src, XER_OV, 1);
|
|
|
|
tcg_gen_extract_tl(cpu_ca, src, XER_CA, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* LR */
|
2021-05-07 13:55:12 +02:00
|
|
|
void spr_read_lr(DisasContext *ctx, int gprn, int sprn)
|
2021-05-06 21:08:37 +02:00
|
|
|
{
|
|
|
|
tcg_gen_mov_tl(cpu_gpr[gprn], cpu_lr);
|
|
|
|
}
|
|
|
|
|
2021-05-07 13:55:12 +02:00
|
|
|
void spr_write_lr(DisasContext *ctx, int sprn, int gprn)
|
2021-05-06 21:08:37 +02:00
|
|
|
{
|
|
|
|
tcg_gen_mov_tl(cpu_lr, cpu_gpr[gprn]);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* CFAR */
|
|
|
|
#if defined(TARGET_PPC64) && !defined(CONFIG_USER_ONLY)
|
2021-05-07 13:55:12 +02:00
|
|
|
void spr_read_cfar(DisasContext *ctx, int gprn, int sprn)
|
2021-05-06 21:08:37 +02:00
|
|
|
{
|
|
|
|
tcg_gen_mov_tl(cpu_gpr[gprn], cpu_cfar);
|
|
|
|
}
|
|
|
|
|
2021-05-07 13:55:12 +02:00
|
|
|
void spr_write_cfar(DisasContext *ctx, int sprn, int gprn)
|
2021-05-06 21:08:37 +02:00
|
|
|
{
|
|
|
|
tcg_gen_mov_tl(cpu_cfar, cpu_gpr[gprn]);
|
|
|
|
}
|
|
|
|
#endif /* defined(TARGET_PPC64) && !defined(CONFIG_USER_ONLY) */
|
|
|
|
|
|
|
|
/* CTR */
|
2021-05-07 13:55:12 +02:00
|
|
|
void spr_read_ctr(DisasContext *ctx, int gprn, int sprn)
|
2021-05-06 21:08:37 +02:00
|
|
|
{
|
|
|
|
tcg_gen_mov_tl(cpu_gpr[gprn], cpu_ctr);
|
|
|
|
}
|
|
|
|
|
2021-05-07 13:55:12 +02:00
|
|
|
void spr_write_ctr(DisasContext *ctx, int sprn, int gprn)
|
2021-05-06 21:08:37 +02:00
|
|
|
{
|
|
|
|
tcg_gen_mov_tl(cpu_ctr, cpu_gpr[gprn]);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* User read access to SPR */
|
|
|
|
/* USPRx */
|
|
|
|
/* UMMCRx */
|
|
|
|
/* UPMCx */
|
|
|
|
/* USIA */
|
|
|
|
/* UDECR */
|
2021-05-07 13:55:12 +02:00
|
|
|
void spr_read_ureg(DisasContext *ctx, int gprn, int sprn)
|
2021-05-06 21:08:37 +02:00
|
|
|
{
|
|
|
|
gen_load_spr(cpu_gpr[gprn], sprn + 0x10);
|
|
|
|
}
|
|
|
|
|
|
|
|
#if defined(TARGET_PPC64) && !defined(CONFIG_USER_ONLY)
|
2021-05-07 13:55:12 +02:00
|
|
|
void spr_write_ureg(DisasContext *ctx, int sprn, int gprn)
|
2021-05-06 21:08:37 +02:00
|
|
|
{
|
|
|
|
gen_store_spr(sprn + 0x10, cpu_gpr[gprn]);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* SPR common to all non-embedded PowerPC */
|
|
|
|
/* DECR */
|
|
|
|
#if !defined(CONFIG_USER_ONLY)
|
2021-05-07 13:55:12 +02:00
|
|
|
void spr_read_decr(DisasContext *ctx, int gprn, int sprn)
|
2021-05-06 21:08:37 +02:00
|
|
|
{
|
2021-05-17 22:50:03 +02:00
|
|
|
gen_icount_io_start(ctx);
|
2021-05-06 21:08:37 +02:00
|
|
|
gen_helper_load_decr(cpu_gpr[gprn], cpu_env);
|
|
|
|
}
|
|
|
|
|
2021-05-07 13:55:12 +02:00
|
|
|
void spr_write_decr(DisasContext *ctx, int sprn, int gprn)
|
2021-05-06 21:08:37 +02:00
|
|
|
{
|
2021-05-17 22:50:03 +02:00
|
|
|
gen_icount_io_start(ctx);
|
2021-05-06 21:08:37 +02:00
|
|
|
gen_helper_store_decr(cpu_env, cpu_gpr[gprn]);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* SPR common to all non-embedded PowerPC, except 601 */
|
|
|
|
/* Time base */
|
2021-05-07 13:55:12 +02:00
|
|
|
void spr_read_tbl(DisasContext *ctx, int gprn, int sprn)
|
2021-05-06 21:08:37 +02:00
|
|
|
{
|
2021-05-17 22:50:03 +02:00
|
|
|
gen_icount_io_start(ctx);
|
2021-05-06 21:08:37 +02:00
|
|
|
gen_helper_load_tbl(cpu_gpr[gprn], cpu_env);
|
|
|
|
}
|
|
|
|
|
2021-05-07 13:55:12 +02:00
|
|
|
void spr_read_tbu(DisasContext *ctx, int gprn, int sprn)
|
2021-05-06 21:08:37 +02:00
|
|
|
{
|
2021-05-17 22:50:03 +02:00
|
|
|
gen_icount_io_start(ctx);
|
2021-05-06 21:08:37 +02:00
|
|
|
gen_helper_load_tbu(cpu_gpr[gprn], cpu_env);
|
|
|
|
}
|
|
|
|
|
2021-05-07 13:55:12 +02:00
|
|
|
void spr_read_atbl(DisasContext *ctx, int gprn, int sprn)
|
2021-05-06 21:08:37 +02:00
|
|
|
{
|
|
|
|
gen_helper_load_atbl(cpu_gpr[gprn], cpu_env);
|
|
|
|
}
|
|
|
|
|
2021-05-07 13:55:12 +02:00
|
|
|
void spr_read_atbu(DisasContext *ctx, int gprn, int sprn)
|
2021-05-06 21:08:37 +02:00
|
|
|
{
|
|
|
|
gen_helper_load_atbu(cpu_gpr[gprn], cpu_env);
|
|
|
|
}
|
|
|
|
|
|
|
|
#if !defined(CONFIG_USER_ONLY)
|
2021-05-07 13:55:12 +02:00
|
|
|
void spr_write_tbl(DisasContext *ctx, int sprn, int gprn)
|
2021-05-06 21:08:37 +02:00
|
|
|
{
|
2021-05-17 22:50:03 +02:00
|
|
|
gen_icount_io_start(ctx);
|
2021-05-06 21:08:37 +02:00
|
|
|
gen_helper_store_tbl(cpu_env, cpu_gpr[gprn]);
|
|
|
|
}
|
|
|
|
|
2021-05-07 13:55:12 +02:00
|
|
|
void spr_write_tbu(DisasContext *ctx, int sprn, int gprn)
|
2021-05-06 21:08:37 +02:00
|
|
|
{
|
2021-05-17 22:50:03 +02:00
|
|
|
gen_icount_io_start(ctx);
|
2021-05-06 21:08:37 +02:00
|
|
|
gen_helper_store_tbu(cpu_env, cpu_gpr[gprn]);
|
|
|
|
}
|
|
|
|
|
2021-05-07 13:55:12 +02:00
|
|
|
void spr_write_atbl(DisasContext *ctx, int sprn, int gprn)
|
2021-05-06 21:08:37 +02:00
|
|
|
{
|
|
|
|
gen_helper_store_atbl(cpu_env, cpu_gpr[gprn]);
|
|
|
|
}
|
|
|
|
|
2021-05-07 13:55:12 +02:00
|
|
|
void spr_write_atbu(DisasContext *ctx, int sprn, int gprn)
|
2021-05-06 21:08:37 +02:00
|
|
|
{
|
|
|
|
gen_helper_store_atbu(cpu_env, cpu_gpr[gprn]);
|
|
|
|
}
|
|
|
|
|
|
|
|
#if defined(TARGET_PPC64)
|
2021-05-07 13:55:12 +02:00
|
|
|
void spr_read_purr(DisasContext *ctx, int gprn, int sprn)
|
2021-05-06 21:08:37 +02:00
|
|
|
{
|
2021-05-17 22:50:03 +02:00
|
|
|
gen_icount_io_start(ctx);
|
2021-05-06 21:08:37 +02:00
|
|
|
gen_helper_load_purr(cpu_gpr[gprn], cpu_env);
|
|
|
|
}
|
|
|
|
|
2021-05-07 13:55:12 +02:00
|
|
|
void spr_write_purr(DisasContext *ctx, int sprn, int gprn)
|
2021-05-06 21:08:37 +02:00
|
|
|
{
|
2021-05-17 22:50:03 +02:00
|
|
|
gen_icount_io_start(ctx);
|
2021-05-06 21:08:37 +02:00
|
|
|
gen_helper_store_purr(cpu_env, cpu_gpr[gprn]);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* HDECR */
|
2021-05-07 13:55:12 +02:00
|
|
|
void spr_read_hdecr(DisasContext *ctx, int gprn, int sprn)
|
2021-05-06 21:08:37 +02:00
|
|
|
{
|
2021-05-17 22:50:03 +02:00
|
|
|
gen_icount_io_start(ctx);
|
2021-05-06 21:08:37 +02:00
|
|
|
gen_helper_load_hdecr(cpu_gpr[gprn], cpu_env);
|
|
|
|
}
|
|
|
|
|
2021-05-07 13:55:12 +02:00
|
|
|
void spr_write_hdecr(DisasContext *ctx, int sprn, int gprn)
|
2021-05-06 21:08:37 +02:00
|
|
|
{
|
2021-05-17 22:50:03 +02:00
|
|
|
gen_icount_io_start(ctx);
|
2021-05-06 21:08:37 +02:00
|
|
|
gen_helper_store_hdecr(cpu_env, cpu_gpr[gprn]);
|
|
|
|
}
|
|
|
|
|
2021-05-07 13:55:12 +02:00
|
|
|
void spr_read_vtb(DisasContext *ctx, int gprn, int sprn)
|
2021-05-06 21:08:37 +02:00
|
|
|
{
|
2021-05-17 22:50:03 +02:00
|
|
|
gen_icount_io_start(ctx);
|
2021-05-06 21:08:37 +02:00
|
|
|
gen_helper_load_vtb(cpu_gpr[gprn], cpu_env);
|
|
|
|
}
|
|
|
|
|
2021-05-07 13:55:12 +02:00
|
|
|
void spr_write_vtb(DisasContext *ctx, int sprn, int gprn)
|
2021-05-06 21:08:37 +02:00
|
|
|
{
|
2021-05-17 22:50:03 +02:00
|
|
|
gen_icount_io_start(ctx);
|
2021-05-06 21:08:37 +02:00
|
|
|
gen_helper_store_vtb(cpu_env, cpu_gpr[gprn]);
|
|
|
|
}
|
|
|
|
|
2021-05-07 13:55:12 +02:00
|
|
|
void spr_write_tbu40(DisasContext *ctx, int sprn, int gprn)
|
2021-05-06 21:08:37 +02:00
|
|
|
{
|
2021-05-17 22:50:03 +02:00
|
|
|
gen_icount_io_start(ctx);
|
2021-05-06 21:08:37 +02:00
|
|
|
gen_helper_store_tbu40(cpu_env, cpu_gpr[gprn]);
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if !defined(CONFIG_USER_ONLY)
|
|
|
|
/* IBAT0U...IBAT0U */
|
|
|
|
/* IBAT0L...IBAT7L */
|
2021-05-07 13:55:12 +02:00
|
|
|
void spr_read_ibat(DisasContext *ctx, int gprn, int sprn)
|
2021-05-06 21:08:37 +02:00
|
|
|
{
|
|
|
|
tcg_gen_ld_tl(cpu_gpr[gprn], cpu_env,
|
|
|
|
offsetof(CPUPPCState,
|
|
|
|
IBAT[sprn & 1][(sprn - SPR_IBAT0U) / 2]));
|
|
|
|
}
|
|
|
|
|
2021-05-07 13:55:12 +02:00
|
|
|
void spr_read_ibat_h(DisasContext *ctx, int gprn, int sprn)
|
2021-05-06 21:08:37 +02:00
|
|
|
{
|
|
|
|
tcg_gen_ld_tl(cpu_gpr[gprn], cpu_env,
|
|
|
|
offsetof(CPUPPCState,
|
|
|
|
IBAT[sprn & 1][((sprn - SPR_IBAT4U) / 2) + 4]));
|
|
|
|
}
|
|
|
|
|
2021-05-07 13:55:12 +02:00
|
|
|
void spr_write_ibatu(DisasContext *ctx, int sprn, int gprn)
|
2021-05-06 21:08:37 +02:00
|
|
|
{
|
|
|
|
TCGv_i32 t0 = tcg_const_i32((sprn - SPR_IBAT0U) / 2);
|
|
|
|
gen_helper_store_ibatu(cpu_env, t0, cpu_gpr[gprn]);
|
|
|
|
tcg_temp_free_i32(t0);
|
|
|
|
}
|
|
|
|
|
2021-05-07 13:55:12 +02:00
|
|
|
void spr_write_ibatu_h(DisasContext *ctx, int sprn, int gprn)
|
2021-05-06 21:08:37 +02:00
|
|
|
{
|
|
|
|
TCGv_i32 t0 = tcg_const_i32(((sprn - SPR_IBAT4U) / 2) + 4);
|
|
|
|
gen_helper_store_ibatu(cpu_env, t0, cpu_gpr[gprn]);
|
|
|
|
tcg_temp_free_i32(t0);
|
|
|
|
}
|
|
|
|
|
2021-05-07 13:55:12 +02:00
|
|
|
void spr_write_ibatl(DisasContext *ctx, int sprn, int gprn)
|
2021-05-06 21:08:37 +02:00
|
|
|
{
|
|
|
|
TCGv_i32 t0 = tcg_const_i32((sprn - SPR_IBAT0L) / 2);
|
|
|
|
gen_helper_store_ibatl(cpu_env, t0, cpu_gpr[gprn]);
|
|
|
|
tcg_temp_free_i32(t0);
|
|
|
|
}
|
|
|
|
|
2021-05-07 13:55:12 +02:00
|
|
|
void spr_write_ibatl_h(DisasContext *ctx, int sprn, int gprn)
|
2021-05-06 21:08:37 +02:00
|
|
|
{
|
|
|
|
TCGv_i32 t0 = tcg_const_i32(((sprn - SPR_IBAT4L) / 2) + 4);
|
|
|
|
gen_helper_store_ibatl(cpu_env, t0, cpu_gpr[gprn]);
|
|
|
|
tcg_temp_free_i32(t0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* DBAT0U...DBAT7U */
|
|
|
|
/* DBAT0L...DBAT7L */
|
2021-05-07 13:55:12 +02:00
|
|
|
void spr_read_dbat(DisasContext *ctx, int gprn, int sprn)
|
2021-05-06 21:08:37 +02:00
|
|
|
{
|
|
|
|
tcg_gen_ld_tl(cpu_gpr[gprn], cpu_env,
|
|
|
|
offsetof(CPUPPCState,
|
|
|
|
DBAT[sprn & 1][(sprn - SPR_DBAT0U) / 2]));
|
|
|
|
}
|
|
|
|
|
2021-05-07 13:55:12 +02:00
|
|
|
void spr_read_dbat_h(DisasContext *ctx, int gprn, int sprn)
|
2021-05-06 21:08:37 +02:00
|
|
|
{
|
|
|
|
tcg_gen_ld_tl(cpu_gpr[gprn], cpu_env,
|
|
|
|
offsetof(CPUPPCState,
|
|
|
|
DBAT[sprn & 1][((sprn - SPR_DBAT4U) / 2) + 4]));
|
|
|
|
}
|
|
|
|
|
2021-05-07 13:55:12 +02:00
|
|
|
void spr_write_dbatu(DisasContext *ctx, int sprn, int gprn)
|
2021-05-06 21:08:37 +02:00
|
|
|
{
|
|
|
|
TCGv_i32 t0 = tcg_const_i32((sprn - SPR_DBAT0U) / 2);
|
|
|
|
gen_helper_store_dbatu(cpu_env, t0, cpu_gpr[gprn]);
|
|
|
|
tcg_temp_free_i32(t0);
|
|
|
|
}
|
|
|
|
|
2021-05-07 13:55:12 +02:00
|
|
|
void spr_write_dbatu_h(DisasContext *ctx, int sprn, int gprn)
|
2021-05-06 21:08:37 +02:00
|
|
|
{
|
|
|
|
TCGv_i32 t0 = tcg_const_i32(((sprn - SPR_DBAT4U) / 2) + 4);
|
|
|
|
gen_helper_store_dbatu(cpu_env, t0, cpu_gpr[gprn]);
|
|
|
|
tcg_temp_free_i32(t0);
|
|
|
|
}
|
|
|
|
|
2021-05-07 13:55:12 +02:00
|
|
|
void spr_write_dbatl(DisasContext *ctx, int sprn, int gprn)
|
2021-05-06 21:08:37 +02:00
|
|
|
{
|
|
|
|
TCGv_i32 t0 = tcg_const_i32((sprn - SPR_DBAT0L) / 2);
|
|
|
|
gen_helper_store_dbatl(cpu_env, t0, cpu_gpr[gprn]);
|
|
|
|
tcg_temp_free_i32(t0);
|
|
|
|
}
|
|
|
|
|
2021-05-07 13:55:12 +02:00
|
|
|
void spr_write_dbatl_h(DisasContext *ctx, int sprn, int gprn)
|
2021-05-06 21:08:37 +02:00
|
|
|
{
|
|
|
|
TCGv_i32 t0 = tcg_const_i32(((sprn - SPR_DBAT4L) / 2) + 4);
|
|
|
|
gen_helper_store_dbatl(cpu_env, t0, cpu_gpr[gprn]);
|
|
|
|
tcg_temp_free_i32(t0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* SDR1 */
|
2021-05-07 13:55:12 +02:00
|
|
|
void spr_write_sdr1(DisasContext *ctx, int sprn, int gprn)
|
2021-05-06 21:08:37 +02:00
|
|
|
{
|
|
|
|
gen_helper_store_sdr1(cpu_env, cpu_gpr[gprn]);
|
|
|
|
}
|
|
|
|
|
|
|
|
#if defined(TARGET_PPC64)
|
|
|
|
/* 64 bits PowerPC specific SPRs */
|
|
|
|
/* PIDR */
|
2021-05-07 13:55:12 +02:00
|
|
|
void spr_write_pidr(DisasContext *ctx, int sprn, int gprn)
|
2021-05-06 21:08:37 +02:00
|
|
|
{
|
|
|
|
gen_helper_store_pidr(cpu_env, cpu_gpr[gprn]);
|
|
|
|
}
|
|
|
|
|
2021-05-07 13:55:12 +02:00
|
|
|
void spr_write_lpidr(DisasContext *ctx, int sprn, int gprn)
|
2021-05-06 21:08:37 +02:00
|
|
|
{
|
|
|
|
gen_helper_store_lpidr(cpu_env, cpu_gpr[gprn]);
|
|
|
|
}
|
|
|
|
|
2021-05-07 13:55:12 +02:00
|
|
|
void spr_read_hior(DisasContext *ctx, int gprn, int sprn)
|
2021-05-06 21:08:37 +02:00
|
|
|
{
|
|
|
|
tcg_gen_ld_tl(cpu_gpr[gprn], cpu_env, offsetof(CPUPPCState, excp_prefix));
|
|
|
|
}
|
|
|
|
|
2021-05-07 13:55:12 +02:00
|
|
|
void spr_write_hior(DisasContext *ctx, int sprn, int gprn)
|
2021-05-06 21:08:37 +02:00
|
|
|
{
|
|
|
|
TCGv t0 = tcg_temp_new();
|
|
|
|
tcg_gen_andi_tl(t0, cpu_gpr[gprn], 0x3FFFFF00000ULL);
|
|
|
|
tcg_gen_st_tl(t0, cpu_env, offsetof(CPUPPCState, excp_prefix));
|
|
|
|
tcg_temp_free(t0);
|
|
|
|
}
|
2021-05-07 13:55:12 +02:00
|
|
|
void spr_write_ptcr(DisasContext *ctx, int sprn, int gprn)
|
2021-05-06 21:08:37 +02:00
|
|
|
{
|
|
|
|
gen_helper_store_ptcr(cpu_env, cpu_gpr[gprn]);
|
|
|
|
}
|
|
|
|
|
2021-05-07 13:55:12 +02:00
|
|
|
void spr_write_pcr(DisasContext *ctx, int sprn, int gprn)
|
2021-05-06 21:08:37 +02:00
|
|
|
{
|
|
|
|
gen_helper_store_pcr(cpu_env, cpu_gpr[gprn]);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* DPDES */
|
2021-05-07 13:55:12 +02:00
|
|
|
void spr_read_dpdes(DisasContext *ctx, int gprn, int sprn)
|
2021-05-06 21:08:37 +02:00
|
|
|
{
|
|
|
|
gen_helper_load_dpdes(cpu_gpr[gprn], cpu_env);
|
|
|
|
}
|
|
|
|
|
2021-05-07 13:55:12 +02:00
|
|
|
void spr_write_dpdes(DisasContext *ctx, int sprn, int gprn)
|
2021-05-06 21:08:37 +02:00
|
|
|
{
|
|
|
|
gen_helper_store_dpdes(cpu_env, cpu_gpr[gprn]);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* PowerPC 601 specific registers */
|
|
|
|
/* RTC */
|
2021-05-07 13:55:12 +02:00
|
|
|
void spr_read_601_rtcl(DisasContext *ctx, int gprn, int sprn)
|
2021-05-06 21:08:37 +02:00
|
|
|
{
|
|
|
|
gen_helper_load_601_rtcl(cpu_gpr[gprn], cpu_env);
|
|
|
|
}
|
|
|
|
|
2021-05-07 13:55:12 +02:00
|
|
|
void spr_read_601_rtcu(DisasContext *ctx, int gprn, int sprn)
|
2021-05-06 21:08:37 +02:00
|
|
|
{
|
|
|
|
gen_helper_load_601_rtcu(cpu_gpr[gprn], cpu_env);
|
|
|
|
}
|
|
|
|
|
|
|
|
#if !defined(CONFIG_USER_ONLY)
|
2021-05-07 13:55:12 +02:00
|
|
|
void spr_write_601_rtcu(DisasContext *ctx, int sprn, int gprn)
|
2021-05-06 21:08:37 +02:00
|
|
|
{
|
|
|
|
gen_helper_store_601_rtcu(cpu_env, cpu_gpr[gprn]);
|
|
|
|
}
|
|
|
|
|
2021-05-07 13:55:12 +02:00
|
|
|
void spr_write_601_rtcl(DisasContext *ctx, int sprn, int gprn)
|
2021-05-06 21:08:37 +02:00
|
|
|
{
|
|
|
|
gen_helper_store_601_rtcl(cpu_env, cpu_gpr[gprn]);
|
|
|
|
}
|
|
|
|
|
2021-05-07 13:55:12 +02:00
|
|
|
void spr_write_hid0_601(DisasContext *ctx, int sprn, int gprn)
|
2021-05-06 21:08:37 +02:00
|
|
|
{
|
|
|
|
gen_helper_store_hid0_601(cpu_env, cpu_gpr[gprn]);
|
|
|
|
/* Must stop the translation as endianness may have changed */
|
2021-05-17 22:50:04 +02:00
|
|
|
ctx->base.is_jmp = DISAS_EXIT_UPDATE;
|
2021-05-06 21:08:37 +02:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* Unified bats */
|
|
|
|
#if !defined(CONFIG_USER_ONLY)
|
2021-05-07 13:55:12 +02:00
|
|
|
void spr_read_601_ubat(DisasContext *ctx, int gprn, int sprn)
|
2021-05-06 21:08:37 +02:00
|
|
|
{
|
|
|
|
tcg_gen_ld_tl(cpu_gpr[gprn], cpu_env,
|
|
|
|
offsetof(CPUPPCState,
|
|
|
|
IBAT[sprn & 1][(sprn - SPR_IBAT0U) / 2]));
|
|
|
|
}
|
|
|
|
|
2021-05-07 13:55:12 +02:00
|
|
|
void spr_write_601_ubatu(DisasContext *ctx, int sprn, int gprn)
|
2021-05-06 21:08:37 +02:00
|
|
|
{
|
|
|
|
TCGv_i32 t0 = tcg_const_i32((sprn - SPR_IBAT0U) / 2);
|
|
|
|
gen_helper_store_601_batl(cpu_env, t0, cpu_gpr[gprn]);
|
|
|
|
tcg_temp_free_i32(t0);
|
|
|
|
}
|
|
|
|
|
2021-05-07 13:55:12 +02:00
|
|
|
void spr_write_601_ubatl(DisasContext *ctx, int sprn, int gprn)
|
2021-05-06 21:08:37 +02:00
|
|
|
{
|
|
|
|
TCGv_i32 t0 = tcg_const_i32((sprn - SPR_IBAT0U) / 2);
|
|
|
|
gen_helper_store_601_batu(cpu_env, t0, cpu_gpr[gprn]);
|
|
|
|
tcg_temp_free_i32(t0);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* PowerPC 40x specific registers */
|
|
|
|
#if !defined(CONFIG_USER_ONLY)
|
2021-05-07 13:55:12 +02:00
|
|
|
void spr_read_40x_pit(DisasContext *ctx, int gprn, int sprn)
|
2021-05-06 21:08:37 +02:00
|
|
|
{
|
2021-05-17 22:50:03 +02:00
|
|
|
gen_icount_io_start(ctx);
|
2021-05-06 21:08:37 +02:00
|
|
|
gen_helper_load_40x_pit(cpu_gpr[gprn], cpu_env);
|
|
|
|
}
|
|
|
|
|
2021-05-07 13:55:12 +02:00
|
|
|
void spr_write_40x_pit(DisasContext *ctx, int sprn, int gprn)
|
2021-05-06 21:08:37 +02:00
|
|
|
{
|
2021-05-17 22:50:03 +02:00
|
|
|
gen_icount_io_start(ctx);
|
2021-05-06 21:08:37 +02:00
|
|
|
gen_helper_store_40x_pit(cpu_env, cpu_gpr[gprn]);
|
|
|
|
}
|
|
|
|
|
2021-05-07 13:55:12 +02:00
|
|
|
void spr_write_40x_dbcr0(DisasContext *ctx, int sprn, int gprn)
|
2021-05-06 21:08:37 +02:00
|
|
|
{
|
2021-05-17 22:50:03 +02:00
|
|
|
gen_icount_io_start(ctx);
|
2021-05-06 21:08:37 +02:00
|
|
|
gen_store_spr(sprn, cpu_gpr[gprn]);
|
|
|
|
gen_helper_store_40x_dbcr0(cpu_env, cpu_gpr[gprn]);
|
|
|
|
/* We must stop translation as we may have rebooted */
|
2021-05-17 22:50:04 +02:00
|
|
|
ctx->base.is_jmp = DISAS_EXIT_UPDATE;
|
2021-05-06 21:08:37 +02:00
|
|
|
}
|
|
|
|
|
2021-05-07 13:55:12 +02:00
|
|
|
void spr_write_40x_sler(DisasContext *ctx, int sprn, int gprn)
|
2021-05-06 21:08:37 +02:00
|
|
|
{
|
2021-05-17 22:50:03 +02:00
|
|
|
gen_icount_io_start(ctx);
|
2021-05-06 21:08:37 +02:00
|
|
|
gen_helper_store_40x_sler(cpu_env, cpu_gpr[gprn]);
|
|
|
|
}
|
|
|
|
|
2021-05-07 13:55:12 +02:00
|
|
|
void spr_write_booke_tcr(DisasContext *ctx, int sprn, int gprn)
|
2021-05-06 21:08:37 +02:00
|
|
|
{
|
2021-05-17 22:50:03 +02:00
|
|
|
gen_icount_io_start(ctx);
|
2021-05-06 21:08:37 +02:00
|
|
|
gen_helper_store_booke_tcr(cpu_env, cpu_gpr[gprn]);
|
|
|
|
}
|
|
|
|
|
2021-05-07 13:55:12 +02:00
|
|
|
void spr_write_booke_tsr(DisasContext *ctx, int sprn, int gprn)
|
2021-05-06 21:08:37 +02:00
|
|
|
{
|
2021-05-17 22:50:03 +02:00
|
|
|
gen_icount_io_start(ctx);
|
2021-05-06 21:08:37 +02:00
|
|
|
gen_helper_store_booke_tsr(cpu_env, cpu_gpr[gprn]);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* PowerPC 403 specific registers */
|
|
|
|
/* PBL1 / PBU1 / PBL2 / PBU2 */
|
|
|
|
#if !defined(CONFIG_USER_ONLY)
|
2021-05-07 13:55:12 +02:00
|
|
|
void spr_read_403_pbr(DisasContext *ctx, int gprn, int sprn)
|
2021-05-06 21:08:37 +02:00
|
|
|
{
|
|
|
|
tcg_gen_ld_tl(cpu_gpr[gprn], cpu_env,
|
|
|
|
offsetof(CPUPPCState, pb[sprn - SPR_403_PBL1]));
|
|
|
|
}
|
|
|
|
|
2021-05-07 13:55:12 +02:00
|
|
|
void spr_write_403_pbr(DisasContext *ctx, int sprn, int gprn)
|
2021-05-06 21:08:37 +02:00
|
|
|
{
|
|
|
|
TCGv_i32 t0 = tcg_const_i32(sprn - SPR_403_PBL1);
|
|
|
|
gen_helper_store_403_pbr(cpu_env, t0, cpu_gpr[gprn]);
|
|
|
|
tcg_temp_free_i32(t0);
|
|
|
|
}
|
|
|
|
|
2021-05-07 13:55:12 +02:00
|
|
|
void spr_write_pir(DisasContext *ctx, int sprn, int gprn)
|
2021-05-06 21:08:37 +02:00
|
|
|
{
|
|
|
|
TCGv t0 = tcg_temp_new();
|
|
|
|
tcg_gen_andi_tl(t0, cpu_gpr[gprn], 0xF);
|
|
|
|
gen_store_spr(SPR_PIR, t0);
|
|
|
|
tcg_temp_free(t0);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* SPE specific registers */
|
2021-05-07 13:55:12 +02:00
|
|
|
void spr_read_spefscr(DisasContext *ctx, int gprn, int sprn)
|
2021-05-06 21:08:37 +02:00
|
|
|
{
|
|
|
|
TCGv_i32 t0 = tcg_temp_new_i32();
|
|
|
|
tcg_gen_ld_i32(t0, cpu_env, offsetof(CPUPPCState, spe_fscr));
|
|
|
|
tcg_gen_extu_i32_tl(cpu_gpr[gprn], t0);
|
|
|
|
tcg_temp_free_i32(t0);
|
|
|
|
}
|
|
|
|
|
2021-05-07 13:55:12 +02:00
|
|
|
void spr_write_spefscr(DisasContext *ctx, int sprn, int gprn)
|
2021-05-06 21:08:37 +02:00
|
|
|
{
|
|
|
|
TCGv_i32 t0 = tcg_temp_new_i32();
|
|
|
|
tcg_gen_trunc_tl_i32(t0, cpu_gpr[gprn]);
|
|
|
|
tcg_gen_st_i32(t0, cpu_env, offsetof(CPUPPCState, spe_fscr));
|
|
|
|
tcg_temp_free_i32(t0);
|
|
|
|
}
|
|
|
|
|
|
|
|
#if !defined(CONFIG_USER_ONLY)
|
|
|
|
/* Callback used to write the exception vector base */
|
2021-05-07 13:55:12 +02:00
|
|
|
void spr_write_excp_prefix(DisasContext *ctx, int sprn, int gprn)
|
2021-05-06 21:08:37 +02:00
|
|
|
{
|
|
|
|
TCGv t0 = tcg_temp_new();
|
|
|
|
tcg_gen_ld_tl(t0, cpu_env, offsetof(CPUPPCState, ivpr_mask));
|
|
|
|
tcg_gen_and_tl(t0, t0, cpu_gpr[gprn]);
|
|
|
|
tcg_gen_st_tl(t0, cpu_env, offsetof(CPUPPCState, excp_prefix));
|
|
|
|
gen_store_spr(sprn, t0);
|
|
|
|
tcg_temp_free(t0);
|
|
|
|
}
|
|
|
|
|
2021-05-07 13:55:12 +02:00
|
|
|
void spr_write_excp_vector(DisasContext *ctx, int sprn, int gprn)
|
2021-05-06 21:08:37 +02:00
|
|
|
{
|
|
|
|
int sprn_offs;
|
|
|
|
|
|
|
|
if (sprn >= SPR_BOOKE_IVOR0 && sprn <= SPR_BOOKE_IVOR15) {
|
|
|
|
sprn_offs = sprn - SPR_BOOKE_IVOR0;
|
|
|
|
} else if (sprn >= SPR_BOOKE_IVOR32 && sprn <= SPR_BOOKE_IVOR37) {
|
|
|
|
sprn_offs = sprn - SPR_BOOKE_IVOR32 + 32;
|
|
|
|
} else if (sprn >= SPR_BOOKE_IVOR38 && sprn <= SPR_BOOKE_IVOR42) {
|
|
|
|
sprn_offs = sprn - SPR_BOOKE_IVOR38 + 38;
|
|
|
|
} else {
|
|
|
|
printf("Trying to write an unknown exception vector %d %03x\n",
|
|
|
|
sprn, sprn);
|
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
TCGv t0 = tcg_temp_new();
|
|
|
|
tcg_gen_ld_tl(t0, cpu_env, offsetof(CPUPPCState, ivor_mask));
|
|
|
|
tcg_gen_and_tl(t0, t0, cpu_gpr[gprn]);
|
|
|
|
tcg_gen_st_tl(t0, cpu_env, offsetof(CPUPPCState, excp_vectors[sprn_offs]));
|
|
|
|
gen_store_spr(sprn, t0);
|
|
|
|
tcg_temp_free(t0);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef TARGET_PPC64
|
|
|
|
#ifndef CONFIG_USER_ONLY
|
2021-05-07 13:55:12 +02:00
|
|
|
void spr_write_amr(DisasContext *ctx, int sprn, int gprn)
|
2021-05-06 21:08:37 +02:00
|
|
|
{
|
|
|
|
TCGv t0 = tcg_temp_new();
|
|
|
|
TCGv t1 = tcg_temp_new();
|
|
|
|
TCGv t2 = tcg_temp_new();
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Note, the HV=1 PR=0 case is handled earlier by simply using
|
|
|
|
* spr_write_generic for HV mode in the SPR table
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* Build insertion mask into t1 based on context */
|
|
|
|
if (ctx->pr) {
|
|
|
|
gen_load_spr(t1, SPR_UAMOR);
|
|
|
|
} else {
|
|
|
|
gen_load_spr(t1, SPR_AMOR);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Mask new bits into t2 */
|
|
|
|
tcg_gen_and_tl(t2, t1, cpu_gpr[gprn]);
|
|
|
|
|
|
|
|
/* Load AMR and clear new bits in t0 */
|
|
|
|
gen_load_spr(t0, SPR_AMR);
|
|
|
|
tcg_gen_andc_tl(t0, t0, t1);
|
|
|
|
|
|
|
|
/* Or'in new bits and write it out */
|
|
|
|
tcg_gen_or_tl(t0, t0, t2);
|
|
|
|
gen_store_spr(SPR_AMR, t0);
|
|
|
|
spr_store_dump_spr(SPR_AMR);
|
|
|
|
|
|
|
|
tcg_temp_free(t0);
|
|
|
|
tcg_temp_free(t1);
|
|
|
|
tcg_temp_free(t2);
|
|
|
|
}
|
|
|
|
|
2021-05-07 13:55:12 +02:00
|
|
|
void spr_write_uamor(DisasContext *ctx, int sprn, int gprn)
|
2021-05-06 21:08:37 +02:00
|
|
|
{
|
|
|
|
TCGv t0 = tcg_temp_new();
|
|
|
|
TCGv t1 = tcg_temp_new();
|
|
|
|
TCGv t2 = tcg_temp_new();
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Note, the HV=1 case is handled earlier by simply using
|
|
|
|
* spr_write_generic for HV mode in the SPR table
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* Build insertion mask into t1 based on context */
|
|
|
|
gen_load_spr(t1, SPR_AMOR);
|
|
|
|
|
|
|
|
/* Mask new bits into t2 */
|
|
|
|
tcg_gen_and_tl(t2, t1, cpu_gpr[gprn]);
|
|
|
|
|
|
|
|
/* Load AMR and clear new bits in t0 */
|
|
|
|
gen_load_spr(t0, SPR_UAMOR);
|
|
|
|
tcg_gen_andc_tl(t0, t0, t1);
|
|
|
|
|
|
|
|
/* Or'in new bits and write it out */
|
|
|
|
tcg_gen_or_tl(t0, t0, t2);
|
|
|
|
gen_store_spr(SPR_UAMOR, t0);
|
|
|
|
spr_store_dump_spr(SPR_UAMOR);
|
|
|
|
|
|
|
|
tcg_temp_free(t0);
|
|
|
|
tcg_temp_free(t1);
|
|
|
|
tcg_temp_free(t2);
|
|
|
|
}
|
|
|
|
|
2021-05-07 13:55:12 +02:00
|
|
|
void spr_write_iamr(DisasContext *ctx, int sprn, int gprn)
|
2021-05-06 21:08:37 +02:00
|
|
|
{
|
|
|
|
TCGv t0 = tcg_temp_new();
|
|
|
|
TCGv t1 = tcg_temp_new();
|
|
|
|
TCGv t2 = tcg_temp_new();
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Note, the HV=1 case is handled earlier by simply using
|
|
|
|
* spr_write_generic for HV mode in the SPR table
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* Build insertion mask into t1 based on context */
|
|
|
|
gen_load_spr(t1, SPR_AMOR);
|
|
|
|
|
|
|
|
/* Mask new bits into t2 */
|
|
|
|
tcg_gen_and_tl(t2, t1, cpu_gpr[gprn]);
|
|
|
|
|
|
|
|
/* Load AMR and clear new bits in t0 */
|
|
|
|
gen_load_spr(t0, SPR_IAMR);
|
|
|
|
tcg_gen_andc_tl(t0, t0, t1);
|
|
|
|
|
|
|
|
/* Or'in new bits and write it out */
|
|
|
|
tcg_gen_or_tl(t0, t0, t2);
|
|
|
|
gen_store_spr(SPR_IAMR, t0);
|
|
|
|
spr_store_dump_spr(SPR_IAMR);
|
|
|
|
|
|
|
|
tcg_temp_free(t0);
|
|
|
|
tcg_temp_free(t1);
|
|
|
|
tcg_temp_free(t2);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef CONFIG_USER_ONLY
|
2021-05-07 13:55:12 +02:00
|
|
|
void spr_read_thrm(DisasContext *ctx, int gprn, int sprn)
|
2021-05-06 21:08:37 +02:00
|
|
|
{
|
|
|
|
gen_helper_fixup_thrm(cpu_env);
|
|
|
|
gen_load_spr(cpu_gpr[gprn], sprn);
|
|
|
|
spr_load_dump_spr(sprn);
|
|
|
|
}
|
|
|
|
#endif /* !CONFIG_USER_ONLY */
|
|
|
|
|
|
|
|
#if !defined(CONFIG_USER_ONLY)
|
2021-05-07 13:55:12 +02:00
|
|
|
void spr_write_e500_l1csr0(DisasContext *ctx, int sprn, int gprn)
|
2021-05-06 21:08:37 +02:00
|
|
|
{
|
|
|
|
TCGv t0 = tcg_temp_new();
|
|
|
|
|
|
|
|
tcg_gen_andi_tl(t0, cpu_gpr[gprn], L1CSR0_DCE | L1CSR0_CPE);
|
|
|
|
gen_store_spr(sprn, t0);
|
|
|
|
tcg_temp_free(t0);
|
|
|
|
}
|
|
|
|
|
2021-05-07 13:55:12 +02:00
|
|
|
void spr_write_e500_l1csr1(DisasContext *ctx, int sprn, int gprn)
|
2021-05-06 21:08:37 +02:00
|
|
|
{
|
|
|
|
TCGv t0 = tcg_temp_new();
|
|
|
|
|
|
|
|
tcg_gen_andi_tl(t0, cpu_gpr[gprn], L1CSR1_ICE | L1CSR1_CPE);
|
|
|
|
gen_store_spr(sprn, t0);
|
|
|
|
tcg_temp_free(t0);
|
|
|
|
}
|
|
|
|
|
2021-05-07 13:55:12 +02:00
|
|
|
void spr_write_e500_l2csr0(DisasContext *ctx, int sprn, int gprn)
|
2021-05-06 21:08:37 +02:00
|
|
|
{
|
|
|
|
TCGv t0 = tcg_temp_new();
|
|
|
|
|
|
|
|
tcg_gen_andi_tl(t0, cpu_gpr[gprn],
|
|
|
|
~(E500_L2CSR0_L2FI | E500_L2CSR0_L2FL | E500_L2CSR0_L2LFC));
|
|
|
|
gen_store_spr(sprn, t0);
|
|
|
|
tcg_temp_free(t0);
|
|
|
|
}
|
|
|
|
|
2021-05-07 13:55:12 +02:00
|
|
|
void spr_write_booke206_mmucsr0(DisasContext *ctx, int sprn, int gprn)
|
2021-05-06 21:08:37 +02:00
|
|
|
{
|
|
|
|
gen_helper_booke206_tlbflush(cpu_env, cpu_gpr[gprn]);
|
|
|
|
}
|
|
|
|
|
2021-05-07 13:55:12 +02:00
|
|
|
void spr_write_booke_pid(DisasContext *ctx, int sprn, int gprn)
|
2021-05-06 21:08:37 +02:00
|
|
|
{
|
|
|
|
TCGv_i32 t0 = tcg_const_i32(sprn);
|
|
|
|
gen_helper_booke_setpid(cpu_env, t0, cpu_gpr[gprn]);
|
|
|
|
tcg_temp_free_i32(t0);
|
|
|
|
}
|
2021-05-07 13:55:12 +02:00
|
|
|
void spr_write_eplc(DisasContext *ctx, int sprn, int gprn)
|
2021-05-06 21:08:37 +02:00
|
|
|
{
|
|
|
|
gen_helper_booke_set_eplc(cpu_env, cpu_gpr[gprn]);
|
|
|
|
}
|
2021-05-07 13:55:12 +02:00
|
|
|
void spr_write_epsc(DisasContext *ctx, int sprn, int gprn)
|
2021-05-06 21:08:37 +02:00
|
|
|
{
|
|
|
|
gen_helper_booke_set_epsc(cpu_env, cpu_gpr[gprn]);
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if !defined(CONFIG_USER_ONLY)
|
2021-05-07 13:55:12 +02:00
|
|
|
void spr_write_mas73(DisasContext *ctx, int sprn, int gprn)
|
2021-05-06 21:08:37 +02:00
|
|
|
{
|
|
|
|
TCGv val = tcg_temp_new();
|
|
|
|
tcg_gen_ext32u_tl(val, cpu_gpr[gprn]);
|
|
|
|
gen_store_spr(SPR_BOOKE_MAS3, val);
|
|
|
|
tcg_gen_shri_tl(val, cpu_gpr[gprn], 32);
|
|
|
|
gen_store_spr(SPR_BOOKE_MAS7, val);
|
|
|
|
tcg_temp_free(val);
|
|
|
|
}
|
|
|
|
|
2021-05-07 13:55:12 +02:00
|
|
|
void spr_read_mas73(DisasContext *ctx, int gprn, int sprn)
|
2021-05-06 21:08:37 +02:00
|
|
|
{
|
|
|
|
TCGv mas7 = tcg_temp_new();
|
|
|
|
TCGv mas3 = tcg_temp_new();
|
|
|
|
gen_load_spr(mas7, SPR_BOOKE_MAS7);
|
|
|
|
tcg_gen_shli_tl(mas7, mas7, 32);
|
|
|
|
gen_load_spr(mas3, SPR_BOOKE_MAS3);
|
|
|
|
tcg_gen_or_tl(cpu_gpr[gprn], mas3, mas7);
|
|
|
|
tcg_temp_free(mas3);
|
|
|
|
tcg_temp_free(mas7);
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef TARGET_PPC64
|
|
|
|
static void gen_fscr_facility_check(DisasContext *ctx, int facility_sprn,
|
|
|
|
int bit, int sprn, int cause)
|
|
|
|
{
|
|
|
|
TCGv_i32 t1 = tcg_const_i32(bit);
|
|
|
|
TCGv_i32 t2 = tcg_const_i32(sprn);
|
|
|
|
TCGv_i32 t3 = tcg_const_i32(cause);
|
|
|
|
|
|
|
|
gen_helper_fscr_facility_check(cpu_env, t1, t2, t3);
|
|
|
|
|
|
|
|
tcg_temp_free_i32(t3);
|
|
|
|
tcg_temp_free_i32(t2);
|
|
|
|
tcg_temp_free_i32(t1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void gen_msr_facility_check(DisasContext *ctx, int facility_sprn,
|
|
|
|
int bit, int sprn, int cause)
|
|
|
|
{
|
|
|
|
TCGv_i32 t1 = tcg_const_i32(bit);
|
|
|
|
TCGv_i32 t2 = tcg_const_i32(sprn);
|
|
|
|
TCGv_i32 t3 = tcg_const_i32(cause);
|
|
|
|
|
|
|
|
gen_helper_msr_facility_check(cpu_env, t1, t2, t3);
|
|
|
|
|
|
|
|
tcg_temp_free_i32(t3);
|
|
|
|
tcg_temp_free_i32(t2);
|
|
|
|
tcg_temp_free_i32(t1);
|
|
|
|
}
|
|
|
|
|
2021-05-07 13:55:12 +02:00
|
|
|
void spr_read_prev_upper32(DisasContext *ctx, int gprn, int sprn)
|
2021-05-06 21:08:37 +02:00
|
|
|
{
|
|
|
|
TCGv spr_up = tcg_temp_new();
|
|
|
|
TCGv spr = tcg_temp_new();
|
|
|
|
|
|
|
|
gen_load_spr(spr, sprn - 1);
|
|
|
|
tcg_gen_shri_tl(spr_up, spr, 32);
|
|
|
|
tcg_gen_ext32u_tl(cpu_gpr[gprn], spr_up);
|
|
|
|
|
|
|
|
tcg_temp_free(spr);
|
|
|
|
tcg_temp_free(spr_up);
|
|
|
|
}
|
|
|
|
|
2021-05-07 13:55:12 +02:00
|
|
|
void spr_write_prev_upper32(DisasContext *ctx, int sprn, int gprn)
|
2021-05-06 21:08:37 +02:00
|
|
|
{
|
|
|
|
TCGv spr = tcg_temp_new();
|
|
|
|
|
|
|
|
gen_load_spr(spr, sprn - 1);
|
|
|
|
tcg_gen_deposit_tl(spr, spr, cpu_gpr[gprn], 32, 32);
|
|
|
|
gen_store_spr(sprn - 1, spr);
|
|
|
|
|
|
|
|
tcg_temp_free(spr);
|
|
|
|
}
|
|
|
|
|
|
|
|
#if !defined(CONFIG_USER_ONLY)
|
2021-05-07 13:55:12 +02:00
|
|
|
void spr_write_hmer(DisasContext *ctx, int sprn, int gprn)
|
2021-05-06 21:08:37 +02:00
|
|
|
{
|
|
|
|
TCGv hmer = tcg_temp_new();
|
|
|
|
|
|
|
|
gen_load_spr(hmer, sprn);
|
|
|
|
tcg_gen_and_tl(hmer, cpu_gpr[gprn], hmer);
|
|
|
|
gen_store_spr(sprn, hmer);
|
|
|
|
spr_store_dump_spr(sprn);
|
|
|
|
tcg_temp_free(hmer);
|
|
|
|
}
|
|
|
|
|
2021-05-07 13:55:12 +02:00
|
|
|
void spr_write_lpcr(DisasContext *ctx, int sprn, int gprn)
|
2021-05-06 21:08:37 +02:00
|
|
|
{
|
|
|
|
gen_helper_store_lpcr(cpu_env, cpu_gpr[gprn]);
|
|
|
|
}
|
|
|
|
#endif /* !defined(CONFIG_USER_ONLY) */
|
|
|
|
|
2021-05-07 13:55:12 +02:00
|
|
|
void spr_read_tar(DisasContext *ctx, int gprn, int sprn)
|
2021-05-06 21:08:37 +02:00
|
|
|
{
|
|
|
|
gen_fscr_facility_check(ctx, SPR_FSCR, FSCR_TAR, sprn, FSCR_IC_TAR);
|
|
|
|
spr_read_generic(ctx, gprn, sprn);
|
|
|
|
}
|
|
|
|
|
2021-05-07 13:55:12 +02:00
|
|
|
void spr_write_tar(DisasContext *ctx, int sprn, int gprn)
|
2021-05-06 21:08:37 +02:00
|
|
|
{
|
|
|
|
gen_fscr_facility_check(ctx, SPR_FSCR, FSCR_TAR, sprn, FSCR_IC_TAR);
|
|
|
|
spr_write_generic(ctx, sprn, gprn);
|
|
|
|
}
|
|
|
|
|
2021-05-07 13:55:12 +02:00
|
|
|
void spr_read_tm(DisasContext *ctx, int gprn, int sprn)
|
2021-05-06 21:08:37 +02:00
|
|
|
{
|
|
|
|
gen_msr_facility_check(ctx, SPR_FSCR, MSR_TM, sprn, FSCR_IC_TM);
|
|
|
|
spr_read_generic(ctx, gprn, sprn);
|
|
|
|
}
|
|
|
|
|
2021-05-07 13:55:12 +02:00
|
|
|
void spr_write_tm(DisasContext *ctx, int sprn, int gprn)
|
2021-05-06 21:08:37 +02:00
|
|
|
{
|
|
|
|
gen_msr_facility_check(ctx, SPR_FSCR, MSR_TM, sprn, FSCR_IC_TM);
|
|
|
|
spr_write_generic(ctx, sprn, gprn);
|
|
|
|
}
|
|
|
|
|
2021-05-07 13:55:12 +02:00
|
|
|
void spr_read_tm_upper32(DisasContext *ctx, int gprn, int sprn)
|
2021-05-06 21:08:37 +02:00
|
|
|
{
|
|
|
|
gen_msr_facility_check(ctx, SPR_FSCR, MSR_TM, sprn, FSCR_IC_TM);
|
|
|
|
spr_read_prev_upper32(ctx, gprn, sprn);
|
|
|
|
}
|
|
|
|
|
2021-05-07 13:55:12 +02:00
|
|
|
void spr_write_tm_upper32(DisasContext *ctx, int sprn, int gprn)
|
2021-05-06 21:08:37 +02:00
|
|
|
{
|
|
|
|
gen_msr_facility_check(ctx, SPR_FSCR, MSR_TM, sprn, FSCR_IC_TM);
|
|
|
|
spr_write_prev_upper32(ctx, sprn, gprn);
|
|
|
|
}
|
|
|
|
|
2021-05-07 13:55:12 +02:00
|
|
|
void spr_read_ebb(DisasContext *ctx, int gprn, int sprn)
|
2021-05-06 21:08:37 +02:00
|
|
|
{
|
|
|
|
gen_fscr_facility_check(ctx, SPR_FSCR, FSCR_EBB, sprn, FSCR_IC_EBB);
|
|
|
|
spr_read_generic(ctx, gprn, sprn);
|
|
|
|
}
|
|
|
|
|
2021-05-07 13:55:12 +02:00
|
|
|
void spr_write_ebb(DisasContext *ctx, int sprn, int gprn)
|
2021-05-06 21:08:37 +02:00
|
|
|
{
|
|
|
|
gen_fscr_facility_check(ctx, SPR_FSCR, FSCR_EBB, sprn, FSCR_IC_EBB);
|
|
|
|
spr_write_generic(ctx, sprn, gprn);
|
|
|
|
}
|
|
|
|
|
2021-05-07 13:55:12 +02:00
|
|
|
void spr_read_ebb_upper32(DisasContext *ctx, int gprn, int sprn)
|
2021-05-06 21:08:37 +02:00
|
|
|
{
|
|
|
|
gen_fscr_facility_check(ctx, SPR_FSCR, FSCR_EBB, sprn, FSCR_IC_EBB);
|
|
|
|
spr_read_prev_upper32(ctx, gprn, sprn);
|
|
|
|
}
|
|
|
|
|
2021-05-07 13:55:12 +02:00
|
|
|
void spr_write_ebb_upper32(DisasContext *ctx, int sprn, int gprn)
|
2021-05-06 21:08:37 +02:00
|
|
|
{
|
|
|
|
gen_fscr_facility_check(ctx, SPR_FSCR, FSCR_EBB, sprn, FSCR_IC_EBB);
|
|
|
|
spr_write_prev_upper32(ctx, sprn, gprn);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2003-11-23 15:55:54 +01:00
|
|
|
#define GEN_HANDLER(name, opc1, opc2, opc3, inval, type) \
|
2011-05-01 00:00:58 +02:00
|
|
|
GEN_OPCODE(name, opc1, opc2, opc3, inval, type, PPC_NONE)
|
|
|
|
|
|
|
|
#define GEN_HANDLER_E(name, opc1, opc2, opc3, inval, type, type2) \
|
|
|
|
GEN_OPCODE(name, opc1, opc2, opc3, inval, type, type2)
|
2003-11-23 15:55:54 +01:00
|
|
|
|
2007-10-26 02:46:07 +02:00
|
|
|
#define GEN_HANDLER2(name, onam, opc1, opc2, opc3, inval, type) \
|
2011-05-01 00:00:58 +02:00
|
|
|
GEN_OPCODE2(name, onam, opc1, opc2, opc3, inval, type, PPC_NONE)
|
|
|
|
|
|
|
|
#define GEN_HANDLER2_E(name, onam, opc1, opc2, opc3, inval, type, type2) \
|
|
|
|
GEN_OPCODE2(name, onam, opc1, opc2, opc3, inval, type, type2)
|
2007-10-26 02:46:07 +02:00
|
|
|
|
2016-07-26 13:58:38 +02:00
|
|
|
#define GEN_HANDLER_E_2(name, opc1, opc2, opc3, opc4, inval, type, type2) \
|
|
|
|
GEN_OPCODE3(name, opc1, opc2, opc3, opc4, inval, type, type2)
|
|
|
|
|
2016-10-19 08:06:47 +02:00
|
|
|
#define GEN_HANDLER2_E_2(name, onam, opc1, opc2, opc3, opc4, inval, typ, typ2) \
|
|
|
|
GEN_OPCODE4(name, onam, opc1, opc2, opc3, opc4, inval, typ, typ2)
|
|
|
|
|
2009-10-01 23:12:16 +02:00
|
|
|
typedef struct opcode_t {
|
2016-07-26 13:58:38 +02:00
|
|
|
unsigned char opc1, opc2, opc3, opc4;
|
2008-06-03 21:51:57 +02:00
|
|
|
#if HOST_LONG_BITS == 64 /* Explicitly align to 64 bits */
|
2016-07-26 13:58:38 +02:00
|
|
|
unsigned char pad[4];
|
2005-02-08 22:24:36 +01:00
|
|
|
#endif
|
2009-10-01 23:12:16 +02:00
|
|
|
opc_handler_t handler;
|
2008-09-20 10:07:15 +02:00
|
|
|
const char *oname;
|
2009-10-01 23:12:16 +02:00
|
|
|
} opcode_t;
|
2003-11-23 15:55:54 +01:00
|
|
|
|
2016-06-21 23:48:51 +02: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-21 23:48:52 +02:00
|
|
|
#define CHK_HVRM GEN_PRIV
|
2016-06-21 23:48:51 +02: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-21 23:48:52 +02:00
|
|
|
#define CHK_HVRM \
|
|
|
|
do { \
|
|
|
|
if (unlikely(ctx->pr || !ctx->hv || ctx->dr)) { \
|
|
|
|
GEN_PRIV; \
|
|
|
|
} \
|
|
|
|
} while (0)
|
2016-06-21 23:48:51 +02: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 01:54:22 +02:00
|
|
|
/*****************************************************************************/
|
|
|
|
/* PowerPC instructions table */
|
2004-07-10 17:33:29 +02:00
|
|
|
|
2011-05-01 00:00:58 +02:00
|
|
|
#define GEN_OPCODE(name, op1, op2, op3, invl, _typ, _typ2) \
|
2009-06-17 17:22:31 +02:00
|
|
|
{ \
|
2003-11-23 15:55:54 +01:00
|
|
|
.opc1 = op1, \
|
|
|
|
.opc2 = op2, \
|
|
|
|
.opc3 = op3, \
|
2016-07-26 13:58:38 +02:00
|
|
|
.opc4 = 0xff, \
|
2003-11-23 15:55:54 +01:00
|
|
|
.handler = { \
|
2011-09-28 07:54:05 +02:00
|
|
|
.inval1 = invl, \
|
|
|
|
.type = _typ, \
|
|
|
|
.type2 = _typ2, \
|
|
|
|
.handler = &gen_##name, \
|
|
|
|
}, \
|
|
|
|
.oname = stringify(name), \
|
|
|
|
}
|
|
|
|
#define GEN_OPCODE_DUAL(name, op1, op2, op3, invl1, invl2, _typ, _typ2) \
|
|
|
|
{ \
|
|
|
|
.opc1 = op1, \
|
|
|
|
.opc2 = op2, \
|
|
|
|
.opc3 = op3, \
|
2016-07-26 13:58:38 +02:00
|
|
|
.opc4 = 0xff, \
|
2011-09-28 07:54:05 +02:00
|
|
|
.handler = { \
|
|
|
|
.inval1 = invl1, \
|
|
|
|
.inval2 = invl2, \
|
2004-01-04 23:58:38 +01:00
|
|
|
.type = _typ, \
|
2011-05-01 00:00:58 +02:00
|
|
|
.type2 = _typ2, \
|
2003-11-23 15:55:54 +01:00
|
|
|
.handler = &gen_##name, \
|
|
|
|
}, \
|
2005-07-02 22:59:34 +02:00
|
|
|
.oname = stringify(name), \
|
2003-11-23 15:55:54 +01:00
|
|
|
}
|
2011-05-01 00:00:58 +02:00
|
|
|
#define GEN_OPCODE2(name, onam, op1, op2, op3, invl, _typ, _typ2) \
|
2009-06-17 17:22:31 +02:00
|
|
|
{ \
|
2007-10-26 02:46:07 +02:00
|
|
|
.opc1 = op1, \
|
|
|
|
.opc2 = op2, \
|
|
|
|
.opc3 = op3, \
|
2016-07-26 13:58:38 +02:00
|
|
|
.opc4 = 0xff, \
|
2007-10-26 02:46:07 +02:00
|
|
|
.handler = { \
|
2011-09-28 07:54:05 +02:00
|
|
|
.inval1 = invl, \
|
2007-10-26 02:46:07 +02:00
|
|
|
.type = _typ, \
|
2011-05-01 00:00:58 +02:00
|
|
|
.type2 = _typ2, \
|
2007-10-26 02:46:07 +02:00
|
|
|
.handler = &gen_##name, \
|
|
|
|
}, \
|
|
|
|
.oname = onam, \
|
|
|
|
}
|
2016-07-26 13:58:38 +02: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), \
|
|
|
|
}
|
2016-10-19 08:06:47 +02:00
|
|
|
#define GEN_OPCODE4(name, onam, 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 = onam, \
|
|
|
|
}
|
2009-06-17 17:22:24 +02:00
|
|
|
|
2009-06-17 17:22:19 +02:00
|
|
|
/* Invalid instruction */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_invalid(DisasContext *ctx)
|
2004-01-04 23:58:38 +01:00
|
|
|
{
|
2008-12-11 23:42:14 +01:00
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_INVAL_INVAL);
|
2004-01-04 23:58:38 +01:00
|
|
|
}
|
|
|
|
|
2009-10-01 23:12:16 +02:00
|
|
|
static opc_handler_t invalid_handler = {
|
2011-09-28 07:54:05 +02:00
|
|
|
.inval1 = 0xFFFFFFFF,
|
|
|
|
.inval2 = 0xFFFFFFFF,
|
2004-01-04 23:58:38 +01:00
|
|
|
.type = PPC_NONE,
|
2011-05-01 00:00:58 +02:00
|
|
|
.type2 = PPC_NONE,
|
2003-11-23 15:55:54 +01:00
|
|
|
.handler = gen_invalid,
|
|
|
|
};
|
|
|
|
|
2008-10-21 13:31:14 +02:00
|
|
|
/*** Integer comparison ***/
|
|
|
|
|
2009-08-16 11:06:54 +02:00
|
|
|
static inline void gen_op_cmp(TCGv arg0, TCGv arg1, int s, int crf)
|
2008-10-21 13:31:14 +02:00
|
|
|
{
|
2013-02-20 08:52:14 +01:00
|
|
|
TCGv t0 = tcg_temp_new();
|
2017-12-17 06:49:53 +01:00
|
|
|
TCGv t1 = tcg_temp_new();
|
|
|
|
TCGv_i32 t = tcg_temp_new_i32();
|
2008-10-21 13:31:14 +02:00
|
|
|
|
2017-12-17 06:49:53 +01:00
|
|
|
tcg_gen_movi_tl(t0, CRF_EQ);
|
|
|
|
tcg_gen_movi_tl(t1, CRF_LT);
|
2019-03-21 12:57:28 +01:00
|
|
|
tcg_gen_movcond_tl((s ? TCG_COND_LT : TCG_COND_LTU),
|
|
|
|
t0, arg0, arg1, t1, t0);
|
2017-12-17 06:49:53 +01:00
|
|
|
tcg_gen_movi_tl(t1, CRF_GT);
|
2019-03-21 12:57:28 +01:00
|
|
|
tcg_gen_movcond_tl((s ? TCG_COND_GT : TCG_COND_GTU),
|
|
|
|
t0, arg0, arg1, t1, t0);
|
2013-02-20 08:52:14 +01:00
|
|
|
|
2017-12-17 06:49:53 +01:00
|
|
|
tcg_gen_trunc_tl_i32(t, t0);
|
|
|
|
tcg_gen_trunc_tl_i32(cpu_crf[crf], cpu_so);
|
|
|
|
tcg_gen_or_i32(cpu_crf[crf], cpu_crf[crf], t);
|
2013-02-20 08:52:14 +01:00
|
|
|
|
|
|
|
tcg_temp_free(t0);
|
2017-12-17 06:49:53 +01:00
|
|
|
tcg_temp_free(t1);
|
|
|
|
tcg_temp_free_i32(t);
|
2008-10-21 13:31:14 +02:00
|
|
|
}
|
|
|
|
|
2009-08-16 11:06:54 +02:00
|
|
|
static inline void gen_op_cmpi(TCGv arg0, target_ulong arg1, int s, int crf)
|
2008-10-21 13:31:14 +02:00
|
|
|
{
|
2013-02-20 08:52:14 +01:00
|
|
|
TCGv t0 = tcg_const_tl(arg1);
|
2008-10-27 23:50:39 +01:00
|
|
|
gen_op_cmp(arg0, t0, s, crf);
|
|
|
|
tcg_temp_free(t0);
|
2008-10-21 13:31:14 +02:00
|
|
|
}
|
|
|
|
|
2009-08-16 11:06:54 +02:00
|
|
|
static inline void gen_op_cmp32(TCGv arg0, TCGv arg1, int s, int crf)
|
2008-10-21 13:31:14 +02:00
|
|
|
{
|
2008-10-27 23:50:39 +01:00
|
|
|
TCGv t0, t1;
|
2013-02-20 08:52:14 +01:00
|
|
|
t0 = tcg_temp_new();
|
|
|
|
t1 = tcg_temp_new();
|
2008-10-21 13:31:14 +02:00
|
|
|
if (s) {
|
2008-10-27 23:50:39 +01:00
|
|
|
tcg_gen_ext32s_tl(t0, arg0);
|
|
|
|
tcg_gen_ext32s_tl(t1, arg1);
|
2008-10-21 13:31:14 +02:00
|
|
|
} else {
|
2008-10-27 23:50:39 +01:00
|
|
|
tcg_gen_ext32u_tl(t0, arg0);
|
|
|
|
tcg_gen_ext32u_tl(t1, arg1);
|
2008-10-21 13:31:14 +02:00
|
|
|
}
|
2008-10-27 23:50:39 +01:00
|
|
|
gen_op_cmp(t0, t1, s, crf);
|
|
|
|
tcg_temp_free(t1);
|
|
|
|
tcg_temp_free(t0);
|
2008-10-21 13:31:14 +02:00
|
|
|
}
|
|
|
|
|
2009-08-16 11:06:54 +02:00
|
|
|
static inline void gen_op_cmpi32(TCGv arg0, target_ulong arg1, int s, int crf)
|
2008-10-21 13:31:14 +02:00
|
|
|
{
|
2013-02-20 08:52:14 +01:00
|
|
|
TCGv t0 = tcg_const_tl(arg1);
|
2008-10-27 23:50:39 +01:00
|
|
|
gen_op_cmp32(arg0, t0, s, crf);
|
|
|
|
tcg_temp_free(t0);
|
2008-10-21 13:31:14 +02:00
|
|
|
}
|
|
|
|
|
2009-08-16 11:06:54 +02:00
|
|
|
static inline void gen_set_Rc0(DisasContext *ctx, TCGv reg)
|
2008-10-21 13:31:14 +02:00
|
|
|
{
|
2013-03-21 11:01:47 +01:00
|
|
|
if (NARROW_MODE(ctx)) {
|
2008-10-21 13:31:14 +02:00
|
|
|
gen_op_cmpi32(reg, 0, 1, 0);
|
2013-03-21 11:01:47 +01:00
|
|
|
} else {
|
2008-10-21 13:31:14 +02:00
|
|
|
gen_op_cmpi(reg, 0, 1, 0);
|
2013-03-21 11:01:47 +01:00
|
|
|
}
|
2008-10-21 13:31:14 +02:00
|
|
|
}
|
|
|
|
|
2016-07-26 13:58:27 +02: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);
|
|
|
|
}
|
2016-11-23 12:37:11 +01:00
|
|
|
tcg_gen_shli_i32(crf, crf, CRF_GT_BIT);
|
2016-07-26 13:58:27 +02:00
|
|
|
tcg_temp_free_i32(src1);
|
|
|
|
tcg_temp_free_i32(src2);
|
|
|
|
tcg_temp_free_i32(src2lo);
|
|
|
|
tcg_temp_free_i32(src2hi);
|
|
|
|
}
|
|
|
|
|
2016-07-26 13:58:34 +02: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 13:31:14 +02:00
|
|
|
/* isel (PowerPC 2.03 specification) */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_isel(DisasContext *ctx)
|
2008-10-21 13:31:14 +02:00
|
|
|
{
|
|
|
|
uint32_t bi = rC(ctx->opcode);
|
2016-02-24 02:18:34 +01:00
|
|
|
uint32_t mask = 0x08 >> (bi & 0x03);
|
|
|
|
TCGv t0 = tcg_temp_new();
|
|
|
|
TCGv zr;
|
2008-10-21 13:31:14 +02:00
|
|
|
|
2016-02-24 02:18:34 +01: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 13:31:14 +02:00
|
|
|
}
|
|
|
|
|
2013-04-20 10:56:16 +02:00
|
|
|
/* cmpb: PowerPC 2.05 specification */
|
|
|
|
static void gen_cmpb(DisasContext *ctx)
|
|
|
|
{
|
|
|
|
gen_helper_cmpb(cpu_gpr[rA(ctx->opcode)], cpu_gpr[rS(ctx->opcode)],
|
|
|
|
cpu_gpr[rB(ctx->opcode)]);
|
|
|
|
}
|
|
|
|
|
2003-11-23 15:55:54 +01:00
|
|
|
/*** Integer arithmetic ***/
|
|
|
|
|
2009-08-16 11:06:54 +02:00
|
|
|
static inline void gen_op_arith_compute_ov(DisasContext *ctx, TCGv arg0,
|
|
|
|
TCGv arg1, TCGv arg2, int sub)
|
2008-11-01 01:54:12 +01:00
|
|
|
{
|
2013-02-20 08:52:15 +01:00
|
|
|
TCGv t0 = tcg_temp_new();
|
2003-11-23 15:55:54 +01:00
|
|
|
|
2013-03-31 16:33:16 +02:00
|
|
|
tcg_gen_xor_tl(cpu_ov, arg0, arg2);
|
2008-11-01 01:54:12 +01:00
|
|
|
tcg_gen_xor_tl(t0, arg1, arg2);
|
2013-02-20 08:52:15 +01:00
|
|
|
if (sub) {
|
|
|
|
tcg_gen_and_tl(cpu_ov, cpu_ov, t0);
|
|
|
|
} else {
|
|
|
|
tcg_gen_andc_tl(cpu_ov, cpu_ov, t0);
|
|
|
|
}
|
|
|
|
tcg_temp_free(t0);
|
2013-03-21 11:01:47 +01:00
|
|
|
if (NARROW_MODE(ctx)) {
|
2017-02-27 05:57:57 +01:00
|
|
|
tcg_gen_extract_tl(cpu_ov, cpu_ov, 31, 1);
|
|
|
|
if (is_isa300(ctx)) {
|
|
|
|
tcg_gen_mov_tl(cpu_ov32, cpu_ov);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (is_isa300(ctx)) {
|
|
|
|
tcg_gen_extract_tl(cpu_ov32, cpu_ov, 31, 1);
|
|
|
|
}
|
2017-03-13 10:31:04 +01:00
|
|
|
tcg_gen_extract_tl(cpu_ov, cpu_ov, TARGET_LONG_BITS - 1, 1);
|
2013-02-20 08:52:15 +01:00
|
|
|
}
|
|
|
|
tcg_gen_or_tl(cpu_so, cpu_so, cpu_ov);
|
2003-11-23 15:55:54 +01:00
|
|
|
}
|
|
|
|
|
2017-02-27 05:57:55 +01:00
|
|
|
static inline void gen_op_arith_compute_ca32(DisasContext *ctx,
|
|
|
|
TCGv res, TCGv arg0, TCGv arg1,
|
2018-11-15 04:22:59 +01:00
|
|
|
TCGv ca32, int sub)
|
2017-02-27 05:57:55 +01:00
|
|
|
{
|
|
|
|
TCGv t0;
|
|
|
|
|
|
|
|
if (!is_isa300(ctx)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
t0 = tcg_temp_new();
|
2017-02-27 05:57:56 +01:00
|
|
|
if (sub) {
|
|
|
|
tcg_gen_eqv_tl(t0, arg0, arg1);
|
|
|
|
} else {
|
|
|
|
tcg_gen_xor_tl(t0, arg0, arg1);
|
|
|
|
}
|
2017-02-27 05:57:55 +01:00
|
|
|
tcg_gen_xor_tl(t0, t0, res);
|
2018-11-15 04:22:59 +01:00
|
|
|
tcg_gen_extract_tl(ca32, t0, 32, 1);
|
2017-02-27 05:57:55 +01:00
|
|
|
tcg_temp_free(t0);
|
|
|
|
}
|
|
|
|
|
2008-11-01 01:54:12 +01:00
|
|
|
/* Common add function */
|
2009-08-16 11:06:54 +02:00
|
|
|
static inline void gen_op_arith_add(DisasContext *ctx, TCGv ret, TCGv arg1,
|
2018-11-15 04:22:59 +01:00
|
|
|
TCGv arg2, TCGv ca, TCGv ca32,
|
|
|
|
bool add_ca, bool compute_ca,
|
2013-02-20 08:52:17 +01:00
|
|
|
bool compute_ov, bool compute_rc0)
|
2008-11-01 01:54:12 +01:00
|
|
|
{
|
2013-02-20 08:52:17 +01:00
|
|
|
TCGv t0 = ret;
|
2007-03-17 15:02:15 +01:00
|
|
|
|
2013-04-03 12:56:45 +02:00
|
|
|
if (compute_ca || compute_ov) {
|
2013-02-20 08:52:16 +01:00
|
|
|
t0 = tcg_temp_new();
|
2008-11-01 01:54:12 +01:00
|
|
|
}
|
2003-11-23 15:55:54 +01:00
|
|
|
|
2013-02-20 08:52:13 +01:00
|
|
|
if (compute_ca) {
|
2013-03-21 11:01:45 +01:00
|
|
|
if (NARROW_MODE(ctx)) {
|
2019-03-21 12:57:28 +01:00
|
|
|
/*
|
|
|
|
* Caution: a non-obvious corner case of the spec is that
|
|
|
|
* we must produce the *entire* 64-bit addition, but
|
|
|
|
* produce the carry into bit 32.
|
|
|
|
*/
|
2013-03-21 11:01:45 +01:00
|
|
|
TCGv t1 = tcg_temp_new();
|
2013-04-03 12:56:45 +02:00
|
|
|
tcg_gen_xor_tl(t1, arg1, arg2); /* add without carry */
|
|
|
|
tcg_gen_add_tl(t0, arg1, arg2);
|
2013-03-21 11:01:45 +01:00
|
|
|
if (add_ca) {
|
2018-11-15 04:22:59 +01:00
|
|
|
tcg_gen_add_tl(t0, t0, ca);
|
2013-03-21 11:01:45 +01:00
|
|
|
}
|
2018-11-15 04:22:59 +01:00
|
|
|
tcg_gen_xor_tl(ca, t0, t1); /* bits changed w/ carry */
|
2013-04-03 12:56:45 +02:00
|
|
|
tcg_temp_free(t1);
|
2018-11-15 04:22:59 +01:00
|
|
|
tcg_gen_extract_tl(ca, ca, 32, 1);
|
2017-02-27 05:57:55 +01:00
|
|
|
if (is_isa300(ctx)) {
|
2018-11-15 04:22:59 +01:00
|
|
|
tcg_gen_mov_tl(ca32, ca);
|
2017-02-27 05:57:55 +01:00
|
|
|
}
|
2013-02-20 08:52:17 +01:00
|
|
|
} else {
|
2013-03-21 11:01:45 +01:00
|
|
|
TCGv zero = tcg_const_tl(0);
|
|
|
|
if (add_ca) {
|
2018-11-15 04:22:59 +01:00
|
|
|
tcg_gen_add2_tl(t0, ca, arg1, zero, ca, zero);
|
|
|
|
tcg_gen_add2_tl(t0, ca, t0, ca, arg2, zero);
|
2013-03-21 11:01:45 +01:00
|
|
|
} else {
|
2018-11-15 04:22:59 +01:00
|
|
|
tcg_gen_add2_tl(t0, ca, arg1, zero, arg2, zero);
|
2013-03-21 11:01:45 +01:00
|
|
|
}
|
2018-11-15 04:22:59 +01:00
|
|
|
gen_op_arith_compute_ca32(ctx, t0, arg1, arg2, ca32, 0);
|
2013-03-21 11:01:45 +01:00
|
|
|
tcg_temp_free(zero);
|
2013-02-20 08:52:17 +01:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
tcg_gen_add_tl(t0, arg1, arg2);
|
|
|
|
if (add_ca) {
|
2018-11-15 04:22:59 +01:00
|
|
|
tcg_gen_add_tl(t0, t0, ca);
|
2013-02-20 08:52:17 +01:00
|
|
|
}
|
2013-02-20 08:52:13 +01:00
|
|
|
}
|
2003-11-23 15:55:54 +01:00
|
|
|
|
2008-11-01 01:54:12 +01:00
|
|
|
if (compute_ov) {
|
|
|
|
gen_op_arith_compute_ov(ctx, t0, arg1, arg2, 0);
|
|
|
|
}
|
2013-02-20 08:52:17 +01:00
|
|
|
if (unlikely(compute_rc0)) {
|
2008-11-01 01:54:12 +01:00
|
|
|
gen_set_Rc0(ctx, t0);
|
2013-02-20 08:52:17 +01:00
|
|
|
}
|
2008-11-01 01:54:12 +01:00
|
|
|
|
2017-10-20 05:27:27 +02:00
|
|
|
if (t0 != ret) {
|
2008-11-01 01:54:12 +01:00
|
|
|
tcg_gen_mov_tl(ret, t0);
|
|
|
|
tcg_temp_free(t0);
|
|
|
|
}
|
2008-09-05 16:19:43 +02:00
|
|
|
}
|
2008-11-01 01:54:12 +01:00
|
|
|
/* Add functions with two operands */
|
2018-11-15 04:22:59 +01:00
|
|
|
#define GEN_INT_ARITH_ADD(name, opc3, ca, add_ca, compute_ca, compute_ov) \
|
2013-02-20 08:52:17 +01:00
|
|
|
static void glue(gen_, name)(DisasContext *ctx) \
|
2008-11-01 01:54:12 +01:00
|
|
|
{ \
|
|
|
|
gen_op_arith_add(ctx, cpu_gpr[rD(ctx->opcode)], \
|
|
|
|
cpu_gpr[rA(ctx->opcode)], cpu_gpr[rB(ctx->opcode)], \
|
2018-11-15 04:22:59 +01:00
|
|
|
ca, glue(ca, 32), \
|
2013-02-20 08:52:17 +01:00
|
|
|
add_ca, compute_ca, compute_ov, Rc(ctx->opcode)); \
|
2008-11-01 01:54:12 +01:00
|
|
|
}
|
|
|
|
/* Add functions with one operand and one immediate */
|
2018-11-15 04:22:59 +01:00
|
|
|
#define GEN_INT_ARITH_ADD_CONST(name, opc3, const_val, ca, \
|
2008-11-01 01:54:12 +01:00
|
|
|
add_ca, compute_ca, compute_ov) \
|
2013-02-20 08:52:17 +01:00
|
|
|
static void glue(gen_, name)(DisasContext *ctx) \
|
2008-11-01 01:54:12 +01:00
|
|
|
{ \
|
2013-02-20 08:52:17 +01:00
|
|
|
TCGv t0 = tcg_const_tl(const_val); \
|
2008-11-01 01:54:12 +01:00
|
|
|
gen_op_arith_add(ctx, cpu_gpr[rD(ctx->opcode)], \
|
|
|
|
cpu_gpr[rA(ctx->opcode)], t0, \
|
2018-11-15 04:22:59 +01:00
|
|
|
ca, glue(ca, 32), \
|
2013-02-20 08:52:17 +01:00
|
|
|
add_ca, compute_ca, compute_ov, Rc(ctx->opcode)); \
|
2008-11-01 01:54:12 +01:00
|
|
|
tcg_temp_free(t0); \
|
|
|
|
}
|
|
|
|
|
|
|
|
/* add add. addo addo. */
|
2018-11-15 04:22:59 +01:00
|
|
|
GEN_INT_ARITH_ADD(add, 0x08, cpu_ca, 0, 0, 0)
|
|
|
|
GEN_INT_ARITH_ADD(addo, 0x18, cpu_ca, 0, 0, 1)
|
2008-11-01 01:54:12 +01:00
|
|
|
/* addc addc. addco addco. */
|
2018-11-15 04:22:59 +01:00
|
|
|
GEN_INT_ARITH_ADD(addc, 0x00, cpu_ca, 0, 1, 0)
|
|
|
|
GEN_INT_ARITH_ADD(addco, 0x10, cpu_ca, 0, 1, 1)
|
2008-11-01 01:54:12 +01:00
|
|
|
/* adde adde. addeo addeo. */
|
2018-11-15 04:22:59 +01:00
|
|
|
GEN_INT_ARITH_ADD(adde, 0x04, cpu_ca, 1, 1, 0)
|
|
|
|
GEN_INT_ARITH_ADD(addeo, 0x14, cpu_ca, 1, 1, 1)
|
2008-11-01 01:54:12 +01:00
|
|
|
/* addme addme. addmeo addmeo. */
|
2018-11-15 04:22:59 +01:00
|
|
|
GEN_INT_ARITH_ADD_CONST(addme, 0x07, -1LL, cpu_ca, 1, 1, 0)
|
|
|
|
GEN_INT_ARITH_ADD_CONST(addmeo, 0x17, -1LL, cpu_ca, 1, 1, 1)
|
|
|
|
/* addex */
|
|
|
|
GEN_INT_ARITH_ADD(addex, 0x05, cpu_ov, 1, 1, 0);
|
2008-11-01 01:54:12 +01:00
|
|
|
/* addze addze. addzeo addzeo.*/
|
2018-11-15 04:22:59 +01:00
|
|
|
GEN_INT_ARITH_ADD_CONST(addze, 0x06, 0, cpu_ca, 1, 1, 0)
|
|
|
|
GEN_INT_ARITH_ADD_CONST(addzeo, 0x16, 0, cpu_ca, 1, 1, 1)
|
2008-11-01 01:54:12 +01:00
|
|
|
/* addic addic.*/
|
2013-02-20 08:52:17 +01:00
|
|
|
static inline void gen_op_addic(DisasContext *ctx, bool compute_rc0)
|
2007-03-17 15:02:15 +01:00
|
|
|
{
|
2013-02-20 08:52:17 +01:00
|
|
|
TCGv c = tcg_const_tl(SIMM(ctx->opcode));
|
|
|
|
gen_op_arith_add(ctx, cpu_gpr[rD(ctx->opcode)], cpu_gpr[rA(ctx->opcode)],
|
2018-11-15 04:22:59 +01:00
|
|
|
c, cpu_ca, cpu_ca32, 0, 1, 0, compute_rc0);
|
2013-02-20 08:52:17 +01:00
|
|
|
tcg_temp_free(c);
|
2007-03-17 15:02:15 +01:00
|
|
|
}
|
2009-06-17 17:22:09 +02:00
|
|
|
|
|
|
|
static void gen_addic(DisasContext *ctx)
|
2007-03-17 15:02:15 +01:00
|
|
|
{
|
2013-02-20 08:52:17 +01:00
|
|
|
gen_op_addic(ctx, 0);
|
2007-03-17 15:02:15 +01:00
|
|
|
}
|
2009-06-17 17:22:14 +02:00
|
|
|
|
|
|
|
static void gen_addic_(DisasContext *ctx)
|
2007-03-17 15:02:15 +01:00
|
|
|
{
|
2013-02-20 08:52:17 +01:00
|
|
|
gen_op_addic(ctx, 1);
|
2007-03-17 15:02:15 +01:00
|
|
|
}
|
2009-06-17 17:22:09 +02:00
|
|
|
|
2009-08-16 11:06:54 +02:00
|
|
|
static inline void gen_op_arith_divw(DisasContext *ctx, TCGv ret, TCGv arg1,
|
|
|
|
TCGv arg2, int sign, int compute_ov)
|
2007-03-17 15:02:15 +01:00
|
|
|
{
|
2016-07-28 20:14:11 +02: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 01:54:12 +01:00
|
|
|
|
2008-11-09 18:27:19 +01:00
|
|
|
tcg_gen_trunc_tl_i32(t0, arg1);
|
|
|
|
tcg_gen_trunc_tl_i32(t1, arg2);
|
2008-11-01 01:54:12 +01:00
|
|
|
if (sign) {
|
2016-07-28 20:14:11 +02: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 01:54:12 +01:00
|
|
|
} else {
|
2016-07-28 20:14:11 +02: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 01:54:12 +01:00
|
|
|
}
|
|
|
|
if (compute_ov) {
|
2016-07-28 20:14:11 +02:00
|
|
|
tcg_gen_extu_i32_tl(cpu_ov, t2);
|
2017-02-27 05:58:00 +01:00
|
|
|
if (is_isa300(ctx)) {
|
|
|
|
tcg_gen_extu_i32_tl(cpu_ov32, t2);
|
|
|
|
}
|
2016-07-28 20:14:11 +02:00
|
|
|
tcg_gen_or_tl(cpu_so, cpu_so, cpu_ov);
|
2008-11-01 01:54:12 +01:00
|
|
|
}
|
2008-11-17 15:43:54 +01:00
|
|
|
tcg_temp_free_i32(t0);
|
|
|
|
tcg_temp_free_i32(t1);
|
2016-07-28 20:14:11 +02:00
|
|
|
tcg_temp_free_i32(t2);
|
|
|
|
tcg_temp_free_i32(t3);
|
|
|
|
|
2019-03-21 12:57:28 +01:00
|
|
|
if (unlikely(Rc(ctx->opcode) != 0)) {
|
2008-11-01 01:54:12 +01:00
|
|
|
gen_set_Rc0(ctx, ret);
|
2019-03-21 12:57:28 +01:00
|
|
|
}
|
2007-03-17 15:02:15 +01:00
|
|
|
}
|
2008-11-01 01:54:12 +01:00
|
|
|
/* Div functions */
|
|
|
|
#define GEN_INT_ARITH_DIVW(name, opc3, sign, compute_ov) \
|
2019-03-21 12:57:28 +01:00
|
|
|
static void glue(gen_, name)(DisasContext *ctx) \
|
2008-11-01 01:54:12 +01:00
|
|
|
{ \
|
|
|
|
gen_op_arith_divw(ctx, cpu_gpr[rD(ctx->opcode)], \
|
|
|
|
cpu_gpr[rA(ctx->opcode)], cpu_gpr[rB(ctx->opcode)], \
|
|
|
|
sign, compute_ov); \
|
|
|
|
}
|
|
|
|
/* divwu divwu. divwuo divwuo. */
|
|
|
|
GEN_INT_ARITH_DIVW(divwu, 0x0E, 0, 0);
|
|
|
|
GEN_INT_ARITH_DIVW(divwuo, 0x1E, 0, 1);
|
|
|
|
/* divw divw. divwo divwo. */
|
|
|
|
GEN_INT_ARITH_DIVW(divw, 0x0F, 1, 0);
|
|
|
|
GEN_INT_ARITH_DIVW(divwo, 0x1F, 1, 1);
|
2014-01-07 17:05:51 +01:00
|
|
|
|
|
|
|
/* div[wd]eu[o][.] */
|
|
|
|
#define GEN_DIVE(name, hlpr, compute_ov) \
|
|
|
|
static void gen_##name(DisasContext *ctx) \
|
|
|
|
{ \
|
|
|
|
TCGv_i32 t0 = tcg_const_i32(compute_ov); \
|
|
|
|
gen_helper_##hlpr(cpu_gpr[rD(ctx->opcode)], cpu_env, \
|
|
|
|
cpu_gpr[rA(ctx->opcode)], cpu_gpr[rB(ctx->opcode)], t0); \
|
|
|
|
tcg_temp_free_i32(t0); \
|
|
|
|
if (unlikely(Rc(ctx->opcode) != 0)) { \
|
|
|
|
gen_set_Rc0(ctx, cpu_gpr[rD(ctx->opcode)]); \
|
|
|
|
} \
|
|
|
|
}
|
|
|
|
|
2014-01-07 17:05:53 +01:00
|
|
|
GEN_DIVE(divweu, divweu, 0);
|
|
|
|
GEN_DIVE(divweuo, divweu, 1);
|
2014-01-07 17:05:54 +01:00
|
|
|
GEN_DIVE(divwe, divwe, 0);
|
|
|
|
GEN_DIVE(divweo, divwe, 1);
|
2014-01-07 17:05:53 +01:00
|
|
|
|
2007-03-17 15:02:15 +01:00
|
|
|
#if defined(TARGET_PPC64)
|
2009-08-16 11:06:54 +02:00
|
|
|
static inline void gen_op_arith_divd(DisasContext *ctx, TCGv ret, TCGv arg1,
|
|
|
|
TCGv arg2, int sign, int compute_ov)
|
2007-03-17 15:02:15 +01:00
|
|
|
{
|
2016-07-28 20:14:12 +02: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 01:54:12 +01:00
|
|
|
|
2016-07-28 20:14:12 +02:00
|
|
|
tcg_gen_mov_i64(t0, arg1);
|
|
|
|
tcg_gen_mov_i64(t1, arg2);
|
2008-11-01 01:54:12 +01:00
|
|
|
if (sign) {
|
2016-07-28 20:14:12 +02: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 01:54:12 +01:00
|
|
|
} else {
|
2016-07-28 20:14:12 +02: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 01:54:12 +01:00
|
|
|
}
|
|
|
|
if (compute_ov) {
|
2016-07-28 20:14:12 +02:00
|
|
|
tcg_gen_mov_tl(cpu_ov, t2);
|
2017-02-27 05:58:00 +01:00
|
|
|
if (is_isa300(ctx)) {
|
|
|
|
tcg_gen_mov_tl(cpu_ov32, t2);
|
|
|
|
}
|
2016-07-28 20:14:12 +02:00
|
|
|
tcg_gen_or_tl(cpu_so, cpu_so, cpu_ov);
|
2008-11-01 01:54:12 +01:00
|
|
|
}
|
2016-07-28 20:14:12 +02:00
|
|
|
tcg_temp_free_i64(t0);
|
|
|
|
tcg_temp_free_i64(t1);
|
|
|
|
tcg_temp_free_i64(t2);
|
|
|
|
tcg_temp_free_i64(t3);
|
|
|
|
|
2019-03-21 12:57:28 +01:00
|
|
|
if (unlikely(Rc(ctx->opcode) != 0)) {
|
2008-11-01 01:54:12 +01:00
|
|
|
gen_set_Rc0(ctx, ret);
|
2019-03-21 12:57:28 +01:00
|
|
|
}
|
2007-03-17 15:02:15 +01:00
|
|
|
}
|
2016-07-28 20:14:12 +02:00
|
|
|
|
2008-11-01 01:54:12 +01:00
|
|
|
#define GEN_INT_ARITH_DIVD(name, opc3, sign, compute_ov) \
|
2019-03-21 12:57:28 +01:00
|
|
|
static void glue(gen_, name)(DisasContext *ctx) \
|
2008-11-01 01:54:12 +01:00
|
|
|
{ \
|
2008-11-09 18:27:19 +01:00
|
|
|
gen_op_arith_divd(ctx, cpu_gpr[rD(ctx->opcode)], \
|
|
|
|
cpu_gpr[rA(ctx->opcode)], cpu_gpr[rB(ctx->opcode)], \
|
|
|
|
sign, compute_ov); \
|
2008-11-01 01:54:12 +01:00
|
|
|
}
|
2017-02-27 05:58:00 +01:00
|
|
|
/* divdu divdu. divduo divduo. */
|
2008-11-01 01:54:12 +01:00
|
|
|
GEN_INT_ARITH_DIVD(divdu, 0x0E, 0, 0);
|
|
|
|
GEN_INT_ARITH_DIVD(divduo, 0x1E, 0, 1);
|
2017-02-27 05:58:00 +01:00
|
|
|
/* divd divd. divdo divdo. */
|
2008-11-01 01:54:12 +01:00
|
|
|
GEN_INT_ARITH_DIVD(divd, 0x0F, 1, 0);
|
|
|
|
GEN_INT_ARITH_DIVD(divdo, 0x1F, 1, 1);
|
2014-01-07 17:05:51 +01:00
|
|
|
|
|
|
|
GEN_DIVE(divdeu, divdeu, 0);
|
|
|
|
GEN_DIVE(divdeuo, divdeu, 1);
|
2014-01-07 17:05:52 +01:00
|
|
|
GEN_DIVE(divde, divde, 0);
|
|
|
|
GEN_DIVE(divdeo, divde, 1);
|
2007-03-17 15:02:15 +01:00
|
|
|
#endif
|
2008-11-01 01:54:12 +01:00
|
|
|
|
2016-07-26 13:58:28 +02: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 13:58:29 +02: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 01:54:12 +01:00
|
|
|
/* mulhw mulhw. */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_mulhw(DisasContext *ctx)
|
2007-03-17 15:02:15 +01:00
|
|
|
{
|
2013-02-20 08:52:12 +01:00
|
|
|
TCGv_i32 t0 = tcg_temp_new_i32();
|
|
|
|
TCGv_i32 t1 = tcg_temp_new_i32();
|
2008-11-01 01:54:12 +01:00
|
|
|
|
2013-02-20 08:52:12 +01:00
|
|
|
tcg_gen_trunc_tl_i32(t0, cpu_gpr[rA(ctx->opcode)]);
|
|
|
|
tcg_gen_trunc_tl_i32(t1, cpu_gpr[rB(ctx->opcode)]);
|
|
|
|
tcg_gen_muls2_i32(t0, t1, t0, t1);
|
|
|
|
tcg_gen_extu_i32_tl(cpu_gpr[rD(ctx->opcode)], t1);
|
|
|
|
tcg_temp_free_i32(t0);
|
|
|
|
tcg_temp_free_i32(t1);
|
2019-03-21 12:57:28 +01:00
|
|
|
if (unlikely(Rc(ctx->opcode) != 0)) {
|
2008-11-01 01:54:12 +01:00
|
|
|
gen_set_Rc0(ctx, cpu_gpr[rD(ctx->opcode)]);
|
2019-03-21 12:57:28 +01:00
|
|
|
}
|
2007-03-17 15:02:15 +01:00
|
|
|
}
|
2009-06-17 17:22:09 +02:00
|
|
|
|
2009-06-17 17:22:19 +02:00
|
|
|
/* mulhwu mulhwu. */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_mulhwu(DisasContext *ctx)
|
2007-03-17 15:02:15 +01:00
|
|
|
{
|
2013-02-20 08:52:12 +01:00
|
|
|
TCGv_i32 t0 = tcg_temp_new_i32();
|
|
|
|
TCGv_i32 t1 = tcg_temp_new_i32();
|
2008-11-01 01:54:12 +01:00
|
|
|
|
2013-02-20 08:52:12 +01:00
|
|
|
tcg_gen_trunc_tl_i32(t0, cpu_gpr[rA(ctx->opcode)]);
|
|
|
|
tcg_gen_trunc_tl_i32(t1, cpu_gpr[rB(ctx->opcode)]);
|
|
|
|
tcg_gen_mulu2_i32(t0, t1, t0, t1);
|
|
|
|
tcg_gen_extu_i32_tl(cpu_gpr[rD(ctx->opcode)], t1);
|
|
|
|
tcg_temp_free_i32(t0);
|
|
|
|
tcg_temp_free_i32(t1);
|
2019-03-21 12:57:28 +01:00
|
|
|
if (unlikely(Rc(ctx->opcode) != 0)) {
|
2008-11-01 01:54:12 +01:00
|
|
|
gen_set_Rc0(ctx, cpu_gpr[rD(ctx->opcode)]);
|
2019-03-21 12:57:28 +01:00
|
|
|
}
|
2007-03-17 15:02:15 +01:00
|
|
|
}
|
2009-06-17 17:22:09 +02:00
|
|
|
|
2009-06-17 17:22:19 +02:00
|
|
|
/* mullw mullw. */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_mullw(DisasContext *ctx)
|
2007-03-17 15:02:15 +01:00
|
|
|
{
|
2014-08-12 15:45:06 +02:00
|
|
|
#if defined(TARGET_PPC64)
|
|
|
|
TCGv_i64 t0, t1;
|
|
|
|
t0 = tcg_temp_new_i64();
|
|
|
|
t1 = tcg_temp_new_i64();
|
|
|
|
tcg_gen_ext32s_tl(t0, cpu_gpr[rA(ctx->opcode)]);
|
|
|
|
tcg_gen_ext32s_tl(t1, cpu_gpr[rB(ctx->opcode)]);
|
|
|
|
tcg_gen_mul_i64(cpu_gpr[rD(ctx->opcode)], t0, t1);
|
|
|
|
tcg_temp_free(t0);
|
|
|
|
tcg_temp_free(t1);
|
|
|
|
#else
|
2014-08-25 21:25:42 +02:00
|
|
|
tcg_gen_mul_i32(cpu_gpr[rD(ctx->opcode)], cpu_gpr[rA(ctx->opcode)],
|
|
|
|
cpu_gpr[rB(ctx->opcode)]);
|
2014-08-12 15:45:06 +02:00
|
|
|
#endif
|
2019-03-21 12:57:28 +01:00
|
|
|
if (unlikely(Rc(ctx->opcode) != 0)) {
|
2008-11-01 01:54:12 +01:00
|
|
|
gen_set_Rc0(ctx, cpu_gpr[rD(ctx->opcode)]);
|
2019-03-21 12:57:28 +01:00
|
|
|
}
|
2007-03-17 15:02:15 +01:00
|
|
|
}
|
2009-06-17 17:22:09 +02:00
|
|
|
|
2009-06-17 17:22:19 +02:00
|
|
|
/* mullwo mullwo. */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_mullwo(DisasContext *ctx)
|
2007-03-17 15:02:15 +01:00
|
|
|
{
|
2013-02-20 08:52:20 +01:00
|
|
|
TCGv_i32 t0 = tcg_temp_new_i32();
|
|
|
|
TCGv_i32 t1 = tcg_temp_new_i32();
|
2008-11-01 01:54:12 +01:00
|
|
|
|
2013-02-20 08:52:20 +01:00
|
|
|
tcg_gen_trunc_tl_i32(t0, cpu_gpr[rA(ctx->opcode)]);
|
|
|
|
tcg_gen_trunc_tl_i32(t1, cpu_gpr[rB(ctx->opcode)]);
|
|
|
|
tcg_gen_muls2_i32(t0, t1, t0, t1);
|
2014-08-12 15:45:07 +02:00
|
|
|
#if defined(TARGET_PPC64)
|
2014-08-25 21:25:43 +02:00
|
|
|
tcg_gen_concat_i32_i64(cpu_gpr[rD(ctx->opcode)], t0, t1);
|
|
|
|
#else
|
|
|
|
tcg_gen_mov_i32(cpu_gpr[rD(ctx->opcode)], t0);
|
2014-08-12 15:45:07 +02:00
|
|
|
#endif
|
2013-02-20 08:52:20 +01:00
|
|
|
|
|
|
|
tcg_gen_sari_i32(t0, t0, 31);
|
|
|
|
tcg_gen_setcond_i32(TCG_COND_NE, t0, t0, t1);
|
|
|
|
tcg_gen_extu_i32_tl(cpu_ov, t0);
|
2017-02-27 05:57:59 +01:00
|
|
|
if (is_isa300(ctx)) {
|
|
|
|
tcg_gen_mov_tl(cpu_ov32, cpu_ov);
|
|
|
|
}
|
2013-02-20 08:52:20 +01:00
|
|
|
tcg_gen_or_tl(cpu_so, cpu_so, cpu_ov);
|
|
|
|
|
|
|
|
tcg_temp_free_i32(t0);
|
|
|
|
tcg_temp_free_i32(t1);
|
2019-03-21 12:57:28 +01:00
|
|
|
if (unlikely(Rc(ctx->opcode) != 0)) {
|
2008-11-01 01:54:12 +01:00
|
|
|
gen_set_Rc0(ctx, cpu_gpr[rD(ctx->opcode)]);
|
2019-03-21 12:57:28 +01:00
|
|
|
}
|
2007-03-17 15:02:15 +01:00
|
|
|
}
|
2009-06-17 17:22:09 +02:00
|
|
|
|
2009-06-17 17:22:19 +02:00
|
|
|
/* mulli */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_mulli(DisasContext *ctx)
|
2007-03-17 15:02:15 +01:00
|
|
|
{
|
2008-11-01 01:54:12 +01:00
|
|
|
tcg_gen_muli_tl(cpu_gpr[rD(ctx->opcode)], cpu_gpr[rA(ctx->opcode)],
|
|
|
|
SIMM(ctx->opcode));
|
2007-03-17 15:02:15 +01:00
|
|
|
}
|
2013-02-20 08:52:12 +01:00
|
|
|
|
2007-03-17 15:02:15 +01:00
|
|
|
#if defined(TARGET_PPC64)
|
2008-11-01 01:54:12 +01:00
|
|
|
/* mulhd mulhd. */
|
2013-02-20 08:52:12 +01:00
|
|
|
static void gen_mulhd(DisasContext *ctx)
|
|
|
|
{
|
|
|
|
TCGv lo = tcg_temp_new();
|
|
|
|
tcg_gen_muls2_tl(lo, cpu_gpr[rD(ctx->opcode)],
|
|
|
|
cpu_gpr[rA(ctx->opcode)], cpu_gpr[rB(ctx->opcode)]);
|
|
|
|
tcg_temp_free(lo);
|
|
|
|
if (unlikely(Rc(ctx->opcode) != 0)) {
|
|
|
|
gen_set_Rc0(ctx, cpu_gpr[rD(ctx->opcode)]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-11-01 01:54:12 +01:00
|
|
|
/* mulhdu mulhdu. */
|
2013-02-20 08:52:12 +01:00
|
|
|
static void gen_mulhdu(DisasContext *ctx)
|
|
|
|
{
|
|
|
|
TCGv lo = tcg_temp_new();
|
|
|
|
tcg_gen_mulu2_tl(lo, cpu_gpr[rD(ctx->opcode)],
|
|
|
|
cpu_gpr[rA(ctx->opcode)], cpu_gpr[rB(ctx->opcode)]);
|
|
|
|
tcg_temp_free(lo);
|
|
|
|
if (unlikely(Rc(ctx->opcode) != 0)) {
|
|
|
|
gen_set_Rc0(ctx, cpu_gpr[rD(ctx->opcode)]);
|
|
|
|
}
|
|
|
|
}
|
2009-06-17 17:22:09 +02:00
|
|
|
|
2009-06-17 17:22:19 +02:00
|
|
|
/* mulld mulld. */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_mulld(DisasContext *ctx)
|
2007-03-17 15:02:15 +01:00
|
|
|
{
|
2008-11-01 01:54:12 +01:00
|
|
|
tcg_gen_mul_tl(cpu_gpr[rD(ctx->opcode)], cpu_gpr[rA(ctx->opcode)],
|
|
|
|
cpu_gpr[rB(ctx->opcode)]);
|
2019-03-21 12:57:28 +01:00
|
|
|
if (unlikely(Rc(ctx->opcode) != 0)) {
|
2008-11-01 01:54:12 +01:00
|
|
|
gen_set_Rc0(ctx, cpu_gpr[rD(ctx->opcode)]);
|
2019-03-21 12:57:28 +01:00
|
|
|
}
|
2007-03-17 15:02:15 +01:00
|
|
|
}
|
2012-05-30 06:23:29 +02:00
|
|
|
|
2008-11-01 01:54:12 +01:00
|
|
|
/* mulldo mulldo. */
|
2012-05-30 06:23:29 +02:00
|
|
|
static void gen_mulldo(DisasContext *ctx)
|
|
|
|
{
|
2014-08-25 21:25:44 +02:00
|
|
|
TCGv_i64 t0 = tcg_temp_new_i64();
|
|
|
|
TCGv_i64 t1 = tcg_temp_new_i64();
|
|
|
|
|
|
|
|
tcg_gen_muls2_i64(t0, t1, cpu_gpr[rA(ctx->opcode)],
|
|
|
|
cpu_gpr[rB(ctx->opcode)]);
|
|
|
|
tcg_gen_mov_i64(cpu_gpr[rD(ctx->opcode)], t0);
|
|
|
|
|
|
|
|
tcg_gen_sari_i64(t0, t0, 63);
|
|
|
|
tcg_gen_setcond_i64(TCG_COND_NE, cpu_ov, t0, t1);
|
2017-02-27 05:57:59 +01:00
|
|
|
if (is_isa300(ctx)) {
|
|
|
|
tcg_gen_mov_tl(cpu_ov32, cpu_ov);
|
|
|
|
}
|
2014-08-25 21:25:44 +02:00
|
|
|
tcg_gen_or_tl(cpu_so, cpu_so, cpu_ov);
|
|
|
|
|
|
|
|
tcg_temp_free_i64(t0);
|
|
|
|
tcg_temp_free_i64(t1);
|
|
|
|
|
2012-05-30 06:23:29 +02:00
|
|
|
if (unlikely(Rc(ctx->opcode) != 0)) {
|
|
|
|
gen_set_Rc0(ctx, cpu_gpr[rD(ctx->opcode)]);
|
|
|
|
}
|
|
|
|
}
|
2007-03-17 15:02:15 +01:00
|
|
|
#endif
|
2008-11-01 01:54:12 +01:00
|
|
|
|
|
|
|
/* Common subf function */
|
2009-08-16 11:06:54 +02:00
|
|
|
static inline void gen_op_arith_subf(DisasContext *ctx, TCGv ret, TCGv arg1,
|
2013-02-20 08:52:17 +01:00
|
|
|
TCGv arg2, bool add_ca, bool compute_ca,
|
|
|
|
bool compute_ov, bool compute_rc0)
|
2003-11-23 15:55:54 +01:00
|
|
|
{
|
2013-02-20 08:52:17 +01:00
|
|
|
TCGv t0 = ret;
|
2003-11-23 15:55:54 +01:00
|
|
|
|
2013-04-03 12:56:45 +02:00
|
|
|
if (compute_ca || compute_ov) {
|
2013-02-20 08:52:17 +01:00
|
|
|
t0 = tcg_temp_new();
|
2013-02-20 08:52:13 +01:00
|
|
|
}
|
2008-11-01 01:54:12 +01:00
|
|
|
|
2013-03-21 11:01:45 +01:00
|
|
|
if (compute_ca) {
|
|
|
|
/* dest = ~arg1 + arg2 [+ ca]. */
|
|
|
|
if (NARROW_MODE(ctx)) {
|
2019-03-21 12:57:28 +01:00
|
|
|
/*
|
|
|
|
* Caution: a non-obvious corner case of the spec is that
|
|
|
|
* we must produce the *entire* 64-bit addition, but
|
|
|
|
* produce the carry into bit 32.
|
|
|
|
*/
|
2013-03-21 11:01:45 +01:00
|
|
|
TCGv inv1 = tcg_temp_new();
|
2013-04-03 12:56:45 +02:00
|
|
|
TCGv t1 = tcg_temp_new();
|
2013-03-21 11:01:45 +01:00
|
|
|
tcg_gen_not_tl(inv1, arg1);
|
|
|
|
if (add_ca) {
|
2013-04-03 12:56:45 +02:00
|
|
|
tcg_gen_add_tl(t0, arg2, cpu_ca);
|
2013-03-21 11:01:45 +01:00
|
|
|
} else {
|
2013-04-03 12:56:45 +02:00
|
|
|
tcg_gen_addi_tl(t0, arg2, 1);
|
2013-03-21 11:01:45 +01:00
|
|
|
}
|
2013-04-03 12:56:45 +02:00
|
|
|
tcg_gen_xor_tl(t1, arg2, inv1); /* add without carry */
|
2013-03-21 11:01:45 +01:00
|
|
|
tcg_gen_add_tl(t0, t0, inv1);
|
2014-01-19 17:26:33 +01:00
|
|
|
tcg_temp_free(inv1);
|
2013-04-03 12:56:45 +02:00
|
|
|
tcg_gen_xor_tl(cpu_ca, t0, t1); /* bits changes w/ carry */
|
|
|
|
tcg_temp_free(t1);
|
2017-07-18 06:55:35 +02:00
|
|
|
tcg_gen_extract_tl(cpu_ca, cpu_ca, 32, 1);
|
2017-02-27 05:57:56 +01:00
|
|
|
if (is_isa300(ctx)) {
|
|
|
|
tcg_gen_mov_tl(cpu_ca32, cpu_ca);
|
|
|
|
}
|
2013-03-21 11:01:45 +01:00
|
|
|
} else if (add_ca) {
|
2013-02-25 20:41:40 +01:00
|
|
|
TCGv zero, inv1 = tcg_temp_new();
|
|
|
|
tcg_gen_not_tl(inv1, arg1);
|
2013-02-20 08:52:17 +01:00
|
|
|
zero = tcg_const_tl(0);
|
|
|
|
tcg_gen_add2_tl(t0, cpu_ca, arg2, zero, cpu_ca, zero);
|
2013-02-25 20:41:40 +01:00
|
|
|
tcg_gen_add2_tl(t0, cpu_ca, t0, cpu_ca, inv1, zero);
|
2018-11-15 04:22:59 +01:00
|
|
|
gen_op_arith_compute_ca32(ctx, t0, inv1, arg2, cpu_ca32, 0);
|
2013-02-20 08:52:17 +01:00
|
|
|
tcg_temp_free(zero);
|
2013-02-25 20:41:40 +01:00
|
|
|
tcg_temp_free(inv1);
|
2013-02-20 08:52:17 +01:00
|
|
|
} else {
|
2013-03-21 11:01:45 +01:00
|
|
|
tcg_gen_setcond_tl(TCG_COND_GEU, cpu_ca, arg2, arg1);
|
2013-02-20 08:52:17 +01:00
|
|
|
tcg_gen_sub_tl(t0, arg2, arg1);
|
2018-11-15 04:22:59 +01:00
|
|
|
gen_op_arith_compute_ca32(ctx, t0, arg1, arg2, cpu_ca32, 1);
|
2013-02-20 08:52:17 +01:00
|
|
|
}
|
2013-03-21 11:01:45 +01:00
|
|
|
} else if (add_ca) {
|
2019-03-21 12:57:28 +01:00
|
|
|
/*
|
|
|
|
* Since we're ignoring carry-out, we can simplify the
|
|
|
|
* standard ~arg1 + arg2 + ca to arg2 - arg1 + ca - 1.
|
|
|
|
*/
|
2013-03-21 11:01:45 +01:00
|
|
|
tcg_gen_sub_tl(t0, arg2, arg1);
|
|
|
|
tcg_gen_add_tl(t0, t0, cpu_ca);
|
|
|
|
tcg_gen_subi_tl(t0, t0, 1);
|
2003-11-23 15:55:54 +01:00
|
|
|
} else {
|
2013-02-20 08:52:17 +01:00
|
|
|
tcg_gen_sub_tl(t0, arg2, arg1);
|
2008-11-01 01:54:12 +01:00
|
|
|
}
|
2013-02-20 08:52:17 +01:00
|
|
|
|
2008-11-01 01:54:12 +01:00
|
|
|
if (compute_ov) {
|
|
|
|
gen_op_arith_compute_ov(ctx, t0, arg1, arg2, 1);
|
|
|
|
}
|
2013-02-20 08:52:17 +01:00
|
|
|
if (unlikely(compute_rc0)) {
|
2008-11-01 01:54:12 +01:00
|
|
|
gen_set_Rc0(ctx, t0);
|
2013-02-20 08:52:17 +01:00
|
|
|
}
|
2008-11-01 01:54:12 +01:00
|
|
|
|
2017-10-20 05:27:27 +02:00
|
|
|
if (t0 != ret) {
|
2008-11-01 01:54:12 +01:00
|
|
|
tcg_gen_mov_tl(ret, t0);
|
|
|
|
tcg_temp_free(t0);
|
2003-11-23 15:55:54 +01:00
|
|
|
}
|
|
|
|
}
|
2008-11-01 01:54:12 +01:00
|
|
|
/* Sub functions with Two operands functions */
|
|
|
|
#define GEN_INT_ARITH_SUBF(name, opc3, add_ca, compute_ca, compute_ov) \
|
2013-02-20 08:52:17 +01:00
|
|
|
static void glue(gen_, name)(DisasContext *ctx) \
|
2008-11-01 01:54:12 +01:00
|
|
|
{ \
|
|
|
|
gen_op_arith_subf(ctx, cpu_gpr[rD(ctx->opcode)], \
|
|
|
|
cpu_gpr[rA(ctx->opcode)], cpu_gpr[rB(ctx->opcode)], \
|
2013-02-20 08:52:17 +01:00
|
|
|
add_ca, compute_ca, compute_ov, Rc(ctx->opcode)); \
|
2008-11-01 01:54:12 +01:00
|
|
|
}
|
|
|
|
/* Sub functions with one operand and one immediate */
|
|
|
|
#define GEN_INT_ARITH_SUBF_CONST(name, opc3, const_val, \
|
|
|
|
add_ca, compute_ca, compute_ov) \
|
2013-02-20 08:52:17 +01:00
|
|
|
static void glue(gen_, name)(DisasContext *ctx) \
|
2008-11-01 01:54:12 +01:00
|
|
|
{ \
|
2013-02-20 08:52:17 +01:00
|
|
|
TCGv t0 = tcg_const_tl(const_val); \
|
2008-11-01 01:54:12 +01:00
|
|
|
gen_op_arith_subf(ctx, cpu_gpr[rD(ctx->opcode)], \
|
|
|
|
cpu_gpr[rA(ctx->opcode)], t0, \
|
2013-02-20 08:52:17 +01:00
|
|
|
add_ca, compute_ca, compute_ov, Rc(ctx->opcode)); \
|
2008-11-01 01:54:12 +01:00
|
|
|
tcg_temp_free(t0); \
|
|
|
|
}
|
|
|
|
/* subf subf. subfo subfo. */
|
|
|
|
GEN_INT_ARITH_SUBF(subf, 0x01, 0, 0, 0)
|
|
|
|
GEN_INT_ARITH_SUBF(subfo, 0x11, 0, 0, 1)
|
|
|
|
/* subfc subfc. subfco subfco. */
|
|
|
|
GEN_INT_ARITH_SUBF(subfc, 0x00, 0, 1, 0)
|
|
|
|
GEN_INT_ARITH_SUBF(subfco, 0x10, 0, 1, 1)
|
|
|
|
/* subfe subfe. subfeo subfo. */
|
|
|
|
GEN_INT_ARITH_SUBF(subfe, 0x04, 1, 1, 0)
|
|
|
|
GEN_INT_ARITH_SUBF(subfeo, 0x14, 1, 1, 1)
|
|
|
|
/* subfme subfme. subfmeo subfmeo. */
|
|
|
|
GEN_INT_ARITH_SUBF_CONST(subfme, 0x07, -1LL, 1, 1, 0)
|
|
|
|
GEN_INT_ARITH_SUBF_CONST(subfmeo, 0x17, -1LL, 1, 1, 1)
|
|
|
|
/* subfze subfze. subfzeo subfzeo.*/
|
|
|
|
GEN_INT_ARITH_SUBF_CONST(subfze, 0x06, 0, 1, 1, 0)
|
|
|
|
GEN_INT_ARITH_SUBF_CONST(subfzeo, 0x16, 0, 1, 1, 1)
|
2009-06-17 17:22:09 +02:00
|
|
|
|
2009-06-17 17:22:19 +02:00
|
|
|
/* subfic */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_subfic(DisasContext *ctx)
|
2003-11-23 15:55:54 +01:00
|
|
|
{
|
2013-02-20 08:52:17 +01:00
|
|
|
TCGv c = tcg_const_tl(SIMM(ctx->opcode));
|
|
|
|
gen_op_arith_subf(ctx, cpu_gpr[rD(ctx->opcode)], cpu_gpr[rA(ctx->opcode)],
|
|
|
|
c, 0, 1, 0, 0);
|
|
|
|
tcg_temp_free(c);
|
2003-11-23 15:55:54 +01:00
|
|
|
}
|
|
|
|
|
2013-02-20 08:52:18 +01:00
|
|
|
/* neg neg. nego nego. */
|
|
|
|
static inline void gen_op_arith_neg(DisasContext *ctx, bool compute_ov)
|
|
|
|
{
|
|
|
|
TCGv zero = tcg_const_tl(0);
|
|
|
|
gen_op_arith_subf(ctx, cpu_gpr[rD(ctx->opcode)], cpu_gpr[rA(ctx->opcode)],
|
|
|
|
zero, 0, 0, compute_ov, Rc(ctx->opcode));
|
|
|
|
tcg_temp_free(zero);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void gen_neg(DisasContext *ctx)
|
|
|
|
{
|
2017-02-27 05:57:58 +01:00
|
|
|
tcg_gen_neg_tl(cpu_gpr[rD(ctx->opcode)], cpu_gpr[rA(ctx->opcode)]);
|
|
|
|
if (unlikely(Rc(ctx->opcode))) {
|
|
|
|
gen_set_Rc0(ctx, cpu_gpr[rD(ctx->opcode)]);
|
|
|
|
}
|
2013-02-20 08:52:18 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static void gen_nego(DisasContext *ctx)
|
|
|
|
{
|
|
|
|
gen_op_arith_neg(ctx, 1);
|
|
|
|
}
|
|
|
|
|
2003-11-23 15:55:54 +01:00
|
|
|
/*** Integer logical ***/
|
2008-10-21 13:31:27 +02:00
|
|
|
#define GEN_LOGICAL2(name, tcg_op, opc, type) \
|
2019-03-21 12:57:28 +01:00
|
|
|
static void glue(gen_, name)(DisasContext *ctx) \
|
2003-11-23 15:55:54 +01:00
|
|
|
{ \
|
2008-10-21 13:31:27 +02:00
|
|
|
tcg_op(cpu_gpr[rA(ctx->opcode)], cpu_gpr[rS(ctx->opcode)], \
|
|
|
|
cpu_gpr[rB(ctx->opcode)]); \
|
2007-03-07 09:32:30 +01:00
|
|
|
if (unlikely(Rc(ctx->opcode) != 0)) \
|
2008-10-21 13:31:27 +02:00
|
|
|
gen_set_Rc0(ctx, cpu_gpr[rA(ctx->opcode)]); \
|
2003-11-23 15:55:54 +01:00
|
|
|
}
|
|
|
|
|
2008-10-21 13:31:27 +02:00
|
|
|
#define GEN_LOGICAL1(name, tcg_op, opc, type) \
|
2019-03-21 12:57:28 +01:00
|
|
|
static void glue(gen_, name)(DisasContext *ctx) \
|
2003-11-23 15:55:54 +01:00
|
|
|
{ \
|
2008-10-21 13:31:27 +02:00
|
|
|
tcg_op(cpu_gpr[rA(ctx->opcode)], cpu_gpr[rS(ctx->opcode)]); \
|
2007-03-07 09:32:30 +01:00
|
|
|
if (unlikely(Rc(ctx->opcode) != 0)) \
|
2008-10-21 13:31:27 +02:00
|
|
|
gen_set_Rc0(ctx, cpu_gpr[rA(ctx->opcode)]); \
|
2003-11-23 15:55:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* and & and. */
|
2008-10-21 13:31:27 +02:00
|
|
|
GEN_LOGICAL2(and, tcg_gen_and_tl, 0x00, PPC_INTEGER);
|
2003-11-23 15:55:54 +01:00
|
|
|
/* andc & andc. */
|
2008-10-21 13:31:27 +02:00
|
|
|
GEN_LOGICAL2(andc, tcg_gen_andc_tl, 0x01, PPC_INTEGER);
|
2009-06-17 17:22:14 +02:00
|
|
|
|
2009-06-17 17:22:19 +02:00
|
|
|
/* andi. */
|
2009-06-17 17:22:14 +02:00
|
|
|
static void gen_andi_(DisasContext *ctx)
|
2003-11-23 15:55:54 +01:00
|
|
|
{
|
2019-03-21 12:57:28 +01:00
|
|
|
tcg_gen_andi_tl(cpu_gpr[rA(ctx->opcode)], cpu_gpr[rS(ctx->opcode)],
|
|
|
|
UIMM(ctx->opcode));
|
2008-10-21 13:31:27 +02:00
|
|
|
gen_set_Rc0(ctx, cpu_gpr[rA(ctx->opcode)]);
|
2003-11-23 15:55:54 +01:00
|
|
|
}
|
2009-06-17 17:22:14 +02:00
|
|
|
|
2009-06-17 17:22:19 +02:00
|
|
|
/* andis. */
|
2009-06-17 17:22:14 +02:00
|
|
|
static void gen_andis_(DisasContext *ctx)
|
2003-11-23 15:55:54 +01:00
|
|
|
{
|
2019-03-21 12:57:28 +01:00
|
|
|
tcg_gen_andi_tl(cpu_gpr[rA(ctx->opcode)], cpu_gpr[rS(ctx->opcode)],
|
|
|
|
UIMM(ctx->opcode) << 16);
|
2008-10-21 13:31:27 +02:00
|
|
|
gen_set_Rc0(ctx, cpu_gpr[rA(ctx->opcode)]);
|
2003-11-23 15:55:54 +01:00
|
|
|
}
|
2009-06-17 17:22:09 +02:00
|
|
|
|
2009-06-17 17:22:19 +02:00
|
|
|
/* cntlzw */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_cntlzw(DisasContext *ctx)
|
2008-10-21 13:31:27 +02:00
|
|
|
{
|
2016-11-16 11:27:03 +01:00
|
|
|
TCGv_i32 t = tcg_temp_new_i32();
|
|
|
|
|
|
|
|
tcg_gen_trunc_tl_i32(t, cpu_gpr[rS(ctx->opcode)]);
|
|
|
|
tcg_gen_clzi_i32(t, t, 32);
|
|
|
|
tcg_gen_extu_i32_tl(cpu_gpr[rA(ctx->opcode)], t);
|
|
|
|
tcg_temp_free_i32(t);
|
|
|
|
|
2019-03-21 12:57:28 +01:00
|
|
|
if (unlikely(Rc(ctx->opcode) != 0)) {
|
2008-10-24 14:03:16 +02:00
|
|
|
gen_set_Rc0(ctx, cpu_gpr[rA(ctx->opcode)]);
|
2019-03-21 12:57:28 +01:00
|
|
|
}
|
2008-10-21 13:31:27 +02:00
|
|
|
}
|
2016-07-26 13:58:33 +02:00
|
|
|
|
|
|
|
/* cnttzw */
|
|
|
|
static void gen_cnttzw(DisasContext *ctx)
|
|
|
|
{
|
2016-11-16 11:27:03 +01:00
|
|
|
TCGv_i32 t = tcg_temp_new_i32();
|
|
|
|
|
|
|
|
tcg_gen_trunc_tl_i32(t, cpu_gpr[rS(ctx->opcode)]);
|
|
|
|
tcg_gen_ctzi_i32(t, t, 32);
|
|
|
|
tcg_gen_extu_i32_tl(cpu_gpr[rA(ctx->opcode)], t);
|
|
|
|
tcg_temp_free_i32(t);
|
|
|
|
|
2016-07-26 13:58:33 +02:00
|
|
|
if (unlikely(Rc(ctx->opcode) != 0)) {
|
|
|
|
gen_set_Rc0(ctx, cpu_gpr[rA(ctx->opcode)]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-11-23 15:55:54 +01:00
|
|
|
/* eqv & eqv. */
|
2008-10-21 13:31:27 +02:00
|
|
|
GEN_LOGICAL2(eqv, tcg_gen_eqv_tl, 0x08, PPC_INTEGER);
|
2003-11-23 15:55:54 +01:00
|
|
|
/* extsb & extsb. */
|
2008-10-21 13:31:27 +02:00
|
|
|
GEN_LOGICAL1(extsb, tcg_gen_ext8s_tl, 0x1D, PPC_INTEGER);
|
2003-11-23 15:55:54 +01:00
|
|
|
/* extsh & extsh. */
|
2008-10-21 13:31:27 +02:00
|
|
|
GEN_LOGICAL1(extsh, tcg_gen_ext16s_tl, 0x1C, PPC_INTEGER);
|
2003-11-23 15:55:54 +01:00
|
|
|
/* nand & nand. */
|
2008-10-21 13:31:27 +02:00
|
|
|
GEN_LOGICAL2(nand, tcg_gen_nand_tl, 0x0E, PPC_INTEGER);
|
2003-11-23 15:55:54 +01:00
|
|
|
/* nor & nor. */
|
2008-10-21 13:31:27 +02:00
|
|
|
GEN_LOGICAL2(nor, tcg_gen_nor_tl, 0x03, PPC_INTEGER);
|
2009-06-17 17:22:09 +02:00
|
|
|
|
2016-06-19 21:19:24 +02:00
|
|
|
#if defined(TARGET_PPC64) && !defined(CONFIG_USER_ONLY)
|
2016-05-03 18:03:33 +02: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 */
|
2018-02-15 20:51:48 +01:00
|
|
|
gen_exception_nip(ctx, EXCP_HLT, ctx->base.pc_next);
|
2016-05-03 18:03:33 +02:00
|
|
|
}
|
|
|
|
#endif /* defined(TARGET_PPC64) */
|
|
|
|
|
2009-06-17 17:22:19 +02:00
|
|
|
/* or & or. */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_or(DisasContext *ctx)
|
2004-01-04 23:58:38 +01:00
|
|
|
{
|
2007-03-07 09:32:30 +01:00
|
|
|
int rs, ra, rb;
|
|
|
|
|
|
|
|
rs = rS(ctx->opcode);
|
|
|
|
ra = rA(ctx->opcode);
|
|
|
|
rb = rB(ctx->opcode);
|
|
|
|
/* Optimisation for mr. ri case */
|
|
|
|
if (rs != ra || rs != rb) {
|
2019-03-21 12:57:28 +01:00
|
|
|
if (rs != rb) {
|
2008-10-21 13:31:27 +02:00
|
|
|
tcg_gen_or_tl(cpu_gpr[ra], cpu_gpr[rs], cpu_gpr[rb]);
|
2019-03-21 12:57:28 +01:00
|
|
|
} else {
|
2008-10-21 13:31:27 +02:00
|
|
|
tcg_gen_mov_tl(cpu_gpr[ra], cpu_gpr[rs]);
|
2019-03-21 12:57:28 +01:00
|
|
|
}
|
|
|
|
if (unlikely(Rc(ctx->opcode) != 0)) {
|
2008-10-21 13:31:27 +02:00
|
|
|
gen_set_Rc0(ctx, cpu_gpr[ra]);
|
2019-03-21 12:57:28 +01:00
|
|
|
}
|
2007-03-07 09:32:30 +01:00
|
|
|
} else if (unlikely(Rc(ctx->opcode) != 0)) {
|
2008-10-21 13:31:27 +02:00
|
|
|
gen_set_Rc0(ctx, cpu_gpr[rs]);
|
2007-09-30 03:18:26 +02:00
|
|
|
#if defined(TARGET_PPC64)
|
2016-06-24 22:18:28 +02:00
|
|
|
} else if (rs != 0) { /* 0 is nop */
|
2008-10-21 13:31:27 +02:00
|
|
|
int prio = 0;
|
|
|
|
|
2007-09-30 03:18:26 +02:00
|
|
|
switch (rs) {
|
|
|
|
case 1:
|
|
|
|
/* Set process priority to low */
|
2008-10-21 13:31:27 +02:00
|
|
|
prio = 2;
|
2007-09-30 03:18:26 +02:00
|
|
|
break;
|
|
|
|
case 6:
|
|
|
|
/* Set process priority to medium-low */
|
2008-10-21 13:31:27 +02:00
|
|
|
prio = 3;
|
2007-09-30 03:18:26 +02:00
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
/* Set process priority to normal */
|
2008-10-21 13:31:27 +02:00
|
|
|
prio = 4;
|
2007-09-30 03:18:26 +02:00
|
|
|
break;
|
2007-09-30 15:03:23 +02:00
|
|
|
#if !defined(CONFIG_USER_ONLY)
|
|
|
|
case 31:
|
2014-09-15 17:03:28 +02:00
|
|
|
if (!ctx->pr) {
|
2007-09-30 15:03:23 +02:00
|
|
|
/* Set process priority to very low */
|
2008-10-21 13:31:27 +02:00
|
|
|
prio = 1;
|
2007-09-30 15:03:23 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 5:
|
2014-09-15 17:03:28 +02:00
|
|
|
if (!ctx->pr) {
|
2007-09-30 15:03:23 +02:00
|
|
|
/* Set process priority to medium-hight */
|
2008-10-21 13:31:27 +02:00
|
|
|
prio = 5;
|
2007-09-30 15:03:23 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 3:
|
2014-09-15 17:03:28 +02:00
|
|
|
if (!ctx->pr) {
|
2007-09-30 15:03:23 +02:00
|
|
|
/* Set process priority to high */
|
2008-10-21 13:31:27 +02:00
|
|
|
prio = 6;
|
2007-09-30 15:03:23 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 7:
|
2016-05-03 18:03:33 +02:00
|
|
|
if (ctx->hv && !ctx->pr) {
|
2007-09-30 15:03:23 +02:00
|
|
|
/* Set process priority to very high */
|
2008-10-21 13:31:27 +02:00
|
|
|
prio = 7;
|
2007-09-30 15:03:23 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
#endif
|
2007-09-30 03:18:26 +02:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2008-10-21 13:31:27 +02:00
|
|
|
if (prio) {
|
2008-11-17 15:43:54 +01:00
|
|
|
TCGv t0 = tcg_temp_new();
|
2008-12-05 08:21:31 +01:00
|
|
|
gen_load_spr(t0, SPR_PPR);
|
2008-10-27 23:50:39 +01:00
|
|
|
tcg_gen_andi_tl(t0, t0, ~0x001C000000000000ULL);
|
|
|
|
tcg_gen_ori_tl(t0, t0, ((uint64_t)prio) << 50);
|
2008-12-05 08:21:31 +01:00
|
|
|
gen_store_spr(SPR_PPR, t0);
|
2008-10-27 23:50:39 +01:00
|
|
|
tcg_temp_free(t0);
|
2016-06-24 22:18:28 +02:00
|
|
|
}
|
2016-06-19 21:19:24 +02:00
|
|
|
#if !defined(CONFIG_USER_ONLY)
|
2019-03-21 12:57:28 +01: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.
|
2016-06-24 22:18:28 +02:00
|
|
|
*/
|
|
|
|
gen_pause(ctx);
|
2016-06-19 21:19:24 +02:00
|
|
|
#endif
|
2007-09-30 03:18:26 +02:00
|
|
|
#endif
|
2004-01-04 23:58:38 +01:00
|
|
|
}
|
|
|
|
}
|
2003-11-23 15:55:54 +01:00
|
|
|
/* orc & orc. */
|
2008-10-21 13:31:27 +02:00
|
|
|
GEN_LOGICAL2(orc, tcg_gen_orc_tl, 0x0C, PPC_INTEGER);
|
2009-06-17 17:22:09 +02:00
|
|
|
|
2009-06-17 17:22:19 +02:00
|
|
|
/* xor & xor. */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_xor(DisasContext *ctx)
|
2004-01-04 23:58:38 +01:00
|
|
|
{
|
|
|
|
/* Optimisation for "set to zero" case */
|
2019-03-21 12:57:28 +01:00
|
|
|
if (rS(ctx->opcode) != rB(ctx->opcode)) {
|
|
|
|
tcg_gen_xor_tl(cpu_gpr[rA(ctx->opcode)], cpu_gpr[rS(ctx->opcode)],
|
|
|
|
cpu_gpr[rB(ctx->opcode)]);
|
|
|
|
} else {
|
2008-10-21 13:31:27 +02:00
|
|
|
tcg_gen_movi_tl(cpu_gpr[rA(ctx->opcode)], 0);
|
2019-03-21 12:57:28 +01:00
|
|
|
}
|
|
|
|
if (unlikely(Rc(ctx->opcode) != 0)) {
|
2008-10-21 13:31:27 +02:00
|
|
|
gen_set_Rc0(ctx, cpu_gpr[rA(ctx->opcode)]);
|
2019-03-21 12:57:28 +01:00
|
|
|
}
|
2004-01-04 23:58:38 +01:00
|
|
|
}
|
2009-06-17 17:22:09 +02:00
|
|
|
|
2009-06-17 17:22:19 +02:00
|
|
|
/* ori */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_ori(DisasContext *ctx)
|
2003-11-23 15:55:54 +01:00
|
|
|
{
|
2007-03-07 09:32:30 +01:00
|
|
|
target_ulong uimm = UIMM(ctx->opcode);
|
2003-11-23 15:55:54 +01:00
|
|
|
|
2004-01-04 23:58:38 +01:00
|
|
|
if (rS(ctx->opcode) == rA(ctx->opcode) && uimm == 0) {
|
|
|
|
return;
|
2007-03-07 09:32:30 +01:00
|
|
|
}
|
2008-10-21 13:31:27 +02:00
|
|
|
tcg_gen_ori_tl(cpu_gpr[rA(ctx->opcode)], cpu_gpr[rS(ctx->opcode)], uimm);
|
2003-11-23 15:55:54 +01:00
|
|
|
}
|
2009-06-17 17:22:09 +02:00
|
|
|
|
2009-06-17 17:22:19 +02:00
|
|
|
/* oris */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_oris(DisasContext *ctx)
|
2003-11-23 15:55:54 +01:00
|
|
|
{
|
2007-03-07 09:32:30 +01:00
|
|
|
target_ulong uimm = UIMM(ctx->opcode);
|
2003-11-23 15:55:54 +01:00
|
|
|
|
2004-01-04 23:58:38 +01:00
|
|
|
if (rS(ctx->opcode) == rA(ctx->opcode) && uimm == 0) {
|
|
|
|
/* NOP */
|
|
|
|
return;
|
2007-03-07 09:32:30 +01:00
|
|
|
}
|
2019-03-21 12:57:28 +01:00
|
|
|
tcg_gen_ori_tl(cpu_gpr[rA(ctx->opcode)], cpu_gpr[rS(ctx->opcode)],
|
|
|
|
uimm << 16);
|
2003-11-23 15:55:54 +01:00
|
|
|
}
|
2009-06-17 17:22:09 +02:00
|
|
|
|
2009-06-17 17:22:19 +02:00
|
|
|
/* xori */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_xori(DisasContext *ctx)
|
2003-11-23 15:55:54 +01:00
|
|
|
{
|
2007-03-07 09:32:30 +01:00
|
|
|
target_ulong uimm = UIMM(ctx->opcode);
|
2004-01-04 23:58:38 +01:00
|
|
|
|
|
|
|
if (rS(ctx->opcode) == rA(ctx->opcode) && uimm == 0) {
|
|
|
|
/* NOP */
|
|
|
|
return;
|
|
|
|
}
|
2008-10-21 13:31:27 +02:00
|
|
|
tcg_gen_xori_tl(cpu_gpr[rA(ctx->opcode)], cpu_gpr[rS(ctx->opcode)], uimm);
|
2003-11-23 15:55:54 +01:00
|
|
|
}
|
2009-06-17 17:22:09 +02:00
|
|
|
|
2009-06-17 17:22:19 +02:00
|
|
|
/* xoris */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_xoris(DisasContext *ctx)
|
2003-11-23 15:55:54 +01:00
|
|
|
{
|
2007-03-07 09:32:30 +01:00
|
|
|
target_ulong uimm = UIMM(ctx->opcode);
|
2004-01-04 23:58:38 +01:00
|
|
|
|
|
|
|
if (rS(ctx->opcode) == rA(ctx->opcode) && uimm == 0) {
|
|
|
|
/* NOP */
|
|
|
|
return;
|
|
|
|
}
|
2019-03-21 12:57:28 +01:00
|
|
|
tcg_gen_xori_tl(cpu_gpr[rA(ctx->opcode)], cpu_gpr[rS(ctx->opcode)],
|
|
|
|
uimm << 16);
|
2003-11-23 15:55:54 +01:00
|
|
|
}
|
2009-06-17 17:22:09 +02:00
|
|
|
|
2009-06-17 17:22:19 +02:00
|
|
|
/* popcntb : PowerPC 2.03 specification */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_popcntb(DisasContext *ctx)
|
2007-03-17 15:02:15 +01:00
|
|
|
{
|
2011-04-01 06:15:13 +02:00
|
|
|
gen_helper_popcntb(cpu_gpr[rA(ctx->opcode)], cpu_gpr[rS(ctx->opcode)]);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void gen_popcntw(DisasContext *ctx)
|
|
|
|
{
|
2016-11-21 11:58:25 +01:00
|
|
|
#if defined(TARGET_PPC64)
|
2011-04-01 06:15:13 +02:00
|
|
|
gen_helper_popcntw(cpu_gpr[rA(ctx->opcode)], cpu_gpr[rS(ctx->opcode)]);
|
2016-11-21 11:58:25 +01:00
|
|
|
#else
|
|
|
|
tcg_gen_ctpop_i32(cpu_gpr[rA(ctx->opcode)], cpu_gpr[rS(ctx->opcode)]);
|
|
|
|
#endif
|
2011-04-01 06:15:13 +02:00
|
|
|
}
|
|
|
|
|
2007-03-17 15:02:15 +01:00
|
|
|
#if defined(TARGET_PPC64)
|
2011-04-01 06:15:13 +02:00
|
|
|
/* popcntd: PowerPC 2.06 specification */
|
|
|
|
static void gen_popcntd(DisasContext *ctx)
|
|
|
|
{
|
2016-11-21 11:58:25 +01:00
|
|
|
tcg_gen_ctpop_i64(cpu_gpr[rA(ctx->opcode)], cpu_gpr[rS(ctx->opcode)]);
|
2007-03-17 15:02:15 +01:00
|
|
|
}
|
2011-04-01 06:15:13 +02:00
|
|
|
#endif
|
2007-03-17 15:02:15 +01:00
|
|
|
|
2013-04-20 10:56:17 +02:00
|
|
|
/* prtyw: PowerPC 2.05 specification */
|
|
|
|
static void gen_prtyw(DisasContext *ctx)
|
|
|
|
{
|
|
|
|
TCGv ra = cpu_gpr[rA(ctx->opcode)];
|
|
|
|
TCGv rs = cpu_gpr[rS(ctx->opcode)];
|
|
|
|
TCGv t0 = tcg_temp_new();
|
|
|
|
tcg_gen_shri_tl(t0, rs, 16);
|
|
|
|
tcg_gen_xor_tl(ra, rs, t0);
|
|
|
|
tcg_gen_shri_tl(t0, ra, 8);
|
|
|
|
tcg_gen_xor_tl(ra, ra, t0);
|
|
|
|
tcg_gen_andi_tl(ra, ra, (target_ulong)0x100000001ULL);
|
|
|
|
tcg_temp_free(t0);
|
|
|
|
}
|
|
|
|
|
|
|
|
#if defined(TARGET_PPC64)
|
|
|
|
/* prtyd: PowerPC 2.05 specification */
|
|
|
|
static void gen_prtyd(DisasContext *ctx)
|
|
|
|
{
|
|
|
|
TCGv ra = cpu_gpr[rA(ctx->opcode)];
|
|
|
|
TCGv rs = cpu_gpr[rS(ctx->opcode)];
|
|
|
|
TCGv t0 = tcg_temp_new();
|
|
|
|
tcg_gen_shri_tl(t0, rs, 32);
|
|
|
|
tcg_gen_xor_tl(ra, rs, t0);
|
|
|
|
tcg_gen_shri_tl(t0, ra, 16);
|
|
|
|
tcg_gen_xor_tl(ra, ra, t0);
|
|
|
|
tcg_gen_shri_tl(t0, ra, 8);
|
|
|
|
tcg_gen_xor_tl(ra, ra, t0);
|
|
|
|
tcg_gen_andi_tl(ra, ra, 1);
|
|
|
|
tcg_temp_free(t0);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2014-01-07 17:05:49 +01:00
|
|
|
#if defined(TARGET_PPC64)
|
|
|
|
/* bpermd */
|
|
|
|
static void gen_bpermd(DisasContext *ctx)
|
|
|
|
{
|
|
|
|
gen_helper_bpermd(cpu_gpr[rA(ctx->opcode)],
|
|
|
|
cpu_gpr[rS(ctx->opcode)], cpu_gpr[rB(ctx->opcode)]);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2007-03-17 15:02:15 +01:00
|
|
|
#if defined(TARGET_PPC64)
|
|
|
|
/* extsw & extsw. */
|
2008-10-21 13:31:27 +02:00
|
|
|
GEN_LOGICAL1(extsw, tcg_gen_ext32s_tl, 0x1E, PPC_64B);
|
2009-06-17 17:22:09 +02:00
|
|
|
|
2009-06-17 17:22:19 +02:00
|
|
|
/* cntlzd */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_cntlzd(DisasContext *ctx)
|
2008-10-21 13:31:27 +02:00
|
|
|
{
|
2016-11-16 11:27:03 +01:00
|
|
|
tcg_gen_clzi_i64(cpu_gpr[rA(ctx->opcode)], cpu_gpr[rS(ctx->opcode)], 64);
|
2019-03-21 12:57:28 +01:00
|
|
|
if (unlikely(Rc(ctx->opcode) != 0)) {
|
2008-10-21 13:31:27 +02:00
|
|
|
gen_set_Rc0(ctx, cpu_gpr[rA(ctx->opcode)]);
|
2019-03-21 12:57:28 +01:00
|
|
|
}
|
2008-10-21 13:31:27 +02:00
|
|
|
}
|
2016-07-26 13:58:32 +02:00
|
|
|
|
|
|
|
/* cnttzd */
|
|
|
|
static void gen_cnttzd(DisasContext *ctx)
|
|
|
|
{
|
2016-11-16 11:27:03 +01:00
|
|
|
tcg_gen_ctzi_i64(cpu_gpr[rA(ctx->opcode)], cpu_gpr[rS(ctx->opcode)], 64);
|
2016-07-26 13:58:32 +02:00
|
|
|
if (unlikely(Rc(ctx->opcode) != 0)) {
|
|
|
|
gen_set_Rc0(ctx, cpu_gpr[rA(ctx->opcode)]);
|
|
|
|
}
|
|
|
|
}
|
2016-09-16 12:51:47 +02:00
|
|
|
|
|
|
|
/* darn */
|
|
|
|
static void gen_darn(DisasContext *ctx)
|
|
|
|
{
|
|
|
|
int l = L(ctx->opcode);
|
|
|
|
|
2019-05-10 19:00:52 +02:00
|
|
|
if (l > 2) {
|
2016-09-16 12:51:47 +02:00
|
|
|
tcg_gen_movi_i64(cpu_gpr[rD(ctx->opcode)], -1);
|
2019-05-10 19:00:52 +02:00
|
|
|
} else {
|
2021-05-17 22:50:03 +02:00
|
|
|
gen_icount_io_start(ctx);
|
2019-05-10 19:00:52 +02:00
|
|
|
if (l == 0) {
|
|
|
|
gen_helper_darn32(cpu_gpr[rD(ctx->opcode)]);
|
|
|
|
} else {
|
|
|
|
/* Return 64-bit random for both CRN and RRN */
|
|
|
|
gen_helper_darn64(cpu_gpr[rD(ctx->opcode)]);
|
|
|
|
}
|
2016-09-16 12:51:47 +02:00
|
|
|
}
|
|
|
|
}
|
2007-03-17 15:02:15 +01:00
|
|
|
#endif
|
|
|
|
|
2003-11-23 15:55:54 +01:00
|
|
|
/*** Integer rotate ***/
|
2009-06-17 17:22:09 +02:00
|
|
|
|
2009-06-17 17:22:19 +02:00
|
|
|
/* rlwimi & rlwimi. */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_rlwimi(DisasContext *ctx)
|
2003-11-23 15:55:54 +01:00
|
|
|
{
|
2016-02-24 02:18:35 +01: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);
|
|
|
|
|
2019-03-21 12:57:28 +01:00
|
|
|
if (sh == (31 - me) && mb <= me) {
|
2016-02-24 02:18:35 +01:00
|
|
|
tcg_gen_deposit_tl(t_ra, t_ra, t_rs, sh, me - mb + 1);
|
2008-10-27 23:50:22 +01:00
|
|
|
} else {
|
|
|
|
target_ulong mask;
|
2020-05-05 20:38:17 +02:00
|
|
|
bool mask_in_32b = true;
|
2008-11-17 15:43:54 +01:00
|
|
|
TCGv t1;
|
2016-02-24 02:18:35 +01:00
|
|
|
|
2007-03-07 09:32:30 +01:00
|
|
|
#if defined(TARGET_PPC64)
|
2008-10-27 23:50:22 +01:00
|
|
|
mb += 32;
|
|
|
|
me += 32;
|
2007-03-07 09:32:30 +01:00
|
|
|
#endif
|
2008-10-27 23:50:22 +01:00
|
|
|
mask = MASK(mb, me);
|
2016-02-24 02:18:35 +01:00
|
|
|
|
2020-05-05 20:38:17 +02:00
|
|
|
#if defined(TARGET_PPC64)
|
|
|
|
if (mask > 0xffffffffu) {
|
|
|
|
mask_in_32b = false;
|
|
|
|
}
|
|
|
|
#endif
|
2008-11-17 15:43:54 +01:00
|
|
|
t1 = tcg_temp_new();
|
2020-05-05 20:38:17 +02:00
|
|
|
if (mask_in_32b) {
|
2016-06-16 21:04:04 +02:00
|
|
|
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 02:18:35 +01: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-27 23:50:22 +01:00
|
|
|
tcg_temp_free(t1);
|
|
|
|
}
|
2016-02-24 02:18:35 +01:00
|
|
|
if (unlikely(Rc(ctx->opcode) != 0)) {
|
|
|
|
gen_set_Rc0(ctx, t_ra);
|
|
|
|
}
|
2003-11-23 15:55:54 +01:00
|
|
|
}
|
2009-06-17 17:22:09 +02:00
|
|
|
|
2009-06-17 17:22:19 +02:00
|
|
|
/* rlwinm & rlwinm. */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_rlwinm(DisasContext *ctx)
|
2003-11-23 15:55:54 +01:00
|
|
|
{
|
2016-02-24 02:18:35 +01:00
|
|
|
TCGv t_ra = cpu_gpr[rA(ctx->opcode)];
|
|
|
|
TCGv t_rs = cpu_gpr[rS(ctx->opcode)];
|
2016-10-15 20:37:19 +02:00
|
|
|
int sh = SH(ctx->opcode);
|
|
|
|
int mb = MB(ctx->opcode);
|
|
|
|
int me = ME(ctx->opcode);
|
|
|
|
int len = me - mb + 1;
|
|
|
|
int rsh = (32 - sh) & 31;
|
|
|
|
|
|
|
|
if (sh != 0 && len > 0 && me == (31 - sh)) {
|
|
|
|
tcg_gen_deposit_z_tl(t_ra, t_rs, sh, len);
|
|
|
|
} else if (me == 31 && rsh + len <= 32) {
|
|
|
|
tcg_gen_extract_tl(t_ra, t_rs, rsh, len);
|
2008-10-27 23:50:22 +01:00
|
|
|
} else {
|
2016-06-16 21:04:04 +02:00
|
|
|
target_ulong mask;
|
2020-05-05 20:38:17 +02:00
|
|
|
bool mask_in_32b = true;
|
2007-03-07 09:32:30 +01:00
|
|
|
#if defined(TARGET_PPC64)
|
2008-10-27 23:50:22 +01:00
|
|
|
mb += 32;
|
|
|
|
me += 32;
|
2007-03-07 09:32:30 +01:00
|
|
|
#endif
|
2016-06-16 21:04:04 +02:00
|
|
|
mask = MASK(mb, me);
|
2020-05-05 20:38:17 +02:00
|
|
|
#if defined(TARGET_PPC64)
|
|
|
|
if (mask > 0xffffffffu) {
|
|
|
|
mask_in_32b = false;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
if (mask_in_32b) {
|
2020-03-09 21:45:57 +01:00
|
|
|
if (sh == 0) {
|
|
|
|
tcg_gen_andi_tl(t_ra, t_rs, mask);
|
|
|
|
} else {
|
|
|
|
TCGv_i32 t0 = tcg_temp_new_i32();
|
|
|
|
tcg_gen_trunc_tl_i32(t0, t_rs);
|
|
|
|
tcg_gen_rotli_i32(t0, t0, sh);
|
|
|
|
tcg_gen_andi_i32(t0, t0, mask);
|
|
|
|
tcg_gen_extu_i32_tl(t_ra, t0);
|
|
|
|
tcg_temp_free_i32(t0);
|
|
|
|
}
|
2016-06-16 21:04:04 +02: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 02:18:35 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (unlikely(Rc(ctx->opcode) != 0)) {
|
|
|
|
gen_set_Rc0(ctx, t_ra);
|
2008-10-27 23:50:22 +01:00
|
|
|
}
|
2003-11-23 15:55:54 +01:00
|
|
|
}
|
2009-06-17 17:22:09 +02:00
|
|
|
|
2009-06-17 17:22:19 +02:00
|
|
|
/* rlwnm & rlwnm. */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_rlwnm(DisasContext *ctx)
|
2003-11-23 15:55:54 +01:00
|
|
|
{
|
2016-02-24 02:18:35 +01: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 21:04:04 +02:00
|
|
|
target_ulong mask;
|
2020-05-05 20:38:17 +02:00
|
|
|
bool mask_in_32b = true;
|
2014-08-25 21:25:41 +02:00
|
|
|
|
2008-11-03 08:08:44 +01:00
|
|
|
#if defined(TARGET_PPC64)
|
2016-02-24 02:18:35 +01:00
|
|
|
mb += 32;
|
|
|
|
me += 32;
|
2008-11-03 08:08:44 +01:00
|
|
|
#endif
|
2016-06-16 21:04:04 +02:00
|
|
|
mask = MASK(mb, me);
|
|
|
|
|
2020-05-05 20:38:17 +02:00
|
|
|
#if defined(TARGET_PPC64)
|
|
|
|
if (mask > 0xffffffffu) {
|
|
|
|
mask_in_32b = false;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
if (mask_in_32b) {
|
2016-06-16 21:04:04 +02:00
|
|
|
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 21:25:41 +02:00
|
|
|
|
2016-06-16 21:04:04 +02:00
|
|
|
tcg_gen_andi_tl(t_ra, t_ra, mask);
|
2016-02-24 02:18:35 +01:00
|
|
|
|
|
|
|
if (unlikely(Rc(ctx->opcode) != 0)) {
|
|
|
|
gen_set_Rc0(ctx, t_ra);
|
2003-11-23 15:55:54 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-03-17 15:02:15 +01:00
|
|
|
#if defined(TARGET_PPC64)
|
|
|
|
#define GEN_PPC64_R2(name, opc1, opc2) \
|
2009-06-17 17:22:14 +02:00
|
|
|
static void glue(gen_, name##0)(DisasContext *ctx) \
|
2007-03-17 15:02:15 +01:00
|
|
|
{ \
|
|
|
|
gen_##name(ctx, 0); \
|
|
|
|
} \
|
2009-06-17 17:22:14 +02:00
|
|
|
\
|
|
|
|
static void glue(gen_, name##1)(DisasContext *ctx) \
|
2007-03-17 15:02:15 +01:00
|
|
|
{ \
|
|
|
|
gen_##name(ctx, 1); \
|
|
|
|
}
|
|
|
|
#define GEN_PPC64_R4(name, opc1, opc2) \
|
2009-06-17 17:22:14 +02:00
|
|
|
static void glue(gen_, name##0)(DisasContext *ctx) \
|
2007-03-17 15:02:15 +01:00
|
|
|
{ \
|
|
|
|
gen_##name(ctx, 0, 0); \
|
|
|
|
} \
|
2009-06-17 17:22:14 +02:00
|
|
|
\
|
|
|
|
static void glue(gen_, name##1)(DisasContext *ctx) \
|
2007-03-17 15:02:15 +01:00
|
|
|
{ \
|
|
|
|
gen_##name(ctx, 0, 1); \
|
|
|
|
} \
|
2009-06-17 17:22:14 +02:00
|
|
|
\
|
|
|
|
static void glue(gen_, name##2)(DisasContext *ctx) \
|
2007-03-17 15:02:15 +01:00
|
|
|
{ \
|
|
|
|
gen_##name(ctx, 1, 0); \
|
|
|
|
} \
|
2009-06-17 17:22:14 +02:00
|
|
|
\
|
|
|
|
static void glue(gen_, name##3)(DisasContext *ctx) \
|
2007-03-17 15:02:15 +01:00
|
|
|
{ \
|
|
|
|
gen_##name(ctx, 1, 1); \
|
|
|
|
}
|
2007-03-22 23:41:50 +01:00
|
|
|
|
2016-02-24 02:18:36 +01:00
|
|
|
static void gen_rldinm(DisasContext *ctx, int mb, int me, int sh)
|
2007-03-22 23:41:50 +01:00
|
|
|
{
|
2016-02-24 02:18:36 +01:00
|
|
|
TCGv t_ra = cpu_gpr[rA(ctx->opcode)];
|
|
|
|
TCGv t_rs = cpu_gpr[rS(ctx->opcode)];
|
2016-10-15 20:37:19 +02:00
|
|
|
int len = me - mb + 1;
|
|
|
|
int rsh = (64 - sh) & 63;
|
2016-02-24 02:18:36 +01:00
|
|
|
|
2016-10-15 20:37:19 +02:00
|
|
|
if (sh != 0 && len > 0 && me == (63 - sh)) {
|
|
|
|
tcg_gen_deposit_z_tl(t_ra, t_rs, sh, len);
|
|
|
|
} else if (me == 63 && rsh + len <= 64) {
|
|
|
|
tcg_gen_extract_tl(t_ra, t_rs, rsh, len);
|
2008-10-27 23:50:22 +01:00
|
|
|
} else {
|
2016-02-24 02:18:36 +01: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-22 23:41:50 +01:00
|
|
|
}
|
|
|
|
}
|
2016-02-24 02:18:36 +01:00
|
|
|
|
2007-03-17 15:02:15 +01:00
|
|
|
/* rldicl - rldicl. */
|
2009-08-16 11:06:54 +02:00
|
|
|
static inline void gen_rldicl(DisasContext *ctx, int mbn, int shn)
|
2007-03-17 15:02:15 +01:00
|
|
|
{
|
2007-03-22 23:41:50 +01:00
|
|
|
uint32_t sh, mb;
|
2007-03-17 15:02:15 +01:00
|
|
|
|
2007-04-06 09:59:47 +02:00
|
|
|
sh = SH(ctx->opcode) | (shn << 5);
|
|
|
|
mb = MB(ctx->opcode) | (mbn << 5);
|
2007-03-22 23:41:50 +01:00
|
|
|
gen_rldinm(ctx, mb, 63, sh);
|
2007-03-17 15:02:15 +01:00
|
|
|
}
|
2007-03-22 23:41:50 +01:00
|
|
|
GEN_PPC64_R4(rldicl, 0x1E, 0x00);
|
2016-02-24 02:18:36 +01:00
|
|
|
|
2007-03-17 15:02:15 +01:00
|
|
|
/* rldicr - rldicr. */
|
2009-08-16 11:06:54 +02:00
|
|
|
static inline void gen_rldicr(DisasContext *ctx, int men, int shn)
|
2007-03-17 15:02:15 +01:00
|
|
|
{
|
2007-03-22 23:41:50 +01:00
|
|
|
uint32_t sh, me;
|
2007-03-17 15:02:15 +01:00
|
|
|
|
2007-04-06 09:59:47 +02:00
|
|
|
sh = SH(ctx->opcode) | (shn << 5);
|
|
|
|
me = MB(ctx->opcode) | (men << 5);
|
2007-03-22 23:41:50 +01:00
|
|
|
gen_rldinm(ctx, 0, me, sh);
|
2007-03-17 15:02:15 +01:00
|
|
|
}
|
2007-03-22 23:41:50 +01:00
|
|
|
GEN_PPC64_R4(rldicr, 0x1E, 0x02);
|
2016-02-24 02:18:36 +01:00
|
|
|
|
2007-03-17 15:02:15 +01:00
|
|
|
/* rldic - rldic. */
|
2009-08-16 11:06:54 +02:00
|
|
|
static inline void gen_rldic(DisasContext *ctx, int mbn, int shn)
|
2007-03-17 15:02:15 +01:00
|
|
|
{
|
2007-03-22 23:41:50 +01:00
|
|
|
uint32_t sh, mb;
|
2007-03-17 15:02:15 +01:00
|
|
|
|
2007-04-06 09:59:47 +02:00
|
|
|
sh = SH(ctx->opcode) | (shn << 5);
|
|
|
|
mb = MB(ctx->opcode) | (mbn << 5);
|
2007-03-22 23:41:50 +01:00
|
|
|
gen_rldinm(ctx, mb, 63 - sh, sh);
|
|
|
|
}
|
|
|
|
GEN_PPC64_R4(rldic, 0x1E, 0x04);
|
|
|
|
|
2016-02-24 02:18:36 +01:00
|
|
|
static void gen_rldnm(DisasContext *ctx, int mb, int me)
|
2007-03-22 23:41:50 +01:00
|
|
|
{
|
2016-02-24 02:18:36 +01: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 08:08:44 +01:00
|
|
|
TCGv t0;
|
2008-10-27 23:50:22 +01:00
|
|
|
|
2008-11-17 15:43:54 +01:00
|
|
|
t0 = tcg_temp_new();
|
2016-02-24 02:18:36 +01:00
|
|
|
tcg_gen_andi_tl(t0, t_rb, 0x3f);
|
|
|
|
tcg_gen_rotl_tl(t_ra, t_rs, t0);
|
2008-11-03 08:08:44 +01:00
|
|
|
tcg_temp_free(t0);
|
2016-02-24 02:18:36 +01: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 15:02:15 +01:00
|
|
|
}
|
2007-03-22 23:41:50 +01:00
|
|
|
|
2007-03-17 15:02:15 +01:00
|
|
|
/* rldcl - rldcl. */
|
2009-08-16 11:06:54 +02:00
|
|
|
static inline void gen_rldcl(DisasContext *ctx, int mbn)
|
2007-03-17 15:02:15 +01:00
|
|
|
{
|
2007-03-22 23:41:50 +01:00
|
|
|
uint32_t mb;
|
2007-03-17 15:02:15 +01:00
|
|
|
|
2007-04-06 09:59:47 +02:00
|
|
|
mb = MB(ctx->opcode) | (mbn << 5);
|
2007-03-22 23:41:50 +01:00
|
|
|
gen_rldnm(ctx, mb, 63);
|
2007-03-17 15:02:15 +01:00
|
|
|
}
|
2007-09-17 10:21:54 +02:00
|
|
|
GEN_PPC64_R2(rldcl, 0x1E, 0x08);
|
2016-02-24 02:18:36 +01:00
|
|
|
|
2007-03-17 15:02:15 +01:00
|
|
|
/* rldcr - rldcr. */
|
2009-08-16 11:06:54 +02:00
|
|
|
static inline void gen_rldcr(DisasContext *ctx, int men)
|
2007-03-17 15:02:15 +01:00
|
|
|
{
|
2007-03-22 23:41:50 +01:00
|
|
|
uint32_t me;
|
2007-03-17 15:02:15 +01:00
|
|
|
|
2007-04-06 09:59:47 +02:00
|
|
|
me = MB(ctx->opcode) | (men << 5);
|
2007-03-22 23:41:50 +01:00
|
|
|
gen_rldnm(ctx, 0, me);
|
2007-03-17 15:02:15 +01:00
|
|
|
}
|
2007-09-17 10:21:54 +02:00
|
|
|
GEN_PPC64_R2(rldcr, 0x1E, 0x09);
|
2016-02-24 02:18:36 +01:00
|
|
|
|
2007-03-17 15:02:15 +01:00
|
|
|
/* rldimi - rldimi. */
|
2016-02-24 02:18:36 +01:00
|
|
|
static void gen_rldimi(DisasContext *ctx, int mbn, int shn)
|
2007-03-17 15:02:15 +01:00
|
|
|
{
|
2016-02-24 02:18:36 +01: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 15:02:15 +01:00
|
|
|
|
2016-02-24 02:18:36 +01:00
|
|
|
if (mb <= me) {
|
|
|
|
tcg_gen_deposit_tl(t_ra, t_ra, t_rs, sh, me - mb + 1);
|
2008-10-27 23:50:22 +01:00
|
|
|
} else {
|
2016-02-24 02:18:36 +01:00
|
|
|
target_ulong mask = MASK(mb, me);
|
|
|
|
TCGv t1 = tcg_temp_new();
|
2008-10-27 23:50:22 +01:00
|
|
|
|
2016-02-24 02:18:36 +01: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-27 23:50:22 +01:00
|
|
|
tcg_temp_free(t1);
|
2007-03-22 23:41:50 +01:00
|
|
|
}
|
2016-02-24 02:18:36 +01:00
|
|
|
if (unlikely(Rc(ctx->opcode) != 0)) {
|
|
|
|
gen_set_Rc0(ctx, t_ra);
|
|
|
|
}
|
2007-03-17 15:02:15 +01:00
|
|
|
}
|
2007-09-17 10:21:54 +02:00
|
|
|
GEN_PPC64_R4(rldimi, 0x1E, 0x06);
|
2007-03-17 15:02:15 +01:00
|
|
|
#endif
|
|
|
|
|
2003-11-23 15:55:54 +01:00
|
|
|
/*** Integer shift ***/
|
2009-06-17 17:22:09 +02:00
|
|
|
|
2009-06-17 17:22:19 +02:00
|
|
|
/* slw & slw. */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_slw(DisasContext *ctx)
|
2008-10-21 13:31:27 +02:00
|
|
|
{
|
2009-09-18 16:56:30 +02:00
|
|
|
TCGv t0, t1;
|
2008-10-21 13:31:27 +02:00
|
|
|
|
2009-09-18 16:56:30 +02:00
|
|
|
t0 = tcg_temp_new();
|
|
|
|
/* AND rS with a mask that is 0 when rB >= 0x20 */
|
|
|
|
#if defined(TARGET_PPC64)
|
|
|
|
tcg_gen_shli_tl(t0, cpu_gpr[rB(ctx->opcode)], 0x3a);
|
|
|
|
tcg_gen_sari_tl(t0, t0, 0x3f);
|
|
|
|
#else
|
|
|
|
tcg_gen_shli_tl(t0, cpu_gpr[rB(ctx->opcode)], 0x1a);
|
|
|
|
tcg_gen_sari_tl(t0, t0, 0x1f);
|
|
|
|
#endif
|
|
|
|
tcg_gen_andc_tl(t0, cpu_gpr[rS(ctx->opcode)], t0);
|
|
|
|
t1 = tcg_temp_new();
|
|
|
|
tcg_gen_andi_tl(t1, cpu_gpr[rB(ctx->opcode)], 0x1f);
|
|
|
|
tcg_gen_shl_tl(cpu_gpr[rA(ctx->opcode)], t0, t1);
|
|
|
|
tcg_temp_free(t1);
|
2008-11-02 09:22:34 +01:00
|
|
|
tcg_temp_free(t0);
|
2009-09-18 16:56:30 +02:00
|
|
|
tcg_gen_ext32u_tl(cpu_gpr[rA(ctx->opcode)], cpu_gpr[rA(ctx->opcode)]);
|
2019-03-21 12:57:28 +01:00
|
|
|
if (unlikely(Rc(ctx->opcode) != 0)) {
|
2008-10-21 13:31:27 +02:00
|
|
|
gen_set_Rc0(ctx, cpu_gpr[rA(ctx->opcode)]);
|
2019-03-21 12:57:28 +01:00
|
|
|
}
|
2008-10-21 13:31:27 +02:00
|
|
|
}
|
2009-06-17 17:22:09 +02:00
|
|
|
|
2009-06-17 17:22:19 +02:00
|
|
|
/* sraw & sraw. */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_sraw(DisasContext *ctx)
|
2008-10-21 13:31:27 +02:00
|
|
|
{
|
2012-05-30 06:23:29 +02:00
|
|
|
gen_helper_sraw(cpu_gpr[rA(ctx->opcode)], cpu_env,
|
2008-11-17 15:43:54 +01:00
|
|
|
cpu_gpr[rS(ctx->opcode)], cpu_gpr[rB(ctx->opcode)]);
|
2019-03-21 12:57:28 +01:00
|
|
|
if (unlikely(Rc(ctx->opcode) != 0)) {
|
2008-10-21 13:31:27 +02:00
|
|
|
gen_set_Rc0(ctx, cpu_gpr[rA(ctx->opcode)]);
|
2019-03-21 12:57:28 +01:00
|
|
|
}
|
2008-10-21 13:31:27 +02:00
|
|
|
}
|
2009-06-17 17:22:09 +02:00
|
|
|
|
2009-06-17 17:22:19 +02:00
|
|
|
/* srawi & srawi. */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_srawi(DisasContext *ctx)
|
2003-11-23 15:55:54 +01:00
|
|
|
{
|
2008-10-21 13:31:27 +02:00
|
|
|
int sh = SH(ctx->opcode);
|
2013-02-20 08:52:19 +01:00
|
|
|
TCGv dst = cpu_gpr[rA(ctx->opcode)];
|
|
|
|
TCGv src = cpu_gpr[rS(ctx->opcode)];
|
|
|
|
if (sh == 0) {
|
2014-08-12 15:45:09 +02:00
|
|
|
tcg_gen_ext32s_tl(dst, src);
|
2013-02-20 08:52:13 +01:00
|
|
|
tcg_gen_movi_tl(cpu_ca, 0);
|
2017-10-06 08:42:44 +02:00
|
|
|
if (is_isa300(ctx)) {
|
|
|
|
tcg_gen_movi_tl(cpu_ca32, 0);
|
|
|
|
}
|
2008-10-21 13:31:27 +02:00
|
|
|
} else {
|
2013-02-20 08:52:19 +01:00
|
|
|
TCGv t0;
|
|
|
|
tcg_gen_ext32s_tl(dst, src);
|
|
|
|
tcg_gen_andi_tl(cpu_ca, dst, (1ULL << sh) - 1);
|
|
|
|
t0 = tcg_temp_new();
|
|
|
|
tcg_gen_sari_tl(t0, dst, TARGET_LONG_BITS - 1);
|
|
|
|
tcg_gen_and_tl(cpu_ca, cpu_ca, t0);
|
|
|
|
tcg_temp_free(t0);
|
|
|
|
tcg_gen_setcondi_tl(TCG_COND_NE, cpu_ca, cpu_ca, 0);
|
2017-10-06 08:42:44 +02:00
|
|
|
if (is_isa300(ctx)) {
|
|
|
|
tcg_gen_mov_tl(cpu_ca32, cpu_ca);
|
|
|
|
}
|
2013-02-20 08:52:19 +01:00
|
|
|
tcg_gen_sari_tl(dst, dst, sh);
|
|
|
|
}
|
|
|
|
if (unlikely(Rc(ctx->opcode) != 0)) {
|
|
|
|
gen_set_Rc0(ctx, dst);
|
2007-03-17 15:02:15 +01:00
|
|
|
}
|
2003-11-23 15:55:54 +01:00
|
|
|
}
|
2009-06-17 17:22:09 +02:00
|
|
|
|
2009-06-17 17:22:19 +02:00
|
|
|
/* srw & srw. */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_srw(DisasContext *ctx)
|
2008-10-21 13:31:27 +02:00
|
|
|
{
|
2008-11-02 09:22:34 +01:00
|
|
|
TCGv t0, t1;
|
2007-03-17 15:02:15 +01:00
|
|
|
|
2009-09-18 16:56:30 +02:00
|
|
|
t0 = tcg_temp_new();
|
|
|
|
/* AND rS with a mask that is 0 when rB >= 0x20 */
|
|
|
|
#if defined(TARGET_PPC64)
|
|
|
|
tcg_gen_shli_tl(t0, cpu_gpr[rB(ctx->opcode)], 0x3a);
|
|
|
|
tcg_gen_sari_tl(t0, t0, 0x3f);
|
|
|
|
#else
|
|
|
|
tcg_gen_shli_tl(t0, cpu_gpr[rB(ctx->opcode)], 0x1a);
|
|
|
|
tcg_gen_sari_tl(t0, t0, 0x1f);
|
|
|
|
#endif
|
|
|
|
tcg_gen_andc_tl(t0, cpu_gpr[rS(ctx->opcode)], t0);
|
|
|
|
tcg_gen_ext32u_tl(t0, t0);
|
2008-11-17 15:43:54 +01:00
|
|
|
t1 = tcg_temp_new();
|
2009-09-18 16:56:30 +02:00
|
|
|
tcg_gen_andi_tl(t1, cpu_gpr[rB(ctx->opcode)], 0x1f);
|
|
|
|
tcg_gen_shr_tl(cpu_gpr[rA(ctx->opcode)], t0, t1);
|
2008-11-02 09:22:34 +01:00
|
|
|
tcg_temp_free(t1);
|
|
|
|
tcg_temp_free(t0);
|
2019-03-21 12:57:28 +01:00
|
|
|
if (unlikely(Rc(ctx->opcode) != 0)) {
|
2008-10-21 13:31:27 +02:00
|
|
|
gen_set_Rc0(ctx, cpu_gpr[rA(ctx->opcode)]);
|
2019-03-21 12:57:28 +01:00
|
|
|
}
|
2008-10-21 13:31:27 +02:00
|
|
|
}
|
2009-06-17 17:22:19 +02:00
|
|
|
|
2007-03-17 15:02:15 +01:00
|
|
|
#if defined(TARGET_PPC64)
|
|
|
|
/* sld & sld. */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_sld(DisasContext *ctx)
|
2008-10-21 13:31:27 +02:00
|
|
|
{
|
2009-09-18 16:56:30 +02:00
|
|
|
TCGv t0, t1;
|
2008-10-21 13:31:27 +02:00
|
|
|
|
2009-09-18 16:56:30 +02:00
|
|
|
t0 = tcg_temp_new();
|
|
|
|
/* AND rS with a mask that is 0 when rB >= 0x40 */
|
|
|
|
tcg_gen_shli_tl(t0, cpu_gpr[rB(ctx->opcode)], 0x39);
|
|
|
|
tcg_gen_sari_tl(t0, t0, 0x3f);
|
|
|
|
tcg_gen_andc_tl(t0, cpu_gpr[rS(ctx->opcode)], t0);
|
|
|
|
t1 = tcg_temp_new();
|
|
|
|
tcg_gen_andi_tl(t1, cpu_gpr[rB(ctx->opcode)], 0x3f);
|
|
|
|
tcg_gen_shl_tl(cpu_gpr[rA(ctx->opcode)], t0, t1);
|
|
|
|
tcg_temp_free(t1);
|
2008-11-02 09:22:34 +01:00
|
|
|
tcg_temp_free(t0);
|
2019-03-21 12:57:28 +01:00
|
|
|
if (unlikely(Rc(ctx->opcode) != 0)) {
|
2008-10-21 13:31:27 +02:00
|
|
|
gen_set_Rc0(ctx, cpu_gpr[rA(ctx->opcode)]);
|
2019-03-21 12:57:28 +01:00
|
|
|
}
|
2008-10-21 13:31:27 +02:00
|
|
|
}
|
2009-06-17 17:22:09 +02:00
|
|
|
|
2009-06-17 17:22:19 +02:00
|
|
|
/* srad & srad. */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_srad(DisasContext *ctx)
|
2008-10-21 13:31:27 +02:00
|
|
|
{
|
2012-05-30 06:23:29 +02:00
|
|
|
gen_helper_srad(cpu_gpr[rA(ctx->opcode)], cpu_env,
|
2008-11-17 15:43:54 +01:00
|
|
|
cpu_gpr[rS(ctx->opcode)], cpu_gpr[rB(ctx->opcode)]);
|
2019-03-21 12:57:28 +01:00
|
|
|
if (unlikely(Rc(ctx->opcode) != 0)) {
|
2008-10-21 13:31:27 +02:00
|
|
|
gen_set_Rc0(ctx, cpu_gpr[rA(ctx->opcode)]);
|
2019-03-21 12:57:28 +01:00
|
|
|
}
|
2008-10-21 13:31:27 +02:00
|
|
|
}
|
2007-03-17 15:02:15 +01:00
|
|
|
/* sradi & sradi. */
|
2009-08-16 11:06:54 +02:00
|
|
|
static inline void gen_sradi(DisasContext *ctx, int n)
|
2007-03-17 15:02:15 +01:00
|
|
|
{
|
2008-10-21 13:31:27 +02:00
|
|
|
int sh = SH(ctx->opcode) + (n << 5);
|
2013-02-20 08:52:19 +01:00
|
|
|
TCGv dst = cpu_gpr[rA(ctx->opcode)];
|
|
|
|
TCGv src = cpu_gpr[rS(ctx->opcode)];
|
|
|
|
if (sh == 0) {
|
|
|
|
tcg_gen_mov_tl(dst, src);
|
2013-02-20 08:52:13 +01:00
|
|
|
tcg_gen_movi_tl(cpu_ca, 0);
|
2017-10-06 08:42:44 +02:00
|
|
|
if (is_isa300(ctx)) {
|
|
|
|
tcg_gen_movi_tl(cpu_ca32, 0);
|
|
|
|
}
|
2008-10-21 13:31:27 +02:00
|
|
|
} else {
|
2013-02-20 08:52:19 +01:00
|
|
|
TCGv t0;
|
|
|
|
tcg_gen_andi_tl(cpu_ca, src, (1ULL << sh) - 1);
|
|
|
|
t0 = tcg_temp_new();
|
|
|
|
tcg_gen_sari_tl(t0, src, TARGET_LONG_BITS - 1);
|
|
|
|
tcg_gen_and_tl(cpu_ca, cpu_ca, t0);
|
|
|
|
tcg_temp_free(t0);
|
|
|
|
tcg_gen_setcondi_tl(TCG_COND_NE, cpu_ca, cpu_ca, 0);
|
2017-10-06 08:42:44 +02:00
|
|
|
if (is_isa300(ctx)) {
|
|
|
|
tcg_gen_mov_tl(cpu_ca32, cpu_ca);
|
|
|
|
}
|
2013-02-20 08:52:19 +01:00
|
|
|
tcg_gen_sari_tl(dst, src, sh);
|
|
|
|
}
|
|
|
|
if (unlikely(Rc(ctx->opcode) != 0)) {
|
|
|
|
gen_set_Rc0(ctx, dst);
|
2007-03-17 15:02:15 +01:00
|
|
|
}
|
|
|
|
}
|
2009-06-17 17:22:14 +02:00
|
|
|
|
|
|
|
static void gen_sradi0(DisasContext *ctx)
|
2007-03-17 15:02:15 +01:00
|
|
|
{
|
|
|
|
gen_sradi(ctx, 0);
|
|
|
|
}
|
2009-06-17 17:22:14 +02:00
|
|
|
|
|
|
|
static void gen_sradi1(DisasContext *ctx)
|
2007-03-17 15:02:15 +01:00
|
|
|
{
|
|
|
|
gen_sradi(ctx, 1);
|
|
|
|
}
|
2009-06-17 17:22:09 +02:00
|
|
|
|
2016-07-28 20:14:18 +02: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 17:22:19 +02:00
|
|
|
/* srd & srd. */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_srd(DisasContext *ctx)
|
2008-10-21 13:31:27 +02:00
|
|
|
{
|
2009-09-18 16:56:30 +02:00
|
|
|
TCGv t0, t1;
|
2008-10-21 13:31:27 +02:00
|
|
|
|
2009-09-18 16:56:30 +02:00
|
|
|
t0 = tcg_temp_new();
|
|
|
|
/* AND rS with a mask that is 0 when rB >= 0x40 */
|
|
|
|
tcg_gen_shli_tl(t0, cpu_gpr[rB(ctx->opcode)], 0x39);
|
|
|
|
tcg_gen_sari_tl(t0, t0, 0x3f);
|
|
|
|
tcg_gen_andc_tl(t0, cpu_gpr[rS(ctx->opcode)], t0);
|
|
|
|
t1 = tcg_temp_new();
|
|
|
|
tcg_gen_andi_tl(t1, cpu_gpr[rB(ctx->opcode)], 0x3f);
|
|
|
|
tcg_gen_shr_tl(cpu_gpr[rA(ctx->opcode)], t0, t1);
|
|
|
|
tcg_temp_free(t1);
|
2008-11-02 09:22:34 +01:00
|
|
|
tcg_temp_free(t0);
|
2019-03-21 12:57:28 +01:00
|
|
|
if (unlikely(Rc(ctx->opcode) != 0)) {
|
2008-10-21 13:31:27 +02:00
|
|
|
gen_set_Rc0(ctx, cpu_gpr[rA(ctx->opcode)]);
|
2019-03-21 12:57:28 +01:00
|
|
|
}
|
2008-10-21 13:31:27 +02:00
|
|
|
}
|
2007-03-17 15:02:15 +01:00
|
|
|
#endif
|
2003-11-23 15:55:54 +01:00
|
|
|
|
2007-03-07 09:32:30 +01:00
|
|
|
/*** Addressing modes ***/
|
|
|
|
/* Register indirect with immediate index : EA = (rA|0) + SIMM */
|
2009-08-16 11:06:54 +02:00
|
|
|
static inline void gen_addr_imm_index(DisasContext *ctx, TCGv EA,
|
|
|
|
target_long maskl)
|
2007-03-07 09:32:30 +01:00
|
|
|
{
|
|
|
|
target_long simm = SIMM(ctx->opcode);
|
|
|
|
|
2007-09-30 15:03:23 +02:00
|
|
|
simm &= ~maskl;
|
2008-12-08 19:11:21 +01:00
|
|
|
if (rA(ctx->opcode) == 0) {
|
2013-03-21 11:01:48 +01:00
|
|
|
if (NARROW_MODE(ctx)) {
|
|
|
|
simm = (uint32_t)simm;
|
|
|
|
}
|
2008-10-14 21:55:54 +02:00
|
|
|
tcg_gen_movi_tl(EA, simm);
|
2008-12-08 19:11:21 +01:00
|
|
|
} else if (likely(simm != 0)) {
|
2008-10-14 21:55:54 +02:00
|
|
|
tcg_gen_addi_tl(EA, cpu_gpr[rA(ctx->opcode)], simm);
|
2013-03-21 11:01:48 +01:00
|
|
|
if (NARROW_MODE(ctx)) {
|
2008-12-08 19:11:21 +01:00
|
|
|
tcg_gen_ext32u_tl(EA, EA);
|
|
|
|
}
|
|
|
|
} else {
|
2013-03-21 11:01:48 +01:00
|
|
|
if (NARROW_MODE(ctx)) {
|
2008-12-08 19:11:21 +01:00
|
|
|
tcg_gen_ext32u_tl(EA, cpu_gpr[rA(ctx->opcode)]);
|
2013-03-21 11:01:48 +01:00
|
|
|
} else {
|
|
|
|
tcg_gen_mov_tl(EA, cpu_gpr[rA(ctx->opcode)]);
|
|
|
|
}
|
2008-12-08 19:11:21 +01:00
|
|
|
}
|
2007-03-07 09:32:30 +01:00
|
|
|
}
|
|
|
|
|
2009-08-16 11:06:54 +02:00
|
|
|
static inline void gen_addr_reg_index(DisasContext *ctx, TCGv EA)
|
2007-03-07 09:32:30 +01:00
|
|
|
{
|
2008-12-08 19:11:21 +01:00
|
|
|
if (rA(ctx->opcode) == 0) {
|
2013-03-21 11:01:48 +01:00
|
|
|
if (NARROW_MODE(ctx)) {
|
2008-12-08 19:11:21 +01:00
|
|
|
tcg_gen_ext32u_tl(EA, cpu_gpr[rB(ctx->opcode)]);
|
2013-03-21 11:01:48 +01:00
|
|
|
} else {
|
|
|
|
tcg_gen_mov_tl(EA, cpu_gpr[rB(ctx->opcode)]);
|
|
|
|
}
|
2008-12-08 19:11:21 +01:00
|
|
|
} else {
|
2008-10-14 21:55:54 +02:00
|
|
|
tcg_gen_add_tl(EA, cpu_gpr[rA(ctx->opcode)], cpu_gpr[rB(ctx->opcode)]);
|
2013-03-21 11:01:48 +01:00
|
|
|
if (NARROW_MODE(ctx)) {
|
2008-12-08 19:11:21 +01:00
|
|
|
tcg_gen_ext32u_tl(EA, EA);
|
|
|
|
}
|
|
|
|
}
|
2007-03-07 09:32:30 +01:00
|
|
|
}
|
|
|
|
|
2009-08-16 11:06:54 +02:00
|
|
|
static inline void gen_addr_register(DisasContext *ctx, TCGv EA)
|
2007-03-07 09:32:30 +01:00
|
|
|
{
|
2008-12-08 19:11:21 +01:00
|
|
|
if (rA(ctx->opcode) == 0) {
|
2008-10-14 21:55:54 +02:00
|
|
|
tcg_gen_movi_tl(EA, 0);
|
2013-03-21 11:01:48 +01:00
|
|
|
} else if (NARROW_MODE(ctx)) {
|
|
|
|
tcg_gen_ext32u_tl(EA, cpu_gpr[rA(ctx->opcode)]);
|
2008-12-08 19:11:21 +01:00
|
|
|
} else {
|
2013-03-21 11:01:48 +01:00
|
|
|
tcg_gen_mov_tl(EA, cpu_gpr[rA(ctx->opcode)]);
|
2008-12-08 19:11:21 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-08-16 11:06:54 +02:00
|
|
|
static inline void gen_addr_add(DisasContext *ctx, TCGv ret, TCGv arg1,
|
|
|
|
target_long val)
|
2008-12-08 19:11:21 +01:00
|
|
|
{
|
|
|
|
tcg_gen_addi_tl(ret, arg1, val);
|
2013-03-21 11:01:48 +01:00
|
|
|
if (NARROW_MODE(ctx)) {
|
2008-12-08 19:11:21 +01:00
|
|
|
tcg_gen_ext32u_tl(ret, ret);
|
|
|
|
}
|
2007-03-07 09:32:30 +01:00
|
|
|
}
|
|
|
|
|
2016-07-27 08:56:47 +02: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 15:11:28 +01:00
|
|
|
/*** Integer load ***/
|
2016-09-12 08:41:30 +02:00
|
|
|
#define DEF_MEMOP(op) ((op) | ctx->default_tcg_memop_mask)
|
2016-09-12 08:41:32 +02:00
|
|
|
#define BSWAP_MEMOP(op) ((op) | (ctx->default_tcg_memop_mask ^ MO_BSWAP))
|
2008-10-15 19:00:37 +02:00
|
|
|
|
2016-09-12 08:41:30 +02:00
|
|
|
#define GEN_QEMU_LOAD_TL(ldop, op) \
|
|
|
|
static void glue(gen_qemu_, ldop)(DisasContext *ctx, \
|
|
|
|
TCGv val, \
|
|
|
|
TCGv addr) \
|
|
|
|
{ \
|
|
|
|
tcg_gen_qemu_ld_tl(val, addr, ctx->mem_idx, op); \
|
2008-10-15 19:00:37 +02:00
|
|
|
}
|
|
|
|
|
2016-09-12 08:41:30 +02:00
|
|
|
GEN_QEMU_LOAD_TL(ld8u, DEF_MEMOP(MO_UB))
|
|
|
|
GEN_QEMU_LOAD_TL(ld16u, DEF_MEMOP(MO_UW))
|
|
|
|
GEN_QEMU_LOAD_TL(ld16s, DEF_MEMOP(MO_SW))
|
|
|
|
GEN_QEMU_LOAD_TL(ld32u, DEF_MEMOP(MO_UL))
|
|
|
|
GEN_QEMU_LOAD_TL(ld32s, DEF_MEMOP(MO_SL))
|
2013-12-20 11:01:50 +01:00
|
|
|
|
2016-09-12 08:41:32 +02:00
|
|
|
GEN_QEMU_LOAD_TL(ld16ur, BSWAP_MEMOP(MO_UW))
|
|
|
|
GEN_QEMU_LOAD_TL(ld32ur, BSWAP_MEMOP(MO_UL))
|
|
|
|
|
2016-09-12 08:41:30 +02:00
|
|
|
#define GEN_QEMU_LOAD_64(ldop, op) \
|
|
|
|
static void glue(gen_qemu_, glue(ldop, _i64))(DisasContext *ctx, \
|
|
|
|
TCGv_i64 val, \
|
|
|
|
TCGv addr) \
|
|
|
|
{ \
|
|
|
|
tcg_gen_qemu_ld_i64(val, addr, ctx->mem_idx, op); \
|
2008-10-15 19:00:37 +02:00
|
|
|
}
|
|
|
|
|
2016-09-12 08:41:41 +02:00
|
|
|
GEN_QEMU_LOAD_64(ld8u, DEF_MEMOP(MO_UB))
|
|
|
|
GEN_QEMU_LOAD_64(ld16u, DEF_MEMOP(MO_UW))
|
2016-09-12 08:41:30 +02:00
|
|
|
GEN_QEMU_LOAD_64(ld32u, DEF_MEMOP(MO_UL))
|
|
|
|
GEN_QEMU_LOAD_64(ld32s, DEF_MEMOP(MO_SL))
|
2016-09-12 08:41:31 +02:00
|
|
|
GEN_QEMU_LOAD_64(ld64, DEF_MEMOP(MO_Q))
|
2008-10-15 19:00:37 +02:00
|
|
|
|
2016-09-12 08:41:32 +02:00
|
|
|
#if defined(TARGET_PPC64)
|
|
|
|
GEN_QEMU_LOAD_64(ld64ur, BSWAP_MEMOP(MO_Q))
|
|
|
|
#endif
|
|
|
|
|
2016-09-12 08:41:33 +02:00
|
|
|
#define GEN_QEMU_STORE_TL(stop, op) \
|
|
|
|
static void glue(gen_qemu_, stop)(DisasContext *ctx, \
|
|
|
|
TCGv val, \
|
|
|
|
TCGv addr) \
|
|
|
|
{ \
|
|
|
|
tcg_gen_qemu_st_tl(val, addr, ctx->mem_idx, op); \
|
2008-10-15 19:00:37 +02:00
|
|
|
}
|
|
|
|
|
2021-06-01 21:35:22 +02:00
|
|
|
#if defined(TARGET_PPC64) || !defined(CONFIG_USER_ONLY)
|
2016-09-12 08:41:33 +02:00
|
|
|
GEN_QEMU_STORE_TL(st8, DEF_MEMOP(MO_UB))
|
2021-06-01 21:35:22 +02:00
|
|
|
#endif
|
2016-09-12 08:41:33 +02:00
|
|
|
GEN_QEMU_STORE_TL(st16, DEF_MEMOP(MO_UW))
|
|
|
|
GEN_QEMU_STORE_TL(st32, DEF_MEMOP(MO_UL))
|
2008-10-15 19:00:37 +02:00
|
|
|
|
2016-09-12 08:41:35 +02:00
|
|
|
GEN_QEMU_STORE_TL(st16r, BSWAP_MEMOP(MO_UW))
|
|
|
|
GEN_QEMU_STORE_TL(st32r, BSWAP_MEMOP(MO_UL))
|
|
|
|
|
2016-09-12 08:41:33 +02:00
|
|
|
#define GEN_QEMU_STORE_64(stop, op) \
|
|
|
|
static void glue(gen_qemu_, glue(stop, _i64))(DisasContext *ctx, \
|
|
|
|
TCGv_i64 val, \
|
|
|
|
TCGv addr) \
|
|
|
|
{ \
|
|
|
|
tcg_gen_qemu_st_i64(val, addr, ctx->mem_idx, op); \
|
2008-10-15 19:00:37 +02:00
|
|
|
}
|
|
|
|
|
2016-09-12 08:41:42 +02:00
|
|
|
GEN_QEMU_STORE_64(st8, DEF_MEMOP(MO_UB))
|
|
|
|
GEN_QEMU_STORE_64(st16, DEF_MEMOP(MO_UW))
|
2016-09-12 08:41:33 +02:00
|
|
|
GEN_QEMU_STORE_64(st32, DEF_MEMOP(MO_UL))
|
2016-09-12 08:41:34 +02:00
|
|
|
GEN_QEMU_STORE_64(st64, DEF_MEMOP(MO_Q))
|
2008-10-15 19:00:37 +02:00
|
|
|
|
2016-09-12 08:41:35 +02:00
|
|
|
#if defined(TARGET_PPC64)
|
|
|
|
GEN_QEMU_STORE_64(st64r, BSWAP_MEMOP(MO_Q))
|
|
|
|
#endif
|
|
|
|
|
2016-06-21 23:48:52 +02:00
|
|
|
#define GEN_LDX_E(name, ldop, opc2, opc3, type, type2, chk) \
|
2009-06-17 17:22:09 +02:00
|
|
|
static void glue(gen_, name##x)(DisasContext *ctx) \
|
2003-11-23 15:55:54 +01:00
|
|
|
{ \
|
2008-12-08 19:11:21 +01:00
|
|
|
TCGv EA; \
|
2016-06-21 23:48:52 +02:00
|
|
|
chk; \
|
2008-12-08 19:11:21 +01: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 19:00:37 +02:00
|
|
|
tcg_temp_free(EA); \
|
2003-11-23 15:55:54 +01:00
|
|
|
}
|
2016-06-21 23:48:52 +02:00
|
|
|
|
2012-02-27 18:18:08 +01:00
|
|
|
#define GEN_LDX(name, ldop, opc2, opc3, type) \
|
2016-06-21 23:48:52 +02: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 15:55:54 +01:00
|
|
|
|
2018-09-21 08:59:07 +02:00
|
|
|
#define GEN_LDEPX(name, ldop, opc2, opc3) \
|
|
|
|
static void glue(gen_, name##epx)(DisasContext *ctx) \
|
|
|
|
{ \
|
|
|
|
TCGv EA; \
|
|
|
|
CHK_SV; \
|
|
|
|
gen_set_access_type(ctx, ACCESS_INT); \
|
|
|
|
EA = tcg_temp_new(); \
|
|
|
|
gen_addr_reg_index(ctx, EA); \
|
|
|
|
tcg_gen_qemu_ld_tl(cpu_gpr[rD(ctx->opcode)], EA, PPC_TLB_EPID_LOAD, ldop);\
|
|
|
|
tcg_temp_free(EA); \
|
|
|
|
}
|
|
|
|
|
|
|
|
GEN_LDEPX(lb, DEF_MEMOP(MO_UB), 0x1F, 0x02)
|
|
|
|
GEN_LDEPX(lh, DEF_MEMOP(MO_UW), 0x1F, 0x08)
|
|
|
|
GEN_LDEPX(lw, DEF_MEMOP(MO_UL), 0x1F, 0x00)
|
|
|
|
#if defined(TARGET_PPC64)
|
|
|
|
GEN_LDEPX(ld, DEF_MEMOP(MO_Q), 0x1D, 0x00)
|
|
|
|
#endif
|
|
|
|
|
2007-03-17 15:02:15 +01:00
|
|
|
#if defined(TARGET_PPC64)
|
2016-06-21 23:48:52 +02:00
|
|
|
/* CI load/store variants */
|
2016-09-12 08:41:31 +02:00
|
|
|
GEN_LDX_HVRM(ldcix, ld64_i64, 0x15, 0x1b, PPC_CILDST)
|
2016-06-21 23:48:52 +02:00
|
|
|
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 17:22:19 +02:00
|
|
|
/* lq */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_lq(DisasContext *ctx)
|
2007-09-30 15:03:23 +02:00
|
|
|
{
|
|
|
|
int ra, rd;
|
2018-06-26 18:19:10 +02:00
|
|
|
TCGv EA, hi, lo;
|
2007-09-30 15:03:23 +02:00
|
|
|
|
2014-02-10 18:26:58 +01:00
|
|
|
/* lq is a legal user mode instruction starting in ISA 2.07 */
|
|
|
|
bool legal_in_user_mode = (ctx->insns_flags2 & PPC2_LSQ_ISA207) != 0;
|
|
|
|
bool le_is_supported = (ctx->insns_flags2 & PPC2_LSQ_ISA207) != 0;
|
|
|
|
|
2014-09-15 17:03:28 +02:00
|
|
|
if (!legal_in_user_mode && ctx->pr) {
|
2016-06-21 23:48:51 +02:00
|
|
|
gen_priv_exception(ctx, POWERPC_EXCP_PRIV_OPC);
|
2007-09-30 15:03:23 +02:00
|
|
|
return;
|
|
|
|
}
|
2014-02-10 18:26:58 +01:00
|
|
|
|
|
|
|
if (!le_is_supported && ctx->le_mode) {
|
2016-07-27 08:56:47 +02:00
|
|
|
gen_align_no_le(ctx);
|
2014-02-10 18:26:58 +01:00
|
|
|
return;
|
|
|
|
}
|
2007-09-30 15:03:23 +02:00
|
|
|
ra = rA(ctx->opcode);
|
|
|
|
rd = rD(ctx->opcode);
|
|
|
|
if (unlikely((rd & 1) || rd == ra)) {
|
2008-12-11 23:42:14 +01:00
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_INVAL_INVAL);
|
2007-09-30 15:03:23 +02:00
|
|
|
return;
|
|
|
|
}
|
2014-02-10 18:26:58 +01:00
|
|
|
|
2008-12-08 19:11:21 +01:00
|
|
|
gen_set_access_type(ctx, ACCESS_INT);
|
2008-11-17 15:43:54 +01:00
|
|
|
EA = tcg_temp_new();
|
2008-12-08 19:11:21 +01:00
|
|
|
gen_addr_imm_index(ctx, EA, 0x0F);
|
2014-02-10 18:26:58 +01:00
|
|
|
|
2018-06-26 18:19:10 +02:00
|
|
|
/* Note that the low part is always in RD+1, even in LE mode. */
|
|
|
|
lo = cpu_gpr[rd + 1];
|
|
|
|
hi = cpu_gpr[rd];
|
|
|
|
|
|
|
|
if (tb_cflags(ctx->base.tb) & CF_PARALLEL) {
|
2018-08-16 02:35:14 +02:00
|
|
|
if (HAVE_ATOMIC128) {
|
|
|
|
TCGv_i32 oi = tcg_temp_new_i32();
|
|
|
|
if (ctx->le_mode) {
|
|
|
|
tcg_gen_movi_i32(oi, make_memop_idx(MO_LEQ, ctx->mem_idx));
|
|
|
|
gen_helper_lq_le_parallel(lo, cpu_env, EA, oi);
|
|
|
|
} else {
|
|
|
|
tcg_gen_movi_i32(oi, make_memop_idx(MO_BEQ, ctx->mem_idx));
|
|
|
|
gen_helper_lq_be_parallel(lo, cpu_env, EA, oi);
|
|
|
|
}
|
|
|
|
tcg_temp_free_i32(oi);
|
|
|
|
tcg_gen_ld_i64(hi, cpu_env, offsetof(CPUPPCState, retxh));
|
2018-06-26 18:19:10 +02:00
|
|
|
} else {
|
2018-08-16 02:35:14 +02:00
|
|
|
/* Restart with exclusive lock. */
|
|
|
|
gen_helper_exit_atomic(cpu_env);
|
|
|
|
ctx->base.is_jmp = DISAS_NORETURN;
|
2018-06-26 18:19:10 +02:00
|
|
|
}
|
|
|
|
} else if (ctx->le_mode) {
|
|
|
|
tcg_gen_qemu_ld_i64(lo, EA, ctx->mem_idx, MO_LEQ);
|
2014-02-10 18:26:58 +01:00
|
|
|
gen_addr_add(ctx, EA, EA, 8);
|
2018-06-26 18:19:10 +02:00
|
|
|
tcg_gen_qemu_ld_i64(hi, EA, ctx->mem_idx, MO_LEQ);
|
2014-02-10 18:26:58 +01:00
|
|
|
} else {
|
2018-06-26 18:19:10 +02:00
|
|
|
tcg_gen_qemu_ld_i64(hi, EA, ctx->mem_idx, MO_BEQ);
|
2014-02-10 18:26:58 +01:00
|
|
|
gen_addr_add(ctx, EA, EA, 8);
|
2018-06-26 18:19:10 +02:00
|
|
|
tcg_gen_qemu_ld_i64(lo, EA, ctx->mem_idx, MO_BEQ);
|
2014-02-10 18:26:58 +01:00
|
|
|
}
|
2008-10-15 19:00:37 +02:00
|
|
|
tcg_temp_free(EA);
|
2007-09-30 15:03:23 +02:00
|
|
|
}
|
2007-03-17 15:02:15 +01:00
|
|
|
#endif
|
2003-11-23 15:55:54 +01:00
|
|
|
|
|
|
|
/*** Integer store ***/
|
2016-06-21 23:48:52 +02:00
|
|
|
#define GEN_STX_E(name, stop, opc2, opc3, type, type2, chk) \
|
2012-02-27 18:18:08 +01:00
|
|
|
static void glue(gen_, name##x)(DisasContext *ctx) \
|
2003-11-23 15:55:54 +01:00
|
|
|
{ \
|
2008-12-08 19:11:21 +01:00
|
|
|
TCGv EA; \
|
2016-06-21 23:48:52 +02:00
|
|
|
chk; \
|
2008-12-08 19:11:21 +01: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 19:00:37 +02:00
|
|
|
tcg_temp_free(EA); \
|
2003-11-23 15:55:54 +01:00
|
|
|
}
|
2012-02-27 18:18:08 +01:00
|
|
|
#define GEN_STX(name, stop, opc2, opc3, type) \
|
2016-06-21 23:48:52 +02: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 15:55:54 +01:00
|
|
|
|
2018-09-21 08:59:07 +02:00
|
|
|
#define GEN_STEPX(name, stop, opc2, opc3) \
|
|
|
|
static void glue(gen_, name##epx)(DisasContext *ctx) \
|
|
|
|
{ \
|
|
|
|
TCGv EA; \
|
|
|
|
CHK_SV; \
|
|
|
|
gen_set_access_type(ctx, ACCESS_INT); \
|
|
|
|
EA = tcg_temp_new(); \
|
|
|
|
gen_addr_reg_index(ctx, EA); \
|
|
|
|
tcg_gen_qemu_st_tl( \
|
|
|
|
cpu_gpr[rD(ctx->opcode)], EA, PPC_TLB_EPID_STORE, stop); \
|
|
|
|
tcg_temp_free(EA); \
|
|
|
|
}
|
|
|
|
|
|
|
|
GEN_STEPX(stb, DEF_MEMOP(MO_UB), 0x1F, 0x06)
|
|
|
|
GEN_STEPX(sth, DEF_MEMOP(MO_UW), 0x1F, 0x0C)
|
|
|
|
GEN_STEPX(stw, DEF_MEMOP(MO_UL), 0x1F, 0x04)
|
|
|
|
#if defined(TARGET_PPC64)
|
|
|
|
GEN_STEPX(std, DEF_MEMOP(MO_Q), 0x1d, 0x04)
|
|
|
|
#endif
|
|
|
|
|
2007-03-17 15:02:15 +01:00
|
|
|
#if defined(TARGET_PPC64)
|
2016-09-12 08:41:34 +02:00
|
|
|
GEN_STX_HVRM(stdcix, st64_i64, 0x15, 0x1f, PPC_CILDST)
|
2016-06-21 23:48:52 +02:00
|
|
|
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 17:22:09 +02:00
|
|
|
|
|
|
|
static void gen_std(DisasContext *ctx)
|
2007-03-17 15:02:15 +01:00
|
|
|
{
|
2007-09-30 15:03:23 +02:00
|
|
|
int rs;
|
2008-10-15 19:00:37 +02:00
|
|
|
TCGv EA;
|
2007-09-30 15:03:23 +02:00
|
|
|
|
|
|
|
rs = rS(ctx->opcode);
|
2014-02-10 18:26:59 +01:00
|
|
|
if ((ctx->opcode & 0x3) == 0x2) { /* stq */
|
|
|
|
bool legal_in_user_mode = (ctx->insns_flags2 & PPC2_LSQ_ISA207) != 0;
|
|
|
|
bool le_is_supported = (ctx->insns_flags2 & PPC2_LSQ_ISA207) != 0;
|
2018-06-26 18:19:11 +02:00
|
|
|
TCGv hi, lo;
|
2014-02-10 18:26:59 +01:00
|
|
|
|
2016-06-07 04:50:24 +02:00
|
|
|
if (!(ctx->insns_flags & PPC_64BX)) {
|
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_INVAL_INVAL);
|
|
|
|
}
|
|
|
|
|
2014-09-15 17:03:28 +02:00
|
|
|
if (!legal_in_user_mode && ctx->pr) {
|
2016-06-21 23:48:51 +02:00
|
|
|
gen_priv_exception(ctx, POWERPC_EXCP_PRIV_OPC);
|
2007-09-30 15:03:23 +02:00
|
|
|
return;
|
|
|
|
}
|
2014-02-10 18:26:59 +01:00
|
|
|
|
|
|
|
if (!le_is_supported && ctx->le_mode) {
|
2016-07-27 08:56:47 +02:00
|
|
|
gen_align_no_le(ctx);
|
2007-03-17 15:02:15 +01:00
|
|
|
return;
|
|
|
|
}
|
2014-02-10 18:26:59 +01:00
|
|
|
|
|
|
|
if (unlikely(rs & 1)) {
|
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_INVAL_INVAL);
|
2007-09-30 15:03:23 +02:00
|
|
|
return;
|
|
|
|
}
|
2008-12-08 19:11:21 +01:00
|
|
|
gen_set_access_type(ctx, ACCESS_INT);
|
2008-11-17 15:43:54 +01:00
|
|
|
EA = tcg_temp_new();
|
2008-12-08 19:11:21 +01:00
|
|
|
gen_addr_imm_index(ctx, EA, 0x03);
|
2014-02-10 18:26:59 +01:00
|
|
|
|
2018-06-26 18:19:11 +02:00
|
|
|
/* Note that the low part is always in RS+1, even in LE mode. */
|
|
|
|
lo = cpu_gpr[rs + 1];
|
|
|
|
hi = cpu_gpr[rs];
|
|
|
|
|
|
|
|
if (tb_cflags(ctx->base.tb) & CF_PARALLEL) {
|
2018-08-16 02:35:14 +02:00
|
|
|
if (HAVE_ATOMIC128) {
|
|
|
|
TCGv_i32 oi = tcg_temp_new_i32();
|
|
|
|
if (ctx->le_mode) {
|
|
|
|
tcg_gen_movi_i32(oi, make_memop_idx(MO_LEQ, ctx->mem_idx));
|
|
|
|
gen_helper_stq_le_parallel(cpu_env, EA, lo, hi, oi);
|
|
|
|
} else {
|
|
|
|
tcg_gen_movi_i32(oi, make_memop_idx(MO_BEQ, ctx->mem_idx));
|
|
|
|
gen_helper_stq_be_parallel(cpu_env, EA, lo, hi, oi);
|
|
|
|
}
|
|
|
|
tcg_temp_free_i32(oi);
|
2018-06-26 18:19:11 +02:00
|
|
|
} else {
|
2018-08-16 02:35:14 +02:00
|
|
|
/* Restart with exclusive lock. */
|
|
|
|
gen_helper_exit_atomic(cpu_env);
|
|
|
|
ctx->base.is_jmp = DISAS_NORETURN;
|
2018-06-26 18:19:11 +02:00
|
|
|
}
|
|
|
|
} else if (ctx->le_mode) {
|
|
|
|
tcg_gen_qemu_st_i64(lo, EA, ctx->mem_idx, MO_LEQ);
|
2014-02-10 18:26:59 +01:00
|
|
|
gen_addr_add(ctx, EA, EA, 8);
|
2018-06-26 18:19:11 +02:00
|
|
|
tcg_gen_qemu_st_i64(hi, EA, ctx->mem_idx, MO_LEQ);
|
2014-02-10 18:26:59 +01:00
|
|
|
} else {
|
2018-06-26 18:19:11 +02:00
|
|
|
tcg_gen_qemu_st_i64(hi, EA, ctx->mem_idx, MO_BEQ);
|
2014-02-10 18:26:59 +01:00
|
|
|
gen_addr_add(ctx, EA, EA, 8);
|
2018-06-26 18:19:11 +02:00
|
|
|
tcg_gen_qemu_st_i64(lo, EA, ctx->mem_idx, MO_BEQ);
|
2014-02-10 18:26:59 +01:00
|
|
|
}
|
2008-10-15 19:00:37 +02:00
|
|
|
tcg_temp_free(EA);
|
2007-09-30 15:03:23 +02:00
|
|
|
} else {
|
2018-06-26 18:19:11 +02:00
|
|
|
/* std / stdu */
|
2007-09-30 15:03:23 +02:00
|
|
|
if (Rc(ctx->opcode)) {
|
|
|
|
if (unlikely(rA(ctx->opcode) == 0)) {
|
2008-12-11 23:42:14 +01:00
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_INVAL_INVAL);
|
2007-09-30 15:03:23 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2008-12-08 19:11:21 +01:00
|
|
|
gen_set_access_type(ctx, ACCESS_INT);
|
2008-11-17 15:43:54 +01:00
|
|
|
EA = tcg_temp_new();
|
2008-12-08 19:11:21 +01:00
|
|
|
gen_addr_imm_index(ctx, EA, 0x03);
|
2016-09-12 08:41:34 +02:00
|
|
|
gen_qemu_st64_i64(ctx, cpu_gpr[rs], EA);
|
2019-03-21 12:57:28 +01:00
|
|
|
if (Rc(ctx->opcode)) {
|
2008-10-15 19:00:37 +02:00
|
|
|
tcg_gen_mov_tl(cpu_gpr[rA(ctx->opcode)], EA);
|
2019-03-21 12:57:28 +01:00
|
|
|
}
|
2008-10-15 19:00:37 +02:00
|
|
|
tcg_temp_free(EA);
|
2007-03-17 15:02:15 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
2003-11-23 15:55:54 +01:00
|
|
|
/*** Integer load and store with byte reverse ***/
|
2014-05-29 16:12:20 +02:00
|
|
|
|
2003-11-23 15:55:54 +01:00
|
|
|
/* lhbrx */
|
2008-11-23 17:30:28 +01:00
|
|
|
GEN_LDX(lhbr, ld16ur, 0x16, 0x18, PPC_INTEGER);
|
2008-10-15 19:00:37 +02:00
|
|
|
|
2003-11-23 15:55:54 +01:00
|
|
|
/* lwbrx */
|
2008-11-23 17:30:28 +01:00
|
|
|
GEN_LDX(lwbr, ld32ur, 0x16, 0x10, PPC_INTEGER);
|
2008-10-15 19:00:37 +02:00
|
|
|
|
2012-02-27 18:18:08 +01:00
|
|
|
#if defined(TARGET_PPC64)
|
|
|
|
/* ldbrx */
|
2016-09-12 08:41:32 +02:00
|
|
|
GEN_LDX_E(ldbr, ld64ur_i64, 0x14, 0x10, PPC_NONE, PPC2_DBRX, CHK_NONE);
|
2016-09-12 08:41:35 +02:00
|
|
|
/* stdbrx */
|
|
|
|
GEN_STX_E(stdbr, st64r_i64, 0x14, 0x14, PPC_NONE, PPC2_DBRX, CHK_NONE);
|
2012-02-27 18:18:08 +01:00
|
|
|
#endif /* TARGET_PPC64 */
|
|
|
|
|
2003-11-23 15:55:54 +01:00
|
|
|
/* sthbrx */
|
2008-11-23 17:30:28 +01:00
|
|
|
GEN_STX(sthbr, st16r, 0x16, 0x1C, PPC_INTEGER);
|
2003-11-23 15:55:54 +01:00
|
|
|
/* stwbrx */
|
2008-11-23 17:30:28 +01:00
|
|
|
GEN_STX(stwbr, st32r, 0x16, 0x14, PPC_INTEGER);
|
2003-11-23 15:55:54 +01:00
|
|
|
|
|
|
|
/*** Integer load and store multiple ***/
|
2009-06-17 17:22:09 +02:00
|
|
|
|
2009-06-17 17:22:19 +02:00
|
|
|
/* lmw */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_lmw(DisasContext *ctx)
|
2003-11-23 15:55:54 +01:00
|
|
|
{
|
2008-12-08 19:11:21 +01:00
|
|
|
TCGv t0;
|
|
|
|
TCGv_i32 t1;
|
2016-07-27 08:56:48 +02:00
|
|
|
|
|
|
|
if (ctx->le_mode) {
|
|
|
|
gen_align_no_le(ctx);
|
|
|
|
return;
|
|
|
|
}
|
2008-12-08 19:11:21 +01: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 06:23:40 +02:00
|
|
|
gen_helper_lmw(cpu_env, t0, t1);
|
2008-11-30 17:23:56 +01:00
|
|
|
tcg_temp_free(t0);
|
|
|
|
tcg_temp_free_i32(t1);
|
2003-11-23 15:55:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* stmw */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_stmw(DisasContext *ctx)
|
2003-11-23 15:55:54 +01:00
|
|
|
{
|
2008-12-08 19:11:21 +01:00
|
|
|
TCGv t0;
|
|
|
|
TCGv_i32 t1;
|
2016-07-27 08:56:48 +02:00
|
|
|
|
|
|
|
if (ctx->le_mode) {
|
|
|
|
gen_align_no_le(ctx);
|
|
|
|
return;
|
|
|
|
}
|
2008-12-08 19:11:21 +01: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 06:23:40 +02:00
|
|
|
gen_helper_stmw(cpu_env, t0, t1);
|
2008-11-30 17:23:56 +01:00
|
|
|
tcg_temp_free(t0);
|
|
|
|
tcg_temp_free_i32(t1);
|
2003-11-23 15:55:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*** Integer load and store strings ***/
|
2009-06-17 17:22:19 +02:00
|
|
|
|
2003-11-23 15:55:54 +01:00
|
|
|
/* lswi */
|
2019-03-21 12:57:28 +01:00
|
|
|
/*
|
|
|
|
* PowerPC32 specification says we must generate an exception if 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...
|
2004-01-04 23:58:38 +01:00
|
|
|
*/
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_lswi(DisasContext *ctx)
|
2003-11-23 15:55:54 +01:00
|
|
|
{
|
2008-11-30 17:24:21 +01:00
|
|
|
TCGv t0;
|
|
|
|
TCGv_i32 t1, t2;
|
2003-11-23 15:55:54 +01:00
|
|
|
int nb = NB(ctx->opcode);
|
|
|
|
int start = rD(ctx->opcode);
|
2004-01-04 23:58:38 +01:00
|
|
|
int ra = rA(ctx->opcode);
|
2003-11-23 15:55:54 +01:00
|
|
|
int nr;
|
|
|
|
|
2016-07-27 08:56:48 +02:00
|
|
|
if (ctx->le_mode) {
|
|
|
|
gen_align_no_le(ctx);
|
|
|
|
return;
|
|
|
|
}
|
2019-03-21 12:57:28 +01:00
|
|
|
if (nb == 0) {
|
2003-11-23 15:55:54 +01:00
|
|
|
nb = 32;
|
2019-03-21 12:57:28 +01:00
|
|
|
}
|
2017-06-22 13:04:16 +02:00
|
|
|
nr = DIV_ROUND_UP(nb, 4);
|
2016-04-14 17:14:52 +02:00
|
|
|
if (unlikely(lsw_reg_in_range(start, nr, ra))) {
|
2008-12-11 23:42:14 +01:00
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_INVAL_LSWX);
|
2004-05-21 14:59:32 +02:00
|
|
|
return;
|
2004-02-21 15:11:27 +01:00
|
|
|
}
|
2008-12-08 19:11:21 +01:00
|
|
|
gen_set_access_type(ctx, ACCESS_INT);
|
2008-11-30 17:24:21 +01:00
|
|
|
t0 = tcg_temp_new();
|
2008-12-08 19:11:21 +01:00
|
|
|
gen_addr_register(ctx, t0);
|
2008-11-30 17:24:21 +01:00
|
|
|
t1 = tcg_const_i32(nb);
|
|
|
|
t2 = tcg_const_i32(start);
|
2012-05-30 06:23:40 +02:00
|
|
|
gen_helper_lsw(cpu_env, t0, t1, t2);
|
2008-11-30 17:24:21 +01:00
|
|
|
tcg_temp_free(t0);
|
|
|
|
tcg_temp_free_i32(t1);
|
|
|
|
tcg_temp_free_i32(t2);
|
2003-11-23 15:55:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* lswx */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_lswx(DisasContext *ctx)
|
2003-11-23 15:55:54 +01:00
|
|
|
{
|
2008-12-08 19:11:21 +01:00
|
|
|
TCGv t0;
|
|
|
|
TCGv_i32 t1, t2, t3;
|
2016-07-27 08:56:48 +02:00
|
|
|
|
|
|
|
if (ctx->le_mode) {
|
|
|
|
gen_align_no_le(ctx);
|
|
|
|
return;
|
|
|
|
}
|
2008-12-08 19:11:21 +01: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 06:23:40 +02:00
|
|
|
gen_helper_lswx(cpu_env, t0, t1, t2, t3);
|
2008-11-30 17:24:21 +01:00
|
|
|
tcg_temp_free(t0);
|
|
|
|
tcg_temp_free_i32(t1);
|
|
|
|
tcg_temp_free_i32(t2);
|
|
|
|
tcg_temp_free_i32(t3);
|
2003-11-23 15:55:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* stswi */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_stswi(DisasContext *ctx)
|
2003-11-23 15:55:54 +01:00
|
|
|
{
|
2008-12-08 19:11:21 +01:00
|
|
|
TCGv t0;
|
|
|
|
TCGv_i32 t1, t2;
|
2004-05-24 00:18:12 +02:00
|
|
|
int nb = NB(ctx->opcode);
|
2016-07-27 08:56:48 +02:00
|
|
|
|
|
|
|
if (ctx->le_mode) {
|
|
|
|
gen_align_no_le(ctx);
|
|
|
|
return;
|
|
|
|
}
|
2008-12-08 19:11:21 +01:00
|
|
|
gen_set_access_type(ctx, ACCESS_INT);
|
|
|
|
t0 = tcg_temp_new();
|
|
|
|
gen_addr_register(ctx, t0);
|
2019-03-21 12:57:28 +01:00
|
|
|
if (nb == 0) {
|
2004-05-24 00:18:12 +02:00
|
|
|
nb = 32;
|
2019-03-21 12:57:28 +01:00
|
|
|
}
|
2008-11-30 17:24:21 +01:00
|
|
|
t1 = tcg_const_i32(nb);
|
2008-12-08 19:11:21 +01:00
|
|
|
t2 = tcg_const_i32(rS(ctx->opcode));
|
2012-05-30 06:23:40 +02:00
|
|
|
gen_helper_stsw(cpu_env, t0, t1, t2);
|
2008-11-30 17:24:21 +01:00
|
|
|
tcg_temp_free(t0);
|
|
|
|
tcg_temp_free_i32(t1);
|
|
|
|
tcg_temp_free_i32(t2);
|
2003-11-23 15:55:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* stswx */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_stswx(DisasContext *ctx)
|
2003-11-23 15:55:54 +01:00
|
|
|
{
|
2008-12-08 19:11:21 +01:00
|
|
|
TCGv t0;
|
|
|
|
TCGv_i32 t1, t2;
|
2016-07-27 08:56:48 +02:00
|
|
|
|
|
|
|
if (ctx->le_mode) {
|
|
|
|
gen_align_no_le(ctx);
|
|
|
|
return;
|
|
|
|
}
|
2008-12-08 19:11:21 +01: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 17:24:21 +01:00
|
|
|
tcg_gen_trunc_tl_i32(t1, cpu_xer);
|
|
|
|
tcg_gen_andi_i32(t1, t1, 0x7F);
|
2008-12-08 19:11:21 +01:00
|
|
|
t2 = tcg_const_i32(rS(ctx->opcode));
|
2012-05-30 06:23:40 +02:00
|
|
|
gen_helper_stsw(cpu_env, t0, t1, t2);
|
2008-11-30 17:24:21 +01:00
|
|
|
tcg_temp_free(t0);
|
|
|
|
tcg_temp_free_i32(t1);
|
|
|
|
tcg_temp_free_i32(t2);
|
2003-11-23 15:55:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*** Memory synchronisation ***/
|
|
|
|
/* eieio */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_eieio(DisasContext *ctx)
|
2003-11-23 15:55:54 +01:00
|
|
|
{
|
2018-06-06 09:33:53 +02:00
|
|
|
TCGBar bar = TCG_MO_LD_ST;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* POWER9 has a eieio instruction variant using bit 6 as a hint to
|
|
|
|
* tell the CPU it is a store-forwarding barrier.
|
|
|
|
*/
|
|
|
|
if (ctx->opcode & 0x2000000) {
|
|
|
|
/*
|
|
|
|
* ISA says that "Reserved fields in instructions are ignored
|
|
|
|
* by the processor". So ignore the bit 6 on non-POWER9 CPU but
|
|
|
|
* as this is not an instruction software should be using,
|
|
|
|
* complain to the user.
|
|
|
|
*/
|
|
|
|
if (!(ctx->insns_flags2 & PPC2_ISA300)) {
|
|
|
|
qemu_log_mask(LOG_GUEST_ERROR, "invalid eieio using bit 6 at @"
|
2021-05-12 20:54:11 +02:00
|
|
|
TARGET_FMT_lx "\n", ctx->cia);
|
2018-06-06 09:33:53 +02:00
|
|
|
} else {
|
|
|
|
bar = TCG_MO_ST_LD;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
tcg_gen_mb(bar | TCG_BAR_SC);
|
2003-11-23 15:55:54 +01:00
|
|
|
}
|
|
|
|
|
2016-06-07 04:50:22 +02:00
|
|
|
#if !defined(CONFIG_USER_ONLY)
|
2016-09-20 18:35:00 +02:00
|
|
|
static inline void gen_check_tlb_flush(DisasContext *ctx, bool global)
|
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 18:03:25 +02:00
|
|
|
{
|
2016-06-07 04:50:22 +02: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 18:03:25 +02:00
|
|
|
|
2016-06-07 04:50:22 +02: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 18:03:25 +02:00
|
|
|
tcg_gen_ld_i32(t, cpu_env, offsetof(CPUPPCState, tlb_need_flush));
|
|
|
|
tcg_gen_brcondi_i32(TCG_COND_EQ, t, 0, l);
|
2016-09-20 18:35:00 +02:00
|
|
|
if (global) {
|
|
|
|
gen_helper_check_tlb_flush_global(cpu_env);
|
|
|
|
} else {
|
|
|
|
gen_helper_check_tlb_flush_local(cpu_env);
|
|
|
|
}
|
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 18:03:25 +02:00
|
|
|
gen_set_label(l);
|
|
|
|
tcg_temp_free_i32(t);
|
|
|
|
}
|
|
|
|
#else
|
2016-09-20 18:35:00 +02:00
|
|
|
static inline void gen_check_tlb_flush(DisasContext *ctx, bool global) { }
|
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 18:03:25 +02:00
|
|
|
#endif
|
|
|
|
|
2003-11-23 15:55:54 +01:00
|
|
|
/* isync */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_isync(DisasContext *ctx)
|
2003-11-23 15:55:54 +01:00
|
|
|
{
|
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 18:03:25 +02: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) {
|
2016-09-20 18:35:00 +02:00
|
|
|
gen_check_tlb_flush(ctx, false);
|
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 18:03:25 +02:00
|
|
|
}
|
2017-04-27 07:18:21 +02:00
|
|
|
tcg_gen_mb(TCG_MO_ALL | TCG_BAR_SC);
|
2021-05-17 22:50:04 +02:00
|
|
|
ctx->base.is_jmp = DISAS_EXIT_UPDATE;
|
2003-11-23 15:55:54 +01:00
|
|
|
}
|
|
|
|
|
2016-09-12 08:41:36 +02:00
|
|
|
#define MEMOP_GET_SIZE(x) (1 << ((x) & MO_SIZE))
|
|
|
|
|
2019-08-23 20:10:58 +02:00
|
|
|
static void gen_load_locked(DisasContext *ctx, MemOp memop)
|
2018-06-26 18:19:15 +02:00
|
|
|
{
|
|
|
|
TCGv gpr = cpu_gpr[rD(ctx->opcode)];
|
|
|
|
TCGv t0 = tcg_temp_new();
|
|
|
|
|
|
|
|
gen_set_access_type(ctx, ACCESS_RES);
|
|
|
|
gen_addr_reg_index(ctx, t0);
|
|
|
|
tcg_gen_qemu_ld_tl(gpr, t0, ctx->mem_idx, memop | MO_ALIGN);
|
|
|
|
tcg_gen_mov_tl(cpu_reserve, t0);
|
|
|
|
tcg_gen_mov_tl(cpu_reserve_val, gpr);
|
|
|
|
tcg_gen_mb(TCG_MO_ALL | TCG_BAR_LDAQ);
|
|
|
|
tcg_temp_free(t0);
|
|
|
|
}
|
|
|
|
|
|
|
|
#define LARX(name, memop) \
|
|
|
|
static void gen_##name(DisasContext *ctx) \
|
|
|
|
{ \
|
|
|
|
gen_load_locked(ctx, memop); \
|
2003-11-23 15:55:54 +01:00
|
|
|
}
|
|
|
|
|
2014-01-07 17:05:56 +01:00
|
|
|
/* lwarx */
|
2016-09-12 08:41:36 +02:00
|
|
|
LARX(lbarx, DEF_MEMOP(MO_UB))
|
|
|
|
LARX(lharx, DEF_MEMOP(MO_UW))
|
|
|
|
LARX(lwarx, DEF_MEMOP(MO_UL))
|
2014-01-07 17:05:56 +01:00
|
|
|
|
2019-08-23 20:10:58 +02:00
|
|
|
static void gen_fetch_inc_conditional(DisasContext *ctx, MemOp memop,
|
2018-06-26 18:19:20 +02:00
|
|
|
TCGv EA, TCGCond cond, int addend)
|
|
|
|
{
|
|
|
|
TCGv t = tcg_temp_new();
|
|
|
|
TCGv t2 = tcg_temp_new();
|
|
|
|
TCGv u = tcg_temp_new();
|
|
|
|
|
|
|
|
tcg_gen_qemu_ld_tl(t, EA, ctx->mem_idx, memop);
|
|
|
|
tcg_gen_addi_tl(t2, EA, MEMOP_GET_SIZE(memop));
|
|
|
|
tcg_gen_qemu_ld_tl(t2, t2, ctx->mem_idx, memop);
|
|
|
|
tcg_gen_addi_tl(u, t, addend);
|
|
|
|
|
|
|
|
/* E.g. for fetch and increment bounded... */
|
|
|
|
/* mem(EA,s) = (t != t2 ? u = t + 1 : t) */
|
|
|
|
tcg_gen_movcond_tl(cond, u, t, t2, u, t);
|
|
|
|
tcg_gen_qemu_st_tl(u, EA, ctx->mem_idx, memop);
|
|
|
|
|
|
|
|
/* RT = (t != t2 ? t : u = 1<<(s*8-1)) */
|
|
|
|
tcg_gen_movi_tl(u, 1 << (MEMOP_GET_SIZE(memop) * 8 - 1));
|
|
|
|
tcg_gen_movcond_tl(cond, cpu_gpr[rD(ctx->opcode)], t, t2, t, u);
|
|
|
|
|
|
|
|
tcg_temp_free(t);
|
|
|
|
tcg_temp_free(t2);
|
|
|
|
tcg_temp_free(u);
|
|
|
|
}
|
|
|
|
|
2019-08-23 20:10:58 +02:00
|
|
|
static void gen_ld_atomic(DisasContext *ctx, MemOp memop)
|
2018-06-26 18:19:16 +02:00
|
|
|
{
|
|
|
|
uint32_t gpr_FC = FC(ctx->opcode);
|
|
|
|
TCGv EA = tcg_temp_new();
|
2018-06-26 18:19:20 +02:00
|
|
|
int rt = rD(ctx->opcode);
|
|
|
|
bool need_serial;
|
2018-06-26 18:19:16 +02:00
|
|
|
TCGv src, dst;
|
|
|
|
|
|
|
|
gen_addr_register(ctx, EA);
|
2018-06-26 18:19:20 +02:00
|
|
|
dst = cpu_gpr[rt];
|
|
|
|
src = cpu_gpr[(rt + 1) & 31];
|
2018-06-26 18:19:16 +02:00
|
|
|
|
2018-06-26 18:19:20 +02:00
|
|
|
need_serial = false;
|
2018-06-26 18:19:16 +02:00
|
|
|
memop |= MO_ALIGN;
|
|
|
|
switch (gpr_FC) {
|
|
|
|
case 0: /* Fetch and add */
|
|
|
|
tcg_gen_atomic_fetch_add_tl(dst, EA, src, ctx->mem_idx, memop);
|
|
|
|
break;
|
|
|
|
case 1: /* Fetch and xor */
|
|
|
|
tcg_gen_atomic_fetch_xor_tl(dst, EA, src, ctx->mem_idx, memop);
|
|
|
|
break;
|
|
|
|
case 2: /* Fetch and or */
|
|
|
|
tcg_gen_atomic_fetch_or_tl(dst, EA, src, ctx->mem_idx, memop);
|
|
|
|
break;
|
|
|
|
case 3: /* Fetch and 'and' */
|
|
|
|
tcg_gen_atomic_fetch_and_tl(dst, EA, src, ctx->mem_idx, memop);
|
|
|
|
break;
|
|
|
|
case 4: /* Fetch and max unsigned */
|
2018-06-26 18:19:19 +02:00
|
|
|
tcg_gen_atomic_fetch_umax_tl(dst, EA, src, ctx->mem_idx, memop);
|
|
|
|
break;
|
2018-06-26 18:19:16 +02:00
|
|
|
case 5: /* Fetch and max signed */
|
2018-06-26 18:19:19 +02:00
|
|
|
tcg_gen_atomic_fetch_smax_tl(dst, EA, src, ctx->mem_idx, memop);
|
|
|
|
break;
|
2018-06-26 18:19:16 +02:00
|
|
|
case 6: /* Fetch and min unsigned */
|
2018-06-26 18:19:19 +02:00
|
|
|
tcg_gen_atomic_fetch_umin_tl(dst, EA, src, ctx->mem_idx, memop);
|
|
|
|
break;
|
2018-06-26 18:19:16 +02:00
|
|
|
case 7: /* Fetch and min signed */
|
2018-06-26 18:19:19 +02:00
|
|
|
tcg_gen_atomic_fetch_smin_tl(dst, EA, src, ctx->mem_idx, memop);
|
|
|
|
break;
|
|
|
|
case 8: /* Swap */
|
|
|
|
tcg_gen_atomic_xchg_tl(dst, EA, src, ctx->mem_idx, memop);
|
|
|
|
break;
|
2018-06-26 18:19:20 +02:00
|
|
|
|
|
|
|
case 16: /* Compare and swap not equal */
|
|
|
|
if (tb_cflags(ctx->base.tb) & CF_PARALLEL) {
|
|
|
|
need_serial = true;
|
|
|
|
} else {
|
|
|
|
TCGv t0 = tcg_temp_new();
|
|
|
|
TCGv t1 = tcg_temp_new();
|
|
|
|
|
|
|
|
tcg_gen_qemu_ld_tl(t0, EA, ctx->mem_idx, memop);
|
|
|
|
if ((memop & MO_SIZE) == MO_64 || TARGET_LONG_BITS == 32) {
|
|
|
|
tcg_gen_mov_tl(t1, src);
|
|
|
|
} else {
|
|
|
|
tcg_gen_ext32u_tl(t1, src);
|
|
|
|
}
|
|
|
|
tcg_gen_movcond_tl(TCG_COND_NE, t1, t0, t1,
|
|
|
|
cpu_gpr[(rt + 2) & 31], t0);
|
|
|
|
tcg_gen_qemu_st_tl(t1, EA, ctx->mem_idx, memop);
|
|
|
|
tcg_gen_mov_tl(dst, t0);
|
|
|
|
|
|
|
|
tcg_temp_free(t0);
|
|
|
|
tcg_temp_free(t1);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2018-06-26 18:19:16 +02:00
|
|
|
case 24: /* Fetch and increment bounded */
|
2018-06-26 18:19:20 +02:00
|
|
|
if (tb_cflags(ctx->base.tb) & CF_PARALLEL) {
|
|
|
|
need_serial = true;
|
|
|
|
} else {
|
|
|
|
gen_fetch_inc_conditional(ctx, memop, EA, TCG_COND_NE, 1);
|
|
|
|
}
|
|
|
|
break;
|
2018-06-26 18:19:16 +02:00
|
|
|
case 25: /* Fetch and increment equal */
|
2018-06-26 18:19:20 +02:00
|
|
|
if (tb_cflags(ctx->base.tb) & CF_PARALLEL) {
|
|
|
|
need_serial = true;
|
|
|
|
} else {
|
|
|
|
gen_fetch_inc_conditional(ctx, memop, EA, TCG_COND_EQ, 1);
|
|
|
|
}
|
|
|
|
break;
|
2018-06-26 18:19:16 +02:00
|
|
|
case 28: /* Fetch and decrement bounded */
|
2018-06-26 18:19:20 +02:00
|
|
|
if (tb_cflags(ctx->base.tb) & CF_PARALLEL) {
|
|
|
|
need_serial = true;
|
|
|
|
} else {
|
|
|
|
gen_fetch_inc_conditional(ctx, memop, EA, TCG_COND_NE, -1);
|
|
|
|
}
|
2018-06-26 18:19:16 +02:00
|
|
|
break;
|
2018-06-26 18:19:20 +02:00
|
|
|
|
2018-06-26 18:19:16 +02:00
|
|
|
default:
|
|
|
|
/* invoke data storage error handler */
|
|
|
|
gen_exception_err(ctx, POWERPC_EXCP_DSI, POWERPC_EXCP_INVAL);
|
|
|
|
}
|
|
|
|
tcg_temp_free(EA);
|
2018-06-26 18:19:20 +02:00
|
|
|
|
|
|
|
if (need_serial) {
|
|
|
|
/* Restart with exclusive lock. */
|
|
|
|
gen_helper_exit_atomic(cpu_env);
|
|
|
|
ctx->base.is_jmp = DISAS_NORETURN;
|
|
|
|
}
|
2018-06-26 18:19:16 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void gen_lwat(DisasContext *ctx)
|
|
|
|
{
|
|
|
|
gen_ld_atomic(ctx, DEF_MEMOP(MO_UL));
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef TARGET_PPC64
|
|
|
|
static void gen_ldat(DisasContext *ctx)
|
|
|
|
{
|
|
|
|
gen_ld_atomic(ctx, DEF_MEMOP(MO_Q));
|
|
|
|
}
|
2017-02-09 06:33:30 +01:00
|
|
|
#endif
|
|
|
|
|
2019-08-23 20:10:58 +02:00
|
|
|
static void gen_st_atomic(DisasContext *ctx, MemOp memop)
|
2018-06-26 18:19:17 +02:00
|
|
|
{
|
|
|
|
uint32_t gpr_FC = FC(ctx->opcode);
|
|
|
|
TCGv EA = tcg_temp_new();
|
|
|
|
TCGv src, discard;
|
|
|
|
|
|
|
|
gen_addr_register(ctx, EA);
|
|
|
|
src = cpu_gpr[rD(ctx->opcode)];
|
|
|
|
discard = tcg_temp_new();
|
|
|
|
|
|
|
|
memop |= MO_ALIGN;
|
|
|
|
switch (gpr_FC) {
|
|
|
|
case 0: /* add and Store */
|
|
|
|
tcg_gen_atomic_add_fetch_tl(discard, EA, src, ctx->mem_idx, memop);
|
|
|
|
break;
|
|
|
|
case 1: /* xor and Store */
|
|
|
|
tcg_gen_atomic_xor_fetch_tl(discard, EA, src, ctx->mem_idx, memop);
|
|
|
|
break;
|
|
|
|
case 2: /* Or and Store */
|
|
|
|
tcg_gen_atomic_or_fetch_tl(discard, EA, src, ctx->mem_idx, memop);
|
|
|
|
break;
|
|
|
|
case 3: /* 'and' and Store */
|
|
|
|
tcg_gen_atomic_and_fetch_tl(discard, EA, src, ctx->mem_idx, memop);
|
|
|
|
break;
|
|
|
|
case 4: /* Store max unsigned */
|
2018-06-26 18:19:19 +02:00
|
|
|
tcg_gen_atomic_umax_fetch_tl(discard, EA, src, ctx->mem_idx, memop);
|
|
|
|
break;
|
2018-06-26 18:19:17 +02:00
|
|
|
case 5: /* Store max signed */
|
2018-06-26 18:19:19 +02:00
|
|
|
tcg_gen_atomic_smax_fetch_tl(discard, EA, src, ctx->mem_idx, memop);
|
|
|
|
break;
|
2018-06-26 18:19:17 +02:00
|
|
|
case 6: /* Store min unsigned */
|
2018-06-26 18:19:19 +02:00
|
|
|
tcg_gen_atomic_umin_fetch_tl(discard, EA, src, ctx->mem_idx, memop);
|
|
|
|
break;
|
2018-06-26 18:19:17 +02:00
|
|
|
case 7: /* Store min signed */
|
2018-06-26 18:19:19 +02:00
|
|
|
tcg_gen_atomic_smin_fetch_tl(discard, EA, src, ctx->mem_idx, memop);
|
|
|
|
break;
|
2018-06-26 18:19:17 +02:00
|
|
|
case 24: /* Store twin */
|
2018-06-26 18:19:21 +02:00
|
|
|
if (tb_cflags(ctx->base.tb) & CF_PARALLEL) {
|
|
|
|
/* Restart with exclusive lock. */
|
|
|
|
gen_helper_exit_atomic(cpu_env);
|
|
|
|
ctx->base.is_jmp = DISAS_NORETURN;
|
|
|
|
} else {
|
|
|
|
TCGv t = tcg_temp_new();
|
|
|
|
TCGv t2 = tcg_temp_new();
|
|
|
|
TCGv s = tcg_temp_new();
|
|
|
|
TCGv s2 = tcg_temp_new();
|
|
|
|
TCGv ea_plus_s = tcg_temp_new();
|
|
|
|
|
|
|
|
tcg_gen_qemu_ld_tl(t, EA, ctx->mem_idx, memop);
|
|
|
|
tcg_gen_addi_tl(ea_plus_s, EA, MEMOP_GET_SIZE(memop));
|
|
|
|
tcg_gen_qemu_ld_tl(t2, ea_plus_s, ctx->mem_idx, memop);
|
|
|
|
tcg_gen_movcond_tl(TCG_COND_EQ, s, t, t2, src, t);
|
|
|
|
tcg_gen_movcond_tl(TCG_COND_EQ, s2, t, t2, src, t2);
|
|
|
|
tcg_gen_qemu_st_tl(s, EA, ctx->mem_idx, memop);
|
|
|
|
tcg_gen_qemu_st_tl(s2, ea_plus_s, ctx->mem_idx, memop);
|
|
|
|
|
|
|
|
tcg_temp_free(ea_plus_s);
|
|
|
|
tcg_temp_free(s2);
|
|
|
|
tcg_temp_free(s);
|
|
|
|
tcg_temp_free(t2);
|
|
|
|
tcg_temp_free(t);
|
|
|
|
}
|
2018-06-26 18:19:17 +02:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
/* invoke data storage error handler */
|
|
|
|
gen_exception_err(ctx, POWERPC_EXCP_DSI, POWERPC_EXCP_INVAL);
|
|
|
|
}
|
|
|
|
tcg_temp_free(discard);
|
|
|
|
tcg_temp_free(EA);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void gen_stwat(DisasContext *ctx)
|
|
|
|
{
|
|
|
|
gen_st_atomic(ctx, DEF_MEMOP(MO_UL));
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef TARGET_PPC64
|
|
|
|
static void gen_stdat(DisasContext *ctx)
|
|
|
|
{
|
|
|
|
gen_st_atomic(ctx, DEF_MEMOP(MO_Q));
|
|
|
|
}
|
2017-02-09 06:33:31 +01:00
|
|
|
#endif
|
|
|
|
|
2019-08-23 20:10:58 +02:00
|
|
|
static void gen_conditional_store(DisasContext *ctx, MemOp memop)
|
2014-01-07 17:05:57 +01:00
|
|
|
{
|
2017-04-27 07:18:19 +02:00
|
|
|
TCGLabel *l1 = gen_new_label();
|
|
|
|
TCGLabel *l2 = gen_new_label();
|
2018-06-26 18:19:14 +02:00
|
|
|
TCGv t0 = tcg_temp_new();
|
|
|
|
int reg = rS(ctx->opcode);
|
2009-08-03 17:43:26 +02:00
|
|
|
|
2018-06-26 18:19:14 +02:00
|
|
|
gen_set_access_type(ctx, ACCESS_RES);
|
|
|
|
gen_addr_reg_index(ctx, t0);
|
|
|
|
tcg_gen_brcond_tl(TCG_COND_NE, t0, cpu_reserve, l1);
|
|
|
|
tcg_temp_free(t0);
|
2017-04-27 07:18:19 +02:00
|
|
|
|
|
|
|
t0 = tcg_temp_new();
|
|
|
|
tcg_gen_atomic_cmpxchg_tl(t0, cpu_reserve, cpu_reserve_val,
|
|
|
|
cpu_gpr[reg], ctx->mem_idx,
|
|
|
|
DEF_MEMOP(memop) | MO_ALIGN);
|
|
|
|
tcg_gen_setcond_tl(TCG_COND_EQ, t0, t0, cpu_reserve_val);
|
|
|
|
tcg_gen_shli_tl(t0, t0, CRF_EQ_BIT);
|
|
|
|
tcg_gen_or_tl(t0, t0, cpu_so);
|
|
|
|
tcg_gen_trunc_tl_i32(cpu_crf[0], t0);
|
|
|
|
tcg_temp_free(t0);
|
|
|
|
tcg_gen_br(l2);
|
|
|
|
|
2014-01-07 17:05:57 +01:00
|
|
|
gen_set_label(l1);
|
2017-04-27 07:18:21 +02:00
|
|
|
|
2019-03-21 12:57:28 +01:00
|
|
|
/*
|
|
|
|
* Address mismatch implies failure. But we still need to provide
|
|
|
|
* the memory barrier semantics of the instruction.
|
|
|
|
*/
|
2017-04-27 07:18:21 +02:00
|
|
|
tcg_gen_mb(TCG_MO_ALL | TCG_BAR_STRL);
|
2017-04-27 07:18:19 +02:00
|
|
|
tcg_gen_trunc_tl_i32(cpu_crf[0], cpu_so);
|
|
|
|
|
|
|
|
gen_set_label(l2);
|
2014-01-07 17:05:57 +01:00
|
|
|
tcg_gen_movi_tl(cpu_reserve, -1);
|
|
|
|
}
|
|
|
|
|
2018-06-26 18:19:14 +02:00
|
|
|
#define STCX(name, memop) \
|
|
|
|
static void gen_##name(DisasContext *ctx) \
|
|
|
|
{ \
|
|
|
|
gen_conditional_store(ctx, memop); \
|
2016-09-12 08:41:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
STCX(stbcx_, DEF_MEMOP(MO_UB))
|
|
|
|
STCX(sthcx_, DEF_MEMOP(MO_UW))
|
|
|
|
STCX(stwcx_, DEF_MEMOP(MO_UL))
|
2014-01-07 17:05:57 +01:00
|
|
|
|
2007-03-23 10:45:27 +01:00
|
|
|
#if defined(TARGET_PPC64)
|
|
|
|
/* ldarx */
|
2016-09-12 08:41:36 +02:00
|
|
|
LARX(ldarx, DEF_MEMOP(MO_Q))
|
2016-09-12 08:41:38 +02:00
|
|
|
/* stdcx. */
|
|
|
|
STCX(stdcx_, DEF_MEMOP(MO_Q))
|
2007-03-23 10:45:27 +01:00
|
|
|
|
2014-02-10 18:27:00 +01:00
|
|
|
/* lqarx */
|
|
|
|
static void gen_lqarx(DisasContext *ctx)
|
|
|
|
{
|
|
|
|
int rd = rD(ctx->opcode);
|
2018-06-26 18:19:10 +02:00
|
|
|
TCGv EA, hi, lo;
|
2014-02-10 18:27:00 +01:00
|
|
|
|
|
|
|
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);
|
2018-06-26 18:19:10 +02:00
|
|
|
EA = tcg_temp_new();
|
2014-02-10 18:27:00 +01:00
|
|
|
gen_addr_reg_index(ctx, EA);
|
2018-06-26 18:19:10 +02:00
|
|
|
|
|
|
|
/* Note that the low part is always in RD+1, even in LE mode. */
|
|
|
|
lo = cpu_gpr[rd + 1];
|
|
|
|
hi = cpu_gpr[rd];
|
|
|
|
|
|
|
|
if (tb_cflags(ctx->base.tb) & CF_PARALLEL) {
|
2018-08-16 02:35:14 +02:00
|
|
|
if (HAVE_ATOMIC128) {
|
|
|
|
TCGv_i32 oi = tcg_temp_new_i32();
|
|
|
|
if (ctx->le_mode) {
|
|
|
|
tcg_gen_movi_i32(oi, make_memop_idx(MO_LEQ | MO_ALIGN_16,
|
|
|
|
ctx->mem_idx));
|
|
|
|
gen_helper_lq_le_parallel(lo, cpu_env, EA, oi);
|
|
|
|
} else {
|
|
|
|
tcg_gen_movi_i32(oi, make_memop_idx(MO_BEQ | MO_ALIGN_16,
|
|
|
|
ctx->mem_idx));
|
|
|
|
gen_helper_lq_be_parallel(lo, cpu_env, EA, oi);
|
|
|
|
}
|
|
|
|
tcg_temp_free_i32(oi);
|
|
|
|
tcg_gen_ld_i64(hi, cpu_env, offsetof(CPUPPCState, retxh));
|
2018-06-26 18:19:10 +02:00
|
|
|
} else {
|
2018-08-16 02:35:14 +02:00
|
|
|
/* Restart with exclusive lock. */
|
|
|
|
gen_helper_exit_atomic(cpu_env);
|
|
|
|
ctx->base.is_jmp = DISAS_NORETURN;
|
|
|
|
tcg_temp_free(EA);
|
|
|
|
return;
|
2018-06-26 18:19:10 +02:00
|
|
|
}
|
|
|
|
} else if (ctx->le_mode) {
|
|
|
|
tcg_gen_qemu_ld_i64(lo, EA, ctx->mem_idx, MO_LEQ | MO_ALIGN_16);
|
|
|
|
tcg_gen_mov_tl(cpu_reserve, EA);
|
|
|
|
gen_addr_add(ctx, EA, EA, 8);
|
|
|
|
tcg_gen_qemu_ld_i64(hi, EA, ctx->mem_idx, MO_LEQ);
|
2014-02-10 18:27:00 +01:00
|
|
|
} else {
|
2018-06-26 18:19:10 +02:00
|
|
|
tcg_gen_qemu_ld_i64(hi, EA, ctx->mem_idx, MO_BEQ | MO_ALIGN_16);
|
|
|
|
tcg_gen_mov_tl(cpu_reserve, EA);
|
|
|
|
gen_addr_add(ctx, EA, EA, 8);
|
|
|
|
tcg_gen_qemu_ld_i64(lo, EA, ctx->mem_idx, MO_BEQ);
|
2014-02-10 18:27:00 +01:00
|
|
|
}
|
|
|
|
tcg_temp_free(EA);
|
2018-06-26 18:19:10 +02:00
|
|
|
|
|
|
|
tcg_gen_st_tl(hi, cpu_env, offsetof(CPUPPCState, reserve_val));
|
|
|
|
tcg_gen_st_tl(lo, cpu_env, offsetof(CPUPPCState, reserve_val2));
|
2014-02-10 18:27:00 +01:00
|
|
|
}
|
|
|
|
|
2016-09-12 08:41:37 +02:00
|
|
|
/* stqcx. */
|
|
|
|
static void gen_stqcx_(DisasContext *ctx)
|
|
|
|
{
|
2018-06-26 18:19:12 +02:00
|
|
|
int rs = rS(ctx->opcode);
|
|
|
|
TCGv EA, hi, lo;
|
2016-09-12 08:41:37 +02:00
|
|
|
|
2018-06-26 18:19:12 +02:00
|
|
|
if (unlikely(rs & 1)) {
|
2016-09-12 08:41:37 +02:00
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_INVAL_INVAL);
|
|
|
|
return;
|
|
|
|
}
|
2018-06-26 18:19:12 +02:00
|
|
|
|
2016-09-12 08:41:37 +02:00
|
|
|
gen_set_access_type(ctx, ACCESS_RES);
|
2018-06-26 18:19:12 +02:00
|
|
|
EA = tcg_temp_new();
|
2016-09-12 08:41:37 +02:00
|
|
|
gen_addr_reg_index(ctx, EA);
|
|
|
|
|
2018-06-26 18:19:12 +02:00
|
|
|
/* Note that the low part is always in RS+1, even in LE mode. */
|
|
|
|
lo = cpu_gpr[rs + 1];
|
|
|
|
hi = cpu_gpr[rs];
|
2016-09-12 08:41:37 +02:00
|
|
|
|
2018-06-26 18:19:12 +02:00
|
|
|
if (tb_cflags(ctx->base.tb) & CF_PARALLEL) {
|
2018-08-16 02:35:14 +02:00
|
|
|
if (HAVE_CMPXCHG128) {
|
|
|
|
TCGv_i32 oi = tcg_const_i32(DEF_MEMOP(MO_Q) | MO_ALIGN_16);
|
|
|
|
if (ctx->le_mode) {
|
|
|
|
gen_helper_stqcx_le_parallel(cpu_crf[0], cpu_env,
|
|
|
|
EA, lo, hi, oi);
|
|
|
|
} else {
|
|
|
|
gen_helper_stqcx_be_parallel(cpu_crf[0], cpu_env,
|
|
|
|
EA, lo, hi, oi);
|
|
|
|
}
|
|
|
|
tcg_temp_free_i32(oi);
|
2018-06-26 18:19:12 +02:00
|
|
|
} else {
|
2018-08-16 02:35:14 +02:00
|
|
|
/* Restart with exclusive lock. */
|
|
|
|
gen_helper_exit_atomic(cpu_env);
|
|
|
|
ctx->base.is_jmp = DISAS_NORETURN;
|
2018-06-26 18:19:12 +02:00
|
|
|
}
|
|
|
|
tcg_temp_free(EA);
|
2016-09-12 08:41:37 +02:00
|
|
|
} else {
|
2018-06-26 18:19:12 +02:00
|
|
|
TCGLabel *lab_fail = gen_new_label();
|
|
|
|
TCGLabel *lab_over = gen_new_label();
|
|
|
|
TCGv_i64 t0 = tcg_temp_new_i64();
|
|
|
|
TCGv_i64 t1 = tcg_temp_new_i64();
|
2016-09-12 08:41:37 +02:00
|
|
|
|
2018-06-26 18:19:12 +02:00
|
|
|
tcg_gen_brcond_tl(TCG_COND_NE, EA, cpu_reserve, lab_fail);
|
|
|
|
tcg_temp_free(EA);
|
2016-09-12 08:41:37 +02:00
|
|
|
|
2018-06-26 18:19:12 +02:00
|
|
|
gen_qemu_ld64_i64(ctx, t0, cpu_reserve);
|
|
|
|
tcg_gen_ld_i64(t1, cpu_env, (ctx->le_mode
|
|
|
|
? offsetof(CPUPPCState, reserve_val2)
|
|
|
|
: offsetof(CPUPPCState, reserve_val)));
|
|
|
|
tcg_gen_brcond_i64(TCG_COND_NE, t0, t1, lab_fail);
|
|
|
|
|
|
|
|
tcg_gen_addi_i64(t0, cpu_reserve, 8);
|
|
|
|
gen_qemu_ld64_i64(ctx, t0, t0);
|
|
|
|
tcg_gen_ld_i64(t1, cpu_env, (ctx->le_mode
|
|
|
|
? offsetof(CPUPPCState, reserve_val)
|
|
|
|
: offsetof(CPUPPCState, reserve_val2)));
|
|
|
|
tcg_gen_brcond_i64(TCG_COND_NE, t0, t1, lab_fail);
|
|
|
|
|
|
|
|
/* Success */
|
|
|
|
gen_qemu_st64_i64(ctx, ctx->le_mode ? lo : hi, cpu_reserve);
|
|
|
|
tcg_gen_addi_i64(t0, cpu_reserve, 8);
|
|
|
|
gen_qemu_st64_i64(ctx, ctx->le_mode ? hi : lo, t0);
|
|
|
|
|
|
|
|
tcg_gen_trunc_tl_i32(cpu_crf[0], cpu_so);
|
|
|
|
tcg_gen_ori_i32(cpu_crf[0], cpu_crf[0], CRF_EQ);
|
|
|
|
tcg_gen_br(lab_over);
|
|
|
|
|
|
|
|
gen_set_label(lab_fail);
|
|
|
|
tcg_gen_trunc_tl_i32(cpu_crf[0], cpu_so);
|
|
|
|
|
|
|
|
gen_set_label(lab_over);
|
|
|
|
tcg_gen_movi_tl(cpu_reserve, -1);
|
|
|
|
tcg_temp_free_i64(t0);
|
|
|
|
tcg_temp_free_i64(t1);
|
|
|
|
}
|
|
|
|
}
|
2007-03-23 10:45:27 +01:00
|
|
|
#endif /* defined(TARGET_PPC64) */
|
|
|
|
|
2003-11-23 15:55:54 +01:00
|
|
|
/* sync */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_sync(DisasContext *ctx)
|
2003-11-23 15:55:54 +01:00
|
|
|
{
|
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 18:03:25 +02:00
|
|
|
uint32_t l = (ctx->opcode >> 21) & 3;
|
|
|
|
|
|
|
|
/*
|
2016-06-07 04:50:22 +02: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 18:03:25 +02:00
|
|
|
*/
|
2016-06-07 04:50:22 +02:00
|
|
|
if (((l == 2) || !(ctx->insns_flags & PPC_64B)) && !ctx->pr) {
|
2016-09-20 18:35:00 +02:00
|
|
|
gen_check_tlb_flush(ctx, true);
|
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 18:03:25 +02:00
|
|
|
}
|
2017-04-27 07:18:21 +02:00
|
|
|
tcg_gen_mb(TCG_MO_ALL | TCG_BAR_SC);
|
2003-11-23 15:55:54 +01:00
|
|
|
}
|
|
|
|
|
2007-09-30 05:46:38 +02:00
|
|
|
/* wait */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_wait(DisasContext *ctx)
|
2007-09-30 05:46:38 +02:00
|
|
|
{
|
2016-06-06 10:47:28 +02:00
|
|
|
TCGv_i32 t0 = tcg_const_i32(1);
|
2013-01-17 18:51:17 +01:00
|
|
|
tcg_gen_st_i32(t0, cpu_env,
|
|
|
|
-offsetof(PowerPCCPU, env) + offsetof(CPUState, halted));
|
2008-11-30 17:23:46 +01:00
|
|
|
tcg_temp_free_i32(t0);
|
2007-09-30 05:46:38 +02:00
|
|
|
/* Stop translation, as the CPU is supposed to sleep from now */
|
2018-02-15 20:51:48 +01:00
|
|
|
gen_exception_nip(ctx, EXCP_HLT, ctx->base.pc_next);
|
2007-09-30 05:46:38 +02:00
|
|
|
}
|
|
|
|
|
2016-06-21 23:48:55 +02: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);
|
2019-02-15 17:16:39 +01:00
|
|
|
/* Stop translation, as the CPU is supposed to sleep from now */
|
|
|
|
gen_exception_nip(ctx, EXCP_HLT, ctx->base.pc_next);
|
2016-06-21 23:48:55 +02:00
|
|
|
#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);
|
2019-02-15 17:16:39 +01:00
|
|
|
/* Stop translation, as the CPU is supposed to sleep from now */
|
|
|
|
gen_exception_nip(ctx, EXCP_HLT, ctx->base.pc_next);
|
2016-06-21 23:48:55 +02:00
|
|
|
#endif /* defined(CONFIG_USER_ONLY) */
|
|
|
|
}
|
|
|
|
|
2016-12-05 12:25:26 +01:00
|
|
|
static void gen_stop(DisasContext *ctx)
|
|
|
|
{
|
2019-02-15 17:16:41 +01:00
|
|
|
#if defined(CONFIG_USER_ONLY)
|
|
|
|
GEN_PRIV;
|
|
|
|
#else
|
|
|
|
TCGv_i32 t;
|
|
|
|
|
|
|
|
CHK_HV;
|
|
|
|
t = tcg_const_i32(PPC_PM_STOP);
|
|
|
|
gen_helper_pminsn(cpu_env, t);
|
|
|
|
tcg_temp_free_i32(t);
|
|
|
|
/* Stop translation, as the CPU is supposed to sleep from now */
|
|
|
|
gen_exception_nip(ctx, EXCP_HLT, ctx->base.pc_next);
|
|
|
|
#endif /* defined(CONFIG_USER_ONLY) */
|
2016-12-05 12:25:26 +01:00
|
|
|
}
|
|
|
|
|
2016-06-21 23:48:55 +02:00
|
|
|
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);
|
2019-02-15 17:16:39 +01:00
|
|
|
/* Stop translation, as the CPU is supposed to sleep from now */
|
|
|
|
gen_exception_nip(ctx, EXCP_HLT, ctx->base.pc_next);
|
2016-06-21 23:48:55 +02:00
|
|
|
#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);
|
2019-02-15 17:16:39 +01:00
|
|
|
/* Stop translation, as the CPU is supposed to sleep from now */
|
|
|
|
gen_exception_nip(ctx, EXCP_HLT, ctx->base.pc_next);
|
2016-06-21 23:48:55 +02:00
|
|
|
#endif /* defined(CONFIG_USER_ONLY) */
|
|
|
|
}
|
|
|
|
#endif /* #if defined(TARGET_PPC64) */
|
|
|
|
|
2011-08-31 17:45:10 +02:00
|
|
|
static inline void gen_update_cfar(DisasContext *ctx, target_ulong nip)
|
|
|
|
{
|
|
|
|
#if defined(TARGET_PPC64)
|
2019-03-21 12:57:28 +01:00
|
|
|
if (ctx->has_cfar) {
|
2011-08-31 17:45:10 +02:00
|
|
|
tcg_gen_movi_tl(cpu_cfar, nip);
|
2019-03-21 12:57:28 +01:00
|
|
|
}
|
2011-08-31 17:45:10 +02:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2016-04-09 00:00:23 +02:00
|
|
|
static inline bool use_goto_tb(DisasContext *ctx, target_ulong dest)
|
|
|
|
{
|
|
|
|
if (unlikely(ctx->singlestep_enabled)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifndef CONFIG_USER_ONLY
|
2018-02-15 20:51:48 +01:00
|
|
|
return (ctx->base.tb->pc & TARGET_PAGE_MASK) == (dest & TARGET_PAGE_MASK);
|
2016-04-09 00:00:23 +02:00
|
|
|
#else
|
|
|
|
return true;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2018-08-14 18:09:51 +02:00
|
|
|
static void gen_lookup_and_goto_ptr(DisasContext *ctx)
|
|
|
|
{
|
|
|
|
int sse = ctx->singlestep_enabled;
|
|
|
|
if (unlikely(sse)) {
|
|
|
|
if (sse & GDBSTUB_SINGLE_STEP) {
|
|
|
|
gen_debug_exception(ctx);
|
|
|
|
} else if (sse & (CPU_SINGLE_STEP | CPU_BRANCH_STEP)) {
|
2021-06-02 14:51:03 +02:00
|
|
|
gen_helper_raise_exception(cpu_env, tcg_constant_i32(gen_prep_dbgex(ctx)));
|
2021-05-17 22:50:08 +02:00
|
|
|
} else {
|
|
|
|
tcg_gen_exit_tb(NULL, 0);
|
2018-08-14 18:09:51 +02:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
tcg_gen_lookup_and_goto_ptr();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-11-23 15:55:54 +01:00
|
|
|
/*** Branch ***/
|
2017-10-27 18:58:14 +02:00
|
|
|
static void gen_goto_tb(DisasContext *ctx, int n, target_ulong dest)
|
2005-11-20 11:31:08 +01:00
|
|
|
{
|
2013-03-21 11:01:46 +01:00
|
|
|
if (NARROW_MODE(ctx)) {
|
2008-10-21 18:31:31 +02:00
|
|
|
dest = (uint32_t) dest;
|
2013-03-21 11:01:46 +01:00
|
|
|
}
|
2016-04-09 00:00:23 +02:00
|
|
|
if (use_goto_tb(ctx, dest)) {
|
2008-02-01 11:50:11 +01:00
|
|
|
tcg_gen_goto_tb(n);
|
2008-10-21 18:31:31 +02:00
|
|
|
tcg_gen_movi_tl(cpu_nip, dest & ~3);
|
2018-05-31 03:06:23 +02:00
|
|
|
tcg_gen_exit_tb(ctx->base.tb, n);
|
2005-11-20 11:31:08 +01:00
|
|
|
} else {
|
2008-10-21 18:31:31 +02:00
|
|
|
tcg_gen_movi_tl(cpu_nip, dest & ~3);
|
2018-08-14 18:09:51 +02:00
|
|
|
gen_lookup_and_goto_ptr(ctx);
|
2005-11-20 11:31:08 +01:00
|
|
|
}
|
2005-10-30 22:39:19 +01:00
|
|
|
}
|
|
|
|
|
2009-08-16 11:06:54 +02:00
|
|
|
static inline void gen_setlr(DisasContext *ctx, target_ulong nip)
|
2007-09-29 15:06:16 +02:00
|
|
|
{
|
2013-03-21 11:01:46 +01:00
|
|
|
if (NARROW_MODE(ctx)) {
|
|
|
|
nip = (uint32_t)nip;
|
|
|
|
}
|
|
|
|
tcg_gen_movi_tl(cpu_lr, nip);
|
2007-09-29 15:06:16 +02:00
|
|
|
}
|
|
|
|
|
2003-11-23 15:55:54 +01:00
|
|
|
/* b ba bl bla */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_b(DisasContext *ctx)
|
2003-11-23 15:55:54 +01:00
|
|
|
{
|
2007-03-07 09:32:30 +01:00
|
|
|
target_ulong li, target;
|
2004-07-08 00:06:01 +02:00
|
|
|
|
|
|
|
/* sign extend LI */
|
2013-03-21 11:01:46 +01:00
|
|
|
li = LI(ctx->opcode);
|
|
|
|
li = (li ^ 0x02000000) - 0x02000000;
|
|
|
|
if (likely(AA(ctx->opcode) == 0)) {
|
2021-05-12 20:54:11 +02:00
|
|
|
target = ctx->cia + li;
|
2013-03-21 11:01:46 +01:00
|
|
|
} else {
|
2004-01-04 23:58:38 +01:00
|
|
|
target = li;
|
2013-03-21 11:01:46 +01:00
|
|
|
}
|
|
|
|
if (LK(ctx->opcode)) {
|
2018-02-15 20:51:48 +01:00
|
|
|
gen_setlr(ctx, ctx->base.pc_next);
|
2013-03-21 11:01:46 +01:00
|
|
|
}
|
2021-05-12 20:54:11 +02:00
|
|
|
gen_update_cfar(ctx, ctx->cia);
|
2005-11-20 11:31:08 +01:00
|
|
|
gen_goto_tb(ctx, 0, target);
|
2021-05-17 22:50:05 +02:00
|
|
|
ctx->base.is_jmp = DISAS_NORETURN;
|
2003-11-23 15:55:54 +01:00
|
|
|
}
|
|
|
|
|
2004-02-21 16:35:00 +01:00
|
|
|
#define BCOND_IM 0
|
|
|
|
#define BCOND_LR 1
|
|
|
|
#define BCOND_CTR 2
|
2014-02-10 18:26:55 +01:00
|
|
|
#define BCOND_TAR 3
|
2004-02-21 16:35:00 +01:00
|
|
|
|
2017-10-27 18:58:14 +02:00
|
|
|
static void gen_bcond(DisasContext *ctx, int type)
|
2007-03-17 15:02:15 +01:00
|
|
|
{
|
|
|
|
uint32_t bo = BO(ctx->opcode);
|
2015-02-13 21:51:55 +01:00
|
|
|
TCGLabel *l1;
|
2008-10-21 18:31:31 +02:00
|
|
|
TCGv target;
|
2018-08-14 18:09:51 +02:00
|
|
|
|
2014-02-10 18:26:55 +01:00
|
|
|
if (type == BCOND_LR || type == BCOND_CTR || type == BCOND_TAR) {
|
2008-11-17 15:43:54 +01:00
|
|
|
target = tcg_temp_local_new();
|
2019-03-21 12:57:28 +01:00
|
|
|
if (type == BCOND_CTR) {
|
2008-10-21 18:31:31 +02:00
|
|
|
tcg_gen_mov_tl(target, cpu_ctr);
|
2019-03-21 12:57:28 +01:00
|
|
|
} else if (type == BCOND_TAR) {
|
2014-02-10 18:26:55 +01:00
|
|
|
gen_load_spr(target, SPR_TAR);
|
2019-03-21 12:57:28 +01:00
|
|
|
} else {
|
2008-10-21 18:31:31 +02:00
|
|
|
tcg_gen_mov_tl(target, cpu_lr);
|
2019-03-21 12:57:28 +01:00
|
|
|
}
|
2009-06-20 03:51:47 +02:00
|
|
|
} else {
|
2017-11-02 12:47:37 +01:00
|
|
|
target = NULL;
|
2004-02-21 16:35:00 +01:00
|
|
|
}
|
2019-03-21 12:57:28 +01:00
|
|
|
if (LK(ctx->opcode)) {
|
2018-02-15 20:51:48 +01:00
|
|
|
gen_setlr(ctx, ctx->base.pc_next);
|
2019-03-21 12:57:28 +01:00
|
|
|
}
|
2008-10-21 18:31:31 +02:00
|
|
|
l1 = gen_new_label();
|
|
|
|
if ((bo & 0x4) == 0) {
|
|
|
|
/* Decrement and test CTR */
|
2008-11-17 15:43:54 +01:00
|
|
|
TCGv temp = tcg_temp_new();
|
2019-03-22 19:03:46 +01:00
|
|
|
|
|
|
|
if (type == BCOND_CTR) {
|
|
|
|
/*
|
|
|
|
* All ISAs up to v3 describe this form of bcctr as invalid but
|
|
|
|
* some processors, ie. 64-bit server processors compliant with
|
|
|
|
* arch 2.x, do implement a "test and decrement" logic instead,
|
2019-03-26 11:21:11 +01:00
|
|
|
* as described in their respective UMs. This logic involves CTR
|
|
|
|
* to act as both the branch target and a counter, which makes
|
|
|
|
* it basically useless and thus never used in real code.
|
|
|
|
*
|
|
|
|
* This form was hence chosen to trigger extra micro-architectural
|
|
|
|
* side-effect on real HW needed for the Spectre v2 workaround.
|
|
|
|
* It is up to guests that implement such workaround, ie. linux, to
|
|
|
|
* use this form in a way it just triggers the side-effect without
|
|
|
|
* doing anything else harmful.
|
2019-03-22 19:03:46 +01:00
|
|
|
*/
|
2019-03-22 19:03:51 +01:00
|
|
|
if (unlikely(!is_book3s_arch2x(ctx))) {
|
2019-03-22 19:03:46 +01:00
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_INVAL_INVAL);
|
|
|
|
tcg_temp_free(temp);
|
|
|
|
tcg_temp_free(target);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (NARROW_MODE(ctx)) {
|
|
|
|
tcg_gen_ext32u_tl(temp, cpu_ctr);
|
|
|
|
} else {
|
|
|
|
tcg_gen_mov_tl(temp, cpu_ctr);
|
|
|
|
}
|
|
|
|
if (bo & 0x2) {
|
|
|
|
tcg_gen_brcondi_tl(TCG_COND_NE, temp, 0, l1);
|
|
|
|
} else {
|
|
|
|
tcg_gen_brcondi_tl(TCG_COND_EQ, temp, 0, l1);
|
|
|
|
}
|
|
|
|
tcg_gen_subi_tl(cpu_ctr, cpu_ctr, 1);
|
2008-10-21 18:31:31 +02:00
|
|
|
} else {
|
2019-03-22 19:03:46 +01:00
|
|
|
tcg_gen_subi_tl(cpu_ctr, cpu_ctr, 1);
|
|
|
|
if (NARROW_MODE(ctx)) {
|
|
|
|
tcg_gen_ext32u_tl(temp, cpu_ctr);
|
|
|
|
} else {
|
|
|
|
tcg_gen_mov_tl(temp, cpu_ctr);
|
|
|
|
}
|
|
|
|
if (bo & 0x2) {
|
|
|
|
tcg_gen_brcondi_tl(TCG_COND_NE, temp, 0, l1);
|
|
|
|
} else {
|
|
|
|
tcg_gen_brcondi_tl(TCG_COND_EQ, temp, 0, l1);
|
|
|
|
}
|
2004-02-21 16:35:00 +01:00
|
|
|
}
|
2008-11-17 15:43:54 +01:00
|
|
|
tcg_temp_free(temp);
|
2008-10-21 18:31:31 +02:00
|
|
|
}
|
|
|
|
if ((bo & 0x10) == 0) {
|
|
|
|
/* Test CR */
|
|
|
|
uint32_t bi = BI(ctx->opcode);
|
2014-08-28 19:15:09 +02:00
|
|
|
uint32_t mask = 0x08 >> (bi & 0x03);
|
2008-11-17 15:43:54 +01:00
|
|
|
TCGv_i32 temp = tcg_temp_new_i32();
|
2008-10-21 18:31:31 +02:00
|
|
|
|
2007-03-17 15:02:15 +01:00
|
|
|
if (bo & 0x8) {
|
2008-10-21 18:31:31 +02:00
|
|
|
tcg_gen_andi_i32(temp, cpu_crf[bi >> 2], mask);
|
|
|
|
tcg_gen_brcondi_i32(TCG_COND_EQ, temp, 0, l1);
|
2007-03-17 15:02:15 +01:00
|
|
|
} else {
|
2008-10-21 18:31:31 +02:00
|
|
|
tcg_gen_andi_i32(temp, cpu_crf[bi >> 2], mask);
|
|
|
|
tcg_gen_brcondi_i32(TCG_COND_NE, temp, 0, l1);
|
2007-03-17 15:02:15 +01:00
|
|
|
}
|
2008-11-17 15:43:54 +01:00
|
|
|
tcg_temp_free_i32(temp);
|
2007-03-17 15:02:15 +01:00
|
|
|
}
|
2021-05-12 20:54:11 +02:00
|
|
|
gen_update_cfar(ctx, ctx->cia);
|
2004-02-21 16:35:00 +01:00
|
|
|
if (type == BCOND_IM) {
|
2008-10-21 18:31:31 +02:00
|
|
|
target_ulong li = (target_long)((int16_t)(BD(ctx->opcode)));
|
|
|
|
if (likely(AA(ctx->opcode) == 0)) {
|
2021-05-12 20:54:11 +02:00
|
|
|
gen_goto_tb(ctx, 0, ctx->cia + li);
|
2008-10-21 18:31:31 +02:00
|
|
|
} else {
|
|
|
|
gen_goto_tb(ctx, 0, li);
|
|
|
|
}
|
2004-02-21 16:35:00 +01:00
|
|
|
} else {
|
2013-03-21 11:01:46 +01:00
|
|
|
if (NARROW_MODE(ctx)) {
|
2008-10-21 18:31:31 +02:00
|
|
|
tcg_gen_andi_tl(cpu_nip, target, (uint32_t)~3);
|
2013-03-21 11:01:46 +01:00
|
|
|
} else {
|
2008-10-21 18:31:31 +02:00
|
|
|
tcg_gen_andi_tl(cpu_nip, target, ~3);
|
2013-03-21 11:01:46 +01:00
|
|
|
}
|
2018-08-14 18:09:51 +02:00
|
|
|
gen_lookup_and_goto_ptr(ctx);
|
2014-01-19 17:26:33 +01:00
|
|
|
tcg_temp_free(target);
|
|
|
|
}
|
2017-10-27 18:58:14 +02:00
|
|
|
if ((bo & 0x14) != 0x14) {
|
2018-08-14 18:09:51 +02:00
|
|
|
/* fallthrough case */
|
2017-10-27 18:58:14 +02:00
|
|
|
gen_set_label(l1);
|
2018-02-15 20:51:48 +01:00
|
|
|
gen_goto_tb(ctx, 1, ctx->base.pc_next);
|
2017-10-27 18:58:14 +02:00
|
|
|
}
|
2021-05-17 22:50:05 +02:00
|
|
|
ctx->base.is_jmp = DISAS_NORETURN;
|
2004-02-21 16:35:00 +01:00
|
|
|
}
|
|
|
|
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_bc(DisasContext *ctx)
|
2007-09-17 10:09:54 +02:00
|
|
|
{
|
2004-02-21 16:35:00 +01:00
|
|
|
gen_bcond(ctx, BCOND_IM);
|
|
|
|
}
|
|
|
|
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_bcctr(DisasContext *ctx)
|
2007-09-17 10:09:54 +02:00
|
|
|
{
|
2004-02-21 16:35:00 +01:00
|
|
|
gen_bcond(ctx, BCOND_CTR);
|
|
|
|
}
|
|
|
|
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_bclr(DisasContext *ctx)
|
2007-09-17 10:09:54 +02:00
|
|
|
{
|
2004-02-21 16:35:00 +01:00
|
|
|
gen_bcond(ctx, BCOND_LR);
|
|
|
|
}
|
2003-11-23 15:55:54 +01:00
|
|
|
|
2014-02-10 18:26:55 +01:00
|
|
|
static void gen_bctar(DisasContext *ctx)
|
|
|
|
{
|
|
|
|
gen_bcond(ctx, BCOND_TAR);
|
|
|
|
}
|
|
|
|
|
2003-11-23 15:55:54 +01:00
|
|
|
/*** Condition register logical ***/
|
2008-10-21 13:31:14 +02:00
|
|
|
#define GEN_CRLOGIC(name, tcg_op, opc) \
|
2019-03-21 12:57:28 +01:00
|
|
|
static void glue(gen_, name)(DisasContext *ctx) \
|
2003-11-23 15:55:54 +01:00
|
|
|
{ \
|
2007-10-31 23:02:17 +01:00
|
|
|
uint8_t bitmask; \
|
|
|
|
int sh; \
|
2008-11-17 15:43:54 +01:00
|
|
|
TCGv_i32 t0, t1; \
|
2007-10-31 23:02:17 +01:00
|
|
|
sh = (crbD(ctx->opcode) & 0x03) - (crbA(ctx->opcode) & 0x03); \
|
2008-11-17 15:43:54 +01:00
|
|
|
t0 = tcg_temp_new_i32(); \
|
2007-10-31 23:02:17 +01:00
|
|
|
if (sh > 0) \
|
2008-11-02 09:22:34 +01:00
|
|
|
tcg_gen_shri_i32(t0, cpu_crf[crbA(ctx->opcode) >> 2], sh); \
|
2007-10-31 23:02:17 +01:00
|
|
|
else if (sh < 0) \
|
2008-11-02 09:22:34 +01:00
|
|
|
tcg_gen_shli_i32(t0, cpu_crf[crbA(ctx->opcode) >> 2], -sh); \
|
2008-10-21 13:31:14 +02:00
|
|
|
else \
|
2008-11-02 09:22:34 +01:00
|
|
|
tcg_gen_mov_i32(t0, cpu_crf[crbA(ctx->opcode) >> 2]); \
|
2008-11-17 15:43:54 +01:00
|
|
|
t1 = tcg_temp_new_i32(); \
|
2007-10-31 23:02:17 +01:00
|
|
|
sh = (crbD(ctx->opcode) & 0x03) - (crbB(ctx->opcode) & 0x03); \
|
|
|
|
if (sh > 0) \
|
2008-11-02 09:22:34 +01:00
|
|
|
tcg_gen_shri_i32(t1, cpu_crf[crbB(ctx->opcode) >> 2], sh); \
|
2007-10-31 23:02:17 +01:00
|
|
|
else if (sh < 0) \
|
2008-11-02 09:22:34 +01:00
|
|
|
tcg_gen_shli_i32(t1, cpu_crf[crbB(ctx->opcode) >> 2], -sh); \
|
2008-10-21 13:31:14 +02:00
|
|
|
else \
|
2008-11-02 09:22:34 +01:00
|
|
|
tcg_gen_mov_i32(t1, cpu_crf[crbB(ctx->opcode) >> 2]); \
|
|
|
|
tcg_op(t0, t0, t1); \
|
2014-08-28 19:15:09 +02:00
|
|
|
bitmask = 0x08 >> (crbD(ctx->opcode) & 0x03); \
|
2008-11-02 09:22:34 +01:00
|
|
|
tcg_gen_andi_i32(t0, t0, bitmask); \
|
|
|
|
tcg_gen_andi_i32(t1, cpu_crf[crbD(ctx->opcode) >> 2], ~bitmask); \
|
|
|
|
tcg_gen_or_i32(cpu_crf[crbD(ctx->opcode) >> 2], t0, t1); \
|
2008-11-17 15:43:54 +01:00
|
|
|
tcg_temp_free_i32(t0); \
|
|
|
|
tcg_temp_free_i32(t1); \
|
2003-11-23 15:55:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* crand */
|
2008-10-21 13:31:14 +02:00
|
|
|
GEN_CRLOGIC(crand, tcg_gen_and_i32, 0x08);
|
2003-11-23 15:55:54 +01:00
|
|
|
/* crandc */
|
2008-10-21 13:31:14 +02:00
|
|
|
GEN_CRLOGIC(crandc, tcg_gen_andc_i32, 0x04);
|
2003-11-23 15:55:54 +01:00
|
|
|
/* creqv */
|
2008-10-21 13:31:14 +02:00
|
|
|
GEN_CRLOGIC(creqv, tcg_gen_eqv_i32, 0x09);
|
2003-11-23 15:55:54 +01:00
|
|
|
/* crnand */
|
2008-10-21 13:31:14 +02:00
|
|
|
GEN_CRLOGIC(crnand, tcg_gen_nand_i32, 0x07);
|
2003-11-23 15:55:54 +01:00
|
|
|
/* crnor */
|
2008-10-21 13:31:14 +02:00
|
|
|
GEN_CRLOGIC(crnor, tcg_gen_nor_i32, 0x01);
|
2003-11-23 15:55:54 +01:00
|
|
|
/* cror */
|
2008-10-21 13:31:14 +02:00
|
|
|
GEN_CRLOGIC(cror, tcg_gen_or_i32, 0x0E);
|
2003-11-23 15:55:54 +01:00
|
|
|
/* crorc */
|
2008-10-21 13:31:14 +02:00
|
|
|
GEN_CRLOGIC(crorc, tcg_gen_orc_i32, 0x0D);
|
2003-11-23 15:55:54 +01:00
|
|
|
/* crxor */
|
2008-10-21 13:31:14 +02:00
|
|
|
GEN_CRLOGIC(crxor, tcg_gen_xor_i32, 0x06);
|
2009-06-17 17:22:09 +02:00
|
|
|
|
2009-06-17 17:22:19 +02:00
|
|
|
/* mcrf */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_mcrf(DisasContext *ctx)
|
2003-11-23 15:55:54 +01:00
|
|
|
{
|
2008-09-04 19:06:47 +02:00
|
|
|
tcg_gen_mov_i32(cpu_crf[crfD(ctx->opcode)], cpu_crf[crfS(ctx->opcode)]);
|
2003-11-23 15:55:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*** System linkage ***/
|
2009-06-17 17:22:09 +02:00
|
|
|
|
2014-09-15 17:03:28 +02:00
|
|
|
/* rfi (supervisor only) */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_rfi(DisasContext *ctx)
|
2003-11-23 15:55:54 +01:00
|
|
|
{
|
2004-01-04 23:58:38 +01:00
|
|
|
#if defined(CONFIG_USER_ONLY)
|
2016-06-21 23:48:51 +02:00
|
|
|
GEN_PRIV;
|
2004-01-04 23:58:38 +01:00
|
|
|
#else
|
2019-03-21 12:57:28 +01:00
|
|
|
/*
|
|
|
|
* This instruction doesn't exist anymore on 64-bit server
|
2016-09-08 09:32:42 +02:00
|
|
|
* processors compliant with arch 2.x
|
2016-06-21 23:48:46 +02:00
|
|
|
*/
|
2019-03-22 19:03:51 +01:00
|
|
|
if (is_book3s_arch2x(ctx)) {
|
2016-09-08 09:32:42 +02:00
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_INVAL_INVAL);
|
|
|
|
return;
|
|
|
|
}
|
2004-01-04 23:58:38 +01:00
|
|
|
/* Restore CPU state */
|
2016-06-21 23:48:51 +02:00
|
|
|
CHK_SV;
|
2021-05-17 22:50:03 +02:00
|
|
|
gen_icount_io_start(ctx);
|
2021-05-12 20:54:11 +02:00
|
|
|
gen_update_cfar(ctx, ctx->cia);
|
2012-05-30 06:23:23 +02:00
|
|
|
gen_helper_rfi(cpu_env);
|
2021-05-12 20:54:18 +02:00
|
|
|
ctx->base.is_jmp = DISAS_EXIT;
|
2004-01-04 23:58:38 +01:00
|
|
|
#endif
|
2003-11-23 15:55:54 +01:00
|
|
|
}
|
|
|
|
|
2007-03-23 10:45:27 +01:00
|
|
|
#if defined(TARGET_PPC64)
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_rfid(DisasContext *ctx)
|
2007-03-23 10:45:27 +01:00
|
|
|
{
|
|
|
|
#if defined(CONFIG_USER_ONLY)
|
2016-06-21 23:48:51 +02:00
|
|
|
GEN_PRIV;
|
2007-03-23 10:45:27 +01:00
|
|
|
#else
|
|
|
|
/* Restore CPU state */
|
2016-06-21 23:48:51 +02:00
|
|
|
CHK_SV;
|
2021-05-17 22:50:03 +02:00
|
|
|
gen_icount_io_start(ctx);
|
2021-05-12 20:54:11 +02:00
|
|
|
gen_update_cfar(ctx, ctx->cia);
|
2012-05-30 06:23:23 +02:00
|
|
|
gen_helper_rfid(cpu_env);
|
2021-05-12 20:54:18 +02:00
|
|
|
ctx->base.is_jmp = DISAS_EXIT;
|
2007-03-23 10:45:27 +01:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2020-05-07 13:53:28 +02:00
|
|
|
#if !defined(CONFIG_USER_ONLY)
|
|
|
|
static void gen_rfscv(DisasContext *ctx)
|
|
|
|
{
|
|
|
|
#if defined(CONFIG_USER_ONLY)
|
|
|
|
GEN_PRIV;
|
|
|
|
#else
|
|
|
|
/* Restore CPU state */
|
|
|
|
CHK_SV;
|
2021-05-17 22:50:03 +02:00
|
|
|
gen_icount_io_start(ctx);
|
2021-05-12 20:54:11 +02:00
|
|
|
gen_update_cfar(ctx, ctx->cia);
|
2020-05-07 13:53:28 +02:00
|
|
|
gen_helper_rfscv(cpu_env);
|
2021-05-12 20:54:18 +02:00
|
|
|
ctx->base.is_jmp = DISAS_EXIT;
|
2020-05-07 13:53:28 +02:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_hrfid(DisasContext *ctx)
|
2007-09-30 15:03:23 +02:00
|
|
|
{
|
|
|
|
#if defined(CONFIG_USER_ONLY)
|
2016-06-21 23:48:51 +02:00
|
|
|
GEN_PRIV;
|
2007-09-30 15:03:23 +02:00
|
|
|
#else
|
|
|
|
/* Restore CPU state */
|
2016-06-21 23:48:51 +02:00
|
|
|
CHK_HV;
|
2012-05-30 06:23:23 +02:00
|
|
|
gen_helper_hrfid(cpu_env);
|
2021-05-12 20:54:18 +02:00
|
|
|
ctx->base.is_jmp = DISAS_EXIT;
|
2007-09-30 15:03:23 +02:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2003-11-23 15:55:54 +01:00
|
|
|
/* sc */
|
2007-10-08 01:10:08 +02:00
|
|
|
#if defined(CONFIG_USER_ONLY)
|
|
|
|
#define POWERPC_SYSCALL POWERPC_EXCP_SYSCALL_USER
|
|
|
|
#else
|
|
|
|
#define POWERPC_SYSCALL POWERPC_EXCP_SYSCALL
|
2020-05-07 13:53:28 +02:00
|
|
|
#define POWERPC_SYSCALL_VECTORED POWERPC_EXCP_SYSCALL_VECTORED
|
2007-10-08 01:10:08 +02:00
|
|
|
#endif
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_sc(DisasContext *ctx)
|
2003-11-23 15:55:54 +01:00
|
|
|
{
|
2007-09-29 15:06:16 +02:00
|
|
|
uint32_t lev;
|
|
|
|
|
|
|
|
lev = (ctx->opcode >> 5) & 0x7F;
|
2008-12-11 23:42:14 +01:00
|
|
|
gen_exception_err(ctx, POWERPC_SYSCALL, lev);
|
2003-11-23 15:55:54 +01:00
|
|
|
}
|
|
|
|
|
2020-05-07 13:53:28 +02:00
|
|
|
#if defined(TARGET_PPC64)
|
|
|
|
#if !defined(CONFIG_USER_ONLY)
|
|
|
|
static void gen_scv(DisasContext *ctx)
|
|
|
|
{
|
2021-03-23 19:43:35 +01:00
|
|
|
uint32_t lev = (ctx->opcode >> 5) & 0x7F;
|
2020-05-07 13:53:28 +02:00
|
|
|
|
2021-03-23 19:43:35 +01:00
|
|
|
/* Set the PC back to the faulting instruction. */
|
2021-05-17 22:50:06 +02:00
|
|
|
gen_update_nip(ctx, ctx->cia);
|
2021-03-23 19:43:35 +01:00
|
|
|
gen_helper_scv(cpu_env, tcg_constant_i32(lev));
|
2020-05-07 13:53:28 +02:00
|
|
|
|
2021-05-17 22:50:06 +02:00
|
|
|
ctx->base.is_jmp = DISAS_NORETURN;
|
2020-05-07 13:53:28 +02:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
2003-11-23 15:55:54 +01:00
|
|
|
/*** Trap ***/
|
2009-06-17 17:22:09 +02:00
|
|
|
|
2016-07-27 08:56:42 +02: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 17:22:19 +02:00
|
|
|
/* tw */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_tw(DisasContext *ctx)
|
2003-11-23 15:55:54 +01:00
|
|
|
{
|
2016-07-27 08:56:42 +02:00
|
|
|
TCGv_i32 t0;
|
|
|
|
|
|
|
|
if (check_unconditional_trap(ctx)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
t0 = tcg_const_i32(TO(ctx->opcode));
|
2012-05-30 06:23:23 +02:00
|
|
|
gen_helper_tw(cpu_env, cpu_gpr[rA(ctx->opcode)], cpu_gpr[rB(ctx->opcode)],
|
|
|
|
t0);
|
2008-11-24 12:28:19 +01:00
|
|
|
tcg_temp_free_i32(t0);
|
2003-11-23 15:55:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* twi */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_twi(DisasContext *ctx)
|
2003-11-23 15:55:54 +01:00
|
|
|
{
|
2016-07-27 08:56:42 +02: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 06:23:23 +02:00
|
|
|
gen_helper_tw(cpu_env, cpu_gpr[rA(ctx->opcode)], t0, t1);
|
2008-11-24 12:28:19 +01:00
|
|
|
tcg_temp_free(t0);
|
|
|
|
tcg_temp_free_i32(t1);
|
2003-11-23 15:55:54 +01:00
|
|
|
}
|
|
|
|
|
2007-03-17 15:02:15 +01:00
|
|
|
#if defined(TARGET_PPC64)
|
|
|
|
/* td */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_td(DisasContext *ctx)
|
2007-03-17 15:02:15 +01:00
|
|
|
{
|
2016-07-27 08:56:42 +02:00
|
|
|
TCGv_i32 t0;
|
|
|
|
|
|
|
|
if (check_unconditional_trap(ctx)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
t0 = tcg_const_i32(TO(ctx->opcode));
|
2012-05-30 06:23:23 +02:00
|
|
|
gen_helper_td(cpu_env, cpu_gpr[rA(ctx->opcode)], cpu_gpr[rB(ctx->opcode)],
|
|
|
|
t0);
|
2008-11-24 12:28:19 +01:00
|
|
|
tcg_temp_free_i32(t0);
|
2007-03-17 15:02:15 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* tdi */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_tdi(DisasContext *ctx)
|
2007-03-17 15:02:15 +01:00
|
|
|
{
|
2016-07-27 08:56:42 +02: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 06:23:23 +02:00
|
|
|
gen_helper_td(cpu_env, cpu_gpr[rA(ctx->opcode)], t0, t1);
|
2008-11-24 12:28:19 +01:00
|
|
|
tcg_temp_free(t0);
|
|
|
|
tcg_temp_free_i32(t1);
|
2007-03-17 15:02:15 +01:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2003-11-23 15:55:54 +01:00
|
|
|
/*** Processor control ***/
|
2009-06-17 17:22:09 +02:00
|
|
|
|
2009-06-17 17:22:19 +02:00
|
|
|
/* mcrxr */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_mcrxr(DisasContext *ctx)
|
2003-11-23 15:55:54 +01:00
|
|
|
{
|
2013-02-20 08:52:13 +01:00
|
|
|
TCGv_i32 t0 = tcg_temp_new_i32();
|
|
|
|
TCGv_i32 t1 = tcg_temp_new_i32();
|
|
|
|
TCGv_i32 dst = cpu_crf[crfD(ctx->opcode)];
|
|
|
|
|
|
|
|
tcg_gen_trunc_tl_i32(t0, cpu_so);
|
|
|
|
tcg_gen_trunc_tl_i32(t1, cpu_ov);
|
|
|
|
tcg_gen_trunc_tl_i32(dst, cpu_ca);
|
2014-06-17 07:54:02 +02:00
|
|
|
tcg_gen_shli_i32(t0, t0, 3);
|
|
|
|
tcg_gen_shli_i32(t1, t1, 2);
|
|
|
|
tcg_gen_shli_i32(dst, dst, 1);
|
2013-02-20 08:52:13 +01:00
|
|
|
tcg_gen_or_i32(dst, dst, t0);
|
|
|
|
tcg_gen_or_i32(dst, dst, t1);
|
|
|
|
tcg_temp_free_i32(t0);
|
|
|
|
tcg_temp_free_i32(t1);
|
|
|
|
|
|
|
|
tcg_gen_movi_tl(cpu_so, 0);
|
|
|
|
tcg_gen_movi_tl(cpu_ov, 0);
|
|
|
|
tcg_gen_movi_tl(cpu_ca, 0);
|
2003-11-23 15:55:54 +01:00
|
|
|
}
|
|
|
|
|
2017-02-27 05:58:01 +01:00
|
|
|
#ifdef TARGET_PPC64
|
|
|
|
/* mcrxrx */
|
|
|
|
static void gen_mcrxrx(DisasContext *ctx)
|
|
|
|
{
|
|
|
|
TCGv t0 = tcg_temp_new();
|
|
|
|
TCGv t1 = tcg_temp_new();
|
|
|
|
TCGv_i32 dst = cpu_crf[crfD(ctx->opcode)];
|
|
|
|
|
|
|
|
/* copy OV and OV32 */
|
|
|
|
tcg_gen_shli_tl(t0, cpu_ov, 1);
|
|
|
|
tcg_gen_or_tl(t0, t0, cpu_ov32);
|
|
|
|
tcg_gen_shli_tl(t0, t0, 2);
|
|
|
|
/* copy CA and CA32 */
|
|
|
|
tcg_gen_shli_tl(t1, cpu_ca, 1);
|
|
|
|
tcg_gen_or_tl(t1, t1, cpu_ca32);
|
|
|
|
tcg_gen_or_tl(t0, t0, t1);
|
|
|
|
tcg_gen_trunc_tl_i32(dst, t0);
|
|
|
|
tcg_temp_free(t0);
|
|
|
|
tcg_temp_free(t1);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2009-03-03 07:12:14 +01:00
|
|
|
/* mfcr mfocrf */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_mfcr(DisasContext *ctx)
|
2003-11-23 15:55:54 +01:00
|
|
|
{
|
2007-03-07 09:32:30 +01:00
|
|
|
uint32_t crm, crn;
|
2007-09-17 10:09:54 +02:00
|
|
|
|
2007-03-07 09:32:30 +01:00
|
|
|
if (likely(ctx->opcode & 0x00100000)) {
|
|
|
|
crm = CRM(ctx->opcode);
|
2009-03-02 23:39:39 +01:00
|
|
|
if (likely(crm && ((crm & (crm - 1)) == 0))) {
|
2019-03-21 12:57:28 +01:00
|
|
|
crn = ctz32(crm);
|
2008-10-21 13:31:14 +02:00
|
|
|
tcg_gen_extu_i32_tl(cpu_gpr[rD(ctx->opcode)], cpu_crf[7 - crn]);
|
2009-03-07 21:57:47 +01:00
|
|
|
tcg_gen_shli_tl(cpu_gpr[rD(ctx->opcode)],
|
|
|
|
cpu_gpr[rD(ctx->opcode)], crn * 4);
|
2007-03-07 09:32:30 +01:00
|
|
|
}
|
2007-03-17 15:02:15 +01:00
|
|
|
} else {
|
2009-03-09 19:50:24 +01:00
|
|
|
TCGv_i32 t0 = tcg_temp_new_i32();
|
|
|
|
tcg_gen_mov_i32(t0, cpu_crf[0]);
|
|
|
|
tcg_gen_shli_i32(t0, t0, 4);
|
|
|
|
tcg_gen_or_i32(t0, t0, cpu_crf[1]);
|
|
|
|
tcg_gen_shli_i32(t0, t0, 4);
|
|
|
|
tcg_gen_or_i32(t0, t0, cpu_crf[2]);
|
|
|
|
tcg_gen_shli_i32(t0, t0, 4);
|
|
|
|
tcg_gen_or_i32(t0, t0, cpu_crf[3]);
|
|
|
|
tcg_gen_shli_i32(t0, t0, 4);
|
|
|
|
tcg_gen_or_i32(t0, t0, cpu_crf[4]);
|
|
|
|
tcg_gen_shli_i32(t0, t0, 4);
|
|
|
|
tcg_gen_or_i32(t0, t0, cpu_crf[5]);
|
|
|
|
tcg_gen_shli_i32(t0, t0, 4);
|
|
|
|
tcg_gen_or_i32(t0, t0, cpu_crf[6]);
|
|
|
|
tcg_gen_shli_i32(t0, t0, 4);
|
|
|
|
tcg_gen_or_i32(t0, t0, cpu_crf[7]);
|
|
|
|
tcg_gen_extu_i32_tl(cpu_gpr[rD(ctx->opcode)], t0);
|
|
|
|
tcg_temp_free_i32(t0);
|
2007-03-17 15:02:15 +01:00
|
|
|
}
|
2003-11-23 15:55:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* mfmsr */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_mfmsr(DisasContext *ctx)
|
2003-11-23 15:55:54 +01:00
|
|
|
{
|
2016-06-21 23:48:51 +02:00
|
|
|
CHK_SV;
|
2008-12-06 14:03:35 +01:00
|
|
|
tcg_gen_mov_tl(cpu_gpr[rD(ctx->opcode)], cpu_msr);
|
2003-11-23 15:55:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* mfspr */
|
2009-08-16 11:06:54 +02:00
|
|
|
static inline void gen_op_mfspr(DisasContext *ctx)
|
2003-11-23 15:55:54 +01:00
|
|
|
{
|
2014-11-26 11:39:48 +01:00
|
|
|
void (*read_cb)(DisasContext *ctx, int gprn, int sprn);
|
2003-11-23 15:55:54 +01:00
|
|
|
uint32_t sprn = SPR(ctx->opcode);
|
|
|
|
|
2016-03-21 13:52:32 +01:00
|
|
|
#if defined(CONFIG_USER_ONLY)
|
|
|
|
read_cb = ctx->spr_cb[sprn].uea_read;
|
|
|
|
#else
|
|
|
|
if (ctx->pr) {
|
|
|
|
read_cb = ctx->spr_cb[sprn].uea_read;
|
|
|
|
} else if (ctx->hv) {
|
2007-09-30 15:03:23 +02:00
|
|
|
read_cb = ctx->spr_cb[sprn].hea_read;
|
2016-03-21 13:52:32 +01:00
|
|
|
} else {
|
2005-07-02 22:59:34 +02:00
|
|
|
read_cb = ctx->spr_cb[sprn].oea_read;
|
2016-03-21 13:52:32 +01:00
|
|
|
}
|
2004-01-04 23:58:38 +01:00
|
|
|
#endif
|
2007-03-07 09:32:30 +01:00
|
|
|
if (likely(read_cb != NULL)) {
|
|
|
|
if (likely(read_cb != SPR_NOACCESS)) {
|
2008-12-07 14:40:29 +01:00
|
|
|
(*read_cb)(ctx, rD(ctx->opcode), sprn);
|
2005-07-02 22:59:34 +02:00
|
|
|
} else {
|
|
|
|
/* Privilege exception */
|
2019-03-21 12:57:28 +01:00
|
|
|
/*
|
|
|
|
* This is a hack to avoid warnings when running Linux:
|
2007-11-02 23:47:50 +01:00
|
|
|
* this OS breaks the PowerPC virtualisation model,
|
|
|
|
* allowing userland application to read the PVR
|
|
|
|
*/
|
|
|
|
if (sprn != SPR_PVR) {
|
2018-05-28 20:11:19 +02:00
|
|
|
qemu_log_mask(LOG_GUEST_ERROR, "Trying to read privileged spr "
|
|
|
|
"%d (0x%03x) at " TARGET_FMT_lx "\n", sprn, sprn,
|
2021-05-12 20:54:11 +02:00
|
|
|
ctx->cia);
|
2005-11-23 22:36:30 +01:00
|
|
|
}
|
2016-06-21 23:48:51 +02:00
|
|
|
gen_priv_exception(ctx, POWERPC_EXCP_PRIV_REG);
|
2003-11-23 15:55:54 +01:00
|
|
|
}
|
2005-07-02 22:59:34 +02:00
|
|
|
} else {
|
2016-06-21 23:48:51 +02: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-02 22:59:34 +02:00
|
|
|
/* Not defined */
|
2018-05-28 20:11:19 +02:00
|
|
|
qemu_log_mask(LOG_GUEST_ERROR,
|
|
|
|
"Trying to read invalid spr %d (0x%03x) at "
|
2021-05-12 20:54:11 +02:00
|
|
|
TARGET_FMT_lx "\n", sprn, sprn, ctx->cia);
|
2016-06-21 23:48:51 +02:00
|
|
|
|
2019-03-21 12:57:28 +01:00
|
|
|
/*
|
|
|
|
* The behaviour depends on MSR:PR and SPR# bit 0x10, it can
|
|
|
|
* generate a priv, a hv emu or a no-op
|
2016-06-21 23:48:51 +02:00
|
|
|
*/
|
|
|
|
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 04:50:28 +02:00
|
|
|
}
|
2003-11-23 15:55:54 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_mfspr(DisasContext *ctx)
|
2003-11-23 15:55:54 +01:00
|
|
|
{
|
2005-07-02 22:59:34 +02:00
|
|
|
gen_op_mfspr(ctx);
|
2007-03-07 09:32:30 +01:00
|
|
|
}
|
2005-07-02 22:59:34 +02:00
|
|
|
|
|
|
|
/* mftb */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_mftb(DisasContext *ctx)
|
2005-07-02 22:59:34 +02:00
|
|
|
{
|
|
|
|
gen_op_mfspr(ctx);
|
2003-11-23 15:55:54 +01:00
|
|
|
}
|
|
|
|
|
2009-03-03 07:12:14 +01:00
|
|
|
/* mtcrf mtocrf*/
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_mtcrf(DisasContext *ctx)
|
2003-11-23 15:55:54 +01:00
|
|
|
{
|
2007-03-07 09:32:30 +01:00
|
|
|
uint32_t crm, crn;
|
2007-09-17 10:09:54 +02:00
|
|
|
|
2007-03-07 09:32:30 +01:00
|
|
|
crm = CRM(ctx->opcode);
|
2009-03-02 23:39:39 +01:00
|
|
|
if (likely((ctx->opcode & 0x00100000))) {
|
|
|
|
if (crm && ((crm & (crm - 1)) == 0)) {
|
|
|
|
TCGv_i32 temp = tcg_temp_new_i32();
|
2019-03-21 12:57:28 +01:00
|
|
|
crn = ctz32(crm);
|
2009-03-02 23:39:39 +01:00
|
|
|
tcg_gen_trunc_tl_i32(temp, cpu_gpr[rS(ctx->opcode)]);
|
2009-03-03 07:12:14 +01:00
|
|
|
tcg_gen_shri_i32(temp, temp, crn * 4);
|
|
|
|
tcg_gen_andi_i32(cpu_crf[7 - crn], temp, 0xf);
|
2009-03-02 23:39:39 +01:00
|
|
|
tcg_temp_free_i32(temp);
|
|
|
|
}
|
2007-03-07 09:32:30 +01:00
|
|
|
} else {
|
2009-03-09 19:50:24 +01:00
|
|
|
TCGv_i32 temp = tcg_temp_new_i32();
|
|
|
|
tcg_gen_trunc_tl_i32(temp, cpu_gpr[rS(ctx->opcode)]);
|
|
|
|
for (crn = 0 ; crn < 8 ; crn++) {
|
|
|
|
if (crm & (1 << crn)) {
|
|
|
|
tcg_gen_shri_i32(cpu_crf[7 - crn], temp, crn * 4);
|
|
|
|
tcg_gen_andi_i32(cpu_crf[7 - crn], cpu_crf[7 - crn], 0xf);
|
|
|
|
}
|
|
|
|
}
|
2008-11-17 15:43:54 +01:00
|
|
|
tcg_temp_free_i32(temp);
|
2007-03-07 09:32:30 +01:00
|
|
|
}
|
2003-11-23 15:55:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* mtmsr */
|
2007-03-23 10:45:27 +01:00
|
|
|
#if defined(TARGET_PPC64)
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_mtmsrd(DisasContext *ctx)
|
2007-03-23 10:45:27 +01:00
|
|
|
{
|
2016-06-21 23:48:51 +02:00
|
|
|
CHK_SV;
|
|
|
|
|
|
|
|
#if !defined(CONFIG_USER_ONLY)
|
2021-05-17 22:50:03 +02:00
|
|
|
gen_icount_io_start(ctx);
|
2007-09-30 15:03:23 +02:00
|
|
|
if (ctx->opcode & 0x00010000) {
|
target/ppc: Fix mtmsr(d) L=1 variant that loses interrupts
If mtmsr L=1 sets MSR[EE] while there is a maskable exception pending,
it does not cause an interrupt. This causes the test case to hang:
https://lists.gnu.org/archive/html/qemu-ppc/2019-10/msg00826.html
More recently, Linux reduced the occurance of operations (e.g., rfi)
which stop translation and allow pending interrupts to be processed.
This started causing hangs in Linux boot in long-running kernel tests,
running with '-d int' shows the decrementer stops firing despite DEC
wrapping and MSR[EE]=1.
https://lists.ozlabs.org/pipermail/linuxppc-dev/2020-April/208301.html
The cause is the broken mtmsr L=1 behaviour, which is contrary to the
architecture. From Power ISA v3.0B, p.977, Move To Machine State Register,
Programming Note states:
If MSR[EE]=0 and an External, Decrementer, or Performance Monitor
exception is pending, executing an mtmsrd instruction that sets
MSR[EE] to 1 will cause the interrupt to occur before the next
instruction is executed, if no higher priority exception exists
Fix this by handling L=1 exactly the same way as L=0, modulo the MSR
bits altered.
The confusion arises from L=0 being "context synchronizing" whereas L=1
is "execution synchronizing", which is a weaker semantic. However this
is not a relaxation of the requirement that these exceptions cause
interrupts when MSR[EE]=1 (e.g., when mtmsr executes to completion as
TCG is doing here), rather it specifies how a pipelined processor can
have multiple instructions in flight where one may influence how another
behaves.
Cc: qemu-stable@nongnu.org
Reported-by: Anton Blanchard <anton@ozlabs.org>
Reported-by: Nathan Chancellor <natechancellor@gmail.com>
Tested-by: Nathan Chancellor <natechancellor@gmail.com>
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
Message-Id: <20200414111131.465560-1-npiggin@gmail.com>
Reviewed-by: Cédric Le Goater <clg@kaod.org>
Tested-by: Cédric Le Goater <clg@kaod.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2020-04-14 13:11:31 +02:00
|
|
|
/* L=1 form only updates EE and RI */
|
2008-12-06 14:03:35 +01:00
|
|
|
TCGv t0 = tcg_temp_new();
|
target/ppc: Fix mtmsr(d) L=1 variant that loses interrupts
If mtmsr L=1 sets MSR[EE] while there is a maskable exception pending,
it does not cause an interrupt. This causes the test case to hang:
https://lists.gnu.org/archive/html/qemu-ppc/2019-10/msg00826.html
More recently, Linux reduced the occurance of operations (e.g., rfi)
which stop translation and allow pending interrupts to be processed.
This started causing hangs in Linux boot in long-running kernel tests,
running with '-d int' shows the decrementer stops firing despite DEC
wrapping and MSR[EE]=1.
https://lists.ozlabs.org/pipermail/linuxppc-dev/2020-April/208301.html
The cause is the broken mtmsr L=1 behaviour, which is contrary to the
architecture. From Power ISA v3.0B, p.977, Move To Machine State Register,
Programming Note states:
If MSR[EE]=0 and an External, Decrementer, or Performance Monitor
exception is pending, executing an mtmsrd instruction that sets
MSR[EE] to 1 will cause the interrupt to occur before the next
instruction is executed, if no higher priority exception exists
Fix this by handling L=1 exactly the same way as L=0, modulo the MSR
bits altered.
The confusion arises from L=0 being "context synchronizing" whereas L=1
is "execution synchronizing", which is a weaker semantic. However this
is not a relaxation of the requirement that these exceptions cause
interrupts when MSR[EE]=1 (e.g., when mtmsr executes to completion as
TCG is doing here), rather it specifies how a pipelined processor can
have multiple instructions in flight where one may influence how another
behaves.
Cc: qemu-stable@nongnu.org
Reported-by: Anton Blanchard <anton@ozlabs.org>
Reported-by: Nathan Chancellor <natechancellor@gmail.com>
Tested-by: Nathan Chancellor <natechancellor@gmail.com>
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
Message-Id: <20200414111131.465560-1-npiggin@gmail.com>
Reviewed-by: Cédric Le Goater <clg@kaod.org>
Tested-by: Cédric Le Goater <clg@kaod.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2020-04-14 13:11:31 +02:00
|
|
|
TCGv t1 = tcg_temp_new();
|
2019-03-21 12:57:28 +01:00
|
|
|
tcg_gen_andi_tl(t0, cpu_gpr[rS(ctx->opcode)],
|
|
|
|
(1 << MSR_RI) | (1 << MSR_EE));
|
target/ppc: Fix mtmsr(d) L=1 variant that loses interrupts
If mtmsr L=1 sets MSR[EE] while there is a maskable exception pending,
it does not cause an interrupt. This causes the test case to hang:
https://lists.gnu.org/archive/html/qemu-ppc/2019-10/msg00826.html
More recently, Linux reduced the occurance of operations (e.g., rfi)
which stop translation and allow pending interrupts to be processed.
This started causing hangs in Linux boot in long-running kernel tests,
running with '-d int' shows the decrementer stops firing despite DEC
wrapping and MSR[EE]=1.
https://lists.ozlabs.org/pipermail/linuxppc-dev/2020-April/208301.html
The cause is the broken mtmsr L=1 behaviour, which is contrary to the
architecture. From Power ISA v3.0B, p.977, Move To Machine State Register,
Programming Note states:
If MSR[EE]=0 and an External, Decrementer, or Performance Monitor
exception is pending, executing an mtmsrd instruction that sets
MSR[EE] to 1 will cause the interrupt to occur before the next
instruction is executed, if no higher priority exception exists
Fix this by handling L=1 exactly the same way as L=0, modulo the MSR
bits altered.
The confusion arises from L=0 being "context synchronizing" whereas L=1
is "execution synchronizing", which is a weaker semantic. However this
is not a relaxation of the requirement that these exceptions cause
interrupts when MSR[EE]=1 (e.g., when mtmsr executes to completion as
TCG is doing here), rather it specifies how a pipelined processor can
have multiple instructions in flight where one may influence how another
behaves.
Cc: qemu-stable@nongnu.org
Reported-by: Anton Blanchard <anton@ozlabs.org>
Reported-by: Nathan Chancellor <natechancellor@gmail.com>
Tested-by: Nathan Chancellor <natechancellor@gmail.com>
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
Message-Id: <20200414111131.465560-1-npiggin@gmail.com>
Reviewed-by: Cédric Le Goater <clg@kaod.org>
Tested-by: Cédric Le Goater <clg@kaod.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2020-04-14 13:11:31 +02:00
|
|
|
tcg_gen_andi_tl(t1, cpu_msr,
|
2019-03-21 12:57:28 +01:00
|
|
|
~(target_ulong)((1 << MSR_RI) | (1 << MSR_EE)));
|
target/ppc: Fix mtmsr(d) L=1 variant that loses interrupts
If mtmsr L=1 sets MSR[EE] while there is a maskable exception pending,
it does not cause an interrupt. This causes the test case to hang:
https://lists.gnu.org/archive/html/qemu-ppc/2019-10/msg00826.html
More recently, Linux reduced the occurance of operations (e.g., rfi)
which stop translation and allow pending interrupts to be processed.
This started causing hangs in Linux boot in long-running kernel tests,
running with '-d int' shows the decrementer stops firing despite DEC
wrapping and MSR[EE]=1.
https://lists.ozlabs.org/pipermail/linuxppc-dev/2020-April/208301.html
The cause is the broken mtmsr L=1 behaviour, which is contrary to the
architecture. From Power ISA v3.0B, p.977, Move To Machine State Register,
Programming Note states:
If MSR[EE]=0 and an External, Decrementer, or Performance Monitor
exception is pending, executing an mtmsrd instruction that sets
MSR[EE] to 1 will cause the interrupt to occur before the next
instruction is executed, if no higher priority exception exists
Fix this by handling L=1 exactly the same way as L=0, modulo the MSR
bits altered.
The confusion arises from L=0 being "context synchronizing" whereas L=1
is "execution synchronizing", which is a weaker semantic. However this
is not a relaxation of the requirement that these exceptions cause
interrupts when MSR[EE]=1 (e.g., when mtmsr executes to completion as
TCG is doing here), rather it specifies how a pipelined processor can
have multiple instructions in flight where one may influence how another
behaves.
Cc: qemu-stable@nongnu.org
Reported-by: Anton Blanchard <anton@ozlabs.org>
Reported-by: Nathan Chancellor <natechancellor@gmail.com>
Tested-by: Nathan Chancellor <natechancellor@gmail.com>
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
Message-Id: <20200414111131.465560-1-npiggin@gmail.com>
Reviewed-by: Cédric Le Goater <clg@kaod.org>
Tested-by: Cédric Le Goater <clg@kaod.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2020-04-14 13:11:31 +02:00
|
|
|
tcg_gen_or_tl(t1, t1, t0);
|
|
|
|
|
|
|
|
gen_helper_store_msr(cpu_env, t1);
|
2008-12-06 14:03:35 +01:00
|
|
|
tcg_temp_free(t0);
|
target/ppc: Fix mtmsr(d) L=1 variant that loses interrupts
If mtmsr L=1 sets MSR[EE] while there is a maskable exception pending,
it does not cause an interrupt. This causes the test case to hang:
https://lists.gnu.org/archive/html/qemu-ppc/2019-10/msg00826.html
More recently, Linux reduced the occurance of operations (e.g., rfi)
which stop translation and allow pending interrupts to be processed.
This started causing hangs in Linux boot in long-running kernel tests,
running with '-d int' shows the decrementer stops firing despite DEC
wrapping and MSR[EE]=1.
https://lists.ozlabs.org/pipermail/linuxppc-dev/2020-April/208301.html
The cause is the broken mtmsr L=1 behaviour, which is contrary to the
architecture. From Power ISA v3.0B, p.977, Move To Machine State Register,
Programming Note states:
If MSR[EE]=0 and an External, Decrementer, or Performance Monitor
exception is pending, executing an mtmsrd instruction that sets
MSR[EE] to 1 will cause the interrupt to occur before the next
instruction is executed, if no higher priority exception exists
Fix this by handling L=1 exactly the same way as L=0, modulo the MSR
bits altered.
The confusion arises from L=0 being "context synchronizing" whereas L=1
is "execution synchronizing", which is a weaker semantic. However this
is not a relaxation of the requirement that these exceptions cause
interrupts when MSR[EE]=1 (e.g., when mtmsr executes to completion as
TCG is doing here), rather it specifies how a pipelined processor can
have multiple instructions in flight where one may influence how another
behaves.
Cc: qemu-stable@nongnu.org
Reported-by: Anton Blanchard <anton@ozlabs.org>
Reported-by: Nathan Chancellor <natechancellor@gmail.com>
Tested-by: Nathan Chancellor <natechancellor@gmail.com>
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
Message-Id: <20200414111131.465560-1-npiggin@gmail.com>
Reviewed-by: Cédric Le Goater <clg@kaod.org>
Tested-by: Cédric Le Goater <clg@kaod.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2020-04-14 13:11:31 +02:00
|
|
|
tcg_temp_free(t1);
|
|
|
|
|
2007-09-30 15:03:23 +02:00
|
|
|
} else {
|
2019-03-21 12:57:28 +01: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-10-01 05:03:51 +02:00
|
|
|
*/
|
2018-02-15 20:51:48 +01:00
|
|
|
gen_update_nip(ctx, ctx->base.pc_next);
|
2012-05-30 06:23:23 +02:00
|
|
|
gen_helper_store_msr(cpu_env, cpu_gpr[rS(ctx->opcode)]);
|
2007-09-30 15:03:23 +02:00
|
|
|
}
|
target/ppc: Fix mtmsr(d) L=1 variant that loses interrupts
If mtmsr L=1 sets MSR[EE] while there is a maskable exception pending,
it does not cause an interrupt. This causes the test case to hang:
https://lists.gnu.org/archive/html/qemu-ppc/2019-10/msg00826.html
More recently, Linux reduced the occurance of operations (e.g., rfi)
which stop translation and allow pending interrupts to be processed.
This started causing hangs in Linux boot in long-running kernel tests,
running with '-d int' shows the decrementer stops firing despite DEC
wrapping and MSR[EE]=1.
https://lists.ozlabs.org/pipermail/linuxppc-dev/2020-April/208301.html
The cause is the broken mtmsr L=1 behaviour, which is contrary to the
architecture. From Power ISA v3.0B, p.977, Move To Machine State Register,
Programming Note states:
If MSR[EE]=0 and an External, Decrementer, or Performance Monitor
exception is pending, executing an mtmsrd instruction that sets
MSR[EE] to 1 will cause the interrupt to occur before the next
instruction is executed, if no higher priority exception exists
Fix this by handling L=1 exactly the same way as L=0, modulo the MSR
bits altered.
The confusion arises from L=0 being "context synchronizing" whereas L=1
is "execution synchronizing", which is a weaker semantic. However this
is not a relaxation of the requirement that these exceptions cause
interrupts when MSR[EE]=1 (e.g., when mtmsr executes to completion as
TCG is doing here), rather it specifies how a pipelined processor can
have multiple instructions in flight where one may influence how another
behaves.
Cc: qemu-stable@nongnu.org
Reported-by: Anton Blanchard <anton@ozlabs.org>
Reported-by: Nathan Chancellor <natechancellor@gmail.com>
Tested-by: Nathan Chancellor <natechancellor@gmail.com>
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
Message-Id: <20200414111131.465560-1-npiggin@gmail.com>
Reviewed-by: Cédric Le Goater <clg@kaod.org>
Tested-by: Cédric Le Goater <clg@kaod.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2020-04-14 13:11:31 +02:00
|
|
|
/* Must stop the translation as machine state (may have) changed */
|
2021-05-17 22:50:04 +02:00
|
|
|
ctx->base.is_jmp = DISAS_EXIT_UPDATE;
|
2016-06-21 23:48:51 +02:00
|
|
|
#endif /* !defined(CONFIG_USER_ONLY) */
|
2007-03-23 10:45:27 +01:00
|
|
|
}
|
2016-06-21 23:48:51 +02:00
|
|
|
#endif /* defined(TARGET_PPC64) */
|
2007-03-23 10:45:27 +01:00
|
|
|
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_mtmsr(DisasContext *ctx)
|
2003-11-23 15:55:54 +01:00
|
|
|
{
|
2016-06-21 23:48:51 +02:00
|
|
|
CHK_SV;
|
|
|
|
|
|
|
|
#if !defined(CONFIG_USER_ONLY)
|
2021-05-17 22:50:03 +02:00
|
|
|
gen_icount_io_start(ctx);
|
target/ppc: Fix mtmsr(d) L=1 variant that loses interrupts
If mtmsr L=1 sets MSR[EE] while there is a maskable exception pending,
it does not cause an interrupt. This causes the test case to hang:
https://lists.gnu.org/archive/html/qemu-ppc/2019-10/msg00826.html
More recently, Linux reduced the occurance of operations (e.g., rfi)
which stop translation and allow pending interrupts to be processed.
This started causing hangs in Linux boot in long-running kernel tests,
running with '-d int' shows the decrementer stops firing despite DEC
wrapping and MSR[EE]=1.
https://lists.ozlabs.org/pipermail/linuxppc-dev/2020-April/208301.html
The cause is the broken mtmsr L=1 behaviour, which is contrary to the
architecture. From Power ISA v3.0B, p.977, Move To Machine State Register,
Programming Note states:
If MSR[EE]=0 and an External, Decrementer, or Performance Monitor
exception is pending, executing an mtmsrd instruction that sets
MSR[EE] to 1 will cause the interrupt to occur before the next
instruction is executed, if no higher priority exception exists
Fix this by handling L=1 exactly the same way as L=0, modulo the MSR
bits altered.
The confusion arises from L=0 being "context synchronizing" whereas L=1
is "execution synchronizing", which is a weaker semantic. However this
is not a relaxation of the requirement that these exceptions cause
interrupts when MSR[EE]=1 (e.g., when mtmsr executes to completion as
TCG is doing here), rather it specifies how a pipelined processor can
have multiple instructions in flight where one may influence how another
behaves.
Cc: qemu-stable@nongnu.org
Reported-by: Anton Blanchard <anton@ozlabs.org>
Reported-by: Nathan Chancellor <natechancellor@gmail.com>
Tested-by: Nathan Chancellor <natechancellor@gmail.com>
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
Message-Id: <20200414111131.465560-1-npiggin@gmail.com>
Reviewed-by: Cédric Le Goater <clg@kaod.org>
Tested-by: Cédric Le Goater <clg@kaod.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2020-04-14 13:11:31 +02:00
|
|
|
if (ctx->opcode & 0x00010000) {
|
|
|
|
/* L=1 form only updates EE and RI */
|
2008-12-06 14:03:35 +01:00
|
|
|
TCGv t0 = tcg_temp_new();
|
target/ppc: Fix mtmsr(d) L=1 variant that loses interrupts
If mtmsr L=1 sets MSR[EE] while there is a maskable exception pending,
it does not cause an interrupt. This causes the test case to hang:
https://lists.gnu.org/archive/html/qemu-ppc/2019-10/msg00826.html
More recently, Linux reduced the occurance of operations (e.g., rfi)
which stop translation and allow pending interrupts to be processed.
This started causing hangs in Linux boot in long-running kernel tests,
running with '-d int' shows the decrementer stops firing despite DEC
wrapping and MSR[EE]=1.
https://lists.ozlabs.org/pipermail/linuxppc-dev/2020-April/208301.html
The cause is the broken mtmsr L=1 behaviour, which is contrary to the
architecture. From Power ISA v3.0B, p.977, Move To Machine State Register,
Programming Note states:
If MSR[EE]=0 and an External, Decrementer, or Performance Monitor
exception is pending, executing an mtmsrd instruction that sets
MSR[EE] to 1 will cause the interrupt to occur before the next
instruction is executed, if no higher priority exception exists
Fix this by handling L=1 exactly the same way as L=0, modulo the MSR
bits altered.
The confusion arises from L=0 being "context synchronizing" whereas L=1
is "execution synchronizing", which is a weaker semantic. However this
is not a relaxation of the requirement that these exceptions cause
interrupts when MSR[EE]=1 (e.g., when mtmsr executes to completion as
TCG is doing here), rather it specifies how a pipelined processor can
have multiple instructions in flight where one may influence how another
behaves.
Cc: qemu-stable@nongnu.org
Reported-by: Anton Blanchard <anton@ozlabs.org>
Reported-by: Nathan Chancellor <natechancellor@gmail.com>
Tested-by: Nathan Chancellor <natechancellor@gmail.com>
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
Message-Id: <20200414111131.465560-1-npiggin@gmail.com>
Reviewed-by: Cédric Le Goater <clg@kaod.org>
Tested-by: Cédric Le Goater <clg@kaod.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2020-04-14 13:11:31 +02:00
|
|
|
TCGv t1 = tcg_temp_new();
|
2019-03-21 12:57:28 +01:00
|
|
|
tcg_gen_andi_tl(t0, cpu_gpr[rS(ctx->opcode)],
|
|
|
|
(1 << MSR_RI) | (1 << MSR_EE));
|
target/ppc: Fix mtmsr(d) L=1 variant that loses interrupts
If mtmsr L=1 sets MSR[EE] while there is a maskable exception pending,
it does not cause an interrupt. This causes the test case to hang:
https://lists.gnu.org/archive/html/qemu-ppc/2019-10/msg00826.html
More recently, Linux reduced the occurance of operations (e.g., rfi)
which stop translation and allow pending interrupts to be processed.
This started causing hangs in Linux boot in long-running kernel tests,
running with '-d int' shows the decrementer stops firing despite DEC
wrapping and MSR[EE]=1.
https://lists.ozlabs.org/pipermail/linuxppc-dev/2020-April/208301.html
The cause is the broken mtmsr L=1 behaviour, which is contrary to the
architecture. From Power ISA v3.0B, p.977, Move To Machine State Register,
Programming Note states:
If MSR[EE]=0 and an External, Decrementer, or Performance Monitor
exception is pending, executing an mtmsrd instruction that sets
MSR[EE] to 1 will cause the interrupt to occur before the next
instruction is executed, if no higher priority exception exists
Fix this by handling L=1 exactly the same way as L=0, modulo the MSR
bits altered.
The confusion arises from L=0 being "context synchronizing" whereas L=1
is "execution synchronizing", which is a weaker semantic. However this
is not a relaxation of the requirement that these exceptions cause
interrupts when MSR[EE]=1 (e.g., when mtmsr executes to completion as
TCG is doing here), rather it specifies how a pipelined processor can
have multiple instructions in flight where one may influence how another
behaves.
Cc: qemu-stable@nongnu.org
Reported-by: Anton Blanchard <anton@ozlabs.org>
Reported-by: Nathan Chancellor <natechancellor@gmail.com>
Tested-by: Nathan Chancellor <natechancellor@gmail.com>
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
Message-Id: <20200414111131.465560-1-npiggin@gmail.com>
Reviewed-by: Cédric Le Goater <clg@kaod.org>
Tested-by: Cédric Le Goater <clg@kaod.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2020-04-14 13:11:31 +02:00
|
|
|
tcg_gen_andi_tl(t1, cpu_msr,
|
2019-03-21 12:57:28 +01:00
|
|
|
~(target_ulong)((1 << MSR_RI) | (1 << MSR_EE)));
|
target/ppc: Fix mtmsr(d) L=1 variant that loses interrupts
If mtmsr L=1 sets MSR[EE] while there is a maskable exception pending,
it does not cause an interrupt. This causes the test case to hang:
https://lists.gnu.org/archive/html/qemu-ppc/2019-10/msg00826.html
More recently, Linux reduced the occurance of operations (e.g., rfi)
which stop translation and allow pending interrupts to be processed.
This started causing hangs in Linux boot in long-running kernel tests,
running with '-d int' shows the decrementer stops firing despite DEC
wrapping and MSR[EE]=1.
https://lists.ozlabs.org/pipermail/linuxppc-dev/2020-April/208301.html
The cause is the broken mtmsr L=1 behaviour, which is contrary to the
architecture. From Power ISA v3.0B, p.977, Move To Machine State Register,
Programming Note states:
If MSR[EE]=0 and an External, Decrementer, or Performance Monitor
exception is pending, executing an mtmsrd instruction that sets
MSR[EE] to 1 will cause the interrupt to occur before the next
instruction is executed, if no higher priority exception exists
Fix this by handling L=1 exactly the same way as L=0, modulo the MSR
bits altered.
The confusion arises from L=0 being "context synchronizing" whereas L=1
is "execution synchronizing", which is a weaker semantic. However this
is not a relaxation of the requirement that these exceptions cause
interrupts when MSR[EE]=1 (e.g., when mtmsr executes to completion as
TCG is doing here), rather it specifies how a pipelined processor can
have multiple instructions in flight where one may influence how another
behaves.
Cc: qemu-stable@nongnu.org
Reported-by: Anton Blanchard <anton@ozlabs.org>
Reported-by: Nathan Chancellor <natechancellor@gmail.com>
Tested-by: Nathan Chancellor <natechancellor@gmail.com>
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
Message-Id: <20200414111131.465560-1-npiggin@gmail.com>
Reviewed-by: Cédric Le Goater <clg@kaod.org>
Tested-by: Cédric Le Goater <clg@kaod.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2020-04-14 13:11:31 +02:00
|
|
|
tcg_gen_or_tl(t1, t1, t0);
|
|
|
|
|
|
|
|
gen_helper_store_msr(cpu_env, t1);
|
2008-12-06 14:03:35 +01:00
|
|
|
tcg_temp_free(t0);
|
target/ppc: Fix mtmsr(d) L=1 variant that loses interrupts
If mtmsr L=1 sets MSR[EE] while there is a maskable exception pending,
it does not cause an interrupt. This causes the test case to hang:
https://lists.gnu.org/archive/html/qemu-ppc/2019-10/msg00826.html
More recently, Linux reduced the occurance of operations (e.g., rfi)
which stop translation and allow pending interrupts to be processed.
This started causing hangs in Linux boot in long-running kernel tests,
running with '-d int' shows the decrementer stops firing despite DEC
wrapping and MSR[EE]=1.
https://lists.ozlabs.org/pipermail/linuxppc-dev/2020-April/208301.html
The cause is the broken mtmsr L=1 behaviour, which is contrary to the
architecture. From Power ISA v3.0B, p.977, Move To Machine State Register,
Programming Note states:
If MSR[EE]=0 and an External, Decrementer, or Performance Monitor
exception is pending, executing an mtmsrd instruction that sets
MSR[EE] to 1 will cause the interrupt to occur before the next
instruction is executed, if no higher priority exception exists
Fix this by handling L=1 exactly the same way as L=0, modulo the MSR
bits altered.
The confusion arises from L=0 being "context synchronizing" whereas L=1
is "execution synchronizing", which is a weaker semantic. However this
is not a relaxation of the requirement that these exceptions cause
interrupts when MSR[EE]=1 (e.g., when mtmsr executes to completion as
TCG is doing here), rather it specifies how a pipelined processor can
have multiple instructions in flight where one may influence how another
behaves.
Cc: qemu-stable@nongnu.org
Reported-by: Anton Blanchard <anton@ozlabs.org>
Reported-by: Nathan Chancellor <natechancellor@gmail.com>
Tested-by: Nathan Chancellor <natechancellor@gmail.com>
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
Message-Id: <20200414111131.465560-1-npiggin@gmail.com>
Reviewed-by: Cédric Le Goater <clg@kaod.org>
Tested-by: Cédric Le Goater <clg@kaod.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2020-04-14 13:11:31 +02:00
|
|
|
tcg_temp_free(t1);
|
|
|
|
|
2007-09-30 15:03:23 +02:00
|
|
|
} else {
|
2011-06-16 10:44:23 +02:00
|
|
|
TCGv msr = tcg_temp_new();
|
|
|
|
|
2019-03-21 12:57:28 +01: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-10-01 05:03:51 +02:00
|
|
|
*/
|
2018-02-15 20:51:48 +01:00
|
|
|
gen_update_nip(ctx, ctx->base.pc_next);
|
2007-03-17 15:02:15 +01:00
|
|
|
#if defined(TARGET_PPC64)
|
2011-06-16 10:44:23 +02:00
|
|
|
tcg_gen_deposit_tl(msr, cpu_msr, cpu_gpr[rS(ctx->opcode)], 0, 32);
|
|
|
|
#else
|
|
|
|
tcg_gen_mov_tl(msr, cpu_gpr[rS(ctx->opcode)]);
|
2007-03-17 15:02:15 +01:00
|
|
|
#endif
|
2012-05-30 06:23:23 +02:00
|
|
|
gen_helper_store_msr(cpu_env, msr);
|
2014-01-19 17:26:33 +01:00
|
|
|
tcg_temp_free(msr);
|
2007-09-30 15:03:23 +02:00
|
|
|
}
|
target/ppc: Fix mtmsr(d) L=1 variant that loses interrupts
If mtmsr L=1 sets MSR[EE] while there is a maskable exception pending,
it does not cause an interrupt. This causes the test case to hang:
https://lists.gnu.org/archive/html/qemu-ppc/2019-10/msg00826.html
More recently, Linux reduced the occurance of operations (e.g., rfi)
which stop translation and allow pending interrupts to be processed.
This started causing hangs in Linux boot in long-running kernel tests,
running with '-d int' shows the decrementer stops firing despite DEC
wrapping and MSR[EE]=1.
https://lists.ozlabs.org/pipermail/linuxppc-dev/2020-April/208301.html
The cause is the broken mtmsr L=1 behaviour, which is contrary to the
architecture. From Power ISA v3.0B, p.977, Move To Machine State Register,
Programming Note states:
If MSR[EE]=0 and an External, Decrementer, or Performance Monitor
exception is pending, executing an mtmsrd instruction that sets
MSR[EE] to 1 will cause the interrupt to occur before the next
instruction is executed, if no higher priority exception exists
Fix this by handling L=1 exactly the same way as L=0, modulo the MSR
bits altered.
The confusion arises from L=0 being "context synchronizing" whereas L=1
is "execution synchronizing", which is a weaker semantic. However this
is not a relaxation of the requirement that these exceptions cause
interrupts when MSR[EE]=1 (e.g., when mtmsr executes to completion as
TCG is doing here), rather it specifies how a pipelined processor can
have multiple instructions in flight where one may influence how another
behaves.
Cc: qemu-stable@nongnu.org
Reported-by: Anton Blanchard <anton@ozlabs.org>
Reported-by: Nathan Chancellor <natechancellor@gmail.com>
Tested-by: Nathan Chancellor <natechancellor@gmail.com>
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
Message-Id: <20200414111131.465560-1-npiggin@gmail.com>
Reviewed-by: Cédric Le Goater <clg@kaod.org>
Tested-by: Cédric Le Goater <clg@kaod.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2020-04-14 13:11:31 +02:00
|
|
|
/* Must stop the translation as machine state (may have) changed */
|
2021-05-17 22:50:04 +02:00
|
|
|
ctx->base.is_jmp = DISAS_EXIT_UPDATE;
|
2004-01-04 23:58:38 +01:00
|
|
|
#endif
|
2003-11-23 15:55:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* mtspr */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_mtspr(DisasContext *ctx)
|
2003-11-23 15:55:54 +01:00
|
|
|
{
|
2014-11-26 11:39:48 +01:00
|
|
|
void (*write_cb)(DisasContext *ctx, int sprn, int gprn);
|
2003-11-23 15:55:54 +01:00
|
|
|
uint32_t sprn = SPR(ctx->opcode);
|
|
|
|
|
2016-03-21 13:52:32 +01:00
|
|
|
#if defined(CONFIG_USER_ONLY)
|
|
|
|
write_cb = ctx->spr_cb[sprn].uea_write;
|
|
|
|
#else
|
|
|
|
if (ctx->pr) {
|
|
|
|
write_cb = ctx->spr_cb[sprn].uea_write;
|
|
|
|
} else if (ctx->hv) {
|
2007-09-30 15:03:23 +02:00
|
|
|
write_cb = ctx->spr_cb[sprn].hea_write;
|
2016-03-21 13:52:32 +01:00
|
|
|
} else {
|
2005-07-02 22:59:34 +02:00
|
|
|
write_cb = ctx->spr_cb[sprn].oea_write;
|
2016-03-21 13:52:32 +01:00
|
|
|
}
|
2004-01-04 23:58:38 +01:00
|
|
|
#endif
|
2007-03-07 09:32:30 +01:00
|
|
|
if (likely(write_cb != NULL)) {
|
|
|
|
if (likely(write_cb != SPR_NOACCESS)) {
|
2008-12-07 14:40:29 +01:00
|
|
|
(*write_cb)(ctx, sprn, rS(ctx->opcode));
|
2005-07-02 22:59:34 +02:00
|
|
|
} else {
|
|
|
|
/* Privilege exception */
|
2018-05-28 20:11:19 +02:00
|
|
|
qemu_log_mask(LOG_GUEST_ERROR, "Trying to write privileged spr "
|
|
|
|
"%d (0x%03x) at " TARGET_FMT_lx "\n", sprn, sprn,
|
2021-05-12 20:54:11 +02:00
|
|
|
ctx->cia);
|
2016-06-21 23:48:51 +02:00
|
|
|
gen_priv_exception(ctx, POWERPC_EXCP_PRIV_REG);
|
2007-03-07 09:32:30 +01:00
|
|
|
}
|
2005-07-02 22:59:34 +02:00
|
|
|
} else {
|
2016-06-21 23:48:51 +02: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-02 22:59:34 +02:00
|
|
|
/* Not defined */
|
2018-05-28 20:11:19 +02:00
|
|
|
qemu_log_mask(LOG_GUEST_ERROR,
|
|
|
|
"Trying to write invalid spr %d (0x%03x) at "
|
2021-05-12 20:54:11 +02:00
|
|
|
TARGET_FMT_lx "\n", sprn, sprn, ctx->cia);
|
2016-06-07 04:50:28 +02:00
|
|
|
|
2016-06-21 23:48:51 +02:00
|
|
|
|
2019-03-21 12:57:28 +01:00
|
|
|
/*
|
|
|
|
* The behaviour depends on MSR:PR and SPR# bit 0x10, it can
|
|
|
|
* generate a priv, a hv emu or a no-op
|
2016-06-21 23:48:51 +02:00
|
|
|
*/
|
|
|
|
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 04:50:28 +02:00
|
|
|
}
|
2003-11-23 15:55:54 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-07-26 13:58:35 +02: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 15:55:54 +01:00
|
|
|
/*** Cache management ***/
|
2009-06-17 17:22:09 +02:00
|
|
|
|
2009-06-17 17:22:19 +02:00
|
|
|
/* dcbf */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_dcbf(DisasContext *ctx)
|
2003-11-23 15:55:54 +01:00
|
|
|
{
|
2007-10-26 02:48:00 +02:00
|
|
|
/* XXX: specification says this is treated as a load by the MMU */
|
2008-12-08 19:11:21 +01:00
|
|
|
TCGv t0;
|
|
|
|
gen_set_access_type(ctx, ACCESS_CACHE);
|
|
|
|
t0 = tcg_temp_new();
|
|
|
|
gen_addr_reg_index(ctx, t0);
|
|
|
|
gen_qemu_ld8u(ctx, t0, t0);
|
2008-11-02 09:22:34 +01:00
|
|
|
tcg_temp_free(t0);
|
2003-11-23 15:55:54 +01:00
|
|
|
}
|
|
|
|
|
2018-09-21 08:59:07 +02:00
|
|
|
/* dcbfep (external PID dcbf) */
|
|
|
|
static void gen_dcbfep(DisasContext *ctx)
|
|
|
|
{
|
|
|
|
/* XXX: specification says this is treated as a load by the MMU */
|
|
|
|
TCGv t0;
|
|
|
|
CHK_SV;
|
|
|
|
gen_set_access_type(ctx, ACCESS_CACHE);
|
|
|
|
t0 = tcg_temp_new();
|
|
|
|
gen_addr_reg_index(ctx, t0);
|
|
|
|
tcg_gen_qemu_ld_tl(t0, t0, PPC_TLB_EPID_LOAD, DEF_MEMOP(MO_UB));
|
|
|
|
tcg_temp_free(t0);
|
|
|
|
}
|
|
|
|
|
2003-11-23 15:55:54 +01:00
|
|
|
/* dcbi (Supervisor only) */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_dcbi(DisasContext *ctx)
|
2003-11-23 15:55:54 +01:00
|
|
|
{
|
2004-04-12 22:39:29 +02:00
|
|
|
#if defined(CONFIG_USER_ONLY)
|
2016-06-21 23:48:51 +02:00
|
|
|
GEN_PRIV;
|
2004-04-12 22:39:29 +02:00
|
|
|
#else
|
2008-10-15 19:00:37 +02:00
|
|
|
TCGv EA, val;
|
2016-06-21 23:48:51 +02:00
|
|
|
|
|
|
|
CHK_SV;
|
2008-11-17 15:43:54 +01:00
|
|
|
EA = tcg_temp_new();
|
2008-12-08 19:11:21 +01:00
|
|
|
gen_set_access_type(ctx, ACCESS_CACHE);
|
|
|
|
gen_addr_reg_index(ctx, EA);
|
2008-11-17 15:43:54 +01:00
|
|
|
val = tcg_temp_new();
|
2007-03-07 09:32:30 +01:00
|
|
|
/* XXX: specification says this should be treated as a store by the MMU */
|
2008-12-08 19:11:21 +01:00
|
|
|
gen_qemu_ld8u(ctx, val, EA);
|
|
|
|
gen_qemu_st8(ctx, val, EA);
|
2008-10-15 19:00:37 +02:00
|
|
|
tcg_temp_free(val);
|
|
|
|
tcg_temp_free(EA);
|
2016-06-21 23:48:51 +02:00
|
|
|
#endif /* defined(CONFIG_USER_ONLY) */
|
2003-11-23 15:55:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* dcdst */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_dcbst(DisasContext *ctx)
|
2003-11-23 15:55:54 +01:00
|
|
|
{
|
2007-03-07 09:32:30 +01:00
|
|
|
/* XXX: specification say this is treated as a load by the MMU */
|
2008-12-08 19:11:21 +01:00
|
|
|
TCGv t0;
|
|
|
|
gen_set_access_type(ctx, ACCESS_CACHE);
|
|
|
|
t0 = tcg_temp_new();
|
|
|
|
gen_addr_reg_index(ctx, t0);
|
|
|
|
gen_qemu_ld8u(ctx, t0, t0);
|
2008-11-02 09:22:34 +01:00
|
|
|
tcg_temp_free(t0);
|
2003-11-23 15:55:54 +01:00
|
|
|
}
|
|
|
|
|
2018-09-21 08:59:07 +02:00
|
|
|
/* dcbstep (dcbstep External PID version) */
|
|
|
|
static void gen_dcbstep(DisasContext *ctx)
|
|
|
|
{
|
|
|
|
/* XXX: specification say this is treated as a load by the MMU */
|
|
|
|
TCGv t0;
|
|
|
|
gen_set_access_type(ctx, ACCESS_CACHE);
|
|
|
|
t0 = tcg_temp_new();
|
|
|
|
gen_addr_reg_index(ctx, t0);
|
|
|
|
tcg_gen_qemu_ld_tl(t0, t0, PPC_TLB_EPID_LOAD, DEF_MEMOP(MO_UB));
|
|
|
|
tcg_temp_free(t0);
|
|
|
|
}
|
|
|
|
|
2003-11-23 15:55:54 +01:00
|
|
|
/* dcbt */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_dcbt(DisasContext *ctx)
|
2003-11-23 15:55:54 +01:00
|
|
|
{
|
2019-03-21 12:57:28 +01:00
|
|
|
/*
|
|
|
|
* interpreted as no-op
|
|
|
|
* XXX: specification say this is treated as a load by the MMU but
|
|
|
|
* does not generate any exception
|
2007-03-07 09:32:30 +01:00
|
|
|
*/
|
2003-11-23 15:55:54 +01:00
|
|
|
}
|
|
|
|
|
2018-09-21 08:59:07 +02:00
|
|
|
/* dcbtep */
|
|
|
|
static void gen_dcbtep(DisasContext *ctx)
|
|
|
|
{
|
2019-03-21 12:57:28 +01:00
|
|
|
/*
|
|
|
|
* interpreted as no-op
|
|
|
|
* XXX: specification say this is treated as a load by the MMU but
|
|
|
|
* does not generate any exception
|
2018-09-21 08:59:07 +02:00
|
|
|
*/
|
|
|
|
}
|
|
|
|
|
2003-11-23 15:55:54 +01:00
|
|
|
/* dcbtst */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_dcbtst(DisasContext *ctx)
|
2003-11-23 15:55:54 +01:00
|
|
|
{
|
2019-03-21 12:57:28 +01:00
|
|
|
/*
|
|
|
|
* interpreted as no-op
|
|
|
|
* XXX: specification say this is treated as a load by the MMU but
|
|
|
|
* does not generate any exception
|
2007-03-07 09:32:30 +01:00
|
|
|
*/
|
2003-11-23 15:55:54 +01:00
|
|
|
}
|
|
|
|
|
2018-09-21 08:59:07 +02:00
|
|
|
/* dcbtstep */
|
|
|
|
static void gen_dcbtstep(DisasContext *ctx)
|
|
|
|
{
|
2019-03-21 12:57:28 +01:00
|
|
|
/*
|
|
|
|
* interpreted as no-op
|
|
|
|
* XXX: specification say this is treated as a load by the MMU but
|
|
|
|
* does not generate any exception
|
2018-09-21 08:59:07 +02:00
|
|
|
*/
|
|
|
|
}
|
|
|
|
|
2014-01-19 17:50:09 +01:00
|
|
|
/* dcbtls */
|
|
|
|
static void gen_dcbtls(DisasContext *ctx)
|
|
|
|
{
|
|
|
|
/* Always fails locking the cache */
|
|
|
|
TCGv t0 = tcg_temp_new();
|
|
|
|
gen_load_spr(t0, SPR_Exxx_L1CSR0);
|
|
|
|
tcg_gen_ori_tl(t0, t0, L1CSR0_CUL);
|
|
|
|
gen_store_spr(SPR_Exxx_L1CSR0, t0);
|
|
|
|
tcg_temp_free(t0);
|
|
|
|
}
|
|
|
|
|
2003-11-23 15:55:54 +01:00
|
|
|
/* dcbz */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_dcbz(DisasContext *ctx)
|
2003-11-23 15:55:54 +01:00
|
|
|
{
|
2013-01-29 13:36:02 +01:00
|
|
|
TCGv tcgv_addr;
|
2016-07-27 08:56:43 +02:00
|
|
|
TCGv_i32 tcgv_op;
|
2007-10-04 02:51:58 +02:00
|
|
|
|
2008-12-08 19:11:21 +01:00
|
|
|
gen_set_access_type(ctx, ACCESS_CACHE);
|
2013-01-29 13:36:02 +01:00
|
|
|
tcgv_addr = tcg_temp_new();
|
2016-07-27 08:56:43 +02:00
|
|
|
tcgv_op = tcg_const_i32(ctx->opcode & 0x03FF000);
|
2013-01-29 13:36:02 +01:00
|
|
|
gen_addr_reg_index(ctx, tcgv_addr);
|
2016-07-27 08:56:43 +02:00
|
|
|
gen_helper_dcbz(cpu_env, tcgv_addr, tcgv_op);
|
2013-01-29 13:36:02 +01:00
|
|
|
tcg_temp_free(tcgv_addr);
|
2016-07-27 08:56:43 +02:00
|
|
|
tcg_temp_free_i32(tcgv_op);
|
2003-11-23 15:55:54 +01:00
|
|
|
}
|
|
|
|
|
2018-09-21 08:59:07 +02:00
|
|
|
/* dcbzep */
|
|
|
|
static void gen_dcbzep(DisasContext *ctx)
|
|
|
|
{
|
|
|
|
TCGv tcgv_addr;
|
|
|
|
TCGv_i32 tcgv_op;
|
|
|
|
|
|
|
|
gen_set_access_type(ctx, ACCESS_CACHE);
|
|
|
|
tcgv_addr = tcg_temp_new();
|
|
|
|
tcgv_op = tcg_const_i32(ctx->opcode & 0x03FF000);
|
|
|
|
gen_addr_reg_index(ctx, tcgv_addr);
|
|
|
|
gen_helper_dcbzep(cpu_env, tcgv_addr, tcgv_op);
|
|
|
|
tcg_temp_free(tcgv_addr);
|
|
|
|
tcg_temp_free_i32(tcgv_op);
|
|
|
|
}
|
|
|
|
|
2009-01-12 22:33:02 +01:00
|
|
|
/* dst / dstt */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_dst(DisasContext *ctx)
|
2009-01-12 22:33:02 +01:00
|
|
|
{
|
|
|
|
if (rA(ctx->opcode) == 0) {
|
2016-07-27 08:56:30 +02:00
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_INVAL_INVAL);
|
2009-01-12 22:33:02 +01:00
|
|
|
} else {
|
|
|
|
/* interpreted as no-op */
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* dstst /dststt */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_dstst(DisasContext *ctx)
|
2009-01-12 22:33:02 +01:00
|
|
|
{
|
|
|
|
if (rA(ctx->opcode) == 0) {
|
2016-07-27 08:56:30 +02:00
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_INVAL_INVAL);
|
2009-01-12 22:33:02 +01:00
|
|
|
} else {
|
|
|
|
/* interpreted as no-op */
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/* dss / dssall */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_dss(DisasContext *ctx)
|
2009-01-12 22:33:02 +01:00
|
|
|
{
|
|
|
|
/* interpreted as no-op */
|
|
|
|
}
|
|
|
|
|
2003-11-23 15:55:54 +01:00
|
|
|
/* icbi */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_icbi(DisasContext *ctx)
|
2003-11-23 15:55:54 +01:00
|
|
|
{
|
2008-12-08 19:11:21 +01:00
|
|
|
TCGv t0;
|
|
|
|
gen_set_access_type(ctx, ACCESS_CACHE);
|
|
|
|
t0 = tcg_temp_new();
|
|
|
|
gen_addr_reg_index(ctx, t0);
|
2012-05-30 06:23:40 +02:00
|
|
|
gen_helper_icbi(cpu_env, t0);
|
2008-11-30 17:24:13 +01:00
|
|
|
tcg_temp_free(t0);
|
2003-11-23 15:55:54 +01:00
|
|
|
}
|
|
|
|
|
2018-09-21 08:59:07 +02:00
|
|
|
/* icbiep */
|
|
|
|
static void gen_icbiep(DisasContext *ctx)
|
|
|
|
{
|
|
|
|
TCGv t0;
|
|
|
|
gen_set_access_type(ctx, ACCESS_CACHE);
|
|
|
|
t0 = tcg_temp_new();
|
|
|
|
gen_addr_reg_index(ctx, t0);
|
|
|
|
gen_helper_icbiep(cpu_env, t0);
|
|
|
|
tcg_temp_free(t0);
|
|
|
|
}
|
|
|
|
|
2003-11-23 15:55:54 +01:00
|
|
|
/* Optional: */
|
|
|
|
/* dcba */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_dcba(DisasContext *ctx)
|
2003-11-23 15:55:54 +01:00
|
|
|
{
|
2019-03-21 12:57:28 +01:00
|
|
|
/*
|
|
|
|
* interpreted as no-op
|
|
|
|
* XXX: specification say this is treated as a store by the MMU
|
2007-09-30 05:46:38 +02:00
|
|
|
* but does not generate any exception
|
|
|
|
*/
|
2003-11-23 15:55:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*** Segment register manipulation ***/
|
|
|
|
/* Supervisor only: */
|
2009-06-17 17:22:09 +02:00
|
|
|
|
2009-06-17 17:22:19 +02:00
|
|
|
/* mfsr */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_mfsr(DisasContext *ctx)
|
2003-11-23 15:55:54 +01:00
|
|
|
{
|
2004-01-04 23:58:38 +01:00
|
|
|
#if defined(CONFIG_USER_ONLY)
|
2016-06-21 23:48:51 +02:00
|
|
|
GEN_PRIV;
|
2004-01-04 23:58:38 +01:00
|
|
|
#else
|
2008-12-06 22:46:17 +01:00
|
|
|
TCGv t0;
|
2016-06-21 23:48:51 +02:00
|
|
|
|
|
|
|
CHK_SV;
|
2008-12-06 22:46:17 +01:00
|
|
|
t0 = tcg_const_tl(SR(ctx->opcode));
|
2012-05-30 06:23:31 +02:00
|
|
|
gen_helper_load_sr(cpu_gpr[rD(ctx->opcode)], cpu_env, t0);
|
2008-12-06 22:46:17 +01:00
|
|
|
tcg_temp_free(t0);
|
2016-06-21 23:48:51 +02:00
|
|
|
#endif /* defined(CONFIG_USER_ONLY) */
|
2003-11-23 15:55:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* mfsrin */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_mfsrin(DisasContext *ctx)
|
2003-11-23 15:55:54 +01:00
|
|
|
{
|
2004-01-04 23:58:38 +01:00
|
|
|
#if defined(CONFIG_USER_ONLY)
|
2016-06-21 23:48:51 +02:00
|
|
|
GEN_PRIV;
|
2004-01-04 23:58:38 +01:00
|
|
|
#else
|
2008-12-06 22:46:17 +01:00
|
|
|
TCGv t0;
|
2016-06-21 23:48:51 +02:00
|
|
|
|
|
|
|
CHK_SV;
|
2008-12-06 22:46:17 +01:00
|
|
|
t0 = tcg_temp_new();
|
2017-07-18 06:55:35 +02:00
|
|
|
tcg_gen_extract_tl(t0, cpu_gpr[rB(ctx->opcode)], 28, 4);
|
2012-05-30 06:23:31 +02:00
|
|
|
gen_helper_load_sr(cpu_gpr[rD(ctx->opcode)], cpu_env, t0);
|
2008-12-06 22:46:17 +01:00
|
|
|
tcg_temp_free(t0);
|
2016-06-21 23:48:51 +02:00
|
|
|
#endif /* defined(CONFIG_USER_ONLY) */
|
2003-11-23 15:55:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* mtsr */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_mtsr(DisasContext *ctx)
|
2003-11-23 15:55:54 +01:00
|
|
|
{
|
2004-01-04 23:58:38 +01:00
|
|
|
#if defined(CONFIG_USER_ONLY)
|
2016-06-21 23:48:51 +02:00
|
|
|
GEN_PRIV;
|
2004-01-04 23:58:38 +01:00
|
|
|
#else
|
2008-12-06 22:46:17 +01:00
|
|
|
TCGv t0;
|
2016-06-21 23:48:51 +02:00
|
|
|
|
|
|
|
CHK_SV;
|
2008-12-06 22:46:17 +01:00
|
|
|
t0 = tcg_const_tl(SR(ctx->opcode));
|
2012-05-30 06:23:31 +02:00
|
|
|
gen_helper_store_sr(cpu_env, t0, cpu_gpr[rS(ctx->opcode)]);
|
2008-12-06 22:46:17 +01:00
|
|
|
tcg_temp_free(t0);
|
2016-06-21 23:48:51 +02:00
|
|
|
#endif /* defined(CONFIG_USER_ONLY) */
|
2003-11-23 15:55:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* mtsrin */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_mtsrin(DisasContext *ctx)
|
2003-11-23 15:55:54 +01:00
|
|
|
{
|
2004-01-04 23:58:38 +01:00
|
|
|
#if defined(CONFIG_USER_ONLY)
|
2016-06-21 23:48:51 +02:00
|
|
|
GEN_PRIV;
|
2004-01-04 23:58:38 +01:00
|
|
|
#else
|
2008-12-06 22:46:17 +01:00
|
|
|
TCGv t0;
|
2016-06-21 23:48:51 +02:00
|
|
|
CHK_SV;
|
|
|
|
|
2008-12-06 22:46:17 +01:00
|
|
|
t0 = tcg_temp_new();
|
2017-07-18 06:55:35 +02:00
|
|
|
tcg_gen_extract_tl(t0, cpu_gpr[rB(ctx->opcode)], 28, 4);
|
2012-05-30 06:23:31 +02:00
|
|
|
gen_helper_store_sr(cpu_env, t0, cpu_gpr[rD(ctx->opcode)]);
|
2008-12-06 22:46:17 +01:00
|
|
|
tcg_temp_free(t0);
|
2016-06-21 23:48:51 +02:00
|
|
|
#endif /* defined(CONFIG_USER_ONLY) */
|
2003-11-23 15:55:54 +01:00
|
|
|
}
|
|
|
|
|
2007-10-06 00:06:02 +02:00
|
|
|
#if defined(TARGET_PPC64)
|
|
|
|
/* Specific implementation for PowerPC 64 "bridge" emulation using SLB */
|
2009-06-17 17:22:14 +02:00
|
|
|
|
2009-06-17 17:22:19 +02:00
|
|
|
/* mfsr */
|
2009-06-17 17:22:14 +02:00
|
|
|
static void gen_mfsr_64b(DisasContext *ctx)
|
2007-10-06 00:06:02 +02:00
|
|
|
{
|
|
|
|
#if defined(CONFIG_USER_ONLY)
|
2016-06-21 23:48:51 +02:00
|
|
|
GEN_PRIV;
|
2007-10-06 00:06:02 +02:00
|
|
|
#else
|
2008-12-06 22:46:17 +01:00
|
|
|
TCGv t0;
|
2016-06-21 23:48:51 +02:00
|
|
|
|
|
|
|
CHK_SV;
|
2008-12-06 22:46:17 +01:00
|
|
|
t0 = tcg_const_tl(SR(ctx->opcode));
|
2012-05-30 06:23:31 +02:00
|
|
|
gen_helper_load_sr(cpu_gpr[rD(ctx->opcode)], cpu_env, t0);
|
2008-12-06 22:46:17 +01:00
|
|
|
tcg_temp_free(t0);
|
2016-06-21 23:48:51 +02:00
|
|
|
#endif /* defined(CONFIG_USER_ONLY) */
|
2007-10-06 00:06:02 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* mfsrin */
|
2009-06-17 17:22:14 +02:00
|
|
|
static void gen_mfsrin_64b(DisasContext *ctx)
|
2007-10-06 00:06:02 +02:00
|
|
|
{
|
|
|
|
#if defined(CONFIG_USER_ONLY)
|
2016-06-21 23:48:51 +02:00
|
|
|
GEN_PRIV;
|
2007-10-06 00:06:02 +02:00
|
|
|
#else
|
2008-12-06 22:46:17 +01:00
|
|
|
TCGv t0;
|
2016-06-21 23:48:51 +02:00
|
|
|
|
|
|
|
CHK_SV;
|
2008-12-06 22:46:17 +01:00
|
|
|
t0 = tcg_temp_new();
|
2017-07-18 06:55:35 +02:00
|
|
|
tcg_gen_extract_tl(t0, cpu_gpr[rB(ctx->opcode)], 28, 4);
|
2012-05-30 06:23:31 +02:00
|
|
|
gen_helper_load_sr(cpu_gpr[rD(ctx->opcode)], cpu_env, t0);
|
2008-12-06 22:46:17 +01:00
|
|
|
tcg_temp_free(t0);
|
2016-06-21 23:48:51 +02:00
|
|
|
#endif /* defined(CONFIG_USER_ONLY) */
|
2007-10-06 00:06:02 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* mtsr */
|
2009-06-17 17:22:14 +02:00
|
|
|
static void gen_mtsr_64b(DisasContext *ctx)
|
2007-10-06 00:06:02 +02:00
|
|
|
{
|
|
|
|
#if defined(CONFIG_USER_ONLY)
|
2016-06-21 23:48:51 +02:00
|
|
|
GEN_PRIV;
|
2007-10-06 00:06:02 +02:00
|
|
|
#else
|
2008-12-06 22:46:17 +01:00
|
|
|
TCGv t0;
|
2016-06-21 23:48:51 +02:00
|
|
|
|
|
|
|
CHK_SV;
|
2008-12-06 22:46:17 +01:00
|
|
|
t0 = tcg_const_tl(SR(ctx->opcode));
|
2012-05-30 06:23:31 +02:00
|
|
|
gen_helper_store_sr(cpu_env, t0, cpu_gpr[rS(ctx->opcode)]);
|
2008-12-06 22:46:17 +01:00
|
|
|
tcg_temp_free(t0);
|
2016-06-21 23:48:51 +02:00
|
|
|
#endif /* defined(CONFIG_USER_ONLY) */
|
2007-10-06 00:06:02 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* mtsrin */
|
2009-06-17 17:22:14 +02:00
|
|
|
static void gen_mtsrin_64b(DisasContext *ctx)
|
2007-10-06 00:06:02 +02:00
|
|
|
{
|
|
|
|
#if defined(CONFIG_USER_ONLY)
|
2016-06-21 23:48:51 +02:00
|
|
|
GEN_PRIV;
|
2007-10-06 00:06:02 +02:00
|
|
|
#else
|
2008-12-06 22:46:17 +01:00
|
|
|
TCGv t0;
|
2016-06-21 23:48:51 +02:00
|
|
|
|
|
|
|
CHK_SV;
|
2008-12-06 22:46:17 +01:00
|
|
|
t0 = tcg_temp_new();
|
2017-07-18 06:55:35 +02:00
|
|
|
tcg_gen_extract_tl(t0, cpu_gpr[rB(ctx->opcode)], 28, 4);
|
2012-05-30 06:23:31 +02:00
|
|
|
gen_helper_store_sr(cpu_env, t0, cpu_gpr[rS(ctx->opcode)]);
|
2008-12-06 22:46:17 +01:00
|
|
|
tcg_temp_free(t0);
|
2016-06-21 23:48:51 +02:00
|
|
|
#endif /* defined(CONFIG_USER_ONLY) */
|
2007-10-06 00:06:02 +02:00
|
|
|
}
|
2009-03-07 21:50:01 +01:00
|
|
|
|
|
|
|
/* slbmte */
|
2009-06-17 17:22:14 +02:00
|
|
|
static void gen_slbmte(DisasContext *ctx)
|
2009-03-07 21:50:01 +01:00
|
|
|
{
|
|
|
|
#if defined(CONFIG_USER_ONLY)
|
2016-06-21 23:48:51 +02:00
|
|
|
GEN_PRIV;
|
2009-03-07 21:50:01 +01:00
|
|
|
#else
|
2016-06-21 23:48:51 +02:00
|
|
|
CHK_SV;
|
|
|
|
|
2012-05-30 06:23:31 +02:00
|
|
|
gen_helper_store_slb(cpu_env, cpu_gpr[rB(ctx->opcode)],
|
|
|
|
cpu_gpr[rS(ctx->opcode)]);
|
2016-06-21 23:48:51 +02:00
|
|
|
#endif /* defined(CONFIG_USER_ONLY) */
|
2009-03-07 21:50:01 +01:00
|
|
|
}
|
|
|
|
|
2011-04-01 06:15:11 +02:00
|
|
|
static void gen_slbmfee(DisasContext *ctx)
|
|
|
|
{
|
|
|
|
#if defined(CONFIG_USER_ONLY)
|
2016-06-21 23:48:51 +02:00
|
|
|
GEN_PRIV;
|
2011-04-01 06:15:11 +02:00
|
|
|
#else
|
2016-06-21 23:48:51 +02:00
|
|
|
CHK_SV;
|
|
|
|
|
2012-05-30 06:23:31 +02:00
|
|
|
gen_helper_load_slb_esid(cpu_gpr[rS(ctx->opcode)], cpu_env,
|
2011-04-01 06:15:11 +02:00
|
|
|
cpu_gpr[rB(ctx->opcode)]);
|
2016-06-21 23:48:51 +02:00
|
|
|
#endif /* defined(CONFIG_USER_ONLY) */
|
2011-04-01 06:15:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void gen_slbmfev(DisasContext *ctx)
|
|
|
|
{
|
|
|
|
#if defined(CONFIG_USER_ONLY)
|
2016-06-21 23:48:51 +02:00
|
|
|
GEN_PRIV;
|
2011-04-01 06:15:11 +02:00
|
|
|
#else
|
2016-06-21 23:48:51 +02:00
|
|
|
CHK_SV;
|
|
|
|
|
2012-05-30 06:23:31 +02:00
|
|
|
gen_helper_load_slb_vsid(cpu_gpr[rS(ctx->opcode)], cpu_env,
|
2011-04-01 06:15:11 +02:00
|
|
|
cpu_gpr[rB(ctx->opcode)]);
|
2016-06-21 23:48:51 +02:00
|
|
|
#endif /* defined(CONFIG_USER_ONLY) */
|
2011-04-01 06:15:11 +02:00
|
|
|
}
|
2016-06-07 04:50:27 +02: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);
|
2016-11-23 12:37:11 +01:00
|
|
|
tcg_gen_ori_i32(cpu_crf[0], cpu_crf[0], CRF_EQ);
|
2016-06-07 04:50:27 +02:00
|
|
|
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 00:06:02 +02:00
|
|
|
#endif /* defined(TARGET_PPC64) */
|
|
|
|
|
2003-11-23 15:55:54 +01:00
|
|
|
/*** Lookaside buffer management ***/
|
2014-09-15 17:03:28 +02:00
|
|
|
/* Optional & supervisor only: */
|
2009-06-17 17:22:09 +02:00
|
|
|
|
2009-06-17 17:22:19 +02:00
|
|
|
/* tlbia */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_tlbia(DisasContext *ctx)
|
2003-11-23 15:55:54 +01:00
|
|
|
{
|
2004-01-04 23:58:38 +01:00
|
|
|
#if defined(CONFIG_USER_ONLY)
|
2016-06-21 23:48:51 +02:00
|
|
|
GEN_PRIV;
|
2004-01-04 23:58:38 +01:00
|
|
|
#else
|
2016-06-21 23:48:51 +02:00
|
|
|
CHK_HV;
|
|
|
|
|
2012-05-30 06:23:31 +02:00
|
|
|
gen_helper_tlbia(cpu_env);
|
2016-06-21 23:48:51 +02:00
|
|
|
#endif /* defined(CONFIG_USER_ONLY) */
|
2003-11-23 15:55:54 +01:00
|
|
|
}
|
|
|
|
|
2009-03-07 21:52:22 +01:00
|
|
|
/* tlbiel */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_tlbiel(DisasContext *ctx)
|
2009-03-07 21:52:22 +01:00
|
|
|
{
|
|
|
|
#if defined(CONFIG_USER_ONLY)
|
2016-06-21 23:48:51 +02:00
|
|
|
GEN_PRIV;
|
2009-03-07 21:52:22 +01:00
|
|
|
#else
|
2016-06-21 23:48:51 +02:00
|
|
|
CHK_SV;
|
|
|
|
|
2012-05-30 06:23:31 +02:00
|
|
|
gen_helper_tlbie(cpu_env, cpu_gpr[rB(ctx->opcode)]);
|
2016-06-21 23:48:51 +02:00
|
|
|
#endif /* defined(CONFIG_USER_ONLY) */
|
2009-03-07 21:52:22 +01:00
|
|
|
}
|
|
|
|
|
2003-11-23 15:55:54 +01:00
|
|
|
/* tlbie */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_tlbie(DisasContext *ctx)
|
2003-11-23 15:55:54 +01:00
|
|
|
{
|
2004-01-04 23:58:38 +01:00
|
|
|
#if defined(CONFIG_USER_ONLY)
|
2016-06-21 23:48:51 +02:00
|
|
|
GEN_PRIV;
|
2004-01-04 23:58:38 +01:00
|
|
|
#else
|
2016-09-20 18:35:01 +02:00
|
|
|
TCGv_i32 t1;
|
2017-05-02 08:37:15 +02:00
|
|
|
|
|
|
|
if (ctx->gtse) {
|
2018-03-14 18:33:36 +01:00
|
|
|
CHK_SV; /* If gtse is set then tlbie is supervisor privileged */
|
2017-05-02 08:37:15 +02:00
|
|
|
} else {
|
|
|
|
CHK_HV; /* Else hypervisor privileged */
|
|
|
|
}
|
2016-06-21 23:48:51 +02:00
|
|
|
|
2013-03-21 11:01:49 +01:00
|
|
|
if (NARROW_MODE(ctx)) {
|
2008-12-06 22:46:17 +01:00
|
|
|
TCGv t0 = tcg_temp_new();
|
|
|
|
tcg_gen_ext32u_tl(t0, cpu_gpr[rB(ctx->opcode)]);
|
2012-05-30 06:23:31 +02:00
|
|
|
gen_helper_tlbie(cpu_env, t0);
|
2008-12-06 22:46:17 +01:00
|
|
|
tcg_temp_free(t0);
|
2013-03-21 11:01:49 +01:00
|
|
|
} else {
|
2012-05-30 06:23:31 +02:00
|
|
|
gen_helper_tlbie(cpu_env, cpu_gpr[rB(ctx->opcode)]);
|
2013-03-21 11:01:49 +01:00
|
|
|
}
|
2016-09-20 18:35:01 +02:00
|
|
|
t1 = tcg_temp_new_i32();
|
|
|
|
tcg_gen_ld_i32(t1, cpu_env, offsetof(CPUPPCState, tlb_need_flush));
|
|
|
|
tcg_gen_ori_i32(t1, t1, TLB_NEED_GLOBAL_FLUSH);
|
|
|
|
tcg_gen_st_i32(t1, cpu_env, offsetof(CPUPPCState, tlb_need_flush));
|
|
|
|
tcg_temp_free_i32(t1);
|
2016-06-21 23:48:51 +02:00
|
|
|
#endif /* defined(CONFIG_USER_ONLY) */
|
2003-11-23 15:55:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* tlbsync */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_tlbsync(DisasContext *ctx)
|
2003-11-23 15:55:54 +01:00
|
|
|
{
|
2004-01-04 23:58:38 +01:00
|
|
|
#if defined(CONFIG_USER_ONLY)
|
2016-06-21 23:48:51 +02:00
|
|
|
GEN_PRIV;
|
2004-01-04 23:58:38 +01:00
|
|
|
#else
|
2018-03-14 18:33:36 +01:00
|
|
|
|
|
|
|
if (ctx->gtse) {
|
|
|
|
CHK_SV; /* If gtse is set then tlbsync is supervisor privileged */
|
|
|
|
} else {
|
|
|
|
CHK_HV; /* Else hypervisor privileged */
|
|
|
|
}
|
2016-06-21 23:48:51 +02:00
|
|
|
|
2016-09-20 18:35:00 +02:00
|
|
|
/* BookS does both ptesync and tlbsync make tlbsync a nop for server */
|
|
|
|
if (ctx->insns_flags & PPC_BOOKE) {
|
|
|
|
gen_check_tlb_flush(ctx, true);
|
|
|
|
}
|
2016-06-21 23:48:51 +02:00
|
|
|
#endif /* defined(CONFIG_USER_ONLY) */
|
2003-11-23 15:55:54 +01:00
|
|
|
}
|
|
|
|
|
2007-03-23 10:45:27 +01:00
|
|
|
#if defined(TARGET_PPC64)
|
|
|
|
/* slbia */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_slbia(DisasContext *ctx)
|
2007-03-23 10:45:27 +01:00
|
|
|
{
|
|
|
|
#if defined(CONFIG_USER_ONLY)
|
2016-06-21 23:48:51 +02:00
|
|
|
GEN_PRIV;
|
2007-03-23 10:45:27 +01:00
|
|
|
#else
|
2020-03-19 07:44:39 +01:00
|
|
|
uint32_t ih = (ctx->opcode >> 21) & 0x7;
|
|
|
|
TCGv_i32 t0 = tcg_const_i32(ih);
|
|
|
|
|
2016-06-21 23:48:51 +02:00
|
|
|
CHK_SV;
|
|
|
|
|
2020-03-19 07:44:39 +01:00
|
|
|
gen_helper_slbia(cpu_env, t0);
|
2020-04-17 11:07:49 +02:00
|
|
|
tcg_temp_free_i32(t0);
|
2016-06-21 23:48:51 +02:00
|
|
|
#endif /* defined(CONFIG_USER_ONLY) */
|
2007-03-23 10:45:27 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* slbie */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_slbie(DisasContext *ctx)
|
2007-03-23 10:45:27 +01:00
|
|
|
{
|
|
|
|
#if defined(CONFIG_USER_ONLY)
|
2016-06-21 23:48:51 +02:00
|
|
|
GEN_PRIV;
|
2007-03-23 10:45:27 +01:00
|
|
|
#else
|
2016-06-21 23:48:51 +02:00
|
|
|
CHK_SV;
|
|
|
|
|
2012-05-30 06:23:31 +02:00
|
|
|
gen_helper_slbie(cpu_env, cpu_gpr[rB(ctx->opcode)]);
|
2016-06-21 23:48:51 +02:00
|
|
|
#endif /* defined(CONFIG_USER_ONLY) */
|
2007-03-23 10:45:27 +01:00
|
|
|
}
|
2017-02-09 11:34:01 +01:00
|
|
|
|
|
|
|
/* slbieg */
|
|
|
|
static void gen_slbieg(DisasContext *ctx)
|
|
|
|
{
|
|
|
|
#if defined(CONFIG_USER_ONLY)
|
|
|
|
GEN_PRIV;
|
|
|
|
#else
|
|
|
|
CHK_SV;
|
|
|
|
|
|
|
|
gen_helper_slbieg(cpu_env, cpu_gpr[rB(ctx->opcode)]);
|
|
|
|
#endif /* defined(CONFIG_USER_ONLY) */
|
|
|
|
}
|
|
|
|
|
2017-02-09 11:34:02 +01:00
|
|
|
/* slbsync */
|
|
|
|
static void gen_slbsync(DisasContext *ctx)
|
|
|
|
{
|
|
|
|
#if defined(CONFIG_USER_ONLY)
|
|
|
|
GEN_PRIV;
|
|
|
|
#else
|
|
|
|
CHK_SV;
|
|
|
|
gen_check_tlb_flush(ctx, true);
|
|
|
|
#endif /* defined(CONFIG_USER_ONLY) */
|
|
|
|
}
|
|
|
|
|
2016-06-21 23:48:51 +02:00
|
|
|
#endif /* defined(TARGET_PPC64) */
|
2007-03-23 10:45:27 +01:00
|
|
|
|
2003-11-23 15:55:54 +01:00
|
|
|
/*** External control ***/
|
|
|
|
/* Optional: */
|
2009-06-17 17:22:09 +02:00
|
|
|
|
2009-06-17 17:22:19 +02:00
|
|
|
/* eciwx */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_eciwx(DisasContext *ctx)
|
2003-11-23 15:55:54 +01:00
|
|
|
{
|
2008-12-08 19:11:21 +01:00
|
|
|
TCGv t0;
|
2008-11-30 17:24:47 +01:00
|
|
|
/* Should check EAR[E] ! */
|
2008-12-08 19:11:21 +01:00
|
|
|
gen_set_access_type(ctx, ACCESS_EXT);
|
|
|
|
t0 = tcg_temp_new();
|
|
|
|
gen_addr_reg_index(ctx, t0);
|
2018-06-26 18:19:18 +02:00
|
|
|
tcg_gen_qemu_ld_tl(cpu_gpr[rD(ctx->opcode)], t0, ctx->mem_idx,
|
|
|
|
DEF_MEMOP(MO_UL | MO_ALIGN));
|
2008-11-30 17:24:47 +01:00
|
|
|
tcg_temp_free(t0);
|
2007-03-07 09:32:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ecowx */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_ecowx(DisasContext *ctx)
|
2007-03-07 09:32:30 +01:00
|
|
|
{
|
2008-12-08 19:11:21 +01:00
|
|
|
TCGv t0;
|
2008-11-30 17:24:47 +01:00
|
|
|
/* Should check EAR[E] ! */
|
2008-12-08 19:11:21 +01:00
|
|
|
gen_set_access_type(ctx, ACCESS_EXT);
|
|
|
|
t0 = tcg_temp_new();
|
|
|
|
gen_addr_reg_index(ctx, t0);
|
2018-06-26 18:19:18 +02:00
|
|
|
tcg_gen_qemu_st_tl(cpu_gpr[rD(ctx->opcode)], t0, ctx->mem_idx,
|
|
|
|
DEF_MEMOP(MO_UL | MO_ALIGN));
|
2008-11-30 17:24:47 +01:00
|
|
|
tcg_temp_free(t0);
|
2007-03-07 09:32:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* PowerPC 601 specific instructions */
|
2009-06-17 17:22:09 +02:00
|
|
|
|
2009-06-17 17:22:19 +02:00
|
|
|
/* abs - abs. */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_abs(DisasContext *ctx)
|
2007-03-07 09:32:30 +01:00
|
|
|
{
|
2019-04-18 02:45:47 +02:00
|
|
|
TCGv d = cpu_gpr[rD(ctx->opcode)];
|
|
|
|
TCGv a = cpu_gpr[rA(ctx->opcode)];
|
|
|
|
|
|
|
|
tcg_gen_abs_tl(d, a);
|
2019-03-21 12:57:28 +01:00
|
|
|
if (unlikely(Rc(ctx->opcode) != 0)) {
|
2019-04-18 02:45:47 +02:00
|
|
|
gen_set_Rc0(ctx, d);
|
2019-03-21 12:57:28 +01:00
|
|
|
}
|
2007-03-07 09:32:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* abso - abso. */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_abso(DisasContext *ctx)
|
2007-03-07 09:32:30 +01:00
|
|
|
{
|
2019-04-18 02:45:47 +02:00
|
|
|
TCGv d = cpu_gpr[rD(ctx->opcode)];
|
|
|
|
TCGv a = cpu_gpr[rA(ctx->opcode)];
|
|
|
|
|
|
|
|
tcg_gen_setcondi_tl(TCG_COND_EQ, cpu_ov, a, 0x80000000);
|
|
|
|
tcg_gen_abs_tl(d, a);
|
|
|
|
tcg_gen_or_tl(cpu_so, cpu_so, cpu_ov);
|
2019-03-21 12:57:28 +01:00
|
|
|
if (unlikely(Rc(ctx->opcode) != 0)) {
|
2019-04-18 02:45:47 +02:00
|
|
|
gen_set_Rc0(ctx, d);
|
2019-03-21 12:57:28 +01:00
|
|
|
}
|
2007-03-07 09:32:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* clcs */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_clcs(DisasContext *ctx)
|
2007-03-07 09:32:30 +01:00
|
|
|
{
|
2008-12-06 13:19:14 +01:00
|
|
|
TCGv_i32 t0 = tcg_const_i32(rA(ctx->opcode));
|
2012-05-30 06:23:38 +02:00
|
|
|
gen_helper_clcs(cpu_gpr[rD(ctx->opcode)], cpu_env, t0);
|
2008-12-06 13:19:14 +01:00
|
|
|
tcg_temp_free_i32(t0);
|
2007-10-26 02:46:07 +02:00
|
|
|
/* Rc=1 sets CR0 to an undefined state */
|
2007-03-07 09:32:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* div - div. */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_div(DisasContext *ctx)
|
2007-03-07 09:32:30 +01:00
|
|
|
{
|
2012-05-30 06:23:29 +02:00
|
|
|
gen_helper_div(cpu_gpr[rD(ctx->opcode)], cpu_env, cpu_gpr[rA(ctx->opcode)],
|
|
|
|
cpu_gpr[rB(ctx->opcode)]);
|
2019-03-21 12:57:28 +01:00
|
|
|
if (unlikely(Rc(ctx->opcode) != 0)) {
|
2008-12-06 13:19:14 +01:00
|
|
|
gen_set_Rc0(ctx, cpu_gpr[rD(ctx->opcode)]);
|
2019-03-21 12:57:28 +01:00
|
|
|
}
|
2007-03-07 09:32:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* divo - divo. */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_divo(DisasContext *ctx)
|
2007-03-07 09:32:30 +01:00
|
|
|
{
|
2012-05-30 06:23:29 +02:00
|
|
|
gen_helper_divo(cpu_gpr[rD(ctx->opcode)], cpu_env, cpu_gpr[rA(ctx->opcode)],
|
|
|
|
cpu_gpr[rB(ctx->opcode)]);
|
2019-03-21 12:57:28 +01:00
|
|
|
if (unlikely(Rc(ctx->opcode) != 0)) {
|
2008-12-06 13:19:14 +01:00
|
|
|
gen_set_Rc0(ctx, cpu_gpr[rD(ctx->opcode)]);
|
2019-03-21 12:57:28 +01:00
|
|
|
}
|
2007-03-07 09:32:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* divs - divs. */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_divs(DisasContext *ctx)
|
2007-03-07 09:32:30 +01:00
|
|
|
{
|
2012-05-30 06:23:29 +02:00
|
|
|
gen_helper_divs(cpu_gpr[rD(ctx->opcode)], cpu_env, cpu_gpr[rA(ctx->opcode)],
|
|
|
|
cpu_gpr[rB(ctx->opcode)]);
|
2019-03-21 12:57:28 +01:00
|
|
|
if (unlikely(Rc(ctx->opcode) != 0)) {
|
2008-12-06 13:19:14 +01:00
|
|
|
gen_set_Rc0(ctx, cpu_gpr[rD(ctx->opcode)]);
|
2019-03-21 12:57:28 +01:00
|
|
|
}
|
2007-03-07 09:32:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* divso - divso. */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_divso(DisasContext *ctx)
|
2007-03-07 09:32:30 +01:00
|
|
|
{
|
2012-05-30 06:23:29 +02:00
|
|
|
gen_helper_divso(cpu_gpr[rD(ctx->opcode)], cpu_env,
|
|
|
|
cpu_gpr[rA(ctx->opcode)], cpu_gpr[rB(ctx->opcode)]);
|
2019-03-21 12:57:28 +01:00
|
|
|
if (unlikely(Rc(ctx->opcode) != 0)) {
|
2008-12-06 13:19:14 +01:00
|
|
|
gen_set_Rc0(ctx, cpu_gpr[rD(ctx->opcode)]);
|
2019-03-21 12:57:28 +01:00
|
|
|
}
|
2007-03-07 09:32:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* doz - doz. */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_doz(DisasContext *ctx)
|
2007-03-07 09:32:30 +01:00
|
|
|
{
|
2015-02-13 21:51:55 +01:00
|
|
|
TCGLabel *l1 = gen_new_label();
|
|
|
|
TCGLabel *l2 = gen_new_label();
|
2019-03-21 12:57:28 +01:00
|
|
|
tcg_gen_brcond_tl(TCG_COND_GE, cpu_gpr[rB(ctx->opcode)],
|
|
|
|
cpu_gpr[rA(ctx->opcode)], l1);
|
|
|
|
tcg_gen_sub_tl(cpu_gpr[rD(ctx->opcode)], cpu_gpr[rB(ctx->opcode)],
|
|
|
|
cpu_gpr[rA(ctx->opcode)]);
|
2008-12-06 13:19:14 +01:00
|
|
|
tcg_gen_br(l2);
|
|
|
|
gen_set_label(l1);
|
|
|
|
tcg_gen_movi_tl(cpu_gpr[rD(ctx->opcode)], 0);
|
|
|
|
gen_set_label(l2);
|
2019-03-21 12:57:28 +01:00
|
|
|
if (unlikely(Rc(ctx->opcode) != 0)) {
|
2008-12-06 13:19:14 +01:00
|
|
|
gen_set_Rc0(ctx, cpu_gpr[rD(ctx->opcode)]);
|
2019-03-21 12:57:28 +01:00
|
|
|
}
|
2007-03-07 09:32:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* dozo - dozo. */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_dozo(DisasContext *ctx)
|
2007-03-07 09:32:30 +01:00
|
|
|
{
|
2015-02-13 21:51:55 +01:00
|
|
|
TCGLabel *l1 = gen_new_label();
|
|
|
|
TCGLabel *l2 = gen_new_label();
|
2008-12-06 13:19:14 +01:00
|
|
|
TCGv t0 = tcg_temp_new();
|
|
|
|
TCGv t1 = tcg_temp_new();
|
|
|
|
TCGv t2 = tcg_temp_new();
|
|
|
|
/* Start with XER OV disabled, the most likely case */
|
2013-02-20 08:52:13 +01:00
|
|
|
tcg_gen_movi_tl(cpu_ov, 0);
|
2019-03-21 12:57:28 +01:00
|
|
|
tcg_gen_brcond_tl(TCG_COND_GE, cpu_gpr[rB(ctx->opcode)],
|
|
|
|
cpu_gpr[rA(ctx->opcode)], l1);
|
2008-12-06 13:19:14 +01:00
|
|
|
tcg_gen_sub_tl(t0, cpu_gpr[rB(ctx->opcode)], cpu_gpr[rA(ctx->opcode)]);
|
|
|
|
tcg_gen_xor_tl(t1, cpu_gpr[rB(ctx->opcode)], cpu_gpr[rA(ctx->opcode)]);
|
|
|
|
tcg_gen_xor_tl(t2, cpu_gpr[rA(ctx->opcode)], t0);
|
|
|
|
tcg_gen_andc_tl(t1, t1, t2);
|
|
|
|
tcg_gen_mov_tl(cpu_gpr[rD(ctx->opcode)], t0);
|
|
|
|
tcg_gen_brcondi_tl(TCG_COND_GE, t1, 0, l2);
|
2013-02-20 08:52:13 +01:00
|
|
|
tcg_gen_movi_tl(cpu_ov, 1);
|
|
|
|
tcg_gen_movi_tl(cpu_so, 1);
|
2008-12-06 13:19:14 +01:00
|
|
|
tcg_gen_br(l2);
|
|
|
|
gen_set_label(l1);
|
|
|
|
tcg_gen_movi_tl(cpu_gpr[rD(ctx->opcode)], 0);
|
|
|
|
gen_set_label(l2);
|
|
|
|
tcg_temp_free(t0);
|
|
|
|
tcg_temp_free(t1);
|
|
|
|
tcg_temp_free(t2);
|
2019-03-21 12:57:28 +01:00
|
|
|
if (unlikely(Rc(ctx->opcode) != 0)) {
|
2008-12-06 13:19:14 +01:00
|
|
|
gen_set_Rc0(ctx, cpu_gpr[rD(ctx->opcode)]);
|
2019-03-21 12:57:28 +01:00
|
|
|
}
|
2007-03-07 09:32:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* dozi */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_dozi(DisasContext *ctx)
|
2007-03-07 09:32:30 +01:00
|
|
|
{
|
2008-12-06 13:19:14 +01:00
|
|
|
target_long simm = SIMM(ctx->opcode);
|
2015-02-13 21:51:55 +01:00
|
|
|
TCGLabel *l1 = gen_new_label();
|
|
|
|
TCGLabel *l2 = gen_new_label();
|
2008-12-06 13:19:14 +01:00
|
|
|
tcg_gen_brcondi_tl(TCG_COND_LT, cpu_gpr[rA(ctx->opcode)], simm, l1);
|
|
|
|
tcg_gen_subfi_tl(cpu_gpr[rD(ctx->opcode)], simm, cpu_gpr[rA(ctx->opcode)]);
|
|
|
|
tcg_gen_br(l2);
|
|
|
|
gen_set_label(l1);
|
|
|
|
tcg_gen_movi_tl(cpu_gpr[rD(ctx->opcode)], 0);
|
|
|
|
gen_set_label(l2);
|
2019-03-21 12:57:28 +01:00
|
|
|
if (unlikely(Rc(ctx->opcode) != 0)) {
|
2008-12-06 13:19:14 +01:00
|
|
|
gen_set_Rc0(ctx, cpu_gpr[rD(ctx->opcode)]);
|
2019-03-21 12:57:28 +01:00
|
|
|
}
|
2007-03-07 09:32:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* lscbx - lscbx. */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_lscbx(DisasContext *ctx)
|
2007-03-07 09:32:30 +01:00
|
|
|
{
|
2008-11-30 17:24:30 +01:00
|
|
|
TCGv t0 = tcg_temp_new();
|
|
|
|
TCGv_i32 t1 = tcg_const_i32(rD(ctx->opcode));
|
|
|
|
TCGv_i32 t2 = tcg_const_i32(rA(ctx->opcode));
|
|
|
|
TCGv_i32 t3 = tcg_const_i32(rB(ctx->opcode));
|
2007-03-07 09:32:30 +01:00
|
|
|
|
2008-12-08 19:11:21 +01:00
|
|
|
gen_addr_reg_index(ctx, t0);
|
2012-05-30 06:23:40 +02:00
|
|
|
gen_helper_lscbx(t0, cpu_env, t0, t1, t2, t3);
|
2008-11-30 17:24:30 +01:00
|
|
|
tcg_temp_free_i32(t1);
|
|
|
|
tcg_temp_free_i32(t2);
|
|
|
|
tcg_temp_free_i32(t3);
|
2008-10-21 13:28:46 +02:00
|
|
|
tcg_gen_andi_tl(cpu_xer, cpu_xer, ~0x7F);
|
2008-11-30 17:24:30 +01:00
|
|
|
tcg_gen_or_tl(cpu_xer, cpu_xer, t0);
|
2019-03-21 12:57:28 +01:00
|
|
|
if (unlikely(Rc(ctx->opcode) != 0)) {
|
2008-11-30 17:24:30 +01:00
|
|
|
gen_set_Rc0(ctx, t0);
|
2019-03-21 12:57:28 +01:00
|
|
|
}
|
2008-11-30 17:24:30 +01:00
|
|
|
tcg_temp_free(t0);
|
2007-03-07 09:32:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* maskg - maskg. */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_maskg(DisasContext *ctx)
|
2007-03-07 09:32:30 +01:00
|
|
|
{
|
2015-02-13 21:51:55 +01:00
|
|
|
TCGLabel *l1 = gen_new_label();
|
2008-12-06 13:19:14 +01:00
|
|
|
TCGv t0 = tcg_temp_new();
|
|
|
|
TCGv t1 = tcg_temp_new();
|
|
|
|
TCGv t2 = tcg_temp_new();
|
|
|
|
TCGv t3 = tcg_temp_new();
|
|
|
|
tcg_gen_movi_tl(t3, 0xFFFFFFFF);
|
|
|
|
tcg_gen_andi_tl(t0, cpu_gpr[rB(ctx->opcode)], 0x1F);
|
|
|
|
tcg_gen_andi_tl(t1, cpu_gpr[rS(ctx->opcode)], 0x1F);
|
|
|
|
tcg_gen_addi_tl(t2, t0, 1);
|
|
|
|
tcg_gen_shr_tl(t2, t3, t2);
|
|
|
|
tcg_gen_shr_tl(t3, t3, t1);
|
|
|
|
tcg_gen_xor_tl(cpu_gpr[rA(ctx->opcode)], t2, t3);
|
|
|
|
tcg_gen_brcond_tl(TCG_COND_GE, t0, t1, l1);
|
|
|
|
tcg_gen_neg_tl(cpu_gpr[rA(ctx->opcode)], cpu_gpr[rA(ctx->opcode)]);
|
|
|
|
gen_set_label(l1);
|
|
|
|
tcg_temp_free(t0);
|
|
|
|
tcg_temp_free(t1);
|
|
|
|
tcg_temp_free(t2);
|
|
|
|
tcg_temp_free(t3);
|
2019-03-21 12:57:28 +01:00
|
|
|
if (unlikely(Rc(ctx->opcode) != 0)) {
|
2008-12-06 13:19:14 +01:00
|
|
|
gen_set_Rc0(ctx, cpu_gpr[rA(ctx->opcode)]);
|
2019-03-21 12:57:28 +01:00
|
|
|
}
|
2007-03-07 09:32:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* maskir - maskir. */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_maskir(DisasContext *ctx)
|
2007-03-07 09:32:30 +01:00
|
|
|
{
|
2008-12-06 13:19:14 +01:00
|
|
|
TCGv t0 = tcg_temp_new();
|
|
|
|
TCGv t1 = tcg_temp_new();
|
|
|
|
tcg_gen_and_tl(t0, cpu_gpr[rS(ctx->opcode)], cpu_gpr[rB(ctx->opcode)]);
|
|
|
|
tcg_gen_andc_tl(t1, cpu_gpr[rA(ctx->opcode)], cpu_gpr[rB(ctx->opcode)]);
|
|
|
|
tcg_gen_or_tl(cpu_gpr[rA(ctx->opcode)], t0, t1);
|
|
|
|
tcg_temp_free(t0);
|
|
|
|
tcg_temp_free(t1);
|
2019-03-21 12:57:28 +01:00
|
|
|
if (unlikely(Rc(ctx->opcode) != 0)) {
|
2008-12-06 13:19:14 +01:00
|
|
|
gen_set_Rc0(ctx, cpu_gpr[rA(ctx->opcode)]);
|
2019-03-21 12:57:28 +01:00
|
|
|
}
|
2007-03-07 09:32:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* mul - mul. */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_mul(DisasContext *ctx)
|
2007-03-07 09:32:30 +01:00
|
|
|
{
|
2008-12-06 13:19:14 +01:00
|
|
|
TCGv_i64 t0 = tcg_temp_new_i64();
|
|
|
|
TCGv_i64 t1 = tcg_temp_new_i64();
|
|
|
|
TCGv t2 = tcg_temp_new();
|
|
|
|
tcg_gen_extu_tl_i64(t0, cpu_gpr[rA(ctx->opcode)]);
|
|
|
|
tcg_gen_extu_tl_i64(t1, cpu_gpr[rB(ctx->opcode)]);
|
|
|
|
tcg_gen_mul_i64(t0, t0, t1);
|
|
|
|
tcg_gen_trunc_i64_tl(t2, t0);
|
|
|
|
gen_store_spr(SPR_MQ, t2);
|
|
|
|
tcg_gen_shri_i64(t1, t0, 32);
|
|
|
|
tcg_gen_trunc_i64_tl(cpu_gpr[rD(ctx->opcode)], t1);
|
|
|
|
tcg_temp_free_i64(t0);
|
|
|
|
tcg_temp_free_i64(t1);
|
|
|
|
tcg_temp_free(t2);
|
2019-03-21 12:57:28 +01:00
|
|
|
if (unlikely(Rc(ctx->opcode) != 0)) {
|
2008-12-06 13:19:14 +01:00
|
|
|
gen_set_Rc0(ctx, cpu_gpr[rD(ctx->opcode)]);
|
2019-03-21 12:57:28 +01:00
|
|
|
}
|
2007-03-07 09:32:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* mulo - mulo. */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_mulo(DisasContext *ctx)
|
2007-03-07 09:32:30 +01:00
|
|
|
{
|
2015-02-13 21:51:55 +01:00
|
|
|
TCGLabel *l1 = gen_new_label();
|
2008-12-06 13:19:14 +01:00
|
|
|
TCGv_i64 t0 = tcg_temp_new_i64();
|
|
|
|
TCGv_i64 t1 = tcg_temp_new_i64();
|
|
|
|
TCGv t2 = tcg_temp_new();
|
|
|
|
/* Start with XER OV disabled, the most likely case */
|
2013-02-20 08:52:13 +01:00
|
|
|
tcg_gen_movi_tl(cpu_ov, 0);
|
2008-12-06 13:19:14 +01:00
|
|
|
tcg_gen_extu_tl_i64(t0, cpu_gpr[rA(ctx->opcode)]);
|
|
|
|
tcg_gen_extu_tl_i64(t1, cpu_gpr[rB(ctx->opcode)]);
|
|
|
|
tcg_gen_mul_i64(t0, t0, t1);
|
|
|
|
tcg_gen_trunc_i64_tl(t2, t0);
|
|
|
|
gen_store_spr(SPR_MQ, t2);
|
|
|
|
tcg_gen_shri_i64(t1, t0, 32);
|
|
|
|
tcg_gen_trunc_i64_tl(cpu_gpr[rD(ctx->opcode)], t1);
|
|
|
|
tcg_gen_ext32s_i64(t1, t0);
|
|
|
|
tcg_gen_brcond_i64(TCG_COND_EQ, t0, t1, l1);
|
2013-02-20 08:52:13 +01:00
|
|
|
tcg_gen_movi_tl(cpu_ov, 1);
|
|
|
|
tcg_gen_movi_tl(cpu_so, 1);
|
2008-12-06 13:19:14 +01:00
|
|
|
gen_set_label(l1);
|
|
|
|
tcg_temp_free_i64(t0);
|
|
|
|
tcg_temp_free_i64(t1);
|
|
|
|
tcg_temp_free(t2);
|
2019-03-21 12:57:28 +01:00
|
|
|
if (unlikely(Rc(ctx->opcode) != 0)) {
|
2008-12-06 13:19:14 +01:00
|
|
|
gen_set_Rc0(ctx, cpu_gpr[rD(ctx->opcode)]);
|
2019-03-21 12:57:28 +01:00
|
|
|
}
|
2007-03-07 09:32:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* nabs - nabs. */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_nabs(DisasContext *ctx)
|
2007-03-07 09:32:30 +01:00
|
|
|
{
|
2019-04-18 02:45:47 +02:00
|
|
|
TCGv d = cpu_gpr[rD(ctx->opcode)];
|
|
|
|
TCGv a = cpu_gpr[rA(ctx->opcode)];
|
|
|
|
|
|
|
|
tcg_gen_abs_tl(d, a);
|
|
|
|
tcg_gen_neg_tl(d, d);
|
2019-03-21 12:57:28 +01:00
|
|
|
if (unlikely(Rc(ctx->opcode) != 0)) {
|
2019-04-18 02:45:47 +02:00
|
|
|
gen_set_Rc0(ctx, d);
|
2019-03-21 12:57:28 +01:00
|
|
|
}
|
2007-03-07 09:32:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* nabso - nabso. */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_nabso(DisasContext *ctx)
|
2007-03-07 09:32:30 +01:00
|
|
|
{
|
2019-04-18 02:45:47 +02:00
|
|
|
TCGv d = cpu_gpr[rD(ctx->opcode)];
|
|
|
|
TCGv a = cpu_gpr[rA(ctx->opcode)];
|
|
|
|
|
|
|
|
tcg_gen_abs_tl(d, a);
|
|
|
|
tcg_gen_neg_tl(d, d);
|
2008-12-06 13:19:14 +01:00
|
|
|
/* nabs never overflows */
|
2013-02-20 08:52:13 +01:00
|
|
|
tcg_gen_movi_tl(cpu_ov, 0);
|
2019-03-21 12:57:28 +01:00
|
|
|
if (unlikely(Rc(ctx->opcode) != 0)) {
|
2019-04-18 02:45:47 +02:00
|
|
|
gen_set_Rc0(ctx, d);
|
2019-03-21 12:57:28 +01:00
|
|
|
}
|
2007-03-07 09:32:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* rlmi - rlmi. */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_rlmi(DisasContext *ctx)
|
2007-03-07 09:32:30 +01:00
|
|
|
{
|
2008-12-05 08:21:44 +01:00
|
|
|
uint32_t mb = MB(ctx->opcode);
|
|
|
|
uint32_t me = ME(ctx->opcode);
|
|
|
|
TCGv t0 = tcg_temp_new();
|
|
|
|
tcg_gen_andi_tl(t0, cpu_gpr[rB(ctx->opcode)], 0x1F);
|
|
|
|
tcg_gen_rotl_tl(t0, cpu_gpr[rS(ctx->opcode)], t0);
|
|
|
|
tcg_gen_andi_tl(t0, t0, MASK(mb, me));
|
2019-03-21 12:57:28 +01:00
|
|
|
tcg_gen_andi_tl(cpu_gpr[rA(ctx->opcode)], cpu_gpr[rA(ctx->opcode)],
|
|
|
|
~MASK(mb, me));
|
2008-12-05 08:21:44 +01:00
|
|
|
tcg_gen_or_tl(cpu_gpr[rA(ctx->opcode)], cpu_gpr[rA(ctx->opcode)], t0);
|
|
|
|
tcg_temp_free(t0);
|
2019-03-21 12:57:28 +01:00
|
|
|
if (unlikely(Rc(ctx->opcode) != 0)) {
|
2008-12-05 08:21:44 +01:00
|
|
|
gen_set_Rc0(ctx, cpu_gpr[rA(ctx->opcode)]);
|
2019-03-21 12:57:28 +01:00
|
|
|
}
|
2007-03-07 09:32:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* rrib - rrib. */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_rrib(DisasContext *ctx)
|
2007-03-07 09:32:30 +01:00
|
|
|
{
|
2008-12-05 08:21:44 +01:00
|
|
|
TCGv t0 = tcg_temp_new();
|
|
|
|
TCGv t1 = tcg_temp_new();
|
|
|
|
tcg_gen_andi_tl(t0, cpu_gpr[rB(ctx->opcode)], 0x1F);
|
|
|
|
tcg_gen_movi_tl(t1, 0x80000000);
|
|
|
|
tcg_gen_shr_tl(t1, t1, t0);
|
|
|
|
tcg_gen_shr_tl(t0, cpu_gpr[rS(ctx->opcode)], t0);
|
|
|
|
tcg_gen_and_tl(t0, t0, t1);
|
|
|
|
tcg_gen_andc_tl(t1, cpu_gpr[rA(ctx->opcode)], t1);
|
|
|
|
tcg_gen_or_tl(cpu_gpr[rA(ctx->opcode)], t0, t1);
|
|
|
|
tcg_temp_free(t0);
|
|
|
|
tcg_temp_free(t1);
|
2019-03-21 12:57:28 +01:00
|
|
|
if (unlikely(Rc(ctx->opcode) != 0)) {
|
2008-12-05 08:21:44 +01:00
|
|
|
gen_set_Rc0(ctx, cpu_gpr[rA(ctx->opcode)]);
|
2019-03-21 12:57:28 +01:00
|
|
|
}
|
2007-03-07 09:32:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* sle - sle. */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_sle(DisasContext *ctx)
|
2007-03-07 09:32:30 +01:00
|
|
|
{
|
2008-12-05 08:21:44 +01:00
|
|
|
TCGv t0 = tcg_temp_new();
|
|
|
|
TCGv t1 = tcg_temp_new();
|
|
|
|
tcg_gen_andi_tl(t1, cpu_gpr[rB(ctx->opcode)], 0x1F);
|
|
|
|
tcg_gen_shl_tl(t0, cpu_gpr[rS(ctx->opcode)], t1);
|
|
|
|
tcg_gen_subfi_tl(t1, 32, t1);
|
|
|
|
tcg_gen_shr_tl(t1, cpu_gpr[rS(ctx->opcode)], t1);
|
|
|
|
tcg_gen_or_tl(t1, t0, t1);
|
|
|
|
tcg_gen_mov_tl(cpu_gpr[rA(ctx->opcode)], t0);
|
|
|
|
gen_store_spr(SPR_MQ, t1);
|
|
|
|
tcg_temp_free(t0);
|
|
|
|
tcg_temp_free(t1);
|
2019-03-21 12:57:28 +01:00
|
|
|
if (unlikely(Rc(ctx->opcode) != 0)) {
|
2008-12-05 08:21:44 +01:00
|
|
|
gen_set_Rc0(ctx, cpu_gpr[rA(ctx->opcode)]);
|
2019-03-21 12:57:28 +01:00
|
|
|
}
|
2007-03-07 09:32:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* sleq - sleq. */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_sleq(DisasContext *ctx)
|
2007-03-07 09:32:30 +01:00
|
|
|
{
|
2008-12-05 08:21:44 +01:00
|
|
|
TCGv t0 = tcg_temp_new();
|
|
|
|
TCGv t1 = tcg_temp_new();
|
|
|
|
TCGv t2 = tcg_temp_new();
|
|
|
|
tcg_gen_andi_tl(t0, cpu_gpr[rB(ctx->opcode)], 0x1F);
|
|
|
|
tcg_gen_movi_tl(t2, 0xFFFFFFFF);
|
|
|
|
tcg_gen_shl_tl(t2, t2, t0);
|
|
|
|
tcg_gen_rotl_tl(t0, cpu_gpr[rS(ctx->opcode)], t0);
|
|
|
|
gen_load_spr(t1, SPR_MQ);
|
|
|
|
gen_store_spr(SPR_MQ, t0);
|
|
|
|
tcg_gen_and_tl(t0, t0, t2);
|
|
|
|
tcg_gen_andc_tl(t1, t1, t2);
|
|
|
|
tcg_gen_or_tl(cpu_gpr[rA(ctx->opcode)], t0, t1);
|
|
|
|
tcg_temp_free(t0);
|
|
|
|
tcg_temp_free(t1);
|
|
|
|
tcg_temp_free(t2);
|
2019-03-21 12:57:28 +01:00
|
|
|
if (unlikely(Rc(ctx->opcode) != 0)) {
|
2008-12-05 08:21:44 +01:00
|
|
|
gen_set_Rc0(ctx, cpu_gpr[rA(ctx->opcode)]);
|
2019-03-21 12:57:28 +01:00
|
|
|
}
|
2007-03-07 09:32:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* sliq - sliq. */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_sliq(DisasContext *ctx)
|
2007-03-07 09:32:30 +01:00
|
|
|
{
|
2008-12-05 08:21:44 +01:00
|
|
|
int sh = SH(ctx->opcode);
|
|
|
|
TCGv t0 = tcg_temp_new();
|
|
|
|
TCGv t1 = tcg_temp_new();
|
|
|
|
tcg_gen_shli_tl(t0, cpu_gpr[rS(ctx->opcode)], sh);
|
|
|
|
tcg_gen_shri_tl(t1, cpu_gpr[rS(ctx->opcode)], 32 - sh);
|
|
|
|
tcg_gen_or_tl(t1, t0, t1);
|
|
|
|
tcg_gen_mov_tl(cpu_gpr[rA(ctx->opcode)], t0);
|
|
|
|
gen_store_spr(SPR_MQ, t1);
|
|
|
|
tcg_temp_free(t0);
|
|
|
|
tcg_temp_free(t1);
|
2019-03-21 12:57:28 +01:00
|
|
|
if (unlikely(Rc(ctx->opcode) != 0)) {
|
2008-12-05 08:21:44 +01:00
|
|
|
gen_set_Rc0(ctx, cpu_gpr[rA(ctx->opcode)]);
|
2019-03-21 12:57:28 +01:00
|
|
|
}
|
2007-03-07 09:32:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* slliq - slliq. */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_slliq(DisasContext *ctx)
|
2007-03-07 09:32:30 +01:00
|
|
|
{
|
2008-12-05 08:21:44 +01:00
|
|
|
int sh = SH(ctx->opcode);
|
|
|
|
TCGv t0 = tcg_temp_new();
|
|
|
|
TCGv t1 = tcg_temp_new();
|
|
|
|
tcg_gen_rotli_tl(t0, cpu_gpr[rS(ctx->opcode)], sh);
|
|
|
|
gen_load_spr(t1, SPR_MQ);
|
|
|
|
gen_store_spr(SPR_MQ, t0);
|
|
|
|
tcg_gen_andi_tl(t0, t0, (0xFFFFFFFFU << sh));
|
|
|
|
tcg_gen_andi_tl(t1, t1, ~(0xFFFFFFFFU << sh));
|
|
|
|
tcg_gen_or_tl(cpu_gpr[rA(ctx->opcode)], t0, t1);
|
|
|
|
tcg_temp_free(t0);
|
|
|
|
tcg_temp_free(t1);
|
2019-03-21 12:57:28 +01:00
|
|
|
if (unlikely(Rc(ctx->opcode) != 0)) {
|
2008-12-05 08:21:44 +01:00
|
|
|
gen_set_Rc0(ctx, cpu_gpr[rA(ctx->opcode)]);
|
2019-03-21 12:57:28 +01:00
|
|
|
}
|
2007-03-07 09:32:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* sllq - sllq. */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_sllq(DisasContext *ctx)
|
2007-03-07 09:32:30 +01:00
|
|
|
{
|
2015-02-13 21:51:55 +01:00
|
|
|
TCGLabel *l1 = gen_new_label();
|
|
|
|
TCGLabel *l2 = gen_new_label();
|
2008-12-05 08:21:44 +01:00
|
|
|
TCGv t0 = tcg_temp_local_new();
|
|
|
|
TCGv t1 = tcg_temp_local_new();
|
|
|
|
TCGv t2 = tcg_temp_local_new();
|
|
|
|
tcg_gen_andi_tl(t2, cpu_gpr[rB(ctx->opcode)], 0x1F);
|
|
|
|
tcg_gen_movi_tl(t1, 0xFFFFFFFF);
|
|
|
|
tcg_gen_shl_tl(t1, t1, t2);
|
|
|
|
tcg_gen_andi_tl(t0, cpu_gpr[rB(ctx->opcode)], 0x20);
|
|
|
|
tcg_gen_brcondi_tl(TCG_COND_EQ, t0, 0, l1);
|
|
|
|
gen_load_spr(t0, SPR_MQ);
|
|
|
|
tcg_gen_and_tl(cpu_gpr[rA(ctx->opcode)], t0, t1);
|
|
|
|
tcg_gen_br(l2);
|
|
|
|
gen_set_label(l1);
|
|
|
|
tcg_gen_shl_tl(t0, cpu_gpr[rS(ctx->opcode)], t2);
|
|
|
|
gen_load_spr(t2, SPR_MQ);
|
|
|
|
tcg_gen_andc_tl(t1, t2, t1);
|
|
|
|
tcg_gen_or_tl(cpu_gpr[rA(ctx->opcode)], t0, t1);
|
|
|
|
gen_set_label(l2);
|
|
|
|
tcg_temp_free(t0);
|
|
|
|
tcg_temp_free(t1);
|
|
|
|
tcg_temp_free(t2);
|
2019-03-21 12:57:28 +01:00
|
|
|
if (unlikely(Rc(ctx->opcode) != 0)) {
|
2008-12-05 08:21:44 +01:00
|
|
|
gen_set_Rc0(ctx, cpu_gpr[rA(ctx->opcode)]);
|
2019-03-21 12:57:28 +01:00
|
|
|
}
|
2007-03-07 09:32:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* slq - slq. */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_slq(DisasContext *ctx)
|
2007-03-07 09:32:30 +01:00
|
|
|
{
|
2015-02-13 21:51:55 +01:00
|
|
|
TCGLabel *l1 = gen_new_label();
|
2008-12-05 08:21:44 +01:00
|
|
|
TCGv t0 = tcg_temp_new();
|
|
|
|
TCGv t1 = tcg_temp_new();
|
|
|
|
tcg_gen_andi_tl(t1, cpu_gpr[rB(ctx->opcode)], 0x1F);
|
|
|
|
tcg_gen_shl_tl(t0, cpu_gpr[rS(ctx->opcode)], t1);
|
|
|
|
tcg_gen_subfi_tl(t1, 32, t1);
|
|
|
|
tcg_gen_shr_tl(t1, cpu_gpr[rS(ctx->opcode)], t1);
|
|
|
|
tcg_gen_or_tl(t1, t0, t1);
|
|
|
|
gen_store_spr(SPR_MQ, t1);
|
|
|
|
tcg_gen_andi_tl(t1, cpu_gpr[rB(ctx->opcode)], 0x20);
|
|
|
|
tcg_gen_mov_tl(cpu_gpr[rA(ctx->opcode)], t0);
|
|
|
|
tcg_gen_brcondi_tl(TCG_COND_EQ, t1, 0, l1);
|
|
|
|
tcg_gen_movi_tl(cpu_gpr[rA(ctx->opcode)], 0);
|
|
|
|
gen_set_label(l1);
|
|
|
|
tcg_temp_free(t0);
|
|
|
|
tcg_temp_free(t1);
|
2019-03-21 12:57:28 +01:00
|
|
|
if (unlikely(Rc(ctx->opcode) != 0)) {
|
2008-12-05 08:21:44 +01:00
|
|
|
gen_set_Rc0(ctx, cpu_gpr[rA(ctx->opcode)]);
|
2019-03-21 12:57:28 +01:00
|
|
|
}
|
2007-03-07 09:32:30 +01:00
|
|
|
}
|
|
|
|
|
2007-03-17 15:02:15 +01:00
|
|
|
/* sraiq - sraiq. */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_sraiq(DisasContext *ctx)
|
2007-03-07 09:32:30 +01:00
|
|
|
{
|
2008-12-05 08:21:44 +01:00
|
|
|
int sh = SH(ctx->opcode);
|
2015-02-13 21:51:55 +01:00
|
|
|
TCGLabel *l1 = gen_new_label();
|
2008-12-05 08:21:44 +01:00
|
|
|
TCGv t0 = tcg_temp_new();
|
|
|
|
TCGv t1 = tcg_temp_new();
|
|
|
|
tcg_gen_shri_tl(t0, cpu_gpr[rS(ctx->opcode)], sh);
|
|
|
|
tcg_gen_shli_tl(t1, cpu_gpr[rS(ctx->opcode)], 32 - sh);
|
|
|
|
tcg_gen_or_tl(t0, t0, t1);
|
|
|
|
gen_store_spr(SPR_MQ, t0);
|
2013-02-20 08:52:13 +01:00
|
|
|
tcg_gen_movi_tl(cpu_ca, 0);
|
2008-12-05 08:21:44 +01:00
|
|
|
tcg_gen_brcondi_tl(TCG_COND_EQ, t1, 0, l1);
|
|
|
|
tcg_gen_brcondi_tl(TCG_COND_GE, cpu_gpr[rS(ctx->opcode)], 0, l1);
|
2013-02-20 08:52:13 +01:00
|
|
|
tcg_gen_movi_tl(cpu_ca, 1);
|
2008-12-05 08:21:44 +01:00
|
|
|
gen_set_label(l1);
|
|
|
|
tcg_gen_sari_tl(cpu_gpr[rA(ctx->opcode)], cpu_gpr[rS(ctx->opcode)], sh);
|
|
|
|
tcg_temp_free(t0);
|
|
|
|
tcg_temp_free(t1);
|
2019-03-21 12:57:28 +01:00
|
|
|
if (unlikely(Rc(ctx->opcode) != 0)) {
|
2008-12-05 08:21:44 +01:00
|
|
|
gen_set_Rc0(ctx, cpu_gpr[rA(ctx->opcode)]);
|
2019-03-21 12:57:28 +01:00
|
|
|
}
|
2007-03-07 09:32:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* sraq - sraq. */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_sraq(DisasContext *ctx)
|
2007-03-07 09:32:30 +01:00
|
|
|
{
|
2015-02-13 21:51:55 +01:00
|
|
|
TCGLabel *l1 = gen_new_label();
|
|
|
|
TCGLabel *l2 = gen_new_label();
|
2008-12-05 08:21:44 +01:00
|
|
|
TCGv t0 = tcg_temp_new();
|
|
|
|
TCGv t1 = tcg_temp_local_new();
|
|
|
|
TCGv t2 = tcg_temp_local_new();
|
|
|
|
tcg_gen_andi_tl(t2, cpu_gpr[rB(ctx->opcode)], 0x1F);
|
|
|
|
tcg_gen_shr_tl(t0, cpu_gpr[rS(ctx->opcode)], t2);
|
|
|
|
tcg_gen_sar_tl(t1, cpu_gpr[rS(ctx->opcode)], t2);
|
|
|
|
tcg_gen_subfi_tl(t2, 32, t2);
|
|
|
|
tcg_gen_shl_tl(t2, cpu_gpr[rS(ctx->opcode)], t2);
|
|
|
|
tcg_gen_or_tl(t0, t0, t2);
|
|
|
|
gen_store_spr(SPR_MQ, t0);
|
|
|
|
tcg_gen_andi_tl(t0, cpu_gpr[rB(ctx->opcode)], 0x20);
|
|
|
|
tcg_gen_brcondi_tl(TCG_COND_EQ, t2, 0, l1);
|
|
|
|
tcg_gen_mov_tl(t2, cpu_gpr[rS(ctx->opcode)]);
|
|
|
|
tcg_gen_sari_tl(t1, cpu_gpr[rS(ctx->opcode)], 31);
|
|
|
|
gen_set_label(l1);
|
|
|
|
tcg_temp_free(t0);
|
|
|
|
tcg_gen_mov_tl(cpu_gpr[rA(ctx->opcode)], t1);
|
2013-02-20 08:52:13 +01:00
|
|
|
tcg_gen_movi_tl(cpu_ca, 0);
|
2008-12-05 08:21:44 +01:00
|
|
|
tcg_gen_brcondi_tl(TCG_COND_GE, t1, 0, l2);
|
|
|
|
tcg_gen_brcondi_tl(TCG_COND_EQ, t2, 0, l2);
|
2013-02-20 08:52:13 +01:00
|
|
|
tcg_gen_movi_tl(cpu_ca, 1);
|
2008-12-05 08:21:44 +01:00
|
|
|
gen_set_label(l2);
|
|
|
|
tcg_temp_free(t1);
|
|
|
|
tcg_temp_free(t2);
|
2019-03-21 12:57:28 +01:00
|
|
|
if (unlikely(Rc(ctx->opcode) != 0)) {
|
2008-12-05 08:21:44 +01:00
|
|
|
gen_set_Rc0(ctx, cpu_gpr[rA(ctx->opcode)]);
|
2019-03-21 12:57:28 +01:00
|
|
|
}
|
2007-03-07 09:32:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* sre - sre. */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_sre(DisasContext *ctx)
|
2007-03-07 09:32:30 +01:00
|
|
|
{
|
2008-12-05 08:21:44 +01:00
|
|
|
TCGv t0 = tcg_temp_new();
|
|
|
|
TCGv t1 = tcg_temp_new();
|
|
|
|
tcg_gen_andi_tl(t1, cpu_gpr[rB(ctx->opcode)], 0x1F);
|
|
|
|
tcg_gen_shr_tl(t0, cpu_gpr[rS(ctx->opcode)], t1);
|
|
|
|
tcg_gen_subfi_tl(t1, 32, t1);
|
|
|
|
tcg_gen_shl_tl(t1, cpu_gpr[rS(ctx->opcode)], t1);
|
|
|
|
tcg_gen_or_tl(t1, t0, t1);
|
|
|
|
tcg_gen_mov_tl(cpu_gpr[rA(ctx->opcode)], t0);
|
|
|
|
gen_store_spr(SPR_MQ, t1);
|
|
|
|
tcg_temp_free(t0);
|
|
|
|
tcg_temp_free(t1);
|
2019-03-21 12:57:28 +01:00
|
|
|
if (unlikely(Rc(ctx->opcode) != 0)) {
|
2008-12-05 08:21:44 +01:00
|
|
|
gen_set_Rc0(ctx, cpu_gpr[rA(ctx->opcode)]);
|
2019-03-21 12:57:28 +01:00
|
|
|
}
|
2007-03-07 09:32:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* srea - srea. */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_srea(DisasContext *ctx)
|
2007-03-07 09:32:30 +01:00
|
|
|
{
|
2008-12-05 08:21:44 +01:00
|
|
|
TCGv t0 = tcg_temp_new();
|
|
|
|
TCGv t1 = tcg_temp_new();
|
|
|
|
tcg_gen_andi_tl(t1, cpu_gpr[rB(ctx->opcode)], 0x1F);
|
|
|
|
tcg_gen_rotr_tl(t0, cpu_gpr[rS(ctx->opcode)], t1);
|
|
|
|
gen_store_spr(SPR_MQ, t0);
|
|
|
|
tcg_gen_sar_tl(cpu_gpr[rA(ctx->opcode)], cpu_gpr[rS(ctx->opcode)], t1);
|
|
|
|
tcg_temp_free(t0);
|
|
|
|
tcg_temp_free(t1);
|
2019-03-21 12:57:28 +01:00
|
|
|
if (unlikely(Rc(ctx->opcode) != 0)) {
|
2008-12-05 08:21:44 +01:00
|
|
|
gen_set_Rc0(ctx, cpu_gpr[rA(ctx->opcode)]);
|
2019-03-21 12:57:28 +01:00
|
|
|
}
|
2007-03-07 09:32:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* sreq */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_sreq(DisasContext *ctx)
|
2007-03-07 09:32:30 +01:00
|
|
|
{
|
2008-12-05 08:21:44 +01:00
|
|
|
TCGv t0 = tcg_temp_new();
|
|
|
|
TCGv t1 = tcg_temp_new();
|
|
|
|
TCGv t2 = tcg_temp_new();
|
|
|
|
tcg_gen_andi_tl(t0, cpu_gpr[rB(ctx->opcode)], 0x1F);
|
|
|
|
tcg_gen_movi_tl(t1, 0xFFFFFFFF);
|
|
|
|
tcg_gen_shr_tl(t1, t1, t0);
|
|
|
|
tcg_gen_rotr_tl(t0, cpu_gpr[rS(ctx->opcode)], t0);
|
|
|
|
gen_load_spr(t2, SPR_MQ);
|
|
|
|
gen_store_spr(SPR_MQ, t0);
|
|
|
|
tcg_gen_and_tl(t0, t0, t1);
|
|
|
|
tcg_gen_andc_tl(t2, t2, t1);
|
|
|
|
tcg_gen_or_tl(cpu_gpr[rA(ctx->opcode)], t0, t2);
|
|
|
|
tcg_temp_free(t0);
|
|
|
|
tcg_temp_free(t1);
|
|
|
|
tcg_temp_free(t2);
|
2019-03-21 12:57:28 +01:00
|
|
|
if (unlikely(Rc(ctx->opcode) != 0)) {
|
2008-12-05 08:21:44 +01:00
|
|
|
gen_set_Rc0(ctx, cpu_gpr[rA(ctx->opcode)]);
|
2019-03-21 12:57:28 +01:00
|
|
|
}
|
2007-03-07 09:32:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* sriq */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_sriq(DisasContext *ctx)
|
2007-03-07 09:32:30 +01:00
|
|
|
{
|
2008-12-05 08:21:44 +01:00
|
|
|
int sh = SH(ctx->opcode);
|
|
|
|
TCGv t0 = tcg_temp_new();
|
|
|
|
TCGv t1 = tcg_temp_new();
|
|
|
|
tcg_gen_shri_tl(t0, cpu_gpr[rS(ctx->opcode)], sh);
|
|
|
|
tcg_gen_shli_tl(t1, cpu_gpr[rS(ctx->opcode)], 32 - sh);
|
|
|
|
tcg_gen_or_tl(t1, t0, t1);
|
|
|
|
tcg_gen_mov_tl(cpu_gpr[rA(ctx->opcode)], t0);
|
|
|
|
gen_store_spr(SPR_MQ, t1);
|
|
|
|
tcg_temp_free(t0);
|
|
|
|
tcg_temp_free(t1);
|
2019-03-21 12:57:28 +01:00
|
|
|
if (unlikely(Rc(ctx->opcode) != 0)) {
|
2008-12-05 08:21:44 +01:00
|
|
|
gen_set_Rc0(ctx, cpu_gpr[rA(ctx->opcode)]);
|
2019-03-21 12:57:28 +01:00
|
|
|
}
|
2007-03-07 09:32:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* srliq */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_srliq(DisasContext *ctx)
|
2007-03-07 09:32:30 +01:00
|
|
|
{
|
2008-12-05 08:21:44 +01:00
|
|
|
int sh = SH(ctx->opcode);
|
|
|
|
TCGv t0 = tcg_temp_new();
|
|
|
|
TCGv t1 = tcg_temp_new();
|
|
|
|
tcg_gen_rotri_tl(t0, cpu_gpr[rS(ctx->opcode)], sh);
|
|
|
|
gen_load_spr(t1, SPR_MQ);
|
|
|
|
gen_store_spr(SPR_MQ, t0);
|
|
|
|
tcg_gen_andi_tl(t0, t0, (0xFFFFFFFFU >> sh));
|
|
|
|
tcg_gen_andi_tl(t1, t1, ~(0xFFFFFFFFU >> sh));
|
|
|
|
tcg_gen_or_tl(cpu_gpr[rA(ctx->opcode)], t0, t1);
|
|
|
|
tcg_temp_free(t0);
|
|
|
|
tcg_temp_free(t1);
|
2019-03-21 12:57:28 +01:00
|
|
|
if (unlikely(Rc(ctx->opcode) != 0)) {
|
2008-12-05 08:21:44 +01:00
|
|
|
gen_set_Rc0(ctx, cpu_gpr[rA(ctx->opcode)]);
|
2019-03-21 12:57:28 +01:00
|
|
|
}
|
2007-03-07 09:32:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* srlq */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_srlq(DisasContext *ctx)
|
2007-03-07 09:32:30 +01:00
|
|
|
{
|
2015-02-13 21:51:55 +01:00
|
|
|
TCGLabel *l1 = gen_new_label();
|
|
|
|
TCGLabel *l2 = gen_new_label();
|
2008-12-05 08:21:44 +01:00
|
|
|
TCGv t0 = tcg_temp_local_new();
|
|
|
|
TCGv t1 = tcg_temp_local_new();
|
|
|
|
TCGv t2 = tcg_temp_local_new();
|
|
|
|
tcg_gen_andi_tl(t2, cpu_gpr[rB(ctx->opcode)], 0x1F);
|
|
|
|
tcg_gen_movi_tl(t1, 0xFFFFFFFF);
|
|
|
|
tcg_gen_shr_tl(t2, t1, t2);
|
|
|
|
tcg_gen_andi_tl(t0, cpu_gpr[rB(ctx->opcode)], 0x20);
|
|
|
|
tcg_gen_brcondi_tl(TCG_COND_EQ, t0, 0, l1);
|
|
|
|
gen_load_spr(t0, SPR_MQ);
|
|
|
|
tcg_gen_and_tl(cpu_gpr[rA(ctx->opcode)], t0, t2);
|
|
|
|
tcg_gen_br(l2);
|
|
|
|
gen_set_label(l1);
|
|
|
|
tcg_gen_shr_tl(t0, cpu_gpr[rS(ctx->opcode)], t2);
|
|
|
|
tcg_gen_and_tl(t0, t0, t2);
|
|
|
|
gen_load_spr(t1, SPR_MQ);
|
|
|
|
tcg_gen_andc_tl(t1, t1, t2);
|
|
|
|
tcg_gen_or_tl(cpu_gpr[rA(ctx->opcode)], t0, t1);
|
|
|
|
gen_set_label(l2);
|
|
|
|
tcg_temp_free(t0);
|
|
|
|
tcg_temp_free(t1);
|
|
|
|
tcg_temp_free(t2);
|
2019-03-21 12:57:28 +01:00
|
|
|
if (unlikely(Rc(ctx->opcode) != 0)) {
|
2008-12-05 08:21:44 +01:00
|
|
|
gen_set_Rc0(ctx, cpu_gpr[rA(ctx->opcode)]);
|
2019-03-21 12:57:28 +01:00
|
|
|
}
|
2007-03-07 09:32:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* srq */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_srq(DisasContext *ctx)
|
2007-03-07 09:32:30 +01:00
|
|
|
{
|
2015-02-13 21:51:55 +01:00
|
|
|
TCGLabel *l1 = gen_new_label();
|
2008-12-05 08:21:44 +01:00
|
|
|
TCGv t0 = tcg_temp_new();
|
|
|
|
TCGv t1 = tcg_temp_new();
|
|
|
|
tcg_gen_andi_tl(t1, cpu_gpr[rB(ctx->opcode)], 0x1F);
|
|
|
|
tcg_gen_shr_tl(t0, cpu_gpr[rS(ctx->opcode)], t1);
|
|
|
|
tcg_gen_subfi_tl(t1, 32, t1);
|
|
|
|
tcg_gen_shl_tl(t1, cpu_gpr[rS(ctx->opcode)], t1);
|
|
|
|
tcg_gen_or_tl(t1, t0, t1);
|
|
|
|
gen_store_spr(SPR_MQ, t1);
|
|
|
|
tcg_gen_andi_tl(t1, cpu_gpr[rB(ctx->opcode)], 0x20);
|
|
|
|
tcg_gen_mov_tl(cpu_gpr[rA(ctx->opcode)], t0);
|
|
|
|
tcg_gen_brcondi_tl(TCG_COND_EQ, t0, 0, l1);
|
|
|
|
tcg_gen_movi_tl(cpu_gpr[rA(ctx->opcode)], 0);
|
|
|
|
gen_set_label(l1);
|
|
|
|
tcg_temp_free(t0);
|
|
|
|
tcg_temp_free(t1);
|
2019-03-21 12:57:28 +01:00
|
|
|
if (unlikely(Rc(ctx->opcode) != 0)) {
|
2008-12-05 08:21:44 +01:00
|
|
|
gen_set_Rc0(ctx, cpu_gpr[rA(ctx->opcode)]);
|
2019-03-21 12:57:28 +01:00
|
|
|
}
|
2007-03-07 09:32:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* PowerPC 602 specific instructions */
|
2009-06-17 17:22:09 +02:00
|
|
|
|
2009-06-17 17:22:19 +02:00
|
|
|
/* dsa */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_dsa(DisasContext *ctx)
|
2007-03-07 09:32:30 +01:00
|
|
|
{
|
|
|
|
/* XXX: TODO */
|
2008-12-11 23:42:14 +01:00
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_INVAL_INVAL);
|
2007-03-07 09:32:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* esa */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_esa(DisasContext *ctx)
|
2007-03-07 09:32:30 +01:00
|
|
|
{
|
|
|
|
/* XXX: TODO */
|
2008-12-11 23:42:14 +01:00
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_INVAL_INVAL);
|
2007-03-07 09:32:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* mfrom */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_mfrom(DisasContext *ctx)
|
2007-03-07 09:32:30 +01:00
|
|
|
{
|
|
|
|
#if defined(CONFIG_USER_ONLY)
|
2016-06-21 23:48:51 +02:00
|
|
|
GEN_PRIV;
|
2007-03-07 09:32:30 +01:00
|
|
|
#else
|
2016-06-21 23:48:51 +02:00
|
|
|
CHK_SV;
|
2008-11-30 17:23:35 +01:00
|
|
|
gen_helper_602_mfrom(cpu_gpr[rD(ctx->opcode)], cpu_gpr[rA(ctx->opcode)]);
|
2016-06-21 23:48:51 +02:00
|
|
|
#endif /* defined(CONFIG_USER_ONLY) */
|
2007-03-07 09:32:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* 602 - 603 - G2 TLB management */
|
2009-06-17 17:22:14 +02:00
|
|
|
|
2009-06-17 17:22:19 +02:00
|
|
|
/* tlbld */
|
2009-06-17 17:22:14 +02:00
|
|
|
static void gen_tlbld_6xx(DisasContext *ctx)
|
2007-03-07 09:32:30 +01:00
|
|
|
{
|
|
|
|
#if defined(CONFIG_USER_ONLY)
|
2016-06-21 23:48:51 +02:00
|
|
|
GEN_PRIV;
|
2007-03-07 09:32:30 +01:00
|
|
|
#else
|
2016-06-21 23:48:51 +02:00
|
|
|
CHK_SV;
|
2012-05-30 06:23:31 +02:00
|
|
|
gen_helper_6xx_tlbd(cpu_env, cpu_gpr[rB(ctx->opcode)]);
|
2016-06-21 23:48:51 +02:00
|
|
|
#endif /* defined(CONFIG_USER_ONLY) */
|
2007-03-07 09:32:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* tlbli */
|
2009-06-17 17:22:14 +02:00
|
|
|
static void gen_tlbli_6xx(DisasContext *ctx)
|
2007-03-07 09:32:30 +01:00
|
|
|
{
|
|
|
|
#if defined(CONFIG_USER_ONLY)
|
2016-06-21 23:48:51 +02:00
|
|
|
GEN_PRIV;
|
2007-03-07 09:32:30 +01:00
|
|
|
#else
|
2016-06-21 23:48:51 +02:00
|
|
|
CHK_SV;
|
2012-05-30 06:23:31 +02:00
|
|
|
gen_helper_6xx_tlbi(cpu_env, cpu_gpr[rB(ctx->opcode)]);
|
2016-06-21 23:48:51 +02:00
|
|
|
#endif /* defined(CONFIG_USER_ONLY) */
|
2007-03-07 09:32:30 +01:00
|
|
|
}
|
|
|
|
|
2007-10-01 07:16:57 +02:00
|
|
|
/* 74xx TLB management */
|
2009-06-17 17:22:14 +02:00
|
|
|
|
2009-06-17 17:22:19 +02:00
|
|
|
/* tlbld */
|
2009-06-17 17:22:14 +02:00
|
|
|
static void gen_tlbld_74xx(DisasContext *ctx)
|
2007-10-01 07:16:57 +02:00
|
|
|
{
|
|
|
|
#if defined(CONFIG_USER_ONLY)
|
2016-06-21 23:48:51 +02:00
|
|
|
GEN_PRIV;
|
2007-10-01 07:16:57 +02:00
|
|
|
#else
|
2016-06-21 23:48:51 +02:00
|
|
|
CHK_SV;
|
2012-05-30 06:23:31 +02:00
|
|
|
gen_helper_74xx_tlbd(cpu_env, cpu_gpr[rB(ctx->opcode)]);
|
2016-06-21 23:48:51 +02:00
|
|
|
#endif /* defined(CONFIG_USER_ONLY) */
|
2007-10-01 07:16:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* tlbli */
|
2009-06-17 17:22:14 +02:00
|
|
|
static void gen_tlbli_74xx(DisasContext *ctx)
|
2007-10-01 07:16:57 +02:00
|
|
|
{
|
|
|
|
#if defined(CONFIG_USER_ONLY)
|
2016-06-21 23:48:51 +02:00
|
|
|
GEN_PRIV;
|
2007-10-01 07:16:57 +02:00
|
|
|
#else
|
2016-06-21 23:48:51 +02:00
|
|
|
CHK_SV;
|
2012-05-30 06:23:31 +02:00
|
|
|
gen_helper_74xx_tlbi(cpu_env, cpu_gpr[rB(ctx->opcode)]);
|
2016-06-21 23:48:51 +02:00
|
|
|
#endif /* defined(CONFIG_USER_ONLY) */
|
2007-10-01 07:16:57 +02:00
|
|
|
}
|
|
|
|
|
2007-03-07 09:32:30 +01:00
|
|
|
/* POWER instructions not in PowerPC 601 */
|
2009-06-17 17:22:09 +02:00
|
|
|
|
2009-06-17 17:22:19 +02:00
|
|
|
/* clf */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_clf(DisasContext *ctx)
|
2007-03-07 09:32:30 +01:00
|
|
|
{
|
|
|
|
/* Cache line flush: implemented as no-op */
|
|
|
|
}
|
|
|
|
|
|
|
|
/* cli */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_cli(DisasContext *ctx)
|
2007-03-07 09:32:30 +01:00
|
|
|
{
|
|
|
|
#if defined(CONFIG_USER_ONLY)
|
2016-06-21 23:48:51 +02:00
|
|
|
GEN_PRIV;
|
2007-03-07 09:32:30 +01:00
|
|
|
#else
|
2016-06-21 23:48:51 +02:00
|
|
|
/* Cache line invalidate: privileged and treated as no-op */
|
|
|
|
CHK_SV;
|
|
|
|
#endif /* defined(CONFIG_USER_ONLY) */
|
2007-03-07 09:32:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* dclst */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_dclst(DisasContext *ctx)
|
2007-03-07 09:32:30 +01:00
|
|
|
{
|
|
|
|
/* Data cache line store: treated as no-op */
|
|
|
|
}
|
|
|
|
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_mfsri(DisasContext *ctx)
|
2007-03-07 09:32:30 +01:00
|
|
|
{
|
|
|
|
#if defined(CONFIG_USER_ONLY)
|
2016-06-21 23:48:51 +02:00
|
|
|
GEN_PRIV;
|
2007-03-07 09:32:30 +01:00
|
|
|
#else
|
2008-12-06 22:46:17 +01:00
|
|
|
int ra = rA(ctx->opcode);
|
|
|
|
int rd = rD(ctx->opcode);
|
|
|
|
TCGv t0;
|
2016-06-21 23:48:51 +02:00
|
|
|
|
|
|
|
CHK_SV;
|
2008-12-06 22:46:17 +01:00
|
|
|
t0 = tcg_temp_new();
|
2008-12-08 19:11:21 +01:00
|
|
|
gen_addr_reg_index(ctx, t0);
|
2017-07-18 06:55:35 +02:00
|
|
|
tcg_gen_extract_tl(t0, t0, 28, 4);
|
2012-05-30 06:23:31 +02:00
|
|
|
gen_helper_load_sr(cpu_gpr[rd], cpu_env, t0);
|
2008-12-06 22:46:17 +01:00
|
|
|
tcg_temp_free(t0);
|
2019-03-21 12:57:28 +01:00
|
|
|
if (ra != 0 && ra != rd) {
|
2008-12-06 22:46:17 +01:00
|
|
|
tcg_gen_mov_tl(cpu_gpr[ra], cpu_gpr[rd]);
|
2019-03-21 12:57:28 +01:00
|
|
|
}
|
2016-06-21 23:48:51 +02:00
|
|
|
#endif /* defined(CONFIG_USER_ONLY) */
|
2007-03-07 09:32:30 +01:00
|
|
|
}
|
|
|
|
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_rac(DisasContext *ctx)
|
2007-03-07 09:32:30 +01:00
|
|
|
{
|
|
|
|
#if defined(CONFIG_USER_ONLY)
|
2016-06-21 23:48:51 +02:00
|
|
|
GEN_PRIV;
|
2007-03-07 09:32:30 +01:00
|
|
|
#else
|
2008-12-06 13:19:14 +01:00
|
|
|
TCGv t0;
|
2016-06-21 23:48:51 +02:00
|
|
|
|
|
|
|
CHK_SV;
|
2008-12-06 13:19:14 +01:00
|
|
|
t0 = tcg_temp_new();
|
2008-12-08 19:11:21 +01:00
|
|
|
gen_addr_reg_index(ctx, t0);
|
2012-05-30 06:23:31 +02:00
|
|
|
gen_helper_rac(cpu_gpr[rD(ctx->opcode)], cpu_env, t0);
|
2008-12-06 13:19:14 +01:00
|
|
|
tcg_temp_free(t0);
|
2016-06-21 23:48:51 +02:00
|
|
|
#endif /* defined(CONFIG_USER_ONLY) */
|
2007-03-07 09:32:30 +01:00
|
|
|
}
|
|
|
|
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_rfsvc(DisasContext *ctx)
|
2007-03-07 09:32:30 +01:00
|
|
|
{
|
|
|
|
#if defined(CONFIG_USER_ONLY)
|
2016-06-21 23:48:51 +02:00
|
|
|
GEN_PRIV;
|
2007-03-07 09:32:30 +01:00
|
|
|
#else
|
2016-06-21 23:48:51 +02:00
|
|
|
CHK_SV;
|
|
|
|
|
2012-05-30 06:23:23 +02:00
|
|
|
gen_helper_rfsvc(cpu_env);
|
2021-05-12 20:54:18 +02:00
|
|
|
ctx->base.is_jmp = DISAS_EXIT;
|
2016-06-21 23:48:51 +02:00
|
|
|
#endif /* defined(CONFIG_USER_ONLY) */
|
2007-03-07 09:32:30 +01:00
|
|
|
}
|
|
|
|
|
2016-07-27 08:56:20 +02:00
|
|
|
/* svc is not implemented for now */
|
2007-03-07 09:32:30 +01:00
|
|
|
|
|
|
|
/* BookE specific instructions */
|
2009-06-17 17:22:09 +02:00
|
|
|
|
2009-06-17 17:22:19 +02:00
|
|
|
/* XXX: not implemented on 440 ? */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_mfapidi(DisasContext *ctx)
|
2007-03-07 09:32:30 +01:00
|
|
|
{
|
|
|
|
/* XXX: TODO */
|
2008-12-11 23:42:14 +01:00
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_INVAL_INVAL);
|
2007-03-07 09:32:30 +01:00
|
|
|
}
|
|
|
|
|
2007-09-21 07:50:37 +02:00
|
|
|
/* XXX: not implemented on 440 ? */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_tlbiva(DisasContext *ctx)
|
2007-03-07 09:32:30 +01:00
|
|
|
{
|
|
|
|
#if defined(CONFIG_USER_ONLY)
|
2016-06-21 23:48:51 +02:00
|
|
|
GEN_PRIV;
|
2007-03-07 09:32:30 +01:00
|
|
|
#else
|
2008-12-06 22:46:17 +01:00
|
|
|
TCGv t0;
|
2016-06-21 23:48:51 +02:00
|
|
|
|
|
|
|
CHK_SV;
|
2008-12-07 16:45:15 +01:00
|
|
|
t0 = tcg_temp_new();
|
2008-12-08 19:11:21 +01:00
|
|
|
gen_addr_reg_index(ctx, t0);
|
2016-01-28 00:31:04 +01:00
|
|
|
gen_helper_tlbiva(cpu_env, cpu_gpr[rB(ctx->opcode)]);
|
2008-12-06 22:46:17 +01:00
|
|
|
tcg_temp_free(t0);
|
2016-06-21 23:48:51 +02:00
|
|
|
#endif /* defined(CONFIG_USER_ONLY) */
|
2007-03-07 09:32:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* All 405 MAC instructions are translated here */
|
2009-08-16 11:06:54 +02:00
|
|
|
static inline void gen_405_mulladd_insn(DisasContext *ctx, int opc2, int opc3,
|
|
|
|
int ra, int rb, int rt, int Rc)
|
2007-03-07 09:32:30 +01:00
|
|
|
{
|
2008-11-01 01:54:23 +01:00
|
|
|
TCGv t0, t1;
|
|
|
|
|
2008-11-17 15:43:54 +01:00
|
|
|
t0 = tcg_temp_local_new();
|
|
|
|
t1 = tcg_temp_local_new();
|
2008-11-01 01:54:23 +01:00
|
|
|
|
2007-03-07 09:32:30 +01:00
|
|
|
switch (opc3 & 0x0D) {
|
|
|
|
case 0x05:
|
|
|
|
/* macchw - macchw. - macchwo - macchwo. */
|
|
|
|
/* macchws - macchws. - macchwso - macchwso. */
|
|
|
|
/* nmacchw - nmacchw. - nmacchwo - nmacchwo. */
|
|
|
|
/* nmacchws - nmacchws. - nmacchwso - nmacchwso. */
|
|
|
|
/* mulchw - mulchw. */
|
2008-11-01 01:54:23 +01:00
|
|
|
tcg_gen_ext16s_tl(t0, cpu_gpr[ra]);
|
|
|
|
tcg_gen_sari_tl(t1, cpu_gpr[rb], 16);
|
|
|
|
tcg_gen_ext16s_tl(t1, t1);
|
2007-03-07 09:32:30 +01:00
|
|
|
break;
|
|
|
|
case 0x04:
|
|
|
|
/* macchwu - macchwu. - macchwuo - macchwuo. */
|
|
|
|
/* macchwsu - macchwsu. - macchwsuo - macchwsuo. */
|
|
|
|
/* mulchwu - mulchwu. */
|
2008-11-01 01:54:23 +01:00
|
|
|
tcg_gen_ext16u_tl(t0, cpu_gpr[ra]);
|
|
|
|
tcg_gen_shri_tl(t1, cpu_gpr[rb], 16);
|
|
|
|
tcg_gen_ext16u_tl(t1, t1);
|
2007-03-07 09:32:30 +01:00
|
|
|
break;
|
|
|
|
case 0x01:
|
|
|
|
/* machhw - machhw. - machhwo - machhwo. */
|
|
|
|
/* machhws - machhws. - machhwso - machhwso. */
|
|
|
|
/* nmachhw - nmachhw. - nmachhwo - nmachhwo. */
|
|
|
|
/* nmachhws - nmachhws. - nmachhwso - nmachhwso. */
|
|
|
|
/* mulhhw - mulhhw. */
|
2008-11-01 01:54:23 +01:00
|
|
|
tcg_gen_sari_tl(t0, cpu_gpr[ra], 16);
|
|
|
|
tcg_gen_ext16s_tl(t0, t0);
|
|
|
|
tcg_gen_sari_tl(t1, cpu_gpr[rb], 16);
|
|
|
|
tcg_gen_ext16s_tl(t1, t1);
|
2007-03-07 09:32:30 +01:00
|
|
|
break;
|
|
|
|
case 0x00:
|
|
|
|
/* machhwu - machhwu. - machhwuo - machhwuo. */
|
|
|
|
/* machhwsu - machhwsu. - machhwsuo - machhwsuo. */
|
|
|
|
/* mulhhwu - mulhhwu. */
|
2008-11-01 01:54:23 +01:00
|
|
|
tcg_gen_shri_tl(t0, cpu_gpr[ra], 16);
|
|
|
|
tcg_gen_ext16u_tl(t0, t0);
|
|
|
|
tcg_gen_shri_tl(t1, cpu_gpr[rb], 16);
|
|
|
|
tcg_gen_ext16u_tl(t1, t1);
|
2007-03-07 09:32:30 +01:00
|
|
|
break;
|
|
|
|
case 0x0D:
|
|
|
|
/* maclhw - maclhw. - maclhwo - maclhwo. */
|
|
|
|
/* maclhws - maclhws. - maclhwso - maclhwso. */
|
|
|
|
/* nmaclhw - nmaclhw. - nmaclhwo - nmaclhwo. */
|
|
|
|
/* nmaclhws - nmaclhws. - nmaclhwso - nmaclhwso. */
|
|
|
|
/* mullhw - mullhw. */
|
2008-11-01 01:54:23 +01:00
|
|
|
tcg_gen_ext16s_tl(t0, cpu_gpr[ra]);
|
|
|
|
tcg_gen_ext16s_tl(t1, cpu_gpr[rb]);
|
2007-03-07 09:32:30 +01:00
|
|
|
break;
|
|
|
|
case 0x0C:
|
|
|
|
/* maclhwu - maclhwu. - maclhwuo - maclhwuo. */
|
|
|
|
/* maclhwsu - maclhwsu. - maclhwsuo - maclhwsuo. */
|
|
|
|
/* mullhwu - mullhwu. */
|
2008-11-01 01:54:23 +01:00
|
|
|
tcg_gen_ext16u_tl(t0, cpu_gpr[ra]);
|
|
|
|
tcg_gen_ext16u_tl(t1, cpu_gpr[rb]);
|
2007-03-07 09:32:30 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (opc2 & 0x04) {
|
2008-11-01 01:54:23 +01:00
|
|
|
/* (n)multiply-and-accumulate (0x0C / 0x0E) */
|
|
|
|
tcg_gen_mul_tl(t1, t0, t1);
|
|
|
|
if (opc2 & 0x02) {
|
|
|
|
/* nmultiply-and-accumulate (0x0E) */
|
|
|
|
tcg_gen_sub_tl(t0, cpu_gpr[rt], t1);
|
|
|
|
} else {
|
|
|
|
/* multiply-and-accumulate (0x0C) */
|
|
|
|
tcg_gen_add_tl(t0, cpu_gpr[rt], t1);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (opc3 & 0x12) {
|
|
|
|
/* Check overflow and/or saturate */
|
2015-02-13 21:51:55 +01:00
|
|
|
TCGLabel *l1 = gen_new_label();
|
2008-11-01 01:54:23 +01:00
|
|
|
|
|
|
|
if (opc3 & 0x10) {
|
|
|
|
/* Start with XER OV disabled, the most likely case */
|
2013-02-20 08:52:13 +01:00
|
|
|
tcg_gen_movi_tl(cpu_ov, 0);
|
2008-11-01 01:54:23 +01:00
|
|
|
}
|
|
|
|
if (opc3 & 0x01) {
|
|
|
|
/* Signed */
|
|
|
|
tcg_gen_xor_tl(t1, cpu_gpr[rt], t1);
|
|
|
|
tcg_gen_brcondi_tl(TCG_COND_GE, t1, 0, l1);
|
|
|
|
tcg_gen_xor_tl(t1, cpu_gpr[rt], t0);
|
|
|
|
tcg_gen_brcondi_tl(TCG_COND_LT, t1, 0, l1);
|
2008-11-09 18:27:03 +01:00
|
|
|
if (opc3 & 0x02) {
|
2008-11-01 01:54:23 +01:00
|
|
|
/* Saturate */
|
|
|
|
tcg_gen_sari_tl(t0, cpu_gpr[rt], 31);
|
|
|
|
tcg_gen_xori_tl(t0, t0, 0x7fffffff);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
/* Unsigned */
|
|
|
|
tcg_gen_brcond_tl(TCG_COND_GEU, t0, t1, l1);
|
2008-11-09 18:27:03 +01:00
|
|
|
if (opc3 & 0x02) {
|
2008-11-01 01:54:23 +01:00
|
|
|
/* Saturate */
|
|
|
|
tcg_gen_movi_tl(t0, UINT32_MAX);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (opc3 & 0x10) {
|
|
|
|
/* Check overflow */
|
2013-02-20 08:52:13 +01:00
|
|
|
tcg_gen_movi_tl(cpu_ov, 1);
|
|
|
|
tcg_gen_movi_tl(cpu_so, 1);
|
2008-11-01 01:54:23 +01:00
|
|
|
}
|
|
|
|
gen_set_label(l1);
|
|
|
|
tcg_gen_mov_tl(cpu_gpr[rt], t0);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
tcg_gen_mul_tl(cpu_gpr[rt], t0, t1);
|
2007-03-07 09:32:30 +01:00
|
|
|
}
|
2008-11-01 01:54:23 +01:00
|
|
|
tcg_temp_free(t0);
|
|
|
|
tcg_temp_free(t1);
|
2007-03-07 09:32:30 +01:00
|
|
|
if (unlikely(Rc) != 0) {
|
|
|
|
/* Update Rc0 */
|
2008-11-01 01:54:23 +01:00
|
|
|
gen_set_Rc0(ctx, cpu_gpr[rt]);
|
2007-03-07 09:32:30 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
Great rework and cleanups to ease PowerPC implementations definitions.
* cleanup cpu.h, removing definitions used only in translate.c/translate_init.c
* add new flags to define instructions sets more precisely
* various changes in MMU models definitions
* add definitions for PowerPC 440/460 support (insns and SPRs).
* add definitions for PowerPC 401/403 and 620 input pins model
* Fix definitions for most PowerPC 401, 403, 405, 440, 601, 602, 603 and 7x0
* Preliminary support for PowerPC 74xx (aka G4) without altivec.
* Code provision for other PowerPC support (7x5, 970, ...).
* New SPR and PVR defined, from PowerPC 2.04 specification and other sources
* Misc code bugs, error messages and styles fixes.
* Update status files for PowerPC cores support.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3244 c046a42c-6fe2-441c-8c8c-71466251a162
2007-09-27 01:54:22 +02:00
|
|
|
#define GEN_MAC_HANDLER(name, opc2, opc3) \
|
2009-06-17 17:22:09 +02:00
|
|
|
static void glue(gen_, name)(DisasContext *ctx) \
|
2007-03-07 09:32:30 +01:00
|
|
|
{ \
|
|
|
|
gen_405_mulladd_insn(ctx, opc2, opc3, rA(ctx->opcode), rB(ctx->opcode), \
|
|
|
|
rD(ctx->opcode), Rc(ctx->opcode)); \
|
|
|
|
}
|
|
|
|
|
|
|
|
/* macchw - macchw. */
|
Great rework and cleanups to ease PowerPC implementations definitions.
* cleanup cpu.h, removing definitions used only in translate.c/translate_init.c
* add new flags to define instructions sets more precisely
* various changes in MMU models definitions
* add definitions for PowerPC 440/460 support (insns and SPRs).
* add definitions for PowerPC 401/403 and 620 input pins model
* Fix definitions for most PowerPC 401, 403, 405, 440, 601, 602, 603 and 7x0
* Preliminary support for PowerPC 74xx (aka G4) without altivec.
* Code provision for other PowerPC support (7x5, 970, ...).
* New SPR and PVR defined, from PowerPC 2.04 specification and other sources
* Misc code bugs, error messages and styles fixes.
* Update status files for PowerPC cores support.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3244 c046a42c-6fe2-441c-8c8c-71466251a162
2007-09-27 01:54:22 +02:00
|
|
|
GEN_MAC_HANDLER(macchw, 0x0C, 0x05);
|
2007-03-07 09:32:30 +01:00
|
|
|
/* macchwo - macchwo. */
|
Great rework and cleanups to ease PowerPC implementations definitions.
* cleanup cpu.h, removing definitions used only in translate.c/translate_init.c
* add new flags to define instructions sets more precisely
* various changes in MMU models definitions
* add definitions for PowerPC 440/460 support (insns and SPRs).
* add definitions for PowerPC 401/403 and 620 input pins model
* Fix definitions for most PowerPC 401, 403, 405, 440, 601, 602, 603 and 7x0
* Preliminary support for PowerPC 74xx (aka G4) without altivec.
* Code provision for other PowerPC support (7x5, 970, ...).
* New SPR and PVR defined, from PowerPC 2.04 specification and other sources
* Misc code bugs, error messages and styles fixes.
* Update status files for PowerPC cores support.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3244 c046a42c-6fe2-441c-8c8c-71466251a162
2007-09-27 01:54:22 +02:00
|
|
|
GEN_MAC_HANDLER(macchwo, 0x0C, 0x15);
|
2007-03-07 09:32:30 +01:00
|
|
|
/* macchws - macchws. */
|
Great rework and cleanups to ease PowerPC implementations definitions.
* cleanup cpu.h, removing definitions used only in translate.c/translate_init.c
* add new flags to define instructions sets more precisely
* various changes in MMU models definitions
* add definitions for PowerPC 440/460 support (insns and SPRs).
* add definitions for PowerPC 401/403 and 620 input pins model
* Fix definitions for most PowerPC 401, 403, 405, 440, 601, 602, 603 and 7x0
* Preliminary support for PowerPC 74xx (aka G4) without altivec.
* Code provision for other PowerPC support (7x5, 970, ...).
* New SPR and PVR defined, from PowerPC 2.04 specification and other sources
* Misc code bugs, error messages and styles fixes.
* Update status files for PowerPC cores support.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3244 c046a42c-6fe2-441c-8c8c-71466251a162
2007-09-27 01:54:22 +02:00
|
|
|
GEN_MAC_HANDLER(macchws, 0x0C, 0x07);
|
2007-03-07 09:32:30 +01:00
|
|
|
/* macchwso - macchwso. */
|
Great rework and cleanups to ease PowerPC implementations definitions.
* cleanup cpu.h, removing definitions used only in translate.c/translate_init.c
* add new flags to define instructions sets more precisely
* various changes in MMU models definitions
* add definitions for PowerPC 440/460 support (insns and SPRs).
* add definitions for PowerPC 401/403 and 620 input pins model
* Fix definitions for most PowerPC 401, 403, 405, 440, 601, 602, 603 and 7x0
* Preliminary support for PowerPC 74xx (aka G4) without altivec.
* Code provision for other PowerPC support (7x5, 970, ...).
* New SPR and PVR defined, from PowerPC 2.04 specification and other sources
* Misc code bugs, error messages and styles fixes.
* Update status files for PowerPC cores support.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3244 c046a42c-6fe2-441c-8c8c-71466251a162
2007-09-27 01:54:22 +02:00
|
|
|
GEN_MAC_HANDLER(macchwso, 0x0C, 0x17);
|
2007-03-07 09:32:30 +01:00
|
|
|
/* macchwsu - macchwsu. */
|
Great rework and cleanups to ease PowerPC implementations definitions.
* cleanup cpu.h, removing definitions used only in translate.c/translate_init.c
* add new flags to define instructions sets more precisely
* various changes in MMU models definitions
* add definitions for PowerPC 440/460 support (insns and SPRs).
* add definitions for PowerPC 401/403 and 620 input pins model
* Fix definitions for most PowerPC 401, 403, 405, 440, 601, 602, 603 and 7x0
* Preliminary support for PowerPC 74xx (aka G4) without altivec.
* Code provision for other PowerPC support (7x5, 970, ...).
* New SPR and PVR defined, from PowerPC 2.04 specification and other sources
* Misc code bugs, error messages and styles fixes.
* Update status files for PowerPC cores support.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3244 c046a42c-6fe2-441c-8c8c-71466251a162
2007-09-27 01:54:22 +02:00
|
|
|
GEN_MAC_HANDLER(macchwsu, 0x0C, 0x06);
|
2007-03-07 09:32:30 +01:00
|
|
|
/* macchwsuo - macchwsuo. */
|
Great rework and cleanups to ease PowerPC implementations definitions.
* cleanup cpu.h, removing definitions used only in translate.c/translate_init.c
* add new flags to define instructions sets more precisely
* various changes in MMU models definitions
* add definitions for PowerPC 440/460 support (insns and SPRs).
* add definitions for PowerPC 401/403 and 620 input pins model
* Fix definitions for most PowerPC 401, 403, 405, 440, 601, 602, 603 and 7x0
* Preliminary support for PowerPC 74xx (aka G4) without altivec.
* Code provision for other PowerPC support (7x5, 970, ...).
* New SPR and PVR defined, from PowerPC 2.04 specification and other sources
* Misc code bugs, error messages and styles fixes.
* Update status files for PowerPC cores support.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3244 c046a42c-6fe2-441c-8c8c-71466251a162
2007-09-27 01:54:22 +02:00
|
|
|
GEN_MAC_HANDLER(macchwsuo, 0x0C, 0x16);
|
2007-03-07 09:32:30 +01:00
|
|
|
/* macchwu - macchwu. */
|
Great rework and cleanups to ease PowerPC implementations definitions.
* cleanup cpu.h, removing definitions used only in translate.c/translate_init.c
* add new flags to define instructions sets more precisely
* various changes in MMU models definitions
* add definitions for PowerPC 440/460 support (insns and SPRs).
* add definitions for PowerPC 401/403 and 620 input pins model
* Fix definitions for most PowerPC 401, 403, 405, 440, 601, 602, 603 and 7x0
* Preliminary support for PowerPC 74xx (aka G4) without altivec.
* Code provision for other PowerPC support (7x5, 970, ...).
* New SPR and PVR defined, from PowerPC 2.04 specification and other sources
* Misc code bugs, error messages and styles fixes.
* Update status files for PowerPC cores support.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3244 c046a42c-6fe2-441c-8c8c-71466251a162
2007-09-27 01:54:22 +02:00
|
|
|
GEN_MAC_HANDLER(macchwu, 0x0C, 0x04);
|
2007-03-07 09:32:30 +01:00
|
|
|
/* macchwuo - macchwuo. */
|
Great rework and cleanups to ease PowerPC implementations definitions.
* cleanup cpu.h, removing definitions used only in translate.c/translate_init.c
* add new flags to define instructions sets more precisely
* various changes in MMU models definitions
* add definitions for PowerPC 440/460 support (insns and SPRs).
* add definitions for PowerPC 401/403 and 620 input pins model
* Fix definitions for most PowerPC 401, 403, 405, 440, 601, 602, 603 and 7x0
* Preliminary support for PowerPC 74xx (aka G4) without altivec.
* Code provision for other PowerPC support (7x5, 970, ...).
* New SPR and PVR defined, from PowerPC 2.04 specification and other sources
* Misc code bugs, error messages and styles fixes.
* Update status files for PowerPC cores support.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3244 c046a42c-6fe2-441c-8c8c-71466251a162
2007-09-27 01:54:22 +02:00
|
|
|
GEN_MAC_HANDLER(macchwuo, 0x0C, 0x14);
|
2007-03-07 09:32:30 +01:00
|
|
|
/* machhw - machhw. */
|
Great rework and cleanups to ease PowerPC implementations definitions.
* cleanup cpu.h, removing definitions used only in translate.c/translate_init.c
* add new flags to define instructions sets more precisely
* various changes in MMU models definitions
* add definitions for PowerPC 440/460 support (insns and SPRs).
* add definitions for PowerPC 401/403 and 620 input pins model
* Fix definitions for most PowerPC 401, 403, 405, 440, 601, 602, 603 and 7x0
* Preliminary support for PowerPC 74xx (aka G4) without altivec.
* Code provision for other PowerPC support (7x5, 970, ...).
* New SPR and PVR defined, from PowerPC 2.04 specification and other sources
* Misc code bugs, error messages and styles fixes.
* Update status files for PowerPC cores support.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3244 c046a42c-6fe2-441c-8c8c-71466251a162
2007-09-27 01:54:22 +02:00
|
|
|
GEN_MAC_HANDLER(machhw, 0x0C, 0x01);
|
2007-03-07 09:32:30 +01:00
|
|
|
/* machhwo - machhwo. */
|
Great rework and cleanups to ease PowerPC implementations definitions.
* cleanup cpu.h, removing definitions used only in translate.c/translate_init.c
* add new flags to define instructions sets more precisely
* various changes in MMU models definitions
* add definitions for PowerPC 440/460 support (insns and SPRs).
* add definitions for PowerPC 401/403 and 620 input pins model
* Fix definitions for most PowerPC 401, 403, 405, 440, 601, 602, 603 and 7x0
* Preliminary support for PowerPC 74xx (aka G4) without altivec.
* Code provision for other PowerPC support (7x5, 970, ...).
* New SPR and PVR defined, from PowerPC 2.04 specification and other sources
* Misc code bugs, error messages and styles fixes.
* Update status files for PowerPC cores support.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3244 c046a42c-6fe2-441c-8c8c-71466251a162
2007-09-27 01:54:22 +02:00
|
|
|
GEN_MAC_HANDLER(machhwo, 0x0C, 0x11);
|
2007-03-07 09:32:30 +01:00
|
|
|
/* machhws - machhws. */
|
Great rework and cleanups to ease PowerPC implementations definitions.
* cleanup cpu.h, removing definitions used only in translate.c/translate_init.c
* add new flags to define instructions sets more precisely
* various changes in MMU models definitions
* add definitions for PowerPC 440/460 support (insns and SPRs).
* add definitions for PowerPC 401/403 and 620 input pins model
* Fix definitions for most PowerPC 401, 403, 405, 440, 601, 602, 603 and 7x0
* Preliminary support for PowerPC 74xx (aka G4) without altivec.
* Code provision for other PowerPC support (7x5, 970, ...).
* New SPR and PVR defined, from PowerPC 2.04 specification and other sources
* Misc code bugs, error messages and styles fixes.
* Update status files for PowerPC cores support.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3244 c046a42c-6fe2-441c-8c8c-71466251a162
2007-09-27 01:54:22 +02:00
|
|
|
GEN_MAC_HANDLER(machhws, 0x0C, 0x03);
|
2007-03-07 09:32:30 +01:00
|
|
|
/* machhwso - machhwso. */
|
Great rework and cleanups to ease PowerPC implementations definitions.
* cleanup cpu.h, removing definitions used only in translate.c/translate_init.c
* add new flags to define instructions sets more precisely
* various changes in MMU models definitions
* add definitions for PowerPC 440/460 support (insns and SPRs).
* add definitions for PowerPC 401/403 and 620 input pins model
* Fix definitions for most PowerPC 401, 403, 405, 440, 601, 602, 603 and 7x0
* Preliminary support for PowerPC 74xx (aka G4) without altivec.
* Code provision for other PowerPC support (7x5, 970, ...).
* New SPR and PVR defined, from PowerPC 2.04 specification and other sources
* Misc code bugs, error messages and styles fixes.
* Update status files for PowerPC cores support.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3244 c046a42c-6fe2-441c-8c8c-71466251a162
2007-09-27 01:54:22 +02:00
|
|
|
GEN_MAC_HANDLER(machhwso, 0x0C, 0x13);
|
2007-03-07 09:32:30 +01:00
|
|
|
/* machhwsu - machhwsu. */
|
Great rework and cleanups to ease PowerPC implementations definitions.
* cleanup cpu.h, removing definitions used only in translate.c/translate_init.c
* add new flags to define instructions sets more precisely
* various changes in MMU models definitions
* add definitions for PowerPC 440/460 support (insns and SPRs).
* add definitions for PowerPC 401/403 and 620 input pins model
* Fix definitions for most PowerPC 401, 403, 405, 440, 601, 602, 603 and 7x0
* Preliminary support for PowerPC 74xx (aka G4) without altivec.
* Code provision for other PowerPC support (7x5, 970, ...).
* New SPR and PVR defined, from PowerPC 2.04 specification and other sources
* Misc code bugs, error messages and styles fixes.
* Update status files for PowerPC cores support.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3244 c046a42c-6fe2-441c-8c8c-71466251a162
2007-09-27 01:54:22 +02:00
|
|
|
GEN_MAC_HANDLER(machhwsu, 0x0C, 0x02);
|
2007-03-07 09:32:30 +01:00
|
|
|
/* machhwsuo - machhwsuo. */
|
Great rework and cleanups to ease PowerPC implementations definitions.
* cleanup cpu.h, removing definitions used only in translate.c/translate_init.c
* add new flags to define instructions sets more precisely
* various changes in MMU models definitions
* add definitions for PowerPC 440/460 support (insns and SPRs).
* add definitions for PowerPC 401/403 and 620 input pins model
* Fix definitions for most PowerPC 401, 403, 405, 440, 601, 602, 603 and 7x0
* Preliminary support for PowerPC 74xx (aka G4) without altivec.
* Code provision for other PowerPC support (7x5, 970, ...).
* New SPR and PVR defined, from PowerPC 2.04 specification and other sources
* Misc code bugs, error messages and styles fixes.
* Update status files for PowerPC cores support.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3244 c046a42c-6fe2-441c-8c8c-71466251a162
2007-09-27 01:54:22 +02:00
|
|
|
GEN_MAC_HANDLER(machhwsuo, 0x0C, 0x12);
|
2007-03-07 09:32:30 +01:00
|
|
|
/* machhwu - machhwu. */
|
Great rework and cleanups to ease PowerPC implementations definitions.
* cleanup cpu.h, removing definitions used only in translate.c/translate_init.c
* add new flags to define instructions sets more precisely
* various changes in MMU models definitions
* add definitions for PowerPC 440/460 support (insns and SPRs).
* add definitions for PowerPC 401/403 and 620 input pins model
* Fix definitions for most PowerPC 401, 403, 405, 440, 601, 602, 603 and 7x0
* Preliminary support for PowerPC 74xx (aka G4) without altivec.
* Code provision for other PowerPC support (7x5, 970, ...).
* New SPR and PVR defined, from PowerPC 2.04 specification and other sources
* Misc code bugs, error messages and styles fixes.
* Update status files for PowerPC cores support.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3244 c046a42c-6fe2-441c-8c8c-71466251a162
2007-09-27 01:54:22 +02:00
|
|
|
GEN_MAC_HANDLER(machhwu, 0x0C, 0x00);
|
2007-03-07 09:32:30 +01:00
|
|
|
/* machhwuo - machhwuo. */
|
Great rework and cleanups to ease PowerPC implementations definitions.
* cleanup cpu.h, removing definitions used only in translate.c/translate_init.c
* add new flags to define instructions sets more precisely
* various changes in MMU models definitions
* add definitions for PowerPC 440/460 support (insns and SPRs).
* add definitions for PowerPC 401/403 and 620 input pins model
* Fix definitions for most PowerPC 401, 403, 405, 440, 601, 602, 603 and 7x0
* Preliminary support for PowerPC 74xx (aka G4) without altivec.
* Code provision for other PowerPC support (7x5, 970, ...).
* New SPR and PVR defined, from PowerPC 2.04 specification and other sources
* Misc code bugs, error messages and styles fixes.
* Update status files for PowerPC cores support.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3244 c046a42c-6fe2-441c-8c8c-71466251a162
2007-09-27 01:54:22 +02:00
|
|
|
GEN_MAC_HANDLER(machhwuo, 0x0C, 0x10);
|
2007-03-07 09:32:30 +01:00
|
|
|
/* maclhw - maclhw. */
|
Great rework and cleanups to ease PowerPC implementations definitions.
* cleanup cpu.h, removing definitions used only in translate.c/translate_init.c
* add new flags to define instructions sets more precisely
* various changes in MMU models definitions
* add definitions for PowerPC 440/460 support (insns and SPRs).
* add definitions for PowerPC 401/403 and 620 input pins model
* Fix definitions for most PowerPC 401, 403, 405, 440, 601, 602, 603 and 7x0
* Preliminary support for PowerPC 74xx (aka G4) without altivec.
* Code provision for other PowerPC support (7x5, 970, ...).
* New SPR and PVR defined, from PowerPC 2.04 specification and other sources
* Misc code bugs, error messages and styles fixes.
* Update status files for PowerPC cores support.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3244 c046a42c-6fe2-441c-8c8c-71466251a162
2007-09-27 01:54:22 +02:00
|
|
|
GEN_MAC_HANDLER(maclhw, 0x0C, 0x0D);
|
2007-03-07 09:32:30 +01:00
|
|
|
/* maclhwo - maclhwo. */
|
Great rework and cleanups to ease PowerPC implementations definitions.
* cleanup cpu.h, removing definitions used only in translate.c/translate_init.c
* add new flags to define instructions sets more precisely
* various changes in MMU models definitions
* add definitions for PowerPC 440/460 support (insns and SPRs).
* add definitions for PowerPC 401/403 and 620 input pins model
* Fix definitions for most PowerPC 401, 403, 405, 440, 601, 602, 603 and 7x0
* Preliminary support for PowerPC 74xx (aka G4) without altivec.
* Code provision for other PowerPC support (7x5, 970, ...).
* New SPR and PVR defined, from PowerPC 2.04 specification and other sources
* Misc code bugs, error messages and styles fixes.
* Update status files for PowerPC cores support.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3244 c046a42c-6fe2-441c-8c8c-71466251a162
2007-09-27 01:54:22 +02:00
|
|
|
GEN_MAC_HANDLER(maclhwo, 0x0C, 0x1D);
|
2007-03-07 09:32:30 +01:00
|
|
|
/* maclhws - maclhws. */
|
Great rework and cleanups to ease PowerPC implementations definitions.
* cleanup cpu.h, removing definitions used only in translate.c/translate_init.c
* add new flags to define instructions sets more precisely
* various changes in MMU models definitions
* add definitions for PowerPC 440/460 support (insns and SPRs).
* add definitions for PowerPC 401/403 and 620 input pins model
* Fix definitions for most PowerPC 401, 403, 405, 440, 601, 602, 603 and 7x0
* Preliminary support for PowerPC 74xx (aka G4) without altivec.
* Code provision for other PowerPC support (7x5, 970, ...).
* New SPR and PVR defined, from PowerPC 2.04 specification and other sources
* Misc code bugs, error messages and styles fixes.
* Update status files for PowerPC cores support.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3244 c046a42c-6fe2-441c-8c8c-71466251a162
2007-09-27 01:54:22 +02:00
|
|
|
GEN_MAC_HANDLER(maclhws, 0x0C, 0x0F);
|
2007-03-07 09:32:30 +01:00
|
|
|
/* maclhwso - maclhwso. */
|
Great rework and cleanups to ease PowerPC implementations definitions.
* cleanup cpu.h, removing definitions used only in translate.c/translate_init.c
* add new flags to define instructions sets more precisely
* various changes in MMU models definitions
* add definitions for PowerPC 440/460 support (insns and SPRs).
* add definitions for PowerPC 401/403 and 620 input pins model
* Fix definitions for most PowerPC 401, 403, 405, 440, 601, 602, 603 and 7x0
* Preliminary support for PowerPC 74xx (aka G4) without altivec.
* Code provision for other PowerPC support (7x5, 970, ...).
* New SPR and PVR defined, from PowerPC 2.04 specification and other sources
* Misc code bugs, error messages and styles fixes.
* Update status files for PowerPC cores support.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3244 c046a42c-6fe2-441c-8c8c-71466251a162
2007-09-27 01:54:22 +02:00
|
|
|
GEN_MAC_HANDLER(maclhwso, 0x0C, 0x1F);
|
2007-03-07 09:32:30 +01:00
|
|
|
/* maclhwu - maclhwu. */
|
Great rework and cleanups to ease PowerPC implementations definitions.
* cleanup cpu.h, removing definitions used only in translate.c/translate_init.c
* add new flags to define instructions sets more precisely
* various changes in MMU models definitions
* add definitions for PowerPC 440/460 support (insns and SPRs).
* add definitions for PowerPC 401/403 and 620 input pins model
* Fix definitions for most PowerPC 401, 403, 405, 440, 601, 602, 603 and 7x0
* Preliminary support for PowerPC 74xx (aka G4) without altivec.
* Code provision for other PowerPC support (7x5, 970, ...).
* New SPR and PVR defined, from PowerPC 2.04 specification and other sources
* Misc code bugs, error messages and styles fixes.
* Update status files for PowerPC cores support.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3244 c046a42c-6fe2-441c-8c8c-71466251a162
2007-09-27 01:54:22 +02:00
|
|
|
GEN_MAC_HANDLER(maclhwu, 0x0C, 0x0C);
|
2007-03-07 09:32:30 +01:00
|
|
|
/* maclhwuo - maclhwuo. */
|
Great rework and cleanups to ease PowerPC implementations definitions.
* cleanup cpu.h, removing definitions used only in translate.c/translate_init.c
* add new flags to define instructions sets more precisely
* various changes in MMU models definitions
* add definitions for PowerPC 440/460 support (insns and SPRs).
* add definitions for PowerPC 401/403 and 620 input pins model
* Fix definitions for most PowerPC 401, 403, 405, 440, 601, 602, 603 and 7x0
* Preliminary support for PowerPC 74xx (aka G4) without altivec.
* Code provision for other PowerPC support (7x5, 970, ...).
* New SPR and PVR defined, from PowerPC 2.04 specification and other sources
* Misc code bugs, error messages and styles fixes.
* Update status files for PowerPC cores support.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3244 c046a42c-6fe2-441c-8c8c-71466251a162
2007-09-27 01:54:22 +02:00
|
|
|
GEN_MAC_HANDLER(maclhwuo, 0x0C, 0x1C);
|
2007-03-07 09:32:30 +01:00
|
|
|
/* maclhwsu - maclhwsu. */
|
Great rework and cleanups to ease PowerPC implementations definitions.
* cleanup cpu.h, removing definitions used only in translate.c/translate_init.c
* add new flags to define instructions sets more precisely
* various changes in MMU models definitions
* add definitions for PowerPC 440/460 support (insns and SPRs).
* add definitions for PowerPC 401/403 and 620 input pins model
* Fix definitions for most PowerPC 401, 403, 405, 440, 601, 602, 603 and 7x0
* Preliminary support for PowerPC 74xx (aka G4) without altivec.
* Code provision for other PowerPC support (7x5, 970, ...).
* New SPR and PVR defined, from PowerPC 2.04 specification and other sources
* Misc code bugs, error messages and styles fixes.
* Update status files for PowerPC cores support.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3244 c046a42c-6fe2-441c-8c8c-71466251a162
2007-09-27 01:54:22 +02:00
|
|
|
GEN_MAC_HANDLER(maclhwsu, 0x0C, 0x0E);
|
2007-03-07 09:32:30 +01:00
|
|
|
/* maclhwsuo - maclhwsuo. */
|
Great rework and cleanups to ease PowerPC implementations definitions.
* cleanup cpu.h, removing definitions used only in translate.c/translate_init.c
* add new flags to define instructions sets more precisely
* various changes in MMU models definitions
* add definitions for PowerPC 440/460 support (insns and SPRs).
* add definitions for PowerPC 401/403 and 620 input pins model
* Fix definitions for most PowerPC 401, 403, 405, 440, 601, 602, 603 and 7x0
* Preliminary support for PowerPC 74xx (aka G4) without altivec.
* Code provision for other PowerPC support (7x5, 970, ...).
* New SPR and PVR defined, from PowerPC 2.04 specification and other sources
* Misc code bugs, error messages and styles fixes.
* Update status files for PowerPC cores support.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3244 c046a42c-6fe2-441c-8c8c-71466251a162
2007-09-27 01:54:22 +02:00
|
|
|
GEN_MAC_HANDLER(maclhwsuo, 0x0C, 0x1E);
|
2007-03-07 09:32:30 +01:00
|
|
|
/* nmacchw - nmacchw. */
|
Great rework and cleanups to ease PowerPC implementations definitions.
* cleanup cpu.h, removing definitions used only in translate.c/translate_init.c
* add new flags to define instructions sets more precisely
* various changes in MMU models definitions
* add definitions for PowerPC 440/460 support (insns and SPRs).
* add definitions for PowerPC 401/403 and 620 input pins model
* Fix definitions for most PowerPC 401, 403, 405, 440, 601, 602, 603 and 7x0
* Preliminary support for PowerPC 74xx (aka G4) without altivec.
* Code provision for other PowerPC support (7x5, 970, ...).
* New SPR and PVR defined, from PowerPC 2.04 specification and other sources
* Misc code bugs, error messages and styles fixes.
* Update status files for PowerPC cores support.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3244 c046a42c-6fe2-441c-8c8c-71466251a162
2007-09-27 01:54:22 +02:00
|
|
|
GEN_MAC_HANDLER(nmacchw, 0x0E, 0x05);
|
2007-03-07 09:32:30 +01:00
|
|
|
/* nmacchwo - nmacchwo. */
|
Great rework and cleanups to ease PowerPC implementations definitions.
* cleanup cpu.h, removing definitions used only in translate.c/translate_init.c
* add new flags to define instructions sets more precisely
* various changes in MMU models definitions
* add definitions for PowerPC 440/460 support (insns and SPRs).
* add definitions for PowerPC 401/403 and 620 input pins model
* Fix definitions for most PowerPC 401, 403, 405, 440, 601, 602, 603 and 7x0
* Preliminary support for PowerPC 74xx (aka G4) without altivec.
* Code provision for other PowerPC support (7x5, 970, ...).
* New SPR and PVR defined, from PowerPC 2.04 specification and other sources
* Misc code bugs, error messages and styles fixes.
* Update status files for PowerPC cores support.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3244 c046a42c-6fe2-441c-8c8c-71466251a162
2007-09-27 01:54:22 +02:00
|
|
|
GEN_MAC_HANDLER(nmacchwo, 0x0E, 0x15);
|
2007-03-07 09:32:30 +01:00
|
|
|
/* nmacchws - nmacchws. */
|
Great rework and cleanups to ease PowerPC implementations definitions.
* cleanup cpu.h, removing definitions used only in translate.c/translate_init.c
* add new flags to define instructions sets more precisely
* various changes in MMU models definitions
* add definitions for PowerPC 440/460 support (insns and SPRs).
* add definitions for PowerPC 401/403 and 620 input pins model
* Fix definitions for most PowerPC 401, 403, 405, 440, 601, 602, 603 and 7x0
* Preliminary support for PowerPC 74xx (aka G4) without altivec.
* Code provision for other PowerPC support (7x5, 970, ...).
* New SPR and PVR defined, from PowerPC 2.04 specification and other sources
* Misc code bugs, error messages and styles fixes.
* Update status files for PowerPC cores support.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3244 c046a42c-6fe2-441c-8c8c-71466251a162
2007-09-27 01:54:22 +02:00
|
|
|
GEN_MAC_HANDLER(nmacchws, 0x0E, 0x07);
|
2007-03-07 09:32:30 +01:00
|
|
|
/* nmacchwso - nmacchwso. */
|
Great rework and cleanups to ease PowerPC implementations definitions.
* cleanup cpu.h, removing definitions used only in translate.c/translate_init.c
* add new flags to define instructions sets more precisely
* various changes in MMU models definitions
* add definitions for PowerPC 440/460 support (insns and SPRs).
* add definitions for PowerPC 401/403 and 620 input pins model
* Fix definitions for most PowerPC 401, 403, 405, 440, 601, 602, 603 and 7x0
* Preliminary support for PowerPC 74xx (aka G4) without altivec.
* Code provision for other PowerPC support (7x5, 970, ...).
* New SPR and PVR defined, from PowerPC 2.04 specification and other sources
* Misc code bugs, error messages and styles fixes.
* Update status files for PowerPC cores support.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3244 c046a42c-6fe2-441c-8c8c-71466251a162
2007-09-27 01:54:22 +02:00
|
|
|
GEN_MAC_HANDLER(nmacchwso, 0x0E, 0x17);
|
2007-03-07 09:32:30 +01:00
|
|
|
/* nmachhw - nmachhw. */
|
Great rework and cleanups to ease PowerPC implementations definitions.
* cleanup cpu.h, removing definitions used only in translate.c/translate_init.c
* add new flags to define instructions sets more precisely
* various changes in MMU models definitions
* add definitions for PowerPC 440/460 support (insns and SPRs).
* add definitions for PowerPC 401/403 and 620 input pins model
* Fix definitions for most PowerPC 401, 403, 405, 440, 601, 602, 603 and 7x0
* Preliminary support for PowerPC 74xx (aka G4) without altivec.
* Code provision for other PowerPC support (7x5, 970, ...).
* New SPR and PVR defined, from PowerPC 2.04 specification and other sources
* Misc code bugs, error messages and styles fixes.
* Update status files for PowerPC cores support.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3244 c046a42c-6fe2-441c-8c8c-71466251a162
2007-09-27 01:54:22 +02:00
|
|
|
GEN_MAC_HANDLER(nmachhw, 0x0E, 0x01);
|
2007-03-07 09:32:30 +01:00
|
|
|
/* nmachhwo - nmachhwo. */
|
Great rework and cleanups to ease PowerPC implementations definitions.
* cleanup cpu.h, removing definitions used only in translate.c/translate_init.c
* add new flags to define instructions sets more precisely
* various changes in MMU models definitions
* add definitions for PowerPC 440/460 support (insns and SPRs).
* add definitions for PowerPC 401/403 and 620 input pins model
* Fix definitions for most PowerPC 401, 403, 405, 440, 601, 602, 603 and 7x0
* Preliminary support for PowerPC 74xx (aka G4) without altivec.
* Code provision for other PowerPC support (7x5, 970, ...).
* New SPR and PVR defined, from PowerPC 2.04 specification and other sources
* Misc code bugs, error messages and styles fixes.
* Update status files for PowerPC cores support.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3244 c046a42c-6fe2-441c-8c8c-71466251a162
2007-09-27 01:54:22 +02:00
|
|
|
GEN_MAC_HANDLER(nmachhwo, 0x0E, 0x11);
|
2007-03-07 09:32:30 +01:00
|
|
|
/* nmachhws - nmachhws. */
|
Great rework and cleanups to ease PowerPC implementations definitions.
* cleanup cpu.h, removing definitions used only in translate.c/translate_init.c
* add new flags to define instructions sets more precisely
* various changes in MMU models definitions
* add definitions for PowerPC 440/460 support (insns and SPRs).
* add definitions for PowerPC 401/403 and 620 input pins model
* Fix definitions for most PowerPC 401, 403, 405, 440, 601, 602, 603 and 7x0
* Preliminary support for PowerPC 74xx (aka G4) without altivec.
* Code provision for other PowerPC support (7x5, 970, ...).
* New SPR and PVR defined, from PowerPC 2.04 specification and other sources
* Misc code bugs, error messages and styles fixes.
* Update status files for PowerPC cores support.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3244 c046a42c-6fe2-441c-8c8c-71466251a162
2007-09-27 01:54:22 +02:00
|
|
|
GEN_MAC_HANDLER(nmachhws, 0x0E, 0x03);
|
2007-03-07 09:32:30 +01:00
|
|
|
/* nmachhwso - nmachhwso. */
|
Great rework and cleanups to ease PowerPC implementations definitions.
* cleanup cpu.h, removing definitions used only in translate.c/translate_init.c
* add new flags to define instructions sets more precisely
* various changes in MMU models definitions
* add definitions for PowerPC 440/460 support (insns and SPRs).
* add definitions for PowerPC 401/403 and 620 input pins model
* Fix definitions for most PowerPC 401, 403, 405, 440, 601, 602, 603 and 7x0
* Preliminary support for PowerPC 74xx (aka G4) without altivec.
* Code provision for other PowerPC support (7x5, 970, ...).
* New SPR and PVR defined, from PowerPC 2.04 specification and other sources
* Misc code bugs, error messages and styles fixes.
* Update status files for PowerPC cores support.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3244 c046a42c-6fe2-441c-8c8c-71466251a162
2007-09-27 01:54:22 +02:00
|
|
|
GEN_MAC_HANDLER(nmachhwso, 0x0E, 0x13);
|
2007-03-07 09:32:30 +01:00
|
|
|
/* nmaclhw - nmaclhw. */
|
Great rework and cleanups to ease PowerPC implementations definitions.
* cleanup cpu.h, removing definitions used only in translate.c/translate_init.c
* add new flags to define instructions sets more precisely
* various changes in MMU models definitions
* add definitions for PowerPC 440/460 support (insns and SPRs).
* add definitions for PowerPC 401/403 and 620 input pins model
* Fix definitions for most PowerPC 401, 403, 405, 440, 601, 602, 603 and 7x0
* Preliminary support for PowerPC 74xx (aka G4) without altivec.
* Code provision for other PowerPC support (7x5, 970, ...).
* New SPR and PVR defined, from PowerPC 2.04 specification and other sources
* Misc code bugs, error messages and styles fixes.
* Update status files for PowerPC cores support.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3244 c046a42c-6fe2-441c-8c8c-71466251a162
2007-09-27 01:54:22 +02:00
|
|
|
GEN_MAC_HANDLER(nmaclhw, 0x0E, 0x0D);
|
2007-03-07 09:32:30 +01:00
|
|
|
/* nmaclhwo - nmaclhwo. */
|
Great rework and cleanups to ease PowerPC implementations definitions.
* cleanup cpu.h, removing definitions used only in translate.c/translate_init.c
* add new flags to define instructions sets more precisely
* various changes in MMU models definitions
* add definitions for PowerPC 440/460 support (insns and SPRs).
* add definitions for PowerPC 401/403 and 620 input pins model
* Fix definitions for most PowerPC 401, 403, 405, 440, 601, 602, 603 and 7x0
* Preliminary support for PowerPC 74xx (aka G4) without altivec.
* Code provision for other PowerPC support (7x5, 970, ...).
* New SPR and PVR defined, from PowerPC 2.04 specification and other sources
* Misc code bugs, error messages and styles fixes.
* Update status files for PowerPC cores support.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3244 c046a42c-6fe2-441c-8c8c-71466251a162
2007-09-27 01:54:22 +02:00
|
|
|
GEN_MAC_HANDLER(nmaclhwo, 0x0E, 0x1D);
|
2007-03-07 09:32:30 +01:00
|
|
|
/* nmaclhws - nmaclhws. */
|
Great rework and cleanups to ease PowerPC implementations definitions.
* cleanup cpu.h, removing definitions used only in translate.c/translate_init.c
* add new flags to define instructions sets more precisely
* various changes in MMU models definitions
* add definitions for PowerPC 440/460 support (insns and SPRs).
* add definitions for PowerPC 401/403 and 620 input pins model
* Fix definitions for most PowerPC 401, 403, 405, 440, 601, 602, 603 and 7x0
* Preliminary support for PowerPC 74xx (aka G4) without altivec.
* Code provision for other PowerPC support (7x5, 970, ...).
* New SPR and PVR defined, from PowerPC 2.04 specification and other sources
* Misc code bugs, error messages and styles fixes.
* Update status files for PowerPC cores support.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3244 c046a42c-6fe2-441c-8c8c-71466251a162
2007-09-27 01:54:22 +02:00
|
|
|
GEN_MAC_HANDLER(nmaclhws, 0x0E, 0x0F);
|
2007-03-07 09:32:30 +01:00
|
|
|
/* nmaclhwso - nmaclhwso. */
|
Great rework and cleanups to ease PowerPC implementations definitions.
* cleanup cpu.h, removing definitions used only in translate.c/translate_init.c
* add new flags to define instructions sets more precisely
* various changes in MMU models definitions
* add definitions for PowerPC 440/460 support (insns and SPRs).
* add definitions for PowerPC 401/403 and 620 input pins model
* Fix definitions for most PowerPC 401, 403, 405, 440, 601, 602, 603 and 7x0
* Preliminary support for PowerPC 74xx (aka G4) without altivec.
* Code provision for other PowerPC support (7x5, 970, ...).
* New SPR and PVR defined, from PowerPC 2.04 specification and other sources
* Misc code bugs, error messages and styles fixes.
* Update status files for PowerPC cores support.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3244 c046a42c-6fe2-441c-8c8c-71466251a162
2007-09-27 01:54:22 +02:00
|
|
|
GEN_MAC_HANDLER(nmaclhwso, 0x0E, 0x1F);
|
2007-03-07 09:32:30 +01:00
|
|
|
|
|
|
|
/* mulchw - mulchw. */
|
Great rework and cleanups to ease PowerPC implementations definitions.
* cleanup cpu.h, removing definitions used only in translate.c/translate_init.c
* add new flags to define instructions sets more precisely
* various changes in MMU models definitions
* add definitions for PowerPC 440/460 support (insns and SPRs).
* add definitions for PowerPC 401/403 and 620 input pins model
* Fix definitions for most PowerPC 401, 403, 405, 440, 601, 602, 603 and 7x0
* Preliminary support for PowerPC 74xx (aka G4) without altivec.
* Code provision for other PowerPC support (7x5, 970, ...).
* New SPR and PVR defined, from PowerPC 2.04 specification and other sources
* Misc code bugs, error messages and styles fixes.
* Update status files for PowerPC cores support.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3244 c046a42c-6fe2-441c-8c8c-71466251a162
2007-09-27 01:54:22 +02:00
|
|
|
GEN_MAC_HANDLER(mulchw, 0x08, 0x05);
|
2007-03-07 09:32:30 +01:00
|
|
|
/* mulchwu - mulchwu. */
|
Great rework and cleanups to ease PowerPC implementations definitions.
* cleanup cpu.h, removing definitions used only in translate.c/translate_init.c
* add new flags to define instructions sets more precisely
* various changes in MMU models definitions
* add definitions for PowerPC 440/460 support (insns and SPRs).
* add definitions for PowerPC 401/403 and 620 input pins model
* Fix definitions for most PowerPC 401, 403, 405, 440, 601, 602, 603 and 7x0
* Preliminary support for PowerPC 74xx (aka G4) without altivec.
* Code provision for other PowerPC support (7x5, 970, ...).
* New SPR and PVR defined, from PowerPC 2.04 specification and other sources
* Misc code bugs, error messages and styles fixes.
* Update status files for PowerPC cores support.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3244 c046a42c-6fe2-441c-8c8c-71466251a162
2007-09-27 01:54:22 +02:00
|
|
|
GEN_MAC_HANDLER(mulchwu, 0x08, 0x04);
|
2007-03-07 09:32:30 +01:00
|
|
|
/* mulhhw - mulhhw. */
|
Great rework and cleanups to ease PowerPC implementations definitions.
* cleanup cpu.h, removing definitions used only in translate.c/translate_init.c
* add new flags to define instructions sets more precisely
* various changes in MMU models definitions
* add definitions for PowerPC 440/460 support (insns and SPRs).
* add definitions for PowerPC 401/403 and 620 input pins model
* Fix definitions for most PowerPC 401, 403, 405, 440, 601, 602, 603 and 7x0
* Preliminary support for PowerPC 74xx (aka G4) without altivec.
* Code provision for other PowerPC support (7x5, 970, ...).
* New SPR and PVR defined, from PowerPC 2.04 specification and other sources
* Misc code bugs, error messages and styles fixes.
* Update status files for PowerPC cores support.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3244 c046a42c-6fe2-441c-8c8c-71466251a162
2007-09-27 01:54:22 +02:00
|
|
|
GEN_MAC_HANDLER(mulhhw, 0x08, 0x01);
|
2007-03-07 09:32:30 +01:00
|
|
|
/* mulhhwu - mulhhwu. */
|
Great rework and cleanups to ease PowerPC implementations definitions.
* cleanup cpu.h, removing definitions used only in translate.c/translate_init.c
* add new flags to define instructions sets more precisely
* various changes in MMU models definitions
* add definitions for PowerPC 440/460 support (insns and SPRs).
* add definitions for PowerPC 401/403 and 620 input pins model
* Fix definitions for most PowerPC 401, 403, 405, 440, 601, 602, 603 and 7x0
* Preliminary support for PowerPC 74xx (aka G4) without altivec.
* Code provision for other PowerPC support (7x5, 970, ...).
* New SPR and PVR defined, from PowerPC 2.04 specification and other sources
* Misc code bugs, error messages and styles fixes.
* Update status files for PowerPC cores support.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3244 c046a42c-6fe2-441c-8c8c-71466251a162
2007-09-27 01:54:22 +02:00
|
|
|
GEN_MAC_HANDLER(mulhhwu, 0x08, 0x00);
|
2007-03-07 09:32:30 +01:00
|
|
|
/* mullhw - mullhw. */
|
Great rework and cleanups to ease PowerPC implementations definitions.
* cleanup cpu.h, removing definitions used only in translate.c/translate_init.c
* add new flags to define instructions sets more precisely
* various changes in MMU models definitions
* add definitions for PowerPC 440/460 support (insns and SPRs).
* add definitions for PowerPC 401/403 and 620 input pins model
* Fix definitions for most PowerPC 401, 403, 405, 440, 601, 602, 603 and 7x0
* Preliminary support for PowerPC 74xx (aka G4) without altivec.
* Code provision for other PowerPC support (7x5, 970, ...).
* New SPR and PVR defined, from PowerPC 2.04 specification and other sources
* Misc code bugs, error messages and styles fixes.
* Update status files for PowerPC cores support.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3244 c046a42c-6fe2-441c-8c8c-71466251a162
2007-09-27 01:54:22 +02:00
|
|
|
GEN_MAC_HANDLER(mullhw, 0x08, 0x0D);
|
2007-03-07 09:32:30 +01:00
|
|
|
/* mullhwu - mullhwu. */
|
Great rework and cleanups to ease PowerPC implementations definitions.
* cleanup cpu.h, removing definitions used only in translate.c/translate_init.c
* add new flags to define instructions sets more precisely
* various changes in MMU models definitions
* add definitions for PowerPC 440/460 support (insns and SPRs).
* add definitions for PowerPC 401/403 and 620 input pins model
* Fix definitions for most PowerPC 401, 403, 405, 440, 601, 602, 603 and 7x0
* Preliminary support for PowerPC 74xx (aka G4) without altivec.
* Code provision for other PowerPC support (7x5, 970, ...).
* New SPR and PVR defined, from PowerPC 2.04 specification and other sources
* Misc code bugs, error messages and styles fixes.
* Update status files for PowerPC cores support.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3244 c046a42c-6fe2-441c-8c8c-71466251a162
2007-09-27 01:54:22 +02:00
|
|
|
GEN_MAC_HANDLER(mullhwu, 0x08, 0x0C);
|
2007-03-07 09:32:30 +01:00
|
|
|
|
|
|
|
/* mfdcr */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_mfdcr(DisasContext *ctx)
|
2007-03-07 09:32:30 +01:00
|
|
|
{
|
|
|
|
#if defined(CONFIG_USER_ONLY)
|
2016-06-21 23:48:51 +02:00
|
|
|
GEN_PRIV;
|
2007-03-07 09:32:30 +01:00
|
|
|
#else
|
2008-12-06 17:37:18 +01:00
|
|
|
TCGv dcrn;
|
2016-06-21 23:48:51 +02:00
|
|
|
|
|
|
|
CHK_SV;
|
2008-12-06 17:37:18 +01:00
|
|
|
dcrn = tcg_const_tl(SPR(ctx->opcode));
|
2012-05-30 06:23:36 +02:00
|
|
|
gen_helper_load_dcr(cpu_gpr[rD(ctx->opcode)], cpu_env, dcrn);
|
2008-12-06 17:37:18 +01:00
|
|
|
tcg_temp_free(dcrn);
|
2016-06-21 23:48:51 +02:00
|
|
|
#endif /* defined(CONFIG_USER_ONLY) */
|
2007-03-07 09:32:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* mtdcr */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_mtdcr(DisasContext *ctx)
|
2007-03-07 09:32:30 +01:00
|
|
|
{
|
|
|
|
#if defined(CONFIG_USER_ONLY)
|
2016-06-21 23:48:51 +02:00
|
|
|
GEN_PRIV;
|
2007-03-07 09:32:30 +01:00
|
|
|
#else
|
2008-12-06 17:37:18 +01:00
|
|
|
TCGv dcrn;
|
2016-06-21 23:48:51 +02:00
|
|
|
|
|
|
|
CHK_SV;
|
2008-12-06 17:37:18 +01:00
|
|
|
dcrn = tcg_const_tl(SPR(ctx->opcode));
|
2012-05-30 06:23:36 +02:00
|
|
|
gen_helper_store_dcr(cpu_env, dcrn, cpu_gpr[rS(ctx->opcode)]);
|
2008-12-06 17:37:18 +01:00
|
|
|
tcg_temp_free(dcrn);
|
2016-06-21 23:48:51 +02:00
|
|
|
#endif /* defined(CONFIG_USER_ONLY) */
|
2007-03-30 12:22:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* mfdcrx */
|
2007-09-21 07:50:37 +02:00
|
|
|
/* XXX: not implemented on 440 ? */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_mfdcrx(DisasContext *ctx)
|
2007-03-30 12:22:46 +02:00
|
|
|
{
|
|
|
|
#if defined(CONFIG_USER_ONLY)
|
2016-06-21 23:48:51 +02:00
|
|
|
GEN_PRIV;
|
2007-03-30 12:22:46 +02:00
|
|
|
#else
|
2016-06-21 23:48:51 +02:00
|
|
|
CHK_SV;
|
2012-05-30 06:23:36 +02:00
|
|
|
gen_helper_load_dcr(cpu_gpr[rD(ctx->opcode)], cpu_env,
|
|
|
|
cpu_gpr[rA(ctx->opcode)]);
|
Great rework and cleanups to ease PowerPC implementations definitions.
* cleanup cpu.h, removing definitions used only in translate.c/translate_init.c
* add new flags to define instructions sets more precisely
* various changes in MMU models definitions
* add definitions for PowerPC 440/460 support (insns and SPRs).
* add definitions for PowerPC 401/403 and 620 input pins model
* Fix definitions for most PowerPC 401, 403, 405, 440, 601, 602, 603 and 7x0
* Preliminary support for PowerPC 74xx (aka G4) without altivec.
* Code provision for other PowerPC support (7x5, 970, ...).
* New SPR and PVR defined, from PowerPC 2.04 specification and other sources
* Misc code bugs, error messages and styles fixes.
* Update status files for PowerPC cores support.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3244 c046a42c-6fe2-441c-8c8c-71466251a162
2007-09-27 01:54:22 +02:00
|
|
|
/* Note: Rc update flag set leads to undefined state of Rc0 */
|
2016-06-21 23:48:51 +02:00
|
|
|
#endif /* defined(CONFIG_USER_ONLY) */
|
2007-03-30 12:22:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* mtdcrx */
|
2007-09-21 07:50:37 +02:00
|
|
|
/* XXX: not implemented on 440 ? */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_mtdcrx(DisasContext *ctx)
|
2007-03-30 12:22:46 +02:00
|
|
|
{
|
|
|
|
#if defined(CONFIG_USER_ONLY)
|
2016-06-21 23:48:51 +02:00
|
|
|
GEN_PRIV;
|
2007-03-30 12:22:46 +02:00
|
|
|
#else
|
2016-06-21 23:48:51 +02:00
|
|
|
CHK_SV;
|
2012-05-30 06:23:36 +02:00
|
|
|
gen_helper_store_dcr(cpu_env, cpu_gpr[rA(ctx->opcode)],
|
|
|
|
cpu_gpr[rS(ctx->opcode)]);
|
Great rework and cleanups to ease PowerPC implementations definitions.
* cleanup cpu.h, removing definitions used only in translate.c/translate_init.c
* add new flags to define instructions sets more precisely
* various changes in MMU models definitions
* add definitions for PowerPC 440/460 support (insns and SPRs).
* add definitions for PowerPC 401/403 and 620 input pins model
* Fix definitions for most PowerPC 401, 403, 405, 440, 601, 602, 603 and 7x0
* Preliminary support for PowerPC 74xx (aka G4) without altivec.
* Code provision for other PowerPC support (7x5, 970, ...).
* New SPR and PVR defined, from PowerPC 2.04 specification and other sources
* Misc code bugs, error messages and styles fixes.
* Update status files for PowerPC cores support.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3244 c046a42c-6fe2-441c-8c8c-71466251a162
2007-09-27 01:54:22 +02:00
|
|
|
/* Note: Rc update flag set leads to undefined state of Rc0 */
|
2016-06-21 23:48:51 +02:00
|
|
|
#endif /* defined(CONFIG_USER_ONLY) */
|
2007-03-07 09:32:30 +01:00
|
|
|
}
|
|
|
|
|
Great rework and cleanups to ease PowerPC implementations definitions.
* cleanup cpu.h, removing definitions used only in translate.c/translate_init.c
* add new flags to define instructions sets more precisely
* various changes in MMU models definitions
* add definitions for PowerPC 440/460 support (insns and SPRs).
* add definitions for PowerPC 401/403 and 620 input pins model
* Fix definitions for most PowerPC 401, 403, 405, 440, 601, 602, 603 and 7x0
* Preliminary support for PowerPC 74xx (aka G4) without altivec.
* Code provision for other PowerPC support (7x5, 970, ...).
* New SPR and PVR defined, from PowerPC 2.04 specification and other sources
* Misc code bugs, error messages and styles fixes.
* Update status files for PowerPC cores support.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3244 c046a42c-6fe2-441c-8c8c-71466251a162
2007-09-27 01:54:22 +02:00
|
|
|
/* mfdcrux (PPC 460) : user-mode access to DCR */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_mfdcrux(DisasContext *ctx)
|
Great rework and cleanups to ease PowerPC implementations definitions.
* cleanup cpu.h, removing definitions used only in translate.c/translate_init.c
* add new flags to define instructions sets more precisely
* various changes in MMU models definitions
* add definitions for PowerPC 440/460 support (insns and SPRs).
* add definitions for PowerPC 401/403 and 620 input pins model
* Fix definitions for most PowerPC 401, 403, 405, 440, 601, 602, 603 and 7x0
* Preliminary support for PowerPC 74xx (aka G4) without altivec.
* Code provision for other PowerPC support (7x5, 970, ...).
* New SPR and PVR defined, from PowerPC 2.04 specification and other sources
* Misc code bugs, error messages and styles fixes.
* Update status files for PowerPC cores support.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3244 c046a42c-6fe2-441c-8c8c-71466251a162
2007-09-27 01:54:22 +02:00
|
|
|
{
|
2012-05-30 06:23:36 +02:00
|
|
|
gen_helper_load_dcr(cpu_gpr[rD(ctx->opcode)], cpu_env,
|
|
|
|
cpu_gpr[rA(ctx->opcode)]);
|
Great rework and cleanups to ease PowerPC implementations definitions.
* cleanup cpu.h, removing definitions used only in translate.c/translate_init.c
* add new flags to define instructions sets more precisely
* various changes in MMU models definitions
* add definitions for PowerPC 440/460 support (insns and SPRs).
* add definitions for PowerPC 401/403 and 620 input pins model
* Fix definitions for most PowerPC 401, 403, 405, 440, 601, 602, 603 and 7x0
* Preliminary support for PowerPC 74xx (aka G4) without altivec.
* Code provision for other PowerPC support (7x5, 970, ...).
* New SPR and PVR defined, from PowerPC 2.04 specification and other sources
* Misc code bugs, error messages and styles fixes.
* Update status files for PowerPC cores support.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3244 c046a42c-6fe2-441c-8c8c-71466251a162
2007-09-27 01:54:22 +02:00
|
|
|
/* Note: Rc update flag set leads to undefined state of Rc0 */
|
|
|
|
}
|
|
|
|
|
|
|
|
/* mtdcrux (PPC 460) : user-mode access to DCR */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_mtdcrux(DisasContext *ctx)
|
Great rework and cleanups to ease PowerPC implementations definitions.
* cleanup cpu.h, removing definitions used only in translate.c/translate_init.c
* add new flags to define instructions sets more precisely
* various changes in MMU models definitions
* add definitions for PowerPC 440/460 support (insns and SPRs).
* add definitions for PowerPC 401/403 and 620 input pins model
* Fix definitions for most PowerPC 401, 403, 405, 440, 601, 602, 603 and 7x0
* Preliminary support for PowerPC 74xx (aka G4) without altivec.
* Code provision for other PowerPC support (7x5, 970, ...).
* New SPR and PVR defined, from PowerPC 2.04 specification and other sources
* Misc code bugs, error messages and styles fixes.
* Update status files for PowerPC cores support.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3244 c046a42c-6fe2-441c-8c8c-71466251a162
2007-09-27 01:54:22 +02:00
|
|
|
{
|
2012-06-24 06:04:17 +02:00
|
|
|
gen_helper_store_dcr(cpu_env, cpu_gpr[rA(ctx->opcode)],
|
2012-05-30 06:23:36 +02:00
|
|
|
cpu_gpr[rS(ctx->opcode)]);
|
Great rework and cleanups to ease PowerPC implementations definitions.
* cleanup cpu.h, removing definitions used only in translate.c/translate_init.c
* add new flags to define instructions sets more precisely
* various changes in MMU models definitions
* add definitions for PowerPC 440/460 support (insns and SPRs).
* add definitions for PowerPC 401/403 and 620 input pins model
* Fix definitions for most PowerPC 401, 403, 405, 440, 601, 602, 603 and 7x0
* Preliminary support for PowerPC 74xx (aka G4) without altivec.
* Code provision for other PowerPC support (7x5, 970, ...).
* New SPR and PVR defined, from PowerPC 2.04 specification and other sources
* Misc code bugs, error messages and styles fixes.
* Update status files for PowerPC cores support.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3244 c046a42c-6fe2-441c-8c8c-71466251a162
2007-09-27 01:54:22 +02:00
|
|
|
/* Note: Rc update flag set leads to undefined state of Rc0 */
|
|
|
|
}
|
|
|
|
|
2007-03-07 09:32:30 +01:00
|
|
|
/* dccci */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_dccci(DisasContext *ctx)
|
2007-03-07 09:32:30 +01:00
|
|
|
{
|
2016-06-21 23:48:51 +02:00
|
|
|
CHK_SV;
|
2007-03-07 09:32:30 +01:00
|
|
|
/* interpreted as no-op */
|
|
|
|
}
|
|
|
|
|
|
|
|
/* dcread */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_dcread(DisasContext *ctx)
|
2007-03-07 09:32:30 +01:00
|
|
|
{
|
|
|
|
#if defined(CONFIG_USER_ONLY)
|
2016-06-21 23:48:51 +02:00
|
|
|
GEN_PRIV;
|
2007-03-07 09:32:30 +01:00
|
|
|
#else
|
2008-10-15 19:00:37 +02:00
|
|
|
TCGv EA, val;
|
2016-06-21 23:48:51 +02:00
|
|
|
|
|
|
|
CHK_SV;
|
2008-12-08 19:11:21 +01:00
|
|
|
gen_set_access_type(ctx, ACCESS_CACHE);
|
2008-11-17 15:43:54 +01:00
|
|
|
EA = tcg_temp_new();
|
2008-12-08 19:11:21 +01:00
|
|
|
gen_addr_reg_index(ctx, EA);
|
2008-11-17 15:43:54 +01:00
|
|
|
val = tcg_temp_new();
|
2008-12-08 19:11:21 +01:00
|
|
|
gen_qemu_ld32u(ctx, val, EA);
|
2008-10-15 19:00:37 +02:00
|
|
|
tcg_temp_free(val);
|
|
|
|
tcg_gen_mov_tl(cpu_gpr[rD(ctx->opcode)], EA);
|
|
|
|
tcg_temp_free(EA);
|
2016-06-21 23:48:51 +02:00
|
|
|
#endif /* defined(CONFIG_USER_ONLY) */
|
2007-03-07 09:32:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* icbt */
|
2009-06-17 17:22:14 +02:00
|
|
|
static void gen_icbt_40x(DisasContext *ctx)
|
2007-03-07 09:32:30 +01:00
|
|
|
{
|
2019-03-21 12:57:28 +01:00
|
|
|
/*
|
|
|
|
* interpreted as no-op
|
|
|
|
* XXX: specification say this is treated as a load by the MMU but
|
|
|
|
* does not generate any exception
|
2007-03-07 09:32:30 +01:00
|
|
|
*/
|
|
|
|
}
|
|
|
|
|
|
|
|
/* iccci */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_iccci(DisasContext *ctx)
|
2007-03-07 09:32:30 +01:00
|
|
|
{
|
2016-06-21 23:48:51 +02:00
|
|
|
CHK_SV;
|
2007-03-07 09:32:30 +01:00
|
|
|
/* interpreted as no-op */
|
|
|
|
}
|
|
|
|
|
|
|
|
/* icread */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_icread(DisasContext *ctx)
|
2007-03-07 09:32:30 +01:00
|
|
|
{
|
2016-06-21 23:48:51 +02:00
|
|
|
CHK_SV;
|
2007-03-07 09:32:30 +01:00
|
|
|
/* interpreted as no-op */
|
|
|
|
}
|
|
|
|
|
2014-09-15 17:03:28 +02:00
|
|
|
/* rfci (supervisor only) */
|
2009-06-17 17:22:14 +02:00
|
|
|
static void gen_rfci_40x(DisasContext *ctx)
|
2007-03-30 12:22:46 +02:00
|
|
|
{
|
|
|
|
#if defined(CONFIG_USER_ONLY)
|
2016-06-21 23:48:51 +02:00
|
|
|
GEN_PRIV;
|
2007-03-30 12:22:46 +02:00
|
|
|
#else
|
2016-06-21 23:48:51 +02:00
|
|
|
CHK_SV;
|
2007-03-30 12:22:46 +02:00
|
|
|
/* Restore CPU state */
|
2012-05-30 06:23:23 +02:00
|
|
|
gen_helper_40x_rfci(cpu_env);
|
2021-05-12 20:54:18 +02:00
|
|
|
ctx->base.is_jmp = DISAS_EXIT;
|
2016-06-21 23:48:51 +02:00
|
|
|
#endif /* defined(CONFIG_USER_ONLY) */
|
2007-03-30 12:22:46 +02:00
|
|
|
}
|
|
|
|
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_rfci(DisasContext *ctx)
|
2007-03-30 12:22:46 +02:00
|
|
|
{
|
|
|
|
#if defined(CONFIG_USER_ONLY)
|
2016-06-21 23:48:51 +02:00
|
|
|
GEN_PRIV;
|
2007-03-30 12:22:46 +02:00
|
|
|
#else
|
2016-06-21 23:48:51 +02:00
|
|
|
CHK_SV;
|
2007-03-30 12:22:46 +02:00
|
|
|
/* Restore CPU state */
|
2012-05-30 06:23:23 +02:00
|
|
|
gen_helper_rfci(cpu_env);
|
2021-05-12 20:54:18 +02:00
|
|
|
ctx->base.is_jmp = DISAS_EXIT;
|
2016-06-21 23:48:51 +02:00
|
|
|
#endif /* defined(CONFIG_USER_ONLY) */
|
2007-03-30 12:22:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* BookE specific */
|
2009-06-17 17:22:09 +02:00
|
|
|
|
2009-06-17 17:22:19 +02:00
|
|
|
/* XXX: not implemented on 440 ? */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_rfdi(DisasContext *ctx)
|
2007-03-07 09:32:30 +01:00
|
|
|
{
|
|
|
|
#if defined(CONFIG_USER_ONLY)
|
2016-06-21 23:48:51 +02:00
|
|
|
GEN_PRIV;
|
2007-03-07 09:32:30 +01:00
|
|
|
#else
|
2016-06-21 23:48:51 +02:00
|
|
|
CHK_SV;
|
2007-03-07 09:32:30 +01:00
|
|
|
/* Restore CPU state */
|
2012-05-30 06:23:23 +02:00
|
|
|
gen_helper_rfdi(cpu_env);
|
2021-05-12 20:54:18 +02:00
|
|
|
ctx->base.is_jmp = DISAS_EXIT;
|
2016-06-21 23:48:51 +02:00
|
|
|
#endif /* defined(CONFIG_USER_ONLY) */
|
2007-03-07 09:32:30 +01:00
|
|
|
}
|
|
|
|
|
2007-09-21 07:50:37 +02:00
|
|
|
/* XXX: not implemented on 440 ? */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_rfmci(DisasContext *ctx)
|
2007-03-30 12:22:46 +02:00
|
|
|
{
|
|
|
|
#if defined(CONFIG_USER_ONLY)
|
2016-06-21 23:48:51 +02:00
|
|
|
GEN_PRIV;
|
2007-03-30 12:22:46 +02:00
|
|
|
#else
|
2016-06-21 23:48:51 +02:00
|
|
|
CHK_SV;
|
2007-03-30 12:22:46 +02:00
|
|
|
/* Restore CPU state */
|
2012-05-30 06:23:23 +02:00
|
|
|
gen_helper_rfmci(cpu_env);
|
2021-05-12 20:54:18 +02:00
|
|
|
ctx->base.is_jmp = DISAS_EXIT;
|
2016-06-21 23:48:51 +02:00
|
|
|
#endif /* defined(CONFIG_USER_ONLY) */
|
2007-03-30 12:22:46 +02:00
|
|
|
}
|
2007-09-19 07:44:04 +02:00
|
|
|
|
2007-03-17 15:02:15 +01:00
|
|
|
/* TLB management - PowerPC 405 implementation */
|
2009-06-17 17:22:14 +02:00
|
|
|
|
2009-06-17 17:22:19 +02:00
|
|
|
/* tlbre */
|
2009-06-17 17:22:14 +02:00
|
|
|
static void gen_tlbre_40x(DisasContext *ctx)
|
2007-03-07 09:32:30 +01:00
|
|
|
{
|
|
|
|
#if defined(CONFIG_USER_ONLY)
|
2016-06-21 23:48:51 +02:00
|
|
|
GEN_PRIV;
|
2007-03-07 09:32:30 +01:00
|
|
|
#else
|
2016-06-21 23:48:51 +02:00
|
|
|
CHK_SV;
|
2007-03-07 09:32:30 +01:00
|
|
|
switch (rB(ctx->opcode)) {
|
|
|
|
case 0:
|
2012-05-30 06:23:31 +02:00
|
|
|
gen_helper_4xx_tlbre_hi(cpu_gpr[rD(ctx->opcode)], cpu_env,
|
|
|
|
cpu_gpr[rA(ctx->opcode)]);
|
2007-03-07 09:32:30 +01:00
|
|
|
break;
|
|
|
|
case 1:
|
2012-05-30 06:23:31 +02:00
|
|
|
gen_helper_4xx_tlbre_lo(cpu_gpr[rD(ctx->opcode)], cpu_env,
|
|
|
|
cpu_gpr[rA(ctx->opcode)]);
|
2007-03-07 09:32:30 +01:00
|
|
|
break;
|
|
|
|
default:
|
2008-12-11 23:42:14 +01:00
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_INVAL_INVAL);
|
2007-03-07 09:32:30 +01:00
|
|
|
break;
|
2004-01-04 23:58:38 +01:00
|
|
|
}
|
2016-06-21 23:48:51 +02:00
|
|
|
#endif /* defined(CONFIG_USER_ONLY) */
|
2007-03-07 09:32:30 +01:00
|
|
|
}
|
|
|
|
|
2007-03-17 15:02:15 +01:00
|
|
|
/* tlbsx - tlbsx. */
|
2009-06-17 17:22:14 +02:00
|
|
|
static void gen_tlbsx_40x(DisasContext *ctx)
|
2007-03-07 09:32:30 +01:00
|
|
|
{
|
|
|
|
#if defined(CONFIG_USER_ONLY)
|
2016-06-21 23:48:51 +02:00
|
|
|
GEN_PRIV;
|
2007-03-07 09:32:30 +01:00
|
|
|
#else
|
2008-12-06 22:46:17 +01:00
|
|
|
TCGv t0;
|
2016-06-21 23:48:51 +02:00
|
|
|
|
|
|
|
CHK_SV;
|
2008-12-06 22:46:17 +01:00
|
|
|
t0 = tcg_temp_new();
|
2008-12-08 19:11:21 +01:00
|
|
|
gen_addr_reg_index(ctx, t0);
|
2012-05-30 06:23:31 +02:00
|
|
|
gen_helper_4xx_tlbsx(cpu_gpr[rD(ctx->opcode)], cpu_env, t0);
|
2008-12-06 22:46:17 +01:00
|
|
|
tcg_temp_free(t0);
|
|
|
|
if (Rc(ctx->opcode)) {
|
2015-02-13 21:51:55 +01:00
|
|
|
TCGLabel *l1 = gen_new_label();
|
2013-02-20 08:52:13 +01:00
|
|
|
tcg_gen_trunc_tl_i32(cpu_crf[0], cpu_so);
|
2008-12-06 22:46:17 +01:00
|
|
|
tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_gpr[rD(ctx->opcode)], -1, l1);
|
|
|
|
tcg_gen_ori_i32(cpu_crf[0], cpu_crf[0], 0x02);
|
|
|
|
gen_set_label(l1);
|
|
|
|
}
|
2016-06-21 23:48:51 +02:00
|
|
|
#endif /* defined(CONFIG_USER_ONLY) */
|
2003-11-23 15:55:54 +01:00
|
|
|
}
|
|
|
|
|
2007-03-07 09:32:30 +01:00
|
|
|
/* tlbwe */
|
2009-06-17 17:22:14 +02:00
|
|
|
static void gen_tlbwe_40x(DisasContext *ctx)
|
2003-11-23 15:55:54 +01:00
|
|
|
{
|
2007-03-07 09:32:30 +01:00
|
|
|
#if defined(CONFIG_USER_ONLY)
|
2016-06-21 23:48:51 +02:00
|
|
|
GEN_PRIV;
|
2007-03-07 09:32:30 +01:00
|
|
|
#else
|
2016-06-21 23:48:51 +02:00
|
|
|
CHK_SV;
|
|
|
|
|
2007-03-07 09:32:30 +01:00
|
|
|
switch (rB(ctx->opcode)) {
|
|
|
|
case 0:
|
2012-05-30 06:23:31 +02:00
|
|
|
gen_helper_4xx_tlbwe_hi(cpu_env, cpu_gpr[rA(ctx->opcode)],
|
|
|
|
cpu_gpr[rS(ctx->opcode)]);
|
2007-03-07 09:32:30 +01:00
|
|
|
break;
|
|
|
|
case 1:
|
2012-05-30 06:23:31 +02:00
|
|
|
gen_helper_4xx_tlbwe_lo(cpu_env, cpu_gpr[rA(ctx->opcode)],
|
|
|
|
cpu_gpr[rS(ctx->opcode)]);
|
2007-03-07 09:32:30 +01:00
|
|
|
break;
|
|
|
|
default:
|
2008-12-11 23:42:14 +01:00
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_INVAL_INVAL);
|
2007-03-07 09:32:30 +01:00
|
|
|
break;
|
2004-01-04 23:58:38 +01:00
|
|
|
}
|
2016-06-21 23:48:51 +02:00
|
|
|
#endif /* defined(CONFIG_USER_ONLY) */
|
2007-03-07 09:32:30 +01:00
|
|
|
}
|
|
|
|
|
2007-09-21 07:28:33 +02:00
|
|
|
/* TLB management - PowerPC 440 implementation */
|
2009-06-17 17:22:14 +02:00
|
|
|
|
2009-06-17 17:22:19 +02:00
|
|
|
/* tlbre */
|
2009-06-17 17:22:14 +02:00
|
|
|
static void gen_tlbre_440(DisasContext *ctx)
|
2007-09-19 07:44:04 +02:00
|
|
|
{
|
|
|
|
#if defined(CONFIG_USER_ONLY)
|
2016-06-21 23:48:51 +02:00
|
|
|
GEN_PRIV;
|
2007-09-19 07:44:04 +02:00
|
|
|
#else
|
2016-06-21 23:48:51 +02:00
|
|
|
CHK_SV;
|
|
|
|
|
2007-09-19 07:44:04 +02:00
|
|
|
switch (rB(ctx->opcode)) {
|
|
|
|
case 0:
|
|
|
|
case 1:
|
|
|
|
case 2:
|
2008-12-06 22:46:17 +01:00
|
|
|
{
|
|
|
|
TCGv_i32 t0 = tcg_const_i32(rB(ctx->opcode));
|
2012-05-30 06:23:31 +02:00
|
|
|
gen_helper_440_tlbre(cpu_gpr[rD(ctx->opcode)], cpu_env,
|
|
|
|
t0, cpu_gpr[rA(ctx->opcode)]);
|
2008-12-06 22:46:17 +01:00
|
|
|
tcg_temp_free_i32(t0);
|
|
|
|
}
|
2007-09-19 07:44:04 +02:00
|
|
|
break;
|
|
|
|
default:
|
2008-12-11 23:42:14 +01:00
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_INVAL_INVAL);
|
2007-09-19 07:44:04 +02:00
|
|
|
break;
|
|
|
|
}
|
2016-06-21 23:48:51 +02:00
|
|
|
#endif /* defined(CONFIG_USER_ONLY) */
|
2007-09-19 07:44:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* tlbsx - tlbsx. */
|
2009-06-17 17:22:14 +02:00
|
|
|
static void gen_tlbsx_440(DisasContext *ctx)
|
2007-09-19 07:44:04 +02:00
|
|
|
{
|
|
|
|
#if defined(CONFIG_USER_ONLY)
|
2016-06-21 23:48:51 +02:00
|
|
|
GEN_PRIV;
|
2007-09-19 07:44:04 +02:00
|
|
|
#else
|
2008-12-06 22:46:17 +01:00
|
|
|
TCGv t0;
|
2016-06-21 23:48:51 +02:00
|
|
|
|
|
|
|
CHK_SV;
|
2008-12-06 22:46:17 +01:00
|
|
|
t0 = tcg_temp_new();
|
2008-12-08 19:11:21 +01:00
|
|
|
gen_addr_reg_index(ctx, t0);
|
2012-05-30 06:23:31 +02:00
|
|
|
gen_helper_440_tlbsx(cpu_gpr[rD(ctx->opcode)], cpu_env, t0);
|
2008-12-06 22:46:17 +01:00
|
|
|
tcg_temp_free(t0);
|
|
|
|
if (Rc(ctx->opcode)) {
|
2015-02-13 21:51:55 +01:00
|
|
|
TCGLabel *l1 = gen_new_label();
|
2013-02-20 08:52:13 +01:00
|
|
|
tcg_gen_trunc_tl_i32(cpu_crf[0], cpu_so);
|
2008-12-06 22:46:17 +01:00
|
|
|
tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_gpr[rD(ctx->opcode)], -1, l1);
|
|
|
|
tcg_gen_ori_i32(cpu_crf[0], cpu_crf[0], 0x02);
|
|
|
|
gen_set_label(l1);
|
|
|
|
}
|
2016-06-21 23:48:51 +02:00
|
|
|
#endif /* defined(CONFIG_USER_ONLY) */
|
2007-09-19 07:44:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* tlbwe */
|
2009-06-17 17:22:14 +02:00
|
|
|
static void gen_tlbwe_440(DisasContext *ctx)
|
2007-09-19 07:44:04 +02:00
|
|
|
{
|
|
|
|
#if defined(CONFIG_USER_ONLY)
|
2016-06-21 23:48:51 +02:00
|
|
|
GEN_PRIV;
|
2007-09-19 07:44:04 +02:00
|
|
|
#else
|
2016-06-21 23:48:51 +02:00
|
|
|
CHK_SV;
|
2007-09-19 07:44:04 +02:00
|
|
|
switch (rB(ctx->opcode)) {
|
|
|
|
case 0:
|
|
|
|
case 1:
|
|
|
|
case 2:
|
2008-12-06 22:46:17 +01:00
|
|
|
{
|
|
|
|
TCGv_i32 t0 = tcg_const_i32(rB(ctx->opcode));
|
2012-05-30 06:23:31 +02:00
|
|
|
gen_helper_440_tlbwe(cpu_env, t0, cpu_gpr[rA(ctx->opcode)],
|
|
|
|
cpu_gpr[rS(ctx->opcode)]);
|
2008-12-06 22:46:17 +01:00
|
|
|
tcg_temp_free_i32(t0);
|
|
|
|
}
|
2007-09-19 07:44:04 +02:00
|
|
|
break;
|
|
|
|
default:
|
2008-12-11 23:42:14 +01:00
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_INVAL_INVAL);
|
2007-09-19 07:44:04 +02:00
|
|
|
break;
|
|
|
|
}
|
2016-06-21 23:48:51 +02:00
|
|
|
#endif /* defined(CONFIG_USER_ONLY) */
|
2007-09-19 07:44:04 +02:00
|
|
|
}
|
|
|
|
|
2011-04-30 23:34:58 +02:00
|
|
|
/* TLB management - PowerPC BookE 2.06 implementation */
|
|
|
|
|
|
|
|
/* tlbre */
|
|
|
|
static void gen_tlbre_booke206(DisasContext *ctx)
|
|
|
|
{
|
2016-06-21 23:48:51 +02:00
|
|
|
#if defined(CONFIG_USER_ONLY)
|
|
|
|
GEN_PRIV;
|
2011-04-30 23:34:58 +02:00
|
|
|
#else
|
2016-06-21 23:48:51 +02:00
|
|
|
CHK_SV;
|
2012-05-30 06:23:31 +02:00
|
|
|
gen_helper_booke206_tlbre(cpu_env);
|
2016-06-21 23:48:51 +02:00
|
|
|
#endif /* defined(CONFIG_USER_ONLY) */
|
2011-04-30 23:34:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* tlbsx - tlbsx. */
|
|
|
|
static void gen_tlbsx_booke206(DisasContext *ctx)
|
|
|
|
{
|
|
|
|
#if defined(CONFIG_USER_ONLY)
|
2016-06-21 23:48:51 +02:00
|
|
|
GEN_PRIV;
|
2011-04-30 23:34:58 +02:00
|
|
|
#else
|
|
|
|
TCGv t0;
|
|
|
|
|
2016-06-21 23:48:51 +02:00
|
|
|
CHK_SV;
|
2011-04-30 23:34:58 +02: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 06:23:31 +02:00
|
|
|
gen_helper_booke206_tlbsx(cpu_env, t0);
|
2014-01-19 17:26:33 +01:00
|
|
|
tcg_temp_free(t0);
|
2016-06-21 23:48:51 +02:00
|
|
|
#endif /* defined(CONFIG_USER_ONLY) */
|
2011-04-30 23:34:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* tlbwe */
|
|
|
|
static void gen_tlbwe_booke206(DisasContext *ctx)
|
|
|
|
{
|
|
|
|
#if defined(CONFIG_USER_ONLY)
|
2016-06-21 23:48:51 +02:00
|
|
|
GEN_PRIV;
|
2011-04-30 23:34:58 +02:00
|
|
|
#else
|
2016-06-21 23:48:51 +02:00
|
|
|
CHK_SV;
|
2012-05-30 06:23:31 +02:00
|
|
|
gen_helper_booke206_tlbwe(cpu_env);
|
2016-06-21 23:48:51 +02:00
|
|
|
#endif /* defined(CONFIG_USER_ONLY) */
|
2011-04-30 23:34:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void gen_tlbivax_booke206(DisasContext *ctx)
|
|
|
|
{
|
|
|
|
#if defined(CONFIG_USER_ONLY)
|
2016-06-21 23:48:51 +02:00
|
|
|
GEN_PRIV;
|
2011-04-30 23:34:58 +02:00
|
|
|
#else
|
|
|
|
TCGv t0;
|
|
|
|
|
2016-06-21 23:48:51 +02:00
|
|
|
CHK_SV;
|
2011-04-30 23:34:58 +02:00
|
|
|
t0 = tcg_temp_new();
|
|
|
|
gen_addr_reg_index(ctx, t0);
|
2012-05-30 06:23:31 +02:00
|
|
|
gen_helper_booke206_tlbivax(cpu_env, t0);
|
2014-01-19 17:26:33 +01:00
|
|
|
tcg_temp_free(t0);
|
2016-06-21 23:48:51 +02:00
|
|
|
#endif /* defined(CONFIG_USER_ONLY) */
|
2011-04-30 23:34:58 +02:00
|
|
|
}
|
|
|
|
|
2012-01-20 04:09:15 +01:00
|
|
|
static void gen_tlbilx_booke206(DisasContext *ctx)
|
|
|
|
{
|
|
|
|
#if defined(CONFIG_USER_ONLY)
|
2016-06-21 23:48:51 +02:00
|
|
|
GEN_PRIV;
|
2012-01-20 04:09:15 +01:00
|
|
|
#else
|
|
|
|
TCGv t0;
|
|
|
|
|
2016-06-21 23:48:51 +02:00
|
|
|
CHK_SV;
|
2012-01-20 04:09:15 +01:00
|
|
|
t0 = tcg_temp_new();
|
|
|
|
gen_addr_reg_index(ctx, t0);
|
|
|
|
|
2019-03-21 12:57:28 +01:00
|
|
|
switch ((ctx->opcode >> 21) & 0x3) {
|
2012-01-20 04:09:15 +01:00
|
|
|
case 0:
|
2012-05-30 06:23:31 +02:00
|
|
|
gen_helper_booke206_tlbilx0(cpu_env, t0);
|
2012-01-20 04:09:15 +01:00
|
|
|
break;
|
|
|
|
case 1:
|
2012-05-30 06:23:31 +02:00
|
|
|
gen_helper_booke206_tlbilx1(cpu_env, t0);
|
2012-01-20 04:09:15 +01:00
|
|
|
break;
|
|
|
|
case 3:
|
2012-05-30 06:23:31 +02:00
|
|
|
gen_helper_booke206_tlbilx3(cpu_env, t0);
|
2012-01-20 04:09:15 +01:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_INVAL_INVAL);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
tcg_temp_free(t0);
|
2016-06-21 23:48:51 +02:00
|
|
|
#endif /* defined(CONFIG_USER_ONLY) */
|
2012-01-20 04:09:15 +01:00
|
|
|
}
|
|
|
|
|
2011-04-30 23:34:58 +02:00
|
|
|
|
2007-03-07 09:32:30 +01:00
|
|
|
/* wrtee */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_wrtee(DisasContext *ctx)
|
2007-03-07 09:32:30 +01:00
|
|
|
{
|
|
|
|
#if defined(CONFIG_USER_ONLY)
|
2016-06-21 23:48:51 +02:00
|
|
|
GEN_PRIV;
|
2007-03-07 09:32:30 +01:00
|
|
|
#else
|
2008-12-06 14:03:35 +01:00
|
|
|
TCGv t0;
|
2016-06-21 23:48:51 +02:00
|
|
|
|
|
|
|
CHK_SV;
|
2008-12-06 14:03:35 +01:00
|
|
|
t0 = tcg_temp_new();
|
|
|
|
tcg_gen_andi_tl(t0, cpu_gpr[rD(ctx->opcode)], (1 << MSR_EE));
|
|
|
|
tcg_gen_andi_tl(cpu_msr, cpu_msr, ~(1 << MSR_EE));
|
|
|
|
tcg_gen_or_tl(cpu_msr, cpu_msr, t0);
|
|
|
|
tcg_temp_free(t0);
|
2019-03-21 12:57:28 +01:00
|
|
|
/*
|
|
|
|
* Stop translation to have a chance to raise an exception if we
|
|
|
|
* just set msr_ee to 1
|
2007-09-29 17:02:38 +02:00
|
|
|
*/
|
2021-05-17 22:50:04 +02:00
|
|
|
ctx->base.is_jmp = DISAS_EXIT_UPDATE;
|
2016-06-21 23:48:51 +02:00
|
|
|
#endif /* defined(CONFIG_USER_ONLY) */
|
2007-03-07 09:32:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* wrteei */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_wrteei(DisasContext *ctx)
|
2007-03-07 09:32:30 +01:00
|
|
|
{
|
|
|
|
#if defined(CONFIG_USER_ONLY)
|
2016-06-21 23:48:51 +02:00
|
|
|
GEN_PRIV;
|
2007-03-07 09:32:30 +01:00
|
|
|
#else
|
2016-06-21 23:48:51 +02:00
|
|
|
CHK_SV;
|
2009-07-03 12:56:57 +02:00
|
|
|
if (ctx->opcode & 0x00008000) {
|
2008-12-06 14:03:35 +01:00
|
|
|
tcg_gen_ori_tl(cpu_msr, cpu_msr, (1 << MSR_EE));
|
|
|
|
/* Stop translation to have a chance to raise an exception */
|
2021-05-17 22:50:04 +02:00
|
|
|
ctx->base.is_jmp = DISAS_EXIT_UPDATE;
|
2008-12-06 14:03:35 +01:00
|
|
|
} else {
|
2009-01-14 20:40:54 +01:00
|
|
|
tcg_gen_andi_tl(cpu_msr, cpu_msr, ~(1 << MSR_EE));
|
2008-12-06 14:03:35 +01:00
|
|
|
}
|
2016-06-21 23:48:51 +02:00
|
|
|
#endif /* defined(CONFIG_USER_ONLY) */
|
2007-03-07 09:32:30 +01:00
|
|
|
}
|
|
|
|
|
2007-04-16 09:18:42 +02:00
|
|
|
/* PowerPC 440 specific instructions */
|
2009-06-17 17:22:09 +02:00
|
|
|
|
2009-06-17 17:22:19 +02:00
|
|
|
/* dlmzb */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_dlmzb(DisasContext *ctx)
|
2007-03-07 09:32:30 +01:00
|
|
|
{
|
2008-11-30 18:26:29 +01:00
|
|
|
TCGv_i32 t0 = tcg_const_i32(Rc(ctx->opcode));
|
2012-05-30 06:23:29 +02:00
|
|
|
gen_helper_dlmzb(cpu_gpr[rA(ctx->opcode)], cpu_env,
|
|
|
|
cpu_gpr[rS(ctx->opcode)], cpu_gpr[rB(ctx->opcode)], t0);
|
2008-11-30 18:26:29 +01:00
|
|
|
tcg_temp_free_i32(t0);
|
2007-03-07 09:32:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* mbar replaces eieio on 440 */
|
2009-06-17 17:22:09 +02:00
|
|
|
static void gen_mbar(DisasContext *ctx)
|
2007-03-07 09:32:30 +01:00
|
|
|
{
|
|
|
|
/* interpreted as no-op */
|
|
|
|
}
|
|
|
|
|
|
|
|
/* msync replaces sync on 440 */
|
2012-01-21 03:48:58 +01:00
|
|
|
static void gen_msync_4xx(DisasContext *ctx)
|
2007-03-07 09:32:30 +01:00
|
|
|
{
|
2019-01-26 15:50:28 +01:00
|
|
|
/* Only e500 seems to treat reserved bits as invalid */
|
|
|
|
if ((ctx->insns_flags2 & PPC2_BOOKE206) &&
|
|
|
|
(ctx->opcode & 0x03FFF801)) {
|
|
|
|
gen_inval_exception(ctx, POWERPC_EXCP_INVAL_INVAL);
|
|
|
|
}
|
|
|
|
/* otherwise interpreted as no-op */
|
2007-03-07 09:32:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* icbt */
|
2009-06-17 17:22:14 +02:00
|
|
|
static void gen_icbt_440(DisasContext *ctx)
|
2007-03-07 09:32:30 +01:00
|
|
|
{
|
2019-03-21 12:57:28 +01:00
|
|
|
/*
|
|
|
|
* interpreted as no-op
|
|
|
|
* XXX: specification say this is treated as a load by the MMU but
|
|
|
|
* does not generate any exception
|
2007-03-07 09:32:30 +01:00
|
|
|
*/
|
2003-11-23 15:55:54 +01:00
|
|
|
}
|
|
|
|
|
2012-01-31 03:18:35 +01:00
|
|
|
/* Embedded.Processor Control */
|
|
|
|
|
|
|
|
static void gen_msgclr(DisasContext *ctx)
|
|
|
|
{
|
|
|
|
#if defined(CONFIG_USER_ONLY)
|
2016-06-21 23:48:51 +02:00
|
|
|
GEN_PRIV;
|
2012-01-31 03:18:35 +01:00
|
|
|
#else
|
2018-01-16 08:41:56 +01:00
|
|
|
CHK_HV;
|
2019-03-22 19:03:51 +01:00
|
|
|
if (is_book3s_arch2x(ctx)) {
|
2018-01-18 15:54:03 +01:00
|
|
|
gen_helper_book3s_msgclr(cpu_env, cpu_gpr[rB(ctx->opcode)]);
|
|
|
|
} else {
|
|
|
|
gen_helper_msgclr(cpu_env, cpu_gpr[rB(ctx->opcode)]);
|
|
|
|
}
|
2016-06-21 23:48:51 +02:00
|
|
|
#endif /* defined(CONFIG_USER_ONLY) */
|
2012-01-31 03:18:35 +01:00
|
|
|
}
|
|
|
|
|
2012-01-31 03:19:23 +01:00
|
|
|
static void gen_msgsnd(DisasContext *ctx)
|
|
|
|
{
|
|
|
|
#if defined(CONFIG_USER_ONLY)
|
2016-06-21 23:48:51 +02:00
|
|
|
GEN_PRIV;
|
2012-01-31 03:19:23 +01:00
|
|
|
#else
|
2018-01-16 08:41:56 +01:00
|
|
|
CHK_HV;
|
2019-03-22 19:03:51 +01:00
|
|
|
if (is_book3s_arch2x(ctx)) {
|
2018-01-18 15:54:03 +01:00
|
|
|
gen_helper_book3s_msgsnd(cpu_gpr[rB(ctx->opcode)]);
|
|
|
|
} else {
|
|
|
|
gen_helper_msgsnd(cpu_gpr[rB(ctx->opcode)]);
|
|
|
|
}
|
2016-06-21 23:48:51 +02:00
|
|
|
#endif /* defined(CONFIG_USER_ONLY) */
|
2012-01-31 03:19:23 +01:00
|
|
|
}
|
|
|
|
|
2020-01-20 11:49:34 +01:00
|
|
|
#if defined(TARGET_PPC64)
|
|
|
|
static void gen_msgclrp(DisasContext *ctx)
|
|
|
|
{
|
|
|
|
#if defined(CONFIG_USER_ONLY)
|
|
|
|
GEN_PRIV;
|
|
|
|
#else
|
|
|
|
CHK_SV;
|
|
|
|
gen_helper_book3s_msgclrp(cpu_env, cpu_gpr[rB(ctx->opcode)]);
|
|
|
|
#endif /* defined(CONFIG_USER_ONLY) */
|
|
|
|
}
|
|
|
|
|
|
|
|
static void gen_msgsndp(DisasContext *ctx)
|
|
|
|
{
|
|
|
|
#if defined(CONFIG_USER_ONLY)
|
|
|
|
GEN_PRIV;
|
|
|
|
#else
|
|
|
|
CHK_SV;
|
|
|
|
gen_helper_book3s_msgsndp(cpu_env, cpu_gpr[rB(ctx->opcode)]);
|
|
|
|
#endif /* defined(CONFIG_USER_ONLY) */
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2018-01-18 15:54:03 +01:00
|
|
|
static void gen_msgsync(DisasContext *ctx)
|
|
|
|
{
|
|
|
|
#if defined(CONFIG_USER_ONLY)
|
|
|
|
GEN_PRIV;
|
|
|
|
#else
|
|
|
|
CHK_HV;
|
|
|
|
#endif /* defined(CONFIG_USER_ONLY) */
|
|
|
|
/* interpreted as no-op */
|
|
|
|
}
|
2009-01-04 23:11:39 +01:00
|
|
|
|
2016-07-26 13:58:36 +02: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 13:58:37 +02: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 13:58:36 +02:00
|
|
|
#endif /* defined(TARGET_PPC64) */
|
|
|
|
|
2014-12-18 17:34:34 +01:00
|
|
|
static void gen_tbegin(DisasContext *ctx)
|
|
|
|
{
|
|
|
|
if (unlikely(!ctx->tm_enabled)) {
|
|
|
|
gen_exception_err(ctx, POWERPC_EXCP_FU, FSCR_IC_TM);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
gen_helper_tbegin(cpu_env);
|
|
|
|
}
|
|
|
|
|
2014-12-18 17:34:35 +01:00
|
|
|
#define GEN_TM_NOOP(name) \
|
|
|
|
static inline void gen_##name(DisasContext *ctx) \
|
|
|
|
{ \
|
|
|
|
if (unlikely(!ctx->tm_enabled)) { \
|
|
|
|
gen_exception_err(ctx, POWERPC_EXCP_FU, FSCR_IC_TM); \
|
|
|
|
return; \
|
|
|
|
} \
|
2019-03-21 12:57:28 +01:00
|
|
|
/* \
|
|
|
|
* Because tbegin always fails in QEMU, these user \
|
2014-12-18 17:34:35 +01:00
|
|
|
* 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);
|
2019-03-21 12:57:28 +01:00
|
|
|
|
2017-01-13 07:28:21 +01:00
|
|
|
static inline void gen_cp_abort(DisasContext *ctx)
|
|
|
|
{
|
2019-03-21 12:57:28 +01:00
|
|
|
/* Do Nothing */
|
2017-01-13 07:28:21 +01:00
|
|
|
}
|
2014-12-18 17:34:35 +01:00
|
|
|
|
2017-02-09 11:34:00 +01:00
|
|
|
#define GEN_CP_PASTE_NOOP(name) \
|
|
|
|
static inline void gen_##name(DisasContext *ctx) \
|
|
|
|
{ \
|
2019-03-21 12:57:28 +01:00
|
|
|
/* \
|
|
|
|
* Generate invalid exception until we have an \
|
|
|
|
* implementation of the copy paste facility \
|
2017-02-09 11:34:00 +01:00
|
|
|
*/ \
|
|
|
|
gen_invalid(ctx); \
|
|
|
|
}
|
|
|
|
|
|
|
|
GEN_CP_PASTE_NOOP(copy)
|
|
|
|
GEN_CP_PASTE_NOOP(paste)
|
|
|
|
|
2014-12-18 17:34:36 +01:00
|
|
|
static void gen_tcheck(DisasContext *ctx)
|
|
|
|
{
|
|
|
|
if (unlikely(!ctx->tm_enabled)) {
|
|
|
|
gen_exception_err(ctx, POWERPC_EXCP_FU, FSCR_IC_TM);
|
|
|
|
return;
|
|
|
|
}
|
2019-03-21 12:57:28 +01:00
|
|
|
/*
|
|
|
|
* Because tbegin always fails, the tcheck implementation is
|
|
|
|
* simple:
|
2014-12-18 17:34:36 +01:00
|
|
|
*
|
|
|
|
* CR[CRF] = TDOOMED || MSR[TS] || 0b0
|
|
|
|
* = 0b1 || 0b00 || 0b0
|
|
|
|
*/
|
|
|
|
tcg_gen_movi_i32(cpu_crf[crfD(ctx->opcode)], 0x8);
|
|
|
|
}
|
|
|
|
|
2014-12-18 17:34:37 +01:00
|
|
|
#if defined(CONFIG_USER_ONLY)
|
|
|
|
#define GEN_TM_PRIV_NOOP(name) \
|
|
|
|
static inline void gen_##name(DisasContext *ctx) \
|
|
|
|
{ \
|
2019-03-21 12:57:28 +01:00
|
|
|
gen_priv_exception(ctx, POWERPC_EXCP_PRIV_OPC); \
|
2014-12-18 17:34:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
#define GEN_TM_PRIV_NOOP(name) \
|
|
|
|
static inline void gen_##name(DisasContext *ctx) \
|
|
|
|
{ \
|
2016-06-21 23:48:51 +02:00
|
|
|
CHK_SV; \
|
2014-12-18 17:34:37 +01:00
|
|
|
if (unlikely(!ctx->tm_enabled)) { \
|
|
|
|
gen_exception_err(ctx, POWERPC_EXCP_FU, FSCR_IC_TM); \
|
|
|
|
return; \
|
|
|
|
} \
|
2019-03-21 12:57:28 +01:00
|
|
|
/* \
|
|
|
|
* Because tbegin always fails, the implementation is \
|
2014-12-18 17:34:37 +01:00
|
|
|
* 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);
|
|
|
|
|
2019-01-02 10:14:17 +01:00
|
|
|
static inline void get_fpr(TCGv_i64 dst, int regno)
|
|
|
|
{
|
2019-03-07 19:05:14 +01:00
|
|
|
tcg_gen_ld_i64(dst, cpu_env, fpr_offset(regno));
|
2019-01-02 10:14:17 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline void set_fpr(int regno, TCGv_i64 src)
|
|
|
|
{
|
2019-03-07 19:05:14 +01:00
|
|
|
tcg_gen_st_i64(src, cpu_env, fpr_offset(regno));
|
2019-01-02 10:14:17 +01:00
|
|
|
}
|
|
|
|
|
2019-01-02 10:14:18 +01:00
|
|
|
static inline void get_avr64(TCGv_i64 dst, int regno, bool high)
|
|
|
|
{
|
2019-03-07 19:05:18 +01:00
|
|
|
tcg_gen_ld_i64(dst, cpu_env, avr64_offset(regno, high));
|
2019-01-02 10:14:18 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline void set_avr64(int regno, TCGv_i64 src, bool high)
|
|
|
|
{
|
2019-03-07 19:05:18 +01:00
|
|
|
tcg_gen_st_i64(src, cpu_env, avr64_offset(regno, high));
|
2019-01-02 10:14:18 +01:00
|
|
|
}
|
|
|
|
|
2021-06-01 21:35:20 +02:00
|
|
|
/*
|
|
|
|
* Helpers for decodetree used by !function for decoding arguments.
|
|
|
|
*/
|
|
|
|
static int times_4(DisasContext *ctx, int x)
|
|
|
|
{
|
|
|
|
return x * 4;
|
|
|
|
}
|
|
|
|
|
2021-06-01 21:35:15 +02:00
|
|
|
/*
|
|
|
|
* Helpers for trans_* functions to check for specific insns flags.
|
|
|
|
* Use token pasting to ensure that we use the proper flag with the
|
|
|
|
* proper variable.
|
|
|
|
*/
|
|
|
|
#define REQUIRE_INSNS_FLAGS(CTX, NAME) \
|
|
|
|
do { \
|
|
|
|
if (((CTX)->insns_flags & PPC_##NAME) == 0) { \
|
|
|
|
return false; \
|
|
|
|
} \
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
#define REQUIRE_INSNS_FLAGS2(CTX, NAME) \
|
|
|
|
do { \
|
|
|
|
if (((CTX)->insns_flags2 & PPC2_##NAME) == 0) { \
|
|
|
|
return false; \
|
|
|
|
} \
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
/* Then special-case the check for 64-bit so that we elide code for ppc32. */
|
|
|
|
#if TARGET_LONG_BITS == 32
|
|
|
|
# define REQUIRE_64BIT(CTX) return false
|
|
|
|
#else
|
|
|
|
# define REQUIRE_64BIT(CTX) REQUIRE_INSNS_FLAGS(CTX, 64B)
|
|
|
|
#endif
|
|
|
|
|
2021-06-01 21:35:20 +02:00
|
|
|
/*
|
|
|
|
* Helpers for implementing sets of trans_* functions.
|
|
|
|
* Defer the implementation of NAME to FUNC, with optional extra arguments.
|
|
|
|
*/
|
|
|
|
#define TRANS(NAME, FUNC, ...) \
|
|
|
|
static bool trans_##NAME(DisasContext *ctx, arg_##NAME *a) \
|
|
|
|
{ return FUNC(ctx, a, __VA_ARGS__); }
|
|
|
|
|
|
|
|
#define TRANS64(NAME, FUNC, ...) \
|
|
|
|
static bool trans_##NAME(DisasContext *ctx, arg_##NAME *a) \
|
|
|
|
{ REQUIRE_64BIT(ctx); return FUNC(ctx, a, __VA_ARGS__); }
|
|
|
|
|
|
|
|
/* TODO: More TRANS* helpers for extra insn_flags checks. */
|
|
|
|
|
|
|
|
|
2021-06-01 21:35:17 +02:00
|
|
|
#include "decode-insn32.c.inc"
|
|
|
|
#include "decode-insn64.c.inc"
|
|
|
|
#include "translate/fixedpoint-impl.c.inc"
|
|
|
|
|
2020-02-04 12:41:01 +01:00
|
|
|
#include "translate/fp-impl.c.inc"
|
2016-08-01 12:17:42 +02:00
|
|
|
|
2020-02-04 12:41:01 +01:00
|
|
|
#include "translate/vmx-impl.c.inc"
|
2016-08-01 12:17:42 +02:00
|
|
|
|
2020-02-04 12:41:01 +01:00
|
|
|
#include "translate/vsx-impl.c.inc"
|
2021-06-01 21:35:26 +02:00
|
|
|
#include "translate/vector-impl.c.inc"
|
2016-08-01 12:17:42 +02:00
|
|
|
|
2020-02-04 12:41:01 +01:00
|
|
|
#include "translate/dfp-impl.c.inc"
|
2016-08-01 12:17:42 +02:00
|
|
|
|
2020-02-04 12:41:01 +01:00
|
|
|
#include "translate/spe-impl.c.inc"
|
2016-08-01 12:17:42 +02:00
|
|
|
|
2016-11-23 12:37:15 +01:00
|
|
|
/* Handles lfdp, lxsd, lxssp */
|
|
|
|
static void gen_dform39(DisasContext *ctx)
|
|
|
|
{
|
|
|
|
switch (ctx->opcode & 0x3) {
|
|
|
|
case 0: /* lfdp */
|
|
|
|
if (ctx->insns_flags2 & PPC2_ISA205) {
|
|
|
|
return gen_lfdp(ctx);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 2: /* lxsd */
|
|
|
|
if (ctx->insns_flags2 & PPC2_ISA300) {
|
|
|
|
return gen_lxsd(ctx);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 3: /* lxssp */
|
|
|
|
if (ctx->insns_flags2 & PPC2_ISA300) {
|
|
|
|
return gen_lxssp(ctx);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return gen_invalid(ctx);
|
|
|
|
}
|
|
|
|
|
2016-11-23 12:37:17 +01:00
|
|
|
/* handles stfdp, lxv, stxsd, stxssp lxvx */
|
2016-11-23 12:37:16 +01:00
|
|
|
static void gen_dform3D(DisasContext *ctx)
|
|
|
|
{
|
|
|
|
if ((ctx->opcode & 3) == 1) { /* DQ-FORM */
|
|
|
|
switch (ctx->opcode & 0x7) {
|
|
|
|
case 1: /* lxv */
|
2016-11-23 12:37:17 +01:00
|
|
|
if (ctx->insns_flags2 & PPC2_ISA300) {
|
|
|
|
return gen_lxv(ctx);
|
|
|
|
}
|
2016-11-23 12:37:16 +01:00
|
|
|
break;
|
|
|
|
case 5: /* stxv */
|
2016-11-23 12:37:17 +01:00
|
|
|
if (ctx->insns_flags2 & PPC2_ISA300) {
|
|
|
|
return gen_stxv(ctx);
|
|
|
|
}
|
2016-11-23 12:37:16 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
} else { /* DS-FORM */
|
|
|
|
switch (ctx->opcode & 0x3) {
|
|
|
|
case 0: /* stfdp */
|
|
|
|
if (ctx->insns_flags2 & PPC2_ISA205) {
|
|
|
|
return gen_stfdp(ctx);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 2: /* stxsd */
|
|
|
|
if (ctx->insns_flags2 & PPC2_ISA300) {
|
|
|
|
return gen_stxsd(ctx);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 3: /* stxssp */
|
|
|
|
if (ctx->insns_flags2 & PPC2_ISA300) {
|
|
|
|
return gen_stxssp(ctx);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return gen_invalid(ctx);
|
|
|
|
}
|
|
|
|
|
2020-07-02 01:43:38 +02:00
|
|
|
#if defined(TARGET_PPC64)
|
|
|
|
/* brd */
|
|
|
|
static void gen_brd(DisasContext *ctx)
|
|
|
|
{
|
|
|
|
tcg_gen_bswap64_i64(cpu_gpr[rA(ctx->opcode)], cpu_gpr[rS(ctx->opcode)]);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* brw */
|
|
|
|
static void gen_brw(DisasContext *ctx)
|
|
|
|
{
|
|
|
|
tcg_gen_bswap64_i64(cpu_gpr[rA(ctx->opcode)], cpu_gpr[rS(ctx->opcode)]);
|
|
|
|
tcg_gen_rotli_i64(cpu_gpr[rA(ctx->opcode)], cpu_gpr[rA(ctx->opcode)], 32);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/* brh */
|
|
|
|
static void gen_brh(DisasContext *ctx)
|
|
|
|
{
|
|
|
|
TCGv_i64 t0 = tcg_temp_new_i64();
|
|
|
|
TCGv_i64 t1 = tcg_temp_new_i64();
|
|
|
|
TCGv_i64 t2 = tcg_temp_new_i64();
|
|
|
|
|
|
|
|
tcg_gen_movi_i64(t0, 0x00ff00ff00ff00ffull);
|
|
|
|
tcg_gen_shri_i64(t1, cpu_gpr[rS(ctx->opcode)], 8);
|
|
|
|
tcg_gen_and_i64(t2, t1, t0);
|
|
|
|
tcg_gen_and_i64(t1, cpu_gpr[rS(ctx->opcode)], t0);
|
|
|
|
tcg_gen_shli_i64(t1, t1, 8);
|
|
|
|
tcg_gen_or_i64(cpu_gpr[rA(ctx->opcode)], t1, t2);
|
|
|
|
|
|
|
|
tcg_temp_free_i64(t0);
|
|
|
|
tcg_temp_free_i64(t1);
|
|
|
|
tcg_temp_free_i64(t2);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2009-10-01 23:12:16 +02:00
|
|
|
static opcode_t opcodes[] = {
|
2020-07-02 01:43:38 +02:00
|
|
|
#if defined(TARGET_PPC64)
|
|
|
|
GEN_HANDLER_E(brd, 0x1F, 0x1B, 0x05, 0x0000F801, PPC_NONE, PPC2_ISA310),
|
|
|
|
GEN_HANDLER_E(brw, 0x1F, 0x1B, 0x04, 0x0000F801, PPC_NONE, PPC2_ISA310),
|
|
|
|
GEN_HANDLER_E(brh, 0x1F, 0x1B, 0x06, 0x0000F801, PPC_NONE, PPC2_ISA310),
|
|
|
|
#endif
|
2009-06-17 17:22:31 +02:00
|
|
|
GEN_HANDLER(invalid, 0x00, 0x00, 0x00, 0xFFFFFFFF, PPC_NONE),
|
2016-07-26 13:58:34 +02:00
|
|
|
#if defined(TARGET_PPC64)
|
|
|
|
GEN_HANDLER_E(cmpeqb, 0x1F, 0x00, 0x07, 0x00600000, PPC_NONE, PPC2_ISA300),
|
|
|
|
#endif
|
2013-04-20 10:56:16 +02:00
|
|
|
GEN_HANDLER_E(cmpb, 0x1F, 0x1C, 0x0F, 0x00000001, PPC_NONE, PPC2_ISA205),
|
2016-07-26 13:58:27 +02:00
|
|
|
GEN_HANDLER_E(cmprb, 0x1F, 0x00, 0x06, 0x00400001, PPC_NONE, PPC2_ISA300),
|
2009-06-17 17:22:31 +02:00
|
|
|
GEN_HANDLER(isel, 0x1F, 0x0F, 0xFF, 0x00000001, PPC_ISEL),
|
|
|
|
GEN_HANDLER(addic, 0x0C, 0xFF, 0xFF, 0x00000000, PPC_INTEGER),
|
|
|
|
GEN_HANDLER2(addic_, "addic.", 0x0D, 0xFF, 0xFF, 0x00000000, PPC_INTEGER),
|
|
|
|
GEN_HANDLER(mulhw, 0x1F, 0x0B, 0x02, 0x00000400, PPC_INTEGER),
|
|
|
|
GEN_HANDLER(mulhwu, 0x1F, 0x0B, 0x00, 0x00000400, PPC_INTEGER),
|
|
|
|
GEN_HANDLER(mullw, 0x1F, 0x0B, 0x07, 0x00000000, PPC_INTEGER),
|
|
|
|
GEN_HANDLER(mullwo, 0x1F, 0x0B, 0x17, 0x00000000, PPC_INTEGER),
|
|
|
|
GEN_HANDLER(mulli, 0x07, 0xFF, 0xFF, 0x00000000, PPC_INTEGER),
|
|
|
|
#if defined(TARGET_PPC64)
|
|
|
|
GEN_HANDLER(mulld, 0x1F, 0x09, 0x07, 0x00000000, PPC_64B),
|
|
|
|
#endif
|
|
|
|
GEN_HANDLER(neg, 0x1F, 0x08, 0x03, 0x0000F800, PPC_INTEGER),
|
|
|
|
GEN_HANDLER(nego, 0x1F, 0x08, 0x13, 0x0000F800, PPC_INTEGER),
|
|
|
|
GEN_HANDLER(subfic, 0x08, 0xFF, 0xFF, 0x00000000, PPC_INTEGER),
|
|
|
|
GEN_HANDLER2(andi_, "andi.", 0x1C, 0xFF, 0xFF, 0x00000000, PPC_INTEGER),
|
|
|
|
GEN_HANDLER2(andis_, "andis.", 0x1D, 0xFF, 0xFF, 0x00000000, PPC_INTEGER),
|
|
|
|
GEN_HANDLER(cntlzw, 0x1F, 0x1A, 0x00, 0x00000000, PPC_INTEGER),
|
2016-07-26 13:58:33 +02:00
|
|
|
GEN_HANDLER_E(cnttzw, 0x1F, 0x1A, 0x10, 0x00000000, PPC_NONE, PPC2_ISA300),
|
2017-02-09 11:34:00 +01:00
|
|
|
GEN_HANDLER_E(copy, 0x1F, 0x06, 0x18, 0x03C00001, PPC_NONE, PPC2_ISA300),
|
2017-01-13 07:28:21 +01:00
|
|
|
GEN_HANDLER_E(cp_abort, 0x1F, 0x06, 0x1A, 0x03FFF801, PPC_NONE, PPC2_ISA300),
|
2017-02-09 11:34:00 +01:00
|
|
|
GEN_HANDLER_E(paste, 0x1F, 0x06, 0x1C, 0x03C00000, PPC_NONE, PPC2_ISA300),
|
2009-06-17 17:22:31 +02: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 19:14:42 +02:00
|
|
|
GEN_HANDLER(popcntb, 0x1F, 0x1A, 0x03, 0x0000F801, PPC_POPCNTB),
|
2011-04-01 06:15:13 +02:00
|
|
|
GEN_HANDLER(popcntw, 0x1F, 0x1A, 0x0b, 0x0000F801, PPC_POPCNTWD),
|
2013-04-20 10:56:17 +02:00
|
|
|
GEN_HANDLER_E(prtyw, 0x1F, 0x1A, 0x04, 0x0000F801, PPC_NONE, PPC2_ISA205),
|
2009-06-17 17:22:31 +02:00
|
|
|
#if defined(TARGET_PPC64)
|
2011-04-01 06:15:13 +02:00
|
|
|
GEN_HANDLER(popcntd, 0x1F, 0x1A, 0x0F, 0x0000F801, PPC_POPCNTWD),
|
2009-06-17 17:22:31 +02:00
|
|
|
GEN_HANDLER(cntlzd, 0x1F, 0x1A, 0x01, 0x00000000, PPC_64B),
|
2016-07-26 13:58:32 +02:00
|
|
|
GEN_HANDLER_E(cnttzd, 0x1F, 0x1A, 0x11, 0x00000000, PPC_NONE, PPC2_ISA300),
|
2016-09-16 12:51:47 +02:00
|
|
|
GEN_HANDLER_E(darn, 0x1F, 0x13, 0x17, 0x001CF801, PPC_NONE, PPC2_ISA300),
|
2013-04-20 10:56:17 +02:00
|
|
|
GEN_HANDLER_E(prtyd, 0x1F, 0x1A, 0x05, 0x0000F801, PPC_NONE, PPC2_ISA205),
|
2014-01-07 17:05:49 +01:00
|
|
|
GEN_HANDLER_E(bpermd, 0x1F, 0x1C, 0x07, 0x00000001, PPC_NONE, PPC2_PERM_ISA206),
|
2009-06-17 17:22:31 +02:00
|
|
|
#endif
|
|
|
|
GEN_HANDLER(rlwimi, 0x14, 0xFF, 0xFF, 0x00000000, PPC_INTEGER),
|
|
|
|
GEN_HANDLER(rlwinm, 0x15, 0xFF, 0xFF, 0x00000000, PPC_INTEGER),
|
|
|
|
GEN_HANDLER(rlwnm, 0x17, 0xFF, 0xFF, 0x00000000, PPC_INTEGER),
|
|
|
|
GEN_HANDLER(slw, 0x1F, 0x18, 0x00, 0x00000000, PPC_INTEGER),
|
|
|
|
GEN_HANDLER(sraw, 0x1F, 0x18, 0x18, 0x00000000, PPC_INTEGER),
|
|
|
|
GEN_HANDLER(srawi, 0x1F, 0x18, 0x19, 0x00000000, PPC_INTEGER),
|
|
|
|
GEN_HANDLER(srw, 0x1F, 0x18, 0x10, 0x00000000, PPC_INTEGER),
|
|
|
|
#if defined(TARGET_PPC64)
|
|
|
|
GEN_HANDLER(sld, 0x1F, 0x1B, 0x00, 0x00000000, PPC_64B),
|
|
|
|
GEN_HANDLER(srad, 0x1F, 0x1A, 0x18, 0x00000000, PPC_64B),
|
|
|
|
GEN_HANDLER2(sradi0, "sradi", 0x1F, 0x1A, 0x19, 0x00000000, PPC_64B),
|
|
|
|
GEN_HANDLER2(sradi1, "sradi", 0x1F, 0x1B, 0x19, 0x00000000, PPC_64B),
|
|
|
|
GEN_HANDLER(srd, 0x1F, 0x1B, 0x10, 0x00000000, PPC_64B),
|
2016-07-28 20:14:18 +02: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 17:22:31 +02:00
|
|
|
#endif
|
|
|
|
#if defined(TARGET_PPC64)
|
|
|
|
GEN_HANDLER(lq, 0x38, 0xFF, 0xFF, 0x00000000, PPC_64BX),
|
|
|
|
GEN_HANDLER(std, 0x3E, 0xFF, 0xFF, 0x00000000, PPC_64B),
|
|
|
|
#endif
|
2016-11-23 12:37:15 +01:00
|
|
|
/* handles lfdp, lxsd, lxssp */
|
|
|
|
GEN_HANDLER_E(dform39, 0x39, 0xFF, 0xFF, 0x00000000, PPC_NONE, PPC2_ISA205),
|
2016-11-23 12:37:17 +01:00
|
|
|
/* handles stfdp, lxv, stxsd, stxssp, stxv */
|
2016-11-23 12:37:16 +01:00
|
|
|
GEN_HANDLER_E(dform3D, 0x3D, 0xFF, 0xFF, 0x00000000, PPC_NONE, PPC2_ISA205),
|
2009-06-17 17:22:31 +02:00
|
|
|
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),
|
2018-06-06 09:33:53 +02:00
|
|
|
GEN_HANDLER(eieio, 0x1F, 0x16, 0x1A, 0x01FFF801, PPC_MEM_EIEIO),
|
2009-06-17 17:22:31 +02:00
|
|
|
GEN_HANDLER(isync, 0x13, 0x16, 0x04, 0x03FFF801, PPC_MEM),
|
2014-01-07 17:05:56 +01:00
|
|
|
GEN_HANDLER_E(lbarx, 0x1F, 0x14, 0x01, 0, PPC_NONE, PPC2_ATOMIC_ISA206),
|
|
|
|
GEN_HANDLER_E(lharx, 0x1F, 0x14, 0x03, 0, PPC_NONE, PPC2_ATOMIC_ISA206),
|
2010-09-10 17:08:33 +02:00
|
|
|
GEN_HANDLER(lwarx, 0x1F, 0x14, 0x00, 0x00000000, PPC_RES),
|
2017-02-09 06:33:30 +01:00
|
|
|
GEN_HANDLER_E(lwat, 0x1F, 0x06, 0x12, 0x00000001, PPC_NONE, PPC2_ISA300),
|
2017-02-09 06:33:31 +01:00
|
|
|
GEN_HANDLER_E(stwat, 0x1F, 0x06, 0x16, 0x00000001, PPC_NONE, PPC2_ISA300),
|
2014-01-07 17:05:57 +01:00
|
|
|
GEN_HANDLER_E(stbcx_, 0x1F, 0x16, 0x15, 0, PPC_NONE, PPC2_ATOMIC_ISA206),
|
|
|
|
GEN_HANDLER_E(sthcx_, 0x1F, 0x16, 0x16, 0, PPC_NONE, PPC2_ATOMIC_ISA206),
|
2009-06-17 17:22:31 +02:00
|
|
|
GEN_HANDLER2(stwcx_, "stwcx.", 0x1F, 0x16, 0x04, 0x00000000, PPC_RES),
|
|
|
|
#if defined(TARGET_PPC64)
|
2017-02-09 06:33:30 +01:00
|
|
|
GEN_HANDLER_E(ldat, 0x1F, 0x06, 0x13, 0x00000001, PPC_NONE, PPC2_ISA300),
|
2017-02-09 06:33:31 +01:00
|
|
|
GEN_HANDLER_E(stdat, 0x1F, 0x06, 0x17, 0x00000001, PPC_NONE, PPC2_ISA300),
|
2010-09-10 17:08:33 +02:00
|
|
|
GEN_HANDLER(ldarx, 0x1F, 0x14, 0x02, 0x00000000, PPC_64B),
|
2014-02-10 18:27:00 +01:00
|
|
|
GEN_HANDLER_E(lqarx, 0x1F, 0x14, 0x08, 0, PPC_NONE, PPC2_LSQ_ISA207),
|
2009-06-17 17:22:31 +02:00
|
|
|
GEN_HANDLER2(stdcx_, "stdcx.", 0x1F, 0x16, 0x06, 0x00000000, PPC_64B),
|
2014-02-10 18:27:01 +01:00
|
|
|
GEN_HANDLER_E(stqcx_, 0x1F, 0x16, 0x05, 0, PPC_NONE, PPC2_LSQ_ISA207),
|
2009-06-17 17:22:31 +02:00
|
|
|
#endif
|
|
|
|
GEN_HANDLER(sync, 0x1F, 0x16, 0x12, 0x039FF801, PPC_MEM_SYNC),
|
|
|
|
GEN_HANDLER(wait, 0x1F, 0x1E, 0x01, 0x03FFF801, PPC_WAIT),
|
2017-02-09 11:34:03 +01:00
|
|
|
GEN_HANDLER_E(wait, 0x1F, 0x1E, 0x00, 0x039FF801, PPC_NONE, PPC2_ISA300),
|
2009-06-17 17:22:31 +02:00
|
|
|
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),
|
2016-09-28 07:45:16 +02:00
|
|
|
GEN_HANDLER_E(bctar, 0x13, 0x10, 0x11, 0x0000E000, PPC_NONE, PPC2_BCTAR_ISA207),
|
2009-06-17 17:22:31 +02:00
|
|
|
GEN_HANDLER(mcrf, 0x13, 0x00, 0xFF, 0x00000001, PPC_INTEGER),
|
|
|
|
GEN_HANDLER(rfi, 0x13, 0x12, 0x01, 0x03FF8001, PPC_FLOW),
|
|
|
|
#if defined(TARGET_PPC64)
|
|
|
|
GEN_HANDLER(rfid, 0x13, 0x12, 0x00, 0x03FF8001, PPC_64B),
|
2020-05-07 13:53:28 +02:00
|
|
|
#if !defined(CONFIG_USER_ONLY)
|
|
|
|
/* Top bit of opc2 corresponds with low bit of LEV, so use two handlers */
|
|
|
|
GEN_HANDLER_E(scv, 0x11, 0x10, 0xFF, 0x03FFF01E, PPC_NONE, PPC2_ISA300),
|
|
|
|
GEN_HANDLER_E(scv, 0x11, 0x00, 0xFF, 0x03FFF01E, PPC_NONE, PPC2_ISA300),
|
|
|
|
GEN_HANDLER_E(rfscv, 0x13, 0x12, 0x02, 0x03FF8001, PPC_NONE, PPC2_ISA300),
|
|
|
|
#endif
|
2016-12-05 12:25:26 +01:00
|
|
|
GEN_HANDLER_E(stop, 0x13, 0x12, 0x0b, 0x03FFF801, PPC_NONE, PPC2_ISA300),
|
2016-06-21 23:48:55 +02: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 17:22:31 +02:00
|
|
|
GEN_HANDLER(hrfid, 0x13, 0x12, 0x08, 0x03FF8001, PPC_64H),
|
|
|
|
#endif
|
2020-05-07 13:53:28 +02:00
|
|
|
/* Top bit of opc2 corresponds with low bit of LEV, so use two handlers */
|
|
|
|
GEN_HANDLER(sc, 0x11, 0x11, 0xFF, 0x03FFF01D, PPC_FLOW),
|
|
|
|
GEN_HANDLER(sc, 0x11, 0x01, 0xFF, 0x03FFF01D, PPC_FLOW),
|
2009-06-17 17:22:31 +02:00
|
|
|
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 13:58:35 +02:00
|
|
|
GEN_HANDLER_E(setb, 0x1F, 0x00, 0x04, 0x0003F801, PPC_NONE, PPC2_ISA300),
|
2017-02-27 05:58:01 +01:00
|
|
|
GEN_HANDLER_E(mcrxrx, 0x1F, 0x00, 0x12, 0x007FF801, PPC_NONE, PPC2_ISA300),
|
2009-06-17 17:22:31 +02:00
|
|
|
#endif
|
2016-06-07 04:50:25 +02:00
|
|
|
GEN_HANDLER(mtmsr, 0x1F, 0x12, 0x04, 0x001EF801, PPC_MISC),
|
2015-11-11 23:49:39 +01:00
|
|
|
GEN_HANDLER(mtspr, 0x1F, 0x13, 0x0E, 0x00000000, PPC_MISC),
|
2009-06-17 17:22:31 +02:00
|
|
|
GEN_HANDLER(dcbf, 0x1F, 0x16, 0x02, 0x03C00001, PPC_CACHE),
|
2018-09-21 08:59:07 +02:00
|
|
|
GEN_HANDLER_E(dcbfep, 0x1F, 0x1F, 0x03, 0x03C00001, PPC_NONE, PPC2_BOOKE206),
|
2009-06-17 17:22:31 +02:00
|
|
|
GEN_HANDLER(dcbi, 0x1F, 0x16, 0x0E, 0x03E00001, PPC_CACHE),
|
|
|
|
GEN_HANDLER(dcbst, 0x1F, 0x16, 0x01, 0x03E00001, PPC_CACHE),
|
2018-09-21 08:59:07 +02:00
|
|
|
GEN_HANDLER_E(dcbstep, 0x1F, 0x1F, 0x01, 0x03E00001, PPC_NONE, PPC2_BOOKE206),
|
target-ppc: add extended opcodes for dcbt/dcbtst
The latest glibc provides a memrchr routine using an extended opcode
of the 'dcbt' instruction :
00000000000a7cc0 <memrchr>:
a7cc0: 11 00 4c 3c addis r2,r12,17
a7cc4: b8 f8 42 38 addi r2,r2,-1864
a7cc8: 14 2a e3 7c add r7,r3,r5
a7ccc: d0 00 07 7c neg r0,r7
a7cd0: ff ff e7 38 addi r7,r7,-1
a7cd4: 78 1b 6a 7c mr r10,r3
a7cd8: 24 06 e6 78 rldicr r6,r7,0,56
a7cdc: 60 00 20 39 li r9,96
a7ce0: 2c 32 09 7e dcbtt r9,r6
....
which breaks grep, and other commands, in TCG mode :
invalid bits: 02000000 for opcode: 1f - 16 - 08 (7e09322c) 00003fff799feca0
This patch adds the extended opcodes for dcbt/dcbtst as no-ops just
like the 'dcbt' instruction.
Signed-off-by: Cédric Le Goater <clg@fr.ibm.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
2014-02-20 14:20:35 +01:00
|
|
|
GEN_HANDLER(dcbt, 0x1F, 0x16, 0x08, 0x00000001, PPC_CACHE),
|
2018-09-21 08:59:07 +02:00
|
|
|
GEN_HANDLER_E(dcbtep, 0x1F, 0x1F, 0x09, 0x00000001, PPC_NONE, PPC2_BOOKE206),
|
target-ppc: add extended opcodes for dcbt/dcbtst
The latest glibc provides a memrchr routine using an extended opcode
of the 'dcbt' instruction :
00000000000a7cc0 <memrchr>:
a7cc0: 11 00 4c 3c addis r2,r12,17
a7cc4: b8 f8 42 38 addi r2,r2,-1864
a7cc8: 14 2a e3 7c add r7,r3,r5
a7ccc: d0 00 07 7c neg r0,r7
a7cd0: ff ff e7 38 addi r7,r7,-1
a7cd4: 78 1b 6a 7c mr r10,r3
a7cd8: 24 06 e6 78 rldicr r6,r7,0,56
a7cdc: 60 00 20 39 li r9,96
a7ce0: 2c 32 09 7e dcbtt r9,r6
....
which breaks grep, and other commands, in TCG mode :
invalid bits: 02000000 for opcode: 1f - 16 - 08 (7e09322c) 00003fff799feca0
This patch adds the extended opcodes for dcbt/dcbtst as no-ops just
like the 'dcbt' instruction.
Signed-off-by: Cédric Le Goater <clg@fr.ibm.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
2014-02-20 14:20:35 +01:00
|
|
|
GEN_HANDLER(dcbtst, 0x1F, 0x16, 0x07, 0x00000001, PPC_CACHE),
|
2018-09-21 08:59:07 +02:00
|
|
|
GEN_HANDLER_E(dcbtstep, 0x1F, 0x1F, 0x07, 0x00000001, PPC_NONE, PPC2_BOOKE206),
|
2014-01-19 17:50:09 +01:00
|
|
|
GEN_HANDLER_E(dcbtls, 0x1F, 0x06, 0x05, 0x02000001, PPC_BOOKE, PPC2_BOOKE206),
|
2013-01-29 13:36:02 +01:00
|
|
|
GEN_HANDLER(dcbz, 0x1F, 0x16, 0x1F, 0x03C00001, PPC_CACHE_DCBZ),
|
2018-09-21 08:59:07 +02:00
|
|
|
GEN_HANDLER_E(dcbzep, 0x1F, 0x1F, 0x1F, 0x03C00001, PPC_NONE, PPC2_BOOKE206),
|
2009-06-17 17:22:31 +02:00
|
|
|
GEN_HANDLER(dst, 0x1F, 0x16, 0x0A, 0x01800001, PPC_ALTIVEC),
|
2018-03-26 01:54:28 +02:00
|
|
|
GEN_HANDLER(dstst, 0x1F, 0x16, 0x0B, 0x01800001, PPC_ALTIVEC),
|
2009-06-17 17:22:31 +02:00
|
|
|
GEN_HANDLER(dss, 0x1F, 0x16, 0x19, 0x019FF801, PPC_ALTIVEC),
|
|
|
|
GEN_HANDLER(icbi, 0x1F, 0x16, 0x1E, 0x03E00001, PPC_CACHE_ICBI),
|
2018-09-21 08:59:07 +02:00
|
|
|
GEN_HANDLER_E(icbiep, 0x1F, 0x1F, 0x1E, 0x03E00001, PPC_NONE, PPC2_BOOKE206),
|
2009-06-17 17:22:31 +02:00
|
|
|
GEN_HANDLER(dcba, 0x1F, 0x16, 0x17, 0x03E00001, PPC_CACHE_DCBA),
|
|
|
|
GEN_HANDLER(mfsr, 0x1F, 0x13, 0x12, 0x0010F801, PPC_SEGMENT),
|
|
|
|
GEN_HANDLER(mfsrin, 0x1F, 0x13, 0x14, 0x001F0001, PPC_SEGMENT),
|
|
|
|
GEN_HANDLER(mtsr, 0x1F, 0x12, 0x06, 0x0010F801, PPC_SEGMENT),
|
|
|
|
GEN_HANDLER(mtsrin, 0x1F, 0x12, 0x07, 0x001F0001, PPC_SEGMENT),
|
|
|
|
#if defined(TARGET_PPC64)
|
|
|
|
GEN_HANDLER2(mfsr_64b, "mfsr", 0x1F, 0x13, 0x12, 0x0010F801, PPC_SEGMENT_64B),
|
|
|
|
GEN_HANDLER2(mfsrin_64b, "mfsrin", 0x1F, 0x13, 0x14, 0x001F0001,
|
|
|
|
PPC_SEGMENT_64B),
|
|
|
|
GEN_HANDLER2(mtsr_64b, "mtsr", 0x1F, 0x12, 0x06, 0x0010F801, PPC_SEGMENT_64B),
|
|
|
|
GEN_HANDLER2(mtsrin_64b, "mtsrin", 0x1F, 0x12, 0x07, 0x001F0001,
|
|
|
|
PPC_SEGMENT_64B),
|
2011-04-01 06:15:11 +02:00
|
|
|
GEN_HANDLER2(slbmte, "slbmte", 0x1F, 0x12, 0x0C, 0x001F0001, PPC_SEGMENT_64B),
|
|
|
|
GEN_HANDLER2(slbmfee, "slbmfee", 0x1F, 0x13, 0x1C, 0x001F0001, PPC_SEGMENT_64B),
|
|
|
|
GEN_HANDLER2(slbmfev, "slbmfev", 0x1F, 0x13, 0x1A, 0x001F0001, PPC_SEGMENT_64B),
|
2016-06-07 04:50:27 +02:00
|
|
|
GEN_HANDLER2(slbfee_, "slbfee.", 0x1F, 0x13, 0x1E, 0x001F0000, PPC_SEGMENT_64B),
|
2009-06-17 17:22:31 +02:00
|
|
|
#endif
|
|
|
|
GEN_HANDLER(tlbia, 0x1F, 0x12, 0x0B, 0x03FFFC01, PPC_MEM_TLBIA),
|
2019-03-21 12:57:28 +01:00
|
|
|
/*
|
|
|
|
* XXX Those instructions will need to be handled differently for
|
|
|
|
* different ISA versions
|
|
|
|
*/
|
2016-05-03 18:03:31 +02:00
|
|
|
GEN_HANDLER(tlbiel, 0x1F, 0x12, 0x08, 0x001F0001, PPC_MEM_TLBIE),
|
|
|
|
GEN_HANDLER(tlbie, 0x1F, 0x12, 0x09, 0x001F0001, PPC_MEM_TLBIE),
|
2017-05-02 08:37:16 +02:00
|
|
|
GEN_HANDLER_E(tlbiel, 0x1F, 0x12, 0x08, 0x00100001, PPC_NONE, PPC2_ISA300),
|
|
|
|
GEN_HANDLER_E(tlbie, 0x1F, 0x12, 0x09, 0x00100001, PPC_NONE, PPC2_ISA300),
|
2009-06-17 17:22:31 +02:00
|
|
|
GEN_HANDLER(tlbsync, 0x1F, 0x16, 0x11, 0x03FFF801, PPC_MEM_TLBSYNC),
|
|
|
|
#if defined(TARGET_PPC64)
|
2016-06-07 04:50:26 +02:00
|
|
|
GEN_HANDLER(slbia, 0x1F, 0x12, 0x0F, 0x031FFC01, PPC_SLBI),
|
2009-06-17 17:22:31 +02:00
|
|
|
GEN_HANDLER(slbie, 0x1F, 0x12, 0x0D, 0x03FF0001, PPC_SLBI),
|
2017-02-09 11:34:01 +01:00
|
|
|
GEN_HANDLER_E(slbieg, 0x1F, 0x12, 0x0E, 0x001F0001, PPC_NONE, PPC2_ISA300),
|
2017-02-09 11:34:02 +01:00
|
|
|
GEN_HANDLER_E(slbsync, 0x1F, 0x12, 0x0A, 0x03FFF801, PPC_NONE, PPC2_ISA300),
|
2009-06-17 17:22:31 +02:00
|
|
|
#endif
|
|
|
|
GEN_HANDLER(eciwx, 0x1F, 0x16, 0x0D, 0x00000001, PPC_EXTERN),
|
|
|
|
GEN_HANDLER(ecowx, 0x1F, 0x16, 0x09, 0x00000001, PPC_EXTERN),
|
|
|
|
GEN_HANDLER(abs, 0x1F, 0x08, 0x0B, 0x0000F800, PPC_POWER_BR),
|
|
|
|
GEN_HANDLER(abso, 0x1F, 0x08, 0x1B, 0x0000F800, PPC_POWER_BR),
|
|
|
|
GEN_HANDLER(clcs, 0x1F, 0x10, 0x13, 0x0000F800, PPC_POWER_BR),
|
|
|
|
GEN_HANDLER(div, 0x1F, 0x0B, 0x0A, 0x00000000, PPC_POWER_BR),
|
|
|
|
GEN_HANDLER(divo, 0x1F, 0x0B, 0x1A, 0x00000000, PPC_POWER_BR),
|
|
|
|
GEN_HANDLER(divs, 0x1F, 0x0B, 0x0B, 0x00000000, PPC_POWER_BR),
|
|
|
|
GEN_HANDLER(divso, 0x1F, 0x0B, 0x1B, 0x00000000, PPC_POWER_BR),
|
|
|
|
GEN_HANDLER(doz, 0x1F, 0x08, 0x08, 0x00000000, PPC_POWER_BR),
|
|
|
|
GEN_HANDLER(dozo, 0x1F, 0x08, 0x18, 0x00000000, PPC_POWER_BR),
|
|
|
|
GEN_HANDLER(dozi, 0x09, 0xFF, 0xFF, 0x00000000, PPC_POWER_BR),
|
|
|
|
GEN_HANDLER(lscbx, 0x1F, 0x15, 0x08, 0x00000000, PPC_POWER_BR),
|
|
|
|
GEN_HANDLER(maskg, 0x1F, 0x1D, 0x00, 0x00000000, PPC_POWER_BR),
|
|
|
|
GEN_HANDLER(maskir, 0x1F, 0x1D, 0x10, 0x00000000, PPC_POWER_BR),
|
|
|
|
GEN_HANDLER(mul, 0x1F, 0x0B, 0x03, 0x00000000, PPC_POWER_BR),
|
|
|
|
GEN_HANDLER(mulo, 0x1F, 0x0B, 0x13, 0x00000000, PPC_POWER_BR),
|
|
|
|
GEN_HANDLER(nabs, 0x1F, 0x08, 0x0F, 0x00000000, PPC_POWER_BR),
|
|
|
|
GEN_HANDLER(nabso, 0x1F, 0x08, 0x1F, 0x00000000, PPC_POWER_BR),
|
|
|
|
GEN_HANDLER(rlmi, 0x16, 0xFF, 0xFF, 0x00000000, PPC_POWER_BR),
|
|
|
|
GEN_HANDLER(rrib, 0x1F, 0x19, 0x10, 0x00000000, PPC_POWER_BR),
|
|
|
|
GEN_HANDLER(sle, 0x1F, 0x19, 0x04, 0x00000000, PPC_POWER_BR),
|
|
|
|
GEN_HANDLER(sleq, 0x1F, 0x19, 0x06, 0x00000000, PPC_POWER_BR),
|
|
|
|
GEN_HANDLER(sliq, 0x1F, 0x18, 0x05, 0x00000000, PPC_POWER_BR),
|
|
|
|
GEN_HANDLER(slliq, 0x1F, 0x18, 0x07, 0x00000000, PPC_POWER_BR),
|
|
|
|
GEN_HANDLER(sllq, 0x1F, 0x18, 0x06, 0x00000000, PPC_POWER_BR),
|
|
|
|
GEN_HANDLER(slq, 0x1F, 0x18, 0x04, 0x00000000, PPC_POWER_BR),
|
|
|
|
GEN_HANDLER(sraiq, 0x1F, 0x18, 0x1D, 0x00000000, PPC_POWER_BR),
|
|
|
|
GEN_HANDLER(sraq, 0x1F, 0x18, 0x1C, 0x00000000, PPC_POWER_BR),
|
|
|
|
GEN_HANDLER(sre, 0x1F, 0x19, 0x14, 0x00000000, PPC_POWER_BR),
|
|
|
|
GEN_HANDLER(srea, 0x1F, 0x19, 0x1C, 0x00000000, PPC_POWER_BR),
|
|
|
|
GEN_HANDLER(sreq, 0x1F, 0x19, 0x16, 0x00000000, PPC_POWER_BR),
|
|
|
|
GEN_HANDLER(sriq, 0x1F, 0x18, 0x15, 0x00000000, PPC_POWER_BR),
|
|
|
|
GEN_HANDLER(srliq, 0x1F, 0x18, 0x17, 0x00000000, PPC_POWER_BR),
|
|
|
|
GEN_HANDLER(srlq, 0x1F, 0x18, 0x16, 0x00000000, PPC_POWER_BR),
|
|
|
|
GEN_HANDLER(srq, 0x1F, 0x18, 0x14, 0x00000000, PPC_POWER_BR),
|
|
|
|
GEN_HANDLER(dsa, 0x1F, 0x14, 0x13, 0x03FFF801, PPC_602_SPEC),
|
|
|
|
GEN_HANDLER(esa, 0x1F, 0x14, 0x12, 0x03FFF801, PPC_602_SPEC),
|
|
|
|
GEN_HANDLER(mfrom, 0x1F, 0x09, 0x08, 0x03E0F801, PPC_602_SPEC),
|
|
|
|
GEN_HANDLER2(tlbld_6xx, "tlbld", 0x1F, 0x12, 0x1E, 0x03FF0001, PPC_6xx_TLB),
|
|
|
|
GEN_HANDLER2(tlbli_6xx, "tlbli", 0x1F, 0x12, 0x1F, 0x03FF0001, PPC_6xx_TLB),
|
|
|
|
GEN_HANDLER2(tlbld_74xx, "tlbld", 0x1F, 0x12, 0x1E, 0x03FF0001, PPC_74xx_TLB),
|
|
|
|
GEN_HANDLER2(tlbli_74xx, "tlbli", 0x1F, 0x12, 0x1F, 0x03FF0001, PPC_74xx_TLB),
|
|
|
|
GEN_HANDLER(clf, 0x1F, 0x16, 0x03, 0x03E00000, PPC_POWER),
|
|
|
|
GEN_HANDLER(cli, 0x1F, 0x16, 0x0F, 0x03E00000, PPC_POWER),
|
|
|
|
GEN_HANDLER(dclst, 0x1F, 0x16, 0x13, 0x03E00000, PPC_POWER),
|
|
|
|
GEN_HANDLER(mfsri, 0x1F, 0x13, 0x13, 0x00000001, PPC_POWER),
|
|
|
|
GEN_HANDLER(rac, 0x1F, 0x12, 0x19, 0x00000001, PPC_POWER),
|
|
|
|
GEN_HANDLER(rfsvc, 0x13, 0x12, 0x02, 0x03FFF0001, PPC_POWER),
|
|
|
|
GEN_HANDLER(lfq, 0x38, 0xFF, 0xFF, 0x00000003, PPC_POWER2),
|
|
|
|
GEN_HANDLER(lfqu, 0x39, 0xFF, 0xFF, 0x00000003, PPC_POWER2),
|
|
|
|
GEN_HANDLER(lfqux, 0x1F, 0x17, 0x19, 0x00000001, PPC_POWER2),
|
|
|
|
GEN_HANDLER(lfqx, 0x1F, 0x17, 0x18, 0x00000001, PPC_POWER2),
|
|
|
|
GEN_HANDLER(stfq, 0x3C, 0xFF, 0xFF, 0x00000003, PPC_POWER2),
|
|
|
|
GEN_HANDLER(stfqu, 0x3D, 0xFF, 0xFF, 0x00000003, PPC_POWER2),
|
|
|
|
GEN_HANDLER(stfqux, 0x1F, 0x17, 0x1D, 0x00000001, PPC_POWER2),
|
|
|
|
GEN_HANDLER(stfqx, 0x1F, 0x17, 0x1C, 0x00000001, PPC_POWER2),
|
|
|
|
GEN_HANDLER(mfapidi, 0x1F, 0x13, 0x08, 0x0000F801, PPC_MFAPIDI),
|
|
|
|
GEN_HANDLER(tlbiva, 0x1F, 0x12, 0x18, 0x03FFF801, PPC_TLBIVA),
|
|
|
|
GEN_HANDLER(mfdcr, 0x1F, 0x03, 0x0A, 0x00000001, PPC_DCR),
|
|
|
|
GEN_HANDLER(mtdcr, 0x1F, 0x03, 0x0E, 0x00000001, PPC_DCR),
|
|
|
|
GEN_HANDLER(mfdcrx, 0x1F, 0x03, 0x08, 0x00000000, PPC_DCRX),
|
|
|
|
GEN_HANDLER(mtdcrx, 0x1F, 0x03, 0x0C, 0x00000000, PPC_DCRX),
|
|
|
|
GEN_HANDLER(mfdcrux, 0x1F, 0x03, 0x09, 0x00000000, PPC_DCRUX),
|
|
|
|
GEN_HANDLER(mtdcrux, 0x1F, 0x03, 0x0D, 0x00000000, PPC_DCRUX),
|
|
|
|
GEN_HANDLER(dccci, 0x1F, 0x06, 0x0E, 0x03E00001, PPC_4xx_COMMON),
|
|
|
|
GEN_HANDLER(dcread, 0x1F, 0x06, 0x0F, 0x00000001, PPC_4xx_COMMON),
|
|
|
|
GEN_HANDLER2(icbt_40x, "icbt", 0x1F, 0x06, 0x08, 0x03E00001, PPC_40x_ICBT),
|
|
|
|
GEN_HANDLER(iccci, 0x1F, 0x06, 0x1E, 0x00000001, PPC_4xx_COMMON),
|
|
|
|
GEN_HANDLER(icread, 0x1F, 0x06, 0x1F, 0x03E00001, PPC_4xx_COMMON),
|
|
|
|
GEN_HANDLER2(rfci_40x, "rfci", 0x13, 0x13, 0x01, 0x03FF8001, PPC_40x_EXCP),
|
2011-04-30 23:34:58 +02:00
|
|
|
GEN_HANDLER_E(rfci, 0x13, 0x13, 0x01, 0x03FF8001, PPC_BOOKE, PPC2_BOOKE206),
|
2009-06-17 17:22:31 +02:00
|
|
|
GEN_HANDLER(rfdi, 0x13, 0x07, 0x01, 0x03FF8001, PPC_RFDI),
|
|
|
|
GEN_HANDLER(rfmci, 0x13, 0x06, 0x01, 0x03FF8001, PPC_RFMCI),
|
|
|
|
GEN_HANDLER2(tlbre_40x, "tlbre", 0x1F, 0x12, 0x1D, 0x00000001, PPC_40x_TLB),
|
|
|
|
GEN_HANDLER2(tlbsx_40x, "tlbsx", 0x1F, 0x12, 0x1C, 0x00000000, PPC_40x_TLB),
|
|
|
|
GEN_HANDLER2(tlbwe_40x, "tlbwe", 0x1F, 0x12, 0x1E, 0x00000001, PPC_40x_TLB),
|
|
|
|
GEN_HANDLER2(tlbre_440, "tlbre", 0x1F, 0x12, 0x1D, 0x00000001, PPC_BOOKE),
|
|
|
|
GEN_HANDLER2(tlbsx_440, "tlbsx", 0x1F, 0x12, 0x1C, 0x00000000, PPC_BOOKE),
|
|
|
|
GEN_HANDLER2(tlbwe_440, "tlbwe", 0x1F, 0x12, 0x1E, 0x00000001, PPC_BOOKE),
|
2011-04-30 23:34:58 +02:00
|
|
|
GEN_HANDLER2_E(tlbre_booke206, "tlbre", 0x1F, 0x12, 0x1D, 0x00000001,
|
|
|
|
PPC_NONE, PPC2_BOOKE206),
|
|
|
|
GEN_HANDLER2_E(tlbsx_booke206, "tlbsx", 0x1F, 0x12, 0x1C, 0x00000000,
|
|
|
|
PPC_NONE, PPC2_BOOKE206),
|
|
|
|
GEN_HANDLER2_E(tlbwe_booke206, "tlbwe", 0x1F, 0x12, 0x1E, 0x00000001,
|
|
|
|
PPC_NONE, PPC2_BOOKE206),
|
|
|
|
GEN_HANDLER2_E(tlbivax_booke206, "tlbivax", 0x1F, 0x12, 0x18, 0x00000001,
|
|
|
|
PPC_NONE, PPC2_BOOKE206),
|
2012-01-20 04:09:15 +01:00
|
|
|
GEN_HANDLER2_E(tlbilx_booke206, "tlbilx", 0x1F, 0x12, 0x00, 0x03800001,
|
|
|
|
PPC_NONE, PPC2_BOOKE206),
|
2012-01-31 03:19:23 +01:00
|
|
|
GEN_HANDLER2_E(msgsnd, "msgsnd", 0x1F, 0x0E, 0x06, 0x03ff0001,
|
|
|
|
PPC_NONE, PPC2_PRCNTL),
|
2012-01-31 03:18:35 +01:00
|
|
|
GEN_HANDLER2_E(msgclr, "msgclr", 0x1F, 0x0E, 0x07, 0x03ff0001,
|
|
|
|
PPC_NONE, PPC2_PRCNTL),
|
2018-01-18 15:54:03 +01:00
|
|
|
GEN_HANDLER2_E(msgsync, "msgsync", 0x1F, 0x16, 0x1B, 0x00000000,
|
|
|
|
PPC_NONE, PPC2_PRCNTL),
|
2009-06-17 17:22:31 +02:00
|
|
|
GEN_HANDLER(wrtee, 0x1F, 0x03, 0x04, 0x000FFC01, PPC_WRTEE),
|
2009-07-03 12:56:57 +02:00
|
|
|
GEN_HANDLER(wrteei, 0x1F, 0x03, 0x05, 0x000E7C01, PPC_WRTEE),
|
2009-06-17 17:22:31 +02:00
|
|
|
GEN_HANDLER(dlmzb, 0x1F, 0x0E, 0x02, 0x00000000, PPC_440_SPEC),
|
2011-04-30 23:34:58 +02:00
|
|
|
GEN_HANDLER_E(mbar, 0x1F, 0x16, 0x1a, 0x001FF801,
|
|
|
|
PPC_BOOKE, PPC2_BOOKE206),
|
2019-01-26 15:50:28 +01:00
|
|
|
GEN_HANDLER(msync_4xx, 0x1F, 0x16, 0x12, 0x039FF801, PPC_BOOKE),
|
2011-04-30 23:34:58 +02:00
|
|
|
GEN_HANDLER2_E(icbt_440, "icbt", 0x1F, 0x16, 0x00, 0x03E00001,
|
|
|
|
PPC_BOOKE, PPC2_BOOKE206),
|
2018-06-19 10:52:15 +02:00
|
|
|
GEN_HANDLER2(icbt_440, "icbt", 0x1F, 0x06, 0x08, 0x03E00001,
|
2019-01-26 15:50:28 +01:00
|
|
|
PPC_440_SPEC),
|
2009-06-17 17:22:31 +02:00
|
|
|
GEN_HANDLER(lvsl, 0x1f, 0x06, 0x00, 0x00000001, PPC_ALTIVEC),
|
|
|
|
GEN_HANDLER(lvsr, 0x1f, 0x06, 0x01, 0x00000001, PPC_ALTIVEC),
|
|
|
|
GEN_HANDLER(mfvscr, 0x04, 0x2, 0x18, 0x001ff800, PPC_ALTIVEC),
|
|
|
|
GEN_HANDLER(mtvscr, 0x04, 0x2, 0x19, 0x03ff0000, PPC_ALTIVEC),
|
|
|
|
GEN_HANDLER(vmladduhm, 0x04, 0x11, 0xFF, 0x00000000, PPC_ALTIVEC),
|
2016-07-26 13:58:36 +02:00
|
|
|
#if defined(TARGET_PPC64)
|
2016-07-26 13:58:37 +02:00
|
|
|
GEN_HANDLER_E(maddhd_maddhdu, 0x04, 0x18, 0xFF, 0x00000000, PPC_NONE,
|
|
|
|
PPC2_ISA300),
|
2016-07-26 13:58:36 +02:00
|
|
|
GEN_HANDLER_E(maddld, 0x04, 0x19, 0xFF, 0x00000000, PPC_NONE, PPC2_ISA300),
|
2020-01-20 11:49:34 +01:00
|
|
|
GEN_HANDLER2_E(msgsndp, "msgsndp", 0x1F, 0x0E, 0x04, 0x03ff0001,
|
|
|
|
PPC_NONE, PPC2_ISA207S),
|
|
|
|
GEN_HANDLER2_E(msgclrp, "msgclrp", 0x1F, 0x0E, 0x05, 0x03ff0001,
|
|
|
|
PPC_NONE, PPC2_ISA207S),
|
2016-07-26 13:58:36 +02:00
|
|
|
#endif
|
2009-06-17 17:22:31 +02: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)
|
2018-11-15 04:22:59 +01:00
|
|
|
GEN_HANDLER_E(addex, 0x1F, 0x0A, 0x05, 0x00000000, PPC_NONE, PPC2_ISA300),
|
2009-06-17 17:22:31 +02:00
|
|
|
GEN_INT_ARITH_ADD_CONST(addze, 0x06, 0, 1, 1, 0)
|
|
|
|
GEN_INT_ARITH_ADD_CONST(addzeo, 0x16, 0, 1, 1, 1)
|
|
|
|
|
|
|
|
#undef GEN_INT_ARITH_DIVW
|
|
|
|
#define GEN_INT_ARITH_DIVW(name, opc3, sign, compute_ov) \
|
|
|
|
GEN_HANDLER(name, 0x1F, 0x0B, opc3, 0x00000000, PPC_INTEGER)
|
|
|
|
GEN_INT_ARITH_DIVW(divwu, 0x0E, 0, 0),
|
|
|
|
GEN_INT_ARITH_DIVW(divwuo, 0x1E, 0, 1),
|
|
|
|
GEN_INT_ARITH_DIVW(divw, 0x0F, 1, 0),
|
|
|
|
GEN_INT_ARITH_DIVW(divwo, 0x1F, 1, 1),
|
2014-01-07 17:05:54 +01:00
|
|
|
GEN_HANDLER_E(divwe, 0x1F, 0x0B, 0x0D, 0, PPC_NONE, PPC2_DIVE_ISA206),
|
|
|
|
GEN_HANDLER_E(divweo, 0x1F, 0x0B, 0x1D, 0, PPC_NONE, PPC2_DIVE_ISA206),
|
2014-01-07 17:05:53 +01:00
|
|
|
GEN_HANDLER_E(divweu, 0x1F, 0x0B, 0x0C, 0, PPC_NONE, PPC2_DIVE_ISA206),
|
|
|
|
GEN_HANDLER_E(divweuo, 0x1F, 0x0B, 0x1C, 0, PPC_NONE, PPC2_DIVE_ISA206),
|
2016-07-26 13:58:28 +02: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 17:22:31 +02:00
|
|
|
|
|
|
|
#if defined(TARGET_PPC64)
|
|
|
|
#undef GEN_INT_ARITH_DIVD
|
|
|
|
#define GEN_INT_ARITH_DIVD(name, opc3, sign, compute_ov) \
|
|
|
|
GEN_HANDLER(name, 0x1F, 0x09, opc3, 0x00000000, PPC_64B)
|
|
|
|
GEN_INT_ARITH_DIVD(divdu, 0x0E, 0, 0),
|
|
|
|
GEN_INT_ARITH_DIVD(divduo, 0x1E, 0, 1),
|
|
|
|
GEN_INT_ARITH_DIVD(divd, 0x0F, 1, 0),
|
|
|
|
GEN_INT_ARITH_DIVD(divdo, 0x1F, 1, 1),
|
|
|
|
|
2014-01-07 17:05:51 +01:00
|
|
|
GEN_HANDLER_E(divdeu, 0x1F, 0x09, 0x0C, 0, PPC_NONE, PPC2_DIVE_ISA206),
|
|
|
|
GEN_HANDLER_E(divdeuo, 0x1F, 0x09, 0x1C, 0, PPC_NONE, PPC2_DIVE_ISA206),
|
2014-01-07 17:05:52 +01:00
|
|
|
GEN_HANDLER_E(divde, 0x1F, 0x09, 0x0D, 0, PPC_NONE, PPC2_DIVE_ISA206),
|
|
|
|
GEN_HANDLER_E(divdeo, 0x1F, 0x09, 0x1D, 0, PPC_NONE, PPC2_DIVE_ISA206),
|
2016-07-26 13:58:29 +02: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 17:05:51 +01:00
|
|
|
|
2009-06-17 17:22:31 +02:00
|
|
|
#undef GEN_INT_ARITH_MUL_HELPER
|
|
|
|
#define GEN_INT_ARITH_MUL_HELPER(name, opc3) \
|
|
|
|
GEN_HANDLER(name, 0x1F, 0x09, opc3, 0x00000000, PPC_64B)
|
|
|
|
GEN_INT_ARITH_MUL_HELPER(mulhdu, 0x00),
|
|
|
|
GEN_INT_ARITH_MUL_HELPER(mulhd, 0x02),
|
|
|
|
GEN_INT_ARITH_MUL_HELPER(mulldo, 0x17),
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#undef GEN_INT_ARITH_SUBF
|
|
|
|
#undef GEN_INT_ARITH_SUBF_CONST
|
|
|
|
#define GEN_INT_ARITH_SUBF(name, opc3, add_ca, compute_ca, compute_ov) \
|
|
|
|
GEN_HANDLER(name, 0x1F, 0x08, opc3, 0x00000000, PPC_INTEGER),
|
|
|
|
#define GEN_INT_ARITH_SUBF_CONST(name, opc3, const_val, \
|
|
|
|
add_ca, compute_ca, compute_ov) \
|
|
|
|
GEN_HANDLER(name, 0x1F, 0x08, opc3, 0x0000F800, PPC_INTEGER),
|
|
|
|
GEN_INT_ARITH_SUBF(subf, 0x01, 0, 0, 0)
|
|
|
|
GEN_INT_ARITH_SUBF(subfo, 0x11, 0, 0, 1)
|
|
|
|
GEN_INT_ARITH_SUBF(subfc, 0x00, 0, 1, 0)
|
|
|
|
GEN_INT_ARITH_SUBF(subfco, 0x10, 0, 1, 1)
|
|
|
|
GEN_INT_ARITH_SUBF(subfe, 0x04, 1, 1, 0)
|
|
|
|
GEN_INT_ARITH_SUBF(subfeo, 0x14, 1, 1, 1)
|
|
|
|
GEN_INT_ARITH_SUBF_CONST(subfme, 0x07, -1LL, 1, 1, 0)
|
|
|
|
GEN_INT_ARITH_SUBF_CONST(subfmeo, 0x17, -1LL, 1, 1, 1)
|
|
|
|
GEN_INT_ARITH_SUBF_CONST(subfze, 0x06, 0, 1, 1, 0)
|
|
|
|
GEN_INT_ARITH_SUBF_CONST(subfzeo, 0x16, 0, 1, 1, 1)
|
|
|
|
|
|
|
|
#undef GEN_LOGICAL1
|
|
|
|
#undef GEN_LOGICAL2
|
|
|
|
#define GEN_LOGICAL2(name, tcg_op, opc, type) \
|
|
|
|
GEN_HANDLER(name, 0x1F, 0x1C, opc, 0x00000000, type)
|
|
|
|
#define GEN_LOGICAL1(name, tcg_op, opc, type) \
|
|
|
|
GEN_HANDLER(name, 0x1F, 0x1A, opc, 0x00000000, type)
|
|
|
|
GEN_LOGICAL2(and, tcg_gen_and_tl, 0x00, PPC_INTEGER),
|
|
|
|
GEN_LOGICAL2(andc, tcg_gen_andc_tl, 0x01, PPC_INTEGER),
|
|
|
|
GEN_LOGICAL2(eqv, tcg_gen_eqv_tl, 0x08, PPC_INTEGER),
|
|
|
|
GEN_LOGICAL1(extsb, tcg_gen_ext8s_tl, 0x1D, PPC_INTEGER),
|
|
|
|
GEN_LOGICAL1(extsh, tcg_gen_ext16s_tl, 0x1C, PPC_INTEGER),
|
|
|
|
GEN_LOGICAL2(nand, tcg_gen_nand_tl, 0x0E, PPC_INTEGER),
|
|
|
|
GEN_LOGICAL2(nor, tcg_gen_nor_tl, 0x03, PPC_INTEGER),
|
|
|
|
GEN_LOGICAL2(orc, tcg_gen_orc_tl, 0x0C, PPC_INTEGER),
|
|
|
|
#if defined(TARGET_PPC64)
|
|
|
|
GEN_LOGICAL1(extsw, tcg_gen_ext32s_tl, 0x1E, PPC_64B),
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(TARGET_PPC64)
|
|
|
|
#undef GEN_PPC64_R2
|
|
|
|
#undef GEN_PPC64_R4
|
|
|
|
#define GEN_PPC64_R2(name, opc1, opc2) \
|
|
|
|
GEN_HANDLER2(name##0, stringify(name), opc1, opc2, 0xFF, 0x00000000, PPC_64B),\
|
|
|
|
GEN_HANDLER2(name##1, stringify(name), opc1, opc2 | 0x10, 0xFF, 0x00000000, \
|
|
|
|
PPC_64B)
|
|
|
|
#define GEN_PPC64_R4(name, opc1, opc2) \
|
|
|
|
GEN_HANDLER2(name##0, stringify(name), opc1, opc2, 0xFF, 0x00000000, PPC_64B),\
|
|
|
|
GEN_HANDLER2(name##1, stringify(name), opc1, opc2 | 0x01, 0xFF, 0x00000000, \
|
|
|
|
PPC_64B), \
|
|
|
|
GEN_HANDLER2(name##2, stringify(name), opc1, opc2 | 0x10, 0xFF, 0x00000000, \
|
|
|
|
PPC_64B), \
|
|
|
|
GEN_HANDLER2(name##3, stringify(name), opc1, opc2 | 0x11, 0xFF, 0x00000000, \
|
|
|
|
PPC_64B)
|
|
|
|
GEN_PPC64_R4(rldicl, 0x1E, 0x00),
|
|
|
|
GEN_PPC64_R4(rldicr, 0x1E, 0x02),
|
|
|
|
GEN_PPC64_R4(rldic, 0x1E, 0x04),
|
|
|
|
GEN_PPC64_R2(rldcl, 0x1E, 0x08),
|
|
|
|
GEN_PPC64_R2(rldcr, 0x1E, 0x09),
|
|
|
|
GEN_PPC64_R4(rldimi, 0x1E, 0x06),
|
|
|
|
#endif
|
|
|
|
|
2012-02-27 18:18:08 +01:00
|
|
|
#undef GEN_LDX_E
|
2016-06-21 23:48:52 +02:00
|
|
|
#define GEN_LDX_E(name, ldop, opc2, opc3, type, type2, chk) \
|
2012-02-27 18:18:08 +01:00
|
|
|
GEN_HANDLER_E(name##x, 0x1F, opc2, opc3, 0x00000001, type, type2),
|
2021-06-01 21:35:20 +02:00
|
|
|
|
2009-06-17 17:22:31 +02:00
|
|
|
#if defined(TARGET_PPC64)
|
2016-09-12 08:41:32 +02:00
|
|
|
GEN_LDX_E(ldbr, ld64ur_i64, 0x14, 0x10, PPC_NONE, PPC2_DBRX, CHK_NONE)
|
2016-06-21 23:48:52 +02:00
|
|
|
|
|
|
|
/* HV/P7 and later only */
|
2016-09-12 08:41:31 +02:00
|
|
|
GEN_LDX_HVRM(ldcix, ld64_i64, 0x15, 0x1b, PPC_CILDST)
|
2016-06-21 23:48:52 +02:00
|
|
|
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 17:22:31 +02:00
|
|
|
#endif
|
|
|
|
GEN_LDX(lhbr, ld16ur, 0x16, 0x18, PPC_INTEGER)
|
|
|
|
GEN_LDX(lwbr, ld32ur, 0x16, 0x10, PPC_INTEGER)
|
|
|
|
|
2018-09-21 08:59:07 +02:00
|
|
|
/* External PID based load */
|
|
|
|
#undef GEN_LDEPX
|
|
|
|
#define GEN_LDEPX(name, ldop, opc2, opc3) \
|
|
|
|
GEN_HANDLER_E(name##epx, 0x1F, opc2, opc3, \
|
|
|
|
0x00000001, PPC_NONE, PPC2_BOOKE206),
|
|
|
|
|
|
|
|
GEN_LDEPX(lb, DEF_MEMOP(MO_UB), 0x1F, 0x02)
|
|
|
|
GEN_LDEPX(lh, DEF_MEMOP(MO_UW), 0x1F, 0x08)
|
|
|
|
GEN_LDEPX(lw, DEF_MEMOP(MO_UL), 0x1F, 0x00)
|
|
|
|
#if defined(TARGET_PPC64)
|
|
|
|
GEN_LDEPX(ld, DEF_MEMOP(MO_Q), 0x1D, 0x00)
|
|
|
|
#endif
|
|
|
|
|
2012-02-27 18:18:08 +01:00
|
|
|
#undef GEN_STX_E
|
2016-06-21 23:48:52 +02:00
|
|
|
#define GEN_STX_E(name, stop, opc2, opc3, type, type2, chk) \
|
2018-06-29 00:38:33 +02:00
|
|
|
GEN_HANDLER_E(name##x, 0x1F, opc2, opc3, 0x00000000, type, type2),
|
2021-06-01 21:35:22 +02:00
|
|
|
|
2009-06-17 17:22:31 +02:00
|
|
|
#if defined(TARGET_PPC64)
|
2016-09-12 08:41:35 +02:00
|
|
|
GEN_STX_E(stdbr, st64r_i64, 0x14, 0x14, PPC_NONE, PPC2_DBRX, CHK_NONE)
|
2016-09-12 08:41:34 +02:00
|
|
|
GEN_STX_HVRM(stdcix, st64_i64, 0x15, 0x1f, PPC_CILDST)
|
2016-06-21 23:48:52 +02:00
|
|
|
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 17:22:31 +02:00
|
|
|
#endif
|
|
|
|
GEN_STX(sthbr, st16r, 0x16, 0x1C, PPC_INTEGER)
|
|
|
|
GEN_STX(stwbr, st32r, 0x16, 0x14, PPC_INTEGER)
|
|
|
|
|
2018-09-21 08:59:07 +02:00
|
|
|
#undef GEN_STEPX
|
|
|
|
#define GEN_STEPX(name, ldop, opc2, opc3) \
|
|
|
|
GEN_HANDLER_E(name##epx, 0x1F, opc2, opc3, \
|
|
|
|
0x00000001, PPC_NONE, PPC2_BOOKE206),
|
|
|
|
|
|
|
|
GEN_STEPX(stb, DEF_MEMOP(MO_UB), 0x1F, 0x06)
|
|
|
|
GEN_STEPX(sth, DEF_MEMOP(MO_UW), 0x1F, 0x0C)
|
|
|
|
GEN_STEPX(stw, DEF_MEMOP(MO_UL), 0x1F, 0x04)
|
|
|
|
#if defined(TARGET_PPC64)
|
|
|
|
GEN_STEPX(std, DEF_MEMOP(MO_Q), 0x1D, 0x04)
|
|
|
|
#endif
|
|
|
|
|
2009-06-17 17:22:31 +02:00
|
|
|
#undef GEN_CRLOGIC
|
|
|
|
#define GEN_CRLOGIC(name, tcg_op, opc) \
|
|
|
|
GEN_HANDLER(name, 0x13, 0x01, opc, 0x00000001, PPC_INTEGER)
|
|
|
|
GEN_CRLOGIC(crand, tcg_gen_and_i32, 0x08),
|
|
|
|
GEN_CRLOGIC(crandc, tcg_gen_andc_i32, 0x04),
|
|
|
|
GEN_CRLOGIC(creqv, tcg_gen_eqv_i32, 0x09),
|
|
|
|
GEN_CRLOGIC(crnand, tcg_gen_nand_i32, 0x07),
|
|
|
|
GEN_CRLOGIC(crnor, tcg_gen_nor_i32, 0x01),
|
|
|
|
GEN_CRLOGIC(cror, tcg_gen_or_i32, 0x0E),
|
|
|
|
GEN_CRLOGIC(crorc, tcg_gen_orc_i32, 0x0D),
|
|
|
|
GEN_CRLOGIC(crxor, tcg_gen_xor_i32, 0x06),
|
|
|
|
|
|
|
|
#undef GEN_MAC_HANDLER
|
|
|
|
#define GEN_MAC_HANDLER(name, opc2, opc3) \
|
|
|
|
GEN_HANDLER(name, 0x04, opc2, opc3, 0x00000000, PPC_405_MAC)
|
|
|
|
GEN_MAC_HANDLER(macchw, 0x0C, 0x05),
|
|
|
|
GEN_MAC_HANDLER(macchwo, 0x0C, 0x15),
|
|
|
|
GEN_MAC_HANDLER(macchws, 0x0C, 0x07),
|
|
|
|
GEN_MAC_HANDLER(macchwso, 0x0C, 0x17),
|
|
|
|
GEN_MAC_HANDLER(macchwsu, 0x0C, 0x06),
|
|
|
|
GEN_MAC_HANDLER(macchwsuo, 0x0C, 0x16),
|
|
|
|
GEN_MAC_HANDLER(macchwu, 0x0C, 0x04),
|
|
|
|
GEN_MAC_HANDLER(macchwuo, 0x0C, 0x14),
|
|
|
|
GEN_MAC_HANDLER(machhw, 0x0C, 0x01),
|
|
|
|
GEN_MAC_HANDLER(machhwo, 0x0C, 0x11),
|
|
|
|
GEN_MAC_HANDLER(machhws, 0x0C, 0x03),
|
|
|
|
GEN_MAC_HANDLER(machhwso, 0x0C, 0x13),
|
|
|
|
GEN_MAC_HANDLER(machhwsu, 0x0C, 0x02),
|
|
|
|
GEN_MAC_HANDLER(machhwsuo, 0x0C, 0x12),
|
|
|
|
GEN_MAC_HANDLER(machhwu, 0x0C, 0x00),
|
|
|
|
GEN_MAC_HANDLER(machhwuo, 0x0C, 0x10),
|
|
|
|
GEN_MAC_HANDLER(maclhw, 0x0C, 0x0D),
|
|
|
|
GEN_MAC_HANDLER(maclhwo, 0x0C, 0x1D),
|
|
|
|
GEN_MAC_HANDLER(maclhws, 0x0C, 0x0F),
|
|
|
|
GEN_MAC_HANDLER(maclhwso, 0x0C, 0x1F),
|
|
|
|
GEN_MAC_HANDLER(maclhwu, 0x0C, 0x0C),
|
|
|
|
GEN_MAC_HANDLER(maclhwuo, 0x0C, 0x1C),
|
|
|
|
GEN_MAC_HANDLER(maclhwsu, 0x0C, 0x0E),
|
|
|
|
GEN_MAC_HANDLER(maclhwsuo, 0x0C, 0x1E),
|
|
|
|
GEN_MAC_HANDLER(nmacchw, 0x0E, 0x05),
|
|
|
|
GEN_MAC_HANDLER(nmacchwo, 0x0E, 0x15),
|
|
|
|
GEN_MAC_HANDLER(nmacchws, 0x0E, 0x07),
|
|
|
|
GEN_MAC_HANDLER(nmacchwso, 0x0E, 0x17),
|
|
|
|
GEN_MAC_HANDLER(nmachhw, 0x0E, 0x01),
|
|
|
|
GEN_MAC_HANDLER(nmachhwo, 0x0E, 0x11),
|
|
|
|
GEN_MAC_HANDLER(nmachhws, 0x0E, 0x03),
|
|
|
|
GEN_MAC_HANDLER(nmachhwso, 0x0E, 0x13),
|
|
|
|
GEN_MAC_HANDLER(nmaclhw, 0x0E, 0x0D),
|
|
|
|
GEN_MAC_HANDLER(nmaclhwo, 0x0E, 0x1D),
|
|
|
|
GEN_MAC_HANDLER(nmaclhws, 0x0E, 0x0F),
|
|
|
|
GEN_MAC_HANDLER(nmaclhwso, 0x0E, 0x1F),
|
|
|
|
GEN_MAC_HANDLER(mulchw, 0x08, 0x05),
|
|
|
|
GEN_MAC_HANDLER(mulchwu, 0x08, 0x04),
|
|
|
|
GEN_MAC_HANDLER(mulhhw, 0x08, 0x01),
|
|
|
|
GEN_MAC_HANDLER(mulhhwu, 0x08, 0x00),
|
|
|
|
GEN_MAC_HANDLER(mullhw, 0x08, 0x0D),
|
|
|
|
GEN_MAC_HANDLER(mullhwu, 0x08, 0x0C),
|
|
|
|
|
2014-12-18 17:34:34 +01:00
|
|
|
GEN_HANDLER2_E(tbegin, "tbegin", 0x1F, 0x0E, 0x14, 0x01DFF800, \
|
|
|
|
PPC_NONE, PPC2_TM),
|
2014-12-18 17:34:35 +01:00
|
|
|
GEN_HANDLER2_E(tend, "tend", 0x1F, 0x0E, 0x15, 0x01FFF800, \
|
|
|
|
PPC_NONE, PPC2_TM),
|
|
|
|
GEN_HANDLER2_E(tabort, "tabort", 0x1F, 0x0E, 0x1C, 0x03E0F800, \
|
|
|
|
PPC_NONE, PPC2_TM),
|
|
|
|
GEN_HANDLER2_E(tabortwc, "tabortwc", 0x1F, 0x0E, 0x18, 0x00000000, \
|
|
|
|
PPC_NONE, PPC2_TM),
|
|
|
|
GEN_HANDLER2_E(tabortwci, "tabortwci", 0x1F, 0x0E, 0x1A, 0x00000000, \
|
|
|
|
PPC_NONE, PPC2_TM),
|
|
|
|
GEN_HANDLER2_E(tabortdc, "tabortdc", 0x1F, 0x0E, 0x19, 0x00000000, \
|
|
|
|
PPC_NONE, PPC2_TM),
|
|
|
|
GEN_HANDLER2_E(tabortdci, "tabortdci", 0x1F, 0x0E, 0x1B, 0x00000000, \
|
|
|
|
PPC_NONE, PPC2_TM),
|
|
|
|
GEN_HANDLER2_E(tsr, "tsr", 0x1F, 0x0E, 0x17, 0x03DFF800, \
|
|
|
|
PPC_NONE, PPC2_TM),
|
2014-12-18 17:34:36 +01:00
|
|
|
GEN_HANDLER2_E(tcheck, "tcheck", 0x1F, 0x0E, 0x16, 0x007FF800, \
|
|
|
|
PPC_NONE, PPC2_TM),
|
2014-12-18 17:34:37 +01:00
|
|
|
GEN_HANDLER2_E(treclaim, "treclaim", 0x1F, 0x0E, 0x1D, 0x03E0F800, \
|
|
|
|
PPC_NONE, PPC2_TM),
|
|
|
|
GEN_HANDLER2_E(trechkpt, "trechkpt", 0x1F, 0x0E, 0x1F, 0x03FFF800, \
|
|
|
|
PPC_NONE, PPC2_TM),
|
2016-08-01 12:17:42 +02:00
|
|
|
|
2020-02-04 12:41:01 +01:00
|
|
|
#include "translate/fp-ops.c.inc"
|
2016-08-01 12:17:42 +02:00
|
|
|
|
2020-02-04 12:41:01 +01:00
|
|
|
#include "translate/vmx-ops.c.inc"
|
2016-08-01 12:17:42 +02:00
|
|
|
|
2020-02-04 12:41:01 +01:00
|
|
|
#include "translate/vsx-ops.c.inc"
|
2016-08-01 12:17:42 +02:00
|
|
|
|
2020-02-04 12:41:01 +01:00
|
|
|
#include "translate/dfp-ops.c.inc"
|
2016-08-01 12:17:42 +02:00
|
|
|
|
2020-02-04 12:41:01 +01:00
|
|
|
#include "translate/spe-ops.c.inc"
|
2009-06-17 17:22:31 +02:00
|
|
|
};
|
|
|
|
|
2021-04-29 18:21:24 +02:00
|
|
|
/*****************************************************************************/
|
|
|
|
/* Opcode types */
|
|
|
|
enum {
|
|
|
|
PPC_DIRECT = 0, /* Opcode routine */
|
|
|
|
PPC_INDIRECT = 1, /* Indirect opcode table */
|
|
|
|
};
|
|
|
|
|
|
|
|
#define PPC_OPCODE_MASK 0x3
|
|
|
|
|
|
|
|
static inline int is_indirect_opcode(void *handler)
|
|
|
|
{
|
|
|
|
return ((uintptr_t)handler & PPC_OPCODE_MASK) == PPC_INDIRECT;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline opc_handler_t **ind_table(void *handler)
|
|
|
|
{
|
|
|
|
return (opc_handler_t **)((uintptr_t)handler & ~PPC_OPCODE_MASK);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Instruction table creation */
|
|
|
|
/* Opcodes tables creation */
|
|
|
|
static void fill_new_table(opc_handler_t **table, int len)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < len; i++) {
|
|
|
|
table[i] = &invalid_handler;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static int create_new_table(opc_handler_t **table, unsigned char idx)
|
|
|
|
{
|
|
|
|
opc_handler_t **tmp;
|
|
|
|
|
|
|
|
tmp = g_new(opc_handler_t *, PPC_CPU_INDIRECT_OPCODES_LEN);
|
|
|
|
fill_new_table(tmp, PPC_CPU_INDIRECT_OPCODES_LEN);
|
|
|
|
table[idx] = (opc_handler_t *)((uintptr_t)tmp | PPC_INDIRECT);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int insert_in_table(opc_handler_t **table, unsigned char idx,
|
|
|
|
opc_handler_t *handler)
|
|
|
|
{
|
|
|
|
if (table[idx] != &invalid_handler) {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
table[idx] = handler;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int register_direct_insn(opc_handler_t **ppc_opcodes,
|
|
|
|
unsigned char idx, opc_handler_t *handler)
|
|
|
|
{
|
|
|
|
if (insert_in_table(ppc_opcodes, idx, handler) < 0) {
|
|
|
|
printf("*** ERROR: opcode %02x already assigned in main "
|
|
|
|
"opcode table\n", idx);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int register_ind_in_table(opc_handler_t **table,
|
|
|
|
unsigned char idx1, unsigned char idx2,
|
|
|
|
opc_handler_t *handler)
|
|
|
|
{
|
|
|
|
if (table[idx1] == &invalid_handler) {
|
|
|
|
if (create_new_table(table, idx1) < 0) {
|
|
|
|
printf("*** ERROR: unable to create indirect table "
|
|
|
|
"idx=%02x\n", idx1);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (!is_indirect_opcode(table[idx1])) {
|
|
|
|
printf("*** ERROR: idx %02x already assigned to a direct "
|
|
|
|
"opcode\n", idx1);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (handler != NULL &&
|
|
|
|
insert_in_table(ind_table(table[idx1]), idx2, handler) < 0) {
|
|
|
|
printf("*** ERROR: opcode %02x already assigned in "
|
|
|
|
"opcode table %02x\n", idx2, idx1);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int register_ind_insn(opc_handler_t **ppc_opcodes,
|
|
|
|
unsigned char idx1, unsigned char idx2,
|
|
|
|
opc_handler_t *handler)
|
|
|
|
{
|
|
|
|
return register_ind_in_table(ppc_opcodes, idx1, idx2, handler);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int register_dblind_insn(opc_handler_t **ppc_opcodes,
|
|
|
|
unsigned char idx1, unsigned char idx2,
|
|
|
|
unsigned char idx3, opc_handler_t *handler)
|
|
|
|
{
|
|
|
|
if (register_ind_in_table(ppc_opcodes, idx1, idx2, NULL) < 0) {
|
|
|
|
printf("*** ERROR: unable to join indirect table idx "
|
|
|
|
"[%02x-%02x]\n", idx1, idx2);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
if (register_ind_in_table(ind_table(ppc_opcodes[idx1]), idx2, idx3,
|
|
|
|
handler) < 0) {
|
|
|
|
printf("*** ERROR: unable to insert opcode "
|
|
|
|
"[%02x-%02x-%02x]\n", idx1, idx2, idx3);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int register_trplind_insn(opc_handler_t **ppc_opcodes,
|
|
|
|
unsigned char idx1, unsigned char idx2,
|
|
|
|
unsigned char idx3, unsigned char idx4,
|
|
|
|
opc_handler_t *handler)
|
|
|
|
{
|
|
|
|
opc_handler_t **table;
|
|
|
|
|
|
|
|
if (register_ind_in_table(ppc_opcodes, idx1, idx2, NULL) < 0) {
|
|
|
|
printf("*** ERROR: unable to join indirect table idx "
|
|
|
|
"[%02x-%02x]\n", idx1, idx2);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
table = ind_table(ppc_opcodes[idx1]);
|
|
|
|
if (register_ind_in_table(table, idx2, idx3, NULL) < 0) {
|
|
|
|
printf("*** ERROR: unable to join 2nd-level indirect table idx "
|
|
|
|
"[%02x-%02x-%02x]\n", idx1, idx2, idx3);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
table = ind_table(table[idx2]);
|
|
|
|
if (register_ind_in_table(table, idx3, idx4, handler) < 0) {
|
|
|
|
printf("*** ERROR: unable to insert opcode "
|
|
|
|
"[%02x-%02x-%02x-%02x]\n", idx1, idx2, idx3, idx4);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
static int register_insn(opc_handler_t **ppc_opcodes, opcode_t *insn)
|
|
|
|
{
|
|
|
|
if (insn->opc2 != 0xFF) {
|
|
|
|
if (insn->opc3 != 0xFF) {
|
|
|
|
if (insn->opc4 != 0xFF) {
|
|
|
|
if (register_trplind_insn(ppc_opcodes, insn->opc1, insn->opc2,
|
|
|
|
insn->opc3, insn->opc4,
|
|
|
|
&insn->handler) < 0) {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (register_dblind_insn(ppc_opcodes, insn->opc1, insn->opc2,
|
|
|
|
insn->opc3, &insn->handler) < 0) {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (register_ind_insn(ppc_opcodes, insn->opc1,
|
|
|
|
insn->opc2, &insn->handler) < 0) {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (register_direct_insn(ppc_opcodes, insn->opc1, &insn->handler) < 0) {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int test_opcode_table(opc_handler_t **table, int len)
|
|
|
|
{
|
|
|
|
int i, count, tmp;
|
|
|
|
|
|
|
|
for (i = 0, count = 0; i < len; i++) {
|
|
|
|
/* Consistency fixup */
|
|
|
|
if (table[i] == NULL) {
|
|
|
|
table[i] = &invalid_handler;
|
|
|
|
}
|
|
|
|
if (table[i] != &invalid_handler) {
|
|
|
|
if (is_indirect_opcode(table[i])) {
|
|
|
|
tmp = test_opcode_table(ind_table(table[i]),
|
|
|
|
PPC_CPU_INDIRECT_OPCODES_LEN);
|
|
|
|
if (tmp == 0) {
|
|
|
|
free(table[i]);
|
|
|
|
table[i] = &invalid_handler;
|
|
|
|
} else {
|
|
|
|
count++;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
count++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return count;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void fix_opcode_tables(opc_handler_t **ppc_opcodes)
|
|
|
|
{
|
|
|
|
if (test_opcode_table(ppc_opcodes, PPC_CPU_OPCODES_LEN) == 0) {
|
|
|
|
printf("*** WARNING: no opcode defined !\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
void create_ppc_opcodes(PowerPCCPU *cpu, Error **errp)
|
|
|
|
{
|
|
|
|
PowerPCCPUClass *pcc = POWERPC_CPU_GET_CLASS(cpu);
|
|
|
|
opcode_t *opc;
|
|
|
|
|
|
|
|
fill_new_table(cpu->opcodes, PPC_CPU_OPCODES_LEN);
|
|
|
|
for (opc = opcodes; opc < &opcodes[ARRAY_SIZE(opcodes)]; opc++) {
|
|
|
|
if (((opc->handler.type & pcc->insns_flags) != 0) ||
|
|
|
|
((opc->handler.type2 & pcc->insns_flags2) != 0)) {
|
|
|
|
if (register_insn(cpu->opcodes, opc) < 0) {
|
|
|
|
error_setg(errp, "ERROR initializing PowerPC instruction "
|
|
|
|
"0x%02x 0x%02x 0x%02x", opc->opc1, opc->opc2,
|
|
|
|
opc->opc3);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fix_opcode_tables(cpu->opcodes);
|
|
|
|
fflush(stdout);
|
|
|
|
fflush(stderr);
|
|
|
|
}
|
|
|
|
|
|
|
|
void destroy_ppc_opcodes(PowerPCCPU *cpu)
|
|
|
|
{
|
|
|
|
opc_handler_t **table, **table_2;
|
|
|
|
int i, j, k;
|
|
|
|
|
|
|
|
for (i = 0; i < PPC_CPU_OPCODES_LEN; i++) {
|
|
|
|
if (cpu->opcodes[i] == &invalid_handler) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (is_indirect_opcode(cpu->opcodes[i])) {
|
|
|
|
table = ind_table(cpu->opcodes[i]);
|
|
|
|
for (j = 0; j < PPC_CPU_INDIRECT_OPCODES_LEN; j++) {
|
|
|
|
if (table[j] == &invalid_handler) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (is_indirect_opcode(table[j])) {
|
|
|
|
table_2 = ind_table(table[j]);
|
|
|
|
for (k = 0; k < PPC_CPU_INDIRECT_OPCODES_LEN; k++) {
|
|
|
|
if (table_2[k] != &invalid_handler &&
|
|
|
|
is_indirect_opcode(table_2[k])) {
|
|
|
|
g_free((opc_handler_t *)((uintptr_t)table_2[k] &
|
|
|
|
~PPC_INDIRECT));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
g_free((opc_handler_t *)((uintptr_t)table[j] &
|
|
|
|
~PPC_INDIRECT));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
g_free((opc_handler_t *)((uintptr_t)cpu->opcodes[i] &
|
|
|
|
~PPC_INDIRECT));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int ppc_fixup_cpu(PowerPCCPU *cpu)
|
|
|
|
{
|
|
|
|
CPUPPCState *env = &cpu->env;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* TCG doesn't (yet) emulate some groups of instructions that are
|
|
|
|
* implemented on some otherwise supported CPUs (e.g. VSX and
|
|
|
|
* decimal floating point instructions on POWER7). We remove
|
|
|
|
* unsupported instruction groups from the cpu state's instruction
|
|
|
|
* masks and hope the guest can cope. For at least the pseries
|
|
|
|
* machine, the unavailability of these instructions can be
|
|
|
|
* advertised to the guest via the device tree.
|
|
|
|
*/
|
|
|
|
if ((env->insns_flags & ~PPC_TCG_INSNS)
|
|
|
|
|| (env->insns_flags2 & ~PPC_TCG_INSNS2)) {
|
|
|
|
warn_report("Disabling some instructions which are not "
|
|
|
|
"emulated by TCG (0x%" PRIx64 ", 0x%" PRIx64 ")",
|
|
|
|
env->insns_flags & ~PPC_TCG_INSNS,
|
|
|
|
env->insns_flags2 & ~PPC_TCG_INSNS2);
|
|
|
|
}
|
|
|
|
env->insns_flags &= PPC_TCG_INSNS;
|
|
|
|
env->insns_flags2 &= PPC_TCG_INSNS2;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2021-05-12 20:54:12 +02:00
|
|
|
static bool decode_legacy(PowerPCCPU *cpu, DisasContext *ctx, uint32_t insn)
|
|
|
|
{
|
|
|
|
opc_handler_t **table, *handler;
|
|
|
|
uint32_t inval;
|
|
|
|
|
|
|
|
ctx->opcode = insn;
|
|
|
|
|
|
|
|
LOG_DISAS("translate opcode %08x (%02x %02x %02x %02x) (%s)\n",
|
|
|
|
insn, opc1(insn), opc2(insn), opc3(insn), opc4(insn),
|
|
|
|
ctx->le_mode ? "little" : "big");
|
|
|
|
|
|
|
|
table = cpu->opcodes;
|
|
|
|
handler = table[opc1(insn)];
|
|
|
|
if (is_indirect_opcode(handler)) {
|
|
|
|
table = ind_table(handler);
|
|
|
|
handler = table[opc2(insn)];
|
|
|
|
if (is_indirect_opcode(handler)) {
|
|
|
|
table = ind_table(handler);
|
|
|
|
handler = table[opc3(insn)];
|
|
|
|
if (is_indirect_opcode(handler)) {
|
|
|
|
table = ind_table(handler);
|
|
|
|
handler = table[opc4(insn)];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Is opcode *REALLY* valid ? */
|
|
|
|
if (unlikely(handler->handler == &gen_invalid)) {
|
|
|
|
qemu_log_mask(LOG_GUEST_ERROR, "invalid/unsupported opcode: "
|
|
|
|
"%02x - %02x - %02x - %02x (%08x) "
|
|
|
|
TARGET_FMT_lx "\n",
|
|
|
|
opc1(insn), opc2(insn), opc3(insn), opc4(insn),
|
|
|
|
insn, ctx->cia);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (unlikely(handler->type & (PPC_SPE | PPC_SPE_SINGLE | PPC_SPE_DOUBLE)
|
|
|
|
&& Rc(insn))) {
|
|
|
|
inval = handler->inval2;
|
|
|
|
} else {
|
|
|
|
inval = handler->inval1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (unlikely((insn & inval) != 0)) {
|
|
|
|
qemu_log_mask(LOG_GUEST_ERROR, "invalid bits: %08x for opcode: "
|
|
|
|
"%02x - %02x - %02x - %02x (%08x) "
|
|
|
|
TARGET_FMT_lx "\n", insn & inval,
|
|
|
|
opc1(insn), opc2(insn), opc3(insn), opc4(insn),
|
|
|
|
insn, ctx->cia);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
handler->handler(ctx);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2018-02-20 02:51:58 +01:00
|
|
|
static void ppc_tr_init_disas_context(DisasContextBase *dcbase, CPUState *cs)
|
2003-11-23 15:55:54 +01:00
|
|
|
{
|
2018-02-15 20:51:49 +01:00
|
|
|
DisasContext *ctx = container_of(dcbase, DisasContext, base);
|
2017-07-14 10:17:35 +02:00
|
|
|
CPUPPCState *env = cs->env_ptr;
|
2021-03-23 19:43:32 +01:00
|
|
|
uint32_t hflags = ctx->base.tb->flags;
|
2018-02-15 20:51:49 +01:00
|
|
|
|
|
|
|
ctx->spr_cb = env->spr_cb;
|
2021-03-23 19:43:32 +01:00
|
|
|
ctx->pr = (hflags >> HFLAGS_PR) & 1;
|
2021-03-23 19:43:38 +01:00
|
|
|
ctx->mem_idx = (hflags >> HFLAGS_DMMU_IDX) & 7;
|
2021-03-23 19:43:32 +01:00
|
|
|
ctx->dr = (hflags >> HFLAGS_DR) & 1;
|
|
|
|
ctx->hv = (hflags >> HFLAGS_HV) & 1;
|
2018-02-15 20:51:49 +01:00
|
|
|
ctx->insns_flags = env->insns_flags;
|
|
|
|
ctx->insns_flags2 = env->insns_flags2;
|
|
|
|
ctx->access_type = -1;
|
2020-12-09 18:35:36 +01:00
|
|
|
ctx->need_access_type = !mmu_is_64bit(env->mmu_model);
|
2021-03-23 19:43:32 +01:00
|
|
|
ctx->le_mode = (hflags >> HFLAGS_LE) & 1;
|
2018-02-15 20:51:49 +01:00
|
|
|
ctx->default_tcg_memop_mask = ctx->le_mode ? MO_LE : MO_BE;
|
2018-08-14 18:09:51 +02:00
|
|
|
ctx->flags = env->flags;
|
2007-03-17 15:02:15 +01:00
|
|
|
#if defined(TARGET_PPC64)
|
2021-03-23 19:43:32 +01:00
|
|
|
ctx->sf_mode = (hflags >> HFLAGS_64) & 1;
|
2018-02-15 20:51:49 +01:00
|
|
|
ctx->has_cfar = !!(env->flags & POWERPC_FLAG_CFAR);
|
2004-01-04 23:58:38 +01:00
|
|
|
#endif
|
2018-03-19 07:05:05 +01:00
|
|
|
ctx->lazy_tlb_flush = env->mmu_model == POWERPC_MMU_32B
|
|
|
|
|| env->mmu_model == POWERPC_MMU_601
|
2020-12-09 18:35:35 +01:00
|
|
|
|| env->mmu_model & POWERPC_MMU_64;
|
2016-06-07 04:50:22 +02:00
|
|
|
|
2021-03-23 19:43:32 +01:00
|
|
|
ctx->fpu_enabled = (hflags >> HFLAGS_FP) & 1;
|
|
|
|
ctx->spe_enabled = (hflags >> HFLAGS_SPE) & 1;
|
|
|
|
ctx->altivec_enabled = (hflags >> HFLAGS_VR) & 1;
|
|
|
|
ctx->vsx_enabled = (hflags >> HFLAGS_VSX) & 1;
|
|
|
|
ctx->tm_enabled = (hflags >> HFLAGS_TM) & 1;
|
2021-03-23 19:43:36 +01:00
|
|
|
ctx->gtse = (hflags >> HFLAGS_GTSE) & 1;
|
2021-03-23 19:43:32 +01:00
|
|
|
|
|
|
|
ctx->singlestep_enabled = 0;
|
|
|
|
if ((hflags >> HFLAGS_SE) & 1) {
|
|
|
|
ctx->singlestep_enabled |= CPU_SINGLE_STEP;
|
2019-03-21 12:57:28 +01:00
|
|
|
}
|
2021-03-23 19:43:32 +01:00
|
|
|
if ((hflags >> HFLAGS_BE) & 1) {
|
2018-02-15 20:51:49 +01:00
|
|
|
ctx->singlestep_enabled |= CPU_BRANCH_STEP;
|
2019-03-21 12:57:28 +01:00
|
|
|
}
|
2018-02-15 20:51:49 +01:00
|
|
|
if (unlikely(ctx->base.singlestep_enabled)) {
|
|
|
|
ctx->singlestep_enabled |= GDBSTUB_SINGLE_STEP;
|
2013-06-21 20:20:45 +02:00
|
|
|
}
|
2015-09-18 00:58:10 +02:00
|
|
|
|
2021-05-17 22:50:07 +02:00
|
|
|
if (ctx->singlestep_enabled & (CPU_SINGLE_STEP | GDBSTUB_SINGLE_STEP)) {
|
|
|
|
ctx->base.max_insns = 1;
|
|
|
|
}
|
2018-02-15 20:51:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static void ppc_tr_tb_start(DisasContextBase *db, CPUState *cs)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static void ppc_tr_insn_start(DisasContextBase *dcbase, CPUState *cs)
|
|
|
|
{
|
|
|
|
tcg_gen_insn_start(dcbase->pc_next);
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool ppc_tr_breakpoint_check(DisasContextBase *dcbase, CPUState *cs,
|
|
|
|
const CPUBreakpoint *bp)
|
|
|
|
{
|
|
|
|
DisasContext *ctx = container_of(dcbase, DisasContext, base);
|
|
|
|
|
2021-05-12 20:54:16 +02:00
|
|
|
gen_update_nip(ctx, ctx->base.pc_next);
|
2018-02-15 20:51:49 +01:00
|
|
|
gen_debug_exception(ctx);
|
2019-03-21 12:57:28 +01: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.
|
|
|
|
*/
|
2018-02-15 20:51:49 +01:00
|
|
|
ctx->base.pc_next += 4;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2021-06-01 21:35:17 +02:00
|
|
|
static bool is_prefix_insn(DisasContext *ctx, uint32_t insn)
|
|
|
|
{
|
|
|
|
REQUIRE_INSNS_FLAGS2(ctx, ISA310);
|
|
|
|
return opc1(insn) == 1;
|
|
|
|
}
|
|
|
|
|
2018-02-15 20:51:49 +01:00
|
|
|
static void ppc_tr_translate_insn(DisasContextBase *dcbase, CPUState *cs)
|
|
|
|
{
|
|
|
|
DisasContext *ctx = container_of(dcbase, DisasContext, base);
|
2019-07-16 14:13:52 +02:00
|
|
|
PowerPCCPU *cpu = POWERPC_CPU(cs);
|
2018-02-15 20:51:49 +01:00
|
|
|
CPUPPCState *env = cs->env_ptr;
|
2021-06-01 21:35:17 +02:00
|
|
|
target_ulong pc;
|
2021-05-12 20:54:12 +02:00
|
|
|
uint32_t insn;
|
|
|
|
bool ok;
|
2018-02-15 20:51:49 +01:00
|
|
|
|
|
|
|
LOG_DISAS("----------------\n");
|
|
|
|
LOG_DISAS("nip=" TARGET_FMT_lx " super=%d ir=%d\n",
|
|
|
|
ctx->base.pc_next, ctx->mem_idx, (int)msr_ir);
|
|
|
|
|
2021-06-01 21:35:17 +02:00
|
|
|
ctx->cia = pc = ctx->base.pc_next;
|
|
|
|
insn = translator_ldl_swap(env, pc, need_byteswap(ctx));
|
|
|
|
ctx->base.pc_next = pc += 4;
|
2011-09-28 07:54:05 +02:00
|
|
|
|
2021-06-01 21:35:17 +02:00
|
|
|
if (!is_prefix_insn(ctx, insn)) {
|
|
|
|
ok = (decode_insn32(ctx, insn) ||
|
|
|
|
decode_legacy(cpu, ctx, insn));
|
|
|
|
} else if ((pc & 63) == 0) {
|
|
|
|
/*
|
|
|
|
* Power v3.1, section 1.9 Exceptions:
|
|
|
|
* attempt to execute a prefixed instruction that crosses a
|
|
|
|
* 64-byte address boundary (system alignment error).
|
|
|
|
*/
|
|
|
|
gen_exception_err(ctx, POWERPC_EXCP_ALIGN, POWERPC_EXCP_ALIGN_INSN);
|
|
|
|
ok = true;
|
|
|
|
} else {
|
|
|
|
uint32_t insn2 = translator_ldl_swap(env, pc, need_byteswap(ctx));
|
|
|
|
ctx->base.pc_next = pc += 4;
|
|
|
|
ok = decode_insn64(ctx, deposit64(insn2, 32, 32, insn));
|
|
|
|
}
|
2021-05-12 20:54:12 +02:00
|
|
|
if (!ok) {
|
|
|
|
gen_invalid(ctx);
|
2018-02-15 20:51:49 +01:00
|
|
|
}
|
2021-05-12 20:54:12 +02:00
|
|
|
|
2021-06-01 21:35:16 +02:00
|
|
|
/* End the TB when crossing a page boundary. */
|
2021-06-01 21:35:17 +02:00
|
|
|
if (ctx->base.is_jmp == DISAS_NEXT && !(pc & ~TARGET_PAGE_MASK)) {
|
2021-06-01 21:35:16 +02:00
|
|
|
ctx->base.is_jmp = DISAS_TOO_MANY;
|
|
|
|
}
|
|
|
|
|
2021-05-17 22:50:10 +02:00
|
|
|
translator_loop_temp_check(&ctx->base);
|
2018-02-15 20:51:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static void ppc_tr_tb_stop(DisasContextBase *dcbase, CPUState *cs)
|
|
|
|
{
|
|
|
|
DisasContext *ctx = container_of(dcbase, DisasContext, base);
|
2021-05-12 20:54:17 +02:00
|
|
|
DisasJumpType is_jmp = ctx->base.is_jmp;
|
|
|
|
target_ulong nip = ctx->base.pc_next;
|
2021-05-17 22:50:07 +02:00
|
|
|
int sse;
|
2018-02-15 20:51:49 +01:00
|
|
|
|
2021-05-12 20:54:17 +02:00
|
|
|
if (is_jmp == DISAS_NORETURN) {
|
|
|
|
/* We have already exited the TB. */
|
2021-05-12 20:54:13 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-05-12 20:54:17 +02:00
|
|
|
/* Honor single stepping. */
|
2021-05-17 22:50:07 +02:00
|
|
|
sse = ctx->singlestep_enabled & (CPU_SINGLE_STEP | GDBSTUB_SINGLE_STEP);
|
|
|
|
if (unlikely(sse)) {
|
2021-05-12 20:54:17 +02:00
|
|
|
switch (is_jmp) {
|
|
|
|
case DISAS_TOO_MANY:
|
|
|
|
case DISAS_EXIT_UPDATE:
|
|
|
|
case DISAS_CHAIN_UPDATE:
|
|
|
|
gen_update_nip(ctx, nip);
|
|
|
|
break;
|
|
|
|
case DISAS_EXIT:
|
|
|
|
case DISAS_CHAIN:
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
g_assert_not_reached();
|
2008-05-11 01:28:14 +02:00
|
|
|
}
|
2021-05-17 22:50:07 +02:00
|
|
|
|
|
|
|
if (sse & GDBSTUB_SINGLE_STEP) {
|
|
|
|
gen_debug_exception(ctx);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
/* else CPU_SINGLE_STEP... */
|
|
|
|
if (nip <= 0x100 || nip > 0xf00) {
|
2021-06-02 14:51:03 +02:00
|
|
|
gen_helper_raise_exception(cpu_env, tcg_constant_i32(gen_prep_dbgex(ctx)));
|
2021-05-17 22:50:07 +02:00
|
|
|
return;
|
|
|
|
}
|
2021-05-12 20:54:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
switch (is_jmp) {
|
|
|
|
case DISAS_TOO_MANY:
|
|
|
|
if (use_goto_tb(ctx, nip)) {
|
|
|
|
tcg_gen_goto_tb(0);
|
|
|
|
gen_update_nip(ctx, nip);
|
|
|
|
tcg_gen_exit_tb(ctx->base.tb, 0);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
/* fall through */
|
|
|
|
case DISAS_CHAIN_UPDATE:
|
|
|
|
gen_update_nip(ctx, nip);
|
|
|
|
/* fall through */
|
|
|
|
case DISAS_CHAIN:
|
|
|
|
tcg_gen_lookup_and_goto_ptr();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case DISAS_EXIT_UPDATE:
|
|
|
|
gen_update_nip(ctx, nip);
|
|
|
|
/* fall through */
|
|
|
|
case DISAS_EXIT:
|
2018-05-31 03:06:23 +02:00
|
|
|
tcg_gen_exit_tb(NULL, 0);
|
2021-05-12 20:54:17 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
g_assert_not_reached();
|
2004-01-04 23:58:38 +01:00
|
|
|
}
|
2018-02-15 20:51:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static void ppc_tr_disas_log(const DisasContextBase *dcbase, CPUState *cs)
|
|
|
|
{
|
|
|
|
qemu_log("IN: %s\n", lookup_symbol(dcbase->pc_first));
|
|
|
|
log_target_disas(cs, dcbase->pc_first, dcbase->tb->size);
|
|
|
|
}
|
2014-03-30 23:50:30 +02:00
|
|
|
|
2018-02-15 20:51:49 +01:00
|
|
|
static const TranslatorOps ppc_tr_ops = {
|
|
|
|
.init_disas_context = ppc_tr_init_disas_context,
|
|
|
|
.tb_start = ppc_tr_tb_start,
|
|
|
|
.insn_start = ppc_tr_insn_start,
|
|
|
|
.breakpoint_check = ppc_tr_breakpoint_check,
|
|
|
|
.translate_insn = ppc_tr_translate_insn,
|
|
|
|
.tb_stop = ppc_tr_tb_stop,
|
|
|
|
.disas_log = ppc_tr_disas_log,
|
|
|
|
};
|
2015-09-02 05:01:40 +02:00
|
|
|
|
2019-04-16 08:54:54 +02:00
|
|
|
void gen_intermediate_code(CPUState *cs, TranslationBlock *tb, int max_insns)
|
2018-02-15 20:51:49 +01:00
|
|
|
{
|
|
|
|
DisasContext ctx;
|
|
|
|
|
2019-04-16 08:54:54 +02:00
|
|
|
translator_loop(&ppc_tr_ops, &ctx.base, cs, tb, max_insns);
|
2003-11-23 15:55:54 +01:00
|
|
|
}
|
|
|
|
|
2015-09-02 00:51:12 +02:00
|
|
|
void restore_state_to_opc(CPUPPCState *env, TranslationBlock *tb,
|
|
|
|
target_ulong *data)
|
2008-04-28 02:32:32 +02:00
|
|
|
{
|
2015-09-02 00:51:12 +02:00
|
|
|
env->nip = data[0];
|
2008-04-28 02:32:32 +02:00
|
|
|
}
|