From patchwork Wed Nov 28 05:38:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 152181 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp686405ljp; Tue, 27 Nov 2018 21:39:20 -0800 (PST) X-Google-Smtp-Source: AFSGD/XcEEGSFmamxojR8/5CjzPVxWNF7oonyeNYRJKykBujpmphpTPnt5edfCDHiaT8mi03CMKe X-Received: by 2002:a81:78cc:: with SMTP id t195mr23279566ywc.387.1543383560596; Tue, 27 Nov 2018 21:39:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543383560; cv=none; d=google.com; s=arc-20160816; b=w6LrxqZJPm5JX/TWmfYEpWaSEUlzoD4S4ckpwmE80MCF8dIrVqgF/0lGAK9yPvDVfV bXEg0CR16InKMAvH0ozntFl5YI5DNtDLPR66LtzkvnPFgl0aFRVZ2kv218kkSGzBdQv/ tMOd0sVgXtewF2t3p3qruhXCZsBUvnpelOWXqmFVenebcL6HqSd+X1nqODMHc6kUGgE7 0pgbRaRHsichVFRVTZFoE0E0mQISjkKp6FroscT172qzzyBKnGjZN+YZGKq87Jkxeb3N GKH2EzxzZT481Wram5ihIzaH0U6AxQnf9n+7BCjPGVSJ1skZxN1Qwzpv+ZENUBuhAn11 CniQ== 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; bh=xjZ2g0RlKwtygAl8ZD7KX634Dk8TC9PWLwdw3xE4psE=; b=Zx0VHomPambpIXZNOf/Q1oyS2arOVObHFzmaF31rqFjAJ3OxQmTq2p0BfO7uYkacbe GPUSQoNZ5acA7AM9Ln31z8GM/+N6icL4VI5N863zYKThu4nCauZCo55KrVOflk9jONBw pqHpAfK5K3xwKs9BB5a6URsQ0a5K6R+9AJ6EVzTMCdPrfy4ObBtIN1AeIO+N8iO2Lohy 4KLO8aCGOoCnsMfWXJ5Cu8PtFkdmp0qRV5l2qrDLiNwD2tiIhqCODRb43Nb0Dixumx8a 7fnc2ZIxyNp/F+w5k6Vq7b3X4QGTqjaGJ+PPFnR8Slpq5Exc0ujEDAbjyjGV2I8zg2eu UW1A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=jWtTukTk; 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 200si4356754ywr.313.2018.11.27.21.39.20 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 27 Nov 2018 21:39:20 -0800 (PST) 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=jWtTukTk; 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]:46028 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gRsZD-0003oH-SM for patch@linaro.org; Wed, 28 Nov 2018 00:39:19 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47819) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gRsYd-0003kh-94 for qemu-devel@nongnu.org; Wed, 28 Nov 2018 00:38:44 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gRsYZ-0004IU-Co for qemu-devel@nongnu.org; Wed, 28 Nov 2018 00:38:42 -0500 Received: from mail-pf1-x434.google.com ([2607:f8b0:4864:20::434]:47085) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gRsYZ-0004He-2r for qemu-devel@nongnu.org; Wed, 28 Nov 2018 00:38:39 -0500 Received: by mail-pf1-x434.google.com with SMTP id c73so9591137pfe.13 for ; Tue, 27 Nov 2018 21:38:39 -0800 (PST) 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=xjZ2g0RlKwtygAl8ZD7KX634Dk8TC9PWLwdw3xE4psE=; b=jWtTukTkyirF/XbueAf983CBMS2W3sbKxEcxaOUzGhaRfkbZHccrKW0OW7ZDFq7K+8 MzDW/aYQa/55YgDnhCC7jcC+MrihiKEtAbidIiPrUGnh5UYjlXqBViiuMKCCz9q2vEe4 oAbGTI35pJSPueJapmf42pp81pSbZlCfeYHCI= 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=xjZ2g0RlKwtygAl8ZD7KX634Dk8TC9PWLwdw3xE4psE=; b=WgCCc20l6cpW+BbuYHlPBA20RaRyAgofhkQcG4mYHWuphHw9D+oEfHo7OHH+kk3fZt BiGYn0q9v4F5sJrves6v9jy5zF5mKV3rbSdryS7tbcj20Y7I289i0M6SBGjkasK5TfaR nh8HHjY5mdfsf1SDATlyL549bLtzfoAvFFg9QJsxYWWKtb5y4ICKEeP+Ycd5rGUbMYSq gSSWZNCXR0TGNbo8iKwBH93lEy0rlTDupZpKH0iJtS3S5Wmp2Kvw0r6b4XavjutWA4y+ FjoGjk7HTuDDW20APn1gCC8pnAublbLBEQ4T0T0loipA07PpaFN0NFEUovEz9kl4pLBx Pd9g== X-Gm-Message-State: AA+aEWZgPAxFO6Org5FCfSZgYqNy8tAHO7pbpjKJILqSFB61xuOtaC/k E6LGZk7NcauiwdFbRws7qRkKJJ5mOaI= X-Received: by 2002:a63:2bc4:: with SMTP id r187mr13226325pgr.306.1543383517679; Tue, 27 Nov 2018 21:38:37 -0800 (PST) Received: from cloudburst.twiddle.net (97-113-170-180.tukw.qwest.net. [97.113.170.180]) by smtp.gmail.com with ESMTPSA id 19sm8569336pfs.108.2018.11.27.21.38.36 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 27 Nov 2018 21:38:36 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Date: Tue, 27 Nov 2018 21:38:23 -0800 Message-Id: <20181128053834.10861-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20181128053834.10861-1-richard.henderson@linaro.org> References: <20181128053834.10861-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::434 Subject: [Qemu-devel] [PATCH 01/12] tcg: Add preferred_reg argument to tcg_reg_alloc 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 new argument will aid register allocation by indicating how the temporary will be used in future. If the preference cannot be satisfied, fall back to the constraints of the current insn. Short circuit the preference when it cannot be satisfied or if it does not further constrain the operation. With an eye toward optimizing function call sequences, optimize for the preferred_reg set containing a single register. For the moment, all users pass 0 for preference. Signed-off-by: Richard Henderson --- tcg/tcg.c | 103 ++++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 81 insertions(+), 22 deletions(-) -- 2.17.2 diff --git a/tcg/tcg.c b/tcg/tcg.c index 8734389ba9..c596277fd0 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -1907,6 +1907,20 @@ static const char * const alignment_name[(MO_AMASK >> MO_ASHIFT) + 1] = { [MO_ALIGN_64 >> MO_ASHIFT] = "al64+", }; +static inline bool tcg_regset_single(TCGRegSet d) +{ + return (d & (d - 1)) == 0; +} + +static inline TCGReg tcg_regset_first(TCGRegSet d) +{ + if (TCG_TARGET_NB_REGS <= 32) { + return ctz32(d); + } else { + return ctz64(d); + } +} + void tcg_dump_ops(TCGContext *s) { char buf[128]; @@ -1922,6 +1936,7 @@ void tcg_dump_ops(TCGContext *s) def = &tcg_op_defs[c]; if (c == INDEX_op_insn_start) { + nb_oargs = 0; col += qemu_log("\n ----"); for (i = 0; i < TARGET_INSN_START_WORDS; ++i) { @@ -2924,31 +2939,72 @@ static void tcg_reg_free(TCGContext *s, TCGReg reg, TCGRegSet allocated_regs) } } -/* Allocate a register belonging to reg1 & ~reg2 */ -static TCGReg tcg_reg_alloc(TCGContext *s, TCGRegSet desired_regs, - TCGRegSet allocated_regs, bool rev) +/** + * tcg_reg_alloc: + * @required_regs: Set of registers in which we must allocate. + * @allocated_regs: Set of registers which must be avoided. + * @preferred_regs: Set of registers we should prefer. + * @rev: True if we search the registers in "indirect" order. + * + * The allocated register must be in @required_regs & ~@allocated_regs, + * but if we can put it in @preferred_regs we may save a move later. + */ +static TCGReg tcg_reg_alloc(TCGContext *s, TCGRegSet required_regs, + TCGRegSet allocated_regs, + TCGRegSet preferred_regs, bool rev) { - int i, n = ARRAY_SIZE(tcg_target_reg_alloc_order); + int i, j, f, n = ARRAY_SIZE(tcg_target_reg_alloc_order); + TCGRegSet reg_ct[2]; const int *order; - TCGReg reg; - TCGRegSet reg_ct; - reg_ct = desired_regs & ~allocated_regs; + reg_ct[1] = required_regs & ~allocated_regs; + tcg_debug_assert(reg_ct[1] != 0); + reg_ct[0] = reg_ct[1] & preferred_regs; + + /* Skip the preferred_regs option if it cannot be satisfied, + or if the preference made no difference. */ + f = reg_ct[0] == 0 || reg_ct[0] == reg_ct[1]; + order = rev ? indirect_reg_alloc_order : tcg_target_reg_alloc_order; - /* first try free registers */ - for(i = 0; i < n; i++) { - reg = order[i]; - if (tcg_regset_test_reg(reg_ct, reg) && s->reg_to_temp[reg] == NULL) - return reg; + /* Try free registers, preferences first. */ + for (j = f; j < 2; j++) { + TCGRegSet set = reg_ct[j]; + + if (tcg_regset_single(set)) { + /* One register in the set. */ + TCGReg reg = tcg_regset_first(set); + if (s->reg_to_temp[reg] == NULL) { + return reg; + } + } else { + for (i = 0; i < n; i++) { + TCGReg reg = order[i]; + if (s->reg_to_temp[reg] == NULL && + tcg_regset_test_reg(set, reg)) { + return reg; + } + } + } } - /* XXX: do better spill choice */ - for(i = 0; i < n; i++) { - reg = order[i]; - if (tcg_regset_test_reg(reg_ct, reg)) { + /* We must spill something. */ + for (j = f; j < 2; j++) { + TCGRegSet set = reg_ct[j]; + + if (tcg_regset_single(set)) { + /* One register in the set. */ + TCGReg reg = tcg_regset_first(set); tcg_reg_free(s, reg, allocated_regs); return reg; + } else { + for (i = 0; i < n; i++) { + TCGReg reg = order[i]; + if (tcg_regset_test_reg(set, reg)) { + tcg_reg_free(s, reg, allocated_regs); + return reg; + } + } } } @@ -2966,12 +3022,14 @@ static void temp_load(TCGContext *s, TCGTemp *ts, TCGRegSet desired_regs, case TEMP_VAL_REG: return; case TEMP_VAL_CONST: - reg = tcg_reg_alloc(s, desired_regs, allocated_regs, ts->indirect_base); + reg = tcg_reg_alloc(s, desired_regs, allocated_regs, + 0, ts->indirect_base); tcg_out_movi(s, ts->type, reg, ts->val); ts->mem_coherent = 0; break; case TEMP_VAL_MEM: - reg = tcg_reg_alloc(s, desired_regs, allocated_regs, ts->indirect_base); + reg = tcg_reg_alloc(s, desired_regs, allocated_regs, + 0, ts->indirect_base); tcg_out_ld(s, ts->type, reg, ts->mem_base->reg, ts->mem_offset); ts->mem_coherent = 1; break; @@ -3131,7 +3189,8 @@ static void tcg_reg_alloc_mov(TCGContext *s, const TCGOp *op) input one. */ tcg_regset_set_reg(allocated_regs, ts->reg); ots->reg = tcg_reg_alloc(s, tcg_target_available_regs[otype], - allocated_regs, ots->indirect_base); + allocated_regs, 0, + ots->indirect_base); } tcg_out_mov(s, otype, ots->reg, ts->reg); } @@ -3219,7 +3278,7 @@ static void tcg_reg_alloc_op(TCGContext *s, const TCGOp *op) /* allocate a new register matching the constraint and move the temporary register into it */ reg = tcg_reg_alloc(s, arg_ct->u.regs, i_allocated_regs, - ts->indirect_base); + 0, ts->indirect_base); tcg_out_mov(s, ts->type, reg, ts->reg); } new_args[i] = reg; @@ -3264,7 +3323,7 @@ static void tcg_reg_alloc_op(TCGContext *s, const TCGOp *op) } else if (arg_ct->ct & TCG_CT_NEWREG) { reg = tcg_reg_alloc(s, arg_ct->u.regs, i_allocated_regs | o_allocated_regs, - ts->indirect_base); + 0, ts->indirect_base); } else { /* if fixed register, we try to use it */ reg = ts->reg; @@ -3273,7 +3332,7 @@ static void tcg_reg_alloc_op(TCGContext *s, const TCGOp *op) goto oarg_end; } reg = tcg_reg_alloc(s, arg_ct->u.regs, o_allocated_regs, - ts->indirect_base); + 0, ts->indirect_base); } tcg_regset_set_reg(o_allocated_regs, reg); /* if a fixed register is used, then a move will be done afterwards */ From patchwork Wed Nov 28 05:38:24 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 152187 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp688737ljp; Tue, 27 Nov 2018 21:42:53 -0800 (PST) X-Google-Smtp-Source: AFSGD/Vr11WOQEjpTitfOjsfB1WYh8XxLrykHEuuE/kPk3B/SNyYpPwwKeqmfiwzSYWOVbuY+o/b X-Received: by 2002:a25:5186:: with SMTP id f128-v6mr36274660ybb.203.1543383773203; Tue, 27 Nov 2018 21:42:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543383773; cv=none; d=google.com; s=arc-20160816; b=xKZeeZuuCZysc8o3YGcYV/q0WU+/9ifqupAz3v3Nd07T4AdpSZQsPc2j9nZs/EfWV2 p28D6yA5h7di+p0PXRa7TwhQ9i6FZHh30ylNQAZ2AQ/w99+GNdhkNLmu9I9/E2AMlI/S oHIlcp1L+2ceVGc51cPiotY65OX6JSsJWe6Um9I9jLti8wObrlr7c2d4RWm3JlWDPXs6 1CjEj6v5aDlwjLPywcknoAc2cZYeQqrErtL8NnCtN6YCw5P8e46IqFDNhrC4XqIQZb7g d1ujyzH5yapqaX6sg6E6AzE52gN2RjtinYb13ZV4UvSFjCR41NYhBVcWTjuP/wWkQMVh Zd7A== 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; bh=wj+Ww7Y6K29VKQ07od9GNMsx9UfCK0GFYGutLalgTzo=; b=gRoMVfsNJ1S4FgWM3zFzLpgfp3//L8f0utWHxzvPQ/+A+kBtqp9NjbAwK/q3ykPqFj tNqAVtHNNSz1thAHtAc4IwkXTUKbR7GUBBGI7GfuXKRDkvg36LTN6JEjxo5g866Qh5AT bCEG2TvWvvbVwFPryY08vwEwX3/2KJJ4pJ4cwSqrtboPZfSy//j31B9H13e55d59BbNJ lJTy9z+oEEa7ZGwWgf2J7FUZPw0B2+LTTF1/WhlR6++xehtxrqHNlI6HBBFCwubGciKH kswT4BXl9fCMMUw/tGGWFfr5dwiRZekUeQbvOwueSymLCMzTr0FiYk7ZWsKIKgsKh6ED 9siw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=RaMbZ1e6; 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 y8si4166327ywc.47.2018.11.27.21.42.53 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 27 Nov 2018 21:42:53 -0800 (PST) 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=RaMbZ1e6; 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]:46048 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gRscb-0006zc-Gn for patch@linaro.org; Wed, 28 Nov 2018 00:42:49 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47820) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gRsYd-0003ki-92 for qemu-devel@nongnu.org; Wed, 28 Nov 2018 00:38:44 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gRsYa-0004Iu-Fm for qemu-devel@nongnu.org; Wed, 28 Nov 2018 00:38:42 -0500 Received: from mail-pg1-x544.google.com ([2607:f8b0:4864:20::544]:33797) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gRsYa-0004Id-Ad for qemu-devel@nongnu.org; Wed, 28 Nov 2018 00:38:40 -0500 Received: by mail-pg1-x544.google.com with SMTP id 17so8979569pgg.1 for ; Tue, 27 Nov 2018 21:38:40 -0800 (PST) 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=wj+Ww7Y6K29VKQ07od9GNMsx9UfCK0GFYGutLalgTzo=; b=RaMbZ1e66VONctlDxmEsYf08mkvu1VLY3r/kmuGG+nnyFDclilr5n/nhDpG4Utpaej v7QM8qOBMKW0pCMh6X6LCqnEJG7e0imxDiKjjnNsj3DjiD56Vkh3UrRuZ7P3CbgnSPjk UuVLxy26cSKZBTg9R85ViryMbl8PIyXDRtHoE= 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=wj+Ww7Y6K29VKQ07od9GNMsx9UfCK0GFYGutLalgTzo=; b=VL+cyELZ/g15ClxB/JwTzIQDKIA08vAtyFEzMF6A00tPFSly7qIRv4Tx7oSXvGyaq8 v0nrcK+pNegoLai25Kgrjhe3PT28QfHAbGqrZXdNQ+8nV7ScI8eGQhbwPhtjGZL6Yx2I u3rXmAoFaAqRwSgfDV5lr1Kyit3X/QQ8C5gY7D7HgJF2d1F0wEBCjA/YFKHY3Dj3UCuq o18B28OtW/rMEDe7tcEnZf06IUpGhHJSdYrOrJGl4L9twCr47Q2hRrzl4jRLP9H+nqrk lHPHJg5+4DF3NyMRJw/FkX0wPUwzosTl2Ij0a1ENZ8aGAhtUdFXx9uOGxUd6A1VtIeiY 8dsw== X-Gm-Message-State: AA+aEWYt6SF2EatlCo1mbuYRfLxuQxNZ0AVIybdEKZCPHshnRf6+cExy 14IVYYmLsZl5pVtKQVs55K2UvRHpTyo= X-Received: by 2002:a63:1904:: with SMTP id z4mr31067927pgl.135.1543383518976; Tue, 27 Nov 2018 21:38:38 -0800 (PST) Received: from cloudburst.twiddle.net (97-113-170-180.tukw.qwest.net. [97.113.170.180]) by smtp.gmail.com with ESMTPSA id 19sm8569336pfs.108.2018.11.27.21.38.37 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 27 Nov 2018 21:38:38 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Date: Tue, 27 Nov 2018 21:38:24 -0800 Message-Id: <20181128053834.10861-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20181128053834.10861-1-richard.henderson@linaro.org> References: <20181128053834.10861-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::544 Subject: [Qemu-devel] [PATCH 02/12] tcg: Add preferred_reg argument to temp_load 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" Pass this through to tcg_reg_alloc. Signed-off-by: Richard Henderson --- tcg/tcg.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) -- 2.17.2 diff --git a/tcg/tcg.c b/tcg/tcg.c index c596277fd0..7f29a2045a 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -2859,7 +2859,7 @@ static void temp_allocate_frame(TCGContext *s, TCGTemp *ts) s->current_frame_offset += sizeof(tcg_target_long); } -static void temp_load(TCGContext *, TCGTemp *, TCGRegSet, TCGRegSet); +static void temp_load(TCGContext *, TCGTemp *, TCGRegSet, TCGRegSet, TCGRegSet); /* Mark a temporary as free or dead. If 'free_or_dead' is negative, mark it free; otherwise mark it dead. */ @@ -2908,7 +2908,7 @@ static void temp_sync(TCGContext *s, TCGTemp *ts, break; } temp_load(s, ts, tcg_target_available_regs[ts->type], - allocated_regs); + allocated_regs, 0); /* fallthrough */ case TEMP_VAL_REG: @@ -3014,7 +3014,7 @@ static TCGReg tcg_reg_alloc(TCGContext *s, TCGRegSet required_regs, /* Make sure the temporary is in a register. If needed, allocate the register from DESIRED while avoiding ALLOCATED. */ static void temp_load(TCGContext *s, TCGTemp *ts, TCGRegSet desired_regs, - TCGRegSet allocated_regs) + TCGRegSet allocated_regs, TCGRegSet preferred_regs) { TCGReg reg; @@ -3023,13 +3023,13 @@ static void temp_load(TCGContext *s, TCGTemp *ts, TCGRegSet desired_regs, return; case TEMP_VAL_CONST: reg = tcg_reg_alloc(s, desired_regs, allocated_regs, - 0, ts->indirect_base); + preferred_regs, ts->indirect_base); tcg_out_movi(s, ts->type, reg, ts->val); ts->mem_coherent = 0; break; case TEMP_VAL_MEM: reg = tcg_reg_alloc(s, desired_regs, allocated_regs, - 0, ts->indirect_base); + preferred_regs, ts->indirect_base); tcg_out_ld(s, ts->type, reg, ts->mem_base->reg, ts->mem_offset); ts->mem_coherent = 1; break; @@ -3159,7 +3159,7 @@ static void tcg_reg_alloc_mov(TCGContext *s, const TCGOp *op) the SOURCE value into its own register first, that way we don't have to reload SOURCE the next time it is used. */ if (ts->val_type == TEMP_VAL_MEM) { - temp_load(s, ts, tcg_target_available_regs[itype], allocated_regs); + temp_load(s, ts, tcg_target_available_regs[itype], allocated_regs, 0); } tcg_debug_assert(ts->val_type == TEMP_VAL_REG); @@ -3243,7 +3243,7 @@ static void tcg_reg_alloc_op(TCGContext *s, const TCGOp *op) goto iarg_end; } - temp_load(s, ts, arg_ct->u.regs, i_allocated_regs); + temp_load(s, ts, arg_ct->u.regs, i_allocated_regs, 0); if (arg_ct->ct & TCG_CT_IALIAS) { if (ts->fixed_reg) { @@ -3424,7 +3424,7 @@ static void tcg_reg_alloc_call(TCGContext *s, TCGOp *op) if (arg != TCG_CALL_DUMMY_ARG) { ts = arg_temp(arg); temp_load(s, ts, tcg_target_available_regs[ts->type], - s->reserved_regs); + s->reserved_regs, 0); tcg_out_st(s, ts->type, ts->reg, TCG_REG_CALL_STACK, stack_offset); } #ifndef TCG_TARGET_STACK_GROWSUP @@ -3449,7 +3449,7 @@ static void tcg_reg_alloc_call(TCGContext *s, TCGOp *op) TCGRegSet arg_set = 0; tcg_regset_set_reg(arg_set, reg); - temp_load(s, ts, arg_set, allocated_regs); + temp_load(s, ts, arg_set, allocated_regs, 0); } tcg_regset_set_reg(allocated_regs, reg); From patchwork Wed Nov 28 05:38:25 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 152183 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp688044ljp; Tue, 27 Nov 2018 21:41:56 -0800 (PST) X-Google-Smtp-Source: AJdET5e9dr73l8ksdCHOdZpOKiNp1rNIavKwthV9GkQq7lS2c4VHe7ke6W/EH/jg2fdfakMOTgDs X-Received: by 2002:a81:6f03:: with SMTP id k3mr35900899ywc.424.1543383716454; Tue, 27 Nov 2018 21:41:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543383716; cv=none; d=google.com; s=arc-20160816; b=b5hxpFNGy1Cra3AoSYijSEs9SD9OK9kZ0GATzcE2w2OXjSjpudbYoVsiEH1hhhkErD DzbYFoWd9VEqZ922oNaHakZ9YwF/olQTHpWG2bHWA+NkMFrhivt6+PKf+lSTOWVnyoYe t9x030btknauI0mmrMTDR0GEFXjXl12fOXr+psIb2qfQNNleRkg7KtkrRdz4qWVkfY3R 6rCkZcx05JrBbIlT2HSqGqBmMTZ1vFtXZvZlAXM6wBHt6hyCLFSFffNkildDKRYGGSkN lO45oe9OXGvZNgkrdQZMEfJjcAwdLYqLYfggTXWoc8SRRWM11nus3XyI7I5KwcKrE3/u ed1g== 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; bh=N+S/Ex+S3f3RfZoA0pODXX8UV9gW9SVi2akCyHlxE00=; b=hGmNHILARUy6ghmB6Sie6KAeXybDjEzR5eC/s/dwcq0+Ek1vvPNNLopBq+KbNayB5Y XAbVlojqHd8e/YoaQL5bpUlCcMa65yNmBHMv2Gcql7L4iWJDG68bdrY51sFPKLIiB8Gt wfgZSSoaQOU2LFXOhMSqVGr0pcZZ9RbTlFMwMug7khEcgGnkrhraDKEUZYCPEA+su0kp nsjwRCQ5wEetzA+H+SBgr6GIMBWUpUv9hiBz7EgFLKWxZ5PRQLZEL647X/RMpJ3Oou29 P32yPMD7AbCCXme9Sz/DIUh5FYZSkK5OmC6hGmryXWcn/LdWIWvehcgd7/YEK6I/1HdZ vKUw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="C/v89Rhl"; 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 m185si4208523ywf.256.2018.11.27.21.41.56 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 27 Nov 2018 21:41:56 -0800 (PST) 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/v89Rhl"; 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]:46040 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gRsbj-0006aq-Pq for patch@linaro.org; Wed, 28 Nov 2018 00:41:55 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47836) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gRsYe-0003lt-ID for qemu-devel@nongnu.org; Wed, 28 Nov 2018 00:38:45 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gRsYd-0004Jw-AN for qemu-devel@nongnu.org; Wed, 28 Nov 2018 00:38:44 -0500 Received: from mail-pl1-x644.google.com ([2607:f8b0:4864:20::644]:35043) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gRsYb-0004J8-Gt for qemu-devel@nongnu.org; Wed, 28 Nov 2018 00:38:42 -0500 Received: by mail-pl1-x644.google.com with SMTP id p8so6529534plo.2 for ; Tue, 27 Nov 2018 21:38:41 -0800 (PST) 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=N+S/Ex+S3f3RfZoA0pODXX8UV9gW9SVi2akCyHlxE00=; b=C/v89RhlVCK2qUByCs0lcC3AharYt17GjavhG/5o4jQz2Cxrx7UGPJkrRprNG8l3NB zNY1bFmND9pMU779gQOXMGZw+z4ciUbIwaRpXqPHdO9b0OMuOL/Vwv1FCZOXm95tNiKw UKGSSmjd0dtn0ugTqDy1Kg3KJ3gPvioAW1HKY= 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=N+S/Ex+S3f3RfZoA0pODXX8UV9gW9SVi2akCyHlxE00=; b=K6EsMJNSbsQdxYVfPE4oWujBafmZEhb1iATCQIfPVrYwmuRcIIeGAe4rpfeLV3X+ru X8rwCFH5w/dr3Co/NJUGP3VpdSkd2IhrffAAKpzTltKrrAzPGIINOw4ppb51y1HQirW2 tM3rnJtarUkHyRLIQioFziXLku7GYbtdtFOHsTkOgnwFLbnACaVGbl6TdjrS4E1c/4h1 T+5WFDIff/SK5YImbXugesJDqjqWAWFy7FJPtRZbSWby/yhQio/1PMYJxlYrvK1OpyAq j/LkFV3vb7rwMAVr/pw1X0gvzsRjgMShGE4Pymce+jFHQ2WjrUXtV1lRxKT002c6i9OT qrag== X-Gm-Message-State: AA+aEWZN6d190bCnAO67P56+JDlTNVTxCmtv5wrnqcv+95uG5oprwiPK +f2doE/bP1KGecuuLZJKY9uWXlYSmac= X-Received: by 2002:a17:902:9a4c:: with SMTP id x12mr1731911plv.94.1543383520195; Tue, 27 Nov 2018 21:38:40 -0800 (PST) Received: from cloudburst.twiddle.net (97-113-170-180.tukw.qwest.net. [97.113.170.180]) by smtp.gmail.com with ESMTPSA id 19sm8569336pfs.108.2018.11.27.21.38.39 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 27 Nov 2018 21:38:39 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Date: Tue, 27 Nov 2018 21:38:25 -0800 Message-Id: <20181128053834.10861-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20181128053834.10861-1-richard.henderson@linaro.org> References: <20181128053834.10861-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::644 Subject: [Qemu-devel] [PATCH 03/12] tcg: Add preferred_reg argument to temp_sync 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" Pass this through to tcg_reg_alloc. Signed-off-by: Richard Henderson --- tcg/tcg.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) -- 2.17.2 diff --git a/tcg/tcg.c b/tcg/tcg.c index 7f29a2045a..509e5974bd 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -2887,8 +2887,8 @@ static inline void temp_dead(TCGContext *s, TCGTemp *ts) registers needs to be allocated to store a constant. If 'free_or_dead' is non-zero, subsequently release the temporary; if it is positive, the temp is dead; if it is negative, the temp is free. */ -static void temp_sync(TCGContext *s, TCGTemp *ts, - TCGRegSet allocated_regs, int free_or_dead) +static void temp_sync(TCGContext *s, TCGTemp *ts, TCGRegSet allocated_regs, + TCGRegSet preferred_regs, int free_or_dead) { if (ts->fixed_reg) { return; @@ -2908,7 +2908,7 @@ static void temp_sync(TCGContext *s, TCGTemp *ts, break; } temp_load(s, ts, tcg_target_available_regs[ts->type], - allocated_regs, 0); + allocated_regs, preferred_regs); /* fallthrough */ case TEMP_VAL_REG: @@ -2935,7 +2935,7 @@ static void tcg_reg_free(TCGContext *s, TCGReg reg, TCGRegSet allocated_regs) { TCGTemp *ts = s->reg_to_temp[reg]; if (ts != NULL) { - temp_sync(s, ts, allocated_regs, -1); + temp_sync(s, ts, allocated_regs, 0, -1); } } @@ -3115,7 +3115,7 @@ static void tcg_reg_alloc_do_movi(TCGContext *s, TCGTemp *ots, ots->val = val; ots->mem_coherent = 0; if (NEED_SYNC_ARG(0)) { - temp_sync(s, ots, s->reserved_regs, IS_DEAD_ARG(0)); + temp_sync(s, ots, s->reserved_regs, 0, IS_DEAD_ARG(0)); } else if (IS_DEAD_ARG(0)) { temp_dead(s, ots); } @@ -3198,7 +3198,7 @@ static void tcg_reg_alloc_mov(TCGContext *s, const TCGOp *op) ots->mem_coherent = 0; s->reg_to_temp[ots->reg] = ots; if (NEED_SYNC_ARG(0)) { - temp_sync(s, ots, allocated_regs, 0); + temp_sync(s, ots, allocated_regs, 0, 0); } } } @@ -3368,7 +3368,7 @@ static void tcg_reg_alloc_op(TCGContext *s, const TCGOp *op) tcg_out_mov(s, ts->type, ts->reg, reg); } if (NEED_SYNC_ARG(i)) { - temp_sync(s, ts, o_allocated_regs, IS_DEAD_ARG(i)); + temp_sync(s, ts, o_allocated_regs, 0, IS_DEAD_ARG(i)); } else if (IS_DEAD_ARG(i)) { temp_dead(s, ts); } @@ -3502,7 +3502,7 @@ static void tcg_reg_alloc_call(TCGContext *s, TCGOp *op) ts->mem_coherent = 0; s->reg_to_temp[reg] = ts; if (NEED_SYNC_ARG(i)) { - temp_sync(s, ts, allocated_regs, IS_DEAD_ARG(i)); + temp_sync(s, ts, allocated_regs, 0, IS_DEAD_ARG(i)); } else if (IS_DEAD_ARG(i)) { temp_dead(s, ts); } From patchwork Wed Nov 28 05:38:26 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 152186 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp688485ljp; Tue, 27 Nov 2018 21:42:33 -0800 (PST) X-Google-Smtp-Source: AFSGD/XP3uXFopc3FX5ujSUCOku2lpknpnkwxSJTOVHM8IWw/sjptIbvWKcrbajFZxHlGT+WUMM9 X-Received: by 2002:a25:6ec1:: with SMTP id j184-v6mr34770780ybc.400.1543383753140; Tue, 27 Nov 2018 21:42:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543383753; cv=none; d=google.com; s=arc-20160816; b=zaL/USrltlVAGuhn5vEJOrwuJMFiGVdbbRhpYN0gQkIRotbWTZ4mRxQZFBq/BSIiqj Puttc2gtSuGg5eXi+W0a4pIoafUE8D0QigJN4bAdNwHhluicmyBsQmdPpbZhQNCMMTa1 +z+0zloPm7sIqku74u7m/cv33mFIZLeQ/oBJv1sZFyFglOBECYIRuf1WN4dpEVipMQWW MnsJMpCE/9CvdpEUwNPAbTOyhJ3ibaiMCIN1S+lD9Prr1AMWKKTNyX3jDj3qm6f+xeqn uK1apTGW/ylHWDXvpctL2uMaPelRjqVEgy27wG4XMmrUszmZuD/OZ4m9b5E6gjgun7aT vzrQ== 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; bh=vQPcVoGV0u9SuJTOPjajxaRuT7Da+0X49o+wYRuOFhM=; b=RZwtjwKWaqy0GrDUukX3FGAg0Dt82YTRrxYZ1SZ4M045Z6ISLCxKAv1P/LgS77BLYm wv8TgYB91a9CWlTvwnQNbXgRpLB7rKqBzVnivs3v0DjZMSnXT3ofcxdZlCWVW5WXjNKP oAooRsBObA5FEEvQwTg5cvCv3qq3Cskp9UvkP2YzBQkZr2YyqgPBGFjoB15/S6mV/yem c65M/a27iPs61FZpz6Dsbh1opTFSCS+GEvGbuxOHJsogOP3mCb8khKePYtfW+EBR2yBK GfTlAdbO17fQzMC3XhRsCr84jz3MFkuhiY+7/Vz+FV2McQ1I74iUqjFC+LmPyWBNdy0i SlHg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=SbPOeqva; 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 f125si4214415ywa.280.2018.11.27.21.42.32 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 27 Nov 2018 21:42:33 -0800 (PST) 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=SbPOeqva; 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]:46045 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gRscK-0006jY-FS for patch@linaro.org; Wed, 28 Nov 2018 00:42:32 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47881) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gRsYi-0003tC-GB for qemu-devel@nongnu.org; Wed, 28 Nov 2018 00:38:53 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gRsYg-0004LL-GJ for qemu-devel@nongnu.org; Wed, 28 Nov 2018 00:38:48 -0500 Received: from mail-pl1-x642.google.com ([2607:f8b0:4864:20::642]:39023) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gRsYd-0004JT-9b for qemu-devel@nongnu.org; Wed, 28 Nov 2018 00:38:44 -0500 Received: by mail-pl1-x642.google.com with SMTP id 101so10531006pld.6 for ; Tue, 27 Nov 2018 21:38:42 -0800 (PST) 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=vQPcVoGV0u9SuJTOPjajxaRuT7Da+0X49o+wYRuOFhM=; b=SbPOeqvao72aUCPdZlSLY+iRN25Mf00mRqdXuqxMmVDqJXQBf3XwKTkcoV5FdE+4co O+WcNOAHACrJHl6xk9eLmtMzT5d0A/YBsiOOuQoSp3XoI7+bwJtsbJ6tRxIEEH1Uns6L JKoWS7INtOdPL4CASpqggc1B6BBxdwYKDlurs= 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=vQPcVoGV0u9SuJTOPjajxaRuT7Da+0X49o+wYRuOFhM=; b=bSC5FJV/oDavgYiJ+wHDjvvGJIKKVUisOsp7YzWviWwxd3Xoxex7bpTI2J30U9lo0k rCPobyOMYJW0LswfM/lmzqAy6TXwkQ4X6s9dw2QHbasKn9wEVZmmsDPQSJHDNR4nf/fj gzZcXMvYrlSJbCUZSGFVYGzoNv6KzxJpU6+/crNFp1oUQX+Y8ZuvnE0jUE9+o7+MKr0F Ff8PsieOXht2JHTTCZqwUtRPU3TuWYJ/qxfjQgFa8JKOYgY2y68bqnlmaOcxtUWrZ1Cw 1GEwHttCQ+SCEreX4gojD02NKJjXBw9rS3ShXbYd3aM+hoPPZ3YI58EHXB7SBRDfWuM/ GGtA== X-Gm-Message-State: AA+aEWZisNsu7r79MicGRPoixu82xiNk9ylDnpOIzzKYEki2ZPg501/3 Ied2Msi/aWjnxYKot0R9wDkIE+bdYiU= X-Received: by 2002:a17:902:bf49:: with SMTP id u9mr35168848pls.4.1543383521392; Tue, 27 Nov 2018 21:38:41 -0800 (PST) Received: from cloudburst.twiddle.net (97-113-170-180.tukw.qwest.net. [97.113.170.180]) by smtp.gmail.com with ESMTPSA id 19sm8569336pfs.108.2018.11.27.21.38.40 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 27 Nov 2018 21:38:40 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Date: Tue, 27 Nov 2018 21:38:26 -0800 Message-Id: <20181128053834.10861-5-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20181128053834.10861-1-richard.henderson@linaro.org> References: <20181128053834.10861-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::642 Subject: [Qemu-devel] [PATCH 04/12] tcg: Add preferred_reg argument to tcg_reg_alloc_do_movi 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" Pass this through to temp_sync. Signed-off-by: Richard Henderson --- tcg/tcg.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) -- 2.17.2 diff --git a/tcg/tcg.c b/tcg/tcg.c index 509e5974bd..c83ca238aa 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -3099,7 +3099,8 @@ static void tcg_reg_alloc_bb_end(TCGContext *s, TCGRegSet allocated_regs) } static void tcg_reg_alloc_do_movi(TCGContext *s, TCGTemp *ots, - tcg_target_ulong val, TCGLifeData arg_life) + tcg_target_ulong val, TCGLifeData arg_life, + TCGRegSet preferred_regs) { if (ots->fixed_reg) { /* For fixed registers, we do not do any constant propagation. */ @@ -3115,7 +3116,7 @@ static void tcg_reg_alloc_do_movi(TCGContext *s, TCGTemp *ots, ots->val = val; ots->mem_coherent = 0; if (NEED_SYNC_ARG(0)) { - temp_sync(s, ots, s->reserved_regs, 0, IS_DEAD_ARG(0)); + temp_sync(s, ots, s->reserved_regs, preferred_regs, IS_DEAD_ARG(0)); } else if (IS_DEAD_ARG(0)) { temp_dead(s, ots); } @@ -3126,7 +3127,7 @@ static void tcg_reg_alloc_movi(TCGContext *s, const TCGOp *op) TCGTemp *ots = arg_temp(op->args[0]); tcg_target_ulong val = op->args[1]; - tcg_reg_alloc_do_movi(s, ots, val, op->life); + tcg_reg_alloc_do_movi(s, ots, val, op->life, 0); } static void tcg_reg_alloc_mov(TCGContext *s, const TCGOp *op) @@ -3150,7 +3151,7 @@ static void tcg_reg_alloc_mov(TCGContext *s, const TCGOp *op) if (IS_DEAD_ARG(1)) { temp_dead(s, ts); } - tcg_reg_alloc_do_movi(s, ots, val, arg_life); + tcg_reg_alloc_do_movi(s, ots, val, arg_life, 0); return; } From patchwork Wed Nov 28 05:38:27 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 152185 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp688392ljp; Tue, 27 Nov 2018 21:42:24 -0800 (PST) X-Google-Smtp-Source: AFSGD/UoLj0jEnxUYStmW6WQDBno/re30lz9xC3udKJfkIr8R9IjyH+GNYfLurOq3Y4EMeAlk0I+ X-Received: by 2002:a81:ae06:: with SMTP id m6mr36709053ywh.416.1543383744610; Tue, 27 Nov 2018 21:42:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543383744; cv=none; d=google.com; s=arc-20160816; b=UGUczxELWmVEwpAk3FHSS7hEuNcZXv5Swj4nO4r+ugvKusn+42YaLWDkZxSeyT/y0Q tjDQtzYIDhAmDxKKfBCIhVjzjzgsErWxrn3F7T39QF0Qbii0ryZJmK3VML1UkRTR9FH7 5Pb9wR4djxyJ1NVj0kd6ReTQBV17TjWMZmJouAFdk/OL3N8v+tbT1NSqdV9QEfHmMORU khyqTUCy+WIxZQMsA7gWaV9BoC6ih9OsXHmOQJR/JN9szyqI92U5N1gp+ZtvbhsQT5YI Ipfxgi/XZOQI3OQRrDoYgvyIrrWJ4RIYsKfqssIFEoVepzGLYjQzGB9jRAOyXTE5v/Ps nyGA== 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; bh=E+Xgls1DHstwRUyEFIzImDIJL7cTIdasMbg1UXdI6nY=; b=dBXYTfU2o+tVkFmt6rt930LwgCSOnlXFLOF+hXLcENeOyutHzgjsfgRERld1Y/YA8f e8CMMx7uQATKoIq+1vAnapm5/N5hpE8PEVFfhV1rjeFXrtijAer2R7INjU4N9y4tXyvw YT9XcIVSGq+9YEb5zK0tngH6HRe4IuEI9a2+I6eUh6JIdN1yIy/WONVshDUYg1E4qOn/ AuA0IF2LlM54ROfhD4ksX2+G3Uq7qiRvued+4cna8WDcVNF25n6BA84plqHB/V64et8a PwB7nkl1ywnS2H0B5yA49NG33LbN/jlbgln/yVaU+e2LaFfihzuUmWtIXzeTB1h9UJmL vqjw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=S8Nhrgpb; 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 c188-v6si4490073ybc.208.2018.11.27.21.42.24 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 27 Nov 2018 21:42:24 -0800 (PST) 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=S8Nhrgpb; 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]:46042 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gRscB-0006eT-UA for patch@linaro.org; Wed, 28 Nov 2018 00:42:23 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47880) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gRsYi-0003tD-GC for qemu-devel@nongnu.org; Wed, 28 Nov 2018 00:38:53 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gRsYg-0004Ln-Jb for qemu-devel@nongnu.org; Wed, 28 Nov 2018 00:38:48 -0500 Received: from mail-pf1-x444.google.com ([2607:f8b0:4864:20::444]:34139) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gRsYe-0004Js-Hy for qemu-devel@nongnu.org; Wed, 28 Nov 2018 00:38:46 -0500 Received: by mail-pf1-x444.google.com with SMTP id h3so9623490pfg.1 for ; Tue, 27 Nov 2018 21:38:43 -0800 (PST) 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=E+Xgls1DHstwRUyEFIzImDIJL7cTIdasMbg1UXdI6nY=; b=S8NhrgpbgbTZLi1NSf22G8yR3HzGanLaTfaXJLjQ1BycrkyCtc3EkPhSc42oontRs8 2sSwunqNO2FmAGAx6mnONNNIRtGu+HDlQnca07WgYm2X0aCbskFFCFzAz95OzId0KFA9 /M7H4CZ0WWVX9c6cOt8a3s/1EPAD8kd3Uwaow= 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=E+Xgls1DHstwRUyEFIzImDIJL7cTIdasMbg1UXdI6nY=; b=pwYo9+PLZYvCm5f43rHY77lx81O34G8sUKsSdI0dMFvVq3ropj6B0tA/8NKI/5bPiB O9uuz+XQ5uXuhzBOSibqbIV/tbCHkZDt42qNly/j9YDTIXM+/d3bZUD4rMtSsZQ63iSX bJV8hQi6DDcNQMYnlL2QOxUQxSyhJrsvEggs1LRWRc4DrzuaRv7z7ImaB5U+9XIC4mOQ cHmXtXDAHjcWQL0my+aQmttQ4j4rlcJZxXZXo/FQkG1rVFcMi04bnFR7bpLApWjSZ5Ad NQWDyMrV/vlb3AGeJyUONBhnB7ivsUxRvI9GI6lGdyURyan/5KtLwBnk6UaO9+RqZAi1 F6fA== X-Gm-Message-State: AA+aEWYyFhy/FaRwIgp9YyqzllUJV3NBNY/AZKg3MOWoCCgn9k4CMY/2 GNbsUr4C8rKP/ZEK2HziRFp4U7RfZ/0= X-Received: by 2002:a62:5fc4:: with SMTP id t187mr5083653pfb.66.1543383522513; Tue, 27 Nov 2018 21:38:42 -0800 (PST) Received: from cloudburst.twiddle.net (97-113-170-180.tukw.qwest.net. [97.113.170.180]) by smtp.gmail.com with ESMTPSA id 19sm8569336pfs.108.2018.11.27.21.38.41 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 27 Nov 2018 21:38:41 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Date: Tue, 27 Nov 2018 21:38:27 -0800 Message-Id: <20181128053834.10861-6-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20181128053834.10861-1-richard.henderson@linaro.org> References: <20181128053834.10861-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::444 Subject: [Qemu-devel] [PATCH 05/12] tcg: Add output_pref to 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 Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Allocate storage for, but do not yet fill in, per-opcode preferences for the output operands. Pass it in to the register allocation routines for output operands. Signed-off-by: Richard Henderson --- tcg/tcg.h | 3 +++ tcg/tcg.c | 18 +++++++++++------- 2 files changed, 14 insertions(+), 7 deletions(-) -- 2.17.2 diff --git a/tcg/tcg.h b/tcg/tcg.h index c6caeeb42b..b2e274b7af 100644 --- a/tcg/tcg.h +++ b/tcg/tcg.h @@ -621,6 +621,9 @@ typedef struct TCGOp { /* Arguments for the opcode. */ TCGArg args[MAX_OPC_PARAM]; + + /* Register preferences for the output(s). */ + TCGRegSet output_pref[2]; } TCGOp; #define TCGOP_CALLI(X) (X)->param1 diff --git a/tcg/tcg.c b/tcg/tcg.c index c83ca238aa..f86415ce29 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -2613,6 +2613,8 @@ static void liveness_pass_1(TCGContext *s) break; } op->life = arg_life; + op->output_pref[0] = 0; + op->output_pref[1] = 0; } } @@ -3127,17 +3129,18 @@ static void tcg_reg_alloc_movi(TCGContext *s, const TCGOp *op) TCGTemp *ots = arg_temp(op->args[0]); tcg_target_ulong val = op->args[1]; - tcg_reg_alloc_do_movi(s, ots, val, op->life, 0); + tcg_reg_alloc_do_movi(s, ots, val, op->life, op->output_pref[0]); } static void tcg_reg_alloc_mov(TCGContext *s, const TCGOp *op) { const TCGLifeData arg_life = op->life; - TCGRegSet allocated_regs; + TCGRegSet allocated_regs, preferred_regs; TCGTemp *ts, *ots; TCGType otype, itype; allocated_regs = s->reserved_regs; + preferred_regs = op->output_pref[0]; ots = arg_temp(op->args[0]); ts = arg_temp(op->args[1]); @@ -3151,7 +3154,7 @@ static void tcg_reg_alloc_mov(TCGContext *s, const TCGOp *op) if (IS_DEAD_ARG(1)) { temp_dead(s, ts); } - tcg_reg_alloc_do_movi(s, ots, val, arg_life, 0); + tcg_reg_alloc_do_movi(s, ots, val, arg_life, preferred_regs); return; } @@ -3160,7 +3163,8 @@ static void tcg_reg_alloc_mov(TCGContext *s, const TCGOp *op) the SOURCE value into its own register first, that way we don't have to reload SOURCE the next time it is used. */ if (ts->val_type == TEMP_VAL_MEM) { - temp_load(s, ts, tcg_target_available_regs[itype], allocated_regs, 0); + temp_load(s, ts, tcg_target_available_regs[itype], + allocated_regs, preferred_regs); } tcg_debug_assert(ts->val_type == TEMP_VAL_REG); @@ -3190,7 +3194,7 @@ static void tcg_reg_alloc_mov(TCGContext *s, const TCGOp *op) input one. */ tcg_regset_set_reg(allocated_regs, ts->reg); ots->reg = tcg_reg_alloc(s, tcg_target_available_regs[otype], - allocated_regs, 0, + allocated_regs, preferred_regs, ots->indirect_base); } tcg_out_mov(s, otype, ots->reg, ts->reg); @@ -3324,7 +3328,7 @@ static void tcg_reg_alloc_op(TCGContext *s, const TCGOp *op) } else if (arg_ct->ct & TCG_CT_NEWREG) { reg = tcg_reg_alloc(s, arg_ct->u.regs, i_allocated_regs | o_allocated_regs, - 0, ts->indirect_base); + op->output_pref[k], ts->indirect_base); } else { /* if fixed register, we try to use it */ reg = ts->reg; @@ -3333,7 +3337,7 @@ static void tcg_reg_alloc_op(TCGContext *s, const TCGOp *op) goto oarg_end; } reg = tcg_reg_alloc(s, arg_ct->u.regs, o_allocated_regs, - 0, ts->indirect_base); + op->output_pref[k], ts->indirect_base); } tcg_regset_set_reg(o_allocated_regs, reg); /* if a fixed register is used, then a move will be done afterwards */ From patchwork Wed Nov 28 05:38:28 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 152188 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp690131ljp; Tue, 27 Nov 2018 21:44:58 -0800 (PST) X-Google-Smtp-Source: AFSGD/WerYlP+iL9sCP4JCV8MH3o++9xKm89Iq1Lpjl97lOh4g0CHZrxIjr4OxXSBZdVBRlZXkxP X-Received: by 2002:a0d:ea8e:: with SMTP id t136mr33856053ywe.376.1543383898577; Tue, 27 Nov 2018 21:44:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543383898; cv=none; d=google.com; s=arc-20160816; b=SJrJf9SZzgBcSJPXK7WBYzOyvGO6Gs+T43LSXHLSDgebn6EOg29AARuKu8xPoi7HVS xkwUiWEXhBcKDNkB9P9pEKoimf7t6NnNRJrlFQqLZlb92AfVULQYo18T3Viufjip+RHd h31uKgTC6+LcCxdp3I4zJ+DRQztOMHcvXrlZkdcMPQ7S83jfvfJflj4cgGCCpCS/nmh3 3C0sjWUeyciOrY0XEwNQ9gv2j53kddh3d63FwN+nifLDn1+ADMN4xdt1YvoVfkVAYewy RUkw6SiVYOvwif8Lgdn8QAFieL0+JAk/QDuZ3qNXHWqlejxzljU2a7CoalQiFmX3V1J8 witg== 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; bh=IP0lLIkXSgPKwsDsoLUp8fVauLPqwdeD0c88AkY4Qpw=; b=a9qFsbBRQkrupV3fFf8JCw9DhktG/JNPcr2NCR6Ojcdjp4wtrHy+oaTpkb3Owz+89A XGVTyuWXrnUET5Jbho9DzlWLbqHHR3Cii5Fgu+ADxS581i6qoJZejz1SjMJNFooNkPtJ mSgYi64Q4gimE8HxYIvzrj3ZwKSAVXmoqrDoZQxma0iGJM9fqgrYUhRgUN5GjDsI4Y9i TB9WRwSHG7K1V+LGQ9EbBFVq//eHYlnzWLrt7gJmwzxPEv6BuHBceHCfZxybIeDDmoCa +V2C449sxnpPLOa2vF5pMSqyd7S467ZvtIfBQpC5FF+lHw5vid6VESa4Rdz16tejzVfR 1Yew== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="ji/hY/kO"; 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 x131si4184527ywd.27.2018.11.27.21.44.58 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 27 Nov 2018 21:44:58 -0800 (PST) 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="ji/hY/kO"; 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]:46055 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gRsef-0001iN-Q9 for patch@linaro.org; Wed, 28 Nov 2018 00:44:57 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47984) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gRsYl-000414-RY for qemu-devel@nongnu.org; Wed, 28 Nov 2018 00:38:53 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gRsYi-0004Mh-ID for qemu-devel@nongnu.org; Wed, 28 Nov 2018 00:38:51 -0500 Received: from mail-pf1-x441.google.com ([2607:f8b0:4864:20::441]:39467) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gRsYg-0004Ka-HA for qemu-devel@nongnu.org; Wed, 28 Nov 2018 00:38:48 -0500 Received: by mail-pf1-x441.google.com with SMTP id c72so9608847pfc.6 for ; Tue, 27 Nov 2018 21:38:44 -0800 (PST) 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=IP0lLIkXSgPKwsDsoLUp8fVauLPqwdeD0c88AkY4Qpw=; b=ji/hY/kOjrrTE8vBuCS3aTph+n89QXAdvHZzkCdK5zv0vVA8E79VXk1UaCNjWcJTrs 47vJnjv+OPXIEBAY9/sK5NHX+0JwL6B88wUH/t38G/GJUG9P1a+L8svl33ljZdy7ZbCZ 0T1Y96ZxeXeaX58tPrQg+YRq+aP1LEvpSUbw4= 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=IP0lLIkXSgPKwsDsoLUp8fVauLPqwdeD0c88AkY4Qpw=; b=rwI0PhoS6q4MJNIPJ1keFBSnLD5GlRGCKy1kkvmZ/TRG7Tv/cIthGD5/dWe0kTlGgM WXAKn4YrQD5XmuigT3h4fpcJWUaNKPcUIST3Iq/4sEVVi5gqBgDGGr1wwe6T/jtYHNQE NtZZBqTDYK/0GnWzYBLS103afFxnDISJ51iZMgE7MCkXN3g82BM7HT1De+uKQW8jh9ba 31Nd3c02zAnjSaAfRV7qBxIosXzjoquzyMVjxmE0PqPdx2t7NBBXWKw/kf2uT78EbLDM aLTs9rS5HUnzP3VUbvE4RQtSiTRJ2GC3Qt2BaRpzkHuV6HwIvv9bQB+jbx0ksyV8M82a R//Q== X-Gm-Message-State: AA+aEWYs8csB7a1qGFp3f4kw8yN2X174mhwsYlVHuWXdSPMBZLb8V/v8 iwqkzqdfLgDamG5RE+yS7iDPXemdKB4= X-Received: by 2002:a63:88c7:: with SMTP id l190mr31308104pgd.110.1543383523760; Tue, 27 Nov 2018 21:38:43 -0800 (PST) Received: from cloudburst.twiddle.net (97-113-170-180.tukw.qwest.net. [97.113.170.180]) by smtp.gmail.com with ESMTPSA id 19sm8569336pfs.108.2018.11.27.21.38.42 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 27 Nov 2018 21:38:42 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Date: Tue, 27 Nov 2018 21:38:28 -0800 Message-Id: <20181128053834.10861-7-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20181128053834.10861-1-richard.henderson@linaro.org> References: <20181128053834.10861-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::441 Subject: [Qemu-devel] [PATCH 06/12] tcg: Improve register allocation for matching constraints 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" Try harder to honor the output_pref. When we're forced to allocate a second register for the input, it does not need to use the input constraint; that will be honored by the register we allocate for the output and a move is already required. Signed-off-by: Richard Henderson --- tcg/tcg.c | 36 ++++++++++++++++++++++++------------ 1 file changed, 24 insertions(+), 12 deletions(-) -- 2.17.2 diff --git a/tcg/tcg.c b/tcg/tcg.c index f86415ce29..adf6570c36 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -3235,6 +3235,8 @@ static void tcg_reg_alloc_op(TCGContext *s, const TCGOp *op) /* satisfy input constraints */ for (k = 0; k < nb_iargs; k++) { + TCGRegSet i_preferred_regs, o_preferred_regs; + i = def->sorted_args[nb_oargs + k]; arg = op->args[i]; arg_ct = &def->args_ct[i]; @@ -3245,17 +3247,18 @@ static void tcg_reg_alloc_op(TCGContext *s, const TCGOp *op) /* constant is OK for instruction */ const_args[i] = 1; new_args[i] = ts->val; - goto iarg_end; + continue; } - temp_load(s, ts, arg_ct->u.regs, i_allocated_regs, 0); - + i_preferred_regs = o_preferred_regs = 0; if (arg_ct->ct & TCG_CT_IALIAS) { + o_preferred_regs = op->output_pref[arg_ct->alias_index]; if (ts->fixed_reg) { /* if fixed register, we must allocate a new register if the alias is not the same register */ - if (arg != op->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 not dead after the instruction, we must allocate @@ -3263,33 +3266,42 @@ static void tcg_reg_alloc_op(TCGContext *s, const TCGOp *op) if (!IS_DEAD_ARG(i)) { goto allocate_in_reg; } + /* check if the current register has already been allocated for another input aliased to an output */ - int k2, i2; - for (k2 = 0 ; k2 < k ; k2++) { - i2 = def->sorted_args[nb_oargs + k2]; - if ((def->args_ct[i2].ct & TCG_CT_IALIAS) && - (new_args[i2] == ts->reg)) { - goto allocate_in_reg; + if (ts->val_type == TEMP_VAL_REG) { + int k2, i2; + reg = ts->reg; + for (k2 = 0 ; k2 < k ; k2++) { + i2 = def->sorted_args[nb_oargs + k2]; + if ((def->args_ct[i2].ct & TCG_CT_IALIAS) && + reg == new_args[i2]) { + goto allocate_in_reg; + } } } + i_preferred_regs = o_preferred_regs; } } + + temp_load(s, ts, arg_ct->u.regs, i_allocated_regs, i_preferred_regs); reg = ts->reg; + if (tcg_regset_test_reg(arg_ct->u.regs, reg)) { /* nothing to do : the constraint is satisfied */ } else { allocate_in_reg: /* allocate a new register matching the constraint and move the temporary register into it */ + temp_load(s, ts, tcg_target_available_regs[ts->type], + i_allocated_regs, 0); reg = tcg_reg_alloc(s, arg_ct->u.regs, i_allocated_regs, - 0, ts->indirect_base); + o_preferred_regs, ts->indirect_base); tcg_out_mov(s, ts->type, reg, ts->reg); } new_args[i] = reg; const_args[i] = 0; tcg_regset_set_reg(i_allocated_regs, reg); - iarg_end: ; } /* mark dead temporaries and free the associated registers */ From patchwork Wed Nov 28 05:38:29 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 152193 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp693965ljp; Tue, 27 Nov 2018 21:50:46 -0800 (PST) X-Google-Smtp-Source: AFSGD/XR7tttr4ZwEiacKaz6ZCH9FR046Gqwl8PopnhKzxVLgIVsAoA/Argd+//5ur83zkzoQogy X-Received: by 2002:a81:8d51:: with SMTP id w17mr32104699ywj.104.1543384246085; Tue, 27 Nov 2018 21:50:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543384246; cv=none; d=google.com; s=arc-20160816; b=AUvoBhjmFlFgFYtkf8ork6qcoHTRurNymtT6OdwNeQuRL8xK/l+UHPI5IKsMDUM9LU yER/lVMkRrzR4G+pN/D7trTq68or+pP8P5PWR7ZrWL1ADqzNzY0N7vOE1lmvJ7c5F6ee nU9RW0qvOJvuh8tM/+mHJyHrDVadL3ouZ1rR9Z55AQk3SV38iFR+SGIi4fZLyMu5U4GO u8xdPjkdOE2RDiqnMl1DyH+Wc2MH5DVQ65dbKQvsMImKaGkGvVbnS4Z8fLeTh6AFVstf F/LT0boicTTugxzKiWDEmf62aeNMJm0WD1kd7u9vjS9wcI4FkKzSPdoiwjqBXZh1hy+R KVPw== 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; bh=9Nkiz5fyuMiuIUbBYyWxbD6vyp9rjrtKS8bXxw2aqDU=; b=sPg4+fg5dyvjqafbb76XqK4J58HsCHN7CUc7fcr8og9ttU4s0s0MA1+WwtsFzreOzu zWMooFrZMtqkRJOOaVUAFGLgxVWZaBOQy25NnlkSexZpIfdKNyPkIOgLNRzJ9B2/s4GH 9eoxeZiS0BppVwoInDK42sgqT2m9+ijNwOgcKtNpAKgyadOikycif4LvuSVxRbd7iAcQ flaUGKq4GlUri5vh6DeNXWm7/4xvrniZqvlj9/TBtjUM8aqKcTCnESgu88KATEDr8+8C MnE6Ek1qgcEGgT8Jf59PM+vGiYOnbOaHx8qXkxIeomRIz/cJumqlzCDHIpfQdP9ErLJW RoIA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=aWkLvOE9; 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 k9si5007009ywh.263.2018.11.27.21.50.45 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 27 Nov 2018 21:50:46 -0800 (PST) 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=aWkLvOE9; 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]:46088 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gRskH-0006Xb-Hq for patch@linaro.org; Wed, 28 Nov 2018 00:50:45 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47987) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gRsYl-000417-Rk for qemu-devel@nongnu.org; Wed, 28 Nov 2018 00:38:53 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gRsYi-0004MV-Ho for qemu-devel@nongnu.org; Wed, 28 Nov 2018 00:38:51 -0500 Received: from mail-pf1-x436.google.com ([2607:f8b0:4864:20::436]:44339) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gRsYg-0004Ku-GE for qemu-devel@nongnu.org; Wed, 28 Nov 2018 00:38:48 -0500 Received: by mail-pf1-x436.google.com with SMTP id u6so9604940pfh.11 for ; Tue, 27 Nov 2018 21:38:46 -0800 (PST) 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=9Nkiz5fyuMiuIUbBYyWxbD6vyp9rjrtKS8bXxw2aqDU=; b=aWkLvOE9ff6PqWicV/DFhaEzMfuwCsFWojA7kPo0Um63j4ki7snNW8ybEPrTE1DnTA ycas+f/eviIJfMXTdy2DnHZF8JHozbseQhdIDljzNKpSrAZZIc4Jmg+UiWjiKLW8hybo 0WrC0mkRiTxQEmpNIuwnThJgwSRSsLPT4r/SI= 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=9Nkiz5fyuMiuIUbBYyWxbD6vyp9rjrtKS8bXxw2aqDU=; b=q24WOsJFomFn/qqkXh/SkEBtqPg9E01LBbD2Bt2djqNgiPYCeGR8Xx99PGZbbROP7a fMLujQ1XqEqRpa0xIwCceht1ZXS76oBH8LZ/iwkShh+etJ1XnAYl+0p5gfR2qPxG7uOn d9xiO+K9r9BmpoZmLiqF2EIIsGiAifEPAQv70FBG59liYJ/ca/R8OfE3K+n/lfXRi561 HtWNH6xa30b4O46170Nf2zs0BzZ6mivV8SELYoca7YG4DzVhLAwxFXrgOfCSCI+udyPd dYXnq5ggXSrtcTHHc6EcFzOrwl/HPime1xSufP1PWTVeuHU7uQ0bF++qqh7reM58bhAK CEYQ== X-Gm-Message-State: AA+aEWaHa/Esr2XiylHGyJ4ElDOFBQW0uKSEwMBE2tp+bOTZovH/O2xX OJqBJP8xKuLVyCg4n7lGRxvDh9prKNM= X-Received: by 2002:a63:f141:: with SMTP id o1mr32379516pgk.134.1543383524930; Tue, 27 Nov 2018 21:38:44 -0800 (PST) Received: from cloudburst.twiddle.net (97-113-170-180.tukw.qwest.net. [97.113.170.180]) by smtp.gmail.com with ESMTPSA id 19sm8569336pfs.108.2018.11.27.21.38.43 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 27 Nov 2018 21:38:44 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Date: Tue, 27 Nov 2018 21:38:29 -0800 Message-Id: <20181128053834.10861-8-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20181128053834.10861-1-richard.henderson@linaro.org> References: <20181128053834.10861-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::436 Subject: [Qemu-devel] [PATCH 07/12] tcg: Dump register preference info with 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 Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Richard Henderson --- tcg/tcg.h | 3 --- tcg/tcg.c | 44 +++++++++++++++++++++++++++++++++++++------- 2 files changed, 37 insertions(+), 10 deletions(-) -- 2.17.2 diff --git a/tcg/tcg.h b/tcg/tcg.h index b2e274b7af..ac5d01c223 100644 --- a/tcg/tcg.h +++ b/tcg/tcg.h @@ -1089,9 +1089,6 @@ TCGOp *tcg_op_insert_after(TCGContext *s, TCGOp *op, TCGOpcode opc, int narg); void tcg_optimize(TCGContext *s); -/* only used for debugging purposes */ -void tcg_dump_ops(TCGContext *s); - TCGv_i32 tcg_const_i32(int32_t val); TCGv_i64 tcg_const_i64(int64_t val); TCGv_i32 tcg_const_local_i32(int32_t val); diff --git a/tcg/tcg.c b/tcg/tcg.c index adf6570c36..27d081e11a 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -1921,7 +1921,7 @@ static inline TCGReg tcg_regset_first(TCGRegSet d) } } -void tcg_dump_ops(TCGContext *s) +static void tcg_dump_ops(TCGContext *s, bool have_prefs) { char buf[128]; TCGOp *op; @@ -2056,12 +2056,15 @@ void tcg_dump_ops(TCGContext *s) col += qemu_log("%s$0x%" TCG_PRIlx, k ? "," : "", op->args[k]); } } - if (op->life) { - unsigned life = op->life; - for (; col < 48; ++col) { + if (have_prefs || op->life) { + for (; col < 40; ++col) { putc(' ', qemu_logfile); } + } + + if (op->life) { + unsigned life = op->life; if (life & (SYNC_ARG * 3)) { qemu_log(" sync:"); @@ -2081,6 +2084,33 @@ void tcg_dump_ops(TCGContext *s) } } } + + if (have_prefs) { + for (i = 0; i < nb_oargs; ++i) { + TCGRegSet set = op->output_pref[i]; + + if (i == 0) { + qemu_log(" pref="); + } else { + qemu_log(","); + } + if (set == 0) { + qemu_log("none"); + } else if (set == MAKE_64BIT_MASK(0, TCG_TARGET_NB_REGS)) { + qemu_log("all"); +#ifdef CONFIG_DEBUG_TCG + } else if (tcg_regset_single(set)) { + TCGReg reg = tcg_regset_first(set); + qemu_log("%s", tcg_target_reg_names[reg]); +#endif + } else if (TCG_TARGET_NB_REGS <= 32) { + qemu_log("%#x", (uint32_t)set); + } else { + qemu_log("%#" PRIx64, (uint64_t)set); + } + } + } + qemu_log("\n"); } } @@ -3669,7 +3699,7 @@ int tcg_gen_code(TCGContext *s, TranslationBlock *tb) && qemu_log_in_addr_range(tb->pc))) { qemu_log_lock(); qemu_log("OP:\n"); - tcg_dump_ops(s); + tcg_dump_ops(s, false); qemu_log("\n"); qemu_log_unlock(); } @@ -3697,7 +3727,7 @@ int tcg_gen_code(TCGContext *s, TranslationBlock *tb) && qemu_log_in_addr_range(tb->pc))) { qemu_log_lock(); qemu_log("OP before indirect lowering:\n"); - tcg_dump_ops(s); + tcg_dump_ops(s, false); qemu_log("\n"); qemu_log_unlock(); } @@ -3718,7 +3748,7 @@ int tcg_gen_code(TCGContext *s, TranslationBlock *tb) && qemu_log_in_addr_range(tb->pc))) { qemu_log_lock(); qemu_log("OP after optimization and liveness analysis:\n"); - tcg_dump_ops(s); + tcg_dump_ops(s, true); qemu_log("\n"); qemu_log_unlock(); } From patchwork Wed Nov 28 05:38:30 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 152190 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp692337ljp; Tue, 27 Nov 2018 21:48:12 -0800 (PST) X-Google-Smtp-Source: AJdET5dEvMjKtXTgN4C8fbOgYIbudKx4F9mzTQw3AWjdi1Ez3mfQFQ6JKlpYCjKdZB1xyvKzIGxZ X-Received: by 2002:a81:b623:: with SMTP id u35mr37382849ywh.177.1543384092408; Tue, 27 Nov 2018 21:48:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543384092; cv=none; d=google.com; s=arc-20160816; b=XNNafkD5g4YUg9/0Te9rBIgAiySxhxyHvANhAAoNG1E8gSG67UpONz9EJDHURZG6h6 nxerED0xjORIJlrLLfG/fBhEORfDT1K5jH7F7sJZdq45FHauxY5EcEbREiH5TNYM9Kbp VgmqbU3RC0Vu82dtU+Lf4EBFT7f5zggmt0CgD0jVLhkt+B5KfekvLkEgAxWVTsslFLQm ZQyUxcuqI69p3kEYA3Tqrb74IMn6r8wY9OKQjt9uI2XCQnuYjvE0oejrw6sxlNaRNfIa LRucrKtA4okB8V4L0NJpQ83olje+/v0lsZxcVumX04qEh4GHoBlJVObSDQLSrI08egJ1 221w== 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; bh=MI9Pri5ZPTaghx1rn22lpK9ksOlRXxZIuJM3sUOWfKI=; b=OXvqIxjqRnr+djp9NrbbW09qFKUbno7ZZSRA4L2aT0BFaWunH/VjL5aCLL/577V0pa pNoLbvq8hh8BS89NYqKAOZ8xaZGQuT4vtgoiDgp8n4eprZy91bbPztnMRI+RAoG7LY4Z QhOZ0BP8/fAV7i8B2nSXUuYecQ+SHtpnF/ujn9NuK6+/KjJHfB8LhPzUsEd8gAik/yvZ 84DNYrPFNQA4JSmBMkXN9diLfnjcW7ISYwNYwRKgQAAqaadnI3jX138PPB7h5RhK0VnR QrtHz63hPpU15DF75xcXjpGZWtHblVwJ2FC8A2b77N36lbw5C3JJ58yKZdW5pPF/yi8f zlgA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=keiU5G5A; 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 1si4232617ywx.421.2018.11.27.21.48.12 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 27 Nov 2018 21:48:12 -0800 (PST) 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=keiU5G5A; 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]:46075 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gRshn-0005HC-PZ for patch@linaro.org; Wed, 28 Nov 2018 00:48:11 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47986) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gRsYl-000416-Rb for qemu-devel@nongnu.org; Wed, 28 Nov 2018 00:38:53 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gRsYi-0004Mt-OD for qemu-devel@nongnu.org; Wed, 28 Nov 2018 00:38:51 -0500 Received: from mail-pg1-x543.google.com ([2607:f8b0:4864:20::543]:43688) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gRsYi-0004Lv-G2 for qemu-devel@nongnu.org; Wed, 28 Nov 2018 00:38:48 -0500 Received: by mail-pg1-x543.google.com with SMTP id v28so8963261pgk.10 for ; Tue, 27 Nov 2018 21:38:47 -0800 (PST) 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=MI9Pri5ZPTaghx1rn22lpK9ksOlRXxZIuJM3sUOWfKI=; b=keiU5G5AWLBNJsAwJvbIpRByjlfowPetTs+ewYyzxjbK9iH1rfWTe2Og76O7h6Tc2b kMN2NGNI2gBpZbD1uMEi5zI/XkBtmw1ZDegZfJQy1wPH0otczncGvuuTT9glIHxTlHrT md30iNQCrRmgKd4pgFby1I5jtAFId62l8V2fQ= 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=MI9Pri5ZPTaghx1rn22lpK9ksOlRXxZIuJM3sUOWfKI=; b=nlGAR2xQ3wqBW6lvpLvEluZLrfOb9nExMjmVuU8nmIw1s+hpFEutYrCTbq18IF4JJM ilIy4Wz0QmXeVC382K4rFUNDlFt1MWoVha+7cZI3SDLLjfN/afvk9rOpfhwk/OpQ4QLR 8/Sit3G947QMC61jKGEp2FvTo0dVRFNQtDxW0VhVGZYfSJrJxUqq25e+iUDvVt3ahE0V hFqytBIF4Kvxb6qtCaDAmcXv90b1w8mRs+RmGTg3hRUMy+lJ7v047ncsCRA4ebxJQzz9 USAauQzmd2yXai4qFlturG3vu0zfaeTj3F57qpXZrMpdTIUs73mvEdtbXnbSCTv3PcOC NJcw== X-Gm-Message-State: AA+aEWYvLEjPxuZ4Mo1JanJkm41/v8Pcpi10tzZ/tnvrQ9+BlCDmMxpv RK+d/S7QgAMtj3GoiIb2J2ieqbOTAL4= X-Received: by 2002:a63:ff62:: with SMTP id s34mr32136752pgk.325.1543383526142; Tue, 27 Nov 2018 21:38:46 -0800 (PST) Received: from cloudburst.twiddle.net (97-113-170-180.tukw.qwest.net. [97.113.170.180]) by smtp.gmail.com with ESMTPSA id 19sm8569336pfs.108.2018.11.27.21.38.45 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 27 Nov 2018 21:38:45 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Date: Tue, 27 Nov 2018 21:38:30 -0800 Message-Id: <20181128053834.10861-9-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20181128053834.10861-1-richard.henderson@linaro.org> References: <20181128053834.10861-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::543 Subject: [Qemu-devel] [PATCH 08/12] tcg: Reindent parts of liveness_pass_1 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" There are two blocks of the form if (foo) { stuff1; goto bar; } else { baz: stuff2; } which have unnecessary and confusing indentation. Remove the else and unindent stuff2. Signed-off-by: Richard Henderson --- tcg/tcg.c | 139 ++++++++++++++++++++++++++++-------------------------- 1 file changed, 71 insertions(+), 68 deletions(-) -- 2.17.2 diff --git a/tcg/tcg.c b/tcg/tcg.c index 27d081e11a..82f9a66d31 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -2458,47 +2458,46 @@ static void liveness_pass_1(TCGContext *s) } } goto do_remove; - } else { - do_not_remove_call: + } + do_not_remove_call: - /* output args are dead */ - for (i = 0; i < nb_oargs; i++) { - arg_ts = arg_temp(op->args[i]); - if (arg_ts->state & TS_DEAD) { - arg_life |= DEAD_ARG << i; - } - if (arg_ts->state & TS_MEM) { - arg_life |= SYNC_ARG << i; - } - arg_ts->state = TS_DEAD; + /* output args are dead */ + for (i = 0; i < nb_oargs; i++) { + arg_ts = arg_temp(op->args[i]); + if (arg_ts->state & TS_DEAD) { + arg_life |= DEAD_ARG << i; } + if (arg_ts->state & TS_MEM) { + arg_life |= SYNC_ARG << i; + } + arg_ts->state = TS_DEAD; + } - if (!(call_flags & (TCG_CALL_NO_WRITE_GLOBALS | - TCG_CALL_NO_READ_GLOBALS))) { - /* globals should go back to memory */ - 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++) { - s->temps[i].state |= TS_MEM; - } + if (!(call_flags & (TCG_CALL_NO_WRITE_GLOBALS | + TCG_CALL_NO_READ_GLOBALS))) { + /* globals should go back to memory */ + 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++) { + s->temps[i].state |= TS_MEM; + } + } - /* record arguments that die in this helper */ - for (i = nb_oargs; i < nb_iargs + nb_oargs; i++) { - arg_ts = arg_temp(op->args[i]); - if (arg_ts && arg_ts->state & TS_DEAD) { - arg_life |= DEAD_ARG << i; - } + /* record arguments that die in this helper */ + for (i = nb_oargs; i < nb_iargs + nb_oargs; 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_ts = arg_temp(op->args[i]); - if (arg_ts) { - arg_ts->state &= ~TS_DEAD; - } + } + /* input arguments are live for preceding opcodes */ + for (i = nb_oargs; i < nb_iargs + nb_oargs; i++) { + arg_ts = arg_temp(op->args[i]); + if (arg_ts) { + arg_ts->state &= ~TS_DEAD; } } } @@ -2602,43 +2601,47 @@ static void liveness_pass_1(TCGContext *s) goto do_not_remove; } } - do_remove: - tcg_op_remove(s, op); - } else { - do_not_remove: - /* output args are dead */ - for (i = 0; i < nb_oargs; i++) { - arg_ts = arg_temp(op->args[i]); - if (arg_ts->state & TS_DEAD) { - arg_life |= DEAD_ARG << i; - } - if (arg_ts->state & TS_MEM) { - arg_life |= SYNC_ARG << i; - } - arg_ts->state = TS_DEAD; - } + goto do_remove; + } + goto do_not_remove; - /* if end of basic block, update */ - if (def->flags & TCG_OPF_BB_END) { - 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++) { - s->temps[i].state |= TS_MEM; - } - } + do_remove: + tcg_op_remove(s, op); + break; - /* record arguments that die in this opcode */ - for (i = nb_oargs; i < nb_oargs + nb_iargs; i++) { - arg_ts = arg_temp(op->args[i]); - if (arg_ts->state & TS_DEAD) { - arg_life |= DEAD_ARG << i; - } + do_not_remove: + /* output args are dead */ + for (i = 0; i < nb_oargs; i++) { + 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++) { - arg_temp(op->args[i])->state &= ~TS_DEAD; + if (arg_ts->state & TS_MEM) { + arg_life |= SYNC_ARG << i; } + arg_ts->state = TS_DEAD; + } + + /* if end of basic block, update */ + if (def->flags & TCG_OPF_BB_END) { + 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++) { + s->temps[i].state |= TS_MEM; + } + } + + /* record arguments that die in this opcode */ + for (i = nb_oargs; i < nb_oargs + nb_iargs; i++) { + 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++) { + arg_temp(op->args[i])->state &= ~TS_DEAD; } break; } From patchwork Wed Nov 28 05:38:31 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 152191 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp692475ljp; Tue, 27 Nov 2018 21:48:23 -0800 (PST) X-Google-Smtp-Source: AJdET5fyMueCdkWoGZm6M3S13jPktQWgX8CYRIZDeqIFklAVx82omXHdkr/Ksf2vkuwaw6UW+WhC X-Received: by 2002:a81:9ad5:: with SMTP id r204mr36636599ywg.215.1543384103691; Tue, 27 Nov 2018 21:48:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543384103; cv=none; d=google.com; s=arc-20160816; b=Ih7a7RQubva+5FvDyyObZNfWZ/EyKV+daQ3QLBnteo2hihU7rErdphDXkGApKH7jaN eedJ5mdPbOVZn4NotEzyJEc/EysPrkQ5Om3n0XXQWFeaUXLvDmU1zNPxTzuodn8Yr7/n Y6Ua7fc23yGTJA5Qy5fdk1Ts/TbLhJSJwJYwiK5xOUmmrQU8VKajRcA6hdYHQbOoNhPY y1IXC3zU4s1sC7SwuGrjfn6CzchHEZQjkE8C6pkIwRPcsosBtJAEDptaHC9HQYWRg7nN nwM0C90wyb67AoNV9nleVaAaQndidn5wbotngrTT/spGa2+jtqqspAa0QvzxhQu5KM0O h9+A== 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; bh=l5Q1tbJR9WcMsBqUTZQX9ofdmMJFwTlSDLTXSU4uz0U=; b=AETf0MpZO26PgzeBxib9R2+ZTl8V71a1+1mmzFX7fMaDaexkxz8FC6gWyrnK8Wx+Zd 0CTz3/IlHV575SnpODB8KzfcZ0x1PmOVjkirgAnMt8RtU9t0f/s2R94xKGyErCh/6bs+ COjsXepIc3jdtvJaOUBKr1fmOVzzYp21QaYh7ImE9afINmQ/mrQGhZpUj5XGYvVH0//Q s0k/xEQD6ZtORtupfGGT65tQu+rvx+W03/Buo0Ls+4hqeERz6PsD36vUta9Le+8d9nmF aNKj0EDnwwMqPbJ+CZFFwHNNcTjIyOjdZXdZlYhsrYyJ1AqAzSTsb1b8Jqd1rHAl7uoV pN7Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=gGrebFdU; 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 185si2838269ywa.37.2018.11.27.21.48.23 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 27 Nov 2018 21:48:23 -0800 (PST) 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=gGrebFdU; 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]:46077 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gRshz-0005PA-0v for patch@linaro.org; Wed, 28 Nov 2018 00:48:23 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47985) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gRsYl-000415-RZ for qemu-devel@nongnu.org; Wed, 28 Nov 2018 00:38:53 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gRsYi-0004N5-T8 for qemu-devel@nongnu.org; Wed, 28 Nov 2018 00:38:51 -0500 Received: from mail-pl1-x643.google.com ([2607:f8b0:4864:20::643]:34803) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gRsYi-0004MH-N2 for qemu-devel@nongnu.org; Wed, 28 Nov 2018 00:38:48 -0500 Received: by mail-pl1-x643.google.com with SMTP id f12-v6so16824726plo.1 for ; Tue, 27 Nov 2018 21:38:48 -0800 (PST) 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=l5Q1tbJR9WcMsBqUTZQX9ofdmMJFwTlSDLTXSU4uz0U=; b=gGrebFdUGIeqKB+0INeGeoxsV5xwHFuYasUKX3bg1caBu+KA51O8ki8wUonqKMyeFS 6uD5zq8VGCIFunAarKAlM7/JfNhPE/n3n3huFR6XH1weu2+/eMxQmB8guJxm2t9LLQKS yMq8U05rzo29gxV73zQ83R5XWyuidj1vmeZz8= 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=l5Q1tbJR9WcMsBqUTZQX9ofdmMJFwTlSDLTXSU4uz0U=; b=d3+ivxTVWBo0qWhKiLs+0jDP+Uw88pHQEx6LYeQ0Ddqtk1HmhNtS+wkvqWeAOYmhaw LYOpfv+p1zE262qCF6TL38UAzirzR+CSV70xzX1CsAIpWDFZ1DDflWP0ibTi5MeJ/4GP cHwhqrMBf34BWVfMJA0X+n8S0Z4G4H1KFx3nTs6cU6ChROOUgXESneyRCF5TKE2tZa2/ UA0vqjEaPgnniBhK/BsFx3OhzBLy6x355swBdmPRHdGDcdvI4+ydIoG4l1aOWx3MOZPG RMQ0XCpxg0060iMS3sh6lb//vRgupLESfe7z+WPhmwmuN5C+5lEgr+eUoOEZw6Y9sVJJ PWzg== X-Gm-Message-State: AA+aEWZprC8SJ0bpVFcHKM/Qw3IWokfVLB9DVkqp2eW7bMftvEeQAcIt xvjYYudqda7lokE4HDh2eSIREqQlle4= X-Received: by 2002:a17:902:f082:: with SMTP id go2mr35602521plb.115.1543383527408; Tue, 27 Nov 2018 21:38:47 -0800 (PST) Received: from cloudburst.twiddle.net (97-113-170-180.tukw.qwest.net. [97.113.170.180]) by smtp.gmail.com with ESMTPSA id 19sm8569336pfs.108.2018.11.27.21.38.46 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 27 Nov 2018 21:38:46 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Date: Tue, 27 Nov 2018 21:38:31 -0800 Message-Id: <20181128053834.10861-10-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20181128053834.10861-1-richard.henderson@linaro.org> References: <20181128053834.10861-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::643 Subject: [Qemu-devel] [PATCH 09/12] tcg: Rename and adjust liveness_pass_1 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" No need for a "tcg_" prefix for a static function; we already have another "la_" prefix for indicating liveness analysis. Pass in nb_globals and nb_temps, as we will already have them in registers for other loops within the parent function. Signed-off-by: Richard Henderson --- tcg/tcg.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) -- 2.17.2 diff --git a/tcg/tcg.c b/tcg/tcg.c index 82f9a66d31..27814df882 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -2389,10 +2389,8 @@ static void reachable_code_pass(TCGContext *s) /* liveness analysis: end of function: all temps are dead, and globals should be in memory. */ -static void tcg_la_func_end(TCGContext *s) +static void la_func_end(TCGContext *s, int ng, int nt) { - int ng = s->nb_globals; - int nt = s->nb_temps; int i; for (i = 0; i < ng; ++i) { @@ -2405,10 +2403,8 @@ static void tcg_la_func_end(TCGContext *s) /* liveness analysis: end of basic block: all temps are dead, globals and local temps should be in memory. */ -static void tcg_la_bb_end(TCGContext *s) +static void la_bb_end(TCGContext *s, int ng, int nt) { - int ng = s->nb_globals; - int nt = s->nb_temps; int i; for (i = 0; i < ng; ++i) { @@ -2427,9 +2423,10 @@ static void tcg_la_bb_end(TCGContext *s) static void liveness_pass_1(TCGContext *s) { int nb_globals = s->nb_globals; + int nb_temps = s->nb_temps; TCGOp *op, *op_prev; - tcg_la_func_end(s); + la_func_end(s, nb_globals, nb_temps); QTAILQ_FOREACH_REVERSE_SAFE(op, &s->ops, TCGOpHead, link, op_prev) { int i, nb_iargs, nb_oargs; @@ -2624,7 +2621,7 @@ static void liveness_pass_1(TCGContext *s) /* if end of basic block, update */ if (def->flags & TCG_OPF_BB_END) { - tcg_la_bb_end(s); + la_bb_end(s, nb_globals, nb_temps); } else if (def->flags & TCG_OPF_SIDE_EFFECTS) { /* globals should be synced to memory */ for (i = 0; i < nb_globals; i++) { From patchwork Wed Nov 28 05:38:32 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 152192 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp692694ljp; Tue, 27 Nov 2018 21:48:44 -0800 (PST) X-Google-Smtp-Source: AFSGD/XltBrzNgzAdpTftkayROCK1V8hEWRHUHpqiy3mp3i07eAtlexVTQx78iPCK+U57048Vl/h X-Received: by 2002:a25:198a:: with SMTP id 132-v6mr35323399ybz.22.1543384124379; Tue, 27 Nov 2018 21:48:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543384124; cv=none; d=google.com; s=arc-20160816; b=PR0hOADeggnEUubnPYtgRjK/hM/JGQzDuv2F6w6N8umqnVB0aqPGlPFZPJaQ8G+uaT we9CDEieDWKqKKOR0S55B/WEl0UBc+CXFqSyHvntcWokh9UcsprBvdq8D6GHSa1zNT4x KlA5nUfHDgOU2YukM+i4wdXZuVsqyLsO8KAFheSvew8eEzpFHw6EGAQ/rAZ8zzgH6bbe xFWJzJa2A8pKSZhrN+s/rVOhPDS6tmRGzALmldioQ4VSoSajsBwxRuOjHT7r8PkWtpAU utFGv+F8jc20hX0y2kJAs9U8oivlPnF5BdZH4lPXHRTxlIC4CprQakzEnUtx1UQMkfpv 88SA== 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; bh=RayPqtg1GIUBRZB3Wq/kgllr6OtflLAyLXeqe+v2dG4=; b=xu/yX5LN8OM8CX2jeKh2uQ+t2lujxmDzyqdVuVBrfuhOD3M76wjsPLqTgk3PZXcLho GEUJ1o3HUFOiArB7KgX6IMVyzo0DNR8OtsnBgUeZyxaFORHYbfUz4Nq/G2oyoiHgUEXO P8btknKzCzrmGEpPHcHZm0q0py0RJ/Cb98siTYNYMgHbuhgj1CFMRKuHILNXk52OCBY4 PV++h4T+eZaXGw8XgfLbBHONcOx6l0DLgu5YNdsbZHUFzdtz/uRsLOFn1TmxcJYKkkUg K7LA6nBI+3hz0Jb7qVFXPMEQ3Z4TVvPvLz1tsvCs7hvvQDIhNkWhMCV77q4MYCHq0CLp saEQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=eWKc5nDP; 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 f126-v6si4304313ybg.323.2018.11.27.21.48.44 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 27 Nov 2018 21:48:44 -0800 (PST) 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=eWKc5nDP; 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]:46078 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gRsiJ-0005R6-Lk for patch@linaro.org; Wed, 28 Nov 2018 00:48:43 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47981) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gRsYl-000413-R7 for qemu-devel@nongnu.org; Wed, 28 Nov 2018 00:38:53 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gRsYk-0004OW-6J for qemu-devel@nongnu.org; Wed, 28 Nov 2018 00:38:51 -0500 Received: from mail-pl1-x642.google.com ([2607:f8b0:4864:20::642]:36434) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gRsYj-0004NP-V1 for qemu-devel@nongnu.org; Wed, 28 Nov 2018 00:38:50 -0500 Received: by mail-pl1-x642.google.com with SMTP id g9so4345340plo.3 for ; Tue, 27 Nov 2018 21:38:49 -0800 (PST) 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=RayPqtg1GIUBRZB3Wq/kgllr6OtflLAyLXeqe+v2dG4=; b=eWKc5nDPv0WFDIGnFs8CHIhI0TBx8nkNsZuRE3Z0V2/rFKBDJd/RcZnUBw/Y8xm0wX N/vATD/mGaON9kpe3Qm1xNAf/pO4wm7zYo9C3xnnj2lgj84YCo14VbGU1wLByovAghhc PT+LDn89IJcTtsqlEnkcc0F/NX+2YZMOE1eQ8= 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=RayPqtg1GIUBRZB3Wq/kgllr6OtflLAyLXeqe+v2dG4=; b=N52ATB3IS6X5CtmM4wTouTdgX72k+Lkuac5+th0L6i4P62DxHrtFepBtCJntjO0p2C WnoSJsGOGJ/TKMYcuDNiaB5B04LN8/c02xvs4JFQEzAafH/Ceq/yAJjSMVaG9TlNtVR1 KpjQLMpk32ULj2tCpcUgnD56sZnLE0TnF7GXGETiG1L3nAM0IhvyPz2Q74jooWogofC6 JZfkYH6PzGOdIdKdwoyd5iukqjYfA/X/ebxzHndm8+G9rQiEy5DCSBYU3SBzqofqet6B cIYzgxPgMf4MXTuI1/13aqBs2dVRLJfSRqCFJQTpg/qR5DevBwV6xuqnCplVOQIlv31J PKoA== X-Gm-Message-State: AA+aEWbj7X9KXoZeCjNmhHwpB6P/r+lBxnYMhPBYcL+ty5LsCjC8HvJE HkeVnxxgTFDZkgWbVVPMECWaIgCOHWk= X-Received: by 2002:a17:902:714c:: with SMTP id u12mr35141985plm.234.1543383528635; Tue, 27 Nov 2018 21:38:48 -0800 (PST) Received: from cloudburst.twiddle.net (97-113-170-180.tukw.qwest.net. [97.113.170.180]) by smtp.gmail.com with ESMTPSA id 19sm8569336pfs.108.2018.11.27.21.38.47 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 27 Nov 2018 21:38:48 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Date: Tue, 27 Nov 2018 21:38:32 -0800 Message-Id: <20181128053834.10861-11-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20181128053834.10861-1-richard.henderson@linaro.org> References: <20181128053834.10861-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::642 Subject: [Qemu-devel] [PATCH 10/12] tcg: Split out more subroutines from liveness_pass_1 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.c | 35 +++++++++++++++++++++++------------ 1 file changed, 23 insertions(+), 12 deletions(-) -- 2.17.2 diff --git a/tcg/tcg.c b/tcg/tcg.c index 27814df882..21668831a1 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -2417,6 +2417,26 @@ static void la_bb_end(TCGContext *s, int ng, int nt) } } +/* liveness analysis: sync globals back to memory. */ +static void la_global_sync(TCGContext *s, int ng) +{ + int i; + + for (i = 0; i < ng; ++i) { + s->temps[i].state |= TS_MEM; + } +} + +/* liveness analysis: sync globals back to memory and kill. */ +static void la_global_kill(TCGContext *s, int ng) +{ + int i; + + for (i = 0; i < ng; i++) { + s->temps[i].state = TS_DEAD | TS_MEM; + } +} + /* Liveness analysis : update the opc_arg_life array to tell if a given input arguments is dead. Instructions updating dead temporaries are removed. */ @@ -2472,15 +2492,9 @@ static void liveness_pass_1(TCGContext *s) if (!(call_flags & (TCG_CALL_NO_WRITE_GLOBALS | TCG_CALL_NO_READ_GLOBALS))) { - /* globals should go back to memory */ - for (i = 0; i < nb_globals; i++) { - s->temps[i].state = TS_DEAD | TS_MEM; - } + la_global_kill(s, nb_globals); } else if (!(call_flags & TCG_CALL_NO_READ_GLOBALS)) { - /* globals should be synced to memory */ - for (i = 0; i < nb_globals; i++) { - s->temps[i].state |= TS_MEM; - } + la_global_sync(s, nb_globals); } /* record arguments that die in this helper */ @@ -2623,10 +2637,7 @@ static void liveness_pass_1(TCGContext *s) if (def->flags & TCG_OPF_BB_END) { la_bb_end(s, nb_globals, nb_temps); } else if (def->flags & TCG_OPF_SIDE_EFFECTS) { - /* globals should be synced to memory */ - for (i = 0; i < nb_globals; i++) { - s->temps[i].state |= TS_MEM; - } + la_global_sync(s, nb_globals); } /* record arguments that die in this opcode */ From patchwork Wed Nov 28 05:38:33 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 152184 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp688104ljp; Tue, 27 Nov 2018 21:42:01 -0800 (PST) X-Google-Smtp-Source: AFSGD/UjO5KiC1bL/rQLsBtlC553EZsiBh8iNfGVE1R70jf/PwEeZl76Rsc1bFMCr0CYjulQcT3s X-Received: by 2002:a25:4214:: with SMTP id p20-v6mr37690963yba.46.1543383721616; Tue, 27 Nov 2018 21:42:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543383721; cv=none; d=google.com; s=arc-20160816; b=rj81p4CJPvkNhckNejUjJLSzlzQ3jE0RRQ1Trp+eCpajnTGr3qFJwdXSwz8r/lL2/p 7r65kNouKyvfuqAB+zgaV5EKPtce3igPg7XNBXIVhWW+6bG0g4Z60QWugFtQb2ov61c5 0zQ7zYFPG+7bTlX1xOn/5EMiwvBegKUD27mW+vmrrQAhJmFHQQOzXMV9Y5myyMD0NjxK sU2u3t1Kiuuv2IfEsedrwrGyOZkilEOH/hxlXKVcQESEy+qlyTw3flT8RR2oTor4428m KW7IjP5271UaHXJRpbpT4gTkQD+TjQ66xinMZ8aE7BJBlwWiFoT6iA3l6ZeIMaXm6HLx PAaA== 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; bh=BO3Y+feOPDtdGYpH71CChV1kkmUFSxlaNa8lwq9tJKY=; b=WVZT7+RklvoGB/ehuZjYFlPZ07cwUUFMa3ZywnpbjURGcn6aqIC19g7dYZ+1EWBRLg YIFoluuvUQNqz3M25N3V2cy0O/WRkbeQ9PGqwfS0lGZyqqZEf23hpqOjXdhufcy3n9M2 Xzr3MOLK90ORmtqCNnXckWR76qDu0ITY0DMqmKkRzD3267DNFDOmipx4pUcSamdDaOT2 wGAE4qkBT9pXel4Y3+a3u75/OnurCK1tg2McyOg1JLW4lVoYScstcqkmoHacjWPvScDQ JCD7HuA9kf8kqPRqPqH21qlRtmOIM1YQNuPBRSw/p8HqO6grL0zHHB67ybqayGD9Ad+2 UmvA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=JjN7VvOa; 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 y14-v6si4348479ybr.371.2018.11.27.21.42.01 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 27 Nov 2018 21:42:01 -0800 (PST) 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=JjN7VvOa; 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]:46043 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gRsbo-0006fi-Vi for patch@linaro.org; Wed, 28 Nov 2018 00:42:01 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47998) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gRsYm-000418-5s for qemu-devel@nongnu.org; Wed, 28 Nov 2018 00:38:53 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gRsYl-0004PM-AG for qemu-devel@nongnu.org; Wed, 28 Nov 2018 00:38:52 -0500 Received: from mail-pf1-x441.google.com ([2607:f8b0:4864:20::441]:41503) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gRsYl-0004Ou-46 for qemu-devel@nongnu.org; Wed, 28 Nov 2018 00:38:51 -0500 Received: by mail-pf1-x441.google.com with SMTP id b7so9606342pfi.8 for ; Tue, 27 Nov 2018 21:38:51 -0800 (PST) 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=BO3Y+feOPDtdGYpH71CChV1kkmUFSxlaNa8lwq9tJKY=; b=JjN7VvOa/lNosBzuh+GWFqfM1ouPuwmprJH+qOIMAMJA1VjukHl2shEinsyRzvXBlB 063OM1i929K3BsU/eCx3NNts6EJCOiPHDAXoUcP7TKZg0KdYFzljgtif+vSac0WJyzpW YTyCyckXcwXSQ7cU5pMvWmpQ24rjX24ScaYmQ= 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=BO3Y+feOPDtdGYpH71CChV1kkmUFSxlaNa8lwq9tJKY=; b=GvGOYsCJtxkkn8HQLNeSlP1/cv1Rew+1OvNuxtoSp9riYCVam6beRAfYD3vn4Nyk+a v7SjimtlWcDrXdyUscb8AIm4U9Y5dq1uNxVlsUIFYQY9Vr01w8JxJXQq993CaOpsHciw b98kcuUgsNAHMMW75W0BT4ghxOot2th0f2NpYSYlo5ZLmA8gShY3flpguBgyrGL/U+LJ phjKUdI0HU0wEl2iIIxiu28zILYg4jB23BO3mI4aXWDeK1qwpUbD4xG40zUD9kJ9Mqdm 0ThgjSIMpJRLZ16AIKWITrC4N2Fdpk8PSYlsYJVEC7z8F9Zd3NCnxYqXc7UyqWlUHtIn NF8A== X-Gm-Message-State: AGRZ1gIIk8bVAxl0dzMVahZU+/6WYDVo7kNj1E/RSd6ltzcj0SYPhxgL DESVo5ioobbg+IxUPOY4bqmDAXaU4FM= X-Received: by 2002:a62:a1a:: with SMTP id s26mr36210640pfi.31.1543383529747; Tue, 27 Nov 2018 21:38:49 -0800 (PST) Received: from cloudburst.twiddle.net (97-113-170-180.tukw.qwest.net. [97.113.170.180]) by smtp.gmail.com with ESMTPSA id 19sm8569336pfs.108.2018.11.27.21.38.48 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 27 Nov 2018 21:38:49 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Date: Tue, 27 Nov 2018 21:38:33 -0800 Message-Id: <20181128053834.10861-12-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20181128053834.10861-1-richard.henderson@linaro.org> References: <20181128053834.10861-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::441 Subject: [Qemu-devel] [PATCH 11/12] tcg: Add TCG_OPF_BB_EXIT 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" Use this to notice the opcodes that exit the TB, which implies that local temps are really dead and need not be synced. Previously we so marked the true end of the TB, but that was immediately overwritten by the la_bb_end invoked by any TCG_OPF_BB_END opcode, like exit_tb. Signed-off-by: Richard Henderson --- tcg/tcg-opc.h | 7 ++++--- tcg/tcg.h | 14 ++++++++------ tcg/tcg.c | 5 ++++- 3 files changed, 16 insertions(+), 10 deletions(-) -- 2.17.2 diff --git a/tcg/tcg-opc.h b/tcg/tcg-opc.h index e3a43aabb6..7a8a3edb5b 100644 --- a/tcg/tcg-opc.h +++ b/tcg/tcg-opc.h @@ -191,9 +191,10 @@ DEF(mulsh_i64, 1, 2, 0, IMPL64 | IMPL(TCG_TARGET_HAS_mulsh_i64)) /* QEMU specific */ DEF(insn_start, 0, 0, TLADDR_ARGS * TARGET_INSN_START_WORDS, TCG_OPF_NOT_PRESENT) -DEF(exit_tb, 0, 0, 1, TCG_OPF_BB_END) -DEF(goto_tb, 0, 0, 1, TCG_OPF_BB_END) -DEF(goto_ptr, 0, 1, 0, TCG_OPF_BB_END | IMPL(TCG_TARGET_HAS_goto_ptr)) +DEF(exit_tb, 0, 0, 1, TCG_OPF_BB_EXIT | TCG_OPF_BB_END) +DEF(goto_tb, 0, 0, 1, TCG_OPF_BB_EXIT | TCG_OPF_BB_END) +DEF(goto_ptr, 0, 1, 0, + TCG_OPF_BB_EXIT | TCG_OPF_BB_END | IMPL(TCG_TARGET_HAS_goto_ptr)) DEF(qemu_ld_i32, 1, TLADDR_ARGS, 1, TCG_OPF_CALL_CLOBBER | TCG_OPF_SIDE_EFFECTS) diff --git a/tcg/tcg.h b/tcg/tcg.h index ac5d01c223..abbf9c836a 100644 --- a/tcg/tcg.h +++ b/tcg/tcg.h @@ -1037,20 +1037,22 @@ typedef struct TCGArgConstraint { /* Bits for TCGOpDef->flags, 8 bits available. */ enum { + /* Instruction exits the translation block. */ + TCG_OPF_BB_EXIT = 0x01, /* Instruction defines the end of a basic block. */ - TCG_OPF_BB_END = 0x01, + TCG_OPF_BB_END = 0x02, /* Instruction clobbers call registers and potentially update globals. */ - TCG_OPF_CALL_CLOBBER = 0x02, + TCG_OPF_CALL_CLOBBER = 0x04, /* Instruction has side effects: it cannot be removed if its outputs are not used, and might trigger exceptions. */ - TCG_OPF_SIDE_EFFECTS = 0x04, + TCG_OPF_SIDE_EFFECTS = 0x08, /* Instruction operands are 64-bits (otherwise 32-bits). */ - TCG_OPF_64BIT = 0x08, + TCG_OPF_64BIT = 0x10, /* Instruction is optional and not implemented by the host, or insn is generic and should not be implemened by the host. */ - TCG_OPF_NOT_PRESENT = 0x10, + TCG_OPF_NOT_PRESENT = 0x20, /* Instruction operands are vectors. */ - TCG_OPF_VECTOR = 0x20, + TCG_OPF_VECTOR = 0x40, }; typedef struct TCGOpDef { diff --git a/tcg/tcg.c b/tcg/tcg.c index 21668831a1..673aaf52a1 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -2446,6 +2446,7 @@ static void liveness_pass_1(TCGContext *s) int nb_temps = s->nb_temps; TCGOp *op, *op_prev; + /* ??? Should be redundant with the exit_tb that ends the TB. */ la_func_end(s, nb_globals, nb_temps); QTAILQ_FOREACH_REVERSE_SAFE(op, &s->ops, TCGOpHead, link, op_prev) { @@ -2634,7 +2635,9 @@ static void liveness_pass_1(TCGContext *s) } /* if end of basic block, update */ - if (def->flags & TCG_OPF_BB_END) { + if (def->flags & TCG_OPF_BB_EXIT) { + la_func_end(s, nb_globals, nb_temps); + } else if (def->flags & TCG_OPF_BB_END) { la_bb_end(s, nb_globals, nb_temps); } else if (def->flags & TCG_OPF_SIDE_EFFECTS) { la_global_sync(s, nb_globals); From patchwork Wed Nov 28 05:38:34 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 152189 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp690426ljp; Tue, 27 Nov 2018 21:45:22 -0800 (PST) X-Google-Smtp-Source: AFSGD/WUGCt4lzG7b28zkGWrsKSDE+vPIVAQUFGiyeyGv8+aKBJTHZ/Q1GwkY1JixPz6wAzoUev2 X-Received: by 2002:a25:ad84:: with SMTP id z4-v6mr36001782ybi.475.1543383922584; Tue, 27 Nov 2018 21:45:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543383922; cv=none; d=google.com; s=arc-20160816; b=WcTPzx5aq2U8W9Mn6MSNaoALQZL47sF+ghnf1T2xnLDTyhXTuNpTAirCahS/miNv7f zFdsHGwqDuWQp108XwBeM3dzAiBcIb9N6Vaig1Q5fr22+Tn+EjSMRXqQWRdYCHcfjTZh jT3T1rbPKTkdkYiKBXgLzJWwuEzC40okT2cOSAg+NqPba+6b8kjeXJZno6gWWdhI2yeU 62muhHmerW0ucSaSQZBYw3yz1y2I+mJqn/xmLhViJi5yE/aPsQpG4Jq9PYKkg0A5lnq9 qIMFxSSzCCkVmFUouZ4ov/ARs4Vbq2rlQmeQ//xP/XyXROh+dPR01hMilMfeDbAIqp24 /6sw== 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; bh=i1xOLMMSZPEBxneoRmjCkNCjZxttxX47mgYHoGxFQFg=; b=YOFyD9KCLkgkcgdCGqhXZqNiO94gmi7/njGY1kO5pqCkiiogfmgvTKPKtVzisDWmZX GExb1iBmOkpuCcXjdcSkJ3nGa+y/5eyIwqxWpwBAGmRxF3Hfeu2RCcMyZ04jJP3KRWKb iHbdzPBND+wAlgK5poZgVTvys/rH3lhrVg4xUuedJ+8pnwCYD39CCEI0SfqGKuHjBc0u fahITPDo76qew5JFkXuSRzrKftnw8c48p3mdgp/I/xz/MgjErmdwzeB1+ZGIXBCG50cu t/reZZJZZvODMRxdtJyBEJn0NA9EnAWmwJB/sHbGAgJybn9nyN4pJv7R0AVW+FeML/DH aq/g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=HFKocHvP; 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 g6si4504602ywc.14.2018.11.27.21.45.22 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 27 Nov 2018 21:45:22 -0800 (PST) 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=HFKocHvP; 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]:46056 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gRsf3-0001ip-Tr for patch@linaro.org; Wed, 28 Nov 2018 00:45:21 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48042) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gRsYq-00041E-Lm for qemu-devel@nongnu.org; Wed, 28 Nov 2018 00:38:57 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gRsYm-0004QS-P9 for qemu-devel@nongnu.org; Wed, 28 Nov 2018 00:38:54 -0500 Received: from mail-pf1-x42d.google.com ([2607:f8b0:4864:20::42d]:37519) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gRsYm-0004Pv-GR for qemu-devel@nongnu.org; Wed, 28 Nov 2018 00:38:52 -0500 Received: by mail-pf1-x42d.google.com with SMTP id y126so1726963pfb.4 for ; Tue, 27 Nov 2018 21:38:52 -0800 (PST) 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=i1xOLMMSZPEBxneoRmjCkNCjZxttxX47mgYHoGxFQFg=; b=HFKocHvPFs7hBDnB6PtIiBpC1GToCPzOuOL1mY0T9n7W0HnUcHSG0e9weQCyxtub5z D6tTXxXr6juiPTMQyfbxv+EsFEgfx2dslSp0fLiAi5Q2bmY30l1lWFVZq9xRNFDlMkul APAzFqb1OvPz7vWX+04JIplKWk1eTNAEBWpKQ= 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=i1xOLMMSZPEBxneoRmjCkNCjZxttxX47mgYHoGxFQFg=; b=bBKZtI/3hceQAjzEwGoFXWMGO2xi99mLqu7Jt5EHMcA8OUe1CN+EQVmfkHVH6JTad8 /uPW5aWEq5qbqvmpmV2bZ2P2LHRhKf93lnrXhIohhsTGrH2N3wHvdB+VjzScynvasRb3 1+37GqByEYlTBz7dBUbJ0McTYQKEpwW5WVqX2FFKY013pXtlJAkoQj7Q91payJoWo2ZZ iB3ZLJByTN3VqjsD0tIH3FFyoT+drtdaJtpUvAYQoL2wmsCmr+YrsQBtY0FZ06vTNeRB axbrUf2xnGuHUeGh7VDlKQ/fKQTu/ieU+IrVuRf/JJ3Vdy63pQeRII7n1oxckwlcJYmr 1x5w== X-Gm-Message-State: AA+aEWb8N22pAMfaF+D3+kzwbIWYGVaJNI+przNYNTInIThDEpT854A/ 3fQgCtZKqc363YL64HNf2Y/be4jo8o0= X-Received: by 2002:a63:1b48:: with SMTP id b8mr32254069pgm.187.1543383531082; Tue, 27 Nov 2018 21:38:51 -0800 (PST) Received: from cloudburst.twiddle.net (97-113-170-180.tukw.qwest.net. [97.113.170.180]) by smtp.gmail.com with ESMTPSA id 19sm8569336pfs.108.2018.11.27.21.38.49 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 27 Nov 2018 21:38:50 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Date: Tue, 27 Nov 2018 21:38:34 -0800 Message-Id: <20181128053834.10861-13-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20181128053834.10861-1-richard.henderson@linaro.org> References: <20181128053834.10861-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::42d Subject: [Qemu-devel] [PATCH 12/12] tcg: Record register preferences during 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 Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" With these preferences, we can arrange for function call arguments to be computed into the proper registers instead of requiring extra moves. Signed-off-by: Richard Henderson --- tcg/tcg.c | 197 +++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 165 insertions(+), 32 deletions(-) -- 2.17.2 diff --git a/tcg/tcg.c b/tcg/tcg.c index 673aaf52a1..734a453fc8 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -2387,6 +2387,21 @@ static void reachable_code_pass(TCGContext *s) #define IS_DEAD_ARG(n) (arg_life & (DEAD_ARG << (n))) #define NEED_SYNC_ARG(n) (arg_life & (SYNC_ARG << (n))) +/* For liveness_pass_1, the register preferences for a given temp. */ +static inline TCGRegSet *la_temp_pref(TCGTemp *ts) +{ + return ts->state_ptr; +} + +/* For liveness_pass_1, reset the preferences for a given temp to the + * maximal regset for its type. + */ +static inline void la_reset_pref(TCGTemp *ts) +{ + *la_temp_pref(ts) + = (ts->state == TS_DEAD ? 0 : tcg_target_available_regs[ts->type]); +} + /* liveness analysis: end of function: all temps are dead, and globals should be in memory. */ static void la_func_end(TCGContext *s, int ng, int nt) @@ -2395,9 +2410,11 @@ static void la_func_end(TCGContext *s, int ng, int nt) for (i = 0; i < ng; ++i) { s->temps[i].state = TS_DEAD | TS_MEM; + la_reset_pref(&s->temps[i]); } for (i = ng; i < nt; ++i) { s->temps[i].state = TS_DEAD; + la_reset_pref(&s->temps[i]); } } @@ -2409,11 +2426,13 @@ static void la_bb_end(TCGContext *s, int ng, int nt) for (i = 0; i < ng; ++i) { s->temps[i].state = TS_DEAD | TS_MEM; + la_reset_pref(&s->temps[i]); } for (i = ng; i < nt; ++i) { s->temps[i].state = (s->temps[i].temp_local ? TS_DEAD | TS_MEM : TS_DEAD); + la_reset_pref(&s->temps[i]); } } @@ -2423,7 +2442,12 @@ static void la_global_sync(TCGContext *s, int ng) int i; for (i = 0; i < ng; ++i) { - s->temps[i].state |= TS_MEM; + int state = s->temps[i].state; + s->temps[i].state = state | TS_MEM; + if (state == TS_DEAD) { + /* If the global was previously dead, reset prefs. */ + la_reset_pref(&s->temps[i]); + } } } @@ -2434,6 +2458,29 @@ static void la_global_kill(TCGContext *s, int ng) for (i = 0; i < ng; i++) { s->temps[i].state = TS_DEAD | TS_MEM; + la_reset_pref(&s->temps[i]); + } +} + +/* liveness analysis: note live globals crossing calls. */ +static void la_cross_call(TCGContext *s, int nt) +{ + TCGRegSet mask = ~tcg_target_call_clobber_regs; + int i; + + for (i = 0; i < nt; i++) { + TCGTemp *ts = &s->temps[i]; + if (!(ts->state & TS_DEAD)) { + TCGRegSet *pset = la_temp_pref(ts); + TCGRegSet set = *pset; + + set &= mask; + /* If the combination is not possible, restart. */ + if (set == 0) { + set = tcg_target_available_regs[ts->type] & mask; + } + *pset = set; + } } } @@ -2445,16 +2492,23 @@ static void liveness_pass_1(TCGContext *s) int nb_globals = s->nb_globals; int nb_temps = s->nb_temps; TCGOp *op, *op_prev; + TCGRegSet *prefs; + int i; + + prefs = tcg_malloc(sizeof(TCGRegSet) * nb_temps); + for (i = 0; i < nb_temps; ++i) { + s->temps[i].state_ptr = prefs + i; + } /* ??? Should be redundant with the exit_tb that ends the TB. */ la_func_end(s, nb_globals, nb_temps); QTAILQ_FOREACH_REVERSE_SAFE(op, &s->ops, TCGOpHead, link, op_prev) { - int i, nb_iargs, nb_oargs; + int nb_iargs, nb_oargs; TCGOpcode opc_new, opc_new2; bool have_opc_new2; TCGLifeData arg_life = 0; - TCGTemp *arg_ts; + TCGTemp *ts; TCGOpcode opc = op->opc; const TCGOpDef *def = &tcg_op_defs[opc]; @@ -2462,6 +2516,7 @@ static void liveness_pass_1(TCGContext *s) case INDEX_op_call: { int call_flags; + int nb_call_regs; nb_oargs = TCGOP_CALLO(op); nb_iargs = TCGOP_CALLI(op); @@ -2470,8 +2525,8 @@ static void liveness_pass_1(TCGContext *s) /* 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_ts = arg_temp(op->args[i]); - if (arg_ts->state != TS_DEAD) { + ts = arg_temp(op->args[i]); + if (ts->state != TS_DEAD) { goto do_not_remove_call; } } @@ -2479,16 +2534,20 @@ static void liveness_pass_1(TCGContext *s) } do_not_remove_call: - /* output args are dead */ + /* Output args are dead. */ for (i = 0; i < nb_oargs; i++) { - arg_ts = arg_temp(op->args[i]); - if (arg_ts->state & TS_DEAD) { + ts = arg_temp(op->args[i]); + if (ts->state & TS_DEAD) { arg_life |= DEAD_ARG << i; } - if (arg_ts->state & TS_MEM) { + if (ts->state & TS_MEM) { arg_life |= SYNC_ARG << i; } - arg_ts->state = TS_DEAD; + ts->state = TS_DEAD; + la_reset_pref(ts); + + /* Not used -- it will be tcg_target_call_oarg_regs[i]. */ + op->output_pref[i] = 0; } if (!(call_flags & (TCG_CALL_NO_WRITE_GLOBALS | @@ -2498,18 +2557,42 @@ static void liveness_pass_1(TCGContext *s) la_global_sync(s, nb_globals); } - /* record arguments that die in this helper */ + /* Record arguments that die in this helper. */ for (i = nb_oargs; i < nb_iargs + nb_oargs; i++) { - arg_ts = arg_temp(op->args[i]); - if (arg_ts && arg_ts->state & TS_DEAD) { + ts = arg_temp(op->args[i]); + if (ts && 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_ts = arg_temp(op->args[i]); - if (arg_ts) { - arg_ts->state &= ~TS_DEAD; + + /* For all live registers, remove call-clobbered prefs. */ + la_cross_call(s, nb_temps); + + nb_call_regs = ARRAY_SIZE(tcg_target_call_iarg_regs); + + /* Input arguments are live for preceding opcodes. */ + for (i = 0; i < nb_iargs; i++) { + ts = arg_temp(op->args[i + nb_oargs]); + if (ts && ts->state & TS_DEAD) { + /* For those arguments that die, and will be allocated + * in registers, clear the register set for that arg, + * to be filled in below. For args that will be on + * the stack, reset to any available reg. + */ + *la_temp_pref(ts) + = (i < nb_call_regs ? 0 : + tcg_target_available_regs[ts->type]); + ts->state &= ~TS_DEAD; + } + } + + /* For each input argument, add its input register to prefs. + If a temp is used once, this produces a single set bit. */ + for (i = 0; i < MIN(nb_call_regs, nb_iargs); i++) { + ts = arg_temp(op->args[i + nb_oargs]); + if (ts) { + tcg_regset_set_reg(*la_temp_pref(ts), + tcg_target_call_iarg_regs[i]); } } } @@ -2518,7 +2601,9 @@ static void liveness_pass_1(TCGContext *s) break; case INDEX_op_discard: /* mark the temporary as dead */ - arg_temp(op->args[0])->state = TS_DEAD; + ts = arg_temp(op->args[0]); + ts->state = TS_DEAD; + la_reset_pref(ts); break; case INDEX_op_add2_i32: @@ -2622,43 +2707,91 @@ static void liveness_pass_1(TCGContext *s) break; do_not_remove: - /* output args are dead */ for (i = 0; i < nb_oargs; i++) { - arg_ts = arg_temp(op->args[i]); - if (arg_ts->state & TS_DEAD) { + ts = arg_temp(op->args[i]); + + /* Remember the preference of the uses that followed. */ + op->output_pref[i] = *la_temp_pref(ts); + + /* Output args are dead. */ + if (ts->state & TS_DEAD) { arg_life |= DEAD_ARG << i; } - if (arg_ts->state & TS_MEM) { + if (ts->state & TS_MEM) { arg_life |= SYNC_ARG << i; } - arg_ts->state = TS_DEAD; + ts->state = TS_DEAD; + la_reset_pref(ts); } - /* if end of basic block, update */ + /* If end of basic block, update. */ if (def->flags & TCG_OPF_BB_EXIT) { la_func_end(s, nb_globals, nb_temps); } else if (def->flags & TCG_OPF_BB_END) { la_bb_end(s, nb_globals, nb_temps); } else if (def->flags & TCG_OPF_SIDE_EFFECTS) { la_global_sync(s, nb_globals); + if (def->flags & TCG_OPF_CALL_CLOBBER) { + la_cross_call(s, nb_temps); + } } - /* record arguments that die in this opcode */ + /* Record arguments that die in this opcode. */ for (i = nb_oargs; i < nb_oargs + nb_iargs; i++) { - arg_ts = arg_temp(op->args[i]); - if (arg_ts->state & TS_DEAD) { + ts = arg_temp(op->args[i]); + if (ts->state & TS_DEAD) { arg_life |= DEAD_ARG << i; } } - /* input arguments are live for preceding opcodes */ + + /* Input arguments are live for preceding opcodes. */ for (i = nb_oargs; i < nb_oargs + nb_iargs; i++) { - arg_temp(op->args[i])->state &= ~TS_DEAD; + ts = arg_temp(op->args[i]); + if (ts->state & TS_DEAD) { + /* For operands that were dead, initially allow + all regs for the type. */ + *la_temp_pref(ts) = tcg_target_available_regs[ts->type]; + ts->state &= ~TS_DEAD; + } + } + + /* Incorporate constraints for this operand. */ + switch (opc) { + case INDEX_op_mov_i32: + case INDEX_op_mov_i64: + /* Note that these are TCG_OPF_NOT_PRESENT and do not + have proper constraints. That said, special case + moves to propagate preferences backward. */ + if (IS_DEAD_ARG(1)) { + *la_temp_pref(arg_temp(op->args[0])) + = *la_temp_pref(arg_temp(op->args[1])); + } + break; + + default: + for (i = nb_oargs; i < nb_oargs + nb_iargs; i++) { + const TCGArgConstraint *ct = &def->args_ct[i]; + TCGRegSet set, *pset; + + ts = arg_temp(op->args[i]); + pset = la_temp_pref(ts); + set = *pset; + + set &= ct->u.regs; + if (ct->ct & TCG_CT_IALIAS) { + set &= op->output_pref[ct->alias_index]; + } + /* If the combination is not possible, restart. */ + if (set == 0) { + set = ct->u.regs; + } + *pset = set; + } + break; } break; } op->life = arg_life; - op->output_pref[0] = 0; - op->output_pref[1] = 0; } }