From patchwork Sat Sep 14 21:54:44 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 274966 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id E68742C0158 for ; Sun, 15 Sep 2013 08:02:59 +1000 (EST) Received: from localhost ([::1]:54726 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VKxvd-0004Pm-Ro for incoming@patchwork.ozlabs.org; Sat, 14 Sep 2013 18:02:57 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34788) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VKxob-0001tF-SR for qemu-devel@nongnu.org; Sat, 14 Sep 2013 17:55:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VKxoV-0004Ai-Ub for qemu-devel@nongnu.org; Sat, 14 Sep 2013 17:55:41 -0400 Received: from mail-pa0-x22e.google.com ([2607:f8b0:400e:c03::22e]:40547) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VKxoV-0004AQ-Ig for qemu-devel@nongnu.org; Sat, 14 Sep 2013 17:55:35 -0400 Received: by mail-pa0-f46.google.com with SMTP id fa1so3908455pad.33 for ; Sat, 14 Sep 2013 14:55:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=614mONiTtOtlBrSkscz2JBpjRBuLIFany+FMLjqUZz4=; b=NabmbZ6JhZzD15hISkGXMdawoNMENlt3OHGAXqqCimsVv2bF6M+DVE7/k7OEtELaZi 4BQfv9oPuditxYGQNPZZqjMtIo1hWVch7GMOq3N3MOYaUCgP65AcQPm8gvzOLQAtPEuj 4XbrG3xcVsG4OEno1z5TJtwM0CW91W5ViNuHev5WnqvgMNzHrvqIhJZKWWnviRc9uugx 6DZwoEyBB/kUVED23vNsJGftbmk8tPBoYG/iyWY72XhecFrl9H/caX/iVa96Y7syXt85 40zfzas8ncXOQXW7v1wkuo4UKWGkrhLBgmPprN/GfetkybQYn0AVL1JzMV8L6vzG/B6W c9tw== X-Received: by 10.68.196.2 with SMTP id ii2mr20925357pbc.86.1379195734666; Sat, 14 Sep 2013 14:55:34 -0700 (PDT) Received: from pebble.twiddle.net (50-194-63-110-static.hfc.comcastbusiness.net. [50.194.63.110]) by mx.google.com with ESMTPSA id gg10sm20458962pbc.46.1969.12.31.16.00.00 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Sat, 14 Sep 2013 14:55:33 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 14 Sep 2013 14:54:44 -0700 Message-Id: <1379195690-6509-28-git-send-email-rth@twiddle.net> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1379195690-6509-1-git-send-email-rth@twiddle.net> References: <1379195690-6509-1-git-send-email-rth@twiddle.net> X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2607:f8b0:400e:c03::22e Cc: peter.maydell@linaro.org, claudio.fontana@gmail.com Subject: [Qemu-devel] [PATCH v4 27/33] tcg-aarch64: Pass return address to load/store helpers directly. X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Signed-off-by: Richard Henderson --- include/exec/exec-all.h | 11 ----------- tcg/aarch64/tcg-target.c | 44 ++++++++++++++++++++++++++------------------ 2 files changed, 26 insertions(+), 29 deletions(-) diff --git a/include/exec/exec-all.h b/include/exec/exec-all.h index beb4149..8b106f5 100644 --- a/include/exec/exec-all.h +++ b/include/exec/exec-all.h @@ -340,17 +340,6 @@ static inline uintptr_t tcg_getra_ldst(uintptr_t ra) ra += b; /* apply the displacement */ return ra; } -# elif defined(__aarch64__) -# define GETRA_LDST(RA) tcg_getra_ldst(RA) -static inline uintptr_t tcg_getra_ldst(uintptr_t ra) -{ - int32_t b; - ra += 4; /* skip one instruction */ - b = *(int32_t *)ra; /* load the branch insn */ - b = (b << 6) >> (6 - 2); /* extract the displacement */ - ra += b; /* apply the displacement */ - return ra; -} # endif #endif /* CONFIG_QEMU_LDST_OPTIMIZATION */ diff --git a/tcg/aarch64/tcg-target.c b/tcg/aarch64/tcg-target.c index 1905271..ce3c17b 100644 --- a/tcg/aarch64/tcg-target.c +++ b/tcg/aarch64/tcg-target.c @@ -1038,39 +1038,46 @@ static inline void tcg_out_addsub2(TCGContext *s, int ext, TCGReg rl, } } -static inline void tcg_out_nop(TCGContext *s) -{ - tcg_out32(s, 0xd503201f); -} - #ifdef CONFIG_SOFTMMU -/* helper signature: helper_ld_mmu(CPUState *env, target_ulong addr, - int mmu_idx) */ +/* helper signature: helper_ret_ld_mmu(CPUState *env, target_ulong addr, + * int mmu_idx, uintptr_t ra) + */ static const void * const qemu_ld_helpers[4] = { - helper_ldb_mmu, - helper_ldw_mmu, - helper_ldl_mmu, - helper_ldq_mmu, + helper_ret_ldub_mmu, + helper_ret_lduw_mmu, + helper_ret_ldul_mmu, + helper_ret_ldq_mmu, }; -/* helper signature: helper_st_mmu(CPUState *env, target_ulong addr, - uintxx_t val, int mmu_idx) */ +/* helper signature: helper_ret_st_mmu(CPUState *env, target_ulong addr, + * uintxx_t val, int mmu_idx, uintptr_t ra) + */ static const void * const qemu_st_helpers[4] = { - helper_stb_mmu, - helper_stw_mmu, - helper_stl_mmu, - helper_stq_mmu, + helper_ret_stb_mmu, + helper_ret_stw_mmu, + helper_ret_stl_mmu, + helper_ret_stq_mmu, }; +static inline void tcg_out_adr(TCGContext *s, TCGReg rd, tcg_target_long addr) +{ + addr -= (tcg_target_long)s->code_ptr; + assert(addr == sextract64(addr, 0, 21)); + tcg_fmt_Rd_disp21(s, INSN_ADR, rd, addr); +} + static void tcg_out_qemu_ld_slow_path(TCGContext *s, TCGLabelQemuLdst *lb) { reloc_pc19(lb->label_ptr[0], (tcg_target_long)s->code_ptr); tcg_out_movr(s, 1, TCG_REG_X0, TCG_AREG0); tcg_out_movr(s, (TARGET_LONG_BITS == 64), TCG_REG_X1, lb->addrlo_reg); tcg_out_movi(s, TCG_TYPE_I32, TCG_REG_X2, lb->mem_index); + tcg_out_adr(s, TCG_REG_X3, (uintptr_t)lb->raddr); + tcg_out_movi(s, TCG_TYPE_I64, TCG_REG_TMP, (tcg_target_long)qemu_ld_helpers[lb->opc & 3]); tcg_out_callr(s, TCG_REG_TMP); + if (lb->opc & 0x04) { tcg_out_sxt(s, 1, lb->opc & 3, lb->datalo_reg, TCG_REG_X0); } else { @@ -1088,11 +1095,12 @@ static void tcg_out_qemu_st_slow_path(TCGContext *s, TCGLabelQemuLdst *lb) tcg_out_movr(s, (TARGET_LONG_BITS == 64), TCG_REG_X1, lb->addrlo_reg); tcg_out_movr(s, 1, TCG_REG_X2, lb->datalo_reg); tcg_out_movi(s, TCG_TYPE_I32, TCG_REG_X3, lb->mem_index); + tcg_out_adr(s, TCG_REG_X4, (uintptr_t)lb->raddr); + tcg_out_movi(s, TCG_TYPE_I64, TCG_REG_TMP, (tcg_target_long)qemu_st_helpers[lb->opc & 3]); tcg_out_callr(s, TCG_REG_TMP); - tcg_out_nop(s); tcg_out_goto(s, (tcg_target_long)lb->raddr); }