From patchwork Mon Oct 16 17:25:20 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 115930 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp3934898qgn; Mon, 16 Oct 2017 10:28:25 -0700 (PDT) X-Received: by 10.55.82.86 with SMTP id g83mr14637466qkb.342.1508174905749; Mon, 16 Oct 2017 10:28:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508174905; cv=none; d=google.com; s=arc-20160816; b=QHk+276D4QzzYBaBjknUXAx/EuBuR6pmq0iHWHEqP7uFy4falkTU40wYu5/Fwp1PEw D9WNLD2BD7AGV2x87h6qleicyQUvormZWo5pUlHYL7CJVAE7Dv4AYASZMwlxiTYbWXvS bzUjvBXC8JwBdGWsOCfs8PpCJzcJdiZ88YLJFzZgmoAzh3C8nOj0byGzFn6XbuhqxfLm Sm7caOJ+luXr0KKULl4tbaeAej0CYhPgYFUJmaa3YMXpIvivxDxbjLC/Vy3O475LcQHw uHOTLbtF7g0NGjatkpH5yk/WxhsdsIdPHzJtEbVtsgV3ZzDmdsBN7X2Ro+RnzdUvK54p f9dw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=zgPU8osK8WOXr6Bfqyrt6MJzS9T+IaVLi64zYa/MXV8=; b=n2fgs/m15PTNjfx67tATTcFQ4Hz2pnw0vHqiPrFCzyD4B/03MRsBELl0SdoMD2epPm pxs6OQkv+/+cs+JMDcw9fYzVkIYoxIcK/KaIkBwZjDdyRpYphbS/6EsJ9HvY9DBy8oBu JwuOmkt2ytSIjldoCP7Vo9CvulU3mABovcpXf+pyFdjjSacAoGjeWUpET/GVSGlUTYTV t6xba7LxUKrAifMlPv29q9AWKgTJ0PkOTupZo9FvMncsLnWXlarfHmWU/cJBe4FHlE82 joJIBoSBRYS/fJoGe1RtltAmSmp9ioTUCrjLTDDNDL9/EVngdeOcLML2qgAxy2wm7bQW Fz+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=QiGukZDT; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id k39si4322286qtc.441.2017.10.16.10.28.25 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 16 Oct 2017 10:28:25 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=QiGukZDT; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:34300 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e49Bf-0003Ln-DN for patch@linaro.org; Mon, 16 Oct 2017 13:28:23 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52130) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e499e-0001rP-U7 for qemu-devel@nongnu.org; Mon, 16 Oct 2017 13:26:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e499b-0003Bs-RI for qemu-devel@nongnu.org; Mon, 16 Oct 2017 13:26:18 -0400 Received: from mail-pg0-x230.google.com ([2607:f8b0:400e:c05::230]:55517) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e499b-0003BA-Hr for qemu-devel@nongnu.org; Mon, 16 Oct 2017 13:26:15 -0400 Received: by mail-pg0-x230.google.com with SMTP id b11so7344727pgn.12 for ; Mon, 16 Oct 2017 10:26:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=zgPU8osK8WOXr6Bfqyrt6MJzS9T+IaVLi64zYa/MXV8=; b=QiGukZDTZTC6YdC7c2eb1M5mn+4KsWEV35fh8dUZ+XQAV84jktNa6O105OXOVqJdlf Ds3eoj7vKl+4ms/wdPKfkGW7KMuNNDkRDb9i9r+u0MxNArA8OnZbRYi+NoUjoaVyQMFY i2nIQzBImNNm/LbwsHQ8vxD0h6pHAYdgYeBzI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=zgPU8osK8WOXr6Bfqyrt6MJzS9T+IaVLi64zYa/MXV8=; b=jHiSIzV9JRkaoH1oaqjywTbNYCLIsoVtS82PRMkLAiwPpXUmPM77EivWpoRne9033G h3hm2tGZF1+IkueXceiWEFXTY4+zDbCMPULUXHVa5Gn2zqZWnyZlso0EHTf//V2ikX5O bAZoWOcmByv8z30xjxnhpPqwWU/EOr+gJeHcBpuOMSH0hE4mSJODOrRLGW9rK+Ka75yd Q3lKYrp/Z4LC9c/xW7LiDELW7NNjakC2WxaDFzrFnA+/FjEzHWhWeeq3TIrgqkrhQzwQ C9+boQM7RtZpgF5q3wqvj72FM+3ae0B4M/fEmS6Tmxf6Brwszq3YK6+ErE7+XfUHszg2 iC1w== X-Gm-Message-State: AMCzsaWDzS17hLK9GcrWAilc8puzdf8x4NaAZixZqXgwTE14+5UmnePD dctymtfcKMn+S8bFOx9qcaYILKjeLXY= X-Google-Smtp-Source: AOwi7QCiE4Yj/G+gcbEZfQWKIceom+znKv7goM8glFU5meSiEv5S8Dn0G9vjTC6vvqg9UbYECGD/yg== X-Received: by 10.99.127.67 with SMTP id p3mr8823114pgn.321.1508174774058; Mon, 16 Oct 2017 10:26:14 -0700 (PDT) Received: from cloudburst.twiddle.net (97-126-104-76.tukw.qwest.net. [97.126.104.76]) by smtp.gmail.com with ESMTPSA id i187sm5594249pfc.96.2017.10.16.10.26.12 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 16 Oct 2017 10:26:13 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Mon, 16 Oct 2017 10:25:20 -0700 Message-Id: <20171016172609.23422-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171016172609.23422-1-richard.henderson@linaro.org> References: <20171016172609.23422-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c05::230 Subject: [Qemu-devel] [PATCH v6 01/50] tcg: Merge opcode arguments into TCGOp 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: cota@braap.org, Richard Henderson Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson Rather than have a separate buffer of 10*max_ops entries, give each opcode 10 entries. The result is actually a bit smaller and should have slightly more cache locality. Signed-off-by: Richard Henderson --- tcg/tcg.h | 37 ++++++++++------------ tcg/optimize.c | 6 ++-- tcg/tcg-op.c | 99 +++++++++++++++++++++------------------------------------- tcg/tcg.c | 98 ++++++++++++++++++++++++++------------------------------- 4 files changed, 98 insertions(+), 142 deletions(-) -- 2.13.6 Reviewed-by: Emilio G. Cota diff --git a/tcg/tcg.h b/tcg/tcg.h index b2d42e3136..2cefd9f125 100644 --- a/tcg/tcg.h +++ b/tcg/tcg.h @@ -51,8 +51,6 @@ #define OPC_BUF_SIZE 640 #define OPC_MAX_SIZE (OPC_BUF_SIZE - MAX_OP_PER_INSTR) -#define OPPARAM_BUF_SIZE (OPC_BUF_SIZE * MAX_OPC_PARAM) - #define CPU_TEMP_BUF_NLONGS 128 /* Default target word size to pointer size. */ @@ -606,33 +604,33 @@ typedef struct TCGTempSet { #define SYNC_ARG 1 typedef uint16_t TCGLifeData; -/* The layout here is designed to avoid crossing of a 32-bit boundary. - If we do so, gcc adds padding, expanding the size to 12. */ +/* The layout here is designed to avoid a bitfield crossing of + a 32-bit boundary, which would cause GCC to add extra padding. */ typedef struct TCGOp { TCGOpcode opc : 8; /* 8 */ - /* Index of the prev/next op, or 0 for the end of the list. */ - unsigned prev : 10; /* 18 */ - unsigned next : 10; /* 28 */ - /* The number of out and in parameter for a call. */ - unsigned calli : 4; /* 32 */ - unsigned callo : 2; /* 34 */ + unsigned calli : 4; /* 12 */ + unsigned callo : 2; /* 14 */ + unsigned : 2; /* 16 */ - /* Index of the arguments for this op, or 0 for zero-operand ops. */ - unsigned args : 14; /* 48 */ + /* Index of the prev/next op, or 0 for the end of the list. */ + unsigned prev : 16; /* 32 */ + unsigned next : 16; /* 48 */ /* Lifetime data of the operands. */ unsigned life : 16; /* 64 */ + + /* Arguments for the opcode. */ + TCGArg args[MAX_OPC_PARAM]; } TCGOp; +/* Make sure that we don't expand the structure without noticing. */ +QEMU_BUILD_BUG_ON(sizeof(TCGOp) != 8 + sizeof(TCGArg) * MAX_OPC_PARAM); + /* Make sure operands fit in the bitfields above. */ QEMU_BUILD_BUG_ON(NB_OPS > (1 << 8)); -QEMU_BUILD_BUG_ON(OPC_BUF_SIZE > (1 << 10)); -QEMU_BUILD_BUG_ON(OPPARAM_BUF_SIZE > (1 << 14)); - -/* Make sure that we don't overflow 64 bits without noticing. */ -QEMU_BUILD_BUG_ON(sizeof(TCGOp) > 8); +QEMU_BUILD_BUG_ON(OPC_BUF_SIZE > (1 << 16)); struct TCGContext { uint8_t *pool_cur, *pool_end; @@ -682,7 +680,6 @@ struct TCGContext { #endif int gen_next_op_idx; - int gen_next_parm_idx; /* Code generation. Note that we specifically do not use tcg_insn_unit here, because there's too much arithmetic throughout that relies @@ -720,7 +717,6 @@ struct TCGContext { TCGTemp *reg_to_temp[TCG_TARGET_NB_REGS]; TCGOp gen_op_buf[OPC_BUF_SIZE]; - TCGArg gen_opparam_buf[OPPARAM_BUF_SIZE]; uint16_t gen_insn_end_off[TCG_MAX_INSNS]; target_ulong gen_insn_data[TCG_MAX_INSNS][TARGET_INSN_START_WORDS]; @@ -731,8 +727,7 @@ extern bool parallel_cpus; static inline void tcg_set_insn_param(int op_idx, int arg, TCGArg v) { - int op_argi = tcg_ctx.gen_op_buf[op_idx].args; - tcg_ctx.gen_opparam_buf[op_argi + arg] = v; + tcg_ctx.gen_op_buf[op_idx].args[arg] = v; } /* The number of opcodes emitted so far. */ diff --git a/tcg/optimize.c b/tcg/optimize.c index adfc56ce62..002aad6bf4 100644 --- a/tcg/optimize.c +++ b/tcg/optimize.c @@ -576,7 +576,7 @@ void tcg_optimize(TCGContext *s) TCGArg tmp; TCGOp * const op = &s->gen_op_buf[oi]; - TCGArg * const args = &s->gen_opparam_buf[op->args]; + TCGArg * const args = op->args; TCGOpcode opc = op->opc; const TCGOpDef *def = &tcg_op_defs[opc]; @@ -1184,7 +1184,7 @@ void tcg_optimize(TCGContext *s) uint64_t b = ((uint64_t)bh << 32) | bl; TCGArg rl, rh; TCGOp *op2 = tcg_op_insert_before(s, op, INDEX_op_movi_i32, 2); - TCGArg *args2 = &s->gen_opparam_buf[op2->args]; + TCGArg *args2 = op2->args; if (opc == INDEX_op_add2_i32) { a += b; @@ -1210,7 +1210,7 @@ void tcg_optimize(TCGContext *s) uint64_t r = (uint64_t)a * b; TCGArg rl, rh; TCGOp *op2 = tcg_op_insert_before(s, op, INDEX_op_movi_i32, 2); - TCGArg *args2 = &s->gen_opparam_buf[op2->args]; + TCGArg *args2 = op2->args; rl = args[0]; rh = args[1]; diff --git a/tcg/tcg-op.c b/tcg/tcg-op.c index d3c0e4799e..bd84a782e3 100644 --- a/tcg/tcg-op.c +++ b/tcg/tcg-op.c @@ -46,107 +46,78 @@ extern TCGv_i32 TCGV_HIGH_link_error(TCGv_i64); Up to and including filling in the forward link immediately. We'll do proper termination of the end of the list after we finish translation. */ -static void tcg_emit_op(TCGContext *ctx, TCGOpcode opc, int args) +static inline TCGOp *tcg_emit_op(TCGContext *ctx, TCGOpcode opc) { int oi = ctx->gen_next_op_idx; int ni = oi + 1; int pi = oi - 1; + TCGOp *op = &ctx->gen_op_buf[oi]; tcg_debug_assert(oi < OPC_BUF_SIZE); ctx->gen_op_buf[0].prev = oi; ctx->gen_next_op_idx = ni; - ctx->gen_op_buf[oi] = (TCGOp){ - .opc = opc, - .args = args, - .prev = pi, - .next = ni - }; + memset(op, 0, offsetof(TCGOp, args)); + op->opc = opc; + op->prev = pi; + op->next = ni; + + return op; } void tcg_gen_op1(TCGContext *ctx, TCGOpcode opc, TCGArg a1) { - int pi = ctx->gen_next_parm_idx; - - tcg_debug_assert(pi + 1 <= OPPARAM_BUF_SIZE); - ctx->gen_next_parm_idx = pi + 1; - ctx->gen_opparam_buf[pi] = a1; - - tcg_emit_op(ctx, opc, pi); + TCGOp *op = tcg_emit_op(ctx, opc); + op->args[0] = a1; } void tcg_gen_op2(TCGContext *ctx, TCGOpcode opc, TCGArg a1, TCGArg a2) { - int pi = ctx->gen_next_parm_idx; - - tcg_debug_assert(pi + 2 <= OPPARAM_BUF_SIZE); - ctx->gen_next_parm_idx = pi + 2; - ctx->gen_opparam_buf[pi + 0] = a1; - ctx->gen_opparam_buf[pi + 1] = a2; - - tcg_emit_op(ctx, opc, pi); + TCGOp *op = tcg_emit_op(ctx, opc); + op->args[0] = a1; + op->args[1] = a2; } void tcg_gen_op3(TCGContext *ctx, TCGOpcode opc, TCGArg a1, TCGArg a2, TCGArg a3) { - int pi = ctx->gen_next_parm_idx; - - tcg_debug_assert(pi + 3 <= OPPARAM_BUF_SIZE); - ctx->gen_next_parm_idx = pi + 3; - ctx->gen_opparam_buf[pi + 0] = a1; - ctx->gen_opparam_buf[pi + 1] = a2; - ctx->gen_opparam_buf[pi + 2] = a3; - - tcg_emit_op(ctx, opc, pi); + TCGOp *op = tcg_emit_op(ctx, opc); + op->args[0] = a1; + op->args[1] = a2; + op->args[2] = a3; } void tcg_gen_op4(TCGContext *ctx, TCGOpcode opc, TCGArg a1, TCGArg a2, TCGArg a3, TCGArg a4) { - int pi = ctx->gen_next_parm_idx; - - tcg_debug_assert(pi + 4 <= OPPARAM_BUF_SIZE); - ctx->gen_next_parm_idx = pi + 4; - ctx->gen_opparam_buf[pi + 0] = a1; - ctx->gen_opparam_buf[pi + 1] = a2; - ctx->gen_opparam_buf[pi + 2] = a3; - ctx->gen_opparam_buf[pi + 3] = a4; - - tcg_emit_op(ctx, opc, pi); + TCGOp *op = tcg_emit_op(ctx, opc); + op->args[0] = a1; + op->args[1] = a2; + op->args[2] = a3; + op->args[3] = a4; } void tcg_gen_op5(TCGContext *ctx, TCGOpcode opc, TCGArg a1, TCGArg a2, TCGArg a3, TCGArg a4, TCGArg a5) { - int pi = ctx->gen_next_parm_idx; - - tcg_debug_assert(pi + 5 <= OPPARAM_BUF_SIZE); - ctx->gen_next_parm_idx = pi + 5; - ctx->gen_opparam_buf[pi + 0] = a1; - ctx->gen_opparam_buf[pi + 1] = a2; - ctx->gen_opparam_buf[pi + 2] = a3; - ctx->gen_opparam_buf[pi + 3] = a4; - ctx->gen_opparam_buf[pi + 4] = a5; - - tcg_emit_op(ctx, opc, pi); + TCGOp *op = tcg_emit_op(ctx, opc); + op->args[0] = a1; + op->args[1] = a2; + op->args[2] = a3; + op->args[3] = a4; + op->args[4] = a5; } void tcg_gen_op6(TCGContext *ctx, TCGOpcode opc, TCGArg a1, TCGArg a2, TCGArg a3, TCGArg a4, TCGArg a5, TCGArg a6) { - int pi = ctx->gen_next_parm_idx; - - tcg_debug_assert(pi + 6 <= OPPARAM_BUF_SIZE); - ctx->gen_next_parm_idx = pi + 6; - ctx->gen_opparam_buf[pi + 0] = a1; - ctx->gen_opparam_buf[pi + 1] = a2; - ctx->gen_opparam_buf[pi + 2] = a3; - ctx->gen_opparam_buf[pi + 3] = a4; - ctx->gen_opparam_buf[pi + 4] = a5; - ctx->gen_opparam_buf[pi + 5] = a6; - - tcg_emit_op(ctx, opc, pi); + TCGOp *op = tcg_emit_op(ctx, opc); + op->args[0] = a1; + op->args[1] = a2; + op->args[2] = a3; + op->args[3] = a4; + op->args[4] = a5; + op->args[5] = a6; } void tcg_gen_mb(TCGBar mb_type) diff --git a/tcg/tcg.c b/tcg/tcg.c index 4492e1eb3f..98673f2190 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -471,7 +471,6 @@ void tcg_func_start(TCGContext *s) s->gen_op_buf[0].next = 1; s->gen_op_buf[0].prev = 0; s->gen_next_op_idx = 1; - s->gen_next_parm_idx = 0; } static inline int temp_idx(TCGContext *s, TCGTemp *ts) @@ -980,9 +979,10 @@ bool tcg_op_supported(TCGOpcode op) void tcg_gen_callN(TCGContext *s, void *func, TCGArg ret, int nargs, TCGArg *args) { - int i, real_args, nb_rets, pi, pi_first; + int i, real_args, nb_rets, pi; unsigned sizemask, flags; TCGHelperInfo *info; + TCGOp *op; info = g_hash_table_lookup(helper_table, (gpointer)func); flags = info->flags; @@ -995,11 +995,11 @@ void tcg_gen_callN(TCGContext *s, void *func, TCGArg ret, int orig_sizemask = sizemask; int orig_nargs = nargs; TCGv_i64 retl, reth; + TCGArg split_args[MAX_OPC_PARAM]; TCGV_UNUSED_I64(retl); TCGV_UNUSED_I64(reth); if (sizemask != 0) { - TCGArg *split_args = __builtin_alloca(sizeof(TCGArg) * nargs * 2); for (i = real_args = 0; i < nargs; ++i) { int is_64bit = sizemask & (1 << (i+1)*2); if (is_64bit) { @@ -1034,7 +1034,19 @@ void tcg_gen_callN(TCGContext *s, void *func, TCGArg ret, } #endif /* TCG_TARGET_EXTEND_ARGS */ - pi_first = pi = s->gen_next_parm_idx; + i = s->gen_next_op_idx; + tcg_debug_assert(i < OPC_BUF_SIZE); + s->gen_op_buf[0].prev = i; + s->gen_next_op_idx = i + 1; + op = &s->gen_op_buf[i]; + + /* Set links for sequential allocation during translation. */ + memset(op, 0, offsetof(TCGOp, args)); + op->opc = INDEX_op_call; + op->prev = i - 1; + op->next = i + 1; + + pi = 0; if (ret != TCG_CALL_DUMMY_ARG) { #if defined(__sparc__) && !defined(__arch64__) \ && !defined(CONFIG_TCG_INTERPRETER) @@ -1044,31 +1056,33 @@ void tcg_gen_callN(TCGContext *s, void *func, TCGArg ret, two return temporaries, and reassemble below. */ retl = tcg_temp_new_i64(); reth = tcg_temp_new_i64(); - s->gen_opparam_buf[pi++] = GET_TCGV_I64(reth); - s->gen_opparam_buf[pi++] = GET_TCGV_I64(retl); + op->args[pi++] = GET_TCGV_I64(reth); + op->args[pi++] = GET_TCGV_I64(retl); nb_rets = 2; } else { - s->gen_opparam_buf[pi++] = ret; + op->args[pi++] = ret; nb_rets = 1; } #else if (TCG_TARGET_REG_BITS < 64 && (sizemask & 1)) { #ifdef HOST_WORDS_BIGENDIAN - s->gen_opparam_buf[pi++] = ret + 1; - s->gen_opparam_buf[pi++] = ret; + op->args[pi++] = ret + 1; + op->args[pi++] = ret; #else - s->gen_opparam_buf[pi++] = ret; - s->gen_opparam_buf[pi++] = ret + 1; + op->args[pi++] = ret; + op->args[pi++] = ret + 1; #endif nb_rets = 2; } else { - s->gen_opparam_buf[pi++] = ret; + op->args[pi++] = ret; nb_rets = 1; } #endif } else { nb_rets = 0; } + op->callo = nb_rets; + real_args = 0; for (i = 0; i < nargs; i++) { int is_64bit = sizemask & (1 << (i+1)*2); @@ -1076,7 +1090,7 @@ void tcg_gen_callN(TCGContext *s, void *func, TCGArg ret, #ifdef TCG_TARGET_CALL_ALIGN_ARGS /* some targets want aligned 64 bit args */ if (real_args & 1) { - s->gen_opparam_buf[pi++] = TCG_CALL_DUMMY_ARG; + op->args[pi++] = TCG_CALL_DUMMY_ARG; real_args++; } #endif @@ -1091,42 +1105,26 @@ void tcg_gen_callN(TCGContext *s, void *func, TCGArg ret, have to get more complicated to differentiate between stack arguments and register arguments. */ #if defined(HOST_WORDS_BIGENDIAN) != defined(TCG_TARGET_STACK_GROWSUP) - s->gen_opparam_buf[pi++] = args[i] + 1; - s->gen_opparam_buf[pi++] = args[i]; + op->args[pi++] = args[i] + 1; + op->args[pi++] = args[i]; #else - s->gen_opparam_buf[pi++] = args[i]; - s->gen_opparam_buf[pi++] = args[i] + 1; + op->args[pi++] = args[i]; + op->args[pi++] = args[i] + 1; #endif real_args += 2; continue; } - s->gen_opparam_buf[pi++] = args[i]; + op->args[pi++] = args[i]; real_args++; } - s->gen_opparam_buf[pi++] = (uintptr_t)func; - s->gen_opparam_buf[pi++] = flags; + op->args[pi++] = (uintptr_t)func; + op->args[pi++] = flags; + op->calli = real_args; - i = s->gen_next_op_idx; - tcg_debug_assert(i < OPC_BUF_SIZE); - tcg_debug_assert(pi <= OPPARAM_BUF_SIZE); - - /* Set links for sequential allocation during translation. */ - s->gen_op_buf[i] = (TCGOp){ - .opc = INDEX_op_call, - .callo = nb_rets, - .calli = real_args, - .args = pi_first, - .prev = i - 1, - .next = i + 1 - }; - - /* Make sure the calli field didn't overflow. */ - tcg_debug_assert(s->gen_op_buf[i].calli == real_args); - - s->gen_op_buf[0].prev = i; - s->gen_next_op_idx = i + 1; - s->gen_next_parm_idx = pi; + /* Make sure the fields didn't overflow. */ + tcg_debug_assert(op->calli == real_args); + tcg_debug_assert(pi <= ARRAY_SIZE(op->args)); #if defined(__sparc__) && !defined(__arch64__) \ && !defined(CONFIG_TCG_INTERPRETER) @@ -1286,7 +1284,7 @@ void tcg_dump_ops(TCGContext *s) op = &s->gen_op_buf[oi]; c = op->opc; def = &tcg_op_defs[c]; - args = &s->gen_opparam_buf[op->args]; + args = op->args; if (c == INDEX_op_insn_start) { col += qemu_log("%s ----", oi != s->gen_op_buf[0].next ? "\n" : ""); @@ -1570,20 +1568,16 @@ TCGOp *tcg_op_insert_before(TCGContext *s, TCGOp *old_op, TCGOpcode opc, int nargs) { int oi = s->gen_next_op_idx; - int pi = s->gen_next_parm_idx; int prev = old_op->prev; int next = old_op - s->gen_op_buf; TCGOp *new_op; tcg_debug_assert(oi < OPC_BUF_SIZE); - tcg_debug_assert(pi + nargs <= OPPARAM_BUF_SIZE); s->gen_next_op_idx = oi + 1; - s->gen_next_parm_idx = pi + nargs; new_op = &s->gen_op_buf[oi]; *new_op = (TCGOp){ .opc = opc, - .args = pi, .prev = prev, .next = next }; @@ -1597,20 +1591,16 @@ TCGOp *tcg_op_insert_after(TCGContext *s, TCGOp *old_op, TCGOpcode opc, int nargs) { int oi = s->gen_next_op_idx; - int pi = s->gen_next_parm_idx; int prev = old_op - s->gen_op_buf; int next = old_op->next; TCGOp *new_op; tcg_debug_assert(oi < OPC_BUF_SIZE); - tcg_debug_assert(pi + nargs <= OPPARAM_BUF_SIZE); s->gen_next_op_idx = oi + 1; - s->gen_next_parm_idx = pi + nargs; new_op = &s->gen_op_buf[oi]; *new_op = (TCGOp){ .opc = opc, - .args = pi, .prev = prev, .next = next }; @@ -1666,7 +1656,7 @@ static void liveness_pass_1(TCGContext *s, uint8_t *temp_state) TCGArg arg; TCGOp * const op = &s->gen_op_buf[oi]; - TCGArg * const args = &s->gen_opparam_buf[op->args]; + TCGArg * const args = op->args; TCGOpcode opc = op->opc; const TCGOpDef *def = &tcg_op_defs[opc]; @@ -1904,7 +1894,7 @@ static bool liveness_pass_2(TCGContext *s, uint8_t *temp_state) for (oi = s->gen_op_buf[0].next; oi != 0; oi = oi_next) { TCGOp *op = &s->gen_op_buf[oi]; - TCGArg *args = &s->gen_opparam_buf[op->args]; + TCGArg *args = op->args; TCGOpcode opc = op->opc; const TCGOpDef *def = &tcg_op_defs[opc]; TCGLifeData arg_life = op->life; @@ -1947,7 +1937,7 @@ static bool liveness_pass_2(TCGContext *s, uint8_t *temp_state) ? INDEX_op_ld_i32 : INDEX_op_ld_i64); TCGOp *lop = tcg_op_insert_before(s, op, lopc, 3); - TCGArg *largs = &s->gen_opparam_buf[lop->args]; + TCGArg *largs = lop->args; largs[0] = dir; largs[1] = temp_idx(s, its->mem_base); @@ -2019,7 +2009,7 @@ static bool liveness_pass_2(TCGContext *s, uint8_t *temp_state) ? INDEX_op_st_i32 : INDEX_op_st_i64); TCGOp *sop = tcg_op_insert_after(s, op, sopc, 3); - TCGArg *sargs = &s->gen_opparam_buf[sop->args]; + TCGArg *sargs = sop->args; sargs[0] = dir; sargs[1] = temp_idx(s, its->mem_base); @@ -2851,7 +2841,7 @@ int tcg_gen_code(TCGContext *s, TranslationBlock *tb) num_insns = -1; for (oi = s->gen_op_buf[0].next; oi != 0; oi = oi_next) { TCGOp * const op = &s->gen_op_buf[oi]; - TCGArg * const args = &s->gen_opparam_buf[op->args]; + TCGArg * const args = op->args; TCGOpcode opc = op->opc; const TCGOpDef *def = &tcg_op_defs[opc]; TCGLifeData arg_life = op->life; From patchwork Mon Oct 16 17:25:21 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 115929 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp3932767qgn; Mon, 16 Oct 2017 10:26:54 -0700 (PDT) X-Received: by 10.200.22.168 with SMTP id r37mr13994606qtj.21.1508174814561; Mon, 16 Oct 2017 10:26:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508174814; cv=none; d=google.com; s=arc-20160816; b=La0cwOqQc4hSfMFazI7JuQUrERzaP6gbjyFlFFMU1kaN/RjQnYJZyYss2JVzAYdgG7 eUhmiBcgGJM4MZsxhRnCAxUo9pgcpgCUQl4wVeLldCA4UZvDa0nNWQcUreGXWKbMNAOY mgLjEw2H9cX+UkoXln19MGBIKlo1ZulEabZMtJNN1rHIpPIhaFB4Ls+Zi6b1elBv3G9M JiTo281X4TlyzX02wPXY9+Dx2tQwEXGDFuTZfrMxrbfSSyAdkUjCXzOkBngzhAFQCQ5x 4B+nvqtq4WzMLpe1v0/FRXUK/JCtSkfKw/csDlmGkyEqVZljAWLOpTmiNYjNLipIc82j a1GA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=ODA7Ix+4en7mOBzGZjcg2RzL9rqEzZqA9JKaAz1eR7I=; b=xae5I7w/e6j45/xEDhRaZjLbHEYWYmMxOxPzZftabgAGu/2ERvRyG9sctVQHPuoClD d9BFn3O2/5dolbqwlm/DhkdxNuRM/j+UzI4NE6YOpn8UqNf7lIIZu2KpIrA1LFl9r6hv CPReyUSUfQidB7XSX2h67IDOTMt8eLlMvSKMvn7y15sMGJrY3wN3smLIUCdtgqC6LcL3 CL1RXtCQd+nDDVto2O5Tm89/ztomkYrFfryjVcWyifEaawS4Dak2qSjMf3zIT45FSFhq UKxWiDNWBOGVvxjzvRPUHeGC2AsN4QGDq5BKnvI69hSLJg/cRJAhuYfwPvESc/0sDNti aSrg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=W8nP5LE6; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id m81si534435qkl.413.2017.10.16.10.26.53 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 16 Oct 2017 10:26:54 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=W8nP5LE6; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:34292 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e49AC-0001yp-2w for patch@linaro.org; Mon, 16 Oct 2017 13:26:52 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52175) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e499h-0001sd-7I for qemu-devel@nongnu.org; Mon, 16 Oct 2017 13:26:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e499d-0003EE-HC for qemu-devel@nongnu.org; Mon, 16 Oct 2017 13:26:21 -0400 Received: from mail-pg0-x234.google.com ([2607:f8b0:400e:c05::234]:52165) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e499d-0003DA-4K for qemu-devel@nongnu.org; Mon, 16 Oct 2017 13:26:17 -0400 Received: by mail-pg0-x234.google.com with SMTP id p9so2747468pgc.8 for ; Mon, 16 Oct 2017 10:26:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ODA7Ix+4en7mOBzGZjcg2RzL9rqEzZqA9JKaAz1eR7I=; b=W8nP5LE6MUPb5O8pv5VEs7JzxBoj6VIegCHkudSt52HMVCrUPqSds96mZpM3HdjnBd nmS2/KjjyXAXuEBQSrAqaROQnpPKnbal32/bmTRBwH3KP9wjYeVNGHnidZ0FYlW3I/OJ kZNj40+xRMxkdqDwqYDwu8vNuPg343Rac/Wio= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ODA7Ix+4en7mOBzGZjcg2RzL9rqEzZqA9JKaAz1eR7I=; b=kfBT3LFpRbECwmb/sgN8DiObsfwqbFf26usA5YG5+8Rvj01TWogQ1mReRjyQ10ZrBa mYi8Fc5ahdkgKRRN9Zm7gOfRHTbR7L1cKHFNlGEpM73ky7s6AjUYUtc7cmSnYOUPcuR8 qF8wBeAuZ0mReSePWG+Kei1DvTya9guUsdxMKMQr0p/SagLXcPa1UGTH1oH0BvzdLh5b OL+6IdFGBenliYSW5NL5yXB7J2kutCH+eP4JK7Rw3cL1kisbLCuxBiUJ9PkVLy5N4bgx AmzkIQBdaKIf6KjNcmCSdosZnlmuIS1CAzx2WzF17AP1S/wF2DQG60wmQtakmVlilRLw ay6A== X-Gm-Message-State: AMCzsaWU1lZww44VLojncEOou4smxYnVCneqiRrfq2iBStroMyZJJOFy 3AjHZg0EBsYMecc7JS34jXwNTreevwc= X-Google-Smtp-Source: AOwi7QBBA3NNa68qsMZ3aCjwjMHdCbcY/PTXrbIriEqThHvzoZSXuEL9mTBVi5D2jT7BF9Andeui/A== X-Received: by 10.84.171.195 with SMTP id l61mr9416084plb.64.1508174775593; Mon, 16 Oct 2017 10:26:15 -0700 (PDT) Received: from cloudburst.twiddle.net (97-126-104-76.tukw.qwest.net. [97.126.104.76]) by smtp.gmail.com with ESMTPSA id i187sm5594249pfc.96.2017.10.16.10.26.14 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 16 Oct 2017 10:26:14 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Mon, 16 Oct 2017 10:25:21 -0700 Message-Id: <20171016172609.23422-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171016172609.23422-1-richard.henderson@linaro.org> References: <20171016172609.23422-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c05::234 Subject: [Qemu-devel] [PATCH v6 02/50] tcg: Propagate args to op->args in optimizer 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: cota@braap.org, Richard Henderson Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson Reviewed-by: Alex BennĂ©e Signed-off-by: Richard Henderson --- tcg/optimize.c | 430 ++++++++++++++++++++++++++++++--------------------------- 1 file changed, 227 insertions(+), 203 deletions(-) -- 2.13.6 Reviewed-by: Emilio G. Cota diff --git a/tcg/optimize.c b/tcg/optimize.c index 002aad6bf4..1a1c6fb90c 100644 --- a/tcg/optimize.c +++ b/tcg/optimize.c @@ -166,8 +166,7 @@ static bool temps_are_copies(TCGArg arg1, TCGArg arg2) return false; } -static void tcg_opt_gen_movi(TCGContext *s, TCGOp *op, TCGArg *args, - TCGArg dst, TCGArg val) +static void tcg_opt_gen_movi(TCGContext *s, TCGOp *op, TCGArg dst, TCGArg val) { TCGOpcode new_op = op_to_movi(op->opc); tcg_target_ulong mask; @@ -184,12 +183,11 @@ static void tcg_opt_gen_movi(TCGContext *s, TCGOp *op, TCGArg *args, } temps[dst].mask = mask; - args[0] = dst; - args[1] = val; + op->args[0] = dst; + op->args[1] = val; } -static void tcg_opt_gen_mov(TCGContext *s, TCGOp *op, TCGArg *args, - TCGArg dst, TCGArg src) +static void tcg_opt_gen_mov(TCGContext *s, TCGOp *op, TCGArg dst, TCGArg src) { if (temps_are_copies(dst, src)) { tcg_op_remove(s, op); @@ -218,8 +216,8 @@ static void tcg_opt_gen_mov(TCGContext *s, TCGOp *op, TCGArg *args, temps[dst].val = temps[src].val; } - args[0] = dst; - args[1] = src; + op->args[0] = dst; + op->args[1] = src; } static TCGArg do_constant_folding_2(TCGOpcode op, TCGArg x, TCGArg y) @@ -559,7 +557,7 @@ static bool swap_commutative2(TCGArg *p1, TCGArg *p2) void tcg_optimize(TCGContext *s) { int oi, oi_next, nb_temps, nb_globals; - TCGArg *prev_mb_args = NULL; + TCGOp *prev_mb = NULL; /* Array VALS has an element for each temp. If this temp holds a constant then its value is kept in VALS' element. @@ -576,7 +574,6 @@ void tcg_optimize(TCGContext *s) TCGArg tmp; TCGOp * const op = &s->gen_op_buf[oi]; - TCGArg * const args = op->args; TCGOpcode opc = op->opc; const TCGOpDef *def = &tcg_op_defs[opc]; @@ -588,7 +585,7 @@ void tcg_optimize(TCGContext *s) nb_oargs = op->callo; nb_iargs = op->calli; for (i = 0; i < nb_oargs + nb_iargs; i++) { - tmp = args[i]; + tmp = op->args[i]; if (tmp != TCG_CALL_DUMMY_ARG) { init_temp_info(tmp); } @@ -597,14 +594,14 @@ void tcg_optimize(TCGContext *s) nb_oargs = def->nb_oargs; nb_iargs = def->nb_iargs; for (i = 0; i < nb_oargs + nb_iargs; i++) { - init_temp_info(args[i]); + init_temp_info(op->args[i]); } } /* Do copy propagation */ for (i = nb_oargs; i < nb_oargs + nb_iargs; i++) { - if (temp_is_copy(args[i])) { - args[i] = find_better_copy(s, args[i]); + if (temp_is_copy(op->args[i])) { + op->args[i] = find_better_copy(s, op->args[i]); } } @@ -620,45 +617,45 @@ void tcg_optimize(TCGContext *s) CASE_OP_32_64(nor): CASE_OP_32_64(muluh): CASE_OP_32_64(mulsh): - swap_commutative(args[0], &args[1], &args[2]); + swap_commutative(op->args[0], &op->args[1], &op->args[2]); break; CASE_OP_32_64(brcond): - if (swap_commutative(-1, &args[0], &args[1])) { - args[2] = tcg_swap_cond(args[2]); + if (swap_commutative(-1, &op->args[0], &op->args[1])) { + op->args[2] = tcg_swap_cond(op->args[2]); } break; CASE_OP_32_64(setcond): - if (swap_commutative(args[0], &args[1], &args[2])) { - args[3] = tcg_swap_cond(args[3]); + if (swap_commutative(op->args[0], &op->args[1], &op->args[2])) { + op->args[3] = tcg_swap_cond(op->args[3]); } break; CASE_OP_32_64(movcond): - if (swap_commutative(-1, &args[1], &args[2])) { - args[5] = tcg_swap_cond(args[5]); + if (swap_commutative(-1, &op->args[1], &op->args[2])) { + op->args[5] = tcg_swap_cond(op->args[5]); } /* For movcond, we canonicalize the "false" input reg to match the destination reg so that the tcg backend can implement a "move if true" operation. */ - if (swap_commutative(args[0], &args[4], &args[3])) { - args[5] = tcg_invert_cond(args[5]); + if (swap_commutative(op->args[0], &op->args[4], &op->args[3])) { + op->args[5] = tcg_invert_cond(op->args[5]); } break; CASE_OP_32_64(add2): - swap_commutative(args[0], &args[2], &args[4]); - swap_commutative(args[1], &args[3], &args[5]); + swap_commutative(op->args[0], &op->args[2], &op->args[4]); + swap_commutative(op->args[1], &op->args[3], &op->args[5]); break; CASE_OP_32_64(mulu2): CASE_OP_32_64(muls2): - swap_commutative(args[0], &args[2], &args[3]); + swap_commutative(op->args[0], &op->args[2], &op->args[3]); break; case INDEX_op_brcond2_i32: - if (swap_commutative2(&args[0], &args[2])) { - args[4] = tcg_swap_cond(args[4]); + if (swap_commutative2(&op->args[0], &op->args[2])) { + op->args[4] = tcg_swap_cond(op->args[4]); } break; case INDEX_op_setcond2_i32: - if (swap_commutative2(&args[1], &args[3])) { - args[5] = tcg_swap_cond(args[5]); + if (swap_commutative2(&op->args[1], &op->args[3])) { + op->args[5] = tcg_swap_cond(op->args[5]); } break; default: @@ -673,8 +670,8 @@ void tcg_optimize(TCGContext *s) CASE_OP_32_64(sar): CASE_OP_32_64(rotl): CASE_OP_32_64(rotr): - if (temp_is_const(args[1]) && temps[args[1]].val == 0) { - tcg_opt_gen_movi(s, op, args, args[0], 0); + if (temp_is_const(op->args[1]) && temps[op->args[1]].val == 0) { + tcg_opt_gen_movi(s, op, op->args[0], 0); continue; } break; @@ -683,7 +680,7 @@ void tcg_optimize(TCGContext *s) TCGOpcode neg_op; bool have_neg; - if (temp_is_const(args[2])) { + if (temp_is_const(op->args[2])) { /* Proceed with possible constant folding. */ break; } @@ -697,40 +694,45 @@ void tcg_optimize(TCGContext *s) if (!have_neg) { break; } - if (temp_is_const(args[1]) && temps[args[1]].val == 0) { + if (temp_is_const(op->args[1]) + && temps[op->args[1]].val == 0) { op->opc = neg_op; - reset_temp(args[0]); - args[1] = args[2]; + reset_temp(op->args[0]); + op->args[1] = op->args[2]; continue; } } break; CASE_OP_32_64(xor): CASE_OP_32_64(nand): - if (!temp_is_const(args[1]) - && temp_is_const(args[2]) && temps[args[2]].val == -1) { + if (!temp_is_const(op->args[1]) + && temp_is_const(op->args[2]) + && temps[op->args[2]].val == -1) { i = 1; goto try_not; } break; CASE_OP_32_64(nor): - if (!temp_is_const(args[1]) - && temp_is_const(args[2]) && temps[args[2]].val == 0) { + if (!temp_is_const(op->args[1]) + && temp_is_const(op->args[2]) + && temps[op->args[2]].val == 0) { i = 1; goto try_not; } break; CASE_OP_32_64(andc): - if (!temp_is_const(args[2]) - && temp_is_const(args[1]) && temps[args[1]].val == -1) { + if (!temp_is_const(op->args[2]) + && temp_is_const(op->args[1]) + && temps[op->args[1]].val == -1) { i = 2; goto try_not; } break; CASE_OP_32_64(orc): CASE_OP_32_64(eqv): - if (!temp_is_const(args[2]) - && temp_is_const(args[1]) && temps[args[1]].val == 0) { + if (!temp_is_const(op->args[2]) + && temp_is_const(op->args[1]) + && temps[op->args[1]].val == 0) { i = 2; goto try_not; } @@ -751,8 +753,8 @@ void tcg_optimize(TCGContext *s) break; } op->opc = not_op; - reset_temp(args[0]); - args[1] = args[i]; + reset_temp(op->args[0]); + op->args[1] = op->args[i]; continue; } default: @@ -771,18 +773,20 @@ void tcg_optimize(TCGContext *s) CASE_OP_32_64(or): CASE_OP_32_64(xor): CASE_OP_32_64(andc): - if (!temp_is_const(args[1]) - && temp_is_const(args[2]) && temps[args[2]].val == 0) { - tcg_opt_gen_mov(s, op, args, args[0], args[1]); + if (!temp_is_const(op->args[1]) + && temp_is_const(op->args[2]) + && temps[op->args[2]].val == 0) { + tcg_opt_gen_mov(s, op, op->args[0], op->args[1]); continue; } break; CASE_OP_32_64(and): CASE_OP_32_64(orc): CASE_OP_32_64(eqv): - if (!temp_is_const(args[1]) - && temp_is_const(args[2]) && temps[args[2]].val == -1) { - tcg_opt_gen_mov(s, op, args, args[0], args[1]); + if (!temp_is_const(op->args[1]) + && temp_is_const(op->args[2]) + && temps[op->args[2]].val == -1) { + tcg_opt_gen_mov(s, op, op->args[0], op->args[1]); continue; } break; @@ -796,21 +800,21 @@ void tcg_optimize(TCGContext *s) affected = -1; switch (opc) { CASE_OP_32_64(ext8s): - if ((temps[args[1]].mask & 0x80) != 0) { + if ((temps[op->args[1]].mask & 0x80) != 0) { break; } CASE_OP_32_64(ext8u): mask = 0xff; goto and_const; CASE_OP_32_64(ext16s): - if ((temps[args[1]].mask & 0x8000) != 0) { + if ((temps[op->args[1]].mask & 0x8000) != 0) { break; } CASE_OP_32_64(ext16u): mask = 0xffff; goto and_const; case INDEX_op_ext32s_i64: - if ((temps[args[1]].mask & 0x80000000) != 0) { + if ((temps[op->args[1]].mask & 0x80000000) != 0) { break; } case INDEX_op_ext32u_i64: @@ -818,110 +822,111 @@ void tcg_optimize(TCGContext *s) goto and_const; CASE_OP_32_64(and): - mask = temps[args[2]].mask; - if (temp_is_const(args[2])) { + mask = temps[op->args[2]].mask; + if (temp_is_const(op->args[2])) { and_const: - affected = temps[args[1]].mask & ~mask; + affected = temps[op->args[1]].mask & ~mask; } - mask = temps[args[1]].mask & mask; + mask = temps[op->args[1]].mask & mask; break; case INDEX_op_ext_i32_i64: - if ((temps[args[1]].mask & 0x80000000) != 0) { + if ((temps[op->args[1]].mask & 0x80000000) != 0) { break; } case INDEX_op_extu_i32_i64: /* We do not compute affected as it is a size changing op. */ - mask = (uint32_t)temps[args[1]].mask; + mask = (uint32_t)temps[op->args[1]].mask; break; CASE_OP_32_64(andc): /* Known-zeros does not imply known-ones. Therefore unless - args[2] is constant, we can't infer anything from it. */ - if (temp_is_const(args[2])) { - mask = ~temps[args[2]].mask; + op->args[2] is constant, we can't infer anything from it. */ + if (temp_is_const(op->args[2])) { + mask = ~temps[op->args[2]].mask; goto and_const; } - /* But we certainly know nothing outside args[1] may be set. */ - mask = temps[args[1]].mask; + /* But we certainly know nothing outside op->args[1] may be set. */ + mask = temps[op->args[1]].mask; break; case INDEX_op_sar_i32: - if (temp_is_const(args[2])) { - tmp = temps[args[2]].val & 31; - mask = (int32_t)temps[args[1]].mask >> tmp; + if (temp_is_const(op->args[2])) { + tmp = temps[op->args[2]].val & 31; + mask = (int32_t)temps[op->args[1]].mask >> tmp; } break; case INDEX_op_sar_i64: - if (temp_is_const(args[2])) { - tmp = temps[args[2]].val & 63; - mask = (int64_t)temps[args[1]].mask >> tmp; + if (temp_is_const(op->args[2])) { + tmp = temps[op->args[2]].val & 63; + mask = (int64_t)temps[op->args[1]].mask >> tmp; } break; case INDEX_op_shr_i32: - if (temp_is_const(args[2])) { - tmp = temps[args[2]].val & 31; - mask = (uint32_t)temps[args[1]].mask >> tmp; + if (temp_is_const(op->args[2])) { + tmp = temps[op->args[2]].val & 31; + mask = (uint32_t)temps[op->args[1]].mask >> tmp; } break; case INDEX_op_shr_i64: - if (temp_is_const(args[2])) { - tmp = temps[args[2]].val & 63; - mask = (uint64_t)temps[args[1]].mask >> tmp; + if (temp_is_const(op->args[2])) { + tmp = temps[op->args[2]].val & 63; + mask = (uint64_t)temps[op->args[1]].mask >> tmp; } break; case INDEX_op_extrl_i64_i32: - mask = (uint32_t)temps[args[1]].mask; + mask = (uint32_t)temps[op->args[1]].mask; break; case INDEX_op_extrh_i64_i32: - mask = (uint64_t)temps[args[1]].mask >> 32; + mask = (uint64_t)temps[op->args[1]].mask >> 32; break; CASE_OP_32_64(shl): - if (temp_is_const(args[2])) { - tmp = temps[args[2]].val & (TCG_TARGET_REG_BITS - 1); - mask = temps[args[1]].mask << tmp; + if (temp_is_const(op->args[2])) { + tmp = temps[op->args[2]].val & (TCG_TARGET_REG_BITS - 1); + mask = temps[op->args[1]].mask << tmp; } break; CASE_OP_32_64(neg): /* Set to 1 all bits to the left of the rightmost. */ - mask = -(temps[args[1]].mask & -temps[args[1]].mask); + mask = -(temps[op->args[1]].mask & -temps[op->args[1]].mask); break; CASE_OP_32_64(deposit): - mask = deposit64(temps[args[1]].mask, args[3], args[4], - temps[args[2]].mask); + mask = deposit64(temps[op->args[1]].mask, op->args[3], + op->args[4], temps[op->args[2]].mask); break; CASE_OP_32_64(extract): - mask = extract64(temps[args[1]].mask, args[2], args[3]); - if (args[2] == 0) { - affected = temps[args[1]].mask & ~mask; + mask = extract64(temps[op->args[1]].mask, op->args[2], op->args[3]); + if (op->args[2] == 0) { + affected = temps[op->args[1]].mask & ~mask; } break; CASE_OP_32_64(sextract): - mask = sextract64(temps[args[1]].mask, args[2], args[3]); - if (args[2] == 0 && (tcg_target_long)mask >= 0) { - affected = temps[args[1]].mask & ~mask; + mask = sextract64(temps[op->args[1]].mask, + op->args[2], op->args[3]); + if (op->args[2] == 0 && (tcg_target_long)mask >= 0) { + affected = temps[op->args[1]].mask & ~mask; } break; CASE_OP_32_64(or): CASE_OP_32_64(xor): - mask = temps[args[1]].mask | temps[args[2]].mask; + mask = temps[op->args[1]].mask | temps[op->args[2]].mask; break; case INDEX_op_clz_i32: case INDEX_op_ctz_i32: - mask = temps[args[2]].mask | 31; + mask = temps[op->args[2]].mask | 31; break; case INDEX_op_clz_i64: case INDEX_op_ctz_i64: - mask = temps[args[2]].mask | 63; + mask = temps[op->args[2]].mask | 63; break; case INDEX_op_ctpop_i32: @@ -937,7 +942,7 @@ void tcg_optimize(TCGContext *s) break; CASE_OP_32_64(movcond): - mask = temps[args[3]].mask | temps[args[4]].mask; + mask = temps[op->args[3]].mask | temps[op->args[4]].mask; break; CASE_OP_32_64(ld8u): @@ -952,7 +957,7 @@ void tcg_optimize(TCGContext *s) CASE_OP_32_64(qemu_ld): { - TCGMemOpIdx oi = args[nb_oargs + nb_iargs]; + TCGMemOpIdx oi = op->args[nb_oargs + nb_iargs]; TCGMemOp mop = get_memop(oi); if (!(mop & MO_SIGN)) { mask = (2ULL << ((8 << (mop & MO_SIZE)) - 1)) - 1; @@ -976,12 +981,12 @@ void tcg_optimize(TCGContext *s) if (partmask == 0) { tcg_debug_assert(nb_oargs == 1); - tcg_opt_gen_movi(s, op, args, args[0], 0); + tcg_opt_gen_movi(s, op, op->args[0], 0); continue; } if (affected == 0) { tcg_debug_assert(nb_oargs == 1); - tcg_opt_gen_mov(s, op, args, args[0], args[1]); + tcg_opt_gen_mov(s, op, op->args[0], op->args[1]); continue; } @@ -991,8 +996,8 @@ void tcg_optimize(TCGContext *s) CASE_OP_32_64(mul): CASE_OP_32_64(muluh): CASE_OP_32_64(mulsh): - if ((temp_is_const(args[2]) && temps[args[2]].val == 0)) { - tcg_opt_gen_movi(s, op, args, args[0], 0); + if ((temp_is_const(op->args[2]) && temps[op->args[2]].val == 0)) { + tcg_opt_gen_movi(s, op, op->args[0], 0); continue; } break; @@ -1004,8 +1009,8 @@ void tcg_optimize(TCGContext *s) switch (opc) { CASE_OP_32_64(or): CASE_OP_32_64(and): - if (temps_are_copies(args[1], args[2])) { - tcg_opt_gen_mov(s, op, args, args[0], args[1]); + if (temps_are_copies(op->args[1], op->args[2])) { + tcg_opt_gen_mov(s, op, op->args[0], op->args[1]); continue; } break; @@ -1018,8 +1023,8 @@ void tcg_optimize(TCGContext *s) CASE_OP_32_64(andc): CASE_OP_32_64(sub): CASE_OP_32_64(xor): - if (temps_are_copies(args[1], args[2])) { - tcg_opt_gen_movi(s, op, args, args[0], 0); + if (temps_are_copies(op->args[1], op->args[2])) { + tcg_opt_gen_movi(s, op, op->args[0], 0); continue; } break; @@ -1032,10 +1037,10 @@ void tcg_optimize(TCGContext *s) allocator where needed and possible. Also detect copies. */ switch (opc) { CASE_OP_32_64(mov): - tcg_opt_gen_mov(s, op, args, args[0], args[1]); + tcg_opt_gen_mov(s, op, op->args[0], op->args[1]); break; CASE_OP_32_64(movi): - tcg_opt_gen_movi(s, op, args, args[0], args[1]); + tcg_opt_gen_movi(s, op, op->args[0], op->args[1]); break; CASE_OP_32_64(not): @@ -1051,9 +1056,9 @@ void tcg_optimize(TCGContext *s) case INDEX_op_extu_i32_i64: case INDEX_op_extrl_i64_i32: case INDEX_op_extrh_i64_i32: - if (temp_is_const(args[1])) { - tmp = do_constant_folding(opc, temps[args[1]].val, 0); - tcg_opt_gen_movi(s, op, args, args[0], tmp); + if (temp_is_const(op->args[1])) { + tmp = do_constant_folding(opc, temps[op->args[1]].val, 0); + tcg_opt_gen_movi(s, op, op->args[0], tmp); break; } goto do_default; @@ -1080,68 +1085,72 @@ void tcg_optimize(TCGContext *s) CASE_OP_32_64(divu): CASE_OP_32_64(rem): CASE_OP_32_64(remu): - if (temp_is_const(args[1]) && temp_is_const(args[2])) { - tmp = do_constant_folding(opc, temps[args[1]].val, - temps[args[2]].val); - tcg_opt_gen_movi(s, op, args, args[0], tmp); + if (temp_is_const(op->args[1]) && temp_is_const(op->args[2])) { + tmp = do_constant_folding(opc, temps[op->args[1]].val, + temps[op->args[2]].val); + tcg_opt_gen_movi(s, op, op->args[0], tmp); break; } goto do_default; CASE_OP_32_64(clz): CASE_OP_32_64(ctz): - if (temp_is_const(args[1])) { - TCGArg v = temps[args[1]].val; + if (temp_is_const(op->args[1])) { + TCGArg v = temps[op->args[1]].val; if (v != 0) { tmp = do_constant_folding(opc, v, 0); - tcg_opt_gen_movi(s, op, args, args[0], tmp); + tcg_opt_gen_movi(s, op, op->args[0], tmp); } else { - tcg_opt_gen_mov(s, op, args, args[0], args[2]); + tcg_opt_gen_mov(s, op, op->args[0], op->args[2]); } break; } goto do_default; CASE_OP_32_64(deposit): - if (temp_is_const(args[1]) && temp_is_const(args[2])) { - tmp = deposit64(temps[args[1]].val, args[3], args[4], - temps[args[2]].val); - tcg_opt_gen_movi(s, op, args, args[0], tmp); + if (temp_is_const(op->args[1]) && temp_is_const(op->args[2])) { + tmp = deposit64(temps[op->args[1]].val, op->args[3], + op->args[4], temps[op->args[2]].val); + tcg_opt_gen_movi(s, op, op->args[0], tmp); break; } goto do_default; CASE_OP_32_64(extract): - if (temp_is_const(args[1])) { - tmp = extract64(temps[args[1]].val, args[2], args[3]); - tcg_opt_gen_movi(s, op, args, args[0], tmp); + if (temp_is_const(op->args[1])) { + tmp = extract64(temps[op->args[1]].val, + op->args[2], op->args[3]); + tcg_opt_gen_movi(s, op, op->args[0], tmp); break; } goto do_default; CASE_OP_32_64(sextract): - if (temp_is_const(args[1])) { - tmp = sextract64(temps[args[1]].val, args[2], args[3]); - tcg_opt_gen_movi(s, op, args, args[0], tmp); + if (temp_is_const(op->args[1])) { + tmp = sextract64(temps[op->args[1]].val, + op->args[2], op->args[3]); + tcg_opt_gen_movi(s, op, op->args[0], tmp); break; } goto do_default; CASE_OP_32_64(setcond): - tmp = do_constant_folding_cond(opc, args[1], args[2], args[3]); + tmp = do_constant_folding_cond(opc, op->args[1], + op->args[2], op->args[3]); if (tmp != 2) { - tcg_opt_gen_movi(s, op, args, args[0], tmp); + tcg_opt_gen_movi(s, op, op->args[0], tmp); break; } goto do_default; CASE_OP_32_64(brcond): - tmp = do_constant_folding_cond(opc, args[0], args[1], args[2]); + tmp = do_constant_folding_cond(opc, op->args[0], + op->args[1], op->args[2]); if (tmp != 2) { if (tmp) { reset_all_temps(nb_temps); op->opc = INDEX_op_br; - args[0] = args[3]; + op->args[0] = op->args[3]; } else { tcg_op_remove(s, op); } @@ -1150,21 +1159,22 @@ void tcg_optimize(TCGContext *s) goto do_default; CASE_OP_32_64(movcond): - tmp = do_constant_folding_cond(opc, args[1], args[2], args[5]); + tmp = do_constant_folding_cond(opc, op->args[1], + op->args[2], op->args[5]); if (tmp != 2) { - tcg_opt_gen_mov(s, op, args, args[0], args[4-tmp]); + tcg_opt_gen_mov(s, op, op->args[0], op->args[4-tmp]); break; } - if (temp_is_const(args[3]) && temp_is_const(args[4])) { - tcg_target_ulong tv = temps[args[3]].val; - tcg_target_ulong fv = temps[args[4]].val; - TCGCond cond = args[5]; + if (temp_is_const(op->args[3]) && temp_is_const(op->args[4])) { + tcg_target_ulong tv = temps[op->args[3]].val; + tcg_target_ulong fv = temps[op->args[4]].val; + TCGCond cond = op->args[5]; if (fv == 1 && tv == 0) { cond = tcg_invert_cond(cond); } else if (!(tv == 1 && fv == 0)) { goto do_default; } - args[3] = cond; + op->args[3] = cond; op->opc = opc = (opc == INDEX_op_movcond_i32 ? INDEX_op_setcond_i32 : INDEX_op_setcond_i64); @@ -1174,17 +1184,16 @@ void tcg_optimize(TCGContext *s) case INDEX_op_add2_i32: case INDEX_op_sub2_i32: - if (temp_is_const(args[2]) && temp_is_const(args[3]) - && temp_is_const(args[4]) && temp_is_const(args[5])) { - uint32_t al = temps[args[2]].val; - uint32_t ah = temps[args[3]].val; - uint32_t bl = temps[args[4]].val; - uint32_t bh = temps[args[5]].val; + if (temp_is_const(op->args[2]) && temp_is_const(op->args[3]) + && temp_is_const(op->args[4]) && temp_is_const(op->args[5])) { + uint32_t al = temps[op->args[2]].val; + uint32_t ah = temps[op->args[3]].val; + uint32_t bl = temps[op->args[4]].val; + uint32_t bh = temps[op->args[5]].val; uint64_t a = ((uint64_t)ah << 32) | al; uint64_t b = ((uint64_t)bh << 32) | bl; TCGArg rl, rh; TCGOp *op2 = tcg_op_insert_before(s, op, INDEX_op_movi_i32, 2); - TCGArg *args2 = op2->args; if (opc == INDEX_op_add2_i32) { a += b; @@ -1192,10 +1201,10 @@ void tcg_optimize(TCGContext *s) a -= b; } - rl = args[0]; - rh = args[1]; - tcg_opt_gen_movi(s, op, args, rl, (int32_t)a); - tcg_opt_gen_movi(s, op2, args2, rh, (int32_t)(a >> 32)); + rl = op->args[0]; + rh = op->args[1]; + tcg_opt_gen_movi(s, op, rl, (int32_t)a); + tcg_opt_gen_movi(s, op2, rh, (int32_t)(a >> 32)); /* We've done all we need to do with the movi. Skip it. */ oi_next = op2->next; @@ -1204,18 +1213,17 @@ void tcg_optimize(TCGContext *s) goto do_default; case INDEX_op_mulu2_i32: - if (temp_is_const(args[2]) && temp_is_const(args[3])) { - uint32_t a = temps[args[2]].val; - uint32_t b = temps[args[3]].val; + if (temp_is_const(op->args[2]) && temp_is_const(op->args[3])) { + uint32_t a = temps[op->args[2]].val; + uint32_t b = temps[op->args[3]].val; uint64_t r = (uint64_t)a * b; TCGArg rl, rh; TCGOp *op2 = tcg_op_insert_before(s, op, INDEX_op_movi_i32, 2); - TCGArg *args2 = op2->args; - rl = args[0]; - rh = args[1]; - tcg_opt_gen_movi(s, op, args, rl, (int32_t)r); - tcg_opt_gen_movi(s, op2, args2, rh, (int32_t)(r >> 32)); + rl = op->args[0]; + rh = op->args[1]; + tcg_opt_gen_movi(s, op, rl, (int32_t)r); + tcg_opt_gen_movi(s, op2, rh, (int32_t)(r >> 32)); /* We've done all we need to do with the movi. Skip it. */ oi_next = op2->next; @@ -1224,41 +1232,47 @@ void tcg_optimize(TCGContext *s) goto do_default; case INDEX_op_brcond2_i32: - tmp = do_constant_folding_cond2(&args[0], &args[2], args[4]); + tmp = do_constant_folding_cond2(&op->args[0], &op->args[2], + op->args[4]); if (tmp != 2) { if (tmp) { do_brcond_true: reset_all_temps(nb_temps); op->opc = INDEX_op_br; - args[0] = args[5]; + op->args[0] = op->args[5]; } else { do_brcond_false: tcg_op_remove(s, op); } - } else if ((args[4] == TCG_COND_LT || args[4] == TCG_COND_GE) - && temp_is_const(args[2]) && temps[args[2]].val == 0 - && temp_is_const(args[3]) && temps[args[3]].val == 0) { + } else if ((op->args[4] == TCG_COND_LT + || op->args[4] == TCG_COND_GE) + && temp_is_const(op->args[2]) + && temps[op->args[2]].val == 0 + && temp_is_const(op->args[3]) + && temps[op->args[3]].val == 0) { /* Simplify LT/GE comparisons vs zero to a single compare vs the high word of the input. */ do_brcond_high: reset_all_temps(nb_temps); op->opc = INDEX_op_brcond_i32; - args[0] = args[1]; - args[1] = args[3]; - args[2] = args[4]; - args[3] = args[5]; - } else if (args[4] == TCG_COND_EQ) { + op->args[0] = op->args[1]; + op->args[1] = op->args[3]; + op->args[2] = op->args[4]; + op->args[3] = op->args[5]; + } else if (op->args[4] == TCG_COND_EQ) { /* Simplify EQ comparisons where one of the pairs can be simplified. */ tmp = do_constant_folding_cond(INDEX_op_brcond_i32, - args[0], args[2], TCG_COND_EQ); + op->args[0], op->args[2], + TCG_COND_EQ); if (tmp == 0) { goto do_brcond_false; } else if (tmp == 1) { goto do_brcond_high; } tmp = do_constant_folding_cond(INDEX_op_brcond_i32, - args[1], args[3], TCG_COND_EQ); + op->args[1], op->args[3], + TCG_COND_EQ); if (tmp == 0) { goto do_brcond_false; } else if (tmp != 1) { @@ -1267,21 +1281,23 @@ void tcg_optimize(TCGContext *s) do_brcond_low: reset_all_temps(nb_temps); op->opc = INDEX_op_brcond_i32; - args[1] = args[2]; - args[2] = args[4]; - args[3] = args[5]; - } else if (args[4] == TCG_COND_NE) { + op->args[1] = op->args[2]; + op->args[2] = op->args[4]; + op->args[3] = op->args[5]; + } else if (op->args[4] == TCG_COND_NE) { /* Simplify NE comparisons where one of the pairs can be simplified. */ tmp = do_constant_folding_cond(INDEX_op_brcond_i32, - args[0], args[2], TCG_COND_NE); + op->args[0], op->args[2], + TCG_COND_NE); if (tmp == 0) { goto do_brcond_high; } else if (tmp == 1) { goto do_brcond_true; } tmp = do_constant_folding_cond(INDEX_op_brcond_i32, - args[1], args[3], TCG_COND_NE); + op->args[1], op->args[3], + TCG_COND_NE); if (tmp == 0) { goto do_brcond_low; } else if (tmp == 1) { @@ -1294,57 +1310,65 @@ void tcg_optimize(TCGContext *s) break; case INDEX_op_setcond2_i32: - tmp = do_constant_folding_cond2(&args[1], &args[3], args[5]); + tmp = do_constant_folding_cond2(&op->args[1], &op->args[3], + op->args[5]); if (tmp != 2) { do_setcond_const: - tcg_opt_gen_movi(s, op, args, args[0], tmp); - } else if ((args[5] == TCG_COND_LT || args[5] == TCG_COND_GE) - && temp_is_const(args[3]) && temps[args[3]].val == 0 - && temp_is_const(args[4]) && temps[args[4]].val == 0) { + tcg_opt_gen_movi(s, op, op->args[0], tmp); + } else if ((op->args[5] == TCG_COND_LT + || op->args[5] == TCG_COND_GE) + && temp_is_const(op->args[3]) + && temps[op->args[3]].val == 0 + && temp_is_const(op->args[4]) + && temps[op->args[4]].val == 0) { /* Simplify LT/GE comparisons vs zero to a single compare vs the high word of the input. */ do_setcond_high: - reset_temp(args[0]); - temps[args[0]].mask = 1; + reset_temp(op->args[0]); + temps[op->args[0]].mask = 1; op->opc = INDEX_op_setcond_i32; - args[1] = args[2]; - args[2] = args[4]; - args[3] = args[5]; - } else if (args[5] == TCG_COND_EQ) { + op->args[1] = op->args[2]; + op->args[2] = op->args[4]; + op->args[3] = op->args[5]; + } else if (op->args[5] == TCG_COND_EQ) { /* Simplify EQ comparisons where one of the pairs can be simplified. */ tmp = do_constant_folding_cond(INDEX_op_setcond_i32, - args[1], args[3], TCG_COND_EQ); + op->args[1], op->args[3], + TCG_COND_EQ); if (tmp == 0) { goto do_setcond_const; } else if (tmp == 1) { goto do_setcond_high; } tmp = do_constant_folding_cond(INDEX_op_setcond_i32, - args[2], args[4], TCG_COND_EQ); + op->args[2], op->args[4], + TCG_COND_EQ); if (tmp == 0) { goto do_setcond_high; } else if (tmp != 1) { goto do_default; } do_setcond_low: - reset_temp(args[0]); - temps[args[0]].mask = 1; + reset_temp(op->args[0]); + temps[op->args[0]].mask = 1; op->opc = INDEX_op_setcond_i32; - args[2] = args[3]; - args[3] = args[5]; - } else if (args[5] == TCG_COND_NE) { + op->args[2] = op->args[3]; + op->args[3] = op->args[5]; + } else if (op->args[5] == TCG_COND_NE) { /* Simplify NE comparisons where one of the pairs can be simplified. */ tmp = do_constant_folding_cond(INDEX_op_setcond_i32, - args[1], args[3], TCG_COND_NE); + op->args[1], op->args[3], + TCG_COND_NE); if (tmp == 0) { goto do_setcond_high; } else if (tmp == 1) { goto do_setcond_const; } tmp = do_constant_folding_cond(INDEX_op_setcond_i32, - args[2], args[4], TCG_COND_NE); + op->args[2], op->args[4], + TCG_COND_NE); if (tmp == 0) { goto do_setcond_low; } else if (tmp == 1) { @@ -1357,7 +1381,7 @@ void tcg_optimize(TCGContext *s) break; case INDEX_op_call: - if (!(args[nb_oargs + nb_iargs + 1] + if (!(op->args[nb_oargs + nb_iargs + 1] & (TCG_CALL_NO_READ_GLOBALS | TCG_CALL_NO_WRITE_GLOBALS))) { for (i = 0; i < nb_globals; i++) { if (test_bit(i, temps_used.l)) { @@ -1379,11 +1403,11 @@ void tcg_optimize(TCGContext *s) } else { do_reset_output: for (i = 0; i < nb_oargs; i++) { - reset_temp(args[i]); + reset_temp(op->args[i]); /* Save the corresponding known-zero bits mask for the first output argument (only one supported so far). */ if (i == 0) { - temps[args[i]].mask = mask; + temps[op->args[i]].mask = mask; } } } @@ -1391,7 +1415,7 @@ void tcg_optimize(TCGContext *s) } /* Eliminate duplicate and redundant fence instructions. */ - if (prev_mb_args) { + if (prev_mb) { switch (opc) { case INDEX_op_mb: /* Merge two barriers of the same type into one, @@ -1405,7 +1429,7 @@ void tcg_optimize(TCGContext *s) * barrier. This is stricter than specified but for * the purposes of TCG is better than not optimizing. */ - prev_mb_args[0] |= args[0]; + prev_mb->args[0] |= op->args[0]; tcg_op_remove(s, op); break; @@ -1421,11 +1445,11 @@ void tcg_optimize(TCGContext *s) case INDEX_op_qemu_st_i64: case INDEX_op_call: /* Opcodes that touch guest memory stop the optimization. */ - prev_mb_args = NULL; + prev_mb = NULL; break; } } else if (opc == INDEX_op_mb) { - prev_mb_args = args; + prev_mb = op; } } } From patchwork Mon Oct 16 17:25:22 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 115936 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp3938547qgn; Mon, 16 Oct 2017 10:32:01 -0700 (PDT) X-Received: by 10.237.35.76 with SMTP id i12mr14511584qtc.276.1508175121446; Mon, 16 Oct 2017 10:32:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508175121; cv=none; d=google.com; s=arc-20160816; b=ITU3rYGAyXaCBeAhkPTSjslWPI6PgQr02sB0HGjn0ERMlsGmn6lAIMJDAecvf6RaU4 55eYLjS0tQP/uY5zUsDfVUdFsacoow7awC96tLw/OtmVoIJsvI5xFrUu+8uETrPynNIX dTo8Mb7VPhhg4ZCoqKFkdpD0WblTopPPBtyr64JvbA8zbUYZ8tfEDlcxqsMtkouICAF6 ymr+apdfzRMoOeAB9KCduH3RE8VmhdCWd8g+cuZsXI5Ge6VXSQTTc5p2MfKY7HmSkpQz D9Er4Y76jxy4d0rXuXAR/9V2FXZcqjtWkFKU/CAU+5IHVM1ouqnKcE51RwRfhj7AzgsK u+Xw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=J0VE06SjkV92bZIVIfFBbcIdqedj3gEMQuhX7z2qXFQ=; b=mhMu9n1CZ/OoUJDjrzCwdILuyWHRvBH03HEHO9e5w+H5lLAlLUMPBrVMPMGGCrLZzB zoDcJf43+v5R6qXpkfYI9lohDV65IFC3Xrbvmj+Izb1T+OJNvJX3XpIVDV2cniJmmxx8 nJ0xizfvSckjzhtL9SiEO0jwt8BLi456UPAEtVBpwGDz4IOocYRD82W3HYWvS6XLjY2s doozQljEQUG7ebIJ0fdn49HwbqAiQxNkfiN4RTZR54geEP6ZPHI/jJvjjy6CPvBq97/q /lFARkWc3kjyTiWulCBCWPXrrCHmplbya/gRXcOpv7gDQ6MNFq0sLVG6oqtVj8d7nONc d/hw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=gSymsFJj; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id s45si2050725qtk.103.2017.10.16.10.32.00 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 16 Oct 2017 10:32:01 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=gSymsFJj; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:34319 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e49F9-0006t3-3w for patch@linaro.org; Mon, 16 Oct 2017 13:31:59 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52170) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e499h-0001sW-34 for qemu-devel@nongnu.org; Mon, 16 Oct 2017 13:26:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e499f-0003Fs-2M for qemu-devel@nongnu.org; Mon, 16 Oct 2017 13:26:21 -0400 Received: from mail-pg0-x22f.google.com ([2607:f8b0:400e:c05::22f]:46993) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e499e-0003Es-Pe for qemu-devel@nongnu.org; Mon, 16 Oct 2017 13:26:18 -0400 Received: by mail-pg0-x22f.google.com with SMTP id k7so7341617pga.3 for ; Mon, 16 Oct 2017 10:26:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=J0VE06SjkV92bZIVIfFBbcIdqedj3gEMQuhX7z2qXFQ=; b=gSymsFJj1Z1pm7t/6j7KEyBB7heWCgExHdxdkI2XxvG6PglJJphAl/XhVgmhYpS9D4 VK4N0oELybJpUvEptLGHVxSvpzQi9pwL0H31rCyrXWMMGFdNo/j+IPb7S+mK8u1k69Zh rFRC63am3eXkvgJam23gQFQ4cCHnLyO8P/jYs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=J0VE06SjkV92bZIVIfFBbcIdqedj3gEMQuhX7z2qXFQ=; b=iPs3qyLoK9NYwR7I4RrKE0/5t/TbP7mn3Xax3y9969rvPYZgxaGpXzFxRq7zrJOe9x KS+AHdszj/BkFtRIGaWx6fNcSOuwVCp8wssEMfxliFrW8zEXL8d3zHPcNk1S51tbvzx3 maSQdfHPqnA30jjywxh+JyqPeDHlZYt087L68/m6umxClKKrwmAHEY7WbxitMDKPkxOQ sGWFC4QpB6i32qu16/NfoT0yAUKhdDisoKGjSEbowicOLqDxMxRwS44pe+8WYjQGe2I6 7VpRM0r/6qEg8w1/ozyXhRgyfptd8HFgLvhmqrollo34vAhr1VXmmxXy0DC9zxEibXkP CdWw== X-Gm-Message-State: AMCzsaURGBN8r88fHEC175+ac2Rf7MhfGUmw94usHEj1VnFRxdTc3fgY WAOAn3WzJ9s+jR8ONmDBc82bCYvrczk= X-Google-Smtp-Source: AOwi7QAV9RyDUxw5S9JJGm0A/N/ovcsjJeixG14BUREB89Pd9in6O9WtS4vTNmpydM8tPAxh40JOKg== X-Received: by 10.159.208.2 with SMTP id a2mr9709124plp.370.1508174777078; Mon, 16 Oct 2017 10:26:17 -0700 (PDT) Received: from cloudburst.twiddle.net (97-126-104-76.tukw.qwest.net. [97.126.104.76]) by smtp.gmail.com with ESMTPSA id i187sm5594249pfc.96.2017.10.16.10.26.15 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 16 Oct 2017 10:26:16 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Mon, 16 Oct 2017 10:25:22 -0700 Message-Id: <20171016172609.23422-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171016172609.23422-1-richard.henderson@linaro.org> References: <20171016172609.23422-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c05::22f Subject: [Qemu-devel] [PATCH v6 03/50] tcg: Propagate args to op->args in tcg.c 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: cota@braap.org, Richard Henderson Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson Reviewed-by: Alex BennĂ©e Signed-off-by: Richard Henderson --- tcg/tcg.c | 121 ++++++++++++++++++++++++++++++-------------------------------- 1 file changed, 58 insertions(+), 63 deletions(-) -- 2.13.6 Reviewed-by: Emilio G. Cota diff --git a/tcg/tcg.c b/tcg/tcg.c index 98673f2190..4f56077f64 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -1277,14 +1277,12 @@ void tcg_dump_ops(TCGContext *s) for (oi = s->gen_op_buf[0].next; oi != 0; oi = op->next) { int i, k, nb_oargs, nb_iargs, nb_cargs; const TCGOpDef *def; - const TCGArg *args; TCGOpcode c; int col = 0; op = &s->gen_op_buf[oi]; c = op->opc; def = &tcg_op_defs[c]; - args = op->args; if (c == INDEX_op_insn_start) { col += qemu_log("%s ----", oi != s->gen_op_buf[0].next ? "\n" : ""); @@ -1292,9 +1290,9 @@ void tcg_dump_ops(TCGContext *s) for (i = 0; i < TARGET_INSN_START_WORDS; ++i) { target_ulong a; #if TARGET_LONG_BITS > TCG_TARGET_REG_BITS - a = ((target_ulong)args[i * 2 + 1] << 32) | args[i * 2]; + a = deposit64(op->args[i * 2], 32, 32, op->args[i * 2 + 1]); #else - a = args[i]; + a = op->args[i]; #endif col += qemu_log(" " TARGET_FMT_lx, a); } @@ -1306,14 +1304,14 @@ void tcg_dump_ops(TCGContext *s) /* function name, flags, out args */ col += qemu_log(" %s %s,$0x%" TCG_PRIlx ",$%d", def->name, - tcg_find_helper(s, args[nb_oargs + nb_iargs]), - args[nb_oargs + nb_iargs + 1], nb_oargs); + tcg_find_helper(s, op->args[nb_oargs + nb_iargs]), + op->args[nb_oargs + nb_iargs + 1], nb_oargs); for (i = 0; i < nb_oargs; i++) { col += qemu_log(",%s", tcg_get_arg_str_idx(s, buf, sizeof(buf), - args[i])); + op->args[i])); } for (i = 0; i < nb_iargs; i++) { - TCGArg arg = args[nb_oargs + i]; + TCGArg arg = op->args[nb_oargs + i]; const char *t = ""; if (arg != TCG_CALL_DUMMY_ARG) { t = tcg_get_arg_str_idx(s, buf, sizeof(buf), arg); @@ -1333,14 +1331,14 @@ void tcg_dump_ops(TCGContext *s) col += qemu_log(","); } col += qemu_log("%s", tcg_get_arg_str_idx(s, buf, sizeof(buf), - args[k++])); + op->args[k++])); } for (i = 0; i < nb_iargs; i++) { if (k != 0) { col += qemu_log(","); } col += qemu_log("%s", tcg_get_arg_str_idx(s, buf, sizeof(buf), - args[k++])); + op->args[k++])); } switch (c) { case INDEX_op_brcond_i32: @@ -1351,10 +1349,11 @@ void tcg_dump_ops(TCGContext *s) case INDEX_op_brcond_i64: case INDEX_op_setcond_i64: case INDEX_op_movcond_i64: - if (args[k] < ARRAY_SIZE(cond_name) && cond_name[args[k]]) { - col += qemu_log(",%s", cond_name[args[k++]]); + if (op->args[k] < ARRAY_SIZE(cond_name) + && cond_name[op->args[k]]) { + col += qemu_log(",%s", cond_name[op->args[k++]]); } else { - col += qemu_log(",$0x%" TCG_PRIlx, args[k++]); + col += qemu_log(",$0x%" TCG_PRIlx, op->args[k++]); } i = 1; break; @@ -1363,7 +1362,7 @@ void tcg_dump_ops(TCGContext *s) case INDEX_op_qemu_ld_i64: case INDEX_op_qemu_st_i64: { - TCGMemOpIdx oi = args[k++]; + TCGMemOpIdx oi = op->args[k++]; TCGMemOp op = get_memop(oi); unsigned ix = get_mmuidx(oi); @@ -1388,14 +1387,15 @@ void tcg_dump_ops(TCGContext *s) case INDEX_op_brcond_i32: case INDEX_op_brcond_i64: case INDEX_op_brcond2_i32: - col += qemu_log("%s$L%d", k ? "," : "", arg_label(args[k])->id); + col += qemu_log("%s$L%d", k ? "," : "", + arg_label(op->args[k])->id); i++, k++; break; default: break; } for (; i < nb_cargs; i++, k++) { - col += qemu_log("%s$0x%" TCG_PRIlx, k ? "," : "", args[k]); + col += qemu_log("%s$0x%" TCG_PRIlx, k ? "," : "", op->args[k]); } } if (op->life) { @@ -1656,7 +1656,6 @@ static void liveness_pass_1(TCGContext *s, uint8_t *temp_state) TCGArg arg; TCGOp * const op = &s->gen_op_buf[oi]; - TCGArg * const args = op->args; TCGOpcode opc = op->opc; const TCGOpDef *def = &tcg_op_defs[opc]; @@ -1669,12 +1668,12 @@ static void liveness_pass_1(TCGContext *s, uint8_t *temp_state) nb_oargs = op->callo; nb_iargs = op->calli; - call_flags = args[nb_oargs + nb_iargs + 1]; + call_flags = op->args[nb_oargs + nb_iargs + 1]; /* pure functions can be removed if their result is unused */ if (call_flags & TCG_CALL_NO_SIDE_EFFECTS) { for (i = 0; i < nb_oargs; i++) { - arg = args[i]; + arg = op->args[i]; if (temp_state[arg] != TS_DEAD) { goto do_not_remove_call; } @@ -1685,7 +1684,7 @@ static void liveness_pass_1(TCGContext *s, uint8_t *temp_state) /* output args are dead */ for (i = 0; i < nb_oargs; i++) { - arg = args[i]; + arg = op->args[i]; if (temp_state[arg] & TS_DEAD) { arg_life |= DEAD_ARG << i; } @@ -1708,7 +1707,7 @@ static void liveness_pass_1(TCGContext *s, uint8_t *temp_state) /* record arguments that die in this helper */ for (i = nb_oargs; i < nb_iargs + nb_oargs; i++) { - arg = args[i]; + arg = op->args[i]; if (arg != TCG_CALL_DUMMY_ARG) { if (temp_state[arg] & TS_DEAD) { arg_life |= DEAD_ARG << i; @@ -1717,7 +1716,7 @@ static void liveness_pass_1(TCGContext *s, uint8_t *temp_state) } /* input arguments are live for preceding opcodes */ for (i = nb_oargs; i < nb_iargs + nb_oargs; i++) { - arg = args[i]; + arg = op->args[i]; if (arg != TCG_CALL_DUMMY_ARG) { temp_state[arg] &= ~TS_DEAD; } @@ -1729,7 +1728,7 @@ static void liveness_pass_1(TCGContext *s, uint8_t *temp_state) break; case INDEX_op_discard: /* mark the temporary as dead */ - temp_state[args[0]] = TS_DEAD; + temp_state[op->args[0]] = TS_DEAD; break; case INDEX_op_add2_i32: @@ -1750,15 +1749,15 @@ static void liveness_pass_1(TCGContext *s, uint8_t *temp_state) the low part. The result can be optimized to a simple add or sub. This happens often for x86_64 guest when the cpu mode is set to 32 bit. */ - if (temp_state[args[1]] == TS_DEAD) { - if (temp_state[args[0]] == TS_DEAD) { + if (temp_state[op->args[1]] == TS_DEAD) { + if (temp_state[op->args[0]] == TS_DEAD) { goto do_remove; } /* Replace the opcode and adjust the args in place, leaving 3 unused args at the end. */ op->opc = opc = opc_new; - args[1] = args[2]; - args[2] = args[4]; + op->args[1] = op->args[2]; + op->args[2] = op->args[4]; /* Fall through and mark the single-word operation live. */ nb_iargs = 2; nb_oargs = 1; @@ -1788,21 +1787,21 @@ static void liveness_pass_1(TCGContext *s, uint8_t *temp_state) do_mul2: nb_iargs = 2; nb_oargs = 2; - if (temp_state[args[1]] == TS_DEAD) { - if (temp_state[args[0]] == TS_DEAD) { + if (temp_state[op->args[1]] == TS_DEAD) { + if (temp_state[op->args[0]] == TS_DEAD) { /* Both parts of the operation are dead. */ goto do_remove; } /* The high part of the operation is dead; generate the low. */ op->opc = opc = opc_new; - args[1] = args[2]; - args[2] = args[3]; - } else if (temp_state[args[0]] == TS_DEAD && have_opc_new2) { + op->args[1] = op->args[2]; + op->args[2] = op->args[3]; + } else if (temp_state[op->args[0]] == TS_DEAD && have_opc_new2) { /* The low part of the operation is dead; generate the high. */ op->opc = opc = opc_new2; - args[0] = args[1]; - args[1] = args[2]; - args[2] = args[3]; + op->args[0] = op->args[1]; + op->args[1] = op->args[2]; + op->args[2] = op->args[3]; } else { goto do_not_remove; } @@ -1820,7 +1819,7 @@ static void liveness_pass_1(TCGContext *s, uint8_t *temp_state) implies side effects */ if (!(def->flags & TCG_OPF_SIDE_EFFECTS) && nb_oargs != 0) { for (i = 0; i < nb_oargs; i++) { - if (temp_state[args[i]] != TS_DEAD) { + if (temp_state[op->args[i]] != TS_DEAD) { goto do_not_remove; } } @@ -1830,7 +1829,7 @@ static void liveness_pass_1(TCGContext *s, uint8_t *temp_state) do_not_remove: /* output args are dead */ for (i = 0; i < nb_oargs; i++) { - arg = args[i]; + arg = op->args[i]; if (temp_state[arg] & TS_DEAD) { arg_life |= DEAD_ARG << i; } @@ -1852,14 +1851,14 @@ static void liveness_pass_1(TCGContext *s, uint8_t *temp_state) /* record arguments that die in this opcode */ for (i = nb_oargs; i < nb_oargs + nb_iargs; i++) { - arg = args[i]; + arg = op->args[i]; if (temp_state[arg] & TS_DEAD) { arg_life |= DEAD_ARG << i; } } /* input arguments are live for preceding opcodes */ for (i = nb_oargs; i < nb_oargs + nb_iargs; i++) { - temp_state[args[i]] &= ~TS_DEAD; + temp_state[op->args[i]] &= ~TS_DEAD; } } break; @@ -1894,7 +1893,6 @@ static bool liveness_pass_2(TCGContext *s, uint8_t *temp_state) for (oi = s->gen_op_buf[0].next; oi != 0; oi = oi_next) { TCGOp *op = &s->gen_op_buf[oi]; - TCGArg *args = op->args; TCGOpcode opc = op->opc; const TCGOpDef *def = &tcg_op_defs[opc]; TCGLifeData arg_life = op->life; @@ -1906,7 +1904,7 @@ static bool liveness_pass_2(TCGContext *s, uint8_t *temp_state) if (opc == INDEX_op_call) { nb_oargs = op->callo; nb_iargs = op->calli; - call_flags = args[nb_oargs + nb_iargs + 1]; + call_flags = op->args[nb_oargs + nb_iargs + 1]; } else { nb_iargs = def->nb_iargs; nb_oargs = def->nb_oargs; @@ -1927,7 +1925,7 @@ static bool liveness_pass_2(TCGContext *s, uint8_t *temp_state) /* Make sure that input arguments are available. */ for (i = nb_oargs; i < nb_iargs + nb_oargs; i++) { - arg = args[i]; + arg = op->args[i]; /* Note this unsigned test catches TCG_CALL_ARG_DUMMY too. */ if (arg < nb_globals) { dir = dir_temps[arg]; @@ -1937,11 +1935,10 @@ static bool liveness_pass_2(TCGContext *s, uint8_t *temp_state) ? INDEX_op_ld_i32 : INDEX_op_ld_i64); TCGOp *lop = tcg_op_insert_before(s, op, lopc, 3); - TCGArg *largs = lop->args; - largs[0] = dir; - largs[1] = temp_idx(s, its->mem_base); - largs[2] = its->mem_offset; + lop->args[0] = dir; + lop->args[1] = temp_idx(s, its->mem_base); + lop->args[2] = its->mem_offset; /* Loaded, but synced with memory. */ temp_state[arg] = TS_MEM; @@ -1953,11 +1950,11 @@ static bool liveness_pass_2(TCGContext *s, uint8_t *temp_state) No action is required except keeping temp_state up to date so that we reload when needed. */ for (i = nb_oargs; i < nb_iargs + nb_oargs; i++) { - arg = args[i]; + arg = op->args[i]; if (arg < nb_globals) { dir = dir_temps[arg]; if (dir != 0) { - args[i] = dir; + op->args[i] = dir; changes = true; if (IS_DEAD_ARG(i)) { temp_state[arg] = TS_DEAD; @@ -1988,7 +1985,7 @@ static bool liveness_pass_2(TCGContext *s, uint8_t *temp_state) /* Outputs become available. */ for (i = 0; i < nb_oargs; i++) { - arg = args[i]; + arg = op->args[i]; if (arg >= nb_globals) { continue; } @@ -1996,7 +1993,7 @@ static bool liveness_pass_2(TCGContext *s, uint8_t *temp_state) if (dir == 0) { continue; } - args[i] = dir; + op->args[i] = dir; changes = true; /* The output is now live and modified. */ @@ -2009,11 +2006,10 @@ static bool liveness_pass_2(TCGContext *s, uint8_t *temp_state) ? INDEX_op_st_i32 : INDEX_op_st_i64); TCGOp *sop = tcg_op_insert_after(s, op, sopc, 3); - TCGArg *sargs = sop->args; - sargs[0] = dir; - sargs[1] = temp_idx(s, its->mem_base); - sargs[2] = its->mem_offset; + sop->args[0] = dir; + sop->args[1] = temp_idx(s, its->mem_base); + sop->args[2] = its->mem_offset; temp_state[arg] = TS_MEM; } @@ -2841,7 +2837,6 @@ int tcg_gen_code(TCGContext *s, TranslationBlock *tb) num_insns = -1; for (oi = s->gen_op_buf[0].next; oi != 0; oi = oi_next) { TCGOp * const op = &s->gen_op_buf[oi]; - TCGArg * const args = op->args; TCGOpcode opc = op->opc; const TCGOpDef *def = &tcg_op_defs[opc]; TCGLifeData arg_life = op->life; @@ -2854,11 +2849,11 @@ int tcg_gen_code(TCGContext *s, TranslationBlock *tb) switch (opc) { case INDEX_op_mov_i32: case INDEX_op_mov_i64: - tcg_reg_alloc_mov(s, def, args, arg_life); + tcg_reg_alloc_mov(s, def, op->args, arg_life); break; case INDEX_op_movi_i32: case INDEX_op_movi_i64: - tcg_reg_alloc_movi(s, args, arg_life); + tcg_reg_alloc_movi(s, op->args, arg_life); break; case INDEX_op_insn_start: if (num_insns >= 0) { @@ -2868,22 +2863,22 @@ int tcg_gen_code(TCGContext *s, TranslationBlock *tb) for (i = 0; i < TARGET_INSN_START_WORDS; ++i) { target_ulong a; #if TARGET_LONG_BITS > TCG_TARGET_REG_BITS - a = ((target_ulong)args[i * 2 + 1] << 32) | args[i * 2]; + a = deposit64(op->args[i * 2], 32, 32, op->args[i * 2 + 1]); #else - a = args[i]; + a = op->args[i]; #endif s->gen_insn_data[num_insns][i] = a; } break; case INDEX_op_discard: - temp_dead(s, &s->temps[args[0]]); + temp_dead(s, &s->temps[op->args[0]]); break; case INDEX_op_set_label: tcg_reg_alloc_bb_end(s, s->reserved_regs); - tcg_out_label(s, arg_label(args[0]), s->code_ptr); + tcg_out_label(s, arg_label(op->args[0]), s->code_ptr); break; case INDEX_op_call: - tcg_reg_alloc_call(s, op->callo, op->calli, args, arg_life); + tcg_reg_alloc_call(s, op->callo, op->calli, op->args, arg_life); break; default: /* Sanity check that we've not introduced any unhandled opcodes. */ @@ -2891,7 +2886,7 @@ int tcg_gen_code(TCGContext *s, TranslationBlock *tb) /* Note: in order to speed up the code, it would be much faster to have specialized register allocator functions for some common argument patterns */ - tcg_reg_alloc_op(s, def, opc, args, arg_life); + tcg_reg_alloc_op(s, def, opc, op->args, arg_life); break; } #ifdef CONFIG_DEBUG_TCG From patchwork Mon Oct 16 17:25:23 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 115931 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp3935910qgn; Mon, 16 Oct 2017 10:29:21 -0700 (PDT) X-Received: by 10.200.38.225 with SMTP id 30mr16358757qtp.334.1508174961593; Mon, 16 Oct 2017 10:29:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508174961; cv=none; d=google.com; s=arc-20160816; b=LkklHexSsE9JFQZrFZh12XWpaTGboKLck0pywaOwJh+kPJNvTofM1zIqr6kKqVY4sb ObBdcqn2ZVU1SIsccapKyykOIP+IRwAylCXujJDItJmdllzVMa5J3yQaoWNFs1Czzp08 goGireuex8nY1LNw0tBQAjHsYnxxE8sEYUTvZKag9WjbSiXfSUdQP8FtFDpNJrNodGWG YCE0ZteMVs4BbOvQQtKioCQB7jttYLHB8hzM+81og6Y+DEFB6u4cuo2fzuq8eSESkejm +dHH7ukEmq0X13c1xaYohFUeCluqF59j/Ax0qavbgijEUGtjd5vZxgCiUm0Wwy8P/oPz SNUQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=mupzlOYUAuyNywOnggVbrrdzIC7T3+eQFkWsnwKDReo=; b=Q0QYYeGXpzaTWThNHjSiMr2Q2bmgAmOugEyy9Cy9tUW4ErLYDKIt/6tFuU7t5NS8g0 x2xewgcjhcWLxtYs/PY+DphIibo3LHxit+B8YaDnzyLwduFyKZl+hBYeDg9wJhcWt1J4 wdRicPZPFjfL9YWu+m3T6N/X/nC0ze6aDAAC7jxt+x96Af7Pbg2njzXs8oJZMst5Z7mi YnaDgdbe8ulRJZU1fzK4rkSnOBs9KBSIznhdGGElwCfyL9FDCJko/GthRCbf2ZUESsKf Q1KwqaI8V6EUuLhN9ZsY3AnRnmcDAVY5pfWf1XscHq59jSYj7/jrTYTnoBQPRjGcCe38 GLDQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=fykog55G; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id h19si1414288qtk.307.2017.10.16.10.29.21 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 16 Oct 2017 10:29:21 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=fykog55G; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:34304 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e49CZ-0004Q5-Bo for patch@linaro.org; Mon, 16 Oct 2017 13:29:19 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52180) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e499h-0001ss-KN for qemu-devel@nongnu.org; Mon, 16 Oct 2017 13:26:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e499g-0003Gl-46 for qemu-devel@nongnu.org; Mon, 16 Oct 2017 13:26:21 -0400 Received: from mail-pf0-x22f.google.com ([2607:f8b0:400e:c00::22f]:45355) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e499f-0003GA-Rk for qemu-devel@nongnu.org; Mon, 16 Oct 2017 13:26:20 -0400 Received: by mail-pf0-x22f.google.com with SMTP id d28so16306527pfe.2 for ; Mon, 16 Oct 2017 10:26:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=mupzlOYUAuyNywOnggVbrrdzIC7T3+eQFkWsnwKDReo=; b=fykog55GnhboxY86I2Djd7qEQCM+I3+yIMD6ahDlWHuID0zEP1fBZmgZAH8Qe8P1qr p0OEfJIPCKRsgUZ5X5AI0rj6DtoUNUU3zisiMm6co/yB6ZZTKXIJNUpsCvrifFLRzHbV 7iZFQYzN7Fm09Uk64b0OnZzMO+7D/CICA/kGE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=mupzlOYUAuyNywOnggVbrrdzIC7T3+eQFkWsnwKDReo=; b=AqbiQYV4ziGJW3cxEmlEBTm8t1XJ0YtlFRnF6IOx76A58C/ori2A35EYEvg63OSRN1 TnGDJQ8EWxkhW9yHY82Yw9KGqLCf+6M37Dp0NQa0VtRG4mRJ0FtpB0wW/0yabk57DSBz oODcPNlu4G7e0r7bhcioXdRZ+JRyBju9Ybbd5oDBqF1+oAUh4YYwebWJJofFmKNcbabR G5BbH/rMmeHnsPQ52gpKEAKreEklL4829o/2xp/iHas5Rd/VhKQp1NfneevHwUMHs3Dd D8MyncM2XifJIJX0hzdjY2WlB2hAteknklvtG91vZUTdAWvMbkYgcTqhJ6gFWiouM5Fb 3Tbg== X-Gm-Message-State: AMCzsaUbQGMkWcw0gXyk874ih+qH9mEriLQeXuPXS7+n8rrc5ZvhJtSA fMN34SPxWcYGeXjH2PXav95qN4gY4DY= X-Google-Smtp-Source: AOwi7QAOMAxG3MRSzlAmWD+gqflHr+touUIKHNhDtT1OcwgVdXKIRrnmNzodxLYqSb/k8uIE+vtL1g== X-Received: by 10.159.208.5 with SMTP id a5mr9744896plp.436.1508174778543; Mon, 16 Oct 2017 10:26:18 -0700 (PDT) Received: from cloudburst.twiddle.net (97-126-104-76.tukw.qwest.net. [97.126.104.76]) by smtp.gmail.com with ESMTPSA id i187sm5594249pfc.96.2017.10.16.10.26.17 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 16 Oct 2017 10:26:17 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Mon, 16 Oct 2017 10:25:23 -0700 Message-Id: <20171016172609.23422-5-richard.henderson@linaro.org> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171016172609.23422-1-richard.henderson@linaro.org> References: <20171016172609.23422-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c00::22f Subject: [Qemu-devel] [PATCH v6 04/50] tcg: Propagate TCGOp down to allocators 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: cota@braap.org, Richard Henderson Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson Reviewed-by: Alex BennĂ©e Signed-off-by: Richard Henderson --- tcg/tcg.c | 78 ++++++++++++++++++++++++++++++++------------------------------- 1 file changed, 40 insertions(+), 38 deletions(-) -- 2.13.6 Reviewed-by: Emilio G. Cota diff --git a/tcg/tcg.c b/tcg/tcg.c index 4f56077f64..147b8904d8 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -2334,25 +2334,24 @@ static void tcg_reg_alloc_do_movi(TCGContext *s, TCGTemp *ots, } } -static void tcg_reg_alloc_movi(TCGContext *s, const TCGArg *args, - TCGLifeData arg_life) +static void tcg_reg_alloc_movi(TCGContext *s, const TCGOp *op) { - TCGTemp *ots = &s->temps[args[0]]; - tcg_target_ulong val = args[1]; + TCGTemp *ots = &s->temps[op->args[0]]; + tcg_target_ulong val = op->args[1]; - tcg_reg_alloc_do_movi(s, ots, val, arg_life); + tcg_reg_alloc_do_movi(s, ots, val, op->life); } -static void tcg_reg_alloc_mov(TCGContext *s, const TCGOpDef *def, - const TCGArg *args, TCGLifeData arg_life) +static void tcg_reg_alloc_mov(TCGContext *s, const TCGOp *op) { + const TCGLifeData arg_life = op->life; TCGRegSet allocated_regs; TCGTemp *ts, *ots; TCGType otype, itype; allocated_regs = s->reserved_regs; - ots = &s->temps[args[0]]; - ts = &s->temps[args[1]]; + ots = &s->temps[op->args[0]]; + ts = &s->temps[op->args[1]]; /* Note that otype != itype for no-op truncation. */ otype = ots->type; @@ -2382,7 +2381,7 @@ static void tcg_reg_alloc_mov(TCGContext *s, const TCGOpDef *def, liveness analysis disabled). */ tcg_debug_assert(NEED_SYNC_ARG(0)); if (!ots->mem_allocated) { - temp_allocate_frame(s, args[0]); + temp_allocate_frame(s, op->args[0]); } tcg_out_st(s, otype, ts->reg, ots->mem_base->reg, ots->mem_offset); if (IS_DEAD_ARG(1)) { @@ -2416,10 +2415,10 @@ static void tcg_reg_alloc_mov(TCGContext *s, const TCGOpDef *def, } } -static void tcg_reg_alloc_op(TCGContext *s, - const TCGOpDef *def, TCGOpcode opc, - const TCGArg *args, TCGLifeData arg_life) +static void tcg_reg_alloc_op(TCGContext *s, const TCGOp *op) { + const TCGLifeData arg_life = op->life; + const TCGOpDef * const def = &tcg_op_defs[op->opc]; TCGRegSet i_allocated_regs; TCGRegSet o_allocated_regs; int i, k, nb_iargs, nb_oargs; @@ -2430,21 +2429,24 @@ static void tcg_reg_alloc_op(TCGContext *s, TCGArg new_args[TCG_MAX_OP_ARGS]; int const_args[TCG_MAX_OP_ARGS]; + /* Sanity check that we've not introduced any unhandled opcodes. */ + tcg_debug_assert(!(def->flags & TCG_OPF_NOT_PRESENT)); + nb_oargs = def->nb_oargs; nb_iargs = def->nb_iargs; /* copy constants */ memcpy(new_args + nb_oargs + nb_iargs, - args + nb_oargs + nb_iargs, + op->args + nb_oargs + nb_iargs, sizeof(TCGArg) * def->nb_cargs); i_allocated_regs = s->reserved_regs; o_allocated_regs = s->reserved_regs; /* satisfy input constraints */ - for(k = 0; k < nb_iargs; k++) { + for (k = 0; k < nb_iargs; k++) { i = def->sorted_args[nb_oargs + k]; - arg = args[i]; + arg = op->args[i]; arg_ct = &def->args_ct[i]; ts = &s->temps[arg]; @@ -2462,7 +2464,7 @@ static void tcg_reg_alloc_op(TCGContext *s, if (ts->fixed_reg) { /* if fixed register, we must allocate a new register if the alias is not the same register */ - if (arg != args[arg_ct->alias_index]) + if (arg != op->args[arg_ct->alias_index]) goto allocate_in_reg; } else { /* if the input is aliased to an output and if it is @@ -2503,7 +2505,7 @@ static void tcg_reg_alloc_op(TCGContext *s, /* mark dead temporaries and free the associated registers */ for (i = nb_oargs; i < nb_oargs + nb_iargs; i++) { if (IS_DEAD_ARG(i)) { - temp_dead(s, &s->temps[args[i]]); + temp_dead(s, &s->temps[op->args[i]]); } } @@ -2527,7 +2529,7 @@ static void tcg_reg_alloc_op(TCGContext *s, /* satisfy the output constraints */ for(k = 0; k < nb_oargs; k++) { i = def->sorted_args[k]; - arg = args[i]; + arg = op->args[i]; arg_ct = &def->args_ct[i]; ts = &s->temps[arg]; if ((arg_ct->ct & TCG_CT_ALIAS) @@ -2566,11 +2568,11 @@ static void tcg_reg_alloc_op(TCGContext *s, } /* emit instruction */ - tcg_out_op(s, opc, new_args, const_args); + tcg_out_op(s, op->opc, new_args, const_args); /* move the outputs in the correct register if needed */ for(i = 0; i < nb_oargs; i++) { - ts = &s->temps[args[i]]; + ts = &s->temps[op->args[i]]; reg = new_args[i]; if (ts->fixed_reg && ts->reg != reg) { tcg_out_mov(s, ts->type, ts->reg, reg); @@ -2589,9 +2591,11 @@ static void tcg_reg_alloc_op(TCGContext *s, #define STACK_DIR(x) (x) #endif -static void tcg_reg_alloc_call(TCGContext *s, int nb_oargs, int nb_iargs, - const TCGArg * const args, TCGLifeData arg_life) +static void tcg_reg_alloc_call(TCGContext *s, TCGOp *op) { + const int nb_oargs = op->callo; + const int nb_iargs = op->calli; + const TCGLifeData arg_life = op->life; int flags, nb_regs, i; TCGReg reg; TCGArg arg; @@ -2602,8 +2606,8 @@ static void tcg_reg_alloc_call(TCGContext *s, int nb_oargs, int nb_iargs, int allocate_args; TCGRegSet allocated_regs; - func_addr = (tcg_insn_unit *)(intptr_t)args[nb_oargs + nb_iargs]; - flags = args[nb_oargs + nb_iargs + 1]; + func_addr = (tcg_insn_unit *)(intptr_t)op->args[nb_oargs + nb_iargs]; + flags = op->args[nb_oargs + nb_iargs + 1]; nb_regs = ARRAY_SIZE(tcg_target_call_iarg_regs); if (nb_regs > nb_iargs) { @@ -2622,8 +2626,8 @@ static void tcg_reg_alloc_call(TCGContext *s, int nb_oargs, int nb_iargs, } stack_offset = TCG_TARGET_CALL_STACK_OFFSET; - for(i = nb_regs; i < nb_iargs; i++) { - arg = args[nb_oargs + i]; + for (i = nb_regs; i < nb_iargs; i++) { + arg = op->args[nb_oargs + i]; #ifdef TCG_TARGET_STACK_GROWSUP stack_offset -= sizeof(tcg_target_long); #endif @@ -2640,8 +2644,8 @@ static void tcg_reg_alloc_call(TCGContext *s, int nb_oargs, int nb_iargs, /* assign input registers */ allocated_regs = s->reserved_regs; - for(i = 0; i < nb_regs; i++) { - arg = args[nb_oargs + i]; + for (i = 0; i < nb_regs; i++) { + arg = op->args[nb_oargs + i]; if (arg != TCG_CALL_DUMMY_ARG) { ts = &s->temps[arg]; reg = tcg_target_call_iarg_regs[i]; @@ -2663,9 +2667,9 @@ static void tcg_reg_alloc_call(TCGContext *s, int nb_oargs, int nb_iargs, } /* mark dead temporaries and free the associated registers */ - for(i = nb_oargs; i < nb_iargs + nb_oargs; i++) { + for (i = nb_oargs; i < nb_iargs + nb_oargs; i++) { if (IS_DEAD_ARG(i)) { - temp_dead(s, &s->temps[args[i]]); + temp_dead(s, &s->temps[op->args[i]]); } } @@ -2690,7 +2694,7 @@ static void tcg_reg_alloc_call(TCGContext *s, int nb_oargs, int nb_iargs, /* assign output registers and emit moves if needed */ for(i = 0; i < nb_oargs; i++) { - arg = args[i]; + arg = op->args[i]; ts = &s->temps[arg]; reg = tcg_target_call_oarg_regs[i]; tcg_debug_assert(s->reg_to_temp[reg] == NULL); @@ -2838,8 +2842,6 @@ int tcg_gen_code(TCGContext *s, TranslationBlock *tb) for (oi = s->gen_op_buf[0].next; oi != 0; oi = oi_next) { TCGOp * const op = &s->gen_op_buf[oi]; TCGOpcode opc = op->opc; - const TCGOpDef *def = &tcg_op_defs[opc]; - TCGLifeData arg_life = op->life; oi_next = op->next; #ifdef CONFIG_PROFILER @@ -2849,11 +2851,11 @@ int tcg_gen_code(TCGContext *s, TranslationBlock *tb) switch (opc) { case INDEX_op_mov_i32: case INDEX_op_mov_i64: - tcg_reg_alloc_mov(s, def, op->args, arg_life); + tcg_reg_alloc_mov(s, op); break; case INDEX_op_movi_i32: case INDEX_op_movi_i64: - tcg_reg_alloc_movi(s, op->args, arg_life); + tcg_reg_alloc_movi(s, op); break; case INDEX_op_insn_start: if (num_insns >= 0) { @@ -2878,7 +2880,7 @@ int tcg_gen_code(TCGContext *s, TranslationBlock *tb) tcg_out_label(s, arg_label(op->args[0]), s->code_ptr); break; case INDEX_op_call: - tcg_reg_alloc_call(s, op->callo, op->calli, op->args, arg_life); + tcg_reg_alloc_call(s, op); break; default: /* Sanity check that we've not introduced any unhandled opcodes. */ @@ -2886,7 +2888,7 @@ int tcg_gen_code(TCGContext *s, TranslationBlock *tb) /* Note: in order to speed up the code, it would be much faster to have specialized register allocator functions for some common argument patterns */ - tcg_reg_alloc_op(s, def, opc, op->args, arg_life); + tcg_reg_alloc_op(s, op); break; } #ifdef CONFIG_DEBUG_TCG From patchwork Mon Oct 16 17:25:24 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 115934 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp3937441qgn; Mon, 16 Oct 2017 10:30:55 -0700 (PDT) X-Received: by 10.200.8.53 with SMTP id u50mr16216325qth.260.1508175055637; Mon, 16 Oct 2017 10:30:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508175055; cv=none; d=google.com; s=arc-20160816; b=z5Oj7qPzrHgK6dFOgaUYrU0ch7MlIVu8kTMc3FBvT5e/Ryq1YCIFKuH13cDuOtPpTm hjKU8v0ukIRxuM1JEGvpx5YrGQwkdj6fi6ZUsL7YYUogZ3Ks1bHTmcWO/QfnL38rwHHV q5wf8SqMHgCGrz5GAoIROJ7bCmHTUtWrRuXV00vf1y39luVZ2i0SmL/Pn3w+zmpXblxl gal+EFYBslykxnyCb/Q+qqR6N7nq0/xNyZDovoSUy1W1eej/fIaiEm10ZNtN3HHr8aY8 KNbw6F2bpGCbFwCNasVd8VH8uuys4WLk3OpyQfxcibrNucsOE7J0bY1MwAPwuW1Aumv1 6x9A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=0UszrWK9b7RuCz6Zft7vjQg4i7roenA/raZAqnkCE30=; b=pPHAPdtJqd7QlOEuq7xg1KtFSZ70kznTCJ0MM8P+2jPqsxXXZdVmSlGy7dTAu1LMnh 0hz3d3b/ndcAJYZpEoWA3jGJcZL1DLLMmSD+TxMJfL9T/zG6TKDjqSDMpM091tNAX52R pmeToTalItQ+82oGpMtt8JRtHUfs/4pKH+wgQGzs0U28QZVK48LnDJfNe/XZ4wuMBVkM ASdRxU5ee1ERk27KyZQD0Wx6RlcdvDquwJfrxFZYl39NsX89vM3fS1xYVKCnotbcUGsK Hfp4zsPdBs7AtZq9/khswjP2Xrnjl8bBCJitUuwg/34lgnHzuaO987TuMAlWzWRqEZ59 x+1A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=hL/vbzM0; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id s37si7082420qth.165.2017.10.16.10.30.55 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 16 Oct 2017 10:30:55 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=hL/vbzM0; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:34312 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e49E5-0005mF-9c for patch@linaro.org; Mon, 16 Oct 2017 13:30:53 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52215) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e499j-0001ur-Oh for qemu-devel@nongnu.org; Mon, 16 Oct 2017 13:26:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e499h-0003IA-Ro for qemu-devel@nongnu.org; Mon, 16 Oct 2017 13:26:23 -0400 Received: from mail-pg0-x22c.google.com ([2607:f8b0:400e:c05::22c]:43971) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e499h-0003HZ-JK for qemu-devel@nongnu.org; Mon, 16 Oct 2017 13:26:21 -0400 Received: by mail-pg0-x22c.google.com with SMTP id s75so6499626pgs.0 for ; Mon, 16 Oct 2017 10:26:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=0UszrWK9b7RuCz6Zft7vjQg4i7roenA/raZAqnkCE30=; b=hL/vbzM0qEpCwl553fPyslO6IF+olsiIYe1hUihJm2LLss48gk5ppXVwvj8EUi8/0b tbdAAkLsSSZb45qB8XL+/EalYVWt1rayeePrOS9omuv/a7vjhLpYT6zWaspfvovOY1UF peFPbNR6KBZwXRgwy9PrbVQNG5cGiLH38tKXY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=0UszrWK9b7RuCz6Zft7vjQg4i7roenA/raZAqnkCE30=; b=NCy0Wnn2Df0m2vKifFXghfa8kZoWWrfICk9oPqIIHrACiBaxc42gHLOF8T+Q1aE8cp /1VDo6fs5WnPfeMccS7w0M5Ib5uZRDmwEKoEDp9a5hURO5gEV1bwxCQlrNcHGZGc1w7j g7NRHH/21lQMLy1EVTp0kyqso/A1dkx68woqr/HSoZEc9EnT50dbcRtLK6qqLxVfteQT 3cFMsYryZupFY4PU0MHipMA9KtDJ1sGBZGmCb/RRP7+KHM7weAZ6dZ5W0Kl8mjFiT5qR k0wDjjacgf5f8iwA6rrNv/XV8IGWNx7fbKTylV2N7sRxpjTM87oXaqvzjGa5aUjz6jrs flSw== X-Gm-Message-State: AMCzsaWh9sLjBQqubNcWKQBE+4qDoDkY/BPH9nT7t4MSB9Pq9TmdB6n9 pPH1OL0ioTFtIvyPodOv9i6Ijggv5Fo= X-Google-Smtp-Source: AOwi7QDhKZy9g873L+NIYL+vYF/D8Tg9gs6riB+z3WAPZYO1N3z8OMZWVpS+0Qxgxmb4Up9zEkh0/w== X-Received: by 10.101.65.198 with SMTP id b6mr8589504pgq.136.1508174780322; Mon, 16 Oct 2017 10:26:20 -0700 (PDT) Received: from cloudburst.twiddle.net (97-126-104-76.tukw.qwest.net. [97.126.104.76]) by smtp.gmail.com with ESMTPSA id i187sm5594249pfc.96.2017.10.16.10.26.18 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 16 Oct 2017 10:26:19 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Mon, 16 Oct 2017 10:25:24 -0700 Message-Id: <20171016172609.23422-6-richard.henderson@linaro.org> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171016172609.23422-1-richard.henderson@linaro.org> References: <20171016172609.23422-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c05::22c Subject: [Qemu-devel] [PATCH v6 05/50] 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: cota@braap.org, Richard Henderson Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson Reviewed-by: Alex BennĂ©e Signed-off-by: Richard Henderson --- tcg/tcg.h | 5 +++++ tcg/optimize.c | 4 ++-- tcg/tcg.c | 51 +++++++++++++++++++++++++-------------------------- 3 files changed, 32 insertions(+), 28 deletions(-) -- 2.13.6 Reviewed-by: Emilio G. Cota diff --git a/tcg/tcg.h b/tcg/tcg.h index 2cefd9f125..f06187fd8e 100644 --- a/tcg/tcg.h +++ b/tcg/tcg.h @@ -725,6 +725,11 @@ struct TCGContext { extern TCGContext tcg_ctx; extern bool parallel_cpus; +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] = v; diff --git a/tcg/optimize.c b/tcg/optimize.c index 1a1c6fb90c..d8c3a7ed56 100644 --- a/tcg/optimize.c +++ b/tcg/optimize.c @@ -133,7 +133,7 @@ static TCGArg find_better_copy(TCGContext *s, TCGArg temp) } /* If it is a temp, search for a temp local. */ - if (!s->temps[temp].temp_local) { + if (!arg_temp(temp)->temp_local) { for (i = temps[temp].next_copy ; i != temp ; i = temps[i].next_copy) { if (s->temps[i].temp_local) { return i; @@ -207,7 +207,7 @@ static void tcg_opt_gen_mov(TCGContext *s, TCGOp *op, TCGArg dst, TCGArg src) } temps[dst].mask = mask; - if (s->temps[src].type == s->temps[dst].type) { + if (arg_temp(src)->type == arg_temp(dst)->type) { temps[dst].next_copy = temps[src].next_copy; temps[dst].prev_copy = src; temps[temps[dst].next_copy].prev_copy = dst; diff --git a/tcg/tcg.c b/tcg/tcg.c index 147b8904d8..2704aa8a4d 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -1200,11 +1200,10 @@ static char *tcg_get_arg_str_ptr(TCGContext *s, char *buf, int buf_size, return buf; } -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 >= 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)); } /* Find helper name. */ @@ -1307,14 +1306,14 @@ void tcg_dump_ops(TCGContext *s) tcg_find_helper(s, op->args[nb_oargs + nb_iargs]), op->args[nb_oargs + nb_iargs + 1], nb_oargs); for (i = 0; i < nb_oargs; i++) { - col += qemu_log(",%s", tcg_get_arg_str_idx(s, buf, sizeof(buf), - op->args[i])); + col += qemu_log(",%s", tcg_get_arg_str(s, buf, sizeof(buf), + op->args[i])); } for (i = 0; i < nb_iargs; i++) { TCGArg arg = op->args[nb_oargs + i]; const char *t = ""; if (arg != TCG_CALL_DUMMY_ARG) { - t = tcg_get_arg_str_idx(s, buf, sizeof(buf), arg); + t = tcg_get_arg_str(s, buf, sizeof(buf), arg); } col += qemu_log(",%s", t); } @@ -1330,15 +1329,15 @@ void tcg_dump_ops(TCGContext *s) if (k != 0) { col += qemu_log(","); } - col += qemu_log("%s", tcg_get_arg_str_idx(s, buf, sizeof(buf), - op->args[k++])); + col += qemu_log("%s", tcg_get_arg_str(s, buf, sizeof(buf), + op->args[k++])); } for (i = 0; i < nb_iargs; i++) { if (k != 0) { col += qemu_log(","); } - col += qemu_log("%s", tcg_get_arg_str_idx(s, buf, sizeof(buf), - op->args[k++])); + col += qemu_log("%s", tcg_get_arg_str(s, buf, sizeof(buf), + op->args[k++])); } switch (c) { case INDEX_op_brcond_i32: @@ -1930,7 +1929,7 @@ static bool liveness_pass_2(TCGContext *s, uint8_t *temp_state) if (arg < nb_globals) { dir = dir_temps[arg]; if (dir != 0 && temp_state[arg] == TS_DEAD) { - TCGTemp *its = &s->temps[arg]; + TCGTemp *its = arg_temp(arg); TCGOpcode lopc = (its->type == TCG_TYPE_I32 ? INDEX_op_ld_i32 : INDEX_op_ld_i64); @@ -2001,7 +2000,7 @@ static bool liveness_pass_2(TCGContext *s, uint8_t *temp_state) /* Sync outputs upon their last write. */ if (NEED_SYNC_ARG(i)) { - TCGTemp *its = &s->temps[arg]; + TCGTemp *its = arg_temp(arg); TCGOpcode sopc = (its->type == TCG_TYPE_I32 ? INDEX_op_st_i32 : INDEX_op_st_i64); @@ -2032,7 +2031,7 @@ static void dump_regs(TCGContext *s) for(i = 0; i < s->nb_temps; i++) { ts = &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]); @@ -2336,7 +2335,7 @@ static void tcg_reg_alloc_do_movi(TCGContext *s, TCGTemp *ots, static void tcg_reg_alloc_movi(TCGContext *s, const TCGOp *op) { - TCGTemp *ots = &s->temps[op->args[0]]; + TCGTemp *ots = arg_temp(op->args[0]); tcg_target_ulong val = op->args[1]; tcg_reg_alloc_do_movi(s, ots, val, op->life); @@ -2350,8 +2349,8 @@ static void tcg_reg_alloc_mov(TCGContext *s, const TCGOp *op) TCGType otype, itype; allocated_regs = s->reserved_regs; - ots = &s->temps[op->args[0]]; - ts = &s->temps[op->args[1]]; + ots = arg_temp(op->args[0]); + ts = arg_temp(op->args[1]); /* Note that otype != itype for no-op truncation. */ otype = ots->type; @@ -2448,7 +2447,7 @@ static void tcg_reg_alloc_op(TCGContext *s, const TCGOp *op) i = def->sorted_args[nb_oargs + k]; arg = op->args[i]; arg_ct = &def->args_ct[i]; - ts = &s->temps[arg]; + ts = arg_temp(arg); if (ts->val_type == TEMP_VAL_CONST && tcg_target_const_match(ts->val, ts->type, arg_ct)) { @@ -2505,7 +2504,7 @@ static void tcg_reg_alloc_op(TCGContext *s, const TCGOp *op) /* mark dead temporaries and free the associated registers */ for (i = 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])); } } @@ -2531,7 +2530,7 @@ static void tcg_reg_alloc_op(TCGContext *s, const TCGOp *op) i = def->sorted_args[k]; arg = op->args[i]; arg_ct = &def->args_ct[i]; - ts = &s->temps[arg]; + ts = arg_temp(arg); if ((arg_ct->ct & TCG_CT_ALIAS) && !const_args[arg_ct->alias_index]) { reg = new_args[arg_ct->alias_index]; @@ -2572,7 +2571,7 @@ static void tcg_reg_alloc_op(TCGContext *s, const TCGOp *op) /* move the outputs in the correct register if needed */ for(i = 0; i < nb_oargs; i++) { - ts = &s->temps[op->args[i]]; + ts = arg_temp(op->args[i]); reg = new_args[i]; if (ts->fixed_reg && ts->reg != reg) { tcg_out_mov(s, ts->type, ts->reg, reg); @@ -2632,7 +2631,7 @@ static void tcg_reg_alloc_call(TCGContext *s, TCGOp *op) stack_offset -= sizeof(tcg_target_long); #endif if (arg != TCG_CALL_DUMMY_ARG) { - ts = &s->temps[arg]; + ts = 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_offset); @@ -2647,7 +2646,7 @@ static void tcg_reg_alloc_call(TCGContext *s, TCGOp *op) for (i = 0; i < nb_regs; i++) { arg = op->args[nb_oargs + i]; if (arg != TCG_CALL_DUMMY_ARG) { - ts = &s->temps[arg]; + ts = arg_temp(arg); reg = tcg_target_call_iarg_regs[i]; tcg_reg_free(s, reg, allocated_regs); @@ -2669,7 +2668,7 @@ static void tcg_reg_alloc_call(TCGContext *s, TCGOp *op) /* mark dead temporaries and free the associated registers */ for (i = 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])); } } @@ -2695,7 +2694,7 @@ static void tcg_reg_alloc_call(TCGContext *s, TCGOp *op) /* assign output registers and emit moves if needed */ for(i = 0; i < nb_oargs; i++) { arg = op->args[i]; - ts = &s->temps[arg]; + ts = arg_temp(arg); reg = tcg_target_call_oarg_regs[i]; tcg_debug_assert(s->reg_to_temp[reg] == NULL); @@ -2873,7 +2872,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); From patchwork Mon Oct 16 17:25:25 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 115941 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp3942355qgn; Mon, 16 Oct 2017 10:36:07 -0700 (PDT) X-Received: by 10.200.48.54 with SMTP id f51mr15354384qte.39.1508175367460; Mon, 16 Oct 2017 10:36:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508175367; cv=none; d=google.com; s=arc-20160816; b=iYn9vZWzAFnwUUpPxwipgTYuvSQTtksPyNfM4SrOXF80jbupGGC5pVYJ6uh7JHLXmc NkTY4ONYM0GutE2SceXTtTgwj23FW2W903GaGkjxrp+3he/A1OPXr+couJ2x0djjA3uq NV1eUDByIOoY/XQWeVi4u5hOmnyAEK9gHoRy9v4g/FxnkOShj90hGmc8NQbvq1TrruIm V6KQmsowWDAuDtys2lmhxh5MeTF8/klluJRbU3E6dDN3Fn4+tHF1+zLik83Hzb4r54vO BAdHp5YmzEEvlc6o3myuPSNUC7xRJajCzAvyZ0uMN5Vya68+DAuX3JgmGOoV5CA6eHkn 1LjQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=hZ9n6xXzAsKsql6NCKFLW4u7P6Isdp90YZ1xrlTByRg=; b=BV6c7fb3dE96A7kU3asA39ZjgdawXy6e5woS2v5/ysjipgBTxxfkHnEIOAfOa3W+Cp +cLNxpwDHxrXdeqw01Duw5Wdfztb/A03+xYESyjSDxREO+sNdF90eu/3uCwHsJgUwypj W1VCk0yJtF5842Zk80za2C1OZO0vJgwrMQA3xMZQ+Osjs3J+HhNPUAkq9qvAMBSN0Yje ncuNsHV76uWLk8XBepqqeMkX0IVvse2zjWmVl7gRUMzQw+LRjsoNjrQrWt+JJT2didyf cnie0dP2W7AfVGW1NDtmW6ISMqLmL4bINxZlqwx4bkyN1a8dPYkkGSDErW4tUkW0Xfeg /UWg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=DdhVIIKx; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id z10si2277428qth.292.2017.10.16.10.36.07 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 16 Oct 2017 10:36:07 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=DdhVIIKx; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:34334 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e49J7-0001qF-8V for patch@linaro.org; Mon, 16 Oct 2017 13:36:05 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52222) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e499k-0001vF-5v for qemu-devel@nongnu.org; Mon, 16 Oct 2017 13:26:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e499j-0003JY-2t for qemu-devel@nongnu.org; Mon, 16 Oct 2017 13:26:24 -0400 Received: from mail-pg0-x230.google.com ([2607:f8b0:400e:c05::230]:52538) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e499i-0003Ih-R8 for qemu-devel@nongnu.org; Mon, 16 Oct 2017 13:26:22 -0400 Received: by mail-pg0-x230.google.com with SMTP id a192so5918158pge.9 for ; Mon, 16 Oct 2017 10:26:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=hZ9n6xXzAsKsql6NCKFLW4u7P6Isdp90YZ1xrlTByRg=; b=DdhVIIKxjnRYNTVxlKH/SFJUyz8M13PoHN0gjVOitLyZDLs55d2w0KSf4ZpVT1QBzk h2hCbQiNVeaHcNmAaAcz1CXkk5fGJYyfPJhIF92EGQCeA0kHUyyFKWxzTW6dXhUmH08z sDEYdX82JnBuQbLchN8CylOxtqC09fE1xeN6k= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=hZ9n6xXzAsKsql6NCKFLW4u7P6Isdp90YZ1xrlTByRg=; b=pYiNT+w0Ri1lNQne947xB3juc5qXEleTElVafv2hDxEXi1gQvhwDf4lQfAZB6fOdgO 1iOmLhGDVu5CdxcEmnqLHnlliCwf6xbnf+4wcvRnTURZ5M5rQc39JBwOPnPZmTOGbBvd IdJoQG4bt1R3q9pDRWVOp1hf69TRfCP/cLvoEAvZS7+nKDjliuOD6cHDf3eiNk8OwdGV 4e+V1AtT71zLPDh2Rn0qRa+qwY/Z+gpX+sy7nJzWjEGNE8gbykEmMrXpbDFO7I6jh+6Y i78+pvWn317bEzdC9IUdMSBLGvOKHB2qc4Pao2QgRiU1TbWJ5px2Zi1EWrhRF7jXuTCd BC/A== X-Gm-Message-State: AMCzsaWtpSI0GXQ0J1rST2H5qxgLO8IRCUv0MdbfBFL4+UGhBfC93tYR +74JmGA7C0kx/mqs/AJwCVc7x3CdjSY= X-Google-Smtp-Source: AOwi7QCf2b6KijrvL/A9Sc+4aNKvJ9cL98drPqAsvDluDS4jmXjp2rOI4rourssXkNDbXkZ+P9jPKw== X-Received: by 10.99.9.193 with SMTP id 184mr8827440pgj.142.1508174781629; Mon, 16 Oct 2017 10:26:21 -0700 (PDT) Received: from cloudburst.twiddle.net (97-126-104-76.tukw.qwest.net. [97.126.104.76]) by smtp.gmail.com with ESMTPSA id i187sm5594249pfc.96.2017.10.16.10.26.20 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 16 Oct 2017 10:26:20 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Mon, 16 Oct 2017 10:25:25 -0700 Message-Id: <20171016172609.23422-7-richard.henderson@linaro.org> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171016172609.23422-1-richard.henderson@linaro.org> References: <20171016172609.23422-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c05::230 Subject: [Qemu-devel] [PATCH v6 06/50] tcg: Add temp_global bit to TCGTemp 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: cota@braap.org, Richard Henderson Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson This avoids needing to test the index of a temp against nb_globals. Signed-off-by: Richard Henderson --- tcg/tcg.h | 12 ++++++++---- tcg/optimize.c | 15 ++++++++------- tcg/tcg.c | 11 ++++++++--- 3 files changed, 24 insertions(+), 14 deletions(-) -- 2.13.6 Reviewed-by: Emilio G. Cota diff --git a/tcg/tcg.h b/tcg/tcg.h index f06187fd8e..fc4d1ed58b 100644 --- a/tcg/tcg.h +++ b/tcg/tcg.h @@ -579,10 +579,14 @@ typedef struct TCGTemp { unsigned int indirect_base:1; unsigned int mem_coherent:1; unsigned int mem_allocated:1; - unsigned int temp_local:1; /* If true, the temp is saved across - basic blocks. Otherwise, it is not - preserved across basic blocks. */ - unsigned int temp_allocated:1; /* never used for code gen */ + /* If true, the temp is saved across both basic blocks and + translation blocks. */ + unsigned int temp_global:1; + /* If true, the temp is saved across basic blocks but dead + at the end of translation blocks. If false, the temp is + dead at the end of basic blocks. */ + unsigned int temp_local:1; + unsigned int temp_allocated:1; tcg_target_long val; struct TCGTemp *mem_base; diff --git a/tcg/optimize.c b/tcg/optimize.c index d8c3a7ed56..55f9e83ce8 100644 --- a/tcg/optimize.c +++ b/tcg/optimize.c @@ -116,25 +116,26 @@ static TCGOpcode op_to_movi(TCGOpcode op) } } -static TCGArg find_better_copy(TCGContext *s, TCGArg temp) +static TCGArg find_better_copy(TCGContext *s, TCGArg arg) { + TCGTemp *ts = arg_temp(arg); TCGArg i; /* If this is already a global, we can't do better. */ - if (temp < s->nb_globals) { - return temp; + if (ts->temp_global) { + return arg; } /* Search for a global first. */ - for (i = temps[temp].next_copy ; i != temp ; i = temps[i].next_copy) { + for (i = temps[arg].next_copy ; i != arg; i = temps[i].next_copy) { if (i < s->nb_globals) { return i; } } /* If it is a temp, search for a temp local. */ - if (!arg_temp(temp)->temp_local) { - for (i = temps[temp].next_copy ; i != temp ; i = temps[i].next_copy) { + if (!ts->temp_local) { + for (i = temps[arg].next_copy ; i != arg; i = temps[i].next_copy) { if (s->temps[i].temp_local) { return i; } @@ -142,7 +143,7 @@ static TCGArg find_better_copy(TCGContext *s, TCGArg temp) } /* Failure to find a better representation, return the same temp. */ - return temp; + return arg; } static bool temps_are_copies(TCGArg arg1, TCGArg arg2) diff --git a/tcg/tcg.c b/tcg/tcg.c index 2704aa8a4d..915e041bea 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -489,9 +489,14 @@ static inline TCGTemp *tcg_temp_alloc(TCGContext *s) static inline TCGTemp *tcg_global_alloc(TCGContext *s) { + TCGTemp *ts; + tcg_debug_assert(s->nb_globals == s->nb_temps); s->nb_globals++; - return tcg_temp_alloc(s); + ts = tcg_temp_alloc(s); + ts->temp_global = 1; + + return ts; } static int tcg_global_reg_new_internal(TCGContext *s, TCGType type, @@ -1190,7 +1195,7 @@ static char *tcg_get_arg_str_ptr(TCGContext *s, char *buf, int buf_size, { int idx = temp_idx(s, ts); - if (idx < s->nb_globals) { + if (ts->temp_global) { pstrcpy(buf, buf_size, ts->name); } else if (ts->temp_local) { snprintf(buf, buf_size, "loc%d", idx - s->nb_globals); @@ -2128,7 +2133,7 @@ static void temp_free_or_dead(TCGContext *s, TCGTemp *ts, int free_or_dead) } ts->val_type = (free_or_dead < 0 || ts->temp_local - || temp_idx(s, ts) < s->nb_globals + || ts->temp_global ? TEMP_VAL_MEM : TEMP_VAL_DEAD); } From patchwork Mon Oct 16 17:25:26 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 115946 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp3944743qgn; Mon, 16 Oct 2017 10:38:54 -0700 (PDT) X-Received: by 10.55.220.2 with SMTP id v2mr15084868qki.64.1508175534716; Mon, 16 Oct 2017 10:38:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508175534; cv=none; d=google.com; s=arc-20160816; b=ULRLDGd4+7PnPqcfQTmmsiKwOv2gIYhazDHbqAtO7ASpcGxMck0tCbMcqq7kQvzXyF TVVfjN5cTww15PLIfKJ3UuasdHUPPmNUw1EluCVxeDumKC1VR9usbKTvdkmxCCposG+S 9HuuNN6RZxnilOdFCTLggAu49C+8riDkXH/8ojGIft7Q5SHSvKPBQFwemoKiau6VqeWG MoiN1vhbbfJ1SYgR5wPz3/9oIUhuc5mxEciX8iTPwwSdD7/SYYJdbQiAtht0i9Cv/nEb M3MGUHDXcsw8cIKmAZhJ05dlw0XMPvmsZohpM1KipMQBD1iwG8LboJb+HpgP6Fo+P3Vo Aheg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=n7xf7QNlSVj2bkYrPVOnOik/BWlhugDl/Dbkdra9CYA=; b=KmKt5xYhHl2hfB+p+re6pckWMO2fqyUjqVaym6DmIpjmwKmqkjEbg8oP2+xucqVK1Q vOiF3lcgunP5rcNbIFqqyBY+hBOCkPCKpivWPzPNCRwKTPdid8Isp0Q5QvhXErXBwgcE RTLlRKz47BF0KYxF0Tlx7koVdE+x+IpOAPOvj+NuNFvyXhlLu6Yqkdn2yvbRBzcfT9pD XbRMmvfBBQJm/79RpDQW6P+aroX1SJk5GmCyrA3tXyZGhZx0/fKHQ/AjN39+9lzSAAsZ rpv1WPYG24ii2PzSeNJs4WfG8P+LmL1Y8V4XcH2xhDbsXNQ1CfcVV0HESKKL3qALYLpY kZgg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=aSVIPAEl; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id m8si449750qti.319.2017.10.16.10.38.54 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 16 Oct 2017 10:38:54 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=aSVIPAEl; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:34343 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e49Lo-00047O-M8 for patch@linaro.org; Mon, 16 Oct 2017 13:38:52 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52265) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e499n-0001yQ-EP for qemu-devel@nongnu.org; Mon, 16 Oct 2017 13:26:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e499k-0003Kf-9t for qemu-devel@nongnu.org; Mon, 16 Oct 2017 13:26:27 -0400 Received: from mail-pg0-x230.google.com ([2607:f8b0:400e:c05::230]:51119) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e499k-0003K5-3u for qemu-devel@nongnu.org; Mon, 16 Oct 2017 13:26:24 -0400 Received: by mail-pg0-x230.google.com with SMTP id y7so7341944pgb.7 for ; Mon, 16 Oct 2017 10:26:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=n7xf7QNlSVj2bkYrPVOnOik/BWlhugDl/Dbkdra9CYA=; b=aSVIPAEl93KDWFL6gfB33q07nClULrkwCFLkmxdSf9Me3gHt4pgTuerj/+Jl36arWN xayPFyO9FoKMOQ8Q9Tt72WYT4fPfU37AhEz/oIcusJ6xSmTvTGMMCQRD5539dRA5K3/B 5vdY4wnTVy0tqnOZgFbL6vLlmea1AozQ4GZ6k= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=n7xf7QNlSVj2bkYrPVOnOik/BWlhugDl/Dbkdra9CYA=; b=HKRPSpaotnAC0M2Bg1I00v0dJfx9KO+LQfPFvWddKIyS1QFbji7C+1F1Aj79SesWG4 UhO+LBUcwQ0mRONyvloTR+1aBuRsYHS65zMnkPt++1m217Z1RAoGBcNgG1g3pJ0QZ1rg MVAQ/5kzLaoJXWKqGcM7fCV8/FJLujurK5qNIpGFYxTCJgJpL3eiHwxeikg3GsHKsqum ayDdmagFze4vkrL/SJ9kJ8YW92cPhQct9uif+K5Z87Pk4YtYjxq+KCNVRE4bU2KYAObl pm2Fdn/iH6tjZKUYczzYLs63rlPGJerhR7jY5j6/ehNjBh+R+ucJSJo4x2nx7ZsbQ+JV xA8A== X-Gm-Message-State: AMCzsaUEjI6XaI8PTyz8FjLwcB7GcZQ92loxXNWeliW71icJiY6lALaz 3tnDiWZR27yUdJdAEsm2kuNzx7r9oKc= X-Google-Smtp-Source: ABhQp+TyxYeggg1Of0s7DakJyojc0/1J5axie+KzV/2zoDpC2W+ywFb1ptZJvkYq8i9qU+3aXgosLw== X-Received: by 10.101.81.70 with SMTP id g6mr6364030pgq.97.1508174783018; Mon, 16 Oct 2017 10:26:23 -0700 (PDT) Received: from cloudburst.twiddle.net (97-126-104-76.tukw.qwest.net. [97.126.104.76]) by smtp.gmail.com with ESMTPSA id i187sm5594249pfc.96.2017.10.16.10.26.21 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 16 Oct 2017 10:26:21 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Mon, 16 Oct 2017 10:25:26 -0700 Message-Id: <20171016172609.23422-8-richard.henderson@linaro.org> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171016172609.23422-1-richard.henderson@linaro.org> References: <20171016172609.23422-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c05::230 Subject: [Qemu-devel] [PATCH v6 07/50] tcg: Return NULL temp for TCG_CALL_DUMMY_ARG 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: cota@braap.org, Richard Henderson Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson Signed-off-by: Richard Henderson --- tcg/tcg.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.13.6 Reviewed-by: Emilio G. Cota diff --git a/tcg/tcg.h b/tcg/tcg.h index fc4d1ed58b..5fcdec1fc5 100644 --- a/tcg/tcg.h +++ b/tcg/tcg.h @@ -731,7 +731,7 @@ extern bool parallel_cpus; static inline TCGTemp *arg_temp(TCGArg a) { - return &tcg_ctx.temps[a]; + return a == TCG_CALL_DUMMY_ARG ? NULL : &tcg_ctx.temps[a]; } static inline void tcg_set_insn_param(int op_idx, int arg, TCGArg v) From patchwork Mon Oct 16 17:25:27 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 115935 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp3938523qgn; Mon, 16 Oct 2017 10:31:59 -0700 (PDT) X-Received: by 10.55.186.196 with SMTP id k187mr8252249qkf.94.1508175119851; Mon, 16 Oct 2017 10:31:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508175119; cv=none; d=google.com; s=arc-20160816; b=K0NLUenHt+GtA+E2NmxPco21wnouy6dcxGkxUyJB1expHjvYE+SkiakltSRjm5pSy4 Wg40Jx6JTqbd7HAg79uY4MWP739jpZECo/XoiNHHdkesvDzzJLSbSbPzxrm5RT5BTMjN sXBvdpYKQICHhxiLsMY2iOhAI3VghcMYKEAoJQD5X22VtOBkyr6Eu7hLe2nmgGuTmHER PTwb5Yp3ZCtASOw2fq0mm5DgKOME/kyA94zA3/Jge+BETqYXY+LNpleVT01t69+fCEG6 hqQYAtqpGQD2tuU8WdsUqxUe/TzyZB2DXSLoPSb9kvoFCkw6jximo4y9n0hFVIQ6AAUu YGxw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=QjHyql3jVDRWJPR9yAKq1NOoZjivpNEciuPakz2ZW28=; b=KHgIkIQsUgnTDg1qfGzL1dkHKtGjS3BfDanr8xcFD79EwLpNlB9NlFzfpWjf2K92YR FCF3LGSvQDS36+Es8ThGiWpkr+TDwPU+1c5zmBarb6gtud+6JsKd804nqmOOAHCTbRrD 8kk4F5JYJiaUlOSRhqCOQ943sbLXh5Ac31YW2yakamqhcwlsZ0W0QAKpH95cngEcJv78 Bp9kpom14EahszvVqBrmW95ZCa1UYuzElWRLVkJMjx9S7ni8ds44cv53ylbgLAnh+APk 9stZwmiUHRa+us7Z2A1Nj4b4sb0CaPUpnSqfQCnd4kBL4wrgx6ApHOPUx0kw1TK6Df5H DMNw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=WFxTFTWd; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id 62si6785431qth.150.2017.10.16.10.31.59 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 16 Oct 2017 10:31:59 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=WFxTFTWd; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:34318 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e49F7-0006sJ-PQ for patch@linaro.org; Mon, 16 Oct 2017 13:31:57 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52266) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e499n-0001yR-Eb for qemu-devel@nongnu.org; Mon, 16 Oct 2017 13:26:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e499l-0003MN-Nn for qemu-devel@nongnu.org; Mon, 16 Oct 2017 13:26:27 -0400 Received: from mail-pg0-x22c.google.com ([2607:f8b0:400e:c05::22c]:55270) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e499l-0003LY-I2 for qemu-devel@nongnu.org; Mon, 16 Oct 2017 13:26:25 -0400 Received: by mail-pg0-x22c.google.com with SMTP id l24so7292738pgu.11 for ; Mon, 16 Oct 2017 10:26:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=QjHyql3jVDRWJPR9yAKq1NOoZjivpNEciuPakz2ZW28=; b=WFxTFTWd9RAaFmkv/Ht4gWBs7jCJ2iotQfyUWmlNuc0CeoII3VPtOG5OzF7+Kx8asT lymlyvQtlik+9rf7jYld9tONn6jFGQtovc9m0qG0n1AwchCkJec3OzeMoz8TCw4/Hz5Q /n3OLxbDpP+FXI40uV5nChGJdXFbt3ExH/Dfw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=QjHyql3jVDRWJPR9yAKq1NOoZjivpNEciuPakz2ZW28=; b=qswdHyykmuZVKbchDusVn5I283pCAQGhSZ0cuJ1K0zlY2bHBvKgC+1VcDbGlZ6U/f9 3pkgs7UVYH7SlHtfgG4BsEm0xL3dAA3g9vBhTlan4GHqSxU69aJ+3GdJqGptwNx7eBUZ fa2IWDgedoDDY6tH2qVEmAgoCf8VbfxPkQKssJMTzISVDPoMjQrTs01YSOr7yWo1/YrG DhQb+Bj1RSKhMS5fWmKFLmVC1SUTy/N3K5uN4bsD2kxz7OHClQfeApTCP3Ht4+GF/PfS A9JW8wA9Jl+RBZBPDTyZF24Zqq3DQ8uQO9rYpdRtwkBJH3s8Vv/kOFU7SuHDnjRf/bf1 Tmyw== X-Gm-Message-State: AMCzsaURqpdlRBAtTVq+TgqVSotbtI3hBnQ4WGgsTSyuANBmCuYxGod4 t1iCbjcESAUPixH4kp76Lwt8RsG3nVQ= X-Google-Smtp-Source: AOwi7QCyyFaXQdK40xY/wBFH3QRl6hr0djQkcxMN3UaqEuMh/4FRE/NZGb82HK4G+j1ZL5f0hPaoJw== X-Received: by 10.99.108.2 with SMTP id h2mr8877427pgc.362.1508174784405; Mon, 16 Oct 2017 10:26:24 -0700 (PDT) Received: from cloudburst.twiddle.net (97-126-104-76.tukw.qwest.net. [97.126.104.76]) by smtp.gmail.com with ESMTPSA id i187sm5594249pfc.96.2017.10.16.10.26.23 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 16 Oct 2017 10:26:23 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Mon, 16 Oct 2017 10:25:27 -0700 Message-Id: <20171016172609.23422-9-richard.henderson@linaro.org> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171016172609.23422-1-richard.henderson@linaro.org> References: <20171016172609.23422-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c05::22c Subject: [Qemu-devel] [PATCH v6 08/50] tcg: Introduce temp_arg 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: cota@braap.org, Richard Henderson Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson Signed-off-by: Richard Henderson --- tcg/tcg.h | 7 +++++++ tcg/tcg.c | 4 ++-- 2 files changed, 9 insertions(+), 2 deletions(-) -- 2.13.6 Reviewed-by: Emilio G. Cota diff --git a/tcg/tcg.h b/tcg/tcg.h index 5fcdec1fc5..1e456d8e5a 100644 --- a/tcg/tcg.h +++ b/tcg/tcg.h @@ -729,6 +729,13 @@ struct TCGContext { extern TCGContext tcg_ctx; extern bool parallel_cpus; +static inline TCGArg temp_arg(TCGTemp *ts) +{ + ptrdiff_t n = ts - tcg_ctx.temps; + tcg_debug_assert(n >= 0 && n < tcg_ctx.nb_temps); + return n; +} + static inline TCGTemp *arg_temp(TCGArg a) { return a == TCG_CALL_DUMMY_ARG ? NULL : &tcg_ctx.temps[a]; diff --git a/tcg/tcg.c b/tcg/tcg.c index 915e041bea..31279ab3bb 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -1941,7 +1941,7 @@ static bool liveness_pass_2(TCGContext *s, uint8_t *temp_state) TCGOp *lop = tcg_op_insert_before(s, op, lopc, 3); lop->args[0] = dir; - lop->args[1] = temp_idx(s, its->mem_base); + lop->args[1] = temp_arg(its->mem_base); lop->args[2] = its->mem_offset; /* Loaded, but synced with memory. */ @@ -2012,7 +2012,7 @@ static bool liveness_pass_2(TCGContext *s, uint8_t *temp_state) TCGOp *sop = tcg_op_insert_after(s, op, sopc, 3); sop->args[0] = dir; - sop->args[1] = temp_idx(s, its->mem_base); + sop->args[1] = temp_arg(its->mem_base); sop->args[2] = its->mem_offset; temp_state[arg] = TS_MEM; From patchwork Mon Oct 16 17:25:28 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 115933 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp3936246qgn; Mon, 16 Oct 2017 10:29:39 -0700 (PDT) X-Received: by 10.55.111.193 with SMTP id k184mr15571488qkc.244.1508174979760; Mon, 16 Oct 2017 10:29:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508174979; cv=none; d=google.com; s=arc-20160816; b=MThCAzc32YbsdpV1UkgczAsB42N4O2QBLXeyOUv3toJsgsU2sBmW5wK8CHVaix+nNr MgLJOFYUMElgL3DMs79djFFw4QqXrxRgbbxb2yEvhI+1IHKbOHUbJfCwtKHAyaa3BYj1 ix2FAbBG7przr5DlaZN52b4xTpVSdL2By6Fh13S+Y9j2P9BQDfzILo3bP47vCrASGkBt FSWoZAEP6KGEK5xhJjsuwFIiU/0lzYAUa6vuVSSpfhen7BLPbUivDMEePkAeaxCuhqHl huE3KrJ5n6c4LwLjtSN1wfZfdLYLCEO6bMEId+IYH86gXOqOdhGjiUfLYFI0j6WpDo0N +wfQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=BthD7adDxfSTuPawZcaG2N12Cto6BHTm8Wx4GL/AuUc=; b=OYLSK6tRTXjxODh8wEqPQcGiKHz1RqwqX99FSwNw7UWZTNlY1nCbbvd24H8tvRF0rV CrwtVMt0OB0PqSs6lEugm1suLkj3ZFJHcY7gmH+NsT2oXwjCjiWD399oD6i/PlKLgN+8 0YRqpFyKq8g82lQlUrzjYsvrOhI4zzM8M6mXrgKajzujGHenB1APaOf4JfygW5AEeyKY U9T0vw21dbTEHCDsx1T1v9Sewggr/yt1fwq6C2uwHADQz6fCpbzD/cqupvUXLQb0kN3A YSajNH4u7uyDIV1Uh8gPvYUS3pjSVmP0+NA/cwVThgK06bnN6GnNTQcZD51/WbKCdumx fP0w== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=ZOUefTwD; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id u23si3102743qtb.345.2017.10.16.10.29.39 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 16 Oct 2017 10:29:39 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=ZOUefTwD; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:34305 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e49Cr-0004pk-DQ for patch@linaro.org; Mon, 16 Oct 2017 13:29:37 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52291) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e499q-00021f-5O for qemu-devel@nongnu.org; Mon, 16 Oct 2017 13:26:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e499o-0003ON-0j for qemu-devel@nongnu.org; Mon, 16 Oct 2017 13:26:30 -0400 Received: from mail-pg0-x22a.google.com ([2607:f8b0:400e:c05::22a]:46994) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e499n-0003Ne-NT for qemu-devel@nongnu.org; Mon, 16 Oct 2017 13:26:27 -0400 Received: by mail-pg0-x22a.google.com with SMTP id k7so7341995pga.3 for ; Mon, 16 Oct 2017 10:26:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=BthD7adDxfSTuPawZcaG2N12Cto6BHTm8Wx4GL/AuUc=; b=ZOUefTwDkO5fVPRR44EGGfoJKP+8hsOow0+79sxso09ArrbBmH3HTJWnZb2QiaXFLU BcVdiREM0rqNQ6QDrBfkK263qbqdqBo2u1EfSvOIWzhSI0laJAqLQvFEcI32PyxvteGh 221NB5gnDPbFdLEpcEDCkmQRu5sZ9TeOwyFaI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=BthD7adDxfSTuPawZcaG2N12Cto6BHTm8Wx4GL/AuUc=; b=bjkzShWbK0fhW7eNBGMxSBPU9vVygdkAczb7qhT792wr2MOgz/pkSiMNj8AET+hFOH aHCJBA9SsKrxwUNFTV7auWZkCnTJ4odXomkoaf2cpcNq9TnIMaC7L58FWnY6gQ1byJnW dfGgLuBlwI3mPe3KHG0Y9KIKMkTQa88x7yegdd/lIVJIOnceAwIrAwDziSJW9gti5pJt LE/UFdWpvK+soSNia/hfu07nBf5qhASUI+PpwT/qnD/USvFL85W8o3fyRlurRYy9it+O o88jly6w9O9E68YwMc60DN+zE5LXA5UXdrXEQF6FVqQg9NQpfNgXvmietwO62UWpf+oq mLeQ== X-Gm-Message-State: AMCzsaXLYTbrKOltwrY8Xog1h3oSrWe6RTBjACiNoFiKbz/KEKBUVIiO rKf0CWERsGDPjYc7wSWWbcNnPwp/ucg= X-Google-Smtp-Source: AOwi7QB9Jvqd6HzJT5Xe8MZdrMGhD/vkLBQX+2zK0q/QwjoVhPHxqtSLBSzqr0xD9Me+KScv96biPA== X-Received: by 10.159.211.7 with SMTP id bc7mr9699977plb.425.1508174785957; Mon, 16 Oct 2017 10:26:25 -0700 (PDT) Received: from cloudburst.twiddle.net (97-126-104-76.tukw.qwest.net. [97.126.104.76]) by smtp.gmail.com with ESMTPSA id i187sm5594249pfc.96.2017.10.16.10.26.24 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 16 Oct 2017 10:26:24 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Mon, 16 Oct 2017 10:25:28 -0700 Message-Id: <20171016172609.23422-10-richard.henderson@linaro.org> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171016172609.23422-1-richard.henderson@linaro.org> References: <20171016172609.23422-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c05::22a Subject: [Qemu-devel] [PATCH v6 09/50] tcg: Use per-temp state data in liveness 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: cota@braap.org, Richard Henderson Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson This avoids having to allocate external memory for each temporary. Signed-off-by: Richard Henderson --- tcg/tcg.h | 6 ++ tcg/tcg.c | 225 ++++++++++++++++++++++++++++++++------------------------------ 2 files changed, 122 insertions(+), 109 deletions(-) -- 2.13.6 Reviewed-by: Emilio G. Cota diff --git a/tcg/tcg.h b/tcg/tcg.h index 1e456d8e5a..4352c0ee8c 100644 --- a/tcg/tcg.h +++ b/tcg/tcg.h @@ -592,6 +592,12 @@ typedef struct TCGTemp { struct TCGTemp *mem_base; intptr_t mem_offset; const char *name; + + /* Pass-specific information that can be stored for a temporary. + One word worth of integer data, and one pointer to data + allocated separately. */ + uintptr_t state; + void *state_ptr; } TCGTemp; typedef struct TCGContext TCGContext; diff --git a/tcg/tcg.c b/tcg/tcg.c index 31279ab3bb..719db9f2b6 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -1622,42 +1622,54 @@ TCGOp *tcg_op_insert_after(TCGContext *s, TCGOp *old_op, /* liveness analysis: end of function: all temps are dead, and globals should be in memory. */ -static inline void tcg_la_func_end(TCGContext *s, uint8_t *temp_state) +static void tcg_la_func_end(TCGContext *s) { - memset(temp_state, TS_DEAD | TS_MEM, s->nb_globals); - memset(temp_state + s->nb_globals, TS_DEAD, s->nb_temps - s->nb_globals); + int ng = s->nb_globals; + int nt = s->nb_temps; + int i; + + for (i = 0; i < ng; ++i) { + s->temps[i].state = TS_DEAD | TS_MEM; + } + for (i = ng; i < nt; ++i) { + s->temps[i].state = TS_DEAD; + } } /* liveness analysis: end of basic block: all temps are dead, globals and local temps should be in memory. */ -static inline void tcg_la_bb_end(TCGContext *s, uint8_t *temp_state) +static void tcg_la_bb_end(TCGContext *s) { - int i, n; + int ng = s->nb_globals; + int nt = s->nb_temps; + int i; - tcg_la_func_end(s, temp_state); - for (i = s->nb_globals, n = s->nb_temps; i < n; i++) { - if (s->temps[i].temp_local) { - temp_state[i] |= TS_MEM; - } + for (i = 0; i < ng; ++i) { + s->temps[i].state = TS_DEAD | TS_MEM; + } + for (i = ng; i < nt; ++i) { + s->temps[i].state = (s->temps[i].temp_local + ? TS_DEAD | TS_MEM + : TS_DEAD); } } /* Liveness analysis : update the opc_arg_life array to tell if a given input arguments is dead. Instructions updating dead temporaries are removed. */ -static void liveness_pass_1(TCGContext *s, uint8_t *temp_state) +static void liveness_pass_1(TCGContext *s) { int nb_globals = s->nb_globals; int oi, oi_prev; - tcg_la_func_end(s, temp_state); + tcg_la_func_end(s); for (oi = s->gen_op_buf[0].prev; oi != 0; oi = oi_prev) { int i, nb_iargs, nb_oargs; TCGOpcode opc_new, opc_new2; bool have_opc_new2; TCGLifeData arg_life = 0; - TCGArg arg; + TCGTemp *arg_ts; TCGOp * const op = &s->gen_op_buf[oi]; TCGOpcode opc = op->opc; @@ -1677,8 +1689,8 @@ static void liveness_pass_1(TCGContext *s, uint8_t *temp_state) /* pure functions can be removed if their result is unused */ if (call_flags & TCG_CALL_NO_SIDE_EFFECTS) { for (i = 0; i < nb_oargs; i++) { - arg = op->args[i]; - if (temp_state[arg] != TS_DEAD) { + arg_ts = arg_temp(op->args[i]); + if (arg_ts->state != TS_DEAD) { goto do_not_remove_call; } } @@ -1688,41 +1700,41 @@ static void liveness_pass_1(TCGContext *s, uint8_t *temp_state) /* output args are dead */ for (i = 0; i < nb_oargs; i++) { - arg = op->args[i]; - if (temp_state[arg] & TS_DEAD) { + arg_ts = arg_temp(op->args[i]); + if (arg_ts->state & TS_DEAD) { arg_life |= DEAD_ARG << i; } - if (temp_state[arg] & TS_MEM) { + if (arg_ts->state & TS_MEM) { arg_life |= SYNC_ARG << i; } - temp_state[arg] = TS_DEAD; + arg_ts->state = TS_DEAD; } if (!(call_flags & (TCG_CALL_NO_WRITE_GLOBALS | TCG_CALL_NO_READ_GLOBALS))) { /* globals should go back to memory */ - memset(temp_state, TS_DEAD | TS_MEM, nb_globals); + for (i = 0; i < nb_globals; i++) { + s->temps[i].state = TS_DEAD | TS_MEM; + } } else if (!(call_flags & TCG_CALL_NO_READ_GLOBALS)) { /* globals should be synced to memory */ for (i = 0; i < nb_globals; i++) { - temp_state[i] |= TS_MEM; + s->temps[i].state |= TS_MEM; } } /* record arguments that die in this helper */ for (i = nb_oargs; i < nb_iargs + nb_oargs; i++) { - arg = op->args[i]; - if (arg != TCG_CALL_DUMMY_ARG) { - if (temp_state[arg] & TS_DEAD) { - arg_life |= DEAD_ARG << i; - } + arg_ts = arg_temp(op->args[i]); + if (arg_ts && arg_ts->state & TS_DEAD) { + arg_life |= DEAD_ARG << i; } } /* input arguments are live for preceding opcodes */ for (i = nb_oargs; i < nb_iargs + nb_oargs; i++) { - arg = op->args[i]; - if (arg != TCG_CALL_DUMMY_ARG) { - temp_state[arg] &= ~TS_DEAD; + arg_ts = arg_temp(op->args[i]); + if (arg_ts) { + arg_ts->state &= ~TS_DEAD; } } } @@ -1732,7 +1744,7 @@ static void liveness_pass_1(TCGContext *s, uint8_t *temp_state) break; case INDEX_op_discard: /* mark the temporary as dead */ - temp_state[op->args[0]] = TS_DEAD; + arg_temp(op->args[0])->state = TS_DEAD; break; case INDEX_op_add2_i32: @@ -1753,8 +1765,8 @@ static void liveness_pass_1(TCGContext *s, uint8_t *temp_state) the low part. The result can be optimized to a simple add or sub. This happens often for x86_64 guest when the cpu mode is set to 32 bit. */ - if (temp_state[op->args[1]] == TS_DEAD) { - if (temp_state[op->args[0]] == TS_DEAD) { + if (arg_temp(op->args[1])->state == TS_DEAD) { + if (arg_temp(op->args[0])->state == TS_DEAD) { goto do_remove; } /* Replace the opcode and adjust the args in place, @@ -1791,8 +1803,8 @@ static void liveness_pass_1(TCGContext *s, uint8_t *temp_state) do_mul2: nb_iargs = 2; nb_oargs = 2; - if (temp_state[op->args[1]] == TS_DEAD) { - if (temp_state[op->args[0]] == TS_DEAD) { + if (arg_temp(op->args[1])->state == TS_DEAD) { + if (arg_temp(op->args[0])->state == TS_DEAD) { /* Both parts of the operation are dead. */ goto do_remove; } @@ -1800,7 +1812,7 @@ static void liveness_pass_1(TCGContext *s, uint8_t *temp_state) op->opc = opc = opc_new; op->args[1] = op->args[2]; op->args[2] = op->args[3]; - } else if (temp_state[op->args[0]] == TS_DEAD && have_opc_new2) { + } else if (arg_temp(op->args[0])->state == TS_DEAD && have_opc_new2) { /* The low part of the operation is dead; generate the high. */ op->opc = opc = opc_new2; op->args[0] = op->args[1]; @@ -1823,7 +1835,7 @@ static void liveness_pass_1(TCGContext *s, uint8_t *temp_state) implies side effects */ if (!(def->flags & TCG_OPF_SIDE_EFFECTS) && nb_oargs != 0) { for (i = 0; i < nb_oargs; i++) { - if (temp_state[op->args[i]] != TS_DEAD) { + if (arg_temp(op->args[i])->state != TS_DEAD) { goto do_not_remove; } } @@ -1833,36 +1845,36 @@ static void liveness_pass_1(TCGContext *s, uint8_t *temp_state) do_not_remove: /* output args are dead */ for (i = 0; i < nb_oargs; i++) { - arg = op->args[i]; - if (temp_state[arg] & TS_DEAD) { + arg_ts = arg_temp(op->args[i]); + if (arg_ts->state & TS_DEAD) { arg_life |= DEAD_ARG << i; } - if (temp_state[arg] & TS_MEM) { + if (arg_ts->state & TS_MEM) { arg_life |= SYNC_ARG << i; } - temp_state[arg] = TS_DEAD; + arg_ts->state = TS_DEAD; } /* if end of basic block, update */ if (def->flags & TCG_OPF_BB_END) { - tcg_la_bb_end(s, temp_state); + tcg_la_bb_end(s); } else if (def->flags & TCG_OPF_SIDE_EFFECTS) { /* globals should be synced to memory */ for (i = 0; i < nb_globals; i++) { - temp_state[i] |= TS_MEM; + s->temps[i].state |= TS_MEM; } } /* record arguments that die in this opcode */ for (i = nb_oargs; i < nb_oargs + nb_iargs; i++) { - arg = op->args[i]; - if (temp_state[arg] & TS_DEAD) { + arg_ts = arg_temp(op->args[i]); + if (arg_ts->state & TS_DEAD) { arg_life |= DEAD_ARG << i; } } /* input arguments are live for preceding opcodes */ for (i = nb_oargs; i < nb_oargs + nb_iargs; i++) { - temp_state[op->args[i]] &= ~TS_DEAD; + arg_temp(op->args[i])->state &= ~TS_DEAD; } } break; @@ -1872,16 +1884,12 @@ static void liveness_pass_1(TCGContext *s, uint8_t *temp_state) } /* Liveness analysis: Convert indirect regs to direct temporaries. */ -static bool liveness_pass_2(TCGContext *s, uint8_t *temp_state) +static bool liveness_pass_2(TCGContext *s) { int nb_globals = s->nb_globals; - int16_t *dir_temps; - int i, oi, oi_next; + int nb_temps, i, oi, oi_next; bool changes = false; - dir_temps = tcg_malloc(nb_globals * sizeof(int16_t)); - memset(dir_temps, 0, nb_globals * sizeof(int16_t)); - /* Create a temporary for each indirect global. */ for (i = 0; i < nb_globals; ++i) { TCGTemp *its = &s->temps[i]; @@ -1889,11 +1897,18 @@ static bool liveness_pass_2(TCGContext *s, uint8_t *temp_state) TCGTemp *dts = tcg_temp_alloc(s); dts->type = its->type; dts->base_type = its->base_type; - dir_temps[i] = temp_idx(s, dts); + its->state_ptr = dts; + } else { + its->state_ptr = NULL; } + /* All globals begin dead. */ + its->state = TS_DEAD; + } + for (nb_temps = s->nb_temps; i < nb_temps; ++i) { + TCGTemp *its = &s->temps[i]; + its->state_ptr = NULL; + its->state = TS_DEAD; } - - memset(temp_state, TS_DEAD, nb_globals); for (oi = s->gen_op_buf[0].next; oi != 0; oi = oi_next) { TCGOp *op = &s->gen_op_buf[oi]; @@ -1901,7 +1916,7 @@ static bool liveness_pass_2(TCGContext *s, uint8_t *temp_state) const TCGOpDef *def = &tcg_op_defs[opc]; TCGLifeData arg_life = op->life; int nb_iargs, nb_oargs, call_flags; - TCGArg arg, dir; + TCGTemp *arg_ts, *dir_ts; oi_next = op->next; @@ -1929,23 +1944,21 @@ static bool liveness_pass_2(TCGContext *s, uint8_t *temp_state) /* Make sure that input arguments are available. */ for (i = nb_oargs; i < nb_iargs + nb_oargs; i++) { - arg = op->args[i]; - /* Note this unsigned test catches TCG_CALL_ARG_DUMMY too. */ - if (arg < nb_globals) { - dir = dir_temps[arg]; - if (dir != 0 && temp_state[arg] == TS_DEAD) { - TCGTemp *its = arg_temp(arg); - TCGOpcode lopc = (its->type == TCG_TYPE_I32 + arg_ts = arg_temp(op->args[i]); + if (arg_ts) { + dir_ts = arg_ts->state_ptr; + if (dir_ts && arg_ts->state == TS_DEAD) { + TCGOpcode lopc = (arg_ts->type == TCG_TYPE_I32 ? INDEX_op_ld_i32 : INDEX_op_ld_i64); TCGOp *lop = tcg_op_insert_before(s, op, lopc, 3); - lop->args[0] = dir; - lop->args[1] = temp_arg(its->mem_base); - lop->args[2] = its->mem_offset; + lop->args[0] = temp_arg(dir_ts); + lop->args[1] = temp_arg(arg_ts->mem_base); + lop->args[2] = arg_ts->mem_offset; /* Loaded, but synced with memory. */ - temp_state[arg] = TS_MEM; + arg_ts->state = TS_MEM; } } } @@ -1954,14 +1967,14 @@ static bool liveness_pass_2(TCGContext *s, uint8_t *temp_state) No action is required except keeping temp_state up to date so that we reload when needed. */ for (i = nb_oargs; i < nb_iargs + nb_oargs; i++) { - arg = op->args[i]; - if (arg < nb_globals) { - dir = dir_temps[arg]; - if (dir != 0) { - op->args[i] = dir; + arg_ts = arg_temp(op->args[i]); + if (arg_ts) { + dir_ts = arg_ts->state_ptr; + if (dir_ts) { + op->args[i] = temp_arg(dir_ts); changes = true; if (IS_DEAD_ARG(i)) { - temp_state[arg] = TS_DEAD; + arg_ts->state = TS_DEAD; } } } @@ -1975,51 +1988,49 @@ static bool liveness_pass_2(TCGContext *s, uint8_t *temp_state) for (i = 0; i < nb_globals; ++i) { /* Liveness should see that globals are synced back, that is, either TS_DEAD or TS_MEM. */ - tcg_debug_assert(dir_temps[i] == 0 - || temp_state[i] != 0); + arg_ts = &s->temps[i]; + tcg_debug_assert(arg_ts->state_ptr == 0 + || arg_ts->state != 0); } } else { for (i = 0; i < nb_globals; ++i) { /* Liveness should see that globals are saved back, that is, TS_DEAD, waiting to be reloaded. */ - tcg_debug_assert(dir_temps[i] == 0 - || temp_state[i] == TS_DEAD); + arg_ts = &s->temps[i]; + tcg_debug_assert(arg_ts->state_ptr == 0 + || arg_ts->state == TS_DEAD); } } /* Outputs become available. */ for (i = 0; i < nb_oargs; i++) { - arg = op->args[i]; - if (arg >= nb_globals) { + arg_ts = arg_temp(op->args[i]); + dir_ts = arg_ts->state_ptr; + if (!dir_ts) { continue; } - dir = dir_temps[arg]; - if (dir == 0) { - continue; - } - op->args[i] = dir; + op->args[i] = temp_arg(dir_ts); changes = true; /* The output is now live and modified. */ - temp_state[arg] = 0; + arg_ts->state = 0; /* Sync outputs upon their last write. */ if (NEED_SYNC_ARG(i)) { - TCGTemp *its = arg_temp(arg); - TCGOpcode sopc = (its->type == TCG_TYPE_I32 + TCGOpcode sopc = (arg_ts->type == TCG_TYPE_I32 ? INDEX_op_st_i32 : INDEX_op_st_i64); TCGOp *sop = tcg_op_insert_after(s, op, sopc, 3); - sop->args[0] = dir; - sop->args[1] = temp_arg(its->mem_base); - sop->args[2] = its->mem_offset; + sop->args[0] = temp_arg(dir_ts); + sop->args[1] = temp_arg(arg_ts->mem_base); + sop->args[2] = arg_ts->mem_offset; - temp_state[arg] = TS_MEM; + arg_ts->state = TS_MEM; } /* Drop outputs that are dead. */ if (IS_DEAD_ARG(i)) { - temp_state[arg] = TS_DEAD; + arg_ts->state = TS_DEAD; } } } @@ -2791,27 +2802,23 @@ int tcg_gen_code(TCGContext *s, TranslationBlock *tb) s->la_time -= profile_getclock(); #endif - { - uint8_t *temp_state = tcg_malloc(s->nb_temps + s->nb_indirects); - - liveness_pass_1(s, temp_state); + liveness_pass_1(s); - if (s->nb_indirects > 0) { + if (s->nb_indirects > 0) { #ifdef DEBUG_DISAS - if (unlikely(qemu_loglevel_mask(CPU_LOG_TB_OP_IND) - && qemu_log_in_addr_range(tb->pc))) { - qemu_log_lock(); - qemu_log("OP before indirect lowering:\n"); - tcg_dump_ops(s); - qemu_log("\n"); - qemu_log_unlock(); - } + if (unlikely(qemu_loglevel_mask(CPU_LOG_TB_OP_IND) + && qemu_log_in_addr_range(tb->pc))) { + qemu_log_lock(); + qemu_log("OP before indirect lowering:\n"); + tcg_dump_ops(s); + qemu_log("\n"); + qemu_log_unlock(); + } #endif - /* Replace indirect temps with direct temps. */ - if (liveness_pass_2(s, temp_state)) { - /* If changes were made, re-run liveness. */ - liveness_pass_1(s, temp_state); - } + /* Replace indirect temps with direct temps. */ + if (liveness_pass_2(s)) { + /* If changes were made, re-run liveness. */ + liveness_pass_1(s); } } From patchwork Mon Oct 16 17:25:29 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 115949 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp3946964qgn; Mon, 16 Oct 2017 10:41:39 -0700 (PDT) X-Received: by 10.55.10.18 with SMTP id 18mr13625407qkk.184.1508175699489; Mon, 16 Oct 2017 10:41:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508175699; cv=none; d=google.com; s=arc-20160816; b=gB0ZAzvBBC66Q6aq3+u2h1cstHyOY46KIgcvqpkaHb2w2+Pvm7iSASvLVGonmgntUG A+s35il5/niaJspxvP+duSOWkFdq3rCQ5ce2OM7ZZ53bxlmxmrb/ceALE2hNLcDqJT9j CYVkIzq/9gXE1gIIQrsmCJ3WsWcYDQDNcJVxyUQLJ9RGGAm4mDv1JphR4TcGxtqo79AC 6ZQ1abSmdnvaOWRfzELsK73UmkD10/au26nKpGHPP2+Mv5e3TzblF4W5C8QrGKNBujSG v1W84xI2N9zUbZGWgN8I8OCXPEXo5BK6Ap1fbELNfZquYNUXzNfZDGQDN0p0/+bAkMo+ DjLw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=14UnMYMoZqmrJ9oz6osYwF58UTet1QjRnDjyBDt55ag=; b=xT/sXdTHueKoG7VFCLg1UCk8Fr8R0l5/uYlNkzXEpx3M9MZkg+JOpld37XXfIm+HM+ pwRy7NAqEKsqDzEvCkQXv280ejnmbmrCu5EjP3TXsvX/hddS0nKqKxUid089VJ5jRw2/ XCVqZVeB4YK3W1g51uOWXf5ybflyvo1iexnN037iivjFndHP9KZOpgQHZQ8wWm//5Mb9 smLG3YY0uHR4RG3Jc7uRSkS+ftycFRCTVaWHAJCy7xLGAuBgJNJSWiKc4jxux/lId6+y W7rdNRSlGqAoMDiY3Kts6+aIIMuhwtVkgiZy05mzv8P0Fsc/PjTWuyHoFTAj7gdQIB6g h4zA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=As0pz483; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id 30si3554604qtb.110.2017.10.16.10.41.39 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 16 Oct 2017 10:41:39 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=As0pz483; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:34356 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e49OT-0006MO-EA for patch@linaro.org; Mon, 16 Oct 2017 13:41:37 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52283) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e499p-00020a-GA for qemu-devel@nongnu.org; Mon, 16 Oct 2017 13:26:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e499o-0003Op-Gp for qemu-devel@nongnu.org; Mon, 16 Oct 2017 13:26:29 -0400 Received: from mail-pg0-x234.google.com ([2607:f8b0:400e:c05::234]:51119) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e499o-0003OF-BR for qemu-devel@nongnu.org; Mon, 16 Oct 2017 13:26:28 -0400 Received: by mail-pg0-x234.google.com with SMTP id y7so7342099pgb.7 for ; Mon, 16 Oct 2017 10:26:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=14UnMYMoZqmrJ9oz6osYwF58UTet1QjRnDjyBDt55ag=; b=As0pz48359ajQ6Ug9EXlJEMwQrr+/sBS2QWjxNai+8p5WVwOfF/3fhxDhd/KPcwzyt cWCxYnHDyAMA1I1wR8su2o/xtzhG4R8Czl3zkg0nSRbBH8v/Jj1AgL0kBSjehiIdz6us y8Imv7uxHkCYAxQuD+ZTCX1xHefxk52O13iMk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=14UnMYMoZqmrJ9oz6osYwF58UTet1QjRnDjyBDt55ag=; b=C+ufwKSvNESbtYGEZuDZ1xO1r5P2w0Ih2hgT19R+GMgkvKJNyJzEzcf9bl34RzhNBN lIA36VjVSI18BA7n5woZCky5cRpwyUu3E1UMBbABND/hBcrSlDcQE2U5DFzp2JTLONmX 6pkklOCCa+6rL5qesImLY+rbpp80nuOW+DvqKDOuiokitlYo8FYktjzn97YrRbY62Leo TTBiORMN+ag5kivSexfWOwKo6v8QefmGGsyKYNnRDWXijmD7tNu+yiy+ylc4dL1Voh76 HvebcZ7EHC4BPbeGTuB4SJ2GS+YnrD2JhI4vtDwSeRlfKF/iUAhsIWQekIyop2tjh0U7 7qbw== X-Gm-Message-State: AMCzsaXMfjtUMc5FQCHT5CpcbaIG6mOhpqb4sXVYQz05IVhR7UoQarZa klk+O1zmZ8ixVAgi+Dmjjpf5cMISRpU= X-Google-Smtp-Source: AOwi7QCNegFNvChZ1UiFH9u0w7h60vCqBUCeCCRnDWwYOAsV4p3oDLl8Phm4hNZNwg+khhZZQk0W5g== X-Received: by 10.84.135.101 with SMTP id 92mr9657204pli.180.1508174787215; Mon, 16 Oct 2017 10:26:27 -0700 (PDT) Received: from cloudburst.twiddle.net (97-126-104-76.tukw.qwest.net. [97.126.104.76]) by smtp.gmail.com with ESMTPSA id i187sm5594249pfc.96.2017.10.16.10.26.25 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 16 Oct 2017 10:26:26 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Mon, 16 Oct 2017 10:25:29 -0700 Message-Id: <20171016172609.23422-11-richard.henderson@linaro.org> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171016172609.23422-1-richard.henderson@linaro.org> References: <20171016172609.23422-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c05::234 Subject: [Qemu-devel] [PATCH v6 10/50] tcg: Avoid loops against variable bounds 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: cota@braap.org, Richard Henderson Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson Copy s->nb_globals or s->nb_temps to a local variable for the purposes of iteration. This should allow the compiler to use low-overhead looping constructs on some hosts. Reviewed-by: Alex BennĂ©e Signed-off-by: Richard Henderson --- tcg/tcg.c | 27 ++++++++++----------------- 1 file changed, 10 insertions(+), 17 deletions(-) -- 2.13.6 Reviewed-by: Emilio G. Cota diff --git a/tcg/tcg.c b/tcg/tcg.c index 719db9f2b6..bb342e06dd 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -1166,23 +1166,16 @@ void tcg_gen_callN(TCGContext *s, void *func, TCGArg ret, static void tcg_reg_alloc_start(TCGContext *s) { - int i; + int i, n; TCGTemp *ts; - for(i = 0; i < s->nb_globals; i++) { + + for (i = 0, n = s->nb_globals; i < n; i++) { ts = &s->temps[i]; - if (ts->fixed_reg) { - ts->val_type = TEMP_VAL_REG; - } else { - ts->val_type = TEMP_VAL_MEM; - } + ts->val_type = (ts->fixed_reg ? TEMP_VAL_REG : TEMP_VAL_MEM); } - for(i = s->nb_globals; i < s->nb_temps; i++) { + for (n = s->nb_temps; i < n; i++) { ts = &s->temps[i]; - if (ts->temp_local) { - ts->val_type = TEMP_VAL_MEM; - } else { - ts->val_type = TEMP_VAL_DEAD; - } + ts->val_type = (ts->temp_local ? TEMP_VAL_MEM : TEMP_VAL_DEAD); ts->mem_allocated = 0; ts->fixed_reg = 0; } @@ -2284,9 +2277,9 @@ static void temp_save(TCGContext *s, TCGTemp *ts, TCGRegSet allocated_regs) temporary registers needs to be allocated to store a constant. */ static void save_globals(TCGContext *s, TCGRegSet allocated_regs) { - int i; + int i, n; - for (i = 0; i < s->nb_globals; i++) { + for (i = 0, n = s->nb_globals; i < n; i++) { temp_save(s, &s->temps[i], allocated_regs); } } @@ -2296,9 +2289,9 @@ static void save_globals(TCGContext *s, TCGRegSet allocated_regs) temporary registers needs to be allocated to store a constant. */ static void sync_globals(TCGContext *s, TCGRegSet allocated_regs) { - int i; + int i, n; - for (i = 0; i < s->nb_globals; i++) { + for (i = 0, n = s->nb_globals; i < n; i++) { TCGTemp *ts = &s->temps[i]; tcg_debug_assert(ts->val_type != TEMP_VAL_REG || ts->fixed_reg From patchwork Mon Oct 16 17:25:30 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 115932 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp3936230qgn; Mon, 16 Oct 2017 10:29:38 -0700 (PDT) X-Received: by 10.200.48.241 with SMTP id w46mr15495209qta.172.1508174978553; Mon, 16 Oct 2017 10:29:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508174978; cv=none; d=google.com; s=arc-20160816; b=LIkKHZDDsSH2q8DmzGeCBQCCNk69L3y7Z7Nda/g0dcgru75d672uvIOd107WXZC9uB b255/XmICSfJyWb1W8wVIGdtzXr35yaZ+m2qihWk0jPWjIilld5SAhxhUyzmgBXZQdgc K9l1WXudh0XZIvqCUS+XKDgx7E/l5yKT+vbgrxoV8XiaHBh7NMAmSVnqHhBQ46bY3JGY OhRtQlrRYDi/TqU8ps7+H9iCjStbYPNYpEZ6wD1VyrLsIAnOH9XJ5XZGCKeMgUVuTVPX JpqYVZ2dp3pQGikzACsOUyZYJfk87ZjFCCZWMMOcKF3JcQVTu3k19TMPNWBfWhuQkTBo lirQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=lJVN+S2DgazaSIILNv42s3kUvwnlG8Z7itYcAljEvG4=; b=XPwKDbSO62lFxEoOSiCyIRychMlLLMGeh1xR+xBUBRMyEy6+fBWOwVDMISwm4P0pKP 9FPxyhOWngh/beGXYEDWlvPyc+VMzlULKwB8MJgeLSWflfc5HuXs5DjQdfUg62GfpSD7 iPKIyA1EQZWPxF2/XZOxLlVAH0HGCmb/W2A8BkS9F6jzlgqOQ1iZPWECRQLX+5WT/blv oEZ80LKo/vQXPIfkrTY6CXRhI01HerCH3Tf7CGAb4PgRdMBCRK/bePZNTgxbg2NAfk+g r5aopLvpF0PYFMDvjKVVw3MbBenp6efNglOTX96GBr2BxZMGV3KmzBL0JYyONSLpAC7O Cs/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Cim06HXu; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id 5si437933qka.174.2017.10.16.10.29.37 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 16 Oct 2017 10:29:38 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Cim06HXu; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:34303 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e49Cq-0004Pz-5z for patch@linaro.org; Mon, 16 Oct 2017 13:29:36 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52300) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e499q-000227-Ld for qemu-devel@nongnu.org; Mon, 16 Oct 2017 13:26:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e499p-0003Pm-OP for qemu-devel@nongnu.org; Mon, 16 Oct 2017 13:26:30 -0400 Received: from mail-pf0-x234.google.com ([2607:f8b0:400e:c00::234]:56145) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e499p-0003PC-Iq for qemu-devel@nongnu.org; Mon, 16 Oct 2017 13:26:29 -0400 Received: by mail-pf0-x234.google.com with SMTP id 17so16278912pfn.12 for ; Mon, 16 Oct 2017 10:26:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=lJVN+S2DgazaSIILNv42s3kUvwnlG8Z7itYcAljEvG4=; b=Cim06HXu3qWkC93NH8i691JvDIyXHbhqmPymk2Qy65Q0H7n17FH7EaahsJsatxNLY8 aljKTqm7+fh3x5aDI8r390cH+Gr4kieRFYL6kOG48T866dVvOT15l1EMxL50lieg9RUr TG4pOoL4hRirxfnqAtobxIrHTpqF4ZSJOhBvw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=lJVN+S2DgazaSIILNv42s3kUvwnlG8Z7itYcAljEvG4=; b=tT2bdpnv6of/B17d5tmKkg3xh6OUFOjLqn00ioS4XLOHtrnhXwPmvM1Sh7JCWc1vdi 4Z9eFyM1ulCISu/XcbpmLB5q5GGungUeMAruAarWN3avJNOihj0WS6e8KRTj50XGlq8i 4J3oXNKodxN/q2QQzhGVM1IHOvs4t3mk8ewlff3ysnrf65SDGHnBf4pjteVxB3pRh8JZ wn0F/7FlAOgsxgTkjI0jzCypKfSa0gKOWgKUiW2VZuBh6IH2s2Xgb20D9Q3WxLCwfVWk be3krNhqF+R+nMTY2ZjToEqFmapqlEbBe7ksc5PjsvgXcNGo0KOH43C1fnjfYNXEJ33e Y67g== X-Gm-Message-State: AMCzsaWyprqmSizq3/8VeLeDaAtxQ3V7AJdKaKCEhzqZIsf37BlqQTma Ibr8OD417II6AMJXVw/Q3qa6OqvuXSk= X-Google-Smtp-Source: AOwi7QB+tDhbHVr3OMycf3GW/trP3/0dRYj9KfKehCpYwlDorZGhwqh7F5FTuqZLZdWkipjQLhd07g== X-Received: by 10.84.231.2 with SMTP id f2mr9352852plk.256.1508174788395; Mon, 16 Oct 2017 10:26:28 -0700 (PDT) Received: from cloudburst.twiddle.net (97-126-104-76.tukw.qwest.net. [97.126.104.76]) by smtp.gmail.com with ESMTPSA id i187sm5594249pfc.96.2017.10.16.10.26.27 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 16 Oct 2017 10:26:27 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Mon, 16 Oct 2017 10:25:30 -0700 Message-Id: <20171016172609.23422-12-richard.henderson@linaro.org> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171016172609.23422-1-richard.henderson@linaro.org> References: <20171016172609.23422-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c00::234 Subject: [Qemu-devel] [PATCH v6 11/50] tcg: Change temp_allocate_frame arg to TCGTemp 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: cota@braap.org, Richard Henderson Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson Signed-off-by: Richard Henderson --- tcg/tcg.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) -- 2.13.6 Reviewed-by: Emilio G. Cota diff --git a/tcg/tcg.c b/tcg/tcg.c index bb342e06dd..163ec8b1c0 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -2103,10 +2103,8 @@ static void check_regs(TCGContext *s) } #endif -static void temp_allocate_frame(TCGContext *s, int temp) +static void temp_allocate_frame(TCGContext *s, TCGTemp *ts) { - TCGTemp *ts; - ts = &s->temps[temp]; #if !(defined(__sparc__) && TCG_TARGET_REG_BITS == 64) /* Sparc64 stack is accessed with offset of 2047 */ s->current_frame_offset = (s->current_frame_offset + @@ -2159,7 +2157,7 @@ static void temp_sync(TCGContext *s, TCGTemp *ts, } if (!ts->mem_coherent) { if (!ts->mem_allocated) { - temp_allocate_frame(s, temp_idx(s, ts)); + temp_allocate_frame(s, ts); } switch (ts->val_type) { case TEMP_VAL_CONST: @@ -2389,7 +2387,7 @@ static void tcg_reg_alloc_mov(TCGContext *s, const TCGOp *op) liveness analysis disabled). */ tcg_debug_assert(NEED_SYNC_ARG(0)); if (!ots->mem_allocated) { - temp_allocate_frame(s, op->args[0]); + temp_allocate_frame(s, ots); } tcg_out_st(s, otype, ts->reg, ots->mem_base->reg, ots->mem_offset); if (IS_DEAD_ARG(1)) { From patchwork Mon Oct 16 17:25:31 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 115937 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp3938765qgn; Mon, 16 Oct 2017 10:32:16 -0700 (PDT) X-Received: by 10.237.37.244 with SMTP id y49mr16144802qtc.131.1508175136656; Mon, 16 Oct 2017 10:32:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508175136; cv=none; d=google.com; s=arc-20160816; b=P2ZgQ3EDr5HYRofs/LY8SJONwve6Cxc4tXXLFR29J6CzYpKSa1zNttv5MwwW2q5Um7 8PfhoQpwqJcB9KnN6stdMUfk3G8xogscdibd30WIQ33ujuCXnt7YPwiAmyqtlq6yEK5X HzLE1TOiJLru9kLgNMSqcHbEV/hprD88+rXdJbgBz7n0ZIi6mGJgpe+Uy9R51G8fYMyA IgDw/RqVmbn6FhlH4UDHBk2XxTkTCUKtrSYBePVE47vEona8EhNsBBmOrKP4H4yCVUnb W+UX3RxbuWYQuSZerPKrQeCWJotNCyUN+HGAbywTQz9J1RCJnBK4Qo0zhGCjdMLNtFqA DN1w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=uc08eLaVrb5X9wMHbwVKCwEfLsADWaQlNRMzz5RsmlE=; b=SDhmEy/VaSpNpCi7hDSjZzQyqUpKBMfmJeG4GQS8qqUSXGU1lSaQXFJ9GJ5t77EW3P 7uXdqOCYg+gQHR4XTjbnZvvM5yqMZRViwvYCLVIOrPrf8ejWT+N+59JbPDhJ3N2a2Oez pOipoQIu+M2ZnTuJz7QM0EatbHIwSeGErxhT4fEe+9mb+7iqihTV8XBAiVRHVBYe+hrv zHxUc9hxqq8/+qgDxLWiSSYJwhq7pXR/Tk1qNN4hBQb7mrjkTH/mZfE/Ci+pUdS/gVtE nMHmLap1raRfsDyWpqDg9XS+XSO6MbMKM9tuRb7/k+6J0LlzdCGCg6EmXmxRjrLZbl6p 37vQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=TUWNgFnH; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id h1si254126qkf.213.2017.10.16.10.32.16 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 16 Oct 2017 10:32:16 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=TUWNgFnH; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:34316 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e49FO-0006rV-Ix for patch@linaro.org; Mon, 16 Oct 2017 13:32:14 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52312) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e499r-00023B-Jj for qemu-devel@nongnu.org; Mon, 16 Oct 2017 13:26:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e499q-0003Qs-Te for qemu-devel@nongnu.org; Mon, 16 Oct 2017 13:26:31 -0400 Received: from mail-pf0-x22c.google.com ([2607:f8b0:400e:c00::22c]:43802) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e499q-0003QI-OL for qemu-devel@nongnu.org; Mon, 16 Oct 2017 13:26:30 -0400 Received: by mail-pf0-x22c.google.com with SMTP id a8so15843593pfc.0 for ; Mon, 16 Oct 2017 10:26:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=uc08eLaVrb5X9wMHbwVKCwEfLsADWaQlNRMzz5RsmlE=; b=TUWNgFnH6wuiJdxdPcuX8mBHR5B0BMODVr4X6mftNDh/1+wu7Kj7gMFcAXhnnvlFTO T5LBDN0Jiw187vDd+wMsHZzD42OmGdbvKpFT2p4fsethxYr6X46RRUj5SRevQeDPtz1c UOdc1flEjD4MXvUf0WOxzrlgn1FJ2YTh/Pdi0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=uc08eLaVrb5X9wMHbwVKCwEfLsADWaQlNRMzz5RsmlE=; b=aUYRKoh1+Gx/N/1+aq0fXsaxyO3Zu3+6SII9VfSDcEwUn/hSOoE6yO7yEHUOM1Fwo8 BWJ5Szbl91MXZvo8/wNU+4feDBakIGqwohWtjPxbJgGvyvdJJ0MwsHkyBG83DCAfin3e PbsF7VoL9bcZUc2drVmg0OVviweAd2IEa8ZfesV0qklgUVJU0gYfOyB7qcyMypuwdh8J 5PjqL1GMaQgQKGHuGlcz4hVaZrMH3PmsmeN7nW8XsjEzvVvhnOwhunA2kqQ0o5dRfkcz t33hEhVGWA6VPyRloLHZr0eJ5xVa1mlZW70KeMDTGcjYc0OTzsLIcLO34NgnwlWBi/Ck Tfsw== X-Gm-Message-State: AMCzsaUR6Toq3Sdm9+CZfFAOozrNTSNMB2gPuEAZrbRX3UyfZuQDwGTg VAnmO8MD59Oh4zNyydzQ59pByXfXZbY= X-Google-Smtp-Source: AOwi7QCheYJMZpXyD+P65vNc6ygSFM3vMRpD3p1zhPKttaTWtWOpbbu34kvS5uEccOaBvCbpgZf0Pg== X-Received: by 10.99.55.1 with SMTP id e1mr8507805pga.175.1508174789580; Mon, 16 Oct 2017 10:26:29 -0700 (PDT) Received: from cloudburst.twiddle.net (97-126-104-76.tukw.qwest.net. [97.126.104.76]) by smtp.gmail.com with ESMTPSA id i187sm5594249pfc.96.2017.10.16.10.26.28 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 16 Oct 2017 10:26:28 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Mon, 16 Oct 2017 10:25:31 -0700 Message-Id: <20171016172609.23422-13-richard.henderson@linaro.org> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171016172609.23422-1-richard.henderson@linaro.org> References: <20171016172609.23422-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c00::22c Subject: [Qemu-devel] [PATCH v6 12/50] tcg: Remove unused TCG_CALL_DUMMY_TCGV 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: cota@braap.org, Richard Henderson Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson Reviewed-by: Alex BennĂ©e Signed-off-by: Richard Henderson --- tcg/tcg.h | 1 - 1 file changed, 1 deletion(-) -- 2.13.6 Reviewed-by: Emilio G. Cota diff --git a/tcg/tcg.h b/tcg/tcg.h index 4352c0ee8c..e0615de90f 100644 --- a/tcg/tcg.h +++ b/tcg/tcg.h @@ -496,7 +496,6 @@ static inline intptr_t QEMU_ARTIFICIAL GET_TCGV_PTR(TCGv_ptr t) #define TCG_CALL_NO_WG_SE (TCG_CALL_NO_WG | TCG_CALL_NO_SE) /* used to align parameters */ -#define TCG_CALL_DUMMY_TCGV MAKE_TCGV_I32(-1) #define TCG_CALL_DUMMY_ARG ((TCGArg)(-1)) /* Conditions. Note that these are laid out for easy manipulation by From patchwork Mon Oct 16 17:25:32 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 115954 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp3950303qgn; Mon, 16 Oct 2017 10:45:26 -0700 (PDT) X-Received: by 10.55.183.134 with SMTP id h128mr15252828qkf.258.1508175926201; Mon, 16 Oct 2017 10:45:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508175926; cv=none; d=google.com; s=arc-20160816; b=S+PIgkk8cqXbPAU1Oduh0SbbLAUkG3T3H/ubJXS+GEALh785HCPOON5KDtoz9W2QsC U7ME3GSGhSz4L1+tAwaiZaWz0IGwIphQTPvmV15IhtkQucxRk03pS1O4gW4Q7Q4V54SH bUIAnuAlxYGyqkqf3nvCDB6gQHYLp9Bsu5WWZM5Pp5ZTWets08y3SClboNApMhS8aYLg aDv+otGJIwrVHEY4NIG4d/uRuDDmrNe/3htFM2xbALzHoLmdM+cEkOjZu69tptTdwHBA f8ia+5kqrz0jNAMNfGWjx3AlXPk+V1KHwF+T0oUGrU8x2sGyLRlEHkI5FkxpshyXb65l 27fA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=u0QX5W2ChFDKotIY5fy9QRJPxN94Nx0++sj/1I+ayIo=; b=oFh0h6gK+R7m24fxmFujPA8U2eTRNnQtiJXj9WigrXcvQcx3RMmpZtvmqR92lX5pqn mpKYqW0SGPCe9GQ0uV5VAZaiOzYhq9zMZHZG4MgmZclKSIjRRSgDcoULRhr5nzYPnK8e 4qjYYYNiwmGoaosvmGb22+uvp0/YPP/TTFEnwOhz8oJtDhcCSEyKXJmcRj/79pWd+rLx u0E7N4QKSeqAVrnU5wYYGy4CfxP4/YcOYdCmm3cVNie2yn38n2zqFnMqKM3EZbCxYev5 RkixP/MWV7mpJSInSQ+VgrF8TjaJk6zGNry8rGprPNXrAw56mtket1S1oOye1y3AD2KV 6NRw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=RJgShSMC; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id a13si1339925qkj.345.2017.10.16.10.45.25 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 16 Oct 2017 10:45:26 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=RJgShSMC; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:34370 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e49S8-0000zX-5W for patch@linaro.org; Mon, 16 Oct 2017 13:45:24 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52327) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e499t-00026Z-Kp for qemu-devel@nongnu.org; Mon, 16 Oct 2017 13:26:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e499s-0003SC-Nk for qemu-devel@nongnu.org; Mon, 16 Oct 2017 13:26:33 -0400 Received: from mail-pf0-x22b.google.com ([2607:f8b0:400e:c00::22b]:51667) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e499s-0003RQ-DK for qemu-devel@nongnu.org; Mon, 16 Oct 2017 13:26:32 -0400 Received: by mail-pf0-x22b.google.com with SMTP id n14so16279924pfh.8 for ; Mon, 16 Oct 2017 10:26:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=u0QX5W2ChFDKotIY5fy9QRJPxN94Nx0++sj/1I+ayIo=; b=RJgShSMCAjcfmEayH8aE+sbXcxt70xhYTr+zPclrv2ZwW2YM3npC3wc30cSbvrccFb DNfH4N3taAnirn29cUp71CqkyKXkTZB97CNaY62jVSE16iZs3FI5kuL7/j7oCJAQdhGu OC7a6zpwynsYtjPES+7IkfUvjhZ9RnDy8sskI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=u0QX5W2ChFDKotIY5fy9QRJPxN94Nx0++sj/1I+ayIo=; b=S9eh0HhRNgY/AIYW9AA6NK+2pRJAcEcTXCVmPprE0DI5OJj8BkXES7gz5zGgOHctSw VCd1CRlB/qB31PhHoMmDZ1JM0EyHVAHduk0dDrT4xfI2WaJgJcFZpVqzC7bXyfrIkF1x v9LxFZZTe4W78RI7y1Yv4qtmXih0c+q0P/EAxjgIy31+IZteRjTISa1WBftpFxg08vyr tQVdnoian4LTePGv1uBSWVJ4L4+UnweW83QDwDmxGjbT6zyau84PIY3JOKyHdbOw46Fe mz4K0E0ho6ns0kEGcFtZo0KSaF1Bn3Pz9kb86A6UACk9LZYuwNn2/60+HL9BujPIWuAt Dnow== X-Gm-Message-State: AMCzsaUwc2CIDp2GkYOd1I3KUUi6QyRD5gN1Xl2AJdKeuzZBLjiKidIf iJbaSwpPBJlJvENxa2Xs+LpuPghbsJk= X-Google-Smtp-Source: ABhQp+Qq353R0XBDANIM2xJy5zpelCDKYB7Sru6IFOJDA0ej/o8mXTDuyx6R0B8wpifZJr+YJ9zr8Q== X-Received: by 10.84.138.131 with SMTP id 3mr68361plp.238.1508174790953; Mon, 16 Oct 2017 10:26:30 -0700 (PDT) Received: from cloudburst.twiddle.net (97-126-104-76.tukw.qwest.net. [97.126.104.76]) by smtp.gmail.com with ESMTPSA id i187sm5594249pfc.96.2017.10.16.10.26.29 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 16 Oct 2017 10:26:30 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Mon, 16 Oct 2017 10:25:32 -0700 Message-Id: <20171016172609.23422-14-richard.henderson@linaro.org> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171016172609.23422-1-richard.henderson@linaro.org> References: <20171016172609.23422-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c00::22b Subject: [Qemu-devel] [PATCH v6 13/50] tcg: Export temp_idx 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: cota@braap.org, Richard Henderson Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson At the same time, drop the TCGContext argument and use tcg_ctx instead. Signed-off-by: Richard Henderson --- tcg/tcg.h | 7 ++++++- tcg/tcg.c | 15 ++++----------- 2 files changed, 10 insertions(+), 12 deletions(-) -- 2.13.6 Reviewed-by: Emilio G. Cota diff --git a/tcg/tcg.h b/tcg/tcg.h index e0615de90f..c50805217c 100644 --- a/tcg/tcg.h +++ b/tcg/tcg.h @@ -734,13 +734,18 @@ struct TCGContext { extern TCGContext tcg_ctx; extern bool parallel_cpus; -static inline TCGArg temp_arg(TCGTemp *ts) +static inline size_t temp_idx(TCGTemp *ts) { ptrdiff_t n = ts - tcg_ctx.temps; tcg_debug_assert(n >= 0 && n < tcg_ctx.nb_temps); return n; } +static inline TCGArg temp_arg(TCGTemp *ts) +{ + return temp_idx(ts); +} + static inline TCGTemp *arg_temp(TCGArg a) { return a == TCG_CALL_DUMMY_ARG ? NULL : &tcg_ctx.temps[a]; diff --git a/tcg/tcg.c b/tcg/tcg.c index 163ec8b1c0..b39944d42a 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -473,13 +473,6 @@ void tcg_func_start(TCGContext *s) s->gen_next_op_idx = 1; } -static inline int temp_idx(TCGContext *s, TCGTemp *ts) -{ - ptrdiff_t n = ts - s->temps; - tcg_debug_assert(n >= 0 && n < s->nb_temps); - return n; -} - static inline TCGTemp *tcg_temp_alloc(TCGContext *s) { int n = s->nb_temps++; @@ -516,7 +509,7 @@ static int tcg_global_reg_new_internal(TCGContext *s, TCGType type, ts->name = name; tcg_regset_set_reg(s->reserved_regs, reg); - return temp_idx(s, ts); + return temp_idx(ts); } void tcg_set_frame(TCGContext *s, TCGReg reg, intptr_t start, intptr_t size) @@ -605,7 +598,7 @@ int tcg_global_mem_new_internal(TCGType type, TCGv_ptr base, ts->mem_offset = offset; ts->name = name; } - return temp_idx(s, ts); + return temp_idx(ts); } static int tcg_temp_new_internal(TCGType type, int temp_local) @@ -645,7 +638,7 @@ static int tcg_temp_new_internal(TCGType type, int temp_local) ts->temp_allocated = 1; ts->temp_local = temp_local; } - idx = temp_idx(s, ts); + idx = temp_idx(ts); } #if defined(CONFIG_DEBUG_TCG) @@ -1186,7 +1179,7 @@ static void tcg_reg_alloc_start(TCGContext *s) static char *tcg_get_arg_str_ptr(TCGContext *s, char *buf, int buf_size, TCGTemp *ts) { - int idx = temp_idx(s, ts); + int idx = temp_idx(ts); if (ts->temp_global) { pstrcpy(buf, buf_size, ts->name); From patchwork Mon Oct 16 17:25:33 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 115940 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp3941677qgn; Mon, 16 Oct 2017 10:35:19 -0700 (PDT) X-Received: by 10.200.14.71 with SMTP id j7mr16272602qti.41.1508175319907; Mon, 16 Oct 2017 10:35:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508175319; cv=none; d=google.com; s=arc-20160816; b=ZE07QjsY4AJm84mFta3CcrNqpWJtBwVeGrHycUYLKpomJ3Bif0vNefFjXxBAL5LSlx SZu0NxR2S5FRLjgAx3fFtDjIX6bGq+s0qC//rPLX5nf+VbzS5RkpANIWlzUSAcdt4hUU 1dxBD2YD3vXkUNGKHubdRnRB3JHokMgO0mIYe2qjz5kUyduDC8jm2LQEzHuQmaI3Yu3f a5Rze/rB8zL0BMNR9XCDhhfuuddXKltSOZG+0V0Vk2ZpkN4i93DDPgPw6U2GZ28Z2pXG MnnEup6/LR6FGXzHN/Hb0WsRvll1GkJTJDdJorPK9x25A9Ch3NF2ryFy5LvwKc2y2feI rWsg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=xQu3a0vMkMDgADARfkzGV6Yh21BxIRbkHvrajy96WtQ=; b=JpA/cAU+Kva41y6U/74RYyk3edmkAcIzHEu+GANIhT/DNtlnR948aHd/f6hr6WAN+U RVU5GK5B9jL10BuRjvP6oV/EDvyNKmXTfkRhMSIJSAhV1Imw8QeFsZoO7epAhaZF6OKm 7RB1R8JIFRTsOIMKGVucmv9zZesvywKhhJ1DXCrHECcW7L9FYnaD732Nb3AM9zLcmYMh 1VW8g7V4ZPGTRjMuhWv6FIg9VcNhjiRMUmvp82lOW6xfX36wCFM4BTlJkdsGP1H/SB2/ newUjFFT7MD93N7oTbNxw/gsYt72jR+InZIJWmWVJ89Jj6LpOrvHVOr4XRXyeb7DZzLr ucBA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=YUiOg1CF; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id e29si7032564qtk.139.2017.10.16.10.35.19 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 16 Oct 2017 10:35:19 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=YUiOg1CF; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:34328 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e49IL-0000xm-F0 for patch@linaro.org; Mon, 16 Oct 2017 13:35:17 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52347) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e499x-0002AV-V3 for qemu-devel@nongnu.org; Mon, 16 Oct 2017 13:26:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e499u-0003TG-E0 for qemu-devel@nongnu.org; Mon, 16 Oct 2017 13:26:37 -0400 Received: from mail-pf0-x22c.google.com ([2607:f8b0:400e:c00::22c]:54601) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e499u-0003Sf-1l for qemu-devel@nongnu.org; Mon, 16 Oct 2017 13:26:34 -0400 Received: by mail-pf0-x22c.google.com with SMTP id n89so8658549pfk.11 for ; Mon, 16 Oct 2017 10:26:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=xQu3a0vMkMDgADARfkzGV6Yh21BxIRbkHvrajy96WtQ=; b=YUiOg1CFzRMO03I+eClmcYXMb+0AcGAHUQj8pj7OBw+GDn4n5VPRvt9Jy7WJsE2YxI 7xCjpC6vIQ24r4xxGMJdIg30IfPBJIz4fJYbdskkQ6kJOq17VFPOhZUneqZ0ThloFHrM GTuEGApe6zRqnpRozm6Sa7g9GOX6lrP6opXiA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=xQu3a0vMkMDgADARfkzGV6Yh21BxIRbkHvrajy96WtQ=; b=Vka3KI/xM6ano2m1upJ0A9hmKHMpJJZpcykYYmNS+3O415kZhS228bvbU7oUaWtpv9 tmo1UAv2ogEF7swvjepoqWMnFq6+1WzKfAmkoe8eRa5sMXWcsdcrLDegv7R25+O1WPOc o0i5fa1RxF96gceg120+SoArPyQUKNGz1cYFApvSprMrMP3Ryz43tsxS9SayyvO24HA8 CvRTsx7hUOtFwZnS0bzUXOYk8ne7PIIjHcRSp9c7LXXzE3QP/QGtPsQ4FF5OEAZwP+Z5 J3S695A3kOBoN3vdnTO94R0F87nCYdWyeM+eQDwQ4fXjiqzb1ohsUaPQvgVLmYrGvoS3 m86w== X-Gm-Message-State: AMCzsaVuQTr77sVuCGQWXEAFWHv8lbFWbxs73Z+VT37JvITJK+cFqvfm VO5fYZ2bfLDxNyaa7s9+IY0v3rPvud8= X-Google-Smtp-Source: AOwi7QCvn6NkEyuH+WEeGwp032dIbFNDRBkGzeNapUJNe9XIGfzJbn9v17glTc4xori5MPyOgyq6FQ== X-Received: by 10.98.198.138 with SMTP id x10mr7920006pfk.55.1508174792395; Mon, 16 Oct 2017 10:26:32 -0700 (PDT) Received: from cloudburst.twiddle.net (97-126-104-76.tukw.qwest.net. [97.126.104.76]) by smtp.gmail.com with ESMTPSA id i187sm5594249pfc.96.2017.10.16.10.26.31 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 16 Oct 2017 10:26:31 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Mon, 16 Oct 2017 10:25:33 -0700 Message-Id: <20171016172609.23422-15-richard.henderson@linaro.org> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171016172609.23422-1-richard.henderson@linaro.org> References: <20171016172609.23422-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c00::22c Subject: [Qemu-devel] [PATCH v6 14/50] tcg: Use per-temp state data in optimize 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: cota@braap.org, Richard Henderson Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson While we're touching many of the lines anyway, adjust the naming of the functions to better distinguish when "TCGArg" vs "TCGTemp" should be used. Signed-off-by: Richard Henderson --- tcg/tcg.h | 5 + tcg/optimize.c | 430 +++++++++++++++++++++++++++++++++------------------------ 2 files changed, 252 insertions(+), 183 deletions(-) -- 2.13.6 Reviewed-by: Emilio G. Cota diff --git a/tcg/tcg.h b/tcg/tcg.h index c50805217c..563e7d36aa 100644 --- a/tcg/tcg.h +++ b/tcg/tcg.h @@ -751,6 +751,11 @@ static inline TCGTemp *arg_temp(TCGArg a) return a == TCG_CALL_DUMMY_ARG ? NULL : &tcg_ctx.temps[a]; } +static inline size_t arg_index(TCGArg a) +{ + return a; +} + static inline void tcg_set_insn_param(int op_idx, int arg, TCGArg v) { tcg_ctx.gen_op_buf[op_idx].args[arg] = v; diff --git a/tcg/optimize.c b/tcg/optimize.c index 55f9e83ce8..ead7bb5e4f 100644 --- a/tcg/optimize.c +++ b/tcg/optimize.c @@ -34,34 +34,63 @@ struct tcg_temp_info { bool is_const; - uint16_t prev_copy; - uint16_t next_copy; + TCGTemp *prev_copy; + TCGTemp *next_copy; tcg_target_ulong val; tcg_target_ulong mask; }; -static struct tcg_temp_info temps[TCG_MAX_TEMPS]; +static struct tcg_temp_info temps_[TCG_MAX_TEMPS]; static TCGTempSet temps_used; -static inline bool temp_is_const(TCGArg arg) +static inline struct tcg_temp_info *ts_info(TCGTemp *ts) { - return temps[arg].is_const; + return ts->state_ptr; } -static inline bool temp_is_copy(TCGArg arg) +static inline struct tcg_temp_info *arg_info(TCGArg arg) { - return temps[arg].next_copy != arg; + return ts_info(arg_temp(arg)); +} + +static inline bool ts_is_const(TCGTemp *ts) +{ + return ts_info(ts)->is_const; +} + +static inline bool arg_is_const(TCGArg arg) +{ + return ts_is_const(arg_temp(arg)); +} + +static inline bool ts_is_copy(TCGTemp *ts) +{ + return ts_info(ts)->next_copy != ts; +} + +static inline bool arg_is_copy(TCGArg arg) +{ + return ts_is_copy(arg_temp(arg)); } /* Reset TEMP's state, possibly removing the temp for the list of copies. */ -static void reset_temp(TCGArg temp) +static void reset_ts(TCGTemp *ts) { - temps[temps[temp].next_copy].prev_copy = temps[temp].prev_copy; - temps[temps[temp].prev_copy].next_copy = temps[temp].next_copy; - temps[temp].next_copy = temp; - temps[temp].prev_copy = temp; - temps[temp].is_const = false; - temps[temp].mask = -1; + struct tcg_temp_info *ti = ts_info(ts); + struct tcg_temp_info *pi = ts_info(ti->prev_copy); + struct tcg_temp_info *ni = ts_info(ti->next_copy); + + ni->prev_copy = ti->prev_copy; + pi->next_copy = ti->next_copy; + ti->next_copy = ts; + ti->prev_copy = ts; + ti->is_const = false; + ti->mask = -1; +} + +static void reset_temp(TCGArg arg) +{ + reset_ts(arg_temp(arg)); } /* Reset all temporaries, given that there are NB_TEMPS of them. */ @@ -71,17 +100,26 @@ static void reset_all_temps(int nb_temps) } /* Initialize and activate a temporary. */ -static void init_temp_info(TCGArg temp) +static void init_ts_info(TCGTemp *ts) { - if (!test_bit(temp, temps_used.l)) { - temps[temp].next_copy = temp; - temps[temp].prev_copy = temp; - temps[temp].is_const = false; - temps[temp].mask = -1; - set_bit(temp, temps_used.l); + size_t idx = temp_idx(ts); + if (!test_bit(idx, temps_used.l)) { + struct tcg_temp_info *ti = &temps_[idx]; + + ts->state_ptr = ti; + ti->next_copy = ts; + ti->prev_copy = ts; + ti->is_const = false; + ti->mask = -1; + set_bit(idx, temps_used.l); } } +static void init_arg_info(TCGArg arg) +{ + init_ts_info(arg_temp(arg)); +} + static int op_bits(TCGOpcode op) { const TCGOpDef *def = &tcg_op_defs[op]; @@ -116,50 +154,49 @@ static TCGOpcode op_to_movi(TCGOpcode op) } } -static TCGArg find_better_copy(TCGContext *s, TCGArg arg) +static TCGTemp *find_better_copy(TCGContext *s, TCGTemp *ts) { - TCGTemp *ts = arg_temp(arg); - TCGArg i; + TCGTemp *i; /* If this is already a global, we can't do better. */ if (ts->temp_global) { - return arg; + return ts; } /* Search for a global first. */ - for (i = temps[arg].next_copy ; i != arg; i = temps[i].next_copy) { - if (i < s->nb_globals) { + for (i = ts_info(ts)->next_copy; i != ts; i = ts_info(i)->next_copy) { + if (i->temp_global) { return i; } } /* If it is a temp, search for a temp local. */ if (!ts->temp_local) { - for (i = temps[arg].next_copy ; i != arg; i = temps[i].next_copy) { - if (s->temps[i].temp_local) { + for (i = ts_info(ts)->next_copy; i != ts; i = ts_info(i)->next_copy) { + if (ts->temp_local) { return i; } } } /* Failure to find a better representation, return the same temp. */ - return arg; + return ts; } -static bool temps_are_copies(TCGArg arg1, TCGArg arg2) +static bool ts_are_copies(TCGTemp *ts1, TCGTemp *ts2) { - TCGArg i; + TCGTemp *i; - if (arg1 == arg2) { + if (ts1 == ts2) { return true; } - if (!temp_is_copy(arg1) || !temp_is_copy(arg2)) { + if (!ts_is_copy(ts1) || !ts_is_copy(ts2)) { return false; } - for (i = temps[arg1].next_copy ; i != arg1 ; i = temps[i].next_copy) { - if (i == arg2) { + for (i = ts_info(ts1)->next_copy; i != ts1; i = ts_info(i)->next_copy) { + if (i == ts2) { return true; } } @@ -167,22 +204,28 @@ static bool temps_are_copies(TCGArg arg1, TCGArg arg2) return false; } +static bool args_are_copies(TCGArg arg1, TCGArg arg2) +{ + return ts_are_copies(arg_temp(arg1), arg_temp(arg2)); +} + static void tcg_opt_gen_movi(TCGContext *s, TCGOp *op, TCGArg dst, TCGArg val) { TCGOpcode new_op = op_to_movi(op->opc); tcg_target_ulong mask; + struct tcg_temp_info *di = arg_info(dst); op->opc = new_op; reset_temp(dst); - temps[dst].is_const = true; - temps[dst].val = val; + di->is_const = true; + di->val = val; mask = val; if (TCG_TARGET_REG_BITS > 32 && new_op == INDEX_op_movi_i32) { /* High bits of the destination are now garbage. */ mask |= ~0xffffffffull; } - temps[dst].mask = mask; + di->mask = mask; op->args[0] = dst; op->args[1] = val; @@ -190,35 +233,44 @@ static void tcg_opt_gen_movi(TCGContext *s, TCGOp *op, TCGArg dst, TCGArg val) static void tcg_opt_gen_mov(TCGContext *s, TCGOp *op, TCGArg dst, TCGArg src) { - if (temps_are_copies(dst, src)) { + TCGTemp *dst_ts = arg_temp(dst); + TCGTemp *src_ts = arg_temp(src); + struct tcg_temp_info *di; + struct tcg_temp_info *si; + tcg_target_ulong mask; + TCGOpcode new_op; + + if (ts_are_copies(dst_ts, src_ts)) { tcg_op_remove(s, op); return; } - TCGOpcode new_op = op_to_mov(op->opc); - tcg_target_ulong mask; + reset_ts(dst_ts); + di = ts_info(dst_ts); + si = ts_info(src_ts); + new_op = op_to_mov(op->opc); op->opc = new_op; + op->args[0] = dst; + op->args[1] = src; - reset_temp(dst); - mask = temps[src].mask; + mask = si->mask; if (TCG_TARGET_REG_BITS > 32 && new_op == INDEX_op_mov_i32) { /* High bits of the destination are now garbage. */ mask |= ~0xffffffffull; } - temps[dst].mask = mask; - - if (arg_temp(src)->type == arg_temp(dst)->type) { - temps[dst].next_copy = temps[src].next_copy; - temps[dst].prev_copy = src; - temps[temps[dst].next_copy].prev_copy = dst; - temps[src].next_copy = dst; - temps[dst].is_const = temps[src].is_const; - temps[dst].val = temps[src].val; - } + di->mask = mask; - op->args[0] = dst; - op->args[1] = src; + if (src_ts->type == dst_ts->type) { + struct tcg_temp_info *ni = ts_info(si->next_copy); + + di->next_copy = si->next_copy; + di->prev_copy = src_ts; + ni->prev_copy = dst_ts; + si->next_copy = dst_ts; + di->is_const = si->is_const; + di->val = si->val; + } } static TCGArg do_constant_folding_2(TCGOpcode op, TCGArg x, TCGArg y) @@ -465,18 +517,20 @@ static bool do_constant_folding_cond_eq(TCGCond c) static TCGArg do_constant_folding_cond(TCGOpcode op, TCGArg x, TCGArg y, TCGCond c) { - if (temp_is_const(x) && temp_is_const(y)) { + tcg_target_ulong xv = arg_info(x)->val; + tcg_target_ulong yv = arg_info(y)->val; + if (arg_is_const(x) && arg_is_const(y)) { switch (op_bits(op)) { case 32: - return do_constant_folding_cond_32(temps[x].val, temps[y].val, c); + return do_constant_folding_cond_32(xv, yv, c); case 64: - return do_constant_folding_cond_64(temps[x].val, temps[y].val, c); + return do_constant_folding_cond_64(xv, yv, c); default: tcg_abort(); } - } else if (temps_are_copies(x, y)) { + } else if (args_are_copies(x, y)) { return do_constant_folding_cond_eq(c); - } else if (temp_is_const(y) && temps[y].val == 0) { + } else if (arg_is_const(y) && yv == 0) { switch (c) { case TCG_COND_LTU: return 0; @@ -496,12 +550,15 @@ static TCGArg do_constant_folding_cond2(TCGArg *p1, TCGArg *p2, TCGCond c) TCGArg al = p1[0], ah = p1[1]; TCGArg bl = p2[0], bh = p2[1]; - if (temp_is_const(bl) && temp_is_const(bh)) { - uint64_t b = ((uint64_t)temps[bh].val << 32) | (uint32_t)temps[bl].val; + if (arg_is_const(bl) && arg_is_const(bh)) { + tcg_target_ulong blv = arg_info(bl)->val; + tcg_target_ulong bhv = arg_info(bh)->val; + uint64_t b = deposit64(blv, 32, 32, bhv); - if (temp_is_const(al) && temp_is_const(ah)) { - uint64_t a; - a = ((uint64_t)temps[ah].val << 32) | (uint32_t)temps[al].val; + if (arg_is_const(al) && arg_is_const(ah)) { + tcg_target_ulong alv = arg_info(al)->val; + tcg_target_ulong ahv = arg_info(ah)->val; + uint64_t a = deposit64(alv, 32, 32, ahv); return do_constant_folding_cond_64(a, b, c); } if (b == 0) { @@ -515,7 +572,7 @@ static TCGArg do_constant_folding_cond2(TCGArg *p1, TCGArg *p2, TCGCond c) } } } - if (temps_are_copies(al, bl) && temps_are_copies(ah, bh)) { + if (args_are_copies(al, bl) && args_are_copies(ah, bh)) { return do_constant_folding_cond_eq(c); } return 2; @@ -525,8 +582,8 @@ static bool swap_commutative(TCGArg dest, TCGArg *p1, TCGArg *p2) { TCGArg a1 = *p1, a2 = *p2; int sum = 0; - sum += temp_is_const(a1); - sum -= temp_is_const(a2); + sum += arg_is_const(a1); + sum -= arg_is_const(a2); /* Prefer the constant in second argument, and then the form op a, a, b, which is better handled on non-RISC hosts. */ @@ -541,10 +598,10 @@ static bool swap_commutative(TCGArg dest, TCGArg *p1, TCGArg *p2) static bool swap_commutative2(TCGArg *p1, TCGArg *p2) { int sum = 0; - sum += temp_is_const(p1[0]); - sum += temp_is_const(p1[1]); - sum -= temp_is_const(p2[0]); - sum -= temp_is_const(p2[1]); + sum += arg_is_const(p1[0]); + sum += arg_is_const(p1[1]); + sum -= arg_is_const(p2[0]); + sum -= arg_is_const(p2[1]); if (sum > 0) { TCGArg t; t = p1[0], p1[0] = p2[0], p2[0] = t; @@ -586,23 +643,24 @@ void tcg_optimize(TCGContext *s) nb_oargs = op->callo; nb_iargs = op->calli; for (i = 0; i < nb_oargs + nb_iargs; i++) { - tmp = op->args[i]; - if (tmp != TCG_CALL_DUMMY_ARG) { - init_temp_info(tmp); + TCGTemp *ts = arg_temp(op->args[i]); + if (ts) { + init_ts_info(ts); } } } else { nb_oargs = def->nb_oargs; nb_iargs = def->nb_iargs; for (i = 0; i < nb_oargs + nb_iargs; i++) { - init_temp_info(op->args[i]); + init_arg_info(op->args[i]); } } /* Do copy propagation */ for (i = nb_oargs; i < nb_oargs + nb_iargs; i++) { - if (temp_is_copy(op->args[i])) { - op->args[i] = find_better_copy(s, op->args[i]); + TCGTemp *ts = arg_temp(op->args[i]); + if (ts && ts_is_copy(ts)) { + op->args[i] = temp_arg(find_better_copy(s, ts)); } } @@ -671,7 +729,8 @@ void tcg_optimize(TCGContext *s) CASE_OP_32_64(sar): CASE_OP_32_64(rotl): CASE_OP_32_64(rotr): - if (temp_is_const(op->args[1]) && temps[op->args[1]].val == 0) { + if (arg_is_const(op->args[1]) + && arg_info(op->args[1])->val == 0) { tcg_opt_gen_movi(s, op, op->args[0], 0); continue; } @@ -681,7 +740,7 @@ void tcg_optimize(TCGContext *s) TCGOpcode neg_op; bool have_neg; - if (temp_is_const(op->args[2])) { + if (arg_is_const(op->args[2])) { /* Proceed with possible constant folding. */ break; } @@ -695,8 +754,8 @@ void tcg_optimize(TCGContext *s) if (!have_neg) { break; } - if (temp_is_const(op->args[1]) - && temps[op->args[1]].val == 0) { + if (arg_is_const(op->args[1]) + && arg_info(op->args[1])->val == 0) { op->opc = neg_op; reset_temp(op->args[0]); op->args[1] = op->args[2]; @@ -706,34 +765,34 @@ void tcg_optimize(TCGContext *s) break; CASE_OP_32_64(xor): CASE_OP_32_64(nand): - if (!temp_is_const(op->args[1]) - && temp_is_const(op->args[2]) - && temps[op->args[2]].val == -1) { + if (!arg_is_const(op->args[1]) + && arg_is_const(op->args[2]) + && arg_info(op->args[2])->val == -1) { i = 1; goto try_not; } break; CASE_OP_32_64(nor): - if (!temp_is_const(op->args[1]) - && temp_is_const(op->args[2]) - && temps[op->args[2]].val == 0) { + if (!arg_is_const(op->args[1]) + && arg_is_const(op->args[2]) + && arg_info(op->args[2])->val == 0) { i = 1; goto try_not; } break; CASE_OP_32_64(andc): - if (!temp_is_const(op->args[2]) - && temp_is_const(op->args[1]) - && temps[op->args[1]].val == -1) { + if (!arg_is_const(op->args[2]) + && arg_is_const(op->args[1]) + && arg_info(op->args[1])->val == -1) { i = 2; goto try_not; } break; CASE_OP_32_64(orc): CASE_OP_32_64(eqv): - if (!temp_is_const(op->args[2]) - && temp_is_const(op->args[1]) - && temps[op->args[1]].val == 0) { + if (!arg_is_const(op->args[2]) + && arg_is_const(op->args[1]) + && arg_info(op->args[1])->val == 0) { i = 2; goto try_not; } @@ -774,9 +833,9 @@ void tcg_optimize(TCGContext *s) CASE_OP_32_64(or): CASE_OP_32_64(xor): CASE_OP_32_64(andc): - if (!temp_is_const(op->args[1]) - && temp_is_const(op->args[2]) - && temps[op->args[2]].val == 0) { + if (!arg_is_const(op->args[1]) + && arg_is_const(op->args[2]) + && arg_info(op->args[2])->val == 0) { tcg_opt_gen_mov(s, op, op->args[0], op->args[1]); continue; } @@ -784,9 +843,9 @@ void tcg_optimize(TCGContext *s) CASE_OP_32_64(and): CASE_OP_32_64(orc): CASE_OP_32_64(eqv): - if (!temp_is_const(op->args[1]) - && temp_is_const(op->args[2]) - && temps[op->args[2]].val == -1) { + if (!arg_is_const(op->args[1]) + && arg_is_const(op->args[2]) + && arg_info(op->args[2])->val == -1) { tcg_opt_gen_mov(s, op, op->args[0], op->args[1]); continue; } @@ -801,21 +860,21 @@ void tcg_optimize(TCGContext *s) affected = -1; switch (opc) { CASE_OP_32_64(ext8s): - if ((temps[op->args[1]].mask & 0x80) != 0) { + if ((arg_info(op->args[1])->mask & 0x80) != 0) { break; } CASE_OP_32_64(ext8u): mask = 0xff; goto and_const; CASE_OP_32_64(ext16s): - if ((temps[op->args[1]].mask & 0x8000) != 0) { + if ((arg_info(op->args[1])->mask & 0x8000) != 0) { break; } CASE_OP_32_64(ext16u): mask = 0xffff; goto and_const; case INDEX_op_ext32s_i64: - if ((temps[op->args[1]].mask & 0x80000000) != 0) { + if ((arg_info(op->args[1])->mask & 0x80000000) != 0) { break; } case INDEX_op_ext32u_i64: @@ -823,111 +882,114 @@ void tcg_optimize(TCGContext *s) goto and_const; CASE_OP_32_64(and): - mask = temps[op->args[2]].mask; - if (temp_is_const(op->args[2])) { + mask = arg_info(op->args[2])->mask; + if (arg_is_const(op->args[2])) { and_const: - affected = temps[op->args[1]].mask & ~mask; + affected = arg_info(op->args[1])->mask & ~mask; } - mask = temps[op->args[1]].mask & mask; + mask = arg_info(op->args[1])->mask & mask; break; case INDEX_op_ext_i32_i64: - if ((temps[op->args[1]].mask & 0x80000000) != 0) { + if ((arg_info(op->args[1])->mask & 0x80000000) != 0) { break; } case INDEX_op_extu_i32_i64: /* We do not compute affected as it is a size changing op. */ - mask = (uint32_t)temps[op->args[1]].mask; + mask = (uint32_t)arg_info(op->args[1])->mask; break; CASE_OP_32_64(andc): /* Known-zeros does not imply known-ones. Therefore unless op->args[2] is constant, we can't infer anything from it. */ - if (temp_is_const(op->args[2])) { - mask = ~temps[op->args[2]].mask; + if (arg_is_const(op->args[2])) { + mask = ~arg_info(op->args[2])->mask; goto and_const; } - /* But we certainly know nothing outside op->args[1] may be set. */ - mask = temps[op->args[1]].mask; + /* But we certainly know nothing outside args[1] may be set. */ + mask = arg_info(op->args[1])->mask; break; case INDEX_op_sar_i32: - if (temp_is_const(op->args[2])) { - tmp = temps[op->args[2]].val & 31; - mask = (int32_t)temps[op->args[1]].mask >> tmp; + if (arg_is_const(op->args[2])) { + tmp = arg_info(op->args[2])->val & 31; + mask = (int32_t)arg_info(op->args[1])->mask >> tmp; } break; case INDEX_op_sar_i64: - if (temp_is_const(op->args[2])) { - tmp = temps[op->args[2]].val & 63; - mask = (int64_t)temps[op->args[1]].mask >> tmp; + if (arg_is_const(op->args[2])) { + tmp = arg_info(op->args[2])->val & 63; + mask = (int64_t)arg_info(op->args[1])->mask >> tmp; } break; case INDEX_op_shr_i32: - if (temp_is_const(op->args[2])) { - tmp = temps[op->args[2]].val & 31; - mask = (uint32_t)temps[op->args[1]].mask >> tmp; + if (arg_is_const(op->args[2])) { + tmp = arg_info(op->args[2])->val & 31; + mask = (uint32_t)arg_info(op->args[1])->mask >> tmp; } break; case INDEX_op_shr_i64: - if (temp_is_const(op->args[2])) { - tmp = temps[op->args[2]].val & 63; - mask = (uint64_t)temps[op->args[1]].mask >> tmp; + if (arg_is_const(op->args[2])) { + tmp = arg_info(op->args[2])->val & 63; + mask = (uint64_t)arg_info(op->args[1])->mask >> tmp; } break; case INDEX_op_extrl_i64_i32: - mask = (uint32_t)temps[op->args[1]].mask; + mask = (uint32_t)arg_info(op->args[1])->mask; break; case INDEX_op_extrh_i64_i32: - mask = (uint64_t)temps[op->args[1]].mask >> 32; + mask = (uint64_t)arg_info(op->args[1])->mask >> 32; break; CASE_OP_32_64(shl): - if (temp_is_const(op->args[2])) { - tmp = temps[op->args[2]].val & (TCG_TARGET_REG_BITS - 1); - mask = temps[op->args[1]].mask << tmp; + if (arg_is_const(op->args[2])) { + tmp = arg_info(op->args[2])->val & (TCG_TARGET_REG_BITS - 1); + mask = arg_info(op->args[1])->mask << tmp; } break; CASE_OP_32_64(neg): /* Set to 1 all bits to the left of the rightmost. */ - mask = -(temps[op->args[1]].mask & -temps[op->args[1]].mask); + mask = -(arg_info(op->args[1])->mask + & -arg_info(op->args[1])->mask); break; CASE_OP_32_64(deposit): - mask = deposit64(temps[op->args[1]].mask, op->args[3], - op->args[4], temps[op->args[2]].mask); + mask = deposit64(arg_info(op->args[1])->mask, + op->args[3], op->args[4], + arg_info(op->args[2])->mask); break; CASE_OP_32_64(extract): - mask = extract64(temps[op->args[1]].mask, op->args[2], op->args[3]); + mask = extract64(arg_info(op->args[1])->mask, + op->args[2], op->args[3]); if (op->args[2] == 0) { - affected = temps[op->args[1]].mask & ~mask; + affected = arg_info(op->args[1])->mask & ~mask; } break; CASE_OP_32_64(sextract): - mask = sextract64(temps[op->args[1]].mask, + mask = sextract64(arg_info(op->args[1])->mask, op->args[2], op->args[3]); if (op->args[2] == 0 && (tcg_target_long)mask >= 0) { - affected = temps[op->args[1]].mask & ~mask; + affected = arg_info(op->args[1])->mask & ~mask; } break; CASE_OP_32_64(or): CASE_OP_32_64(xor): - mask = temps[op->args[1]].mask | temps[op->args[2]].mask; + mask = arg_info(op->args[1])->mask | arg_info(op->args[2])->mask; break; case INDEX_op_clz_i32: case INDEX_op_ctz_i32: - mask = temps[op->args[2]].mask | 31; + mask = arg_info(op->args[2])->mask | 31; break; case INDEX_op_clz_i64: case INDEX_op_ctz_i64: - mask = temps[op->args[2]].mask | 63; + mask = arg_info(op->args[2])->mask | 63; break; case INDEX_op_ctpop_i32: @@ -943,7 +1005,7 @@ void tcg_optimize(TCGContext *s) break; CASE_OP_32_64(movcond): - mask = temps[op->args[3]].mask | temps[op->args[4]].mask; + mask = arg_info(op->args[3])->mask | arg_info(op->args[4])->mask; break; CASE_OP_32_64(ld8u): @@ -997,7 +1059,8 @@ void tcg_optimize(TCGContext *s) CASE_OP_32_64(mul): CASE_OP_32_64(muluh): CASE_OP_32_64(mulsh): - if ((temp_is_const(op->args[2]) && temps[op->args[2]].val == 0)) { + if (arg_is_const(op->args[2]) + && arg_info(op->args[2])->val == 0) { tcg_opt_gen_movi(s, op, op->args[0], 0); continue; } @@ -1010,7 +1073,7 @@ void tcg_optimize(TCGContext *s) switch (opc) { CASE_OP_32_64(or): CASE_OP_32_64(and): - if (temps_are_copies(op->args[1], op->args[2])) { + if (args_are_copies(op->args[1], op->args[2])) { tcg_opt_gen_mov(s, op, op->args[0], op->args[1]); continue; } @@ -1024,7 +1087,7 @@ void tcg_optimize(TCGContext *s) CASE_OP_32_64(andc): CASE_OP_32_64(sub): CASE_OP_32_64(xor): - if (temps_are_copies(op->args[1], op->args[2])) { + if (args_are_copies(op->args[1], op->args[2])) { tcg_opt_gen_movi(s, op, op->args[0], 0); continue; } @@ -1057,8 +1120,8 @@ void tcg_optimize(TCGContext *s) case INDEX_op_extu_i32_i64: case INDEX_op_extrl_i64_i32: case INDEX_op_extrh_i64_i32: - if (temp_is_const(op->args[1])) { - tmp = do_constant_folding(opc, temps[op->args[1]].val, 0); + if (arg_is_const(op->args[1])) { + tmp = do_constant_folding(opc, arg_info(op->args[1])->val, 0); tcg_opt_gen_movi(s, op, op->args[0], tmp); break; } @@ -1086,9 +1149,9 @@ void tcg_optimize(TCGContext *s) CASE_OP_32_64(divu): CASE_OP_32_64(rem): CASE_OP_32_64(remu): - if (temp_is_const(op->args[1]) && temp_is_const(op->args[2])) { - tmp = do_constant_folding(opc, temps[op->args[1]].val, - temps[op->args[2]].val); + if (arg_is_const(op->args[1]) && arg_is_const(op->args[2])) { + tmp = do_constant_folding(opc, arg_info(op->args[1])->val, + arg_info(op->args[2])->val); tcg_opt_gen_movi(s, op, op->args[0], tmp); break; } @@ -1096,8 +1159,8 @@ void tcg_optimize(TCGContext *s) CASE_OP_32_64(clz): CASE_OP_32_64(ctz): - if (temp_is_const(op->args[1])) { - TCGArg v = temps[op->args[1]].val; + if (arg_is_const(op->args[1])) { + TCGArg v = arg_info(op->args[1])->val; if (v != 0) { tmp = do_constant_folding(opc, v, 0); tcg_opt_gen_movi(s, op, op->args[0], tmp); @@ -1109,17 +1172,18 @@ void tcg_optimize(TCGContext *s) goto do_default; CASE_OP_32_64(deposit): - if (temp_is_const(op->args[1]) && temp_is_const(op->args[2])) { - tmp = deposit64(temps[op->args[1]].val, op->args[3], - op->args[4], temps[op->args[2]].val); + if (arg_is_const(op->args[1]) && arg_is_const(op->args[2])) { + tmp = deposit64(arg_info(op->args[1])->val, + op->args[3], op->args[4], + arg_info(op->args[2])->val); tcg_opt_gen_movi(s, op, op->args[0], tmp); break; } goto do_default; CASE_OP_32_64(extract): - if (temp_is_const(op->args[1])) { - tmp = extract64(temps[op->args[1]].val, + if (arg_is_const(op->args[1])) { + tmp = extract64(arg_info(op->args[1])->val, op->args[2], op->args[3]); tcg_opt_gen_movi(s, op, op->args[0], tmp); break; @@ -1127,8 +1191,8 @@ void tcg_optimize(TCGContext *s) goto do_default; CASE_OP_32_64(sextract): - if (temp_is_const(op->args[1])) { - tmp = sextract64(temps[op->args[1]].val, + if (arg_is_const(op->args[1])) { + tmp = sextract64(arg_info(op->args[1])->val, op->args[2], op->args[3]); tcg_opt_gen_movi(s, op, op->args[0], tmp); break; @@ -1166,9 +1230,9 @@ void tcg_optimize(TCGContext *s) tcg_opt_gen_mov(s, op, op->args[0], op->args[4-tmp]); break; } - if (temp_is_const(op->args[3]) && temp_is_const(op->args[4])) { - tcg_target_ulong tv = temps[op->args[3]].val; - tcg_target_ulong fv = temps[op->args[4]].val; + if (arg_is_const(op->args[3]) && arg_is_const(op->args[4])) { + tcg_target_ulong tv = arg_info(op->args[3])->val; + tcg_target_ulong fv = arg_info(op->args[4])->val; TCGCond cond = op->args[5]; if (fv == 1 && tv == 0) { cond = tcg_invert_cond(cond); @@ -1185,12 +1249,12 @@ void tcg_optimize(TCGContext *s) case INDEX_op_add2_i32: case INDEX_op_sub2_i32: - if (temp_is_const(op->args[2]) && temp_is_const(op->args[3]) - && temp_is_const(op->args[4]) && temp_is_const(op->args[5])) { - uint32_t al = temps[op->args[2]].val; - uint32_t ah = temps[op->args[3]].val; - uint32_t bl = temps[op->args[4]].val; - uint32_t bh = temps[op->args[5]].val; + if (arg_is_const(op->args[2]) && arg_is_const(op->args[3]) + && arg_is_const(op->args[4]) && arg_is_const(op->args[5])) { + uint32_t al = arg_info(op->args[2])->val; + uint32_t ah = arg_info(op->args[3])->val; + uint32_t bl = arg_info(op->args[4])->val; + uint32_t bh = arg_info(op->args[5])->val; uint64_t a = ((uint64_t)ah << 32) | al; uint64_t b = ((uint64_t)bh << 32) | bl; TCGArg rl, rh; @@ -1214,9 +1278,9 @@ void tcg_optimize(TCGContext *s) goto do_default; case INDEX_op_mulu2_i32: - if (temp_is_const(op->args[2]) && temp_is_const(op->args[3])) { - uint32_t a = temps[op->args[2]].val; - uint32_t b = temps[op->args[3]].val; + if (arg_is_const(op->args[2]) && arg_is_const(op->args[3])) { + uint32_t a = arg_info(op->args[2])->val; + uint32_t b = arg_info(op->args[3])->val; uint64_t r = (uint64_t)a * b; TCGArg rl, rh; TCGOp *op2 = tcg_op_insert_before(s, op, INDEX_op_movi_i32, 2); @@ -1247,10 +1311,10 @@ void tcg_optimize(TCGContext *s) } } else if ((op->args[4] == TCG_COND_LT || op->args[4] == TCG_COND_GE) - && temp_is_const(op->args[2]) - && temps[op->args[2]].val == 0 - && temp_is_const(op->args[3]) - && temps[op->args[3]].val == 0) { + && arg_is_const(op->args[2]) + && arg_info(op->args[2])->val == 0 + && arg_is_const(op->args[3]) + && arg_info(op->args[3])->val == 0) { /* Simplify LT/GE comparisons vs zero to a single compare vs the high word of the input. */ do_brcond_high: @@ -1318,15 +1382,15 @@ void tcg_optimize(TCGContext *s) tcg_opt_gen_movi(s, op, op->args[0], tmp); } else if ((op->args[5] == TCG_COND_LT || op->args[5] == TCG_COND_GE) - && temp_is_const(op->args[3]) - && temps[op->args[3]].val == 0 - && temp_is_const(op->args[4]) - && temps[op->args[4]].val == 0) { + && arg_is_const(op->args[3]) + && arg_info(op->args[3])->val == 0 + && arg_is_const(op->args[4]) + && arg_info(op->args[4])->val == 0) { /* Simplify LT/GE comparisons vs zero to a single compare vs the high word of the input. */ do_setcond_high: reset_temp(op->args[0]); - temps[op->args[0]].mask = 1; + arg_info(op->args[0])->mask = 1; op->opc = INDEX_op_setcond_i32; op->args[1] = op->args[2]; op->args[2] = op->args[4]; @@ -1352,7 +1416,7 @@ void tcg_optimize(TCGContext *s) } do_setcond_low: reset_temp(op->args[0]); - temps[op->args[0]].mask = 1; + arg_info(op->args[0])->mask = 1; op->opc = INDEX_op_setcond_i32; op->args[2] = op->args[3]; op->args[3] = op->args[5]; @@ -1386,7 +1450,7 @@ void tcg_optimize(TCGContext *s) & (TCG_CALL_NO_READ_GLOBALS | TCG_CALL_NO_WRITE_GLOBALS))) { for (i = 0; i < nb_globals; i++) { if (test_bit(i, temps_used.l)) { - reset_temp(i); + reset_ts(&s->temps[i]); } } } @@ -1408,7 +1472,7 @@ void tcg_optimize(TCGContext *s) /* Save the corresponding known-zero bits mask for the first output argument (only one supported so far). */ if (i == 0) { - temps[op->args[i]].mask = mask; + arg_info(op->args[i])->mask = mask; } } } From patchwork Mon Oct 16 17:25:34 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 115938 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp3938859qgn; Mon, 16 Oct 2017 10:32:23 -0700 (PDT) X-Received: by 10.200.2.175 with SMTP id p47mr14192403qtg.242.1508175143034; Mon, 16 Oct 2017 10:32:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508175143; cv=none; d=google.com; s=arc-20160816; b=TT/UYc+A8tetnfL6HD3kDiPRbHzfMhaDTbfzTE24UuBa18z6wnwoPQaf5kpQ+y6NEM o/waVKxNbAsbOipbE/wjnA00ZrTDFcw3BlphGOzwncAqxYQ4+KYYxvoHsbey4kh4EZnu 6TjjpRvqyJxeOLLDMc10ZoYHYbpwYQT0QFdAP9V88D7NpB3i3vp7JSchDiR6XldBXsCK QObE5l5SK4FhV0DzmB7zKw+VmYO6cWQa63XFRCyUce/8sADsbPzE0IoghBrWdVTMJ9uC yKhWQKrmFQ5GI1ojzLYJYOyEBY1kbBamuDlT8hjB04T0DHShQwAiqDPA4CtEDTrAn1OD oGkw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=JnxhZ6QkDEKz2BBvJC2eHU0k3b3glcIqDd+NPuRB7uk=; b=DeDBfIDWW25SCHWVqqE9mLjPDPj+uux6ce3rQWLn07tTzkZT5zAd1keutpByUx84qI R7YSqNVLIipsEo7TaENEFyIuas09hTFltmeLQxKr0UsIqTBHye/v09VPHy8JdAaAKfen 8sDb6zBKrgQMrN2+T9QJZ63k+GbGosOq6EIoMKFUyKoZNC735wNZN05NwEnxT8HUYV1s x5NmuDBFsqeq7klXXMDxtls/mTLN5DDiY8kHvBIVouE9EboSCmWUjCCGkZp0WGV0tg6I 2QDwkBNtj3OH6AO87mjSJLehOlks1mehJOKgttoqsYp2i1bhWFMGDk/qKROoHMc9cutj Mm2A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=PJjCOZ6/; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id b190si5584517qkd.189.2017.10.16.10.32.22 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 16 Oct 2017 10:32:23 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=PJjCOZ6/; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:34320 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e49FU-0007JZ-I1 for patch@linaro.org; Mon, 16 Oct 2017 13:32:20 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52343) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e499x-0002AB-Gc for qemu-devel@nongnu.org; Mon, 16 Oct 2017 13:26:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e499v-0003U3-CE for qemu-devel@nongnu.org; Mon, 16 Oct 2017 13:26:37 -0400 Received: from mail-pg0-x235.google.com ([2607:f8b0:400e:c05::235]:55270) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e499v-0003TR-4V for qemu-devel@nongnu.org; Mon, 16 Oct 2017 13:26:35 -0400 Received: by mail-pg0-x235.google.com with SMTP id l24so7293079pgu.11 for ; Mon, 16 Oct 2017 10:26:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=JnxhZ6QkDEKz2BBvJC2eHU0k3b3glcIqDd+NPuRB7uk=; b=PJjCOZ6/E+IwAC4zeUXSUV7d1HYFZKocyDywMwH3/dBb5xDD5HjL0EydFjLPVM7VJ9 EfVDIr4ifTijPsEn+FtMDjWNTkOzCCzsyiRW2VPS5J2m/IjFs2uC6lIwgJ2AUhMKLTqG rVuWlXXAjMMx0uVvYd92JXl/GJvY9djh6OY80= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=JnxhZ6QkDEKz2BBvJC2eHU0k3b3glcIqDd+NPuRB7uk=; b=Ak7fPXhmGFM+jELp6UMgrOZkvOZFOCROvACoAcTkKccXpdslPSVlqOUKFkCBnEY4j8 KfSmJZWL1f2dKmPPVNubswz0KfhLVjcjX560LC+Y7tmlvoT+j1B3KHTwx85jRuttzios 1kKpjf/+jQD9eFwapqBlFfsIcpBc8r/L60HY+B0QQBUrAoQ3+US74GPfDdXU+dKUjstz ya6FX5Y4rjotknZ73+yb1W+3AzDjt8RcHJVSPLf2cw0hmoHwc2j6ElfhzkGLvAz9utQ8 GutvJCRIQDUg1vX+BeasvvArlfDoJ3Ui7YTPSWggDfnfxCJVw6RGDPN46wh+0mx8eaPF 4GyQ== X-Gm-Message-State: AMCzsaW7uMbz+rVza09duqErlTUESCHTW49NM+yvQ5jVW4+Jdmw2nvvS npU28P5OADs+YDEgMbLdPARFYyycpLQ= X-Google-Smtp-Source: AOwi7QBeDKAEtkSgP/yy3/BULs3a8Moca6yY6Jtmq1btmtzqjZv+ZLMhEV/O/yIM3Gc4ED/8vBNQzQ== X-Received: by 10.84.210.166 with SMTP id a35mr9718700pli.426.1508174793765; Mon, 16 Oct 2017 10:26:33 -0700 (PDT) Received: from cloudburst.twiddle.net (97-126-104-76.tukw.qwest.net. [97.126.104.76]) by smtp.gmail.com with ESMTPSA id i187sm5594249pfc.96.2017.10.16.10.26.32 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 16 Oct 2017 10:26:32 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Mon, 16 Oct 2017 10:25:34 -0700 Message-Id: <20171016172609.23422-16-richard.henderson@linaro.org> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171016172609.23422-1-richard.henderson@linaro.org> References: <20171016172609.23422-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c05::235 Subject: [Qemu-devel] [PATCH v6 15/50] tcg: Push tcg_ctx into generator functions 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: cota@braap.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Richard Henderson --- tcg/tcg-op.h | 100 +++++++++++++++++++++++++++-------------------------------- tcg/tcg-op.c | 47 ++++++++++++++-------------- 2 files changed, 69 insertions(+), 78 deletions(-) -- 2.13.6 Reviewed-by: Emilio G. Cota diff --git a/tcg/tcg-op.h b/tcg/tcg-op.h index 18d01b2f43..de9a61206a 100644 --- a/tcg/tcg-op.h +++ b/tcg/tcg-op.h @@ -28,173 +28,166 @@ /* Basic output routines. Not for general consumption. */ -void tcg_gen_op1(TCGContext *, TCGOpcode, TCGArg); -void tcg_gen_op2(TCGContext *, TCGOpcode, TCGArg, TCGArg); -void tcg_gen_op3(TCGContext *, TCGOpcode, TCGArg, TCGArg, TCGArg); -void tcg_gen_op4(TCGContext *, TCGOpcode, TCGArg, TCGArg, TCGArg, TCGArg); -void tcg_gen_op5(TCGContext *, TCGOpcode, TCGArg, TCGArg, TCGArg, - TCGArg, TCGArg); -void tcg_gen_op6(TCGContext *, TCGOpcode, TCGArg, TCGArg, TCGArg, - TCGArg, TCGArg, TCGArg); - +void tcg_gen_op1(TCGOpcode, TCGArg); +void tcg_gen_op2(TCGOpcode, TCGArg, TCGArg); +void tcg_gen_op3(TCGOpcode, TCGArg, TCGArg, TCGArg); +void tcg_gen_op4(TCGOpcode, TCGArg, TCGArg, TCGArg, TCGArg); +void tcg_gen_op5(TCGOpcode, TCGArg, TCGArg, TCGArg, TCGArg, TCGArg); +void tcg_gen_op6(TCGOpcode, TCGArg, TCGArg, TCGArg, TCGArg, TCGArg, TCGArg); static inline void tcg_gen_op1_i32(TCGOpcode opc, TCGv_i32 a1) { - tcg_gen_op1(&tcg_ctx, opc, GET_TCGV_I32(a1)); + tcg_gen_op1(opc, GET_TCGV_I32(a1)); } static inline void tcg_gen_op1_i64(TCGOpcode opc, TCGv_i64 a1) { - tcg_gen_op1(&tcg_ctx, opc, GET_TCGV_I64(a1)); + tcg_gen_op1(opc, GET_TCGV_I64(a1)); } static inline void tcg_gen_op1i(TCGOpcode opc, TCGArg a1) { - tcg_gen_op1(&tcg_ctx, opc, a1); + tcg_gen_op1(opc, a1); } static inline void tcg_gen_op2_i32(TCGOpcode opc, TCGv_i32 a1, TCGv_i32 a2) { - tcg_gen_op2(&tcg_ctx, opc, GET_TCGV_I32(a1), GET_TCGV_I32(a2)); + tcg_gen_op2(opc, GET_TCGV_I32(a1), GET_TCGV_I32(a2)); } static inline void tcg_gen_op2_i64(TCGOpcode opc, TCGv_i64 a1, TCGv_i64 a2) { - tcg_gen_op2(&tcg_ctx, opc, GET_TCGV_I64(a1), GET_TCGV_I64(a2)); + tcg_gen_op2(opc, GET_TCGV_I64(a1), GET_TCGV_I64(a2)); } static inline void tcg_gen_op2i_i32(TCGOpcode opc, TCGv_i32 a1, TCGArg a2) { - tcg_gen_op2(&tcg_ctx, opc, GET_TCGV_I32(a1), a2); + tcg_gen_op2(opc, GET_TCGV_I32(a1), a2); } static inline void tcg_gen_op2i_i64(TCGOpcode opc, TCGv_i64 a1, TCGArg a2) { - tcg_gen_op2(&tcg_ctx, opc, GET_TCGV_I64(a1), a2); + tcg_gen_op2(opc, GET_TCGV_I64(a1), a2); } static inline void tcg_gen_op2ii(TCGOpcode opc, TCGArg a1, TCGArg a2) { - tcg_gen_op2(&tcg_ctx, opc, a1, a2); + tcg_gen_op2(opc, a1, a2); } static inline void tcg_gen_op3_i32(TCGOpcode opc, TCGv_i32 a1, TCGv_i32 a2, TCGv_i32 a3) { - tcg_gen_op3(&tcg_ctx, opc, GET_TCGV_I32(a1), - GET_TCGV_I32(a2), GET_TCGV_I32(a3)); + tcg_gen_op3(opc, GET_TCGV_I32(a1), GET_TCGV_I32(a2), GET_TCGV_I32(a3)); } static inline void tcg_gen_op3_i64(TCGOpcode opc, TCGv_i64 a1, TCGv_i64 a2, TCGv_i64 a3) { - tcg_gen_op3(&tcg_ctx, opc, GET_TCGV_I64(a1), - GET_TCGV_I64(a2), GET_TCGV_I64(a3)); + tcg_gen_op3(opc, GET_TCGV_I64(a1), GET_TCGV_I64(a2), GET_TCGV_I64(a3)); } static inline void tcg_gen_op3i_i32(TCGOpcode opc, TCGv_i32 a1, TCGv_i32 a2, TCGArg a3) { - tcg_gen_op3(&tcg_ctx, opc, GET_TCGV_I32(a1), GET_TCGV_I32(a2), a3); + tcg_gen_op3(opc, GET_TCGV_I32(a1), GET_TCGV_I32(a2), a3); } static inline void tcg_gen_op3i_i64(TCGOpcode opc, TCGv_i64 a1, TCGv_i64 a2, TCGArg a3) { - tcg_gen_op3(&tcg_ctx, opc, GET_TCGV_I64(a1), GET_TCGV_I64(a2), a3); + tcg_gen_op3(opc, GET_TCGV_I64(a1), GET_TCGV_I64(a2), a3); } static inline void tcg_gen_ldst_op_i32(TCGOpcode opc, TCGv_i32 val, TCGv_ptr base, TCGArg offset) { - tcg_gen_op3(&tcg_ctx, opc, GET_TCGV_I32(val), GET_TCGV_PTR(base), offset); + tcg_gen_op3(opc, GET_TCGV_I32(val), GET_TCGV_PTR(base), offset); } static inline void tcg_gen_ldst_op_i64(TCGOpcode opc, TCGv_i64 val, TCGv_ptr base, TCGArg offset) { - tcg_gen_op3(&tcg_ctx, opc, GET_TCGV_I64(val), GET_TCGV_PTR(base), offset); + tcg_gen_op3(opc, GET_TCGV_I64(val), GET_TCGV_PTR(base), offset); } static inline void tcg_gen_op4_i32(TCGOpcode opc, TCGv_i32 a1, TCGv_i32 a2, TCGv_i32 a3, TCGv_i32 a4) { - tcg_gen_op4(&tcg_ctx, opc, GET_TCGV_I32(a1), GET_TCGV_I32(a2), + tcg_gen_op4(opc, GET_TCGV_I32(a1), GET_TCGV_I32(a2), GET_TCGV_I32(a3), GET_TCGV_I32(a4)); } static inline void tcg_gen_op4_i64(TCGOpcode opc, TCGv_i64 a1, TCGv_i64 a2, TCGv_i64 a3, TCGv_i64 a4) { - tcg_gen_op4(&tcg_ctx, opc, GET_TCGV_I64(a1), GET_TCGV_I64(a2), + tcg_gen_op4(opc, GET_TCGV_I64(a1), GET_TCGV_I64(a2), GET_TCGV_I64(a3), GET_TCGV_I64(a4)); } static inline void tcg_gen_op4i_i32(TCGOpcode opc, TCGv_i32 a1, TCGv_i32 a2, TCGv_i32 a3, TCGArg a4) { - tcg_gen_op4(&tcg_ctx, opc, GET_TCGV_I32(a1), GET_TCGV_I32(a2), - GET_TCGV_I32(a3), a4); + tcg_gen_op4(opc, GET_TCGV_I32(a1), GET_TCGV_I32(a2), GET_TCGV_I32(a3), a4); } static inline void tcg_gen_op4i_i64(TCGOpcode opc, TCGv_i64 a1, TCGv_i64 a2, TCGv_i64 a3, TCGArg a4) { - tcg_gen_op4(&tcg_ctx, opc, GET_TCGV_I64(a1), GET_TCGV_I64(a2), - GET_TCGV_I64(a3), a4); + tcg_gen_op4(opc, GET_TCGV_I64(a1), GET_TCGV_I64(a2), GET_TCGV_I64(a3), a4); } static inline void tcg_gen_op4ii_i32(TCGOpcode opc, TCGv_i32 a1, TCGv_i32 a2, TCGArg a3, TCGArg a4) { - tcg_gen_op4(&tcg_ctx, opc, GET_TCGV_I32(a1), GET_TCGV_I32(a2), a3, a4); + tcg_gen_op4(opc, GET_TCGV_I32(a1), GET_TCGV_I32(a2), a3, a4); } static inline void tcg_gen_op4ii_i64(TCGOpcode opc, TCGv_i64 a1, TCGv_i64 a2, TCGArg a3, TCGArg a4) { - tcg_gen_op4(&tcg_ctx, opc, GET_TCGV_I64(a1), GET_TCGV_I64(a2), a3, a4); + tcg_gen_op4(opc, GET_TCGV_I64(a1), GET_TCGV_I64(a2), a3, a4); } static inline void tcg_gen_op5_i32(TCGOpcode opc, TCGv_i32 a1, TCGv_i32 a2, TCGv_i32 a3, TCGv_i32 a4, TCGv_i32 a5) { - tcg_gen_op5(&tcg_ctx, opc, GET_TCGV_I32(a1), GET_TCGV_I32(a2), + tcg_gen_op5(opc, GET_TCGV_I32(a1), GET_TCGV_I32(a2), GET_TCGV_I32(a3), GET_TCGV_I32(a4), GET_TCGV_I32(a5)); } static inline void tcg_gen_op5_i64(TCGOpcode opc, TCGv_i64 a1, TCGv_i64 a2, TCGv_i64 a3, TCGv_i64 a4, TCGv_i64 a5) { - tcg_gen_op5(&tcg_ctx, opc, GET_TCGV_I64(a1), GET_TCGV_I64(a2), + tcg_gen_op5(opc, GET_TCGV_I64(a1), GET_TCGV_I64(a2), GET_TCGV_I64(a3), GET_TCGV_I64(a4), GET_TCGV_I64(a5)); } static inline void tcg_gen_op5i_i32(TCGOpcode opc, TCGv_i32 a1, TCGv_i32 a2, TCGv_i32 a3, TCGv_i32 a4, TCGArg a5) { - tcg_gen_op5(&tcg_ctx, opc, GET_TCGV_I32(a1), GET_TCGV_I32(a2), + tcg_gen_op5(opc, GET_TCGV_I32(a1), GET_TCGV_I32(a2), GET_TCGV_I32(a3), GET_TCGV_I32(a4), a5); } static inline void tcg_gen_op5i_i64(TCGOpcode opc, TCGv_i64 a1, TCGv_i64 a2, TCGv_i64 a3, TCGv_i64 a4, TCGArg a5) { - tcg_gen_op5(&tcg_ctx, opc, GET_TCGV_I64(a1), GET_TCGV_I64(a2), + tcg_gen_op5(opc, GET_TCGV_I64(a1), GET_TCGV_I64(a2), GET_TCGV_I64(a3), GET_TCGV_I64(a4), a5); } static inline void tcg_gen_op5ii_i32(TCGOpcode opc, TCGv_i32 a1, TCGv_i32 a2, TCGv_i32 a3, TCGArg a4, TCGArg a5) { - tcg_gen_op5(&tcg_ctx, opc, GET_TCGV_I32(a1), GET_TCGV_I32(a2), + tcg_gen_op5(opc, GET_TCGV_I32(a1), GET_TCGV_I32(a2), GET_TCGV_I32(a3), a4, a5); } static inline void tcg_gen_op5ii_i64(TCGOpcode opc, TCGv_i64 a1, TCGv_i64 a2, TCGv_i64 a3, TCGArg a4, TCGArg a5) { - tcg_gen_op5(&tcg_ctx, opc, GET_TCGV_I64(a1), GET_TCGV_I64(a2), + tcg_gen_op5(opc, GET_TCGV_I64(a1), GET_TCGV_I64(a2), GET_TCGV_I64(a3), a4, a5); } @@ -202,7 +195,7 @@ static inline void tcg_gen_op6_i32(TCGOpcode opc, TCGv_i32 a1, TCGv_i32 a2, TCGv_i32 a3, TCGv_i32 a4, TCGv_i32 a5, TCGv_i32 a6) { - tcg_gen_op6(&tcg_ctx, opc, GET_TCGV_I32(a1), GET_TCGV_I32(a2), + tcg_gen_op6(opc, GET_TCGV_I32(a1), GET_TCGV_I32(a2), GET_TCGV_I32(a3), GET_TCGV_I32(a4), GET_TCGV_I32(a5), GET_TCGV_I32(a6)); } @@ -211,7 +204,7 @@ static inline void tcg_gen_op6_i64(TCGOpcode opc, TCGv_i64 a1, TCGv_i64 a2, TCGv_i64 a3, TCGv_i64 a4, TCGv_i64 a5, TCGv_i64 a6) { - tcg_gen_op6(&tcg_ctx, opc, GET_TCGV_I64(a1), GET_TCGV_I64(a2), + tcg_gen_op6(opc, GET_TCGV_I64(a1), GET_TCGV_I64(a2), GET_TCGV_I64(a3), GET_TCGV_I64(a4), GET_TCGV_I64(a5), GET_TCGV_I64(a6)); } @@ -220,7 +213,7 @@ static inline void tcg_gen_op6i_i32(TCGOpcode opc, TCGv_i32 a1, TCGv_i32 a2, TCGv_i32 a3, TCGv_i32 a4, TCGv_i32 a5, TCGArg a6) { - tcg_gen_op6(&tcg_ctx, opc, GET_TCGV_I32(a1), GET_TCGV_I32(a2), + tcg_gen_op6(opc, GET_TCGV_I32(a1), GET_TCGV_I32(a2), GET_TCGV_I32(a3), GET_TCGV_I32(a4), GET_TCGV_I32(a5), a6); } @@ -228,7 +221,7 @@ static inline void tcg_gen_op6i_i64(TCGOpcode opc, TCGv_i64 a1, TCGv_i64 a2, TCGv_i64 a3, TCGv_i64 a4, TCGv_i64 a5, TCGArg a6) { - tcg_gen_op6(&tcg_ctx, opc, GET_TCGV_I64(a1), GET_TCGV_I64(a2), + tcg_gen_op6(opc, GET_TCGV_I64(a1), GET_TCGV_I64(a2), GET_TCGV_I64(a3), GET_TCGV_I64(a4), GET_TCGV_I64(a5), a6); } @@ -236,7 +229,7 @@ static inline void tcg_gen_op6ii_i32(TCGOpcode opc, TCGv_i32 a1, TCGv_i32 a2, TCGv_i32 a3, TCGv_i32 a4, TCGArg a5, TCGArg a6) { - tcg_gen_op6(&tcg_ctx, opc, GET_TCGV_I32(a1), GET_TCGV_I32(a2), + tcg_gen_op6(opc, GET_TCGV_I32(a1), GET_TCGV_I32(a2), GET_TCGV_I32(a3), GET_TCGV_I32(a4), a5, a6); } @@ -244,7 +237,7 @@ static inline void tcg_gen_op6ii_i64(TCGOpcode opc, TCGv_i64 a1, TCGv_i64 a2, TCGv_i64 a3, TCGv_i64 a4, TCGArg a5, TCGArg a6) { - tcg_gen_op6(&tcg_ctx, opc, GET_TCGV_I64(a1), GET_TCGV_I64(a2), + tcg_gen_op6(opc, GET_TCGV_I64(a1), GET_TCGV_I64(a2), GET_TCGV_I64(a3), GET_TCGV_I64(a4), a5, a6); } @@ -253,12 +246,12 @@ static inline void tcg_gen_op6ii_i64(TCGOpcode opc, TCGv_i64 a1, TCGv_i64 a2, static inline void gen_set_label(TCGLabel *l) { - tcg_gen_op1(&tcg_ctx, INDEX_op_set_label, label_arg(l)); + tcg_gen_op1(INDEX_op_set_label, label_arg(l)); } static inline void tcg_gen_br(TCGLabel *l) { - tcg_gen_op1(&tcg_ctx, INDEX_op_br, label_arg(l)); + tcg_gen_op1(INDEX_op_br, label_arg(l)); } void tcg_gen_mb(TCGBar); @@ -732,25 +725,24 @@ static inline void tcg_gen_concat32_i64(TCGv_i64 ret, TCGv_i64 lo, TCGv_i64 hi) # if TARGET_LONG_BITS <= TCG_TARGET_REG_BITS static inline void tcg_gen_insn_start(target_ulong pc) { - tcg_gen_op1(&tcg_ctx, INDEX_op_insn_start, pc); + tcg_gen_op1(INDEX_op_insn_start, pc); } # else static inline void tcg_gen_insn_start(target_ulong pc) { - tcg_gen_op2(&tcg_ctx, INDEX_op_insn_start, - (uint32_t)pc, (uint32_t)(pc >> 32)); + tcg_gen_op2(INDEX_op_insn_start, (uint32_t)pc, (uint32_t)(pc >> 32)); } # endif #elif TARGET_INSN_START_WORDS == 2 # if TARGET_LONG_BITS <= TCG_TARGET_REG_BITS static inline void tcg_gen_insn_start(target_ulong pc, target_ulong a1) { - tcg_gen_op2(&tcg_ctx, INDEX_op_insn_start, pc, a1); + tcg_gen_op2(INDEX_op_insn_start, pc, a1); } # else static inline void tcg_gen_insn_start(target_ulong pc, target_ulong a1) { - tcg_gen_op4(&tcg_ctx, INDEX_op_insn_start, + tcg_gen_op4(INDEX_op_insn_start, (uint32_t)pc, (uint32_t)(pc >> 32), (uint32_t)a1, (uint32_t)(a1 >> 32)); } @@ -760,13 +752,13 @@ static inline void tcg_gen_insn_start(target_ulong pc, target_ulong a1) static inline void tcg_gen_insn_start(target_ulong pc, target_ulong a1, target_ulong a2) { - tcg_gen_op3(&tcg_ctx, INDEX_op_insn_start, pc, a1, a2); + tcg_gen_op3(INDEX_op_insn_start, pc, a1, a2); } # else static inline void tcg_gen_insn_start(target_ulong pc, target_ulong a1, target_ulong a2) { - tcg_gen_op6(&tcg_ctx, INDEX_op_insn_start, + tcg_gen_op6(INDEX_op_insn_start, (uint32_t)pc, (uint32_t)(pc >> 32), (uint32_t)a1, (uint32_t)(a1 >> 32), (uint32_t)a2, (uint32_t)(a2 >> 32)); diff --git a/tcg/tcg-op.c b/tcg/tcg-op.c index bd84a782e3..bff4b95097 100644 --- a/tcg/tcg-op.c +++ b/tcg/tcg-op.c @@ -46,8 +46,9 @@ extern TCGv_i32 TCGV_HIGH_link_error(TCGv_i64); Up to and including filling in the forward link immediately. We'll do proper termination of the end of the list after we finish translation. */ -static inline TCGOp *tcg_emit_op(TCGContext *ctx, TCGOpcode opc) +static inline TCGOp *tcg_emit_op(TCGOpcode opc) { + TCGContext *ctx = &tcg_ctx; int oi = ctx->gen_next_op_idx; int ni = oi + 1; int pi = oi - 1; @@ -65,42 +66,40 @@ static inline TCGOp *tcg_emit_op(TCGContext *ctx, TCGOpcode opc) return op; } -void tcg_gen_op1(TCGContext *ctx, TCGOpcode opc, TCGArg a1) +void tcg_gen_op1(TCGOpcode opc, TCGArg a1) { - TCGOp *op = tcg_emit_op(ctx, opc); + TCGOp *op = tcg_emit_op(opc); op->args[0] = a1; } -void tcg_gen_op2(TCGContext *ctx, TCGOpcode opc, TCGArg a1, TCGArg a2) +void tcg_gen_op2(TCGOpcode opc, TCGArg a1, TCGArg a2) { - TCGOp *op = tcg_emit_op(ctx, opc); + TCGOp *op = tcg_emit_op(opc); op->args[0] = a1; op->args[1] = a2; } -void tcg_gen_op3(TCGContext *ctx, TCGOpcode opc, TCGArg a1, - TCGArg a2, TCGArg a3) +void tcg_gen_op3(TCGOpcode opc, TCGArg a1, TCGArg a2, TCGArg a3) { - TCGOp *op = tcg_emit_op(ctx, opc); + TCGOp *op = tcg_emit_op(opc); op->args[0] = a1; op->args[1] = a2; op->args[2] = a3; } -void tcg_gen_op4(TCGContext *ctx, TCGOpcode opc, TCGArg a1, - TCGArg a2, TCGArg a3, TCGArg a4) +void tcg_gen_op4(TCGOpcode opc, TCGArg a1, TCGArg a2, TCGArg a3, TCGArg a4) { - TCGOp *op = tcg_emit_op(ctx, opc); + TCGOp *op = tcg_emit_op(opc); op->args[0] = a1; op->args[1] = a2; op->args[2] = a3; op->args[3] = a4; } -void tcg_gen_op5(TCGContext *ctx, TCGOpcode opc, TCGArg a1, - TCGArg a2, TCGArg a3, TCGArg a4, TCGArg a5) +void tcg_gen_op5(TCGOpcode opc, TCGArg a1, TCGArg a2, TCGArg a3, + TCGArg a4, TCGArg a5) { - TCGOp *op = tcg_emit_op(ctx, opc); + TCGOp *op = tcg_emit_op(opc); op->args[0] = a1; op->args[1] = a2; op->args[2] = a3; @@ -108,10 +107,10 @@ void tcg_gen_op5(TCGContext *ctx, TCGOpcode opc, TCGArg a1, op->args[4] = a5; } -void tcg_gen_op6(TCGContext *ctx, TCGOpcode opc, TCGArg a1, TCGArg a2, - TCGArg a3, TCGArg a4, TCGArg a5, TCGArg a6) +void tcg_gen_op6(TCGOpcode opc, TCGArg a1, TCGArg a2, TCGArg a3, + TCGArg a4, TCGArg a5, TCGArg a6) { - TCGOp *op = tcg_emit_op(ctx, opc); + TCGOp *op = tcg_emit_op(opc); op->args[0] = a1; op->args[1] = a2; op->args[2] = a3; @@ -123,7 +122,7 @@ void tcg_gen_op6(TCGContext *ctx, TCGOpcode opc, TCGArg a1, TCGArg a2, void tcg_gen_mb(TCGBar mb_type) { if (parallel_cpus) { - tcg_gen_op1(&tcg_ctx, INDEX_op_mb, mb_type); + tcg_gen_op1(INDEX_op_mb, mb_type); } } @@ -2458,7 +2457,7 @@ void tcg_gen_extrl_i64_i32(TCGv_i32 ret, TCGv_i64 arg) if (TCG_TARGET_REG_BITS == 32) { tcg_gen_mov_i32(ret, TCGV_LOW(arg)); } else if (TCG_TARGET_HAS_extrl_i64_i32) { - tcg_gen_op2(&tcg_ctx, INDEX_op_extrl_i64_i32, + tcg_gen_op2(INDEX_op_extrl_i64_i32, GET_TCGV_I32(ret), GET_TCGV_I64(arg)); } else { tcg_gen_mov_i32(ret, MAKE_TCGV_I32(GET_TCGV_I64(arg))); @@ -2470,7 +2469,7 @@ void tcg_gen_extrh_i64_i32(TCGv_i32 ret, TCGv_i64 arg) if (TCG_TARGET_REG_BITS == 32) { tcg_gen_mov_i32(ret, TCGV_HIGH(arg)); } else if (TCG_TARGET_HAS_extrh_i64_i32) { - tcg_gen_op2(&tcg_ctx, INDEX_op_extrh_i64_i32, + tcg_gen_op2(INDEX_op_extrh_i64_i32, GET_TCGV_I32(ret), GET_TCGV_I64(arg)); } else { TCGv_i64 t = tcg_temp_new_i64(); @@ -2486,7 +2485,7 @@ void tcg_gen_extu_i32_i64(TCGv_i64 ret, TCGv_i32 arg) tcg_gen_mov_i32(TCGV_LOW(ret), arg); tcg_gen_movi_i32(TCGV_HIGH(ret), 0); } else { - tcg_gen_op2(&tcg_ctx, INDEX_op_extu_i32_i64, + tcg_gen_op2(INDEX_op_extu_i32_i64, GET_TCGV_I64(ret), GET_TCGV_I32(arg)); } } @@ -2497,7 +2496,7 @@ void tcg_gen_ext_i32_i64(TCGv_i64 ret, TCGv_i32 arg) tcg_gen_mov_i32(TCGV_LOW(ret), arg); tcg_gen_sari_i32(TCGV_HIGH(ret), TCGV_LOW(ret), 31); } else { - tcg_gen_op2(&tcg_ctx, INDEX_op_ext_i32_i64, + tcg_gen_op2(INDEX_op_ext_i32_i64, GET_TCGV_I64(ret), GET_TCGV_I32(arg)); } } @@ -2609,7 +2608,7 @@ static void gen_ldst_i32(TCGOpcode opc, TCGv_i32 val, TCGv addr, if (TCG_TARGET_REG_BITS == 32) { tcg_gen_op4i_i32(opc, val, TCGV_LOW(addr), TCGV_HIGH(addr), oi); } else { - tcg_gen_op3(&tcg_ctx, opc, GET_TCGV_I32(val), GET_TCGV_I64(addr), oi); + tcg_gen_op3(opc, GET_TCGV_I32(val), GET_TCGV_I64(addr), oi); } #endif } @@ -2622,7 +2621,7 @@ static void gen_ldst_i64(TCGOpcode opc, TCGv_i64 val, TCGv addr, if (TCG_TARGET_REG_BITS == 32) { tcg_gen_op4i_i32(opc, TCGV_LOW(val), TCGV_HIGH(val), addr, oi); } else { - tcg_gen_op3(&tcg_ctx, opc, GET_TCGV_I64(val), GET_TCGV_I32(addr), oi); + tcg_gen_op3(opc, GET_TCGV_I64(val), GET_TCGV_I32(addr), oi); } #else if (TCG_TARGET_REG_BITS == 32) { From patchwork Mon Oct 16 17:25:35 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 115939 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp3941266qgn; Mon, 16 Oct 2017 10:34:52 -0700 (PDT) X-Received: by 10.237.38.36 with SMTP id z33mr15067996qtc.258.1508175292912; Mon, 16 Oct 2017 10:34:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508175292; cv=none; d=google.com; s=arc-20160816; b=rmA2cK4SkAy3cDMy05pT6sO2/Zo14XGVVmcTaORcL3SJXyQ2Oi3jWS3L+blVVJoIyw EUhkqCn51epmwoZbDvtWXuSsWmkthOnLvKiQDe1uuxNIri7EeT+5kRIrS7jPdfcQ3nNT RtpjGJKm16jMFO/zUe/egBeQkTkEv9q7l5Yn3t6nAdHLAmznHk01ePSdLuhO2wTUkdhm ZSPJo8DGkeVX6b6BMrIlb63FggEhsc9fGUEzSmMIm9WnDBzkbkFhIUaBBX/J/3JR2O+T wKL/vSE2MqTFi70u35q1P3F6X1a1LsMdU6Y27CLOGiriPdOYtb7qhvr/qhVVCJoOiv7v TAIA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=1kQwh+6emE+i8dPPDChMVGTTzNWDPNxpy5NPSlnmM1o=; b=Syp1bC4GrA13+TecBzq7dlZwhRd89aFO/8WbTpmzhQi1+7414zWPmEdLFZadPMDlj5 TPvamqP4x9JniTzQ34BiLSZFqlKL3xG9aEozyHL53TJVNvQWAKB3/szAob0ioV1y+jwK wGvPQZQaAO19LVfCzY0p3nwbqWuB0wqY7l4K5hDnL3LO8znsfkHKqze56CoNKRTMBcT/ 5If9v/rIPrP692PLBCVfte63AITccBLI6xE71Fq5UINfFlf7DhVCD4wHI7rzUI/iE5SK 1CTWYWvnc4HWIAA38o1efSb3bjoeRH9zv/6qL082hQiFaVSbw+HTjPNt1K/XqsClYX9l rjXA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=X/HKEtsv; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id q16si2165269qkh.107.2017.10.16.10.34.52 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 16 Oct 2017 10:34:52 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=X/HKEtsv; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:34326 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e49Hu-0000rH-Lr for patch@linaro.org; Mon, 16 Oct 2017 13:34:50 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52353) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e499y-0002BT-UI for qemu-devel@nongnu.org; Mon, 16 Oct 2017 13:26:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e499x-0003Vb-On for qemu-devel@nongnu.org; Mon, 16 Oct 2017 13:26:38 -0400 Received: from mail-pg0-x22b.google.com ([2607:f8b0:400e:c05::22b]:55271) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e499x-0003Ux-HF for qemu-devel@nongnu.org; Mon, 16 Oct 2017 13:26:37 -0400 Received: by mail-pg0-x22b.google.com with SMTP id l24so7293177pgu.11 for ; Mon, 16 Oct 2017 10:26:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=1kQwh+6emE+i8dPPDChMVGTTzNWDPNxpy5NPSlnmM1o=; b=X/HKEtsv9ob74PHKsPxjnwIOuJpY73hx2B2SAnKwMmWWweYhdeOFtbCpk7My95OEXS VuZTMBn/L006XZ6yctbwKLQbHPDh2tEx6X8o49czo0g/ep5ZzlZAL9f4Bh7PM88qJCC8 HhfrLfrwLHSpT87cbNq2FSJ/pi37XvUP0dprM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=1kQwh+6emE+i8dPPDChMVGTTzNWDPNxpy5NPSlnmM1o=; b=Jgkr520HqovN0nuxOom8TvCgSxMKvib8DSfkiAZk8SsbN2Pc3bqV5v9ahjdRZXjfLu RVB2gUKCRrX1fVWCSnHRYQ2+Qi4c6mIDIIMgfQalSlwSkke7fCljbtNj9lzheuBjEGA1 i+JJDR440BiSmjVGief6DuVwVQA0kDYnY1+933/vasqQzC1h7zUdPk5CWwz3AvOcpVRy pL+3Po9yw6DyZF71SP5fHCFj5EP/2m/qat2Onnl5OwIcfaPWXcsRdDOhndCMasE6NWeq ffHCc1GegewJcUMKwJQcmlIQEKkLdjJTB9j7wGNpFUpz+UwzDRb8mcfSH0Vqnz60InIW tFHg== X-Gm-Message-State: AMCzsaXssTUQCV1Of5SvDB3zmmVdIq24OXu7aOKMH7H4oEWtVPJ3kNIb ngjuHIGGC05nz8D/WLVM3zV6jViyGbY= X-Google-Smtp-Source: AOwi7QA9sPfkO84rldd/ohN80hjWUwHxoWQPAF1L9S+E0NxkIFdLdutFN1xPm/Sr7pi/Gw/2FJ4M7Q== X-Received: by 10.159.195.7 with SMTP id bd7mr9773202plb.366.1508174796339; Mon, 16 Oct 2017 10:26:36 -0700 (PDT) Received: from cloudburst.twiddle.net (97-126-104-76.tukw.qwest.net. [97.126.104.76]) by smtp.gmail.com with ESMTPSA id i187sm5594249pfc.96.2017.10.16.10.26.34 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 16 Oct 2017 10:26:35 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Mon, 16 Oct 2017 10:25:35 -0700 Message-Id: <20171016172609.23422-17-richard.henderson@linaro.org> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171016172609.23422-1-richard.henderson@linaro.org> References: <20171016172609.23422-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c05::22b Subject: [Qemu-devel] [PATCH v6 16/50] tcg: Push tcg_ctx into tcg_gen_callN 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: cota@braap.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Richard Henderson --- include/exec/helper-gen.h | 12 ++++++------ tcg/tcg.h | 3 +-- tcg/tcg.c | 4 ++-- 3 files changed, 9 insertions(+), 10 deletions(-) -- 2.13.6 Reviewed-by: Emilio G. Cota diff --git a/include/exec/helper-gen.h b/include/exec/helper-gen.h index 8239ffc77c..476acd9220 100644 --- a/include/exec/helper-gen.h +++ b/include/exec/helper-gen.h @@ -9,7 +9,7 @@ #define DEF_HELPER_FLAGS_0(name, flags, ret) \ static inline void glue(gen_helper_, name)(dh_retvar_decl0(ret)) \ { \ - tcg_gen_callN(&tcg_ctx, HELPER(name), dh_retvar(ret), 0, NULL); \ + tcg_gen_callN(HELPER(name), dh_retvar(ret), 0, NULL); \ } #define DEF_HELPER_FLAGS_1(name, flags, ret, t1) \ @@ -17,7 +17,7 @@ static inline void glue(gen_helper_, name)(dh_retvar_decl(ret) \ dh_arg_decl(t1, 1)) \ { \ TCGArg args[1] = { dh_arg(t1, 1) }; \ - tcg_gen_callN(&tcg_ctx, HELPER(name), dh_retvar(ret), 1, args); \ + tcg_gen_callN(HELPER(name), dh_retvar(ret), 1, args); \ } #define DEF_HELPER_FLAGS_2(name, flags, ret, t1, t2) \ @@ -25,7 +25,7 @@ static inline void glue(gen_helper_, name)(dh_retvar_decl(ret) \ dh_arg_decl(t1, 1), dh_arg_decl(t2, 2)) \ { \ TCGArg args[2] = { dh_arg(t1, 1), dh_arg(t2, 2) }; \ - tcg_gen_callN(&tcg_ctx, HELPER(name), dh_retvar(ret), 2, args); \ + tcg_gen_callN(HELPER(name), dh_retvar(ret), 2, args); \ } #define DEF_HELPER_FLAGS_3(name, flags, ret, t1, t2, t3) \ @@ -33,7 +33,7 @@ static inline void glue(gen_helper_, name)(dh_retvar_decl(ret) \ dh_arg_decl(t1, 1), dh_arg_decl(t2, 2), dh_arg_decl(t3, 3)) \ { \ TCGArg args[3] = { dh_arg(t1, 1), dh_arg(t2, 2), dh_arg(t3, 3) }; \ - tcg_gen_callN(&tcg_ctx, HELPER(name), dh_retvar(ret), 3, args); \ + tcg_gen_callN(HELPER(name), dh_retvar(ret), 3, args); \ } #define DEF_HELPER_FLAGS_4(name, flags, ret, t1, t2, t3, t4) \ @@ -43,7 +43,7 @@ static inline void glue(gen_helper_, name)(dh_retvar_decl(ret) \ { \ TCGArg args[4] = { dh_arg(t1, 1), dh_arg(t2, 2), \ dh_arg(t3, 3), dh_arg(t4, 4) }; \ - tcg_gen_callN(&tcg_ctx, HELPER(name), dh_retvar(ret), 4, args); \ + tcg_gen_callN(HELPER(name), dh_retvar(ret), 4, args); \ } #define DEF_HELPER_FLAGS_5(name, flags, ret, t1, t2, t3, t4, t5) \ @@ -53,7 +53,7 @@ static inline void glue(gen_helper_, name)(dh_retvar_decl(ret) \ { \ TCGArg args[5] = { dh_arg(t1, 1), dh_arg(t2, 2), dh_arg(t3, 3), \ dh_arg(t4, 4), dh_arg(t5, 5) }; \ - tcg_gen_callN(&tcg_ctx, HELPER(name), dh_retvar(ret), 5, args); \ + tcg_gen_callN(HELPER(name), dh_retvar(ret), 5, args); \ } #include "helper.h" diff --git a/tcg/tcg.h b/tcg/tcg.h index 563e7d36aa..0d61932301 100644 --- a/tcg/tcg.h +++ b/tcg/tcg.h @@ -951,8 +951,7 @@ do {\ bool tcg_op_supported(TCGOpcode op); -void tcg_gen_callN(TCGContext *s, void *func, - TCGArg ret, int nargs, TCGArg *args); +void tcg_gen_callN(void *func, TCGArg ret, int nargs, TCGArg *args); void tcg_op_remove(TCGContext *s, TCGOp *op); TCGOp *tcg_op_insert_before(TCGContext *s, TCGOp *op, TCGOpcode opc, int narg); diff --git a/tcg/tcg.c b/tcg/tcg.c index b39944d42a..113700ccc1 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -974,9 +974,9 @@ bool tcg_op_supported(TCGOpcode op) /* Note: we convert the 64 bit args to 32 bit and do some alignment and endian swap. Maybe it would be better to do the alignment and endian swap in tcg_reg_alloc_call(). */ -void tcg_gen_callN(TCGContext *s, void *func, TCGArg ret, - int nargs, TCGArg *args) +void tcg_gen_callN(void *func, TCGArg ret, int nargs, TCGArg *args) { + TCGContext *s = &tcg_ctx; int i, real_args, nb_rets, pi; unsigned sizemask, flags; TCGHelperInfo *info; From patchwork Mon Oct 16 17:25:36 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 115945 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp3944333qgn; Mon, 16 Oct 2017 10:38:25 -0700 (PDT) X-Received: by 10.55.22.38 with SMTP id g38mr14752590qkh.98.1508175505451; Mon, 16 Oct 2017 10:38:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508175505; cv=none; d=google.com; s=arc-20160816; b=wdXOuKEO/ggkASNbUqLzmlhJaDkd/X5y6gnh+ENeNYvZsMk3KxuFNjpKD//+SHrvcQ XhPLCJGOYWnp9Aay7ljQbOmeuEUZV9tXS0mhzXdWxh/rSse+9Q8TaS8Vbv3w1L2wniWr iOhwnT45iUCX1TQOHEct+kT69atNWpzWvm387wbUD+UG1xAuhvxPbhyIO9W4O2/AA900 5h2s7cCae1xwatAnl+H25s4RbyZJaBi9RieEzO0Px43nxOJKujRWSZltEtuY2BK5/BJe bgxSU2OmeUVqPWwrpF2F30PGa6BvqrOMcA83xcCzbm/J0Sd4zCNpyRAhyr9MUZ+t/NHF EVhQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=92fYPmyDY0Oeji9Zv0dqXtG7mvhGw3J9iH8TfLx4JI8=; b=cYHREp+n7m+eJJQt3BejXzSwlu3lY+RzufLz42gAvvHkla1cMYr6i4HRGhubVFfENR O0Bll/e2eQjtwMEEC1hovgAOJZ25jJAdladgX1XbEf7v3OWIdHn5WIO+DXmmlgxjqSHW 9YVCAMJ4q+EMcfOtldVd7benFR8qTOhL8VM/zjgflk+sdHlWptdpjF2mjiKcawzAkxuC hb13vz/bs6kf3+EwX2m1vhDTvGnsukWy3i4/uY4vc3xisqgVC4fCHhfba3yHbtnqGIGn X2dLrWWQC8bnbBpO9N6Ob7SsFv2DvubfaO+b6ta/kNelcdptegz9aapNvwWVzaulCJ3s cYHQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=cZT81WGr; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id n23si4361883qkn.377.2017.10.16.10.38.24 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 16 Oct 2017 10:38:25 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=cZT81WGr; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:34341 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e49LL-0003Nj-3O for patch@linaro.org; Mon, 16 Oct 2017 13:38:23 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52380) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e49A1-0002Dm-EC for qemu-devel@nongnu.org; Mon, 16 Oct 2017 13:26:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e499z-0003Wk-ES for qemu-devel@nongnu.org; Mon, 16 Oct 2017 13:26:41 -0400 Received: from mail-pf0-x229.google.com ([2607:f8b0:400e:c00::229]:49548) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e499z-0003WG-6O for qemu-devel@nongnu.org; Mon, 16 Oct 2017 13:26:39 -0400 Received: by mail-pf0-x229.google.com with SMTP id i5so3201637pfe.6 for ; Mon, 16 Oct 2017 10:26:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=92fYPmyDY0Oeji9Zv0dqXtG7mvhGw3J9iH8TfLx4JI8=; b=cZT81WGrKt94lRn2A1QUNPt05trfgieEA4lvS4QgSQ5xo+jMweY8FFm6Mibm/l3ub3 ICTaNX1MMIOpXxxQ2XIOY6E5FNrbIi4lxuNIP3or0FHIVxFf6/uxbcyFedfh4BvqKFZR 9syJ3eK0vrUobtKMsNTW98zEAOZ0EyUfUY7vI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=92fYPmyDY0Oeji9Zv0dqXtG7mvhGw3J9iH8TfLx4JI8=; b=gPhaUnDDEeebe9M8jxie+9BuuX+CJbVi9+UpTUple4uZQIZksrv6iOlJ436NyWs0QP 2i1HUm2iYCU9oKKkql/5tRbNwz4BwrMwP6proP/k1YpoAS6w1MZRqdqSlqRAgbEAlXac 9Jc8qHSfq701ZG5d08BmONOB6vVoQEG1D1ySdx+aabUerNxDzzVCIgQ7DcwrM8qf3I0Y m4JGWrN7C3T868cRlhOPbp7UmaMu00iD+5xpwOIf90de4Hylfwj6hAMnBjwknp7TVmaF uvkvTlt1HEcRMeGwMPutvq+P+UXqTGVEvnioG0YxUxoIgimTH6LhmpnlXJXVEXr+ayAi Jylg== X-Gm-Message-State: AMCzsaWHRxvy2kOFB8rLqNX4eENGxTTMwhw5VkiRFqm1HhAcZharqjHO VrEbDFJAUNq5x1QTOEf/VKvZ5tZTbN0= X-Google-Smtp-Source: AOwi7QCKs9jWw1/MuB46Xyhw+LxiDT+tms8uWDyD8nl7HLdPMy2jW49K/3BtYS9Tau6x9P19Yw/TgQ== X-Received: by 10.84.171.195 with SMTP id l61mr9416774plb.64.1508174797617; Mon, 16 Oct 2017 10:26:37 -0700 (PDT) Received: from cloudburst.twiddle.net (97-126-104-76.tukw.qwest.net. [97.126.104.76]) by smtp.gmail.com with ESMTPSA id i187sm5594249pfc.96.2017.10.16.10.26.36 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 16 Oct 2017 10:26:36 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Mon, 16 Oct 2017 10:25:36 -0700 Message-Id: <20171016172609.23422-18-richard.henderson@linaro.org> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171016172609.23422-1-richard.henderson@linaro.org> References: <20171016172609.23422-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c00::229 Subject: [Qemu-devel] [PATCH v6 17/50] tcg: Introduce index_arg 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: cota@braap.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" For multi-threaded tcg we have one TCGContext per thread. With that, plus static cpu_* variables, we need the translators to handle indicies. We transform those to "arguments" at opcode generating time. For now, that transformation is a no-op. Signed-off-by: Richard Henderson --- tcg/tcg-op.h | 92 ++++++++++++++++++++++++++++++------------------------------ tcg/tcg.h | 20 +++++++++++++ tcg/tcg-op.c | 14 ++++----- tcg/tcg.c | 26 ++++++++--------- 4 files changed, 86 insertions(+), 66 deletions(-) -- 2.13.6 Reviewed-by: Emilio G. Cota diff --git a/tcg/tcg-op.h b/tcg/tcg-op.h index de9a61206a..ca1a3becb9 100644 --- a/tcg/tcg-op.h +++ b/tcg/tcg-op.h @@ -37,12 +37,12 @@ void tcg_gen_op6(TCGOpcode, TCGArg, TCGArg, TCGArg, TCGArg, TCGArg, TCGArg); static inline void tcg_gen_op1_i32(TCGOpcode opc, TCGv_i32 a1) { - tcg_gen_op1(opc, GET_TCGV_I32(a1)); + tcg_gen_op1(opc, tcgv_i32_arg(a1)); } static inline void tcg_gen_op1_i64(TCGOpcode opc, TCGv_i64 a1) { - tcg_gen_op1(opc, GET_TCGV_I64(a1)); + tcg_gen_op1(opc, tcgv_i64_arg(a1)); } static inline void tcg_gen_op1i(TCGOpcode opc, TCGArg a1) @@ -52,22 +52,22 @@ static inline void tcg_gen_op1i(TCGOpcode opc, TCGArg a1) static inline void tcg_gen_op2_i32(TCGOpcode opc, TCGv_i32 a1, TCGv_i32 a2) { - tcg_gen_op2(opc, GET_TCGV_I32(a1), GET_TCGV_I32(a2)); + tcg_gen_op2(opc, tcgv_i32_arg(a1), tcgv_i32_arg(a2)); } static inline void tcg_gen_op2_i64(TCGOpcode opc, TCGv_i64 a1, TCGv_i64 a2) { - tcg_gen_op2(opc, GET_TCGV_I64(a1), GET_TCGV_I64(a2)); + tcg_gen_op2(opc, tcgv_i64_arg(a1), tcgv_i64_arg(a2)); } static inline void tcg_gen_op2i_i32(TCGOpcode opc, TCGv_i32 a1, TCGArg a2) { - tcg_gen_op2(opc, GET_TCGV_I32(a1), a2); + tcg_gen_op2(opc, tcgv_i32_arg(a1), a2); } static inline void tcg_gen_op2i_i64(TCGOpcode opc, TCGv_i64 a1, TCGArg a2) { - tcg_gen_op2(opc, GET_TCGV_I64(a1), a2); + tcg_gen_op2(opc, tcgv_i64_arg(a1), a2); } static inline void tcg_gen_op2ii(TCGOpcode opc, TCGArg a1, TCGArg a2) @@ -78,167 +78,167 @@ static inline void tcg_gen_op2ii(TCGOpcode opc, TCGArg a1, TCGArg a2) static inline void tcg_gen_op3_i32(TCGOpcode opc, TCGv_i32 a1, TCGv_i32 a2, TCGv_i32 a3) { - tcg_gen_op3(opc, GET_TCGV_I32(a1), GET_TCGV_I32(a2), GET_TCGV_I32(a3)); + tcg_gen_op3(opc, tcgv_i32_arg(a1), tcgv_i32_arg(a2), tcgv_i32_arg(a3)); } static inline void tcg_gen_op3_i64(TCGOpcode opc, TCGv_i64 a1, TCGv_i64 a2, TCGv_i64 a3) { - tcg_gen_op3(opc, GET_TCGV_I64(a1), GET_TCGV_I64(a2), GET_TCGV_I64(a3)); + tcg_gen_op3(opc, tcgv_i64_arg(a1), tcgv_i64_arg(a2), tcgv_i64_arg(a3)); } static inline void tcg_gen_op3i_i32(TCGOpcode opc, TCGv_i32 a1, TCGv_i32 a2, TCGArg a3) { - tcg_gen_op3(opc, GET_TCGV_I32(a1), GET_TCGV_I32(a2), a3); + tcg_gen_op3(opc, tcgv_i32_arg(a1), tcgv_i32_arg(a2), a3); } static inline void tcg_gen_op3i_i64(TCGOpcode opc, TCGv_i64 a1, TCGv_i64 a2, TCGArg a3) { - tcg_gen_op3(opc, GET_TCGV_I64(a1), GET_TCGV_I64(a2), a3); + tcg_gen_op3(opc, tcgv_i64_arg(a1), tcgv_i64_arg(a2), a3); } static inline void tcg_gen_ldst_op_i32(TCGOpcode opc, TCGv_i32 val, TCGv_ptr base, TCGArg offset) { - tcg_gen_op3(opc, GET_TCGV_I32(val), GET_TCGV_PTR(base), offset); + tcg_gen_op3(opc, tcgv_i32_arg(val), tcgv_ptr_arg(base), offset); } static inline void tcg_gen_ldst_op_i64(TCGOpcode opc, TCGv_i64 val, TCGv_ptr base, TCGArg offset) { - tcg_gen_op3(opc, GET_TCGV_I64(val), GET_TCGV_PTR(base), offset); + tcg_gen_op3(opc, tcgv_i64_arg(val), tcgv_ptr_arg(base), offset); } static inline void tcg_gen_op4_i32(TCGOpcode opc, TCGv_i32 a1, TCGv_i32 a2, TCGv_i32 a3, TCGv_i32 a4) { - tcg_gen_op4(opc, GET_TCGV_I32(a1), GET_TCGV_I32(a2), - GET_TCGV_I32(a3), GET_TCGV_I32(a4)); + tcg_gen_op4(opc, tcgv_i32_arg(a1), tcgv_i32_arg(a2), + tcgv_i32_arg(a3), tcgv_i32_arg(a4)); } static inline void tcg_gen_op4_i64(TCGOpcode opc, TCGv_i64 a1, TCGv_i64 a2, TCGv_i64 a3, TCGv_i64 a4) { - tcg_gen_op4(opc, GET_TCGV_I64(a1), GET_TCGV_I64(a2), - GET_TCGV_I64(a3), GET_TCGV_I64(a4)); + tcg_gen_op4(opc, tcgv_i64_arg(a1), tcgv_i64_arg(a2), + tcgv_i64_arg(a3), tcgv_i64_arg(a4)); } static inline void tcg_gen_op4i_i32(TCGOpcode opc, TCGv_i32 a1, TCGv_i32 a2, TCGv_i32 a3, TCGArg a4) { - tcg_gen_op4(opc, GET_TCGV_I32(a1), GET_TCGV_I32(a2), GET_TCGV_I32(a3), a4); + tcg_gen_op4(opc, tcgv_i32_arg(a1), tcgv_i32_arg(a2), tcgv_i32_arg(a3), a4); } static inline void tcg_gen_op4i_i64(TCGOpcode opc, TCGv_i64 a1, TCGv_i64 a2, TCGv_i64 a3, TCGArg a4) { - tcg_gen_op4(opc, GET_TCGV_I64(a1), GET_TCGV_I64(a2), GET_TCGV_I64(a3), a4); + tcg_gen_op4(opc, tcgv_i64_arg(a1), tcgv_i64_arg(a2), tcgv_i64_arg(a3), a4); } static inline void tcg_gen_op4ii_i32(TCGOpcode opc, TCGv_i32 a1, TCGv_i32 a2, TCGArg a3, TCGArg a4) { - tcg_gen_op4(opc, GET_TCGV_I32(a1), GET_TCGV_I32(a2), a3, a4); + tcg_gen_op4(opc, tcgv_i32_arg(a1), tcgv_i32_arg(a2), a3, a4); } static inline void tcg_gen_op4ii_i64(TCGOpcode opc, TCGv_i64 a1, TCGv_i64 a2, TCGArg a3, TCGArg a4) { - tcg_gen_op4(opc, GET_TCGV_I64(a1), GET_TCGV_I64(a2), a3, a4); + tcg_gen_op4(opc, tcgv_i64_arg(a1), tcgv_i64_arg(a2), a3, a4); } static inline void tcg_gen_op5_i32(TCGOpcode opc, TCGv_i32 a1, TCGv_i32 a2, TCGv_i32 a3, TCGv_i32 a4, TCGv_i32 a5) { - tcg_gen_op5(opc, GET_TCGV_I32(a1), GET_TCGV_I32(a2), - GET_TCGV_I32(a3), GET_TCGV_I32(a4), GET_TCGV_I32(a5)); + tcg_gen_op5(opc, tcgv_i32_arg(a1), tcgv_i32_arg(a2), + tcgv_i32_arg(a3), tcgv_i32_arg(a4), tcgv_i32_arg(a5)); } static inline void tcg_gen_op5_i64(TCGOpcode opc, TCGv_i64 a1, TCGv_i64 a2, TCGv_i64 a3, TCGv_i64 a4, TCGv_i64 a5) { - tcg_gen_op5(opc, GET_TCGV_I64(a1), GET_TCGV_I64(a2), - GET_TCGV_I64(a3), GET_TCGV_I64(a4), GET_TCGV_I64(a5)); + tcg_gen_op5(opc, tcgv_i64_arg(a1), tcgv_i64_arg(a2), + tcgv_i64_arg(a3), tcgv_i64_arg(a4), tcgv_i64_arg(a5)); } static inline void tcg_gen_op5i_i32(TCGOpcode opc, TCGv_i32 a1, TCGv_i32 a2, TCGv_i32 a3, TCGv_i32 a4, TCGArg a5) { - tcg_gen_op5(opc, GET_TCGV_I32(a1), GET_TCGV_I32(a2), - GET_TCGV_I32(a3), GET_TCGV_I32(a4), a5); + tcg_gen_op5(opc, tcgv_i32_arg(a1), tcgv_i32_arg(a2), + tcgv_i32_arg(a3), tcgv_i32_arg(a4), a5); } static inline void tcg_gen_op5i_i64(TCGOpcode opc, TCGv_i64 a1, TCGv_i64 a2, TCGv_i64 a3, TCGv_i64 a4, TCGArg a5) { - tcg_gen_op5(opc, GET_TCGV_I64(a1), GET_TCGV_I64(a2), - GET_TCGV_I64(a3), GET_TCGV_I64(a4), a5); + tcg_gen_op5(opc, tcgv_i64_arg(a1), tcgv_i64_arg(a2), + tcgv_i64_arg(a3), tcgv_i64_arg(a4), a5); } static inline void tcg_gen_op5ii_i32(TCGOpcode opc, TCGv_i32 a1, TCGv_i32 a2, TCGv_i32 a3, TCGArg a4, TCGArg a5) { - tcg_gen_op5(opc, GET_TCGV_I32(a1), GET_TCGV_I32(a2), - GET_TCGV_I32(a3), a4, a5); + tcg_gen_op5(opc, tcgv_i32_arg(a1), tcgv_i32_arg(a2), + tcgv_i32_arg(a3), a4, a5); } static inline void tcg_gen_op5ii_i64(TCGOpcode opc, TCGv_i64 a1, TCGv_i64 a2, TCGv_i64 a3, TCGArg a4, TCGArg a5) { - tcg_gen_op5(opc, GET_TCGV_I64(a1), GET_TCGV_I64(a2), - GET_TCGV_I64(a3), a4, a5); + tcg_gen_op5(opc, tcgv_i64_arg(a1), tcgv_i64_arg(a2), + tcgv_i64_arg(a3), a4, a5); } static inline void tcg_gen_op6_i32(TCGOpcode opc, TCGv_i32 a1, TCGv_i32 a2, TCGv_i32 a3, TCGv_i32 a4, TCGv_i32 a5, TCGv_i32 a6) { - tcg_gen_op6(opc, GET_TCGV_I32(a1), GET_TCGV_I32(a2), - GET_TCGV_I32(a3), GET_TCGV_I32(a4), GET_TCGV_I32(a5), - GET_TCGV_I32(a6)); + tcg_gen_op6(opc, tcgv_i32_arg(a1), tcgv_i32_arg(a2), + tcgv_i32_arg(a3), tcgv_i32_arg(a4), tcgv_i32_arg(a5), + tcgv_i32_arg(a6)); } static inline void tcg_gen_op6_i64(TCGOpcode opc, TCGv_i64 a1, TCGv_i64 a2, TCGv_i64 a3, TCGv_i64 a4, TCGv_i64 a5, TCGv_i64 a6) { - tcg_gen_op6(opc, GET_TCGV_I64(a1), GET_TCGV_I64(a2), - GET_TCGV_I64(a3), GET_TCGV_I64(a4), GET_TCGV_I64(a5), - GET_TCGV_I64(a6)); + tcg_gen_op6(opc, tcgv_i64_arg(a1), tcgv_i64_arg(a2), + tcgv_i64_arg(a3), tcgv_i64_arg(a4), tcgv_i64_arg(a5), + tcgv_i64_arg(a6)); } static inline void tcg_gen_op6i_i32(TCGOpcode opc, TCGv_i32 a1, TCGv_i32 a2, TCGv_i32 a3, TCGv_i32 a4, TCGv_i32 a5, TCGArg a6) { - tcg_gen_op6(opc, GET_TCGV_I32(a1), GET_TCGV_I32(a2), - GET_TCGV_I32(a3), GET_TCGV_I32(a4), GET_TCGV_I32(a5), a6); + tcg_gen_op6(opc, tcgv_i32_arg(a1), tcgv_i32_arg(a2), + tcgv_i32_arg(a3), tcgv_i32_arg(a4), tcgv_i32_arg(a5), a6); } static inline void tcg_gen_op6i_i64(TCGOpcode opc, TCGv_i64 a1, TCGv_i64 a2, TCGv_i64 a3, TCGv_i64 a4, TCGv_i64 a5, TCGArg a6) { - tcg_gen_op6(opc, GET_TCGV_I64(a1), GET_TCGV_I64(a2), - GET_TCGV_I64(a3), GET_TCGV_I64(a4), GET_TCGV_I64(a5), a6); + tcg_gen_op6(opc, tcgv_i64_arg(a1), tcgv_i64_arg(a2), + tcgv_i64_arg(a3), tcgv_i64_arg(a4), tcgv_i64_arg(a5), a6); } static inline void tcg_gen_op6ii_i32(TCGOpcode opc, TCGv_i32 a1, TCGv_i32 a2, TCGv_i32 a3, TCGv_i32 a4, TCGArg a5, TCGArg a6) { - tcg_gen_op6(opc, GET_TCGV_I32(a1), GET_TCGV_I32(a2), - GET_TCGV_I32(a3), GET_TCGV_I32(a4), a5, a6); + tcg_gen_op6(opc, tcgv_i32_arg(a1), tcgv_i32_arg(a2), + tcgv_i32_arg(a3), tcgv_i32_arg(a4), a5, a6); } static inline void tcg_gen_op6ii_i64(TCGOpcode opc, TCGv_i64 a1, TCGv_i64 a2, TCGv_i64 a3, TCGv_i64 a4, TCGArg a5, TCGArg a6) { - tcg_gen_op6(opc, GET_TCGV_I64(a1), GET_TCGV_I64(a2), - GET_TCGV_I64(a3), GET_TCGV_I64(a4), a5, a6); + tcg_gen_op6(opc, tcgv_i64_arg(a1), tcgv_i64_arg(a2), + tcgv_i64_arg(a3), tcgv_i64_arg(a4), a5, a6); } diff --git a/tcg/tcg.h b/tcg/tcg.h index 0d61932301..b8ede7fe5c 100644 --- a/tcg/tcg.h +++ b/tcg/tcg.h @@ -756,6 +756,26 @@ static inline size_t arg_index(TCGArg a) return a; } +static inline TCGArg index_arg(size_t n) +{ + return n; +} + +static inline TCGArg tcgv_i32_arg(TCGv_i32 t) +{ + return index_arg(GET_TCGV_I32(t)); +} + +static inline TCGArg tcgv_i64_arg(TCGv_i64 t) +{ + return index_arg(GET_TCGV_I64(t)); +} + +static inline TCGArg tcgv_ptr_arg(TCGv_ptr t) +{ + return index_arg(GET_TCGV_PTR(t)); +} + static inline void tcg_set_insn_param(int op_idx, int arg, TCGArg v) { tcg_ctx.gen_op_buf[op_idx].args[arg] = v; diff --git a/tcg/tcg-op.c b/tcg/tcg-op.c index bff4b95097..be4b623e82 100644 --- a/tcg/tcg-op.c +++ b/tcg/tcg-op.c @@ -2458,7 +2458,7 @@ void tcg_gen_extrl_i64_i32(TCGv_i32 ret, TCGv_i64 arg) tcg_gen_mov_i32(ret, TCGV_LOW(arg)); } else if (TCG_TARGET_HAS_extrl_i64_i32) { tcg_gen_op2(INDEX_op_extrl_i64_i32, - GET_TCGV_I32(ret), GET_TCGV_I64(arg)); + tcgv_i32_arg(ret), tcgv_i64_arg(arg)); } else { tcg_gen_mov_i32(ret, MAKE_TCGV_I32(GET_TCGV_I64(arg))); } @@ -2470,7 +2470,7 @@ void tcg_gen_extrh_i64_i32(TCGv_i32 ret, TCGv_i64 arg) tcg_gen_mov_i32(ret, TCGV_HIGH(arg)); } else if (TCG_TARGET_HAS_extrh_i64_i32) { tcg_gen_op2(INDEX_op_extrh_i64_i32, - GET_TCGV_I32(ret), GET_TCGV_I64(arg)); + tcgv_i32_arg(ret), tcgv_i64_arg(arg)); } else { TCGv_i64 t = tcg_temp_new_i64(); tcg_gen_shri_i64(t, arg, 32); @@ -2486,7 +2486,7 @@ void tcg_gen_extu_i32_i64(TCGv_i64 ret, TCGv_i32 arg) tcg_gen_movi_i32(TCGV_HIGH(ret), 0); } else { tcg_gen_op2(INDEX_op_extu_i32_i64, - GET_TCGV_I64(ret), GET_TCGV_I32(arg)); + tcgv_i64_arg(ret), tcgv_i32_arg(arg)); } } @@ -2497,7 +2497,7 @@ void tcg_gen_ext_i32_i64(TCGv_i64 ret, TCGv_i32 arg) tcg_gen_sari_i32(TCGV_HIGH(ret), TCGV_LOW(ret), 31); } else { tcg_gen_op2(INDEX_op_ext_i32_i64, - GET_TCGV_I64(ret), GET_TCGV_I32(arg)); + tcgv_i64_arg(ret), tcgv_i32_arg(arg)); } } @@ -2563,7 +2563,7 @@ void tcg_gen_lookup_and_goto_ptr(void) if (TCG_TARGET_HAS_goto_ptr && !qemu_loglevel_mask(CPU_LOG_TB_NOCHAIN)) { TCGv_ptr ptr = tcg_temp_new_ptr(); gen_helper_lookup_tb_ptr(ptr, tcg_ctx.tcg_env); - tcg_gen_op1i(INDEX_op_goto_ptr, GET_TCGV_PTR(ptr)); + tcg_gen_op1i(INDEX_op_goto_ptr, tcgv_ptr_arg(ptr)); tcg_temp_free_ptr(ptr); } else { tcg_gen_exit_tb(0); @@ -2608,7 +2608,7 @@ static void gen_ldst_i32(TCGOpcode opc, TCGv_i32 val, TCGv addr, if (TCG_TARGET_REG_BITS == 32) { tcg_gen_op4i_i32(opc, val, TCGV_LOW(addr), TCGV_HIGH(addr), oi); } else { - tcg_gen_op3(opc, GET_TCGV_I32(val), GET_TCGV_I64(addr), oi); + tcg_gen_op3(opc, tcgv_i32_arg(val), tcgv_i64_arg(addr), oi); } #endif } @@ -2621,7 +2621,7 @@ static void gen_ldst_i64(TCGOpcode opc, TCGv_i64 val, TCGv addr, if (TCG_TARGET_REG_BITS == 32) { tcg_gen_op4i_i32(opc, TCGV_LOW(val), TCGV_HIGH(val), addr, oi); } else { - tcg_gen_op3(opc, GET_TCGV_I64(val), GET_TCGV_I32(addr), oi); + tcg_gen_op3(opc, tcgv_i64_arg(val), tcgv_i32_arg(addr), oi); } #else if (TCG_TARGET_REG_BITS == 32) { diff --git a/tcg/tcg.c b/tcg/tcg.c index 113700ccc1..129aecca60 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -1054,25 +1054,25 @@ void tcg_gen_callN(void *func, TCGArg ret, int nargs, TCGArg *args) two return temporaries, and reassemble below. */ retl = tcg_temp_new_i64(); reth = tcg_temp_new_i64(); - op->args[pi++] = GET_TCGV_I64(reth); - op->args[pi++] = GET_TCGV_I64(retl); + op->args[pi++] = tcgv_i64_arg(reth); + op->args[pi++] = tcgv_i64_arg(retl); nb_rets = 2; } else { - op->args[pi++] = ret; + op->args[pi++] = index_arg(ret); nb_rets = 1; } #else if (TCG_TARGET_REG_BITS < 64 && (sizemask & 1)) { #ifdef HOST_WORDS_BIGENDIAN - op->args[pi++] = ret + 1; - op->args[pi++] = ret; + op->args[pi++] = index_arg(ret + 1); + op->args[pi++] = index_arg(ret); #else - op->args[pi++] = ret; - op->args[pi++] = ret + 1; + op->args[pi++] = index_arg(ret); + op->args[pi++] = index_arg(ret + 1); #endif nb_rets = 2; } else { - op->args[pi++] = ret; + op->args[pi++] = index_arg(ret); nb_rets = 1; } #endif @@ -1103,17 +1103,17 @@ void tcg_gen_callN(void *func, TCGArg ret, int nargs, TCGArg *args) have to get more complicated to differentiate between stack arguments and register arguments. */ #if defined(HOST_WORDS_BIGENDIAN) != defined(TCG_TARGET_STACK_GROWSUP) - op->args[pi++] = args[i] + 1; - op->args[pi++] = args[i]; + op->args[pi++] = index_arg(args[i] + 1); + op->args[pi++] = index_arg(args[i]); #else - op->args[pi++] = args[i]; - op->args[pi++] = args[i] + 1; + op->args[pi++] = index_arg(args[i]); + op->args[pi++] = index_arg(args[i] + 1); #endif real_args += 2; continue; } - op->args[pi++] = args[i]; + op->args[pi++] = index_arg(args[i]); real_args++; } op->args[pi++] = (uintptr_t)func; From patchwork Mon Oct 16 17:25:37 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 115942 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp3943203qgn; Mon, 16 Oct 2017 10:37:06 -0700 (PDT) X-Received: by 10.55.6.22 with SMTP id 22mr13968920qkg.340.1508175426897; Mon, 16 Oct 2017 10:37:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508175426; cv=none; d=google.com; s=arc-20160816; b=KH1gcXpoDiLoN4vM3al3G5SgCPPPyhDj7BaPq1alWdGqLZOYgGeCvwjtOHR2AT5Tu/ TdlG1f/8L0yh1fW4lTDmzt5iDWurxhyXeg5+YEYZFN2XOyoq+wj63aEKVAKNwKYF5kxR OjEf2JfQoGFok/3A2+pOAqSLy5hY1WY4l6IMq0/dbJtZGsTqC20ZWLj/Sm3blQ7eYcIT AVFJ9U/kjWjIMAvYwfZHu+zZt6zWwc8QtlVF1H3PyGVpsYYQjxCQJx4QbY+J9fYKWUVU ZGg1SmBsgZ8e1ym29BGMu+tMEd9VrgcC0sgU4wdnb4+U6bxqaTGFKyM5/84NEKm/5Rin LQtA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=W/uVhJTBBm1QQTcQZ5J5hpaa/mYKhmO+eNQ749BoQnc=; b=EtTOWKDmkpqLU3rw12b8o2M3W9LTbIEXLuwYgg4nIkiWdQjPmXDsHRd5xFx/wWOBXo gSrBWBlhIl6IJTGdT18UWLoeEIfcRXrzkV9U3ZY4NqiXEhgdpwmDotvF/VW5H+6kCM39 VxGihlLBScWvBDl1xtdCgOSNgWVqMYz1TlTV4v0BMW0M3c9tB3QS9p/Oqq/jxW31D6wp Y1DX6G00xbgF91O1v77IVxrl07dz1n4xlEwxlpDMRg7lWSSd5HooOZiVNxmly4FyKh6h 4NtyAf3c2SYFaOgzaUxuzTjs9+mE39LZKf+5NBZ/CRPigh70QYhRvXd9+PSIlJ08JPKH AXzw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=gFW2XShd; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id 45si405903qtx.60.2017.10.16.10.37.06 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 16 Oct 2017 10:37:06 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=gFW2XShd; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:34338 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e49K4-0002Na-Q9 for patch@linaro.org; Mon, 16 Oct 2017 13:37:04 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52377) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e49A1-0002DC-0t for qemu-devel@nongnu.org; Mon, 16 Oct 2017 13:26:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e499z-0003X8-UB for qemu-devel@nongnu.org; Mon, 16 Oct 2017 13:26:41 -0400 Received: from mail-pf0-x234.google.com ([2607:f8b0:400e:c00::234]:50192) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e499z-0003Wg-PQ for qemu-devel@nongnu.org; Mon, 16 Oct 2017 13:26:39 -0400 Received: by mail-pf0-x234.google.com with SMTP id b6so7884690pfh.7 for ; Mon, 16 Oct 2017 10:26:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=W/uVhJTBBm1QQTcQZ5J5hpaa/mYKhmO+eNQ749BoQnc=; b=gFW2XShd8C6UDw3abz56YyC3V96r5EK01BVi4ld5vfTaAF1RJI+zQxPVyGl2yW0V72 YNCYe0iJxR8nKQ11MJtI2wHP+XKYFgZ8ggn7koheX7yQTrsF57YKkeRJHeJFancBHyCH +tOGq5iYxlFqVo8OhnKUFDLV88AcukPXaNjg8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=W/uVhJTBBm1QQTcQZ5J5hpaa/mYKhmO+eNQ749BoQnc=; b=mB9zxhsmIzCfhnmvyXUxKyiomZQDpR4h5TXPhbuNBcis0DZnWHgocpAqerSs0vQU5e QLlUiRqHYLG18s3vhxhipQoKcVvVw1CwXDvfkcNo8PMSRX1NHvKUfDAgDcbmjO07Q0Gv v8Vxsj1FJT8My3YwHEA77BZ7yaG/2tYChIgWP+mb5mv+6fo+j30Fqj5DXJGpgyW4NAJU Kafj6HIO80iSJP8Bd0qtfEKbGmrpAsxjgd4bDD/tgJXIu1vIWMPKsHNxL3TcMqqF+z/b pphoRtYD9Q+XuKYdgZf6/nozjwWaMe3HOQwcxkwYNc93RguvZ8JnCkjaG/CG0+dgm4q9 g/cQ== X-Gm-Message-State: AMCzsaV+2WHY+Y9nYrramsVZ8y0BU5pjCbKC50kV9yyVN6ymU72yK6YU iTwWaB8wbxd5cshqghJxOsJ+VfvVbgQ= X-Google-Smtp-Source: AOwi7QAde+ThUnfKOzgm4ez6HN4ak7CwTBr/Jy2Vl6H7dZ4OIWZC51y8Skc/R3ICsFz97NN4ptxfDw== X-Received: by 10.159.208.2 with SMTP id a2mr9709858plp.370.1508174798617; Mon, 16 Oct 2017 10:26:38 -0700 (PDT) Received: from cloudburst.twiddle.net (97-126-104-76.tukw.qwest.net. [97.126.104.76]) by smtp.gmail.com with ESMTPSA id i187sm5594249pfc.96.2017.10.16.10.26.37 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 16 Oct 2017 10:26:37 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Mon, 16 Oct 2017 10:25:37 -0700 Message-Id: <20171016172609.23422-19-richard.henderson@linaro.org> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171016172609.23422-1-richard.henderson@linaro.org> References: <20171016172609.23422-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c00::234 Subject: [Qemu-devel] [PATCH v6 18/50] tcg: Reserve temporary index 0 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: cota@braap.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Since we cast indicies to pointers, reserving 0 allows us to use NULL for unused/dummy instead of (T *)-1. Signed-off-by: Richard Henderson --- tcg/tcg.h | 16 ++++++++-------- tcg/tcg.c | 5 ++++- 2 files changed, 12 insertions(+), 9 deletions(-) -- 2.13.6 diff --git a/tcg/tcg.h b/tcg/tcg.h index b8ede7fe5c..ccf1bcdaf6 100644 --- a/tcg/tcg.h +++ b/tcg/tcg.h @@ -471,13 +471,13 @@ static inline intptr_t QEMU_ARTIFICIAL GET_TCGV_PTR(TCGv_ptr t) #define TCGV_EQUAL_PTR(a, b) (GET_TCGV_PTR(a) == GET_TCGV_PTR(b)) /* Dummy definition to avoid compiler warnings. */ -#define TCGV_UNUSED_I32(x) x = MAKE_TCGV_I32(-1) -#define TCGV_UNUSED_I64(x) x = MAKE_TCGV_I64(-1) -#define TCGV_UNUSED_PTR(x) x = MAKE_TCGV_PTR(-1) +#define TCGV_UNUSED_I32(x) ((x) = NULL) +#define TCGV_UNUSED_I64(x) ((x) = NULL) +#define TCGV_UNUSED_PTR(x) ((x) = NULL) -#define TCGV_IS_UNUSED_I32(x) (GET_TCGV_I32(x) == -1) -#define TCGV_IS_UNUSED_I64(x) (GET_TCGV_I64(x) == -1) -#define TCGV_IS_UNUSED_PTR(x) (GET_TCGV_PTR(x) == -1) +#define TCGV_IS_UNUSED_I32(x) (GET_TCGV_I32(x) == 0) +#define TCGV_IS_UNUSED_I64(x) (GET_TCGV_I64(x) == 0) +#define TCGV_IS_UNUSED_PTR(x) (GET_TCGV_PTR(x) == 0) /* call flags */ /* Helper does not read globals (either directly or through an exception). It @@ -496,7 +496,7 @@ static inline intptr_t QEMU_ARTIFICIAL GET_TCGV_PTR(TCGv_ptr t) #define TCG_CALL_NO_WG_SE (TCG_CALL_NO_WG | TCG_CALL_NO_SE) /* used to align parameters */ -#define TCG_CALL_DUMMY_ARG ((TCGArg)(-1)) +#define TCG_CALL_DUMMY_ARG ((TCGArg)0) /* Conditions. Note that these are laid out for easy manipulation by the functions below: @@ -737,7 +737,7 @@ extern bool parallel_cpus; static inline size_t temp_idx(TCGTemp *ts) { ptrdiff_t n = ts - tcg_ctx.temps; - tcg_debug_assert(n >= 0 && n < tcg_ctx.nb_temps); + tcg_debug_assert(n > 0 && n < tcg_ctx.nb_temps); return n; } diff --git a/tcg/tcg.c b/tcg/tcg.c index 129aecca60..7cf39f7067 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -333,7 +333,10 @@ void tcg_context_init(TCGContext *s) int *sorted_args; memset(s, 0, sizeof(*s)); - s->nb_globals = 0; + /* Reserve temp index 0 so that, with the funny casting that we do, + the first one doesn't look like NULL. */ + s->nb_globals = 1; + s->nb_temps = 1; /* Count total number of arguments and allocate the corresponding space */ From patchwork Mon Oct 16 17:25:38 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 115959 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp3954031qgn; Mon, 16 Oct 2017 10:50:00 -0700 (PDT) X-Received: by 10.200.3.8 with SMTP id q8mr3126823qtg.57.1508176200325; Mon, 16 Oct 2017 10:50:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508176200; cv=none; d=google.com; s=arc-20160816; b=YR+a0JMyvsdKd97K3kq76j2wUy6MHhDUYBSz+3/xQpqI3uYNsA5WTmnHqBcGxPArqS FhRm6vdwEBUdye+L7jXaVpEU+do4K8KimKXzm0GkS+Wf7APyPnN45pGEDxlpdXwFXpmx RWVXeVg9ZSNdA+dhceS1Siy54VXuPqXQ2Lt2lthp1eaOBNgnE5gDbYjXW7T4mZ8vdTNm zEaACRG/ZLjE4o44HZeeZSUyJ9HolSrgHavppITQfiL4ZuX8+CJh9XHzyquGpywJf0YF 4GGwzdlWnmggGrttUpwYiJhBFrp3SGNy+biIdq7YcAWBLkbWoBASbklHq2AO6ga9H7cw KuGw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=+PJqDWICacH3Ja8M/ePqBFw43qxeA+TLf01qhiiXFnU=; b=JCC8TNAHOwL5qrV42lBY8SK8nrIxorraGzoEZaKSxtkEGadMLtH7n+ZRQ7ElM/Qbjt YXGB6jQVcYIHKQNQPzfOQ6uOv3VQ1ZNBt7uveslm3kqD1yxzu9oN3mz6abtxrNBfzoaw k+1zSNavs35FC3IQpinCtVPKZQhA5C6tVT4t+AO+txWg2JjxbE6PltlbZXfmyTq2FCWk 7jrOJxtB8M/M3iKDEMD8JazO+hnMgaKUp8UZQJtkl494OeIdkDY3AUDSGunSxqNd3rBQ H1uNZbUQq/ZxA7TZ0VCzAbnXVW6531PEKJYr6RELURj3fOhPo0F2r6gVag/01iFI1FXb V80A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=bRDrSUTz; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id n17si453525qki.236.2017.10.16.10.50.00 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 16 Oct 2017 10:50:00 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=bRDrSUTz; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:34387 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e49WY-0004e5-8V for patch@linaro.org; Mon, 16 Oct 2017 13:49:58 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52391) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e49A2-0002EZ-9T for qemu-devel@nongnu.org; Mon, 16 Oct 2017 13:26:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e49A1-0003YL-Ij for qemu-devel@nongnu.org; Mon, 16 Oct 2017 13:26:42 -0400 Received: from mail-pg0-x22f.google.com ([2607:f8b0:400e:c05::22f]:52539) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e49A1-0003Xq-CZ for qemu-devel@nongnu.org; Mon, 16 Oct 2017 13:26:41 -0400 Received: by mail-pg0-x22f.google.com with SMTP id a192so5918766pge.9 for ; Mon, 16 Oct 2017 10:26:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=+PJqDWICacH3Ja8M/ePqBFw43qxeA+TLf01qhiiXFnU=; b=bRDrSUTzD/gW348V3IW+efd2IuzIM7CbOxXtEMgGSkJTo0vXSxCpnVRzLsbsxOcSDs yPZ1rw32wsQQJ7e3ePEqzXhJR6m9oWjDI+Ut1dav8RtsJKKr2Uyt4Z5Szv/rmpKHqZSQ 8QlukEp+2vJ1URxIsk8DTUnqNJjLUWjYU9HO4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=+PJqDWICacH3Ja8M/ePqBFw43qxeA+TLf01qhiiXFnU=; b=tRDc94irGJgpVOrdsvSv+njpCZjx5aOsbrSqpc52Xtcv8BoSNfiT4yCgzqaPaz08LC OWxipnK4ozthKntvi9P9bBi1LTQfH9PnsIMkkGySyRqgTQDqLQkE4Z7bXfl6GTzzMzNL s0KlfmHq3C4hlybxeWdgbOQAuSjUUr0P9guulgQfbbq+iOFjJDbZcjNUZJwtwywvW7nE aD7YhJv/XjlTKmdMB5a40oo0VJj1jUJcN4+4jW4nesPXGUn8KQ4sQTEHIdv0UGi9q8qv TDjnFPSj9v+lFA7gbOIm7StdcE1pz2ZB4u7MAEd8C+Xzqa4MpKarsrdcLs64KjjkFQ62 MBow== X-Gm-Message-State: AMCzsaXkTTIz0lEyYlcGDYgf486xqQOvPL0MwZte5q/yPChk8cK5ZPIO 0qSLTbxnjtw0SnMMgeN4jZSk+i797+M= X-Google-Smtp-Source: AOwi7QCod+O+KrWjwE4a4T0/KJdPeEdoa5TKryh3PhQ5wmPfx+NNczlbV5nFLq9cW55wTRLfiFrG3g== X-Received: by 10.84.194.131 with SMTP id h3mr9540973pld.352.1508174800263; Mon, 16 Oct 2017 10:26:40 -0700 (PDT) Received: from cloudburst.twiddle.net (97-126-104-76.tukw.qwest.net. [97.126.104.76]) by smtp.gmail.com with ESMTPSA id i187sm5594249pfc.96.2017.10.16.10.26.39 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 16 Oct 2017 10:26:39 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Mon, 16 Oct 2017 10:25:38 -0700 Message-Id: <20171016172609.23422-20-richard.henderson@linaro.org> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171016172609.23422-1-richard.henderson@linaro.org> References: <20171016172609.23422-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c05::22f Subject: [Qemu-devel] [PATCH v6 19/50] target/alpha: Avoid translate_init unless tcg_enabled 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: cota@braap.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Richard Henderson --- target/alpha/cpu.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) -- 2.13.6 diff --git a/target/alpha/cpu.c b/target/alpha/cpu.c index b8a21f4e01..b52ebd7356 100644 --- a/target/alpha/cpu.c +++ b/target/alpha/cpu.c @@ -260,7 +260,9 @@ static void alpha_cpu_initfn(Object *obj) cs->env_ptr = env; tlb_flush(cs); - alpha_translate_init(); + if (tcg_enabled()) { + alpha_translate_init(); + } env->lock_addr = -1; #if defined(CONFIG_USER_ONLY) From patchwork Mon Oct 16 17:25:39 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 115950 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp3947587qgn; Mon, 16 Oct 2017 10:42:22 -0700 (PDT) X-Received: by 10.237.36.189 with SMTP id t58mr16003296qtc.332.1508175742848; Mon, 16 Oct 2017 10:42:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508175742; cv=none; d=google.com; s=arc-20160816; b=Hd9dcOQlBFe2Dkh6GK03AUWdHBQHBzTCMb+kksI1UVCYGTzkMOBPl3Jqu5x9JQovkv F1dmCoZRWE/rhfGMPz14FdTBh9gFcz47SeX25KuzLATYtSjQl+0AdAnqqiZI+R4n7toT N5wu6lfM2Gb8pTYlxqUsNvg+xfSt6LvQA34xgetiT+DRo9Z/wMnqG/BW8LPaJfdYZF3L 1yfmX2GQVs9jL/Ch6La6yaeKKFPLJiu7dNUE1ejtYrJiXR9RXll+Hg9fMkgJsFTE/Usi FLCP3KXpAZ08BzSzfauFeCZWT/Hf9zBzDph4EoBHqkZrGC0YKRWEjYV6wwCAoMrawmSq LPZQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=IONFb2XJk+VDbXqkgo7RAVhmeHix+0CIeS5n+r84MQs=; b=H+W35fw/3WyF4251l9TtK6PWqA/8UEuSwVxjprGJReGCw79q+Bx/adNI6j8eSamYfC zcxFtSCpbaMNK+cJg1835ggWBf2s/7mUEheolsiqpaPzYQZqAqgx92cy2NTAa2kb34Sb j8mH1uLsGPpKFhezDIvrjBFXWZPI6cRegVwwZPoZcFT7aQR59yz9FG4CpsY5jMtQVgTH wxP6gggdYdmnZUT95yPPQ1IHEtBfwNjMvJv+++PGFpaPOd2C00tBOZ6wSsPawnShuVbO rpJHCNzSH+aOK1ZRorN9s2XD8Rp8U9sqbkXmFOVhd9tUqUEQNsTYUms8BVYd8Cu5KJWX lIHQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Z4X1fZpa; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id e126si6709953qkd.77.2017.10.16.10.42.22 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 16 Oct 2017 10:42:22 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Z4X1fZpa; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:34358 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e49PA-0006di-D3 for patch@linaro.org; Mon, 16 Oct 2017 13:42:20 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52418) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e49A6-0002KX-Jf for qemu-devel@nongnu.org; Mon, 16 Oct 2017 13:26:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e49A3-0003Zn-Mw for qemu-devel@nongnu.org; Mon, 16 Oct 2017 13:26:46 -0400 Received: from mail-pg0-x234.google.com ([2607:f8b0:400e:c05::234]:54129) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e49A3-0003Z7-Bd for qemu-devel@nongnu.org; Mon, 16 Oct 2017 13:26:43 -0400 Received: by mail-pg0-x234.google.com with SMTP id s2so7346584pge.10 for ; Mon, 16 Oct 2017 10:26:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=IONFb2XJk+VDbXqkgo7RAVhmeHix+0CIeS5n+r84MQs=; b=Z4X1fZpaD6tPaKi5w8ehJZ9vYmKlGYCHZTsmQOXnNLPFP0/cEhVZx/d1AxA3LrmVVu bsJdGeC3GfAwRoZH6OXcht7TUbq0E7sddsUva1JfT18IUj/lXD4PDWzyB3ia8Gz2YlCL HFxvoWf5BB++CSOxlTu9xcFjQBB7UHSWFCSKM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=IONFb2XJk+VDbXqkgo7RAVhmeHix+0CIeS5n+r84MQs=; b=TN1/sFSW/D3YbZvqpJyPxdwI6RZsOGeU+jvhozj+rFO+3J8M7nRLwEgM4LnsIxoikP OiRQc0nwzmL4FjeCOFWZQPNjLHP9lJW3vPlHtSgocBNbRaQkgQ4iGI/9bn9PW0HKXFc2 xPj8RCaptabsajUEDyEQuApicdJ6OASbvO8GJB5TNvxdzy3PQUDAF9Wy1DpwXyN+D0AJ sdRl1FUFlOaoKvbVQTyy3ylJ3c+5zsGyr2fn4gsevmWFHp3hrxc51hxZazlo0yjE+vw7 xyrXG6GoqXIabU0HRAhRw6HUBw4c0TrDVYid6g5QiHdiU9CV2ERZu/euMWTgGJGzCqxW UfqQ== X-Gm-Message-State: AMCzsaWStVZa2+mSDP5bKEd2NYtQIi+pMFHGnzJlP30LvK97gcsfcYW3 2YRaqpUS4OU4gII9N/YTSjHv46B7XxE= X-Google-Smtp-Source: AOwi7QBYunlwpbsdTaRVKhv7PygRKERxAudhrDMT++z/L27aqi6oYwJV3Z6qm+Mx29KgMdPAXAn7ig== X-Received: by 10.159.208.5 with SMTP id a5mr9745636plp.436.1508174801733; Mon, 16 Oct 2017 10:26:41 -0700 (PDT) Received: from cloudburst.twiddle.net (97-126-104-76.tukw.qwest.net. [97.126.104.76]) by smtp.gmail.com with ESMTPSA id i187sm5594249pfc.96.2017.10.16.10.26.40 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 16 Oct 2017 10:26:40 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Mon, 16 Oct 2017 10:25:39 -0700 Message-Id: <20171016172609.23422-21-richard.henderson@linaro.org> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171016172609.23422-1-richard.henderson@linaro.org> References: <20171016172609.23422-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c05::234 Subject: [Qemu-devel] [PATCH v6 20/50] qom: Introduce CPUClass.tcg_initialize 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: cota@braap.org, =?utf-8?q?Andreas_F=C3=A4rber?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Move target cpu tcg initialization to common code, called from cpu_exec_realizefn. Cc: Andreas Färber Signed-off-by: Richard Henderson --- include/qom/cpu.h | 8 ++++++-- target/sparc/cpu.h | 2 +- exec.c | 7 ++++++- target/alpha/cpu.c | 5 +---- target/alpha/translate.c | 6 ------ target/arm/cpu.c | 6 +----- target/cris/cpu.c | 16 ++++++---------- target/hppa/cpu.c | 3 +-- target/hppa/translate.c | 6 ------ target/i386/cpu.c | 5 +---- target/i386/translate.c | 6 ------ target/lm32/cpu.c | 7 +------ target/m68k/cpu.c | 7 +------ target/microblaze/cpu.c | 7 +------ target/mips/cpu.c | 5 +---- target/mips/translate.c | 7 ------- target/moxie/cpu.c | 7 +------ target/moxie/translate.c | 6 ------ target/nios2/cpu.c | 7 +------ target/openrisc/cpu.c | 7 +------ target/ppc/translate.c | 6 ------ target/ppc/translate_init.c | 5 +---- target/s390x/cpu.c | 7 +------ target/sh4/cpu.c | 5 +---- target/sh4/translate.c | 7 ------- target/sparc/cpu.c | 5 +---- target/sparc/translate.c | 9 +-------- target/tilegx/cpu.c | 7 +------ target/tricore/cpu.c | 5 +---- target/tricore/translate.c | 5 +---- target/unicore32/cpu.c | 7 +------ target/xtensa/cpu.c | 7 +------ 32 files changed, 40 insertions(+), 165 deletions(-) -- 2.13.6 Reviewed-by: Emilio G. Cota Acked-by: Andreas Färber Reviewed-by: Philippe Mathieu-DaudĂ© diff --git a/include/qom/cpu.h b/include/qom/cpu.h index 0efebdbcf4..df0ba86202 100644 --- a/include/qom/cpu.h +++ b/include/qom/cpu.h @@ -195,10 +195,8 @@ typedef struct CPUClass { void *opaque); const struct VMStateDescription *vmsd; - int gdb_num_core_regs; const char *gdb_core_xml_file; gchar * (*gdb_arch_name)(CPUState *cpu); - bool gdb_stop_before_watchpoint; void (*cpu_exec_enter)(CPUState *cpu); void (*cpu_exec_exit)(CPUState *cpu); @@ -206,6 +204,12 @@ typedef struct CPUClass { void (*disas_set_info)(CPUState *cpu, disassemble_info *info); vaddr (*adjust_watchpoint_address)(CPUState *cpu, vaddr addr, int len); + void (*tcg_initialize)(void); + + /* Keep non-pointer data at the end to minimize holes. */ + int gdb_num_core_regs; + bool gdb_stop_before_watchpoint; + bool tcg_initialized; } CPUClass; #ifdef HOST_WORDS_BIGENDIAN diff --git a/target/sparc/cpu.h b/target/sparc/cpu.h index 1598f65927..bf2b8931cc 100644 --- a/target/sparc/cpu.h +++ b/target/sparc/cpu.h @@ -594,7 +594,7 @@ int sparc_cpu_memory_rw_debug(CPUState *cpu, vaddr addr, /* translate.c */ -void gen_intermediate_code_init(CPUSPARCState *env); +void sparc_tcg_init(void); /* cpu-exec.c */ diff --git a/exec.c b/exec.c index 6378714a2b..30a1a9fb79 100644 --- a/exec.c +++ b/exec.c @@ -763,10 +763,15 @@ void cpu_exec_initfn(CPUState *cpu) void cpu_exec_realizefn(CPUState *cpu, Error **errp) { - CPUClass *cc ATTRIBUTE_UNUSED = CPU_GET_CLASS(cpu); + CPUClass *cc = CPU_GET_CLASS(cpu); cpu_list_add(cpu); + if (tcg_enabled() && !cc->tcg_initialized) { + cc->tcg_initialized = true; + cc->tcg_initialize(); + } + #ifndef CONFIG_USER_ONLY if (qdev_get_vmsd(DEVICE(cpu)) == NULL) { vmstate_register(NULL, cpu->cpu_index, &vmstate_cpu_common, cpu); diff --git a/target/alpha/cpu.c b/target/alpha/cpu.c index b52ebd7356..bc9520535b 100644 --- a/target/alpha/cpu.c +++ b/target/alpha/cpu.c @@ -260,10 +260,6 @@ static void alpha_cpu_initfn(Object *obj) cs->env_ptr = env; tlb_flush(cs); - if (tcg_enabled()) { - alpha_translate_init(); - } - env->lock_addr = -1; #if defined(CONFIG_USER_ONLY) env->flags = ENV_FLAG_PS_USER | ENV_FLAG_FEN; @@ -301,6 +297,7 @@ static void alpha_cpu_class_init(ObjectClass *oc, void *data) dc->vmsd = &vmstate_alpha_cpu; #endif cc->disas_set_info = alpha_cpu_disas_set_info; + cc->tcg_initialize = alpha_translate_init; cc->gdb_num_core_regs = 67; } diff --git a/target/alpha/translate.c b/target/alpha/translate.c index f32c95b9a1..3c8d1dc333 100644 --- a/target/alpha/translate.c +++ b/target/alpha/translate.c @@ -124,14 +124,8 @@ void alpha_translate_init(void) }; #endif - static bool done_init = 0; int i; - if (done_init) { - return; - } - done_init = 1; - cpu_env = tcg_global_reg_new_ptr(TCG_AREG0, "env"); tcg_ctx.tcg_env = cpu_env; diff --git a/target/arm/cpu.c b/target/arm/cpu.c index 88578f360e..056284985d 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -534,7 +534,6 @@ static void arm_cpu_initfn(Object *obj) { CPUState *cs = CPU(obj); ARMCPU *cpu = ARM_CPU(obj); - static bool inited; cs->env_ptr = &cpu->env; cpu->cp_regs = g_hash_table_new_full(g_int_hash, g_int_equal, @@ -578,10 +577,6 @@ static void arm_cpu_initfn(Object *obj) if (tcg_enabled()) { cpu->psci_version = 2; /* TCG implements PSCI 0.2 */ - if (!inited) { - inited = true; - arm_translate_init(); - } } } @@ -1765,6 +1760,7 @@ static void arm_cpu_class_init(ObjectClass *oc, void *data) #endif cc->disas_set_info = arm_disas_set_info; + cc->tcg_initialize = arm_translate_init; } static void cpu_register(const ARMCPUInfo *info) diff --git a/target/cris/cpu.c b/target/cris/cpu.c index 88d93f2d11..527a3448bf 100644 --- a/target/cris/cpu.c +++ b/target/cris/cpu.c @@ -181,7 +181,6 @@ static void cris_cpu_initfn(Object *obj) CRISCPU *cpu = CRIS_CPU(obj); CRISCPUClass *ccc = CRIS_CPU_GET_CLASS(obj); CPUCRISState *env = &cpu->env; - static bool tcg_initialized; cs->env_ptr = env; @@ -191,15 +190,6 @@ static void cris_cpu_initfn(Object *obj) /* IRQ and NMI lines. */ qdev_init_gpio_in(DEVICE(cpu), cris_cpu_set_irq, 2); #endif - - if (tcg_enabled() && !tcg_initialized) { - tcg_initialized = true; - if (env->pregs[PR_VR] < 32) { - cris_initialize_crisv10_tcg(); - } else { - cris_initialize_tcg(); - } - } } static void crisv8_cpu_class_init(ObjectClass *oc, void *data) @@ -210,6 +200,7 @@ static void crisv8_cpu_class_init(ObjectClass *oc, void *data) ccc->vr = 8; cc->do_interrupt = crisv10_cpu_do_interrupt; cc->gdb_read_register = crisv10_cpu_gdb_read_register; + cc->tcg_initialize = cris_initialize_crisv10_tcg; } static void crisv9_cpu_class_init(ObjectClass *oc, void *data) @@ -220,6 +211,7 @@ static void crisv9_cpu_class_init(ObjectClass *oc, void *data) ccc->vr = 9; cc->do_interrupt = crisv10_cpu_do_interrupt; cc->gdb_read_register = crisv10_cpu_gdb_read_register; + cc->tcg_initialize = cris_initialize_crisv10_tcg; } static void crisv10_cpu_class_init(ObjectClass *oc, void *data) @@ -230,6 +222,7 @@ static void crisv10_cpu_class_init(ObjectClass *oc, void *data) ccc->vr = 10; cc->do_interrupt = crisv10_cpu_do_interrupt; cc->gdb_read_register = crisv10_cpu_gdb_read_register; + cc->tcg_initialize = cris_initialize_crisv10_tcg; } static void crisv11_cpu_class_init(ObjectClass *oc, void *data) @@ -240,6 +233,7 @@ static void crisv11_cpu_class_init(ObjectClass *oc, void *data) ccc->vr = 11; cc->do_interrupt = crisv10_cpu_do_interrupt; cc->gdb_read_register = crisv10_cpu_gdb_read_register; + cc->tcg_initialize = cris_initialize_crisv10_tcg; } static void crisv17_cpu_class_init(ObjectClass *oc, void *data) @@ -250,6 +244,7 @@ static void crisv17_cpu_class_init(ObjectClass *oc, void *data) ccc->vr = 17; cc->do_interrupt = crisv10_cpu_do_interrupt; cc->gdb_read_register = crisv10_cpu_gdb_read_register; + cc->tcg_initialize = cris_initialize_crisv10_tcg; } static void crisv32_cpu_class_init(ObjectClass *oc, void *data) @@ -322,6 +317,7 @@ static void cris_cpu_class_init(ObjectClass *oc, void *data) cc->gdb_stop_before_watchpoint = true; cc->disas_set_info = cris_disas_set_info; + cc->tcg_initialize = cris_initialize_tcg; } static const TypeInfo cris_cpu_type_info = { diff --git a/target/hppa/cpu.c b/target/hppa/cpu.c index a477b452f0..9e7b0d4ccb 100644 --- a/target/hppa/cpu.c +++ b/target/hppa/cpu.c @@ -108,8 +108,6 @@ static void hppa_cpu_initfn(Object *obj) cs->env_ptr = env; cpu_hppa_loaded_fr0(env); set_snan_bit_is_one(true, &env->fp_status); - - hppa_translate_init(); } static ObjectClass *hppa_cpu_class_by_name(const char *cpu_model) @@ -136,6 +134,7 @@ static void hppa_cpu_class_init(ObjectClass *oc, void *data) cc->gdb_write_register = hppa_cpu_gdb_write_register; cc->handle_mmu_fault = hppa_cpu_handle_mmu_fault; cc->disas_set_info = hppa_cpu_disas_set_info; + cc->tcg_initialize = hppa_translate_init; cc->gdb_num_core_regs = 128; } diff --git a/target/hppa/translate.c b/target/hppa/translate.c index 26242f4b3c..334ee74e4c 100644 --- a/target/hppa/translate.c +++ b/target/hppa/translate.c @@ -124,14 +124,8 @@ void hppa_translate_init(void) "r24", "r25", "r26", "r27", "r28", "r29", "r30", "r31" }; - static bool done_init = 0; int i; - if (done_init) { - return; - } - done_init = 1; - cpu_env = tcg_global_reg_new_ptr(TCG_AREG0, "env"); tcg_ctx.tcg_env = cpu_env; diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 98732cd65f..53ec94ac9b 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -3719,10 +3719,6 @@ static void x86_cpu_realizefn(DeviceState *dev, Error **errp) return; } - if (tcg_enabled()) { - tcg_x86_init(); - } - #ifndef CONFIG_USER_ONLY qemu_register_reset(x86_cpu_machine_reset_cb, cpu); @@ -4216,6 +4212,7 @@ static void x86_cpu_common_class_init(ObjectClass *oc, void *data) #endif cc->cpu_exec_enter = x86_cpu_exec_enter; cc->cpu_exec_exit = x86_cpu_exec_exit; + cc->tcg_initialize = tcg_x86_init; dc->user_creatable = true; } diff --git a/target/i386/translate.c b/target/i386/translate.c index 5d61fa96ad..51860c8db2 100644 --- a/target/i386/translate.c +++ b/target/i386/translate.c @@ -8329,12 +8329,6 @@ void tcg_x86_init(void) "bnd0_ub", "bnd1_ub", "bnd2_ub", "bnd3_ub" }; int i; - static bool initialized; - - if (initialized) { - return; - } - initialized = true; cpu_env = tcg_global_reg_new_ptr(TCG_AREG0, "env"); tcg_ctx.tcg_env = cpu_env; diff --git a/target/lm32/cpu.c b/target/lm32/cpu.c index bf081f56d2..7f3a292f2b 100644 --- a/target/lm32/cpu.c +++ b/target/lm32/cpu.c @@ -163,16 +163,10 @@ static void lm32_cpu_initfn(Object *obj) CPUState *cs = CPU(obj); LM32CPU *cpu = LM32_CPU(obj); CPULM32State *env = &cpu->env; - static bool tcg_initialized; cs->env_ptr = env; env->flags = 0; - - if (tcg_enabled() && !tcg_initialized) { - tcg_initialized = true; - lm32_translate_init(); - } } static void lm32_basic_cpu_initfn(Object *obj) @@ -286,6 +280,7 @@ static void lm32_cpu_class_init(ObjectClass *oc, void *data) cc->gdb_stop_before_watchpoint = true; cc->debug_excp_handler = lm32_debug_excp_handler; cc->disas_set_info = lm32_cpu_disas_set_info; + cc->tcg_initialize = lm32_translate_init; } static void lm32_register_cpu_type(const LM32CPUInfo *info) diff --git a/target/m68k/cpu.c b/target/m68k/cpu.c index 8c70e0805c..5da19e570b 100644 --- a/target/m68k/cpu.c +++ b/target/m68k/cpu.c @@ -247,14 +247,8 @@ static void m68k_cpu_initfn(Object *obj) CPUState *cs = CPU(obj); M68kCPU *cpu = M68K_CPU(obj); CPUM68KState *env = &cpu->env; - static bool inited; cs->env_ptr = env; - - if (tcg_enabled() && !inited) { - inited = true; - m68k_tcg_init(); - } } static const VMStateDescription vmstate_m68k_cpu = { @@ -288,6 +282,7 @@ static void m68k_cpu_class_init(ObjectClass *c, void *data) cc->get_phys_page_debug = m68k_cpu_get_phys_page_debug; #endif cc->disas_set_info = m68k_cpu_disas_set_info; + cc->tcg_initialize = m68k_tcg_init; cc->gdb_num_core_regs = 18; cc->gdb_core_xml_file = "cf-core.xml"; diff --git a/target/microblaze/cpu.c b/target/microblaze/cpu.c index ddffe86e9b..5700652e06 100644 --- a/target/microblaze/cpu.c +++ b/target/microblaze/cpu.c @@ -205,7 +205,6 @@ static void mb_cpu_initfn(Object *obj) CPUState *cs = CPU(obj); MicroBlazeCPU *cpu = MICROBLAZE_CPU(obj); CPUMBState *env = &cpu->env; - static bool tcg_initialized; cs->env_ptr = env; @@ -215,11 +214,6 @@ static void mb_cpu_initfn(Object *obj) /* Inbound IRQ and FIR lines */ qdev_init_gpio_in(DEVICE(cpu), microblaze_cpu_set_irq, 2); #endif - - if (tcg_enabled() && !tcg_initialized) { - tcg_initialized = true; - mb_tcg_init(); - } } static const VMStateDescription vmstate_mb_cpu = { @@ -289,6 +283,7 @@ static void mb_cpu_class_init(ObjectClass *oc, void *data) cc->gdb_num_core_regs = 32 + 5; cc->disas_set_info = mb_disas_set_info; + cc->tcg_initialize = mb_tcg_init; } static const TypeInfo mb_cpu_type_info = { diff --git a/target/mips/cpu.c b/target/mips/cpu.c index c15b894362..0ae70288dd 100644 --- a/target/mips/cpu.c +++ b/target/mips/cpu.c @@ -150,10 +150,6 @@ static void mips_cpu_initfn(Object *obj) cs->env_ptr = env; env->cpu_model = mcc->cpu_def; - - if (tcg_enabled()) { - mips_tcg_init(); - } } static char *mips_cpu_type_name(const char *cpu_model) @@ -202,6 +198,7 @@ static void mips_cpu_class_init(ObjectClass *c, void *data) cc->vmsd = &vmstate_mips_cpu; #endif cc->disas_set_info = mips_cpu_disas_set_info; + cc->tcg_initialize = mips_tcg_init; cc->gdb_num_core_regs = 73; cc->gdb_stop_before_watchpoint = true; diff --git a/target/mips/translate.c b/target/mips/translate.c index ac05f3aa09..ef07fa827e 100644 --- a/target/mips/translate.c +++ b/target/mips/translate.c @@ -20453,11 +20453,6 @@ void mips_cpu_dump_state(CPUState *cs, FILE *f, fprintf_function cpu_fprintf, void mips_tcg_init(void) { int i; - static int inited; - - /* Initialize various static tables. */ - if (inited) - return; cpu_env = tcg_global_reg_new_ptr(TCG_AREG0, "env"); tcg_ctx.tcg_env = cpu_env; @@ -20506,8 +20501,6 @@ void mips_tcg_init(void) fpu_fcr31 = tcg_global_mem_new_i32(cpu_env, offsetof(CPUMIPSState, active_fpu.fcr31), "fcr31"); - - inited = 1; } #include "translate_init.c" diff --git a/target/moxie/cpu.c b/target/moxie/cpu.c index 30bd44fcad..24ab3f3708 100644 --- a/target/moxie/cpu.c +++ b/target/moxie/cpu.c @@ -77,14 +77,8 @@ static void moxie_cpu_initfn(Object *obj) { CPUState *cs = CPU(obj); MoxieCPU *cpu = MOXIE_CPU(obj); - static int inited; cs->env_ptr = &cpu->env; - - if (tcg_enabled() && !inited) { - inited = 1; - moxie_translate_init(); - } } static ObjectClass *moxie_cpu_class_by_name(const char *cpu_model) @@ -122,6 +116,7 @@ static void moxie_cpu_class_init(ObjectClass *oc, void *data) cc->vmsd = &vmstate_moxie_cpu; #endif cc->disas_set_info = moxie_cpu_disas_set_info; + cc->tcg_initialize = moxie_translate_init; } static void moxielite_initfn(Object *obj) diff --git a/target/moxie/translate.c b/target/moxie/translate.c index 3cfd232558..eaf5103920 100644 --- a/target/moxie/translate.c +++ b/target/moxie/translate.c @@ -94,7 +94,6 @@ void moxie_cpu_dump_state(CPUState *cs, FILE *f, fprintf_function cpu_fprintf, void moxie_translate_init(void) { int i; - static int done_init; static const char * const gregnames[16] = { "$fp", "$sp", "$r0", "$r1", "$r2", "$r3", "$r4", "$r5", @@ -102,9 +101,6 @@ void moxie_translate_init(void) "$r10", "$r11", "$r12", "$r13" }; - if (done_init) { - return; - } cpu_env = tcg_global_reg_new_ptr(TCG_AREG0, "env"); tcg_ctx.tcg_env = cpu_env; cpu_pc = tcg_global_mem_new_i32(cpu_env, @@ -118,8 +114,6 @@ void moxie_translate_init(void) offsetof(CPUMoxieState, cc_a), "cc_a"); cc_b = tcg_global_mem_new_i32(cpu_env, offsetof(CPUMoxieState, cc_b), "cc_b"); - - done_init = 1; } static inline bool use_goto_tb(DisasContext *ctx, target_ulong dest) diff --git a/target/nios2/cpu.c b/target/nios2/cpu.c index 5b02fb67ea..4742e52c78 100644 --- a/target/nios2/cpu.c +++ b/target/nios2/cpu.c @@ -69,18 +69,12 @@ static void nios2_cpu_initfn(Object *obj) CPUState *cs = CPU(obj); Nios2CPU *cpu = NIOS2_CPU(obj); CPUNios2State *env = &cpu->env; - static bool tcg_initialized; cs->env_ptr = env; #if !defined(CONFIG_USER_ONLY) mmu_init(env); #endif - - if (tcg_enabled() && !tcg_initialized) { - tcg_initialized = true; - nios2_tcg_init(); - } } static ObjectClass *nios2_cpu_class_by_name(const char *cpu_model) @@ -215,6 +209,7 @@ static void nios2_cpu_class_init(ObjectClass *oc, void *data) cc->gdb_read_register = nios2_cpu_gdb_read_register; cc->gdb_write_register = nios2_cpu_gdb_write_register; cc->gdb_num_core_regs = 49; + cc->tcg_initialize = nios2_tcg_init; } static const TypeInfo nios2_cpu_type_info = { diff --git a/target/openrisc/cpu.c b/target/openrisc/cpu.c index af9cdcc102..2b5a59061c 100644 --- a/target/openrisc/cpu.c +++ b/target/openrisc/cpu.c @@ -87,18 +87,12 @@ static void openrisc_cpu_initfn(Object *obj) { CPUState *cs = CPU(obj); OpenRISCCPU *cpu = OPENRISC_CPU(obj); - static int inited; cs->env_ptr = &cpu->env; #ifndef CONFIG_USER_ONLY cpu_openrisc_mmu_init(cpu); #endif - - if (tcg_enabled() && !inited) { - inited = 1; - openrisc_translate_init(); - } } /* CPU models */ @@ -170,6 +164,7 @@ static void openrisc_cpu_class_init(ObjectClass *oc, void *data) dc->vmsd = &vmstate_openrisc_cpu; #endif cc->gdb_num_core_regs = 32 + 3; + cc->tcg_initialize = openrisc_translate_init; } static void cpu_register(const OpenRISCCPUInfo *info) diff --git a/target/ppc/translate.c b/target/ppc/translate.c index 606b605ba0..770b461704 100644 --- a/target/ppc/translate.c +++ b/target/ppc/translate.c @@ -84,10 +84,6 @@ void ppc_translate_init(void) int i; char* p; size_t cpu_reg_names_size; - static int done_init = 0; - - if (done_init) - return; cpu_env = tcg_global_reg_new_ptr(TCG_AREG0, "env"); tcg_ctx.tcg_env = cpu_env; @@ -191,8 +187,6 @@ void ppc_translate_init(void) cpu_access_type = tcg_global_mem_new_i32(cpu_env, offsetof(CPUPPCState, access_type), "access_type"); - - done_init = 1; } /* internal defines */ diff --git a/target/ppc/translate_init.c b/target/ppc/translate_init.c index c6399a3a0d..4397254dbf 100644 --- a/target/ppc/translate_init.c +++ b/target/ppc/translate_init.c @@ -10661,10 +10661,6 @@ static void ppc_cpu_initfn(Object *obj) env->sps = (env->mmu_model & POWERPC_MMU_64K) ? defsps_64k : defsps_4k; } #endif /* defined(TARGET_PPC64) */ - - if (tcg_enabled()) { - ppc_translate_init(); - } } static bool ppc_pvr_match_default(PowerPCCPUClass *pcc, uint32_t pvr) @@ -10742,6 +10738,7 @@ static void ppc_cpu_class_init(ObjectClass *oc, void *data) #ifndef CONFIG_USER_ONLY cc->virtio_is_big_endian = ppc_cpu_is_big_endian; #endif + cc->tcg_initialize = ppc_translate_init; dc->fw_name = "PowerPC,UNKNOWN"; } diff --git a/target/s390x/cpu.c b/target/s390x/cpu.c index 3fdf9bae70..74b64032f4 100644 --- a/target/s390x/cpu.c +++ b/target/s390x/cpu.c @@ -235,7 +235,6 @@ static void s390_cpu_initfn(Object *obj) CPUState *cs = CPU(obj); S390CPU *cpu = S390_CPU(obj); CPUS390XState *env = &cpu->env; - static bool inited; #if !defined(CONFIG_USER_ONLY) struct tm tm; #endif @@ -253,11 +252,6 @@ static void s390_cpu_initfn(Object *obj) env->cpu_timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, s390x_cpu_timer, cpu); s390_cpu_set_state(CPU_STATE_STOPPED, cpu); #endif - - if (tcg_enabled() && !inited) { - inited = true; - s390x_translate_init(); - } } static void s390_cpu_finalize(Object *obj) @@ -498,6 +492,7 @@ static void s390_cpu_class_init(ObjectClass *oc, void *data) #endif #endif cc->disas_set_info = s390_cpu_disas_set_info; + cc->tcg_initialize = s390x_translate_init; cc->gdb_num_core_regs = S390_NUM_CORE_REGS; cc->gdb_core_xml_file = "s390x-core64.xml"; diff --git a/target/sh4/cpu.c b/target/sh4/cpu.c index 252440e019..89abce2472 100644 --- a/target/sh4/cpu.c +++ b/target/sh4/cpu.c @@ -258,10 +258,6 @@ static void superh_cpu_initfn(Object *obj) cs->env_ptr = env; env->movcal_backup_tail = &(env->movcal_backup); - - if (tcg_enabled()) { - sh4_translate_init(); - } } static const VMStateDescription vmstate_sh_cpu = { @@ -297,6 +293,7 @@ static void superh_cpu_class_init(ObjectClass *oc, void *data) cc->get_phys_page_debug = superh_cpu_get_phys_page_debug; #endif cc->disas_set_info = superh_cpu_disas_set_info; + cc->tcg_initialize = sh4_translate_init; cc->gdb_num_core_regs = 59; diff --git a/target/sh4/translate.c b/target/sh4/translate.c index 8db9fba26e..b4e4fd3782 100644 --- a/target/sh4/translate.c +++ b/target/sh4/translate.c @@ -81,7 +81,6 @@ static TCGv cpu_flags, cpu_delayed_pc, cpu_delayed_cond; void sh4_translate_init(void) { int i; - static int done_init = 0; static const char * const gregnames[24] = { "R0_BANK0", "R1_BANK0", "R2_BANK0", "R3_BANK0", "R4_BANK0", "R5_BANK0", "R6_BANK0", "R7_BANK0", @@ -100,10 +99,6 @@ void sh4_translate_init(void) "FPR12_BANK1", "FPR13_BANK1", "FPR14_BANK1", "FPR15_BANK1", }; - if (done_init) { - return; - } - cpu_env = tcg_global_reg_new_ptr(TCG_AREG0, "env"); tcg_ctx.tcg_env = cpu_env; @@ -163,8 +158,6 @@ void sh4_translate_init(void) cpu_fregs[i] = tcg_global_mem_new_i32(cpu_env, offsetof(CPUSH4State, fregs[i]), fregnames[i]); - - done_init = 1; } void superh_cpu_dump_state(CPUState *cs, FILE *f, diff --git a/target/sparc/cpu.c b/target/sparc/cpu.c index beab90f3e6..47d0927707 100644 --- a/target/sparc/cpu.c +++ b/target/sparc/cpu.c @@ -784,10 +784,6 @@ static void sparc_cpu_initfn(Object *obj) cs->env_ptr = env; - if (tcg_enabled()) { - gen_intermediate_code_init(env); - } - if (scc->cpu_def) { env->def = *scc->cpu_def; } @@ -891,6 +887,7 @@ static void sparc_cpu_class_init(ObjectClass *oc, void *data) cc->vmsd = &vmstate_sparc_cpu; #endif cc->disas_set_info = cpu_sparc_disas_set_info; + cc->tcg_initialize = sparc_tcg_init; #if defined(TARGET_SPARC64) && !defined(TARGET_ABI32) cc->gdb_num_core_regs = 86; diff --git a/target/sparc/translate.c b/target/sparc/translate.c index 6290705b11..f63d7fb6ab 100644 --- a/target/sparc/translate.c +++ b/target/sparc/translate.c @@ -5862,9 +5862,8 @@ void gen_intermediate_code(CPUState *cs, TranslationBlock * tb) #endif } -void gen_intermediate_code_init(CPUSPARCState *env) +void sparc_tcg_init(void) { - static int inited; static const char gregnames[32][4] = { "g0", "g1", "g2", "g3", "g4", "g5", "g6", "g7", "o0", "o1", "o2", "o3", "o4", "o5", "o6", "o7", @@ -5917,12 +5916,6 @@ void gen_intermediate_code_init(CPUSPARCState *env) unsigned int i; - /* init various static tables */ - if (inited) { - return; - } - inited = 1; - cpu_env = tcg_global_reg_new_ptr(TCG_AREG0, "env"); tcg_ctx.tcg_env = cpu_env; diff --git a/target/tilegx/cpu.c b/target/tilegx/cpu.c index 7345f5a8b5..2ef8ea7daa 100644 --- a/target/tilegx/cpu.c +++ b/target/tilegx/cpu.c @@ -103,14 +103,8 @@ static void tilegx_cpu_initfn(Object *obj) CPUState *cs = CPU(obj); TileGXCPU *cpu = TILEGX_CPU(obj); CPUTLGState *env = &cpu->env; - static bool tcg_initialized; cs->env_ptr = env; - - if (tcg_enabled() && !tcg_initialized) { - tcg_initialized = true; - tilegx_tcg_init(); - } } static void tilegx_cpu_do_interrupt(CPUState *cs) @@ -161,6 +155,7 @@ static void tilegx_cpu_class_init(ObjectClass *oc, void *data) cc->set_pc = tilegx_cpu_set_pc; cc->handle_mmu_fault = tilegx_cpu_handle_mmu_fault; cc->gdb_num_core_regs = 0; + cc->tcg_initialize = tilegx_tcg_init; } static const TypeInfo tilegx_cpu_type_info = { diff --git a/target/tricore/cpu.c b/target/tricore/cpu.c index 871eb35453..cd93806d47 100644 --- a/target/tricore/cpu.c +++ b/target/tricore/cpu.c @@ -109,10 +109,6 @@ static void tricore_cpu_initfn(Object *obj) CPUTriCoreState *env = &cpu->env; cs->env_ptr = env; - - if (tcg_enabled()) { - tricore_tcg_init(); - } } static ObjectClass *tricore_cpu_class_by_name(const char *cpu_model) @@ -182,6 +178,7 @@ static void tricore_cpu_class_init(ObjectClass *c, void *data) cc->set_pc = tricore_cpu_set_pc; cc->synchronize_from_tb = tricore_cpu_synchronize_from_tb; cc->get_phys_page_attrs_debug = tricore_cpu_get_phys_page_attrs_debug; + cc->tcg_initialize = tricore_tcg_init; } static void cpu_register(const TriCoreCPUInfo *info) diff --git a/target/tricore/translate.c b/target/tricore/translate.c index 4e4198e887..b6cfbdfa9f 100644 --- a/target/tricore/translate.c +++ b/target/tricore/translate.c @@ -8880,10 +8880,7 @@ static void tricore_tcg_init_csfr(void) void tricore_tcg_init(void) { int i; - static int inited; - if (inited) { - return; - } + cpu_env = tcg_global_reg_new_ptr(TCG_AREG0, "env"); tcg_ctx.tcg_env = cpu_env; /* reg init */ diff --git a/target/unicore32/cpu.c b/target/unicore32/cpu.c index 138acc9dd8..526604ff78 100644 --- a/target/unicore32/cpu.c +++ b/target/unicore32/cpu.c @@ -117,7 +117,6 @@ static void uc32_cpu_initfn(Object *obj) CPUState *cs = CPU(obj); UniCore32CPU *cpu = UNICORE32_CPU(obj); CPUUniCore32State *env = &cpu->env; - static bool inited; cs->env_ptr = env; @@ -130,11 +129,6 @@ static void uc32_cpu_initfn(Object *obj) #endif tlb_flush(cs); - - if (tcg_enabled() && !inited) { - inited = true; - uc32_translate_init(); - } } static const VMStateDescription vmstate_uc32_cpu = { @@ -162,6 +156,7 @@ static void uc32_cpu_class_init(ObjectClass *oc, void *data) #else cc->get_phys_page_debug = uc32_cpu_get_phys_page_debug; #endif + cc->tcg_initialize = uc32_translate_init; dc->vmsd = &vmstate_uc32_cpu; } diff --git a/target/xtensa/cpu.c b/target/xtensa/cpu.c index dcdc765a86..a5651e5dab 100644 --- a/target/xtensa/cpu.c +++ b/target/xtensa/cpu.c @@ -121,7 +121,6 @@ static void xtensa_cpu_initfn(Object *obj) XtensaCPU *cpu = XTENSA_CPU(obj); XtensaCPUClass *xcc = XTENSA_CPU_GET_CLASS(obj); CPUXtensaState *env = &cpu->env; - static bool tcg_inited; cs->env_ptr = env; env->config = xcc->config; @@ -131,11 +130,6 @@ static void xtensa_cpu_initfn(Object *obj) memory_region_init_io(env->system_er, NULL, NULL, env, "er", UINT64_C(0x100000000)); address_space_init(env->address_space_er, env->system_er, "ER"); - - if (tcg_enabled() && !tcg_inited) { - tcg_inited = true; - xtensa_translate_init(); - } } static const VMStateDescription vmstate_xtensa_cpu = { @@ -170,6 +164,7 @@ static void xtensa_cpu_class_init(ObjectClass *oc, void *data) cc->do_unassigned_access = xtensa_cpu_do_unassigned_access; #endif cc->debug_excp_handler = xtensa_breakpoint_handler; + cc->tcg_initialize = xtensa_translate_init; dc->vmsd = &vmstate_xtensa_cpu; } From patchwork Mon Oct 16 17:25:40 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 115943 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp3943803qgn; Mon, 16 Oct 2017 10:37:47 -0700 (PDT) X-Received: by 10.55.33.203 with SMTP id f72mr15177347qki.176.1508175467674; Mon, 16 Oct 2017 10:37:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508175467; cv=none; d=google.com; s=arc-20160816; b=pbTSZ8PEhb5/m3uBLpSPqOy8XFkYkFLt3MrPgunEnWgprU20mBInI6z6owHt6MiTkl uMykCHy4KZ1lauY+tm1k0J8akaK7RE6wZdMoY4NHgM0lFgjENK5erSbOmXeyfqKP0OE5 +wVF3MOeJwZzjn3yMfZmI7o8IiRmnzBL0uB25cM2ulOBMUW0g1C6cecp21MgoZuIjmpJ wOWYEhqaQkTPu2H+jmjNrsUwcLCXfjyhotKzMuBM+W6BOH2BmfQeEhgxZ/dVNg77Se7o a/OqJFKNIZrNH9bSq1+UCP+Awx7voGLz4oO6Kinik8eh0SNV7EWAc7V/MiBzThp5Zi5L 6crQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=CKzrL3nrIbxNWEEUClAtJxQyYcnjHcU6IGSZwQDG0YE=; b=PzTmEWy0eOSCaXv9CYVqBsvAqtkRNcFQEu8GZa+diIzbWpJDoE4KZODsLU5SsYoRMv kwUQM04VMLpTOvaIXAFgeToEYTPQHppKlc2tdX8luXIviltwFoLFbwbp85ITfiTwMrZb UUom7kCG6kaN8aZ6xN3c//oFRccu0dUjNkKoVFjglYZnyPTSV222ajjYphioHmwuMWsz Oy9fO1nmeIr8PwALeOkpY0gD1e29ozXC7GN5toC8hBBj0AZF/Q0BVxa8EZUenm86ZJ41 ueYAQ+kZOLLdX/vIxzixH8sYDKBmlw7R4+JauCjiF5py6aCpwfdcfkmA7D17umHBNVgN Jcmw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=ZbTWWpez; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id g16si454106qtk.436.2017.10.16.10.37.47 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 16 Oct 2017 10:37:47 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=ZbTWWpez; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:34340 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e49Kj-0003AC-I2 for patch@linaro.org; Mon, 16 Oct 2017 13:37:45 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52407) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e49A5-0002JH-Hc for qemu-devel@nongnu.org; Mon, 16 Oct 2017 13:26:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e49A4-0003aR-JF for qemu-devel@nongnu.org; Mon, 16 Oct 2017 13:26:45 -0400 Received: from mail-pf0-x22a.google.com ([2607:f8b0:400e:c00::22a]:44288) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e49A4-0003Zv-DQ for qemu-devel@nongnu.org; Mon, 16 Oct 2017 13:26:44 -0400 Received: by mail-pf0-x22a.google.com with SMTP id x7so16317335pfa.1 for ; Mon, 16 Oct 2017 10:26:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=CKzrL3nrIbxNWEEUClAtJxQyYcnjHcU6IGSZwQDG0YE=; b=ZbTWWpez/7DqTR8WXo+ltznZXYs9OmU3R+UH5rU84ya2DUIN7B7HogfD6xuwfq6kWm nPGsmgNYvf3aIZcJcD4cFj2EPB5+eSz94aw2b4RiVsWcmWUF9cYRGcGAez5FT7tO6pCk UVKjVU+hlnrkB2vnD1hLBH1ypBfkrP9/Gq7RY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=CKzrL3nrIbxNWEEUClAtJxQyYcnjHcU6IGSZwQDG0YE=; b=k3AHD6tsF9fijXwmtBf/iHOcZY1zoR0okmK3hSHEQqtLtKghTWZA13KxUzhZs6fr0R pZooFlY2FBqlYdp9ipUHYwl2jSSBSOC7ekku2j52seOHkoj3zwCYxBEEXt9Sx3Qo9ym6 5Kt0LBugcTunuqwu6dJVUMvCICrkA7mQuCzvPZnTexla2rikzOuF1ck9yxytf8Yng+oE loUy504IDNe8NcWYyDz+AMNautDtgMS6afkOysESOiVHJ2qI5XeRZomkk6BqhaaDtbxJ tSBC/ExO8mYNIjU6NGL+Fqg/iOz1eQGMH6o95PmMpk5z3Yo1gTKzAlLmwz9NkQLtyDiQ DOag== X-Gm-Message-State: AMCzsaVgr7PKagMd6pg9hJ7CglZinp3yDPKaFyZXCbpinIk87zkKkXho 0uWn7SPovacdPPuFvC5XOKWkEZJmlXo= X-Google-Smtp-Source: AOwi7QC3Z/FY+BnS6jKqPTduZxfObGkI8KKn5gWhXR9qi16D1PYGqj/dHuWDWdJPsyXhBF032pwP3A== X-Received: by 10.159.207.131 with SMTP id z3mr9724184plo.191.1508174803241; Mon, 16 Oct 2017 10:26:43 -0700 (PDT) Received: from cloudburst.twiddle.net (97-126-104-76.tukw.qwest.net. [97.126.104.76]) by smtp.gmail.com with ESMTPSA id i187sm5594249pfc.96.2017.10.16.10.26.41 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 16 Oct 2017 10:26:42 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Mon, 16 Oct 2017 10:25:40 -0700 Message-Id: <20171016172609.23422-22-richard.henderson@linaro.org> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171016172609.23422-1-richard.henderson@linaro.org> References: <20171016172609.23422-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c00::22a Subject: [Qemu-devel] [PATCH v6 21/50] tcg: Use pointers in TCGOp->args 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: cota@braap.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" This limits the indexing into tcg_ctx.temps to initial opcode generation time. Signed-off-by: Richard Henderson --- tcg/tcg.h | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) -- 2.13.6 Reviewed-by: Emilio G. Cota diff --git a/tcg/tcg.h b/tcg/tcg.h index ccf1bcdaf6..d5bf61b1cf 100644 --- a/tcg/tcg.h +++ b/tcg/tcg.h @@ -741,24 +741,29 @@ static inline size_t temp_idx(TCGTemp *ts) return n; } +static inline TCGTemp *idx_temp(size_t n) +{ + return n == TCG_CALL_DUMMY_ARG ? NULL : &tcg_ctx.temps[n]; +} + static inline TCGArg temp_arg(TCGTemp *ts) { - return temp_idx(ts); + return (uintptr_t)ts; } static inline TCGTemp *arg_temp(TCGArg a) { - return a == TCG_CALL_DUMMY_ARG ? NULL : &tcg_ctx.temps[a]; + return (TCGTemp *)a; } static inline size_t arg_index(TCGArg a) { - return a; + return temp_idx(arg_temp(a)); } static inline TCGArg index_arg(size_t n) { - return n; + return temp_arg(idx_temp(n)); } static inline TCGArg tcgv_i32_arg(TCGv_i32 t) From patchwork Mon Oct 16 17:25:41 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 115948 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp3946394qgn; Mon, 16 Oct 2017 10:40:57 -0700 (PDT) X-Received: by 10.55.102.215 with SMTP id a206mr15258638qkc.269.1508175657835; Mon, 16 Oct 2017 10:40:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508175657; cv=none; d=google.com; s=arc-20160816; b=BLgIpVJGDtFhnBwNc17gSALIIHwEhAn38amu/bAOKQGwmP1FfnqSSzYoaMUrD6cZSx zCbmdW5OMy1HLylZwOnPNYWrTpvFfyjn6wrNfjsn7/Qy62gqy16kIsZL2UUsUTTscBVk FFjSTt0Q5c4HmcT6PQRJI6jcauc7O3mL6lpDlU7a45lw7f2DIAvdFiKB99wtFyKC0BMg lsLp/Py1s6zfJKtmu3znmKdfdg+8pNXr8p1VOMszXKJY/mphucumOxzPXHzOdj/IaFOg ZcNncQgnWgX/n5qE5qAwyKFXmHqaOkGC3VRe7wUfOvpvsHH54Jo8u2aglxODHAy5+HC+ PHaQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=4KOSZmF6KY2F5O3AWX8XxXx225xmKmTHj8EK9B+6V/c=; b=NhczLyBGm4ySe5BNanWI3Leaf7NVCeuF9dg7GkP7AqSafF09QRFKBW0QGypJlT22VY LHIlsyeAK8j/+qO/RMeFmaWy6JcxdnvusmTUaytciaawyU6+haD4p02EurUVUTV3uKx+ flzQxphTmUmAN5hl3lKd61EkoCKuAwg4LxNB1R6WR7tyOaZS/sngjwa1JyrbHuA4bgG9 I3+H4hTKpnvK771lp2cXV6PJRsgCvMOQF5ZsDiHgyNFRo0ABR1LS1f9cGAO1IlfvyrZo Kwim245C9RH/v/eaP15xqGOxCUx7Nk0lGDdP/As4G7PO3XBjzUvvYIPI5HLPHOKLkP2T N4Eg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=EbFE2CNY; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id f35si1142596qte.215.2017.10.16.10.40.57 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 16 Oct 2017 10:40:57 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=EbFE2CNY; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:34355 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e49Nn-0005me-Em for patch@linaro.org; Mon, 16 Oct 2017 13:40:55 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52436) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e49A8-0002Ma-JJ for qemu-devel@nongnu.org; Mon, 16 Oct 2017 13:26:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e49A6-0003bw-M3 for qemu-devel@nongnu.org; Mon, 16 Oct 2017 13:26:48 -0400 Received: from mail-pf0-x22a.google.com ([2607:f8b0:400e:c00::22a]:47608) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e49A6-0003bH-DH for qemu-devel@nongnu.org; Mon, 16 Oct 2017 13:26:46 -0400 Received: by mail-pf0-x22a.google.com with SMTP id z11so16297869pfk.4 for ; Mon, 16 Oct 2017 10:26:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=4KOSZmF6KY2F5O3AWX8XxXx225xmKmTHj8EK9B+6V/c=; b=EbFE2CNYNmhGk6tGdDVfHdF4Cif50NcIrH2/o7szGaqmNkNuwwVLasVzLlNzRhkk6o ewXwjd75LRB89Xx/fkXVsxcVf8VTypbuZjw8TmFJXn+UWk2Ne1y4h6Mk/3m2H+IVKoHR Yw5/4e8/OkCDHAYI/jp+XtMtyfo9cmjncFR3A= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=4KOSZmF6KY2F5O3AWX8XxXx225xmKmTHj8EK9B+6V/c=; b=OV1eyCI7XDXH439YWbuzIXYNdiusPm3Wz3wtSifzUMa2oc3YMMrg1itbIqhQzuGvA/ Y41Qpa7Pz1yvDHE3CQ8LEewtaanpY8+m4IYi66l0OAzy3tY4LRgKtTNhMN5eGrS8btQQ 56EX25dLhM4sYz6MRiYv9HyTctlRBSz/0zCBYLZxYfM+shYfd+cN801h6QblGKR/DvHq KGvFP4u1YDOQh0XRX+vRg5b85lUnvITyUpRYCDGtyNN0JFKFjTmLbdWEh8unIWziTqjM L37OpRlTdCWXnjfbIMahoV2BnY/AjTPGO70US25+qvxXpiHxZtvq4BTaHZzeJmXeoF6V gZig== X-Gm-Message-State: AMCzsaUZoP2hDBq2tTtN2t/yI4YZU2cDqsBjOC1JPNvzhsQLSsS7Tz3p HIT1IFdeOWUWqERCGfTvvc2i5YKSfP8= X-Google-Smtp-Source: AOwi7QDbbdZ3M4G/LVc88lzMXKCuTYULOLEfJFWvHz8ZU9ZrQlaVsKt5YQslJKMpEVe+2I0DEJ13FA== X-Received: by 10.84.198.131 with SMTP id p3mr9625895pld.245.1508174805016; Mon, 16 Oct 2017 10:26:45 -0700 (PDT) Received: from cloudburst.twiddle.net (97-126-104-76.tukw.qwest.net. [97.126.104.76]) by smtp.gmail.com with ESMTPSA id i187sm5594249pfc.96.2017.10.16.10.26.43 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 16 Oct 2017 10:26:43 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Mon, 16 Oct 2017 10:25:41 -0700 Message-Id: <20171016172609.23422-23-richard.henderson@linaro.org> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171016172609.23422-1-richard.henderson@linaro.org> References: <20171016172609.23422-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c00::22a Subject: [Qemu-devel] [PATCH v6 22/50] tcg: define CF_PARALLEL and use it for TB hashing along with CF_COUNT_MASK 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: cota@braap.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: "Emilio G. Cota" This will enable us to decouple code translation from the value of parallel_cpus at any given time. It will also help us minimize TB flushes when generating code via EXCP_ATOMIC. Note that the declaration of parallel_cpus is brought to exec-all.h to be able to define there the "curr_cflags" inline. Signed-off-by: Emilio G. Cota --- include/exec/exec-all.h | 20 +++++++++++++++++++- include/exec/tb-hash-xx.h | 9 ++++++--- include/exec/tb-hash.h | 4 ++-- include/exec/tb-lookup.h | 6 +++--- tcg/tcg.h | 1 - accel/tcg/cpu-exec.c | 45 +++++++++++++++++++++++---------------------- accel/tcg/tcg-runtime.c | 2 +- accel/tcg/translate-all.c | 13 +++++++++---- exec.c | 2 +- tests/qht-bench.c | 2 +- 10 files changed, 65 insertions(+), 39 deletions(-) -- 2.13.6 diff --git a/include/exec/exec-all.h b/include/exec/exec-all.h index 53f1835c43..352abc7450 100644 --- a/include/exec/exec-all.h +++ b/include/exec/exec-all.h @@ -325,6 +325,9 @@ struct TranslationBlock { #define CF_USE_ICOUNT 0x20000 #define CF_IGNORE_ICOUNT 0x40000 /* Do not generate icount code */ #define CF_INVALID 0x80000 /* TB is stale. Setters must acquire tb_lock */ +#define CF_PARALLEL 0x100000 /* Generate code for a parallel context */ +/* cflags' mask for hashing/comparison */ +#define CF_HASH_MASK (CF_PARALLEL) /* Per-vCPU dynamic tracing state used to generate this TB */ uint32_t trace_vcpu_dstate; @@ -365,11 +368,26 @@ struct TranslationBlock { uintptr_t jmp_list_first; }; +extern bool parallel_cpus; + +/* Hide the atomic_read to make code a little easier on the eyes */ +static inline uint32_t tb_cflags(const TranslationBlock *tb) +{ + return atomic_read(&tb->cflags); +} + +/* current cflags for hashing/comparison */ +static inline uint32_t curr_cflags(void) +{ + return parallel_cpus ? CF_PARALLEL : 0; +} + void tb_free(TranslationBlock *tb); void tb_flush(CPUState *cpu); void tb_phys_invalidate(TranslationBlock *tb, tb_page_addr_t page_addr); TranslationBlock *tb_htable_lookup(CPUState *cpu, target_ulong pc, - target_ulong cs_base, uint32_t flags); + target_ulong cs_base, uint32_t flags, + uint32_t cf_mask); void tb_set_jmp_target(TranslationBlock *tb, int n, uintptr_t addr); /* GETPC is the true target of the return instruction that we'll execute. */ diff --git a/include/exec/tb-hash-xx.h b/include/exec/tb-hash-xx.h index 6cd3022c07..747a9a612c 100644 --- a/include/exec/tb-hash-xx.h +++ b/include/exec/tb-hash-xx.h @@ -48,8 +48,8 @@ * xxhash32, customized for input variables that are not guaranteed to be * contiguous in memory. */ -static inline -uint32_t tb_hash_func6(uint64_t a0, uint64_t b0, uint32_t e, uint32_t f) +static inline uint32_t +tb_hash_func7(uint64_t a0, uint64_t b0, uint32_t e, uint32_t f, uint32_t g) { uint32_t v1 = TB_HASH_XX_SEED + PRIME32_1 + PRIME32_2; uint32_t v2 = TB_HASH_XX_SEED + PRIME32_2; @@ -78,7 +78,7 @@ uint32_t tb_hash_func6(uint64_t a0, uint64_t b0, uint32_t e, uint32_t f) v4 *= PRIME32_1; h32 = rol32(v1, 1) + rol32(v2, 7) + rol32(v3, 12) + rol32(v4, 18); - h32 += 24; + h32 += 28; h32 += e * PRIME32_3; h32 = rol32(h32, 17) * PRIME32_4; @@ -86,6 +86,9 @@ uint32_t tb_hash_func6(uint64_t a0, uint64_t b0, uint32_t e, uint32_t f) h32 += f * PRIME32_3; h32 = rol32(h32, 17) * PRIME32_4; + h32 += g * PRIME32_3; + h32 = rol32(h32, 17) * PRIME32_4; + h32 ^= h32 >> 15; h32 *= PRIME32_2; h32 ^= h32 >> 13; diff --git a/include/exec/tb-hash.h b/include/exec/tb-hash.h index 17b5ee0edf..0526c4f678 100644 --- a/include/exec/tb-hash.h +++ b/include/exec/tb-hash.h @@ -59,9 +59,9 @@ static inline unsigned int tb_jmp_cache_hash_func(target_ulong pc) static inline uint32_t tb_hash_func(tb_page_addr_t phys_pc, target_ulong pc, uint32_t flags, - uint32_t trace_vcpu_dstate) + uint32_t cf_mask, uint32_t trace_vcpu_dstate) { - return tb_hash_func6(phys_pc, pc, flags, trace_vcpu_dstate); + return tb_hash_func7(phys_pc, pc, flags, cf_mask, trace_vcpu_dstate); } #endif diff --git a/include/exec/tb-lookup.h b/include/exec/tb-lookup.h index 436b6d5ecf..296138591a 100644 --- a/include/exec/tb-lookup.h +++ b/include/exec/tb-lookup.h @@ -21,7 +21,7 @@ /* Might cause an exception, so have a longjmp destination ready */ static inline TranslationBlock * tb_lookup__cpu_state(CPUState *cpu, target_ulong *pc, target_ulong *cs_base, - uint32_t *flags) + uint32_t *flags, uint32_t cf_mask) { CPUArchState *env = (CPUArchState *)cpu->env_ptr; TranslationBlock *tb; @@ -35,10 +35,10 @@ tb_lookup__cpu_state(CPUState *cpu, target_ulong *pc, target_ulong *cs_base, tb->cs_base == *cs_base && tb->flags == *flags && tb->trace_vcpu_dstate == *cpu->trace_dstate && - !(atomic_read(&tb->cflags) & CF_INVALID))) { + (tb_cflags(tb) & (CF_HASH_MASK | CF_INVALID)) == cf_mask)) { return tb; } - tb = tb_htable_lookup(cpu, *pc, *cs_base, *flags); + tb = tb_htable_lookup(cpu, *pc, *cs_base, *flags, cf_mask); if (tb == NULL) { return NULL; } diff --git a/tcg/tcg.h b/tcg/tcg.h index d5bf61b1cf..5e1170b299 100644 --- a/tcg/tcg.h +++ b/tcg/tcg.h @@ -732,7 +732,6 @@ struct TCGContext { }; extern TCGContext tcg_ctx; -extern bool parallel_cpus; static inline size_t temp_idx(TCGTemp *ts) { diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c index 363dfa208a..39ec9508d1 100644 --- a/accel/tcg/cpu-exec.c +++ b/accel/tcg/cpu-exec.c @@ -207,7 +207,8 @@ static void cpu_exec_nocache(CPUState *cpu, int max_cycles, tb_lock(); tb = tb_gen_code(cpu, orig_tb->pc, orig_tb->cs_base, orig_tb->flags, max_cycles | CF_NOCACHE - | (ignore_icount ? CF_IGNORE_ICOUNT : 0)); + | (ignore_icount ? CF_IGNORE_ICOUNT : 0) + | curr_cflags()); tb->orig_tb = orig_tb; tb_unlock(); @@ -225,31 +226,27 @@ static void cpu_exec_nocache(CPUState *cpu, int max_cycles, static void cpu_exec_step(CPUState *cpu) { CPUClass *cc = CPU_GET_CLASS(cpu); - CPUArchState *env = (CPUArchState *)cpu->env_ptr; TranslationBlock *tb; target_ulong cs_base, pc; uint32_t flags; + uint32_t cflags = 1 | CF_IGNORE_ICOUNT; - cpu_get_tb_cpu_state(env, &pc, &cs_base, &flags); if (sigsetjmp(cpu->jmp_env, 0) == 0) { - mmap_lock(); - tb_lock(); - tb = tb_gen_code(cpu, pc, cs_base, flags, - 1 | CF_NOCACHE | CF_IGNORE_ICOUNT); - tb->orig_tb = NULL; - tb_unlock(); - mmap_unlock(); + tb = tb_lookup__cpu_state(cpu, &pc, &cs_base, &flags, + cflags & CF_HASH_MASK); + if (tb == NULL) { + mmap_lock(); + tb_lock(); + tb = tb_gen_code(cpu, pc, cs_base, flags, cflags); + tb_unlock(); + mmap_unlock(); + } cc->cpu_exec_enter(cpu); /* execute the generated code */ - trace_exec_tb_nocache(tb, pc); + trace_exec_tb(tb, pc); cpu_tb_exec(cpu, tb); cc->cpu_exec_exit(cpu); - - tb_lock(); - tb_phys_invalidate(tb, -1); - tb_free(tb); - tb_unlock(); } else { /* We may have exited due to another problem here, so we need * to reset any tb_locks we may have taken but didn't release. @@ -281,6 +278,7 @@ struct tb_desc { CPUArchState *env; tb_page_addr_t phys_page1; uint32_t flags; + uint32_t cf_mask; uint32_t trace_vcpu_dstate; }; @@ -294,7 +292,7 @@ static bool tb_cmp(const void *p, const void *d) tb->cs_base == desc->cs_base && tb->flags == desc->flags && tb->trace_vcpu_dstate == desc->trace_vcpu_dstate && - !(atomic_read(&tb->cflags) & CF_INVALID)) { + (tb_cflags(tb) & (CF_HASH_MASK | CF_INVALID)) == desc->cf_mask) { /* check next page if needed */ if (tb->page_addr[1] == -1) { return true; @@ -313,7 +311,8 @@ static bool tb_cmp(const void *p, const void *d) } TranslationBlock *tb_htable_lookup(CPUState *cpu, target_ulong pc, - target_ulong cs_base, uint32_t flags) + target_ulong cs_base, uint32_t flags, + uint32_t cf_mask) { tb_page_addr_t phys_pc; struct tb_desc desc; @@ -322,11 +321,12 @@ TranslationBlock *tb_htable_lookup(CPUState *cpu, target_ulong pc, desc.env = (CPUArchState *)cpu->env_ptr; desc.cs_base = cs_base; desc.flags = flags; + desc.cf_mask = cf_mask; desc.trace_vcpu_dstate = *cpu->trace_dstate; desc.pc = pc; phys_pc = get_page_addr_code(desc.env, pc); desc.phys_page1 = phys_pc & TARGET_PAGE_MASK; - h = tb_hash_func(phys_pc, pc, flags, *cpu->trace_dstate); + h = tb_hash_func(phys_pc, pc, flags, cf_mask, *cpu->trace_dstate); return qht_lookup(&tcg_ctx.tb_ctx.htable, tb_cmp, &desc, h); } @@ -373,8 +373,9 @@ static inline TranslationBlock *tb_find(CPUState *cpu, target_ulong cs_base, pc; uint32_t flags; bool acquired_tb_lock = false; + uint32_t cf_mask = curr_cflags(); - tb = tb_lookup__cpu_state(cpu, &pc, &cs_base, &flags); + tb = tb_lookup__cpu_state(cpu, &pc, &cs_base, &flags, cf_mask); if (tb == NULL) { /* mmap_lock is needed by tb_gen_code, and mmap_lock must be * taken outside tb_lock. As system emulation is currently @@ -387,10 +388,10 @@ static inline TranslationBlock *tb_find(CPUState *cpu, /* There's a chance that our desired tb has been translated while * taking the locks so we check again inside the lock. */ - tb = tb_htable_lookup(cpu, pc, cs_base, flags); + tb = tb_htable_lookup(cpu, pc, cs_base, flags, cf_mask); if (likely(tb == NULL)) { /* if no translated code available, then translate it now */ - tb = tb_gen_code(cpu, pc, cs_base, flags, 0); + tb = tb_gen_code(cpu, pc, cs_base, flags, cf_mask); } mmap_unlock(); diff --git a/accel/tcg/tcg-runtime.c b/accel/tcg/tcg-runtime.c index 54d89100d9..25f0cabfed 100644 --- a/accel/tcg/tcg-runtime.c +++ b/accel/tcg/tcg-runtime.c @@ -151,7 +151,7 @@ void *HELPER(lookup_tb_ptr)(CPUArchState *env) target_ulong cs_base, pc; uint32_t flags; - tb = tb_lookup__cpu_state(cpu, &pc, &cs_base, &flags); + tb = tb_lookup__cpu_state(cpu, &pc, &cs_base, &flags, curr_cflags()); if (tb == NULL) { return tcg_ctx.code_gen_epilogue; } diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c index c5ce99d549..1271944ae8 100644 --- a/accel/tcg/translate-all.c +++ b/accel/tcg/translate-all.c @@ -1101,7 +1101,8 @@ void tb_phys_invalidate(TranslationBlock *tb, tb_page_addr_t page_addr) /* remove the TB from the hash list */ phys_pc = tb->page_addr[0] + (tb->pc & ~TARGET_PAGE_MASK); - h = tb_hash_func(phys_pc, tb->pc, tb->flags, tb->trace_vcpu_dstate); + h = tb_hash_func(phys_pc, tb->pc, tb->flags, tb->cflags & CF_HASH_MASK, + tb->trace_vcpu_dstate); qht_remove(&tcg_ctx.tb_ctx.htable, tb, h); /* remove the TB from the page list */ @@ -1245,7 +1246,8 @@ static void tb_link_page(TranslationBlock *tb, tb_page_addr_t phys_pc, } /* add in the hash table */ - h = tb_hash_func(phys_pc, tb->pc, tb->flags, tb->trace_vcpu_dstate); + h = tb_hash_func(phys_pc, tb->pc, tb->flags, tb->cflags & CF_HASH_MASK, + tb->trace_vcpu_dstate); qht_insert(&tcg_ctx.tb_ctx.htable, tb, h); #ifdef CONFIG_USER_ONLY @@ -1548,7 +1550,8 @@ void tb_invalidate_phys_page_range(tb_page_addr_t start, tb_page_addr_t end, /* we generate a block containing just the instruction modifying the memory. It will ensure that it cannot modify itself */ - tb_gen_code(cpu, current_pc, current_cs_base, current_flags, 1); + tb_gen_code(cpu, current_pc, current_cs_base, current_flags, + 1 | curr_cflags()); cpu_loop_exit_noexc(cpu); } #endif @@ -1666,7 +1669,8 @@ static bool tb_invalidate_phys_page(tb_page_addr_t addr, uintptr_t pc) /* we generate a block containing just the instruction modifying the memory. It will ensure that it cannot modify itself */ - tb_gen_code(cpu, current_pc, current_cs_base, current_flags, 1); + tb_gen_code(cpu, current_pc, current_cs_base, current_flags, + 1 | curr_cflags()); /* tb_lock will be reset after cpu_loop_exit_noexc longjmps * back into the cpu_exec loop. */ return true; @@ -1810,6 +1814,7 @@ void cpu_io_recompile(CPUState *cpu, uintptr_t retaddr) } cflags = n | CF_LAST_IO; + cflags |= curr_cflags(); pc = tb->pc; cs_base = tb->cs_base; flags = tb->flags; diff --git a/exec.c b/exec.c index 30a1a9fb79..5d43d9541f 100644 --- a/exec.c +++ b/exec.c @@ -2435,7 +2435,7 @@ static void check_watchpoint(int offset, int len, MemTxAttrs attrs, int flags) cpu_loop_exit(cpu); } else { cpu_get_tb_cpu_state(env, &pc, &cs_base, &cpu_flags); - tb_gen_code(cpu, pc, cs_base, cpu_flags, 1); + tb_gen_code(cpu, pc, cs_base, cpu_flags, 1 | curr_cflags()); cpu_loop_exit_noexc(cpu); } } diff --git a/tests/qht-bench.c b/tests/qht-bench.c index 11c1cec766..4cabdfd62a 100644 --- a/tests/qht-bench.c +++ b/tests/qht-bench.c @@ -103,7 +103,7 @@ static bool is_equal(const void *obj, const void *userp) static inline uint32_t h(unsigned long v) { - return tb_hash_func6(v, 0, 0, 0); + return tb_hash_func7(v, 0, 0, 0, 0); } /* From patchwork Mon Oct 16 17:25:42 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 115944 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp3944167qgn; Mon, 16 Oct 2017 10:38:13 -0700 (PDT) X-Received: by 10.200.28.74 with SMTP id j10mr16084847qtk.11.1508175493193; Mon, 16 Oct 2017 10:38:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508175493; cv=none; d=google.com; s=arc-20160816; b=tcDOQ2J+s5HNNdnRuWXCINqE5cf0YO11V6Zgl+R/vDnLomTaGWR/r07rOhs7OG0wDG YotSEY5g1LgoDhfXcCPZtl7W+u9CzUIbi/hQU4+id/5A6fCG2Bs2Sh076hn6ULvTsrdh cneQ/og73bMTAaOPmtRm3GHIGVlfAYUV6iqbyQxhNCGlWpIltbmQhaRBS6AaxX+Lpvtn X5elfyTXnH7wKBMf39Dt8lKZ6+qnf0U+VkzVoloXrLZqyOuhNltXOli8Lzg90R+S2uBR 0+/la9MCPfhB3PzmftedXQvfkAh6qRRFpH1V+dfIKDYxYVwyOk+4DwNR7GrHiXPSQoGV I6Zw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=VRiKczW003TPQXKPZ0Vbsvn24QSHkBE9hREgv3VRI1c=; b=EomBoxTTJN/GqJDMYb/l8fCXDt+NzNHy5U3jVjqSK7akm9Mqtgaa1jHzUT5V3XlPIJ 6AZ05DStsJ3XUKcXeHXSSbBzlEwLLgycr7Kv9zIsXMQFtlPQcdG4rGopZppXy1yFs8PT ICCAnkxpN9QnvUeuHNuF5onxvqlNpBo50fOf2tNH8PO+Rfl1UhTH5BjHI4Hs6f7Wu6+3 R19eM2JbCHw8WuBEWMPWb+YEQ/MKU/obP2dXF/E0birghywA8a+3R0U7LrYbFtkqabP1 J5jTdp4fgezjiTRMO1KY0yk4L/mTXSgCbfOY+DpTfV5DF8lo89zBGVTOG5hbw7/OHsV0 Rc6Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=EkmrCE8z; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id y186si3322027qke.278.2017.10.16.10.38.12 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 16 Oct 2017 10:38:13 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=EkmrCE8z; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:34342 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e49L9-0003Wo-2o for patch@linaro.org; Mon, 16 Oct 2017 13:38:11 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52434) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e49A8-0002MU-Gd for qemu-devel@nongnu.org; Mon, 16 Oct 2017 13:26:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e49A7-0003ci-Pb for qemu-devel@nongnu.org; Mon, 16 Oct 2017 13:26:48 -0400 Received: from mail-pf0-x22b.google.com ([2607:f8b0:400e:c00::22b]:54267) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e49A7-0003cF-JK for qemu-devel@nongnu.org; Mon, 16 Oct 2017 13:26:47 -0400 Received: by mail-pf0-x22b.google.com with SMTP id t188so13793979pfd.10 for ; Mon, 16 Oct 2017 10:26:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=VRiKczW003TPQXKPZ0Vbsvn24QSHkBE9hREgv3VRI1c=; b=EkmrCE8zapzN55q4B+lewAXE/3DQK1rGGDZEMLtRUdTQ1tKtByjhQIoGu+G9niC7ja bOACwK4xsnRMW1SpuytSCdaFhOAxynPqpSNeCPxBzhZ1+3NaQNOM81xAgH+WNfjNyVLa +MM8S3cbdDTU6TRcrP1FBwL9cMDvNfcu5TBkA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=VRiKczW003TPQXKPZ0Vbsvn24QSHkBE9hREgv3VRI1c=; b=kuZeqgOwcvfMm0Nn7h6UNacalNuzzHIwhOlAPjTfIflSjP03e8tmQ/KtM8zP/hxLt5 QzeQrfQlZGSFNLf0WZKcWN0FDvqA2IlUZG19iJjz2AlpyMyE9RYiBFwbRYtzke+CR93g prwKU40T5sA2OS2pTsOuL3J0hYvxFISqAhwrvBOMEbakygyte8fu8vjSi1l4CmQKu5Tk ggMWn1QJQqJd2ar6DgM1OVeklWy8kZAOqR5Fpcer7djf7l8eZi55ZIbPh2RSYuEUg+jH lhcHuQf+TS5nTTKbJ0Kfr/B1dRMNWt4J2Pob5sqMfcVzBj5dKvPmqy7MAhR/nDhymyDQ mxBg== X-Gm-Message-State: AMCzsaVXJ0HXpwO+MDGDiPjbcIY9FbLkcajCcJkv/8Pnsz2/tJRQhW2/ V/LZK+tswmVRa2IdVot7HAjFBFOvdj8= X-Google-Smtp-Source: AOwi7QDehbYdPEiqgrX9b8GnTYzQKLcEYxyLQKtDDumxlnrBmbMtedUuHH96kx0QISfQnNsPPwwBBg== X-Received: by 10.98.17.202 with SMTP id 71mr9380843pfr.142.1508174806401; Mon, 16 Oct 2017 10:26:46 -0700 (PDT) Received: from cloudburst.twiddle.net (97-126-104-76.tukw.qwest.net. [97.126.104.76]) by smtp.gmail.com with ESMTPSA id i187sm5594249pfc.96.2017.10.16.10.26.45 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 16 Oct 2017 10:26:45 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Mon, 16 Oct 2017 10:25:42 -0700 Message-Id: <20171016172609.23422-24-richard.henderson@linaro.org> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171016172609.23422-1-richard.henderson@linaro.org> References: <20171016172609.23422-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c00::22b Subject: [Qemu-devel] [PATCH v6 23/50] hack dump tb->flags and tb->cflags 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: cota@braap.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" --- accel/tcg/cpu-exec.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) -- 2.13.6 diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c index 39ec9508d1..99f1d519c5 100644 --- a/accel/tcg/cpu-exec.c +++ b/accel/tcg/cpu-exec.c @@ -146,9 +146,9 @@ static inline tcg_target_ulong cpu_tb_exec(CPUState *cpu, TranslationBlock *itb) uint8_t *tb_ptr = itb->tc.ptr; qemu_log_mask_and_addr(CPU_LOG_EXEC, itb->pc, - "Trace %p [%d: " TARGET_FMT_lx "] %s\n", + "Trace %p [%d: " TARGET_FMT_lx ", %x, %x] %s\n", itb->tc.ptr, cpu->cpu_index, itb->pc, - lookup_symbol(itb->pc)); + itb->flags, itb->cflags, lookup_symbol(itb->pc)); #if defined(DEBUG_DISAS) if (qemu_loglevel_mask(CPU_LOG_TB_CPU) From patchwork Mon Oct 16 17:25:43 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 115964 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp3956196qgn; Mon, 16 Oct 2017 10:52:50 -0700 (PDT) X-Received: by 10.237.58.225 with SMTP id o88mr6492780qte.190.1508176370785; Mon, 16 Oct 2017 10:52:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508176370; cv=none; d=google.com; s=arc-20160816; b=tBpCATuDnD8RJZHQQVNQyXLnZMeywd2z9BATv48FybCmZr5fouD58Yl8c/3otJmNkM WIOvwgkz9NlVGHQEoqPlK72m3W9oHpgo8uH+iNrjQ6p5F0AgHGdRKMJvXxt5zcUbFGj9 XNFFrGbjg640RsU2BBfYG8Bg/lpOYjGXTkWimA34giG+aLfTKEvbUnPQSK2kj0Wb9fQe olLKRyQo141Xjk+nhdKUGDKqo/OVpqwK8G1zDRSArO/X8anY2xPfMpiWacvnNwuy4fQn icy1LTlGk1/JxX7kXAkqWTtgx0/KwqCLVdgpoR6A8y616omgr9OVjPFtr4GkvShCs6vP h61w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=sJo+iGomDG5NL/43UhVM4Ppm/0mTQM65rKN2jIeYUSc=; b=aHpF4709uc/hH4xteC9dAgqPdSdnFoCSNAmXYGmNoXVwciTPJinwLn2grSEyAJkFW3 4TJ11UUw0/mQmXK2KNyNG4Nrzxc7thfpULWDpkFtPjzpCet2DdXQ7fP24kB/xTH7BJ+P LmxyLbNWPbjFLWhDnWJYLFx5HpwHOpTIupcXnxurilraXciFEyaSxlIIrYi7mgGQw4pv E8OPuf2gKYJVN6LqzIxj+GP0SadJ/TQJutkrjKy1UWe5pSgsq3v+27KqXeOuSgYbCbCz Puqc2BXRaCTZDc4UrOplBNtF6hFW2wY/L0vb6wmHUx7UjyJFK294M1BR4kIsEpI+CERh Jl4Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=UoU8LvrK; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id 10si930861qkv.348.2017.10.16.10.52.50 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 16 Oct 2017 10:52:50 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=UoU8LvrK; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:34401 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e49ZH-00076g-Av for patch@linaro.org; Mon, 16 Oct 2017 13:52:47 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52456) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e49AA-0002OE-C6 for qemu-devel@nongnu.org; Mon, 16 Oct 2017 13:26:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e49A9-0003da-3t for qemu-devel@nongnu.org; Mon, 16 Oct 2017 13:26:50 -0400 Received: from mail-pf0-x22c.google.com ([2607:f8b0:400e:c00::22c]:54267) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e49A8-0003d7-Sl for qemu-devel@nongnu.org; Mon, 16 Oct 2017 13:26:49 -0400 Received: by mail-pf0-x22c.google.com with SMTP id t188so13794023pfd.10 for ; Mon, 16 Oct 2017 10:26:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=sJo+iGomDG5NL/43UhVM4Ppm/0mTQM65rKN2jIeYUSc=; b=UoU8LvrKNygT5NSnI4AJ4vYq4V4InDnH1r/CN7f8kGx9/ztMjT/77CNH2WLp6nIfqS yNC9Ne9zzFzGVAPGzdsTXGBg84ytr3TDmIrW+bGMpKXcr8h6fhDeaKF/0uVxcFuvTBYL xUpSsieutK5LD/QWHKrAspr3v5ujrI19lwuPc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=sJo+iGomDG5NL/43UhVM4Ppm/0mTQM65rKN2jIeYUSc=; b=DFOQj8zwMRJFHJpXcX3m9GEBSzP9o9LOmvQ77byTVWbz7BDsL7JmLUbudnkvAodUba +BMeyrmOUuV5oIQkpHD7N1FC0Ll3WH5YpqTmTd6z/ftWwlA+Z8T0x5vtBhV/hkBIlenP iY3NkCi6eQBy0jaz/ZM7uZIWioMEl/5DZL2+3LQ0kKlDVMw5uYHr/zkuuoqSL4rlunnz /DE8tiZJJSJ9le+s0E4spo4V9jSExAWwmvhzG6z4Np5AMBqyI+0tYnttRwZ7B5vS0ao5 mSnET8hXm7IAMZt1GQ+C/GTr9cFDp1LP61OghNMdAA0s4rKji4cpmBsrKXDzjffcElyb fCqw== X-Gm-Message-State: AMCzsaUPXaIYRjLF1ftTRnkCbjd2SFkd8ge/saTRd+zUHRn2uh2DnhFI rA+fdAui6k6TmfnAYzRuJGo9Ke+4uh4= X-Google-Smtp-Source: AOwi7QCiFttcS7MqufjM2glxx4frxF14q0OYQJktiQYBYKmJVHapaVlAvh96HfH5zxSm30+U4u8qdg== X-Received: by 10.159.211.7 with SMTP id bc7mr9700708plb.425.1508174807699; Mon, 16 Oct 2017 10:26:47 -0700 (PDT) Received: from cloudburst.twiddle.net (97-126-104-76.tukw.qwest.net. [97.126.104.76]) by smtp.gmail.com with ESMTPSA id i187sm5594249pfc.96.2017.10.16.10.26.46 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 16 Oct 2017 10:26:46 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Mon, 16 Oct 2017 10:25:43 -0700 Message-Id: <20171016172609.23422-25-richard.henderson@linaro.org> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171016172609.23422-1-richard.henderson@linaro.org> References: <20171016172609.23422-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c00::22c Subject: [Qemu-devel] [PATCH v6 24/50] tcg: Add CPUState step_next_tb 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: cota@braap.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" We were generating code during tb_invalidate_phys_page_range and check_watchpoint, and (seemingly) discarding the TB, assuming that it would magically be picked up during the next iteration through the cpu_exec loop. Instead, set a flag in CPUState so that we set cflags to properly request a TB with a single guest insn so that there is no more magic. Signed-off-by: Richard Henderson --- include/qom/cpu.h | 1 + accel/tcg/cpu-exec.c | 19 +++++++++++++++---- accel/tcg/translate-all.c | 18 ++++-------------- exec.c | 6 +----- 4 files changed, 21 insertions(+), 23 deletions(-) -- 2.13.6 diff --git a/include/qom/cpu.h b/include/qom/cpu.h index df0ba86202..1fb165a43c 100644 --- a/include/qom/cpu.h +++ b/include/qom/cpu.h @@ -344,6 +344,7 @@ struct CPUState { bool unplug; bool crash_occurred; bool exit_request; + bool step_next_tb; /* updates protected by BQL */ uint32_t interrupt_request; int singlestep_enabled; diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c index 99f1d519c5..df410a8d6e 100644 --- a/accel/tcg/cpu-exec.c +++ b/accel/tcg/cpu-exec.c @@ -367,13 +367,12 @@ static inline void tb_add_jump(TranslationBlock *tb, int n, static inline TranslationBlock *tb_find(CPUState *cpu, TranslationBlock *last_tb, - int tb_exit) + int tb_exit, uint32_t cf_mask) { TranslationBlock *tb; target_ulong cs_base, pc; uint32_t flags; bool acquired_tb_lock = false; - uint32_t cf_mask = curr_cflags(); tb = tb_lookup__cpu_state(cpu, &pc, &cs_base, &flags, cf_mask); if (tb == NULL) { @@ -501,7 +500,7 @@ static inline bool cpu_handle_exception(CPUState *cpu, int *ret) } else if (replay_has_exception() && cpu->icount_decr.u16.low + cpu->icount_extra == 0) { /* try to cause an exception pending in the log */ - cpu_exec_nocache(cpu, 1, tb_find(cpu, NULL, 0), true); + cpu_exec_nocache(cpu, 1, tb_find(cpu, NULL, 0, curr_cflags()), true); *ret = -1; return true; #endif @@ -697,7 +696,19 @@ int cpu_exec(CPUState *cpu) int tb_exit = 0; while (!cpu_handle_interrupt(cpu, &last_tb)) { - TranslationBlock *tb = tb_find(cpu, last_tb, tb_exit); + uint32_t cf_mask = curr_cflags(); + TranslationBlock *tb; + + /* For precise smc, we generate a block containing just the + instruction modifying the memory, ensuring that it cannot + modify itself. We also need to single-step past a + stop-after-access watchpoint. */ + if (cpu->step_next_tb) { + cf_mask |= 1; + cpu->step_next_tb = false; + } + + tb = tb_find(cpu, last_tb, tb_exit, cf_mask); cpu_loop_exec_tb(cpu, tb, &last_tb, &tb_exit); /* Try to align the host and virtual clocks if the guest is in advance */ diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c index 1271944ae8..a7415c8661 100644 --- a/accel/tcg/translate-all.c +++ b/accel/tcg/translate-all.c @@ -1463,14 +1463,12 @@ void tb_invalidate_phys_page_range(tb_page_addr_t start, tb_page_addr_t end, int is_cpu_write_access) { TranslationBlock *tb, *tb_next; -#if defined(TARGET_HAS_PRECISE_SMC) - CPUState *cpu = current_cpu; - CPUArchState *env = NULL; -#endif tb_page_addr_t tb_start, tb_end; PageDesc *p; int n; #ifdef TARGET_HAS_PRECISE_SMC + CPUState *cpu = current_cpu; + CPUArchState *env = NULL; int current_tb_not_found = is_cpu_write_access; TranslationBlock *current_tb = NULL; int current_tb_modified = 0; @@ -1547,11 +1545,7 @@ void tb_invalidate_phys_page_range(tb_page_addr_t start, tb_page_addr_t end, #endif #ifdef TARGET_HAS_PRECISE_SMC if (current_tb_modified) { - /* we generate a block containing just the instruction - modifying the memory. It will ensure that it cannot modify - itself */ - tb_gen_code(cpu, current_pc, current_cs_base, current_flags, - 1 | curr_cflags()); + cpu->step_next_tb = true; cpu_loop_exit_noexc(cpu); } #endif @@ -1666,11 +1660,7 @@ static bool tb_invalidate_phys_page(tb_page_addr_t addr, uintptr_t pc) p->first_tb = NULL; #ifdef TARGET_HAS_PRECISE_SMC if (current_tb_modified) { - /* we generate a block containing just the instruction - modifying the memory. It will ensure that it cannot modify - itself */ - tb_gen_code(cpu, current_pc, current_cs_base, current_flags, - 1 | curr_cflags()); + cpu->step_next_tb = true; /* tb_lock will be reset after cpu_loop_exit_noexc longjmps * back into the cpu_exec loop. */ return true; diff --git a/exec.c b/exec.c index 5d43d9541f..a9737ba5e9 100644 --- a/exec.c +++ b/exec.c @@ -2390,11 +2390,8 @@ static void check_watchpoint(int offset, int len, MemTxAttrs attrs, int flags) { CPUState *cpu = current_cpu; CPUClass *cc = CPU_GET_CLASS(cpu); - CPUArchState *env = cpu->env_ptr; - target_ulong pc, cs_base; target_ulong vaddr; CPUWatchpoint *wp; - uint32_t cpu_flags; assert(tcg_enabled()); if (cpu->watchpoint_hit) { @@ -2434,8 +2431,7 @@ static void check_watchpoint(int offset, int len, MemTxAttrs attrs, int flags) cpu->exception_index = EXCP_DEBUG; cpu_loop_exit(cpu); } else { - cpu_get_tb_cpu_state(env, &pc, &cs_base, &cpu_flags); - tb_gen_code(cpu, pc, cs_base, cpu_flags, 1 | curr_cflags()); + cpu->step_next_tb = true; cpu_loop_exit_noexc(cpu); } } From patchwork Mon Oct 16 17:25:44 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 115952 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp3949984qgn; Mon, 16 Oct 2017 10:45:04 -0700 (PDT) X-Received: by 10.200.36.86 with SMTP id d22mr3632602qtd.140.1508175904570; Mon, 16 Oct 2017 10:45:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508175904; cv=none; d=google.com; s=arc-20160816; b=c/tuBqwWxYS7z8Hr+48WuNcld7oTbgHpYc9erUHQXKijCmA9+G+kqelxiw9u1/INUY CwnbfOPtfDD6K+8lbC2IBnAHEVZjM6kBdwi0mafLBXZWF/VLfxJCe8Q5B8U9jLOWJzBG XJYUdKTBtx9m6kIFoyrugy/P+CFLtGUfZ/SL29gYBSx3U+KbNwZ+DrY9X0ru1lqBqT4h uEPW56uGrwTaNB89XnQE+EDdE14a1bfitG17pDwPgiMa3zQguUaYQ4MjylkgYPFBVpes CAEynefcVUgaVo9TSR0XKHzYLPQhOjgEsGdsdlzP6XFegywUav+gOX9EKQ4P6KydNrA6 AvDA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=cM3365VCpQ9z81Wh/bl09YMwsCGOpw96BCbOfolWxcA=; b=bRa/xuptR1+L4ZprQuSrCi+FgtV6Vq99VBkvezu1K+yc/fiLew1naPxIb3X/REk2FZ pPdUSlDBXa2uG6BaP4s4hjbYjkMjF1ofTTHudrfNBKrVnBEORGr4N3LBKIVIDpEPSoRe XIHgPMqTX6ZCkvMZSXyVELofBYuvEoL2sioXVbGwrjOS4osWHjU1SyqMuNPnlds/sjY+ v/vQYogFMSxSsOXlM+E4/eKoloB8j3gD9mHRVZiXN4HVHMN2mb79Ta/ivCXVIPEQj9AN uouMPkw2x6BuQFhwL2Vquyg4T1Vlxfaeety75bGLpeU/zSV8NGE7Xhmr4jMpaqWFexmP Z09Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=H2cKlubn; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id v39si2752327qta.190.2017.10.16.10.45.04 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 16 Oct 2017 10:45:04 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=H2cKlubn; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:34366 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e49Rm-0000QD-EZ for patch@linaro.org; Mon, 16 Oct 2017 13:45:02 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52466) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e49AB-0002P6-A5 for qemu-devel@nongnu.org; Mon, 16 Oct 2017 13:26:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e49AA-0003eR-ED for qemu-devel@nongnu.org; Mon, 16 Oct 2017 13:26:51 -0400 Received: from mail-pf0-x22f.google.com ([2607:f8b0:400e:c00::22f]:45356) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e49AA-0003e4-8O for qemu-devel@nongnu.org; Mon, 16 Oct 2017 13:26:50 -0400 Received: by mail-pf0-x22f.google.com with SMTP id d28so16307464pfe.2 for ; Mon, 16 Oct 2017 10:26:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=cM3365VCpQ9z81Wh/bl09YMwsCGOpw96BCbOfolWxcA=; b=H2cKlubnqmQUV0X+nLEojYRFkoRzHOMQty8ZuFzaxzFlS0R0QFzOhZfNbx2y5cAOgY I73xp/ekhmgfG7TGR0xhIwTA2Xf/nZk2ZR1EULbDG2ePTxWGr/jOjQ4T4+BG2tklVe2f Kf+MtM8wYgMau+LEvKjxSCgC1lqYS19/spedw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=cM3365VCpQ9z81Wh/bl09YMwsCGOpw96BCbOfolWxcA=; b=rMn+Jmzuc2xf2q5yw2cgDt+AsXbxBZP1MO927f/HuyO9mpXho+Hf99mYgfuZuWFFvU qhhkgQRMmuRdUKGKKgiy1FMUtrCor1Ny+1+HOUbYT7/10IIe3KfpT1PSAPxdY2WSTsaq Wt0mBB1+SxzPLWUizFGhp/9okfnIGdkNJPRBgZh1NFsa6qH+22PlF1JFaN51Ei4Iqog/ mE+8CqIysiTQSrbqV3AXNMXmOFbW7jVBnnBYEc9/pLKP50Z0kCkstFzATx9/XqSeaK3v oNW6+3o+iPWvDFRsqCiVa7MwdMXK6h+wiVDbvgHOFHkn/KDVzJyGZucDSFf1tG71GTD4 I6Tw== X-Gm-Message-State: AMCzsaVvUgi/FXU3zZJcwj2Ej0daA8BKXDgB6pJatkTgbAPtPW+RKELf G9IIvPmsh3wernfnuC2UFnAoiiWcpzI= X-Google-Smtp-Source: AOwi7QAKqUGZqPs1bsAFScZlRuwTPIdhYWHbW5Ux1X9Wumh3zvF7RhI4SUmuMjIJemxTshyDenK21g== X-Received: by 10.84.135.101 with SMTP id 92mr9657914pli.180.1508174809172; Mon, 16 Oct 2017 10:26:49 -0700 (PDT) Received: from cloudburst.twiddle.net (97-126-104-76.tukw.qwest.net. [97.126.104.76]) by smtp.gmail.com with ESMTPSA id i187sm5594249pfc.96.2017.10.16.10.26.47 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 16 Oct 2017 10:26:48 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Mon, 16 Oct 2017 10:25:44 -0700 Message-Id: <20171016172609.23422-26-richard.henderson@linaro.org> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171016172609.23422-1-richard.henderson@linaro.org> References: <20171016172609.23422-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c00::22f Subject: [Qemu-devel] [PATCH v6 25/50] tcg: Include CF_COUNT_MASK in CF_HASH_MASK 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: cota@braap.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Richard Henderson --- include/exec/exec-all.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.13.6 diff --git a/include/exec/exec-all.h b/include/exec/exec-all.h index 352abc7450..0fdb72bb22 100644 --- a/include/exec/exec-all.h +++ b/include/exec/exec-all.h @@ -327,7 +327,7 @@ struct TranslationBlock { #define CF_INVALID 0x80000 /* TB is stale. Setters must acquire tb_lock */ #define CF_PARALLEL 0x100000 /* Generate code for a parallel context */ /* cflags' mask for hashing/comparison */ -#define CF_HASH_MASK (CF_PARALLEL) +#define CF_HASH_MASK (CF_COUNT_MASK | CF_PARALLEL) /* Per-vCPU dynamic tracing state used to generate this TB */ uint32_t trace_vcpu_dstate; From patchwork Mon Oct 16 17:25:45 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 115953 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp3950038qgn; Mon, 16 Oct 2017 10:45:07 -0700 (PDT) X-Received: by 10.55.98.205 with SMTP id w196mr15595623qkb.322.1508175907571; Mon, 16 Oct 2017 10:45:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508175907; cv=none; d=google.com; s=arc-20160816; b=A3vytU2JuPpVHMJRNDjlx8y0BKoXiUAm1F6Y6Czf6RumjffA8jTzMo89qnAhFGZ9VP JoVxpK480lwCpaQw/ybcyusCQIwEpiKbVtYxVMk7DoB2wcMMxK5U8P6yQvx0UpNfEGDr vGTS4v3ZjC7jPr1VCcFL74/YkqF6ToB+rGqQvtcI9B2ffpL28HpALvLdMqLVTbc1vP65 aZHTGiY4Ovd6RbFS4yRmEo9+1gSAUIWv0AHUID34Ftjh7AiUCEUnLwG3zlfCp6fNyqOQ K8sOmlgPQmekLR4eqGUDejrU+3jV9lEAn2tziCYZR4WdrZpTeG9LDgIIWAS9i6ebKZkZ sztA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=AGUyEKSJAcrEkwgnab2mR61mPgzHbHM+d2dXxvqAYno=; b=IK39655mxiq8BJw0KCLlfao+Wmf7Vvq6DdIzMMh95sCuhc0u2pLTsQSUIZWMVRe+2D Q9qFkd7AqsKUqg1xEY6EfZYowzSL+uw26WgJyGCQ0eeVVFqWYeFaBIxRyXu1N2ymqhIZ DvEs/AtIR6bWF/GGCNeKuETHT88it5OcALr3ccgR+9uG7uhZp2gs6DpwoLl9rJzOAKY7 Vmii5pElXQsTnKLyXi8nR3BE519qrHjMU8Ke42grK/bGQY3pvl4nRqPIfQUGyU6uzzpQ Wzt5a+LmhqpYCCe+NJykIys+bQWPDI95t/hqih8ezA23Uf8/t5mR4wha6Pa4z0ewRf7f bz0w== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=DARwxK9s; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id j6si690242qtj.255.2017.10.16.10.45.06 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 16 Oct 2017 10:45:07 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=DARwxK9s; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:34368 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e49Rp-0000Qf-2H for patch@linaro.org; Mon, 16 Oct 2017 13:45:05 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52507) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e49AH-0002Wo-Cu for qemu-devel@nongnu.org; Mon, 16 Oct 2017 13:27:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e49AC-0003g1-U9 for qemu-devel@nongnu.org; Mon, 16 Oct 2017 13:26:57 -0400 Received: from mail-pf0-x235.google.com ([2607:f8b0:400e:c00::235]:46253) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e49AC-0003fT-Gq for qemu-devel@nongnu.org; Mon, 16 Oct 2017 13:26:52 -0400 Received: by mail-pf0-x235.google.com with SMTP id p87so16295701pfj.3 for ; Mon, 16 Oct 2017 10:26:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=AGUyEKSJAcrEkwgnab2mR61mPgzHbHM+d2dXxvqAYno=; b=DARwxK9szzv5IVq1g4pBlKMSma6DnMjf0EV95ggoRk65eCQIChfF6IsyD0ajnlM/ls Z7qrCUcG6xeJ0XPu6sAmeR+jnrvX5ao3f7y/YqkeeIVMcwv/Cm2nzxr3NPzGO1V3mHyM M6QhSxh8RpuG5d2puA3dBAQIz/xrQAHKmBxWg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=AGUyEKSJAcrEkwgnab2mR61mPgzHbHM+d2dXxvqAYno=; b=QFDfVHAgFqCVfW4pQBHRlPAKrVyy+7YyMhK9lL9CXbmIjJgrcw+zvlulR5/u9I7NWv G31C3xdzBnYZZtDSZ9P9f2OX5XvuON/8xE/KtiQvOV/dREKSW+VLY7jl8gnt3cAwYsj5 z6afsJFqA+U3o8z9cFg0TAZujmZUagVMvSpvP8laGh+aNQPaTqpX0tfX9pHo02qGx4rb bKJHA0Iw/ICpM5pFF33GlOQRO3wABKg29SLSn1xIMkBMVykFE4SB2ThB9vQN8O0/wTt+ +q93D1wSzKTHr4gqNqkgEYzfSDSPcOn3QIk6l7k9ddS1a2QH2KkakRGOHF0V+sMbUhpx 7WCg== X-Gm-Message-State: AMCzsaW+bgiw1CupSNQwRti+Fl37genviSpwKQgmNkXn7xZA4LJmIRDe 0nCBiHHCDTONZFOk73eA08M1C/brvvk= X-Google-Smtp-Source: AOwi7QAzqfd/tu9susrtB8fosCZcDE+wL9UTlhaMLz69Nzyovp0uH2AlrcqRCTVBpmKyg/l0YDanqQ== X-Received: by 10.98.64.207 with SMTP id f76mr9275314pfd.279.1508174810743; Mon, 16 Oct 2017 10:26:50 -0700 (PDT) Received: from cloudburst.twiddle.net (97-126-104-76.tukw.qwest.net. [97.126.104.76]) by smtp.gmail.com with ESMTPSA id i187sm5594249pfc.96.2017.10.16.10.26.49 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 16 Oct 2017 10:26:49 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Mon, 16 Oct 2017 10:25:45 -0700 Message-Id: <20171016172609.23422-27-richard.henderson@linaro.org> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171016172609.23422-1-richard.henderson@linaro.org> References: <20171016172609.23422-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c00::235 Subject: [Qemu-devel] [PATCH v6 26/50] tcg: convert tb->cflags reads to tb_cflags(tb) 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: cota@braap.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: "Emilio G. Cota" Convert all existing readers of tb->cflags to tb_cflags, so that we use atomic_read and therefore avoid undefined behaviour in C11. Note that the remaining setters/getters of the field are protected by tb_lock, and therefore do not need conversion. Luckily all readers access the field via 'tb->cflags' (so no foo.cflags, bar->cflags in the code base), which makes the conversion easily scriptable: FILES=$(git grep 'tb->cflags' target include/exec/gen-icount.h \ accel/tcg/translator.c | cut -f1 -d':' | sort | uniq) perl -pi -e 's/([^.>])tb->cflags/$1tb_cflags(tb)/g' $FILES perl -pi -e 's/([a-z->.]*)(->|\.)tb->cflags/tb_cflags($1$2tb)/g' $FILES Then manually fixed the few errors that checkpatch reported. Compile-tested for all targets. Suggested-by: Richard Henderson Reviewed-by: Richard Henderson Signed-off-by: Emilio G. Cota --- include/exec/gen-icount.h | 8 ++++---- accel/tcg/translator.c | 4 ++-- target/alpha/translate.c | 4 ++-- target/arm/translate-a64.c | 7 ++++--- target/arm/translate.c | 6 +++--- target/cris/translate.c | 6 +++--- target/hppa/translate.c | 2 +- target/i386/translate.c | 48 +++++++++++++++++++++---------------------- target/lm32/translate.c | 14 ++++++------- target/m68k/translate.c | 6 +++--- target/microblaze/translate.c | 6 +++--- target/mips/translate.c | 26 +++++++++++------------ target/moxie/translate.c | 2 +- target/nios2/translate.c | 6 +++--- target/openrisc/translate.c | 6 +++--- target/ppc/translate.c | 6 +++--- target/ppc/translate_init.c | 32 ++++++++++++++--------------- target/s390x/translate.c | 8 ++++---- target/sh4/translate.c | 6 +++--- target/sparc/translate.c | 6 +++--- target/tilegx/translate.c | 2 +- target/tricore/translate.c | 2 +- target/unicore32/translate.c | 6 +++--- target/xtensa/translate.c | 28 ++++++++++++------------- 24 files changed, 124 insertions(+), 123 deletions(-) -- 2.13.6 diff --git a/include/exec/gen-icount.h b/include/exec/gen-icount.h index 9b3cb14dfa..48b566c1c9 100644 --- a/include/exec/gen-icount.h +++ b/include/exec/gen-icount.h @@ -13,7 +13,7 @@ static inline void gen_tb_start(TranslationBlock *tb) TCGv_i32 count, imm; exitreq_label = gen_new_label(); - if (tb->cflags & CF_USE_ICOUNT) { + if (tb_cflags(tb) & CF_USE_ICOUNT) { count = tcg_temp_local_new_i32(); } else { count = tcg_temp_new_i32(); @@ -22,7 +22,7 @@ static inline void gen_tb_start(TranslationBlock *tb) tcg_gen_ld_i32(count, tcg_ctx.tcg_env, -ENV_OFFSET + offsetof(CPUState, icount_decr.u32)); - if (tb->cflags & CF_USE_ICOUNT) { + if (tb_cflags(tb) & CF_USE_ICOUNT) { imm = tcg_temp_new_i32(); /* We emit a movi with a dummy immediate argument. Keep the insn index * of the movi so that we later (when we know the actual insn count) @@ -36,7 +36,7 @@ static inline void gen_tb_start(TranslationBlock *tb) tcg_gen_brcondi_i32(TCG_COND_LT, count, 0, exitreq_label); - if (tb->cflags & CF_USE_ICOUNT) { + if (tb_cflags(tb) & CF_USE_ICOUNT) { tcg_gen_st16_i32(count, tcg_ctx.tcg_env, -ENV_OFFSET + offsetof(CPUState, icount_decr.u16.low)); } @@ -46,7 +46,7 @@ static inline void gen_tb_start(TranslationBlock *tb) static inline void gen_tb_end(TranslationBlock *tb, int num_insns) { - if (tb->cflags & CF_USE_ICOUNT) { + if (tb_cflags(tb) & CF_USE_ICOUNT) { /* Update the num_insn immediate parameter now that we know * the actual insn count. */ tcg_set_insn_param(icount_start_insn_idx, 1, num_insns); diff --git a/accel/tcg/translator.c b/accel/tcg/translator.c index afa3af478a..23c6602cd9 100644 --- a/accel/tcg/translator.c +++ b/accel/tcg/translator.c @@ -45,7 +45,7 @@ void translator_loop(const TranslatorOps *ops, DisasContextBase *db, db->singlestep_enabled = cpu->singlestep_enabled; /* Instruction counting */ - max_insns = db->tb->cflags & CF_COUNT_MASK; + max_insns = tb_cflags(db->tb) & CF_COUNT_MASK; if (max_insns == 0) { max_insns = CF_COUNT_MASK; } @@ -95,7 +95,7 @@ void translator_loop(const TranslatorOps *ops, DisasContextBase *db, update db->pc_next and db->is_jmp to indicate what should be done next -- either exiting this loop or locate the start of the next instruction. */ - if (db->num_insns == max_insns && (db->tb->cflags & CF_LAST_IO)) { + if (db->num_insns == max_insns && (tb_cflags(db->tb) & CF_LAST_IO)) { /* Accept I/O on the last instruction. */ gen_io_start(); ops->translate_insn(db, cpu); diff --git a/target/alpha/translate.c b/target/alpha/translate.c index 3c8d1dc333..53b8c036e2 100644 --- a/target/alpha/translate.c +++ b/target/alpha/translate.c @@ -455,7 +455,7 @@ static bool in_superpage(DisasContext *ctx, int64_t addr) static bool use_exit_tb(DisasContext *ctx) { - return ((ctx->base.tb->cflags & CF_LAST_IO) + return ((tb_cflags(ctx->base.tb) & CF_LAST_IO) || ctx->base.singlestep_enabled || singlestep); } @@ -2399,7 +2399,7 @@ static DisasJumpType translate_one(DisasContext *ctx, uint32_t insn) case 0xC000: /* RPCC */ va = dest_gpr(ctx, ra); - if (ctx->base.tb->cflags & CF_USE_ICOUNT) { + if (tb_cflags(ctx->base.tb) & CF_USE_ICOUNT) { gen_io_start(); gen_helper_load_pcc(va, cpu_env); gen_io_end(); diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c index a39b9d3633..e9bee8c196 100644 --- a/target/arm/translate-a64.c +++ b/target/arm/translate-a64.c @@ -348,7 +348,8 @@ static inline bool use_goto_tb(DisasContext *s, int n, uint64_t dest) /* No direct tb linking with singlestep (either QEMU's or the ARM * debug architecture kind) or deterministic io */ - if (s->base.singlestep_enabled || s->ss_active || (s->base.tb->cflags & CF_LAST_IO)) { + if (s->base.singlestep_enabled || s->ss_active || + (tb_cflags(s->base.tb) & CF_LAST_IO)) { return false; } @@ -1561,7 +1562,7 @@ static void handle_sys(DisasContext *s, uint32_t insn, bool isread, break; } - if ((s->base.tb->cflags & CF_USE_ICOUNT) && (ri->type & ARM_CP_IO)) { + if ((tb_cflags(s->base.tb) & CF_USE_ICOUNT) && (ri->type & ARM_CP_IO)) { gen_io_start(); } @@ -1592,7 +1593,7 @@ static void handle_sys(DisasContext *s, uint32_t insn, bool isread, } } - if ((s->base.tb->cflags & CF_USE_ICOUNT) && (ri->type & ARM_CP_IO)) { + if ((tb_cflags(s->base.tb) & CF_USE_ICOUNT) && (ri->type & ARM_CP_IO)) { /* I/O operations must end the TB here (whether read or write) */ gen_io_end(); s->base.is_jmp = DISAS_UPDATE; diff --git a/target/arm/translate.c b/target/arm/translate.c index 4da1a4cbc6..dfa547b1db 100644 --- a/target/arm/translate.c +++ b/target/arm/translate.c @@ -7704,7 +7704,7 @@ static int disas_coproc_insn(DisasContext *s, uint32_t insn) break; } - if ((s->base.tb->cflags & CF_USE_ICOUNT) && (ri->type & ARM_CP_IO)) { + if ((tb_cflags(s->base.tb) & CF_USE_ICOUNT) && (ri->type & ARM_CP_IO)) { gen_io_start(); } @@ -7795,7 +7795,7 @@ static int disas_coproc_insn(DisasContext *s, uint32_t insn) } } - if ((s->base.tb->cflags & CF_USE_ICOUNT) && (ri->type & ARM_CP_IO)) { + if ((tb_cflags(s->base.tb) & CF_USE_ICOUNT) && (ri->type & ARM_CP_IO)) { /* I/O operations must end the TB here (whether read or write) */ gen_io_end(); gen_lookup_tb(s); @@ -12253,7 +12253,7 @@ static void arm_tr_tb_stop(DisasContextBase *dcbase, CPUState *cpu) { DisasContext *dc = container_of(dcbase, DisasContext, base); - if (dc->base.tb->cflags & CF_LAST_IO && dc->condjmp) { + if (tb_cflags(dc->base.tb) & CF_LAST_IO && dc->condjmp) { /* FIXME: This can theoretically happen with self-modifying code. */ cpu_abort(cpu, "IO on conditional branch instruction"); } diff --git a/target/cris/translate.c b/target/cris/translate.c index 38a999e6f1..07ec2b1831 100644 --- a/target/cris/translate.c +++ b/target/cris/translate.c @@ -3141,7 +3141,7 @@ void gen_intermediate_code(CPUState *cs, struct TranslationBlock *tb) next_page_start = (pc_start & TARGET_PAGE_MASK) + TARGET_PAGE_SIZE; num_insns = 0; - max_insns = tb->cflags & CF_COUNT_MASK; + max_insns = tb_cflags(tb) & CF_COUNT_MASK; if (max_insns == 0) { max_insns = CF_COUNT_MASK; } @@ -3171,7 +3171,7 @@ void gen_intermediate_code(CPUState *cs, struct TranslationBlock *tb) /* Pretty disas. */ LOG_DIS("%8.8x:\t", dc->pc); - if (num_insns == max_insns && (tb->cflags & CF_LAST_IO)) { + if (num_insns == max_insns && (tb_cflags(tb) & CF_LAST_IO)) { gen_io_start(); } dc->clear_x = 1; @@ -3244,7 +3244,7 @@ void gen_intermediate_code(CPUState *cs, struct TranslationBlock *tb) npc = dc->pc; - if (tb->cflags & CF_LAST_IO) + if (tb_cflags(tb) & CF_LAST_IO) gen_io_end(); /* Force an update if the per-tb cpu state has changed. */ if (dc->is_jmp == DISAS_NEXT diff --git a/target/hppa/translate.c b/target/hppa/translate.c index 334ee74e4c..460b4d3154 100644 --- a/target/hppa/translate.c +++ b/target/hppa/translate.c @@ -469,7 +469,7 @@ static DisasJumpType gen_illegal(DisasContext *ctx) static bool use_goto_tb(DisasContext *ctx, target_ulong dest) { /* Suppress goto_tb in the case of single-steping and IO. */ - if ((ctx->base.tb->cflags & CF_LAST_IO) || ctx->base.singlestep_enabled) { + if ((tb_cflags(ctx->base.tb) & CF_LAST_IO) || ctx->base.singlestep_enabled) { return false; } return true; diff --git a/target/i386/translate.c b/target/i386/translate.c index 51860c8db2..f60582082e 100644 --- a/target/i386/translate.c +++ b/target/i386/translate.c @@ -1117,7 +1117,7 @@ static void gen_bpt_io(DisasContext *s, TCGv_i32 t_port, int ot) static inline void gen_ins(DisasContext *s, TCGMemOp ot) { - if (s->base.tb->cflags & CF_USE_ICOUNT) { + if (tb_cflags(s->base.tb) & CF_USE_ICOUNT) { gen_io_start(); } gen_string_movl_A0_EDI(s); @@ -1132,14 +1132,14 @@ static inline void gen_ins(DisasContext *s, TCGMemOp ot) gen_op_movl_T0_Dshift(ot); gen_op_add_reg_T0(s->aflag, R_EDI); gen_bpt_io(s, cpu_tmp2_i32, ot); - if (s->base.tb->cflags & CF_USE_ICOUNT) { + if (tb_cflags(s->base.tb) & CF_USE_ICOUNT) { gen_io_end(); } } static inline void gen_outs(DisasContext *s, TCGMemOp ot) { - if (s->base.tb->cflags & CF_USE_ICOUNT) { + if (tb_cflags(s->base.tb) & CF_USE_ICOUNT) { gen_io_start(); } gen_string_movl_A0_ESI(s); @@ -1152,7 +1152,7 @@ static inline void gen_outs(DisasContext *s, TCGMemOp ot) gen_op_movl_T0_Dshift(ot); gen_op_add_reg_T0(s->aflag, R_ESI); gen_bpt_io(s, cpu_tmp2_i32, ot); - if (s->base.tb->cflags & CF_USE_ICOUNT) { + if (tb_cflags(s->base.tb) & CF_USE_ICOUNT) { gen_io_end(); } } @@ -6301,7 +6301,7 @@ static target_ulong disas_insn(DisasContext *s, CPUState *cpu) gen_repz_ins(s, ot, pc_start - s->cs_base, s->pc - s->cs_base); } else { gen_ins(s, ot); - if (s->base.tb->cflags & CF_USE_ICOUNT) { + if (tb_cflags(s->base.tb) & CF_USE_ICOUNT) { gen_jmp(s, s->pc - s->cs_base); } } @@ -6316,7 +6316,7 @@ static target_ulong disas_insn(DisasContext *s, CPUState *cpu) gen_repz_outs(s, ot, pc_start - s->cs_base, s->pc - s->cs_base); } else { gen_outs(s, ot); - if (s->base.tb->cflags & CF_USE_ICOUNT) { + if (tb_cflags(s->base.tb) & CF_USE_ICOUNT) { gen_jmp(s, s->pc - s->cs_base); } } @@ -6332,14 +6332,14 @@ static target_ulong disas_insn(DisasContext *s, CPUState *cpu) tcg_gen_movi_tl(cpu_T0, val); gen_check_io(s, ot, pc_start - s->cs_base, SVM_IOIO_TYPE_MASK | svm_is_rep(prefixes)); - if (s->base.tb->cflags & CF_USE_ICOUNT) { + if (tb_cflags(s->base.tb) & CF_USE_ICOUNT) { gen_io_start(); } tcg_gen_movi_i32(cpu_tmp2_i32, val); gen_helper_in_func(ot, cpu_T1, cpu_tmp2_i32); gen_op_mov_reg_v(ot, R_EAX, cpu_T1); gen_bpt_io(s, cpu_tmp2_i32, ot); - if (s->base.tb->cflags & CF_USE_ICOUNT) { + if (tb_cflags(s->base.tb) & CF_USE_ICOUNT) { gen_io_end(); gen_jmp(s, s->pc - s->cs_base); } @@ -6353,14 +6353,14 @@ static target_ulong disas_insn(DisasContext *s, CPUState *cpu) svm_is_rep(prefixes)); gen_op_mov_v_reg(ot, cpu_T1, R_EAX); - if (s->base.tb->cflags & CF_USE_ICOUNT) { + if (tb_cflags(s->base.tb) & CF_USE_ICOUNT) { gen_io_start(); } tcg_gen_movi_i32(cpu_tmp2_i32, val); tcg_gen_trunc_tl_i32(cpu_tmp3_i32, cpu_T1); gen_helper_out_func(ot, cpu_tmp2_i32, cpu_tmp3_i32); gen_bpt_io(s, cpu_tmp2_i32, ot); - if (s->base.tb->cflags & CF_USE_ICOUNT) { + if (tb_cflags(s->base.tb) & CF_USE_ICOUNT) { gen_io_end(); gen_jmp(s, s->pc - s->cs_base); } @@ -6371,14 +6371,14 @@ static target_ulong disas_insn(DisasContext *s, CPUState *cpu) tcg_gen_ext16u_tl(cpu_T0, cpu_regs[R_EDX]); gen_check_io(s, ot, pc_start - s->cs_base, SVM_IOIO_TYPE_MASK | svm_is_rep(prefixes)); - if (s->base.tb->cflags & CF_USE_ICOUNT) { + if (tb_cflags(s->base.tb) & CF_USE_ICOUNT) { gen_io_start(); } tcg_gen_trunc_tl_i32(cpu_tmp2_i32, cpu_T0); gen_helper_in_func(ot, cpu_T1, cpu_tmp2_i32); gen_op_mov_reg_v(ot, R_EAX, cpu_T1); gen_bpt_io(s, cpu_tmp2_i32, ot); - if (s->base.tb->cflags & CF_USE_ICOUNT) { + if (tb_cflags(s->base.tb) & CF_USE_ICOUNT) { gen_io_end(); gen_jmp(s, s->pc - s->cs_base); } @@ -6391,14 +6391,14 @@ static target_ulong disas_insn(DisasContext *s, CPUState *cpu) svm_is_rep(prefixes)); gen_op_mov_v_reg(ot, cpu_T1, R_EAX); - if (s->base.tb->cflags & CF_USE_ICOUNT) { + if (tb_cflags(s->base.tb) & CF_USE_ICOUNT) { gen_io_start(); } tcg_gen_trunc_tl_i32(cpu_tmp2_i32, cpu_T0); tcg_gen_trunc_tl_i32(cpu_tmp3_i32, cpu_T1); gen_helper_out_func(ot, cpu_tmp2_i32, cpu_tmp3_i32); gen_bpt_io(s, cpu_tmp2_i32, ot); - if (s->base.tb->cflags & CF_USE_ICOUNT) { + if (tb_cflags(s->base.tb) & CF_USE_ICOUNT) { gen_io_end(); gen_jmp(s, s->pc - s->cs_base); } @@ -7106,11 +7106,11 @@ static target_ulong disas_insn(DisasContext *s, CPUState *cpu) case 0x131: /* rdtsc */ gen_update_cc_op(s); gen_jmp_im(pc_start - s->cs_base); - if (s->base.tb->cflags & CF_USE_ICOUNT) { + if (tb_cflags(s->base.tb) & CF_USE_ICOUNT) { gen_io_start(); } gen_helper_rdtsc(cpu_env); - if (s->base.tb->cflags & CF_USE_ICOUNT) { + if (tb_cflags(s->base.tb) & CF_USE_ICOUNT) { gen_io_end(); gen_jmp(s, s->pc - s->cs_base); } @@ -7565,11 +7565,11 @@ static target_ulong disas_insn(DisasContext *s, CPUState *cpu) } gen_update_cc_op(s); gen_jmp_im(pc_start - s->cs_base); - if (s->base.tb->cflags & CF_USE_ICOUNT) { + if (tb_cflags(s->base.tb) & CF_USE_ICOUNT) { gen_io_start(); } gen_helper_rdtscp(cpu_env); - if (s->base.tb->cflags & CF_USE_ICOUNT) { + if (tb_cflags(s->base.tb) & CF_USE_ICOUNT) { gen_io_end(); gen_jmp(s, s->pc - s->cs_base); } @@ -7934,24 +7934,24 @@ static target_ulong disas_insn(DisasContext *s, CPUState *cpu) gen_update_cc_op(s); gen_jmp_im(pc_start - s->cs_base); if (b & 2) { - if (s->base.tb->cflags & CF_USE_ICOUNT) { + if (tb_cflags(s->base.tb) & CF_USE_ICOUNT) { gen_io_start(); } gen_op_mov_v_reg(ot, cpu_T0, rm); gen_helper_write_crN(cpu_env, tcg_const_i32(reg), cpu_T0); - if (s->base.tb->cflags & CF_USE_ICOUNT) { + if (tb_cflags(s->base.tb) & CF_USE_ICOUNT) { gen_io_end(); } gen_jmp_im(s->pc - s->cs_base); gen_eob(s); } else { - if (s->base.tb->cflags & CF_USE_ICOUNT) { + if (tb_cflags(s->base.tb) & CF_USE_ICOUNT) { gen_io_start(); } gen_helper_read_crN(cpu_T0, cpu_env, tcg_const_i32(reg)); gen_op_mov_reg_v(ot, rm, cpu_T0); - if (s->base.tb->cflags & CF_USE_ICOUNT) { + if (tb_cflags(s->base.tb) & CF_USE_ICOUNT) { gen_io_end(); } } @@ -8415,7 +8415,7 @@ static int i386_tr_init_disas_context(DisasContextBase *dcbase, CPUState *cpu, record/replay modes and there will always be an additional step for ecx=0 when icount is enabled. */ - dc->repz_opt = !dc->jmp_opt && !(dc->base.tb->cflags & CF_USE_ICOUNT); + dc->repz_opt = !dc->jmp_opt && !(tb_cflags(dc->base.tb) & CF_USE_ICOUNT); #if 0 /* check addseg logic */ if (!dc->addseg && (dc->vm86 || !dc->pe || !dc->code32)) @@ -8481,7 +8481,7 @@ static void i386_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu) the flag and abort the translation to give the irqs a chance to happen */ dc->base.is_jmp = DISAS_TOO_MANY; - } else if ((dc->base.tb->cflags & CF_USE_ICOUNT) + } else if ((tb_cflags(dc->base.tb) & CF_USE_ICOUNT) && ((dc->base.pc_next & TARGET_PAGE_MASK) != ((dc->base.pc_next + TARGET_MAX_INSN_SIZE - 1) & TARGET_PAGE_MASK) diff --git a/target/lm32/translate.c b/target/lm32/translate.c index 65bc9c0bf6..d4a2e00165 100644 --- a/target/lm32/translate.c +++ b/target/lm32/translate.c @@ -880,24 +880,24 @@ static void dec_wcsr(DisasContext *dc) break; case CSR_IM: /* mark as an io operation because it could cause an interrupt */ - if (dc->tb->cflags & CF_USE_ICOUNT) { + if (tb_cflags(dc->tb) & CF_USE_ICOUNT) { gen_io_start(); } gen_helper_wcsr_im(cpu_env, cpu_R[dc->r1]); tcg_gen_movi_tl(cpu_pc, dc->pc + 4); - if (dc->tb->cflags & CF_USE_ICOUNT) { + if (tb_cflags(dc->tb) & CF_USE_ICOUNT) { gen_io_end(); } dc->is_jmp = DISAS_UPDATE; break; case CSR_IP: /* mark as an io operation because it could cause an interrupt */ - if (dc->tb->cflags & CF_USE_ICOUNT) { + if (tb_cflags(dc->tb) & CF_USE_ICOUNT) { gen_io_start(); } gen_helper_wcsr_ip(cpu_env, cpu_R[dc->r1]); tcg_gen_movi_tl(cpu_pc, dc->pc + 4); - if (dc->tb->cflags & CF_USE_ICOUNT) { + if (tb_cflags(dc->tb) & CF_USE_ICOUNT) { gen_io_end(); } dc->is_jmp = DISAS_UPDATE; @@ -1078,7 +1078,7 @@ void gen_intermediate_code(CPUState *cs, struct TranslationBlock *tb) next_page_start = (pc_start & TARGET_PAGE_MASK) + TARGET_PAGE_SIZE; num_insns = 0; - max_insns = tb->cflags & CF_COUNT_MASK; + max_insns = tb_cflags(tb) & CF_COUNT_MASK; if (max_insns == 0) { max_insns = CF_COUNT_MASK; } @@ -1106,7 +1106,7 @@ void gen_intermediate_code(CPUState *cs, struct TranslationBlock *tb) /* Pretty disas. */ LOG_DIS("%8.8x:\t", dc->pc); - if (num_insns == max_insns && (tb->cflags & CF_LAST_IO)) { + if (num_insns == max_insns && (tb_cflags(tb) & CF_LAST_IO)) { gen_io_start(); } @@ -1119,7 +1119,7 @@ void gen_intermediate_code(CPUState *cs, struct TranslationBlock *tb) && (dc->pc < next_page_start) && num_insns < max_insns); - if (tb->cflags & CF_LAST_IO) { + if (tb_cflags(tb) & CF_LAST_IO) { gen_io_end(); } diff --git a/target/m68k/translate.c b/target/m68k/translate.c index d738f32f9c..d199105559 100644 --- a/target/m68k/translate.c +++ b/target/m68k/translate.c @@ -5547,7 +5547,7 @@ void gen_intermediate_code(CPUState *cs, TranslationBlock *tb) dc->done_mac = 0; dc->writeback_mask = 0; num_insns = 0; - max_insns = tb->cflags & CF_COUNT_MASK; + max_insns = tb_cflags(tb) & CF_COUNT_MASK; if (max_insns == 0) { max_insns = CF_COUNT_MASK; } @@ -5573,7 +5573,7 @@ void gen_intermediate_code(CPUState *cs, TranslationBlock *tb) break; } - if (num_insns == max_insns && (tb->cflags & CF_LAST_IO)) { + if (num_insns == max_insns && (tb_cflags(tb) & CF_LAST_IO)) { gen_io_start(); } @@ -5585,7 +5585,7 @@ void gen_intermediate_code(CPUState *cs, TranslationBlock *tb) (pc_offset) < (TARGET_PAGE_SIZE - 32) && num_insns < max_insns); - if (tb->cflags & CF_LAST_IO) + if (tb_cflags(tb) & CF_LAST_IO) gen_io_end(); if (unlikely(cs->singlestep_enabled)) { /* Make sure the pc is updated, and raise a debug exception. */ diff --git a/target/microblaze/translate.c b/target/microblaze/translate.c index 067b0878d6..c70a2d6644 100644 --- a/target/microblaze/translate.c +++ b/target/microblaze/translate.c @@ -1666,7 +1666,7 @@ void gen_intermediate_code(CPUState *cs, struct TranslationBlock *tb) next_page_start = (pc_start & TARGET_PAGE_MASK) + TARGET_PAGE_SIZE; num_insns = 0; - max_insns = tb->cflags & CF_COUNT_MASK; + max_insns = tb_cflags(tb) & CF_COUNT_MASK; if (max_insns == 0) { max_insns = CF_COUNT_MASK; } @@ -1701,7 +1701,7 @@ void gen_intermediate_code(CPUState *cs, struct TranslationBlock *tb) /* Pretty disas. */ LOG_DIS("%8.8x:\t", dc->pc); - if (num_insns == max_insns && (tb->cflags & CF_LAST_IO)) { + if (num_insns == max_insns && (tb_cflags(tb) & CF_LAST_IO)) { gen_io_start(); } @@ -1763,7 +1763,7 @@ void gen_intermediate_code(CPUState *cs, struct TranslationBlock *tb) npc = dc->jmp_pc; } - if (tb->cflags & CF_LAST_IO) + if (tb_cflags(tb) & CF_LAST_IO) gen_io_end(); /* Force an update if the per-tb cpu state has changed. */ if (dc->is_jmp == DISAS_NEXT diff --git a/target/mips/translate.c b/target/mips/translate.c index ef07fa827e..aadffbec39 100644 --- a/target/mips/translate.c +++ b/target/mips/translate.c @@ -5327,11 +5327,11 @@ static void gen_mfc0(DisasContext *ctx, TCGv arg, int reg, int sel) switch (sel) { case 0: /* Mark as an IO operation because we read the time. */ - if (ctx->tb->cflags & CF_USE_ICOUNT) { + if (tb_cflags(ctx->tb) & CF_USE_ICOUNT) { gen_io_start(); } gen_helper_mfc0_count(arg, cpu_env); - if (ctx->tb->cflags & CF_USE_ICOUNT) { + if (tb_cflags(ctx->tb) & CF_USE_ICOUNT) { gen_io_end(); } /* Break the TB to be able to take timer interrupts immediately @@ -5734,7 +5734,7 @@ static void gen_mtc0(DisasContext *ctx, TCGv arg, int reg, int sel) if (sel != 0) check_insn(ctx, ISA_MIPS32); - if (ctx->tb->cflags & CF_USE_ICOUNT) { + if (tb_cflags(ctx->tb) & CF_USE_ICOUNT) { gen_io_start(); } @@ -6401,7 +6401,7 @@ static void gen_mtc0(DisasContext *ctx, TCGv arg, int reg, int sel) trace_mips_translate_c0("mtc0", rn, reg, sel); /* For simplicity assume that all writes can cause interrupts. */ - if (ctx->tb->cflags & CF_USE_ICOUNT) { + if (tb_cflags(ctx->tb) & CF_USE_ICOUNT) { gen_io_end(); /* BS_STOP isn't sufficient, we need to ensure we break out of * translated code to check for pending interrupts. */ @@ -6679,11 +6679,11 @@ static void gen_dmfc0(DisasContext *ctx, TCGv arg, int reg, int sel) switch (sel) { case 0: /* Mark as an IO operation because we read the time. */ - if (ctx->tb->cflags & CF_USE_ICOUNT) { + if (tb_cflags(ctx->tb) & CF_USE_ICOUNT) { gen_io_start(); } gen_helper_mfc0_count(arg, cpu_env); - if (ctx->tb->cflags & CF_USE_ICOUNT) { + if (tb_cflags(ctx->tb) & CF_USE_ICOUNT) { gen_io_end(); } /* Break the TB to be able to take timer interrupts immediately @@ -7072,7 +7072,7 @@ static void gen_dmtc0(DisasContext *ctx, TCGv arg, int reg, int sel) if (sel != 0) check_insn(ctx, ISA_MIPS64); - if (ctx->tb->cflags & CF_USE_ICOUNT) { + if (tb_cflags(ctx->tb) & CF_USE_ICOUNT) { gen_io_start(); } @@ -7727,7 +7727,7 @@ static void gen_dmtc0(DisasContext *ctx, TCGv arg, int reg, int sel) trace_mips_translate_c0("dmtc0", rn, reg, sel); /* For simplicity assume that all writes can cause interrupts. */ - if (ctx->tb->cflags & CF_USE_ICOUNT) { + if (tb_cflags(ctx->tb) & CF_USE_ICOUNT) { gen_io_end(); /* BS_STOP isn't sufficient, we need to ensure we break out of * translated code to check for pending interrupts. */ @@ -10756,11 +10756,11 @@ static void gen_rdhwr(DisasContext *ctx, int rt, int rd, int sel) gen_store_gpr(t0, rt); break; case 2: - if (ctx->tb->cflags & CF_USE_ICOUNT) { + if (tb_cflags(ctx->tb) & CF_USE_ICOUNT) { gen_io_start(); } gen_helper_rdhwr_cc(t0, cpu_env); - if (ctx->tb->cflags & CF_USE_ICOUNT) { + if (tb_cflags(ctx->tb) & CF_USE_ICOUNT) { gen_io_end(); } gen_store_gpr(t0, rt); @@ -20248,7 +20248,7 @@ void gen_intermediate_code(CPUState *cs, struct TranslationBlock *tb) ctx.default_tcg_memop_mask = (ctx.insn_flags & ISA_MIPS32R6) ? MO_UNALN : MO_ALIGN; num_insns = 0; - max_insns = tb->cflags & CF_COUNT_MASK; + max_insns = tb_cflags(tb) & CF_COUNT_MASK; if (max_insns == 0) { max_insns = CF_COUNT_MASK; } @@ -20274,7 +20274,7 @@ void gen_intermediate_code(CPUState *cs, struct TranslationBlock *tb) goto done_generating; } - if (num_insns == max_insns && (tb->cflags & CF_LAST_IO)) { + if (num_insns == max_insns && (tb_cflags(tb) & CF_LAST_IO)) { gen_io_start(); } @@ -20335,7 +20335,7 @@ void gen_intermediate_code(CPUState *cs, struct TranslationBlock *tb) if (singlestep) break; } - if (tb->cflags & CF_LAST_IO) { + if (tb_cflags(tb) & CF_LAST_IO) { gen_io_end(); } if (cs->singlestep_enabled && ctx.bstate != BS_BRANCH) { diff --git a/target/moxie/translate.c b/target/moxie/translate.c index eaf5103920..3f1e609028 100644 --- a/target/moxie/translate.c +++ b/target/moxie/translate.c @@ -832,7 +832,7 @@ void gen_intermediate_code(CPUState *cs, struct TranslationBlock *tb) ctx.singlestep_enabled = 0; ctx.bstate = BS_NONE; num_insns = 0; - max_insns = tb->cflags & CF_COUNT_MASK; + max_insns = tb_cflags(tb) & CF_COUNT_MASK; if (max_insns == 0) { max_insns = CF_COUNT_MASK; } diff --git a/target/nios2/translate.c b/target/nios2/translate.c index 6b0961837d..507d04e573 100644 --- a/target/nios2/translate.c +++ b/target/nios2/translate.c @@ -827,7 +827,7 @@ void gen_intermediate_code(CPUState *cs, TranslationBlock *tb) max_insns = 1; } else { int page_insns = (TARGET_PAGE_SIZE - (tb->pc & TARGET_PAGE_MASK)) / 4; - max_insns = tb->cflags & CF_COUNT_MASK; + max_insns = tb_cflags(tb) & CF_COUNT_MASK; if (max_insns == 0) { max_insns = CF_COUNT_MASK; } @@ -854,7 +854,7 @@ void gen_intermediate_code(CPUState *cs, TranslationBlock *tb) break; } - if (num_insns == max_insns && (tb->cflags & CF_LAST_IO)) { + if (num_insns == max_insns && (tb_cflags(tb) & CF_LAST_IO)) { gen_io_start(); } @@ -871,7 +871,7 @@ void gen_intermediate_code(CPUState *cs, TranslationBlock *tb) !tcg_op_buf_full() && num_insns < max_insns); - if (tb->cflags & CF_LAST_IO) { + if (tb_cflags(tb) & CF_LAST_IO) { gen_io_end(); } diff --git a/target/openrisc/translate.c b/target/openrisc/translate.c index 112db1ad0f..666d050650 100644 --- a/target/openrisc/translate.c +++ b/target/openrisc/translate.c @@ -1546,7 +1546,7 @@ void gen_intermediate_code(CPUState *cs, struct TranslationBlock *tb) next_page_start = (pc_start & TARGET_PAGE_MASK) + TARGET_PAGE_SIZE; num_insns = 0; - max_insns = tb->cflags & CF_COUNT_MASK; + max_insns = tb_cflags(tb) & CF_COUNT_MASK; if (max_insns == 0) { max_insns = CF_COUNT_MASK; @@ -1589,7 +1589,7 @@ void gen_intermediate_code(CPUState *cs, struct TranslationBlock *tb) break; } - if (num_insns == max_insns && (tb->cflags & CF_LAST_IO)) { + if (num_insns == max_insns && (tb_cflags(tb) & CF_LAST_IO)) { gen_io_start(); } disas_openrisc_insn(dc, cpu); @@ -1612,7 +1612,7 @@ void gen_intermediate_code(CPUState *cs, struct TranslationBlock *tb) && (dc->pc < next_page_start) && num_insns < max_insns); - if (tb->cflags & CF_LAST_IO) { + if (tb_cflags(tb) & CF_LAST_IO) { gen_io_end(); } diff --git a/target/ppc/translate.c b/target/ppc/translate.c index 770b461704..5e637d2e97 100644 --- a/target/ppc/translate.c +++ b/target/ppc/translate.c @@ -7261,7 +7261,7 @@ void gen_intermediate_code(CPUState *cs, struct TranslationBlock *tb) msr_se = 1; #endif num_insns = 0; - max_insns = tb->cflags & CF_COUNT_MASK; + max_insns = tb_cflags(tb) & CF_COUNT_MASK; if (max_insns == 0) { max_insns = CF_COUNT_MASK; } @@ -7289,7 +7289,7 @@ void gen_intermediate_code(CPUState *cs, struct TranslationBlock *tb) LOG_DISAS("----------------\n"); LOG_DISAS("nip=" TARGET_FMT_lx " super=%d ir=%d\n", ctx.nip, ctx.mem_idx, (int)msr_ir); - if (num_insns == max_insns && (tb->cflags & CF_LAST_IO)) + if (num_insns == max_insns && (tb_cflags(tb) & CF_LAST_IO)) gen_io_start(); if (unlikely(need_byteswap(&ctx))) { ctx.opcode = bswap32(cpu_ldl_code(env, ctx.nip)); @@ -7370,7 +7370,7 @@ void gen_intermediate_code(CPUState *cs, struct TranslationBlock *tb) exit(1); } } - if (tb->cflags & CF_LAST_IO) + if (tb_cflags(tb) & CF_LAST_IO) gen_io_end(); if (ctx.exception == POWERPC_EXCP_NONE) { gen_goto_tb(&ctx, 0, ctx.nip); diff --git a/target/ppc/translate_init.c b/target/ppc/translate_init.c index 4397254dbf..e00c485a4e 100644 --- a/target/ppc/translate_init.c +++ b/target/ppc/translate_init.c @@ -176,11 +176,11 @@ static void spr_write_ureg(DisasContext *ctx, int sprn, int gprn) #if !defined(CONFIG_USER_ONLY) static void spr_read_decr(DisasContext *ctx, int gprn, int sprn) { - if (ctx->tb->cflags & CF_USE_ICOUNT) { + if (tb_cflags(ctx->tb) & CF_USE_ICOUNT) { gen_io_start(); } gen_helper_load_decr(cpu_gpr[gprn], cpu_env); - if (ctx->tb->cflags & CF_USE_ICOUNT) { + if (tb_cflags(ctx->tb) & CF_USE_ICOUNT) { gen_io_end(); gen_stop_exception(ctx); } @@ -188,11 +188,11 @@ static void spr_read_decr(DisasContext *ctx, int gprn, int sprn) static void spr_write_decr(DisasContext *ctx, int sprn, int gprn) { - if (ctx->tb->cflags & CF_USE_ICOUNT) { + if (tb_cflags(ctx->tb) & CF_USE_ICOUNT) { gen_io_start(); } gen_helper_store_decr(cpu_env, cpu_gpr[gprn]); - if (ctx->tb->cflags & CF_USE_ICOUNT) { + if (tb_cflags(ctx->tb) & CF_USE_ICOUNT) { gen_io_end(); gen_stop_exception(ctx); } @@ -203,11 +203,11 @@ static void spr_write_decr(DisasContext *ctx, int sprn, int gprn) /* Time base */ static void spr_read_tbl(DisasContext *ctx, int gprn, int sprn) { - if (ctx->tb->cflags & CF_USE_ICOUNT) { + if (tb_cflags(ctx->tb) & CF_USE_ICOUNT) { gen_io_start(); } gen_helper_load_tbl(cpu_gpr[gprn], cpu_env); - if (ctx->tb->cflags & CF_USE_ICOUNT) { + if (tb_cflags(ctx->tb) & CF_USE_ICOUNT) { gen_io_end(); gen_stop_exception(ctx); } @@ -215,11 +215,11 @@ static void spr_read_tbl(DisasContext *ctx, int gprn, int sprn) static void spr_read_tbu(DisasContext *ctx, int gprn, int sprn) { - if (ctx->tb->cflags & CF_USE_ICOUNT) { + if (tb_cflags(ctx->tb) & CF_USE_ICOUNT) { gen_io_start(); } gen_helper_load_tbu(cpu_gpr[gprn], cpu_env); - if (ctx->tb->cflags & CF_USE_ICOUNT) { + if (tb_cflags(ctx->tb) & CF_USE_ICOUNT) { gen_io_end(); gen_stop_exception(ctx); } @@ -240,11 +240,11 @@ static void spr_read_atbu(DisasContext *ctx, int gprn, int sprn) #if !defined(CONFIG_USER_ONLY) static void spr_write_tbl(DisasContext *ctx, int sprn, int gprn) { - if (ctx->tb->cflags & CF_USE_ICOUNT) { + if (tb_cflags(ctx->tb) & CF_USE_ICOUNT) { gen_io_start(); } gen_helper_store_tbl(cpu_env, cpu_gpr[gprn]); - if (ctx->tb->cflags & CF_USE_ICOUNT) { + if (tb_cflags(ctx->tb) & CF_USE_ICOUNT) { gen_io_end(); gen_stop_exception(ctx); } @@ -252,11 +252,11 @@ static void spr_write_tbl(DisasContext *ctx, int sprn, int gprn) static void spr_write_tbu(DisasContext *ctx, int sprn, int gprn) { - if (ctx->tb->cflags & CF_USE_ICOUNT) { + if (tb_cflags(ctx->tb) & CF_USE_ICOUNT) { gen_io_start(); } gen_helper_store_tbu(cpu_env, cpu_gpr[gprn]); - if (ctx->tb->cflags & CF_USE_ICOUNT) { + if (tb_cflags(ctx->tb) & CF_USE_ICOUNT) { gen_io_end(); gen_stop_exception(ctx); } @@ -284,11 +284,11 @@ static void spr_read_purr(DisasContext *ctx, int gprn, int sprn) /* HDECR */ static void spr_read_hdecr(DisasContext *ctx, int gprn, int sprn) { - if (ctx->tb->cflags & CF_USE_ICOUNT) { + if (tb_cflags(ctx->tb) & CF_USE_ICOUNT) { gen_io_start(); } gen_helper_load_hdecr(cpu_gpr[gprn], cpu_env); - if (ctx->tb->cflags & CF_USE_ICOUNT) { + if (tb_cflags(ctx->tb) & CF_USE_ICOUNT) { gen_io_end(); gen_stop_exception(ctx); } @@ -296,11 +296,11 @@ static void spr_read_hdecr(DisasContext *ctx, int gprn, int sprn) static void spr_write_hdecr(DisasContext *ctx, int sprn, int gprn) { - if (ctx->tb->cflags & CF_USE_ICOUNT) { + if (tb_cflags(ctx->tb) & CF_USE_ICOUNT) { gen_io_start(); } gen_helper_store_hdecr(cpu_env, cpu_gpr[gprn]); - if (ctx->tb->cflags & CF_USE_ICOUNT) { + if (tb_cflags(ctx->tb) & CF_USE_ICOUNT) { gen_io_end(); gen_stop_exception(ctx); } diff --git a/target/s390x/translate.c b/target/s390x/translate.c index 165d2cac3e..b950b16d9b 100644 --- a/target/s390x/translate.c +++ b/target/s390x/translate.c @@ -554,7 +554,7 @@ static void gen_op_calc_cc(DisasContext *s) static bool use_exit_tb(DisasContext *s) { return (s->singlestep_enabled || - (s->tb->cflags & CF_LAST_IO) || + (tb_cflags(s->tb) & CF_LAST_IO) || (s->tb->flags & FLAG_MASK_PER)); } @@ -5881,7 +5881,7 @@ void gen_intermediate_code(CPUState *cs, struct TranslationBlock *tb) next_page_start = (pc_start & TARGET_PAGE_MASK) + TARGET_PAGE_SIZE; num_insns = 0; - max_insns = tb->cflags & CF_COUNT_MASK; + max_insns = tb_cflags(tb) & CF_COUNT_MASK; if (max_insns == 0) { max_insns = CF_COUNT_MASK; } @@ -5906,7 +5906,7 @@ void gen_intermediate_code(CPUState *cs, struct TranslationBlock *tb) break; } - if (num_insns == max_insns && (tb->cflags & CF_LAST_IO)) { + if (num_insns == max_insns && (tb_cflags(tb) & CF_LAST_IO)) { gen_io_start(); } @@ -5925,7 +5925,7 @@ void gen_intermediate_code(CPUState *cs, struct TranslationBlock *tb) } } while (status == NO_EXIT); - if (tb->cflags & CF_LAST_IO) { + if (tb_cflags(tb) & CF_LAST_IO) { gen_io_end(); } diff --git a/target/sh4/translate.c b/target/sh4/translate.c index b4e4fd3782..33176c9926 100644 --- a/target/sh4/translate.c +++ b/target/sh4/translate.c @@ -2248,7 +2248,7 @@ void gen_intermediate_code(CPUState *cs, struct TranslationBlock *tb) (ctx.tbflags & (1 << SR_RB))) * 0x10; ctx.fbank = ctx.tbflags & FPSCR_FR ? 0x10 : 0; - max_insns = tb->cflags & CF_COUNT_MASK; + max_insns = tb_cflags(tb) & CF_COUNT_MASK; if (max_insns == 0) { max_insns = CF_COUNT_MASK; } @@ -2292,7 +2292,7 @@ void gen_intermediate_code(CPUState *cs, struct TranslationBlock *tb) break; } - if (num_insns == max_insns && (tb->cflags & CF_LAST_IO)) { + if (num_insns == max_insns && (tb_cflags(tb) & CF_LAST_IO)) { gen_io_start(); } @@ -2300,7 +2300,7 @@ void gen_intermediate_code(CPUState *cs, struct TranslationBlock *tb) decode_opc(&ctx); ctx.pc += 2; } - if (tb->cflags & CF_LAST_IO) { + if (tb_cflags(tb) & CF_LAST_IO) { gen_io_end(); } diff --git a/target/sparc/translate.c b/target/sparc/translate.c index f63d7fb6ab..05414ce8a8 100644 --- a/target/sparc/translate.c +++ b/target/sparc/translate.c @@ -5772,7 +5772,7 @@ void gen_intermediate_code(CPUState *cs, TranslationBlock * tb) #endif num_insns = 0; - max_insns = tb->cflags & CF_COUNT_MASK; + max_insns = tb_cflags(tb) & CF_COUNT_MASK; if (max_insns == 0) { max_insns = CF_COUNT_MASK; } @@ -5801,7 +5801,7 @@ void gen_intermediate_code(CPUState *cs, TranslationBlock * tb) goto exit_gen_loop; } - if (num_insns == max_insns && (tb->cflags & CF_LAST_IO)) { + if (num_insns == max_insns && (tb_cflags(tb) & CF_LAST_IO)) { gen_io_start(); } @@ -5828,7 +5828,7 @@ void gen_intermediate_code(CPUState *cs, TranslationBlock * tb) num_insns < max_insns); exit_gen_loop: - if (tb->cflags & CF_LAST_IO) { + if (tb_cflags(tb) & CF_LAST_IO) { gen_io_end(); } if (!dc->is_br) { diff --git a/target/tilegx/translate.c b/target/tilegx/translate.c index ace2830a84..5cd84f6b25 100644 --- a/target/tilegx/translate.c +++ b/target/tilegx/translate.c @@ -2378,7 +2378,7 @@ void gen_intermediate_code(CPUState *cs, struct TranslationBlock *tb) uint64_t pc_start = tb->pc; uint64_t next_page_start = (pc_start & TARGET_PAGE_MASK) + TARGET_PAGE_SIZE; int num_insns = 0; - int max_insns = tb->cflags & CF_COUNT_MASK; + int max_insns = tb_cflags(tb) & CF_COUNT_MASK; dc->pc = pc_start; dc->mmuidx = 0; diff --git a/target/tricore/translate.c b/target/tricore/translate.c index b6cfbdfa9f..042c0e69bc 100644 --- a/target/tricore/translate.c +++ b/target/tricore/translate.c @@ -8790,7 +8790,7 @@ void gen_intermediate_code(CPUState *cs, struct TranslationBlock *tb) int num_insns, max_insns; num_insns = 0; - max_insns = tb->cflags & CF_COUNT_MASK; + max_insns = tb_cflags(tb) & CF_COUNT_MASK; if (max_insns == 0) { max_insns = CF_COUNT_MASK; } diff --git a/target/unicore32/translate.c b/target/unicore32/translate.c index 6c094d59d7..d717de0335 100644 --- a/target/unicore32/translate.c +++ b/target/unicore32/translate.c @@ -1900,7 +1900,7 @@ void gen_intermediate_code(CPUState *cs, TranslationBlock *tb) cpu_F1d = tcg_temp_new_i64(); next_page_start = (pc_start & TARGET_PAGE_MASK) + TARGET_PAGE_SIZE; num_insns = 0; - max_insns = tb->cflags & CF_COUNT_MASK; + max_insns = tb_cflags(tb) & CF_COUNT_MASK; if (max_insns == 0) { max_insns = CF_COUNT_MASK; } @@ -1933,7 +1933,7 @@ void gen_intermediate_code(CPUState *cs, TranslationBlock *tb) goto done_generating; } - if (num_insns == max_insns && (tb->cflags & CF_LAST_IO)) { + if (num_insns == max_insns && (tb_cflags(tb) & CF_LAST_IO)) { gen_io_start(); } @@ -1958,7 +1958,7 @@ void gen_intermediate_code(CPUState *cs, TranslationBlock *tb) dc->pc < next_page_start && num_insns < max_insns); - if (tb->cflags & CF_LAST_IO) { + if (tb_cflags(tb) & CF_LAST_IO) { if (dc->condjmp) { /* FIXME: This can theoretically happen with self-modifying code. */ diff --git a/target/xtensa/translate.c b/target/xtensa/translate.c index d7bf07e8e6..f62319eddd 100644 --- a/target/xtensa/translate.c +++ b/target/xtensa/translate.c @@ -517,12 +517,12 @@ static bool gen_check_sr(DisasContext *dc, uint32_t sr, unsigned access) static bool gen_rsr_ccount(DisasContext *dc, TCGv_i32 d, uint32_t sr) { - if (dc->tb->cflags & CF_USE_ICOUNT) { + if (tb_cflags(dc->tb) & CF_USE_ICOUNT) { gen_io_start(); } gen_helper_update_ccount(cpu_env); tcg_gen_mov_i32(d, cpu_SR[sr]); - if (dc->tb->cflags & CF_USE_ICOUNT) { + if (tb_cflags(dc->tb) & CF_USE_ICOUNT) { gen_io_end(); return true; } @@ -702,11 +702,11 @@ static bool gen_wsr_cpenable(DisasContext *dc, uint32_t sr, TCGv_i32 v) static void gen_check_interrupts(DisasContext *dc) { - if (dc->tb->cflags & CF_USE_ICOUNT) { + if (tb_cflags(dc->tb) & CF_USE_ICOUNT) { gen_io_start(); } gen_helper_check_interrupts(cpu_env); - if (dc->tb->cflags & CF_USE_ICOUNT) { + if (tb_cflags(dc->tb) & CF_USE_ICOUNT) { gen_io_end(); } } @@ -760,11 +760,11 @@ static bool gen_wsr_ps(DisasContext *dc, uint32_t sr, TCGv_i32 v) static bool gen_wsr_ccount(DisasContext *dc, uint32_t sr, TCGv_i32 v) { - if (dc->tb->cflags & CF_USE_ICOUNT) { + if (tb_cflags(dc->tb) & CF_USE_ICOUNT) { gen_io_start(); } gen_helper_wsr_ccount(cpu_env, v); - if (dc->tb->cflags & CF_USE_ICOUNT) { + if (tb_cflags(dc->tb) & CF_USE_ICOUNT) { gen_io_end(); gen_jumpi_check_loop_end(dc, 0); return true; @@ -801,11 +801,11 @@ static bool gen_wsr_ccompare(DisasContext *dc, uint32_t sr, TCGv_i32 v) tcg_gen_mov_i32(cpu_SR[sr], v); tcg_gen_andi_i32(cpu_SR[INTSET], cpu_SR[INTSET], ~int_bit); - if (dc->tb->cflags & CF_USE_ICOUNT) { + if (tb_cflags(dc->tb) & CF_USE_ICOUNT) { gen_io_start(); } gen_helper_update_ccompare(cpu_env, tmp); - if (dc->tb->cflags & CF_USE_ICOUNT) { + if (tb_cflags(dc->tb) & CF_USE_ICOUNT) { gen_io_end(); gen_jumpi_check_loop_end(dc, 0); ret = true; @@ -900,11 +900,11 @@ static void gen_waiti(DisasContext *dc, uint32_t imm4) TCGv_i32 pc = tcg_const_i32(dc->next_pc); TCGv_i32 intlevel = tcg_const_i32(imm4); - if (dc->tb->cflags & CF_USE_ICOUNT) { + if (tb_cflags(dc->tb) & CF_USE_ICOUNT) { gen_io_start(); } gen_helper_waiti(cpu_env, pc, intlevel); - if (dc->tb->cflags & CF_USE_ICOUNT) { + if (tb_cflags(dc->tb) & CF_USE_ICOUNT) { gen_io_end(); } tcg_temp_free(pc); @@ -3126,7 +3126,7 @@ void gen_intermediate_code(CPUState *cs, TranslationBlock *tb) CPUXtensaState *env = cs->env_ptr; DisasContext dc; int insn_count = 0; - int max_insns = tb->cflags & CF_COUNT_MASK; + int max_insns = tb_cflags(tb) & CF_COUNT_MASK; uint32_t pc_start = tb->pc; uint32_t next_page_start = (pc_start & TARGET_PAGE_MASK) + TARGET_PAGE_SIZE; @@ -3162,7 +3162,7 @@ void gen_intermediate_code(CPUState *cs, TranslationBlock *tb) gen_tb_start(tb); - if ((tb->cflags & CF_USE_ICOUNT) && + if ((tb_cflags(tb) & CF_USE_ICOUNT) && (tb->flags & XTENSA_TBFLAG_YIELD)) { tcg_gen_insn_start(dc.pc); ++insn_count; @@ -3194,7 +3194,7 @@ void gen_intermediate_code(CPUState *cs, TranslationBlock *tb) break; } - if (insn_count == max_insns && (tb->cflags & CF_LAST_IO)) { + if (insn_count == max_insns && (tb_cflags(tb) & CF_LAST_IO)) { gen_io_start(); } @@ -3235,7 +3235,7 @@ done: tcg_temp_free(dc.next_icount); } - if (tb->cflags & CF_LAST_IO) { + if (tb_cflags(tb) & CF_LAST_IO) { gen_io_end(); } From patchwork Mon Oct 16 17:25:46 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 115955 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp3950784qgn; Mon, 16 Oct 2017 10:46:03 -0700 (PDT) X-Received: by 10.233.244.1 with SMTP id y1mr15707661qkl.300.1508175963535; Mon, 16 Oct 2017 10:46:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508175963; cv=none; d=google.com; s=arc-20160816; b=JAmZIN/tUPnolN1gvYmvBDtwul/jVvUlo4ATW83D8GluUmHEQciHur2v4PtpDkiLtO c0V5kTtRRQ2AAczyECuBx5OkXZeIsv4o1Y8KzJlMxVFYrZInT1KYJ+x9Gb2P6VgMKRCl U3Dya7whpYtpE+Ql9BQm4rdNqBBD/UocXp9C1SUGiIa9NneGzrKvX0JE0SpboFEDf4Zq rYwFMsJ1J5AYPaLxtvvX6y9pgbORUWzM2jf3A5jxVxKi3MhFw/7w20hcHfXuJHOTiMKk 6ZHb6eo72beWDptOkSGXkNP40fS7b/wm4oqKrYbIS6g20fi7WjOaIA9LOtZN6l4tQjOl /lPg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=jyya47iTzUAdCGaEw+6tfV7WebwryS73Is3iHDpzmrA=; b=n4B6oHvQXz6X3zWkTP8/XkPkhAGtgDW3kaWAiNebYYo1H1zHD8Ok2EGRWlYnWvYXGd 3DFSr+rNbp8N8U7UgYbe4/kT5XShAvKx5hIRDRiLqhlb0lGYLovyLewkuxh8fZtEL38y W25RnAqXvtDRvg3fPQHiEhTlMzdAMt51QjudXy4gkBGjr9nlktXypwDXNH+yB6qOv/YW sontWgqBVuX2Gm6X2wx5WWac1X2sdCcduzX/YfUUoAHgkvwxhkb+aUV6gUMBCHEB6MMf Mh2xXpxQssKirkqbGyJyB4c8bPHykzikufe/i0zynQfomRQFZaqUeawh7KLV+fMvbodS +WlQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=OVn+DCR+; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id h43si1171879qte.273.2017.10.16.10.46.03 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 16 Oct 2017 10:46:03 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=OVn+DCR+; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:34376 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e49Sj-0001eQ-9r for patch@linaro.org; Mon, 16 Oct 2017 13:46:01 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52480) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e49AE-0002U5-On for qemu-devel@nongnu.org; Mon, 16 Oct 2017 13:26:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e49AD-0003gM-ER for qemu-devel@nongnu.org; Mon, 16 Oct 2017 13:26:54 -0400 Received: from mail-pf0-x22a.google.com ([2607:f8b0:400e:c00::22a]:53056) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e49AD-0003fm-6W for qemu-devel@nongnu.org; Mon, 16 Oct 2017 13:26:53 -0400 Received: by mail-pf0-x22a.google.com with SMTP id e64so16286014pfk.9 for ; Mon, 16 Oct 2017 10:26:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=jyya47iTzUAdCGaEw+6tfV7WebwryS73Is3iHDpzmrA=; b=OVn+DCR+ELufyR9O4DIPXa1tuGnLPG8DhBJY07+R9qG7rOpHVHeCSCD6xTiYE0Zcfx IgBhz05A7fIX66RtcfPHa8K1Hrz4HXdn+kDYxmp84SeCjjeLaxYfM/XJ3emvTi+3Adyo yKrS7pbr8iBIT421vxskL7ojVE3RRl3lYfh9s= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=jyya47iTzUAdCGaEw+6tfV7WebwryS73Is3iHDpzmrA=; b=DfaOJbtuuPRgPRh+WQV6io0MYxtNSnZGcoFzj5jqVIXTmeXe312s0WFHlNl34oJ7yY 2UWn+KdkI46s4Jnh1eiIQcAJ57a5KDapDW+Mj3NRTdqofIQrJAJLFCahbG+g366XjB/U CyzGBSCPQsZilWyJEWCGRYWvhenK1WjutX8EPkM/5/3HgMYcJaPklKSytnUajJwwqHTd dwUnQobd2azs+ykzl+ep7hqW/AOPe358W0MnBcQu5aoaZdHruU+ntoCztEd7o819JHij l1yAwlroqwpArUYY+pxSJ5qjQHVMk/RyQHwSjpTQvRnWinVxsqEygXE1BVUqvoBTfhUJ /hrA== X-Gm-Message-State: AMCzsaUM6SywKlciYbAjXm6sQDtIsc5PVKu79aqYu0+WYy6Hr/WAJy1o jtV+1sybr8hLZbF5o1WWJVBMPXs/HJY= X-Google-Smtp-Source: AOwi7QBJ2hx1/nzdMh0dn/rw8kiPduunqWYf0EWoF1syRWQRI7/oUCxadtN/mgxnt4SKV+TBXOOJtw== X-Received: by 10.98.69.86 with SMTP id s83mr9549614pfa.32.1508174811934; Mon, 16 Oct 2017 10:26:51 -0700 (PDT) Received: from cloudburst.twiddle.net (97-126-104-76.tukw.qwest.net. [97.126.104.76]) by smtp.gmail.com with ESMTPSA id i187sm5594249pfc.96.2017.10.16.10.26.50 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 16 Oct 2017 10:26:51 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Mon, 16 Oct 2017 10:25:46 -0700 Message-Id: <20171016172609.23422-28-richard.henderson@linaro.org> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171016172609.23422-1-richard.henderson@linaro.org> References: <20171016172609.23422-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c00::22a Subject: [Qemu-devel] [PATCH v6 27/50] target/arm: check CF_PARALLEL instead of parallel_cpus 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: cota@braap.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: "Emilio G. Cota" Thereby decoupling the resulting translated code from the current state of the system. Reviewed-by: Richard Henderson Signed-off-by: Emilio G. Cota --- target/arm/helper-a64.h | 4 ++++ target/arm/helper-a64.c | 38 ++++++++++++++++++++++++++++++++------ target/arm/op_helper.c | 7 ------- target/arm/translate-a64.c | 31 +++++++++++++++++++++++++------ target/arm/translate.c | 9 +++++++-- 5 files changed, 68 insertions(+), 21 deletions(-) -- 2.13.6 diff --git a/target/arm/helper-a64.h b/target/arm/helper-a64.h index 6f9eaba533..85d86741db 100644 --- a/target/arm/helper-a64.h +++ b/target/arm/helper-a64.h @@ -43,4 +43,8 @@ DEF_HELPER_FLAGS_2(fcvtx_f64_to_f32, TCG_CALL_NO_RWG, f32, f64, env) DEF_HELPER_FLAGS_3(crc32_64, TCG_CALL_NO_RWG_SE, i64, i64, i64, i32) DEF_HELPER_FLAGS_3(crc32c_64, TCG_CALL_NO_RWG_SE, i64, i64, i64, i32) DEF_HELPER_FLAGS_4(paired_cmpxchg64_le, TCG_CALL_NO_WG, i64, env, i64, i64, i64) +DEF_HELPER_FLAGS_4(paired_cmpxchg64_le_parallel, TCG_CALL_NO_WG, + i64, env, i64, i64, i64) DEF_HELPER_FLAGS_4(paired_cmpxchg64_be, TCG_CALL_NO_WG, i64, env, i64, i64, i64) +DEF_HELPER_FLAGS_4(paired_cmpxchg64_be_parallel, TCG_CALL_NO_WG, + i64, env, i64, i64, i64) diff --git a/target/arm/helper-a64.c b/target/arm/helper-a64.c index d9df82cff5..d0e435ca4b 100644 --- a/target/arm/helper-a64.c +++ b/target/arm/helper-a64.c @@ -430,8 +430,9 @@ uint64_t HELPER(crc32c_64)(uint64_t acc, uint64_t val, uint32_t bytes) } /* Returns 0 on success; 1 otherwise. */ -uint64_t HELPER(paired_cmpxchg64_le)(CPUARMState *env, uint64_t addr, - uint64_t new_lo, uint64_t new_hi) +static uint64_t do_paired_cmpxchg64_le(CPUARMState *env, uint64_t addr, + uint64_t new_lo, uint64_t new_hi, + bool parallel) { uintptr_t ra = GETPC(); Int128 oldv, cmpv, newv; @@ -440,7 +441,7 @@ uint64_t HELPER(paired_cmpxchg64_le)(CPUARMState *env, uint64_t addr, cmpv = int128_make128(env->exclusive_val, env->exclusive_high); newv = int128_make128(new_lo, new_hi); - if (parallel_cpus) { + if (parallel) { #ifndef CONFIG_ATOMIC128 cpu_loop_exit_atomic(ENV_GET_CPU(env), ra); #else @@ -484,8 +485,21 @@ uint64_t HELPER(paired_cmpxchg64_le)(CPUARMState *env, uint64_t addr, return !success; } -uint64_t HELPER(paired_cmpxchg64_be)(CPUARMState *env, uint64_t addr, - uint64_t new_lo, uint64_t new_hi) +uint64_t HELPER(paired_cmpxchg64_le)(CPUARMState *env, uint64_t addr, + uint64_t new_lo, uint64_t new_hi) +{ + return do_paired_cmpxchg64_le(env, addr, new_lo, new_hi, false); +} + +uint64_t HELPER(paired_cmpxchg64_le_parallel)(CPUARMState *env, uint64_t addr, + uint64_t new_lo, uint64_t new_hi) +{ + return do_paired_cmpxchg64_le(env, addr, new_lo, new_hi, true); +} + +static uint64_t do_paired_cmpxchg64_be(CPUARMState *env, uint64_t addr, + uint64_t new_lo, uint64_t new_hi, + bool parallel) { uintptr_t ra = GETPC(); Int128 oldv, cmpv, newv; @@ -494,7 +508,7 @@ uint64_t HELPER(paired_cmpxchg64_be)(CPUARMState *env, uint64_t addr, cmpv = int128_make128(env->exclusive_val, env->exclusive_high); newv = int128_make128(new_lo, new_hi); - if (parallel_cpus) { + if (parallel) { #ifndef CONFIG_ATOMIC128 cpu_loop_exit_atomic(ENV_GET_CPU(env), ra); #else @@ -537,3 +551,15 @@ uint64_t HELPER(paired_cmpxchg64_be)(CPUARMState *env, uint64_t addr, return !success; } + +uint64_t HELPER(paired_cmpxchg64_be)(CPUARMState *env, uint64_t addr, + uint64_t new_lo, uint64_t new_hi) +{ + return do_paired_cmpxchg64_be(env, addr, new_lo, new_hi, false); +} + +uint64_t HELPER(paired_cmpxchg64_be_parallel)(CPUARMState *env, uint64_t addr, + uint64_t new_lo, uint64_t new_hi) +{ + return do_paired_cmpxchg64_be(env, addr, new_lo, new_hi, true); +} diff --git a/target/arm/op_helper.c b/target/arm/op_helper.c index 3914145709..138d0df82f 100644 --- a/target/arm/op_helper.c +++ b/target/arm/op_helper.c @@ -502,13 +502,6 @@ void HELPER(yield)(CPUARMState *env) ARMCPU *cpu = arm_env_get_cpu(env); CPUState *cs = CPU(cpu); - /* When running in MTTCG we don't generate jumps to the yield and - * WFE helpers as it won't affect the scheduling of other vCPUs. - * If we wanted to more completely model WFE/SEV so we don't busy - * spin unnecessarily we would need to do something more involved. - */ - g_assert(!parallel_cpus); - /* This is a non-trappable hint instruction that generally indicates * that the guest is currently busy-looping. Yield control back to the * top level loop so that a more deserving VCPU has a chance to run. diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c index e9bee8c196..f6b364c04b 100644 --- a/target/arm/translate-a64.c +++ b/target/arm/translate-a64.c @@ -1336,13 +1336,18 @@ static void handle_hint(DisasContext *s, uint32_t insn, case 3: /* WFI */ s->base.is_jmp = DISAS_WFI; return; + /* When running in MTTCG we don't generate jumps to the yield and + * WFE helpers as it won't affect the scheduling of other vCPUs. + * If we wanted to more completely model WFE/SEV so we don't busy + * spin unnecessarily we would need to do something more involved. + */ case 1: /* YIELD */ - if (!parallel_cpus) { + if (!(tb_cflags(s->base.tb) & CF_PARALLEL)) { s->base.is_jmp = DISAS_YIELD; } return; case 2: /* WFE */ - if (!parallel_cpus) { + if (!(tb_cflags(s->base.tb) & CF_PARALLEL)) { s->base.is_jmp = DISAS_WFE; } return; @@ -1931,11 +1936,25 @@ static void gen_store_exclusive(DisasContext *s, int rd, int rt, int rt2, MO_64 | MO_ALIGN | s->be_data); tcg_gen_setcond_i64(TCG_COND_NE, tmp, tmp, cpu_exclusive_val); } else if (s->be_data == MO_LE) { - gen_helper_paired_cmpxchg64_le(tmp, cpu_env, cpu_exclusive_addr, - cpu_reg(s, rt), cpu_reg(s, rt2)); + if (tb_cflags(s->base.tb) & CF_PARALLEL) { + gen_helper_paired_cmpxchg64_le_parallel(tmp, cpu_env, + cpu_exclusive_addr, + cpu_reg(s, rt), + cpu_reg(s, rt2)); + } else { + gen_helper_paired_cmpxchg64_le(tmp, cpu_env, cpu_exclusive_addr, + cpu_reg(s, rt), cpu_reg(s, rt2)); + } } else { - gen_helper_paired_cmpxchg64_be(tmp, cpu_env, cpu_exclusive_addr, - cpu_reg(s, rt), cpu_reg(s, rt2)); + if (tb_cflags(s->base.tb) & CF_PARALLEL) { + gen_helper_paired_cmpxchg64_be_parallel(tmp, cpu_env, + cpu_exclusive_addr, + cpu_reg(s, rt), + cpu_reg(s, rt2)); + } else { + gen_helper_paired_cmpxchg64_be(tmp, cpu_env, cpu_exclusive_addr, + cpu_reg(s, rt), cpu_reg(s, rt2)); + } } } else { tcg_gen_atomic_cmpxchg_i64(tmp, cpu_exclusive_addr, cpu_exclusive_val, diff --git a/target/arm/translate.c b/target/arm/translate.c index dfa547b1db..397cc7afea 100644 --- a/target/arm/translate.c +++ b/target/arm/translate.c @@ -4546,8 +4546,13 @@ static void gen_exception_return(DisasContext *s, TCGv_i32 pc) static void gen_nop_hint(DisasContext *s, int val) { switch (val) { + /* When running in MTTCG we don't generate jumps to the yield and + * WFE helpers as it won't affect the scheduling of other vCPUs. + * If we wanted to more completely model WFE/SEV so we don't busy + * spin unnecessarily we would need to do something more involved. + */ case 1: /* yield */ - if (!parallel_cpus) { + if (!(tb_cflags(s->base.tb) & CF_PARALLEL)) { gen_set_pc_im(s, s->pc); s->base.is_jmp = DISAS_YIELD; } @@ -4557,7 +4562,7 @@ static void gen_nop_hint(DisasContext *s, int val) s->base.is_jmp = DISAS_WFI; break; case 2: /* wfe */ - if (!parallel_cpus) { + if (!(tb_cflags(s->base.tb) & CF_PARALLEL)) { gen_set_pc_im(s, s->pc); s->base.is_jmp = DISAS_WFE; } From patchwork Mon Oct 16 17:25:47 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 115961 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp3955329qgn; Mon, 16 Oct 2017 10:51:44 -0700 (PDT) X-Received: by 10.55.16.34 with SMTP id a34mr15367257qkh.353.1508176304161; Mon, 16 Oct 2017 10:51:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508176304; cv=none; d=google.com; s=arc-20160816; b=WBTm2zebbpGovdBmKzsPQAfwYlLaghsAQFgp6VaSErg6vAD6JEn6ZdhGOqBP3Fsmec bClNwzVA/2yAFedZ/5sHWycg9Bl2rrsSJcMbm8fsvRM5hWnQKFW587214NddU/CDZtCw dk7I+0+cxb9+dSwwIlnREaRBklb44/rgKkeRyRNtmjtsB63sBnaWbTlUsl1MLOcxqZoE xrSL4L5CCuTYJEEdjPMTIO6Pd4zPbSrQZx5aEzqWiZLc6voWP80638oWidkvcy8HjTnm N7mYQU3YbIOp/9S6gZ3DhGid5ZlEz3YXi2KH12P93A4uz3CgBpv5dLmeyP0fyYpvd9hL y0Ag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=RAagLYFqCSetGLwSSInErglxie5S43P08bbjsB82qWY=; b=Y5ryFgCeIo9UCdbuthzH3vCK/nlGb7PrfKUosj1pzwtPs8YkZu9yimj59kYEMRyDUR pmj1xx2HCArom3xsVf9vUUaTJNjehW+gNCKiM1SV/KEiCqEJql5dHhT9A/JG1S64iyUB kV2Q/XP9aS0AIm1hjjd84aibI+J/DVv1M2GSedQbXnP+9AUPpRT60AwYMDHZnsplLCCo 6S12AniTkb2KHyV2TBbYGtYVzM6qjafpKWRoFSg2SPF3FizuSNQDI6+rY0E6ep0+qC9C RdGEgQ/rnUa8ZCNlsXli4U3eMbe/J15wE8yicgGkBui/K8D/Ikoh+/lGZZRsuVaFTtm6 zHOg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=EoeWklp9; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id g13si6960915qtc.18.2017.10.16.10.51.43 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 16 Oct 2017 10:51:44 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=EoeWklp9; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:34398 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e49YD-0006OL-SV for patch@linaro.org; Mon, 16 Oct 2017 13:51:41 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52519) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e49AI-0002YE-Ks for qemu-devel@nongnu.org; Mon, 16 Oct 2017 13:26:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e49AE-0003h9-Jx for qemu-devel@nongnu.org; Mon, 16 Oct 2017 13:26:58 -0400 Received: from mail-pf0-x229.google.com ([2607:f8b0:400e:c00::229]:49549) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e49AE-0003gm-E1 for qemu-devel@nongnu.org; Mon, 16 Oct 2017 13:26:54 -0400 Received: by mail-pf0-x229.google.com with SMTP id i5so3202092pfe.6 for ; Mon, 16 Oct 2017 10:26:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=RAagLYFqCSetGLwSSInErglxie5S43P08bbjsB82qWY=; b=EoeWklp95HqvNRQ0FZmSn5SXvU7JOQmFsNZtRmLS1pey1zhVmgJOPvSRA0QOo8Wd2t p1duEFtwt6rhIJmS3RSoO6MdDyeizE9s+CX8VcMDR8mwJwJBNw5U9ytkpGlqyv3whTgY OhBnEIjd5S20sBungacXt1EQTZzunXmAc2Gvw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=RAagLYFqCSetGLwSSInErglxie5S43P08bbjsB82qWY=; b=JbLqueFayGcVU5Z0QnAkG3HM7Hyfu1CnHmhXnh/0sXq0zsyJAp/vj+PlHIF+KJ6SCD wtcYi4fYGwRS/I1bCFUgZyOoCKVRmefm8d37N52R+o7Pv05Pxxqmf9Ts6tfQlHLUImMV LrBzYmHtaRaptuDW5kuW76/8c0BM5yrxSRlW/PS7NCCHYb2chCmUklPZVlvsixJnTJL2 EzW6I0TRnmse8E6D1QyxP5JdwK4XMrg77gmtA5ndhYPI6Txrmcx48WCzXeEz9AWd8dTM 7aNvNn82XFE8iNckNsW89HOvtZ0pyY6SEyz+536g/ITG25nYxhv3KAMrR54c2xmAD3N0 simQ== X-Gm-Message-State: AMCzsaVRfuaMgDs1/ar+eIklc/y9mXKOd3oox6fNBRYsWXBgB4mGx3MJ xsQlY0WAeSvfMRKICwfMrvpjJfqKLC0= X-Google-Smtp-Source: AOwi7QCOojsB6nnaKgh5qsKhGSnogyF6mC2wB2Y3dphXaX25x4awgqc3Xqx3KMr2boGt5YiygMzPcQ== X-Received: by 10.98.198.138 with SMTP id x10mr7920705pfk.55.1508174813259; Mon, 16 Oct 2017 10:26:53 -0700 (PDT) Received: from cloudburst.twiddle.net (97-126-104-76.tukw.qwest.net. [97.126.104.76]) by smtp.gmail.com with ESMTPSA id i187sm5594249pfc.96.2017.10.16.10.26.52 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 16 Oct 2017 10:26:52 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Mon, 16 Oct 2017 10:25:47 -0700 Message-Id: <20171016172609.23422-29-richard.henderson@linaro.org> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171016172609.23422-1-richard.henderson@linaro.org> References: <20171016172609.23422-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c00::229 Subject: [Qemu-devel] [PATCH v6 28/50] target/hppa: check CF_PARALLEL instead of parallel_cpus 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: cota@braap.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: "Emilio G. Cota" Thereby decoupling the resulting translated code from the current state of the system. Reviewed-by: Richard Henderson Signed-off-by: Emilio G. Cota --- target/hppa/helper.h | 2 ++ target/hppa/op_helper.c | 32 ++++++++++++++++++++++++++++---- target/hppa/translate.c | 12 ++++++++++-- 3 files changed, 40 insertions(+), 6 deletions(-) -- 2.13.6 diff --git a/target/hppa/helper.h b/target/hppa/helper.h index 789f07fc0a..0a6b900555 100644 --- a/target/hppa/helper.h +++ b/target/hppa/helper.h @@ -3,7 +3,9 @@ DEF_HELPER_FLAGS_2(tsv, TCG_CALL_NO_WG, void, env, tl) DEF_HELPER_FLAGS_2(tcond, TCG_CALL_NO_WG, void, env, tl) DEF_HELPER_FLAGS_3(stby_b, TCG_CALL_NO_WG, void, env, tl, tl) +DEF_HELPER_FLAGS_3(stby_b_parallel, TCG_CALL_NO_WG, void, env, tl, tl) DEF_HELPER_FLAGS_3(stby_e, TCG_CALL_NO_WG, void, env, tl, tl) +DEF_HELPER_FLAGS_3(stby_e_parallel, TCG_CALL_NO_WG, void, env, tl, tl) DEF_HELPER_FLAGS_1(probe_r, TCG_CALL_NO_RWG_SE, tl, tl) DEF_HELPER_FLAGS_1(probe_w, TCG_CALL_NO_RWG_SE, tl, tl) diff --git a/target/hppa/op_helper.c b/target/hppa/op_helper.c index c05c0d5572..3104404e8d 100644 --- a/target/hppa/op_helper.c +++ b/target/hppa/op_helper.c @@ -76,7 +76,8 @@ static void atomic_store_3(CPUHPPAState *env, target_ulong addr, uint32_t val, #endif } -void HELPER(stby_b)(CPUHPPAState *env, target_ulong addr, target_ulong val) +static void do_stby_b(CPUHPPAState *env, target_ulong addr, target_ulong val, + bool parallel) { uintptr_t ra = GETPC(); @@ -89,7 +90,7 @@ void HELPER(stby_b)(CPUHPPAState *env, target_ulong addr, target_ulong val) break; case 1: /* The 3 byte store must appear atomic. */ - if (parallel_cpus) { + if (parallel) { atomic_store_3(env, addr, val, 0x00ffffffu, ra); } else { cpu_stb_data_ra(env, addr, val >> 16, ra); @@ -102,14 +103,26 @@ void HELPER(stby_b)(CPUHPPAState *env, target_ulong addr, target_ulong val) } } -void HELPER(stby_e)(CPUHPPAState *env, target_ulong addr, target_ulong val) +void HELPER(stby_b)(CPUHPPAState *env, target_ulong addr, target_ulong val) +{ + do_stby_b(env, addr, val, false); +} + +void HELPER(stby_b_parallel)(CPUHPPAState *env, target_ulong addr, + target_ulong val) +{ + do_stby_b(env, addr, val, true); +} + +static void do_stby_e(CPUHPPAState *env, target_ulong addr, target_ulong val, + bool parallel) { uintptr_t ra = GETPC(); switch (addr & 3) { case 3: /* The 3 byte store must appear atomic. */ - if (parallel_cpus) { + if (parallel) { atomic_store_3(env, addr - 3, val, 0xffffff00u, ra); } else { cpu_stw_data_ra(env, addr - 3, val >> 16, ra); @@ -132,6 +145,17 @@ void HELPER(stby_e)(CPUHPPAState *env, target_ulong addr, target_ulong val) } } +void HELPER(stby_e)(CPUHPPAState *env, target_ulong addr, target_ulong val) +{ + do_stby_e(env, addr, val, false); +} + +void HELPER(stby_e_parallel)(CPUHPPAState *env, target_ulong addr, + target_ulong val) +{ + do_stby_e(env, addr, val, true); +} + target_ulong HELPER(probe_r)(target_ulong addr) { return page_check_range(addr, 1, PAGE_READ); diff --git a/target/hppa/translate.c b/target/hppa/translate.c index 460b4d3154..08b2c73291 100644 --- a/target/hppa/translate.c +++ b/target/hppa/translate.c @@ -2291,9 +2291,17 @@ static DisasJumpType trans_stby(DisasContext *ctx, uint32_t insn, val = load_gpr(ctx, rt); if (a) { - gen_helper_stby_e(cpu_env, addr, val); + if (tb_cflags(ctx->base.tb) & CF_PARALLEL) { + gen_helper_stby_e_parallel(cpu_env, addr, val); + } else { + gen_helper_stby_e(cpu_env, addr, val); + } } else { - gen_helper_stby_b(cpu_env, addr, val); + if (tb_cflags(ctx->base.tb) & CF_PARALLEL) { + gen_helper_stby_b_parallel(cpu_env, addr, val); + } else { + gen_helper_stby_b(cpu_env, addr, val); + } } if (m) { From patchwork Mon Oct 16 17:25:48 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 115958 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp3953193qgn; Mon, 16 Oct 2017 10:48:59 -0700 (PDT) X-Received: by 10.55.113.70 with SMTP id m67mr1537108qkc.23.1508176139035; Mon, 16 Oct 2017 10:48:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508176139; cv=none; d=google.com; s=arc-20160816; b=NhocW0brdLlwuI/f8VF6lWbiPv0Eppzg7zwQC+EjH3+wCkEbm/JoY046AMa9xmZPlz agEsgjLnuZW7TFOhvuAqWCF4vf6Cspde30AiMBbq461QxTqEQ3SV6UgSDi7D5N5kpFhA /EV2NY/qfv/m+l222czl2/h5Lc7GHihz+9JOqrl7hBsumt/IJPXj5sy7WckVmA5ygbYL G1VurMdkPDYtyBiELc6vmUKGAoLX8lIARKbA9o0yqB1kghlKTwQUVGHAHhd74xM5klUf vijghm0KKe8IhhZP5oRPrsFCLgvq3BQMqTKQB1ruIVC3Pf5EntJxQxZXhNxxQQb/YpgF 2ZWA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=fqWJKypEERna3DL8OZNR6W8KwfaZwhXECLG28bhJ+UM=; b=UEiFALd0wmdBf7pmDL8IAl6dTUYvqttguLs9Y7iZ9jCguTLeMooSUbE0M38s3RTq+N yYU7e+ZqwQ279iqPs+2DqraOXqP+H9PjYqO5xbo5SBAtLqzDr6OODQk7YQo5v6a0shwk XHJwB4SQMbuhkTVo2onO72ohu3cYH/z+Z+p4quHjSBqY00zOJWKZ5FfRPbpjDq/6d6zv 8Zz++uirks3pXgOOL24Ddw/1NB3SVXZ+qPwbId7YXbU1cTb7H2L3Xkufv/cfs9f3mO9v HCLHchxu0nUvPmMjObbjXLw1q4bsXCJ7J3LIsX8J0CeDVW7v9bRQnt63YV3Hka3F+IzY /kIg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=E/0o1Ngy; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id 11si185114qkn.237.2017.10.16.10.48.58 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 16 Oct 2017 10:48:59 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=E/0o1Ngy; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:34384 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e49VY-00041T-Vb for patch@linaro.org; Mon, 16 Oct 2017 13:48:57 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52496) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e49AG-0002WF-OZ for qemu-devel@nongnu.org; Mon, 16 Oct 2017 13:26:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e49AF-0003hq-OM for qemu-devel@nongnu.org; Mon, 16 Oct 2017 13:26:56 -0400 Received: from mail-pg0-x22b.google.com ([2607:f8b0:400e:c05::22b]:54130) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e49AF-0003hR-Ic for qemu-devel@nongnu.org; Mon, 16 Oct 2017 13:26:55 -0400 Received: by mail-pg0-x22b.google.com with SMTP id s2so7347008pge.10 for ; Mon, 16 Oct 2017 10:26:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=fqWJKypEERna3DL8OZNR6W8KwfaZwhXECLG28bhJ+UM=; b=E/0o1Ngy+HLRwWAOtYNs3QJkHMsdixhOFQvlcMw+BKY52rAfeTg5NRyhe2S5t/MpbS yKBDTy2FjKnAKv6OKL3CbBbTKmVZwAdvCdXiJUhzhmXcpZCEg7ffT0JEectl+8VJAXop DEZ5oPUbNTA5raXvOjoEOnUmuFqZUAMz8SgvA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=fqWJKypEERna3DL8OZNR6W8KwfaZwhXECLG28bhJ+UM=; b=QqNi+BQpXkwiAaPSy31aM0Vl7feTU9jYf00YdYmTSafwTLkybJtFZugZEq3QU79ndD FXCpJura8wq9GVSYlY6BQKcTQDTKIrd4ZyUXTYwOqxnKwkw5P0punbUee2X7bSuJ7qT2 bJXDreO9O++wB1RD/yixBOOF1iBfw7Ne4iAwUiuAf9CZxiDGRuKGkelM0sH9iNleE/N+ DObaBsA7l+aDWVvb+W7DcwZhYULpU7RqmvTcQ5hVGW/SNDRIrN/HBPWeZ+wHiVTOv+Gc h053uWQReBrBJD4GMzM4qKdjSkfqOPiXz08DGYotkfXPTBoZQnbX35rW96oDgwNMB7zt Q/5Q== X-Gm-Message-State: AMCzsaWYBRUZ8xU9XKLWHPGy8Naol7x2bEeGt49QdC1VwVHNr+IXCQlE v8Em89klqqRgUiLjFp3S6GwQHIr/EsA= X-Google-Smtp-Source: AOwi7QBYkSqCqytaGyVIeD2Lugrqs7cTpIcLU372eMHXVKb+jMuC+eyUT3sS5zlxrdZB7NLsXtEfHw== X-Received: by 10.98.35.18 with SMTP id j18mr9436391pfj.37.1508174814448; Mon, 16 Oct 2017 10:26:54 -0700 (PDT) Received: from cloudburst.twiddle.net (97-126-104-76.tukw.qwest.net. [97.126.104.76]) by smtp.gmail.com with ESMTPSA id i187sm5594249pfc.96.2017.10.16.10.26.53 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 16 Oct 2017 10:26:53 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Mon, 16 Oct 2017 10:25:48 -0700 Message-Id: <20171016172609.23422-30-richard.henderson@linaro.org> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171016172609.23422-1-richard.henderson@linaro.org> References: <20171016172609.23422-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c05::22b Subject: [Qemu-devel] [PATCH v6 29/50] target/i386: check CF_PARALLEL instead of parallel_cpus 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: cota@braap.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: "Emilio G. Cota" Thereby decoupling the resulting translated code from the current state of the system. Reviewed-by: Richard Henderson Signed-off-by: Emilio G. Cota --- target/i386/translate.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) -- 2.13.6 diff --git a/target/i386/translate.c b/target/i386/translate.c index f60582082e..6663cd1db8 100644 --- a/target/i386/translate.c +++ b/target/i386/translate.c @@ -5265,7 +5265,7 @@ static target_ulong disas_insn(DisasContext *s, CPUState *cpu) if (!(s->cpuid_ext_features & CPUID_EXT_CX16)) goto illegal_op; gen_lea_modrm(env, s, modrm); - if ((s->prefix & PREFIX_LOCK) && parallel_cpus) { + if ((s->prefix & PREFIX_LOCK) && (tb_cflags(s->base.tb) & CF_PARALLEL)) { gen_helper_cmpxchg16b(cpu_env, cpu_A0); } else { gen_helper_cmpxchg16b_unlocked(cpu_env, cpu_A0); @@ -5276,7 +5276,7 @@ static target_ulong disas_insn(DisasContext *s, CPUState *cpu) if (!(s->cpuid_features & CPUID_CX8)) goto illegal_op; gen_lea_modrm(env, s, modrm); - if ((s->prefix & PREFIX_LOCK) && parallel_cpus) { + if ((s->prefix & PREFIX_LOCK) && (tb_cflags(s->base.tb) & CF_PARALLEL)) { gen_helper_cmpxchg8b(cpu_env, cpu_A0); } else { gen_helper_cmpxchg8b_unlocked(cpu_env, cpu_A0); From patchwork Mon Oct 16 17:25:49 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 115947 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp3946094qgn; Mon, 16 Oct 2017 10:40:35 -0700 (PDT) X-Received: by 10.200.1.136 with SMTP id x8mr16250380qtf.259.1508175635382; Mon, 16 Oct 2017 10:40:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508175635; cv=none; d=google.com; s=arc-20160816; b=pgYmMepb9z/O3Dk7r/I/BiaOE/tr14wpOenuPUwHZFQFRdUiylv03Kh8579wp2381p OHf4QcFW6APsi6Bn7OXoMPqh/cjMS814/3cNAiM4Br0d4UmK3EOcniBmsYXSkjW2tSIG w/T1Y65oYNx5GO3I6yiHLIBQ1O8ipqAsZJsbpkAqtN0wOdiliRT72MV2P5+VqaUp+uqo mZdRpFn3RYrnQMYJa4vPUpaLyb5of8UWvSW6cgeZby6RmC6xInPetD77G+lFm99G34bs 0NDd5XDuVAjTofDGd9ddaa+76miesCFrEuXp5pEQTvGOIsgzSHLBt/kFBO7Q1BI3Lu5C aWMg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=xFDqbXK1UuvZhOApzTuLKyN0ZQDx68yPe+6wHJld0dI=; b=GGLKS+0n944FDR5zgFiM7qNMynsxtvaIsM/LJzVGBxWd1scHrip5HAirsMrPbI/1Gh FtLcRsFl658MuRsNLLhEzBaF/+pDhVpk2ncKGqUMZYUkLnXNL9Mrr4zyY8PjDVwI00KN sW1iEFer82ivP7OvUYu6VRrjm9h/k1pXMGC7ffN/nqebejJPDKJ/Y4G6K6WsTy0/WXLL HVftaBsOXgCy75AHpd/9Y2wziu3jrgwFr8D7MAUcItoBvLVsnbC4tpwDaCTZNtDFwscM Vjzxu1pFhI2qswQNu2ZKQEMklWwzD51r4IsMLPY/8zFux0qRxrzNquV3G3sOpz88ZJey mC7g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=keYDoO/P; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id e3si6398795qtc.337.2017.10.16.10.40.34 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 16 Oct 2017 10:40:35 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=keYDoO/P; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:34352 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e49NR-0005Ro-5X for patch@linaro.org; Mon, 16 Oct 2017 13:40:33 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52517) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e49AI-0002Y1-Di for qemu-devel@nongnu.org; Mon, 16 Oct 2017 13:26:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e49AH-0003j8-8N for qemu-devel@nongnu.org; Mon, 16 Oct 2017 13:26:58 -0400 Received: from mail-pg0-x22f.google.com ([2607:f8b0:400e:c05::22f]:55519) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e49AH-0003iT-05 for qemu-devel@nongnu.org; Mon, 16 Oct 2017 13:26:57 -0400 Received: by mail-pg0-x22f.google.com with SMTP id b11so7346201pgn.12 for ; Mon, 16 Oct 2017 10:26:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=xFDqbXK1UuvZhOApzTuLKyN0ZQDx68yPe+6wHJld0dI=; b=keYDoO/P+btU0HrZwDOAiTL3PY3Y5Fz9eDUHp4QJjEoluRIDDvNGJscDnIH6rUdF12 AKXKbKfLZ0IkPCbs38qoWmCh0CxLHgghd16Oooy3oom0JyEApBpIawpcRnE2szwsBSL1 sFFRU8Kt2vEgxqtwjIrAuzKcccM7z3bkeZeGM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=xFDqbXK1UuvZhOApzTuLKyN0ZQDx68yPe+6wHJld0dI=; b=g6dwvtIDCerh16Ax+vnV3FCyZI9UMLXoSyTMwpomoLco531ZVIglNXHa2mQkGKo0nS ma6Cj24y288BsDWFTy/x9/1Gp7lHwSW9HBsxZy3pRmX66HFycFjjDn1WFjomQ3EfQar8 5txuDAkEpClW+RzkYmKMB+HCLvoKRGZkfv4VRIboFxkxIm9zmqMabM11Mqu8N9qHa+6i 6mlFVZ5RKAMxkud7I4uQn322sPEe+1MGddsMCIph5A+lgWaNh2UvtFw7u2ZBqEko6tx2 v8xh3TTKRRSYZEB/FBR5jV276tYJGHioEf2FXxfnuHrgMsLhlspqsFnRlgcRA2Sd7P6B syew== X-Gm-Message-State: AMCzsaWKhZM5glw5NZnYSc2ELRKuclpXb2eUry5cLeL/u8sCTQir4NQ/ F+Fp0yDyZylXmkKMJoTtHeGQBXSlebk= X-Google-Smtp-Source: AOwi7QBl+eyl46dOoiFPMIzYtYRfXutA5nvHmFiKIeW3qKVoGWVUsz/EIeoT5mFeTRpm8JamcNzeog== X-Received: by 10.84.231.2 with SMTP id f2mr9353698plk.256.1508174815836; Mon, 16 Oct 2017 10:26:55 -0700 (PDT) Received: from cloudburst.twiddle.net (97-126-104-76.tukw.qwest.net. [97.126.104.76]) by smtp.gmail.com with ESMTPSA id i187sm5594249pfc.96.2017.10.16.10.26.54 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 16 Oct 2017 10:26:55 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Mon, 16 Oct 2017 10:25:49 -0700 Message-Id: <20171016172609.23422-31-richard.henderson@linaro.org> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171016172609.23422-1-richard.henderson@linaro.org> References: <20171016172609.23422-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c05::22f Subject: [Qemu-devel] [PATCH v6 30/50] target/m68k: check CF_PARALLEL instead of parallel_cpus 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: cota@braap.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: "Emilio G. Cota" Thereby decoupling the resulting translated code from the current state of the system. Reviewed-by: Richard Henderson Signed-off-by: Emilio G. Cota --- target/m68k/helper.h | 1 + target/m68k/op_helper.c | 33 ++++++++++++++++++++------------- target/m68k/translate.c | 12 ++++++++++-- 3 files changed, 31 insertions(+), 15 deletions(-) -- 2.13.6 diff --git a/target/m68k/helper.h b/target/m68k/helper.h index 475a1f2186..eebe52dae5 100644 --- a/target/m68k/helper.h +++ b/target/m68k/helper.h @@ -11,6 +11,7 @@ DEF_HELPER_2(set_sr, void, env, i32) DEF_HELPER_3(movec, void, env, i32, i32) DEF_HELPER_4(cas2w, void, env, i32, i32, i32) DEF_HELPER_4(cas2l, void, env, i32, i32, i32) +DEF_HELPER_4(cas2l_parallel, void, env, i32, i32, i32) #define dh_alias_fp ptr #define dh_ctype_fp FPReg * diff --git a/target/m68k/op_helper.c b/target/m68k/op_helper.c index 7b5126c88d..63089511cb 100644 --- a/target/m68k/op_helper.c +++ b/target/m68k/op_helper.c @@ -361,6 +361,7 @@ void HELPER(divsll)(CPUM68KState *env, int numr, int regr, int32_t den) env->dregs[numr] = quot; } +/* We're executing in a serial context -- no need to be atomic. */ void HELPER(cas2w)(CPUM68KState *env, uint32_t regs, uint32_t a1, uint32_t a2) { uint32_t Dc1 = extract32(regs, 9, 3); @@ -374,17 +375,11 @@ void HELPER(cas2w)(CPUM68KState *env, uint32_t regs, uint32_t a1, uint32_t a2) int16_t l1, l2; uintptr_t ra = GETPC(); - if (parallel_cpus) { - /* Tell the main loop we need to serialize this insn. */ - cpu_loop_exit_atomic(ENV_GET_CPU(env), ra); - } else { - /* We're executing in a serial context -- no need to be atomic. */ - l1 = cpu_lduw_data_ra(env, a1, ra); - l2 = cpu_lduw_data_ra(env, a2, ra); - if (l1 == c1 && l2 == c2) { - cpu_stw_data_ra(env, a1, u1, ra); - cpu_stw_data_ra(env, a2, u2, ra); - } + l1 = cpu_lduw_data_ra(env, a1, ra); + l2 = cpu_lduw_data_ra(env, a2, ra); + if (l1 == c1 && l2 == c2) { + cpu_stw_data_ra(env, a1, u1, ra); + cpu_stw_data_ra(env, a2, u2, ra); } if (c1 != l1) { @@ -399,7 +394,8 @@ void HELPER(cas2w)(CPUM68KState *env, uint32_t regs, uint32_t a1, uint32_t a2) env->dregs[Dc2] = deposit32(env->dregs[Dc2], 0, 16, l2); } -void HELPER(cas2l)(CPUM68KState *env, uint32_t regs, uint32_t a1, uint32_t a2) +static void do_cas2l(CPUM68KState *env, uint32_t regs, uint32_t a1, uint32_t a2, + bool parallel) { uint32_t Dc1 = extract32(regs, 9, 3); uint32_t Dc2 = extract32(regs, 6, 3); @@ -416,7 +412,7 @@ void HELPER(cas2l)(CPUM68KState *env, uint32_t regs, uint32_t a1, uint32_t a2) TCGMemOpIdx oi; #endif - if (parallel_cpus) { + if (parallel) { /* We're executing in a parallel context -- must be atomic. */ #ifdef CONFIG_ATOMIC64 uint64_t c, u, l; @@ -470,6 +466,17 @@ void HELPER(cas2l)(CPUM68KState *env, uint32_t regs, uint32_t a1, uint32_t a2) env->dregs[Dc2] = l2; } +void HELPER(cas2l)(CPUM68KState *env, uint32_t regs, uint32_t a1, uint32_t a2) +{ + do_cas2l(env, regs, a1, a2, false); +} + +void HELPER(cas2l_parallel)(CPUM68KState *env, uint32_t regs, uint32_t a1, + uint32_t a2) +{ + do_cas2l(env, regs, a1, a2, true); +} + struct bf_data { uint32_t addr; uint32_t bofs; diff --git a/target/m68k/translate.c b/target/m68k/translate.c index d199105559..3506864030 100644 --- a/target/m68k/translate.c +++ b/target/m68k/translate.c @@ -2312,7 +2312,11 @@ DISAS_INSN(cas2w) (REG(ext1, 6) << 3) | (REG(ext2, 0) << 6) | (REG(ext1, 0) << 9)); - gen_helper_cas2w(cpu_env, regs, addr1, addr2); + if (tb_cflags(s->tb) & CF_PARALLEL) { + gen_helper_exit_atomic(cpu_env); + } else { + gen_helper_cas2w(cpu_env, regs, addr1, addr2); + } tcg_temp_free(regs); /* Note that cas2w also assigned to env->cc_op. */ @@ -2358,7 +2362,11 @@ DISAS_INSN(cas2l) (REG(ext1, 6) << 3) | (REG(ext2, 0) << 6) | (REG(ext1, 0) << 9)); - gen_helper_cas2l(cpu_env, regs, addr1, addr2); + if (tb_cflags(s->tb) & CF_PARALLEL) { + gen_helper_cas2l_parallel(cpu_env, regs, addr1, addr2); + } else { + gen_helper_cas2l(cpu_env, regs, addr1, addr2); + } tcg_temp_free(regs); /* Note that cas2l also assigned to env->cc_op. */ From patchwork Mon Oct 16 17:25:50 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 115968 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp3958889qgn; Mon, 16 Oct 2017 10:56:05 -0700 (PDT) X-Received: by 10.55.31.163 with SMTP id n35mr15348886qkh.279.1508176565739; Mon, 16 Oct 2017 10:56:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508176565; cv=none; d=google.com; s=arc-20160816; b=KYfTKitiuZipZIGU2OcsEcUIsNFEVqAABBB3AZxWTYHaq5SeJBKe+bX5ZnJ5BvCk7M Zg9SDpfDHwuWXjqOhJGd8ZRevZxsdhB50nqLtvlMdZqa2fN0/akPuR3Mxhso4KtqaHKk rp/lfSHfb2c+JndQUUHWJZUt5CE+W8JBvPSap+S8NIOCd1o2eqXitHJFboA5IZJIZGK/ b6XuVbu+9/TNaPd5dAk+CDr9e99yHydAvPaRlEMyvBah0NLFdWXdfFxzWTVrIQkz0dUw v/qQdbZnnB/Pp00q4ji0Zn4FEfrO4uZnuk7OGXoXljy66vVwClu+1crrmQbfW5F9L6qB t0CQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=p5KcfTV/19rdduEHLMjjQjn3skOs1jiMQVA1+BKU01Q=; b=yIELjmmU/i5s0MmVzcdjhAgc6TjfNW7ETmhh6GXGDGS8eJJf/1tAiIbovBxkglrIJx ByVkjnJ5sG2TxTrg2B2Yx7sJAl1TE29VpP6J4McSgbpA9hANnTeno3L79T2KPw0A09vU caqLedLOmXrGCLSMXEoyMRZPlIlkeNUT1eZQ1oimCFK45lSnv1kogSVJ6deTDoRAmmWp PSU1luSNl/9wb+21l8KeEBB7QLEoKzNwH2xqXgPmR6jjdb6oHlsDhnKL/FOpSL0YLXu1 DMXbozX+n5Mr5nBha97c0Wp3dk2jadcVubLXc4DBxnS8bCvBOA8thZcXvKld4nVAI1nU pNuQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=YAxqSKnZ; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id w49si2618486qtw.419.2017.10.16.10.56.05 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 16 Oct 2017 10:56:05 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=YAxqSKnZ; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:34418 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e49cR-0001js-JR for patch@linaro.org; Mon, 16 Oct 2017 13:56:03 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52538) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e49AK-0002a2-A9 for qemu-devel@nongnu.org; Mon, 16 Oct 2017 13:27:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e49AI-0003kl-P4 for qemu-devel@nongnu.org; Mon, 16 Oct 2017 13:27:00 -0400 Received: from mail-pf0-x235.google.com ([2607:f8b0:400e:c00::235]:44288) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e49AI-0003jn-FG for qemu-devel@nongnu.org; Mon, 16 Oct 2017 13:26:58 -0400 Received: by mail-pf0-x235.google.com with SMTP id x7so16317786pfa.1 for ; Mon, 16 Oct 2017 10:26:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=p5KcfTV/19rdduEHLMjjQjn3skOs1jiMQVA1+BKU01Q=; b=YAxqSKnZKtJcg8IycZu0whBXF8fja6AnYcVvvIScJDe51EkGX1HOIb2RElj/ituGKD w4pOMb1pjrgJrqDjrag3Sr9nXRPNtVcu19QFET9Os3R20G7dhQ5HvnbYpizU0KhcUvBb PDs7B7+exaKkBnkN9zOB0OS84sTC2+dKQLKAA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=p5KcfTV/19rdduEHLMjjQjn3skOs1jiMQVA1+BKU01Q=; b=CufbnRYLDRVPEWQAS6HiIZF1HOPMcC4LC2Jgys0a7+NiM4l2cVoIRazuopuVeE48gb BVxag589AEFotclcc6hHDZ8g2oSkz7S6tEr0CwlPo5hWnGQmEh3gfYMUVvVTowCP+Xvf sBCx41nYkKh9p5DgJMniFcr3Meww/Zizst1bYpX0NKFr+/CP0K2hfxE53xjgBzb8J8i8 rk4/XKPMPP9hz3QhKBJZbWstsBDYzpVNEQyi2THucW5m++XiK9Clk+NrTy7g6dgI/R3Z amAaMQ/K0fIZGVC3Zy30XZhEslzsqDnCMgWdRxbvVLw4E+vOMCYMtIUiqm44UI5n2yWR yECg== X-Gm-Message-State: AMCzsaUlEtRJcrUw69bh07tEF6xE7xG6Du2J4TwAAiTRNOpLsX2N7B8n JT3cQiMmpqpgJwi0WgrAsE2UKKtImLk= X-Google-Smtp-Source: ABhQp+Q+iMu43/4egXfmwEFtFX86pre7s1fYcH4koOTcr+DpfFtgGe7EwOse7mDVinu6xLjraVKQGA== X-Received: by 10.84.202.194 with SMTP id q2mr1680737plh.19.1508174817221; Mon, 16 Oct 2017 10:26:57 -0700 (PDT) Received: from cloudburst.twiddle.net (97-126-104-76.tukw.qwest.net. [97.126.104.76]) by smtp.gmail.com with ESMTPSA id i187sm5594249pfc.96.2017.10.16.10.26.55 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 16 Oct 2017 10:26:56 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Mon, 16 Oct 2017 10:25:50 -0700 Message-Id: <20171016172609.23422-32-richard.henderson@linaro.org> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171016172609.23422-1-richard.henderson@linaro.org> References: <20171016172609.23422-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c00::235 Subject: [Qemu-devel] [PATCH v6 31/50] target/s390x: check CF_PARALLEL instead of parallel_cpus 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: cota@braap.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: "Emilio G. Cota" Thereby decoupling the resulting translated code from the current state of the system. Reviewed-by: Richard Henderson Signed-off-by: Emilio G. Cota --- target/s390x/helper.h | 4 +++ target/s390x/mem_helper.c | 80 +++++++++++++++++++++++++++++++++++++---------- target/s390x/translate.c | 26 ++++++++++++--- 3 files changed, 88 insertions(+), 22 deletions(-) -- 2.13.6 diff --git a/target/s390x/helper.h b/target/s390x/helper.h index 52c2963baa..d0da36c988 100644 --- a/target/s390x/helper.h +++ b/target/s390x/helper.h @@ -34,7 +34,9 @@ DEF_HELPER_3(celgb, i64, env, i64, i32) DEF_HELPER_3(cdlgb, i64, env, i64, i32) DEF_HELPER_3(cxlgb, i64, env, i64, i32) DEF_HELPER_4(cdsg, void, env, i64, i32, i32) +DEF_HELPER_4(cdsg_parallel, void, env, i64, i32, i32) DEF_HELPER_4(csst, i32, env, i32, i64, i64) +DEF_HELPER_4(csst_parallel, i32, env, i32, i64, i64) DEF_HELPER_FLAGS_3(aeb, TCG_CALL_NO_WG, i64, env, i64, i64) DEF_HELPER_FLAGS_3(adb, TCG_CALL_NO_WG, i64, env, i64, i64) DEF_HELPER_FLAGS_5(axb, TCG_CALL_NO_WG, i64, env, i64, i64, i64, i64) @@ -106,7 +108,9 @@ DEF_HELPER_FLAGS_2(sfas, TCG_CALL_NO_WG, void, env, i64) DEF_HELPER_FLAGS_1(popcnt, TCG_CALL_NO_RWG_SE, i64, i64) DEF_HELPER_2(stfle, i32, env, i64) DEF_HELPER_FLAGS_2(lpq, TCG_CALL_NO_WG, i64, env, i64) +DEF_HELPER_FLAGS_2(lpq_parallel, TCG_CALL_NO_WG, i64, env, i64) DEF_HELPER_FLAGS_4(stpq, TCG_CALL_NO_WG, void, env, i64, i64, i64) +DEF_HELPER_FLAGS_4(stpq_parallel, TCG_CALL_NO_WG, void, env, i64, i64, i64) DEF_HELPER_4(mvcos, i32, env, i64, i64, i64) DEF_HELPER_4(cu12, i32, env, i32, i32, i32) DEF_HELPER_4(cu14, i32, env, i32, i32, i32) diff --git a/target/s390x/mem_helper.c b/target/s390x/mem_helper.c index bbbe1c62b3..6055f3915c 100644 --- a/target/s390x/mem_helper.c +++ b/target/s390x/mem_helper.c @@ -1361,8 +1361,8 @@ uint32_t HELPER(trXX)(CPUS390XState *env, uint32_t r1, uint32_t r2, return cc; } -void HELPER(cdsg)(CPUS390XState *env, uint64_t addr, - uint32_t r1, uint32_t r3) +static void do_cdsg(CPUS390XState *env, uint64_t addr, + uint32_t r1, uint32_t r3, bool parallel) { uintptr_t ra = GETPC(); Int128 cmpv = int128_make128(env->regs[r1 + 1], env->regs[r1]); @@ -1370,7 +1370,7 @@ void HELPER(cdsg)(CPUS390XState *env, uint64_t addr, Int128 oldv; bool fail; - if (parallel_cpus) { + if (parallel) { #ifndef CONFIG_ATOMIC128 cpu_loop_exit_atomic(ENV_GET_CPU(env), ra); #else @@ -1402,7 +1402,20 @@ void HELPER(cdsg)(CPUS390XState *env, uint64_t addr, env->regs[r1 + 1] = int128_getlo(oldv); } -uint32_t HELPER(csst)(CPUS390XState *env, uint32_t r3, uint64_t a1, uint64_t a2) +void HELPER(cdsg)(CPUS390XState *env, uint64_t addr, + uint32_t r1, uint32_t r3) +{ + do_cdsg(env, addr, r1, r3, false); +} + +void HELPER(cdsg_parallel)(CPUS390XState *env, uint64_t addr, + uint32_t r1, uint32_t r3) +{ + do_cdsg(env, addr, r1, r3, true); +} + +static uint32_t do_csst(CPUS390XState *env, uint32_t r3, uint64_t a1, + uint64_t a2, bool parallel) { #if !defined(CONFIG_USER_ONLY) || defined(CONFIG_ATOMIC128) uint32_t mem_idx = cpu_mmu_index(env, false); @@ -1438,7 +1451,7 @@ uint32_t HELPER(csst)(CPUS390XState *env, uint32_t r3, uint64_t a1, uint64_t a2) the complete operation is not. Therefore we do not need to assert serial context in order to implement this. That said, restart early if we can't support either operation that is supposed to be atomic. */ - if (parallel_cpus) { + if (parallel) { int mask = 0; #if !defined(CONFIG_ATOMIC64) mask = -8; @@ -1462,7 +1475,7 @@ uint32_t HELPER(csst)(CPUS390XState *env, uint32_t r3, uint64_t a1, uint64_t a2) uint32_t cv = env->regs[r3]; uint32_t ov; - if (parallel_cpus) { + if (parallel) { #ifdef CONFIG_USER_ONLY uint32_t *haddr = g2h(a1); ov = atomic_cmpxchg__nocheck(haddr, cv, nv); @@ -1485,7 +1498,7 @@ uint32_t HELPER(csst)(CPUS390XState *env, uint32_t r3, uint64_t a1, uint64_t a2) uint64_t cv = env->regs[r3]; uint64_t ov; - if (parallel_cpus) { + if (parallel) { #ifdef CONFIG_ATOMIC64 # ifdef CONFIG_USER_ONLY uint64_t *haddr = g2h(a1); @@ -1495,7 +1508,7 @@ uint32_t HELPER(csst)(CPUS390XState *env, uint32_t r3, uint64_t a1, uint64_t a2) ov = helper_atomic_cmpxchgq_be_mmu(env, a1, cv, nv, oi, ra); # endif #else - /* Note that we asserted !parallel_cpus above. */ + /* Note that we asserted !parallel above. */ g_assert_not_reached(); #endif } else { @@ -1515,13 +1528,13 @@ uint32_t HELPER(csst)(CPUS390XState *env, uint32_t r3, uint64_t a1, uint64_t a2) Int128 cv = int128_make128(env->regs[r3 + 1], env->regs[r3]); Int128 ov; - if (parallel_cpus) { + if (parallel) { #ifdef CONFIG_ATOMIC128 TCGMemOpIdx oi = make_memop_idx(MO_TEQ | MO_ALIGN_16, mem_idx); ov = helper_atomic_cmpxchgo_be_mmu(env, a1, cv, nv, oi, ra); cc = !int128_eq(ov, cv); #else - /* Note that we asserted !parallel_cpus above. */ + /* Note that we asserted !parallel above. */ g_assert_not_reached(); #endif } else { @@ -1565,13 +1578,13 @@ uint32_t HELPER(csst)(CPUS390XState *env, uint32_t r3, uint64_t a1, uint64_t a2) cpu_stq_data_ra(env, a2, svh, ra); break; case 4: - if (parallel_cpus) { + if (parallel) { #ifdef CONFIG_ATOMIC128 TCGMemOpIdx oi = make_memop_idx(MO_TEQ | MO_ALIGN_16, mem_idx); Int128 sv = int128_make128(svl, svh); helper_atomic_sto_be_mmu(env, a2, sv, oi, ra); #else - /* Note that we asserted !parallel_cpus above. */ + /* Note that we asserted !parallel above. */ g_assert_not_reached(); #endif } else { @@ -1592,6 +1605,17 @@ uint32_t HELPER(csst)(CPUS390XState *env, uint32_t r3, uint64_t a1, uint64_t a2) g_assert_not_reached(); } +uint32_t HELPER(csst)(CPUS390XState *env, uint32_t r3, uint64_t a1, uint64_t a2) +{ + return do_csst(env, r3, a1, a2, false); +} + +uint32_t HELPER(csst_parallel)(CPUS390XState *env, uint32_t r3, uint64_t a1, + uint64_t a2) +{ + return do_csst(env, r3, a1, a2, true); +} + #if !defined(CONFIG_USER_ONLY) void HELPER(lctlg)(CPUS390XState *env, uint32_t r1, uint64_t a2, uint32_t r3) { @@ -2019,12 +2043,12 @@ uint64_t HELPER(lra)(CPUS390XState *env, uint64_t addr) #endif /* load pair from quadword */ -uint64_t HELPER(lpq)(CPUS390XState *env, uint64_t addr) +static uint64_t do_lpq(CPUS390XState *env, uint64_t addr, bool parallel) { uintptr_t ra = GETPC(); uint64_t hi, lo; - if (parallel_cpus) { + if (parallel) { #ifndef CONFIG_ATOMIC128 cpu_loop_exit_atomic(ENV_GET_CPU(env), ra); #else @@ -2045,13 +2069,23 @@ uint64_t HELPER(lpq)(CPUS390XState *env, uint64_t addr) return hi; } +uint64_t HELPER(lpq)(CPUS390XState *env, uint64_t addr) +{ + return do_lpq(env, addr, false); +} + +uint64_t HELPER(lpq_parallel)(CPUS390XState *env, uint64_t addr) +{ + return do_lpq(env, addr, true); +} + /* store pair to quadword */ -void HELPER(stpq)(CPUS390XState *env, uint64_t addr, - uint64_t low, uint64_t high) +static void do_stpq(CPUS390XState *env, uint64_t addr, + uint64_t low, uint64_t high, bool parallel) { uintptr_t ra = GETPC(); - if (parallel_cpus) { + if (parallel) { #ifndef CONFIG_ATOMIC128 cpu_loop_exit_atomic(ENV_GET_CPU(env), ra); #else @@ -2069,6 +2103,18 @@ void HELPER(stpq)(CPUS390XState *env, uint64_t addr, } } +void HELPER(stpq)(CPUS390XState *env, uint64_t addr, + uint64_t low, uint64_t high) +{ + do_stpq(env, addr, low, high, false); +} + +void HELPER(stpq_parallel)(CPUS390XState *env, uint64_t addr, + uint64_t low, uint64_t high) +{ + do_stpq(env, addr, low, high, true); +} + /* Execute instruction. This instruction executes an insn modified with the contents of r1. It does not change the executed instruction in memory; it does not change the program counter. diff --git a/target/s390x/translate.c b/target/s390x/translate.c index b950b16d9b..399aeb2800 100644 --- a/target/s390x/translate.c +++ b/target/s390x/translate.c @@ -1966,7 +1966,11 @@ static ExitStatus op_cdsg(DisasContext *s, DisasOps *o) addr = get_address(s, 0, b2, d2); t_r1 = tcg_const_i32(r1); t_r3 = tcg_const_i32(r3); - gen_helper_cdsg(cpu_env, addr, t_r1, t_r3); + if (tb_cflags(s->tb) & CF_PARALLEL) { + gen_helper_cdsg_parallel(cpu_env, addr, t_r1, t_r3); + } else { + gen_helper_cdsg(cpu_env, addr, t_r1, t_r3); + } tcg_temp_free_i64(addr); tcg_temp_free_i32(t_r1); tcg_temp_free_i32(t_r3); @@ -1980,7 +1984,11 @@ static ExitStatus op_csst(DisasContext *s, DisasOps *o) int r3 = get_field(s->fields, r3); TCGv_i32 t_r3 = tcg_const_i32(r3); - gen_helper_csst(cc_op, cpu_env, t_r3, o->in1, o->in2); + if (tb_cflags(s->tb) & CF_PARALLEL) { + gen_helper_csst_parallel(cc_op, cpu_env, t_r3, o->in1, o->in2); + } else { + gen_helper_csst(cc_op, cpu_env, t_r3, o->in1, o->in2); + } tcg_temp_free_i32(t_r3); set_cc_static(s); @@ -2937,7 +2945,7 @@ static ExitStatus op_lpd(DisasContext *s, DisasOps *o) TCGMemOp mop = s->insn->data; /* In a parallel context, stop the world and single step. */ - if (parallel_cpus) { + if (tb_cflags(s->tb) & CF_PARALLEL) { potential_page_fault(s); gen_exception(EXCP_ATOMIC); return EXIT_NORETURN; @@ -2958,7 +2966,11 @@ static ExitStatus op_lpd(DisasContext *s, DisasOps *o) static ExitStatus op_lpq(DisasContext *s, DisasOps *o) { - gen_helper_lpq(o->out, cpu_env, o->in2); + if (tb_cflags(s->tb) & CF_PARALLEL) { + gen_helper_lpq_parallel(o->out, cpu_env, o->in2); + } else { + gen_helper_lpq(o->out, cpu_env, o->in2); + } return_low128(o->out2); return NO_EXIT; } @@ -4279,7 +4291,11 @@ static ExitStatus op_stmh(DisasContext *s, DisasOps *o) static ExitStatus op_stpq(DisasContext *s, DisasOps *o) { - gen_helper_stpq(cpu_env, o->in2, o->out2, o->out); + if (tb_cflags(s->tb) & CF_PARALLEL) { + gen_helper_stpq_parallel(cpu_env, o->in2, o->out2, o->out); + } else { + gen_helper_stpq(cpu_env, o->in2, o->out2, o->out); + } return NO_EXIT; } From patchwork Mon Oct 16 17:25:51 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 115957 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp3952393qgn; Mon, 16 Oct 2017 10:47:58 -0700 (PDT) X-Received: by 10.200.53.200 with SMTP id l8mr16203118qtb.49.1508176077977; Mon, 16 Oct 2017 10:47:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508176077; cv=none; d=google.com; s=arc-20160816; b=GlE4Tx4EPMUTsxAIcVwK8x//zmg7MaLvCQZHcoirMp2u2Hm4Kmmvhz9WOE/wNa02GS nOdUsGaGVTmsAfLzNOKJoncsJmwQgNGCRxIp9kiU3nPpDjBmkZNRboe0ZgbwJ8dV5j94 T5djx07kg3ssNj18DnOOJmF6AmY4Jap8CSxr+NtXtCLEc2usaS7WYG1svGh249VxgJqv s0BQTLV7iyVwZqWyYcolaficXs0T3+OcQvLkuXYzLhL2QcwVnI1YGmjtlgoAX6/TZ5i/ j/3ivL6067ttjtOXKdSeLt/LBQhe4Bt34iTwVRr4r8HWVn+IS3YF6HVCDPeT+m0LODLw FHmQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=4Ma9RsLmJse9wKSQr2fdk1qKcq67iH7WS9DOCSRJnyU=; b=M2U9oGN1SqgueyryovHZyM1ZMEQwUcG33NFEoyxfLMZZvDEENdYUxBRHEi5DfQvlCD qNkKqYQSv841nVkEIV9ToKpoaYIlLzTTwndiCTw2YA33C/STtWQnKKTvCaXlrhcQJOk1 Xj8iHmn7cKNdRWTBQpy4qD6XRm6rCdlI7xHR8QWe2lI2q5XmFBfYfkWpjHGDCWYvDKiG 9Hr7gJngzWnhrFnDV/TD4+CrIgc4ORLLKZjx2OI+ytVuAUbxI9NtxBHC7R+tHlgoSLF/ Pn1bak+VIf6rZsiRwaTGVfjXwZn2El/hRz1E1ORt4qM5vumdBLyru3sVkeQPEH52y6P4 wHbA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=JwA4pkuR; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id 38si1796261qkw.176.2017.10.16.10.47.57 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 16 Oct 2017 10:47:57 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=JwA4pkuR; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:34382 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e49UZ-0002w4-Tz for patch@linaro.org; Mon, 16 Oct 2017 13:47:55 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52596) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e49AN-0002cy-4u for qemu-devel@nongnu.org; Mon, 16 Oct 2017 13:27:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e49AJ-0003lP-Q0 for qemu-devel@nongnu.org; Mon, 16 Oct 2017 13:27:03 -0400 Received: from mail-pg0-x22b.google.com ([2607:f8b0:400e:c05::22b]:57332) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e49AJ-0003ku-K5 for qemu-devel@nongnu.org; Mon, 16 Oct 2017 13:26:59 -0400 Received: by mail-pg0-x22b.google.com with SMTP id m18so7344105pgd.13 for ; Mon, 16 Oct 2017 10:26:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=4Ma9RsLmJse9wKSQr2fdk1qKcq67iH7WS9DOCSRJnyU=; b=JwA4pkuRDCQufvDyrg00h+j2sc5Jyqo9f3fUTkbjaIYfGqmk6SbDLeHpkXGqHj01Yu B7jQWMMwLlQROlfqF27K8fwZWh0zf73D8Xdt1wgAngQNWSkNfIWpBzV1/0taG5onqwWy MibVuOtTjUaURyzHa2NkT4XT3GjW2N13KAb6g= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=4Ma9RsLmJse9wKSQr2fdk1qKcq67iH7WS9DOCSRJnyU=; b=ZC/vbNyuIyWa3x44OjeHy2l5PM/Y104sDAnI1oUYRd1rBdyhVsss4ghRLlFyES87JW PMAS8RR7TMSaN0LR/dgBgDY1JKdXW0vdPtDk0ADWWncLfG/SaPXCRTeJmHtm4gC8/TX9 IfFiYiW2+WJnhAu5X32LmxsidNtkn8oHoeP5e0yNb3Sq7JYlPSBADZ8b1sm2T6ilb+jF /exxL+B4TwAj8ZRaAhrgUUpxR6OCFDZN5D0O7lbhjDg4yfVw5Fi/rYOBldLsTxR+ua4b kjmng3uAFaAMIgeMp3rJXEnmeu88osRM8nRhQzAa37sOsxZMvAxkxnWZ6cX4yed9SJas 51Mg== X-Gm-Message-State: AMCzsaUVEdAl9zfs/tKLbb3CSIzhGdjU2NbVFNFyxFau70Kg4j0jaovv jOPDBpDbPHowOuKsPTNCmb0fmbdULx0= X-Google-Smtp-Source: AOwi7QBd+6BwNuNTyP38ZCQG9ymZLVEgme60ePOxYTod+RWQrdHtN/j1g81OPobc4TrvZHl0/WdrhQ== X-Received: by 10.98.9.27 with SMTP id e27mr9163232pfd.284.1508174818482; Mon, 16 Oct 2017 10:26:58 -0700 (PDT) Received: from cloudburst.twiddle.net (97-126-104-76.tukw.qwest.net. [97.126.104.76]) by smtp.gmail.com with ESMTPSA id i187sm5594249pfc.96.2017.10.16.10.26.57 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 16 Oct 2017 10:26:57 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Mon, 16 Oct 2017 10:25:51 -0700 Message-Id: <20171016172609.23422-33-richard.henderson@linaro.org> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171016172609.23422-1-richard.henderson@linaro.org> References: <20171016172609.23422-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c05::22b Subject: [Qemu-devel] [PATCH v6 32/50] target/sh4: check CF_PARALLEL instead of parallel_cpus 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: cota@braap.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: "Emilio G. Cota" Thereby decoupling the resulting translated code from the current state of the system. Reviewed-by: Richard Henderson Signed-off-by: Emilio G. Cota --- target/sh4/translate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.13.6 diff --git a/target/sh4/translate.c b/target/sh4/translate.c index 33176c9926..f918bae978 100644 --- a/target/sh4/translate.c +++ b/target/sh4/translate.c @@ -521,7 +521,7 @@ static void _decode_opc(DisasContext * ctx) /* Detect the start of a gUSA region. If so, update envflags and end the TB. This will allow us to see the end of the region (stored in R0) in the next TB. */ - if (B11_8 == 15 && B7_0s < 0 && parallel_cpus) { + if (B11_8 == 15 && B7_0s < 0 && (tb_cflags(ctx->tb) & CF_PARALLEL)) { ctx->envflags = deposit32(ctx->envflags, GUSA_SHIFT, 8, B7_0s); ctx->bstate = BS_STOP; } From patchwork Mon Oct 16 17:25:52 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 115966 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp3958446qgn; Mon, 16 Oct 2017 10:55:32 -0700 (PDT) X-Received: by 10.200.8.53 with SMTP id u50mr16332064qth.260.1508176532562; Mon, 16 Oct 2017 10:55:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508176532; cv=none; d=google.com; s=arc-20160816; b=JZx6HqStUCHHM5647SXnGkIwYLt9IbKLvgR1F1g8eDNRkB+F5FHjfiPMCnlIVYIB4O 7BwGuKBxgDhRYDnGf3QQmInn0+xBsh49770daP6NIJZsZm18jFXXc9Pf7Jj+mlkBFTZW PPIk8JSPLmUB20RsDw5k1SY3vY1t02jXawtjXW/K5DAf5r/AjHOJpFTHp2VU8DIkdUPk yisrbTaxg/FSL6HKnr9n54iFqUEQp/dIPPBZqJ455RSi/mbZMFrXs2YgyAiWY6M+/4Eg 9RQ55/Gc3v6WFAvU5ypm9SUmyBgB5hc/UTEpOL5u2k2B3s/rhm/H001GUShxTIkndVb4 u5jw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=XrDOWbNcFJTmBQzRovNO+7qJou3wvKXhrlz+xDEDj2I=; b=PGhJkyNXpMnlH0QVtpG7p0YUCWBTZuwYCSbgJ9KkN3+J6zegpDVFg2lnlvU8QDU7Lu pKFpGujrEJBNqf8D/dnSCnbWkAZumsPfPkR220eBz0Z68a3MXbAfBNzms2efqCsf5y27 AHhHzJLAi9uL8B94Mv0JVDTW21+sYOeMlefBowGS+pdtuTWOEQBOTlMHRFzp9U16c+t8 j0R0qxW3VKkA0TrrHRRJiOPcMkf17tBTEBJsRfPOYF8mXTGDiVomJUk1/1tLdF7vbwlx 5/6ZIVSx8WaaVmgC6HVZrZe+zJ2qHZQhD08Fp2ja45aexnCrsrBGvT3xKNAChNLm9aFv 60PQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=c39tBE9k; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id i185si2743895qka.198.2017.10.16.10.55.32 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 16 Oct 2017 10:55:32 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=c39tBE9k; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:34412 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e49bu-000137-H0 for patch@linaro.org; Mon, 16 Oct 2017 13:55:30 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52593) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e49AN-0002cv-3y for qemu-devel@nongnu.org; Mon, 16 Oct 2017 13:27:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e49AL-0003mc-1g for qemu-devel@nongnu.org; Mon, 16 Oct 2017 13:27:03 -0400 Received: from mail-pf0-x233.google.com ([2607:f8b0:400e:c00::233]:43803) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e49AK-0003lt-Rx for qemu-devel@nongnu.org; Mon, 16 Oct 2017 13:27:00 -0400 Received: by mail-pf0-x233.google.com with SMTP id a8so15844580pfc.0 for ; Mon, 16 Oct 2017 10:27:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=XrDOWbNcFJTmBQzRovNO+7qJou3wvKXhrlz+xDEDj2I=; b=c39tBE9kuxeZSWVu+nUoyX+vfQ59dyyCT7g5A7MXYQETvX4VE0zcZH5pH25OvIm+SV mujqHIBt4QUGTduF+kKj4qaxwSDPxPV6Xl/GlExBn+RT3fBqUiY1zHOmX7c3WaQJSvTX 6QD+37Ocdprm67F4DtpmGV0CBRZkK4xuH7ukI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=XrDOWbNcFJTmBQzRovNO+7qJou3wvKXhrlz+xDEDj2I=; b=d8cI3ofovvBNl+ZX8XZz34ISsOAbGXsfr3Eh5+l7jUuuTZiTLyv4MS5DvfaaueowtO M1TKkpTUaXCoF1UJgB6+yjn7WulI7cy/x5z3UbAedQfezaUxI6AmaGmUOfVHzuX5oPdf /5kgRek33YYOUOL5Jk0jnlp/4/GuHBt/yJ5bhtXGqMtEf7CK8dwBw5Qg4GfL7y9sPuj6 qqEj4dCnfGYDVGxIO0r7PNd4rk+ejiBGntQdfRtSXp1yrTcESQyMUuImill2QB2fQ+4L YhY0kaxMg8ikdKF5tZNmcB/C9p2+Y1/ofAb9uvbvzPYUQimAQFSwvRVNBwH/67EeKyWT QvoA== X-Gm-Message-State: AMCzsaVKen4gsUd1iibQ474Nv+uK9eL5QFeZHKhnLjTCaJYy734VY/9P ehSn+etfVIb5D70UBxzmYJ49lCZGILw= X-Google-Smtp-Source: AOwi7QDGbSDXrX4J7aNx7W4RSudsTdZUszvSrauZLgnqVlQYxH9P7RYUqUsC86VB3xslKqUwgGfJmQ== X-Received: by 10.98.57.215 with SMTP id u84mr9294600pfj.300.1508174819642; Mon, 16 Oct 2017 10:26:59 -0700 (PDT) Received: from cloudburst.twiddle.net (97-126-104-76.tukw.qwest.net. [97.126.104.76]) by smtp.gmail.com with ESMTPSA id i187sm5594249pfc.96.2017.10.16.10.26.58 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 16 Oct 2017 10:26:58 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Mon, 16 Oct 2017 10:25:52 -0700 Message-Id: <20171016172609.23422-34-richard.henderson@linaro.org> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171016172609.23422-1-richard.henderson@linaro.org> References: <20171016172609.23422-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c00::233 Subject: [Qemu-devel] [PATCH v6 33/50] target/sparc: check CF_PARALLEL instead of parallel_cpus 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: cota@braap.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: "Emilio G. Cota" Thereby decoupling the resulting translated code from the current state of the system. Reviewed-by: Richard Henderson Signed-off-by: Emilio G. Cota --- target/sparc/translate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.13.6 diff --git a/target/sparc/translate.c b/target/sparc/translate.c index 05414ce8a8..0669d4e8e5 100644 --- a/target/sparc/translate.c +++ b/target/sparc/translate.c @@ -2442,7 +2442,7 @@ static void gen_ldstub_asi(DisasContext *dc, TCGv dst, TCGv addr, int insn) default: /* ??? In theory, this should be raise DAE_invalid_asi. But the SS-20 roms do ldstuba [%l0] #ASI_M_CTL, %o1. */ - if (parallel_cpus) { + if (tb_cflags(dc->tb) & CF_PARALLEL) { gen_helper_exit_atomic(cpu_env); } else { TCGv_i32 r_asi = tcg_const_i32(da.asi); From patchwork Mon Oct 16 17:25:53 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 115956 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp3952051qgn; Mon, 16 Oct 2017 10:47:31 -0700 (PDT) X-Received: by 10.55.82.86 with SMTP id g83mr14719668qkb.342.1508176051095; Mon, 16 Oct 2017 10:47:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508176051; cv=none; d=google.com; s=arc-20160816; b=KYzPkitVddkZsIND8PFBDBjF64ln3YBpy7o3krxf09m6mMgtcabhexCePhgMrUsZFN RiBiZVy21KIwi+PnKgOzwZwfxGEqV+c3cTtlRE46aDm98/yDzjqNI5OePQQRQuTKjMPy TnStcGz0EK/VCqjyqooUQh2jvWCZmJzKUgl4mECzvAeTn5BrNNxBdYJD35URiPJqv+N0 G+/ak6pEt6N9eGRV3UhhIVoX2GzWFm3MyvdqOKMwv10SsEE9UFD1/XtxkFR3Tjxv0lWW 6p3w1MqyPLc3OMLYYfgFv5avEwyhS7chdxlVAk/1M5dmSMXklHkexpTcoKsvULBiG9C9 SlvQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=rNneEMePZmh2n3MgU+clGSMraZtaGE+TiRXzcHouM8E=; b=HRdZ9ROPHu4FYzQm/hOVWLgUYEIhWLXao3XyybQ7bmK8IT4V0lLBaWEf0H2DPvlGn9 jSax6SJy6ECCuke8s+xyIYDAyxiQx5RJR7te6UuMJGBVlrSGtfJ1gdmt4h/Ktp6Ejo96 u7dkp3d3Ur/Uy+D8RzHiesrq/w81e55oMbahcxPc85eQ1RyMgtmNdiIWPN4280FbA7Wd JWEKaMFh9dDXpWS3rJQZDMyqRJQF35+u3Be86SHU9+JmCAjuQ4PahCqh+49v7quUUkF9 3IY+kakqIGmC7eb/zkfPVOYT29TTUIGXP79l8y2HjhM+azNCjazX6UaswMYMrNAxg0p+ usPA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=KpT6/9sw; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id i22si480258qkh.292.2017.10.16.10.47.30 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 16 Oct 2017 10:47:31 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=KpT6/9sw; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:34380 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e49U8-0002r5-QI for patch@linaro.org; Mon, 16 Oct 2017 13:47:28 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52678) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e49AS-0002ik-IQ for qemu-devel@nongnu.org; Mon, 16 Oct 2017 13:27:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e49AM-0003og-KV for qemu-devel@nongnu.org; Mon, 16 Oct 2017 13:27:08 -0400 Received: from mail-pg0-x232.google.com ([2607:f8b0:400e:c05::232]:47624) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e49AM-0003nm-Ep for qemu-devel@nongnu.org; Mon, 16 Oct 2017 13:27:02 -0400 Received: by mail-pg0-x232.google.com with SMTP id r25so7349314pgn.4 for ; Mon, 16 Oct 2017 10:27:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=rNneEMePZmh2n3MgU+clGSMraZtaGE+TiRXzcHouM8E=; b=KpT6/9swbCbXrI2IV0xjjoIuCYiFe6cP57GAz/iOBniN65YI3c2Y4lukI8tsDynkpV HRuOjk0MPl+0zC9MuIbZC99Ii/JcGLqalIYsoY9cQdhN0GRHYF4z31ZyyAOXO1TAQheI p0YjlVqsF3jBGWNb233E1ELmRZVmt1IJJEWto= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=rNneEMePZmh2n3MgU+clGSMraZtaGE+TiRXzcHouM8E=; b=O3W3UjXNePTbooNa2Dbz1SJFsfYMTPpDXhbGU7sM840dJPojkkOECcv24TVRExi8sK 75jj10mKzn6ichy0iK9GwH+hMQozd1eMoqCMkFXIvGv7mWOaMepJ3IulvQFhVlR/RTK5 7ZVSC1bg9zOPB+D9xBCnKfgaAEvBxMBAhqqWzet7MXVl6ze4HrTuCMUR+43ExlceZ4l+ 6EfWdFSMbJ8B+avnMfX1DxTbv8+ir1IXF+LqtHmaETNZ+uWxQXZnLBJ4dqaYBidGZBtj 1pBjFEd+XCOVTsNL1t6u12IGPO0kqoRQAWXHISWE2krwT7L9qA+TA/cs+RMkOs82uWhm Nq/g== X-Gm-Message-State: AMCzsaVs+/kfH7Xl4J/KVgyliQPZPOkwMXzVoXXAVUvyhXMHfamwEeUD hdrMkouTwaib1KcTcbuceL5+TimP0MM= X-Google-Smtp-Source: AOwi7QDAmAiDZFzGxQQlqihhAVz8CKgiRNQ95VzhrNx1EJON2Pp8ZbdLj0HVG5qm2FO1QMuuok/bkg== X-Received: by 10.84.210.166 with SMTP id a35mr9719602pli.426.1508174821230; Mon, 16 Oct 2017 10:27:01 -0700 (PDT) Received: from cloudburst.twiddle.net (97-126-104-76.tukw.qwest.net. [97.126.104.76]) by smtp.gmail.com with ESMTPSA id i187sm5594249pfc.96.2017.10.16.10.26.59 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 16 Oct 2017 10:27:00 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Mon, 16 Oct 2017 10:25:53 -0700 Message-Id: <20171016172609.23422-35-richard.henderson@linaro.org> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171016172609.23422-1-richard.henderson@linaro.org> References: <20171016172609.23422-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c05::232 Subject: [Qemu-devel] [PATCH v6 34/50] tcg: check CF_PARALLEL instead of parallel_cpus 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: cota@braap.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: "Emilio G. Cota" Thereby decoupling the resulting translated code from the current state of the system. The tb->cflags field is not passed to tcg generation functions. So we add a field to TCGContext, storing there a copy of tb->cflags. Most architectures have <= 32 registers, which results in a 4-byte hole in TCGContext. Use this hole for the new field. Reviewed-by: Richard Henderson Signed-off-by: Emilio G. Cota --- tcg/tcg.h | 1 + accel/tcg/translate-all.c | 1 + tcg/tcg-op.c | 10 +++++----- 3 files changed, 7 insertions(+), 5 deletions(-) -- 2.13.6 diff --git a/tcg/tcg.h b/tcg/tcg.h index 5e1170b299..6736a9fe2e 100644 --- a/tcg/tcg.h +++ b/tcg/tcg.h @@ -656,6 +656,7 @@ struct TCGContext { uintptr_t *tb_jmp_target_addr; /* tb->jmp_target_arg if !direct_jump */ TCGRegSet reserved_regs; + uint32_t tb_cflags; /* cflags of the current TB */ intptr_t current_frame_offset; intptr_t frame_start; intptr_t frame_end; diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c index a7415c8661..d3dee985b4 100644 --- a/accel/tcg/translate-all.c +++ b/accel/tcg/translate-all.c @@ -1296,6 +1296,7 @@ TranslationBlock *tb_gen_code(CPUState *cpu, tb->flags = flags; tb->cflags = cflags; tb->trace_vcpu_dstate = *cpu->trace_dstate; + tcg_ctx.tb_cflags = cflags; #ifdef CONFIG_PROFILER tcg_ctx.tb_count1++; /* includes aborted translations because of diff --git a/tcg/tcg-op.c b/tcg/tcg-op.c index be4b623e82..3253451115 100644 --- a/tcg/tcg-op.c +++ b/tcg/tcg-op.c @@ -121,7 +121,7 @@ void tcg_gen_op6(TCGOpcode opc, TCGArg a1, TCGArg a2, TCGArg a3, void tcg_gen_mb(TCGBar mb_type) { - if (parallel_cpus) { + if (tcg_ctx.tb_cflags & CF_PARALLEL) { tcg_gen_op1(INDEX_op_mb, mb_type); } } @@ -2780,7 +2780,7 @@ void tcg_gen_atomic_cmpxchg_i32(TCGv_i32 retv, TCGv addr, TCGv_i32 cmpv, { memop = tcg_canonicalize_memop(memop, 0, 0); - if (!parallel_cpus) { + if (!(tcg_ctx.tb_cflags & CF_PARALLEL)) { TCGv_i32 t1 = tcg_temp_new_i32(); TCGv_i32 t2 = tcg_temp_new_i32(); @@ -2824,7 +2824,7 @@ void tcg_gen_atomic_cmpxchg_i64(TCGv_i64 retv, TCGv addr, TCGv_i64 cmpv, { memop = tcg_canonicalize_memop(memop, 1, 0); - if (!parallel_cpus) { + if (!(tcg_ctx.tb_cflags & CF_PARALLEL)) { TCGv_i64 t1 = tcg_temp_new_i64(); TCGv_i64 t2 = tcg_temp_new_i64(); @@ -3001,7 +3001,7 @@ static void * const table_##NAME[16] = { \ void tcg_gen_atomic_##NAME##_i32 \ (TCGv_i32 ret, TCGv addr, TCGv_i32 val, TCGArg idx, TCGMemOp memop) \ { \ - if (parallel_cpus) { \ + if (tcg_ctx.tb_cflags & CF_PARALLEL) { \ do_atomic_op_i32(ret, addr, val, idx, memop, table_##NAME); \ } else { \ do_nonatomic_op_i32(ret, addr, val, idx, memop, NEW, \ @@ -3011,7 +3011,7 @@ void tcg_gen_atomic_##NAME##_i32 \ void tcg_gen_atomic_##NAME##_i64 \ (TCGv_i64 ret, TCGv addr, TCGv_i64 val, TCGArg idx, TCGMemOp memop) \ { \ - if (parallel_cpus) { \ + if (tcg_ctx.tb_cflags & CF_PARALLEL) { \ do_atomic_op_i64(ret, addr, val, idx, memop, table_##NAME); \ } else { \ do_nonatomic_op_i64(ret, addr, val, idx, memop, NEW, \ From patchwork Mon Oct 16 17:25:54 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 115970 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp3959695qgn; Mon, 16 Oct 2017 10:57:07 -0700 (PDT) X-Received: by 10.55.115.133 with SMTP id o127mr15040475qkc.351.1508176627411; Mon, 16 Oct 2017 10:57:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508176627; cv=none; d=google.com; s=arc-20160816; b=z4n5PHF+EzSkYCA6OMxYcyBYEq9k04qB7M4QxCYyeI13FArv6wbeLK9Cy4YzAb4qAS fWFjgag2qHmhrNBEK/wjZdRi/cHD1kSDKb1/3rh4qX8r1LedtmHhtYgJaThfG7Xay467 0kCYYTqvvOprU1k55/4khER+6u0P8s9ar4SCAPS9eUfDu2TuxwOJEuNVoTfj2pftQFYM o73e4W6m88UtP0L1WfeTtbsSVLRF/yEcNQAF3ZjmCpvMZKWRDsnL8CkgRVYfQb7jbnYD RamFjzmxfDENS8Yrlzle0NDb1ow7eY4pFDTgwOumBnvL4mEzY2NzeILgjo19hB5kSAZK DUAw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=l2NW2eibSR6aGsXmh0Di9NTdRoHSvwrB4y9R4avxQdo=; b=ipla19abYagKhx70RIAUSjR9a1yWiHg/X/eH0OOEsxZ7YN8PGiDC5aqwyHP2Ctgudw fqQue6B8oRcKLLqcrljuw7J3r0JViC+tzN9brLjY48oN/GYwSEzt6A66bFN/VzWDT99Y yNbYYlS2IVZ5xb+H7XkCJt2UXxjPw6yWFxyo1NhvbBE+8AGnsXVJp+BBuiLJiCASTMoc 5P+8RG0YnU65OBXxYaFi1P0cKD7RLEWAehNCDjVRzsNcYBtqiMrw5Jz4ZN2Aj26ntPfy z+3deW1Vdy4AKhz1iwqa539h/AphTxZXLl0p5SL2RzYHCkclbqGHjkMWkZVNV68ro27R fa1g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=A4E/Wz2o; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id i89si3583699qtd.221.2017.10.16.10.57.07 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 16 Oct 2017 10:57:07 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=A4E/Wz2o; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:34426 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e49dR-0002sx-E5 for patch@linaro.org; Mon, 16 Oct 2017 13:57:05 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52618) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e49AO-0002en-TI for qemu-devel@nongnu.org; Mon, 16 Oct 2017 13:27:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e49AN-0003ph-Rf for qemu-devel@nongnu.org; Mon, 16 Oct 2017 13:27:04 -0400 Received: from mail-pf0-x232.google.com ([2607:f8b0:400e:c00::232]:54267) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e49AN-0003p1-M7 for qemu-devel@nongnu.org; Mon, 16 Oct 2017 13:27:03 -0400 Received: by mail-pf0-x232.google.com with SMTP id t188so13794494pfd.10 for ; Mon, 16 Oct 2017 10:27:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=l2NW2eibSR6aGsXmh0Di9NTdRoHSvwrB4y9R4avxQdo=; b=A4E/Wz2oIIVhlLqFDnBPy8OL20f0FkOC0ntYtTThSvay8mf9Aks7flFggTfoCv+V2e i4/ePeAVcFAZ+wPqkbN7hsonR53lgDKYIzrkAzBRss5QFShyiYLFzSyujbhXPKGcJcgP iCdaH679JSZ8yMyKSMxejUF1FJmNt1TB+KtsI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=l2NW2eibSR6aGsXmh0Di9NTdRoHSvwrB4y9R4avxQdo=; b=Tns/dOSGgKZYi4LKnFO2gMSqU6GFY3RighGAmA8Ef2QJyEqAZo0DnY08lOcmk6hnJS Tt0Q8NGGsBLvhkDkBQOBaM+kjym/pd42WMgVqg8IuVP41FR5UkSurWsmogNOuRsxFBNI LpQWSSirKgFH9c3H1KShfaVW3OARIKjcaEKc2RLhOydCh4vmWVahzp4ergG7gaYoxUbj pKZK0XaCxQlzVIsvnF+CgG2zOUfIRi+iGVHYwvTn5K4yIkZ1/HQgAjTQMgj/Hr6/kZir YFQYu/SGwmkOknVizitkYeG2UjWll91rJ5tk4TYdrnKBL1yK7jwO1eFdWT/B0TLVL2S0 BoGQ== X-Gm-Message-State: AMCzsaWIFjUKL/4wMUjEUXVazQ9Q4QXjK85wpN3BbeBs6ryxvHXQOYwL LuIGVyGnM3TKsK7QKbGpWLcbN3hgx5s= X-Google-Smtp-Source: AOwi7QC8H7yzJz2anJ+Nicfo7PgmbdLViYpKwGLe3z11DCh6PcAOgE26BcK8hqK2k7Lyw4jiCCCnjQ== X-Received: by 10.99.95.203 with SMTP id t194mr6880123pgb.318.1508174822423; Mon, 16 Oct 2017 10:27:02 -0700 (PDT) Received: from cloudburst.twiddle.net (97-126-104-76.tukw.qwest.net. [97.126.104.76]) by smtp.gmail.com with ESMTPSA id i187sm5594249pfc.96.2017.10.16.10.27.01 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 16 Oct 2017 10:27:01 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Mon, 16 Oct 2017 10:25:54 -0700 Message-Id: <20171016172609.23422-36-richard.henderson@linaro.org> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171016172609.23422-1-richard.henderson@linaro.org> References: <20171016172609.23422-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c00::232 Subject: [Qemu-devel] [PATCH v6 35/50] cpu-exec: lookup/generate TB outside exclusive region during step_atomic 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: cota@braap.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: "Emilio G. Cota" Now that all code generation has been converted to check CF_PARALLEL, we can generate !CF_PARALLEL code without having yet set !parallel_cpus -- and therefore without having to be in the exclusive region during cpu_exec_step_atomic. While at it, merge cpu_exec_step into cpu_exec_step_atomic. Reviewed-by: Richard Henderson Signed-off-by: Emilio G. Cota --- accel/tcg/cpu-exec.c | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) -- 2.13.6 diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c index df410a8d6e..0eecbccebc 100644 --- a/accel/tcg/cpu-exec.c +++ b/accel/tcg/cpu-exec.c @@ -223,30 +223,40 @@ static void cpu_exec_nocache(CPUState *cpu, int max_cycles, } #endif -static void cpu_exec_step(CPUState *cpu) +void cpu_exec_step_atomic(CPUState *cpu) { CPUClass *cc = CPU_GET_CLASS(cpu); TranslationBlock *tb; target_ulong cs_base, pc; uint32_t flags; uint32_t cflags = 1 | CF_IGNORE_ICOUNT; + uint32_t cf_mask = cflags & CF_HASH_MASK; if (sigsetjmp(cpu->jmp_env, 0) == 0) { - tb = tb_lookup__cpu_state(cpu, &pc, &cs_base, &flags, - cflags & CF_HASH_MASK); + tb = tb_lookup__cpu_state(cpu, &pc, &cs_base, &flags, cf_mask); if (tb == NULL) { mmap_lock(); tb_lock(); - tb = tb_gen_code(cpu, pc, cs_base, flags, cflags); + tb = tb_htable_lookup(cpu, pc, cs_base, flags, cf_mask); + if (likely(tb == NULL)) { + tb = tb_gen_code(cpu, pc, cs_base, flags, cflags); + } tb_unlock(); mmap_unlock(); } + start_exclusive(); + + /* Since we got here, we know that parallel_cpus must be true. */ + parallel_cpus = false; cc->cpu_exec_enter(cpu); /* execute the generated code */ trace_exec_tb(tb, pc); cpu_tb_exec(cpu, tb); cc->cpu_exec_exit(cpu); + parallel_cpus = true; + + end_exclusive(); } else { /* We may have exited due to another problem here, so we need * to reset any tb_locks we may have taken but didn't release. @@ -260,18 +270,6 @@ static void cpu_exec_step(CPUState *cpu) } } -void cpu_exec_step_atomic(CPUState *cpu) -{ - start_exclusive(); - - /* Since we got here, we know that parallel_cpus must be true. */ - parallel_cpus = false; - cpu_exec_step(cpu); - parallel_cpus = true; - - end_exclusive(); -} - struct tb_desc { target_ulong pc; target_ulong cs_base; From patchwork Mon Oct 16 17:25:55 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 115951 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp3949681qgn; Mon, 16 Oct 2017 10:44:47 -0700 (PDT) X-Received: by 10.55.176.68 with SMTP id z65mr10852254qke.75.1508175887870; Mon, 16 Oct 2017 10:44:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508175887; cv=none; d=google.com; s=arc-20160816; b=k90ZBPu83TWqEQGUrWh5A6ZJb58vBvhuyBAC/xGa4qbGJngTu0hiEnzDsGzbptRv4+ 6a/Uk4We+txfBaaLTZpjshwTZyWPo8/E6amUAQLrUP8zG5OggkXu8qPC5hHWj1ydRxiT Aem47Fgwb6D036oc0ZJimIxzJkDJcp5ys+3ajXDNHC7MBIwVKZvrTjok9Y26ggzA2NyO PkG20FhjA/+d/Fb6UxaoWUOy6xyAnOyWNOOctNSkF811CYnUeN7A+UG6ihjK5zqjwVpF 7ruDILc/xLs18K5eeOiNtZaf7lBQS+XbpyIok422v/rL/LyV0HmBaQRES7T/i65jhtaq LBQw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=fTnG+pYtyBDmdpZrb4pJY39N9JOIdfqX72NWpGL3Keo=; b=lzJ6wn6ALE9bNK8xelKpKzRrXhHQs1F1v1WhsSwauAIsBZvPd6BMQpOT2zwq3jNIYw 2UTi7/HiH5a1HYWFFMDl8APdti4t0/WpkUYopRBHuSpBq+kwVNFUQyR0NJNB7G0iWKMr 7hm8yi+fPdmlNMtZi4BvKYYUibClr8SV4GuVSNShPZmrECli77OxwFsA3EfkkLbOxrj0 SGMFzrFVL2I04SC6DX+EV8eTqmJP3SEk/efKLt9+iRAL6CmO0SvjoA/emW4dGfCJU9oN kouVWS78mIf0eibQzKy4T5Xekqm+VLFWxLEkOHB0xi99tR2QRGMlcm5dTb9x+KQF8JMz 8ghA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=cKEfGkon; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id i1si4677870qkc.127.2017.10.16.10.44.47 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 16 Oct 2017 10:44:47 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=cKEfGkon; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:34367 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e49RV-0000QL-Q3 for patch@linaro.org; Mon, 16 Oct 2017 13:44:45 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52637) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e49AQ-0002fy-2o for qemu-devel@nongnu.org; Mon, 16 Oct 2017 13:27:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e49AP-0003qj-B3 for qemu-devel@nongnu.org; Mon, 16 Oct 2017 13:27:06 -0400 Received: from mail-pf0-x22d.google.com ([2607:f8b0:400e:c00::22d]:54602) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e49AP-0003qE-4t for qemu-devel@nongnu.org; Mon, 16 Oct 2017 13:27:05 -0400 Received: by mail-pf0-x22d.google.com with SMTP id n89so8659477pfk.11 for ; Mon, 16 Oct 2017 10:27:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=fTnG+pYtyBDmdpZrb4pJY39N9JOIdfqX72NWpGL3Keo=; b=cKEfGkonb1Rlufh36vyzisx2hvd+oC/MIa1t8pKqBb5CJZLqqflrmjEqrs9lR4HNb0 Hw4HplGybjUNAnkaej/b/a9EGzDLgNzi+fPWfCukPJ9+4781+rFPvNSoOiEUkU02B7iS GbsftVIh29keoMvgMDgpzColaP1poZBOyq9ls= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=fTnG+pYtyBDmdpZrb4pJY39N9JOIdfqX72NWpGL3Keo=; b=GQNcyB5PkQI7mMR/xOEnKKMLlffmiQm7x7504oMKzDOdgOuSW2ARk4qE/XKkU9ja0n WYoQMgKb3WrZ3iPTHAiLvd5jSwkmLYjZIrWwZ2hOTlvuFw6AuN/u6oeHOe4SkIDn7Kvm Fsipmqjh1YpMgMv2dY4OjaEXwR9CYTjlC5/RbWAJ3cwoQ3QOpOyxzhhw1vGRCTFUpwH2 MGZWo/14luFo55bxlS3Mg3Ov1YE82sDDAT+xr2bmfIm1ZtKAmr06F2fnkmJimnZXVPFU FAeLzzGdHVN/4AMxJ342JBbx4bk6MUH1uF9dB9Spb/GYo5NYm3Oz94/NBnACjqZ+RGAo pMIQ== X-Gm-Message-State: AMCzsaVyKb3Fn+AWOnvFONFjzX8Oi/d1JHpbsxLOz08yb2ZA42VaX/MK m67WHkGZP22nKUoS0eeXAoTUvEfmifE= X-Google-Smtp-Source: AOwi7QA7PcUee+74F9OomEGOt/IQlwQfmS9SYYycINZSJkleuEVheUaXlChpycMZ5lXMlwXbH2Aumg== X-Received: by 10.98.70.137 with SMTP id o9mr9307535pfi.19.1508174823969; Mon, 16 Oct 2017 10:27:03 -0700 (PDT) Received: from cloudburst.twiddle.net (97-126-104-76.tukw.qwest.net. [97.126.104.76]) by smtp.gmail.com with ESMTPSA id i187sm5594249pfc.96.2017.10.16.10.27.02 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 16 Oct 2017 10:27:03 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Mon, 16 Oct 2017 10:25:55 -0700 Message-Id: <20171016172609.23422-37-richard.henderson@linaro.org> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171016172609.23422-1-richard.henderson@linaro.org> References: <20171016172609.23422-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c00::22d Subject: [Qemu-devel] [PATCH v6 36/50] tcg: Add CF_LAST_IO + CF_USE_ICOUNT to CF_HASH_MASK 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: cota@braap.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" These flags are used by target/*/translate.c, and affect code generation. Signed-off-by: Richard Henderson --- include/exec/exec-all.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) -- 2.13.6 diff --git a/include/exec/exec-all.h b/include/exec/exec-all.h index 0fdb72bb22..a3bd3e7abd 100644 --- a/include/exec/exec-all.h +++ b/include/exec/exec-all.h @@ -327,7 +327,8 @@ struct TranslationBlock { #define CF_INVALID 0x80000 /* TB is stale. Setters must acquire tb_lock */ #define CF_PARALLEL 0x100000 /* Generate code for a parallel context */ /* cflags' mask for hashing/comparison */ -#define CF_HASH_MASK (CF_COUNT_MASK | CF_PARALLEL) +#define CF_HASH_MASK \ + (CF_COUNT_MASK | CF_LAST_IO | CF_USE_ICOUNT | CF_PARALLEL) /* Per-vCPU dynamic tracing state used to generate this TB */ uint32_t trace_vcpu_dstate; From patchwork Mon Oct 16 17:25:56 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 115969 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp3959251qgn; Mon, 16 Oct 2017 10:56:32 -0700 (PDT) X-Received: by 10.200.8.53 with SMTP id u50mr14920345qth.106.1508176592847; Mon, 16 Oct 2017 10:56:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508176592; cv=none; d=google.com; s=arc-20160816; b=tzq3RUZmYnAUB2CupUEVivO0bnRghUf0AO0NYM/hKKCGjTqCngNf333JFUQvGdOER4 +Dw09iSc0ImEiwXJPiLNQj4GPQnq2atjGdmrD9AhBrUtIFPUqiUPqLqZG+hQ9fQsbCrI Zww2TQP+DjfJdP8CG0WXDOo4DbZzg5moUSSICM5FFgYw8rgbiCkq7vZ1hmVcL9kxEtS2 eaWeMPo2yNXVF6I0SXsSptKzwIAxlDzS275wcuapyVgRb7XHpNTvSV1g3Ihow6AThdp9 7Y9BBWN4gXqMKZMXvxr3c3hFdHS8a4Ju+EIERm99C4366fviWQBw7/nUAhKWxPYig2Xx jqEw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=Vw/hp+C1d3vT3b7ZsD+YkxtyOWMep2FJT3usVPD/ybU=; b=kKrvv9WtSTZWYMjK5J5/SnRHqmh5M8mxTqFSheuzMMPDDkhV9VegjX5wWfzanVyZG/ qSDxV25prDeg8eq5c7JIFUJAWDF4yNYHTWYPzreU5+BRTyI/hYe/gdjMtzXlnwDwB2a/ g2IgAyaQfyrKdbOvpEBGsbFWXLDKNyN9rhoa1tQ1WCkVntPkn1zPIN3eJQ/YBpuKx4fB qQuF1UkXywPPUIprmWJqFrZS5xSwTDLaEijnp5VTKNv/eeCRL229QHn+K+okyAxvykU4 hcoBmRtfROoQBPYrbX7WEc3oyM8s0piXLnzpiGgM//cwfMdTMIpFQMssxMBtHTxbKgSu RlJg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Z6JFuhqM; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id l187si3072711qkc.277.2017.10.16.10.56.32 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 16 Oct 2017 10:56:32 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Z6JFuhqM; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:34421 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e49cs-0002Lq-NK for patch@linaro.org; Mon, 16 Oct 2017 13:56:30 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52665) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e49AR-0002hw-Mz for qemu-devel@nongnu.org; Mon, 16 Oct 2017 13:27:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e49AQ-0003rt-Gd for qemu-devel@nongnu.org; Mon, 16 Oct 2017 13:27:07 -0400 Received: from mail-pf0-x236.google.com ([2607:f8b0:400e:c00::236]:44288) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e49AQ-0003rI-A2 for qemu-devel@nongnu.org; Mon, 16 Oct 2017 13:27:06 -0400 Received: by mail-pf0-x236.google.com with SMTP id x7so16318020pfa.1 for ; Mon, 16 Oct 2017 10:27:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Vw/hp+C1d3vT3b7ZsD+YkxtyOWMep2FJT3usVPD/ybU=; b=Z6JFuhqMt+qpc9rxSanHrM2nQa0s1p+Vaj0ZM0ZA5uE+wlhzVh1NT1PxCVzsCs1iay aVJK77uOqHoj7rMh8A1/FQqXDkSdkv3XG0Mrp7Q6lSrSGiXPwjHCVJy3637cZqAOuwYw bEd6qSo0K87sqA4PajUyNAitTAGVxCn5yVrOY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Vw/hp+C1d3vT3b7ZsD+YkxtyOWMep2FJT3usVPD/ybU=; b=NeW5I7JZiZFbE/OdCo7NiO5nDbnzxGaUdG3ooz3LKsWelhPlK7iFXwlgBlPmj5KEpL Syepv0EZgQuFFkg0fuBJDAoBvGcRd70TWzTszjW4MkEZLyQevSqeEHoBD1/HQrNyIqrS Its1bseGinu55aDCkVgss2mvsFjBOmdeYi1lB78qUx/XxL2NiNma+6OZxRSD5kdNUE6n WH9hM4mDSiKXMmoaVaYj0v9thPs0i1fqgL9FNyTExTvQQe4am15JE0K2VThi3yLBLclw Gf9nB317CuM6fNC+xLQNQu3dcOx7+ZAoL2chv07icu3UWE6MTZuDWI9Y36FhUk/9FS11 gcSg== X-Gm-Message-State: AMCzsaXRo2uW6beVdefRbGZlxSljJnC92FgdQ5Nrk2JRxL9GqvSC2fAU RLXSC29oP4BRK6UBSgdvKVA+kunJ1z0= X-Google-Smtp-Source: AOwi7QAPcU2fSe69dQDidCb1GYO2K2T1k9cVIxoUhAzKwaCRItzRY33flgGh1uRIe3I4k+t2FNoHYw== X-Received: by 10.98.75.221 with SMTP id d90mr9496235pfj.90.1508174825070; Mon, 16 Oct 2017 10:27:05 -0700 (PDT) Received: from cloudburst.twiddle.net (97-126-104-76.tukw.qwest.net. [97.126.104.76]) by smtp.gmail.com with ESMTPSA id i187sm5594249pfc.96.2017.10.16.10.27.03 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 16 Oct 2017 10:27:04 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Mon, 16 Oct 2017 10:25:56 -0700 Message-Id: <20171016172609.23422-38-richard.henderson@linaro.org> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171016172609.23422-1-richard.henderson@linaro.org> References: <20171016172609.23422-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c00::236 Subject: [Qemu-devel] [PATCH v6 37/50] tcg: Remove CF_IGNORE_ICOUNT 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: cota@braap.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Now that we have curr_cflags, we can include CF_USE_ICOUNT early and then remove it as necessary. Signed-off-by: Richard Henderson --- include/exec/exec-all.h | 17 +++++++++-------- accel/tcg/cpu-exec.c | 16 +++++++++------- accel/tcg/translate-all.c | 3 --- 3 files changed, 18 insertions(+), 18 deletions(-) -- 2.13.6 diff --git a/include/exec/exec-all.h b/include/exec/exec-all.h index a3bd3e7abd..f14c6a56eb 100644 --- a/include/exec/exec-all.h +++ b/include/exec/exec-all.h @@ -22,6 +22,7 @@ #include "qemu-common.h" #include "exec/tb-context.h" +#include "sysemu/cpus.h" /* allow to see translation results - the slowdown should be negligible, so we leave it */ #define DEBUG_DISAS @@ -319,13 +320,12 @@ struct TranslationBlock { size <= TARGET_PAGE_SIZE) */ uint16_t icount; uint32_t cflags; /* compile flags */ -#define CF_COUNT_MASK 0x7fff -#define CF_LAST_IO 0x8000 /* Last insn may be an IO access. */ -#define CF_NOCACHE 0x10000 /* To be freed after execution */ -#define CF_USE_ICOUNT 0x20000 -#define CF_IGNORE_ICOUNT 0x40000 /* Do not generate icount code */ -#define CF_INVALID 0x80000 /* TB is stale. Setters must acquire tb_lock */ -#define CF_PARALLEL 0x100000 /* Generate code for a parallel context */ +#define CF_COUNT_MASK 0x00007fff +#define CF_LAST_IO 0x00008000 /* Last insn may be an IO access. */ +#define CF_NOCACHE 0x00010000 /* To be freed after execution */ +#define CF_USE_ICOUNT 0x00020000 +#define CF_INVALID 0x00040000 /* TB is stale. Setters need tb_lock */ +#define CF_PARALLEL 0x00080000 /* Generate code for a parallel context */ /* cflags' mask for hashing/comparison */ #define CF_HASH_MASK \ (CF_COUNT_MASK | CF_LAST_IO | CF_USE_ICOUNT | CF_PARALLEL) @@ -380,7 +380,8 @@ static inline uint32_t tb_cflags(const TranslationBlock *tb) /* current cflags for hashing/comparison */ static inline uint32_t curr_cflags(void) { - return parallel_cpus ? CF_PARALLEL : 0; + return (parallel_cpus ? CF_PARALLEL : 0) + | (use_icount ? CF_USE_ICOUNT : 0); } void tb_free(TranslationBlock *tb); diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c index 0eecbccebc..59fd784436 100644 --- a/accel/tcg/cpu-exec.c +++ b/accel/tcg/cpu-exec.c @@ -198,17 +198,19 @@ static void cpu_exec_nocache(CPUState *cpu, int max_cycles, TranslationBlock *orig_tb, bool ignore_icount) { TranslationBlock *tb; + uint32_t cflags = curr_cflags() | CF_NOCACHE; + + if (ignore_icount) { + cflags &= ~CF_USE_ICOUNT; + } /* Should never happen. We only end up here when an existing TB is too long. */ - if (max_cycles > CF_COUNT_MASK) - max_cycles = CF_COUNT_MASK; + cflags |= MIN(max_cycles, CF_COUNT_MASK); tb_lock(); - tb = tb_gen_code(cpu, orig_tb->pc, orig_tb->cs_base, orig_tb->flags, - max_cycles | CF_NOCACHE - | (ignore_icount ? CF_IGNORE_ICOUNT : 0) - | curr_cflags()); + tb = tb_gen_code(cpu, orig_tb->pc, orig_tb->cs_base, + orig_tb->flags, cflags); tb->orig_tb = orig_tb; tb_unlock(); @@ -229,7 +231,7 @@ void cpu_exec_step_atomic(CPUState *cpu) TranslationBlock *tb; target_ulong cs_base, pc; uint32_t flags; - uint32_t cflags = 1 | CF_IGNORE_ICOUNT; + uint32_t cflags = 1; uint32_t cf_mask = cflags & CF_HASH_MASK; if (sigsetjmp(cpu->jmp_env, 0) == 0) { diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c index d3dee985b4..d6b3bc0a38 100644 --- a/accel/tcg/translate-all.c +++ b/accel/tcg/translate-all.c @@ -1274,9 +1274,6 @@ TranslationBlock *tb_gen_code(CPUState *cpu, assert_memory_lock(); phys_pc = get_page_addr_code(env, pc); - if (use_icount && !(cflags & CF_IGNORE_ICOUNT)) { - cflags |= CF_USE_ICOUNT; - } tb = tb_alloc(pc); if (unlikely(!tb)) { From patchwork Mon Oct 16 17:25:57 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 115972 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp3961744qgn; Mon, 16 Oct 2017 10:59:41 -0700 (PDT) X-Received: by 10.237.60.154 with SMTP id d26mr14133628qtf.227.1508176781345; Mon, 16 Oct 2017 10:59:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508176781; cv=none; d=google.com; s=arc-20160816; b=Xo7H4ffgYrJGJraw2QjMR7F+zQ9RZtKNMwfZI+oS4krVr+IhKMVk9pCwtcA7RfvLpI TzPNZ9NIMyKg6PU7qIOTA2ovKMZOPI2T2TB5MGEpeBsMh31a8EltV2v7kHZ7HfjUU/Gg gOkbjV9ADYl5LOlspYnLrV8mmZy/kKPp03taFtDW2JVARWjYG08joqp9qxXfpP7KdO9Z 5pEiBepqJUHDdLxTC6AuO64yAmCQ+t8BsE/GixuDHzGkGkGS9IgXPow7To1agWicf74R UkzodUFWXxIdzQJRxwOnnvhWFeUG3C343xmMk1fVnzv3kDmLIeoF5V++Ii2KDFPHhuAR JduQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=4eLQGwLbfn+m/deJ/0OTHG97Y6YcJ69T4LHmy2PbIMc=; b=T07vP4vF3qO4k9qPNBwnUtCahLlwU4cthVvK8llIh/bNWgMTb9UVOovkZPZBHJDs6y xXr31feQ4Lf10yz4wMxF1VffbXs5x8wh4rcNbJpx5c9Rti5JjOuMfQrYDFh2CwOuFOdW f9EVW0iAykuO5a4lDTveEx1VIunC5TiADjK4gha6VhOC7DmtUaaQi5ZPrHOOeM9+MSqn i6oOdf1f3Rm9mMU6PGlsT1bGI3HoursIxgUmMNjP+bGV4ynp9ua56FxkyDmMkbtS9sZU 64hKGQ2pNZvakzRomViWtMwb9N53V7Maha0g0l1C3L0xXDjVpQNk0b07/8Bl7lJvEBG6 lEug== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=BJgeJS8E; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id z57si1014206qtb.125.2017.10.16.10.59.40 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 16 Oct 2017 10:59:41 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=BJgeJS8E; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:34438 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e49fv-0005Xj-36 for patch@linaro.org; Mon, 16 Oct 2017 13:59:39 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52709) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e49AU-0002kr-8H for qemu-devel@nongnu.org; Mon, 16 Oct 2017 13:27:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e49AS-0003tB-5r for qemu-devel@nongnu.org; Mon, 16 Oct 2017 13:27:10 -0400 Received: from mail-pg0-x235.google.com ([2607:f8b0:400e:c05::235]:47624) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e49AR-0003sV-T3 for qemu-devel@nongnu.org; Mon, 16 Oct 2017 13:27:08 -0400 Received: by mail-pg0-x235.google.com with SMTP id r25so7349502pgn.4 for ; Mon, 16 Oct 2017 10:27:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=4eLQGwLbfn+m/deJ/0OTHG97Y6YcJ69T4LHmy2PbIMc=; b=BJgeJS8ExdzEY2WaD3xf6TbpuIB9SdWsGyfjcOPGKaJFrPwgDZHu1kBWMm2FyxiLOM RBH5SY5vyzvyD44YYrxkCBEp0LWldz0WX2oDYdUUPXDnvEsCvsTBr6/bJxiTmDMqHqBI W6T4HZ4QkSLLnN5rt82vmL97r9zeQF/HaEwyQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=4eLQGwLbfn+m/deJ/0OTHG97Y6YcJ69T4LHmy2PbIMc=; b=pF6+9jF6XfN0s9iT1JPYd5yRU2X01J5swXUMMJmktSbV0QauiYWUfszVn83FbD2g1M qn6rE1WMQRFdvGqQZiAzIHAnF/DW8dXc3esMiHtNDhAudWSZHm0rGyLBfoC1oxN85IJX fizGG61+GbkjFCCpYJOLRlhdlbjwKCzcPtnqbvACoSJtTTobUdif2ypoqQc/XmLafdhO Y9WVIOCyi9CdaBYyW86ztBY0gYwgQrVgu76zEnm53yHwBtlZ8XemvOHjPGvrYWwI9JDg y7p5s7saTuQHvZ+Y1bSvGhtlCTts01IDiBzwBBU/PlPDDTWVdUP7wm82tQXER0bkPkHH mSkg== X-Gm-Message-State: AMCzsaWyMZnLwjADr4NJtVr0mL4DA5F1DmeGclf+2xNUvMEQNbB2Y+GQ 5KxDHmiY0Y7q9SiKXIjlfJD74Nhr2qI= X-Google-Smtp-Source: ABhQp+RHnoBo/QE+Df322R2k5h/miy1zE6g5ciI0LCBgTO+fap16Z6xKhvV+wDwrWv2qflOt1z20oQ== X-Received: by 10.101.69.8 with SMTP id n8mr826427pgq.79.1508174826470; Mon, 16 Oct 2017 10:27:06 -0700 (PDT) Received: from cloudburst.twiddle.net (97-126-104-76.tukw.qwest.net. [97.126.104.76]) by smtp.gmail.com with ESMTPSA id i187sm5594249pfc.96.2017.10.16.10.27.05 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 16 Oct 2017 10:27:05 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Mon, 16 Oct 2017 10:25:57 -0700 Message-Id: <20171016172609.23422-39-richard.henderson@linaro.org> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171016172609.23422-1-richard.henderson@linaro.org> References: <20171016172609.23422-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c05::235 Subject: [Qemu-devel] [PATCH v6 38/50] translate-all: use a binary search tree to track TBs in TBContext 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: cota@braap.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: "Emilio G. Cota" This is a prerequisite for supporting multiple TCG contexts, since we will have threads generating code in separate regions of code_gen_buffer. For this we need a new field (.size) in struct tb_tc to keep track of the size of the translated code. This field uses a size_t to avoid adding a hole to the struct, although really an unsigned int would have been enough. The comparison function we use is optimized for the common case: insertions. Profiling shows that upon booting debian-arm, 98% of comparisons are between existing tb's (i.e. a->size and b->size are both !0), which happens during insertions (and removals, but those are rare). The remaining cases are lookups. From reading the glib sources we see that the first key is always the lookup key. However, the code does not assume this to always be the case because this behaviour is not guaranteed in the glib docs. However, we embed this knowledge in the code as a branch hint for the compiler. Note that tb_free does not free space in the code_gen_buffer anymore, since we cannot easily know whether the tb is the last one inserted in code_gen_buffer. The next patch in this series renames tb_free to tb_remove to reflect this. Performance-wise, lookups in tb_find_pc are the same as before: O(log n). However, insertions are O(log n) instead of O(1), which results in a small slowdown when booting debian-arm: Performance counter stats for 'build/arm-softmmu/qemu-system-arm \ -machine type=virt -nographic -smp 1 -m 4096 \ -netdev user,id=unet,hostfwd=tcp::2222-:22 \ -device virtio-net-device,netdev=unet \ -drive file=img/arm/jessie-arm32.qcow2,id=myblock,index=0,if=none \ -device virtio-blk-device,drive=myblock \ -kernel img/arm/aarch32-current-linux-kernel-only.img \ -append console=ttyAMA0 root=/dev/vda1 \ -name arm,debug-threads=on -smp 1' (10 runs): - Before: 8048.598422 task-clock (msec) # 0.931 CPUs utilized ( +- 0.28% ) 16,974 context-switches # 0.002 M/sec ( +- 0.12% ) 0 cpu-migrations # 0.000 K/sec 10,125 page-faults # 0.001 M/sec ( +- 1.23% ) 35,144,901,879 cycles # 4.367 GHz ( +- 0.14% ) stalled-cycles-frontend stalled-cycles-backend 65,758,252,643 instructions # 1.87 insns per cycle ( +- 0.33% ) 10,871,298,668 branches # 1350.707 M/sec ( +- 0.41% ) 192,322,212 branch-misses # 1.77% of all branches ( +- 0.32% ) 8.640869419 seconds time elapsed ( +- 0.57% ) - After: 8146.242027 task-clock (msec) # 0.923 CPUs utilized ( +- 1.23% ) 17,016 context-switches # 0.002 M/sec ( +- 0.40% ) 0 cpu-migrations # 0.000 K/sec 18,769 page-faults # 0.002 M/sec ( +- 0.45% ) 35,660,956,120 cycles # 4.378 GHz ( +- 1.22% ) stalled-cycles-frontend stalled-cycles-backend 65,095,366,607 instructions # 1.83 insns per cycle ( +- 1.73% ) 10,803,480,261 branches # 1326.192 M/sec ( +- 1.95% ) 195,601,289 branch-misses # 1.81% of all branches ( +- 0.39% ) 8.828660235 seconds time elapsed ( +- 0.38% ) Reviewed-by: Richard Henderson Signed-off-by: Emilio G. Cota --- include/exec/exec-all.h | 5 ++ include/exec/tb-context.h | 4 +- accel/tcg/translate-all.c | 217 ++++++++++++++++++++++++---------------------- 3 files changed, 118 insertions(+), 108 deletions(-) -- 2.13.6 Signed-off-by: Emilio G. Cota diff --git a/include/exec/exec-all.h b/include/exec/exec-all.h index f14c6a56eb..4c4242a1d8 100644 --- a/include/exec/exec-all.h +++ b/include/exec/exec-all.h @@ -306,10 +306,15 @@ static inline void tb_invalidate_phys_addr(AddressSpace *as, hwaddr addr) /* * Translation Cache-related fields of a TB. + * This struct exists just for convenience; we keep track of TB's in a binary + * search tree, and the only fields needed to compare TB's in the tree are + * @ptr and @size. @search is brought here for consistency, since it is also + * a TC-related field. */ struct tb_tc { void *ptr; /* pointer to the translated code */ uint8_t *search; /* pointer to search data */ + size_t size; }; struct TranslationBlock { diff --git a/include/exec/tb-context.h b/include/exec/tb-context.h index 25c2afe753..1fa8dcc737 100644 --- a/include/exec/tb-context.h +++ b/include/exec/tb-context.h @@ -31,10 +31,8 @@ typedef struct TBContext TBContext; struct TBContext { - TranslationBlock **tbs; + GTree *tb_tree; struct qht htable; - size_t tbs_size; - int nb_tbs; /* any access to the tbs or the page table must use this lock */ QemuMutex tb_lock; diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c index d6b3bc0a38..083e1c7336 100644 --- a/accel/tcg/translate-all.c +++ b/accel/tcg/translate-all.c @@ -776,6 +776,48 @@ static inline void *alloc_code_gen_buffer(void) } #endif /* USE_STATIC_CODE_GEN_BUFFER, WIN32, POSIX */ +/* compare a pointer @ptr and a tb_tc @s */ +static int ptr_cmp_tb_tc(const void *ptr, const struct tb_tc *s) +{ + if (ptr >= s->ptr + s->size) { + return 1; + } else if (ptr < s->ptr) { + return -1; + } + return 0; +} + +static gint tb_tc_cmp(gconstpointer ap, gconstpointer bp) +{ + const struct tb_tc *a = ap; + const struct tb_tc *b = bp; + + /* + * When both sizes are set, we know this isn't a lookup. + * This is the most likely case: every TB must be inserted; lookups + * are a lot less frequent. + */ + if (likely(a->size && b->size)) { + if (a->ptr > b->ptr) { + return 1; + } else if (a->ptr < b->ptr) { + return -1; + } + /* a->ptr == b->ptr should happen only on deletions */ + g_assert(a->size == b->size); + return 0; + } + /* + * All lookups have either .size field set to 0. + * From the glib sources we see that @ap is always the lookup key. However + * the docs provide no guarantee, so we just mark this case as likely. + */ + if (likely(a->size == 0)) { + return ptr_cmp_tb_tc(a->ptr, b); + } + return ptr_cmp_tb_tc(b->ptr, a); +} + static inline void code_gen_alloc(size_t tb_size) { tcg_ctx.code_gen_buffer_size = size_code_gen_buffer(tb_size); @@ -784,15 +826,7 @@ static inline void code_gen_alloc(size_t tb_size) fprintf(stderr, "Could not allocate dynamic translator buffer\n"); exit(1); } - - /* size this conservatively -- realloc later if needed */ - tcg_ctx.tb_ctx.tbs_size = - tcg_ctx.code_gen_buffer_size / CODE_GEN_AVG_BLOCK_SIZE / 8; - if (unlikely(!tcg_ctx.tb_ctx.tbs_size)) { - tcg_ctx.tb_ctx.tbs_size = 64 * 1024; - } - tcg_ctx.tb_ctx.tbs = g_new(TranslationBlock *, tcg_ctx.tb_ctx.tbs_size); - + tcg_ctx.tb_ctx.tb_tree = g_tree_new(tb_tc_cmp); qemu_mutex_init(&tcg_ctx.tb_ctx.tb_lock); } @@ -829,7 +863,6 @@ void tcg_exec_init(unsigned long tb_size) static TranslationBlock *tb_alloc(target_ulong pc) { TranslationBlock *tb; - TBContext *ctx; assert_tb_locked(); @@ -837,12 +870,6 @@ static TranslationBlock *tb_alloc(target_ulong pc) if (unlikely(tb == NULL)) { return NULL; } - ctx = &tcg_ctx.tb_ctx; - if (unlikely(ctx->nb_tbs == ctx->tbs_size)) { - ctx->tbs_size *= 2; - ctx->tbs = g_renew(TranslationBlock *, ctx->tbs, ctx->tbs_size); - } - ctx->tbs[ctx->nb_tbs++] = tb; return tb; } @@ -851,16 +878,7 @@ void tb_free(TranslationBlock *tb) { assert_tb_locked(); - /* In practice this is mostly used for single use temporary TB - Ignore the hard cases and just back up if this TB happens to - be the last one generated. */ - if (tcg_ctx.tb_ctx.nb_tbs > 0 && - tb == tcg_ctx.tb_ctx.tbs[tcg_ctx.tb_ctx.nb_tbs - 1]) { - size_t struct_size = ROUND_UP(sizeof(*tb), qemu_icache_linesize); - - tcg_ctx.code_gen_ptr = tb->tc.ptr - struct_size; - tcg_ctx.tb_ctx.nb_tbs--; - } + g_tree_remove(tcg_ctx.tb_ctx.tb_tree, &tb->tc); } static inline void invalidate_page_bitmap(PageDesc *p) @@ -918,11 +936,12 @@ static void do_tb_flush(CPUState *cpu, run_on_cpu_data tb_flush_count) } if (DEBUG_TB_FLUSH_GATE) { - printf("qemu: flush code_size=%td nb_tbs=%d avg_tb_size=%td\n", - tcg_ctx.code_gen_ptr - tcg_ctx.code_gen_buffer, - tcg_ctx.tb_ctx.nb_tbs, tcg_ctx.tb_ctx.nb_tbs > 0 ? - (tcg_ctx.code_gen_ptr - tcg_ctx.code_gen_buffer) / - tcg_ctx.tb_ctx.nb_tbs : 0); + size_t nb_tbs = g_tree_nnodes(tcg_ctx.tb_ctx.tb_tree); + + printf("qemu: flush code_size=%td nb_tbs=%zu avg_tb_size=%td\n", + tcg_ctx.code_gen_ptr - tcg_ctx.code_gen_buffer, nb_tbs, + nb_tbs > 0 ? + (tcg_ctx.code_gen_ptr - tcg_ctx.code_gen_buffer) / nb_tbs : 0); } if ((unsigned long)(tcg_ctx.code_gen_ptr - tcg_ctx.code_gen_buffer) > tcg_ctx.code_gen_buffer_size) { @@ -933,7 +952,10 @@ static void do_tb_flush(CPUState *cpu, run_on_cpu_data tb_flush_count) cpu_tb_jmp_cache_clear(cpu); } - tcg_ctx.tb_ctx.nb_tbs = 0; + /* Increment the refcount first so that destroy acts as a reset */ + g_tree_ref(tcg_ctx.tb_ctx.tb_tree); + g_tree_destroy(tcg_ctx.tb_ctx.tb_tree); + qht_reset_size(&tcg_ctx.tb_ctx.htable, CODE_GEN_HTABLE_SIZE); page_flush_tb(); @@ -1340,6 +1362,7 @@ TranslationBlock *tb_gen_code(CPUState *cpu, if (unlikely(search_size < 0)) { goto buffer_overflow; } + tb->tc.size = gen_code_size; #ifdef CONFIG_PROFILER tcg_ctx.code_time += profile_getclock() - ti; @@ -1410,6 +1433,7 @@ TranslationBlock *tb_gen_code(CPUState *cpu, * through the physical hash table and physical page list. */ tb_link_page(tb, phys_pc, phys_page2); + g_tree_insert(tcg_ctx.tb_ctx.tb_tree, &tb->tc, tb); return tb; } @@ -1670,37 +1694,16 @@ static bool tb_invalidate_phys_page(tb_page_addr_t addr, uintptr_t pc) } #endif -/* find the TB 'tb' such that tb[0].tc_ptr <= tc_ptr < - tb[1].tc_ptr. Return NULL if not found */ +/* + * Find the TB 'tb' such that + * tb->tc.ptr <= tc_ptr < tb->tc.ptr + tb->tc.size + * Return NULL if not found. + */ static TranslationBlock *tb_find_pc(uintptr_t tc_ptr) { - int m_min, m_max, m; - uintptr_t v; - TranslationBlock *tb; + struct tb_tc s = { .ptr = (void *)tc_ptr }; - if (tcg_ctx.tb_ctx.nb_tbs <= 0) { - return NULL; - } - if (tc_ptr < (uintptr_t)tcg_ctx.code_gen_buffer || - tc_ptr >= (uintptr_t)tcg_ctx.code_gen_ptr) { - return NULL; - } - /* binary search (cf Knuth) */ - m_min = 0; - m_max = tcg_ctx.tb_ctx.nb_tbs - 1; - while (m_min <= m_max) { - m = (m_min + m_max) >> 1; - tb = tcg_ctx.tb_ctx.tbs[m]; - v = (uintptr_t)tb->tc.ptr; - if (v == tc_ptr) { - return tb; - } else if (tc_ptr < v) { - m_max = m - 1; - } else { - m_min = m + 1; - } - } - return tcg_ctx.tb_ctx.tbs[m_max]; + return g_tree_lookup(tcg_ctx.tb_ctx.tb_tree, &s); } #if !defined(CONFIG_USER_ONLY) @@ -1886,63 +1889,67 @@ static void print_qht_statistics(FILE *f, fprintf_function cpu_fprintf, g_free(hgram); } +struct tb_tree_stats { + size_t target_size; + size_t max_target_size; + size_t direct_jmp_count; + size_t direct_jmp2_count; + size_t cross_page; +}; + +static gboolean tb_tree_stats_iter(gpointer key, gpointer value, gpointer data) +{ + const TranslationBlock *tb = value; + struct tb_tree_stats *tst = data; + + tst->target_size += tb->size; + if (tb->size > tst->max_target_size) { + tst->max_target_size = tb->size; + } + if (tb->page_addr[1] != -1) { + tst->cross_page++; + } + if (tb->jmp_reset_offset[0] != TB_JMP_RESET_OFFSET_INVALID) { + tst->direct_jmp_count++; + if (tb->jmp_reset_offset[1] != TB_JMP_RESET_OFFSET_INVALID) { + tst->direct_jmp2_count++; + } + } + return false; +} + void dump_exec_info(FILE *f, fprintf_function cpu_fprintf) { - int i, target_code_size, max_target_code_size; - int direct_jmp_count, direct_jmp2_count, cross_page; - TranslationBlock *tb; + struct tb_tree_stats tst = {}; struct qht_stats hst; + size_t nb_tbs; tb_lock(); - target_code_size = 0; - max_target_code_size = 0; - cross_page = 0; - direct_jmp_count = 0; - direct_jmp2_count = 0; - for (i = 0; i < tcg_ctx.tb_ctx.nb_tbs; i++) { - tb = tcg_ctx.tb_ctx.tbs[i]; - target_code_size += tb->size; - if (tb->size > max_target_code_size) { - max_target_code_size = tb->size; - } - if (tb->page_addr[1] != -1) { - cross_page++; - } - if (tb->jmp_reset_offset[0] != TB_JMP_RESET_OFFSET_INVALID) { - direct_jmp_count++; - if (tb->jmp_reset_offset[1] != TB_JMP_RESET_OFFSET_INVALID) { - direct_jmp2_count++; - } - } - } + nb_tbs = g_tree_nnodes(tcg_ctx.tb_ctx.tb_tree); + g_tree_foreach(tcg_ctx.tb_ctx.tb_tree, tb_tree_stats_iter, &tst); /* XXX: avoid using doubles ? */ cpu_fprintf(f, "Translation buffer state:\n"); cpu_fprintf(f, "gen code size %td/%zd\n", tcg_ctx.code_gen_ptr - tcg_ctx.code_gen_buffer, tcg_ctx.code_gen_highwater - tcg_ctx.code_gen_buffer); - cpu_fprintf(f, "TB count %d\n", tcg_ctx.tb_ctx.nb_tbs); - cpu_fprintf(f, "TB avg target size %d max=%d bytes\n", - tcg_ctx.tb_ctx.nb_tbs ? target_code_size / - tcg_ctx.tb_ctx.nb_tbs : 0, - max_target_code_size); + cpu_fprintf(f, "TB count %zu\n", nb_tbs); + cpu_fprintf(f, "TB avg target size %zu max=%zu bytes\n", + nb_tbs ? tst.target_size / nb_tbs : 0, + tst.max_target_size); cpu_fprintf(f, "TB avg host size %td bytes (expansion ratio: %0.1f)\n", - tcg_ctx.tb_ctx.nb_tbs ? (tcg_ctx.code_gen_ptr - - tcg_ctx.code_gen_buffer) / - tcg_ctx.tb_ctx.nb_tbs : 0, - target_code_size ? (double) (tcg_ctx.code_gen_ptr - - tcg_ctx.code_gen_buffer) / - target_code_size : 0); - cpu_fprintf(f, "cross page TB count %d (%d%%)\n", cross_page, - tcg_ctx.tb_ctx.nb_tbs ? (cross_page * 100) / - tcg_ctx.tb_ctx.nb_tbs : 0); - cpu_fprintf(f, "direct jump count %d (%d%%) (2 jumps=%d %d%%)\n", - direct_jmp_count, - tcg_ctx.tb_ctx.nb_tbs ? (direct_jmp_count * 100) / - tcg_ctx.tb_ctx.nb_tbs : 0, - direct_jmp2_count, - tcg_ctx.tb_ctx.nb_tbs ? (direct_jmp2_count * 100) / - tcg_ctx.tb_ctx.nb_tbs : 0); + nb_tbs ? (tcg_ctx.code_gen_ptr - + tcg_ctx.code_gen_buffer) / nb_tbs : 0, + tst.target_size ? (double) (tcg_ctx.code_gen_ptr - + tcg_ctx.code_gen_buffer) / + tst.target_size : 0); + cpu_fprintf(f, "cross page TB count %zu (%zu%%)\n", tst.cross_page, + nb_tbs ? (tst.cross_page * 100) / nb_tbs : 0); + cpu_fprintf(f, "direct jump count %zu (%zu%%) (2 jumps=%zu %zu%%)\n", + tst.direct_jmp_count, + nb_tbs ? (tst.direct_jmp_count * 100) / nb_tbs : 0, + tst.direct_jmp2_count, + nb_tbs ? (tst.direct_jmp2_count * 100) / nb_tbs : 0); qht_statistics_init(&tcg_ctx.tb_ctx.htable, &hst); print_qht_statistics(f, cpu_fprintf, hst); From patchwork Mon Oct 16 17:25:58 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 115960 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp3954672qgn; Mon, 16 Oct 2017 10:50:49 -0700 (PDT) X-Received: by 10.55.150.195 with SMTP id y186mr15099638qkd.228.1508176249266; Mon, 16 Oct 2017 10:50:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508176249; cv=none; d=google.com; s=arc-20160816; b=Qj7btWw2LGfeYi3hdohRCgUpNgUPMbeDk4l+OzSVahCpZNknhCqpA5V+g+bkKwlzwu pI3DZUWRX4LNUqtbp4juPVADj60snpdYyUPPUbr3cepC8LqeSQ4YAJPnnkdeTWFms80B 2AZGWgZQ3kHDLfuIgNB+GSRp0h8J+cTYfmQ/HVYUnTkM70l2usjahSdHYLz62wyAxmJh qpL+JwqwZfrO3aW1bMmbjGgy5PmHZ0TJu392AqKkyKAHN+IKGK57hL1+nDEQ81gA29xk 8/doWFWoPyiF6vZLboc0m6yuAiWNb7dTg+cB15N0HlL9QAx6YQFrpHQNqf4Xik+t2HLI w1HA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=rKW+KdkvOF9EOXRo7dmyn5uHsd88uC8X4HeG4p5K65U=; b=vpnuIRO374oMmbywnh21MBzkghJCQ3OjXJwveGil0yGawM0s/3a1C64IoTSLMInqpq It9dzPUDAc7m3pT9sgtrvNUInCS2PlIN8c72eMx9eCtct8Q9k/RETzwex96xHRPVD2MV /qorPPSVwwqixrbMrSVTnA77DNkbkHPp1nuTZnBq5f6F5PKkTp+ihodmlJnuSckIzPrj 9cw/OdwHotAiVHX+bslqtaGts1lJ63QzsinILB8IOmK6Ie7ISLr/uqeQXXWr4skV41Ao 0gH1niA1ycDF2wKIDAIi7GT4i/1OURyAIP/xrK0OOJxrjaEyj7/wLyKzmfzxkoCPQGWX 6HWg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=bQVxkSQ5; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id n6si7132365qtc.308.2017.10.16.10.50.48 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 16 Oct 2017 10:50:49 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=bQVxkSQ5; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:34391 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e49XL-0005II-1f for patch@linaro.org; Mon, 16 Oct 2017 13:50:47 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52732) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e49AY-0002mN-Bg for qemu-devel@nongnu.org; Mon, 16 Oct 2017 13:27:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e49AT-0003uI-CY for qemu-devel@nongnu.org; Mon, 16 Oct 2017 13:27:12 -0400 Received: from mail-pg0-x22f.google.com ([2607:f8b0:400e:c05::22f]:51122) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e49AT-0003tg-88 for qemu-devel@nongnu.org; Mon, 16 Oct 2017 13:27:09 -0400 Received: by mail-pg0-x22f.google.com with SMTP id y7so7343538pgb.7 for ; Mon, 16 Oct 2017 10:27:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=rKW+KdkvOF9EOXRo7dmyn5uHsd88uC8X4HeG4p5K65U=; b=bQVxkSQ5W+lkHlM6fURtZ9FSAwBbVMjwxofuXMmGOe810itLIC9/ZR7ayMpbJSgYp5 KKhFVapWqSGNKTp85iimCUJoZn0F0FcMZCl/Us/bBQSywabXeqeKWhH5XswW+4/6FtOp wvLx2eOKrRnG/kewNttbCZ0T1EZ0V0E811Q10= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=rKW+KdkvOF9EOXRo7dmyn5uHsd88uC8X4HeG4p5K65U=; b=JJw93jyo+a8563MXs+2ZpOvnxRkhau+zHPp9uC5inaMvUWb1UZ2vTGJs37RTme4s13 VXXWbNDRYRGJ7r9QIlcv/fjQjUeXFgxuUppkymDJ+N4mcdV2/bVUoBRAIVPtTCKB+TQL qKEVQAmfJGq2gmPuCj7IisM2uDhZlnpydAKZPFwSsU1qSLBPIbPk3Guemd5tdQYccicd gr5tAbEe7+Qtr2J6WIlnIfiI66eiz7yZ3e57Rn5RfDFizhcuQWFdykecCkGMxp0s21ww AlywFWqZmrsZFB64dA/HCsvEhSzBDTpyn59KAAX3BW/7Ygb5zkjuwZ+23a1GktnEREsE n/gw== X-Gm-Message-State: AMCzsaXIPbknFwxBvi6su22NG7Urgfhmw6DSu6aSRqCyYFzAbZIKN/ur Djlz/12tsyno5N/B3BPrtDdWcrHpzYk= X-Google-Smtp-Source: AOwi7QBQT8sMxMIUTxJoDBqmdL36DvXBx3DxTmX8P4O7BQNDBzclBPeU4N8xTB0Yk20V8nb9Y5pkxw== X-Received: by 10.84.171.195 with SMTP id l61mr9417701plb.64.1508174828101; Mon, 16 Oct 2017 10:27:08 -0700 (PDT) Received: from cloudburst.twiddle.net (97-126-104-76.tukw.qwest.net. [97.126.104.76]) by smtp.gmail.com with ESMTPSA id i187sm5594249pfc.96.2017.10.16.10.27.06 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 16 Oct 2017 10:27:06 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Mon, 16 Oct 2017 10:25:58 -0700 Message-Id: <20171016172609.23422-40-richard.henderson@linaro.org> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171016172609.23422-1-richard.henderson@linaro.org> References: <20171016172609.23422-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c05::22f Subject: [Qemu-devel] [PATCH v6 39/50] exec-all: rename tb_free to tb_remove 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: cota@braap.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: "Emilio G. Cota" We don't really free anything in this function anymore; we just remove the TB from the binary search tree. Suggested-by: Alex BennĂ©e Reviewed-by: Richard Henderson Signed-off-by: Emilio G. Cota --- include/exec/exec-all.h | 2 +- accel/tcg/cpu-exec.c | 2 +- accel/tcg/translate-all.c | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) -- 2.13.6 diff --git a/include/exec/exec-all.h b/include/exec/exec-all.h index 4c4242a1d8..746f4be71e 100644 --- a/include/exec/exec-all.h +++ b/include/exec/exec-all.h @@ -389,7 +389,7 @@ static inline uint32_t curr_cflags(void) | (use_icount ? CF_USE_ICOUNT : 0); } -void tb_free(TranslationBlock *tb); +void tb_remove(TranslationBlock *tb); void tb_flush(CPUState *cpu); void tb_phys_invalidate(TranslationBlock *tb, tb_page_addr_t page_addr); TranslationBlock *tb_htable_lookup(CPUState *cpu, target_ulong pc, diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c index 59fd784436..6a4a33235b 100644 --- a/accel/tcg/cpu-exec.c +++ b/accel/tcg/cpu-exec.c @@ -220,7 +220,7 @@ static void cpu_exec_nocache(CPUState *cpu, int max_cycles, tb_lock(); tb_phys_invalidate(tb, -1); - tb_free(tb); + tb_remove(tb); tb_unlock(); } #endif diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c index 083e1c7336..76db9c775a 100644 --- a/accel/tcg/translate-all.c +++ b/accel/tcg/translate-all.c @@ -375,7 +375,7 @@ bool cpu_restore_state(CPUState *cpu, uintptr_t retaddr) if (tb->cflags & CF_NOCACHE) { /* one-shot translation, invalidate it immediately */ tb_phys_invalidate(tb, -1); - tb_free(tb); + tb_remove(tb); } r = true; } @@ -874,7 +874,7 @@ static TranslationBlock *tb_alloc(target_ulong pc) } /* Called with tb_lock held. */ -void tb_free(TranslationBlock *tb) +void tb_remove(TranslationBlock *tb) { assert_tb_locked(); @@ -1816,7 +1816,7 @@ void cpu_io_recompile(CPUState *cpu, uintptr_t retaddr) * cpu_exec_nocache() */ tb_phys_invalidate(tb->orig_tb, -1); } - tb_free(tb); + tb_remove(tb); } /* FIXME: In theory this could raise an exception. In practice we have already translated the block once so it's probably ok. */ From patchwork Mon Oct 16 17:25:59 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 115974 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp3965081qgn; Mon, 16 Oct 2017 11:02:26 -0700 (PDT) X-Received: by 10.237.54.42 with SMTP id e39mr15641681qtb.87.1508176946583; Mon, 16 Oct 2017 11:02:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508176946; cv=none; d=google.com; s=arc-20160816; b=ehFu11+jhYDwVhj+odBqd/ks2qA9N5JjYu6Da6xWpy46Bb/MH9g/R3p7woanRf2tsY z2rCGmhMKsoPqSGKTN2B84AiFkrHEyaji7YHfPJIiyyu9E+V548B+gsUBGAPKuAYLwN3 GtgqlynBRz3Gg8cz4Eojjgw8+GHFtSbqtsvaQovpYnweXXqexYDDNFI1tT2FiJe+RtAF Gs1bsu7fYc+TFruOkHvuo1qqEyTrbJhKNcHOTyLLjduSfKXP1Q49ea8s/yhxqHj9DmiU 5qkbkLjuew3Qxdr3vvKNm2cxG1CxE5A2nMkFPq0CspfQvW9XXwx+SCJnruCeDtI0WcgC R72Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=bUAYvoRE++vtOhfTfGcC3GQ+auq5Nx2oS4tsDzfqZ3k=; b=YjONcxy2qqHolq3Rra/4ZkfVnhuuh4EquI2b+DO9PmmXk69Yk6a3O7WPjW+cMbNERX VuRoG1LR26Xk+kj7drZHPSRytSEEOpXot33/xrqTHPInTqUXqZ1nqPTJhVd2wzDMpcqu CbuAfQiWidWgGX1vdsBMe0KLNUr7tOLZi+LF53eBRZJB+v7FExGynidjc+wk35feSaqH b6Bny88dA6wZEF8Qq3XALLYmKYkvhZ27E9Hy8c2LoqQ+B8XSB6h3+um9/uyN2gwIt6V4 BHbeI0Kadfc6ry4MhwSV0QEqMJ6NrhDmZfxT/gDFOYEJS93uw+leIP9SlhdbiAM9tKis kA8g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=CLQ5O5h/; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id w24si1213131qta.58.2017.10.16.11.02.26 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 16 Oct 2017 11:02:26 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=CLQ5O5h/; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:34458 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e49ia-0007sy-Ar for patch@linaro.org; Mon, 16 Oct 2017 14:02:24 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52733) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e49AY-0002mO-Bf for qemu-devel@nongnu.org; Mon, 16 Oct 2017 13:27:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e49AV-0003vd-14 for qemu-devel@nongnu.org; Mon, 16 Oct 2017 13:27:12 -0400 Received: from mail-pg0-x22a.google.com ([2607:f8b0:400e:c05::22a]:49899) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e49AU-0003v1-PB for qemu-devel@nongnu.org; Mon, 16 Oct 2017 13:27:10 -0400 Received: by mail-pg0-x22a.google.com with SMTP id g6so5925014pgn.6 for ; Mon, 16 Oct 2017 10:27:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=bUAYvoRE++vtOhfTfGcC3GQ+auq5Nx2oS4tsDzfqZ3k=; b=CLQ5O5h/WNFJND+/AzeiA3mqCHqdzFzDEdjPILv3NYHeK+zq/ylJcLwRECqinYrjeS 8vmETiiVXUy8WX80irDgHwS5l0ImKJej1sxmg8FL16QyqhOe7NR0MdWqG2CAISNEq7Zt NWKIc0bTlm+dkt7vsGTvEVncSUEcmk4n95138= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=bUAYvoRE++vtOhfTfGcC3GQ+auq5Nx2oS4tsDzfqZ3k=; b=R1k+cdfUKxE6JPOtDB6mNff1cHKNEprJHm9HzcMgBDMTpmM5RORiIrTrp+CFylhw+k 0HSRkdHrW0/eYDurBTibP3TbBBNqFQnAjbxLzwYlKw1gk15ibQ5H7uz4n5cY0I75+4l6 Zy4h1zTQGa5k01kFgs2aY2kcOWwMlEuskdqQdhcona1CwmEvhgWS2IVamCyCJScHaZG+ IF4vLrDLhf1/lGaa9Ua6BetpW1SFb+CXZK6U3xuERFZjtU3WVGxsH4ObYgqtVaoNaIMD SxyMw1y6gwgkCrJ47zHLqw8sLXGkYpsYOch5LaO/91/2F+KUHlbX1FxCkv0mu4s6XrOT Vnhw== X-Gm-Message-State: AMCzsaVbZw45yb9/9ueR0EYAlvMxKx1nPx6E5tu38DMJXndK/4iHYX9B BNT4tNIWYb87M40eJAKHhs4eZfRS8mk= X-Google-Smtp-Source: AOwi7QBQzvLdT/y2A1JXw0buMJ02cRf8Ery+RaBxoTWwQW9709nYmx0RWngYa/7glk3x32GJEC6qsQ== X-Received: by 10.99.95.201 with SMTP id t192mr7101759pgb.398.1508174829527; Mon, 16 Oct 2017 10:27:09 -0700 (PDT) Received: from cloudburst.twiddle.net (97-126-104-76.tukw.qwest.net. [97.126.104.76]) by smtp.gmail.com with ESMTPSA id i187sm5594249pfc.96.2017.10.16.10.27.08 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 16 Oct 2017 10:27:08 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Mon, 16 Oct 2017 10:25:59 -0700 Message-Id: <20171016172609.23422-41-richard.henderson@linaro.org> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171016172609.23422-1-richard.henderson@linaro.org> References: <20171016172609.23422-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c05::22a Subject: [Qemu-devel] [PATCH v6 40/50] translate-all: report correct avg host TB size 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: cota@braap.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: "Emilio G. Cota" Since commit 6e3b2bfd6 ("tcg: allocate TB structs before the corresponding translated code") we are not fully utilizing code_gen_buffer for translated code, and therefore are incorrectly reporting the amount of translated code as well as the average host TB size. Address this by: - Making the conscious choice of misreporting the total translated code; doing otherwise would mislead users into thinking "-tb-size" is not honoured. - Expanding tb_tree_stats to accurately count the bytes of translated code on the host, and using this for reporting the average tb host size, as well as the expansion ratio. In the future we might want to consider reporting the accurate numbers for the total translated code, together with a "bookkeeping/overhead" field to account for the TB structs. Reviewed-by: Richard Henderson Signed-off-by: Emilio G. Cota --- accel/tcg/translate-all.c | 32 +++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-) -- 2.13.6 diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c index 76db9c775a..b21671d6f4 100644 --- a/accel/tcg/translate-all.c +++ b/accel/tcg/translate-all.c @@ -923,6 +923,15 @@ static void page_flush_tb(void) } } +static gboolean tb_host_size_iter(gpointer key, gpointer value, gpointer data) +{ + const TranslationBlock *tb = value; + size_t *size = data; + + *size += tb->tc.size; + return false; +} + /* flush all the translation blocks */ static void do_tb_flush(CPUState *cpu, run_on_cpu_data tb_flush_count) { @@ -937,11 +946,12 @@ static void do_tb_flush(CPUState *cpu, run_on_cpu_data tb_flush_count) if (DEBUG_TB_FLUSH_GATE) { size_t nb_tbs = g_tree_nnodes(tcg_ctx.tb_ctx.tb_tree); + size_t host_size = 0; - printf("qemu: flush code_size=%td nb_tbs=%zu avg_tb_size=%td\n", + g_tree_foreach(tcg_ctx.tb_ctx.tb_tree, tb_host_size_iter, &host_size); + printf("qemu: flush code_size=%td nb_tbs=%zu avg_tb_size=%zu\n", tcg_ctx.code_gen_ptr - tcg_ctx.code_gen_buffer, nb_tbs, - nb_tbs > 0 ? - (tcg_ctx.code_gen_ptr - tcg_ctx.code_gen_buffer) / nb_tbs : 0); + nb_tbs > 0 ? host_size / nb_tbs : 0); } if ((unsigned long)(tcg_ctx.code_gen_ptr - tcg_ctx.code_gen_buffer) > tcg_ctx.code_gen_buffer_size) { @@ -1890,6 +1900,7 @@ static void print_qht_statistics(FILE *f, fprintf_function cpu_fprintf, } struct tb_tree_stats { + size_t host_size; size_t target_size; size_t max_target_size; size_t direct_jmp_count; @@ -1902,6 +1913,7 @@ static gboolean tb_tree_stats_iter(gpointer key, gpointer value, gpointer data) const TranslationBlock *tb = value; struct tb_tree_stats *tst = data; + tst->host_size += tb->tc.size; tst->target_size += tb->size; if (tb->size > tst->max_target_size) { tst->max_target_size = tb->size; @@ -1930,6 +1942,11 @@ void dump_exec_info(FILE *f, fprintf_function cpu_fprintf) g_tree_foreach(tcg_ctx.tb_ctx.tb_tree, tb_tree_stats_iter, &tst); /* XXX: avoid using doubles ? */ cpu_fprintf(f, "Translation buffer state:\n"); + /* + * Report total code size including the padding and TB structs; + * otherwise users might think "-tb-size" is not honoured. + * For avg host size we use the precise numbers from tb_tree_stats though. + */ cpu_fprintf(f, "gen code size %td/%zd\n", tcg_ctx.code_gen_ptr - tcg_ctx.code_gen_buffer, tcg_ctx.code_gen_highwater - tcg_ctx.code_gen_buffer); @@ -1937,12 +1954,9 @@ void dump_exec_info(FILE *f, fprintf_function cpu_fprintf) cpu_fprintf(f, "TB avg target size %zu max=%zu bytes\n", nb_tbs ? tst.target_size / nb_tbs : 0, tst.max_target_size); - cpu_fprintf(f, "TB avg host size %td bytes (expansion ratio: %0.1f)\n", - nb_tbs ? (tcg_ctx.code_gen_ptr - - tcg_ctx.code_gen_buffer) / nb_tbs : 0, - tst.target_size ? (double) (tcg_ctx.code_gen_ptr - - tcg_ctx.code_gen_buffer) / - tst.target_size : 0); + cpu_fprintf(f, "TB avg host size %zu bytes (expansion ratio: %0.1f)\n", + nb_tbs ? tst.host_size / nb_tbs : 0, + tst.target_size ? (double)tst.host_size / tst.target_size : 0); cpu_fprintf(f, "cross page TB count %zu (%zu%%)\n", tst.cross_page, nb_tbs ? (tst.cross_page * 100) / nb_tbs : 0); cpu_fprintf(f, "direct jump count %zu (%zu%%) (2 jumps=%zu %zu%%)\n", From patchwork Mon Oct 16 17:26:00 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 115971 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp3961350qgn; Mon, 16 Oct 2017 10:59:08 -0700 (PDT) X-Received: by 10.233.239.215 with SMTP id d206mr14420789qkg.59.1508176748041; Mon, 16 Oct 2017 10:59:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508176748; cv=none; d=google.com; s=arc-20160816; b=ZNA7p2NjHD1XmesyjOIjE3YOebHNG/dXFw6+2SCbhlrQs5UmDJuDhMaivmVceN0/aA B5nsm26Of4uwDcCgea4IXbFMckb1dojlspUnPW2W42wXNeYVOh0h08QwBVMVLyo/Ijxq +ZaAfqfdUQaVRhxAdCJCz0yJyKVIVSVKKQsDIS1ylxkBJECh486VVlwKKcthDzZLsEEf 8ybsq9Q7oBSUF8jpYhorLfRD3owR9/mxEjcZ5r2SwNlcxQdHlRc9vtZ4dBjmm55d9XGg f+U9m5bZrdXz6aRpjl4057JZ3LZdJVSR35bWW3LeMcJH/GwyeWH9MB5bpHV3ElfQecdk 3QMA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=5gLpsSURJCvdKy3g1+IW5c1QZdKxsnrW9+1xstSV9Ls=; b=GyNvEyauP2Tdc8w/l0qJ6yBvr5uqdhxE/3C7W4nSr4RSrOGjYZDcADQxygw6murNfQ JMnAk3ZrcIyDcJb/2VpOtuxckhorsTaH+ZwpmQSxLbvY2GYoCEeQVHzWn/Wc+615tqKy hbFAJaggjZxDlwqkLQq+3dd6Fsla58qA7HZNkkST03fwOHiPZkTMvgtpG+cHTE3eeYEm v11kjtWG+tTlOODcXAg+Z7vq8Nq4c0OIaKeG/id8wlz1W5UB80zeOsoNSlO2XUOLwuPA Osd8AaAsHb37dxaZfGqJ1SvXgHB38ii/rKoiy3rdTc7yEtfLyfVkjRXSidAGY+yfhnhB OoQQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=DNthPiMD; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id j92si2988489qtd.294.2017.10.16.10.59.07 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 16 Oct 2017 10:59:08 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=DNthPiMD; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:34434 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e49fN-000542-RS for patch@linaro.org; Mon, 16 Oct 2017 13:59:05 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52751) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e49AY-0002mP-Bl for qemu-devel@nongnu.org; Mon, 16 Oct 2017 13:27:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e49AW-0003wl-IP for qemu-devel@nongnu.org; Mon, 16 Oct 2017 13:27:14 -0400 Received: from mail-pf0-x22b.google.com ([2607:f8b0:400e:c00::22b]:50194) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e49AW-0003wG-9g for qemu-devel@nongnu.org; Mon, 16 Oct 2017 13:27:12 -0400 Received: by mail-pf0-x22b.google.com with SMTP id b6so7885746pfh.7 for ; Mon, 16 Oct 2017 10:27:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=5gLpsSURJCvdKy3g1+IW5c1QZdKxsnrW9+1xstSV9Ls=; b=DNthPiMD4QqrlXilpuv4RsJryKtl6VLkJw69bU1MeF2+as6uYK9GIRrCXfTARwb03y cNfiCIIUc0sY05Sbbvd3cQQe3rDxIUaoSMFcD9KrW1ROUz+8eiZBc+3j0Q04scg5KQBI RrSIxh1a0kUqY1lJuDGaASR/kMZLfV+YDutoQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=5gLpsSURJCvdKy3g1+IW5c1QZdKxsnrW9+1xstSV9Ls=; b=YU0tN59QtQVVnYcr6apX/vg76amWgJBsOgSFqJG4Ask9SuE6S1/4vXPQcazzZvHOyg QQfigM7ALUvE5vi/z3i5Wk9TwGJbMI9pD8PKktmJjXRYfUfUK/O8sNdqZmziRIefzuSa K7l0/MfwkJi4g7q1eI/tr5+RfQsSYnAAEajnCi6UeVcbhuqtnX5NblkJhZUmrl1IATjB fuWpn6eQOW3Lr4wEDa5Q1fqxn5cGItdVsGDLtvJaE87ncrOIUby9S79W12adRmY0oQ8f OIZQK8xMa3oQfgP+MLfjP8c8TvT7Nk7tEtPbS+4EJLHGv2S2ut3fK3IsfxXI0G0XO1x2 s71w== X-Gm-Message-State: AMCzsaUFykyJ+Mqm7Y1n+HesyJDNhOvAn7SW+zWtNkkr2oFPhVaIKY0F sqUag4mqgQgUmiBD9IE5l3iqhftQ6xU= X-Google-Smtp-Source: AOwi7QDxgT6+xIneYa2o3RszmDgeYafujc9eSUPSwPEqo3Gg595HCczaVfFN+y72gfKVTwRUtYz6vA== X-Received: by 10.159.208.2 with SMTP id a2mr9710880plp.370.1508174831016; Mon, 16 Oct 2017 10:27:11 -0700 (PDT) Received: from cloudburst.twiddle.net (97-126-104-76.tukw.qwest.net. [97.126.104.76]) by smtp.gmail.com with ESMTPSA id i187sm5594249pfc.96.2017.10.16.10.27.09 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 16 Oct 2017 10:27:10 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Mon, 16 Oct 2017 10:26:00 -0700 Message-Id: <20171016172609.23422-42-richard.henderson@linaro.org> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171016172609.23422-1-richard.henderson@linaro.org> References: <20171016172609.23422-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c00::22b Subject: [Qemu-devel] [PATCH v6 41/50] tcg: take tb_ctx out of TCGContext 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: cota@braap.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: "Emilio G. Cota" Groundwork for supporting multiple TCG contexts. Reviewed-by: Richard Henderson Reviewed-by: Alex BennĂ©e Signed-off-by: Emilio G. Cota --- include/exec/tb-context.h | 2 ++ tcg/tcg.h | 2 -- accel/tcg/cpu-exec.c | 2 +- accel/tcg/translate-all.c | 57 +++++++++++++++++++++++------------------------ linux-user/main.c | 6 ++--- 5 files changed, 34 insertions(+), 35 deletions(-) -- 2.13.6 diff --git a/include/exec/tb-context.h b/include/exec/tb-context.h index 1fa8dcc737..1d41202485 100644 --- a/include/exec/tb-context.h +++ b/include/exec/tb-context.h @@ -41,4 +41,6 @@ struct TBContext { int tb_phys_invalidate_count; }; +extern TBContext tb_ctx; + #endif diff --git a/tcg/tcg.h b/tcg/tcg.h index 6736a9fe2e..58267fd3fd 100644 --- a/tcg/tcg.h +++ b/tcg/tcg.h @@ -705,8 +705,6 @@ struct TCGContext { /* Threshold to flush the translated code buffer. */ void *code_gen_highwater; - TBContext tb_ctx; - /* Track which vCPU triggers events */ CPUState *cpu; /* *_trans */ TCGv_env tcg_env; /* *_exec */ diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c index 6a4a33235b..bb1b00eaf6 100644 --- a/accel/tcg/cpu-exec.c +++ b/accel/tcg/cpu-exec.c @@ -327,7 +327,7 @@ TranslationBlock *tb_htable_lookup(CPUState *cpu, target_ulong pc, phys_pc = get_page_addr_code(desc.env, pc); desc.phys_page1 = phys_pc & TARGET_PAGE_MASK; h = tb_hash_func(phys_pc, pc, flags, cf_mask, *cpu->trace_dstate); - return qht_lookup(&tcg_ctx.tb_ctx.htable, tb_cmp, &desc, h); + return qht_lookup(&tb_ctx.htable, tb_cmp, &desc, h); } void tb_set_jmp_target(TranslationBlock *tb, int n, uintptr_t addr) diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c index b21671d6f4..86247f87ad 100644 --- a/accel/tcg/translate-all.c +++ b/accel/tcg/translate-all.c @@ -154,6 +154,7 @@ static void *l1_map[V_L1_MAX_SIZE]; /* code generation context */ TCGContext tcg_ctx; +TBContext tb_ctx; bool parallel_cpus; /* translation block context */ @@ -185,7 +186,7 @@ static void page_table_config_init(void) void tb_lock(void) { assert_tb_unlocked(); - qemu_mutex_lock(&tcg_ctx.tb_ctx.tb_lock); + qemu_mutex_lock(&tb_ctx.tb_lock); have_tb_lock++; } @@ -193,13 +194,13 @@ void tb_unlock(void) { assert_tb_locked(); have_tb_lock--; - qemu_mutex_unlock(&tcg_ctx.tb_ctx.tb_lock); + qemu_mutex_unlock(&tb_ctx.tb_lock); } void tb_lock_reset(void) { if (have_tb_lock) { - qemu_mutex_unlock(&tcg_ctx.tb_ctx.tb_lock); + qemu_mutex_unlock(&tb_ctx.tb_lock); have_tb_lock = 0; } } @@ -826,15 +827,15 @@ static inline void code_gen_alloc(size_t tb_size) fprintf(stderr, "Could not allocate dynamic translator buffer\n"); exit(1); } - tcg_ctx.tb_ctx.tb_tree = g_tree_new(tb_tc_cmp); - qemu_mutex_init(&tcg_ctx.tb_ctx.tb_lock); + tb_ctx.tb_tree = g_tree_new(tb_tc_cmp); + qemu_mutex_init(&tb_ctx.tb_lock); } static void tb_htable_init(void) { unsigned int mode = QHT_MODE_AUTO_RESIZE; - qht_init(&tcg_ctx.tb_ctx.htable, CODE_GEN_HTABLE_SIZE, mode); + qht_init(&tb_ctx.htable, CODE_GEN_HTABLE_SIZE, mode); } /* Must be called before using the QEMU cpus. 'tb_size' is the size @@ -878,7 +879,7 @@ void tb_remove(TranslationBlock *tb) { assert_tb_locked(); - g_tree_remove(tcg_ctx.tb_ctx.tb_tree, &tb->tc); + g_tree_remove(tb_ctx.tb_tree, &tb->tc); } static inline void invalidate_page_bitmap(PageDesc *p) @@ -940,15 +941,15 @@ static void do_tb_flush(CPUState *cpu, run_on_cpu_data tb_flush_count) /* If it is already been done on request of another CPU, * just retry. */ - if (tcg_ctx.tb_ctx.tb_flush_count != tb_flush_count.host_int) { + if (tb_ctx.tb_flush_count != tb_flush_count.host_int) { goto done; } if (DEBUG_TB_FLUSH_GATE) { - size_t nb_tbs = g_tree_nnodes(tcg_ctx.tb_ctx.tb_tree); + size_t nb_tbs = g_tree_nnodes(tb_ctx.tb_tree); size_t host_size = 0; - g_tree_foreach(tcg_ctx.tb_ctx.tb_tree, tb_host_size_iter, &host_size); + g_tree_foreach(tb_ctx.tb_tree, tb_host_size_iter, &host_size); printf("qemu: flush code_size=%td nb_tbs=%zu avg_tb_size=%zu\n", tcg_ctx.code_gen_ptr - tcg_ctx.code_gen_buffer, nb_tbs, nb_tbs > 0 ? host_size / nb_tbs : 0); @@ -963,17 +964,16 @@ static void do_tb_flush(CPUState *cpu, run_on_cpu_data tb_flush_count) } /* Increment the refcount first so that destroy acts as a reset */ - g_tree_ref(tcg_ctx.tb_ctx.tb_tree); - g_tree_destroy(tcg_ctx.tb_ctx.tb_tree); + g_tree_ref(tb_ctx.tb_tree); + g_tree_destroy(tb_ctx.tb_tree); - qht_reset_size(&tcg_ctx.tb_ctx.htable, CODE_GEN_HTABLE_SIZE); + qht_reset_size(&tb_ctx.htable, CODE_GEN_HTABLE_SIZE); page_flush_tb(); tcg_ctx.code_gen_ptr = tcg_ctx.code_gen_buffer; /* XXX: flush processor icache at this point if cache flush is expensive */ - atomic_mb_set(&tcg_ctx.tb_ctx.tb_flush_count, - tcg_ctx.tb_ctx.tb_flush_count + 1); + atomic_mb_set(&tb_ctx.tb_flush_count, tb_ctx.tb_flush_count + 1); done: tb_unlock(); @@ -982,7 +982,7 @@ done: void tb_flush(CPUState *cpu) { if (tcg_enabled()) { - unsigned tb_flush_count = atomic_mb_read(&tcg_ctx.tb_ctx.tb_flush_count); + unsigned tb_flush_count = atomic_mb_read(&tb_ctx.tb_flush_count); async_safe_run_on_cpu(cpu, do_tb_flush, RUN_ON_CPU_HOST_INT(tb_flush_count)); } @@ -1015,7 +1015,7 @@ do_tb_invalidate_check(struct qht *ht, void *p, uint32_t hash, void *userp) static void tb_invalidate_check(target_ulong address) { address &= TARGET_PAGE_MASK; - qht_iter(&tcg_ctx.tb_ctx.htable, do_tb_invalidate_check, &address); + qht_iter(&tb_ctx.htable, do_tb_invalidate_check, &address); } static void @@ -1035,7 +1035,7 @@ do_tb_page_check(struct qht *ht, void *p, uint32_t hash, void *userp) /* verify that all the pages have correct rights for code */ static void tb_page_check(void) { - qht_iter(&tcg_ctx.tb_ctx.htable, do_tb_page_check, NULL); + qht_iter(&tb_ctx.htable, do_tb_page_check, NULL); } #endif /* CONFIG_USER_ONLY */ @@ -1135,7 +1135,7 @@ void tb_phys_invalidate(TranslationBlock *tb, tb_page_addr_t page_addr) phys_pc = tb->page_addr[0] + (tb->pc & ~TARGET_PAGE_MASK); h = tb_hash_func(phys_pc, tb->pc, tb->flags, tb->cflags & CF_HASH_MASK, tb->trace_vcpu_dstate); - qht_remove(&tcg_ctx.tb_ctx.htable, tb, h); + qht_remove(&tb_ctx.htable, tb, h); /* remove the TB from the page list */ if (tb->page_addr[0] != page_addr) { @@ -1164,7 +1164,7 @@ void tb_phys_invalidate(TranslationBlock *tb, tb_page_addr_t page_addr) /* suppress any remaining jumps to this TB */ tb_jmp_unlink(tb); - tcg_ctx.tb_ctx.tb_phys_invalidate_count++; + tb_ctx.tb_phys_invalidate_count++; } #ifdef CONFIG_SOFTMMU @@ -1280,7 +1280,7 @@ static void tb_link_page(TranslationBlock *tb, tb_page_addr_t phys_pc, /* add in the hash table */ h = tb_hash_func(phys_pc, tb->pc, tb->flags, tb->cflags & CF_HASH_MASK, tb->trace_vcpu_dstate); - qht_insert(&tcg_ctx.tb_ctx.htable, tb, h); + qht_insert(&tb_ctx.htable, tb, h); #ifdef CONFIG_USER_ONLY if (DEBUG_TB_CHECK_GATE) { @@ -1443,7 +1443,7 @@ TranslationBlock *tb_gen_code(CPUState *cpu, * through the physical hash table and physical page list. */ tb_link_page(tb, phys_pc, phys_page2); - g_tree_insert(tcg_ctx.tb_ctx.tb_tree, &tb->tc, tb); + g_tree_insert(tb_ctx.tb_tree, &tb->tc, tb); return tb; } @@ -1713,7 +1713,7 @@ static TranslationBlock *tb_find_pc(uintptr_t tc_ptr) { struct tb_tc s = { .ptr = (void *)tc_ptr }; - return g_tree_lookup(tcg_ctx.tb_ctx.tb_tree, &s); + return g_tree_lookup(tb_ctx.tb_tree, &s); } #if !defined(CONFIG_USER_ONLY) @@ -1938,8 +1938,8 @@ void dump_exec_info(FILE *f, fprintf_function cpu_fprintf) tb_lock(); - nb_tbs = g_tree_nnodes(tcg_ctx.tb_ctx.tb_tree); - g_tree_foreach(tcg_ctx.tb_ctx.tb_tree, tb_tree_stats_iter, &tst); + nb_tbs = g_tree_nnodes(tb_ctx.tb_tree); + g_tree_foreach(tb_ctx.tb_tree, tb_tree_stats_iter, &tst); /* XXX: avoid using doubles ? */ cpu_fprintf(f, "Translation buffer state:\n"); /* @@ -1965,15 +1965,14 @@ void dump_exec_info(FILE *f, fprintf_function cpu_fprintf) tst.direct_jmp2_count, nb_tbs ? (tst.direct_jmp2_count * 100) / nb_tbs : 0); - qht_statistics_init(&tcg_ctx.tb_ctx.htable, &hst); + qht_statistics_init(&tb_ctx.htable, &hst); print_qht_statistics(f, cpu_fprintf, hst); qht_statistics_destroy(&hst); cpu_fprintf(f, "\nStatistics:\n"); cpu_fprintf(f, "TB flush count %u\n", - atomic_read(&tcg_ctx.tb_ctx.tb_flush_count)); - cpu_fprintf(f, "TB invalidate count %d\n", - tcg_ctx.tb_ctx.tb_phys_invalidate_count); + atomic_read(&tb_ctx.tb_flush_count)); + cpu_fprintf(f, "TB invalidate count %d\n", tb_ctx.tb_phys_invalidate_count); cpu_fprintf(f, "TLB flush count %zu\n", tlb_flush_count()); tcg_dump_info(f, cpu_fprintf); diff --git a/linux-user/main.c b/linux-user/main.c index 829f974662..b288670121 100644 --- a/linux-user/main.c +++ b/linux-user/main.c @@ -114,7 +114,7 @@ int cpu_get_pic_interrupt(CPUX86State *env) void fork_start(void) { cpu_list_lock(); - qemu_mutex_lock(&tcg_ctx.tb_ctx.tb_lock); + qemu_mutex_lock(&tb_ctx.tb_lock); mmap_fork_start(); } @@ -130,11 +130,11 @@ void fork_end(int child) QTAILQ_REMOVE(&cpus, cpu, node); } } - qemu_mutex_init(&tcg_ctx.tb_ctx.tb_lock); + qemu_mutex_init(&tb_ctx.tb_lock); qemu_init_cpu_list(); gdbserver_fork(thread_cpu); } else { - qemu_mutex_unlock(&tcg_ctx.tb_ctx.tb_lock); + qemu_mutex_unlock(&tb_ctx.tb_lock); cpu_list_unlock(); } } From patchwork Mon Oct 16 17:26:01 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 115976 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp3967922qgn; Mon, 16 Oct 2017 11:05:10 -0700 (PDT) X-Received: by 10.200.16.136 with SMTP id a8mr9046939qtj.177.1508177110280; Mon, 16 Oct 2017 11:05:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508177110; cv=none; d=google.com; s=arc-20160816; b=0Np6NrsROgmPvWK3uUm1qO6NtIdxlCxpVl2ziCKjSTNRcwmMnqqd4Uzw2odQ2ks6bq ZFQ+WS4vU3YQlkOIZo5SY057LaTMGdVtGYLgOkxHM3ZS+lCN4topBRHoEAQe4ZeUjDpE i/3v+92R8Gh/BNY9/JFmp94VT6i56aCqyBbKUhtC1TYdUocewkl74KEDKBMMceJ4OPd8 iIpOLKRhH7HKFxwERKbNAHKVJjDn5D6H75/AyoxwfPIGW3b3jYtiMcZAbfaeVcg+Pq0c XzLw4XCBwQNS8btZ1FkpdP6syjOw01kqgh/wDlZ1v+VygCj6TdUiHol7liv6myZlM7Fl AxFw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=ldI9zgW5J7S2u6objWoC7Kcl2C7VMlfGDmhFWuoHLbk=; b=e/uBPDySovKm/oeh5I5541ePRWg0QUAZttVHHrBPua1LAsLBnnNmFPHWtvsRTbeKgr FJEbk2+FiUC+Yma3cl3fxHk6zGSx9ootKHGiUZnZZzWElhloz2b7E31jrExkUNGQ4EOs xrz3l4D2Thh+QCEVST5zCE8dzI2FvDvaC3d40q9V1f7D0HtPPAsM4tGN/IrPYRvTq3+q pkyZtrIGB4gVOJGESR9oZEQ5DOw2kNLm7O3N2+lMFGLiDuN/ABGC3XNagCJl+XUfOFJk PTjMAAI6KdBzrwl8JKSw/rZdHyOuQ0up/MHibRSNJzk4G6qT8f7fUi4mD+wAgyD8YYL7 i9hQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=W0QANV+U; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id 23si1203361qtu.237.2017.10.16.11.05.09 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 16 Oct 2017 11:05:10 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=W0QANV+U; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:34472 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e49lD-0001aa-R2 for patch@linaro.org; Mon, 16 Oct 2017 14:05:07 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52831) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e49Ac-0002rA-Lp for qemu-devel@nongnu.org; Mon, 16 Oct 2017 13:27:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e49AY-0003zm-L0 for qemu-devel@nongnu.org; Mon, 16 Oct 2017 13:27:18 -0400 Received: from mail-pg0-x236.google.com ([2607:f8b0:400e:c05::236]:48221) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e49AY-0003xw-7F for qemu-devel@nongnu.org; Mon, 16 Oct 2017 13:27:14 -0400 Received: by mail-pg0-x236.google.com with SMTP id v78so7337086pgb.5 for ; Mon, 16 Oct 2017 10:27:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=ldI9zgW5J7S2u6objWoC7Kcl2C7VMlfGDmhFWuoHLbk=; b=W0QANV+U6iXIZGeSy/YRpqUdcEOOhjDc9ka2LsgyNidloSLyTnNIvYAVMSneTAW4um rvTqoFrPU6YfArHJxrIuIu/uOBm4m6iOHLvk3IIvai5DIAL4W4Adw6W21UFhfWyzNuA+ pvDM1V2zaI0U+INKUUe1X0KA4aIB34lXtkKJk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=ldI9zgW5J7S2u6objWoC7Kcl2C7VMlfGDmhFWuoHLbk=; b=LO7qQtNLgpGQe9KDdtjZyqbCU/R/GfMRQoLFCYK2k8pv5pYVhdVR7XptU2zLWAapO6 n0Kn9xv9FPgDLxPafjfH5+qrteork/dsmzK14G1EYapA6UGmIOS7SwAerh7yv0jDgDYp Xvgf1dks9ohXlHFQTJ4+JrBsvBxkK5p3BMLpdOv6zcA8DxfHFWzQ16ptEb7QmmiX2bf1 YiaZ6RU+gPCI65ZwHearjjcTK82DDEswPwOTiQvYx0nWPxPwQtCpKVmbfVNhX5faiG7S OJkKp4yVgfSdw7TWxBmItBZqdRVl1pNZsydbdLhwZqXn1jSIsCl0HV220W2IWlUzSIAJ u1qQ== X-Gm-Message-State: AMCzsaWFrukiDOXUFVhmbPZ91lZyg/UHifu9b40X3IrpqYJgLjqDfWUt de6UWm5TYBnV8bWGQ3qEy5vqCZmFle0= X-Google-Smtp-Source: ABhQp+SIOrHNswblG2+8Go4MUe91oSmnh6ahEMFthh0ysKk2YHoWrfI1F85cURTvg3d5xn7iJLauUw== X-Received: by 10.84.164.231 with SMTP id l36mr3975525plg.179.1508174832438; Mon, 16 Oct 2017 10:27:12 -0700 (PDT) Received: from cloudburst.twiddle.net (97-126-104-76.tukw.qwest.net. [97.126.104.76]) by smtp.gmail.com with ESMTPSA id i187sm5594249pfc.96.2017.10.16.10.27.11 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 16 Oct 2017 10:27:11 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Mon, 16 Oct 2017 10:26:01 -0700 Message-Id: <20171016172609.23422-43-richard.henderson@linaro.org> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171016172609.23422-1-richard.henderson@linaro.org> References: <20171016172609.23422-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c05::236 Subject: [Qemu-devel] [PATCH v6 42/50] tcg: define tcg_init_ctx and make tcg_ctx a pointer 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: cota@braap.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: "Emilio G. Cota" Groundwork for supporting multiple TCG contexts. The core of this patch is this change to tcg/tcg.h: > -extern TCGContext tcg_ctx; > +extern TCGContext tcg_init_ctx; > +extern TCGContext *tcg_ctx; Note that for now we set *tcg_ctx to whatever TCGContext is passed to tcg_context_init -- in this case &tcg_init_ctx. Reviewed-by: Richard Henderson Signed-off-by: Emilio G. Cota --- include/exec/gen-icount.h | 10 ++-- tcg/tcg.h | 19 ++++---- accel/tcg/tcg-runtime.c | 2 +- accel/tcg/translate-all.c | 109 +++++++++++++++++++++--------------------- bsd-user/main.c | 2 +- linux-user/main.c | 2 +- target/alpha/translate.c | 2 +- target/arm/translate.c | 2 +- target/cris/translate.c | 2 +- target/cris/translate_v10.c | 2 +- target/hppa/translate.c | 2 +- target/i386/translate.c | 2 +- target/lm32/translate.c | 2 +- target/m68k/translate.c | 2 +- target/microblaze/translate.c | 2 +- target/mips/translate.c | 2 +- target/moxie/translate.c | 2 +- target/openrisc/translate.c | 2 +- target/ppc/translate.c | 2 +- target/s390x/translate.c | 2 +- target/sh4/translate.c | 2 +- target/sparc/translate.c | 2 +- target/tilegx/translate.c | 2 +- target/tricore/translate.c | 2 +- target/unicore32/translate.c | 2 +- target/xtensa/translate.c | 2 +- tcg/tcg-op.c | 46 +++++++++--------- tcg/tcg.c | 22 +++++---- 28 files changed, 128 insertions(+), 124 deletions(-) -- 2.13.6 diff --git a/include/exec/gen-icount.h b/include/exec/gen-icount.h index 48b566c1c9..c58b0b2585 100644 --- a/include/exec/gen-icount.h +++ b/include/exec/gen-icount.h @@ -19,7 +19,7 @@ static inline void gen_tb_start(TranslationBlock *tb) count = tcg_temp_new_i32(); } - tcg_gen_ld_i32(count, tcg_ctx.tcg_env, + tcg_gen_ld_i32(count, tcg_ctx->tcg_env, -ENV_OFFSET + offsetof(CPUState, icount_decr.u32)); if (tb_cflags(tb) & CF_USE_ICOUNT) { @@ -37,7 +37,7 @@ static inline void gen_tb_start(TranslationBlock *tb) tcg_gen_brcondi_i32(TCG_COND_LT, count, 0, exitreq_label); if (tb_cflags(tb) & CF_USE_ICOUNT) { - tcg_gen_st16_i32(count, tcg_ctx.tcg_env, + tcg_gen_st16_i32(count, tcg_ctx->tcg_env, -ENV_OFFSET + offsetof(CPUState, icount_decr.u16.low)); } @@ -56,13 +56,13 @@ static inline void gen_tb_end(TranslationBlock *tb, int num_insns) tcg_gen_exit_tb((uintptr_t)tb + TB_EXIT_REQUESTED); /* Terminate the linked list. */ - tcg_ctx.gen_op_buf[tcg_ctx.gen_op_buf[0].prev].next = 0; + tcg_ctx->gen_op_buf[tcg_ctx->gen_op_buf[0].prev].next = 0; } static inline void gen_io_start(void) { TCGv_i32 tmp = tcg_const_i32(1); - tcg_gen_st_i32(tmp, tcg_ctx.tcg_env, + tcg_gen_st_i32(tmp, tcg_ctx->tcg_env, -ENV_OFFSET + offsetof(CPUState, can_do_io)); tcg_temp_free_i32(tmp); } @@ -70,7 +70,7 @@ static inline void gen_io_start(void) static inline void gen_io_end(void) { TCGv_i32 tmp = tcg_const_i32(0); - tcg_gen_st_i32(tmp, tcg_ctx.tcg_env, + tcg_gen_st_i32(tmp, tcg_ctx->tcg_env, -ENV_OFFSET + offsetof(CPUState, can_do_io)); tcg_temp_free_i32(tmp); } diff --git a/tcg/tcg.h b/tcg/tcg.h index 58267fd3fd..859020a0fd 100644 --- a/tcg/tcg.h +++ b/tcg/tcg.h @@ -730,18 +730,19 @@ struct TCGContext { target_ulong gen_insn_data[TCG_MAX_INSNS][TARGET_INSN_START_WORDS]; }; -extern TCGContext tcg_ctx; +extern TCGContext tcg_init_ctx; +extern TCGContext *tcg_ctx; static inline size_t temp_idx(TCGTemp *ts) { - ptrdiff_t n = ts - tcg_ctx.temps; - tcg_debug_assert(n > 0 && n < tcg_ctx.nb_temps); + ptrdiff_t n = ts - tcg_ctx->temps; + tcg_debug_assert(n > 0 && n < tcg_ctx->nb_temps); return n; } static inline TCGTemp *idx_temp(size_t n) { - return n == TCG_CALL_DUMMY_ARG ? NULL : &tcg_ctx.temps[n]; + return n == TCG_CALL_DUMMY_ARG ? NULL : &tcg_ctx->temps[n]; } static inline TCGArg temp_arg(TCGTemp *ts) @@ -781,13 +782,13 @@ static inline TCGArg tcgv_ptr_arg(TCGv_ptr t) static inline void tcg_set_insn_param(int op_idx, int arg, TCGArg v) { - tcg_ctx.gen_op_buf[op_idx].args[arg] = v; + tcg_ctx->gen_op_buf[op_idx].args[arg] = v; } /* The number of opcodes emitted so far. */ static inline int tcg_op_buf_count(void) { - return tcg_ctx.gen_next_op_idx; + return tcg_ctx->gen_next_op_idx; } /* Test for whether to terminate the TB for using too many opcodes. */ @@ -806,7 +807,7 @@ TranslationBlock *tcg_tb_alloc(TCGContext *s); /* Called with tb_lock held. */ static inline void *tcg_malloc(int size) { - TCGContext *s = &tcg_ctx; + TCGContext *s = tcg_ctx; uint8_t *ptr, *ptr_end; /* ??? This is a weak placeholder for minimum malloc alignment. */ @@ -815,7 +816,7 @@ static inline void *tcg_malloc(int size) ptr = s->pool_cur; ptr_end = ptr + size; if (unlikely(ptr_end > s->pool_end)) { - return tcg_malloc_internal(&tcg_ctx, size); + return tcg_malloc_internal(tcg_ctx, size); } else { s->pool_cur = ptr_end; return ptr; @@ -1154,7 +1155,7 @@ static inline unsigned get_mmuidx(TCGMemOpIdx oi) uintptr_t tcg_qemu_tb_exec(CPUArchState *env, uint8_t *tb_ptr); #else # define tcg_qemu_tb_exec(env, tb_ptr) \ - ((uintptr_t (*)(void *, void *))tcg_ctx.code_gen_prologue)(env, tb_ptr) + ((uintptr_t (*)(void *, void *))tcg_ctx->code_gen_prologue)(env, tb_ptr) #endif void tcg_register_jit(void *buf, size_t buf_size); diff --git a/accel/tcg/tcg-runtime.c b/accel/tcg/tcg-runtime.c index 25f0cabfed..4172ffda82 100644 --- a/accel/tcg/tcg-runtime.c +++ b/accel/tcg/tcg-runtime.c @@ -153,7 +153,7 @@ void *HELPER(lookup_tb_ptr)(CPUArchState *env) tb = tb_lookup__cpu_state(cpu, &pc, &cs_base, &flags, curr_cflags()); if (tb == NULL) { - return tcg_ctx.code_gen_epilogue; + return tcg_ctx->code_gen_epilogue; } qemu_log_mask_and_addr(CPU_LOG_EXEC, pc, "Chain %p [%d: " TARGET_FMT_lx "] %s\n", diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c index 86247f87ad..826d9869dd 100644 --- a/accel/tcg/translate-all.c +++ b/accel/tcg/translate-all.c @@ -153,7 +153,8 @@ static int v_l2_levels; static void *l1_map[V_L1_MAX_SIZE]; /* code generation context */ -TCGContext tcg_ctx; +TCGContext tcg_init_ctx; +TCGContext *tcg_ctx; TBContext tb_ctx; bool parallel_cpus; @@ -209,7 +210,7 @@ static TranslationBlock *tb_find_pc(uintptr_t tc_ptr); void cpu_gen_init(void) { - tcg_context_init(&tcg_ctx); + tcg_context_init(&tcg_init_ctx); } /* Encode VAL as a signed leb128 sequence at P. @@ -267,7 +268,7 @@ static target_long decode_sleb128(uint8_t **pp) static int encode_search(TranslationBlock *tb, uint8_t *block) { - uint8_t *highwater = tcg_ctx.code_gen_highwater; + uint8_t *highwater = tcg_ctx->code_gen_highwater; uint8_t *p = block; int i, j, n; @@ -280,12 +281,12 @@ static int encode_search(TranslationBlock *tb, uint8_t *block) if (i == 0) { prev = (j == 0 ? tb->pc : 0); } else { - prev = tcg_ctx.gen_insn_data[i - 1][j]; + prev = tcg_ctx->gen_insn_data[i - 1][j]; } - p = encode_sleb128(p, tcg_ctx.gen_insn_data[i][j] - prev); + p = encode_sleb128(p, tcg_ctx->gen_insn_data[i][j] - prev); } - prev = (i == 0 ? 0 : tcg_ctx.gen_insn_end_off[i - 1]); - p = encode_sleb128(p, tcg_ctx.gen_insn_end_off[i] - prev); + prev = (i == 0 ? 0 : tcg_ctx->gen_insn_end_off[i - 1]); + p = encode_sleb128(p, tcg_ctx->gen_insn_end_off[i] - prev); /* Test for (pending) buffer overflow. The assumption is that any one row beginning below the high water mark cannot overrun @@ -345,8 +346,8 @@ static int cpu_restore_state_from_tb(CPUState *cpu, TranslationBlock *tb, restore_state_to_opc(env, tb, data); #ifdef CONFIG_PROFILER - tcg_ctx.restore_time += profile_getclock() - ti; - tcg_ctx.restore_count++; + tcg_ctx->restore_time += profile_getclock() - ti; + tcg_ctx->restore_count++; #endif return 0; } @@ -592,7 +593,7 @@ static inline void *split_cross_256mb(void *buf1, size_t size1) buf1 = buf2; } - tcg_ctx.code_gen_buffer_size = size1; + tcg_ctx->code_gen_buffer_size = size1; return buf1; } #endif @@ -655,16 +656,16 @@ static inline void *alloc_code_gen_buffer(void) size = full_size - qemu_real_host_page_size; /* Honor a command-line option limiting the size of the buffer. */ - if (size > tcg_ctx.code_gen_buffer_size) { - size = (((uintptr_t)buf + tcg_ctx.code_gen_buffer_size) + if (size > tcg_ctx->code_gen_buffer_size) { + size = (((uintptr_t)buf + tcg_ctx->code_gen_buffer_size) & qemu_real_host_page_mask) - (uintptr_t)buf; } - tcg_ctx.code_gen_buffer_size = size; + tcg_ctx->code_gen_buffer_size = size; #ifdef __mips__ if (cross_256mb(buf, size)) { buf = split_cross_256mb(buf, size); - size = tcg_ctx.code_gen_buffer_size; + size = tcg_ctx->code_gen_buffer_size; } #endif @@ -677,7 +678,7 @@ static inline void *alloc_code_gen_buffer(void) #elif defined(_WIN32) static inline void *alloc_code_gen_buffer(void) { - size_t size = tcg_ctx.code_gen_buffer_size; + size_t size = tcg_ctx->code_gen_buffer_size; void *buf1, *buf2; /* Perform the allocation in two steps, so that the guard page @@ -696,7 +697,7 @@ static inline void *alloc_code_gen_buffer(void) { int flags = MAP_PRIVATE | MAP_ANONYMOUS; uintptr_t start = 0; - size_t size = tcg_ctx.code_gen_buffer_size; + size_t size = tcg_ctx->code_gen_buffer_size; void *buf; /* Constrain the position of the buffer based on the host cpu. @@ -713,7 +714,7 @@ static inline void *alloc_code_gen_buffer(void) flags |= MAP_32BIT; /* Cannot expect to map more than 800MB in low memory. */ if (size > 800u * 1024 * 1024) { - tcg_ctx.code_gen_buffer_size = size = 800u * 1024 * 1024; + tcg_ctx->code_gen_buffer_size = size = 800u * 1024 * 1024; } # elif defined(__sparc__) start = 0x40000000ul; @@ -753,7 +754,7 @@ static inline void *alloc_code_gen_buffer(void) default: /* Split the original buffer. Free the smaller half. */ buf2 = split_cross_256mb(buf, size); - size2 = tcg_ctx.code_gen_buffer_size; + size2 = tcg_ctx->code_gen_buffer_size; if (buf == buf2) { munmap(buf + size2 + qemu_real_host_page_size, size - size2); } else { @@ -821,9 +822,9 @@ static gint tb_tc_cmp(gconstpointer ap, gconstpointer bp) static inline void code_gen_alloc(size_t tb_size) { - tcg_ctx.code_gen_buffer_size = size_code_gen_buffer(tb_size); - tcg_ctx.code_gen_buffer = alloc_code_gen_buffer(); - if (tcg_ctx.code_gen_buffer == NULL) { + tcg_ctx->code_gen_buffer_size = size_code_gen_buffer(tb_size); + tcg_ctx->code_gen_buffer = alloc_code_gen_buffer(); + if (tcg_ctx->code_gen_buffer == NULL) { fprintf(stderr, "Could not allocate dynamic translator buffer\n"); exit(1); } @@ -851,7 +852,7 @@ void tcg_exec_init(unsigned long tb_size) #if defined(CONFIG_SOFTMMU) /* There's no guest base to take into account, so go ahead and initialize the prologue now. */ - tcg_prologue_init(&tcg_ctx); + tcg_prologue_init(tcg_ctx); #endif } @@ -867,7 +868,7 @@ static TranslationBlock *tb_alloc(target_ulong pc) assert_tb_locked(); - tb = tcg_tb_alloc(&tcg_ctx); + tb = tcg_tb_alloc(tcg_ctx); if (unlikely(tb == NULL)) { return NULL; } @@ -951,11 +952,11 @@ static void do_tb_flush(CPUState *cpu, run_on_cpu_data tb_flush_count) g_tree_foreach(tb_ctx.tb_tree, tb_host_size_iter, &host_size); printf("qemu: flush code_size=%td nb_tbs=%zu avg_tb_size=%zu\n", - tcg_ctx.code_gen_ptr - tcg_ctx.code_gen_buffer, nb_tbs, + tcg_ctx->code_gen_ptr - tcg_ctx->code_gen_buffer, nb_tbs, nb_tbs > 0 ? host_size / nb_tbs : 0); } - if ((unsigned long)(tcg_ctx.code_gen_ptr - tcg_ctx.code_gen_buffer) - > tcg_ctx.code_gen_buffer_size) { + if ((unsigned long)(tcg_ctx->code_gen_ptr - tcg_ctx->code_gen_buffer) + > tcg_ctx->code_gen_buffer_size) { cpu_abort(cpu, "Internal error: code buffer overflow\n"); } @@ -970,7 +971,7 @@ static void do_tb_flush(CPUState *cpu, run_on_cpu_data tb_flush_count) qht_reset_size(&tb_ctx.htable, CODE_GEN_HTABLE_SIZE); page_flush_tb(); - tcg_ctx.code_gen_ptr = tcg_ctx.code_gen_buffer; + tcg_ctx->code_gen_ptr = tcg_ctx->code_gen_buffer; /* XXX: flush processor icache at this point if cache flush is expensive */ atomic_mb_set(&tb_ctx.tb_flush_count, tb_ctx.tb_flush_count + 1); @@ -1318,44 +1319,44 @@ TranslationBlock *tb_gen_code(CPUState *cpu, cpu_loop_exit(cpu); } - gen_code_buf = tcg_ctx.code_gen_ptr; + gen_code_buf = tcg_ctx->code_gen_ptr; tb->tc.ptr = gen_code_buf; tb->pc = pc; tb->cs_base = cs_base; tb->flags = flags; tb->cflags = cflags; tb->trace_vcpu_dstate = *cpu->trace_dstate; - tcg_ctx.tb_cflags = cflags; + tcg_ctx->tb_cflags = cflags; #ifdef CONFIG_PROFILER - tcg_ctx.tb_count1++; /* includes aborted translations because of + tcg_ctx->tb_count1++; /* includes aborted translations because of exceptions */ ti = profile_getclock(); #endif - tcg_func_start(&tcg_ctx); + tcg_func_start(tcg_ctx); - tcg_ctx.cpu = ENV_GET_CPU(env); + tcg_ctx->cpu = ENV_GET_CPU(env); gen_intermediate_code(cpu, tb); - tcg_ctx.cpu = NULL; + tcg_ctx->cpu = NULL; trace_translate_block(tb, tb->pc, tb->tc.ptr); /* generate machine code */ tb->jmp_reset_offset[0] = TB_JMP_RESET_OFFSET_INVALID; tb->jmp_reset_offset[1] = TB_JMP_RESET_OFFSET_INVALID; - tcg_ctx.tb_jmp_reset_offset = tb->jmp_reset_offset; + tcg_ctx->tb_jmp_reset_offset = tb->jmp_reset_offset; if (TCG_TARGET_HAS_direct_jump) { - tcg_ctx.tb_jmp_insn_offset = tb->jmp_target_arg; - tcg_ctx.tb_jmp_target_addr = NULL; + tcg_ctx->tb_jmp_insn_offset = tb->jmp_target_arg; + tcg_ctx->tb_jmp_target_addr = NULL; } else { - tcg_ctx.tb_jmp_insn_offset = NULL; - tcg_ctx.tb_jmp_target_addr = tb->jmp_target_arg; + tcg_ctx->tb_jmp_insn_offset = NULL; + tcg_ctx->tb_jmp_target_addr = tb->jmp_target_arg; } #ifdef CONFIG_PROFILER - tcg_ctx.tb_count++; - tcg_ctx.interm_time += profile_getclock() - ti; + tcg_ctx->tb_count++; + tcg_ctx->interm_time += profile_getclock() - ti; ti = profile_getclock(); #endif @@ -1364,7 +1365,7 @@ TranslationBlock *tb_gen_code(CPUState *cpu, the tcg optimization currently hidden inside tcg_gen_code. All that should be required is to flush the TBs, allocate a new TB, re-initialize it per above, and re-do the actual code generation. */ - gen_code_size = tcg_gen_code(&tcg_ctx, tb); + gen_code_size = tcg_gen_code(tcg_ctx, tb); if (unlikely(gen_code_size < 0)) { goto buffer_overflow; } @@ -1375,10 +1376,10 @@ TranslationBlock *tb_gen_code(CPUState *cpu, tb->tc.size = gen_code_size; #ifdef CONFIG_PROFILER - tcg_ctx.code_time += profile_getclock() - ti; - tcg_ctx.code_in_len += tb->size; - tcg_ctx.code_out_len += gen_code_size; - tcg_ctx.search_out_len += search_size; + tcg_ctx->code_time += profile_getclock() - ti; + tcg_ctx->code_in_len += tb->size; + tcg_ctx->code_out_len += gen_code_size; + tcg_ctx->search_out_len += search_size; #endif #ifdef DEBUG_DISAS @@ -1386,8 +1387,8 @@ TranslationBlock *tb_gen_code(CPUState *cpu, qemu_log_in_addr_range(tb->pc)) { qemu_log_lock(); qemu_log("OUT: [size=%d]\n", gen_code_size); - if (tcg_ctx.data_gen_ptr) { - size_t code_size = tcg_ctx.data_gen_ptr - tb->tc.ptr; + if (tcg_ctx->data_gen_ptr) { + size_t code_size = tcg_ctx->data_gen_ptr - tb->tc.ptr; size_t data_size = gen_code_size - code_size; size_t i; @@ -1396,12 +1397,12 @@ TranslationBlock *tb_gen_code(CPUState *cpu, for (i = 0; i < data_size; i += sizeof(tcg_target_ulong)) { if (sizeof(tcg_target_ulong) == 8) { qemu_log("0x%08" PRIxPTR ": .quad 0x%016" PRIx64 "\n", - (uintptr_t)tcg_ctx.data_gen_ptr + i, - *(uint64_t *)(tcg_ctx.data_gen_ptr + i)); + (uintptr_t)tcg_ctx->data_gen_ptr + i, + *(uint64_t *)(tcg_ctx->data_gen_ptr + i)); } else { qemu_log("0x%08" PRIxPTR ": .long 0x%08x\n", - (uintptr_t)tcg_ctx.data_gen_ptr + i, - *(uint32_t *)(tcg_ctx.data_gen_ptr + i)); + (uintptr_t)tcg_ctx->data_gen_ptr + i, + *(uint32_t *)(tcg_ctx->data_gen_ptr + i)); } } } else { @@ -1413,7 +1414,7 @@ TranslationBlock *tb_gen_code(CPUState *cpu, } #endif - tcg_ctx.code_gen_ptr = (void *) + tcg_ctx->code_gen_ptr = (void *) ROUND_UP((uintptr_t)gen_code_buf + gen_code_size + search_size, CODE_GEN_ALIGN); @@ -1948,8 +1949,8 @@ void dump_exec_info(FILE *f, fprintf_function cpu_fprintf) * For avg host size we use the precise numbers from tb_tree_stats though. */ cpu_fprintf(f, "gen code size %td/%zd\n", - tcg_ctx.code_gen_ptr - tcg_ctx.code_gen_buffer, - tcg_ctx.code_gen_highwater - tcg_ctx.code_gen_buffer); + tcg_ctx->code_gen_ptr - tcg_ctx->code_gen_buffer, + tcg_ctx->code_gen_highwater - tcg_ctx->code_gen_buffer); cpu_fprintf(f, "TB count %zu\n", nb_tbs); cpu_fprintf(f, "TB avg target size %zu max=%zu bytes\n", nb_tbs ? tst.target_size / nb_tbs : 0, diff --git a/bsd-user/main.c b/bsd-user/main.c index 836daac15c..392c0ed5fb 100644 --- a/bsd-user/main.c +++ b/bsd-user/main.c @@ -977,7 +977,7 @@ int main(int argc, char **argv) /* Now that we've loaded the binary, GUEST_BASE is fixed. Delay generating the prologue until now so that the prologue can take the real value of GUEST_BASE into account. */ - tcg_prologue_init(&tcg_ctx); + tcg_prologue_init(tcg_ctx); /* build Task State */ memset(ts, 0, sizeof(TaskState)); diff --git a/linux-user/main.c b/linux-user/main.c index b288670121..5f40c1a702 100644 --- a/linux-user/main.c +++ b/linux-user/main.c @@ -4457,7 +4457,7 @@ int main(int argc, char **argv, char **envp) /* Now that we've loaded the binary, GUEST_BASE is fixed. Delay generating the prologue until now so that the prologue can take the real value of GUEST_BASE into account. */ - tcg_prologue_init(&tcg_ctx); + tcg_prologue_init(tcg_ctx); #if defined(TARGET_I386) env->cr[0] = CR0_PG_MASK | CR0_WP_MASK | CR0_PE_MASK; diff --git a/target/alpha/translate.c b/target/alpha/translate.c index 53b8c036e2..f6247bf38d 100644 --- a/target/alpha/translate.c +++ b/target/alpha/translate.c @@ -127,7 +127,7 @@ void alpha_translate_init(void) int i; cpu_env = tcg_global_reg_new_ptr(TCG_AREG0, "env"); - tcg_ctx.tcg_env = cpu_env; + tcg_ctx->tcg_env = cpu_env; for (i = 0; i < 31; i++) { cpu_std_ir[i] = tcg_global_mem_new_i64(cpu_env, diff --git a/target/arm/translate.c b/target/arm/translate.c index 397cc7afea..7873c03ae8 100644 --- a/target/arm/translate.c +++ b/target/arm/translate.c @@ -82,7 +82,7 @@ void arm_translate_init(void) int i; cpu_env = tcg_global_reg_new_ptr(TCG_AREG0, "env"); - tcg_ctx.tcg_env = cpu_env; + tcg_ctx->tcg_env = cpu_env; for (i = 0; i < 16; i++) { cpu_R[i] = tcg_global_mem_new_i32(cpu_env, diff --git a/target/cris/translate.c b/target/cris/translate.c index 07ec2b1831..cd420e018f 100644 --- a/target/cris/translate.c +++ b/target/cris/translate.c @@ -3369,7 +3369,7 @@ void cris_initialize_tcg(void) int i; cpu_env = tcg_global_reg_new_ptr(TCG_AREG0, "env"); - tcg_ctx.tcg_env = cpu_env; + tcg_ctx->tcg_env = cpu_env; cc_x = tcg_global_mem_new(cpu_env, offsetof(CPUCRISState, cc_x), "cc_x"); cc_src = tcg_global_mem_new(cpu_env, diff --git a/target/cris/translate_v10.c b/target/cris/translate_v10.c index 4a0b485d8e..5d489203f4 100644 --- a/target/cris/translate_v10.c +++ b/target/cris/translate_v10.c @@ -1273,7 +1273,7 @@ void cris_initialize_crisv10_tcg(void) int i; cpu_env = tcg_global_reg_new_ptr(TCG_AREG0, "env"); - tcg_ctx.tcg_env = cpu_env; + tcg_ctx->tcg_env = cpu_env; cc_x = tcg_global_mem_new(cpu_env, offsetof(CPUCRISState, cc_x), "cc_x"); cc_src = tcg_global_mem_new(cpu_env, diff --git a/target/hppa/translate.c b/target/hppa/translate.c index 08b2c73291..9059812d4e 100644 --- a/target/hppa/translate.c +++ b/target/hppa/translate.c @@ -127,7 +127,7 @@ void hppa_translate_init(void) int i; cpu_env = tcg_global_reg_new_ptr(TCG_AREG0, "env"); - tcg_ctx.tcg_env = cpu_env; + tcg_ctx->tcg_env = cpu_env; TCGV_UNUSED(cpu_gr[0]); for (i = 1; i < 32; i++) { diff --git a/target/i386/translate.c b/target/i386/translate.c index 6663cd1db8..dde7b144bd 100644 --- a/target/i386/translate.c +++ b/target/i386/translate.c @@ -8331,7 +8331,7 @@ void tcg_x86_init(void) int i; cpu_env = tcg_global_reg_new_ptr(TCG_AREG0, "env"); - tcg_ctx.tcg_env = cpu_env; + tcg_ctx->tcg_env = cpu_env; cpu_cc_op = tcg_global_mem_new_i32(cpu_env, offsetof(CPUX86State, cc_op), "cc_op"); cpu_cc_dst = tcg_global_mem_new(cpu_env, offsetof(CPUX86State, cc_dst), diff --git a/target/lm32/translate.c b/target/lm32/translate.c index d4a2e00165..6707967a2c 100644 --- a/target/lm32/translate.c +++ b/target/lm32/translate.c @@ -1209,7 +1209,7 @@ void lm32_translate_init(void) int i; cpu_env = tcg_global_reg_new_ptr(TCG_AREG0, "env"); - tcg_ctx.tcg_env = cpu_env; + tcg_ctx->tcg_env = cpu_env; for (i = 0; i < ARRAY_SIZE(cpu_R); i++) { cpu_R[i] = tcg_global_mem_new(cpu_env, diff --git a/target/m68k/translate.c b/target/m68k/translate.c index 3506864030..26c8b4e0ba 100644 --- a/target/m68k/translate.c +++ b/target/m68k/translate.c @@ -70,7 +70,7 @@ void m68k_tcg_init(void) int i; cpu_env = tcg_global_reg_new_ptr(TCG_AREG0, "env"); - tcg_ctx.tcg_env = cpu_env; + tcg_ctx->tcg_env = cpu_env; #define DEFO32(name, offset) \ QREG_##name = tcg_global_mem_new_i32(cpu_env, \ diff --git a/target/microblaze/translate.c b/target/microblaze/translate.c index c70a2d6644..22f8d6230b 100644 --- a/target/microblaze/translate.c +++ b/target/microblaze/translate.c @@ -1856,7 +1856,7 @@ void mb_tcg_init(void) int i; cpu_env = tcg_global_reg_new_ptr(TCG_AREG0, "env"); - tcg_ctx.tcg_env = cpu_env; + tcg_ctx->tcg_env = cpu_env; env_debug = tcg_global_mem_new(cpu_env, offsetof(CPUMBState, debug), diff --git a/target/mips/translate.c b/target/mips/translate.c index aadffbec39..7dfa94ab26 100644 --- a/target/mips/translate.c +++ b/target/mips/translate.c @@ -20455,7 +20455,7 @@ void mips_tcg_init(void) int i; cpu_env = tcg_global_reg_new_ptr(TCG_AREG0, "env"); - tcg_ctx.tcg_env = cpu_env; + tcg_ctx->tcg_env = cpu_env; TCGV_UNUSED(cpu_gpr[0]); for (i = 1; i < 32; i++) diff --git a/target/moxie/translate.c b/target/moxie/translate.c index 3f1e609028..59c70b5cef 100644 --- a/target/moxie/translate.c +++ b/target/moxie/translate.c @@ -102,7 +102,7 @@ void moxie_translate_init(void) }; cpu_env = tcg_global_reg_new_ptr(TCG_AREG0, "env"); - tcg_ctx.tcg_env = cpu_env; + tcg_ctx->tcg_env = cpu_env; cpu_pc = tcg_global_mem_new_i32(cpu_env, offsetof(CPUMoxieState, pc), "$pc"); for (i = 0; i < 16; i++) diff --git a/target/openrisc/translate.c b/target/openrisc/translate.c index 666d050650..b031f2db97 100644 --- a/target/openrisc/translate.c +++ b/target/openrisc/translate.c @@ -81,7 +81,7 @@ void openrisc_translate_init(void) int i; cpu_env = tcg_global_reg_new_ptr(TCG_AREG0, "env"); - tcg_ctx.tcg_env = cpu_env; + tcg_ctx->tcg_env = cpu_env; cpu_sr = tcg_global_mem_new(cpu_env, offsetof(CPUOpenRISCState, sr), "sr"); cpu_dflag = tcg_global_mem_new_i32(cpu_env, diff --git a/target/ppc/translate.c b/target/ppc/translate.c index 5e637d2e97..2db0fe77ff 100644 --- a/target/ppc/translate.c +++ b/target/ppc/translate.c @@ -86,7 +86,7 @@ void ppc_translate_init(void) size_t cpu_reg_names_size; cpu_env = tcg_global_reg_new_ptr(TCG_AREG0, "env"); - tcg_ctx.tcg_env = cpu_env; + tcg_ctx->tcg_env = cpu_env; p = cpu_reg_names; cpu_reg_names_size = sizeof(cpu_reg_names); diff --git a/target/s390x/translate.c b/target/s390x/translate.c index 399aeb2800..1c58643293 100644 --- a/target/s390x/translate.c +++ b/target/s390x/translate.c @@ -113,7 +113,7 @@ void s390x_translate_init(void) int i; cpu_env = tcg_global_reg_new_ptr(TCG_AREG0, "env"); - tcg_ctx.tcg_env = cpu_env; + tcg_ctx->tcg_env = cpu_env; psw_addr = tcg_global_mem_new_i64(cpu_env, offsetof(CPUS390XState, psw.addr), "psw_addr"); diff --git a/target/sh4/translate.c b/target/sh4/translate.c index f918bae978..c13be851ba 100644 --- a/target/sh4/translate.c +++ b/target/sh4/translate.c @@ -100,7 +100,7 @@ void sh4_translate_init(void) }; cpu_env = tcg_global_reg_new_ptr(TCG_AREG0, "env"); - tcg_ctx.tcg_env = cpu_env; + tcg_ctx->tcg_env = cpu_env; for (i = 0; i < 24; i++) { cpu_gregs[i] = tcg_global_mem_new_i32(cpu_env, diff --git a/target/sparc/translate.c b/target/sparc/translate.c index 0669d4e8e5..adb286de8f 100644 --- a/target/sparc/translate.c +++ b/target/sparc/translate.c @@ -5917,7 +5917,7 @@ void sparc_tcg_init(void) unsigned int i; cpu_env = tcg_global_reg_new_ptr(TCG_AREG0, "env"); - tcg_ctx.tcg_env = cpu_env; + tcg_ctx->tcg_env = cpu_env; cpu_regwptr = tcg_global_mem_new_ptr(cpu_env, offsetof(CPUSPARCState, regwptr), diff --git a/target/tilegx/translate.c b/target/tilegx/translate.c index 5cd84f6b25..a744c38bb7 100644 --- a/target/tilegx/translate.c +++ b/target/tilegx/translate.c @@ -2446,7 +2446,7 @@ void tilegx_tcg_init(void) int i; cpu_env = tcg_global_reg_new_ptr(TCG_AREG0, "env"); - tcg_ctx.tcg_env = cpu_env; + tcg_ctx->tcg_env = cpu_env; cpu_pc = tcg_global_mem_new_i64(cpu_env, offsetof(CPUTLGState, pc), "pc"); for (i = 0; i < TILEGX_R_COUNT; i++) { cpu_regs[i] = tcg_global_mem_new_i64(cpu_env, diff --git a/target/tricore/translate.c b/target/tricore/translate.c index 042c0e69bc..590cbbee8b 100644 --- a/target/tricore/translate.c +++ b/target/tricore/translate.c @@ -8882,7 +8882,7 @@ void tricore_tcg_init(void) int i; cpu_env = tcg_global_reg_new_ptr(TCG_AREG0, "env"); - tcg_ctx.tcg_env = cpu_env; + tcg_ctx->tcg_env = cpu_env; /* reg init */ for (i = 0 ; i < 16 ; i++) { cpu_gpr_a[i] = tcg_global_mem_new(cpu_env, diff --git a/target/unicore32/translate.c b/target/unicore32/translate.c index d717de0335..070653e2d1 100644 --- a/target/unicore32/translate.c +++ b/target/unicore32/translate.c @@ -75,7 +75,7 @@ void uc32_translate_init(void) int i; cpu_env = tcg_global_reg_new_ptr(TCG_AREG0, "env"); - tcg_ctx.tcg_env = cpu_env; + tcg_ctx->tcg_env = cpu_env; for (i = 0; i < 32; i++) { cpu_R[i] = tcg_global_mem_new_i32(cpu_env, diff --git a/target/xtensa/translate.c b/target/xtensa/translate.c index f62319eddd..ab96b77d88 100644 --- a/target/xtensa/translate.c +++ b/target/xtensa/translate.c @@ -222,7 +222,7 @@ void xtensa_translate_init(void) int i; cpu_env = tcg_global_reg_new_ptr(TCG_AREG0, "env"); - tcg_ctx.tcg_env = cpu_env; + tcg_ctx->tcg_env = cpu_env; cpu_pc = tcg_global_mem_new_i32(cpu_env, offsetof(CPUXtensaState, pc), "pc"); diff --git a/tcg/tcg-op.c b/tcg/tcg-op.c index 3253451115..7764e2a497 100644 --- a/tcg/tcg-op.c +++ b/tcg/tcg-op.c @@ -48,7 +48,7 @@ extern TCGv_i32 TCGV_HIGH_link_error(TCGv_i64); static inline TCGOp *tcg_emit_op(TCGOpcode opc) { - TCGContext *ctx = &tcg_ctx; + TCGContext *ctx = tcg_ctx; int oi = ctx->gen_next_op_idx; int ni = oi + 1; int pi = oi - 1; @@ -121,7 +121,7 @@ void tcg_gen_op6(TCGOpcode opc, TCGArg a1, TCGArg a2, TCGArg a3, void tcg_gen_mb(TCGBar mb_type) { - if (tcg_ctx.tb_cflags & CF_PARALLEL) { + if (tcg_ctx->tb_cflags & CF_PARALLEL) { tcg_gen_op1(INDEX_op_mb, mb_type); } } @@ -2552,8 +2552,8 @@ void tcg_gen_goto_tb(unsigned idx) tcg_debug_assert(idx <= 1); #ifdef CONFIG_DEBUG_TCG /* Verify that we havn't seen this numbered exit before. */ - tcg_debug_assert((tcg_ctx.goto_tb_issue_mask & (1 << idx)) == 0); - tcg_ctx.goto_tb_issue_mask |= 1 << idx; + tcg_debug_assert((tcg_ctx->goto_tb_issue_mask & (1 << idx)) == 0); + tcg_ctx->goto_tb_issue_mask |= 1 << idx; #endif tcg_gen_op1i(INDEX_op_goto_tb, idx); } @@ -2562,7 +2562,7 @@ void tcg_gen_lookup_and_goto_ptr(void) { if (TCG_TARGET_HAS_goto_ptr && !qemu_loglevel_mask(CPU_LOG_TB_NOCHAIN)) { TCGv_ptr ptr = tcg_temp_new_ptr(); - gen_helper_lookup_tb_ptr(ptr, tcg_ctx.tcg_env); + gen_helper_lookup_tb_ptr(ptr, tcg_ctx->tcg_env); tcg_gen_op1i(INDEX_op_goto_ptr, tcgv_ptr_arg(ptr)); tcg_temp_free_ptr(ptr); } else { @@ -2648,7 +2648,7 @@ void tcg_gen_qemu_ld_i32(TCGv_i32 val, TCGv addr, TCGArg idx, TCGMemOp memop) { tcg_gen_req_mo(TCG_MO_LD_LD | TCG_MO_ST_LD); memop = tcg_canonicalize_memop(memop, 0, 0); - trace_guest_mem_before_tcg(tcg_ctx.cpu, tcg_ctx.tcg_env, + trace_guest_mem_before_tcg(tcg_ctx->cpu, tcg_ctx->tcg_env, addr, trace_mem_get_info(memop, 0)); gen_ldst_i32(INDEX_op_qemu_ld_i32, val, addr, memop, idx); } @@ -2657,7 +2657,7 @@ void tcg_gen_qemu_st_i32(TCGv_i32 val, TCGv addr, TCGArg idx, TCGMemOp memop) { tcg_gen_req_mo(TCG_MO_LD_ST | TCG_MO_ST_ST); memop = tcg_canonicalize_memop(memop, 0, 1); - trace_guest_mem_before_tcg(tcg_ctx.cpu, tcg_ctx.tcg_env, + trace_guest_mem_before_tcg(tcg_ctx->cpu, tcg_ctx->tcg_env, addr, trace_mem_get_info(memop, 1)); gen_ldst_i32(INDEX_op_qemu_st_i32, val, addr, memop, idx); } @@ -2676,7 +2676,7 @@ void tcg_gen_qemu_ld_i64(TCGv_i64 val, TCGv addr, TCGArg idx, TCGMemOp memop) } memop = tcg_canonicalize_memop(memop, 1, 0); - trace_guest_mem_before_tcg(tcg_ctx.cpu, tcg_ctx.tcg_env, + trace_guest_mem_before_tcg(tcg_ctx->cpu, tcg_ctx->tcg_env, addr, trace_mem_get_info(memop, 0)); gen_ldst_i64(INDEX_op_qemu_ld_i64, val, addr, memop, idx); } @@ -2690,7 +2690,7 @@ void tcg_gen_qemu_st_i64(TCGv_i64 val, TCGv addr, TCGArg idx, TCGMemOp memop) } memop = tcg_canonicalize_memop(memop, 1, 1); - trace_guest_mem_before_tcg(tcg_ctx.cpu, tcg_ctx.tcg_env, + trace_guest_mem_before_tcg(tcg_ctx->cpu, tcg_ctx->tcg_env, addr, trace_mem_get_info(memop, 1)); gen_ldst_i64(INDEX_op_qemu_st_i64, val, addr, memop, idx); } @@ -2780,7 +2780,7 @@ void tcg_gen_atomic_cmpxchg_i32(TCGv_i32 retv, TCGv addr, TCGv_i32 cmpv, { memop = tcg_canonicalize_memop(memop, 0, 0); - if (!(tcg_ctx.tb_cflags & CF_PARALLEL)) { + if (!(tcg_ctx->tb_cflags & CF_PARALLEL)) { TCGv_i32 t1 = tcg_temp_new_i32(); TCGv_i32 t2 = tcg_temp_new_i32(); @@ -2806,11 +2806,11 @@ void tcg_gen_atomic_cmpxchg_i32(TCGv_i32 retv, TCGv addr, TCGv_i32 cmpv, #ifdef CONFIG_SOFTMMU { TCGv_i32 oi = tcg_const_i32(make_memop_idx(memop & ~MO_SIGN, idx)); - gen(retv, tcg_ctx.tcg_env, addr, cmpv, newv, oi); + gen(retv, tcg_ctx->tcg_env, addr, cmpv, newv, oi); tcg_temp_free_i32(oi); } #else - gen(retv, tcg_ctx.tcg_env, addr, cmpv, newv); + gen(retv, tcg_ctx->tcg_env, addr, cmpv, newv); #endif if (memop & MO_SIGN) { @@ -2824,7 +2824,7 @@ void tcg_gen_atomic_cmpxchg_i64(TCGv_i64 retv, TCGv addr, TCGv_i64 cmpv, { memop = tcg_canonicalize_memop(memop, 1, 0); - if (!(tcg_ctx.tb_cflags & CF_PARALLEL)) { + if (!(tcg_ctx->tb_cflags & CF_PARALLEL)) { TCGv_i64 t1 = tcg_temp_new_i64(); TCGv_i64 t2 = tcg_temp_new_i64(); @@ -2851,14 +2851,14 @@ void tcg_gen_atomic_cmpxchg_i64(TCGv_i64 retv, TCGv addr, TCGv_i64 cmpv, #ifdef CONFIG_SOFTMMU { TCGv_i32 oi = tcg_const_i32(make_memop_idx(memop, idx)); - gen(retv, tcg_ctx.tcg_env, addr, cmpv, newv, oi); + gen(retv, tcg_ctx->tcg_env, addr, cmpv, newv, oi); tcg_temp_free_i32(oi); } #else - gen(retv, tcg_ctx.tcg_env, addr, cmpv, newv); + gen(retv, tcg_ctx->tcg_env, addr, cmpv, newv); #endif #else - gen_helper_exit_atomic(tcg_ctx.tcg_env); + gen_helper_exit_atomic(tcg_ctx->tcg_env); /* Produce a result, so that we have a well-formed opcode stream with respect to uses of the result in the (dead) code following. */ tcg_gen_movi_i64(retv, 0); @@ -2914,11 +2914,11 @@ static void do_atomic_op_i32(TCGv_i32 ret, TCGv addr, TCGv_i32 val, #ifdef CONFIG_SOFTMMU { TCGv_i32 oi = tcg_const_i32(make_memop_idx(memop & ~MO_SIGN, idx)); - gen(ret, tcg_ctx.tcg_env, addr, val, oi); + gen(ret, tcg_ctx->tcg_env, addr, val, oi); tcg_temp_free_i32(oi); } #else - gen(ret, tcg_ctx.tcg_env, addr, val); + gen(ret, tcg_ctx->tcg_env, addr, val); #endif if (memop & MO_SIGN) { @@ -2959,14 +2959,14 @@ static void do_atomic_op_i64(TCGv_i64 ret, TCGv addr, TCGv_i64 val, #ifdef CONFIG_SOFTMMU { TCGv_i32 oi = tcg_const_i32(make_memop_idx(memop & ~MO_SIGN, idx)); - gen(ret, tcg_ctx.tcg_env, addr, val, oi); + gen(ret, tcg_ctx->tcg_env, addr, val, oi); tcg_temp_free_i32(oi); } #else - gen(ret, tcg_ctx.tcg_env, addr, val); + gen(ret, tcg_ctx->tcg_env, addr, val); #endif #else - gen_helper_exit_atomic(tcg_ctx.tcg_env); + gen_helper_exit_atomic(tcg_ctx->tcg_env); /* Produce a result, so that we have a well-formed opcode stream with respect to uses of the result in the (dead) code following. */ tcg_gen_movi_i64(ret, 0); @@ -3001,7 +3001,7 @@ static void * const table_##NAME[16] = { \ void tcg_gen_atomic_##NAME##_i32 \ (TCGv_i32 ret, TCGv addr, TCGv_i32 val, TCGArg idx, TCGMemOp memop) \ { \ - if (tcg_ctx.tb_cflags & CF_PARALLEL) { \ + if (tcg_ctx->tb_cflags & CF_PARALLEL) { \ do_atomic_op_i32(ret, addr, val, idx, memop, table_##NAME); \ } else { \ do_nonatomic_op_i32(ret, addr, val, idx, memop, NEW, \ @@ -3011,7 +3011,7 @@ void tcg_gen_atomic_##NAME##_i32 \ void tcg_gen_atomic_##NAME##_i64 \ (TCGv_i64 ret, TCGv addr, TCGv_i64 val, TCGArg idx, TCGMemOp memop) \ { \ - if (tcg_ctx.tb_cflags & CF_PARALLEL) { \ + if (tcg_ctx->tb_cflags & CF_PARALLEL) { \ do_atomic_op_i64(ret, addr, val, idx, memop, table_##NAME); \ } else { \ do_nonatomic_op_i64(ret, addr, val, idx, memop, NEW, \ diff --git a/tcg/tcg.c b/tcg/tcg.c index 7cf39f7067..e509fdc255 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -243,7 +243,7 @@ static void tcg_out_label(TCGContext *s, TCGLabel *l, tcg_insn_unit *ptr) TCGLabel *gen_new_label(void) { - TCGContext *s = &tcg_ctx; + TCGContext *s = tcg_ctx; TCGLabel *l = tcg_malloc(sizeof(TCGLabel)); *l = (TCGLabel){ @@ -385,6 +385,8 @@ void tcg_context_init(TCGContext *s) for (; i < ARRAY_SIZE(tcg_target_reg_alloc_order); ++i) { indirect_reg_alloc_order[i] = tcg_target_reg_alloc_order[i]; } + + tcg_ctx = s; } /* @@ -526,7 +528,7 @@ void tcg_set_frame(TCGContext *s, TCGReg reg, intptr_t start, intptr_t size) TCGv_i32 tcg_global_reg_new_i32(TCGReg reg, const char *name) { - TCGContext *s = &tcg_ctx; + TCGContext *s = tcg_ctx; int idx; if (tcg_regset_test_reg(s->reserved_regs, reg)) { @@ -538,7 +540,7 @@ TCGv_i32 tcg_global_reg_new_i32(TCGReg reg, const char *name) TCGv_i64 tcg_global_reg_new_i64(TCGReg reg, const char *name) { - TCGContext *s = &tcg_ctx; + TCGContext *s = tcg_ctx; int idx; if (tcg_regset_test_reg(s->reserved_regs, reg)) { @@ -551,7 +553,7 @@ TCGv_i64 tcg_global_reg_new_i64(TCGReg reg, const char *name) int tcg_global_mem_new_internal(TCGType type, TCGv_ptr base, intptr_t offset, const char *name) { - TCGContext *s = &tcg_ctx; + TCGContext *s = tcg_ctx; TCGTemp *base_ts = &s->temps[GET_TCGV_PTR(base)]; TCGTemp *ts = tcg_global_alloc(s); int indirect_reg = 0, bigendian = 0; @@ -606,7 +608,7 @@ int tcg_global_mem_new_internal(TCGType type, TCGv_ptr base, static int tcg_temp_new_internal(TCGType type, int temp_local) { - TCGContext *s = &tcg_ctx; + TCGContext *s = tcg_ctx; TCGTemp *ts; int idx, k; @@ -668,7 +670,7 @@ TCGv_i64 tcg_temp_new_internal_i64(int temp_local) static void tcg_temp_free_internal(int idx) { - TCGContext *s = &tcg_ctx; + TCGContext *s = tcg_ctx; TCGTemp *ts; int k; @@ -733,13 +735,13 @@ TCGv_i64 tcg_const_local_i64(int64_t val) #if defined(CONFIG_DEBUG_TCG) void tcg_clear_temp_count(void) { - TCGContext *s = &tcg_ctx; + TCGContext *s = tcg_ctx; s->temps_in_use = 0; } int tcg_check_temp_count(void) { - TCGContext *s = &tcg_ctx; + TCGContext *s = tcg_ctx; if (s->temps_in_use) { /* Clear the count so that we don't give another * warning immediately next time around. @@ -979,7 +981,7 @@ bool tcg_op_supported(TCGOpcode op) and endian swap in tcg_reg_alloc_call(). */ void tcg_gen_callN(void *func, TCGArg ret, int nargs, TCGArg *args) { - TCGContext *s = &tcg_ctx; + TCGContext *s = tcg_ctx; int i, real_args, nb_rets, pi; unsigned sizemask, flags; TCGHelperInfo *info; @@ -2924,7 +2926,7 @@ int tcg_gen_code(TCGContext *s, TranslationBlock *tb) #ifdef CONFIG_PROFILER void tcg_dump_info(FILE *f, fprintf_function cpu_fprintf) { - TCGContext *s = &tcg_ctx; + TCGContext *s = tcg_ctx; int64_t tb_count = s->tb_count; int64_t tb_div_count = tb_count ? tb_count : 1; int64_t tot = s->interm_time + s->code_time; From patchwork Mon Oct 16 17:26:02 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 115973 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp3964318qgn; Mon, 16 Oct 2017 11:01:49 -0700 (PDT) X-Received: by 10.55.27.25 with SMTP id b25mr14506064qkb.144.1508176909168; Mon, 16 Oct 2017 11:01:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508176909; cv=none; d=google.com; s=arc-20160816; b=XNYxg406Ef4JlgU/h8INwZ5U7PpEMJAmojpLBhfIWjUGsISWrocqVzZjLu0mgwoIxt 4FsID2rxB91QxHPSGGSigtJPy4ya3iPTTeJVsJlZgTa/JCVnht2TYN8462gYUS8HZh45 z4E9nI27I6c76YTFyjFaX0Ue5V5RaKXOWmUIns950n0cBgRimyI2qGzUU5hsHNIPYidf K382K0rE9zH9CXiAGaoxojl2xYMCBJBJ324tSMGFtHzigMtaXefM4NwVxH1YIR69PiA+ or7J85C1j1Ef1Q+TFtE3YX9SqGrPNBFInokj/9s1BCVyQYVoMSuJu1M4QqxHqUzcZAox 26vA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=ViV/bGkaXUS0nCNcyrWZvDanioqzWbtSBi1CASquMq0=; b=YIzprxRwzk2HKMGakSbI8N5hjGwU50ghqvV+QMukepKkU1Yk5Y1ZoahRUcGRi1L7gK 2Abj61nZC25X+4ProA462NTn0TH88NV82+wkhLzrCjMeZDNzI7mWb7XVbq01C2TqBwX3 i32iSM7XKecltSZ4Lrds9Eb8JJhjntR+5gJke69Dl+ouinA1egq7CM13PqALhOpzrDBu mEaWaC1/bjZpZ/nFKdPb1YeY9PplwENP0xmcUs+hu34ZJegcFEmSdAyoCDoISBs0ssby 81JNXNaKZyEA/J02Md8GCPhsVwk9KeZc589oFuEUxWP9ZrvxhPUZBvdqg+8BuphRPGF8 ML5A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=N42j7RRO; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id o74si865944qka.351.2017.10.16.11.01.48 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 16 Oct 2017 11:01:49 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=N42j7RRO; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:34457 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e49hz-0007PP-49 for patch@linaro.org; Mon, 16 Oct 2017 14:01:47 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52779) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e49Aa-0002oL-61 for qemu-devel@nongnu.org; Mon, 16 Oct 2017 13:27:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e49AZ-00040U-1T for qemu-devel@nongnu.org; Mon, 16 Oct 2017 13:27:16 -0400 Received: from mail-pf0-x233.google.com ([2607:f8b0:400e:c00::233]:46254) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e49AY-0003yr-Ra for qemu-devel@nongnu.org; Mon, 16 Oct 2017 13:27:14 -0400 Received: by mail-pf0-x233.google.com with SMTP id p87so16296477pfj.3 for ; Mon, 16 Oct 2017 10:27:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ViV/bGkaXUS0nCNcyrWZvDanioqzWbtSBi1CASquMq0=; b=N42j7RROlSU/aw6k3dy9sfXc76fzkIZXgDcVwT8ZcXFknXW2sn9XA3pG9r5MHQfusx 6In/CLfmt/g8oF3/cebxTA14iDFtTRMr3XaYNWN7tFSO9Fz9NK9ZdlCkIhkOatg5a1WD txNdruWyRCN9Wfim2KXjLem6z/nb9TG848kxk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ViV/bGkaXUS0nCNcyrWZvDanioqzWbtSBi1CASquMq0=; b=MfrPtp8RzwLB1uZeV97o1rvb1Xg/Z7w88Lvg98Pt7cj9ljkdPFa9A0CQdUqj68iz+n 02J4G9AqklaK0OTjGD0DqsURN/U5ycgq2Ywlnl7/2iFxcNHhG9WPH8cv29y0mWEDIsyh 8gTCo7bTtEv7+h0/iMVYZFtg1zxHPKFuhh9lvCjC/inzaF7YMK94YT68gSWxN2V0WCj0 XQ6nl62o3Psxh3fOCJcE9gjtUIMRD3iRHqhpwaDMq6jPXJPxPwjsvICGluuON++TlkA4 WnGqgp8kwuZJ+8IStKz6mT84OgiFvfWEZcpOCVAiztqWwVZ/6LmBlGL7hJarQ+3owWwT kuSQ== X-Gm-Message-State: AMCzsaVaHQSwwPQ6KHo/aDc1amkNxpviNqj9e+GrjNTx4/WEC91grjJ8 WBC6yKkuyWusoToNxHbb0UxiGQy5Wes= X-Google-Smtp-Source: AOwi7QDf5u+1l5aRR63BdzHsJaVeDBGY3CDRRI6KgU/lurnlBuTfEgaxT0WQdDncJOm1lJG3C6IiEQ== X-Received: by 10.159.207.131 with SMTP id z3mr9725159plo.191.1508174833726; Mon, 16 Oct 2017 10:27:13 -0700 (PDT) Received: from cloudburst.twiddle.net (97-126-104-76.tukw.qwest.net. [97.126.104.76]) by smtp.gmail.com with ESMTPSA id i187sm5594249pfc.96.2017.10.16.10.27.12 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 16 Oct 2017 10:27:12 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Mon, 16 Oct 2017 10:26:02 -0700 Message-Id: <20171016172609.23422-44-richard.henderson@linaro.org> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171016172609.23422-1-richard.henderson@linaro.org> References: <20171016172609.23422-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c00::233 Subject: [Qemu-devel] [PATCH v6 43/50] gen-icount: fold exitreq_label into TCGContext 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: cota@braap.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: "Emilio G. Cota" Groundwork for supporting multiple TCG contexts. Reviewed-by: Richard Henderson Reviewed-by: Alex BennĂ©e Signed-off-by: Emilio G. Cota --- include/exec/gen-icount.h | 7 +++---- tcg/tcg.h | 2 ++ 2 files changed, 5 insertions(+), 4 deletions(-) -- 2.13.6 diff --git a/include/exec/gen-icount.h b/include/exec/gen-icount.h index c58b0b2585..fe80176462 100644 --- a/include/exec/gen-icount.h +++ b/include/exec/gen-icount.h @@ -6,13 +6,12 @@ /* Helpers for instruction counting code generation. */ static int icount_start_insn_idx; -static TCGLabel *exitreq_label; static inline void gen_tb_start(TranslationBlock *tb) { TCGv_i32 count, imm; - exitreq_label = gen_new_label(); + tcg_ctx->exitreq_label = gen_new_label(); if (tb_cflags(tb) & CF_USE_ICOUNT) { count = tcg_temp_local_new_i32(); } else { @@ -34,7 +33,7 @@ static inline void gen_tb_start(TranslationBlock *tb) tcg_temp_free_i32(imm); } - tcg_gen_brcondi_i32(TCG_COND_LT, count, 0, exitreq_label); + tcg_gen_brcondi_i32(TCG_COND_LT, count, 0, tcg_ctx->exitreq_label); if (tb_cflags(tb) & CF_USE_ICOUNT) { tcg_gen_st16_i32(count, tcg_ctx->tcg_env, @@ -52,7 +51,7 @@ static inline void gen_tb_end(TranslationBlock *tb, int num_insns) tcg_set_insn_param(icount_start_insn_idx, 1, num_insns); } - gen_set_label(exitreq_label); + gen_set_label(tcg_ctx->exitreq_label); tcg_gen_exit_tb((uintptr_t)tb + TB_EXIT_REQUESTED); /* Terminate the linked list. */ diff --git a/tcg/tcg.h b/tcg/tcg.h index 859020a0fd..dd11d9f835 100644 --- a/tcg/tcg.h +++ b/tcg/tcg.h @@ -717,6 +717,8 @@ struct TCGContext { struct TCGLabelPoolData *pool_labels; #endif + TCGLabel *exitreq_label; + TCGTempSet free_temps[TCG_TYPE_COUNT * 2]; TCGTemp temps[TCG_MAX_TEMPS]; /* globals first, temps after */ From patchwork Mon Oct 16 17:26:03 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 115977 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp3968953qgn; Mon, 16 Oct 2017 11:06:13 -0700 (PDT) X-Received: by 10.200.4.169 with SMTP id s41mr15910822qtg.212.1508177173515; Mon, 16 Oct 2017 11:06:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508177173; cv=none; d=google.com; s=arc-20160816; b=VzvlUOoPzMEBfzzXGhszt2QF6A14ZtO3xAvtH/vmJ24q3OSlIFubTnTtfaNehQ645+ g69uTafOhocIL7Jjq64WRyrGLp3PjWm1cOkbGSj4rP5sHqxI4c1GOh+HBnUAlMv5phBf 4X6tBH2PiRHS41IQwWmDJ/PvmOVd/7jf9J0aGyL2VkJx0egxzqwxvBw9btk8emvpK+v5 BxPIS1cErxXCWRElsBL+qfpQKvAQ/i3wUobSHIEb3uGlnRZyW9Zss1IqaB63SgTEAScT U3xd9QjJu3JssheLArCbTb+iVnOoHViGaas56GyvASTuv4y4/LGBy8tlfR/0M0oCavOR icyA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=vCy259Hd0iPkc7/74Haae/g7ny02+7f0iEMwV2uAIVI=; b=YG3s4LuYY4PQ/zU8nCw+VorqNLroVv9l3sasR5CLe+22fTStpuPSOpjpWHjVSmV6yj iI/FTqacElxkoYQNa91YOMmLd+KupmRImEF5cy2OLAGz/lrqN/LoIqdr+3/kGpfAVFh6 RQucKQDcT9T2YViheJkTgsPMr9VbutnDfd9jFAhb0oQJPoGCVdSTODpHHjDsWE8g90kY gEVRkRzh4Hw6Q5UY+4aGoKbIudBQ8d3BSnkBDomqOccwr39FGAh5YJwByRc52dnLyHtB 3b1cnu1X7QCLkG/rLb0+YbJ/nOwgNA77ajr++bWZSU0qk4W7R/1zGq1iE8/5SW/DDrUg 6kqA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=VlBO/fdE; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id d129si2372573qka.305.2017.10.16.11.06.13 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 16 Oct 2017 11:06:13 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=VlBO/fdE; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:34479 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e49mF-0002Ba-Ee for patch@linaro.org; Mon, 16 Oct 2017 14:06:11 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52800) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e49Ab-0002pM-5b for qemu-devel@nongnu.org; Mon, 16 Oct 2017 13:27:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e49Aa-00041e-By for qemu-devel@nongnu.org; Mon, 16 Oct 2017 13:27:17 -0400 Received: from mail-pf0-x234.google.com ([2607:f8b0:400e:c00::234]:46254) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e49Aa-00040w-5j for qemu-devel@nongnu.org; Mon, 16 Oct 2017 13:27:16 -0400 Received: by mail-pf0-x234.google.com with SMTP id p87so16296522pfj.3 for ; Mon, 16 Oct 2017 10:27:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=vCy259Hd0iPkc7/74Haae/g7ny02+7f0iEMwV2uAIVI=; b=VlBO/fdEoBeNW3MLqaJPlq8nTgP+umFv5Wxbv3869MeYD/pDSqWrk6blyXbUXkPtig IyBOt6Su8WWydsWMwqPO0Nwh+gUVgq94HCFQ2bQhSxINqQviVazSGs1wxsP2gbwySNLT +GrFhmudMN/vNuCbtJfvIN9XbWGbuphzuTTeQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=vCy259Hd0iPkc7/74Haae/g7ny02+7f0iEMwV2uAIVI=; b=Ewm/k4rUmwUuI39VO76vhAVjrAOGpjrzx33qZr7r2vmhiEjoAFseKplB0HP8VLlmUh MJMUAQ2DNV1ix/eKym2H0QSAlcQ/hy/w2yOmKkDzp8AawN2sYjqwGI7wCMsPaGadhVjn RWbLbQQfKceTXBDLpneC1HKQ2Lp/zmwGBpPJGXQP63KvGGXNbAm5m5zp/fbqFymSLYWr vYNQI9UgIsZOEWvnHYzX/h0tz2wqhrsJouS2WuwkX5lPUxjC5aeQnh08FgGtImzIOQPn MRWT6zNdig+xuOXB3rXgNubBZlWqgcwKsmyLh3pNh2Z4QRxh4vPbV2X/bAOcJjtFM1ow KJKQ== X-Gm-Message-State: AMCzsaW24vW0dx2s/Tq6GLN3ZNKtzE25T1ce310XTbn9vAl/pdmEFrJJ eixvg3cf+jvIU2mnp6x7SFQ7LDPtXqo= X-Google-Smtp-Source: AOwi7QAX+ZaUtKa5sek9Yydp2EsPj9/feRCwvtw/9Jqq0pxbEYI74nZCFRuTAbL1+uxlcloj8DSyZQ== X-Received: by 10.98.58.69 with SMTP id h66mr9275093pfa.121.1508174835064; Mon, 16 Oct 2017 10:27:15 -0700 (PDT) Received: from cloudburst.twiddle.net (97-126-104-76.tukw.qwest.net. [97.126.104.76]) by smtp.gmail.com with ESMTPSA id i187sm5594249pfc.96.2017.10.16.10.27.13 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 16 Oct 2017 10:27:14 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Mon, 16 Oct 2017 10:26:03 -0700 Message-Id: <20171016172609.23422-45-richard.henderson@linaro.org> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171016172609.23422-1-richard.henderson@linaro.org> References: <20171016172609.23422-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c00::234 Subject: [Qemu-devel] [PATCH v6 44/50] tcg: introduce **tcg_ctxs to keep track of all TCGContext's 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: cota@braap.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: "Emilio G. Cota" Groundwork for supporting multiple TCG contexts. Note that having n_tcg_ctxs is unnecessary. However, it is convenient to have it, since it will simplify iterating over the array: we'll have just a for loop instead of having to iterate over a NULL-terminated array (which would require n+1 elems) or having to check with ifdef's for usermode/softmmu. Reviewed-by: Richard Henderson Signed-off-by: Emilio G. Cota --- tcg/tcg.c | 5 +++++ 1 file changed, 5 insertions(+) -- 2.13.6 diff --git a/tcg/tcg.c b/tcg/tcg.c index e509fdc255..225e7cccea 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -118,6 +118,9 @@ static bool tcg_out_ldst_finalize(TCGContext *s); #define TCG_HIGHWATER 1024 +static TCGContext **tcg_ctxs; +static unsigned int n_tcg_ctxs; + static TCGRegSet tcg_target_available_regs[2]; static TCGRegSet tcg_target_call_clobber_regs; @@ -387,6 +390,8 @@ void tcg_context_init(TCGContext *s) } tcg_ctx = s; + tcg_ctxs = &tcg_ctx; + n_tcg_ctxs = 1; } /* From patchwork Mon Oct 16 17:26:04 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 115963 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp3955684qgn; Mon, 16 Oct 2017 10:52:10 -0700 (PDT) X-Received: by 10.200.28.74 with SMTP id j10mr16147686qtk.11.1508176330910; Mon, 16 Oct 2017 10:52:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508176330; cv=none; d=google.com; s=arc-20160816; b=aDQrWrqyazA4BfRG7/p0tAQ+CwOdoSYD2bMGLiyBC3806uO9Rb1zrnXffZloh+uF2j gTN0rwWJiiy6PLwi8JAtCO/14fEZWMEaADpf5xeEvZTfPTrjqffyMF3eeIYrbq0riXQI RAJGucABwVhZ5n6NQUsJQwx/FD//QwY/yQiGS+qVuzJ4oUCYSSz5ikkuqOyJq/BysoIs X6+N+nwAR3FAVJLE7j0kn59tvWnC3ar2ALEMETGrBfmpZJvckPRUjZ0lzcSHgAQDjFZ6 kqJLI9zFXn1l2xGiBdiECDhA3rSgdgMgGGbgfFpY/mEgY86E7i9QzP7NmRU7lK7hXAvP iOxQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=UFyA04crwXq2Ky2kUeX488IkU0fCRnaCfCacYkCL7m0=; b=D/zWUFHilD3ZvhCFqX5r5Lvo+aC2LW4IuQHX1oIiDBbf97UvHFIwM8Rb0+Pxqbwhrc YQpuoyJUVUiQmK/dt73LhCujMgeo3V7o93KBJZiplzlOXqCJEmc3VyCHtG0SW2I2yG+P H5xlkY2C0LMQBsDouqNLZd+G8z9LYOWymzpmF5n5hmn5GLxDa5prCmkvuKCQkh4m91pL n/ZSR339y/3cv/snWpurcZQyhU/UnsgSUNGLTVSI2cGWwowLV8fdw377ilkVbkR89c4K fFdnwiq+VBwUxs1i2oPkpOHzhtYn2HXi73sDA64i3cteHdRq6BCzJW/f2blrAU30Ax2M zt8Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=fdvy7Kv6; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id t14si4142778qtj.23.2017.10.16.10.52.10 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 16 Oct 2017 10:52:10 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=fdvy7Kv6; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:34399 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e49Ye-0006SO-Ne for patch@linaro.org; Mon, 16 Oct 2017 13:52:08 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52865) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e49Af-0002tz-AY for qemu-devel@nongnu.org; Mon, 16 Oct 2017 13:27:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e49Ac-00043U-1t for qemu-devel@nongnu.org; Mon, 16 Oct 2017 13:27:21 -0400 Received: from mail-pf0-x236.google.com ([2607:f8b0:400e:c00::236]:47608) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e49Ab-00042W-Q2 for qemu-devel@nongnu.org; Mon, 16 Oct 2017 13:27:17 -0400 Received: by mail-pf0-x236.google.com with SMTP id z11so16298919pfk.4 for ; Mon, 16 Oct 2017 10:27:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=UFyA04crwXq2Ky2kUeX488IkU0fCRnaCfCacYkCL7m0=; b=fdvy7Kv6gRZfjFcBb7EmOHThVZrjHCY2Xxy2ABbiLsSsvn1EfImV2TQd/OuSVcmUAZ d/bO0SY8GJAK8tdm/q9EoFtrbLXtBh744D2LhKQv/Vi0FVWOIc/HkvYV+sI/WZzGEbOU +4+fWMP3XflzxBIJIxOIF7U7dS8E4aXyi6V2U= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=UFyA04crwXq2Ky2kUeX488IkU0fCRnaCfCacYkCL7m0=; b=ox2+7DTBXAPr5I3pC+B0UqnG2nXMCuyBrWxshOS5hjjZliExnQzpqmKFGRcVsUMiV7 xl0BDjgAa6uzlp9G1o1DBUxXPvzuHckz2X21xAn754DcYJ+NHKaS1WZQZOd9O/bMFhhh QgvrNBR0+CBHrj8JWE5b43+W0wF59iEYUdtcLCAZ40mGM6cUL+KFYam/52w77EZ5gEbO vL2ZHa8s8tHbLlCBVniUQ/KUoLh7DGLER1Nyllh5BO8RtWY03BS9y2fdcKswhr08XX8/ PDWmKktBKJHhxr9vsndO3TlVZ1SwBxBP1yF2wFpSBC4Uy+G+0uQEvF4B0+r12dg42py2 F8rA== X-Gm-Message-State: AMCzsaUISbSMgVHg4jybj0ZgKTI7YIOsvUzb8Mh08WDb+5SbF2NneuP2 zVAMC5ilFXtappMPC7VdNzOyUYUQxAE= X-Google-Smtp-Source: AOwi7QB0/O0vJEFd7ylXdfBraafx5zhtDTAXBDGB0VJghuvTjGj9wfoCKfFjpr3KIgTw9vVgeyFpFQ== X-Received: by 10.159.211.7 with SMTP id bc7mr9701646plb.425.1508174836489; Mon, 16 Oct 2017 10:27:16 -0700 (PDT) Received: from cloudburst.twiddle.net (97-126-104-76.tukw.qwest.net. [97.126.104.76]) by smtp.gmail.com with ESMTPSA id i187sm5594249pfc.96.2017.10.16.10.27.15 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 16 Oct 2017 10:27:15 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Mon, 16 Oct 2017 10:26:04 -0700 Message-Id: <20171016172609.23422-46-richard.henderson@linaro.org> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171016172609.23422-1-richard.henderson@linaro.org> References: <20171016172609.23422-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c00::236 Subject: [Qemu-devel] [PATCH v6 45/50] tcg: distribute profiling counters across TCGContext's 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: cota@braap.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: "Emilio G. Cota" This is groundwork for supporting multiple TCG contexts. To avoid scalability issues when profiling info is enabled, this patch makes the profiling info counters distributed via the following changes: 1) Consolidate profile info into its own struct, TCGProfile, which TCGContext also includes. Note that tcg_table_op_count is brought into TCGProfile after dropping the tcg_ prefix. 2) Iterate over the TCG contexts in the system to obtain the total counts. This change also requires updating the accessors to TCGProfile fields to use atomic_read/set whenever there may be conflicting accesses (as defined in C11) to them. Reviewed-by: Richard Henderson Signed-off-by: Emilio G. Cota --- tcg/tcg.h | 38 +++++++++------- accel/tcg/translate-all.c | 23 +++++----- tcg/tcg.c | 110 ++++++++++++++++++++++++++++++++++++++-------- 3 files changed, 126 insertions(+), 45 deletions(-) -- 2.13.6 diff --git a/tcg/tcg.h b/tcg/tcg.h index dd11d9f835..50ebe76aca 100644 --- a/tcg/tcg.h +++ b/tcg/tcg.h @@ -641,6 +641,26 @@ QEMU_BUILD_BUG_ON(sizeof(TCGOp) != 8 + sizeof(TCGArg) * MAX_OPC_PARAM); QEMU_BUILD_BUG_ON(NB_OPS > (1 << 8)); QEMU_BUILD_BUG_ON(OPC_BUF_SIZE > (1 << 16)); +typedef struct TCGProfile { + int64_t tb_count1; + int64_t tb_count; + int64_t op_count; /* total insn count */ + int op_count_max; /* max insn per TB */ + int64_t temp_count; + int temp_count_max; + int64_t del_op_count; + int64_t code_in_len; + int64_t code_out_len; + int64_t search_out_len; + int64_t interm_time; + int64_t code_time; + int64_t la_time; + int64_t opt_time; + int64_t restore_count; + int64_t restore_time; + int64_t table_op_count[NB_OPS]; +} TCGProfile; + struct TCGContext { uint8_t *pool_cur, *pool_end; TCGPool *pool_first, *pool_current, *pool_first_large; @@ -665,23 +685,7 @@ struct TCGContext { tcg_insn_unit *code_ptr; #ifdef CONFIG_PROFILER - /* profiling info */ - int64_t tb_count1; - int64_t tb_count; - int64_t op_count; /* total insn count */ - int op_count_max; /* max insn per TB */ - int64_t temp_count; - int temp_count_max; - int64_t del_op_count; - int64_t code_in_len; - int64_t code_out_len; - int64_t search_out_len; - int64_t interm_time; - int64_t code_time; - int64_t la_time; - int64_t opt_time; - int64_t restore_count; - int64_t restore_time; + TCGProfile prof; #endif #ifdef CONFIG_DEBUG_TCG diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c index 826d9869dd..614bb3adcc 100644 --- a/accel/tcg/translate-all.c +++ b/accel/tcg/translate-all.c @@ -312,6 +312,7 @@ static int cpu_restore_state_from_tb(CPUState *cpu, TranslationBlock *tb, uint8_t *p = tb->tc.search; int i, j, num_insns = tb->icount; #ifdef CONFIG_PROFILER + TCGProfile *prof = &tcg_ctx->prof; int64_t ti = profile_getclock(); #endif @@ -346,8 +347,9 @@ static int cpu_restore_state_from_tb(CPUState *cpu, TranslationBlock *tb, restore_state_to_opc(env, tb, data); #ifdef CONFIG_PROFILER - tcg_ctx->restore_time += profile_getclock() - ti; - tcg_ctx->restore_count++; + atomic_set(&prof->restore_time, + prof->restore_time + profile_getclock() - ti); + atomic_set(&prof->restore_count, prof->restore_count + 1); #endif return 0; } @@ -1302,6 +1304,7 @@ TranslationBlock *tb_gen_code(CPUState *cpu, tcg_insn_unit *gen_code_buf; int gen_code_size, search_size; #ifdef CONFIG_PROFILER + TCGProfile *prof = &tcg_ctx->prof; int64_t ti; #endif assert_memory_lock(); @@ -1329,8 +1332,8 @@ TranslationBlock *tb_gen_code(CPUState *cpu, tcg_ctx->tb_cflags = cflags; #ifdef CONFIG_PROFILER - tcg_ctx->tb_count1++; /* includes aborted translations because of - exceptions */ + /* includes aborted translations because of exceptions */ + atomic_set(&prof->tb_count1, prof->tb_count1 + 1); ti = profile_getclock(); #endif @@ -1355,8 +1358,8 @@ TranslationBlock *tb_gen_code(CPUState *cpu, } #ifdef CONFIG_PROFILER - tcg_ctx->tb_count++; - tcg_ctx->interm_time += profile_getclock() - ti; + atomic_set(&prof->tb_count, prof->tb_count + 1); + atomic_set(&prof->interm_time, prof->interm_time + profile_getclock() - ti); ti = profile_getclock(); #endif @@ -1376,10 +1379,10 @@ TranslationBlock *tb_gen_code(CPUState *cpu, tb->tc.size = gen_code_size; #ifdef CONFIG_PROFILER - tcg_ctx->code_time += profile_getclock() - ti; - tcg_ctx->code_in_len += tb->size; - tcg_ctx->code_out_len += gen_code_size; - tcg_ctx->search_out_len += search_size; + atomic_set(&prof->code_time, prof->code_time + profile_getclock() - ti); + atomic_set(&prof->code_in_len, prof->code_in_len + tb->size); + atomic_set(&prof->code_out_len, prof->code_out_len + gen_code_size); + atomic_set(&prof->search_out_len, prof->search_out_len + search_size); #endif #ifdef DEBUG_DISAS diff --git a/tcg/tcg.c b/tcg/tcg.c index 225e7cccea..4b7dc800ec 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -1560,7 +1560,7 @@ void tcg_op_remove(TCGContext *s, TCGOp *op) memset(op, 0, sizeof(*op)); #ifdef CONFIG_PROFILER - s->del_op_count++; + atomic_set(&s->prof.del_op_count, s->prof.del_op_count + 1); #endif } @@ -2731,15 +2731,79 @@ static void tcg_reg_alloc_call(TCGContext *s, TCGOp *op) #ifdef CONFIG_PROFILER -static int64_t tcg_table_op_count[NB_OPS]; +/* avoid copy/paste errors */ +#define PROF_ADD(to, from, field) \ + do { \ + (to)->field += atomic_read(&((from)->field)); \ + } while (0) + +#define PROF_MAX(to, from, field) \ + do { \ + typeof((from)->field) val__ = atomic_read(&((from)->field)); \ + if (val__ > (to)->field) { \ + (to)->field = val__; \ + } \ + } while (0) + +/* Pass in a zero'ed @prof */ +static inline +void tcg_profile_snapshot(TCGProfile *prof, bool counters, bool table) +{ + unsigned int i; + + for (i = 0; i < n_tcg_ctxs; i++) { + const TCGProfile *orig = &tcg_ctxs[i]->prof; + + if (counters) { + PROF_ADD(prof, orig, tb_count1); + PROF_ADD(prof, orig, tb_count); + PROF_ADD(prof, orig, op_count); + PROF_MAX(prof, orig, op_count_max); + PROF_ADD(prof, orig, temp_count); + PROF_MAX(prof, orig, temp_count_max); + PROF_ADD(prof, orig, del_op_count); + PROF_ADD(prof, orig, code_in_len); + PROF_ADD(prof, orig, code_out_len); + PROF_ADD(prof, orig, search_out_len); + PROF_ADD(prof, orig, interm_time); + PROF_ADD(prof, orig, code_time); + PROF_ADD(prof, orig, la_time); + PROF_ADD(prof, orig, opt_time); + PROF_ADD(prof, orig, restore_count); + PROF_ADD(prof, orig, restore_time); + } + if (table) { + int i; + + for (i = 0; i < NB_OPS; i++) { + PROF_ADD(prof, orig, table_op_count[i]); + } + } + } +} + +#undef PROF_ADD +#undef PROF_MAX + +static void tcg_profile_snapshot_counters(TCGProfile *prof) +{ + tcg_profile_snapshot(prof, true, false); +} + +static void tcg_profile_snapshot_table(TCGProfile *prof) +{ + tcg_profile_snapshot(prof, false, true); +} void tcg_dump_op_count(FILE *f, fprintf_function cpu_fprintf) { + TCGProfile prof = {}; int i; + tcg_profile_snapshot_table(&prof); for (i = 0; i < NB_OPS; i++) { cpu_fprintf(f, "%s %" PRId64 "\n", tcg_op_defs[i].name, - tcg_table_op_count[i]); + prof.table_op_count[i]); } } #else @@ -2752,6 +2816,9 @@ void tcg_dump_op_count(FILE *f, fprintf_function cpu_fprintf) int tcg_gen_code(TCGContext *s, TranslationBlock *tb) { +#ifdef CONFIG_PROFILER + TCGProfile *prof = &s->prof; +#endif int i, oi, oi_next, num_insns; #ifdef CONFIG_PROFILER @@ -2759,15 +2826,15 @@ int tcg_gen_code(TCGContext *s, TranslationBlock *tb) int n; n = s->gen_op_buf[0].prev + 1; - s->op_count += n; - if (n > s->op_count_max) { - s->op_count_max = n; + atomic_set(&prof->op_count, prof->op_count + n); + if (n > prof->op_count_max) { + atomic_set(&prof->op_count_max, n); } n = s->nb_temps; - s->temp_count += n; - if (n > s->temp_count_max) { - s->temp_count_max = n; + atomic_set(&prof->temp_count, prof->temp_count + n); + if (n > prof->temp_count_max) { + atomic_set(&prof->temp_count_max, n); } } #endif @@ -2784,7 +2851,7 @@ int tcg_gen_code(TCGContext *s, TranslationBlock *tb) #endif #ifdef CONFIG_PROFILER - s->opt_time -= profile_getclock(); + atomic_set(&prof->opt_time, prof->opt_time - profile_getclock()); #endif #ifdef USE_TCG_OPTIMIZATIONS @@ -2792,8 +2859,8 @@ int tcg_gen_code(TCGContext *s, TranslationBlock *tb) #endif #ifdef CONFIG_PROFILER - s->opt_time += profile_getclock(); - s->la_time -= profile_getclock(); + atomic_set(&prof->opt_time, prof->opt_time + profile_getclock()); + atomic_set(&prof->la_time, prof->la_time - profile_getclock()); #endif liveness_pass_1(s); @@ -2817,7 +2884,7 @@ int tcg_gen_code(TCGContext *s, TranslationBlock *tb) } #ifdef CONFIG_PROFILER - s->la_time += profile_getclock(); + atomic_set(&prof->la_time, prof->la_time + profile_getclock()); #endif #ifdef DEBUG_DISAS @@ -2850,7 +2917,7 @@ int tcg_gen_code(TCGContext *s, TranslationBlock *tb) oi_next = op->next; #ifdef CONFIG_PROFILER - tcg_table_op_count[opc]++; + atomic_set(&prof->table_op_count[opc], prof->table_op_count[opc] + 1); #endif switch (opc) { @@ -2931,10 +2998,17 @@ int tcg_gen_code(TCGContext *s, TranslationBlock *tb) #ifdef CONFIG_PROFILER void tcg_dump_info(FILE *f, fprintf_function cpu_fprintf) { - TCGContext *s = tcg_ctx; - int64_t tb_count = s->tb_count; - int64_t tb_div_count = tb_count ? tb_count : 1; - int64_t tot = s->interm_time + s->code_time; + TCGProfile prof = {}; + const TCGProfile *s; + int64_t tb_count; + int64_t tb_div_count; + int64_t tot; + + tcg_profile_snapshot_counters(&prof); + s = &prof; + tb_count = s->tb_count; + tb_div_count = tb_count ? tb_count : 1; + tot = s->interm_time + s->code_time; cpu_fprintf(f, "JIT cycles %" PRId64 " (%0.3f s at 2.4 GHz)\n", tot, tot / 2.4e9); From patchwork Mon Oct 16 17:26:05 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 115979 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp3972067qgn; Mon, 16 Oct 2017 11:09:14 -0700 (PDT) X-Received: by 10.200.40.202 with SMTP id j10mr14776386qtj.301.1508177354202; Mon, 16 Oct 2017 11:09:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508177354; cv=none; d=google.com; s=arc-20160816; b=gxdgI1QPX3Z+CmVpCdqFo8y9kFOsvwidFOol1AwBrjUhJXXNl/Y86Q3F+lvmzr2mk5 JwaohKbU8CDtp1nB9/iyMx2cOA3VVoz2rJFA8AATQtLHtibw3+1Kmtehd8/VvXYYAPeQ G0KVMjhITcoSl9m6bR2CW1zPD6ZenRIKM18wOHjuBTNAV/npHGs9+eJCHpKoC6Q8VNTy RDs137NbgvF3XSCH9nmZ8Lvz0q9aJxVEbNx1d17aoGYlmSv/4G6FxlYFpGxAerdfvm6b PbnX9qMxSoocaGKraw3V9G+8K746Ep0USEOb1ihSCeu5eQG0+QPYhcTUop13v3rJq9/g p2Xw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=uJ+6idNGx8Q+mUo4Bnbv/J0eV4RGBdO4S7TS3gW8eL4=; b=rEAY2FG+z9lnLoUGbDcHWVP8W+FhCbSVApU9lkXaIfDc9UyM/pZXyfvEBm21/aBkTO vFNXSTKsd0Ur89iGGxg/Y8kR7064hVriohUrmmx6bNMfUPpWleHYlxbuhoH2MxnObZyd EQdMb4JMD90wcbaARn3WitfPUOgpfkg57rJ/96kugXas0RDUc5wV4shGk+rc8+xsOU+b zgtfJ9pQfs9WFDbvLMfvHuhX42lMNSBngKczGQsNlPY4DpkytVLyRmauWhbSHHIrWWpb AJvanev5q09WKQL7MhD2CLf9hu/8F67Qt+2Nju7+pKrrizJ2avrWq+5SYkyR9XV9qEcK iGkQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=YsGef0PX; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id l76si1923976qke.71.2017.10.16.11.09.13 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 16 Oct 2017 11:09:14 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=YsGef0PX; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:34499 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e49p9-0004i3-UQ for patch@linaro.org; Mon, 16 Oct 2017 14:09:12 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52866) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e49Af-0002u3-Am for qemu-devel@nongnu.org; Mon, 16 Oct 2017 13:27:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e49Ad-000462-Ei for qemu-devel@nongnu.org; Mon, 16 Oct 2017 13:27:21 -0400 Received: from mail-pf0-x230.google.com ([2607:f8b0:400e:c00::230]:54268) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e49Ad-00044r-7a for qemu-devel@nongnu.org; Mon, 16 Oct 2017 13:27:19 -0400 Received: by mail-pf0-x230.google.com with SMTP id t188so13795001pfd.10 for ; Mon, 16 Oct 2017 10:27:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=uJ+6idNGx8Q+mUo4Bnbv/J0eV4RGBdO4S7TS3gW8eL4=; b=YsGef0PXwF5kbJzuJnFXeJ8rDAvpeF+bINtn4rt60nLkh05rins48uZXTkNyw2CPjw ymb00DYbpnfRII5mSu3TM1rg8f/T7Lj9sY2NeTbnC05uWNJax56JeCh8iqhLB5qUAp5b xsUfQndVDQ6fbj3b40KiGsEDv1qm/jFT0pZE0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=uJ+6idNGx8Q+mUo4Bnbv/J0eV4RGBdO4S7TS3gW8eL4=; b=GDX9Uk/OWOFJMSmv97jcuIzEZa3ihCgnGBSE5tJ7+AD8uQUcFM4VhgPyvEKYV+IHxZ 8Uq75+sn2H6dLCgy5a67WK5BlUm1yxJ61vBdxbKcIEYD4/UmRNHIMkCcsReRXcl8wGcl T0tnNaq4N5vO+sw+1WpXdNMDWhtMojvqv0y0wb5glLvF46y91CUTiyzrRFWQknHiaL+S JihEyHR+uvdGRW1sqIISMX728TACGsTUMmYKVNMJ1ZdvzRg+CUwXA+NDjx7Etix0kmA6 a3vcGzCl0VPsPKEyJL4m4cKaUKptH5jfTtKjEU6xtyBbw2TAvUf0YhTjqtYuYdvCu+93 CWbw== X-Gm-Message-State: AMCzsaXxoHxrktQqWtRfXQ4D52Eq0S4mI3A/q3QYAlJpHAHMd55zEheG tCT+S1hGdXQ1MAIbd6VTImFDikoRgFY= X-Google-Smtp-Source: AOwi7QCKHXe9hKzC10N6OR6P/REqUgb0k3aTJwXSx47orQzwaaCpxK750zPw/2+ZRRjlLNIIdurZZA== X-Received: by 10.84.173.4 with SMTP id o4mr9483914plb.152.1508174837914; Mon, 16 Oct 2017 10:27:17 -0700 (PDT) Received: from cloudburst.twiddle.net (97-126-104-76.tukw.qwest.net. [97.126.104.76]) by smtp.gmail.com with ESMTPSA id i187sm5594249pfc.96.2017.10.16.10.27.16 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 16 Oct 2017 10:27:16 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Mon, 16 Oct 2017 10:26:05 -0700 Message-Id: <20171016172609.23422-47-richard.henderson@linaro.org> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171016172609.23422-1-richard.henderson@linaro.org> References: <20171016172609.23422-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c00::230 Subject: [Qemu-devel] [PATCH v6 46/50] tcg: allocate optimizer temps with tcg_malloc 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: cota@braap.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: "Emilio G. Cota" Groundwork for supporting multiple TCG contexts. While at it, also allocate temps_used directly as a bitmap of the required size, instead of using a bitmap of TCG_MAX_TEMPS via TCGTempSet. Performance-wise we lose about 1.12% in a translation-heavy workload such as booting+shutting down debian-arm: Performance counter stats for 'taskset -c 0 arm-softmmu/qemu-system-arm \ -machine type=virt -nographic -smp 1 -m 4096 \ -netdev user,id=unet,hostfwd=tcp::2222-:22 \ -device virtio-net-device,netdev=unet \ -drive file=die-on-boot.qcow2,id=myblock,index=0,if=none \ -device virtio-blk-device,drive=myblock \ -kernel kernel.img -append console=ttyAMA0 root=/dev/vda1 \ -name arm,debug-threads=on -smp 1' (10 runs): exec time (s) Relative slowdown wrt original (%) --------------------------------------------------------------- original 20.213321616 0. tcg_malloc 20.441130078 1.1270214 TCGContext 20.477846517 1.3086662 g_malloc 20.780527895 2.8061013 The other two alternatives shown in the table are: - TCGContext: embed temps[TCG_MAX_TEMPS] and TCGTempSet used_temps in TCGContext. This is simple enough but it isn't faster than using tcg_malloc; moreover, it wastes memory. - g_malloc: allocate/deallocate both temps and used_temps every time tcg_optimize is executed. Suggested-by: Richard Henderson Signed-off-by: Emilio G. Cota Signed-off-by: Richard Henderson Signed-off-by: Richard Henderson --- tcg/optimize.c | 42 +++++++++++++++++++----------------------- 1 file changed, 19 insertions(+), 23 deletions(-) -- 2.13.6 diff --git a/tcg/optimize.c b/tcg/optimize.c index ead7bb5e4f..847dfa44c9 100644 --- a/tcg/optimize.c +++ b/tcg/optimize.c @@ -40,9 +40,6 @@ struct tcg_temp_info { tcg_target_ulong mask; }; -static struct tcg_temp_info temps_[TCG_MAX_TEMPS]; -static TCGTempSet temps_used; - static inline struct tcg_temp_info *ts_info(TCGTemp *ts) { return ts->state_ptr; @@ -93,31 +90,27 @@ static void reset_temp(TCGArg arg) reset_ts(arg_temp(arg)); } -/* Reset all temporaries, given that there are NB_TEMPS of them. */ -static void reset_all_temps(int nb_temps) -{ - bitmap_zero(temps_used.l, nb_temps); -} - /* Initialize and activate a temporary. */ -static void init_ts_info(TCGTemp *ts) +static void init_ts_info(struct tcg_temp_info *infos, + TCGTempSet *temps_used, TCGTemp *ts) { size_t idx = temp_idx(ts); - if (!test_bit(idx, temps_used.l)) { - struct tcg_temp_info *ti = &temps_[idx]; + if (!test_bit(idx, temps_used->l)) { + struct tcg_temp_info *ti = &infos[idx]; ts->state_ptr = ti; ti->next_copy = ts; ti->prev_copy = ts; ti->is_const = false; ti->mask = -1; - set_bit(idx, temps_used.l); + set_bit(idx, temps_used->l); } } -static void init_arg_info(TCGArg arg) +static void init_arg_info(struct tcg_temp_info *infos, + TCGTempSet *temps_used, TCGArg arg) { - init_ts_info(arg_temp(arg)); + init_ts_info(infos, temps_used, arg_temp(arg)); } static int op_bits(TCGOpcode op) @@ -616,6 +609,8 @@ void tcg_optimize(TCGContext *s) { int oi, oi_next, nb_temps, nb_globals; TCGOp *prev_mb = NULL; + struct tcg_temp_info *infos; + TCGTempSet temps_used; /* Array VALS has an element for each temp. If this temp holds a constant then its value is kept in VALS' element. @@ -624,7 +619,8 @@ void tcg_optimize(TCGContext *s) nb_temps = s->nb_temps; nb_globals = s->nb_globals; - reset_all_temps(nb_temps); + bitmap_zero(temps_used.l, nb_temps); + infos = tcg_malloc(sizeof(struct tcg_temp_info) * nb_temps); for (oi = s->gen_op_buf[0].next; oi != 0; oi = oi_next) { tcg_target_ulong mask, partmask, affected; @@ -645,14 +641,14 @@ void tcg_optimize(TCGContext *s) for (i = 0; i < nb_oargs + nb_iargs; i++) { TCGTemp *ts = arg_temp(op->args[i]); if (ts) { - init_ts_info(ts); + init_ts_info(infos, &temps_used, ts); } } } else { nb_oargs = def->nb_oargs; nb_iargs = def->nb_iargs; for (i = 0; i < nb_oargs + nb_iargs; i++) { - init_arg_info(op->args[i]); + init_arg_info(infos, &temps_used, op->args[i]); } } @@ -1213,7 +1209,7 @@ void tcg_optimize(TCGContext *s) op->args[1], op->args[2]); if (tmp != 2) { if (tmp) { - reset_all_temps(nb_temps); + bitmap_zero(temps_used.l, nb_temps); op->opc = INDEX_op_br; op->args[0] = op->args[3]; } else { @@ -1302,7 +1298,7 @@ void tcg_optimize(TCGContext *s) if (tmp != 2) { if (tmp) { do_brcond_true: - reset_all_temps(nb_temps); + bitmap_zero(temps_used.l, nb_temps); op->opc = INDEX_op_br; op->args[0] = op->args[5]; } else { @@ -1318,7 +1314,7 @@ void tcg_optimize(TCGContext *s) /* Simplify LT/GE comparisons vs zero to a single compare vs the high word of the input. */ do_brcond_high: - reset_all_temps(nb_temps); + bitmap_zero(temps_used.l, nb_temps); op->opc = INDEX_op_brcond_i32; op->args[0] = op->args[1]; op->args[1] = op->args[3]; @@ -1344,7 +1340,7 @@ void tcg_optimize(TCGContext *s) goto do_default; } do_brcond_low: - reset_all_temps(nb_temps); + bitmap_zero(temps_used.l, nb_temps); op->opc = INDEX_op_brcond_i32; op->args[1] = op->args[2]; op->args[2] = op->args[4]; @@ -1464,7 +1460,7 @@ void tcg_optimize(TCGContext *s) block, otherwise we only trash the output args. "mask" is the non-zero bits mask for the first output arg. */ if (def->flags & TCG_OPF_BB_END) { - reset_all_temps(nb_temps); + bitmap_zero(temps_used.l, nb_temps); } else { do_reset_output: for (i = 0; i < nb_oargs; i++) { From patchwork Mon Oct 16 17:26:06 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 115978 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp3970010qgn; Mon, 16 Oct 2017 11:07:15 -0700 (PDT) X-Received: by 10.200.43.167 with SMTP id m36mr14433112qtm.174.1508177235345; Mon, 16 Oct 2017 11:07:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508177235; cv=none; d=google.com; s=arc-20160816; b=1Gsk6x+tFLDCzbvsJxwrvNYqdT2TgZQrMjXviwiU3etkgI/96Hhccbz2ZQ5t+SzGW3 r1U+9d2NPn6pZsBMBb2FokkLpaLoo84ea3GxhovmgeQ8tZJgAw0fSvwtyk4vC40QERof 1wqW9QfNmlOsTe8cStGQasJwu876YJtyy1WJLdEzEbG7qeHT885D9rcVsxFd+u8CkPsl hjnKI/URjGugaaZMhFXXau5HU9djREu5TpWZU/x3FmztPR0eG5WACYfFIwxXMKmaI+OF eegcT8UlN919tyCM/g8sl9A737I5NMXWRrhqh275DR9l1Fg0LcS6CnpsXdNCFT+KqQCz d14g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=i1HvMWTORlTi4mrRA3t7lTf3wipFQA4Aj9Z7zWl118Y=; b=AGMduOedmdU4TiqhzxySxf8CsyCbomxXRtk9qky/NT3hHv/jAAdq3qEzObp7MYqZCc NEv0JNIJq6dfaa9blsOupNgrmfQtNryPquAoB/oZvAAPpSQsNunWqL2hlnmEEHGX1nfd byLKbaBhDP5yxOkb6LieeVh/3eP3euQVIqVy5+b7sAw1tw88RIYqy4Cqf8jxZCp2++ei x5NFuaJi32NcAd1Ekxx84787yZ4toxuQYL9rzzB/Tp/fe3rCOLa70X+Af/Wyw4FEatYy u0aXuxNOSqJtFg3ha+3yajFceZ9Est2lXhkPkjgNjBEM4rUNdhNzOqTVA/l7Jbvhckmw ZP4w== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Jdj99N04; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id 31si6862072qth.225.2017.10.16.11.07.15 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 16 Oct 2017 11:07:15 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Jdj99N04; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:34486 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e49nF-0003Gr-6b for patch@linaro.org; Mon, 16 Oct 2017 14:07:13 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52872) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e49Af-0002uF-Gy for qemu-devel@nongnu.org; Mon, 16 Oct 2017 13:27:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e49Ae-00047I-JR for qemu-devel@nongnu.org; Mon, 16 Oct 2017 13:27:21 -0400 Received: from mail-pf0-x22e.google.com ([2607:f8b0:400e:c00::22e]:44289) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e49Ae-00046N-Ef for qemu-devel@nongnu.org; Mon, 16 Oct 2017 13:27:20 -0400 Received: by mail-pf0-x22e.google.com with SMTP id x7so16318496pfa.1 for ; Mon, 16 Oct 2017 10:27:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=i1HvMWTORlTi4mrRA3t7lTf3wipFQA4Aj9Z7zWl118Y=; b=Jdj99N04fRMSvtuW4Vyehc94g3n4LBmX+psq1ZUfjoxZTQOfax1ajadM1fIBN0Y/SG aAUATCIuknda/a0dnxESAemTtyQBa6PQhq+vWlJN4SsQC1s0vXJmUxx4JH519fV3zN63 e3BGASh+FF7X249EbHmVZjA9dvg6D1E4peJ/c= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=i1HvMWTORlTi4mrRA3t7lTf3wipFQA4Aj9Z7zWl118Y=; b=YVqEk5buDOhKLylay36Xw5oCF+bqlbcclkeYbATWCXFR09VsjC21tPDX4TeO1/7kVI YgjZ99KYgUVIHTgY4gd3Uq1Wwt4XGQyuPZgEZ1kkOyiifFoK5tluC6FVdTZ+PnDdv436 nLCbPN3bVB8nklq5LrMTZcO5z4kJu+J/HiTzNdrY2JJfFGZuqsOziu75ZsCHJCcSGwp1 jMpYxRGGGQDxV+Ixy+vkL6tBddXwGUQiIm9Z8TamFLC1g7asxzQtUOpYrYPe25XskTvl Ae6+KCjJI08WBhC8ACiYE1MVDx9z8HlF/uC3dP/4Tbn08Xkjx4mgpMssaNIcADsg3ox6 NJwA== X-Gm-Message-State: AMCzsaWytVGXHS//NvimPjXk5sb/je/suVImW2C3saD2v9Zc8we17SxF rpHWCDVMvsiKkMNk6duzYtsuMlrWgoM= X-Google-Smtp-Source: AOwi7QDUqToJw+HNxSswfH/yYIA0Z7InXLaiyCZK6WPb2pSY5taSBbboiiBk7Gvi15TKSfdf7bcMjQ== X-Received: by 10.84.244.198 with SMTP id f6mr9808305plt.32.1508174839233; Mon, 16 Oct 2017 10:27:19 -0700 (PDT) Received: from cloudburst.twiddle.net (97-126-104-76.tukw.qwest.net. [97.126.104.76]) by smtp.gmail.com with ESMTPSA id i187sm5594249pfc.96.2017.10.16.10.27.17 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 16 Oct 2017 10:27:18 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Mon, 16 Oct 2017 10:26:06 -0700 Message-Id: <20171016172609.23422-48-richard.henderson@linaro.org> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171016172609.23422-1-richard.henderson@linaro.org> References: <20171016172609.23422-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c00::22e Subject: [Qemu-devel] [PATCH v6 47/50] osdep: introduce qemu_mprotect_rwx/none 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: cota@braap.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: "Emilio G. Cota" Reviewed-by: Richard Henderson Signed-off-by: Emilio G. Cota Signed-off-by: Richard Henderson --- include/qemu/osdep.h | 2 ++ util/osdep.c | 41 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+) -- 2.13.6 diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h index 826650c58a..281782d526 100644 --- a/include/qemu/osdep.h +++ b/include/qemu/osdep.h @@ -371,6 +371,8 @@ void sigaction_invoke(struct sigaction *action, #endif int qemu_madvise(void *addr, size_t len, int advice); +int qemu_mprotect_rwx(void *addr, size_t size); +int qemu_mprotect_none(void *addr, size_t size); int qemu_open(const char *name, int flags, ...); int qemu_close(int fd); diff --git a/util/osdep.c b/util/osdep.c index a479fedc4a..1231f9f876 100644 --- a/util/osdep.c +++ b/util/osdep.c @@ -73,6 +73,47 @@ int qemu_madvise(void *addr, size_t len, int advice) #endif } +static int qemu_mprotect__osdep(void *addr, size_t size, int prot) +{ + g_assert(!((uintptr_t)addr & ~qemu_real_host_page_mask)); + g_assert(!(size & ~qemu_real_host_page_mask)); + +#ifdef _WIN32 + DWORD old_protect; + + if (!VirtualProtect(addr, size, prot, &old_protect)) { + error_report("%s: VirtualProtect failed with error code %ld", + __func__, GetLastError()); + return -1; + } + return 0; +#else + if (mprotect(addr, size, prot)) { + error_report("%s: mprotect failed: %s", __func__, strerror(errno)); + return -1; + } + return 0; +#endif +} + +int qemu_mprotect_rwx(void *addr, size_t size) +{ +#ifdef _WIN32 + return qemu_mprotect__osdep(addr, size, PAGE_EXECUTE_READWRITE); +#else + return qemu_mprotect__osdep(addr, size, PROT_READ | PROT_WRITE | PROT_EXEC); +#endif +} + +int qemu_mprotect_none(void *addr, size_t size) +{ +#ifdef _WIN32 + return qemu_mprotect__osdep(addr, size, PAGE_NOACCESS); +#else + return qemu_mprotect__osdep(addr, size, PROT_NONE); +#endif +} + #ifndef _WIN32 static int fcntl_op_setlk = -1; From patchwork Mon Oct 16 17:26:07 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 115965 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp3957882qgn; Mon, 16 Oct 2017 10:54:50 -0700 (PDT) X-Received: by 10.200.23.82 with SMTP id u18mr15177991qtk.163.1508176490595; Mon, 16 Oct 2017 10:54:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508176490; cv=none; d=google.com; s=arc-20160816; b=gZ4WZQfm53ghX7tWjiMG8shGua1Yd/vphvqD1L4pTplhsvX3VI1JuAPLn30OnDwh/+ KHpLuOO6ZBQR5bqfQ5OsUWVrf1FTceLc+dRuCSKMLe2AJ6dt0vWV0Lunkr6SlwAHqLsC 7WycjIUaCupgXlqlki6RLycQdZaLCu+5dQ2+l4CZzIj2oJChWhN2UDVgD3qYbg7Bi47j NvyITKsx54BcHUkFwnAAxgoNiqqpPRzqM6Qk5icZ/Ccr3X0K5O1PfVKPTkZZStRdt+9M fok8Rn4V8JJhRI+kjKqwZzCW7RIiEWGygYUdL9vvbvFA5H41d3h4WDP0GOt53UysADXn KiIQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=6e72cvxx7Qfm+Rx17cGpbHvv52iihArS/ChNd5KPwAk=; b=MnuEw+sT7EmloY1FQN/h8Xnd+qIJsDu2R1Wz5LgPcbEsM53fBKmcJpNuOdvbZH7GTx sg8wp54ro7f/wLvmdr6lmDdYizy8FwEUVMUxpnCixYD5eqrqaK0LQVR+CGvXj+yvkTIl NDK95eMRN0FwPE28jcBp11V4+K4he8Vf9MOqkIvhumwD+TlrAfW4o4VdeN4rint8ShuU Kwje3D75FNtulcTZNNuXuL5XkcERcBXeWQlOCpsD+cd51rHZWxOXYShHLgb/a2HvoIgy gyOjcN0eNAqcYeMuZCaZDMSkL9lb/KrSyNw4z5WvhhWbwddf3oRYyhhlqO27IlaI1ZHH c/Nw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=klz3PaqF; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id v12si6994686qta.252.2017.10.16.10.54.50 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 16 Oct 2017 10:54:50 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=klz3PaqF; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:34409 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e49bE-0000PC-Jj for patch@linaro.org; Mon, 16 Oct 2017 13:54:48 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52906) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e49Ah-0002vy-Aw for qemu-devel@nongnu.org; Mon, 16 Oct 2017 13:27:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e49Ag-0004Aj-57 for qemu-devel@nongnu.org; Mon, 16 Oct 2017 13:27:23 -0400 Received: from mail-pg0-x22a.google.com ([2607:f8b0:400e:c05::22a]:55273) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e49Af-0004AD-Vo for qemu-devel@nongnu.org; Mon, 16 Oct 2017 13:27:22 -0400 Received: by mail-pg0-x22a.google.com with SMTP id l24so7294698pgu.11 for ; Mon, 16 Oct 2017 10:27:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=6e72cvxx7Qfm+Rx17cGpbHvv52iihArS/ChNd5KPwAk=; b=klz3PaqFwrVNefFXr6rr41s0veG5Oa68bskf/3lWZXSQ6LG00OIJ3LkkLMyDlRGP/d vG3GtHhBCfDCZfr23Y/xXZ4eW5cDVjIGVCqVK35lKvBI+Apsf0y0P0qTPodY4gkuwY2+ sFFoB3RvofLm81OKRV3mRdFt/pWwbDiyte2kA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=6e72cvxx7Qfm+Rx17cGpbHvv52iihArS/ChNd5KPwAk=; b=uNbkaUTWyD7PO2YBgKjd/EdAArlD40b/sHHC5uSzWqr0lotPpiJoOzDXZ3SE10YhHX bVbcTvbXoFRsh3ccgagOzH9dv67hvY1BWoaH9Oi9sBjbZ8sbizj+dgQp3CrK0D033r9b KtahFn6YOt/k5M1lVsyxo+P+X2/5zW9c0kltVLg4wlPZ0uDLiljlqoc6tNx0k5Xfp31A vudzW6JXTuNVffjd0SAAVkB9ni+YXccx4v7E2uyD6ozEOpaNQNnE6YPzzHiGpqB4zTVb fw9Uvrp/l+KzX4ySqFoQgnrtBu2UE9rNzGsurusXr3k3d+Zbsm86I8HWpx+ETq5Wr6YR 3rlw== X-Gm-Message-State: AMCzsaW5O1aNaVpF1dz/MhfznN/Wq56O5zISajz51YyIqOsjMf/8nY2J +U7ydeGdutES8r2VTfMRTQRf4X7kVLQ= X-Google-Smtp-Source: AOwi7QCqfBd80YJvWpmOAP37J8Dkcb83lW11fqfsDkK4J1MvTmNJrFyfm61cvqp5ep3HOnKP5CRG7g== X-Received: by 10.84.234.199 with SMTP id i7mr9485990plt.66.1508174840825; Mon, 16 Oct 2017 10:27:20 -0700 (PDT) Received: from cloudburst.twiddle.net (97-126-104-76.tukw.qwest.net. [97.126.104.76]) by smtp.gmail.com with ESMTPSA id i187sm5594249pfc.96.2017.10.16.10.27.19 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 16 Oct 2017 10:27:19 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Mon, 16 Oct 2017 10:26:07 -0700 Message-Id: <20171016172609.23422-49-richard.henderson@linaro.org> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171016172609.23422-1-richard.henderson@linaro.org> References: <20171016172609.23422-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c05::22a Subject: [Qemu-devel] [PATCH v6 48/50] translate-all: use qemu_protect_rwx/none helpers 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: cota@braap.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: "Emilio G. Cota" The helpers require the address and size to be page-aligned, so do that before calling them. Reviewed-by: Richard Henderson Signed-off-by: Emilio G. Cota Signed-off-by: Richard Henderson --- accel/tcg/translate-all.c | 61 ++++++++++------------------------------------- 1 file changed, 13 insertions(+), 48 deletions(-) -- 2.13.6 diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c index 614bb3adcc..cc25b7555b 100644 --- a/accel/tcg/translate-all.c +++ b/accel/tcg/translate-all.c @@ -604,63 +604,24 @@ static inline void *split_cross_256mb(void *buf1, size_t size1) static uint8_t static_code_gen_buffer[DEFAULT_CODE_GEN_BUFFER_SIZE] __attribute__((aligned(CODE_GEN_ALIGN))); -# ifdef _WIN32 -static inline void do_protect(void *addr, long size, int prot) -{ - DWORD old_protect; - VirtualProtect(addr, size, prot, &old_protect); -} - -static inline void map_exec(void *addr, long size) -{ - do_protect(addr, size, PAGE_EXECUTE_READWRITE); -} - -static inline void map_none(void *addr, long size) -{ - do_protect(addr, size, PAGE_NOACCESS); -} -# else -static inline void do_protect(void *addr, long size, int prot) -{ - uintptr_t start, end; - - start = (uintptr_t)addr; - start &= qemu_real_host_page_mask; - - end = (uintptr_t)addr + size; - end = ROUND_UP(end, qemu_real_host_page_size); - - mprotect((void *)start, end - start, prot); -} - -static inline void map_exec(void *addr, long size) -{ - do_protect(addr, size, PROT_READ | PROT_WRITE | PROT_EXEC); -} - -static inline void map_none(void *addr, long size) -{ - do_protect(addr, size, PROT_NONE); -} -# endif /* WIN32 */ - static inline void *alloc_code_gen_buffer(void) { void *buf = static_code_gen_buffer; + void *end = static_code_gen_buffer + sizeof(static_code_gen_buffer); size_t full_size, size; - /* The size of the buffer, rounded down to end on a page boundary. */ - full_size = (((uintptr_t)buf + sizeof(static_code_gen_buffer)) - & qemu_real_host_page_mask) - (uintptr_t)buf; + /* page-align the beginning and end of the buffer */ + buf = QEMU_ALIGN_PTR_UP(buf, qemu_real_host_page_size); + end = QEMU_ALIGN_PTR_DOWN(end, qemu_real_host_page_size); /* Reserve a guard page. */ + full_size = end - buf; size = full_size - qemu_real_host_page_size; /* Honor a command-line option limiting the size of the buffer. */ if (size > tcg_ctx->code_gen_buffer_size) { - size = (((uintptr_t)buf + tcg_ctx->code_gen_buffer_size) - & qemu_real_host_page_mask) - (uintptr_t)buf; + size = QEMU_ALIGN_DOWN(tcg_ctx->code_gen_buffer_size, + qemu_real_host_page_size); } tcg_ctx->code_gen_buffer_size = size; @@ -671,8 +632,12 @@ static inline void *alloc_code_gen_buffer(void) } #endif - map_exec(buf, size); - map_none(buf + size, qemu_real_host_page_size); + if (qemu_mprotect_rwx(buf, size)) { + abort(); + } + if (qemu_mprotect_none(buf + size, qemu_real_host_page_size)) { + abort(); + } qemu_madvise(buf, size, QEMU_MADV_HUGEPAGE); return buf; From patchwork Mon Oct 16 17:26:08 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 115962 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp3955413qgn; Mon, 16 Oct 2017 10:51:51 -0700 (PDT) X-Received: by 10.55.19.228 with SMTP id 97mr13956492qkt.271.1508176311264; Mon, 16 Oct 2017 10:51:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508176311; cv=none; d=google.com; s=arc-20160816; b=DUKwn/BW/s7wRhgvJP+N6iLIh8gpN8i4gxFuQzPwYAHYens8haERpgv2bxv4nr/WOV QWZHl1Ie4X/J+ATE1zP42fpV+wc3NX2Re0eyjMtaydCEov8WgES/34dli/wXyxAdpXVr 9V+WpupCUwYNx2399Vhx5YIYV8zAg2RYF3fwSwQG8u18Px3jJBytxnVWr74S3GGPHzj5 R4XiSnNZhaD46p7GSUGLxX0QZFMJLoEbzkbD9Pfze8OaRhFljv3m228Y/UlWN2sSAcM3 Axj3FjcQquwv4CwLfvtRXGzOI7YIKiYfjrOdFGNc61rajkMERF5BxWTX6erCVssXPURv 6/Pg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=FM4PMS/eOK5C7DcNIT9ct7Q+1MWfmBwl2qH0Cel/siI=; b=liIqanViRo//OcXL1eQQLneH0E3djauc5KK3+MYkq7/sDIhX5u/eqaicG+F2RQbYYX qf47hF8LOkYaWyHh5aDifJ3Zbl+DwP+wbvrS4xgaaY9J4TrMj/LfWIGdNxg/nYLM8R93 uIAlt62bF2bPGQaf/hBcaZqoGrkCnhG/i7gOLtOjcbfosgNyXiQ7jiBz8rQpsC++Vnlc /mzA9YAso17CtLmsGE7QgZupMMr4j5sQvtyJoK8yxLDlf1U+p7Z3ZAWReNUo3zKeHkVl PjOf/OvATkCvtCFikh0nMUIZKa3f1BN0PcSADdjBtx6CkiEu6yb7x4QAilwP5IJ+5K1W Tjlw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=GAwIqH7U; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id a42si1480865qtb.299.2017.10.16.10.51.50 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 16 Oct 2017 10:51:51 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=GAwIqH7U; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:34400 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e49YK-0006U4-Sg for patch@linaro.org; Mon, 16 Oct 2017 13:51:48 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52944) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e49Ak-00035X-Jj for qemu-devel@nongnu.org; Mon, 16 Oct 2017 13:27:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e49Ai-0004CJ-1m for qemu-devel@nongnu.org; Mon, 16 Oct 2017 13:27:26 -0400 Received: from mail-pg0-x231.google.com ([2607:f8b0:400e:c05::231]:51123) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e49Ah-0004BZ-OB for qemu-devel@nongnu.org; Mon, 16 Oct 2017 13:27:23 -0400 Received: by mail-pg0-x231.google.com with SMTP id y7so7344023pgb.7 for ; Mon, 16 Oct 2017 10:27:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=FM4PMS/eOK5C7DcNIT9ct7Q+1MWfmBwl2qH0Cel/siI=; b=GAwIqH7UI39Iij7sm7yWX1NKd1b5VIjWyevsCebINZzMAbmjZrSku2IYbRf+oywUf1 5PIqJKJwY8L33cvJ+NLBsAq+iaGsRVaaf7La13hEvR5KvVYxHiQZTHXfvX181IhRKQRD VJc3kdHOfxtrentyJz0kONrWUpYcpt1JLeMLw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=FM4PMS/eOK5C7DcNIT9ct7Q+1MWfmBwl2qH0Cel/siI=; b=L0OAP45a2zO1IJA2kp8onsV2ZHi0rCdwmwWvriNUWACx+RfYkeWTc1J1w2xggsJ2+C tVRK5WdavlAkMb+qkbjzmZ/QLnoSMiBF0K2ZEuHPSlKIZRgMkzGdKGlDSkZnouxTRRKD b7p6kZMCNooVB5hOcaTuUP9HxQmyYzhxumiesOPQr7hGYzoGQ1yIEm+Gsuk5/qW8SAu+ pXmjEy97Ha7nc9rtIJCLGDDdPgt2MIVG2TqmIOHw+txNZ8mwKg+0GtPLs2OTRlhmrRXj rT5GMGSJMhyOrxZei5kxK5xuefsOAW8+XH75wW4mxFwRei4NtZpDf21yPAeiQjGdQHo4 jDjQ== X-Gm-Message-State: AMCzsaW4DCOYNdSmU/GEEXfnJvdyl8IxQN7z6s/AAxQ6GT8qefYiHPYy 2onJX+IiNs3gLi1UXRc3fwLj2CgsMaY= X-Google-Smtp-Source: AOwi7QBY5cIeIPlEl4zCS0TDeCipvSxP6N3RVmCpP3sXoO2X/uOxpWQxeEqPF/tG0wKzgL8dSOi7Eg== X-Received: by 10.159.198.131 with SMTP id g3mr9715363plo.337.1508174842110; Mon, 16 Oct 2017 10:27:22 -0700 (PDT) Received: from cloudburst.twiddle.net (97-126-104-76.tukw.qwest.net. [97.126.104.76]) by smtp.gmail.com with ESMTPSA id i187sm5594249pfc.96.2017.10.16.10.27.20 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 16 Oct 2017 10:27:21 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Mon, 16 Oct 2017 10:26:08 -0700 Message-Id: <20171016172609.23422-50-richard.henderson@linaro.org> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171016172609.23422-1-richard.henderson@linaro.org> References: <20171016172609.23422-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c05::231 Subject: [Qemu-devel] [PATCH v6 49/50] tcg: introduce regions to split code_gen_buffer 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: cota@braap.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: "Emilio G. Cota" This is groundwork for supporting multiple TCG contexts. The naive solution here is to split code_gen_buffer statically among the TCG threads; this however results in poor utilization if translation needs are different across TCG threads. What we do here is to add an extra layer of indirection, assigning regions that act just like pages do in virtual memory allocation. (BTW if you are wondering about the chosen naming, I did not want to use blocks or pages because those are already heavily used in QEMU). We use a global lock to serialize allocations as well as statistics reporting (we now export the size of the used code_gen_buffer with tcg_code_size()). Note that for the allocator we could just use a counter and atomic_inc; however, that would complicate the gathering of tcg_code_size()-like stats. So given that the region operations are not a fast path, a lock seems the most reasonable choice. The effectiveness of this approach is clear after seeing some numbers. I used the bootup+shutdown of debian-arm with '-tb-size 80' as a benchmark. Note that I'm evaluating this after enabling per-thread TCG (which is done by a subsequent commit). * -smp 1, 1 region (entire buffer): qemu: flush code_size=83885014 nb_tbs=154739 avg_tb_size=357 qemu: flush code_size=83884902 nb_tbs=153136 avg_tb_size=363 qemu: flush code_size=83885014 nb_tbs=152777 avg_tb_size=364 qemu: flush code_size=83884950 nb_tbs=150057 avg_tb_size=373 qemu: flush code_size=83884998 nb_tbs=150234 avg_tb_size=373 qemu: flush code_size=83885014 nb_tbs=154009 avg_tb_size=360 qemu: flush code_size=83885014 nb_tbs=151007 avg_tb_size=370 qemu: flush code_size=83885014 nb_tbs=151816 avg_tb_size=367 That is, 8 flushes. * -smp 8, 32 regions (80/32 MB per region) [i.e. this patch]: qemu: flush code_size=76328008 nb_tbs=141040 avg_tb_size=356 qemu: flush code_size=75366534 nb_tbs=138000 avg_tb_size=361 qemu: flush code_size=76864546 nb_tbs=140653 avg_tb_size=361 qemu: flush code_size=76309084 nb_tbs=135945 avg_tb_size=375 qemu: flush code_size=74581856 nb_tbs=132909 avg_tb_size=375 qemu: flush code_size=73927256 nb_tbs=135616 avg_tb_size=360 qemu: flush code_size=78629426 nb_tbs=142896 avg_tb_size=365 qemu: flush code_size=76667052 nb_tbs=138508 avg_tb_size=368 Again, 8 flushes. Note how buffer utilization is not 100%, but it is close. Smaller region sizes would yield higher utilization, but we want region allocation to be rare (it acquires a lock), so we do not want to go too small. * -smp 8, static partitioning of 8 regions (10 MB per region): qemu: flush code_size=21936504 nb_tbs=40570 avg_tb_size=354 qemu: flush code_size=11472174 nb_tbs=20633 avg_tb_size=370 qemu: flush code_size=11603976 nb_tbs=21059 avg_tb_size=365 qemu: flush code_size=23254872 nb_tbs=41243 avg_tb_size=377 qemu: flush code_size=28289496 nb_tbs=52057 avg_tb_size=358 qemu: flush code_size=43605160 nb_tbs=78896 avg_tb_size=367 qemu: flush code_size=45166552 nb_tbs=82158 avg_tb_size=364 qemu: flush code_size=63289640 nb_tbs=116494 avg_tb_size=358 qemu: flush code_size=51389960 nb_tbs=93937 avg_tb_size=362 qemu: flush code_size=59665928 nb_tbs=107063 avg_tb_size=372 qemu: flush code_size=38380824 nb_tbs=68597 avg_tb_size=374 qemu: flush code_size=44884568 nb_tbs=79901 avg_tb_size=376 qemu: flush code_size=50782632 nb_tbs=90681 avg_tb_size=374 qemu: flush code_size=39848888 nb_tbs=71433 avg_tb_size=372 qemu: flush code_size=64708840 nb_tbs=119052 avg_tb_size=359 qemu: flush code_size=49830008 nb_tbs=90992 avg_tb_size=362 qemu: flush code_size=68372408 nb_tbs=123442 avg_tb_size=368 qemu: flush code_size=33555560 nb_tbs=59514 avg_tb_size=378 qemu: flush code_size=44748344 nb_tbs=80974 avg_tb_size=367 qemu: flush code_size=37104248 nb_tbs=67609 avg_tb_size=364 That is, 20 flushes. Note how a static partitioning approach uses the code buffer poorly, leading to many unnecessary flushes. Signed-off-by: Emilio G. Cota --- tcg/tcg.h | 6 ++ accel/tcg/translate-all.c | 63 +++++-------- bsd-user/main.c | 1 + cpus.c | 12 +++ linux-user/main.c | 1 + tcg/tcg.c | 222 +++++++++++++++++++++++++++++++++++++++++++++- 6 files changed, 260 insertions(+), 45 deletions(-) -- 2.13.6 diff --git a/tcg/tcg.h b/tcg/tcg.h index 50ebe76aca..d3d16a2cce 100644 --- a/tcg/tcg.h +++ b/tcg/tcg.h @@ -810,6 +810,12 @@ void *tcg_malloc_internal(TCGContext *s, int size); void tcg_pool_reset(TCGContext *s); TranslationBlock *tcg_tb_alloc(TCGContext *s); +void tcg_region_init(void); +void tcg_region_reset_all(void); + +size_t tcg_code_size(void); +size_t tcg_code_capacity(void); + /* Called with tb_lock held. */ static inline void *tcg_malloc(int size) { diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c index cc25b7555b..66b1733911 100644 --- a/accel/tcg/translate-all.c +++ b/accel/tcg/translate-all.c @@ -608,15 +608,13 @@ static inline void *alloc_code_gen_buffer(void) { void *buf = static_code_gen_buffer; void *end = static_code_gen_buffer + sizeof(static_code_gen_buffer); - size_t full_size, size; + size_t size; /* page-align the beginning and end of the buffer */ buf = QEMU_ALIGN_PTR_UP(buf, qemu_real_host_page_size); end = QEMU_ALIGN_PTR_DOWN(end, qemu_real_host_page_size); - /* Reserve a guard page. */ - full_size = end - buf; - size = full_size - qemu_real_host_page_size; + size = end - buf; /* Honor a command-line option limiting the size of the buffer. */ if (size > tcg_ctx->code_gen_buffer_size) { @@ -635,9 +633,6 @@ static inline void *alloc_code_gen_buffer(void) if (qemu_mprotect_rwx(buf, size)) { abort(); } - if (qemu_mprotect_none(buf + size, qemu_real_host_page_size)) { - abort(); - } qemu_madvise(buf, size, QEMU_MADV_HUGEPAGE); return buf; @@ -646,22 +641,16 @@ static inline void *alloc_code_gen_buffer(void) static inline void *alloc_code_gen_buffer(void) { size_t size = tcg_ctx->code_gen_buffer_size; - void *buf1, *buf2; - - /* Perform the allocation in two steps, so that the guard page - is reserved but uncommitted. */ - buf1 = VirtualAlloc(NULL, size + qemu_real_host_page_size, - MEM_RESERVE, PAGE_NOACCESS); - if (buf1 != NULL) { - buf2 = VirtualAlloc(buf1, size, MEM_COMMIT, PAGE_EXECUTE_READWRITE); - assert(buf1 == buf2); - } + void *buf; - return buf1; + buf = VirtualAlloc(NULL, size, MEM_RESERVE | MEM_COMMIT, + PAGE_EXECUTE_READWRITE); + return buf; } #else static inline void *alloc_code_gen_buffer(void) { + int prot = PROT_WRITE | PROT_READ | PROT_EXEC; int flags = MAP_PRIVATE | MAP_ANONYMOUS; uintptr_t start = 0; size_t size = tcg_ctx->code_gen_buffer_size; @@ -695,8 +684,7 @@ static inline void *alloc_code_gen_buffer(void) # endif # endif - buf = mmap((void *)start, size + qemu_real_host_page_size, - PROT_NONE, flags, -1, 0); + buf = mmap((void *)start, size, prot, flags, -1, 0); if (buf == MAP_FAILED) { return NULL; } @@ -706,24 +694,23 @@ static inline void *alloc_code_gen_buffer(void) /* Try again, with the original still mapped, to avoid re-acquiring that 256mb crossing. This time don't specify an address. */ size_t size2; - void *buf2 = mmap(NULL, size + qemu_real_host_page_size, - PROT_NONE, flags, -1, 0); + void *buf2 = mmap(NULL, size, prot, flags, -1, 0); switch ((int)(buf2 != MAP_FAILED)) { case 1: if (!cross_256mb(buf2, size)) { /* Success! Use the new buffer. */ - munmap(buf, size + qemu_real_host_page_size); + munmap(buf, size); break; } /* Failure. Work with what we had. */ - munmap(buf2, size + qemu_real_host_page_size); + munmap(buf2, size); /* fallthru */ default: /* Split the original buffer. Free the smaller half. */ buf2 = split_cross_256mb(buf, size); size2 = tcg_ctx->code_gen_buffer_size; if (buf == buf2) { - munmap(buf + size2 + qemu_real_host_page_size, size - size2); + munmap(buf + size2, size - size2); } else { munmap(buf, size - size2); } @@ -734,10 +721,6 @@ static inline void *alloc_code_gen_buffer(void) } #endif - /* Make the final buffer accessible. The guard page at the end - will remain inaccessible with PROT_NONE. */ - mprotect(buf, size, PROT_WRITE | PROT_READ | PROT_EXEC); - /* Request large pages for the buffer. */ qemu_madvise(buf, size, QEMU_MADV_HUGEPAGE); @@ -918,13 +901,8 @@ static void do_tb_flush(CPUState *cpu, run_on_cpu_data tb_flush_count) size_t host_size = 0; g_tree_foreach(tb_ctx.tb_tree, tb_host_size_iter, &host_size); - printf("qemu: flush code_size=%td nb_tbs=%zu avg_tb_size=%zu\n", - tcg_ctx->code_gen_ptr - tcg_ctx->code_gen_buffer, nb_tbs, - nb_tbs > 0 ? host_size / nb_tbs : 0); - } - if ((unsigned long)(tcg_ctx->code_gen_ptr - tcg_ctx->code_gen_buffer) - > tcg_ctx->code_gen_buffer_size) { - cpu_abort(cpu, "Internal error: code buffer overflow\n"); + printf("qemu: flush code_size=%zu nb_tbs=%zu avg_tb_size=%zu\n", + tcg_code_size(), nb_tbs, nb_tbs > 0 ? host_size / nb_tbs : 0); } CPU_FOREACH(cpu) { @@ -938,7 +916,7 @@ static void do_tb_flush(CPUState *cpu, run_on_cpu_data tb_flush_count) qht_reset_size(&tb_ctx.htable, CODE_GEN_HTABLE_SIZE); page_flush_tb(); - tcg_ctx->code_gen_ptr = tcg_ctx->code_gen_buffer; + tcg_region_reset_all(); /* XXX: flush processor icache at this point if cache flush is expensive */ atomic_mb_set(&tb_ctx.tb_flush_count, tb_ctx.tb_flush_count + 1); @@ -1276,9 +1254,9 @@ TranslationBlock *tb_gen_code(CPUState *cpu, phys_pc = get_page_addr_code(env, pc); + buffer_overflow: tb = tb_alloc(pc); if (unlikely(!tb)) { - buffer_overflow: /* flush must be done */ tb_flush(cpu); mmap_unlock(); @@ -1382,9 +1360,9 @@ TranslationBlock *tb_gen_code(CPUState *cpu, } #endif - tcg_ctx->code_gen_ptr = (void *) + atomic_set(&tcg_ctx->code_gen_ptr, (void *) ROUND_UP((uintptr_t)gen_code_buf + gen_code_size + search_size, - CODE_GEN_ALIGN); + CODE_GEN_ALIGN)); /* init jump list */ assert(((uintptr_t)tb & 3) == 0); @@ -1916,9 +1894,8 @@ void dump_exec_info(FILE *f, fprintf_function cpu_fprintf) * otherwise users might think "-tb-size" is not honoured. * For avg host size we use the precise numbers from tb_tree_stats though. */ - cpu_fprintf(f, "gen code size %td/%zd\n", - tcg_ctx->code_gen_ptr - tcg_ctx->code_gen_buffer, - tcg_ctx->code_gen_highwater - tcg_ctx->code_gen_buffer); + cpu_fprintf(f, "gen code size %zu/%zu\n", + tcg_code_size(), tcg_code_capacity()); cpu_fprintf(f, "TB count %zu\n", nb_tbs); cpu_fprintf(f, "TB avg target size %zu max=%zu bytes\n", nb_tbs ? tst.target_size / nb_tbs : 0, diff --git a/bsd-user/main.c b/bsd-user/main.c index 392c0ed5fb..f1b244b59b 100644 --- a/bsd-user/main.c +++ b/bsd-user/main.c @@ -978,6 +978,7 @@ int main(int argc, char **argv) generating the prologue until now so that the prologue can take the real value of GUEST_BASE into account. */ tcg_prologue_init(tcg_ctx); + tcg_region_init(); /* build Task State */ memset(ts, 0, sizeof(TaskState)); diff --git a/cpus.c b/cpus.c index c9a624003a..8e06257a74 100644 --- a/cpus.c +++ b/cpus.c @@ -1664,6 +1664,18 @@ static void qemu_tcg_init_vcpu(CPUState *cpu) char thread_name[VCPU_THREAD_NAME_SIZE]; static QemuCond *single_tcg_halt_cond; static QemuThread *single_tcg_cpu_thread; + static int tcg_region_inited; + + /* + * Initialize TCG regions--once. Now is a good time, because: + * (1) TCG's init context, prologue and target globals have been set up. + * (2) qemu_tcg_mttcg_enabled() works now (TCG init code runs before the + * -accel flag is processed, so the check doesn't work then). + */ + if (!tcg_region_inited) { + tcg_region_inited = 1; + tcg_region_init(); + } if (qemu_tcg_mttcg_enabled() || !single_tcg_cpu_thread) { cpu->thread = g_malloc0(sizeof(QemuThread)); diff --git a/linux-user/main.c b/linux-user/main.c index 5f40c1a702..199d71ecbb 100644 --- a/linux-user/main.c +++ b/linux-user/main.c @@ -4458,6 +4458,7 @@ int main(int argc, char **argv, char **envp) generating the prologue until now so that the prologue can take the real value of GUEST_BASE into account. */ tcg_prologue_init(tcg_ctx); + tcg_region_init(); #if defined(TARGET_I386) env->cr[0] = CR0_PG_MASK | CR0_WP_MASK | CR0_PE_MASK; diff --git a/tcg/tcg.c b/tcg/tcg.c index 4b7dc800ec..1ce1b08525 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -121,6 +121,30 @@ static bool tcg_out_ldst_finalize(TCGContext *s); static TCGContext **tcg_ctxs; static unsigned int n_tcg_ctxs; +/* + * We divide code_gen_buffer into equally-sized "regions" that TCG threads + * dynamically allocate from as demand dictates. Given appropriate region + * sizing, this minimizes flushes even when some TCG threads generate a lot + * more code than others. + */ +struct tcg_region_state { + QemuMutex lock; + + /* fields set at init time */ + void *start; + void *start_aligned; + void *end; + size_t n; + size_t size; /* size of one region */ + size_t stride; /* .size + guard size */ + + /* fields protected by the lock */ + size_t current; /* current region index */ + size_t agg_size_full; /* aggregate size of full regions */ +}; + +static struct tcg_region_state region; + static TCGRegSet tcg_target_available_regs[2]; static TCGRegSet tcg_target_call_clobber_regs; @@ -258,6 +282,196 @@ TCGLabel *gen_new_label(void) #include "tcg-target.inc.c" +static void tcg_region_bounds(size_t curr_region, void **pstart, void **pend) +{ + void *start, *end; + + start = region.start_aligned + curr_region * region.stride; + end = start + region.size; + + if (curr_region == 0) { + start = region.start; + } + if (curr_region == region.n - 1) { + end = region.end; + } + + *pstart = start; + *pend = end; +} + +static void tcg_region_assign(TCGContext *s, size_t curr_region) +{ + void *start, *end; + + tcg_region_bounds(curr_region, &start, &end); + + s->code_gen_buffer = start; + s->code_gen_ptr = start; + s->code_gen_buffer_size = end - start; + s->code_gen_highwater = end - TCG_HIGHWATER; +} + +static bool tcg_region_alloc__locked(TCGContext *s) +{ + if (region.current == region.n) { + return true; + } + tcg_region_assign(s, region.current); + region.current++; + return false; +} + +/* + * Request a new region once the one in use has filled up. + * Returns true on error. + */ +static bool tcg_region_alloc(TCGContext *s) +{ + bool err; + /* read the region size now; alloc__locked will overwrite it on success */ + size_t size_full = s->code_gen_buffer_size; + + qemu_mutex_lock(®ion.lock); + err = tcg_region_alloc__locked(s); + if (!err) { + region.agg_size_full += size_full - TCG_HIGHWATER; + } + qemu_mutex_unlock(®ion.lock); + return err; +} + +/* + * Perform a context's first region allocation. + * This function does _not_ increment region.agg_size_full. + */ +static inline bool tcg_region_initial_alloc__locked(TCGContext *s) +{ + return tcg_region_alloc__locked(s); +} + +/* Call from a safe-work context */ +void tcg_region_reset_all(void) +{ + unsigned int i; + + qemu_mutex_lock(®ion.lock); + region.current = 0; + region.agg_size_full = 0; + + for (i = 0; i < n_tcg_ctxs; i++) { + bool err = tcg_region_initial_alloc__locked(tcg_ctxs[i]); + + g_assert(!err); + } + qemu_mutex_unlock(®ion.lock); +} + +/* + * Initializes region partitioning. + * + * Called at init time from the parent thread (i.e. the one calling + * tcg_context_init), after the target's TCG globals have been set. + */ +void tcg_region_init(void) +{ + void *buf = tcg_init_ctx.code_gen_buffer; + void *aligned; + size_t size = tcg_init_ctx.code_gen_buffer_size; + size_t page_size = qemu_real_host_page_size; + size_t region_size; + size_t n_regions; + size_t i; + + /* We do not yet support multiple TCG contexts, so use one region for now */ + n_regions = 1; + + /* The first region will be 'aligned - buf' bytes larger than the others */ + aligned = QEMU_ALIGN_PTR_UP(buf, page_size); + g_assert(aligned < tcg_init_ctx.code_gen_buffer + size); + /* + * Make region_size a multiple of page_size, using aligned as the start. + * As a result of this we might end up with a few extra pages at the end of + * the buffer; we will assign those to the last region. + */ + region_size = (size - (aligned - buf)) / n_regions; + region_size = QEMU_ALIGN_DOWN(region_size, page_size); + + /* A region must have at least 2 pages; one code, one guard */ + g_assert(region_size >= 2 * page_size); + + /* init the region struct */ + qemu_mutex_init(®ion.lock); + region.n = n_regions; + region.size = region_size - page_size; + region.stride = region_size; + region.start = buf; + region.start_aligned = aligned; + /* page-align the end, since its last page will be a guard page */ + region.end = QEMU_ALIGN_PTR_DOWN(buf + size, page_size); + /* account for that last guard page */ + region.end -= page_size; + + /* set guard pages */ + for (i = 0; i < region.n; i++) { + void *start, *end; + int rc; + + tcg_region_bounds(i, &start, &end); + rc = qemu_mprotect_none(end, page_size); + g_assert(!rc); + } + + /* We do not yet support multiple TCG contexts so allocate the region now */ + { + bool err = tcg_region_initial_alloc__locked(tcg_ctx); + + g_assert(!err); + } +} + +/* + * Returns the size (in bytes) of all translated code (i.e. from all regions) + * currently in the cache. + * See also: tcg_code_capacity() + * Do not confuse with tcg_current_code_size(); that one applies to a single + * TCG context. + */ +size_t tcg_code_size(void) +{ + unsigned int i; + size_t total; + + qemu_mutex_lock(®ion.lock); + total = region.agg_size_full; + for (i = 0; i < n_tcg_ctxs; i++) { + const TCGContext *s = tcg_ctxs[i]; + size_t size; + + size = atomic_read(&s->code_gen_ptr) - s->code_gen_buffer; + g_assert(size <= s->code_gen_buffer_size); + total += size; + } + qemu_mutex_unlock(®ion.lock); + return total; +} + +/* + * Returns the code capacity (in bytes) of the entire cache, i.e. including all + * regions. + * See also: tcg_code_size() + */ +size_t tcg_code_capacity(void) +{ + size_t guard_size, capacity; + + /* no need for synchronization; these variables are set at init time */ + guard_size = region.stride - region.size; + capacity = region.end + guard_size - region.start; + capacity -= region.n * (guard_size + TCG_HIGHWATER); + return capacity; +} + /* pool based memory allocation */ void *tcg_malloc_internal(TCGContext *s, int size) { @@ -404,13 +618,17 @@ TranslationBlock *tcg_tb_alloc(TCGContext *s) TranslationBlock *tb; void *next; + retry: tb = (void *)ROUND_UP((uintptr_t)s->code_gen_ptr, align); next = (void *)ROUND_UP((uintptr_t)(tb + 1), align); if (unlikely(next > s->code_gen_highwater)) { - return NULL; + if (tcg_region_alloc(s)) { + return NULL; + } + goto retry; } - s->code_gen_ptr = next; + atomic_set(&s->code_gen_ptr, next); s->data_gen_ptr = NULL; return tb; } From patchwork Mon Oct 16 17:26:09 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 115967 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp3958703qgn; Mon, 16 Oct 2017 10:55:50 -0700 (PDT) X-Received: by 10.237.34.28 with SMTP id n28mr15873462qtc.30.1508176550903; Mon, 16 Oct 2017 10:55:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508176550; cv=none; d=google.com; s=arc-20160816; b=yBMEph4Ie/ydj0DqjPb7xruM+cwnplNr93BJsuv3UFKWp+96M6lj45nb4axqKO5QVH TX9EiYzSPDDOLOv3O70MqMHhlTFqr/+Bj8c2pfAH7k+8UIzv1yUZiPkxVsSLbJgirsJ3 vIFRbZQPoLCdNXTfrSQ/Q23uYzL4kIO2AoN4GojW1R83zItaHYRGRh+SBVHPUAERsIS7 YrMdaN8lU2M1h4Ot5iZVs8RSrIswYqVwSreQJS4Po2wVVBV4WpcB6etemECDQQXf/qFk FIFsW4UY2yJrb5gMOjJmqdXe5n/sM/nmbM9I6Rasn6qsrXgB0/hFeZKw8XFr5NV5lzSW 4iYQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=co87QNBExpoR5iCSUcN16vOvbaitg2wPnssAsuHT7DE=; b=ZKe5LZxPtxSbNA1YW9R4fWYua7Otou7/w9x4zc/zJANxO7SZgKuC533/bqzRGAAU0l BVsHa60AlPGRTJ3QJ7t+0AkPKMYJx2LHYMBZrlImbRzyt1sqE3qf7GTlj2bHSuY0GIqE OR6IqhDPjA8FmqMmw2TZHVgTtW58w0/2qXXM4nXrCKB7wrkRscClufBCZo4YxYcPVHdV XxgdhbTKWM/EP73/wsw6lGFf1caj1BTZnO7SvNHNKkblzn0ldJniy9+6OKVg6NsU/Zri bAGMl8gkZ45I/zVIqcBaW+8CkIkUadralTLoAZh8im5am4iKKJW/0MPEs50T39IMtCd7 Dgrw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=c/pC1BI7; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id x13si4636202qti.177.2017.10.16.10.55.50 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 16 Oct 2017 10:55:50 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=c/pC1BI7; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:34419 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e49cC-0001lh-IL for patch@linaro.org; Mon, 16 Oct 2017 13:55:48 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52956) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e49Al-00036J-E8 for qemu-devel@nongnu.org; Mon, 16 Oct 2017 13:27:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e49Aj-0004DW-CJ for qemu-devel@nongnu.org; Mon, 16 Oct 2017 13:27:27 -0400 Received: from mail-pg0-x22d.google.com ([2607:f8b0:400e:c05::22d]:55273) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e49Aj-0004Cl-4v for qemu-devel@nongnu.org; Mon, 16 Oct 2017 13:27:25 -0400 Received: by mail-pg0-x22d.google.com with SMTP id l24so7294840pgu.11 for ; Mon, 16 Oct 2017 10:27:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=co87QNBExpoR5iCSUcN16vOvbaitg2wPnssAsuHT7DE=; b=c/pC1BI74U4DoLAIt4vC2C9O81e4Rx+kgG4+hN+xeMGWhzaaJAczv9yZt6Z8wWyHil cGpa1eaRlmLZbkMs6a6KNyVWquoN/ur4nJB4FkJftBq4EOipfmDUmt5ezwFHM02hnNP6 cvZElPohTvdvVPYX+SbxTCqanYXCF6FgxHags= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=co87QNBExpoR5iCSUcN16vOvbaitg2wPnssAsuHT7DE=; b=lnDDNVD95YXvla+zp7rlHkF6w6gR9prlLs/HtfhP3S6vc61fo2mYrAaYyaaNip6VNn jYqRHrOuSFSzXEQSd3kvkqxZogfjdb/8HdDqt0gGOfr5sHvmGXSRBsMeOhJyDDE5xrTR SBFlLZPVGRGsLlPT1wiPEF5xPXOFyn7vi7Uyt5horDidNEXJ88SpYnftCHk1WIP8qlyr itE5Z2V67BCKhrOU+QJn4cMgt7B4CbeW5eeoNAgyXxpYOYyWBTh17pJdYJFlrgakzfgN A245fXLQ+UdBdsoU8aBogqsvj34SNnfJV0JSneV3fiYKfeKMzDPQD1FSHPjyg8tEsCJC IlkQ== X-Gm-Message-State: AMCzsaWCG2mK20NlYxqXLVvHWZ7mKu+c/eYWm5p+Z76+QxIwJjJWfG2E c0Udi6xwMJ5G3xhR+B0ILM+lPPtI4J8= X-Google-Smtp-Source: ABhQp+S3TY3iu55lsf8A2OwkBktCxlyupF60zJHoY8ABcC4SPMUac/ula5GZyEg5XpHj+F/Ouc3n4g== X-Received: by 10.98.55.133 with SMTP id e127mr890049pfa.130.1508174843738; Mon, 16 Oct 2017 10:27:23 -0700 (PDT) Received: from cloudburst.twiddle.net (97-126-104-76.tukw.qwest.net. [97.126.104.76]) by smtp.gmail.com with ESMTPSA id i187sm5594249pfc.96.2017.10.16.10.27.22 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 16 Oct 2017 10:27:22 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Mon, 16 Oct 2017 10:26:09 -0700 Message-Id: <20171016172609.23422-51-richard.henderson@linaro.org> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171016172609.23422-1-richard.henderson@linaro.org> References: <20171016172609.23422-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c05::22d Subject: [Qemu-devel] [PATCH v6 50/50] tcg: enable multiple TCG contexts in softmmu 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: cota@braap.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: "Emilio G. Cota" This enables parallel TCG code generation. However, we do not take advantage of it yet since tb_lock is still held during tb_gen_code. In user-mode we use a single TCG context; see the documentation added to tcg_region_init for the rationale. Note that targets do not need any conversion: targets initialize a TCGContext (e.g. defining TCG globals), and after this initialization has finished, the context is cloned by the vCPU threads, each of them keeping a separate copy. TCG threads claim one entry in tcg_ctxs[] by atomically increasing n_tcg_ctxs. Do not be too annoyed by the subsequent atomic_read's of that variable and tcg_ctxs; they are there just to play nice with analysis tools such as thread sanitizer. Note that we do not allocate an array of contexts (we allocate an array of pointers instead) because when tcg_context_init is called, we do not know yet how many contexts we'll use since the bool behind qemu_tcg_mttcg_enabled() isn't set yet. Previous patches folded some TCG globals into TCGContext. The non-const globals remaining are only set at init time, i.e. before the TCG threads are spawned. Here is a list of these set-at-init-time globals under tcg/: Only written by tcg_context_init: - indirect_reg_alloc_order - tcg_op_defs Only written by tcg_target_init (called from tcg_context_init): - tcg_target_available_regs - tcg_target_call_clobber_regs - arm: arm_arch, use_idiv_instructions - i386: have_cmov, have_bmi1, have_bmi2, have_lzcnt, have_movbe, have_popcnt - mips: use_movnz_instructions, use_mips32_instructions, use_mips32r2_instructions, got_sigill (tcg_target_detect_isa) - ppc: have_isa_2_06, have_isa_3_00, tb_ret_addr - s390: tb_ret_addr, s390_facilities - sparc: qemu_ld_trampoline, qemu_st_trampoline (build_trampolines), use_vis3_instructions Only written by tcg_prologue_init: - 'struct jit_code_entry one_entry' - aarch64: tb_ret_addr - arm: tb_ret_addr - i386: tb_ret_addr, guest_base_flags - ia64: tb_ret_addr - mips: tb_ret_addr, bswap32_addr, bswap32u_addr, bswap64_addr Reviewed-by: Richard Henderson Signed-off-by: Emilio G. Cota --- tcg/tcg.h | 7 ++- accel/tcg/translate-all.c | 2 +- cpus.c | 2 + linux-user/syscall.c | 1 + tcg/tcg.c | 146 +++++++++++++++++++++++++++++++++++++++++++--- 5 files changed, 145 insertions(+), 13 deletions(-) -- 2.13.6 diff --git a/tcg/tcg.h b/tcg/tcg.h index d3d16a2cce..60bab14958 100644 --- a/tcg/tcg.h +++ b/tcg/tcg.h @@ -737,7 +737,7 @@ struct TCGContext { }; extern TCGContext tcg_init_ctx; -extern TCGContext *tcg_ctx; +extern __thread TCGContext *tcg_ctx; static inline size_t temp_idx(TCGTemp *ts) { @@ -805,7 +805,7 @@ static inline bool tcg_op_buf_full(void) /* pool based memory allocation */ -/* tb_lock must be held for tcg_malloc_internal. */ +/* user-mode: tb_lock must be held for tcg_malloc_internal. */ void *tcg_malloc_internal(TCGContext *s, int size); void tcg_pool_reset(TCGContext *s); TranslationBlock *tcg_tb_alloc(TCGContext *s); @@ -816,7 +816,7 @@ void tcg_region_reset_all(void); size_t tcg_code_size(void); size_t tcg_code_capacity(void); -/* Called with tb_lock held. */ +/* user-mode: Called with tb_lock held. */ static inline void *tcg_malloc(int size) { TCGContext *s = tcg_ctx; @@ -836,6 +836,7 @@ static inline void *tcg_malloc(int size) } void tcg_context_init(TCGContext *s); +void tcg_register_thread(void); void tcg_prologue_init(TCGContext *s); void tcg_func_start(TCGContext *s); diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c index 66b1733911..ac8dfe645c 100644 --- a/accel/tcg/translate-all.c +++ b/accel/tcg/translate-all.c @@ -154,7 +154,7 @@ static void *l1_map[V_L1_MAX_SIZE]; /* code generation context */ TCGContext tcg_init_ctx; -TCGContext *tcg_ctx; +__thread TCGContext *tcg_ctx; TBContext tb_ctx; bool parallel_cpus; diff --git a/cpus.c b/cpus.c index 8e06257a74..114c29b6a0 100644 --- a/cpus.c +++ b/cpus.c @@ -1307,6 +1307,7 @@ static void *qemu_tcg_rr_cpu_thread_fn(void *arg) CPUState *cpu = arg; rcu_register_thread(); + tcg_register_thread(); qemu_mutex_lock_iothread(); qemu_thread_get_self(cpu->thread); @@ -1454,6 +1455,7 @@ static void *qemu_tcg_cpu_thread_fn(void *arg) g_assert(!use_icount); rcu_register_thread(); + tcg_register_thread(); qemu_mutex_lock_iothread(); qemu_thread_get_self(cpu->thread); diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 9b6364a266..364d67b664 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -6215,6 +6215,7 @@ static void *clone_func(void *arg) TaskState *ts; rcu_register_thread(); + tcg_register_thread(); env = info->env; cpu = ENV_GET_CPU(env); thread_cpu = cpu; diff --git a/tcg/tcg.c b/tcg/tcg.c index 1ce1b08525..f93f499061 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -58,6 +58,7 @@ #include "elf.h" #include "exec/log.h" +#include "sysemu/sysemu.h" /* Forward declarations for functions declared in tcg-target.inc.c and used here. */ @@ -353,25 +354,87 @@ static inline bool tcg_region_initial_alloc__locked(TCGContext *s) /* Call from a safe-work context */ void tcg_region_reset_all(void) { + unsigned int n_ctxs = atomic_read(&n_tcg_ctxs); unsigned int i; qemu_mutex_lock(®ion.lock); region.current = 0; region.agg_size_full = 0; - for (i = 0; i < n_tcg_ctxs; i++) { - bool err = tcg_region_initial_alloc__locked(tcg_ctxs[i]); + for (i = 0; i < n_ctxs; i++) { + TCGContext *s = atomic_read(&tcg_ctxs[i]); + bool err = tcg_region_initial_alloc__locked(s); g_assert(!err); } qemu_mutex_unlock(®ion.lock); } +#ifdef CONFIG_USER_ONLY +static size_t tcg_n_regions(void) +{ + return 1; +} +#else +/* + * It is likely that some vCPUs will translate more code than others, so we + * first try to set more regions than max_cpus, with those regions being of + * reasonable size. If that's not possible we make do by evenly dividing + * the code_gen_buffer among the vCPUs. + */ +static size_t tcg_n_regions(void) +{ + size_t i; + + /* Use a single region if all we have is one vCPU thread */ + if (max_cpus == 1 || !qemu_tcg_mttcg_enabled()) { + return 1; + } + + /* Try to have more regions than max_cpus, with each region being >= 2 MB */ + for (i = 8; i > 0; i--) { + size_t regions_per_thread = i; + size_t region_size; + + region_size = tcg_init_ctx.code_gen_buffer_size; + region_size /= max_cpus * regions_per_thread; + + if (region_size >= 2 * 1024u * 1024) { + return max_cpus * regions_per_thread; + } + } + /* If we can't, then just allocate one region per vCPU thread */ + return max_cpus; +} +#endif + /* * Initializes region partitioning. * * Called at init time from the parent thread (i.e. the one calling * tcg_context_init), after the target's TCG globals have been set. + * + * Region partitioning works by splitting code_gen_buffer into separate regions, + * and then assigning regions to TCG threads so that the threads can translate + * code in parallel without synchronization. + * + * In softmmu the number of TCG threads is bounded by max_cpus, so we use at + * least max_cpus regions in MTTCG. In !MTTCG we use a single region. + * Note that the TCG options from the command-line (i.e. -accel accel=tcg,[...]) + * must have been parsed before calling this function, since it calls + * qemu_tcg_mttcg_enabled(). + * + * In user-mode we use a single region. Having multiple regions in user-mode + * is not supported, because the number of vCPU threads (recall that each thread + * spawned by the guest corresponds to a vCPU thread) is only bounded by the + * OS, and usually this number is huge (tens of thousands is not uncommon). + * Thus, given this large bound on the number of vCPU threads and the fact + * that code_gen_buffer is allocated at compile-time, we cannot guarantee + * that the availability of at least one region per vCPU thread. + * + * However, this user-mode limitation is unlikely to be a significant problem + * in practice. Multi-threaded guests share most if not all of their translated + * code, which makes parallel code generation less appealing than in softmmu. */ void tcg_region_init(void) { @@ -383,8 +446,7 @@ void tcg_region_init(void) size_t n_regions; size_t i; - /* We do not yet support multiple TCG contexts, so use one region for now */ - n_regions = 1; + n_regions = tcg_n_regions(); /* The first region will be 'aligned - buf' bytes larger than the others */ aligned = QEMU_ALIGN_PTR_UP(buf, page_size); @@ -422,13 +484,66 @@ void tcg_region_init(void) g_assert(!rc); } - /* We do not yet support multiple TCG contexts so allocate the region now */ + /* In user-mode we support only one ctx, so do the initial allocation now */ +#ifdef CONFIG_USER_ONLY { bool err = tcg_region_initial_alloc__locked(tcg_ctx); g_assert(!err); } +#endif +} + +/* + * All TCG threads except the parent (i.e. the one that called tcg_context_init + * and registered the target's TCG globals) must register with this function + * before initiating translation. + * + * In user-mode we just point tcg_ctx to tcg_init_ctx. See the documentation + * of tcg_region_init() for the reasoning behind this. + * + * In softmmu each caller registers its context in tcg_ctxs[]. Note that in + * softmmu tcg_ctxs[] does not track tcg_ctx_init, since the initial context + * is not used anymore for translation once this function is called. + * + * Not tracking tcg_init_ctx in tcg_ctxs[] in softmmu keeps code that iterates + * over the array (e.g. tcg_code_size() the same for both softmmu and user-mode. + */ +#ifdef CONFIG_USER_ONLY +void tcg_register_thread(void) +{ + tcg_ctx = &tcg_init_ctx; +} +#else +void tcg_register_thread(void) +{ + TCGContext *s = g_malloc(sizeof(*s)); + unsigned int i, n; + bool err; + + *s = tcg_init_ctx; + + /* Relink mem_base. */ + for (i = 0, n = tcg_init_ctx.nb_globals; i < n; ++i) { + if (tcg_init_ctx.temps[i].mem_base) { + ptrdiff_t b = tcg_init_ctx.temps[i].mem_base - tcg_init_ctx.temps; + tcg_debug_assert(b >= 0 && b < n); + s->temps[i].mem_base = &s->temps[b]; + } + } + + /* Claim an entry in tcg_ctxs */ + n = atomic_fetch_inc(&n_tcg_ctxs); + g_assert(n < max_cpus); + atomic_set(&tcg_ctxs[n], s); + + tcg_ctx = s; + qemu_mutex_lock(®ion.lock); + err = tcg_region_initial_alloc__locked(tcg_ctx); + g_assert(!err); + qemu_mutex_unlock(®ion.lock); } +#endif /* !CONFIG_USER_ONLY */ /* * Returns the size (in bytes) of all translated code (i.e. from all regions) @@ -439,13 +554,14 @@ void tcg_region_init(void) */ size_t tcg_code_size(void) { + unsigned int n_ctxs = atomic_read(&n_tcg_ctxs); unsigned int i; size_t total; qemu_mutex_lock(®ion.lock); total = region.agg_size_full; - for (i = 0; i < n_tcg_ctxs; i++) { - const TCGContext *s = tcg_ctxs[i]; + for (i = 0; i < n_ctxs; i++) { + const TCGContext *s = atomic_read(&tcg_ctxs[i]); size_t size; size = atomic_read(&s->code_gen_ptr) - s->code_gen_buffer; @@ -604,8 +720,18 @@ void tcg_context_init(TCGContext *s) } tcg_ctx = s; + /* + * In user-mode we simply share the init context among threads, since we + * use a single region. See the documentation tcg_region_init() for the + * reasoning behind this. + * In softmmu we will have at most max_cpus TCG threads. + */ +#ifdef CONFIG_USER_ONLY tcg_ctxs = &tcg_ctx; n_tcg_ctxs = 1; +#else + tcg_ctxs = g_new(TCGContext *, max_cpus); +#endif } /* @@ -2967,10 +3093,12 @@ static void tcg_reg_alloc_call(TCGContext *s, TCGOp *op) static inline void tcg_profile_snapshot(TCGProfile *prof, bool counters, bool table) { + unsigned int n_ctxs = atomic_read(&n_tcg_ctxs); unsigned int i; - for (i = 0; i < n_tcg_ctxs; i++) { - const TCGProfile *orig = &tcg_ctxs[i]->prof; + for (i = 0; i < n_ctxs; i++) { + TCGContext *s = atomic_read(&tcg_ctxs[i]); + const TCGProfile *orig = &s->prof; if (counters) { PROF_ADD(prof, orig, tb_count1);