From nobody Tue May 7 07:38:23 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1543383666233235.12817451696765; Tue, 27 Nov 2018 21:41:06 -0800 (PST) Received: from localhost ([::1]:46037 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gRsau-0005W5-Tb for importer@patchew.org; Wed, 28 Nov 2018 00:41:04 -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) 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) 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-Google-Smtp-Source: AFSGD/UrHbrfrJYz2Xw1s3iga1hogsMo7Ax1JJ5Q1omlbiMw9oU0P9B4APR4yYuYwr2ZV6SCzaLkaA== X-Received: by 2002:a63:2bc4:: with SMTP id r187mr13226325pgr.306.1543383517679; Tue, 27 Nov 2018 21:38:37 -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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: Emilio G. Cota --- tcg/tcg.c | 103 ++++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 81 insertions(+), 22 deletions(-) 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] =3D { [MO_ALIGN_64 >> MO_ASHIFT] =3D "al64+", }; =20 +static inline bool tcg_regset_single(TCGRegSet d) +{ + return (d & (d - 1)) =3D=3D 0; +} + +static inline TCGReg tcg_regset_first(TCGRegSet d) +{ + if (TCG_TARGET_NB_REGS <=3D 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 =3D &tcg_op_defs[c]; =20 if (c =3D=3D INDEX_op_insn_start) { + nb_oargs =3D 0; col +=3D qemu_log("\n ----"); =20 for (i =3D 0; i < TARGET_INSN_START_WORDS; ++i) { @@ -2924,31 +2939,72 @@ static void tcg_reg_free(TCGContext *s, TCGReg reg,= TCGRegSet allocated_regs) } } =20 -/* 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 =3D ARRAY_SIZE(tcg_target_reg_alloc_order); + int i, j, f, n =3D ARRAY_SIZE(tcg_target_reg_alloc_order); + TCGRegSet reg_ct[2]; const int *order; - TCGReg reg; - TCGRegSet reg_ct; =20 - reg_ct =3D desired_regs & ~allocated_regs; + reg_ct[1] =3D required_regs & ~allocated_regs; + tcg_debug_assert(reg_ct[1] !=3D 0); + reg_ct[0] =3D reg_ct[1] & preferred_regs; + + /* Skip the preferred_regs option if it cannot be satisfied, + or if the preference made no difference. */ + f =3D reg_ct[0] =3D=3D 0 || reg_ct[0] =3D=3D reg_ct[1]; + order =3D rev ? indirect_reg_alloc_order : tcg_target_reg_alloc_order; =20 - /* first try free registers */ - for(i =3D 0; i < n; i++) { - reg =3D order[i]; - if (tcg_regset_test_reg(reg_ct, reg) && s->reg_to_temp[reg] =3D=3D= NULL) - return reg; + /* Try free registers, preferences first. */ + for (j =3D f; j < 2; j++) { + TCGRegSet set =3D reg_ct[j]; + + if (tcg_regset_single(set)) { + /* One register in the set. */ + TCGReg reg =3D tcg_regset_first(set); + if (s->reg_to_temp[reg] =3D=3D NULL) { + return reg; + } + } else { + for (i =3D 0; i < n; i++) { + TCGReg reg =3D order[i]; + if (s->reg_to_temp[reg] =3D=3D NULL && + tcg_regset_test_reg(set, reg)) { + return reg; + } + } + } } =20 - /* XXX: do better spill choice */ - for(i =3D 0; i < n; i++) { - reg =3D order[i]; - if (tcg_regset_test_reg(reg_ct, reg)) { + /* We must spill something. */ + for (j =3D f; j < 2; j++) { + TCGRegSet set =3D reg_ct[j]; + + if (tcg_regset_single(set)) { + /* One register in the set. */ + TCGReg reg =3D tcg_regset_first(set); tcg_reg_free(s, reg, allocated_regs); return reg; + } else { + for (i =3D 0; i < n; i++) { + TCGReg reg =3D order[i]; + if (tcg_regset_test_reg(set, reg)) { + tcg_reg_free(s, reg, allocated_regs); + return reg; + } + } } } =20 @@ -2966,12 +3022,14 @@ static void temp_load(TCGContext *s, TCGTemp *ts, T= CGRegSet desired_regs, case TEMP_VAL_REG: return; case TEMP_VAL_CONST: - reg =3D tcg_reg_alloc(s, desired_regs, allocated_regs, ts->indirec= t_base); + reg =3D tcg_reg_alloc(s, desired_regs, allocated_regs, + 0, ts->indirect_base); tcg_out_movi(s, ts->type, reg, ts->val); ts->mem_coherent =3D 0; break; case TEMP_VAL_MEM: - reg =3D tcg_reg_alloc(s, desired_regs, allocated_regs, ts->indirec= t_base); + reg =3D 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 =3D 1; break; @@ -3131,7 +3189,8 @@ static void tcg_reg_alloc_mov(TCGContext *s, const TC= GOp *op) input one. */ tcg_regset_set_reg(allocated_regs, ts->reg); ots->reg =3D tcg_reg_alloc(s, tcg_target_available_regs[ot= ype], - allocated_regs, ots->indirect_bas= e); + 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 TCG= Op *op) /* allocate a new register matching the constraint=20 and move the temporary register into it */ reg =3D 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] =3D reg; @@ -3264,7 +3323,7 @@ static void tcg_reg_alloc_op(TCGContext *s, const TCG= Op *op) } else if (arg_ct->ct & TCG_CT_NEWREG) { reg =3D 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 =3D ts->reg; @@ -3273,7 +3332,7 @@ static void tcg_reg_alloc_op(TCGContext *s, const TCG= Op *op) goto oarg_end; } reg =3D 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 after= wards */ --=20 2.17.2 From nobody Tue May 7 07:38:23 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1543383873697511.92923981602416; Tue, 27 Nov 2018 21:44:33 -0800 (PST) Received: from localhost ([::1]:46052 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gRseG-0000vU-C2 for importer@patchew.org; Wed, 28 Nov 2018 00:44:32 -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) 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) 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-Google-Smtp-Source: AFSGD/VgOjBD38OEVynM1kQSbnTSDrjTYwZaUT0jpJEKStglZ9c7f6d8XEdLm2y2mdMMIL2rMlzcHQ== X-Received: by 2002:a63:1904:: with SMTP id z4mr31067927pgl.135.1543383518976; 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Pass this through to tcg_reg_alloc. Signed-off-by: Richard Henderson Reviewed-by: Emilio G. Cota --- tcg/tcg.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) 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, TCGTem= p *ts) s->current_frame_offset +=3D sizeof(tcg_target_long); } =20 -static void temp_load(TCGContext *, TCGTemp *, TCGRegSet, TCGRegSet); +static void temp_load(TCGContext *, TCGTemp *, TCGRegSet, TCGRegSet, TCGRe= gSet); =20 /* 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 */ =20 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 regi= ster 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; =20 @@ -3023,13 +3023,13 @@ static void temp_load(TCGContext *s, TCGTemp *ts, T= CGRegSet desired_regs, return; case TEMP_VAL_CONST: reg =3D 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 =3D 0; break; case TEMP_VAL_MEM: reg =3D 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 =3D 1; break; @@ -3159,7 +3159,7 @@ static void tcg_reg_alloc_mov(TCGContext *s, const TC= GOp *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 =3D=3D 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); } =20 tcg_debug_assert(ts->val_type =3D=3D TEMP_VAL_REG); @@ -3243,7 +3243,7 @@ static void tcg_reg_alloc_op(TCGContext *s, const TCG= Op *op) goto iarg_end; } =20 - temp_load(s, ts, arg_ct->u.regs, i_allocated_regs); + temp_load(s, ts, arg_ct->u.regs, i_allocated_regs, 0); =20 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 !=3D TCG_CALL_DUMMY_ARG) { ts =3D 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_off= set); } #ifndef TCG_TARGET_STACK_GROWSUP @@ -3449,7 +3449,7 @@ static void tcg_reg_alloc_call(TCGContext *s, TCGOp *= op) TCGRegSet arg_set =3D 0; =20 tcg_regset_set_reg(arg_set, reg); - temp_load(s, ts, arg_set, allocated_regs); + temp_load(s, ts, arg_set, allocated_regs, 0); } =20 tcg_regset_set_reg(allocated_regs, reg); --=20 2.17.2 From nobody Tue May 7 07:38:23 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1543383664082198.15424502374674; Tue, 27 Nov 2018 21:41:04 -0800 (PST) Received: from localhost ([::1]:46036 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gRsas-0005UI-PW for importer@patchew.org; Wed, 28 Nov 2018 00:41:02 -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) 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) 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-Google-Smtp-Source: AFSGD/Umldd5cAoNQXwpnlNMed/R+RCHOZuJS5lb0FnoNruhHMj3VjQkJPau/Hro+WniEXgqJOwudQ== X-Received: by 2002:a17:902:9a4c:: with SMTP id x12mr1731911plv.94.1543383520195; Tue, 27 Nov 2018 21:38:40 -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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Pass this through to tcg_reg_alloc. Signed-off-by: Richard Henderson Reviewed-by: Emilio G. Cota --- tcg/tcg.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) 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 */ =20 case TEMP_VAL_REG: @@ -2935,7 +2935,7 @@ static void tcg_reg_free(TCGContext *s, TCGReg reg, T= CGRegSet allocated_regs) { TCGTemp *ts =3D s->reg_to_temp[reg]; if (ts !=3D NULL) { - temp_sync(s, ts, allocated_regs, -1); + temp_sync(s, ts, allocated_regs, 0, -1); } } =20 @@ -3115,7 +3115,7 @@ static void tcg_reg_alloc_do_movi(TCGContext *s, TCGT= emp *ots, ots->val =3D val; ots->mem_coherent =3D 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 TC= GOp *op) ots->mem_coherent =3D 0; s->reg_to_temp[ots->reg] =3D 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 TCG= Op *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 =3D 0; s->reg_to_temp[reg] =3D 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); } --=20 2.17.2 From nobody Tue May 7 07:38:23 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1543383850224767.7328167239056; Tue, 27 Nov 2018 21:44:10 -0800 (PST) Received: from localhost ([::1]:46051 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gRsdt-0000fs-0Q for importer@patchew.org; Wed, 28 Nov 2018 00:44:09 -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) 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) 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-Google-Smtp-Source: AFSGD/XMFznfF0m7tnwpo33b6AmIHRIW7SnhzBRzPHuwn0DkWM/0a8nYN4yxNw721zDvm2D82gkuPA== X-Received: by 2002:a17:902:bf49:: with SMTP id u9mr35168848pls.4.1543383521392; Tue, 27 Nov 2018 21:38:41 -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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Pass this through to temp_sync. Signed-off-by: Richard Henderson Reviewed-by: Emilio G. Cota --- tcg/tcg.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) 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, TCGRe= gSet allocated_regs) } =20 static void tcg_reg_alloc_do_movi(TCGContext *s, TCGTemp *ots, - tcg_target_ulong val, TCGLifeData arg_li= fe) + tcg_target_ulong val, TCGLifeData arg_li= fe, + 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, TCGT= emp *ots, ots->val =3D val; ots->mem_coherent =3D 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 T= CGOp *op) TCGTemp *ots =3D arg_temp(op->args[0]); tcg_target_ulong val =3D op->args[1]; =20 - tcg_reg_alloc_do_movi(s, ots, val, op->life); + tcg_reg_alloc_do_movi(s, ots, val, op->life, 0); } =20 static void tcg_reg_alloc_mov(TCGContext *s, const TCGOp *op) @@ -3150,7 +3151,7 @@ static void tcg_reg_alloc_mov(TCGContext *s, const TC= GOp *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; } =20 --=20 2.17.2 From nobody Tue May 7 07:38:23 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1543383849414601.0139919537669; Tue, 27 Nov 2018 21:44:09 -0800 (PST) Received: from localhost ([::1]:46049 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gRsdl-0000XD-88 for importer@patchew.org; Wed, 28 Nov 2018 00:44:01 -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) 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) 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-Google-Smtp-Source: AFSGD/XVAXkApWwCwtz4lvIBRFAfGaNZ80rgxt3+l6sGT5wNMl/xs4EAjdkSvtcB9K3rJZOJTdaJEw== X-Received: by 2002:a62:5fc4:: with SMTP id t187mr5083653pfb.66.1543383522513; Tue, 27 Nov 2018 21:38:42 -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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: Emilio G. Cota --- tcg/tcg.h | 3 +++ tcg/tcg.c | 18 +++++++++++------- 2 files changed, 14 insertions(+), 7 deletions(-) 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 { =20 /* Arguments for the opcode. */ TCGArg args[MAX_OPC_PARAM]; + + /* Register preferences for the output(s). */ + TCGRegSet output_pref[2]; } TCGOp; =20 #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 =3D arg_life; + op->output_pref[0] =3D 0; + op->output_pref[1] =3D 0; } } =20 @@ -3127,17 +3129,18 @@ static void tcg_reg_alloc_movi(TCGContext *s, const= TCGOp *op) TCGTemp *ots =3D arg_temp(op->args[0]); tcg_target_ulong val =3D op->args[1]; =20 - tcg_reg_alloc_do_movi(s, ots, val, op->life, 0); + tcg_reg_alloc_do_movi(s, ots, val, op->life, op->output_pref[0]); } =20 static void tcg_reg_alloc_mov(TCGContext *s, const TCGOp *op) { const TCGLifeData arg_life =3D op->life; - TCGRegSet allocated_regs; + TCGRegSet allocated_regs, preferred_regs; TCGTemp *ts, *ots; TCGType otype, itype; =20 allocated_regs =3D s->reserved_regs; + preferred_regs =3D op->output_pref[0]; ots =3D arg_temp(op->args[0]); ts =3D arg_temp(op->args[1]); =20 @@ -3151,7 +3154,7 @@ static void tcg_reg_alloc_mov(TCGContext *s, const TC= GOp *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; } =20 @@ -3160,7 +3163,8 @@ static void tcg_reg_alloc_mov(TCGContext *s, const TC= GOp *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 =3D=3D 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); } =20 tcg_debug_assert(ts->val_type =3D=3D TEMP_VAL_REG); @@ -3190,7 +3194,7 @@ static void tcg_reg_alloc_mov(TCGContext *s, const TC= GOp *op) input one. */ tcg_regset_set_reg(allocated_regs, ts->reg); ots->reg =3D tcg_reg_alloc(s, tcg_target_available_regs[ot= ype], - 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 TCG= Op *op) } else if (arg_ct->ct & TCG_CT_NEWREG) { reg =3D 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 =3D ts->reg; @@ -3333,7 +3337,7 @@ static void tcg_reg_alloc_op(TCGContext *s, const TCG= Op *op) goto oarg_end; } reg =3D 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 after= wards */ --=20 2.17.2 From nobody Tue May 7 07:38:23 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1543383854840279.8484098875872; Tue, 27 Nov 2018 21:44:14 -0800 (PST) Received: from localhost ([::1]:46050 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gRsdn-0000Yf-BE for importer@patchew.org; Wed, 28 Nov 2018 00:44:03 -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) 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) 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-Google-Smtp-Source: AFSGD/WyxuEjN1e0Rb9lx6p7J5vhrZD1lm70Axn0VheFjO9s6QrmYBmuip2mA/dCNV8iPZB2XFomwA== X-Received: by 2002:a63:88c7:: with SMTP id l190mr31308104pgd.110.1543383523760; Tue, 27 Nov 2018 21:38:43 -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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: Emilio G. Cota --- tcg/tcg.c | 36 ++++++++++++++++++++++++------------ 1 file changed, 24 insertions(+), 12 deletions(-) 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 TCG= Op *op) =20 /* satisfy input constraints */=20 for (k =3D 0; k < nb_iargs; k++) { + TCGRegSet i_preferred_regs, o_preferred_regs; + i =3D def->sorted_args[nb_oargs + k]; arg =3D op->args[i]; arg_ct =3D &def->args_ct[i]; @@ -3245,17 +3247,18 @@ static void tcg_reg_alloc_op(TCGContext *s, const T= CGOp *op) /* constant is OK for instruction */ const_args[i] =3D 1; new_args[i] =3D ts->val; - goto iarg_end; + continue; } =20 - temp_load(s, ts, arg_ct->u.regs, i_allocated_regs, 0); - + i_preferred_regs =3D o_preferred_regs =3D 0; if (arg_ct->ct & TCG_CT_IALIAS) { + o_preferred_regs =3D 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 !=3D op->args[arg_ct->alias_index]) + if (arg !=3D 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 T= CGOp *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 =3D 0 ; k2 < k ; k2++) { - i2 =3D def->sorted_args[nb_oargs + k2]; - if ((def->args_ct[i2].ct & TCG_CT_IALIAS) && - (new_args[i2] =3D=3D ts->reg)) { - goto allocate_in_reg; + if (ts->val_type =3D=3D TEMP_VAL_REG) { + int k2, i2; + reg =3D ts->reg; + for (k2 =3D 0 ; k2 < k ; k2++) { + i2 =3D def->sorted_args[nb_oargs + k2]; + if ((def->args_ct[i2].ct & TCG_CT_IALIAS) && + reg =3D=3D new_args[i2]) { + goto allocate_in_reg; + } } } + i_preferred_regs =3D o_preferred_regs; } } + + temp_load(s, ts, arg_ct->u.regs, i_allocated_regs, i_preferred_reg= s); reg =3D 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=20 and move the temporary register into it */ + temp_load(s, ts, tcg_target_available_regs[ts->type], + i_allocated_regs, 0); reg =3D 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] =3D reg; const_args[i] =3D 0; tcg_regset_set_reg(i_allocated_regs, reg); - iarg_end: ; } =20 /* mark dead temporaries and free the associated registers */ --=20 2.17.2 From nobody Tue May 7 07:38:23 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1543384306723857.5312023281391; Tue, 27 Nov 2018 21:51:46 -0800 (PST) Received: from localhost ([::1]:46090 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gRslF-00074T-Q6 for importer@patchew.org; Wed, 28 Nov 2018 00:51: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) 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) 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-Google-Smtp-Source: AJdET5cb8X+OfgzsJTyxP2no8d7KO8wrzM25iHsmQvQFclIkcFVV8oSNLEjeDy6SChQkxmPlrS95Uw== X-Received: by 2002:a63:f141:: with SMTP id o1mr32379516pgk.134.1543383524930; 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Richard Henderson Reviewed-by: Emilio G. Cota --- tcg/tcg.h | 3 --- tcg/tcg.c | 44 +++++++++++++++++++++++++++++++++++++------- 2 files changed, 37 insertions(+), 10 deletions(-) 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); =20 void tcg_optimize(TCGContext *s); =20 -/* 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) } } =20 -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 +=3D qemu_log("%s$0x%" TCG_PRIlx, k ? "," : "", op->ar= gs[k]); } } - if (op->life) { - unsigned life =3D op->life; =20 - for (; col < 48; ++col) { + if (have_prefs || op->life) { + for (; col < 40; ++col) { putc(' ', qemu_logfile); } + } + + if (op->life) { + unsigned life =3D op->life; =20 if (life & (SYNC_ARG * 3)) { qemu_log(" sync:"); @@ -2081,6 +2084,33 @@ void tcg_dump_ops(TCGContext *s) } } } + + if (have_prefs) { + for (i =3D 0; i < nb_oargs; ++i) { + TCGRegSet set =3D op->output_pref[i]; + + if (i =3D=3D 0) { + qemu_log(" pref=3D"); + } else { + qemu_log(","); + } + if (set =3D=3D 0) { + qemu_log("none"); + } else if (set =3D=3D MAKE_64BIT_MASK(0, TCG_TARGET_NB_REG= S)) { + qemu_log("all"); +#ifdef CONFIG_DEBUG_TCG + } else if (tcg_regset_single(set)) { + TCGReg reg =3D tcg_regset_first(set); + qemu_log("%s", tcg_target_reg_names[reg]); +#endif + } else if (TCG_TARGET_NB_REGS <=3D 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(); } --=20 2.17.2 From nobody Tue May 7 07:38:23 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1543384040196821.5934948713223; Tue, 27 Nov 2018 21:47:20 -0800 (PST) Received: from localhost ([::1]:46070 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gRsgx-00033k-0l for importer@patchew.org; Wed, 28 Nov 2018 00:47:19 -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) 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) 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-Google-Smtp-Source: AFSGD/WdnmqpsrxnQz8Malrx4B1GzgOB/N2vC4zxP1RempC6NJ6aDzGproraracGsQkL1aJEAoX63g== X-Received: by 2002:a63:ff62:: with SMTP id s34mr32136752pgk.325.1543383526142; Tue, 27 Nov 2018 21:38:46 -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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: Emilio G. Cota --- tcg/tcg.c | 139 ++++++++++++++++++++++++++++-------------------------- 1 file changed, 71 insertions(+), 68 deletions(-) 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: =20 - /* output args are dead */ - for (i =3D 0; i < nb_oargs; i++) { - arg_ts =3D arg_temp(op->args[i]); - if (arg_ts->state & TS_DEAD) { - arg_life |=3D DEAD_ARG << i; - } - if (arg_ts->state & TS_MEM) { - arg_life |=3D SYNC_ARG << i; - } - arg_ts->state =3D TS_DEAD; + /* output args are dead */ + for (i =3D 0; i < nb_oargs; i++) { + arg_ts =3D arg_temp(op->args[i]); + if (arg_ts->state & TS_DEAD) { + arg_life |=3D DEAD_ARG << i; } + if (arg_ts->state & TS_MEM) { + arg_life |=3D SYNC_ARG << i; + } + arg_ts->state =3D TS_DEAD; + } =20 - if (!(call_flags & (TCG_CALL_NO_WRITE_GLOBALS | - TCG_CALL_NO_READ_GLOBALS))) { - /* globals should go back to memory */ - for (i =3D 0; i < nb_globals; i++) { - s->temps[i].state =3D TS_DEAD | TS_MEM; - } - } else if (!(call_flags & TCG_CALL_NO_READ_GLOBALS)) { - /* globals should be synced to memory */ - for (i =3D 0; i < nb_globals; i++) { - s->temps[i].state |=3D TS_MEM; - } + if (!(call_flags & (TCG_CALL_NO_WRITE_GLOBALS | + TCG_CALL_NO_READ_GLOBALS))) { + /* globals should go back to memory */ + for (i =3D 0; i < nb_globals; i++) { + s->temps[i].state =3D TS_DEAD | TS_MEM; } + } else if (!(call_flags & TCG_CALL_NO_READ_GLOBALS)) { + /* globals should be synced to memory */ + for (i =3D 0; i < nb_globals; i++) { + s->temps[i].state |=3D TS_MEM; + } + } =20 - /* record arguments that die in this helper */ - for (i =3D nb_oargs; i < nb_iargs + nb_oargs; i++) { - arg_ts =3D arg_temp(op->args[i]); - if (arg_ts && arg_ts->state & TS_DEAD) { - arg_life |=3D DEAD_ARG << i; - } + /* record arguments that die in this helper */ + for (i =3D nb_oargs; i < nb_iargs + nb_oargs; i++) { + arg_ts =3D arg_temp(op->args[i]); + if (arg_ts && arg_ts->state & TS_DEAD) { + arg_life |=3D DEAD_ARG << i; } - /* input arguments are live for preceding opcodes */ - for (i =3D nb_oargs; i < nb_iargs + nb_oargs; i++) { - arg_ts =3D arg_temp(op->args[i]); - if (arg_ts) { - arg_ts->state &=3D ~TS_DEAD; - } + } + /* input arguments are live for preceding opcodes */ + for (i =3D nb_oargs; i < nb_iargs + nb_oargs; i++) { + arg_ts =3D arg_temp(op->args[i]); + if (arg_ts) { + arg_ts->state &=3D ~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 =3D 0; i < nb_oargs; i++) { - arg_ts =3D arg_temp(op->args[i]); - if (arg_ts->state & TS_DEAD) { - arg_life |=3D DEAD_ARG << i; - } - if (arg_ts->state & TS_MEM) { - arg_life |=3D SYNC_ARG << i; - } - arg_ts->state =3D TS_DEAD; - } + goto do_remove; + } + goto do_not_remove; =20 - /* 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 =3D 0; i < nb_globals; i++) { - s->temps[i].state |=3D TS_MEM; - } - } + do_remove: + tcg_op_remove(s, op); + break; =20 - /* record arguments that die in this opcode */ - for (i =3D nb_oargs; i < nb_oargs + nb_iargs; i++) { - arg_ts =3D arg_temp(op->args[i]); - if (arg_ts->state & TS_DEAD) { - arg_life |=3D DEAD_ARG << i; - } + do_not_remove: + /* output args are dead */ + for (i =3D 0; i < nb_oargs; i++) { + arg_ts =3D arg_temp(op->args[i]); + if (arg_ts->state & TS_DEAD) { + arg_life |=3D DEAD_ARG << i; } - /* input arguments are live for preceding opcodes */ - for (i =3D nb_oargs; i < nb_oargs + nb_iargs; i++) { - arg_temp(op->args[i])->state &=3D ~TS_DEAD; + if (arg_ts->state & TS_MEM) { + arg_life |=3D SYNC_ARG << i; } + arg_ts->state =3D 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 =3D 0; i < nb_globals; i++) { + s->temps[i].state |=3D TS_MEM; + } + } + + /* record arguments that die in this opcode */ + for (i =3D nb_oargs; i < nb_oargs + nb_iargs; i++) { + arg_ts =3D arg_temp(op->args[i]); + if (arg_ts->state & TS_DEAD) { + arg_life |=3D DEAD_ARG << i; + } + } + /* input arguments are live for preceding opcodes */ + for (i =3D nb_oargs; i < nb_oargs + nb_iargs; i++) { + arg_temp(op->args[i])->state &=3D ~TS_DEAD; } break; } --=20 2.17.2 From nobody Tue May 7 07:38:23 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1543384069882505.21106002614465; Tue, 27 Nov 2018 21:47:49 -0800 (PST) Received: from localhost ([::1]:46071 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gRshM-0003JF-Nm for importer@patchew.org; Wed, 28 Nov 2018 00:47:44 -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) 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) 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-Google-Smtp-Source: AFSGD/V2BpXzQ6akNxzXw5b+skTe73w4RWnkh237qe/mQcqKmCudLqJ9JgNLCQq8FU0T5hUX0VeBVQ== X-Received: by 2002:a17:902:f082:: with SMTP id go2mr35602521plb.115.1543383527408; Tue, 27 Nov 2018 21:38:47 -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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: Emilio G. Cota --- tcg/tcg.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) 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) =20 /* 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 =3D s->nb_globals; - int nt =3D s->nb_temps; int i; =20 for (i =3D 0; i < ng; ++i) { @@ -2405,10 +2403,8 @@ static void tcg_la_func_end(TCGContext *s) =20 /* 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 =3D s->nb_globals; - int nt =3D s->nb_temps; int i; =20 for (i =3D 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 =3D s->nb_globals; + int nb_temps =3D s->nb_temps; TCGOp *op, *op_prev; =20 - tcg_la_func_end(s); + la_func_end(s, nb_globals, nb_temps); =20 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) =20 /* 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 =3D 0; i < nb_globals; i++) { --=20 2.17.2 From nobody Tue May 7 07:38:23 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1543384198935350.12203746807495; Tue, 27 Nov 2018 21:49:58 -0800 (PST) Received: from localhost ([::1]:46080 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gRsjH-0005sU-JK for importer@patchew.org; Wed, 28 Nov 2018 00:49: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) 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) 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-Google-Smtp-Source: AFSGD/UQBKYTHxCHpmldxXGVUV+zXxb4VR8amUn4+TGPIY3h5zMdDRlHLC4Blvh4ewehRlu9jZZy0Q== X-Received: by 2002:a17:902:714c:: with SMTP id u12mr35141985plm.234.1543383528635; 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Richard Henderson Reviewed-by: Emilio G. Cota --- tcg/tcg.c | 35 +++++++++++++++++++++++------------ 1 file changed, 23 insertions(+), 12 deletions(-) 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) } } =20 +/* liveness analysis: sync globals back to memory. */ +static void la_global_sync(TCGContext *s, int ng) +{ + int i; + + for (i =3D 0; i < ng; ++i) { + s->temps[i].state |=3D TS_MEM; + } +} + +/* liveness analysis: sync globals back to memory and kill. */ +static void la_global_kill(TCGContext *s, int ng) +{ + int i; + + for (i =3D 0; i < ng; i++) { + s->temps[i].state =3D 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) =20 if (!(call_flags & (TCG_CALL_NO_WRITE_GLOBALS | TCG_CALL_NO_READ_GLOBALS))) { - /* globals should go back to memory */ - for (i =3D 0; i < nb_globals; i++) { - s->temps[i].state =3D 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 =3D 0; i < nb_globals; i++) { - s->temps[i].state |=3D TS_MEM; - } + la_global_sync(s, nb_globals); } =20 /* 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 =3D 0; i < nb_globals; i++) { - s->temps[i].state |=3D TS_MEM; - } + la_global_sync(s, nb_globals); } =20 /* record arguments that die in this opcode */ --=20 2.17.2 From nobody Tue May 7 07:38:23 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1543383675982496.31113879863324; Tue, 27 Nov 2018 21:41:15 -0800 (PST) Received: from localhost ([::1]:46038 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gRsb0-0005ZQ-8L for importer@patchew.org; Wed, 28 Nov 2018 00:41:10 -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) 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) 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-Google-Smtp-Source: AJdET5eb41gdfJuSfb844Tf0vTRsBuIxP//IM0QUp9XBqS4NjMpPpxzgu6ESovy71h3hGnJNL3xv8Q== X-Received: by 2002:a62:a1a:: with SMTP id s26mr36210640pfi.31.1543383529747; 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: Emilio G. Cota --- tcg/tcg-opc.h | 7 ++++--- tcg/tcg.h | 14 ++++++++------ tcg/tcg.c | 5 ++++- 3 files changed, 16 insertions(+), 10 deletions(-) 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_m= ulsh_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)) =20 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 { =20 /* Bits for TCGOpDef->flags, 8 bits available. */ enum { + /* Instruction exits the translation block. */ + TCG_OPF_BB_EXIT =3D 0x01, /* Instruction defines the end of a basic block. */ - TCG_OPF_BB_END =3D 0x01, + TCG_OPF_BB_END =3D 0x02, /* Instruction clobbers call registers and potentially update globals.= */ - TCG_OPF_CALL_CLOBBER =3D 0x02, + TCG_OPF_CALL_CLOBBER =3D 0x04, /* Instruction has side effects: it cannot be removed if its outputs are not used, and might trigger exceptions. */ - TCG_OPF_SIDE_EFFECTS =3D 0x04, + TCG_OPF_SIDE_EFFECTS =3D 0x08, /* Instruction operands are 64-bits (otherwise 32-bits). */ - TCG_OPF_64BIT =3D 0x08, + TCG_OPF_64BIT =3D 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 =3D 0x10, + TCG_OPF_NOT_PRESENT =3D 0x20, /* Instruction operands are vectors. */ - TCG_OPF_VECTOR =3D 0x20, + TCG_OPF_VECTOR =3D 0x40, }; =20 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 =3D s->nb_temps; TCGOp *op, *op_prev; =20 + /* ??? Should be redundant with the exit_tb that ends the TB. */ la_func_end(s, nb_globals, nb_temps); =20 QTAILQ_FOREACH_REVERSE_SAFE(op, &s->ops, TCGOpHead, link, op_prev) { @@ -2634,7 +2635,9 @@ static void liveness_pass_1(TCGContext *s) } =20 /* 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); --=20 2.17.2 From nobody Tue May 7 07:38:23 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1543384034678929.0321551506854; Tue, 27 Nov 2018 21:47:14 -0800 (PST) Received: from localhost ([::1]:46068 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gRsgq-0002wc-Pm for importer@patchew.org; Wed, 28 Nov 2018 00:47:12 -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) 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) 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-Google-Smtp-Source: AFSGD/Us8eQIYRPovESkncK6m4DgsUwT/fLdJtfew0a9jBcDd0x/P2Xfe+fUp/2lP0SX1cmFdAilqA== X-Received: by 2002:a63:1b48:: with SMTP id b8mr32254069pgm.187.1543383531082; Tue, 27 Nov 2018 21:38:51 -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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: Emilio G. Cota --- tcg/tcg.c | 197 +++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 165 insertions(+), 32 deletions(-) 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))) =20 +/* 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) + =3D (ts->state =3D=3D 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 n= t) =20 for (i =3D 0; i < ng; ++i) { s->temps[i].state =3D TS_DEAD | TS_MEM; + la_reset_pref(&s->temps[i]); } for (i =3D ng; i < nt; ++i) { s->temps[i].state =3D TS_DEAD; + la_reset_pref(&s->temps[i]); } } =20 @@ -2409,11 +2426,13 @@ static void la_bb_end(TCGContext *s, int ng, int nt) =20 for (i =3D 0; i < ng; ++i) { s->temps[i].state =3D TS_DEAD | TS_MEM; + la_reset_pref(&s->temps[i]); } for (i =3D ng; i < nt; ++i) { s->temps[i].state =3D (s->temps[i].temp_local ? TS_DEAD | TS_MEM : TS_DEAD); + la_reset_pref(&s->temps[i]); } } =20 @@ -2423,7 +2442,12 @@ static void la_global_sync(TCGContext *s, int ng) int i; =20 for (i =3D 0; i < ng; ++i) { - s->temps[i].state |=3D TS_MEM; + int state =3D s->temps[i].state; + s->temps[i].state =3D state | TS_MEM; + if (state =3D=3D TS_DEAD) { + /* If the global was previously dead, reset prefs. */ + la_reset_pref(&s->temps[i]); + } } } =20 @@ -2434,6 +2458,29 @@ static void la_global_kill(TCGContext *s, int ng) =20 for (i =3D 0; i < ng; i++) { s->temps[i].state =3D 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 =3D ~tcg_target_call_clobber_regs; + int i; + + for (i =3D 0; i < nt; i++) { + TCGTemp *ts =3D &s->temps[i]; + if (!(ts->state & TS_DEAD)) { + TCGRegSet *pset =3D la_temp_pref(ts); + TCGRegSet set =3D *pset; + + set &=3D mask; + /* If the combination is not possible, restart. */ + if (set =3D=3D 0) { + set =3D tcg_target_available_regs[ts->type] & mask; + } + *pset =3D set; + } } } =20 @@ -2445,16 +2492,23 @@ static void liveness_pass_1(TCGContext *s) int nb_globals =3D s->nb_globals; int nb_temps =3D s->nb_temps; TCGOp *op, *op_prev; + TCGRegSet *prefs; + int i; + + prefs =3D tcg_malloc(sizeof(TCGRegSet) * nb_temps); + for (i =3D 0; i < nb_temps; ++i) { + s->temps[i].state_ptr =3D prefs + i; + } =20 /* ??? Should be redundant with the exit_tb that ends the TB. */ la_func_end(s, nb_globals, nb_temps); =20 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 =3D 0; - TCGTemp *arg_ts; + TCGTemp *ts; TCGOpcode opc =3D op->opc; const TCGOpDef *def =3D &tcg_op_defs[opc]; =20 @@ -2462,6 +2516,7 @@ static void liveness_pass_1(TCGContext *s) case INDEX_op_call: { int call_flags; + int nb_call_regs; =20 nb_oargs =3D TCGOP_CALLO(op); nb_iargs =3D 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 =3D 0; i < nb_oargs; i++) { - arg_ts =3D arg_temp(op->args[i]); - if (arg_ts->state !=3D TS_DEAD) { + ts =3D arg_temp(op->args[i]); + if (ts->state !=3D TS_DEAD) { goto do_not_remove_call; } } @@ -2479,16 +2534,20 @@ static void liveness_pass_1(TCGContext *s) } do_not_remove_call: =20 - /* output args are dead */ + /* Output args are dead. */ for (i =3D 0; i < nb_oargs; i++) { - arg_ts =3D arg_temp(op->args[i]); - if (arg_ts->state & TS_DEAD) { + ts =3D arg_temp(op->args[i]); + if (ts->state & TS_DEAD) { arg_life |=3D DEAD_ARG << i; } - if (arg_ts->state & TS_MEM) { + if (ts->state & TS_MEM) { arg_life |=3D SYNC_ARG << i; } - arg_ts->state =3D TS_DEAD; + ts->state =3D TS_DEAD; + la_reset_pref(ts); + + /* Not used -- it will be tcg_target_call_oarg_regs[i]= . */ + op->output_pref[i] =3D 0; } =20 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); } =20 - /* record arguments that die in this helper */ + /* Record arguments that die in this helper. */ for (i =3D nb_oargs; i < nb_iargs + nb_oargs; i++) { - arg_ts =3D arg_temp(op->args[i]); - if (arg_ts && arg_ts->state & TS_DEAD) { + ts =3D arg_temp(op->args[i]); + if (ts && ts->state & TS_DEAD) { arg_life |=3D DEAD_ARG << i; } } - /* input arguments are live for preceding opcodes */ - for (i =3D nb_oargs; i < nb_iargs + nb_oargs; i++) { - arg_ts =3D arg_temp(op->args[i]); - if (arg_ts) { - arg_ts->state &=3D ~TS_DEAD; + + /* For all live registers, remove call-clobbered prefs. */ + la_cross_call(s, nb_temps); + + nb_call_regs =3D ARRAY_SIZE(tcg_target_call_iarg_regs); + + /* Input arguments are live for preceding opcodes. */ + for (i =3D 0; i < nb_iargs; i++) { + ts =3D arg_temp(op->args[i + nb_oargs]); + if (ts && ts->state & TS_DEAD) { + /* For those arguments that die, and will be alloc= ated + * in registers, clear the register set for that a= rg, + * to be filled in below. For args that will be on + * the stack, reset to any available reg. + */ + *la_temp_pref(ts) + =3D (i < nb_call_regs ? 0 : + tcg_target_available_regs[ts->type]); + ts->state &=3D ~TS_DEAD; + } + } + + /* For each input argument, add its input register to pref= s. + If a temp is used once, this produces a single set bit.= */ + for (i =3D 0; i < MIN(nb_call_regs, nb_iargs); i++) { + ts =3D 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 =3D TS_DEAD; + ts =3D arg_temp(op->args[0]); + ts->state =3D TS_DEAD; + la_reset_pref(ts); break; =20 case INDEX_op_add2_i32: @@ -2622,43 +2707,91 @@ static void liveness_pass_1(TCGContext *s) break; =20 do_not_remove: - /* output args are dead */ for (i =3D 0; i < nb_oargs; i++) { - arg_ts =3D arg_temp(op->args[i]); - if (arg_ts->state & TS_DEAD) { + ts =3D arg_temp(op->args[i]); + + /* Remember the preference of the uses that followed. */ + op->output_pref[i] =3D *la_temp_pref(ts); + + /* Output args are dead. */ + if (ts->state & TS_DEAD) { arg_life |=3D DEAD_ARG << i; } - if (arg_ts->state & TS_MEM) { + if (ts->state & TS_MEM) { arg_life |=3D SYNC_ARG << i; } - arg_ts->state =3D TS_DEAD; + ts->state =3D TS_DEAD; + la_reset_pref(ts); } =20 - /* 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); + } } =20 - /* record arguments that die in this opcode */ + /* Record arguments that die in this opcode. */ for (i =3D nb_oargs; i < nb_oargs + nb_iargs; i++) { - arg_ts =3D arg_temp(op->args[i]); - if (arg_ts->state & TS_DEAD) { + ts =3D arg_temp(op->args[i]); + if (ts->state & TS_DEAD) { arg_life |=3D DEAD_ARG << i; } } - /* input arguments are live for preceding opcodes */ + + /* Input arguments are live for preceding opcodes. */ for (i =3D nb_oargs; i < nb_oargs + nb_iargs; i++) { - arg_temp(op->args[i])->state &=3D ~TS_DEAD; + ts =3D 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) =3D tcg_target_available_regs[ts->ty= pe]; + ts->state &=3D ~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])) + =3D *la_temp_pref(arg_temp(op->args[1])); + } + break; + + default: + for (i =3D nb_oargs; i < nb_oargs + nb_iargs; i++) { + const TCGArgConstraint *ct =3D &def->args_ct[i]; + TCGRegSet set, *pset; + + ts =3D arg_temp(op->args[i]); + pset =3D la_temp_pref(ts); + set =3D *pset; + + set &=3D ct->u.regs; + if (ct->ct & TCG_CT_IALIAS) { + set &=3D op->output_pref[ct->alias_index]; + } + /* If the combination is not possible, restart. */ + if (set =3D=3D 0) { + set =3D ct->u.regs; + } + *pset =3D set; + } + break; } break; } op->life =3D arg_life; - op->output_pref[0] =3D 0; - op->output_pref[1] =3D 0; } } =20 --=20 2.17.2