mirror of
https://github.com/izzy2lost/xemu.git
synced 2026-07-06 00:20:22 -07:00
Merge remote-tracking branch 'remotes/rth-gitlab/tags/pull-tcg-20210629' into staging
TranslatorOps conversion for target/avr TranslatorOps conversion for target/cris TranslatorOps conversion for target/nios2 Simple vector operations on TCGv_i32 Host signal fixes for *BSD Improvements to tcg bswap operations # gpg: Signature made Tue 29 Jun 2021 19:51:03 BST # gpg: using RSA key 7A481E78868B4DB6A85A05C064DF38E8AF7E215F # gpg: issuer "richard.henderson@linaro.org" # gpg: Good signature from "Richard Henderson <richard.henderson@linaro.org>" [full] # Primary key fingerprint: 7A48 1E78 868B 4DB6 A85A 05C0 64DF 38E8 AF7E 215F * remotes/rth-gitlab/tags/pull-tcg-20210629: (63 commits) tcg/riscv: Remove MO_BSWAP handling tcg/aarch64: Unset TCG_TARGET_HAS_MEMORY_BSWAP tcg/arm: Unset TCG_TARGET_HAS_MEMORY_BSWAP target/mips: Fix gen_mxu_s32ldd_s32lddr target/sh4: Improve swap.b translation target/i386: Improve bswap translation target/arm: Improve REVSH target/arm: Improve vector REV target/arm: Improve REV32 tcg: Make use of bswap flags in tcg_gen_qemu_st_* tcg: Make use of bswap flags in tcg_gen_qemu_ld_* tcg: Add flags argument to tcg_gen_bswap16_*, tcg_gen_bswap32_i64 tcg: Handle new bswap flags during optimize tcg/tci: Support bswap flags tcg/mips: Support bswap flags in tcg_out_bswap32 tcg/mips: Support bswap flags in tcg_out_bswap16 tcg/s390: Support bswap flags tcg/ppc: Use power10 byte-reverse instructions tcg/ppc: Support bswap flags tcg/ppc: Split out tcg_out_bswap64 ... Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
+18
-2
@@ -254,28 +254,35 @@ void *probe_access(CPUArchState *env, target_ulong addr, int size,
|
||||
|
||||
#if defined(__NetBSD__)
|
||||
#include <ucontext.h>
|
||||
#include <machine/trap.h>
|
||||
|
||||
#define EIP_sig(context) ((context)->uc_mcontext.__gregs[_REG_EIP])
|
||||
#define TRAP_sig(context) ((context)->uc_mcontext.__gregs[_REG_TRAPNO])
|
||||
#define ERROR_sig(context) ((context)->uc_mcontext.__gregs[_REG_ERR])
|
||||
#define MASK_sig(context) ((context)->uc_sigmask)
|
||||
#define PAGE_FAULT_TRAP T_PAGEFLT
|
||||
#elif defined(__FreeBSD__) || defined(__DragonFly__)
|
||||
#include <ucontext.h>
|
||||
#include <machine/trap.h>
|
||||
|
||||
#define EIP_sig(context) (*((unsigned long *)&(context)->uc_mcontext.mc_eip))
|
||||
#define TRAP_sig(context) ((context)->uc_mcontext.mc_trapno)
|
||||
#define ERROR_sig(context) ((context)->uc_mcontext.mc_err)
|
||||
#define MASK_sig(context) ((context)->uc_sigmask)
|
||||
#define PAGE_FAULT_TRAP T_PAGEFLT
|
||||
#elif defined(__OpenBSD__)
|
||||
#include <machine/trap.h>
|
||||
#define EIP_sig(context) ((context)->sc_eip)
|
||||
#define TRAP_sig(context) ((context)->sc_trapno)
|
||||
#define ERROR_sig(context) ((context)->sc_err)
|
||||
#define MASK_sig(context) ((context)->sc_mask)
|
||||
#define PAGE_FAULT_TRAP T_PAGEFLT
|
||||
#else
|
||||
#define EIP_sig(context) ((context)->uc_mcontext.gregs[REG_EIP])
|
||||
#define TRAP_sig(context) ((context)->uc_mcontext.gregs[REG_TRAPNO])
|
||||
#define ERROR_sig(context) ((context)->uc_mcontext.gregs[REG_ERR])
|
||||
#define MASK_sig(context) ((context)->uc_sigmask)
|
||||
#define PAGE_FAULT_TRAP 0xe
|
||||
#endif
|
||||
|
||||
int cpu_signal_handler(int host_signum, void *pinfo,
|
||||
@@ -301,34 +308,42 @@ int cpu_signal_handler(int host_signum, void *pinfo,
|
||||
pc = EIP_sig(uc);
|
||||
trapno = TRAP_sig(uc);
|
||||
return handle_cpu_signal(pc, info,
|
||||
trapno == 0xe ? (ERROR_sig(uc) >> 1) & 1 : 0,
|
||||
trapno == PAGE_FAULT_TRAP ?
|
||||
(ERROR_sig(uc) >> 1) & 1 : 0,
|
||||
&MASK_sig(uc));
|
||||
}
|
||||
|
||||
#elif defined(__x86_64__)
|
||||
|
||||
#ifdef __NetBSD__
|
||||
#include <machine/trap.h>
|
||||
#define PC_sig(context) _UC_MACHINE_PC(context)
|
||||
#define TRAP_sig(context) ((context)->uc_mcontext.__gregs[_REG_TRAPNO])
|
||||
#define ERROR_sig(context) ((context)->uc_mcontext.__gregs[_REG_ERR])
|
||||
#define MASK_sig(context) ((context)->uc_sigmask)
|
||||
#define PAGE_FAULT_TRAP T_PAGEFLT
|
||||
#elif defined(__OpenBSD__)
|
||||
#include <machine/trap.h>
|
||||
#define PC_sig(context) ((context)->sc_rip)
|
||||
#define TRAP_sig(context) ((context)->sc_trapno)
|
||||
#define ERROR_sig(context) ((context)->sc_err)
|
||||
#define MASK_sig(context) ((context)->sc_mask)
|
||||
#define PAGE_FAULT_TRAP T_PAGEFLT
|
||||
#elif defined(__FreeBSD__) || defined(__DragonFly__)
|
||||
#include <ucontext.h>
|
||||
#include <machine/trap.h>
|
||||
|
||||
#define PC_sig(context) (*((unsigned long *)&(context)->uc_mcontext.mc_rip))
|
||||
#define TRAP_sig(context) ((context)->uc_mcontext.mc_trapno)
|
||||
#define ERROR_sig(context) ((context)->uc_mcontext.mc_err)
|
||||
#define MASK_sig(context) ((context)->uc_sigmask)
|
||||
#define PAGE_FAULT_TRAP T_PAGEFLT
|
||||
#else
|
||||
#define PC_sig(context) ((context)->uc_mcontext.gregs[REG_RIP])
|
||||
#define TRAP_sig(context) ((context)->uc_mcontext.gregs[REG_TRAPNO])
|
||||
#define ERROR_sig(context) ((context)->uc_mcontext.gregs[REG_ERR])
|
||||
#define MASK_sig(context) ((context)->uc_sigmask)
|
||||
#define PAGE_FAULT_TRAP 0xe
|
||||
#endif
|
||||
|
||||
int cpu_signal_handler(int host_signum, void *pinfo,
|
||||
@@ -346,7 +361,8 @@ int cpu_signal_handler(int host_signum, void *pinfo,
|
||||
|
||||
pc = PC_sig(uc);
|
||||
return handle_cpu_signal(pc, info,
|
||||
TRAP_sig(uc) == 0xe ? (ERROR_sig(uc) >> 1) & 1 : 0,
|
||||
TRAP_sig(uc) == PAGE_FAULT_TRAP ?
|
||||
(ERROR_sig(uc) >> 1) & 1 : 0,
|
||||
&MASK_sig(uc));
|
||||
}
|
||||
|
||||
|
||||
@@ -401,4 +401,47 @@ void tcg_gen_vec_sar16i_i64(TCGv_i64 d, TCGv_i64 a, int64_t);
|
||||
void tcg_gen_vec_rotl8i_i64(TCGv_i64 d, TCGv_i64 a, int64_t c);
|
||||
void tcg_gen_vec_rotl16i_i64(TCGv_i64 d, TCGv_i64 a, int64_t c);
|
||||
|
||||
/* 32-bit vector operations. */
|
||||
void tcg_gen_vec_add8_i32(TCGv_i32 d, TCGv_i32 a, TCGv_i32 b);
|
||||
void tcg_gen_vec_add16_i32(TCGv_i32 d, TCGv_i32 a, TCGv_i32 b);
|
||||
|
||||
void tcg_gen_vec_sub8_i32(TCGv_i32 d, TCGv_i32 a, TCGv_i32 b);
|
||||
void tcg_gen_vec_sub16_i32(TCGv_i32 d, TCGv_i32 a, TCGv_i32 b);
|
||||
|
||||
void tcg_gen_vec_shl8i_i32(TCGv_i32 d, TCGv_i32 a, int32_t);
|
||||
void tcg_gen_vec_shl16i_i32(TCGv_i32 d, TCGv_i32 a, int32_t);
|
||||
void tcg_gen_vec_shr8i_i32(TCGv_i32 d, TCGv_i32 a, int32_t);
|
||||
void tcg_gen_vec_shr16i_i32(TCGv_i32 d, TCGv_i32 a, int32_t);
|
||||
void tcg_gen_vec_sar8i_i32(TCGv_i32 d, TCGv_i32 a, int32_t);
|
||||
void tcg_gen_vec_sar16i_i32(TCGv_i32 d, TCGv_i32 a, int32_t);
|
||||
|
||||
#if TARGET_LONG_BITS == 64
|
||||
#define tcg_gen_vec_add8_tl tcg_gen_vec_add8_i64
|
||||
#define tcg_gen_vec_sub8_tl tcg_gen_vec_sub8_i64
|
||||
#define tcg_gen_vec_add16_tl tcg_gen_vec_add16_i64
|
||||
#define tcg_gen_vec_sub16_tl tcg_gen_vec_sub16_i64
|
||||
#define tcg_gen_vec_add32_tl tcg_gen_vec_add32_i64
|
||||
#define tcg_gen_vec_sub32_tl tcg_gen_vec_sub32_i64
|
||||
#define tcg_gen_vec_shl8i_tl tcg_gen_vec_shl8i_i64
|
||||
#define tcg_gen_vec_shr8i_tl tcg_gen_vec_shr8i_i64
|
||||
#define tcg_gen_vec_sar8i_tl tcg_gen_vec_sar8i_i64
|
||||
#define tcg_gen_vec_shl16i_tl tcg_gen_vec_shl16i_i64
|
||||
#define tcg_gen_vec_shr16i_tl tcg_gen_vec_shr16i_i64
|
||||
#define tcg_gen_vec_sar16i_tl tcg_gen_vec_sar16i_i64
|
||||
|
||||
#else
|
||||
#define tcg_gen_vec_add8_tl tcg_gen_vec_add8_i32
|
||||
#define tcg_gen_vec_sub8_tl tcg_gen_vec_sub8_i32
|
||||
#define tcg_gen_vec_add16_tl tcg_gen_vec_add16_i32
|
||||
#define tcg_gen_vec_sub16_tl tcg_gen_vec_sub16_i32
|
||||
#define tcg_gen_vec_add32_tl tcg_gen_add_i32
|
||||
#define tcg_gen_vec_sub32_tl tcg_gen_sub_i32
|
||||
#define tcg_gen_vec_shl8i_tl tcg_gen_vec_shl8i_i32
|
||||
#define tcg_gen_vec_shr8i_tl tcg_gen_vec_shr8i_i32
|
||||
#define tcg_gen_vec_sar8i_tl tcg_gen_vec_sar8i_i32
|
||||
#define tcg_gen_vec_shl16i_tl tcg_gen_vec_shl16i_i32
|
||||
#define tcg_gen_vec_shr16i_tl tcg_gen_vec_shr16i_i32
|
||||
#define tcg_gen_vec_sar16i_tl tcg_gen_vec_sar16i_i32
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -330,7 +330,7 @@ void tcg_gen_ext8s_i32(TCGv_i32 ret, TCGv_i32 arg);
|
||||
void tcg_gen_ext16s_i32(TCGv_i32 ret, TCGv_i32 arg);
|
||||
void tcg_gen_ext8u_i32(TCGv_i32 ret, TCGv_i32 arg);
|
||||
void tcg_gen_ext16u_i32(TCGv_i32 ret, TCGv_i32 arg);
|
||||
void tcg_gen_bswap16_i32(TCGv_i32 ret, TCGv_i32 arg);
|
||||
void tcg_gen_bswap16_i32(TCGv_i32 ret, TCGv_i32 arg, int flags);
|
||||
void tcg_gen_bswap32_i32(TCGv_i32 ret, TCGv_i32 arg);
|
||||
void tcg_gen_smin_i32(TCGv_i32, TCGv_i32 arg1, TCGv_i32 arg2);
|
||||
void tcg_gen_smax_i32(TCGv_i32, TCGv_i32 arg1, TCGv_i32 arg2);
|
||||
@@ -528,8 +528,8 @@ void tcg_gen_ext32s_i64(TCGv_i64 ret, TCGv_i64 arg);
|
||||
void tcg_gen_ext8u_i64(TCGv_i64 ret, TCGv_i64 arg);
|
||||
void tcg_gen_ext16u_i64(TCGv_i64 ret, TCGv_i64 arg);
|
||||
void tcg_gen_ext32u_i64(TCGv_i64 ret, TCGv_i64 arg);
|
||||
void tcg_gen_bswap16_i64(TCGv_i64 ret, TCGv_i64 arg);
|
||||
void tcg_gen_bswap32_i64(TCGv_i64 ret, TCGv_i64 arg);
|
||||
void tcg_gen_bswap16_i64(TCGv_i64 ret, TCGv_i64 arg, int flags);
|
||||
void tcg_gen_bswap32_i64(TCGv_i64 ret, TCGv_i64 arg, int flags);
|
||||
void tcg_gen_bswap64_i64(TCGv_i64 ret, TCGv_i64 arg);
|
||||
void tcg_gen_smin_i64(TCGv_i64, TCGv_i64 arg1, TCGv_i64 arg2);
|
||||
void tcg_gen_smax_i64(TCGv_i64, TCGv_i64 arg1, TCGv_i64 arg2);
|
||||
@@ -1192,7 +1192,7 @@ void tcg_gen_stl_vec(TCGv_vec r, TCGv_ptr base, TCGArg offset, TCGType t);
|
||||
#define tcg_gen_ext32u_tl tcg_gen_mov_i32
|
||||
#define tcg_gen_ext32s_tl tcg_gen_mov_i32
|
||||
#define tcg_gen_bswap16_tl tcg_gen_bswap16_i32
|
||||
#define tcg_gen_bswap32_tl tcg_gen_bswap32_i32
|
||||
#define tcg_gen_bswap32_tl(D, S, F) tcg_gen_bswap32_i32(D, S)
|
||||
#define tcg_gen_bswap_tl tcg_gen_bswap32_i32
|
||||
#define tcg_gen_concat_tl_i64 tcg_gen_concat_i32_i64
|
||||
#define tcg_gen_extr_i64_tl tcg_gen_extr_i64_i32
|
||||
|
||||
@@ -96,8 +96,8 @@ DEF(ext8s_i32, 1, 1, 0, IMPL(TCG_TARGET_HAS_ext8s_i32))
|
||||
DEF(ext16s_i32, 1, 1, 0, IMPL(TCG_TARGET_HAS_ext16s_i32))
|
||||
DEF(ext8u_i32, 1, 1, 0, IMPL(TCG_TARGET_HAS_ext8u_i32))
|
||||
DEF(ext16u_i32, 1, 1, 0, IMPL(TCG_TARGET_HAS_ext16u_i32))
|
||||
DEF(bswap16_i32, 1, 1, 0, IMPL(TCG_TARGET_HAS_bswap16_i32))
|
||||
DEF(bswap32_i32, 1, 1, 0, IMPL(TCG_TARGET_HAS_bswap32_i32))
|
||||
DEF(bswap16_i32, 1, 1, 1, IMPL(TCG_TARGET_HAS_bswap16_i32))
|
||||
DEF(bswap32_i32, 1, 1, 1, IMPL(TCG_TARGET_HAS_bswap32_i32))
|
||||
DEF(not_i32, 1, 1, 0, IMPL(TCG_TARGET_HAS_not_i32))
|
||||
DEF(neg_i32, 1, 1, 0, IMPL(TCG_TARGET_HAS_neg_i32))
|
||||
DEF(andc_i32, 1, 2, 0, IMPL(TCG_TARGET_HAS_andc_i32))
|
||||
@@ -165,9 +165,9 @@ DEF(ext32s_i64, 1, 1, 0, IMPL64 | IMPL(TCG_TARGET_HAS_ext32s_i64))
|
||||
DEF(ext8u_i64, 1, 1, 0, IMPL64 | IMPL(TCG_TARGET_HAS_ext8u_i64))
|
||||
DEF(ext16u_i64, 1, 1, 0, IMPL64 | IMPL(TCG_TARGET_HAS_ext16u_i64))
|
||||
DEF(ext32u_i64, 1, 1, 0, IMPL64 | IMPL(TCG_TARGET_HAS_ext32u_i64))
|
||||
DEF(bswap16_i64, 1, 1, 0, IMPL64 | IMPL(TCG_TARGET_HAS_bswap16_i64))
|
||||
DEF(bswap32_i64, 1, 1, 0, IMPL64 | IMPL(TCG_TARGET_HAS_bswap32_i64))
|
||||
DEF(bswap64_i64, 1, 1, 0, IMPL64 | IMPL(TCG_TARGET_HAS_bswap64_i64))
|
||||
DEF(bswap16_i64, 1, 1, 1, IMPL64 | IMPL(TCG_TARGET_HAS_bswap16_i64))
|
||||
DEF(bswap32_i64, 1, 1, 1, IMPL64 | IMPL(TCG_TARGET_HAS_bswap32_i64))
|
||||
DEF(bswap64_i64, 1, 1, 1, IMPL64 | IMPL(TCG_TARGET_HAS_bswap64_i64))
|
||||
DEF(not_i64, 1, 1, 0, IMPL64 | IMPL(TCG_TARGET_HAS_not_i64))
|
||||
DEF(neg_i64, 1, 1, 0, IMPL64 | IMPL(TCG_TARGET_HAS_neg_i64))
|
||||
DEF(andc_i64, 1, 2, 0, IMPL64 | IMPL(TCG_TARGET_HAS_andc_i64))
|
||||
|
||||
@@ -408,6 +408,18 @@ typedef TCGv_ptr TCGv_env;
|
||||
/* Used to align parameters. See the comment before tcgv_i32_temp. */
|
||||
#define TCG_CALL_DUMMY_ARG ((TCGArg)0)
|
||||
|
||||
/*
|
||||
* Flags for the bswap opcodes.
|
||||
* If IZ, the input is zero-extended, otherwise unknown.
|
||||
* If OZ or OS, the output is zero- or sign-extended respectively,
|
||||
* otherwise the high bits are undefined.
|
||||
*/
|
||||
enum {
|
||||
TCG_BSWAP_IZ = 1,
|
||||
TCG_BSWAP_OZ = 2,
|
||||
TCG_BSWAP_OS = 4,
|
||||
};
|
||||
|
||||
typedef enum TCGTempVal {
|
||||
TEMP_VAL_DEAD,
|
||||
TEMP_VAL_REG,
|
||||
|
||||
@@ -5430,22 +5430,13 @@ static void handle_rev32(DisasContext *s, unsigned int sf,
|
||||
unsigned int rn, unsigned int rd)
|
||||
{
|
||||
TCGv_i64 tcg_rd = cpu_reg(s, rd);
|
||||
TCGv_i64 tcg_rn = cpu_reg(s, rn);
|
||||
|
||||
if (sf) {
|
||||
TCGv_i64 tcg_tmp = tcg_temp_new_i64();
|
||||
TCGv_i64 tcg_rn = read_cpu_reg(s, rn, sf);
|
||||
|
||||
/* bswap32_i64 requires zero high word */
|
||||
tcg_gen_ext32u_i64(tcg_tmp, tcg_rn);
|
||||
tcg_gen_bswap32_i64(tcg_rd, tcg_tmp);
|
||||
tcg_gen_shri_i64(tcg_tmp, tcg_rn, 32);
|
||||
tcg_gen_bswap32_i64(tcg_tmp, tcg_tmp);
|
||||
tcg_gen_concat32_i64(tcg_rd, tcg_rd, tcg_tmp);
|
||||
|
||||
tcg_temp_free_i64(tcg_tmp);
|
||||
tcg_gen_bswap64_i64(tcg_rd, tcg_rn);
|
||||
tcg_gen_rotri_i64(tcg_rd, tcg_rd, 32);
|
||||
} else {
|
||||
tcg_gen_ext32u_i64(tcg_rd, cpu_reg(s, rn));
|
||||
tcg_gen_bswap32_i64(tcg_rd, tcg_rd);
|
||||
tcg_gen_bswap32_i64(tcg_rd, tcg_rn, TCG_BSWAP_OZ);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12453,10 +12444,10 @@ static void handle_rev(DisasContext *s, int opcode, bool u,
|
||||
read_vec_element(s, tcg_tmp, rn, i, grp_size);
|
||||
switch (grp_size) {
|
||||
case MO_16:
|
||||
tcg_gen_bswap16_i64(tcg_tmp, tcg_tmp);
|
||||
tcg_gen_bswap16_i64(tcg_tmp, tcg_tmp, TCG_BSWAP_IZ);
|
||||
break;
|
||||
case MO_32:
|
||||
tcg_gen_bswap32_i64(tcg_tmp, tcg_tmp);
|
||||
tcg_gen_bswap32_i64(tcg_tmp, tcg_tmp, TCG_BSWAP_IZ);
|
||||
break;
|
||||
case MO_64:
|
||||
tcg_gen_bswap64_i64(tcg_tmp, tcg_tmp);
|
||||
|
||||
@@ -354,9 +354,7 @@ void gen_rev16(TCGv_i32 dest, TCGv_i32 var)
|
||||
/* Byteswap low halfword and sign extend. */
|
||||
static void gen_revsh(TCGv_i32 dest, TCGv_i32 var)
|
||||
{
|
||||
tcg_gen_ext16u_i32(var, var);
|
||||
tcg_gen_bswap16_i32(var, var);
|
||||
tcg_gen_ext16s_i32(dest, var);
|
||||
tcg_gen_bswap16_i32(var, var, TCG_BSWAP_OS);
|
||||
}
|
||||
|
||||
/* Dual 16-bit add. Result placed in t0 and t1 is marked as dead.
|
||||
|
||||
+154
-130
@@ -80,7 +80,7 @@ typedef struct DisasContext DisasContext;
|
||||
|
||||
/* This is the state at translation time. */
|
||||
struct DisasContext {
|
||||
TranslationBlock *tb;
|
||||
DisasContextBase base;
|
||||
|
||||
CPUAVRState *env;
|
||||
CPUState *cs;
|
||||
@@ -90,8 +90,6 @@ struct DisasContext {
|
||||
|
||||
/* Routine used to access memory */
|
||||
int memidx;
|
||||
int bstate;
|
||||
int singlestep;
|
||||
|
||||
/*
|
||||
* some AVR instructions can make the following instruction to be skipped
|
||||
@@ -106,7 +104,7 @@ struct DisasContext {
|
||||
* used in the following manner (sketch)
|
||||
*
|
||||
* TCGLabel *skip_label = NULL;
|
||||
* if (ctx.skip_cond != TCG_COND_NEVER) {
|
||||
* if (ctx->skip_cond != TCG_COND_NEVER) {
|
||||
* skip_label = gen_new_label();
|
||||
* tcg_gen_brcond_tl(skip_cond, skip_var0, skip_var1, skip_label);
|
||||
* }
|
||||
@@ -116,7 +114,7 @@ struct DisasContext {
|
||||
* free_skip_var0 = false;
|
||||
* }
|
||||
*
|
||||
* translate(&ctx);
|
||||
* translate(ctx);
|
||||
*
|
||||
* if (skip_label) {
|
||||
* gen_set_label(skip_label);
|
||||
@@ -191,7 +189,7 @@ static bool avr_have_feature(DisasContext *ctx, int feature)
|
||||
{
|
||||
if (!avr_feature(ctx->env, feature)) {
|
||||
gen_helper_unsupported(cpu_env);
|
||||
ctx->bstate = DISAS_NORETURN;
|
||||
ctx->base.is_jmp = DISAS_NORETURN;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@@ -1011,13 +1009,13 @@ static void gen_jmp_ez(DisasContext *ctx)
|
||||
{
|
||||
tcg_gen_deposit_tl(cpu_pc, cpu_r[30], cpu_r[31], 8, 8);
|
||||
tcg_gen_or_tl(cpu_pc, cpu_pc, cpu_eind);
|
||||
ctx->bstate = DISAS_LOOKUP;
|
||||
ctx->base.is_jmp = DISAS_LOOKUP;
|
||||
}
|
||||
|
||||
static void gen_jmp_z(DisasContext *ctx)
|
||||
{
|
||||
tcg_gen_deposit_tl(cpu_pc, cpu_r[30], cpu_r[31], 8, 8);
|
||||
ctx->bstate = DISAS_LOOKUP;
|
||||
ctx->base.is_jmp = DISAS_LOOKUP;
|
||||
}
|
||||
|
||||
static void gen_push_ret(DisasContext *ctx, int ret)
|
||||
@@ -1083,9 +1081,9 @@ static void gen_pop_ret(DisasContext *ctx, TCGv ret)
|
||||
|
||||
static void gen_goto_tb(DisasContext *ctx, int n, target_ulong dest)
|
||||
{
|
||||
TranslationBlock *tb = ctx->tb;
|
||||
const TranslationBlock *tb = ctx->base.tb;
|
||||
|
||||
if (ctx->singlestep == 0) {
|
||||
if (!ctx->base.singlestep_enabled) {
|
||||
tcg_gen_goto_tb(n);
|
||||
tcg_gen_movi_i32(cpu_pc, dest);
|
||||
tcg_gen_exit_tb(tb, n);
|
||||
@@ -1094,7 +1092,7 @@ static void gen_goto_tb(DisasContext *ctx, int n, target_ulong dest)
|
||||
gen_helper_debug(cpu_env);
|
||||
tcg_gen_exit_tb(NULL, 0);
|
||||
}
|
||||
ctx->bstate = DISAS_NORETURN;
|
||||
ctx->base.is_jmp = DISAS_NORETURN;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1254,7 +1252,7 @@ static bool trans_RET(DisasContext *ctx, arg_RET *a)
|
||||
{
|
||||
gen_pop_ret(ctx, cpu_pc);
|
||||
|
||||
ctx->bstate = DISAS_LOOKUP;
|
||||
ctx->base.is_jmp = DISAS_LOOKUP;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1272,7 +1270,7 @@ static bool trans_RETI(DisasContext *ctx, arg_RETI *a)
|
||||
tcg_gen_movi_tl(cpu_If, 1);
|
||||
|
||||
/* Need to return to main loop to re-evaluate interrupts. */
|
||||
ctx->bstate = DISAS_EXIT;
|
||||
ctx->base.is_jmp = DISAS_EXIT;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1484,7 +1482,7 @@ static bool trans_BRBC(DisasContext *ctx, arg_BRBC *a)
|
||||
gen_goto_tb(ctx, 0, ctx->npc + a->imm);
|
||||
gen_set_label(not_taken);
|
||||
|
||||
ctx->bstate = DISAS_CHAIN;
|
||||
ctx->base.is_jmp = DISAS_CHAIN;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1533,7 +1531,7 @@ static bool trans_BRBS(DisasContext *ctx, arg_BRBS *a)
|
||||
gen_goto_tb(ctx, 0, ctx->npc + a->imm);
|
||||
gen_set_label(not_taken);
|
||||
|
||||
ctx->bstate = DISAS_CHAIN;
|
||||
ctx->base.is_jmp = DISAS_CHAIN;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1610,7 +1608,7 @@ static TCGv gen_get_zaddr(void)
|
||||
*/
|
||||
static void gen_data_store(DisasContext *ctx, TCGv data, TCGv addr)
|
||||
{
|
||||
if (ctx->tb->flags & TB_FLAGS_FULL_ACCESS) {
|
||||
if (ctx->base.tb->flags & TB_FLAGS_FULL_ACCESS) {
|
||||
gen_helper_fullwr(cpu_env, data, addr);
|
||||
} else {
|
||||
tcg_gen_qemu_st8(data, addr, MMU_DATA_IDX); /* mem[addr] = data */
|
||||
@@ -1619,7 +1617,7 @@ static void gen_data_store(DisasContext *ctx, TCGv data, TCGv addr)
|
||||
|
||||
static void gen_data_load(DisasContext *ctx, TCGv data, TCGv addr)
|
||||
{
|
||||
if (ctx->tb->flags & TB_FLAGS_FULL_ACCESS) {
|
||||
if (ctx->base.tb->flags & TB_FLAGS_FULL_ACCESS) {
|
||||
gen_helper_fullrd(data, cpu_env, addr);
|
||||
} else {
|
||||
tcg_gen_qemu_ld8u(data, addr, MMU_DATA_IDX); /* data = mem[addr] */
|
||||
@@ -2793,7 +2791,7 @@ static bool trans_BREAK(DisasContext *ctx, arg_BREAK *a)
|
||||
#ifdef BREAKPOINT_ON_BREAK
|
||||
tcg_gen_movi_tl(cpu_pc, ctx->npc - 1);
|
||||
gen_helper_debug(cpu_env);
|
||||
ctx->bstate = DISAS_EXIT;
|
||||
ctx->base.is_jmp = DISAS_EXIT;
|
||||
#else
|
||||
/* NOP */
|
||||
#endif
|
||||
@@ -2819,7 +2817,7 @@ static bool trans_NOP(DisasContext *ctx, arg_NOP *a)
|
||||
static bool trans_SLEEP(DisasContext *ctx, arg_SLEEP *a)
|
||||
{
|
||||
gen_helper_sleep(cpu_env);
|
||||
ctx->bstate = DISAS_NORETURN;
|
||||
ctx->base.is_jmp = DISAS_NORETURN;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -2850,7 +2848,7 @@ static void translate(DisasContext *ctx)
|
||||
|
||||
if (!decode_insn(ctx, opcode)) {
|
||||
gen_helper_unsupported(cpu_env);
|
||||
ctx->bstate = DISAS_NORETURN;
|
||||
ctx->base.is_jmp = DISAS_NORETURN;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2899,112 +2897,134 @@ static bool canonicalize_skip(DisasContext *ctx)
|
||||
return true;
|
||||
}
|
||||
|
||||
void gen_intermediate_code(CPUState *cs, TranslationBlock *tb, int max_insns)
|
||||
static void gen_breakpoint(DisasContext *ctx)
|
||||
{
|
||||
CPUAVRState *env = cs->env_ptr;
|
||||
DisasContext ctx = {
|
||||
.tb = tb,
|
||||
.cs = cs,
|
||||
.env = env,
|
||||
.memidx = 0,
|
||||
.bstate = DISAS_NEXT,
|
||||
.skip_cond = TCG_COND_NEVER,
|
||||
.singlestep = cs->singlestep_enabled,
|
||||
};
|
||||
target_ulong pc_start = tb->pc / 2;
|
||||
int num_insns = 0;
|
||||
canonicalize_skip(ctx);
|
||||
tcg_gen_movi_tl(cpu_pc, ctx->npc);
|
||||
gen_helper_debug(cpu_env);
|
||||
ctx->base.is_jmp = DISAS_NORETURN;
|
||||
}
|
||||
|
||||
if (tb->flags & TB_FLAGS_FULL_ACCESS) {
|
||||
static void avr_tr_init_disas_context(DisasContextBase *dcbase, CPUState *cs)
|
||||
{
|
||||
DisasContext *ctx = container_of(dcbase, DisasContext, base);
|
||||
CPUAVRState *env = cs->env_ptr;
|
||||
uint32_t tb_flags = ctx->base.tb->flags;
|
||||
|
||||
ctx->cs = cs;
|
||||
ctx->env = env;
|
||||
ctx->npc = ctx->base.pc_first / 2;
|
||||
|
||||
ctx->skip_cond = TCG_COND_NEVER;
|
||||
if (tb_flags & TB_FLAGS_SKIP) {
|
||||
ctx->skip_cond = TCG_COND_ALWAYS;
|
||||
ctx->skip_var0 = cpu_skip;
|
||||
}
|
||||
|
||||
if (tb_flags & TB_FLAGS_FULL_ACCESS) {
|
||||
/*
|
||||
* This flag is set by ST/LD instruction we will regenerate it ONLY
|
||||
* with mem/cpu memory access instead of mem access
|
||||
*/
|
||||
max_insns = 1;
|
||||
ctx->base.max_insns = 1;
|
||||
}
|
||||
if (ctx.singlestep) {
|
||||
max_insns = 1;
|
||||
}
|
||||
|
||||
static void avr_tr_tb_start(DisasContextBase *db, CPUState *cs)
|
||||
{
|
||||
}
|
||||
|
||||
static void avr_tr_insn_start(DisasContextBase *dcbase, CPUState *cs)
|
||||
{
|
||||
DisasContext *ctx = container_of(dcbase, DisasContext, base);
|
||||
|
||||
tcg_gen_insn_start(ctx->npc);
|
||||
}
|
||||
|
||||
static bool avr_tr_breakpoint_check(DisasContextBase *dcbase, CPUState *cs,
|
||||
const CPUBreakpoint *bp)
|
||||
{
|
||||
DisasContext *ctx = container_of(dcbase, DisasContext, base);
|
||||
|
||||
gen_breakpoint(ctx);
|
||||
return true;
|
||||
}
|
||||
|
||||
static void avr_tr_translate_insn(DisasContextBase *dcbase, CPUState *cs)
|
||||
{
|
||||
DisasContext *ctx = container_of(dcbase, DisasContext, base);
|
||||
TCGLabel *skip_label = NULL;
|
||||
|
||||
/*
|
||||
* This is due to some strange GDB behavior
|
||||
* Let's assume main has address 0x100:
|
||||
* b main - sets breakpoint at address 0x00000100 (code)
|
||||
* b *0x100 - sets breakpoint at address 0x00800100 (data)
|
||||
*
|
||||
* The translator driver has already taken care of the code pointer.
|
||||
*/
|
||||
if (!ctx->base.singlestep_enabled &&
|
||||
cpu_breakpoint_test(cs, OFFSET_DATA + ctx->base.pc_next, BP_ANY)) {
|
||||
gen_breakpoint(ctx);
|
||||
return;
|
||||
}
|
||||
|
||||
gen_tb_start(tb);
|
||||
|
||||
ctx.npc = pc_start;
|
||||
if (tb->flags & TB_FLAGS_SKIP) {
|
||||
ctx.skip_cond = TCG_COND_ALWAYS;
|
||||
ctx.skip_var0 = cpu_skip;
|
||||
}
|
||||
|
||||
do {
|
||||
TCGLabel *skip_label = NULL;
|
||||
|
||||
/* translate current instruction */
|
||||
tcg_gen_insn_start(ctx.npc);
|
||||
num_insns++;
|
||||
|
||||
/*
|
||||
* this is due to some strange GDB behavior
|
||||
* let's assume main has address 0x100
|
||||
* b main - sets breakpoint at address 0x00000100 (code)
|
||||
* b *0x100 - sets breakpoint at address 0x00800100 (data)
|
||||
*/
|
||||
if (unlikely(!ctx.singlestep &&
|
||||
(cpu_breakpoint_test(cs, OFFSET_CODE + ctx.npc * 2, BP_ANY) ||
|
||||
cpu_breakpoint_test(cs, OFFSET_DATA + ctx.npc * 2, BP_ANY)))) {
|
||||
canonicalize_skip(&ctx);
|
||||
tcg_gen_movi_tl(cpu_pc, ctx.npc);
|
||||
gen_helper_debug(cpu_env);
|
||||
goto done_generating;
|
||||
/* Conditionally skip the next instruction, if indicated. */
|
||||
if (ctx->skip_cond != TCG_COND_NEVER) {
|
||||
skip_label = gen_new_label();
|
||||
if (ctx->skip_var0 == cpu_skip) {
|
||||
/*
|
||||
* Copy cpu_skip so that we may zero it before the branch.
|
||||
* This ensures that cpu_skip is non-zero after the label
|
||||
* if and only if the skipped insn itself sets a skip.
|
||||
*/
|
||||
ctx->free_skip_var0 = true;
|
||||
ctx->skip_var0 = tcg_temp_new();
|
||||
tcg_gen_mov_tl(ctx->skip_var0, cpu_skip);
|
||||
tcg_gen_movi_tl(cpu_skip, 0);
|
||||
}
|
||||
|
||||
/* Conditionally skip the next instruction, if indicated. */
|
||||
if (ctx.skip_cond != TCG_COND_NEVER) {
|
||||
skip_label = gen_new_label();
|
||||
if (ctx.skip_var0 == cpu_skip) {
|
||||
/*
|
||||
* Copy cpu_skip so that we may zero it before the branch.
|
||||
* This ensures that cpu_skip is non-zero after the label
|
||||
* if and only if the skipped insn itself sets a skip.
|
||||
*/
|
||||
ctx.free_skip_var0 = true;
|
||||
ctx.skip_var0 = tcg_temp_new();
|
||||
tcg_gen_mov_tl(ctx.skip_var0, cpu_skip);
|
||||
tcg_gen_movi_tl(cpu_skip, 0);
|
||||
}
|
||||
if (ctx.skip_var1 == NULL) {
|
||||
tcg_gen_brcondi_tl(ctx.skip_cond, ctx.skip_var0, 0, skip_label);
|
||||
} else {
|
||||
tcg_gen_brcond_tl(ctx.skip_cond, ctx.skip_var0,
|
||||
ctx.skip_var1, skip_label);
|
||||
ctx.skip_var1 = NULL;
|
||||
}
|
||||
if (ctx.free_skip_var0) {
|
||||
tcg_temp_free(ctx.skip_var0);
|
||||
ctx.free_skip_var0 = false;
|
||||
}
|
||||
ctx.skip_cond = TCG_COND_NEVER;
|
||||
ctx.skip_var0 = NULL;
|
||||
if (ctx->skip_var1 == NULL) {
|
||||
tcg_gen_brcondi_tl(ctx->skip_cond, ctx->skip_var0, 0, skip_label);
|
||||
} else {
|
||||
tcg_gen_brcond_tl(ctx->skip_cond, ctx->skip_var0,
|
||||
ctx->skip_var1, skip_label);
|
||||
ctx->skip_var1 = NULL;
|
||||
}
|
||||
|
||||
translate(&ctx);
|
||||
|
||||
if (skip_label) {
|
||||
canonicalize_skip(&ctx);
|
||||
gen_set_label(skip_label);
|
||||
if (ctx.bstate == DISAS_NORETURN) {
|
||||
ctx.bstate = DISAS_CHAIN;
|
||||
}
|
||||
if (ctx->free_skip_var0) {
|
||||
tcg_temp_free(ctx->skip_var0);
|
||||
ctx->free_skip_var0 = false;
|
||||
}
|
||||
} while (ctx.bstate == DISAS_NEXT
|
||||
&& num_insns < max_insns
|
||||
&& (ctx.npc - pc_start) * 2 < TARGET_PAGE_SIZE - 4
|
||||
&& !tcg_op_buf_full());
|
||||
|
||||
if (tb->cflags & CF_LAST_IO) {
|
||||
gen_io_end();
|
||||
ctx->skip_cond = TCG_COND_NEVER;
|
||||
ctx->skip_var0 = NULL;
|
||||
}
|
||||
|
||||
bool nonconst_skip = canonicalize_skip(&ctx);
|
||||
translate(ctx);
|
||||
|
||||
switch (ctx.bstate) {
|
||||
ctx->base.pc_next = ctx->npc * 2;
|
||||
|
||||
if (skip_label) {
|
||||
canonicalize_skip(ctx);
|
||||
gen_set_label(skip_label);
|
||||
if (ctx->base.is_jmp == DISAS_NORETURN) {
|
||||
ctx->base.is_jmp = DISAS_CHAIN;
|
||||
}
|
||||
}
|
||||
|
||||
if (ctx->base.is_jmp == DISAS_NEXT) {
|
||||
target_ulong page_first = ctx->base.pc_first & TARGET_PAGE_MASK;
|
||||
|
||||
if ((ctx->base.pc_next - page_first) >= TARGET_PAGE_SIZE - 4) {
|
||||
ctx->base.is_jmp = DISAS_TOO_MANY;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void avr_tr_tb_stop(DisasContextBase *dcbase, CPUState *cs)
|
||||
{
|
||||
DisasContext *ctx = container_of(dcbase, DisasContext, base);
|
||||
bool nonconst_skip = canonicalize_skip(ctx);
|
||||
|
||||
switch (ctx->base.is_jmp) {
|
||||
case DISAS_NORETURN:
|
||||
assert(!nonconst_skip);
|
||||
break;
|
||||
@@ -3013,19 +3033,19 @@ void gen_intermediate_code(CPUState *cs, TranslationBlock *tb, int max_insns)
|
||||
case DISAS_CHAIN:
|
||||
if (!nonconst_skip) {
|
||||
/* Note gen_goto_tb checks singlestep. */
|
||||
gen_goto_tb(&ctx, 1, ctx.npc);
|
||||
gen_goto_tb(ctx, 1, ctx->npc);
|
||||
break;
|
||||
}
|
||||
tcg_gen_movi_tl(cpu_pc, ctx.npc);
|
||||
tcg_gen_movi_tl(cpu_pc, ctx->npc);
|
||||
/* fall through */
|
||||
case DISAS_LOOKUP:
|
||||
if (!ctx.singlestep) {
|
||||
if (!ctx->base.singlestep_enabled) {
|
||||
tcg_gen_lookup_and_goto_ptr();
|
||||
break;
|
||||
}
|
||||
/* fall through */
|
||||
case DISAS_EXIT:
|
||||
if (ctx.singlestep) {
|
||||
if (ctx->base.singlestep_enabled) {
|
||||
gen_helper_debug(cpu_env);
|
||||
} else {
|
||||
tcg_gen_exit_tb(NULL, 0);
|
||||
@@ -3034,24 +3054,28 @@ void gen_intermediate_code(CPUState *cs, TranslationBlock *tb, int max_insns)
|
||||
default:
|
||||
g_assert_not_reached();
|
||||
}
|
||||
}
|
||||
|
||||
done_generating:
|
||||
gen_tb_end(tb, num_insns);
|
||||
static void avr_tr_disas_log(const DisasContextBase *dcbase, CPUState *cs)
|
||||
{
|
||||
qemu_log("IN: %s\n", lookup_symbol(dcbase->pc_first));
|
||||
log_target_disas(cs, dcbase->pc_first, dcbase->tb->size);
|
||||
}
|
||||
|
||||
tb->size = (ctx.npc - pc_start) * 2;
|
||||
tb->icount = num_insns;
|
||||
static const TranslatorOps avr_tr_ops = {
|
||||
.init_disas_context = avr_tr_init_disas_context,
|
||||
.tb_start = avr_tr_tb_start,
|
||||
.insn_start = avr_tr_insn_start,
|
||||
.breakpoint_check = avr_tr_breakpoint_check,
|
||||
.translate_insn = avr_tr_translate_insn,
|
||||
.tb_stop = avr_tr_tb_stop,
|
||||
.disas_log = avr_tr_disas_log,
|
||||
};
|
||||
|
||||
#ifdef DEBUG_DISAS
|
||||
if (qemu_loglevel_mask(CPU_LOG_TB_IN_ASM)
|
||||
&& qemu_log_in_addr_range(tb->pc)) {
|
||||
FILE *fd;
|
||||
fd = qemu_log_lock();
|
||||
qemu_log("IN: %s\n", lookup_symbol(tb->pc));
|
||||
log_target_disas(cs, tb->pc, tb->size);
|
||||
qemu_log("\n");
|
||||
qemu_log_unlock(fd);
|
||||
}
|
||||
#endif
|
||||
void gen_intermediate_code(CPUState *cs, TranslationBlock *tb, int max_insns)
|
||||
{
|
||||
DisasContext dc = { };
|
||||
translator_loop(&avr_tr_ops, &dc.base, cs, tb, max_insns);
|
||||
}
|
||||
|
||||
void restore_state_to_opc(CPUAVRState *env, TranslationBlock *tb,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
DEF_HELPER_2(raise_exception, void, env, i32)
|
||||
DEF_HELPER_2(raise_exception, noreturn, env, i32)
|
||||
DEF_HELPER_2(tlb_flush_pid, void, env, i32)
|
||||
DEF_HELPER_2(spc_write, void, env, i32)
|
||||
DEF_HELPER_1(rfe, void, env)
|
||||
|
||||
+255
-260
File diff suppressed because it is too large
Load Diff
@@ -21,7 +21,7 @@
|
||||
#include "qemu/osdep.h"
|
||||
#include "crisv10-decode.h"
|
||||
|
||||
static const char *regnames_v10[] =
|
||||
static const char * const regnames_v10[] =
|
||||
{
|
||||
"$r0", "$r1", "$r2", "$r3",
|
||||
"$r4", "$r5", "$r6", "$r7",
|
||||
@@ -29,7 +29,7 @@ static const char *regnames_v10[] =
|
||||
"$r12", "$r13", "$sp", "$pc",
|
||||
};
|
||||
|
||||
static const char *pregnames_v10[] =
|
||||
static const char * const pregnames_v10[] =
|
||||
{
|
||||
"$bz", "$vr", "$p2", "$p3",
|
||||
"$wz", "$ccr", "$p6-prefix", "$mof",
|
||||
@@ -38,7 +38,7 @@ static const char *pregnames_v10[] =
|
||||
};
|
||||
|
||||
/* We need this table to handle preg-moves with implicit width. */
|
||||
static int preg_sizes_v10[] = {
|
||||
static const int preg_sizes_v10[] = {
|
||||
1, /* bz. */
|
||||
1, /* vr. */
|
||||
1, /* pid. */
|
||||
@@ -61,6 +61,7 @@ static inline void cris_illegal_insn(DisasContext *dc)
|
||||
{
|
||||
qemu_log_mask(LOG_GUEST_ERROR, "illegal insn at pc=%x\n", dc->pc);
|
||||
t_gen_raise_exception(EXCP_BREAK);
|
||||
dc->base.is_jmp = DISAS_NORETURN;
|
||||
}
|
||||
|
||||
static void gen_store_v10_conditional(DisasContext *dc, TCGv addr, TCGv val,
|
||||
@@ -105,9 +106,8 @@ static void gen_store_v10(DisasContext *dc, TCGv addr, TCGv val,
|
||||
cris_store_direct_jmp(dc);
|
||||
}
|
||||
|
||||
/* Conditional writes. We only support the kind were X is known
|
||||
at translation time. */
|
||||
if (dc->flagx_known && dc->flags_x) {
|
||||
/* Conditional writes. */
|
||||
if (dc->flags_x) {
|
||||
gen_store_v10_conditional(dc, addr, val, size, mem_index);
|
||||
return;
|
||||
}
|
||||
@@ -375,7 +375,6 @@ static unsigned int dec10_setclrf(DisasContext *dc)
|
||||
|
||||
|
||||
if (flags & X_FLAG) {
|
||||
dc->flagx_known = 1;
|
||||
if (set)
|
||||
dc->flags_x = X_FLAG;
|
||||
else
|
||||
@@ -1169,7 +1168,7 @@ static unsigned int dec10_ind(CPUCRISState *env, DisasContext *dc)
|
||||
t_gen_mov_env_TN(trap_vector, c);
|
||||
tcg_temp_free(c);
|
||||
t_gen_raise_exception(EXCP_BREAK);
|
||||
dc->is_jmp = DISAS_UPDATE;
|
||||
dc->base.is_jmp = DISAS_NORETURN;
|
||||
return insn_len;
|
||||
}
|
||||
LOG_DIS("%d: jump.%d %d r%d r%d\n", __LINE__, size,
|
||||
@@ -1277,7 +1276,7 @@ static unsigned int crisv10_decoder(CPUCRISState *env, DisasContext *dc)
|
||||
if (dc->clear_prefix && dc->tb_flags & PFIX_FLAG) {
|
||||
dc->tb_flags &= ~PFIX_FLAG;
|
||||
tcg_gen_andi_tl(cpu_PR[PR_CCS], cpu_PR[PR_CCS], ~PFIX_FLAG);
|
||||
if (dc->tb_flags != dc->tb->flags) {
|
||||
if (dc->tb_flags != dc->base.tb->flags) {
|
||||
dc->cpustate_changed = 1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7195,17 +7195,11 @@ static target_ulong disas_insn(DisasContext *s, CPUState *cpu)
|
||||
reg = (b & 7) | REX_B(s);
|
||||
#ifdef TARGET_X86_64
|
||||
if (dflag == MO_64) {
|
||||
gen_op_mov_v_reg(s, MO_64, s->T0, reg);
|
||||
tcg_gen_bswap64_i64(s->T0, s->T0);
|
||||
gen_op_mov_reg_v(s, MO_64, reg, s->T0);
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
gen_op_mov_v_reg(s, MO_32, s->T0, reg);
|
||||
tcg_gen_ext32u_tl(s->T0, s->T0);
|
||||
tcg_gen_bswap32_tl(s->T0, s->T0);
|
||||
gen_op_mov_reg_v(s, MO_32, reg, s->T0);
|
||||
tcg_gen_bswap64_i64(cpu_regs[reg], cpu_regs[reg]);
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
tcg_gen_bswap32_tl(cpu_regs[reg], cpu_regs[reg], TCG_BSWAP_OZ);
|
||||
break;
|
||||
case 0xd6: /* salc */
|
||||
if (CODE64(s))
|
||||
|
||||
@@ -857,12 +857,8 @@ static void gen_mxu_s32ldd_s32lddr(DisasContext *ctx)
|
||||
tcg_gen_ori_tl(t1, t1, 0xFFFFF000);
|
||||
}
|
||||
tcg_gen_add_tl(t1, t0, t1);
|
||||
tcg_gen_qemu_ld_tl(t1, t1, ctx->mem_idx, MO_SL);
|
||||
tcg_gen_qemu_ld_tl(t1, t1, ctx->mem_idx, MO_TESL ^ (sel * MO_BSWAP));
|
||||
|
||||
if (sel == 1) {
|
||||
/* S32LDDR */
|
||||
tcg_gen_bswap32_tl(t1, t1);
|
||||
}
|
||||
gen_store_mxu_gpr(t1, XRa);
|
||||
|
||||
tcg_temp_free(t0);
|
||||
|
||||
+153
-165
File diff suppressed because it is too large
Load Diff
@@ -3939,13 +3939,13 @@ static DisasJumpType op_rosbg(DisasContext *s, DisasOps *o)
|
||||
|
||||
static DisasJumpType op_rev16(DisasContext *s, DisasOps *o)
|
||||
{
|
||||
tcg_gen_bswap16_i64(o->out, o->in2);
|
||||
tcg_gen_bswap16_i64(o->out, o->in2, TCG_BSWAP_IZ | TCG_BSWAP_OZ);
|
||||
return DISAS_NEXT;
|
||||
}
|
||||
|
||||
static DisasJumpType op_rev32(DisasContext *s, DisasOps *o)
|
||||
{
|
||||
tcg_gen_bswap32_i64(o->out, o->in2);
|
||||
tcg_gen_bswap32_i64(o->out, o->in2, TCG_BSWAP_IZ | TCG_BSWAP_OZ);
|
||||
return DISAS_NEXT;
|
||||
}
|
||||
|
||||
|
||||
@@ -676,8 +676,7 @@ static void _decode_opc(DisasContext * ctx)
|
||||
case 0x6008: /* swap.b Rm,Rn */
|
||||
{
|
||||
TCGv low = tcg_temp_new();
|
||||
tcg_gen_ext16u_i32(low, REG(B7_4));
|
||||
tcg_gen_bswap16_i32(low, low);
|
||||
tcg_gen_bswap16_i32(low, REG(B7_4), 0);
|
||||
tcg_gen_deposit_i32(REG(B11_8), REG(B7_4), low, 0, 16);
|
||||
tcg_temp_free(low);
|
||||
}
|
||||
|
||||
+14
-8
@@ -295,19 +295,25 @@ ext32u_i64 t0, t1
|
||||
|
||||
8, 16 or 32 bit sign/zero extension (both operands must have the same type)
|
||||
|
||||
* bswap16_i32/i64 t0, t1
|
||||
* bswap16_i32/i64 t0, t1, flags
|
||||
|
||||
16 bit byte swap on a 32/64 bit value. It assumes that the two/six high order
|
||||
bytes are set to zero.
|
||||
16 bit byte swap on the low bits of a 32/64 bit input.
|
||||
If flags & TCG_BSWAP_IZ, then t1 is known to be zero-extended from bit 15.
|
||||
If flags & TCG_BSWAP_OZ, then t0 will be zero-extended from bit 15.
|
||||
If flags & TCG_BSWAP_OS, then t0 will be sign-extended from bit 15.
|
||||
If neither TCG_BSWAP_OZ nor TCG_BSWAP_OS are set, then the bits of
|
||||
t0 above bit 15 may contain any value.
|
||||
|
||||
* bswap32_i32/i64 t0, t1
|
||||
* bswap32_i64 t0, t1, flags
|
||||
|
||||
32 bit byte swap on a 32/64 bit value. With a 64 bit value, it assumes that
|
||||
the four high order bytes are set to zero.
|
||||
32 bit byte swap on a 64-bit value. The flags are the same as for bswap16,
|
||||
except they apply from bit 31 instead of bit 15.
|
||||
|
||||
* bswap64_i64 t0, t1
|
||||
* bswap32_i32 t0, t1, flags
|
||||
* bswap64_i64 t0, t1, flags
|
||||
|
||||
64 bit byte swap
|
||||
32/64 bit byte swap. The flags are ignored, but still present
|
||||
for consistency with the other bswap opcodes.
|
||||
|
||||
* discard_i32/i64 t0
|
||||
|
||||
|
||||
@@ -475,9 +475,7 @@ typedef enum {
|
||||
/* Data-processing (1 source) instructions. */
|
||||
I3507_CLZ = 0x5ac01000,
|
||||
I3507_RBIT = 0x5ac00000,
|
||||
I3507_REV16 = 0x5ac00400,
|
||||
I3507_REV32 = 0x5ac00800,
|
||||
I3507_REV64 = 0x5ac00c00,
|
||||
I3507_REV = 0x5ac00000, /* + size << 10 */
|
||||
|
||||
/* Data-processing (2 source) instructions. */
|
||||
I3508_LSLV = 0x1ac02000,
|
||||
@@ -1417,19 +1415,11 @@ static void tcg_out_brcond(TCGContext *s, TCGType ext, TCGCond c, TCGArg a,
|
||||
}
|
||||
}
|
||||
|
||||
static inline void tcg_out_rev64(TCGContext *s, TCGReg rd, TCGReg rn)
|
||||
static inline void tcg_out_rev(TCGContext *s, int ext, MemOp s_bits,
|
||||
TCGReg rd, TCGReg rn)
|
||||
{
|
||||
tcg_out_insn(s, 3507, REV64, TCG_TYPE_I64, rd, rn);
|
||||
}
|
||||
|
||||
static inline void tcg_out_rev32(TCGContext *s, TCGReg rd, TCGReg rn)
|
||||
{
|
||||
tcg_out_insn(s, 3507, REV32, TCG_TYPE_I32, rd, rn);
|
||||
}
|
||||
|
||||
static inline void tcg_out_rev16(TCGContext *s, TCGReg rd, TCGReg rn)
|
||||
{
|
||||
tcg_out_insn(s, 3507, REV16, TCG_TYPE_I32, rd, rn);
|
||||
/* REV, REV16, REV32 */
|
||||
tcg_out_insn_3507(s, I3507_REV | (s_bits << 10), ext, rd, rn);
|
||||
}
|
||||
|
||||
static inline void tcg_out_sxt(TCGContext *s, TCGType ext, MemOp s_bits,
|
||||
@@ -1557,28 +1547,34 @@ static void tcg_out_cltz(TCGContext *s, TCGType ext, TCGReg d,
|
||||
/* helper signature: helper_ret_ld_mmu(CPUState *env, target_ulong addr,
|
||||
* TCGMemOpIdx oi, uintptr_t ra)
|
||||
*/
|
||||
static void * const qemu_ld_helpers[16] = {
|
||||
[MO_UB] = helper_ret_ldub_mmu,
|
||||
[MO_LEUW] = helper_le_lduw_mmu,
|
||||
[MO_LEUL] = helper_le_ldul_mmu,
|
||||
[MO_LEQ] = helper_le_ldq_mmu,
|
||||
[MO_BEUW] = helper_be_lduw_mmu,
|
||||
[MO_BEUL] = helper_be_ldul_mmu,
|
||||
[MO_BEQ] = helper_be_ldq_mmu,
|
||||
static void * const qemu_ld_helpers[4] = {
|
||||
[MO_8] = helper_ret_ldub_mmu,
|
||||
#ifdef HOST_WORDS_BIGENDIAN
|
||||
[MO_16] = helper_be_lduw_mmu,
|
||||
[MO_32] = helper_be_ldul_mmu,
|
||||
[MO_64] = helper_be_ldq_mmu,
|
||||
#else
|
||||
[MO_16] = helper_le_lduw_mmu,
|
||||
[MO_32] = helper_le_ldul_mmu,
|
||||
[MO_64] = helper_le_ldq_mmu,
|
||||
#endif
|
||||
};
|
||||
|
||||
/* helper signature: helper_ret_st_mmu(CPUState *env, target_ulong addr,
|
||||
* uintxx_t val, TCGMemOpIdx oi,
|
||||
* uintptr_t ra)
|
||||
*/
|
||||
static void * const qemu_st_helpers[16] = {
|
||||
[MO_UB] = helper_ret_stb_mmu,
|
||||
[MO_LEUW] = helper_le_stw_mmu,
|
||||
[MO_LEUL] = helper_le_stl_mmu,
|
||||
[MO_LEQ] = helper_le_stq_mmu,
|
||||
[MO_BEUW] = helper_be_stw_mmu,
|
||||
[MO_BEUL] = helper_be_stl_mmu,
|
||||
[MO_BEQ] = helper_be_stq_mmu,
|
||||
static void * const qemu_st_helpers[4] = {
|
||||
[MO_8] = helper_ret_stb_mmu,
|
||||
#ifdef HOST_WORDS_BIGENDIAN
|
||||
[MO_16] = helper_be_stw_mmu,
|
||||
[MO_32] = helper_be_stl_mmu,
|
||||
[MO_64] = helper_be_stq_mmu,
|
||||
#else
|
||||
[MO_16] = helper_le_stw_mmu,
|
||||
[MO_32] = helper_le_stl_mmu,
|
||||
[MO_64] = helper_le_stq_mmu,
|
||||
#endif
|
||||
};
|
||||
|
||||
static inline void tcg_out_adr(TCGContext *s, TCGReg rd, const void *target)
|
||||
@@ -1602,7 +1598,7 @@ static bool tcg_out_qemu_ld_slow_path(TCGContext *s, TCGLabelQemuLdst *lb)
|
||||
tcg_out_mov(s, TARGET_LONG_BITS == 64, TCG_REG_X1, lb->addrlo_reg);
|
||||
tcg_out_movi(s, TCG_TYPE_I32, TCG_REG_X2, oi);
|
||||
tcg_out_adr(s, TCG_REG_X3, lb->raddr);
|
||||
tcg_out_call(s, qemu_ld_helpers[opc & (MO_BSWAP | MO_SIZE)]);
|
||||
tcg_out_call(s, qemu_ld_helpers[opc & MO_SIZE]);
|
||||
if (opc & MO_SIGN) {
|
||||
tcg_out_sxt(s, lb->type, size, lb->datalo_reg, TCG_REG_X0);
|
||||
} else {
|
||||
@@ -1628,7 +1624,7 @@ static bool tcg_out_qemu_st_slow_path(TCGContext *s, TCGLabelQemuLdst *lb)
|
||||
tcg_out_mov(s, size == MO_64, TCG_REG_X2, lb->datalo_reg);
|
||||
tcg_out_movi(s, TCG_TYPE_I32, TCG_REG_X3, oi);
|
||||
tcg_out_adr(s, TCG_REG_X4, lb->raddr);
|
||||
tcg_out_call(s, qemu_st_helpers[opc & (MO_BSWAP | MO_SIZE)]);
|
||||
tcg_out_call(s, qemu_st_helpers[opc & MO_SIZE]);
|
||||
tcg_out_goto(s, lb->raddr);
|
||||
return true;
|
||||
}
|
||||
@@ -1724,7 +1720,8 @@ static void tcg_out_qemu_ld_direct(TCGContext *s, MemOp memop, TCGType ext,
|
||||
TCGReg data_r, TCGReg addr_r,
|
||||
TCGType otype, TCGReg off_r)
|
||||
{
|
||||
const MemOp bswap = memop & MO_BSWAP;
|
||||
/* Byte swapping is left to middle-end expansion. */
|
||||
tcg_debug_assert((memop & MO_BSWAP) == 0);
|
||||
|
||||
switch (memop & MO_SSIZE) {
|
||||
case MO_UB:
|
||||
@@ -1736,40 +1733,19 @@ static void tcg_out_qemu_ld_direct(TCGContext *s, MemOp memop, TCGType ext,
|
||||
break;
|
||||
case MO_UW:
|
||||
tcg_out_ldst_r(s, I3312_LDRH, data_r, addr_r, otype, off_r);
|
||||
if (bswap) {
|
||||
tcg_out_rev16(s, data_r, data_r);
|
||||
}
|
||||
break;
|
||||
case MO_SW:
|
||||
if (bswap) {
|
||||
tcg_out_ldst_r(s, I3312_LDRH, data_r, addr_r, otype, off_r);
|
||||
tcg_out_rev16(s, data_r, data_r);
|
||||
tcg_out_sxt(s, ext, MO_16, data_r, data_r);
|
||||
} else {
|
||||
tcg_out_ldst_r(s, (ext ? I3312_LDRSHX : I3312_LDRSHW),
|
||||
data_r, addr_r, otype, off_r);
|
||||
}
|
||||
tcg_out_ldst_r(s, (ext ? I3312_LDRSHX : I3312_LDRSHW),
|
||||
data_r, addr_r, otype, off_r);
|
||||
break;
|
||||
case MO_UL:
|
||||
tcg_out_ldst_r(s, I3312_LDRW, data_r, addr_r, otype, off_r);
|
||||
if (bswap) {
|
||||
tcg_out_rev32(s, data_r, data_r);
|
||||
}
|
||||
break;
|
||||
case MO_SL:
|
||||
if (bswap) {
|
||||
tcg_out_ldst_r(s, I3312_LDRW, data_r, addr_r, otype, off_r);
|
||||
tcg_out_rev32(s, data_r, data_r);
|
||||
tcg_out_sxt(s, TCG_TYPE_I64, MO_32, data_r, data_r);
|
||||
} else {
|
||||
tcg_out_ldst_r(s, I3312_LDRSWX, data_r, addr_r, otype, off_r);
|
||||
}
|
||||
tcg_out_ldst_r(s, I3312_LDRSWX, data_r, addr_r, otype, off_r);
|
||||
break;
|
||||
case MO_Q:
|
||||
tcg_out_ldst_r(s, I3312_LDRX, data_r, addr_r, otype, off_r);
|
||||
if (bswap) {
|
||||
tcg_out_rev64(s, data_r, data_r);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
tcg_abort();
|
||||
@@ -1780,31 +1756,20 @@ static void tcg_out_qemu_st_direct(TCGContext *s, MemOp memop,
|
||||
TCGReg data_r, TCGReg addr_r,
|
||||
TCGType otype, TCGReg off_r)
|
||||
{
|
||||
const MemOp bswap = memop & MO_BSWAP;
|
||||
/* Byte swapping is left to middle-end expansion. */
|
||||
tcg_debug_assert((memop & MO_BSWAP) == 0);
|
||||
|
||||
switch (memop & MO_SIZE) {
|
||||
case MO_8:
|
||||
tcg_out_ldst_r(s, I3312_STRB, data_r, addr_r, otype, off_r);
|
||||
break;
|
||||
case MO_16:
|
||||
if (bswap && data_r != TCG_REG_XZR) {
|
||||
tcg_out_rev16(s, TCG_REG_TMP, data_r);
|
||||
data_r = TCG_REG_TMP;
|
||||
}
|
||||
tcg_out_ldst_r(s, I3312_STRH, data_r, addr_r, otype, off_r);
|
||||
break;
|
||||
case MO_32:
|
||||
if (bswap && data_r != TCG_REG_XZR) {
|
||||
tcg_out_rev32(s, TCG_REG_TMP, data_r);
|
||||
data_r = TCG_REG_TMP;
|
||||
}
|
||||
tcg_out_ldst_r(s, I3312_STRW, data_r, addr_r, otype, off_r);
|
||||
break;
|
||||
case MO_64:
|
||||
if (bswap && data_r != TCG_REG_XZR) {
|
||||
tcg_out_rev64(s, TCG_REG_TMP, data_r);
|
||||
data_r = TCG_REG_TMP;
|
||||
}
|
||||
tcg_out_ldst_r(s, I3312_STRX, data_r, addr_r, otype, off_r);
|
||||
break;
|
||||
default:
|
||||
@@ -2184,15 +2149,27 @@ static void tcg_out_op(TCGContext *s, TCGOpcode opc,
|
||||
break;
|
||||
|
||||
case INDEX_op_bswap64_i64:
|
||||
tcg_out_rev64(s, a0, a1);
|
||||
tcg_out_rev(s, TCG_TYPE_I64, MO_64, a0, a1);
|
||||
break;
|
||||
case INDEX_op_bswap32_i64:
|
||||
tcg_out_rev(s, TCG_TYPE_I32, MO_32, a0, a1);
|
||||
if (a2 & TCG_BSWAP_OS) {
|
||||
tcg_out_sxt(s, TCG_TYPE_I64, MO_32, a0, a0);
|
||||
}
|
||||
break;
|
||||
case INDEX_op_bswap32_i32:
|
||||
tcg_out_rev32(s, a0, a1);
|
||||
tcg_out_rev(s, TCG_TYPE_I32, MO_32, a0, a1);
|
||||
break;
|
||||
case INDEX_op_bswap16_i64:
|
||||
case INDEX_op_bswap16_i32:
|
||||
tcg_out_rev16(s, a0, a1);
|
||||
tcg_out_rev(s, TCG_TYPE_I32, MO_16, a0, a1);
|
||||
if (a2 & TCG_BSWAP_OS) {
|
||||
/* Output must be sign-extended. */
|
||||
tcg_out_sxt(s, ext, MO_16, a0, a0);
|
||||
} else if ((a2 & (TCG_BSWAP_IZ | TCG_BSWAP_OZ)) == TCG_BSWAP_OZ) {
|
||||
/* Output must be zero-extended, but input isn't. */
|
||||
tcg_out_uxt(s, MO_16, a0, a0);
|
||||
}
|
||||
break;
|
||||
|
||||
case INDEX_op_ext8s_i64:
|
||||
|
||||
@@ -148,7 +148,7 @@ typedef enum {
|
||||
#define TCG_TARGET_HAS_cmpsel_vec 0
|
||||
|
||||
#define TCG_TARGET_DEFAULT_MO (0)
|
||||
#define TCG_TARGET_HAS_MEMORY_BSWAP 1
|
||||
#define TCG_TARGET_HAS_MEMORY_BSWAP 0
|
||||
|
||||
void tb_target_set_jmp_target(uintptr_t, uintptr_t, uintptr_t, uintptr_t);
|
||||
|
||||
|
||||
+129
-166
@@ -1013,50 +1013,71 @@ static inline void tcg_out_ext16u(TCGContext *s, int cond,
|
||||
}
|
||||
}
|
||||
|
||||
static inline void tcg_out_bswap16s(TCGContext *s, int cond, int rd, int rn)
|
||||
static void tcg_out_bswap16(TCGContext *s, int cond, int rd, int rn, int flags)
|
||||
{
|
||||
if (use_armv6_instructions) {
|
||||
/* revsh */
|
||||
tcg_out32(s, 0x06ff0fb0 | (cond << 28) | (rd << 12) | rn);
|
||||
} else {
|
||||
tcg_out_dat_reg(s, cond, ARITH_MOV,
|
||||
TCG_REG_TMP, 0, rn, SHIFT_IMM_LSL(24));
|
||||
tcg_out_dat_reg(s, cond, ARITH_MOV,
|
||||
TCG_REG_TMP, 0, TCG_REG_TMP, SHIFT_IMM_ASR(16));
|
||||
tcg_out_dat_reg(s, cond, ARITH_ORR,
|
||||
rd, TCG_REG_TMP, rn, SHIFT_IMM_LSR(8));
|
||||
}
|
||||
}
|
||||
if (flags & TCG_BSWAP_OS) {
|
||||
/* revsh */
|
||||
tcg_out32(s, 0x06ff0fb0 | (cond << 28) | (rd << 12) | rn);
|
||||
return;
|
||||
}
|
||||
|
||||
static inline void tcg_out_bswap16(TCGContext *s, int cond, int rd, int rn)
|
||||
{
|
||||
if (use_armv6_instructions) {
|
||||
/* rev16 */
|
||||
tcg_out32(s, 0x06bf0fb0 | (cond << 28) | (rd << 12) | rn);
|
||||
} else {
|
||||
tcg_out_dat_reg(s, cond, ARITH_MOV,
|
||||
TCG_REG_TMP, 0, rn, SHIFT_IMM_LSL(24));
|
||||
tcg_out_dat_reg(s, cond, ARITH_MOV,
|
||||
TCG_REG_TMP, 0, TCG_REG_TMP, SHIFT_IMM_LSR(16));
|
||||
tcg_out_dat_reg(s, cond, ARITH_ORR,
|
||||
rd, TCG_REG_TMP, rn, SHIFT_IMM_LSR(8));
|
||||
if ((flags & (TCG_BSWAP_IZ | TCG_BSWAP_OZ)) == TCG_BSWAP_OZ) {
|
||||
/* uxth */
|
||||
tcg_out32(s, 0x06ff0070 | (cond << 28) | (rd << 12) | rd);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/* swap the two low bytes assuming that the two high input bytes and the
|
||||
two high output bit can hold any value. */
|
||||
static inline void tcg_out_bswap16st(TCGContext *s, int cond, int rd, int rn)
|
||||
{
|
||||
if (use_armv6_instructions) {
|
||||
/* rev16 */
|
||||
tcg_out32(s, 0x06bf0fb0 | (cond << 28) | (rd << 12) | rn);
|
||||
} else {
|
||||
if (flags == 0) {
|
||||
/*
|
||||
* For stores, no input or output extension:
|
||||
* rn = xxAB
|
||||
* lsr tmp, rn, #8 tmp = 0xxA
|
||||
* and tmp, tmp, #0xff tmp = 000A
|
||||
* orr rd, tmp, rn, lsl #8 rd = xABA
|
||||
*/
|
||||
tcg_out_dat_reg(s, cond, ARITH_MOV,
|
||||
TCG_REG_TMP, 0, rn, SHIFT_IMM_LSR(8));
|
||||
tcg_out_dat_imm(s, cond, ARITH_AND, TCG_REG_TMP, TCG_REG_TMP, 0xff);
|
||||
tcg_out_dat_reg(s, cond, ARITH_ORR,
|
||||
rd, TCG_REG_TMP, rn, SHIFT_IMM_LSL(8));
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* Byte swap, leaving the result at the top of the register.
|
||||
* We will then shift down, zero or sign-extending.
|
||||
*/
|
||||
if (flags & TCG_BSWAP_IZ) {
|
||||
/*
|
||||
* rn = 00AB
|
||||
* ror tmp, rn, #8 tmp = B00A
|
||||
* orr tmp, tmp, tmp, lsl #16 tmp = BA00
|
||||
*/
|
||||
tcg_out_dat_reg(s, cond, ARITH_MOV,
|
||||
TCG_REG_TMP, 0, rn, SHIFT_IMM_ROR(8));
|
||||
tcg_out_dat_reg(s, cond, ARITH_ORR,
|
||||
TCG_REG_TMP, TCG_REG_TMP, TCG_REG_TMP,
|
||||
SHIFT_IMM_LSL(16));
|
||||
} else {
|
||||
/*
|
||||
* rn = xxAB
|
||||
* and tmp, rn, #0xff00 tmp = 00A0
|
||||
* lsl tmp, tmp, #8 tmp = 0A00
|
||||
* orr tmp, tmp, rn, lsl #24 tmp = BA00
|
||||
*/
|
||||
tcg_out_dat_rI(s, cond, ARITH_AND, TCG_REG_TMP, rn, 0xff00, 1);
|
||||
tcg_out_dat_reg(s, cond, ARITH_MOV,
|
||||
TCG_REG_TMP, 0, TCG_REG_TMP, SHIFT_IMM_LSL(8));
|
||||
tcg_out_dat_reg(s, cond, ARITH_ORR,
|
||||
TCG_REG_TMP, TCG_REG_TMP, rn, SHIFT_IMM_LSL(24));
|
||||
}
|
||||
tcg_out_dat_reg(s, cond, ARITH_MOV, rd, 0, TCG_REG_TMP,
|
||||
(flags & TCG_BSWAP_OS
|
||||
? SHIFT_IMM_ASR(8) : SHIFT_IMM_LSR(8)));
|
||||
}
|
||||
|
||||
static inline void tcg_out_bswap32(TCGContext *s, int cond, int rd, int rn)
|
||||
@@ -1372,34 +1393,38 @@ static void tcg_out_vldst(TCGContext *s, ARMInsn insn,
|
||||
/* helper signature: helper_ret_ld_mmu(CPUState *env, target_ulong addr,
|
||||
* int mmu_idx, uintptr_t ra)
|
||||
*/
|
||||
static void * const qemu_ld_helpers[16] = {
|
||||
static void * const qemu_ld_helpers[8] = {
|
||||
[MO_UB] = helper_ret_ldub_mmu,
|
||||
[MO_SB] = helper_ret_ldsb_mmu,
|
||||
|
||||
[MO_LEUW] = helper_le_lduw_mmu,
|
||||
[MO_LEUL] = helper_le_ldul_mmu,
|
||||
[MO_LEQ] = helper_le_ldq_mmu,
|
||||
[MO_LESW] = helper_le_ldsw_mmu,
|
||||
[MO_LESL] = helper_le_ldul_mmu,
|
||||
|
||||
[MO_BEUW] = helper_be_lduw_mmu,
|
||||
[MO_BEUL] = helper_be_ldul_mmu,
|
||||
[MO_BEQ] = helper_be_ldq_mmu,
|
||||
[MO_BESW] = helper_be_ldsw_mmu,
|
||||
[MO_BESL] = helper_be_ldul_mmu,
|
||||
#ifdef HOST_WORDS_BIGENDIAN
|
||||
[MO_UW] = helper_be_lduw_mmu,
|
||||
[MO_UL] = helper_be_ldul_mmu,
|
||||
[MO_Q] = helper_be_ldq_mmu,
|
||||
[MO_SW] = helper_be_ldsw_mmu,
|
||||
[MO_SL] = helper_be_ldul_mmu,
|
||||
#else
|
||||
[MO_UW] = helper_le_lduw_mmu,
|
||||
[MO_UL] = helper_le_ldul_mmu,
|
||||
[MO_Q] = helper_le_ldq_mmu,
|
||||
[MO_SW] = helper_le_ldsw_mmu,
|
||||
[MO_SL] = helper_le_ldul_mmu,
|
||||
#endif
|
||||
};
|
||||
|
||||
/* helper signature: helper_ret_st_mmu(CPUState *env, target_ulong addr,
|
||||
* uintxx_t val, int mmu_idx, uintptr_t ra)
|
||||
*/
|
||||
static void * const qemu_st_helpers[16] = {
|
||||
[MO_UB] = helper_ret_stb_mmu,
|
||||
[MO_LEUW] = helper_le_stw_mmu,
|
||||
[MO_LEUL] = helper_le_stl_mmu,
|
||||
[MO_LEQ] = helper_le_stq_mmu,
|
||||
[MO_BEUW] = helper_be_stw_mmu,
|
||||
[MO_BEUL] = helper_be_stl_mmu,
|
||||
[MO_BEQ] = helper_be_stq_mmu,
|
||||
static void * const qemu_st_helpers[4] = {
|
||||
[MO_8] = helper_ret_stb_mmu,
|
||||
#ifdef HOST_WORDS_BIGENDIAN
|
||||
[MO_16] = helper_be_stw_mmu,
|
||||
[MO_32] = helper_be_stl_mmu,
|
||||
[MO_64] = helper_be_stq_mmu,
|
||||
#else
|
||||
[MO_16] = helper_le_stw_mmu,
|
||||
[MO_32] = helper_le_stl_mmu,
|
||||
[MO_64] = helper_le_stq_mmu,
|
||||
#endif
|
||||
};
|
||||
|
||||
/* Helper routines for marshalling helper function arguments into
|
||||
@@ -1604,9 +1629,9 @@ static bool tcg_out_qemu_ld_slow_path(TCGContext *s, TCGLabelQemuLdst *lb)
|
||||
icache usage. For pre-armv6, use the signed helpers since we do
|
||||
not have a single insn sign-extend. */
|
||||
if (use_armv6_instructions) {
|
||||
func = qemu_ld_helpers[opc & (MO_BSWAP | MO_SIZE)];
|
||||
func = qemu_ld_helpers[opc & MO_SIZE];
|
||||
} else {
|
||||
func = qemu_ld_helpers[opc & (MO_BSWAP | MO_SSIZE)];
|
||||
func = qemu_ld_helpers[opc & MO_SSIZE];
|
||||
if (opc & MO_SIGN) {
|
||||
opc = MO_UL;
|
||||
}
|
||||
@@ -1684,7 +1709,7 @@ static bool tcg_out_qemu_st_slow_path(TCGContext *s, TCGLabelQemuLdst *lb)
|
||||
argreg = tcg_out_arg_reg32(s, argreg, TCG_REG_R14);
|
||||
|
||||
/* Tail-call to the helper, which will return to the fast path. */
|
||||
tcg_out_goto(s, COND_AL, qemu_st_helpers[opc & (MO_BSWAP | MO_SIZE)]);
|
||||
tcg_out_goto(s, COND_AL, qemu_st_helpers[opc & MO_SIZE]);
|
||||
return true;
|
||||
}
|
||||
#endif /* SOFTMMU */
|
||||
@@ -1693,7 +1718,8 @@ static inline void tcg_out_qemu_ld_index(TCGContext *s, MemOp opc,
|
||||
TCGReg datalo, TCGReg datahi,
|
||||
TCGReg addrlo, TCGReg addend)
|
||||
{
|
||||
MemOp bswap = opc & MO_BSWAP;
|
||||
/* Byte swapping is left to middle-end expansion. */
|
||||
tcg_debug_assert((opc & MO_BSWAP) == 0);
|
||||
|
||||
switch (opc & MO_SSIZE) {
|
||||
case MO_UB:
|
||||
@@ -1704,49 +1730,30 @@ static inline void tcg_out_qemu_ld_index(TCGContext *s, MemOp opc,
|
||||
break;
|
||||
case MO_UW:
|
||||
tcg_out_ld16u_r(s, COND_AL, datalo, addrlo, addend);
|
||||
if (bswap) {
|
||||
tcg_out_bswap16(s, COND_AL, datalo, datalo);
|
||||
}
|
||||
break;
|
||||
case MO_SW:
|
||||
if (bswap) {
|
||||
tcg_out_ld16u_r(s, COND_AL, datalo, addrlo, addend);
|
||||
tcg_out_bswap16s(s, COND_AL, datalo, datalo);
|
||||
} else {
|
||||
tcg_out_ld16s_r(s, COND_AL, datalo, addrlo, addend);
|
||||
}
|
||||
tcg_out_ld16s_r(s, COND_AL, datalo, addrlo, addend);
|
||||
break;
|
||||
case MO_UL:
|
||||
default:
|
||||
tcg_out_ld32_r(s, COND_AL, datalo, addrlo, addend);
|
||||
if (bswap) {
|
||||
tcg_out_bswap32(s, COND_AL, datalo, datalo);
|
||||
}
|
||||
break;
|
||||
case MO_Q:
|
||||
{
|
||||
TCGReg dl = (bswap ? datahi : datalo);
|
||||
TCGReg dh = (bswap ? datalo : datahi);
|
||||
|
||||
/* Avoid ldrd for user-only emulation, to handle unaligned. */
|
||||
if (USING_SOFTMMU && use_armv6_instructions
|
||||
&& (dl & 1) == 0 && dh == dl + 1) {
|
||||
tcg_out_ldrd_r(s, COND_AL, dl, addrlo, addend);
|
||||
} else if (dl != addend) {
|
||||
tcg_out_ld32_rwb(s, COND_AL, dl, addend, addrlo);
|
||||
tcg_out_ld32_12(s, COND_AL, dh, addend, 4);
|
||||
} else {
|
||||
tcg_out_dat_reg(s, COND_AL, ARITH_ADD, TCG_REG_TMP,
|
||||
addend, addrlo, SHIFT_IMM_LSL(0));
|
||||
tcg_out_ld32_12(s, COND_AL, dl, TCG_REG_TMP, 0);
|
||||
tcg_out_ld32_12(s, COND_AL, dh, TCG_REG_TMP, 4);
|
||||
}
|
||||
if (bswap) {
|
||||
tcg_out_bswap32(s, COND_AL, dl, dl);
|
||||
tcg_out_bswap32(s, COND_AL, dh, dh);
|
||||
}
|
||||
/* Avoid ldrd for user-only emulation, to handle unaligned. */
|
||||
if (USING_SOFTMMU && use_armv6_instructions
|
||||
&& (datalo & 1) == 0 && datahi == datalo + 1) {
|
||||
tcg_out_ldrd_r(s, COND_AL, datalo, addrlo, addend);
|
||||
} else if (datalo != addend) {
|
||||
tcg_out_ld32_rwb(s, COND_AL, datalo, addend, addrlo);
|
||||
tcg_out_ld32_12(s, COND_AL, datahi, addend, 4);
|
||||
} else {
|
||||
tcg_out_dat_reg(s, COND_AL, ARITH_ADD, TCG_REG_TMP,
|
||||
addend, addrlo, SHIFT_IMM_LSL(0));
|
||||
tcg_out_ld32_12(s, COND_AL, datalo, TCG_REG_TMP, 0);
|
||||
tcg_out_ld32_12(s, COND_AL, datahi, TCG_REG_TMP, 4);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
g_assert_not_reached();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1754,7 +1761,8 @@ static inline void tcg_out_qemu_ld_direct(TCGContext *s, MemOp opc,
|
||||
TCGReg datalo, TCGReg datahi,
|
||||
TCGReg addrlo)
|
||||
{
|
||||
MemOp bswap = opc & MO_BSWAP;
|
||||
/* Byte swapping is left to middle-end expansion. */
|
||||
tcg_debug_assert((opc & MO_BSWAP) == 0);
|
||||
|
||||
switch (opc & MO_SSIZE) {
|
||||
case MO_UB:
|
||||
@@ -1765,47 +1773,28 @@ static inline void tcg_out_qemu_ld_direct(TCGContext *s, MemOp opc,
|
||||
break;
|
||||
case MO_UW:
|
||||
tcg_out_ld16u_8(s, COND_AL, datalo, addrlo, 0);
|
||||
if (bswap) {
|
||||
tcg_out_bswap16(s, COND_AL, datalo, datalo);
|
||||
}
|
||||
break;
|
||||
case MO_SW:
|
||||
if (bswap) {
|
||||
tcg_out_ld16u_8(s, COND_AL, datalo, addrlo, 0);
|
||||
tcg_out_bswap16s(s, COND_AL, datalo, datalo);
|
||||
} else {
|
||||
tcg_out_ld16s_8(s, COND_AL, datalo, addrlo, 0);
|
||||
}
|
||||
tcg_out_ld16s_8(s, COND_AL, datalo, addrlo, 0);
|
||||
break;
|
||||
case MO_UL:
|
||||
default:
|
||||
tcg_out_ld32_12(s, COND_AL, datalo, addrlo, 0);
|
||||
if (bswap) {
|
||||
tcg_out_bswap32(s, COND_AL, datalo, datalo);
|
||||
}
|
||||
break;
|
||||
case MO_Q:
|
||||
{
|
||||
TCGReg dl = (bswap ? datahi : datalo);
|
||||
TCGReg dh = (bswap ? datalo : datahi);
|
||||
|
||||
/* Avoid ldrd for user-only emulation, to handle unaligned. */
|
||||
if (USING_SOFTMMU && use_armv6_instructions
|
||||
&& (dl & 1) == 0 && dh == dl + 1) {
|
||||
tcg_out_ldrd_8(s, COND_AL, dl, addrlo, 0);
|
||||
} else if (dl == addrlo) {
|
||||
tcg_out_ld32_12(s, COND_AL, dh, addrlo, bswap ? 0 : 4);
|
||||
tcg_out_ld32_12(s, COND_AL, dl, addrlo, bswap ? 4 : 0);
|
||||
} else {
|
||||
tcg_out_ld32_12(s, COND_AL, dl, addrlo, bswap ? 4 : 0);
|
||||
tcg_out_ld32_12(s, COND_AL, dh, addrlo, bswap ? 0 : 4);
|
||||
}
|
||||
if (bswap) {
|
||||
tcg_out_bswap32(s, COND_AL, dl, dl);
|
||||
tcg_out_bswap32(s, COND_AL, dh, dh);
|
||||
}
|
||||
/* Avoid ldrd for user-only emulation, to handle unaligned. */
|
||||
if (USING_SOFTMMU && use_armv6_instructions
|
||||
&& (datalo & 1) == 0 && datahi == datalo + 1) {
|
||||
tcg_out_ldrd_8(s, COND_AL, datalo, addrlo, 0);
|
||||
} else if (datalo == addrlo) {
|
||||
tcg_out_ld32_12(s, COND_AL, datahi, addrlo, 4);
|
||||
tcg_out_ld32_12(s, COND_AL, datalo, addrlo, 0);
|
||||
} else {
|
||||
tcg_out_ld32_12(s, COND_AL, datalo, addrlo, 0);
|
||||
tcg_out_ld32_12(s, COND_AL, datahi, addrlo, 4);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
g_assert_not_reached();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1854,44 +1843,31 @@ static inline void tcg_out_qemu_st_index(TCGContext *s, int cond, MemOp opc,
|
||||
TCGReg datalo, TCGReg datahi,
|
||||
TCGReg addrlo, TCGReg addend)
|
||||
{
|
||||
MemOp bswap = opc & MO_BSWAP;
|
||||
/* Byte swapping is left to middle-end expansion. */
|
||||
tcg_debug_assert((opc & MO_BSWAP) == 0);
|
||||
|
||||
switch (opc & MO_SIZE) {
|
||||
case MO_8:
|
||||
tcg_out_st8_r(s, cond, datalo, addrlo, addend);
|
||||
break;
|
||||
case MO_16:
|
||||
if (bswap) {
|
||||
tcg_out_bswap16st(s, cond, TCG_REG_R0, datalo);
|
||||
tcg_out_st16_r(s, cond, TCG_REG_R0, addrlo, addend);
|
||||
} else {
|
||||
tcg_out_st16_r(s, cond, datalo, addrlo, addend);
|
||||
}
|
||||
tcg_out_st16_r(s, cond, datalo, addrlo, addend);
|
||||
break;
|
||||
case MO_32:
|
||||
default:
|
||||
if (bswap) {
|
||||
tcg_out_bswap32(s, cond, TCG_REG_R0, datalo);
|
||||
tcg_out_st32_r(s, cond, TCG_REG_R0, addrlo, addend);
|
||||
} else {
|
||||
tcg_out_st32_r(s, cond, datalo, addrlo, addend);
|
||||
}
|
||||
tcg_out_st32_r(s, cond, datalo, addrlo, addend);
|
||||
break;
|
||||
case MO_64:
|
||||
/* Avoid strd for user-only emulation, to handle unaligned. */
|
||||
if (bswap) {
|
||||
tcg_out_bswap32(s, cond, TCG_REG_R0, datahi);
|
||||
tcg_out_st32_rwb(s, cond, TCG_REG_R0, addend, addrlo);
|
||||
tcg_out_bswap32(s, cond, TCG_REG_R0, datalo);
|
||||
tcg_out_st32_12(s, cond, TCG_REG_R0, addend, 4);
|
||||
} else if (USING_SOFTMMU && use_armv6_instructions
|
||||
&& (datalo & 1) == 0 && datahi == datalo + 1) {
|
||||
if (USING_SOFTMMU && use_armv6_instructions
|
||||
&& (datalo & 1) == 0 && datahi == datalo + 1) {
|
||||
tcg_out_strd_r(s, cond, datalo, addrlo, addend);
|
||||
} else {
|
||||
tcg_out_st32_rwb(s, cond, datalo, addend, addrlo);
|
||||
tcg_out_st32_12(s, cond, datahi, addend, 4);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
g_assert_not_reached();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1899,44 +1875,31 @@ static inline void tcg_out_qemu_st_direct(TCGContext *s, MemOp opc,
|
||||
TCGReg datalo, TCGReg datahi,
|
||||
TCGReg addrlo)
|
||||
{
|
||||
MemOp bswap = opc & MO_BSWAP;
|
||||
/* Byte swapping is left to middle-end expansion. */
|
||||
tcg_debug_assert((opc & MO_BSWAP) == 0);
|
||||
|
||||
switch (opc & MO_SIZE) {
|
||||
case MO_8:
|
||||
tcg_out_st8_12(s, COND_AL, datalo, addrlo, 0);
|
||||
break;
|
||||
case MO_16:
|
||||
if (bswap) {
|
||||
tcg_out_bswap16st(s, COND_AL, TCG_REG_R0, datalo);
|
||||
tcg_out_st16_8(s, COND_AL, TCG_REG_R0, addrlo, 0);
|
||||
} else {
|
||||
tcg_out_st16_8(s, COND_AL, datalo, addrlo, 0);
|
||||
}
|
||||
tcg_out_st16_8(s, COND_AL, datalo, addrlo, 0);
|
||||
break;
|
||||
case MO_32:
|
||||
default:
|
||||
if (bswap) {
|
||||
tcg_out_bswap32(s, COND_AL, TCG_REG_R0, datalo);
|
||||
tcg_out_st32_12(s, COND_AL, TCG_REG_R0, addrlo, 0);
|
||||
} else {
|
||||
tcg_out_st32_12(s, COND_AL, datalo, addrlo, 0);
|
||||
}
|
||||
tcg_out_st32_12(s, COND_AL, datalo, addrlo, 0);
|
||||
break;
|
||||
case MO_64:
|
||||
/* Avoid strd for user-only emulation, to handle unaligned. */
|
||||
if (bswap) {
|
||||
tcg_out_bswap32(s, COND_AL, TCG_REG_R0, datahi);
|
||||
tcg_out_st32_12(s, COND_AL, TCG_REG_R0, addrlo, 0);
|
||||
tcg_out_bswap32(s, COND_AL, TCG_REG_R0, datalo);
|
||||
tcg_out_st32_12(s, COND_AL, TCG_REG_R0, addrlo, 4);
|
||||
} else if (USING_SOFTMMU && use_armv6_instructions
|
||||
&& (datalo & 1) == 0 && datahi == datalo + 1) {
|
||||
if (USING_SOFTMMU && use_armv6_instructions
|
||||
&& (datalo & 1) == 0 && datahi == datalo + 1) {
|
||||
tcg_out_strd_8(s, COND_AL, datalo, addrlo, 0);
|
||||
} else {
|
||||
tcg_out_st32_12(s, COND_AL, datalo, addrlo, 0);
|
||||
tcg_out_st32_12(s, COND_AL, datahi, addrlo, 4);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
g_assert_not_reached();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2245,7 +2208,7 @@ static inline void tcg_out_op(TCGContext *s, TCGOpcode opc,
|
||||
break;
|
||||
|
||||
case INDEX_op_bswap16_i32:
|
||||
tcg_out_bswap16(s, COND_AL, args[0], args[1]);
|
||||
tcg_out_bswap16(s, COND_AL, args[0], args[1], args[2]);
|
||||
break;
|
||||
case INDEX_op_bswap32_i32:
|
||||
tcg_out_bswap32(s, COND_AL, args[0], args[1]);
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user