mips: Fix build

This commit is contained in:
Lioncash 2021-03-05 08:39:18 -05:00
parent dec4c70142
commit 704353c758
4 changed files with 75 additions and 157 deletions

View file

@ -26,8 +26,7 @@
#ifdef CONFIG_USER_ONLY #ifdef CONFIG_USER_ONLY
#define TARGET_PAGE_BITS 12 #define TARGET_PAGE_BITS 12
#else #else
#define TARGET_PAGE_BITS_VARY #define TARGET_PAGE_BITS 12
#define TARGET_PAGE_BITS_MIN 12
#endif #endif
#define NB_MMU_MODES 4 #define NB_MMU_MODES 4

View file

@ -200,28 +200,11 @@ static void mips_register_cpudef_type(struct uc_struct *uc, const struct mips_de
{ {
char *typename = mips_cpu_type_name(def->name); char *typename = mips_cpu_type_name(def->name);
TypeInfo ti = { TypeInfo ti = {
typename, .name = typename,
TYPE_MIPS_CPU, .parent = TYPE_MIPS_CPU,
0, .class_data = (void *)def,
0, .class_init = mips_cpu_cpudef_class_init,
NULL,
NULL,
NULL,
NULL,
(void *)def,
mips_cpu_cpudef_class_init,
NULL,
NULL,
false,
NULL,
NULL,
NULL,
}; };
type_register(uc, &ti); type_register(uc, &ti);
@ -233,24 +216,17 @@ void mips_cpu_register_types(void *opaque)
int i; int i;
const TypeInfo mips_cpu_type_info = { const TypeInfo mips_cpu_type_info = {
TYPE_MIPS_CPU, .name = TYPE_MIPS_CPU,
TYPE_CPU, .parent = TYPE_CPU,
sizeof(MIPSCPUClass), .class_size = sizeof(MIPSCPUClass),
sizeof(MIPSCPU), .instance_size = sizeof(MIPSCPU),
opaque, .instance_userdata = opaque,
mips_cpu_initfn, .instance_init = mips_cpu_initfn,
NULL, .class_init = mips_cpu_class_init,
NULL,
NULL, .abstract = true,
mips_cpu_class_init,
NULL,
NULL,
true,
}; };
type_register(opaque, &mips_cpu_type_info); type_register(opaque, &mips_cpu_type_info);

View file

@ -50,65 +50,6 @@ static void raise_exception(CPUMIPSState *env, uint32_t exception)
do_raise_exception(env, exception, 0); do_raise_exception(env, exception, 0);
} }
#if defined(CONFIG_USER_ONLY)
#define HELPER_LD(name, insn, type) \
static inline type do_##name(CPUMIPSState *env, target_ulong addr, \
int mem_idx, uintptr_t retaddr) \
{ \
return (type) cpu_##insn##_data_ra(env, addr, retaddr); \
}
#else
#define HELPER_LD(name, insn, type) \
static inline type do_##name(CPUMIPSState *env, target_ulong addr, \
int mem_idx, uintptr_t retaddr) \
{ \
switch (mem_idx) \
{ \
case 0: return (type) cpu_##insn##_kernel_ra(env, addr, retaddr); \
case 1: return (type) cpu_##insn##_super_ra(env, addr, retaddr); \
default: \
case 2: return (type) cpu_##insn##_user_ra(env, addr, retaddr); \
case 3: return (type) cpu_##insn##_error_ra(env, addr, retaddr); \
} \
}
#endif
HELPER_LD(lw, ldl, int32_t)
#if defined(TARGET_MIPS64)
HELPER_LD(ld, ldq, int64_t)
#endif
#undef HELPER_LD
#if defined(CONFIG_USER_ONLY)
#define HELPER_ST(name, insn, type) \
static inline void do_##name(CPUMIPSState *env, target_ulong addr, \
type val, int mem_idx, uintptr_t retaddr) \
{ \
cpu_##insn##_data_ra(env, addr, val, retaddr); \
}
#else
#define HELPER_ST(name, insn, type) \
static inline void do_##name(CPUMIPSState *env, target_ulong addr, \
type val, int mem_idx, uintptr_t retaddr) \
{ \
switch (mem_idx) \
{ \
case 0: cpu_##insn##_kernel_ra(env, addr, val, retaddr); break; \
case 1: cpu_##insn##_super_ra(env, addr, val, retaddr); break; \
default: \
case 2: cpu_##insn##_user_ra(env, addr, val, retaddr); break; \
case 3: \
cpu_##insn##_error_ra(env, addr, val, retaddr); \
break; \
} \
}
#endif
HELPER_ST(sb, stb, uint8_t)
HELPER_ST(sw, stl, uint32_t)
#if defined(TARGET_MIPS64)
HELPER_ST(sd, stq, uint64_t)
#endif
#undef HELPER_ST
/* 64 bits arithmetic for 32 bits hosts */ /* 64 bits arithmetic for 32 bits hosts */
static inline uint64_t get_HILO(CPUMIPSState *env) static inline uint64_t get_HILO(CPUMIPSState *env)
{ {
@ -361,7 +302,7 @@ static inline hwaddr do_translate_address(CPUMIPSState *env,
} }
} }
#define HELPER_LD_ATOMIC(name, insn, almask) \ #define HELPER_LD_ATOMIC(name, insn, almask, do_cast) \
target_ulong helper_##name(CPUMIPSState *env, target_ulong arg, int mem_idx) \ target_ulong helper_##name(CPUMIPSState *env, target_ulong arg, int mem_idx) \
{ \ { \
if (arg & almask) { \ if (arg & almask) { \
@ -370,12 +311,12 @@ target_ulong helper_##name(CPUMIPSState *env, target_ulong arg, int mem_idx) \
} \ } \
env->CP0_LLAddr = do_translate_address(env, arg, 0, GETPC()); \ env->CP0_LLAddr = do_translate_address(env, arg, 0, GETPC()); \
env->lladdr = arg; \ env->lladdr = arg; \
env->llval = do_##insn(env, arg, mem_idx, GETPC()); \ env->llval = do_cast cpu_##insn##_mmuidx_ra(env, arg, mem_idx, GETPC()); \
return env->llval; \ return env->llval; \
} }
HELPER_LD_ATOMIC(ll, lw, 0x3) HELPER_LD_ATOMIC(ll, ldl, 0x3, (target_long)(int32_t))
#ifdef TARGET_MIPS64 #ifdef TARGET_MIPS64
HELPER_LD_ATOMIC(lld, ld, 0x7) HELPER_LD_ATOMIC(lld, ldq, 0x7, (target_ulong))
#endif #endif
#undef HELPER_LD_ATOMIC #undef HELPER_LD_ATOMIC
#endif #endif
@ -391,42 +332,42 @@ HELPER_LD_ATOMIC(lld, ld, 0x7)
void helper_swl(CPUMIPSState *env, target_ulong arg1, target_ulong arg2, void helper_swl(CPUMIPSState *env, target_ulong arg1, target_ulong arg2,
int mem_idx) int mem_idx)
{ {
do_sb(env, arg2, (uint8_t)(arg1 >> 24), mem_idx, GETPC()); cpu_stb_mmuidx_ra(env, arg2, (uint8_t)(arg1 >> 24), mem_idx, GETPC());
if (GET_LMASK(arg2) <= 2) { if (GET_LMASK(arg2) <= 2) {
do_sb(env, GET_OFFSET(arg2, 1), (uint8_t)(arg1 >> 16), mem_idx, cpu_stb_mmuidx_ra(env, GET_OFFSET(arg2, 1), (uint8_t)(arg1 >> 16),
GETPC()); mem_idx, GETPC());
} }
if (GET_LMASK(arg2) <= 1) { if (GET_LMASK(arg2) <= 1) {
do_sb(env, GET_OFFSET(arg2, 2), (uint8_t)(arg1 >> 8), mem_idx, cpu_stb_mmuidx_ra(env, GET_OFFSET(arg2, 2), (uint8_t)(arg1 >> 8),
GETPC()); mem_idx, GETPC());
} }
if (GET_LMASK(arg2) == 0) { if (GET_LMASK(arg2) == 0) {
do_sb(env, GET_OFFSET(arg2, 3), (uint8_t)arg1, mem_idx, cpu_stb_mmuidx_ra(env, GET_OFFSET(arg2, 3), (uint8_t)arg1,
GETPC()); mem_idx, GETPC());
} }
} }
void helper_swr(CPUMIPSState *env, target_ulong arg1, target_ulong arg2, void helper_swr(CPUMIPSState *env, target_ulong arg1, target_ulong arg2,
int mem_idx) int mem_idx)
{ {
do_sb(env, arg2, (uint8_t)arg1, mem_idx, GETPC()); cpu_stb_mmuidx_ra(env, arg2, (uint8_t)arg1, mem_idx, GETPC());
if (GET_LMASK(arg2) >= 1) { if (GET_LMASK(arg2) >= 1) {
do_sb(env, GET_OFFSET(arg2, -1), (uint8_t)(arg1 >> 8), mem_idx, cpu_stb_mmuidx_ra(env, GET_OFFSET(arg2, -1), (uint8_t)(arg1 >> 8),
GETPC()); mem_idx, GETPC());
} }
if (GET_LMASK(arg2) >= 2) { if (GET_LMASK(arg2) >= 2) {
do_sb(env, GET_OFFSET(arg2, -2), (uint8_t)(arg1 >> 16), mem_idx, cpu_stb_mmuidx_ra(env, GET_OFFSET(arg2, -2), (uint8_t)(arg1 >> 16),
GETPC()); mem_idx, GETPC());
} }
if (GET_LMASK(arg2) == 3) { if (GET_LMASK(arg2) == 3) {
do_sb(env, GET_OFFSET(arg2, -3), (uint8_t)(arg1 >> 24), mem_idx, cpu_stb_mmuidx_ra(env, GET_OFFSET(arg2, -3), (uint8_t)(arg1 >> 24),
GETPC()); mem_idx, GETPC());
} }
} }
@ -443,82 +384,82 @@ void helper_swr(CPUMIPSState *env, target_ulong arg1, target_ulong arg2,
void helper_sdl(CPUMIPSState *env, target_ulong arg1, target_ulong arg2, void helper_sdl(CPUMIPSState *env, target_ulong arg1, target_ulong arg2,
int mem_idx) int mem_idx)
{ {
do_sb(env, arg2, (uint8_t)(arg1 >> 56), mem_idx, GETPC()); cpu_stb_mmuidx_ra(env, arg2, (uint8_t)(arg1 >> 56), mem_idx, GETPC());
if (GET_LMASK64(arg2) <= 6) { if (GET_LMASK64(arg2) <= 6) {
do_sb(env, GET_OFFSET(arg2, 1), (uint8_t)(arg1 >> 48), mem_idx, cpu_stb_mmuidx_ra(env, GET_OFFSET(arg2, 1), (uint8_t)(arg1 >> 48),
GETPC()); mem_idx, GETPC());
} }
if (GET_LMASK64(arg2) <= 5) { if (GET_LMASK64(arg2) <= 5) {
do_sb(env, GET_OFFSET(arg2, 2), (uint8_t)(arg1 >> 40), mem_idx, cpu_stb_mmuidx_ra(env, GET_OFFSET(arg2, 2), (uint8_t)(arg1 >> 40),
GETPC()); mem_idx, GETPC());
} }
if (GET_LMASK64(arg2) <= 4) { if (GET_LMASK64(arg2) <= 4) {
do_sb(env, GET_OFFSET(arg2, 3), (uint8_t)(arg1 >> 32), mem_idx, cpu_stb_mmuidx_ra(env, GET_OFFSET(arg2, 3), (uint8_t)(arg1 >> 32),
GETPC()); mem_idx, GETPC());
} }
if (GET_LMASK64(arg2) <= 3) { if (GET_LMASK64(arg2) <= 3) {
do_sb(env, GET_OFFSET(arg2, 4), (uint8_t)(arg1 >> 24), mem_idx, cpu_stb_mmuidx_ra(env, GET_OFFSET(arg2, 4), (uint8_t)(arg1 >> 24),
GETPC()); mem_idx, GETPC());
} }
if (GET_LMASK64(arg2) <= 2) { if (GET_LMASK64(arg2) <= 2) {
do_sb(env, GET_OFFSET(arg2, 5), (uint8_t)(arg1 >> 16), mem_idx, cpu_stb_mmuidx_ra(env, GET_OFFSET(arg2, 5), (uint8_t)(arg1 >> 16),
GETPC()); mem_idx, GETPC());
} }
if (GET_LMASK64(arg2) <= 1) { if (GET_LMASK64(arg2) <= 1) {
do_sb(env, GET_OFFSET(arg2, 6), (uint8_t)(arg1 >> 8), mem_idx, cpu_stb_mmuidx_ra(env, GET_OFFSET(arg2, 6), (uint8_t)(arg1 >> 8),
GETPC()); mem_idx, GETPC());
} }
if (GET_LMASK64(arg2) <= 0) { if (GET_LMASK64(arg2) <= 0) {
do_sb(env, GET_OFFSET(arg2, 7), (uint8_t)arg1, mem_idx, cpu_stb_mmuidx_ra(env, GET_OFFSET(arg2, 7), (uint8_t)arg1,
GETPC()); mem_idx, GETPC());
} }
} }
void helper_sdr(CPUMIPSState *env, target_ulong arg1, target_ulong arg2, void helper_sdr(CPUMIPSState *env, target_ulong arg1, target_ulong arg2,
int mem_idx) int mem_idx)
{ {
do_sb(env, arg2, (uint8_t)arg1, mem_idx, GETPC()); cpu_stb_mmuidx_ra(env, arg2, (uint8_t)arg1, mem_idx, GETPC());
if (GET_LMASK64(arg2) >= 1) { if (GET_LMASK64(arg2) >= 1) {
do_sb(env, GET_OFFSET(arg2, -1), (uint8_t)(arg1 >> 8), mem_idx, cpu_stb_mmuidx_ra(env, GET_OFFSET(arg2, -1), (uint8_t)(arg1 >> 8),
GETPC()); mem_idx, GETPC());
} }
if (GET_LMASK64(arg2) >= 2) { if (GET_LMASK64(arg2) >= 2) {
do_sb(env, GET_OFFSET(arg2, -2), (uint8_t)(arg1 >> 16), mem_idx, cpu_stb_mmuidx_ra(env, GET_OFFSET(arg2, -2), (uint8_t)(arg1 >> 16),
GETPC()); mem_idx, GETPC());
} }
if (GET_LMASK64(arg2) >= 3) { if (GET_LMASK64(arg2) >= 3) {
do_sb(env, GET_OFFSET(arg2, -3), (uint8_t)(arg1 >> 24), mem_idx, cpu_stb_mmuidx_ra(env, GET_OFFSET(arg2, -3), (uint8_t)(arg1 >> 24),
GETPC()); mem_idx, GETPC());
} }
if (GET_LMASK64(arg2) >= 4) { if (GET_LMASK64(arg2) >= 4) {
do_sb(env, GET_OFFSET(arg2, -4), (uint8_t)(arg1 >> 32), mem_idx, cpu_stb_mmuidx_ra(env, GET_OFFSET(arg2, -4), (uint8_t)(arg1 >> 32),
GETPC()); mem_idx, GETPC());
} }
if (GET_LMASK64(arg2) >= 5) { if (GET_LMASK64(arg2) >= 5) {
do_sb(env, GET_OFFSET(arg2, -5), (uint8_t)(arg1 >> 40), mem_idx, cpu_stb_mmuidx_ra(env, GET_OFFSET(arg2, -5), (uint8_t)(arg1 >> 40),
GETPC()); mem_idx, GETPC());
} }
if (GET_LMASK64(arg2) >= 6) { if (GET_LMASK64(arg2) >= 6) {
do_sb(env, GET_OFFSET(arg2, -6), (uint8_t)(arg1 >> 48), mem_idx, cpu_stb_mmuidx_ra(env, GET_OFFSET(arg2, -6), (uint8_t)(arg1 >> 48),
GETPC()); mem_idx, GETPC());
} }
if (GET_LMASK64(arg2) == 7) { if (GET_LMASK64(arg2) == 7) {
do_sb(env, GET_OFFSET(arg2, -7), (uint8_t)(arg1 >> 56), mem_idx, cpu_stb_mmuidx_ra(env, GET_OFFSET(arg2, -7), (uint8_t)(arg1 >> 56),
GETPC()); mem_idx, GETPC());
} }
} }
#endif /* TARGET_MIPS64 */ #endif /* TARGET_MIPS64 */
@ -536,14 +477,14 @@ void helper_lwm(CPUMIPSState *env, target_ulong addr, target_ulong reglist,
for (i = 0; i < base_reglist; i++) { for (i = 0; i < base_reglist; i++) {
env->active_tc.gpr[multiple_regs[i]] = env->active_tc.gpr[multiple_regs[i]] =
(target_long)do_lw(env, addr, mem_idx, GETPC()); (target_long)cpu_ldl_mmuidx_ra(env, addr, mem_idx, GETPC());
addr += 4; addr += 4;
} }
} }
if (do_r31) { if (do_r31) {
env->active_tc.gpr[31] = (target_long)do_lw(env, addr, mem_idx, env->active_tc.gpr[31] =
GETPC()); (target_long)cpu_ldl_mmuidx_ra(env, addr, mem_idx, GETPC());
} }
} }
@ -557,14 +498,14 @@ void helper_swm(CPUMIPSState *env, target_ulong addr, target_ulong reglist,
target_ulong i; target_ulong i;
for (i = 0; i < base_reglist; i++) { for (i = 0; i < base_reglist; i++) {
do_sw(env, addr, env->active_tc.gpr[multiple_regs[i]], mem_idx, cpu_stw_mmuidx_ra(env, addr, env->active_tc.gpr[multiple_regs[i]],
GETPC()); mem_idx, GETPC());
addr += 4; addr += 4;
} }
} }
if (do_r31) { if (do_r31) {
do_sw(env, addr, env->active_tc.gpr[31], mem_idx, GETPC()); cpu_stw_mmuidx_ra(env, addr, env->active_tc.gpr[31], mem_idx, GETPC());
} }
} }
@ -579,14 +520,15 @@ void helper_ldm(CPUMIPSState *env, target_ulong addr, target_ulong reglist,
target_ulong i; target_ulong i;
for (i = 0; i < base_reglist; i++) { for (i = 0; i < base_reglist; i++) {
env->active_tc.gpr[multiple_regs[i]] = do_ld(env, addr, mem_idx, env->active_tc.gpr[multiple_regs[i]] =
GETPC()); cpu_ldq_mmuidx_ra(env, addr, mem_idx, GETPC());
addr += 8; addr += 8;
} }
} }
if (do_r31) { if (do_r31) {
env->active_tc.gpr[31] = do_ld(env, addr, mem_idx, GETPC()); env->active_tc.gpr[31] =
cpu_ldq_mmuidx_ra(env, addr, mem_idx, GETPC());
} }
} }
@ -600,14 +542,14 @@ void helper_sdm(CPUMIPSState *env, target_ulong addr, target_ulong reglist,
target_ulong i; target_ulong i;
for (i = 0; i < base_reglist; i++) { for (i = 0; i < base_reglist; i++) {
do_sd(env, addr, env->active_tc.gpr[multiple_regs[i]], mem_idx, cpu_stq_mmuidx_ra(env, addr, env->active_tc.gpr[multiple_regs[i]],
GETPC()); mem_idx, GETPC());
addr += 8; addr += 8;
} }
} }
if (do_r31) { if (do_r31) {
do_sd(env, addr, env->active_tc.gpr[31], mem_idx, GETPC()); cpu_stq_mmuidx_ra(env, addr, env->active_tc.gpr[31], mem_idx, GETPC());
} }
} }
#endif #endif

View file

@ -5863,6 +5863,7 @@ static void gen_loongson_multimedia(DisasContext *ctx, int rd, int rs, int rt)
gen_store_fpr64(ctx, t0, rd); gen_store_fpr64(ctx, t0, rd);
no_rd:
tcg_temp_free_i64(tcg_ctx, t0); tcg_temp_free_i64(tcg_ctx, t0);
tcg_temp_free_i64(tcg_ctx, t1); tcg_temp_free_i64(tcg_ctx, t1);
} }