OSDN Git Service

* src/sparc/v9.S (STACKFRAME): Bump to 176.
[pf3gnuchains/gcc-fork.git] / libffi / src / sparc / v9.S
index e2eeb43..bf31a2b 100644 (file)
@@ -1,7 +1,7 @@
 /* -----------------------------------------------------------------------
-   v9.S - Copyright (c) 2000, 2003 Cygnus Solutions
+   v9.S - Copyright (c) 2000, 2003, 2004, 2008 Red Hat, Inc.
    
-   Sparc 64bit Foreign Function Interface 
+   SPARC 64-bit Foreign Function Interface 
 
    Permission is hereby granted, free of charge, to any person obtaining
    a copy of this software and associated documentation files (the
    The above copyright notice and this permission notice shall be included
    in all copies or substantial portions of the Software.
 
-   THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS
-   OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-   IN NO EVENT SHALL CYGNUS SOLUTIONS BE LIABLE FOR ANY CLAIM, DAMAGES OR
-   OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
-   ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
-   OTHER DEALINGS IN THE SOFTWARE.
+   THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
+   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+   NONINFRINGEMENT.  IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+   HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+   WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+   OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+   DEALINGS IN THE SOFTWARE.
    ----------------------------------------------------------------------- */
 
 #define LIBFFI_ASM     
+#include <fficonfig.h>
 #include <ffi.h>
 
 #ifdef SPARC64
 /* Only compile this in for 64bit builds, because otherwise the object file
    will have inproper architecture due to used instructions.  */
 
-#define STACKFRAME 128         /* Minimum stack framesize for SPARC */
+#define STACKFRAME 176         /* Minimum stack framesize for SPARC 64-bit */
 #define STACK_BIAS 2047
 #define ARGS (128)             /* Offset of register area in frame */
 
 .text
         .align 8
-.globl ffi_call_V9
-.globl _ffi_call_V9
+.globl ffi_call_v9
+.globl _ffi_call_v9
 
-ffi_call_V9:
-_ffi_call_V9:
+ffi_call_v9:
+_ffi_call_v9:
 .LLFB1:
        save    %sp, -STACKFRAME, %sp
 .LLCFI0:
@@ -86,7 +88,7 @@ _ffi_call_V9:
 
        cmp     %i3, FFI_TYPE_INT
        be,a,pt %icc, done
-        stx    %o0, [%i4]      ! (delay)
+        stx    %o0, [%i4+0]    ! (delay)
 
        cmp     %i3, FFI_TYPE_FLOAT
        be,a,pn %icc, done
@@ -122,13 +124,14 @@ dostruct:
         restore
 .LLFE1:
 
-.ffi_call_V9_end:
-       .size   ffi_call_V9,.ffi_call_V9_end-ffi_call_V9
+.ffi_call_v9_end:
+       .size   ffi_call_v9,.ffi_call_v9_end-ffi_call_v9
 
 
-#define        STACKFRAME       240    /* 16*8 register window +
+#undef STACKFRAME
+#define        STACKFRAME       336    /* 16*8 register window +
                                   6*8 args backing store +
-                                  8*8 locals */
+                                  20*8 locals */
 #define        FP              %fp+STACK_BIAS
 
 /* ffi_closure_v9(...)
@@ -153,55 +156,74 @@ ffi_closure_v9:
        stx     %i5, [FP+128+40]
 
        ! Store possible floating point argument registers too.
-       std     %f0, [FP-48]
-       std     %f2, [FP-40]
-       std     %f4, [FP-32]
-       std     %f6, [FP-24]
-       std     %f8, [FP-16]
-       std     %f10, [FP-8]
+       std     %f0,  [FP-128]
+       std     %f2,  [FP-120]
+       std     %f4,  [FP-112]
+       std     %f6,  [FP-104]
+       std     %f8,  [FP-96]
+       std     %f10, [FP-88]
+       std     %f12, [FP-80]
+       std     %f14, [FP-72]
+       std     %f16, [FP-64]
+       std     %f18, [FP-56]
+       std     %f20, [FP-48]
+       std     %f22, [FP-40]
+       std     %f24, [FP-32]
+       std     %f26, [FP-24]
+       std     %f28, [FP-16]
+       std     %f30, [FP-8]
 
        ! Call ffi_closure_sparc_inner to do the bulk of the work.
        mov     %g1, %o0
-       add     %fp, STACK_BIAS-64, %o1
+       add     %fp, STACK_BIAS-160, %o1
        add     %fp, STACK_BIAS+128, %o2
-       call    ffi_closure_sparc_inner
-        add    %fp, STACK_BIAS-48, %o3
+       call    ffi_closure_sparc_inner_v9
+        add    %fp, STACK_BIAS-128, %o3
 
        ! Load up the return value in the proper type.
+       ! See ffi_prep_cif_machdep for the list of cases.
        cmp     %o0, FFI_TYPE_VOID
        be,pn   %icc, done1
 
+       cmp     %o0, FFI_TYPE_INT
+       be,pn   %icc, integer
+
        cmp     %o0, FFI_TYPE_FLOAT
        be,a,pn %icc, done1
-        ld     [FP-64], %f0
+        ld     [FP-160], %f0
 
        cmp     %o0, FFI_TYPE_DOUBLE
        be,a,pn %icc, done1
-        ldd    [FP-64], %f0
+        ldd    [FP-160], %f0
 
+#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
        cmp     %o0, FFI_TYPE_LONGDOUBLE
        be,a,pn %icc, longdouble1
-        ldd    [FP-64], %f0
+        ldd    [FP-160], %f0
+#endif
 
-       cmp     %o0, FFI_TYPE_STRUCT
-       be,pn   %icc, struct1
+       ! FFI_TYPE_STRUCT
+       ldx     [FP-152], %i1
+       ldx     [FP-144], %i2
+       ldx     [FP-136], %i3
+       ldd     [FP-160], %f0
+       ldd     [FP-152], %f2
+       ldd     [FP-144], %f4
+       ldd     [FP-136], %f6
 
-       ! FFI_TYPE_UINT64 | FFI_TYPE_SINT64 | FFI_TYPE_POINTER
-       ldx     [FP-64], %i0
+integer:
+       ldx     [FP-160], %i0
 
 done1:
        ret
         restore
 
-struct1:
-       ldx [FP-56], %i2
-       ret
-        restore
-
+#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
 longdouble1:
-       ldd     [FP-56], %f2
+       ldd     [FP-152], %f2
        ret
         restore
+#endif
 .LLFE2:
 
 .ffi_closure_v9_end:
@@ -279,3 +301,7 @@ longdouble1:
        .align 8
 .LLEFDE2:
 #endif
+
+#ifdef __linux__
+       .section        .note.GNU-stack,"",@progbits
+#endif