From nobody Sat Jun 29 02:59:57 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1610051450; cv=none; d=zohomail.com; s=zohoarc; b=T1OAf+0kNmj/Pn7sruDdZ8mHdZs3TOEuq4pt2724ePmTd2dlhqq4dYvRsDbHjSbQ/VfqCxkASUEYqCnb03wgqAk2rgFAzQlRx6uS3UF+ctT4asPtYHMIiMZtybqlRH0veqsu/1WxDvg3uQtXXnVcP1Ent67U1ExmcV+7TyRwmvw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610051450; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=RjsLWt3F7DefhddvmyHDtzHbHX1tk83XD8LIVsXHpX8=; b=lZmX7mV3IKIiXRMyNYydVosBRojDnJKclIoi5Pt2c1D9PP/t2/D4ZwaiZClVmaMK04bFOsLtRNsplW9jUl6W/RwExyNLDCqXK/AkLO9pEJnrJi+VoFPT/E5O7zQOPQf5LN1RuFUWtcUNVkVAqBf1lw0lOKv6AgkI2efBFLVfM0E= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1610051450488695.9557907666621; Thu, 7 Jan 2021 12:30:50 -0800 (PST) Received: from localhost ([::1]:34648 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kxbvl-0002hR-7Q for importer@patchew.org; Thu, 07 Jan 2021 15:30:49 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:48698) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kxbhf-0001eH-B6 for qemu-devel@nongnu.org; Thu, 07 Jan 2021 15:16:15 -0500 Received: from mail-pf1-x42f.google.com ([2607:f8b0:4864:20::42f]:46469) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kxbhY-0001kR-H4 for qemu-devel@nongnu.org; Thu, 07 Jan 2021 15:16:15 -0500 Received: by mail-pf1-x42f.google.com with SMTP id s21so4543276pfu.13 for ; Thu, 07 Jan 2021 12:16:07 -0800 (PST) Received: from localhost.localdomain (rrcs-173-197-107-21.west.biz.rr.com. [173.197.107.21]) by smtp.gmail.com with ESMTPSA id v6sm6516265pfi.31.2021.01.07.12.16.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Jan 2021 12:16:06 -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=RjsLWt3F7DefhddvmyHDtzHbHX1tk83XD8LIVsXHpX8=; b=iF/sgumtKrFBoMum+1BTX8MfSxdhPBVAFyQ1gC9Nu0vyHnFOAfzi3yADxfZbga4ASM 3LbOo3vVVNa3z1wwT024XvW4EuP4J922DsAksluRgF2FUD+ykHmXe0XrY92JYEMmn1cz 8z5K+00U+8ETEHdjohWUU5Z4l7K1YXxJUKDUm/6i9lJneYPalgQvXqRyfN2I7UsCsS4H TQ9nwrI7DQy4CroO+AjwwiclfspBopZmCIJRqAuXeSr+iT98F3xxg5bgMx0KlCCwvQK7 vFJ57+sHN9e99MXPAO0CLmhOoGsqcICK+2al0PQJjbDPsETcbvVnv65wNiFBLQwQVl9X DYuA== 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=RjsLWt3F7DefhddvmyHDtzHbHX1tk83XD8LIVsXHpX8=; b=iUHo7glrXlijLzRqPCgPJeeBsfCfsWtQLxl+LlaNBEQUDOdNEF3cFXLeS+8AFDHI91 VIW5EIL4f3U74Pd4gHwGoZ4qmHDhQ7Y/ufgK4uy5D32sWs1x2TXwfOjn32pRhiBXdT2U tCv3thjVRohcIbn/AxalPRtqmHYVvmrrQiTwkAnzmxsAuvki4KibgOveOA7cM+LXXs+q GqTb085EgJ6qniq4qYqoF1ghdmj0Jsak7DHP4UBG1zYq5pwHjSpDCK2Et/bAPnF0u1HP 3sfSbIUqe6TivN0VCPnD0MvcmYKLYaV1W4FLey7bpNnvd+390shi4f1cjeTfYvOoXpmN Kwqw== X-Gm-Message-State: AOAM532WI9Mj8YcP3YLB9xd5mOo7V7ui5IZcrVOPNkVZmfnnOm7OUul3 KpF3YH4cmbLUcwQ4iaMK0PeCCISaThc8xg== X-Google-Smtp-Source: ABdhPJx1QPGFI9JMUgiAUHB5ZAZkBBMcW4w8sHGr2PsMZknvTJu2FYiAVKiqvygWt1EiZ8M2hbY/rg== X-Received: by 2002:a62:fc86:0:b029:19d:9943:c843 with SMTP id e128-20020a62fc860000b029019d9943c843mr390171pfh.71.1610050566710; Thu, 07 Jan 2021 12:16:06 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 44/47] tcg/arm: Support split-wx code generation Date: Thu, 7 Jan 2021 10:14:45 -1000 Message-Id: <20210107201448.1152301-45-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210107201448.1152301-1-richard.henderson@linaro.org> References: <20210107201448.1152301-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::42f; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42f.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: peter.maydell@linaro.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) Content-Type: text/plain; charset="utf-8" Signed-off-by: Richard Henderson --- tcg/arm/tcg-target.h | 2 +- tcg/arm/tcg-target.c.inc | 37 +++++++++++++++++++++---------------- 2 files changed, 22 insertions(+), 17 deletions(-) diff --git a/tcg/arm/tcg-target.h b/tcg/arm/tcg-target.h index 494837d128..fdf75ba93f 100644 --- a/tcg/arm/tcg-target.h +++ b/tcg/arm/tcg-target.h @@ -142,6 +142,6 @@ void tb_target_set_jmp_target(uintptr_t, uintptr_t, uin= tptr_t, uintptr_t); #define TCG_TARGET_NEED_LDST_LABELS #endif #define TCG_TARGET_NEED_POOL_LABELS -#define TCG_TARGET_SUPPORT_MIRROR 0 +#define TCG_TARGET_SUPPORT_MIRROR 1 =20 #endif diff --git a/tcg/arm/tcg-target.c.inc b/tcg/arm/tcg-target.c.inc index 9b9400f164..3d2717aeb0 100644 --- a/tcg/arm/tcg-target.c.inc +++ b/tcg/arm/tcg-target.c.inc @@ -187,29 +187,32 @@ static const uint8_t tcg_cond_to_arm_cond[] =3D { [TCG_COND_GTU] =3D COND_HI, }; =20 -static inline bool reloc_pc24(tcg_insn_unit *code_ptr, tcg_insn_unit *targ= et) +static bool reloc_pc24(tcg_insn_unit *src_rw, const tcg_insn_unit *target) { - ptrdiff_t offset =3D (tcg_ptr_byte_diff(target, code_ptr) - 8) >> 2; + const tcg_insn_unit *src_rx =3D tcg_splitwx_to_rx(src_rw); + ptrdiff_t offset =3D (tcg_ptr_byte_diff(target, src_rx) - 8) >> 2; + if (offset =3D=3D sextract32(offset, 0, 24)) { - *code_ptr =3D (*code_ptr & ~0xffffff) | (offset & 0xffffff); + *src_rw =3D deposit32(*src_rw, 0, 24, offset); return true; } return false; } =20 -static inline bool reloc_pc13(tcg_insn_unit *code_ptr, tcg_insn_unit *targ= et) +static bool reloc_pc13(tcg_insn_unit *src_rw, const tcg_insn_unit *target) { - ptrdiff_t offset =3D tcg_ptr_byte_diff(target, code_ptr) - 8; + const tcg_insn_unit *src_rx =3D tcg_splitwx_to_rx(src_rw); + ptrdiff_t offset =3D tcg_ptr_byte_diff(target, src_rx) - 8; =20 if (offset >=3D -0xfff && offset <=3D 0xfff) { - tcg_insn_unit insn =3D *code_ptr; + tcg_insn_unit insn =3D *src_rw; bool u =3D (offset >=3D 0); if (!u) { offset =3D -offset; } insn =3D deposit32(insn, 23, 1, u); insn =3D deposit32(insn, 0, 12, offset); - *code_ptr =3D insn; + *src_rw =3D insn; return true; } return false; @@ -221,9 +224,9 @@ static bool patch_reloc(tcg_insn_unit *code_ptr, int ty= pe, tcg_debug_assert(addend =3D=3D 0); =20 if (type =3D=3D R_ARM_PC24) { - return reloc_pc24(code_ptr, (tcg_insn_unit *)value); + return reloc_pc24(code_ptr, (const tcg_insn_unit *)value); } else if (type =3D=3D R_ARM_PC13) { - return reloc_pc13(code_ptr, (tcg_insn_unit *)value); + return reloc_pc13(code_ptr, (const tcg_insn_unit *)value); } else { g_assert_not_reached(); } @@ -617,7 +620,7 @@ static void tcg_out_movi32(TCGContext *s, int cond, int= rd, uint32_t arg) =20 /* Check for a pc-relative address. This will usually be the TB, or within the TB, which is immediately before the code block. */ - diff =3D arg - ((intptr_t)s->code_ptr + 8); + diff =3D tcg_pcrel_diff(s, (void *)arg) - 8; if (diff >=3D 0) { rot =3D encode_imm(diff); if (rot >=3D 0) { @@ -1337,7 +1340,8 @@ static void add_qemu_ldst_label(TCGContext *s, bool i= s_ld, TCGMemOpIdx oi, label->datahi_reg =3D datahi; label->addrlo_reg =3D addrlo; label->addrhi_reg =3D addrhi; - label->raddr =3D raddr; + /* TODO: Cast goes away when all hosts converted */ + label->raddr =3D (void *)tcg_splitwx_to_rx(raddr); label->label_ptr[0] =3D label_ptr; } =20 @@ -1348,7 +1352,7 @@ static bool tcg_out_qemu_ld_slow_path(TCGContext *s, = TCGLabelQemuLdst *lb) MemOp opc =3D get_memop(oi); void *func; =20 - if (!reloc_pc24(lb->label_ptr[0], s->code_ptr)) { + if (!reloc_pc24(lb->label_ptr[0], tcg_splitwx_to_rx(s->code_ptr))) { return false; } =20 @@ -1411,7 +1415,7 @@ static bool tcg_out_qemu_st_slow_path(TCGContext *s, = TCGLabelQemuLdst *lb) TCGMemOpIdx oi =3D lb->oi; MemOp opc =3D get_memop(oi); =20 - if (!reloc_pc24(lb->label_ptr[0], s->code_ptr)) { + if (!reloc_pc24(lb->label_ptr[0], tcg_splitwx_to_rx(s->code_ptr))) { return false; } =20 @@ -1762,8 +1766,8 @@ static inline void tcg_out_op(TCGContext *s, TCGOpcod= e opc, TCGReg base =3D TCG_REG_PC; =20 tcg_debug_assert(s->tb_jmp_insn_offset =3D=3D 0); - ptr =3D (intptr_t)(s->tb_jmp_target_addr + args[0]); - dif =3D ptr - ((intptr_t)s->code_ptr + 8); + ptr =3D (intptr_t)tcg_splitwx_to_rx(s->tb_jmp_target_addr + ar= gs[0]); + dif =3D tcg_pcrel_diff(s, (void *)ptr) - 8; dil =3D sextract32(dif, 0, 12); if (dif !=3D dil) { /* The TB is close, but outside the 12 bits addressable by @@ -2297,7 +2301,8 @@ static void tcg_target_qemu_prologue(TCGContext *s) * Return path for goto_ptr. Set return value to 0, a-la exit_tb, * and fall through to the rest of the epilogue. */ - tcg_code_gen_epilogue =3D s->code_ptr; + /* TODO: Cast goes away when all hosts converted */ + tcg_code_gen_epilogue =3D (void *)tcg_splitwx_to_rx(s->code_ptr); tcg_out_movi(s, TCG_TYPE_PTR, TCG_REG_R0, 0); tcg_out_epilogue(s); } --=20 2.25.1