From nobody Mon Feb 9 16:32:18 2026 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=1604634323; cv=none; d=zohomail.com; s=zohoarc; b=Yw09BZdccE82bNfd/EgclC3Cfk/WL0GZNUEVUjqhumIg1LTQ+g8wZ4A0xMfyimqpZW6vaaBk6FFUK3Hxd9qIXw6fHtCBX5l556tzJyR/G7ob0zmzWiiQs4eYp6aJ9Pw4DACDDvIhPvQT5yjbwBJAcQBrjL2TpCxt2GB4cqCczDk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604634323; 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=pY7YptV5jK52/EGSfz+70ZXeLAnSsRhMupI/NGLlfao=; b=gdmvayGZa4zOLBJnaQzFac2nd19+XxFR4jYNh7MxlA7VV7r4sfburhlKD25L0efNN32Paeuc2wA2rjaHifnEYRyXZ7dfb+RBBa0rSNEIB+3T9tbZTIYg+8FDU25m+1Wlzrk61nfQaP4hUG2QtU9iGL4jys+Rpj5HpZonGqnbeQI= 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 1604634323311668.0106694077829; Thu, 5 Nov 2020 19:45:23 -0800 (PST) Received: from localhost ([::1]:48844 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kasgk-0003kE-7w for importer@patchew.org; Thu, 05 Nov 2020 22:45:22 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:47212) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kasS5-0005Vb-FH for qemu-devel@nongnu.org; Thu, 05 Nov 2020 22:30:14 -0500 Received: from mail-pg1-x542.google.com ([2607:f8b0:4864:20::542]:39964) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kasS1-00077M-OR for qemu-devel@nongnu.org; Thu, 05 Nov 2020 22:30:11 -0500 Received: by mail-pg1-x542.google.com with SMTP id x13so2880672pgp.7 for ; Thu, 05 Nov 2020 19:30:02 -0800 (PST) Received: from localhost.localdomain (76-14-210-194.or.wavecable.com. [76.14.210.194]) by smtp.gmail.com with ESMTPSA id i10sm40773pfd.60.2020.11.05.19.29.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Nov 2020 19:30:00 -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=pY7YptV5jK52/EGSfz+70ZXeLAnSsRhMupI/NGLlfao=; b=nCoKluwlNDu2+WsZadTbwfyDuW4VcgCWFPKDcbSQ6yJKvQFdcE6/tpKzIhhw6aYnNu 2q5WyMOfuIP1SXFZ8QsZV5LNqenkfVQB8POnPWDZyzX/Mbr1yx8mLWNgf+XBF52qPBdF W1E752WaFxlSj/9ANVbv7pXw6d6C/RWMN3VC7KBOu9omRXrzPGgdGmxBlSAsA35lsqZ5 GOFApu/GKMw+vE0YMdZmMLUOZqgbCqZj0lzct7I2XmEu8VljaHg+/kZZneHl5bpWkMSA 70xB7OMm+jFcD4CVDKJP33SZouJOfBOfxkrcCqL9NBpW5ZSpuKDYwTQyRWB3XAI6JU5L niDw== 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=pY7YptV5jK52/EGSfz+70ZXeLAnSsRhMupI/NGLlfao=; b=ZMM+zgIpZZWvEc3j+XuTx6k+KjEUgP6ONhyCICcbXKniSPyj35YUisU6EimwcWTWRU R47Rxvo8Gumlmlxt4wa4SqZuT6UL2c+KxCchjLq0la2yUCHPUpOKGDONezHbI3ITMByk OLiUjD9QMP50CKAQvCYw76QGL/I7MBH4XN/19jIavUYjmc97tsE655B0qi/OVlIuqu5E szVzthCZIeh9jGQ3EocUr6gWm06nRjP9lYhL2fM96G54mV3zsWtWYJTj3tpx0agXRnpC EBJyp1TxjfO8eTtuTZuI0cocB1+8GwypJ9c6biGydX7amev/lFqXf907P/jH0qtlU0at iAOg== X-Gm-Message-State: AOAM530rXRKgVpQ5T7XdrQkx4Speh/V5UPFZde/QKAJomOKHShMdMssX BLk+Xj75HTuh+2lpWSweU6tI4q1voDRrOA== X-Google-Smtp-Source: ABdhPJwYnH+zP4tJHNiwsPCY34BxnpN42esb6FVkVb1xKT3Mz8oXyJU+qAP/5Rw06kBrG0jF6hGNXw== X-Received: by 2002:a17:90a:f211:: with SMTP id bs17mr138622pjb.153.1604633400809; Thu, 05 Nov 2020 19:30:00 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 27/41] tcg/ppc: Support split-wx code generation Date: Thu, 5 Nov 2020 19:29:07 -0800 Message-Id: <20201106032921.600200-28-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201106032921.600200-1-richard.henderson@linaro.org> References: <20201106032921.600200-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::542; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x542.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. 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: j@getutm.app 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/ppc/tcg-target.h | 2 +- tcg/ppc/tcg-target.c.inc | 53 +++++++++++++++++++++++----------------- 2 files changed, 31 insertions(+), 24 deletions(-) diff --git a/tcg/ppc/tcg-target.h b/tcg/ppc/tcg-target.h index 78d6a5e96f..a8628b6cad 100644 --- a/tcg/ppc/tcg-target.h +++ b/tcg/ppc/tcg-target.h @@ -185,6 +185,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/ppc/tcg-target.c.inc b/tcg/ppc/tcg-target.c.inc index 91d5d95ddf..fe33687787 100644 --- a/tcg/ppc/tcg-target.c.inc +++ b/tcg/ppc/tcg-target.c.inc @@ -62,8 +62,6 @@ #define TCG_CT_CONST_MONE 0x2000 #define TCG_CT_CONST_WSZ 0x4000 =20 -static tcg_insn_unit *tb_ret_addr; - TCGPowerISA have_isa; static bool have_isel; bool have_altivec; @@ -184,35 +182,41 @@ static inline bool in_range_b(tcg_target_long target) return target =3D=3D sextract64(target, 0, 26); } =20 -static uint32_t reloc_pc24_val(tcg_insn_unit *pc, const tcg_insn_unit *tar= get) +static uint32_t reloc_pc24_val(const tcg_insn_unit *pc, + const tcg_insn_unit *target) { ptrdiff_t disp =3D tcg_ptr_byte_diff(target, pc); tcg_debug_assert(in_range_b(disp)); return disp & 0x3fffffc; } =20 -static bool reloc_pc24(tcg_insn_unit *pc, tcg_insn_unit *target) +static bool reloc_pc24(tcg_insn_unit *src_rw, const tcg_insn_unit *target) { - ptrdiff_t disp =3D tcg_ptr_byte_diff(target, pc); + const tcg_insn_unit *src_rx =3D tcg_splitwx_to_rx(src_rw); + ptrdiff_t disp =3D tcg_ptr_byte_diff(target, src_rx); + if (in_range_b(disp)) { - *pc =3D (*pc & ~0x3fffffc) | (disp & 0x3fffffc); + *src_rw =3D (*src_rw & ~0x3fffffc) | (disp & 0x3fffffc); return true; } return false; } =20 -static uint16_t reloc_pc14_val(tcg_insn_unit *pc, const tcg_insn_unit *tar= get) +static uint16_t reloc_pc14_val(const tcg_insn_unit *pc, + const tcg_insn_unit *target) { ptrdiff_t disp =3D tcg_ptr_byte_diff(target, pc); tcg_debug_assert(disp =3D=3D (int16_t) disp); return disp & 0xfffc; } =20 -static bool reloc_pc14(tcg_insn_unit *pc, tcg_insn_unit *target) +static bool reloc_pc14(tcg_insn_unit *src_rw, const tcg_insn_unit *target) { - ptrdiff_t disp =3D tcg_ptr_byte_diff(target, pc); + const tcg_insn_unit *src_rx =3D tcg_splitwx_to_rx(src_rw); + ptrdiff_t disp =3D tcg_ptr_byte_diff(target, src_rx); + if (disp =3D=3D (int16_t) disp) { - *pc =3D (*pc & ~0xfffc) | (disp & 0xfffc); + *src_rw =3D (*src_rw & ~0xfffc) | (disp & 0xfffc); return true; } return false; @@ -673,12 +677,12 @@ static const uint32_t tcg_to_isel[] =3D { static bool patch_reloc(tcg_insn_unit *code_ptr, int type, intptr_t value, intptr_t addend) { - tcg_insn_unit *target; + const tcg_insn_unit *target; int16_t lo; int32_t hi; =20 value +=3D addend; - target =3D (tcg_insn_unit *)value; + target =3D (const tcg_insn_unit *)value; =20 switch (type) { case R_PPC_REL14: @@ -1544,7 +1548,7 @@ static void tcg_out_setcond(TCGContext *s, TCGType ty= pe, TCGCond cond, static void tcg_out_bc(TCGContext *s, int bc, TCGLabel *l) { if (l->has_value) { - bc |=3D reloc_pc14_val(s->code_ptr, l->u.value_ptr); + bc |=3D reloc_pc14_val(tcg_splitwx_to_rx(s->code_ptr), l->u.value_= ptr); } else { tcg_out_reloc(s, s->code_ptr, R_PPC_REL14, l, 0); } @@ -1997,7 +2001,8 @@ static void add_qemu_ldst_label(TCGContext *s, bool i= s_ld, TCGMemOpIdx oi, label->datahi_reg =3D datahi_reg; label->addrlo_reg =3D addrlo_reg; label->addrhi_reg =3D addrhi_reg; - 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 lptr; } =20 @@ -2007,7 +2012,7 @@ static bool tcg_out_qemu_ld_slow_path(TCGContext *s, = TCGLabelQemuLdst *lb) MemOp opc =3D get_memop(oi); TCGReg hi, lo, arg =3D TCG_REG_R3; =20 - if (!reloc_pc14(lb->label_ptr[0], s->code_ptr)) { + if (!reloc_pc14(lb->label_ptr[0], tcg_splitwx_to_rx(s->code_ptr))) { return false; } =20 @@ -2055,7 +2060,7 @@ static bool tcg_out_qemu_st_slow_path(TCGContext *s, = TCGLabelQemuLdst *lb) MemOp s_bits =3D opc & MO_SIZE; TCGReg hi, lo, arg =3D TCG_REG_R3; =20 - if (!reloc_pc14(lb->label_ptr[0], s->code_ptr)) { + if (!reloc_pc14(lb->label_ptr[0], tcg_splitwx_to_rx(s->code_ptr))) { return false; } =20 @@ -2306,10 +2311,10 @@ static void tcg_target_qemu_prologue(TCGContext *s) int i; =20 #ifdef _CALL_AIX - void **desc =3D (void **)s->code_ptr; - desc[0] =3D desc + 2; /* entry point */ - desc[1] =3D 0; /* environment pointer */ - s->code_ptr =3D (void *)(desc + 2); /* skip over descriptor */ + const void **desc =3D (const void **)s->code_ptr; + desc[0] =3D tcg_splitwx_to_rx(desc + 2); /* entry point */ + desc[1] =3D 0; /* environment pointer */ + s->code_ptr =3D (void *)(desc + 2); /* skip over descriptor */ #endif =20 tcg_set_frame(s, TCG_REG_CALL_STACK, REG_SAVE_BOT - CPU_TEMP_BUF_SIZE, @@ -2341,7 +2346,8 @@ static void tcg_target_qemu_prologue(TCGContext *s) tcg_out32(s, BCCTR | BO_ALWAYS); =20 /* Epilogue */ - tcg_code_gen_epilogue =3D tb_ret_addr =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); =20 tcg_out_ld(s, TCG_TYPE_PTR, TCG_REG_R0, TCG_REG_R1, FRAME_SIZE+LR_OFFS= ET); for (i =3D 0; i < ARRAY_SIZE(tcg_target_callee_save_regs); ++i) { @@ -2362,7 +2368,7 @@ static void tcg_out_op(TCGContext *s, TCGOpcode opc, = const TCGArg *args, switch (opc) { case INDEX_op_exit_tb: tcg_out_movi(s, TCG_TYPE_PTR, TCG_REG_R3, args[0]); - tcg_out_b(s, 0, tb_ret_addr); + tcg_out_b(s, 0, tcg_code_gen_epilogue); break; case INDEX_op_goto_tb: if (s->tb_jmp_insn_offset) { @@ -2410,7 +2416,8 @@ static void tcg_out_op(TCGContext *s, TCGOpcode opc, = const TCGArg *args, uint32_t insn =3D B; =20 if (l->has_value) { - insn |=3D reloc_pc24_val(s->code_ptr, l->u.value_ptr); + insn |=3D reloc_pc24_val(tcg_splitwx_to_rx(s->code_ptr), + l->u.value_ptr); } else { tcg_out_reloc(s, s->code_ptr, R_PPC_REL24, l, 0); } --=20 2.25.1