Received: from eggs.gnu.org ([2001:4830:134:3::10]:51002) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WOefc-0007oB-36 for qemu-devel@nongnu.org; Fri, 14 Mar 2014 22:50:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WOefW-0007Ek-2L for qemu-devel@nongnu.org; Fri, 14 Mar 2014 22:49:55 -0400 Received: from mail-pb0-x230.google.com ([2607:f8b0:400e:c01::230]:45134) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WOefV-0007Eb-Rb for qemu-devel@nongnu.org; Fri, 14 Mar 2014 22:49:49 -0400 Received: by mail-pb0-f48.google.com with SMTP id md12so3377498pbc.7 for ; Fri, 14 Mar 2014 19:49:49 -0700 (PDT) Sender: Richard Henderson From: Richard Henderson Date: Fri, 14 Mar 2014 19:48:39 -0700 Message-Id: <1394851732-25692-14-git-send-email-rth@twiddle.net> In-Reply-To: <1394851732-25692-1-git-send-email-rth@twiddle.net> References: <1394851732-25692-1-git-send-email-rth@twiddle.net> Subject: [Qemu-devel] [PATCH 13/26] tcg-aarch64: Rearrange prologue insn order List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, claudio.fontana@gmail.com Loads LR earlier so that it's available for the return branch earlier. Signed-off-by: Richard Henderson --- tcg/aarch64/tcg-target.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/tcg/aarch64/tcg-target.c b/tcg/aarch64/tcg-target.c index d391c10..05857bf 100644 --- a/tcg/aarch64/tcg-target.c +++ b/tcg/aarch64/tcg-target.c @@ -1853,13 +1853,13 @@ static void tcg_target_qemu_prologue(TCGContext *s) + (TCG_TARGET_STACK_ALIGN - 1); frame_size_tcg_locals &= ~(TCG_TARGET_STACK_ALIGN - 1); - /* Push (FP, LR) and allocate space for all saved registers. */ - tcg_out_insn(s, 3314, STP, TCG_REG_FP, TCG_REG_LR, + /* Push (x19, x20) and allocate space for all saved registers. */ + tcg_out_insn(s, 3314, STP, TCG_REG_X19, TCG_REG_X20, TCG_REG_SP, -frame_size_callee_saved, 1, 1); - /* Store callee-preserved regs x19..x28. */ - for (r = TCG_REG_X19; r <= TCG_REG_X27; r += 2) { - int ofs = (r - TCG_REG_X19 + 2) * 8; + /* Store callee-preserved regs x21..x30. */ + for (r = TCG_REG_X21; r < TCG_REG_X30; r += 2) { + int ofs = (r - TCG_REG_X19) * 8; tcg_out_insn(s, 3314, STP, r, r + 1, TCG_REG_SP, ofs, 1, 0); } @@ -1887,14 +1887,15 @@ static void tcg_target_qemu_prologue(TCGContext *s) tcg_out_insn(s, 3401, ADDI, TCG_TYPE_I64, TCG_REG_SP, TCG_REG_SP, frame_size_tcg_locals); - /* Restore registers x19..x28. */ - for (r = TCG_REG_X19; r <= TCG_REG_X27; r += 2) { - int ofs = (r - TCG_REG_X19 + 2) * 8; + /* Restore registers x30..x21 in reverse order. This gets LR loaded + in the first LDP, minimizing the latency to the return insn. */ + for (r = TCG_REG_X29; r >= TCG_REG_X21; r -= 2) { + int ofs = (r - TCG_REG_X19) * 8; tcg_out_insn(s, 3314, LDP, r, r + 1, TCG_REG_SP, ofs, 1, 0); } - /* Pop (FP, LR), restore SP to previous frame. */ - tcg_out_insn(s, 3314, LDP, TCG_REG_FP, TCG_REG_LR, + /* Pop (x19, x20), restoring SP to previous frame. */ + tcg_out_insn(s, 3314, LDP, TCG_REG_X19, TCG_REG_X20, TCG_REG_SP, frame_size_callee_saved, 0, 1); tcg_out_insn(s, 3207, RET, TCG_REG_LR); } -- 1.8.5.3