From patchwork Thu Jun 5 13:13:38 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcus Shawcroft X-Patchwork-Id: 356385 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id BAB341400D5 for ; Thu, 5 Jun 2014 23:13:50 +1000 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:subject:content-type; q= dns; s=default; b=eib/2ilpg1MDznpMo8F6/sUqPcPxlVhH1nVHLc9oW0YWo4 kGSakLRoFK4d05jhdgEXWzam0dICb9wMkvchgJNwHVsf69kZGmspqHuLj1CLs1YJ H+6istaKr6mbSXS8YJKhDOX6JGukCz6RLEKzD99w4out9OWub7uGs0ZVhr/NI= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:subject:content-type; s= default; bh=1/FBmghtIgWvK233KXBiZPOgT3M=; b=y6HbDqIlmr/2NdiOm543 Wr/Q08/eRmFqHFPHdCHzKs4WigvfdhMA8WIlq5aFHXTHPv4t227cVtd/MNGHzi7w jQNoRG4JQzhFI6RuRyE2dyf/v9p0Hh78H/anf5DEggh1TXrj0i8d74jAvArzzTWL 86NonllZlRGxtaN+jLa8DgA= Received: (qmail 2494 invoked by alias); 5 Jun 2014 13:13:44 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 2479 invoked by uid 89); 5 Jun 2014 13:13:43 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.6 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 X-HELO: service87.mimecast.com Received: from service87.mimecast.com (HELO service87.mimecast.com) (91.220.42.44) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 05 Jun 2014 13:13:41 +0000 Received: from cam-owa1.Emea.Arm.com (fw-tnat.cambridge.arm.com [217.140.96.21]) by service87.mimecast.com; Thu, 05 Jun 2014 14:13:39 +0100 Received: from [10.1.207.52] ([10.1.255.212]) by cam-owa1.Emea.Arm.com with Microsoft SMTPSVC(6.0.3790.3959); Thu, 5 Jun 2014 14:13:35 +0100 Message-ID: <53906D02.6070702@arm.com> Date: Thu, 05 Jun 2014 14:13:38 +0100 From: Marcus Shawcroft User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.5.0 MIME-Version: 1.0 To: "gcc-patches@gcc.gnu.org" Subject: [COMMITTED][AArch64] Add frame_size and hard_fp_offset to machine.frame X-MC-Unique: 114060514133901801 Each of the various frame related functions in the backend contains a bespoke set of frame layout calculations. This patch recognizes that all of these functions require three pieces of information from which they can trivially compute the various offsets and sizes they need. We compute the STACK_BOUNDARY rounded locations of the frame_pointer, the location of the hard_frame_pointer and the frame_size once and cache them in the machine.frame structure. Committed /Marcus 2014-06-05 Marcus Shawcroft * config/aarch64/aarch64.h (aarch64_frame): Add hard_fp_offset and frame_size. * config/aarch64/aarch64.c (aarch64_layout_frame): Initialize aarch64_frame hard_fp_offset and frame_size. (aarch64_expand_prologue): Use aarch64_frame hard_fp_offset and frame_size; remove original_frame_size. (aarch64_expand_epilogue, aarch64_final_eh_return_addr): Likewise. (aarch64_initial_elimination_offset): Remove frame_size and offset. Use aarch64_frame frame_size. diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c index 6d9fe4d..0f86a5b 100644 --- a/gcc/config/aarch64/aarch64.c +++ b/gcc/config/aarch64/aarch64.c @@ -1868,6 +1868,18 @@ aarch64_layout_frame (void) offset = AARCH64_ROUND_UP (offset, STACK_BOUNDARY / BITS_PER_UNIT); cfun->machine->frame.saved_regs_size = offset; + + cfun->machine->frame.hard_fp_offset + = AARCH64_ROUND_UP (cfun->machine->frame.saved_varargs_size + + get_frame_size () + + cfun->machine->frame.saved_regs_size, + STACK_BOUNDARY / BITS_PER_UNIT); + + cfun->machine->frame.frame_size + = AARCH64_ROUND_UP (cfun->machine->frame.hard_fp_offset + + crtl->outgoing_args_size, + STACK_BOUNDARY / BITS_PER_UNIT); + cfun->machine->frame.laid_out = true; } @@ -2118,26 +2130,20 @@ aarch64_expand_prologue (void) sub sp, sp, */ - HOST_WIDE_INT original_frame_size; /* local variables + vararg save */ HOST_WIDE_INT frame_size, offset; - HOST_WIDE_INT fp_offset; /* FP offset from SP */ + HOST_WIDE_INT fp_offset; /* Offset from hard FP to SP. */ rtx insn; aarch64_layout_frame (); - original_frame_size = get_frame_size () + cfun->machine->frame.saved_varargs_size; - gcc_assert ((!cfun->machine->frame.saved_varargs_size || cfun->stdarg) - && (cfun->stdarg || !cfun->machine->frame.saved_varargs_size)); - frame_size = (original_frame_size + cfun->machine->frame.saved_regs_size - + crtl->outgoing_args_size); - offset = frame_size = AARCH64_ROUND_UP (frame_size, - STACK_BOUNDARY / BITS_PER_UNIT); if (flag_stack_usage_info) - current_function_static_stack_size = frame_size; + current_function_static_stack_size = cfun->machine->frame.frame_size; + + frame_size = cfun->machine->frame.frame_size; + offset = cfun->machine->frame.frame_size; - fp_offset = (offset - - original_frame_size - - cfun->machine->frame.saved_regs_size); + fp_offset = cfun->machine->frame.frame_size + - cfun->machine->frame.hard_fp_offset; /* Store pairs and load pairs have a range only -512 to 504. */ if (offset >= 512) @@ -2148,7 +2154,7 @@ aarch64_expand_prologue (void) register area. This will allow the pre-index write-back store pair instructions to be used for setting up the stack frame efficiently. */ - offset = original_frame_size + cfun->machine->frame.saved_regs_size; + offset = cfun->machine->frame.hard_fp_offset; if (offset >= 512) offset = cfun->machine->frame.saved_regs_size; @@ -2284,28 +2290,23 @@ aarch64_expand_prologue (void) void aarch64_expand_epilogue (bool for_sibcall) { - HOST_WIDE_INT original_frame_size, frame_size, offset; + HOST_WIDE_INT frame_size, offset; HOST_WIDE_INT fp_offset; rtx insn; rtx cfa_reg; aarch64_layout_frame (); - original_frame_size = get_frame_size () + cfun->machine->frame.saved_varargs_size; - frame_size = (original_frame_size + cfun->machine->frame.saved_regs_size - + crtl->outgoing_args_size); - offset = frame_size = AARCH64_ROUND_UP (frame_size, - STACK_BOUNDARY / BITS_PER_UNIT); - fp_offset = (offset - - original_frame_size - - cfun->machine->frame.saved_regs_size); + offset = frame_size = cfun->machine->frame.frame_size; + fp_offset = cfun->machine->frame.frame_size + - cfun->machine->frame.hard_fp_offset; cfa_reg = frame_pointer_needed ? hard_frame_pointer_rtx : stack_pointer_rtx; /* Store pairs and load pairs have a range only -512 to 504. */ if (offset >= 512) { - offset = original_frame_size + cfun->machine->frame.saved_regs_size; + offset = cfun->machine->frame.hard_fp_offset; if (offset >= 512) offset = cfun->machine->frame.saved_regs_size; @@ -2487,16 +2488,12 @@ aarch64_expand_epilogue (bool for_sibcall) rtx aarch64_final_eh_return_addr (void) { - HOST_WIDE_INT original_frame_size, frame_size, offset, fp_offset; + HOST_WIDE_INT fp_offset; + aarch64_layout_frame (); - original_frame_size = get_frame_size () + cfun->machine->frame.saved_varargs_size; - frame_size = (original_frame_size + cfun->machine->frame.saved_regs_size - + crtl->outgoing_args_size); - offset = frame_size = AARCH64_ROUND_UP (frame_size, - STACK_BOUNDARY / BITS_PER_UNIT); - fp_offset = offset - - original_frame_size - - cfun->machine->frame.saved_regs_size; + + fp_offset = cfun->machine->frame.frame_size + - cfun->machine->frame.hard_fp_offset; if (cfun->machine->frame.reg_offset[LR_REGNUM] < 0) return gen_rtx_REG (DImode, LR_REGNUM); @@ -4246,42 +4243,28 @@ aarch64_can_eliminate (const int from, const int to) HOST_WIDE_INT aarch64_initial_elimination_offset (unsigned from, unsigned to) { - HOST_WIDE_INT frame_size; - HOST_WIDE_INT offset; - aarch64_layout_frame (); - frame_size = (get_frame_size () + cfun->machine->frame.saved_regs_size - + crtl->outgoing_args_size - + cfun->machine->frame.saved_varargs_size); - - frame_size = AARCH64_ROUND_UP (frame_size, STACK_BOUNDARY / BITS_PER_UNIT); - offset = frame_size; if (to == HARD_FRAME_POINTER_REGNUM) { if (from == ARG_POINTER_REGNUM) - return offset - crtl->outgoing_args_size; + return cfun->machine->frame.frame_size - crtl->outgoing_args_size; if (from == FRAME_POINTER_REGNUM) - return cfun->machine->frame.saved_regs_size + get_frame_size (); + return (cfun->machine->frame.hard_fp_offset + - cfun->machine->frame.saved_varargs_size); } if (to == STACK_POINTER_REGNUM) { if (from == FRAME_POINTER_REGNUM) - { - HOST_WIDE_INT elim = crtl->outgoing_args_size - + cfun->machine->frame.saved_regs_size - + get_frame_size (); - elim = AARCH64_ROUND_UP (elim, STACK_BOUNDARY / BITS_PER_UNIT); - return elim; - } + return (cfun->machine->frame.frame_size + - cfun->machine->frame.saved_varargs_size); } - return offset; + return cfun->machine->frame.frame_size; } - /* Implement RETURN_ADDR_RTX. We do not support moving back to a previous frame. */ diff --git a/gcc/config/aarch64/aarch64.h b/gcc/config/aarch64/aarch64.h index 392d095..ae94356 100644 --- a/gcc/config/aarch64/aarch64.h +++ b/gcc/config/aarch64/aarch64.h @@ -527,6 +527,17 @@ struct GTY (()) aarch64_frame HOST_WIDE_INT padding0; HOST_WIDE_INT hardfp_offset; /* HARD_FRAME_POINTER_REGNUM */ + /* Offset from the base of the frame (incomming SP) to the + hard_frame_pointer. This value is always a multiple of + STACK_BOUNDARY. */ + HOST_WIDE_INT hard_fp_offset; + + /* The size of the frame. This value is the offset from base of the + * frame (incomming SP) to the stack_pointer. This value is always + * a multiple of STACK_BOUNDARY. */ + + HOST_WIDE_INT frame_size; + bool laid_out; }; -- 1.7.9.5