From patchwork Sun Oct 3 21:42:42 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Philipp Tomsich X-Patchwork-Id: 12533075 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1C9F6C433F5 for ; Sun, 3 Oct 2021 21:43:34 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 6C53161373 for ; Sun, 3 Oct 2021 21:43:33 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 6C53161373 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=vrull.eu Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:57772 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mX9Ge-00084R-B9 for qemu-devel@archiver.kernel.org; Sun, 03 Oct 2021 17:43:32 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56366) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mX9G1-0007O7-4z for qemu-devel@nongnu.org; Sun, 03 Oct 2021 17:42:53 -0400 Received: from mail-lf1-x130.google.com ([2a00:1450:4864:20::130]:39600) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mX9Fy-0000EV-Tr for qemu-devel@nongnu.org; Sun, 03 Oct 2021 17:42:52 -0400 Received: by mail-lf1-x130.google.com with SMTP id n8so7953010lfk.6 for ; Sun, 03 Oct 2021 14:42:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vrull-eu.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=l3IwrmhKYHOfZ+rT79f9aEpSgQwVthSHCLu34YnwWDw=; b=45Z/x5U8LyMcphtJdDpyKhhto3TQO+UYQmR4lCre7S4Yh5oygiN8jyvZhAHdxoBxgO sIb38IKVlXbWdxpGzi9lz5JimeWh2WJYdbFGqWp4wbxsPc7v1FC5O+D2VmX9TPQawchT 0yBhMwm9qOC6ym2j3mubNonUnM/a0y50+hkm2Te4xbuDxt2G8qKsgqneXC9QY86CZ7iF NUuvqVGbvkHoHsfGtjR6znemPw/WJ/Nj4qrW7u0YY32EEkQE2PBH0mI3r8VIyoKadIPt 3lkuCcplRXSgUq8IpKL5g8C+qsun3AyHH8VLUUg6ON+g1U6JctPIZPatjNwfOarbVmj/ 3XvQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=l3IwrmhKYHOfZ+rT79f9aEpSgQwVthSHCLu34YnwWDw=; b=ZTZEKUV0D9BOAQafzurTkDb2lOSWxh7dSlAskrkDyzpPS32rI564RkHiY9FrdWuCf3 BHR0WaqJz769w4lbYGqZ0jRrochyxInX8LIZn48EVIagqoHROTjJIgPfvpF07GpCZ74s ueL8LeviIkUSAE8pSsYZdJrwC++vmNtxR9efAYKdvJNl2T43thYxaEnGY3FhJGMb3rke vqSZAZ6xk9aC/n14NTaDEHcL0RGIkrzKvTJ+CRerMLVW6CJb9SMfYPyIZ1vDSn26dqSA 2bBfZjvt5LIa0ZIBS47mX+FJly61B8xfEO8wqFUeWl9H8AWvPV0iTOwAZPu2IjqCTceC /SyA== X-Gm-Message-State: AOAM530Sk1rTwmQcETYmoFWIRDCLK9HwnMyMSsyxnisSNKy4T2pQcQiI QGr6awXu0N62f0a9V+SG+4eeUzGw3lDlQ8w4 X-Google-Smtp-Source: ABdhPJxjcugOJT1+DMZsrvfk06Ao6buqNcoE9k3sU0G3plOdH2or4o5UgM6VKfAGp3VoF0oEoq+lmw== X-Received: by 2002:a2e:140d:: with SMTP id u13mr11508791ljd.298.1633297366874; Sun, 03 Oct 2021 14:42:46 -0700 (PDT) Received: from localhost.localdomain ([2a01:4f9:3a:1e26::2]) by smtp.gmail.com with ESMTPSA id l14sm191772lfe.124.2021.10.03.14.42.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Oct 2021 14:42:46 -0700 (PDT) From: Philipp Tomsich To: qemu-devel@nongnu.org Subject: [PATCH v2 1/2] tcg: add dup_const_tl wrapper Date: Sun, 3 Oct 2021 23:42:42 +0200 Message-Id: <20211003214243.3813425-1-philipp.tomsich@vrull.eu> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::130; envelope-from=philipp.tomsich@vrull.eu; helo=mail-lf1-x130.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-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: Richard Henderson , Alistair Francis , Philipp Tomsich Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" dup_const always generates a uint64_t, which may exceed the size of a target_long (generating warnings with recent-enough compilers). To ensure that we can use dup_const both for 64bit and 32bit targets, this adds dup_const_tl, which either maps back to dup_const (for 64bit targets) or provides a similar implementation using 32bit constants. Signed-off-by: Philipp Tomsich Reviewed-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé --- Changes in v2: - Changed dup_const_tl to enforce the sanity check with qemu_build_not_reached as requested in the review. include/tcg/tcg.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/include/tcg/tcg.h b/include/tcg/tcg.h index 44ccd86f3e..1bb6c0ce3e 100644 --- a/include/tcg/tcg.h +++ b/include/tcg/tcg.h @@ -1272,6 +1272,18 @@ uint64_t dup_const(unsigned vece, uint64_t c); : (qemu_build_not_reached_always(), 0)) \ : dup_const(VECE, C)) +#if TARGET_LONG_BITS == 64 +# define dup_const_tl dup_const +#else +# define dup_const_tl(VECE, C) \ + (__builtin_constant_p(VECE) \ + ? ( (VECE) == MO_8 ? 0x01010101ul * (uint8_t)(C) \ + : (VECE) == MO_16 ? 0x00010001ul * (uint16_t)(C) \ + : (VECE) == MO_32 ? 0x00000001ul * (uint32_t)(C) \ + : (qemu_build_not_reached_always(), 0)) \ + : (target_long)dup_const(VECE, C)) +#endif + /* * Memory helpers that will be used by TCG generated code. */ From patchwork Sun Oct 3 21:42:43 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Philipp Tomsich X-Patchwork-Id: 12533077 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 14FEFC433EF for ; Sun, 3 Oct 2021 21:44:55 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A42BD61373 for ; Sun, 3 Oct 2021 21:44:54 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org A42BD61373 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=vrull.eu Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:59898 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mX9Hx-00016A-QX for qemu-devel@archiver.kernel.org; Sun, 03 Oct 2021 17:44:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56368) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mX9G1-0007OF-Nd for qemu-devel@nongnu.org; Sun, 03 Oct 2021 17:42:53 -0400 Received: from mail-lf1-x12d.google.com ([2a00:1450:4864:20::12d]:41955) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mX9Fy-0000FM-QM for qemu-devel@nongnu.org; Sun, 03 Oct 2021 17:42:53 -0400 Received: by mail-lf1-x12d.google.com with SMTP id j5so58516760lfg.8 for ; Sun, 03 Oct 2021 14:42:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vrull-eu.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=xak2sEAwzGEUNDut8cfkpYCfvFdv2LJdzkKEfqvDZWs=; b=Db5oe03GBXUuZ/J8JONWW7azcDNBbVjlm2+geN4LNFiUdz4ahETAtfB/vfmmdkC1Jz wRxfFzm8i7rypF/+0up04YNahqrIB+slML189eL6k70ZEpa8ONYFE+vil/hgEkmZwhDR vT/fXYvVzf1c/8sahX/RNFYsv9C4VBdJwgDDT3vLPgLEo9YRC0IPoU95jCHDP6h87PTn vtd8+riwSrD0Y5x6THcdsYJ3xUNko1SRHk5ki+r4utzCzOaGU228yvlL0pgt3WyrlFYU ETn1JVKi6Ny70C/TZO/xIs/UZW6DVC8iVovXvVvZnpjoq492qpm4g2sAYbR7/mYBo2ar DlRA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=xak2sEAwzGEUNDut8cfkpYCfvFdv2LJdzkKEfqvDZWs=; b=ExLvqxe8lfg471VjvPu1G/m8A7ti9NfCW9JFmCBMxX9TxJ1XSRyTzOabPzXY0jeEYQ yGNg6GYMTk9B+QUgOb4GmBkJOHVDpxlKA+PFSAVZg0Q88apuqaq0jTU9kv62MxFALmWh N1wi3+1uvEwtL4pT0cEs2CA+qpq3l4Nlq7bBwbfKxh8IFDFSWrkerqXQWVJ+ggAkLhhL TJGQqhXE3/3ROY/DKNwxyPnFHn8YTCm5nH+o9fXDZ2CSjMlL8mKRyUsaUEP24hEdiRop eofmy6hX+86xkiETgja420KCgwgb0ZOZBb9CUf0lutVnmHKfcrVqJXBwl2ULjxASwPWO 5jcA== X-Gm-Message-State: AOAM5327cx8E8Ysxsdc3tf7VWeae352m/SoRYWSNlReMTt08cnzere0I 2GxAQ7R+cjH0aHiS4FjVydBA4ShULCe3b0jS X-Google-Smtp-Source: ABdhPJzMYIv0utqgSYbgziy2hRtw84aiq7pugcETrco37Lp8+NzZszI4w9LFb9I7wbcMUt/iLUk3qA== X-Received: by 2002:a2e:a591:: with SMTP id m17mr11752621ljp.5.1633297367672; Sun, 03 Oct 2021 14:42:47 -0700 (PDT) Received: from localhost.localdomain ([2a01:4f9:3a:1e26::2]) by smtp.gmail.com with ESMTPSA id l14sm191772lfe.124.2021.10.03.14.42.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Oct 2021 14:42:47 -0700 (PDT) From: Philipp Tomsich To: qemu-devel@nongnu.org Subject: [PATCH v2 2/2] target/riscv: Use dup_const_tl in orc.b to legalise truncation of constant Date: Sun, 3 Oct 2021 23:42:43 +0200 Message-Id: <20211003214243.3813425-2-philipp.tomsich@vrull.eu> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211003214243.3813425-1-philipp.tomsich@vrull.eu> References: <20211003214243.3813425-1-philipp.tomsich@vrull.eu> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::12d; envelope-from=philipp.tomsich@vrull.eu; helo=mail-lf1-x12d.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-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: Richard Henderson , Alistair Francis , Philipp Tomsich Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" We need to use the newly introduced dup_const_tl in orc.b to legalise the truncation (to target_long) of the constant generated with dup_const. Signed-off-by: Philipp Tomsich Reviewed-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Alistair Francis --- (no changes since v1) target/riscv/insn_trans/trans_rvb.c.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target/riscv/insn_trans/trans_rvb.c.inc b/target/riscv/insn_trans/trans_rvb.c.inc index 2927353d9b..185c3e9a60 100644 --- a/target/riscv/insn_trans/trans_rvb.c.inc +++ b/target/riscv/insn_trans/trans_rvb.c.inc @@ -249,7 +249,7 @@ static bool trans_rev8_64(DisasContext *ctx, arg_rev8_64 *a) static void gen_orc_b(TCGv ret, TCGv source1) { TCGv tmp = tcg_temp_new(); - TCGv ones = tcg_constant_tl(dup_const(MO_8, 0x01)); + TCGv ones = tcg_constant_tl(dup_const_tl(MO_8, 0x01)); /* Set lsb in each byte if the byte was zero. */ tcg_gen_sub_tl(tmp, source1, ones);