From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18100 invoked by alias); 7 Feb 2011 19:34:53 -0000 Received: (qmail 17937 invoked by uid 22791); 7 Feb 2011 19:34:51 -0000 X-SWARE-Spam-Status: No, hits=-1.8 required=5.0 tests=AWL,BAYES_00,TW_BF,TW_JB,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from oarmail.oarcorp.com (HELO OARmail.OARCORP.com) (67.63.146.244) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 07 Feb 2011 19:34:46 +0000 Received: from iceland.oarcorp.com (192.168.1.160) by OARmail.OARCORP.com (192.168.2.2) with Microsoft SMTP Server (TLS) id 8.1.436.0; Mon, 7 Feb 2011 13:34:44 -0600 Message-ID: <4D504954.2090902@oarcorp.com> Date: Mon, 07 Feb 2011 19:34:00 -0000 From: Joel Sherrill User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.13) Gecko/20101209 Fedora/3.1.7-0.35.b3pre.fc14 Thunderbird/3.1.7 MIME-Version: 1.0 To: , Ian Lance Taylor , Ralf Corsepius Subject: Patch to Enhance m68k Support Content-Type: multipart/mixed; boundary="------------060905050004010409020307" Mailing-List: contact libffi-discuss-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libffi-discuss-owner@sourceware.org X-SW-Source: 2011/txt/msg00032.txt.bz2 --------------060905050004010409020307 Content-Type: text/plain; charset="ISO-8859-1"; format=flowed Content-Transfer-Encoding: 7bit Content-length: 1251 Hi, Ian and I have been working on trying to get Go to work on as many rtems targets as possible. Go requires that libffi support be in place and this is the first time RTEMS has needed libffi. RTEMS builds a lot of multilibs and the m68k libffi code did not support anything but 68020-ish CPUs with HW FPU. This patch adds support for Coldfire cores, mc68000 cores, and soft float variants. It also adds support for flushing the cache on RTEMS. I reported this as and got review on the patch as GCC PR47442 but it appears that Ralf also reported this in 2004 as PR14555 and I am a CC on that. But now we really need it. LOL Can someone please apply this and bring it into gcc? Thanks. 2011-02-07 Joel Sherrill * libffi/src/m68k/ffi.c: Add RTEMS support for cache flushing. Handle case when CPU variant does not have long double support. * libffi/src/m68k/sysv.S: Add support for mc68000, Coldfire, and cores with soft floating point. -- Joel Sherrill, Ph.D. Director of Research& Development joel.sherrill@OARcorp.com On-Line Applications Research Ask me about RTEMS: a free RTOS Huntsville AL 35805 Support Available (256) 722-9985 --------------060905050004010409020307 Content-Type: text/plain; name="libffi-m68k.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="libffi-m68k.diff" Content-length: 3098 2011-02-07 Joel Sherrill * libffi/src/m68k/ffi.c: Add RTEMS support for cache flushing. Handle case when CPU variant does not have long double support. * libffi/src/m68k/sysv.S: Add support for mc68000, Coldfire, and cores with soft floating point. =================================================================== --- libffi/src/m68k/ffi.c (revision 169864) +++ libffi/src/m68k/ffi.c (working copy) @@ -9,8 +9,12 @@ #include #include +#ifdef __rtems__ +void rtems_cache_flush_multiple_data_lines( const void *, size_t ); +#else #include #include +#endif void ffi_call_SYSV (extended_cif *, unsigned, unsigned, @@ -144,9 +148,11 @@ cif->flags = CIF_FLAGS_DOUBLE; break; +#if (FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE) case FFI_TYPE_LONGDOUBLE: cif->flags = CIF_FLAGS_LDOUBLE; break; +#endif case FFI_TYPE_POINTER: cif->flags = CIF_FLAGS_POINTER; @@ -266,8 +272,12 @@ else *(void **)(closure->tramp + 8) = ffi_closure_SYSV; +#ifdef __rtems__ + rtems_cache_flush_multiple_data_lines( codeloc, FFI_TRAMPOLINE_SIZE ); +#else syscall(SYS_cacheflush, codeloc, FLUSH_SCOPE_LINE, FLUSH_CACHE_BOTH, FFI_TRAMPOLINE_SIZE); +#endif closure->cif = cif; closure->user_data = user_data; Index: libffi/src/m68k/sysv.S =================================================================== --- libffi/src/m68k/sysv.S (revision 169864) +++ libffi/src/m68k/sysv.S (working copy) @@ -1,4 +1,5 @@ /* ----------------------------------------------------------------------- + sysv.S - Copyright (c) 1998 Andreas Schwab Copyright (c) 2008 Red Hat, Inc. @@ -85,7 +86,12 @@ move.l 16(%fp),%d2 | If the return value pointer is NULL, assume no return value. + | NOTE: On the mc68000, tst on an address register is not supported. +#if defined(__mc68000__) && !defined(__mcoldfire__) + cmp.w #0, %a1 +#else tst.l %a1 +#endif jbeq noretval btst #0,%d2 @@ -103,19 +109,34 @@ retfloat: btst #2,%d2 jbeq retdouble +#if defined(__MC68881__) fmove.s %fp0,(%a1) +#else + move.l %d0,(%a1) +#endif jbra epilogue retdouble: btst #3,%d2 jbeq retlongdouble +#if defined(__MC68881__) fmove.d %fp0,(%a1) +#else + move.l %d0,(%a1)+ + move.l %d1,(%a1) +#endif jbra epilogue retlongdouble: btst #4,%d2 jbeq retpointer +#if defined(__MC68881__) fmove.x %fp0,(%a1) +#else + move.l %d0,(%a1)+ + move.l %d1,(%a1)+ + move.l %d2,(%a1) +#endif jbra epilogue retpointer: @@ -178,16 +199,31 @@ move.l (%a0),%d1 jra .Lcls_epilogue .Lcls_ret_float: +#if defined(__MC68881__) fmove.s (%a0),%fp0 +#else + move.l (%a0),%d0 +#endif jra .Lcls_epilogue 1: lsr.l #2,%d0 jne 1f jcs .Lcls_ret_ldouble +#if defined(__MC68881__) fmove.d (%a0),%fp0 +#else + move.l (%a0)+,%d0 + move.l (%a0),%d1 +#endif jra .Lcls_epilogue .Lcls_ret_ldouble: +#if defined(__MC68881__) fmove.x (%a0),%fp0 +#else + move.l (%a0)+,%d0 + move.l (%a0)+,%d1 + move.l (%a0),%d2 +#endif jra .Lcls_epilogue 1: lsr.l #2,%d0 --------------060905050004010409020307--