From patchwork Tue Jun 1 15:00:41 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 451393 Delivered-To: patch@linaro.org Received: by 2002:a02:c735:0:0:0:0:0 with SMTP id h21csp1870875jao; Tue, 1 Jun 2021 08:08:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxiHTVsNIBkrVtye1Ur8EpGBjzFHF9jgSSNFiajDJMJhe80gN9R+qJtZ3JjfSj+lcqVBb/w X-Received: by 2002:a05:600c:35cc:: with SMTP id r12mr4875wmq.1.1622560122372; Tue, 01 Jun 2021 08:08:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622560122; cv=none; d=google.com; s=arc-20160816; b=VLiRlp4VUD5gqNUhu2pAyEyfBJvN2vGzHSUZXGTxLpRaujVDKNpSwE61ectJBzrxJW dark8+FRT9TDIgF2iKd45hINCiSnrBtS6mcLwIVyNr71T539rkrjzExDLotIdoCHYtmo bYIGFLDmY8iIzQGcbRZUSsUCGVb0/PtlrIat53StE82Dh4OM6U1XUJG2tTXkdtLzZnTT eE5W2PG5fUEB9Bn5vRnI/MHv0GyjWxuoYAlMHN/IVtnczP4QjdFN03lPoOI7VV9qcsJ0 4aepcOl62Nf9++ABVmGLAVN6zShWS8NDEk+EwGity41IIEFP88F/tl82Ebn4lQ3AGxS0 G4uA== 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:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=Ht8N/KCBkjYSaUObM7d0Vb7s6Kg841z61eMFrL9GxjQ=; b=kAZ+6RmPk+Wvnzgp/cXeGbDwxcrIFevX2aa/HNBa25Lk2Qt7PVHAhMnoy07Q2WJKk2 6xqyaeIt6+ioeBazTDmHmV0v4uw33JCofkFCnh2yu1GrmhQq+rcza2oC536/3BRdkdnk oamAFd8vZ5J+g1pffrPGSvlkCeuwE7vKNAzgg+SLoJheMbjh7w2OOF/750DXq0MmlHVY p+Rd3Dugm7ZY+Duujq1g5lrqMICQzCkFBDqTvgTSuurDdTDXhLPRwN1AGGQXkTuJK7fN xrAOgQA0J1yC0jK3PET8diukviOQ4TZfgRL8AlWbXfvzoGMZ7YL583xAkQR4WxKfp9U4 9Mkg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="fX5t/xWW"; 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 a8si15936916ejc.334.2021.06.01.08.08.42 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 01 Jun 2021 08:08:42 -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=pass header.i=@linaro.org header.s=google header.b="fX5t/xWW"; 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]:52506 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lo60X-0004zd-AA for patch@linaro.org; Tue, 01 Jun 2021 11:08:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36260) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lo5tL-0002Ak-W7 for qemu-devel@nongnu.org; Tue, 01 Jun 2021 11:01:16 -0400 Received: from mail-il1-x12a.google.com ([2607:f8b0:4864:20::12a]:35617) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lo5tJ-0002Ti-Lg for qemu-devel@nongnu.org; Tue, 01 Jun 2021 11:01:15 -0400 Received: by mail-il1-x12a.google.com with SMTP id b9so5544910ilr.2 for ; Tue, 01 Jun 2021 08:01:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Ht8N/KCBkjYSaUObM7d0Vb7s6Kg841z61eMFrL9GxjQ=; b=fX5t/xWWsLUezaqgJ/f2SeQUlXEC0zZuf1ivvvtwHA6b8o5cbu1LLpz4EhD30q5J5b JWlSfoOwT//+z5/0YBjSZHkbOUZ+rY48iSwISxgVI/q0/b/qmULTtcdH25429g49p8iT fbrHN57Mm00B9/KcWS0VKbQvGVrO2mj4lqG2w7E9aN7Q6ftDtR40ZTOlCIvqeFttelWz LEmYKHUpGd8RRKHaZRmJ/qxKYlwYTjfRvXsGZk31kTytJoQ6aBDkpNJmw3O91SBUUaAa hEXZxvOkDGCBH90Noz8ocRIBQgja2AJOt0gibEdeEIRng5Csk1oJ2KeGig7EMCSzbZgb Fudg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Ht8N/KCBkjYSaUObM7d0Vb7s6Kg841z61eMFrL9GxjQ=; b=nCz7FdHO7sXE7QNzJ4lJgBiXxeJ/+IJRE5jnX7C8viFPdoLHre5pc1CVTwQTWSkKuH BngNdJQ4YQB/oxkPXHwQb6LMO6y2bjzXfDEKRdk1/Dk5AVZvMWVc/SHUE9SbOr/7ye2J TmKAC6J7/3oqPQ0GzL88zduXZVdvvuYvH1gO5vFymPSbqtApP1rbRsPNFbh3Btb0rvhC lz0FqUKY44uz8Gxqttc0dC7b/j1cqWOfqaIezq/N5TDPSFdQpMZGjxXHqeBlE9iLuxaH w05l/V9S8OC3yOpyAkUW2wimNHjhb4AJm4Ud/fHechNC/NT7kRYCecjXreGnaULk3ioa SKAA== X-Gm-Message-State: AOAM531PoeyVuQylfgYMgf4ZrBakxIswwNj/6GQlxhhwc1yv7297OjV0 Kx8WxwKrHDYiQmpmiWQqv9QtJ321wdM4YbJT X-Received: by 2002:a92:b506:: with SMTP id f6mr9779747ile.148.1622559672505; Tue, 01 Jun 2021 08:01:12 -0700 (PDT) Received: from localhost.localdomain ([2607:fb90:806c:3e8a:9cf0:b3be:5e07:b99f]) by smtp.gmail.com with ESMTPSA id f8sm4109909ilj.37.2021.06.01.08.01.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Jun 2021 08:01:12 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v7 02/27] tcg: Add tcg_call_flags Date: Tue, 1 Jun 2021 08:00:41 -0700 Message-Id: <20210601150106.12761-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210601150106.12761-1-richard.henderson@linaro.org> References: <20210601150106.12761-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::12a; envelope-from=richard.henderson@linaro.org; helo=mail-il1-x12a.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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" We're going to change how to look up the call flags from a TCGop, so extract it as a helper. Tested-by: Philippe Mathieu-Daudé Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- tcg/internal.h | 33 +++++++++++++++++++++++++++++++++ tcg/optimize.c | 3 ++- tcg/tcg.c | 15 +++++++-------- 3 files changed, 42 insertions(+), 9 deletions(-) create mode 100644 tcg/internal.h -- 2.25.1 diff --git a/tcg/internal.h b/tcg/internal.h new file mode 100644 index 0000000000..35a8a0d9fa --- /dev/null +++ b/tcg/internal.h @@ -0,0 +1,33 @@ +/* + * Internal declarations for Tiny Code Generator for QEMU + * + * Copyright (c) 2008 Fabrice Bellard + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#ifndef TCG_INTERNAL_H +#define TCG_INTERNAL_H 1 + +static inline unsigned tcg_call_flags(TCGOp *op) +{ + return op->args[TCGOP_CALLO(op) + TCGOP_CALLI(op) + 1]; +} + +#endif /* TCG_INTERNAL_H */ diff --git a/tcg/optimize.c b/tcg/optimize.c index 37c902283e..081b62798e 100644 --- a/tcg/optimize.c +++ b/tcg/optimize.c @@ -25,6 +25,7 @@ #include "qemu/osdep.h" #include "tcg/tcg-op.h" +#include "internal.h" #define CASE_OP_32_64(x) \ glue(glue(case INDEX_op_, x), _i32): \ @@ -1481,7 +1482,7 @@ void tcg_optimize(TCGContext *s) break; case INDEX_op_call: - if (!(op->args[nb_oargs + nb_iargs + 1] + if (!(tcg_call_flags(op) & (TCG_CALL_NO_READ_GLOBALS | TCG_CALL_NO_WRITE_GLOBALS))) { for (i = 0; i < nb_globals; i++) { if (test_bit(i, temps_used.l)) { diff --git a/tcg/tcg.c b/tcg/tcg.c index 5c9a89d22d..1fb4604e45 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -63,6 +63,7 @@ #include "elf.h" #include "exec/log.h" +#include "internal.h" /* Forward declarations for functions declared in tcg-target.c.inc and used here. */ @@ -2333,9 +2334,9 @@ static void tcg_dump_ops(TCGContext *s, bool have_prefs) nb_cargs = def->nb_cargs; /* function name, flags, out args */ - col += qemu_log(" %s %s,$0x%" TCG_PRIlx ",$%d", def->name, + col += qemu_log(" %s %s,$0x%x,$%d", def->name, tcg_find_helper(s, op->args[nb_oargs + nb_iargs]), - op->args[nb_oargs + nb_iargs + 1], nb_oargs); + tcg_call_flags(op), nb_oargs); for (i = 0; i < nb_oargs; i++) { col += qemu_log(",%s", tcg_get_arg_str(s, buf, sizeof(buf), op->args[i])); @@ -2709,7 +2710,6 @@ static void reachable_code_pass(TCGContext *s) QTAILQ_FOREACH_SAFE(op, &s->ops, link, op_next) { bool remove = dead; TCGLabel *label; - int call_flags; switch (op->opc) { case INDEX_op_set_label: @@ -2754,8 +2754,7 @@ static void reachable_code_pass(TCGContext *s) case INDEX_op_call: /* Notice noreturn helper calls, raising exceptions. */ - call_flags = op->args[TCGOP_CALLO(op) + TCGOP_CALLI(op) + 1]; - if (call_flags & TCG_CALL_NO_RETURN) { + if (tcg_call_flags(op) & TCG_CALL_NO_RETURN) { dead = true; } break; @@ -2956,7 +2955,7 @@ static void liveness_pass_1(TCGContext *s) nb_oargs = TCGOP_CALLO(op); nb_iargs = TCGOP_CALLI(op); - call_flags = op->args[nb_oargs + nb_iargs + 1]; + call_flags = tcg_call_flags(op); /* pure functions can be removed if their result is unused */ if (call_flags & TCG_CALL_NO_SIDE_EFFECTS) { @@ -3271,7 +3270,7 @@ static bool liveness_pass_2(TCGContext *s) if (opc == INDEX_op_call) { nb_oargs = TCGOP_CALLO(op); nb_iargs = TCGOP_CALLI(op); - call_flags = op->args[nb_oargs + nb_iargs + 1]; + call_flags = tcg_call_flags(op); } else { nb_iargs = def->nb_iargs; nb_oargs = def->nb_oargs; @@ -4353,7 +4352,7 @@ static void tcg_reg_alloc_call(TCGContext *s, TCGOp *op) TCGRegSet allocated_regs; func_addr = (tcg_insn_unit *)(intptr_t)op->args[nb_oargs + nb_iargs]; - flags = op->args[nb_oargs + nb_iargs + 1]; + flags = tcg_call_flags(op); nb_regs = ARRAY_SIZE(tcg_target_call_iarg_regs); if (nb_regs > nb_iargs) {