From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55335) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aVA4P-0007cK-TH for qemu-devel@nongnu.org; Sun, 14 Feb 2016 22:43:30 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aVA4O-0006I6-SZ for qemu-devel@nongnu.org; Sun, 14 Feb 2016 22:43:29 -0500 Received: from mail-qk0-x242.google.com ([2607:f8b0:400d:c09::242]:34688) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aVA4O-0006Hv-JC for qemu-devel@nongnu.org; Sun, 14 Feb 2016 22:43:28 -0500 Received: by mail-qk0-x242.google.com with SMTP id u128so4997302qkh.1 for ; Sun, 14 Feb 2016 19:43:28 -0800 (PST) Sender: Richard Henderson From: Richard Henderson Date: Mon, 15 Feb 2016 14:42:24 +1100 Message-Id: <1455507754-8978-7-git-send-email-rth@twiddle.net> In-Reply-To: <1455507754-8978-1-git-send-email-rth@twiddle.net> References: <1455507754-8978-1-git-send-email-rth@twiddle.net> Subject: [Qemu-devel] [PATCH v2 06/16] tcg-mips: Adjust move functions for mips64 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: mark.cave-ayland@ilande.co.uk, aurelien@aurel32.net Signed-off-by: Richard Henderson --- tcg/mips/tcg-target.c | 34 +++++++++++++++++++++++++--------- 1 file changed, 25 insertions(+), 9 deletions(-) diff --git a/tcg/mips/tcg-target.c b/tcg/mips/tcg-target.c index 88c032c..0451acb 100644 --- a/tcg/mips/tcg-target.c +++ b/tcg/mips/tcg-target.c @@ -536,23 +536,39 @@ static inline void tcg_out_mov(TCGContext *s, TCGType type, { /* Simple reg-reg move, optimising out the 'do nothing' case */ if (ret != arg) { - tcg_out_opc_reg(s, OPC_ADDU, ret, arg, TCG_REG_ZERO); + tcg_out_opc_reg(s, OPC_OR, ret, arg, TCG_REG_ZERO); } } -static inline void tcg_out_movi(TCGContext *s, TCGType type, - TCGReg reg, tcg_target_long arg) +static void tcg_out_movi(TCGContext *s, TCGType type, + TCGReg ret, tcg_target_long arg) { + if (TCG_TARGET_REG_BITS == 64 && type == TCG_TYPE_I32) { + arg = (int32_t)arg; + } if (arg == (int16_t)arg) { - tcg_out_opc_imm(s, OPC_ADDIU, reg, TCG_REG_ZERO, arg); - } else if (arg == (uint16_t)arg) { - tcg_out_opc_imm(s, OPC_ORI, reg, TCG_REG_ZERO, arg); + tcg_out_opc_imm(s, OPC_ADDIU, ret, TCG_REG_ZERO, arg); + return; + } + if (arg == (uint16_t)arg) { + tcg_out_opc_imm(s, OPC_ORI, ret, TCG_REG_ZERO, arg); + return; + } + if (TCG_TARGET_REG_BITS == 32 || arg == (int32_t)arg) { + tcg_out_opc_imm(s, OPC_LUI, ret, TCG_REG_ZERO, arg >> 16); } else { - tcg_out_opc_imm(s, OPC_LUI, reg, TCG_REG_ZERO, arg >> 16); - if (arg & 0xffff) { - tcg_out_opc_imm(s, OPC_ORI, reg, reg, arg & 0xffff); + 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); + } } static inline void tcg_out_bswap16(TCGContext *s, TCGReg ret, TCGReg arg) -- 2.5.0