]> oss.titaniummirror.com Git - msp430-gcc.git/blobdiff - gcc/config/xtensa/lib2funcs.S
Imported gcc-4.4.3
[msp430-gcc.git] / gcc / config / xtensa / lib2funcs.S
index f607e01f2eaafb713cf914b55baaecd09bd1dc4a..65134e24ccf91694ae866b56b88d765d8665d061 100644 (file)
@@ -1,75 +1,43 @@
 /* Assembly functions for libgcc2.
-   Copyright (C) 2001 Free Software Foundation, Inc.
+   Copyright (C) 2001, 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
    Contributed by Bob Wilson (bwilson@tensilica.com) at Tensilica.
 
 This file is part of GCC.
 
 GCC is free software; you can redistribute it and/or modify it under
 the terms of the GNU General Public License as published by the Free
-Software Foundation; either version 2, or (at your option) any later
+Software Foundation; either version 3, or (at your option) any later
 version.
 
-In addition to the permissions in the GNU General Public License, the
-Free Software Foundation gives you unlimited permission to link the
-compiled version of this file into combinations with other programs,
-and to distribute those combinations without any restriction coming
-from the use of this file.  (The General Public License restrictions
-do apply in other respects; for example, they cover modification of
-the file, and distribution when not linked into a combine
-executable.)
-
 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
 WARRANTY; without even the implied warranty of MERCHANTABILITY or
 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 for more details.
 
-You should have received a copy of the GNU General Public License
-along with GCC; see the file COPYING.  If not, write to the Free
-Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-02111-1307, USA.  */
+Under Section 7 of GPL version 3, you are granted additional
+permissions described in the GCC Runtime Library Exception, version
+3.1, as published by the Free Software Foundation.
 
-#include "xtensa/xtensa-config.h"
+You should have received a copy of the GNU General Public License and
+a copy of the GCC Runtime Library Exception along with this program;
+see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
+<http://www.gnu.org/licenses/>.  */
 
-/* __xtensa_libgcc_window_spill: This function uses a series of nested
-   calls to flush out all but the current register window.  This is
-   used to set up the stack so that arbitrary frames can be accessed.
-   The functions used for the nested calls are also reused by the
-   nonlocal goto function below. */
+#include "xtensa-config.h"
 
-        .align  4
-        .global __xtensa_libgcc_window_spill
-        .type   __xtensa_libgcc_window_spill,@function
-__xtensa_libgcc_window_spill:
-       entry   sp, 48
-       call4   .L__wdwspill_assist52   // called with call8, only need a call4
-       retw
-        .size   __xtensa_libgcc_window_spill,.-__xtensa_libgcc_window_spill
+/* __xtensa_libgcc_window_spill: This function flushes out all but the
+   current register window.  This is used to set up the stack so that
+   arbitrary frames can be accessed.  */
 
-        .align  4
-.L__wdwspill_assist56:
-       entry   sp, 16
-       call4   .L__wdwspill_assist52
-       retw
-        .align  4
-.L__wdwspill_assist52:
-       entry   sp, 48
-       call12  .L__wdwspill_assist40
-       retw
-        .align  4
-.L__wdwspill_assist40:
-       entry   sp, 48
-       call12  .L__wdwspill_assist28
-       retw
-        .align  4
-.L__wdwspill_assist28:
-       entry   sp, 48
-       call12  .L__wdwspill_assist16
-       retw
-        .align  4
-.L__wdwspill_assist16:
-       entry   sp, 16
-       movi    a15, 0
+       .align  4
+       .global __xtensa_libgcc_window_spill
+       .type   __xtensa_libgcc_window_spill,@function
+__xtensa_libgcc_window_spill:
+       entry   sp, 32
+       movi    a2, 0
+       syscall
        retw
+       .size   __xtensa_libgcc_window_spill, .-__xtensa_libgcc_window_spill
 
 
 /* __xtensa_nonlocal_goto: This code does all the hard work of a
@@ -89,8 +57,11 @@ __xtensa_libgcc_window_spill:
 __xtensa_nonlocal_goto:
        entry   sp, 32
 
-       /* flush registers */
-       call8   .L__wdwspill_assist56
+       /* Flush registers.  */
+       mov     a5, a2
+       movi    a2, 0
+       syscall
+       mov     a2, a5
 
        /* Because the save area for a0-a3 is stored one frame below
           the one identified by a2, the only way to restore those
@@ -115,48 +86,48 @@ __xtensa_nonlocal_goto:
           function.  This can be extracted from the high bits of the
           return address, initially in a0.  As the unwinding
           proceeds, the window size is taken from the value of a0
-          saved _two_ frames below the current frame. */
+          saved _two_ frames below the current frame.  */
 
-       addi    a5, sp, -16             # a5 = prev - save area
+       addi    a5, sp, -16     /* a5 = prev - save area */
        l32i    a6, a5, 4
