From patchwork Sun Mar 17 09:08:22 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 160459 Delivered-To: patch@linaro.org Received: by 2002:a02:5cc1:0:0:0:0:0 with SMTP id w62csp1404099jad; Sun, 17 Mar 2019 02:09:11 -0700 (PDT) X-Google-Smtp-Source: APXvYqw7/aELjUlyu/gdt6bC+04O7xkJWxBRvvdktv1A8UvQjjkkSf3+KhQ7yLHX96kpUjxIAv3x X-Received: by 2002:a05:6000:46:: with SMTP id k6mr8074038wrx.319.1552813751095; Sun, 17 Mar 2019 02:09:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552813751; cv=none; d=google.com; s=arc-20160816; b=v3YGlmmMVDRT9x20jSwp080MLvUyCjNfSuzxvZhsxEPJbuuvLw5Fpz73uBHEvpF6Ew 8f9BISf6BvjUKOg5oKAHCnSETuAekWasOIiPmWKjLwqzIwMhkG0KanVghHXTFcFYpx4A 0shGWmSkLr+/2FOh0v/3hBGxqhHlQAvfRVMIkCz0boIEtQ0/6tmhsGrdHToC4Z0bLbT7 mKKMYbn0XqwyeLSDWdR9zdNjfj3P+QgCVFSw4MPvCFNgTJVZkfNQsX2Zk3gvB4qWTIlD jyvg/nastx5OdrC5yGh0IaEKQejH4ZdCyUVkWgyEfEjVLSiahra2frh40NZ2vEcXNg2w aS3Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=hodYlcpRqUFAyF1u9EayD/KhJ3+IN8OK9GoDdoOHadc=; b=aDYxF4iJP02WD+xMdK3qwzEL9VuyYR8qyv0WcWOdvkL7oy/xulB78ah9C4T288kvX1 OmTqwmlnuhL+lFheV4+ASuJkDqhy/1qoFzDkazgJhv/X5fWkF8yIDF0LqKHzf1UL1hyG XkLfdo5ZnzM48FD2ZJVS5g4qynRkB6qpWw9BCYNX578dh1ojsV4nJNW4sIzEfhOaHaEP aNFTUhoQdRfA36+vlJV1C8JoMODrjvpj9sMKlmf/ZyibGs1Lv2LjDRw0rmvaAYHEVPWN p3AIOB5CFE5hHunId4Cstgwxf4QH985obl2WRSP0hePDuSiCMy9tZ6lxFajAmdP02NKy 5nAg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="sg/YFPkJ"; 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=fail (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 25si1823429wmi.101.2019.03.17.02.09.10 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sun, 17 Mar 2019 02:09:11 -0700 (PDT) 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=fail header.i=@linaro.org header.s=google header.b="sg/YFPkJ"; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1]:52071 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h5Rn3-0005cS-TI for patch@linaro.org; Sun, 17 Mar 2019 05:09:09 -0400 Received: from eggs.gnu.org ([209.51.188.92]:47633) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h5Rmb-0005bq-RK for qemu-devel@nongnu.org; Sun, 17 Mar 2019 05:08:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h5Rma-00045N-C5 for qemu-devel@nongnu.org; Sun, 17 Mar 2019 05:08:41 -0400 Received: from mail-pf1-x443.google.com ([2607:f8b0:4864:20::443]:41137) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1h5RmZ-00043a-UJ for qemu-devel@nongnu.org; Sun, 17 Mar 2019 05:08:40 -0400 Received: by mail-pf1-x443.google.com with SMTP id d25so9218896pfn.8 for ; Sun, 17 Mar 2019 02:08:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=hodYlcpRqUFAyF1u9EayD/KhJ3+IN8OK9GoDdoOHadc=; b=sg/YFPkJc52rgWQSSHVmujtSIe3QcNEJx+qFQJgxLNu6itx8oXd+olblfinDiNc8f9 BY/vQMLViTEQyDtjl6F8LdExhQeeTEPEoJTwqBWheWW+oFk1R0xGC6VGQ7zQnLRoEhVv 4R0oGc36Gkhxz/IJCnqAi69QAmCsrQoVAOl3RNNgP26u5dF2Nx6y/Y9k9pfDdQxYvNnC U4e2lZWgYkz/yrPCjJ8cvAyOSYm4HpNVdsKk8oBJrckHRovlfUrQdk0sMJTP8qWR5Vuh l+d6aiIuuPWz8nayW7DWl2AZ1eywiTz4J8J+rfaTLE4olz0GQOMkOsy2SaeC5MvhlxXc DG1A== 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=hodYlcpRqUFAyF1u9EayD/KhJ3+IN8OK9GoDdoOHadc=; b=WChpNUydcPDgMIi35E26t5cKscgO/R3rkO4zTaxBJjNP2k/HUm5PN3XHObf2JpyCfG QvNp9g4vYvjblAitXKKauY/atlpP+kdv1CsEvjBfduOa0F+GtRvzTwj6E6iIWvMIMvyl nnZpxsfY4Kdqk8BFZQzoMoETQqAHi/Vx9S3D5hGsDyUN/dQrJXtLKypEwcy+TXrKADnL ItIra5HOYXRA7r/pwDB7JWAylpagUmsPh+SexgRwmtONZoJlVJ2rIffnxUtd/Dya49Vq u1whMA/RTOb1npWPh8G+PrvsdJeAjuyE7b9FzbL50Soq0jNpoSoZVdM7Z55Nf2TXLCQn Wy9w== X-Gm-Message-State: APjAAAXAmh/S1dvQYq1ous72jmOnU/oHKCnJFBVrEjhsCF77zLYVwrhw 2ctOOgdW3lryvTqxJKwvjCL08IWaaHY= X-Received: by 2002:a17:902:1121:: with SMTP id d30mr13887081pla.104.1552813718215; Sun, 17 Mar 2019 02:08:38 -0700 (PDT) Received: from cloudburst.twiddle.net (97-113-188-82.tukw.qwest.net. [97.113.188.82]) by smtp.gmail.com with ESMTPSA id b85sm19378435pfj.56.2019.03.17.02.08.37 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 17 Mar 2019 02:08:37 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sun, 17 Mar 2019 02:08:22 -0700 Message-Id: <20190317090834.5552-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20190317090834.5552-1-richard.henderson@linaro.org> References: <20190317090834.5552-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::443 Subject: [Qemu-devel] [PATCH for-4.1 v2 01/13] tcg: Assert fixed_reg is read-only 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: mark.cave-ayland@ilande.co.uk, david@gibson.dropbear.id.au Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" The only fixed_reg is cpu_env, and it should not be modified during any TB. Therefore code that tries to special-case moves into a fixed_reg is dead. Remove it. Signed-off-by: Richard Henderson --- tcg/tcg.c | 85 +++++++++++++++++++++++++------------------------------ 1 file changed, 38 insertions(+), 47 deletions(-) -- 2.17.2 diff --git a/tcg/tcg.c b/tcg/tcg.c index 9b2bf7f439..6f320a4849 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -3275,11 +3275,8 @@ static void tcg_reg_alloc_do_movi(TCGContext *s, TCGTemp *ots, tcg_target_ulong val, TCGLifeData arg_life, TCGRegSet preferred_regs) { - if (ots->fixed_reg) { - /* For fixed registers, we do not do any constant propagation. */ - tcg_out_movi(s, ots->type, ots->reg, val); - return; - } + /* ENV should not be modified. */ + tcg_debug_assert(!ots->fixed_reg); /* The movi is not explicitly generated here. */ if (ots->val_type == TEMP_VAL_REG) { @@ -3315,6 +3312,9 @@ static void tcg_reg_alloc_mov(TCGContext *s, const TCGOp *op) ots = arg_temp(op->args[0]); ts = arg_temp(op->args[1]); + /* ENV should not be modified. */ + tcg_debug_assert(!ots->fixed_reg); + /* Note that otype != itype for no-op truncation. */ otype = ots->type; itype = ts->type; @@ -3339,7 +3339,7 @@ static void tcg_reg_alloc_mov(TCGContext *s, const TCGOp *op) } tcg_debug_assert(ts->val_type == TEMP_VAL_REG); - if (IS_DEAD_ARG(0) && !ots->fixed_reg) { + if (IS_DEAD_ARG(0)) { /* mov to a non-saved dead register makes no sense (even with liveness analysis disabled). */ tcg_debug_assert(NEED_SYNC_ARG(0)); @@ -3352,7 +3352,7 @@ static void tcg_reg_alloc_mov(TCGContext *s, const TCGOp *op) } temp_dead(s, ots); } else { - if (IS_DEAD_ARG(1) && !ts->fixed_reg && !ots->fixed_reg) { + if (IS_DEAD_ARG(1) && !ts->fixed_reg) { /* the mov can be suppressed */ if (ots->val_type == TEMP_VAL_REG) { s->reg_to_temp[ots->reg] = NULL; @@ -3505,6 +3505,10 @@ static void tcg_reg_alloc_op(TCGContext *s, const TCGOp *op) arg = op->args[i]; arg_ct = &def->args_ct[i]; ts = arg_temp(arg); + + /* ENV should not be modified. */ + tcg_debug_assert(!ts->fixed_reg); + if ((arg_ct->ct & TCG_CT_ALIAS) && !const_args[arg_ct->alias_index]) { reg = new_args[arg_ct->alias_index]; @@ -3513,29 +3517,19 @@ static void tcg_reg_alloc_op(TCGContext *s, const TCGOp *op) i_allocated_regs | o_allocated_regs, op->output_pref[k], ts->indirect_base); } else { - /* if fixed register, we try to use it */ - reg = ts->reg; - if (ts->fixed_reg && - tcg_regset_test_reg(arg_ct->u.regs, reg)) { - goto oarg_end; - } reg = tcg_reg_alloc(s, arg_ct->u.regs, o_allocated_regs, op->output_pref[k], ts->indirect_base); } tcg_regset_set_reg(o_allocated_regs, reg); - /* if a fixed register is used, then a move will be done afterwards */ - if (!ts->fixed_reg) { - if (ts->val_type == TEMP_VAL_REG) { - s->reg_to_temp[ts->reg] = NULL; - } - ts->val_type = TEMP_VAL_REG; - ts->reg = reg; - /* temp value is modified, so the value kept in memory is - potentially not the same */ - ts->mem_coherent = 0; - s->reg_to_temp[reg] = ts; + if (ts->val_type == TEMP_VAL_REG) { + s->reg_to_temp[ts->reg] = NULL; } - oarg_end: + ts->val_type = TEMP_VAL_REG; + ts->reg = reg; + /* temp value is modified, so the value kept in memory is + potentially not the same */ + ts->mem_coherent = 0; + s->reg_to_temp[reg] = ts; new_args[i] = reg; } } @@ -3551,10 +3545,10 @@ static void tcg_reg_alloc_op(TCGContext *s, const TCGOp *op) /* move the outputs in the correct register if needed */ for(i = 0; i < nb_oargs; i++) { ts = arg_temp(op->args[i]); - reg = new_args[i]; - if (ts->fixed_reg && ts->reg != reg) { - tcg_out_mov(s, ts->type, ts->reg, reg); - } + + /* ENV should not be modified. */ + tcg_debug_assert(!ts->fixed_reg); + if (NEED_SYNC_ARG(i)) { temp_sync(s, ts, o_allocated_regs, 0, IS_DEAD_ARG(i)); } else if (IS_DEAD_ARG(i)) { @@ -3675,26 +3669,23 @@ static void tcg_reg_alloc_call(TCGContext *s, TCGOp *op) for(i = 0; i < nb_oargs; i++) { arg = op->args[i]; ts = arg_temp(arg); + + /* ENV should not be modified. */ + tcg_debug_assert(!ts->fixed_reg); + reg = tcg_target_call_oarg_regs[i]; tcg_debug_assert(s->reg_to_temp[reg] == NULL); - - if (ts->fixed_reg) { - if (ts->reg != reg) { - tcg_out_mov(s, ts->type, ts->reg, reg); - } - } else { - if (ts->val_type == TEMP_VAL_REG) { - s->reg_to_temp[ts->reg] = NULL; - } - ts->val_type = TEMP_VAL_REG; - ts->reg = reg; - ts->mem_coherent = 0; - s->reg_to_temp[reg] = ts; - if (NEED_SYNC_ARG(i)) { - temp_sync(s, ts, allocated_regs, 0, IS_DEAD_ARG(i)); - } else if (IS_DEAD_ARG(i)) { - temp_dead(s, ts); - } + if (ts->val_type == TEMP_VAL_REG) { + s->reg_to_temp[ts->reg] = NULL; + } + ts->val_type = TEMP_VAL_REG; + ts->reg = reg; + ts->mem_coherent = 0; + s->reg_to_temp[reg] = ts; + if (NEED_SYNC_ARG(i)) { + temp_sync(s, ts, allocated_regs, 0, IS_DEAD_ARG(i)); + } else if (IS_DEAD_ARG(i)) { + temp_dead(s, ts); } } }