From patchwork Mon Jan 10 20:31:39 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 78206 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 C792FB6EDF for ; Tue, 11 Jan 2011 07:34:04 +1100 (EST) Received: (qmail 19764 invoked by alias); 10 Jan 2011 20:32:41 -0000 Received: (qmail 19629 invoked by uid 22791); 10 Jan 2011 20:32:37 -0000 X-SWARE-Spam-Status: No, hits=-1.7 required=5.0 tests=AWL, BAYES_00, TW_XD, TW_XF X-Spam-Check-By: sourceware.org Received: from eggs.gnu.org (HELO eggs.gnu.org) (140.186.70.92) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 10 Jan 2011 20:32:29 +0000 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PcOPi-00070e-KK for gcc-patches@gcc.gnu.org; Mon, 10 Jan 2011 15:32:27 -0500 Received: from a.mail.sonic.net ([64.142.16.245]:54747) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PcOPi-00070O-9X for gcc-patches@gcc.gnu.org; Mon, 10 Jan 2011 15:32:26 -0500 Received: from are.twiddle.net (are.twiddle.net [75.101.38.216]) by a.mail.sonic.net (8.13.8.Beta0-Sonic/8.13.7) with ESMTP id p0AKWO0c015223 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 10 Jan 2011 12:32:24 -0800 Received: from anchor.twiddle.home (anchor.twiddle.home [172.31.0.4]) by are.twiddle.net (8.14.4/8.14.4) with ESMTP id p0AKWO5Q006769; Mon, 10 Jan 2011 12:32:24 -0800 Received: from anchor.twiddle.home (localhost.localdomain [127.0.0.1]) by anchor.twiddle.home (8.14.4/8.14.4) with ESMTP id p0AKWLVq019689; Mon, 10 Jan 2011 12:32:22 -0800 Received: (from rth@localhost) by anchor.twiddle.home (8.14.4/8.14.4/Submit) id p0AKWKqd019688; Mon, 10 Jan 2011 12:32:20 -0800 From: Richard Henderson To: gcc-patches@gcc.gnu.org Cc: nickc@redhat.com, law@redhat.com, Richard Henderson Subject: [PATCH 10/28] mn10300: Clean up trampoline handling Date: Mon, 10 Jan 2011 12:31:39 -0800 Message-Id: <1294691517-19580-11-git-send-email-rth@redhat.com> In-Reply-To: <1294691517-19580-1-git-send-email-rth@redhat.com> References: <1294691517-19580-1-git-send-email-rth@redhat.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4-2.6 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 From: Richard Henderson The old code was failing in the testsuite. I didn't try to debug exactly why, since the existing code was needlessly complex. --- gcc/config/mn10300/mn10300.c | 50 +++++++++++++++++++++--------------------- gcc/config/mn10300/mn10300.h | 5 +-- 2 files changed, 27 insertions(+), 28 deletions(-) diff --git a/gcc/config/mn10300/mn10300.c b/gcc/config/mn10300/mn10300.c index e801c47..7c090aa 100644 --- a/gcc/config/mn10300/mn10300.c +++ b/gcc/config/mn10300/mn10300.c @@ -2239,37 +2239,39 @@ mn10300_case_values_threshold (void) return 6; } -/* Worker function for TARGET_ASM_TRAMPOLINE_TEMPLATE. */ - -static void -mn10300_asm_trampoline_template (FILE *f) -{ - fprintf (f, "\tadd -4,sp\n"); - fprintf (f, "\t.long 0x0004fffa\n"); - fprintf (f, "\tmov (0,sp),a0\n"); - fprintf (f, "\tadd 4,sp\n"); - fprintf (f, "\tmov (13,a0),a1\n"); - fprintf (f, "\tmov (17,a0),a0\n"); - fprintf (f, "\tjmp (a0)\n"); - fprintf (f, "\t.long 0\n"); - fprintf (f, "\t.long 0\n"); -} - /* Worker function for TARGET_TRAMPOLINE_INIT. */ static void mn10300_trampoline_init (rtx m_tramp, tree fndecl, rtx chain_value) { - rtx fnaddr = XEXP (DECL_RTL (fndecl), 0); - rtx mem; + rtx mem, disp, fnaddr = XEXP (DECL_RTL (fndecl), 0); + + /* This is a strict alignment target, which means that we play + some games to make sure that the locations at which we need + to store and wind up at aligned addresses. + + 0x28 0x00 add 0,d0 + 0xfc 0xdd mov chain,a1 + + 0xf8 0xed 0x00 btst 0,d1 + 0xdc jmp fnaddr + + + Note that the two extra insns are effectively nops; they + clobber the flags but do not affect the contents of D0 or D1. */ - emit_block_move (m_tramp, assemble_trampoline_template (), - GEN_INT (TRAMPOLINE_SIZE), BLOCK_OP_NORMAL); + disp = expand_binop (SImode, sub_optab, fnaddr, + plus_constant (XEXP (m_tramp, 0), 11), + NULL_RTX, 1, OPTAB_DIRECT); - mem = adjust_address (m_tramp, SImode, 0x14); + mem = adjust_address (m_tramp, SImode, 0); + emit_move_insn (mem, gen_int_mode (0xddfc0028, SImode)); + mem = adjust_address (m_tramp, SImode, 4); emit_move_insn (mem, chain_value); - mem = adjust_address (m_tramp, SImode, 0x18); - emit_move_insn (mem, fnaddr); + mem = adjust_address (m_tramp, SImode, 8); + emit_move_insn (mem, gen_int_mode (0xdc00edf8, SImode)); + mem = adjust_address (m_tramp, SImode, 12); + emit_move_insn (mem, disp); } /* Output the assembler code for a C++ thunk function. @@ -2558,8 +2560,6 @@ mn10300_conditional_register_usage (void) #undef TARGET_PREFERRED_OUTPUT_RELOAD_CLASS #define TARGET_PREFERRED_OUTPUT_RELOAD_CLASS mn10300_preferred_output_reload_class -#undef TARGET_ASM_TRAMPOLINE_TEMPLATE -#define TARGET_ASM_TRAMPOLINE_TEMPLATE mn10300_asm_trampoline_template #undef TARGET_TRAMPOLINE_INIT #define TARGET_TRAMPOLINE_INIT mn10300_trampoline_init diff --git a/gcc/config/mn10300/mn10300.h b/gcc/config/mn10300/mn10300.h index 60d7d43..0ee0cd1 100644 --- a/gcc/config/mn10300/mn10300.h +++ b/gcc/config/mn10300/mn10300.h @@ -533,9 +533,8 @@ struct cum_arg /* Length in units of the trampoline for entering a nested function. */ -#define TRAMPOLINE_SIZE 0x1b - -#define TRAMPOLINE_ALIGNMENT 32 +#define TRAMPOLINE_SIZE 16 +#define TRAMPOLINE_ALIGNMENT 32 /* A C expression whose value is RTL representing the value of the return address for the frame COUNT steps up from the current frame.