From patchwork Mon Dec 19 22:09:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 635133 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp2586603pvb; Mon, 19 Dec 2022 14:10:02 -0800 (PST) X-Google-Smtp-Source: AMrXdXv+RhaGftIYzyNTxVYt2zIo8IuomnMsZX9XUi5bbxmLaaUYnoU1FSU+0yYcuWb5KuuP0I0F X-Received: by 2002:a1f:bfd5:0:b0:3d3:1c0b:1b05 with SMTP id p204-20020a1fbfd5000000b003d31c0b1b05mr1897024vkf.16.1671487802203; Mon, 19 Dec 2022 14:10:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671487802; cv=none; d=google.com; s=arc-20160816; b=CtDHtSxB/98ih7phNJempIoypKnU4Wn3wN7HwMUnWIVB53mloNFK6zVZwuy9XQcHDf Kh3m9AlYdte+i45qQVysMrrgsnvMxhU6a1erc8mZtQMit1uqSXtY6xlWabOnN5vwiuEY 2UecERSyC3Qew5Mlz1PjcN0zUVdTXk07RjW0xGn9BmWGbvPGP+Ov0IQ9gQURBmFOjIt9 5gk6UWC6WYhvv2oX0dgeDYsJJtVo0yqqjxxjKBOHL0CgPKv1Q9B5zGXWXnrkS39P1JAT 712Re6JXvSW05P6f6gGUU/dUg1ymfbLxA6DUPmqHiYvQc5yonP1ns2DsY4q485ECnMao Hb0A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=yCa7rvoOYcxml3sS30mPGNdG0+HY4We04jGWTlwlZdc=; b=ufmeT4QgYW+Z9WQUy0P1Ab3xKi2h84TDT+70uNbmra9GODUwqNISWs8whazIMImkoc TlKgV5m6VDZLgZkCIBuCum9149yMYspyvXLp5hvXL0FOSK5D8JC26xVvVdWor84LHLzC sgmDK6vHl7NZ4cBTfMoWae8QooHCltTez9TTjrRc+UVpBJihPpFQxE5QT2lRk2xlkJfs AElIAFVo0sNnejcO97YZhkze+I6aFEYWOE9uS4jN0gz4XAfQIfxpItOIs1Gp1BmY20UZ tQigO4VTxwQ7bqr7F5UUBDzlMShr6vPWvQ5VQZi/ZBu1bkTgHm3tmg2438EjMs85yo4U gIDA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=PMkj27Tx; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 14-20020a370b0e000000b006fec5eab391si4234559qkl.131.2022.12.19.14.10.02 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 19 Dec 2022 14:10:02 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=PMkj27Tx; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p7OKT-0008T7-PR; Mon, 19 Dec 2022 17:09:49 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p7OKO-0008Si-OJ for qemu-devel@nongnu.org; Mon, 19 Dec 2022 17:09:44 -0500 Received: from mail-ej1-x633.google.com ([2a00:1450:4864:20::633]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1p7OKL-0003w1-7r for qemu-devel@nongnu.org; Mon, 19 Dec 2022 17:09:43 -0500 Received: by mail-ej1-x633.google.com with SMTP id t17so25020363eju.1 for ; Mon, 19 Dec 2022 14:09:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=yCa7rvoOYcxml3sS30mPGNdG0+HY4We04jGWTlwlZdc=; b=PMkj27TxQgGqg5m4Ns5gh4z04rnBroFHUS4EzR7nOMnbXp+gmzwDbSXXMezMvZH2uD F0BpSLH8mDAWx8b4AMTGUdyDXmttcDJDbbDmPZklD/4HhuNIa/54LkPh8Tw5dmxIRdVz SP5nBlhQ+SjWXSAh5V3voTrJFZDZfwfPB3C+EdxZhrASdauBIcBoCZKLsWKtDn626IT2 UEJJMR5YSkZlvdaNPuj7iuut4cdBtAF6UmOdphBSVlxyQvGW+BDMZ8zpZOh2OActtNuO sIKJCvhVzhZcIOKYBNSZaDbh1kSkCbwFgGK5yFXcbw0Myfztz16ohfR0OKivo3JBVr59 eH9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=yCa7rvoOYcxml3sS30mPGNdG0+HY4We04jGWTlwlZdc=; b=RMNuU3GrMYj0EyoSmiVSMpHKn2mp69kKx9UKxuoIecnBKkyIm9n9ULSyFUck0GBUyX FKJq1U5ZLT5JN9KNQXVz4bnhfsninZFkOnOrFHNLE37Hbt2epMB1g2z/FlMVD1sbcXfV VN5yGEV/HPzyCPFAI+GcMsrZliVbHwaf+QUo6NyUblpssEdNqgYqaBwYXXjaNKUBdFq5 ugJKAEGkCrUGXGkpm4LImHchSxfnPi9qQf9OzXbQax83p8/LGFBzJSyjneAdpL695nGR qpYGtOQxPxS01Akg0MyDgF08sYnHJXnydnpEaJwDkuBkfdUmTtv1JDITXYO3vDev145L EN1Q== X-Gm-Message-State: ANoB5pnlzm9KvpHpJnRW477tIJ6nRR9wmG+mv3OKLxqLq/8jT2ZdQHP4 92tXg5Ruxuqt4Ramqk8uSsDkaf0DKUraiqerGNI= X-Received: by 2002:a17:906:6bda:b0:7c0:eb38:f8af with SMTP id t26-20020a1709066bda00b007c0eb38f8afmr37701382ejs.2.1671487779579; Mon, 19 Dec 2022 14:09:39 -0800 (PST) Received: from localhost.localdomain ([185.126.107.38]) by smtp.gmail.com with ESMTPSA id s17-20020a170906355100b007aef930360asm4844015eja.59.2022.12.19.14.09.38 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 19 Dec 2022 14:09:38 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Richard Henderson , =?utf-8?q?Philippe_Mat?= =?utf-8?q?hieu-Daud=C3=A9?= Subject: [PATCH v4 04b/27] tcg: Massage tcg_reg_alloc_op() Date: Mon, 19 Dec 2022 23:09:24 +0100 Message-Id: <20221219220925.79218-3-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221219220925.79218-1-philmd@linaro.org> References: <20221213212541.1820840-5-richard.henderson@linaro.org> <20221219220925.79218-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::633; envelope-from=philmd@linaro.org; helo=mail-ej1-x633.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org In preparation of introducing paired registers in the next commit, massage tcg_reg_alloc_op() a bit by converting it to a switch with a single case: the current non-paired register. Signed-off-by: Richard Henderson [PMD: Split from bigger patch, 2/3] Signed-off-by: Philippe Mathieu-Daudé --- include/tcg/tcg.h | 1 + tcg/tcg.c | 98 ++++++++++++++++++++++++++++------------------- 2 files changed, 59 insertions(+), 40 deletions(-) diff --git a/include/tcg/tcg.h b/include/tcg/tcg.h index d84bae6e3f..2f7bbf4882 100644 --- a/include/tcg/tcg.h +++ b/include/tcg/tcg.h @@ -951,6 +951,7 @@ typedef struct TCGArgConstraint { unsigned ct : 16; unsigned alias_index : 4; unsigned sort_index : 4; + unsigned pair : 1; /* 0: not paired, 1: illegal */ bool oalias : 1; bool ialias : 1; bool newreg : 1; diff --git a/tcg/tcg.c b/tcg/tcg.c index 92141bd79a..67cf36ace8 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -3550,8 +3550,8 @@ static void tcg_reg_alloc_op(TCGContext *s, const TCGOp *op) /* satisfy input constraints */ for (k = 0; k < nb_iargs; k++) { - TCGRegSet i_preferred_regs; - bool allocate_new_reg; + TCGRegSet i_preferred_regs, i_required_regs; + bool allocate_new_reg, copyto_new_reg; i = def->args_ct[nb_oargs + k].sort_index; arg = op->args[i]; @@ -3568,43 +3568,54 @@ static void tcg_reg_alloc_op(TCGContext *s, const TCGOp *op) reg = ts->reg; i_preferred_regs = 0; + i_required_regs = arg_ct->regs; allocate_new_reg = false; + copyto_new_reg = false; - if (arg_ct->ialias) { - i_preferred_regs = op->output_pref[arg_ct->alias_index]; + switch (arg_ct->pair) { + case 0: /* not paired */ + if (arg_ct->ialias) { + i_preferred_regs = op->output_pref[arg_ct->alias_index]; - /* - * If the input is readonly, then it cannot also be an - * output and aliased to itself. If the input is not - * dead after the instruction, we must allocate a new - * register and move it. - */ - if (temp_readonly(ts) || !IS_DEAD_ARG(i)) { - allocate_new_reg = true; - } else if (ts->val_type == TEMP_VAL_REG) { /* - * Check if the current register has already been - * allocated for another input. + * If the input is not dead after the instruction, + * we must allocate a new register and move it. */ - allocate_new_reg = tcg_regset_test_reg(i_allocated_regs, reg); + if (!IS_DEAD_ARG(i)) { + allocate_new_reg = true; + } else if (ts->val_type == TEMP_VAL_REG) { + /* + * Check if the current register has already been + * allocated for another input. + */ + allocate_new_reg = + tcg_regset_test_reg(i_allocated_regs, reg); + } } + if (!allocate_new_reg) { + temp_load(s, ts, i_required_regs, i_allocated_regs, + i_preferred_regs); + reg = ts->reg; + allocate_new_reg = !tcg_regset_test_reg(i_required_regs, reg); + } + if (allocate_new_reg) { + /* + * Allocate a new register matching the constraint + * and move the temporary register into it. + */ + temp_load(s, ts, tcg_target_available_regs[ts->type], + i_allocated_regs, 0); + reg = tcg_reg_alloc(s, i_required_regs, i_allocated_regs, + i_preferred_regs, ts->indirect_base); + copyto_new_reg = true; + } + break; + + default: + g_assert_not_reached(); } - if (!allocate_new_reg) { - temp_load(s, ts, arg_ct->regs, i_allocated_regs, i_preferred_regs); - reg = ts->reg; - allocate_new_reg = !tcg_regset_test_reg(arg_ct->regs, reg); - } - - if (allocate_new_reg) { - /* - * Allocate a new register matching the constraint - * and move the temporary register into it. - */ - temp_load(s, ts, tcg_target_available_regs[ts->type], - i_allocated_regs, 0); - reg = tcg_reg_alloc(s, arg_ct->regs, i_allocated_regs, - i_preferred_regs, ts->indirect_base); + if (copyto_new_reg) { if (!tcg_out_mov(s, ts->type, reg, ts->reg)) { /* * Cross register class move not supported. Sync the @@ -3656,15 +3667,22 @@ static void tcg_reg_alloc_op(TCGContext *s, const TCGOp *op) /* ENV should not be modified. */ tcg_debug_assert(!temp_readonly(ts)); - if (arg_ct->oalias && !const_args[arg_ct->alias_index]) { - reg = new_args[arg_ct->alias_index]; - } else if (arg_ct->newreg) { - reg = tcg_reg_alloc(s, arg_ct->regs, - i_allocated_regs | o_allocated_regs, - op->output_pref[k], ts->indirect_base); - } else { - reg = tcg_reg_alloc(s, arg_ct->regs, o_allocated_regs, - op->output_pref[k], ts->indirect_base); + switch (arg_ct->pair) { + case 0: /* not paired */ + if (arg_ct->oalias && !const_args[arg_ct->alias_index]) { + reg = new_args[arg_ct->alias_index]; + } else if (arg_ct->newreg) { + reg = tcg_reg_alloc(s, arg_ct->regs, + i_allocated_regs | o_allocated_regs, + op->output_pref[k], ts->indirect_base); + } else { + reg = tcg_reg_alloc(s, arg_ct->regs, o_allocated_regs, + op->output_pref[k], ts->indirect_base); + } + break; + + default: + g_assert_not_reached(); } tcg_regset_set_reg(o_allocated_regs, reg); set_temp_val_reg(s, ts, reg);