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
|
|
|
|
//#define SH4_SINGLE_STEP
|
|
|
|
|
|
|
|
#include "cpu.h"
|
2012-10-24 13:12:21 +04:00
|
|
|
#include "disas/disas.h"
|
2008-02-01 13:50:11 +03:00
|
|
|
#include "tcg-op.h"
|
2006-04-28 01:07:38 +04:00
|
|
|
|
2008-11-17 17:43:54 +03:00
|
|
|
#include "helper.h"
|
|
|
|
#define GEN_HELPER 1
|
|
|
|
#include "helper.h"
|
|
|
|
|
2006-04-28 01:07:38 +04:00
|
|
|
typedef struct DisasContext {
|
|
|
|
struct TranslationBlock *tb;
|
|
|
|
target_ulong pc;
|
|
|
|
uint16_t opcode;
|
|
|
|
uint32_t flags;
|
2007-12-02 09:10:04 +03:00
|
|
|
int bstate;
|
2006-04-28 01:07:38 +04:00
|
|
|
int memidx;
|
|
|
|
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
|
2012-09-16 15:12:21 +04:00
|
|
|
#define IS_USER(ctx) (!(ctx->flags & 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 */
|
2008-11-17 17:43:54 +03:00
|
|
|
static TCGv_ptr cpu_env;
|
2008-08-29 04:48:50 +04:00
|
|
|
static TCGv cpu_gregs[24];
|
2008-08-29 20:32:18 +04:00
|
|
|
static TCGv cpu_pc, cpu_sr, cpu_ssr, cpu_spc, cpu_gbr;
|
|
|
|
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 */
|
|
|
|
static TCGv cpu_flags, cpu_delayed_pc;
|
2008-08-29 04:48:50 +04:00
|
|
|
|
2010-03-31 18:54:11 +04:00
|
|
|
static uint32_t gen_opc_hflags[OPC_BUF_SIZE];
|
|
|
|
|
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
|
|
|
|
2008-06-29 05:03:05 +04:00
|
|
|
if (done_init)
|
|
|
|
return;
|
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");
|
2008-08-29 04:48:50 +04:00
|
|
|
|
|
|
|
for (i = 0; i < 24; i++)
|
2008-11-17 17:43:54 +03:00
|
|
|
cpu_gregs[i] = tcg_global_mem_new_i32(TCG_AREG0,
|
2012-03-14 04:38:22 +04:00
|
|
|
offsetof(CPUSH4State, gregs[i]),
|
2008-11-19 21:00:47 +03:00
|
|
|
gregnames[i]);
|
2008-08-29 01:02:00 +04:00
|
|
|
|
2008-11-17 17:43:54 +03:00
|
|
|
cpu_pc = tcg_global_mem_new_i32(TCG_AREG0,
|
2012-03-14 04:38:22 +04:00
|
|
|
offsetof(CPUSH4State, pc), "PC");
|
2008-11-17 17:43:54 +03:00
|
|
|
cpu_sr = tcg_global_mem_new_i32(TCG_AREG0,
|
2012-03-14 04:38:22 +04:00
|
|
|
offsetof(CPUSH4State, sr), "SR");
|
2008-11-17 17:43:54 +03:00
|
|
|
cpu_ssr = tcg_global_mem_new_i32(TCG_AREG0,
|
2012-03-14 04:38:22 +04:00
|
|
|
offsetof(CPUSH4State, ssr), "SSR");
|
2008-11-17 17:43:54 +03:00
|
|
|
cpu_spc = tcg_global_mem_new_i32(TCG_AREG0,
|
2012-03-14 04:38:22 +04:00
|
|
|
offsetof(CPUSH4State, spc), "SPC");
|
2008-11-17 17:43:54 +03:00
|
|
|
cpu_gbr = tcg_global_mem_new_i32(TCG_AREG0,
|
2012-03-14 04:38:22 +04:00
|
|
|
offsetof(CPUSH4State, gbr), "GBR");
|
2008-11-17 17:43:54 +03:00
|
|
|
cpu_vbr = tcg_global_mem_new_i32(TCG_AREG0,
|
2012-03-14 04:38:22 +04:00
|
|
|
offsetof(CPUSH4State, vbr), "VBR");
|
2008-11-17 17:43:54 +03:00
|
|
|
cpu_sgr = tcg_global_mem_new_i32(TCG_AREG0,
|
2012-03-14 04:38:22 +04:00
|
|
|
offsetof(CPUSH4State, sgr), "SGR");
|
2008-11-17 17:43:54 +03:00
|
|
|
cpu_dbr = tcg_global_mem_new_i32(TCG_AREG0,
|
2012-03-14 04:38:22 +04:00
|
|
|
offsetof(CPUSH4State, dbr), "DBR");
|
2008-11-17 17:43:54 +03:00
|
|
|
cpu_mach = tcg_global_mem_new_i32(TCG_AREG0,
|
2012-03-14 04:38:22 +04:00
|
|
|
offsetof(CPUSH4State, mach), "MACH");
|
2008-11-17 17:43:54 +03:00
|
|
|
cpu_macl = tcg_global_mem_new_i32(TCG_AREG0,
|
2012-03-14 04:38:22 +04:00
|
|
|
offsetof(CPUSH4State, macl), "MACL");
|
2008-11-17 17:43:54 +03:00
|
|
|
cpu_pr = tcg_global_mem_new_i32(TCG_AREG0,
|
2012-03-14 04:38:22 +04:00
|
|
|
offsetof(CPUSH4State, pr), "PR");
|
2008-11-17 17:43:54 +03:00
|
|
|
cpu_fpscr = tcg_global_mem_new_i32(TCG_AREG0,
|
2012-03-14 04:38:22 +04:00
|
|
|
offsetof(CPUSH4State, fpscr), "FPSCR");
|
2008-11-17 17:43:54 +03:00
|
|
|
cpu_fpul = tcg_global_mem_new_i32(TCG_AREG0,
|
2012-03-14 04:38:22 +04:00
|
|
|
offsetof(CPUSH4State, fpul), "FPUL");
|
2008-11-17 17:43:54 +03:00
|
|
|
|
|
|
|
cpu_flags = tcg_global_mem_new_i32(TCG_AREG0,
|
2012-03-14 04:38:22 +04:00
|
|
|
offsetof(CPUSH4State, flags), "_flags_");
|
2008-11-17 17:43:54 +03:00
|
|
|
cpu_delayed_pc = tcg_global_mem_new_i32(TCG_AREG0,
|
2012-03-14 04:38:22 +04:00
|
|
|
offsetof(CPUSH4State, delayed_pc),
|
2008-11-17 17:43:54 +03:00
|
|
|
"_delayed_pc_");
|
2009-03-02 20:13:21 +03:00
|
|
|
cpu_ldst = tcg_global_mem_new_i32(TCG_AREG0,
|
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++)
|
|
|
|
cpu_fregs[i] = tcg_global_mem_new_i32(TCG_AREG0,
|
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",
|
|
|
|
env->pc, env->sr, 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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void gen_goto_tb(DisasContext * ctx, int n, target_ulong dest)
|
|
|
|
{
|
|
|
|
TranslationBlock *tb;
|
|
|
|
tb = ctx->tb;
|
|
|
|
|
|
|
|
if ((tb->pc & TARGET_PAGE_MASK) == (dest & TARGET_PAGE_MASK) &&
|
|
|
|
!ctx->singlestep_enabled) {
|
|
|
|
/* Use a direct jump if in same page and singlestep not enabled */
|
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);
|
2013-08-21 02:53:10 +04:00
|
|
|
tcg_gen_exit_tb((uintptr_t)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);
|
2008-02-01 13:50:11 +03:00
|
|
|
if (ctx->singlestep_enabled)
|
2012-09-02 14:37:06 +04:00
|
|
|
gen_helper_debug(cpu_env);
|
2008-02-01 13:50:11 +03:00
|
|
|
tcg_gen_exit_tb(0);
|
2006-04-28 01:07:38 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void gen_jump(DisasContext * ctx)
|
|
|
|
{
|
|
|
|
if (ctx->delayed_pc == (uint32_t) - 1) {
|
|
|
|
/* 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);
|
2006-04-28 01:07:38 +04:00
|
|
|
if (ctx->singlestep_enabled)
|
2012-09-02 14:37:06 +04:00
|
|
|
gen_helper_debug(cpu_env);
|
2008-02-01 13:50:11 +03:00
|
|
|
tcg_gen_exit_tb(0);
|
2006-04-28 01:07:38 +04:00
|
|
|
} else {
|
|
|
|
gen_goto_tb(ctx, 0, ctx->delayed_pc);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-08-30 02:32:32 +04:00
|
|
|
static inline void gen_branch_slot(uint32_t delayed_pc, int t)
|
|
|
|
{
|
2008-09-01 17:09:21 +04:00
|
|
|
TCGv sr;
|
2008-08-30 02:32:32 +04:00
|
|
|
int label = gen_new_label();
|
|
|
|
tcg_gen_movi_i32(cpu_delayed_pc, delayed_pc);
|
2008-11-17 17:43:54 +03:00
|
|
|
sr = tcg_temp_new();
|
2008-09-01 17:09:21 +04:00
|
|
|
tcg_gen_andi_i32(sr, cpu_sr, SR_T);
|
2011-01-14 22:39:18 +03:00
|
|
|
tcg_gen_brcondi_i32(t ? TCG_COND_EQ:TCG_COND_NE, sr, 0, label);
|
2008-08-30 02:32:32 +04:00
|
|
|
tcg_gen_ori_i32(cpu_flags, cpu_flags, DELAY_SLOT_TRUE);
|
|
|
|
gen_set_label(label);
|
|
|
|
}
|
|
|
|
|
2006-04-28 01:07:38 +04:00
|
|
|
/* Immediate conditional jump (bt or bf) */
|
|
|
|
static void gen_conditional_jump(DisasContext * ctx,
|
|
|
|
target_ulong ift, target_ulong ifnott)
|
|
|
|
{
|
|
|
|
int l1;
|
2008-09-01 17:09:21 +04:00
|
|
|
TCGv sr;
|
2006-04-28 01:07:38 +04:00
|
|
|
|
|
|
|
l1 = gen_new_label();
|
2008-11-17 17:43:54 +03:00
|
|
|
sr = tcg_temp_new();
|
2008-09-01 17:09:21 +04:00
|
|
|
tcg_gen_andi_i32(sr, cpu_sr, SR_T);
|
2011-01-14 22:39:18 +03:00
|
|
|
tcg_gen_brcondi_i32(TCG_COND_NE, sr, 0, l1);
|
2006-04-28 01:07:38 +04:00
|
|
|
gen_goto_tb(ctx, 0, ifnott);
|
|
|
|
gen_set_label(l1);
|
|
|
|
gen_goto_tb(ctx, 1, ift);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Delayed conditional jump (bt or bf) */
|
|
|
|
static void gen_delayed_conditional_jump(DisasContext * ctx)
|
|
|
|
{
|
|
|
|
int l1;
|
2008-09-01 17:09:21 +04:00
|
|
|
TCGv ds;
|
2006-04-28 01:07:38 +04:00
|
|
|
|
|
|
|
l1 = gen_new_label();
|
2008-11-17 17:43:54 +03:00
|
|
|
ds = tcg_temp_new();
|
2008-09-01 17:09:21 +04:00
|
|
|
tcg_gen_andi_i32(ds, cpu_flags, DELAY_SLOT_TRUE);
|
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);
|
2008-08-30 02:32:32 +04:00
|
|
|
tcg_gen_andi_i32(cpu_flags, cpu_flags, ~DELAY_SLOT_TRUE);
|
2006-06-18 23:12:54 +04:00
|
|
|
gen_jump(ctx);
|
2006-04-28 01:07:38 +04:00
|
|
|
}
|
|
|
|
|
2008-08-30 00:12:18 +04:00
|
|
|
static inline void gen_cmp(int cond, TCGv t0, TCGv t1)
|
|
|
|
{
|
2011-01-14 22:39:18 +03:00
|
|
|
TCGv t;
|
|
|
|
|
|
|
|
t = tcg_temp_new();
|
|
|
|
tcg_gen_setcond_i32(cond, t, t1, t0);
|
|
|
|
tcg_gen_andi_i32(cpu_sr, cpu_sr, ~SR_T);
|
|
|
|
tcg_gen_or_i32(cpu_sr, cpu_sr, t);
|
|
|
|
|
|
|
|
tcg_temp_free(t);
|
2008-08-30 00:12:18 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline void gen_cmp_imm(int cond, TCGv t0, int32_t imm)
|
|
|
|
{
|
2011-01-14 22:39:18 +03:00
|
|
|
TCGv t;
|
|
|
|
|
|
|
|
t = tcg_temp_new();
|
|
|
|
tcg_gen_setcondi_i32(cond, t, t0, imm);
|
|
|
|
tcg_gen_andi_i32(cpu_sr, cpu_sr, ~SR_T);
|
|
|
|
tcg_gen_or_i32(cpu_sr, cpu_sr, t);
|
|
|
|
|
|
|
|
tcg_temp_free(t);
|
2008-08-30 00:12:18 +04:00
|
|
|
}
|
|
|
|
|
2008-08-30 02:32:32 +04:00
|
|
|
static inline void gen_store_flags(uint32_t flags)
|
|
|
|
{
|
|
|
|
tcg_gen_andi_i32(cpu_flags, cpu_flags, DELAY_SLOT_TRUE);
|
|
|
|
tcg_gen_ori_i32(cpu_flags, cpu_flags, flags);
|
|
|
|
}
|
|
|
|
|
2008-09-01 17:09:06 +04:00
|
|
|
static inline void gen_copy_bit_i32(TCGv t0, int p0, TCGv t1, int p1)
|
|
|
|
{
|
2008-11-17 17:43:54 +03:00
|
|
|
TCGv tmp = tcg_temp_new();
|
2008-09-01 17:09:06 +04:00
|
|
|
|
|
|
|
p0 &= 0x1f;
|
|
|
|
p1 &= 0x1f;
|
|
|
|
|
|
|
|
tcg_gen_andi_i32(tmp, t1, (1 << p1));
|
|
|
|
tcg_gen_andi_i32(t0, t0, ~(1 << p0));
|
|
|
|
if (p0 < p1)
|
|
|
|
tcg_gen_shri_i32(tmp, tmp, p1 - p0);
|
|
|
|
else if (p0 > p1)
|
|
|
|
tcg_gen_shli_i32(tmp, tmp, p0 - p1);
|
|
|
|
tcg_gen_or_i32(t0, t0, tmp);
|
|
|
|
|
|
|
|
tcg_temp_free(tmp);
|
|
|
|
}
|
|
|
|
|
2008-11-17 17:43:54 +03:00
|
|
|
static inline void gen_load_fpr64(TCGv_i64 t, int reg)
|
2008-09-02 02:11:56 +04:00
|
|
|
{
|
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
|
|
|
}
|
|
|
|
|
2008-11-17 17:43:54 +03:00
|
|
|
static inline void gen_store_fpr64 (TCGv_i64 t, int reg)
|
2008-09-02 02:11:56 +04:00
|
|
|
{
|
2008-11-17 17:43:54 +03:00
|
|
|
TCGv_i32 tmp = tcg_temp_new_i32();
|
2008-09-02 02:11:56 +04:00
|
|
|
tcg_gen_trunc_i64_i32(tmp, t);
|
2008-11-19 21:00:47 +03:00
|
|
|
tcg_gen_mov_i32(cpu_fregs[reg + 1], tmp);
|
2008-09-02 02:11:56 +04:00
|
|
|
tcg_gen_shri_i64(t, t, 32);
|
|
|
|
tcg_gen_trunc_i64_i32(tmp, t);
|
2008-11-19 21:00:47 +03:00
|
|
|
tcg_gen_mov_i32(cpu_fregs[reg], tmp);
|
2008-11-17 17:43:54 +03:00
|
|
|
tcg_temp_free_i32(tmp);
|
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)
|
|
|
|
|
2012-09-16 15:12:21 +04:00
|
|
|
#define REG(x) ((x) < 8 && (ctx->flags & (SR_MD | SR_RB)) == (SR_MD | SR_RB) \
|
|
|
|
? (cpu_gregs[x + 16]) : (cpu_gregs[x]))
|
2006-04-28 01:07:38 +04:00
|
|
|
|
2012-09-16 15:12:21 +04:00
|
|
|
#define ALTREG(x) ((x) < 8 && (ctx->flags & (SR_MD | SR_RB)) != (SR_MD | SR_RB)\
|
2008-09-01 17:09:14 +04:00
|
|
|
? (cpu_gregs[x + 16]) : (cpu_gregs[x]))
|
2006-04-28 01:07:38 +04:00
|
|
|
|
2012-09-16 15:12:21 +04:00
|
|
|
#define FREG(x) (ctx->flags & FPSCR_FR ? (x) ^ 0x10 : (x))
|
2007-05-13 20:33:43 +04:00
|
|
|
#define XHACK(x) ((((x) & 1 ) << 4) | ((x) & 0xe))
|
2012-09-16 15:12:21 +04:00
|
|
|
#define XREG(x) (ctx->flags & FPSCR_FR ? XHACK(x) ^ 0x10 : XHACK(x))
|
2007-06-22 15:12:01 +04:00
|
|
|
#define DREG(x) FREG(x) /* Assumes lsb of (x) is always 0 */
|
2006-06-14 19:02:05 +04:00
|
|
|
|
2006-04-28 01:07:38 +04:00
|
|
|
#define CHECK_NOT_DELAY_SLOT \
|
2008-12-08 01:46:31 +03:00
|
|
|
if (ctx->flags & (DELAY_SLOT | DELAY_SLOT_CONDITIONAL)) \
|
|
|
|
{ \
|
2012-09-16 15:12:21 +04:00
|
|
|
tcg_gen_movi_i32(cpu_pc, ctx->pc); \
|
2012-09-02 14:37:06 +04:00
|
|
|
gen_helper_raise_slot_illegal_instruction(cpu_env); \
|
2012-09-16 15:12:21 +04:00
|
|
|
ctx->bstate = BS_BRANCH; \
|
2008-12-08 01:46:31 +03:00
|
|
|
return; \
|
|
|
|
}
|
2006-04-28 01:07:38 +04:00
|
|
|
|
2011-01-11 18:13:34 +03:00
|
|
|
#define CHECK_PRIVILEGED \
|
|
|
|
if (IS_USER(ctx)) { \
|
2012-09-16 15:12:21 +04:00
|
|
|
tcg_gen_movi_i32(cpu_pc, ctx->pc); \
|
2011-01-11 18:13:34 +03:00
|
|
|
if (ctx->flags & (DELAY_SLOT | DELAY_SLOT_CONDITIONAL)) { \
|
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 { \
|
2012-09-02 14:37:06 +04:00
|
|
|
gen_helper_raise_illegal_instruction(cpu_env); \
|
2011-01-11 18:13:34 +03:00
|
|
|
} \
|
2012-09-16 15:12:21 +04:00
|
|
|
ctx->bstate = BS_BRANCH; \
|
2011-01-11 18:13:34 +03:00
|
|
|
return; \
|
2008-09-15 12:49:15 +04:00
|
|
|
}
|
|
|
|
|
2008-12-08 01:46:31 +03:00
|
|
|
#define CHECK_FPU_ENABLED \
|
|
|
|
if (ctx->flags & SR_FD) { \
|
2012-09-16 15:12:21 +04:00
|
|
|
tcg_gen_movi_i32(cpu_pc, ctx->pc); \
|
2008-12-08 01:46:31 +03:00
|
|
|
if (ctx->flags & (DELAY_SLOT | DELAY_SLOT_CONDITIONAL)) { \
|
2012-09-02 14:37:06 +04:00
|
|
|
gen_helper_raise_slot_fpu_disable(cpu_env); \
|
2008-12-08 01:46:31 +03:00
|
|
|
} else { \
|
2012-09-02 14:37:06 +04:00
|
|
|
gen_helper_raise_fpu_disable(cpu_env); \
|
2008-12-08 01:46:31 +03:00
|
|
|
} \
|
2012-09-16 15:12:21 +04:00
|
|
|
ctx->bstate = BS_BRANCH; \
|
2008-12-08 01:46:31 +03:00
|
|
|
return; \
|
|
|
|
}
|
|
|
|
|
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 */
|
2008-08-29 20:32:18 +04:00
|
|
|
tcg_gen_andi_i32(cpu_sr, cpu_sr, ~(SR_M | SR_Q | SR_T));
|
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);
|
2006-04-28 01:07:38 +04:00
|
|
|
ctx->flags |= DELAY_SLOT;
|
|
|
|
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 */
|
2008-08-29 20:32:18 +04:00
|
|
|
tcg_gen_andi_i32(cpu_sr, cpu_sr, ~SR_S);
|
2006-04-28 01:07:38 +04:00
|
|
|
return;
|
|
|
|
case 0x0008: /* clrt */
|
2012-09-16 15:12:20 +04:00
|
|
|
tcg_gen_andi_i32(cpu_sr, cpu_sr, ~SR_T);
|
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
|
|
|
|
tcg_gen_mov_i32(cpu_sr, cpu_ssr);
|
|
|
|
tcg_gen_mov_i32(cpu_delayed_pc, cpu_spc);
|
2006-04-28 01:07:38 +04:00
|
|
|
ctx->flags |= DELAY_SLOT;
|
|
|
|
ctx->delayed_pc = (uint32_t) - 1;
|
|
|
|
return;
|
|
|
|
case 0x0058: /* sets */
|
2008-08-29 20:32:18 +04:00
|
|
|
tcg_gen_ori_i32(cpu_sr, cpu_sr, SR_S);
|
2006-04-28 01:07:38 +04:00
|
|
|
return;
|
|
|
|
case 0x0018: /* sett */
|
2012-09-16 15:12:20 +04:00
|
|
|
tcg_gen_ori_i32(cpu_sr, cpu_sr, SR_T);
|
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 */
|
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 */
|
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;
|
|
|
|
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 */
|
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;
|
|
|
|
tcg_gen_movi_i32(cpu_delayed_pc, ctx->delayed_pc);
|
2006-04-28 01:07:38 +04:00
|
|
|
ctx->flags |= DELAY_SLOT;
|
|
|
|
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;
|
|
|
|
tcg_gen_movi_i32(cpu_delayed_pc, ctx->delayed_pc);
|
2006-04-28 01:07:38 +04:00
|
|
|
ctx->flags |= DELAY_SLOT;
|
|
|
|
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
|
|
|
{
|
2010-01-31 03:07:25 +03: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_andi_i32(high, REG(B7_4), 0xffff0000);
|
2008-11-17 17:43:54 +03:00
|
|
|
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);
|
2008-09-01 17:09:21 +04:00
|
|
|
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 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
|
|
|
{
|
|
|
|
TCGv t0, t1, t2;
|
|
|
|
t0 = tcg_temp_new();
|
|
|
|
tcg_gen_andi_i32(t0, cpu_sr, SR_T);
|
|
|
|
t1 = tcg_temp_new();
|
|
|
|
tcg_gen_add_i32(t1, REG(B7_4), REG(B11_8));
|
|
|
|
tcg_gen_add_i32(t0, t0, t1);
|
|
|
|
t2 = tcg_temp_new();
|
|
|
|
tcg_gen_setcond_i32(TCG_COND_GTU, t2, REG(B11_8), t1);
|
|
|
|
tcg_gen_setcond_i32(TCG_COND_GTU, t1, t1, t0);
|
|
|
|
tcg_gen_or_i32(t1, t1, t2);
|
|
|
|
tcg_temp_free(t2);
|
|
|
|
tcg_gen_andi_i32(cpu_sr, cpu_sr, ~SR_T);
|
|
|
|
tcg_gen_or_i32(cpu_sr, cpu_sr, t1);
|
|
|
|
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 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));
|
|
|
|
tcg_gen_andc_i32(t1, t1, t2);
|
|
|
|
tcg_temp_free(t2);
|
|
|
|
tcg_gen_shri_i32(t1, t1, 31);
|
|
|
|
tcg_gen_andi_i32(cpu_sr, cpu_sr, ~SR_T);
|
|
|
|
tcg_gen_or_i32(cpu_sr, cpu_sr, t1);
|
|
|
|
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 */
|
2008-09-01 17:09:14 +04:00
|
|
|
gen_cmp(TCG_COND_EQ, REG(B7_4), REG(B11_8));
|
2006-04-28 01:07:38 +04:00
|
|
|
return;
|
|
|
|
case 0x3003: /* cmp/ge Rm,Rn */
|
2008-09-01 17:09:14 +04:00
|
|
|
gen_cmp(TCG_COND_GE, REG(B7_4), REG(B11_8));
|
2006-04-28 01:07:38 +04:00
|
|
|
return;
|
|
|
|
case 0x3007: /* cmp/gt Rm,Rn */
|
2008-09-01 17:09:14 +04:00
|
|
|
gen_cmp(TCG_COND_GT, REG(B7_4), REG(B11_8));
|
2006-04-28 01:07:38 +04:00
|
|
|
return;
|
|
|
|
case 0x3006: /* cmp/hi Rm,Rn */
|
2008-09-01 17:09:14 +04:00
|
|
|
gen_cmp(TCG_COND_GTU, REG(B7_4), REG(B11_8));
|
2006-04-28 01:07:38 +04:00
|
|
|
return;
|
|
|
|
case 0x3002: /* cmp/hs Rm,Rn */
|
2008-09-01 17:09:14 +04:00
|
|
|
gen_cmp(TCG_COND_GEU, REG(B7_4), REG(B11_8));
|
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();
|
|
|
|
tcg_gen_andi_i32(cpu_sr, cpu_sr, ~SR_T);
|
2008-09-01 17:09:21 +04:00
|
|
|
tcg_gen_xor_i32(cmp1, REG(B7_4), REG(B11_8));
|
|
|
|
tcg_gen_andi_i32(cmp2, cmp1, 0xff000000);
|
2011-01-14 22:39:18 +03:00
|
|
|
tcg_gen_setcondi_i32(TCG_COND_EQ, cmp2, cmp2, 0);
|
|
|
|
tcg_gen_or_i32(cpu_sr, cpu_sr, cmp2);
|
2008-09-01 17:09:21 +04:00
|
|
|
tcg_gen_andi_i32(cmp2, cmp1, 0x00ff0000);
|
2011-01-14 22:39:18 +03:00
|
|
|
tcg_gen_setcondi_i32(TCG_COND_EQ, cmp2, cmp2, 0);
|
|
|
|
tcg_gen_or_i32(cpu_sr, cpu_sr, cmp2);
|
2008-09-01 17:09:21 +04:00
|
|
|
tcg_gen_andi_i32(cmp2, cmp1, 0x0000ff00);
|
2011-01-14 22:39:18 +03:00
|
|
|
tcg_gen_setcondi_i32(TCG_COND_EQ, cmp2, cmp2, 0);
|
|
|
|
tcg_gen_or_i32(cpu_sr, cpu_sr, cmp2);
|
2008-09-01 17:09:21 +04:00
|
|
|
tcg_gen_andi_i32(cmp2, cmp1, 0x000000ff);
|
2011-01-14 22:39:18 +03:00
|
|
|
tcg_gen_setcondi_i32(TCG_COND_EQ, cmp2, cmp2, 0);
|
|
|
|
tcg_gen_or_i32(cpu_sr, cpu_sr, cmp2);
|
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 */
|
2008-09-01 17:09:21 +04:00
|
|
|
{
|
|
|
|
gen_copy_bit_i32(cpu_sr, 8, REG(B11_8), 31); /* SR_Q */
|
|
|
|
gen_copy_bit_i32(cpu_sr, 9, REG(B7_4), 31); /* SR_M */
|
2008-11-17 17:43:54 +03:00
|
|
|
TCGv val = tcg_temp_new();
|
2008-09-01 17:09:21 +04:00
|
|
|
tcg_gen_xor_i32(val, REG(B7_4), REG(B11_8));
|
|
|
|
gen_copy_bit_i32(cpu_sr, 0, val, 31); /* SR_T */
|
|
|
|
tcg_temp_free(val);
|
|
|
|
}
|
2006-04-28 01:07:38 +04:00
|
|
|
return;
|
|
|
|
case 0x3004: /* div1 Rm,Rn */
|
2012-09-02 14:37:06 +04:00
|
|
|
gen_helper_div1(REG(B11_8), cpu_env, REG(B7_4), REG(B11_8));
|
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
|
|
|
{
|
|
|
|
TCGv t0, t1;
|
|
|
|
t0 = tcg_temp_new();
|
|
|
|
tcg_gen_neg_i32(t0, REG(B7_4));
|
|
|
|
t1 = tcg_temp_new();
|
|
|
|
tcg_gen_andi_i32(t1, cpu_sr, SR_T);
|
|
|
|
tcg_gen_sub_i32(REG(B11_8), t0, t1);
|
|
|
|
tcg_gen_andi_i32(cpu_sr, cpu_sr, ~SR_T);
|
2011-02-04 22:19:33 +03:00
|
|
|
tcg_gen_setcondi_i32(TCG_COND_GTU, t1, t0, 0);
|
2011-01-13 10:20:39 +03:00
|
|
|
tcg_gen_or_i32(cpu_sr, cpu_sr, t1);
|
2011-02-04 22:19:33 +03:00
|
|
|
tcg_gen_setcond_i32(TCG_COND_GTU, t1, REG(B11_8), t0);
|
2011-01-13 10:20:39 +03:00
|
|
|
tcg_gen_or_i32(cpu_sr, cpu_sr, t1);
|
|
|
|
tcg_temp_free(t0);
|
|
|
|
tcg_temp_free(t1);
|
|
|
|
}
|
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
|
|
|
{
|
|
|
|
int label1 = gen_new_label();
|
|
|
|
int label2 = gen_new_label();
|
|
|
|
int label3 = gen_new_label();
|
|
|
|
int label4 = gen_new_label();
|
2010-01-31 03:07:25 +03:00
|
|
|
TCGv shift;
|
2008-09-01 17:09:14 +04:00
|
|
|
tcg_gen_brcondi_i32(TCG_COND_LT, REG(B7_4), 0, label1);
|
2008-09-01 17:09:06 +04:00
|
|
|
/* Rm positive, shift to the left */
|
2010-01-31 03:07:25 +03:00
|
|
|
shift = tcg_temp_new();
|
2008-09-01 17:09:21 +04:00
|
|
|
tcg_gen_andi_i32(shift, REG(B7_4), 0x1f);
|
|
|
|
tcg_gen_shl_i32(REG(B11_8), REG(B11_8), shift);
|
2010-01-31 03:07:25 +03:00
|
|
|
tcg_temp_free(shift);
|
2008-09-01 17:09:06 +04:00
|
|
|
tcg_gen_br(label4);
|
|
|
|
/* Rm negative, shift to the right */
|
|
|
|
gen_set_label(label1);
|
2010-01-31 03:07:25 +03:00
|
|
|
shift = tcg_temp_new();
|
2008-09-01 17:09:21 +04:00
|
|
|
tcg_gen_andi_i32(shift, REG(B7_4), 0x1f);
|
|
|
|
tcg_gen_brcondi_i32(TCG_COND_EQ, shift, 0, label2);
|
|
|
|
tcg_gen_not_i32(shift, REG(B7_4));
|
|
|
|
tcg_gen_andi_i32(shift, shift, 0x1f);
|
|
|
|
tcg_gen_addi_i32(shift, shift, 1);
|
|
|
|
tcg_gen_sar_i32(REG(B11_8), REG(B11_8), shift);
|
2010-01-31 03:07:25 +03:00
|
|
|
tcg_temp_free(shift);
|
2008-09-01 17:09:06 +04:00
|
|
|
tcg_gen_br(label4);
|
|
|
|
/* Rm = -32 */
|
|
|
|
gen_set_label(label2);
|
2008-09-01 17:09:14 +04:00
|
|
|
tcg_gen_brcondi_i32(TCG_COND_LT, REG(B11_8), 0, label3);
|
|
|
|
tcg_gen_movi_i32(REG(B11_8), 0);
|
2008-09-01 17:09:06 +04:00
|
|
|
tcg_gen_br(label4);
|
|
|
|
gen_set_label(label3);
|
2008-09-01 17:09:14 +04:00
|
|
|
tcg_gen_movi_i32(REG(B11_8), 0xffffffff);
|
2008-09-01 17:09:06 +04:00
|
|
|
gen_set_label(label4);
|
|
|
|
}
|
2006-04-28 01:07:38 +04:00
|
|
|
return;
|
|
|
|
case 0x400d: /* shld Rm,Rn */
|
2008-09-01 17:09:06 +04:00
|
|
|
{
|
|
|
|
int label1 = gen_new_label();
|
|
|
|
int label2 = gen_new_label();
|
|
|
|
int label3 = gen_new_label();
|
2010-01-31 03:07:25 +03:00
|
|
|
TCGv shift;
|
2008-09-01 17:09:14 +04:00
|
|
|
tcg_gen_brcondi_i32(TCG_COND_LT, REG(B7_4), 0, label1);
|
2008-09-01 17:09:06 +04:00
|
|
|
/* Rm positive, shift to the left */
|
2010-01-31 03:07:25 +03:00
|
|
|
shift = tcg_temp_new();
|
2008-09-01 17:09:21 +04:00
|
|
|
tcg_gen_andi_i32(shift, REG(B7_4), 0x1f);
|
|
|
|
tcg_gen_shl_i32(REG(B11_8), REG(B11_8), shift);
|
2010-01-31 03:07:25 +03:00
|
|
|
tcg_temp_free(shift);
|
2008-09-01 17:09:06 +04:00
|
|
|
tcg_gen_br(label3);
|
|
|
|
/* Rm negative, shift to the right */
|
|
|
|
gen_set_label(label1);
|
2010-01-31 03:07:25 +03:00
|
|
|
shift = tcg_temp_new();
|
2008-09-01 17:09:21 +04:00
|
|
|
tcg_gen_andi_i32(shift, REG(B7_4), 0x1f);
|
|
|
|
tcg_gen_brcondi_i32(TCG_COND_EQ, shift, 0, label2);
|
|
|
|
tcg_gen_not_i32(shift, REG(B7_4));
|
|
|
|
tcg_gen_andi_i32(shift, shift, 0x1f);
|
|
|
|
tcg_gen_addi_i32(shift, shift, 1);
|
|
|
|
tcg_gen_shr_i32(REG(B11_8), REG(B11_8), shift);
|
2010-01-31 03:07:25 +03:00
|
|
|
tcg_temp_free(shift);
|
2008-09-01 17:09:06 +04:00
|
|
|
tcg_gen_br(label3);
|
|
|
|
/* Rm = -32 */
|
|
|
|
gen_set_label(label2);
|
2008-09-01 17:09:14 +04:00
|
|
|
tcg_gen_movi_i32(REG(B11_8), 0);
|
2008-09-01 17:09:06 +04:00
|
|
|
gen_set_label(label3);
|
|
|
|
}
|
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
|
|
|
{
|
|
|
|
TCGv t0, t1, t2;
|
|
|
|
t0 = tcg_temp_new();
|
|
|
|
tcg_gen_andi_i32(t0, cpu_sr, SR_T);
|
|
|
|
t1 = tcg_temp_new();
|
|
|
|
tcg_gen_sub_i32(t1, REG(B11_8), REG(B7_4));
|
|
|
|
tcg_gen_sub_i32(t0, t1, t0);
|
|
|
|
t2 = tcg_temp_new();
|
|
|
|
tcg_gen_setcond_i32(TCG_COND_LTU, t2, REG(B11_8), t1);
|
|
|
|
tcg_gen_setcond_i32(TCG_COND_LTU, t1, t1, t0);
|
|
|
|
tcg_gen_or_i32(t1, t1, t2);
|
|
|
|
tcg_temp_free(t2);
|
|
|
|
tcg_gen_andi_i32(cpu_sr, cpu_sr, ~SR_T);
|
|
|
|
tcg_gen_or_i32(cpu_sr, cpu_sr, t1);
|
|
|
|
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 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);
|
|
|
|
tcg_gen_shri_i32(t1, t1, 31);
|
|
|
|
tcg_gen_andi_i32(cpu_sr, cpu_sr, ~SR_T);
|
|
|
|
tcg_gen_or_i32(cpu_sr, cpu_sr, t1);
|
|
|
|
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));
|
|
|
|
gen_cmp_imm(TCG_COND_EQ, val, 0);
|
|
|
|
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
|
2012-09-16 15:12:21 +04:00
|
|
|
if (ctx->flags & FPSCR_SZ) {
|
2008-11-17 17:43:54 +03:00
|
|
|
TCGv_i64 fp = tcg_temp_new_i64();
|
2008-09-02 02:11:56 +04:00
|
|
|
gen_load_fpr64(fp, XREG(B7_4));
|
|
|
|
gen_store_fpr64(fp, XREG(B11_8));
|
2008-11-17 17:43:54 +03:00
|
|
|
tcg_temp_free_i64(fp);
|
2006-06-14 19:02:05 +04:00
|
|
|
} else {
|
2008-11-19 21:00:47 +03:00
|
|
|
tcg_gen_mov_i32(cpu_fregs[FREG(B11_8)], cpu_fregs[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
|
2012-09-16 15:12:21 +04:00
|
|
|
if (ctx->flags & FPSCR_SZ) {
|
2008-11-22 13:09:27 +03:00
|
|
|
TCGv addr_hi = tcg_temp_new();
|
|
|
|
int fr = XREG(B7_4);
|
|
|
|
tcg_gen_addi_i32(addr_hi, REG(B11_8), 4);
|
2013-12-11 10:56:47 +04:00
|
|
|
tcg_gen_qemu_st_i32(cpu_fregs[fr], REG(B11_8),
|
|
|
|
ctx->memidx, MO_TEUL);
|
|
|
|
tcg_gen_qemu_st_i32(cpu_fregs[fr+1], addr_hi,
|
|
|
|
ctx->memidx, MO_TEUL);
|
2008-11-22 13:09:27 +03:00
|
|
|
tcg_temp_free(addr_hi);
|
2006-06-14 19:02:05 +04:00
|
|
|
} else {
|
2013-12-11 10:56:47 +04:00
|
|
|
tcg_gen_qemu_st_i32(cpu_fregs[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
|
2012-09-16 15:12:21 +04:00
|
|
|
if (ctx->flags & FPSCR_SZ) {
|
2008-11-22 13:09:27 +03:00
|
|
|
TCGv addr_hi = tcg_temp_new();
|
|
|
|
int fr = XREG(B11_8);
|
|
|
|
tcg_gen_addi_i32(addr_hi, REG(B7_4), 4);
|
2013-12-11 10:56:47 +04:00
|
|
|
tcg_gen_qemu_ld_i32(cpu_fregs[fr], REG(B7_4), ctx->memidx, MO_TEUL);
|
|
|
|
tcg_gen_qemu_ld_i32(cpu_fregs[fr+1], addr_hi, ctx->memidx, MO_TEUL);
|
2008-11-22 13:09:27 +03:00
|
|
|
tcg_temp_free(addr_hi);
|
2006-06-14 19:02:05 +04:00
|
|
|
} else {
|
2013-12-11 10:56:47 +04:00
|
|
|
tcg_gen_qemu_ld_i32(cpu_fregs[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
|
2012-09-16 15:12:21 +04:00
|
|
|
if (ctx->flags & FPSCR_SZ) {
|
2008-11-22 13:09:27 +03:00
|
|
|
TCGv addr_hi = tcg_temp_new();
|
|
|
|
int fr = XREG(B11_8);
|
|
|
|
tcg_gen_addi_i32(addr_hi, REG(B7_4), 4);
|
2013-12-11 10:56:47 +04:00
|
|
|
tcg_gen_qemu_ld_i32(cpu_fregs[fr], REG(B7_4), ctx->memidx, MO_TEUL);
|
|
|
|
tcg_gen_qemu_ld_i32(cpu_fregs[fr+1], addr_hi, ctx->memidx, MO_TEUL);
|
2008-11-22 13:09:27 +03:00
|
|
|
tcg_gen_addi_i32(REG(B7_4), REG(B7_4), 8);
|
|
|
|
tcg_temp_free(addr_hi);
|
2006-06-14 19:02:05 +04:00
|
|
|
} else {
|
2013-12-11 10:56:47 +04:00
|
|
|
tcg_gen_qemu_ld_i32(cpu_fregs[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
|
2012-09-16 15:12:21 +04:00
|
|
|
if (ctx->flags & FPSCR_SZ) {
|
2008-11-22 13:09:27 +03:00
|
|
|
TCGv addr = tcg_temp_new_i32();
|
|
|
|
int fr = XREG(B7_4);
|
|
|
|
tcg_gen_subi_i32(addr, REG(B11_8), 4);
|
2013-12-11 10:56:47 +04:00
|
|
|
tcg_gen_qemu_st_i32(cpu_fregs[fr+1], addr, ctx->memidx, MO_TEUL);
|
2010-01-31 03:07:25 +03:00
|
|
|
tcg_gen_subi_i32(addr, addr, 4);
|
2013-12-11 10:56:47 +04:00
|
|
|
tcg_gen_qemu_st_i32(cpu_fregs[fr], addr, ctx->memidx, MO_TEUL);
|
2008-11-22 13:09:27 +03:00
|
|
|
tcg_gen_mov_i32(REG(B11_8), addr);
|
2008-09-02 02:11:56 +04:00
|
|
|
tcg_temp_free(addr);
|
2006-06-14 19:02:05 +04:00
|
|
|
} else {
|
2008-11-17 17:43:54 +03:00
|
|
|
TCGv addr;
|
|
|
|
addr = tcg_temp_new_i32();
|
2008-09-02 02:11:56 +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_fregs[FREG(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-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 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));
|
2012-09-16 15:12:21 +04:00
|
|
|
if (ctx->flags & FPSCR_SZ) {
|
2008-11-22 13:09:27 +03:00
|
|
|
int fr = XREG(B11_8);
|
2013-12-11 10:56:47 +04:00
|
|
|
tcg_gen_qemu_ld_i32(cpu_fregs[fr], addr,
|
|
|
|
ctx->memidx, MO_TEUL);
|
2008-11-22 13:09:27 +03:00
|
|
|
tcg_gen_addi_i32(addr, addr, 4);
|
2013-12-11 10:56:47 +04:00
|
|
|
tcg_gen_qemu_ld_i32(cpu_fregs[fr+1], addr,
|
|
|
|
ctx->memidx, MO_TEUL);
|
2008-09-02 02:11:56 +04:00
|
|
|
} else {
|
2013-12-11 10:56:47 +04:00
|
|
|
tcg_gen_qemu_ld_i32(cpu_fregs[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));
|
2012-09-16 15:12:21 +04:00
|
|
|
if (ctx->flags & FPSCR_SZ) {
|
2008-11-22 13:09:27 +03:00
|
|
|
int fr = XREG(B7_4);
|
2013-12-11 10:56:47 +04:00
|
|
|
tcg_gen_qemu_ld_i32(cpu_fregs[fr], addr,
|
|
|
|
ctx->memidx, MO_TEUL);
|
2008-11-22 13:09:27 +03:00
|
|
|
tcg_gen_addi_i32(addr, addr, 4);
|
2013-12-11 10:56:47 +04:00
|
|
|
tcg_gen_qemu_ld_i32(cpu_fregs[fr+1], addr,
|
|
|
|
ctx->memidx, MO_TEUL);
|
2008-09-02 02:11:56 +04:00
|
|
|
} else {
|
2013-12-11 10:56:47 +04:00
|
|
|
tcg_gen_qemu_st_i32(cpu_fregs[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
|
2012-09-16 15:12:21 +04:00
|
|
|
if (ctx->flags & FPSCR_PR) {
|
2008-11-17 17:43:54 +03:00
|
|
|
TCGv_i64 fp0, fp1;
|
|
|
|
|
2008-09-02 02:11:56 +04:00
|
|
|
if (ctx->opcode & 0x0110)
|
|
|
|
break; /* illegal instruction */
|
2008-11-17 17:43:54 +03:00
|
|
|
fp0 = tcg_temp_new_i64();
|
|
|
|
fp1 = tcg_temp_new_i64();
|
2008-09-02 02:11:56 +04:00
|
|
|
gen_load_fpr64(fp0, DREG(B11_8));
|
|
|
|
gen_load_fpr64(fp1, DREG(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 */
|
2012-09-02 14:37:06 +04:00
|
|
|
gen_helper_fcmp_eq_DT(cpu_env, fp0, fp1);
|
2008-11-17 17:43:54 +03:00
|
|
|
return;
|
|
|
|
case 0xf005: /* fcmp/gt Rm,Rn */
|
2012-09-02 14:37:06 +04:00
|
|
|
gen_helper_fcmp_gt_DT(cpu_env, fp0, fp1);
|
2008-11-17 17:43:54 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
gen_store_fpr64(fp0, DREG(B11_8));
|
|
|
|
tcg_temp_free_i64(fp0);
|
|
|
|
tcg_temp_free_i64(fp1);
|
|
|
|
} else {
|
|
|
|
switch (ctx->opcode & 0xf00f) {
|
|
|
|
case 0xf000: /* fadd Rm,Rn */
|
2012-09-02 14:37:06 +04:00
|
|
|
gen_helper_fadd_FT(cpu_fregs[FREG(B11_8)], cpu_env,
|
|
|
|
cpu_fregs[FREG(B11_8)],
|
|
|
|
cpu_fregs[FREG(B7_4)]);
|
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_FT(cpu_fregs[FREG(B11_8)], cpu_env,
|
|
|
|
cpu_fregs[FREG(B11_8)],
|
|
|
|
cpu_fregs[FREG(B7_4)]);
|
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_FT(cpu_fregs[FREG(B11_8)], cpu_env,
|
|
|
|
cpu_fregs[FREG(B11_8)],
|
|
|
|
cpu_fregs[FREG(B7_4)]);
|
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_FT(cpu_fregs[FREG(B11_8)], cpu_env,
|
|
|
|
cpu_fregs[FREG(B11_8)],
|
|
|
|
cpu_fregs[FREG(B7_4)]);
|
2008-11-17 17:43:54 +03:00
|
|
|
break;
|
|
|
|
case 0xf004: /* fcmp/eq Rm,Rn */
|
2012-09-02 14:37:06 +04:00
|
|
|
gen_helper_fcmp_eq_FT(cpu_env, cpu_fregs[FREG(B11_8)],
|
|
|
|
cpu_fregs[FREG(B7_4)]);
|
2008-11-17 17:43:54 +03:00
|
|
|
return;
|
|
|
|
case 0xf005: /* fcmp/gt Rm,Rn */
|
2012-09-02 14:37:06 +04:00
|
|
|
gen_helper_fcmp_gt_FT(cpu_env, cpu_fregs[FREG(B11_8)],
|
|
|
|
cpu_fregs[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 */
|
|
|
|
{
|
|
|
|
CHECK_FPU_ENABLED
|
2012-09-16 15:12:21 +04:00
|
|
|
if (ctx->flags & FPSCR_PR) {
|
2009-01-15 00:02:59 +03:00
|
|
|
break; /* illegal instruction */
|
|
|
|
} else {
|
2012-09-02 14:37:06 +04:00
|
|
|
gen_helper_fmac_FT(cpu_fregs[FREG(B11_8)], cpu_env,
|
|
|
|
cpu_fregs[FREG(0)], cpu_fregs[FREG(B7_4)],
|
|
|
|
cpu_fregs[FREG(B11_8)]);
|
2009-01-15 00:02:59 +03:00
|
|
|
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
|
|
|
|
gen_conditional_jump(ctx, ctx->pc + 2,
|
|
|
|
ctx->pc + 4 + B7_0s * 2);
|
2007-12-02 09:10:04 +03:00
|
|
|
ctx->bstate = BS_BRANCH;
|
2006-04-28 01:07:38 +04:00
|
|
|
return;
|
|
|
|
case 0x8f00: /* bf/s label */
|
|
|
|
CHECK_NOT_DELAY_SLOT
|
2008-08-30 02:32:32 +04:00
|
|
|
gen_branch_slot(ctx->delayed_pc = ctx->pc + 4 + B7_0s * 2, 0);
|
2006-04-28 01:07:38 +04:00
|
|
|
ctx->flags |= DELAY_SLOT_CONDITIONAL;
|
|
|
|
return;
|
|
|
|
case 0x8900: /* bt label */
|
|
|
|
CHECK_NOT_DELAY_SLOT
|
|
|
|
gen_conditional_jump(ctx, ctx->pc + 4 + B7_0s * 2,
|
|
|
|
ctx->pc + 2);
|
2007-12-02 09:10:04 +03:00
|
|
|
ctx->bstate = BS_BRANCH;
|
2006-04-28 01:07:38 +04:00
|
|
|
return;
|
|
|
|
case 0x8d00: /* bt/s label */
|
|
|
|
CHECK_NOT_DELAY_SLOT
|
2008-08-30 02:32:32 +04:00
|
|
|
gen_branch_slot(ctx->delayed_pc = ctx->pc + 4 + B7_0s * 2, 1);
|
2006-04-28 01:07:38 +04:00
|
|
|
ctx->flags |= DELAY_SLOT_CONDITIONAL;
|
|
|
|
return;
|
|
|
|
case 0x8800: /* cmp/eq #imm,R0 */
|
2008-09-01 17:09:14 +04:00
|
|
|
gen_cmp_imm(TCG_COND_EQ, 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
|
2012-09-16 15:12:21 +04:00
|
|
|
tcg_gen_movi_i32(cpu_pc, ctx->pc);
|
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);
|
|
|
|
ctx->bstate = BS_BRANCH;
|
|
|
|
}
|
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);
|
|
|
|
gen_cmp_imm(TCG_COND_EQ, val, 0);
|
|
|
|
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);
|
|
|
|
gen_cmp_imm(TCG_COND_EQ, val, 0);
|
|
|
|
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);
|
2006-04-28 01:07:38 +04:00
|
|
|
ctx->flags |= DELAY_SLOT;
|
|
|
|
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);
|
2006-04-28 01:07:38 +04:00
|
|
|
ctx->flags |= DELAY_SLOT;
|
|
|
|
ctx->delayed_pc = (uint32_t) - 1;
|
|
|
|
return;
|
|
|
|
case 0x4015: /* cmp/pl Rn */
|
2008-09-01 17:09:14 +04:00
|
|
|
gen_cmp_imm(TCG_COND_GT, REG(B11_8), 0);
|
2006-04-28 01:07:38 +04:00
|
|
|
return;
|
|
|
|
case 0x4011: /* cmp/pz Rn */
|
2008-09-01 17:09:14 +04:00
|
|
|
gen_cmp_imm(TCG_COND_GE, 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);
|
|
|
|
gen_cmp_imm(TCG_COND_EQ, 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));
|
2006-04-28 01:07:38 +04:00
|
|
|
ctx->flags |= DELAY_SLOT;
|
|
|
|
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));
|
2006-04-28 01:07:38 +04:00
|
|
|
ctx->flags |= DELAY_SLOT;
|
|
|
|
ctx->delayed_pc = (uint32_t) - 1;
|
|
|
|
return;
|
2008-09-15 12:49:15 +04:00
|
|
|
case 0x400e: /* ldc Rm,SR */
|
|
|
|
CHECK_PRIVILEGED
|
2008-09-01 17:09:14 +04:00
|
|
|
tcg_gen_andi_i32(cpu_sr, REG(B11_8), 0x700083f3);
|
2008-08-31 02:07:52 +04:00
|
|
|
ctx->bstate = BS_STOP;
|
|
|
|
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);
|
2008-09-01 17:09:21 +04:00
|
|
|
tcg_gen_andi_i32(cpu_sr, val, 0x700083f3);
|
|
|
|
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
|
2008-09-01 17:09:14 +04:00
|
|
|
tcg_gen_mov_i32(REG(B11_8), cpu_sr);
|
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();
|
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_sr, 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-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)
|
|
|
|
LD(sgr, 0x403a, 0x4036, CHECK_PRIVILEGED if (!(ctx->features & SH_FEATURE_SH4A)) break;)
|
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;
|
2008-10-13 03:32:59 +04:00
|
|
|
case 0x40a9:
|
|
|
|
/* MOVUA.L @Rm,R0 (Rm) -> R0
|
|
|
|
Load non-boundary-aligned data */
|
2013-12-11 10:56:47 +04:00
|
|
|
tcg_gen_qemu_ld_i32(REG(0), REG(B11_8), ctx->memidx, MO_TEUL);
|
2008-10-13 03:32:59 +04:00
|
|
|
return;
|
|
|
|
case 0x40e9:
|
|
|
|
/* MOVUA.L @Rm+,R0 (Rm) -> R0, Rm + 4 -> Rm
|
|
|
|
Load non-boundary-aligned data */
|
2013-12-11 10:56:47 +04:00
|
|
|
tcg_gen_qemu_ld_i32(REG(0), REG(B11_8), ctx->memidx, MO_TEUL);
|
2008-10-13 03:32:59 +04:00
|
|
|
tcg_gen_addi_i32(REG(B11_8), REG(B11_8), 4);
|
|
|
|
return;
|
2006-04-28 01:07:38 +04:00
|
|
|
case 0x0029: /* movt Rn */
|
2008-09-01 17:09:14 +04:00
|
|
|
tcg_gen_andi_i32(REG(B11_8), cpu_sr, 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
|
|
|
|
*/
|
|
|
|
if (ctx->features & SH_FEATURE_SH4A) {
|
|
|
|
int label = gen_new_label();
|
2012-09-16 15:12:20 +04:00
|
|
|
tcg_gen_andi_i32(cpu_sr, cpu_sr, ~SR_T);
|
2009-03-02 20:13:21 +03:00
|
|
|
tcg_gen_or_i32(cpu_sr, cpu_sr, cpu_ldst);
|
|
|
|
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;
|
|
|
|
} else
|
|
|
|
break;
|
|
|
|
case 0x0063:
|
|
|
|
/* MOVLI.L @Rm,R0
|
|
|
|
1 -> LDST
|
|
|
|
(Rm) -> R0
|
|
|
|
When interrupt/exception
|
|
|
|
occurred 0 -> LDST
|
|
|
|
*/
|
|
|
|
if (ctx->features & SH_FEATURE_SH4A) {
|
|
|
|
tcg_gen_movi_i32(cpu_ldst, 0);
|
2013-12-11 10:56:47 +04:00
|
|
|
tcg_gen_qemu_ld_i32(REG(0), REG(B11_8), ctx->memidx, MO_TESL);
|
2009-03-02 20:13:21 +03:00
|
|
|
tcg_gen_movi_i32(cpu_ldst, 1);
|
|
|
|
return;
|
|
|
|
} else
|
|
|
|
break;
|
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 */
|
|
|
|
if (ctx->features & SH_FEATURE_SH4A)
|
|
|
|
return;
|
|
|
|
else
|
|
|
|
break;
|
|
|
|
case 0x00e3: /* icbi @Rn */
|
|
|
|
if (ctx->features & SH_FEATURE_SH4A)
|
|
|
|
return;
|
|
|
|
else
|
|
|
|
break;
|
|
|
|
case 0x00ab: /* synco */
|
|
|
|
if (ctx->features & SH_FEATURE_SH4A)
|
|
|
|
return;
|
|
|
|
else
|
|
|
|
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();
|
2008-09-01 17:09:21 +04:00
|
|
|
tcg_gen_mov_i32(tmp, cpu_sr);
|
|
|
|
gen_copy_bit_i32(cpu_sr, 0, REG(B11_8), 31);
|
|
|
|
tcg_gen_shli_i32(REG(B11_8), REG(B11_8), 1);
|
|
|
|
gen_copy_bit_i32(REG(B11_8), 0, tmp, 0);
|
|
|
|
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();
|
2008-09-01 17:09:21 +04:00
|
|
|
tcg_gen_mov_i32(tmp, cpu_sr);
|
|
|
|
gen_copy_bit_i32(cpu_sr, 0, REG(B11_8), 0);
|
|
|
|
tcg_gen_shri_i32(REG(B11_8), REG(B11_8), 1);
|
|
|
|
gen_copy_bit_i32(REG(B11_8), 31, tmp, 0);
|
|
|
|
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);
|
|
|
|
gen_copy_bit_i32(cpu_sr, 0, REG(B11_8), 0);
|
2006-04-28 01:07:38 +04:00
|
|
|
return;
|
|
|
|
case 0x4005: /* rotr Rn */
|
2008-09-01 17:09:14 +04:00
|
|
|
gen_copy_bit_i32(cpu_sr, 0, 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 */
|
2008-09-01 17:09:14 +04:00
|
|
|
gen_copy_bit_i32(cpu_sr, 0, REG(B11_8), 31);
|
|
|
|
tcg_gen_shli_i32(REG(B11_8), REG(B11_8), 1);
|
2006-04-28 01:07:38 +04:00
|
|
|
return;
|
|
|
|
case 0x4021: /* shar Rn */
|
2008-09-01 17:09:14 +04:00
|
|
|
gen_copy_bit_i32(cpu_sr, 0, REG(B11_8), 0);
|
|
|
|
tcg_gen_sari_i32(REG(B11_8), REG(B11_8), 1);
|
2006-04-28 01:07:38 +04:00
|
|
|
return;
|
|
|
|
case 0x4001: /* shlr Rn */
|
2008-09-01 17:09:14 +04:00
|
|
|
gen_copy_bit_i32(cpu_sr, 0, REG(B11_8), 0);
|
|
|
|
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 */
|
2008-09-01 17:09:21 +04:00
|
|
|
{
|
|
|
|
TCGv addr, val;
|
2009-01-01 17:09:05 +03:00
|
|
|
addr = tcg_temp_local_new();
|
2008-09-01 17:09:21 +04:00
|
|
|
tcg_gen_mov_i32(addr, REG(B11_8));
|
2009-01-01 17:09:05 +03:00
|
|
|
val = tcg_temp_local_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
|
|
|
gen_cmp_imm(TCG_COND_EQ, val, 0);
|
|
|
|
tcg_gen_ori_i32(val, val, 0x80);
|
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;
|
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
|
|
|
|
tcg_gen_mov_i32(cpu_fregs[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
|
|
|
|
tcg_gen_mov_i32(cpu_fpul, cpu_fregs[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
|
2012-09-16 15:12:21 +04:00
|
|
|
if (ctx->flags & FPSCR_PR) {
|
2008-11-17 17:43:54 +03:00
|
|
|
TCGv_i64 fp;
|
2007-06-22 15:12:01 +04:00
|
|
|
if (ctx->opcode & 0x0100)
|
|
|
|
break; /* illegal instruction */
|
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);
|
2008-09-02 02:11:56 +04:00
|
|
|
gen_store_fpr64(fp, DREG(B11_8));
|
2008-11-17 17:43:54 +03:00
|
|
|
tcg_temp_free_i64(fp);
|
2007-06-22 15:12:01 +04:00
|
|
|
}
|
|
|
|
else {
|
2012-09-02 14:37:06 +04:00
|
|
|
gen_helper_float_FT(cpu_fregs[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
|
2012-09-16 15:12:21 +04:00
|
|
|
if (ctx->flags & FPSCR_PR) {
|
2008-11-17 17:43:54 +03:00
|
|
|
TCGv_i64 fp;
|
2007-06-22 15:12:01 +04:00
|
|
|
if (ctx->opcode & 0x0100)
|
|
|
|
break; /* illegal instruction */
|
2008-11-17 17:43:54 +03:00
|
|
|
fp = tcg_temp_new_i64();
|
2008-09-02 02:11:56 +04:00
|
|
|
gen_load_fpr64(fp, DREG(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 {
|
2012-09-02 14:37:06 +04:00
|
|
|
gen_helper_ftrc_FT(cpu_fpul, cpu_env, cpu_fregs[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
|
2008-09-02 02:12:06 +04:00
|
|
|
{
|
2008-11-19 21:00:47 +03:00
|
|
|
gen_helper_fneg_T(cpu_fregs[FREG(B11_8)], cpu_fregs[FREG(B11_8)]);
|
2008-09-02 02:12:06 +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 0xf05d: /* fabs FRn/DRn */
|
2008-12-10 20:31:43 +03:00
|
|
|
CHECK_FPU_ENABLED
|
2012-09-16 15:12:21 +04:00
|
|
|
if (ctx->flags & FPSCR_PR) {
|
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 (ctx->opcode & 0x0100)
|
|
|
|
break; /* illegal instruction */
|
2008-11-17 17:43:54 +03:00
|
|
|
TCGv_i64 fp = tcg_temp_new_i64();
|
2008-09-02 02:11:56 +04:00
|
|
|
gen_load_fpr64(fp, DREG(B11_8));
|
2008-11-17 17:43:54 +03:00
|
|
|
gen_helper_fabs_DT(fp, fp);
|
2008-09-02 02:11:56 +04:00
|
|
|
gen_store_fpr64(fp, DREG(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 {
|
2008-11-19 21:00:47 +03:00
|
|
|
gen_helper_fabs_FT(cpu_fregs[FREG(B11_8)], cpu_fregs[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 0xf06d: /* fsqrt FRn */
|
2008-12-10 20:31:43 +03:00
|
|
|
CHECK_FPU_ENABLED
|
2012-09-16 15:12:21 +04:00
|
|
|
if (ctx->flags & FPSCR_PR) {
|
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 (ctx->opcode & 0x0100)
|
|
|
|
break; /* illegal instruction */
|
2008-11-17 17:43:54 +03:00
|
|
|
TCGv_i64 fp = tcg_temp_new_i64();
|
2008-09-02 02:11:56 +04:00
|
|
|
gen_load_fpr64(fp, DREG(B11_8));
|
2012-09-02 14:37:06 +04:00
|
|
|
gen_helper_fsqrt_DT(fp, cpu_env, fp);
|
2008-09-02 02:11:56 +04:00
|
|
|
gen_store_fpr64(fp, DREG(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 {
|
2012-09-02 14:37:06 +04:00
|
|
|
gen_helper_fsqrt_FT(cpu_fregs[FREG(B11_8)], cpu_env,
|
|
|
|
cpu_fregs[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
|
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
|
2012-09-16 15:12:21 +04:00
|
|
|
if (!(ctx->flags & FPSCR_PR)) {
|
2008-11-19 21:00:47 +03:00
|
|
|
tcg_gen_movi_i32(cpu_fregs[FREG(B11_8)], 0);
|
2007-06-22 15:12:01 +04:00
|
|
|
}
|
2008-11-20 09:41:29 +03:00
|
|
|
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
|
2012-09-16 15:12:21 +04:00
|
|
|
if (!(ctx->flags & FPSCR_PR)) {
|
2008-11-19 21:00:47 +03:00
|
|
|
tcg_gen_movi_i32(cpu_fregs[FREG(B11_8)], 0x3f800000);
|
2007-06-22 15:12:01 +04:00
|
|
|
}
|
2008-11-20 09:41:29 +03: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 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);
|
2008-09-02 02:11:56 +04:00
|
|
|
gen_store_fpr64(fp, DREG(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();
|
2008-09-02 02:11:56 +04:00
|
|
|
gen_load_fpr64(fp, DREG(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
|
2012-09-16 15:12:21 +04:00
|
|
|
if ((ctx->flags & FPSCR_PR) == 0) {
|
2011-01-14 22:39:18 +03:00
|
|
|
TCGv m, n;
|
2012-01-05 16:11:48 +04:00
|
|
|
m = tcg_const_i32((ctx->opcode >> 8) & 3);
|
|
|
|
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
|
|
|
|
if ((ctx->opcode & 0x0300) == 0x0100 &&
|
2012-09-16 15:12:21 +04:00
|
|
|
(ctx->flags & FPSCR_PR) == 0) {
|
2011-01-14 22:39:18 +03:00
|
|
|
TCGv n;
|
2012-01-05 16:11:48 +04:00
|
|
|
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
|
2012-09-16 15:12:21 +04:00
|
|
|
tcg_gen_movi_i32(cpu_pc, ctx->pc);
|
2011-01-11 18:13:34 +03:00
|
|
|
if (ctx->flags & (DELAY_SLOT | DELAY_SLOT_CONDITIONAL)) {
|
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 {
|
2012-09-02 14:37:06 +04:00
|
|
|
gen_helper_raise_illegal_instruction(cpu_env);
|
2011-01-11 18:13:34 +03:00
|
|
|
}
|
2012-09-16 15:12:21 +04:00
|
|
|
ctx->bstate = BS_BRANCH;
|
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
|
|
|
{
|
|
|
|
uint32_t old_flags = ctx->flags;
|
|
|
|
|
2012-09-25 01:55:47 +04:00
|
|
|
if (unlikely(qemu_loglevel_mask(CPU_LOG_TB_OP | CPU_LOG_TB_OP_OPT))) {
|
2011-01-14 22:39:18 +03:00
|
|
|
tcg_gen_debug_insn_start(ctx->pc);
|
|
|
|
}
|
|
|
|
|
2007-12-02 09:10:04 +03:00
|
|
|
_decode_opc(ctx);
|
|
|
|
|
|
|
|
if (old_flags & (DELAY_SLOT | DELAY_SLOT_CONDITIONAL)) {
|
|
|
|
if (ctx->flags & DELAY_SLOT_CLEARME) {
|
2008-08-30 02:32:32 +04:00
|
|
|
gen_store_flags(0);
|
2008-08-22 12:57:35 +04:00
|
|
|
} else {
|
|
|
|
/* go out of the delay slot */
|
|
|
|
uint32_t new_flags = ctx->flags;
|
|
|
|
new_flags &= ~(DELAY_SLOT | DELAY_SLOT_CONDITIONAL);
|
2008-08-30 02:32:32 +04:00
|
|
|
gen_store_flags(new_flags);
|
2007-12-02 09:10:04 +03:00
|
|
|
}
|
|
|
|
ctx->flags = 0;
|
|
|
|
ctx->bstate = BS_BRANCH;
|
|
|
|
if (old_flags & DELAY_SLOT_CONDITIONAL) {
|
|
|
|
gen_delayed_conditional_jump(ctx);
|
|
|
|
} else if (old_flags & DELAY_SLOT) {
|
|
|
|
gen_jump(ctx);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2008-08-22 12:57:35 +04:00
|
|
|
|
|
|
|
/* go into a delay slot */
|
|
|
|
if (ctx->flags & (DELAY_SLOT | DELAY_SLOT_CONDITIONAL))
|
2008-08-30 02:32:32 +04:00
|
|
|
gen_store_flags(ctx->flags);
|
2006-04-28 01:07:38 +04:00
|
|
|
}
|
|
|
|
|
2008-07-18 22:01:29 +04:00
|
|
|
static inline void
|
2013-06-22 00:24:41 +04:00
|
|
|
gen_intermediate_code_internal(SuperHCPU *cpu, TranslationBlock *tb,
|
|
|
|
bool search_pc)
|
2006-04-28 01:07:38 +04:00
|
|
|
{
|
2013-06-21 22:20:45 +04:00
|
|
|
CPUState *cs = CPU(cpu);
|
2013-06-22 00:24:41 +04:00
|
|
|
CPUSH4State *env = &cpu->env;
|
2006-04-28 01:07:38 +04:00
|
|
|
DisasContext ctx;
|
|
|
|
target_ulong pc_start;
|
|
|
|
static uint16_t *gen_opc_end;
|
2008-11-18 23:07:32 +03:00
|
|
|
CPUBreakpoint *bp;
|
2006-06-17 23:58:25 +04:00
|
|
|
int i, ii;
|
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;
|
2012-11-12 13:27:47 +04:00
|
|
|
gen_opc_end = tcg_ctx.gen_opc_buf + OPC_MAX_SIZE;
|
2006-04-28 01:07:38 +04:00
|
|
|
ctx.pc = pc_start;
|
2007-12-02 09:10:04 +03:00
|
|
|
ctx.flags = (uint32_t)tb->flags;
|
|
|
|
ctx.bstate = BS_NONE;
|
2012-09-16 15:12:21 +04:00
|
|
|
ctx.memidx = (ctx.flags & 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;
|
2012-09-16 15:12:21 +04:00
|
|
|
ctx.has_movcal = (ctx.flags & TB_FLAG_PENDING_MOVCA);
|
2006-04-28 01:07:38 +04:00
|
|
|
|
2006-06-17 23:58:25 +04:00
|
|
|
ii = -1;
|
2008-06-29 05:03:05 +04:00
|
|
|
num_insns = 0;
|
|
|
|
max_insns = tb->cflags & CF_COUNT_MASK;
|
|
|
|
if (max_insns == 0)
|
|
|
|
max_insns = CF_COUNT_MASK;
|
2013-02-22 22:10:05 +04:00
|
|
|
gen_tb_start();
|
2012-11-12 13:27:45 +04:00
|
|
|
while (ctx.bstate == BS_NONE && tcg_ctx.gen_opc_ptr < gen_opc_end) {
|
2013-08-26 23:22:53 +04:00
|
|
|
if (unlikely(!QTAILQ_EMPTY(&cs->breakpoints))) {
|
|
|
|
QTAILQ_FOREACH(bp, &cs->breakpoints, entry) {
|
2008-11-18 23:07:32 +03:00
|
|
|
if (ctx.pc == bp->pc) {
|
2006-04-28 01:07:38 +04:00
|
|
|
/* We have hit a breakpoint - make sure PC is up-to-date */
|
2008-08-29 20:32:18 +04:00
|
|
|
tcg_gen_movi_i32(cpu_pc, ctx.pc);
|
2012-09-02 14:37:06 +04:00
|
|
|
gen_helper_debug(cpu_env);
|
2012-09-16 15:12:21 +04:00
|
|
|
ctx.bstate = BS_BRANCH;
|
2006-04-28 01:07:38 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2006-06-17 23:58:25 +04:00
|
|
|
if (search_pc) {
|
2012-11-12 13:27:47 +04:00
|
|
|
i = tcg_ctx.gen_opc_ptr - tcg_ctx.gen_opc_buf;
|
2006-06-17 23:58:25 +04:00
|
|
|
if (ii < i) {
|
|
|
|
ii++;
|
|
|
|
while (ii < i)
|
2012-11-21 11:43:06 +04:00
|
|
|
tcg_ctx.gen_opc_instr_start[ii++] = 0;
|
2006-06-17 23:58:25 +04:00
|
|
|
}
|
2012-11-21 11:43:04 +04:00
|
|
|
tcg_ctx.gen_opc_pc[ii] = ctx.pc;
|
2007-12-02 09:10:04 +03:00
|
|
|
gen_opc_hflags[ii] = ctx.flags;
|
2012-11-21 11:43:06 +04:00
|
|
|
tcg_ctx.gen_opc_instr_start[ii] = 1;
|
2012-11-21 11:43:05 +04:00
|
|
|
tcg_ctx.gen_opc_icount[ii] = num_insns;
|
2006-06-17 23:58:25 +04:00
|
|
|
}
|
2008-06-29 05:03:05 +04:00
|
|
|
if (num_insns + 1 == max_insns && (tb->cflags & CF_LAST_IO))
|
|
|
|
gen_io_start();
|
2006-04-28 01:07:38 +04:00
|
|
|
#if 0
|
|
|
|
fprintf(stderr, "Loading opcode at address 0x%08x\n", ctx.pc);
|
|
|
|
fflush(stderr);
|
|
|
|
#endif
|
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);
|
2008-06-29 05:03:05 +04:00
|
|
|
num_insns++;
|
2006-04-28 01:07:38 +04:00
|
|
|
ctx.pc += 2;
|
|
|
|
if ((ctx.pc & (TARGET_PAGE_SIZE - 1)) == 0)
|
|
|
|
break;
|
2013-06-21 22:20:45 +04:00
|
|
|
if (cs->singlestep_enabled) {
|
2006-04-28 01:07:38 +04:00
|
|
|
break;
|
2013-06-21 22:20:45 +04:00
|
|
|
}
|
2008-06-29 05:03:05 +04:00
|
|
|
if (num_insns >= max_insns)
|
|
|
|
break;
|
2009-04-06 00:08:59 +04:00
|
|
|
if (singlestep)
|
|
|
|
break;
|
2006-04-28 01:07:38 +04:00
|
|
|
}
|
2008-06-29 05:03:05 +04:00
|
|
|
if (tb->cflags & CF_LAST_IO)
|
|
|
|
gen_io_end();
|
2013-06-21 22:20:45 +04:00
|
|
|
if (cs->singlestep_enabled) {
|
2008-10-13 03:32:48 +04:00
|
|
|
tcg_gen_movi_i32(cpu_pc, ctx.pc);
|
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:
|
|
|
|
/* gen_op_interrupt_restart(); */
|
|
|
|
/* fall through */
|
|
|
|
case BS_NONE:
|
|
|
|
if (ctx.flags) {
|
2008-08-30 02:32:32 +04:00
|
|
|
gen_store_flags(ctx.flags | DELAY_SLOT_CLEARME);
|
2007-12-02 09:10:04 +03:00
|
|
|
}
|
|
|
|
gen_goto_tb(&ctx, 0, ctx.pc);
|
|
|
|
break;
|
|
|
|
case BS_EXCP:
|
|
|
|
/* gen_op_interrupt_restart(); */
|
2008-02-01 13:50:11 +03:00
|
|
|
tcg_gen_exit_tb(0);
|
2007-12-02 09:10:04 +03:00
|
|
|
break;
|
|
|
|
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);
|
2012-11-12 13:27:45 +04:00
|
|
|
*tcg_ctx.gen_opc_ptr = INDEX_op_end;
|
2006-06-17 23:58:25 +04:00
|
|
|
if (search_pc) {
|
2012-11-12 13:27:47 +04:00
|
|
|
i = tcg_ctx.gen_opc_ptr - tcg_ctx.gen_opc_buf;
|
2006-06-17 23:58:25 +04:00
|
|
|
ii++;
|
|
|
|
while (ii <= i)
|
2012-11-21 11:43:06 +04:00
|
|
|
tcg_ctx.gen_opc_instr_start[ii++] = 0;
|
2006-06-17 23:58:25 +04:00
|
|
|
} else {
|
|
|
|
tb->size = ctx.pc - pc_start;
|
2008-06-29 05:03:05 +04:00
|
|
|
tb->icount = num_insns;
|
2006-06-17 23:58:25 +04:00
|
|
|
}
|
2006-04-28 01:07:38 +04:00
|
|
|
|
|
|
|
#ifdef DEBUG_DISAS
|
2009-01-16 01:36:53 +03:00
|
|
|
if (qemu_loglevel_mask(CPU_LOG_TB_IN_ASM)) {
|
2009-01-16 01:34:14 +03:00
|
|
|
qemu_log("IN:\n"); /* , lookup_symbol(pc_start)); */
|
2012-09-08 16:40:00 +04:00
|
|
|
log_target_disas(env, pc_start, ctx.pc - pc_start, 0);
|
2009-01-16 01:34:14 +03:00
|
|
|
qemu_log("\n");
|
2006-04-28 01:07:38 +04:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2012-03-14 04:38:22 +04:00
|
|
|
void gen_intermediate_code(CPUSH4State * env, struct TranslationBlock *tb)
|
2006-04-28 01:07:38 +04:00
|
|
|
{
|
2013-06-22 00:24:41 +04:00
|
|
|
gen_intermediate_code_internal(sh_env_get_cpu(env), tb, false);
|
2006-04-28 01:07:38 +04:00
|
|
|
}
|
|
|
|
|
2012-03-14 04:38:22 +04:00
|
|
|
void gen_intermediate_code_pc(CPUSH4State * env, struct TranslationBlock *tb)
|
2006-04-28 01:07:38 +04:00
|
|
|
{
|
2013-06-22 00:24:41 +04:00
|
|
|
gen_intermediate_code_internal(sh_env_get_cpu(env), tb, true);
|
2006-04-28 01:07:38 +04:00
|
|
|
}
|
2008-04-28 04:32:32 +04:00
|
|
|
|
2012-03-14 04:38:22 +04:00
|
|
|
void restore_state_to_opc(CPUSH4State *env, TranslationBlock *tb, int pc_pos)
|
2008-04-28 04:32:32 +04:00
|
|
|
{
|
2012-11-21 11:43:04 +04:00
|
|
|
env->pc = tcg_ctx.gen_opc_pc[pc_pos];
|
2008-04-28 04:32:32 +04:00
|
|
|
env->flags = gen_opc_hflags[pc_pos];
|
|
|
|
}
|