[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 2/5] tcg/ppc: Hoist common argument loads in tcg_out_op()
From: |
Philippe Mathieu-Daudé |
Subject: |
[PATCH 2/5] tcg/ppc: Hoist common argument loads in tcg_out_op() |
Date: |
Mon, 11 Jan 2021 16:01:11 +0100 |
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
tcg/ppc/tcg-target.c.inc | 294 ++++++++++++++++++---------------------
1 file changed, 138 insertions(+), 156 deletions(-)
diff --git a/tcg/ppc/tcg-target.c.inc b/tcg/ppc/tcg-target.c.inc
index 19a4a12f155..d37b519d693 100644
--- a/tcg/ppc/tcg-target.c.inc
+++ b/tcg/ppc/tcg-target.c.inc
@@ -2357,15 +2357,23 @@ static void tcg_target_qemu_prologue(TCGContext *s)
tcg_out32(s, BCLR | BO_ALWAYS);
}
-static void tcg_out_op(TCGContext *s, TCGOpcode opc, const TCGArg *args,
- const int *const_args)
+static void tcg_out_op(TCGContext *s, TCGOpcode opc,
+ const TCGArg args[TCG_MAX_OP_ARGS],
+ const int const_args[TCG_MAX_OP_ARGS])
{
TCGArg a0, a1, a2;
- int c;
+ int c, c1, c2;
+
+ /* Hoist the loads of the most common arguments. */
+ a0 = args[0];
+ a1 = args[1];
+ a2 = args[2];
+ c1 = const_args[1];
+ c2 = const_args[2];
switch (opc) {
case INDEX_op_exit_tb:
- tcg_out_movi(s, TCG_TYPE_PTR, TCG_REG_R3, args[0]);
+ tcg_out_movi(s, TCG_TYPE_PTR, TCG_REG_R3, a0);
tcg_out_b(s, 0, tcg_code_gen_epilogue);
break;
case INDEX_op_goto_tb:
@@ -2376,24 +2384,24 @@ static void tcg_out_op(TCGContext *s, TCGOpcode opc,
const TCGArg *args,
if ((uintptr_t)s->code_ptr & 7) {
tcg_out32(s, NOP);
}
- s->tb_jmp_insn_offset[args[0]] = tcg_current_code_size(s);
+ s->tb_jmp_insn_offset[a0] = tcg_current_code_size(s);
tcg_out32(s, ADDIS | TAI(TCG_REG_TB, TCG_REG_TB, 0));
tcg_out32(s, ADDI | TAI(TCG_REG_TB, TCG_REG_TB, 0));
} else {
- s->tb_jmp_insn_offset[args[0]] = tcg_current_code_size(s);
+ s->tb_jmp_insn_offset[a0] = tcg_current_code_size(s);
tcg_out32(s, B);
- s->tb_jmp_reset_offset[args[0]] = tcg_current_code_size(s);
+ s->tb_jmp_reset_offset[a0] = tcg_current_code_size(s);
break;
}
} else {
/* Indirect jump. */
tcg_debug_assert(s->tb_jmp_insn_offset == NULL);
tcg_out_ld(s, TCG_TYPE_PTR, TCG_REG_TB, 0,
- (intptr_t)(s->tb_jmp_insn_offset + args[0]));
+ (intptr_t)(s->tb_jmp_insn_offset + a0));
}
tcg_out32(s, MTSPR | RS(TCG_REG_TB) | CTR);
tcg_out32(s, BCCTR | BO_ALWAYS);
- set_jmp_reset_offset(s, args[0]);
+ set_jmp_reset_offset(s, a0);
if (USE_REG_TB) {
/* For the unlinked case, need to reset TCG_REG_TB. */
tcg_out_mem_long(s, ADDI, ADD, TCG_REG_TB, TCG_REG_TB,
@@ -2401,16 +2409,16 @@ static void tcg_out_op(TCGContext *s, TCGOpcode opc,
const TCGArg *args,
}
break;
case INDEX_op_goto_ptr:
- tcg_out32(s, MTSPR | RS(args[0]) | CTR);
+ tcg_out32(s, MTSPR | RS(a0) | CTR);
if (USE_REG_TB) {
- tcg_out_mov(s, TCG_TYPE_PTR, TCG_REG_TB, args[0]);
+ tcg_out_mov(s, TCG_TYPE_PTR, TCG_REG_TB, a0);
}
tcg_out32(s, ADDI | TAI(TCG_REG_R3, 0, 0));
tcg_out32(s, BCCTR | BO_ALWAYS);
break;
case INDEX_op_br:
{
- TCGLabel *l = arg_label(args[0]);
+ TCGLabel *l = arg_label(a0);
uint32_t insn = B;
if (l->has_value) {
@@ -2424,50 +2432,49 @@ static void tcg_out_op(TCGContext *s, TCGOpcode opc,
const TCGArg *args,
break;
case INDEX_op_ld8u_i32:
case INDEX_op_ld8u_i64:
- tcg_out_mem_long(s, LBZ, LBZX, args[0], args[1], args[2]);
+ tcg_out_mem_long(s, LBZ, LBZX, a0, a1, a2);
break;
case INDEX_op_ld8s_i32:
case INDEX_op_ld8s_i64:
- tcg_out_mem_long(s, LBZ, LBZX, args[0], args[1], args[2]);
- tcg_out32(s, EXTSB | RS(args[0]) | RA(args[0]));
+ tcg_out_mem_long(s, LBZ, LBZX, a0, a1, a2);
+ tcg_out32(s, EXTSB | RS(a0) | RA(a0));
break;
case INDEX_op_ld16u_i32:
case INDEX_op_ld16u_i64:
- tcg_out_mem_long(s, LHZ, LHZX, args[0], args[1], args[2]);
+ tcg_out_mem_long(s, LHZ, LHZX, a0, a1, a2);
break;
case INDEX_op_ld16s_i32:
case INDEX_op_ld16s_i64:
- tcg_out_mem_long(s, LHA, LHAX, args[0], args[1], args[2]);
+ tcg_out_mem_long(s, LHA, LHAX, a0, a1, a2);
break;
case INDEX_op_ld_i32:
case INDEX_op_ld32u_i64:
- tcg_out_mem_long(s, LWZ, LWZX, args[0], args[1], args[2]);
+ tcg_out_mem_long(s, LWZ, LWZX, a0, a1, a2);
break;
case INDEX_op_ld32s_i64:
- tcg_out_mem_long(s, LWA, LWAX, args[0], args[1], args[2]);
+ tcg_out_mem_long(s, LWA, LWAX, a0, a1, a2);
break;
case INDEX_op_ld_i64:
- tcg_out_mem_long(s, LD, LDX, args[0], args[1], args[2]);
+ tcg_out_mem_long(s, LD, LDX, a0, a1, a2);
break;
case INDEX_op_st8_i32:
case INDEX_op_st8_i64:
- tcg_out_mem_long(s, STB, STBX, args[0], args[1], args[2]);
+ tcg_out_mem_long(s, STB, STBX, a0, a1, a2);
break;
case INDEX_op_st16_i32:
case INDEX_op_st16_i64:
- tcg_out_mem_long(s, STH, STHX, args[0], args[1], args[2]);
+ tcg_out_mem_long(s, STH, STHX, a0, a1, a2);
break;
case INDEX_op_st_i32:
case INDEX_op_st32_i64:
- tcg_out_mem_long(s, STW, STWX, args[0], args[1], args[2]);
+ tcg_out_mem_long(s, STW, STWX, a0, a1, a2);
break;
case INDEX_op_st_i64:
- tcg_out_mem_long(s, STD, STDX, args[0], args[1], args[2]);
+ tcg_out_mem_long(s, STD, STDX, a0, a1, a2);
break;
case INDEX_op_add_i32:
- a0 = args[0], a1 = args[1], a2 = args[2];
- if (const_args[2]) {
+ if (c2) {
do_addi_32:
tcg_out_mem_long(s, ADDI, ADD, a0, a1, (int32_t)a2);
} else {
@@ -2475,14 +2482,13 @@ static void tcg_out_op(TCGContext *s, TCGOpcode opc,
const TCGArg *args,
}
break;
case INDEX_op_sub_i32:
- a0 = args[0], a1 = args[1], a2 = args[2];
- if (const_args[1]) {
- if (const_args[2]) {
+ if (c1) {
+ if (c2) {
tcg_out_movi(s, TCG_TYPE_I32, a0, a1 - a2);
} else {
tcg_out32(s, SUBFIC | TAI(a0, a2, a1));
}
- } else if (const_args[2]) {
+ } else if (c2) {
a2 = -a2;
goto do_addi_32;
} else {
@@ -2491,16 +2497,14 @@ static void tcg_out_op(TCGContext *s, TCGOpcode opc,
const TCGArg *args,
break;
case INDEX_op_and_i32:
- a0 = args[0], a1 = args[1], a2 = args[2];
- if (const_args[2]) {
+ if (c2) {
tcg_out_andi32(s, a0, a1, a2);
} else {
tcg_out32(s, AND | SAB(a1, a0, a2));
}
break;
case INDEX_op_and_i64:
- a0 = args[0], a1 = args[1], a2 = args[2];
- if (const_args[2]) {
+ if (c2) {
tcg_out_andi64(s, a0, a1, a2);
} else {
tcg_out32(s, AND | SAB(a1, a0, a2));
@@ -2508,8 +2512,7 @@ static void tcg_out_op(TCGContext *s, TCGOpcode opc,
const TCGArg *args,
break;
case INDEX_op_or_i64:
case INDEX_op_or_i32:
- a0 = args[0], a1 = args[1], a2 = args[2];
- if (const_args[2]) {
+ if (c2) {
tcg_out_ori32(s, a0, a1, a2);
} else {
tcg_out32(s, OR | SAB(a1, a0, a2));
@@ -2517,83 +2520,75 @@ static void tcg_out_op(TCGContext *s, TCGOpcode opc,
const TCGArg *args,
break;
case INDEX_op_xor_i64:
case INDEX_op_xor_i32:
- a0 = args[0], a1 = args[1], a2 = args[2];
- if (const_args[2]) {
+ if (c2) {
tcg_out_xori32(s, a0, a1, a2);
} else {
tcg_out32(s, XOR | SAB(a1, a0, a2));
}
break;
case INDEX_op_andc_i32:
- a0 = args[0], a1 = args[1], a2 = args[2];
- if (const_args[2]) {
+ if (c2) {
tcg_out_andi32(s, a0, a1, ~a2);
} else {
tcg_out32(s, ANDC | SAB(a1, a0, a2));
}
break;
case INDEX_op_andc_i64:
- a0 = args[0], a1 = args[1], a2 = args[2];
- if (const_args[2]) {
+ if (c2) {
tcg_out_andi64(s, a0, a1, ~a2);
} else {
tcg_out32(s, ANDC | SAB(a1, a0, a2));
}
break;
case INDEX_op_orc_i32:
- if (const_args[2]) {
- tcg_out_ori32(s, args[0], args[1], ~args[2]);
+ if (c2) {
+ tcg_out_ori32(s, a0, a1, ~a2);
break;
}
/* FALLTHRU */
case INDEX_op_orc_i64:
- tcg_out32(s, ORC | SAB(args[1], args[0], args[2]));
+ tcg_out32(s, ORC | SAB(a1, a0, a2));
break;
case INDEX_op_eqv_i32:
- if (const_args[2]) {
- tcg_out_xori32(s, args[0], args[1], ~args[2]);
+ if (c2) {
+ tcg_out_xori32(s, a0, a1, ~a2);
break;
}
/* FALLTHRU */
case INDEX_op_eqv_i64:
- tcg_out32(s, EQV | SAB(args[1], args[0], args[2]));
+ tcg_out32(s, EQV | SAB(a1, a0, a2));
break;
case INDEX_op_nand_i32:
case INDEX_op_nand_i64:
- tcg_out32(s, NAND | SAB(args[1], args[0], args[2]));
+ tcg_out32(s, NAND | SAB(a1, a0, a2));
break;
case INDEX_op_nor_i32:
case INDEX_op_nor_i64:
- tcg_out32(s, NOR | SAB(args[1], args[0], args[2]));
+ tcg_out32(s, NOR | SAB(a1, a0, a2));
break;
case INDEX_op_clz_i32:
- tcg_out_cntxz(s, TCG_TYPE_I32, CNTLZW, args[0], args[1],
- args[2], const_args[2]);
+ tcg_out_cntxz(s, TCG_TYPE_I32, CNTLZW, a0, a1, a2, c2);
break;
case INDEX_op_ctz_i32:
- tcg_out_cntxz(s, TCG_TYPE_I32, CNTTZW, args[0], args[1],
- args[2], const_args[2]);
+ tcg_out_cntxz(s, TCG_TYPE_I32, CNTTZW, a0, a1, a2, c2);
break;
case INDEX_op_ctpop_i32:
- tcg_out32(s, CNTPOPW | SAB(args[1], args[0], 0));
+ tcg_out32(s, CNTPOPW | SAB(a1, a0, 0));
break;
case INDEX_op_clz_i64:
- tcg_out_cntxz(s, TCG_TYPE_I64, CNTLZD, args[0], args[1],
- args[2], const_args[2]);
+ tcg_out_cntxz(s, TCG_TYPE_I64, CNTLZD, a0, a1, a2, c2);
break;
case INDEX_op_ctz_i64:
- tcg_out_cntxz(s, TCG_TYPE_I64, CNTTZD, args[0], args[1],
- args[2], const_args[2]);
+ tcg_out_cntxz(s, TCG_TYPE_I64, CNTTZD, a0, a1, a2, c2);
break;
case INDEX_op_ctpop_i64:
- tcg_out32(s, CNTPOPD | SAB(args[1], args[0], 0));
+ tcg_out32(s, CNTPOPD | SAB(a1, a0, 0));
break;
case INDEX_op_mul_i32:
- a0 = args[0], a1 = args[1], a2 = args[2];
- if (const_args[2]) {
+ if (c2) {
tcg_out32(s, MULLI | TAI(a0, a1, a2));
} else {
tcg_out32(s, MULLW | TAB(a0, a1, a2));
@@ -2601,62 +2596,58 @@ static void tcg_out_op(TCGContext *s, TCGOpcode opc,
const TCGArg *args,
break;
case INDEX_op_div_i32:
- tcg_out32(s, DIVW | TAB(args[0], args[1], args[2]));
+ tcg_out32(s, DIVW | TAB(a0, a1, a2));
break;
case INDEX_op_divu_i32:
- tcg_out32(s, DIVWU | TAB(args[0], args[1], args[2]));
+ tcg_out32(s, DIVWU | TAB(a0, a1, a2));
break;
case INDEX_op_shl_i32:
- if (const_args[2]) {
+ if (c2) {
/* Limit immediate shift count lest we create an illegal insn. */
- tcg_out_shli32(s, args[0], args[1], args[2] & 31);
+ tcg_out_shli32(s, a0, a1, a2 & 31);
} else {
- tcg_out32(s, SLW | SAB(args[1], args[0], args[2]));
+ tcg_out32(s, SLW | SAB(a1, a0, a2));
}
break;
case INDEX_op_shr_i32:
- if (const_args[2]) {
+ if (c2) {
/* Limit immediate shift count lest we create an illegal insn. */
- tcg_out_shri32(s, args[0], args[1], args[2] & 31);
+ tcg_out_shri32(s, a0, a1, a2 & 31);
} else {
- tcg_out32(s, SRW | SAB(args[1], args[0], args[2]));
+ tcg_out32(s, SRW | SAB(a1, a0, a2));
}
break;
case INDEX_op_sar_i32:
- if (const_args[2]) {
+ if (c2) {
/* Limit immediate shift count lest we create an illegal insn. */
- tcg_out32(s, SRAWI | RS(args[1]) | RA(args[0]) | SH(args[2] & 31));
+ tcg_out32(s, SRAWI | RS(a1) | RA(a0) | SH(a2 & 31));
} else {
- tcg_out32(s, SRAW | SAB(args[1], args[0], args[2]));
+ tcg_out32(s, SRAW | SAB(a1, a0, a2));
}
break;
case INDEX_op_rotl_i32:
- if (const_args[2]) {
- tcg_out_rlw(s, RLWINM, args[0], args[1], args[2], 0, 31);
+ if (c2) {
+ tcg_out_rlw(s, RLWINM, a0, a1, a2, 0, 31);
} else {
- tcg_out32(s, RLWNM | SAB(args[1], args[0], args[2])
- | MB(0) | ME(31));
+ tcg_out32(s, RLWNM | SAB(a1, a0, a2) | MB(0) | ME(31));
}
break;
case INDEX_op_rotr_i32:
- if (const_args[2]) {
- tcg_out_rlw(s, RLWINM, args[0], args[1], 32 - args[2], 0, 31);
+ if (c2) {
+ tcg_out_rlw(s, RLWINM, a0, a1, 32 - a2, 0, 31);
} else {
- tcg_out32(s, SUBFIC | TAI(TCG_REG_R0, args[2], 32));
- tcg_out32(s, RLWNM | SAB(args[1], args[0], TCG_REG_R0)
- | MB(0) | ME(31));
+ tcg_out32(s, SUBFIC | TAI(TCG_REG_R0, a2, 32));
+ tcg_out32(s, RLWNM | SAB(a1, a0, TCG_REG_R0) | MB(0) | ME(31));
}
break;
case INDEX_op_brcond_i32:
- tcg_out_brcond(s, args[2], args[0], args[1], const_args[1],
- arg_label(args[3]), TCG_TYPE_I32);
+ tcg_out_brcond(s, a2, a0, a1, c1, arg_label(args[3]), TCG_TYPE_I32);
break;
case INDEX_op_brcond_i64:
- tcg_out_brcond(s, args[2], args[0], args[1], const_args[1],
- arg_label(args[3]), TCG_TYPE_I64);
+ tcg_out_brcond(s, a2, a0, a1, c1, arg_label(args[3]), TCG_TYPE_I64);
break;
case INDEX_op_brcond2_i32:
tcg_out_brcond2(s, args, const_args);
@@ -2664,17 +2655,16 @@ static void tcg_out_op(TCGContext *s, TCGOpcode opc,
const TCGArg *args,
case INDEX_op_neg_i32:
case INDEX_op_neg_i64:
- tcg_out32(s, NEG | RT(args[0]) | RA(args[1]));
+ tcg_out32(s, NEG | RT(a0) | RA(a1));
break;
case INDEX_op_not_i32:
case INDEX_op_not_i64:
- tcg_out32(s, NOR | SAB(args[1], args[0], args[1]));
+ tcg_out32(s, NOR | SAB(a1, a0, a1));
break;
case INDEX_op_add_i64:
- a0 = args[0], a1 = args[1], a2 = args[2];
- if (const_args[2]) {
+ if (c2) {
do_addi_64:
tcg_out_mem_long(s, ADDI, ADD, a0, a1, a2);
} else {
@@ -2682,14 +2672,13 @@ static void tcg_out_op(TCGContext *s, TCGOpcode opc,
const TCGArg *args,
}
break;
case INDEX_op_sub_i64:
- a0 = args[0], a1 = args[1], a2 = args[2];
- if (const_args[1]) {
- if (const_args[2]) {
+ if (c1) {
+ if (c2) {
tcg_out_movi(s, TCG_TYPE_I64, a0, a1 - a2);
} else {
tcg_out32(s, SUBFIC | TAI(a0, a2, a1));
}
- } else if (const_args[2]) {
+ } else if (c2) {
a2 = -a2;
goto do_addi_64;
} else {
@@ -2698,58 +2687,57 @@ static void tcg_out_op(TCGContext *s, TCGOpcode opc,
const TCGArg *args,
break;
case INDEX_op_shl_i64:
- if (const_args[2]) {
+ if (c2) {
/* Limit immediate shift count lest we create an illegal insn. */
- tcg_out_shli64(s, args[0], args[1], args[2] & 63);
+ tcg_out_shli64(s, a0, a1, a2 & 63);
} else {
- tcg_out32(s, SLD | SAB(args[1], args[0], args[2]));
+ tcg_out32(s, SLD | SAB(a1, a0, a2));
}
break;
case INDEX_op_shr_i64:
- if (const_args[2]) {
+ if (c2) {
/* Limit immediate shift count lest we create an illegal insn. */
- tcg_out_shri64(s, args[0], args[1], args[2] & 63);
+ tcg_out_shri64(s, a0, a1, a2 & 63);
} else {
- tcg_out32(s, SRD | SAB(args[1], args[0], args[2]));
+ tcg_out32(s, SRD | SAB(a1, a0, a2));
}
break;
case INDEX_op_sar_i64:
- if (const_args[2]) {
- int sh = SH(args[2] & 0x1f) | (((args[2] >> 5) & 1) << 1);
- tcg_out32(s, SRADI | RA(args[0]) | RS(args[1]) | sh);
+ if (c2) {
+ int sh = SH(a2 & 0x1f) | (((a2 >> 5) & 1) << 1);
+ tcg_out32(s, SRADI | RA(a0) | RS(a1) | sh);
} else {
- tcg_out32(s, SRAD | SAB(args[1], args[0], args[2]));
+ tcg_out32(s, SRAD | SAB(a1, a0, a2));
}
break;
case INDEX_op_rotl_i64:
- if (const_args[2]) {
- tcg_out_rld(s, RLDICL, args[0], args[1], args[2], 0);
+ if (c2) {
+ tcg_out_rld(s, RLDICL, a0, a1, a2, 0);
} else {
- tcg_out32(s, RLDCL | SAB(args[1], args[0], args[2]) | MB64(0));
+ tcg_out32(s, RLDCL | SAB(a1, a0, a2) | MB64(0));
}
break;
case INDEX_op_rotr_i64:
- if (const_args[2]) {
- tcg_out_rld(s, RLDICL, args[0], args[1], 64 - args[2], 0);
+ if (c2) {
+ tcg_out_rld(s, RLDICL, a0, a1, 64 - a2, 0);
} else {
- tcg_out32(s, SUBFIC | TAI(TCG_REG_R0, args[2], 64));
- tcg_out32(s, RLDCL | SAB(args[1], args[0], TCG_REG_R0) | MB64(0));
+ tcg_out32(s, SUBFIC | TAI(TCG_REG_R0, a2, 64));
+ tcg_out32(s, RLDCL | SAB(a1, a0, TCG_REG_R0) | MB64(0));
}
break;
case INDEX_op_mul_i64:
- a0 = args[0], a1 = args[1], a2 = args[2];
- if (const_args[2]) {
+ if (c2) {
tcg_out32(s, MULLI | TAI(a0, a1, a2));
} else {
tcg_out32(s, MULLD | TAB(a0, a1, a2));
}
break;
case INDEX_op_div_i64:
- tcg_out32(s, DIVD | TAB(args[0], args[1], args[2]));
+ tcg_out32(s, DIVD | TAB(a0, a1, a2));
break;
case INDEX_op_divu_i64:
- tcg_out32(s, DIVDU | TAB(args[0], args[1], args[2]));
+ tcg_out32(s, DIVDU | TAB(a0, a1, a2));
break;
case INDEX_op_qemu_ld_i32:
@@ -2778,19 +2766,19 @@ static void tcg_out_op(TCGContext *s, TCGOpcode opc,
const TCGArg *args,
c = EXTSW;
goto gen_ext;
gen_ext:
- tcg_out32(s, c | RS(args[1]) | RA(args[0]));
+ tcg_out32(s, c | RS(a1) | RA(a0));
break;
case INDEX_op_extu_i32_i64:
- tcg_out_ext32u(s, args[0], args[1]);
+ tcg_out_ext32u(s, a0, a1);
break;
case INDEX_op_setcond_i32:
- tcg_out_setcond(s, TCG_TYPE_I32, args[3], args[0], args[1], args[2],
- const_args[2]);
+ tcg_out_setcond(s, TCG_TYPE_I32, args[3], a0, a1, a2,
+ c2);
break;
case INDEX_op_setcond_i64:
- tcg_out_setcond(s, TCG_TYPE_I64, args[3], args[0], args[1], args[2],
- const_args[2]);
+ tcg_out_setcond(s, TCG_TYPE_I64, args[3], a0, a1, a2,
+ c2);
break;
case INDEX_op_setcond2_i32:
tcg_out_setcond2(s, args, const_args);
@@ -2798,7 +2786,6 @@ static void tcg_out_op(TCGContext *s, TCGOpcode opc,
const TCGArg *args,
case INDEX_op_bswap16_i32:
case INDEX_op_bswap16_i64:
- a0 = args[0], a1 = args[1];
/* a1 = abcd */
if (a0 != a1) {
/* a0 = (a1 r<< 24) & 0xff # 000c */
@@ -2818,10 +2805,9 @@ static void tcg_out_op(TCGContext *s, TCGOpcode opc,
const TCGArg *args,
case INDEX_op_bswap32_i32:
case INDEX_op_bswap32_i64:
/* Stolen from gcc's builtin_bswap32 */
- a1 = args[1];
- a0 = args[0] == a1 ? TCG_REG_R0 : args[0];
+ a0 = a0 == a1 ? TCG_REG_R0 : a0;
- /* a1 = args[1] # abcd */
+ /* a1 = a1 # abcd */
/* a0 = rotate_left (a1, 8) # bcda */
tcg_out_rlw(s, RLWINM, a0, a1, 8, 0, 31);
/* a0 = (a0 & ~0xff000000) | ((a1 r<< 24) & 0xff000000) # dcda */
@@ -2830,12 +2816,12 @@ static void tcg_out_op(TCGContext *s, TCGOpcode opc,
const TCGArg *args,
tcg_out_rlw(s, RLWIMI, a0, a1, 24, 16, 23);
if (a0 == TCG_REG_R0) {
- tcg_out_mov(s, TCG_TYPE_REG, args[0], a0);
+ tcg_out_mov(s, TCG_TYPE_REG, a0, a0);
}
break;
case INDEX_op_bswap64_i64:
- a0 = args[0], a1 = args[1], a2 = TCG_REG_R0;
+ a2 = TCG_REG_R0;
if (a0 == a1) {
a0 = TCG_REG_R0;
a2 = a1;
@@ -2862,44 +2848,42 @@ static void tcg_out_op(TCGContext *s, TCGOpcode opc,
const TCGArg *args,
tcg_out_rlw(s, RLWIMI, a0, a2, 24, 16, 23);
if (a0 == 0) {
- tcg_out_mov(s, TCG_TYPE_REG, args[0], a0);
+ tcg_out_mov(s, TCG_TYPE_REG, a0, a0);
}
break;
case INDEX_op_deposit_i32:
- if (const_args[2]) {
+ if (c2) {
uint32_t mask = ((2u << (args[4] - 1)) - 1) << args[3];
- tcg_out_andi32(s, args[0], args[0], ~mask);
+ tcg_out_andi32(s, a0, a0, ~mask);
} else {
- tcg_out_rlw(s, RLWIMI, args[0], args[2], args[3],
+ tcg_out_rlw(s, RLWIMI, a0, a2, args[3],
32 - args[3] - args[4], 31 - args[3]);
}
break;
case INDEX_op_deposit_i64:
- if (const_args[2]) {
+ if (c2) {
uint64_t mask = ((2ull << (args[4] - 1)) - 1) << args[3];
- tcg_out_andi64(s, args[0], args[0], ~mask);
+ tcg_out_andi64(s, a0, a0, ~mask);
} else {
- tcg_out_rld(s, RLDIMI, args[0], args[2], args[3],
- 64 - args[3] - args[4]);
+ tcg_out_rld(s, RLDIMI, a0, a2, args[3], 64 - args[3] - args[4]);
}
break;
case INDEX_op_extract_i32:
- tcg_out_rlw(s, RLWINM, args[0], args[1],
- 32 - args[2], 32 - args[3], 31);
+ tcg_out_rlw(s, RLWINM, a0, a1, 32 - a2, 32 - args[3], 31);
break;
case INDEX_op_extract_i64:
- tcg_out_rld(s, RLDICL, args[0], args[1], 64 - args[2], 64 - args[3]);
+ tcg_out_rld(s, RLDICL, a0, a1, 64 - a2, 64 - args[3]);
break;
case INDEX_op_movcond_i32:
- tcg_out_movcond(s, TCG_TYPE_I32, args[5], args[0], args[1], args[2],
- args[3], args[4], const_args[2]);
+ tcg_out_movcond(s, TCG_TYPE_I32, args[5], a0, a1, a2,
+ args[3], args[4], c2);
break;
case INDEX_op_movcond_i64:
- tcg_out_movcond(s, TCG_TYPE_I64, args[5], args[0], args[1], args[2],
- args[3], args[4], const_args[2]);
+ tcg_out_movcond(s, TCG_TYPE_I64, args[5], a0, a1, a2,
+ args[3], args[4], c2);
break;
#if TCG_TARGET_REG_BITS == 64
@@ -2910,14 +2894,13 @@ static void tcg_out_op(TCGContext *s, TCGOpcode opc,
const TCGArg *args,
/* Note that the CA bit is defined based on the word size of the
environment. So in 64-bit mode it's always carry-out of bit 63.
The fallback code using deposit works just as well for 32-bit. */
- a0 = args[0], a1 = args[1];
if (a0 == args[3] || (!const_args[5] && a0 == args[5])) {
a0 = TCG_REG_R0;
}
if (const_args[4]) {
- tcg_out32(s, ADDIC | TAI(a0, args[2], args[4]));
+ tcg_out32(s, ADDIC | TAI(a0, a2, args[4]));
} else {
- tcg_out32(s, ADDC | TAB(a0, args[2], args[4]));
+ tcg_out32(s, ADDC | TAB(a0, a2, args[4]));
}
if (const_args[5]) {
tcg_out32(s, (args[5] ? ADDME : ADDZE) | RT(a1) | RA(args[3]));
@@ -2925,7 +2908,7 @@ static void tcg_out_op(TCGContext *s, TCGOpcode opc,
const TCGArg *args,
tcg_out32(s, ADDE | TAB(a1, args[3], args[5]));
}
if (a0 != args[0]) {
- tcg_out_mov(s, TCG_TYPE_REG, args[0], a0);
+ tcg_out_mov(s, TCG_TYPE_REG, a0, a0);
}
break;
@@ -2934,14 +2917,13 @@ static void tcg_out_op(TCGContext *s, TCGOpcode opc,
const TCGArg *args,
#else
case INDEX_op_sub2_i32:
#endif
- a0 = args[0], a1 = args[1];
if (a0 == args[5] || (!const_args[3] && a0 == args[3])) {
a0 = TCG_REG_R0;
}
- if (const_args[2]) {
- tcg_out32(s, SUBFIC | TAI(a0, args[4], args[2]));
+ if (c2) {
+ tcg_out32(s, SUBFIC | TAI(a0, args[4], a2));
} else {
- tcg_out32(s, SUBFC | TAB(a0, args[4], args[2]));
+ tcg_out32(s, SUBFC | TAB(a0, args[4], a2));
}
if (const_args[3]) {
tcg_out32(s, (args[3] ? SUBFME : SUBFZE) | RT(a1) | RA(args[5]));
@@ -2949,25 +2931,25 @@ static void tcg_out_op(TCGContext *s, TCGOpcode opc,
const TCGArg *args,
tcg_out32(s, SUBFE | TAB(a1, args[5], args[3]));
}
if (a0 != args[0]) {
- tcg_out_mov(s, TCG_TYPE_REG, args[0], a0);
+ tcg_out_mov(s, TCG_TYPE_REG, a0, a0);
}
break;
case INDEX_op_muluh_i32:
- tcg_out32(s, MULHWU | TAB(args[0], args[1], args[2]));
+ tcg_out32(s, MULHWU | TAB(a0, a1, a2));
break;
case INDEX_op_mulsh_i32:
- tcg_out32(s, MULHW | TAB(args[0], args[1], args[2]));
+ tcg_out32(s, MULHW | TAB(a0, a1, a2));
break;
case INDEX_op_muluh_i64:
- tcg_out32(s, MULHDU | TAB(args[0], args[1], args[2]));
+ tcg_out32(s, MULHDU | TAB(a0, a1, a2));
break;
case INDEX_op_mulsh_i64:
- tcg_out32(s, MULHD | TAB(args[0], args[1], args[2]));
+ tcg_out32(s, MULHD | TAB(a0, a1, a2));
break;
case INDEX_op_mb:
- tcg_out_mb(s, args[0]);
+ tcg_out_mb(s, a0);
break;
case INDEX_op_mov_i32: /* Always emitted via tcg_out_mov. */
--
2.26.2
- [PATCH 0/5] tcg: Restrict tcg_out_op() to arrays of TCG_MAX_OP_ARGS elements, Philippe Mathieu-Daudé, 2021/01/11
- [PATCH 2/5] tcg/ppc: Hoist common argument loads in tcg_out_op(),
Philippe Mathieu-Daudé <=
- [PATCH 1/5] tcg/arm: Hoist common argument loads in tcg_out_op(), Philippe Mathieu-Daudé, 2021/01/11
- [PATCH 3/5] tcg/s390: Hoist common argument loads in tcg_out_op(), Philippe Mathieu-Daudé, 2021/01/11
- [RFC PATCH 4/5] tcg: Restrict tcg_out_op() to arrays of TCG_MAX_OP_ARGS elements, Philippe Mathieu-Daudé, 2021/01/11
- [RFC PATCH 5/5] tcg: Restrict tcg_out_vec_op() to arrays of TCG_MAX_OP_ARGS elements, Philippe Mathieu-Daudé, 2021/01/11
- Re: [PATCH 0/5] tcg: Restrict tcg_out_op() to arrays of TCG_MAX_OP_ARGS elements, Richard Henderson, 2021/01/11