From: Aurelien Jarno <aurelien@aurel32.net>
To: Yongbok Kim <yongbok.kim@imgtec.com>
Cc: leon.alrae@imgtec.com, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH v3 14/15] target-mips: microMIPS32 R6 POOL16{A, C} instructions
Date: Wed, 24 Jun 2015 15:43:10 +0200 [thread overview]
Message-ID: <20150624134310.GE15630@aurel32.net> (raw)
In-Reply-To: <1435073928-21830-15-git-send-email-yongbok.kim@imgtec.com>
On 2015-06-23 16:38, Yongbok Kim wrote:
> microMIPS32 Release 6 POOL16A/ POOL16C instructions
>
> Signed-off-by: Yongbok Kim <yongbok.kim@imgtec.com>
> ---
> target-mips/translate.c | 122 +++++++++++++++++++++++++++++++++++++++++------
> 1 files changed, 107 insertions(+), 15 deletions(-)
>
> diff --git a/target-mips/translate.c b/target-mips/translate.c
> index 4bce6e8..82764e7 100644
> --- a/target-mips/translate.c
> +++ b/target-mips/translate.c
> @@ -13163,6 +13163,102 @@ static void gen_pool16c_insn(DisasContext *ctx)
> }
> }
>
> +static inline void gen_movep(DisasContext *ctx, int enc_dest, int enc_rt,
> + int enc_rs)
> +{
> + int rd, rs, re, rt;
> + static const int rd_enc[] = { 5, 5, 6, 4, 4, 4, 4, 4 };
> + static const int re_enc[] = { 6, 7, 7, 21, 22, 5, 6, 7 };
> + static const int rs_rt_enc[] = { 0, 17, 2, 3, 16, 18, 19, 20 };
> + rd = rd_enc[enc_dest];
> + re = re_enc[enc_dest];
> + rs = rs_rt_enc[enc_rs];
> + rt = rs_rt_enc[enc_rt];
> + gen_arith(ctx, OPC_ADDU, rd, rs, 0);
> + gen_arith(ctx, OPC_ADDU, re, rt, 0);
Do we really want to call ADDU here? This could be as simple as:
if (rs) {
tcg_gen_mov_tl(rd, rs);
} else {
tcg_gen_movi_tl(rd, 0);
}
if (rt) {
tcg_gen_mov_tl(re, rt);
} else {
tcg_gen_movi_tl(re, 0);
}
> +}
> +
> +static void gen_pool16c_r6_insn(DisasContext *ctx)
> +{
> + int rt = mmreg((ctx->opcode >> 7) & 0x7);
> + int rs = mmreg((ctx->opcode >> 4) & 0x7);
> +
> + switch (ctx->opcode & 0xf) {
> + case R6_NOT16:
> + gen_logic(ctx, OPC_NOR, rt, rs, 0);
> + break;
> + case R6_AND16:
> + gen_logic(ctx, OPC_AND, rt, rt, rs);
> + break;
> + case R6_LWM16:
> + {
> + int lwm_converted = 0x11 + extract32(ctx->opcode, 8, 2);
> + int offset = extract32(ctx->opcode, 4, 4);
> + gen_ldst_multiple(ctx, LWM32, lwm_converted, 29, offset << 2);
> + }
> + break;
> + case R6_JRC16: /* JRCADDIUSP */
> + if ((ctx->opcode >> 4) & 1) {
> + /* JRCADDIUSP */
> + int imm = extract32(ctx->opcode, 5, 5);
> + gen_compute_branch(ctx, OPC_JR, 2, 31, 0, 0, 0);
> + gen_arith_imm(ctx, OPC_ADDIU, 29, 29, imm << 2);
> + } else {
> + /* JRC16 */
> + int rs = extract32(ctx->opcode, 5, 5);
> + gen_compute_branch(ctx, OPC_JR, 2, rs, 0, 0, 0);
> + }
> + break;
> + case MOVEP ... MOVEP_07:
> + case MOVEP_0C ... MOVEP_0F:
> + {
> + int enc_dest = uMIPS_RD(ctx->opcode);
> + int enc_rt = uMIPS_RS2(ctx->opcode);
> + int enc_rs = (ctx->opcode & 3) | ((ctx->opcode >> 1) & 4);
> + gen_movep(ctx, enc_dest, enc_rt, enc_rs);
> + }
> + break;
> + case R6_XOR16:
> + gen_logic(ctx, OPC_XOR, rt, rt, rs);
> + break;
> + case R6_OR16:
> + gen_logic(ctx, OPC_OR, rt, rt, rs);
> + break;
> + case R6_SWM16:
> + {
> + int swm_converted = 0x11 + extract32(ctx->opcode, 8, 2);
> + int offset = extract32(ctx->opcode, 4, 4);
> + gen_ldst_multiple(ctx, SWM32, swm_converted, 29, offset << 2);
> + }
> + break;
> + case JALRC16: /* BREAK16, SDBBP16 */
> + switch (ctx->opcode & 0x3f) {
> + case JALRC16:
> + case JALRC16 + 0x20:
> + /* JALRC16 */
> + gen_compute_branch(ctx, OPC_JALR, 2, (ctx->opcode >> 5) & 0x1f,
> + 31, 0, 0);
> + break;
> + case R6_BREAK16:
> + /* BREAK16 */
> + generate_exception(ctx, EXCP_BREAK);
> + break;
> + case R6_SDBBP16:
> + /* SDBBP16 */
> + if (ctx->hflags & MIPS_HFLAG_SBRI) {
> + generate_exception(ctx, EXCP_RI);
> + } else {
> + generate_exception(ctx, EXCP_DBp);
> + }
> + break;
> + }
> + break;
> + default:
> + generate_exception(ctx, EXCP_RI);
> + break;
> + }
> +}
> +
> static void gen_ldxs (DisasContext *ctx, int base, int index, int rd)
> {
> TCGv t0 = tcg_temp_new();
> @@ -15168,8 +15264,11 @@ static int decode_micromips_opc (CPUMIPSState *env, DisasContext *ctx)
> opc = OPC_SUBU;
> break;
> }
> -
> - gen_arith(ctx, opc, rd, rs1, rs2);
> + if (ctx->insn_flags & ISA_MIPS32R6) {
> + gen_arith(ctx, opc, rs1, rd, rs2);
> + } else {
> + gen_arith(ctx, opc, rd, rs1, rs2);
> + }
That change is correct, but it would be nice to add a comment saying
that while the manual still describe the instruction as rd = rs + rt,
the register number location in the instruction encoding has changed.
> }
> break;
> case POOL16B:
> @@ -15193,7 +15292,11 @@ static int decode_micromips_opc (CPUMIPSState *env, DisasContext *ctx)
> }
> break;
> case POOL16C:
> - gen_pool16c_insn(ctx);
> + if (ctx->insn_flags & ISA_MIPS32R6) {
> + gen_pool16c_r6_insn(ctx);
> + } else {
> + gen_pool16c_insn(ctx);
> + }
> break;
> case LWGP16:
> {
> @@ -15213,18 +15316,7 @@ static int decode_micromips_opc (CPUMIPSState *env, DisasContext *ctx)
> int enc_dest = uMIPS_RD(ctx->opcode);
> int enc_rt = uMIPS_RS2(ctx->opcode);
> int enc_rs = uMIPS_RS1(ctx->opcode);
> - int rd, rs, re, rt;
> - static const int rd_enc[] = { 5, 5, 6, 4, 4, 4, 4, 4 };
> - static const int re_enc[] = { 6, 7, 7, 21, 22, 5, 6, 7 };
> - static const int rs_rt_enc[] = { 0, 17, 2, 3, 16, 18, 19, 20 };
> -
> - rd = rd_enc[enc_dest];
> - re = re_enc[enc_dest];
> - rs = rs_rt_enc[enc_rs];
> - rt = rs_rt_enc[enc_rt];
> -
> - gen_arith(ctx, OPC_ADDU, rd, rs, 0);
> - gen_arith(ctx, OPC_ADDU, re, rt, 0);
> + gen_movep(ctx, enc_dest, enc_rt, enc_rs);
> }
> break;
> case LBU16:
Besides the comments above, this all looks correct.
Reviewed-by: Aurelien Jarno <aurelien@aurel32.net>
--
Aurelien Jarno GPG: 4096R/1DDD8C9B
aurelien@aurel32.net http://www.aurel32.net
next prev parent reply other threads:[~2015-06-24 13:43 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-06-23 15:38 [Qemu-devel] [PATCH v3 00/15] target-mips: add microMIPS32 R6 Instruction Set support Yongbok Kim
2015-06-23 15:38 ` [Qemu-devel] [PATCH v3 01/15] target-mips: fix {RD, WR}PGPR in microMIPS Yongbok Kim
2015-06-23 15:38 ` [Qemu-devel] [PATCH v3 02/15] target-mips: add microMIPS TLBINV, TLBINVF Yongbok Kim
2015-06-23 15:38 ` [Qemu-devel] [PATCH v3 03/15] target-mips: remove an unused argument Yongbok Kim
2015-06-23 23:35 ` Aurelien Jarno
2015-06-23 15:38 ` [Qemu-devel] [PATCH v3 04/15] target-mips: refactor {D}LSA, {D}ALIGN, {D}BITSWAP Yongbok Kim
2015-06-24 11:04 ` Aurelien Jarno
2015-06-24 12:31 ` Leon Alrae
2015-06-24 13:16 ` Aurelien Jarno
2015-06-23 15:38 ` [Qemu-devel] [PATCH v3 05/15] target-mips: rearrange gen_compute_compact_branch Yongbok Kim
2015-06-24 11:15 ` Aurelien Jarno
2015-06-23 15:38 ` [Qemu-devel] [PATCH v3 06/15] target-mips: raise RI exceptions when FIR.PS = 0 Yongbok Kim
2015-06-24 12:28 ` Aurelien Jarno
2015-06-24 14:24 ` Yongbok Kim
2015-06-24 14:59 ` Aurelien Jarno
2015-06-24 15:24 ` Aurelien Jarno
2015-06-24 15:53 ` Yongbok Kim
2015-06-23 15:38 ` [Qemu-devel] [PATCH v3 07/15] target-mips: signal RI for removed instructions in microMIPS R6 Yongbok Kim
2015-06-24 12:32 ` Aurelien Jarno
2015-06-23 15:38 ` [Qemu-devel] [PATCH v3 08/15] target-mips: add microMIPS32 R6 opcode enum Yongbok Kim
2015-06-24 13:23 ` Aurelien Jarno
2015-06-23 15:38 ` [Qemu-devel] [PATCH v3 09/15] target-mips: microMIPS32 R6 branches and jumps Yongbok Kim
2015-06-24 13:24 ` Aurelien Jarno
2015-06-23 15:38 ` [Qemu-devel] [PATCH v3 10/15] target-mips: microMIPS32 R6 POOL32A{XF} instructions Yongbok Kim
2015-06-24 13:24 ` Aurelien Jarno
2015-06-23 15:38 ` [Qemu-devel] [PATCH v3 11/15] target-mips: microMIPS32 R6 POOL32F instructions Yongbok Kim
2015-06-23 15:38 ` [Qemu-devel] [PATCH v3 12/15] target-mips: microMIPS32 R6 POOL32{I, C} instructions Yongbok Kim
2015-06-23 16:16 ` Leon Alrae
2015-06-24 13:29 ` Aurelien Jarno
2015-06-23 15:38 ` [Qemu-devel] [PATCH v3 13/15] target-mips: microMIPS32 R6 Major instructions Yongbok Kim
2015-06-24 13:33 ` Aurelien Jarno
2015-06-23 15:38 ` [Qemu-devel] [PATCH v3 14/15] target-mips: microMIPS32 R6 POOL16{A, C} instructions Yongbok Kim
2015-06-23 16:16 ` Leon Alrae
2015-06-24 13:43 ` Aurelien Jarno [this message]
2015-06-23 15:38 ` [Qemu-devel] [PATCH v3 15/15] target-mips: add mips32r6-generic CPU definition Yongbok Kim
2015-06-24 13:44 ` Aurelien Jarno
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20150624134310.GE15630@aurel32.net \
--to=aurelien@aurel32.net \
--cc=leon.alrae@imgtec.com \
--cc=qemu-devel@nongnu.org \
--cc=yongbok.kim@imgtec.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.