Skip to content

Commit

Permalink
target/mips: Support the R5900 SQ multimedia instruction [#4]
Browse files Browse the repository at this point in the history
Signed-off-by: Fredrik Noring <noring@nocrew.org>
  • Loading branch information
frno7 committed Mar 2, 2019
1 parent 0800cbe commit c34b28e
Showing 1 changed file with 42 additions and 2 deletions.
44 changes: 42 additions & 2 deletions target/mips/translate.c
Original file line number Diff line number Diff line change
Expand Up @@ -2628,6 +2628,17 @@ static inline void gen_store_gpr (TCGv t, int reg)

#if defined(TARGET_MIPS64)
/* 128-bit multimedia register moves. */
static inline void gen_load_mmr(TCGv_i64 hi, TCGv_i64 lo, int reg)
{
if (reg == 0) {
tcg_gen_movi_i64(hi, 0);
tcg_gen_movi_i64(lo, 0);
} else {
tcg_gen_mov_i64(hi, cpu_mmr[reg]);
tcg_gen_mov_i64(lo, cpu_gpr[reg]);
}
}

static inline void gen_store_mmr(TCGv_i64 hi, TCGv_i64 lo, int reg)
{
if (reg != 0) {
Expand Down Expand Up @@ -27514,7 +27525,36 @@ static void gen_mmi_lq(CPUMIPSState *env, DisasContext *ctx)

static void gen_mmi_sq(DisasContext *ctx, int base, int rt, int offset)
{
generate_exception_end(ctx, EXCP_RI); /* TODO: MMI_OPC_SQ */
#if !defined(TARGET_MIPS64)
generate_exception_end(ctx, EXCP_RI);
#else
TCGv_i64 addr = tcg_temp_new_i64();
TCGv_i64 val0 = tcg_temp_new_i64();
TCGv_i64 val1 = tcg_temp_new_i64();

gen_base_offset_addr(ctx, addr, base, offset);

/*
* The least significant four bits of the effective address are
* masked to zero, effectively creating an aligned address. No
* address exceptions due to alignment are possible.
*/
tcg_gen_andi_i64(addr, addr, ~0xFULL);

#if defined(TARGET_WORDS_BIGENDIAN)
gen_load_mmr(val0, val1, rt);
#else
gen_load_mmr(val1, val0, rt);
#endif

tcg_gen_qemu_st_i64(val0, addr, ctx->mem_idx, MO_UNALN | MO_64);
tcg_gen_addi_i64(addr, addr, 8);
tcg_gen_qemu_st_i64(val1, addr, ctx->mem_idx, MO_UNALN | MO_64);

tcg_temp_free_i64(val1);
tcg_temp_free_i64(val0);
tcg_temp_free_i64(addr);
#endif /* defined(TARGET_MIPS64) */
}

/*
Expand Down Expand Up @@ -27542,7 +27582,7 @@ static void decode_mmi_sq(CPUMIPSState *env, DisasContext *ctx)
{
int base = extract32(ctx->opcode, 21, 5);
int rt = extract32(ctx->opcode, 16, 5);
int offset = extract32(ctx->opcode, 0, 16);
int offset = sextract32(ctx->opcode, 0, 16);

#ifdef CONFIG_USER_ONLY
uint32_t op1 = MASK_SPECIAL3(ctx->opcode);
Expand Down

0 comments on commit c34b28e

Please sign in to comment.