From patchwork Sun Feb 27 02:04:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 546438 Delivered-To: patch@linaro.org Received: by 2002:ac0:9f50:0:0:0:0:0 with SMTP id l16csp1611355imf; Sat, 26 Feb 2022 18:12:37 -0800 (PST) X-Google-Smtp-Source: ABdhPJyeFRSTKXEuKZDaTbyc9WCFjeGCxCNPJyDPx8dQTFxCiBtiqWNYbbkIhWbFC/COpbG3o3GT X-Received: by 2002:a25:2087:0:b0:623:249a:73b6 with SMTP id g129-20020a252087000000b00623249a73b6mr13539267ybg.139.1645927957161; Sat, 26 Feb 2022 18:12:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645927957; cv=none; d=google.com; s=arc-20160816; b=QCwDt1vqChsoxVVFQPEr90yTj2YIg0O31CgzX55w0TYL0aa1KsgYwe3gNO/pmpcAmv YvQhA2YCK1PjwAsDXJ1+ufYWbIhBaZTYNJ5e7ToFZVXWk8ob7XFSEqUBfwLAQkMyg/yx RYeDa9qrSu8uiUrFbKTAYrqUO5P08kXtSZ9CHq1H/PQBYkqfeloF+UgB30SeOcGr4VXw 8KxdG7ZExNh1QH9IwdXPXUB9uaFHky0dio/lL/V6LxSJOOApvFgbDmfAe3G/Jo9W8xs/ cMDxIbpwgEk6gvi59DdZd18gpvng5djjjkWDXDTvL2my2f2pJU1NfrB0n+Hm20QTlz6i onHw== 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=jnX70N9tXw0gNkaxVpbBV0ft/4s+qVkI6Ltte/X6Qzk=; b=vUz0nEcKt3WZse+boU8rzZzTUIhFxxCt0lyyqSv+hR4QvpDxDWDe1WnQLIaF6DGr0J Cu4lEK6vSKw0kROgYzZ9TXWuzPDz+z0TyVKaYjK+mi/2GwZY6VprHFxeiUFj8O5Uq5Ne vfnTS3SF3gPFH9DwYUKC1RoJ4i8g+a50cw67IM2CPYNqs7QtHO5GCPQtTbOaFlxT0z/c +cv1rQUHj4LDVE039lGmDpbRpVN78DLpUfGDHKRjyZ4zuNQ7Xr8l1wyLG1MFdyhcF6w2 t0yhB2YYcPlqEfZqZtQKumAmTdgcRN0www6wEhtC4COgYnwP31LiF6+A5lE9Mzls8JO0 1/CQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=aj1SjNEo; 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 j11-20020a25230b000000b00610adfca83bsi5104023ybj.426.2022.02.26.18.12.37 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sat, 26 Feb 2022 18:12:37 -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=aj1SjNEo; 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]:57412 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nO936-00078N-Lp for patch@linaro.org; Sat, 26 Feb 2022 21:12:36 -0500 Received: from eggs.gnu.org ([209.51.188.92]:38478) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nO8vd-000340-TV for qemu-devel@nongnu.org; Sat, 26 Feb 2022 21:04:55 -0500 Received: from [2607:f8b0:4864:20::1035] (port=39788 helo=mail-pj1-x1035.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nO8vP-0007TQ-V9 for qemu-devel@nongnu.org; Sat, 26 Feb 2022 21:04:53 -0500 Received: by mail-pj1-x1035.google.com with SMTP id h17-20020a17090acf1100b001bc68ecce4aso11717421pju.4 for ; Sat, 26 Feb 2022 18:04:29 -0800 (PST) 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=jnX70N9tXw0gNkaxVpbBV0ft/4s+qVkI6Ltte/X6Qzk=; b=aj1SjNEomV/3nhrTPlxp8PkeAnz9lrO5gD6Q3AtyVkJkm46v86v/Vf+mf97XP+hw2B EnnwpcrLyhfhvff5Ik6cmKjeTWDl9vNdOE5j2jPFQt31/c/NF7XWBvqA3C7h3OJFIM9/ d+edb2NPyuXBOnbSwwcAWOoX4xRdBmC1JIwFuIr78nfKudamt1mPwP+VfibfopOORZIq LXDxGQ4vZlNKQfsyetotovilgni2EA0wE8LGvGFlR2SHbYeD12JCDXUYhHcpiB5Z+gK4 o1C05mf7zPQPAP+2xjF3RVnQrioErIz0zxZXdR4ls80iYuH1W6pXtFmNhppz6z7ZOmVY bw/g== 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=jnX70N9tXw0gNkaxVpbBV0ft/4s+qVkI6Ltte/X6Qzk=; b=oU6Scwr/xDwneHS8EdNsEXCaIMuTL6uf56HqyXTPGtl/GtXXldrMvJxO9eirlZUAfa 5fo3Bgwqbkt9MZ5+gyDg2gtZrTnFV9stxc8jmr7Jq06qPDtavcYjyuOWwGW8fqCP10ml ijXSGobZNKjZ6T3ZjyuY+RcvNLg+LRimSHInzCpE6mtCZNw1dGZEo+WO+S8Uhat1+q7C IYb38CFecdxsQ8hHetNm5dcUOitalxW0lDT1GTzKVcqU2yqs6n/fzUCTWsEK1iaDuVHQ wlSx07ukaznUJlYWiPS2JWw3F+UlSSGcwJaSLodQH2Mvglo+K0Wqqid/cjJwl0LeR0dc 7Ctw== X-Gm-Message-State: AOAM533AZ587t2AQBtDyOxMPbt5JYATonOjBidevoljxe6VtLaCCaWJe 5CpXzO1iocsPAkFCdI4gcYPDbR2nE6L7AQ2N X-Received: by 2002:a17:903:4115:b0:151:34d0:6717 with SMTP id r21-20020a170903411500b0015134d06717mr9315148pld.169.1645927468509; Sat, 26 Feb 2022 18:04:28 -0800 (PST) Received: from localhost.localdomain (2603-800c-1201-c600-9001-d56a-9ee0-0246.res6.spectrum.com. [2603:800c:1201:c600:9001:d56a:9ee0:246]) by smtp.gmail.com with ESMTPSA id q13-20020a056a00088d00b004e1bea9c582sm8304021pfj.43.2022.02.26.18.04.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 26 Feb 2022 18:04:28 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 9/9] tcg/loongarch64: Support TCG_TARGET_SIGNED_ADDR32 Date: Sat, 26 Feb 2022 16:04:13 -1000 Message-Id: <20220227020413.11741-10-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220227020413.11741-1-richard.henderson@linaro.org> References: <20220227020413.11741-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::1035 (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::1035; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1035.google.com X-Spam_score_int: -6 X-Spam_score: -0.7 X-Spam_bar: / X-Spam_report: (-0.7 / 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, PDS_HP_HELO_NORDNS=0.659, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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: , Cc: WANG Xuerui Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" All 32-bit LoongArch operations sign-extend the output, so we are easily able to keep TCG_TYPE_I32 values sign-extended in host registers. Cc: WANG Xuerui Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé --- tcg/loongarch64/tcg-target-sa32.h | 2 +- tcg/loongarch64/tcg-target.c.inc | 15 ++++++--------- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/tcg/loongarch64/tcg-target-sa32.h b/tcg/loongarch64/tcg-target-sa32.h index cb185b1526..aaffd777bf 100644 --- a/tcg/loongarch64/tcg-target-sa32.h +++ b/tcg/loongarch64/tcg-target-sa32.h @@ -1 +1 @@ -#define TCG_TARGET_SIGNED_ADDR32 0 +#define TCG_TARGET_SIGNED_ADDR32 1 diff --git a/tcg/loongarch64/tcg-target.c.inc b/tcg/loongarch64/tcg-target.c.inc index a3debf6da7..425f6629ca 100644 --- a/tcg/loongarch64/tcg-target.c.inc +++ b/tcg/loongarch64/tcg-target.c.inc @@ -880,8 +880,6 @@ static bool tcg_out_qemu_st_slow_path(TCGContext *s, TCGLabelQemuLdst *l) return tcg_out_fail_alignment(s, l); } -#endif /* CONFIG_SOFTMMU */ - /* * `ext32u` the address register into the temp register given, * if target is 32-bit, no-op otherwise. @@ -891,12 +889,13 @@ static bool tcg_out_qemu_st_slow_path(TCGContext *s, TCGLabelQemuLdst *l) static TCGReg tcg_out_zext_addr_if_32_bit(TCGContext *s, TCGReg addr, TCGReg tmp) { - if (TARGET_LONG_BITS == 32) { + if (TARGET_LONG_BITS == 32 && !guest_base_signed_addr32) { tcg_out_ext32u(s, tmp, addr); return tmp; } return addr; } +#endif /* CONFIG_SOFTMMU */ static void tcg_out_qemu_ld_indexed(TCGContext *s, TCGReg rd, TCGReg rj, TCGReg rk, MemOp opc, TCGType type) @@ -944,8 +943,8 @@ static void tcg_out_qemu_ld(TCGContext *s, const TCGArg *args, TCGType type) tcg_insn_unit *label_ptr[1]; #else unsigned a_bits; -#endif TCGReg base; +#endif data_regl = *args++; addr_regl = *args++; @@ -954,8 +953,7 @@ static void tcg_out_qemu_ld(TCGContext *s, const TCGArg *args, TCGType type) #if defined(CONFIG_SOFTMMU) tcg_out_tlb_load(s, addr_regl, oi, label_ptr, 1); - base = tcg_out_zext_addr_if_32_bit(s, addr_regl, TCG_REG_TMP0); - tcg_out_qemu_ld_indexed(s, data_regl, base, TCG_REG_TMP2, opc, type); + tcg_out_qemu_ld_indexed(s, data_regl, addr_regl, TCG_REG_TMP2, opc, type); add_qemu_ldst_label(s, 1, oi, type, data_regl, addr_regl, s->code_ptr, label_ptr); @@ -1004,8 +1002,8 @@ static void tcg_out_qemu_st(TCGContext *s, const TCGArg *args) tcg_insn_unit *label_ptr[1]; #else unsigned a_bits; -#endif TCGReg base; +#endif data_regl = *args++; addr_regl = *args++; @@ -1014,8 +1012,7 @@ static void tcg_out_qemu_st(TCGContext *s, const TCGArg *args) #if defined(CONFIG_SOFTMMU) tcg_out_tlb_load(s, addr_regl, oi, label_ptr, 0); - base = tcg_out_zext_addr_if_32_bit(s, addr_regl, TCG_REG_TMP0); - tcg_out_qemu_st_indexed(s, data_regl, base, TCG_REG_TMP2, opc); + tcg_out_qemu_st_indexed(s, data_regl, addr_regl, TCG_REG_TMP2, opc); add_qemu_ldst_label(s, 0, oi, 0, /* type param is unused for stores */ data_regl, addr_regl,