~ubuntu-branches/ubuntu/lucid/gauche-c-wrapper/lucid

« back to all changes in this revision

Viewing changes to libffi/src/frv/eabi.S

  • Committer: Bazaar Package Importer
  • Author(s): NIIBE Yutaka
  • Date: 2008-04-07 09:15:03 UTC
  • Revision ID: james.westby@ubuntu.com-20080407091503-wu0h414koe95kj4i
Tags: upstream-0.5.2
ImportĀ upstreamĀ versionĀ 0.5.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* -----------------------------------------------------------------------
 
2
   eabi.S - Copyright (c) 2004  Anthony Green
 
3
   
 
4
   FR-V Assembly glue.
 
5
 
 
6
   $Id: sysv.S,v 1.1.1.1 1998/11/29 16:48:16 green Exp $
 
7
 
 
8
   Permission is hereby granted, free of charge, to any person obtaining
 
9
   a copy of this software and associated documentation files (the
 
10
   ``Software''), to deal in the Software without restriction, including
 
11
   without limitation the rights to use, copy, modify, merge, publish,
 
12
   distribute, sublicense, and/or sell copies of the Software, and to
 
13
   permit persons to whom the Software is furnished to do so, subject to
 
14
   the following conditions:
 
15
 
 
16
   The above copyright notice and this permission notice shall be included
 
17
   in all copies or substantial portions of the Software.
 
18
 
 
19
   THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS
 
20
   OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 
21
   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
 
22
   IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR
 
23
   OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
 
24
   ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
 
25
   OTHER DEALINGS IN THE SOFTWARE.
 
26
   ----------------------------------------------------------------------- */
 
27
 
 
28
#define LIBFFI_ASM      
 
29
#include <fficonfig.h>
 
30
#include <ffi.h>
 
31
 
 
32
        .globl ffi_prep_args_EABI
 
33
 
 
34
        .text
 
35
        .p2align 4
 
36
        .globl ffi_call_EABI
 
37
        .type ffi_call_EABI, @function
 
38
 
 
39
        # gr8 :   ffi_prep_args
 
40
        # gr9 :   &ecif
 
41
        # gr10:   cif->bytes
 
42
        # gr11:   fig->flags
 
43
        # gr12:   ecif.rvalue
 
44
        # gr13:   fn
 
45
        
 
46
ffi_call_EABI:  
 
47
        addi    sp, #-80, sp
 
48
        sti     fp, @(sp, #24)
 
49
        addi    sp, #24, fp
 
50
        movsg   lr, gr5
 
51
 
 
52
        /* Make room for the new arguments.  */
 
53
        /* subi sp, fp, gr10 */
 
54
        
 
55
        /* Store return address and incoming args on stack.  */
 
56
        sti     gr5, @(fp, #8)
 
57
        sti     gr8, @(fp, #-4)
 
58
        sti     gr9, @(fp, #-8)
 
59
        sti     gr10, @(fp, #-12)
 
60
        sti     gr11, @(fp, #-16)
 
61
        sti     gr12, @(fp, #-20)
 
62
        sti     gr13, @(fp, #-24)
 
63
 
 
64
        sub     sp, gr10, sp
 
65
        
 
66
        /* Call ffi_prep_args.  */
 
67
        ldi     @(fp, #-4), gr4
 
68
        addi    sp, #0, gr8
 
69
        ldi     @(fp, #-8), gr9
 
70
#ifdef __FRV_FDPIC__
 
71
        ldd     @(gr4, gr0), gr14
 
72
        calll   @(gr14, gr0)
 
73
#else
 
74
        calll   @(gr4, gr0)
 
75
#endif  
 
76
 
 
77
        /* ffi_prep_args returns the new stack pointer.  */
 
78
        mov     gr8, gr4
 
79
                
 
80
        ldi     @(sp, #0), gr8
 
81
        ldi     @(sp, #4), gr9
 
82
        ldi     @(sp, #8), gr10
 
83
        ldi     @(sp, #12), gr11
 
84
        ldi     @(sp, #16), gr12
 
85
        ldi     @(sp, #20), gr13
 
86
 
 
87
        /* Always copy the return value pointer into the hidden
 
88
           parameter register.  This is only strictly necessary
 
89
           when we're returning an aggregate type, but it doesn't
 
90
           hurt to do this all the time, and it saves a branch.  */
 
91
        ldi     @(fp, #-20), gr3
 
92
 
 
93
        /* Use the ffi_prep_args return value for the new sp.  */
 
94
        mov     gr4, sp
 
95
        
 
96
        /* Call the target function.  */
 
97
        ldi     @(fp, -24), gr4
 
98
#ifdef __FRV_FDPIC__
 
99
        ldd     @(gr4, gr0), gr14
 
100
        calll   @(gr14, gr0)
 
101
#else
 
102
        calll   @(gr4, gr0)
 
103
#endif  
 
104
 
 
105
        /* Store the result. */
 
106
        ldi     @(fp, #-16), gr10  /* fig->flags */
 
107
        ldi     @(fp, #-20), gr4   /* ecif.rvalue */
 
108
 
 
109
        /* Is the return value stored in two registers?  */
 
110
        cmpi    gr10, #8, icc0
 
111
        bne     icc0, 0, .L2
 
112
        /*   Yes, save them.  */
 
113
        sti     gr8, @(gr4, #0)
 
114
        sti     gr9, @(gr4, #4)
 
115
        bra     .L3
 
116
.L2:
 
117
        /* Is the return value a structure?  */
 
118
        cmpi    gr10, #-1, icc0
 
119
        beq     icc0, 0, .L3
 
120
        /*   No, save a 4 byte return value.  */
 
121
        sti     gr8, @(gr4, #0)
 
122
.L3:    
 
123
 
 
124
        /* Restore the stack, and return.  */
 
125
        ldi     @(fp, 8), gr5
 
126
        ld      @(fp, gr0), fp
 
127
        addi    sp,#80,sp
 
128
        jmpl    @(gr5,gr0)
 
129
        .size ffi_call_EABI, .-ffi_call_EABI
 
130