From nobody Tue May 21 02:31:22 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=1629318138; cv=none; d=zohomail.com; s=zohoarc; b=dQm1b8mArh/MXHouBC4GKD44FrvfVpGMpPzfMatS6l/DSoNet/f85MiO9/AOg21kpne4GAV4jG/2TaQZ73sSPZczymiDSQ8whz+ENwlO/mdAM9t5aAa4QakD61Pa8D7AeXhKsPTGKYTfFUqIZ/4/SWmooxmRXEdi1UZ5NM+J8Os= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1629318138; h=Content-Transfer-Encoding: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=TW2jPB+qt2tYLCLMQFTHUpeWPukL7tgvM1aowRW86hI=; b=YkN4zaonUeC5mRqRkSuc1ur/qC0c3vc4Z6Nr9oIeDZPS6Y2sjt5mIWJfSZLVP1PyuC2VbimjffFdgxagrQ4Q9lkHhACItZzNRJLicevIfsSYKo71J+A7uqFMaWOa0wgxIodO8HDm4m9aS+gQErfvkV6O9fazXR+B2KQplmZ0zXg= 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) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1629318138474338.6565896401428; Wed, 18 Aug 2021 13:22:18 -0700 (PDT) Received: from localhost ([::1]:42722 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mGS4k-0002Wx-Ua for importer@patchew.org; Wed, 18 Aug 2021 16:22:16 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40194) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mGS2J-0007zU-KL for qemu-devel@nongnu.org; Wed, 18 Aug 2021 16:19:43 -0400 Received: from mail-pf1-x429.google.com ([2607:f8b0:4864:20::429]:39691) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mGS2D-00066z-BO for qemu-devel@nongnu.org; Wed, 18 Aug 2021 16:19:43 -0400 Received: by mail-pf1-x429.google.com with SMTP id t13so3334495pfl.6 for ; Wed, 18 Aug 2021 13:19:36 -0700 (PDT) Received: from localhost.localdomain ([173.197.107.15]) by smtp.gmail.com with ESMTPSA id x13sm619621pjh.30.2021.08.18.13.19.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Aug 2021 13:19:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=TW2jPB+qt2tYLCLMQFTHUpeWPukL7tgvM1aowRW86hI=; b=yUjnjwCDD8adKLXQfGGIzgqtrpnGtmTC0IgFivRXjOTldM20Uao3JEj9UnjOaamXwH xd/Cd/dI4fbQaIUTMQ8VSlqZAsbJ4/A7H+69gQ+4a/isYWYziRNyhQ/KZKPFTebM4rHv Nv36JX8Xd68tBX+0Njm7Z0NMvqAMZyvQN2/MCutbXNJXtlug19WLTzf/AtAL86tTpy7g UkG/s49QpMlvMc4znWxdENrc6y9C8EKjZNgKMHmcZZpgs3XFXsvpe1fIt4lPtgl3QJTw tOaTjQIeM5mjmxb6+TI75ujyCo9Sj7K2U0fmzPzFZmXAQyHMFDWzupGBEUOHAEotu7ar lLLg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=TW2jPB+qt2tYLCLMQFTHUpeWPukL7tgvM1aowRW86hI=; b=MFVUEIDU9eKbjMVtN1Qt5Zebtlw2vJ2NvGIVscIQnSNz/5rL70ffcSzU7FlLg1DGAn 3Vl0lc18s1ZLEdW/kehavVRC2DcRsOKbt1Xc3R0bfHxpHUYjPX9RwPzUIalKxGeX0z5V nbFcohKmZB3vTs47CKkMmn6xeoGFiEfO8WFJDczLByuEWot7gcJ8yIYepdom3YVuRLst pL+j/dERBhd9oQ3qxVI6dFmergLsJDCHXZ3xRTd1eKHG8QOymoMYMpd1ySimd/YxYU9L Katgr6EWQwxif6+F96QHD2Tvuf/Ozxp9y4ITw5wquLGDfIK5AnbNZobtvRqYBnI5GiGO U7gw== X-Gm-Message-State: AOAM533hZG+HzNmg3XaZem+ETBQh69euu/KPknh8pXHi6hyOL9wfwzOI VWy+lzul6WMQIPcD70Olhy2m/vPnL4T5xA== X-Google-Smtp-Source: ABdhPJxfhwm1QOogYDU/qn3PpHWdq2pZOcByW5kJxwsMUo1bRyWwMdPTRfwGHdszDBYjlEh0oFPeKw== X-Received: by 2002:a63:790b:: with SMTP id u11mr10394040pgc.71.1629317975388; Wed, 18 Aug 2021 13:19:35 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 01/16] tcg/mips: Support unaligned access for user-only Date: Wed, 18 Aug 2021 10:19:16 -1000 Message-Id: <20210818201931.393394-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210818201931.393394-1-richard.henderson@linaro.org> References: <20210818201931.393394-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::429; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x429.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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1629318140231100001 Content-Type: text/plain; charset="utf-8" This is kinda sorta the opposite of the other tcg hosts, where we get (normal) alignment checks for free with host SIGBUS and need to add code to support unaligned accesses. Fortunately, the ISA contains pairs of instructions that are used to implement unaligned memory accesses. Use them. Signed-off-by: Richard Henderson --- tcg/mips/tcg-target.h | 2 - tcg/mips/tcg-target.c.inc | 324 +++++++++++++++++++++++++++++++++++++- 2 files changed, 318 insertions(+), 8 deletions(-) diff --git a/tcg/mips/tcg-target.h b/tcg/mips/tcg-target.h index 3a62055f04..3afbb31918 100644 --- a/tcg/mips/tcg-target.h +++ b/tcg/mips/tcg-target.h @@ -209,8 +209,6 @@ extern bool use_mips32r2_instructions; =20 void tb_target_set_jmp_target(uintptr_t, uintptr_t, uintptr_t, uintptr_t); =20 -#ifdef CONFIG_SOFTMMU #define TCG_TARGET_NEED_LDST_LABELS -#endif =20 #endif diff --git a/tcg/mips/tcg-target.c.inc b/tcg/mips/tcg-target.c.inc index 02dc4b63ae..7ed0de9dae 100644 --- a/tcg/mips/tcg-target.c.inc +++ b/tcg/mips/tcg-target.c.inc @@ -24,6 +24,8 @@ * THE SOFTWARE. */ =20 +#include "../tcg-ldst.c.inc" + #ifdef HOST_WORDS_BIGENDIAN # define MIPS_BE 1 #else @@ -230,16 +232,26 @@ typedef enum { OPC_ORI =3D 015 << 26, OPC_XORI =3D 016 << 26, OPC_LUI =3D 017 << 26, + OPC_BNEL =3D 025 << 26, + OPC_BNEZALC_R6 =3D 030 << 26, OPC_DADDIU =3D 031 << 26, + OPC_LDL =3D 032 << 26, + OPC_LDR =3D 033 << 26, OPC_LB =3D 040 << 26, OPC_LH =3D 041 << 26, + OPC_LWL =3D 042 << 26, OPC_LW =3D 043 << 26, OPC_LBU =3D 044 << 26, OPC_LHU =3D 045 << 26, + OPC_LWR =3D 046 << 26, OPC_LWU =3D 047 << 26, OPC_SB =3D 050 << 26, OPC_SH =3D 051 << 26, + OPC_SWL =3D 052 << 26, OPC_SW =3D 053 << 26, + OPC_SDL =3D 054 << 26, + OPC_SDR =3D 055 << 26, + OPC_SWR =3D 056 << 26, OPC_LD =3D 067 << 26, OPC_SD =3D 077 << 26, =20 @@ -1035,8 +1047,6 @@ static void tcg_out_call(TCGContext *s, const tcg_ins= n_unit *arg) } =20 #if defined(CONFIG_SOFTMMU) -#include "../tcg-ldst.c.inc" - static void * const qemu_ld_helpers[(MO_SSIZE | MO_BSWAP) + 1] =3D { [MO_UB] =3D helper_ret_ldub_mmu, [MO_SB] =3D helper_ret_ldsb_mmu, @@ -1344,7 +1354,82 @@ static bool tcg_out_qemu_st_slow_path(TCGContext *s,= TCGLabelQemuLdst *l) tcg_out_mov(s, TCG_TYPE_PTR, tcg_target_call_iarg_regs[0], TCG_AREG0); return true; } -#endif + +#else + +static void tcg_out_test_alignment(TCGContext *s, bool is_ld, TCGReg addrl= o, + TCGReg addrhi, unsigned a_bits) +{ + unsigned a_mask =3D (1 << a_bits) - 1; + TCGLabelQemuLdst *l =3D new_ldst_label(s); + + l->is_ld =3D is_ld; + l->addrlo_reg =3D addrlo; + l->addrhi_reg =3D addrhi; + + /* We are expecting a_bits to max out at 7, much lower than ANDI. */ + tcg_debug_assert(a_bits < 16); + tcg_out_opc_imm(s, OPC_ANDI, TCG_TMP0, addrlo, a_mask); + + l->label_ptr[0] =3D s->code_ptr; + if (use_mips32r6_instructions) { + tcg_out_opc_br(s, OPC_BNEZALC_R6, TCG_REG_ZERO, TCG_TMP0); + } else { + tcg_out_opc_br(s, OPC_BNEL, TCG_TMP0, TCG_REG_ZERO); + tcg_out_nop(s); + } + + l->raddr =3D tcg_splitwx_to_rx(s->code_ptr); +} + +static bool tcg_out_fail_alignment(TCGContext *s, TCGLabelQemuLdst *l) +{ + void *target; + + if (!reloc_pc16(l->label_ptr[0], tcg_splitwx_to_rx(s->code_ptr))) { + return false; + } + + if (TCG_TARGET_REG_BITS < TARGET_LONG_BITS) { + /* A0 is env, A1 is skipped, A2:A3 is the uint64_t address. */ + TCGReg a2 =3D MIPS_BE ? l->addrhi_reg : l->addrlo_reg; + TCGReg a3 =3D MIPS_BE ? l->addrlo_reg : l->addrhi_reg; + + if (a3 !=3D TCG_REG_A2) { + tcg_out_mov(s, TCG_TYPE_I32, TCG_REG_A2, a2); + tcg_out_mov(s, TCG_TYPE_I32, TCG_REG_A3, a3); + } else if (a2 !=3D TCG_REG_A3) { + tcg_out_mov(s, TCG_TYPE_I32, TCG_REG_A3, a3); + tcg_out_mov(s, TCG_TYPE_I32, TCG_REG_A2, a2); + } else { + tcg_out_mov(s, TCG_TYPE_I32, TCG_TMP0, TCG_REG_A2); + tcg_out_mov(s, TCG_TYPE_I32, TCG_REG_A2, TCG_REG_A3); + tcg_out_mov(s, TCG_TYPE_I32, TCG_REG_A3, TCG_TMP0); + } + } else { + tcg_out_mov(s, TCG_TYPE_TL, TCG_REG_A1, l->addrlo_reg); + } + tcg_out_mov(s, TCG_TYPE_PTR, TCG_REG_A0, TCG_AREG0); + + /* + * Tail call to the helper, with the return address back inline. + * We have arrived here via BNEL, so $31 is already set. + */ + target =3D (l->is_ld ? helper_unaligned_ld : helper_unaligned_st); + tcg_out_call_int(s, target, true); + return true; +} + +static bool tcg_out_qemu_ld_slow_path(TCGContext *s, TCGLabelQemuLdst *l) +{ + return tcg_out_fail_alignment(s, l); +} + +static bool tcg_out_qemu_st_slow_path(TCGContext *s, TCGLabelQemuLdst *l) +{ + return tcg_out_fail_alignment(s, l); +} +#endif /* SOFTMMU */ =20 static void tcg_out_qemu_ld_direct(TCGContext *s, TCGReg lo, TCGReg hi, TCGReg base, MemOp opc, bool is_64) @@ -1450,6 +1535,117 @@ static void tcg_out_qemu_ld_direct(TCGContext *s, T= CGReg lo, TCGReg hi, } } =20 +static void __attribute__((unused)) +tcg_out_qemu_ld_unalign(TCGContext *s, TCGReg lo, TCGReg hi, + TCGReg base, MemOp opc, bool is_64) +{ + const MIPSInsn lw1 =3D MIPS_BE ? OPC_LWL : OPC_LWR; + const MIPSInsn lw2 =3D MIPS_BE ? OPC_LWR : OPC_LWL; + const MIPSInsn ld1 =3D MIPS_BE ? OPC_LDL : OPC_LDR; + const MIPSInsn ld2 =3D MIPS_BE ? OPC_LDR : OPC_LDL; + + bool sgn =3D (opc & MO_SIGN); + + switch (opc & (MO_SSIZE | MO_BSWAP)) { + case MO_SW | MO_BE: + case MO_UW | MO_BE: + tcg_out_opc_imm(s, sgn ? OPC_LB : OPC_LBU, TCG_TMP0, base, 0); + tcg_out_opc_imm(s, OPC_LBU, TCG_TMP1, base, 1); + tcg_out_opc_sa(s, OPC_SLL, TCG_TMP0, TCG_TMP0, 8); + tcg_out_opc_reg(s, OPC_OR, lo, TCG_TMP0, TCG_TMP1); + break; + + case MO_SW | MO_LE: + case MO_UW | MO_LE: + tcg_out_opc_imm(s, OPC_LBU, TCG_TMP0, base, 0); + tcg_out_opc_imm(s, sgn ? OPC_LB : OPC_LBU, TCG_TMP1, base, 1); + tcg_out_opc_sa(s, OPC_SLL, TCG_TMP1, TCG_TMP1, 8); + tcg_out_opc_reg(s, OPC_OR, lo, TCG_TMP0, TCG_TMP1); + break; + + case MO_SL: + case MO_UL: + tcg_out_opc_imm(s, lw1, lo, base, 0); + tcg_out_opc_imm(s, lw2, lo, base, 3); + if (TCG_TARGET_REG_BITS =3D=3D 64 && is_64 && !sgn) { + tcg_out_ext32u(s, lo, lo); + } + break; + + case MO_UL | MO_BSWAP: + case MO_SL | MO_BSWAP: + if (use_mips32r2_instructions) { + tcg_out_opc_imm(s, lw1, lo, base, 0); + tcg_out_opc_imm(s, lw2, lo, base, 3); + tcg_out_bswap32(s, lo, lo, + TCG_TARGET_REG_BITS =3D=3D 64 && is_64 + ? (sgn ? TCG_BSWAP_OS : TCG_BSWAP_OZ) : 0); + } else { + const tcg_insn_unit *subr =3D + (TCG_TARGET_REG_BITS =3D=3D 64 && is_64 && !sgn + ? bswap32u_addr : bswap32_addr); + + tcg_out_opc_imm(s, lw1, TCG_TMP0, base, 0); + tcg_out_bswap_subr(s, subr); + /* delay slot */ + tcg_out_opc_imm(s, lw2, TCG_TMP0, base, 3); + tcg_out_mov(s, is_64 ? TCG_TYPE_I64 : TCG_TYPE_I32, lo, TCG_TM= P3); + } + break; + + case MO_Q: + if (TCG_TARGET_REG_BITS =3D=3D 64) { + tcg_out_opc_imm(s, ld1, lo, base, 0); + tcg_out_opc_imm(s, ld2, lo, base, 7); + } else { + tcg_out_opc_imm(s, lw1, MIPS_BE ? hi : lo, base, 0 + 0); + tcg_out_opc_imm(s, lw2, MIPS_BE ? hi : lo, base, 0 + 3); + tcg_out_opc_imm(s, lw1, MIPS_BE ? lo : hi, base, 4 + 0); + tcg_out_opc_imm(s, lw2, MIPS_BE ? lo : hi, base, 4 + 3); + } + break; + + case MO_Q | MO_BSWAP: + if (TCG_TARGET_REG_BITS =3D=3D 64) { + if (use_mips32r2_instructions) { + tcg_out_opc_imm(s, ld1, lo, base, 0); + tcg_out_opc_imm(s, ld2, lo, base, 7); + tcg_out_bswap64(s, lo, lo); + } else { + tcg_out_opc_imm(s, ld1, TCG_TMP0, base, 0); + tcg_out_bswap_subr(s, bswap64_addr); + /* delay slot */ + tcg_out_opc_imm(s, ld2, TCG_TMP0, base, 7); + tcg_out_mov(s, TCG_TYPE_I64, lo, TCG_TMP3); + } + } else if (use_mips32r2_instructions) { + tcg_out_opc_imm(s, lw1, TCG_TMP0, base, 0 + 0); + tcg_out_opc_imm(s, lw2, TCG_TMP0, base, 0 + 3); + tcg_out_opc_imm(s, lw1, TCG_TMP1, base, 4 + 0); + tcg_out_opc_imm(s, lw2, TCG_TMP1, base, 4 + 3); + tcg_out_opc_reg(s, OPC_WSBH, TCG_TMP0, 0, TCG_TMP0); + tcg_out_opc_reg(s, OPC_WSBH, TCG_TMP1, 0, TCG_TMP1); + tcg_out_opc_sa(s, OPC_ROTR, MIPS_BE ? lo : hi, TCG_TMP0, 16); + tcg_out_opc_sa(s, OPC_ROTR, MIPS_BE ? hi : lo, TCG_TMP1, 16); + } else { + tcg_out_opc_imm(s, lw1, TCG_TMP0, base, 0 + 0); + tcg_out_bswap_subr(s, bswap32_addr); + /* delay slot */ + tcg_out_opc_imm(s, lw2, TCG_TMP0, base, 0 + 3); + tcg_out_opc_imm(s, lw1, TCG_TMP0, base, 4 + 0); + tcg_out_mov(s, TCG_TYPE_I32, MIPS_BE ? lo : hi, TCG_TMP3); + tcg_out_bswap_subr(s, bswap32_addr); + /* delay slot */ + tcg_out_opc_imm(s, lw2, TCG_TMP0, base, 4 + 3); + tcg_out_mov(s, TCG_TYPE_I32, MIPS_BE ? hi : lo, TCG_TMP3); + } + break; + + default: + tcg_abort(); + } +} + static void tcg_out_qemu_ld(TCGContext *s, const TCGArg *args, bool is_64) { TCGReg addr_regl, addr_regh __attribute__((unused)); @@ -1458,6 +1654,8 @@ static void tcg_out_qemu_ld(TCGContext *s, const TCGA= rg *args, bool is_64) MemOp opc; #if defined(CONFIG_SOFTMMU) tcg_insn_unit *label_ptr[2]; +#else + unsigned a_bits, s_bits; #endif TCGReg base =3D TCG_REG_A0; =20 @@ -1487,7 +1685,27 @@ static void tcg_out_qemu_ld(TCGContext *s, const TCG= Arg *args, bool is_64) } else { tcg_out_opc_reg(s, ALIAS_PADD, base, TCG_GUEST_BASE_REG, addr_regl= ); } - tcg_out_qemu_ld_direct(s, data_regl, data_regh, base, opc, is_64); + a_bits =3D get_alignment_bits(opc); + s_bits =3D opc & MO_SIZE; + /* + * R6 removes the left/right instructions but requires the + * system to support misaligned memory accesses. + */ + if (use_mips32r6_instructions) { + if (a_bits) { + tcg_out_test_alignment(s, true, addr_regl, addr_regh, a_bits); + } + tcg_out_qemu_ld_direct(s, data_regl, data_regh, base, opc, is_64); + } else { + if (a_bits && a_bits !=3D s_bits) { + tcg_out_test_alignment(s, true, addr_regl, addr_regh, a_bits); + } + if (a_bits >=3D s_bits) { + tcg_out_qemu_ld_direct(s, data_regl, data_regh, base, opc, is_= 64); + } else { + tcg_out_qemu_ld_unalign(s, data_regl, data_regh, base, opc, is= _64); + } + } #endif } =20 @@ -1552,6 +1770,79 @@ static void tcg_out_qemu_st_direct(TCGContext *s, TC= GReg lo, TCGReg hi, } } =20 +static void __attribute__((unused)) +tcg_out_qemu_st_unalign(TCGContext *s, TCGReg lo, TCGReg hi, + TCGReg base, MemOp opc) +{ + const MIPSInsn sw1 =3D MIPS_BE ? OPC_SWL : OPC_SWR; + const MIPSInsn sw2 =3D MIPS_BE ? OPC_SWR : OPC_SWL; + const MIPSInsn sd1 =3D MIPS_BE ? OPC_SDL : OPC_SDR; + const MIPSInsn sd2 =3D MIPS_BE ? OPC_SDR : OPC_SDL; + + /* Don't clutter the code below with checks to avoid bswapping ZERO. = */ + if ((lo | hi) =3D=3D 0) { + opc &=3D ~MO_BSWAP; + } + + switch (opc & (MO_SIZE | MO_BSWAP)) { + case MO_16 | MO_BE: + tcg_out_opc_sa(s, OPC_SRL, TCG_TMP0, lo, 8); + tcg_out_opc_imm(s, OPC_SB, TCG_TMP0, base, 0); + tcg_out_opc_imm(s, OPC_SB, lo, base, 1); + break; + + case MO_16 | MO_LE: + tcg_out_opc_sa(s, OPC_SRL, TCG_TMP0, lo, 8); + tcg_out_opc_imm(s, OPC_SB, lo, base, 0); + tcg_out_opc_imm(s, OPC_SB, TCG_TMP0, base, 1); + break; + + case MO_32 | MO_BSWAP: + tcg_out_bswap32(s, TCG_TMP3, lo, 0); + lo =3D TCG_TMP3; + /* fall through */ + case MO_32: + tcg_out_opc_imm(s, sw1, lo, base, 0); + tcg_out_opc_imm(s, sw2, lo, base, 3); + break; + + case MO_64 | MO_BSWAP: + if (TCG_TARGET_REG_BITS =3D=3D 64) { + tcg_out_bswap64(s, TCG_TMP3, lo); + lo =3D TCG_TMP3; + } else if (use_mips32r2_instructions) { + tcg_out_opc_reg(s, OPC_WSBH, TCG_TMP0, 0, MIPS_BE ? hi : lo); + tcg_out_opc_reg(s, OPC_WSBH, TCG_TMP1, 0, MIPS_BE ? lo : hi); + tcg_out_opc_sa(s, OPC_ROTR, TCG_TMP0, TCG_TMP0, 16); + tcg_out_opc_sa(s, OPC_ROTR, TCG_TMP1, TCG_TMP1, 16); + hi =3D MIPS_BE ? TCG_TMP0 : TCG_TMP1; + lo =3D MIPS_BE ? TCG_TMP1 : TCG_TMP0; + } else { + tcg_out_bswap32(s, TCG_TMP3, MIPS_BE ? lo : hi, 0); + tcg_out_opc_imm(s, sw1, TCG_TMP3, base, 0); + tcg_out_opc_imm(s, sw2, TCG_TMP3, base, 3); + tcg_out_bswap32(s, TCG_TMP3, MIPS_BE ? hi : lo, 0); + tcg_out_opc_imm(s, sw1, TCG_TMP3, base, 4); + tcg_out_opc_imm(s, sw2, TCG_TMP3, base, 7); + break; + } + /* fall through */ + case MO_64: + if (TCG_TARGET_REG_BITS =3D=3D 64) { + tcg_out_opc_imm(s, sd1, lo, base, 0); + tcg_out_opc_imm(s, sd2, lo, base, 7); + } else { + tcg_out_opc_imm(s, sw1, MIPS_BE ? hi : lo, base, 0); + tcg_out_opc_imm(s, sw2, MIPS_BE ? hi : lo, base, 3); + tcg_out_opc_imm(s, sw1, MIPS_BE ? lo : hi, base, 4); + tcg_out_opc_imm(s, sw2, MIPS_BE ? lo : hi, base, 7); + } + break; + + default: + tcg_abort(); + } +} static void tcg_out_qemu_st(TCGContext *s, const TCGArg *args, bool is_64) { TCGReg addr_regl, addr_regh __attribute__((unused)); @@ -1560,6 +1851,8 @@ static void tcg_out_qemu_st(TCGContext *s, const TCGA= rg *args, bool is_64) MemOp opc; #if defined(CONFIG_SOFTMMU) tcg_insn_unit *label_ptr[2]; +#else + unsigned a_bits, s_bits; #endif TCGReg base =3D TCG_REG_A0; =20 @@ -1578,7 +1871,6 @@ static void tcg_out_qemu_st(TCGContext *s, const TCGA= rg *args, bool is_64) data_regl, data_regh, addr_regl, addr_regh, s->code_ptr, label_ptr); #else - base =3D TCG_REG_A0; if (TCG_TARGET_REG_BITS > TARGET_LONG_BITS) { tcg_out_ext32u(s, base, addr_regl); addr_regl =3D base; @@ -1590,7 +1882,27 @@ static void tcg_out_qemu_st(TCGContext *s, const TCG= Arg *args, bool is_64) } else { tcg_out_opc_reg(s, ALIAS_PADD, base, TCG_GUEST_BASE_REG, addr_regl= ); } - tcg_out_qemu_st_direct(s, data_regl, data_regh, base, opc); + a_bits =3D get_alignment_bits(opc); + s_bits =3D opc & MO_SIZE; + /* + * R6 removes the left/right instructions but requires the + * system to support misaligned memory accesses. + */ + if (use_mips32r6_instructions) { + if (a_bits) { + tcg_out_test_alignment(s, true, addr_regl, addr_regh, a_bits); + } + tcg_out_qemu_st_direct(s, data_regl, data_regh, base, opc); + } else { + if (a_bits && a_bits !=3D s_bits) { + tcg_out_test_alignment(s, true, addr_regl, addr_regh, a_bits); + } + if (a_bits >=3D s_bits) { + tcg_out_qemu_st_direct(s, data_regl, data_regh, base, opc); + } else { + tcg_out_qemu_st_unalign(s, data_regl, data_regh, base, opc); + } + } #endif } =20 --=20 2.25.1 From nobody Tue May 21 02:31:22 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=1629318725; cv=none; d=zohomail.com; s=zohoarc; b=h6sU6CzAE7eQHBE0+1BbHGsy1ccYzTtZmdiD8TnltlAMl3q//tAJb9BhXaT043Cps92y3N1DiHUw8FuH79jtSatWqP5LA5lBMb4KgNnRcsh8iVaF8rAOgYU8ZForBMPbLaqr5PJGdNCG/eLbIUFPNTpQyN6rNWQAyCKDM38flIs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1629318725; h=Content-Transfer-Encoding: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=r6oX0sSPyEwxmWKFqa3wE6vu1liF30zaILMwFsdFRog=; b=XEARW1mEvnkGmYV8H9RdDUglhTE+1xRuJQQYn6KTJl4+VttAogw4mhwHOO/MM+UTBdv0bzH6FtoWnnO3GSUnKVxk40Aq3vncYY16qRWsIbhRQwAnrId1j1iSP/U4/S1fIVDM8wt3vPUZ0O2gf1qKmOHII2wmKky8hhISURslBmk= 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) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1629318725864445.7424056351458; Wed, 18 Aug 2021 13:32:05 -0700 (PDT) Received: from localhost ([::1]:46930 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mGSEG-0007Uj-L1 for importer@patchew.org; Wed, 18 Aug 2021 16:32:04 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40186) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mGS2J-0007yQ-A3 for qemu-devel@nongnu.org; Wed, 18 Aug 2021 16:19:43 -0400 Received: from mail-pl1-x629.google.com ([2607:f8b0:4864:20::629]:36413) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mGS2H-00067C-6i for qemu-devel@nongnu.org; Wed, 18 Aug 2021 16:19:43 -0400 Received: by mail-pl1-x629.google.com with SMTP id f3so2563815plg.3 for ; Wed, 18 Aug 2021 13:19:37 -0700 (PDT) Received: from localhost.localdomain ([173.197.107.15]) by smtp.gmail.com with ESMTPSA id x13sm619621pjh.30.2021.08.18.13.19.35 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Aug 2021 13:19:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=r6oX0sSPyEwxmWKFqa3wE6vu1liF30zaILMwFsdFRog=; b=ygtet+A4A3yMhF+PdfcCHJxPE2XsgtrHUDsb5nX7JQpwdJYZ5VNP5fzsBUW/9XTlId 7XO64KJyjRdJgwZmXsHlYfaMBNvhY8D3eydvQ1duD6cErvb3Bdw2/LqSDdVLVfOPeSgp +RyS9LUNB9k+tMrdKql+jb5o4gTR5ptdJDwRguYP+RFt5Y8Ezv9SckVBZjKvTvhUZiHd aHV/9ffH1eBUyR9WOL+51Z8JvdtsbYTHgoaPP+K7hXzMVwr12Xiag7RJEaJokJHCohBt XxlcaFtDT1HV2wKBmOAzzW8Ei1P5N14qtMG6aYIIL9r8kiZihopO7wGqiIDR/k1qcRyg MBBg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=r6oX0sSPyEwxmWKFqa3wE6vu1liF30zaILMwFsdFRog=; b=mh+2j4afjmNKrjxL2Tq+jkqiMJ9BOEfBuAJ8ZqGtiNu3MUdNstssUPp/GDsMdphvWV Ecb9B1QfWB4vLVor3lGdBclG8bLxiEM0tgMcZHVXQ+vjdYO8NSI0rWIYQwbC6jgKDRmu hZb2NgPOJES+im/9Gfby9AUSyTmvoRQ7GwrxkQ+YG0mhzkLQHBcF7To6f4mNGqHZetX4 jDA5TujoDvHOYoeE4AB7qZY7OeM+KPAwvLTqxOHdmD/wJkbP9FN3U1e6lDjnyInwVBVe NlulGtUx1LX8XClhUXqq4vxtSlZWoPyQg0lkgJNjqKAN3UNQSCJnJwtuZBsZfIVkqokA cYWw== X-Gm-Message-State: AOAM533IZ6AvFiwOwlS+7LU+A2ZiZRvZEc6YKcw0Qr7JsB+61pf5PAza ATDIStI3qZ4Whz6sGYa6z3A1YCNQEmfabA== X-Google-Smtp-Source: ABdhPJz4ujo+OYUkSvCKV3jmFH+HKUlJiSUvJEIAG0IJZilmgWPV52nHNffUcyBXeCHi7vBHRMOuSg== X-Received: by 2002:a17:90a:9411:: with SMTP id r17mr11070536pjo.49.1629317976310; Wed, 18 Aug 2021 13:19:36 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 02/16] tcg/mips: Support unaligned access for softmmu Date: Wed, 18 Aug 2021 10:19:17 -1000 Message-Id: <20210818201931.393394-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210818201931.393394-1-richard.henderson@linaro.org> References: <20210818201931.393394-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::629; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x629.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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1629318726925100001 Content-Type: text/plain; charset="utf-8" We can use the routines just added for user-only to emit unaligned accesses in softmmu mode too. Signed-off-by: Richard Henderson Reviewed-by: Jiaxun Yang --- tcg/mips/tcg-target.c.inc | 91 ++++++++++++++++++++++----------------- 1 file changed, 51 insertions(+), 40 deletions(-) diff --git a/tcg/mips/tcg-target.c.inc b/tcg/mips/tcg-target.c.inc index 7ed0de9dae..3d6a0ba39e 100644 --- a/tcg/mips/tcg-target.c.inc +++ b/tcg/mips/tcg-target.c.inc @@ -1154,8 +1154,10 @@ static void tcg_out_tlb_load(TCGContext *s, TCGReg b= ase, TCGReg addrl, tcg_insn_unit *label_ptr[2], bool is_load) { MemOp opc =3D get_memop(oi); - unsigned s_bits =3D opc & MO_SIZE; unsigned a_bits =3D get_alignment_bits(opc); + unsigned s_bits =3D opc & MO_SIZE; + unsigned a_mask =3D (1 << a_bits) - 1; + unsigned s_mask =3D (1 << s_bits) - 1; int mem_index =3D get_mmuidx(oi); int fast_off =3D TLB_MASK_TABLE_OFS(mem_index); int mask_off =3D fast_off + offsetof(CPUTLBDescFast, mask); @@ -1163,7 +1165,7 @@ static void tcg_out_tlb_load(TCGContext *s, TCGReg ba= se, TCGReg addrl, int add_off =3D offsetof(CPUTLBEntry, addend); int cmp_off =3D (is_load ? offsetof(CPUTLBEntry, addr_read) : offsetof(CPUTLBEntry, addr_write)); - target_ulong mask; + target_ulong tlb_mask; =20 /* Load tlb_mask[mmu_idx] and tlb_table[mmu_idx]. */ tcg_out_ld(s, TCG_TYPE_PTR, TCG_TMP0, TCG_AREG0, mask_off); @@ -1177,27 +1179,13 @@ static void tcg_out_tlb_load(TCGContext *s, TCGReg = base, TCGReg addrl, /* Add the tlb_table pointer, creating the CPUTLBEntry address in TMP3= . */ tcg_out_opc_reg(s, ALIAS_PADD, TCG_TMP3, TCG_TMP3, TCG_TMP1); =20 - /* We don't currently support unaligned accesses. - We could do so with mips32r6. */ - if (a_bits < s_bits) { - a_bits =3D s_bits; - } - - /* Mask the page bits, keeping the alignment bits to compare against. = */ - mask =3D (target_ulong)TARGET_PAGE_MASK | ((1 << a_bits) - 1); - /* Load the (low-half) tlb comparator. */ if (TCG_TARGET_REG_BITS < TARGET_LONG_BITS) { - tcg_out_ld(s, TCG_TYPE_I32, TCG_TMP0, TCG_TMP3, cmp_off + LO_OFF); - tcg_out_movi(s, TCG_TYPE_I32, TCG_TMP1, mask); + tcg_out_ldst(s, OPC_LW, TCG_TMP0, TCG_TMP3, cmp_off + LO_OFF); } else { tcg_out_ldst(s, (TARGET_LONG_BITS =3D=3D 64 ? OPC_LD : TCG_TARGET_REG_BITS =3D=3D 64 ? OPC_LWU : OPC_L= W), TCG_TMP0, TCG_TMP3, cmp_off); - tcg_out_movi(s, TCG_TYPE_TL, TCG_TMP1, mask); - /* No second compare is required here; - load the tlb addend for the fast path. */ - tcg_out_ld(s, TCG_TYPE_PTR, TCG_TMP2, TCG_TMP3, add_off); } =20 /* Zero extend a 32-bit guest address for a 64-bit host. */ @@ -1205,7 +1193,25 @@ static void tcg_out_tlb_load(TCGContext *s, TCGReg b= ase, TCGReg addrl, tcg_out_ext32u(s, base, addrl); addrl =3D base; } - tcg_out_opc_reg(s, OPC_AND, TCG_TMP1, TCG_TMP1, addrl); + + /* + * Mask the page bits, keeping the alignment bits to compare against. + * For unaligned accesses, compare against the end of the access to + * verify that it does not cross a page boundary. + */ + tlb_mask =3D (target_ulong)TARGET_PAGE_MASK | a_mask; + tcg_out_movi(s, TCG_TYPE_I32, TCG_TMP1, tlb_mask); + if (a_mask >=3D s_mask) { + tcg_out_opc_reg(s, OPC_AND, TCG_TMP1, TCG_TMP1, addrl); + } else { + tcg_out_opc_imm(s, ALIAS_PADDI, TCG_TMP2, addrl, s_mask - a_mask); + tcg_out_opc_reg(s, OPC_AND, TCG_TMP1, TCG_TMP1, TCG_TMP2); + } + + if (TCG_TARGET_REG_BITS >=3D TARGET_LONG_BITS) { + /* Load the tlb addend for the fast path. */ + tcg_out_ld(s, TCG_TYPE_PTR, TCG_TMP2, TCG_TMP3, add_off); + } =20 label_ptr[0] =3D s->code_ptr; tcg_out_opc_br(s, OPC_BNE, TCG_TMP1, TCG_TMP0); @@ -1213,7 +1219,7 @@ static void tcg_out_tlb_load(TCGContext *s, TCGReg ba= se, TCGReg addrl, /* Load and test the high half tlb comparator. */ if (TCG_TARGET_REG_BITS < TARGET_LONG_BITS) { /* delay slot */ - tcg_out_ld(s, TCG_TYPE_I32, TCG_TMP0, TCG_TMP3, cmp_off + HI_OFF); + tcg_out_ldst(s, OPC_LW, TCG_TMP0, TCG_TMP3, cmp_off + HI_OFF); =20 /* Load the tlb addend for the fast path. */ tcg_out_ld(s, TCG_TYPE_PTR, TCG_TMP2, TCG_TMP3, add_off); @@ -1535,8 +1541,7 @@ static void tcg_out_qemu_ld_direct(TCGContext *s, TCG= Reg lo, TCGReg hi, } } =20 -static void __attribute__((unused)) -tcg_out_qemu_ld_unalign(TCGContext *s, TCGReg lo, TCGReg hi, +static void tcg_out_qemu_ld_unalign(TCGContext *s, TCGReg lo, TCGReg hi, TCGReg base, MemOp opc, bool is_64) { const MIPSInsn lw1 =3D MIPS_BE ? OPC_LWL : OPC_LWR; @@ -1655,8 +1660,8 @@ static void tcg_out_qemu_ld(TCGContext *s, const TCGA= rg *args, bool is_64) #if defined(CONFIG_SOFTMMU) tcg_insn_unit *label_ptr[2]; #else - unsigned a_bits, s_bits; #endif + unsigned a_bits, s_bits; TCGReg base =3D TCG_REG_A0; =20 data_regl =3D *args++; @@ -1665,10 +1670,20 @@ static void tcg_out_qemu_ld(TCGContext *s, const TC= GArg *args, bool is_64) addr_regh =3D (TCG_TARGET_REG_BITS < TARGET_LONG_BITS ? *args++ : 0); oi =3D *args++; opc =3D get_memop(oi); + a_bits =3D get_alignment_bits(opc); + s_bits =3D opc & MO_SIZE; =20 + /* + * R6 removes the left/right instructions but requires the + * system to support misaligned memory accesses. + */ #if defined(CONFIG_SOFTMMU) tcg_out_tlb_load(s, base, addr_regl, addr_regh, oi, label_ptr, 1); - tcg_out_qemu_ld_direct(s, data_regl, data_regh, base, opc, is_64); + if (use_mips32r6_instructions || a_bits >=3D s_bits) { + tcg_out_qemu_ld_direct(s, data_regl, data_regh, base, opc, is_64); + } else { + tcg_out_qemu_ld_unalign(s, data_regl, data_regh, base, opc, is_64); + } add_qemu_ldst_label(s, 1, oi, (is_64 ? TCG_TYPE_I64 : TCG_TYPE_I32), data_regl, data_regh, addr_regl, addr_regh, @@ -1685,12 +1700,6 @@ static void tcg_out_qemu_ld(TCGContext *s, const TCG= Arg *args, bool is_64) } else { tcg_out_opc_reg(s, ALIAS_PADD, base, TCG_GUEST_BASE_REG, addr_regl= ); } - a_bits =3D get_alignment_bits(opc); - s_bits =3D opc & MO_SIZE; - /* - * R6 removes the left/right instructions but requires the - * system to support misaligned memory accesses. - */ if (use_mips32r6_instructions) { if (a_bits) { tcg_out_test_alignment(s, true, addr_regl, addr_regh, a_bits); @@ -1770,8 +1779,7 @@ static void tcg_out_qemu_st_direct(TCGContext *s, TCG= Reg lo, TCGReg hi, } } =20 -static void __attribute__((unused)) -tcg_out_qemu_st_unalign(TCGContext *s, TCGReg lo, TCGReg hi, +static void tcg_out_qemu_st_unalign(TCGContext *s, TCGReg lo, TCGReg hi, TCGReg base, MemOp opc) { const MIPSInsn sw1 =3D MIPS_BE ? OPC_SWL : OPC_SWR; @@ -1851,9 +1859,8 @@ static void tcg_out_qemu_st(TCGContext *s, const TCGA= rg *args, bool is_64) MemOp opc; #if defined(CONFIG_SOFTMMU) tcg_insn_unit *label_ptr[2]; -#else - unsigned a_bits, s_bits; #endif + unsigned a_bits, s_bits; TCGReg base =3D TCG_REG_A0; =20 data_regl =3D *args++; @@ -1862,10 +1869,20 @@ static void tcg_out_qemu_st(TCGContext *s, const TC= GArg *args, bool is_64) addr_regh =3D (TCG_TARGET_REG_BITS < TARGET_LONG_BITS ? *args++ : 0); oi =3D *args++; opc =3D get_memop(oi); + a_bits =3D get_alignment_bits(opc); + s_bits =3D opc & MO_SIZE; =20 + /* + * R6 removes the left/right instructions but requires the + * system to support misaligned memory accesses. + */ #if defined(CONFIG_SOFTMMU) tcg_out_tlb_load(s, base, addr_regl, addr_regh, oi, label_ptr, 0); - tcg_out_qemu_st_direct(s, data_regl, data_regh, base, opc); + if (use_mips32r6_instructions || a_bits >=3D s_bits) { + tcg_out_qemu_st_direct(s, data_regl, data_regh, base, opc); + } else { + tcg_out_qemu_st_unalign(s, data_regl, data_regh, base, opc); + } add_qemu_ldst_label(s, 0, oi, (is_64 ? TCG_TYPE_I64 : TCG_TYPE_I32), data_regl, data_regh, addr_regl, addr_regh, @@ -1882,12 +1899,6 @@ static void tcg_out_qemu_st(TCGContext *s, const TCG= Arg *args, bool is_64) } else { tcg_out_opc_reg(s, ALIAS_PADD, base, TCG_GUEST_BASE_REG, addr_regl= ); } - a_bits =3D get_alignment_bits(opc); - s_bits =3D opc & MO_SIZE; - /* - * R6 removes the left/right instructions but requires the - * system to support misaligned memory accesses. - */ if (use_mips32r6_instructions) { if (a_bits) { tcg_out_test_alignment(s, true, addr_regl, addr_regh, a_bits); --=20 2.25.1 From nobody Tue May 21 02:31:22 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=1629318269; cv=none; d=zohomail.com; s=zohoarc; b=nzJ3gMJoLtnGxN6GFWiPuYsUqyZszJRNfrIa4oTfYMAOZAvdN6mqDK2wzM3yLpMgvjVEFTbVN85V0uraY/BpTSeP3JxTtzOf0s3se1Wn9lO3mF6PradtTOdk31vqeV/CJetGpab4FXRBEIsNkuNWr6yCPZW8utgQ+cWV2jcqhdY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1629318269; h=Content-Transfer-Encoding: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=wtevaJ7IG8tKFN4eF5alBUKWgZUImY9MLHAChMV4wyA=; b=m+eqeerxyLnbz39odiwen746J7AugXnilokGDBgxaE0RCcG0STsftU+ZIdEpEMIqQg/rX7JPLjhFmpOec4BrFwEA8q+ql9rqtIMfJt85ePWeccVVxk7zjpzS5V2dCU5cpVbdcUlDrpHxZ853ks1lOyCCKXb4hivxP4g8RigMzYw= 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) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1629318269468720.8197414089096; Wed, 18 Aug 2021 13:24:29 -0700 (PDT) Received: from localhost ([::1]:51556 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mGS6u-0008OD-Ft for importer@patchew.org; Wed, 18 Aug 2021 16:24:28 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40312) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mGS2N-00087Q-39 for qemu-devel@nongnu.org; Wed, 18 Aug 2021 16:19:47 -0400 Received: from mail-pf1-x42d.google.com ([2607:f8b0:4864:20::42d]:36541) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mGS2H-00068W-8c for qemu-devel@nongnu.org; Wed, 18 Aug 2021 16:19:46 -0400 Received: by mail-pf1-x42d.google.com with SMTP id m26so3335441pff.3 for ; Wed, 18 Aug 2021 13:19:38 -0700 (PDT) Received: from localhost.localdomain ([173.197.107.15]) by smtp.gmail.com with ESMTPSA id x13sm619621pjh.30.2021.08.18.13.19.36 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Aug 2021 13:19:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=wtevaJ7IG8tKFN4eF5alBUKWgZUImY9MLHAChMV4wyA=; b=hc3AtgXEfCSMbkeOqtNFiOP9bYpwAOYeZ7Fl1Jw4hCnAOkloMv8O0Y9KKCbRX+djPR czAagsKl13mcn+Xx38Vt190I1FlbfGhLzOTiKZ531nYs5fPux6ObKXrMgH3MYGVj9Dv5 lMgPwCLAlGV7AxWsX7fuYEc9TG5elKjVsWnrDt1VzEhc7vYdnhMIHZ3RfhmY79LgcPCf 7hPu8XUxBR1TgrCegc4Qo3yNGabt6yP7D+NBsFIk28GzN6Rp46w6Tcymi9i2zt56R2jE crYkgT6VXi9+iI4AvUV1auwhxuO5RcLXHPrrqeZWRbNtWYooaZxo585RAmhptJy740Uy Is9w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=wtevaJ7IG8tKFN4eF5alBUKWgZUImY9MLHAChMV4wyA=; b=RBuu6v+crFiZiWe4GVXtFXAVI9TMLz9ZqRNhWsok+f6kSgk3Pv1yj9KEWCqgIqPY0A YbkqX8Am0qNbpOMNlO2piubdCqUkVuh6I54L76mHlEz4eLYjUdwqLqezEpmOrHKO60Gi cSlqoZ+iC0PWY8zYYF8SEgmcUHp6UkL1OUBWRxOwOtb2+6GTkrE/AxEQ+TnjcnOkQpc0 RXICP78uIhfAgnbqxb918jItHc6X9lWCJOwSO9NwOFRrz+WRJy4g5+gumbKNtAjFE1Nq 5aLRrbHtbD1DNInX96FtDkuy6ucqLdbUnNcv8rA9mhJHEX7BIJrlvPUoYPJh08tQX04I F8aA== X-Gm-Message-State: AOAM532giTuGzAAzY8bgJIunf/51lSWOLS7+M2ST9H2VMZcqYIvV6dfi 3k4oTXp7x7Kyn0lPv5CbYkQIndKyVR7lpg== X-Google-Smtp-Source: ABdhPJwOdkzH3nz87ORrrKUOkVHf0DwcM3RmCuj8U3zdsfTBVEFcoUa7Le2MItfAcGxfWMkbSfh21w== X-Received: by 2002:a63:2024:: with SMTP id g36mr10474207pgg.213.1629317977238; Wed, 18 Aug 2021 13:19:37 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 03/16] tcg/mips: Drop inline markers Date: Wed, 18 Aug 2021 10:19:18 -1000 Message-Id: <20210818201931.393394-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210818201931.393394-1-richard.henderson@linaro.org> References: <20210818201931.393394-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::42d; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42d.google.com X-Spam_score_int: -1 X-Spam_score: -0.2 X-Spam_bar: / X-Spam_report: (-0.2 / 5.0 requ) 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1629318270014100003 Content-Type: text/plain; charset="utf-8" Let the compiler decide about inlining. Remove tcg_out_ext8s and tcg_out_ext16s as unused. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- tcg/mips/tcg-target.c.inc | 76 ++++++++++++++------------------------- 1 file changed, 27 insertions(+), 49 deletions(-) diff --git a/tcg/mips/tcg-target.c.inc b/tcg/mips/tcg-target.c.inc index 3d6a0ba39e..94f1bebdba 100644 --- a/tcg/mips/tcg-target.c.inc +++ b/tcg/mips/tcg-target.c.inc @@ -189,7 +189,7 @@ static bool patch_reloc(tcg_insn_unit *code_ptr, int ty= pe, #endif =20 =20 -static inline bool is_p2m1(tcg_target_long val) +static bool is_p2m1(tcg_target_long val) { return val && ((val + 1) & val) =3D=3D 0; } @@ -373,8 +373,8 @@ typedef enum { /* * Type reg */ -static inline void tcg_out_opc_reg(TCGContext *s, MIPSInsn opc, - TCGReg rd, TCGReg rs, TCGReg rt) +static void tcg_out_opc_reg(TCGContext *s, MIPSInsn opc, + TCGReg rd, TCGReg rs, TCGReg rt) { int32_t inst; =20 @@ -388,8 +388,8 @@ static inline void tcg_out_opc_reg(TCGContext *s, MIPSI= nsn opc, /* * Type immediate */ -static inline void tcg_out_opc_imm(TCGContext *s, MIPSInsn opc, - TCGReg rt, TCGReg rs, TCGArg imm) +static void tcg_out_opc_imm(TCGContext *s, MIPSInsn opc, + TCGReg rt, TCGReg rs, TCGArg imm) { int32_t inst; =20 @@ -403,8 +403,8 @@ static inline void tcg_out_opc_imm(TCGContext *s, MIPSI= nsn opc, /* * Type bitfield */ -static inline void tcg_out_opc_bf(TCGContext *s, MIPSInsn opc, TCGReg rt, - TCGReg rs, int msb, int lsb) +static void tcg_out_opc_bf(TCGContext *s, MIPSInsn opc, TCGReg rt, + TCGReg rs, int msb, int lsb) { int32_t inst; =20 @@ -416,8 +416,8 @@ static inline void tcg_out_opc_bf(TCGContext *s, MIPSIn= sn opc, TCGReg rt, tcg_out32(s, inst); } =20 -static inline void tcg_out_opc_bf64(TCGContext *s, MIPSInsn opc, MIPSInsn = opm, - MIPSInsn oph, TCGReg rt, TCGReg rs, +static void tcg_out_opc_bf64(TCGContext *s, MIPSInsn opc, MIPSInsn opm, + MIPSInsn oph, TCGReg rt, TCGReg rs, int msb, int lsb) { if (lsb >=3D 32) { @@ -434,8 +434,7 @@ static inline void tcg_out_opc_bf64(TCGContext *s, MIPS= Insn opc, MIPSInsn opm, /* * Type branch */ -static inline void tcg_out_opc_br(TCGContext *s, MIPSInsn opc, - TCGReg rt, TCGReg rs) +static void tcg_out_opc_br(TCGContext *s, MIPSInsn opc, TCGReg rt, TCGReg = rs) { tcg_out_opc_imm(s, opc, rt, rs, 0); } @@ -443,8 +442,8 @@ static inline void tcg_out_opc_br(TCGContext *s, MIPSIn= sn opc, /* * Type sa */ -static inline void tcg_out_opc_sa(TCGContext *s, MIPSInsn opc, - TCGReg rd, TCGReg rt, TCGArg sa) +static void tcg_out_opc_sa(TCGContext *s, MIPSInsn opc, + TCGReg rd, TCGReg rt, TCGArg sa) { int32_t inst; =20 @@ -491,28 +490,27 @@ static bool tcg_out_opc_jmp(TCGContext *s, MIPSInsn o= pc, const void *target) return true; } =20 -static inline void tcg_out_nop(TCGContext *s) +static void tcg_out_nop(TCGContext *s) { tcg_out32(s, 0); } =20 -static inline void tcg_out_dsll(TCGContext *s, TCGReg rd, TCGReg rt, TCGAr= g sa) +static void tcg_out_dsll(TCGContext *s, TCGReg rd, TCGReg rt, TCGArg sa) { tcg_out_opc_sa64(s, OPC_DSLL, OPC_DSLL32, rd, rt, sa); } =20 -static inline void tcg_out_dsrl(TCGContext *s, TCGReg rd, TCGReg rt, TCGAr= g sa) +static void tcg_out_dsrl(TCGContext *s, TCGReg rd, TCGReg rt, TCGArg sa) { tcg_out_opc_sa64(s, OPC_DSRL, OPC_DSRL32, rd, rt, sa); } =20 -static inline void tcg_out_dsra(TCGContext *s, TCGReg rd, TCGReg rt, TCGAr= g sa) +static void tcg_out_dsra(TCGContext *s, TCGReg rd, TCGReg rt, TCGArg sa) { tcg_out_opc_sa64(s, OPC_DSRA, OPC_DSRA32, rd, rt, sa); } =20 -static inline bool tcg_out_mov(TCGContext *s, TCGType type, - TCGReg ret, TCGReg arg) +static bool tcg_out_mov(TCGContext *s, TCGType type, TCGReg ret, TCGReg ar= g) { /* Simple reg-reg move, optimising out the 'do nothing' case */ if (ret !=3D arg) { @@ -624,27 +622,7 @@ static void tcg_out_bswap64(TCGContext *s, TCGReg ret,= TCGReg arg) } } =20 -static inline void tcg_out_ext8s(TCGContext *s, TCGReg ret, TCGReg arg) -{ - if (use_mips32r2_instructions) { - tcg_out_opc_reg(s, OPC_SEB, ret, 0, arg); - } else { - tcg_out_opc_sa(s, OPC_SLL, ret, arg, 24); - tcg_out_opc_sa(s, OPC_SRA, ret, ret, 24); - } -} - -static inline void tcg_out_ext16s(TCGContext *s, TCGReg ret, TCGReg arg) -{ - if (use_mips32r2_instructions) { - tcg_out_opc_reg(s, OPC_SEH, ret, 0, arg); - } else { - tcg_out_opc_sa(s, OPC_SLL, ret, arg, 16); - tcg_out_opc_sa(s, OPC_SRA, ret, ret, 16); - } -} - -static inline void tcg_out_ext32u(TCGContext *s, TCGReg ret, TCGReg arg) +static void tcg_out_ext32u(TCGContext *s, TCGReg ret, TCGReg arg) { if (use_mips32r2_instructions) { tcg_out_opc_bf(s, OPC_DEXT, ret, arg, 31, 0); @@ -668,8 +646,8 @@ static void tcg_out_ldst(TCGContext *s, MIPSInsn opc, T= CGReg data, tcg_out_opc_imm(s, opc, data, addr, lo); } =20 -static inline void tcg_out_ld(TCGContext *s, TCGType type, TCGReg arg, - TCGReg arg1, intptr_t arg2) +static void tcg_out_ld(TCGContext *s, TCGType type, TCGReg arg, + TCGReg arg1, intptr_t arg2) { MIPSInsn opc =3D OPC_LD; if (TCG_TARGET_REG_BITS =3D=3D 32 || type =3D=3D TCG_TYPE_I32) { @@ -678,8 +656,8 @@ static inline void tcg_out_ld(TCGContext *s, TCGType ty= pe, TCGReg arg, tcg_out_ldst(s, opc, arg, arg1, arg2); } =20 -static inline void tcg_out_st(TCGContext *s, TCGType type, TCGReg arg, - TCGReg arg1, intptr_t arg2) +static void tcg_out_st(TCGContext *s, TCGType type, TCGReg arg, + TCGReg arg1, intptr_t arg2) { MIPSInsn opc =3D OPC_SD; if (TCG_TARGET_REG_BITS =3D=3D 32 || type =3D=3D TCG_TYPE_I32) { @@ -688,8 +666,8 @@ static inline void tcg_out_st(TCGContext *s, TCGType ty= pe, TCGReg arg, tcg_out_ldst(s, opc, arg, arg1, arg2); } =20 -static inline bool tcg_out_sti(TCGContext *s, TCGType type, TCGArg val, - TCGReg base, intptr_t ofs) +static bool tcg_out_sti(TCGContext *s, TCGType type, TCGArg val, + TCGReg base, intptr_t ofs) { if (val =3D=3D 0) { tcg_out_st(s, type, TCG_REG_ZERO, base, ofs); @@ -1960,9 +1938,9 @@ static void tcg_out_clz(TCGContext *s, MIPSInsn opcv2= , MIPSInsn opcv6, } } =20 -static inline void tcg_out_op(TCGContext *s, TCGOpcode opc, - const TCGArg args[TCG_MAX_OP_ARGS], - const int const_args[TCG_MAX_OP_ARGS]) +static void tcg_out_op(TCGContext *s, TCGOpcode opc, + const TCGArg args[TCG_MAX_OP_ARGS], + const int const_args[TCG_MAX_OP_ARGS]) { MIPSInsn i1, i2; TCGArg a0, a1, a2; --=20 2.25.1 From nobody Tue May 21 02:31:22 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=1629318268; cv=none; d=zohomail.com; s=zohoarc; b=jhn4m9sbytIVMzG2KX8HzK9sRbPPAM3zOMMD17jJUYWRiBKTRDz8gIXv8fF/gKoXnwiljGawGZOCdsHvKWuZ/NhzOCEYDE3KwVnn2f2QhIlaTl/ZBgSrfM8+2PUH50JnzQZNT7Cu2dC30dOR4gOVk+X/iXNklCWJ4yOKxvDSiSA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1629318268; h=Content-Transfer-Encoding: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=+CMPBOKVQeWTwZGrxMiWTzbA3RbAllHepTMsTUswk6M=; b=bEqj/LjEhQIBZy0puKKCqvC0ASXAtbS3eBCgeya0mtdgPJxaItDU8XGjCXTJpzE/EGJ5rYiw1VzK5BxnrRYL9W0XfDSeY+y2I9Eu9Ogs7q3hfQzqR4cygRuih+/eo3NXLfCUwSRw07SHHRSgFKzUEXItEPXrlDAz8zkgBL40xkk= 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) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1629318268854745.4269850567825; Wed, 18 Aug 2021 13:24:28 -0700 (PDT) Received: from localhost ([::1]:51412 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mGS6t-0008Hg-M1 for importer@patchew.org; Wed, 18 Aug 2021 16:24:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40216) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mGS2K-00081W-L4 for qemu-devel@nongnu.org; Wed, 18 Aug 2021 16:19:44 -0400 Received: from mail-pf1-x42e.google.com ([2607:f8b0:4864:20::42e]:39696) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mGS2H-00068t-7p for qemu-devel@nongnu.org; Wed, 18 Aug 2021 16:19:44 -0400 Received: by mail-pf1-x42e.google.com with SMTP id t13so3334639pfl.6 for ; Wed, 18 Aug 2021 13:19:39 -0700 (PDT) Received: from localhost.localdomain ([173.197.107.15]) by smtp.gmail.com with ESMTPSA id x13sm619621pjh.30.2021.08.18.13.19.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Aug 2021 13:19:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=+CMPBOKVQeWTwZGrxMiWTzbA3RbAllHepTMsTUswk6M=; b=Zp2bL720Hll6EKYci/jXuMy8QpKRNEFGZinSwnDBhJVvnqNxnGwUwKDgcZ5DwwsVBp ICxX1CPTvpa3YJ64341/iQIHJ1Tm4gIWTFjj7h8mERmuAZrJqj4h6BX35lkixCIH7RDF qDVSH1o1kO3M/M/2rjDX8jQrwP79UHCOWP4GZs9Km8VT7o/0K0c1hW3RXLmuh4DkPd+f bmrU20OZtys6MQwCTV2Hp8CNCIlgobD0A5CvcbSKuyXXFQU3hLEQLZ5rKyP7RvzJMVvr Kh9Xv8709i3US18NzOCZmwKMfZTkvDVg4wen5uw0BqtcXMgUNjYWwIDkOqBOWIbUwyAg uBfg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=+CMPBOKVQeWTwZGrxMiWTzbA3RbAllHepTMsTUswk6M=; b=pumQw4Am+HEAMQkBGNQwoFIMViQyi/+ZLi0SsHLvvwwm1NuqcEMuUr+ANuF+QKY1IC tup7NwU5CbcVnLHG7VlW4M9Xtxm3oSe35kdV5IS1TqcJfLb8W4ScLIFebHecNbENc/kE WwWFaZVh9T2JhuB+f8XWbf1LjCeTxiKjb8v8uFBm73UZaKduIR/mcpRCHfBatfYPjPKb mGnyVVtan7ub7z/L7eY6J1LTYpf0NktRu3B7ZsCz8TQ9A53BR+X4eMcFNFwLsnUsL1JS M0hXdFu+8TS7LXX3wWVkXqjG/Ogr+BTKj1tRf9QBiAm+hu2OjvIvBO+0uVCqnEh7nnV4 KTYg== X-Gm-Message-State: AOAM530Wm9Our3MvM++LQ1zim5Sphiw7vTkDk59RlpfdDi68uskkG/o3 EEuds6dG3KYdP0PxlwnJTXEuZpcKiF28wQ== X-Google-Smtp-Source: ABdhPJwr/up1Vjpv30vuG6xsArjAtIzIwPr71QBUqZ1S+CU4i2NwcvRQ16FGH3sQCjrM9HzoDXVrMQ== X-Received: by 2002:a05:6a00:a0b:b0:3e1:e511:1224 with SMTP id p11-20020a056a000a0b00b003e1e5111224mr10795873pfh.67.1629317978188; Wed, 18 Aug 2021 13:19:38 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 04/16] tcg/mips: Move TCG_AREG0 to S8 Date: Wed, 18 Aug 2021 10:19:19 -1000 Message-Id: <20210818201931.393394-5-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210818201931.393394-1-richard.henderson@linaro.org> References: <20210818201931.393394-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::42e; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42e.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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1629318269941100001 Content-Type: text/plain; charset="utf-8" No functional change; just moving the saved reserved regs to the end. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- tcg/mips/tcg-target.h | 2 +- tcg/mips/tcg-target.c.inc | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tcg/mips/tcg-target.h b/tcg/mips/tcg-target.h index 3afbb31918..c34cccebd3 100644 --- a/tcg/mips/tcg-target.h +++ b/tcg/mips/tcg-target.h @@ -80,7 +80,7 @@ typedef enum { TCG_REG_RA, =20 TCG_REG_CALL_STACK =3D TCG_REG_SP, - TCG_AREG0 =3D TCG_REG_S0, + TCG_AREG0 =3D TCG_REG_S8, } TCGReg; =20 /* used for function call generation */ diff --git a/tcg/mips/tcg-target.c.inc b/tcg/mips/tcg-target.c.inc index 94f1bebdba..92bde50704 100644 --- a/tcg/mips/tcg-target.c.inc +++ b/tcg/mips/tcg-target.c.inc @@ -2542,7 +2542,7 @@ static TCGConstraintSetIndex tcg_target_op_def(TCGOpc= ode op) } =20 static const int tcg_target_callee_save_regs[] =3D { - TCG_REG_S0, /* used for the global env (TCG_AREG0) */ + TCG_REG_S0, TCG_REG_S1, TCG_REG_S2, TCG_REG_S3, @@ -2550,7 +2550,7 @@ static const int tcg_target_callee_save_regs[] =3D { TCG_REG_S5, TCG_REG_S6, TCG_REG_S7, - TCG_REG_S8, + TCG_REG_S8, /* used for the global env (TCG_AREG0) */ TCG_REG_RA, /* should be last for ABI compliance */ }; =20 --=20 2.25.1 From nobody Tue May 21 02:31:22 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=1629318145; cv=none; d=zohomail.com; s=zohoarc; b=hsm0vwJDCI2GnfxOJjM4X8nstYik/FyqLlT4tnUc1wZ97cwuP4FpkR00z4z+nQ5btVc2Q/9m8XxXDO2lNDKzAhjWmVF/la3BK3V61bH4ctEhYxLVj7tvmZybBP2CZOvaEfqzhAAp9WEZ6VMoOdru9qjjAWr19u4a8hxEDz294l0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1629318145; h=Content-Transfer-Encoding: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=3D/M6PiJA/KHiyIzYScTLEu+qTs2bRAx1trHXsXn6VU=; b=b9A4i8EtODA5QrsutV1RikGTckVXPvIqF54glit/HW0GDf82jaYd0eSoEvbUkimlvcZ+wDB0X3HwLi04+BxKPEbSNIvNYwRPL6M2qXbdL5QKVUk6D2GIY70SAMxv3WUJqEa4vJXxr3x8s/0/iZCl8eHBAF4bOBjfF9xJN1RYUq4= 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) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1629318145586205.68911540635997; Wed, 18 Aug 2021 13:22:25 -0700 (PDT) Received: from localhost ([::1]:42970 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mGS4u-0002gx-Eh for importer@patchew.org; Wed, 18 Aug 2021 16:22:24 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40262) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mGS2M-00084D-46 for qemu-devel@nongnu.org; Wed, 18 Aug 2021 16:19:46 -0400 Received: from mail-pg1-x52b.google.com ([2607:f8b0:4864:20::52b]:40597) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mGS2H-00069G-8Z for qemu-devel@nongnu.org; Wed, 18 Aug 2021 16:19:45 -0400 Received: by mail-pg1-x52b.google.com with SMTP id y23so3480910pgi.7 for ; Wed, 18 Aug 2021 13:19:39 -0700 (PDT) Received: from localhost.localdomain ([173.197.107.15]) by smtp.gmail.com with ESMTPSA id x13sm619621pjh.30.2021.08.18.13.19.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Aug 2021 13:19:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=3D/M6PiJA/KHiyIzYScTLEu+qTs2bRAx1trHXsXn6VU=; b=SwtvxVvktXqEGyjD8CyMzVorAjhJRXwznN3H6xIOGkHXaRRxp1eg2xZ9TF9C8tYOtP qt6oiSWr/q+YvTDGsDrmHDAkuDldY2Ic7+ItPGEbcS9gxeVkIhZl074D23UE05VewMQ9 2xcZGlH10cISVqUp96ottPIeeX3ikLiPORqU1QQrS4Qpr4tnHL9Qr/eqQhYWEk3C3bKm vf1OjB1WQO/mFcewjeBxSkh8R7cCr3jApZOviorisRjpvLkFB7noW5irPsDWvSYpNq9d jFm2WvJJjoH42kXDgKA59Nszh/3xh8yFeZld085QWbzDCBRPZ5L6lY90vCvyfSKh8C4O 53Og== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=3D/M6PiJA/KHiyIzYScTLEu+qTs2bRAx1trHXsXn6VU=; b=dHMVfDydsJcAaWc/ZkCNsqu6hBM0OTt7P10/RstgsehW5/NYmDQ5ZH7VCU2QCY2GbW P8KRZsRUQP0LZ0gJJ1e0Ds3zzWXq7ykU+wLdRcn2Q4J66GEpH/XniJv3oZsh4zfozfbX bu0P3nj0H5zD3tA+bgcLlFd8TQyaSLjDl1hlshYByLOp3CXclylPSCeBIdQ2j0tHH+59 AbF/Yhyoj/GhCO9jpwOUzNqZazMa4y0rin5Jbcvq/g6CO4k+g4QvnJUOo6lWte/50C4B pJXVGeah41YsiJ2M2IV6qdpJHpvp3SlBLgchLmMPOhkJqU+5K5UmRaAacIP3GGaxWfUe Knlw== X-Gm-Message-State: AOAM533rsVTx5BCuB5+JD2odTVwkwi584t6PcxQhwR/UEGf5SjZkPkbZ EjM7xrV+UJVSFDRZKJ3pic5EHBzg62DRPg== X-Google-Smtp-Source: ABdhPJwSkiDXcvtL0c22HwsP8Oa16FdUdQ5N/mFFyBQhNmk5JQxUQKRxd0otTfEbCeHx6g2zhZqDuQ== X-Received: by 2002:a65:428b:: with SMTP id j11mr10774429pgp.301.1629317979135; Wed, 18 Aug 2021 13:19:39 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 05/16] tcg/mips: Move TCG_GUEST_BASE_REG to S7 Date: Wed, 18 Aug 2021 10:19:20 -1000 Message-Id: <20210818201931.393394-6-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210818201931.393394-1-richard.henderson@linaro.org> References: <20210818201931.393394-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::52b; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x52b.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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1629318146287100001 Content-Type: text/plain; charset="utf-8" No functional change; just moving the saved reserved regs to the end. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- tcg/mips/tcg-target.c.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tcg/mips/tcg-target.c.inc b/tcg/mips/tcg-target.c.inc index 92bde50704..b3a2cc88ab 100644 --- a/tcg/mips/tcg-target.c.inc +++ b/tcg/mips/tcg-target.c.inc @@ -86,7 +86,7 @@ static const char * const tcg_target_reg_names[TCG_TARGET= _NB_REGS] =3D { #define TCG_TMP3 TCG_REG_T7 =20 #ifndef CONFIG_SOFTMMU -#define TCG_GUEST_BASE_REG TCG_REG_S1 +#define TCG_GUEST_BASE_REG TCG_REG_S7 #endif =20 /* check if we really need so many registers :P */ --=20 2.25.1 From nobody Tue May 21 02:31:22 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=1629318779; cv=none; d=zohomail.com; s=zohoarc; b=LR2qcrRXvri9sqeqIWIlfbxE8IK3nElhlL8xLQ8MCEaDSc71Ir7nV6iJrbWiI0oYuz//T4lrsFkkrfyuySW94KGEga9HrA3gO7Mo9G58vKGV3vmsWyBIHLua8fUvtqI2KXOJXZOqrOSoPzSu/3yXwzPQ1qj1zxyfWEXTjpuhE0Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1629318779; h=Content-Transfer-Encoding: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=jNjyfYROdoiW+oB5URi9KU06Tz8MB4l7ljtYIqD7XFQ=; b=PUgETH2RKl7HPj5OL85wAQ6nyclHBfbJFcSavWdM2V4umBGqWf4guomM1cE/e/qp7n+KxR9fBrorEyJUk4gFoZrzmfTMmDBYUA6/+JgQLExwvqUgWoX4EohRU0MTvXUle3hHHFlb/+QqKkPqkLDanJdjraTpW27+Uz7FFZcoycc= 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) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1629318779115238.0098636602944; Wed, 18 Aug 2021 13:32:59 -0700 (PDT) Received: from localhost ([::1]:49340 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mGSF8-0000wu-4X for importer@patchew.org; Wed, 18 Aug 2021 16:32:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40220) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mGS2K-00081z-Pp for qemu-devel@nongnu.org; Wed, 18 Aug 2021 16:19:44 -0400 Received: from mail-pg1-x530.google.com ([2607:f8b0:4864:20::530]:40602) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mGS2H-0006AR-FP for qemu-devel@nongnu.org; Wed, 18 Aug 2021 16:19:44 -0400 Received: by mail-pg1-x530.google.com with SMTP id y23so3480985pgi.7 for ; Wed, 18 Aug 2021 13:19:41 -0700 (PDT) Received: from localhost.localdomain ([173.197.107.15]) by smtp.gmail.com with ESMTPSA id x13sm619621pjh.30.2021.08.18.13.19.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Aug 2021 13:19:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=jNjyfYROdoiW+oB5URi9KU06Tz8MB4l7ljtYIqD7XFQ=; b=Z9SIfqyDsZYO2wu4hTqa5jTIW9YlfFmN9k5KGHHj48mrfTZD4XW5plU3ubAgwytkdG W05D4/qe+4j6F+PzwBEcbevbEHapr5YiG381r2rKpn5MuOaGG0MBLAp8V2iB9x0ErXUY fy5yxyH0pf+zFqeR0ctbqDmbrPmQ+xggiPiiVpaVfBfSglxxNDO92HoaqpT9qTk+ojn6 KHsixE6qVvDzlQm0JXllPH0RWOr5sL7GC2hHElhWPOU2XCcJ1cjmxUCRJlZKBYl2UzBP xP9X7EUFHuGcGs/6SaI7LLbRDgUEKOx3pQR01oULXPo38IWwgqzVna1ox3hNEU18/d++ 1sfQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=jNjyfYROdoiW+oB5URi9KU06Tz8MB4l7ljtYIqD7XFQ=; b=ImI2M8wHs/BtMN6C6PKTwLADv8Lot6UnL4iP3nuVwuROg3LjpuirMzoN6qdkoT5DTU 6S+gzxwV0+S0q9PWAkEjl/KzErL36oNDExDnTN9+m5h9DpQrVPmnrgY94J4yUl1iZj5A kFNwzK5JKxchBdCtPdF3D0buo8Q+kWJ/MRUKwWtzSS263RxJ41ttEHmlfyN1hQ4xAaE9 iY/t8YenKv0uiKMcpbz3Hnya2zrkDkP8UULAyNBfLYORN127c5bRmoyH/Ys3EFmQM0tB w00ieuTO0l7yAl9VL6N2bbTzMQidS7Bg7QbI7X4oT4PHnK5z8AoKVaT/XsMa2lIjw/LX zF1g== X-Gm-Message-State: AOAM533R/4n+Si1jln8vGOZHGbVgj60QR/2BiqKdAue7L1d+PtRzMnzG zaygSUWHhp+LcGIDxQ+a+wUF5Qj92bIzdA== X-Google-Smtp-Source: ABdhPJzD+AEQ/r5wOQPzhiaAUCx+xAJuuzU3/18DPcad6qlHdpJQURQVdnbYAitkjRqF+RGl8rGatg== X-Received: by 2002:a63:fe41:: with SMTP id x1mr10402085pgj.272.1629317980205; Wed, 18 Aug 2021 13:19:40 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 06/16] tcg/mips: Unify TCG_GUEST_BASE_REG tests Date: Wed, 18 Aug 2021 10:19:21 -1000 Message-Id: <20210818201931.393394-7-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210818201931.393394-1-richard.henderson@linaro.org> References: <20210818201931.393394-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::530; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x530.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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1629318779545100001 Content-Type: text/plain; charset="utf-8" In tcg_out_qemu_ld/st, we already check for guest_base matching int16_t. Mirror that when setting up TCG_GUEST_BASE_REG in the prologue. Signed-off-by: Richard Henderson --- tcg/mips/tcg-target.c.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tcg/mips/tcg-target.c.inc b/tcg/mips/tcg-target.c.inc index b3a2cc88ab..4019c22f3c 100644 --- a/tcg/mips/tcg-target.c.inc +++ b/tcg/mips/tcg-target.c.inc @@ -2671,7 +2671,7 @@ static void tcg_target_qemu_prologue(TCGContext *s) } =20 #ifndef CONFIG_SOFTMMU - if (guest_base) { + if (guest_base !=3D (int16_t)guest_base) { tcg_out_movi(s, TCG_TYPE_PTR, TCG_GUEST_BASE_REG, guest_base); tcg_regset_set_reg(s->reserved_regs, TCG_GUEST_BASE_REG); } --=20 2.25.1 From nobody Tue May 21 02:31:22 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=1629318434; cv=none; d=zohomail.com; s=zohoarc; b=Gy1BrVd1N9JW5H8+ushpO49mfgqyxPQyR2CkGXMcoDZpObH03OqdJM49KLFFNSDHZg2Vt/kTrJltPMAmjpXFnkwC3eVrFTWEtdXfMk+MIJlCfidmgMqO8I7VeLyjkmM9hkjvAPnyVL5Cwk/YfymbCAtoG00FZpFNzO69ts+hF/A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1629318434; h=Content-Transfer-Encoding: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=ZAJvKrninoDXi86yNb6pa5/NGflGIWCBcmCsKqBF7oE=; b=QDn/SaAHoSkZNvMcjgmeQLGaU6hr6ParM3Ke//vM50G/rEWbWDZi9ng3nfTqI2TCABZi7mxyD/q264C+PanVbuOfYu1aujlpLmtmMrF5o6jjtaGTVlBaG3ypvEWbRk+bjU3Pc8IlJ+/hWkFeIUCYdY6unF6ryvv67/WxRChBL/o= 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) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1629318434348540.8769979724191; Wed, 18 Aug 2021 13:27:14 -0700 (PDT) Received: from localhost ([::1]:60026 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mGS9Z-0005gL-2E for importer@patchew.org; Wed, 18 Aug 2021 16:27:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40258) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mGS2M-00083y-0u for qemu-devel@nongnu.org; Wed, 18 Aug 2021 16:19:46 -0400 Received: from mail-pf1-x430.google.com ([2607:f8b0:4864:20::430]:36544) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mGS2I-0006BK-Hl for qemu-devel@nongnu.org; Wed, 18 Aug 2021 16:19:45 -0400 Received: by mail-pf1-x430.google.com with SMTP id m26so3335588pff.3 for ; Wed, 18 Aug 2021 13:19:41 -0700 (PDT) Received: from localhost.localdomain ([173.197.107.15]) by smtp.gmail.com with ESMTPSA id x13sm619621pjh.30.2021.08.18.13.19.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Aug 2021 13:19:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=ZAJvKrninoDXi86yNb6pa5/NGflGIWCBcmCsKqBF7oE=; b=Xym+ooOPjszCLlRySpY5JoUHTx/B5Kuugcev6d//nnw6wsowaOzDz1wk9LMdotHdAE v0yEqziGlidu8gVQH8bLl5SoqLjgV1H0fDMKRPGy7sXWsHCQ6QP0eBq+9BrWh64QVTdk tSMld+MZLrAxTxForOe5gbk6tj+shbrABqt9FzK3mxOuPEJC4FqVrtP5USV9pYtT0MRe Ur9ejROnRIsqPk89WlG6oNRQqtEQk9HJ3ieQJCuHJQgA0Nw9NJmpgJlP3QlBFx6Tu2ni l1+8PWDw/cCVUXxUaOqgryBj2VffFSI03Q8i0/yvQj4snVMbfdr3Nhsa+xsZrVzLOeNP YkKg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ZAJvKrninoDXi86yNb6pa5/NGflGIWCBcmCsKqBF7oE=; b=XVCvh9q/ktyh1yGJjUQjNXRxNPer7kz6Un/4WXmJxZu/BipWqLH+qYepdVa5nLq639 ZPffWAVvWQW1C8fHC+MMAMKaHYGzJymOyCGDl1pEiB3+n6WWu22/uo295ybqCCprBfmY s4DZ2fjosH5AX9jsg8reSqF528nFG/txxWd7SGQahFGyhRszPos53L3yGnvgxJNVlrHr o1UTNl+60wVRbAgcIqIlY80JzSIeRLDXuHche3Rwi8cwxppKn8/Lnp6kYmUPTSeLRO7z xUbY+silL8FQA0DkljIvkJQZ0IPvqxGUnT41L4xnbZb7ZrGsb83D3Z72AgCck4IwMcKT uRVw== X-Gm-Message-State: AOAM533ascIFHkJi4qSOgXZ2DiQUCM8QbCnZ7TwtDRIw0h0LIRf0+kX1 1Kg4jF1FdzJlYPsPBx+e0HM4SAYhp2yPNQ== X-Google-Smtp-Source: ABdhPJx25XtPPJDGPufYgKUi6zk1M/p17cpSYy8ProH9TVSH4o0Q2oG+yhrUxTvrh81dodDuiqwaCg== X-Received: by 2002:a63:88c7:: with SMTP id l190mr10485873pgd.438.1629317981121; Wed, 18 Aug 2021 13:19:41 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 07/16] tcg/mips: Allow JAL to be out of range in tcg_out_bswap_subr Date: Wed, 18 Aug 2021 10:19:22 -1000 Message-Id: <20210818201931.393394-8-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210818201931.393394-1-richard.henderson@linaro.org> References: <20210818201931.393394-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::430; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x430.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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1629318435557100001 Content-Type: text/plain; charset="utf-8" Weaning off of unique alignment requirements, so allow JAL to not reach the target. TCG_TMP1 is always available for use as a scratch because it is clobbered by the subroutine being called. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- tcg/mips/tcg-target.c.inc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tcg/mips/tcg-target.c.inc b/tcg/mips/tcg-target.c.inc index 4019c22f3c..c65c4ee1f8 100644 --- a/tcg/mips/tcg-target.c.inc +++ b/tcg/mips/tcg-target.c.inc @@ -585,8 +585,10 @@ static void tcg_out_bswap16(TCGContext *s, TCGReg ret,= TCGReg arg, int flags) =20 static void tcg_out_bswap_subr(TCGContext *s, const tcg_insn_unit *sub) { - bool ok =3D tcg_out_opc_jmp(s, OPC_JAL, sub); - tcg_debug_assert(ok); + if (!tcg_out_opc_jmp(s, OPC_JAL, sub)) { + tcg_out_movi(s, TCG_TYPE_PTR, TCG_TMP1, (uintptr_t)sub); + tcg_out_opc_reg(s, OPC_JALR, TCG_REG_RA, TCG_TMP1, 0); + } } =20 static void tcg_out_bswap32(TCGContext *s, TCGReg ret, TCGReg arg, int fla= gs) --=20 2.25.1 From nobody Tue May 21 02:31:22 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=1629318565; cv=none; d=zohomail.com; s=zohoarc; b=mCgRJIQLwoOM24LDnz1TOHcCBd4T7rFpFfCl0b5LE5D7koHft4kAF3GoVMCnQ+q3W0S3BtDbB/Be8tyFbT8cY6MYljelaD9Tf55OPxy2sW3PQYR84Usk6sHNp4k9GJoLcLQPqElZLOKTk0Uj9CwDgwe15eYajWOjiwVOjPFor9A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1629318565; h=Content-Transfer-Encoding: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=xt/P1E35n4DoR7F0qpGvXqATfrrFWhQKn4h1puAkVi4=; b=HLG5ZusdwC5e64/39nP+7/i9OcQVacppwt/3h6qsHgVcYOXpKYKb2hrdJBZns+1g7gd3sU+2OactnxP2bwoMnbrH/xcm/T+IJOGp75fUwO52oypcvQaFK436HlYj9Qg/0lmF/VwfTKI7sl2oTw+eKNGWwqkjs0glwBfjhS3eRro= 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) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 162931856589530.087609689099054; Wed, 18 Aug 2021 13:29:25 -0700 (PDT) Received: from localhost ([::1]:40548 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mGSBg-000376-QJ for importer@patchew.org; Wed, 18 Aug 2021 16:29:24 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40266) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mGS2M-00084o-94 for qemu-devel@nongnu.org; Wed, 18 Aug 2021 16:19:46 -0400 Received: from mail-pf1-x434.google.com ([2607:f8b0:4864:20::434]:42951) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mGS2J-0006CP-BD for qemu-devel@nongnu.org; Wed, 18 Aug 2021 16:19:46 -0400 Received: by mail-pf1-x434.google.com with SMTP id 18so3336699pfh.9 for ; Wed, 18 Aug 2021 13:19:42 -0700 (PDT) Received: from localhost.localdomain ([173.197.107.15]) by smtp.gmail.com with ESMTPSA id x13sm619621pjh.30.2021.08.18.13.19.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Aug 2021 13:19:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=xt/P1E35n4DoR7F0qpGvXqATfrrFWhQKn4h1puAkVi4=; b=TSZ6T+I6Fl9kPGjkAKvDxNK0uP7j5dR81C22y7LXAt0RPAm/iRkK38hJT9nN6apw3l ocrirZtthdWmRwDHLJYrEC9XTWuN0D7a9/Y3Sof1LpM+whOZL32X3vMU0hxtvoi4oB6G zNZKxGmMry2+HEpQDHZZSAyYH2Bx9DxrMDcWCb4ZbP0BXA7z1q2XAtlQI+MFYdOGwIld ZVsrq5j7WDZUWN2IxHaw1ON4ET+gXHH/RipY4Idkn+YRI4TSdnf57Jzx5qyNanAPMDWS 2Gpw+GO0TxQVUDEzzStoSrC2siDVskNe2PnPJiS0EWtkbOtMU3vdw7/BMyShQF1YsT/G 4KFA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=xt/P1E35n4DoR7F0qpGvXqATfrrFWhQKn4h1puAkVi4=; b=WRgajeqAHpcDOjcbd/aCHGuiQVwf+zjIMMSE+V2K5N8v68/1NJzoCBwkytkrocHveV kLSVS6xVAYmnOaH7byGXgLDOSFNuyPGrmN+/fWEeAg4bkyRyE/6qreKO2FQyTfbjeeFW snCicgmG2rpiw2hXbWmEBibqlRxlPXqCKYWDVN8fGY1GUN1utyHk2xFTxn077VqE+feD EMTi5xVW/JDj6OeRUEzlTtu+646OL7eCQIcfwDBKu/Qjlt0Dd2mpCfE20UTlILFlHS9o z7VFxeH9CYawWdEyolB7MsLCvASSpPf8aOsWiKc4eoD4l3oxH+LWO2vb+cePLruzLa9Q qQrw== X-Gm-Message-State: AOAM533c6e9qnu4No50Yz1NeALel1TwOBnEzH5RaxonUdRX+iHdSkim6 vOisb4zGPVD+XrzjDpOzfGLAzmnCFPgmpA== X-Google-Smtp-Source: ABdhPJyMNAn41mKO8Jay6cd+S83XhOQZECVw45E2mhEdcPqXNmiikLXruKLnxqvQpoVpFXVPpgxYow== X-Received: by 2002:a65:51c7:: with SMTP id i7mr10395763pgq.300.1629317982062; Wed, 18 Aug 2021 13:19:42 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 08/16] tcg/mips: Unset TCG_TARGET_HAS_direct_jump Date: Wed, 18 Aug 2021 10:19:23 -1000 Message-Id: <20210818201931.393394-9-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210818201931.393394-1-richard.henderson@linaro.org> References: <20210818201931.393394-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::434; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x434.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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1629318566705100001 Content-Type: text/plain; charset="utf-8" Only use indirect jumps. Finish weaning away from the unique alignment requirements for code_gen_buffer. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- tcg/mips/tcg-target.h | 12 +++++------- tcg/mips/tcg-target.c.inc | 23 +++++------------------ 2 files changed, 10 insertions(+), 25 deletions(-) diff --git a/tcg/mips/tcg-target.h b/tcg/mips/tcg-target.h index c34cccebd3..28c42e23e1 100644 --- a/tcg/mips/tcg-target.h +++ b/tcg/mips/tcg-target.h @@ -39,11 +39,7 @@ #define TCG_TARGET_TLB_DISPLACEMENT_BITS 16 #define TCG_TARGET_NB_REGS 32 =20 -/* - * We have a 256MB branch region, but leave room to make sure the - * main executable is also within that region. - */ -#define MAX_CODE_GEN_BUFFER_SIZE (128 * MiB) +#define MAX_CODE_GEN_BUFFER_SIZE ((size_t)-1) =20 typedef enum { TCG_REG_ZERO =3D 0, @@ -136,7 +132,7 @@ extern bool use_mips32r2_instructions; #define TCG_TARGET_HAS_muluh_i32 1 #define TCG_TARGET_HAS_mulsh_i32 1 #define TCG_TARGET_HAS_bswap32_i32 1 -#define TCG_TARGET_HAS_direct_jump 1 +#define TCG_TARGET_HAS_direct_jump 0 =20 #if TCG_TARGET_REG_BITS =3D=3D 64 #define TCG_TARGET_HAS_add2_i32 0 @@ -207,7 +203,9 @@ extern bool use_mips32r2_instructions; #define TCG_TARGET_DEFAULT_MO (0) #define TCG_TARGET_HAS_MEMORY_BSWAP 1 =20 -void tb_target_set_jmp_target(uintptr_t, uintptr_t, uintptr_t, uintptr_t); +/* not defined -- call should be eliminated at compile time */ +void tb_target_set_jmp_target(uintptr_t, uintptr_t, uintptr_t, uintptr_t) + QEMU_ERROR("code path is reachable"); =20 #define TCG_TARGET_NEED_LDST_LABELS =20 diff --git a/tcg/mips/tcg-target.c.inc b/tcg/mips/tcg-target.c.inc index c65c4ee1f8..1c5c0854c7 100644 --- a/tcg/mips/tcg-target.c.inc +++ b/tcg/mips/tcg-target.c.inc @@ -1977,17 +1977,11 @@ static void tcg_out_op(TCGContext *s, TCGOpcode opc, } break; case INDEX_op_goto_tb: - if (s->tb_jmp_insn_offset) { - /* direct jump method */ - s->tb_jmp_insn_offset[a0] =3D tcg_current_code_size(s); - /* Avoid clobbering the address during retranslation. */ - tcg_out32(s, OPC_J | (*(uint32_t *)s->code_ptr & 0x3ffffff)); - } else { - /* indirect jump method */ - tcg_out_ld(s, TCG_TYPE_PTR, TCG_TMP0, TCG_REG_ZERO, - (uintptr_t)(s->tb_jmp_target_addr + a0)); - tcg_out_opc_reg(s, OPC_JR, 0, TCG_TMP0, 0); - } + /* indirect jump method */ + tcg_debug_assert(s->tb_jmp_insn_offset =3D=3D 0); + tcg_out_ld(s, TCG_TYPE_PTR, TCG_TMP0, TCG_REG_ZERO, + (uintptr_t)(s->tb_jmp_target_addr + a0)); + tcg_out_opc_reg(s, OPC_JR, 0, TCG_TMP0, 0); tcg_out_nop(s); set_jmp_reset_offset(s, a0); break; @@ -2861,13 +2855,6 @@ static void tcg_target_init(TCGContext *s) tcg_regset_set_reg(s->reserved_regs, TCG_REG_GP); /* global pointer = */ } =20 -void tb_target_set_jmp_target(uintptr_t tc_ptr, uintptr_t jmp_rx, - uintptr_t jmp_rw, uintptr_t addr) -{ - qatomic_set((uint32_t *)jmp_rw, deposit32(OPC_J, 0, 26, addr >> 2)); - flush_idcache_range(jmp_rx, jmp_rw, 4); -} - typedef struct { DebugFrameHeader h; uint8_t fde_def_cfa[4]; --=20 2.25.1 From nobody Tue May 21 02:31:22 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=1629319051; cv=none; d=zohomail.com; s=zohoarc; b=geQnBGX9ZNQg+vpoLw+/IsR2NUrgSIOa04xchspUoEF2o2XvZP0ourHWiKvpeOIt5rm+vl1rnbZsnNcrnrh5qmLyA8zGBu+x7dMX8JBsnkII5ijhthODf1ti/aEBbzOxCvvBS8QyEkSu3j5jqQwVKMxvQ8bXGnglE4g+otaWK44= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1629319051; h=Content-Transfer-Encoding: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=dLKp0mDnjjRjPauDQA0yKsYIxkun+14IJ8e0NroxfP0=; b=c0j1q8I5xEeOm9KE40MYzaoYE3w4EhD63N0NhXiN/6bgTa1vFUGOReOnkjbZZ35VEBC6YG7lsviKajHG8yxjphm4BGI8R5HqONsjnhHET8qUhDmG2bnWV/GQ3S0fDKtUugcMkYlqw216fAy5j21GGCJ6Tz+dgJGFxbeNj2B0Iqk= 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) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 162931905171126.53406458963832; Wed, 18 Aug 2021 13:37:31 -0700 (PDT) Received: from localhost ([::1]:59878 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mGSJW-0008Hq-Ni for importer@patchew.org; Wed, 18 Aug 2021 16:37:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40320) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mGS2N-00088T-CV for qemu-devel@nongnu.org; Wed, 18 Aug 2021 16:19:47 -0400 Received: from mail-pf1-x436.google.com ([2607:f8b0:4864:20::436]:38466) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mGS2K-0006Eg-AE for qemu-devel@nongnu.org; Wed, 18 Aug 2021 16:19:47 -0400 Received: by mail-pf1-x436.google.com with SMTP id a21so3338394pfh.5 for ; Wed, 18 Aug 2021 13:19:43 -0700 (PDT) Received: from localhost.localdomain ([173.197.107.15]) by smtp.gmail.com with ESMTPSA id x13sm619621pjh.30.2021.08.18.13.19.42 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Aug 2021 13:19:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=dLKp0mDnjjRjPauDQA0yKsYIxkun+14IJ8e0NroxfP0=; b=GjB/NbVw8c/qldv19W4yn+SplSDazvAR4v+6xK6LORpPnHxueKRFeb4MYOfCrUQAlt ftIfq60avd7E3zDS19MIKBE1WK0G9OVrzWGz9ShkKh9bwOIFqnRqZzubipDSqPRTd5kH u/ETyGYNafabrcbxqnOiE4fxri7VnlZChK9mI9VVR2Bb8qKn7QtLT5iG6By6yUtSx2hl RJssyFuiV5BJfP4P0xaf4BSjd5HGKSGozu9P5S486sf8oDWyhRZVMUN2sAgBbqPKxbrU B1QFKYiEoZuo1AYiPT1Xg+uESjQFQ4FryjSASwYwj3eqoNMBtH0k9VYpnnwdyJ5+whZL BK7Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=dLKp0mDnjjRjPauDQA0yKsYIxkun+14IJ8e0NroxfP0=; b=h7+osDcfeT89N7aGujNdwl37MFBGWA+t0Uq83QbKdDuXE0YA0pBPKah6ljO5OJhzMj wcluKczbDD07/a33lboOJFMp97Zir6P74KCEwTJrjUutocP6ygDMbkb99MwNs4N4exBZ kooiljQMSda6kafD95YxOVUj9Lfsg/XGlFKwHQcmQM7QyX7pHvrJ6tbS1gxbIClfMP/4 33iP6KUiZtOaRrrDxykqQASIr4fsTmvnEQKqTuWp8WX76lNSrHvJ8BFDwJGcECAZW/+v NAqQYvnvf547OO/bRguTi9WYlXYPcCdm4zAqwekeez7yIQci5MBZlQn6V0GT3Jrwoctn VmRg== X-Gm-Message-State: AOAM532GldZmr+Lr/9I6JDtkxkjQoanDKIaiCIAZDxz1mjhCCXZ+fxXs uqXXIG4bMXeJ71IPfBdeieM9GMDG1CrAxQ== X-Google-Smtp-Source: ABdhPJzBIZdcYlRlmaXu33vv/LYxJSiiHIiuhBWh0FcDCQl88m5rqZWo2uUuQmn4kKJRBJXjf8oT+w== X-Received: by 2002:a63:fd54:: with SMTP id m20mr10564431pgj.104.1629317983053; Wed, 18 Aug 2021 13:19:43 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 09/16] tcg/mips: Drop special alignment for code_gen_buffer Date: Wed, 18 Aug 2021 10:19:24 -1000 Message-Id: <20210818201931.393394-10-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210818201931.393394-1-richard.henderson@linaro.org> References: <20210818201931.393394-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::436; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x436.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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1629319052685100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- tcg/region.c | 91 ---------------------------------------------------- 1 file changed, 91 deletions(-) diff --git a/tcg/region.c b/tcg/region.c index e64c3ea230..9cc30d4922 100644 --- a/tcg/region.c +++ b/tcg/region.c @@ -467,38 +467,6 @@ static size_t tcg_n_regions(size_t tb_size, unsigned m= ax_cpus) (DEFAULT_CODE_GEN_BUFFER_SIZE_1 < MAX_CODE_GEN_BUFFER_SIZE \ ? DEFAULT_CODE_GEN_BUFFER_SIZE_1 : MAX_CODE_GEN_BUFFER_SIZE) =20 -#ifdef __mips__ -/* - * In order to use J and JAL within the code_gen_buffer, we require - * that the buffer not cross a 256MB boundary. - */ -static inline bool cross_256mb(void *addr, size_t size) -{ - return ((uintptr_t)addr ^ ((uintptr_t)addr + size)) & ~0x0ffffffful; -} - -/* - * We weren't able to allocate a buffer without crossing that boundary, - * so make do with the larger portion of the buffer that doesn't cross. - * Returns the new base and size of the buffer in *obuf and *osize. - */ -static inline void split_cross_256mb(void **obuf, size_t *osize, - void *buf1, size_t size1) -{ - void *buf2 =3D (void *)(((uintptr_t)buf1 + size1) & ~0x0ffffffful); - size_t size2 =3D buf1 + size1 - buf2; - - size1 =3D buf2 - buf1; - if (size1 < size2) { - size1 =3D size2; - buf1 =3D buf2; - } - - *obuf =3D buf1; - *osize =3D size1; -} -#endif - #ifdef USE_STATIC_CODE_GEN_BUFFER static uint8_t static_code_gen_buffer[DEFAULT_CODE_GEN_BUFFER_SIZE] __attribute__((aligned(CODE_GEN_ALIGN))); @@ -526,12 +494,6 @@ static int alloc_code_gen_buffer(size_t tb_size, int s= plitwx, Error **errp) size =3D QEMU_ALIGN_DOWN(tb_size, qemu_real_host_page_size); } =20 -#ifdef __mips__ - if (cross_256mb(buf, size)) { - split_cross_256mb(&buf, &size, buf, size); - } -#endif - region.start_aligned =3D buf; region.total_size =3D size; =20 @@ -573,39 +535,6 @@ static int alloc_code_gen_buffer_anon(size_t size, int= prot, return -1; } =20 -#ifdef __mips__ - if (cross_256mb(buf, size)) { - /* - * Try again, with the original still mapped, to avoid re-acquiring - * the same 256mb crossing. - */ - size_t size2; - void *buf2 =3D mmap(NULL, size, prot, flags, -1, 0); - switch ((int)(buf2 !=3D MAP_FAILED)) { - case 1: - if (!cross_256mb(buf2, size)) { - /* Success! Use the new buffer. */ - munmap(buf, size); - break; - } - /* Failure. Work with what we had. */ - munmap(buf2, size); - /* fallthru */ - default: - /* Split the original buffer. Free the smaller half. */ - split_cross_256mb(&buf2, &size2, buf, size); - if (buf =3D=3D buf2) { - munmap(buf + size2, size - size2); - } else { - munmap(buf, size - size2); - } - size =3D size2; - break; - } - buf =3D buf2; - } -#endif - region.start_aligned =3D buf; region.total_size =3D size; return prot; @@ -620,35 +549,15 @@ static bool alloc_code_gen_buffer_splitwx_memfd(size_= t size, Error **errp) void *buf_rw =3D NULL, *buf_rx =3D MAP_FAILED; int fd =3D -1; =20 -#ifdef __mips__ - /* Find space for the RX mapping, vs the 256MiB regions. */ - if (alloc_code_gen_buffer_anon(size, PROT_NONE, - MAP_PRIVATE | MAP_ANONYMOUS | - MAP_NORESERVE, errp) < 0) { - return false; - } - /* The size of the mapping may have been adjusted. */ - buf_rx =3D region.start_aligned; - size =3D region.total_size; -#endif - buf_rw =3D qemu_memfd_alloc("tcg-jit", size, 0, &fd, errp); if (buf_rw =3D=3D NULL) { goto fail; } =20 -#ifdef __mips__ - void *tmp =3D mmap(buf_rx, size, PROT_READ | PROT_EXEC, - MAP_SHARED | MAP_FIXED, fd, 0); - if (tmp !=3D buf_rx) { - goto fail_rx; - } -#else buf_rx =3D mmap(NULL, size, PROT_READ | PROT_EXEC, MAP_SHARED, fd, 0); if (buf_rx =3D=3D MAP_FAILED) { goto fail_rx; } -#endif =20 close(fd); region.start_aligned =3D buf_rw; --=20 2.25.1 From nobody Tue May 21 02:31:22 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=1629318899; cv=none; d=zohomail.com; s=zohoarc; b=T4BF6Rmpxgbx20PkgjtmEXl4F3xWPFcaVrGsHK+SthpxTuMKAZgUELIoeToU0YaW+OSePwRKIXzukeYMG5/gaOpQ/zdSLQ1AhmNjCobyn2EwDFynxDDxUKf5H6UibgRA/u5v0SC7plId0NYBV5eu04wEd9lKqGo7mgAFQVAO4DA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1629318899; h=Content-Transfer-Encoding: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=vy83n381f/P0a9RBv7Zua8KHFnM0TgwxLmEkGAu93xY=; b=aq2Sgn8U/ajDfl9OrSW7FvrtkbXRvipjep3e15mVF3GZwfeFecH97XTd3KTjKagm7ZL4ImEDt1q+ngUYiqKbw0RIJALvOrFuZfVe4iqhBr/E07LH++jVQ0R0X8jV4djMTtaRRwjaU5QRQt/MqxuK9kpk+ZOyocJoTsE3fLOKW/8= 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) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1629318899212880.4633696625772; Wed, 18 Aug 2021 13:34:59 -0700 (PDT) Received: from localhost ([::1]:53636 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mGSH3-00043z-Te for importer@patchew.org; Wed, 18 Aug 2021 16:34:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40342) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mGS2O-0008BN-DP for qemu-devel@nongnu.org; Wed, 18 Aug 2021 16:19:48 -0400 Received: from mail-pj1-x102a.google.com ([2607:f8b0:4864:20::102a]:46006) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mGS2L-0006GZ-BX for qemu-devel@nongnu.org; Wed, 18 Aug 2021 16:19:48 -0400 Received: by mail-pj1-x102a.google.com with SMTP id m24-20020a17090a7f98b0290178b1a81700so3156304pjl.4 for ; Wed, 18 Aug 2021 13:19:44 -0700 (PDT) Received: from localhost.localdomain ([173.197.107.15]) by smtp.gmail.com with ESMTPSA id x13sm619621pjh.30.2021.08.18.13.19.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Aug 2021 13:19:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=vy83n381f/P0a9RBv7Zua8KHFnM0TgwxLmEkGAu93xY=; b=qYYB/tgu8zLpGaSG6YMuMDCvv2NsSjLQ4rRReG6UsJFgeWSbAJDW8C9Vk4m3JyiCmD 9o3XKMPEYOjWot1fqyYlvpdZOapvu2Od76sA9pvGZRU1TkzdKaWqWreW713WPZ6GXv5C W2cLyVixv6e2Zzx6rkk4iaoCKjdWDHVcBlR6yfe9XsNmnbQTX9HnIKTS4WDY1PBZMxYC 6CFFc+y/VHWfm8eZg30GM8qVCa9PBxOHVLvQS4i5ZJz4x8uvZ88oEauECrdNTI/sfHqi GNPnIltMdm/ewDGfMQ1YpwlYkC9O3xCc8s4x2/EPccBveO2MnZ/2RBBL73DZLATXIMJ8 DEGA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=vy83n381f/P0a9RBv7Zua8KHFnM0TgwxLmEkGAu93xY=; b=cDPAu/X6PCtPGuVnAtBm5cEFN+I/+382m6iUcsX7QoojPfZYeBWz2n74aPABgtx5Os uuSecTM7G00dW78Fj0OtZSEgML18zrOk2bvHFQDvKEky7Vb5Toe2aSBGezQL/xk8MxTK WeKWjQukWh/tSsrDzmPhwxeBDXcXlU9JhvZbAmAJQLvLghlcXdcPMAsPrj7i5nbxeWE1 4mNvHS01+6+YRzEPTa8UtfAX5gwhWK9W/EpgS7B6zPsouI5UTjf9HbUB2Cdpa7ZqGYQs 4Jk4ebSJLHBrEd2tFnqh+rnn8eUoDDmiOFTLDzOXSgBGyCHRpAJIzE8bFE3hU/bju2Si 2v2A== X-Gm-Message-State: AOAM531GBQR4Kpw3e+wbFU4tjiLmY2iOCg2G5QNLyg3glw4zWcQgc7/K i7TwLceIYICd2mKX0YK3lGp2MWa6dTv7fA== X-Google-Smtp-Source: ABdhPJzJhRCIeuthzXhs4gAuIycAoTKK9Ts5K+HeeeUyPkNtlnreAluPXpG1FAMOAzBp7reqAYs4Uw== X-Received: by 2002:a17:902:8506:b029:12c:76a8:d1b8 with SMTP id bj6-20020a1709028506b029012c76a8d1b8mr8755538plb.14.1629317984023; Wed, 18 Aug 2021 13:19:44 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 10/16] tcg/mips: Create and use TCG_REG_TB Date: Wed, 18 Aug 2021 10:19:25 -1000 Message-Id: <20210818201931.393394-11-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210818201931.393394-1-richard.henderson@linaro.org> References: <20210818201931.393394-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::102a; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102a.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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1629318900439100001 Content-Type: text/plain; charset="utf-8" This vastly reduces the size of code generated for 64-bit addresses. The code for exit_tb, for instance, where we load a (tagged) pointer to the current TB, goes from 0x400aa9725c: li v0,64 0x400aa97260: dsll v0,v0,0x10 0x400aa97264: ori v0,v0,0xaa9 0x400aa97268: dsll v0,v0,0x10 0x400aa9726c: j 0x400aa9703c 0x400aa97270: ori v0,v0,0x7083 to 0x400aa97240: j 0x400aa97040 0x400aa97244: daddiu v0,s6,-189 Signed-off-by: Richard Henderson --- tcg/mips/tcg-target.c.inc | 73 ++++++++++++++++++++++++++++++++------- 1 file changed, 61 insertions(+), 12 deletions(-) diff --git a/tcg/mips/tcg-target.c.inc b/tcg/mips/tcg-target.c.inc index 1c5c0854c7..333b9572d0 100644 --- a/tcg/mips/tcg-target.c.inc +++ b/tcg/mips/tcg-target.c.inc @@ -88,6 +88,11 @@ static const char * const tcg_target_reg_names[TCG_TARGE= T_NB_REGS] =3D { #ifndef CONFIG_SOFTMMU #define TCG_GUEST_BASE_REG TCG_REG_S7 #endif +#if TCG_TARGET_REG_BITS =3D=3D 64 +#define TCG_REG_TB TCG_REG_S6 +#else +#define TCG_REG_TB (qemu_build_not_reached(), TCG_REG_ZERO) +#endif =20 /* check if we really need so many registers :P */ static const int tcg_target_reg_alloc_order[] =3D { @@ -1961,34 +1966,72 @@ static void tcg_out_op(TCGContext *s, TCGOpcode opc, switch (opc) { case INDEX_op_exit_tb: { - TCGReg b0 =3D TCG_REG_ZERO; + TCGReg base =3D TCG_REG_ZERO; + int16_t lo =3D 0; =20 - a0 =3D (intptr_t)a0; - if (a0 & ~0xffff) { - tcg_out_movi(s, TCG_TYPE_PTR, TCG_REG_V0, a0 & ~0xffff); - b0 =3D TCG_REG_V0; + if (a0) { + intptr_t ofs; + if (TCG_TARGET_REG_BITS =3D=3D 64) { + ofs =3D tcg_tbrel_diff(s, (void *)a0); + lo =3D ofs; + if (ofs =3D=3D lo) { + base =3D TCG_REG_TB; + } else { + base =3D TCG_REG_V0; + tcg_out_movi(s, TCG_TYPE_PTR, base, ofs - lo); + tcg_out_opc_reg(s, ALIAS_PADD, base, base, TCG_REG= _TB); + } + } else { + ofs =3D a0; + lo =3D ofs; + base =3D TCG_REG_V0; + tcg_out_movi(s, TCG_TYPE_PTR, base, ofs - lo); + } } if (!tcg_out_opc_jmp(s, OPC_J, tb_ret_addr)) { tcg_out_movi(s, TCG_TYPE_PTR, TCG_TMP0, (uintptr_t)tb_ret_addr); tcg_out_opc_reg(s, OPC_JR, 0, TCG_TMP0, 0); } - tcg_out_opc_imm(s, OPC_ORI, TCG_REG_V0, b0, a0 & 0xffff); + tcg_out_opc_imm(s, ALIAS_PADDI, TCG_REG_V0, base, lo); } break; case INDEX_op_goto_tb: /* indirect jump method */ tcg_debug_assert(s->tb_jmp_insn_offset =3D=3D 0); - tcg_out_ld(s, TCG_TYPE_PTR, TCG_TMP0, TCG_REG_ZERO, - (uintptr_t)(s->tb_jmp_target_addr + a0)); - tcg_out_opc_reg(s, OPC_JR, 0, TCG_TMP0, 0); - tcg_out_nop(s); - set_jmp_reset_offset(s, a0); + { + TCGReg base, dest; + intptr_t ofs; + + if (TCG_TARGET_REG_BITS =3D=3D 64) { + dest =3D base =3D TCG_REG_TB; + ofs =3D tcg_tbrel_diff(s, s->tb_jmp_target_addr + a0); + } else { + dest =3D TCG_TMP0; + base =3D TCG_REG_ZERO; + ofs =3D (intptr_t)(s->tb_jmp_target_addr + a0); + } + tcg_out_ld(s, TCG_TYPE_PTR, dest, base, ofs); + tcg_out_opc_reg(s, OPC_JR, 0, dest, 0); + /* delay slot */ + tcg_out_nop(s); + + set_jmp_reset_offset(s, args[0]); + if (TCG_TARGET_REG_BITS =3D=3D 64) { + /* For the unlinked case, need to reset TCG_REG_TB. */ + tcg_out_ldst(s, ALIAS_PADDI, TCG_REG_TB, TCG_REG_TB, + -tcg_current_code_size(s)); + } + } break; case INDEX_op_goto_ptr: /* jmp to the given host address (could be epilogue) */ tcg_out_opc_reg(s, OPC_JR, 0, a0, 0); - tcg_out_nop(s); + if (TCG_TARGET_REG_BITS =3D=3D 64) { + tcg_out_mov(s, TCG_TYPE_PTR, TCG_REG_TB, a0); + } else { + tcg_out_nop(s); + } break; case INDEX_op_br: tcg_out_brcond(s, TCG_COND_EQ, TCG_REG_ZERO, TCG_REG_ZERO, @@ -2672,6 +2715,9 @@ static void tcg_target_qemu_prologue(TCGContext *s) tcg_regset_set_reg(s->reserved_regs, TCG_GUEST_BASE_REG); } #endif + if (TCG_TARGET_REG_BITS =3D=3D 64) { + tcg_out_mov(s, TCG_TYPE_PTR, TCG_REG_TB, tcg_target_call_iarg_regs= [1]); + } =20 /* Call generated code */ tcg_out_opc_reg(s, OPC_JR, 0, tcg_target_call_iarg_regs[1], 0); @@ -2853,6 +2899,9 @@ static void tcg_target_init(TCGContext *s) tcg_regset_set_reg(s->reserved_regs, TCG_REG_RA); /* return address = */ tcg_regset_set_reg(s->reserved_regs, TCG_REG_SP); /* stack pointer */ tcg_regset_set_reg(s->reserved_regs, TCG_REG_GP); /* global pointer = */ + if (TCG_TARGET_REG_BITS =3D=3D 64) { + tcg_regset_set_reg(s->reserved_regs, TCG_REG_TB); /* tc->tc_ptr */ + } } =20 typedef struct { --=20 2.25.1 From nobody Tue May 21 02:31:22 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=1629318941; cv=none; d=zohomail.com; s=zohoarc; b=i8o02a9I9zVCPDA37oXFTVFYFP8nnFr82Kvn8tZpb3ANaPU+iwmz4M2MxzQ0Ufp2GTOz1bmtpBI0LSkKRIYyB635kW0gj7x4so77d6lhwaDkRoeWO9RROk4TumQkeVwlz+Cs3wnazn00v7GvHIwIYVvejdTZ+3NEnaxf3k8wID4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1629318941; h=Content-Transfer-Encoding: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=vdoMbOjvjUbRTDz6SRu0t7kZ7lZlYLcBKfY5+VwkcJ4=; b=IkH0G0bSl2eKyC1OE1Iy475RFa1ZS2M1b2S9UQ4s9XL3E9IpdxKeQcLTWwrvgN5YmHOpMw5GbTcq+WS1ulSw2I8/wtoRjxHlvxTMbENIyHQNfYEbEe9MLJuipg9RfO/fcjYP5wzR/DkZGhqq17B/igLICl/ktFiw97xnChI6qTI= 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) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1629318941439450.4264687742242; Wed, 18 Aug 2021 13:35:41 -0700 (PDT) Received: from localhost ([::1]:55576 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mGSHk-0005Lo-Ea for importer@patchew.org; Wed, 18 Aug 2021 16:35:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40322) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mGS2N-00088v-IF for qemu-devel@nongnu.org; Wed, 18 Aug 2021 16:19:47 -0400 Received: from mail-pf1-x436.google.com ([2607:f8b0:4864:20::436]:39704) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mGS2M-0006Hv-8B for qemu-devel@nongnu.org; Wed, 18 Aug 2021 16:19:47 -0400 Received: by mail-pf1-x436.google.com with SMTP id t13so3334893pfl.6 for ; Wed, 18 Aug 2021 13:19:45 -0700 (PDT) Received: from localhost.localdomain ([173.197.107.15]) by smtp.gmail.com with ESMTPSA id x13sm619621pjh.30.2021.08.18.13.19.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Aug 2021 13:19:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=vdoMbOjvjUbRTDz6SRu0t7kZ7lZlYLcBKfY5+VwkcJ4=; b=x2dw2Q7xMf6DyJ7W0SwNtlW0ZELQwJ6BBHcO0o9MmEorzx+fBI+BW0W36bSKg9F3RM wTMr1kKhhVqQRHUGZgmMTsfB5K91WzjwQN5FnD8HjxO7nqq4CFKDmWOhFqnRsej/irGR XY/QHJv6kxrsUaOLsK2SsPb3HGJmQHt7D3nPzdAZGhSou4KE91zIwWNBsWiplcSnTgFY Fif7XLvfP1iJxymXM2LP0j2IGDc2c37Fnks4aU80+XAY+BISo/85u3WLpiCkvkMUC+HR 4hDAg5bw0G/QdaB+/84CYXFuMVVOSb1GOX8owLc6PfJPVjWKTriRBZaY4Rk1wD4oqTJr xhhQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=vdoMbOjvjUbRTDz6SRu0t7kZ7lZlYLcBKfY5+VwkcJ4=; b=JoF/5iXbG9KTQT/8b3ko8gTNXz8Stsm8hEqXCx9e+QycYqaKO1qGozbFZJnShGmmVx fZnL5IGz5lOK3qLFQvjzUgLNHuPispW3bf6cfezA3GrQLJWOf2XTXMzgnV4it1wKfglu qluKmoRvGPCJzYeWzgNiqUQw4JMqa3wkOggItgYofxW/yXnYNk8B3e5qwK4x5S8DcinI i3tnqwlQjf/5oYRaGqV58mj4wDjeQXAYq91/uKoeUKEtHy1RbaBtJOWKTGS2PXqb+xN6 AWo/7cUg9eQjwz+oHCK2XucBF8hAjr0c5sBV+uWhWnCebzjJeUxXBHgrQtkNdYsT2v4I WaBA== X-Gm-Message-State: AOAM533YNjx3c06PIwSEMXHi0ZOItlHDBz5RhSgeP24kmrLNOl7Z3Vyx jHpC6mayg+uuldFejGWQkXZX4COLDlJmUQ== X-Google-Smtp-Source: ABdhPJzbXJJkiR9EuntQuHCgnwjNj4vcsmF0lCW+JpOZB1dwdR5w7nZA8xjX0uIUFBQCVrTo6Ds/Tw== X-Received: by 2002:a63:da14:: with SMTP id c20mr10555663pgh.155.1629317984919; Wed, 18 Aug 2021 13:19:44 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 11/16] tcg/mips: Split out tcg_out_movi_one Date: Wed, 18 Aug 2021 10:19:26 -1000 Message-Id: <20210818201931.393394-12-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210818201931.393394-1-richard.henderson@linaro.org> References: <20210818201931.393394-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::436; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x436.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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1629318942930100001 Content-Type: text/plain; charset="utf-8" Emit all constants that can be loaded in exactly one insn. Signed-off-by: Richard Henderson --- tcg/mips/tcg-target.c.inc | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/tcg/mips/tcg-target.c.inc b/tcg/mips/tcg-target.c.inc index 333b9572d0..b32edd5a7a 100644 --- a/tcg/mips/tcg-target.c.inc +++ b/tcg/mips/tcg-target.c.inc @@ -524,20 +524,34 @@ static bool tcg_out_mov(TCGContext *s, TCGType type, = TCGReg ret, TCGReg arg) return true; } =20 +static bool tcg_out_movi_one(TCGContext *s, TCGReg ret, tcg_target_long ar= g) +{ + if (arg =3D=3D (int16_t)arg) { + tcg_out_opc_imm(s, OPC_ADDIU, ret, TCG_REG_ZERO, arg); + return true; + } + if (arg =3D=3D (uint16_t)arg) { + tcg_out_opc_imm(s, OPC_ORI, ret, TCG_REG_ZERO, arg); + return true; + } + if (arg =3D=3D (int32_t)arg && (arg & 0xffff) =3D=3D 0) { + tcg_out_opc_imm(s, OPC_LUI, ret, TCG_REG_ZERO, arg >> 16); + return true; + } + return false; +} + static void tcg_out_movi(TCGContext *s, TCGType type, TCGReg ret, tcg_target_long arg) { if (TCG_TARGET_REG_BITS =3D=3D 64 && type =3D=3D TCG_TYPE_I32) { arg =3D (int32_t)arg; } - if (arg =3D=3D (int16_t)arg) { - tcg_out_opc_imm(s, OPC_ADDIU, ret, TCG_REG_ZERO, arg); - return; - } - if (arg =3D=3D (uint16_t)arg) { - tcg_out_opc_imm(s, OPC_ORI, ret, TCG_REG_ZERO, arg); + + if (tcg_out_movi_one(s, ret, arg)) { return; } + if (TCG_TARGET_REG_BITS =3D=3D 32 || arg =3D=3D (int32_t)arg) { tcg_out_opc_imm(s, OPC_LUI, ret, TCG_REG_ZERO, arg >> 16); } else { --=20 2.25.1 From nobody Tue May 21 02:31:22 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=1629318436; cv=none; d=zohomail.com; s=zohoarc; b=ZIx2hdxXhflF7vN8hh7jh/eEMHVvXIlTp6i1Dmv8kuqoJ7rAEDTNqyncdihX+P3qdHBZ+jBL63RoLnwSBQ83YeU3F3wniPLkxq4x2cbzcBvsf4Qh8cYWMQDKpdx4QH6qSOujU37v23qvpElG3fJM/qcls3UBHZ3ngEFibttVq7I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1629318436; h=Content-Transfer-Encoding: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=WMobBd21hxhBtnfxmCHTdmsDMrlUXdir7Qqr9MLBdJc=; b=X/ORFZhtnyxipHy9tDqAlj6VQYiHdk6a5OeCO/s6Kbolb7d/GcD6/nREHtqfZAwq5jZN/fHo50R9bbCvccCI3ECKKCelMYZWe871GsYfndIUaWpWKQpSmQTQhFkxfiL6EecItaCkkd3QCRnXkxBBZUyQwsMo8Dkuni02DS+wIxc= 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) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1629318436349951.2213362434934; Wed, 18 Aug 2021 13:27:16 -0700 (PDT) Received: from localhost ([::1]:60232 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mGS9b-0005oq-5D for importer@patchew.org; Wed, 18 Aug 2021 16:27:15 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40346) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mGS2O-0008Cc-RY for qemu-devel@nongnu.org; Wed, 18 Aug 2021 16:19:48 -0400 Received: from mail-pl1-x62f.google.com ([2607:f8b0:4864:20::62f]:42770) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mGS2N-0006Jk-9P for qemu-devel@nongnu.org; Wed, 18 Aug 2021 16:19:48 -0400 Received: by mail-pl1-x62f.google.com with SMTP id w6so2527179plg.9 for ; Wed, 18 Aug 2021 13:19:46 -0700 (PDT) Received: from localhost.localdomain ([173.197.107.15]) by smtp.gmail.com with ESMTPSA id x13sm619621pjh.30.2021.08.18.13.19.45 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Aug 2021 13:19:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=WMobBd21hxhBtnfxmCHTdmsDMrlUXdir7Qqr9MLBdJc=; b=FzLfKJcXPtz5DzBZ6cwBKUWM6Eh9YID/+rWBWrjxtGHmcDeTrickWj+m8dck6L3BQA n1GMg0OUrT42qI2t49dTzsvr3dfoi6wMy6S+iGIkcuyEzn41g3ks/7G00m1yLL8YtpYd gwimOa4IpSDTXXq1bxiA9X2gzjTth7Ju1NvpVaBv2WN+pyX7Bf3Pkw2wcwXmTujfI0/k 3C6BRJ3bzjXXSM2ZZDko+2T/PUcb3enWkSa6GIWjwIl/FgCdZ8g8emrqR5qy1KYJhGHW 5lj8SFWcHx1qYkh9DfmKEWgtX6qgNrvl3KHZF2Wazr6hPKFNFBGQytrOt7ulc5lVeXcb J2RA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=WMobBd21hxhBtnfxmCHTdmsDMrlUXdir7Qqr9MLBdJc=; b=Jj2Uzqv+JhzDjDWDXNeoaVgLCj+OiL9ukT4XAdbI45DPMqOtdIXdFlak5LRblFWB+b 3cGdAl3CQnzqC+G/gZ+bAmFMzetg7fmY3CZI8cshLDZATseQRN9bmRYY1DDg1Os1qobJ 0F3lmabqyUJTxQVVLk2F70mvC91eEc1rCpOjUqA5YXw0ZRvjVLpnwXm/V507zv3CrJNF 3SU1ax834nWwFKIeZp3WLn1pZfJk8rxiZ4xsAbx3/dePIlPt1s6pulGCO9UfbeFi9K/l nrlw1o+d2ebr86SN3E9sPO1fqsR41+/yu04NRMohyig/MB9JU4oKbesS8R8Zb1+cnCdp yRfA== X-Gm-Message-State: AOAM530l1xsB0Ao2P9U56xjXIV4tcoGjqNTqsm7+E7bXd/qOIYE+O8mU KRqDIiaYctZGwjAlfo4mdSjEiMbheAK8qA== X-Google-Smtp-Source: ABdhPJxfYDfaWj5q0qFw7A7IeYD0AZB4yQh7fIwNuz7RNQDXuCNqIxAmT/HKtoXJAS8AWKWiT3hIBA== X-Received: by 2002:a17:902:bcc6:b0:12d:bd30:bc4d with SMTP id o6-20020a170902bcc600b0012dbd30bc4dmr8575902pls.18.1629317985921; Wed, 18 Aug 2021 13:19:45 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 12/16] tcg/mips: Split out tcg_out_movi_two Date: Wed, 18 Aug 2021 10:19:27 -1000 Message-Id: <20210818201931.393394-13-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210818201931.393394-1-richard.henderson@linaro.org> References: <20210818201931.393394-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::62f; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62f.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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1629318437571100003 Content-Type: text/plain; charset="utf-8" Emit all 32-bit signed constants, which can be loaded in two insns. Signed-off-by: Richard Henderson --- tcg/mips/tcg-target.c.inc | 35 ++++++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 11 deletions(-) diff --git a/tcg/mips/tcg-target.c.inc b/tcg/mips/tcg-target.c.inc index b32edd5a7a..d351d53a7b 100644 --- a/tcg/mips/tcg-target.c.inc +++ b/tcg/mips/tcg-target.c.inc @@ -541,6 +541,22 @@ static bool tcg_out_movi_one(TCGContext *s, TCGReg ret= , tcg_target_long arg) return false; } =20 +static bool tcg_out_movi_two(TCGContext *s, TCGReg ret, tcg_target_long ar= g) +{ + /* + * All signed 32-bit constants are loadable with two immediates, + * and everything else requires more work. + */ + if (arg =3D=3D (int32_t)arg) { + if (!tcg_out_movi_one(s, ret, arg)) { + tcg_out_opc_imm(s, OPC_LUI, ret, TCG_REG_ZERO, arg >> 16); + tcg_out_opc_imm(s, OPC_ORI, ret, ret, arg & 0xffff); + } + return true; + } + return false; +} + static void tcg_out_movi(TCGContext *s, TCGType type, TCGReg ret, tcg_target_long arg) { @@ -548,21 +564,18 @@ static void tcg_out_movi(TCGContext *s, TCGType type, arg =3D (int32_t)arg; } =20 - if (tcg_out_movi_one(s, ret, arg)) { + /* Load all 32-bit constants. */ + if (tcg_out_movi_two(s, ret, arg)) { return; } =20 - if (TCG_TARGET_REG_BITS =3D=3D 32 || arg =3D=3D (int32_t)arg) { - tcg_out_opc_imm(s, OPC_LUI, ret, TCG_REG_ZERO, arg >> 16); + tcg_out_movi(s, TCG_TYPE_I32, ret, arg >> 31 >> 1); + if (arg & 0xffff0000ull) { + tcg_out_dsll(s, ret, ret, 16); + tcg_out_opc_imm(s, OPC_ORI, ret, ret, arg >> 16); + tcg_out_dsll(s, ret, ret, 16); } else { - tcg_out_movi(s, TCG_TYPE_I32, ret, arg >> 31 >> 1); - if (arg & 0xffff0000ull) { - tcg_out_dsll(s, ret, ret, 16); - tcg_out_opc_imm(s, OPC_ORI, ret, ret, arg >> 16); - tcg_out_dsll(s, ret, ret, 16); - } else { - tcg_out_dsll(s, ret, ret, 32); - } + tcg_out_dsll(s, ret, ret, 32); } if (arg & 0xffff) { tcg_out_opc_imm(s, OPC_ORI, ret, ret, arg & 0xffff); --=20 2.25.1 From nobody Tue May 21 02:31:22 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=1629319025; cv=none; d=zohomail.com; s=zohoarc; b=igY6e85vDODN2dDTDs4dH/jdsbkt1WgT6Dhfc2lH2ldmSgfax7Mn6IlVVHJfrKve137Ejv4IEaD3pmJ/uJWaOlR2hqE7+kbAraIjNJGwLWRvCI60y28+LwAuslZSJQ7JRsmDpK7ghMrADSwAkrd638O3VSboLt4atIXLMbbX0Pk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1629319025; h=Content-Transfer-Encoding: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=dmNHD8oMVOw6IiwNX8BcqXva18N9be8xhmnHYKvCR/4=; b=gUqzI3ZPy7hWIzCn/ty5nRGIT5lLSgtZefHTCOw/54iZ1YaMSlwRe5LsaYIROqwE6IHqo4oY92N2XIMheCWUBNmUp6Yo/kWykBZvphvqhxt1uedQghB0CDvrHPubFWYwKXv8DAk+rEqibSI+sL8NiTCLEALj6QOakDYg/06MU3Q= 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) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1629319025752391.0646163801215; Wed, 18 Aug 2021 13:37:05 -0700 (PDT) Received: from localhost ([::1]:58478 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mGSJ6-0007KF-P0 for importer@patchew.org; Wed, 18 Aug 2021 16:37:04 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40364) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mGS2P-0008Fe-RK for qemu-devel@nongnu.org; Wed, 18 Aug 2021 16:19:49 -0400 Received: from mail-pf1-x42e.google.com ([2607:f8b0:4864:20::42e]:46802) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mGS2O-0006K4-6N for qemu-devel@nongnu.org; Wed, 18 Aug 2021 16:19:49 -0400 Received: by mail-pf1-x42e.google.com with SMTP id y11so3334806pfl.13 for ; Wed, 18 Aug 2021 13:19:47 -0700 (PDT) Received: from localhost.localdomain ([173.197.107.15]) by smtp.gmail.com with ESMTPSA id x13sm619621pjh.30.2021.08.18.13.19.46 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Aug 2021 13:19:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=dmNHD8oMVOw6IiwNX8BcqXva18N9be8xhmnHYKvCR/4=; b=v7UUHDILwNguMjgH5Y6T4vKpTdcoX3i47kNCxlhhpWSeOpDelrxdW2+lz+tYfgt7ys DkEW9IZ48AY0Xwpgs9WVa4RjiTskw+AqmQd5axVAk/G7zZFW/MKxIvgcU2OBjUPPpPji mutlI8zBrNuIV5t34QONuY21d8obm0olGOSqxUwZnbX70kDuTRtdk6yikl/a0zAcAVUn tJ0oFsM6qVuNemUuH2I00EtsDJfU+mppOmZ7pV9cpP0+Z+jLaLIcSUlnM+oi5rOdpeRw qgQr7Y0dGrXFOhrpBHmdHeWDrUyPI5OpTZZfNF2rGxUhxPlQGKjR7UvHt4cXIsczw4vI EdZw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=dmNHD8oMVOw6IiwNX8BcqXva18N9be8xhmnHYKvCR/4=; b=HSy1/8fYuIYJoSBhkoRqKVG0woDVXHqpiQPD3C3WmhOR1wkUJ145aSwYsjAuQSrGtA yW3zyEiqin3tOd1/uskrpsipfgZU/4qVB8x2t+8NB5/7RDm+aYbcL+4Naqgnk2t/I/OA w9ZD/qE/XHq+44i1vmCnmRTaY9k1ikcGjbL1+OFK7H1VeUYeecDP2ave1FNv6xf7nnpa ZwFpQiG9xerPM4sq+xEcSrKKLNrBKARglqWXjXCI3nPbb1B27POiWQcF/eHi7SBOg4SP zUSla+/+2pZ5Y3vQT+9XVWoaRtye3Saoorv4VTkCgXT3h/JfhHcylUCcLoQZ2yhQilaD +YvA== X-Gm-Message-State: AOAM5312Dmwk8N+FQM2WYK+a/d8vxBVcl4pMGU/4chrVBtaPEDAHFckZ TV8loJEp1NUDlettsLTT9HHtLP7rT2sbZA== X-Google-Smtp-Source: ABdhPJwnMZf5WTQWC2g7if8Fn44KFIj7v+GlFqmpLBtLSEid4yLAaVRIWCf0rSlFkcXaXnkzxasqtg== X-Received: by 2002:a62:dd83:0:b029:30f:d69:895f with SMTP id w125-20020a62dd830000b029030f0d69895fmr11175081pff.17.1629317986868; Wed, 18 Aug 2021 13:19:46 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 13/16] tcg/mips: Use the constant pool for 64-bit constants Date: Wed, 18 Aug 2021 10:19:28 -1000 Message-Id: <20210818201931.393394-14-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210818201931.393394-1-richard.henderson@linaro.org> References: <20210818201931.393394-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::42e; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42e.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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1629319026262100001 Content-Type: text/plain; charset="utf-8" During normal processing, the constant pool is accessible via TCG_REG_TB. During the prologue, it is accessible via TCG_REG_T9. Signed-off-by: Richard Henderson --- tcg/mips/tcg-target.h | 1 + tcg/mips/tcg-target.c.inc | 65 +++++++++++++++++++++++++++++---------- 2 files changed, 49 insertions(+), 17 deletions(-) diff --git a/tcg/mips/tcg-target.h b/tcg/mips/tcg-target.h index 28c42e23e1..839364b493 100644 --- a/tcg/mips/tcg-target.h +++ b/tcg/mips/tcg-target.h @@ -208,5 +208,6 @@ void tb_target_set_jmp_target(uintptr_t, uintptr_t, uin= tptr_t, uintptr_t) QEMU_ERROR("code path is reachable"); =20 #define TCG_TARGET_NEED_LDST_LABELS +#define TCG_TARGET_NEED_POOL_LABELS =20 #endif diff --git a/tcg/mips/tcg-target.c.inc b/tcg/mips/tcg-target.c.inc index d351d53a7b..2ab37ac7c0 100644 --- a/tcg/mips/tcg-target.c.inc +++ b/tcg/mips/tcg-target.c.inc @@ -25,6 +25,7 @@ */ =20 #include "../tcg-ldst.c.inc" +#include "../tcg-pool.c.inc" =20 #ifdef HOST_WORDS_BIGENDIAN # define MIPS_BE 1 @@ -166,9 +167,18 @@ static bool reloc_pc16(tcg_insn_unit *src_rw, const tc= g_insn_unit *target) static bool patch_reloc(tcg_insn_unit *code_ptr, int type, intptr_t value, intptr_t addend) { - tcg_debug_assert(type =3D=3D R_MIPS_PC16); - tcg_debug_assert(addend =3D=3D 0); - return reloc_pc16(code_ptr, (const tcg_insn_unit *)value); + value +=3D addend; + switch (type) { + case R_MIPS_PC16: + return reloc_pc16(code_ptr, (const tcg_insn_unit *)value); + case R_MIPS_16: + if (value !=3D (int16_t)value) { + return false; + } + *code_ptr =3D deposit32(*code_ptr, 0, 16, value); + return true; + } + g_assert_not_reached(); } =20 #define TCG_CT_CONST_ZERO 0x100 @@ -500,6 +510,11 @@ static void tcg_out_nop(TCGContext *s) tcg_out32(s, 0); } =20 +static void tcg_out_nop_fill(tcg_insn_unit *p, int count) +{ + memset(p, 0, count * sizeof(tcg_insn_unit)); +} + static void tcg_out_dsll(TCGContext *s, TCGReg rd, TCGReg rt, TCGArg sa) { tcg_out_opc_sa64(s, OPC_DSLL, OPC_DSLL32, rd, rt, sa); @@ -557,8 +572,15 @@ static bool tcg_out_movi_two(TCGContext *s, TCGReg ret= , tcg_target_long arg) return false; } =20 -static void tcg_out_movi(TCGContext *s, TCGType type, - TCGReg ret, tcg_target_long arg) +static void tcg_out_movi_pool(TCGContext *s, TCGReg ret, + tcg_target_long arg, TCGReg tbreg) +{ + new_pool_label(s, arg, R_MIPS_16, s->code_ptr, tcg_tbrel_diff(s, NULL)= ); + tcg_out_opc_imm(s, OPC_LD, ret, tbreg, 0); +} + +static void tcg_out_movi_int(TCGContext *s, TCGType type, TCGReg ret, + tcg_target_long arg, TCGReg tbreg) { if (TCG_TARGET_REG_BITS =3D=3D 64 && type =3D=3D TCG_TYPE_I32) { arg =3D (int32_t)arg; @@ -568,18 +590,17 @@ static void tcg_out_movi(TCGContext *s, TCGType type, if (tcg_out_movi_two(s, ret, arg)) { return; } + assert(TCG_TARGET_REG_BITS =3D=3D 64); =20 - tcg_out_movi(s, TCG_TYPE_I32, ret, arg >> 31 >> 1); - if (arg & 0xffff0000ull) { - tcg_out_dsll(s, ret, ret, 16); - tcg_out_opc_imm(s, OPC_ORI, ret, ret, arg >> 16); - tcg_out_dsll(s, ret, ret, 16); - } else { - tcg_out_dsll(s, ret, ret, 32); - } - if (arg & 0xffff) { - tcg_out_opc_imm(s, OPC_ORI, ret, ret, arg & 0xffff); - } + /* Otherwise, put 64-bit constants into the constant pool. */ + tcg_out_movi_pool(s, ret, arg, tbreg); +} + +static void tcg_out_movi(TCGContext *s, TCGType type, + TCGReg ret, tcg_target_long arg) +{ + TCGReg tbreg =3D TCG_TARGET_REG_BITS =3D=3D 64 ? TCG_REG_TB : 0; + tcg_out_movi_int(s, type, ret, arg, tbreg); } =20 static void tcg_out_bswap16(TCGContext *s, TCGReg ret, TCGReg arg, int fla= gs) @@ -2738,10 +2759,20 @@ static void tcg_target_qemu_prologue(TCGContext *s) =20 #ifndef CONFIG_SOFTMMU if (guest_base !=3D (int16_t)guest_base) { - tcg_out_movi(s, TCG_TYPE_PTR, TCG_GUEST_BASE_REG, guest_base); + /* + * The function call abi for n32 and n64 will have loaded $25 (t9) + * with the address of the prologue, so we can use that instead + * of TCG_REG_TB. + */ +#if TCG_TARGET_REG_BITS =3D=3D 64 && !defined(__mips_abicalls) +# error "Unknown mips abi" +#endif + tcg_out_movi_int(s, TCG_TYPE_PTR, TCG_GUEST_BASE_REG, guest_base, + TCG_TARGET_REG_BITS =3D=3D 64 ? TCG_REG_T9 : 0); tcg_regset_set_reg(s->reserved_regs, TCG_GUEST_BASE_REG); } #endif + if (TCG_TARGET_REG_BITS =3D=3D 64) { tcg_out_mov(s, TCG_TYPE_PTR, TCG_REG_TB, tcg_target_call_iarg_regs= [1]); } --=20 2.25.1 From nobody Tue May 21 02:31:22 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=1629319135; cv=none; d=zohomail.com; s=zohoarc; b=bNbBEOmCi72mMmLrelpFZUc/ZeGWd9heaVanl0dkeAFeOsHFBSow6EjtDoOY/tSTEqXzPLVVc7vF1g5X4meHNAndiQQCLYrZlweCJSFJW0VbqPsF5hiogRtwpTtZ/1/J+GwwBWFwTRENKuhHNJypOWC9MZT5SEqB2PYjhbO3300= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1629319135; h=Content-Transfer-Encoding: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=aRM/aV1nNd+z0X6JLDx3kBkYbHw3rVDD5maGh4N4GXM=; b=oDzc4xa1KfaML9y2qXySc1xkRmzsfzoynSBntsejcZ4fGSV0c0xg16QCNox8tqglmiFix9UZRUxMQA4h+6lX4pTJ0AkVqolBfn04pHcFkHXS1AZjGhzWllFT/poVb7AiheCnJGaD8mTf22UmWuKwEcJxrxzhRpCKyZTsH5UPhN8= 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) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1629319134860197.80685371952734; Wed, 18 Aug 2021 13:38:54 -0700 (PDT) Received: from localhost ([::1]:34968 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mGSKr-00023B-Re for importer@patchew.org; Wed, 18 Aug 2021 16:38:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40372) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mGS2Q-0008GL-FO for qemu-devel@nongnu.org; Wed, 18 Aug 2021 16:19:53 -0400 Received: from mail-pg1-x52c.google.com ([2607:f8b0:4864:20::52c]:41834) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mGS2P-0006LF-31 for qemu-devel@nongnu.org; Wed, 18 Aug 2021 16:19:50 -0400 Received: by mail-pg1-x52c.google.com with SMTP id k24so3485409pgh.8 for ; Wed, 18 Aug 2021 13:19:48 -0700 (PDT) Received: from localhost.localdomain ([173.197.107.15]) by smtp.gmail.com with ESMTPSA id x13sm619621pjh.30.2021.08.18.13.19.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Aug 2021 13:19:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=aRM/aV1nNd+z0X6JLDx3kBkYbHw3rVDD5maGh4N4GXM=; b=AheVb+eFo+YD6nig9aY/StyGg0faymC1Y43Tm1T2UlqrTz5E5O066z7qQIHUuWkZ6a I1A2FgFeXVsnpT3kEuD6CcwHAosJChJu2VwlcDuJxhUqDb8oGpsd17imv6yQmzNO8aan 2JQk/B/3pZQ4aWqMC0CDv4pvkX3abQN5QxM+1driwdhaem26HgMEHjLy8xpCN58aATBQ QBAU3t1Xk0rU39tIVEg6uAABTdnBeutKrwjH4OwIXVVPHZTfGUh669soXfYgCyggWqSg yxKKjmaq2Rh2b1lidsdZMdf6h5zhzuIl1K3tQeAvMkA4Yh/7+iRbhUmAeMGW0KXdEe3X /zBQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=aRM/aV1nNd+z0X6JLDx3kBkYbHw3rVDD5maGh4N4GXM=; b=VCzN+PBMZ11kK5DERROBtFcOP8nM7tNpWClP6zFxR4qSduTLkc7tNlWWHVCilhW4s5 C8xNOMcXTgxUemzRGBeu1cHnqkfembUR9c8Y8ntmF9K+4EbSSE7r4jQWTQtraEC7QTMG PGmntiB2KcnmmoJadjXFSexTAXnSylsGj38J3Q1wuVzJ3nW2PyeBBQmvvL+hKb8ygVs5 RQinsLfqyZ7eULHekyDbYLaLVAmAwsEy6jsRJ1IvoKfCd2yNsRn+bY7j8hqSnVZIBNNl CmoHLJENLOFBvPbCPGFKQPKq6/w0Kuhb/HBKxNCPGTyYzffs664VI/HzxShDd0oud4IO 9q6g== X-Gm-Message-State: AOAM5311jTpniqTgEGz/Q7RRO7XFMfoyZl2ngnnwgQkvg9sawYB9Cn88 9EfjwtRNsZAY8wZ08nXoCghoDydwoO/mMw== X-Google-Smtp-Source: ABdhPJyaKFazkAy0801fxuBOWdcQJWCmPHzWHynYHKbv9eByef7SJdZsI2uMqyx5R7PooHZUlv8EoQ== X-Received: by 2002:a05:6a00:1ace:b0:3e2:2a73:e0a4 with SMTP id f14-20020a056a001ace00b003e22a73e0a4mr11357832pfv.73.1629317987782; Wed, 18 Aug 2021 13:19:47 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 14/16] tcg/mips: Aggressively use the constant pool for n64 calls Date: Wed, 18 Aug 2021 10:19:29 -1000 Message-Id: <20210818201931.393394-15-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210818201931.393394-1-richard.henderson@linaro.org> References: <20210818201931.393394-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::52c; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x52c.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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1629319136044100001 Content-Type: text/plain; charset="utf-8" Repeated calls to a single helper are common -- especially the ones for softmmu memory access. Prefer the constant pool to longer sequences to increase sharing. Signed-off-by: Richard Henderson --- tcg/mips/tcg-target.c.inc | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/tcg/mips/tcg-target.c.inc b/tcg/mips/tcg-target.c.inc index 2ab37ac7c0..f641d86561 100644 --- a/tcg/mips/tcg-target.c.inc +++ b/tcg/mips/tcg-target.c.inc @@ -1057,9 +1057,19 @@ static void tcg_out_movcond(TCGContext *s, TCGCond c= ond, TCGReg ret, =20 static void tcg_out_call_int(TCGContext *s, const tcg_insn_unit *arg, bool= tail) { - /* Note that the ABI requires the called function's address to be - loaded into T9, even if a direct branch is in range. */ - tcg_out_movi(s, TCG_TYPE_PTR, TCG_REG_T9, (uintptr_t)arg); + /* + * Note that __mips_abicalls requires the called function's address + * to be loaded into $25 (t9), even if a direct branch is in range. + * + * For n64, always drop the pointer into the constant pool. + * We can re-use helper addresses often and do not want any + * of the longer sequences tcg_out_movi may try. + */ + if (sizeof(uintptr_t) =3D=3D 8) { + tcg_out_movi_pool(s, TCG_REG_T9, (uintptr_t)arg, TCG_REG_TB); + } else { + tcg_out_movi(s, TCG_TYPE_PTR, TCG_REG_T9, (uintptr_t)arg); + } =20 /* But do try a direct branch, allowing the cpu better insn prefetch. = */ if (tail) { --=20 2.25.1 From nobody Tue May 21 02:31:22 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=1629318568; cv=none; d=zohomail.com; s=zohoarc; b=in4oQJ6zmL7dMvHTo8dicFyb4R9tTdcQmHNzhbhnL0sS52YMWkbPVGJ4lOeJN1zt4Yis2DXknKLX78A222Qxg1xZIdjnFgfdgxwc6+vT9UdZsMyKy6MqVZb7NNa9BJ3Hz8yyxFV90mrTwFBZuSHmNDIS3Wq8cSGeDuZ4DIenPLc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1629318568; h=Content-Transfer-Encoding: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=HpQSpkjMY/HVPNmupFN14WCJnZd0Eg9bjbOHuKK4v+k=; b=PvxgC37rqbzMWoX9TNseGpyfvvc8OVLL8jmpcBNguQoAFoBkFGZtfPnCZLfeFqZJyL4J3Xf9q+2/Wo2ugtS+coWTq9MbAFPIqar6mgEZFcj21JRmtJbfVdokaDUi0kW2VBAjsN2icg0yLXfmjAxVMAGGKjdfD4lqueVxGD9ItmU= 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) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1629318568631188.813798293525; Wed, 18 Aug 2021 13:29:28 -0700 (PDT) Received: from localhost ([::1]:40766 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mGSBj-0003Fc-Ll for importer@patchew.org; Wed, 18 Aug 2021 16:29:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40396) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mGS2U-0008HI-0z for qemu-devel@nongnu.org; Wed, 18 Aug 2021 16:19:54 -0400 Received: from mail-pg1-x536.google.com ([2607:f8b0:4864:20::536]:40608) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mGS2Q-0006Lu-3O for qemu-devel@nongnu.org; Wed, 18 Aug 2021 16:19:51 -0400 Received: by mail-pg1-x536.google.com with SMTP id y23so3481434pgi.7 for ; Wed, 18 Aug 2021 13:19:49 -0700 (PDT) Received: from localhost.localdomain ([173.197.107.15]) by smtp.gmail.com with ESMTPSA id x13sm619621pjh.30.2021.08.18.13.19.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Aug 2021 13:19:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=HpQSpkjMY/HVPNmupFN14WCJnZd0Eg9bjbOHuKK4v+k=; b=jtVxb4cfisbRGFNexDMxEdL9ceTblFTBKFJkL7HxT6/5rdDnZPJ0WO4r4jrPCaWhKn qdNdwPL0oOB221mKImSJHwxnCVEtlZiY6jOUp7nwSN8YDrn/zWHNhSQFmHSYfw0mFn5R d99AVgoLVVEmsp+EvObCmyUmkOGTqqAHLcPBFoFS29qJo0YuP6Irpxo5FPGn4XhbgNvp d4kZWQFmG0chD8WhYsp/VCvMaVDKXBLzKb4h/oukOWpv3XaE9ahLdUKOQyDw1FGqJLN/ GPaBZoZHrqHWqJi3drj4b+sLyln1qMBce6yrskGIP0vOAw4qplp+ho8o3n4GeIBRLf4z 1aLg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=HpQSpkjMY/HVPNmupFN14WCJnZd0Eg9bjbOHuKK4v+k=; b=MTqsQtlcLM7hG3CQSfuPgIW2sZh3cGWlRlFLa8xfmDO/Os1AY/YRe7cG4C2IorkDfx rbw1Nq+yfo9FWZ/3sjF62GNFk7qYwosCa1YE+ufG8aJK2oZHaWgetdPPazktuL/EQxFZ 0VoW92pd3DsR3bj/NwAi9NCdDYEfE6yk5MwKU9wWOHWM4RUvOeFBto/kzR2SjS49D9B4 0auDjTq3BUVZcDhsGapPi/2g+IoDYh/G+meKC4wo2llf0tZB13G21LWL3tkqgHaLluOn vyIN6tW1+MsIDAc8EM8xV/HiRqTghitIdyf4RB3LFXzNu/EP6hqVduCIxXG2rNG4tVxd ygJQ== X-Gm-Message-State: AOAM53126osvbKK6sdCOti1DZzbNjic98RwtS+2E8UChSmM7+KSQsaNe JC6FEIIZjJmSZq1pCvzHm/jG9P6RsJKj6g== X-Google-Smtp-Source: ABdhPJxhazTC2IhgOg08zuiMzNyhopn9ELxiH8qv27SFEmnFU2pExikZYmTKzR9d6L5YRIkpeznU9Q== X-Received: by 2002:a65:494e:: with SMTP id q14mr10504923pgs.314.1629317988807; Wed, 18 Aug 2021 13:19:48 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 15/16] tcg/mips: Try tb-relative addresses in tcg_out_movi Date: Wed, 18 Aug 2021 10:19:30 -1000 Message-Id: <20210818201931.393394-16-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210818201931.393394-1-richard.henderson@linaro.org> References: <20210818201931.393394-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::536; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x536.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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1629318568800100001 Content-Type: text/plain; charset="utf-8" These addresses are often loaded by the qemu_ld/st slow path, for loading the retaddr value. Signed-off-by: Richard Henderson --- tcg/mips/tcg-target.c.inc | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tcg/mips/tcg-target.c.inc b/tcg/mips/tcg-target.c.inc index f641d86561..27a23662c8 100644 --- a/tcg/mips/tcg-target.c.inc +++ b/tcg/mips/tcg-target.c.inc @@ -582,6 +582,8 @@ static void tcg_out_movi_pool(TCGContext *s, TCGReg ret, static void tcg_out_movi_int(TCGContext *s, TCGType type, TCGReg ret, tcg_target_long arg, TCGReg tbreg) { + tcg_target_long tmp; + if (TCG_TARGET_REG_BITS =3D=3D 64 && type =3D=3D TCG_TYPE_I32) { arg =3D (int32_t)arg; } @@ -592,6 +594,17 @@ static void tcg_out_movi_int(TCGContext *s, TCGType ty= pe, TCGReg ret, } assert(TCG_TARGET_REG_BITS =3D=3D 64); =20 + /* Load addresses within 2GB of TB with 1 or 3 insns. */ + tmp =3D tcg_tbrel_diff(s, (void *)arg); + if (tmp =3D=3D (int16_t)tmp) { + tcg_out_opc_imm(s, OPC_DADDIU, ret, tbreg, tmp); + return; + } + if (tcg_out_movi_two(s, ret, tmp)) { + tcg_out_opc_reg(s, OPC_DADDU, ret, ret, tbreg); + return; + } + /* Otherwise, put 64-bit constants into the constant pool. */ tcg_out_movi_pool(s, ret, arg, tbreg); } --=20 2.25.1 From nobody Tue May 21 02:31:22 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=1629318764; cv=none; d=zohomail.com; s=zohoarc; b=OqoERPe5Tl6taU5q8NWqx3vhm9jPxQma3fXkf13iGgSrs4rlilps0nZz+Li+pjzhSoA+Vg/Tp/zRr+/bH9VErjz/tA0tINPZLXOov7S+II+0yOqF9Rd8K0ZOuu7NTtwp0synZM4t8yU0BMcGSo68jCRSNQTNTWaSYqDopqItULo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1629318764; h=Content-Transfer-Encoding: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=lfVt0eT0nNOIPktjRSBpSBNPqCJhivS9a0zJZSVFgMw=; b=hzEVJHeJk0dtfV/8kZ3gq+wlWf1l4OLnD+f7sUjU23RNKewVLcDwskkmlBF61SjRwqSFw3UEhaVlC6pTflAeo4x+/nvJmwSAORkfn7mjiYp4gaq+PI+9W+BtGEOq85a+bvxwL5/QQP0ZK57UQbRvhGcF54nYr9VIlhdbfdHqcUQ= 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) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1629318764927925.2989651462308; Wed, 18 Aug 2021 13:32:44 -0700 (PDT) Received: from localhost ([::1]:48692 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mGSEt-0000T0-Pt for importer@patchew.org; Wed, 18 Aug 2021 16:32:43 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40410) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mGS2V-0008MK-CF for qemu-devel@nongnu.org; Wed, 18 Aug 2021 16:19:55 -0400 Received: from mail-pj1-x1029.google.com ([2607:f8b0:4864:20::1029]:38882) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mGS2T-0006Mv-RG for qemu-devel@nongnu.org; Wed, 18 Aug 2021 16:19:55 -0400 Received: by mail-pj1-x1029.google.com with SMTP id om1-20020a17090b3a8100b0017941c44ce4so9699313pjb.3 for ; Wed, 18 Aug 2021 13:19:50 -0700 (PDT) Received: from localhost.localdomain ([173.197.107.15]) by smtp.gmail.com with ESMTPSA id x13sm619621pjh.30.2021.08.18.13.19.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Aug 2021 13:19:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=lfVt0eT0nNOIPktjRSBpSBNPqCJhivS9a0zJZSVFgMw=; b=Y5xGaA4u+HiyvL1PijjTBEdlG0pTzle5/n4SM0DT04SHj36F5dbfSbVt3z4XwMAYZV E3xAEwmUEKo5lY9Xk5l3hPjW3DJs+mV2OmWCzMx6LW6eAfSHjEvs0/IoJDXWsEJjCxRO K3/UtRJyp9JmSf9EWsjANqifUcLwKiAPWB0Wvb5mcUI59dYOCOq/VgMGxZ3U9XT0CwpV tCPV10H8e8S6jEHXnlMBSef5KUT2qz543lxOadlNAHHSgl3uyWZhCoHlRzW8KyW5vWnN QREfarZLoh+5muZbamy8UBgBIOBcV2pOsfig6zXEn1UcsnANMG5odDFtytS6nr+NxOrc 8HHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=lfVt0eT0nNOIPktjRSBpSBNPqCJhivS9a0zJZSVFgMw=; b=URLLEg51JHKEch7tQgamb2vvLpLbuQm54QNUkwI8yWUQxRd6hU6VRFcqqOkDJjYrP4 VpMP3revybYNtxM4E3/DHY07CPGdCn0lswVt04SVi4U/Ei2PC6d3dtzbnK4xmSA4KK+V F3ONMg9k6M1pYV2N1gkc3gLLANgXwUMp9X0sv3YHkaaKpH53hLtTDxDmOpFzmErFpSFJ d/Oz6ZpntYEaCEW0eAynk/Zq5IavTx+9n6Tp7kUUtiUlSihGLwKWpwauhth/AJbW7b46 M0HmoAA4Ud0I5KTQxiBGEbEWmjMwgGmds/ZeqlTn9ki51PxBfburNtxgPRj05K2K9BlZ qmOw== X-Gm-Message-State: AOAM532daZAMW6dYaxY0ObM38fXsMKCK+bE+m85+KaZwyYNL6gM2sn1o epW0ihWa0IIrkeWMHR5UKrkjA0LCw3RSow== X-Google-Smtp-Source: ABdhPJz395EwXSvZ+gc8julrEw6gELfbsDRlrwBfa3ULcQtd5NqZP0DJwDw/uDfgsK1qzXoi83Xn3A== X-Received: by 2002:a17:902:d890:b029:12d:f2:e8d6 with SMTP id b16-20020a170902d890b029012d00f2e8d6mr8661525plz.42.1629317989902; Wed, 18 Aug 2021 13:19:49 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 16/16] tcg/mips: Try three insns with shift and add in tcg_out_movi Date: Wed, 18 Aug 2021 10:19:31 -1000 Message-Id: <20210818201931.393394-17-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210818201931.393394-1-richard.henderson@linaro.org> References: <20210818201931.393394-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::1029; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1029.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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1629318766490100001 Content-Type: text/plain; charset="utf-8" These sequences are inexpensive to test. Maxing out at three insns results in the same space as a load plus the constant pool entry. Signed-off-by: Richard Henderson --- tcg/mips/tcg-target.c.inc | 44 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/tcg/mips/tcg-target.c.inc b/tcg/mips/tcg-target.c.inc index 27a23662c8..92f324de68 100644 --- a/tcg/mips/tcg-target.c.inc +++ b/tcg/mips/tcg-target.c.inc @@ -583,6 +583,7 @@ static void tcg_out_movi_int(TCGContext *s, TCGType typ= e, TCGReg ret, tcg_target_long arg, TCGReg tbreg) { tcg_target_long tmp; + int sh, lo; =20 if (TCG_TARGET_REG_BITS =3D=3D 64 && type =3D=3D TCG_TYPE_I32) { arg =3D (int32_t)arg; @@ -605,6 +606,49 @@ static void tcg_out_movi_int(TCGContext *s, TCGType ty= pe, TCGReg ret, return; } =20 + /* + * Load bitmasks with a right-shift. This is good for things + * like 0x0fff_ffff_ffff_fff0: ADDUI r,0xff00 + DSRL r,r,4. + * or similarly using LUI. For this to work, bit 31 must be set. + */ + if (arg > 0 && (int32_t)arg < 0) { + sh =3D clz64(arg); + if (tcg_out_movi_one(s, ret, arg << sh)) { + tcg_out_dsrl(s, ret, ret, sh); + return; + } + } + + /* + * Load slightly larger constants using left-shift. + * Limit this sequence to 3 insns to avoid too much expansion. + */ + sh =3D ctz64(arg); + if (sh && tcg_out_movi_two(s, ret, arg >> sh)) { + tcg_out_dsll(s, ret, ret, sh); + return; + } + + /* + * Load slightly larger constants using left-shift and add/or. + * Prefer addi with a negative immediate when that would produce + * a larger shift. For this to work, bits 15 and 16 must be set. + */ + lo =3D arg & 0xffff; + if (lo) { + if ((arg & 0x18000) =3D=3D 0x18000) { + lo =3D (int16_t)arg; + } + tmp =3D arg - lo; + sh =3D ctz64(tmp); + tmp >>=3D sh; + if (tcg_out_movi_one(s, ret, tmp)) { + tcg_out_dsll(s, ret, ret, sh); + tcg_out_opc_imm(s, lo < 0 ? OPC_DADDIU : OPC_ORI, ret, ret, lo= ); + return; + } + } + /* Otherwise, put 64-bit constants into the constant pool. */ tcg_out_movi_pool(s, ret, arg, tbreg); } --=20 2.25.1