From nobody Mon Feb 9 08:57:17 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; dkim=fail spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1498013763182953.5000802380808; Tue, 20 Jun 2017 19:56:03 -0700 (PDT) Received: from localhost ([::1]:51561 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dNVoH-0003rD-Au for importer@patchew.org; Tue, 20 Jun 2017 22:56:01 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33882) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dNVhF-0006RY-OJ for qemu-devel@nongnu.org; Tue, 20 Jun 2017 22:48:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dNVhE-0002Mo-65 for qemu-devel@nongnu.org; Tue, 20 Jun 2017 22:48:45 -0400 Received: from mail-qk0-x243.google.com ([2607:f8b0:400d:c09::243]:36434) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dNVhE-0002Md-1a for qemu-devel@nongnu.org; Tue, 20 Jun 2017 22:48:44 -0400 Received: by mail-qk0-x243.google.com with SMTP id r62so13614025qkf.3 for ; Tue, 20 Jun 2017 19:48:43 -0700 (PDT) Received: from bigtime.twiddle.net.com (97-113-165-157.tukw.qwest.net. [97.113.165.157]) by smtp.gmail.com with ESMTPSA id l53sm2478939qta.56.2017.06.20.19.48.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 20 Jun 2017 19:48:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=F+lKoNLKZ2ZVHg7THjQVXJO0J81NJspKV4blJseQQHQ=; b=ftdOGLrGQL3MvsBjecPvj6Ke0JUd8Vp49LCzUdXAWrC9wIIQ6F0js1jDYVDqlEmvXf XUr+ZBMG9biRNO/aPM1n/nAGzz/+FYeWCebRSaD2Oby6XimYFxR1p3WF5R3mH90DPgap Qu3NWQaMm4v8fpMhv8XlDizuBfrBXtQ+vusYBXWz4NH1x784jS0CYndofntplkfy9bR7 u8UWXOPsp90lodO0ZAFEZTtIOZcJQmob5tippmhx+tXHe2amqTWed6y/4csF2PY7EoLx RM72ZoTiLFWO64vce5Qr/9rfXrD7yw/EoVLktOF0DDvuhjviyGLnX+Xe3aiOQToPjFUv kM0Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=F+lKoNLKZ2ZVHg7THjQVXJO0J81NJspKV4blJseQQHQ=; b=r8IfJUem6h1uXwGFHyrM9DKFVGjhVncyfz5hRV9qUfDzTiGpA92xRHnBPtcemQXTRb 1LTHuiRtGXVanCmtwm7WN3BYszJgH7KZTnqPvt233cEiliDw3pJpEdTIIJUlZr5R3Xo3 yeJLNAhP/kOW8XpZyxTSsw+RTX2wY9jwvQRg01zGL46TlZTkFgI38is61UKbpm+Jv/b/ 5xVFlClON7ClyUN/Mu6Tpra7qPEzFuhP4U2U4xf0nf8rZhoNCQuhJaLr4DOo5NDn6JL4 ydYzcV9gxxcA4Sj2mmpb5RU1uss4y8hBMPqS5kfYvovMGpV30Vr1d3EW6cE8fZ46+Xrt XVgQ== X-Gm-Message-State: AKS2vOz+0X2e62JTvvxYZyGmG8GxJ4N/oumqTeTB9OKQmdQGaSCs5gtj 4q+uX57nQBAYvpVQyns= X-Received: by 10.55.46.2 with SMTP id u2mr20529062qkh.23.1498013323155; Tue, 20 Jun 2017 19:48:43 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Tue, 20 Jun 2017 19:48:20 -0700 Message-Id: <20170621024831.26019-6-rth@twiddle.net> X-Mailer: git-send-email 2.9.4 In-Reply-To: <20170621024831.26019-1-rth@twiddle.net> References: <20170621024831.26019-1-rth@twiddle.net> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400d:c09::243 Subject: [Qemu-devel] [PATCH 05/16] tcg: Introduce arg_temp X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: aurelien@aurel32.net Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Richard Henderson Reviewed-by: Alex Benn=C3=A9e --- tcg/optimize.c | 4 ++-- tcg/tcg.c | 51 +++++++++++++++++++++++++-------------------------- tcg/tcg.h | 5 +++++ 3 files changed, 32 insertions(+), 28 deletions(-) diff --git a/tcg/optimize.c b/tcg/optimize.c index 1a1c6fb..d8c3a7e 100644 --- a/tcg/optimize.c +++ b/tcg/optimize.c @@ -133,7 +133,7 @@ static TCGArg find_better_copy(TCGContext *s, TCGArg te= mp) } =20 /* If it is a temp, search for a temp local. */ - if (!s->temps[temp].temp_local) { + if (!arg_temp(temp)->temp_local) { for (i =3D temps[temp].next_copy ; i !=3D temp ; i =3D temps[i].ne= xt_copy) { if (s->temps[i].temp_local) { return i; @@ -207,7 +207,7 @@ static void tcg_opt_gen_mov(TCGContext *s, TCGOp *op, T= CGArg dst, TCGArg src) } temps[dst].mask =3D mask; =20 - if (s->temps[src].type =3D=3D s->temps[dst].type) { + if (arg_temp(src)->type =3D=3D arg_temp(dst)->type) { temps[dst].next_copy =3D temps[src].next_copy; temps[dst].prev_copy =3D src; temps[temps[dst].next_copy].prev_copy =3D dst; diff --git a/tcg/tcg.c b/tcg/tcg.c index e2248a6..068ac51 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -977,11 +977,10 @@ static char *tcg_get_arg_str_ptr(TCGContext *s, char = *buf, int buf_size, return buf; } =20 -static char *tcg_get_arg_str_idx(TCGContext *s, char *buf, - int buf_size, int idx) +static char *tcg_get_arg_str(TCGContext *s, char *buf, + int buf_size, TCGArg arg) { - tcg_debug_assert(idx >=3D 0 && idx < s->nb_temps); - return tcg_get_arg_str_ptr(s, buf, buf_size, &s->temps[idx]); + return tcg_get_arg_str_ptr(s, buf, buf_size, arg_temp(arg)); } =20 /* Find helper name. */ @@ -1084,14 +1083,14 @@ void tcg_dump_ops(TCGContext *s) tcg_find_helper(s, op->args[nb_oargs + nb_iarg= s]), op->args[nb_oargs + nb_iargs + 1], nb_oargs); for (i =3D 0; i < nb_oargs; i++) { - col +=3D qemu_log(",%s", tcg_get_arg_str_idx(s, buf, sizeo= f(buf), - op->args[i])); + col +=3D qemu_log(",%s", tcg_get_arg_str(s, buf, sizeof(bu= f), + op->args[i])); } for (i =3D 0; i < nb_iargs; i++) { TCGArg arg =3D op->args[nb_oargs + i]; const char *t =3D ""; if (arg !=3D TCG_CALL_DUMMY_ARG) { - t =3D tcg_get_arg_str_idx(s, buf, sizeof(buf), arg); + t =3D tcg_get_arg_str(s, buf, sizeof(buf), arg); } col +=3D qemu_log(",%s", t); } @@ -1107,15 +1106,15 @@ void tcg_dump_ops(TCGContext *s) if (k !=3D 0) { col +=3D qemu_log(","); } - col +=3D qemu_log("%s", tcg_get_arg_str_idx(s, buf, sizeof= (buf), - op->args[k++])); + col +=3D qemu_log("%s", tcg_get_arg_str(s, buf, sizeof(buf= ), + op->args[k++])); } for (i =3D 0; i < nb_iargs; i++) { if (k !=3D 0) { col +=3D qemu_log(","); } - col +=3D qemu_log("%s", tcg_get_arg_str_idx(s, buf, sizeof= (buf), - op->args[k++])); + col +=3D qemu_log("%s", tcg_get_arg_str(s, buf, sizeof(buf= ), + op->args[k++])); } switch (c) { case INDEX_op_brcond_i32: @@ -1707,7 +1706,7 @@ static bool liveness_pass_2(TCGContext *s, uint8_t *t= emp_state) if (arg < nb_globals) { dir =3D dir_temps[arg]; if (dir !=3D 0 && temp_state[arg] =3D=3D TS_DEAD) { - TCGTemp *its =3D &s->temps[arg]; + TCGTemp *its =3D arg_temp(arg); TCGOpcode lopc =3D (its->type =3D=3D TCG_TYPE_I32 ? INDEX_op_ld_i32 : INDEX_op_ld_i64); @@ -1778,7 +1777,7 @@ static bool liveness_pass_2(TCGContext *s, uint8_t *t= emp_state) =20 /* Sync outputs upon their last write. */ if (NEED_SYNC_ARG(i)) { - TCGTemp *its =3D &s->temps[arg]; + TCGTemp *its =3D arg_temp(arg); TCGOpcode sopc =3D (its->type =3D=3D TCG_TYPE_I32 ? INDEX_op_st_i32 : INDEX_op_st_i64); @@ -1809,7 +1808,7 @@ static void dump_regs(TCGContext *s) =20 for(i =3D 0; i < s->nb_temps; i++) { ts =3D &s->temps[i]; - printf(" %10s: ", tcg_get_arg_str_idx(s, buf, sizeof(buf), i)); + printf(" %10s: ", tcg_get_arg_str_ptr(s, buf, sizeof(buf), ts)); switch(ts->val_type) { case TEMP_VAL_REG: printf("%s", tcg_target_reg_names[ts->reg]); @@ -2113,7 +2112,7 @@ static void tcg_reg_alloc_do_movi(TCGContext *s, TCGT= emp *ots, =20 static void tcg_reg_alloc_movi(TCGContext *s, const TCGOp *op) { - TCGTemp *ots =3D &s->temps[op->args[0]]; + TCGTemp *ots =3D arg_temp(op->args[0]); tcg_target_ulong val =3D op->args[1]; =20 tcg_reg_alloc_do_movi(s, ots, val, op->life); @@ -2127,8 +2126,8 @@ static void tcg_reg_alloc_mov(TCGContext *s, const TC= GOp *op) TCGType otype, itype; =20 tcg_regset_set(allocated_regs, s->reserved_regs); - ots =3D &s->temps[op->args[0]]; - ts =3D &s->temps[op->args[1]]; + ots =3D arg_temp(op->args[0]); + ts =3D arg_temp(op->args[1]); =20 /* Note that otype !=3D itype for no-op truncation. */ otype =3D ots->type; @@ -2225,7 +2224,7 @@ static void tcg_reg_alloc_op(TCGContext *s, const TCG= Op *op) i =3D def->sorted_args[nb_oargs + k]; arg =3D op->args[i]; arg_ct =3D &def->args_ct[i]; - ts =3D &s->temps[arg]; + ts =3D arg_temp(arg); =20 if (ts->val_type =3D=3D TEMP_VAL_CONST && tcg_target_const_match(ts->val, ts->type, arg_ct)) { @@ -2282,7 +2281,7 @@ static void tcg_reg_alloc_op(TCGContext *s, const TCG= Op *op) /* mark dead temporaries and free the associated registers */ for (i =3D nb_oargs; i < nb_oargs + nb_iargs; i++) { if (IS_DEAD_ARG(i)) { - temp_dead(s, &s->temps[op->args[i]]); + temp_dead(s, arg_temp(op->args[i])); } } =20 @@ -2308,7 +2307,7 @@ static void tcg_reg_alloc_op(TCGContext *s, const TCG= Op *op) i =3D def->sorted_args[k]; arg =3D op->args[i]; arg_ct =3D &def->args_ct[i]; - ts =3D &s->temps[arg]; + ts =3D arg_temp(arg); if ((arg_ct->ct & TCG_CT_ALIAS) && !const_args[arg_ct->alias_index]) { reg =3D new_args[arg_ct->alias_index]; @@ -2349,7 +2348,7 @@ static void tcg_reg_alloc_op(TCGContext *s, const TCG= Op *op) =20 /* move the outputs in the correct register if needed */ for(i =3D 0; i < nb_oargs; i++) { - ts =3D &s->temps[op->args[i]]; + ts =3D arg_temp(op->args[i]); reg =3D new_args[i]; if (ts->fixed_reg && ts->reg !=3D reg) { tcg_out_mov(s, ts->type, ts->reg, reg); @@ -2409,7 +2408,7 @@ static void tcg_reg_alloc_call(TCGContext *s, TCGOp *= op) stack_offset -=3D sizeof(tcg_target_long); #endif if (arg !=3D TCG_CALL_DUMMY_ARG) { - ts =3D &s->temps[arg]; + ts =3D arg_temp(arg); temp_load(s, ts, tcg_target_available_regs[ts->type], s->reserved_regs); tcg_out_st(s, ts->type, ts->reg, TCG_REG_CALL_STACK, stack_off= set); @@ -2424,7 +2423,7 @@ static void tcg_reg_alloc_call(TCGContext *s, TCGOp *= op) for (i =3D 0; i < nb_regs; i++) { arg =3D op->args[nb_oargs + i]; if (arg !=3D TCG_CALL_DUMMY_ARG) { - ts =3D &s->temps[arg]; + ts =3D arg_temp(arg); reg =3D tcg_target_call_iarg_regs[i]; tcg_reg_free(s, reg, allocated_regs); =20 @@ -2447,7 +2446,7 @@ static void tcg_reg_alloc_call(TCGContext *s, TCGOp *= op) /* mark dead temporaries and free the associated registers */ for (i =3D nb_oargs; i < nb_iargs + nb_oargs; i++) { if (IS_DEAD_ARG(i)) { - temp_dead(s, &s->temps[op->args[i]]); + temp_dead(s, arg_temp(op->args[i])); } } =20 @@ -2473,7 +2472,7 @@ static void tcg_reg_alloc_call(TCGContext *s, TCGOp *= op) /* assign output registers and emit moves if needed */ for(i =3D 0; i < nb_oargs; i++) { arg =3D op->args[i]; - ts =3D &s->temps[arg]; + ts =3D arg_temp(arg); reg =3D tcg_target_call_oarg_regs[i]; tcg_debug_assert(s->reg_to_temp[reg] =3D=3D NULL); =20 @@ -2646,7 +2645,7 @@ int tcg_gen_code(TCGContext *s, TranslationBlock *tb) } break; case INDEX_op_discard: - temp_dead(s, &s->temps[op->args[0]]); + temp_dead(s, arg_temp(op->args[0])); break; case INDEX_op_set_label: tcg_reg_alloc_bb_end(s, s->reserved_regs); diff --git a/tcg/tcg.h b/tcg/tcg.h index 720e04e..70d9fda 100644 --- a/tcg/tcg.h +++ b/tcg/tcg.h @@ -724,6 +724,11 @@ struct TCGContext { extern TCGContext tcg_ctx; extern bool parallel_cpus; =20 +static inline TCGTemp *arg_temp(TCGArg a) +{ + return &tcg_ctx.temps[a]; +} + static inline void tcg_set_insn_param(int op_idx, int arg, TCGArg v) { tcg_ctx.gen_op_buf[op_idx].args[arg] =3D v; --=20 2.9.4