2006-04-28 01:07:38 +04:00
|
|
|
/*
|
|
|
|
* SH4 translation
|
2007-09-17 01:08:06 +04:00
|
|
|
*
|
2006-04-28 01:07:38 +04:00
|
|
|
* Copyright (c) 2005 Samuel Tardieu
|
|
|
|
*
|
|
|
|
* 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/>.
|
2006-04-28 01:07:38 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
#define DEBUG_DISAS
|
|
|
|
|
2016-01-26 21:17:20 +03:00
|
|
|
#include "qemu/osdep.h"
|
2006-04-28 01:07:38 +04:00
|
|
|
#include "cpu.h"
|
2012-10-24 13:12:21 +04:00
|
|
|
#include "disas/disas.h"
|
2016-03-15 15:18:37 +03:00
|
|
|
#include "exec/exec-all.h"
|
2008-02-01 13:50:11 +03:00
|
|
|
#include "tcg-op.h"
|
2014-03-28 22:42:10 +04:00
|
|
|
#include "exec/cpu_ldst.h"
|
2006-04-28 01:07:38 +04:00
|
|
|
|
2014-04-08 09:31:41 +04:00
|
|
|
#include "exec/helper-proto.h"
|
|
|
|
#include "exec/helper-gen.h"
|
2008-11-17 17:43:54 +03:00
|
|
|
|
2014-05-30 16:12:25 +04:00
|
|
|
#include "trace-tcg.h"
|
2016-01-07 16:55:28 +03:00
|
|
|
#include "exec/log.h"
|
2014-05-30 16:12:25 +04:00
|
|
|
|
|
|
|
|
2006-04-28 01:07:38 +04:00
|
|
|
typedef struct DisasContext {
|
|
|
|
struct TranslationBlock *tb;
|
|
|
|
target_ulong pc;
|
|
|
|
uint16_t opcode;
|
2017-05-02 00:20:43 +03:00
|
|
|
uint32_t tbflags; /* should stay unmodified during the TB translation */
|
|
|
|
uint32_t envflags; /* should stay in sync with env->flags using TCG ops */
|
2007-12-02 09:10:04 +03:00
|
|
|
int bstate;
|
2006-04-28 01:07:38 +04:00
|
|
|
int memidx;
|
2017-07-18 23:02:35 +03:00
|
|
|
int gbank;
|
2017-07-18 23:02:38 +03:00
|
|
|
int fbank;
|
2006-04-28 01:07:38 +04:00
|
|
|
uint32_t delayed_pc;
|
|
|
|
int singlestep_enabled;
|
2008-12-13 21:57:37 +03:00
|
|
|
uint32_t features;
|
2009-04-02 03:10:46 +04:00
|
|
|
int has_movcal;
|
2006-04-28 01:07:38 +04:00
|
|
|
} DisasContext;
|
|
|
|
|
2008-09-15 12:49:15 +04:00
|
|
|
#if defined(CONFIG_USER_ONLY)
|
|
|
|
#define IS_USER(ctx) 1
|
|
|
|
#else
|
2017-05-02 00:20:43 +03:00
|
|
|
#define IS_USER(ctx) (!(ctx->tbflags & (1u << SR_MD)))
|
2008-09-15 12:49:15 +04:00
|
|
|
#endif
|
|
|
|
|
2007-12-02 09:10:04 +03:00
|
|
|
enum {
|
|
|
|
BS_NONE = 0, /* We go out of the TB without reaching a branch or an
|
|
|
|
* exception condition
|
|
|
|
*/
|
|
|
|
BS_STOP = 1, /* We want to stop translation for any reason */
|
|
|
|
BS_BRANCH = 2, /* We reached a branch condition */
|
|
|
|
BS_EXCP = 3, /* We reached an exception condition */
|
|
|
|
};
|
|
|
|
|
2008-08-29 04:48:50 +04:00
|
|
|
/* global register indexes */
|
2016-02-25 19:43:15 +03:00
|
|
|
static TCGv_env cpu_env;
|
2017-07-18 23:02:35 +03:00
|
|
|
static TCGv cpu_gregs[32];
|
2015-05-25 02:28:56 +03:00
|
|
|
static TCGv cpu_sr, cpu_sr_m, cpu_sr_q, cpu_sr_t;
|
|
|
|
static TCGv cpu_pc, cpu_ssr, cpu_spc, cpu_gbr;
|
2008-08-29 20:32:18 +04:00
|
|
|
static TCGv cpu_vbr, cpu_sgr, cpu_dbr, cpu_mach, cpu_macl;
|
2009-03-02 20:13:21 +03:00
|
|
|
static TCGv cpu_pr, cpu_fpscr, cpu_fpul, cpu_ldst;
|
2008-11-19 21:00:47 +03:00
|
|
|
static TCGv cpu_fregs[32];
|
2008-08-30 02:32:32 +04:00
|
|
|
|
|
|
|
/* internal register indexes */
|
2017-05-02 00:20:43 +03:00
|
|
|
static TCGv cpu_flags, cpu_delayed_pc, cpu_delayed_cond;
|
2008-08-29 04:48:50 +04:00
|
|
|
|
2012-12-17 21:19:49 +04:00
|
|
|
#include "exec/gen-icount.h"
|
2008-06-29 05:03:05 +04:00
|
|
|
|
2013-01-20 04:30:32 +04:00
|
|
|
void sh4_translate_init(void)
|
2008-06-29 05:03:05 +04:00
|
|
|
{
|
2008-08-29 04:48:50 +04:00
|
|
|
int i;
|
2008-06-29 05:03:05 +04:00
|
|
|
static int done_init = 0;
|
2008-08-29 14:05:12 +04:00
|
|
|
static const char * const gregnames[24] = {
|
2008-08-29 04:48:50 +04:00
|
|
|
"R0_BANK0", "R1_BANK0", "R2_BANK0", "R3_BANK0",
|
|
|
|
"R4_BANK0", "R5_BANK0", "R6_BANK0", "R7_BANK0",
|
|
|
|
"R8", "R9", "R10", "R11", "R12", "R13", "R14", "R15",
|
|
|
|
"R0_BANK1", "R1_BANK1", "R2_BANK1", "R3_BANK1",
|
|
|
|
"R4_BANK1", "R5_BANK1", "R6_BANK1", "R7_BANK1"
|
|
|
|
};
|
2008-11-19 21:00:47 +03:00
|
|
|
static const char * const fregnames[32] = {
|
|
|
|
"FPR0_BANK0", "FPR1_BANK0", "FPR2_BANK0", "FPR3_BANK0",
|
|
|
|
"FPR4_BANK0", "FPR5_BANK0", "FPR6_BANK0", "FPR7_BANK0",
|
|
|
|
"FPR8_BANK0", "FPR9_BANK0", "FPR10_BANK0", "FPR11_BANK0",
|
|
|
|
"FPR12_BANK0", "FPR13_BANK0", "FPR14_BANK0", "FPR15_BANK0",
|
|
|
|
"FPR0_BANK1", "FPR1_BANK1", "FPR2_BANK1", "FPR3_BANK1",
|
|
|
|
"FPR4_BANK1", "FPR5_BANK1", "FPR6_BANK1", "FPR7_BANK1",
|
|
|
|
"FPR8_BANK1", "FPR9_BANK1", "FPR10_BANK1", "FPR11_BANK1",
|
|
|
|
"FPR12_BANK1", "FPR13_BANK1", "FPR14_BANK1", "FPR15_BANK1",
|
|
|
|
};
|
2008-08-29 04:48:50 +04:00
|
|
|
|
2017-07-18 23:02:35 +03:00
|
|
|
if (done_init) {
|
2008-06-29 05:03:05 +04:00
|
|
|
return;
|
2017-07-18 23:02:35 +03:00
|
|
|
}
|
2008-08-29 04:48:50 +04:00
|
|
|
|
2008-11-17 17:43:54 +03:00
|
|
|
cpu_env = tcg_global_reg_new_ptr(TCG_AREG0, "env");
|
2016-06-09 20:31:41 +03:00
|
|
|
tcg_ctx.tcg_env = cpu_env;
|
2008-08-29 04:48:50 +04:00
|
|
|
|
2017-07-18 23:02:35 +03:00
|
|
|
for (i = 0; i < 24; i++) {
|
2013-09-18 23:53:09 +04:00
|
|
|
cpu_gregs[i] = tcg_global_mem_new_i32(cpu_env,
|
2012-03-14 04:38:22 +04:00
|
|
|
offsetof(CPUSH4State, gregs[i]),
|
2008-11-19 21:00:47 +03:00
|
|
|
gregnames[i]);
|
2017-07-18 23:02:35 +03:00
|
|
|
}
|
|
|
|
memcpy(cpu_gregs + 24, cpu_gregs + 8, 8 * sizeof(TCGv));
|
2008-08-29 01:02:00 +04:00
|
|
|
|
2013-09-18 23:53:09 +04:00
|
|
|
cpu_pc = tcg_global_mem_new_i32(cpu_env,
|
2012-03-14 04:38:22 +04:00
|
|
|
offsetof(CPUSH4State, pc), "PC");
|
2013-09-18 23:53:09 +04:00
|
|
|
cpu_sr = tcg_global_mem_new_i32(cpu_env,
|
2012-03-14 04:38:22 +04:00
|
|
|
offsetof(CPUSH4State, sr), "SR");
|
2013-09-18 23:53:09 +04:00
|
|
|
cpu_sr_m = tcg_global_mem_new_i32(cpu_env,
|
|
|
|
offsetof(CPUSH4State, sr_m), "SR_M");
|
|
|
|
cpu_sr_q = tcg_global_mem_new_i32(cpu_env,
|
|
|
|
offsetof(CPUSH4State, sr_q), "SR_Q");
|
|
|
|
cpu_sr_t = tcg_global_mem_new_i32(cpu_env,
|
|
|
|
offsetof(CPUSH4State, sr_t), "SR_T");
|
|
|
|
cpu_ssr = tcg_global_mem_new_i32(cpu_env,
|
2012-03-14 04:38:22 +04:00
|
|
|
offsetof(CPUSH4State, ssr), "SSR");
|
2013-09-18 23:53:09 +04:00
|
|
|
cpu_spc = tcg_global_mem_new_i32(cpu_env,
|
2012-03-14 04:38:22 +04:00
|
|
|
offsetof(CPUSH4State, spc), "SPC");
|
2013-09-18 23:53:09 +04:00
|
|
|
cpu_gbr = tcg_global_mem_new_i32(cpu_env,
|
2012-03-14 04:38:22 +04:00
|
|
|
offsetof(CPUSH4State, gbr), "GBR");
|
2013-09-18 23:53:09 +04:00
|
|
|
cpu_vbr = tcg_global_mem_new_i32(cpu_env,
|
2012-03-14 04:38:22 +04:00
|
|
|
offsetof(CPUSH4State, vbr), "VBR");
|
2013-09-18 23:53:09 +04:00
|
|
|
cpu_sgr = tcg_global_mem_new_i32(cpu_env,
|
2012-03-14 04:38:22 +04:00
|
|
|
offsetof(CPUSH4State, sgr), "SGR");
|
2013-09-18 23:53:09 +04:00
|
|
|
cpu_dbr = tcg_global_mem_new_i32(cpu_env,
|
2012-03-14 04:38:22 +04:00
|
|
|
offsetof(CPUSH4State, dbr), "DBR");
|
2013-09-18 23:53:09 +04:00
|
|
|
cpu_mach = tcg_global_mem_new_i32(cpu_env,
|
2012-03-14 04:38:22 +04:00
|
|
|
offsetof(CPUSH4State, mach), "MACH");
|
2013-09-18 23:53:09 +04:00
|
|
|
cpu_macl = tcg_global_mem_new_i32(cpu_env,
|
2012-03-14 04:38:22 +04:00
|
|
|
offsetof(CPUSH4State, macl), "MACL");
|
2013-09-18 23:53:09 +04:00
|
|
|
cpu_pr = tcg_global_mem_new_i32(cpu_env,
|
2012-03-14 04:38:22 +04:00
|
|
|
offsetof(CPUSH4State, pr), "PR");
|
2013-09-18 23:53:09 +04:00
|
|
|
cpu_fpscr = tcg_global_mem_new_i32(cpu_env,
|
2012-03-14 04:38:22 +04:00
|
|
|
offsetof(CPUSH4State, fpscr), "FPSCR");
|
2013-09-18 23:53:09 +04:00
|
|
|
cpu_fpul = tcg_global_mem_new_i32(cpu_env,
|
2012-03-14 04:38:22 +04:00
|
|
|
offsetof(CPUSH4State, fpul), "FPUL");
|
2008-11-17 17:43:54 +03:00
|
|
|
|
2013-09-18 23:53:09 +04:00
|
|
|
cpu_flags = tcg_global_mem_new_i32(cpu_env,
|
2012-03-14 04:38:22 +04:00
|
|
|
offsetof(CPUSH4State, flags), "_flags_");
|
2013-09-18 23:53:09 +04:00
|
|
|
cpu_delayed_pc = tcg_global_mem_new_i32(cpu_env,
|
2012-03-14 04:38:22 +04:00
|
|
|
offsetof(CPUSH4State, delayed_pc),
|
2008-11-17 17:43:54 +03:00
|
|
|
"_delayed_pc_");
|
2017-05-02 00:20:43 +03:00
|
|
|
cpu_delayed_cond = tcg_global_mem_new_i32(cpu_env,
|
|
|
|
offsetof(CPUSH4State,
|
|
|
|
delayed_cond),
|
|
|
|
"_delayed_cond_");
|
2013-09-18 23:53:09 +04:00
|
|
|
cpu_ldst = tcg_global_mem_new_i32(cpu_env,
|
2012-03-14 04:38:22 +04:00
|
|
|
offsetof(CPUSH4State, ldst), "_ldst_");
|
2008-08-30 02:32:32 +04:00
|
|
|
|
2008-11-19 21:00:47 +03:00
|
|
|
for (i = 0; i < 32; i++)
|
2013-09-18 23:53:09 +04:00
|
|
|
cpu_fregs[i] = tcg_global_mem_new_i32(cpu_env,
|
2012-03-14 04:38:22 +04:00
|
|
|
offsetof(CPUSH4State, fregs[i]),
|
2008-11-19 21:00:47 +03:00
|
|
|
fregnames[i]);
|
|
|
|
|
2008-06-29 05:03:05 +04:00
|
|
|
done_init = 1;
|
|
|
|
}
|
|
|
|
|
2013-05-27 03:33:50 +04:00
|
|
|
void superh_cpu_dump_state(CPUState *cs, FILE *f,
|
|
|
|
fprintf_function cpu_fprintf, int flags)
|
2006-04-28 01:07:38 +04:00
|
|
|
{
|
2013-05-27 03:33:50 +04:00
|
|
|
SuperHCPU *cpu = SUPERH_CPU(cs);
|
|
|
|
CPUSH4State *env = &cpu->env;
|
2006-04-28 01:07:38 +04:00
|
|
|
int i;
|
2006-06-14 19:02:05 +04:00
|
|
|
cpu_fprintf(f, "pc=0x%08x sr=0x%08x pr=0x%08x fpscr=0x%08x\n",
|
2015-05-25 02:28:56 +03:00
|
|
|
env->pc, cpu_read_sr(env), env->pr, env->fpscr);
|
2008-08-22 12:57:35 +04:00
|
|
|
cpu_fprintf(f, "spc=0x%08x ssr=0x%08x gbr=0x%08x vbr=0x%08x\n",
|
|
|
|
env->spc, env->ssr, env->gbr, env->vbr);
|
|
|
|
cpu_fprintf(f, "sgr=0x%08x dbr=0x%08x delayed_pc=0x%08x fpul=0x%08x\n",
|
|
|
|
env->sgr, env->dbr, env->delayed_pc, env->fpul);
|
2006-04-28 01:07:38 +04:00
|
|
|
for (i = 0; i < 24; i += 4) {
|
|
|
|
cpu_fprintf(f, "r%d=0x%08x r%d=0x%08x r%d=0x%08x r%d=0x%08x\n",
|
|
|
|
i, env->gregs[i], i + 1, env->gregs[i + 1],
|
|
|
|
i + 2, env->gregs[i + 2], i + 3, env->gregs[i + 3]);
|
|
|
|
}
|
|
|
|
if (env->flags & DELAY_SLOT) {
|
|
|
|
cpu_fprintf(f, "in delay slot (delayed_pc=0x%08x)\n",
|
|
|
|
env->delayed_pc);
|
|
|
|
} else if (env->flags & DELAY_SLOT_CONDITIONAL) {
|
|
|
|
cpu_fprintf(f, "in conditional delay slot (delayed_pc=0x%08x)\n",
|
|
|
|
env->delayed_pc);
|
2017-05-17 01:48:18 +03:00
|
|
|
} else if (env->flags & DELAY_SLOT_RTE) {
|
|
|
|
cpu_fprintf(f, "in rte delay slot (delayed_pc=0x%08x)\n",
|
|
|
|
env->delayed_pc);
|
2006-04-28 01:07:38 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-05-25 02:28:56 +03:00
|
|
|
static void gen_read_sr(TCGv dst)
|
|
|
|
{
|
2015-05-25 02:28:56 +03:00
|
|
|
TCGv t0 = tcg_temp_new();
|
|
|
|
tcg_gen_shli_i32(t0, cpu_sr_q, SR_Q);
|
|
|
|
tcg_gen_or_i32(dst, dst, t0);
|
|
|
|
tcg_gen_shli_i32(t0, cpu_sr_m, SR_M);
|
|
|
|
tcg_gen_or_i32(dst, dst, t0);
|
|
|
|
tcg_gen_shli_i32(t0, cpu_sr_t, SR_T);
|
|
|
|
tcg_gen_or_i32(dst, cpu_sr, t0);
|
|
|
|
tcg_temp_free_i32(t0);
|
2015-05-25 02:28:56 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static void gen_write_sr(TCGv src)
|
|
|
|
{
|
2015-05-25 02:28:56 +03:00
|
|
|
tcg_gen_andi_i32(cpu_sr, src,
|
|
|
|
~((1u << SR_Q) | (1u << SR_M) | (1u << SR_T)));
|
2017-05-02 00:20:43 +03:00
|
|
|
tcg_gen_extract_i32(cpu_sr_q, src, SR_Q, 1);
|
|
|
|
tcg_gen_extract_i32(cpu_sr_m, src, SR_M, 1);
|
|
|
|
tcg_gen_extract_i32(cpu_sr_t, src, SR_T, 1);
|
2015-05-25 02:28:56 +03:00
|
|
|
}
|
|
|
|
|
2017-05-02 00:20:43 +03:00
|
|
|
static inline void gen_save_cpu_state(DisasContext *ctx, bool save_pc)
|
|
|
|
{
|
|
|
|
if (save_pc) {
|
|
|
|
tcg_gen_movi_i32(cpu_pc, ctx->pc);
|
|
|
|
}
|
|
|
|
if (ctx->delayed_pc != (uint32_t) -1) {
|
|
|
|
tcg_gen_movi_i32(cpu_delayed_pc, ctx->delayed_pc);
|
|
|
|
}
|
2017-07-18 23:02:28 +03:00
|
|
|
if ((ctx->tbflags & TB_FLAG_ENVFLAGS_MASK) != ctx->envflags) {
|
2017-05-02 00:20:43 +03:00
|
|
|
tcg_gen_movi_i32(cpu_flags, ctx->envflags);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-07-18 23:02:52 +03:00
|
|
|
static inline bool use_exit_tb(DisasContext *ctx)
|
|
|
|
{
|
|
|
|
return (ctx->tbflags & GUSA_EXCLUSIVE) != 0;
|
|
|
|
}
|
|
|
|
|
2016-04-09 01:00:23 +03:00
|
|
|
static inline bool use_goto_tb(DisasContext *ctx, target_ulong dest)
|
2006-04-28 01:07:38 +04:00
|
|
|
{
|
2017-07-18 23:02:52 +03:00
|
|
|
/* Use a direct jump if in same page and singlestep not enabled */
|
|
|
|
if (unlikely(ctx->singlestep_enabled || use_exit_tb(ctx))) {
|
2017-07-18 23:02:31 +03:00
|
|
|
return false;
|
|
|
|
}
|
2016-04-09 01:00:23 +03:00
|
|
|
#ifndef CONFIG_USER_ONLY
|
|
|
|
return (ctx->tb->pc & TARGET_PAGE_MASK) == (dest & TARGET_PAGE_MASK);
|
|
|
|
#else
|
|
|
|
return true;
|
|
|
|
#endif
|
|
|
|
}
|
2006-04-28 01:07:38 +04:00
|
|
|
|
2016-04-09 01:00:23 +03:00
|
|
|
static void gen_goto_tb(DisasContext *ctx, int n, target_ulong dest)
|
|
|
|
{
|
|
|
|
if (use_goto_tb(ctx, dest)) {
|
2008-02-01 13:50:11 +03:00
|
|
|
tcg_gen_goto_tb(n);
|
2008-08-29 20:32:18 +04:00
|
|
|
tcg_gen_movi_i32(cpu_pc, dest);
|
2016-04-09 01:00:23 +03:00
|
|
|
tcg_gen_exit_tb((uintptr_t)ctx->tb + n);
|
2006-04-28 01:07:38 +04:00
|
|
|
} else {
|
2008-08-29 20:32:18 +04:00
|
|
|
tcg_gen_movi_i32(cpu_pc, dest);
|
2017-07-18 23:02:52 +03:00
|
|
|
if (ctx->singlestep_enabled) {
|
2012-09-02 14:37:06 +04:00
|
|
|
gen_helper_debug(cpu_env);
|
2017-07-18 23:02:52 +03:00
|
|
|
} else if (use_exit_tb(ctx)) {
|
|
|
|
tcg_gen_exit_tb(0);
|
|
|
|
} else {
|
|
|
|
tcg_gen_lookup_and_goto_ptr(cpu_pc);
|
|
|
|
}
|
2006-04-28 01:07:38 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void gen_jump(DisasContext * ctx)
|
|
|
|
{
|
2017-07-18 23:02:52 +03:00
|
|
|
if (ctx->delayed_pc == -1) {
|
2006-04-28 01:07:38 +04:00
|
|
|
/* Target is not statically known, it comes necessarily from a
|
|
|
|
delayed jump as immediate jump are conditinal jumps */
|
2008-08-30 02:32:32 +04:00
|
|
|
tcg_gen_mov_i32(cpu_pc, cpu_delayed_pc);
|
2017-05-02 00:20:43 +03:00
|
|
|
tcg_gen_discard_i32(cpu_delayed_pc);
|
2017-07-18 23:02:52 +03:00
|
|
|
if (ctx->singlestep_enabled) {
|
2012-09-02 14:37:06 +04:00
|
|
|
gen_helper_debug(cpu_env);
|
2017-07-18 23:02:52 +03:00
|
|
|
} else if (use_exit_tb(ctx)) {
|
|
|
|
tcg_gen_exit_tb(0);
|
|
|
|
} else {
|
|
|
|
tcg_gen_lookup_and_goto_ptr(cpu_pc);
|
|
|
|
}
|
2006-04-28 01:07:38 +04:00
|
|
|
} else {
|
|
|
|
gen_goto_tb(ctx, 0, ctx->delayed_pc);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Immediate conditional jump (bt or bf) */
|
2017-07-18 23:02:31 +03:00
|
|
|
static void gen_conditional_jump(DisasContext *ctx, target_ulong dest,
|
|
|
|
bool jump_if_true)
|
2006-04-28 01:07:38 +04:00
|
|
|
{
|
2015-05-25 02:28:56 +03:00
|
|
|
TCGLabel *l1 = gen_new_label();
|
2017-07-18 23:02:31 +03:00
|
|
|
TCGCond cond_not_taken = jump_if_true ? TCG_COND_EQ : TCG_COND_NE;
|
|
|
|
|
|
|
|
if (ctx->tbflags & GUSA_EXCLUSIVE) {
|
|
|
|
/* When in an exclusive region, we must continue to the end.
|
|
|
|
Therefore, exit the region on a taken branch, but otherwise
|
|
|
|
fall through to the next instruction. */
|
|
|
|
tcg_gen_brcondi_i32(cond_not_taken, cpu_sr_t, 0, l1);
|
|
|
|
tcg_gen_movi_i32(cpu_flags, ctx->envflags & ~GUSA_MASK);
|
|
|
|
/* Note that this won't actually use a goto_tb opcode because we
|
|
|
|
disallow it in use_goto_tb, but it handles exit + singlestep. */
|
|
|
|
gen_goto_tb(ctx, 0, dest);
|
|
|
|
gen_set_label(l1);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-05-02 00:20:43 +03:00
|
|
|
gen_save_cpu_state(ctx, false);
|
2017-07-18 23:02:31 +03:00
|
|
|
tcg_gen_brcondi_i32(cond_not_taken, cpu_sr_t, 0, l1);
|
|
|
|
gen_goto_tb(ctx, 0, dest);
|
2006-04-28 01:07:38 +04:00
|
|
|
gen_set_label(l1);
|
2017-07-18 23:02:31 +03:00
|
|
|
gen_goto_tb(ctx, 1, ctx->pc + 2);
|
2017-05-02 00:20:43 +03:00
|
|
|
ctx->bstate = BS_BRANCH;
|
2006-04-28 01:07:38 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Delayed conditional jump (bt or bf) */
|
|
|
|
static void gen_delayed_conditional_jump(DisasContext * ctx)
|
|
|
|
{
|
2017-07-18 23:02:31 +03:00
|
|
|
TCGLabel *l1 = gen_new_label();
|
|
|
|
TCGv ds = tcg_temp_new();
|
2006-04-28 01:07:38 +04:00
|
|
|
|
2017-05-02 00:20:43 +03:00
|
|
|
tcg_gen_mov_i32(ds, cpu_delayed_cond);
|
|
|
|
tcg_gen_discard_i32(cpu_delayed_cond);
|
2017-07-18 23:02:31 +03:00
|
|
|
|
|
|
|
if (ctx->tbflags & GUSA_EXCLUSIVE) {
|
|
|
|
/* When in an exclusive region, we must continue to the end.
|
|
|
|
Therefore, exit the region on a taken branch, but otherwise
|
|
|
|
fall through to the next instruction. */
|
|
|
|
tcg_gen_brcondi_i32(TCG_COND_EQ, ds, 0, l1);
|
|
|
|
|
|
|
|
/* Leave the gUSA region. */
|
|
|
|
tcg_gen_movi_i32(cpu_flags, ctx->envflags & ~GUSA_MASK);
|
|
|
|
gen_jump(ctx);
|
|
|
|
|
|
|
|
gen_set_label(l1);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-01-14 22:39:18 +03:00
|
|
|
tcg_gen_brcondi_i32(TCG_COND_NE, ds, 0, l1);
|
2007-12-02 09:10:04 +03:00
|
|
|
gen_goto_tb(ctx, 1, ctx->pc + 2);
|
2006-04-28 01:07:38 +04:00
|
|
|
gen_set_label(l1);
|
2006-06-18 23:12:54 +04:00
|
|
|
gen_jump(ctx);
|
2006-04-28 01:07:38 +04:00
|
|
|
}
|
|
|
|
|
2017-07-18 23:02:37 +03:00
|
|
|
static inline void gen_load_fpr64(DisasContext *ctx, TCGv_i64 t, int reg)
|
2008-09-02 02:11:56 +04:00
|
|
|
{
|
2017-07-18 23:02:40 +03:00
|
|
|
/* We have already signaled illegal instruction for odd Dr. */
|
|
|
|
tcg_debug_assert((reg & 1) == 0);
|
|
|
|
reg ^= ctx->fbank;
|
2008-11-19 21:00:47 +03:00
|
|
|
tcg_gen_concat_i32_i64(t, cpu_fregs[reg + 1], cpu_fregs[reg]);
|
2008-09-02 02:11:56 +04:00
|
|
|
}
|
|
|
|
|
2017-07-18 23:02:37 +03:00
|
|
|
static inline void gen_store_fpr64(DisasContext *ctx, TCGv_i64 t, int reg)
|
2008-09-02 02:11:56 +04:00
|
|
|
{
|
2017-07-18 23:02:40 +03:00
|
|
|
/* We have already signaled illegal instruction for odd Dr. */
|
|
|
|
tcg_debug_assert((reg & 1) == 0);
|
|
|
|
reg ^= ctx->fbank;
|
2017-05-02 00:20:43 +03:00
|
|
|
tcg_gen_extr_i64_i32(cpu_fregs[reg + 1], cpu_fregs[reg], t);
|
2008-09-02 02:11:56 +04:00
|
|
|
}
|
|
|
|
|
2006-04-28 01:07:38 +04:00
|
|
|
#define B3_0 (ctx->opcode & 0xf)
|
|
|
|
#define B6_4 ((ctx->opcode >> 4) & 0x7)
|
|
|
|
#define B7_4 ((ctx->opcode >> 4) & 0xf)
|
|
|
|
#define B7_0 (ctx->opcode & 0xff)
|
|
|
|
#define B7_0s ((int32_t) (int8_t) (ctx->opcode & 0xff))
|
|
|
|
#define B11_0s (ctx->opcode & 0x800 ? 0xfffff000 | (ctx->opcode & 0xfff) : \
|
|
|
|
(ctx->opcode & 0xfff))
|
|
|
|
#define B11_8 ((ctx->opcode >> 8) & 0xf)
|
|
|
|
#define B15_12 ((ctx->opcode >> 12) & 0xf)
|
|
|
|
|
2017-07-18 23:02:35 +03:00
|
|
|
#define REG(x) cpu_gregs[(x) ^ ctx->gbank]
|
|
|
|
#define ALTREG(x) cpu_gregs[(x) ^ ctx->gbank ^ 0x10]
|
2017-07-18 23:02:38 +03:00
|
|
|
#define FREG(x) cpu_fregs[(x) ^ ctx->fbank]
|
2006-04-28 01:07:38 +04:00
|
|
|
|
2007-05-13 20:33:43 +04:00
|
|
|
#define XHACK(x) ((((x) & 1 ) << 4) | ((x) & 0xe))
|
2006-06-14 19:02:05 +04:00
|
|
|
|
2006-04-28 01:07:38 +04:00
|
|
|
#define CHECK_NOT_DELAY_SLOT \
|
2017-07-18 23:02:43 +03:00
|
|
|
if (ctx->envflags & DELAY_SLOT_MASK) { \
|
|
|
|
goto do_illegal_slot; \
|
2017-05-02 00:20:43 +03:00
|
|
|
}
|
|
|
|
|
2017-07-18 23:02:44 +03:00
|
|
|
#define CHECK_PRIVILEGED \
|
|
|
|
if (IS_USER(ctx)) { \
|
|
|
|
goto do_illegal; \
|
2017-05-02 00:20:43 +03:00
|
|
|
}
|
|
|
|
|
2017-07-18 23:02:45 +03:00
|
|
|
#define CHECK_FPU_ENABLED \
|
|
|
|
if (ctx->tbflags & (1u << SR_FD)) { \
|
|
|
|
goto do_fpu_disabled; \
|
2017-05-02 00:20:43 +03:00
|
|
|
}
|
2008-12-08 01:46:31 +03:00
|
|
|
|
2017-07-18 23:02:47 +03:00
|
|
|
#define CHECK_FPSCR_PR_0 \
|
|
|
|
if (ctx->tbflags & FPSCR_PR) { \
|
|
|
|
goto do_illegal; \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define CHECK_FPSCR_PR_1 \
|
|
|
|
if (!(ctx->tbflags & FPSCR_PR)) { \
|
|
|
|
goto do_illegal; \
|
|
|
|
}
|
|
|
|
|
2017-07-18 23:02:48 +03:00
|
|
|
#define CHECK_SH4A \
|
|
|
|
if (!(ctx->features & SH_FEATURE_SH4A)) { \
|
|
|
|
goto do_illegal; \
|
|
|
|
}
|
|
|
|
|
2008-10-26 16:43:07 +03:00
|
|
|
static void _decode_opc(DisasContext * ctx)
|
2006-04-28 01:07:38 +04:00
|
|
|
{
|
2009-04-02 03:10:46 +04:00
|
|
|
/* This code tries to make movcal emulation sufficiently
|
|
|
|
accurate for Linux purposes. This instruction writes
|
|
|
|
memory, and prior to that, always allocates a cache line.
|
|
|
|
It is used in two contexts:
|
|
|
|
- in memcpy, where data is copied in blocks, the first write
|
|
|
|
of to a block uses movca.l for performance.
|
|
|
|
- in arch/sh/mm/cache-sh4.c, movcal.l + ocbi combination is used
|
|
|
|
to flush the cache. Here, the data written by movcal.l is never
|
|
|
|
written to memory, and the data written is just bogus.
|
|
|
|
|
|
|
|
To simulate this, we simulate movcal.l, we store the value to memory,
|
|
|
|
but we also remember the previous content. If we see ocbi, we check
|
|
|
|
if movcal.l for that address was done previously. If so, the write should
|
|
|
|
not have hit the memory, so we restore the previous content.
|
|
|
|
When we see an instruction that is neither movca.l
|
|
|
|
nor ocbi, the previous content is discarded.
|
|
|
|
|
|
|
|
To optimize, we only try to flush stores when we're at the start of
|
|
|
|
TB, or if we already saw movca.l in this TB and did not flush stores
|
|
|
|
yet. */
|
|
|
|
if (ctx->has_movcal)
|
|
|
|
{
|
|
|
|
int opcode = ctx->opcode & 0xf0ff;
|
|
|
|
if (opcode != 0x0093 /* ocbi */
|
|
|
|
&& opcode != 0x00c3 /* movca.l */)
|
|
|
|
{
|
2012-09-02 14:37:06 +04:00
|
|
|
gen_helper_discard_movcal_backup(cpu_env);
|
2009-04-02 03:10:46 +04:00
|
|
|
ctx->has_movcal = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-04-28 01:07:38 +04:00
|
|
|
#if 0
|
|
|
|
fprintf(stderr, "Translating opcode 0x%04x\n", ctx->opcode);
|
|
|
|
#endif
|
2008-12-10 20:31:43 +03:00
|
|
|
|
2006-04-28 01:07:38 +04:00
|
|
|
switch (ctx->opcode) {
|
|
|
|
case 0x0019: /* div0u */
|
2015-05-25 02:28:56 +03:00
|
|
|
tcg_gen_movi_i32(cpu_sr_m, 0);
|
|
|
|
tcg_gen_movi_i32(cpu_sr_q, 0);
|
2015-05-25 02:28:56 +03:00
|
|
|
tcg_gen_movi_i32(cpu_sr_t, 0);
|
2006-04-28 01:07:38 +04:00
|
|
|
return;
|
|
|
|
case 0x000b: /* rts */
|
2008-08-30 02:32:32 +04:00
|
|
|
CHECK_NOT_DELAY_SLOT
|
|
|
|
tcg_gen_mov_i32(cpu_delayed_pc, cpu_pr);
|
2017-05-02 00:20:43 +03:00
|
|
|
ctx->envflags |= DELAY_SLOT;
|
2006-04-28 01:07:38 +04:00
|
|
|
ctx->delayed_pc = (uint32_t) - 1;
|
|
|
|
return;
|
|
|
|
case 0x0028: /* clrmac */
|
2008-08-29 20:32:18 +04:00
|
|
|
tcg_gen_movi_i32(cpu_mach, 0);
|
|
|
|
tcg_gen_movi_i32(cpu_macl, 0);
|
2006-04-28 01:07:38 +04:00
|
|
|
return;
|
|
|
|
case 0x0048: /* clrs */
|
2015-05-25 02:28:56 +03:00
|
|
|
tcg_gen_andi_i32(cpu_sr, cpu_sr, ~(1u << SR_S));
|
2006-04-28 01:07:38 +04:00
|
|
|
return;
|
|
|
|
case 0x0008: /* clrt */
|
2015-05-25 02:28:56 +03:00
|
|
|
tcg_gen_movi_i32(cpu_sr_t, 0);
|
2006-04-28 01:07:38 +04:00
|
|
|
return;
|
|
|
|
case 0x0038: /* ldtlb */
|
2008-09-15 12:49:15 +04:00
|
|
|
CHECK_PRIVILEGED
|
2012-09-02 14:37:06 +04:00
|
|
|
gen_helper_ldtlb(cpu_env);
|
2006-04-28 01:07:38 +04:00
|
|
|
return;
|
2007-09-29 23:52:22 +04:00
|
|
|
case 0x002b: /* rte */
|
2008-09-15 12:49:15 +04:00
|
|
|
CHECK_PRIVILEGED
|
2008-08-30 02:32:32 +04:00
|
|
|
CHECK_NOT_DELAY_SLOT
|
2015-05-25 02:28:56 +03:00
|
|
|
gen_write_sr(cpu_ssr);
|
2008-08-30 02:32:32 +04:00
|
|
|
tcg_gen_mov_i32(cpu_delayed_pc, cpu_spc);
|
2017-05-17 01:48:18 +03:00
|
|
|
ctx->envflags |= DELAY_SLOT_RTE;
|
2006-04-28 01:07:38 +04:00
|
|
|
ctx->delayed_pc = (uint32_t) - 1;
|
2017-05-17 01:48:18 +03:00
|
|
|
ctx->bstate = BS_STOP;
|
2006-04-28 01:07:38 +04:00
|
|
|
return;
|
|
|
|
case 0x0058: /* sets */
|
2015-05-25 02:28:56 +03:00
|
|
|
tcg_gen_ori_i32(cpu_sr, cpu_sr, (1u << SR_S));
|
2006-04-28 01:07:38 +04:00
|
|
|
return;
|
|
|
|
case 0x0018: /* sett */
|
2015-05-25 02:28:56 +03:00
|
|
|
tcg_gen_movi_i32(cpu_sr_t, 1);
|
2006-04-28 01:07:38 +04:00
|
|
|
return;
|
SH4, fix several instructions
fix instruction code for frchg, fschg, ocbp.
fix addressing mode handling for @Rn+, @-Rn, @(disp,gbr).
fix operation for div0s.
fix comments for mov imm, add imm, @(r0+,gbr), mac.l @Rm+,@Rn+.
fix ldb to ldub for or/tst/xor.b #imm,@(r0,gbr).
add fmov extended operations.
add fcmp/eq, fcmp/gt, fneg, fabs, fsqrt, fcnvsd, fcnvds.
(Takashi Yoshii)
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@4040 c046a42c-6fe2-441c-8c8c-71466251a162
2008-03-12 02:22:37 +03:00
|
|
|
case 0xfbfd: /* frchg */
|
2017-07-18 23:02:50 +03:00
|
|
|
CHECK_FPSCR_PR_0
|
2008-08-30 17:55:14 +04:00
|
|
|
tcg_gen_xori_i32(cpu_fpscr, cpu_fpscr, FPSCR_FR);
|
2007-12-02 09:10:04 +03:00
|
|
|
ctx->bstate = BS_STOP;
|
2006-04-28 01:07:38 +04:00
|
|
|
return;
|
SH4, fix several instructions
fix instruction code for frchg, fschg, ocbp.
fix addressing mode handling for @Rn+, @-Rn, @(disp,gbr).
fix operation for div0s.
fix comments for mov imm, add imm, @(r0+,gbr), mac.l @Rm+,@Rn+.
fix ldb to ldub for or/tst/xor.b #imm,@(r0,gbr).
add fmov extended operations.
add fcmp/eq, fcmp/gt, fneg, fabs, fsqrt, fcnvsd, fcnvds.
(Takashi Yoshii)
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@4040 c046a42c-6fe2-441c-8c8c-71466251a162
2008-03-12 02:22:37 +03:00
|
|
|
case 0xf3fd: /* fschg */
|
2017-07-18 23:02:50 +03:00
|
|
|
CHECK_FPSCR_PR_0
|
2012-09-16 15:12:21 +04:00
|
|
|
tcg_gen_xori_i32(cpu_fpscr, cpu_fpscr, FPSCR_SZ);
|
2007-12-02 09:10:04 +03:00
|
|
|
ctx->bstate = BS_STOP;
|
2006-04-28 01:07:38 +04:00
|
|
|
return;
|
2017-07-18 23:02:49 +03:00
|
|
|
case 0xf7fd: /* fpchg */
|
|
|
|
CHECK_SH4A
|
|
|
|
tcg_gen_xori_i32(cpu_fpscr, cpu_fpscr, FPSCR_PR);
|
|
|
|
ctx->bstate = BS_STOP;
|
|
|
|
return;
|
2006-04-28 01:07:38 +04:00
|
|
|
case 0x0009: /* nop */
|
|
|
|
return;
|
|
|
|
case 0x001b: /* sleep */
|
2008-09-15 12:49:15 +04:00
|
|
|
CHECK_PRIVILEGED
|
2012-09-16 15:12:21 +04:00
|
|
|
tcg_gen_movi_i32(cpu_pc, ctx->pc + 2);
|
|
|
|
gen_helper_sleep(cpu_env);
|
2006-04-28 01:07:38 +04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (ctx->opcode & 0xf000) {
|
|
|
|
case 0x1000: /* mov.l Rm,@(disp,Rn) */
|
2008-09-01 17:09:21 +04:00
|
|
|
{
|
2008-11-17 17:43:54 +03:00
|
|
|
TCGv addr = tcg_temp_new();
|
2008-09-01 17:09:21 +04:00
|
|
|
tcg_gen_addi_i32(addr, REG(B11_8), B3_0 * 4);
|
2013-12-11 10:56:47 +04:00
|
|
|
tcg_gen_qemu_st_i32(REG(B7_4), addr, ctx->memidx, MO_TEUL);
|
2008-09-01 17:09:21 +04:00
|
|
|
tcg_temp_free(addr);
|
|
|
|
}
|
2006-04-28 01:07:38 +04:00
|
|
|
return;
|
|
|
|
case 0x5000: /* mov.l @(disp,Rm),Rn */
|
2008-09-01 17:09:21 +04:00
|
|
|
{
|
2008-11-17 17:43:54 +03:00
|
|
|
TCGv addr = tcg_temp_new();
|
2008-09-01 17:09:21 +04:00
|
|
|
tcg_gen_addi_i32(addr, REG(B7_4), B3_0 * 4);
|
2013-12-11 10:56:47 +04:00
|
|
|
tcg_gen_qemu_ld_i32(REG(B11_8), addr, ctx->memidx, MO_TESL);
|
2008-09-01 17:09:21 +04:00
|
|
|
tcg_temp_free(addr);
|
|
|
|
}
|
2006-04-28 01:07:38 +04:00
|
|
|
return;
|
SH4, fix several instructions
fix instruction code for frchg, fschg, ocbp.
fix addressing mode handling for @Rn+, @-Rn, @(disp,gbr).
fix operation for div0s.
fix comments for mov imm, add imm, @(r0+,gbr), mac.l @Rm+,@Rn+.
fix ldb to ldub for or/tst/xor.b #imm,@(r0,gbr).
add fmov extended operations.
add fcmp/eq, fcmp/gt, fneg, fabs, fsqrt, fcnvsd, fcnvds.
(Takashi Yoshii)
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@4040 c046a42c-6fe2-441c-8c8c-71466251a162
2008-03-12 02:22:37 +03:00
|
|
|
case 0xe000: /* mov #imm,Rn */
|
2017-07-18 23:02:31 +03:00
|
|
|
#ifdef CONFIG_USER_ONLY
|
|
|
|
/* Detect the start of a gUSA region. If so, update envflags
|
|
|
|
and end the TB. This will allow us to see the end of the
|
|
|
|
region (stored in R0) in the next TB. */
|
|
|
|
if (B11_8 == 15 && B7_0s < 0 && parallel_cpus) {
|
|
|
|
ctx->envflags = deposit32(ctx->envflags, GUSA_SHIFT, 8, B7_0s);
|
|
|
|
ctx->bstate = BS_STOP;
|
|
|
|
}
|
|
|
|
#endif
|
2008-09-01 17:09:14 +04:00
|
|
|
tcg_gen_movi_i32(REG(B11_8), B7_0s);
|
2006-04-28 01:07:38 +04:00
|
|
|
return;
|
|
|
|
case 0x9000: /* mov.w @(disp,PC),Rn */
|
2008-09-01 17:09:21 +04:00
|
|
|
{
|
|
|
|
TCGv addr = tcg_const_i32(ctx->pc + 4 + B7_0 * 2);
|
2013-12-11 10:56:47 +04:00
|
|
|
tcg_gen_qemu_ld_i32(REG(B11_8), addr, ctx->memidx, MO_TESW);
|
2008-09-01 17:09:21 +04:00
|
|
|
tcg_temp_free(addr);
|
|
|
|
}
|
2006-04-28 01:07:38 +04:00
|
|
|
return;
|
|
|
|
case 0xd000: /* mov.l @(disp,PC),Rn */
|
2008-09-01 17:09:21 +04:00
|
|
|
{
|
|
|
|
TCGv addr = tcg_const_i32((ctx->pc + 4 + B7_0 * 4) & ~3);
|
2013-12-11 10:56:47 +04:00
|
|
|
tcg_gen_qemu_ld_i32(REG(B11_8), addr, ctx->memidx, MO_TESL);
|
2008-09-01 17:09:21 +04:00
|
|
|
tcg_temp_free(addr);
|
|
|
|
}
|
2006-04-28 01:07:38 +04:00
|
|
|
return;
|
SH4, fix several instructions
fix instruction code for frchg, fschg, ocbp.
fix addressing mode handling for @Rn+, @-Rn, @(disp,gbr).
fix operation for div0s.
fix comments for mov imm, add imm, @(r0+,gbr), mac.l @Rm+,@Rn+.
fix ldb to ldub for or/tst/xor.b #imm,@(r0,gbr).
add fmov extended operations.
add fcmp/eq, fcmp/gt, fneg, fabs, fsqrt, fcnvsd, fcnvds.
(Takashi Yoshii)
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@4040 c046a42c-6fe2-441c-8c8c-71466251a162
2008-03-12 02:22:37 +03:00
|
|
|
case 0x7000: /* add #imm,Rn */
|
2008-09-01 17:09:14 +04:00
|
|
|
tcg_gen_addi_i32(REG(B11_8), REG(B11_8), B7_0s);
|
2006-04-28 01:07:38 +04:00
|
|
|
return;
|
|
|
|
case 0xa000: /* bra disp */
|
|
|
|
CHECK_NOT_DELAY_SLOT
|
2008-08-30 02:32:32 +04:00
|
|
|
ctx->delayed_pc = ctx->pc + 4 + B11_0s * 2;
|
2017-05-02 00:20:43 +03:00
|
|
|
ctx->envflags |= DELAY_SLOT;
|
2006-04-28 01:07:38 +04:00
|
|
|
return;
|
|
|
|
case 0xb000: /* bsr disp */
|
|
|
|
CHECK_NOT_DELAY_SLOT
|
2008-08-30 02:32:32 +04:00
|
|
|
tcg_gen_movi_i32(cpu_pr, ctx->pc + 4);
|
|
|
|
ctx->delayed_pc = ctx->pc + 4 + B11_0s * 2;
|
2017-05-02 00:20:43 +03:00
|
|
|
ctx->envflags |= DELAY_SLOT;
|
2006-04-28 01:07:38 +04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (ctx->opcode & 0xf00f) {
|
|
|
|
case 0x6003: /* mov Rm,Rn */
|
2008-09-01 17:09:14 +04:00
|
|
|
tcg_gen_mov_i32(REG(B11_8), REG(B7_4));
|
2006-04-28 01:07:38 +04:00
|
|
|
return;
|
|
|
|
case 0x2000: /* mov.b Rm,@Rn */
|
2013-12-11 10:56:47 +04:00
|
|
|
tcg_gen_qemu_st_i32(REG(B7_4), REG(B11_8), ctx->memidx, MO_UB);
|
2006-04-28 01:07:38 +04:00
|
|
|
return;
|
|
|
|
case 0x2001: /* mov.w Rm,@Rn */
|
2013-12-11 10:56:47 +04:00
|
|
|
tcg_gen_qemu_st_i32(REG(B7_4), REG(B11_8), ctx->memidx, MO_TEUW);
|
2006-04-28 01:07:38 +04:00
|
|
|
return;
|
|
|
|
case 0x2002: /* mov.l Rm,@Rn */
|
2013-12-11 10:56:47 +04:00
|
|
|
tcg_gen_qemu_st_i32(REG(B7_4), REG(B11_8), ctx->memidx, MO_TEUL);
|
2006-04-28 01:07:38 +04:00
|
|
|
return;
|
|
|
|
case 0x6000: /* mov.b @Rm,Rn */
|
2013-12-11 10:56:47 +04:00
|
|
|
tcg_gen_qemu_ld_i32(REG(B11_8), REG(B7_4), ctx->memidx, MO_SB);
|
2006-04-28 01:07:38 +04:00
|
|
|
return;
|
|
|
|
case 0x6001: /* mov.w @Rm,Rn */
|
2013-12-11 10:56:47 +04:00
|
|
|
tcg_gen_qemu_ld_i32(REG(B11_8), REG(B7_4), ctx->memidx, MO_TESW);
|
2006-04-28 01:07:38 +04:00
|
|
|
return;
|
|
|
|
case 0x6002: /* mov.l @Rm,Rn */
|
2013-12-11 10:56:47 +04:00
|
|
|
tcg_gen_qemu_ld_i32(REG(B11_8), REG(B7_4), ctx->memidx, MO_TESL);
|
2006-04-28 01:07:38 +04:00
|
|
|
return;
|
|
|
|
case 0x2004: /* mov.b Rm,@-Rn */
|
2008-09-01 17:09:21 +04:00
|
|
|
{
|
2008-11-17 17:43:54 +03:00
|
|
|
TCGv addr = tcg_temp_new();
|
2008-09-01 17:09:21 +04:00
|
|
|
tcg_gen_subi_i32(addr, REG(B11_8), 1);
|
2013-12-11 10:56:47 +04:00
|
|
|
/* might cause re-execution */
|
|
|
|
tcg_gen_qemu_st_i32(REG(B7_4), addr, ctx->memidx, MO_UB);
|
2010-01-31 03:07:25 +03:00
|
|
|
tcg_gen_mov_i32(REG(B11_8), addr); /* modify register status */
|
2008-09-01 17:09:21 +04:00
|
|
|
tcg_temp_free(addr);
|
|
|
|
}
|
2006-04-28 01:07:38 +04:00
|
|
|
return;
|
|
|
|
case 0x2005: /* mov.w Rm,@-Rn */
|
2008-09-01 17:09:21 +04:00
|
|
|
{
|
2008-11-17 17:43:54 +03:00
|
|
|
TCGv addr = tcg_temp_new();
|
2008-09-01 17:09:21 +04:00
|
|
|
tcg_gen_subi_i32(addr, REG(B11_8), 2);
|
2013-12-11 10:56:47 +04:00
|
|
|
tcg_gen_qemu_st_i32(REG(B7_4), addr, ctx->memidx, MO_TEUW);
|
2010-01-31 03:07:25 +03:00
|
|
|
tcg_gen_mov_i32(REG(B11_8), addr);
|
2008-09-01 17:09:21 +04:00
|
|
|
tcg_temp_free(addr);
|
|
|
|
}
|
2006-04-28 01:07:38 +04:00
|
|
|
return;
|
|
|
|
case 0x2006: /* mov.l Rm,@-Rn */
|
2008-09-01 17:09:21 +04:00
|
|
|
{
|
2008-11-17 17:43:54 +03:00
|
|
|
TCGv addr = tcg_temp_new();
|
2008-09-01 17:09:21 +04:00
|
|
|
tcg_gen_subi_i32(addr, REG(B11_8), 4);
|
2013-12-11 10:56:47 +04:00
|
|
|
tcg_gen_qemu_st_i32(REG(B7_4), addr, ctx->memidx, MO_TEUL);
|
2010-01-31 03:07:25 +03:00
|
|
|
tcg_gen_mov_i32(REG(B11_8), addr);
|
2008-09-01 17:09:21 +04:00
|
|
|
}
|
2006-04-28 01:07:38 +04:00
|
|
|
return;
|
2006-06-14 19:02:05 +04:00
|
|
|
case 0x6004: /* mov.b @Rm+,Rn */
|
2013-12-11 10:56:47 +04:00
|
|
|
tcg_gen_qemu_ld_i32(REG(B11_8), REG(B7_4), ctx->memidx, MO_SB);
|
SH4, fix several instructions
fix instruction code for frchg, fschg, ocbp.
fix addressing mode handling for @Rn+, @-Rn, @(disp,gbr).
fix operation for div0s.
fix comments for mov imm, add imm, @(r0+,gbr), mac.l @Rm+,@Rn+.
fix ldb to ldub for or/tst/xor.b #imm,@(r0,gbr).
add fmov extended operations.
add fcmp/eq, fcmp/gt, fneg, fabs, fsqrt, fcnvsd, fcnvds.
(Takashi Yoshii)
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@4040 c046a42c-6fe2-441c-8c8c-71466251a162
2008-03-12 02:22:37 +03:00
|
|
|
if ( B11_8 != B7_4 )
|
2008-09-01 17:09:14 +04:00
|
|
|
tcg_gen_addi_i32(REG(B7_4), REG(B7_4), 1);
|
2006-04-28 01:07:38 +04:00
|
|
|
return;
|
|
|
|
case 0x6005: /* mov.w @Rm+,Rn */
|
2013-12-11 10:56:47 +04:00
|
|
|
tcg_gen_qemu_ld_i32(REG(B11_8), REG(B7_4), ctx->memidx, MO_TESW);
|
SH4, fix several instructions
fix instruction code for frchg, fschg, ocbp.
fix addressing mode handling for @Rn+, @-Rn, @(disp,gbr).
fix operation for div0s.
fix comments for mov imm, add imm, @(r0+,gbr), mac.l @Rm+,@Rn+.
fix ldb to ldub for or/tst/xor.b #imm,@(r0,gbr).
add fmov extended operations.
add fcmp/eq, fcmp/gt, fneg, fabs, fsqrt, fcnvsd, fcnvds.
(Takashi Yoshii)
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@4040 c046a42c-6fe2-441c-8c8c-71466251a162
2008-03-12 02:22:37 +03:00
|
|
|
if ( B11_8 != B7_4 )
|
2008-09-01 17:09:14 +04:00
|
|
|
tcg_gen_addi_i32(REG(B7_4), REG(B7_4), 2);
|
2006-04-28 01:07:38 +04:00
|
|
|
return;
|
|
|
|
case 0x6006: /* mov.l @Rm+,Rn */
|
2013-12-11 10:56:47 +04:00
|
|
|
tcg_gen_qemu_ld_i32(REG(B11_8), REG(B7_4), ctx->memidx, MO_TESL);
|
SH4, fix several instructions
fix instruction code for frchg, fschg, ocbp.
fix addressing mode handling for @Rn+, @-Rn, @(disp,gbr).
fix operation for div0s.
fix comments for mov imm, add imm, @(r0+,gbr), mac.l @Rm+,@Rn+.
fix ldb to ldub for or/tst/xor.b #imm,@(r0,gbr).
add fmov extended operations.
add fcmp/eq, fcmp/gt, fneg, fabs, fsqrt, fcnvsd, fcnvds.
(Takashi Yoshii)
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@4040 c046a42c-6fe2-441c-8c8c-71466251a162
2008-03-12 02:22:37 +03:00
|
|
|
if ( B11_8 != B7_4 )
|
2008-09-01 17:09:14 +04:00
|
|
|
tcg_gen_addi_i32(REG(B7_4), REG(B7_4), 4);
|
2006-04-28 01:07:38 +04:00
|
|
|
return;
|
|
|
|
case 0x0004: /* mov.b Rm,@(R0,Rn) */
|
2008-09-01 17:09:21 +04:00
|
|
|
{
|
2008-11-17 17:43:54 +03:00
|
|
|
TCGv addr = tcg_temp_new();
|
2008-09-01 17:09:21 +04:00
|
|
|
tcg_gen_add_i32(addr, REG(B11_8), REG(0));
|
2013-12-11 10:56:47 +04:00
|
|
|
tcg_gen_qemu_st_i32(REG(B7_4), addr, ctx->memidx, MO_UB);
|
2008-09-01 17:09:21 +04:00
|
|
|
tcg_temp_free(addr);
|
|
|
|
}
|
2006-04-28 01:07:38 +04:00
|
|
|
return;
|
|
|
|
case 0x0005: /* mov.w Rm,@(R0,Rn) */
|
2008-09-01 17:09:21 +04:00
|
|
|
{
|
2008-11-17 17:43:54 +03:00
|
|
|
TCGv addr = tcg_temp_new();
|
2008-09-01 17:09:21 +04:00
|
|
|
tcg_gen_add_i32(addr, REG(B11_8), REG(0));
|
2013-12-11 10:56:47 +04:00
|
|
|
tcg_gen_qemu_st_i32(REG(B7_4), addr, ctx->memidx, MO_TEUW);
|
2008-09-01 17:09:21 +04:00
|
|
|
tcg_temp_free(addr);
|
|
|
|
}
|
2006-04-28 01:07:38 +04:00
|
|
|
return;
|
|
|
|
case 0x0006: /* mov.l Rm,@(R0,Rn) */
|
2008-09-01 17:09:21 +04:00
|
|
|
{
|
2008-11-17 17:43:54 +03:00
|
|
|
TCGv addr = tcg_temp_new();
|
2008-09-01 17:09:21 +04:00
|
|
|
tcg_gen_add_i32(addr, REG(B11_8), REG(0));
|
2013-12-11 10:56:47 +04:00
|
|
|
tcg_gen_qemu_st_i32(REG(B7_4), addr, ctx->memidx, MO_TEUL);
|
2008-09-01 17:09:21 +04:00
|
|
|
tcg_temp_free(addr);
|
|
|
|
}
|
2006-04-28 01:07:38 +04:00
|
|
|
return;
|
|
|
|
case 0x000c: /* mov.b @(R0,Rm),Rn */
|
2008-09-01 17:09:21 +04:00
|
|
|
{
|
2008-11-17 17:43:54 +03:00
|
|
|
TCGv addr = tcg_temp_new();
|
2008-09-01 17:09:21 +04:00
|
|
|
tcg_gen_add_i32(addr, REG(B7_4), REG(0));
|
2013-12-11 10:56:47 +04:00
|
|
|
tcg_gen_qemu_ld_i32(REG(B11_8), addr, ctx->memidx, MO_SB);
|
2008-09-01 17:09:21 +04:00
|
|
|
tcg_temp_free(addr);
|
|
|
|
}
|
2006-04-28 01:07:38 +04:00
|
|
|
return;
|
|
|
|
case 0x000d: /* mov.w @(R0,Rm),Rn */
|
2008-09-01 17:09:21 +04:00
|
|
|
{
|
2008-11-17 17:43:54 +03:00
|
|
|
TCGv addr = tcg_temp_new();
|
2008-09-01 17:09:21 +04:00
|
|
|
tcg_gen_add_i32(addr, REG(B7_4), REG(0));
|
2013-12-11 10:56:47 +04:00
|
|
|
tcg_gen_qemu_ld_i32(REG(B11_8), addr, ctx->memidx, MO_TESW);
|
2008-09-01 17:09:21 +04:00
|
|
|
tcg_temp_free(addr);
|
|
|
|
}
|
2006-04-28 01:07:38 +04:00
|
|
|
return;
|
|
|
|
case 0x000e: /* mov.l @(R0,Rm),Rn */
|
2008-09-01 17:09:21 +04:00
|
|
|
{
|
2008-11-17 17:43:54 +03:00
|
|
|
TCGv addr = tcg_temp_new();
|
2008-09-01 17:09:21 +04:00
|
|
|
tcg_gen_add_i32(addr, REG(B7_4), REG(0));
|
2013-12-11 10:56:47 +04:00
|
|
|
tcg_gen_qemu_ld_i32(REG(B11_8), addr, ctx->memidx, MO_TESL);
|
2008-09-01 17:09:21 +04:00
|
|
|
tcg_temp_free(addr);
|
|
|
|
}
|
2006-04-28 01:07:38 +04:00
|
|
|
return;
|
|
|
|
case 0x6008: /* swap.b Rm,Rn */
|
2008-09-01 17:09:21 +04:00
|
|
|
{
|
2015-07-05 18:05:08 +03:00
|
|
|
TCGv low = tcg_temp_new();;
|
2010-01-31 03:07:25 +03:00
|
|
|
tcg_gen_ext16u_i32(low, REG(B7_4));
|
|
|
|
tcg_gen_bswap16_i32(low, low);
|
2015-07-05 18:05:08 +03:00
|
|
|
tcg_gen_deposit_i32(REG(B11_8), REG(B7_4), low, 0, 16);
|
2008-09-01 17:09:21 +04:00
|
|
|
tcg_temp_free(low);
|
|
|
|
}
|
2006-04-28 01:07:38 +04:00
|
|
|
return;
|
|
|
|
case 0x6009: /* swap.w Rm,Rn */
|
2012-09-16 15:12:20 +04:00
|
|
|
tcg_gen_rotli_i32(REG(B11_8), REG(B7_4), 16);
|
2006-04-28 01:07:38 +04:00
|
|
|
return;
|
|
|
|
case 0x200d: /* xtrct Rm,Rn */
|
2008-09-01 17:09:21 +04:00
|
|
|
{
|
|
|
|
TCGv high, low;
|
2008-11-17 17:43:54 +03:00
|
|
|
high = tcg_temp_new();
|
2010-01-31 03:07:25 +03:00
|
|
|
tcg_gen_shli_i32(high, REG(B7_4), 16);
|
2008-11-17 17:43:54 +03:00
|
|
|
low = tcg_temp_new();
|
2008-09-01 17:09:21 +04:00
|
|
|
tcg_gen_shri_i32(low, REG(B11_8), 16);
|
|
|
|
tcg_gen_or_i32(REG(B11_8), high, low);
|
|
|
|
tcg_temp_free(low);
|
|
|
|
tcg_temp_free(high);
|
|
|
|
}
|
2006-04-28 01:07:38 +04:00
|
|
|
return;
|
|
|
|
case 0x300c: /* add Rm,Rn */
|
2008-09-01 17:09:14 +04:00
|
|
|
tcg_gen_add_i32(REG(B11_8), REG(B11_8), REG(B7_4));
|
2006-04-28 01:07:38 +04:00
|
|
|
return;
|
|
|
|
case 0x300e: /* addc Rm,Rn */
|
2012-09-16 15:12:20 +04:00
|
|
|
{
|
2015-05-25 02:28:56 +03:00
|
|
|
TCGv t0, t1;
|
2015-05-25 02:28:56 +03:00
|
|
|
t0 = tcg_const_tl(0);
|
2012-09-16 15:12:20 +04:00
|
|
|
t1 = tcg_temp_new();
|
2015-05-25 02:28:56 +03:00
|
|
|
tcg_gen_add2_i32(t1, cpu_sr_t, cpu_sr_t, t0, REG(B7_4), t0);
|
|
|
|
tcg_gen_add2_i32(REG(B11_8), cpu_sr_t,
|
|
|
|
REG(B11_8), t0, t1, cpu_sr_t);
|
2012-09-16 15:12:20 +04:00
|
|
|
tcg_temp_free(t0);
|
2015-05-25 02:28:56 +03:00
|
|
|
tcg_temp_free(t1);
|
2012-09-16 15:12:20 +04:00
|
|
|
}
|
2006-04-28 01:07:38 +04:00
|
|
|
return;
|
|
|
|
case 0x300f: /* addv Rm,Rn */
|
2012-09-16 15:12:20 +04:00
|
|
|
{
|
|
|
|
TCGv t0, t1, t2;
|
|
|
|
t0 = tcg_temp_new();
|
|
|
|
tcg_gen_add_i32(t0, REG(B7_4), REG(B11_8));
|
|
|
|
t1 = tcg_temp_new();
|
|
|
|
tcg_gen_xor_i32(t1, t0, REG(B11_8));
|
|
|
|
t2 = tcg_temp_new();
|
|
|
|
tcg_gen_xor_i32(t2, REG(B7_4), REG(B11_8));
|
2015-05-25 02:28:56 +03:00
|
|
|
tcg_gen_andc_i32(cpu_sr_t, t1, t2);
|
2012-09-16 15:12:20 +04:00
|
|
|
tcg_temp_free(t2);
|
2015-05-25 02:28:56 +03:00
|
|
|
tcg_gen_shri_i32(cpu_sr_t, cpu_sr_t, 31);
|
2012-09-16 15:12:20 +04:00
|
|
|
tcg_temp_free(t1);
|
|
|
|
tcg_gen_mov_i32(REG(B7_4), t0);
|
|
|
|
tcg_temp_free(t0);
|
|
|
|
}
|
2006-04-28 01:07:38 +04:00
|
|
|
return;
|
|
|
|
case 0x2009: /* and Rm,Rn */
|
2008-09-01 17:09:14 +04:00
|
|
|
tcg_gen_and_i32(REG(B11_8), REG(B11_8), REG(B7_4));
|
2006-04-28 01:07:38 +04:00
|
|
|
return;
|
|
|
|
case 0x3000: /* cmp/eq Rm,Rn */
|
2015-05-25 02:28:56 +03:00
|
|
|
tcg_gen_setcond_i32(TCG_COND_EQ, cpu_sr_t, REG(B11_8), REG(B7_4));
|
2006-04-28 01:07:38 +04:00
|
|
|
return;
|
|
|
|
case 0x3003: /* cmp/ge Rm,Rn */
|
2015-05-25 02:28:56 +03:00
|
|
|
tcg_gen_setcond_i32(TCG_COND_GE, cpu_sr_t, REG(B11_8), REG(B7_4));
|
2006-04-28 01:07:38 +04:00
|
|
|
return;
|
|
|
|
case 0x3007: /* cmp/gt Rm,Rn */
|
2015-05-25 02:28:56 +03:00
|
|
|
tcg_gen_setcond_i32(TCG_COND_GT, cpu_sr_t, REG(B11_8), REG(B7_4));
|
2006-04-28 01:07:38 +04:00
|
|
|
return;
|
|
|
|
case 0x3006: /* cmp/hi Rm,Rn */
|
2015-05-25 02:28:56 +03:00
|
|
|
tcg_gen_setcond_i32(TCG_COND_GTU, cpu_sr_t, REG(B11_8), REG(B7_4));
|
2006-04-28 01:07:38 +04:00
|
|
|
return;
|
|
|
|
case 0x3002: /* cmp/hs Rm,Rn */
|
2015-05-25 02:28:56 +03:00
|
|
|
tcg_gen_setcond_i32(TCG_COND_GEU, cpu_sr_t, REG(B11_8), REG(B7_4));
|
2006-04-28 01:07:38 +04:00
|
|
|
return;
|
|
|
|
case 0x200c: /* cmp/str Rm,Rn */
|
2008-09-01 17:09:06 +04:00
|
|
|
{
|
2011-01-14 22:39:18 +03:00
|
|
|
TCGv cmp1 = tcg_temp_new();
|
|
|
|
TCGv cmp2 = tcg_temp_new();
|
2015-07-05 19:50:09 +03:00
|
|
|
tcg_gen_xor_i32(cmp2, REG(B7_4), REG(B11_8));
|
|
|
|
tcg_gen_subi_i32(cmp1, cmp2, 0x01010101);
|
|
|
|
tcg_gen_andc_i32(cmp1, cmp1, cmp2);
|
|
|
|
tcg_gen_andi_i32(cmp1, cmp1, 0x80808080);
|
|
|
|
tcg_gen_setcondi_i32(TCG_COND_NE, cpu_sr_t, cmp1, 0);
|
2008-09-01 17:09:21 +04:00
|
|
|
tcg_temp_free(cmp2);
|
|
|
|
tcg_temp_free(cmp1);
|
2008-09-01 17:09:06 +04:00
|
|
|
}
|
2006-04-28 01:07:38 +04:00
|
|
|
return;
|
|
|
|
case 0x2007: /* div0s Rm,Rn */
|
2015-05-25 02:28:56 +03:00
|
|
|
tcg_gen_shri_i32(cpu_sr_q, REG(B11_8), 31); /* SR_Q */
|
|
|
|
tcg_gen_shri_i32(cpu_sr_m, REG(B7_4), 31); /* SR_M */
|
|
|
|
tcg_gen_xor_i32(cpu_sr_t, cpu_sr_q, cpu_sr_m); /* SR_T */
|
2006-04-28 01:07:38 +04:00
|
|
|
return;
|
|
|
|
case 0x3004: /* div1 Rm,Rn */
|
2015-05-25 02:28:56 +03:00
|
|
|
{
|
|
|
|
TCGv t0 = tcg_temp_new();
|
|
|
|
TCGv t1 = tcg_temp_new();
|
|
|
|
TCGv t2 = tcg_temp_new();
|
|
|
|
TCGv zero = tcg_const_i32(0);
|
|
|
|
|
|
|
|
/* shift left arg1, saving the bit being pushed out and inserting
|
|
|
|
T on the right */
|
|
|
|
tcg_gen_shri_i32(t0, REG(B11_8), 31);
|
|
|
|
tcg_gen_shli_i32(REG(B11_8), REG(B11_8), 1);
|
|
|
|
tcg_gen_or_i32(REG(B11_8), REG(B11_8), cpu_sr_t);
|
|
|
|
|
|
|
|
/* Add or subtract arg0 from arg1 depending if Q == M. To avoid
|
|
|
|
using 64-bit temps, we compute arg0's high part from q ^ m, so
|
|
|
|
that it is 0x00000000 when adding the value or 0xffffffff when
|
|
|
|
subtracting it. */
|
|
|
|
tcg_gen_xor_i32(t1, cpu_sr_q, cpu_sr_m);
|
|
|
|
tcg_gen_subi_i32(t1, t1, 1);
|
|
|
|
tcg_gen_neg_i32(t2, REG(B7_4));
|
|
|
|
tcg_gen_movcond_i32(TCG_COND_EQ, t2, t1, zero, REG(B7_4), t2);
|
|
|
|
tcg_gen_add2_i32(REG(B11_8), t1, REG(B11_8), zero, t2, t1);
|
|
|
|
|
|
|
|
/* compute T and Q depending on carry */
|
|
|
|
tcg_gen_andi_i32(t1, t1, 1);
|
|
|
|
tcg_gen_xor_i32(t1, t1, t0);
|
|
|
|
tcg_gen_xori_i32(cpu_sr_t, t1, 1);
|
|
|
|
tcg_gen_xor_i32(cpu_sr_q, cpu_sr_m, t1);
|
|
|
|
|
|
|
|
tcg_temp_free(zero);
|
|
|
|
tcg_temp_free(t2);
|
|
|
|
tcg_temp_free(t1);
|
|
|
|
tcg_temp_free(t0);
|
|
|
|
}
|
2006-04-28 01:07:38 +04:00
|
|
|
return;
|
|
|
|
case 0x300d: /* dmuls.l Rm,Rn */
|
2013-02-20 11:52:23 +04:00
|
|
|
tcg_gen_muls2_i32(cpu_macl, cpu_mach, REG(B7_4), REG(B11_8));
|
2006-04-28 01:07:38 +04:00
|
|
|
return;
|
|
|
|
case 0x3005: /* dmulu.l Rm,Rn */
|
2013-02-20 11:52:23 +04:00
|
|
|
tcg_gen_mulu2_i32(cpu_macl, cpu_mach, REG(B7_4), REG(B11_8));
|
2006-04-28 01:07:38 +04:00
|
|
|
return;
|
|
|
|
case 0x600e: /* exts.b Rm,Rn */
|
2008-09-01 17:09:14 +04:00
|
|
|
tcg_gen_ext8s_i32(REG(B11_8), REG(B7_4));
|
2006-04-28 01:07:38 +04:00
|
|
|
return;
|
|
|
|
case 0x600f: /* exts.w Rm,Rn */
|
2008-09-01 17:09:14 +04:00
|
|
|
tcg_gen_ext16s_i32(REG(B11_8), REG(B7_4));
|
2006-04-28 01:07:38 +04:00
|
|
|
return;
|
|
|
|
case 0x600c: /* extu.b Rm,Rn */
|
2008-09-01 17:09:14 +04:00
|
|
|
tcg_gen_ext8u_i32(REG(B11_8), REG(B7_4));
|
2006-04-28 01:07:38 +04:00
|
|
|
return;
|
|
|
|
case 0x600d: /* extu.w Rm,Rn */
|
2008-09-01 17:09:14 +04:00
|
|
|
tcg_gen_ext16u_i32(REG(B11_8), REG(B7_4));
|
2006-04-28 01:07:38 +04:00
|
|
|
return;
|
SH4, fix several instructions
fix instruction code for frchg, fschg, ocbp.
fix addressing mode handling for @Rn+, @-Rn, @(disp,gbr).
fix operation for div0s.
fix comments for mov imm, add imm, @(r0+,gbr), mac.l @Rm+,@Rn+.
fix ldb to ldub for or/tst/xor.b #imm,@(r0,gbr).
add fmov extended operations.
add fcmp/eq, fcmp/gt, fneg, fabs, fsqrt, fcnvsd, fcnvds.
(Takashi Yoshii)
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@4040 c046a42c-6fe2-441c-8c8c-71466251a162
2008-03-12 02:22:37 +03:00
|
|
|
case 0x000f: /* mac.l @Rm+,@Rn+ */
|
2008-09-01 17:09:21 +04:00
|
|
|
{
|
|
|
|
TCGv arg0, arg1;
|
2008-11-17 17:43:54 +03:00
|
|
|
arg0 = tcg_temp_new();
|
2013-12-11 10:56:47 +04:00
|
|
|
tcg_gen_qemu_ld_i32(arg0, REG(B7_4), ctx->memidx, MO_TESL);
|
2008-11-17 17:43:54 +03:00
|
|
|
arg1 = tcg_temp_new();
|
2013-12-11 10:56:47 +04:00
|
|
|
tcg_gen_qemu_ld_i32(arg1, REG(B11_8), ctx->memidx, MO_TESL);
|
2012-09-02 14:37:06 +04:00
|
|
|
gen_helper_macl(cpu_env, arg0, arg1);
|
2008-09-01 17:09:21 +04:00
|
|
|
tcg_temp_free(arg1);
|
|
|
|
tcg_temp_free(arg0);
|
|
|
|
tcg_gen_addi_i32(REG(B7_4), REG(B7_4), 4);
|
|
|
|
tcg_gen_addi_i32(REG(B11_8), REG(B11_8), 4);
|
|
|
|
}
|
2006-04-28 01:07:38 +04:00
|
|
|
return;
|
|
|
|
case 0x400f: /* mac.w @Rm+,@Rn+ */
|
2008-09-01 17:09:21 +04:00
|
|
|
{
|
|
|
|
TCGv arg0, arg1;
|
2008-11-17 17:43:54 +03:00
|
|
|
arg0 = tcg_temp_new();
|
2013-12-11 10:56:47 +04:00
|
|
|
tcg_gen_qemu_ld_i32(arg0, REG(B7_4), ctx->memidx, MO_TESL);
|
2008-11-17 17:43:54 +03:00
|
|
|
arg1 = tcg_temp_new();
|
2013-12-11 10:56:47 +04:00
|
|
|
tcg_gen_qemu_ld_i32(arg1, REG(B11_8), ctx->memidx, MO_TESL);
|
2012-09-02 14:37:06 +04:00
|
|
|
gen_helper_macw(cpu_env, arg0, arg1);
|
2008-09-01 17:09:21 +04:00
|
|
|
tcg_temp_free(arg1);
|
|
|
|
tcg_temp_free(arg0);
|
|
|
|
tcg_gen_addi_i32(REG(B11_8), REG(B11_8), 2);
|
|
|
|
tcg_gen_addi_i32(REG(B7_4), REG(B7_4), 2);
|
|
|
|
}
|
2006-04-28 01:07:38 +04:00
|
|
|
return;
|
|
|
|
case 0x0007: /* mul.l Rm,Rn */
|
2008-09-01 17:09:14 +04:00
|
|
|
tcg_gen_mul_i32(cpu_macl, REG(B7_4), REG(B11_8));
|
2006-04-28 01:07:38 +04:00
|
|
|
return;
|
|
|
|
case 0x200f: /* muls.w Rm,Rn */
|
2008-09-01 17:09:21 +04:00
|
|
|
{
|
|
|
|
TCGv arg0, arg1;
|
2008-11-17 17:43:54 +03:00
|
|
|
arg0 = tcg_temp_new();
|
2008-09-01 17:09:21 +04:00
|
|
|
tcg_gen_ext16s_i32(arg0, REG(B7_4));
|
2008-11-17 17:43:54 +03:00
|
|
|
arg1 = tcg_temp_new();
|
2008-09-01 17:09:21 +04:00
|
|
|
tcg_gen_ext16s_i32(arg1, REG(B11_8));
|
|
|
|
tcg_gen_mul_i32(cpu_macl, arg0, arg1);
|
|
|
|
tcg_temp_free(arg1);
|
|
|
|
tcg_temp_free(arg0);
|
|
|
|
}
|
2006-04-28 01:07:38 +04:00
|
|
|
return;
|
|
|
|
case 0x200e: /* mulu.w Rm,Rn */
|
2008-09-01 17:09:21 +04:00
|
|
|
{
|
|
|
|
TCGv arg0, arg1;
|
2008-11-17 17:43:54 +03:00
|
|
|
arg0 = tcg_temp_new();
|
2008-09-01 17:09:21 +04:00
|
|
|
tcg_gen_ext16u_i32(arg0, REG(B7_4));
|
2008-11-17 17:43:54 +03:00
|
|
|
arg1 = tcg_temp_new();
|
2008-09-01 17:09:21 +04:00
|
|
|
tcg_gen_ext16u_i32(arg1, REG(B11_8));
|
|
|
|
tcg_gen_mul_i32(cpu_macl, arg0, arg1);
|
|
|
|
tcg_temp_free(arg1);
|
|
|
|
tcg_temp_free(arg0);
|
|
|
|
}
|
2006-04-28 01:07:38 +04:00
|
|
|
return;
|
|
|
|
case 0x600b: /* neg Rm,Rn */
|
2008-09-01 17:09:14 +04:00
|
|
|
tcg_gen_neg_i32(REG(B11_8), REG(B7_4));
|
2006-04-28 01:07:38 +04:00
|
|
|
return;
|
|
|
|
case 0x600a: /* negc Rm,Rn */
|
2011-01-13 10:20:39 +03:00
|
|
|
{
|
2015-05-25 02:28:56 +03:00
|
|
|
TCGv t0 = tcg_const_i32(0);
|
|
|
|
tcg_gen_add2_i32(REG(B11_8), cpu_sr_t,
|
|
|
|
REG(B7_4), t0, cpu_sr_t, t0);
|
|
|
|
tcg_gen_sub2_i32(REG(B11_8), cpu_sr_t,
|
|
|
|
t0, t0, REG(B11_8), cpu_sr_t);
|
|
|
|
tcg_gen_andi_i32(cpu_sr_t, cpu_sr_t, 1);
|
2011-01-13 10:20:39 +03:00
|
|
|
tcg_temp_free(t0);
|
|
|
|
}
|
2006-04-28 01:07:38 +04:00
|
|
|
return;
|
|
|
|
case 0x6007: /* not Rm,Rn */
|
2008-09-01 17:09:14 +04:00
|
|
|
tcg_gen_not_i32(REG(B11_8), REG(B7_4));
|
2006-04-28 01:07:38 +04:00
|
|
|
return;
|
|
|
|
case 0x200b: /* or Rm,Rn */
|
2008-09-01 17:09:14 +04:00
|
|
|
tcg_gen_or_i32(REG(B11_8), REG(B11_8), REG(B7_4));
|
2006-04-28 01:07:38 +04:00
|
|
|
return;
|
|
|
|
case 0x400c: /* shad Rm,Rn */
|
2008-09-01 17:09:06 +04:00
|
|
|
{
|
2015-07-05 23:39:03 +03:00
|
|
|
TCGv t0 = tcg_temp_new();
|
|
|
|
TCGv t1 = tcg_temp_new();
|
|
|
|
TCGv t2 = tcg_temp_new();
|
|
|
|
|
|
|
|
tcg_gen_andi_i32(t0, REG(B7_4), 0x1f);
|
|
|
|
|
|
|
|
/* positive case: shift to the left */
|
|
|
|
tcg_gen_shl_i32(t1, REG(B11_8), t0);
|
|
|
|
|
|
|
|
/* negative case: shift to the right in two steps to
|
|
|
|
correctly handle the -32 case */
|
|
|
|
tcg_gen_xori_i32(t0, t0, 0x1f);
|
|
|
|
tcg_gen_sar_i32(t2, REG(B11_8), t0);
|
|
|
|
tcg_gen_sari_i32(t2, t2, 1);
|
|
|
|
|
|
|
|
/* select between the two cases */
|
|
|
|
tcg_gen_movi_i32(t0, 0);
|
|
|
|
tcg_gen_movcond_i32(TCG_COND_GE, REG(B11_8), REG(B7_4), t0, t1, t2);
|
|
|
|
|
|
|
|
tcg_temp_free(t0);
|
|
|
|
tcg_temp_free(t1);
|
|
|
|
tcg_temp_free(t2);
|
2008-09-01 17:09:06 +04:00
|
|
|
}
|
2006-04-28 01:07:38 +04:00
|
|
|
return;
|
|
|
|
case 0x400d: /* shld Rm,Rn */
|
2008-09-01 17:09:06 +04:00
|
|
|
{
|
2015-07-05 23:37:18 +03:00
|
|
|
TCGv t0 = tcg_temp_new();
|
|
|
|
TCGv t1 = tcg_temp_new();
|
|
|
|
TCGv t2 = tcg_temp_new();
|
|
|
|
|
|
|
|
tcg_gen_andi_i32(t0, REG(B7_4), 0x1f);
|
|
|
|
|
|
|
|
/* positive case: shift to the left */
|
|
|
|
tcg_gen_shl_i32(t1, REG(B11_8), t0);
|
|
|
|
|
|
|
|
/* negative case: shift to the right in two steps to
|
|
|
|
correctly handle the -32 case */
|
|
|
|
tcg_gen_xori_i32(t0, t0, 0x1f);
|
|
|
|
tcg_gen_shr_i32(t2, REG(B11_8), t0);
|
|
|
|
tcg_gen_shri_i32(t2, t2, 1);
|
|
|
|
|
|
|
|
/* select between the two cases */
|
|
|
|
tcg_gen_movi_i32(t0, 0);
|
|
|
|
tcg_gen_movcond_i32(TCG_COND_GE, REG(B11_8), REG(B7_4), t0, t1, t2);
|
|
|
|
|
|
|
|
tcg_temp_free(t0);
|
|
|
|
tcg_temp_free(t1);
|
|
|
|
tcg_temp_free(t2);
|
2008-09-01 17:09:06 +04:00
|
|
|
}
|
2006-04-28 01:07:38 +04:00
|
|
|
return;
|
|
|
|
case 0x3008: /* sub Rm,Rn */
|
2008-09-01 17:09:14 +04:00
|
|
|
tcg_gen_sub_i32(REG(B11_8), REG(B11_8), REG(B7_4));
|
2006-04-28 01:07:38 +04:00
|
|
|
return;
|
|
|
|
case 0x300a: /* subc Rm,Rn */
|
2012-09-16 15:12:20 +04:00
|
|
|
{
|
2015-05-25 02:28:56 +03:00
|
|
|
TCGv t0, t1;
|
|
|
|
t0 = tcg_const_tl(0);
|
2012-09-16 15:12:20 +04:00
|
|
|
t1 = tcg_temp_new();
|
2015-05-25 02:28:56 +03:00
|
|
|
tcg_gen_add2_i32(t1, cpu_sr_t, cpu_sr_t, t0, REG(B7_4), t0);
|
|
|
|
tcg_gen_sub2_i32(REG(B11_8), cpu_sr_t,
|
|
|
|
REG(B11_8), t0, t1, cpu_sr_t);
|
|
|
|
tcg_gen_andi_i32(cpu_sr_t, cpu_sr_t, 1);
|
2012-09-16 15:12:20 +04:00
|
|
|
tcg_temp_free(t0);
|
2015-05-25 02:28:56 +03:00
|
|
|
tcg_temp_free(t1);
|
2012-09-16 15:12:20 +04:00
|
|
|
}
|
2006-04-28 01:07:38 +04:00
|
|
|
return;
|
|
|
|
case 0x300b: /* subv Rm,Rn */
|
2012-09-16 15:12:20 +04:00
|
|
|
{
|
|
|
|
TCGv t0, t1, t2;
|
|
|
|
t0 = tcg_temp_new();
|
|
|
|
tcg_gen_sub_i32(t0, REG(B11_8), REG(B7_4));
|
|
|
|
t1 = tcg_temp_new();
|
|
|
|
tcg_gen_xor_i32(t1, t0, REG(B7_4));
|
|
|
|
t2 = tcg_temp_new();
|
|
|
|
tcg_gen_xor_i32(t2, REG(B11_8), REG(B7_4));
|
|
|
|
tcg_gen_and_i32(t1, t1, t2);
|
|
|
|
tcg_temp_free(t2);
|
2015-05-25 02:28:56 +03:00
|
|
|
tcg_gen_shri_i32(cpu_sr_t, t1, 31);
|
2012-09-16 15:12:20 +04:00
|
|
|
tcg_temp_free(t1);
|
|
|
|
tcg_gen_mov_i32(REG(B11_8), t0);
|
|
|
|
tcg_temp_free(t0);
|
|
|
|
}
|
2006-04-28 01:07:38 +04:00
|
|
|
return;
|
|
|
|
case 0x2008: /* tst Rm,Rn */
|
2008-09-01 17:09:21 +04:00
|
|
|
{
|
2008-11-17 17:43:54 +03:00
|
|
|
TCGv val = tcg_temp_new();
|
2008-09-01 17:09:21 +04:00
|
|
|
tcg_gen_and_i32(val, REG(B7_4), REG(B11_8));
|
2015-05-25 02:28:56 +03:00
|
|
|
tcg_gen_setcondi_i32(TCG_COND_EQ, cpu_sr_t, val, 0);
|
2008-09-01 17:09:21 +04:00
|
|
|
tcg_temp_free(val);
|
|
|
|
}
|
2006-04-28 01:07:38 +04:00
|
|
|
return;
|
|
|
|
case 0x200a: /* xor Rm,Rn */
|
2008-09-01 17:09:14 +04:00
|
|
|
tcg_gen_xor_i32(REG(B11_8), REG(B11_8), REG(B7_4));
|
2006-04-28 01:07:38 +04:00
|
|
|
return;
|
2007-06-22 15:44:41 +04:00
|
|
|
case 0xf00c: /* fmov {F,D,X}Rm,{F,D,X}Rn - FPSCR: Nothing */
|
2008-12-10 20:31:43 +03:00
|
|
|
CHECK_FPU_ENABLED
|
2017-05-02 00:20:43 +03:00
|
|
|
if (ctx->tbflags & FPSCR_SZ) {
|
2017-07-18 23:02:42 +03:00
|
|
|
int xsrc = XHACK(B7_4);
|
|
|
|
int xdst = XHACK(B11_8);
|
|
|
|
tcg_gen_mov_i32(FREG(xdst), FREG(xsrc));
|
|
|
|
tcg_gen_mov_i32(FREG(xdst + 1), FREG(xsrc + 1));
|
2006-06-14 19:02:05 +04:00
|
|
|
} else {
|
2017-07-18 23:02:36 +03:00
|
|
|
tcg_gen_mov_i32(FREG(B11_8), FREG(B7_4));
|
2006-06-14 19:02:05 +04:00
|
|
|
}
|
|
|
|
return;
|
2007-06-22 15:44:41 +04:00
|
|
|
case 0xf00a: /* fmov {F,D,X}Rm,@Rn - FPSCR: Nothing */
|
2008-12-10 20:31:43 +03:00
|
|
|
CHECK_FPU_ENABLED
|
2017-05-02 00:20:43 +03:00
|
|
|
if (ctx->tbflags & FPSCR_SZ) {
|
2017-07-18 23:02:41 +03:00
|
|
|
TCGv_i64 fp = tcg_temp_new_i64();
|
|
|
|
gen_load_fpr64(ctx, fp, XHACK(B7_4));
|
|
|
|
tcg_gen_qemu_st_i64(fp, REG(B11_8), ctx->memidx, MO_TEQ);
|
|
|
|
tcg_temp_free_i64(fp);
|
2006-06-14 19:02:05 +04:00
|
|
|
} else {
|
2017-07-18 23:02:36 +03:00
|
|
|
tcg_gen_qemu_st_i32(FREG(B7_4), REG(B11_8), ctx->memidx, MO_TEUL);
|
2006-06-14 19:02:05 +04:00
|
|
|
}
|
|
|
|
return;
|
2007-06-22 15:44:41 +04:00
|
|
|
case 0xf008: /* fmov @Rm,{F,D,X}Rn - FPSCR: Nothing */
|
2008-12-10 20:31:43 +03:00
|
|
|
CHECK_FPU_ENABLED
|
2017-05-02 00:20:43 +03:00
|
|
|
if (ctx->tbflags & FPSCR_SZ) {
|
2017-07-18 23:02:41 +03:00
|
|
|
TCGv_i64 fp = tcg_temp_new_i64();
|
|
|
|
tcg_gen_qemu_ld_i64(fp, REG(B7_4), ctx->memidx, MO_TEQ);
|
|
|
|
gen_store_fpr64(ctx, fp, XHACK(B11_8));
|
|
|
|
tcg_temp_free_i64(fp);
|
2006-06-14 19:02:05 +04:00
|
|
|
} else {
|
2017-07-18 23:02:36 +03:00
|
|
|
tcg_gen_qemu_ld_i32(FREG(B11_8), REG(B7_4), ctx->memidx, MO_TEUL);
|
2006-06-14 19:02:05 +04:00
|
|
|
}
|
|
|
|
return;
|
2007-06-22 15:44:41 +04:00
|
|
|
case 0xf009: /* fmov @Rm+,{F,D,X}Rn - FPSCR: Nothing */
|
2008-12-10 20:31:43 +03:00
|
|
|
CHECK_FPU_ENABLED
|
2017-05-02 00:20:43 +03:00
|
|
|
if (ctx->tbflags & FPSCR_SZ) {
|
2017-07-18 23:02:41 +03:00
|
|
|
TCGv_i64 fp = tcg_temp_new_i64();
|
|
|
|
tcg_gen_qemu_ld_i64(fp, REG(B7_4), ctx->memidx, MO_TEQ);
|
|
|
|
gen_store_fpr64(ctx, fp, XHACK(B11_8));
|
|
|
|
tcg_temp_free_i64(fp);
|
|
|
|
tcg_gen_addi_i32(REG(B7_4), REG(B7_4), 8);
|
2006-06-14 19:02:05 +04:00
|
|
|
} else {
|
2017-07-18 23:02:36 +03:00
|
|
|
tcg_gen_qemu_ld_i32(FREG(B11_8), REG(B7_4), ctx->memidx, MO_TEUL);
|
2008-09-02 02:11:56 +04:00
|
|
|
tcg_gen_addi_i32(REG(B7_4), REG(B7_4), 4);
|
2006-06-14 19:02:05 +04:00
|
|
|
}
|
|
|
|
return;
|
2007-06-22 15:44:41 +04:00
|
|
|
case 0xf00b: /* fmov {F,D,X}Rm,@-Rn - FPSCR: Nothing */
|
2008-12-10 20:31:43 +03:00
|
|
|
CHECK_FPU_ENABLED
|
2017-07-18 23:02:41 +03:00
|
|
|
{
|
|
|
|
TCGv addr = tcg_temp_new_i32();
|
|
|
|
if (ctx->tbflags & FPSCR_SZ) {
|
|
|
|
TCGv_i64 fp = tcg_temp_new_i64();
|
|
|
|
gen_load_fpr64(ctx, fp, XHACK(B7_4));
|
|
|
|
tcg_gen_subi_i32(addr, REG(B11_8), 8);
|
|
|
|
tcg_gen_qemu_st_i64(fp, addr, ctx->memidx, MO_TEQ);
|
|
|
|
tcg_temp_free_i64(fp);
|
|
|
|
} else {
|
|
|
|
tcg_gen_subi_i32(addr, REG(B11_8), 4);
|
|
|
|
tcg_gen_qemu_st_i32(FREG(B7_4), addr, ctx->memidx, MO_TEUL);
|
|
|
|
}
|
|
|
|
tcg_gen_mov_i32(REG(B11_8), addr);
|
|
|
|
tcg_temp_free(addr);
|
|
|
|
}
|
2006-06-14 19:02:05 +04:00
|
|
|
return;
|
2007-06-22 15:44:41 +04:00
|
|
|
case 0xf006: /* fmov @(R0,Rm),{F,D,X}Rm - FPSCR: Nothing */
|
2008-12-10 20:31:43 +03:00
|
|
|
CHECK_FPU_ENABLED
|
2008-09-02 02:11:56 +04:00
|
|
|
{
|
2008-11-17 17:43:54 +03:00
|
|
|
TCGv addr = tcg_temp_new_i32();
|
2008-09-02 02:11:56 +04:00
|
|
|
tcg_gen_add_i32(addr, REG(B7_4), REG(0));
|
2017-05-02 00:20:43 +03:00
|
|
|
if (ctx->tbflags & FPSCR_SZ) {
|
2017-07-18 23:02:41 +03:00
|
|
|
TCGv_i64 fp = tcg_temp_new_i64();
|
|
|
|
tcg_gen_qemu_ld_i64(fp, addr, ctx->memidx, MO_TEQ);
|
|
|
|
gen_store_fpr64(ctx, fp, XHACK(B11_8));
|
|
|
|
tcg_temp_free_i64(fp);
|
2008-09-02 02:11:56 +04:00
|
|
|
} else {
|
2017-07-18 23:02:36 +03:00
|
|
|
tcg_gen_qemu_ld_i32(FREG(B11_8), addr, ctx->memidx, MO_TEUL);
|
2008-09-02 02:11:56 +04:00
|
|
|
}
|
|
|
|
tcg_temp_free(addr);
|
2006-06-14 19:02:05 +04:00
|
|
|
}
|
|
|
|
return;
|
2007-06-22 15:44:41 +04:00
|
|
|
case 0xf007: /* fmov {F,D,X}Rn,@(R0,Rn) - FPSCR: Nothing */
|
2008-12-10 20:31:43 +03:00
|
|
|
CHECK_FPU_ENABLED
|
2008-09-02 02:11:56 +04:00
|
|
|
{
|
2008-11-17 17:43:54 +03:00
|
|
|
TCGv addr = tcg_temp_new();
|
2008-09-02 02:11:56 +04:00
|
|
|
tcg_gen_add_i32(addr, REG(B11_8), REG(0));
|
2017-05-02 00:20:43 +03:00
|
|
|
if (ctx->tbflags & FPSCR_SZ) {
|
2017-07-18 23:02:41 +03:00
|
|
|
TCGv_i64 fp = tcg_temp_new_i64();
|
|
|
|
gen_load_fpr64(ctx, fp, XHACK(B7_4));
|
|
|
|
tcg_gen_qemu_st_i64(fp, addr, ctx->memidx, MO_TEQ);
|
|
|
|
tcg_temp_free_i64(fp);
|
2008-09-02 02:11:56 +04:00
|
|
|
} else {
|
2017-07-18 23:02:36 +03:00
|
|
|
tcg_gen_qemu_st_i32(FREG(B7_4), addr, ctx->memidx, MO_TEUL);
|
2008-09-02 02:11:56 +04:00
|
|
|
}
|
|
|
|
tcg_temp_free(addr);
|
2006-06-14 19:02:05 +04:00
|
|
|
}
|
|
|
|
return;
|
2007-06-22 15:44:41 +04:00
|
|
|
case 0xf000: /* fadd Rm,Rn - FPSCR: R[PR,Enable.O/U/I]/W[Cause,Flag] */
|
|
|
|
case 0xf001: /* fsub Rm,Rn - FPSCR: R[PR,Enable.O/U/I]/W[Cause,Flag] */
|
|
|
|
case 0xf002: /* fmul Rm,Rn - FPSCR: R[PR,Enable.O/U/I]/W[Cause,Flag] */
|
|
|
|
case 0xf003: /* fdiv Rm,Rn - FPSCR: R[PR,Enable.O/U/I]/W[Cause,Flag] */
|
|
|
|
case 0xf004: /* fcmp/eq Rm,Rn - FPSCR: R[PR,Enable.V]/W[Cause,Flag] */
|
|
|
|
case 0xf005: /* fcmp/gt Rm,Rn - FPSCR: R[PR,Enable.V]/W[Cause,Flag] */
|
2008-09-02 02:11:56 +04:00
|
|
|
{
|
2008-12-10 20:31:43 +03:00
|
|
|
CHECK_FPU_ENABLED
|
2017-05-02 00:20:43 +03:00
|
|
|
if (ctx->tbflags & FPSCR_PR) {
|
2008-11-17 17:43:54 +03:00
|
|
|
TCGv_i64 fp0, fp1;
|
|
|
|
|
2017-07-18 23:02:46 +03:00
|
|
|
if (ctx->opcode & 0x0110) {
|
|
|
|
goto do_illegal;
|
|
|
|
}
|
2008-11-17 17:43:54 +03:00
|
|
|
fp0 = tcg_temp_new_i64();
|
|
|
|
fp1 = tcg_temp_new_i64();
|
2017-07-18 23:02:40 +03:00
|
|
|
gen_load_fpr64(ctx, fp0, B11_8);
|
|
|
|
gen_load_fpr64(ctx, fp1, B7_4);
|
2008-11-17 17:43:54 +03:00
|
|
|
switch (ctx->opcode & 0xf00f) {
|
|
|
|
case 0xf000: /* fadd Rm,Rn */
|
2012-09-02 14:37:06 +04:00
|
|
|
gen_helper_fadd_DT(fp0, cpu_env, fp0, fp1);
|
2008-11-17 17:43:54 +03:00
|
|
|
break;
|
|
|
|
case 0xf001: /* fsub Rm,Rn */
|
2012-09-02 14:37:06 +04:00
|
|
|
gen_helper_fsub_DT(fp0, cpu_env, fp0, fp1);
|
2008-11-17 17:43:54 +03:00
|
|
|
break;
|
|
|
|
case 0xf002: /* fmul Rm,Rn */
|
2012-09-02 14:37:06 +04:00
|
|
|
gen_helper_fmul_DT(fp0, cpu_env, fp0, fp1);
|
2008-11-17 17:43:54 +03:00
|
|
|
break;
|
|
|
|
case 0xf003: /* fdiv Rm,Rn */
|
2012-09-02 14:37:06 +04:00
|
|
|
gen_helper_fdiv_DT(fp0, cpu_env, fp0, fp1);
|
2008-11-17 17:43:54 +03:00
|
|
|
break;
|
|
|
|
case 0xf004: /* fcmp/eq Rm,Rn */
|
2017-07-02 22:31:25 +03:00
|
|
|
gen_helper_fcmp_eq_DT(cpu_sr_t, cpu_env, fp0, fp1);
|
2008-11-17 17:43:54 +03:00
|
|
|
return;
|
|
|
|
case 0xf005: /* fcmp/gt Rm,Rn */
|
2017-07-02 22:31:25 +03:00
|
|
|
gen_helper_fcmp_gt_DT(cpu_sr_t, cpu_env, fp0, fp1);
|
2008-11-17 17:43:54 +03:00
|
|
|
return;
|
|
|
|
}
|
2017-07-18 23:02:40 +03:00
|
|
|
gen_store_fpr64(ctx, fp0, B11_8);
|
2008-11-17 17:43:54 +03:00
|
|
|
tcg_temp_free_i64(fp0);
|
|
|
|
tcg_temp_free_i64(fp1);
|
|
|
|
} else {
|
|
|
|
switch (ctx->opcode & 0xf00f) {
|
|
|
|
case 0xf000: /* fadd Rm,Rn */
|
2017-07-18 23:02:36 +03:00
|
|
|
gen_helper_fadd_FT(FREG(B11_8), cpu_env,
|
|
|
|
FREG(B11_8), FREG(B7_4));
|
2008-11-17 17:43:54 +03:00
|
|
|
break;
|
|
|
|
case 0xf001: /* fsub Rm,Rn */
|
2017-07-18 23:02:36 +03:00
|
|
|
gen_helper_fsub_FT(FREG(B11_8), cpu_env,
|
|
|
|
FREG(B11_8), FREG(B7_4));
|
2008-11-17 17:43:54 +03:00
|
|
|
break;
|
|
|
|
case 0xf002: /* fmul Rm,Rn */
|
2017-07-18 23:02:36 +03:00
|
|
|
gen_helper_fmul_FT(FREG(B11_8), cpu_env,
|
|
|
|
FREG(B11_8), FREG(B7_4));
|
2008-11-17 17:43:54 +03:00
|
|
|
break;
|
|
|
|
case 0xf003: /* fdiv Rm,Rn */
|
2017-07-18 23:02:36 +03:00
|
|
|
gen_helper_fdiv_FT(FREG(B11_8), cpu_env,
|
|
|
|
FREG(B11_8), FREG(B7_4));
|
2008-11-17 17:43:54 +03:00
|
|
|
break;
|
|
|
|
case 0xf004: /* fcmp/eq Rm,Rn */
|
2017-07-02 22:31:25 +03:00
|
|
|
gen_helper_fcmp_eq_FT(cpu_sr_t, cpu_env,
|
2017-07-18 23:02:36 +03:00
|
|
|
FREG(B11_8), FREG(B7_4));
|
2008-11-17 17:43:54 +03:00
|
|
|
return;
|
|
|
|
case 0xf005: /* fcmp/gt Rm,Rn */
|
2017-07-02 22:31:25 +03:00
|
|
|
gen_helper_fcmp_gt_FT(cpu_sr_t, cpu_env,
|
2017-07-18 23:02:36 +03:00
|
|
|
FREG(B11_8), FREG(B7_4));
|
2008-11-17 17:43:54 +03:00
|
|
|
return;
|
|
|
|
}
|
2008-09-02 02:11:56 +04:00
|
|
|
}
|
2007-06-22 15:12:01 +04:00
|
|
|
}
|
|
|
|
return;
|
2009-01-15 00:02:59 +03:00
|
|
|
case 0xf00e: /* fmac FR0,RM,Rn */
|
2017-07-18 23:02:47 +03:00
|
|
|
CHECK_FPU_ENABLED
|
|
|
|
CHECK_FPSCR_PR_0
|
|
|
|
gen_helper_fmac_FT(FREG(B11_8), cpu_env,
|
|
|
|
FREG(0), FREG(B7_4), FREG(B11_8));
|
|
|
|
return;
|
2006-04-28 01:07:38 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
switch (ctx->opcode & 0xff00) {
|
|
|
|
case 0xc900: /* and #imm,R0 */
|
2008-09-01 17:09:14 +04:00
|
|
|
tcg_gen_andi_i32(REG(0), REG(0), B7_0);
|
2006-04-28 01:07:38 +04:00
|
|
|
return;
|
SH4, fix several instructions
fix instruction code for frchg, fschg, ocbp.
fix addressing mode handling for @Rn+, @-Rn, @(disp,gbr).
fix operation for div0s.
fix comments for mov imm, add imm, @(r0+,gbr), mac.l @Rm+,@Rn+.
fix ldb to ldub for or/tst/xor.b #imm,@(r0,gbr).
add fmov extended operations.
add fcmp/eq, fcmp/gt, fneg, fabs, fsqrt, fcnvsd, fcnvds.
(Takashi Yoshii)
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@4040 c046a42c-6fe2-441c-8c8c-71466251a162
2008-03-12 02:22:37 +03:00
|
|
|
case 0xcd00: /* and.b #imm,@(R0,GBR) */
|
2008-09-01 17:09:21 +04:00
|
|
|
{
|
|
|
|
TCGv addr, val;
|
2008-11-17 17:43:54 +03:00
|
|
|
addr = tcg_temp_new();
|
2008-09-01 17:09:21 +04:00
|
|
|
tcg_gen_add_i32(addr, REG(0), cpu_gbr);
|
2008-11-17 17:43:54 +03:00
|
|
|
val = tcg_temp_new();
|
2013-12-11 10:56:47 +04:00
|
|
|
tcg_gen_qemu_ld_i32(val, addr, ctx->memidx, MO_UB);
|
2008-09-01 17:09:21 +04:00
|
|
|
tcg_gen_andi_i32(val, val, B7_0);
|
2013-12-11 10:56:47 +04:00
|
|
|
tcg_gen_qemu_st_i32(val, addr, ctx->memidx, MO_UB);
|
2008-09-01 17:09:21 +04:00
|
|
|
tcg_temp_free(val);
|
|
|
|
tcg_temp_free(addr);
|
|
|
|
}
|
2006-04-28 01:07:38 +04:00
|
|
|
return;
|
|
|
|
case 0x8b00: /* bf label */
|
|
|
|
CHECK_NOT_DELAY_SLOT
|
2017-07-18 23:02:31 +03:00
|
|
|
gen_conditional_jump(ctx, ctx->pc + 4 + B7_0s * 2, false);
|
2006-04-28 01:07:38 +04:00
|
|
|
return;
|
|
|
|
case 0x8f00: /* bf/s label */
|
|
|
|
CHECK_NOT_DELAY_SLOT
|
2017-05-02 00:20:43 +03:00
|
|
|
tcg_gen_xori_i32(cpu_delayed_cond, cpu_sr_t, 1);
|
|
|
|
ctx->delayed_pc = ctx->pc + 4 + B7_0s * 2;
|
2017-05-02 00:20:43 +03:00
|
|
|
ctx->envflags |= DELAY_SLOT_CONDITIONAL;
|
2006-04-28 01:07:38 +04:00
|
|
|
return;
|
|
|
|
case 0x8900: /* bt label */
|
|
|
|
CHECK_NOT_DELAY_SLOT
|
2017-07-18 23:02:31 +03:00
|
|
|
gen_conditional_jump(ctx, ctx->pc + 4 + B7_0s * 2, true);
|
2006-04-28 01:07:38 +04:00
|
|
|
return;
|
|
|
|
case 0x8d00: /* bt/s label */
|
|
|
|
CHECK_NOT_DELAY_SLOT
|
2017-05-02 00:20:43 +03:00
|
|
|
tcg_gen_mov_i32(cpu_delayed_cond, cpu_sr_t);
|
|
|
|
ctx->delayed_pc = ctx->pc + 4 + B7_0s * 2;
|
2017-05-02 00:20:43 +03:00
|
|
|
ctx->envflags |= DELAY_SLOT_CONDITIONAL;
|
2006-04-28 01:07:38 +04:00
|
|
|
return;
|
|
|
|
case 0x8800: /* cmp/eq #imm,R0 */
|
2015-05-25 02:28:56 +03:00
|
|
|
tcg_gen_setcondi_i32(TCG_COND_EQ, cpu_sr_t, REG(0), B7_0s);
|
2006-04-28 01:07:38 +04:00
|
|
|
return;
|
|
|
|
case 0xc400: /* mov.b @(disp,GBR),R0 */
|
2008-09-01 17:09:21 +04:00
|
|
|
{
|
2008-11-17 17:43:54 +03:00
|
|
|
TCGv addr = tcg_temp_new();
|
2008-09-01 17:09:21 +04:00
|
|
|
tcg_gen_addi_i32(addr, cpu_gbr, B7_0);
|
2013-12-11 10:56:47 +04:00
|
|
|
tcg_gen_qemu_ld_i32(REG(0), addr, ctx->memidx, MO_SB);
|
2008-09-01 17:09:21 +04:00
|
|
|
tcg_temp_free(addr);
|
|
|
|
}
|
2006-04-28 01:07:38 +04:00
|
|
|
return;
|
|
|
|
case 0xc500: /* mov.w @(disp,GBR),R0 */
|
2008-09-01 17:09:21 +04:00
|
|
|
{
|
2008-11-17 17:43:54 +03:00
|
|
|
TCGv addr = tcg_temp_new();
|
2008-09-01 17:09:21 +04:00
|
|
|
tcg_gen_addi_i32(addr, cpu_gbr, B7_0 * 2);
|
2013-12-11 10:56:47 +04:00
|
|
|
tcg_gen_qemu_ld_i32(REG(0), addr, ctx->memidx, MO_TESW);
|
2008-09-01 17:09:21 +04:00
|
|
|
tcg_temp_free(addr);
|
|
|
|
}
|
2006-04-28 01:07:38 +04:00
|
|
|
return;
|
|
|
|
case 0xc600: /* mov.l @(disp,GBR),R0 */
|
2008-09-01 17:09:21 +04:00
|
|
|
{
|
2008-11-17 17:43:54 +03:00
|
|
|
TCGv addr = tcg_temp_new();
|
2008-09-01 17:09:21 +04:00
|
|
|
tcg_gen_addi_i32(addr, cpu_gbr, B7_0 * 4);
|
2013-12-11 10:56:47 +04:00
|
|
|
tcg_gen_qemu_ld_i32(REG(0), addr, ctx->memidx, MO_TESL);
|
2008-09-01 17:09:21 +04:00
|
|
|
tcg_temp_free(addr);
|
|
|
|
}
|
2006-04-28 01:07:38 +04:00
|
|
|
return;
|
|
|
|
case 0xc000: /* mov.b R0,@(disp,GBR) */
|
2008-09-01 17:09:21 +04:00
|
|
|
{
|
2008-11-17 17:43:54 +03:00
|
|
|
TCGv addr = tcg_temp_new();
|
2008-09-01 17:09:21 +04:00
|
|
|
tcg_gen_addi_i32(addr, cpu_gbr, B7_0);
|
2013-12-11 10:56:47 +04:00
|
|
|
tcg_gen_qemu_st_i32(REG(0), addr, ctx->memidx, MO_UB);
|
2008-09-01 17:09:21 +04:00
|
|
|
tcg_temp_free(addr);
|
|
|
|
}
|
2006-04-28 01:07:38 +04:00
|
|
|
return;
|
|
|
|
case 0xc100: /* mov.w R0,@(disp,GBR) */
|
2008-09-01 17:09:21 +04:00
|
|
|
{
|
2008-11-17 17:43:54 +03:00
|
|
|
TCGv addr = tcg_temp_new();
|
2008-09-01 17:09:21 +04:00
|
|
|
tcg_gen_addi_i32(addr, cpu_gbr, B7_0 * 2);
|
2013-12-11 10:56:47 +04:00
|
|
|
tcg_gen_qemu_st_i32(REG(0), addr, ctx->memidx, MO_TEUW);
|
2008-09-01 17:09:21 +04:00
|
|
|
tcg_temp_free(addr);
|
|
|
|
}
|
2006-04-28 01:07:38 +04:00
|
|
|
return;
|
|
|
|
case 0xc200: /* mov.l R0,@(disp,GBR) */
|
2008-09-01 17:09:21 +04:00
|
|
|
{
|
2008-11-17 17:43:54 +03:00
|
|
|
TCGv addr = tcg_temp_new();
|
2008-09-01 17:09:21 +04:00
|
|
|
tcg_gen_addi_i32(addr, cpu_gbr, B7_0 * 4);
|
2013-12-11 10:56:47 +04:00
|
|
|
tcg_gen_qemu_st_i32(REG(0), addr, ctx->memidx, MO_TEUL);
|
2008-09-01 17:09:21 +04:00
|
|
|
tcg_temp_free(addr);
|
|
|
|
}
|
2006-04-28 01:07:38 +04:00
|
|
|
return;
|
|
|
|
case 0x8000: /* mov.b R0,@(disp,Rn) */
|
2008-09-01 17:09:21 +04:00
|
|
|
{
|
2008-11-17 17:43:54 +03:00
|
|
|
TCGv addr = tcg_temp_new();
|
2008-09-01 17:09:21 +04:00
|
|
|
tcg_gen_addi_i32(addr, REG(B7_4), B3_0);
|
2013-12-11 10:56:47 +04:00
|
|
|
tcg_gen_qemu_st_i32(REG(0), addr, ctx->memidx, MO_UB);
|
2008-09-01 17:09:21 +04:00
|
|
|
tcg_temp_free(addr);
|
|
|
|
}
|
2006-04-28 01:07:38 +04:00
|
|
|
return;
|
|
|
|
case 0x8100: /* mov.w R0,@(disp,Rn) */
|
2008-09-01 17:09:21 +04:00
|
|
|
{
|
2008-11-17 17:43:54 +03:00
|
|
|
TCGv addr = tcg_temp_new();
|
2008-09-01 17:09:21 +04:00
|
|
|
tcg_gen_addi_i32(addr, REG(B7_4), B3_0 * 2);
|
2013-12-11 10:56:47 +04:00
|
|
|
tcg_gen_qemu_st_i32(REG(0), addr, ctx->memidx, MO_TEUW);
|
2008-09-01 17:09:21 +04:00
|
|
|
tcg_temp_free(addr);
|
|
|
|
}
|
2006-04-28 01:07:38 +04:00
|
|
|
return;
|
|
|
|
case 0x8400: /* mov.b @(disp,Rn),R0 */
|
2008-09-01 17:09:21 +04:00
|
|
|
{
|
2008-11-17 17:43:54 +03:00
|
|
|
TCGv addr = tcg_temp_new();
|
2008-09-01 17:09:21 +04:00
|
|
|
tcg_gen_addi_i32(addr, REG(B7_4), B3_0);
|
2013-12-11 10:56:47 +04:00
|
|
|
tcg_gen_qemu_ld_i32(REG(0), addr, ctx->memidx, MO_SB);
|
2008-09-01 17:09:21 +04:00
|
|
|
tcg_temp_free(addr);
|
|
|
|
}
|
2006-04-28 01:07:38 +04:00
|
|
|
return;
|
|
|
|
case 0x8500: /* mov.w @(disp,Rn),R0 */
|
2008-09-01 17:09:21 +04:00
|
|
|
{
|
2008-11-17 17:43:54 +03:00
|
|
|
TCGv addr = tcg_temp_new();
|
2008-09-01 17:09:21 +04:00
|
|
|
tcg_gen_addi_i32(addr, REG(B7_4), B3_0 * 2);
|
2013-12-11 10:56:47 +04:00
|
|
|
tcg_gen_qemu_ld_i32(REG(0), addr, ctx->memidx, MO_TESW);
|
2008-09-01 17:09:21 +04:00
|
|
|
tcg_temp_free(addr);
|
|
|
|
}
|
2006-04-28 01:07:38 +04:00
|
|
|
return;
|
|
|
|
case 0xc700: /* mova @(disp,PC),R0 */
|
2008-09-01 17:09:14 +04:00
|
|
|
tcg_gen_movi_i32(REG(0), ((ctx->pc & 0xfffffffc) + 4 + B7_0 * 4) & ~3);
|
2006-04-28 01:07:38 +04:00
|
|
|
return;
|
|
|
|
case 0xcb00: /* or #imm,R0 */
|
2008-09-01 17:09:14 +04:00
|
|
|
tcg_gen_ori_i32(REG(0), REG(0), B7_0);
|
2006-04-28 01:07:38 +04:00
|
|
|
return;
|
SH4, fix several instructions
fix instruction code for frchg, fschg, ocbp.
fix addressing mode handling for @Rn+, @-Rn, @(disp,gbr).
fix operation for div0s.
fix comments for mov imm, add imm, @(r0+,gbr), mac.l @Rm+,@Rn+.
fix ldb to ldub for or/tst/xor.b #imm,@(r0,gbr).
add fmov extended operations.
add fcmp/eq, fcmp/gt, fneg, fabs, fsqrt, fcnvsd, fcnvds.
(Takashi Yoshii)
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@4040 c046a42c-6fe2-441c-8c8c-71466251a162
2008-03-12 02:22:37 +03:00
|
|
|
case 0xcf00: /* or.b #imm,@(R0,GBR) */
|
2008-09-01 17:09:21 +04:00
|
|
|
{
|
|
|
|
TCGv addr, val;
|
2008-11-17 17:43:54 +03:00
|
|
|
addr = tcg_temp_new();
|
2008-09-01 17:09:21 +04:00
|
|
|
tcg_gen_add_i32(addr, REG(0), cpu_gbr);
|
2008-11-17 17:43:54 +03:00
|
|
|
val = tcg_temp_new();
|
2013-12-11 10:56:47 +04:00
|
|
|
tcg_gen_qemu_ld_i32(val, addr, ctx->memidx, MO_UB);
|
2008-09-01 17:09:21 +04:00
|
|
|
tcg_gen_ori_i32(val, val, B7_0);
|
2013-12-11 10:56:47 +04:00
|
|
|
tcg_gen_qemu_st_i32(val, addr, ctx->memidx, MO_UB);
|
2008-09-01 17:09:21 +04:00
|
|
|
tcg_temp_free(val);
|
|
|
|
tcg_temp_free(addr);
|
|
|
|
}
|
2006-04-28 01:07:38 +04:00
|
|
|
return;
|
|
|
|
case 0xc300: /* trapa #imm */
|
2008-09-01 17:09:21 +04:00
|
|
|
{
|
|
|
|
TCGv imm;
|
|
|
|
CHECK_NOT_DELAY_SLOT
|
2017-05-02 00:20:43 +03:00
|
|
|
gen_save_cpu_state(ctx, true);
|
2008-09-01 17:09:21 +04:00
|
|
|
imm = tcg_const_i32(B7_0);
|
2012-09-02 14:37:06 +04:00
|
|
|
gen_helper_trapa(cpu_env, imm);
|
2008-09-01 17:09:21 +04:00
|
|
|
tcg_temp_free(imm);
|
2017-05-02 00:20:43 +03:00
|
|
|
ctx->bstate = BS_EXCP;
|
2008-09-01 17:09:21 +04:00
|
|
|
}
|
2006-04-28 01:07:38 +04:00
|
|
|
return;
|
|
|
|
case 0xc800: /* tst #imm,R0 */
|
2008-09-01 17:09:21 +04:00
|
|
|
{
|
2008-11-17 17:43:54 +03:00
|
|
|
TCGv val = tcg_temp_new();
|
2008-09-01 17:09:21 +04:00
|
|
|
tcg_gen_andi_i32(val, REG(0), B7_0);
|
2015-05-25 02:28:56 +03:00
|
|
|
tcg_gen_setcondi_i32(TCG_COND_EQ, cpu_sr_t, val, 0);
|
2008-09-01 17:09:21 +04:00
|
|
|
tcg_temp_free(val);
|
|
|
|
}
|
2006-04-28 01:07:38 +04:00
|
|
|
return;
|
SH4, fix several instructions
fix instruction code for frchg, fschg, ocbp.
fix addressing mode handling for @Rn+, @-Rn, @(disp,gbr).
fix operation for div0s.
fix comments for mov imm, add imm, @(r0+,gbr), mac.l @Rm+,@Rn+.
fix ldb to ldub for or/tst/xor.b #imm,@(r0,gbr).
add fmov extended operations.
add fcmp/eq, fcmp/gt, fneg, fabs, fsqrt, fcnvsd, fcnvds.
(Takashi Yoshii)
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@4040 c046a42c-6fe2-441c-8c8c-71466251a162
2008-03-12 02:22:37 +03:00
|
|
|
case 0xcc00: /* tst.b #imm,@(R0,GBR) */
|
2008-09-01 17:09:21 +04:00
|
|
|
{
|
2008-11-17 17:43:54 +03:00
|
|
|
TCGv val = tcg_temp_new();
|
2008-09-01 17:09:21 +04:00
|
|
|
tcg_gen_add_i32(val, REG(0), cpu_gbr);
|
2013-12-11 10:56:47 +04:00
|
|
|
tcg_gen_qemu_ld_i32(val, val, ctx->memidx, MO_UB);
|
2008-09-01 17:09:21 +04:00
|
|
|
tcg_gen_andi_i32(val, val, B7_0);
|
2015-05-25 02:28:56 +03:00
|
|
|
tcg_gen_setcondi_i32(TCG_COND_EQ, cpu_sr_t, val, 0);
|
2008-09-01 17:09:21 +04:00
|
|
|
tcg_temp_free(val);
|
|
|
|
}
|
2006-04-28 01:07:38 +04:00
|
|
|
return;
|
|
|
|
case 0xca00: /* xor #imm,R0 */
|
2008-09-01 17:09:14 +04:00
|
|
|
tcg_gen_xori_i32(REG(0), REG(0), B7_0);
|
2006-04-28 01:07:38 +04:00
|
|
|
return;
|
SH4, fix several instructions
fix instruction code for frchg, fschg, ocbp.
fix addressing mode handling for @Rn+, @-Rn, @(disp,gbr).
fix operation for div0s.
fix comments for mov imm, add imm, @(r0+,gbr), mac.l @Rm+,@Rn+.
fix ldb to ldub for or/tst/xor.b #imm,@(r0,gbr).
add fmov extended operations.
add fcmp/eq, fcmp/gt, fneg, fabs, fsqrt, fcnvsd, fcnvds.
(Takashi Yoshii)
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@4040 c046a42c-6fe2-441c-8c8c-71466251a162
2008-03-12 02:22:37 +03:00
|
|
|
case 0xce00: /* xor.b #imm,@(R0,GBR) */
|
2008-09-01 17:09:21 +04:00
|
|
|
{
|
|
|
|
TCGv addr, val;
|
2008-11-17 17:43:54 +03:00
|
|
|
addr = tcg_temp_new();
|
2008-09-01 17:09:21 +04:00
|
|
|
tcg_gen_add_i32(addr, REG(0), cpu_gbr);
|
2008-11-17 17:43:54 +03:00
|
|
|
val = tcg_temp_new();
|
2013-12-11 10:56:47 +04:00
|
|
|
tcg_gen_qemu_ld_i32(val, addr, ctx->memidx, MO_UB);
|
2008-09-01 17:09:21 +04:00
|
|
|
tcg_gen_xori_i32(val, val, B7_0);
|
2013-12-11 10:56:47 +04:00
|
|
|
tcg_gen_qemu_st_i32(val, addr, ctx->memidx, MO_UB);
|
2008-09-01 17:09:21 +04:00
|
|
|
tcg_temp_free(val);
|
|
|
|
tcg_temp_free(addr);
|
|
|
|
}
|
2006-04-28 01:07:38 +04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (ctx->opcode & 0xf08f) {
|
|
|
|
case 0x408e: /* ldc Rm,Rn_BANK */
|
2008-09-15 12:49:15 +04:00
|
|
|
CHECK_PRIVILEGED
|
2008-09-01 17:09:14 +04:00
|
|
|
tcg_gen_mov_i32(ALTREG(B6_4), REG(B11_8));
|
2006-04-28 01:07:38 +04:00
|
|
|
return;
|
|
|
|
case 0x4087: /* ldc.l @Rm+,Rn_BANK */
|
2008-09-15 12:49:15 +04:00
|
|
|
CHECK_PRIVILEGED
|
2013-12-11 10:56:47 +04:00
|
|
|
tcg_gen_qemu_ld_i32(ALTREG(B6_4), REG(B11_8), ctx->memidx, MO_TESL);
|
2008-09-01 17:09:14 +04:00
|
|
|
tcg_gen_addi_i32(REG(B11_8), REG(B11_8), 4);
|
2006-04-28 01:07:38 +04:00
|
|
|
return;
|
|
|
|
case 0x0082: /* stc Rm_BANK,Rn */
|
2008-09-15 12:49:15 +04:00
|
|
|
CHECK_PRIVILEGED
|
2008-09-01 17:09:14 +04:00
|
|
|
tcg_gen_mov_i32(REG(B11_8), ALTREG(B6_4));
|
2006-04-28 01:07:38 +04:00
|
|
|
return;
|
|
|
|
case 0x4083: /* stc.l Rm_BANK,@-Rn */
|
2008-09-15 12:49:15 +04:00
|
|
|
CHECK_PRIVILEGED
|
2008-09-01 17:09:21 +04:00
|
|
|
{
|
2008-11-17 17:43:54 +03:00
|
|
|
TCGv addr = tcg_temp_new();
|
2008-09-01 17:09:21 +04:00
|
|
|
tcg_gen_subi_i32(addr, REG(B11_8), 4);
|
2013-12-11 10:56:47 +04:00
|
|
|
tcg_gen_qemu_st_i32(ALTREG(B6_4), addr, ctx->memidx, MO_TEUL);
|
2010-01-31 03:07:25 +03:00
|
|
|
tcg_gen_mov_i32(REG(B11_8), addr);
|
2008-09-01 17:09:21 +04:00
|
|
|
tcg_temp_free(addr);
|
|
|
|
}
|
2006-04-28 01:07:38 +04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (ctx->opcode & 0xf0ff) {
|
|
|
|
case 0x0023: /* braf Rn */
|
2008-09-01 17:09:14 +04:00
|
|
|
CHECK_NOT_DELAY_SLOT
|
|
|
|
tcg_gen_addi_i32(cpu_delayed_pc, REG(B11_8), ctx->pc + 4);
|
2017-05-02 00:20:43 +03:00
|
|
|
ctx->envflags |= DELAY_SLOT;
|
2006-04-28 01:07:38 +04:00
|
|
|
ctx->delayed_pc = (uint32_t) - 1;
|
|
|
|
return;
|
|
|
|
case 0x0003: /* bsrf Rn */
|
2008-09-01 17:09:14 +04:00
|
|
|
CHECK_NOT_DELAY_SLOT
|
2008-08-30 02:32:32 +04:00
|
|
|
tcg_gen_movi_i32(cpu_pr, ctx->pc + 4);
|
2008-09-01 17:09:14 +04:00
|
|
|
tcg_gen_add_i32(cpu_delayed_pc, REG(B11_8), cpu_pr);
|
2017-05-02 00:20:43 +03:00
|
|
|
ctx->envflags |= DELAY_SLOT;
|
2006-04-28 01:07:38 +04:00
|
|
|
ctx->delayed_pc = (uint32_t) - 1;
|
|
|
|
return;
|
|
|
|
case 0x4015: /* cmp/pl Rn */
|
2015-05-25 02:28:56 +03:00
|
|
|
tcg_gen_setcondi_i32(TCG_COND_GT, cpu_sr_t, REG(B11_8), 0);
|
2006-04-28 01:07:38 +04:00
|
|
|
return;
|
|
|
|
case 0x4011: /* cmp/pz Rn */
|
2015-05-25 02:28:56 +03:00
|
|
|
tcg_gen_setcondi_i32(TCG_COND_GE, cpu_sr_t, REG(B11_8), 0);
|
2006-04-28 01:07:38 +04:00
|
|
|
return;
|
|
|
|
case 0x4010: /* dt Rn */
|
2008-09-01 17:09:14 +04:00
|
|
|
tcg_gen_subi_i32(REG(B11_8), REG(B11_8), 1);
|
2015-05-25 02:28:56 +03:00
|
|
|
tcg_gen_setcondi_i32(TCG_COND_EQ, cpu_sr_t, REG(B11_8), 0);
|
2006-04-28 01:07:38 +04:00
|
|
|
return;
|
|
|
|
case 0x402b: /* jmp @Rn */
|
2008-09-01 17:09:14 +04:00
|
|
|
CHECK_NOT_DELAY_SLOT
|
|
|
|
tcg_gen_mov_i32(cpu_delayed_pc, REG(B11_8));
|
2017-05-02 00:20:43 +03:00
|
|
|
ctx->envflags |= DELAY_SLOT;
|
2006-04-28 01:07:38 +04:00
|
|
|
ctx->delayed_pc = (uint32_t) - 1;
|
|
|
|
return;
|
|
|
|
case 0x400b: /* jsr @Rn */
|
2008-09-01 17:09:14 +04:00
|
|
|
CHECK_NOT_DELAY_SLOT
|
2008-08-30 02:32:32 +04:00
|
|
|
tcg_gen_movi_i32(cpu_pr, ctx->pc + 4);
|
2008-09-01 17:09:14 +04:00
|
|
|
tcg_gen_mov_i32(cpu_delayed_pc, REG(B11_8));
|
2017-05-02 00:20:43 +03:00
|
|
|
ctx->envflags |= DELAY_SLOT;
|
2006-04-28 01:07:38 +04:00
|
|
|
ctx->delayed_pc = (uint32_t) - 1;
|
|
|
|
return;
|
2008-09-15 12:49:15 +04:00
|
|
|
case 0x400e: /* ldc Rm,SR */
|
|
|
|
CHECK_PRIVILEGED
|
2015-05-25 02:28:56 +03:00
|
|
|
{
|
|
|
|
TCGv val = tcg_temp_new();
|
|
|
|
tcg_gen_andi_i32(val, REG(B11_8), 0x700083f3);
|
|
|
|
gen_write_sr(val);
|
|
|
|
tcg_temp_free(val);
|
|
|
|
ctx->bstate = BS_STOP;
|
|
|
|
}
|
2008-08-31 02:07:52 +04:00
|
|
|
return;
|
2008-09-15 12:49:15 +04:00
|
|
|
case 0x4007: /* ldc.l @Rm+,SR */
|
|
|
|
CHECK_PRIVILEGED
|
2008-09-01 17:09:21 +04:00
|
|
|
{
|
2008-11-17 17:43:54 +03:00
|
|
|
TCGv val = tcg_temp_new();
|
2013-12-11 10:56:47 +04:00
|
|
|
tcg_gen_qemu_ld_i32(val, REG(B11_8), ctx->memidx, MO_TESL);
|
2015-05-25 02:28:56 +03:00
|
|
|
tcg_gen_andi_i32(val, val, 0x700083f3);
|
|
|
|
gen_write_sr(val);
|
2008-09-01 17:09:21 +04:00
|
|
|
tcg_temp_free(val);
|
|
|
|
tcg_gen_addi_i32(REG(B11_8), REG(B11_8), 4);
|
|
|
|
ctx->bstate = BS_STOP;
|
|
|
|
}
|
2008-08-31 02:07:52 +04:00
|
|
|
return;
|
2008-09-15 12:49:15 +04:00
|
|
|
case 0x0002: /* stc SR,Rn */
|
|
|
|
CHECK_PRIVILEGED
|
2015-05-25 02:28:56 +03:00
|
|
|
gen_read_sr(REG(B11_8));
|
2008-08-31 02:07:52 +04:00
|
|
|
return;
|
2008-09-15 12:49:15 +04:00
|
|
|
case 0x4003: /* stc SR,@-Rn */
|
|
|
|
CHECK_PRIVILEGED
|
2008-09-01 17:09:21 +04:00
|
|
|
{
|
2008-11-17 17:43:54 +03:00
|
|
|
TCGv addr = tcg_temp_new();
|
2015-05-25 02:28:56 +03:00
|
|
|
TCGv val = tcg_temp_new();
|
2008-09-01 17:09:21 +04:00
|
|
|
tcg_gen_subi_i32(addr, REG(B11_8), 4);
|
2015-05-25 02:28:56 +03:00
|
|
|
gen_read_sr(val);
|
|
|
|
tcg_gen_qemu_st_i32(val, addr, ctx->memidx, MO_TEUL);
|
2010-01-31 03:07:25 +03:00
|
|
|
tcg_gen_mov_i32(REG(B11_8), addr);
|
2015-05-25 02:28:56 +03:00
|
|
|
tcg_temp_free(val);
|
2008-09-01 17:09:21 +04:00
|
|
|
tcg_temp_free(addr);
|
|
|
|
}
|
2008-08-31 02:07:52 +04:00
|
|
|
return;
|
2010-07-12 09:05:31 +04:00
|
|
|
#define LD(reg,ldnum,ldpnum,prechk) \
|
2006-04-28 01:07:38 +04:00
|
|
|
case ldnum: \
|
2008-09-15 12:49:15 +04:00
|
|
|
prechk \
|
2008-09-01 17:09:14 +04:00
|
|
|
tcg_gen_mov_i32 (cpu_##reg, REG(B11_8)); \
|
2006-04-28 01:07:38 +04:00
|
|
|
return; \
|
|
|
|
case ldpnum: \
|
2008-09-15 12:49:15 +04:00
|
|
|
prechk \
|
2013-12-11 10:56:47 +04:00
|
|
|
tcg_gen_qemu_ld_i32(cpu_##reg, REG(B11_8), ctx->memidx, MO_TESL); \
|
2008-09-01 17:09:14 +04:00
|
|
|
tcg_gen_addi_i32(REG(B11_8), REG(B11_8), 4); \
|
2010-07-12 09:05:31 +04:00
|
|
|
return;
|
|
|
|
#define ST(reg,stnum,stpnum,prechk) \
|
2006-04-28 01:07:38 +04:00
|
|
|
case stnum: \
|
2008-09-15 12:49:15 +04:00
|
|
|
prechk \
|
2008-09-01 17:09:14 +04:00
|
|
|
tcg_gen_mov_i32 (REG(B11_8), cpu_##reg); \
|
2006-04-28 01:07:38 +04:00
|
|
|
return; \
|
|
|
|
case stpnum: \
|
2008-09-15 12:49:15 +04:00
|
|
|
prechk \
|
2008-09-01 17:09:21 +04:00
|
|
|
{ \
|
2010-01-31 03:07:25 +03:00
|
|
|
TCGv addr = tcg_temp_new(); \
|
2008-09-01 17:09:21 +04:00
|
|
|
tcg_gen_subi_i32(addr, REG(B11_8), 4); \
|
2013-12-11 10:56:47 +04:00
|
|
|
tcg_gen_qemu_st_i32(cpu_##reg, addr, ctx->memidx, MO_TEUL); \
|
2010-01-31 03:07:25 +03:00
|
|
|
tcg_gen_mov_i32(REG(B11_8), addr); \
|
2008-09-01 17:09:21 +04:00
|
|
|
tcg_temp_free(addr); \
|
2008-09-02 12:42:16 +04:00
|
|
|
} \
|
2006-04-28 01:07:38 +04:00
|
|
|
return;
|
2010-07-12 09:05:31 +04:00
|
|
|
#define LDST(reg,ldnum,ldpnum,stnum,stpnum,prechk) \
|
|
|
|
LD(reg,ldnum,ldpnum,prechk) \
|
|
|
|
ST(reg,stnum,stpnum,prechk)
|
2008-09-15 12:49:15 +04:00
|
|
|
LDST(gbr, 0x401e, 0x4017, 0x0012, 0x4013, {})
|
|
|
|
LDST(vbr, 0x402e, 0x4027, 0x0022, 0x4023, CHECK_PRIVILEGED)
|
|
|
|
LDST(ssr, 0x403e, 0x4037, 0x0032, 0x4033, CHECK_PRIVILEGED)
|
|
|
|
LDST(spc, 0x404e, 0x4047, 0x0042, 0x4043, CHECK_PRIVILEGED)
|
2010-07-12 09:05:32 +04:00
|
|
|
ST(sgr, 0x003a, 0x4032, CHECK_PRIVILEGED)
|
2017-07-18 23:02:48 +03:00
|
|
|
LD(sgr, 0x403a, 0x4036, CHECK_PRIVILEGED CHECK_SH4A)
|
2008-09-15 12:49:15 +04:00
|
|
|
LDST(dbr, 0x40fa, 0x40f6, 0x00fa, 0x40f2, CHECK_PRIVILEGED)
|
|
|
|
LDST(mach, 0x400a, 0x4006, 0x000a, 0x4002, {})
|
|
|
|
LDST(macl, 0x401a, 0x4016, 0x001a, 0x4012, {})
|
|
|
|
LDST(pr, 0x402a, 0x4026, 0x002a, 0x4022, {})
|
2008-12-08 01:46:31 +03:00
|
|
|
LDST(fpul, 0x405a, 0x4056, 0x005a, 0x4052, {CHECK_FPU_ENABLED})
|
2008-08-31 02:07:52 +04:00
|
|
|
case 0x406a: /* lds Rm,FPSCR */
|
2008-12-08 01:46:31 +03:00
|
|
|
CHECK_FPU_ENABLED
|
2012-09-02 14:37:06 +04:00
|
|
|
gen_helper_ld_fpscr(cpu_env, REG(B11_8));
|
2008-08-31 02:07:52 +04:00
|
|
|
ctx->bstate = BS_STOP;
|
|
|
|
return;
|
|
|
|
case 0x4066: /* lds.l @Rm+,FPSCR */
|
2008-12-08 01:46:31 +03:00
|
|
|
CHECK_FPU_ENABLED
|
2008-09-01 17:09:21 +04:00
|
|
|
{
|
2008-11-17 17:43:54 +03:00
|
|
|
TCGv addr = tcg_temp_new();
|
2013-12-11 10:56:47 +04:00
|
|
|
tcg_gen_qemu_ld_i32(addr, REG(B11_8), ctx->memidx, MO_TESL);
|
2008-09-01 17:09:21 +04:00
|
|
|
tcg_gen_addi_i32(REG(B11_8), REG(B11_8), 4);
|
2012-09-02 14:37:06 +04:00
|
|
|
gen_helper_ld_fpscr(cpu_env, addr);
|
2008-09-01 17:09:21 +04:00
|
|
|
tcg_temp_free(addr);
|
|
|
|
ctx->bstate = BS_STOP;
|
|
|
|
}
|
2008-08-31 02:07:52 +04:00
|
|
|
return;
|
|
|
|
case 0x006a: /* sts FPSCR,Rn */
|
2008-12-08 01:46:31 +03:00
|
|
|
CHECK_FPU_ENABLED
|
2008-09-01 17:09:21 +04:00
|
|
|
tcg_gen_andi_i32(REG(B11_8), cpu_fpscr, 0x003fffff);
|
2008-08-31 02:07:52 +04:00
|
|
|
return;
|
|
|
|
case 0x4062: /* sts FPSCR,@-Rn */
|
2008-12-08 01:46:31 +03:00
|
|
|
CHECK_FPU_ENABLED
|
2008-09-01 17:09:21 +04:00
|
|
|
{
|
|
|
|
TCGv addr, val;
|
2008-11-17 17:43:54 +03:00
|
|
|
val = tcg_temp_new();
|
2008-09-01 17:09:21 +04:00
|
|
|
tcg_gen_andi_i32(val, cpu_fpscr, 0x003fffff);
|
2008-11-17 17:43:54 +03:00
|
|
|
addr = tcg_temp_new();
|
2008-09-01 17:09:21 +04:00
|
|
|
tcg_gen_subi_i32(addr, REG(B11_8), 4);
|
2013-12-11 10:56:47 +04:00
|
|
|
tcg_gen_qemu_st_i32(val, addr, ctx->memidx, MO_TEUL);
|
2010-01-31 03:07:25 +03:00
|
|
|
tcg_gen_mov_i32(REG(B11_8), addr);
|
2008-09-01 17:09:21 +04:00
|
|
|
tcg_temp_free(addr);
|
|
|
|
tcg_temp_free(val);
|
|
|
|
}
|
2008-08-31 02:07:52 +04:00
|
|
|
return;
|
2006-04-28 01:07:38 +04:00
|
|
|
case 0x00c3: /* movca.l R0,@Rm */
|
2009-04-02 03:10:46 +04:00
|
|
|
{
|
|
|
|
TCGv val = tcg_temp_new();
|
2013-12-11 10:56:47 +04:00
|
|
|
tcg_gen_qemu_ld_i32(val, REG(B11_8), ctx->memidx, MO_TEUL);
|
2012-09-02 14:37:06 +04:00
|
|
|
gen_helper_movcal(cpu_env, REG(B11_8), val);
|
2013-12-11 10:56:47 +04:00
|
|
|
tcg_gen_qemu_st_i32(REG(0), REG(B11_8), ctx->memidx, MO_TEUL);
|
2009-04-02 03:10:46 +04:00
|
|
|
}
|
|
|
|
ctx->has_movcal = 1;
|
2006-04-28 01:07:38 +04:00
|
|
|
return;
|
2017-05-02 00:20:43 +03:00
|
|
|
case 0x40a9: /* movua.l @Rm,R0 */
|
2017-07-18 23:02:48 +03:00
|
|
|
CHECK_SH4A
|
2017-05-02 00:20:43 +03:00
|
|
|
/* Load non-boundary-aligned data */
|
2017-07-18 23:02:48 +03:00
|
|
|
tcg_gen_qemu_ld_i32(REG(0), REG(B11_8), ctx->memidx,
|
|
|
|
MO_TEUL | MO_UNALN);
|
|
|
|
return;
|
2017-05-02 00:20:43 +03:00
|
|
|
break;
|
|
|
|
case 0x40e9: /* movua.l @Rm+,R0 */
|
2017-07-18 23:02:48 +03:00
|
|
|
CHECK_SH4A
|
2017-05-02 00:20:43 +03:00
|
|
|
/* Load non-boundary-aligned data */
|
2017-07-18 23:02:48 +03:00
|
|
|
tcg_gen_qemu_ld_i32(REG(0), REG(B11_8), ctx->memidx,
|
|
|
|
MO_TEUL | MO_UNALN);
|
|
|
|
tcg_gen_addi_i32(REG(B11_8), REG(B11_8), 4);
|
|
|
|
return;
|
2017-05-02 00:20:43 +03:00
|
|
|
break;
|
2006-04-28 01:07:38 +04:00
|
|
|
case 0x0029: /* movt Rn */
|
2015-05-25 02:28:56 +03:00
|
|
|
tcg_gen_mov_i32(REG(B11_8), cpu_sr_t);
|
2006-04-28 01:07:38 +04:00
|
|
|
return;
|
2009-03-02 20:13:21 +03:00
|
|
|
case 0x0073:
|
|
|
|
/* MOVCO.L
|
|
|
|
LDST -> T
|
|
|
|
If (T == 1) R0 -> (Rn)
|
|
|
|
0 -> LDST
|
|
|
|
*/
|
2017-07-18 23:02:48 +03:00
|
|
|
CHECK_SH4A
|
|
|
|
{
|
2015-02-13 23:51:55 +03:00
|
|
|
TCGLabel *label = gen_new_label();
|
2015-05-25 02:28:56 +03:00
|
|
|
tcg_gen_mov_i32(cpu_sr_t, cpu_ldst);
|
2009-03-02 20:13:21 +03:00
|
|
|
tcg_gen_brcondi_i32(TCG_COND_EQ, cpu_ldst, 0, label);
|
2013-12-11 10:56:47 +04:00
|
|
|
tcg_gen_qemu_st_i32(REG(0), REG(B11_8), ctx->memidx, MO_TEUL);
|
2009-03-02 20:13:21 +03:00
|
|
|
gen_set_label(label);
|
|
|
|
tcg_gen_movi_i32(cpu_ldst, 0);
|
|
|
|
return;
|
2017-07-18 23:02:48 +03:00
|
|
|
}
|
2009-03-02 20:13:21 +03:00
|
|
|
case 0x0063:
|
|
|
|
/* MOVLI.L @Rm,R0
|
|
|
|
1 -> LDST
|
|
|
|
(Rm) -> R0
|
|
|
|
When interrupt/exception
|
|
|
|
occurred 0 -> LDST
|
|
|
|
*/
|
2017-07-18 23:02:48 +03:00
|
|
|
CHECK_SH4A
|
|
|
|
tcg_gen_movi_i32(cpu_ldst, 0);
|
|
|
|
tcg_gen_qemu_ld_i32(REG(0), REG(B11_8), ctx->memidx, MO_TESL);
|
|
|
|
tcg_gen_movi_i32(cpu_ldst, 1);
|
|
|
|
return;
|
2006-04-28 01:07:38 +04:00
|
|
|
case 0x0093: /* ocbi @Rn */
|
2008-09-01 17:09:21 +04:00
|
|
|
{
|
2012-09-02 14:37:06 +04:00
|
|
|
gen_helper_ocbi(cpu_env, REG(B11_8));
|
2008-09-01 17:09:21 +04:00
|
|
|
}
|
2006-04-28 01:07:38 +04:00
|
|
|
return;
|
SH4, fix several instructions
fix instruction code for frchg, fschg, ocbp.
fix addressing mode handling for @Rn+, @-Rn, @(disp,gbr).
fix operation for div0s.
fix comments for mov imm, add imm, @(r0+,gbr), mac.l @Rm+,@Rn+.
fix ldb to ldub for or/tst/xor.b #imm,@(r0,gbr).
add fmov extended operations.
add fcmp/eq, fcmp/gt, fneg, fabs, fsqrt, fcnvsd, fcnvds.
(Takashi Yoshii)
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@4040 c046a42c-6fe2-441c-8c8c-71466251a162
2008-03-12 02:22:37 +03:00
|
|
|
case 0x00a3: /* ocbp @Rn */
|
2006-04-28 01:07:38 +04:00
|
|
|
case 0x00b3: /* ocbwb @Rn */
|
2012-01-07 18:20:12 +04:00
|
|
|
/* These instructions are supposed to do nothing in case of
|
|
|
|
a cache miss. Given that we only partially emulate caches
|
|
|
|
it is safe to simply ignore them. */
|
2006-04-28 01:07:38 +04:00
|
|
|
return;
|
|
|
|
case 0x0083: /* pref @Rn */
|
|
|
|
return;
|
2008-12-13 21:57:37 +03:00
|
|
|
case 0x00d3: /* prefi @Rn */
|
2017-07-18 23:02:48 +03:00
|
|
|
CHECK_SH4A
|
|
|
|
return;
|
2008-12-13 21:57:37 +03:00
|
|
|
case 0x00e3: /* icbi @Rn */
|
2017-07-18 23:02:48 +03:00
|
|
|
CHECK_SH4A
|
|
|
|
return;
|
2008-12-13 21:57:37 +03:00
|
|
|
case 0x00ab: /* synco */
|
2017-07-18 23:02:48 +03:00
|
|
|
CHECK_SH4A
|
|
|
|
tcg_gen_mb(TCG_MO_ALL | TCG_BAR_SC);
|
|
|
|
return;
|
2017-05-02 00:20:43 +03:00
|
|
|
break;
|
2006-04-28 01:07:38 +04:00
|
|
|
case 0x4024: /* rotcl Rn */
|
2008-09-01 17:09:21 +04:00
|
|
|
{
|
2008-11-17 17:43:54 +03:00
|
|
|
TCGv tmp = tcg_temp_new();
|
2015-05-25 02:28:56 +03:00
|
|
|
tcg_gen_mov_i32(tmp, cpu_sr_t);
|
|
|
|
tcg_gen_shri_i32(cpu_sr_t, REG(B11_8), 31);
|
2008-09-01 17:09:21 +04:00
|
|
|
tcg_gen_shli_i32(REG(B11_8), REG(B11_8), 1);
|
2015-05-25 02:28:56 +03:00
|
|
|
tcg_gen_or_i32(REG(B11_8), REG(B11_8), tmp);
|
2008-09-01 17:09:21 +04:00
|
|
|
tcg_temp_free(tmp);
|
|
|
|
}
|
2006-04-28 01:07:38 +04:00
|
|
|
return;
|
|
|
|
case 0x4025: /* rotcr Rn */
|
2008-09-01 17:09:21 +04:00
|
|
|
{
|
2008-11-17 17:43:54 +03:00
|
|
|
TCGv tmp = tcg_temp_new();
|
2015-05-25 02:28:56 +03:00
|
|
|
tcg_gen_shli_i32(tmp, cpu_sr_t, 31);
|
|
|
|
tcg_gen_andi_i32(cpu_sr_t, REG(B11_8), 1);
|
2008-09-01 17:09:21 +04:00
|
|
|
tcg_gen_shri_i32(REG(B11_8), REG(B11_8), 1);
|
2015-05-25 02:28:56 +03:00
|
|
|
tcg_gen_or_i32(REG(B11_8), REG(B11_8), tmp);
|
2008-09-01 17:09:21 +04:00
|
|
|
tcg_temp_free(tmp);
|
|
|
|
}
|
2006-04-28 01:07:38 +04:00
|
|
|
return;
|
|
|
|
case 0x4004: /* rotl Rn */
|
2011-01-13 10:20:39 +03:00
|
|
|
tcg_gen_rotli_i32(REG(B11_8), REG(B11_8), 1);
|
2015-05-25 02:28:56 +03:00
|
|
|
tcg_gen_andi_i32(cpu_sr_t, REG(B11_8), 0);
|
2006-04-28 01:07:38 +04:00
|
|
|
return;
|
|
|
|
case 0x4005: /* rotr Rn */
|
2015-05-25 02:28:56 +03:00
|
|
|
tcg_gen_andi_i32(cpu_sr_t, REG(B11_8), 0);
|
2011-01-13 10:20:39 +03:00
|
|
|
tcg_gen_rotri_i32(REG(B11_8), REG(B11_8), 1);
|
2006-04-28 01:07:38 +04:00
|
|
|
return;
|
|
|
|
case 0x4000: /* shll Rn */
|
|
|
|
case 0x4020: /* shal Rn */
|
2015-05-25 02:28:56 +03:00
|
|
|
tcg_gen_shri_i32(cpu_sr_t, REG(B11_8), 31);
|
2008-09-01 17:09:14 +04:00
|
|
|
tcg_gen_shli_i32(REG(B11_8), REG(B11_8), 1);
|
2006-04-28 01:07:38 +04:00
|
|
|
return;
|
|
|
|
case 0x4021: /* shar Rn */
|
2015-05-25 02:28:56 +03:00
|
|
|
tcg_gen_andi_i32(cpu_sr_t, REG(B11_8), 1);
|
2008-09-01 17:09:14 +04:00
|
|
|
tcg_gen_sari_i32(REG(B11_8), REG(B11_8), 1);
|
2006-04-28 01:07:38 +04:00
|
|
|
return;
|
|
|
|
case 0x4001: /* shlr Rn */
|
2015-05-25 02:28:56 +03:00
|
|
|
tcg_gen_andi_i32(cpu_sr_t, REG(B11_8), 1);
|
2008-09-01 17:09:14 +04:00
|
|
|
tcg_gen_shri_i32(REG(B11_8), REG(B11_8), 1);
|
2006-04-28 01:07:38 +04:00
|
|
|
return;
|
|
|
|
case 0x4008: /* shll2 Rn */
|
2008-09-01 17:09:14 +04:00
|
|
|
tcg_gen_shli_i32(REG(B11_8), REG(B11_8), 2);
|
2006-04-28 01:07:38 +04:00
|
|
|
return;
|
|
|
|
case 0x4018: /* shll8 Rn */
|
2008-09-01 17:09:14 +04:00
|
|
|
tcg_gen_shli_i32(REG(B11_8), REG(B11_8), 8);
|
2006-04-28 01:07:38 +04:00
|
|
|
return;
|
|
|
|
case 0x4028: /* shll16 Rn */
|
2008-09-01 17:09:14 +04:00
|
|
|
tcg_gen_shli_i32(REG(B11_8), REG(B11_8), 16);
|
2006-04-28 01:07:38 +04:00
|
|
|
return;
|
|
|
|
case 0x4009: /* shlr2 Rn */
|
2008-09-01 17:09:14 +04:00
|
|
|
tcg_gen_shri_i32(REG(B11_8), REG(B11_8), 2);
|
2006-04-28 01:07:38 +04:00
|
|
|
return;
|
|
|
|
case 0x4019: /* shlr8 Rn */
|
2008-09-01 17:09:14 +04:00
|
|
|
tcg_gen_shri_i32(REG(B11_8), REG(B11_8), 8);
|
2006-04-28 01:07:38 +04:00
|
|
|
return;
|
|
|
|
case 0x4029: /* shlr16 Rn */
|
2008-09-01 17:09:14 +04:00
|
|
|
tcg_gen_shri_i32(REG(B11_8), REG(B11_8), 16);
|
2006-04-28 01:07:38 +04:00
|
|
|
return;
|
|
|
|
case 0x401b: /* tas.b @Rn */
|
2017-05-02 00:20:43 +03:00
|
|
|
{
|
|
|
|
TCGv val = tcg_const_i32(0x80);
|
|
|
|
tcg_gen_atomic_fetch_or_i32(val, REG(B11_8), val,
|
|
|
|
ctx->memidx, MO_UB);
|
2015-05-25 02:28:56 +03:00
|
|
|
tcg_gen_setcondi_i32(TCG_COND_EQ, cpu_sr_t, val, 0);
|
2017-05-02 00:20:43 +03:00
|
|
|
tcg_temp_free(val);
|
|
|
|
}
|
|
|
|
return;
|
2007-06-22 15:44:41 +04:00
|
|
|
case 0xf00d: /* fsts FPUL,FRn - FPSCR: Nothing */
|
2008-12-10 20:31:43 +03:00
|
|
|
CHECK_FPU_ENABLED
|
2017-07-18 23:02:36 +03:00
|
|
|
tcg_gen_mov_i32(FREG(B11_8), cpu_fpul);
|
2006-06-14 19:02:05 +04:00
|
|
|
return;
|
2007-06-22 15:44:41 +04:00
|
|
|
case 0xf01d: /* flds FRm,FPUL - FPSCR: Nothing */
|
2008-12-10 20:31:43 +03:00
|
|
|
CHECK_FPU_ENABLED
|
2017-07-18 23:02:36 +03:00
|
|
|
tcg_gen_mov_i32(cpu_fpul, FREG(B11_8));
|
2006-06-14 19:02:05 +04:00
|
|
|
return;
|
2007-06-22 15:44:41 +04:00
|
|
|
case 0xf02d: /* float FPUL,FRn/DRn - FPSCR: R[PR,Enable.I]/W[Cause,Flag] */
|
2008-12-10 20:31:43 +03:00
|
|
|
CHECK_FPU_ENABLED
|
2017-05-02 00:20:43 +03:00
|
|
|
if (ctx->tbflags & FPSCR_PR) {
|
2008-11-17 17:43:54 +03:00
|
|
|
TCGv_i64 fp;
|
2017-07-18 23:02:46 +03:00
|
|
|
if (ctx->opcode & 0x0100) {
|
|
|
|
goto do_illegal;
|
|
|
|
}
|
2008-11-17 17:43:54 +03:00
|
|
|
fp = tcg_temp_new_i64();
|
2012-09-02 14:37:06 +04:00
|
|
|
gen_helper_float_DT(fp, cpu_env, cpu_fpul);
|
2017-07-18 23:02:40 +03:00
|
|
|
gen_store_fpr64(ctx, fp, B11_8);
|
2008-11-17 17:43:54 +03:00
|
|
|
tcg_temp_free_i64(fp);
|
2007-06-22 15:12:01 +04:00
|
|
|
}
|
|
|
|
else {
|
2017-07-18 23:02:36 +03:00
|
|
|
gen_helper_float_FT(FREG(B11_8), cpu_env, cpu_fpul);
|
2007-06-22 15:12:01 +04:00
|
|
|
}
|
|
|
|
return;
|
2007-06-22 15:44:41 +04:00
|
|
|
case 0xf03d: /* ftrc FRm/DRm,FPUL - FPSCR: R[PR,Enable.V]/W[Cause,Flag] */
|
2008-12-10 20:31:43 +03:00
|
|
|
CHECK_FPU_ENABLED
|
2017-05-02 00:20:43 +03:00
|
|
|
if (ctx->tbflags & FPSCR_PR) {
|
2008-11-17 17:43:54 +03:00
|
|
|
TCGv_i64 fp;
|
2017-07-18 23:02:46 +03:00
|
|
|
if (ctx->opcode & 0x0100) {
|
|
|
|
goto do_illegal;
|
|
|
|
}
|
2008-11-17 17:43:54 +03:00
|
|
|
fp = tcg_temp_new_i64();
|
2017-07-18 23:02:40 +03:00
|
|
|
gen_load_fpr64(ctx, fp, B11_8);
|
2012-09-02 14:37:06 +04:00
|
|
|
gen_helper_ftrc_DT(cpu_fpul, cpu_env, fp);
|
2008-11-17 17:43:54 +03:00
|
|
|
tcg_temp_free_i64(fp);
|
2007-06-22 15:12:01 +04:00
|
|
|
}
|
|
|
|
else {
|
2017-07-18 23:02:36 +03:00
|
|
|
gen_helper_ftrc_FT(cpu_fpul, cpu_env, FREG(B11_8));
|
2007-06-22 15:12:01 +04:00
|
|
|
}
|
|
|
|
return;
|
SH4, fix several instructions
fix instruction code for frchg, fschg, ocbp.
fix addressing mode handling for @Rn+, @-Rn, @(disp,gbr).
fix operation for div0s.
fix comments for mov imm, add imm, @(r0+,gbr), mac.l @Rm+,@Rn+.
fix ldb to ldub for or/tst/xor.b #imm,@(r0,gbr).
add fmov extended operations.
add fcmp/eq, fcmp/gt, fneg, fabs, fsqrt, fcnvsd, fcnvds.
(Takashi Yoshii)
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@4040 c046a42c-6fe2-441c-8c8c-71466251a162
2008-03-12 02:22:37 +03:00
|
|
|
case 0xf04d: /* fneg FRn/DRn - FPSCR: Nothing */
|
2008-12-10 20:31:43 +03:00
|
|
|
CHECK_FPU_ENABLED
|
2017-07-18 23:02:36 +03:00
|
|
|
tcg_gen_xori_i32(FREG(B11_8), FREG(B11_8), 0x80000000);
|
SH4, fix several instructions
fix instruction code for frchg, fschg, ocbp.
fix addressing mode handling for @Rn+, @-Rn, @(disp,gbr).
fix operation for div0s.
fix comments for mov imm, add imm, @(r0+,gbr), mac.l @Rm+,@Rn+.
fix ldb to ldub for or/tst/xor.b #imm,@(r0,gbr).
add fmov extended operations.
add fcmp/eq, fcmp/gt, fneg, fabs, fsqrt, fcnvsd, fcnvds.
(Takashi Yoshii)
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@4040 c046a42c-6fe2-441c-8c8c-71466251a162
2008-03-12 02:22:37 +03:00
|
|
|
return;
|
2017-07-02 19:18:14 +03:00
|
|
|
case 0xf05d: /* fabs FRn/DRn - FPCSR: Nothing */
|
2008-12-10 20:31:43 +03:00
|
|
|
CHECK_FPU_ENABLED
|
2017-07-18 23:02:36 +03:00
|
|
|
tcg_gen_andi_i32(FREG(B11_8), FREG(B11_8), 0x7fffffff);
|
SH4, fix several instructions
fix instruction code for frchg, fschg, ocbp.
fix addressing mode handling for @Rn+, @-Rn, @(disp,gbr).
fix operation for div0s.
fix comments for mov imm, add imm, @(r0+,gbr), mac.l @Rm+,@Rn+.
fix ldb to ldub for or/tst/xor.b #imm,@(r0,gbr).
add fmov extended operations.
add fcmp/eq, fcmp/gt, fneg, fabs, fsqrt, fcnvsd, fcnvds.
(Takashi Yoshii)
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@4040 c046a42c-6fe2-441c-8c8c-71466251a162
2008-03-12 02:22:37 +03:00
|
|
|
return;
|
|
|
|
case 0xf06d: /* fsqrt FRn */
|
2008-12-10 20:31:43 +03:00
|
|
|
CHECK_FPU_ENABLED
|
2017-05-02 00:20:43 +03:00
|
|
|
if (ctx->tbflags & FPSCR_PR) {
|
2017-07-18 23:02:46 +03:00
|
|
|
if (ctx->opcode & 0x0100) {
|
|
|
|
goto do_illegal;
|
|
|
|
}
|
2008-11-17 17:43:54 +03:00
|
|
|
TCGv_i64 fp = tcg_temp_new_i64();
|
2017-07-18 23:02:40 +03:00
|
|
|
gen_load_fpr64(ctx, fp, B11_8);
|
2012-09-02 14:37:06 +04:00
|
|
|
gen_helper_fsqrt_DT(fp, cpu_env, fp);
|
2017-07-18 23:02:40 +03:00
|
|
|
gen_store_fpr64(ctx, fp, B11_8);
|
2008-11-17 17:43:54 +03:00
|
|
|
tcg_temp_free_i64(fp);
|
SH4, fix several instructions
fix instruction code for frchg, fschg, ocbp.
fix addressing mode handling for @Rn+, @-Rn, @(disp,gbr).
fix operation for div0s.
fix comments for mov imm, add imm, @(r0+,gbr), mac.l @Rm+,@Rn+.
fix ldb to ldub for or/tst/xor.b #imm,@(r0,gbr).
add fmov extended operations.
add fcmp/eq, fcmp/gt, fneg, fabs, fsqrt, fcnvsd, fcnvds.
(Takashi Yoshii)
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@4040 c046a42c-6fe2-441c-8c8c-71466251a162
2008-03-12 02:22:37 +03:00
|
|
|
} else {
|
2017-07-18 23:02:36 +03:00
|
|
|
gen_helper_fsqrt_FT(FREG(B11_8), cpu_env, FREG(B11_8));
|
SH4, fix several instructions
fix instruction code for frchg, fschg, ocbp.
fix addressing mode handling for @Rn+, @-Rn, @(disp,gbr).
fix operation for div0s.
fix comments for mov imm, add imm, @(r0+,gbr), mac.l @Rm+,@Rn+.
fix ldb to ldub for or/tst/xor.b #imm,@(r0,gbr).
add fmov extended operations.
add fcmp/eq, fcmp/gt, fneg, fabs, fsqrt, fcnvsd, fcnvds.
(Takashi Yoshii)
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@4040 c046a42c-6fe2-441c-8c8c-71466251a162
2008-03-12 02:22:37 +03:00
|
|
|
}
|
|
|
|
return;
|
|
|
|
case 0xf07d: /* fsrra FRn */
|
2008-12-10 20:31:43 +03:00
|
|
|
CHECK_FPU_ENABLED
|
2017-07-18 23:02:51 +03:00
|
|
|
CHECK_FPSCR_PR_0
|
|
|
|
gen_helper_fsrra_FT(FREG(B11_8), cpu_env, FREG(B11_8));
|
SH4, fix several instructions
fix instruction code for frchg, fschg, ocbp.
fix addressing mode handling for @Rn+, @-Rn, @(disp,gbr).
fix operation for div0s.
fix comments for mov imm, add imm, @(r0+,gbr), mac.l @Rm+,@Rn+.
fix ldb to ldub for or/tst/xor.b #imm,@(r0,gbr).
add fmov extended operations.
add fcmp/eq, fcmp/gt, fneg, fabs, fsqrt, fcnvsd, fcnvds.
(Takashi Yoshii)
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@4040 c046a42c-6fe2-441c-8c8c-71466251a162
2008-03-12 02:22:37 +03:00
|
|
|
break;
|
2007-06-22 15:44:41 +04:00
|
|
|
case 0xf08d: /* fldi0 FRn - FPSCR: R[PR] */
|
2008-12-10 20:31:43 +03:00
|
|
|
CHECK_FPU_ENABLED
|
2017-07-18 23:02:47 +03:00
|
|
|
CHECK_FPSCR_PR_0
|
|
|
|
tcg_gen_movi_i32(FREG(B11_8), 0);
|
|
|
|
return;
|
2007-06-22 15:44:41 +04:00
|
|
|
case 0xf09d: /* fldi1 FRn - FPSCR: R[PR] */
|
2008-12-10 20:31:43 +03:00
|
|
|
CHECK_FPU_ENABLED
|
2017-07-18 23:02:47 +03:00
|
|
|
CHECK_FPSCR_PR_0
|
|
|
|
tcg_gen_movi_i32(FREG(B11_8), 0x3f800000);
|
|
|
|
return;
|
SH4, fix several instructions
fix instruction code for frchg, fschg, ocbp.
fix addressing mode handling for @Rn+, @-Rn, @(disp,gbr).
fix operation for div0s.
fix comments for mov imm, add imm, @(r0+,gbr), mac.l @Rm+,@Rn+.
fix ldb to ldub for or/tst/xor.b #imm,@(r0,gbr).
add fmov extended operations.
add fcmp/eq, fcmp/gt, fneg, fabs, fsqrt, fcnvsd, fcnvds.
(Takashi Yoshii)
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@4040 c046a42c-6fe2-441c-8c8c-71466251a162
2008-03-12 02:22:37 +03:00
|
|
|
case 0xf0ad: /* fcnvsd FPUL,DRn */
|
2008-12-10 20:31:43 +03:00
|
|
|
CHECK_FPU_ENABLED
|
2008-09-02 02:11:56 +04:00
|
|
|
{
|
2008-11-17 17:43:54 +03:00
|
|
|
TCGv_i64 fp = tcg_temp_new_i64();
|
2012-09-02 14:37:06 +04:00
|
|
|
gen_helper_fcnvsd_FT_DT(fp, cpu_env, cpu_fpul);
|
2017-07-18 23:02:40 +03:00
|
|
|
gen_store_fpr64(ctx, fp, B11_8);
|
2008-11-17 17:43:54 +03:00
|
|
|
tcg_temp_free_i64(fp);
|
2008-09-02 02:11:56 +04:00
|
|
|
}
|
SH4, fix several instructions
fix instruction code for frchg, fschg, ocbp.
fix addressing mode handling for @Rn+, @-Rn, @(disp,gbr).
fix operation for div0s.
fix comments for mov imm, add imm, @(r0+,gbr), mac.l @Rm+,@Rn+.
fix ldb to ldub for or/tst/xor.b #imm,@(r0,gbr).
add fmov extended operations.
add fcmp/eq, fcmp/gt, fneg, fabs, fsqrt, fcnvsd, fcnvds.
(Takashi Yoshii)
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@4040 c046a42c-6fe2-441c-8c8c-71466251a162
2008-03-12 02:22:37 +03:00
|
|
|
return;
|
|
|
|
case 0xf0bd: /* fcnvds DRn,FPUL */
|
2008-12-10 20:31:43 +03:00
|
|
|
CHECK_FPU_ENABLED
|
2008-09-02 02:11:56 +04:00
|
|
|
{
|
2008-11-17 17:43:54 +03:00
|
|
|
TCGv_i64 fp = tcg_temp_new_i64();
|
2017-07-18 23:02:40 +03:00
|
|
|
gen_load_fpr64(ctx, fp, B11_8);
|
2012-09-02 14:37:06 +04:00
|
|
|
gen_helper_fcnvds_DT_FT(cpu_fpul, cpu_env, fp);
|
2008-11-17 17:43:54 +03:00
|
|
|
tcg_temp_free_i64(fp);
|
2008-09-02 02:11:56 +04:00
|
|
|
}
|
SH4, fix several instructions
fix instruction code for frchg, fschg, ocbp.
fix addressing mode handling for @Rn+, @-Rn, @(disp,gbr).
fix operation for div0s.
fix comments for mov imm, add imm, @(r0+,gbr), mac.l @Rm+,@Rn+.
fix ldb to ldub for or/tst/xor.b #imm,@(r0,gbr).
add fmov extended operations.
add fcmp/eq, fcmp/gt, fneg, fabs, fsqrt, fcnvsd, fcnvds.
(Takashi Yoshii)
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@4040 c046a42c-6fe2-441c-8c8c-71466251a162
2008-03-12 02:22:37 +03:00
|
|
|
return;
|
2011-01-14 22:39:18 +03:00
|
|
|
case 0xf0ed: /* fipr FVm,FVn */
|
|
|
|
CHECK_FPU_ENABLED
|
2017-07-18 23:02:47 +03:00
|
|
|
CHECK_FPSCR_PR_1
|
|
|
|
{
|
|
|
|
TCGv m = tcg_const_i32((ctx->opcode >> 8) & 3);
|
|
|
|
TCGv n = tcg_const_i32((ctx->opcode >> 10) & 3);
|
2012-09-02 14:37:06 +04:00
|
|
|
gen_helper_fipr(cpu_env, m, n);
|
2011-01-14 22:39:18 +03:00
|
|
|
tcg_temp_free(m);
|
|
|
|
tcg_temp_free(n);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
break;
|
2011-01-14 22:39:18 +03:00
|
|
|
case 0xf0fd: /* ftrv XMTRX,FVn */
|
|
|
|
CHECK_FPU_ENABLED
|
2017-07-18 23:02:47 +03:00
|
|
|
CHECK_FPSCR_PR_1
|
|
|
|
{
|
|
|
|
if ((ctx->opcode & 0x0300) != 0x0100) {
|
|
|
|
goto do_illegal;
|
|
|
|
}
|
|
|
|
TCGv n = tcg_const_i32((ctx->opcode >> 10) & 3);
|
2012-09-02 14:37:06 +04:00
|
|
|
gen_helper_ftrv(cpu_env, n);
|
2011-01-14 22:39:18 +03:00
|
|
|
tcg_temp_free(n);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
break;
|
2006-04-28 01:07:38 +04:00
|
|
|
}
|
2008-12-13 21:57:46 +03:00
|
|
|
#if 0
|
2006-04-28 01:07:38 +04:00
|
|
|
fprintf(stderr, "unknown instruction 0x%04x at pc 0x%08x\n",
|
|
|
|
ctx->opcode, ctx->pc);
|
2008-12-13 21:57:46 +03:00
|
|
|
fflush(stderr);
|
|
|
|
#endif
|
2017-07-18 23:02:44 +03:00
|
|
|
do_illegal:
|
2017-05-17 01:48:18 +03:00
|
|
|
if (ctx->envflags & DELAY_SLOT_MASK) {
|
2017-07-18 23:02:43 +03:00
|
|
|
do_illegal_slot:
|
|
|
|
gen_save_cpu_state(ctx, true);
|
2012-09-02 14:37:06 +04:00
|
|
|
gen_helper_raise_slot_illegal_instruction(cpu_env);
|
2011-01-11 18:13:34 +03:00
|
|
|
} else {
|
2017-07-18 23:02:43 +03:00
|
|
|
gen_save_cpu_state(ctx, true);
|
2012-09-02 14:37:06 +04:00
|
|
|
gen_helper_raise_illegal_instruction(cpu_env);
|
2011-01-11 18:13:34 +03:00
|
|
|
}
|
2017-05-02 00:20:43 +03:00
|
|
|
ctx->bstate = BS_EXCP;
|
2017-07-18 23:02:45 +03:00
|
|
|
return;
|
|
|
|
|
|
|
|
do_fpu_disabled:
|
|
|
|
gen_save_cpu_state(ctx, true);
|
|
|
|
if (ctx->envflags & DELAY_SLOT_MASK) {
|
|
|
|
gen_helper_raise_slot_fpu_disable(cpu_env);
|
|
|
|
} else {
|
|
|
|
gen_helper_raise_fpu_disable(cpu_env);
|
|
|
|
}
|
|
|
|
ctx->bstate = BS_EXCP;
|
|
|
|
return;
|
2007-12-02 09:10:04 +03:00
|
|
|
}
|
|
|
|
|
2008-10-26 16:43:07 +03:00
|
|
|
static void decode_opc(DisasContext * ctx)
|
2007-12-02 09:10:04 +03:00
|
|
|
{
|
2017-05-02 00:20:43 +03:00
|
|
|
uint32_t old_flags = ctx->envflags;
|
2007-12-02 09:10:04 +03:00
|
|
|
|
|
|
|
_decode_opc(ctx);
|
|
|
|
|
2017-05-17 01:48:18 +03:00
|
|
|
if (old_flags & DELAY_SLOT_MASK) {
|
2017-05-02 00:20:43 +03:00
|
|
|
/* go out of the delay slot */
|
2017-05-17 01:48:18 +03:00
|
|
|
ctx->envflags &= ~DELAY_SLOT_MASK;
|
2017-07-18 23:02:31 +03:00
|
|
|
|
|
|
|
/* When in an exclusive region, we must continue to the end
|
|
|
|
for conditional branches. */
|
|
|
|
if (ctx->tbflags & GUSA_EXCLUSIVE
|
|
|
|
&& old_flags & DELAY_SLOT_CONDITIONAL) {
|
|
|
|
gen_delayed_conditional_jump(ctx);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
/* Otherwise this is probably an invalid gUSA region.
|
|
|
|
Drop the GUSA bits so the next TB doesn't see them. */
|
|
|
|
ctx->envflags &= ~GUSA_MASK;
|
|
|
|
|
2017-05-02 00:20:43 +03:00
|
|
|
tcg_gen_movi_i32(cpu_flags, ctx->envflags);
|
2007-12-02 09:10:04 +03:00
|
|
|
ctx->bstate = BS_BRANCH;
|
|
|
|
if (old_flags & DELAY_SLOT_CONDITIONAL) {
|
|
|
|
gen_delayed_conditional_jump(ctx);
|
2017-05-17 01:48:18 +03:00
|
|
|
} else {
|
2007-12-02 09:10:04 +03:00
|
|
|
gen_jump(ctx);
|
|
|
|
}
|
2017-07-18 23:02:31 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef CONFIG_USER_ONLY
|
|
|
|
/* For uniprocessors, SH4 uses optimistic restartable atomic sequences.
|
|
|
|
Upon an interrupt, a real kernel would simply notice magic values in
|
|
|
|
the registers and reset the PC to the start of the sequence.
|
|
|
|
|
|
|
|
For QEMU, we cannot do this in quite the same way. Instead, we notice
|
|
|
|
the normal start of such a sequence (mov #-x,r15). While we can handle
|
|
|
|
any sequence via cpu_exec_step_atomic, we can recognize the "normal"
|
|
|
|
sequences and transform them into atomic operations as seen by the host.
|
|
|
|
*/
|
|
|
|
static int decode_gusa(DisasContext *ctx, CPUSH4State *env, int *pmax_insns)
|
|
|
|
{
|
2017-07-18 23:02:32 +03:00
|
|
|
uint16_t insns[5];
|
|
|
|
int ld_adr, ld_dst, ld_mop;
|
|
|
|
int op_dst, op_src, op_opc;
|
|
|
|
int mv_src, mt_dst, st_src, st_mop;
|
|
|
|
TCGv op_arg;
|
|
|
|
|
2017-07-18 23:02:31 +03:00
|
|
|
uint32_t pc = ctx->pc;
|
|
|
|
uint32_t pc_end = ctx->tb->cs_base;
|
|
|
|
int backup = sextract32(ctx->tbflags, GUSA_SHIFT, 8);
|
|
|
|
int max_insns = (pc_end - pc) / 2;
|
2017-07-18 23:02:32 +03:00
|
|
|
int i;
|
2017-07-18 23:02:31 +03:00
|
|
|
|
|
|
|
if (pc != pc_end + backup || max_insns < 2) {
|
|
|
|
/* This is a malformed gUSA region. Don't do anything special,
|
|
|
|
since the interpreter is likely to get confused. */
|
|
|
|
ctx->envflags &= ~GUSA_MASK;
|
|
|
|
return 0;
|
|
|
|
}
|
2007-12-02 09:10:04 +03:00
|
|
|
|
2017-07-18 23:02:31 +03:00
|
|
|
if (ctx->tbflags & GUSA_EXCLUSIVE) {
|
|
|
|
/* Regardless of single-stepping or the end of the page,
|
|
|
|
we must complete execution of the gUSA region while
|
|
|
|
holding the exclusive lock. */
|
|
|
|
*pmax_insns = max_insns;
|
|
|
|
return 0;
|
2007-12-02 09:10:04 +03:00
|
|
|
}
|
2017-07-18 23:02:31 +03:00
|
|
|
|
2017-07-18 23:02:32 +03:00
|
|
|
/* The state machine below will consume only a few insns.
|
|
|
|
If there are more than that in a region, fail now. */
|
|
|
|
if (max_insns > ARRAY_SIZE(insns)) {
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Read all of the insns for the region. */
|
|
|
|
for (i = 0; i < max_insns; ++i) {
|
|
|
|
insns[i] = cpu_lduw_code(env, pc + i * 2);
|
|
|
|
}
|
|
|
|
|
|
|
|
ld_adr = ld_dst = ld_mop = -1;
|
|
|
|
mv_src = -1;
|
|
|
|
op_dst = op_src = op_opc = -1;
|
|
|
|
mt_dst = -1;
|
|
|
|
st_src = st_mop = -1;
|
|
|
|
TCGV_UNUSED(op_arg);
|
|
|
|
i = 0;
|
|
|
|
|
|
|
|
#define NEXT_INSN \
|
|
|
|
do { if (i >= max_insns) goto fail; ctx->opcode = insns[i++]; } while (0)
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Expect a load to begin the region.
|
|
|
|
*/
|
|
|
|
NEXT_INSN;
|
|
|
|
switch (ctx->opcode & 0xf00f) {
|
|
|
|
case 0x6000: /* mov.b @Rm,Rn */
|
|
|
|
ld_mop = MO_SB;
|
|
|
|
break;
|
|
|
|
case 0x6001: /* mov.w @Rm,Rn */
|
|
|
|
ld_mop = MO_TESW;
|
|
|
|
break;
|
|
|
|
case 0x6002: /* mov.l @Rm,Rn */
|
|
|
|
ld_mop = MO_TESL;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
ld_adr = B7_4;
|
|
|
|
ld_dst = B11_8;
|
|
|
|
if (ld_adr == ld_dst) {
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
/* Unless we see a mov, any two-operand operation must use ld_dst. */
|
|
|
|
op_dst = ld_dst;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Expect an optional register move.
|
|
|
|
*/
|
|
|
|
NEXT_INSN;
|
|
|
|
switch (ctx->opcode & 0xf00f) {
|
|
|
|
case 0x6003: /* mov Rm,Rn */
|
|
|
|
/* Here we want to recognize ld_dst being saved for later consumtion,
|
|
|
|
or for another input register being copied so that ld_dst need not
|
|
|
|
be clobbered during the operation. */
|
|
|
|
op_dst = B11_8;
|
|
|
|
mv_src = B7_4;
|
|
|
|
if (op_dst == ld_dst) {
|
|
|
|
/* Overwriting the load output. */
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
if (mv_src != ld_dst) {
|
|
|
|
/* Copying a new input; constrain op_src to match the load. */
|
|
|
|
op_src = ld_dst;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
/* Put back and re-examine as operation. */
|
|
|
|
--i;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Expect the operation.
|
|
|
|
*/
|
|
|
|
NEXT_INSN;
|
|
|
|
switch (ctx->opcode & 0xf00f) {
|
|
|
|
case 0x300c: /* add Rm,Rn */
|
|
|
|
op_opc = INDEX_op_add_i32;
|
|
|
|
goto do_reg_op;
|
|
|
|
case 0x2009: /* and Rm,Rn */
|
|
|
|
op_opc = INDEX_op_and_i32;
|
|
|
|
goto do_reg_op;
|
|
|
|
case 0x200a: /* xor Rm,Rn */
|
|
|
|
op_opc = INDEX_op_xor_i32;
|
|
|
|
goto do_reg_op;
|
|
|
|
case 0x200b: /* or Rm,Rn */
|
|
|
|
op_opc = INDEX_op_or_i32;
|
|
|
|
do_reg_op:
|
|
|
|
/* The operation register should be as expected, and the
|
|
|
|
other input cannot depend on the load. */
|
|
|
|
if (op_dst != B11_8) {
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
if (op_src < 0) {
|
|
|
|
/* Unconstrainted input. */
|
|
|
|
op_src = B7_4;
|
|
|
|
} else if (op_src == B7_4) {
|
|
|
|
/* Constrained input matched load. All operations are
|
|
|
|
commutative; "swap" them by "moving" the load output
|
|
|
|
to the (implicit) first argument and the move source
|
|
|
|
to the (explicit) second argument. */
|
|
|
|
op_src = mv_src;
|
|
|
|
} else {
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
op_arg = REG(op_src);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x6007: /* not Rm,Rn */
|
|
|
|
if (ld_dst != B7_4 || mv_src >= 0) {
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
op_dst = B11_8;
|
|
|
|
op_opc = INDEX_op_xor_i32;
|
|
|
|
op_arg = tcg_const_i32(-1);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x7000 ... 0x700f: /* add #imm,Rn */
|
|
|
|
if (op_dst != B11_8 || mv_src >= 0) {
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
op_opc = INDEX_op_add_i32;
|
|
|
|
op_arg = tcg_const_i32(B7_0s);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x3000: /* cmp/eq Rm,Rn */
|
|
|
|
/* Looking for the middle of a compare-and-swap sequence,
|
|
|
|
beginning with the compare. Operands can be either order,
|
|
|
|
but with only one overlapping the load. */
|
|
|
|
if ((ld_dst == B11_8) + (ld_dst == B7_4) != 1 || mv_src >= 0) {
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
op_opc = INDEX_op_setcond_i32; /* placeholder */
|
|
|
|
op_src = (ld_dst == B11_8 ? B7_4 : B11_8);
|
|
|
|
op_arg = REG(op_src);
|
|
|
|
|
|
|
|
NEXT_INSN;
|
|
|
|
switch (ctx->opcode & 0xff00) {
|
|
|
|
case 0x8b00: /* bf label */
|
|
|
|
case 0x8f00: /* bf/s label */
|
|
|
|
if (pc + (i + 1 + B7_0s) * 2 != pc_end) {
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
if ((ctx->opcode & 0xff00) == 0x8b00) { /* bf label */
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
/* We're looking to unconditionally modify Rn with the
|
|
|
|
result of the comparison, within the delay slot of
|
|
|
|
the branch. This is used by older gcc. */
|
|
|
|
NEXT_INSN;
|
|
|
|
if ((ctx->opcode & 0xf0ff) == 0x0029) { /* movt Rn */
|
|
|
|
mt_dst = B11_8;
|
|
|
|
} else {
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x2008: /* tst Rm,Rn */
|
|
|
|
/* Looking for a compare-and-swap against zero. */
|
|
|
|
if (ld_dst != B11_8 || ld_dst != B7_4 || mv_src >= 0) {
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
op_opc = INDEX_op_setcond_i32;
|
|
|
|
op_arg = tcg_const_i32(0);
|
|
|
|
|
|
|
|
NEXT_INSN;
|
|
|
|
if ((ctx->opcode & 0xff00) != 0x8900 /* bt label */
|
|
|
|
|| pc + (i + 1 + B7_0s) * 2 != pc_end) {
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
/* Put back and re-examine as store. */
|
|
|
|
--i;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Expect the store.
|
|
|
|
*/
|
|
|
|
/* The store must be the last insn. */
|
|
|
|
if (i != max_insns - 1) {
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
NEXT_INSN;
|
|
|
|
switch (ctx->opcode & 0xf00f) {
|
|
|
|
case 0x2000: /* mov.b Rm,@Rn */
|
|
|
|
st_mop = MO_UB;
|
|
|
|
break;
|
|
|
|
case 0x2001: /* mov.w Rm,@Rn */
|
|
|
|
st_mop = MO_UW;
|
|
|
|
break;
|
|
|
|
case 0x2002: /* mov.l Rm,@Rn */
|
|
|
|
st_mop = MO_UL;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
/* The store must match the load. */
|
|
|
|
if (ld_adr != B11_8 || st_mop != (ld_mop & MO_SIZE)) {
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
st_src = B7_4;
|
|
|
|
|
|
|
|
#undef NEXT_INSN
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Emit the operation.
|
|
|
|
*/
|
|
|
|
tcg_gen_insn_start(pc, ctx->envflags);
|
|
|
|
switch (op_opc) {
|
|
|
|
case -1:
|
|
|
|
/* No operation found. Look for exchange pattern. */
|
|
|
|
if (st_src == ld_dst || mv_src >= 0) {
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
tcg_gen_atomic_xchg_i32(REG(ld_dst), REG(ld_adr), REG(st_src),
|
|
|
|
ctx->memidx, ld_mop);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case INDEX_op_add_i32:
|
|
|
|
if (op_dst != st_src) {
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
if (op_dst == ld_dst && st_mop == MO_UL) {
|
|
|
|
tcg_gen_atomic_add_fetch_i32(REG(ld_dst), REG(ld_adr),
|
|
|
|
op_arg, ctx->memidx, ld_mop);
|
|
|
|
} else {
|
|
|
|
tcg_gen_atomic_fetch_add_i32(REG(ld_dst), REG(ld_adr),
|
|
|
|
op_arg, ctx->memidx, ld_mop);
|
|
|
|
if (op_dst != ld_dst) {
|
|
|
|
/* Note that mop sizes < 4 cannot use add_fetch
|
|
|
|
because it won't carry into the higher bits. */
|
|
|
|
tcg_gen_add_i32(REG(op_dst), REG(ld_dst), op_arg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case INDEX_op_and_i32:
|
|
|
|
if (op_dst != st_src) {
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
if (op_dst == ld_dst) {
|
|
|
|
tcg_gen_atomic_and_fetch_i32(REG(ld_dst), REG(ld_adr),
|
|
|
|
op_arg, ctx->memidx, ld_mop);
|
|
|
|
} else {
|
|
|
|
tcg_gen_atomic_fetch_and_i32(REG(ld_dst), REG(ld_adr),
|
|
|
|
op_arg, ctx->memidx, ld_mop);
|
|
|
|
tcg_gen_and_i32(REG(op_dst), REG(ld_dst), op_arg);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case INDEX_op_or_i32:
|
|
|
|
if (op_dst != st_src) {
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
if (op_dst == ld_dst) {
|
|
|
|
tcg_gen_atomic_or_fetch_i32(REG(ld_dst), REG(ld_adr),
|
|
|
|
op_arg, ctx->memidx, ld_mop);
|
|
|
|
} else {
|
|
|
|
tcg_gen_atomic_fetch_or_i32(REG(ld_dst), REG(ld_adr),
|
|
|
|
op_arg, ctx->memidx, ld_mop);
|
|
|
|
tcg_gen_or_i32(REG(op_dst), REG(ld_dst), op_arg);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case INDEX_op_xor_i32:
|
|
|
|
if (op_dst != st_src) {
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
if (op_dst == ld_dst) {
|
|
|
|
tcg_gen_atomic_xor_fetch_i32(REG(ld_dst), REG(ld_adr),
|
|
|
|
op_arg, ctx->memidx, ld_mop);
|
|
|
|
} else {
|
|
|
|
tcg_gen_atomic_fetch_xor_i32(REG(ld_dst), REG(ld_adr),
|
|
|
|
op_arg, ctx->memidx, ld_mop);
|
|
|
|
tcg_gen_xor_i32(REG(op_dst), REG(ld_dst), op_arg);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case INDEX_op_setcond_i32:
|
|
|
|
if (st_src == ld_dst) {
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
tcg_gen_atomic_cmpxchg_i32(REG(ld_dst), REG(ld_adr), op_arg,
|
|
|
|
REG(st_src), ctx->memidx, ld_mop);
|
|
|
|
tcg_gen_setcond_i32(TCG_COND_EQ, cpu_sr_t, REG(ld_dst), op_arg);
|
|
|
|
if (mt_dst >= 0) {
|
|
|
|
tcg_gen_mov_i32(REG(mt_dst), cpu_sr_t);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
g_assert_not_reached();
|
|
|
|
}
|
|
|
|
|
|
|
|
/* If op_src is not a valid register, then op_arg was a constant. */
|
|
|
|
if (op_src < 0) {
|
|
|
|
tcg_temp_free_i32(op_arg);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* The entire region has been translated. */
|
|
|
|
ctx->envflags &= ~GUSA_MASK;
|
|
|
|
ctx->pc = pc_end;
|
|
|
|
return max_insns;
|
|
|
|
|
|
|
|
fail:
|
2017-07-18 23:02:31 +03:00
|
|
|
qemu_log_mask(LOG_UNIMP, "Unrecognized gUSA sequence %08x-%08x\n",
|
|
|
|
pc, pc_end);
|
|
|
|
|
|
|
|
/* Restart with the EXCLUSIVE bit set, within a TB run via
|
|
|
|
cpu_exec_step_atomic holding the exclusive lock. */
|
|
|
|
tcg_gen_insn_start(pc, ctx->envflags);
|
|
|
|
ctx->envflags |= GUSA_EXCLUSIVE;
|
|
|
|
gen_save_cpu_state(ctx, false);
|
|
|
|
gen_helper_exclusive(cpu_env);
|
|
|
|
ctx->bstate = BS_EXCP;
|
|
|
|
|
|
|
|
/* We're not executing an instruction, but we must report one for the
|
|
|
|
purposes of accounting within the TB. We might as well report the
|
|
|
|
entire region consumed via ctx->pc so that it's immediately available
|
|
|
|
in the disassembly dump. */
|
|
|
|
ctx->pc = pc_end;
|
|
|
|
return 1;
|
2006-04-28 01:07:38 +04:00
|
|
|
}
|
2017-07-18 23:02:31 +03:00
|
|
|
#endif
|
2006-04-28 01:07:38 +04:00
|
|
|
|
2017-07-14 11:17:35 +03:00
|
|
|
void gen_intermediate_code(CPUState *cs, struct TranslationBlock *tb)
|
2006-04-28 01:07:38 +04:00
|
|
|
{
|
2017-07-14 11:17:35 +03:00
|
|
|
CPUSH4State *env = cs->env_ptr;
|
2006-04-28 01:07:38 +04:00
|
|
|
DisasContext ctx;
|
|
|
|
target_ulong pc_start;
|
2008-06-29 05:03:05 +04:00
|
|
|
int num_insns;
|
|
|
|
int max_insns;
|
2006-04-28 01:07:38 +04:00
|
|
|
|
|
|
|
pc_start = tb->pc;
|
|
|
|
ctx.pc = pc_start;
|
2017-05-02 00:20:43 +03:00
|
|
|
ctx.tbflags = (uint32_t)tb->flags;
|
2017-07-18 23:02:28 +03:00
|
|
|
ctx.envflags = tb->flags & TB_FLAG_ENVFLAGS_MASK;
|
2007-12-02 09:10:04 +03:00
|
|
|
ctx.bstate = BS_NONE;
|
2017-05-02 00:20:43 +03:00
|
|
|
ctx.memidx = (ctx.tbflags & (1u << SR_MD)) == 0 ? 1 : 0;
|
2006-06-17 22:48:31 +04:00
|
|
|
/* We don't know if the delayed pc came from a dynamic or static branch,
|
|
|
|
so assume it is a dynamic branch. */
|
2007-12-02 09:10:04 +03:00
|
|
|
ctx.delayed_pc = -1; /* use delayed pc from env pointer */
|
2006-04-28 01:07:38 +04:00
|
|
|
ctx.tb = tb;
|
2013-06-21 22:20:45 +04:00
|
|
|
ctx.singlestep_enabled = cs->singlestep_enabled;
|
2008-12-13 21:57:37 +03:00
|
|
|
ctx.features = env->features;
|
2017-05-02 00:20:43 +03:00
|
|
|
ctx.has_movcal = (ctx.tbflags & TB_FLAG_PENDING_MOVCA);
|
2017-07-18 23:02:35 +03:00
|
|
|
ctx.gbank = ((ctx.tbflags & (1 << SR_MD)) &&
|
|
|
|
(ctx.tbflags & (1 << SR_RB))) * 0x10;
|
2017-07-18 23:02:38 +03:00
|
|
|
ctx.fbank = ctx.tbflags & FPSCR_FR ? 0x10 : 0;
|
2006-04-28 01:07:38 +04:00
|
|
|
|
2008-06-29 05:03:05 +04:00
|
|
|
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
|
|
|
}
|
2017-07-18 23:02:27 +03:00
|
|
|
max_insns = MIN(max_insns, TCG_MAX_INSNS);
|
|
|
|
|
|
|
|
/* Since the ISA is fixed-width, we can bound by the number
|
|
|
|
of instructions remaining on the page. */
|
|
|
|
num_insns = -(ctx.pc | TARGET_PAGE_MASK) / 2;
|
|
|
|
max_insns = MIN(max_insns, num_insns);
|
|
|
|
|
|
|
|
/* Single stepping means just that. */
|
|
|
|
if (ctx.singlestep_enabled || singlestep) {
|
|
|
|
max_insns = 1;
|
2015-09-01 00:34:41 +03:00
|
|
|
}
|
|
|
|
|
2014-11-26 13:40:05 +03:00
|
|
|
gen_tb_start(tb);
|
2017-07-18 23:02:27 +03:00
|
|
|
num_insns = 0;
|
|
|
|
|
2017-07-18 23:02:31 +03:00
|
|
|
#ifdef CONFIG_USER_ONLY
|
|
|
|
if (ctx.tbflags & GUSA_MASK) {
|
|
|
|
num_insns = decode_gusa(&ctx, env, &max_insns);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2017-07-18 23:02:27 +03:00
|
|
|
while (ctx.bstate == BS_NONE
|
|
|
|
&& num_insns < max_insns
|
|
|
|
&& !tcg_op_buf_full()) {
|
2017-05-02 00:20:43 +03:00
|
|
|
tcg_gen_insn_start(ctx.pc, ctx.envflags);
|
2015-09-18 00:25:46 +03:00
|
|
|
num_insns++;
|
2015-08-29 22:59:29 +03:00
|
|
|
|
2015-09-18 01:58:10 +03:00
|
|
|
if (unlikely(cpu_breakpoint_test(cs, ctx.pc, BP_ANY))) {
|
|
|
|
/* We have hit a breakpoint - make sure PC is up-to-date */
|
2017-05-02 00:20:43 +03:00
|
|
|
gen_save_cpu_state(&ctx, true);
|
2015-09-18 01:58:10 +03:00
|
|
|
gen_helper_debug(cpu_env);
|
2017-05-02 00:20:43 +03:00
|
|
|
ctx.bstate = BS_EXCP;
|
2015-10-14 01:07:49 +03:00
|
|
|
/* The address covered by the breakpoint must be included in
|
|
|
|
[tb->pc, tb->pc + tb->size) in order to for it to be
|
|
|
|
properly cleared -- thus we increment the PC here so that
|
|
|
|
the logic setting tb->size below does the right thing. */
|
|
|
|
ctx.pc += 2;
|
2015-09-18 01:58:10 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2012-09-02 14:37:06 +04:00
|
|
|
ctx.opcode = cpu_lduw_code(env, ctx.pc);
|
2006-04-28 01:07:38 +04:00
|
|
|
decode_opc(&ctx);
|
|
|
|
ctx.pc += 2;
|
|
|
|
}
|
2017-07-18 23:02:27 +03:00
|
|
|
if (tb->cflags & CF_LAST_IO) {
|
2008-06-29 05:03:05 +04:00
|
|
|
gen_io_end();
|
2017-07-18 23:02:27 +03:00
|
|
|
}
|
2017-07-18 23:02:31 +03:00
|
|
|
|
|
|
|
if (ctx.tbflags & GUSA_EXCLUSIVE) {
|
|
|
|
/* Ending the region of exclusivity. Clear the bits. */
|
|
|
|
ctx.envflags &= ~GUSA_MASK;
|
|
|
|
}
|
|
|
|
|
2013-06-21 22:20:45 +04:00
|
|
|
if (cs->singlestep_enabled) {
|
2017-05-02 00:20:43 +03:00
|
|
|
gen_save_cpu_state(&ctx, true);
|
2012-09-02 14:37:06 +04:00
|
|
|
gen_helper_debug(cpu_env);
|
2007-12-02 09:10:04 +03:00
|
|
|
} else {
|
|
|
|
switch (ctx.bstate) {
|
|
|
|
case BS_STOP:
|
2017-05-02 00:20:43 +03:00
|
|
|
gen_save_cpu_state(&ctx, true);
|
2017-05-02 00:20:43 +03:00
|
|
|
tcg_gen_exit_tb(0);
|
|
|
|
break;
|
2007-12-02 09:10:04 +03:00
|
|
|
case BS_NONE:
|
2017-05-02 00:20:43 +03:00
|
|
|
gen_save_cpu_state(&ctx, false);
|
2007-12-02 09:10:04 +03:00
|
|
|
gen_goto_tb(&ctx, 0, ctx.pc);
|
|
|
|
break;
|
|
|
|
case BS_EXCP:
|
2017-05-02 00:20:43 +03:00
|
|
|
/* fall through */
|
2007-12-02 09:10:04 +03:00
|
|
|
case BS_BRANCH:
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2006-04-28 01:07:38 +04:00
|
|
|
}
|
2007-12-02 09:10:04 +03:00
|
|
|
|
2013-02-22 22:10:05 +04:00
|
|
|
gen_tb_end(tb, num_insns);
|
2014-03-31 01:50:30 +04:00
|
|
|
|
2015-09-02 06:01:40 +03:00
|
|
|
tb->size = ctx.pc - pc_start;
|
|
|
|
tb->icount = num_insns;
|
2006-04-28 01:07:38 +04:00
|
|
|
|
|
|
|
#ifdef DEBUG_DISAS
|
2016-04-20 21:39:35 +03:00
|
|
|
if (qemu_loglevel_mask(CPU_LOG_TB_IN_ASM)
|
|
|
|
&& qemu_log_in_addr_range(pc_start)) {
|
2016-09-23 01:17:10 +03:00
|
|
|
qemu_log_lock();
|
2009-01-16 01:34:14 +03:00
|
|
|
qemu_log("IN:\n"); /* , lookup_symbol(pc_start)); */
|
2015-05-25 00:20:41 +03:00
|
|
|
log_target_disas(cs, pc_start, ctx.pc - pc_start, 0);
|
2009-01-16 01:34:14 +03:00
|
|
|
qemu_log("\n");
|
2016-09-23 01:17:10 +03:00
|
|
|
qemu_log_unlock();
|
2006-04-28 01:07:38 +04:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2015-09-02 01:51:12 +03:00
|
|
|
void restore_state_to_opc(CPUSH4State *env, TranslationBlock *tb,
|
|
|
|
target_ulong *data)
|
2008-04-28 04:32:32 +04:00
|
|
|
{
|
2015-09-02 01:51:12 +03:00
|
|
|
env->pc = data[0];
|
|
|
|
env->flags = data[1];
|
2017-05-02 00:20:43 +03:00
|
|
|
/* Theoretically delayed_pc should also be restored. In practice the
|
|
|
|
branch instruction is re-executed after exception, so the delayed
|
|
|
|
branch target will be recomputed. */
|
2008-04-28 04:32:32 +04:00
|
|
|
}
|