]>
Commit | Line | Data |
---|---|---|
cc4c8975 KH |
1 | #define LIBFFI_ASM |
2 | #include <powerpc/asm.h> | |
3 | ||
4 | .globl ffi_closure_helper_SYSV | |
5 | ||
6 | ENTRY(ffi_closure_SYSV) | |
7 | stwu %r1,-144(%r1) | |
8 | mflr %r0 | |
9 | stw %r31,140(%r1) | |
10 | stw %r0,148(%r1) | |
11 | ||
12 | # we want to build up an areas for the parameters passed | |
13 | # in registers (both floating point and integer) | |
14 | ||
15 | # so first save gpr 3 to gpr 10 (aligned to 4) | |
16 | stw %r3, 16(%r1) | |
17 | stw %r4, 20(%r1) | |
18 | stw %r5, 24(%r1) | |
19 | stw %r6, 28(%r1) | |
20 | stw %r7, 32(%r1) | |
21 | stw %r8, 36(%r1) | |
22 | stw %r9, 40(%r1) | |
23 | stw %r10,44(%r1) | |
24 | ||
25 | # next save fpr 1 to fpr 8 (aligned to 8) | |
26 | stfd %f1, 48(%r1) | |
27 | stfd %f2, 56(%r1) | |
28 | stfd %f3, 64(%r1) | |
29 | stfd %f4, 72(%r1) | |
30 | stfd %f5, 80(%r1) | |
31 | stfd %f6, 88(%r1) | |
32 | stfd %f7, 96(%r1) | |
33 | stfd %f8, 104(%r1) | |
34 | ||
35 | # set up registers for the routine that actually does the work | |
36 | # get the context pointer from the trampoline | |
37 | mr %r3,%r11 | |
38 | ||
39 | # now load up the pointer to the result storage | |
40 | addi %r4,%r1,112 | |
41 | ||
42 | # now load up the pointer to the saved gpr registers | |
43 | addi %r5,%r1,16 | |
44 | ||
45 | # now load up the pointer to the saved fpr registers */ | |
46 | addi %r6,%r1,48 | |
47 | ||
48 | # now load up the pointer to the outgoing parameter | |
49 | # stack in the previous frame | |
50 | # i.e. the previous frame pointer + 8 | |
51 | addi %r7,%r1,152 | |
52 | ||
53 | # make the call | |
54 | bl JUMPTARGET(ffi_closure_helper_SYSV) | |
55 | ||
56 | # now r3 contains the return type | |
57 | # so use it to look up in a table | |
58 | # so we know how to deal with each type | |
59 | ||
60 | # look up the proper starting point in table | |
61 | # by using return type as offset | |
62 | addi %r5,%r1,112 # get pointer to results area | |
63 | addis %r4,0,.L60@ha # get address of jump table | |
64 | addi %r4,%r4,.L60@l | |
65 | slwi %r3,%r3,2 # now multiply return type by 4 | |
66 | lwzx %r3,%r4,%r3 # get the contents of that table value | |
67 | add %r3,%r3,%r4 # add contents of table to table address | |
68 | mtctr %r3 | |
69 | bctr # jump to it | |
70 | .align 2 | |
71 | .L60: | |
72 | .long .L44-.L60 # FFI_TYPE_VOID | |
73 | .long .L50-.L60 # FFI_TYPE_INT | |
74 | .long .L47-.L60 # FFI_TYPE_FLOAT | |
75 | .long .L46-.L60 # FFI_TYPE_DOUBLE | |
76 | .long .L46-.L60 # FFI_TYPE_LONGDOUBLE | |
77 | .long .L56-.L60 # FFI_TYPE_UINT8 | |
78 | .long .L55-.L60 # FFI_TYPE_SINT8 | |
79 | .long .L58-.L60 # FFI_TYPE_UINT16 | |
80 | .long .L57-.L60 # FFI_TYPE_SINT16 | |
81 | .long .L50-.L60 # FFI_TYPE_UINT32 | |
82 | .long .L50-.L60 # FFI_TYPE_SINT32 | |
83 | .long .L48-.L60 # FFI_TYPE_UINT64 | |
84 | .long .L48-.L60 # FFI_TYPE_SINT64 | |
85 | .long .L44-.L60 # FFI_TYPE_STRUCT | |
86 | .long .L50-.L60 # FFI_TYPE_POINTER | |
87 | ||
88 | ||
89 | # case double | |
90 | .L46: | |
91 | lfd %f1,0(%r5) | |
92 | b .L44 | |
93 | ||
94 | # case float | |
95 | .L47: | |
96 | lfs %f1,0(%r5) | |
97 | b .L44 | |
98 | ||
99 | # case long long | |
100 | .L48: | |
101 | lwz %r3,0(%r5) | |
102 | lwz %r4,4(%r5) | |
103 | b .L44 | |
104 | ||
105 | # case default / int32 / pointer | |
106 | .L50: | |
107 | lwz %r3,0(%r5) | |
108 | b .L44 | |
109 | ||
110 | # case signed int8 | |
111 | .L55: | |
112 | addi %r5,%r5,3 | |
113 | lbz %r3,0(%r5) | |
114 | extsb %r3,%r3 | |
115 | b .L44 | |
116 | ||
117 | # case unsigned int8 | |
118 | .L56: | |
119 | addi %r5,%r5,3 | |
120 | lbz %r3,0(%r5) | |
121 | b .L44 | |
122 | ||
123 | # case signed int16 | |
124 | .L57: | |
125 | addi %r5,%r5,2 | |
126 | lhz %r3,0(%r5) | |
127 | extsh %r3,%r3 | |
128 | b .L44 | |
129 | ||
130 | #case unsigned int16 | |
131 | .L58: | |
132 | addi %r5,%r5,2 | |
133 | lhz %r3,0(%r5) | |
134 | ||
135 | # case void / done | |
136 | .L44: | |
137 | ||
138 | lwz %r11,0(%r1) | |
139 | lwz %r0,4(%r11) | |
140 | mtlr %r0 | |
141 | lwz %r31,-4(%r11) | |
142 | mr %r1,%r11 | |
143 | blr | |
144 | END(ffi_closure_SYSV) | |
145 | ||
146 | ||
147 | ||
148 |