Skip to content

Commit

Permalink
target/mips: Support the R5900 LQ 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 c1ebd20 commit 0800cbe
Showing 1 changed file with 45 additions and 1 deletion.
46 changes: 45 additions & 1 deletion target/mips/translate.c
Original file line number Diff line number Diff line change
Expand Up @@ -2626,6 +2626,17 @@ static inline void gen_store_gpr (TCGv t, int reg)
tcg_gen_mov_tl(cpu_gpr[reg], t);
}

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

/* Moves to/from shadow registers. */
static inline void gen_load_srsgpr (int from, int to)
{
Expand Down Expand Up @@ -27465,7 +27476,40 @@ static void decode_mmi(CPUMIPSState *env, DisasContext *ctx)

static void gen_mmi_lq(CPUMIPSState *env, DisasContext *ctx)
{
generate_exception_end(ctx, EXCP_RI); /* TODO: MMI_OPC_LQ */
#if !defined(TARGET_MIPS64)
generate_exception_end(ctx, EXCP_RI);
#else
int base = extract32(ctx->opcode, 21, 5);
int rt = extract32(ctx->opcode, 16, 5);
int offset = sextract32(ctx->opcode, 0, 16);

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);

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

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

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

static void gen_mmi_sq(DisasContext *ctx, int base, int rt, int offset)
Expand Down

0 comments on commit 0800cbe

Please sign in to comment.