2003-10-01 00:36:07 +04:00
|
|
|
/*
|
|
|
|
SPARC translation
|
|
|
|
|
|
|
|
Copyright (C) 2003 Thomas M. Ogrisegg <tom@fnord.at>
|
2005-07-02 18:31:34 +04:00
|
|
|
Copyright (C) 2003-2005 Fabrice Bellard
|
2003-10-01 00:36:07 +04:00
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU Lesser General Public
|
|
|
|
License as published by the Free Software Foundation; either
|
|
|
|
version 2 of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
This library is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
Lesser General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Lesser General Public
|
2009-07-17 00:47:01 +04:00
|
|
|
License along with this library; if not, see <http://www.gnu.org/licenses/>.
|
2003-10-01 00:36:07 +04:00
|
|
|
*/
|
|
|
|
|
2016-01-26 21:16:59 +03:00
|
|
|
#include "qemu/osdep.h"
|
2003-10-01 00:36:07 +04:00
|
|
|
|
|
|
|
#include "cpu.h"
|
2012-10-24 13:12:21 +04:00
|
|
|
#include "disas/disas.h"
|
2014-04-08 09:31:41 +04:00
|
|
|
#include "exec/helper-proto.h"
|
2008-02-01 13:50:11 +03:00
|
|
|
#include "tcg-op.h"
|
2014-03-28 22:42:10 +04:00
|
|
|
#include "exec/cpu_ldst.h"
|
2003-10-01 00:36:07 +04:00
|
|
|
|
2014-04-08 09:31:41 +04:00
|
|
|
#include "exec/helper-gen.h"
|
2008-11-17 17:43:54 +03:00
|
|
|
|
2014-05-30 16:12:25 +04:00
|
|
|
#include "trace-tcg.h"
|
|
|
|
|
|
|
|
|
2003-10-01 00:36:07 +04:00
|
|
|
#define DEBUG_DISAS
|
|
|
|
|
2004-02-16 23:30:05 +03: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] */
|
|
|
|
|
2008-02-24 17:10:06 +03:00
|
|
|
/* global register indexes */
|
2008-11-17 17:43:54 +03:00
|
|
|
static TCGv_ptr cpu_env, cpu_regwptr;
|
2009-06-06 05:54:03 +04:00
|
|
|
static TCGv cpu_cc_src, cpu_cc_src2, cpu_cc_dst;
|
|
|
|
static TCGv_i32 cpu_cc_op;
|
2008-11-17 17:43:54 +03:00
|
|
|
static TCGv_i32 cpu_psr;
|
|
|
|
static TCGv cpu_fsr, cpu_pc, cpu_npc, cpu_gregs[8];
|
2008-09-06 21:51:43 +04:00
|
|
|
static TCGv cpu_y;
|
|
|
|
#ifndef CONFIG_USER_ONLY
|
|
|
|
static TCGv cpu_tbr;
|
|
|
|
#endif
|
2012-10-16 13:32:30 +04:00
|
|
|
static TCGv cpu_cond;
|
2008-03-13 23:45:31 +03:00
|
|
|
#ifdef TARGET_SPARC64
|
2008-11-17 17:43:54 +03:00
|
|
|
static TCGv_i32 cpu_xcc, cpu_asi, cpu_fprs;
|
|
|
|
static TCGv cpu_gsr;
|
2008-09-06 21:51:43 +04:00
|
|
|
static TCGv cpu_tick_cmpr, cpu_stick_cmpr, cpu_hstick_cmpr;
|
2008-11-17 17:43:54 +03:00
|
|
|
static TCGv cpu_hintp, cpu_htba, cpu_hver, cpu_ssr, cpu_ver;
|
|
|
|
static TCGv_i32 cpu_softint;
|
2008-09-06 21:51:43 +04:00
|
|
|
#else
|
|
|
|
static TCGv cpu_wim;
|
2008-03-13 23:45:31 +03:00
|
|
|
#endif
|
2008-09-10 23:54:51 +04:00
|
|
|
/* Floating point registers */
|
2011-10-17 21:42:49 +04:00
|
|
|
static TCGv_i64 cpu_fpr[TARGET_DPREGS];
|
2008-02-24 17:10:06 +03:00
|
|
|
|
2012-12-17 21:19:49 +04:00
|
|
|
#include "exec/gen-icount.h"
|
2008-06-29 05:03:05 +04:00
|
|
|
|
2003-10-01 00:36:07 +04:00
|
|
|
typedef struct DisasContext {
|
2007-09-20 18:54:22 +04: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 23:30:05 +03:00
|
|
|
target_ulong jump_pc[2]; /* used when JUMP_PC pc value is used */
|
2004-01-04 18:01:44 +03:00
|
|
|
int is_br;
|
2004-10-01 01:55:55 +04:00
|
|
|
int mem_idx;
|
2006-06-26 23:53:29 +04:00
|
|
|
int fpu_enabled;
|
2008-07-17 16:53:05 +04:00
|
|
|
int address_mask_32bit;
|
2010-04-26 21:17:24 +04:00
|
|
|
int singlestep;
|
2009-05-10 11:19:11 +04:00
|
|
|
uint32_t cc_op; /* current CC operation */
|
2004-01-04 18:01:44 +03:00
|
|
|
struct TranslationBlock *tb;
|
2008-08-21 21:33:42 +04:00
|
|
|
sparc_def_t *def;
|
2011-10-17 21:42:49 +04:00
|
|
|
TCGv_i32 t32[3];
|
2012-10-16 13:32:12 +04:00
|
|
|
TCGv ttl[5];
|
2011-10-17 21:42:49 +04:00
|
|
|
int n_t32;
|
2012-10-16 13:32:12 +04:00
|
|
|
int n_ttl;
|
2003-10-01 00:36:07 +04:00
|
|
|
} DisasContext;
|
|
|
|
|
2012-10-06 03:54:57 +04:00
|
|
|
typedef struct {
|
|
|
|
TCGCond cond;
|
|
|
|
bool is_bool;
|
|
|
|
bool g1, g2;
|
|
|
|
TCGv c1, c2;
|
|
|
|
} DisasCompare;
|
|
|
|
|
2005-07-02 18:31:34 +04:00
|
|
|
// This function uses non-native bit order
|
2009-05-03 22:51:22 +04:00
|
|
|
#define GET_FIELD(X, FROM, TO) \
|
|
|
|
((X) >> (31 - (TO)) & ((1 << ((TO) - (FROM) + 1)) - 1))
|
2003-10-01 00:36:07 +04:00
|
|
|
|
2005-07-02 18:31:34 +04:00
|
|
|
// This function uses the order in the manuals, i.e. bit 0 is 2^0
|
2009-05-03 22:51:22 +04:00
|
|
|
#define GET_FIELD_SP(X, FROM, TO) \
|
2005-07-02 18:31:34 +04: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-05 00:22:35 +04:00
|
|
|
#define GET_FIELD_SPs(x,a,b) sign_extend (GET_FIELD_SP(x,a,b), ((b) - (a) + 1))
|
2005-07-02 18:31:34 +04:00
|
|
|
|
|
|
|
#ifdef TARGET_SPARC64
|
2007-10-03 21:46:29 +04:00
|
|
|
#define DFPREG(r) (((r & 1) << 5) | (r & 0x1e))
|
2007-11-25 21:40:20 +03:00
|
|
|
#define QFPREG(r) (((r & 1) << 5) | (r & 0x1c))
|
2005-07-02 18:31:34 +04:00
|
|
|
#else
|
2007-04-07 00:02:09 +04:00
|
|
|
#define DFPREG(r) (r & 0x1e)
|
2007-11-25 21:40:20 +03:00
|
|
|
#define QFPREG(r) (r & 0x1c)
|
2005-07-02 18:31:34 +04:00
|
|
|
#endif
|
|
|
|
|
2008-09-26 22:05:23 +04:00
|
|
|
#define UA2005_HTRAP_MASK 0xff
|
|
|
|
#define V8_TRAP_MASK 0x7f
|
|
|
|
|
2005-07-02 18:31:34 +04:00
|
|
|
static int sign_extend(int x, int len)
|
|
|
|
{
|
|
|
|
len = 32 - len;
|
|
|
|
return (x << len) >> len;
|
|
|
|
}
|
|
|
|
|
2003-10-01 00:36:07 +04:00
|
|
|
#define IS_IMM (insn & (1<<13))
|
|
|
|
|
2012-10-16 13:32:20 +04:00
|
|
|
static inline TCGv_i32 get_temp_i32(DisasContext *dc)
|
|
|
|
{
|
|
|
|
TCGv_i32 t;
|
|
|
|
assert(dc->n_t32 < ARRAY_SIZE(dc->t32));
|
|
|
|
dc->t32[dc->n_t32++] = t = tcg_temp_new_i32();
|
|
|
|
return t;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline TCGv get_temp_tl(DisasContext *dc)
|
|
|
|
{
|
|
|
|
TCGv t;
|
|
|
|
assert(dc->n_ttl < ARRAY_SIZE(dc->ttl));
|
|
|
|
dc->ttl[dc->n_ttl++] = t = tcg_temp_new();
|
|
|
|
return t;
|
|
|
|
}
|
|
|
|
|
2011-10-15 02:03:25 +04:00
|
|
|
static inline void gen_update_fprs_dirty(int rd)
|
|
|
|
{
|
|
|
|
#if defined(TARGET_SPARC64)
|
|
|
|
tcg_gen_ori_i32(cpu_fprs, cpu_fprs, (rd < 32) ? 1 : 2);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2008-03-21 20:53:56 +03:00
|
|
|
/* floating point registers moves */
|
2011-10-15 01:58:32 +04:00
|
|
|
static TCGv_i32 gen_load_fpr_F(DisasContext *dc, unsigned int src)
|
|
|
|
{
|
2011-10-17 21:42:49 +04:00
|
|
|
#if TCG_TARGET_REG_BITS == 32
|
|
|
|
if (src & 1) {
|
|
|
|
return TCGV_LOW(cpu_fpr[src / 2]);
|
|
|
|
} else {
|
|
|
|
return TCGV_HIGH(cpu_fpr[src / 2]);
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
if (src & 1) {
|
|
|
|
return MAKE_TCGV_I32(GET_TCGV_I64(cpu_fpr[src / 2]));
|
|
|
|
} else {
|
2012-10-16 13:32:20 +04:00
|
|
|
TCGv_i32 ret = get_temp_i32(dc);
|
2011-10-17 21:42:49 +04:00
|
|
|
TCGv_i64 t = tcg_temp_new_i64();
|
|
|
|
|
|
|
|
tcg_gen_shri_i64(t, cpu_fpr[src / 2], 32);
|
2015-07-24 21:49:53 +03:00
|
|
|
tcg_gen_extrl_i64_i32(ret, t);
|
2011-10-17 21:42:49 +04:00
|
|
|
tcg_temp_free_i64(t);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
#endif
|
2011-10-15 01:58:32 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void gen_store_fpr_F(DisasContext *dc, unsigned int dst, TCGv_i32 v)
|
|
|
|
{
|
2011-10-17 21:42:49 +04:00
|
|
|
#if TCG_TARGET_REG_BITS == 32
|
|
|
|
if (dst & 1) {
|
|
|
|
tcg_gen_mov_i32(TCGV_LOW(cpu_fpr[dst / 2]), v);
|
|
|
|
} else {
|
|
|
|
tcg_gen_mov_i32(TCGV_HIGH(cpu_fpr[dst / 2]), v);
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
TCGv_i64 t = MAKE_TCGV_I64(GET_TCGV_I32(v));
|
|
|
|
tcg_gen_deposit_i64(cpu_fpr[dst / 2], cpu_fpr[dst / 2], t,
|
|
|
|
(dst & 1 ? 0 : 32), 32);
|
|
|
|
#endif
|
2011-10-15 02:03:25 +04:00
|
|
|
gen_update_fprs_dirty(dst);
|
2011-10-15 01:58:32 +04:00
|
|
|
}
|
|
|
|
|
2012-10-16 13:32:21 +04:00
|
|
|
static TCGv_i32 gen_dest_fpr_F(DisasContext *dc)
|
2011-10-15 01:58:32 +04:00
|
|
|
{
|
2012-10-16 13:32:21 +04:00
|
|
|
return get_temp_i32(dc);
|
2011-10-15 01:58:32 +04:00
|
|
|
}
|
|
|
|
|
2011-10-15 02:47:35 +04:00
|
|
|
static TCGv_i64 gen_load_fpr_D(DisasContext *dc, unsigned int src)
|
|
|
|
{
|
|
|
|
src = DFPREG(src);
|
2011-10-17 21:42:49 +04:00
|
|
|
return cpu_fpr[src / 2];
|
2011-10-15 02:47:35 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void gen_store_fpr_D(DisasContext *dc, unsigned int dst, TCGv_i64 v)
|
|
|
|
{
|
|
|
|
dst = DFPREG(dst);
|
2011-10-17 21:42:49 +04:00
|
|
|
tcg_gen_mov_i64(cpu_fpr[dst / 2], v);
|
2011-10-15 02:47:35 +04:00
|
|
|
gen_update_fprs_dirty(dst);
|
|
|
|
}
|
|
|
|
|
2012-10-16 13:32:26 +04:00
|
|
|
static TCGv_i64 gen_dest_fpr_D(DisasContext *dc, unsigned int dst)
|
2011-10-15 02:47:35 +04:00
|
|
|
{
|
2012-10-16 13:32:26 +04:00
|
|
|
return cpu_fpr[DFPREG(dst) / 2];
|
2011-10-15 02:47:35 +04:00
|
|
|
}
|
|
|
|
|
2008-03-21 20:53:56 +03:00
|
|
|
static void gen_op_load_fpr_QT0(unsigned int src)
|
|
|
|
{
|
2011-10-17 21:42:49 +04: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 20:53:56 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static void gen_op_load_fpr_QT1(unsigned int src)
|
|
|
|
{
|
2011-10-17 21:42:49 +04: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 20:53:56 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static void gen_op_store_QT0_fpr(unsigned int dst)
|
|
|
|
{
|
2011-10-17 21:42:49 +04: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 20:53:56 +03:00
|
|
|
}
|
2007-11-25 21:40:20 +03:00
|
|
|
|
2011-10-15 23:00:08 +04:00
|
|
|
#ifdef TARGET_SPARC64
|
2011-10-17 21:42:49 +04:00
|
|
|
static void gen_move_Q(unsigned int rd, unsigned int rs)
|
2011-10-15 23:00:08 +04:00
|
|
|
{
|
|
|
|
rd = QFPREG(rd);
|
|
|
|
rs = QFPREG(rs);
|
|
|
|
|
2011-10-17 21:42:49 +04: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]);
|
2011-10-15 23:00:08 +04:00
|
|
|
gen_update_fprs_dirty(rd);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2007-09-21 23:10:53 +04:00
|
|
|
/* moves */
|
|
|
|
#ifdef CONFIG_USER_ONLY
|
2005-07-02 18:31:34 +04:00
|
|
|
#define supervisor(dc) 0
|
2007-09-21 23:10:53 +04:00
|
|
|
#ifdef TARGET_SPARC64
|
2007-04-22 23:14:52 +04:00
|
|
|
#define hypervisor(dc) 0
|
2007-09-21 23:10:53 +04:00
|
|
|
#endif
|
2005-07-02 18:31:34 +04:00
|
|
|
#else
|
2010-05-22 14:52:24 +04:00
|
|
|
#define supervisor(dc) (dc->mem_idx >= MMU_KERNEL_IDX)
|
2007-09-21 23:10:53 +04:00
|
|
|
#ifdef TARGET_SPARC64
|
2010-05-22 14:52:24 +04:00
|
|
|
#define hypervisor(dc) (dc->mem_idx == MMU_HYPV_IDX)
|
2007-10-14 21:07:21 +04:00
|
|
|
#else
|
2005-07-02 18:31:34 +04:00
|
|
|
#endif
|
2007-09-21 23:10:53 +04:00
|
|
|
#endif
|
|
|
|
|
2008-07-17 16:53:05 +04:00
|
|
|
#ifdef TARGET_SPARC64
|
|
|
|
#ifndef TARGET_ABI32
|
|
|
|
#define AM_CHECK(dc) ((dc)->address_mask_32bit)
|
2008-02-24 17:10:06 +03:00
|
|
|
#else
|
2008-07-17 16:53:05 +04:00
|
|
|
#define AM_CHECK(dc) (1)
|
|
|
|
#endif
|
2008-02-24 17:10:06 +03:00
|
|
|
#endif
|
2007-09-30 23:38:12 +04:00
|
|
|
|
2008-07-17 16:53:05 +04: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 13:32:12 +04:00
|
|
|
static inline TCGv gen_load_gpr(DisasContext *dc, int reg)
|
|
|
|
{
|
|
|
|
if (reg == 0 || reg >= 8) {
|
|
|
|
TCGv t = get_temp_tl(dc);
|
|
|
|
if (reg == 0) {
|
|
|
|
tcg_gen_movi_tl(t, 0);
|
|
|
|
} else {
|
|
|
|
tcg_gen_ld_tl(t, cpu_regwptr, (reg - 8) * sizeof(target_ulong));
|
|
|
|
}
|
|
|
|
return t;
|
|
|
|
} else {
|
|
|
|
return cpu_gregs[reg];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void gen_store_gpr(DisasContext *dc, int reg, TCGv v)
|
|
|
|
{
|
|
|
|
if (reg > 0) {
|
|
|
|
if (reg < 8) {
|
|
|
|
tcg_gen_mov_tl(cpu_gregs[reg], v);
|
|
|
|
} else {
|
|
|
|
tcg_gen_st_tl(v, cpu_regwptr, (reg - 8) * sizeof(target_ulong));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline TCGv gen_dest_gpr(DisasContext *dc, int reg)
|
|
|
|
{
|
|
|
|
if (reg == 0 || reg >= 8) {
|
|
|
|
return get_temp_tl(dc);
|
|
|
|
} else {
|
|
|
|
return cpu_gregs[reg];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-09-17 01:08:06 +04:00
|
|
|
static inline void gen_goto_tb(DisasContext *s, int tb_num,
|
2005-11-20 13:32:05 +03:00
|
|
|
target_ulong pc, target_ulong npc)
|
|
|
|
{
|
|
|
|
TranslationBlock *tb;
|
|
|
|
|
|
|
|
tb = s->tb;
|
|
|
|
if ((pc & TARGET_PAGE_MASK) == (tb->pc & TARGET_PAGE_MASK) &&
|
2010-04-26 21:17:24 +04:00
|
|
|
(npc & TARGET_PAGE_MASK) == (tb->pc & TARGET_PAGE_MASK) &&
|
|
|
|
!s->singlestep) {
|
2005-11-20 13:32:05 +03:00
|
|
|
/* jump to same page: we can use a direct jump */
|
2008-02-01 13:50:11 +03:00
|
|
|
tcg_gen_goto_tb(tb_num);
|
2008-03-26 23:45:06 +03:00
|
|
|
tcg_gen_movi_tl(cpu_pc, pc);
|
|
|
|
tcg_gen_movi_tl(cpu_npc, npc);
|
2013-08-21 02:53:10 +04:00
|
|
|
tcg_gen_exit_tb((uintptr_t)tb + tb_num);
|
2005-11-20 13:32:05 +03:00
|
|
|
} else {
|
|
|
|
/* jump to another page: currently not optimized */
|
2008-03-26 23:45:06 +03:00
|
|
|
tcg_gen_movi_tl(cpu_pc, pc);
|
|
|
|
tcg_gen_movi_tl(cpu_npc, npc);
|
2008-02-01 13:50:11 +03:00
|
|
|
tcg_gen_exit_tb(0);
|
2005-11-20 13:32:05 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-03-09 00:36:50 +03:00
|
|
|
// XXX suboptimal
|
2008-11-17 17:43:54 +03:00
|
|
|
static inline void gen_mov_reg_N(TCGv reg, TCGv_i32 src)
|
2008-03-09 00:36:50 +03:00
|
|
|
{
|
2008-03-22 11:40:28 +03:00
|
|
|
tcg_gen_extu_i32_tl(reg, src);
|
2008-04-23 21:12:35 +04:00
|
|
|
tcg_gen_shri_tl(reg, reg, PSR_NEG_SHIFT);
|
2008-03-09 00:36:50 +03:00
|
|
|
tcg_gen_andi_tl(reg, reg, 0x1);
|
|
|
|
}
|
|
|
|
|
2008-11-17 17:43:54 +03:00
|
|
|
static inline void gen_mov_reg_Z(TCGv reg, TCGv_i32 src)
|
2008-03-09 00:36:50 +03:00
|
|
|
{
|
2008-03-22 11:40:28 +03:00
|
|
|
tcg_gen_extu_i32_tl(reg, src);
|
2008-04-23 21:12:35 +04:00
|
|
|
tcg_gen_shri_tl(reg, reg, PSR_ZERO_SHIFT);
|
2008-03-09 00:36:50 +03:00
|
|
|
tcg_gen_andi_tl(reg, reg, 0x1);
|
|
|
|
}
|
|
|
|
|
2008-11-17 17:43:54 +03:00
|
|
|
static inline void gen_mov_reg_V(TCGv reg, TCGv_i32 src)
|
2008-03-09 00:36:50 +03:00
|
|
|
{
|
2008-03-22 11:40:28 +03:00
|
|
|
tcg_gen_extu_i32_tl(reg, src);
|
2008-04-23 21:12:35 +04:00
|
|
|
tcg_gen_shri_tl(reg, reg, PSR_OVF_SHIFT);
|
2008-03-09 00:36:50 +03:00
|
|
|
tcg_gen_andi_tl(reg, reg, 0x1);
|
|
|
|
}
|
|
|
|
|
2008-11-17 17:43:54 +03:00
|
|
|
static inline void gen_mov_reg_C(TCGv reg, TCGv_i32 src)
|
2008-03-09 00:36:50 +03:00
|
|
|
{
|
2008-03-22 11:40:28 +03:00
|
|
|
tcg_gen_extu_i32_tl(reg, src);
|
2008-04-23 21:12:35 +04:00
|
|
|
tcg_gen_shri_tl(reg, reg, PSR_CARRY_SHIFT);
|
2008-03-09 00:36:50 +03:00
|
|
|
tcg_gen_andi_tl(reg, reg, 0x1);
|
|
|
|
}
|
|
|
|
|
2008-03-26 23:47:52 +03:00
|
|
|
static inline void gen_op_add_cc(TCGv dst, TCGv src1, TCGv src2)
|
2008-03-13 23:45:31 +03:00
|
|
|
{
|
2008-03-26 23:47:52 +03:00
|
|
|
tcg_gen_mov_tl(cpu_cc_src, src1);
|
2008-05-04 00:51:00 +04:00
|
|
|
tcg_gen_mov_tl(cpu_cc_src2, src2);
|
2008-06-21 23:46:48 +04:00
|
|
|
tcg_gen_add_tl(cpu_cc_dst, cpu_cc_src, cpu_cc_src2);
|
2009-05-10 11:19:17 +04:00
|
|
|
tcg_gen_mov_tl(dst, cpu_cc_dst);
|
2009-05-02 23:14:05 +04:00
|
|
|
}
|
|
|
|
|
2010-05-12 22:04:27 +04:00
|
|
|
static TCGv_i32 gen_add32_carry32(void)
|
2008-03-13 23:45:31 +03:00
|
|
|
{
|
2010-05-12 22:04:27 +04: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 21:49:53 +03: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 22:04:27 +04: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);
|
|
|
|
|
|
|
|
#if TARGET_LONG_BITS == 64
|
|
|
|
tcg_temp_free_i32(cc_src1_32);
|
|
|
|
tcg_temp_free_i32(cc_src2_32);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
return carry_32;
|
2009-05-02 23:14:05 +04:00
|
|
|
}
|
|
|
|
|
2010-05-12 22:04:27 +04:00
|
|
|
static TCGv_i32 gen_sub32_carry32(void)
|
2009-05-02 23:14:05 +04:00
|
|
|
{
|
2010-05-12 22:04:27 +04: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 21:49:53 +03: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 22:04:27 +04: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);
|
|
|
|
|
|
|
|
#if TARGET_LONG_BITS == 64
|
|
|
|
tcg_temp_free_i32(cc_src1_32);
|
|
|
|
tcg_temp_free_i32(cc_src2_32);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
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 11:52:21 +04: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);
|
|
|
|
tcg_temp_free(carry);
|
2010-05-12 22:04:27 +04: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 20:01:57 +04:00
|
|
|
gen_helper_compute_C_icc(carry_32, cpu_env);
|
2010-05-12 22:04:27 +04: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);
|
|
|
|
|
|
|
|
tcg_temp_free_i32(carry_32);
|
|
|
|
#if TARGET_LONG_BITS == 64
|
|
|
|
tcg_temp_free(carry);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
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 23:45:31 +03:00
|
|
|
}
|
|
|
|
|
2009-05-02 23:14:05 +04:00
|
|
|
static inline void gen_op_sub_cc(TCGv dst, TCGv src1, TCGv src2)
|
2008-03-13 23:45:31 +03:00
|
|
|
{
|
2008-03-26 23:47:52 +03:00
|
|
|
tcg_gen_mov_tl(cpu_cc_src, src1);
|
2008-05-04 00:51:00 +04:00
|
|
|
tcg_gen_mov_tl(cpu_cc_src2, src2);
|
2009-05-02 23:14:05 +04:00
|
|
|
tcg_gen_sub_tl(cpu_cc_dst, cpu_cc_src, cpu_cc_src2);
|
2009-05-10 11:38:34 +04:00
|
|
|
tcg_gen_mov_tl(dst, cpu_cc_dst);
|
2009-05-02 23:14:05 +04:00
|
|
|
}
|
|
|
|
|
2010-05-12 22:04:27 +04:00
|
|
|
static void gen_op_subx_int(DisasContext *dc, TCGv dst, TCGv src1,
|
|
|
|
TCGv src2, int update_cc)
|
2009-05-02 23:14:05 +04:00
|
|
|
{
|
2010-05-12 22:04:27 +04:00
|
|
|
TCGv_i32 carry_32;
|
|
|
|
TCGv carry;
|
2009-05-02 23:14:05 +04:00
|
|
|
|
2010-05-12 22:04:27 +04: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 11:52:21 +04: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);
|
|
|
|
tcg_temp_free(carry);
|
2010-05-12 22:04:27 +04: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 20:01:57 +04:00
|
|
|
gen_helper_compute_C_icc(carry_32, cpu_env);
|
2010-05-12 22:04:27 +04: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);
|
|
|
|
|
|
|
|
tcg_temp_free_i32(carry_32);
|
|
|
|
#if TARGET_LONG_BITS == 64
|
|
|
|
tcg_temp_free(carry);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
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 23:45:31 +03:00
|
|
|
}
|
|
|
|
|
2008-03-26 23:47:52 +03:00
|
|
|
static inline void gen_op_mulscc(TCGv dst, TCGv src1, TCGv src2)
|
2008-03-16 22:22:18 +03:00
|
|
|
{
|
2012-10-16 13:32:31 +04:00
|
|
|
TCGv r_temp, zero, t0;
|
2008-03-16 22:22:18 +03:00
|
|
|
|
2008-11-17 17:43:54 +03:00
|
|
|
r_temp = tcg_temp_new();
|
2012-10-16 13:32:31 +04:00
|
|
|
t0 = tcg_temp_new();
|
2008-03-16 22:22:18 +03:00
|
|
|
|
|
|
|
/* old op:
|
|
|
|
if (!(env->y & 1))
|
|
|
|
T1 = 0;
|
|
|
|
*/
|
2012-10-06 03:55:06 +04:00
|
|
|
zero = tcg_const_tl(0);
|
2008-09-13 21:20:52 +04:00
|
|
|
tcg_gen_andi_tl(cpu_cc_src, src1, 0xffffffff);
|
2008-09-06 21:51:43 +04:00
|
|
|
tcg_gen_andi_tl(r_temp, cpu_y, 0x1);
|
2008-09-13 21:20:52 +04:00
|
|
|
tcg_gen_andi_tl(cpu_cc_src2, src2, 0xffffffff);
|
2012-10-06 03:55:06 +04:00
|
|
|
tcg_gen_movcond_tl(TCG_COND_EQ, cpu_cc_src2, r_temp, zero,
|
|
|
|
zero, cpu_cc_src2);
|
|
|
|
tcg_temp_free(zero);
|
2008-03-16 22:22:18 +03:00
|
|
|
|
|
|
|
// b2 = T0 & 1;
|
|
|
|
// env->y = (b2 << 31) | (env->y >> 1);
|
2008-09-01 23:35:29 +04:00
|
|
|
tcg_gen_andi_tl(r_temp, cpu_cc_src, 0x1);
|
|
|
|
tcg_gen_shli_tl(r_temp, r_temp, 31);
|
2012-10-16 13:32:31 +04:00
|
|
|
tcg_gen_shri_tl(t0, cpu_y, 1);
|
|
|
|
tcg_gen_andi_tl(t0, t0, 0x7fffffff);
|
|
|
|
tcg_gen_or_tl(t0, t0, r_temp);
|
|
|
|
tcg_gen_andi_tl(cpu_y, t0, 0xffffffff);
|
2008-03-16 22:22:18 +03:00
|
|
|
|
|
|
|
// b1 = N ^ V;
|
2012-10-16 13:32:31 +04:00
|
|
|
gen_mov_reg_N(t0, cpu_psr);
|
2008-03-16 22:22:18 +03:00
|
|
|
gen_mov_reg_V(r_temp, cpu_psr);
|
2012-10-16 13:32:31 +04:00
|
|
|
tcg_gen_xor_tl(t0, t0, r_temp);
|
2008-05-27 23:39:12 +04:00
|
|
|
tcg_temp_free(r_temp);
|
2008-03-16 22:22:18 +03:00
|
|
|
|
|
|
|
// T0 = (b1 << 31) | (T0 >> 1);
|
|
|
|
// src1 = T0;
|
2012-10-16 13:32:31 +04:00
|
|
|
tcg_gen_shli_tl(t0, t0, 31);
|
2008-05-04 00:51:00 +04:00
|
|
|
tcg_gen_shri_tl(cpu_cc_src, cpu_cc_src, 1);
|
2012-10-16 13:32:31 +04:00
|
|
|
tcg_gen_or_tl(cpu_cc_src, cpu_cc_src, t0);
|
|
|
|
tcg_temp_free(t0);
|
2008-03-16 22:22:18 +03:00
|
|
|
|
2008-06-21 23:46:48 +04:00
|
|
|
tcg_gen_add_tl(cpu_cc_dst, cpu_cc_src, cpu_cc_src2);
|
2008-03-16 22:22:18 +03:00
|
|
|
|
2008-06-21 23:46:48 +04:00
|
|
|
tcg_gen_mov_tl(dst, cpu_cc_dst);
|
2008-03-16 22:22:18 +03:00
|
|
|
}
|
|
|
|
|
2010-06-02 00:12:58 +04:00
|
|
|
static inline void gen_op_multiply(TCGv dst, TCGv src1, TCGv src2, int sign_ext)
|
2008-03-16 22:24:42 +03:00
|
|
|
{
|
2013-02-20 11:52:22 +04:00
|
|
|
#if TARGET_LONG_BITS == 32
|
2010-06-02 00:12:58 +04:00
|
|
|
if (sign_ext) {
|
2013-02-20 11:52:22 +04:00
|
|
|
tcg_gen_muls2_tl(dst, cpu_y, src1, src2);
|
2010-06-02 00:12:58 +04:00
|
|
|
} else {
|
2013-02-20 11:52:22 +04:00
|
|
|
tcg_gen_mulu2_tl(dst, cpu_y, src1, src2);
|
2010-06-02 00:12:58 +04:00
|
|
|
}
|
2013-02-20 11:52:22 +04:00
|
|
|
#else
|
|
|
|
TCGv t0 = tcg_temp_new_i64();
|
|
|
|
TCGv t1 = tcg_temp_new_i64();
|
2010-06-02 00:12:58 +04:00
|
|
|
|
2013-02-20 11:52:22 +04: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-02 00:12:58 +04:00
|
|
|
|
2013-02-20 11:52:22 +04:00
|
|
|
tcg_gen_mul_i64(dst, t0, t1);
|
|
|
|
tcg_temp_free(t0);
|
|
|
|
tcg_temp_free(t1);
|
2010-06-02 00:12:58 +04:00
|
|
|
|
2013-02-20 11:52:22 +04:00
|
|
|
tcg_gen_shri_i64(cpu_y, dst, 32);
|
|
|
|
#endif
|
2008-03-16 22:24:42 +03:00
|
|
|
}
|
|
|
|
|
2010-06-02 00:12:58 +04:00
|
|
|
static inline void gen_op_umul(TCGv dst, TCGv src1, TCGv src2)
|
2008-03-16 22:24:42 +03:00
|
|
|
{
|
2010-06-02 00:12:58 +04:00
|
|
|
/* zero-extend truncated operands before multiplication */
|
|
|
|
gen_op_multiply(dst, src1, src2, 0);
|
|
|
|
}
|
2008-03-16 22:24:42 +03:00
|
|
|
|
2010-06-02 00:12:58 +04: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 22:24:42 +03:00
|
|
|
}
|
|
|
|
|
2008-03-09 00:36:50 +03:00
|
|
|
// 1
|
|
|
|
static inline void gen_op_eval_ba(TCGv dst)
|
|
|
|
{
|
|
|
|
tcg_gen_movi_tl(dst, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Z
|
2008-11-17 17:43:54 +03:00
|
|
|
static inline void gen_op_eval_be(TCGv dst, TCGv_i32 src)
|
2008-03-09 00:36:50 +03:00
|
|
|
{
|
|
|
|
gen_mov_reg_Z(dst, src);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Z | (N ^ V)
|
2008-11-17 17:43:54 +03:00
|
|
|
static inline void gen_op_eval_ble(TCGv dst, TCGv_i32 src)
|
2008-03-09 00:36:50 +03:00
|
|
|
{
|
2012-10-16 13:32:31 +04:00
|
|
|
TCGv t0 = tcg_temp_new();
|
|
|
|
gen_mov_reg_N(t0, src);
|
2008-03-09 00:36:50 +03:00
|
|
|
gen_mov_reg_V(dst, src);
|
2012-10-16 13:32:31 +04:00
|
|
|
tcg_gen_xor_tl(dst, dst, t0);
|
|
|
|
gen_mov_reg_Z(t0, src);
|
|
|
|
tcg_gen_or_tl(dst, dst, t0);
|
|
|
|
tcg_temp_free(t0);
|
2008-03-09 00:36:50 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// N ^ V
|
2008-11-17 17:43:54 +03:00
|
|
|
static inline void gen_op_eval_bl(TCGv dst, TCGv_i32 src)
|
2008-03-09 00:36:50 +03:00
|
|
|
{
|
2012-10-16 13:32:31 +04:00
|
|
|
TCGv t0 = tcg_temp_new();
|
|
|
|
gen_mov_reg_V(t0, src);
|
2008-03-09 00:36:50 +03:00
|
|
|
gen_mov_reg_N(dst, src);
|
2012-10-16 13:32:31 +04:00
|
|
|
tcg_gen_xor_tl(dst, dst, t0);
|
|
|
|
tcg_temp_free(t0);
|
2008-03-09 00:36:50 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// C | Z
|
2008-11-17 17:43:54 +03:00
|
|
|
static inline void gen_op_eval_bleu(TCGv dst, TCGv_i32 src)
|
2008-03-09 00:36:50 +03:00
|
|
|
{
|
2012-10-16 13:32:31 +04:00
|
|
|
TCGv t0 = tcg_temp_new();
|
|
|
|
gen_mov_reg_Z(t0, src);
|
2008-03-09 00:36:50 +03:00
|
|
|
gen_mov_reg_C(dst, src);
|
2012-10-16 13:32:31 +04:00
|
|
|
tcg_gen_or_tl(dst, dst, t0);
|
|
|
|
tcg_temp_free(t0);
|
2008-03-09 00:36:50 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// C
|
2008-11-17 17:43:54 +03:00
|
|
|
static inline void gen_op_eval_bcs(TCGv dst, TCGv_i32 src)
|
2008-03-09 00:36:50 +03:00
|
|
|
{
|
|
|
|
gen_mov_reg_C(dst, src);
|
|
|
|
}
|
|
|
|
|
|
|
|
// V
|
2008-11-17 17:43:54 +03:00
|
|
|
static inline void gen_op_eval_bvs(TCGv dst, TCGv_i32 src)
|
2008-03-09 00:36:50 +03: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 17:43:54 +03:00
|
|
|
static inline void gen_op_eval_bneg(TCGv dst, TCGv_i32 src)
|
2008-03-09 00:36:50 +03:00
|
|
|
{
|
|
|
|
gen_mov_reg_N(dst, src);
|
|
|
|
}
|
|
|
|
|
|
|
|
// !Z
|
2008-11-17 17:43:54 +03:00
|
|
|
static inline void gen_op_eval_bne(TCGv dst, TCGv_i32 src)
|
2008-03-09 00:36:50 +03:00
|
|
|
{
|
|
|
|
gen_mov_reg_Z(dst, src);
|
|
|
|
tcg_gen_xori_tl(dst, dst, 0x1);
|
|
|
|
}
|
|
|
|
|
|
|
|
// !(Z | (N ^ V))
|
2008-11-17 17:43:54 +03:00
|
|
|
static inline void gen_op_eval_bg(TCGv dst, TCGv_i32 src)
|
2008-03-09 00:36:50 +03:00
|
|
|
{
|
2012-10-16 13:32:31 +04:00
|
|
|
gen_op_eval_ble(dst, src);
|
2008-03-09 00:36:50 +03:00
|
|
|
tcg_gen_xori_tl(dst, dst, 0x1);
|
|
|
|
}
|
|
|
|
|
|
|
|
// !(N ^ V)
|
2008-11-17 17:43:54 +03:00
|
|
|
static inline void gen_op_eval_bge(TCGv dst, TCGv_i32 src)
|
2008-03-09 00:36:50 +03:00
|
|
|
{
|
2012-10-16 13:32:31 +04:00
|
|
|
gen_op_eval_bl(dst, src);
|
2008-03-09 00:36:50 +03:00
|
|
|
tcg_gen_xori_tl(dst, dst, 0x1);
|
|
|
|
}
|
|
|
|
|
|
|
|
// !(C | Z)
|
2008-11-17 17:43:54 +03:00
|
|
|
static inline void gen_op_eval_bgu(TCGv dst, TCGv_i32 src)
|
2008-03-09 00:36:50 +03:00
|
|
|
{
|
2012-10-16 13:32:31 +04:00
|
|
|
gen_op_eval_bleu(dst, src);
|
2008-03-09 00:36:50 +03:00
|
|
|
tcg_gen_xori_tl(dst, dst, 0x1);
|
|
|
|
}
|
|
|
|
|
|
|
|
// !C
|
2008-11-17 17:43:54 +03:00
|
|
|
static inline void gen_op_eval_bcc(TCGv dst, TCGv_i32 src)
|
2008-03-09 00:36:50 +03:00
|
|
|
{
|
|
|
|
gen_mov_reg_C(dst, src);
|
|
|
|
tcg_gen_xori_tl(dst, dst, 0x1);
|
|
|
|
}
|
|
|
|
|
|
|
|
// !N
|
2008-11-17 17:43:54 +03:00
|
|
|
static inline void gen_op_eval_bpos(TCGv dst, TCGv_i32 src)
|
2008-03-09 00:36:50 +03:00
|
|
|
{
|
|
|
|
gen_mov_reg_N(dst, src);
|
|
|
|
tcg_gen_xori_tl(dst, dst, 0x1);
|
|
|
|
}
|
|
|
|
|
|
|
|
// !V
|
2008-11-17 17:43:54 +03:00
|
|
|
static inline void gen_op_eval_bvc(TCGv dst, TCGv_i32 src)
|
2008-03-09 00:36:50 +03: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-30 01:03:31 +04:00
|
|
|
tcg_gen_shri_tl(reg, src, FSR_FCC0_SHIFT + fcc_offset);
|
2008-03-09 00:36:50 +03: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-30 01:03:31 +04:00
|
|
|
tcg_gen_shri_tl(reg, src, FSR_FCC1_SHIFT + fcc_offset);
|
2008-03-09 00:36:50 +03: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 13:32:31 +04:00
|
|
|
TCGv t0 = tcg_temp_new();
|
2008-03-09 00:36:50 +03:00
|
|
|
gen_mov_reg_FCC0(dst, src, fcc_offset);
|
2012-10-16 13:32:31 +04:00
|
|
|
gen_mov_reg_FCC1(t0, src, fcc_offset);
|
|
|
|
tcg_gen_or_tl(dst, dst, t0);
|
|
|
|
tcg_temp_free(t0);
|
2008-03-09 00:36:50 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// 1 or 2: FCC0 ^ FCC1
|
|
|
|
static inline void gen_op_eval_fblg(TCGv dst, TCGv src,
|
|
|
|
unsigned int fcc_offset)
|
|
|
|
{
|
2012-10-16 13:32:31 +04:00
|
|
|
TCGv t0 = tcg_temp_new();
|
2008-03-09 00:36:50 +03:00
|
|
|
gen_mov_reg_FCC0(dst, src, fcc_offset);
|
2012-10-16 13:32:31 +04:00
|
|
|
gen_mov_reg_FCC1(t0, src, fcc_offset);
|
|
|
|
tcg_gen_xor_tl(dst, dst, t0);
|
|
|
|
tcg_temp_free(t0);
|
2008-03-09 00:36:50 +03: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 13:32:31 +04:00
|
|
|
TCGv t0 = tcg_temp_new();
|
2008-03-09 00:36:50 +03:00
|
|
|
gen_mov_reg_FCC0(dst, src, fcc_offset);
|
2012-10-16 13:32:31 +04:00
|
|
|
gen_mov_reg_FCC1(t0, src, fcc_offset);
|
|
|
|
tcg_gen_andc_tl(dst, dst, t0);
|
|
|
|
tcg_temp_free(t0);
|
2008-03-09 00:36:50 +03: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 13:32:31 +04:00
|
|
|
TCGv t0 = tcg_temp_new();
|
2008-03-09 00:36:50 +03:00
|
|
|
gen_mov_reg_FCC0(dst, src, fcc_offset);
|
2012-10-16 13:32:31 +04:00
|
|
|
gen_mov_reg_FCC1(t0, src, fcc_offset);
|
|
|
|
tcg_gen_andc_tl(dst, t0, dst);
|
|
|
|
tcg_temp_free(t0);
|
2008-03-09 00:36:50 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// 3: FCC0 & FCC1
|
|
|
|
static inline void gen_op_eval_fbu(TCGv dst, TCGv src,
|
|
|
|
unsigned int fcc_offset)
|
|
|
|
{
|
2012-10-16 13:32:31 +04:00
|
|
|
TCGv t0 = tcg_temp_new();
|
2008-03-09 00:36:50 +03:00
|
|
|
gen_mov_reg_FCC0(dst, src, fcc_offset);
|
2012-10-16 13:32:31 +04:00
|
|
|
gen_mov_reg_FCC1(t0, src, fcc_offset);
|
|
|
|
tcg_gen_and_tl(dst, dst, t0);
|
|
|
|
tcg_temp_free(t0);
|
2008-03-09 00:36:50 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// 0: !(FCC0 | FCC1)
|
|
|
|
static inline void gen_op_eval_fbe(TCGv dst, TCGv src,
|
|
|
|
unsigned int fcc_offset)
|
|
|
|
{
|
2012-10-16 13:32:31 +04:00
|
|
|
TCGv t0 = tcg_temp_new();
|
2008-03-09 00:36:50 +03:00
|
|
|
gen_mov_reg_FCC0(dst, src, fcc_offset);
|
2012-10-16 13:32:31 +04:00
|
|
|
gen_mov_reg_FCC1(t0, src, fcc_offset);
|
|
|
|
tcg_gen_or_tl(dst, dst, t0);
|
2008-03-09 00:36:50 +03:00
|
|
|
tcg_gen_xori_tl(dst, dst, 0x1);
|
2012-10-16 13:32:31 +04:00
|
|
|
tcg_temp_free(t0);
|
2008-03-09 00:36:50 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// 0 or 3: !(FCC0 ^ FCC1)
|
|
|
|
static inline void gen_op_eval_fbue(TCGv dst, TCGv src,
|
|
|
|
unsigned int fcc_offset)
|
|
|
|
{
|
2012-10-16 13:32:31 +04:00
|
|
|
TCGv t0 = tcg_temp_new();
|
2008-03-09 00:36:50 +03:00
|
|
|
gen_mov_reg_FCC0(dst, src, fcc_offset);
|
2012-10-16 13:32:31 +04:00
|
|
|
gen_mov_reg_FCC1(t0, src, fcc_offset);
|
|
|
|
tcg_gen_xor_tl(dst, dst, t0);
|
2008-03-09 00:36:50 +03:00
|
|
|
tcg_gen_xori_tl(dst, dst, 0x1);
|
2012-10-16 13:32:31 +04:00
|
|
|
tcg_temp_free(t0);
|
2008-03-09 00:36:50 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// 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 13:32:31 +04:00
|
|
|
TCGv t0 = tcg_temp_new();
|
2008-03-09 00:36:50 +03:00
|
|
|
gen_mov_reg_FCC0(dst, src, fcc_offset);
|
2012-10-16 13:32:31 +04:00
|
|
|
gen_mov_reg_FCC1(t0, src, fcc_offset);
|
|
|
|
tcg_gen_andc_tl(dst, dst, t0);
|
2008-03-09 00:36:50 +03:00
|
|
|
tcg_gen_xori_tl(dst, dst, 0x1);
|
2012-10-16 13:32:31 +04:00
|
|
|
tcg_temp_free(t0);
|
2008-03-09 00:36:50 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// 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 13:32:31 +04:00
|
|
|
TCGv t0 = tcg_temp_new();
|
2008-03-09 00:36:50 +03:00
|
|
|
gen_mov_reg_FCC0(dst, src, fcc_offset);
|
2012-10-16 13:32:31 +04:00
|
|
|
gen_mov_reg_FCC1(t0, src, fcc_offset);
|
|
|
|
tcg_gen_andc_tl(dst, t0, dst);
|
2008-03-09 00:36:50 +03:00
|
|
|
tcg_gen_xori_tl(dst, dst, 0x1);
|
2012-10-16 13:32:31 +04:00
|
|
|
tcg_temp_free(t0);
|
2008-03-09 00:36:50 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// !3: !(FCC0 & FCC1)
|
|
|
|
static inline void gen_op_eval_fbo(TCGv dst, TCGv src,
|
|
|
|
unsigned int fcc_offset)
|
|
|
|
{
|
2012-10-16 13:32:31 +04:00
|
|
|
TCGv t0 = tcg_temp_new();
|
2008-03-09 00:36:50 +03:00
|
|
|
gen_mov_reg_FCC0(dst, src, fcc_offset);
|
2012-10-16 13:32:31 +04:00
|
|
|
gen_mov_reg_FCC1(t0, src, fcc_offset);
|
|
|
|
tcg_gen_and_tl(dst, dst, t0);
|
2008-03-09 00:36:50 +03:00
|
|
|
tcg_gen_xori_tl(dst, dst, 0x1);
|
2012-10-16 13:32:31 +04:00
|
|
|
tcg_temp_free(t0);
|
2008-03-09 00:36:50 +03:00
|
|
|
}
|
|
|
|
|
2007-06-25 23:52:58 +04:00
|
|
|
static inline void gen_branch2(DisasContext *dc, target_ulong pc1,
|
2008-03-09 00:36:50 +03:00
|
|
|
target_ulong pc2, TCGv r_cond)
|
2005-07-23 18:27:54 +04:00
|
|
|
{
|
2015-02-13 23:51:55 +03:00
|
|
|
TCGLabel *l1 = gen_new_label();
|
2005-07-23 18:27:54 +04:00
|
|
|
|
2008-05-24 06:22:00 +04:00
|
|
|
tcg_gen_brcondi_tl(TCG_COND_EQ, r_cond, 0, l1);
|
2005-07-23 18:27:54 +04:00
|
|
|
|
2005-11-20 13:32:05 +03:00
|
|
|
gen_goto_tb(dc, 0, pc1, pc1 + 4);
|
2005-07-23 18:27:54 +04:00
|
|
|
|
|
|
|
gen_set_label(l1);
|
2005-11-20 13:32:05 +03:00
|
|
|
gen_goto_tb(dc, 1, pc2, pc2 + 4);
|
2005-07-23 18:27:54 +04:00
|
|
|
}
|
|
|
|
|
2015-08-31 22:44:16 +03:00
|
|
|
static void gen_branch_a(DisasContext *dc, target_ulong pc1)
|
2005-07-23 18:27:54 +04:00
|
|
|
{
|
2015-02-13 23:51:55 +03:00
|
|
|
TCGLabel *l1 = gen_new_label();
|
2015-08-31 22:44:16 +03:00
|
|
|
target_ulong npc = dc->npc;
|
2005-07-23 18:27:54 +04:00
|
|
|
|
2015-08-31 22:44:16 +03:00
|
|
|
tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_cond, 0, l1);
|
2005-07-23 18:27:54 +04:00
|
|
|
|
2015-08-31 22:44:16 +03:00
|
|
|
gen_goto_tb(dc, 0, npc, pc1);
|
2005-07-23 18:27:54 +04:00
|
|
|
|
|
|
|
gen_set_label(l1);
|
2015-08-31 22:44:16 +03:00
|
|
|
gen_goto_tb(dc, 1, npc + 4, npc + 8);
|
|
|
|
|
|
|
|
dc->is_br = 1;
|
2005-07-23 18:27:54 +04:00
|
|
|
}
|
|
|
|
|
2015-08-31 23:01:47 +03: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);
|
|
|
|
t = tcg_const_tl(pc1);
|
|
|
|
z = tcg_const_tl(0);
|
|
|
|
tcg_gen_movcond_tl(TCG_COND_NE, cpu_npc, cpu_cond, z, t, cpu_npc);
|
|
|
|
tcg_temp_free(t);
|
|
|
|
tcg_temp_free(z);
|
|
|
|
|
|
|
|
dc->pc = DYNAMIC_PC;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-10-06 03:54:56 +04:00
|
|
|
static inline void gen_generic_branch(DisasContext *dc)
|
2005-07-23 18:27:54 +04:00
|
|
|
{
|
2012-10-06 03:55:02 +04:00
|
|
|
TCGv npc0 = tcg_const_tl(dc->jump_pc[0]);
|
|
|
|
TCGv npc1 = tcg_const_tl(dc->jump_pc[1]);
|
|
|
|
TCGv zero = tcg_const_tl(0);
|
2008-03-09 00:36:50 +03:00
|
|
|
|
2012-10-06 03:55:02 +04:00
|
|
|
tcg_gen_movcond_tl(TCG_COND_NE, cpu_npc, cpu_cond, zero, npc0, npc1);
|
2005-07-23 18:27:54 +04:00
|
|
|
|
2012-10-06 03:55:02 +04:00
|
|
|
tcg_temp_free(npc0);
|
|
|
|
tcg_temp_free(npc1);
|
|
|
|
tcg_temp_free(zero);
|
2005-07-23 18:27:54 +04:00
|
|
|
}
|
|
|
|
|
2008-03-26 23:47:52 +03:00
|
|
|
/* call this function before using the condition register as it may
|
|
|
|
have been set for a jump */
|
2012-10-06 03:54:51 +04:00
|
|
|
static inline void flush_cond(DisasContext *dc)
|
2005-07-23 18:27:54 +04:00
|
|
|
{
|
|
|
|
if (dc->npc == JUMP_PC) {
|
2012-10-06 03:54:56 +04:00
|
|
|
gen_generic_branch(dc);
|
2005-07-23 18:27:54 +04:00
|
|
|
dc->npc = DYNAMIC_PC;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-10-06 03:54:55 +04:00
|
|
|
static inline void save_npc(DisasContext *dc)
|
2004-02-16 23:30:05 +03:00
|
|
|
{
|
|
|
|
if (dc->npc == JUMP_PC) {
|
2012-10-06 03:54:56 +04:00
|
|
|
gen_generic_branch(dc);
|
2004-02-16 23:30:05 +03:00
|
|
|
dc->npc = DYNAMIC_PC;
|
|
|
|
} else if (dc->npc != DYNAMIC_PC) {
|
2008-03-26 23:45:06 +03:00
|
|
|
tcg_gen_movi_tl(cpu_npc, dc->npc);
|
2004-02-16 23:30:05 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-10-10 01:50:00 +04:00
|
|
|
static inline void update_psr(DisasContext *dc)
|
2004-02-16 23:30:05 +03:00
|
|
|
{
|
2009-08-15 20:52:54 +04:00
|
|
|
if (dc->cc_op != CC_OP_FLAGS) {
|
|
|
|
dc->cc_op = CC_OP_FLAGS;
|
2011-07-03 20:01:57 +04:00
|
|
|
gen_helper_compute_psr(cpu_env);
|
2009-08-15 20:52:54 +04:00
|
|
|
}
|
2012-10-10 01:50:00 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline void save_state(DisasContext *dc)
|
|
|
|
{
|
|
|
|
tcg_gen_movi_tl(cpu_pc, dc->pc);
|
2012-10-06 03:54:55 +04:00
|
|
|
save_npc(dc);
|
2004-02-16 23:30:05 +03:00
|
|
|
}
|
|
|
|
|
2012-10-06 03:54:54 +04:00
|
|
|
static inline void gen_mov_pc_npc(DisasContext *dc)
|
2005-02-13 23:11:30 +03:00
|
|
|
{
|
|
|
|
if (dc->npc == JUMP_PC) {
|
2012-10-06 03:54:56 +04:00
|
|
|
gen_generic_branch(dc);
|
2008-03-16 22:23:31 +03:00
|
|
|
tcg_gen_mov_tl(cpu_pc, cpu_npc);
|
2005-02-13 23:11:30 +03:00
|
|
|
dc->pc = DYNAMIC_PC;
|
|
|
|
} else if (dc->npc == DYNAMIC_PC) {
|
2008-03-16 22:23:31 +03:00
|
|
|
tcg_gen_mov_tl(cpu_pc, cpu_npc);
|
2005-02-13 23:11:30 +03:00
|
|
|
dc->pc = DYNAMIC_PC;
|
|
|
|
} else {
|
|
|
|
dc->pc = dc->npc;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-03-02 21:22:19 +03:00
|
|
|
static inline void gen_op_next_insn(void)
|
|
|
|
{
|
2008-03-16 22:23:31 +03:00
|
|
|
tcg_gen_mov_tl(cpu_pc, cpu_npc);
|
|
|
|
tcg_gen_addi_tl(cpu_npc, cpu_npc, 4);
|
2008-03-02 21:22:19 +03:00
|
|
|
}
|
|
|
|
|
2012-10-06 03:54:57 +04:00
|
|
|
static void free_compare(DisasCompare *cmp)
|
|
|
|
{
|
|
|
|
if (!cmp->g1) {
|
|
|
|
tcg_temp_free(cmp->c1);
|
|
|
|
}
|
|
|
|
if (!cmp->g2) {
|
|
|
|
tcg_temp_free(cmp->c2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-10-06 03:55:10 +04:00
|
|
|
static void gen_compare(DisasCompare *cmp, bool xcc, unsigned int cond,
|
2012-10-06 03:54:57 +04:00
|
|
|
DisasContext *dc)
|
2008-03-09 00:36:50 +03:00
|
|
|
{
|
2012-10-06 03:55:10 +04:00
|
|
|
static int subcc_cond[16] = {
|
2012-10-10 01:49:58 +04:00
|
|
|
TCG_COND_NEVER,
|
2012-10-06 03:55:10 +04:00
|
|
|
TCG_COND_EQ,
|
|
|
|
TCG_COND_LE,
|
|
|
|
TCG_COND_LT,
|
|
|
|
TCG_COND_LEU,
|
|
|
|
TCG_COND_LTU,
|
|
|
|
-1, /* neg */
|
|
|
|
-1, /* overflow */
|
2012-10-10 01:49:58 +04:00
|
|
|
TCG_COND_ALWAYS,
|
2012-10-06 03:55:10 +04:00
|
|
|
TCG_COND_NE,
|
|
|
|
TCG_COND_GT,
|
|
|
|
TCG_COND_GE,
|
|
|
|
TCG_COND_GTU,
|
|
|
|
TCG_COND_GEU,
|
|
|
|
-1, /* pos */
|
|
|
|
-1, /* no overflow */
|
|
|
|
};
|
|
|
|
|
2012-10-10 01:49:58 +04: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 17:43:54 +03:00
|
|
|
TCGv_i32 r_src;
|
2012-10-06 03:54:57 +04:00
|
|
|
TCGv r_dst;
|
|
|
|
|
2005-07-02 18:31:34 +04:00
|
|
|
#ifdef TARGET_SPARC64
|
2012-10-06 03:55:10 +04:00
|
|
|
if (xcc) {
|
2008-03-13 23:45:31 +03:00
|
|
|
r_src = cpu_xcc;
|
2012-10-06 03:55:10 +04:00
|
|
|
} else {
|
2008-03-13 23:45:31 +03:00
|
|
|
r_src = cpu_psr;
|
2012-10-06 03:55:10 +04:00
|
|
|
}
|
2005-07-02 18:31:34 +04:00
|
|
|
#else
|
2008-03-13 23:45:31 +03:00
|
|
|
r_src = cpu_psr;
|
2005-07-02 18:31:34 +04:00
|
|
|
#endif
|
2012-10-06 03:55:10 +04:00
|
|
|
|
2009-05-10 11:19:11 +04:00
|
|
|
switch (dc->cc_op) {
|
2012-10-10 01:49:58 +04:00
|
|
|
case CC_OP_LOGIC:
|
|
|
|
cmp->cond = logic_cond[cond];
|
|
|
|
do_compare_dst_0:
|
|
|
|
cmp->is_bool = false;
|
|
|
|
cmp->g2 = false;
|
|
|
|
cmp->c2 = tcg_const_tl(0);
|
|
|
|
#ifdef TARGET_SPARC64
|
|
|
|
if (!xcc) {
|
|
|
|
cmp->g1 = false;
|
|
|
|
cmp->c1 = tcg_temp_new();
|
|
|
|
tcg_gen_ext32s_tl(cmp->c1, cpu_cc_dst);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
cmp->g1 = true;
|
|
|
|
cmp->c1 = cpu_cc_dst;
|
|
|
|
break;
|
|
|
|
|
2012-10-06 03:55:10 +04: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-10 01:49:58 +04:00
|
|
|
goto do_compare_dst_0;
|
2012-10-06 03:55:10 +04: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->g1 = cmp->g2 = false;
|
|
|
|
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-10 01:49:57 +04:00
|
|
|
break;
|
2012-10-06 03:55:10 +04:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
cmp->g1 = cmp->g2 = true;
|
|
|
|
cmp->c1 = cpu_cc_src;
|
|
|
|
cmp->c2 = cpu_cc_src2;
|
|
|
|
break;
|
|
|
|
}
|
2009-05-10 11:19:11 +04:00
|
|
|
break;
|
2012-10-06 03:55:10 +04:00
|
|
|
|
2009-05-10 11:19:11 +04:00
|
|
|
default:
|
2012-10-06 03:55:10 +04:00
|
|
|
do_dynamic:
|
2011-07-03 20:01:57 +04:00
|
|
|
gen_helper_compute_psr(cpu_env);
|
2009-05-10 11:19:11 +04:00
|
|
|
dc->cc_op = CC_OP_FLAGS;
|
2012-10-06 03:55:10 +04:00
|
|
|
/* FALLTHRU */
|
|
|
|
|
|
|
|
case CC_OP_FLAGS:
|
|
|
|
/* We're going to generate a boolean result. */
|
|
|
|
cmp->cond = TCG_COND_NE;
|
|
|
|
cmp->is_bool = true;
|
|
|
|
cmp->g1 = cmp->g2 = false;
|
|
|
|
cmp->c1 = r_dst = tcg_temp_new();
|
|
|
|
cmp->c2 = tcg_const_tl(0);
|
|
|
|
|
|
|
|
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-09 00:36:50 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2003-10-01 00:36:07 +04:00
|
|
|
|
2012-10-06 03:54:57 +04:00
|
|
|
static void gen_fcompare(DisasCompare *cmp, unsigned int cc, unsigned int cond)
|
2004-10-01 01:55:55 +04:00
|
|
|
{
|
2008-03-09 00:36:50 +03:00
|
|
|
unsigned int offset;
|
2012-10-06 03:54:57 +04:00
|
|
|
TCGv r_dst;
|
|
|
|
|
|
|
|
/* For now we still generate a straight boolean result. */
|
|
|
|
cmp->cond = TCG_COND_NE;
|
|
|
|
cmp->is_bool = true;
|
|
|
|
cmp->g1 = cmp->g2 = false;
|
|
|
|
cmp->c1 = r_dst = tcg_temp_new();
|
|
|
|
cmp->c2 = tcg_const_tl(0);
|
2008-03-09 00:36:50 +03: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 21:12:11 +03:00
|
|
|
gen_op_eval_fbne(r_dst, cpu_fsr, offset);
|
2008-03-09 00:36:50 +03:00
|
|
|
break;
|
|
|
|
case 0x2:
|
2008-03-15 21:12:11 +03:00
|
|
|
gen_op_eval_fblg(r_dst, cpu_fsr, offset);
|
2008-03-09 00:36:50 +03:00
|
|
|
break;
|
|
|
|
case 0x3:
|
2008-03-15 21:12:11 +03:00
|
|
|
gen_op_eval_fbul(r_dst, cpu_fsr, offset);
|
2008-03-09 00:36:50 +03:00
|
|
|
break;
|
|
|
|
case 0x4:
|
2008-03-15 21:12:11 +03:00
|
|
|
gen_op_eval_fbl(r_dst, cpu_fsr, offset);
|
2008-03-09 00:36:50 +03:00
|
|
|
break;
|
|
|
|
case 0x5:
|
2008-03-15 21:12:11 +03:00
|
|
|
gen_op_eval_fbug(r_dst, cpu_fsr, offset);
|
2008-03-09 00:36:50 +03:00
|
|
|
break;
|
|
|
|
case 0x6:
|
2008-03-15 21:12:11 +03:00
|
|
|
gen_op_eval_fbg(r_dst, cpu_fsr, offset);
|
2008-03-09 00:36:50 +03:00
|
|
|
break;
|
|
|
|
case 0x7:
|
2008-03-15 21:12:11 +03:00
|
|
|
gen_op_eval_fbu(r_dst, cpu_fsr, offset);
|
2008-03-09 00:36:50 +03:00
|
|
|
break;
|
|
|
|
case 0x8:
|
|
|
|
gen_op_eval_ba(r_dst);
|
|
|
|
break;
|
|
|
|
case 0x9:
|
2008-03-15 21:12:11 +03:00
|
|
|
gen_op_eval_fbe(r_dst, cpu_fsr, offset);
|
2008-03-09 00:36:50 +03:00
|
|
|
break;
|
|
|
|
case 0xa:
|
2008-03-15 21:12:11 +03:00
|
|
|
gen_op_eval_fbue(r_dst, cpu_fsr, offset);
|
2008-03-09 00:36:50 +03:00
|
|
|
break;
|
|
|
|
case 0xb:
|
2008-03-15 21:12:11 +03:00
|
|
|
gen_op_eval_fbge(r_dst, cpu_fsr, offset);
|
2008-03-09 00:36:50 +03:00
|
|
|
break;
|
|
|
|
case 0xc:
|
2008-03-15 21:12:11 +03:00
|
|
|
gen_op_eval_fbuge(r_dst, cpu_fsr, offset);
|
2008-03-09 00:36:50 +03:00
|
|
|
break;
|
|
|
|
case 0xd:
|
2008-03-15 21:12:11 +03:00
|
|
|
gen_op_eval_fble(r_dst, cpu_fsr, offset);
|
2008-03-09 00:36:50 +03:00
|
|
|
break;
|
|
|
|
case 0xe:
|
2008-03-15 21:12:11 +03:00
|
|
|
gen_op_eval_fbule(r_dst, cpu_fsr, offset);
|
2008-03-09 00:36:50 +03:00
|
|
|
break;
|
|
|
|
case 0xf:
|
2008-03-15 21:12:11 +03:00
|
|
|
gen_op_eval_fbo(r_dst, cpu_fsr, offset);
|
2008-03-09 00:36:50 +03:00
|
|
|
break;
|
|
|
|
}
|
2004-10-01 01:55:55 +04:00
|
|
|
}
|
2008-03-02 21:25:27 +03:00
|
|
|
|
2012-10-06 03:54:57 +04: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);
|
|
|
|
}
|
|
|
|
|
|
|
|
free_compare(&cmp);
|
|
|
|
}
|
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
|
|
|
free_compare(&cmp);
|
|
|
|
}
|
|
|
|
|
2008-03-09 00:36:50 +03:00
|
|
|
#ifdef TARGET_SPARC64
|
2008-03-02 21:25:27 +03: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-09 00:36:50 +03:00
|
|
|
|
2012-10-06 03:54:57 +04: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->g1 = true;
|
|
|
|
cmp->g2 = false;
|
|
|
|
cmp->c1 = r_src;
|
|
|
|
cmp->c2 = tcg_const_tl(0);
|
|
|
|
}
|
|
|
|
|
2008-03-26 23:47:52 +03:00
|
|
|
static inline void gen_cond_reg(TCGv r_dst, int cond, TCGv r_src)
|
2008-03-09 00:36:50 +03:00
|
|
|
{
|
2012-10-06 03:54:57 +04:00
|
|
|
DisasCompare cmp;
|
|
|
|
gen_compare_reg(&cmp, cond, r_src);
|
2008-03-09 00:36:50 +03:00
|
|
|
|
2012-10-06 03:54:57 +04:00
|
|
|
/* The interface is to return a boolean in r_dst. */
|
|
|
|
tcg_gen_setcond_tl(cmp.cond, r_dst, cmp.c1, cmp.c2);
|
|
|
|
|
|
|
|
free_compare(&cmp);
|
2008-03-09 00:36:50 +03:00
|
|
|
}
|
2005-07-02 18:31:34 +04:00
|
|
|
#endif
|
2004-01-04 18:01:44 +03:00
|
|
|
|
2012-10-06 03:54:50 +04:00
|
|
|
static void do_branch(DisasContext *dc, int32_t offset, uint32_t insn, int cc)
|
2003-10-01 00:36:07 +04:00
|
|
|
{
|
2004-01-04 18:01:44 +03:00
|
|
|
unsigned int cond = GET_FIELD(insn, 3, 6), a = (insn & (1 << 29));
|
2005-01-31 01:39:04 +03:00
|
|
|
target_ulong target = dc->pc + offset;
|
2007-09-17 01:08:06 +04:00
|
|
|
|
2012-05-12 13:15:20 +04:00
|
|
|
#ifdef TARGET_SPARC64
|
|
|
|
if (unlikely(AM_CHECK(dc))) {
|
|
|
|
target &= 0xffffffffULL;
|
|
|
|
}
|
|
|
|
#endif
|
2004-01-04 18:01:44 +03:00
|
|
|
if (cond == 0x0) {
|
2007-09-20 18:54:22 +04: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 18:01:44 +03:00
|
|
|
} else if (cond == 0x8) {
|
2007-09-20 18:54:22 +04:00
|
|
|
/* unconditional taken */
|
|
|
|
if (a) {
|
|
|
|
dc->pc = target;
|
|
|
|
dc->npc = dc->pc + 4;
|
|
|
|
} else {
|
|
|
|
dc->pc = dc->npc;
|
|
|
|
dc->npc = target;
|
2009-08-22 15:46:10 +04:00
|
|
|
tcg_gen_mov_tl(cpu_pc, cpu_npc);
|
2007-09-20 18:54:22 +04:00
|
|
|
}
|
2004-01-04 18:01:44 +03:00
|
|
|
} else {
|
2012-10-06 03:54:51 +04:00
|
|
|
flush_cond(dc);
|
2012-10-06 03:54:50 +04:00
|
|
|
gen_cond(cpu_cond, cc, cond, dc);
|
2007-09-20 18:54:22 +04:00
|
|
|
if (a) {
|
2015-08-31 22:44:16 +03:00
|
|
|
gen_branch_a(dc, target);
|
2007-09-20 18:54:22 +04:00
|
|
|
} else {
|
2015-08-31 23:01:47 +03:00
|
|
|
gen_branch_n(dc, target);
|
2007-09-20 18:54:22 +04:00
|
|
|
}
|
2004-01-04 18:01:44 +03:00
|
|
|
}
|
2003-10-01 00:36:07 +04:00
|
|
|
}
|
|
|
|
|
2012-10-06 03:54:50 +04:00
|
|
|
static void do_fbranch(DisasContext *dc, int32_t offset, uint32_t insn, int cc)
|
2004-10-01 01:55:55 +04:00
|
|
|
{
|
|
|
|
unsigned int cond = GET_FIELD(insn, 3, 6), a = (insn & (1 << 29));
|
2005-01-31 01:39:04 +03:00
|
|
|
target_ulong target = dc->pc + offset;
|
|
|
|
|
2012-05-12 13:15:20 +04:00
|
|
|
#ifdef TARGET_SPARC64
|
|
|
|
if (unlikely(AM_CHECK(dc))) {
|
|
|
|
target &= 0xffffffffULL;
|
|
|
|
}
|
|
|
|
#endif
|
2004-10-01 01:55:55 +04:00
|
|
|
if (cond == 0x0) {
|
2007-09-20 18:54:22 +04: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-10-01 01:55:55 +04:00
|
|
|
} else if (cond == 0x8) {
|
2007-09-20 18:54:22 +04:00
|
|
|
/* unconditional taken */
|
|
|
|
if (a) {
|
|
|
|
dc->pc = target;
|
|
|
|
dc->npc = dc->pc + 4;
|
|
|
|
} else {
|
|
|
|
dc->pc = dc->npc;
|
|
|
|
dc->npc = target;
|
2009-08-22 15:46:10 +04:00
|
|
|
tcg_gen_mov_tl(cpu_pc, cpu_npc);
|
2007-09-20 18:54:22 +04:00
|
|
|
}
|
2004-10-01 01:55:55 +04:00
|
|
|
} else {
|
2012-10-06 03:54:51 +04:00
|
|
|
flush_cond(dc);
|
2012-10-06 03:54:50 +04:00
|
|
|
gen_fcond(cpu_cond, cc, cond);
|
2007-09-20 18:54:22 +04:00
|
|
|
if (a) {
|
2015-08-31 22:44:16 +03:00
|
|
|
gen_branch_a(dc, target);
|
2007-09-20 18:54:22 +04:00
|
|
|
} else {
|
2015-08-31 23:01:47 +03:00
|
|
|
gen_branch_n(dc, target);
|
2007-09-20 18:54:22 +04:00
|
|
|
}
|
2004-10-01 01:55:55 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-07-02 18:31:34 +04:00
|
|
|
#ifdef TARGET_SPARC64
|
2008-03-26 23:47:52 +03:00
|
|
|
static void do_branch_reg(DisasContext *dc, int32_t offset, uint32_t insn,
|
2012-10-06 03:54:50 +04:00
|
|
|
TCGv r_reg)
|
2003-10-01 00:36:07 +04:00
|
|
|
{
|
2005-07-02 18:31:34 +04:00
|
|
|
unsigned int cond = GET_FIELD_SP(insn, 25, 27), a = (insn & (1 << 29));
|
|
|
|
target_ulong target = dc->pc + offset;
|
|
|
|
|
2012-05-12 13:15:20 +04:00
|
|
|
if (unlikely(AM_CHECK(dc))) {
|
|
|
|
target &= 0xffffffffULL;
|
|
|
|
}
|
2012-10-06 03:54:51 +04:00
|
|
|
flush_cond(dc);
|
2012-10-06 03:54:50 +04:00
|
|
|
gen_cond_reg(cpu_cond, cond, r_reg);
|
2005-07-02 18:31:34 +04:00
|
|
|
if (a) {
|
2015-08-31 22:44:16 +03:00
|
|
|
gen_branch_a(dc, target);
|
2005-07-02 18:31:34 +04:00
|
|
|
} else {
|
2015-08-31 23:01:47 +03:00
|
|
|
gen_branch_n(dc, target);
|
2005-07-02 18:31:34 +04:00
|
|
|
}
|
2003-10-01 00:36:07 +04:00
|
|
|
}
|
|
|
|
|
2008-11-17 17:43:54 +03:00
|
|
|
static inline void gen_op_fcmps(int fccno, TCGv_i32 r_rs1, TCGv_i32 r_rs2)
|
2008-03-04 23:00:18 +03:00
|
|
|
{
|
2008-09-10 23:54:51 +04:00
|
|
|
switch (fccno) {
|
|
|
|
case 0:
|
2011-07-03 14:42:23 +04:00
|
|
|
gen_helper_fcmps(cpu_env, r_rs1, r_rs2);
|
2008-09-10 23:54:51 +04:00
|
|
|
break;
|
|
|
|
case 1:
|
2011-07-03 14:42:23 +04:00
|
|
|
gen_helper_fcmps_fcc1(cpu_env, r_rs1, r_rs2);
|
2008-09-10 23:54:51 +04:00
|
|
|
break;
|
|
|
|
case 2:
|
2011-07-03 14:42:23 +04:00
|
|
|
gen_helper_fcmps_fcc2(cpu_env, r_rs1, r_rs2);
|
2008-09-10 23:54:51 +04:00
|
|
|
break;
|
|
|
|
case 3:
|
2011-07-03 14:42:23 +04:00
|
|
|
gen_helper_fcmps_fcc3(cpu_env, r_rs1, r_rs2);
|
2008-09-10 23:54:51 +04:00
|
|
|
break;
|
|
|
|
}
|
2008-03-04 23:00:18 +03:00
|
|
|
}
|
|
|
|
|
2011-10-15 21:20:20 +04:00
|
|
|
static inline void gen_op_fcmpd(int fccno, TCGv_i64 r_rs1, TCGv_i64 r_rs2)
|
2008-03-04 23:00:18 +03:00
|
|
|
{
|
2008-11-17 17:43:54 +03:00
|
|
|
switch (fccno) {
|
|
|
|
case 0:
|
2011-10-15 21:20:20 +04:00
|
|
|
gen_helper_fcmpd(cpu_env, r_rs1, r_rs2);
|
2008-11-17 17:43:54 +03:00
|
|
|
break;
|
|
|
|
case 1:
|
2011-10-15 21:20:20 +04:00
|
|
|
gen_helper_fcmpd_fcc1(cpu_env, r_rs1, r_rs2);
|
2008-11-17 17:43:54 +03:00
|
|
|
break;
|
|
|
|
case 2:
|
2011-10-15 21:20:20 +04:00
|
|
|
gen_helper_fcmpd_fcc2(cpu_env, r_rs1, r_rs2);
|
2008-11-17 17:43:54 +03:00
|
|
|
break;
|
|
|
|
case 3:
|
2011-10-15 21:20:20 +04:00
|
|
|
gen_helper_fcmpd_fcc3(cpu_env, r_rs1, r_rs2);
|
2008-11-17 17:43:54 +03:00
|
|
|
break;
|
|
|
|
}
|
2008-03-04 23:00:18 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline void gen_op_fcmpq(int fccno)
|
|
|
|
{
|
2008-11-17 17:43:54 +03:00
|
|
|
switch (fccno) {
|
|
|
|
case 0:
|
2011-07-03 14:42:23 +04:00
|
|
|
gen_helper_fcmpq(cpu_env);
|
2008-11-17 17:43:54 +03:00
|
|
|
break;
|
|
|
|
case 1:
|
2011-07-03 14:42:23 +04:00
|
|
|
gen_helper_fcmpq_fcc1(cpu_env);
|
2008-11-17 17:43:54 +03:00
|
|
|
break;
|
|
|
|
case 2:
|
2011-07-03 14:42:23 +04:00
|
|
|
gen_helper_fcmpq_fcc2(cpu_env);
|
2008-11-17 17:43:54 +03:00
|
|
|
break;
|
|
|
|
case 3:
|
2011-07-03 14:42:23 +04:00
|
|
|
gen_helper_fcmpq_fcc3(cpu_env);
|
2008-11-17 17:43:54 +03:00
|
|
|
break;
|
|
|
|
}
|
2008-03-04 23:00:18 +03:00
|
|
|
}
|
|
|
|
|
2008-11-17 17:43:54 +03:00
|
|
|
static inline void gen_op_fcmpes(int fccno, TCGv_i32 r_rs1, TCGv_i32 r_rs2)
|
2008-03-04 23:00:18 +03:00
|
|
|
{
|
2008-09-10 23:54:51 +04:00
|
|
|
switch (fccno) {
|
|
|
|
case 0:
|
2011-07-03 14:42:23 +04:00
|
|
|
gen_helper_fcmpes(cpu_env, r_rs1, r_rs2);
|
2008-09-10 23:54:51 +04:00
|
|
|
break;
|
|
|
|
case 1:
|
2011-07-03 14:42:23 +04:00
|
|
|
gen_helper_fcmpes_fcc1(cpu_env, r_rs1, r_rs2);
|
2008-09-10 23:54:51 +04:00
|
|
|
break;
|
|
|
|
case 2:
|
2011-07-03 14:42:23 +04:00
|
|
|
gen_helper_fcmpes_fcc2(cpu_env, r_rs1, r_rs2);
|
2008-09-10 23:54:51 +04:00
|
|
|
break;
|
|
|
|
case 3:
|
2011-07-03 14:42:23 +04:00
|
|
|
gen_helper_fcmpes_fcc3(cpu_env, r_rs1, r_rs2);
|
2008-09-10 23:54:51 +04:00
|
|
|
break;
|
|
|
|
}
|
2008-03-04 23:00:18 +03:00
|
|
|
}
|
|
|
|
|
2011-10-15 21:20:20 +04:00
|
|
|
static inline void gen_op_fcmped(int fccno, TCGv_i64 r_rs1, TCGv_i64 r_rs2)
|
2008-03-04 23:00:18 +03:00
|
|
|
{
|
2008-11-17 17:43:54 +03:00
|
|
|
switch (fccno) {
|
|
|
|
case 0:
|
2011-10-15 21:20:20 +04:00
|
|
|
gen_helper_fcmped(cpu_env, r_rs1, r_rs2);
|
2008-11-17 17:43:54 +03:00
|
|
|
break;
|
|
|
|
case 1:
|
2011-10-15 21:20:20 +04:00
|
|
|
gen_helper_fcmped_fcc1(cpu_env, r_rs1, r_rs2);
|
2008-11-17 17:43:54 +03:00
|
|
|
break;
|
|
|
|
case 2:
|
2011-10-15 21:20:20 +04:00
|
|
|
gen_helper_fcmped_fcc2(cpu_env, r_rs1, r_rs2);
|
2008-11-17 17:43:54 +03:00
|
|
|
break;
|
|
|
|
case 3:
|
2011-10-15 21:20:20 +04:00
|
|
|
gen_helper_fcmped_fcc3(cpu_env, r_rs1, r_rs2);
|
2008-11-17 17:43:54 +03:00
|
|
|
break;
|
|
|
|
}
|
2008-03-04 23:00:18 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline void gen_op_fcmpeq(int fccno)
|
|
|
|
{
|
2008-11-17 17:43:54 +03:00
|
|
|
switch (fccno) {
|
|
|
|
case 0:
|
2011-07-03 14:42:23 +04:00
|
|
|
gen_helper_fcmpeq(cpu_env);
|
2008-11-17 17:43:54 +03:00
|
|
|
break;
|
|
|
|
case 1:
|
2011-07-03 14:42:23 +04:00
|
|
|
gen_helper_fcmpeq_fcc1(cpu_env);
|
2008-11-17 17:43:54 +03:00
|
|
|
break;
|
|
|
|
case 2:
|
2011-07-03 14:42:23 +04:00
|
|
|
gen_helper_fcmpeq_fcc2(cpu_env);
|
2008-11-17 17:43:54 +03:00
|
|
|
break;
|
|
|
|
case 3:
|
2011-07-03 14:42:23 +04:00
|
|
|
gen_helper_fcmpeq_fcc3(cpu_env);
|
2008-11-17 17:43:54 +03:00
|
|
|
break;
|
|
|
|
}
|
2008-03-04 23:00:18 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
2008-09-10 23:54:51 +04:00
|
|
|
static inline void gen_op_fcmps(int fccno, TCGv r_rs1, TCGv r_rs2)
|
2008-03-04 23:00:18 +03:00
|
|
|
{
|
2011-07-03 14:42:23 +04:00
|
|
|
gen_helper_fcmps(cpu_env, r_rs1, r_rs2);
|
2008-03-04 23:00:18 +03:00
|
|
|
}
|
|
|
|
|
2011-10-15 21:20:20 +04:00
|
|
|
static inline void gen_op_fcmpd(int fccno, TCGv_i64 r_rs1, TCGv_i64 r_rs2)
|
2008-03-04 23:00:18 +03:00
|
|
|
{
|
2011-10-15 21:20:20 +04:00
|
|
|
gen_helper_fcmpd(cpu_env, r_rs1, r_rs2);
|
2008-03-04 23:00:18 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline void gen_op_fcmpq(int fccno)
|
|
|
|
{
|
2011-07-03 14:42:23 +04:00
|
|
|
gen_helper_fcmpq(cpu_env);
|
2008-03-04 23:00:18 +03:00
|
|
|
}
|
|
|
|
|
2008-09-10 23:54:51 +04:00
|
|
|
static inline void gen_op_fcmpes(int fccno, TCGv r_rs1, TCGv r_rs2)
|
2008-03-04 23:00:18 +03:00
|
|
|
{
|
2011-07-03 14:42:23 +04:00
|
|
|
gen_helper_fcmpes(cpu_env, r_rs1, r_rs2);
|
2008-03-04 23:00:18 +03:00
|
|
|
}
|
|
|
|
|
2011-10-15 21:20:20 +04:00
|
|
|
static inline void gen_op_fcmped(int fccno, TCGv_i64 r_rs1, TCGv_i64 r_rs2)
|
2008-03-04 23:00:18 +03:00
|
|
|
{
|
2011-10-15 21:20:20 +04:00
|
|
|
gen_helper_fcmped(cpu_env, r_rs1, r_rs2);
|
2008-03-04 23:00:18 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline void gen_op_fcmpeq(int fccno)
|
|
|
|
{
|
2011-07-03 14:42:23 +04:00
|
|
|
gen_helper_fcmpeq(cpu_env);
|
2008-03-04 23:00:18 +03:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2008-03-06 23:09:54 +03:00
|
|
|
static inline void gen_op_fpexception_im(int fsr_flags)
|
|
|
|
{
|
2008-11-17 17:43:54 +03:00
|
|
|
TCGv_i32 r_const;
|
2008-05-27 23:39:12 +04:00
|
|
|
|
2008-09-06 21:50:16 +04:00
|
|
|
tcg_gen_andi_tl(cpu_fsr, cpu_fsr, FSR_FTT_NMASK);
|
2008-03-15 21:12:11 +03:00
|
|
|
tcg_gen_ori_tl(cpu_fsr, cpu_fsr, fsr_flags);
|
2008-05-27 23:39:12 +04:00
|
|
|
r_const = tcg_const_i32(TT_FP_EXCP);
|
2011-07-03 12:19:42 +04:00
|
|
|
gen_helper_raise_exception(cpu_env, r_const);
|
2008-11-17 17:43:54 +03:00
|
|
|
tcg_temp_free_i32(r_const);
|
2008-03-06 23:09:54 +03:00
|
|
|
}
|
|
|
|
|
2012-10-06 03:54:52 +04:00
|
|
|
static int gen_trap_ifnofpu(DisasContext *dc)
|
2006-06-26 23:53:29 +04:00
|
|
|
{
|
|
|
|
#if !defined(CONFIG_USER_ONLY)
|
|
|
|
if (!dc->fpu_enabled) {
|
2008-11-17 17:43:54 +03:00
|
|
|
TCGv_i32 r_const;
|
2008-05-27 23:39:12 +04:00
|
|
|
|
2012-10-06 03:54:53 +04:00
|
|
|
save_state(dc);
|
2008-05-27 23:39:12 +04:00
|
|
|
r_const = tcg_const_i32(TT_NFPU_INSN);
|
2011-07-03 12:19:42 +04:00
|
|
|
gen_helper_raise_exception(cpu_env, r_const);
|
2008-11-17 17:43:54 +03:00
|
|
|
tcg_temp_free_i32(r_const);
|
2006-06-26 23:53:29 +04:00
|
|
|
dc->is_br = 1;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-03-04 23:00:18 +03:00
|
|
|
static inline void gen_op_clear_ieee_excp_and_FTT(void)
|
|
|
|
{
|
2008-09-06 21:50:16 +04:00
|
|
|
tcg_gen_andi_tl(cpu_fsr, cpu_fsr, FSR_FTT_CEXC_NMASK);
|
2008-03-04 23:00:18 +03:00
|
|
|
}
|
|
|
|
|
2011-10-15 22:52:00 +04: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 13:32:21 +04:00
|
|
|
dst = gen_dest_fpr_F(dc);
|
2011-10-15 22:52:00 +04:00
|
|
|
|
|
|
|
gen(dst, cpu_env, src);
|
|
|
|
|
|
|
|
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 13:32:21 +04:00
|
|
|
dst = gen_dest_fpr_F(dc);
|
2011-10-15 22:52:00 +04: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 13:32:21 +04:00
|
|
|
dst = gen_dest_fpr_F(dc);
|
2011-10-15 22:52:00 +04:00
|
|
|
|
|
|
|
gen(dst, cpu_env, src1, src2);
|
|
|
|
|
|
|
|
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 13:32:21 +04:00
|
|
|
dst = gen_dest_fpr_F(dc);
|
2011-10-15 22:52:00 +04: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 13:32:26 +04:00
|
|
|
dst = gen_dest_fpr_D(dc, rd);
|
2011-10-15 22:52:00 +04:00
|
|
|
|
|
|
|
gen(dst, cpu_env, src);
|
|
|
|
|
|
|
|
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 13:32:26 +04:00
|
|
|
dst = gen_dest_fpr_D(dc, rd);
|
2011-10-15 22:52:00 +04: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 13:32:26 +04:00
|
|
|
dst = gen_dest_fpr_D(dc, rd);
|
2011-10-15 22:52:00 +04:00
|
|
|
|
|
|
|
gen(dst, cpu_env, src1, src2);
|
|
|
|
|
|
|
|
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 13:32:26 +04:00
|
|
|
dst = gen_dest_fpr_D(dc, rd);
|
2011-10-15 22:52:00 +04:00
|
|
|
|
|
|
|
gen(dst, src1, src2);
|
|
|
|
|
|
|
|
gen_store_fpr_D(dc, rd, dst);
|
|
|
|
}
|
2011-10-18 04:32:26 +04:00
|
|
|
|
2011-10-18 05:03:47 +04: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 13:32:26 +04:00
|
|
|
dst = gen_dest_fpr_D(dc, rd);
|
2011-10-18 05:03:47 +04:00
|
|
|
|
|
|
|
gen(dst, cpu_gsr, src1, src2);
|
|
|
|
|
|
|
|
gen_store_fpr_D(dc, rd, dst);
|
|
|
|
}
|
|
|
|
|
2011-10-18 04:32:26 +04: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 13:32:26 +04:00
|
|
|
dst = gen_dest_fpr_D(dc, rd);
|
2011-10-18 04:32:26 +04:00
|
|
|
|
|
|
|
gen(dst, src0, src1, src2);
|
|
|
|
|
|
|
|
gen_store_fpr_D(dc, rd, dst);
|
|
|
|
}
|
2011-10-15 22:52:00 +04: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);
|
|
|
|
|
|
|
|
gen_op_store_QT0_fpr(QFPREG(rd));
|
|
|
|
gen_update_fprs_dirty(QFPREG(rd));
|
|
|
|
}
|
|
|
|
|
|
|
|
#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));
|
|
|
|
gen_update_fprs_dirty(QFPREG(rd));
|
|
|
|
}
|
|
|
|
#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);
|
|
|
|
|
|
|
|
gen_op_store_QT0_fpr(QFPREG(rd));
|
|
|
|
gen_update_fprs_dirty(QFPREG(rd));
|
|
|
|
}
|
|
|
|
|
|
|
|
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 13:32:26 +04:00
|
|
|
dst = gen_dest_fpr_D(dc, rd);
|
2011-10-15 22:52:00 +04:00
|
|
|
|
|
|
|
gen(dst, cpu_env, src1, src2);
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
gen_op_store_QT0_fpr(QFPREG(rd));
|
|
|
|
gen_update_fprs_dirty(QFPREG(rd));
|
|
|
|
}
|
|
|
|
|
|
|
|
#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 13:32:26 +04:00
|
|
|
dst = gen_dest_fpr_D(dc, rd);
|
2011-10-15 22:52:00 +04:00
|
|
|
|
|
|
|
gen(dst, cpu_env, src);
|
|
|
|
|
|
|
|
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 13:32:26 +04:00
|
|
|
dst = gen_dest_fpr_D(dc, rd);
|
2011-10-15 22:52:00 +04: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 13:32:21 +04:00
|
|
|
dst = gen_dest_fpr_F(dc);
|
2011-10-15 22:52:00 +04:00
|
|
|
|
|
|
|
gen(dst, cpu_env, src);
|
|
|
|
|
|
|
|
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 13:32:21 +04:00
|
|
|
dst = gen_dest_fpr_F(dc);
|
2011-10-15 22:52:00 +04:00
|
|
|
|
|
|
|
gen(dst, cpu_env);
|
|
|
|
|
|
|
|
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 13:32:26 +04:00
|
|
|
dst = gen_dest_fpr_D(dc, rd);
|
2011-10-15 22:52:00 +04:00
|
|
|
|
|
|
|
gen(dst, cpu_env);
|
|
|
|
|
|
|
|
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));
|
|
|
|
gen_update_fprs_dirty(QFPREG(rd));
|
|
|
|
}
|
|
|
|
|
|
|
|
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));
|
|
|
|
gen_update_fprs_dirty(QFPREG(rd));
|
|
|
|
}
|
|
|
|
|
2008-02-24 17:10:06 +03:00
|
|
|
/* asi moves */
|
|
|
|
#ifdef TARGET_SPARC64
|
2008-11-17 17:43:54 +03:00
|
|
|
static inline TCGv_i32 gen_get_asi(int insn, TCGv r_addr)
|
2008-02-24 17:10:06 +03:00
|
|
|
{
|
2008-08-06 19:28:20 +04:00
|
|
|
int asi;
|
2008-11-17 17:43:54 +03:00
|
|
|
TCGv_i32 r_asi;
|
2008-02-24 17:10:06 +03:00
|
|
|
|
|
|
|
if (IS_IMM) {
|
2008-11-17 17:43:54 +03:00
|
|
|
r_asi = tcg_temp_new_i32();
|
2008-09-06 21:51:43 +04:00
|
|
|
tcg_gen_mov_i32(r_asi, cpu_asi);
|
2008-02-24 17:10:06 +03:00
|
|
|
} else {
|
|
|
|
asi = GET_FIELD(insn, 19, 26);
|
2008-03-16 22:18:54 +03:00
|
|
|
r_asi = tcg_const_i32(asi);
|
2008-02-24 17:10:06 +03:00
|
|
|
}
|
2008-03-16 22:18:54 +03:00
|
|
|
return r_asi;
|
|
|
|
}
|
|
|
|
|
2008-05-12 20:13:33 +04:00
|
|
|
static inline void gen_ld_asi(TCGv dst, TCGv addr, int insn, int size,
|
|
|
|
int sign)
|
2008-03-16 22:18:54 +03:00
|
|
|
{
|
2008-11-17 17:43:54 +03:00
|
|
|
TCGv_i32 r_asi, r_size, r_sign;
|
2008-03-16 22:18:54 +03:00
|
|
|
|
2008-03-26 23:47:52 +03:00
|
|
|
r_asi = gen_get_asi(insn, addr);
|
2008-05-27 23:39:12 +04:00
|
|
|
r_size = tcg_const_i32(size);
|
|
|
|
r_sign = tcg_const_i32(sign);
|
2011-07-05 00:34:28 +04:00
|
|
|
gen_helper_ld_asi(dst, cpu_env, addr, r_asi, r_size, r_sign);
|
2008-11-17 17:43:54 +03:00
|
|
|
tcg_temp_free_i32(r_sign);
|
|
|
|
tcg_temp_free_i32(r_size);
|
|
|
|
tcg_temp_free_i32(r_asi);
|
2008-02-24 17:10:06 +03:00
|
|
|
}
|
|
|
|
|
2008-03-26 23:47:52 +03:00
|
|
|
static inline void gen_st_asi(TCGv src, TCGv addr, int insn, int size)
|
2008-02-24 17:10:06 +03:00
|
|
|
{
|
2008-11-17 17:43:54 +03:00
|
|
|
TCGv_i32 r_asi, r_size;
|
2008-02-24 17:10:06 +03:00
|
|
|
|
2008-03-26 23:47:52 +03:00
|
|
|
r_asi = gen_get_asi(insn, addr);
|
2008-05-27 23:39:12 +04:00
|
|
|
r_size = tcg_const_i32(size);
|
2011-07-05 00:34:28 +04:00
|
|
|
gen_helper_st_asi(cpu_env, addr, src, r_asi, r_size);
|
2008-11-17 17:43:54 +03:00
|
|
|
tcg_temp_free_i32(r_size);
|
|
|
|
tcg_temp_free_i32(r_asi);
|
2008-02-24 17:10:06 +03:00
|
|
|
}
|
|
|
|
|
2008-03-26 23:47:52 +03:00
|
|
|
static inline void gen_ldf_asi(TCGv addr, int insn, int size, int rd)
|
2008-02-24 17:10:06 +03:00
|
|
|
{
|
2008-11-17 17:43:54 +03:00
|
|
|
TCGv_i32 r_asi, r_size, r_rd;
|
2008-02-24 17:10:06 +03:00
|
|
|
|
2008-03-26 23:47:52 +03:00
|
|
|
r_asi = gen_get_asi(insn, addr);
|
2008-05-27 23:39:12 +04:00
|
|
|
r_size = tcg_const_i32(size);
|
|
|
|
r_rd = tcg_const_i32(rd);
|
2011-07-05 00:34:28 +04:00
|
|
|
gen_helper_ldf_asi(cpu_env, addr, r_asi, r_size, r_rd);
|
2008-11-17 17:43:54 +03:00
|
|
|
tcg_temp_free_i32(r_rd);
|
|
|
|
tcg_temp_free_i32(r_size);
|
|
|
|
tcg_temp_free_i32(r_asi);
|
2008-02-24 17:10:06 +03:00
|
|
|
}
|
|
|
|
|
2008-03-26 23:47:52 +03:00
|
|
|
static inline void gen_stf_asi(TCGv addr, int insn, int size, int rd)
|
2008-02-24 17:10:06 +03:00
|
|
|
{
|
2008-11-17 17:43:54 +03:00
|
|
|
TCGv_i32 r_asi, r_size, r_rd;
|
2008-02-24 17:10:06 +03:00
|
|
|
|
2008-03-29 11:59:48 +03:00
|
|
|
r_asi = gen_get_asi(insn, addr);
|
2008-05-27 23:39:12 +04:00
|
|
|
r_size = tcg_const_i32(size);
|
|
|
|
r_rd = tcg_const_i32(rd);
|
2011-07-05 00:34:28 +04:00
|
|
|
gen_helper_stf_asi(cpu_env, addr, r_asi, r_size, r_rd);
|
2008-11-17 17:43:54 +03:00
|
|
|
tcg_temp_free_i32(r_rd);
|
|
|
|
tcg_temp_free_i32(r_size);
|
|
|
|
tcg_temp_free_i32(r_asi);
|
2008-02-24 17:10:06 +03:00
|
|
|
}
|
|
|
|
|
2012-10-16 13:32:16 +04:00
|
|
|
static inline void gen_swap_asi(TCGv dst, TCGv src, TCGv addr, int insn)
|
2008-02-24 17:10:06 +03:00
|
|
|
{
|
2008-11-17 17:43:54 +03:00
|
|
|
TCGv_i32 r_asi, r_size, r_sign;
|
2012-10-16 13:32:25 +04:00
|
|
|
TCGv_i64 t64 = tcg_temp_new_i64();
|
2008-02-24 17:10:06 +03:00
|
|
|
|
2008-03-26 23:47:52 +03:00
|
|
|
r_asi = gen_get_asi(insn, addr);
|
2008-05-27 23:39:12 +04:00
|
|
|
r_size = tcg_const_i32(4);
|
|
|
|
r_sign = tcg_const_i32(0);
|
2012-10-16 13:32:25 +04:00
|
|
|
gen_helper_ld_asi(t64, cpu_env, addr, r_asi, r_size, r_sign);
|
2008-11-17 17:43:54 +03:00
|
|
|
tcg_temp_free_i32(r_sign);
|
2012-10-16 13:32:16 +04:00
|
|
|
gen_helper_st_asi(cpu_env, addr, src, r_asi, r_size);
|
2008-11-17 17:43:54 +03:00
|
|
|
tcg_temp_free_i32(r_size);
|
|
|
|
tcg_temp_free_i32(r_asi);
|
2012-10-16 13:32:25 +04:00
|
|
|
tcg_gen_trunc_i64_tl(dst, t64);
|
|
|
|
tcg_temp_free_i64(t64);
|
2008-02-24 17:10:06 +03:00
|
|
|
}
|
|
|
|
|
2012-10-16 13:32:15 +04:00
|
|
|
static inline void gen_ldda_asi(DisasContext *dc, TCGv hi, TCGv addr,
|
|
|
|
int insn, int rd)
|
2008-02-24 17:10:06 +03:00
|
|
|
{
|
2008-11-17 17:43:54 +03:00
|
|
|
TCGv_i32 r_asi, r_rd;
|
2008-02-24 17:10:06 +03:00
|
|
|
|
2008-03-26 23:47:52 +03:00
|
|
|
r_asi = gen_get_asi(insn, addr);
|
2008-07-19 17:25:28 +04:00
|
|
|
r_rd = tcg_const_i32(rd);
|
2011-07-05 00:34:28 +04:00
|
|
|
gen_helper_ldda_asi(cpu_env, addr, r_asi, r_rd);
|
2008-11-17 17:43:54 +03:00
|
|
|
tcg_temp_free_i32(r_rd);
|
|
|
|
tcg_temp_free_i32(r_asi);
|
2008-03-16 22:18:54 +03:00
|
|
|
}
|
|
|
|
|
2012-10-16 13:32:15 +04:00
|
|
|
static inline void gen_stda_asi(DisasContext *dc, TCGv hi, TCGv addr,
|
|
|
|
int insn, int rd)
|
2008-03-16 22:18:54 +03:00
|
|
|
{
|
2008-11-17 17:43:54 +03:00
|
|
|
TCGv_i32 r_asi, r_size;
|
2012-10-16 13:32:15 +04:00
|
|
|
TCGv lo = gen_load_gpr(dc, rd + 1);
|
2012-10-16 13:32:25 +04:00
|
|
|
TCGv_i64 t64 = tcg_temp_new_i64();
|
2008-09-21 18:49:09 +04:00
|
|
|
|
2012-10-16 13:32:25 +04:00
|
|
|
tcg_gen_concat_tl_i64(t64, lo, hi);
|
2008-03-26 23:47:52 +03:00
|
|
|
r_asi = gen_get_asi(insn, addr);
|
2008-05-27 23:39:12 +04:00
|
|
|
r_size = tcg_const_i32(8);
|
2012-10-16 13:32:25 +04:00
|
|
|
gen_helper_st_asi(cpu_env, addr, t64, r_asi, r_size);
|
2008-11-17 17:43:54 +03:00
|
|
|
tcg_temp_free_i32(r_size);
|
|
|
|
tcg_temp_free_i32(r_asi);
|
2012-10-16 13:32:25 +04:00
|
|
|
tcg_temp_free_i64(t64);
|
2008-02-24 17:10:06 +03:00
|
|
|
}
|
|
|
|
|
2012-10-16 13:32:17 +04:00
|
|
|
static inline void gen_casx_asi(DisasContext *dc, TCGv addr,
|
2012-10-16 13:32:15 +04:00
|
|
|
TCGv val2, int insn, int rd)
|
2008-02-24 17:10:06 +03:00
|
|
|
{
|
2012-10-16 13:32:17 +04:00
|
|
|
TCGv val1 = gen_load_gpr(dc, rd);
|
|
|
|
TCGv dst = gen_dest_gpr(dc, rd);
|
2012-10-16 13:32:15 +04:00
|
|
|
TCGv_i32 r_asi = gen_get_asi(insn, addr);
|
2008-02-24 17:10:06 +03:00
|
|
|
|
2012-10-16 13:32:17 +04:00
|
|
|
gen_helper_casx_asi(dst, cpu_env, addr, val1, val2, r_asi);
|
2008-11-17 17:43:54 +03:00
|
|
|
tcg_temp_free_i32(r_asi);
|
2012-10-16 13:32:17 +04:00
|
|
|
gen_store_gpr(dc, rd, dst);
|
2008-02-24 17:10:06 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
#elif !defined(CONFIG_USER_ONLY)
|
|
|
|
|
2008-05-12 20:13:33 +04:00
|
|
|
static inline void gen_ld_asi(TCGv dst, TCGv addr, int insn, int size,
|
|
|
|
int sign)
|
2008-02-24 17:10:06 +03:00
|
|
|
{
|
2008-11-17 17:43:54 +03:00
|
|
|
TCGv_i32 r_asi, r_size, r_sign;
|
2012-10-16 13:32:25 +04:00
|
|
|
TCGv_i64 t64 = tcg_temp_new_i64();
|
2008-02-24 17:10:06 +03:00
|
|
|
|
2008-05-27 23:39:12 +04:00
|
|
|
r_asi = tcg_const_i32(GET_FIELD(insn, 19, 26));
|
|
|
|
r_size = tcg_const_i32(size);
|
|
|
|
r_sign = tcg_const_i32(sign);
|
2012-10-16 13:32:25 +04:00
|
|
|
gen_helper_ld_asi(t64, cpu_env, addr, r_asi, r_size, r_sign);
|
|
|
|
tcg_temp_free_i32(r_sign);
|
|
|
|
tcg_temp_free_i32(r_size);
|
|
|
|
tcg_temp_free_i32(r_asi);
|
|
|
|
tcg_gen_trunc_i64_tl(dst, t64);
|
|
|
|
tcg_temp_free_i64(t64);
|
2008-02-24 17:10:06 +03:00
|
|
|
}
|
|
|
|
|
2008-03-26 23:47:52 +03:00
|
|
|
static inline void gen_st_asi(TCGv src, TCGv addr, int insn, int size)
|
2008-02-24 17:10:06 +03:00
|
|
|
{
|
2008-11-17 17:43:54 +03:00
|
|
|
TCGv_i32 r_asi, r_size;
|
2012-10-16 13:32:25 +04:00
|
|
|
TCGv_i64 t64 = tcg_temp_new_i64();
|
2008-02-24 17:10:06 +03:00
|
|
|
|
2012-10-16 13:32:25 +04:00
|
|
|
tcg_gen_extu_tl_i64(t64, src);
|
2008-05-27 23:39:12 +04:00
|
|
|
r_asi = tcg_const_i32(GET_FIELD(insn, 19, 26));
|
|
|
|
r_size = tcg_const_i32(size);
|
2012-10-16 13:32:25 +04:00
|
|
|
gen_helper_st_asi(cpu_env, addr, t64, r_asi, r_size);
|
|
|
|
tcg_temp_free_i32(r_size);
|
|
|
|
tcg_temp_free_i32(r_asi);
|
|
|
|
tcg_temp_free_i64(t64);
|
2008-02-24 17:10:06 +03:00
|
|
|
}
|
|
|
|
|
2012-10-16 13:32:16 +04:00
|
|
|
static inline void gen_swap_asi(TCGv dst, TCGv src, TCGv addr, int insn)
|
2008-02-24 17:10:06 +03:00
|
|
|
{
|
2008-11-17 17:43:54 +03:00
|
|
|
TCGv_i32 r_asi, r_size, r_sign;
|
2012-10-16 13:32:25 +04:00
|
|
|
TCGv_i64 r_val, t64;
|
2008-02-24 17:10:06 +03:00
|
|
|
|
2008-05-27 23:39:12 +04:00
|
|
|
r_asi = tcg_const_i32(GET_FIELD(insn, 19, 26));
|
|
|
|
r_size = tcg_const_i32(4);
|
|
|
|
r_sign = tcg_const_i32(0);
|
2012-10-16 13:32:25 +04:00
|
|
|
t64 = tcg_temp_new_i64();
|
|
|
|
gen_helper_ld_asi(t64, cpu_env, addr, r_asi, r_size, r_sign);
|
2008-05-27 23:39:12 +04:00
|
|
|
tcg_temp_free(r_sign);
|
2008-11-17 17:43:54 +03:00
|
|
|
r_val = tcg_temp_new_i64();
|
2012-10-16 13:32:16 +04:00
|
|
|
tcg_gen_extu_tl_i64(r_val, src);
|
2011-07-05 00:34:28 +04:00
|
|
|
gen_helper_st_asi(cpu_env, addr, r_val, r_asi, r_size);
|
2008-11-17 17:43:54 +03:00
|
|
|
tcg_temp_free_i64(r_val);
|
2012-10-16 13:32:25 +04:00
|
|
|
tcg_temp_free_i32(r_size);
|
|
|
|
tcg_temp_free_i32(r_asi);
|
|
|
|
tcg_gen_trunc_i64_tl(dst, t64);
|
|
|
|
tcg_temp_free_i64(t64);
|
2008-02-24 17:10:06 +03:00
|
|
|
}
|
|
|
|
|
2012-10-16 13:32:15 +04:00
|
|
|
static inline void gen_ldda_asi(DisasContext *dc, TCGv hi, TCGv addr,
|
|
|
|
int insn, int rd)
|
2008-02-24 17:10:06 +03:00
|
|
|
{
|
2008-11-17 17:43:54 +03:00
|
|
|
TCGv_i32 r_asi, r_size, r_sign;
|
2012-10-16 13:32:15 +04:00
|
|
|
TCGv t;
|
2012-10-16 13:32:25 +04:00
|
|
|
TCGv_i64 t64;
|
2008-02-24 17:10:06 +03:00
|
|
|
|
2008-05-27 23:39:12 +04:00
|
|
|
r_asi = tcg_const_i32(GET_FIELD(insn, 19, 26));
|
|
|
|
r_size = tcg_const_i32(8);
|
|
|
|
r_sign = tcg_const_i32(0);
|
2012-10-16 13:32:25 +04:00
|
|
|
t64 = tcg_temp_new_i64();
|
|
|
|
gen_helper_ld_asi(t64, cpu_env, addr, r_asi, r_size, r_sign);
|
|
|
|
tcg_temp_free_i32(r_sign);
|
|
|
|
tcg_temp_free_i32(r_size);
|
|
|
|
tcg_temp_free_i32(r_asi);
|
2012-10-16 13:32:15 +04:00
|
|
|
|
|
|
|
t = gen_dest_gpr(dc, rd + 1);
|
2012-10-16 13:32:25 +04:00
|
|
|
tcg_gen_trunc_i64_tl(t, t64);
|
2012-10-16 13:32:15 +04:00
|
|
|
gen_store_gpr(dc, rd + 1, t);
|
|
|
|
|
2012-10-16 13:32:25 +04:00
|
|
|
tcg_gen_shri_i64(t64, t64, 32);
|
|
|
|
tcg_gen_trunc_i64_tl(hi, t64);
|
|
|
|
tcg_temp_free_i64(t64);
|
2012-10-16 13:32:15 +04:00
|
|
|
gen_store_gpr(dc, rd, hi);
|
2008-03-16 22:18:54 +03:00
|
|
|
}
|
|
|
|
|
2012-10-16 13:32:15 +04:00
|
|
|
static inline void gen_stda_asi(DisasContext *dc, TCGv hi, TCGv addr,
|
|
|
|
int insn, int rd)
|
2008-03-16 22:18:54 +03:00
|
|
|
{
|
2008-11-17 17:43:54 +03:00
|
|
|
TCGv_i32 r_asi, r_size;
|
2012-10-16 13:32:15 +04:00
|
|
|
TCGv lo = gen_load_gpr(dc, rd + 1);
|
2012-10-16 13:32:25 +04:00
|
|
|
TCGv_i64 t64 = tcg_temp_new_i64();
|
2008-09-21 18:49:09 +04:00
|
|
|
|
2012-10-16 13:32:25 +04:00
|
|
|
tcg_gen_concat_tl_i64(t64, lo, hi);
|
2008-05-27 23:39:12 +04:00
|
|
|
r_asi = tcg_const_i32(GET_FIELD(insn, 19, 26));
|
|
|
|
r_size = tcg_const_i32(8);
|
2012-10-16 13:32:25 +04:00
|
|
|
gen_helper_st_asi(cpu_env, addr, t64, r_asi, r_size);
|
|
|
|
tcg_temp_free_i32(r_size);
|
|
|
|
tcg_temp_free_i32(r_asi);
|
|
|
|
tcg_temp_free_i64(t64);
|
2008-02-24 17:10:06 +03:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if !defined(CONFIG_USER_ONLY) || defined(TARGET_SPARC64)
|
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 13:36:00 +04:00
|
|
|
static inline void gen_cas_asi(DisasContext *dc, TCGv addr,
|
|
|
|
TCGv val2, int insn, int rd)
|
|
|
|
{
|
|
|
|
TCGv val1 = gen_load_gpr(dc, rd);
|
|
|
|
TCGv dst = gen_dest_gpr(dc, rd);
|
|
|
|
#ifdef TARGET_SPARC64
|
|
|
|
TCGv_i32 r_asi = gen_get_asi(insn, addr);
|
|
|
|
#else
|
|
|
|
TCGv_i32 r_asi = tcg_const_i32(GET_FIELD(insn, 19, 26));
|
|
|
|
#endif
|
|
|
|
|
|
|
|
gen_helper_cas_asi(dst, cpu_env, addr, val1, val2, r_asi);
|
|
|
|
tcg_temp_free_i32(r_asi);
|
|
|
|
gen_store_gpr(dc, rd, dst);
|
|
|
|
}
|
|
|
|
|
2008-03-26 23:47:52 +03:00
|
|
|
static inline void gen_ldstub_asi(TCGv dst, TCGv addr, int insn)
|
2008-02-24 17:10:06 +03:00
|
|
|
{
|
2008-11-17 17:43:54 +03:00
|
|
|
TCGv_i64 r_val;
|
|
|
|
TCGv_i32 r_asi, r_size;
|
2008-02-24 17:10:06 +03:00
|
|
|
|
2008-03-26 23:47:52 +03:00
|
|
|
gen_ld_asi(dst, addr, insn, 1, 0);
|
2008-02-24 17:10:06 +03:00
|
|
|
|
2008-05-27 23:39:12 +04:00
|
|
|
r_val = tcg_const_i64(0xffULL);
|
|
|
|
r_asi = tcg_const_i32(GET_FIELD(insn, 19, 26));
|
|
|
|
r_size = tcg_const_i32(1);
|
2011-07-05 00:34:28 +04:00
|
|
|
gen_helper_st_asi(cpu_env, addr, r_val, r_asi, r_size);
|
2008-11-17 17:43:54 +03:00
|
|
|
tcg_temp_free_i32(r_size);
|
|
|
|
tcg_temp_free_i32(r_asi);
|
|
|
|
tcg_temp_free_i64(r_val);
|
2008-02-24 17:10:06 +03:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2012-10-16 13:32:14 +04:00
|
|
|
static TCGv get_src1(DisasContext *dc, unsigned int insn)
|
2008-03-29 23:38:35 +03:00
|
|
|
{
|
2012-10-16 13:32:14 +04:00
|
|
|
unsigned int rs1 = GET_FIELD(insn, 13, 17);
|
|
|
|
return gen_load_gpr(dc, rs1);
|
2008-03-29 23:38:35 +03:00
|
|
|
}
|
|
|
|
|
2012-10-16 13:32:14 +04:00
|
|
|
static TCGv get_src2(DisasContext *dc, unsigned int insn)
|
2008-03-29 23:39:41 +03:00
|
|
|
{
|
|
|
|
if (IS_IMM) { /* immediate */
|
2010-04-17 20:25:08 +04:00
|
|
|
target_long simm = GET_FIELDs(insn, 19, 31);
|
2012-10-16 13:32:14 +04:00
|
|
|
TCGv t = get_temp_tl(dc);
|
|
|
|
tcg_gen_movi_tl(t, simm);
|
|
|
|
return t;
|
|
|
|
} else { /* register */
|
2010-04-17 20:25:08 +04:00
|
|
|
unsigned int rs2 = GET_FIELD(insn, 27, 31);
|
2012-10-16 13:32:14 +04:00
|
|
|
return gen_load_gpr(dc, rs2);
|
2008-03-29 23:39:41 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-08-03 23:15:02 +04:00
|
|
|
#ifdef TARGET_SPARC64
|
2012-10-06 03:54:59 +04: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 21:49:53 +03:00
|
|
|
tcg_gen_extrl_i64_i32(c32, cmp->c1);
|
2012-10-06 03:54:59 +04:00
|
|
|
} else {
|
|
|
|
TCGv_i64 c64 = tcg_temp_new_i64();
|
|
|
|
tcg_gen_setcond_i64(cmp->cond, c64, cmp->c1, cmp->c2);
|
2015-07-24 21:49:53 +03:00
|
|
|
tcg_gen_extrl_i64_i32(c32, c64);
|
2012-10-06 03:54:59 +04:00
|
|
|
tcg_temp_free_i64(c64);
|
|
|
|
}
|
|
|
|
|
|
|
|
s1 = gen_load_fpr_F(dc, rs);
|
|
|
|
s2 = gen_load_fpr_F(dc, rd);
|
2012-10-16 13:32:21 +04:00
|
|
|
dst = gen_dest_fpr_F(dc);
|
2012-10-06 03:54:59 +04:00
|
|
|
zero = tcg_const_i32(0);
|
|
|
|
|
|
|
|
tcg_gen_movcond_i32(TCG_COND_NE, dst, c32, zero, s1, s2);
|
|
|
|
|
|
|
|
tcg_temp_free_i32(c32);
|
|
|
|
tcg_temp_free_i32(zero);
|
|
|
|
gen_store_fpr_F(dc, rd, dst);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void gen_fmovd(DisasContext *dc, DisasCompare *cmp, int rd, int rs)
|
|
|
|
{
|
2012-10-16 13:32:26 +04:00
|
|
|
TCGv_i64 dst = gen_dest_fpr_D(dc, rd);
|
2012-10-06 03:54:59 +04: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]);
|
|
|
|
|
|
|
|
gen_update_fprs_dirty(qd);
|
|
|
|
}
|
|
|
|
|
2014-12-24 01:11:20 +03:00
|
|
|
#ifndef CONFIG_USER_ONLY
|
2009-08-03 23:15:02 +04:00
|
|
|
static inline void gen_load_trap_state_at_tl(TCGv_ptr r_tsptr, TCGv_ptr cpu_env)
|
|
|
|
{
|
2010-02-20 13:45:23 +03:00
|
|
|
TCGv_i32 r_tl = tcg_temp_new_i32();
|
2009-08-03 23:15:02 +04:00
|
|
|
|
|
|
|
/* load env->tl into r_tl */
|
2010-02-20 13:45:23 +03:00
|
|
|
tcg_gen_ld_i32(r_tl, cpu_env, offsetof(CPUSPARCState, tl));
|
2009-08-03 23:15:02 +04:00
|
|
|
|
|
|
|
/* tl = [0 ... MAXTL_MASK] where MAXTL_MASK must be power of 2 */
|
2010-02-20 13:45:23 +03:00
|
|
|
tcg_gen_andi_i32(r_tl, r_tl, MAXTL_MASK);
|
2009-08-03 23:15:02 +04:00
|
|
|
|
|
|
|
/* calculate offset to current trap state from env->ts, reuse r_tl */
|
2010-02-20 13:45:23 +03:00
|
|
|
tcg_gen_muli_i32(r_tl, r_tl, sizeof (trap_state));
|
2012-03-14 04:38:22 +04:00
|
|
|
tcg_gen_addi_ptr(r_tsptr, cpu_env, offsetof(CPUSPARCState, ts));
|
2009-08-03 23:15:02 +04:00
|
|
|
|
|
|
|
/* tsptr = env->ts[env->tl & MAXTL_MASK] */
|
2010-02-20 13:45:23 +03: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);
|
2010-02-25 21:05:41 +03:00
|
|
|
tcg_temp_free_ptr(r_tl_tmp);
|
2010-02-20 13:45:23 +03:00
|
|
|
}
|
2009-08-03 23:15:02 +04:00
|
|
|
|
2010-02-20 13:45:23 +03:00
|
|
|
tcg_temp_free_i32(r_tl);
|
2009-08-03 23:15:02 +04:00
|
|
|
}
|
2014-12-24 01:11:20 +03:00
|
|
|
#endif
|
2011-10-18 06:57:23 +04:00
|
|
|
|
|
|
|
static void gen_edge(DisasContext *dc, TCGv dst, TCGv s1, TCGv s2,
|
|
|
|
int width, bool cc, bool left)
|
|
|
|
{
|
|
|
|
TCGv lo1, lo2, t1, t2;
|
|
|
|
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);
|
|
|
|
|
|
|
|
t1 = tcg_const_tl(tabl);
|
|
|
|
t2 = tcg_const_tl(tabr);
|
|
|
|
tcg_gen_shr_tl(lo1, t1, lo1);
|
|
|
|
tcg_gen_shr_tl(lo2, t2, lo2);
|
|
|
|
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
|
|
|
|
*/
|
|
|
|
tcg_gen_setcond_tl(TCG_COND_EQ, t1, s1, s2);
|
|
|
|
tcg_gen_neg_tl(t1, t1);
|
|
|
|
tcg_gen_or_tl(lo2, lo2, t1);
|
|
|
|
tcg_gen_and_tl(dst, dst, lo2);
|
|
|
|
|
|
|
|
tcg_temp_free(lo1);
|
|
|
|
tcg_temp_free(lo2);
|
|
|
|
tcg_temp_free(t1);
|
|
|
|
tcg_temp_free(t2);
|
|
|
|
}
|
2011-10-18 19:35:58 +04: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);
|
|
|
|
|
|
|
|
tcg_temp_free(tmp);
|
|
|
|
}
|
2011-10-18 20:41:30 +04: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);
|
|
|
|
|
|
|
|
tcg_temp_free(t1);
|
|
|
|
tcg_temp_free(t2);
|
|
|
|
tcg_temp_free(shift);
|
|
|
|
}
|
2009-08-03 23:15:02 +04:00
|
|
|
#endif
|
|
|
|
|
2008-05-10 00:13:43 +04:00
|
|
|
#define CHECK_IU_FEATURE(dc, FEATURE) \
|
2008-08-21 21:33:42 +04:00
|
|
|
if (!((dc)->def->features & CPU_FEATURE_ ## FEATURE)) \
|
2008-05-10 00:13:43 +04:00
|
|
|
goto illegal_insn;
|
|
|
|
#define CHECK_FPU_FEATURE(dc, FEATURE) \
|
2008-08-21 21:33:42 +04:00
|
|
|
if (!((dc)->def->features & CPU_FEATURE_ ## FEATURE)) \
|
2008-05-10 00:13:43 +04:00
|
|
|
goto nfpu_insn;
|
|
|
|
|
2005-02-13 23:11:30 +03:00
|
|
|
/* before an instruction, dc->pc must be static */
|
2011-08-01 16:19:05 +04:00
|
|
|
static void disas_sparc_insn(DisasContext * dc, unsigned int insn)
|
2004-01-04 18:01:44 +03:00
|
|
|
{
|
2011-08-01 16:19:05 +04:00
|
|
|
unsigned int opc, rs1, rs2, rd;
|
2012-10-16 13:32:18 +04:00
|
|
|
TCGv cpu_src1, cpu_src2;
|
2011-10-15 01:58:32 +04:00
|
|
|
TCGv_i32 cpu_src1_32, cpu_src2_32, cpu_dst_32;
|
2011-10-15 02:47:35 +04:00
|
|
|
TCGv_i64 cpu_src1_64, cpu_src2_64, cpu_dst_64;
|
2009-05-02 22:58:57 +04:00
|
|
|
target_long simm;
|
2003-10-01 00:36:07 +04:00
|
|
|
|
2004-01-04 18:01:44 +03:00
|
|
|
opc = GET_FIELD(insn, 0, 1);
|
|
|
|
rd = GET_FIELD(insn, 2, 6);
|
2008-03-29 12:09:25 +03:00
|
|
|
|
2004-01-04 18:01:44 +03:00
|
|
|
switch (opc) {
|
2007-09-20 18:54:22 +04:00
|
|
|
case 0: /* branches/sethi */
|
|
|
|
{
|
|
|
|
unsigned int xop = GET_FIELD(insn, 7, 9);
|
|
|
|
int32_t target;
|
|
|
|
switch (xop) {
|
2005-07-02 18:31:34 +04:00
|
|
|
#ifdef TARGET_SPARC64
|
2007-09-20 18:54:22 +04:00
|
|
|
case 0x1: /* V9 BPcc */
|
|
|
|
{
|
|
|
|
int cc;
|
|
|
|
|
|
|
|
target = GET_FIELD_SP(insn, 0, 18);
|
2011-05-14 11:14:57 +04:00
|
|
|
target = sign_extend(target, 19);
|
2007-09-20 18:54:22 +04:00
|
|
|
target <<= 2;
|
|
|
|
cc = GET_FIELD_SP(insn, 20, 21);
|
|
|
|
if (cc == 0)
|
2012-10-06 03:54:50 +04:00
|
|
|
do_branch(dc, target, insn, 0);
|
2007-09-20 18:54:22 +04:00
|
|
|
else if (cc == 2)
|
2012-10-06 03:54:50 +04:00
|
|
|
do_branch(dc, target, insn, 1);
|
2007-09-20 18:54:22 +04:00
|
|
|
else
|
|
|
|
goto illegal_insn;
|
|
|
|
goto jmp_insn;
|
|
|
|
}
|
|
|
|
case 0x3: /* V9 BPr */
|
|
|
|
{
|
|
|
|
target = GET_FIELD_SP(insn, 0, 13) |
|
2006-06-24 01:01:56 +04:00
|
|
|
(GET_FIELD_SP(insn, 20, 21) << 14);
|
2007-09-20 18:54:22 +04:00
|
|
|
target = sign_extend(target, 16);
|
|
|
|
target <<= 2;
|
2012-10-16 13:32:14 +04:00
|
|
|
cpu_src1 = get_src1(dc, insn);
|
2012-10-06 03:54:50 +04:00
|
|
|
do_branch_reg(dc, target, insn, cpu_src1);
|
2007-09-20 18:54:22 +04:00
|
|
|
goto jmp_insn;
|
|
|
|
}
|
|
|
|
case 0x5: /* V9 FBPcc */
|
|
|
|
{
|
|
|
|
int cc = GET_FIELD_SP(insn, 20, 21);
|
2012-10-06 03:54:52 +04:00
|
|
|
if (gen_trap_ifnofpu(dc)) {
|
2006-06-26 23:53:29 +04:00
|
|
|
goto jmp_insn;
|
2012-10-06 03:54:52 +04:00
|
|
|
}
|
2007-09-20 18:54:22 +04:00
|
|
|
target = GET_FIELD_SP(insn, 0, 18);
|
|
|
|
target = sign_extend(target, 19);
|
|
|
|
target <<= 2;
|
2012-10-06 03:54:50 +04:00
|
|
|
do_fbranch(dc, target, insn, cc);
|
2007-09-20 18:54:22 +04:00
|
|
|
goto jmp_insn;
|
|
|
|
}
|
2007-04-05 22:09:15 +04:00
|
|
|
#else
|
2007-09-20 18:54:22 +04: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 03:54:50 +04:00
|
|
|
do_branch(dc, target, insn, 0);
|
2007-09-20 18:54:22 +04:00
|
|
|
goto jmp_insn;
|
|
|
|
}
|
|
|
|
case 0x6: /* FBN+x */
|
|
|
|
{
|
2012-10-06 03:54:52 +04:00
|
|
|
if (gen_trap_ifnofpu(dc)) {
|
2006-06-26 23:53:29 +04:00
|
|
|
goto jmp_insn;
|
2012-10-06 03:54:52 +04:00
|
|
|
}
|
2007-09-20 18:54:22 +04:00
|
|
|
target = GET_FIELD(insn, 10, 31);
|
|
|
|
target = sign_extend(target, 22);
|
|
|
|
target <<= 2;
|
2012-10-06 03:54:50 +04:00
|
|
|
do_fbranch(dc, target, insn, 0);
|
2007-09-20 18:54:22 +04:00
|
|
|
goto jmp_insn;
|
|
|
|
}
|
|
|
|
case 0x4: /* SETHI */
|
2012-10-16 13:32:13 +04:00
|
|
|
/* Special-case %g0 because that's the canonical nop. */
|
|
|
|
if (rd) {
|
2007-09-20 18:54:22 +04:00
|
|
|
uint32_t value = GET_FIELD(insn, 10, 31);
|
2012-10-16 13:32:13 +04:00
|
|
|
TCGv t = gen_dest_gpr(dc, rd);
|
|
|
|
tcg_gen_movi_tl(t, value << 10);
|
|
|
|
gen_store_gpr(dc, rd, t);
|
2007-09-20 18:54:22 +04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0x0: /* UNIMPL */
|
|
|
|
default:
|
2005-07-02 18:31:34 +04:00
|
|
|
goto illegal_insn;
|
2007-09-20 18:54:22 +04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
2009-05-03 22:51:22 +04:00
|
|
|
case 1: /*CALL*/
|
|
|
|
{
|
2007-09-20 18:54:22 +04:00
|
|
|
target_long target = GET_FIELDs(insn, 2, 31) << 2;
|
2012-10-16 13:32:13 +04:00
|
|
|
TCGv o7 = gen_dest_gpr(dc, 15);
|
2004-01-04 18:01:44 +03:00
|
|
|
|
2012-10-16 13:32:13 +04:00
|
|
|
tcg_gen_movi_tl(o7, dc->pc);
|
|
|
|
gen_store_gpr(dc, 15, o7);
|
2007-09-20 18:54:22 +04:00
|
|
|
target += dc->pc;
|
2012-10-06 03:54:54 +04:00
|
|
|
gen_mov_pc_npc(dc);
|
2012-05-12 13:15:20 +04:00
|
|
|
#ifdef TARGET_SPARC64
|
|
|
|
if (unlikely(AM_CHECK(dc))) {
|
|
|
|
target &= 0xffffffffULL;
|
|
|
|
}
|
|
|
|
#endif
|
2007-09-20 18:54:22 +04:00
|
|
|
dc->npc = target;
|
|
|
|
}
|
|
|
|
goto jmp_insn;
|
|
|
|
case 2: /* FPU & Logical Operations */
|
|
|
|
{
|
|
|
|
unsigned int xop = GET_FIELD(insn, 7, 12);
|
2012-10-29 08:50:20 +04:00
|
|
|
TCGv cpu_dst = get_temp_tl(dc);
|
2012-10-16 13:32:31 +04:00
|
|
|
TCGv cpu_tmp0;
|
2012-10-16 13:32:30 +04:00
|
|
|
|
2007-09-20 18:54:22 +04:00
|
|
|
if (xop == 0x3a) { /* generate trap */
|
2012-10-06 03:55:04 +04:00
|
|
|
int cond = GET_FIELD(insn, 3, 6);
|
|
|
|
TCGv_i32 trap;
|
2015-02-13 23:51:55 +03:00
|
|
|
TCGLabel *l1 = NULL;
|
|
|
|
int mask;
|
2005-07-02 18:31:34 +04:00
|
|
|
|
2012-10-06 03:55:04 +04:00
|
|
|
if (cond == 0) {
|
|
|
|
/* Trap never. */
|
|
|
|
break;
|
2004-01-04 18:01:44 +03:00
|
|
|
}
|
2011-01-24 14:56:55 +03:00
|
|
|
|
2012-10-06 03:55:04 +04:00
|
|
|
save_state(dc);
|
2011-01-24 14:56:55 +03:00
|
|
|
|
2012-10-06 03:55:04 +04:00
|
|
|
if (cond != 8) {
|
|
|
|
/* Conditional trap. */
|
2012-10-06 03:54:58 +04:00
|
|
|
DisasCompare cmp;
|
2005-07-02 18:31:34 +04:00
|
|
|
#ifdef TARGET_SPARC64
|
2007-09-20 18:54:22 +04:00
|
|
|
/* V9 icc/xcc */
|
|
|
|
int cc = GET_FIELD_SP(insn, 11, 12);
|
2012-10-06 03:54:58 +04:00
|
|
|
if (cc == 0) {
|
|
|
|
gen_compare(&cmp, 0, cond, dc);
|
|
|
|
} else if (cc == 2) {
|
|
|
|
gen_compare(&cmp, 1, cond, dc);
|
|
|
|
} else {
|
2007-09-20 18:54:22 +04:00
|
|
|
goto illegal_insn;
|
2012-10-06 03:54:58 +04:00
|
|
|
}
|
2005-07-02 18:31:34 +04:00
|
|
|
#else
|
2012-10-06 03:54:58 +04:00
|
|
|
gen_compare(&cmp, 0, cond, dc);
|
2005-07-02 18:31:34 +04:00
|
|
|
#endif
|
2008-09-26 22:05:23 +04:00
|
|
|
l1 = gen_new_label();
|
2012-10-06 03:54:58 +04:00
|
|
|
tcg_gen_brcond_tl(tcg_invert_cond(cmp.cond),
|
|
|
|
cmp.c1, cmp.c2, l1);
|
|
|
|
free_compare(&cmp);
|
2012-10-06 03:55:04 +04:00
|
|
|
}
|
2008-09-26 22:05:23 +04:00
|
|
|
|
2012-10-06 03:55:04 +04: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) {
|
|
|
|
rs2 = GET_FIELD_SP(insn, 0, 6);
|
|
|
|
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 13:32:13 +04:00
|
|
|
TCGv t1 = gen_load_gpr(dc, rs1);
|
2012-10-06 03:55:04 +04:00
|
|
|
tcg_gen_trunc_tl_i32(trap, t1);
|
|
|
|
tcg_gen_addi_i32(trap, trap, rs2);
|
|
|
|
}
|
|
|
|
} else {
|
2012-10-16 13:32:13 +04:00
|
|
|
TCGv t1, t2;
|
2012-10-06 03:55:04 +04:00
|
|
|
rs2 = GET_FIELD_SP(insn, 0, 4);
|
2012-10-16 13:32:13 +04:00
|
|
|
t1 = gen_load_gpr(dc, rs1);
|
|
|
|
t2 = gen_load_gpr(dc, rs2);
|
2012-10-06 03:55:04 +04: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);
|
|
|
|
tcg_temp_free_i32(trap);
|
2008-09-26 22:05:23 +04:00
|
|
|
|
2012-10-06 03:55:09 +04:00
|
|
|
if (cond == 8) {
|
|
|
|
/* An unconditional trap ends the TB. */
|
|
|
|
dc->is_br = 1;
|
|
|
|
goto jmp_insn;
|
|
|
|
} else {
|
|
|
|
/* A conditional trap falls through to the next insn. */
|
2008-09-26 22:05:23 +04:00
|
|
|
gen_set_label(l1);
|
2012-10-06 03:55:09 +04:00
|
|
|
break;
|
2004-01-04 18:01:44 +03:00
|
|
|
}
|
|
|
|
} else if (xop == 0x28) {
|
|
|
|
rs1 = GET_FIELD(insn, 13, 17);
|
|
|
|
switch(rs1) {
|
|
|
|
case 0: /* rdy */
|
2007-04-01 19:05:09 +04: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 14:56:56 +03:00
|
|
|
/* Read Asr17 */
|
|
|
|
if (rs1 == 0x11 && dc->def->features & CPU_FEATURE_ASR17) {
|
2012-10-16 13:32:13 +04:00
|
|
|
TCGv t = gen_dest_gpr(dc, rd);
|
2011-01-24 14:56:56 +03:00
|
|
|
/* Read Asr17 for a Leon3 monoprocessor */
|
2012-10-16 13:32:13 +04:00
|
|
|
tcg_gen_movi_tl(t, (1 << 8) | (dc->def->nwindows - 1));
|
|
|
|
gen_store_gpr(dc, rd, t);
|
2011-01-24 14:56:56 +03:00
|
|
|
break;
|
|
|
|
}
|
2007-04-01 19:05:09 +04:00
|
|
|
#endif
|
2012-10-16 13:32:13 +04:00
|
|
|
gen_store_gpr(dc, rd, cpu_y);
|
2004-01-04 18:01:44 +03:00
|
|
|
break;
|
2005-07-02 18:31:34 +04:00
|
|
|
#ifdef TARGET_SPARC64
|
2007-09-20 18:54:22 +04:00
|
|
|
case 0x2: /* V9 rdccr */
|
2012-10-10 01:50:00 +04:00
|
|
|
update_psr(dc);
|
2011-07-04 01:01:59 +04:00
|
|
|
gen_helper_rdccr(cpu_dst, cpu_env);
|
2012-10-16 13:32:13 +04:00
|
|
|
gen_store_gpr(dc, rd, cpu_dst);
|
2005-07-02 18:31:34 +04:00
|
|
|
break;
|
2007-09-20 18:54:22 +04:00
|
|
|
case 0x3: /* V9 rdasi */
|
2008-09-06 21:51:43 +04:00
|
|
|
tcg_gen_ext_i32_tl(cpu_dst, cpu_asi);
|
2012-10-16 13:32:13 +04:00
|
|
|
gen_store_gpr(dc, rd, cpu_dst);
|
2005-07-02 18:31:34 +04:00
|
|
|
break;
|
2007-09-20 18:54:22 +04:00
|
|
|
case 0x4: /* V9 rdtick */
|
2008-03-02 21:28:06 +03:00
|
|
|
{
|
2008-11-17 17:43:54 +03:00
|
|
|
TCGv_ptr r_tickptr;
|
2015-11-08 20:11:59 +03:00
|
|
|
TCGv_i32 r_const;
|
2008-03-02 21:28:06 +03:00
|
|
|
|
2008-11-17 17:43:54 +03:00
|
|
|
r_tickptr = tcg_temp_new_ptr();
|
2015-11-08 20:11:59 +03:00
|
|
|
r_const = tcg_const_i32(dc->mem_idx);
|
2008-03-02 21:28:06 +03:00
|
|
|
tcg_gen_ld_ptr(r_tickptr, cpu_env,
|
2012-03-14 04:38:22 +04:00
|
|
|
offsetof(CPUSPARCState, tick));
|
2015-11-08 20:11:59 +03:00
|
|
|
gen_helper_tick_get_count(cpu_dst, cpu_env, r_tickptr,
|
|
|
|
r_const);
|
2008-11-17 17:43:54 +03:00
|
|
|
tcg_temp_free_ptr(r_tickptr);
|
2015-11-08 20:11:59 +03:00
|
|
|
tcg_temp_free_i32(r_const);
|
2012-10-16 13:32:13 +04:00
|
|
|
gen_store_gpr(dc, rd, cpu_dst);
|
2008-03-02 21:28:06 +03:00
|
|
|
}
|
2005-07-02 18:31:34 +04:00
|
|
|
break;
|
2007-09-20 18:54:22 +04:00
|
|
|
case 0x5: /* V9 rdpc */
|
2008-05-27 23:39:12 +04:00
|
|
|
{
|
2012-10-16 13:32:13 +04:00
|
|
|
TCGv t = gen_dest_gpr(dc, rd);
|
2012-05-12 13:15:20 +04:00
|
|
|
if (unlikely(AM_CHECK(dc))) {
|
2012-10-16 13:32:13 +04:00
|
|
|
tcg_gen_movi_tl(t, dc->pc & 0xffffffffULL);
|
2012-05-12 13:15:20 +04:00
|
|
|
} else {
|
2012-10-16 13:32:13 +04:00
|
|
|
tcg_gen_movi_tl(t, dc->pc);
|
2012-05-12 13:15:20 +04:00
|
|
|
}
|
2012-10-16 13:32:13 +04:00
|
|
|
gen_store_gpr(dc, rd, t);
|
2008-05-27 23:39:12 +04:00
|
|
|
}
|
2007-09-20 18:54:22 +04:00
|
|
|
break;
|
|
|
|
case 0x6: /* V9 rdfprs */
|
2008-09-06 21:51:43 +04:00
|
|
|
tcg_gen_ext_i32_tl(cpu_dst, cpu_fprs);
|
2012-10-16 13:32:13 +04:00
|
|
|
gen_store_gpr(dc, rd, cpu_dst);
|
2005-07-02 18:31:34 +04:00
|
|
|
break;
|
2007-04-01 19:05:09 +04:00
|
|
|
case 0xf: /* V9 membar */
|
|
|
|
break; /* no effect */
|
2007-09-20 18:54:22 +04:00
|
|
|
case 0x13: /* Graphics Status */
|
2012-10-06 03:54:52 +04:00
|
|
|
if (gen_trap_ifnofpu(dc)) {
|
2006-07-19 01:12:17 +04:00
|
|
|
goto jmp_insn;
|
2012-10-06 03:54:52 +04:00
|
|
|
}
|
2012-10-16 13:32:13 +04:00
|
|
|
gen_store_gpr(dc, rd, cpu_gsr);
|
2006-07-19 01:12:17 +04:00
|
|
|
break;
|
2008-09-22 23:50:28 +04:00
|
|
|
case 0x16: /* Softint */
|
|
|
|
tcg_gen_ext_i32_tl(cpu_dst, cpu_softint);
|
2012-10-16 13:32:13 +04:00
|
|
|
gen_store_gpr(dc, rd, cpu_dst);
|
2008-09-22 23:50:28 +04:00
|
|
|
break;
|
2007-09-20 18:54:22 +04:00
|
|
|
case 0x17: /* Tick compare */
|
2012-10-16 13:32:13 +04:00
|
|
|
gen_store_gpr(dc, rd, cpu_tick_cmpr);
|
2005-07-23 18:27:54 +04:00
|
|
|
break;
|
2007-09-20 18:54:22 +04:00
|
|
|
case 0x18: /* System tick */
|
2008-03-02 21:28:06 +03:00
|
|
|
{
|
2008-11-17 17:43:54 +03:00
|
|
|
TCGv_ptr r_tickptr;
|
2015-11-08 20:11:59 +03:00
|
|
|
TCGv_i32 r_const;
|
2008-03-02 21:28:06 +03:00
|
|
|
|
2008-11-17 17:43:54 +03:00
|
|
|
r_tickptr = tcg_temp_new_ptr();
|
2015-11-08 20:11:59 +03:00
|
|
|
r_const = tcg_const_i32(dc->mem_idx);
|
2008-03-02 21:28:06 +03:00
|
|
|
tcg_gen_ld_ptr(r_tickptr, cpu_env,
|
2012-03-14 04:38:22 +04:00
|
|
|
offsetof(CPUSPARCState, stick));
|
2015-11-08 20:11:59 +03:00
|
|
|
gen_helper_tick_get_count(cpu_dst, cpu_env, r_tickptr,
|
|
|
|
r_const);
|
2008-11-17 17:43:54 +03:00
|
|
|
tcg_temp_free_ptr(r_tickptr);
|
2015-11-08 20:11:59 +03:00
|
|
|
tcg_temp_free_i32(r_const);
|
2012-10-16 13:32:13 +04:00
|
|
|
gen_store_gpr(dc, rd, cpu_dst);
|
2008-03-02 21:28:06 +03:00
|
|
|
}
|
2005-07-23 18:27:54 +04:00
|
|
|
break;
|
2007-09-20 18:54:22 +04:00
|
|
|
case 0x19: /* System tick compare */
|
2012-10-16 13:32:13 +04:00
|
|
|
gen_store_gpr(dc, rd, cpu_stick_cmpr);
|
2005-07-23 18:27:54 +04:00
|
|
|
break;
|
2007-09-20 18:54:22 +04: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 18:31:34 +04:00
|
|
|
#endif
|
|
|
|
default:
|
2004-01-04 18:01:44 +03:00
|
|
|
goto illegal_insn;
|
|
|
|
}
|
2004-10-01 01:55:55 +04:00
|
|
|
#if !defined(CONFIG_USER_ONLY)
|
2007-04-22 23:14:52 +04:00
|
|
|
} else if (xop == 0x29) { /* rdpsr / UA2005 rdhpr */
|
2005-07-02 18:31:34 +04:00
|
|
|
#ifndef TARGET_SPARC64
|
2012-10-10 01:50:00 +04:00
|
|
|
if (!supervisor(dc)) {
|
2007-09-20 18:54:22 +04:00
|
|
|
goto priv_insn;
|
2012-10-10 01:50:00 +04:00
|
|
|
}
|
|
|
|
update_psr(dc);
|
2011-07-04 01:01:59 +04:00
|
|
|
gen_helper_rdpsr(cpu_dst, cpu_env);
|
2007-04-22 23:14:52 +04:00
|
|
|
#else
|
2008-07-20 22:22:16 +04:00
|
|
|
CHECK_IU_FEATURE(dc, HYPV);
|
2007-04-22 23:14:52 +04:00
|
|
|
if (!hypervisor(dc))
|
|
|
|
goto priv_insn;
|
|
|
|
rs1 = GET_FIELD(insn, 13, 17);
|
|
|
|
switch (rs1) {
|
|
|
|
case 0: // hpstate
|
|
|
|
// gen_op_rdhpstate();
|
|
|
|
break;
|
|
|
|
case 1: // htstate
|
|
|
|
// gen_op_rdhtstate();
|
|
|
|
break;
|
|
|
|
case 3: // hintp
|
2008-09-06 21:51:43 +04:00
|
|
|
tcg_gen_mov_tl(cpu_dst, cpu_hintp);
|
2007-04-22 23:14:52 +04:00
|
|
|
break;
|
|
|
|
case 5: // htba
|
2008-09-06 21:51:43 +04:00
|
|
|
tcg_gen_mov_tl(cpu_dst, cpu_htba);
|
2007-04-22 23:14:52 +04:00
|
|
|
break;
|
|
|
|
case 6: // hver
|
2008-09-06 21:51:43 +04:00
|
|
|
tcg_gen_mov_tl(cpu_dst, cpu_hver);
|
2007-04-22 23:14:52 +04:00
|
|
|
break;
|
|
|
|
case 31: // hstick_cmpr
|
2008-09-06 21:51:43 +04:00
|
|
|
tcg_gen_mov_tl(cpu_dst, cpu_hstick_cmpr);
|
2007-04-22 23:14:52 +04:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
goto illegal_insn;
|
|
|
|
}
|
|
|
|
#endif
|
2012-10-16 13:32:13 +04:00
|
|
|
gen_store_gpr(dc, rd, cpu_dst);
|
2004-10-01 01:55:55 +04:00
|
|
|
break;
|
2005-07-02 18:31:34 +04:00
|
|
|
} else if (xop == 0x2a) { /* rdwim / V9 rdpr */
|
2012-10-16 13:32:31 +04:00
|
|
|
if (!supervisor(dc)) {
|
2007-09-20 18:54:22 +04:00
|
|
|
goto priv_insn;
|
2012-10-16 13:32:31 +04:00
|
|
|
}
|
|
|
|
cpu_tmp0 = get_temp_tl(dc);
|
2005-07-02 18:31:34 +04:00
|
|
|
#ifdef TARGET_SPARC64
|
|
|
|
rs1 = GET_FIELD(insn, 13, 17);
|
2007-09-20 18:54:22 +04:00
|
|
|
switch (rs1) {
|
|
|
|
case 0: // tpc
|
2008-03-05 20:59:48 +03:00
|
|
|
{
|
2008-11-17 17:43:54 +03:00
|
|
|
TCGv_ptr r_tsptr;
|
2008-03-05 20:59:48 +03:00
|
|
|
|
2008-11-17 17:43:54 +03:00
|
|
|
r_tsptr = tcg_temp_new_ptr();
|
2009-08-03 23:15:02 +04:00
|
|
|
gen_load_trap_state_at_tl(r_tsptr, cpu_env);
|
2008-11-17 17:43:54 +03:00
|
|
|
tcg_gen_ld_tl(cpu_tmp0, r_tsptr,
|
2008-03-05 20:59:48 +03:00
|
|
|
offsetof(trap_state, tpc));
|
2008-11-17 17:43:54 +03:00
|
|
|
tcg_temp_free_ptr(r_tsptr);
|
2008-03-05 20:59:48 +03:00
|
|
|
}
|
2007-09-20 18:54:22 +04:00
|
|
|
break;
|
|
|
|
case 1: // tnpc
|
2008-03-05 20:59:48 +03:00
|
|
|
{
|
2008-11-17 17:43:54 +03:00
|
|
|
TCGv_ptr r_tsptr;
|
2008-03-05 20:59:48 +03:00
|
|
|
|
2008-11-17 17:43:54 +03:00
|
|
|
r_tsptr = tcg_temp_new_ptr();
|
2009-08-03 23:15:02 +04:00
|
|
|
gen_load_trap_state_at_tl(r_tsptr, cpu_env);
|
2008-06-21 23:50:10 +04:00
|
|
|
tcg_gen_ld_tl(cpu_tmp0, r_tsptr,
|
2008-03-05 20:59:48 +03:00
|
|
|
offsetof(trap_state, tnpc));
|
2008-11-17 17:43:54 +03:00
|
|
|
tcg_temp_free_ptr(r_tsptr);
|
2008-03-05 20:59:48 +03:00
|
|
|
}
|
2007-09-20 18:54:22 +04:00
|
|
|
break;
|
|
|
|
case 2: // tstate
|
2008-03-05 20:59:48 +03:00
|
|
|
{
|
2008-11-17 17:43:54 +03:00
|
|
|
TCGv_ptr r_tsptr;
|
2008-03-05 20:59:48 +03:00
|
|
|
|
2008-11-17 17:43:54 +03:00
|
|
|
r_tsptr = tcg_temp_new_ptr();
|
2009-08-03 23:15:02 +04:00
|
|
|
gen_load_trap_state_at_tl(r_tsptr, cpu_env);
|
2008-06-21 23:50:10 +04:00
|
|
|
tcg_gen_ld_tl(cpu_tmp0, r_tsptr,
|
2008-03-05 20:59:48 +03:00
|
|
|
offsetof(trap_state, tstate));
|
2008-11-17 17:43:54 +03:00
|
|
|
tcg_temp_free_ptr(r_tsptr);
|
2008-03-05 20:59:48 +03:00
|
|
|
}
|
2007-09-20 18:54:22 +04:00
|
|
|
break;
|
|
|
|
case 3: // tt
|
2008-03-05 20:59:48 +03:00
|
|
|
{
|
2012-10-16 13:32:22 +04:00
|
|
|
TCGv_ptr r_tsptr = tcg_temp_new_ptr();
|
2008-03-05 20:59:48 +03:00
|
|
|
|
2009-08-03 23:15:02 +04:00
|
|
|
gen_load_trap_state_at_tl(r_tsptr, cpu_env);
|
2012-10-16 13:32:22 +04:00
|
|
|
tcg_gen_ld32s_tl(cpu_tmp0, r_tsptr,
|
|
|
|
offsetof(trap_state, tt));
|
2008-11-17 17:43:54 +03:00
|
|
|
tcg_temp_free_ptr(r_tsptr);
|
2008-03-05 20:59:48 +03:00
|
|
|
}
|
2007-09-20 18:54:22 +04:00
|
|
|
break;
|
|
|
|
case 4: // tick
|
2008-03-02 21:28:06 +03:00
|
|
|
{
|
2008-11-17 17:43:54 +03:00
|
|
|
TCGv_ptr r_tickptr;
|
2015-11-08 20:11:59 +03:00
|
|
|
TCGv_i32 r_const;
|
2008-03-02 21:28:06 +03:00
|
|
|
|
2008-11-17 17:43:54 +03:00
|
|
|
r_tickptr = tcg_temp_new_ptr();
|
2015-11-08 20:11:59 +03:00
|
|
|
r_const = tcg_const_i32(dc->mem_idx);
|
2008-03-02 21:28:06 +03:00
|
|
|
tcg_gen_ld_ptr(r_tickptr, cpu_env,
|
2012-03-14 04:38:22 +04:00
|
|
|
offsetof(CPUSPARCState, tick));
|
2015-11-08 20:11:59 +03:00
|
|
|
gen_helper_tick_get_count(cpu_tmp0, cpu_env,
|
|
|
|
r_tickptr, r_const);
|
2008-11-17 17:43:54 +03:00
|
|
|
tcg_temp_free_ptr(r_tickptr);
|
2015-11-08 20:11:59 +03:00
|
|
|
tcg_temp_free_i32(r_const);
|
2008-03-02 21:28:06 +03:00
|
|
|
}
|
2007-09-20 18:54:22 +04:00
|
|
|
break;
|
|
|
|
case 5: // tba
|
2008-09-06 21:51:43 +04:00
|
|
|
tcg_gen_mov_tl(cpu_tmp0, cpu_tbr);
|
2007-09-20 18:54:22 +04:00
|
|
|
break;
|
|
|
|
case 6: // pstate
|
2012-10-16 13:32:22 +04:00
|
|
|
tcg_gen_ld32s_tl(cpu_tmp0, cpu_env,
|
|
|
|
offsetof(CPUSPARCState, pstate));
|
2007-09-20 18:54:22 +04:00
|
|
|
break;
|
|
|
|
case 7: // tl
|
2012-10-16 13:32:22 +04:00
|
|
|
tcg_gen_ld32s_tl(cpu_tmp0, cpu_env,
|
|
|
|
offsetof(CPUSPARCState, tl));
|
2007-09-20 18:54:22 +04:00
|
|
|
break;
|
|
|
|
case 8: // pil
|
2012-10-16 13:32:22 +04:00
|
|
|
tcg_gen_ld32s_tl(cpu_tmp0, cpu_env,
|
|
|
|
offsetof(CPUSPARCState, psrpil));
|
2007-09-20 18:54:22 +04:00
|
|
|
break;
|
|
|
|
case 9: // cwp
|
2011-07-04 01:01:59 +04:00
|
|
|
gen_helper_rdcwp(cpu_tmp0, cpu_env);
|
2007-09-20 18:54:22 +04:00
|
|
|
break;
|
|
|
|
case 10: // cansave
|
2012-10-16 13:32:22 +04:00
|
|
|
tcg_gen_ld32s_tl(cpu_tmp0, cpu_env,
|
|
|
|
offsetof(CPUSPARCState, cansave));
|
2007-09-20 18:54:22 +04:00
|
|
|
break;
|
|
|
|
case 11: // canrestore
|
2012-10-16 13:32:22 +04:00
|
|
|
tcg_gen_ld32s_tl(cpu_tmp0, cpu_env,
|
|
|
|
offsetof(CPUSPARCState, canrestore));
|
2007-09-20 18:54:22 +04:00
|
|
|
break;
|
|
|
|
case 12: // cleanwin
|
2012-10-16 13:32:22 +04:00
|
|
|
tcg_gen_ld32s_tl(cpu_tmp0, cpu_env,
|
|
|
|
offsetof(CPUSPARCState, cleanwin));
|
2007-09-20 18:54:22 +04:00
|
|
|
break;
|
|
|
|
case 13: // otherwin
|
2012-10-16 13:32:22 +04:00
|
|
|
tcg_gen_ld32s_tl(cpu_tmp0, cpu_env,
|
|
|
|
offsetof(CPUSPARCState, otherwin));
|
2007-09-20 18:54:22 +04:00
|
|
|
break;
|
|
|
|
case 14: // wstate
|
2012-10-16 13:32:22 +04:00
|
|
|
tcg_gen_ld32s_tl(cpu_tmp0, cpu_env,
|
|
|
|
offsetof(CPUSPARCState, wstate));
|
2007-09-20 18:54:22 +04:00
|
|
|
break;
|
2007-04-22 23:14:52 +04:00
|
|
|
case 16: // UA2005 gl
|
2008-07-20 22:22:16 +04:00
|
|
|
CHECK_IU_FEATURE(dc, GL);
|
2012-10-16 13:32:22 +04:00
|
|
|
tcg_gen_ld32s_tl(cpu_tmp0, cpu_env,
|
|
|
|
offsetof(CPUSPARCState, gl));
|
2007-04-22 23:14:52 +04:00
|
|
|
break;
|
|
|
|
case 26: // UA2005 strand status
|
2008-07-20 22:22:16 +04:00
|
|
|
CHECK_IU_FEATURE(dc, HYPV);
|
2007-04-22 23:14:52 +04:00
|
|
|
if (!hypervisor(dc))
|
|
|
|
goto priv_insn;
|
2008-11-01 16:44:52 +03:00
|
|
|
tcg_gen_mov_tl(cpu_tmp0, cpu_ssr);
|
2007-04-22 23:14:52 +04:00
|
|
|
break;
|
2007-09-20 18:54:22 +04:00
|
|
|
case 31: // ver
|
2008-09-06 21:51:43 +04:00
|
|
|
tcg_gen_mov_tl(cpu_tmp0, cpu_ver);
|
2007-09-20 18:54:22 +04:00
|
|
|
break;
|
|
|
|
case 15: // fq
|
|
|
|
default:
|
|
|
|
goto illegal_insn;
|
|
|
|
}
|
2005-07-02 18:31:34 +04:00
|
|
|
#else
|
2008-09-06 21:51:43 +04:00
|
|
|
tcg_gen_ext_i32_tl(cpu_tmp0, cpu_wim);
|
2005-07-02 18:31:34 +04:00
|
|
|
#endif
|
2012-10-16 13:32:13 +04:00
|
|
|
gen_store_gpr(dc, rd, cpu_tmp0);
|
2004-10-01 01:55:55 +04:00
|
|
|
break;
|
2005-07-02 18:31:34 +04:00
|
|
|
} else if (xop == 0x2b) { /* rdtbr / V9 flushw */
|
|
|
|
#ifdef TARGET_SPARC64
|
2012-10-06 03:54:53 +04:00
|
|
|
save_state(dc);
|
2011-07-04 01:01:59 +04:00
|
|
|
gen_helper_flushw(cpu_env);
|
2005-07-02 18:31:34 +04:00
|
|
|
#else
|
2007-09-20 18:54:22 +04:00
|
|
|
if (!supervisor(dc))
|
|
|
|
goto priv_insn;
|
2012-10-16 13:32:13 +04:00
|
|
|
gen_store_gpr(dc, rd, cpu_tbr);
|
2005-07-02 18:31:34 +04:00
|
|
|
#endif
|
2004-10-01 01:55:55 +04:00
|
|
|
break;
|
|
|
|
#endif
|
2007-09-20 18:54:22 +04:00
|
|
|
} else if (xop == 0x34) { /* FPU Operations */
|
2012-10-06 03:54:52 +04:00
|
|
|
if (gen_trap_ifnofpu(dc)) {
|
2006-06-26 23:53:29 +04:00
|
|
|
goto jmp_insn;
|
2012-10-06 03:54:52 +04:00
|
|
|
}
|
2007-09-20 18:54:22 +04:00
|
|
|
gen_op_clear_ieee_excp_and_FTT();
|
2004-10-01 01:55:55 +04:00
|
|
|
rs1 = GET_FIELD(insn, 13, 17);
|
2007-09-20 18:54:22 +04:00
|
|
|
rs2 = GET_FIELD(insn, 27, 31);
|
|
|
|
xop = GET_FIELD(insn, 18, 26);
|
2012-10-06 03:54:53 +04:00
|
|
|
save_state(dc);
|
2007-09-20 18:54:22 +04:00
|
|
|
switch (xop) {
|
2009-05-03 22:51:22 +04:00
|
|
|
case 0x1: /* fmovs */
|
2011-10-15 01:58:32 +04:00
|
|
|
cpu_src1_32 = gen_load_fpr_F(dc, rs2);
|
|
|
|
gen_store_fpr_F(dc, rd, cpu_src1_32);
|
2009-05-03 22:51:22 +04:00
|
|
|
break;
|
|
|
|
case 0x5: /* fnegs */
|
2011-10-15 22:52:00 +04:00
|
|
|
gen_ne_fop_FF(dc, rd, rs2, gen_helper_fnegs);
|
2009-05-03 22:51:22 +04:00
|
|
|
break;
|
|
|
|
case 0x9: /* fabss */
|
2011-10-15 22:52:00 +04:00
|
|
|
gen_ne_fop_FF(dc, rd, rs2, gen_helper_fabss);
|
2009-05-03 22:51:22 +04:00
|
|
|
break;
|
|
|
|
case 0x29: /* fsqrts */
|
|
|
|
CHECK_FPU_FEATURE(dc, FSQRT);
|
2011-10-15 22:52:00 +04:00
|
|
|
gen_fop_FF(dc, rd, rs2, gen_helper_fsqrts);
|
2009-05-03 22:51:22 +04:00
|
|
|
break;
|
|
|
|
case 0x2a: /* fsqrtd */
|
|
|
|
CHECK_FPU_FEATURE(dc, FSQRT);
|
2011-10-15 22:52:00 +04:00
|
|
|
gen_fop_DD(dc, rd, rs2, gen_helper_fsqrtd);
|
2009-05-03 22:51:22 +04:00
|
|
|
break;
|
|
|
|
case 0x2b: /* fsqrtq */
|
|
|
|
CHECK_FPU_FEATURE(dc, FLOAT128);
|
2011-10-15 22:52:00 +04:00
|
|
|
gen_fop_QQ(dc, rd, rs2, gen_helper_fsqrtq);
|
2009-05-03 22:51:22 +04:00
|
|
|
break;
|
|
|
|
case 0x41: /* fadds */
|
2011-10-15 22:52:00 +04:00
|
|
|
gen_fop_FFF(dc, rd, rs1, rs2, gen_helper_fadds);
|
2009-05-03 22:51:22 +04:00
|
|
|
break;
|
|
|
|
case 0x42: /* faddd */
|
2011-10-15 22:52:00 +04:00
|
|
|
gen_fop_DDD(dc, rd, rs1, rs2, gen_helper_faddd);
|
2009-05-03 22:51:22 +04:00
|
|
|
break;
|
|
|
|
case 0x43: /* faddq */
|
|
|
|
CHECK_FPU_FEATURE(dc, FLOAT128);
|
2011-10-15 22:52:00 +04:00
|
|
|
gen_fop_QQQ(dc, rd, rs1, rs2, gen_helper_faddq);
|
2009-05-03 22:51:22 +04:00
|
|
|
break;
|
|
|
|
case 0x45: /* fsubs */
|
2011-10-15 22:52:00 +04:00
|
|
|
gen_fop_FFF(dc, rd, rs1, rs2, gen_helper_fsubs);
|
2009-05-03 22:51:22 +04:00
|
|
|
break;
|
|
|
|
case 0x46: /* fsubd */
|
2011-10-15 22:52:00 +04:00
|
|
|
gen_fop_DDD(dc, rd, rs1, rs2, gen_helper_fsubd);
|
2009-05-03 22:51:22 +04:00
|
|
|
break;
|
|
|
|
case 0x47: /* fsubq */
|
|
|
|
CHECK_FPU_FEATURE(dc, FLOAT128);
|
2011-10-15 22:52:00 +04:00
|
|
|
gen_fop_QQQ(dc, rd, rs1, rs2, gen_helper_fsubq);
|
2009-05-03 22:51:22 +04:00
|
|
|
break;
|
|
|
|
case 0x49: /* fmuls */
|
|
|
|
CHECK_FPU_FEATURE(dc, FMUL);
|
2011-10-15 22:52:00 +04:00
|
|
|
gen_fop_FFF(dc, rd, rs1, rs2, gen_helper_fmuls);
|
2009-05-03 22:51:22 +04:00
|
|
|
break;
|
|
|
|
case 0x4a: /* fmuld */
|
|
|
|
CHECK_FPU_FEATURE(dc, FMUL);
|
2011-10-15 22:52:00 +04:00
|
|
|
gen_fop_DDD(dc, rd, rs1, rs2, gen_helper_fmuld);
|
2009-05-03 22:51:22 +04:00
|
|
|
break;
|
|
|
|
case 0x4b: /* fmulq */
|
|
|
|
CHECK_FPU_FEATURE(dc, FLOAT128);
|
|
|
|
CHECK_FPU_FEATURE(dc, FMUL);
|
2011-10-15 22:52:00 +04:00
|
|
|
gen_fop_QQQ(dc, rd, rs1, rs2, gen_helper_fmulq);
|
2009-05-03 22:51:22 +04:00
|
|
|
break;
|
|
|
|
case 0x4d: /* fdivs */
|
2011-10-15 22:52:00 +04:00
|
|
|
gen_fop_FFF(dc, rd, rs1, rs2, gen_helper_fdivs);
|
2009-05-03 22:51:22 +04:00
|
|
|
break;
|
|
|
|
case 0x4e: /* fdivd */
|
2011-10-15 22:52:00 +04:00
|
|
|
gen_fop_DDD(dc, rd, rs1, rs2, gen_helper_fdivd);
|
2009-05-03 22:51:22 +04:00
|
|
|
break;
|
|
|
|
case 0x4f: /* fdivq */
|
|
|
|
CHECK_FPU_FEATURE(dc, FLOAT128);
|
2011-10-15 22:52:00 +04:00
|
|
|
gen_fop_QQQ(dc, rd, rs1, rs2, gen_helper_fdivq);
|
2009-05-03 22:51:22 +04:00
|
|
|
break;
|
|
|
|
case 0x69: /* fsmuld */
|
|
|
|
CHECK_FPU_FEATURE(dc, FSMULD);
|
2011-10-15 22:52:00 +04:00
|
|
|
gen_fop_DFF(dc, rd, rs1, rs2, gen_helper_fsmuld);
|
2009-05-03 22:51:22 +04:00
|
|
|
break;
|
|
|
|
case 0x6e: /* fdmulq */
|
|
|
|
CHECK_FPU_FEATURE(dc, FLOAT128);
|
2011-10-15 22:52:00 +04:00
|
|
|
gen_fop_QDD(dc, rd, rs1, rs2, gen_helper_fdmulq);
|
2009-05-03 22:51:22 +04:00
|
|
|
break;
|
|
|
|
case 0xc4: /* fitos */
|
2011-10-15 22:52:00 +04:00
|
|
|
gen_fop_FF(dc, rd, rs2, gen_helper_fitos);
|
2009-05-03 22:51:22 +04:00
|
|
|
break;
|
|
|
|
case 0xc6: /* fdtos */
|
2011-10-15 22:52:00 +04:00
|
|
|
gen_fop_FD(dc, rd, rs2, gen_helper_fdtos);
|
2009-05-03 22:51:22 +04:00
|
|
|
break;
|
|
|
|
case 0xc7: /* fqtos */
|
|
|
|
CHECK_FPU_FEATURE(dc, FLOAT128);
|
2011-10-15 22:52:00 +04:00
|
|
|
gen_fop_FQ(dc, rd, rs2, gen_helper_fqtos);
|
2009-05-03 22:51:22 +04:00
|
|
|
break;
|
|
|
|
case 0xc8: /* fitod */
|
2011-10-15 22:52:00 +04:00
|
|
|
gen_ne_fop_DF(dc, rd, rs2, gen_helper_fitod);
|
2009-05-03 22:51:22 +04:00
|
|
|
break;
|
|
|
|
case 0xc9: /* fstod */
|
2011-10-15 22:52:00 +04:00
|
|
|
gen_ne_fop_DF(dc, rd, rs2, gen_helper_fstod);
|
2009-05-03 22:51:22 +04:00
|
|
|
break;
|
|
|
|
case 0xcb: /* fqtod */
|
|
|
|
CHECK_FPU_FEATURE(dc, FLOAT128);
|
2011-10-15 22:52:00 +04:00
|
|
|
gen_fop_DQ(dc, rd, rs2, gen_helper_fqtod);
|
2009-05-03 22:51:22 +04:00
|
|
|
break;
|
|
|
|
case 0xcc: /* fitoq */
|
|
|
|
CHECK_FPU_FEATURE(dc, FLOAT128);
|
2011-10-15 22:52:00 +04:00
|
|
|
gen_ne_fop_QF(dc, rd, rs2, gen_helper_fitoq);
|
2009-05-03 22:51:22 +04:00
|
|
|
break;
|
|
|
|
case 0xcd: /* fstoq */
|
|
|
|
CHECK_FPU_FEATURE(dc, FLOAT128);
|
2011-10-15 22:52:00 +04:00
|
|
|
gen_ne_fop_QF(dc, rd, rs2, gen_helper_fstoq);
|
2009-05-03 22:51:22 +04:00
|
|
|
break;
|
|
|
|
case 0xce: /* fdtoq */
|
|
|
|
CHECK_FPU_FEATURE(dc, FLOAT128);
|
2011-10-15 22:52:00 +04:00
|
|
|
gen_ne_fop_QD(dc, rd, rs2, gen_helper_fdtoq);
|
2009-05-03 22:51:22 +04:00
|
|
|
break;
|
|
|
|
case 0xd1: /* fstoi */
|
2011-10-15 22:52:00 +04:00
|
|
|
gen_fop_FF(dc, rd, rs2, gen_helper_fstoi);
|
2009-05-03 22:51:22 +04:00
|
|
|
break;
|
|
|
|
case 0xd2: /* fdtoi */
|
2011-10-15 22:52:00 +04:00
|
|
|
gen_fop_FD(dc, rd, rs2, gen_helper_fdtoi);
|
2009-05-03 22:51:22 +04:00
|
|
|
break;
|
|
|
|
case 0xd3: /* fqtoi */
|
|
|
|
CHECK_FPU_FEATURE(dc, FLOAT128);
|
2011-10-15 22:52:00 +04:00
|
|
|
gen_fop_FQ(dc, rd, rs2, gen_helper_fqtoi);
|
2009-05-03 22:51:22 +04:00
|
|
|
break;
|
2005-07-02 18:31:34 +04:00
|
|
|
#ifdef TARGET_SPARC64
|
2009-05-03 22:51:22 +04:00
|
|
|
case 0x2: /* V9 fmovd */
|
2011-10-15 02:47:35 +04:00
|
|
|
cpu_src1_64 = gen_load_fpr_D(dc, rs2);
|
|
|
|
gen_store_fpr_D(dc, rd, cpu_src1_64);
|
2009-05-03 22:51:22 +04:00
|
|
|
break;
|
|
|
|
case 0x3: /* V9 fmovq */
|
|
|
|
CHECK_FPU_FEATURE(dc, FLOAT128);
|
2011-10-15 23:00:08 +04:00
|
|
|
gen_move_Q(rd, rs2);
|
2009-05-03 22:51:22 +04:00
|
|
|
break;
|
|
|
|
case 0x6: /* V9 fnegd */
|
2011-10-15 22:52:00 +04:00
|
|
|
gen_ne_fop_DD(dc, rd, rs2, gen_helper_fnegd);
|
2009-05-03 22:51:22 +04:00
|
|
|
break;
|
|
|
|
case 0x7: /* V9 fnegq */
|
|
|
|
CHECK_FPU_FEATURE(dc, FLOAT128);
|
2011-10-15 22:52:00 +04:00
|
|
|
gen_ne_fop_QQ(dc, rd, rs2, gen_helper_fnegq);
|
2009-05-03 22:51:22 +04:00
|
|
|
break;
|
|
|
|
case 0xa: /* V9 fabsd */
|
2011-10-15 22:52:00 +04:00
|
|
|
gen_ne_fop_DD(dc, rd, rs2, gen_helper_fabsd);
|
2009-05-03 22:51:22 +04:00
|
|
|
break;
|
|
|
|
case 0xb: /* V9 fabsq */
|
|
|
|
CHECK_FPU_FEATURE(dc, FLOAT128);
|
2011-10-15 22:52:00 +04:00
|
|
|
gen_ne_fop_QQ(dc, rd, rs2, gen_helper_fabsq);
|
2009-05-03 22:51:22 +04:00
|
|
|
break;
|
|
|
|
case 0x81: /* V9 fstox */
|
2011-10-15 22:52:00 +04:00
|
|
|
gen_fop_DF(dc, rd, rs2, gen_helper_fstox);
|
2009-05-03 22:51:22 +04:00
|
|
|
break;
|
|
|
|
case 0x82: /* V9 fdtox */
|
2011-10-15 22:52:00 +04:00
|
|
|
gen_fop_DD(dc, rd, rs2, gen_helper_fdtox);
|
2009-05-03 22:51:22 +04:00
|
|
|
break;
|
|
|
|
case 0x83: /* V9 fqtox */
|
|
|
|
CHECK_FPU_FEATURE(dc, FLOAT128);
|
2011-10-15 22:52:00 +04:00
|
|
|
gen_fop_DQ(dc, rd, rs2, gen_helper_fqtox);
|
2009-05-03 22:51:22 +04:00
|
|
|
break;
|
|
|
|
case 0x84: /* V9 fxtos */
|
2011-10-15 22:52:00 +04:00
|
|
|
gen_fop_FD(dc, rd, rs2, gen_helper_fxtos);
|
2009-05-03 22:51:22 +04:00
|
|
|
break;
|
|
|
|
case 0x88: /* V9 fxtod */
|
2011-10-15 22:52:00 +04:00
|
|
|
gen_fop_DD(dc, rd, rs2, gen_helper_fxtod);
|
2009-05-03 22:51:22 +04:00
|
|
|
break;
|
|
|
|
case 0x8c: /* V9 fxtoq */
|
|
|
|
CHECK_FPU_FEATURE(dc, FLOAT128);
|
2011-10-15 22:52:00 +04:00
|
|
|
gen_ne_fop_QD(dc, rd, rs2, gen_helper_fxtoq);
|
2009-05-03 22:51:22 +04:00
|
|
|
break;
|
2007-09-20 18:54:22 +04:00
|
|
|
#endif
|
2009-05-03 22:51:22 +04:00
|
|
|
default:
|
|
|
|
goto illegal_insn;
|
2007-09-20 18:54:22 +04:00
|
|
|
}
|
|
|
|
} else if (xop == 0x35) { /* FPU Operations */
|
2005-07-02 18:31:34 +04:00
|
|
|
#ifdef TARGET_SPARC64
|
2007-09-20 18:54:22 +04:00
|
|
|
int cond;
|
2005-07-02 18:31:34 +04:00
|
|
|
#endif
|
2012-10-06 03:54:52 +04:00
|
|
|
if (gen_trap_ifnofpu(dc)) {
|
2006-06-26 23:53:29 +04:00
|
|
|
goto jmp_insn;
|
2012-10-06 03:54:52 +04:00
|
|
|
}
|
2007-09-20 18:54:22 +04:00
|
|
|
gen_op_clear_ieee_excp_and_FTT();
|
2004-01-04 18:01:44 +03:00
|
|
|
rs1 = GET_FIELD(insn, 13, 17);
|
2007-09-20 18:54:22 +04:00
|
|
|
rs2 = GET_FIELD(insn, 27, 31);
|
|
|
|
xop = GET_FIELD(insn, 18, 26);
|
2012-10-06 03:54:53 +04:00
|
|
|
save_state(dc);
|
2008-03-04 22:56:06 +03:00
|
|
|
|
2012-10-06 03:55:07 +04:00
|
|
|
#ifdef TARGET_SPARC64
|
|
|
|
#define FMOVR(sz) \
|
|
|
|
do { \
|
|
|
|
DisasCompare cmp; \
|
2012-10-17 03:28:35 +04:00
|
|
|
cond = GET_FIELD_SP(insn, 10, 12); \
|
2012-10-16 13:32:14 +04:00
|
|
|
cpu_src1 = get_src1(dc, insn); \
|
2012-10-06 03:55:07 +04:00
|
|
|
gen_compare_reg(&cmp, cond, cpu_src1); \
|
|
|
|
gen_fmov##sz(dc, &cmp, rd, rs2); \
|
|
|
|
free_compare(&cmp); \
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
if ((xop & 0x11f) == 0x005) { /* V9 fmovsr */
|
|
|
|
FMOVR(s);
|
2007-09-20 18:54:22 +04:00
|
|
|
break;
|
|
|
|
} else if ((xop & 0x11f) == 0x006) { // V9 fmovdr
|
2012-10-06 03:55:07 +04:00
|
|
|
FMOVR(d);
|
2007-09-20 18:54:22 +04:00
|
|
|
break;
|
|
|
|
} else if ((xop & 0x11f) == 0x007) { // V9 fmovqr
|
2008-05-10 00:13:43 +04:00
|
|
|
CHECK_FPU_FEATURE(dc, FLOAT128);
|
2012-10-06 03:55:07 +04:00
|
|
|
FMOVR(q);
|
2007-11-25 21:40:20 +03:00
|
|
|
break;
|
2007-09-20 18:54:22 +04:00
|
|
|
}
|
2012-10-06 03:55:07 +04:00
|
|
|
#undef FMOVR
|
2007-09-20 18:54:22 +04:00
|
|
|
#endif
|
|
|
|
switch (xop) {
|
2005-07-02 18:31:34 +04:00
|
|
|
#ifdef TARGET_SPARC64
|
2012-10-06 03:54:59 +04:00
|
|
|
#define FMOVCC(fcc, sz) \
|
|
|
|
do { \
|
|
|
|
DisasCompare cmp; \
|
2008-09-10 23:54:51 +04:00
|
|
|
cond = GET_FIELD_SP(insn, 14, 17); \
|
2012-10-06 03:54:59 +04:00
|
|
|
gen_fcompare(&cmp, fcc, cond); \
|
|
|
|
gen_fmov##sz(dc, &cmp, rd, rs2); \
|
|
|
|
free_compare(&cmp); \
|
|
|
|
} while (0)
|
|
|
|
|
2007-09-20 18:54:22 +04:00
|
|
|
case 0x001: /* V9 fmovscc %fcc0 */
|
2012-10-06 03:54:59 +04:00
|
|
|
FMOVCC(0, s);
|
2007-09-20 18:54:22 +04:00
|
|
|
break;
|
|
|
|
case 0x002: /* V9 fmovdcc %fcc0 */
|
2012-10-06 03:54:59 +04:00
|
|
|
FMOVCC(0, d);
|
2007-09-20 18:54:22 +04:00
|
|
|
break;
|
|
|
|
case 0x003: /* V9 fmovqcc %fcc0 */
|
2008-05-10 00:13:43 +04:00
|
|
|
CHECK_FPU_FEATURE(dc, FLOAT128);
|
2012-10-06 03:54:59 +04:00
|
|
|
FMOVCC(0, q);
|
2007-11-25 21:40:20 +03:00
|
|
|
break;
|
2007-09-20 18:54:22 +04:00
|
|
|
case 0x041: /* V9 fmovscc %fcc1 */
|
2012-10-06 03:54:59 +04:00
|
|
|
FMOVCC(1, s);
|
2007-09-20 18:54:22 +04:00
|
|
|
break;
|
|
|
|
case 0x042: /* V9 fmovdcc %fcc1 */
|
2012-10-06 03:54:59 +04:00
|
|
|
FMOVCC(1, d);
|
2007-09-20 18:54:22 +04:00
|
|
|
break;
|
|
|
|
case 0x043: /* V9 fmovqcc %fcc1 */
|
2008-05-10 00:13:43 +04:00
|
|
|
CHECK_FPU_FEATURE(dc, FLOAT128);
|
2012-10-06 03:54:59 +04:00
|
|
|
FMOVCC(1, q);
|
2007-11-25 21:40:20 +03:00
|
|
|
break;
|
2007-09-20 18:54:22 +04:00
|
|
|
case 0x081: /* V9 fmovscc %fcc2 */
|
2012-10-06 03:54:59 +04:00
|
|
|
FMOVCC(2, s);
|
2007-09-20 18:54:22 +04:00
|
|
|
break;
|
|
|
|
case 0x082: /* V9 fmovdcc %fcc2 */
|
2012-10-06 03:54:59 +04:00
|
|
|
FMOVCC(2, d);
|
2007-09-20 18:54:22 +04:00
|
|
|
break;
|
|
|
|
case 0x083: /* V9 fmovqcc %fcc2 */
|
2008-05-10 00:13:43 +04:00
|
|
|
CHECK_FPU_FEATURE(dc, FLOAT128);
|
2012-10-06 03:54:59 +04:00
|
|
|
FMOVCC(2, q);
|
2007-11-25 21:40:20 +03:00
|
|
|
break;
|
2007-09-20 18:54:22 +04:00
|
|
|
case 0x0c1: /* V9 fmovscc %fcc3 */
|
2012-10-06 03:54:59 +04:00
|
|
|
FMOVCC(3, s);
|
2007-09-20 18:54:22 +04:00
|
|
|
break;
|
|
|
|
case 0x0c2: /* V9 fmovdcc %fcc3 */
|
2012-10-06 03:54:59 +04:00
|
|
|
FMOVCC(3, d);
|
2007-09-20 18:54:22 +04:00
|
|
|
break;
|
|
|
|
case 0x0c3: /* V9 fmovqcc %fcc3 */
|
2008-05-10 00:13:43 +04:00
|
|
|
CHECK_FPU_FEATURE(dc, FLOAT128);
|
2012-10-06 03:54:59 +04:00
|
|
|
FMOVCC(3, q);
|
2007-11-25 21:40:20 +03:00
|
|
|
break;
|
2012-10-06 03:54:59 +04:00
|
|
|
#undef FMOVCC
|
|
|
|
#define FMOVCC(xcc, sz) \
|
|
|
|
do { \
|
|
|
|
DisasCompare cmp; \
|
2008-09-10 23:54:51 +04:00
|
|
|
cond = GET_FIELD_SP(insn, 14, 17); \
|
2012-10-06 03:54:59 +04:00
|
|
|
gen_compare(&cmp, xcc, cond, dc); \
|
|
|
|
gen_fmov##sz(dc, &cmp, rd, rs2); \
|
|
|
|
free_compare(&cmp); \
|
|
|
|
} while (0)
|
2008-03-09 00:36:50 +03:00
|
|
|
|
2007-09-20 18:54:22 +04:00
|
|
|
case 0x101: /* V9 fmovscc %icc */
|
2012-10-06 03:54:59 +04:00
|
|
|
FMOVCC(0, s);
|
2007-09-20 18:54:22 +04:00
|
|
|
break;
|
|
|
|
case 0x102: /* V9 fmovdcc %icc */
|
2012-10-06 03:54:59 +04:00
|
|
|
FMOVCC(0, d);
|
2011-07-18 10:36:57 +04:00
|
|
|
break;
|
2007-09-20 18:54:22 +04:00
|
|
|
case 0x103: /* V9 fmovqcc %icc */
|
2008-05-10 00:13:43 +04:00
|
|
|
CHECK_FPU_FEATURE(dc, FLOAT128);
|
2012-10-06 03:54:59 +04:00
|
|
|
FMOVCC(0, q);
|
2007-11-25 21:40:20 +03:00
|
|
|
break;
|
2007-09-20 18:54:22 +04:00
|
|
|
case 0x181: /* V9 fmovscc %xcc */
|
2012-10-06 03:54:59 +04:00
|
|
|
FMOVCC(1, s);
|
2007-09-20 18:54:22 +04:00
|
|
|
break;
|
|
|
|
case 0x182: /* V9 fmovdcc %xcc */
|
2012-10-06 03:54:59 +04:00
|
|
|
FMOVCC(1, d);
|
2007-09-20 18:54:22 +04:00
|
|
|
break;
|
|
|
|
case 0x183: /* V9 fmovqcc %xcc */
|
2008-05-10 00:13:43 +04:00
|
|
|
CHECK_FPU_FEATURE(dc, FLOAT128);
|
2012-10-06 03:54:59 +04:00
|
|
|
FMOVCC(1, q);
|
2007-11-25 21:40:20 +03:00
|
|
|
break;
|
2012-10-06 03:54:59 +04:00
|
|
|
#undef FMOVCC
|
2007-11-25 21:40:20 +03:00
|
|
|
#endif
|
|
|
|
case 0x51: /* fcmps, V9 %fcc */
|
2011-10-15 01:58:32 +04: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 18:54:22 +04:00
|
|
|
break;
|
2007-11-25 21:40:20 +03:00
|
|
|
case 0x52: /* fcmpd, V9 %fcc */
|
2011-10-15 21:20:20 +04: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 18:54:22 +04:00
|
|
|
break;
|
2007-11-25 21:40:20 +03:00
|
|
|
case 0x53: /* fcmpq, V9 %fcc */
|
2008-05-10 00:13:43 +04:00
|
|
|
CHECK_FPU_FEATURE(dc, FLOAT128);
|
2007-11-25 21:40:20 +03:00
|
|
|
gen_op_load_fpr_QT0(QFPREG(rs1));
|
|
|
|
gen_op_load_fpr_QT1(QFPREG(rs2));
|
2008-03-04 23:00:18 +03:00
|
|
|
gen_op_fcmpq(rd & 3);
|
2007-11-25 21:40:20 +03:00
|
|
|
break;
|
2007-09-20 18:54:22 +04:00
|
|
|
case 0x55: /* fcmpes, V9 %fcc */
|
2011-10-15 01:58:32 +04: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 18:54:22 +04:00
|
|
|
break;
|
|
|
|
case 0x56: /* fcmped, V9 %fcc */
|
2011-10-15 21:20:20 +04: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 18:54:22 +04:00
|
|
|
break;
|
2007-11-25 21:40:20 +03:00
|
|
|
case 0x57: /* fcmpeq, V9 %fcc */
|
2008-05-10 00:13:43 +04:00
|
|
|
CHECK_FPU_FEATURE(dc, FLOAT128);
|
2007-11-25 21:40:20 +03:00
|
|
|
gen_op_load_fpr_QT0(QFPREG(rs1));
|
|
|
|
gen_op_load_fpr_QT1(QFPREG(rs2));
|
2008-03-04 23:00:18 +03:00
|
|
|
gen_op_fcmpeq(rd & 3);
|
2007-11-25 21:40:20 +03:00
|
|
|
break;
|
2007-09-20 18:54:22 +04:00
|
|
|
default:
|
|
|
|
goto illegal_insn;
|
|
|
|
}
|
|
|
|
} else if (xop == 0x2) {
|
2012-10-16 13:32:13 +04:00
|
|
|
TCGv dst = gen_dest_gpr(dc, rd);
|
2004-12-20 02:18:01 +03:00
|
|
|
rs1 = GET_FIELD(insn, 13, 17);
|
2007-09-20 18:54:22 +04:00
|
|
|
if (rs1 == 0) {
|
2012-10-16 13:32:13 +04:00
|
|
|
/* clr/mov shortcut : or %g0, x, y -> mov x, y */
|
2007-09-20 18:54:22 +04:00
|
|
|
if (IS_IMM) { /* immediate */
|
2009-05-02 22:58:57 +04:00
|
|
|
simm = GET_FIELDs(insn, 19, 31);
|
2012-10-16 13:32:13 +04:00
|
|
|
tcg_gen_movi_tl(dst, simm);
|
|
|
|
gen_store_gpr(dc, rd, dst);
|
2007-09-20 18:54:22 +04:00
|
|
|
} else { /* register */
|
|
|
|
rs2 = GET_FIELD(insn, 27, 31);
|
2012-10-16 13:32:13 +04: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 18:54:22 +04:00
|
|
|
}
|
|
|
|
} else {
|
2012-10-16 13:32:14 +04:00
|
|
|
cpu_src1 = get_src1(dc, insn);
|
2007-09-20 18:54:22 +04:00
|
|
|
if (IS_IMM) { /* immediate */
|
2009-05-02 22:58:57 +04:00
|
|
|
simm = GET_FIELDs(insn, 19, 31);
|
2012-10-16 13:32:13 +04:00
|
|
|
tcg_gen_ori_tl(dst, cpu_src1, simm);
|
|
|
|
gen_store_gpr(dc, rd, dst);
|
2007-09-20 18:54:22 +04:00
|
|
|
} else { /* register */
|
|
|
|
rs2 = GET_FIELD(insn, 27, 31);
|
2012-10-16 13:32:13 +04: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 18:54:22 +04:00
|
|
|
}
|
|
|
|
}
|
2005-07-23 18:27:54 +04:00
|
|
|
#ifdef TARGET_SPARC64
|
2007-09-20 18:54:22 +04:00
|
|
|
} else if (xop == 0x25) { /* sll, V9 sllx */
|
2012-10-16 13:32:14 +04:00
|
|
|
cpu_src1 = get_src1(dc, insn);
|
2007-09-20 18:54:22 +04:00
|
|
|
if (IS_IMM) { /* immediate */
|
2009-05-02 22:58:57 +04:00
|
|
|
simm = GET_FIELDs(insn, 20, 31);
|
2008-02-24 17:10:06 +03:00
|
|
|
if (insn & (1 << 12)) {
|
2009-05-02 22:58:57 +04:00
|
|
|
tcg_gen_shli_i64(cpu_dst, cpu_src1, simm & 0x3f);
|
2008-02-24 17:10:06 +03:00
|
|
|
} else {
|
2009-05-02 22:58:57 +04:00
|
|
|
tcg_gen_shli_i64(cpu_dst, cpu_src1, simm & 0x1f);
|
2008-02-24 17:10:06 +03:00
|
|
|
}
|
2007-09-20 18:54:22 +04:00
|
|
|
} else { /* register */
|
2005-07-23 18:27:54 +04:00
|
|
|
rs2 = GET_FIELD(insn, 27, 31);
|
2012-10-16 13:32:13 +04:00
|
|
|
cpu_src2 = gen_load_gpr(dc, rs2);
|
2012-10-16 13:32:31 +04:00
|
|
|
cpu_tmp0 = get_temp_tl(dc);
|
2008-02-24 17:10:06 +03:00
|
|
|
if (insn & (1 << 12)) {
|
2008-03-29 12:09:25 +03:00
|
|
|
tcg_gen_andi_i64(cpu_tmp0, cpu_src2, 0x3f);
|
2008-02-24 17:10:06 +03:00
|
|
|
} else {
|
2008-03-29 12:09:25 +03:00
|
|
|
tcg_gen_andi_i64(cpu_tmp0, cpu_src2, 0x1f);
|
2008-02-24 17:10:06 +03:00
|
|
|
}
|
2008-08-06 22:13:54 +04:00
|
|
|
tcg_gen_shl_i64(cpu_dst, cpu_src1, cpu_tmp0);
|
2005-07-23 18:27:54 +04:00
|
|
|
}
|
2012-10-16 13:32:13 +04:00
|
|
|
gen_store_gpr(dc, rd, cpu_dst);
|
2007-09-20 18:54:22 +04:00
|
|
|
} else if (xop == 0x26) { /* srl, V9 srlx */
|
2012-10-16 13:32:14 +04:00
|
|
|
cpu_src1 = get_src1(dc, insn);
|
2007-09-20 18:54:22 +04:00
|
|
|
if (IS_IMM) { /* immediate */
|
2009-05-02 22:58:57 +04:00
|
|
|
simm = GET_FIELDs(insn, 20, 31);
|
2008-02-24 17:10:06 +03:00
|
|
|
if (insn & (1 << 12)) {
|
2009-05-02 22:58:57 +04:00
|
|
|
tcg_gen_shri_i64(cpu_dst, cpu_src1, simm & 0x3f);
|
2008-02-24 17:10:06 +03:00
|
|
|
} else {
|
2008-03-29 12:09:25 +03:00
|
|
|
tcg_gen_andi_i64(cpu_dst, cpu_src1, 0xffffffffULL);
|
2009-05-02 22:58:57 +04:00
|
|
|
tcg_gen_shri_i64(cpu_dst, cpu_dst, simm & 0x1f);
|
2008-02-24 17:10:06 +03:00
|
|
|
}
|
2007-09-20 18:54:22 +04:00
|
|
|
} else { /* register */
|
2005-07-23 18:27:54 +04:00
|
|
|
rs2 = GET_FIELD(insn, 27, 31);
|
2012-10-16 13:32:13 +04:00
|
|
|
cpu_src2 = gen_load_gpr(dc, rs2);
|
2012-10-16 13:32:31 +04:00
|
|
|
cpu_tmp0 = get_temp_tl(dc);
|
2008-02-24 17:10:06 +03:00
|
|
|
if (insn & (1 << 12)) {
|
2008-03-29 12:09:25 +03:00
|
|
|
tcg_gen_andi_i64(cpu_tmp0, cpu_src2, 0x3f);
|
|
|
|
tcg_gen_shr_i64(cpu_dst, cpu_src1, cpu_tmp0);
|
2008-02-24 17:10:06 +03:00
|
|
|
} else {
|
2008-03-29 12:09:25 +03: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 17:10:06 +03:00
|
|
|
}
|
2005-07-23 18:27:54 +04:00
|
|
|
}
|
2012-10-16 13:32:13 +04:00
|
|
|
gen_store_gpr(dc, rd, cpu_dst);
|
2007-09-20 18:54:22 +04:00
|
|
|
} else if (xop == 0x27) { /* sra, V9 srax */
|
2012-10-16 13:32:14 +04:00
|
|
|
cpu_src1 = get_src1(dc, insn);
|
2007-09-20 18:54:22 +04:00
|
|
|
if (IS_IMM) { /* immediate */
|
2009-05-02 22:58:57 +04:00
|
|
|
simm = GET_FIELDs(insn, 20, 31);
|
2008-02-24 17:10:06 +03:00
|
|
|
if (insn & (1 << 12)) {
|
2009-05-02 22:58:57 +04:00
|
|
|
tcg_gen_sari_i64(cpu_dst, cpu_src1, simm & 0x3f);
|
2008-02-24 17:10:06 +03:00
|
|
|
} else {
|
2012-10-16 13:32:13 +04:00
|
|
|
tcg_gen_ext32s_i64(cpu_dst, cpu_src1);
|
2009-05-02 22:58:57 +04:00
|
|
|
tcg_gen_sari_i64(cpu_dst, cpu_dst, simm & 0x1f);
|
2008-02-24 17:10:06 +03:00
|
|
|
}
|
2007-09-20 18:54:22 +04:00
|
|
|
} else { /* register */
|
2005-07-23 18:27:54 +04:00
|
|
|
rs2 = GET_FIELD(insn, 27, 31);
|
2012-10-16 13:32:13 +04:00
|
|
|
cpu_src2 = gen_load_gpr(dc, rs2);
|
2012-10-16 13:32:31 +04:00
|
|
|
cpu_tmp0 = get_temp_tl(dc);
|
2008-02-24 17:10:06 +03:00
|
|
|
if (insn & (1 << 12)) {
|
2008-03-29 12:09:25 +03:00
|
|
|
tcg_gen_andi_i64(cpu_tmp0, cpu_src2, 0x3f);
|
|
|
|
tcg_gen_sar_i64(cpu_dst, cpu_src1, cpu_tmp0);
|
2008-02-24 17:10:06 +03:00
|
|
|
} else {
|
2008-03-29 12:09:25 +03:00
|
|
|
tcg_gen_andi_i64(cpu_tmp0, cpu_src2, 0x1f);
|
2012-10-16 13:32:13 +04:00
|
|
|
tcg_gen_ext32s_i64(cpu_dst, cpu_src1);
|
2008-03-29 12:09:25 +03:00
|
|
|
tcg_gen_sar_i64(cpu_dst, cpu_dst, cpu_tmp0);
|
2008-02-24 17:10:06 +03:00
|
|
|
}
|
2005-07-23 18:27:54 +04:00
|
|
|
}
|
2012-10-16 13:32:13 +04:00
|
|
|
gen_store_gpr(dc, rd, cpu_dst);
|
2004-12-20 02:18:01 +03:00
|
|
|
#endif
|
2007-04-01 19:08:21 +04:00
|
|
|
} else if (xop < 0x36) {
|
2004-01-04 18:01:44 +03:00
|
|
|
if (xop < 0x20) {
|
2012-10-16 13:32:14 +04:00
|
|
|
cpu_src1 = get_src1(dc, insn);
|
|
|
|
cpu_src2 = get_src2(dc, insn);
|
2004-01-04 18:01:44 +03:00
|
|
|
switch (xop & ~0x10) {
|
2009-05-03 00:19:46 +04:00
|
|
|
case 0x0: /* add */
|
2012-10-16 13:32:13 +04: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 23:14:05 +04:00
|
|
|
} else {
|
2012-10-16 13:32:13 +04:00
|
|
|
tcg_gen_add_tl(cpu_dst, cpu_src1, cpu_src2);
|
2009-05-02 23:14:05 +04:00
|
|
|
}
|
2004-01-04 18:01:44 +03:00
|
|
|
break;
|
2009-05-03 00:19:46 +04:00
|
|
|
case 0x1: /* and */
|
2012-10-16 13:32:13 +04:00
|
|
|
tcg_gen_and_tl(cpu_dst, cpu_src1, cpu_src2);
|
2009-05-02 23:14:05 +04:00
|
|
|
if (xop & 0x10) {
|
2009-05-10 11:38:34 +04: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 23:14:05 +04:00
|
|
|
}
|
2004-01-04 18:01:44 +03:00
|
|
|
break;
|
2009-05-03 00:19:46 +04:00
|
|
|
case 0x2: /* or */
|
2012-10-16 13:32:13 +04:00
|
|
|
tcg_gen_or_tl(cpu_dst, cpu_src1, cpu_src2);
|
2009-05-10 11:19:11 +04:00
|
|
|
if (xop & 0x10) {
|
2009-05-10 11:38:34 +04: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 11:19:11 +04:00
|
|
|
}
|
2007-09-20 18:54:22 +04:00
|
|
|
break;
|
2009-05-03 00:19:46 +04:00
|
|
|
case 0x3: /* xor */
|
2012-10-16 13:32:13 +04:00
|
|
|
tcg_gen_xor_tl(cpu_dst, cpu_src1, cpu_src2);
|
2009-05-10 11:19:11 +04:00
|
|
|
if (xop & 0x10) {
|
2009-05-10 11:38:34 +04: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 11:19:11 +04:00
|
|
|
}
|
2004-01-04 18:01:44 +03:00
|
|
|
break;
|
2009-05-03 00:19:46 +04:00
|
|
|
case 0x4: /* sub */
|
2012-10-16 13:32:13 +04: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 23:14:05 +04:00
|
|
|
} else {
|
2012-10-16 13:32:13 +04:00
|
|
|
tcg_gen_sub_tl(cpu_dst, cpu_src1, cpu_src2);
|
2009-05-02 23:14:05 +04:00
|
|
|
}
|
2004-01-04 18:01:44 +03:00
|
|
|
break;
|
2009-05-03 00:19:46 +04:00
|
|
|
case 0x5: /* andn */
|
2012-10-16 13:32:13 +04:00
|
|
|
tcg_gen_andc_tl(cpu_dst, cpu_src1, cpu_src2);
|
2009-05-10 11:19:11 +04:00
|
|
|
if (xop & 0x10) {
|
2009-05-10 11:38:34 +04: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 11:19:11 +04:00
|
|
|
}
|
2004-01-04 18:01:44 +03:00
|
|
|
break;
|
2009-05-03 00:19:46 +04:00
|
|
|
case 0x6: /* orn */
|
2012-10-16 13:32:13 +04:00
|
|
|
tcg_gen_orc_tl(cpu_dst, cpu_src1, cpu_src2);
|
2009-05-10 11:19:11 +04:00
|
|
|
if (xop & 0x10) {
|
2009-05-10 11:38:34 +04: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 11:19:11 +04:00
|
|
|
}
|
2004-01-04 18:01:44 +03:00
|
|
|
break;
|
2009-05-03 00:19:46 +04:00
|
|
|
case 0x7: /* xorn */
|
2012-10-16 13:32:13 +04:00
|
|
|
tcg_gen_eqv_tl(cpu_dst, cpu_src1, cpu_src2);
|
2009-05-10 11:19:11 +04:00
|
|
|
if (xop & 0x10) {
|
2009-05-10 11:38:34 +04: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 11:19:11 +04:00
|
|
|
}
|
2004-01-04 18:01:44 +03:00
|
|
|
break;
|
2009-05-03 00:19:46 +04:00
|
|
|
case 0x8: /* addx, V9 addc */
|
2010-05-12 22:04:27 +04:00
|
|
|
gen_op_addx_int(dc, cpu_dst, cpu_src1, cpu_src2,
|
|
|
|
(xop & 0x10));
|
2004-01-04 18:01:44 +03:00
|
|
|
break;
|
2006-06-18 23:36:58 +04:00
|
|
|
#ifdef TARGET_SPARC64
|
2007-09-20 18:54:22 +04:00
|
|
|
case 0x9: /* V9 mulx */
|
2012-10-16 13:32:13 +04:00
|
|
|
tcg_gen_mul_i64(cpu_dst, cpu_src1, cpu_src2);
|
2006-06-18 23:36:58 +04:00
|
|
|
break;
|
|
|
|
#endif
|
2009-05-03 00:19:46 +04:00
|
|
|
case 0xa: /* umul */
|
2008-05-10 00:13:43 +04:00
|
|
|
CHECK_IU_FEATURE(dc, MUL);
|
2008-03-29 12:09:25 +03:00
|
|
|
gen_op_umul(cpu_dst, cpu_src1, cpu_src2);
|
2009-05-10 11:19:11 +04:00
|
|
|
if (xop & 0x10) {
|
2009-05-10 11:38:34 +04: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 11:19:11 +04:00
|
|
|
}
|
2004-01-04 18:01:44 +03:00
|
|
|
break;
|
2009-05-03 00:19:46 +04:00
|
|
|
case 0xb: /* smul */
|
2008-05-10 00:13:43 +04:00
|
|
|
CHECK_IU_FEATURE(dc, MUL);
|
2008-03-29 12:09:25 +03:00
|
|
|
gen_op_smul(cpu_dst, cpu_src1, cpu_src2);
|
2009-05-10 11:19:11 +04:00
|
|
|
if (xop & 0x10) {
|
2009-05-10 11:38:34 +04: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 11:19:11 +04:00
|
|
|
}
|
2004-01-04 18:01:44 +03:00
|
|
|
break;
|
2009-05-03 00:19:46 +04:00
|
|
|
case 0xc: /* subx, V9 subc */
|
2010-05-12 22:04:27 +04:00
|
|
|
gen_op_subx_int(dc, cpu_dst, cpu_src1, cpu_src2,
|
|
|
|
(xop & 0x10));
|
2004-01-04 18:01:44 +03:00
|
|
|
break;
|
2006-06-18 23:36:58 +04:00
|
|
|
#ifdef TARGET_SPARC64
|
2007-09-20 18:54:22 +04:00
|
|
|
case 0xd: /* V9 udivx */
|
2012-10-06 03:55:03 +04:00
|
|
|
gen_helper_udivx(cpu_dst, cpu_env, cpu_src1, cpu_src2);
|
2006-06-18 23:36:58 +04:00
|
|
|
break;
|
|
|
|
#endif
|
2009-05-03 00:19:46 +04:00
|
|
|
case 0xe: /* udiv */
|
2008-05-10 00:13:43 +04:00
|
|
|
CHECK_IU_FEATURE(dc, DIV);
|
2009-05-10 11:19:11 +04:00
|
|
|
if (xop & 0x10) {
|
2011-07-04 22:15:42 +04:00
|
|
|
gen_helper_udiv_cc(cpu_dst, cpu_env, cpu_src1,
|
|
|
|
cpu_src2);
|
2009-05-10 11:42:54 +04:00
|
|
|
dc->cc_op = CC_OP_DIV;
|
2010-12-26 01:25:47 +03:00
|
|
|
} else {
|
2011-07-04 22:15:42 +04:00
|
|
|
gen_helper_udiv(cpu_dst, cpu_env, cpu_src1,
|
|
|
|
cpu_src2);
|
2009-05-10 11:19:11 +04:00
|
|
|
}
|
2004-01-04 18:01:44 +03:00
|
|
|
break;
|
2009-05-03 00:19:46 +04:00
|
|
|
case 0xf: /* sdiv */
|
2008-05-10 00:13:43 +04:00
|
|
|
CHECK_IU_FEATURE(dc, DIV);
|
2009-05-10 11:19:11 +04:00
|
|
|
if (xop & 0x10) {
|
2011-07-04 22:15:42 +04:00
|
|
|
gen_helper_sdiv_cc(cpu_dst, cpu_env, cpu_src1,
|
|
|
|
cpu_src2);
|
2009-05-10 11:42:54 +04:00
|
|
|
dc->cc_op = CC_OP_DIV;
|
2010-12-26 01:25:47 +03:00
|
|
|
} else {
|
2011-07-04 22:15:42 +04:00
|
|
|
gen_helper_sdiv(cpu_dst, cpu_env, cpu_src1,
|
|
|
|
cpu_src2);
|
2009-05-10 11:19:11 +04:00
|
|
|
}
|
2004-01-04 18:01:44 +03:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
goto illegal_insn;
|
|
|
|
}
|
2012-10-16 13:32:13 +04:00
|
|
|
gen_store_gpr(dc, rd, cpu_dst);
|
2004-01-04 18:01:44 +03:00
|
|
|
} else {
|
2012-10-16 13:32:14 +04:00
|
|
|
cpu_src1 = get_src1(dc, insn);
|
|
|
|
cpu_src2 = get_src2(dc, insn);
|
2004-01-04 18:01:44 +03:00
|
|
|
switch (xop) {
|
2007-09-20 18:54:22 +04:00
|
|
|
case 0x20: /* taddcc */
|
2012-10-06 03:55:05 +04:00
|
|
|
gen_op_add_cc(cpu_dst, cpu_src1, cpu_src2);
|
2012-10-16 13:32:13 +04:00
|
|
|
gen_store_gpr(dc, rd, cpu_dst);
|
2009-05-10 11:38:35 +04:00
|
|
|
tcg_gen_movi_i32(cpu_cc_op, CC_OP_TADD);
|
|
|
|
dc->cc_op = CC_OP_TADD;
|
2007-09-20 18:54:22 +04:00
|
|
|
break;
|
|
|
|
case 0x21: /* tsubcc */
|
2012-10-06 03:55:05 +04:00
|
|
|
gen_op_sub_cc(cpu_dst, cpu_src1, cpu_src2);
|
2012-10-16 13:32:13 +04:00
|
|
|
gen_store_gpr(dc, rd, cpu_dst);
|
2009-05-10 11:38:35 +04:00
|
|
|
tcg_gen_movi_i32(cpu_cc_op, CC_OP_TSUB);
|
|
|
|
dc->cc_op = CC_OP_TSUB;
|
2007-09-20 18:54:22 +04:00
|
|
|
break;
|
|
|
|
case 0x22: /* taddcctv */
|
2012-10-06 03:55:05 +04:00
|
|
|
gen_helper_taddcctv(cpu_dst, cpu_env,
|
|
|
|
cpu_src1, cpu_src2);
|
2012-10-16 13:32:13 +04:00
|
|
|
gen_store_gpr(dc, rd, cpu_dst);
|
2009-05-10 11:38:35 +04:00
|
|
|
dc->cc_op = CC_OP_TADDTV;
|
2007-09-20 18:54:22 +04:00
|
|
|
break;
|
|
|
|
case 0x23: /* tsubcctv */
|
2012-10-06 03:55:05 +04:00
|
|
|
gen_helper_tsubcctv(cpu_dst, cpu_env,
|
|
|
|
cpu_src1, cpu_src2);
|
2012-10-16 13:32:13 +04:00
|
|
|
gen_store_gpr(dc, rd, cpu_dst);
|
2009-05-10 11:38:35 +04:00
|
|
|
dc->cc_op = CC_OP_TSUBTV;
|
2007-09-20 18:54:22 +04:00
|
|
|
break;
|
2004-01-04 18:01:44 +03:00
|
|
|
case 0x24: /* mulscc */
|
2012-10-10 01:50:00 +04:00
|
|
|
update_psr(dc);
|
2008-03-29 12:09:25 +03:00
|
|
|
gen_op_mulscc(cpu_dst, cpu_src1, cpu_src2);
|
2012-10-16 13:32:13 +04:00
|
|
|
gen_store_gpr(dc, rd, cpu_dst);
|
2009-05-10 11:43:21 +04:00
|
|
|
tcg_gen_movi_i32(cpu_cc_op, CC_OP_ADD);
|
|
|
|
dc->cc_op = CC_OP_ADD;
|
2004-01-04 18:01:44 +03:00
|
|
|
break;
|
2005-07-23 18:27:54 +04:00
|
|
|
#ifndef TARGET_SPARC64
|
2007-09-20 18:54:22 +04:00
|
|
|
case 0x25: /* sll */
|
2008-05-17 13:43:12 +04:00
|
|
|
if (IS_IMM) { /* immediate */
|
2009-05-02 22:58:57 +04:00
|
|
|
simm = GET_FIELDs(insn, 20, 31);
|
|
|
|
tcg_gen_shli_tl(cpu_dst, cpu_src1, simm & 0x1f);
|
2008-05-17 13:43:12 +04:00
|
|
|
} else { /* register */
|
2012-10-16 13:32:31 +04:00
|
|
|
cpu_tmp0 = get_temp_tl(dc);
|
2008-05-17 13:43:12 +04:00
|
|
|
tcg_gen_andi_tl(cpu_tmp0, cpu_src2, 0x1f);
|
|
|
|
tcg_gen_shl_tl(cpu_dst, cpu_src1, cpu_tmp0);
|
|
|
|
}
|
2012-10-16 13:32:13 +04:00
|
|
|
gen_store_gpr(dc, rd, cpu_dst);
|
2004-01-04 18:01:44 +03:00
|
|
|
break;
|
2005-07-23 18:27:54 +04:00
|
|
|
case 0x26: /* srl */
|
2008-05-17 13:43:12 +04:00
|
|
|
if (IS_IMM) { /* immediate */
|
2009-05-02 22:58:57 +04:00
|
|
|
simm = GET_FIELDs(insn, 20, 31);
|
|
|
|
tcg_gen_shri_tl(cpu_dst, cpu_src1, simm & 0x1f);
|
2008-05-17 13:43:12 +04:00
|
|
|
} else { /* register */
|
2012-10-16 13:32:31 +04:00
|
|
|
cpu_tmp0 = get_temp_tl(dc);
|
2008-05-17 13:43:12 +04:00
|
|
|
tcg_gen_andi_tl(cpu_tmp0, cpu_src2, 0x1f);
|
|
|
|
tcg_gen_shr_tl(cpu_dst, cpu_src1, cpu_tmp0);
|
|
|
|
}
|
2012-10-16 13:32:13 +04:00
|
|
|
gen_store_gpr(dc, rd, cpu_dst);
|
2004-01-04 18:01:44 +03:00
|
|
|
break;
|
2005-07-23 18:27:54 +04:00
|
|
|
case 0x27: /* sra */
|
2008-05-17 13:43:12 +04:00
|
|
|
if (IS_IMM) { /* immediate */
|
2009-05-02 22:58:57 +04:00
|
|
|
simm = GET_FIELDs(insn, 20, 31);
|
|
|
|
tcg_gen_sari_tl(cpu_dst, cpu_src1, simm & 0x1f);
|
2008-05-17 13:43:12 +04:00
|
|
|
} else { /* register */
|
2012-10-16 13:32:31 +04:00
|
|
|
cpu_tmp0 = get_temp_tl(dc);
|
2008-05-17 13:43:12 +04:00
|
|
|
tcg_gen_andi_tl(cpu_tmp0, cpu_src2, 0x1f);
|
|
|
|
tcg_gen_sar_tl(cpu_dst, cpu_src1, cpu_tmp0);
|
|
|
|
}
|
2012-10-16 13:32:13 +04:00
|
|
|
gen_store_gpr(dc, rd, cpu_dst);
|
2004-01-04 18:01:44 +03:00
|
|
|
break;
|
2005-07-23 18:27:54 +04:00
|
|
|
#endif
|
2004-01-04 18:01:44 +03:00
|
|
|
case 0x30:
|
|
|
|
{
|
2012-10-16 13:32:31 +04:00
|
|
|
cpu_tmp0 = get_temp_tl(dc);
|
2004-01-04 18:01:44 +03:00
|
|
|
switch(rd) {
|
2005-07-02 18:31:34 +04:00
|
|
|
case 0: /* wry */
|
2008-09-11 20:01:02 +04:00
|
|
|
tcg_gen_xor_tl(cpu_tmp0, cpu_src1, cpu_src2);
|
|
|
|
tcg_gen_andi_tl(cpu_y, cpu_tmp0, 0xffffffff);
|
2004-01-04 18:01:44 +03:00
|
|
|
break;
|
2007-04-01 19:05:09 +04: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 15:45:07 +04:00
|
|
|
if ((rd == 0x13) && (dc->def->features &
|
|
|
|
CPU_FEATURE_POWERDOWN)) {
|
|
|
|
/* LEON3 power-down */
|
2013-11-27 11:50:11 +04:00
|
|
|
save_state(dc);
|
2013-02-19 15:45:07 +04:00
|
|
|
gen_helper_power_down(cpu_env);
|
|
|
|
}
|
2007-04-01 19:05:09 +04:00
|
|
|
break;
|
|
|
|
#else
|
2007-09-20 18:54:22 +04:00
|
|
|
case 0x2: /* V9 wrccr */
|
2012-10-16 13:32:29 +04:00
|
|
|
tcg_gen_xor_tl(cpu_tmp0, cpu_src1, cpu_src2);
|
|
|
|
gen_helper_wrccr(cpu_env, cpu_tmp0);
|
2009-05-10 11:19:11 +04:00
|
|
|
tcg_gen_movi_i32(cpu_cc_op, CC_OP_FLAGS);
|
|
|
|
dc->cc_op = CC_OP_FLAGS;
|
2007-09-20 18:54:22 +04:00
|
|
|
break;
|
|
|
|
case 0x3: /* V9 wrasi */
|
2012-10-16 13:32:29 +04:00
|
|
|
tcg_gen_xor_tl(cpu_tmp0, cpu_src1, cpu_src2);
|
|
|
|
tcg_gen_andi_tl(cpu_tmp0, cpu_tmp0, 0xff);
|
|
|
|
tcg_gen_trunc_tl_i32(cpu_asi, cpu_tmp0);
|
2007-09-20 18:54:22 +04:00
|
|
|
break;
|
|
|
|
case 0x6: /* V9 wrfprs */
|
2012-10-16 13:32:29 +04:00
|
|
|
tcg_gen_xor_tl(cpu_tmp0, cpu_src1, cpu_src2);
|
|
|
|
tcg_gen_trunc_tl_i32(cpu_fprs, cpu_tmp0);
|
2012-10-06 03:54:53 +04:00
|
|
|
save_state(dc);
|
2007-04-13 19:49:56 +04:00
|
|
|
gen_op_next_insn();
|
2008-02-01 13:50:11 +03:00
|
|
|
tcg_gen_exit_tb(0);
|
2007-04-13 19:49:56 +04:00
|
|
|
dc->is_br = 1;
|
2007-09-20 18:54:22 +04:00
|
|
|
break;
|
|
|
|
case 0xf: /* V9 sir, nop if user */
|
2005-07-02 18:31:34 +04:00
|
|
|
#if !defined(CONFIG_USER_ONLY)
|
2010-04-18 18:22:14 +04:00
|
|
|
if (supervisor(dc)) {
|
2008-02-24 17:10:06 +03:00
|
|
|
; // XXX
|
2010-04-18 18:22:14 +04:00
|
|
|
}
|
2005-07-02 18:31:34 +04:00
|
|
|
#endif
|
2007-09-20 18:54:22 +04:00
|
|
|
break;
|
|
|
|
case 0x13: /* Graphics Status */
|
2012-10-06 03:54:52 +04:00
|
|
|
if (gen_trap_ifnofpu(dc)) {
|
2006-07-19 01:12:17 +04:00
|
|
|
goto jmp_insn;
|
2012-10-06 03:54:52 +04:00
|
|
|
}
|
2008-09-06 21:51:43 +04:00
|
|
|
tcg_gen_xor_tl(cpu_gsr, cpu_src1, cpu_src2);
|
2007-09-20 18:54:22 +04:00
|
|
|
break;
|
2008-09-22 23:50:28 +04:00
|
|
|
case 0x14: /* Softint set */
|
|
|
|
if (!supervisor(dc))
|
|
|
|
goto illegal_insn;
|
2012-10-16 13:32:27 +04:00
|
|
|
tcg_gen_xor_tl(cpu_tmp0, cpu_src1, cpu_src2);
|
|
|
|
gen_helper_set_softint(cpu_env, cpu_tmp0);
|
2008-09-22 23:50:28 +04:00
|
|
|
break;
|
|
|
|
case 0x15: /* Softint clear */
|
|
|
|
if (!supervisor(dc))
|
|
|
|
goto illegal_insn;
|
2012-10-16 13:32:27 +04:00
|
|
|
tcg_gen_xor_tl(cpu_tmp0, cpu_src1, cpu_src2);
|
|
|
|
gen_helper_clear_softint(cpu_env, cpu_tmp0);
|
2008-09-22 23:50:28 +04:00
|
|
|
break;
|
|
|
|
case 0x16: /* Softint write */
|
|
|
|
if (!supervisor(dc))
|
|
|
|
goto illegal_insn;
|
2012-10-16 13:32:27 +04:00
|
|
|
tcg_gen_xor_tl(cpu_tmp0, cpu_src1, cpu_src2);
|
|
|
|
gen_helper_write_softint(cpu_env, cpu_tmp0);
|
2008-09-22 23:50:28 +04:00
|
|
|
break;
|
2007-09-20 18:54:22 +04:00
|
|
|
case 0x17: /* Tick compare */
|
2005-07-23 18:27:54 +04:00
|
|
|
#if !defined(CONFIG_USER_ONLY)
|
2007-09-20 18:54:22 +04:00
|
|
|
if (!supervisor(dc))
|
|
|
|
goto illegal_insn;
|
2005-07-23 18:27:54 +04:00
|
|
|
#endif
|
2008-03-02 21:28:06 +03:00
|
|
|
{
|
2008-11-17 17:43:54 +03:00
|
|
|
TCGv_ptr r_tickptr;
|
2008-03-02 21:28:06 +03:00
|
|
|
|
2008-09-06 21:51:43 +04:00
|
|
|
tcg_gen_xor_tl(cpu_tick_cmpr, cpu_src1,
|
2008-03-29 12:09:25 +03:00
|
|
|
cpu_src2);
|
2008-11-17 17:43:54 +03:00
|
|
|
r_tickptr = tcg_temp_new_ptr();
|
2008-03-02 21:28:06 +03:00
|
|
|
tcg_gen_ld_ptr(r_tickptr, cpu_env,
|
2012-03-14 04:38:22 +04:00
|
|
|
offsetof(CPUSPARCState, tick));
|
2008-11-17 17:43:54 +03:00
|
|
|
gen_helper_tick_set_limit(r_tickptr,
|
|
|
|
cpu_tick_cmpr);
|
|
|
|
tcg_temp_free_ptr(r_tickptr);
|
2008-03-02 21:28:06 +03:00
|
|
|
}
|
2007-09-20 18:54:22 +04:00
|
|
|
break;
|
|
|
|
case 0x18: /* System tick */
|
2005-07-23 18:27:54 +04:00
|
|
|
#if !defined(CONFIG_USER_ONLY)
|
2007-09-20 18:54:22 +04:00
|
|
|
if (!supervisor(dc))
|
|
|
|
goto illegal_insn;
|
2005-07-23 18:27:54 +04:00
|
|
|
#endif
|
2008-03-02 21:28:06 +03:00
|
|
|
{
|
2008-11-17 17:43:54 +03:00
|
|
|
TCGv_ptr r_tickptr;
|
2008-03-02 21:28:06 +03:00
|
|
|
|
2012-10-16 13:32:29 +04:00
|
|
|
tcg_gen_xor_tl(cpu_tmp0, cpu_src1,
|
2008-03-29 12:09:25 +03:00
|
|
|
cpu_src2);
|
2008-11-17 17:43:54 +03:00
|
|
|
r_tickptr = tcg_temp_new_ptr();
|
2008-03-02 21:28:06 +03:00
|
|
|
tcg_gen_ld_ptr(r_tickptr, cpu_env,
|
2012-03-14 04:38:22 +04:00
|
|
|
offsetof(CPUSPARCState, stick));
|
2008-11-17 17:43:54 +03:00
|
|
|
gen_helper_tick_set_count(r_tickptr,
|
2012-10-16 13:32:29 +04:00
|
|
|
cpu_tmp0);
|
2008-11-17 17:43:54 +03:00
|
|
|
tcg_temp_free_ptr(r_tickptr);
|
2008-03-02 21:28:06 +03:00
|
|
|
}
|
2007-09-20 18:54:22 +04:00
|
|
|
break;
|
|
|
|
case 0x19: /* System tick compare */
|
2005-07-23 18:27:54 +04:00
|
|
|
#if !defined(CONFIG_USER_ONLY)
|
2007-09-20 18:54:22 +04:00
|
|
|
if (!supervisor(dc))
|
|
|
|
goto illegal_insn;
|
2005-07-02 18:31:34 +04:00
|
|
|
#endif
|
2008-03-02 21:28:06 +03:00
|
|
|
{
|
2008-11-17 17:43:54 +03:00
|
|
|
TCGv_ptr r_tickptr;
|
2008-03-02 21:28:06 +03:00
|
|
|
|
2008-09-06 21:51:43 +04:00
|
|
|
tcg_gen_xor_tl(cpu_stick_cmpr, cpu_src1,
|
2008-03-29 12:09:25 +03:00
|
|
|
cpu_src2);
|
2008-11-17 17:43:54 +03:00
|
|
|
r_tickptr = tcg_temp_new_ptr();
|
2008-03-02 21:28:06 +03:00
|
|
|
tcg_gen_ld_ptr(r_tickptr, cpu_env,
|
2012-03-14 04:38:22 +04:00
|
|
|
offsetof(CPUSPARCState, stick));
|
2008-11-17 17:43:54 +03:00
|
|
|
gen_helper_tick_set_limit(r_tickptr,
|
|
|
|
cpu_stick_cmpr);
|
|
|
|
tcg_temp_free_ptr(r_tickptr);
|
2008-03-02 21:28:06 +03:00
|
|
|
}
|
2007-09-20 18:54:22 +04:00
|
|
|
break;
|
2005-07-23 18:27:54 +04:00
|
|
|
|
2007-09-20 18:54:22 +04:00
|
|
|
case 0x10: /* Performance Control */
|
2008-05-12 20:13:33 +04:00
|
|
|
case 0x11: /* Performance Instrumentation
|
|
|
|
Counter */
|
2007-09-20 18:54:22 +04:00
|
|
|
case 0x12: /* Dispatch Control */
|
2005-07-23 18:27:54 +04:00
|
|
|
#endif
|
2005-07-02 18:31:34 +04:00
|
|
|
default:
|
2004-01-04 18:01:44 +03:00
|
|
|
goto illegal_insn;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2004-10-01 01:55:55 +04:00
|
|
|
#if !defined(CONFIG_USER_ONLY)
|
2005-01-31 01:39:04 +03:00
|
|
|
case 0x31: /* wrpsr, V9 saved, restored */
|
2004-10-01 01:55:55 +04:00
|
|
|
{
|
2007-09-20 18:54:22 +04:00
|
|
|
if (!supervisor(dc))
|
|
|
|
goto priv_insn;
|
2005-07-02 18:31:34 +04:00
|
|
|
#ifdef TARGET_SPARC64
|
2007-09-20 18:54:22 +04:00
|
|
|
switch (rd) {
|
|
|
|
case 0:
|
2011-07-04 01:01:59 +04:00
|
|
|
gen_helper_saved(cpu_env);
|
2007-09-20 18:54:22 +04:00
|
|
|
break;
|
|
|
|
case 1:
|
2011-07-04 01:01:59 +04:00
|
|
|
gen_helper_restored(cpu_env);
|
2007-09-20 18:54:22 +04:00
|
|
|
break;
|
2007-04-22 23:14:52 +04:00
|
|
|
case 2: /* UA2005 allclean */
|
|
|
|
case 3: /* UA2005 otherw */
|
|
|
|
case 4: /* UA2005 normalw */
|
|
|
|
case 5: /* UA2005 invalw */
|
|
|
|
// XXX
|
2007-09-20 18:54:22 +04:00
|
|
|
default:
|
2005-07-02 18:31:34 +04:00
|
|
|
goto illegal_insn;
|
|
|
|
}
|
|
|
|
#else
|
2012-10-16 13:32:31 +04:00
|
|
|
cpu_tmp0 = get_temp_tl(dc);
|
2012-10-16 13:32:29 +04:00
|
|
|
tcg_gen_xor_tl(cpu_tmp0, cpu_src1, cpu_src2);
|
|
|
|
gen_helper_wrpsr(cpu_env, cpu_tmp0);
|
2009-05-10 11:19:11 +04:00
|
|
|
tcg_gen_movi_i32(cpu_cc_op, CC_OP_FLAGS);
|
|
|
|
dc->cc_op = CC_OP_FLAGS;
|
2012-10-06 03:54:53 +04:00
|
|
|
save_state(dc);
|
2005-11-11 03:24:58 +03:00
|
|
|
gen_op_next_insn();
|
2008-02-01 13:50:11 +03:00
|
|
|
tcg_gen_exit_tb(0);
|
2007-09-20 18:54:22 +04:00
|
|
|
dc->is_br = 1;
|
2005-07-02 18:31:34 +04:00
|
|
|
#endif
|
2004-10-01 01:55:55 +04:00
|
|
|
}
|
|
|
|
break;
|
2005-01-31 01:39:04 +03:00
|
|
|
case 0x32: /* wrwim, V9 wrpr */
|
2004-10-01 01:55:55 +04:00
|
|
|
{
|
2007-09-20 18:54:22 +04:00
|
|
|
if (!supervisor(dc))
|
|
|
|
goto priv_insn;
|
2012-10-16 13:32:31 +04:00
|
|
|
cpu_tmp0 = get_temp_tl(dc);
|
2008-06-21 23:50:10 +04:00
|
|
|
tcg_gen_xor_tl(cpu_tmp0, cpu_src1, cpu_src2);
|
2005-07-02 18:31:34 +04:00
|
|
|
#ifdef TARGET_SPARC64
|
2007-09-20 18:54:22 +04:00
|
|
|
switch (rd) {
|
|
|
|
case 0: // tpc
|
2008-03-05 20:59:48 +03:00
|
|
|
{
|
2008-11-17 17:43:54 +03:00
|
|
|
TCGv_ptr r_tsptr;
|
2008-03-05 20:59:48 +03:00
|
|
|
|
2008-11-17 17:43:54 +03:00
|
|
|
r_tsptr = tcg_temp_new_ptr();
|
2009-08-03 23:15:02 +04:00
|
|
|
gen_load_trap_state_at_tl(r_tsptr, cpu_env);
|
2008-06-21 23:50:10 +04:00
|
|
|
tcg_gen_st_tl(cpu_tmp0, r_tsptr,
|
2008-03-05 20:59:48 +03:00
|
|
|
offsetof(trap_state, tpc));
|
2008-11-17 17:43:54 +03:00
|
|
|
tcg_temp_free_ptr(r_tsptr);
|
2008-03-05 20:59:48 +03:00
|
|
|
}
|
2007-09-20 18:54:22 +04:00
|
|
|
break;
|
|
|
|
case 1: // tnpc
|
2008-03-05 20:59:48 +03:00
|
|
|
{
|
2008-11-17 17:43:54 +03:00
|
|
|
TCGv_ptr r_tsptr;
|
2008-03-05 20:59:48 +03:00
|
|
|
|
2008-11-17 17:43:54 +03:00
|
|
|
r_tsptr = tcg_temp_new_ptr();
|
2009-08-03 23:15:02 +04:00
|
|
|
gen_load_trap_state_at_tl(r_tsptr, cpu_env);
|
2008-06-21 23:50:10 +04:00
|
|
|
tcg_gen_st_tl(cpu_tmp0, r_tsptr,
|
2008-03-05 20:59:48 +03:00
|
|
|
offsetof(trap_state, tnpc));
|
2008-11-17 17:43:54 +03:00
|
|
|
tcg_temp_free_ptr(r_tsptr);
|
2008-03-05 20:59:48 +03:00
|
|
|
}
|
2007-09-20 18:54:22 +04:00
|
|
|
break;
|
|
|
|
case 2: // tstate
|
2008-03-05 20:59:48 +03:00
|
|
|
{
|
2008-11-17 17:43:54 +03:00
|
|
|
TCGv_ptr r_tsptr;
|
2008-03-05 20:59:48 +03:00
|
|
|
|
2008-11-17 17:43:54 +03:00
|
|
|
r_tsptr = tcg_temp_new_ptr();
|
2009-08-03 23:15:02 +04:00
|
|
|
gen_load_trap_state_at_tl(r_tsptr, cpu_env);
|
2008-06-21 23:50:10 +04:00
|
|
|
tcg_gen_st_tl(cpu_tmp0, r_tsptr,
|
2008-05-12 20:13:33 +04:00
|
|
|
offsetof(trap_state,
|
|
|
|
tstate));
|
2008-11-17 17:43:54 +03:00
|
|
|
tcg_temp_free_ptr(r_tsptr);
|
2008-03-05 20:59:48 +03:00
|
|
|
}
|
2007-09-20 18:54:22 +04:00
|
|
|
break;
|
|
|
|
case 3: // tt
|
2008-03-05 20:59:48 +03:00
|
|
|
{
|
2008-11-17 17:43:54 +03:00
|
|
|
TCGv_ptr r_tsptr;
|
2008-03-05 20:59:48 +03:00
|
|
|
|
2008-11-17 17:43:54 +03:00
|
|
|
r_tsptr = tcg_temp_new_ptr();
|
2009-08-03 23:15:02 +04:00
|
|
|
gen_load_trap_state_at_tl(r_tsptr, cpu_env);
|
2012-10-16 13:32:23 +04:00
|
|
|
tcg_gen_st32_tl(cpu_tmp0, r_tsptr,
|
|
|
|
offsetof(trap_state, tt));
|
2008-11-17 17:43:54 +03:00
|
|
|
tcg_temp_free_ptr(r_tsptr);
|
2008-03-05 20:59:48 +03:00
|
|
|
}
|
2007-09-20 18:54:22 +04:00
|
|
|
break;
|
|
|
|
case 4: // tick
|
2008-03-02 21:28:06 +03:00
|
|
|
{
|
2008-11-17 17:43:54 +03:00
|
|
|
TCGv_ptr r_tickptr;
|
2008-03-02 21:28:06 +03:00
|
|
|
|
2008-11-17 17:43:54 +03:00
|
|
|
r_tickptr = tcg_temp_new_ptr();
|
2008-03-02 21:28:06 +03:00
|
|
|
tcg_gen_ld_ptr(r_tickptr, cpu_env,
|
2012-03-14 04:38:22 +04:00
|
|
|
offsetof(CPUSPARCState, tick));
|
2008-11-17 17:43:54 +03:00
|
|
|
gen_helper_tick_set_count(r_tickptr,
|
|
|
|
cpu_tmp0);
|
|
|
|
tcg_temp_free_ptr(r_tickptr);
|
2008-03-02 21:28:06 +03:00
|
|
|
}
|
2007-09-20 18:54:22 +04:00
|
|
|
break;
|
|
|
|
case 5: // tba
|
2008-09-06 21:51:43 +04:00
|
|
|
tcg_gen_mov_tl(cpu_tbr, cpu_tmp0);
|
2007-09-20 18:54:22 +04:00
|
|
|
break;
|
|
|
|
case 6: // pstate
|
2012-10-10 01:49:59 +04:00
|
|
|
save_state(dc);
|
|
|
|
gen_helper_wrpstate(cpu_env, cpu_tmp0);
|
|
|
|
dc->npc = DYNAMIC_PC;
|
2007-09-20 18:54:22 +04:00
|
|
|
break;
|
|
|
|
case 7: // tl
|
2012-10-10 01:49:59 +04:00
|
|
|
save_state(dc);
|
2012-10-16 13:32:23 +04:00
|
|
|
tcg_gen_st32_tl(cpu_tmp0, cpu_env,
|
2012-10-10 01:49:59 +04:00
|
|
|
offsetof(CPUSPARCState, tl));
|
|
|
|
dc->npc = DYNAMIC_PC;
|
2007-09-20 18:54:22 +04:00
|
|
|
break;
|
|
|
|
case 8: // pil
|
2011-07-04 01:01:59 +04:00
|
|
|
gen_helper_wrpil(cpu_env, cpu_tmp0);
|
2007-09-20 18:54:22 +04:00
|
|
|
break;
|
|
|
|
case 9: // cwp
|
2011-07-04 01:01:59 +04:00
|
|
|
gen_helper_wrcwp(cpu_env, cpu_tmp0);
|
2007-09-20 18:54:22 +04:00
|
|
|
break;
|
|
|
|
case 10: // cansave
|
2012-10-16 13:32:23 +04:00
|
|
|
tcg_gen_st32_tl(cpu_tmp0, cpu_env,
|
|
|
|
offsetof(CPUSPARCState,
|
|
|
|
cansave));
|
2007-09-20 18:54:22 +04:00
|
|
|
break;
|
|
|
|
case 11: // canrestore
|
2012-10-16 13:32:23 +04:00
|
|
|
tcg_gen_st32_tl(cpu_tmp0, cpu_env,
|
|
|
|
offsetof(CPUSPARCState,
|
|
|
|
canrestore));
|
2007-09-20 18:54:22 +04:00
|
|
|
break;
|
|
|
|
case 12: // cleanwin
|
2012-10-16 13:32:23 +04:00
|
|
|
tcg_gen_st32_tl(cpu_tmp0, cpu_env,
|
|
|
|
offsetof(CPUSPARCState,
|
|
|
|
cleanwin));
|
2007-09-20 18:54:22 +04:00
|
|
|
break;
|
|
|
|
case 13: // otherwin
|
2012-10-16 13:32:23 +04:00
|
|
|
tcg_gen_st32_tl(cpu_tmp0, cpu_env,
|
|
|
|
offsetof(CPUSPARCState,
|
|
|
|
otherwin));
|
2007-09-20 18:54:22 +04:00
|
|
|
break;
|
|
|
|
case 14: // wstate
|
2012-10-16 13:32:23 +04:00
|
|
|
tcg_gen_st32_tl(cpu_tmp0, cpu_env,
|
|
|
|
offsetof(CPUSPARCState,
|
|
|
|
wstate));
|
2007-09-20 18:54:22 +04:00
|
|
|
break;
|
2007-04-22 23:14:52 +04:00
|
|
|
case 16: // UA2005 gl
|
2008-07-20 22:22:16 +04:00
|
|
|
CHECK_IU_FEATURE(dc, GL);
|
2012-10-16 13:32:23 +04:00
|
|
|
tcg_gen_st32_tl(cpu_tmp0, cpu_env,
|
|
|
|
offsetof(CPUSPARCState, gl));
|
2007-04-22 23:14:52 +04:00
|
|
|
break;
|
|
|
|
case 26: // UA2005 strand status
|
2008-07-20 22:22:16 +04:00
|
|
|
CHECK_IU_FEATURE(dc, HYPV);
|
2007-04-22 23:14:52 +04:00
|
|
|
if (!hypervisor(dc))
|
|
|
|
goto priv_insn;
|
2008-11-01 16:44:52 +03:00
|
|
|
tcg_gen_mov_tl(cpu_ssr, cpu_tmp0);
|
2007-04-22 23:14:52 +04:00
|
|
|
break;
|
2007-09-20 18:54:22 +04:00
|
|
|
default:
|
|
|
|
goto illegal_insn;
|
|
|
|
}
|
2005-07-02 18:31:34 +04:00
|
|
|
#else
|
2012-10-16 13:32:23 +04: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 21:34:42 +04:00
|
|
|
(1 << dc->def->nwindows) - 1);
|
2012-10-16 13:32:23 +04:00
|
|
|
}
|
2005-07-02 18:31:34 +04:00
|
|
|
#endif
|
2004-10-01 01:55:55 +04:00
|
|
|
}
|
|
|
|
break;
|
2007-04-22 23:14:52 +04:00
|
|
|
case 0x33: /* wrtbr, UA2005 wrhpr */
|
2004-10-01 01:55:55 +04:00
|
|
|
{
|
2007-04-22 23:14:52 +04:00
|
|
|
#ifndef TARGET_SPARC64
|
2007-09-20 18:54:22 +04:00
|
|
|
if (!supervisor(dc))
|
|
|
|
goto priv_insn;
|
2008-09-06 21:51:43 +04:00
|
|
|
tcg_gen_xor_tl(cpu_tbr, cpu_src1, cpu_src2);
|
2007-04-22 23:14:52 +04:00
|
|
|
#else
|
2008-07-20 22:22:16 +04:00
|
|
|
CHECK_IU_FEATURE(dc, HYPV);
|
2007-04-22 23:14:52 +04:00
|
|
|
if (!hypervisor(dc))
|
|
|
|
goto priv_insn;
|
2012-10-16 13:32:31 +04:00
|
|
|
cpu_tmp0 = get_temp_tl(dc);
|
2008-06-21 23:50:10 +04:00
|
|
|
tcg_gen_xor_tl(cpu_tmp0, cpu_src1, cpu_src2);
|
2007-04-22 23:14:52 +04:00
|
|
|
switch (rd) {
|
|
|
|
case 0: // hpstate
|
|
|
|
// XXX gen_op_wrhpstate();
|
2012-10-06 03:54:53 +04:00
|
|
|
save_state(dc);
|
2007-04-22 23:14:52 +04:00
|
|
|
gen_op_next_insn();
|
2008-02-01 13:50:11 +03:00
|
|
|
tcg_gen_exit_tb(0);
|
2007-04-22 23:14:52 +04:00
|
|
|
dc->is_br = 1;
|
|
|
|
break;
|
|
|
|
case 1: // htstate
|
|
|
|
// XXX gen_op_wrhtstate();
|
|
|
|
break;
|
|
|
|
case 3: // hintp
|
2008-09-06 21:51:43 +04:00
|
|
|
tcg_gen_mov_tl(cpu_hintp, cpu_tmp0);
|
2007-04-22 23:14:52 +04:00
|
|
|
break;
|
|
|
|
case 5: // htba
|
2008-09-06 21:51:43 +04:00
|
|
|
tcg_gen_mov_tl(cpu_htba, cpu_tmp0);
|
2007-04-22 23:14:52 +04:00
|
|
|
break;
|
|
|
|
case 31: // hstick_cmpr
|
2008-03-02 21:28:06 +03:00
|
|
|
{
|
2008-11-17 17:43:54 +03:00
|
|
|
TCGv_ptr r_tickptr;
|
2008-03-02 21:28:06 +03:00
|
|
|
|
2008-09-06 21:51:43 +04:00
|
|
|
tcg_gen_mov_tl(cpu_hstick_cmpr, cpu_tmp0);
|
2008-11-17 17:43:54 +03:00
|
|
|
r_tickptr = tcg_temp_new_ptr();
|
2008-03-02 21:28:06 +03:00
|
|
|
tcg_gen_ld_ptr(r_tickptr, cpu_env,
|
2012-03-14 04:38:22 +04:00
|
|
|
offsetof(CPUSPARCState, hstick));
|
2008-11-17 17:43:54 +03:00
|
|
|
gen_helper_tick_set_limit(r_tickptr,
|
|
|
|
cpu_hstick_cmpr);
|
|
|
|
tcg_temp_free_ptr(r_tickptr);
|
2008-03-02 21:28:06 +03:00
|
|
|
}
|
2007-04-22 23:14:52 +04:00
|
|
|
break;
|
|
|
|
case 6: // hver readonly
|
|
|
|
default:
|
|
|
|
goto illegal_insn;
|
|
|
|
}
|
|
|
|
#endif
|
2004-10-01 01:55:55 +04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
#endif
|
2005-07-02 18:31:34 +04:00
|
|
|
#ifdef TARGET_SPARC64
|
2007-09-20 18:54:22 +04:00
|
|
|
case 0x2c: /* V9 movcc */
|
|
|
|
{
|
|
|
|
int cc = GET_FIELD_SP(insn, 11, 12);
|
|
|
|
int cond = GET_FIELD_SP(insn, 14, 17);
|
2012-10-06 03:55:00 +04:00
|
|
|
DisasCompare cmp;
|
2012-10-16 13:32:13 +04:00
|
|
|
TCGv dst;
|
2008-03-02 21:25:27 +03:00
|
|
|
|
2007-09-20 18:54:22 +04:00
|
|
|
if (insn & (1 << 18)) {
|
2012-10-06 03:55:00 +04:00
|
|
|
if (cc == 0) {
|
|
|
|
gen_compare(&cmp, 0, cond, dc);
|
|
|
|
} else if (cc == 2) {
|
|
|
|
gen_compare(&cmp, 1, cond, dc);
|
|
|
|
} else {
|
2007-09-20 18:54:22 +04:00
|
|
|
goto illegal_insn;
|
2012-10-06 03:55:00 +04:00
|
|
|
}
|
2007-09-20 18:54:22 +04:00
|
|
|
} else {
|
2012-10-06 03:55:00 +04:00
|
|
|
gen_fcompare(&cmp, cc, cond);
|
2007-09-20 18:54:22 +04:00
|
|
|
}
|
2008-03-02 21:25:27 +03:00
|
|
|
|
2012-10-06 03:55:00 +04: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 22:58:57 +04:00
|
|
|
simm = GET_FIELD_SPs(insn, 0, 10);
|
2012-10-06 03:55:00 +04:00
|
|
|
tcg_gen_movi_tl(cpu_src2, simm);
|
2008-03-02 21:25:27 +03:00
|
|
|
}
|
2012-10-06 03:55:00 +04:00
|
|
|
|
2012-10-16 13:32:13 +04:00
|
|
|
dst = gen_load_gpr(dc, rd);
|
|
|
|
tcg_gen_movcond_tl(cmp.cond, dst,
|
2012-10-06 03:55:00 +04:00
|
|
|
cmp.c1, cmp.c2,
|
2012-10-16 13:32:13 +04:00
|
|
|
cpu_src2, dst);
|
2012-10-06 03:55:00 +04:00
|
|
|
free_compare(&cmp);
|
2012-10-16 13:32:13 +04:00
|
|
|
gen_store_gpr(dc, rd, dst);
|
2007-09-20 18:54:22 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 0x2d: /* V9 sdivx */
|
2012-10-06 03:55:03 +04:00
|
|
|
gen_helper_sdivx(cpu_dst, cpu_env, cpu_src1, cpu_src2);
|
2012-10-16 13:32:13 +04:00
|
|
|
gen_store_gpr(dc, rd, cpu_dst);
|
2007-09-20 18:54:22 +04:00
|
|
|
break;
|
|
|
|
case 0x2e: /* V9 popc */
|
2012-10-16 13:32:13 +04:00
|
|
|
gen_helper_popc(cpu_dst, cpu_src2);
|
|
|
|
gen_store_gpr(dc, rd, cpu_dst);
|
|
|
|
break;
|
2007-09-20 18:54:22 +04:00
|
|
|
case 0x2f: /* V9 movr */
|
|
|
|
{
|
|
|
|
int cond = GET_FIELD_SP(insn, 10, 12);
|
2012-10-06 03:55:01 +04:00
|
|
|
DisasCompare cmp;
|
2012-10-16 13:32:13 +04:00
|
|
|
TCGv dst;
|
2008-03-02 21:25:27 +03:00
|
|
|
|
2012-10-06 03:55:01 +04:00
|
|
|
gen_compare_reg(&cmp, cond, cpu_src1);
|
2008-05-27 23:39:12 +04:00
|
|
|
|
2012-10-06 03:55:01 +04: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 22:58:57 +04:00
|
|
|
simm = GET_FIELD_SPs(insn, 0, 9);
|
2012-10-06 03:55:01 +04:00
|
|
|
tcg_gen_movi_tl(cpu_src2, simm);
|
2007-09-20 18:54:22 +04:00
|
|
|
}
|
2012-10-06 03:55:01 +04:00
|
|
|
|
2012-10-16 13:32:13 +04:00
|
|
|
dst = gen_load_gpr(dc, rd);
|
|
|
|
tcg_gen_movcond_tl(cmp.cond, dst,
|
2012-10-06 03:55:01 +04:00
|
|
|
cmp.c1, cmp.c2,
|
2012-10-16 13:32:13 +04:00
|
|
|
cpu_src2, dst);
|
2012-10-06 03:55:01 +04:00
|
|
|
free_compare(&cmp);
|
2012-10-16 13:32:13 +04:00
|
|
|
gen_store_gpr(dc, rd, dst);
|
2007-09-20 18:54:22 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
default:
|
|
|
|
goto illegal_insn;
|
|
|
|
}
|
|
|
|
}
|
2007-04-13 19:49:56 +04: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 03:54:52 +04:00
|
|
|
if (gen_trap_ifnofpu(dc)) {
|
2007-04-22 23:14:52 +04:00
|
|
|
goto jmp_insn;
|
2012-10-06 03:54:52 +04:00
|
|
|
}
|
2007-04-13 19:49:56 +04:00
|
|
|
|
|
|
|
switch (opf) {
|
2007-04-22 23:14:52 +04:00
|
|
|
case 0x000: /* VIS I edge8cc */
|
2011-10-18 06:57:23 +04:00
|
|
|
CHECK_FPU_FEATURE(dc, VIS1);
|
2012-10-16 13:32:13 +04:00
|
|
|
cpu_src1 = gen_load_gpr(dc, rs1);
|
|
|
|
cpu_src2 = gen_load_gpr(dc, rs2);
|
2011-10-18 06:57:23 +04:00
|
|
|
gen_edge(dc, cpu_dst, cpu_src1, cpu_src2, 8, 1, 0);
|
2012-10-16 13:32:13 +04:00
|
|
|
gen_store_gpr(dc, rd, cpu_dst);
|
2011-10-18 06:57:23 +04:00
|
|
|
break;
|
2007-04-22 23:14:52 +04:00
|
|
|
case 0x001: /* VIS II edge8n */
|
2011-10-18 06:57:23 +04:00
|
|
|
CHECK_FPU_FEATURE(dc, VIS2);
|
2012-10-16 13:32:13 +04:00
|
|
|
cpu_src1 = gen_load_gpr(dc, rs1);
|
|
|
|
cpu_src2 = gen_load_gpr(dc, rs2);
|
2011-10-18 06:57:23 +04:00
|
|
|
gen_edge(dc, cpu_dst, cpu_src1, cpu_src2, 8, 0, 0);
|
2012-10-16 13:32:13 +04:00
|
|
|
gen_store_gpr(dc, rd, cpu_dst);
|
2011-10-18 06:57:23 +04:00
|
|
|
break;
|
2007-04-22 23:14:52 +04:00
|
|
|
case 0x002: /* VIS I edge8lcc */
|
2011-10-18 06:57:23 +04:00
|
|
|
CHECK_FPU_FEATURE(dc, VIS1);
|
2012-10-16 13:32:13 +04:00
|
|
|
cpu_src1 = gen_load_gpr(dc, rs1);
|
|
|
|
cpu_src2 = gen_load_gpr(dc, rs2);
|
2011-10-18 06:57:23 +04:00
|
|
|
gen_edge(dc, cpu_dst, cpu_src1, cpu_src2, 8, 1, 1);
|
2012-10-16 13:32:13 +04:00
|
|
|
gen_store_gpr(dc, rd, cpu_dst);
|
2011-10-18 06:57:23 +04:00
|
|
|
break;
|
2007-04-22 23:14:52 +04:00
|
|
|
case 0x003: /* VIS II edge8ln */
|
2011-10-18 06:57:23 +04:00
|
|
|
CHECK_FPU_FEATURE(dc, VIS2);
|
2012-10-16 13:32:13 +04:00
|
|
|
cpu_src1 = gen_load_gpr(dc, rs1);
|
|
|
|
cpu_src2 = gen_load_gpr(dc, rs2);
|
2011-10-18 06:57:23 +04:00
|
|
|
gen_edge(dc, cpu_dst, cpu_src1, cpu_src2, 8, 0, 1);
|
2012-10-16 13:32:13 +04:00
|
|
|
gen_store_gpr(dc, rd, cpu_dst);
|
2011-10-18 06:57:23 +04:00
|
|
|
break;
|
2007-04-22 23:14:52 +04:00
|
|
|
case 0x004: /* VIS I edge16cc */
|
2011-10-18 06:57:23 +04:00
|
|
|
CHECK_FPU_FEATURE(dc, VIS1);
|
2012-10-16 13:32:13 +04:00
|
|
|
cpu_src1 = gen_load_gpr(dc, rs1);
|
|
|
|
cpu_src2 = gen_load_gpr(dc, rs2);
|
2011-10-18 06:57:23 +04:00
|
|
|
gen_edge(dc, cpu_dst, cpu_src1, cpu_src2, 16, 1, 0);
|
2012-10-16 13:32:13 +04:00
|
|
|
gen_store_gpr(dc, rd, cpu_dst);
|
2011-10-18 06:57:23 +04:00
|
|
|
break;
|
2007-04-22 23:14:52 +04:00
|
|
|
case 0x005: /* VIS II edge16n */
|
2011-10-18 06:57:23 +04:00
|
|
|
CHECK_FPU_FEATURE(dc, VIS2);
|
2012-10-16 13:32:13 +04:00
|
|
|
cpu_src1 = gen_load_gpr(dc, rs1);
|
|
|
|
cpu_src2 = gen_load_gpr(dc, rs2);
|
2011-10-18 06:57:23 +04:00
|
|
|
gen_edge(dc, cpu_dst, cpu_src1, cpu_src2, 16, 0, 0);
|
2012-10-16 13:32:13 +04:00
|
|
|
gen_store_gpr(dc, rd, cpu_dst);
|
2011-10-18 06:57:23 +04:00
|
|
|
break;
|
2007-04-22 23:14:52 +04:00
|
|
|
case 0x006: /* VIS I edge16lcc */
|
2011-10-18 06:57:23 +04:00
|
|
|
CHECK_FPU_FEATURE(dc, VIS1);
|
2012-10-16 13:32:13 +04:00
|
|
|
cpu_src1 = gen_load_gpr(dc, rs1);
|
|
|
|
cpu_src2 = gen_load_gpr(dc, rs2);
|
2011-10-18 06:57:23 +04:00
|
|
|
gen_edge(dc, cpu_dst, cpu_src1, cpu_src2, 16, 1, 1);
|
2012-10-16 13:32:13 +04:00
|
|
|
gen_store_gpr(dc, rd, cpu_dst);
|
2011-10-18 06:57:23 +04:00
|
|
|
break;
|
2007-04-22 23:14:52 +04:00
|
|
|
case 0x007: /* VIS II edge16ln */
|
2011-10-18 06:57:23 +04:00
|
|
|
CHECK_FPU_FEATURE(dc, VIS2);
|
2012-10-16 13:32:13 +04:00
|
|
|
cpu_src1 = gen_load_gpr(dc, rs1);
|
|
|
|
cpu_src2 = gen_load_gpr(dc, rs2);
|
2011-10-18 06:57:23 +04:00
|
|
|
gen_edge(dc, cpu_dst, cpu_src1, cpu_src2, 16, 0, 1);
|
2012-10-16 13:32:13 +04:00
|
|
|
gen_store_gpr(dc, rd, cpu_dst);
|
2011-10-18 06:57:23 +04:00
|
|
|
break;
|
2007-04-22 23:14:52 +04:00
|
|
|
case 0x008: /* VIS I edge32cc */
|
2011-10-18 06:57:23 +04:00
|
|
|
CHECK_FPU_FEATURE(dc, VIS1);
|
2012-10-16 13:32:13 +04:00
|
|
|
cpu_src1 = gen_load_gpr(dc, rs1);
|
|
|
|
cpu_src2 = gen_load_gpr(dc, rs2);
|
2011-10-18 06:57:23 +04:00
|
|
|
gen_edge(dc, cpu_dst, cpu_src1, cpu_src2, 32, 1, 0);
|
2012-10-16 13:32:13 +04:00
|
|
|
gen_store_gpr(dc, rd, cpu_dst);
|
2011-10-18 06:57:23 +04:00
|
|
|
break;
|
2007-04-22 23:14:52 +04:00
|
|
|
case 0x009: /* VIS II edge32n */
|
2011-10-18 06:57:23 +04:00
|
|
|
CHECK_FPU_FEATURE(dc, VIS2);
|
2012-10-16 13:32:13 +04:00
|
|
|
cpu_src1 = gen_load_gpr(dc, rs1);
|
|
|
|
cpu_src2 = gen_load_gpr(dc, rs2);
|
2011-10-18 06:57:23 +04:00
|
|
|
gen_edge(dc, cpu_dst, cpu_src1, cpu_src2, 32, 0, 0);
|
2012-10-16 13:32:13 +04:00
|
|
|
gen_store_gpr(dc, rd, cpu_dst);
|
2011-10-18 06:57:23 +04:00
|
|
|
break;
|
2007-04-22 23:14:52 +04:00
|
|
|
case 0x00a: /* VIS I edge32lcc */
|
2011-10-18 06:57:23 +04:00
|
|
|
CHECK_FPU_FEATURE(dc, VIS1);
|
2012-10-16 13:32:13 +04:00
|
|
|
cpu_src1 = gen_load_gpr(dc, rs1);
|
|
|
|
cpu_src2 = gen_load_gpr(dc, rs2);
|
2011-10-18 06:57:23 +04:00
|
|
|
gen_edge(dc, cpu_dst, cpu_src1, cpu_src2, 32, 1, 1);
|
2012-10-16 13:32:13 +04:00
|
|
|
gen_store_gpr(dc, rd, cpu_dst);
|
2011-10-18 06:57:23 +04:00
|
|
|
break;
|
2007-04-22 23:14:52 +04:00
|
|
|
case 0x00b: /* VIS II edge32ln */
|
2011-10-18 06:57:23 +04:00
|
|
|
CHECK_FPU_FEATURE(dc, VIS2);
|
2012-10-16 13:32:13 +04:00
|
|
|
cpu_src1 = gen_load_gpr(dc, rs1);
|
|
|
|
cpu_src2 = gen_load_gpr(dc, rs2);
|
2011-10-18 06:57:23 +04:00
|
|
|
gen_edge(dc, cpu_dst, cpu_src1, cpu_src2, 32, 0, 1);
|
2012-10-16 13:32:13 +04:00
|
|
|
gen_store_gpr(dc, rd, cpu_dst);
|
2011-10-18 06:57:23 +04:00
|
|
|
break;
|
2007-04-22 23:14:52 +04:00
|
|
|
case 0x010: /* VIS I array8 */
|
2008-05-10 00:13:43 +04:00
|
|
|
CHECK_FPU_FEATURE(dc, VIS1);
|
2012-10-16 13:32:14 +04:00
|
|
|
cpu_src1 = gen_load_gpr(dc, rs1);
|
2012-10-16 13:32:13 +04:00
|
|
|
cpu_src2 = gen_load_gpr(dc, rs2);
|
2011-10-20 01:56:43 +04:00
|
|
|
gen_helper_array8(cpu_dst, cpu_src1, cpu_src2);
|
2012-10-16 13:32:13 +04:00
|
|
|
gen_store_gpr(dc, rd, cpu_dst);
|
2007-04-22 23:14:52 +04:00
|
|
|
break;
|
|
|
|
case 0x012: /* VIS I array16 */
|
2008-05-10 00:13:43 +04:00
|
|
|
CHECK_FPU_FEATURE(dc, VIS1);
|
2012-10-16 13:32:14 +04:00
|
|
|
cpu_src1 = gen_load_gpr(dc, rs1);
|
2012-10-16 13:32:13 +04:00
|
|
|
cpu_src2 = gen_load_gpr(dc, rs2);
|
2011-10-20 01:56:43 +04:00
|
|
|
gen_helper_array8(cpu_dst, cpu_src1, cpu_src2);
|
2008-03-29 12:09:25 +03:00
|
|
|
tcg_gen_shli_i64(cpu_dst, cpu_dst, 1);
|
2012-10-16 13:32:13 +04:00
|
|
|
gen_store_gpr(dc, rd, cpu_dst);
|
2007-04-22 23:14:52 +04:00
|
|
|
break;
|
|
|
|
case 0x014: /* VIS I array32 */
|
2008-05-10 00:13:43 +04:00
|
|
|
CHECK_FPU_FEATURE(dc, VIS1);
|
2012-10-16 13:32:14 +04:00
|
|
|
cpu_src1 = gen_load_gpr(dc, rs1);
|
2012-10-16 13:32:13 +04:00
|
|
|
cpu_src2 = gen_load_gpr(dc, rs2);
|
2011-10-20 01:56:43 +04:00
|
|
|
gen_helper_array8(cpu_dst, cpu_src1, cpu_src2);
|
2008-03-29 12:09:25 +03:00
|
|
|
tcg_gen_shli_i64(cpu_dst, cpu_dst, 2);
|
2012-10-16 13:32:13 +04:00
|
|
|
gen_store_gpr(dc, rd, cpu_dst);
|
2007-04-22 23:14:52 +04:00
|
|
|
break;
|
2007-04-13 19:49:56 +04:00
|
|
|
case 0x018: /* VIS I alignaddr */
|
2008-05-10 00:13:43 +04:00
|
|
|
CHECK_FPU_FEATURE(dc, VIS1);
|
2012-10-16 13:32:14 +04:00
|
|
|
cpu_src1 = gen_load_gpr(dc, rs1);
|
2012-10-16 13:32:13 +04:00
|
|
|
cpu_src2 = gen_load_gpr(dc, rs2);
|
2011-10-18 19:35:58 +04:00
|
|
|
gen_alignaddr(cpu_dst, cpu_src1, cpu_src2, 0);
|
2012-10-16 13:32:13 +04:00
|
|
|
gen_store_gpr(dc, rd, cpu_dst);
|
2007-04-13 19:49:56 +04:00
|
|
|
break;
|
|
|
|
case 0x01a: /* VIS I alignaddrl */
|
2011-10-18 19:35:58 +04:00
|
|
|
CHECK_FPU_FEATURE(dc, VIS1);
|
2012-10-16 13:32:14 +04:00
|
|
|
cpu_src1 = gen_load_gpr(dc, rs1);
|
2012-10-16 13:32:13 +04:00
|
|
|
cpu_src2 = gen_load_gpr(dc, rs2);
|
2011-10-18 19:35:58 +04:00
|
|
|
gen_alignaddr(cpu_dst, cpu_src1, cpu_src2, 1);
|
2012-10-16 13:32:13 +04:00
|
|
|
gen_store_gpr(dc, rd, cpu_dst);
|
2011-10-18 19:35:58 +04:00
|
|
|
break;
|
|
|
|
case 0x019: /* VIS II bmask */
|
2011-10-18 20:24:43 +04:00
|
|
|
CHECK_FPU_FEATURE(dc, VIS2);
|
2012-10-16 13:32:14 +04:00
|
|
|
cpu_src1 = gen_load_gpr(dc, rs1);
|
|
|
|
cpu_src2 = gen_load_gpr(dc, rs2);
|
2011-10-18 20:24:43 +04: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 13:32:13 +04:00
|
|
|
gen_store_gpr(dc, rd, cpu_dst);
|
2011-10-18 20:24:43 +04:00
|
|
|
break;
|
2007-04-22 23:14:52 +04:00
|
|
|
case 0x020: /* VIS I fcmple16 */
|
2008-05-10 00:13:43 +04:00
|
|
|
CHECK_FPU_FEATURE(dc, VIS1);
|
2011-10-15 21:20:20 +04:00
|
|
|
cpu_src1_64 = gen_load_fpr_D(dc, rs1);
|
|
|
|
cpu_src2_64 = gen_load_fpr_D(dc, rs2);
|
2011-10-20 01:56:43 +04:00
|
|
|
gen_helper_fcmple16(cpu_dst, cpu_src1_64, cpu_src2_64);
|
2012-10-16 13:32:13 +04:00
|
|
|
gen_store_gpr(dc, rd, cpu_dst);
|
2007-04-22 23:14:52 +04:00
|
|
|
break;
|
|
|
|
case 0x022: /* VIS I fcmpne16 */
|
2008-05-10 00:13:43 +04:00
|
|
|
CHECK_FPU_FEATURE(dc, VIS1);
|
2011-10-15 21:20:20 +04:00
|
|
|
cpu_src1_64 = gen_load_fpr_D(dc, rs1);
|
|
|
|
cpu_src2_64 = gen_load_fpr_D(dc, rs2);
|
2011-10-20 01:56:43 +04:00
|
|
|
gen_helper_fcmpne16(cpu_dst, cpu_src1_64, cpu_src2_64);
|
2012-10-16 13:32:13 +04:00
|
|
|
gen_store_gpr(dc, rd, cpu_dst);
|
2007-04-13 19:49:56 +04:00
|
|
|
break;
|
2007-04-22 23:14:52 +04:00
|
|
|
case 0x024: /* VIS I fcmple32 */
|
2008-05-10 00:13:43 +04:00
|
|
|
CHECK_FPU_FEATURE(dc, VIS1);
|
2011-10-15 21:20:20 +04:00
|
|
|
cpu_src1_64 = gen_load_fpr_D(dc, rs1);
|
|
|
|
cpu_src2_64 = gen_load_fpr_D(dc, rs2);
|
2011-10-20 01:56:43 +04:00
|
|
|
gen_helper_fcmple32(cpu_dst, cpu_src1_64, cpu_src2_64);
|
2012-10-16 13:32:13 +04:00
|
|
|
gen_store_gpr(dc, rd, cpu_dst);
|
2007-04-22 23:14:52 +04:00
|
|
|
break;
|
|
|
|
case 0x026: /* VIS I fcmpne32 */
|
2008-05-10 00:13:43 +04:00
|
|
|
CHECK_FPU_FEATURE(dc, VIS1);
|
2011-10-15 21:20:20 +04:00
|
|
|
cpu_src1_64 = gen_load_fpr_D(dc, rs1);
|
|
|
|
cpu_src2_64 = gen_load_fpr_D(dc, rs2);
|
2011-10-20 01:56:43 +04:00
|
|
|
gen_helper_fcmpne32(cpu_dst, cpu_src1_64, cpu_src2_64);
|
2012-10-16 13:32:13 +04:00
|
|
|
gen_store_gpr(dc, rd, cpu_dst);
|
2007-04-22 23:14:52 +04:00
|
|
|
break;
|
|
|
|
case 0x028: /* VIS I fcmpgt16 */
|
2008-05-10 00:13:43 +04:00
|
|
|
CHECK_FPU_FEATURE(dc, VIS1);
|
2011-10-15 21:20:20 +04:00
|
|
|
cpu_src1_64 = gen_load_fpr_D(dc, rs1);
|
|
|
|
cpu_src2_64 = gen_load_fpr_D(dc, rs2);
|
2011-10-20 01:56:43 +04:00
|
|
|
gen_helper_fcmpgt16(cpu_dst, cpu_src1_64, cpu_src2_64);
|
2012-10-16 13:32:13 +04:00
|
|
|
gen_store_gpr(dc, rd, cpu_dst);
|
2007-04-22 23:14:52 +04:00
|
|
|
break;
|
|
|
|
case 0x02a: /* VIS I fcmpeq16 */
|
2008-05-10 00:13:43 +04:00
|
|
|
CHECK_FPU_FEATURE(dc, VIS1);
|
2011-10-15 21:20:20 +04:00
|
|
|
cpu_src1_64 = gen_load_fpr_D(dc, rs1);
|
|
|
|
cpu_src2_64 = gen_load_fpr_D(dc, rs2);
|
2011-10-20 01:56:43 +04:00
|
|
|
gen_helper_fcmpeq16(cpu_dst, cpu_src1_64, cpu_src2_64);
|
2012-10-16 13:32:13 +04:00
|
|
|
gen_store_gpr(dc, rd, cpu_dst);
|
2007-04-22 23:14:52 +04:00
|
|
|
break;
|
|
|
|
case 0x02c: /* VIS I fcmpgt32 */
|
2008-05-10 00:13:43 +04:00
|
|
|
CHECK_FPU_FEATURE(dc, VIS1);
|
2011-10-15 21:20:20 +04:00
|
|
|
cpu_src1_64 = gen_load_fpr_D(dc, rs1);
|
|
|
|
cpu_src2_64 = gen_load_fpr_D(dc, rs2);
|
2011-10-20 01:56:43 +04:00
|
|
|
gen_helper_fcmpgt32(cpu_dst, cpu_src1_64, cpu_src2_64);
|
2012-10-16 13:32:13 +04:00
|
|
|
gen_store_gpr(dc, rd, cpu_dst);
|
2007-04-22 23:14:52 +04:00
|
|
|
break;
|
|
|
|
case 0x02e: /* VIS I fcmpeq32 */
|
2008-05-10 00:13:43 +04:00
|
|
|
CHECK_FPU_FEATURE(dc, VIS1);
|
2011-10-15 21:20:20 +04:00
|
|
|
cpu_src1_64 = gen_load_fpr_D(dc, rs1);
|
|
|
|
cpu_src2_64 = gen_load_fpr_D(dc, rs2);
|
2011-10-20 01:56:43 +04:00
|
|
|
gen_helper_fcmpeq32(cpu_dst, cpu_src1_64, cpu_src2_64);
|
2012-10-16 13:32:13 +04:00
|
|
|
gen_store_gpr(dc, rd, cpu_dst);
|
2007-04-22 23:14:52 +04:00
|
|
|
break;
|
|
|
|
case 0x031: /* VIS I fmul8x16 */
|
2008-05-10 00:13:43 +04:00
|
|
|
CHECK_FPU_FEATURE(dc, VIS1);
|
2011-10-15 22:52:00 +04:00
|
|
|
gen_ne_fop_DDD(dc, rd, rs1, rs2, gen_helper_fmul8x16);
|
2007-04-22 23:14:52 +04:00
|
|
|
break;
|
|
|
|
case 0x033: /* VIS I fmul8x16au */
|
2008-05-10 00:13:43 +04:00
|
|
|
CHECK_FPU_FEATURE(dc, VIS1);
|
2011-10-15 22:52:00 +04:00
|
|
|
gen_ne_fop_DDD(dc, rd, rs1, rs2, gen_helper_fmul8x16au);
|
2007-04-22 23:14:52 +04:00
|
|
|
break;
|
|
|
|
case 0x035: /* VIS I fmul8x16al */
|
2008-05-10 00:13:43 +04:00
|
|
|
CHECK_FPU_FEATURE(dc, VIS1);
|
2011-10-15 22:52:00 +04:00
|
|
|
gen_ne_fop_DDD(dc, rd, rs1, rs2, gen_helper_fmul8x16al);
|
2007-04-22 23:14:52 +04:00
|
|
|
break;
|
|
|
|
case 0x036: /* VIS I fmul8sux16 */
|
2008-05-10 00:13:43 +04:00
|
|
|
CHECK_FPU_FEATURE(dc, VIS1);
|
2011-10-15 22:52:00 +04:00
|
|
|
gen_ne_fop_DDD(dc, rd, rs1, rs2, gen_helper_fmul8sux16);
|
2007-04-22 23:14:52 +04:00
|
|
|
break;
|
|
|
|
case 0x037: /* VIS I fmul8ulx16 */
|
2008-05-10 00:13:43 +04:00
|
|
|
CHECK_FPU_FEATURE(dc, VIS1);
|
2011-10-15 22:52:00 +04:00
|
|
|
gen_ne_fop_DDD(dc, rd, rs1, rs2, gen_helper_fmul8ulx16);
|
2007-04-22 23:14:52 +04:00
|
|
|
break;
|
|
|
|
case 0x038: /* VIS I fmuld8sux16 */
|
2008-05-10 00:13:43 +04:00
|
|
|
CHECK_FPU_FEATURE(dc, VIS1);
|
2011-10-15 22:52:00 +04:00
|
|
|
gen_ne_fop_DDD(dc, rd, rs1, rs2, gen_helper_fmuld8sux16);
|
2007-04-22 23:14:52 +04:00
|
|
|
break;
|
|
|
|
case 0x039: /* VIS I fmuld8ulx16 */
|
2008-05-10 00:13:43 +04:00
|
|
|
CHECK_FPU_FEATURE(dc, VIS1);
|
2011-10-15 22:52:00 +04:00
|
|
|
gen_ne_fop_DDD(dc, rd, rs1, rs2, gen_helper_fmuld8ulx16);
|
2007-04-22 23:14:52 +04:00
|
|
|
break;
|
|
|
|
case 0x03a: /* VIS I fpack32 */
|
2011-10-18 05:03:47 +04:00
|
|
|
CHECK_FPU_FEATURE(dc, VIS1);
|
|
|
|
gen_gsr_fop_DDD(dc, rd, rs1, rs2, gen_helper_fpack32);
|
|
|
|
break;
|
2007-04-22 23:14:52 +04:00
|
|
|
case 0x03b: /* VIS I fpack16 */
|
2011-10-18 05:03:47 +04:00
|
|
|
CHECK_FPU_FEATURE(dc, VIS1);
|
|
|
|
cpu_src1_64 = gen_load_fpr_D(dc, rs2);
|
2012-10-16 13:32:21 +04:00
|
|
|
cpu_dst_32 = gen_dest_fpr_F(dc);
|
2011-10-18 05:03:47 +04: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 23:14:52 +04:00
|
|
|
case 0x03d: /* VIS I fpackfix */
|
2011-10-18 05:03:47 +04:00
|
|
|
CHECK_FPU_FEATURE(dc, VIS1);
|
|
|
|
cpu_src1_64 = gen_load_fpr_D(dc, rs2);
|
2012-10-16 13:32:21 +04:00
|
|
|
cpu_dst_32 = gen_dest_fpr_F(dc);
|
2011-10-18 05:03:47 +04: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 04:32:26 +04: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 19:49:56 +04:00
|
|
|
case 0x048: /* VIS I faligndata */
|
2008-05-10 00:13:43 +04:00
|
|
|
CHECK_FPU_FEATURE(dc, VIS1);
|
2011-10-18 20:41:30 +04:00
|
|
|
gen_gsr_fop_DDD(dc, rd, rs1, rs2, gen_faligndata);
|
2007-04-13 19:49:56 +04:00
|
|
|
break;
|
2007-04-22 23:14:52 +04:00
|
|
|
case 0x04b: /* VIS I fpmerge */
|
2008-05-10 00:13:43 +04:00
|
|
|
CHECK_FPU_FEATURE(dc, VIS1);
|
2011-10-15 22:52:00 +04:00
|
|
|
gen_ne_fop_DDD(dc, rd, rs1, rs2, gen_helper_fpmerge);
|
2007-04-22 23:14:52 +04:00
|
|
|
break;
|
|
|
|
case 0x04c: /* VIS II bshuffle */
|
2011-10-18 20:24:43 +04:00
|
|
|
CHECK_FPU_FEATURE(dc, VIS2);
|
|
|
|
gen_gsr_fop_DDD(dc, rd, rs1, rs2, gen_helper_bshuffle);
|
|
|
|
break;
|
2007-04-22 23:14:52 +04:00
|
|
|
case 0x04d: /* VIS I fexpand */
|
2008-05-10 00:13:43 +04:00
|
|
|
CHECK_FPU_FEATURE(dc, VIS1);
|
2011-10-15 22:52:00 +04:00
|
|
|
gen_ne_fop_DDD(dc, rd, rs1, rs2, gen_helper_fexpand);
|
2007-04-22 23:14:52 +04:00
|
|
|
break;
|
|
|
|
case 0x050: /* VIS I fpadd16 */
|
2008-05-10 00:13:43 +04:00
|
|
|
CHECK_FPU_FEATURE(dc, VIS1);
|
2011-10-15 22:52:00 +04:00
|
|
|
gen_ne_fop_DDD(dc, rd, rs1, rs2, gen_helper_fpadd16);
|
2007-04-22 23:14:52 +04:00
|
|
|
break;
|
|
|
|
case 0x051: /* VIS I fpadd16s */
|
2008-05-10 00:13:43 +04:00
|
|
|
CHECK_FPU_FEATURE(dc, VIS1);
|
2011-10-15 22:52:00 +04:00
|
|
|
gen_ne_fop_FFF(dc, rd, rs1, rs2, gen_helper_fpadd16s);
|
2007-04-22 23:14:52 +04:00
|
|
|
break;
|
|
|
|
case 0x052: /* VIS I fpadd32 */
|
2008-05-10 00:13:43 +04:00
|
|
|
CHECK_FPU_FEATURE(dc, VIS1);
|
2011-10-15 22:52:00 +04:00
|
|
|
gen_ne_fop_DDD(dc, rd, rs1, rs2, gen_helper_fpadd32);
|
2007-04-22 23:14:52 +04:00
|
|
|
break;
|
|
|
|
case 0x053: /* VIS I fpadd32s */
|
2008-05-10 00:13:43 +04:00
|
|
|
CHECK_FPU_FEATURE(dc, VIS1);
|
2011-10-15 22:52:00 +04:00
|
|
|
gen_ne_fop_FFF(dc, rd, rs1, rs2, tcg_gen_add_i32);
|
2007-04-22 23:14:52 +04:00
|
|
|
break;
|
|
|
|
case 0x054: /* VIS I fpsub16 */
|
2008-05-10 00:13:43 +04:00
|
|
|
CHECK_FPU_FEATURE(dc, VIS1);
|
2011-10-15 22:52:00 +04:00
|
|
|
gen_ne_fop_DDD(dc, rd, rs1, rs2, gen_helper_fpsub16);
|
2007-04-22 23:14:52 +04:00
|
|
|
break;
|
|
|
|
case 0x055: /* VIS I fpsub16s */
|
2008-05-10 00:13:43 +04:00
|
|
|
CHECK_FPU_FEATURE(dc, VIS1);
|
2011-10-15 22:52:00 +04:00
|
|
|
gen_ne_fop_FFF(dc, rd, rs1, rs2, gen_helper_fpsub16s);
|
2007-04-22 23:14:52 +04:00
|
|
|
break;
|
|
|
|
case 0x056: /* VIS I fpsub32 */
|
2008-05-10 00:13:43 +04:00
|
|
|
CHECK_FPU_FEATURE(dc, VIS1);
|
2011-10-15 22:52:00 +04:00
|
|
|
gen_ne_fop_DDD(dc, rd, rs1, rs2, gen_helper_fpsub32);
|
2007-04-22 23:14:52 +04:00
|
|
|
break;
|
|
|
|
case 0x057: /* VIS I fpsub32s */
|
2008-05-10 00:13:43 +04:00
|
|
|
CHECK_FPU_FEATURE(dc, VIS1);
|
2011-10-15 22:52:00 +04:00
|
|
|
gen_ne_fop_FFF(dc, rd, rs1, rs2, tcg_gen_sub_i32);
|
2007-04-22 23:14:52 +04:00
|
|
|
break;
|
2007-04-13 19:49:56 +04:00
|
|
|
case 0x060: /* VIS I fzero */
|
2008-05-10 00:13:43 +04:00
|
|
|
CHECK_FPU_FEATURE(dc, VIS1);
|
2012-10-16 13:32:26 +04:00
|
|
|
cpu_dst_64 = gen_dest_fpr_D(dc, rd);
|
2011-10-15 02:47:35 +04:00
|
|
|
tcg_gen_movi_i64(cpu_dst_64, 0);
|
|
|
|
gen_store_fpr_D(dc, rd, cpu_dst_64);
|
2007-04-13 19:49:56 +04:00
|
|
|
break;
|
|
|
|
case 0x061: /* VIS I fzeros */
|
2008-05-10 00:13:43 +04:00
|
|
|
CHECK_FPU_FEATURE(dc, VIS1);
|
2012-10-16 13:32:21 +04:00
|
|
|
cpu_dst_32 = gen_dest_fpr_F(dc);
|
2011-10-15 01:58:32 +04:00
|
|
|
tcg_gen_movi_i32(cpu_dst_32, 0);
|
|
|
|
gen_store_fpr_F(dc, rd, cpu_dst_32);
|
2007-04-13 19:49:56 +04:00
|
|
|
break;
|
2007-04-22 23:14:52 +04:00
|
|
|
case 0x062: /* VIS I fnor */
|
2008-05-10 00:13:43 +04:00
|
|
|
CHECK_FPU_FEATURE(dc, VIS1);
|
2011-10-15 22:52:00 +04:00
|
|
|
gen_ne_fop_DDD(dc, rd, rs1, rs2, tcg_gen_nor_i64);
|
2007-04-22 23:14:52 +04:00
|
|
|
break;
|
|
|
|
case 0x063: /* VIS I fnors */
|
2008-05-10 00:13:43 +04:00
|
|
|
CHECK_FPU_FEATURE(dc, VIS1);
|
2011-10-15 22:52:00 +04:00
|
|
|
gen_ne_fop_FFF(dc, rd, rs1, rs2, tcg_gen_nor_i32);
|
2007-04-22 23:14:52 +04:00
|
|
|
break;
|
|
|
|
case 0x064: /* VIS I fandnot2 */
|
2008-05-10 00:13:43 +04:00
|
|
|
CHECK_FPU_FEATURE(dc, VIS1);
|
2011-10-15 22:52:00 +04:00
|
|
|
gen_ne_fop_DDD(dc, rd, rs1, rs2, tcg_gen_andc_i64);
|
2007-04-22 23:14:52 +04:00
|
|
|
break;
|
|
|
|
case 0x065: /* VIS I fandnot2s */
|
2008-05-10 00:13:43 +04:00
|
|
|
CHECK_FPU_FEATURE(dc, VIS1);
|
2011-10-15 22:52:00 +04:00
|
|
|
gen_ne_fop_FFF(dc, rd, rs1, rs2, tcg_gen_andc_i32);
|
2007-04-22 23:14:52 +04:00
|
|
|
break;
|
|
|
|
case 0x066: /* VIS I fnot2 */
|
2008-05-10 00:13:43 +04:00
|
|
|
CHECK_FPU_FEATURE(dc, VIS1);
|
2011-10-15 22:52:00 +04:00
|
|
|
gen_ne_fop_DD(dc, rd, rs2, tcg_gen_not_i64);
|
2007-04-22 23:14:52 +04:00
|
|
|
break;
|
|
|
|
case 0x067: /* VIS I fnot2s */
|
2008-05-10 00:13:43 +04:00
|
|
|
CHECK_FPU_FEATURE(dc, VIS1);
|
2011-10-15 22:52:00 +04:00
|
|
|
gen_ne_fop_FF(dc, rd, rs2, tcg_gen_not_i32);
|
2007-04-22 23:14:52 +04:00
|
|
|
break;
|
|
|
|
case 0x068: /* VIS I fandnot1 */
|
2008-05-10 00:13:43 +04:00
|
|
|
CHECK_FPU_FEATURE(dc, VIS1);
|
2011-10-15 22:52:00 +04:00
|
|
|
gen_ne_fop_DDD(dc, rd, rs2, rs1, tcg_gen_andc_i64);
|
2007-04-22 23:14:52 +04:00
|
|
|
break;
|
|
|
|
case 0x069: /* VIS I fandnot1s */
|
2008-05-10 00:13:43 +04:00
|
|
|
CHECK_FPU_FEATURE(dc, VIS1);
|
2011-10-15 22:52:00 +04:00
|
|
|
gen_ne_fop_FFF(dc, rd, rs2, rs1, tcg_gen_andc_i32);
|
2007-04-22 23:14:52 +04:00
|
|
|
break;
|
|
|
|
case 0x06a: /* VIS I fnot1 */
|
2008-05-10 00:13:43 +04:00
|
|
|
CHECK_FPU_FEATURE(dc, VIS1);
|
2011-10-15 22:52:00 +04:00
|
|
|
gen_ne_fop_DD(dc, rd, rs1, tcg_gen_not_i64);
|
2007-04-22 23:14:52 +04:00
|
|
|
break;
|
|
|
|
case 0x06b: /* VIS I fnot1s */
|
2008-05-10 00:13:43 +04:00
|
|
|
CHECK_FPU_FEATURE(dc, VIS1);
|
2011-10-15 22:52:00 +04:00
|
|
|
gen_ne_fop_FF(dc, rd, rs1, tcg_gen_not_i32);
|
2007-04-22 23:14:52 +04:00
|
|
|
break;
|
|
|
|
case 0x06c: /* VIS I fxor */
|
2008-05-10 00:13:43 +04:00
|
|
|
CHECK_FPU_FEATURE(dc, VIS1);
|
2011-10-15 22:52:00 +04:00
|
|
|
gen_ne_fop_DDD(dc, rd, rs1, rs2, tcg_gen_xor_i64);
|
2007-04-22 23:14:52 +04:00
|
|
|
break;
|
|
|
|
case 0x06d: /* VIS I fxors */
|
2008-05-10 00:13:43 +04:00
|
|
|
CHECK_FPU_FEATURE(dc, VIS1);
|
2011-10-15 22:52:00 +04:00
|
|
|
gen_ne_fop_FFF(dc, rd, rs1, rs2, tcg_gen_xor_i32);
|
2007-04-22 23:14:52 +04:00
|
|
|
break;
|
|
|
|
case 0x06e: /* VIS I fnand */
|
2008-05-10 00:13:43 +04:00
|
|
|
CHECK_FPU_FEATURE(dc, VIS1);
|
2011-10-15 22:52:00 +04:00
|
|
|
gen_ne_fop_DDD(dc, rd, rs1, rs2, tcg_gen_nand_i64);
|
2007-04-22 23:14:52 +04:00
|
|
|
break;
|
|
|
|
case 0x06f: /* VIS I fnands */
|
2008-05-10 00:13:43 +04:00
|
|
|
CHECK_FPU_FEATURE(dc, VIS1);
|
2011-10-15 22:52:00 +04:00
|
|
|
gen_ne_fop_FFF(dc, rd, rs1, rs2, tcg_gen_nand_i32);
|
2007-04-22 23:14:52 +04:00
|
|
|
break;
|
|
|
|
case 0x070: /* VIS I fand */
|
2008-05-10 00:13:43 +04:00
|
|
|
CHECK_FPU_FEATURE(dc, VIS1);
|
2011-10-15 22:52:00 +04:00
|
|
|
gen_ne_fop_DDD(dc, rd, rs1, rs2, tcg_gen_and_i64);
|
2007-04-22 23:14:52 +04:00
|
|
|
break;
|
|
|
|
case 0x071: /* VIS I fands */
|
2008-05-10 00:13:43 +04:00
|
|
|
CHECK_FPU_FEATURE(dc, VIS1);
|
2011-10-15 22:52:00 +04:00
|
|
|
gen_ne_fop_FFF(dc, rd, rs1, rs2, tcg_gen_and_i32);
|
2007-04-22 23:14:52 +04:00
|
|
|
break;
|
|
|
|
case 0x072: /* VIS I fxnor */
|
2008-05-10 00:13:43 +04:00
|
|
|
CHECK_FPU_FEATURE(dc, VIS1);
|
2011-10-15 22:52:00 +04:00
|
|
|
gen_ne_fop_DDD(dc, rd, rs1, rs2, tcg_gen_eqv_i64);
|
2007-04-22 23:14:52 +04:00
|
|
|
break;
|
|
|
|
case 0x073: /* VIS I fxnors */
|
2008-05-10 00:13:43 +04:00
|
|
|
CHECK_FPU_FEATURE(dc, VIS1);
|
2011-10-15 22:52:00 +04:00
|
|
|
gen_ne_fop_FFF(dc, rd, rs1, rs2, tcg_gen_eqv_i32);
|
2007-04-22 23:14:52 +04:00
|
|
|
break;
|
2007-04-13 19:49:56 +04:00
|
|
|
case 0x074: /* VIS I fsrc1 */
|
2008-05-10 00:13:43 +04:00
|
|
|
CHECK_FPU_FEATURE(dc, VIS1);
|
2011-10-15 02:47:35 +04:00
|
|
|
cpu_src1_64 = gen_load_fpr_D(dc, rs1);
|
|
|
|
gen_store_fpr_D(dc, rd, cpu_src1_64);
|
2007-04-13 19:49:56 +04:00
|
|
|
break;
|
|
|
|
case 0x075: /* VIS I fsrc1s */
|
2008-05-10 00:13:43 +04:00
|
|
|
CHECK_FPU_FEATURE(dc, VIS1);
|
2011-10-15 01:58:32 +04:00
|
|
|
cpu_src1_32 = gen_load_fpr_F(dc, rs1);
|
|
|
|
gen_store_fpr_F(dc, rd, cpu_src1_32);
|
2007-04-13 19:49:56 +04:00
|
|
|
break;
|
2007-04-22 23:14:52 +04:00
|
|
|
case 0x076: /* VIS I fornot2 */
|
2008-05-10 00:13:43 +04:00
|
|
|
CHECK_FPU_FEATURE(dc, VIS1);
|
2011-10-15 22:52:00 +04:00
|
|
|
gen_ne_fop_DDD(dc, rd, rs1, rs2, tcg_gen_orc_i64);
|
2007-04-22 23:14:52 +04:00
|
|
|
break;
|
|
|
|
case 0x077: /* VIS I fornot2s */
|
2008-05-10 00:13:43 +04:00
|
|
|
CHECK_FPU_FEATURE(dc, VIS1);
|
2011-10-15 22:52:00 +04:00
|
|
|
gen_ne_fop_FFF(dc, rd, rs1, rs2, tcg_gen_orc_i32);
|
2007-04-22 23:14:52 +04:00
|
|
|
break;
|
2007-04-13 19:49:56 +04:00
|
|
|
case 0x078: /* VIS I fsrc2 */
|
2008-05-10 00:13:43 +04:00
|
|
|
CHECK_FPU_FEATURE(dc, VIS1);
|
2011-10-15 02:47:35 +04:00
|
|
|
cpu_src1_64 = gen_load_fpr_D(dc, rs2);
|
|
|
|
gen_store_fpr_D(dc, rd, cpu_src1_64);
|
2007-04-13 19:49:56 +04:00
|
|
|
break;
|
|
|
|
case 0x079: /* VIS I fsrc2s */
|
2008-05-10 00:13:43 +04:00
|
|
|
CHECK_FPU_FEATURE(dc, VIS1);
|
2011-10-15 01:58:32 +04:00
|
|
|
cpu_src1_32 = gen_load_fpr_F(dc, rs2);
|
|
|
|
gen_store_fpr_F(dc, rd, cpu_src1_32);
|
2007-04-13 19:49:56 +04:00
|
|
|
break;
|
2007-04-22 23:14:52 +04:00
|
|
|
case 0x07a: /* VIS I fornot1 */
|
2008-05-10 00:13:43 +04:00
|
|
|
CHECK_FPU_FEATURE(dc, VIS1);
|
2011-10-15 22:52:00 +04:00
|
|
|
gen_ne_fop_DDD(dc, rd, rs2, rs1, tcg_gen_orc_i64);
|
2007-04-22 23:14:52 +04:00
|
|
|
break;
|
|
|
|
case 0x07b: /* VIS I fornot1s */
|
2008-05-10 00:13:43 +04:00
|
|
|
CHECK_FPU_FEATURE(dc, VIS1);
|
2011-10-15 22:52:00 +04:00
|
|
|
gen_ne_fop_FFF(dc, rd, rs2, rs1, tcg_gen_orc_i32);
|
2007-04-22 23:14:52 +04:00
|
|
|
break;
|
|
|
|
case 0x07c: /* VIS I for */
|
2008-05-10 00:13:43 +04:00
|
|
|
CHECK_FPU_FEATURE(dc, VIS1);
|
2011-10-15 22:52:00 +04:00
|
|
|
gen_ne_fop_DDD(dc, rd, rs1, rs2, tcg_gen_or_i64);
|
2007-04-22 23:14:52 +04:00
|
|
|
break;
|
|
|
|
case 0x07d: /* VIS I fors */
|
2008-05-10 00:13:43 +04:00
|
|
|
CHECK_FPU_FEATURE(dc, VIS1);
|
2011-10-15 22:52:00 +04:00
|
|
|
gen_ne_fop_FFF(dc, rd, rs1, rs2, tcg_gen_or_i32);
|
2007-04-22 23:14:52 +04:00
|
|
|
break;
|
2007-04-13 19:49:56 +04:00
|
|
|
case 0x07e: /* VIS I fone */
|
2008-05-10 00:13:43 +04:00
|
|
|
CHECK_FPU_FEATURE(dc, VIS1);
|
2012-10-16 13:32:26 +04:00
|
|
|
cpu_dst_64 = gen_dest_fpr_D(dc, rd);
|
2011-10-15 02:47:35 +04:00
|
|
|
tcg_gen_movi_i64(cpu_dst_64, -1);
|
|
|
|
gen_store_fpr_D(dc, rd, cpu_dst_64);
|
2007-04-13 19:49:56 +04:00
|
|
|
break;
|
|
|
|
case 0x07f: /* VIS I fones */
|
2008-05-10 00:13:43 +04:00
|
|
|
CHECK_FPU_FEATURE(dc, VIS1);
|
2012-10-16 13:32:21 +04:00
|
|
|
cpu_dst_32 = gen_dest_fpr_F(dc);
|
2011-10-15 01:58:32 +04:00
|
|
|
tcg_gen_movi_i32(cpu_dst_32, -1);
|
|
|
|
gen_store_fpr_F(dc, rd, cpu_dst_32);
|
2007-04-13 19:49:56 +04:00
|
|
|
break;
|
2007-04-22 23:14:52 +04:00
|
|
|
case 0x080: /* VIS I shutdown */
|
|
|
|
case 0x081: /* VIS II siam */
|
|
|
|
// XXX
|
|
|
|
goto illegal_insn;
|
2007-04-13 19:49:56 +04:00
|
|
|
default:
|
|
|
|
goto illegal_insn;
|
|
|
|
}
|
|
|
|
#else
|
2007-09-20 18:54:22 +04:00
|
|
|
goto ncp_insn;
|
2007-04-13 19:49:56 +04:00
|
|
|
#endif
|
|
|
|
} else if (xop == 0x37) { /* V8 CPop2, V9 impdep2 */
|
2007-04-01 19:08:21 +04:00
|
|
|
#ifdef TARGET_SPARC64
|
2007-09-20 18:54:22 +04:00
|
|
|
goto illegal_insn;
|
2007-04-01 19:08:21 +04:00
|
|
|
#else
|
2007-09-20 18:54:22 +04:00
|
|
|
goto ncp_insn;
|
2007-04-01 19:08:21 +04:00
|
|
|
#endif
|
2005-07-02 18:31:34 +04:00
|
|
|
#ifdef TARGET_SPARC64
|
2007-09-20 18:54:22 +04:00
|
|
|
} else if (xop == 0x39) { /* V9 return */
|
2008-11-17 17:43:54 +03:00
|
|
|
TCGv_i32 r_const;
|
2008-05-27 23:39:12 +04:00
|
|
|
|
2012-10-06 03:54:53 +04:00
|
|
|
save_state(dc);
|
2012-10-16 13:32:14 +04:00
|
|
|
cpu_src1 = get_src1(dc, insn);
|
2012-10-16 13:32:31 +04:00
|
|
|
cpu_tmp0 = get_temp_tl(dc);
|
2007-09-20 18:54:22 +04:00
|
|
|
if (IS_IMM) { /* immediate */
|
2009-05-02 22:58:57 +04:00
|
|
|
simm = GET_FIELDs(insn, 19, 31);
|
2012-10-16 13:32:29 +04:00
|
|
|
tcg_gen_addi_tl(cpu_tmp0, cpu_src1, simm);
|
2007-09-20 18:54:22 +04:00
|
|
|
} else { /* register */
|
2005-07-02 18:31:34 +04:00
|
|
|
rs2 = GET_FIELD(insn, 27, 31);
|
2007-09-20 18:54:22 +04:00
|
|
|
if (rs2) {
|
2012-10-16 13:32:13 +04:00
|
|
|
cpu_src2 = gen_load_gpr(dc, rs2);
|
2012-10-16 13:32:29 +04:00
|
|
|
tcg_gen_add_tl(cpu_tmp0, cpu_src1, cpu_src2);
|
2012-10-16 13:32:13 +04:00
|
|
|
} else {
|
2012-10-16 13:32:29 +04:00
|
|
|
tcg_gen_mov_tl(cpu_tmp0, cpu_src1);
|
2012-10-16 13:32:13 +04:00
|
|
|
}
|
2005-07-02 18:31:34 +04:00
|
|
|
}
|
2011-07-04 01:01:59 +04:00
|
|
|
gen_helper_restore(cpu_env);
|
2012-10-06 03:54:54 +04:00
|
|
|
gen_mov_pc_npc(dc);
|
2008-05-27 23:39:12 +04:00
|
|
|
r_const = tcg_const_i32(3);
|
2012-10-16 13:32:29 +04:00
|
|
|
gen_helper_check_align(cpu_env, cpu_tmp0, r_const);
|
2008-11-17 17:43:54 +03:00
|
|
|
tcg_temp_free_i32(r_const);
|
2012-10-16 13:32:29 +04:00
|
|
|
tcg_gen_mov_tl(cpu_npc, cpu_tmp0);
|
2007-09-20 18:54:22 +04:00
|
|
|
dc->npc = DYNAMIC_PC;
|
|
|
|
goto jmp_insn;
|
2005-07-02 18:31:34 +04:00
|
|
|
#endif
|
2007-09-20 18:54:22 +04:00
|
|
|
} else {
|
2012-10-16 13:32:14 +04:00
|
|
|
cpu_src1 = get_src1(dc, insn);
|
2012-10-16 13:32:31 +04:00
|
|
|
cpu_tmp0 = get_temp_tl(dc);
|
2007-09-20 18:54:22 +04:00
|
|
|
if (IS_IMM) { /* immediate */
|
2009-05-02 22:58:57 +04:00
|
|
|
simm = GET_FIELDs(insn, 19, 31);
|
2012-10-16 13:32:29 +04:00
|
|
|
tcg_gen_addi_tl(cpu_tmp0, cpu_src1, simm);
|
2007-09-20 18:54:22 +04:00
|
|
|
} else { /* register */
|
2004-12-20 02:18:01 +03:00
|
|
|
rs2 = GET_FIELD(insn, 27, 31);
|
2007-09-20 18:54:22 +04:00
|
|
|
if (rs2) {
|
2012-10-16 13:32:13 +04:00
|
|
|
cpu_src2 = gen_load_gpr(dc, rs2);
|
2012-10-16 13:32:29 +04:00
|
|
|
tcg_gen_add_tl(cpu_tmp0, cpu_src1, cpu_src2);
|
2012-10-16 13:32:13 +04:00
|
|
|
} else {
|
2012-10-16 13:32:29 +04:00
|
|
|
tcg_gen_mov_tl(cpu_tmp0, cpu_src1);
|
2012-10-16 13:32:13 +04:00
|
|
|
}
|
2004-01-04 18:01:44 +03:00
|
|
|
}
|
2007-09-20 18:54:22 +04:00
|
|
|
switch (xop) {
|
|
|
|
case 0x38: /* jmpl */
|
|
|
|
{
|
2012-10-16 13:32:13 +04:00
|
|
|
TCGv t;
|
2008-11-17 17:43:54 +03:00
|
|
|
TCGv_i32 r_const;
|
2008-05-27 23:39:12 +04:00
|
|
|
|
2012-10-16 13:32:13 +04:00
|
|
|
t = gen_dest_gpr(dc, rd);
|
|
|
|
tcg_gen_movi_tl(t, dc->pc);
|
|
|
|
gen_store_gpr(dc, rd, t);
|
2012-10-06 03:54:54 +04:00
|
|
|
gen_mov_pc_npc(dc);
|
2008-05-27 23:39:12 +04:00
|
|
|
r_const = tcg_const_i32(3);
|
2012-10-16 13:32:29 +04:00
|
|
|
gen_helper_check_align(cpu_env, cpu_tmp0, r_const);
|
2008-11-17 17:43:54 +03:00
|
|
|
tcg_temp_free_i32(r_const);
|
2012-10-16 13:32:29 +04:00
|
|
|
gen_address_mask(dc, cpu_tmp0);
|
|
|
|
tcg_gen_mov_tl(cpu_npc, cpu_tmp0);
|
2007-09-20 18:54:22 +04:00
|
|
|
dc->npc = DYNAMIC_PC;
|
|
|
|
}
|
|
|
|
goto jmp_insn;
|
2005-07-02 18:31:34 +04:00
|
|
|
#if !defined(CONFIG_USER_ONLY) && !defined(TARGET_SPARC64)
|
2007-09-20 18:54:22 +04:00
|
|
|
case 0x39: /* rett, V9 return */
|
|
|
|
{
|
2008-11-17 17:43:54 +03:00
|
|
|
TCGv_i32 r_const;
|
2008-05-27 23:39:12 +04:00
|
|
|
|
2007-09-20 18:54:22 +04:00
|
|
|
if (!supervisor(dc))
|
|
|
|
goto priv_insn;
|
2012-10-06 03:54:54 +04:00
|
|
|
gen_mov_pc_npc(dc);
|
2008-05-27 23:39:12 +04:00
|
|
|
r_const = tcg_const_i32(3);
|
2012-10-16 13:32:29 +04:00
|
|
|
gen_helper_check_align(cpu_env, cpu_tmp0, r_const);
|
2008-11-17 17:43:54 +03:00
|
|
|
tcg_temp_free_i32(r_const);
|
2012-10-16 13:32:29 +04:00
|
|
|
tcg_gen_mov_tl(cpu_npc, cpu_tmp0);
|
2007-09-20 18:54:22 +04:00
|
|
|
dc->npc = DYNAMIC_PC;
|
2011-07-04 01:01:59 +04:00
|
|
|
gen_helper_rett(cpu_env);
|
2007-09-20 18:54:22 +04:00
|
|
|
}
|
|
|
|
goto jmp_insn;
|
|
|
|
#endif
|
|
|
|
case 0x3b: /* flush */
|
2008-08-21 21:33:42 +04:00
|
|
|
if (!((dc)->def->features & CPU_FEATURE_FLUSH))
|
2008-05-10 00:13:43 +04:00
|
|
|
goto unimp_flush;
|
2011-05-14 15:55:30 +04:00
|
|
|
/* nop */
|
2007-09-20 18:54:22 +04:00
|
|
|
break;
|
|
|
|
case 0x3c: /* save */
|
2012-10-06 03:54:53 +04:00
|
|
|
save_state(dc);
|
2011-07-04 01:01:59 +04:00
|
|
|
gen_helper_save(cpu_env);
|
2012-10-16 13:32:29 +04:00
|
|
|
gen_store_gpr(dc, rd, cpu_tmp0);
|
2007-09-20 18:54:22 +04:00
|
|
|
break;
|
|
|
|
case 0x3d: /* restore */
|
2012-10-06 03:54:53 +04:00
|
|
|
save_state(dc);
|
2011-07-04 01:01:59 +04:00
|
|
|
gen_helper_restore(cpu_env);
|
2012-10-16 13:32:29 +04:00
|
|
|
gen_store_gpr(dc, rd, cpu_tmp0);
|
2007-09-20 18:54:22 +04:00
|
|
|
break;
|
2005-07-02 18:31:34 +04:00
|
|
|
#if !defined(CONFIG_USER_ONLY) && defined(TARGET_SPARC64)
|
2007-09-20 18:54:22 +04:00
|
|
|
case 0x3e: /* V9 done/retry */
|
|
|
|
{
|
|
|
|
switch (rd) {
|
|
|
|
case 0:
|
|
|
|
if (!supervisor(dc))
|
|
|
|
goto priv_insn;
|
|
|
|
dc->npc = DYNAMIC_PC;
|
|
|
|
dc->pc = DYNAMIC_PC;
|
2011-07-04 01:01:59 +04:00
|
|
|
gen_helper_done(cpu_env);
|
2007-09-20 18:54:22 +04:00
|
|
|
goto jmp_insn;
|
|
|
|
case 1:
|
|
|
|
if (!supervisor(dc))
|
|
|
|
goto priv_insn;
|
|
|
|
dc->npc = DYNAMIC_PC;
|
|
|
|
dc->pc = DYNAMIC_PC;
|
2011-07-04 01:01:59 +04:00
|
|
|
gen_helper_retry(cpu_env);
|
2007-09-20 18:54:22 +04:00
|
|
|
goto jmp_insn;
|
|
|
|
default:
|
|
|
|
goto illegal_insn;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
#endif
|
|
|
|
default:
|
|
|
|
goto illegal_insn;
|
|
|
|
}
|
2004-01-04 18:01:44 +03:00
|
|
|
}
|
2007-09-20 18:54:22 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 3: /* load/store instructions */
|
|
|
|
{
|
|
|
|
unsigned int xop = GET_FIELD(insn, 7, 12);
|
2012-10-16 13:32:19 +04:00
|
|
|
/* ??? gen_address_mask prevents us from using a source
|
|
|
|
register directly. Always generate a temporary. */
|
|
|
|
TCGv cpu_addr = get_temp_tl(dc);
|
2008-03-29 23:38:35 +03:00
|
|
|
|
2012-10-16 13:32:19 +04:00
|
|
|
tcg_gen_mov_tl(cpu_addr, get_src1(dc, insn));
|
|
|
|
if (xop == 0x3c || xop == 0x3e) {
|
|
|
|
/* V9 casa/casxa : no offset */
|
2008-07-15 18:52:09 +04:00
|
|
|
} else if (IS_IMM) { /* immediate */
|
2009-05-02 22:58:57 +04:00
|
|
|
simm = GET_FIELDs(insn, 19, 31);
|
2012-10-16 13:32:19 +04:00
|
|
|
if (simm != 0) {
|
|
|
|
tcg_gen_addi_tl(cpu_addr, cpu_addr, simm);
|
|
|
|
}
|
2007-09-20 18:54:22 +04:00
|
|
|
} else { /* register */
|
|
|
|
rs2 = GET_FIELD(insn, 27, 31);
|
|
|
|
if (rs2 != 0) {
|
2012-10-16 13:32:19 +04:00
|
|
|
tcg_gen_add_tl(cpu_addr, cpu_addr, gen_load_gpr(dc, rs2));
|
2012-10-16 13:32:13 +04:00
|
|
|
}
|
2007-09-20 18:54:22 +04:00
|
|
|
}
|
2007-06-11 00:26:38 +04: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 13:32:17 +04:00
|
|
|
TCGv cpu_val = gen_dest_gpr(dc, rd);
|
|
|
|
|
2007-09-20 18:54:22 +04:00
|
|
|
switch (xop) {
|
2009-05-03 00:19:46 +04:00
|
|
|
case 0x0: /* ld, V9 lduw, load unsigned word */
|
2008-07-17 16:53:05 +04:00
|
|
|
gen_address_mask(dc, cpu_addr);
|
2008-03-29 12:09:25 +03:00
|
|
|
tcg_gen_qemu_ld32u(cpu_val, cpu_addr, dc->mem_idx);
|
2007-09-20 18:54:22 +04:00
|
|
|
break;
|
2009-05-03 00:19:46 +04:00
|
|
|
case 0x1: /* ldub, load unsigned byte */
|
2008-07-17 16:53:05 +04:00
|
|
|
gen_address_mask(dc, cpu_addr);
|
2008-03-29 12:09:25 +03:00
|
|
|
tcg_gen_qemu_ld8u(cpu_val, cpu_addr, dc->mem_idx);
|
2007-09-20 18:54:22 +04:00
|
|
|
break;
|
2009-05-03 00:19:46 +04:00
|
|
|
case 0x2: /* lduh, load unsigned halfword */
|
2008-07-17 16:53:05 +04:00
|
|
|
gen_address_mask(dc, cpu_addr);
|
2008-03-29 12:09:25 +03:00
|
|
|
tcg_gen_qemu_ld16u(cpu_val, cpu_addr, dc->mem_idx);
|
2007-09-20 18:54:22 +04:00
|
|
|
break;
|
2009-05-03 00:19:46 +04:00
|
|
|
case 0x3: /* ldd, load double word */
|
2007-09-20 18:54:22 +04:00
|
|
|
if (rd & 1)
|
2007-04-01 19:15:36 +04:00
|
|
|
goto illegal_insn;
|
2008-02-24 17:10:06 +03:00
|
|
|
else {
|
2008-11-17 17:43:54 +03:00
|
|
|
TCGv_i32 r_const;
|
2012-10-16 13:32:28 +04:00
|
|
|
TCGv_i64 t64;
|
2008-05-27 23:39:12 +04:00
|
|
|
|
2012-10-06 03:54:53 +04:00
|
|
|
save_state(dc);
|
2008-05-27 23:39:12 +04:00
|
|
|
r_const = tcg_const_i32(7);
|
2011-07-05 00:34:28 +04:00
|
|
|
/* XXX remove alignment check */
|
|
|
|
gen_helper_check_align(cpu_env, cpu_addr, r_const);
|
2008-11-17 17:43:54 +03:00
|
|
|
tcg_temp_free_i32(r_const);
|
2008-07-17 16:53:05 +04:00
|
|
|
gen_address_mask(dc, cpu_addr);
|
2012-10-16 13:32:28 +04:00
|
|
|
t64 = tcg_temp_new_i64();
|
|
|
|
tcg_gen_qemu_ld64(t64, cpu_addr, dc->mem_idx);
|
2012-10-16 13:32:31 +04: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 13:32:28 +04:00
|
|
|
tcg_gen_shri_i64(t64, t64, 32);
|
|
|
|
tcg_gen_trunc_i64_tl(cpu_val, t64);
|
|
|
|
tcg_temp_free_i64(t64);
|
2012-10-16 13:32:31 +04:00
|
|
|
tcg_gen_ext32u_tl(cpu_val, cpu_val);
|
2008-02-24 17:10:06 +03:00
|
|
|
}
|
2007-09-20 18:54:22 +04:00
|
|
|
break;
|
2009-05-03 00:19:46 +04:00
|
|
|
case 0x9: /* ldsb, load signed byte */
|
2008-07-17 16:53:05 +04:00
|
|
|
gen_address_mask(dc, cpu_addr);
|
2008-03-29 12:09:25 +03:00
|
|
|
tcg_gen_qemu_ld8s(cpu_val, cpu_addr, dc->mem_idx);
|
2007-09-20 18:54:22 +04:00
|
|
|
break;
|
2009-05-03 00:19:46 +04:00
|
|
|
case 0xa: /* ldsh, load signed halfword */
|
2008-07-17 16:53:05 +04:00
|
|
|
gen_address_mask(dc, cpu_addr);
|
2008-03-29 12:09:25 +03:00
|
|
|
tcg_gen_qemu_ld16s(cpu_val, cpu_addr, dc->mem_idx);
|
2007-09-20 18:54:22 +04:00
|
|
|
break;
|
|
|
|
case 0xd: /* ldstub -- XXX: should be atomically */
|
2008-05-27 23:39:12 +04:00
|
|
|
{
|
|
|
|
TCGv r_const;
|
|
|
|
|
2008-07-17 16:53:05 +04:00
|
|
|
gen_address_mask(dc, cpu_addr);
|
2008-05-27 23:39:12 +04:00
|
|
|
tcg_gen_qemu_ld8s(cpu_val, cpu_addr, dc->mem_idx);
|
|
|
|
r_const = tcg_const_tl(0xff);
|
|
|
|
tcg_gen_qemu_st8(r_const, cpu_addr, dc->mem_idx);
|
|
|
|
tcg_temp_free(r_const);
|
|
|
|
}
|
2007-09-20 18:54:22 +04:00
|
|
|
break;
|
2012-10-16 13:32:31 +04:00
|
|
|
case 0x0f:
|
|
|
|
/* swap, swap register with memory. Also atomically */
|
|
|
|
{
|
|
|
|
TCGv t0 = get_temp_tl(dc);
|
|
|
|
CHECK_IU_FEATURE(dc, SWAP);
|
|
|
|
cpu_src1 = gen_load_gpr(dc, rd);
|
|
|
|
gen_address_mask(dc, cpu_addr);
|
|
|
|
tcg_gen_qemu_ld32u(t0, cpu_addr, dc->mem_idx);
|
|
|
|
tcg_gen_qemu_st32(cpu_src1, cpu_addr, dc->mem_idx);
|
|
|
|
tcg_gen_mov_tl(cpu_val, t0);
|
|
|
|
}
|
2007-09-20 18:54:22 +04:00
|
|
|
break;
|
2005-07-02 18:31:34 +04:00
|
|
|
#if !defined(CONFIG_USER_ONLY) || defined(TARGET_SPARC64)
|
2009-05-03 00:19:46 +04:00
|
|
|
case 0x10: /* lda, V9 lduwa, load word alternate */
|
2005-07-02 18:31:34 +04:00
|
|
|
#ifndef TARGET_SPARC64
|
2007-09-20 18:54:22 +04:00
|
|
|
if (IS_IMM)
|
|
|
|
goto illegal_insn;
|
|
|
|
if (!supervisor(dc))
|
|
|
|
goto priv_insn;
|
2007-07-11 20:43:30 +04:00
|
|
|
#endif
|
2012-10-06 03:54:53 +04:00
|
|
|
save_state(dc);
|
2008-03-29 12:09:25 +03:00
|
|
|
gen_ld_asi(cpu_val, cpu_addr, insn, 4, 0);
|
2007-09-20 18:54:22 +04:00
|
|
|
break;
|
2009-05-03 00:19:46 +04:00
|
|
|
case 0x11: /* lduba, load unsigned byte alternate */
|
2005-07-02 18:31:34 +04:00
|
|
|
#ifndef TARGET_SPARC64
|
2007-09-20 18:54:22 +04:00
|
|
|
if (IS_IMM)
|
|
|
|
goto illegal_insn;
|
|
|
|
if (!supervisor(dc))
|
|
|
|
goto priv_insn;
|
|
|
|
#endif
|
2012-10-06 03:54:53 +04:00
|
|
|
save_state(dc);
|
2008-03-29 12:09:25 +03:00
|
|
|
gen_ld_asi(cpu_val, cpu_addr, insn, 1, 0);
|
2007-09-20 18:54:22 +04:00
|
|
|
break;
|
2009-05-03 00:19:46 +04:00
|
|
|
case 0x12: /* lduha, load unsigned halfword alternate */
|
2005-07-02 18:31:34 +04:00
|
|
|
#ifndef TARGET_SPARC64
|
2007-09-20 18:54:22 +04:00
|
|
|
if (IS_IMM)
|
|
|
|
goto illegal_insn;
|
|
|
|
if (!supervisor(dc))
|
|
|
|
goto priv_insn;
|
2005-07-02 18:31:34 +04:00
|
|
|
#endif
|
2012-10-06 03:54:53 +04:00
|
|
|
save_state(dc);
|
2008-03-29 12:09:25 +03:00
|
|
|
gen_ld_asi(cpu_val, cpu_addr, insn, 2, 0);
|
2007-09-20 18:54:22 +04:00
|
|
|
break;
|
2009-05-03 00:19:46 +04:00
|
|
|
case 0x13: /* ldda, load double word alternate */
|
2005-07-02 18:31:34 +04:00
|
|
|
#ifndef TARGET_SPARC64
|
2007-09-20 18:54:22 +04:00
|
|
|
if (IS_IMM)
|
|
|
|
goto illegal_insn;
|
|
|
|
if (!supervisor(dc))
|
|
|
|
goto priv_insn;
|
2005-07-02 18:31:34 +04:00
|
|
|
#endif
|
2007-09-20 18:54:22 +04:00
|
|
|
if (rd & 1)
|
2007-04-01 19:15:36 +04:00
|
|
|
goto illegal_insn;
|
2012-10-06 03:54:53 +04:00
|
|
|
save_state(dc);
|
2012-10-16 13:32:15 +04:00
|
|
|
gen_ldda_asi(dc, cpu_val, cpu_addr, insn, rd);
|
2008-07-19 17:25:28 +04:00
|
|
|
goto skip_move;
|
2009-05-03 00:19:46 +04:00
|
|
|
case 0x19: /* ldsba, load signed byte alternate */
|
2005-07-02 18:31:34 +04:00
|
|
|
#ifndef TARGET_SPARC64
|
2007-09-20 18:54:22 +04:00
|
|
|
if (IS_IMM)
|
|
|
|
goto illegal_insn;
|
|
|
|
if (!supervisor(dc))
|
|
|
|
goto priv_insn;
|
|
|
|
#endif
|
2012-10-06 03:54:53 +04:00
|
|
|
save_state(dc);
|
2008-03-29 12:09:25 +03:00
|
|
|
gen_ld_asi(cpu_val, cpu_addr, insn, 1, 1);
|
2007-09-20 18:54:22 +04:00
|
|
|
break;
|
2009-05-03 00:19:46 +04:00
|
|
|
case 0x1a: /* ldsha, load signed halfword alternate */
|
2005-07-02 18:31:34 +04:00
|
|
|
#ifndef TARGET_SPARC64
|
2007-09-20 18:54:22 +04:00
|
|
|
if (IS_IMM)
|
|
|
|
goto illegal_insn;
|
|
|
|
if (!supervisor(dc))
|
|
|
|
goto priv_insn;
|
2005-07-02 18:31:34 +04:00
|
|
|
#endif
|
2012-10-06 03:54:53 +04:00
|
|
|
save_state(dc);
|
2008-03-29 12:09:25 +03:00
|
|
|
gen_ld_asi(cpu_val, cpu_addr, insn, 2, 1);
|
2007-09-20 18:54:22 +04:00
|
|
|
break;
|
|
|
|
case 0x1d: /* ldstuba -- XXX: should be atomically */
|
2005-07-02 18:31:34 +04:00
|
|
|
#ifndef TARGET_SPARC64
|
2007-09-20 18:54:22 +04:00
|
|
|
if (IS_IMM)
|
|
|
|
goto illegal_insn;
|
|
|
|
if (!supervisor(dc))
|
|
|
|
goto priv_insn;
|
|
|
|
#endif
|
2012-10-06 03:54:53 +04:00
|
|
|
save_state(dc);
|
2008-03-29 12:09:25 +03:00
|
|
|
gen_ldstub_asi(cpu_val, cpu_addr, insn);
|
2007-09-20 18:54:22 +04:00
|
|
|
break;
|
2009-05-03 00:19:46 +04:00
|
|
|
case 0x1f: /* swapa, swap reg with alt. memory. Also
|
2008-05-12 20:13:33 +04:00
|
|
|
atomically */
|
2008-05-10 00:13:43 +04:00
|
|
|
CHECK_IU_FEATURE(dc, SWAP);
|
2005-07-02 18:31:34 +04:00
|
|
|
#ifndef TARGET_SPARC64
|
2007-09-20 18:54:22 +04:00
|
|
|
if (IS_IMM)
|
|
|
|
goto illegal_insn;
|
|
|
|
if (!supervisor(dc))
|
|
|
|
goto priv_insn;
|
2007-07-11 20:43:30 +04:00
|
|
|
#endif
|
2012-10-06 03:54:53 +04:00
|
|
|
save_state(dc);
|
2012-10-16 13:32:16 +04:00
|
|
|
cpu_src1 = gen_load_gpr(dc, rd);
|
|
|
|
gen_swap_asi(cpu_val, cpu_src1, cpu_addr, insn);
|
2007-09-20 18:54:22 +04:00
|
|
|
break;
|
2005-07-02 18:31:34 +04:00
|
|
|
|
|
|
|
#ifndef TARGET_SPARC64
|
2007-09-20 18:54:22 +04:00
|
|
|
case 0x30: /* ldc */
|
|
|
|
case 0x31: /* ldcsr */
|
|
|
|
case 0x33: /* lddc */
|
|
|
|
goto ncp_insn;
|
2005-07-02 18:31:34 +04:00
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
#ifdef TARGET_SPARC64
|
2007-09-20 18:54:22 +04:00
|
|
|
case 0x08: /* V9 ldsw */
|
2008-07-17 16:53:05 +04:00
|
|
|
gen_address_mask(dc, cpu_addr);
|
2008-03-29 12:09:25 +03:00
|
|
|
tcg_gen_qemu_ld32s(cpu_val, cpu_addr, dc->mem_idx);
|
2007-09-20 18:54:22 +04:00
|
|
|
break;
|
|
|
|
case 0x0b: /* V9 ldx */
|
2008-07-17 16:53:05 +04:00
|
|
|
gen_address_mask(dc, cpu_addr);
|
2008-03-29 12:09:25 +03:00
|
|
|
tcg_gen_qemu_ld64(cpu_val, cpu_addr, dc->mem_idx);
|
2007-09-20 18:54:22 +04:00
|
|
|
break;
|
|
|
|
case 0x18: /* V9 ldswa */
|
2012-10-06 03:54:53 +04:00
|
|
|
save_state(dc);
|
2008-03-29 12:09:25 +03:00
|
|
|
gen_ld_asi(cpu_val, cpu_addr, insn, 4, 1);
|
2007-09-20 18:54:22 +04:00
|
|
|
break;
|
|
|
|
case 0x1b: /* V9 ldxa */
|
2012-10-06 03:54:53 +04:00
|
|
|
save_state(dc);
|
2008-03-29 12:09:25 +03:00
|
|
|
gen_ld_asi(cpu_val, cpu_addr, insn, 8, 0);
|
2007-09-20 18:54:22 +04:00
|
|
|
break;
|
|
|
|
case 0x2d: /* V9 prefetch, no effect */
|
|
|
|
goto skip_move;
|
|
|
|
case 0x30: /* V9 ldfa */
|
2012-10-06 03:54:52 +04:00
|
|
|
if (gen_trap_ifnofpu(dc)) {
|
2011-07-14 13:41:37 +04:00
|
|
|
goto jmp_insn;
|
|
|
|
}
|
2012-10-06 03:54:53 +04:00
|
|
|
save_state(dc);
|
2008-03-29 12:09:25 +03:00
|
|
|
gen_ldf_asi(cpu_addr, insn, 4, rd);
|
2011-07-23 06:20:07 +04:00
|
|
|
gen_update_fprs_dirty(rd);
|
2007-09-21 23:10:53 +04:00
|
|
|
goto skip_move;
|
2007-09-20 18:54:22 +04:00
|
|
|
case 0x33: /* V9 lddfa */
|
2012-10-06 03:54:52 +04:00
|
|
|
if (gen_trap_ifnofpu(dc)) {
|
2011-07-14 13:41:37 +04:00
|
|
|
goto jmp_insn;
|
|
|
|
}
|
2012-10-06 03:54:53 +04:00
|
|
|
save_state(dc);
|
2008-03-29 12:09:25 +03:00
|
|
|
gen_ldf_asi(cpu_addr, insn, 8, DFPREG(rd));
|
2011-07-23 06:20:07 +04:00
|
|
|
gen_update_fprs_dirty(DFPREG(rd));
|
2007-09-21 23:10:53 +04:00
|
|
|
goto skip_move;
|
2007-09-20 18:54:22 +04:00
|
|
|
case 0x3d: /* V9 prefetcha, no effect */
|
|
|
|
goto skip_move;
|
|
|
|
case 0x32: /* V9 ldqfa */
|
2008-05-10 00:13:43 +04:00
|
|
|
CHECK_FPU_FEATURE(dc, FLOAT128);
|
2012-10-06 03:54:52 +04:00
|
|
|
if (gen_trap_ifnofpu(dc)) {
|
2011-07-14 13:41:37 +04:00
|
|
|
goto jmp_insn;
|
|
|
|
}
|
2012-10-06 03:54:53 +04:00
|
|
|
save_state(dc);
|
2008-03-29 12:09:25 +03:00
|
|
|
gen_ldf_asi(cpu_addr, insn, 16, QFPREG(rd));
|
2011-07-23 06:20:07 +04:00
|
|
|
gen_update_fprs_dirty(QFPREG(rd));
|
2007-11-25 21:40:20 +03:00
|
|
|
goto skip_move;
|
2007-09-20 18:54:22 +04:00
|
|
|
#endif
|
|
|
|
default:
|
|
|
|
goto illegal_insn;
|
|
|
|
}
|
2012-10-16 13:32:13 +04:00
|
|
|
gen_store_gpr(dc, rd, cpu_val);
|
2008-07-19 17:25:28 +04:00
|
|
|
#if !defined(CONFIG_USER_ONLY) || defined(TARGET_SPARC64)
|
2007-09-20 18:54:22 +04:00
|
|
|
skip_move: ;
|
2005-07-02 18:31:34 +04:00
|
|
|
#endif
|
2007-09-20 18:54:22 +04:00
|
|
|
} else if (xop >= 0x20 && xop < 0x24) {
|
2012-10-16 13:32:31 +04:00
|
|
|
TCGv t0;
|
|
|
|
|
2012-10-06 03:54:52 +04:00
|
|
|
if (gen_trap_ifnofpu(dc)) {
|
2006-06-26 23:53:29 +04:00
|
|
|
goto jmp_insn;
|
2012-10-06 03:54:52 +04:00
|
|
|
}
|
2012-10-06 03:54:53 +04:00
|
|
|
save_state(dc);
|
2007-09-20 18:54:22 +04:00
|
|
|
switch (xop) {
|
2009-05-03 00:19:46 +04:00
|
|
|
case 0x20: /* ldf, load fpreg */
|
2008-07-17 16:53:05 +04:00
|
|
|
gen_address_mask(dc, cpu_addr);
|
2012-10-16 13:32:31 +04:00
|
|
|
t0 = get_temp_tl(dc);
|
|
|
|
tcg_gen_qemu_ld32u(t0, cpu_addr, dc->mem_idx);
|
2012-10-16 13:32:21 +04:00
|
|
|
cpu_dst_32 = gen_dest_fpr_F(dc);
|
2012-10-16 13:32:31 +04:00
|
|
|
tcg_gen_trunc_tl_i32(cpu_dst_32, t0);
|
2011-10-15 01:58:32 +04:00
|
|
|
gen_store_fpr_F(dc, rd, cpu_dst_32);
|
2007-09-20 18:54:22 +04:00
|
|
|
break;
|
2008-09-09 23:02:49 +04:00
|
|
|
case 0x21: /* ldfsr, V9 ldxfsr */
|
|
|
|
#ifdef TARGET_SPARC64
|
2008-07-17 16:53:05 +04:00
|
|
|
gen_address_mask(dc, cpu_addr);
|
2008-09-09 23:02:49 +04:00
|
|
|
if (rd == 1) {
|
2012-10-16 13:32:28 +04:00
|
|
|
TCGv_i64 t64 = tcg_temp_new_i64();
|
|
|
|
tcg_gen_qemu_ld64(t64, cpu_addr, dc->mem_idx);
|
|
|
|
gen_helper_ldxfsr(cpu_env, t64);
|
|
|
|
tcg_temp_free_i64(t64);
|
2012-10-16 13:32:24 +04:00
|
|
|
break;
|
2010-06-02 00:12:37 +04:00
|
|
|
}
|
2012-10-16 13:32:24 +04:00
|
|
|
#endif
|
2012-10-16 13:32:31 +04:00
|
|
|
cpu_dst_32 = get_temp_i32(dc);
|
|
|
|
t0 = get_temp_tl(dc);
|
|
|
|
tcg_gen_qemu_ld32u(t0, cpu_addr, dc->mem_idx);
|
|
|
|
tcg_gen_trunc_tl_i32(cpu_dst_32, t0);
|
|
|
|
gen_helper_ldfsr(cpu_env, cpu_dst_32);
|
2007-09-20 18:54:22 +04:00
|
|
|
break;
|
2009-05-03 00:19:46 +04:00
|
|
|
case 0x22: /* ldqf, load quad fpreg */
|
2008-05-27 23:39:12 +04:00
|
|
|
{
|
2008-11-17 17:43:54 +03:00
|
|
|
TCGv_i32 r_const;
|
2008-05-27 23:39:12 +04:00
|
|
|
|
|
|
|
CHECK_FPU_FEATURE(dc, FLOAT128);
|
|
|
|
r_const = tcg_const_i32(dc->mem_idx);
|
2010-06-02 23:38:45 +04:00
|
|
|
gen_address_mask(dc, cpu_addr);
|
2011-07-05 00:34:28 +04:00
|
|
|
gen_helper_ldqf(cpu_env, cpu_addr, r_const);
|
2008-11-17 17:43:54 +03:00
|
|
|
tcg_temp_free_i32(r_const);
|
2008-05-27 23:39:12 +04:00
|
|
|
gen_op_store_QT0_fpr(QFPREG(rd));
|
2011-07-23 06:20:07 +04:00
|
|
|
gen_update_fprs_dirty(QFPREG(rd));
|
2008-05-27 23:39:12 +04:00
|
|
|
}
|
2007-11-25 21:40:20 +03:00
|
|
|
break;
|
2009-05-03 00:19:46 +04:00
|
|
|
case 0x23: /* lddf, load double fpreg */
|
2011-10-15 21:20:20 +04:00
|
|
|
gen_address_mask(dc, cpu_addr);
|
2012-10-16 13:32:26 +04:00
|
|
|
cpu_dst_64 = gen_dest_fpr_D(dc, rd);
|
2011-10-15 21:20:20 +04:00
|
|
|
tcg_gen_qemu_ld64(cpu_dst_64, cpu_addr, dc->mem_idx);
|
|
|
|
gen_store_fpr_D(dc, rd, cpu_dst_64);
|
2007-09-20 18:54:22 +04:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
goto illegal_insn;
|
|
|
|
}
|
2009-05-03 22:51:22 +04:00
|
|
|
} else if (xop < 8 || (xop >= 0x14 && xop < 0x18) ||
|
2007-09-20 18:54:22 +04:00
|
|
|
xop == 0xe || xop == 0x1e) {
|
2012-10-16 13:32:17 +04:00
|
|
|
TCGv cpu_val = gen_load_gpr(dc, rd);
|
|
|
|
|
2007-09-20 18:54:22 +04:00
|
|
|
switch (xop) {
|
2009-05-03 00:19:46 +04:00
|
|
|
case 0x4: /* st, store word */
|
2008-07-17 16:53:05 +04:00
|
|
|
gen_address_mask(dc, cpu_addr);
|
2008-03-29 12:09:25 +03:00
|
|
|
tcg_gen_qemu_st32(cpu_val, cpu_addr, dc->mem_idx);
|
2007-09-20 18:54:22 +04:00
|
|
|
break;
|
2009-05-03 00:19:46 +04:00
|
|
|
case 0x5: /* stb, store byte */
|
2008-07-17 16:53:05 +04:00
|
|
|
gen_address_mask(dc, cpu_addr);
|
2008-03-29 12:09:25 +03:00
|
|
|
tcg_gen_qemu_st8(cpu_val, cpu_addr, dc->mem_idx);
|
2007-09-20 18:54:22 +04:00
|
|
|
break;
|
2009-05-03 00:19:46 +04:00
|
|
|
case 0x6: /* sth, store halfword */
|
2008-07-17 16:53:05 +04:00
|
|
|
gen_address_mask(dc, cpu_addr);
|
2008-03-29 12:09:25 +03:00
|
|
|
tcg_gen_qemu_st16(cpu_val, cpu_addr, dc->mem_idx);
|
2007-09-20 18:54:22 +04:00
|
|
|
break;
|
2009-05-03 00:19:46 +04:00
|
|
|
case 0x7: /* std, store double word */
|
2007-09-20 18:54:22 +04:00
|
|
|
if (rd & 1)
|
2007-04-01 19:15:36 +04:00
|
|
|
goto illegal_insn;
|
2008-02-24 17:10:06 +03:00
|
|
|
else {
|
2008-11-17 17:43:54 +03:00
|
|
|
TCGv_i32 r_const;
|
2012-10-16 13:32:28 +04:00
|
|
|
TCGv_i64 t64;
|
2012-10-16 13:32:17 +04:00
|
|
|
TCGv lo;
|
2008-02-24 17:10:06 +03:00
|
|
|
|
2012-10-06 03:54:53 +04:00
|
|
|
save_state(dc);
|
2008-07-17 16:53:05 +04:00
|
|
|
gen_address_mask(dc, cpu_addr);
|
2008-05-27 23:39:12 +04:00
|
|
|
r_const = tcg_const_i32(7);
|
2011-07-05 00:34:28 +04:00
|
|
|
/* XXX remove alignment check */
|
|
|
|
gen_helper_check_align(cpu_env, cpu_addr, r_const);
|
2008-11-17 17:43:54 +03:00
|
|
|
tcg_temp_free_i32(r_const);
|
2012-10-16 13:32:17 +04:00
|
|
|
lo = gen_load_gpr(dc, rd + 1);
|
2012-10-16 13:32:28 +04:00
|
|
|
|
|
|
|
t64 = tcg_temp_new_i64();
|
|
|
|
tcg_gen_concat_tl_i64(t64, lo, cpu_val);
|
|
|
|
tcg_gen_qemu_st64(t64, cpu_addr, dc->mem_idx);
|
|
|
|
tcg_temp_free_i64(t64);
|
2008-05-04 15:58:45 +04:00
|
|
|
}
|
2007-09-20 18:54:22 +04:00
|
|
|
break;
|
2005-07-02 18:31:34 +04:00
|
|
|
#if !defined(CONFIG_USER_ONLY) || defined(TARGET_SPARC64)
|
2009-05-03 00:19:46 +04:00
|
|
|
case 0x14: /* sta, V9 stwa, store word alternate */
|
2005-07-02 18:31:34 +04:00
|
|
|
#ifndef TARGET_SPARC64
|
2007-09-20 18:54:22 +04:00
|
|
|
if (IS_IMM)
|
|
|
|
goto illegal_insn;
|
|
|
|
if (!supervisor(dc))
|
|
|
|
goto priv_insn;
|
2007-07-11 20:43:30 +04:00
|
|
|
#endif
|
2012-10-06 03:54:53 +04:00
|
|
|
save_state(dc);
|
2008-03-29 12:09:25 +03:00
|
|
|
gen_st_asi(cpu_val, cpu_addr, insn, 4);
|
2010-05-22 14:52:35 +04:00
|
|
|
dc->npc = DYNAMIC_PC;
|
2005-04-10 18:40:58 +04:00
|
|
|
break;
|
2009-05-03 00:19:46 +04:00
|
|
|
case 0x15: /* stba, store byte alternate */
|
2005-07-02 18:31:34 +04:00
|
|
|
#ifndef TARGET_SPARC64
|
2007-09-20 18:54:22 +04:00
|
|
|
if (IS_IMM)
|
|
|
|
goto illegal_insn;
|
|
|
|
if (!supervisor(dc))
|
|
|
|
goto priv_insn;
|
2005-07-02 18:31:34 +04:00
|
|
|
#endif
|
2012-10-06 03:54:53 +04:00
|
|
|
save_state(dc);
|
2008-03-29 12:09:25 +03:00
|
|
|
gen_st_asi(cpu_val, cpu_addr, insn, 1);
|
2010-05-22 14:52:35 +04:00
|
|
|
dc->npc = DYNAMIC_PC;
|
2005-04-10 18:40:58 +04:00
|
|
|
break;
|
2009-05-03 00:19:46 +04:00
|
|
|
case 0x16: /* stha, store halfword alternate */
|
2005-07-02 18:31:34 +04:00
|
|
|
#ifndef TARGET_SPARC64
|
2007-09-20 18:54:22 +04:00
|
|
|
if (IS_IMM)
|
|
|
|
goto illegal_insn;
|
|
|
|
if (!supervisor(dc))
|
|
|
|
goto priv_insn;
|
2007-07-11 20:43:30 +04:00
|
|
|
#endif
|
2012-10-06 03:54:53 +04:00
|
|
|
save_state(dc);
|
2008-03-29 12:09:25 +03:00
|
|
|
gen_st_asi(cpu_val, cpu_addr, insn, 2);
|
2010-05-22 14:52:35 +04:00
|
|
|
dc->npc = DYNAMIC_PC;
|
2005-04-10 18:40:58 +04:00
|
|
|
break;
|
2009-05-03 00:19:46 +04:00
|
|
|
case 0x17: /* stda, store double word alternate */
|
2005-07-02 18:31:34 +04:00
|
|
|
#ifndef TARGET_SPARC64
|
2007-09-20 18:54:22 +04:00
|
|
|
if (IS_IMM)
|
|
|
|
goto illegal_insn;
|
|
|
|
if (!supervisor(dc))
|
|
|
|
goto priv_insn;
|
2005-07-02 18:31:34 +04:00
|
|
|
#endif
|
2007-09-20 18:54:22 +04:00
|
|
|
if (rd & 1)
|
2007-04-01 19:15:36 +04:00
|
|
|
goto illegal_insn;
|
2008-02-24 17:10:06 +03:00
|
|
|
else {
|
2012-10-06 03:54:53 +04:00
|
|
|
save_state(dc);
|
2012-10-16 13:32:15 +04:00
|
|
|
gen_stda_asi(dc, cpu_val, cpu_addr, insn, rd);
|
2008-02-24 17:10:06 +03:00
|
|
|
}
|
2005-04-10 18:40:58 +04:00
|
|
|
break;
|
2004-12-20 02:18:01 +03:00
|
|
|
#endif
|
2005-07-02 18:31:34 +04:00
|
|
|
#ifdef TARGET_SPARC64
|
2007-09-20 18:54:22 +04:00
|
|
|
case 0x0e: /* V9 stx */
|
2008-07-17 16:53:05 +04:00
|
|
|
gen_address_mask(dc, cpu_addr);
|
2008-03-29 12:09:25 +03:00
|
|
|
tcg_gen_qemu_st64(cpu_val, cpu_addr, dc->mem_idx);
|
2007-09-20 18:54:22 +04:00
|
|
|
break;
|
|
|
|
case 0x1e: /* V9 stxa */
|
2012-10-06 03:54:53 +04:00
|
|
|
save_state(dc);
|
2008-03-29 12:09:25 +03:00
|
|
|
gen_st_asi(cpu_val, cpu_addr, insn, 8);
|
2010-05-22 14:52:35 +04:00
|
|
|
dc->npc = DYNAMIC_PC;
|
2007-09-20 18:54:22 +04:00
|
|
|
break;
|
2005-07-02 18:31:34 +04:00
|
|
|
#endif
|
2007-09-20 18:54:22 +04:00
|
|
|
default:
|
|
|
|
goto illegal_insn;
|
|
|
|
}
|
|
|
|
} else if (xop > 0x23 && xop < 0x28) {
|
2012-10-06 03:54:52 +04:00
|
|
|
if (gen_trap_ifnofpu(dc)) {
|
2006-06-26 23:53:29 +04:00
|
|
|
goto jmp_insn;
|
2012-10-06 03:54:52 +04:00
|
|
|
}
|
2012-10-06 03:54:53 +04:00
|
|
|
save_state(dc);
|
2007-09-20 18:54:22 +04:00
|
|
|
switch (xop) {
|
2009-05-03 00:19:46 +04:00
|
|
|
case 0x24: /* stf, store fpreg */
|
2012-10-16 13:32:31 +04:00
|
|
|
{
|
|
|
|
TCGv t = get_temp_tl(dc);
|
|
|
|
gen_address_mask(dc, cpu_addr);
|
|
|
|
cpu_src1_32 = gen_load_fpr_F(dc, rd);
|
|
|
|
tcg_gen_ext_i32_tl(t, cpu_src1_32);
|
|
|
|
tcg_gen_qemu_st32(t, cpu_addr, dc->mem_idx);
|
|
|
|
}
|
2007-09-20 18:54:22 +04:00
|
|
|
break;
|
|
|
|
case 0x25: /* stfsr, V9 stxfsr */
|
2012-10-16 13:32:24 +04:00
|
|
|
{
|
|
|
|
TCGv t = get_temp_tl(dc);
|
|
|
|
|
|
|
|
tcg_gen_ld_tl(t, cpu_env, offsetof(CPUSPARCState, fsr));
|
2008-09-09 23:02:49 +04:00
|
|
|
#ifdef TARGET_SPARC64
|
2012-10-16 13:32:24 +04:00
|
|
|
gen_address_mask(dc, cpu_addr);
|
|
|
|
if (rd == 1) {
|
|
|
|
tcg_gen_qemu_st64(t, cpu_addr, dc->mem_idx);
|
|
|
|
break;
|
|
|
|
}
|
2008-09-09 23:02:49 +04:00
|
|
|
#endif
|
2012-10-16 13:32:24 +04:00
|
|
|
tcg_gen_qemu_st32(t, cpu_addr, dc->mem_idx);
|
|
|
|
}
|
2007-09-20 18:54:22 +04:00
|
|
|
break;
|
2007-11-25 21:40:20 +03:00
|
|
|
case 0x26:
|
|
|
|
#ifdef TARGET_SPARC64
|
|
|
|
/* V9 stqf, store quad fpreg */
|
2008-05-27 23:39:12 +04:00
|
|
|
{
|
2008-11-17 17:43:54 +03:00
|
|
|
TCGv_i32 r_const;
|
2008-05-27 23:39:12 +04:00
|
|
|
|
|
|
|
CHECK_FPU_FEATURE(dc, FLOAT128);
|
|
|
|
gen_op_load_fpr_QT0(QFPREG(rd));
|
|
|
|
r_const = tcg_const_i32(dc->mem_idx);
|
2010-06-02 23:38:45 +04:00
|
|
|
gen_address_mask(dc, cpu_addr);
|
2011-07-05 00:34:28 +04:00
|
|
|
gen_helper_stqf(cpu_env, cpu_addr, r_const);
|
2008-11-17 17:43:54 +03:00
|
|
|
tcg_temp_free_i32(r_const);
|
2008-05-27 23:39:12 +04:00
|
|
|
}
|
2007-11-25 21:40:20 +03:00
|
|
|
break;
|
|
|
|
#else /* !TARGET_SPARC64 */
|
|
|
|
/* stdfq, store floating point queue */
|
|
|
|
#if defined(CONFIG_USER_ONLY)
|
|
|
|
goto illegal_insn;
|
|
|
|
#else
|
2007-09-20 18:54:22 +04:00
|
|
|
if (!supervisor(dc))
|
|
|
|
goto priv_insn;
|
2012-10-06 03:54:52 +04:00
|
|
|
if (gen_trap_ifnofpu(dc)) {
|
2007-09-20 18:54:22 +04:00
|
|
|
goto jmp_insn;
|
2012-10-06 03:54:52 +04:00
|
|
|
}
|
2007-09-20 18:54:22 +04:00
|
|
|
goto nfq_insn;
|
2007-11-25 21:40:20 +03:00
|
|
|
#endif
|
2007-09-20 18:54:22 +04:00
|
|
|
#endif
|
2009-05-03 00:19:46 +04:00
|
|
|
case 0x27: /* stdf, store double fpreg */
|
2011-10-15 21:20:20 +04:00
|
|
|
gen_address_mask(dc, cpu_addr);
|
|
|
|
cpu_src1_64 = gen_load_fpr_D(dc, rd);
|
|
|
|
tcg_gen_qemu_st64(cpu_src1_64, cpu_addr, dc->mem_idx);
|
2007-09-20 18:54:22 +04:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
goto illegal_insn;
|
|
|
|
}
|
|
|
|
} else if (xop > 0x33 && xop < 0x3f) {
|
2012-10-06 03:54:53 +04:00
|
|
|
save_state(dc);
|
2007-09-20 18:54:22 +04:00
|
|
|
switch (xop) {
|
2007-04-05 22:09:15 +04:00
|
|
|
#ifdef TARGET_SPARC64
|
2007-09-20 18:54:22 +04:00
|
|
|
case 0x34: /* V9 stfa */
|
2012-10-06 03:54:52 +04:00
|
|
|
if (gen_trap_ifnofpu(dc)) {
|
2011-07-14 13:41:39 +04:00
|
|
|
goto jmp_insn;
|
|
|
|
}
|
2008-03-29 12:09:25 +03:00
|
|
|
gen_stf_asi(cpu_addr, insn, 4, rd);
|
2007-09-20 18:54:22 +04:00
|
|
|
break;
|
2007-11-25 21:40:20 +03:00
|
|
|
case 0x36: /* V9 stqfa */
|
2008-05-27 23:39:12 +04:00
|
|
|
{
|
2008-11-17 17:43:54 +03:00
|
|
|
TCGv_i32 r_const;
|
2008-05-27 23:39:12 +04:00
|
|
|
|
|
|
|
CHECK_FPU_FEATURE(dc, FLOAT128);
|
2012-10-06 03:54:52 +04:00
|
|
|
if (gen_trap_ifnofpu(dc)) {
|
2011-07-14 13:41:39 +04:00
|
|
|
goto jmp_insn;
|
|
|
|
}
|
2008-05-27 23:39:12 +04:00
|
|
|
r_const = tcg_const_i32(7);
|
2011-07-05 00:34:28 +04:00
|
|
|
gen_helper_check_align(cpu_env, cpu_addr, r_const);
|
2008-11-17 17:43:54 +03:00
|
|
|
tcg_temp_free_i32(r_const);
|
2008-05-27 23:39:12 +04:00
|
|
|
gen_stf_asi(cpu_addr, insn, 16, QFPREG(rd));
|
|
|
|
}
|
2007-11-25 21:40:20 +03:00
|
|
|
break;
|
2007-09-20 18:54:22 +04:00
|
|
|
case 0x37: /* V9 stdfa */
|
2012-10-06 03:54:52 +04:00
|
|
|
if (gen_trap_ifnofpu(dc)) {
|
2011-07-14 13:41:39 +04:00
|
|
|
goto jmp_insn;
|
|
|
|
}
|
2008-03-29 12:09:25 +03:00
|
|
|
gen_stf_asi(cpu_addr, insn, 8, DFPREG(rd));
|
2007-09-20 18:54:22 +04:00
|
|
|
break;
|
|
|
|
case 0x3e: /* V9 casxa */
|
2012-10-16 13:32:18 +04:00
|
|
|
rs2 = GET_FIELD(insn, 27, 31);
|
|
|
|
cpu_src2 = gen_load_gpr(dc, rs2);
|
2012-10-16 13:32:17 +04:00
|
|
|
gen_casx_asi(dc, cpu_addr, cpu_src2, insn, rd);
|
2007-09-20 18:54:22 +04:00
|
|
|
break;
|
2007-04-05 22:09:15 +04:00
|
|
|
#else
|
2007-09-20 18:54:22 +04: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 13:36:00 +04:00
|
|
|
#endif
|
|
|
|
#if !defined(CONFIG_USER_ONLY) || defined(TARGET_SPARC64)
|
|
|
|
case 0x3c: /* V9 or LEON3 casa */
|
|
|
|
#ifndef TARGET_SPARC64
|
|
|
|
CHECK_IU_FEATURE(dc, CASA);
|
|
|
|
if (IS_IMM) {
|
|
|
|
goto illegal_insn;
|
|
|
|
}
|
2015-12-04 18:01:02 +03:00
|
|
|
/* LEON3 allows CASA from user space with ASI 0xa */
|
|
|
|
if ((GET_FIELD(insn, 19, 26) != 0xa) && !supervisor(dc)) {
|
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 13:36:00 +04:00
|
|
|
goto priv_insn;
|
|
|
|
}
|
|
|
|
#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 18:54:22 +04:00
|
|
|
#endif
|
|
|
|
default:
|
|
|
|
goto illegal_insn;
|
|
|
|
}
|
2012-10-16 13:32:18 +04:00
|
|
|
} else {
|
2007-09-20 18:54:22 +04:00
|
|
|
goto illegal_insn;
|
2012-10-16 13:32:18 +04:00
|
|
|
}
|
2007-09-20 18:54:22 +04:00
|
|
|
}
|
|
|
|
break;
|
2004-01-04 18:01:44 +03:00
|
|
|
}
|
|
|
|
/* default case for non jump instructions */
|
2004-02-16 23:30:05 +03:00
|
|
|
if (dc->npc == DYNAMIC_PC) {
|
2007-09-20 18:54:22 +04:00
|
|
|
dc->pc = DYNAMIC_PC;
|
|
|
|
gen_op_next_insn();
|
2004-02-16 23:30:05 +03:00
|
|
|
} else if (dc->npc == JUMP_PC) {
|
|
|
|
/* we can do a static jump */
|
2008-03-29 12:09:25 +03:00
|
|
|
gen_branch2(dc, dc->jump_pc[0], dc->jump_pc[1], cpu_cond);
|
2004-02-16 23:30:05 +03:00
|
|
|
dc->is_br = 1;
|
|
|
|
} else {
|
2007-09-20 18:54:22 +04:00
|
|
|
dc->pc = dc->npc;
|
|
|
|
dc->npc = dc->npc + 4;
|
2004-01-04 18:01:44 +03:00
|
|
|
}
|
2004-12-20 02:18:01 +03:00
|
|
|
jmp_insn:
|
2010-04-17 20:25:08 +04:00
|
|
|
goto egress;
|
2004-01-04 18:01:44 +03:00
|
|
|
illegal_insn:
|
2008-05-27 23:39:12 +04:00
|
|
|
{
|
2008-11-17 17:43:54 +03:00
|
|
|
TCGv_i32 r_const;
|
2008-05-27 23:39:12 +04:00
|
|
|
|
2012-10-06 03:54:53 +04:00
|
|
|
save_state(dc);
|
2008-05-27 23:39:12 +04:00
|
|
|
r_const = tcg_const_i32(TT_ILL_INSN);
|
2011-07-03 12:19:42 +04:00
|
|
|
gen_helper_raise_exception(cpu_env, r_const);
|
2008-11-17 17:43:54 +03:00
|
|
|
tcg_temp_free_i32(r_const);
|
2008-05-27 23:39:12 +04:00
|
|
|
dc->is_br = 1;
|
|
|
|
}
|
2010-04-17 20:25:08 +04:00
|
|
|
goto egress;
|
2008-05-10 00:13:43 +04:00
|
|
|
unimp_flush:
|
2008-05-27 23:39:12 +04:00
|
|
|
{
|
2008-11-17 17:43:54 +03:00
|
|
|
TCGv_i32 r_const;
|
2008-05-27 23:39:12 +04:00
|
|
|
|
2012-10-06 03:54:53 +04:00
|
|
|
save_state(dc);
|
2008-05-27 23:39:12 +04:00
|
|
|
r_const = tcg_const_i32(TT_UNIMP_FLUSH);
|
2011-07-03 12:19:42 +04:00
|
|
|
gen_helper_raise_exception(cpu_env, r_const);
|
2008-11-17 17:43:54 +03:00
|
|
|
tcg_temp_free_i32(r_const);
|
2008-05-27 23:39:12 +04:00
|
|
|
dc->is_br = 1;
|
|
|
|
}
|
2010-04-17 20:25:08 +04:00
|
|
|
goto egress;
|
2004-12-20 02:18:01 +03:00
|
|
|
#if !defined(CONFIG_USER_ONLY)
|
2004-10-01 01:55:55 +04:00
|
|
|
priv_insn:
|
2008-05-27 23:39:12 +04:00
|
|
|
{
|
2008-11-17 17:43:54 +03:00
|
|
|
TCGv_i32 r_const;
|
2008-05-27 23:39:12 +04:00
|
|
|
|
2012-10-06 03:54:53 +04:00
|
|
|
save_state(dc);
|
2008-05-27 23:39:12 +04:00
|
|
|
r_const = tcg_const_i32(TT_PRIV_INSN);
|
2011-07-03 12:19:42 +04:00
|
|
|
gen_helper_raise_exception(cpu_env, r_const);
|
2008-11-17 17:43:54 +03:00
|
|
|
tcg_temp_free_i32(r_const);
|
2008-05-27 23:39:12 +04:00
|
|
|
dc->is_br = 1;
|
|
|
|
}
|
2010-04-17 20:25:08 +04:00
|
|
|
goto egress;
|
2008-05-10 00:13:43 +04:00
|
|
|
#endif
|
2004-12-20 02:18:01 +03:00
|
|
|
nfpu_insn:
|
2012-10-06 03:54:53 +04:00
|
|
|
save_state(dc);
|
2004-12-20 02:18:01 +03:00
|
|
|
gen_op_fpexception_im(FSR_FTT_UNIMPFPOP);
|
|
|
|
dc->is_br = 1;
|
2010-04-17 20:25:08 +04:00
|
|
|
goto egress;
|
2008-05-10 00:13:43 +04:00
|
|
|
#if !defined(CONFIG_USER_ONLY) && !defined(TARGET_SPARC64)
|
2007-04-05 22:12:08 +04:00
|
|
|
nfq_insn:
|
2012-10-06 03:54:53 +04:00
|
|
|
save_state(dc);
|
2007-04-05 22:12:08 +04:00
|
|
|
gen_op_fpexception_im(FSR_FTT_SEQ_ERROR);
|
|
|
|
dc->is_br = 1;
|
2010-04-17 20:25:08 +04:00
|
|
|
goto egress;
|
2007-04-05 22:12:08 +04:00
|
|
|
#endif
|
2007-04-01 19:08:21 +04:00
|
|
|
#ifndef TARGET_SPARC64
|
|
|
|
ncp_insn:
|
2008-05-27 23:39:12 +04:00
|
|
|
{
|
|
|
|
TCGv r_const;
|
|
|
|
|
2012-10-06 03:54:53 +04:00
|
|
|
save_state(dc);
|
2008-05-27 23:39:12 +04:00
|
|
|
r_const = tcg_const_i32(TT_NCP_INSN);
|
2011-07-03 12:19:42 +04:00
|
|
|
gen_helper_raise_exception(cpu_env, r_const);
|
2008-05-27 23:39:12 +04:00
|
|
|
tcg_temp_free(r_const);
|
|
|
|
dc->is_br = 1;
|
|
|
|
}
|
2010-04-17 20:25:08 +04:00
|
|
|
goto egress;
|
2007-04-01 19:08:21 +04:00
|
|
|
#endif
|
2010-04-17 20:25:08 +04:00
|
|
|
egress:
|
2011-10-17 21:42:49 +04:00
|
|
|
if (dc->n_t32 != 0) {
|
|
|
|
int i;
|
|
|
|
for (i = dc->n_t32 - 1; i >= 0; --i) {
|
|
|
|
tcg_temp_free_i32(dc->t32[i]);
|
|
|
|
}
|
|
|
|
dc->n_t32 = 0;
|
|
|
|
}
|
2012-10-16 13:32:12 +04:00
|
|
|
if (dc->n_ttl != 0) {
|
|
|
|
int i;
|
|
|
|
for (i = dc->n_ttl - 1; i >= 0; --i) {
|
|
|
|
tcg_temp_free(dc->ttl[i]);
|
|
|
|
}
|
|
|
|
dc->n_ttl = 0;
|
|
|
|
}
|
2003-10-01 00:36:07 +04:00
|
|
|
}
|
|
|
|
|
2015-09-02 06:01:40 +03:00
|
|
|
void gen_intermediate_code(CPUSPARCState * env, TranslationBlock * tb)
|
2003-10-01 00:36:07 +04:00
|
|
|
{
|
2015-09-02 06:01:40 +03:00
|
|
|
SPARCCPU *cpu = sparc_env_get_cpu(env);
|
2013-06-21 22:20:45 +04:00
|
|
|
CPUState *cs = CPU(cpu);
|
2004-02-16 23:30:05 +03:00
|
|
|
target_ulong pc_start, last_pc;
|
2004-01-04 18:01:44 +03:00
|
|
|
DisasContext dc1, *dc = &dc1;
|
2008-06-29 05:03:05 +04:00
|
|
|
int num_insns;
|
|
|
|
int max_insns;
|
2011-08-01 16:19:05 +04:00
|
|
|
unsigned int insn;
|
2004-01-04 18:01:44 +03:00
|
|
|
|
|
|
|
memset(dc, 0, sizeof(DisasContext));
|
|
|
|
dc->tb = tb;
|
2004-02-16 23:30:05 +03:00
|
|
|
pc_start = tb->pc;
|
2004-01-04 18:01:44 +03:00
|
|
|
dc->pc = pc_start;
|
2004-12-20 02:18:01 +03:00
|
|
|
last_pc = dc->pc;
|
2004-02-16 23:30:05 +03:00
|
|
|
dc->npc = (target_ulong) tb->cs_base;
|
2009-05-10 11:19:11 +04:00
|
|
|
dc->cc_op = CC_OP_DYNAMIC;
|
2015-08-17 10:34:10 +03:00
|
|
|
dc->mem_idx = cpu_mmu_index(env, false);
|
2008-08-21 21:33:42 +04:00
|
|
|
dc->def = env->def;
|
2011-07-14 21:30:43 +04:00
|
|
|
dc->fpu_enabled = tb_fpu_enabled(tb->flags);
|
|
|
|
dc->address_mask_32bit = tb_am_enabled(tb->flags);
|
2013-06-21 22:20:45 +04:00
|
|
|
dc->singlestep = (cs->singlestep_enabled || singlestep);
|
2004-01-04 18:01:44 +03:00
|
|
|
|
2008-06-29 05:03:05 +04:00
|
|
|
num_insns = 0;
|
|
|
|
max_insns = tb->cflags & CF_COUNT_MASK;
|
2015-09-01 00:34:41 +03:00
|
|
|
if (max_insns == 0) {
|
2008-06-29 05:03:05 +04:00
|
|
|
max_insns = CF_COUNT_MASK;
|
2015-09-01 00:34:41 +03:00
|
|
|
}
|
|
|
|
if (max_insns > TCG_MAX_INSNS) {
|
|
|
|
max_insns = TCG_MAX_INSNS;
|
|
|
|
}
|
|
|
|
|
2014-11-26 13:40:05 +03:00
|
|
|
gen_tb_start(tb);
|
2004-01-04 18:01:44 +03:00
|
|
|
do {
|
2015-08-31 23:30:52 +03: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:25:46 +03:00
|
|
|
num_insns++;
|
2015-10-14 01:07:49 +03:00
|
|
|
last_pc = dc->pc;
|
2015-08-29 22:59:29 +03:00
|
|
|
|
2015-09-18 01:58:10 +03:00
|
|
|
if (unlikely(cpu_breakpoint_test(cs, dc->pc, BP_ANY))) {
|
|
|
|
if (dc->pc != pc_start) {
|
|
|
|
save_state(dc);
|
|
|
|
}
|
|
|
|
gen_helper_debug(cpu_env);
|
|
|
|
tcg_gen_exit_tb(0);
|
|
|
|
dc->is_br = 1;
|
|
|
|
goto exit_gen_loop;
|
|
|
|
}
|
|
|
|
|
2015-09-18 00:25:46 +03:00
|
|
|
if (num_insns == max_insns && (tb->cflags & CF_LAST_IO)) {
|
2008-06-29 05:03:05 +04:00
|
|
|
gen_io_start();
|
2015-08-29 22:59:29 +03:00
|
|
|
}
|
|
|
|
|
2011-08-01 16:19:05 +04:00
|
|
|
insn = cpu_ldl_code(env, dc->pc);
|
2012-10-06 03:55:08 +04:00
|
|
|
|
2011-08-01 16:19:05 +04:00
|
|
|
disas_sparc_insn(dc, insn);
|
2007-09-20 18:54:22 +04:00
|
|
|
|
|
|
|
if (dc->is_br)
|
|
|
|
break;
|
|
|
|
/* if the next PC is different, we abort now */
|
|
|
|
if (dc->pc != (last_pc + 4))
|
|
|
|
break;
|
2005-04-10 18:40:58 +04: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 */
|
|
|
|
if ((dc->pc & (TARGET_PAGE_SIZE - 1)) == 0)
|
|
|
|
break;
|
2004-12-20 02:18:01 +03:00
|
|
|
/* if single step mode, we generate only one instruction and
|
|
|
|
generate an exception */
|
2010-04-26 21:17:24 +04:00
|
|
|
if (dc->singlestep) {
|
2004-12-20 02:18:01 +03:00
|
|
|
break;
|
|
|
|
}
|
2014-03-31 02:36:56 +04:00
|
|
|
} while (!tcg_op_buf_full() &&
|
2008-06-29 05:03:05 +04:00
|
|
|
(dc->pc - pc_start) < (TARGET_PAGE_SIZE - 32) &&
|
|
|
|
num_insns < max_insns);
|
2004-12-20 02:18:01 +03:00
|
|
|
|
|
|
|
exit_gen_loop:
|
2012-10-06 03:55:08 +04:00
|
|
|
if (tb->cflags & CF_LAST_IO) {
|
2008-06-29 05:03:05 +04:00
|
|
|
gen_io_end();
|
2012-10-06 03:55:08 +04:00
|
|
|
}
|
2004-02-16 23:30:05 +03:00
|
|
|
if (!dc->is_br) {
|
2007-09-17 01:08:06 +04:00
|
|
|
if (dc->pc != DYNAMIC_PC &&
|
2004-02-16 23:30:05 +03:00
|
|
|
(dc->npc != DYNAMIC_PC && dc->npc != JUMP_PC)) {
|
|
|
|
/* static PC and NPC: we can use direct chaining */
|
2008-03-26 23:45:06 +03:00
|
|
|
gen_goto_tb(dc, 0, dc->pc, dc->npc);
|
2004-02-16 23:30:05 +03:00
|
|
|
} else {
|
2012-10-06 03:55:08 +04:00
|
|
|
if (dc->pc != DYNAMIC_PC) {
|
2008-03-26 23:45:06 +03:00
|
|
|
tcg_gen_movi_tl(cpu_pc, dc->pc);
|
2012-10-06 03:55:08 +04:00
|
|
|
}
|
2012-10-06 03:54:55 +04:00
|
|
|
save_npc(dc);
|
2008-02-01 13:50:11 +03:00
|
|
|
tcg_gen_exit_tb(0);
|
2004-02-16 23:30:05 +03:00
|
|
|
}
|
|
|
|
}
|
2013-02-22 22:10:05 +04:00
|
|
|
gen_tb_end(tb, num_insns);
|
2014-03-31 01:50:30 +04:00
|
|
|
|
2015-09-02 06:01:40 +03:00
|
|
|
tb->size = last_pc + 4 - pc_start;
|
|
|
|
tb->icount = num_insns;
|
|
|
|
|
2003-10-01 00:36:07 +04:00
|
|
|
#ifdef DEBUG_DISAS
|
2009-01-16 01:36:53 +03:00
|
|
|
if (qemu_loglevel_mask(CPU_LOG_TB_IN_ASM)) {
|
2009-01-16 01:34:14 +03:00
|
|
|
qemu_log("--------------\n");
|
|
|
|
qemu_log("IN: %s\n", lookup_symbol(pc_start));
|
2015-05-25 00:20:41 +03:00
|
|
|
log_target_disas(cs, pc_start, last_pc + 4 - pc_start, 0);
|
2009-01-16 01:34:14 +03:00
|
|
|
qemu_log("\n");
|
2004-01-04 18:01:44 +03:00
|
|
|
}
|
2003-10-01 00:36:07 +04:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2008-03-29 18:46:56 +03:00
|
|
|
void gen_intermediate_code_init(CPUSPARCState *env)
|
2004-12-20 02:18:01 +03:00
|
|
|
{
|
2008-03-14 20:35:02 +03:00
|
|
|
unsigned int i;
|
2008-03-29 18:46:56 +03:00
|
|
|
static int inited;
|
2008-03-14 20:35:02 +03:00
|
|
|
static const char * const gregnames[8] = {
|
|
|
|
NULL, // g0 not used
|
|
|
|
"g1",
|
|
|
|
"g2",
|
|
|
|
"g3",
|
|
|
|
"g4",
|
|
|
|
"g5",
|
|
|
|
"g6",
|
|
|
|
"g7",
|
|
|
|
};
|
2011-10-17 21:42:49 +04:00
|
|
|
static const char * const fregnames[32] = {
|
|
|
|
"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 23:54:51 +04:00
|
|
|
};
|
2007-11-10 18:15:54 +03:00
|
|
|
|
2008-02-24 17:10:06 +03:00
|
|
|
/* init various static tables */
|
|
|
|
if (!inited) {
|
|
|
|
inited = 1;
|
|
|
|
|
2008-11-17 17:43:54 +03:00
|
|
|
cpu_env = tcg_global_reg_new_ptr(TCG_AREG0, "env");
|
|
|
|
cpu_regwptr = tcg_global_mem_new_ptr(TCG_AREG0,
|
2012-03-14 04:38:22 +04:00
|
|
|
offsetof(CPUSPARCState, regwptr),
|
2008-11-17 17:43:54 +03:00
|
|
|
"regwptr");
|
2008-02-24 17:10:06 +03:00
|
|
|
#ifdef TARGET_SPARC64
|
2012-03-14 04:38:22 +04:00
|
|
|
cpu_xcc = tcg_global_mem_new_i32(TCG_AREG0, offsetof(CPUSPARCState, xcc),
|
2008-11-17 17:43:54 +03:00
|
|
|
"xcc");
|
2012-03-14 04:38:22 +04:00
|
|
|
cpu_asi = tcg_global_mem_new_i32(TCG_AREG0, offsetof(CPUSPARCState, asi),
|
2008-11-17 17:43:54 +03:00
|
|
|
"asi");
|
2012-03-14 04:38:22 +04:00
|
|
|
cpu_fprs = tcg_global_mem_new_i32(TCG_AREG0, offsetof(CPUSPARCState, fprs),
|
2008-11-17 17:43:54 +03:00
|
|
|
"fprs");
|
2012-03-14 04:38:22 +04:00
|
|
|
cpu_gsr = tcg_global_mem_new(TCG_AREG0, offsetof(CPUSPARCState, gsr),
|
2008-09-06 21:51:43 +04:00
|
|
|
"gsr");
|
2008-11-17 17:43:54 +03:00
|
|
|
cpu_tick_cmpr = tcg_global_mem_new(TCG_AREG0,
|
2012-03-14 04:38:22 +04:00
|
|
|
offsetof(CPUSPARCState, tick_cmpr),
|
2008-09-06 21:51:43 +04:00
|
|
|
"tick_cmpr");
|
2008-11-17 17:43:54 +03:00
|
|
|
cpu_stick_cmpr = tcg_global_mem_new(TCG_AREG0,
|
2012-03-14 04:38:22 +04:00
|
|
|
offsetof(CPUSPARCState, stick_cmpr),
|
2008-09-06 21:51:43 +04:00
|
|
|
"stick_cmpr");
|
2008-11-17 17:43:54 +03:00
|
|
|
cpu_hstick_cmpr = tcg_global_mem_new(TCG_AREG0,
|
2012-03-14 04:38:22 +04:00
|
|
|
offsetof(CPUSPARCState, hstick_cmpr),
|
2008-09-06 21:51:43 +04:00
|
|
|
"hstick_cmpr");
|
2012-03-14 04:38:22 +04:00
|
|
|
cpu_hintp = tcg_global_mem_new(TCG_AREG0, offsetof(CPUSPARCState, hintp),
|
2008-09-06 21:51:43 +04:00
|
|
|
"hintp");
|
2012-03-14 04:38:22 +04:00
|
|
|
cpu_htba = tcg_global_mem_new(TCG_AREG0, offsetof(CPUSPARCState, htba),
|
2008-11-17 17:43:54 +03:00
|
|
|
"htba");
|
2012-03-14 04:38:22 +04:00
|
|
|
cpu_hver = tcg_global_mem_new(TCG_AREG0, offsetof(CPUSPARCState, hver),
|
2008-11-17 17:43:54 +03:00
|
|
|
"hver");
|
|
|
|
cpu_ssr = tcg_global_mem_new(TCG_AREG0,
|
2012-03-14 04:38:22 +04:00
|
|
|
offsetof(CPUSPARCState, ssr), "ssr");
|
2008-11-17 17:43:54 +03:00
|
|
|
cpu_ver = tcg_global_mem_new(TCG_AREG0,
|
2012-03-14 04:38:22 +04:00
|
|
|
offsetof(CPUSPARCState, version), "ver");
|
2008-11-17 17:43:54 +03:00
|
|
|
cpu_softint = tcg_global_mem_new_i32(TCG_AREG0,
|
2012-03-14 04:38:22 +04:00
|
|
|
offsetof(CPUSPARCState, softint),
|
2008-11-17 17:43:54 +03:00
|
|
|
"softint");
|
2008-09-06 21:51:43 +04:00
|
|
|
#else
|
2012-03-14 04:38:22 +04:00
|
|
|
cpu_wim = tcg_global_mem_new(TCG_AREG0, offsetof(CPUSPARCState, wim),
|
2008-09-06 21:51:43 +04:00
|
|
|
"wim");
|
2008-02-24 17:10:06 +03:00
|
|
|
#endif
|
2012-03-14 04:38:22 +04:00
|
|
|
cpu_cond = tcg_global_mem_new(TCG_AREG0, offsetof(CPUSPARCState, cond),
|
2008-05-12 20:13:33 +04:00
|
|
|
"cond");
|
2012-03-14 04:38:22 +04:00
|
|
|
cpu_cc_src = tcg_global_mem_new(TCG_AREG0, offsetof(CPUSPARCState, cc_src),
|
2008-03-13 23:45:31 +03:00
|
|
|
"cc_src");
|
2008-11-17 17:43:54 +03:00
|
|
|
cpu_cc_src2 = tcg_global_mem_new(TCG_AREG0,
|
2012-03-14 04:38:22 +04:00
|
|
|
offsetof(CPUSPARCState, cc_src2),
|
2008-03-16 22:22:18 +03:00
|
|
|
"cc_src2");
|
2012-03-14 04:38:22 +04:00
|
|
|
cpu_cc_dst = tcg_global_mem_new(TCG_AREG0, offsetof(CPUSPARCState, cc_dst),
|
2008-03-13 23:45:31 +03:00
|
|
|
"cc_dst");
|
2012-03-14 04:38:22 +04:00
|
|
|
cpu_cc_op = tcg_global_mem_new_i32(TCG_AREG0, offsetof(CPUSPARCState, cc_op),
|
2009-05-10 11:19:11 +04:00
|
|
|
"cc_op");
|
2012-03-14 04:38:22 +04:00
|
|
|
cpu_psr = tcg_global_mem_new_i32(TCG_AREG0, offsetof(CPUSPARCState, psr),
|
2008-11-17 17:43:54 +03:00
|
|
|
"psr");
|
2012-03-14 04:38:22 +04:00
|
|
|
cpu_fsr = tcg_global_mem_new(TCG_AREG0, offsetof(CPUSPARCState, fsr),
|
2008-03-15 21:12:11 +03:00
|
|
|
"fsr");
|
2012-03-14 04:38:22 +04:00
|
|
|
cpu_pc = tcg_global_mem_new(TCG_AREG0, offsetof(CPUSPARCState, pc),
|
2008-03-16 22:23:31 +03:00
|
|
|
"pc");
|
2012-03-14 04:38:22 +04:00
|
|
|
cpu_npc = tcg_global_mem_new(TCG_AREG0, offsetof(CPUSPARCState, npc),
|
2008-11-17 17:43:54 +03:00
|
|
|
"npc");
|
2012-03-14 04:38:22 +04:00
|
|
|
cpu_y = tcg_global_mem_new(TCG_AREG0, offsetof(CPUSPARCState, y), "y");
|
2008-09-06 21:51:43 +04:00
|
|
|
#ifndef CONFIG_USER_ONLY
|
2012-03-14 04:38:22 +04:00
|
|
|
cpu_tbr = tcg_global_mem_new(TCG_AREG0, offsetof(CPUSPARCState, tbr),
|
2008-09-06 21:51:43 +04:00
|
|
|
"tbr");
|
|
|
|
#endif
|
2011-10-17 21:42:49 +04:00
|
|
|
for (i = 1; i < 8; i++) {
|
2008-11-17 17:43:54 +03:00
|
|
|
cpu_gregs[i] = tcg_global_mem_new(TCG_AREG0,
|
2012-03-14 04:38:22 +04:00
|
|
|
offsetof(CPUSPARCState, gregs[i]),
|
2008-03-14 20:35:02 +03:00
|
|
|
gregnames[i]);
|
2011-10-17 21:42:49 +04:00
|
|
|
}
|
|
|
|
for (i = 0; i < TARGET_DPREGS; i++) {
|
|
|
|
cpu_fpr[i] = tcg_global_mem_new_i64(TCG_AREG0,
|
2012-03-14 04:38:22 +04:00
|
|
|
offsetof(CPUSPARCState, fpr[i]),
|
2011-10-15 23:12:02 +04:00
|
|
|
fregnames[i]);
|
2011-10-17 21:42:49 +04:00
|
|
|
}
|
2008-02-24 17:10:06 +03:00
|
|
|
}
|
2004-04-25 21:56:08 +04:00
|
|
|
}
|
2008-04-28 04:32:32 +04:00
|
|
|
|
2015-09-02 01:51:12 +03:00
|
|
|
void restore_state_to_opc(CPUSPARCState *env, TranslationBlock *tb,
|
|
|
|
target_ulong *data)
|
2008-04-28 04:32:32 +04:00
|
|
|
{
|
2015-09-02 01:51:12 +03:00
|
|
|
target_ulong pc = data[0];
|
|
|
|
target_ulong npc = data[1];
|
|
|
|
|
|
|
|
env->pc = pc;
|
2015-08-31 23:24:44 +03:00
|
|
|
if (npc == DYNAMIC_PC) {
|
2008-04-28 04:32:32 +04:00
|
|
|
/* dynamic NPC: already stored */
|
2015-08-31 23:24:44 +03:00
|
|
|
} else if (npc & JUMP_PC) {
|
2010-04-11 23:47:49 +04:00
|
|
|
/* jump PC: use 'cond' and the jump targets of the translation */
|
|
|
|
if (env->cond) {
|
2015-08-31 23:24:44 +03:00
|
|
|
env->npc = npc & ~3;
|
2010-04-11 23:47:49 +04:00
|
|
|
} else {
|
2015-08-31 23:24:44 +03:00
|
|
|
env->npc = pc + 4;
|
2010-04-11 23:47:49 +04:00
|
|
|
}
|
2008-04-28 04:32:32 +04:00
|
|
|
} else {
|
|
|
|
env->npc = npc;
|
|
|
|
}
|
|
|
|
}
|