-       addi    a6, a6, -16             # a6 = cur - save area
-       mov     a8, a0                  # a8 = return address (for window size)
+       addi    a6, a6, -16     /* a6 = cur - save area */
+       mov     a8, a0          /* a8 = return address (for window size) */
        j       .Lfirstframe
 
-.Lnextframe:   
-       l32i    a8, a5, 0               # next return address (for window size)
-       mov     a5, a6                  # advance prev
-       addi    a6, a7, -16             # advance cur
-.Lfirstframe:  
-       l32i    a7, a6, 4               # a7 = next
-       bge     a2, a7, .Lnextframe
+.Lnextframe:
+       l32i    a8, a5, 0       /* next return address (for window size) */
+       mov     a5, a6          /* advance prev */
+       addi    a6, a7, -16     /* advance cur */
+.Lfirstframe:
+       l32i    a7, a6, 4       /* a7 = next */
+       bgeu    a2, a7, .Lnextframe
 
        /* At this point, prev (a5) points to the save area with the saved
           values of a0-a3.  Copy those values into the save area at the
           current sp so they will be reloaded when the return from this
           function underflows.  We don't have to worry about exceptions
           while updating the current save area, because the windows have
-          already been flushed. */
+          already been flushed.  */
 
-       addi    a4, sp, -16             # a4 = save area of this function
+       addi    a4, sp, -16     /* a4 = save area of this function */
        l32i    a6, a5, 0
        l32i    a7, a5, 4
        s32i    a6, a4, 0
        s32i    a7, a4, 4
        l32i    a6, a5, 8
-       l32i    a7, a5, 12 
+       l32i    a7, a5, 12
        s32i    a6, a4, 8
        s32i    a7, a4, 12
-       
+
        /* Set return address to goto handler.  Use the window size bits
-          from the return address two frames below the target. */
-       extui   a8, a8, 30, 2           # get window size from return addr.
-       slli    a3, a3, 2               # get goto handler addr. << 2
+          from the return address two frames below the target.  */
+       extui   a8, a8, 30, 2   /* get window size from return addr. */
+       slli    a3, a3, 2       /* get goto handler addr. << 2 */
        ssai    2
-       src     a0, a8, a3              # combine them with a funnel shift
+       src     a0, a8, a3      /* combine them with a funnel shift */
 
        retw
-       .size   __xtensa_nonlocal_goto,.-__xtensa_nonlocal_goto
+       .size   __xtensa_nonlocal_goto, .-__xtensa_nonlocal_goto
 
 
 /* __xtensa_sync_caches: This function is called after writing a trampoline
@@ -173,9 +144,10 @@ __xtensa_nonlocal_goto:
    At least one IHI instruction is needed for each i-cache line which may
    be touched by the trampoline.  An ISYNC instruction is also needed to
    make sure that the modified instructions are loaded into the instruction
-   fetch buffer. */
-       
-#define TRAMPOLINE_SIZE 49
+   fetch buffer.  */
+
+/* Use the maximum trampoline size.  Flushing a bit extra is OK.  */
+#define TRAMPOLINE_SIZE 60
 
        .text
        .align  4
@@ -183,8 +155,8 @@ __xtensa_nonlocal_goto:
        .type   __xtensa_sync_caches,@function
 __xtensa_sync_caches:
        entry   sp, 32
-#if XCHAL_DCACHE_SIZE > 0 && XCHAL_DCACHE_IS_WRITEBACK
-       # Flush the trampoline from the data cache
+#if XCHAL_DCACHE_SIZE > 0
+       /* Flush the trampoline from the data cache.  */
        extui   a4, a2, 0, XCHAL_DCACHE_LINEWIDTH
        addi    a4, a4, TRAMPOLINE_SIZE
        addi    a4, a4, (1 << XCHAL_DCACHE_LINEWIDTH) - 1
@@ -196,9 +168,9 @@ __xtensa_sync_caches:
        addi    a4, a4, -1
        bnez    a4, .Ldcache_loop
        isync
-#endif 
+#endif
 #if XCHAL_ICACHE_SIZE > 0
-       # Invalidate the corresponding lines in the instruction cache
+       /* Invalidate the corresponding lines in the instruction cache.  */
        extui   a4, a2, 0, XCHAL_ICACHE_LINEWIDTH
        addi    a4, a4, TRAMPOLINE_SIZE
        addi    a4, a4, (1 << XCHAL_ICACHE_LINEWIDTH) - 1
@@ -208,7 +180,7 @@ __xtensa_sync_caches:
        addi    a2, a2, (1 << XCHAL_ICACHE_LINEWIDTH)
        addi    a4, a4, -1
        bnez    a4, .Licache_loop
-       isync
 #endif
+       isync
        retw
-       .size   __xtensa_sync_caches,.-__xtensa_sync_caches
+       .size   __xtensa_sync_caches, .-__xtensa_sync_caches