2003-09-30 22:36:07 +02:00
|
|
|
/*
|
|
|
|
SPARC translation
|
|
|
|
|
|
|
|
Copyright (C) 2003 Thomas M. Ogrisegg <tom@fnord.at>
|
2005-07-02 16:31:34 +02:00
|
|
|
Copyright (C) 2003-2005 Fabrice Bellard
|
2003-09-30 22:36:07 +02:00
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU Lesser General Public
|
|
|
|
License as published by the Free Software Foundation; either
|
2020-10-23 14:42:35 +02:00
|
|
|
version 2.1 of the License, or (at your option) any later version.
|
2003-09-30 22:36:07 +02: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-09-30 22:36:07 +02:00
|
|
|
*/
|
|
|
|
|
2016-01-26 19:16:59 +01:00
|
|
|
#include "qemu/osdep.h"
|
2003-09-30 22:36:07 +02:00
|
|
|
|
|
|
|
#include "cpu.h"
|
2012-10-24 11:12:21 +02:00
|
|
|
#include "disas/disas.h"
|
2014-04-08 07:31:41 +02:00
|
|
|
#include "exec/helper-proto.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"
|
2014-03-28 19:42:10 +01:00
|
|
|
#include "exec/cpu_ldst.h"
|
2003-09-30 22:36:07 +02:00
|
|
|
|
2014-04-08 07:31:41 +02:00
|
|
|
#include "exec/helper-gen.h"
|
2008-11-17 15:43:54 +01:00
|
|
|
|
2018-02-15 02:52:14 +01:00
|
|
|
#include "exec/translator.h"
|
2016-01-07 14:55:28 +01:00
|
|
|
#include "exec/log.h"
|
2015-09-03 20:36:02 +02:00
|
|
|
#include "asi.h"
|
2014-05-30 14:12:25 +02:00
|
|
|
|
|
|
|
|
2004-02-16 21:30:05 +01:00
|
|
|
#define DYNAMIC_PC 1 /* dynamic pc value */
|
|
|
|
#define JUMP_PC 2 /* dynamic pc value which takes only two values
|
|
|
|
according to jump_pc[T2] */
|
|
|
|
|
2018-06-15 09:33:03 +02:00
|
|
|
#define DISAS_EXIT DISAS_TARGET_0
|
|
|
|
|
2008-02-24 15:10:06 +01:00
|
|
|
/* global register indexes */
|
2016-02-25 17:43:15 +01:00
|
|
|
static TCGv_ptr cpu_regwptr;
|
2009-06-06 03:54:03 +02:00
|
|
|
static TCGv cpu_cc_src, cpu_cc_src2, cpu_cc_dst;
|
|
|
|
static TCGv_i32 cpu_cc_op;
|
2008-11-17 15:43:54 +01:00
|
|
|
static TCGv_i32 cpu_psr;
|
2013-09-19 19:51:12 +02:00
|
|
|
static TCGv cpu_fsr, cpu_pc, cpu_npc;
|
|
|
|
static TCGv cpu_regs[32];
|
2008-09-06 19:51:43 +02:00
|
|
|
static TCGv cpu_y;
|
|
|
|
#ifndef CONFIG_USER_ONLY
|
|
|
|
static TCGv cpu_tbr;
|
|
|
|
#endif
|
2012-10-16 11:32:30 +02:00
|
|
|
static TCGv cpu_cond;
|
2008-03-13 21:45:31 +01:00
|
|
|
#ifdef TARGET_SPARC64
|
2015-09-03 23:14:33 +02:00
|
|
|
static TCGv_i32 cpu_xcc, cpu_fprs;
|
2008-11-17 15:43:54 +01:00
|
|
|
static TCGv cpu_gsr;
|
2008-09-06 19:51:43 +02:00
|
|
|
static TCGv cpu_tick_cmpr, cpu_stick_cmpr, cpu_hstick_cmpr;
|
2008-11-17 15:43:54 +01:00
|
|
|
static TCGv cpu_hintp, cpu_htba, cpu_hver, cpu_ssr, cpu_ver;
|
2008-09-06 19:51:43 +02:00
|
|
|
#else
|
|
|
|
static TCGv cpu_wim;
|
2008-03-13 21:45:31 +01:00
|
|
|
#endif
|
2008-09-10 21:54:51 +02:00
|
|
|
/* Floating point registers */
|
2011-10-17 19:42:49 +02:00
|
|
|
static TCGv_i64 cpu_fpr[TARGET_DPREGS];
|
2008-02-24 15:10:06 +01:00
|
|
|
|
2012-12-17 18:19:49 +01:00
|
|
|
#include "exec/gen-icount.h"
|
2008-06-29 03:03:05 +02:00
|
|
|
|
2003-09-30 22:36:07 +02:00
|
|
|
typedef struct DisasContext {
|
2018-02-15 03:16:30 +01:00
|
|
|
DisasContextBase base;
|
2007-09-20 16:54:22 +02:00
|
|
|
target_ulong pc; /* current Program Counter: integer or DYNAMIC_PC */
|
|
|
|
target_ulong npc; /* next PC: integer or DYNAMIC_PC or JUMP_PC */
|
2004-02-16 21:30:05 +01:00
|
|
|
target_ulong jump_pc[2]; /* used when JUMP_PC pc value is used */
|
2004-09-30 23:55:55 +02:00
|
|
|
int mem_idx;
|
2016-11-01 21:57:01 +01:00
|
|
|
bool fpu_enabled;
|
|
|
|
bool address_mask_32bit;
|
|
|
|
#ifndef CONFIG_USER_ONLY
|
|
|
|
bool supervisor;
|
|
|
|
#ifdef TARGET_SPARC64
|
|
|
|
bool hypervisor;
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
2009-05-10 09:19:11 +02:00
|
|
|
uint32_t cc_op; /* current CC operation */
|
2008-08-21 19:33:42 +02:00
|
|
|
sparc_def_t *def;
|
2015-09-03 23:14:33 +02:00
|
|
|
#ifdef TARGET_SPARC64
|
2015-09-09 20:56:38 +02:00
|
|
|
int fprs_dirty;
|
2015-09-03 23:14:33 +02:00
|
|
|
int asi;
|
|
|
|
#endif
|
2003-09-30 22:36:07 +02:00
|
|
|
} DisasContext;
|
|
|
|
|
2012-10-06 01:54:57 +02:00
|
|
|
typedef struct {
|
|
|
|
TCGCond cond;
|
|
|
|
bool is_bool;
|
|
|
|
TCGv c1, c2;
|
|
|
|
} DisasCompare;
|
|
|
|
|
2005-07-02 16:31:34 +02:00
|
|
|
// This function uses non-native bit order
|
2009-05-03 20:51:22 +02:00
|
|
|
#define GET_FIELD(X, FROM, TO) \
|
|
|
|
((X) >> (31 - (TO)) & ((1 << ((TO) - (FROM) + 1)) - 1))
|
2003-09-30 22:36:07 +02:00
|
|
|
|
2005-07-02 16:31:34 +02:00
|
|
|
// This function uses the order in the manuals, i.e. bit 0 is 2^0
|
2009-05-03 20:51:22 +02:00
|
|
|
#define GET_FIELD_SP(X, FROM, TO) \
|
2005-07-02 16:31:34 +02:00
|
|
|
GET_FIELD(X, 31 - (TO), 31 - (FROM))
|
|
|
|
|
|
|
|
#define GET_FIELDs(x,a,b) sign_extend (GET_FIELD(x,a,b), (b) - (a) + 1)
|
2007-07-04 22:22:35 +02:00
|
|
|
#define GET_FIELD_SPs(x,a,b) sign_extend (GET_FIELD_SP(x,a,b), ((b) - (a) + 1))
|
2005-07-02 16:31:34 +02:00
|
|
|
|
|
|
|
#ifdef TARGET_SPARC64
|
2007-10-03 19:46:29 +02:00
|
|
|
#define DFPREG(r) (((r & 1) << 5) | (r & 0x1e))
|
2007-11-25 19:40:20 +01:00
|
|
|
#define QFPREG(r) (((r & 1) << 5) | (r & 0x1c))
|
2005-07-02 16:31:34 +02:00
|
|
|
#else
|
2007-04-06 22:02:09 +02:00
|
|
|
#define DFPREG(r) (r & 0x1e)
|
2007-11-25 19:40:20 +01:00
|
|
|
#define QFPREG(r) (r & 0x1c)
|
2005-07-02 16:31:34 +02:00
|
|
|
#endif
|
|
|
|
|
2008-09-26 20:05:23 +02:00
|
|
|
#define UA2005_HTRAP_MASK 0xff
|
|
|
|
#define V8_TRAP_MASK 0x7f
|
|
|
|
|
2005-07-02 16:31:34 +02:00
|
|
|
static int sign_extend(int x, int len)
|
|
|
|
{
|
|
|
|
len = 32 - len;
|
|
|
|
return (x << len) >> len;
|
|
|
|
}
|
|
|
|
|
2003-09-30 22:36:07 +02:00
|
|
|
#define IS_IMM (insn & (1<<13))
|
|
|
|
|
2015-09-09 20:56:38 +02:00
|
|
|
static inline void gen_update_fprs_dirty(DisasContext *dc, int rd)
|
2011-10-15 00:03:25 +02:00
|
|
|
{
|
|
|
|
#if defined(TARGET_SPARC64)
|
2015-09-09 20:56:38 +02:00
|
|
|
int bit = (rd < 32) ? 1 : 2;
|
|
|
|
/* If we know we've already set this bit within the TB,
|
|
|
|
we can avoid setting it again. */
|
|
|
|
if (!(dc->fprs_dirty & bit)) {
|
|
|
|
dc->fprs_dirty |= bit;
|
|
|
|
tcg_gen_ori_i32(cpu_fprs, cpu_fprs, bit);
|
|
|
|
}
|
2011-10-15 00:03:25 +02:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2008-03-21 18:53:56 +01:00
|
|
|
/* floating point registers moves */
|
2011-10-14 23:58:32 +02:00
|
|
|
static TCGv_i32 gen_load_fpr_F(DisasContext *dc, unsigned int src)
|
|
|
|
{
|
2023-02-25 08:26:59 +01:00
|
|
|
TCGv_i32 ret = tcg_temp_new_i32();
|
2011-10-17 19:42:49 +02:00
|
|
|
if (src & 1) {
|
2017-10-20 09:30:24 +02:00
|
|
|
tcg_gen_extrl_i64_i32(ret, cpu_fpr[src / 2]);
|
2011-10-17 19:42:49 +02:00
|
|
|
} else {
|
2017-10-20 09:30:24 +02:00
|
|
|
tcg_gen_extrh_i64_i32(ret, cpu_fpr[src / 2]);
|
2011-10-17 19:42:49 +02:00
|
|
|
}
|
2017-10-20 09:30:24 +02:00
|
|
|
return ret;
|
2011-10-14 23:58:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void gen_store_fpr_F(DisasContext *dc, unsigned int dst, TCGv_i32 v)
|
|
|
|
{
|
2022-10-17 02:57:03 +02:00
|
|
|
TCGv_i64 t = tcg_temp_new_i64();
|
|
|
|
|
|
|
|
tcg_gen_extu_i32_i64(t, v);
|
2011-10-17 19:42:49 +02:00
|
|
|
tcg_gen_deposit_i64(cpu_fpr[dst / 2], cpu_fpr[dst / 2], t,
|
|
|
|
(dst & 1 ? 0 : 32), 32);
|
2015-09-09 20:56:38 +02:00
|
|
|
gen_update_fprs_dirty(dc, dst);
|
2011-10-14 23:58:32 +02:00
|
|
|
}
|
|
|
|
|
2012-10-16 11:32:21 +02:00
|
|
|
static TCGv_i32 gen_dest_fpr_F(DisasContext *dc)
|
2011-10-14 23:58:32 +02:00
|
|
|
{
|
2023-02-25 08:26:59 +01:00
|
|
|
return tcg_temp_new_i32();
|
2011-10-14 23:58:32 +02:00
|
|
|
}
|
|
|
|
|
2011-10-15 00:47:35 +02:00
|
|
|
static TCGv_i64 gen_load_fpr_D(DisasContext *dc, unsigned int src)
|
|
|
|
{
|
|
|
|
src = DFPREG(src);
|
2011-10-17 19:42:49 +02:00
|
|
|
return cpu_fpr[src / 2];
|
2011-10-15 00:47:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void gen_store_fpr_D(DisasContext *dc, unsigned int dst, TCGv_i64 v)
|
|
|
|
{
|
|
|
|
dst = DFPREG(dst);
|
2011-10-17 19:42:49 +02:00
|
|
|
tcg_gen_mov_i64(cpu_fpr[dst / 2], v);
|
2015-09-09 20:56:38 +02:00
|
|
|
gen_update_fprs_dirty(dc, dst);
|
2011-10-15 00:47:35 +02:00
|
|
|
}
|
|
|
|
|
2012-10-16 11:32:26 +02:00
|
|
|
static TCGv_i64 gen_dest_fpr_D(DisasContext *dc, unsigned int dst)
|
2011-10-15 00:47:35 +02:00
|
|
|
{
|
2012-10-16 11:32:26 +02:00
|
|
|
return cpu_fpr[DFPREG(dst) / 2];
|
2011-10-15 00:47:35 +02:00
|
|
|
}
|
|
|
|
|
2008-03-21 18:53:56 +01:00
|
|
|
static void gen_op_load_fpr_QT0(unsigned int src)
|
|
|
|
{
|
2011-10-17 19:42:49 +02:00
|
|
|
tcg_gen_st_i64(cpu_fpr[src / 2], cpu_env, offsetof(CPUSPARCState, qt0) +
|
|
|
|
offsetof(CPU_QuadU, ll.upper));
|
|
|
|
tcg_gen_st_i64(cpu_fpr[src/2 + 1], cpu_env, offsetof(CPUSPARCState, qt0) +
|
|
|
|
offsetof(CPU_QuadU, ll.lower));
|
2008-03-21 18:53:56 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static void gen_op_load_fpr_QT1(unsigned int src)
|
|
|
|
{
|
2011-10-17 19:42:49 +02:00
|
|
|
tcg_gen_st_i64(cpu_fpr[src / 2], cpu_env, offsetof(CPUSPARCState, qt1) +
|
|
|
|
offsetof(CPU_QuadU, ll.upper));
|
|
|
|
tcg_gen_st_i64(cpu_fpr[src/2 + 1], cpu_env, offsetof(CPUSPARCState, qt1) +
|
|
|
|
offsetof(CPU_QuadU, ll.lower));
|
2008-03-21 18:53:56 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static void gen_op_store_QT0_fpr(unsigned int dst)
|
|
|
|
{
|
2011-10-17 19:42:49 +02:00
|
|
|
tcg_gen_ld_i64(cpu_fpr[dst / 2], cpu_env, offsetof(CPUSPARCState, qt0) +
|
|
|
|
offsetof(CPU_QuadU, ll.upper));
|
|
|
|
tcg_gen_ld_i64(cpu_fpr[dst/2 + 1], cpu_env, offsetof(CPUSPARCState, qt0) +
|
|
|
|
offsetof(CPU_QuadU, ll.lower));
|
2008-03-21 18:53:56 +01:00
|
|
|
}
|
2007-11-25 19:40:20 +01:00
|
|
|
|
2016-07-14 20:47:08 +02:00
|
|
|
static void gen_store_fpr_Q(DisasContext *dc, unsigned int dst,
|
|
|
|
TCGv_i64 v1, TCGv_i64 v2)
|
|
|
|
{
|
|
|
|
dst = QFPREG(dst);
|
|
|
|
|
|
|
|
tcg_gen_mov_i64(cpu_fpr[dst / 2], v1);
|
|
|
|
tcg_gen_mov_i64(cpu_fpr[dst / 2 + 1], v2);
|
|
|
|
gen_update_fprs_dirty(dc, dst);
|
|
|
|
}
|
|
|
|
|
2011-10-15 21:00:08 +02:00
|
|
|
#ifdef TARGET_SPARC64
|
2016-07-14 20:47:08 +02:00
|
|
|
static TCGv_i64 gen_load_fpr_Q0(DisasContext *dc, unsigned int src)
|
|
|
|
{
|
|
|
|
src = QFPREG(src);
|
|
|
|
return cpu_fpr[src / 2];
|
|
|
|
}
|
|
|
|
|
|
|
|
static TCGv_i64 gen_load_fpr_Q1(DisasContext *dc, unsigned int src)
|
|
|
|
{
|
|
|
|
src = QFPREG(src);
|
|
|
|
return cpu_fpr[src / 2 + 1];
|
|
|
|
}
|
|
|
|
|
2015-09-09 20:56:38 +02:00
|
|
|
static void gen_move_Q(DisasContext *dc, unsigned int rd, unsigned int rs)
|
2011-10-15 21:00:08 +02:00
|
|
|
{
|
|
|
|
rd = QFPREG(rd);
|
|
|
|
rs = QFPREG(rs);
|
|
|
|
|
2011-10-17 19:42:49 +02:00
|
|
|
tcg_gen_mov_i64(cpu_fpr[rd / 2], cpu_fpr[rs / 2]);
|
|
|
|
tcg_gen_mov_i64(cpu_fpr[rd / 2 + 1], cpu_fpr[rs / 2 + 1]);
|
2015-09-09 20:56:38 +02:00
|
|
|
gen_update_fprs_dirty(dc, rd);
|
2011-10-15 21:00:08 +02:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2007-09-21 21:10:53 +02:00
|
|
|
/* moves */
|
|
|
|
#ifdef CONFIG_USER_ONLY
|
2005-07-02 16:31:34 +02:00
|
|
|
#define supervisor(dc) 0
|
2007-09-21 21:10:53 +02:00
|
|
|
#ifdef TARGET_SPARC64
|
2007-04-22 21:14:52 +02:00
|
|
|
#define hypervisor(dc) 0
|
2007-09-21 21:10:53 +02:00
|
|
|
#endif
|
2005-07-02 16:31:34 +02:00
|
|
|
#else
|
2007-09-21 21:10:53 +02:00
|
|
|
#ifdef TARGET_SPARC64
|
2016-11-01 21:57:01 +01:00
|
|
|
#define hypervisor(dc) (dc->hypervisor)
|
|
|
|
#define supervisor(dc) (dc->supervisor | dc->hypervisor)
|
2007-10-14 19:07:21 +02:00
|
|
|
#else
|
2016-11-01 21:57:01 +01:00
|
|
|
#define supervisor(dc) (dc->supervisor)
|
2005-07-02 16:31:34 +02:00
|
|
|
#endif
|
2007-09-21 21:10:53 +02:00
|
|
|
#endif
|
|
|
|
|
2008-07-17 14:53:05 +02:00
|
|
|
#ifdef TARGET_SPARC64
|
|
|
|
#ifndef TARGET_ABI32
|
|
|
|
#define AM_CHECK(dc) ((dc)->address_mask_32bit)
|
2008-02-24 15:10:06 +01:00
|
|
|
#else
|
2008-07-17 14:53:05 +02:00
|
|
|
#define AM_CHECK(dc) (1)
|
|
|
|
#endif
|
2008-02-24 15:10:06 +01:00
|
|
|
#endif
|
2007-09-30 21:38:12 +02:00
|
|
|
|
2008-07-17 14:53:05 +02:00
|
|
|
static inline void gen_address_mask(DisasContext *dc, TCGv addr)
|
|
|
|
{
|
|
|
|
#ifdef TARGET_SPARC64
|
|
|
|
if (AM_CHECK(dc))
|
|
|
|
tcg_gen_andi_tl(addr, addr, 0xffffffffULL);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2012-10-16 11:32:12 +02:00
|
|
|
static inline TCGv gen_load_gpr(DisasContext *dc, int reg)
|
|
|
|
{
|
2013-09-19 19:51:12 +02:00
|
|
|
if (reg > 0) {
|
|
|
|
assert(reg < 32);
|
|
|
|
return cpu_regs[reg];
|
|
|
|
} else {
|
2023-02-25 08:24:23 +01:00
|
|
|
TCGv t = tcg_temp_new();
|
2013-09-19 19:51:12 +02:00
|
|
|
tcg_gen_movi_tl(t, 0);
|
2012-10-16 11:32:12 +02:00
|
|
|
return t;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void gen_store_gpr(DisasContext *dc, int reg, TCGv v)
|
|
|
|
{
|
|
|
|
if (reg > 0) {
|
2013-09-19 19:51:12 +02:00
|
|
|
assert(reg < 32);
|
|
|
|
tcg_gen_mov_tl(cpu_regs[reg], v);
|
2012-10-16 11:32:12 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline TCGv gen_dest_gpr(DisasContext *dc, int reg)
|
|
|
|
{
|
2013-09-19 19:51:12 +02:00
|
|
|
if (reg > 0) {
|
|
|
|
assert(reg < 32);
|
|
|
|
return cpu_regs[reg];
|
2012-10-16 11:32:12 +02:00
|
|
|
} else {
|
2023-02-25 08:24:23 +01:00
|
|
|
return tcg_temp_new();
|
2012-10-16 11:32:12 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-06-21 01:54:12 +02:00
|
|
|
static bool use_goto_tb(DisasContext *s, target_ulong pc, target_ulong npc)
|
2016-04-09 00:00:23 +02:00
|
|
|
{
|
2021-06-21 01:54:12 +02:00
|
|
|
return translator_use_goto_tb(&s->base, pc) &&
|
|
|
|
translator_use_goto_tb(&s->base, npc);
|
2016-04-09 00:00:23 +02:00
|
|
|
}
|
|
|
|
|
2021-06-21 01:54:12 +02:00
|
|
|
static void gen_goto_tb(DisasContext *s, int tb_num,
|
|
|
|
target_ulong pc, target_ulong npc)
|
2005-11-20 11:32:05 +01:00
|
|
|
{
|
2016-04-09 00:00:23 +02:00
|
|
|
if (use_goto_tb(s, pc, npc)) {
|
2005-11-20 11:32:05 +01:00
|
|
|
/* jump to same page: we can use a direct jump */
|
2008-02-01 11:50:11 +01:00
|
|
|
tcg_gen_goto_tb(tb_num);
|
2008-03-26 21:45:06 +01:00
|
|
|
tcg_gen_movi_tl(cpu_pc, pc);
|
|
|
|
tcg_gen_movi_tl(cpu_npc, npc);
|
2018-05-31 03:06:23 +02:00
|
|
|
tcg_gen_exit_tb(s->base.tb, tb_num);
|
2005-11-20 11:32:05 +01:00
|
|
|
} else {
|
|
|
|
/* jump to another page: currently not optimized */
|
2008-03-26 21:45:06 +01:00
|
|
|
tcg_gen_movi_tl(cpu_pc, pc);
|
|
|
|
tcg_gen_movi_tl(cpu_npc, npc);
|
2018-05-31 03:06:23 +02:00
|
|
|
tcg_gen_exit_tb(NULL, 0);
|
2005-11-20 11:32:05 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-03-08 22:36:50 +01:00
|
|
|
// XXX suboptimal
|
2008-11-17 15:43:54 +01:00
|
|
|
static inline void gen_mov_reg_N(TCGv reg, TCGv_i32 src)
|
2008-03-08 22:36:50 +01:00
|
|
|
{
|
2008-03-22 09:40:28 +01:00
|
|
|
tcg_gen_extu_i32_tl(reg, src);
|
2017-07-18 06:55:36 +02:00
|
|
|
tcg_gen_extract_tl(reg, reg, PSR_NEG_SHIFT, 1);
|
2008-03-08 22:36:50 +01:00
|
|
|
}
|
|
|
|
|
2008-11-17 15:43:54 +01:00
|
|
|
static inline void gen_mov_reg_Z(TCGv reg, TCGv_i32 src)
|
2008-03-08 22:36:50 +01:00
|
|
|
{
|
2008-03-22 09:40:28 +01:00
|
|
|
tcg_gen_extu_i32_tl(reg, src);
|
2017-07-18 06:55:36 +02:00
|
|
|
tcg_gen_extract_tl(reg, reg, PSR_ZERO_SHIFT, 1);
|
2008-03-08 22:36:50 +01:00
|
|
|
}
|
|
|
|
|
2008-11-17 15:43:54 +01:00
|
|
|
static inline void gen_mov_reg_V(TCGv reg, TCGv_i32 src)
|
2008-03-08 22:36:50 +01:00
|
|
|
{
|
2008-03-22 09:40:28 +01:00
|
|
|
tcg_gen_extu_i32_tl(reg, src);
|
2017-07-18 06:55:36 +02:00
|
|
|
tcg_gen_extract_tl(reg, reg, PSR_OVF_SHIFT, 1);
|
2008-03-08 22:36:50 +01:00
|
|
|
}
|
|
|
|
|
2008-11-17 15:43:54 +01:00
|
|
|
static inline void gen_mov_reg_C(TCGv reg, TCGv_i32 src)
|
2008-03-08 22:36:50 +01:00
|
|
|
{
|
2008-03-22 09:40:28 +01:00
|
|
|
tcg_gen_extu_i32_tl(reg, src);
|
2017-07-18 06:55:36 +02:00
|
|
|
tcg_gen_extract_tl(reg, reg, PSR_CARRY_SHIFT, 1);
|
2008-03-08 22:36:50 +01:00
|
|
|
}
|
|
|
|
|
2008-03-26 21:47:52 +01:00
|
|
|
static inline void gen_op_add_cc(TCGv dst, TCGv src1, TCGv src2)
|
2008-03-13 21:45:31 +01:00
|
|
|
{
|
2008-03-26 21:47:52 +01:00
|
|
|
tcg_gen_mov_tl(cpu_cc_src, src1);
|
2008-05-03 22:51:00 +02:00
|
|
|
tcg_gen_mov_tl(cpu_cc_src2, src2);
|
2008-06-21 21:46:48 +02:00
|
|
|
tcg_gen_add_tl(cpu_cc_dst, cpu_cc_src, cpu_cc_src2);
|
2009-05-10 09:19:17 +02:00
|
|
|
tcg_gen_mov_tl(dst, cpu_cc_dst);
|
2009-05-02 21:14:05 +02:00
|
|
|
}
|
|
|
|
|
2010-05-12 20:04:27 +02:00
|
|
|
static TCGv_i32 gen_add32_carry32(void)
|
2008-03-13 21:45:31 +01:00
|
|
|
{
|
2010-05-12 20:04:27 +02:00
|
|
|
TCGv_i32 carry_32, cc_src1_32, cc_src2_32;
|
|
|
|
|
|
|
|
/* Carry is computed from a previous add: (dst < src) */
|
|
|
|
#if TARGET_LONG_BITS == 64
|
|
|
|
cc_src1_32 = tcg_temp_new_i32();
|
|
|
|
cc_src2_32 = tcg_temp_new_i32();
|
2015-07-24 20:49:53 +02:00
|
|
|
tcg_gen_extrl_i64_i32(cc_src1_32, cpu_cc_dst);
|
|
|
|
tcg_gen_extrl_i64_i32(cc_src2_32, cpu_cc_src);
|
2010-05-12 20:04:27 +02:00
|
|
|
#else
|
|
|
|
cc_src1_32 = cpu_cc_dst;
|
|
|
|
cc_src2_32 = cpu_cc_src;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
carry_32 = tcg_temp_new_i32();
|
|
|
|
tcg_gen_setcond_i32(TCG_COND_LTU, carry_32, cc_src1_32, cc_src2_32);
|
|
|
|
|
|
|
|
return carry_32;
|
2009-05-02 21:14:05 +02:00
|
|
|
}
|
|
|
|
|
2010-05-12 20:04:27 +02:00
|
|
|
static TCGv_i32 gen_sub32_carry32(void)
|
2009-05-02 21:14:05 +02:00
|
|
|
{
|
2010-05-12 20:04:27 +02:00
|
|
|
TCGv_i32 carry_32, cc_src1_32, cc_src2_32;
|
|
|
|
|
|
|
|
/* Carry is computed from a previous borrow: (src1 < src2) */
|
|
|
|
#if TARGET_LONG_BITS == 64
|
|
|
|
cc_src1_32 = tcg_temp_new_i32();
|
|
|
|
cc_src2_32 = tcg_temp_new_i32();
|
2015-07-24 20:49:53 +02:00
|
|
|
tcg_gen_extrl_i64_i32(cc_src1_32, cpu_cc_src);
|
|
|
|
tcg_gen_extrl_i64_i32(cc_src2_32, cpu_cc_src2);
|
2010-05-12 20:04:27 +02:00
|
|
|
#else
|
|
|
|
cc_src1_32 = cpu_cc_src;
|
|
|
|
cc_src2_32 = cpu_cc_src2;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
carry_32 = tcg_temp_new_i32();
|
|
|
|
tcg_gen_setcond_i32(TCG_COND_LTU, carry_32, cc_src1_32, cc_src2_32);
|
|
|
|
|
|
|
|
return carry_32;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void gen_op_addx_int(DisasContext *dc, TCGv dst, TCGv src1,
|
|
|
|
TCGv src2, int update_cc)
|
|
|
|
{
|
|
|
|
TCGv_i32 carry_32;
|
|
|
|
TCGv carry;
|
|
|
|
|
|
|
|
switch (dc->cc_op) {
|
|
|
|
case CC_OP_DIV:
|
|
|
|
case CC_OP_LOGIC:
|
|
|
|
/* Carry is known to be zero. Fall back to plain ADD. */
|
|
|
|
if (update_cc) {
|
|
|
|
gen_op_add_cc(dst, src1, src2);
|
|
|
|
} else {
|
|
|
|
tcg_gen_add_tl(dst, src1, src2);
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
|
|
|
|
case CC_OP_ADD:
|
|
|
|
case CC_OP_TADD:
|
|
|
|
case CC_OP_TADDTV:
|
2013-02-20 08:52:21 +01:00
|
|
|
if (TARGET_LONG_BITS == 32) {
|
|
|
|
/* We can re-use the host's hardware carry generation by using
|
|
|
|
an ADD2 opcode. We discard the low part of the output.
|
|
|
|
Ideally we'd combine this operation with the add that
|
|
|
|
generated the carry in the first place. */
|
|
|
|
carry = tcg_temp_new();
|
|
|
|
tcg_gen_add2_tl(carry, dst, cpu_cc_src, src1, cpu_cc_src2, src2);
|
2010-05-12 20:04:27 +02:00
|
|
|
goto add_done;
|
|
|
|
}
|
|
|
|
carry_32 = gen_add32_carry32();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CC_OP_SUB:
|
|
|
|
case CC_OP_TSUB:
|
|
|
|
case CC_OP_TSUBTV:
|
|
|
|
carry_32 = gen_sub32_carry32();
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
/* We need external help to produce the carry. */
|
|
|
|
carry_32 = tcg_temp_new_i32();
|
2011-07-03 18:01:57 +02:00
|
|
|
gen_helper_compute_C_icc(carry_32, cpu_env);
|
2010-05-12 20:04:27 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
#if TARGET_LONG_BITS == 64
|
|
|
|
carry = tcg_temp_new();
|
|
|
|
tcg_gen_extu_i32_i64(carry, carry_32);
|
|
|
|
#else
|
|
|
|
carry = carry_32;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
tcg_gen_add_tl(dst, src1, src2);
|
|
|
|
tcg_gen_add_tl(dst, dst, carry);
|
|
|
|
|
|
|
|
add_done:
|
|
|
|
if (update_cc) {
|
|
|
|
tcg_gen_mov_tl(cpu_cc_src, src1);
|
|
|
|
tcg_gen_mov_tl(cpu_cc_src2, src2);
|
|
|
|
tcg_gen_mov_tl(cpu_cc_dst, dst);
|
|
|
|
tcg_gen_movi_i32(cpu_cc_op, CC_OP_ADDX);
|
|
|
|
dc->cc_op = CC_OP_ADDX;
|
|
|
|
}
|
2008-03-13 21:45:31 +01:00
|
|
|
}
|
|
|
|
|
2009-05-02 21:14:05 +02:00
|
|
|
static inline void gen_op_sub_cc(TCGv dst, TCGv src1, TCGv src2)
|
2008-03-13 21:45:31 +01:00
|
|
|
{
|
2008-03-26 21:47:52 +01:00
|
|
|
tcg_gen_mov_tl(cpu_cc_src, src1);
|
2008-05-03 22:51:00 +02:00
|
|
|
tcg_gen_mov_tl(cpu_cc_src2, src2);
|
2009-05-02 21:14:05 +02:00
|
|
|
tcg_gen_sub_tl(cpu_cc_dst, cpu_cc_src, cpu_cc_src2);
|
2009-05-10 09:38:34 +02:00
|
|
|
tcg_gen_mov_tl(dst, cpu_cc_dst);
|
2009-05-02 21:14:05 +02:00
|
|
|
}
|
|
|
|
|
2010-05-12 20:04:27 +02:00
|
|
|
static void gen_op_subx_int(DisasContext *dc, TCGv dst, TCGv src1,
|
|
|
|
TCGv src2, int update_cc)
|
2009-05-02 21:14:05 +02:00
|
|
|
{
|
2010-05-12 20:04:27 +02:00
|
|
|
TCGv_i32 carry_32;
|
|
|
|
TCGv carry;
|
2009-05-02 21:14:05 +02:00
|
|
|
|
2010-05-12 20:04:27 +02:00
|
|
|
switch (dc->cc_op) {
|
|
|
|
case CC_OP_DIV:
|
|
|
|
case CC_OP_LOGIC:
|
|
|
|
/* Carry is known to be zero. Fall back to plain SUB. */
|
|
|
|
if (update_cc) {
|
|
|
|
gen_op_sub_cc(dst, src1, src2);
|
|
|
|
} else {
|
|
|
|
tcg_gen_sub_tl(dst, src1, src2);
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
|
|
|
|
case CC_OP_ADD:
|
|
|
|
case CC_OP_TADD:
|
|
|
|
case CC_OP_TADDTV:
|
|
|
|
carry_32 = gen_add32_carry32();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CC_OP_SUB:
|
|
|
|
case CC_OP_TSUB:
|
|
|
|
case CC_OP_TSUBTV:
|
2013-02-20 08:52:21 +01:00
|
|
|
if (TARGET_LONG_BITS == 32) {
|
|
|
|
/* We can re-use the host's hardware carry generation by using
|
|
|
|
a SUB2 opcode. We discard the low part of the output.
|
|
|
|
Ideally we'd combine this operation with the add that
|
|
|
|
generated the carry in the first place. */
|
|
|
|
carry = tcg_temp_new();
|
|
|
|
tcg_gen_sub2_tl(carry, dst, cpu_cc_src, src1, cpu_cc_src2, src2);
|
2010-05-12 20:04:27 +02:00
|
|
|
goto sub_done;
|
|
|
|
}
|
|
|
|
carry_32 = gen_sub32_carry32();
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
/* We need external help to produce the carry. */
|
|
|
|
carry_32 = tcg_temp_new_i32();
|
2011-07-03 18:01:57 +02:00
|
|
|
gen_helper_compute_C_icc(carry_32, cpu_env);
|
2010-05-12 20:04:27 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
#if TARGET_LONG_BITS == 64
|
|
|
|
carry = tcg_temp_new();
|
|
|
|
tcg_gen_extu_i32_i64(carry, carry_32);
|
|
|
|
#else
|
|
|
|
carry = carry_32;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
tcg_gen_sub_tl(dst, src1, src2);
|
|
|
|
tcg_gen_sub_tl(dst, dst, carry);
|
|
|
|
|
|
|
|
sub_done:
|
|
|
|
if (update_cc) {
|
|
|
|
tcg_gen_mov_tl(cpu_cc_src, src1);
|
|
|
|
tcg_gen_mov_tl(cpu_cc_src2, src2);
|
|
|
|
tcg_gen_mov_tl(cpu_cc_dst, dst);
|
|
|
|
tcg_gen_movi_i32(cpu_cc_op, CC_OP_SUBX);
|
|
|
|
dc->cc_op = CC_OP_SUBX;
|
|
|
|
}
|
2008-03-13 21:45:31 +01:00
|
|
|
}
|
|
|
|
|
2008-03-26 21:47:52 +01:00
|
|
|
static inline void gen_op_mulscc(TCGv dst, TCGv src1, TCGv src2)
|
2008-03-16 20:22:18 +01:00
|
|
|
{
|
2012-10-16 11:32:31 +02:00
|
|
|
TCGv r_temp, zero, t0;
|
2008-03-16 20:22:18 +01:00
|
|
|
|
2008-11-17 15:43:54 +01:00
|
|
|
r_temp = tcg_temp_new();
|
2012-10-16 11:32:31 +02:00
|
|
|
t0 = tcg_temp_new();
|
2008-03-16 20:22:18 +01:00
|
|
|
|
|
|
|
/* old op:
|
|
|
|
if (!(env->y & 1))
|
|
|
|
T1 = 0;
|
|
|
|
*/
|
2023-02-26 22:15:00 +01:00
|
|
|
zero = tcg_constant_tl(0);
|
2008-09-13 19:20:52 +02:00
|
|
|
tcg_gen_andi_tl(cpu_cc_src, src1, 0xffffffff);
|
2008-09-06 19:51:43 +02:00
|
|
|
tcg_gen_andi_tl(r_temp, cpu_y, 0x1);
|
2008-09-13 19:20:52 +02:00
|
|
|
tcg_gen_andi_tl(cpu_cc_src2, src2, 0xffffffff);
|
2012-10-06 01:55:06 +02:00
|
|
|
tcg_gen_movcond_tl(TCG_COND_EQ, cpu_cc_src2, r_temp, zero,
|
|
|
|
zero, cpu_cc_src2);
|
2008-03-16 20:22:18 +01:00
|
|
|
|
|
|
|
// b2 = T0 & 1;
|
|
|
|
// env->y = (b2 << 31) | (env->y >> 1);
|
2017-07-18 06:55:36 +02:00
|
|
|
tcg_gen_extract_tl(t0, cpu_y, 1, 31);
|
2017-07-18 06:55:38 +02:00
|
|
|
tcg_gen_deposit_tl(cpu_y, t0, cpu_cc_src, 31, 1);
|
2008-03-16 20:22:18 +01:00
|
|
|
|
|
|
|
// b1 = N ^ V;
|
2012-10-16 11:32:31 +02:00
|
|
|
gen_mov_reg_N(t0, cpu_psr);
|
2008-03-16 20:22:18 +01:00
|
|
|
gen_mov_reg_V(r_temp, cpu_psr);
|
2012-10-16 11:32:31 +02:00
|
|
|
tcg_gen_xor_tl(t0, t0, r_temp);
|
2008-03-16 20:22:18 +01:00
|
|
|
|
|
|
|
// T0 = (b1 << 31) | (T0 >> 1);
|
|
|
|
// src1 = T0;
|
2012-10-16 11:32:31 +02:00
|
|
|
tcg_gen_shli_tl(t0, t0, 31);
|
2008-05-03 22:51:00 +02:00
|
|
|
tcg_gen_shri_tl(cpu_cc_src, cpu_cc_src, 1);
|
2012-10-16 11:32:31 +02:00
|
|
|
tcg_gen_or_tl(cpu_cc_src, cpu_cc_src, t0);
|
2008-03-16 20:22:18 +01:00
|
|
|
|
2008-06-21 21:46:48 +02:00
|
|
|
tcg_gen_add_tl(cpu_cc_dst, cpu_cc_src, cpu_cc_src2);
|
2008-03-16 20:22:18 +01:00
|
|
|
|
2008-06-21 21:46:48 +02:00
|
|
|
tcg_gen_mov_tl(dst, cpu_cc_dst);
|
2008-03-16 20:22:18 +01:00
|
|
|
}
|
|
|
|
|
2010-06-01 22:12:58 +02:00
|
|
|
static inline void gen_op_multiply(TCGv dst, TCGv src1, TCGv src2, int sign_ext)
|
2008-03-16 20:24:42 +01:00
|
|
|
{
|
2013-02-20 08:52:22 +01:00
|
|
|
#if TARGET_LONG_BITS == 32
|
2010-06-01 22:12:58 +02:00
|
|
|
if (sign_ext) {
|
2013-02-20 08:52:22 +01:00
|
|
|
tcg_gen_muls2_tl(dst, cpu_y, src1, src2);
|
2010-06-01 22:12:58 +02:00
|
|
|
} else {
|
2013-02-20 08:52:22 +01:00
|
|
|
tcg_gen_mulu2_tl(dst, cpu_y, src1, src2);
|
2010-06-01 22:12:58 +02:00
|
|
|
}
|
2013-02-20 08:52:22 +01:00
|
|
|
#else
|
|
|
|
TCGv t0 = tcg_temp_new_i64();
|
|
|
|
TCGv t1 = tcg_temp_new_i64();
|
2010-06-01 22:12:58 +02:00
|
|
|
|
2013-02-20 08:52:22 +01:00
|
|
|
if (sign_ext) {
|
|
|
|
tcg_gen_ext32s_i64(t0, src1);
|
|
|
|
tcg_gen_ext32s_i64(t1, src2);
|
|
|
|
} else {
|
|
|
|
tcg_gen_ext32u_i64(t0, src1);
|
|
|
|
tcg_gen_ext32u_i64(t1, src2);
|
|
|
|
}
|
2010-06-01 22:12:58 +02:00
|
|
|
|
2013-02-20 08:52:22 +01:00
|
|
|
tcg_gen_mul_i64(dst, t0, t1);
|
|
|
|
tcg_gen_shri_i64(cpu_y, dst, 32);
|
|
|
|
#endif
|
2008-03-16 20:24:42 +01:00
|
|
|
}
|
|
|
|
|
2010-06-01 22:12:58 +02:00
|
|
|
static inline void gen_op_umul(TCGv dst, TCGv src1, TCGv src2)
|
2008-03-16 20:24:42 +01:00
|
|
|
{
|
2010-06-01 22:12:58 +02:00
|
|
|
/* zero-extend truncated operands before multiplication */
|
|
|
|
gen_op_multiply(dst, src1, src2, 0);
|
|
|
|
}
|
2008-03-16 20:24:42 +01:00
|
|
|
|
2010-06-01 22:12:58 +02:00
|
|
|
static inline void gen_op_smul(TCGv dst, TCGv src1, TCGv src2)
|
|
|
|
{
|
|
|
|
/* sign-extend truncated operands before multiplication */
|
|
|
|
gen_op_multiply(dst, src1, src2, 1);
|
2008-03-16 20:24:42 +01:00
|
|
|
}
|
|
|
|
|
2008-03-08 22:36:50 +01:00
|
|
|
// 1
|
|
|
|
static inline void gen_op_eval_ba(TCGv dst)
|
|
|
|
{
|
|
|
|
tcg_gen_movi_tl(dst, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Z
|
2008-11-17 15:43:54 +01:00
|
|
|
static inline void gen_op_eval_be(TCGv dst, TCGv_i32 src)
|
2008-03-08 22:36:50 +01:00
|
|
|
{
|
|
|
|
gen_mov_reg_Z(dst, src);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Z | (N ^ V)
|
2008-11-17 15:43:54 +01:00
|
|
|
static inline void gen_op_eval_ble(TCGv dst, TCGv_i32 src)
|
2008-03-08 22:36:50 +01:00
|
|
|
{
|
2012-10-16 11:32:31 +02:00
|
|
|
TCGv t0 = tcg_temp_new();
|
|
|
|
gen_mov_reg_N(t0, src);
|
2008-03-08 22:36:50 +01:00
|
|
|
gen_mov_reg_V(dst, src);
|
2012-10-16 11:32:31 +02:00
|
|
|
tcg_gen_xor_tl(dst, dst, t0);
|
|
|
|
gen_mov_reg_Z(t0, src);
|
|
|
|
tcg_gen_or_tl(dst, dst, t0);
|
2008-03-08 22:36:50 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// N ^ V
|
2008-11-17 15:43:54 +01:00
|
|
|
static inline void gen_op_eval_bl(TCGv dst, TCGv_i32 src)
|
2008-03-08 22:36:50 +01:00
|
|
|
{
|
2012-10-16 11:32:31 +02:00
|
|
|
TCGv t0 = tcg_temp_new();
|
|
|
|
gen_mov_reg_V(t0, src);
|
2008-03-08 22:36:50 +01:00
|
|
|
gen_mov_reg_N(dst, src);
|
2012-10-16 11:32:31 +02:00
|
|
|
tcg_gen_xor_tl(dst, dst, t0);
|
2008-03-08 22:36:50 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// C | Z
|
2008-11-17 15:43:54 +01:00
|
|
|
static inline void gen_op_eval_bleu(TCGv dst, TCGv_i32 src)
|
2008-03-08 22:36:50 +01:00
|
|
|
{
|
2012-10-16 11:32:31 +02:00
|
|
|
TCGv t0 = tcg_temp_new();
|
|
|
|
gen_mov_reg_Z(t0, src);
|
2008-03-08 22:36:50 +01:00
|
|
|
gen_mov_reg_C(dst, src);
|
2012-10-16 11:32:31 +02:00
|
|
|
tcg_gen_or_tl(dst, dst, t0);
|
2008-03-08 22:36:50 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// C
|
2008-11-17 15:43:54 +01:00
|
|
|
static inline void gen_op_eval_bcs(TCGv dst, TCGv_i32 src)
|
2008-03-08 22:36:50 +01:00
|
|
|
{
|
|
|
|
gen_mov_reg_C(dst, src);
|
|
|
|
}
|
|
|
|
|
|
|
|
// V
|
2008-11-17 15:43:54 +01:00
|
|
|
static inline void gen_op_eval_bvs(TCGv dst, TCGv_i32 src)
|
2008-03-08 22:36:50 +01:00
|
|
|
{
|
|
|
|
gen_mov_reg_V(dst, src);
|
|
|
|
}
|
|
|
|
|
|
|
|
// 0
|
|
|
|
static inline void gen_op_eval_bn(TCGv dst)
|
|
|
|
{
|
|
|
|
tcg_gen_movi_tl(dst, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
// N
|
2008-11-17 15:43:54 +01:00
|
|
|
static inline void gen_op_eval_bneg(TCGv dst, TCGv_i32 src)
|
2008-03-08 22:36:50 +01:00
|
|
|
{
|
|
|
|
gen_mov_reg_N(dst, src);
|
|
|
|
}
|
|
|
|
|
|
|
|
// !Z
|
2008-11-17 15:43:54 +01:00
|
|
|
static inline void gen_op_eval_bne(TCGv dst, TCGv_i32 src)
|
2008-03-08 22:36:50 +01:00
|
|
|
{
|
|
|
|
gen_mov_reg_Z(dst, src);
|
|
|
|
tcg_gen_xori_tl(dst, dst, 0x1);
|
|
|
|
}
|
|
|
|
|
|
|
|
// !(Z | (N ^ V))
|
2008-11-17 15:43:54 +01:00
|
|
|
static inline void gen_op_eval_bg(TCGv dst, TCGv_i32 src)
|
2008-03-08 22:36:50 +01:00
|
|
|
{
|
2012-10-16 11:32:31 +02:00
|
|
|
gen_op_eval_ble(dst, src);
|
2008-03-08 22:36:50 +01:00
|
|
|
tcg_gen_xori_tl(dst, dst, 0x1);
|
|
|
|
}
|
|
|
|
|
|
|
|
// !(N ^ V)
|
2008-11-17 15:43:54 +01:00
|
|
|
static inline void gen_op_eval_bge(TCGv dst, TCGv_i32 src)
|
2008-03-08 22:36:50 +01:00
|
|
|
{
|
2012-10-16 11:32:31 +02:00
|
|
|
gen_op_eval_bl(dst, src);
|
2008-03-08 22:36:50 +01:00
|
|
|
tcg_gen_xori_tl(dst, dst, 0x1);
|
|
|
|
}
|
|
|
|
|
|
|
|
// !(C | Z)
|
2008-11-17 15:43:54 +01:00
|
|
|
static inline void gen_op_eval_bgu(TCGv dst, TCGv_i32 src)
|
2008-03-08 22:36:50 +01:00
|
|
|
{
|
2012-10-16 11:32:31 +02:00
|
|
|
gen_op_eval_bleu(dst, src);
|
2008-03-08 22:36:50 +01:00
|
|
|
tcg_gen_xori_tl(dst, dst, 0x1);
|
|
|
|
}
|
|
|
|
|
|
|
|
// !C
|
2008-11-17 15:43:54 +01:00
|
|
|
static inline void gen_op_eval_bcc(TCGv dst, TCGv_i32 src)
|
2008-03-08 22:36:50 +01:00
|
|
|
{
|
|
|
|
gen_mov_reg_C(dst, src);
|
|
|
|
tcg_gen_xori_tl(dst, dst, 0x1);
|
|
|
|
}
|
|
|
|
|
|
|
|
// !N
|
2008-11-17 15:43:54 +01:00
|
|
|
static inline void gen_op_eval_bpos(TCGv dst, TCGv_i32 src)
|
2008-03-08 22:36:50 +01:00
|
|
|
{
|
|
|
|
gen_mov_reg_N(dst, src);
|
|
|
|
tcg_gen_xori_tl(dst, dst, 0x1);
|
|
|
|
}
|
|
|
|
|
|
|
|
// !V
|
2008-11-17 15:43:54 +01:00
|
|
|
static inline void gen_op_eval_bvc(TCGv dst, TCGv_i32 src)
|
2008-03-08 22:36:50 +01:00
|
|
|
{
|
|
|
|
gen_mov_reg_V(dst, src);
|
|
|
|
tcg_gen_xori_tl(dst, dst, 0x1);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
FPSR bit field FCC1 | FCC0:
|
|
|
|
0 =
|
|
|
|
1 <
|
|
|
|
2 >
|
|
|
|
3 unordered
|
|
|
|
*/
|
|
|
|
static inline void gen_mov_reg_FCC0(TCGv reg, TCGv src,
|
|
|
|
unsigned int fcc_offset)
|
|
|
|
{
|
2008-08-29 23:03:31 +02:00
|
|
|
tcg_gen_shri_tl(reg, src, FSR_FCC0_SHIFT + fcc_offset);
|
2008-03-08 22:36:50 +01:00
|
|
|
tcg_gen_andi_tl(reg, reg, 0x1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void gen_mov_reg_FCC1(TCGv reg, TCGv src,
|
|
|
|
unsigned int fcc_offset)
|
|
|
|
{
|
2008-08-29 23:03:31 +02:00
|
|
|
tcg_gen_shri_tl(reg, src, FSR_FCC1_SHIFT + fcc_offset);
|
2008-03-08 22:36:50 +01:00
|
|
|
tcg_gen_andi_tl(reg, reg, 0x1);
|
|
|
|
}
|
|
|
|
|
|
|
|
// !0: FCC0 | FCC1
|
|
|
|
static inline void gen_op_eval_fbne(TCGv dst, TCGv src,
|
|
|
|
unsigned int fcc_offset)
|
|
|
|
{
|
2012-10-16 11:32:31 +02:00
|
|
|
TCGv t0 = tcg_temp_new();
|
2008-03-08 22:36:50 +01:00
|
|
|
gen_mov_reg_FCC0(dst, src, fcc_offset);
|
2012-10-16 11:32:31 +02:00
|
|
|
gen_mov_reg_FCC1(t0, src, fcc_offset);
|
|
|
|
tcg_gen_or_tl(dst, dst, t0);
|
2008-03-08 22:36:50 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// 1 or 2: FCC0 ^ FCC1
|
|
|
|
static inline void gen_op_eval_fblg(TCGv dst, TCGv src,
|
|
|
|
unsigned int fcc_offset)
|
|
|
|
{
|
2012-10-16 11:32:31 +02:00
|
|
|
TCGv t0 = tcg_temp_new();
|
2008-03-08 22:36:50 +01:00
|
|
|
gen_mov_reg_FCC0(dst, src, fcc_offset);
|
2012-10-16 11:32:31 +02:00
|
|
|
gen_mov_reg_FCC1(t0, src, fcc_offset);
|
|
|
|
tcg_gen_xor_tl(dst, dst, t0);
|
2008-03-08 22:36:50 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// 1 or 3: FCC0
|
|
|
|
static inline void gen_op_eval_fbul(TCGv dst, TCGv src,
|
|
|
|
unsigned int fcc_offset)
|
|
|
|
{
|
|
|
|
gen_mov_reg_FCC0(dst, src, fcc_offset);
|
|
|
|
}
|
|
|
|
|
|
|
|
// 1: FCC0 & !FCC1
|
|
|
|
static inline void gen_op_eval_fbl(TCGv dst, TCGv src,
|
|
|
|
unsigned int fcc_offset)
|
|
|
|
{
|
2012-10-16 11:32:31 +02:00
|
|
|
TCGv t0 = tcg_temp_new();
|
2008-03-08 22:36:50 +01:00
|
|
|
gen_mov_reg_FCC0(dst, src, fcc_offset);
|
2012-10-16 11:32:31 +02:00
|
|
|
gen_mov_reg_FCC1(t0, src, fcc_offset);
|
|
|
|
tcg_gen_andc_tl(dst, dst, t0);
|
2008-03-08 22:36:50 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// 2 or 3: FCC1
|
|
|
|
static inline void gen_op_eval_fbug(TCGv dst, TCGv src,
|
|
|
|
unsigned int fcc_offset)
|
|
|
|
{
|
|
|
|
gen_mov_reg_FCC1(dst, src, fcc_offset);
|
|
|
|
}
|
|
|
|
|
|
|
|
// 2: !FCC0 & FCC1
|
|
|
|
static inline void gen_op_eval_fbg(TCGv dst, TCGv src,
|
|
|
|
unsigned int fcc_offset)
|
|
|
|
{
|
2012-10-16 11:32:31 +02:00
|
|
|
TCGv t0 = tcg_temp_new();
|
2008-03-08 22:36:50 +01:00
|
|
|
gen_mov_reg_FCC0(dst, src, fcc_offset);
|
2012-10-16 11:32:31 +02:00
|
|
|
gen_mov_reg_FCC1(t0, src, fcc_offset);
|
|
|
|
tcg_gen_andc_tl(dst, t0, dst);
|
2008-03-08 22:36:50 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// 3: FCC0 & FCC1
|
|
|
|
static inline void gen_op_eval_fbu(TCGv dst, TCGv src,
|
|
|
|
unsigned int fcc_offset)
|
|
|
|
{
|
2012-10-16 11:32:31 +02:00
|
|
|
TCGv t0 = tcg_temp_new();
|
2008-03-08 22:36:50 +01:00
|
|
|
gen_mov_reg_FCC0(dst, src, fcc_offset);
|
2012-10-16 11:32:31 +02:00
|
|
|
gen_mov_reg_FCC1(t0, src, fcc_offset);
|
|
|
|
tcg_gen_and_tl(dst, dst, t0);
|
2008-03-08 22:36:50 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// 0: !(FCC0 | FCC1)
|
|
|
|
static inline void gen_op_eval_fbe(TCGv dst, TCGv src,
|
|
|
|
unsigned int fcc_offset)
|
|
|
|
{
|
2012-10-16 11:32:31 +02:00
|
|
|
TCGv t0 = tcg_temp_new();
|
2008-03-08 22:36:50 +01:00
|
|
|
gen_mov_reg_FCC0(dst, src, fcc_offset);
|
2012-10-16 11:32:31 +02:00
|
|
|
gen_mov_reg_FCC1(t0, src, fcc_offset);
|
|
|
|
tcg_gen_or_tl(dst, dst, t0);
|
2008-03-08 22:36:50 +01:00
|
|
|
tcg_gen_xori_tl(dst, dst, 0x1);
|
|
|
|
}
|
|
|
|
|
|
|
|
// 0 or 3: !(FCC0 ^ FCC1)
|
|
|
|
static inline void gen_op_eval_fbue(TCGv dst, TCGv src,
|
|
|
|
unsigned int fcc_offset)
|
|
|
|
{
|
2012-10-16 11:32:31 +02:00
|
|
|
TCGv t0 = tcg_temp_new();
|
2008-03-08 22:36:50 +01:00
|
|
|
gen_mov_reg_FCC0(dst, src, fcc_offset);
|
2012-10-16 11:32:31 +02:00
|
|
|
gen_mov_reg_FCC1(t0, src, fcc_offset);
|
|
|
|
tcg_gen_xor_tl(dst, dst, t0);
|
2008-03-08 22:36:50 +01:00
|
|
|
tcg_gen_xori_tl(dst, dst, 0x1);
|
|
|
|
}
|
|
|
|
|
|
|
|
// 0 or 2: !FCC0
|
|
|
|
static inline void gen_op_eval_fbge(TCGv dst, TCGv src,
|
|
|
|
unsigned int fcc_offset)
|
|
|
|
{
|
|
|
|
gen_mov_reg_FCC0(dst, src, fcc_offset);
|
|
|
|
tcg_gen_xori_tl(dst, dst, 0x1);
|
|
|
|
}
|
|
|
|
|
|
|
|
// !1: !(FCC0 & !FCC1)
|
|
|
|
static inline void gen_op_eval_fbuge(TCGv dst, TCGv src,
|
|
|
|
unsigned int fcc_offset)
|
|
|
|
{
|
2012-10-16 11:32:31 +02:00
|
|
|
TCGv t0 = tcg_temp_new();
|
2008-03-08 22:36:50 +01:00
|
|
|
gen_mov_reg_FCC0(dst, src, fcc_offset);
|
2012-10-16 11:32:31 +02:00
|
|
|
gen_mov_reg_FCC1(t0, src, fcc_offset);
|
|
|
|
tcg_gen_andc_tl(dst, dst, t0);
|
2008-03-08 22:36:50 +01:00
|
|
|
tcg_gen_xori_tl(dst, dst, 0x1);
|
|
|
|
}
|
|
|
|
|
|
|
|
// 0 or 1: !FCC1
|
|
|
|
static inline void gen_op_eval_fble(TCGv dst, TCGv src,
|
|
|
|
unsigned int fcc_offset)
|
|
|
|
{
|
|
|
|
gen_mov_reg_FCC1(dst, src, fcc_offset);
|
|
|
|
tcg_gen_xori_tl(dst, dst, 0x1);
|
|
|
|
}
|
|
|
|
|
|
|
|
// !2: !(!FCC0 & FCC1)
|
|
|
|
static inline void gen_op_eval_fbule(TCGv dst, TCGv src,
|
|
|
|
unsigned int fcc_offset)
|
|
|
|
{
|
2012-10-16 11:32:31 +02:00
|
|
|
TCGv t0 = tcg_temp_new();
|
2008-03-08 22:36:50 +01:00
|
|
|
gen_mov_reg_FCC0(dst, src, fcc_offset);
|
2012-10-16 11:32:31 +02:00
|
|
|
gen_mov_reg_FCC1(t0, src, fcc_offset);
|
|
|
|
tcg_gen_andc_tl(dst, t0, dst);
|
2008-03-08 22:36:50 +01:00
|
|
|
tcg_gen_xori_tl(dst, dst, 0x1);
|
|
|
|
}
|
|
|
|
|
|
|
|
// !3: !(FCC0 & FCC1)
|
|
|
|
static inline void gen_op_eval_fbo(TCGv dst, TCGv src,
|
|
|
|
unsigned int fcc_offset)
|
|
|
|
{
|
2012-10-16 11:32:31 +02:00
|
|
|
TCGv t0 = tcg_temp_new();
|
2008-03-08 22:36:50 +01:00
|
|
|
gen_mov_reg_FCC0(dst, src, fcc_offset);
|
2012-10-16 11:32:31 +02:00
|
|
|
gen_mov_reg_FCC1(t0, src, fcc_offset);
|
|
|
|
tcg_gen_and_tl(dst, dst, t0);
|
2008-03-08 22:36:50 +01:00
|
|
|
tcg_gen_xori_tl(dst, dst, 0x1);
|
|
|
|
}
|
|
|
|
|
2007-06-25 21:52:58 +02:00
|
|
|
static inline void gen_branch2(DisasContext *dc, target_ulong pc1,
|
2008-03-08 22:36:50 +01:00
|
|
|
target_ulong pc2, TCGv r_cond)
|
2005-07-23 16:27:54 +02:00
|
|
|
{
|
2015-02-13 21:51:55 +01:00
|
|
|
TCGLabel *l1 = gen_new_label();
|
2005-07-23 16:27:54 +02:00
|
|
|
|
2008-05-24 04:22:00 +02:00
|
|
|
tcg_gen_brcondi_tl(TCG_COND_EQ, r_cond, 0, l1);
|
2005-07-23 16:27:54 +02:00
|
|
|
|
2005-11-20 11:32:05 +01:00
|
|
|
gen_goto_tb(dc, 0, pc1, pc1 + 4);
|
2005-07-23 16:27:54 +02:00
|
|
|
|
|
|
|
gen_set_label(l1);
|
2005-11-20 11:32:05 +01:00
|
|
|
gen_goto_tb(dc, 1, pc2, pc2 + 4);
|
2005-07-23 16:27:54 +02:00
|
|
|
}
|
|
|
|
|
2015-08-31 21:44:16 +02:00
|
|
|
static void gen_branch_a(DisasContext *dc, target_ulong pc1)
|
2005-07-23 16:27:54 +02:00
|
|
|
{
|
2015-02-13 21:51:55 +01:00
|
|
|
TCGLabel *l1 = gen_new_label();
|
2015-08-31 21:44:16 +02:00
|
|
|
target_ulong npc = dc->npc;
|
2005-07-23 16:27:54 +02:00
|
|
|
|
2015-08-31 21:44:16 +02:00
|
|
|
tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_cond, 0, l1);
|
2005-07-23 16:27:54 +02:00
|
|
|
|
2015-08-31 21:44:16 +02:00
|
|
|
gen_goto_tb(dc, 0, npc, pc1);
|
2005-07-23 16:27:54 +02:00
|
|
|
|
|
|
|
gen_set_label(l1);
|
2015-08-31 21:44:16 +02:00
|
|
|
gen_goto_tb(dc, 1, npc + 4, npc + 8);
|
|
|
|
|
2018-02-15 03:16:30 +01:00
|
|
|
dc->base.is_jmp = DISAS_NORETURN;
|
2005-07-23 16:27:54 +02:00
|
|
|
}
|
|
|
|
|
2015-08-31 22:01:47 +02:00
|
|
|
static void gen_branch_n(DisasContext *dc, target_ulong pc1)
|
|
|
|
{
|
|
|
|
target_ulong npc = dc->npc;
|
|
|
|
|
|
|
|
if (likely(npc != DYNAMIC_PC)) {
|
|
|
|
dc->pc = npc;
|
|
|
|
dc->jump_pc[0] = pc1;
|
|
|
|
dc->jump_pc[1] = npc + 4;
|
|
|
|
dc->npc = JUMP_PC;
|
|
|
|
} else {
|
|
|
|
TCGv t, z;
|
|
|
|
|
|
|
|
tcg_gen_mov_tl(cpu_pc, cpu_npc);
|
|
|
|
|
|
|
|
tcg_gen_addi_tl(cpu_npc, cpu_npc, 4);
|
2023-02-26 22:15:00 +01:00
|
|
|
t = tcg_constant_tl(pc1);
|
|
|
|
z = tcg_constant_tl(0);
|
2015-08-31 22:01:47 +02:00
|
|
|
tcg_gen_movcond_tl(TCG_COND_NE, cpu_npc, cpu_cond, z, t, cpu_npc);
|
|
|
|
|
|
|
|
dc->pc = DYNAMIC_PC;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-10-06 01:54:56 +02:00
|
|
|
static inline void gen_generic_branch(DisasContext *dc)
|
2005-07-23 16:27:54 +02:00
|
|
|
{
|
2023-02-26 22:15:00 +01:00
|
|
|
TCGv npc0 = tcg_constant_tl(dc->jump_pc[0]);
|
|
|
|
TCGv npc1 = tcg_constant_tl(dc->jump_pc[1]);
|
|
|
|
TCGv zero = tcg_constant_tl(0);
|
2008-03-08 22:36:50 +01:00
|
|
|
|
2012-10-06 01:55:02 +02:00
|
|
|
tcg_gen_movcond_tl(TCG_COND_NE, cpu_npc, cpu_cond, zero, npc0, npc1);
|
2005-07-23 16:27:54 +02:00
|
|
|
}
|
|
|
|
|
2008-03-26 21:47:52 +01:00
|
|
|
/* call this function before using the condition register as it may
|
|
|
|
have been set for a jump */
|
2012-10-06 01:54:51 +02:00
|
|
|
static inline void flush_cond(DisasContext *dc)
|
2005-07-23 16:27:54 +02:00
|
|
|
{
|
|
|
|
if (dc->npc == JUMP_PC) {
|
2012-10-06 01:54:56 +02:00
|
|
|
gen_generic_branch(dc);
|
2005-07-23 16:27:54 +02:00
|
|
|
dc->npc = DYNAMIC_PC;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-10-06 01:54:55 +02:00
|
|
|
static inline void save_npc(DisasContext *dc)
|
2004-02-16 21:30:05 +01:00
|
|
|
{
|
|
|
|
if (dc->npc == JUMP_PC) {
|
2012-10-06 01:54:56 +02:00
|
|
|
gen_generic_branch(dc);
|
2004-02-16 21:30:05 +01:00
|
|
|
dc->npc = DYNAMIC_PC;
|
|
|
|
} else if (dc->npc != DYNAMIC_PC) {
|
2008-03-26 21:45:06 +01:00
|
|
|
tcg_gen_movi_tl(cpu_npc, dc->npc);
|
2004-02-16 21:30:05 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-10-09 23:50:00 +02:00
|
|
|
static inline void update_psr(DisasContext *dc)
|
2004-02-16 21:30:05 +01:00
|
|
|
{
|
2009-08-15 18:52:54 +02:00
|
|
|
if (dc->cc_op != CC_OP_FLAGS) {
|
|
|
|
dc->cc_op = CC_OP_FLAGS;
|
2011-07-03 18:01:57 +02:00
|
|
|
gen_helper_compute_psr(cpu_env);
|
2009-08-15 18:52:54 +02:00
|
|
|
}
|
2012-10-09 23:50:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline void save_state(DisasContext *dc)
|
|
|
|
{
|
|
|
|
tcg_gen_movi_tl(cpu_pc, dc->pc);
|
2012-10-06 01:54:55 +02:00
|
|
|
save_npc(dc);
|
2004-02-16 21:30:05 +01:00
|
|
|
}
|
|
|
|
|
2015-09-03 05:00:29 +02:00
|
|
|
static void gen_exception(DisasContext *dc, int which)
|
|
|
|
{
|
|
|
|
save_state(dc);
|
2023-02-26 22:15:00 +01:00
|
|
|
gen_helper_raise_exception(cpu_env, tcg_constant_i32(which));
|
2018-02-15 03:16:30 +01:00
|
|
|
dc->base.is_jmp = DISAS_NORETURN;
|
2015-09-03 05:00:29 +02:00
|
|
|
}
|
|
|
|
|
2015-09-03 21:43:15 +02:00
|
|
|
static void gen_check_align(TCGv addr, int mask)
|
|
|
|
{
|
2023-02-26 22:15:00 +01:00
|
|
|
gen_helper_check_align(cpu_env, addr, tcg_constant_i32(mask));
|
2015-09-03 21:43:15 +02:00
|
|
|
}
|
|
|
|
|
2012-10-06 01:54:54 +02:00
|
|
|
static inline void gen_mov_pc_npc(DisasContext *dc)
|
2005-02-13 21:11:30 +01:00
|
|
|
{
|
|
|
|
if (dc->npc == JUMP_PC) {
|
2012-10-06 01:54:56 +02:00
|
|
|
gen_generic_branch(dc);
|
2008-03-16 20:23:31 +01:00
|
|
|
tcg_gen_mov_tl(cpu_pc, cpu_npc);
|
2005-02-13 21:11:30 +01:00
|
|
|
dc->pc = DYNAMIC_PC;
|
|
|
|
} else if (dc->npc == DYNAMIC_PC) {
|
2008-03-16 20:23:31 +01:00
|
|
|
tcg_gen_mov_tl(cpu_pc, cpu_npc);
|
2005-02-13 21:11:30 +01:00
|
|
|
dc->pc = DYNAMIC_PC;
|
|
|
|
} else {
|
|
|
|
dc->pc = dc->npc;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-03-02 19:22:19 +01:00
|
|
|
static inline void gen_op_next_insn(void)
|
|
|
|
{
|
2008-03-16 20:23:31 +01:00
|
|
|
tcg_gen_mov_tl(cpu_pc, cpu_npc);
|
|
|
|
tcg_gen_addi_tl(cpu_npc, cpu_npc, 4);
|
2008-03-02 19:22:19 +01:00
|
|
|
}
|
|
|
|
|
2012-10-06 01:55:10 +02:00
|
|
|
static void gen_compare(DisasCompare *cmp, bool xcc, unsigned int cond,
|
2012-10-06 01:54:57 +02:00
|
|
|
DisasContext *dc)
|
2008-03-08 22:36:50 +01:00
|
|
|
{
|
2012-10-06 01:55:10 +02:00
|
|
|
static int subcc_cond[16] = {
|
2012-10-09 23:49:58 +02:00
|
|
|
TCG_COND_NEVER,
|
2012-10-06 01:55:10 +02:00
|
|
|
TCG_COND_EQ,
|
|
|
|
TCG_COND_LE,
|
|
|
|
TCG_COND_LT,
|
|
|
|
TCG_COND_LEU,
|
|
|
|
TCG_COND_LTU,
|
|
|
|
-1, /* neg */
|
|
|
|
-1, /* overflow */
|
2012-10-09 23:49:58 +02:00
|
|
|
TCG_COND_ALWAYS,
|
2012-10-06 01:55:10 +02:00
|
|
|
TCG_COND_NE,
|
|
|
|
TCG_COND_GT,
|
|
|
|
TCG_COND_GE,
|
|
|
|
TCG_COND_GTU,
|
|
|
|
TCG_COND_GEU,
|
|
|
|
-1, /* pos */
|
|
|
|
-1, /* no overflow */
|
|
|
|
};
|
|
|
|
|
2012-10-09 23:49:58 +02:00
|
|
|
static int logic_cond[16] = {
|
|
|
|
TCG_COND_NEVER,
|
|
|
|
TCG_COND_EQ, /* eq: Z */
|
|
|
|
TCG_COND_LE, /* le: Z | (N ^ V) -> Z | N */
|
|
|
|
TCG_COND_LT, /* lt: N ^ V -> N */
|
|
|
|
TCG_COND_EQ, /* leu: C | Z -> Z */
|
|
|
|
TCG_COND_NEVER, /* ltu: C -> 0 */
|
|
|
|
TCG_COND_LT, /* neg: N */
|
|
|
|
TCG_COND_NEVER, /* vs: V -> 0 */
|
|
|
|
TCG_COND_ALWAYS,
|
|
|
|
TCG_COND_NE, /* ne: !Z */
|
|
|
|
TCG_COND_GT, /* gt: !(Z | (N ^ V)) -> !(Z | N) */
|
|
|
|
TCG_COND_GE, /* ge: !(N ^ V) -> !N */
|
|
|
|
TCG_COND_NE, /* gtu: !(C | Z) -> !Z */
|
|
|
|
TCG_COND_ALWAYS, /* geu: !C -> 1 */
|
|
|
|
TCG_COND_GE, /* pos: !N */
|
|
|
|
TCG_COND_ALWAYS, /* vc: !V -> 1 */
|
|
|
|
};
|
|
|
|
|
2008-11-17 15:43:54 +01:00
|
|
|
TCGv_i32 r_src;
|
2012-10-06 01:54:57 +02:00
|
|
|
TCGv r_dst;
|
|
|
|
|
2005-07-02 16:31:34 +02:00
|
|
|
#ifdef TARGET_SPARC64
|
2012-10-06 01:55:10 +02:00
|
|
|
if (xcc) {
|
2008-03-13 21:45:31 +01:00
|
|
|
r_src = cpu_xcc;
|
2012-10-06 01:55:10 +02:00
|
|
|
} else {
|
2008-03-13 21:45:31 +01:00
|
|
|
r_src = cpu_psr;
|
2012-10-06 01:55:10 +02:00
|
|
|
}
|
2005-07-02 16:31:34 +02:00
|
|
|
#else
|
2008-03-13 21:45:31 +01:00
|
|
|
r_src = cpu_psr;
|
2005-07-02 16:31:34 +02:00
|
|
|
#endif
|
2012-10-06 01:55:10 +02:00
|
|
|
|
2009-05-10 09:19:11 +02:00
|
|
|
switch (dc->cc_op) {
|
2012-10-09 23:49:58 +02:00
|
|
|
case CC_OP_LOGIC:
|
|
|
|
cmp->cond = logic_cond[cond];
|
|
|
|
do_compare_dst_0:
|
|
|
|
cmp->is_bool = false;
|
2023-02-26 22:15:00 +01:00
|
|
|
cmp->c2 = tcg_constant_tl(0);
|
2012-10-09 23:49:58 +02:00
|
|
|
#ifdef TARGET_SPARC64
|
|
|
|
if (!xcc) {
|
|
|
|
cmp->c1 = tcg_temp_new();
|
|
|
|
tcg_gen_ext32s_tl(cmp->c1, cpu_cc_dst);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
cmp->c1 = cpu_cc_dst;
|
|
|
|
break;
|
|
|
|
|
2012-10-06 01:55:10 +02:00
|
|
|
case CC_OP_SUB:
|
|
|
|
switch (cond) {
|
|
|
|
case 6: /* neg */
|
|
|
|
case 14: /* pos */
|
|
|
|
cmp->cond = (cond == 6 ? TCG_COND_LT : TCG_COND_GE);
|
2012-10-09 23:49:58 +02:00
|
|
|
goto do_compare_dst_0;
|
2012-10-06 01:55:10 +02:00
|
|
|
|
|
|
|
case 7: /* overflow */
|
|
|
|
case 15: /* !overflow */
|
|
|
|
goto do_dynamic;
|
|
|
|
|
|
|
|
default:
|
|
|
|
cmp->cond = subcc_cond[cond];
|
|
|
|
cmp->is_bool = false;
|
|
|
|
#ifdef TARGET_SPARC64
|
|
|
|
if (!xcc) {
|
|
|
|
/* Note that sign-extension works for unsigned compares as
|
|
|
|
long as both operands are sign-extended. */
|
|
|
|
cmp->c1 = tcg_temp_new();
|
|
|
|
cmp->c2 = tcg_temp_new();
|
|
|
|
tcg_gen_ext32s_tl(cmp->c1, cpu_cc_src);
|
|
|
|
tcg_gen_ext32s_tl(cmp->c2, cpu_cc_src2);
|
2012-10-09 23:49:57 +02:00
|
|
|
break;
|
2012-10-06 01:55:10 +02:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
cmp->c1 = cpu_cc_src;
|
|
|
|
cmp->c2 = cpu_cc_src2;
|
|
|
|
break;
|
|
|
|
}
|
2009-05-10 09:19:11 +02:00
|
|
|
break;
|
2012-10-06 01:55:10 +02:00
|
|
|
|
2009-05-10 09:19:11 +02:00
|
|
|
default:
|
2012-10-06 01:55:10 +02:00
|
|
|
do_dynamic:
|
2011-07-03 18:01:57 +02:00
|
|
|
gen_helper_compute_psr(cpu_env);
|
2009-05-10 09:19:11 +02:00
|
|
|
dc->cc_op = CC_OP_FLAGS;
|
2012-10-06 01:55:10 +02:00
|
|
|
/* FALLTHRU */
|
|
|
|
|
|
|
|
case CC_OP_FLAGS:
|
|
|
|
/* We're going to generate a boolean result. */
|
|
|
|
cmp->cond = TCG_COND_NE;
|
|
|
|
cmp->is_bool = true;
|
|
|
|
cmp->c1 = r_dst = tcg_temp_new();
|
2023-02-26 22:15:00 +01:00
|
|
|
cmp->c2 = tcg_constant_tl(0);
|
2012-10-06 01:55:10 +02:00
|
|
|
|
|
|
|
switch (cond) {
|
|
|
|
case 0x0:
|
|
|
|
gen_op_eval_bn(r_dst);
|
|
|
|
break;
|
|
|
|
case 0x1:
|
|
|
|
gen_op_eval_be(r_dst, r_src);
|
|
|
|
break;
|
|
|
|
case 0x2:
|
|
|
|
gen_op_eval_ble(r_dst, r_src);
|
|
|
|
break;
|
|
|
|
case 0x3:
|
|
|
|
gen_op_eval_bl(r_dst, r_src);
|
|
|
|
break;
|
|
|
|
case 0x4:
|
|
|
|
gen_op_eval_bleu(r_dst, r_src);
|
|
|
|
break;
|
|
|
|
case 0x5:
|
|
|
|
gen_op_eval_bcs(r_dst, r_src);
|
|
|
|
break;
|
|
|
|
case 0x6:
|
|
|
|
gen_op_eval_bneg(r_dst, r_src);
|
|
|
|
break;
|
|
|
|
case 0x7:
|
|
|
|
gen_op_eval_bvs(r_dst, r_src);
|
|
|
|
break;
|
|
|
|
case 0x8:
|
|
|
|
gen_op_eval_ba(r_dst);
|
|
|
|
break;
|
|
|
|
case 0x9:
|
|
|
|
gen_op_eval_bne(r_dst, r_src);
|
|
|
|
break;
|
|
|
|
case 0xa:
|
|
|
|
gen_op_eval_bg(r_dst, r_src);
|
|
|
|
break;
|
|
|
|
case 0xb:
|
|
|
|
gen_op_eval_bge(r_dst, r_src);
|
|
|
|
break;
|
|
|
|
case 0xc:
|
|
|
|
gen_op_eval_bgu(r_dst, r_src);
|
|
|
|
break;
|
|
|
|
case 0xd:
|
|
|
|
gen_op_eval_bcc(r_dst, r_src);
|
|
|
|
break;
|
|
|
|
case 0xe:
|
|
|
|
gen_op_eval_bpos(r_dst, r_src);
|
|
|
|
break;
|
|
|
|
case 0xf:
|
|
|
|
gen_op_eval_bvc(r_dst, r_src);
|
|
|
|
break;
|
|
|
|
}
|
2008-03-08 22:36:50 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2003-09-30 22:36:07 +02:00
|
|
|
|
2012-10-06 01:54:57 +02:00
|
|
|
static void gen_fcompare(DisasCompare *cmp, unsigned int cc, unsigned int cond)
|
2004-09-30 23:55:55 +02:00
|
|
|
{
|
2008-03-08 22:36:50 +01:00
|
|
|
unsigned int offset;
|
2012-10-06 01:54:57 +02:00
|
|
|
TCGv r_dst;
|
|
|
|
|
|
|
|
/* For now we still generate a straight boolean result. */
|
|
|
|
cmp->cond = TCG_COND_NE;
|
|
|
|
cmp->is_bool = true;
|
|
|
|
cmp->c1 = r_dst = tcg_temp_new();
|
2023-02-26 22:15:00 +01:00
|
|
|
cmp->c2 = tcg_constant_tl(0);
|
2008-03-08 22:36:50 +01:00
|
|
|
|
|
|
|
switch (cc) {
|
|
|
|
default:
|
|
|
|
case 0x0:
|
|
|
|
offset = 0;
|
|
|
|
break;
|
|
|
|
case 0x1:
|
|
|
|
offset = 32 - 10;
|
|
|
|
break;
|
|
|
|
case 0x2:
|
|
|
|
offset = 34 - 10;
|
|
|
|
break;
|
|
|
|
case 0x3:
|
|
|
|
offset = 36 - 10;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (cond) {
|
|
|
|
case 0x0:
|
|
|
|
gen_op_eval_bn(r_dst);
|
|
|
|
break;
|
|
|
|
case 0x1:
|
2008-03-15 19:12:11 +01:00
|
|
|
gen_op_eval_fbne(r_dst, cpu_fsr, offset);
|
2008-03-08 22:36:50 +01:00
|
|
|
break;
|
|
|
|
case 0x2:
|
2008-03-15 19:12:11 +01:00
|
|
|
gen_op_eval_fblg(r_dst, cpu_fsr, offset);
|
2008-03-08 22:36:50 +01:00
|
|
|
break;
|
|
|
|
case 0x3:
|
2008-03-15 19:12:11 +01:00
|
|
|
gen_op_eval_fbul(r_dst, cpu_fsr, offset);
|
2008-03-08 22:36:50 +01:00
|
|
|
break;
|
|
|
|
case 0x4:
|
2008-03-15 19:12:11 +01:00
|
|
|
gen_op_eval_fbl(r_dst, cpu_fsr, offset);
|
2008-03-08 22:36:50 +01:00
|
|
|
break;
|
|
|
|
case 0x5:
|
2008-03-15 19:12:11 +01:00
|
|
|
gen_op_eval_fbug(r_dst, cpu_fsr, offset);
|
2008-03-08 22:36:50 +01:00
|
|
|
break;
|
|
|
|
case 0x6:
|
2008-03-15 19:12:11 +01:00
|
|
|
gen_op_eval_fbg(r_dst, cpu_fsr, offset);
|
2008-03-08 22:36:50 +01:00
|
|
|
break;
|
|
|
|
case 0x7:
|
2008-03-15 19:12:11 +01:00
|
|
|
gen_op_eval_fbu(r_dst, cpu_fsr, offset);
|
2008-03-08 22:36:50 +01:00
|
|
|
break;
|
|
|
|
case 0x8:
|
|
|
|
gen_op_eval_ba(r_dst);
|
|
|
|
break;
|
|
|
|
case 0x9:
|
2008-03-15 19:12:11 +01:00
|
|
|
gen_op_eval_fbe(r_dst, cpu_fsr, offset);
|
2008-03-08 22:36:50 +01:00
|
|
|
break;
|
|
|
|
case 0xa:
|
2008-03-15 19:12:11 +01:00
|
|
|
gen_op_eval_fbue(r_dst, cpu_fsr, offset);
|
2008-03-08 22:36:50 +01:00
|
|
|
break;
|
|
|
|
case 0xb:
|
2008-03-15 19:12:11 +01:00
|
|
|
gen_op_eval_fbge(r_dst, cpu_fsr, offset);
|
2008-03-08 22:36:50 +01:00
|
|
|
break;
|
|
|
|
case 0xc:
|
2008-03-15 19:12:11 +01:00
|
|
|
gen_op_eval_fbuge(r_dst, cpu_fsr, offset);
|
2008-03-08 22:36:50 +01:00
|
|
|
break;
|
|
|
|
case 0xd:
|
2008-03-15 19:12:11 +01:00
|
|
|
gen_op_eval_fble(r_dst, cpu_fsr, offset);
|
2008-03-08 22:36:50 +01:00
|
|
|
break;
|
|
|
|
case 0xe:
|
2008-03-15 19:12:11 +01:00
|
|
|
gen_op_eval_fbule(r_dst, cpu_fsr, offset);
|
2008-03-08 22:36:50 +01:00
|
|
|
break;
|
|
|
|
case 0xf:
|
2008-03-15 19:12:11 +01:00
|
|
|
gen_op_eval_fbo(r_dst, cpu_fsr, offset);
|
2008-03-08 22:36:50 +01:00
|
|
|
break;
|
|
|
|
}
|
2004-09-30 23:55:55 +02:00
|
|
|
}
|
2008-03-02 19:25:27 +01:00
|
|
|
|
2012-10-06 01:54:57 +02:00
|
|
|
static void gen_cond(TCGv r_dst, unsigned int cc, unsigned int cond,
|
|
|
|
DisasContext *dc)
|
|
|
|
{
|
|
|
|
DisasCompare cmp;
|
|
|
|
gen_compare(&cmp, cc, cond, dc);
|
|
|
|
|
|
|
|
/* The interface is to return a boolean in r_dst. */
|
|
|
|
if (cmp.is_bool) {
|
|
|
|
tcg_gen_mov_tl(r_dst, cmp.c1);
|
|
|
|
} else {
|
|
|
|
tcg_gen_setcond_tl(cmp.cond, r_dst, cmp.c1, cmp.c2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void gen_fcond(TCGv r_dst, unsigned int cc, unsigned int cond)
|
|
|
|
{
|
|
|
|
DisasCompare cmp;
|
|
|
|
gen_fcompare(&cmp, cc, cond);
|
|
|
|
|
|
|
|
/* The interface is to return a boolean in r_dst. */
|
|
|
|
if (cmp.is_bool) {
|
|
|
|
tcg_gen_mov_tl(r_dst, cmp.c1);
|
|
|
|
} else {
|
|
|
|
tcg_gen_setcond_tl(cmp.cond, r_dst, cmp.c1, cmp.c2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-03-08 22:36:50 +01:00
|
|
|
#ifdef TARGET_SPARC64
|
2008-03-02 19:25:27 +01:00
|
|
|
// Inverted logic
|
|
|
|
static const int gen_tcg_cond_reg[8] = {
|
|
|
|
-1,
|
|
|
|
TCG_COND_NE,
|
|
|
|
TCG_COND_GT,
|
|
|
|
TCG_COND_GE,
|
|
|
|
-1,
|
|
|
|
TCG_COND_EQ,
|
|
|
|
TCG_COND_LE,
|
|
|
|
TCG_COND_LT,
|
|
|
|
};
|
2008-03-08 22:36:50 +01:00
|
|
|
|
2012-10-06 01:54:57 +02:00
|
|
|
static void gen_compare_reg(DisasCompare *cmp, int cond, TCGv r_src)
|
|
|
|
{
|
|
|
|
cmp->cond = tcg_invert_cond(gen_tcg_cond_reg[cond]);
|
|
|
|
cmp->is_bool = false;
|
|
|
|
cmp->c1 = r_src;
|
2023-02-26 22:15:00 +01:00
|
|
|
cmp->c2 = tcg_constant_tl(0);
|
2012-10-06 01:54:57 +02:00
|
|
|
}
|
|
|
|
|
2008-03-26 21:47:52 +01:00
|
|
|
static inline void gen_cond_reg(TCGv r_dst, int cond, TCGv r_src)
|
2008-03-08 22:36:50 +01:00
|
|
|
{
|
2012-10-06 01:54:57 +02:00
|
|
|
DisasCompare cmp;
|
|
|
|
gen_compare_reg(&cmp, cond, r_src);
|
2008-03-08 22:36:50 +01:00
|
|
|
|
2012-10-06 01:54:57 +02:00
|
|
|
/* The interface is to return a boolean in r_dst. */
|
|
|
|
tcg_gen_setcond_tl(cmp.cond, r_dst, cmp.c1, cmp.c2);
|
2008-03-08 22:36:50 +01:00
|
|
|
}
|
2005-07-02 16:31:34 +02:00
|
|
|
#endif
|
2004-01-04 16:01:44 +01:00
|
|
|
|
2012-10-06 01:54:50 +02:00
|
|
|
static void do_branch(DisasContext *dc, int32_t offset, uint32_t insn, int cc)
|
2003-09-30 22:36:07 +02:00
|
|
|
{
|
2004-01-04 16:01:44 +01:00
|
|
|
unsigned int cond = GET_FIELD(insn, 3, 6), a = (insn & (1 << 29));
|
2005-01-30 23:39:04 +01:00
|
|
|
target_ulong target = dc->pc + offset;
|
2007-09-16 23:08:06 +02:00
|
|
|
|
2012-05-12 11:15:20 +02:00
|
|
|
#ifdef TARGET_SPARC64
|
|
|
|
if (unlikely(AM_CHECK(dc))) {
|
|
|
|
target &= 0xffffffffULL;
|
|
|
|
}
|
|
|
|
#endif
|
2004-01-04 16:01:44 +01:00
|
|
|
if (cond == 0x0) {
|
2007-09-20 16:54:22 +02:00
|
|
|
/* unconditional not taken */
|
|
|
|
if (a) {
|
|
|
|
dc->pc = dc->npc + 4;
|
|
|
|
dc->npc = dc->pc + 4;
|
|
|
|
} else {
|
|
|
|
dc->pc = dc->npc;
|
|
|
|
dc->npc = dc->pc + 4;
|
|
|
|
}
|
2004-01-04 16:01:44 +01:00
|
|
|
} else if (cond == 0x8) {
|
2007-09-20 16:54:22 +02:00
|
|
|
/* unconditional taken */
|
|
|
|
if (a) {
|
|
|
|
dc->pc = target;
|
|
|
|
dc->npc = dc->pc + 4;
|
|
|
|
} else {
|
|
|
|
dc->pc = dc->npc;
|
|
|
|
dc->npc = target;
|
2009-08-22 13:46:10 +02:00
|
|
|
tcg_gen_mov_tl(cpu_pc, cpu_npc);
|
2007-09-20 16:54:22 +02:00
|
|
|
}
|
2004-01-04 16:01:44 +01:00
|
|
|
} else {
|
2012-10-06 01:54:51 +02:00
|
|
|
flush_cond(dc);
|
2012-10-06 01:54:50 +02:00
|
|
|
gen_cond(cpu_cond, cc, cond, dc);
|
2007-09-20 16:54:22 +02:00
|
|
|
if (a) {
|
2015-08-31 21:44:16 +02:00
|
|
|
gen_branch_a(dc, target);
|
2007-09-20 16:54:22 +02:00
|
|
|
} else {
|
2015-08-31 22:01:47 +02:00
|
|
|
gen_branch_n(dc, target);
|
2007-09-20 16:54:22 +02:00
|
|
|
}
|
2004-01-04 16:01:44 +01:00
|
|
|
}
|
2003-09-30 22:36:07 +02:00
|
|
|
}
|
|
|
|
|
2012-10-06 01:54:50 +02:00
|
|
|
static void do_fbranch(DisasContext *dc, int32_t offset, uint32_t insn, int cc)
|
2004-09-30 23:55:55 +02:00
|
|
|
{
|
|
|
|
unsigned int cond = GET_FIELD(insn, 3, 6), a = (insn & (1 << 29));
|
2005-01-30 23:39:04 +01:00
|
|
|
target_ulong target = dc->pc + offset;
|
|
|
|
|
2012-05-12 11:15:20 +02:00
|
|
|
#ifdef TARGET_SPARC64
|
|
|
|
if (unlikely(AM_CHECK(dc))) {
|
|
|
|
target &= 0xffffffffULL;
|
|
|
|
}
|
|
|
|
#endif
|
2004-09-30 23:55:55 +02:00
|
|
|
if (cond == 0x0) {
|
2007-09-20 16:54:22 +02:00
|
|
|
/* unconditional not taken */
|
|
|
|
if (a) {
|
|
|
|
dc->pc = dc->npc + 4;
|
|
|
|
dc->npc = dc->pc + 4;
|
|
|
|
} else {
|
|
|
|
dc->pc = dc->npc;
|
|
|
|
dc->npc = dc->pc + 4;
|
|
|
|
}
|
2004-09-30 23:55:55 +02:00
|
|
|
} else if (cond == 0x8) {
|
2007-09-20 16:54:22 +02:00
|
|
|
/* unconditional taken */
|
|
|
|
if (a) {
|
|
|
|
dc->pc = target;
|
|
|
|
dc->npc = dc->pc + 4;
|
|
|
|
} else {
|
|
|
|
dc->pc = dc->npc;
|
|
|
|
dc->npc = target;
|
2009-08-22 13:46:10 +02:00
|
|
|
tcg_gen_mov_tl(cpu_pc, cpu_npc);
|
2007-09-20 16:54:22 +02:00
|
|
|
}
|
2004-09-30 23:55:55 +02:00
|
|
|
} else {
|
2012-10-06 01:54:51 +02:00
|
|
|
flush_cond(dc);
|
2012-10-06 01:54:50 +02:00
|
|
|
gen_fcond(cpu_cond, cc, cond);
|
2007-09-20 16:54:22 +02:00
|
|
|
if (a) {
|
2015-08-31 21:44:16 +02:00
|
|
|
gen_branch_a(dc, target);
|
2007-09-20 16:54:22 +02:00
|
|
|
} else {
|
2015-08-31 22:01:47 +02:00
|
|
|
gen_branch_n(dc, target);
|
2007-09-20 16:54:22 +02:00
|
|
|
}
|
2004-09-30 23:55:55 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-07-02 16:31:34 +02:00
|
|
|
#ifdef TARGET_SPARC64
|
2008-03-26 21:47:52 +01:00
|
|
|
static void do_branch_reg(DisasContext *dc, int32_t offset, uint32_t insn,
|
2012-10-06 01:54:50 +02:00
|
|
|
TCGv r_reg)
|
2003-09-30 22:36:07 +02:00
|
|
|
{
|
2005-07-02 16:31:34 +02:00
|
|
|
unsigned int cond = GET_FIELD_SP(insn, 25, 27), a = (insn & (1 << 29));
|
|
|
|
target_ulong target = dc->pc + offset;
|
|
|
|
|
2012-05-12 11:15:20 +02:00
|
|
|
if (unlikely(AM_CHECK(dc))) {
|
|
|
|
target &= 0xffffffffULL;
|
|
|
|
}
|
2012-10-06 01:54:51 +02:00
|
|
|
flush_cond(dc);
|
2012-10-06 01:54:50 +02:00
|
|
|
gen_cond_reg(cpu_cond, cond, r_reg);
|
2005-07-02 16:31:34 +02:00
|
|
|
if (a) {
|
2015-08-31 21:44:16 +02:00
|
|
|
gen_branch_a(dc, target);
|
2005-07-02 16:31:34 +02:00
|
|
|
} else {
|
2015-08-31 22:01:47 +02:00
|
|
|
gen_branch_n(dc, target);
|
2005-07-02 16:31:34 +02:00
|
|
|
}
|
2003-09-30 22:36:07 +02:00
|
|
|
}
|
|
|
|
|
2008-11-17 15:43:54 +01:00
|
|
|
static inline void gen_op_fcmps(int fccno, TCGv_i32 r_rs1, TCGv_i32 r_rs2)
|
2008-03-04 21:00:18 +01:00
|
|
|
{
|
2008-09-10 21:54:51 +02:00
|
|
|
switch (fccno) {
|
|
|
|
case 0:
|
2015-09-09 20:11:36 +02:00
|
|
|
gen_helper_fcmps(cpu_fsr, cpu_env, r_rs1, r_rs2);
|
2008-09-10 21:54:51 +02:00
|
|
|
break;
|
|
|
|
case 1:
|
2015-09-09 20:11:36 +02:00
|
|
|
gen_helper_fcmps_fcc1(cpu_fsr, cpu_env, r_rs1, r_rs2);
|
2008-09-10 21:54:51 +02:00
|
|
|
break;
|
|
|
|
case 2:
|
2015-09-09 20:11:36 +02:00
|
|
|
gen_helper_fcmps_fcc2(cpu_fsr, cpu_env, r_rs1, r_rs2);
|
2008-09-10 21:54:51 +02:00
|
|
|
break;
|
|
|
|
case 3:
|
2015-09-09 20:11:36 +02:00
|
|
|
gen_helper_fcmps_fcc3(cpu_fsr, cpu_env, r_rs1, r_rs2);
|
2008-09-10 21:54:51 +02:00
|
|
|
break;
|
|
|
|
}
|
2008-03-04 21:00:18 +01:00
|
|
|
}
|
|
|
|
|
2011-10-15 19:20:20 +02:00
|
|
|
static inline void gen_op_fcmpd(int fccno, TCGv_i64 r_rs1, TCGv_i64 r_rs2)
|
2008-03-04 21:00:18 +01:00
|
|
|
{
|
2008-11-17 15:43:54 +01:00
|
|
|
switch (fccno) {
|
|
|
|
case 0:
|
2015-09-09 20:11:36 +02:00
|
|
|
gen_helper_fcmpd(cpu_fsr, cpu_env, r_rs1, r_rs2);
|
2008-11-17 15:43:54 +01:00
|
|
|
break;
|
|
|
|
case 1:
|
2015-09-09 20:11:36 +02:00
|
|
|
gen_helper_fcmpd_fcc1(cpu_fsr, cpu_env, r_rs1, r_rs2);
|
2008-11-17 15:43:54 +01:00
|
|
|
break;
|
|
|
|
case 2:
|
2015-09-09 20:11:36 +02:00
|
|
|
gen_helper_fcmpd_fcc2(cpu_fsr, cpu_env, r_rs1, r_rs2);
|
2008-11-17 15:43:54 +01:00
|
|
|
break;
|
|
|
|
case 3:
|
2015-09-09 20:11:36 +02:00
|
|
|
gen_helper_fcmpd_fcc3(cpu_fsr, cpu_env, r_rs1, r_rs2);
|
2008-11-17 15:43:54 +01:00
|
|
|
break;
|
|
|
|
}
|
2008-03-04 21:00:18 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline void gen_op_fcmpq(int fccno)
|
|
|
|
{
|
2008-11-17 15:43:54 +01:00
|
|
|
switch (fccno) {
|
|
|
|
case 0:
|
2015-09-09 20:11:36 +02:00
|
|
|
gen_helper_fcmpq(cpu_fsr, cpu_env);
|
2008-11-17 15:43:54 +01:00
|
|
|
break;
|
|
|
|
case 1:
|
2015-09-09 20:11:36 +02:00
|
|
|
gen_helper_fcmpq_fcc1(cpu_fsr, cpu_env);
|
2008-11-17 15:43:54 +01:00
|
|
|
break;
|
|
|
|
case 2:
|
2015-09-09 20:11:36 +02:00
|
|
|
gen_helper_fcmpq_fcc2(cpu_fsr, cpu_env);
|
2008-11-17 15:43:54 +01:00
|
|
|
break;
|
|
|
|
case 3:
|
2015-09-09 20:11:36 +02:00
|
|
|
gen_helper_fcmpq_fcc3(cpu_fsr, cpu_env);
|
2008-11-17 15:43:54 +01:00
|
|
|
break;
|
|
|
|
}
|
2008-03-04 21:00:18 +01:00
|
|
|
}
|
|
|
|
|
2008-11-17 15:43:54 +01:00
|
|
|
static inline void gen_op_fcmpes(int fccno, TCGv_i32 r_rs1, TCGv_i32 r_rs2)
|
2008-03-04 21:00:18 +01:00
|
|
|
{
|
2008-09-10 21:54:51 +02:00
|
|
|
switch (fccno) {
|
|
|
|
case 0:
|
2015-09-09 20:11:36 +02:00
|
|
|
gen_helper_fcmpes(cpu_fsr, cpu_env, r_rs1, r_rs2);
|
2008-09-10 21:54:51 +02:00
|
|
|
break;
|
|
|
|
case 1:
|
2015-09-09 20:11:36 +02:00
|
|
|
gen_helper_fcmpes_fcc1(cpu_fsr, cpu_env, r_rs1, r_rs2);
|
2008-09-10 21:54:51 +02:00
|
|
|
break;
|
|
|
|
case 2:
|
2015-09-09 20:11:36 +02:00
|
|
|
gen_helper_fcmpes_fcc2(cpu_fsr, cpu_env, r_rs1, r_rs2);
|
2008-09-10 21:54:51 +02:00
|
|
|
break;
|
|
|
|
case 3:
|
2015-09-09 20:11:36 +02:00
|
|
|
gen_helper_fcmpes_fcc3(cpu_fsr, cpu_env, r_rs1, r_rs2);
|
2008-09-10 21:54:51 +02:00
|
|
|
break;
|
|
|
|
}
|
2008-03-04 21:00:18 +01:00
|
|
|
}
|
|
|
|
|
2011-10-15 19:20:20 +02:00
|
|
|
static inline void gen_op_fcmped(int fccno, TCGv_i64 r_rs1, TCGv_i64 r_rs2)
|
2008-03-04 21:00:18 +01:00
|
|
|
{
|
2008-11-17 15:43:54 +01:00
|
|
|
switch (fccno) {
|
|
|
|
case 0:
|
2015-09-09 20:11:36 +02:00
|
|
|
gen_helper_fcmped(cpu_fsr, cpu_env, r_rs1, r_rs2);
|
2008-11-17 15:43:54 +01:00
|
|
|
break;
|
|
|
|
case 1:
|
2015-09-09 20:11:36 +02:00
|
|
|
gen_helper_fcmped_fcc1(cpu_fsr, cpu_env, r_rs1, r_rs2);
|
2008-11-17 15:43:54 +01:00
|
|
|
break;
|
|
|
|
case 2:
|
2015-09-09 20:11:36 +02:00
|
|
|
gen_helper_fcmped_fcc2(cpu_fsr, cpu_env, r_rs1, r_rs2);
|
2008-11-17 15:43:54 +01:00
|
|
|
break;
|
|
|
|
case 3:
|
2015-09-09 20:11:36 +02:00
|
|
|
gen_helper_fcmped_fcc3(cpu_fsr, cpu_env, r_rs1, r_rs2);
|
2008-11-17 15:43:54 +01:00
|
|
|
break;
|
|
|
|
}
|
2008-03-04 21:00:18 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline void gen_op_fcmpeq(int fccno)
|
|
|
|
{
|
2008-11-17 15:43:54 +01:00
|
|
|
switch (fccno) {
|
|
|
|
case 0:
|
2015-09-09 20:11:36 +02:00
|
|
|
gen_helper_fcmpeq(cpu_fsr, cpu_env);
|
2008-11-17 15:43:54 +01:00
|
|
|
break;
|
|
|
|
case 1:
|
2015-09-09 20:11:36 +02:00
|
|
|
gen_helper_fcmpeq_fcc1(cpu_fsr, cpu_env);
|
2008-11-17 15:43:54 +01:00
|
|
|
break;
|
|
|
|
case 2:
|
2015-09-09 20:11:36 +02:00
|
|
|
gen_helper_fcmpeq_fcc2(cpu_fsr, cpu_env);
|
2008-11-17 15:43:54 +01:00
|
|
|
break;
|
|
|
|
case 3:
|
2015-09-09 20:11:36 +02:00
|
|
|
gen_helper_fcmpeq_fcc3(cpu_fsr, cpu_env);
|
2008-11-17 15:43:54 +01:00
|
|
|
break;
|
|
|
|
}
|
2008-03-04 21:00:18 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
2008-09-10 21:54:51 +02:00
|
|
|
static inline void gen_op_fcmps(int fccno, TCGv r_rs1, TCGv r_rs2)
|
2008-03-04 21:00:18 +01:00
|
|
|
{
|
2015-09-09 20:11:36 +02:00
|
|
|
gen_helper_fcmps(cpu_fsr, cpu_env, r_rs1, r_rs2);
|
2008-03-04 21:00:18 +01:00
|
|
|
}
|
|
|
|
|
2011-10-15 19:20:20 +02:00
|
|
|
static inline void gen_op_fcmpd(int fccno, TCGv_i64 r_rs1, TCGv_i64 r_rs2)
|
2008-03-04 21:00:18 +01:00
|
|
|
{
|
2015-09-09 20:11:36 +02:00
|
|
|
gen_helper_fcmpd(cpu_fsr, cpu_env, r_rs1, r_rs2);
|
2008-03-04 21:00:18 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline void gen_op_fcmpq(int fccno)
|
|
|
|
{
|
2015-09-09 20:11:36 +02:00
|
|
|
gen_helper_fcmpq(cpu_fsr, cpu_env);
|
2008-03-04 21:00:18 +01:00
|
|
|
}
|
|
|
|
|
2008-09-10 21:54:51 +02:00
|
|
|
static inline void gen_op_fcmpes(int fccno, TCGv r_rs1, TCGv r_rs2)
|
2008-03-04 21:00:18 +01:00
|
|
|
{
|
2015-09-09 20:11:36 +02:00
|
|
|
gen_helper_fcmpes(cpu_fsr, cpu_env, r_rs1, r_rs2);
|
2008-03-04 21:00:18 +01:00
|
|
|
}
|
|
|
|
|
2011-10-15 19:20:20 +02:00
|
|
|
static inline void gen_op_fcmped(int fccno, TCGv_i64 r_rs1, TCGv_i64 r_rs2)
|
2008-03-04 21:00:18 +01:00
|
|
|
{
|
2015-09-09 20:11:36 +02:00
|
|
|
gen_helper_fcmped(cpu_fsr, cpu_env, r_rs1, r_rs2);
|
2008-03-04 21:00:18 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline void gen_op_fcmpeq(int fccno)
|
|
|
|
{
|
2015-09-09 20:11:36 +02:00
|
|
|
gen_helper_fcmpeq(cpu_fsr, cpu_env);
|
2008-03-04 21:00:18 +01:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2015-09-03 05:00:29 +02:00
|
|
|
static void gen_op_fpexception_im(DisasContext *dc, int fsr_flags)
|
2008-03-06 21:09:54 +01:00
|
|
|
{
|
2008-09-06 19:50:16 +02:00
|
|
|
tcg_gen_andi_tl(cpu_fsr, cpu_fsr, FSR_FTT_NMASK);
|
2008-03-15 19:12:11 +01:00
|
|
|
tcg_gen_ori_tl(cpu_fsr, cpu_fsr, fsr_flags);
|
2015-09-03 05:00:29 +02:00
|
|
|
gen_exception(dc, TT_FP_EXCP);
|
2008-03-06 21:09:54 +01:00
|
|
|
}
|
|
|
|
|
2012-10-06 01:54:52 +02:00
|
|
|
static int gen_trap_ifnofpu(DisasContext *dc)
|
2006-06-26 21:53:29 +02:00
|
|
|
{
|
|
|
|
#if !defined(CONFIG_USER_ONLY)
|
|
|
|
if (!dc->fpu_enabled) {
|
2015-09-03 05:00:29 +02:00
|
|
|
gen_exception(dc, TT_NFPU_INSN);
|
2006-06-26 21:53:29 +02:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-03-04 21:00:18 +01:00
|
|
|
static inline void gen_op_clear_ieee_excp_and_FTT(void)
|
|
|
|
{
|
2008-09-06 19:50:16 +02:00
|
|
|
tcg_gen_andi_tl(cpu_fsr, cpu_fsr, FSR_FTT_CEXC_NMASK);
|
2008-03-04 21:00:18 +01:00
|
|
|
}
|
|
|
|
|
2011-10-15 20:52:00 +02:00
|
|
|
static inline void gen_fop_FF(DisasContext *dc, int rd, int rs,
|
|
|
|
void (*gen)(TCGv_i32, TCGv_ptr, TCGv_i32))
|
|
|
|
{
|
|
|
|
TCGv_i32 dst, src;
|
|
|
|
|
|
|
|
src = gen_load_fpr_F(dc, rs);
|
2012-10-16 11:32:21 +02:00
|
|
|
dst = gen_dest_fpr_F(dc);
|
2011-10-15 20:52:00 +02:00
|
|
|
|
|
|
|
gen(dst, cpu_env, src);
|
2015-09-09 20:11:36 +02:00
|
|
|
gen_helper_check_ieee_exceptions(cpu_fsr, cpu_env);
|
2011-10-15 20:52:00 +02:00
|
|
|
|
|
|
|
gen_store_fpr_F(dc, rd, dst);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void gen_ne_fop_FF(DisasContext *dc, int rd, int rs,
|
|
|
|
void (*gen)(TCGv_i32, TCGv_i32))
|
|
|
|
{
|
|
|
|
TCGv_i32 dst, src;
|
|
|
|
|
|
|
|
src = gen_load_fpr_F(dc, rs);
|
2012-10-16 11:32:21 +02:00
|
|
|
dst = gen_dest_fpr_F(dc);
|
2011-10-15 20:52:00 +02:00
|
|
|
|
|
|
|
gen(dst, src);
|
|
|
|
|
|
|
|
gen_store_fpr_F(dc, rd, dst);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void gen_fop_FFF(DisasContext *dc, int rd, int rs1, int rs2,
|
|
|
|
void (*gen)(TCGv_i32, TCGv_ptr, TCGv_i32, TCGv_i32))
|
|
|
|
{
|
|
|
|
TCGv_i32 dst, src1, src2;
|
|
|
|
|
|
|
|
src1 = gen_load_fpr_F(dc, rs1);
|
|
|
|
src2 = gen_load_fpr_F(dc, rs2);
|
2012-10-16 11:32:21 +02:00
|
|
|
dst = gen_dest_fpr_F(dc);
|
2011-10-15 20:52:00 +02:00
|
|
|
|
|
|
|
gen(dst, cpu_env, src1, src2);
|
2015-09-09 20:11:36 +02:00
|
|
|
gen_helper_check_ieee_exceptions(cpu_fsr, cpu_env);
|
2011-10-15 20:52:00 +02:00
|
|
|
|
|
|
|
gen_store_fpr_F(dc, rd, dst);
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef TARGET_SPARC64
|
|
|
|
static inline void gen_ne_fop_FFF(DisasContext *dc, int rd, int rs1, int rs2,
|
|
|
|
void (*gen)(TCGv_i32, TCGv_i32, TCGv_i32))
|
|
|
|
{
|
|
|
|
TCGv_i32 dst, src1, src2;
|
|
|
|
|
|
|
|
src1 = gen_load_fpr_F(dc, rs1);
|
|
|
|
src2 = gen_load_fpr_F(dc, rs2);
|
2012-10-16 11:32:21 +02:00
|
|
|
dst = gen_dest_fpr_F(dc);
|
2011-10-15 20:52:00 +02:00
|
|
|
|
|
|
|
gen(dst, src1, src2);
|
|
|
|
|
|
|
|
gen_store_fpr_F(dc, rd, dst);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
static inline void gen_fop_DD(DisasContext *dc, int rd, int rs,
|
|
|
|
void (*gen)(TCGv_i64, TCGv_ptr, TCGv_i64))
|
|
|
|
{
|
|
|
|
TCGv_i64 dst, src;
|
|
|
|
|
|
|
|
src = gen_load_fpr_D(dc, rs);
|
2012-10-16 11:32:26 +02:00
|
|
|
dst = gen_dest_fpr_D(dc, rd);
|
2011-10-15 20:52:00 +02:00
|
|
|
|
|
|
|
gen(dst, cpu_env, src);
|
2015-09-09 20:11:36 +02:00
|
|
|
gen_helper_check_ieee_exceptions(cpu_fsr, cpu_env);
|
2011-10-15 20:52:00 +02:00
|
|
|
|
|
|
|
gen_store_fpr_D(dc, rd, dst);
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef TARGET_SPARC64
|
|
|
|
static inline void gen_ne_fop_DD(DisasContext *dc, int rd, int rs,
|
|
|
|
void (*gen)(TCGv_i64, TCGv_i64))
|
|
|
|
{
|
|
|
|
TCGv_i64 dst, src;
|
|
|
|
|
|
|
|
src = gen_load_fpr_D(dc, rs);
|
2012-10-16 11:32:26 +02:00
|
|
|
dst = gen_dest_fpr_D(dc, rd);
|
2011-10-15 20:52:00 +02:00
|
|
|
|
|
|
|
gen(dst, src);
|
|
|
|
|
|
|
|
gen_store_fpr_D(dc, rd, dst);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
static inline void gen_fop_DDD(DisasContext *dc, int rd, int rs1, int rs2,
|
|
|
|
void (*gen)(TCGv_i64, TCGv_ptr, TCGv_i64, TCGv_i64))
|
|
|
|
{
|
|
|
|
TCGv_i64 dst, src1, src2;
|
|
|
|
|
|
|
|
src1 = gen_load_fpr_D(dc, rs1);
|
|
|
|
src2 = gen_load_fpr_D(dc, rs2);
|
2012-10-16 11:32:26 +02:00
|
|
|
dst = gen_dest_fpr_D(dc, rd);
|
2011-10-15 20:52:00 +02:00
|
|
|
|
|
|
|
gen(dst, cpu_env, src1, src2);
|
2015-09-09 20:11:36 +02:00
|
|
|
gen_helper_check_ieee_exceptions(cpu_fsr, cpu_env);
|
2011-10-15 20:52:00 +02:00
|
|
|
|
|
|
|
gen_store_fpr_D(dc, rd, dst);
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef TARGET_SPARC64
|
|
|
|
static inline void gen_ne_fop_DDD(DisasContext *dc, int rd, int rs1, int rs2,
|
|
|
|
void (*gen)(TCGv_i64, TCGv_i64, TCGv_i64))
|
|
|
|
{
|
|
|
|
TCGv_i64 dst, src1, src2;
|
|
|
|
|
|
|
|
src1 = gen_load_fpr_D(dc, rs1);
|
|
|
|
src2 = gen_load_fpr_D(dc, rs2);
|
2012-10-16 11:32:26 +02:00
|
|
|
dst = gen_dest_fpr_D(dc, rd);
|
2011-10-15 20:52:00 +02:00
|
|
|
|
|
|
|
gen(dst, src1, src2);
|
|
|
|
|
|
|
|
gen_store_fpr_D(dc, rd, dst);
|
|
|
|
}
|
2011-10-18 02:32:26 +02:00
|
|
|
|
2011-10-18 03:03:47 +02:00
|
|
|
static inline void gen_gsr_fop_DDD(DisasContext *dc, int rd, int rs1, int rs2,
|
|
|
|
void (*gen)(TCGv_i64, TCGv_i64, TCGv_i64, TCGv_i64))
|
|
|
|
{
|
|
|
|
TCGv_i64 dst, src1, src2;
|
|
|
|
|
|
|
|
src1 = gen_load_fpr_D(dc, rs1);
|
|
|
|
src2 = gen_load_fpr_D(dc, rs2);
|
2012-10-16 11:32:26 +02:00
|
|
|
dst = gen_dest_fpr_D(dc, rd);
|
2011-10-18 03:03:47 +02:00
|
|
|
|
|
|
|
gen(dst, cpu_gsr, src1, src2);
|
|
|
|
|
|
|
|
gen_store_fpr_D(dc, rd, dst);
|
|
|
|
}
|
|
|
|
|
2011-10-18 02:32:26 +02:00
|
|
|
static inline void gen_ne_fop_DDDD(DisasContext *dc, int rd, int rs1, int rs2,
|
|
|
|
void (*gen)(TCGv_i64, TCGv_i64, TCGv_i64, TCGv_i64))
|
|
|
|
{
|
|
|
|
TCGv_i64 dst, src0, src1, src2;
|
|
|
|
|
|
|
|
src1 = gen_load_fpr_D(dc, rs1);
|
|
|
|
src2 = gen_load_fpr_D(dc, rs2);
|
|
|
|
src0 = gen_load_fpr_D(dc, rd);
|
2012-10-16 11:32:26 +02:00
|
|
|
dst = gen_dest_fpr_D(dc, rd);
|
2011-10-18 02:32:26 +02:00
|
|
|
|
|
|
|
gen(dst, src0, src1, src2);
|
|
|
|
|
|
|
|
gen_store_fpr_D(dc, rd, dst);
|
|
|
|
}
|
2011-10-15 20:52:00 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
static inline void gen_fop_QQ(DisasContext *dc, int rd, int rs,
|
|
|
|
void (*gen)(TCGv_ptr))
|
|
|
|
{
|
|
|
|
gen_op_load_fpr_QT1(QFPREG(rs));
|
|
|
|
|
|
|
|
gen(cpu_env);
|
2015-09-09 20:11:36 +02:00
|
|
|
gen_helper_check_ieee_exceptions(cpu_fsr, cpu_env);
|
2011-10-15 20:52:00 +02:00
|
|
|
|
|
|
|
gen_op_store_QT0_fpr(QFPREG(rd));
|
2015-09-09 20:56:38 +02:00
|
|
|
gen_update_fprs_dirty(dc, QFPREG(rd));
|
2011-10-15 20:52:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef TARGET_SPARC64
|
|
|
|
static inline void gen_ne_fop_QQ(DisasContext *dc, int rd, int rs,
|
|
|
|
void (*gen)(TCGv_ptr))
|
|
|
|
{
|
|
|
|
gen_op_load_fpr_QT1(QFPREG(rs));
|
|
|
|
|
|
|
|
gen(cpu_env);
|
|
|
|
|
|
|
|
gen_op_store_QT0_fpr(QFPREG(rd));
|
2015-09-09 20:56:38 +02:00
|
|
|
gen_update_fprs_dirty(dc, QFPREG(rd));
|
2011-10-15 20:52:00 +02:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
static inline void gen_fop_QQQ(DisasContext *dc, int rd, int rs1, int rs2,
|
|
|
|
void (*gen)(TCGv_ptr))
|
|
|
|
{
|
|
|
|
gen_op_load_fpr_QT0(QFPREG(rs1));
|
|
|
|
gen_op_load_fpr_QT1(QFPREG(rs2));
|
|
|
|
|
|
|
|
gen(cpu_env);
|
2015-09-09 20:11:36 +02:00
|
|
|
gen_helper_check_ieee_exceptions(cpu_fsr, cpu_env);
|
2011-10-15 20:52:00 +02:00
|
|
|
|
|
|
|
gen_op_store_QT0_fpr(QFPREG(rd));
|
2015-09-09 20:56:38 +02:00
|
|
|
gen_update_fprs_dirty(dc, QFPREG(rd));
|
2011-10-15 20:52:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline void gen_fop_DFF(DisasContext *dc, int rd, int rs1, int rs2,
|
|
|
|
void (*gen)(TCGv_i64, TCGv_ptr, TCGv_i32, TCGv_i32))
|
|
|
|
{
|
|
|
|
TCGv_i64 dst;
|
|
|
|
TCGv_i32 src1, src2;
|
|
|
|
|
|
|
|
src1 = gen_load_fpr_F(dc, rs1);
|
|
|
|
src2 = gen_load_fpr_F(dc, rs2);
|
2012-10-16 11:32:26 +02:00
|
|
|
dst = gen_dest_fpr_D(dc, rd);
|
2011-10-15 20:52:00 +02:00
|
|
|
|
|
|
|
gen(dst, cpu_env, src1, src2);
|
2015-09-09 20:11:36 +02:00
|
|
|
gen_helper_check_ieee_exceptions(cpu_fsr, cpu_env);
|
2011-10-15 20:52:00 +02:00
|
|
|
|
|
|
|
gen_store_fpr_D(dc, rd, dst);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void gen_fop_QDD(DisasContext *dc, int rd, int rs1, int rs2,
|
|
|
|
void (*gen)(TCGv_ptr, TCGv_i64, TCGv_i64))
|
|
|
|
{
|
|
|
|
TCGv_i64 src1, src2;
|
|
|
|
|
|
|
|
src1 = gen_load_fpr_D(dc, rs1);
|
|
|
|
src2 = gen_load_fpr_D(dc, rs2);
|
|
|
|
|
|
|
|
gen(cpu_env, src1, src2);
|
2015-09-09 20:11:36 +02:00
|
|
|
gen_helper_check_ieee_exceptions(cpu_fsr, cpu_env);
|
2011-10-15 20:52:00 +02:00
|
|
|
|
|
|
|
gen_op_store_QT0_fpr(QFPREG(rd));
|
2015-09-09 20:56:38 +02:00
|
|
|
gen_update_fprs_dirty(dc, QFPREG(rd));
|
2011-10-15 20:52:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef TARGET_SPARC64
|
|
|
|
static inline void gen_fop_DF(DisasContext *dc, int rd, int rs,
|
|
|
|
void (*gen)(TCGv_i64, TCGv_ptr, TCGv_i32))
|
|
|
|
{
|
|
|
|
TCGv_i64 dst;
|
|
|
|
TCGv_i32 src;
|
|
|
|
|
|
|
|
src = gen_load_fpr_F(dc, rs);
|
2012-10-16 11:32:26 +02:00
|
|
|
dst = gen_dest_fpr_D(dc, rd);
|
2011-10-15 20:52:00 +02:00
|
|
|
|
|
|
|
gen(dst, cpu_env, src);
|
2015-09-09 20:11:36 +02:00
|
|
|
gen_helper_check_ieee_exceptions(cpu_fsr, cpu_env);
|
2011-10-15 20:52:00 +02:00
|
|
|
|
|
|
|
gen_store_fpr_D(dc, rd, dst);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
static inline void gen_ne_fop_DF(DisasContext *dc, int rd, int rs,
|
|
|
|
void (*gen)(TCGv_i64, TCGv_ptr, TCGv_i32))
|
|
|
|
{
|
|
|
|
TCGv_i64 dst;
|
|
|
|
TCGv_i32 src;
|
|
|
|
|
|
|
|
src = gen_load_fpr_F(dc, rs);
|
2012-10-16 11:32:26 +02:00
|
|
|
dst = gen_dest_fpr_D(dc, rd);
|
2011-10-15 20:52:00 +02:00
|
|
|
|
|
|
|
gen(dst, cpu_env, src);
|
|
|
|
|
|
|
|
gen_store_fpr_D(dc, rd, dst);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void gen_fop_FD(DisasContext *dc, int rd, int rs,
|
|
|
|
void (*gen)(TCGv_i32, TCGv_ptr, TCGv_i64))
|
|
|
|
{
|
|
|
|
TCGv_i32 dst;
|
|
|
|
TCGv_i64 src;
|
|
|
|
|
|
|
|
src = gen_load_fpr_D(dc, rs);
|
2012-10-16 11:32:21 +02:00
|
|
|
dst = gen_dest_fpr_F(dc);
|
2011-10-15 20:52:00 +02:00
|
|
|
|
|
|
|
gen(dst, cpu_env, src);
|
2015-09-09 20:11:36 +02:00
|
|
|
gen_helper_check_ieee_exceptions(cpu_fsr, cpu_env);
|
2011-10-15 20:52:00 +02:00
|
|
|
|
|
|
|
gen_store_fpr_F(dc, rd, dst);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void gen_fop_FQ(DisasContext *dc, int rd, int rs,
|
|
|
|
void (*gen)(TCGv_i32, TCGv_ptr))
|
|
|
|
{
|
|
|
|
TCGv_i32 dst;
|
|
|
|
|
|
|
|
gen_op_load_fpr_QT1(QFPREG(rs));
|
2012-10-16 11:32:21 +02:00
|
|
|
dst = gen_dest_fpr_F(dc);
|
2011-10-15 20:52:00 +02:00
|
|
|
|
|
|
|
gen(dst, cpu_env);
|
2015-09-09 20:11:36 +02:00
|
|
|
gen_helper_check_ieee_exceptions(cpu_fsr, cpu_env);
|
2011-10-15 20:52:00 +02:00
|
|
|
|
|
|
|
gen_store_fpr_F(dc, rd, dst);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void gen_fop_DQ(DisasContext *dc, int rd, int rs,
|
|
|
|
void (*gen)(TCGv_i64, TCGv_ptr))
|
|
|
|
{
|
|
|
|
TCGv_i64 dst;
|
|
|
|
|
|
|
|
gen_op_load_fpr_QT1(QFPREG(rs));
|
2012-10-16 11:32:26 +02:00
|
|
|
dst = gen_dest_fpr_D(dc, rd);
|
2011-10-15 20:52:00 +02:00
|
|
|
|
|
|
|
gen(dst, cpu_env);
|
2015-09-09 20:11:36 +02:00
|
|
|
gen_helper_check_ieee_exceptions(cpu_fsr, cpu_env);
|
2011-10-15 20:52:00 +02:00
|
|
|
|
|
|
|
gen_store_fpr_D(dc, rd, dst);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void gen_ne_fop_QF(DisasContext *dc, int rd, int rs,
|
|
|
|
void (*gen)(TCGv_ptr, TCGv_i32))
|
|
|
|
{
|
|
|
|
TCGv_i32 src;
|
|
|
|
|
|
|
|
src = gen_load_fpr_F(dc, rs);
|
|
|
|
|
|
|
|
gen(cpu_env, src);
|
|
|
|
|
|
|
|
gen_op_store_QT0_fpr(QFPREG(rd));
|
2015-09-09 20:56:38 +02:00
|
|
|
gen_update_fprs_dirty(dc, QFPREG(rd));
|
2011-10-15 20:52:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline void gen_ne_fop_QD(DisasContext *dc, int rd, int rs,
|
|
|
|
void (*gen)(TCGv_ptr, TCGv_i64))
|
|
|
|
{
|
|
|
|
TCGv_i64 src;
|
|
|
|
|
|
|
|
src = gen_load_fpr_D(dc, rs);
|
|
|
|
|
|
|
|
gen(cpu_env, src);
|
|
|
|
|
|
|
|
gen_op_store_QT0_fpr(QFPREG(rd));
|
2015-09-09 20:56:38 +02:00
|
|
|
gen_update_fprs_dirty(dc, QFPREG(rd));
|
2011-10-15 20:52:00 +02:00
|
|
|
}
|
|
|
|
|
2016-07-13 00:29:18 +02:00
|
|
|
static void gen_swap(DisasContext *dc, TCGv dst, TCGv src,
|
2019-08-23 20:10:58 +02:00
|
|
|
TCGv addr, int mmu_idx, MemOp memop)
|
2016-07-13 00:29:18 +02:00
|
|
|
{
|
|
|
|
gen_address_mask(dc, addr);
|
2023-05-02 17:12:44 +02:00
|
|
|
tcg_gen_atomic_xchg_tl(dst, addr, src, mmu_idx, memop | MO_ALIGN);
|
2016-07-13 00:29:18 +02:00
|
|
|
}
|
|
|
|
|
2016-07-13 00:38:13 +02:00
|
|
|
static void gen_ldstub(DisasContext *dc, TCGv dst, TCGv addr, int mmu_idx)
|
|
|
|
{
|
2023-02-26 22:15:00 +01:00
|
|
|
TCGv m1 = tcg_constant_tl(0xff);
|
2016-07-13 00:38:13 +02:00
|
|
|
gen_address_mask(dc, addr);
|
2016-09-13 04:01:53 +02:00
|
|
|
tcg_gen_atomic_xchg_tl(dst, addr, m1, mmu_idx, MO_UB);
|
2016-07-13 00:38:13 +02:00
|
|
|
}
|
|
|
|
|
2008-02-24 15:10:06 +01:00
|
|
|
/* asi moves */
|
2015-09-03 06:22:41 +02:00
|
|
|
#if !defined(CONFIG_USER_ONLY) || defined(TARGET_SPARC64)
|
2015-09-03 06:45:15 +02:00
|
|
|
typedef enum {
|
|
|
|
GET_ASI_HELPER,
|
|
|
|
GET_ASI_EXCP,
|
2015-09-03 09:53:40 +02:00
|
|
|
GET_ASI_DIRECT,
|
2015-09-03 22:13:35 +02:00
|
|
|
GET_ASI_DTWINX,
|
2015-09-06 17:30:00 +02:00
|
|
|
GET_ASI_BLOCK,
|
|
|
|
GET_ASI_SHORT,
|
2016-07-14 21:46:19 +02:00
|
|
|
GET_ASI_BCOPY,
|
|
|
|
GET_ASI_BFILL,
|
2015-09-03 06:45:15 +02:00
|
|
|
} ASIType;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
ASIType type;
|
2015-09-03 23:14:33 +02:00
|
|
|
int asi;
|
2015-09-03 09:53:40 +02:00
|
|
|
int mem_idx;
|
2019-08-23 20:10:58 +02:00
|
|
|
MemOp memop;
|
2015-09-03 06:45:15 +02:00
|
|
|
} DisasASI;
|
2008-02-24 15:10:06 +01:00
|
|
|
|
2019-08-23 20:10:58 +02:00
|
|
|
static DisasASI get_asi(DisasContext *dc, int insn, MemOp memop)
|
2015-09-03 06:45:15 +02:00
|
|
|
{
|
|
|
|
int asi = GET_FIELD(insn, 19, 26);
|
|
|
|
ASIType type = GET_ASI_HELPER;
|
2015-09-03 09:53:40 +02:00
|
|
|
int mem_idx = dc->mem_idx;
|
2015-09-03 06:45:15 +02:00
|
|
|
|
|
|
|
#ifndef TARGET_SPARC64
|
|
|
|
/* Before v9, all asis are immediate and privileged. */
|
2008-02-24 15:10:06 +01:00
|
|
|
if (IS_IMM) {
|
2015-09-03 06:22:41 +02:00
|
|
|
gen_exception(dc, TT_ILL_INSN);
|
2015-09-03 06:45:15 +02:00
|
|
|
type = GET_ASI_EXCP;
|
|
|
|
} else if (supervisor(dc)
|
|
|
|
/* Note that LEON accepts ASI_USERDATA in user mode, for
|
|
|
|
use with CASA. Also note that previous versions of
|
2015-09-03 20:36:02 +02:00
|
|
|
QEMU allowed (and old versions of gcc emitted) ASI_P
|
|
|
|
for LEON, which is incorrect. */
|
|
|
|
|| (asi == ASI_USERDATA
|
2015-09-03 06:45:15 +02:00
|
|
|
&& (dc->def->features & CPU_FEATURE_CASA))) {
|
2015-09-03 09:53:40 +02:00
|
|
|
switch (asi) {
|
|
|
|
case ASI_USERDATA: /* User data access */
|
|
|
|
mem_idx = MMU_USER_IDX;
|
|
|
|
type = GET_ASI_DIRECT;
|
|
|
|
break;
|
|
|
|
case ASI_KERNELDATA: /* Supervisor data access */
|
|
|
|
mem_idx = MMU_KERNEL_IDX;
|
|
|
|
type = GET_ASI_DIRECT;
|
|
|
|
break;
|
2016-07-13 06:29:44 +02:00
|
|
|
case ASI_M_BYPASS: /* MMU passthrough */
|
|
|
|
case ASI_LEON_BYPASS: /* LEON MMU passthrough */
|
|
|
|
mem_idx = MMU_PHYS_IDX;
|
|
|
|
type = GET_ASI_DIRECT;
|
|
|
|
break;
|
2016-07-14 21:46:19 +02:00
|
|
|
case ASI_M_BCOPY: /* Block copy, sta access */
|
|
|
|
mem_idx = MMU_KERNEL_IDX;
|
|
|
|
type = GET_ASI_BCOPY;
|
|
|
|
break;
|
|
|
|
case ASI_M_BFILL: /* Block fill, stda access */
|
|
|
|
mem_idx = MMU_KERNEL_IDX;
|
|
|
|
type = GET_ASI_BFILL;
|
|
|
|
break;
|
2015-09-03 09:53:40 +02:00
|
|
|
}
|
2018-03-02 10:59:25 +01:00
|
|
|
|
|
|
|
/* MMU_PHYS_IDX is used when the MMU is disabled to passthrough the
|
|
|
|
* permissions check in get_physical_address(..).
|
|
|
|
*/
|
|
|
|
mem_idx = (dc->mem_idx == MMU_PHYS_IDX) ? MMU_PHYS_IDX : mem_idx;
|
2008-02-24 15:10:06 +01:00
|
|
|
} else {
|
2015-09-03 06:45:15 +02:00
|
|
|
gen_exception(dc, TT_PRIV_INSN);
|
|
|
|
type = GET_ASI_EXCP;
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
if (IS_IMM) {
|
|
|
|
asi = dc->asi;
|
2008-02-24 15:10:06 +01:00
|
|
|
}
|
2015-09-03 09:53:40 +02:00
|
|
|
/* With v9, all asis below 0x80 are privileged. */
|
|
|
|
/* ??? We ought to check cpu_has_hypervisor, but we didn't copy
|
|
|
|
down that bit into DisasContext. For the moment that's ok,
|
|
|
|
since the direct implementations below doesn't have any ASIs
|
|
|
|
in the restricted [0x30, 0x7f] range, and the check will be
|
|
|
|
done properly in the helper. */
|
|
|
|
if (!supervisor(dc) && asi < 0x80) {
|
|
|
|
gen_exception(dc, TT_PRIV_ACT);
|
|
|
|
type = GET_ASI_EXCP;
|
|
|
|
} else {
|
|
|
|
switch (asi) {
|
2016-07-13 06:29:44 +02:00
|
|
|
case ASI_REAL: /* Bypass */
|
|
|
|
case ASI_REAL_IO: /* Bypass, non-cacheable */
|
|
|
|
case ASI_REAL_L: /* Bypass LE */
|
|
|
|
case ASI_REAL_IO_L: /* Bypass, non-cacheable LE */
|
|
|
|
case ASI_TWINX_REAL: /* Real address, twinx */
|
|
|
|
case ASI_TWINX_REAL_L: /* Real address, twinx, LE */
|
2016-07-13 09:43:05 +02:00
|
|
|
case ASI_QUAD_LDD_PHYS:
|
|
|
|
case ASI_QUAD_LDD_PHYS_L:
|
2016-07-13 06:29:44 +02:00
|
|
|
mem_idx = MMU_PHYS_IDX;
|
|
|
|
break;
|
2015-09-03 09:53:40 +02:00
|
|
|
case ASI_N: /* Nucleus */
|
|
|
|
case ASI_NL: /* Nucleus LE */
|
2015-09-03 22:13:35 +02:00
|
|
|
case ASI_TWINX_N:
|
|
|
|
case ASI_TWINX_NL:
|
2016-07-13 09:43:05 +02:00
|
|
|
case ASI_NUCLEUS_QUAD_LDD:
|
|
|
|
case ASI_NUCLEUS_QUAD_LDD_L:
|
2016-03-02 14:53:38 +01:00
|
|
|
if (hypervisor(dc)) {
|
2016-06-09 10:16:03 +02:00
|
|
|
mem_idx = MMU_PHYS_IDX;
|
2016-03-02 14:53:38 +01:00
|
|
|
} else {
|
|
|
|
mem_idx = MMU_NUCLEUS_IDX;
|
|
|
|
}
|
2015-09-03 09:53:40 +02:00
|
|
|
break;
|
|
|
|
case ASI_AIUP: /* As if user primary */
|
|
|
|
case ASI_AIUPL: /* As if user primary LE */
|
2015-09-03 22:13:35 +02:00
|
|
|
case ASI_TWINX_AIUP:
|
|
|
|
case ASI_TWINX_AIUP_L:
|
2015-09-06 17:30:00 +02:00
|
|
|
case ASI_BLK_AIUP_4V:
|
|
|
|
case ASI_BLK_AIUP_L_4V:
|
|
|
|
case ASI_BLK_AIUP:
|
|
|
|
case ASI_BLK_AIUPL:
|
2015-09-03 09:53:40 +02:00
|
|
|
mem_idx = MMU_USER_IDX;
|
|
|
|
break;
|
|
|
|
case ASI_AIUS: /* As if user secondary */
|
|
|
|
case ASI_AIUSL: /* As if user secondary LE */
|
2015-09-03 22:13:35 +02:00
|
|
|
case ASI_TWINX_AIUS:
|
|
|
|
case ASI_TWINX_AIUS_L:
|
2015-09-06 17:30:00 +02:00
|
|
|
case ASI_BLK_AIUS_4V:
|
|
|
|
case ASI_BLK_AIUS_L_4V:
|
|
|
|
case ASI_BLK_AIUS:
|
|
|
|
case ASI_BLK_AIUSL:
|
2015-09-03 09:53:40 +02:00
|
|
|
mem_idx = MMU_USER_SECONDARY_IDX;
|
|
|
|
break;
|
|
|
|
case ASI_S: /* Secondary */
|
|
|
|
case ASI_SL: /* Secondary LE */
|
2015-09-03 22:13:35 +02:00
|
|
|
case ASI_TWINX_S:
|
|
|
|
case ASI_TWINX_SL:
|
2015-09-06 17:30:00 +02:00
|
|
|
case ASI_BLK_COMMIT_S:
|
|
|
|
case ASI_BLK_S:
|
|
|
|
case ASI_BLK_SL:
|
|
|
|
case ASI_FL8_S:
|
|
|
|
case ASI_FL8_SL:
|
|
|
|
case ASI_FL16_S:
|
|
|
|
case ASI_FL16_SL:
|
2015-09-03 09:53:40 +02:00
|
|
|
if (mem_idx == MMU_USER_IDX) {
|
|
|
|
mem_idx = MMU_USER_SECONDARY_IDX;
|
|
|
|
} else if (mem_idx == MMU_KERNEL_IDX) {
|
|
|
|
mem_idx = MMU_KERNEL_SECONDARY_IDX;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case ASI_P: /* Primary */
|
|
|
|
case ASI_PL: /* Primary LE */
|
2015-09-03 22:13:35 +02:00
|
|
|
case ASI_TWINX_P:
|
|
|
|
case ASI_TWINX_PL:
|
2015-09-06 17:30:00 +02:00
|
|
|
case ASI_BLK_COMMIT_P:
|
|
|
|
case ASI_BLK_P:
|
|
|
|
case ASI_BLK_PL:
|
|
|
|
case ASI_FL8_P:
|
|
|
|
case ASI_FL8_PL:
|
|
|
|
case ASI_FL16_P:
|
|
|
|
case ASI_FL16_PL:
|
2015-09-03 09:53:40 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
switch (asi) {
|
2016-07-13 06:29:44 +02:00
|
|
|
case ASI_REAL:
|
|
|
|
case ASI_REAL_IO:
|
|
|
|
case ASI_REAL_L:
|
|
|
|
case ASI_REAL_IO_L:
|
2015-09-03 09:53:40 +02:00
|
|
|
case ASI_N:
|
|
|
|
case ASI_NL:
|
|
|
|
case ASI_AIUP:
|
|
|
|
case ASI_AIUPL:
|
|
|
|
case ASI_AIUS:
|
|
|
|
case ASI_AIUSL:
|
|
|
|
case ASI_S:
|
|
|
|
case ASI_SL:
|
|
|
|
case ASI_P:
|
|
|
|
case ASI_PL:
|
|
|
|
type = GET_ASI_DIRECT;
|
|
|
|
break;
|
2016-07-13 06:29:44 +02:00
|
|
|
case ASI_TWINX_REAL:
|
|
|
|
case ASI_TWINX_REAL_L:
|
2015-09-03 22:13:35 +02:00
|
|
|
case ASI_TWINX_N:
|
|
|
|
case ASI_TWINX_NL:
|
|
|
|
case ASI_TWINX_AIUP:
|
|
|
|
case ASI_TWINX_AIUP_L:
|
|
|
|
case ASI_TWINX_AIUS:
|
|
|
|
case ASI_TWINX_AIUS_L:
|
|
|
|
case ASI_TWINX_P:
|
|
|
|
case ASI_TWINX_PL:
|
|
|
|
case ASI_TWINX_S:
|
|
|
|
case ASI_TWINX_SL:
|
2016-07-13 09:43:05 +02:00
|
|
|
case ASI_QUAD_LDD_PHYS:
|
|
|
|
case ASI_QUAD_LDD_PHYS_L:
|
|
|
|
case ASI_NUCLEUS_QUAD_LDD:
|
|
|
|
case ASI_NUCLEUS_QUAD_LDD_L:
|
2015-09-03 22:13:35 +02:00
|
|
|
type = GET_ASI_DTWINX;
|
|
|
|
break;
|
2015-09-06 17:30:00 +02:00
|
|
|
case ASI_BLK_COMMIT_P:
|
|
|
|
case ASI_BLK_COMMIT_S:
|
|
|
|
case ASI_BLK_AIUP_4V:
|
|
|
|
case ASI_BLK_AIUP_L_4V:
|
|
|
|
case ASI_BLK_AIUP:
|
|
|
|
case ASI_BLK_AIUPL:
|
|
|
|
case ASI_BLK_AIUS_4V:
|
|
|
|
case ASI_BLK_AIUS_L_4V:
|
|
|
|
case ASI_BLK_AIUS:
|
|
|
|
case ASI_BLK_AIUSL:
|
|
|
|
case ASI_BLK_S:
|
|
|
|
case ASI_BLK_SL:
|
|
|
|
case ASI_BLK_P:
|
|
|
|
case ASI_BLK_PL:
|
|
|
|
type = GET_ASI_BLOCK;
|
|
|
|
break;
|
|
|
|
case ASI_FL8_S:
|
|
|
|
case ASI_FL8_SL:
|
|
|
|
case ASI_FL8_P:
|
|
|
|
case ASI_FL8_PL:
|
|
|
|
memop = MO_UB;
|
|
|
|
type = GET_ASI_SHORT;
|
|
|
|
break;
|
|
|
|
case ASI_FL16_S:
|
|
|
|
case ASI_FL16_SL:
|
|
|
|
case ASI_FL16_P:
|
|
|
|
case ASI_FL16_PL:
|
|
|
|
memop = MO_TEUW;
|
|
|
|
type = GET_ASI_SHORT;
|
|
|
|
break;
|
2015-09-03 09:53:40 +02:00
|
|
|
}
|
|
|
|
/* The little-endian asis all have bit 3 set. */
|
|
|
|
if (asi & 8) {
|
|
|
|
memop ^= MO_BSWAP;
|
|
|
|
}
|
|
|
|
}
|
2015-09-03 06:45:15 +02:00
|
|
|
#endif
|
|
|
|
|
2015-09-03 09:53:40 +02:00
|
|
|
return (DisasASI){ type, asi, mem_idx, memop };
|
2008-03-16 20:18:54 +01:00
|
|
|
}
|
|
|
|
|
2015-09-03 06:22:41 +02:00
|
|
|
static void gen_ld_asi(DisasContext *dc, TCGv dst, TCGv addr,
|
2019-08-23 20:10:58 +02:00
|
|
|
int insn, MemOp memop)
|
2008-03-16 20:18:54 +01:00
|
|
|
{
|
2015-09-03 09:53:40 +02:00
|
|
|
DisasASI da = get_asi(dc, insn, memop);
|
2008-03-16 20:18:54 +01:00
|
|
|
|
2015-09-03 06:45:15 +02:00
|
|
|
switch (da.type) {
|
|
|
|
case GET_ASI_EXCP:
|
|
|
|
break;
|
2015-09-03 22:13:35 +02:00
|
|
|
case GET_ASI_DTWINX: /* Reserved for ldda. */
|
|
|
|
gen_exception(dc, TT_ILL_INSN);
|
|
|
|
break;
|
2015-09-03 09:53:40 +02:00
|
|
|
case GET_ASI_DIRECT:
|
|
|
|
gen_address_mask(dc, addr);
|
2023-05-02 17:12:44 +02:00
|
|
|
tcg_gen_qemu_ld_tl(dst, addr, da.mem_idx, da.memop | MO_ALIGN);
|
2015-09-03 09:53:40 +02:00
|
|
|
break;
|
2015-09-03 06:45:15 +02:00
|
|
|
default:
|
|
|
|
{
|
2023-02-26 22:15:00 +01:00
|
|
|
TCGv_i32 r_asi = tcg_constant_i32(da.asi);
|
2023-05-02 17:12:44 +02:00
|
|
|
TCGv_i32 r_mop = tcg_constant_i32(memop | MO_ALIGN);
|
2015-09-03 06:45:15 +02:00
|
|
|
|
|
|
|
save_state(dc);
|
2015-09-03 06:22:41 +02:00
|
|
|
#ifdef TARGET_SPARC64
|
2015-09-03 22:37:09 +02:00
|
|
|
gen_helper_ld_asi(dst, cpu_env, addr, r_asi, r_mop);
|
2015-09-03 06:22:41 +02:00
|
|
|
#else
|
2015-09-03 06:45:15 +02:00
|
|
|
{
|
|
|
|
TCGv_i64 t64 = tcg_temp_new_i64();
|
2015-09-03 22:37:09 +02:00
|
|
|
gen_helper_ld_asi(t64, cpu_env, addr, r_asi, r_mop);
|
2015-09-03 06:45:15 +02:00
|
|
|
tcg_gen_trunc_i64_tl(dst, t64);
|
|
|
|
}
|
2015-09-03 06:22:41 +02:00
|
|
|
#endif
|
2015-09-03 06:45:15 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2008-02-24 15:10:06 +01:00
|
|
|
}
|
|
|
|
|
2015-09-03 06:22:41 +02:00
|
|
|
static void gen_st_asi(DisasContext *dc, TCGv src, TCGv addr,
|
2019-08-23 20:10:58 +02:00
|
|
|
int insn, MemOp memop)
|
2008-02-24 15:10:06 +01:00
|
|
|
{
|
2015-09-03 09:53:40 +02:00
|
|
|
DisasASI da = get_asi(dc, insn, memop);
|
2008-02-24 15:10:06 +01:00
|
|
|
|
2015-09-03 06:45:15 +02:00
|
|
|
switch (da.type) {
|
|
|
|
case GET_ASI_EXCP:
|
|
|
|
break;
|
2015-09-03 22:13:35 +02:00
|
|
|
case GET_ASI_DTWINX: /* Reserved for stda. */
|
2016-11-02 10:37:44 +01:00
|
|
|
#ifndef TARGET_SPARC64
|
2015-09-03 22:13:35 +02:00
|
|
|
gen_exception(dc, TT_ILL_INSN);
|
|
|
|
break;
|
2016-11-02 10:37:44 +01:00
|
|
|
#else
|
|
|
|
if (!(dc->def->features & CPU_FEATURE_HYPV)) {
|
|
|
|
/* Pre OpenSPARC CPUs don't have these */
|
|
|
|
gen_exception(dc, TT_ILL_INSN);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
/* in OpenSPARC T1+ CPUs TWINX ASIs in store instructions
|
|
|
|
* are ST_BLKINIT_ ASIs */
|
|
|
|
#endif
|
2020-12-11 16:24:22 +01:00
|
|
|
/* fall through */
|
2015-09-03 09:53:40 +02:00
|
|
|
case GET_ASI_DIRECT:
|
|
|
|
gen_address_mask(dc, addr);
|
2023-05-02 17:12:44 +02:00
|
|
|
tcg_gen_qemu_st_tl(src, addr, da.mem_idx, da.memop | MO_ALIGN);
|
2015-09-03 09:53:40 +02:00
|
|
|
break;
|
2016-07-14 21:46:19 +02:00
|
|
|
#if !defined(TARGET_SPARC64) && !defined(CONFIG_USER_ONLY)
|
|
|
|
case GET_ASI_BCOPY:
|
|
|
|
/* Copy 32 bytes from the address in SRC to ADDR. */
|
|
|
|
/* ??? The original qemu code suggests 4-byte alignment, dropping
|
|
|
|
the low bits, but the only place I can see this used is in the
|
|
|
|
Linux kernel with 32 byte alignment, which would make more sense
|
|
|
|
as a cacheline-style operation. */
|
|
|
|
{
|
|
|
|
TCGv saddr = tcg_temp_new();
|
|
|
|
TCGv daddr = tcg_temp_new();
|
2023-02-26 22:15:00 +01:00
|
|
|
TCGv four = tcg_constant_tl(4);
|
2016-07-14 21:46:19 +02:00
|
|
|
TCGv_i32 tmp = tcg_temp_new_i32();
|
|
|
|
int i;
|
|
|
|
|
|
|
|
tcg_gen_andi_tl(saddr, src, -4);
|
|
|
|
tcg_gen_andi_tl(daddr, addr, -4);
|
|
|
|
for (i = 0; i < 32; i += 4) {
|
|
|
|
/* Since the loads and stores are paired, allow the
|
|
|
|
copy to happen in the host endianness. */
|
|
|
|
tcg_gen_qemu_ld_i32(tmp, saddr, da.mem_idx, MO_UL);
|
|
|
|
tcg_gen_qemu_st_i32(tmp, daddr, da.mem_idx, MO_UL);
|
|
|
|
tcg_gen_add_tl(saddr, saddr, four);
|
|
|
|
tcg_gen_add_tl(daddr, daddr, four);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
#endif
|
2015-09-03 06:45:15 +02:00
|
|
|
default:
|
|
|
|
{
|
2023-02-26 22:15:00 +01:00
|
|
|
TCGv_i32 r_asi = tcg_constant_i32(da.asi);
|
2023-05-02 17:12:44 +02:00
|
|
|
TCGv_i32 r_mop = tcg_constant_i32(memop | MO_ALIGN);
|
2015-09-03 06:45:15 +02:00
|
|
|
|
|
|
|
save_state(dc);
|
2015-09-03 06:22:41 +02:00
|
|
|
#ifdef TARGET_SPARC64
|
2015-09-03 22:37:09 +02:00
|
|
|
gen_helper_st_asi(cpu_env, addr, src, r_asi, r_mop);
|
2015-09-03 06:22:41 +02:00
|
|
|
#else
|
2015-09-03 06:45:15 +02:00
|
|
|
{
|
|
|
|
TCGv_i64 t64 = tcg_temp_new_i64();
|
|
|
|
tcg_gen_extu_tl_i64(t64, src);
|
2015-09-03 22:37:09 +02:00
|
|
|
gen_helper_st_asi(cpu_env, addr, t64, r_asi, r_mop);
|
2015-09-03 06:45:15 +02:00
|
|
|
}
|
2015-09-03 06:22:41 +02:00
|
|
|
#endif
|
2015-09-03 06:45:15 +02:00
|
|
|
|
|
|
|
/* A write to a TLB register may alter page maps. End the TB. */
|
|
|
|
dc->npc = DYNAMIC_PC;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2008-02-24 15:10:06 +01:00
|
|
|
}
|
|
|
|
|
2015-09-03 06:22:41 +02:00
|
|
|
static void gen_swap_asi(DisasContext *dc, TCGv dst, TCGv src,
|
|
|
|
TCGv addr, int insn)
|
2008-02-24 15:10:06 +01:00
|
|
|
{
|
2015-09-03 09:53:40 +02:00
|
|
|
DisasASI da = get_asi(dc, insn, MO_TEUL);
|
2015-09-03 06:22:41 +02:00
|
|
|
|
2015-09-03 06:45:15 +02:00
|
|
|
switch (da.type) {
|
|
|
|
case GET_ASI_EXCP:
|
|
|
|
break;
|
2016-07-13 00:29:18 +02:00
|
|
|
case GET_ASI_DIRECT:
|
|
|
|
gen_swap(dc, dst, src, addr, da.mem_idx, da.memop);
|
|
|
|
break;
|
2015-09-03 06:45:15 +02:00
|
|
|
default:
|
2016-07-13 00:29:18 +02:00
|
|
|
/* ??? Should be DAE_invalid_asi. */
|
|
|
|
gen_exception(dc, TT_DATA_ACCESS);
|
2015-09-03 06:45:15 +02:00
|
|
|
break;
|
|
|
|
}
|
2008-02-24 15:10:06 +01:00
|
|
|
}
|
|
|
|
|
2016-09-13 04:11:18 +02:00
|
|
|
static void gen_cas_asi(DisasContext *dc, TCGv addr, TCGv cmpv,
|
2015-09-03 06:22:41 +02:00
|
|
|
int insn, int rd)
|
|
|
|
{
|
2015-09-03 09:53:40 +02:00
|
|
|
DisasASI da = get_asi(dc, insn, MO_TEUL);
|
2016-09-13 04:11:18 +02:00
|
|
|
TCGv oldv;
|
2015-09-03 06:22:41 +02:00
|
|
|
|
2016-07-13 01:10:32 +02:00
|
|
|
switch (da.type) {
|
|
|
|
case GET_ASI_EXCP:
|
2015-09-03 06:45:15 +02:00
|
|
|
return;
|
2016-07-13 01:10:32 +02:00
|
|
|
case GET_ASI_DIRECT:
|
|
|
|
oldv = tcg_temp_new();
|
2016-09-13 04:11:18 +02:00
|
|
|
tcg_gen_atomic_cmpxchg_tl(oldv, addr, cmpv, gen_load_gpr(dc, rd),
|
2023-05-02 17:12:44 +02:00
|
|
|
da.mem_idx, da.memop | MO_ALIGN);
|
2016-07-13 01:10:32 +02:00
|
|
|
gen_store_gpr(dc, rd, oldv);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
/* ??? Should be DAE_invalid_asi. */
|
|
|
|
gen_exception(dc, TT_DATA_ACCESS);
|
|
|
|
break;
|
2015-09-03 06:45:15 +02:00
|
|
|
}
|
2015-09-03 06:22:41 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void gen_ldstub_asi(DisasContext *dc, TCGv dst, TCGv addr, int insn)
|
|
|
|
{
|
2015-09-03 09:53:40 +02:00
|
|
|
DisasASI da = get_asi(dc, insn, MO_UB);
|
2015-09-03 06:22:41 +02:00
|
|
|
|
2015-09-03 06:45:15 +02:00
|
|
|
switch (da.type) {
|
|
|
|
case GET_ASI_EXCP:
|
|
|
|
break;
|
2016-07-13 00:38:13 +02:00
|
|
|
case GET_ASI_DIRECT:
|
|
|
|
gen_ldstub(dc, dst, addr, da.mem_idx);
|
|
|
|
break;
|
2015-09-03 06:45:15 +02:00
|
|
|
default:
|
2017-01-27 09:08:21 +01:00
|
|
|
/* ??? In theory, this should be raise DAE_invalid_asi.
|
|
|
|
But the SS-20 roms do ldstuba [%l0] #ASI_M_CTL, %o1. */
|
2018-02-15 03:16:30 +01:00
|
|
|
if (tb_cflags(dc->base.tb) & CF_PARALLEL) {
|
2017-01-27 09:08:21 +01:00
|
|
|
gen_helper_exit_atomic(cpu_env);
|
|
|
|
} else {
|
2023-02-26 22:15:00 +01:00
|
|
|
TCGv_i32 r_asi = tcg_constant_i32(da.asi);
|
|
|
|
TCGv_i32 r_mop = tcg_constant_i32(MO_UB);
|
2017-01-27 09:08:21 +01:00
|
|
|
TCGv_i64 s64, t64;
|
|
|
|
|
|
|
|
save_state(dc);
|
|
|
|
t64 = tcg_temp_new_i64();
|
|
|
|
gen_helper_ld_asi(t64, cpu_env, addr, r_asi, r_mop);
|
|
|
|
|
2023-02-26 22:15:00 +01:00
|
|
|
s64 = tcg_constant_i64(0xff);
|
2017-01-27 09:08:21 +01:00
|
|
|
gen_helper_st_asi(cpu_env, addr, s64, r_asi, r_mop);
|
|
|
|
|
|
|
|
tcg_gen_trunc_i64_tl(dst, t64);
|
|
|
|
|
|
|
|
/* End the TB. */
|
|
|
|
dc->npc = DYNAMIC_PC;
|
|
|
|
}
|
2015-09-03 06:45:15 +02:00
|
|
|
break;
|
|
|
|
}
|
2015-09-03 06:22:41 +02:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef TARGET_SPARC64
|
|
|
|
static void gen_ldf_asi(DisasContext *dc, TCGv addr,
|
|
|
|
int insn, int size, int rd)
|
2008-02-24 15:10:06 +01:00
|
|
|
{
|
2022-01-06 22:00:51 +01:00
|
|
|
DisasASI da = get_asi(dc, insn, (size == 4 ? MO_TEUL : MO_TEUQ));
|
2015-09-04 16:43:50 +02:00
|
|
|
TCGv_i32 d32;
|
2016-08-31 19:48:03 +02:00
|
|
|
TCGv_i64 d64;
|
2008-02-24 15:10:06 +01:00
|
|
|
|
2015-09-03 06:45:15 +02:00
|
|
|
switch (da.type) {
|
|
|
|
case GET_ASI_EXCP:
|
|
|
|
break;
|
2015-09-04 16:43:50 +02:00
|
|
|
|
|
|
|
case GET_ASI_DIRECT:
|
|
|
|
gen_address_mask(dc, addr);
|
|
|
|
switch (size) {
|
|
|
|
case 4:
|
|
|
|
d32 = gen_dest_fpr_F(dc);
|
2023-05-02 17:12:44 +02:00
|
|
|
tcg_gen_qemu_ld_i32(d32, addr, da.mem_idx, da.memop | MO_ALIGN);
|
2015-09-04 16:43:50 +02:00
|
|
|
gen_store_fpr_F(dc, rd, d32);
|
|
|
|
break;
|
|
|
|
case 8:
|
2016-08-31 19:48:03 +02:00
|
|
|
tcg_gen_qemu_ld_i64(cpu_fpr[rd / 2], addr, da.mem_idx,
|
|
|
|
da.memop | MO_ALIGN_4);
|
2015-09-04 16:43:50 +02:00
|
|
|
break;
|
|
|
|
case 16:
|
2016-08-31 19:48:03 +02:00
|
|
|
d64 = tcg_temp_new_i64();
|
|
|
|
tcg_gen_qemu_ld_i64(d64, addr, da.mem_idx, da.memop | MO_ALIGN_4);
|
2015-09-04 16:43:50 +02:00
|
|
|
tcg_gen_addi_tl(addr, addr, 8);
|
2016-08-31 19:48:03 +02:00
|
|
|
tcg_gen_qemu_ld_i64(cpu_fpr[rd/2+1], addr, da.mem_idx,
|
|
|
|
da.memop | MO_ALIGN_4);
|
|
|
|
tcg_gen_mov_i64(cpu_fpr[rd / 2], d64);
|
2015-09-04 16:43:50 +02:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
g_assert_not_reached();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2015-09-06 17:30:00 +02:00
|
|
|
case GET_ASI_BLOCK:
|
|
|
|
/* Valid for lddfa on aligned registers only. */
|
|
|
|
if (size == 8 && (rd & 7) == 0) {
|
2019-08-23 20:10:58 +02:00
|
|
|
MemOp memop;
|
2015-09-06 17:30:00 +02:00
|
|
|
TCGv eight;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
gen_address_mask(dc, addr);
|
|
|
|
|
2016-06-24 06:54:28 +02:00
|
|
|
/* The first operation checks required alignment. */
|
|
|
|
memop = da.memop | MO_ALIGN_64;
|
2023-02-26 22:15:00 +01:00
|
|
|
eight = tcg_constant_tl(8);
|
2015-09-06 17:30:00 +02:00
|
|
|
for (i = 0; ; ++i) {
|
|
|
|
tcg_gen_qemu_ld_i64(cpu_fpr[rd / 2 + i], addr,
|
2016-06-24 06:54:28 +02:00
|
|
|
da.mem_idx, memop);
|
2015-09-06 17:30:00 +02:00
|
|
|
if (i == 7) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
tcg_gen_add_tl(addr, addr, eight);
|
2016-06-24 06:54:28 +02:00
|
|
|
memop = da.memop;
|
2015-09-06 17:30:00 +02:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
gen_exception(dc, TT_ILL_INSN);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GET_ASI_SHORT:
|
|
|
|
/* Valid for lddfa only. */
|
|
|
|
if (size == 8) {
|
|
|
|
gen_address_mask(dc, addr);
|
2023-05-02 17:12:44 +02:00
|
|
|
tcg_gen_qemu_ld_i64(cpu_fpr[rd / 2], addr, da.mem_idx,
|
|
|
|
da.memop | MO_ALIGN);
|
2015-09-06 17:30:00 +02:00
|
|
|
} else {
|
|
|
|
gen_exception(dc, TT_ILL_INSN);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2015-09-03 06:45:15 +02:00
|
|
|
default:
|
|
|
|
{
|
2023-02-26 22:15:00 +01:00
|
|
|
TCGv_i32 r_asi = tcg_constant_i32(da.asi);
|
2023-05-02 17:12:44 +02:00
|
|
|
TCGv_i32 r_mop = tcg_constant_i32(da.memop | MO_ALIGN);
|
2015-09-03 06:45:15 +02:00
|
|
|
|
|
|
|
save_state(dc);
|
2015-09-09 01:12:46 +02:00
|
|
|
/* According to the table in the UA2011 manual, the only
|
|
|
|
other asis that are valid for ldfa/lddfa/ldqfa are
|
|
|
|
the NO_FAULT asis. We still need a helper for these,
|
|
|
|
but we can just use the integer asi helper for them. */
|
|
|
|
switch (size) {
|
|
|
|
case 4:
|
2016-08-31 19:48:03 +02:00
|
|
|
d64 = tcg_temp_new_i64();
|
|
|
|
gen_helper_ld_asi(d64, cpu_env, addr, r_asi, r_mop);
|
|
|
|
d32 = gen_dest_fpr_F(dc);
|
|
|
|
tcg_gen_extrl_i64_i32(d32, d64);
|
|
|
|
gen_store_fpr_F(dc, rd, d32);
|
2015-09-09 01:12:46 +02:00
|
|
|
break;
|
|
|
|
case 8:
|
|
|
|
gen_helper_ld_asi(cpu_fpr[rd / 2], cpu_env, addr, r_asi, r_mop);
|
|
|
|
break;
|
|
|
|
case 16:
|
2016-08-31 19:48:03 +02:00
|
|
|
d64 = tcg_temp_new_i64();
|
|
|
|
gen_helper_ld_asi(d64, cpu_env, addr, r_asi, r_mop);
|
2015-09-09 01:12:46 +02:00
|
|
|
tcg_gen_addi_tl(addr, addr, 8);
|
|
|
|
gen_helper_ld_asi(cpu_fpr[rd/2+1], cpu_env, addr, r_asi, r_mop);
|
2016-08-31 19:48:03 +02:00
|
|
|
tcg_gen_mov_i64(cpu_fpr[rd / 2], d64);
|
2015-09-09 01:12:46 +02:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
g_assert_not_reached();
|
|
|
|
}
|
2015-09-03 06:45:15 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2008-02-24 15:10:06 +01:00
|
|
|
}
|
|
|
|
|
2015-09-03 06:22:41 +02:00
|
|
|
static void gen_stf_asi(DisasContext *dc, TCGv addr,
|
|
|
|
int insn, int size, int rd)
|
2008-02-24 15:10:06 +01:00
|
|
|
{
|
2022-01-06 22:00:51 +01:00
|
|
|
DisasASI da = get_asi(dc, insn, (size == 4 ? MO_TEUL : MO_TEUQ));
|
2015-09-04 16:43:50 +02:00
|
|
|
TCGv_i32 d32;
|
2008-02-24 15:10:06 +01:00
|
|
|
|
2015-09-03 06:45:15 +02:00
|
|
|
switch (da.type) {
|
|
|
|
case GET_ASI_EXCP:
|
|
|
|
break;
|
2015-09-04 16:43:50 +02:00
|
|
|
|
|
|
|
case GET_ASI_DIRECT:
|
|
|
|
gen_address_mask(dc, addr);
|
|
|
|
switch (size) {
|
|
|
|
case 4:
|
|
|
|
d32 = gen_load_fpr_F(dc, rd);
|
2023-05-02 17:12:44 +02:00
|
|
|
tcg_gen_qemu_st_i32(d32, addr, da.mem_idx, da.memop | MO_ALIGN);
|
2015-09-04 16:43:50 +02:00
|
|
|
break;
|
|
|
|
case 8:
|
2016-08-31 19:48:03 +02:00
|
|
|
tcg_gen_qemu_st_i64(cpu_fpr[rd / 2], addr, da.mem_idx,
|
|
|
|
da.memop | MO_ALIGN_4);
|
2015-09-04 16:43:50 +02:00
|
|
|
break;
|
|
|
|
case 16:
|
2016-08-31 19:48:03 +02:00
|
|
|
/* Only 4-byte alignment required. However, it is legal for the
|
|
|
|
cpu to signal the alignment fault, and the OS trap handler is
|
|
|
|
required to fix it up. Requiring 16-byte alignment here avoids
|
|
|
|
having to probe the second page before performing the first
|
|
|
|
write. */
|
2016-07-14 20:47:08 +02:00
|
|
|
tcg_gen_qemu_st_i64(cpu_fpr[rd / 2], addr, da.mem_idx,
|
|
|
|
da.memop | MO_ALIGN_16);
|
2015-09-04 16:43:50 +02:00
|
|
|
tcg_gen_addi_tl(addr, addr, 8);
|
|
|
|
tcg_gen_qemu_st_i64(cpu_fpr[rd/2+1], addr, da.mem_idx, da.memop);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
g_assert_not_reached();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2015-09-06 17:30:00 +02:00
|
|
|
case GET_ASI_BLOCK:
|
|
|
|
/* Valid for stdfa on aligned registers only. */
|
|
|
|
if (size == 8 && (rd & 7) == 0) {
|
2019-08-23 20:10:58 +02:00
|
|
|
MemOp memop;
|
2015-09-06 17:30:00 +02:00
|
|
|
TCGv eight;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
gen_address_mask(dc, addr);
|
|
|
|
|
2016-06-24 06:54:28 +02:00
|
|
|
/* The first operation checks required alignment. */
|
|
|
|
memop = da.memop | MO_ALIGN_64;
|
2023-02-26 22:15:00 +01:00
|
|
|
eight = tcg_constant_tl(8);
|
2015-09-06 17:30:00 +02:00
|
|
|
for (i = 0; ; ++i) {
|
|
|
|
tcg_gen_qemu_st_i64(cpu_fpr[rd / 2 + i], addr,
|
2016-06-24 06:54:28 +02:00
|
|
|
da.mem_idx, memop);
|
2015-09-06 17:30:00 +02:00
|
|
|
if (i == 7) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
tcg_gen_add_tl(addr, addr, eight);
|
2016-06-24 06:54:28 +02:00
|
|
|
memop = da.memop;
|
2015-09-06 17:30:00 +02:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
gen_exception(dc, TT_ILL_INSN);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GET_ASI_SHORT:
|
|
|
|
/* Valid for stdfa only. */
|
|
|
|
if (size == 8) {
|
|
|
|
gen_address_mask(dc, addr);
|
2023-05-02 17:12:44 +02:00
|
|
|
tcg_gen_qemu_st_i64(cpu_fpr[rd / 2], addr, da.mem_idx,
|
|
|
|
da.memop | MO_ALIGN);
|
2015-09-06 17:30:00 +02:00
|
|
|
} else {
|
|
|
|
gen_exception(dc, TT_ILL_INSN);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2015-09-03 06:45:15 +02:00
|
|
|
default:
|
2015-09-09 01:12:46 +02:00
|
|
|
/* According to the table in the UA2011 manual, the only
|
|
|
|
other asis that are valid for ldfa/lddfa/ldqfa are
|
|
|
|
the PST* asis, which aren't currently handled. */
|
|
|
|
gen_exception(dc, TT_ILL_INSN);
|
2015-09-03 06:45:15 +02:00
|
|
|
break;
|
|
|
|
}
|
2008-02-24 15:10:06 +01:00
|
|
|
}
|
|
|
|
|
2015-09-03 22:13:35 +02:00
|
|
|
static void gen_ldda_asi(DisasContext *dc, TCGv addr, int insn, int rd)
|
2008-02-24 15:10:06 +01:00
|
|
|
{
|
2022-01-06 22:00:51 +01:00
|
|
|
DisasASI da = get_asi(dc, insn, MO_TEUQ);
|
2015-09-03 22:13:35 +02:00
|
|
|
TCGv_i64 hi = gen_dest_gpr(dc, rd);
|
|
|
|
TCGv_i64 lo = gen_dest_gpr(dc, rd + 1);
|
2008-02-24 15:10:06 +01:00
|
|
|
|
2015-09-03 06:45:15 +02:00
|
|
|
switch (da.type) {
|
|
|
|
case GET_ASI_EXCP:
|
2015-09-03 22:13:35 +02:00
|
|
|
return;
|
|
|
|
|
|
|
|
case GET_ASI_DTWINX:
|
|
|
|
gen_address_mask(dc, addr);
|
2016-06-24 06:54:28 +02:00
|
|
|
tcg_gen_qemu_ld_i64(hi, addr, da.mem_idx, da.memop | MO_ALIGN_16);
|
2015-09-03 22:13:35 +02:00
|
|
|
tcg_gen_addi_tl(addr, addr, 8);
|
|
|
|
tcg_gen_qemu_ld_i64(lo, addr, da.mem_idx, da.memop);
|
2015-09-03 06:45:15 +02:00
|
|
|
break;
|
2015-09-03 22:13:35 +02:00
|
|
|
|
|
|
|
case GET_ASI_DIRECT:
|
|
|
|
{
|
|
|
|
TCGv_i64 tmp = tcg_temp_new_i64();
|
|
|
|
|
|
|
|
gen_address_mask(dc, addr);
|
2023-05-02 17:12:44 +02:00
|
|
|
tcg_gen_qemu_ld_i64(tmp, addr, da.mem_idx, da.memop | MO_ALIGN);
|
2015-09-03 22:13:35 +02:00
|
|
|
|
|
|
|
/* Note that LE ldda acts as if each 32-bit register
|
|
|
|
result is byte swapped. Having just performed one
|
|
|
|
64-bit bswap, we need now to swap the writebacks. */
|
|
|
|
if ((da.memop & MO_BSWAP) == MO_TE) {
|
|
|
|
tcg_gen_extr32_i64(lo, hi, tmp);
|
|
|
|
} else {
|
|
|
|
tcg_gen_extr32_i64(hi, lo, tmp);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2015-09-03 06:45:15 +02:00
|
|
|
default:
|
2016-07-13 00:09:54 +02:00
|
|
|
/* ??? In theory we've handled all of the ASIs that are valid
|
|
|
|
for ldda, and this should raise DAE_invalid_asi. However,
|
|
|
|
real hardware allows others. This can be seen with e.g.
|
|
|
|
FreeBSD 10.3 wrt ASI_IC_TAG. */
|
2015-09-03 06:45:15 +02:00
|
|
|
{
|
2023-02-26 22:15:00 +01:00
|
|
|
TCGv_i32 r_asi = tcg_constant_i32(da.asi);
|
|
|
|
TCGv_i32 r_mop = tcg_constant_i32(da.memop);
|
2016-07-13 00:09:54 +02:00
|
|
|
TCGv_i64 tmp = tcg_temp_new_i64();
|
2015-09-03 06:45:15 +02:00
|
|
|
|
|
|
|
save_state(dc);
|
2016-07-13 00:09:54 +02:00
|
|
|
gen_helper_ld_asi(tmp, cpu_env, addr, r_asi, r_mop);
|
2015-09-03 17:42:23 +02:00
|
|
|
|
2016-07-13 00:09:54 +02:00
|
|
|
/* See above. */
|
|
|
|
if ((da.memop & MO_BSWAP) == MO_TE) {
|
|
|
|
tcg_gen_extr32_i64(lo, hi, tmp);
|
|
|
|
} else {
|
|
|
|
tcg_gen_extr32_i64(hi, lo, tmp);
|
|
|
|
}
|
2015-09-03 06:45:15 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2015-09-03 22:13:35 +02:00
|
|
|
|
|
|
|
gen_store_gpr(dc, rd, hi);
|
|
|
|
gen_store_gpr(dc, rd + 1, lo);
|
2008-03-16 20:18:54 +01:00
|
|
|
}
|
|
|
|
|
2015-09-03 06:22:41 +02:00
|
|
|
static void gen_stda_asi(DisasContext *dc, TCGv hi, TCGv addr,
|
|
|
|
int insn, int rd)
|
2008-03-16 20:18:54 +01:00
|
|
|
{
|
2022-01-06 22:00:51 +01:00
|
|
|
DisasASI da = get_asi(dc, insn, MO_TEUQ);
|
2012-10-16 11:32:15 +02:00
|
|
|
TCGv lo = gen_load_gpr(dc, rd + 1);
|
2008-09-21 16:49:09 +02:00
|
|
|
|
2015-09-03 06:45:15 +02:00
|
|
|
switch (da.type) {
|
|
|
|
case GET_ASI_EXCP:
|
|
|
|
break;
|
2015-09-03 22:13:35 +02:00
|
|
|
|
|
|
|
case GET_ASI_DTWINX:
|
|
|
|
gen_address_mask(dc, addr);
|
2016-06-24 06:54:28 +02:00
|
|
|
tcg_gen_qemu_st_i64(hi, addr, da.mem_idx, da.memop | MO_ALIGN_16);
|
2015-09-03 22:13:35 +02:00
|
|
|
tcg_gen_addi_tl(addr, addr, 8);
|
|
|
|
tcg_gen_qemu_st_i64(lo, addr, da.mem_idx, da.memop);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GET_ASI_DIRECT:
|
|
|
|
{
|
|
|
|
TCGv_i64 t64 = tcg_temp_new_i64();
|
|
|
|
|
|
|
|
/* Note that LE stda acts as if each 32-bit register result is
|
|
|
|
byte swapped. We will perform one 64-bit LE store, so now
|
|
|
|
we must swap the order of the construction. */
|
|
|
|
if ((da.memop & MO_BSWAP) == MO_TE) {
|
|
|
|
tcg_gen_concat32_i64(t64, lo, hi);
|
|
|
|
} else {
|
|
|
|
tcg_gen_concat32_i64(t64, hi, lo);
|
|
|
|
}
|
|
|
|
gen_address_mask(dc, addr);
|
2023-05-02 17:12:44 +02:00
|
|
|
tcg_gen_qemu_st_i64(t64, addr, da.mem_idx, da.memop | MO_ALIGN);
|
2015-09-03 22:13:35 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2015-09-03 06:45:15 +02:00
|
|
|
default:
|
2016-07-13 00:09:54 +02:00
|
|
|
/* ??? In theory we've handled all of the ASIs that are valid
|
|
|
|
for stda, and this should raise DAE_invalid_asi. */
|
2015-09-03 06:45:15 +02:00
|
|
|
{
|
2023-02-26 22:15:00 +01:00
|
|
|
TCGv_i32 r_asi = tcg_constant_i32(da.asi);
|
|
|
|
TCGv_i32 r_mop = tcg_constant_i32(da.memop);
|
2016-07-13 00:09:54 +02:00
|
|
|
TCGv_i64 t64 = tcg_temp_new_i64();
|
2015-09-03 06:45:15 +02:00
|
|
|
|
2016-07-13 00:09:54 +02:00
|
|
|
/* See above. */
|
|
|
|
if ((da.memop & MO_BSWAP) == MO_TE) {
|
|
|
|
tcg_gen_concat32_i64(t64, lo, hi);
|
|
|
|
} else {
|
|
|
|
tcg_gen_concat32_i64(t64, hi, lo);
|
|
|
|
}
|
2015-09-03 06:45:15 +02:00
|
|
|
|
2016-07-13 00:09:54 +02:00
|
|
|
save_state(dc);
|
2015-09-03 22:37:09 +02:00
|
|
|
gen_helper_st_asi(cpu_env, addr, t64, r_asi, r_mop);
|
2015-09-03 06:45:15 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2008-02-24 15:10:06 +01:00
|
|
|
}
|
|
|
|
|
2016-07-13 01:10:32 +02:00
|
|
|
static void gen_casx_asi(DisasContext *dc, TCGv addr, TCGv cmpv,
|
2015-09-03 06:22:41 +02:00
|
|
|
int insn, int rd)
|
2008-02-24 15:10:06 +01:00
|
|
|
{
|
2022-01-06 22:00:51 +01:00
|
|
|
DisasASI da = get_asi(dc, insn, MO_TEUQ);
|
2016-09-13 04:11:18 +02:00
|
|
|
TCGv oldv;
|
2008-02-24 15:10:06 +01:00
|
|
|
|
2016-07-13 01:10:32 +02:00
|
|
|
switch (da.type) {
|
|
|
|
case GET_ASI_EXCP:
|
2015-09-03 06:45:15 +02:00
|
|
|
return;
|
2016-07-13 01:10:32 +02:00
|
|
|
case GET_ASI_DIRECT:
|
|
|
|
oldv = tcg_temp_new();
|
2016-09-13 04:11:18 +02:00
|
|
|
tcg_gen_atomic_cmpxchg_tl(oldv, addr, cmpv, gen_load_gpr(dc, rd),
|
2023-05-02 17:12:44 +02:00
|
|
|
da.mem_idx, da.memop | MO_ALIGN);
|
2016-07-13 01:10:32 +02:00
|
|
|
gen_store_gpr(dc, rd, oldv);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
/* ??? Should be DAE_invalid_asi. */
|
|
|
|
gen_exception(dc, TT_DATA_ACCESS);
|
|
|
|
break;
|
|
|
|
}
|
2008-02-24 15:10:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
#elif !defined(CONFIG_USER_ONLY)
|
2015-09-03 22:13:35 +02:00
|
|
|
static void gen_ldda_asi(DisasContext *dc, TCGv addr, int insn, int rd)
|
2008-02-24 15:10:06 +01:00
|
|
|
{
|
2013-09-19 19:51:12 +02:00
|
|
|
/* ??? Work around an apparent bug in Ubuntu gcc 4.8.2-10ubuntu2+12,
|
|
|
|
whereby "rd + 1" elicits "error: array subscript is above array".
|
|
|
|
Since we have already asserted that rd is even, the semantics
|
|
|
|
are unchanged. */
|
2015-09-03 06:45:15 +02:00
|
|
|
TCGv lo = gen_dest_gpr(dc, rd | 1);
|
2015-09-03 22:13:35 +02:00
|
|
|
TCGv hi = gen_dest_gpr(dc, rd);
|
2015-09-03 06:45:15 +02:00
|
|
|
TCGv_i64 t64 = tcg_temp_new_i64();
|
2022-01-06 22:00:51 +01:00
|
|
|
DisasASI da = get_asi(dc, insn, MO_TEUQ);
|
2015-09-03 06:45:15 +02:00
|
|
|
|
|
|
|
switch (da.type) {
|
|
|
|
case GET_ASI_EXCP:
|
|
|
|
return;
|
2015-09-03 22:13:35 +02:00
|
|
|
case GET_ASI_DIRECT:
|
|
|
|
gen_address_mask(dc, addr);
|
2023-05-02 17:12:44 +02:00
|
|
|
tcg_gen_qemu_ld_i64(t64, addr, da.mem_idx, da.memop | MO_ALIGN);
|
2015-09-03 22:13:35 +02:00
|
|
|
break;
|
2015-09-03 06:45:15 +02:00
|
|
|
default:
|
|
|
|
{
|
2023-02-26 22:15:00 +01:00
|
|
|
TCGv_i32 r_asi = tcg_constant_i32(da.asi);
|
|
|
|
TCGv_i32 r_mop = tcg_constant_i32(MO_UQ);
|
2015-09-03 06:45:15 +02:00
|
|
|
|
|
|
|
save_state(dc);
|
2015-09-03 22:37:09 +02:00
|
|
|
gen_helper_ld_asi(t64, cpu_env, addr, r_asi, r_mop);
|
2015-09-03 06:45:15 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2012-10-16 11:32:15 +02:00
|
|
|
|
2015-09-03 06:45:15 +02:00
|
|
|
tcg_gen_extr_i64_i32(lo, hi, t64);
|
|
|
|
gen_store_gpr(dc, rd | 1, lo);
|
2012-10-16 11:32:15 +02:00
|
|
|
gen_store_gpr(dc, rd, hi);
|
2008-03-16 20:18:54 +01:00
|
|
|
}
|
|
|
|
|
2015-09-03 06:22:41 +02:00
|
|
|
static void gen_stda_asi(DisasContext *dc, TCGv hi, TCGv addr,
|
|
|
|
int insn, int rd)
|
2008-03-16 20:18:54 +01:00
|
|
|
{
|
2022-01-06 22:00:51 +01:00
|
|
|
DisasASI da = get_asi(dc, insn, MO_TEUQ);
|
2012-10-16 11:32:15 +02:00
|
|
|
TCGv lo = gen_load_gpr(dc, rd + 1);
|
2012-10-16 11:32:25 +02:00
|
|
|
TCGv_i64 t64 = tcg_temp_new_i64();
|
2008-09-21 16:49:09 +02:00
|
|
|
|
2012-10-16 11:32:25 +02:00
|
|
|
tcg_gen_concat_tl_i64(t64, lo, hi);
|
2015-09-03 06:45:15 +02:00
|
|
|
|
|
|
|
switch (da.type) {
|
|
|
|
case GET_ASI_EXCP:
|
|
|
|
break;
|
2015-09-03 22:13:35 +02:00
|
|
|
case GET_ASI_DIRECT:
|
|
|
|
gen_address_mask(dc, addr);
|
2023-05-02 17:12:44 +02:00
|
|
|
tcg_gen_qemu_st_i64(t64, addr, da.mem_idx, da.memop | MO_ALIGN);
|
2015-09-03 22:13:35 +02:00
|
|
|
break;
|
2016-07-14 21:46:19 +02:00
|
|
|
case GET_ASI_BFILL:
|
|
|
|
/* Store 32 bytes of T64 to ADDR. */
|
|
|
|
/* ??? The original qemu code suggests 8-byte alignment, dropping
|
|
|
|
the low bits, but the only place I can see this used is in the
|
|
|
|
Linux kernel with 32 byte alignment, which would make more sense
|
|
|
|
as a cacheline-style operation. */
|
|
|
|
{
|
|
|
|
TCGv d_addr = tcg_temp_new();
|
2023-02-26 22:15:00 +01:00
|
|
|
TCGv eight = tcg_constant_tl(8);
|
2016-07-14 21:46:19 +02:00
|
|
|
int i;
|
|
|
|
|
|
|
|
tcg_gen_andi_tl(d_addr, addr, -8);
|
|
|
|
for (i = 0; i < 32; i += 8) {
|
|
|
|
tcg_gen_qemu_st_i64(t64, d_addr, da.mem_idx, da.memop);
|
|
|
|
tcg_gen_add_tl(d_addr, d_addr, eight);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2015-09-03 06:45:15 +02:00
|
|
|
default:
|
|
|
|
{
|
2023-02-26 22:15:00 +01:00
|
|
|
TCGv_i32 r_asi = tcg_constant_i32(da.asi);
|
|
|
|
TCGv_i32 r_mop = tcg_constant_i32(MO_UQ);
|
2015-09-03 06:45:15 +02:00
|
|
|
|
|
|
|
save_state(dc);
|
2015-09-03 22:37:09 +02:00
|
|
|
gen_helper_st_asi(cpu_env, addr, t64, r_asi, r_mop);
|
2015-09-03 06:45:15 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2008-02-24 15:10:06 +01:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2012-10-16 11:32:14 +02:00
|
|
|
static TCGv get_src1(DisasContext *dc, unsigned int insn)
|
2008-03-29 21:38:35 +01:00
|
|
|
{
|
2012-10-16 11:32:14 +02:00
|
|
|
unsigned int rs1 = GET_FIELD(insn, 13, 17);
|
|
|
|
return gen_load_gpr(dc, rs1);
|
2008-03-29 21:38:35 +01:00
|
|
|
}
|
|
|
|
|
2012-10-16 11:32:14 +02:00
|
|
|
static TCGv get_src2(DisasContext *dc, unsigned int insn)
|
2008-03-29 21:39:41 +01:00
|
|
|
{
|
|
|
|
if (IS_IMM) { /* immediate */
|
2010-04-17 18:25:08 +02:00
|
|
|
target_long simm = GET_FIELDs(insn, 19, 31);
|
2023-02-25 08:24:23 +01:00
|
|
|
TCGv t = tcg_temp_new();
|
2012-10-16 11:32:14 +02:00
|
|
|
tcg_gen_movi_tl(t, simm);
|
|
|
|
return t;
|
|
|
|
} else { /* register */
|
2010-04-17 18:25:08 +02:00
|
|
|
unsigned int rs2 = GET_FIELD(insn, 27, 31);
|
2012-10-16 11:32:14 +02:00
|
|
|
return gen_load_gpr(dc, rs2);
|
2008-03-29 21:39:41 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-08-03 21:15:02 +02:00
|
|
|
#ifdef TARGET_SPARC64
|
2012-10-06 01:54:59 +02:00
|
|
|
static void gen_fmovs(DisasContext *dc, DisasCompare *cmp, int rd, int rs)
|
|
|
|
{
|
|
|
|
TCGv_i32 c32, zero, dst, s1, s2;
|
|
|
|
|
|
|
|
/* We have two choices here: extend the 32 bit data and use movcond_i64,
|
|
|
|
or fold the comparison down to 32 bits and use movcond_i32. Choose
|
|
|
|
the later. */
|
|
|
|
c32 = tcg_temp_new_i32();
|
|
|
|
if (cmp->is_bool) {
|
2015-07-24 20:49:53 +02:00
|
|
|
tcg_gen_extrl_i64_i32(c32, cmp->c1);
|
2012-10-06 01:54:59 +02:00
|
|
|
} else {
|
|
|
|
TCGv_i64 c64 = tcg_temp_new_i64();
|
|
|
|
tcg_gen_setcond_i64(cmp->cond, c64, cmp->c1, cmp->c2);
|
2015-07-24 20:49:53 +02:00
|
|
|
tcg_gen_extrl_i64_i32(c32, c64);
|
2012-10-06 01:54:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
s1 = gen_load_fpr_F(dc, rs);
|
|
|
|
s2 = gen_load_fpr_F(dc, rd);
|
2012-10-16 11:32:21 +02:00
|
|
|
dst = gen_dest_fpr_F(dc);
|
2023-02-26 22:15:00 +01:00
|
|
|
zero = tcg_constant_i32(0);
|
2012-10-06 01:54:59 +02:00
|
|
|
|
|
|
|
tcg_gen_movcond_i32(TCG_COND_NE, dst, c32, zero, s1, s2);
|
|
|
|
|
|
|
|
gen_store_fpr_F(dc, rd, dst);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void gen_fmovd(DisasContext *dc, DisasCompare *cmp, int rd, int rs)
|
|
|
|
{
|
2012-10-16 11:32:26 +02:00
|
|
|
TCGv_i64 dst = gen_dest_fpr_D(dc, rd);
|
2012-10-06 01:54:59 +02:00
|
|
|
tcg_gen_movcond_i64(cmp->cond, dst, cmp->c1, cmp->c2,
|
|
|
|
gen_load_fpr_D(dc, rs),
|
|
|
|
gen_load_fpr_D(dc, rd));
|
|
|
|
gen_store_fpr_D(dc, rd, dst);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void gen_fmovq(DisasContext *dc, DisasCompare *cmp, int rd, int rs)
|
|
|
|
{
|
|
|
|
int qd = QFPREG(rd);
|
|
|
|
int qs = QFPREG(rs);
|
|
|
|
|
|
|
|
tcg_gen_movcond_i64(cmp->cond, cpu_fpr[qd / 2], cmp->c1, cmp->c2,
|
|
|
|
cpu_fpr[qs / 2], cpu_fpr[qd / 2]);
|
|
|
|
tcg_gen_movcond_i64(cmp->cond, cpu_fpr[qd / 2 + 1], cmp->c1, cmp->c2,
|
|
|
|
cpu_fpr[qs / 2 + 1], cpu_fpr[qd / 2 + 1]);
|
|
|
|
|
2015-09-09 20:56:38 +02:00
|
|
|
gen_update_fprs_dirty(dc, qd);
|
2012-10-06 01:54:59 +02:00
|
|
|
}
|
|
|
|
|
2014-12-23 23:11:20 +01:00
|
|
|
#ifndef CONFIG_USER_ONLY
|
2016-02-25 17:43:15 +01:00
|
|
|
static inline void gen_load_trap_state_at_tl(TCGv_ptr r_tsptr, TCGv_env cpu_env)
|
2009-08-03 21:15:02 +02:00
|
|
|
{
|
2010-02-20 11:45:23 +01:00
|
|
|
TCGv_i32 r_tl = tcg_temp_new_i32();
|
2009-08-03 21:15:02 +02:00
|
|
|
|
|
|
|
/* load env->tl into r_tl */
|
2010-02-20 11:45:23 +01:00
|
|
|
tcg_gen_ld_i32(r_tl, cpu_env, offsetof(CPUSPARCState, tl));
|
2009-08-03 21:15:02 +02:00
|
|
|
|
|
|
|
/* tl = [0 ... MAXTL_MASK] where MAXTL_MASK must be power of 2 */
|
2010-02-20 11:45:23 +01:00
|
|
|
tcg_gen_andi_i32(r_tl, r_tl, MAXTL_MASK);
|
2009-08-03 21:15:02 +02:00
|
|
|
|
|
|
|
/* calculate offset to current trap state from env->ts, reuse r_tl */
|
2010-02-20 11:45:23 +01:00
|
|
|
tcg_gen_muli_i32(r_tl, r_tl, sizeof (trap_state));
|
2012-03-14 01:38:22 +01:00
|
|
|
tcg_gen_addi_ptr(r_tsptr, cpu_env, offsetof(CPUSPARCState, ts));
|
2009-08-03 21:15:02 +02:00
|
|
|
|
|
|
|
/* tsptr = env->ts[env->tl & MAXTL_MASK] */
|
2010-02-20 11:45:23 +01:00
|
|
|
{
|
|
|
|
TCGv_ptr r_tl_tmp = tcg_temp_new_ptr();
|
|
|
|
tcg_gen_ext_i32_ptr(r_tl_tmp, r_tl);
|
|
|
|
tcg_gen_add_ptr(r_tsptr, r_tsptr, r_tl_tmp);
|
|
|
|
}
|
2009-08-03 21:15:02 +02:00
|
|
|
}
|
2014-12-23 23:11:20 +01:00
|
|
|
#endif
|
2011-10-18 04:57:23 +02:00
|
|
|
|
|
|
|
static void gen_edge(DisasContext *dc, TCGv dst, TCGv s1, TCGv s2,
|
|
|
|
int width, bool cc, bool left)
|
|
|
|
{
|
2023-02-26 22:14:48 +01:00
|
|
|
TCGv lo1, lo2;
|
2011-10-18 04:57:23 +02:00
|
|
|
uint64_t amask, tabl, tabr;
|
|
|
|
int shift, imask, omask;
|
|
|
|
|
|
|
|
if (cc) {
|
|
|
|
tcg_gen_mov_tl(cpu_cc_src, s1);
|
|
|
|
tcg_gen_mov_tl(cpu_cc_src2, s2);
|
|
|
|
tcg_gen_sub_tl(cpu_cc_dst, s1, s2);
|
|
|
|
tcg_gen_movi_i32(cpu_cc_op, CC_OP_SUB);
|
|
|
|
dc->cc_op = CC_OP_SUB;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Theory of operation: there are two tables, left and right (not to
|
|
|
|
be confused with the left and right versions of the opcode). These
|
|
|
|
are indexed by the low 3 bits of the inputs. To make things "easy",
|
|
|
|
these tables are loaded into two constants, TABL and TABR below.
|
|
|
|
The operation index = (input & imask) << shift calculates the index
|
|
|
|
into the constant, while val = (table >> index) & omask calculates
|
|
|
|
the value we're looking for. */
|
|
|
|
switch (width) {
|
|
|
|
case 8:
|
|
|
|
imask = 0x7;
|
|
|
|
shift = 3;
|
|
|
|
omask = 0xff;
|
|
|
|
if (left) {
|
|
|
|
tabl = 0x80c0e0f0f8fcfeffULL;
|
|
|
|
tabr = 0xff7f3f1f0f070301ULL;
|
|
|
|
} else {
|
|
|
|
tabl = 0x0103070f1f3f7fffULL;
|
|
|
|
tabr = 0xfffefcf8f0e0c080ULL;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 16:
|
|
|
|
imask = 0x6;
|
|
|
|
shift = 1;
|
|
|
|
omask = 0xf;
|
|
|
|
if (left) {
|
|
|
|
tabl = 0x8cef;
|
|
|
|
tabr = 0xf731;
|
|
|
|
} else {
|
|
|
|
tabl = 0x137f;
|
|
|
|
tabr = 0xfec8;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 32:
|
|
|
|
imask = 0x4;
|
|
|
|
shift = 0;
|
|
|
|
omask = 0x3;
|
|
|
|
if (left) {
|
|
|
|
tabl = (2 << 2) | 3;
|
|
|
|
tabr = (3 << 2) | 1;
|
|
|
|
} else {
|
|
|
|
tabl = (1 << 2) | 3;
|
|
|
|
tabr = (3 << 2) | 2;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
abort();
|
|
|
|
}
|
|
|
|
|
|
|
|
lo1 = tcg_temp_new();
|
|
|
|
lo2 = tcg_temp_new();
|
|
|
|
tcg_gen_andi_tl(lo1, s1, imask);
|
|
|
|
tcg_gen_andi_tl(lo2, s2, imask);
|
|
|
|
tcg_gen_shli_tl(lo1, lo1, shift);
|
|
|
|
tcg_gen_shli_tl(lo2, lo2, shift);
|
|
|
|
|
2023-02-26 22:14:48 +01:00
|
|
|
tcg_gen_shr_tl(lo1, tcg_constant_tl(tabl), lo1);
|
|
|
|
tcg_gen_shr_tl(lo2, tcg_constant_tl(tabr), lo2);
|
2011-10-18 04:57:23 +02:00
|
|
|
tcg_gen_andi_tl(dst, lo1, omask);
|
|
|
|
tcg_gen_andi_tl(lo2, lo2, omask);
|
|
|
|
|
|
|
|
amask = -8;
|
|
|
|
if (AM_CHECK(dc)) {
|
|
|
|
amask &= 0xffffffffULL;
|
|
|
|
}
|
|
|
|
tcg_gen_andi_tl(s1, s1, amask);
|
|
|
|
tcg_gen_andi_tl(s2, s2, amask);
|
|
|
|
|
|
|
|
/* We want to compute
|
|
|
|
dst = (s1 == s2 ? lo1 : lo1 & lo2).
|
|
|
|
We've already done dst = lo1, so this reduces to
|
|
|
|
dst &= (s1 == s2 ? -1 : lo2)
|
|
|
|
Which we perform by
|
|
|
|
lo2 |= -(s1 == s2)
|
|
|
|
dst &= lo2
|
|
|
|
*/
|
2023-02-26 22:14:48 +01:00
|
|
|
tcg_gen_setcond_tl(TCG_COND_EQ, lo1, s1, s2);
|
|
|
|
tcg_gen_neg_tl(lo1, lo1);
|
|
|
|
tcg_gen_or_tl(lo2, lo2, lo1);
|
2011-10-18 04:57:23 +02:00
|
|
|
tcg_gen_and_tl(dst, dst, lo2);
|
|
|
|
}
|
2011-10-18 17:35:58 +02:00
|
|
|
|
|
|
|
static void gen_alignaddr(TCGv dst, TCGv s1, TCGv s2, bool left)
|
|
|
|
{
|
|
|
|
TCGv tmp = tcg_temp_new();
|
|
|
|
|
|
|
|
tcg_gen_add_tl(tmp, s1, s2);
|
|
|
|
tcg_gen_andi_tl(dst, tmp, -8);
|
|
|
|
if (left) {
|
|
|
|
tcg_gen_neg_tl(tmp, tmp);
|
|
|
|
}
|
|
|
|
tcg_gen_deposit_tl(cpu_gsr, cpu_gsr, tmp, 0, 3);
|
|
|
|
}
|
2011-10-18 18:41:30 +02:00
|
|
|
|
|
|
|
static void gen_faligndata(TCGv dst, TCGv gsr, TCGv s1, TCGv s2)
|
|
|
|
{
|
|
|
|
TCGv t1, t2, shift;
|
|
|
|
|
|
|
|
t1 = tcg_temp_new();
|
|
|
|
t2 = tcg_temp_new();
|
|
|
|
shift = tcg_temp_new();
|
|
|
|
|
|
|
|
tcg_gen_andi_tl(shift, gsr, 7);
|
|
|
|
tcg_gen_shli_tl(shift, shift, 3);
|
|
|
|
tcg_gen_shl_tl(t1, s1, shift);
|
|
|
|
|
|
|
|
/* A shift of 64 does not produce 0 in TCG. Divide this into a
|
|
|
|
shift of (up to 63) followed by a constant shift of 1. */
|
|
|
|
tcg_gen_xori_tl(shift, shift, 63);
|
|
|
|
tcg_gen_shr_tl(t2, s2, shift);
|
|
|
|
tcg_gen_shri_tl(t2, t2, 1);
|
|
|
|
|
|
|
|
tcg_gen_or_tl(dst, t1, t2);
|
|
|
|
}
|
2009-08-03 21:15:02 +02:00
|
|
|
#endif
|
|
|
|
|
2008-05-09 22:13:43 +02:00
|
|
|
#define CHECK_IU_FEATURE(dc, FEATURE) \
|
2008-08-21 19:33:42 +02:00
|
|
|
if (!((dc)->def->features & CPU_FEATURE_ ## FEATURE)) \
|
2008-05-09 22:13:43 +02:00
|
|
|
goto illegal_insn;
|
|
|
|
#define CHECK_FPU_FEATURE(dc, FEATURE) \
|
2008-08-21 19:33:42 +02:00
|
|
|
if (!((dc)->def->features & CPU_FEATURE_ ## FEATURE)) \
|
2008-05-09 22:13:43 +02:00
|
|
|
goto nfpu_insn;
|
|
|
|
|
2005-02-13 21:11:30 +01:00
|
|
|
/* before an instruction, dc->pc must be static */
|
2011-08-01 14:19:05 +02:00
|
|
|
static void disas_sparc_insn(DisasContext * dc, unsigned int insn)
|
2004-01-04 16:01:44 +01:00
|
|
|
{
|
2011-08-01 14:19:05 +02:00
|
|
|
unsigned int opc, rs1, rs2, rd;
|
2012-10-16 11:32:18 +02:00
|
|
|
TCGv cpu_src1, cpu_src2;
|
2011-10-14 23:58:32 +02:00
|
|
|
TCGv_i32 cpu_src1_32, cpu_src2_32, cpu_dst_32;
|
2011-10-15 00:47:35 +02:00
|
|
|
TCGv_i64 cpu_src1_64, cpu_src2_64, cpu_dst_64;
|
2009-05-02 20:58:57 +02:00
|
|
|
target_long simm;
|
2003-09-30 22:36:07 +02:00
|
|
|
|
2004-01-04 16:01:44 +01:00
|
|
|
opc = GET_FIELD(insn, 0, 1);
|
|
|
|
rd = GET_FIELD(insn, 2, 6);
|
2008-03-29 10:09:25 +01:00
|
|
|
|
2004-01-04 16:01:44 +01:00
|
|
|
switch (opc) {
|
2007-09-20 16:54:22 +02:00
|
|
|
case 0: /* branches/sethi */
|
|
|
|
{
|
|
|
|
unsigned int xop = GET_FIELD(insn, 7, 9);
|
|
|
|
int32_t target;
|
|
|
|
switch (xop) {
|
2005-07-02 16:31:34 +02:00
|
|
|
#ifdef TARGET_SPARC64
|
2007-09-20 16:54:22 +02:00
|
|
|
case 0x1: /* V9 BPcc */
|
|
|
|
{
|
|
|
|
int cc;
|
|
|
|
|
|
|
|
target = GET_FIELD_SP(insn, 0, 18);
|
2011-05-14 09:14:57 +02:00
|
|
|
target = sign_extend(target, 19);
|
2007-09-20 16:54:22 +02:00
|
|
|
target <<= 2;
|
|
|
|
cc = GET_FIELD_SP(insn, 20, 21);
|
|
|
|
if (cc == 0)
|
2012-10-06 01:54:50 +02:00
|
|
|
do_branch(dc, target, insn, 0);
|
2007-09-20 16:54:22 +02:00
|
|
|
else if (cc == 2)
|
2012-10-06 01:54:50 +02:00
|
|
|
do_branch(dc, target, insn, 1);
|
2007-09-20 16:54:22 +02:00
|
|
|
else
|
|
|
|
goto illegal_insn;
|
|
|
|
goto jmp_insn;
|
|
|
|
}
|
|
|
|
case 0x3: /* V9 BPr */
|
|
|
|
{
|
|
|
|
target = GET_FIELD_SP(insn, 0, 13) |
|
2006-06-23 23:01:56 +02:00
|
|
|
(GET_FIELD_SP(insn, 20, 21) << 14);
|
2007-09-20 16:54:22 +02:00
|
|
|
target = sign_extend(target, 16);
|
|
|
|
target <<= 2;
|
2012-10-16 11:32:14 +02:00
|
|
|
cpu_src1 = get_src1(dc, insn);
|
2012-10-06 01:54:50 +02:00
|
|
|
do_branch_reg(dc, target, insn, cpu_src1);
|
2007-09-20 16:54:22 +02:00
|
|
|
goto jmp_insn;
|
|
|
|
}
|
|
|
|
case 0x5: /* V9 FBPcc */
|
|
|
|
{
|
|
|
|
int cc = GET_FIELD_SP(insn, 20, 21);
|
2012-10-06 01:54:52 +02:00
|
|
|
if (gen_trap_ifnofpu(dc)) {
|
2006-06-26 21:53:29 +02:00
|
|
|
goto jmp_insn;
|
2012-10-06 01:54:52 +02:00
|
|
|
}
|
2007-09-20 16:54:22 +02:00
|
|
|
target = GET_FIELD_SP(insn, 0, 18);
|
|
|
|
target = sign_extend(target, 19);
|
|
|
|
target <<= 2;
|
2012-10-06 01:54:50 +02:00
|
|
|
do_fbranch(dc, target, insn, cc);
|
2007-09-20 16:54:22 +02:00
|
|
|
goto jmp_insn;
|
|
|
|
}
|
2007-04-05 20:09:15 +02:00
|
|
|
#else
|
2007-09-20 16:54:22 +02:00
|
|
|
case 0x7: /* CBN+x */
|
|
|
|
{
|
|
|
|
goto ncp_insn;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
case 0x2: /* BN+x */
|
|
|
|
{
|
|
|
|
target = GET_FIELD(insn, 10, 31);
|
|
|
|
target = sign_extend(target, 22);
|
|
|
|
target <<= 2;
|
2012-10-06 01:54:50 +02:00
|
|
|
do_branch(dc, target, insn, 0);
|
2007-09-20 16:54:22 +02:00
|
|
|
goto jmp_insn;
|
|
|
|
}
|
|
|
|
case 0x6: /* FBN+x */
|
|
|
|
{
|
2012-10-06 01:54:52 +02:00
|
|
|
if (gen_trap_ifnofpu(dc)) {
|
2006-06-26 21:53:29 +02:00
|
|
|
goto jmp_insn;
|
2012-10-06 01:54:52 +02:00
|
|
|
}
|
2007-09-20 16:54:22 +02:00
|
|
|
target = GET_FIELD(insn, 10, 31);
|
|
|
|
target = sign_extend(target, 22);
|
|
|
|
target <<= 2;
|
2012-10-06 01:54:50 +02:00
|
|
|
do_fbranch(dc, target, insn, 0);
|
2007-09-20 16:54:22 +02:00
|
|
|
goto jmp_insn;
|
|
|
|
}
|
|
|
|
case 0x4: /* SETHI */
|
2012-10-16 11:32:13 +02:00
|
|
|
/* Special-case %g0 because that's the canonical nop. */
|
|
|
|
if (rd) {
|
2007-09-20 16:54:22 +02:00
|
|
|
uint32_t value = GET_FIELD(insn, 10, 31);
|
2012-10-16 11:32:13 +02:00
|
|
|
TCGv t = gen_dest_gpr(dc, rd);
|
|
|
|
tcg_gen_movi_tl(t, value << 10);
|
|
|
|
gen_store_gpr(dc, rd, t);
|
2007-09-20 16:54:22 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0x0: /* UNIMPL */
|
|
|
|
default:
|
2005-07-02 16:31:34 +02:00
|
|
|
goto illegal_insn;
|
2007-09-20 16:54:22 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
2009-05-03 20:51:22 +02:00
|
|
|
case 1: /*CALL*/
|
|
|
|
{
|
2007-09-20 16:54:22 +02:00
|
|
|
target_long target = GET_FIELDs(insn, 2, 31) << 2;
|
2012-10-16 11:32:13 +02:00
|
|
|
TCGv o7 = gen_dest_gpr(dc, 15);
|
2004-01-04 16:01:44 +01:00
|
|
|
|
2012-10-16 11:32:13 +02:00
|
|
|
tcg_gen_movi_tl(o7, dc->pc);
|
|
|
|
gen_store_gpr(dc, 15, o7);
|
2007-09-20 16:54:22 +02:00
|
|
|
target += dc->pc;
|
2012-10-06 01:54:54 +02:00
|
|
|
gen_mov_pc_npc(dc);
|
2012-05-12 11:15:20 +02:00
|
|
|
#ifdef TARGET_SPARC64
|
|
|
|
if (unlikely(AM_CHECK(dc))) {
|
|
|
|
target &= 0xffffffffULL;
|
|
|
|
}
|
|
|
|
#endif
|
2007-09-20 16:54:22 +02:00
|
|
|
dc->npc = target;
|
|
|
|
}
|
|
|
|
goto jmp_insn;
|
|
|
|
case 2: /* FPU & Logical Operations */
|
|
|
|
{
|
|
|
|
unsigned int xop = GET_FIELD(insn, 7, 12);
|
2023-02-25 08:24:23 +01:00
|
|
|
TCGv cpu_dst = tcg_temp_new();
|
2012-10-16 11:32:31 +02:00
|
|
|
TCGv cpu_tmp0;
|
2012-10-16 11:32:30 +02:00
|
|
|
|
2007-09-20 16:54:22 +02:00
|
|
|
if (xop == 0x3a) { /* generate trap */
|
2012-10-06 01:55:04 +02:00
|
|
|
int cond = GET_FIELD(insn, 3, 6);
|
|
|
|
TCGv_i32 trap;
|
2015-02-13 21:51:55 +01:00
|
|
|
TCGLabel *l1 = NULL;
|
|
|
|
int mask;
|
2005-07-02 16:31:34 +02:00
|
|
|
|
2012-10-06 01:55:04 +02:00
|
|
|
if (cond == 0) {
|
|
|
|
/* Trap never. */
|
|
|
|
break;
|
2004-01-04 16:01:44 +01:00
|
|
|
}
|
2011-01-24 12:56:55 +01:00
|
|
|
|
2012-10-06 01:55:04 +02:00
|
|
|
save_state(dc);
|
2011-01-24 12:56:55 +01:00
|
|
|
|
2012-10-06 01:55:04 +02:00
|
|
|
if (cond != 8) {
|
|
|
|
/* Conditional trap. */
|
2012-10-06 01:54:58 +02:00
|
|
|
DisasCompare cmp;
|
2005-07-02 16:31:34 +02:00
|
|
|
#ifdef TARGET_SPARC64
|
2007-09-20 16:54:22 +02:00
|
|
|
/* V9 icc/xcc */
|
|
|
|
int cc = GET_FIELD_SP(insn, 11, 12);
|
2012-10-06 01:54:58 +02:00
|
|
|
if (cc == 0) {
|
|
|
|
gen_compare(&cmp, 0, cond, dc);
|
|
|
|
} else if (cc == 2) {
|
|
|
|
gen_compare(&cmp, 1, cond, dc);
|
|
|
|
} else {
|
2007-09-20 16:54:22 +02:00
|
|
|
goto illegal_insn;
|
2012-10-06 01:54:58 +02:00
|
|
|
}
|
2005-07-02 16:31:34 +02:00
|
|
|
#else
|
2012-10-06 01:54:58 +02:00
|
|
|
gen_compare(&cmp, 0, cond, dc);
|
2005-07-02 16:31:34 +02:00
|
|
|
#endif
|
2008-09-26 20:05:23 +02:00
|
|
|
l1 = gen_new_label();
|
2012-10-06 01:54:58 +02:00
|
|
|
tcg_gen_brcond_tl(tcg_invert_cond(cmp.cond),
|
|
|
|
cmp.c1, cmp.c2, l1);
|
2012-10-06 01:55:04 +02:00
|
|
|
}
|
2008-09-26 20:05:23 +02:00
|
|
|
|
2012-10-06 01:55:04 +02:00
|
|
|
mask = ((dc->def->features & CPU_FEATURE_HYPV) && supervisor(dc)
|
|
|
|
? UA2005_HTRAP_MASK : V8_TRAP_MASK);
|
|
|
|
|
|
|
|
/* Don't use the normal temporaries, as they may well have
|
|
|
|
gone out of scope with the branch above. While we're
|
|
|
|
doing that we might as well pre-truncate to 32-bit. */
|
|
|
|
trap = tcg_temp_new_i32();
|
|
|
|
|
|
|
|
rs1 = GET_FIELD_SP(insn, 14, 18);
|
|
|
|
if (IS_IMM) {
|
2016-06-08 14:17:36 +02:00
|
|
|
rs2 = GET_FIELD_SP(insn, 0, 7);
|
2012-10-06 01:55:04 +02:00
|
|
|
if (rs1 == 0) {
|
|
|
|
tcg_gen_movi_i32(trap, (rs2 & mask) + TT_TRAP);
|
|
|
|
/* Signal that the trap value is fully constant. */
|
|
|
|
mask = 0;
|
|
|
|
} else {
|
2012-10-16 11:32:13 +02:00
|
|
|
TCGv t1 = gen_load_gpr(dc, rs1);
|
2012-10-06 01:55:04 +02:00
|
|
|
tcg_gen_trunc_tl_i32(trap, t1);
|
|
|
|
tcg_gen_addi_i32(trap, trap, rs2);
|
|
|
|
}
|
|
|
|
} else {
|
2012-10-16 11:32:13 +02:00
|
|
|
TCGv t1, t2;
|
2012-10-06 01:55:04 +02:00
|
|
|
rs2 = GET_FIELD_SP(insn, 0, 4);
|
2012-10-16 11:32:13 +02:00
|
|
|
t1 = gen_load_gpr(dc, rs1);
|
|
|
|
t2 = gen_load_gpr(dc, rs2);
|
2012-10-06 01:55:04 +02:00
|
|
|
tcg_gen_add_tl(t1, t1, t2);
|
|
|
|
tcg_gen_trunc_tl_i32(trap, t1);
|
|
|
|
}
|
|
|
|
if (mask != 0) {
|
|
|
|
tcg_gen_andi_i32(trap, trap, mask);
|
|
|
|
tcg_gen_addi_i32(trap, trap, TT_TRAP);
|
|
|
|
}
|
|
|
|
|
|
|
|
gen_helper_raise_exception(cpu_env, trap);
|
2008-09-26 20:05:23 +02:00
|
|
|
|
2012-10-06 01:55:09 +02:00
|
|
|
if (cond == 8) {
|
|
|
|
/* An unconditional trap ends the TB. */
|
2018-02-15 03:16:30 +01:00
|
|
|
dc->base.is_jmp = DISAS_NORETURN;
|
2012-10-06 01:55:09 +02:00
|
|
|
goto jmp_insn;
|
|
|
|
} else {
|
|
|
|
/* A conditional trap falls through to the next insn. */
|
2008-09-26 20:05:23 +02:00
|
|
|
gen_set_label(l1);
|
2012-10-06 01:55:09 +02:00
|
|
|
break;
|
2004-01-04 16:01:44 +01:00
|
|
|
}
|
|
|
|
} else if (xop == 0x28) {
|
|
|
|
rs1 = GET_FIELD(insn, 13, 17);
|
|
|
|
switch(rs1) {
|
|
|
|
case 0: /* rdy */
|
2007-04-01 17:05:09 +02:00
|
|
|
#ifndef TARGET_SPARC64
|
|
|
|
case 0x01 ... 0x0e: /* undefined in the SPARCv8
|
|
|
|
manual, rdy on the microSPARC
|
|
|
|
II */
|
|
|
|
case 0x0f: /* stbar in the SPARCv8 manual,
|
|
|
|
rdy on the microSPARC II */
|
|
|
|
case 0x10 ... 0x1f: /* implementation-dependent in the
|
|
|
|
SPARCv8 manual, rdy on the
|
|
|
|
microSPARC II */
|
2011-01-24 12:56:56 +01:00
|
|
|
/* Read Asr17 */
|
|
|
|
if (rs1 == 0x11 && dc->def->features & CPU_FEATURE_ASR17) {
|
2012-10-16 11:32:13 +02:00
|
|
|
TCGv t = gen_dest_gpr(dc, rd);
|
2011-01-24 12:56:56 +01:00
|
|
|
/* Read Asr17 for a Leon3 monoprocessor */
|
2012-10-16 11:32:13 +02:00
|
|
|
tcg_gen_movi_tl(t, (1 << 8) | (dc->def->nwindows - 1));
|
|
|
|
gen_store_gpr(dc, rd, t);
|
2011-01-24 12:56:56 +01:00
|
|
|
break;
|
|
|
|
}
|
2007-04-01 17:05:09 +02:00
|
|
|
#endif
|
2012-10-16 11:32:13 +02:00
|
|
|
gen_store_gpr(dc, rd, cpu_y);
|
2004-01-04 16:01:44 +01:00
|
|
|
break;
|
2005-07-02 16:31:34 +02:00
|
|
|
#ifdef TARGET_SPARC64
|
2007-09-20 16:54:22 +02:00
|
|
|
case 0x2: /* V9 rdccr */
|
2012-10-09 23:50:00 +02:00
|
|
|
update_psr(dc);
|
2011-07-03 23:01:59 +02:00
|
|
|
gen_helper_rdccr(cpu_dst, cpu_env);
|
2012-10-16 11:32:13 +02:00
|
|
|
gen_store_gpr(dc, rd, cpu_dst);
|
2005-07-02 16:31:34 +02:00
|
|
|
break;
|
2007-09-20 16:54:22 +02:00
|
|
|
case 0x3: /* V9 rdasi */
|
2015-09-03 23:14:33 +02:00
|
|
|
tcg_gen_movi_tl(cpu_dst, dc->asi);
|
2012-10-16 11:32:13 +02:00
|
|
|
gen_store_gpr(dc, rd, cpu_dst);
|
2005-07-02 16:31:34 +02:00
|
|
|
break;
|
2007-09-20 16:54:22 +02:00
|
|
|
case 0x4: /* V9 rdtick */
|
2008-03-02 19:28:06 +01:00
|
|
|
{
|
2008-11-17 15:43:54 +01:00
|
|
|
TCGv_ptr r_tickptr;
|
2015-11-08 18:11:59 +01:00
|
|
|
TCGv_i32 r_const;
|
2008-03-02 19:28:06 +01:00
|
|
|
|
2008-11-17 15:43:54 +01:00
|
|
|
r_tickptr = tcg_temp_new_ptr();
|
2023-02-26 22:15:00 +01:00
|
|
|
r_const = tcg_constant_i32(dc->mem_idx);
|
2008-03-02 19:28:06 +01:00
|
|
|
tcg_gen_ld_ptr(r_tickptr, cpu_env,
|
2012-03-14 01:38:22 +01:00
|
|
|
offsetof(CPUSPARCState, tick));
|
2018-06-15 09:33:03 +02:00
|
|
|
if (tb_cflags(dc->base.tb) & CF_USE_ICOUNT) {
|
|
|
|
gen_io_start();
|
|
|
|
}
|
2015-11-08 18:11:59 +01:00
|
|
|
gen_helper_tick_get_count(cpu_dst, cpu_env, r_tickptr,
|
|
|
|
r_const);
|
2012-10-16 11:32:13 +02:00
|
|
|
gen_store_gpr(dc, rd, cpu_dst);
|
2018-06-15 09:33:03 +02:00
|
|
|
if (tb_cflags(dc->base.tb) & CF_USE_ICOUNT) {
|
2021-07-24 15:49:01 +02:00
|
|
|
/* I/O operations in icount mode must end the TB */
|
|
|
|
dc->base.is_jmp = DISAS_EXIT;
|
2018-06-15 09:33:03 +02:00
|
|
|
}
|
2008-03-02 19:28:06 +01:00
|
|
|
}
|
2005-07-02 16:31:34 +02:00
|
|
|
break;
|
2007-09-20 16:54:22 +02:00
|
|
|
case 0x5: /* V9 rdpc */
|
2008-05-27 21:39:12 +02:00
|
|
|
{
|
2012-10-16 11:32:13 +02:00
|
|
|
TCGv t = gen_dest_gpr(dc, rd);
|
2012-05-12 11:15:20 +02:00
|
|
|
if (unlikely(AM_CHECK(dc))) {
|
2012-10-16 11:32:13 +02:00
|
|
|
tcg_gen_movi_tl(t, dc->pc & 0xffffffffULL);
|
2012-05-12 11:15:20 +02:00
|
|
|
} else {
|
2012-10-16 11:32:13 +02:00
|
|
|
tcg_gen_movi_tl(t, dc->pc);
|
2012-05-12 11:15:20 +02:00
|
|
|
}
|
2012-10-16 11:32:13 +02:00
|
|
|
gen_store_gpr(dc, rd, t);
|
2008-05-27 21:39:12 +02:00
|
|
|
}
|
2007-09-20 16:54:22 +02:00
|
|
|
break;
|
|
|
|
case 0x6: /* V9 rdfprs */
|
2008-09-06 19:51:43 +02:00
|
|
|
tcg_gen_ext_i32_tl(cpu_dst, cpu_fprs);
|
2012-10-16 11:32:13 +02:00
|
|
|
gen_store_gpr(dc, rd, cpu_dst);
|
2005-07-02 16:31:34 +02:00
|
|
|
break;
|
2007-04-01 17:05:09 +02:00
|
|
|
case 0xf: /* V9 membar */
|
|
|
|
break; /* no effect */
|
2007-09-20 16:54:22 +02:00
|
|
|
case 0x13: /* Graphics Status */
|
2012-10-06 01:54:52 +02:00
|
|
|
if (gen_trap_ifnofpu(dc)) {
|
2006-07-18 23:12:17 +02:00
|
|
|
goto jmp_insn;
|
2012-10-06 01:54:52 +02:00
|
|
|
}
|
2012-10-16 11:32:13 +02:00
|
|
|
gen_store_gpr(dc, rd, cpu_gsr);
|
2006-07-18 23:12:17 +02:00
|
|
|
break;
|
2008-09-22 21:50:28 +02:00
|
|
|
case 0x16: /* Softint */
|
2015-08-19 18:58:17 +02:00
|
|
|
tcg_gen_ld32s_tl(cpu_dst, cpu_env,
|
|
|
|
offsetof(CPUSPARCState, softint));
|
2012-10-16 11:32:13 +02:00
|
|
|
gen_store_gpr(dc, rd, cpu_dst);
|
2008-09-22 21:50:28 +02:00
|
|
|
break;
|
2007-09-20 16:54:22 +02:00
|
|
|
case 0x17: /* Tick compare */
|
2012-10-16 11:32:13 +02:00
|
|
|
gen_store_gpr(dc, rd, cpu_tick_cmpr);
|
2005-07-23 16:27:54 +02:00
|
|
|
break;
|
2007-09-20 16:54:22 +02:00
|
|
|
case 0x18: /* System tick */
|
2008-03-02 19:28:06 +01:00
|
|
|
{
|
2008-11-17 15:43:54 +01:00
|
|
|
TCGv_ptr r_tickptr;
|
2015-11-08 18:11:59 +01:00
|
|
|
TCGv_i32 r_const;
|
2008-03-02 19:28:06 +01:00
|
|
|
|
2008-11-17 15:43:54 +01:00
|
|
|
r_tickptr = tcg_temp_new_ptr();
|
2023-02-26 22:15:00 +01:00
|
|
|
r_const = tcg_constant_i32(dc->mem_idx);
|
2008-03-02 19:28:06 +01:00
|
|
|
tcg_gen_ld_ptr(r_tickptr, cpu_env,
|
2012-03-14 01:38:22 +01:00
|
|
|
offsetof(CPUSPARCState, stick));
|
2018-06-15 09:33:03 +02:00
|
|
|
if (tb_cflags(dc->base.tb) & CF_USE_ICOUNT) {
|
|
|
|
gen_io_start();
|
|
|
|
}
|
2015-11-08 18:11:59 +01:00
|
|
|
gen_helper_tick_get_count(cpu_dst, cpu_env, r_tickptr,
|
|
|
|
r_const);
|
2012-10-16 11:32:13 +02:00
|
|
|
gen_store_gpr(dc, rd, cpu_dst);
|
2018-06-15 09:33:03 +02:00
|
|
|
if (tb_cflags(dc->base.tb) & CF_USE_ICOUNT) {
|
2021-07-24 15:49:01 +02:00
|
|
|
/* I/O operations in icount mode must end the TB */
|
|
|
|
dc->base.is_jmp = DISAS_EXIT;
|
2018-06-15 09:33:03 +02:00
|
|
|
}
|
2008-03-02 19:28:06 +01:00
|
|
|
}
|
2005-07-23 16:27:54 +02:00
|
|
|
break;
|
2007-09-20 16:54:22 +02:00
|
|
|
case 0x19: /* System tick compare */
|
2012-10-16 11:32:13 +02:00
|
|
|
gen_store_gpr(dc, rd, cpu_stick_cmpr);
|
2005-07-23 16:27:54 +02:00
|
|
|
break;
|
2016-03-02 14:45:19 +01:00
|
|
|
case 0x1a: /* UltraSPARC-T1 Strand status */
|
|
|
|
/* XXX HYPV check maybe not enough, UA2005 & UA2007 describe
|
|
|
|
* this ASR as impl. dep
|
|
|
|
*/
|
|
|
|
CHECK_IU_FEATURE(dc, HYPV);
|
|
|
|
{
|
|
|
|
TCGv t = gen_dest_gpr(dc, rd);
|
|
|
|
tcg_gen_movi_tl(t, 1UL);
|
|
|
|
gen_store_gpr(dc, rd, t);
|
|
|
|
}
|
|
|
|
break;
|
2007-09-20 16:54:22 +02:00
|
|
|
case 0x10: /* Performance Control */
|
|
|
|
case 0x11: /* Performance Instrumentation Counter */
|
|
|
|
case 0x12: /* Dispatch Control */
|
|
|
|
case 0x14: /* Softint set, WO */
|
|
|
|
case 0x15: /* Softint clear, WO */
|
2005-07-02 16:31:34 +02:00
|
|
|
#endif
|
|
|
|
default:
|
2004-01-04 16:01:44 +01:00
|
|
|
goto illegal_insn;
|
|
|
|
}
|
2004-09-30 23:55:55 +02:00
|
|
|
#if !defined(CONFIG_USER_ONLY)
|
2007-04-22 21:14:52 +02:00
|
|
|
} else if (xop == 0x29) { /* rdpsr / UA2005 rdhpr */
|
2005-07-02 16:31:34 +02:00
|
|
|
#ifndef TARGET_SPARC64
|
2012-10-09 23:50:00 +02:00
|
|
|
if (!supervisor(dc)) {
|
2007-09-20 16:54:22 +02:00
|
|
|
goto priv_insn;
|
2012-10-09 23:50:00 +02:00
|
|
|
}
|
|
|
|
update_psr(dc);
|
2011-07-03 23:01:59 +02:00
|
|
|
gen_helper_rdpsr(cpu_dst, cpu_env);
|
2007-04-22 21:14:52 +02:00
|
|
|
#else
|
2008-07-20 20:22:16 +02:00
|
|
|
CHECK_IU_FEATURE(dc, HYPV);
|
2007-04-22 21:14:52 +02:00
|
|
|
if (!hypervisor(dc))
|
|
|
|
goto priv_insn;
|
|
|
|
rs1 = GET_FIELD(insn, 13, 17);
|
|
|
|
switch (rs1) {
|
|
|
|
case 0: // hpstate
|
2016-06-08 14:14:36 +02:00
|
|
|
tcg_gen_ld_i64(cpu_dst, cpu_env,
|
|
|
|
offsetof(CPUSPARCState, hpstate));
|
2007-04-22 21:14:52 +02:00
|
|
|
break;
|
|
|
|
case 1: // htstate
|
|
|
|
// gen_op_rdhtstate();
|
|
|
|
break;
|
|
|
|
case 3: // hintp
|
2008-09-06 19:51:43 +02:00
|
|
|
tcg_gen_mov_tl(cpu_dst, cpu_hintp);
|
2007-04-22 21:14:52 +02:00
|
|
|
break;
|
|
|
|
case 5: // htba
|
2008-09-06 19:51:43 +02:00
|
|
|
tcg_gen_mov_tl(cpu_dst, cpu_htba);
|
2007-04-22 21:14:52 +02:00
|
|
|
break;
|
|
|
|
case 6: // hver
|
2008-09-06 19:51:43 +02:00
|
|
|
tcg_gen_mov_tl(cpu_dst, cpu_hver);
|
2007-04-22 21:14:52 +02:00
|
|
|
break;
|
|
|
|
case 31: // hstick_cmpr
|
2008-09-06 19:51:43 +02:00
|
|
|
tcg_gen_mov_tl(cpu_dst, cpu_hstick_cmpr);
|
2007-04-22 21:14:52 +02:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
goto illegal_insn;
|
|
|
|
}
|
|
|
|
#endif
|
2012-10-16 11:32:13 +02:00
|
|
|
gen_store_gpr(dc, rd, cpu_dst);
|
2004-09-30 23:55:55 +02:00
|
|
|
break;
|
2005-07-02 16:31:34 +02:00
|
|
|
} else if (xop == 0x2a) { /* rdwim / V9 rdpr */
|
2012-10-16 11:32:31 +02:00
|
|
|
if (!supervisor(dc)) {
|
2007-09-20 16:54:22 +02:00
|
|
|
goto priv_insn;
|
2012-10-16 11:32:31 +02:00
|
|
|
}
|
2023-02-25 08:24:23 +01:00
|
|
|
cpu_tmp0 = tcg_temp_new();
|
2005-07-02 16:31:34 +02:00
|
|
|
#ifdef TARGET_SPARC64
|
|
|
|
rs1 = GET_FIELD(insn, 13, 17);
|
2007-09-20 16:54:22 +02:00
|
|
|
switch (rs1) {
|
|
|
|
case 0: // tpc
|
2008-03-05 18:59:48 +01:00
|
|
|
{
|
2008-11-17 15:43:54 +01:00
|
|
|
TCGv_ptr r_tsptr;
|
2008-03-05 18:59:48 +01:00
|
|
|
|
2008-11-17 15:43:54 +01:00
|
|
|
r_tsptr = tcg_temp_new_ptr();
|
2009-08-03 21:15:02 +02:00
|
|
|
gen_load_trap_state_at_tl(r_tsptr, cpu_env);
|
2008-11-17 15:43:54 +01:00
|
|
|
tcg_gen_ld_tl(cpu_tmp0, r_tsptr,
|
2008-03-05 18:59:48 +01:00
|
|
|
offsetof(trap_state, tpc));
|
|
|
|
}
|
2007-09-20 16:54:22 +02:00
|
|
|
break;
|
|
|
|
case 1: // tnpc
|
2008-03-05 18:59:48 +01:00
|
|
|
{
|
2008-11-17 15:43:54 +01:00
|
|
|
TCGv_ptr r_tsptr;
|
2008-03-05 18:59:48 +01:00
|
|
|
|
2008-11-17 15:43:54 +01:00
|
|
|
r_tsptr = tcg_temp_new_ptr();
|
2009-08-03 21:15:02 +02:00
|
|
|
gen_load_trap_state_at_tl(r_tsptr, cpu_env);
|
2008-06-21 21:50:10 +02:00
|
|
|
tcg_gen_ld_tl(cpu_tmp0, r_tsptr,
|
2008-03-05 18:59:48 +01:00
|
|
|
offsetof(trap_state, tnpc));
|
|
|
|
}
|
2007-09-20 16:54:22 +02:00
|
|
|
break;
|
|
|
|
case 2: // tstate
|
2008-03-05 18:59:48 +01:00
|
|
|
{
|
2008-11-17 15:43:54 +01:00
|
|
|
TCGv_ptr r_tsptr;
|
2008-03-05 18:59:48 +01:00
|
|
|
|
2008-11-17 15:43:54 +01:00
|
|
|
r_tsptr = tcg_temp_new_ptr();
|
2009-08-03 21:15:02 +02:00
|
|
|
gen_load_trap_state_at_tl(r_tsptr, cpu_env);
|
2008-06-21 21:50:10 +02:00
|
|
|
tcg_gen_ld_tl(cpu_tmp0, r_tsptr,
|
2008-03-05 18:59:48 +01:00
|
|
|
offsetof(trap_state, tstate));
|
|
|
|
}
|
2007-09-20 16:54:22 +02:00
|
|
|
break;
|
|
|
|
case 3: // tt
|
2008-03-05 18:59:48 +01:00
|
|
|
{
|
2012-10-16 11:32:22 +02:00
|
|
|
TCGv_ptr r_tsptr = tcg_temp_new_ptr();
|
2008-03-05 18:59:48 +01:00
|
|
|
|
2009-08-03 21:15:02 +02:00
|
|
|
gen_load_trap_state_at_tl(r_tsptr, cpu_env);
|
2012-10-16 11:32:22 +02:00
|
|
|
tcg_gen_ld32s_tl(cpu_tmp0, r_tsptr,
|
|
|
|
offsetof(trap_state, tt));
|
2008-03-05 18:59:48 +01:00
|
|
|
}
|
2007-09-20 16:54:22 +02:00
|
|
|
break;
|
|
|
|
case 4: // tick
|
2008-03-02 19:28:06 +01:00
|
|
|
{
|
2008-11-17 15:43:54 +01:00
|
|
|
TCGv_ptr r_tickptr;
|
2015-11-08 18:11:59 +01:00
|
|
|
TCGv_i32 r_const;
|
2008-03-02 19:28:06 +01:00
|
|
|
|
2008-11-17 15:43:54 +01:00
|
|
|
r_tickptr = tcg_temp_new_ptr();
|
2023-02-26 22:15:00 +01:00
|
|
|
r_const = tcg_constant_i32(dc->mem_idx);
|
2008-03-02 19:28:06 +01:00
|
|
|
tcg_gen_ld_ptr(r_tickptr, cpu_env,
|
2012-03-14 01:38:22 +01:00
|
|
|
offsetof(CPUSPARCState, tick));
|
2018-06-15 09:33:03 +02:00
|
|
|
if (tb_cflags(dc->base.tb) & CF_USE_ICOUNT) {
|
|
|
|
gen_io_start();
|
|
|
|
}
|
2015-11-08 18:11:59 +01:00
|
|
|
gen_helper_tick_get_count(cpu_tmp0, cpu_env,
|
|
|
|
r_tickptr, r_const);
|
2018-06-15 09:33:03 +02:00
|
|
|
if (tb_cflags(dc->base.tb) & CF_USE_ICOUNT) {
|
2021-07-24 15:49:01 +02:00
|
|
|
/* I/O operations in icount mode must end the TB */
|
|
|
|
dc->base.is_jmp = DISAS_EXIT;
|
2018-06-15 09:33:03 +02:00
|
|
|
}
|
2008-03-02 19:28:06 +01:00
|
|
|
}
|
2007-09-20 16:54:22 +02:00
|
|
|
break;
|
|
|
|
case 5: // tba
|
2008-09-06 19:51:43 +02:00
|
|
|
tcg_gen_mov_tl(cpu_tmp0, cpu_tbr);
|
2007-09-20 16:54:22 +02:00
|
|
|
break;
|
|
|
|
case 6: // pstate
|
2012-10-16 11:32:22 +02:00
|
|
|
tcg_gen_ld32s_tl(cpu_tmp0, cpu_env,
|
|
|
|
offsetof(CPUSPARCState, pstate));
|
2007-09-20 16:54:22 +02:00
|
|
|
break;
|
|
|
|
case 7: // tl
|
2012-10-16 11:32:22 +02:00
|
|
|
tcg_gen_ld32s_tl(cpu_tmp0, cpu_env,
|
|
|
|
offsetof(CPUSPARCState, tl));
|
2007-09-20 16:54:22 +02:00
|
|
|
break;
|
|
|
|
case 8: // pil
|
2012-10-16 11:32:22 +02:00
|
|
|
tcg_gen_ld32s_tl(cpu_tmp0, cpu_env,
|
|
|
|
offsetof(CPUSPARCState, psrpil));
|
2007-09-20 16:54:22 +02:00
|
|
|
break;
|
|
|
|
case 9: // cwp
|
2011-07-03 23:01:59 +02:00
|
|
|
gen_helper_rdcwp(cpu_tmp0, cpu_env);
|
2007-09-20 16:54:22 +02:00
|
|
|
break;
|
|
|
|
case 10: // cansave
|
2012-10-16 11:32:22 +02:00
|
|
|
tcg_gen_ld32s_tl(cpu_tmp0, cpu_env,
|
|
|
|
offsetof(CPUSPARCState, cansave));
|
2007-09-20 16:54:22 +02:00
|
|
|
break;
|
|
|
|
case 11: // canrestore
|
2012-10-16 11:32:22 +02:00
|
|
|
tcg_gen_ld32s_tl(cpu_tmp0, cpu_env,
|
|
|
|
offsetof(CPUSPARCState, canrestore));
|
2007-09-20 16:54:22 +02:00
|
|
|
break;
|
|
|
|
case 12: // cleanwin
|
2012-10-16 11:32:22 +02:00
|
|
|
tcg_gen_ld32s_tl(cpu_tmp0, cpu_env,
|
|
|
|
offsetof(CPUSPARCState, cleanwin));
|
2007-09-20 16:54:22 +02:00
|
|
|
break;
|
|
|
|
case 13: // otherwin
|
2012-10-16 11:32:22 +02:00
|
|
|
tcg_gen_ld32s_tl(cpu_tmp0, cpu_env,
|
|
|
|
offsetof(CPUSPARCState, otherwin));
|
2007-09-20 16:54:22 +02:00
|
|
|
break;
|
|
|
|
case 14: // wstate
|
2012-10-16 11:32:22 +02:00
|
|
|
tcg_gen_ld32s_tl(cpu_tmp0, cpu_env,
|
|
|
|
offsetof(CPUSPARCState, wstate));
|
2007-09-20 16:54:22 +02:00
|
|
|
break;
|
2007-04-22 21:14:52 +02:00
|
|
|
case 16: // UA2005 gl
|
2008-07-20 20:22:16 +02:00
|
|
|
CHECK_IU_FEATURE(dc, GL);
|
2012-10-16 11:32:22 +02:00
|
|
|
tcg_gen_ld32s_tl(cpu_tmp0, cpu_env,
|
|
|
|
offsetof(CPUSPARCState, gl));
|
2007-04-22 21:14:52 +02:00
|
|
|
break;
|
|
|
|
case 26: // UA2005 strand status
|
2008-07-20 20:22:16 +02:00
|
|
|
CHECK_IU_FEATURE(dc, HYPV);
|
2007-04-22 21:14:52 +02:00
|
|
|
if (!hypervisor(dc))
|
|
|
|
goto priv_insn;
|
2008-11-01 14:44:52 +01:00
|
|
|
tcg_gen_mov_tl(cpu_tmp0, cpu_ssr);
|
2007-04-22 21:14:52 +02:00
|
|
|
break;
|
2007-09-20 16:54:22 +02:00
|
|
|
case 31: // ver
|
2008-09-06 19:51:43 +02:00
|
|
|
tcg_gen_mov_tl(cpu_tmp0, cpu_ver);
|
2007-09-20 16:54:22 +02:00
|
|
|
break;
|
|
|
|
case 15: // fq
|
|
|
|
default:
|
|
|
|
goto illegal_insn;
|
|
|
|
}
|
2005-07-02 16:31:34 +02:00
|
|
|
#else
|
2008-09-06 19:51:43 +02:00
|
|
|
tcg_gen_ext_i32_tl(cpu_tmp0, cpu_wim);
|
2005-07-02 16:31:34 +02:00
|
|
|
#endif
|
2012-10-16 11:32:13 +02:00
|
|
|
gen_store_gpr(dc, rd, cpu_tmp0);
|
2004-09-30 23:55:55 +02:00
|
|
|
break;
|
2020-06-25 11:12:03 +02:00
|
|
|
#endif
|
|
|
|
#if defined(TARGET_SPARC64) || !defined(CONFIG_USER_ONLY)
|
2005-07-02 16:31:34 +02:00
|
|
|
} else if (xop == 0x2b) { /* rdtbr / V9 flushw */
|
|
|
|
#ifdef TARGET_SPARC64
|
2011-07-03 23:01:59 +02:00
|
|
|
gen_helper_flushw(cpu_env);
|
2005-07-02 16:31:34 +02:00
|
|
|
#else
|
2007-09-20 16:54:22 +02:00
|
|
|
if (!supervisor(dc))
|
|
|
|
goto priv_insn;
|
2012-10-16 11:32:13 +02:00
|
|
|
gen_store_gpr(dc, rd, cpu_tbr);
|
2005-07-02 16:31:34 +02:00
|
|
|
#endif
|
2004-09-30 23:55:55 +02:00
|
|
|
break;
|
|
|
|
#endif
|
2007-09-20 16:54:22 +02:00
|
|
|
} else if (xop == 0x34) { /* FPU Operations */
|
2012-10-06 01:54:52 +02:00
|
|
|
if (gen_trap_ifnofpu(dc)) {
|
2006-06-26 21:53:29 +02:00
|
|
|
goto jmp_insn;
|
2012-10-06 01:54:52 +02:00
|
|
|
}
|
2007-09-20 16:54:22 +02:00
|
|
|
gen_op_clear_ieee_excp_and_FTT();
|
2004-09-30 23:55:55 +02:00
|
|
|
rs1 = GET_FIELD(insn, 13, 17);
|
2007-09-20 16:54:22 +02:00
|
|
|
rs2 = GET_FIELD(insn, 27, 31);
|
|
|
|
xop = GET_FIELD(insn, 18, 26);
|
2015-09-09 20:34:28 +02:00
|
|
|
|
2007-09-20 16:54:22 +02:00
|
|
|
switch (xop) {
|
2009-05-03 20:51:22 +02:00
|
|
|
case 0x1: /* fmovs */
|
2011-10-14 23:58:32 +02:00
|
|
|
cpu_src1_32 = gen_load_fpr_F(dc, rs2);
|
|
|
|
gen_store_fpr_F(dc, rd, cpu_src1_32);
|
2009-05-03 20:51:22 +02:00
|
|
|
break;
|
|
|
|
case 0x5: /* fnegs */
|
2011-10-15 20:52:00 +02:00
|
|
|
gen_ne_fop_FF(dc, rd, rs2, gen_helper_fnegs);
|
2009-05-03 20:51:22 +02:00
|
|
|
break;
|
|
|
|
case 0x9: /* fabss */
|
2011-10-15 20:52:00 +02:00
|
|
|
gen_ne_fop_FF(dc, rd, rs2, gen_helper_fabss);
|
2009-05-03 20:51:22 +02:00
|
|
|
break;
|
|
|
|
case 0x29: /* fsqrts */
|
|
|
|
CHECK_FPU_FEATURE(dc, FSQRT);
|
2011-10-15 20:52:00 +02:00
|
|
|
gen_fop_FF(dc, rd, rs2, gen_helper_fsqrts);
|
2009-05-03 20:51:22 +02:00
|
|
|
break;
|
|
|
|
case 0x2a: /* fsqrtd */
|
|
|
|
CHECK_FPU_FEATURE(dc, FSQRT);
|
2011-10-15 20:52:00 +02:00
|
|
|
gen_fop_DD(dc, rd, rs2, gen_helper_fsqrtd);
|
2009-05-03 20:51:22 +02:00
|
|
|
break;
|
|
|
|
case 0x2b: /* fsqrtq */
|
|
|
|
CHECK_FPU_FEATURE(dc, FLOAT128);
|
2011-10-15 20:52:00 +02:00
|
|
|
gen_fop_QQ(dc, rd, rs2, gen_helper_fsqrtq);
|
2009-05-03 20:51:22 +02:00
|
|
|
break;
|
|
|
|
case 0x41: /* fadds */
|
2011-10-15 20:52:00 +02:00
|
|
|
gen_fop_FFF(dc, rd, rs1, rs2, gen_helper_fadds);
|
2009-05-03 20:51:22 +02:00
|
|
|
break;
|
|
|
|
case 0x42: /* faddd */
|
2011-10-15 20:52:00 +02:00
|
|
|
gen_fop_DDD(dc, rd, rs1, rs2, gen_helper_faddd);
|
2009-05-03 20:51:22 +02:00
|
|
|
break;
|
|
|
|
case 0x43: /* faddq */
|
|
|
|
CHECK_FPU_FEATURE(dc, FLOAT128);
|
2011-10-15 20:52:00 +02:00
|
|
|
gen_fop_QQQ(dc, rd, rs1, rs2, gen_helper_faddq);
|
2009-05-03 20:51:22 +02:00
|
|
|
break;
|
|
|
|
case 0x45: /* fsubs */
|
2011-10-15 20:52:00 +02:00
|
|
|
gen_fop_FFF(dc, rd, rs1, rs2, gen_helper_fsubs);
|
2009-05-03 20:51:22 +02:00
|
|
|
break;
|
|
|
|
case 0x46: /* fsubd */
|
2011-10-15 20:52:00 +02:00
|
|
|
gen_fop_DDD(dc, rd, rs1, rs2, gen_helper_fsubd);
|
2009-05-03 20:51:22 +02:00
|
|
|
break;
|
|
|
|
case 0x47: /* fsubq */
|
|
|
|
CHECK_FPU_FEATURE(dc, FLOAT128);
|
2011-10-15 20:52:00 +02:00
|
|
|
gen_fop_QQQ(dc, rd, rs1, rs2, gen_helper_fsubq);
|
2009-05-03 20:51:22 +02:00
|
|
|
break;
|
|
|
|
case 0x49: /* fmuls */
|
|
|
|
CHECK_FPU_FEATURE(dc, FMUL);
|
2011-10-15 20:52:00 +02:00
|
|
|
gen_fop_FFF(dc, rd, rs1, rs2, gen_helper_fmuls);
|
2009-05-03 20:51:22 +02:00
|
|
|
break;
|
|
|
|
case 0x4a: /* fmuld */
|
|
|
|
CHECK_FPU_FEATURE(dc, FMUL);
|
2011-10-15 20:52:00 +02:00
|
|
|
gen_fop_DDD(dc, rd, rs1, rs2, gen_helper_fmuld);
|
2009-05-03 20:51:22 +02:00
|
|
|
break;
|
|
|
|
case 0x4b: /* fmulq */
|
|
|
|
CHECK_FPU_FEATURE(dc, FLOAT128);
|
|
|
|
CHECK_FPU_FEATURE(dc, FMUL);
|
2011-10-15 20:52:00 +02:00
|
|
|
gen_fop_QQQ(dc, rd, rs1, rs2, gen_helper_fmulq);
|
2009-05-03 20:51:22 +02:00
|
|
|
break;
|
|
|
|
case 0x4d: /* fdivs */
|
2011-10-15 20:52:00 +02:00
|
|
|
gen_fop_FFF(dc, rd, rs1, rs2, gen_helper_fdivs);
|
2009-05-03 20:51:22 +02:00
|
|
|
break;
|
|
|
|
case 0x4e: /* fdivd */
|
2011-10-15 20:52:00 +02:00
|
|
|
gen_fop_DDD(dc, rd, rs1, rs2, gen_helper_fdivd);
|
2009-05-03 20:51:22 +02:00
|
|
|
break;
|
|
|
|
case 0x4f: /* fdivq */
|
|
|
|
CHECK_FPU_FEATURE(dc, FLOAT128);
|
2011-10-15 20:52:00 +02:00
|
|
|
gen_fop_QQQ(dc, rd, rs1, rs2, gen_helper_fdivq);
|
2009-05-03 20:51:22 +02:00
|
|
|
break;
|
|
|
|
case 0x69: /* fsmuld */
|
|
|
|
CHECK_FPU_FEATURE(dc, FSMULD);
|
2011-10-15 20:52:00 +02:00
|
|
|
gen_fop_DFF(dc, rd, rs1, rs2, gen_helper_fsmuld);
|
2009-05-03 20:51:22 +02:00
|
|
|
break;
|
|
|
|
case 0x6e: /* fdmulq */
|
|
|
|
CHECK_FPU_FEATURE(dc, FLOAT128);
|
2011-10-15 20:52:00 +02:00
|
|
|
gen_fop_QDD(dc, rd, rs1, rs2, gen_helper_fdmulq);
|
2009-05-03 20:51:22 +02:00
|
|
|
break;
|
|
|
|
case 0xc4: /* fitos */
|
2011-10-15 20:52:00 +02:00
|
|
|
gen_fop_FF(dc, rd, rs2, gen_helper_fitos);
|
2009-05-03 20:51:22 +02:00
|
|
|
break;
|
|
|
|
case 0xc6: /* fdtos */
|
2011-10-15 20:52:00 +02:00
|
|
|
gen_fop_FD(dc, rd, rs2, gen_helper_fdtos);
|
2009-05-03 20:51:22 +02:00
|
|
|
break;
|
|
|
|
case 0xc7: /* fqtos */
|
|
|
|
CHECK_FPU_FEATURE(dc, FLOAT128);
|
2011-10-15 20:52:00 +02:00
|
|
|
gen_fop_FQ(dc, rd, rs2, gen_helper_fqtos);
|
2009-05-03 20:51:22 +02:00
|
|
|
break;
|
|
|
|
case 0xc8: /* fitod */
|
2011-10-15 20:52:00 +02:00
|
|
|
gen_ne_fop_DF(dc, rd, rs2, gen_helper_fitod);
|
2009-05-03 20:51:22 +02:00
|
|
|
break;
|
|
|
|
case 0xc9: /* fstod */
|
2011-10-15 20:52:00 +02:00
|
|
|
gen_ne_fop_DF(dc, rd, rs2, gen_helper_fstod);
|
2009-05-03 20:51:22 +02:00
|
|
|
break;
|
|
|
|
case 0xcb: /* fqtod */
|
|
|
|
CHECK_FPU_FEATURE(dc, FLOAT128);
|
2011-10-15 20:52:00 +02:00
|
|
|
gen_fop_DQ(dc, rd, rs2, gen_helper_fqtod);
|
2009-05-03 20:51:22 +02:00
|
|
|
break;
|
|
|
|
case 0xcc: /* fitoq */
|
|
|
|
CHECK_FPU_FEATURE(dc, FLOAT128);
|
2011-10-15 20:52:00 +02:00
|
|
|
gen_ne_fop_QF(dc, rd, rs2, gen_helper_fitoq);
|
2009-05-03 20:51:22 +02:00
|
|
|
break;
|
|
|
|
case 0xcd: /* fstoq */
|
|
|
|
CHECK_FPU_FEATURE(dc, FLOAT128);
|
2011-10-15 20:52:00 +02:00
|
|
|
gen_ne_fop_QF(dc, rd, rs2, gen_helper_fstoq);
|
2009-05-03 20:51:22 +02:00
|
|
|
break;
|
|
|
|
case 0xce: /* fdtoq */
|
|
|
|
CHECK_FPU_FEATURE(dc, FLOAT128);
|
2011-10-15 20:52:00 +02:00
|
|
|
gen_ne_fop_QD(dc, rd, rs2, gen_helper_fdtoq);
|
2009-05-03 20:51:22 +02:00
|
|
|
break;
|
|
|
|
case 0xd1: /* fstoi */
|
2011-10-15 20:52:00 +02:00
|
|
|
gen_fop_FF(dc, rd, rs2, gen_helper_fstoi);
|
2009-05-03 20:51:22 +02:00
|
|
|
break;
|
|
|
|
case 0xd2: /* fdtoi */
|
2011-10-15 20:52:00 +02:00
|
|
|
gen_fop_FD(dc, rd, rs2, gen_helper_fdtoi);
|
2009-05-03 20:51:22 +02:00
|
|
|
break;
|
|
|
|
case 0xd3: /* fqtoi */
|
|
|
|
CHECK_FPU_FEATURE(dc, FLOAT128);
|
2011-10-15 20:52:00 +02:00
|
|
|
gen_fop_FQ(dc, rd, rs2, gen_helper_fqtoi);
|
2009-05-03 20:51:22 +02:00
|
|
|
break;
|
2005-07-02 16:31:34 +02:00
|
|
|
#ifdef TARGET_SPARC64
|
2009-05-03 20:51:22 +02:00
|
|
|
case 0x2: /* V9 fmovd */
|
2011-10-15 00:47:35 +02:00
|
|
|
cpu_src1_64 = gen_load_fpr_D(dc, rs2);
|
|
|
|
gen_store_fpr_D(dc, rd, cpu_src1_64);
|
2009-05-03 20:51:22 +02:00
|
|
|
break;
|
|
|
|
case 0x3: /* V9 fmovq */
|
|
|
|
CHECK_FPU_FEATURE(dc, FLOAT128);
|
2015-09-09 20:56:38 +02:00
|
|
|
gen_move_Q(dc, rd, rs2);
|
2009-05-03 20:51:22 +02:00
|
|
|
break;
|
|
|
|
case 0x6: /* V9 fnegd */
|
2011-10-15 20:52:00 +02:00
|
|
|
gen_ne_fop_DD(dc, rd, rs2, gen_helper_fnegd);
|
2009-05-03 20:51:22 +02:00
|
|
|
break;
|
|
|
|
case 0x7: /* V9 fnegq */
|
|
|
|
CHECK_FPU_FEATURE(dc, FLOAT128);
|
2011-10-15 20:52:00 +02:00
|
|
|
gen_ne_fop_QQ(dc, rd, rs2, gen_helper_fnegq);
|
2009-05-03 20:51:22 +02:00
|
|
|
break;
|
|
|
|
case 0xa: /* V9 fabsd */
|
2011-10-15 20:52:00 +02:00
|
|
|
gen_ne_fop_DD(dc, rd, rs2, gen_helper_fabsd);
|
2009-05-03 20:51:22 +02:00
|
|
|
break;
|
|
|
|
case 0xb: /* V9 fabsq */
|
|
|
|
CHECK_FPU_FEATURE(dc, FLOAT128);
|
2011-10-15 20:52:00 +02:00
|
|
|
gen_ne_fop_QQ(dc, rd, rs2, gen_helper_fabsq);
|
2009-05-03 20:51:22 +02:00
|
|
|
break;
|
|
|
|
case 0x81: /* V9 fstox */
|
2011-10-15 20:52:00 +02:00
|
|
|
gen_fop_DF(dc, rd, rs2, gen_helper_fstox);
|
2009-05-03 20:51:22 +02:00
|
|
|
break;
|
|
|
|
case 0x82: /* V9 fdtox */
|
2011-10-15 20:52:00 +02:00
|
|
|
gen_fop_DD(dc, rd, rs2, gen_helper_fdtox);
|
2009-05-03 20:51:22 +02:00
|
|
|
break;
|
|
|
|
case 0x83: /* V9 fqtox */
|
|
|
|
CHECK_FPU_FEATURE(dc, FLOAT128);
|
2011-10-15 20:52:00 +02:00
|
|
|
gen_fop_DQ(dc, rd, rs2, gen_helper_fqtox);
|
2009-05-03 20:51:22 +02:00
|
|
|
break;
|
|
|
|
case 0x84: /* V9 fxtos */
|
2011-10-15 20:52:00 +02:00
|
|
|
gen_fop_FD(dc, rd, rs2, gen_helper_fxtos);
|
2009-05-03 20:51:22 +02:00
|
|
|
break;
|
|
|
|
case 0x88: /* V9 fxtod */
|
2011-10-15 20:52:00 +02:00
|
|
|
gen_fop_DD(dc, rd, rs2, gen_helper_fxtod);
|
2009-05-03 20:51:22 +02:00
|
|
|
break;
|
|
|
|
case 0x8c: /* V9 fxtoq */
|
|
|
|
CHECK_FPU_FEATURE(dc, FLOAT128);
|
2011-10-15 20:52:00 +02:00
|
|
|
gen_ne_fop_QD(dc, rd, rs2, gen_helper_fxtoq);
|
2009-05-03 20:51:22 +02:00
|
|
|
break;
|
2007-09-20 16:54:22 +02:00
|
|
|
#endif
|
2009-05-03 20:51:22 +02:00
|
|
|
default:
|
|
|
|
goto illegal_insn;
|
2007-09-20 16:54:22 +02:00
|
|
|
}
|
|
|
|
} else if (xop == 0x35) { /* FPU Operations */
|
2005-07-02 16:31:34 +02:00
|
|
|
#ifdef TARGET_SPARC64
|
2007-09-20 16:54:22 +02:00
|
|
|
int cond;
|
2005-07-02 16:31:34 +02:00
|
|
|
#endif
|
2012-10-06 01:54:52 +02:00
|
|
|
if (gen_trap_ifnofpu(dc)) {
|
2006-06-26 21:53:29 +02:00
|
|
|
goto jmp_insn;
|
2012-10-06 01:54:52 +02:00
|
|
|
}
|
2007-09-20 16:54:22 +02:00
|
|
|
gen_op_clear_ieee_excp_and_FTT();
|
2004-01-04 16:01:44 +01:00
|
|
|
rs1 = GET_FIELD(insn, 13, 17);
|
2007-09-20 16:54:22 +02:00
|
|
|
rs2 = GET_FIELD(insn, 27, 31);
|
|
|
|
xop = GET_FIELD(insn, 18, 26);
|
2008-03-04 20:56:06 +01:00
|
|
|
|
2012-10-06 01:55:07 +02:00
|
|
|
#ifdef TARGET_SPARC64
|
|
|
|
#define FMOVR(sz) \
|
|
|
|
do { \
|
|
|
|
DisasCompare cmp; \
|
2012-10-17 01:28:35 +02:00
|
|
|
cond = GET_FIELD_SP(insn, 10, 12); \
|
2012-10-16 11:32:14 +02:00
|
|
|
cpu_src1 = get_src1(dc, insn); \
|
2012-10-06 01:55:07 +02:00
|
|
|
gen_compare_reg(&cmp, cond, cpu_src1); \
|
|
|
|
gen_fmov##sz(dc, &cmp, rd, rs2); \
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
if ((xop & 0x11f) == 0x005) { /* V9 fmovsr */
|
|
|
|
FMOVR(s);
|
2007-09-20 16:54:22 +02:00
|
|
|
break;
|
|
|
|
} else if ((xop & 0x11f) == 0x006) { // V9 fmovdr
|
2012-10-06 01:55:07 +02:00
|
|
|
FMOVR(d);
|
2007-09-20 16:54:22 +02:00
|
|
|
break;
|
|
|
|
} else if ((xop & 0x11f) == 0x007) { // V9 fmovqr
|
2008-05-09 22:13:43 +02:00
|
|
|
CHECK_FPU_FEATURE(dc, FLOAT128);
|
2012-10-06 01:55:07 +02:00
|
|
|
FMOVR(q);
|
2007-11-25 19:40:20 +01:00
|
|
|
break;
|
2007-09-20 16:54:22 +02:00
|
|
|
}
|
2012-10-06 01:55:07 +02:00
|
|
|
#undef FMOVR
|
2007-09-20 16:54:22 +02:00
|
|
|
#endif
|
|
|
|
switch (xop) {
|
2005-07-02 16:31:34 +02:00
|
|
|
#ifdef TARGET_SPARC64
|
2012-10-06 01:54:59 +02:00
|
|
|
#define FMOVCC(fcc, sz) \
|
|
|
|
do { \
|
|
|
|
DisasCompare cmp; \
|
2008-09-10 21:54:51 +02:00
|
|
|
cond = GET_FIELD_SP(insn, 14, 17); \
|
2012-10-06 01:54:59 +02:00
|
|
|
gen_fcompare(&cmp, fcc, cond); \
|
|
|
|
gen_fmov##sz(dc, &cmp, rd, rs2); \
|
|
|
|
} while (0)
|
|
|
|
|
2007-09-20 16:54:22 +02:00
|
|
|
case 0x001: /* V9 fmovscc %fcc0 */
|
2012-10-06 01:54:59 +02:00
|
|
|
FMOVCC(0, s);
|
2007-09-20 16:54:22 +02:00
|
|
|
break;
|
|
|
|
case 0x002: /* V9 fmovdcc %fcc0 */
|
2012-10-06 01:54:59 +02:00
|
|
|
FMOVCC(0, d);
|
2007-09-20 16:54:22 +02:00
|
|
|
break;
|
|
|
|
case 0x003: /* V9 fmovqcc %fcc0 */
|
2008-05-09 22:13:43 +02:00
|
|
|
CHECK_FPU_FEATURE(dc, FLOAT128);
|
2012-10-06 01:54:59 +02:00
|
|
|
FMOVCC(0, q);
|
2007-11-25 19:40:20 +01:00
|
|
|
break;
|
2007-09-20 16:54:22 +02:00
|
|
|
case 0x041: /* V9 fmovscc %fcc1 */
|
2012-10-06 01:54:59 +02:00
|
|
|
FMOVCC(1, s);
|
2007-09-20 16:54:22 +02:00
|
|
|
break;
|
|
|
|
case 0x042: /* V9 fmovdcc %fcc1 */
|
2012-10-06 01:54:59 +02:00
|
|
|
FMOVCC(1, d);
|
2007-09-20 16:54:22 +02:00
|
|
|
break;
|
|
|
|
case 0x043: /* V9 fmovqcc %fcc1 */
|
2008-05-09 22:13:43 +02:00
|
|
|
CHECK_FPU_FEATURE(dc, FLOAT128);
|
2012-10-06 01:54:59 +02:00
|
|
|
FMOVCC(1, q);
|
2007-11-25 19:40:20 +01:00
|
|
|
break;
|
2007-09-20 16:54:22 +02:00
|
|
|
case 0x081: /* V9 fmovscc %fcc2 */
|
2012-10-06 01:54:59 +02:00
|
|
|
FMOVCC(2, s);
|
2007-09-20 16:54:22 +02:00
|
|
|
break;
|
|
|
|
case 0x082: /* V9 fmovdcc %fcc2 */
|
2012-10-06 01:54:59 +02:00
|
|
|
FMOVCC(2, d);
|
2007-09-20 16:54:22 +02:00
|
|
|
break;
|
|
|
|
case 0x083: /* V9 fmovqcc %fcc2 */
|
2008-05-09 22:13:43 +02:00
|
|
|
CHECK_FPU_FEATURE(dc, FLOAT128);
|
2012-10-06 01:54:59 +02:00
|
|
|
FMOVCC(2, q);
|
2007-11-25 19:40:20 +01:00
|
|
|
break;
|
2007-09-20 16:54:22 +02:00
|
|
|
case 0x0c1: /* V9 fmovscc %fcc3 */
|
2012-10-06 01:54:59 +02:00
|
|
|
FMOVCC(3, s);
|
2007-09-20 16:54:22 +02:00
|
|
|
break;
|
|
|
|
case 0x0c2: /* V9 fmovdcc %fcc3 */
|
2012-10-06 01:54:59 +02:00
|
|
|
FMOVCC(3, d);
|
2007-09-20 16:54:22 +02:00
|
|
|
break;
|
|
|
|
case 0x0c3: /* V9 fmovqcc %fcc3 */
|
2008-05-09 22:13:43 +02:00
|
|
|
CHECK_FPU_FEATURE(dc, FLOAT128);
|
2012-10-06 01:54:59 +02:00
|
|
|
FMOVCC(3, q);
|
2007-11-25 19:40:20 +01:00
|
|
|
break;
|
2012-10-06 01:54:59 +02:00
|
|
|
#undef FMOVCC
|
|
|
|
#define FMOVCC(xcc, sz) \
|
|
|
|
do { \
|
|
|
|
DisasCompare cmp; \
|
2008-09-10 21:54:51 +02:00
|
|
|
cond = GET_FIELD_SP(insn, 14, 17); \
|
2012-10-06 01:54:59 +02:00
|
|
|
gen_compare(&cmp, xcc, cond, dc); \
|
|
|
|
gen_fmov##sz(dc, &cmp, rd, rs2); \
|
|
|
|
} while (0)
|
2008-03-08 22:36:50 +01:00
|
|
|
|
2007-09-20 16:54:22 +02:00
|
|
|
case 0x101: /* V9 fmovscc %icc */
|
2012-10-06 01:54:59 +02:00
|
|
|
FMOVCC(0, s);
|
2007-09-20 16:54:22 +02:00
|
|
|
break;
|
|
|
|
case 0x102: /* V9 fmovdcc %icc */
|
2012-10-06 01:54:59 +02:00
|
|
|
FMOVCC(0, d);
|
2011-07-18 08:36:57 +02:00
|
|
|
break;
|
2007-09-20 16:54:22 +02:00
|
|
|
case 0x103: /* V9 fmovqcc %icc */
|
2008-05-09 22:13:43 +02:00
|
|
|
CHECK_FPU_FEATURE(dc, FLOAT128);
|
2012-10-06 01:54:59 +02:00
|
|
|
FMOVCC(0, q);
|
2007-11-25 19:40:20 +01:00
|
|
|
break;
|
2007-09-20 16:54:22 +02:00
|
|
|
case 0x181: /* V9 fmovscc %xcc */
|
2012-10-06 01:54:59 +02:00
|
|
|
FMOVCC(1, s);
|
2007-09-20 16:54:22 +02:00
|
|
|
break;
|
|
|
|
case 0x182: /* V9 fmovdcc %xcc */
|
2012-10-06 01:54:59 +02:00
|
|
|
FMOVCC(1, d);
|
2007-09-20 16:54:22 +02:00
|
|
|
break;
|
|
|
|
case 0x183: /* V9 fmovqcc %xcc */
|
2008-05-09 22:13:43 +02:00
|
|
|
CHECK_FPU_FEATURE(dc, FLOAT128);
|
2012-10-06 01:54:59 +02:00
|
|
|
FMOVCC(1, q);
|
2007-11-25 19:40:20 +01:00
|
|
|
break;
|
2012-10-06 01:54:59 +02:00
|
|
|
#undef FMOVCC
|
2007-11-25 19:40:20 +01:00
|
|
|
#endif
|
|
|
|
case 0x51: /* fcmps, V9 %fcc */
|
2011-10-14 23:58:32 +02:00
|
|
|
cpu_src1_32 = gen_load_fpr_F(dc, rs1);
|
|
|
|
cpu_src2_32 = gen_load_fpr_F(dc, rs2);
|
|
|
|
gen_op_fcmps(rd & 3, cpu_src1_32, cpu_src2_32);
|
2007-09-20 16:54:22 +02:00
|
|
|
break;
|
2007-11-25 19:40:20 +01:00
|
|
|
case 0x52: /* fcmpd, V9 %fcc */
|
2011-10-15 19:20:20 +02:00
|
|
|
cpu_src1_64 = gen_load_fpr_D(dc, rs1);
|
|
|
|
cpu_src2_64 = gen_load_fpr_D(dc, rs2);
|
|
|
|
gen_op_fcmpd(rd & 3, cpu_src1_64, cpu_src2_64);
|
2007-09-20 16:54:22 +02:00
|
|
|
break;
|
2007-11-25 19:40:20 +01:00
|
|
|
case 0x53: /* fcmpq, V9 %fcc */
|
2008-05-09 22:13:43 +02:00
|
|
|
CHECK_FPU_FEATURE(dc, FLOAT128);
|
2007-11-25 19:40:20 +01:00
|
|
|
gen_op_load_fpr_QT0(QFPREG(rs1));
|
|
|
|
gen_op_load_fpr_QT1(QFPREG(rs2));
|
2008-03-04 21:00:18 +01:00
|
|
|
gen_op_fcmpq(rd & 3);
|
2007-11-25 19:40:20 +01:00
|
|
|
break;
|
2007-09-20 16:54:22 +02:00
|
|
|
case 0x55: /* fcmpes, V9 %fcc */
|
2011-10-14 23:58:32 +02:00
|
|
|
cpu_src1_32 = gen_load_fpr_F(dc, rs1);
|
|
|
|
cpu_src2_32 = gen_load_fpr_F(dc, rs2);
|
|
|
|
gen_op_fcmpes(rd & 3, cpu_src1_32, cpu_src2_32);
|
2007-09-20 16:54:22 +02:00
|
|
|
break;
|
|
|
|
case 0x56: /* fcmped, V9 %fcc */
|
2011-10-15 19:20:20 +02:00
|
|
|
cpu_src1_64 = gen_load_fpr_D(dc, rs1);
|
|
|
|
cpu_src2_64 = gen_load_fpr_D(dc, rs2);
|
|
|
|
gen_op_fcmped(rd & 3, cpu_src1_64, cpu_src2_64);
|
2007-09-20 16:54:22 +02:00
|
|
|
break;
|
2007-11-25 19:40:20 +01:00
|
|
|
case 0x57: /* fcmpeq, V9 %fcc */
|
2008-05-09 22:13:43 +02:00
|
|
|
CHECK_FPU_FEATURE(dc, FLOAT128);
|
2007-11-25 19:40:20 +01:00
|
|
|
gen_op_load_fpr_QT0(QFPREG(rs1));
|
|
|
|
gen_op_load_fpr_QT1(QFPREG(rs2));
|
2008-03-04 21:00:18 +01:00
|
|
|
gen_op_fcmpeq(rd & 3);
|
2007-11-25 19:40:20 +01:00
|
|
|
break;
|
2007-09-20 16:54:22 +02:00
|
|
|
default:
|
|
|
|
goto illegal_insn;
|
|
|
|
}
|
|
|
|
} else if (xop == 0x2) {
|
2012-10-16 11:32:13 +02:00
|
|
|
TCGv dst = gen_dest_gpr(dc, rd);
|
2004-12-20 00:18:01 +01:00
|
|
|
rs1 = GET_FIELD(insn, 13, 17);
|
2007-09-20 16:54:22 +02:00
|
|
|
if (rs1 == 0) {
|
2012-10-16 11:32:13 +02:00
|
|
|
/* clr/mov shortcut : or %g0, x, y -> mov x, y */
|
2007-09-20 16:54:22 +02:00
|
|
|
if (IS_IMM) { /* immediate */
|
2009-05-02 20:58:57 +02:00
|
|
|
simm = GET_FIELDs(insn, 19, 31);
|
2012-10-16 11:32:13 +02:00
|
|
|
tcg_gen_movi_tl(dst, simm);
|
|
|
|
gen_store_gpr(dc, rd, dst);
|
2007-09-20 16:54:22 +02:00
|
|
|
} else { /* register */
|
|
|
|
rs2 = GET_FIELD(insn, 27, 31);
|
2012-10-16 11:32:13 +02:00
|
|
|
if (rs2 == 0) {
|
|
|
|
tcg_gen_movi_tl(dst, 0);
|
|
|
|
gen_store_gpr(dc, rd, dst);
|
|
|
|
} else {
|
|
|
|
cpu_src2 = gen_load_gpr(dc, rs2);
|
|
|
|
gen_store_gpr(dc, rd, cpu_src2);
|
|
|
|
}
|
2007-09-20 16:54:22 +02:00
|
|
|
}
|
|
|
|
} else {
|
2012-10-16 11:32:14 +02:00
|
|
|
cpu_src1 = get_src1(dc, insn);
|
2007-09-20 16:54:22 +02:00
|
|
|
if (IS_IMM) { /* immediate */
|
2009-05-02 20:58:57 +02:00
|
|
|
simm = GET_FIELDs(insn, 19, 31);
|
2012-10-16 11:32:13 +02:00
|
|
|
tcg_gen_ori_tl(dst, cpu_src1, simm);
|
|
|
|
gen_store_gpr(dc, rd, dst);
|
2007-09-20 16:54:22 +02:00
|
|
|
} else { /* register */
|
|
|
|
rs2 = GET_FIELD(insn, 27, 31);
|
2012-10-16 11:32:13 +02:00
|
|
|
if (rs2 == 0) {
|
|
|
|
/* mov shortcut: or x, %g0, y -> mov x, y */
|
|
|
|
gen_store_gpr(dc, rd, cpu_src1);
|
|
|
|
} else {
|
|
|
|
cpu_src2 = gen_load_gpr(dc, rs2);
|
|
|
|
tcg_gen_or_tl(dst, cpu_src1, cpu_src2);
|
|
|
|
gen_store_gpr(dc, rd, dst);
|
|
|
|
}
|
2007-09-20 16:54:22 +02:00
|
|
|
}
|
|
|
|
}
|
2005-07-23 16:27:54 +02:00
|
|
|
#ifdef TARGET_SPARC64
|
2007-09-20 16:54:22 +02:00
|
|
|
} else if (xop == 0x25) { /* sll, V9 sllx */
|
2012-10-16 11:32:14 +02:00
|
|
|
cpu_src1 = get_src1(dc, insn);
|
2007-09-20 16:54:22 +02:00
|
|
|
if (IS_IMM) { /* immediate */
|
2009-05-02 20:58:57 +02:00
|
|
|
simm = GET_FIELDs(insn, 20, 31);
|
2008-02-24 15:10:06 +01:00
|
|
|
if (insn & (1 << 12)) {
|
2009-05-02 20:58:57 +02:00
|
|
|
tcg_gen_shli_i64(cpu_dst, cpu_src1, simm & 0x3f);
|
2008-02-24 15:10:06 +01:00
|
|
|
} else {
|
2009-05-02 20:58:57 +02:00
|
|
|
tcg_gen_shli_i64(cpu_dst, cpu_src1, simm & 0x1f);
|
2008-02-24 15:10:06 +01:00
|
|
|
}
|
2007-09-20 16:54:22 +02:00
|
|
|
} else { /* register */
|
2005-07-23 16:27:54 +02:00
|
|
|
rs2 = GET_FIELD(insn, 27, 31);
|
2012-10-16 11:32:13 +02:00
|
|
|
cpu_src2 = gen_load_gpr(dc, rs2);
|
2023-02-25 08:24:23 +01:00
|
|
|
cpu_tmp0 = tcg_temp_new();
|
2008-02-24 15:10:06 +01:00
|
|
|
if (insn & (1 << 12)) {
|
2008-03-29 10:09:25 +01:00
|
|
|
tcg_gen_andi_i64(cpu_tmp0, cpu_src2, 0x3f);
|
2008-02-24 15:10:06 +01:00
|
|
|
} else {
|
2008-03-29 10:09:25 +01:00
|
|
|
tcg_gen_andi_i64(cpu_tmp0, cpu_src2, 0x1f);
|
2008-02-24 15:10:06 +01:00
|
|
|
}
|
2008-08-06 20:13:54 +02:00
|
|
|
tcg_gen_shl_i64(cpu_dst, cpu_src1, cpu_tmp0);
|
2005-07-23 16:27:54 +02:00
|
|
|
}
|
2012-10-16 11:32:13 +02:00
|
|
|
gen_store_gpr(dc, rd, cpu_dst);
|
2007-09-20 16:54:22 +02:00
|
|
|
} else if (xop == 0x26) { /* srl, V9 srlx */
|
2012-10-16 11:32:14 +02:00
|
|
|
cpu_src1 = get_src1(dc, insn);
|
2007-09-20 16:54:22 +02:00
|
|
|
if (IS_IMM) { /* immediate */
|
2009-05-02 20:58:57 +02:00
|
|
|
simm = GET_FIELDs(insn, 20, 31);
|
2008-02-24 15:10:06 +01:00
|
|
|
if (insn & (1 << 12)) {
|
2009-05-02 20:58:57 +02:00
|
|
|
tcg_gen_shri_i64(cpu_dst, cpu_src1, simm & 0x3f);
|
2008-02-24 15:10:06 +01:00
|
|
|
} else {
|
2008-03-29 10:09:25 +01:00
|
|
|
tcg_gen_andi_i64(cpu_dst, cpu_src1, 0xffffffffULL);
|
2009-05-02 20:58:57 +02:00
|
|
|
tcg_gen_shri_i64(cpu_dst, cpu_dst, simm & 0x1f);
|
2008-02-24 15:10:06 +01:00
|
|
|
}
|
2007-09-20 16:54:22 +02:00
|
|
|
} else { /* register */
|
2005-07-23 16:27:54 +02:00
|
|
|
rs2 = GET_FIELD(insn, 27, 31);
|
2012-10-16 11:32:13 +02:00
|
|
|
cpu_src2 = gen_load_gpr(dc, rs2);
|
2023-02-25 08:24:23 +01:00
|
|
|
cpu_tmp0 = tcg_temp_new();
|
2008-02-24 15:10:06 +01:00
|
|
|
if (insn & (1 << 12)) {
|
2008-03-29 10:09:25 +01:00
|
|
|
tcg_gen_andi_i64(cpu_tmp0, cpu_src2, 0x3f);
|
|
|
|
tcg_gen_shr_i64(cpu_dst, cpu_src1, cpu_tmp0);
|
2008-02-24 15:10:06 +01:00
|
|
|
} else {
|
2008-03-29 10:09:25 +01:00
|
|
|
tcg_gen_andi_i64(cpu_tmp0, cpu_src2, 0x1f);
|
|
|
|
tcg_gen_andi_i64(cpu_dst, cpu_src1, 0xffffffffULL);
|
|
|
|
tcg_gen_shr_i64(cpu_dst, cpu_dst, cpu_tmp0);
|
2008-02-24 15:10:06 +01:00
|
|
|
}
|
2005-07-23 16:27:54 +02:00
|
|
|
}
|
2012-10-16 11:32:13 +02:00
|
|
|
gen_store_gpr(dc, rd, cpu_dst);
|
2007-09-20 16:54:22 +02:00
|
|
|
} else if (xop == 0x27) { /* sra, V9 srax */
|
2012-10-16 11:32:14 +02:00
|
|
|
cpu_src1 = get_src1(dc, insn);
|
2007-09-20 16:54:22 +02:00
|
|
|
if (IS_IMM) { /* immediate */
|
2009-05-02 20:58:57 +02:00
|
|
|
simm = GET_FIELDs(insn, 20, 31);
|
2008-02-24 15:10:06 +01:00
|
|
|
if (insn & (1 << 12)) {
|
2009-05-02 20:58:57 +02:00
|
|
|
tcg_gen_sari_i64(cpu_dst, cpu_src1, simm & 0x3f);
|
2008-02-24 15:10:06 +01:00
|
|
|
} else {
|
2012-10-16 11:32:13 +02:00
|
|
|
tcg_gen_ext32s_i64(cpu_dst, cpu_src1);
|
2009-05-02 20:58:57 +02:00
|
|
|
tcg_gen_sari_i64(cpu_dst, cpu_dst, simm & 0x1f);
|
2008-02-24 15:10:06 +01:00
|
|
|
}
|
2007-09-20 16:54:22 +02:00
|
|
|
} else { /* register */
|
2005-07-23 16:27:54 +02:00
|
|
|
rs2 = GET_FIELD(insn, 27, 31);
|
2012-10-16 11:32:13 +02:00
|
|
|
cpu_src2 = gen_load_gpr(dc, rs2);
|
2023-02-25 08:24:23 +01:00
|
|
|
cpu_tmp0 = tcg_temp_new();
|
2008-02-24 15:10:06 +01:00
|
|
|
if (insn & (1 << 12)) {
|
2008-03-29 10:09:25 +01:00
|
|
|
tcg_gen_andi_i64(cpu_tmp0, cpu_src2, 0x3f);
|
|
|
|
tcg_gen_sar_i64(cpu_dst, cpu_src1, cpu_tmp0);
|
2008-02-24 15:10:06 +01:00
|
|
|
} else {
|
2008-03-29 10:09:25 +01:00
|
|
|
tcg_gen_andi_i64(cpu_tmp0, cpu_src2, 0x1f);
|
2012-10-16 11:32:13 +02:00
|
|
|
tcg_gen_ext32s_i64(cpu_dst, cpu_src1);
|
2008-03-29 10:09:25 +01:00
|
|
|
tcg_gen_sar_i64(cpu_dst, cpu_dst, cpu_tmp0);
|
2008-02-24 15:10:06 +01:00
|
|
|
}
|
2005-07-23 16:27:54 +02:00
|
|
|
}
|
2012-10-16 11:32:13 +02:00
|
|
|
gen_store_gpr(dc, rd, cpu_dst);
|
2004-12-20 00:18:01 +01:00
|
|
|
#endif
|
2007-04-01 17:08:21 +02:00
|
|
|
} else if (xop < 0x36) {
|
2004-01-04 16:01:44 +01:00
|
|
|
if (xop < 0x20) {
|
2012-10-16 11:32:14 +02:00
|
|
|
cpu_src1 = get_src1(dc, insn);
|
|
|
|
cpu_src2 = get_src2(dc, insn);
|
2004-01-04 16:01:44 +01:00
|
|
|
switch (xop & ~0x10) {
|
2009-05-02 22:19:46 +02:00
|
|
|
case 0x0: /* add */
|
2012-10-16 11:32:13 +02:00
|
|
|
if (xop & 0x10) {
|
|
|
|
gen_op_add_cc(cpu_dst, cpu_src1, cpu_src2);
|
|
|
|
tcg_gen_movi_i32(cpu_cc_op, CC_OP_ADD);
|
|
|
|
dc->cc_op = CC_OP_ADD;
|
2009-05-02 21:14:05 +02:00
|
|
|
} else {
|
2012-10-16 11:32:13 +02:00
|
|
|
tcg_gen_add_tl(cpu_dst, cpu_src1, cpu_src2);
|
2009-05-02 21:14:05 +02:00
|
|
|
}
|
2004-01-04 16:01:44 +01:00
|
|
|
break;
|
2009-05-02 22:19:46 +02:00
|
|
|
case 0x1: /* and */
|
2012-10-16 11:32:13 +02:00
|
|
|
tcg_gen_and_tl(cpu_dst, cpu_src1, cpu_src2);
|
2009-05-02 21:14:05 +02:00
|
|
|
if (xop & 0x10) {
|
2009-05-10 09:38:34 +02:00
|
|
|
tcg_gen_mov_tl(cpu_cc_dst, cpu_dst);
|
|
|
|
tcg_gen_movi_i32(cpu_cc_op, CC_OP_LOGIC);
|
|
|
|
dc->cc_op = CC_OP_LOGIC;
|
2009-05-02 21:14:05 +02:00
|
|
|
}
|
2004-01-04 16:01:44 +01:00
|
|
|
break;
|
2009-05-02 22:19:46 +02:00
|
|
|
case 0x2: /* or */
|
2012-10-16 11:32:13 +02:00
|
|
|
tcg_gen_or_tl(cpu_dst, cpu_src1, cpu_src2);
|
2009-05-10 09:19:11 +02:00
|
|
|
if (xop & 0x10) {
|
2009-05-10 09:38:34 +02:00
|
|
|
tcg_gen_mov_tl(cpu_cc_dst, cpu_dst);
|
|
|
|
tcg_gen_movi_i32(cpu_cc_op, CC_OP_LOGIC);
|
|
|
|
dc->cc_op = CC_OP_LOGIC;
|
2009-05-10 09:19:11 +02:00
|
|
|
}
|
2007-09-20 16:54:22 +02:00
|
|
|
break;
|
2009-05-02 22:19:46 +02:00
|
|
|
case 0x3: /* xor */
|
2012-10-16 11:32:13 +02:00
|
|
|
tcg_gen_xor_tl(cpu_dst, cpu_src1, cpu_src2);
|
2009-05-10 09:19:11 +02:00
|
|
|
if (xop & 0x10) {
|
2009-05-10 09:38:34 +02:00
|
|
|
tcg_gen_mov_tl(cpu_cc_dst, cpu_dst);
|
|
|
|
tcg_gen_movi_i32(cpu_cc_op, CC_OP_LOGIC);
|
|
|
|
dc->cc_op = CC_OP_LOGIC;
|
2009-05-10 09:19:11 +02:00
|
|
|
}
|
2004-01-04 16:01:44 +01:00
|
|
|
break;
|
2009-05-02 22:19:46 +02:00
|
|
|
case 0x4: /* sub */
|
2012-10-16 11:32:13 +02:00
|
|
|
if (xop & 0x10) {
|
|
|
|
gen_op_sub_cc(cpu_dst, cpu_src1, cpu_src2);
|
|
|
|
tcg_gen_movi_i32(cpu_cc_op, CC_OP_SUB);
|
|
|
|
dc->cc_op = CC_OP_SUB;
|
2009-05-02 21:14:05 +02:00
|
|
|
} else {
|
2012-10-16 11:32:13 +02:00
|
|
|
tcg_gen_sub_tl(cpu_dst, cpu_src1, cpu_src2);
|
2009-05-02 21:14:05 +02:00
|
|
|
}
|
2004-01-04 16:01:44 +01:00
|
|
|
break;
|
2009-05-02 22:19:46 +02:00
|
|
|
case 0x5: /* andn */
|
2012-10-16 11:32:13 +02:00
|
|
|
tcg_gen_andc_tl(cpu_dst, cpu_src1, cpu_src2);
|
2009-05-10 09:19:11 +02:00
|
|
|
if (xop & 0x10) {
|
2009-05-10 09:38:34 +02:00
|
|
|
tcg_gen_mov_tl(cpu_cc_dst, cpu_dst);
|
|
|
|
tcg_gen_movi_i32(cpu_cc_op, CC_OP_LOGIC);
|
|
|
|
dc->cc_op = CC_OP_LOGIC;
|
2009-05-10 09:19:11 +02:00
|
|
|
}
|
2004-01-04 16:01:44 +01:00
|
|
|
break;
|
2009-05-02 22:19:46 +02:00
|
|
|
case 0x6: /* orn */
|
2012-10-16 11:32:13 +02:00
|
|
|
tcg_gen_orc_tl(cpu_dst, cpu_src1, cpu_src2);
|
2009-05-10 09:19:11 +02:00
|
|
|
if (xop & 0x10) {
|
2009-05-10 09:38:34 +02:00
|
|
|
tcg_gen_mov_tl(cpu_cc_dst, cpu_dst);
|
|
|
|
tcg_gen_movi_i32(cpu_cc_op, CC_OP_LOGIC);
|
|
|
|
dc->cc_op = CC_OP_LOGIC;
|
2009-05-10 09:19:11 +02:00
|
|
|
}
|
2004-01-04 16:01:44 +01:00
|
|
|
break;
|
2009-05-02 22:19:46 +02:00
|
|
|
case 0x7: /* xorn */
|
2012-10-16 11:32:13 +02:00
|
|
|
tcg_gen_eqv_tl(cpu_dst, cpu_src1, cpu_src2);
|
2009-05-10 09:19:11 +02:00
|
|
|
if (xop & 0x10) {
|
2009-05-10 09:38:34 +02:00
|
|
|
tcg_gen_mov_tl(cpu_cc_dst, cpu_dst);
|
|
|
|
tcg_gen_movi_i32(cpu_cc_op, CC_OP_LOGIC);
|
|
|
|
dc->cc_op = CC_OP_LOGIC;
|
2009-05-10 09:19:11 +02:00
|
|
|
}
|
2004-01-04 16:01:44 +01:00
|
|
|
break;
|
2009-05-02 22:19:46 +02:00
|
|
|
case 0x8: /* addx, V9 addc */
|
2010-05-12 20:04:27 +02:00
|
|
|
gen_op_addx_int(dc, cpu_dst, cpu_src1, cpu_src2,
|
|
|
|
(xop & 0x10));
|
2004-01-04 16:01:44 +01:00
|
|
|
break;
|
2006-06-18 21:36:58 +02:00
|
|
|
#ifdef TARGET_SPARC64
|
2007-09-20 16:54:22 +02:00
|
|
|
case 0x9: /* V9 mulx */
|
2012-10-16 11:32:13 +02:00
|
|
|
tcg_gen_mul_i64(cpu_dst, cpu_src1, cpu_src2);
|
2006-06-18 21:36:58 +02:00
|
|
|
break;
|
|
|
|
#endif
|
2009-05-02 22:19:46 +02:00
|
|
|
case 0xa: /* umul */
|
2008-05-09 22:13:43 +02:00
|
|
|
CHECK_IU_FEATURE(dc, MUL);
|
2008-03-29 10:09:25 +01:00
|
|
|
gen_op_umul(cpu_dst, cpu_src1, cpu_src2);
|
2009-05-10 09:19:11 +02:00
|
|
|
if (xop & 0x10) {
|
2009-05-10 09:38:34 +02:00
|
|
|
tcg_gen_mov_tl(cpu_cc_dst, cpu_dst);
|
|
|
|
tcg_gen_movi_i32(cpu_cc_op, CC_OP_LOGIC);
|
|
|
|
dc->cc_op = CC_OP_LOGIC;
|
2009-05-10 09:19:11 +02:00
|
|
|
}
|
2004-01-04 16:01:44 +01:00
|
|
|
break;
|
2009-05-02 22:19:46 +02:00
|
|
|
case 0xb: /* smul */
|
2008-05-09 22:13:43 +02:00
|
|
|
CHECK_IU_FEATURE(dc, MUL);
|
2008-03-29 10:09:25 +01:00
|
|
|
gen_op_smul(cpu_dst, cpu_src1, cpu_src2);
|
2009-05-10 09:19:11 +02:00
|
|
|
if (xop & 0x10) {
|
2009-05-10 09:38:34 +02:00
|
|
|
tcg_gen_mov_tl(cpu_cc_dst, cpu_dst);
|
|
|
|
tcg_gen_movi_i32(cpu_cc_op, CC_OP_LOGIC);
|
|
|
|
dc->cc_op = CC_OP_LOGIC;
|
2009-05-10 09:19:11 +02:00
|
|
|
}
|
2004-01-04 16:01:44 +01:00
|
|
|
break;
|
2009-05-02 22:19:46 +02:00
|
|
|
case 0xc: /* subx, V9 subc */
|
2010-05-12 20:04:27 +02:00
|
|
|
gen_op_subx_int(dc, cpu_dst, cpu_src1, cpu_src2,
|
|
|
|
(xop & 0x10));
|
2004-01-04 16:01:44 +01:00
|
|
|
break;
|
2006-06-18 21:36:58 +02:00
|
|
|
#ifdef TARGET_SPARC64
|
2007-09-20 16:54:22 +02:00
|
|
|
case 0xd: /* V9 udivx */
|
2012-10-06 01:55:03 +02:00
|
|
|
gen_helper_udivx(cpu_dst, cpu_env, cpu_src1, cpu_src2);
|
2006-06-18 21:36:58 +02:00
|
|
|
break;
|
|
|
|
#endif
|
2009-05-02 22:19:46 +02:00
|
|
|
case 0xe: /* udiv */
|
2008-05-09 22:13:43 +02:00
|
|
|
CHECK_IU_FEATURE(dc, DIV);
|
2009-05-10 09:19:11 +02:00
|
|
|
if (xop & 0x10) {
|
2011-07-04 20:15:42 +02:00
|
|
|
gen_helper_udiv_cc(cpu_dst, cpu_env, cpu_src1,
|
|
|
|
cpu_src2);
|
2009-05-10 09:42:54 +02:00
|
|
|
dc->cc_op = CC_OP_DIV;
|
2010-12-25 23:25:47 +01:00
|
|
|
} else {
|
2011-07-04 20:15:42 +02:00
|
|
|
gen_helper_udiv(cpu_dst, cpu_env, cpu_src1,
|
|
|
|
cpu_src2);
|
2009-05-10 09:19:11 +02:00
|
|
|
}
|
2004-01-04 16:01:44 +01:00
|
|
|
break;
|
2009-05-02 22:19:46 +02:00
|
|
|
case 0xf: /* sdiv */
|
2008-05-09 22:13:43 +02:00
|
|
|
CHECK_IU_FEATURE(dc, DIV);
|
2009-05-10 09:19:11 +02:00
|
|
|
if (xop & 0x10) {
|
2011-07-04 20:15:42 +02:00
|
|
|
gen_helper_sdiv_cc(cpu_dst, cpu_env, cpu_src1,
|
|
|
|
cpu_src2);
|
2009-05-10 09:42:54 +02:00
|
|
|
dc->cc_op = CC_OP_DIV;
|
2010-12-25 23:25:47 +01:00
|
|
|
} else {
|
2011-07-04 20:15:42 +02:00
|
|
|
gen_helper_sdiv(cpu_dst, cpu_env, cpu_src1,
|
|
|
|
cpu_src2);
|
2009-05-10 09:19:11 +02:00
|
|
|
}
|
2004-01-04 16:01:44 +01:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
goto illegal_insn;
|
|
|
|
}
|
2012-10-16 11:32:13 +02:00
|
|
|
gen_store_gpr(dc, rd, cpu_dst);
|
2004-01-04 16:01:44 +01:00
|
|
|
} else {
|
2012-10-16 11:32:14 +02:00
|
|
|
cpu_src1 = get_src1(dc, insn);
|
|
|
|
cpu_src2 = get_src2(dc, insn);
|
2004-01-04 16:01:44 +01:00
|
|
|
switch (xop) {
|
2007-09-20 16:54:22 +02:00
|
|
|
case 0x20: /* taddcc */
|
2012-10-06 01:55:05 +02:00
|
|
|
gen_op_add_cc(cpu_dst, cpu_src1, cpu_src2);
|
2012-10-16 11:32:13 +02:00
|
|
|
gen_store_gpr(dc, rd, cpu_dst);
|
2009-05-10 09:38:35 +02:00
|
|
|
tcg_gen_movi_i32(cpu_cc_op, CC_OP_TADD);
|
|
|
|
dc->cc_op = CC_OP_TADD;
|
2007-09-20 16:54:22 +02:00
|
|
|
break;
|
|
|
|
case 0x21: /* tsubcc */
|
2012-10-06 01:55:05 +02:00
|
|
|
gen_op_sub_cc(cpu_dst, cpu_src1, cpu_src2);
|
2012-10-16 11:32:13 +02:00
|
|
|
gen_store_gpr(dc, rd, cpu_dst);
|
2009-05-10 09:38:35 +02:00
|
|
|
tcg_gen_movi_i32(cpu_cc_op, CC_OP_TSUB);
|
|
|
|
dc->cc_op = CC_OP_TSUB;
|
2007-09-20 16:54:22 +02:00
|
|
|
break;
|
|
|
|
case 0x22: /* taddcctv */
|
2012-10-06 01:55:05 +02:00
|
|
|
gen_helper_taddcctv(cpu_dst, cpu_env,
|
|
|
|
cpu_src1, cpu_src2);
|
2012-10-16 11:32:13 +02:00
|
|
|
gen_store_gpr(dc, rd, cpu_dst);
|
2009-05-10 09:38:35 +02:00
|
|
|
dc->cc_op = CC_OP_TADDTV;
|
2007-09-20 16:54:22 +02:00
|
|
|
break;
|
|
|
|
case 0x23: /* tsubcctv */
|
2012-10-06 01:55:05 +02:00
|
|
|
gen_helper_tsubcctv(cpu_dst, cpu_env,
|
|
|
|
cpu_src1, cpu_src2);
|
2012-10-16 11:32:13 +02:00
|
|
|
gen_store_gpr(dc, rd, cpu_dst);
|
2009-05-10 09:38:35 +02:00
|
|
|
dc->cc_op = CC_OP_TSUBTV;
|
2007-09-20 16:54:22 +02:00
|
|
|
break;
|
2004-01-04 16:01:44 +01:00
|
|
|
case 0x24: /* mulscc */
|
2012-10-09 23:50:00 +02:00
|
|
|
update_psr(dc);
|
2008-03-29 10:09:25 +01:00
|
|
|
gen_op_mulscc(cpu_dst, cpu_src1, cpu_src2);
|
2012-10-16 11:32:13 +02:00
|
|
|
gen_store_gpr(dc, rd, cpu_dst);
|
2009-05-10 09:43:21 +02:00
|
|
|
tcg_gen_movi_i32(cpu_cc_op, CC_OP_ADD);
|
|
|
|
dc->cc_op = CC_OP_ADD;
|
2004-01-04 16:01:44 +01:00
|
|
|
break;
|
2005-07-23 16:27:54 +02:00
|
|
|
#ifndef TARGET_SPARC64
|
2007-09-20 16:54:22 +02:00
|
|
|
case 0x25: /* sll */
|
2008-05-17 11:43:12 +02:00
|
|
|
if (IS_IMM) { /* immediate */
|
2009-05-02 20:58:57 +02:00
|
|
|
simm = GET_FIELDs(insn, 20, 31);
|
|
|
|
tcg_gen_shli_tl(cpu_dst, cpu_src1, simm & 0x1f);
|
2008-05-17 11:43:12 +02:00
|
|
|
} else { /* register */
|
2023-02-25 08:24:23 +01:00
|
|
|
cpu_tmp0 = tcg_temp_new();
|
2008-05-17 11:43:12 +02:00
|
|
|
tcg_gen_andi_tl(cpu_tmp0, cpu_src2, 0x1f);
|
|
|
|
tcg_gen_shl_tl(cpu_dst, cpu_src1, cpu_tmp0);
|
|
|
|
}
|
2012-10-16 11:32:13 +02:00
|
|
|
gen_store_gpr(dc, rd, cpu_dst);
|
2004-01-04 16:01:44 +01:00
|
|
|
break;
|
2005-07-23 16:27:54 +02:00
|
|
|
case 0x26: /* srl */
|
2008-05-17 11:43:12 +02:00
|
|
|
if (IS_IMM) { /* immediate */
|
2009-05-02 20:58:57 +02:00
|
|
|
simm = GET_FIELDs(insn, 20, 31);
|
|
|
|
tcg_gen_shri_tl(cpu_dst, cpu_src1, simm & 0x1f);
|
2008-05-17 11:43:12 +02:00
|
|
|
} else { /* register */
|
2023-02-25 08:24:23 +01:00
|
|
|
cpu_tmp0 = tcg_temp_new();
|
2008-05-17 11:43:12 +02:00
|
|
|
tcg_gen_andi_tl(cpu_tmp0, cpu_src2, 0x1f);
|
|
|
|
tcg_gen_shr_tl(cpu_dst, cpu_src1, cpu_tmp0);
|
|
|
|
}
|
2012-10-16 11:32:13 +02:00
|
|
|
gen_store_gpr(dc, rd, cpu_dst);
|
2004-01-04 16:01:44 +01:00
|
|
|
break;
|
2005-07-23 16:27:54 +02:00
|
|
|
case 0x27: /* sra */
|
2008-05-17 11:43:12 +02:00
|
|
|
if (IS_IMM) { /* immediate */
|
2009-05-02 20:58:57 +02:00
|
|
|
simm = GET_FIELDs(insn, 20, 31);
|
|
|
|
tcg_gen_sari_tl(cpu_dst, cpu_src1, simm & 0x1f);
|
2008-05-17 11:43:12 +02:00
|
|
|
} else { /* register */
|
2023-02-25 08:24:23 +01:00
|
|
|
cpu_tmp0 = tcg_temp_new();
|
2008-05-17 11:43:12 +02:00
|
|
|
tcg_gen_andi_tl(cpu_tmp0, cpu_src2, 0x1f);
|
|
|
|
tcg_gen_sar_tl(cpu_dst, cpu_src1, cpu_tmp0);
|
|
|
|
}
|
2012-10-16 11:32:13 +02:00
|
|
|
gen_store_gpr(dc, rd, cpu_dst);
|
2004-01-04 16:01:44 +01:00
|
|
|
break;
|
2005-07-23 16:27:54 +02:00
|
|
|
#endif
|
2004-01-04 16:01:44 +01:00
|
|
|
case 0x30:
|
|
|
|
{
|
2023-02-25 08:24:23 +01:00
|
|
|
cpu_tmp0 = tcg_temp_new();
|
2004-01-04 16:01:44 +01:00
|
|
|
switch(rd) {
|
2005-07-02 16:31:34 +02:00
|
|
|
case 0: /* wry */
|
2008-09-11 18:01:02 +02:00
|
|
|
tcg_gen_xor_tl(cpu_tmp0, cpu_src1, cpu_src2);
|
|
|
|
tcg_gen_andi_tl(cpu_y, cpu_tmp0, 0xffffffff);
|
2004-01-04 16:01:44 +01:00
|
|
|
break;
|
2007-04-01 17:05:09 +02:00
|
|
|
#ifndef TARGET_SPARC64
|
|
|
|
case 0x01 ... 0x0f: /* undefined in the
|
|
|
|
SPARCv8 manual, nop
|
|
|
|
on the microSPARC
|
|
|
|
II */
|
|
|
|
case 0x10 ... 0x1f: /* implementation-dependent
|
|
|
|
in the SPARCv8
|
|
|
|
manual, nop on the
|
|
|
|
microSPARC II */
|
2013-02-19 12:45:07 +01:00
|
|
|
if ((rd == 0x13) && (dc->def->features &
|
|
|
|
CPU_FEATURE_POWERDOWN)) {
|
|
|
|
/* LEON3 power-down */
|
2013-11-27 08:50:11 +01:00
|
|
|
save_state(dc);
|
2013-02-19 12:45:07 +01:00
|
|
|
gen_helper_power_down(cpu_env);
|
|
|
|
}
|
2007-04-01 17:05:09 +02:00
|
|
|
break;
|
|
|
|
#else
|
2007-09-20 16:54:22 +02:00
|
|
|
case 0x2: /* V9 wrccr */
|
2012-10-16 11:32:29 +02:00
|
|
|
tcg_gen_xor_tl(cpu_tmp0, cpu_src1, cpu_src2);
|
|
|
|
gen_helper_wrccr(cpu_env, cpu_tmp0);
|
2009-05-10 09:19:11 +02:00
|
|
|
tcg_gen_movi_i32(cpu_cc_op, CC_OP_FLAGS);
|
|
|
|
dc->cc_op = CC_OP_FLAGS;
|
2007-09-20 16:54:22 +02:00
|
|
|
break;
|
|
|
|
case 0x3: /* V9 wrasi */
|
2012-10-16 11:32:29 +02:00
|
|
|
tcg_gen_xor_tl(cpu_tmp0, cpu_src1, cpu_src2);
|
|
|
|
tcg_gen_andi_tl(cpu_tmp0, cpu_tmp0, 0xff);
|
2015-09-03 23:14:33 +02:00
|
|
|
tcg_gen_st32_tl(cpu_tmp0, cpu_env,
|
|
|
|
offsetof(CPUSPARCState, asi));
|
|
|
|
/* End TB to notice changed ASI. */
|
|
|
|
save_state(dc);
|
|
|
|
gen_op_next_insn();
|
2018-05-31 03:06:23 +02:00
|
|
|
tcg_gen_exit_tb(NULL, 0);
|
2018-02-15 03:16:30 +01:00
|
|
|
dc->base.is_jmp = DISAS_NORETURN;
|
2007-09-20 16:54:22 +02:00
|
|
|
break;
|
|
|
|
case 0x6: /* V9 wrfprs */
|
2012-10-16 11:32:29 +02:00
|
|
|
tcg_gen_xor_tl(cpu_tmp0, cpu_src1, cpu_src2);
|
|
|
|
tcg_gen_trunc_tl_i32(cpu_fprs, cpu_tmp0);
|
2015-09-09 20:56:38 +02:00
|
|
|
dc->fprs_dirty = 0;
|
2012-10-06 01:54:53 +02:00
|
|
|
save_state(dc);
|
2007-04-13 17:49:56 +02:00
|
|
|
gen_op_next_insn();
|
2018-05-31 03:06:23 +02:00
|
|
|
tcg_gen_exit_tb(NULL, 0);
|
2018-02-15 03:16:30 +01:00
|
|
|
dc->base.is_jmp = DISAS_NORETURN;
|
2007-09-20 16:54:22 +02:00
|
|
|
break;
|
|
|
|
case 0xf: /* V9 sir, nop if user */
|
2005-07-02 16:31:34 +02:00
|
|
|
#if !defined(CONFIG_USER_ONLY)
|
2010-04-18 16:22:14 +02:00
|
|
|
if (supervisor(dc)) {
|
2008-02-24 15:10:06 +01:00
|
|
|
; // XXX
|
2010-04-18 16:22:14 +02:00
|
|
|
}
|
2005-07-02 16:31:34 +02:00
|
|
|
#endif
|
2007-09-20 16:54:22 +02:00
|
|
|
break;
|
|
|
|
case 0x13: /* Graphics Status */
|
2012-10-06 01:54:52 +02:00
|
|
|
if (gen_trap_ifnofpu(dc)) {
|
2006-07-18 23:12:17 +02:00
|
|
|
goto jmp_insn;
|
2012-10-06 01:54:52 +02:00
|
|
|
}
|
2008-09-06 19:51:43 +02:00
|
|
|
tcg_gen_xor_tl(cpu_gsr, cpu_src1, cpu_src2);
|
2007-09-20 16:54:22 +02:00
|
|
|
break;
|
2008-09-22 21:50:28 +02:00
|
|
|
case 0x14: /* Softint set */
|
|
|
|
if (!supervisor(dc))
|
|
|
|
goto illegal_insn;
|
2012-10-16 11:32:27 +02:00
|
|
|
tcg_gen_xor_tl(cpu_tmp0, cpu_src1, cpu_src2);
|
|
|
|
gen_helper_set_softint(cpu_env, cpu_tmp0);
|
2008-09-22 21:50:28 +02:00
|
|
|
break;
|
|
|
|
case 0x15: /* Softint clear */
|
|
|
|
if (!supervisor(dc))
|
|
|
|
goto illegal_insn;
|
2012-10-16 11:32:27 +02:00
|
|
|
tcg_gen_xor_tl(cpu_tmp0, cpu_src1, cpu_src2);
|
|
|
|
gen_helper_clear_softint(cpu_env, cpu_tmp0);
|
2008-09-22 21:50:28 +02:00
|
|
|
break;
|
|
|
|
case 0x16: /* Softint write */
|
|
|
|
if (!supervisor(dc))
|
|
|
|
goto illegal_insn;
|
2012-10-16 11:32:27 +02:00
|
|
|
tcg_gen_xor_tl(cpu_tmp0, cpu_src1, cpu_src2);
|
|
|
|
gen_helper_write_softint(cpu_env, cpu_tmp0);
|
2008-09-22 21:50:28 +02:00
|
|
|
break;
|
2007-09-20 16:54:22 +02:00
|
|
|
case 0x17: /* Tick compare */
|
2005-07-23 16:27:54 +02:00
|
|
|
#if !defined(CONFIG_USER_ONLY)
|
2007-09-20 16:54:22 +02:00
|
|
|
if (!supervisor(dc))
|
|
|
|
goto illegal_insn;
|
2005-07-23 16:27:54 +02:00
|
|
|
#endif
|
2008-03-02 19:28:06 +01:00
|
|
|
{
|
2008-11-17 15:43:54 +01:00
|
|
|
TCGv_ptr r_tickptr;
|
2008-03-02 19:28:06 +01:00
|
|
|
|
2008-09-06 19:51:43 +02:00
|
|
|
tcg_gen_xor_tl(cpu_tick_cmpr, cpu_src1,
|
2008-03-29 10:09:25 +01:00
|
|
|
cpu_src2);
|
2008-11-17 15:43:54 +01:00
|
|
|
r_tickptr = tcg_temp_new_ptr();
|
2008-03-02 19:28:06 +01:00
|
|
|
tcg_gen_ld_ptr(r_tickptr, cpu_env,
|
2012-03-14 01:38:22 +01:00
|
|
|
offsetof(CPUSPARCState, tick));
|
2018-06-15 09:33:03 +02:00
|
|
|
if (tb_cflags(dc->base.tb) &
|
|
|
|
CF_USE_ICOUNT) {
|
|
|
|
gen_io_start();
|
|
|
|
}
|
2008-11-17 15:43:54 +01:00
|
|
|
gen_helper_tick_set_limit(r_tickptr,
|
|
|
|
cpu_tick_cmpr);
|
2018-06-15 09:33:03 +02:00
|
|
|
/* End TB to handle timer interrupt */
|
|
|
|
dc->base.is_jmp = DISAS_EXIT;
|
2008-03-02 19:28:06 +01:00
|
|
|
}
|
2007-09-20 16:54:22 +02:00
|
|
|
break;
|
|
|
|
case 0x18: /* System tick */
|
2005-07-23 16:27:54 +02:00
|
|
|
#if !defined(CONFIG_USER_ONLY)
|
2007-09-20 16:54:22 +02:00
|
|
|
if (!supervisor(dc))
|
|
|
|
goto illegal_insn;
|
2005-07-23 16:27:54 +02:00
|
|
|
#endif
|
2008-03-02 19:28:06 +01:00
|
|
|
{
|
2008-11-17 15:43:54 +01:00
|
|
|
TCGv_ptr r_tickptr;
|
2008-03-02 19:28:06 +01:00
|
|
|
|
2012-10-16 11:32:29 +02:00
|
|
|
tcg_gen_xor_tl(cpu_tmp0, cpu_src1,
|
2008-03-29 10:09:25 +01:00
|
|
|
cpu_src2);
|
2008-11-17 15:43:54 +01:00
|
|
|
r_tickptr = tcg_temp_new_ptr();
|
2008-03-02 19:28:06 +01:00
|
|
|
tcg_gen_ld_ptr(r_tickptr, cpu_env,
|
2012-03-14 01:38:22 +01:00
|
|
|
offsetof(CPUSPARCState, stick));
|
2018-06-15 09:33:03 +02:00
|
|
|
if (tb_cflags(dc->base.tb) &
|
|
|
|
CF_USE_ICOUNT) {
|
|
|
|
gen_io_start();
|
|
|
|
}
|
2008-11-17 15:43:54 +01:00
|
|
|
gen_helper_tick_set_count(r_tickptr,
|
2012-10-16 11:32:29 +02:00
|
|
|
cpu_tmp0);
|
2018-06-15 09:33:03 +02:00
|
|
|
/* End TB to handle timer interrupt */
|
|
|
|
dc->base.is_jmp = DISAS_EXIT;
|
2008-03-02 19:28:06 +01:00
|
|
|
}
|
2007-09-20 16:54:22 +02:00
|
|
|
break;
|
|
|
|
case 0x19: /* System tick compare */
|
2005-07-23 16:27:54 +02:00
|
|
|
#if !defined(CONFIG_USER_ONLY)
|
2007-09-20 16:54:22 +02:00
|
|
|
if (!supervisor(dc))
|
|
|
|
goto illegal_insn;
|
2005-07-02 16:31:34 +02:00
|
|
|
#endif
|
2008-03-02 19:28:06 +01:00
|
|
|
{
|
2008-11-17 15:43:54 +01:00
|
|
|
TCGv_ptr r_tickptr;
|
2008-03-02 19:28:06 +01:00
|
|
|
|
2008-09-06 19:51:43 +02:00
|
|
|
tcg_gen_xor_tl(cpu_stick_cmpr, cpu_src1,
|
2008-03-29 10:09:25 +01:00
|
|
|
cpu_src2);
|
2008-11-17 15:43:54 +01:00
|
|
|
r_tickptr = tcg_temp_new_ptr();
|
2008-03-02 19:28:06 +01:00
|
|
|
tcg_gen_ld_ptr(r_tickptr, cpu_env,
|
2012-03-14 01:38:22 +01:00
|
|
|
offsetof(CPUSPARCState, stick));
|
2018-06-15 09:33:03 +02:00
|
|
|
if (tb_cflags(dc->base.tb) &
|
|
|
|
CF_USE_ICOUNT) {
|
|
|
|
gen_io_start();
|
|
|
|
}
|
2008-11-17 15:43:54 +01:00
|
|
|
gen_helper_tick_set_limit(r_tickptr,
|
|
|
|
cpu_stick_cmpr);
|
2018-06-15 09:33:03 +02:00
|
|
|
/* End TB to handle timer interrupt */
|
|
|
|
dc->base.is_jmp = DISAS_EXIT;
|
2008-03-02 19:28:06 +01:00
|
|
|
}
|
2007-09-20 16:54:22 +02:00
|
|
|
break;
|
2005-07-23 16:27:54 +02:00
|
|
|
|
2007-09-20 16:54:22 +02:00
|
|
|
case 0x10: /* Performance Control */
|
2008-05-12 18:13:33 +02:00
|
|
|
case 0x11: /* Performance Instrumentation
|
|
|
|
Counter */
|
2007-09-20 16:54:22 +02:00
|
|
|
case 0x12: /* Dispatch Control */
|
2005-07-23 16:27:54 +02:00
|
|
|
#endif
|
2005-07-02 16:31:34 +02:00
|
|
|
default:
|
2004-01-04 16:01:44 +01:00
|
|
|
goto illegal_insn;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2004-09-30 23:55:55 +02:00
|
|
|
#if !defined(CONFIG_USER_ONLY)
|
2005-01-30 23:39:04 +01:00
|
|
|
case 0x31: /* wrpsr, V9 saved, restored */
|
2004-09-30 23:55:55 +02:00
|
|
|
{
|
2007-09-20 16:54:22 +02:00
|
|
|
if (!supervisor(dc))
|
|
|
|
goto priv_insn;
|
2005-07-02 16:31:34 +02:00
|
|
|
#ifdef TARGET_SPARC64
|
2007-09-20 16:54:22 +02:00
|
|
|
switch (rd) {
|
|
|
|
case 0:
|
2011-07-03 23:01:59 +02:00
|
|
|
gen_helper_saved(cpu_env);
|
2007-09-20 16:54:22 +02:00
|
|
|
break;
|
|
|
|
case 1:
|
2011-07-03 23:01:59 +02:00
|
|
|
gen_helper_restored(cpu_env);
|
2007-09-20 16:54:22 +02:00
|
|
|
break;
|
2007-04-22 21:14:52 +02:00
|
|
|
case 2: /* UA2005 allclean */
|
|
|
|
case 3: /* UA2005 otherw */
|
|
|
|
case 4: /* UA2005 normalw */
|
|
|
|
case 5: /* UA2005 invalw */
|
|
|
|
// XXX
|
2007-09-20 16:54:22 +02:00
|
|
|
default:
|
2005-07-02 16:31:34 +02:00
|
|
|
goto illegal_insn;
|
|
|
|
}
|
|
|
|
#else
|
2023-02-25 08:24:23 +01:00
|
|
|
cpu_tmp0 = tcg_temp_new();
|
2012-10-16 11:32:29 +02:00
|
|
|
tcg_gen_xor_tl(cpu_tmp0, cpu_src1, cpu_src2);
|
|
|
|
gen_helper_wrpsr(cpu_env, cpu_tmp0);
|
2009-05-10 09:19:11 +02:00
|
|
|
tcg_gen_movi_i32(cpu_cc_op, CC_OP_FLAGS);
|
|
|
|
dc->cc_op = CC_OP_FLAGS;
|
2012-10-06 01:54:53 +02:00
|
|
|
save_state(dc);
|
2005-11-11 01:24:58 +01:00
|
|
|
gen_op_next_insn();
|
2018-05-31 03:06:23 +02:00
|
|
|
tcg_gen_exit_tb(NULL, 0);
|
2018-02-15 03:16:30 +01:00
|
|
|
dc->base.is_jmp = DISAS_NORETURN;
|
2005-07-02 16:31:34 +02:00
|
|
|
#endif
|
2004-09-30 23:55:55 +02:00
|
|
|
}
|
|
|
|
break;
|
2005-01-30 23:39:04 +01:00
|
|
|
case 0x32: /* wrwim, V9 wrpr */
|
2004-09-30 23:55:55 +02:00
|
|
|
{
|
2007-09-20 16:54:22 +02:00
|
|
|
if (!supervisor(dc))
|
|
|
|
goto priv_insn;
|
2023-02-25 08:24:23 +01:00
|
|
|
cpu_tmp0 = tcg_temp_new();
|
2008-06-21 21:50:10 +02:00
|
|
|
tcg_gen_xor_tl(cpu_tmp0, cpu_src1, cpu_src2);
|
2005-07-02 16:31:34 +02:00
|
|
|
#ifdef TARGET_SPARC64
|
2007-09-20 16:54:22 +02:00
|
|
|
switch (rd) {
|
|
|
|
case 0: // tpc
|
2008-03-05 18:59:48 +01:00
|
|
|
{
|
2008-11-17 15:43:54 +01:00
|
|
|
TCGv_ptr r_tsptr;
|
2008-03-05 18:59:48 +01:00
|
|
|
|
2008-11-17 15:43:54 +01:00
|
|
|
r_tsptr = tcg_temp_new_ptr();
|
2009-08-03 21:15:02 +02:00
|
|
|
gen_load_trap_state_at_tl(r_tsptr, cpu_env);
|
2008-06-21 21:50:10 +02:00
|
|
|
tcg_gen_st_tl(cpu_tmp0, r_tsptr,
|
2008-03-05 18:59:48 +01:00
|
|
|
offsetof(trap_state, tpc));
|
|
|
|
}
|
2007-09-20 16:54:22 +02:00
|
|
|
break;
|
|
|
|
case 1: // tnpc
|
2008-03-05 18:59:48 +01:00
|
|
|
{
|
2008-11-17 15:43:54 +01:00
|
|
|
TCGv_ptr r_tsptr;
|
2008-03-05 18:59:48 +01:00
|
|
|
|
2008-11-17 15:43:54 +01:00
|
|
|
r_tsptr = tcg_temp_new_ptr();
|
2009-08-03 21:15:02 +02:00
|
|
|
gen_load_trap_state_at_tl(r_tsptr, cpu_env);
|
2008-06-21 21:50:10 +02:00
|
|
|
tcg_gen_st_tl(cpu_tmp0, r_tsptr,
|
2008-03-05 18:59:48 +01:00
|
|
|
offsetof(trap_state, tnpc));
|
|
|
|
}
|
2007-09-20 16:54:22 +02:00
|
|
|
break;
|
|
|
|
case 2: // tstate
|
2008-03-05 18:59:48 +01:00
|
|
|
{
|
2008-11-17 15:43:54 +01:00
|
|
|
TCGv_ptr r_tsptr;
|
2008-03-05 18:59:48 +01:00
|
|
|
|
2008-11-17 15:43:54 +01:00
|
|
|
r_tsptr = tcg_temp_new_ptr();
|
2009-08-03 21:15:02 +02:00
|
|
|
gen_load_trap_state_at_tl(r_tsptr, cpu_env);
|
2008-06-21 21:50:10 +02:00
|
|
|
tcg_gen_st_tl(cpu_tmp0, r_tsptr,
|
2008-05-12 18:13:33 +02:00
|
|
|
offsetof(trap_state,
|
|
|
|
tstate));
|
2008-03-05 18:59:48 +01:00
|
|
|
}
|
2007-09-20 16:54:22 +02:00
|
|
|
break;
|
|
|
|
case 3: // tt
|
2008-03-05 18:59:48 +01:00
|
|
|
{
|
2008-11-17 15:43:54 +01:00
|
|
|
TCGv_ptr r_tsptr;
|
2008-03-05 18:59:48 +01:00
|
|
|
|
2008-11-17 15:43:54 +01:00
|
|
|
r_tsptr = tcg_temp_new_ptr();
|
2009-08-03 21:15:02 +02:00
|
|
|
gen_load_trap_state_at_tl(r_tsptr, cpu_env);
|
2012-10-16 11:32:23 +02:00
|
|
|
tcg_gen_st32_tl(cpu_tmp0, r_tsptr,
|
|
|
|
offsetof(trap_state, tt));
|
2008-03-05 18:59:48 +01:00
|
|
|
}
|
2007-09-20 16:54:22 +02:00
|
|
|
break;
|
|
|
|
case 4: // tick
|
2008-03-02 19:28:06 +01:00
|
|
|
{
|
2008-11-17 15:43:54 +01:00
|
|
|
TCGv_ptr r_tickptr;
|
2008-03-02 19:28:06 +01:00
|
|
|
|
2008-11-17 15:43:54 +01:00
|
|
|
r_tickptr = tcg_temp_new_ptr();
|
2008-03-02 19:28:06 +01:00
|
|
|
tcg_gen_ld_ptr(r_tickptr, cpu_env,
|
2012-03-14 01:38:22 +01:00
|
|
|
offsetof(CPUSPARCState, tick));
|
2018-06-15 09:33:03 +02:00
|
|
|
if (tb_cflags(dc->base.tb) &
|
|
|
|
CF_USE_ICOUNT) {
|
|
|
|
gen_io_start();
|
|
|
|
}
|
2008-11-17 15:43:54 +01:00
|
|
|
gen_helper_tick_set_count(r_tickptr,
|
|
|
|
cpu_tmp0);
|
2018-06-15 09:33:03 +02:00
|
|
|
/* End TB to handle timer interrupt */
|
|
|
|
dc->base.is_jmp = DISAS_EXIT;
|
2008-03-02 19:28:06 +01:00
|
|
|
}
|
2007-09-20 16:54:22 +02:00
|
|
|
break;
|
|
|
|
case 5: // tba
|
2008-09-06 19:51:43 +02:00
|
|
|
tcg_gen_mov_tl(cpu_tbr, cpu_tmp0);
|
2007-09-20 16:54:22 +02:00
|
|
|
break;
|
|
|
|
case 6: // pstate
|
2012-10-09 23:49:59 +02:00
|
|
|
save_state(dc);
|
2018-06-15 09:33:03 +02:00
|
|
|
if (tb_cflags(dc->base.tb) & CF_USE_ICOUNT) {
|
|
|
|
gen_io_start();
|
|
|
|
}
|
2012-10-09 23:49:59 +02:00
|
|
|
gen_helper_wrpstate(cpu_env, cpu_tmp0);
|
2018-06-15 09:33:03 +02:00
|
|
|
if (tb_cflags(dc->base.tb) & CF_USE_ICOUNT) {
|
2021-07-24 15:49:01 +02:00
|
|
|
/* I/O ops in icount mode must end the TB */
|
|
|
|
dc->base.is_jmp = DISAS_EXIT;
|
2018-06-15 09:33:03 +02:00
|
|
|
}
|
2012-10-09 23:49:59 +02:00
|
|
|
dc->npc = DYNAMIC_PC;
|
2007-09-20 16:54:22 +02:00
|
|
|
break;
|
|
|
|
case 7: // tl
|
2012-10-09 23:49:59 +02:00
|
|
|
save_state(dc);
|
2012-10-16 11:32:23 +02:00
|
|
|
tcg_gen_st32_tl(cpu_tmp0, cpu_env,
|
2012-10-09 23:49:59 +02:00
|
|
|
offsetof(CPUSPARCState, tl));
|
|
|
|
dc->npc = DYNAMIC_PC;
|
2007-09-20 16:54:22 +02:00
|
|
|
break;
|
|
|
|
case 8: // pil
|
2018-06-15 09:33:03 +02:00
|
|
|
if (tb_cflags(dc->base.tb) & CF_USE_ICOUNT) {
|
|
|
|
gen_io_start();
|
|
|
|
}
|
2011-07-03 23:01:59 +02:00
|
|
|
gen_helper_wrpil(cpu_env, cpu_tmp0);
|
2018-06-15 09:33:03 +02:00
|
|
|
if (tb_cflags(dc->base.tb) & CF_USE_ICOUNT) {
|
2021-07-24 15:49:01 +02:00
|
|
|
/* I/O ops in icount mode must end the TB */
|
|
|
|
dc->base.is_jmp = DISAS_EXIT;
|
2018-06-15 09:33:03 +02:00
|
|
|
}
|
2007-09-20 16:54:22 +02:00
|
|
|
break;
|
|
|
|
case 9: // cwp
|
2011-07-03 23:01:59 +02:00
|
|
|
gen_helper_wrcwp(cpu_env, cpu_tmp0);
|
2007-09-20 16:54:22 +02:00
|
|
|
break;
|
|
|
|
case 10: // cansave
|
2012-10-16 11:32:23 +02:00
|
|
|
tcg_gen_st32_tl(cpu_tmp0, cpu_env,
|
|
|
|
offsetof(CPUSPARCState,
|
|
|
|
cansave));
|
2007-09-20 16:54:22 +02:00
|
|
|
break;
|
|
|
|
case 11: // canrestore
|
2012-10-16 11:32:23 +02:00
|
|
|
tcg_gen_st32_tl(cpu_tmp0, cpu_env,
|
|
|
|
offsetof(CPUSPARCState,
|
|
|
|
canrestore));
|
2007-09-20 16:54:22 +02:00
|
|
|
break;
|
|
|
|
case 12: // cleanwin
|
2012-10-16 11:32:23 +02:00
|
|
|
tcg_gen_st32_tl(cpu_tmp0, cpu_env,
|
|
|
|
offsetof(CPUSPARCState,
|
|
|
|
cleanwin));
|
2007-09-20 16:54:22 +02:00
|
|
|
break;
|
|
|
|
case 13: // otherwin
|
2012-10-16 11:32:23 +02:00
|
|
|
tcg_gen_st32_tl(cpu_tmp0, cpu_env,
|
|
|
|
offsetof(CPUSPARCState,
|
|
|
|
otherwin));
|
2007-09-20 16:54:22 +02:00
|
|
|
break;
|
|
|
|
case 14: // wstate
|
2012-10-16 11:32:23 +02:00
|
|
|
tcg_gen_st32_tl(cpu_tmp0, cpu_env,
|
|
|
|
offsetof(CPUSPARCState,
|
|
|
|
wstate));
|
2007-09-20 16:54:22 +02:00
|
|
|
break;
|
2007-04-22 21:14:52 +02:00
|
|
|
case 16: // UA2005 gl
|
2008-07-20 20:22:16 +02:00
|
|
|
CHECK_IU_FEATURE(dc, GL);
|
2016-06-07 18:34:49 +02:00
|
|
|
gen_helper_wrgl(cpu_env, cpu_tmp0);
|
2007-04-22 21:14:52 +02:00
|
|
|
break;
|
|
|
|
case 26: // UA2005 strand status
|
2008-07-20 20:22:16 +02:00
|
|
|
CHECK_IU_FEATURE(dc, HYPV);
|
2007-04-22 21:14:52 +02:00
|
|
|
if (!hypervisor(dc))
|
|
|
|
goto priv_insn;
|
2008-11-01 14:44:52 +01:00
|
|
|
tcg_gen_mov_tl(cpu_ssr, cpu_tmp0);
|
2007-04-22 21:14:52 +02:00
|
|
|
break;
|
2007-09-20 16:54:22 +02:00
|
|
|
default:
|
|
|
|
goto illegal_insn;
|
|
|
|
}
|
2005-07-02 16:31:34 +02:00
|
|
|
#else
|
2012-10-16 11:32:23 +02:00
|
|
|
tcg_gen_trunc_tl_i32(cpu_wim, cpu_tmp0);
|
|
|
|
if (dc->def->nwindows != 32) {
|
|
|
|
tcg_gen_andi_tl(cpu_wim, cpu_wim,
|
2008-08-21 19:34:42 +02:00
|
|
|
(1 << dc->def->nwindows) - 1);
|
2012-10-16 11:32:23 +02:00
|
|
|
}
|
2005-07-02 16:31:34 +02:00
|
|
|
#endif
|
2004-09-30 23:55:55 +02:00
|
|
|
}
|
|
|
|
break;
|
2007-04-22 21:14:52 +02:00
|
|
|
case 0x33: /* wrtbr, UA2005 wrhpr */
|
2004-09-30 23:55:55 +02:00
|
|
|
{
|
2007-04-22 21:14:52 +02:00
|
|
|
#ifndef TARGET_SPARC64
|
2007-09-20 16:54:22 +02:00
|
|
|
if (!supervisor(dc))
|
|
|
|
goto priv_insn;
|
2008-09-06 19:51:43 +02:00
|
|
|
tcg_gen_xor_tl(cpu_tbr, cpu_src1, cpu_src2);
|
2007-04-22 21:14:52 +02:00
|
|
|
#else
|
2008-07-20 20:22:16 +02:00
|
|
|
CHECK_IU_FEATURE(dc, HYPV);
|
2007-04-22 21:14:52 +02:00
|
|
|
if (!hypervisor(dc))
|
|
|
|
goto priv_insn;
|
2023-02-25 08:24:23 +01:00
|
|
|
cpu_tmp0 = tcg_temp_new();
|
2008-06-21 21:50:10 +02:00
|
|
|
tcg_gen_xor_tl(cpu_tmp0, cpu_src1, cpu_src2);
|
2007-04-22 21:14:52 +02:00
|
|
|
switch (rd) {
|
|
|
|
case 0: // hpstate
|
2016-06-08 14:14:36 +02:00
|
|
|
tcg_gen_st_i64(cpu_tmp0, cpu_env,
|
|
|
|
offsetof(CPUSPARCState,
|
|
|
|
hpstate));
|
2012-10-06 01:54:53 +02:00
|
|
|
save_state(dc);
|
2007-04-22 21:14:52 +02:00
|
|
|
gen_op_next_insn();
|
2018-05-31 03:06:23 +02:00
|
|
|
tcg_gen_exit_tb(NULL, 0);
|
2018-02-15 03:16:30 +01:00
|
|
|
dc->base.is_jmp = DISAS_NORETURN;
|
2007-04-22 21:14:52 +02:00
|
|
|
break;
|
|
|
|
case 1: // htstate
|
|
|
|
// XXX gen_op_wrhtstate();
|
|
|
|
break;
|
|
|
|
case 3: // hintp
|
2008-09-06 19:51:43 +02:00
|
|
|
tcg_gen_mov_tl(cpu_hintp, cpu_tmp0);
|
2007-04-22 21:14:52 +02:00
|
|
|
break;
|
|
|
|
case 5: // htba
|
2008-09-06 19:51:43 +02:00
|
|
|
tcg_gen_mov_tl(cpu_htba, cpu_tmp0);
|
2007-04-22 21:14:52 +02:00
|
|
|
break;
|
|
|
|
case 31: // hstick_cmpr
|
2008-03-02 19:28:06 +01:00
|
|
|
{
|
2008-11-17 15:43:54 +01:00
|
|
|
TCGv_ptr r_tickptr;
|
2008-03-02 19:28:06 +01:00
|
|
|
|
2008-09-06 19:51:43 +02:00
|
|
|
tcg_gen_mov_tl(cpu_hstick_cmpr, cpu_tmp0);
|
2008-11-17 15:43:54 +01:00
|
|
|
r_tickptr = tcg_temp_new_ptr();
|
2008-03-02 19:28:06 +01:00
|
|
|
tcg_gen_ld_ptr(r_tickptr, cpu_env,
|
2012-03-14 01:38:22 +01:00
|
|
|
offsetof(CPUSPARCState, hstick));
|
2018-06-15 09:33:03 +02:00
|
|
|
if (tb_cflags(dc->base.tb) &
|
|
|
|
CF_USE_ICOUNT) {
|
|
|
|
gen_io_start();
|
|
|
|
}
|
2008-11-17 15:43:54 +01:00
|
|
|
gen_helper_tick_set_limit(r_tickptr,
|
|
|
|
cpu_hstick_cmpr);
|
2018-06-15 09:33:03 +02:00
|
|
|
/* End TB to handle timer interrupt */
|
|
|
|
dc->base.is_jmp = DISAS_EXIT;
|
2008-03-02 19:28:06 +01:00
|
|
|
}
|
2007-04-22 21:14:52 +02:00
|
|
|
break;
|
|
|
|
case 6: // hver readonly
|
|
|
|
default:
|
|
|
|
goto illegal_insn;
|
|
|
|
}
|
|
|
|
#endif
|
2004-09-30 23:55:55 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
#endif
|
2005-07-02 16:31:34 +02:00
|
|
|
#ifdef TARGET_SPARC64
|
2007-09-20 16:54:22 +02:00
|
|
|
case 0x2c: /* V9 movcc */
|
|
|
|
{
|
|
|
|
int cc = GET_FIELD_SP(insn, 11, 12);
|
|
|
|
int cond = GET_FIELD_SP(insn, 14, 17);
|
2012-10-06 01:55:00 +02:00
|
|
|
DisasCompare cmp;
|
2012-10-16 11:32:13 +02:00
|
|
|
TCGv dst;
|
2008-03-02 19:25:27 +01:00
|
|
|
|
2007-09-20 16:54:22 +02:00
|
|
|
if (insn & (1 << 18)) {
|
2012-10-06 01:55:00 +02:00
|
|
|
if (cc == 0) {
|
|
|
|
gen_compare(&cmp, 0, cond, dc);
|
|
|
|
} else if (cc == 2) {
|
|
|
|
gen_compare(&cmp, 1, cond, dc);
|
|
|
|
} else {
|
2007-09-20 16:54:22 +02:00
|
|
|
goto illegal_insn;
|
2012-10-06 01:55:00 +02:00
|
|
|
}
|
2007-09-20 16:54:22 +02:00
|
|
|
} else {
|
2012-10-06 01:55:00 +02:00
|
|
|
gen_fcompare(&cmp, cc, cond);
|
2007-09-20 16:54:22 +02:00
|
|
|
}
|
2008-03-02 19:25:27 +01:00
|
|
|
|
2012-10-06 01:55:00 +02:00
|
|
|
/* The get_src2 above loaded the normal 13-bit
|
|
|
|
immediate field, not the 11-bit field we have
|
|
|
|
in movcc. But it did handle the reg case. */
|
|
|
|
if (IS_IMM) {
|
2009-05-02 20:58:57 +02:00
|
|
|
simm = GET_FIELD_SPs(insn, 0, 10);
|
2012-10-06 01:55:00 +02:00
|
|
|
tcg_gen_movi_tl(cpu_src2, simm);
|
2008-03-02 19:25:27 +01:00
|
|
|
}
|
2012-10-06 01:55:00 +02:00
|
|
|
|
2012-10-16 11:32:13 +02:00
|
|
|
dst = gen_load_gpr(dc, rd);
|
|
|
|
tcg_gen_movcond_tl(cmp.cond, dst,
|
2012-10-06 01:55:00 +02:00
|
|
|
cmp.c1, cmp.c2,
|
2012-10-16 11:32:13 +02:00
|
|
|
cpu_src2, dst);
|
|
|
|
gen_store_gpr(dc, rd, dst);
|
2007-09-20 16:54:22 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 0x2d: /* V9 sdivx */
|
2012-10-06 01:55:03 +02:00
|
|
|
gen_helper_sdivx(cpu_dst, cpu_env, cpu_src1, cpu_src2);
|
2012-10-16 11:32:13 +02:00
|
|
|
gen_store_gpr(dc, rd, cpu_dst);
|
2007-09-20 16:54:22 +02:00
|
|
|
break;
|
|
|
|
case 0x2e: /* V9 popc */
|
2016-11-21 12:08:27 +01:00
|
|
|
tcg_gen_ctpop_tl(cpu_dst, cpu_src2);
|
2012-10-16 11:32:13 +02:00
|
|
|
gen_store_gpr(dc, rd, cpu_dst);
|
|
|
|
break;
|
2007-09-20 16:54:22 +02:00
|
|
|
case 0x2f: /* V9 movr */
|
|
|
|
{
|
|
|
|
int cond = GET_FIELD_SP(insn, 10, 12);
|
2012-10-06 01:55:01 +02:00
|
|
|
DisasCompare cmp;
|
2012-10-16 11:32:13 +02:00
|
|
|
TCGv dst;
|
2008-03-02 19:25:27 +01:00
|
|
|
|
2012-10-06 01:55:01 +02:00
|
|
|
gen_compare_reg(&cmp, cond, cpu_src1);
|
2008-05-27 21:39:12 +02:00
|
|
|
|
2012-10-06 01:55:01 +02:00
|
|
|
/* The get_src2 above loaded the normal 13-bit
|
|
|
|
immediate field, not the 10-bit field we have
|
|
|
|
in movr. But it did handle the reg case. */
|
|
|
|
if (IS_IMM) {
|
2009-05-02 20:58:57 +02:00
|
|
|
simm = GET_FIELD_SPs(insn, 0, 9);
|
2012-10-06 01:55:01 +02:00
|
|
|
tcg_gen_movi_tl(cpu_src2, simm);
|
2007-09-20 16:54:22 +02:00
|
|
|
}
|
2012-10-06 01:55:01 +02:00
|
|
|
|
2012-10-16 11:32:13 +02:00
|
|
|
dst = gen_load_gpr(dc, rd);
|
|
|
|
tcg_gen_movcond_tl(cmp.cond, dst,
|
2012-10-06 01:55:01 +02:00
|
|
|
cmp.c1, cmp.c2,
|
2012-10-16 11:32:13 +02:00
|
|
|
cpu_src2, dst);
|
|
|
|
gen_store_gpr(dc, rd, dst);
|
2007-09-20 16:54:22 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
default:
|
|
|
|
goto illegal_insn;
|
|
|
|
}
|
|
|
|
}
|
2007-04-13 17:49:56 +02:00
|
|
|
} else if (xop == 0x36) { /* UltraSparc shutdown, VIS, V8 CPop1 */
|
|
|
|
#ifdef TARGET_SPARC64
|
|
|
|
int opf = GET_FIELD_SP(insn, 5, 13);
|
|
|
|
rs1 = GET_FIELD(insn, 13, 17);
|
|
|
|
rs2 = GET_FIELD(insn, 27, 31);
|
2012-10-06 01:54:52 +02:00
|
|
|
if (gen_trap_ifnofpu(dc)) {
|
2007-04-22 21:14:52 +02:00
|
|
|
goto jmp_insn;
|
2012-10-06 01:54:52 +02:00
|
|
|
}
|
2007-04-13 17:49:56 +02:00
|
|
|
|
|
|
|
switch (opf) {
|
2007-04-22 21:14:52 +02:00
|
|
|
case 0x000: /* VIS I edge8cc */
|
2011-10-18 04:57:23 +02:00
|
|
|
CHECK_FPU_FEATURE(dc, VIS1);
|
2012-10-16 11:32:13 +02:00
|
|
|
cpu_src1 = gen_load_gpr(dc, rs1);
|
|
|
|
cpu_src2 = gen_load_gpr(dc, rs2);
|
2011-10-18 04:57:23 +02:00
|
|
|
gen_edge(dc, cpu_dst, cpu_src1, cpu_src2, 8, 1, 0);
|
2012-10-16 11:32:13 +02:00
|
|
|
gen_store_gpr(dc, rd, cpu_dst);
|
2011-10-18 04:57:23 +02:00
|
|
|
break;
|
2007-04-22 21:14:52 +02:00
|
|
|
case 0x001: /* VIS II edge8n */
|
2011-10-18 04:57:23 +02:00
|
|
|
CHECK_FPU_FEATURE(dc, VIS2);
|
2012-10-16 11:32:13 +02:00
|
|
|
cpu_src1 = gen_load_gpr(dc, rs1);
|
|
|
|
cpu_src2 = gen_load_gpr(dc, rs2);
|
2011-10-18 04:57:23 +02:00
|
|
|
gen_edge(dc, cpu_dst, cpu_src1, cpu_src2, 8, 0, 0);
|
2012-10-16 11:32:13 +02:00
|
|
|
gen_store_gpr(dc, rd, cpu_dst);
|
2011-10-18 04:57:23 +02:00
|
|
|
break;
|
2007-04-22 21:14:52 +02:00
|
|
|
case 0x002: /* VIS I edge8lcc */
|
2011-10-18 04:57:23 +02:00
|
|
|
CHECK_FPU_FEATURE(dc, VIS1);
|
2012-10-16 11:32:13 +02:00
|
|
|
cpu_src1 = gen_load_gpr(dc, rs1);
|
|
|
|
cpu_src2 = gen_load_gpr(dc, rs2);
|
2011-10-18 04:57:23 +02:00
|
|
|
gen_edge(dc, cpu_dst, cpu_src1, cpu_src2, 8, 1, 1);
|
2012-10-16 11:32:13 +02:00
|
|
|
gen_store_gpr(dc, rd, cpu_dst);
|
2011-10-18 04:57:23 +02:00
|
|
|
break;
|
2007-04-22 21:14:52 +02:00
|
|
|
case 0x003: /* VIS II edge8ln */
|
2011-10-18 04:57:23 +02:00
|
|
|
CHECK_FPU_FEATURE(dc, VIS2);
|
2012-10-16 11:32:13 +02:00
|
|
|
cpu_src1 = gen_load_gpr(dc, rs1);
|
|
|
|
cpu_src2 = gen_load_gpr(dc, rs2);
|
2011-10-18 04:57:23 +02:00
|
|
|
gen_edge(dc, cpu_dst, cpu_src1, cpu_src2, 8, 0, 1);
|
2012-10-16 11:32:13 +02:00
|
|
|
gen_store_gpr(dc, rd, cpu_dst);
|
2011-10-18 04:57:23 +02:00
|
|
|
break;
|
2007-04-22 21:14:52 +02:00
|
|
|
case 0x004: /* VIS I edge16cc */
|
2011-10-18 04:57:23 +02:00
|
|
|
CHECK_FPU_FEATURE(dc, VIS1);
|
2012-10-16 11:32:13 +02:00
|
|
|
cpu_src1 = gen_load_gpr(dc, rs1);
|
|
|
|
cpu_src2 = gen_load_gpr(dc, rs2);
|
2011-10-18 04:57:23 +02:00
|
|
|
gen_edge(dc, cpu_dst, cpu_src1, cpu_src2, 16, 1, 0);
|
2012-10-16 11:32:13 +02:00
|
|
|
gen_store_gpr(dc, rd, cpu_dst);
|
2011-10-18 04:57:23 +02:00
|
|
|
break;
|
2007-04-22 21:14:52 +02:00
|
|
|
case 0x005: /* VIS II edge16n */
|
2011-10-18 04:57:23 +02:00
|
|
|
CHECK_FPU_FEATURE(dc, VIS2);
|
2012-10-16 11:32:13 +02:00
|
|
|
cpu_src1 = gen_load_gpr(dc, rs1);
|
|
|
|
cpu_src2 = gen_load_gpr(dc, rs2);
|
2011-10-18 04:57:23 +02:00
|
|
|
gen_edge(dc, cpu_dst, cpu_src1, cpu_src2, 16, 0, 0);
|
2012-10-16 11:32:13 +02:00
|
|
|
gen_store_gpr(dc, rd, cpu_dst);
|
2011-10-18 04:57:23 +02:00
|
|
|
break;
|
2007-04-22 21:14:52 +02:00
|
|
|
case 0x006: /* VIS I edge16lcc */
|
2011-10-18 04:57:23 +02:00
|
|
|
CHECK_FPU_FEATURE(dc, VIS1);
|
2012-10-16 11:32:13 +02:00
|
|
|
cpu_src1 = gen_load_gpr(dc, rs1);
|
|
|
|
cpu_src2 = gen_load_gpr(dc, rs2);
|
2011-10-18 04:57:23 +02:00
|
|
|
gen_edge(dc, cpu_dst, cpu_src1, cpu_src2, 16, 1, 1);
|
2012-10-16 11:32:13 +02:00
|
|
|
gen_store_gpr(dc, rd, cpu_dst);
|
2011-10-18 04:57:23 +02:00
|
|
|
break;
|
2007-04-22 21:14:52 +02:00
|
|
|
case 0x007: /* VIS II edge16ln */
|
2011-10-18 04:57:23 +02:00
|
|
|
CHECK_FPU_FEATURE(dc, VIS2);
|
2012-10-16 11:32:13 +02:00
|
|
|
cpu_src1 = gen_load_gpr(dc, rs1);
|
|
|
|
cpu_src2 = gen_load_gpr(dc, rs2);
|
2011-10-18 04:57:23 +02:00
|
|
|
gen_edge(dc, cpu_dst, cpu_src1, cpu_src2, 16, 0, 1);
|
2012-10-16 11:32:13 +02:00
|
|
|
gen_store_gpr(dc, rd, cpu_dst);
|
2011-10-18 04:57:23 +02:00
|
|
|
break;
|
2007-04-22 21:14:52 +02:00
|
|
|
case 0x008: /* VIS I edge32cc */
|
2011-10-18 04:57:23 +02:00
|
|
|
CHECK_FPU_FEATURE(dc, VIS1);
|
2012-10-16 11:32:13 +02:00
|
|
|
cpu_src1 = gen_load_gpr(dc, rs1);
|
|
|
|
cpu_src2 = gen_load_gpr(dc, rs2);
|
2011-10-18 04:57:23 +02:00
|
|
|
gen_edge(dc, cpu_dst, cpu_src1, cpu_src2, 32, 1, 0);
|
2012-10-16 11:32:13 +02:00
|
|
|
gen_store_gpr(dc, rd, cpu_dst);
|
2011-10-18 04:57:23 +02:00
|
|
|
break;
|
2007-04-22 21:14:52 +02:00
|
|
|
case 0x009: /* VIS II edge32n */
|
2011-10-18 04:57:23 +02:00
|
|
|
CHECK_FPU_FEATURE(dc, VIS2);
|
2012-10-16 11:32:13 +02:00
|
|
|
cpu_src1 = gen_load_gpr(dc, rs1);
|
|
|
|
cpu_src2 = gen_load_gpr(dc, rs2);
|
2011-10-18 04:57:23 +02:00
|
|
|
gen_edge(dc, cpu_dst, cpu_src1, cpu_src2, 32, 0, 0);
|
2012-10-16 11:32:13 +02:00
|
|
|
gen_store_gpr(dc, rd, cpu_dst);
|
2011-10-18 04:57:23 +02:00
|
|
|
break;
|
2007-04-22 21:14:52 +02:00
|
|
|
case 0x00a: /* VIS I edge32lcc */
|
2011-10-18 04:57:23 +02:00
|
|
|
CHECK_FPU_FEATURE(dc, VIS1);
|
2012-10-16 11:32:13 +02:00
|
|
|
cpu_src1 = gen_load_gpr(dc, rs1);
|
|
|
|
cpu_src2 = gen_load_gpr(dc, rs2);
|
2011-10-18 04:57:23 +02:00
|
|
|
gen_edge(dc, cpu_dst, cpu_src1, cpu_src2, 32, 1, 1);
|
2012-10-16 11:32:13 +02:00
|
|
|
gen_store_gpr(dc, rd, cpu_dst);
|
2011-10-18 04:57:23 +02:00
|
|
|
break;
|
2007-04-22 21:14:52 +02:00
|
|
|
case 0x00b: /* VIS II edge32ln */
|
2011-10-18 04:57:23 +02:00
|
|
|
CHECK_FPU_FEATURE(dc, VIS2);
|
2012-10-16 11:32:13 +02:00
|
|
|
cpu_src1 = gen_load_gpr(dc, rs1);
|
|
|
|
cpu_src2 = gen_load_gpr(dc, rs2);
|
2011-10-18 04:57:23 +02:00
|
|
|
gen_edge(dc, cpu_dst, cpu_src1, cpu_src2, 32, 0, 1);
|
2012-10-16 11:32:13 +02:00
|
|
|
gen_store_gpr(dc, rd, cpu_dst);
|
2011-10-18 04:57:23 +02:00
|
|
|
break;
|
2007-04-22 21:14:52 +02:00
|
|
|
case 0x010: /* VIS I array8 */
|
2008-05-09 22:13:43 +02:00
|
|
|
CHECK_FPU_FEATURE(dc, VIS1);
|
2012-10-16 11:32:14 +02:00
|
|
|
cpu_src1 = gen_load_gpr(dc, rs1);
|
2012-10-16 11:32:13 +02:00
|
|
|
cpu_src2 = gen_load_gpr(dc, rs2);
|
2011-10-19 23:56:43 +02:00
|
|
|
gen_helper_array8(cpu_dst, cpu_src1, cpu_src2);
|
2012-10-16 11:32:13 +02:00
|
|
|
gen_store_gpr(dc, rd, cpu_dst);
|
2007-04-22 21:14:52 +02:00
|
|
|
break;
|
|
|
|
case 0x012: /* VIS I array16 */
|
2008-05-09 22:13:43 +02:00
|
|
|
CHECK_FPU_FEATURE(dc, VIS1);
|
2012-10-16 11:32:14 +02:00
|
|
|
cpu_src1 = gen_load_gpr(dc, rs1);
|
2012-10-16 11:32:13 +02:00
|
|
|
cpu_src2 = gen_load_gpr(dc, rs2);
|
2011-10-19 23:56:43 +02:00
|
|
|
gen_helper_array8(cpu_dst, cpu_src1, cpu_src2);
|
2008-03-29 10:09:25 +01:00
|
|
|
tcg_gen_shli_i64(cpu_dst, cpu_dst, 1);
|
2012-10-16 11:32:13 +02:00
|
|
|
gen_store_gpr(dc, rd, cpu_dst);
|
2007-04-22 21:14:52 +02:00
|
|
|
break;
|
|
|
|
case 0x014: /* VIS I array32 */
|
2008-05-09 22:13:43 +02:00
|
|
|
CHECK_FPU_FEATURE(dc, VIS1);
|
2012-10-16 11:32:14 +02:00
|
|
|
cpu_src1 = gen_load_gpr(dc, rs1);
|
2012-10-16 11:32:13 +02:00
|
|
|
cpu_src2 = gen_load_gpr(dc, rs2);
|
2011-10-19 23:56:43 +02:00
|
|
|
gen_helper_array8(cpu_dst, cpu_src1, cpu_src2);
|
2008-03-29 10:09:25 +01:00
|
|
|
tcg_gen_shli_i64(cpu_dst, cpu_dst, 2);
|
2012-10-16 11:32:13 +02:00
|
|
|
gen_store_gpr(dc, rd, cpu_dst);
|
2007-04-22 21:14:52 +02:00
|
|
|
break;
|
2007-04-13 17:49:56 +02:00
|
|
|
case 0x018: /* VIS I alignaddr */
|
2008-05-09 22:13:43 +02:00
|
|
|
CHECK_FPU_FEATURE(dc, VIS1);
|
2012-10-16 11:32:14 +02:00
|
|
|
cpu_src1 = gen_load_gpr(dc, rs1);
|
2012-10-16 11:32:13 +02:00
|
|
|
cpu_src2 = gen_load_gpr(dc, rs2);
|
2011-10-18 17:35:58 +02:00
|
|
|
gen_alignaddr(cpu_dst, cpu_src1, cpu_src2, 0);
|
2012-10-16 11:32:13 +02:00
|
|
|
gen_store_gpr(dc, rd, cpu_dst);
|
2007-04-13 17:49:56 +02:00
|
|
|
break;
|
|
|
|
case 0x01a: /* VIS I alignaddrl */
|
2011-10-18 17:35:58 +02:00
|
|
|
CHECK_FPU_FEATURE(dc, VIS1);
|
2012-10-16 11:32:14 +02:00
|
|
|
cpu_src1 = gen_load_gpr(dc, rs1);
|
2012-10-16 11:32:13 +02:00
|
|
|
cpu_src2 = gen_load_gpr(dc, rs2);
|
2011-10-18 17:35:58 +02:00
|
|
|
gen_alignaddr(cpu_dst, cpu_src1, cpu_src2, 1);
|
2012-10-16 11:32:13 +02:00
|
|
|
gen_store_gpr(dc, rd, cpu_dst);
|
2011-10-18 17:35:58 +02:00
|
|
|
break;
|
|
|
|
case 0x019: /* VIS II bmask */
|
2011-10-18 18:24:43 +02:00
|
|
|
CHECK_FPU_FEATURE(dc, VIS2);
|
2012-10-16 11:32:14 +02:00
|
|
|
cpu_src1 = gen_load_gpr(dc, rs1);
|
|
|
|
cpu_src2 = gen_load_gpr(dc, rs2);
|
2011-10-18 18:24:43 +02:00
|
|
|
tcg_gen_add_tl(cpu_dst, cpu_src1, cpu_src2);
|
|
|
|
tcg_gen_deposit_tl(cpu_gsr, cpu_gsr, cpu_dst, 32, 32);
|
2012-10-16 11:32:13 +02:00
|
|
|
gen_store_gpr(dc, rd, cpu_dst);
|
2011-10-18 18:24:43 +02:00
|
|
|
break;
|
2007-04-22 21:14:52 +02:00
|
|
|
case 0x020: /* VIS I fcmple16 */
|
2008-05-09 22:13:43 +02:00
|
|
|
CHECK_FPU_FEATURE(dc, VIS1);
|
2011-10-15 19:20:20 +02:00
|
|
|
cpu_src1_64 = gen_load_fpr_D(dc, rs1);
|
|
|
|
cpu_src2_64 = gen_load_fpr_D(dc, rs2);
|
2011-10-19 23:56:43 +02:00
|
|
|
gen_helper_fcmple16(cpu_dst, cpu_src1_64, cpu_src2_64);
|
2012-10-16 11:32:13 +02:00
|
|
|
gen_store_gpr(dc, rd, cpu_dst);
|
2007-04-22 21:14:52 +02:00
|
|
|
break;
|
|
|
|
case 0x022: /* VIS I fcmpne16 */
|
2008-05-09 22:13:43 +02:00
|
|
|
CHECK_FPU_FEATURE(dc, VIS1);
|
2011-10-15 19:20:20 +02:00
|
|
|
cpu_src1_64 = gen_load_fpr_D(dc, rs1);
|
|
|
|
cpu_src2_64 = gen_load_fpr_D(dc, rs2);
|
2011-10-19 23:56:43 +02:00
|
|
|
gen_helper_fcmpne16(cpu_dst, cpu_src1_64, cpu_src2_64);
|
2012-10-16 11:32:13 +02:00
|
|
|
gen_store_gpr(dc, rd, cpu_dst);
|
2007-04-13 17:49:56 +02:00
|
|
|
break;
|
2007-04-22 21:14:52 +02:00
|
|
|
case 0x024: /* VIS I fcmple32 */
|
2008-05-09 22:13:43 +02:00
|
|
|
CHECK_FPU_FEATURE(dc, VIS1);
|
2011-10-15 19:20:20 +02:00
|
|
|
cpu_src1_64 = gen_load_fpr_D(dc, rs1);
|
|
|
|
cpu_src2_64 = gen_load_fpr_D(dc, rs2);
|
2011-10-19 23:56:43 +02:00
|
|
|
gen_helper_fcmple32(cpu_dst, cpu_src1_64, cpu_src2_64);
|
2012-10-16 11:32:13 +02:00
|
|
|
gen_store_gpr(dc, rd, cpu_dst);
|
2007-04-22 21:14:52 +02:00
|
|
|
break;
|
|
|
|
case 0x026: /* VIS I fcmpne32 */
|
2008-05-09 22:13:43 +02:00
|
|
|
CHECK_FPU_FEATURE(dc, VIS1);
|
2011-10-15 19:20:20 +02:00
|
|
|
cpu_src1_64 = gen_load_fpr_D(dc, rs1);
|
|
|
|
cpu_src2_64 = gen_load_fpr_D(dc, rs2);
|
2011-10-19 23:56:43 +02:00
|
|
|
gen_helper_fcmpne32(cpu_dst, cpu_src1_64, cpu_src2_64);
|
2012-10-16 11:32:13 +02:00
|
|
|
gen_store_gpr(dc, rd, cpu_dst);
|
2007-04-22 21:14:52 +02:00
|
|
|
break;
|
|
|
|
case 0x028: /* VIS I fcmpgt16 */
|
2008-05-09 22:13:43 +02:00
|
|
|
CHECK_FPU_FEATURE(dc, VIS1);
|
2011-10-15 19:20:20 +02:00
|
|
|
cpu_src1_64 = gen_load_fpr_D(dc, rs1);
|
|
|
|
cpu_src2_64 = gen_load_fpr_D(dc, rs2);
|
2011-10-19 23:56:43 +02:00
|
|
|
gen_helper_fcmpgt16(cpu_dst, cpu_src1_64, cpu_src2_64);
|
2012-10-16 11:32:13 +02:00
|
|
|
gen_store_gpr(dc, rd, cpu_dst);
|
2007-04-22 21:14:52 +02:00
|
|
|
break;
|
|
|
|
case 0x02a: /* VIS I fcmpeq16 */
|
2008-05-09 22:13:43 +02:00
|
|
|
CHECK_FPU_FEATURE(dc, VIS1);
|
2011-10-15 19:20:20 +02:00
|
|
|
cpu_src1_64 = gen_load_fpr_D(dc, rs1);
|
|
|
|
cpu_src2_64 = gen_load_fpr_D(dc, rs2);
|
2011-10-19 23:56:43 +02:00
|
|
|
gen_helper_fcmpeq16(cpu_dst, cpu_src1_64, cpu_src2_64);
|
2012-10-16 11:32:13 +02:00
|
|
|
gen_store_gpr(dc, rd, cpu_dst);
|
2007-04-22 21:14:52 +02:00
|
|
|
break;
|
|
|
|
case 0x02c: /* VIS I fcmpgt32 */
|
2008-05-09 22:13:43 +02:00
|
|
|
CHECK_FPU_FEATURE(dc, VIS1);
|
2011-10-15 19:20:20 +02:00
|
|
|
cpu_src1_64 = gen_load_fpr_D(dc, rs1);
|
|
|
|
cpu_src2_64 = gen_load_fpr_D(dc, rs2);
|
2011-10-19 23:56:43 +02:00
|
|
|
gen_helper_fcmpgt32(cpu_dst, cpu_src1_64, cpu_src2_64);
|
2012-10-16 11:32:13 +02:00
|
|
|
gen_store_gpr(dc, rd, cpu_dst);
|
2007-04-22 21:14:52 +02:00
|
|
|
break;
|
|
|
|
case 0x02e: /* VIS I fcmpeq32 */
|
2008-05-09 22:13:43 +02:00
|
|
|
CHECK_FPU_FEATURE(dc, VIS1);
|
2011-10-15 19:20:20 +02:00
|
|
|
cpu_src1_64 = gen_load_fpr_D(dc, rs1);
|
|
|
|
cpu_src2_64 = gen_load_fpr_D(dc, rs2);
|
2011-10-19 23:56:43 +02:00
|
|
|
gen_helper_fcmpeq32(cpu_dst, cpu_src1_64, cpu_src2_64);
|
2012-10-16 11:32:13 +02:00
|
|
|
gen_store_gpr(dc, rd, cpu_dst);
|
2007-04-22 21:14:52 +02:00
|
|
|
break;
|
|
|
|
case 0x031: /* VIS I fmul8x16 */
|
2008-05-09 22:13:43 +02:00
|
|
|
CHECK_FPU_FEATURE(dc, VIS1);
|
2011-10-15 20:52:00 +02:00
|
|
|
gen_ne_fop_DDD(dc, rd, rs1, rs2, gen_helper_fmul8x16);
|
2007-04-22 21:14:52 +02:00
|
|
|
break;
|
|
|
|
case 0x033: /* VIS I fmul8x16au */
|
2008-05-09 22:13:43 +02:00
|
|
|
CHECK_FPU_FEATURE(dc, VIS1);
|
2011-10-15 20:52:00 +02:00
|
|
|
gen_ne_fop_DDD(dc, rd, rs1, rs2, gen_helper_fmul8x16au);
|
2007-04-22 21:14:52 +02:00
|
|
|
break;
|
|
|
|
case 0x035: /* VIS I fmul8x16al */
|
2008-05-09 22:13:43 +02:00
|
|
|
CHECK_FPU_FEATURE(dc, VIS1);
|
2011-10-15 20:52:00 +02:00
|
|
|
gen_ne_fop_DDD(dc, rd, rs1, rs2, gen_helper_fmul8x16al);
|
2007-04-22 21:14:52 +02:00
|
|
|
break;
|
|
|
|
case 0x036: /* VIS I fmul8sux16 */
|
2008-05-09 22:13:43 +02:00
|
|
|
CHECK_FPU_FEATURE(dc, VIS1);
|
2011-10-15 20:52:00 +02:00
|
|
|
gen_ne_fop_DDD(dc, rd, rs1, rs2, gen_helper_fmul8sux16);
|
2007-04-22 21:14:52 +02:00
|
|
|
break;
|
|
|
|
case 0x037: /* VIS I fmul8ulx16 */
|
2008-05-09 22:13:43 +02:00
|
|
|
CHECK_FPU_FEATURE(dc, VIS1);
|
2011-10-15 20:52:00 +02:00
|
|
|
gen_ne_fop_DDD(dc, rd, rs1, rs2, gen_helper_fmul8ulx16);
|
2007-04-22 21:14:52 +02:00
|
|
|
break;
|
|
|
|
case 0x038: /* VIS I fmuld8sux16 */
|
2008-05-09 22:13:43 +02:00
|
|
|
CHECK_FPU_FEATURE(dc, VIS1);
|
2011-10-15 20:52:00 +02:00
|
|
|
gen_ne_fop_DDD(dc, rd, rs1, rs2, gen_helper_fmuld8sux16);
|
2007-04-22 21:14:52 +02:00
|
|
|
break;
|
|
|
|
case 0x039: /* VIS I fmuld8ulx16 */
|
2008-05-09 22:13:43 +02:00
|
|
|
CHECK_FPU_FEATURE(dc, VIS1);
|
2011-10-15 20:52:00 +02:00
|
|
|
gen_ne_fop_DDD(dc, rd, rs1, rs2, gen_helper_fmuld8ulx16);
|
2007-04-22 21:14:52 +02:00
|
|
|
break;
|
|
|
|
case 0x03a: /* VIS I fpack32 */
|
2011-10-18 03:03:47 +02:00
|
|
|
CHECK_FPU_FEATURE(dc, VIS1);
|
|
|
|
gen_gsr_fop_DDD(dc, rd, rs1, rs2, gen_helper_fpack32);
|
|
|
|
break;
|
2007-04-22 21:14:52 +02:00
|
|
|
case 0x03b: /* VIS I fpack16 */
|
2011-10-18 03:03:47 +02:00
|
|
|
CHECK_FPU_FEATURE(dc, VIS1);
|
|
|
|
cpu_src1_64 = gen_load_fpr_D(dc, rs2);
|
2012-10-16 11:32:21 +02:00
|
|
|
cpu_dst_32 = gen_dest_fpr_F(dc);
|
2011-10-18 03:03:47 +02:00
|
|
|
gen_helper_fpack16(cpu_dst_32, cpu_gsr, cpu_src1_64);
|
|
|
|
gen_store_fpr_F(dc, rd, cpu_dst_32);
|
|
|
|
break;
|
2007-04-22 21:14:52 +02:00
|
|
|
case 0x03d: /* VIS I fpackfix */
|
2011-10-18 03:03:47 +02:00
|
|
|
CHECK_FPU_FEATURE(dc, VIS1);
|
|
|
|
cpu_src1_64 = gen_load_fpr_D(dc, rs2);
|
2012-10-16 11:32:21 +02:00
|
|
|
cpu_dst_32 = gen_dest_fpr_F(dc);
|
2011-10-18 03:03:47 +02:00
|
|
|
gen_helper_fpackfix(cpu_dst_32, cpu_gsr, cpu_src1_64);
|
|
|
|
gen_store_fpr_F(dc, rd, cpu_dst_32);
|
|
|
|
break;
|
2011-10-18 02:32:26 +02:00
|
|
|
case 0x03e: /* VIS I pdist */
|
|
|
|
CHECK_FPU_FEATURE(dc, VIS1);
|
|
|
|
gen_ne_fop_DDDD(dc, rd, rs1, rs2, gen_helper_pdist);
|
|
|
|
break;
|
2007-04-13 17:49:56 +02:00
|
|
|
case 0x048: /* VIS I faligndata */
|
2008-05-09 22:13:43 +02:00
|
|
|
CHECK_FPU_FEATURE(dc, VIS1);
|
2011-10-18 18:41:30 +02:00
|
|
|
gen_gsr_fop_DDD(dc, rd, rs1, rs2, gen_faligndata);
|
2007-04-13 17:49:56 +02:00
|
|
|
break;
|
2007-04-22 21:14:52 +02:00
|
|
|
case 0x04b: /* VIS I fpmerge */
|
2008-05-09 22:13:43 +02:00
|
|
|
CHECK_FPU_FEATURE(dc, VIS1);
|
2011-10-15 20:52:00 +02:00
|
|
|
gen_ne_fop_DDD(dc, rd, rs1, rs2, gen_helper_fpmerge);
|
2007-04-22 21:14:52 +02:00
|
|
|
break;
|
|
|
|
case 0x04c: /* VIS II bshuffle */
|
2011-10-18 18:24:43 +02:00
|
|
|
CHECK_FPU_FEATURE(dc, VIS2);
|
|
|
|
gen_gsr_fop_DDD(dc, rd, rs1, rs2, gen_helper_bshuffle);
|
|
|
|
break;
|
2007-04-22 21:14:52 +02:00
|
|
|
case 0x04d: /* VIS I fexpand */
|
2008-05-09 22:13:43 +02:00
|
|
|
CHECK_FPU_FEATURE(dc, VIS1);
|
2011-10-15 20:52:00 +02:00
|
|
|
gen_ne_fop_DDD(dc, rd, rs1, rs2, gen_helper_fexpand);
|
2007-04-22 21:14:52 +02:00
|
|
|
break;
|
|
|
|
case 0x050: /* VIS I fpadd16 */
|
2008-05-09 22:13:43 +02:00
|
|
|
CHECK_FPU_FEATURE(dc, VIS1);
|
2011-10-15 20:52:00 +02:00
|
|
|
gen_ne_fop_DDD(dc, rd, rs1, rs2, gen_helper_fpadd16);
|
2007-04-22 21:14:52 +02:00
|
|
|
break;
|
|
|
|
case 0x051: /* VIS I fpadd16s */
|
2008-05-09 22:13:43 +02:00
|
|
|
CHECK_FPU_FEATURE(dc, VIS1);
|
2011-10-15 20:52:00 +02:00
|
|
|
gen_ne_fop_FFF(dc, rd, rs1, rs2, gen_helper_fpadd16s);
|
2007-04-22 21:14:52 +02:00
|
|
|
break;
|
|
|
|
case 0x052: /* VIS I fpadd32 */
|
2008-05-09 22:13:43 +02:00
|
|
|
CHECK_FPU_FEATURE(dc, VIS1);
|
2011-10-15 20:52:00 +02:00
|
|
|
gen_ne_fop_DDD(dc, rd, rs1, rs2, gen_helper_fpadd32);
|
2007-04-22 21:14:52 +02:00
|
|
|
break;
|
|
|
|
case 0x053: /* VIS I fpadd32s */
|
2008-05-09 22:13:43 +02:00
|
|
|
CHECK_FPU_FEATURE(dc, VIS1);
|
2011-10-15 20:52:00 +02:00
|
|
|
gen_ne_fop_FFF(dc, rd, rs1, rs2, tcg_gen_add_i32);
|
2007-04-22 21:14:52 +02:00
|
|
|
break;
|
|
|
|
case 0x054: /* VIS I fpsub16 */
|
2008-05-09 22:13:43 +02:00
|
|
|
CHECK_FPU_FEATURE(dc, VIS1);
|
2011-10-15 20:52:00 +02:00
|
|
|
gen_ne_fop_DDD(dc, rd, rs1, rs2, gen_helper_fpsub16);
|
2007-04-22 21:14:52 +02:00
|
|
|
break;
|
|
|
|
case 0x055: /* VIS I fpsub16s */
|
2008-05-09 22:13:43 +02:00
|
|
|
CHECK_FPU_FEATURE(dc, VIS1);
|
2011-10-15 20:52:00 +02:00
|
|
|
gen_ne_fop_FFF(dc, rd, rs1, rs2, gen_helper_fpsub16s);
|
2007-04-22 21:14:52 +02:00
|
|
|
break;
|
|
|
|
case 0x056: /* VIS I fpsub32 */
|
2008-05-09 22:13:43 +02:00
|
|
|
CHECK_FPU_FEATURE(dc, VIS1);
|
2011-10-15 20:52:00 +02:00
|
|
|
gen_ne_fop_DDD(dc, rd, rs1, rs2, gen_helper_fpsub32);
|
2007-04-22 21:14:52 +02:00
|
|
|
break;
|
|
|
|
case 0x057: /* VIS I fpsub32s */
|
2008-05-09 22:13:43 +02:00
|
|
|
CHECK_FPU_FEATURE(dc, VIS1);
|
2011-10-15 20:52:00 +02:00
|
|
|
gen_ne_fop_FFF(dc, rd, rs1, rs2, tcg_gen_sub_i32);
|
2007-04-22 21:14:52 +02:00
|
|
|
break;
|
2007-04-13 17:49:56 +02:00
|
|
|
case 0x060: /* VIS I fzero */
|
2008-05-09 22:13:43 +02:00
|
|
|
CHECK_FPU_FEATURE(dc, VIS1);
|
2012-10-16 11:32:26 +02:00
|
|
|
cpu_dst_64 = gen_dest_fpr_D(dc, rd);
|
2011-10-15 00:47:35 +02:00
|
|
|
tcg_gen_movi_i64(cpu_dst_64, 0);
|
|
|
|
gen_store_fpr_D(dc, rd, cpu_dst_64);
|
2007-04-13 17:49:56 +02:00
|
|
|
break;
|
|
|
|
case 0x061: /* VIS I fzeros */
|
2008-05-09 22:13:43 +02:00
|
|
|
CHECK_FPU_FEATURE(dc, VIS1);
|
2012-10-16 11:32:21 +02:00
|
|
|
cpu_dst_32 = gen_dest_fpr_F(dc);
|
2011-10-14 23:58:32 +02:00
|
|
|
tcg_gen_movi_i32(cpu_dst_32, 0);
|
|
|
|
gen_store_fpr_F(dc, rd, cpu_dst_32);
|
2007-04-13 17:49:56 +02:00
|
|
|
break;
|
2007-04-22 21:14:52 +02:00
|
|
|
case 0x062: /* VIS I fnor */
|
2008-05-09 22:13:43 +02:00
|
|
|
CHECK_FPU_FEATURE(dc, VIS1);
|
2011-10-15 20:52:00 +02:00
|
|
|
gen_ne_fop_DDD(dc, rd, rs1, rs2, tcg_gen_nor_i64);
|
2007-04-22 21:14:52 +02:00
|
|
|
break;
|
|
|
|
case 0x063: /* VIS I fnors */
|
2008-05-09 22:13:43 +02:00
|
|
|
CHECK_FPU_FEATURE(dc, VIS1);
|
2011-10-15 20:52:00 +02:00
|
|
|
gen_ne_fop_FFF(dc, rd, rs1, rs2, tcg_gen_nor_i32);
|
2007-04-22 21:14:52 +02:00
|
|
|
break;
|
|
|
|
case 0x064: /* VIS I fandnot2 */
|
2008-05-09 22:13:43 +02:00
|
|
|
CHECK_FPU_FEATURE(dc, VIS1);
|
2011-10-15 20:52:00 +02:00
|
|
|
gen_ne_fop_DDD(dc, rd, rs1, rs2, tcg_gen_andc_i64);
|
2007-04-22 21:14:52 +02:00
|
|
|
break;
|
|
|
|
case 0x065: /* VIS I fandnot2s */
|
2008-05-09 22:13:43 +02:00
|
|
|
CHECK_FPU_FEATURE(dc, VIS1);
|
2011-10-15 20:52:00 +02:00
|
|
|
gen_ne_fop_FFF(dc, rd, rs1, rs2, tcg_gen_andc_i32);
|
2007-04-22 21:14:52 +02:00
|
|
|
break;
|
|
|
|
case 0x066: /* VIS I fnot2 */
|
2008-05-09 22:13:43 +02:00
|
|
|
CHECK_FPU_FEATURE(dc, VIS1);
|
2011-10-15 20:52:00 +02:00
|
|
|
gen_ne_fop_DD(dc, rd, rs2, tcg_gen_not_i64);
|
2007-04-22 21:14:52 +02:00
|
|
|
break;
|
|
|
|
case 0x067: /* VIS I fnot2s */
|
2008-05-09 22:13:43 +02:00
|
|
|
CHECK_FPU_FEATURE(dc, VIS1);
|
2011-10-15 20:52:00 +02:00
|
|
|
gen_ne_fop_FF(dc, rd, rs2, tcg_gen_not_i32);
|
2007-04-22 21:14:52 +02:00
|
|
|
break;
|
|
|
|
case 0x068: /* VIS I fandnot1 */
|
2008-05-09 22:13:43 +02:00
|
|
|
CHECK_FPU_FEATURE(dc, VIS1);
|
2011-10-15 20:52:00 +02:00
|
|
|
gen_ne_fop_DDD(dc, rd, rs2, rs1, tcg_gen_andc_i64);
|
2007-04-22 21:14:52 +02:00
|
|
|
break;
|
|
|
|
case 0x069: /* VIS I fandnot1s */
|
2008-05-09 22:13:43 +02:00
|
|
|
CHECK_FPU_FEATURE(dc, VIS1);
|
2011-10-15 20:52:00 +02:00
|
|
|
gen_ne_fop_FFF(dc, rd, rs2, rs1, tcg_gen_andc_i32);
|
2007-04-22 21:14:52 +02:00
|
|
|
break;
|
|
|
|
case 0x06a: /* VIS I fnot1 */
|
2008-05-09 22:13:43 +02:00
|
|
|
CHECK_FPU_FEATURE(dc, VIS1);
|
2011-10-15 20:52:00 +02:00
|
|
|
gen_ne_fop_DD(dc, rd, rs1, tcg_gen_not_i64);
|
2007-04-22 21:14:52 +02:00
|
|
|
break;
|
|
|
|
case 0x06b: /* VIS I fnot1s */
|
2008-05-09 22:13:43 +02:00
|
|
|
CHECK_FPU_FEATURE(dc, VIS1);
|
2011-10-15 20:52:00 +02:00
|
|
|
gen_ne_fop_FF(dc, rd, rs1, tcg_gen_not_i32);
|
2007-04-22 21:14:52 +02:00
|
|
|
break;
|
|
|
|
case 0x06c: /* VIS I fxor */
|
2008-05-09 22:13:43 +02:00
|
|
|
CHECK_FPU_FEATURE(dc, VIS1);
|
2011-10-15 20:52:00 +02:00
|
|
|
gen_ne_fop_DDD(dc, rd, rs1, rs2, tcg_gen_xor_i64);
|
2007-04-22 21:14:52 +02:00
|
|
|
break;
|
|
|
|
case 0x06d: /* VIS I fxors */
|
2008-05-09 22:13:43 +02:00
|
|
|
CHECK_FPU_FEATURE(dc, VIS1);
|
2011-10-15 20:52:00 +02:00
|
|
|
gen_ne_fop_FFF(dc, rd, rs1, rs2, tcg_gen_xor_i32);
|
2007-04-22 21:14:52 +02:00
|
|
|
break;
|
|
|
|
case 0x06e: /* VIS I fnand */
|
2008-05-09 22:13:43 +02:00
|
|
|
CHECK_FPU_FEATURE(dc, VIS1);
|
2011-10-15 20:52:00 +02:00
|
|
|
gen_ne_fop_DDD(dc, rd, rs1, rs2, tcg_gen_nand_i64);
|
2007-04-22 21:14:52 +02:00
|
|
|
break;
|
|
|
|
case 0x06f: /* VIS I fnands */
|
2008-05-09 22:13:43 +02:00
|
|
|
CHECK_FPU_FEATURE(dc, VIS1);
|
2011-10-15 20:52:00 +02:00
|
|
|
gen_ne_fop_FFF(dc, rd, rs1, rs2, tcg_gen_nand_i32);
|
2007-04-22 21:14:52 +02:00
|
|
|
break;
|
|
|
|
case 0x070: /* VIS I fand */
|
2008-05-09 22:13:43 +02:00
|
|
|
CHECK_FPU_FEATURE(dc, VIS1);
|
2011-10-15 20:52:00 +02:00
|
|
|
gen_ne_fop_DDD(dc, rd, rs1, rs2, tcg_gen_and_i64);
|
2007-04-22 21:14:52 +02:00
|
|
|
break;
|
|
|
|
case 0x071: /* VIS I fands */
|
2008-05-09 22:13:43 +02:00
|
|
|
CHECK_FPU_FEATURE(dc, VIS1);
|
2011-10-15 20:52:00 +02:00
|
|
|
gen_ne_fop_FFF(dc, rd, rs1, rs2, tcg_gen_and_i32);
|
2007-04-22 21:14:52 +02:00
|
|
|
break;
|
|
|
|
case 0x072: /* VIS I fxnor */
|
2008-05-09 22:13:43 +02:00
|
|
|
CHECK_FPU_FEATURE(dc, VIS1);
|
2011-10-15 20:52:00 +02:00
|
|
|
gen_ne_fop_DDD(dc, rd, rs1, rs2, tcg_gen_eqv_i64);
|
2007-04-22 21:14:52 +02:00
|
|
|
break;
|
|
|
|
case 0x073: /* VIS I fxnors */
|
2008-05-09 22:13:43 +02:00
|
|
|
CHECK_FPU_FEATURE(dc, VIS1);
|
2011-10-15 20:52:00 +02:00
|
|
|
gen_ne_fop_FFF(dc, rd, rs1, rs2, tcg_gen_eqv_i32);
|
2007-04-22 21:14:52 +02:00
|
|
|
break;
|
2007-04-13 17:49:56 +02:00
|
|
|
case 0x074: /* VIS I fsrc1 */
|
2008-05-09 22:13:43 +02:00
|
|
|
CHECK_FPU_FEATURE(dc, VIS1);
|
2011-10-15 00:47:35 +02:00
|
|
|
cpu_src1_64 = gen_load_fpr_D(dc, rs1);
|
|
|
|
gen_store_fpr_D(dc, rd, cpu_src1_64);
|
2007-04-13 17:49:56 +02:00
|
|
|
break;
|
|
|
|
case 0x075: /* VIS I fsrc1s */
|
2008-05-09 22:13:43 +02:00
|
|
|
CHECK_FPU_FEATURE(dc, VIS1);
|
2011-10-14 23:58:32 +02:00
|
|
|
cpu_src1_32 = gen_load_fpr_F(dc, rs1);
|
|
|
|
gen_store_fpr_F(dc, rd, cpu_src1_32);
|
2007-04-13 17:49:56 +02:00
|
|
|
break;
|
2007-04-22 21:14:52 +02:00
|
|
|
case 0x076: /* VIS I fornot2 */
|
2008-05-09 22:13:43 +02:00
|
|
|
CHECK_FPU_FEATURE(dc, VIS1);
|
2011-10-15 20:52:00 +02:00
|
|
|
gen_ne_fop_DDD(dc, rd, rs1, rs2, tcg_gen_orc_i64);
|
2007-04-22 21:14:52 +02:00
|
|
|
break;
|
|
|
|
case 0x077: /* VIS I fornot2s */
|
2008-05-09 22:13:43 +02:00
|
|
|
CHECK_FPU_FEATURE(dc, VIS1);
|
2011-10-15 20:52:00 +02:00
|
|
|
gen_ne_fop_FFF(dc, rd, rs1, rs2, tcg_gen_orc_i32);
|
2007-04-22 21:14:52 +02:00
|
|
|
break;
|
2007-04-13 17:49:56 +02:00
|
|
|
case 0x078: /* VIS I fsrc2 */
|
2008-05-09 22:13:43 +02:00
|
|
|
CHECK_FPU_FEATURE(dc, VIS1);
|
2011-10-15 00:47:35 +02:00
|
|
|
cpu_src1_64 = gen_load_fpr_D(dc, rs2);
|
|
|
|
gen_store_fpr_D(dc, rd, cpu_src1_64);
|
2007-04-13 17:49:56 +02:00
|
|
|
break;
|
|
|
|
case 0x079: /* VIS I fsrc2s */
|
2008-05-09 22:13:43 +02:00
|
|
|
CHECK_FPU_FEATURE(dc, VIS1);
|
2011-10-14 23:58:32 +02:00
|
|
|
cpu_src1_32 = gen_load_fpr_F(dc, rs2);
|
|
|
|
gen_store_fpr_F(dc, rd, cpu_src1_32);
|
2007-04-13 17:49:56 +02:00
|
|
|
break;
|
2007-04-22 21:14:52 +02:00
|
|
|
case 0x07a: /* VIS I fornot1 */
|
2008-05-09 22:13:43 +02:00
|
|
|
CHECK_FPU_FEATURE(dc, VIS1);
|
2011-10-15 20:52:00 +02:00
|
|
|
gen_ne_fop_DDD(dc, rd, rs2, rs1, tcg_gen_orc_i64);
|
2007-04-22 21:14:52 +02:00
|
|
|
break;
|
|
|
|
case 0x07b: /* VIS I fornot1s */
|
2008-05-09 22:13:43 +02:00
|
|
|
CHECK_FPU_FEATURE(dc, VIS1);
|
2011-10-15 20:52:00 +02:00
|
|
|
gen_ne_fop_FFF(dc, rd, rs2, rs1, tcg_gen_orc_i32);
|
2007-04-22 21:14:52 +02:00
|
|
|
break;
|
|
|
|
case 0x07c: /* VIS I for */
|
2008-05-09 22:13:43 +02:00
|
|
|
CHECK_FPU_FEATURE(dc, VIS1);
|
2011-10-15 20:52:00 +02:00
|
|
|
gen_ne_fop_DDD(dc, rd, rs1, rs2, tcg_gen_or_i64);
|
2007-04-22 21:14:52 +02:00
|
|
|
break;
|
|
|
|
case 0x07d: /* VIS I fors */
|
2008-05-09 22:13:43 +02:00
|
|
|
CHECK_FPU_FEATURE(dc, VIS1);
|
2011-10-15 20:52:00 +02:00
|
|
|
gen_ne_fop_FFF(dc, rd, rs1, rs2, tcg_gen_or_i32);
|
2007-04-22 21:14:52 +02:00
|
|
|
break;
|
2007-04-13 17:49:56 +02:00
|
|
|
case 0x07e: /* VIS I fone */
|
2008-05-09 22:13:43 +02:00
|
|
|
CHECK_FPU_FEATURE(dc, VIS1);
|
2012-10-16 11:32:26 +02:00
|
|
|
cpu_dst_64 = gen_dest_fpr_D(dc, rd);
|
2011-10-15 00:47:35 +02:00
|
|
|
tcg_gen_movi_i64(cpu_dst_64, -1);
|
|
|
|
gen_store_fpr_D(dc, rd, cpu_dst_64);
|
2007-04-13 17:49:56 +02:00
|
|
|
break;
|
|
|
|
case 0x07f: /* VIS I fones */
|
2008-05-09 22:13:43 +02:00
|
|
|
CHECK_FPU_FEATURE(dc, VIS1);
|
2012-10-16 11:32:21 +02:00
|
|
|
cpu_dst_32 = gen_dest_fpr_F(dc);
|
2011-10-14 23:58:32 +02:00
|
|
|
tcg_gen_movi_i32(cpu_dst_32, -1);
|
|
|
|
gen_store_fpr_F(dc, rd, cpu_dst_32);
|
2007-04-13 17:49:56 +02:00
|
|
|
break;
|
2007-04-22 21:14:52 +02:00
|
|
|
case 0x080: /* VIS I shutdown */
|
|
|
|
case 0x081: /* VIS II siam */
|
|
|
|
// XXX
|
|
|
|
goto illegal_insn;
|
2007-04-13 17:49:56 +02:00
|
|
|
default:
|
|
|
|
goto illegal_insn;
|
|
|
|
}
|
|
|
|
#else
|
2007-09-20 16:54:22 +02:00
|
|
|
goto ncp_insn;
|
2007-04-13 17:49:56 +02:00
|
|
|
#endif
|
|
|
|
} else if (xop == 0x37) { /* V8 CPop2, V9 impdep2 */
|
2007-04-01 17:08:21 +02:00
|
|
|
#ifdef TARGET_SPARC64
|
2007-09-20 16:54:22 +02:00
|
|
|
goto illegal_insn;
|
2007-04-01 17:08:21 +02:00
|
|
|
#else
|
2007-09-20 16:54:22 +02:00
|
|
|
goto ncp_insn;
|
2007-04-01 17:08:21 +02:00
|
|
|
#endif
|
2005-07-02 16:31:34 +02:00
|
|
|
#ifdef TARGET_SPARC64
|
2007-09-20 16:54:22 +02:00
|
|
|
} else if (xop == 0x39) { /* V9 return */
|
2012-10-06 01:54:53 +02:00
|
|
|
save_state(dc);
|
2012-10-16 11:32:14 +02:00
|
|
|
cpu_src1 = get_src1(dc, insn);
|
2023-02-25 08:24:23 +01:00
|
|
|
cpu_tmp0 = tcg_temp_new();
|
2007-09-20 16:54:22 +02:00
|
|
|
if (IS_IMM) { /* immediate */
|
2009-05-02 20:58:57 +02:00
|
|
|
simm = GET_FIELDs(insn, 19, 31);
|
2012-10-16 11:32:29 +02:00
|
|
|
tcg_gen_addi_tl(cpu_tmp0, cpu_src1, simm);
|
2007-09-20 16:54:22 +02:00
|
|
|
} else { /* register */
|
2005-07-02 16:31:34 +02:00
|
|
|
rs2 = GET_FIELD(insn, 27, 31);
|
2007-09-20 16:54:22 +02:00
|
|
|
if (rs2) {
|
2012-10-16 11:32:13 +02:00
|
|
|
cpu_src2 = gen_load_gpr(dc, rs2);
|
2012-10-16 11:32:29 +02:00
|
|
|
tcg_gen_add_tl(cpu_tmp0, cpu_src1, cpu_src2);
|
2012-10-16 11:32:13 +02:00
|
|
|
} else {
|
2012-10-16 11:32:29 +02:00
|
|
|
tcg_gen_mov_tl(cpu_tmp0, cpu_src1);
|
2012-10-16 11:32:13 +02:00
|
|
|
}
|
2005-07-02 16:31:34 +02:00
|
|
|
}
|
2011-07-03 23:01:59 +02:00
|
|
|
gen_helper_restore(cpu_env);
|
2012-10-06 01:54:54 +02:00
|
|
|
gen_mov_pc_npc(dc);
|
2015-09-03 21:43:15 +02:00
|
|
|
gen_check_align(cpu_tmp0, 3);
|
2012-10-16 11:32:29 +02:00
|
|
|
tcg_gen_mov_tl(cpu_npc, cpu_tmp0);
|
2007-09-20 16:54:22 +02:00
|
|
|
dc->npc = DYNAMIC_PC;
|
|
|
|
goto jmp_insn;
|
2005-07-02 16:31:34 +02:00
|
|
|
#endif
|
2007-09-20 16:54:22 +02:00
|
|
|
} else {
|
2012-10-16 11:32:14 +02:00
|
|
|
cpu_src1 = get_src1(dc, insn);
|
2023-02-25 08:24:23 +01:00
|
|
|
cpu_tmp0 = tcg_temp_new();
|
2007-09-20 16:54:22 +02:00
|
|
|
if (IS_IMM) { /* immediate */
|
2009-05-02 20:58:57 +02:00
|
|
|
simm = GET_FIELDs(insn, 19, 31);
|
2012-10-16 11:32:29 +02:00
|
|
|
tcg_gen_addi_tl(cpu_tmp0, cpu_src1, simm);
|
2007-09-20 16:54:22 +02:00
|
|
|
} else { /* register */
|
2004-12-20 00:18:01 +01:00
|
|
|
rs2 = GET_FIELD(insn, 27, 31);
|
2007-09-20 16:54:22 +02:00
|
|
|
if (rs2) {
|
2012-10-16 11:32:13 +02:00
|
|
|
cpu_src2 = gen_load_gpr(dc, rs2);
|
2012-10-16 11:32:29 +02:00
|
|
|
tcg_gen_add_tl(cpu_tmp0, cpu_src1, cpu_src2);
|
2012-10-16 11:32:13 +02:00
|
|
|
} else {
|
2012-10-16 11:32:29 +02:00
|
|
|
tcg_gen_mov_tl(cpu_tmp0, cpu_src1);
|
2012-10-16 11:32:13 +02:00
|
|
|
}
|
2004-01-04 16:01:44 +01:00
|
|
|
}
|
2007-09-20 16:54:22 +02:00
|
|
|
switch (xop) {
|
|
|
|
case 0x38: /* jmpl */
|
|
|
|
{
|
2015-09-03 21:43:15 +02:00
|
|
|
TCGv t = gen_dest_gpr(dc, rd);
|
2012-10-16 11:32:13 +02:00
|
|
|
tcg_gen_movi_tl(t, dc->pc);
|
|
|
|
gen_store_gpr(dc, rd, t);
|
2015-09-03 21:43:15 +02:00
|
|
|
|
2012-10-06 01:54:54 +02:00
|
|
|
gen_mov_pc_npc(dc);
|
2015-09-03 21:43:15 +02:00
|
|
|
gen_check_align(cpu_tmp0, 3);
|
2012-10-16 11:32:29 +02:00
|
|
|
gen_address_mask(dc, cpu_tmp0);
|
|
|
|
tcg_gen_mov_tl(cpu_npc, cpu_tmp0);
|
2007-09-20 16:54:22 +02:00
|
|
|
dc->npc = DYNAMIC_PC;
|
|
|
|
}
|
|
|
|
goto jmp_insn;
|
2005-07-02 16:31:34 +02:00
|
|
|
#if !defined(CONFIG_USER_ONLY) && !defined(TARGET_SPARC64)
|
2007-09-20 16:54:22 +02:00
|
|
|
case 0x39: /* rett, V9 return */
|
|
|
|
{
|
|
|
|
if (!supervisor(dc))
|
|
|
|
goto priv_insn;
|
2012-10-06 01:54:54 +02:00
|
|
|
gen_mov_pc_npc(dc);
|
2015-09-03 21:43:15 +02:00
|
|
|
gen_check_align(cpu_tmp0, 3);
|
2012-10-16 11:32:29 +02:00
|
|
|
tcg_gen_mov_tl(cpu_npc, cpu_tmp0);
|
2007-09-20 16:54:22 +02:00
|
|
|
dc->npc = DYNAMIC_PC;
|
2011-07-03 23:01:59 +02:00
|
|
|
gen_helper_rett(cpu_env);
|
2007-09-20 16:54:22 +02:00
|
|
|
}
|
|
|
|
goto jmp_insn;
|
|
|
|
#endif
|
|
|
|
case 0x3b: /* flush */
|
2008-08-21 19:33:42 +02:00
|
|
|
if (!((dc)->def->features & CPU_FEATURE_FLUSH))
|
2008-05-09 22:13:43 +02:00
|
|
|
goto unimp_flush;
|
2011-05-14 13:55:30 +02:00
|
|
|
/* nop */
|
2007-09-20 16:54:22 +02:00
|
|
|
break;
|
|
|
|
case 0x3c: /* save */
|
2011-07-03 23:01:59 +02:00
|
|
|
gen_helper_save(cpu_env);
|
2012-10-16 11:32:29 +02:00
|
|
|
gen_store_gpr(dc, rd, cpu_tmp0);
|
2007-09-20 16:54:22 +02:00
|
|
|
break;
|
|
|
|
case 0x3d: /* restore */
|
2011-07-03 23:01:59 +02:00
|
|
|
gen_helper_restore(cpu_env);
|
2012-10-16 11:32:29 +02:00
|
|
|
gen_store_gpr(dc, rd, cpu_tmp0);
|
2007-09-20 16:54:22 +02:00
|
|
|
break;
|
2005-07-02 16:31:34 +02:00
|
|
|
#if !defined(CONFIG_USER_ONLY) && defined(TARGET_SPARC64)
|
2007-09-20 16:54:22 +02:00
|
|
|
case 0x3e: /* V9 done/retry */
|
|
|
|
{
|
|
|
|
switch (rd) {
|
|
|
|
case 0:
|
|
|
|
if (!supervisor(dc))
|
|
|
|
goto priv_insn;
|
|
|
|
dc->npc = DYNAMIC_PC;
|
|
|
|
dc->pc = DYNAMIC_PC;
|
2018-06-15 09:33:03 +02:00
|
|
|
if (tb_cflags(dc->base.tb) & CF_USE_ICOUNT) {
|
|
|
|
gen_io_start();
|
|
|
|
}
|
2011-07-03 23:01:59 +02:00
|
|
|
gen_helper_done(cpu_env);
|
2007-09-20 16:54:22 +02:00
|
|
|
goto jmp_insn;
|
|
|
|
case 1:
|
|
|
|
if (!supervisor(dc))
|
|
|
|
goto priv_insn;
|
|
|
|
dc->npc = DYNAMIC_PC;
|
|
|
|
dc->pc = DYNAMIC_PC;
|
2018-06-15 09:33:03 +02:00
|
|
|
if (tb_cflags(dc->base.tb) & CF_USE_ICOUNT) {
|
|
|
|
gen_io_start();
|
|
|
|
}
|
2011-07-03 23:01:59 +02:00
|
|
|
gen_helper_retry(cpu_env);
|
2007-09-20 16:54:22 +02:00
|
|
|
goto jmp_insn;
|
|
|
|
default:
|
|
|
|
goto illegal_insn;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
#endif
|
|
|
|
default:
|
|
|
|
goto illegal_insn;
|
|
|
|
}
|
2004-01-04 16:01:44 +01:00
|
|
|
}
|
2007-09-20 16:54:22 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 3: /* load/store instructions */
|
|
|
|
{
|
|
|
|
unsigned int xop = GET_FIELD(insn, 7, 12);
|
2012-10-16 11:32:19 +02:00
|
|
|
/* ??? gen_address_mask prevents us from using a source
|
|
|
|
register directly. Always generate a temporary. */
|
2023-02-25 08:24:23 +01:00
|
|
|
TCGv cpu_addr = tcg_temp_new();
|
2008-03-29 21:38:35 +01:00
|
|
|
|
2012-10-16 11:32:19 +02:00
|
|
|
tcg_gen_mov_tl(cpu_addr, get_src1(dc, insn));
|
|
|
|
if (xop == 0x3c || xop == 0x3e) {
|
|
|
|
/* V9 casa/casxa : no offset */
|
2008-07-15 16:52:09 +02:00
|
|
|
} else if (IS_IMM) { /* immediate */
|
2009-05-02 20:58:57 +02:00
|
|
|
simm = GET_FIELDs(insn, 19, 31);
|
2012-10-16 11:32:19 +02:00
|
|
|
if (simm != 0) {
|
|
|
|
tcg_gen_addi_tl(cpu_addr, cpu_addr, simm);
|
|
|
|
}
|
2007-09-20 16:54:22 +02:00
|
|
|
} else { /* register */
|
|
|
|
rs2 = GET_FIELD(insn, 27, 31);
|
|
|
|
if (rs2 != 0) {
|
2012-10-16 11:32:19 +02:00
|
|
|
tcg_gen_add_tl(cpu_addr, cpu_addr, gen_load_gpr(dc, rs2));
|
2012-10-16 11:32:13 +02:00
|
|
|
}
|
2007-09-20 16:54:22 +02:00
|
|
|
}
|
2007-06-10 22:26:38 +02:00
|
|
|
if (xop < 4 || (xop > 7 && xop < 0x14 && xop != 0x0e) ||
|
|
|
|
(xop > 0x17 && xop <= 0x1d ) ||
|
|
|
|
(xop > 0x2c && xop <= 0x33) || xop == 0x1f || xop == 0x3d) {
|
2012-10-16 11:32:17 +02:00
|
|
|
TCGv cpu_val = gen_dest_gpr(dc, rd);
|
|
|
|
|
2007-09-20 16:54:22 +02:00
|
|
|
switch (xop) {
|
2009-05-02 22:19:46 +02:00
|
|
|
case 0x0: /* ld, V9 lduw, load unsigned word */
|
2008-07-17 14:53:05 +02:00
|
|
|
gen_address_mask(dc, cpu_addr);
|
2023-05-02 15:57:39 +02:00
|
|
|
tcg_gen_qemu_ld_tl(cpu_val, cpu_addr,
|
2023-05-02 17:12:44 +02:00
|
|
|
dc->mem_idx, MO_TEUL | MO_ALIGN);
|
2007-09-20 16:54:22 +02:00
|
|
|
break;
|
2009-05-02 22:19:46 +02:00
|
|
|
case 0x1: /* ldub, load unsigned byte */
|
2008-07-17 14:53:05 +02:00
|
|
|
gen_address_mask(dc, cpu_addr);
|
2023-05-02 15:57:39 +02:00
|
|
|
tcg_gen_qemu_ld_tl(cpu_val, cpu_addr,
|
|
|
|
dc->mem_idx, MO_UB);
|
2007-09-20 16:54:22 +02:00
|
|
|
break;
|
2009-05-02 22:19:46 +02:00
|
|
|
case 0x2: /* lduh, load unsigned halfword */
|
2008-07-17 14:53:05 +02:00
|
|
|
gen_address_mask(dc, cpu_addr);
|
2023-05-02 15:57:39 +02:00
|
|
|
tcg_gen_qemu_ld_tl(cpu_val, cpu_addr,
|
2023-05-02 17:12:44 +02:00
|
|
|
dc->mem_idx, MO_TEUW | MO_ALIGN);
|
2007-09-20 16:54:22 +02:00
|
|
|
break;
|
2009-05-02 22:19:46 +02:00
|
|
|
case 0x3: /* ldd, load double word */
|
2007-09-20 16:54:22 +02:00
|
|
|
if (rd & 1)
|
2007-04-01 17:15:36 +02:00
|
|
|
goto illegal_insn;
|
2008-02-24 15:10:06 +01:00
|
|
|
else {
|
2012-10-16 11:32:28 +02:00
|
|
|
TCGv_i64 t64;
|
2008-05-27 21:39:12 +02:00
|
|
|
|
2008-07-17 14:53:05 +02:00
|
|
|
gen_address_mask(dc, cpu_addr);
|
2012-10-16 11:32:28 +02:00
|
|
|
t64 = tcg_temp_new_i64();
|
2023-05-02 15:57:39 +02:00
|
|
|
tcg_gen_qemu_ld_i64(t64, cpu_addr,
|
2023-05-02 17:12:44 +02:00
|
|
|
dc->mem_idx, MO_TEUQ | MO_ALIGN);
|
2012-10-16 11:32:31 +02:00
|
|
|
tcg_gen_trunc_i64_tl(cpu_val, t64);
|
|
|
|
tcg_gen_ext32u_tl(cpu_val, cpu_val);
|
|
|
|
gen_store_gpr(dc, rd + 1, cpu_val);
|
2012-10-16 11:32:28 +02:00
|
|
|
tcg_gen_shri_i64(t64, t64, 32);
|
|
|
|
tcg_gen_trunc_i64_tl(cpu_val, t64);
|
2012-10-16 11:32:31 +02:00
|
|
|
tcg_gen_ext32u_tl(cpu_val, cpu_val);
|
2008-02-24 15:10:06 +01:00
|
|
|
}
|
2007-09-20 16:54:22 +02:00
|
|
|
break;
|
2009-05-02 22:19:46 +02:00
|
|
|
case 0x9: /* ldsb, load signed byte */
|
2008-07-17 14:53:05 +02:00
|
|
|
gen_address_mask(dc, cpu_addr);
|
2023-05-02 15:57:39 +02:00
|
|
|
tcg_gen_qemu_ld_tl(cpu_val, cpu_addr, dc->mem_idx, MO_SB);
|
2007-09-20 16:54:22 +02:00
|
|
|
break;
|
2009-05-02 22:19:46 +02:00
|
|
|
case 0xa: /* ldsh, load signed halfword */
|
2008-07-17 14:53:05 +02:00
|
|
|
gen_address_mask(dc, cpu_addr);
|
2023-05-02 15:57:39 +02:00
|
|
|
tcg_gen_qemu_ld_tl(cpu_val, cpu_addr,
|
2023-05-02 17:12:44 +02:00
|
|
|
dc->mem_idx, MO_TESW | MO_ALIGN);
|
2007-09-20 16:54:22 +02:00
|
|
|
break;
|
2016-07-13 00:38:13 +02:00
|
|
|
case 0xd: /* ldstub */
|
|
|
|
gen_ldstub(dc, cpu_val, cpu_addr, dc->mem_idx);
|
2007-09-20 16:54:22 +02:00
|
|
|
break;
|
2012-10-16 11:32:31 +02:00
|
|
|
case 0x0f:
|
|
|
|
/* swap, swap register with memory. Also atomically */
|
2016-07-13 00:29:18 +02:00
|
|
|
CHECK_IU_FEATURE(dc, SWAP);
|
|
|
|
cpu_src1 = gen_load_gpr(dc, rd);
|
|
|
|
gen_swap(dc, cpu_val, cpu_src1, cpu_addr,
|
|
|
|
dc->mem_idx, MO_TEUL);
|
2007-09-20 16:54:22 +02:00
|
|
|
break;
|
2005-07-02 16:31:34 +02:00
|
|
|
#if !defined(CONFIG_USER_ONLY) || defined(TARGET_SPARC64)
|
2009-05-02 22:19:46 +02:00
|
|
|
case 0x10: /* lda, V9 lduwa, load word alternate */
|
2015-09-03 06:55:40 +02:00
|
|
|
gen_ld_asi(dc, cpu_val, cpu_addr, insn, MO_TEUL);
|
2007-09-20 16:54:22 +02:00
|
|
|
break;
|
2009-05-02 22:19:46 +02:00
|
|
|
case 0x11: /* lduba, load unsigned byte alternate */
|
2015-09-03 06:55:40 +02:00
|
|
|
gen_ld_asi(dc, cpu_val, cpu_addr, insn, MO_UB);
|
2007-09-20 16:54:22 +02:00
|
|
|
break;
|
2009-05-02 22:19:46 +02:00
|
|
|
case 0x12: /* lduha, load unsigned halfword alternate */
|
2015-09-03 06:55:40 +02:00
|
|
|
gen_ld_asi(dc, cpu_val, cpu_addr, insn, MO_TEUW);
|
2007-09-20 16:54:22 +02:00
|
|
|
break;
|
2009-05-02 22:19:46 +02:00
|
|
|
case 0x13: /* ldda, load double word alternate */
|
2015-09-03 06:45:15 +02:00
|
|
|
if (rd & 1) {
|
2007-04-01 17:15:36 +02:00
|
|
|
goto illegal_insn;
|
2015-09-03 06:45:15 +02:00
|
|
|
}
|
2015-09-03 22:13:35 +02:00
|
|
|
gen_ldda_asi(dc, cpu_addr, insn, rd);
|
2008-07-19 15:25:28 +02:00
|
|
|
goto skip_move;
|
2009-05-02 22:19:46 +02:00
|
|
|
case 0x19: /* ldsba, load signed byte alternate */
|
2015-09-03 06:55:40 +02:00
|
|
|
gen_ld_asi(dc, cpu_val, cpu_addr, insn, MO_SB);
|
2007-09-20 16:54:22 +02:00
|
|
|
break;
|
2009-05-02 22:19:46 +02:00
|
|
|
case 0x1a: /* ldsha, load signed halfword alternate */
|
2015-09-03 06:55:40 +02:00
|
|
|
gen_ld_asi(dc, cpu_val, cpu_addr, insn, MO_TESW);
|
2007-09-20 16:54:22 +02:00
|
|
|
break;
|
|
|
|
case 0x1d: /* ldstuba -- XXX: should be atomically */
|
2015-09-03 06:22:41 +02:00
|
|
|
gen_ldstub_asi(dc, cpu_val, cpu_addr, insn);
|
2007-09-20 16:54:22 +02:00
|
|
|
break;
|
2009-05-02 22:19:46 +02:00
|
|
|
case 0x1f: /* swapa, swap reg with alt. memory. Also
|
2008-05-12 18:13:33 +02:00
|
|
|
atomically */
|
2008-05-09 22:13:43 +02:00
|
|
|
CHECK_IU_FEATURE(dc, SWAP);
|
2012-10-16 11:32:16 +02:00
|
|
|
cpu_src1 = gen_load_gpr(dc, rd);
|
2015-09-03 06:22:41 +02:00
|
|
|
gen_swap_asi(dc, cpu_val, cpu_src1, cpu_addr, insn);
|
2007-09-20 16:54:22 +02:00
|
|
|
break;
|
2005-07-02 16:31:34 +02:00
|
|
|
|
|
|
|
#ifndef TARGET_SPARC64
|
2007-09-20 16:54:22 +02:00
|
|
|
case 0x30: /* ldc */
|
|
|
|
case 0x31: /* ldcsr */
|
|
|
|
case 0x33: /* lddc */
|
|
|
|
goto ncp_insn;
|
2005-07-02 16:31:34 +02:00
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
#ifdef TARGET_SPARC64
|
2007-09-20 16:54:22 +02:00
|
|
|
case 0x08: /* V9 ldsw */
|
2008-07-17 14:53:05 +02:00
|
|
|
gen_address_mask(dc, cpu_addr);
|
2023-05-02 15:57:39 +02:00
|
|
|
tcg_gen_qemu_ld_tl(cpu_val, cpu_addr,
|
2023-05-02 17:12:44 +02:00
|
|
|
dc->mem_idx, MO_TESL | MO_ALIGN);
|
2007-09-20 16:54:22 +02:00
|
|
|
break;
|
|
|
|
case 0x0b: /* V9 ldx */
|
2008-07-17 14:53:05 +02:00
|
|
|
gen_address_mask(dc, cpu_addr);
|
2023-05-02 15:57:39 +02:00
|
|
|
tcg_gen_qemu_ld_tl(cpu_val, cpu_addr,
|
2023-05-02 17:12:44 +02:00
|
|
|
dc->mem_idx, MO_TEUQ | MO_ALIGN);
|
2007-09-20 16:54:22 +02:00
|
|
|
break;
|
|
|
|
case 0x18: /* V9 ldswa */
|
2015-09-03 06:55:40 +02:00
|
|
|
gen_ld_asi(dc, cpu_val, cpu_addr, insn, MO_TESL);
|
2007-09-20 16:54:22 +02:00
|
|
|
break;
|
|
|
|
case 0x1b: /* V9 ldxa */
|
2022-01-06 22:00:51 +01:00
|
|
|
gen_ld_asi(dc, cpu_val, cpu_addr, insn, MO_TEUQ);
|
2007-09-20 16:54:22 +02:00
|
|
|
break;
|
|
|
|
case 0x2d: /* V9 prefetch, no effect */
|
|
|
|
goto skip_move;
|
|
|
|
case 0x30: /* V9 ldfa */
|
2012-10-06 01:54:52 +02:00
|
|
|
if (gen_trap_ifnofpu(dc)) {
|
2011-07-14 11:41:37 +02:00
|
|
|
goto jmp_insn;
|
|
|
|
}
|
2015-09-03 06:22:41 +02:00
|
|
|
gen_ldf_asi(dc, cpu_addr, insn, 4, rd);
|
2015-09-09 20:56:38 +02:00
|
|
|
gen_update_fprs_dirty(dc, rd);
|
2007-09-21 21:10:53 +02:00
|
|
|
goto skip_move;
|
2007-09-20 16:54:22 +02:00
|
|
|
case 0x33: /* V9 lddfa */
|
2012-10-06 01:54:52 +02:00
|
|
|
if (gen_trap_ifnofpu(dc)) {
|
2011-07-14 11:41:37 +02:00
|
|
|
goto jmp_insn;
|
|
|
|
}
|
2015-09-03 06:22:41 +02:00
|
|
|
gen_ldf_asi(dc, cpu_addr, insn, 8, DFPREG(rd));
|
2015-09-09 20:56:38 +02:00
|
|
|
gen_update_fprs_dirty(dc, DFPREG(rd));
|
2007-09-21 21:10:53 +02:00
|
|
|
goto skip_move;
|
2007-09-20 16:54:22 +02:00
|
|
|
case 0x3d: /* V9 prefetcha, no effect */
|
|
|
|
goto skip_move;
|
|
|
|
case 0x32: /* V9 ldqfa */
|
2008-05-09 22:13:43 +02:00
|
|
|
CHECK_FPU_FEATURE(dc, FLOAT128);
|
2012-10-06 01:54:52 +02:00
|
|
|
if (gen_trap_ifnofpu(dc)) {
|
2011-07-14 11:41:37 +02:00
|
|
|
goto jmp_insn;
|
|
|
|
}
|
2015-09-03 06:22:41 +02:00
|
|
|
gen_ldf_asi(dc, cpu_addr, insn, 16, QFPREG(rd));
|
2015-09-09 20:56:38 +02:00
|
|
|
gen_update_fprs_dirty(dc, QFPREG(rd));
|
2007-11-25 19:40:20 +01:00
|
|
|
goto skip_move;
|
2007-09-20 16:54:22 +02:00
|
|
|
#endif
|
|
|
|
default:
|
|
|
|
goto illegal_insn;
|
|
|
|
}
|
2012-10-16 11:32:13 +02:00
|
|
|
gen_store_gpr(dc, rd, cpu_val);
|
2008-07-19 15:25:28 +02:00
|
|
|
#if !defined(CONFIG_USER_ONLY) || defined(TARGET_SPARC64)
|
2007-09-20 16:54:22 +02:00
|
|
|
skip_move: ;
|
2005-07-02 16:31:34 +02:00
|
|
|
#endif
|
2007-09-20 16:54:22 +02:00
|
|
|
} else if (xop >= 0x20 && xop < 0x24) {
|
2012-10-06 01:54:52 +02:00
|
|
|
if (gen_trap_ifnofpu(dc)) {
|
2006-06-26 21:53:29 +02:00
|
|
|
goto jmp_insn;
|
2012-10-06 01:54:52 +02:00
|
|
|
}
|
2007-09-20 16:54:22 +02:00
|
|
|
switch (xop) {
|
2009-05-02 22:19:46 +02:00
|
|
|
case 0x20: /* ldf, load fpreg */
|
2008-07-17 14:53:05 +02:00
|
|
|
gen_address_mask(dc, cpu_addr);
|
2012-10-16 11:32:21 +02:00
|
|
|
cpu_dst_32 = gen_dest_fpr_F(dc);
|
2016-08-31 19:48:03 +02:00
|
|
|
tcg_gen_qemu_ld_i32(cpu_dst_32, cpu_addr,
|
2023-05-02 17:12:44 +02:00
|
|
|
dc->mem_idx, MO_TEUL | MO_ALIGN);
|
2011-10-14 23:58:32 +02:00
|
|
|
gen_store_fpr_F(dc, rd, cpu_dst_32);
|
2007-09-20 16:54:22 +02:00
|
|
|
break;
|
2008-09-09 21:02:49 +02:00
|
|
|
case 0x21: /* ldfsr, V9 ldxfsr */
|
|
|
|
#ifdef TARGET_SPARC64
|
2008-07-17 14:53:05 +02:00
|
|
|
gen_address_mask(dc, cpu_addr);
|
2008-09-09 21:02:49 +02:00
|
|
|
if (rd == 1) {
|
2012-10-16 11:32:28 +02:00
|
|
|
TCGv_i64 t64 = tcg_temp_new_i64();
|
2016-08-31 19:48:03 +02:00
|
|
|
tcg_gen_qemu_ld_i64(t64, cpu_addr,
|
2023-05-02 17:12:44 +02:00
|
|
|
dc->mem_idx, MO_TEUQ | MO_ALIGN);
|
2015-09-09 20:11:36 +02:00
|
|
|
gen_helper_ldxfsr(cpu_fsr, cpu_env, cpu_fsr, t64);
|
2012-10-16 11:32:24 +02:00
|
|
|
break;
|
2010-06-01 22:12:37 +02:00
|
|
|
}
|
2012-10-16 11:32:24 +02:00
|
|
|
#endif
|
2023-02-25 08:26:59 +01:00
|
|
|
cpu_dst_32 = tcg_temp_new_i32();
|
2016-08-31 19:48:03 +02:00
|
|
|
tcg_gen_qemu_ld_i32(cpu_dst_32, cpu_addr,
|
2023-05-02 17:12:44 +02:00
|
|
|
dc->mem_idx, MO_TEUL | MO_ALIGN);
|
2015-09-09 20:11:36 +02:00
|
|
|
gen_helper_ldfsr(cpu_fsr, cpu_env, cpu_fsr, cpu_dst_32);
|
2007-09-20 16:54:22 +02:00
|
|
|
break;
|
2009-05-02 22:19:46 +02:00
|
|
|
case 0x22: /* ldqf, load quad fpreg */
|
2016-07-14 20:47:08 +02:00
|
|
|
CHECK_FPU_FEATURE(dc, FLOAT128);
|
|
|
|
gen_address_mask(dc, cpu_addr);
|
|
|
|
cpu_src1_64 = tcg_temp_new_i64();
|
2016-08-31 19:48:03 +02:00
|
|
|
tcg_gen_qemu_ld_i64(cpu_src1_64, cpu_addr, dc->mem_idx,
|
2022-01-06 22:00:51 +01:00
|
|
|
MO_TEUQ | MO_ALIGN_4);
|
2016-07-14 20:47:08 +02:00
|
|
|
tcg_gen_addi_tl(cpu_addr, cpu_addr, 8);
|
|
|
|
cpu_src2_64 = tcg_temp_new_i64();
|
2016-08-31 19:48:03 +02:00
|
|
|
tcg_gen_qemu_ld_i64(cpu_src2_64, cpu_addr, dc->mem_idx,
|
2022-01-06 22:00:51 +01:00
|
|
|
MO_TEUQ | MO_ALIGN_4);
|
2016-07-14 20:47:08 +02:00
|
|
|
gen_store_fpr_Q(dc, rd, cpu_src1_64, cpu_src2_64);
|
2007-11-25 19:40:20 +01:00
|
|
|
break;
|
2009-05-02 22:19:46 +02:00
|
|
|
case 0x23: /* lddf, load double fpreg */
|
2011-10-15 19:20:20 +02:00
|
|
|
gen_address_mask(dc, cpu_addr);
|
2012-10-16 11:32:26 +02:00
|
|
|
cpu_dst_64 = gen_dest_fpr_D(dc, rd);
|
2016-08-31 19:48:03 +02:00
|
|
|
tcg_gen_qemu_ld_i64(cpu_dst_64, cpu_addr, dc->mem_idx,
|
2022-01-06 22:00:51 +01:00
|
|
|
MO_TEUQ | MO_ALIGN_4);
|
2011-10-15 19:20:20 +02:00
|
|
|
gen_store_fpr_D(dc, rd, cpu_dst_64);
|
2007-09-20 16:54:22 +02:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
goto illegal_insn;
|
|
|
|
}
|
2009-05-03 20:51:22 +02:00
|
|
|
} else if (xop < 8 || (xop >= 0x14 && xop < 0x18) ||
|
2007-09-20 16:54:22 +02:00
|
|
|
xop == 0xe || xop == 0x1e) {
|
2012-10-16 11:32:17 +02:00
|
|
|
TCGv cpu_val = gen_load_gpr(dc, rd);
|
|
|
|
|
2007-09-20 16:54:22 +02:00
|
|
|
switch (xop) {
|
2009-05-02 22:19:46 +02:00
|
|
|
case 0x4: /* st, store word */
|
2008-07-17 14:53:05 +02:00
|
|
|
gen_address_mask(dc, cpu_addr);
|
2023-05-02 15:57:39 +02:00
|
|
|
tcg_gen_qemu_st_tl(cpu_val, cpu_addr,
|
2023-05-02 17:12:44 +02:00
|
|
|
dc->mem_idx, MO_TEUL | MO_ALIGN);
|
2007-09-20 16:54:22 +02:00
|
|
|
break;
|
2009-05-02 22:19:46 +02:00
|
|
|
case 0x5: /* stb, store byte */
|
2008-07-17 14:53:05 +02:00
|
|
|
gen_address_mask(dc, cpu_addr);
|
2023-05-02 15:57:39 +02:00
|
|
|
tcg_gen_qemu_st_tl(cpu_val, cpu_addr, dc->mem_idx, MO_UB);
|
2007-09-20 16:54:22 +02:00
|
|
|
break;
|
2009-05-02 22:19:46 +02:00
|
|
|
case 0x6: /* sth, store halfword */
|
2008-07-17 14:53:05 +02:00
|
|
|
gen_address_mask(dc, cpu_addr);
|
2023-05-02 15:57:39 +02:00
|
|
|
tcg_gen_qemu_st_tl(cpu_val, cpu_addr,
|
2023-05-02 17:12:44 +02:00
|
|
|
dc->mem_idx, MO_TEUW | MO_ALIGN);
|
2007-09-20 16:54:22 +02:00
|
|
|
break;
|
2009-05-02 22:19:46 +02:00
|
|
|
case 0x7: /* std, store double word */
|
2007-09-20 16:54:22 +02:00
|
|
|
if (rd & 1)
|
2007-04-01 17:15:36 +02:00
|
|
|
goto illegal_insn;
|
2008-02-24 15:10:06 +01:00
|
|
|
else {
|
2012-10-16 11:32:28 +02:00
|
|
|
TCGv_i64 t64;
|
2012-10-16 11:32:17 +02:00
|
|
|
TCGv lo;
|
2008-02-24 15:10:06 +01:00
|
|
|
|
2008-07-17 14:53:05 +02:00
|
|
|
gen_address_mask(dc, cpu_addr);
|
2012-10-16 11:32:17 +02:00
|
|
|
lo = gen_load_gpr(dc, rd + 1);
|
2012-10-16 11:32:28 +02:00
|
|
|
t64 = tcg_temp_new_i64();
|
|
|
|
tcg_gen_concat_tl_i64(t64, lo, cpu_val);
|
2023-05-02 15:57:39 +02:00
|
|
|
tcg_gen_qemu_st_i64(t64, cpu_addr,
|
2023-05-02 17:12:44 +02:00
|
|
|
dc->mem_idx, MO_TEUQ | MO_ALIGN);
|
2008-05-04 13:58:45 +02:00
|
|
|
}
|
2007-09-20 16:54:22 +02:00
|
|
|
break;
|
2005-07-02 16:31:34 +02:00
|
|
|
#if !defined(CONFIG_USER_ONLY) || defined(TARGET_SPARC64)
|
2009-05-02 22:19:46 +02:00
|
|
|
case 0x14: /* sta, V9 stwa, store word alternate */
|
2015-09-03 06:55:40 +02:00
|
|
|
gen_st_asi(dc, cpu_val, cpu_addr, insn, MO_TEUL);
|
2005-04-10 16:40:58 +02:00
|
|
|
break;
|
2009-05-02 22:19:46 +02:00
|
|
|
case 0x15: /* stba, store byte alternate */
|
2015-09-03 06:55:40 +02:00
|
|
|
gen_st_asi(dc, cpu_val, cpu_addr, insn, MO_UB);
|
2005-04-10 16:40:58 +02:00
|
|
|
break;
|
2009-05-02 22:19:46 +02:00
|
|
|
case 0x16: /* stha, store halfword alternate */
|
2015-09-03 06:55:40 +02:00
|
|
|
gen_st_asi(dc, cpu_val, cpu_addr, insn, MO_TEUW);
|
2005-04-10 16:40:58 +02:00
|
|
|
break;
|
2009-05-02 22:19:46 +02:00
|
|
|
case 0x17: /* stda, store double word alternate */
|
2015-09-03 06:45:15 +02:00
|
|
|
if (rd & 1) {
|
2007-09-20 16:54:22 +02:00
|
|
|
goto illegal_insn;
|
2008-02-24 15:10:06 +01:00
|
|
|
}
|
2015-09-03 06:45:15 +02:00
|
|
|
gen_stda_asi(dc, cpu_val, cpu_addr, insn, rd);
|
2005-04-10 16:40:58 +02:00
|
|
|
break;
|
2004-12-20 00:18:01 +01:00
|
|
|
#endif
|
2005-07-02 16:31:34 +02:00
|
|
|
#ifdef TARGET_SPARC64
|
2007-09-20 16:54:22 +02:00
|
|
|
case 0x0e: /* V9 stx */
|
2008-07-17 14:53:05 +02:00
|
|
|
gen_address_mask(dc, cpu_addr);
|
2023-05-02 15:57:39 +02:00
|
|
|
tcg_gen_qemu_st_tl(cpu_val, cpu_addr,
|
2023-05-02 17:12:44 +02:00
|
|
|
dc->mem_idx, MO_TEUQ | MO_ALIGN);
|
2007-09-20 16:54:22 +02:00
|
|
|
break;
|
|
|
|
case 0x1e: /* V9 stxa */
|
2022-01-06 22:00:51 +01:00
|
|
|
gen_st_asi(dc, cpu_val, cpu_addr, insn, MO_TEUQ);
|
2007-09-20 16:54:22 +02:00
|
|
|
break;
|
2005-07-02 16:31:34 +02:00
|
|
|
#endif
|
2007-09-20 16:54:22 +02:00
|
|
|
default:
|
|
|
|
goto illegal_insn;
|
|
|
|
}
|
|
|
|
} else if (xop > 0x23 && xop < 0x28) {
|
2012-10-06 01:54:52 +02:00
|
|
|
if (gen_trap_ifnofpu(dc)) {
|
2006-06-26 21:53:29 +02:00
|
|
|
goto jmp_insn;
|
2012-10-06 01:54:52 +02:00
|
|
|
}
|
2007-09-20 16:54:22 +02:00
|
|
|
switch (xop) {
|
2009-05-02 22:19:46 +02:00
|
|
|
case 0x24: /* stf, store fpreg */
|
2016-08-31 19:48:03 +02:00
|
|
|
gen_address_mask(dc, cpu_addr);
|
|
|
|
cpu_src1_32 = gen_load_fpr_F(dc, rd);
|
|
|
|
tcg_gen_qemu_st_i32(cpu_src1_32, cpu_addr,
|
2023-05-02 17:12:44 +02:00
|
|
|
dc->mem_idx, MO_TEUL | MO_ALIGN);
|
2007-09-20 16:54:22 +02:00
|
|
|
break;
|
|
|
|
case 0x25: /* stfsr, V9 stxfsr */
|
2012-10-16 11:32:24 +02:00
|
|
|
{
|
2008-09-09 21:02:49 +02:00
|
|
|
#ifdef TARGET_SPARC64
|
2012-10-16 11:32:24 +02:00
|
|
|
gen_address_mask(dc, cpu_addr);
|
|
|
|
if (rd == 1) {
|
2023-05-02 15:57:39 +02:00
|
|
|
tcg_gen_qemu_st_tl(cpu_fsr, cpu_addr,
|
2023-05-02 17:12:44 +02:00
|
|
|
dc->mem_idx, MO_TEUQ | MO_ALIGN);
|
2012-10-16 11:32:24 +02:00
|
|
|
break;
|
|
|
|
}
|
2008-09-09 21:02:49 +02:00
|
|
|
#endif
|
2023-05-02 15:57:39 +02:00
|
|
|
tcg_gen_qemu_st_tl(cpu_fsr, cpu_addr,
|
2023-05-02 17:12:44 +02:00
|
|
|
dc->mem_idx, MO_TEUL | MO_ALIGN);
|
2012-10-16 11:32:24 +02:00
|
|
|
}
|
2007-09-20 16:54:22 +02:00
|
|
|
break;
|
2007-11-25 19:40:20 +01:00
|
|
|
case 0x26:
|
|
|
|
#ifdef TARGET_SPARC64
|
|
|
|
/* V9 stqf, store quad fpreg */
|
2016-07-14 20:47:08 +02:00
|
|
|
CHECK_FPU_FEATURE(dc, FLOAT128);
|
|
|
|
gen_address_mask(dc, cpu_addr);
|
|
|
|
/* ??? While stqf only requires 4-byte alignment, it is
|
|
|
|
legal for the cpu to signal the unaligned exception.
|
|
|
|
The OS trap handler is then required to fix it up.
|
|
|
|
For qemu, this avoids having to probe the second page
|
|
|
|
before performing the first write. */
|
|
|
|
cpu_src1_64 = gen_load_fpr_Q0(dc, rd);
|
|
|
|
tcg_gen_qemu_st_i64(cpu_src1_64, cpu_addr,
|
2022-01-06 22:00:51 +01:00
|
|
|
dc->mem_idx, MO_TEUQ | MO_ALIGN_16);
|
2016-07-14 20:47:08 +02:00
|
|
|
tcg_gen_addi_tl(cpu_addr, cpu_addr, 8);
|
|
|
|
cpu_src2_64 = gen_load_fpr_Q1(dc, rd);
|
|
|
|
tcg_gen_qemu_st_i64(cpu_src1_64, cpu_addr,
|
2022-01-06 22:00:51 +01:00
|
|
|
dc->mem_idx, MO_TEUQ);
|
2007-11-25 19:40:20 +01:00
|
|
|
break;
|
|
|
|
#else /* !TARGET_SPARC64 */
|
|
|
|
/* stdfq, store floating point queue */
|
|
|
|
#if defined(CONFIG_USER_ONLY)
|
|
|
|
goto illegal_insn;
|
|
|
|
#else
|
2007-09-20 16:54:22 +02:00
|
|
|
if (!supervisor(dc))
|
|
|
|
goto priv_insn;
|
2012-10-06 01:54:52 +02:00
|
|
|
if (gen_trap_ifnofpu(dc)) {
|
2007-09-20 16:54:22 +02:00
|
|
|
goto jmp_insn;
|
2012-10-06 01:54:52 +02:00
|
|
|
}
|
2007-09-20 16:54:22 +02:00
|
|
|
goto nfq_insn;
|
2007-11-25 19:40:20 +01:00
|
|
|
#endif
|
2007-09-20 16:54:22 +02:00
|
|
|
#endif
|
2009-05-02 22:19:46 +02:00
|
|
|
case 0x27: /* stdf, store double fpreg */
|
2011-10-15 19:20:20 +02:00
|
|
|
gen_address_mask(dc, cpu_addr);
|
|
|
|
cpu_src1_64 = gen_load_fpr_D(dc, rd);
|
2016-08-31 19:48:03 +02:00
|
|
|
tcg_gen_qemu_st_i64(cpu_src1_64, cpu_addr, dc->mem_idx,
|
2022-01-06 22:00:51 +01:00
|
|
|
MO_TEUQ | MO_ALIGN_4);
|
2007-09-20 16:54:22 +02:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
goto illegal_insn;
|
|
|
|
}
|
|
|
|
} else if (xop > 0x33 && xop < 0x3f) {
|
|
|
|
switch (xop) {
|
2007-04-05 20:09:15 +02:00
|
|
|
#ifdef TARGET_SPARC64
|
2007-09-20 16:54:22 +02:00
|
|
|
case 0x34: /* V9 stfa */
|
2012-10-06 01:54:52 +02:00
|
|
|
if (gen_trap_ifnofpu(dc)) {
|
2011-07-14 11:41:39 +02:00
|
|
|
goto jmp_insn;
|
|
|
|
}
|
2015-09-03 06:22:41 +02:00
|
|
|
gen_stf_asi(dc, cpu_addr, insn, 4, rd);
|
2007-09-20 16:54:22 +02:00
|
|
|
break;
|
2007-11-25 19:40:20 +01:00
|
|
|
case 0x36: /* V9 stqfa */
|
2008-05-27 21:39:12 +02:00
|
|
|
{
|
|
|
|
CHECK_FPU_FEATURE(dc, FLOAT128);
|
2012-10-06 01:54:52 +02:00
|
|
|
if (gen_trap_ifnofpu(dc)) {
|
2011-07-14 11:41:39 +02:00
|
|
|
goto jmp_insn;
|
|
|
|
}
|
2015-09-03 06:22:41 +02:00
|
|
|
gen_stf_asi(dc, cpu_addr, insn, 16, QFPREG(rd));
|
2008-05-27 21:39:12 +02:00
|
|
|
}
|
2007-11-25 19:40:20 +01:00
|
|
|
break;
|
2007-09-20 16:54:22 +02:00
|
|
|
case 0x37: /* V9 stdfa */
|
2012-10-06 01:54:52 +02:00
|
|
|
if (gen_trap_ifnofpu(dc)) {
|
2011-07-14 11:41:39 +02:00
|
|
|
goto jmp_insn;
|
|
|
|
}
|
2015-09-03 06:22:41 +02:00
|
|
|
gen_stf_asi(dc, cpu_addr, insn, 8, DFPREG(rd));
|
2007-09-20 16:54:22 +02:00
|
|
|
break;
|
|
|
|
case 0x3e: /* V9 casxa */
|
2012-10-16 11:32:18 +02:00
|
|
|
rs2 = GET_FIELD(insn, 27, 31);
|
|
|
|
cpu_src2 = gen_load_gpr(dc, rs2);
|
2012-10-16 11:32:17 +02:00
|
|
|
gen_casx_asi(dc, cpu_addr, cpu_src2, insn, rd);
|
2007-09-20 16:54:22 +02:00
|
|
|
break;
|
2007-04-05 20:09:15 +02:00
|
|
|
#else
|
2007-09-20 16:54:22 +02:00
|
|
|
case 0x34: /* stc */
|
|
|
|
case 0x35: /* stcsr */
|
|
|
|
case 0x36: /* stdcq */
|
|
|
|
case 0x37: /* stdc */
|
|
|
|
goto ncp_insn;
|
target-sparc: Add and use CPU_FEATURE_CASA
The LEON3 processor has support for the CASA instruction which is
normally only available for SPARC V9 processors. Binutils 2.24
and GCC 4.9 will support this instruction for LEON3. GCC uses it to
generate C11 atomic operations.
The CAS synthetic instruction uses an ASI of 0x80. If TARGET_SPARC64 is
not defined use a supervisor data load/store for an ASI of 0x80 in
helper_ld_asi()/helper_st_asi(). The supervisor data load/store was
choosen according to the LEON3 documentation.
The ASI 0x80 is defined in the SPARC V9 manual, Table 12—Address Space
Identifiers (ASIs). Here we have: 0x80, ASI_PRIMARY, Unrestricted
access, Primary address space.
Tested with the following program:
#include <assert.h>
#include <stdatomic.h>
void test(void)
{
atomic_int a;
int e;
_Bool b;
atomic_store(&a, 1);
e = 1;
b = atomic_compare_exchange_strong(&a, &e, 2);
assert(b);
assert(atomic_load(&a) == 2);
atomic_store(&a, 3);
e = 4;
b = atomic_compare_exchange_strong(&a, &e, 5);
assert(!b);
assert(atomic_load(&a) == 3);
}
Tested also on a NGMP board with a LEON4 processor.
Reviewed-by: Fabien Chouteau <chouteau@adacore.com>
Reviewed-by: Andreas Färber <afaerber@suse.de>
Tested-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
Reviewed-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
2014-03-11 10:36:00 +01:00
|
|
|
#endif
|
|
|
|
#if !defined(CONFIG_USER_ONLY) || defined(TARGET_SPARC64)
|
|
|
|
case 0x3c: /* V9 or LEON3 casa */
|
|
|
|
#ifndef TARGET_SPARC64
|
|
|
|
CHECK_IU_FEATURE(dc, CASA);
|
|
|
|
#endif
|
|
|
|
rs2 = GET_FIELD(insn, 27, 31);
|
|
|
|
cpu_src2 = gen_load_gpr(dc, rs2);
|
|
|
|
gen_cas_asi(dc, cpu_addr, cpu_src2, insn, rd);
|
|
|
|
break;
|
2007-09-20 16:54:22 +02:00
|
|
|
#endif
|
|
|
|
default:
|
|
|
|
goto illegal_insn;
|
|
|
|
}
|
2012-10-16 11:32:18 +02:00
|
|
|
} else {
|
2007-09-20 16:54:22 +02:00
|
|
|
goto illegal_insn;
|
2012-10-16 11:32:18 +02:00
|
|
|
}
|
2007-09-20 16:54:22 +02:00
|
|
|
}
|
|
|
|
break;
|
2004-01-04 16:01:44 +01:00
|
|
|
}
|
|
|
|
/* default case for non jump instructions */
|
2004-02-16 21:30:05 +01:00
|
|
|
if (dc->npc == DYNAMIC_PC) {
|
2007-09-20 16:54:22 +02:00
|
|
|
dc->pc = DYNAMIC_PC;
|
|
|
|
gen_op_next_insn();
|
2004-02-16 21:30:05 +01:00
|
|
|
} else if (dc->npc == JUMP_PC) {
|
|
|
|
/* we can do a static jump */
|
2008-03-29 10:09:25 +01:00
|
|
|
gen_branch2(dc, dc->jump_pc[0], dc->jump_pc[1], cpu_cond);
|
2018-02-15 03:16:30 +01:00
|
|
|
dc->base.is_jmp = DISAS_NORETURN;
|
2004-02-16 21:30:05 +01:00
|
|
|
} else {
|
2007-09-20 16:54:22 +02:00
|
|
|
dc->pc = dc->npc;
|
|
|
|
dc->npc = dc->npc + 4;
|
2004-01-04 16:01:44 +01:00
|
|
|
}
|
2004-12-20 00:18:01 +01:00
|
|
|
jmp_insn:
|
2023-02-25 08:29:17 +01:00
|
|
|
return;
|
2004-01-04 16:01:44 +01:00
|
|
|
illegal_insn:
|
2015-09-03 05:00:29 +02:00
|
|
|
gen_exception(dc, TT_ILL_INSN);
|
2023-02-25 08:29:17 +01:00
|
|
|
return;
|
2008-05-09 22:13:43 +02:00
|
|
|
unimp_flush:
|
2015-09-03 05:00:29 +02:00
|
|
|
gen_exception(dc, TT_UNIMP_FLUSH);
|
2023-02-25 08:29:17 +01:00
|
|
|
return;
|
2004-12-20 00:18:01 +01:00
|
|
|
#if !defined(CONFIG_USER_ONLY)
|
2004-09-30 23:55:55 +02:00
|
|
|
priv_insn:
|
2015-09-03 05:00:29 +02:00
|
|
|
gen_exception(dc, TT_PRIV_INSN);
|
2023-02-25 08:29:17 +01:00
|
|
|
return;
|
2008-05-09 22:13:43 +02:00
|
|
|
#endif
|
2004-12-20 00:18:01 +01:00
|
|
|
nfpu_insn:
|
2015-09-03 05:00:29 +02:00
|
|
|
gen_op_fpexception_im(dc, FSR_FTT_UNIMPFPOP);
|
2023-02-25 08:29:17 +01:00
|
|
|
return;
|
2008-05-09 22:13:43 +02:00
|
|
|
#if !defined(CONFIG_USER_ONLY) && !defined(TARGET_SPARC64)
|
2007-04-05 20:12:08 +02:00
|
|
|
nfq_insn:
|
2015-09-03 05:00:29 +02:00
|
|
|
gen_op_fpexception_im(dc, FSR_FTT_SEQ_ERROR);
|
2023-02-25 08:29:17 +01:00
|
|
|
return;
|
2007-04-05 20:12:08 +02:00
|
|
|
#endif
|
2007-04-01 17:08:21 +02:00
|
|
|
#ifndef TARGET_SPARC64
|
|
|
|
ncp_insn:
|
2015-09-03 05:00:29 +02:00
|
|
|
gen_exception(dc, TT_NCP_INSN);
|
2023-02-25 08:29:17 +01:00
|
|
|
return;
|
2007-04-01 17:08:21 +02:00
|
|
|
#endif
|
2003-09-30 22:36:07 +02:00
|
|
|
}
|
|
|
|
|
2018-02-15 23:50:16 +01:00
|
|
|
static void sparc_tr_init_disas_context(DisasContextBase *dcbase, CPUState *cs)
|
2003-09-30 22:36:07 +02:00
|
|
|
{
|
2018-02-15 23:50:16 +01:00
|
|
|
DisasContext *dc = container_of(dcbase, DisasContext, base);
|
2017-07-14 10:17:35 +02:00
|
|
|
CPUSPARCState *env = cs->env_ptr;
|
2018-02-15 23:50:16 +01:00
|
|
|
int bound;
|
2018-02-15 03:16:30 +01:00
|
|
|
|
|
|
|
dc->pc = dc->base.pc_first;
|
2018-02-15 23:50:16 +01:00
|
|
|
dc->npc = (target_ulong)dc->base.tb->cs_base;
|
2009-05-10 09:19:11 +02:00
|
|
|
dc->cc_op = CC_OP_DYNAMIC;
|
2018-02-15 23:50:16 +01:00
|
|
|
dc->mem_idx = dc->base.tb->flags & TB_FLAG_MMU_MASK;
|
2017-08-24 18:31:26 +02:00
|
|
|
dc->def = &env->def;
|
2018-02-15 23:50:16 +01:00
|
|
|
dc->fpu_enabled = tb_fpu_enabled(dc->base.tb->flags);
|
|
|
|
dc->address_mask_32bit = tb_am_enabled(dc->base.tb->flags);
|
2016-11-01 21:57:01 +01:00
|
|
|
#ifndef CONFIG_USER_ONLY
|
2018-02-15 23:50:16 +01:00
|
|
|
dc->supervisor = (dc->base.tb->flags & TB_FLAG_SUPER) != 0;
|
2016-11-01 21:57:01 +01:00
|
|
|
#endif
|
2015-09-03 23:14:33 +02:00
|
|
|
#ifdef TARGET_SPARC64
|
2015-09-09 20:56:38 +02:00
|
|
|
dc->fprs_dirty = 0;
|
2018-02-15 23:50:16 +01:00
|
|
|
dc->asi = (dc->base.tb->flags >> TB_FLAG_ASI_SHIFT) & 0xff;
|
2016-11-01 21:57:01 +01:00
|
|
|
#ifndef CONFIG_USER_ONLY
|
2018-02-15 23:50:16 +01:00
|
|
|
dc->hypervisor = (dc->base.tb->flags & TB_FLAG_HYPER) != 0;
|
2016-11-01 21:57:01 +01:00
|
|
|
#endif
|
2015-09-03 23:14:33 +02:00
|
|
|
#endif
|
2018-02-15 23:50:16 +01:00
|
|
|
/*
|
|
|
|
* if we reach a page boundary, we stop generation so that the
|
|
|
|
* PC of a TT_TFAULT exception is always in the right page
|
|
|
|
*/
|
|
|
|
bound = -(dc->base.pc_first | TARGET_PAGE_MASK) / 4;
|
|
|
|
dc->base.max_insns = MIN(dc->base.max_insns, bound);
|
|
|
|
}
|
2004-01-04 16:01:44 +01:00
|
|
|
|
2018-02-15 23:50:16 +01:00
|
|
|
static void sparc_tr_tb_start(DisasContextBase *db, CPUState *cs)
|
|
|
|
{
|
|
|
|
}
|
2015-08-31 23:34:41 +02:00
|
|
|
|
2018-02-15 23:50:16 +01:00
|
|
|
static void sparc_tr_insn_start(DisasContextBase *dcbase, CPUState *cs)
|
|
|
|
{
|
|
|
|
DisasContext *dc = container_of(dcbase, DisasContext, base);
|
2015-08-29 21:59:29 +02:00
|
|
|
|
2018-02-15 23:50:16 +01:00
|
|
|
if (dc->npc & JUMP_PC) {
|
|
|
|
assert(dc->jump_pc[1] == dc->pc + 4);
|
|
|
|
tcg_gen_insn_start(dc->pc, dc->jump_pc[0] | JUMP_PC);
|
|
|
|
} else {
|
|
|
|
tcg_gen_insn_start(dc->pc, dc->npc);
|
|
|
|
}
|
|
|
|
}
|
2015-09-18 00:58:10 +02:00
|
|
|
|
2018-02-15 23:50:16 +01:00
|
|
|
static void sparc_tr_translate_insn(DisasContextBase *dcbase, CPUState *cs)
|
|
|
|
{
|
|
|
|
DisasContext *dc = container_of(dcbase, DisasContext, base);
|
|
|
|
CPUSPARCState *env = cs->env_ptr;
|
|
|
|
unsigned int insn;
|
2007-09-20 16:54:22 +02:00
|
|
|
|
2021-08-10 00:32:59 +02:00
|
|
|
insn = translator_ldl(env, &dc->base, dc->pc);
|
2018-02-15 23:50:16 +01:00
|
|
|
dc->base.pc_next += 4;
|
|
|
|
disas_sparc_insn(dc, insn);
|
2004-12-20 00:18:01 +01:00
|
|
|
|
2018-02-15 23:50:16 +01:00
|
|
|
if (dc->base.is_jmp == DISAS_NORETURN) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (dc->pc != dc->base.pc_next) {
|
|
|
|
dc->base.is_jmp = DISAS_TOO_MANY;
|
2012-10-06 01:55:08 +02:00
|
|
|
}
|
2018-02-15 23:50:16 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static void sparc_tr_tb_stop(DisasContextBase *dcbase, CPUState *cs)
|
|
|
|
{
|
|
|
|
DisasContext *dc = container_of(dcbase, DisasContext, base);
|
|
|
|
|
2018-06-15 09:33:03 +02:00
|
|
|
switch (dc->base.is_jmp) {
|
|
|
|
case DISAS_NEXT:
|
|
|
|
case DISAS_TOO_MANY:
|
2007-09-16 23:08:06 +02:00
|
|
|
if (dc->pc != DYNAMIC_PC &&
|
2004-02-16 21:30:05 +01:00
|
|
|
(dc->npc != DYNAMIC_PC && dc->npc != JUMP_PC)) {
|
|
|
|
/* static PC and NPC: we can use direct chaining */
|
2008-03-26 21:45:06 +01:00
|
|
|
gen_goto_tb(dc, 0, dc->pc, dc->npc);
|
2004-02-16 21:30:05 +01:00
|
|
|
} else {
|
2012-10-06 01:55:08 +02:00
|
|
|
if (dc->pc != DYNAMIC_PC) {
|
2008-03-26 21:45:06 +01:00
|
|
|
tcg_gen_movi_tl(cpu_pc, dc->pc);
|
2012-10-06 01:55:08 +02:00
|
|
|
}
|
2012-10-06 01:54:55 +02:00
|
|
|
save_npc(dc);
|
2018-05-31 03:06:23 +02:00
|
|
|
tcg_gen_exit_tb(NULL, 0);
|
2004-02-16 21:30:05 +01:00
|
|
|
}
|
2018-06-15 09:33:03 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case DISAS_NORETURN:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case DISAS_EXIT:
|
|
|
|
/* Exit TB */
|
|
|
|
save_state(dc);
|
|
|
|
tcg_gen_exit_tb(NULL, 0);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
g_assert_not_reached();
|
2004-02-16 21:30:05 +01:00
|
|
|
}
|
2018-02-15 23:50:16 +01:00
|
|
|
}
|
|
|
|
|
2022-04-17 20:29:52 +02:00
|
|
|
static void sparc_tr_disas_log(const DisasContextBase *dcbase,
|
|
|
|
CPUState *cpu, FILE *logfile)
|
2018-02-15 23:50:16 +01:00
|
|
|
{
|
2022-04-17 20:29:52 +02:00
|
|
|
fprintf(logfile, "IN: %s\n", lookup_symbol(dcbase->pc_first));
|
|
|
|
target_disas(logfile, cpu, dcbase->pc_first, dcbase->tb->size);
|
2018-02-15 23:50:16 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static const TranslatorOps sparc_tr_ops = {
|
|
|
|
.init_disas_context = sparc_tr_init_disas_context,
|
|
|
|
.tb_start = sparc_tr_tb_start,
|
|
|
|
.insn_start = sparc_tr_insn_start,
|
|
|
|
.translate_insn = sparc_tr_translate_insn,
|
|
|
|
.tb_stop = sparc_tr_tb_stop,
|
|
|
|
.disas_log = sparc_tr_disas_log,
|
|
|
|
};
|
|
|
|
|
2023-01-29 02:19:22 +01:00
|
|
|
void gen_intermediate_code(CPUState *cs, TranslationBlock *tb, int *max_insns,
|
2022-08-11 22:48:03 +02:00
|
|
|
target_ulong pc, void *host_pc)
|
2018-02-15 23:50:16 +01:00
|
|
|
{
|
|
|
|
DisasContext dc = {};
|
|
|
|
|
2022-08-11 22:48:03 +02:00
|
|
|
translator_loop(cs, tb, max_insns, pc, host_pc, &sparc_tr_ops, &dc.base);
|
2003-09-30 22:36:07 +02:00
|
|
|
}
|
|
|
|
|
2017-10-16 04:02:42 +02:00
|
|
|
void sparc_tcg_init(void)
|
2004-12-20 00:18:01 +01:00
|
|
|
{
|
2013-09-19 19:51:12 +02:00
|
|
|
static const char gregnames[32][4] = {
|
2013-09-19 19:49:01 +02:00
|
|
|
"g0", "g1", "g2", "g3", "g4", "g5", "g6", "g7",
|
2013-09-19 19:51:12 +02:00
|
|
|
"o0", "o1", "o2", "o3", "o4", "o5", "o6", "o7",
|
|
|
|
"l0", "l1", "l2", "l3", "l4", "l5", "l6", "l7",
|
|
|
|
"i0", "i1", "i2", "i3", "i4", "i5", "i6", "i7",
|
2008-03-14 18:35:02 +01:00
|
|
|
};
|
2013-09-19 19:49:01 +02:00
|
|
|
static const char fregnames[32][4] = {
|
2011-10-17 19:42:49 +02:00
|
|
|
"f0", "f2", "f4", "f6", "f8", "f10", "f12", "f14",
|
|
|
|
"f16", "f18", "f20", "f22", "f24", "f26", "f28", "f30",
|
|
|
|
"f32", "f34", "f36", "f38", "f40", "f42", "f44", "f46",
|
|
|
|
"f48", "f50", "f52", "f54", "f56", "f58", "f60", "f62",
|
2008-09-10 21:54:51 +02:00
|
|
|
};
|
2007-11-10 16:15:54 +01:00
|
|
|
|
2013-09-19 19:49:01 +02:00
|
|
|
static const struct { TCGv_i32 *ptr; int off; const char *name; } r32[] = {
|
2008-02-24 15:10:06 +01:00
|
|
|
#ifdef TARGET_SPARC64
|
2013-09-19 19:49:01 +02:00
|
|
|
{ &cpu_xcc, offsetof(CPUSPARCState, xcc), "xcc" },
|
|
|
|
{ &cpu_fprs, offsetof(CPUSPARCState, fprs), "fprs" },
|
2008-09-06 19:51:43 +02:00
|
|
|
#else
|
2013-09-19 19:49:01 +02:00
|
|
|
{ &cpu_wim, offsetof(CPUSPARCState, wim), "wim" },
|
|
|
|
#endif
|
|
|
|
{ &cpu_cc_op, offsetof(CPUSPARCState, cc_op), "cc_op" },
|
|
|
|
{ &cpu_psr, offsetof(CPUSPARCState, psr), "psr" },
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct { TCGv *ptr; int off; const char *name; } rtl[] = {
|
|
|
|
#ifdef TARGET_SPARC64
|
|
|
|
{ &cpu_gsr, offsetof(CPUSPARCState, gsr), "gsr" },
|
|
|
|
{ &cpu_tick_cmpr, offsetof(CPUSPARCState, tick_cmpr), "tick_cmpr" },
|
|
|
|
{ &cpu_stick_cmpr, offsetof(CPUSPARCState, stick_cmpr), "stick_cmpr" },
|
|
|
|
{ &cpu_hstick_cmpr, offsetof(CPUSPARCState, hstick_cmpr),
|
|
|
|
"hstick_cmpr" },
|
|
|
|
{ &cpu_hintp, offsetof(CPUSPARCState, hintp), "hintp" },
|
|
|
|
{ &cpu_htba, offsetof(CPUSPARCState, htba), "htba" },
|
|
|
|
{ &cpu_hver, offsetof(CPUSPARCState, hver), "hver" },
|
|
|
|
{ &cpu_ssr, offsetof(CPUSPARCState, ssr), "ssr" },
|
|
|
|
{ &cpu_ver, offsetof(CPUSPARCState, version), "ver" },
|
2008-02-24 15:10:06 +01:00
|
|
|
#endif
|
2013-09-19 19:49:01 +02:00
|
|
|
{ &cpu_cond, offsetof(CPUSPARCState, cond), "cond" },
|
|
|
|
{ &cpu_cc_src, offsetof(CPUSPARCState, cc_src), "cc_src" },
|
|
|
|
{ &cpu_cc_src2, offsetof(CPUSPARCState, cc_src2), "cc_src2" },
|
|
|
|
{ &cpu_cc_dst, offsetof(CPUSPARCState, cc_dst), "cc_dst" },
|
|
|
|
{ &cpu_fsr, offsetof(CPUSPARCState, fsr), "fsr" },
|
|
|
|
{ &cpu_pc, offsetof(CPUSPARCState, pc), "pc" },
|
|
|
|
{ &cpu_npc, offsetof(CPUSPARCState, npc), "npc" },
|
|
|
|
{ &cpu_y, offsetof(CPUSPARCState, y), "y" },
|
2008-09-06 19:51:43 +02:00
|
|
|
#ifndef CONFIG_USER_ONLY
|
2013-09-19 19:49:01 +02:00
|
|
|
{ &cpu_tbr, offsetof(CPUSPARCState, tbr), "tbr" },
|
2008-09-06 19:51:43 +02:00
|
|
|
#endif
|
2013-09-19 19:49:01 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
unsigned int i;
|
|
|
|
|
|
|
|
cpu_regwptr = tcg_global_mem_new_ptr(cpu_env,
|
|
|
|
offsetof(CPUSPARCState, regwptr),
|
|
|
|
"regwptr");
|
|
|
|
|
|
|
|
for (i = 0; i < ARRAY_SIZE(r32); ++i) {
|
|
|
|
*r32[i].ptr = tcg_global_mem_new_i32(cpu_env, r32[i].off, r32[i].name);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < ARRAY_SIZE(rtl); ++i) {
|
|
|
|
*rtl[i].ptr = tcg_global_mem_new(cpu_env, rtl[i].off, rtl[i].name);
|
|
|
|
}
|
|
|
|
|
2017-11-02 12:47:37 +01:00
|
|
|
cpu_regs[0] = NULL;
|
2013-09-19 19:49:01 +02:00
|
|
|
for (i = 1; i < 8; ++i) {
|
2013-09-19 19:51:12 +02:00
|
|
|
cpu_regs[i] = tcg_global_mem_new(cpu_env,
|
|
|
|
offsetof(CPUSPARCState, gregs[i]),
|
|
|
|
gregnames[i]);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 8; i < 32; ++i) {
|
|
|
|
cpu_regs[i] = tcg_global_mem_new(cpu_regwptr,
|
|
|
|
(i - 8) * sizeof(target_ulong),
|
|
|
|
gregnames[i]);
|
2013-09-19 19:49:01 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < TARGET_DPREGS; i++) {
|
|
|
|
cpu_fpr[i] = tcg_global_mem_new_i64(cpu_env,
|
|
|
|
offsetof(CPUSPARCState, fpr[i]),
|
|
|
|
fregnames[i]);
|
2008-02-24 15:10:06 +01:00
|
|
|
}
|
2004-04-25 19:56:08 +02:00
|
|
|
}
|
2008-04-28 02:32:32 +02:00
|
|
|
|
2022-10-24 13:03:29 +02:00
|
|
|
void sparc_restore_state_to_opc(CPUState *cs,
|
|
|
|
const TranslationBlock *tb,
|
|
|
|
const uint64_t *data)
|
2008-04-28 02:32:32 +02:00
|
|
|
{
|
2022-10-24 13:03:29 +02:00
|
|
|
SPARCCPU *cpu = SPARC_CPU(cs);
|
|
|
|
CPUSPARCState *env = &cpu->env;
|
2015-09-02 00:51:12 +02:00
|
|
|
target_ulong pc = data[0];
|
|
|
|
target_ulong npc = data[1];
|
|
|
|
|
|
|
|
env->pc = pc;
|
2015-08-31 22:24:44 +02:00
|
|
|
if (npc == DYNAMIC_PC) {
|
2008-04-28 02:32:32 +02:00
|
|
|
/* dynamic NPC: already stored */
|
2015-08-31 22:24:44 +02:00
|
|
|
} else if (npc & JUMP_PC) {
|
2010-04-11 21:47:49 +02:00
|
|
|
/* jump PC: use 'cond' and the jump targets of the translation */
|
|
|
|
if (env->cond) {
|
2015-08-31 22:24:44 +02:00
|
|
|
env->npc = npc & ~3;
|
2010-04-11 21:47:49 +02:00
|
|
|
} else {
|
2015-08-31 22:24:44 +02:00
|
|
|
env->npc = pc + 4;
|
2010-04-11 21:47:49 +02:00
|
|
|
}
|
2008-04-28 02:32:32 +02:00
|
|
|
} else {
|
|
|
|
env->npc = npc;
|
|
|
|
}
|
|
|
|
}
|