From patchwork Tue Apr 9 19:35:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 787249 Delivered-To: patch@linaro.org Received: by 2002:adf:fdd2:0:b0:346:15ad:a2a with SMTP id i18csp383968wrs; Tue, 9 Apr 2024 12:38:56 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCX1TzrKU37+n5qHfD45CGt15H4wS4NVKNEK7k2tXbIjGsAhbBT8TppZr3c4y6kcHN/0rwdnGiB4iZaKL7w6TM6n X-Google-Smtp-Source: AGHT+IG2H6aBvWQNSvNmTbcZpnUwb8ugF/nZYiV5Crf10Hzn/8caANnGwvwdgqwyQlQ/vU9qXWBQ X-Received: by 2002:a05:6808:4184:b0:3c5:e66b:1f79 with SMTP id dj4-20020a056808418400b003c5e66b1f79mr519580oib.16.1712691536320; Tue, 09 Apr 2024 12:38:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712691536; cv=none; d=google.com; s=arc-20160816; b=Pm3TrlOZEBLbDgs1XBFBGRpjWJ6YkTHikStcj2YpYqVR4Rqc/K/82O1g06YnHR/0TA omElZOvLxRPlhgb8q4kfbdDEHxN/eRXecZESy2+UPRmHMabeXCaV+PnNHwrVk0d55WG3 I5LrIzJtuKYlcNB6q97IKogoQBt7eR/Wykmt80kUVD/FIYJSEFNaaCK3U+VAYTJ6/qfL S7QroKpcy3qIIe0ZHAgq22o13NmL0vF5yeHiaIpR0xQYArHvYuoJnDNTKpYDz4Jt7FDw 7aXvK50MLXvhDR0VqeeH8DR2KUwpg+gCH4Ufd9KOmW5O9NTDkyIzhGMMK5co2vCLXcKh 6gug== 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=gHgrMBfJl0EWko+KOSUm9E0b6yMA9Veb8odtrLbxwoY=; fh=XWt4jYijdNxai0FT2E6j/i4Lx4wzcENDxh6icUDNRFQ=; b=0RO8raVUNvR9sPAZ8c71HvPmGCy/BGot5foWx3swQeOYOrc9jsOFDgxbCXG9BKpVYa QMi6zIP6YeLUv4Smpw7/bGFPLajh+ufsKvR3+Lew+lQ6D+Ido5grQJiXI3iXvqYy/ith tsl1eWJ7ELGoouyr5NkGwHvGkx+p1GNG1+z5YCrR+FYgayqi+Q0gK+a28MO/1t+REUuW WrdaFnArg2dmH9nMQaPfskN1v8DFvpVJGVVagqMFXb7RBE1CCgEGb/0VnSorgvvkRo0S EgpLIMY/wO7B1Kp1DkrhqM/bsKHDwlIJkK1oKKpJ8IsWAtZiPRSz6t6pAgUG4kjByq2j xw9w==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=IEqn9q4m; 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 e13-20020ac8598d000000b00434996df207si5659924qte.402.2024.04.09.12.38.56 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 09 Apr 2024 12:38:56 -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=IEqn9q4m; 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 1ruHGc-0000bd-3f; Tue, 09 Apr 2024 15:36:26 -0400 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 1ruHGa-0000av-Px for qemu-devel@nongnu.org; Tue, 09 Apr 2024 15:36:24 -0400 Received: from mail-pl1-x635.google.com ([2607:f8b0:4864:20::635]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ruHGZ-0004ee-4I for qemu-devel@nongnu.org; Tue, 09 Apr 2024 15:36:24 -0400 Received: by mail-pl1-x635.google.com with SMTP id d9443c01a7336-1e3c9300c65so34837365ad.0 for ; Tue, 09 Apr 2024 12:36:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1712691382; x=1713296182; darn=nongnu.org; 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=gHgrMBfJl0EWko+KOSUm9E0b6yMA9Veb8odtrLbxwoY=; b=IEqn9q4mI7uGEEJ8Bwg0zenUgpV5E8P3xggkUB6+c0qc/04iha6C7W0R1PC6Ac7tjZ aAZQiNKmSdOFVoGEU+jUeRqcrq4RGu2/c51hc86oyEYt+PhODRBNzt80A9q79a+tNlbe DNmeFvRe8s7dzsx3/4itAWIzNv9caW9J6/YZGW7SUl2KEo6brYUk4SkGuhN5qK2m0M0u O5VsheCPWSRau8ePLnQB7+i4QcKBZ1crrF8xRqCxcNEnAe8HDgNv1TnSxSKEE6m7nsE/ sPmdgvCKXCPMJF7tzIYbAEm93yasvU3hu7Kyo06kzqbtacB56156/LT4dkr5K+bfO8YG JpLg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712691382; x=1713296182; 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=gHgrMBfJl0EWko+KOSUm9E0b6yMA9Veb8odtrLbxwoY=; b=F1mla7Qmk++vjGB+eSfh2TIzpInReSzpvSHKZX2XPHfqPhQsslOz8+0OFSfubbfTLx Yv+Gayj78hlfoNp4L1IxAtvL+lmAbgjUu3likIh+KYpdvLCfqqViQ0lQKV7tGTkpOKiF w9C+XFlEBTogUNuPizLI+VHpQ+N4w+R3VRyfsAghsaLidGwKD7bYeqzfnfOoKBpFA8g/ l2+mMK7sb/NWDfQXYHGOq97t3uZ/LuMLIWxmU7KW1LZ0KeJ3K/tjYZ9pm2QpeEfe63wZ Hw+JNX3T2Yl7+VpBX6rKUu5zlOgSNqkomlDJ/DwBsEdNNBCAQNxwDd9wc9CpGFACtNH7 FjCg== X-Gm-Message-State: AOJu0Yx6oRUARM5Tpany3MU4rV83orT7XjdNFWm0rMAkbyrwsw5aAmYc jvJhA6RkQWpyvx3jMrv1AmM+QfQVg7TI4j181dw4IN0fmEKYTzCBhu5rOqOKAQIwZBITg/oqPb1 / X-Received: by 2002:a17:903:41ce:b0:1e3:e081:d29b with SMTP id u14-20020a17090341ce00b001e3e081d29bmr808905ple.45.1712691381899; Tue, 09 Apr 2024 12:36:21 -0700 (PDT) Received: from stoup.. (098-147-007-212.res.spectrum.com. [98.147.7.212]) by smtp.gmail.com with ESMTPSA id c17-20020a170902d49100b001e1071cf0bbsm6065843plg.302.2024.04.09.12.36.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Apr 2024 12:36:21 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?utf-8?q?J=C3=B8rgen_Hansen?= , =?utf-8?q?Philip?= =?utf-8?q?pe_Mathieu-Daud=C3=A9?= , Pierrick Bouvier Subject: [PULL v2 11/20] tcg: Add TCGContext.emit_before_op Date: Tue, 9 Apr 2024 09:35:54 -1000 Message-Id: <20240409193603.1703216-12-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240409193603.1703216-1-richard.henderson@linaro.org> References: <20240409193603.1703216-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::635; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x635.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 Allow operations to be emitted via normal expanders into the middle of the opcode stream. Tested-by: Jørgen Hansen Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Pierrick Bouvier Signed-off-by: Richard Henderson --- include/tcg/tcg.h | 6 ++++++ tcg/tcg.c | 14 ++++++++++++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/include/tcg/tcg.h b/include/tcg/tcg.h index 451f3fec41..05a1912f8a 100644 --- a/include/tcg/tcg.h +++ b/include/tcg/tcg.h @@ -553,6 +553,12 @@ struct TCGContext { QTAILQ_HEAD(, TCGOp) ops, free_ops; QSIMPLEQ_HEAD(, TCGLabel) labels; + /* + * When clear, new ops are added to the tail of @ops. + * When set, new ops are added in front of @emit_before_op. + */ + TCGOp *emit_before_op; + /* Tells which temporary holds a given register. It does not take into account fixed registers */ TCGTemp *reg_to_temp[TCG_TARGET_NB_REGS]; diff --git a/tcg/tcg.c b/tcg/tcg.c index d6670237fb..0c0bb9d169 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -1521,6 +1521,7 @@ void tcg_func_start(TCGContext *s) QTAILQ_INIT(&s->ops); QTAILQ_INIT(&s->free_ops); + s->emit_before_op = NULL; QSIMPLEQ_INIT(&s->labels); tcg_debug_assert(s->addr_type == TCG_TYPE_I32 || @@ -2332,7 +2333,11 @@ static void tcg_gen_callN(TCGHelperInfo *info, TCGTemp *ret, TCGTemp **args) op->args[pi++] = (uintptr_t)info; tcg_debug_assert(pi == total_args); - QTAILQ_INSERT_TAIL(&tcg_ctx->ops, op, link); + if (tcg_ctx->emit_before_op) { + QTAILQ_INSERT_BEFORE(tcg_ctx->emit_before_op, op, link); + } else { + QTAILQ_INSERT_TAIL(&tcg_ctx->ops, op, link); + } tcg_debug_assert(n_extend < ARRAY_SIZE(extend_free)); for (i = 0; i < n_extend; ++i) { @@ -3215,7 +3220,12 @@ static TCGOp *tcg_op_alloc(TCGOpcode opc, unsigned nargs) TCGOp *tcg_emit_op(TCGOpcode opc, unsigned nargs) { TCGOp *op = tcg_op_alloc(opc, nargs); - QTAILQ_INSERT_TAIL(&tcg_ctx->ops, op, link); + + if (tcg_ctx->emit_before_op) { + QTAILQ_INSERT_BEFORE(tcg_ctx->emit_before_op, op, link); + } else { + QTAILQ_INSERT_TAIL(&tcg_ctx->ops, op, link); + } return op; }