From patchwork Fri Nov 16 16:20:32 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Greenhalgh X-Patchwork-Id: 199681 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]) by ozlabs.org (Postfix) with SMTP id 4E0392C0094 for ; Sat, 17 Nov 2012 03:20:55 +1100 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1353687656; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: From:To:Cc:Subject:Date:Message-Id:MIME-Version:Content-Type: Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:Sender:Delivered-To; bh=IPiBIVPyHWDrw9wEX5Zu mEvxmc4=; b=quRVEzbVScXCsSefSI/dWNJ9/oEHLbRebXCP7Lpmps4plyehrffK NBCU+8IZ1gc3T2S6lRCUeqFwNtP3TF9Vc/vqwaNs0sh5FBp2YN7d4zGXh1S7UjaE r3C4ZzqXDD65FfSDHBLWv5BDKFYWcly9G0PKmJ/giWxV4lL5hvV0uDM= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:Received:From:To:Cc:Subject:Date:Message-Id:MIME-Version:X-MC-Unique:Content-Type:X-IsSubscribed:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=T83xz/ch57TUCtJlCGqe6nZYqbic5v2qGpTrR5js9hA6mogliCuu6pZojSba97 Kyz1Q6bH9+64vUqiFvI1HiSmJU5agcbu9jJQRp/0+wmj7Kk72nTxmQQ9cxEBljJ6 BosDaMbVwTwE3ce2OraQ9hTGvYD76Ig/UgLz/rB8aQ9fk=; Received: (qmail 6840 invoked by alias); 16 Nov 2012 16:20:47 -0000 Received: (qmail 6819 invoked by uid 22791); 16 Nov 2012 16:20:45 -0000 X-SWARE-Spam-Status: No, hits=-1.1 required=5.0 tests=AWL, BAYES_20, KHOP_RCVD_UNTRUST, RCVD_IN_DNSWL_LOW X-Spam-Check-By: sourceware.org Received: from service87.mimecast.com (HELO service87.mimecast.com) (91.220.42.44) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 16 Nov 2012 16:20:41 +0000 Received: from cam-owa2.Emea.Arm.com (fw-tnat.cambridge.arm.com [217.140.96.21]) by service87.mimecast.com; Fri, 16 Nov 2012 16:20:40 +0000 Received: from e106375-lin.cambridge.arm.com ([10.1.255.212]) by cam-owa2.Emea.Arm.com with Microsoft SMTPSVC(6.0.3790.3959); Fri, 16 Nov 2012 16:20:38 +0000 From: James Greenhalgh To: gcc-patches@gcc.gnu.org Cc: marcus.shawcroft@arm.com, sofiane.naci@arm.com Subject: [Patch AArch64] Refactor thunks code generation Date: Fri, 16 Nov 2012 16:20:32 +0000 Message-Id: <1353082832-29401-1-git-send-email-james.greenhalgh@arm.com> MIME-Version: 1.0 X-MC-Unique: 112111616204013201 X-IsSubscribed: yes 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 Hi, I'm sending this on behalf of Sofiane Naci who is currently on holiday. Code generation for C++ thunks previously spat out assembly code, which affects scheduling of the generated code. This patch rewrites the code to generate RTL patterns. A full aarch64-none-elf regression run shows no issues. Thanks Sofiane --- gcc/ 2012-11-16 Sofiane Naci * config/aarch64/aarch64.c (aarch64_output_mi_thunk): Refactor to generate RTL patterns. diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c index 4437fef..7d1e7a2 100644 --- a/gcc/config/aarch64/aarch64.c +++ b/gcc/config/aarch64/aarch64.c @@ -2335,9 +2335,10 @@ aarch64_output_mi_thunk (FILE *file, tree thunk ATTRIBUTE_UNUSED, to return a pointer to an aggregate. On AArch64 a result value pointer will be in x8. */ int this_regno = R0_REGNUM; + rtx this_rtx, temp0, temp1, addr, insn, funexp; - /* Make sure unwind info is emitted for the thunk if needed. */ - final_start_function (emit_barrier (), file, 1); + reload_completed = 1; + emit_note (NOTE_INSN_PROLOGUE_END); if (vcall_offset == 0) aarch64_add_constant (file, this_regno, IP1_REGNUM, delta); @@ -2345,37 +2346,55 @@ aarch64_output_mi_thunk (FILE *file, tree thunk ATTRIBUTE_UNUSED, { gcc_assert ((vcall_offset & 0x7) == 0); - if (delta == 0) - asm_fprintf (file, "\tldr\t%r, [%r]\n", IP0_REGNUM, this_regno); - else if (delta >= -256 && delta < 256) - asm_fprintf (file, "\tldr\t%r, [%r,%wd]!\n", IP0_REGNUM, this_regno, - delta); - else - { - aarch64_add_constant (file, this_regno, IP1_REGNUM, delta); + this_rtx = gen_rtx_REG (Pmode, this_regno); + temp0 = gen_rtx_REG (Pmode, IP0_REGNUM); + temp1 = gen_rtx_REG (Pmode, IP1_REGNUM); - asm_fprintf (file, "\tldr\t%r, [%r]\n", IP0_REGNUM, this_regno); + addr = this_rtx; + if (delta != 0) + { + if (delta >= -256 && delta < 256) + addr = gen_rtx_PRE_MODIFY (Pmode, this_rtx, + plus_constant (Pmode, this_rtx, delta)); + else + aarch64_add_constant (file, this_regno, IP1_REGNUM, delta); } + aarch64_emit_move (temp0, gen_rtx_MEM (Pmode, addr)); + if (vcall_offset >= -256 && vcall_offset < 32768) - asm_fprintf (file, "\tldr\t%r, [%r,%wd]\n", IP1_REGNUM, IP0_REGNUM, - vcall_offset); + addr = plus_constant (Pmode, temp0, vcall_offset); else { aarch64_build_constant (file, IP1_REGNUM, vcall_offset); - asm_fprintf (file, "\tldr\t%r, [%r,%r]\n", IP1_REGNUM, IP0_REGNUM, - IP1_REGNUM); + addr = gen_rtx_PLUS (Pmode, temp0, temp1); } - asm_fprintf (file, "\tadd\t%r, %r, %r\n", this_regno, this_regno, - IP1_REGNUM); + aarch64_emit_move (temp1, gen_rtx_MEM (Pmode,addr)); + emit_insn (gen_add2_insn (this_rtx, temp1)); } - output_asm_insn ("b\t%a0", &XEXP (DECL_RTL (function), 0)); + /* Generate a tail call to the target function. */ + if (!TREE_USED (function)) + { + assemble_external (function); + TREE_USED (function) = 1; + } + funexp = XEXP (DECL_RTL (function), 0); + funexp = gen_rtx_MEM (FUNCTION_MODE, funexp); + insn = emit_call_insn (gen_sibcall (funexp, const0_rtx, NULL_RTX)); + SIBLING_CALL_P (insn) = 1; + + insn = get_insns (); + shorten_branches (insn); + final_start_function (insn, file, 1); + final (insn, file, 1); final_end_function (); + + /* Stop pretending to be a post-reload pass. */ + reload_completed = 0; } - static int aarch64_tls_operand_p_1 (rtx *x, void *data ATTRIBUTE_UNUSED) {