Mercurial > pub > dyncall > dyncall
annotate dyncall/dyncall_callvm_ppc64.c @ 533:71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
* integration of aggregate-by-value (struct, union) support patch for x64 (win and sysv)
* windows/x64 asm additions to specify how stack unwinds (help for debuggers, exception handling, etc.)
* see Changelog for details
- new calling convention modes for thiscalls (platform agnostic, was specific before)
* new signature character for platform agnostic thiscalls ('*' / DC_SIGCHAR_CC_THISCALL)
- dcCallF(), dcVCallF(), dcArgF() and dcVArgF():
* added support for aggregates-by-value (wasn't part of patch)
* change that those functions don't implicitly call dcReset() anymore, which was unflexible (breaking change)
- added macros to feature test implementation for aggregate-by-value and syscall support
- changed libdyncall_s.lib and libdyncallback_s.lib order in callback test makefiles, as some toolchains are picky about order
- doc:
* man page updates to describe aggregate interface
* manual overview changes to highlight platforms with aggregate-by-value support
- test/plain: replaced tests w/ old/stale sctruct interface with new aggregate one
author | Tassilo Philipp |
---|---|
date | Thu, 21 Apr 2022 13:35:47 +0200 |
parents | ddfb9577a00e |
children |
rev | line source |
---|---|
0 | 1 /* |
2 | |
3 Package: dyncall | |
4 Library: dyncall | |
5 File: dyncall/dyncall_callvm_ppc64.c | |
466
ddfb9577a00e
introduced platform-native thiscall mode (DC_CALL_C_DEFAULT_THIS), as needed
Tassilo Philipp
parents:
366
diff
changeset
|
6 Description: |
0 | 7 License: |
8 | |
9 Copyright (c) 2014-2015 Masanori Mitsugi <mitsugi@linux.vnet.ibm.com> | |
366
ad5f9803f52f
- removal of some unnecessary headers that only contained internally used forward declarations, so no need to have them
Tassilo Philipp
parents:
84
diff
changeset
|
10 2020 Tassilo Philipp <tphilipp@potion-studios.com> |
466
ddfb9577a00e
introduced platform-native thiscall mode (DC_CALL_C_DEFAULT_THIS), as needed
Tassilo Philipp
parents:
366
diff
changeset
|
11 |
0 | 12 |
13 Permission to use, copy, modify, and distribute this software for any | |
14 purpose with or without fee is hereby granted, provided that the above | |
15 copyright notice and this permission notice appear in all copies. | |
16 | |
17 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | |
18 WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | |
19 MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | |
20 ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | |
21 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | |
22 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | |
23 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | |
24 | |
25 */ | |
26 | |
27 | |
28 /* | |
29 | |
30 dyncall callvm for ppc64 architectures | |
31 | |
32 SUPPORTED CALLING CONVENTIONS | |
33 ppc64/linux | |
7 | 34 ppc64/syscall |
0 | 35 |
36 REVISION | |
7 | 37 2015/07/08 added syscall |
0 | 38 2014/08/07 initial support |
39 | |
40 */ | |
41 | |
42 #include "dyncall_callvm_ppc64.h" | |
43 #include "dyncall_alloc.h" | |
44 #include "dyncall_macros.h" | |
45 #include "dyncall_types.h" | |
46 | |
366
ad5f9803f52f
- removal of some unnecessary headers that only contained internally used forward declarations, so no need to have them
Tassilo Philipp
parents:
84
diff
changeset
|
47 |
466
ddfb9577a00e
introduced platform-native thiscall mode (DC_CALL_C_DEFAULT_THIS), as needed
Tassilo Philipp
parents:
366
diff
changeset
|
48 /* |
366
ad5f9803f52f
- removal of some unnecessary headers that only contained internally used forward declarations, so no need to have them
Tassilo Philipp
parents:
84
diff
changeset
|
49 ** PowerPC 64-bit calling convention call |
ad5f9803f52f
- removal of some unnecessary headers that only contained internally used forward declarations, so no need to have them
Tassilo Philipp
parents:
84
diff
changeset
|
50 ** |
ad5f9803f52f
- removal of some unnecessary headers that only contained internally used forward declarations, so no need to have them
Tassilo Philipp
parents:
84
diff
changeset
|
51 ** - hybrid return-type call (bool ... pointer) |
ad5f9803f52f
- removal of some unnecessary headers that only contained internally used forward declarations, so no need to have them
Tassilo Philipp
parents:
84
diff
changeset
|
52 ** |
ad5f9803f52f
- removal of some unnecessary headers that only contained internally used forward declarations, so no need to have them
Tassilo Philipp
parents:
84
diff
changeset
|
53 */ |
ad5f9803f52f
- removal of some unnecessary headers that only contained internally used forward declarations, so no need to have them
Tassilo Philipp
parents:
84
diff
changeset
|
54 |
ad5f9803f52f
- removal of some unnecessary headers that only contained internally used forward declarations, so no need to have them
Tassilo Philipp
parents:
84
diff
changeset
|
55 void dcCall_ppc64(DCpointer target, DCRegData_ppc64* ppc64data, DCsize stksize, DCpointer stkdata); |
ad5f9803f52f
- removal of some unnecessary headers that only contained internally used forward declarations, so no need to have them
Tassilo Philipp
parents:
84
diff
changeset
|
56 |
ad5f9803f52f
- removal of some unnecessary headers that only contained internally used forward declarations, so no need to have them
Tassilo Philipp
parents:
84
diff
changeset
|
57 /* syscall */ |
ad5f9803f52f
- removal of some unnecessary headers that only contained internally used forward declarations, so no need to have them
Tassilo Philipp
parents:
84
diff
changeset
|
58 void dcCall_ppc64_syscall(DCpointer target, DCRegData_ppc64* ppc64data, DCsize stksize, DCpointer stkdata); |
ad5f9803f52f
- removal of some unnecessary headers that only contained internally used forward declarations, so no need to have them
Tassilo Philipp
parents:
84
diff
changeset
|
59 |
ad5f9803f52f
- removal of some unnecessary headers that only contained internally used forward declarations, so no need to have them
Tassilo Philipp
parents:
84
diff
changeset
|
60 |
ad5f9803f52f
- removal of some unnecessary headers that only contained internally used forward declarations, so no need to have them
Tassilo Philipp
parents:
84
diff
changeset
|
61 |
0 | 62 /* Support for Power PC 64-bit */ |
63 | |
64 static void dc_callvm_free_ppc64(DCCallVM* in_self) | |
65 { | |
66 dcFreeMem(in_self); | |
67 } | |
68 | |
69 static void dc_callvm_reset_ppc64(DCCallVM* in_self) | |
70 { | |
71 DCCallVM_ppc64* self = (DCCallVM_ppc64*)in_self; | |
72 dcVecReset(&self->mVecHead); | |
73 self->mIntRegs = 0; | |
74 self->mFloatRegs = 0; | |
75 } | |
76 | |
77 /* fillup integer register file AND push on stack (for ellipsis) */ | |
78 | |
79 static void dc_callvm_argInt_ppc64(DCCallVM* in_self, DCint i) | |
80 { | |
81 /* promote to longlong */ | |
82 dcArgLongLong(in_self, (DClonglong)i); | |
83 } | |
84 | |
85 /** floating-point **/ | |
86 | |
87 /* double*/ | |
88 | |
89 static void dc_callvm_argDouble_ppc64(DCCallVM* in_self, DCdouble d) | |
90 { | |
91 DCCallVM_ppc64* self = (DCCallVM_ppc64*)in_self; | |
92 | |
83
54930a037e8a
- PPC64 single-precision float fixes for more than 13 float args (thanks Masanori!)
cslag
parents:
7
diff
changeset
|
93 if (self->mFloatRegs < 13) { |
0 | 94 self->mRegData.mFloatData[self->mFloatRegs++] = d; |
95 if (self->mIntRegs < 8) { | |
96 self->mRegData.mIntData[self->mIntRegs++] = *( (DClonglong*) &d ); | |
97 #if DC__ABI_PPC64_ELF_V == 2 | |
98 return; | |
99 #endif | |
100 } | |
83
54930a037e8a
- PPC64 single-precision float fixes for more than 13 float args (thanks Masanori!)
cslag
parents:
7
diff
changeset
|
101 } |
0 | 102 |
103 #if DC__ABI_PPC64_ELF_V == 2 | |
104 if (dcVecSize(&self->mVecHead) == 0) { | |
105 dcVecSkip(&self->mVecHead,sizeof(DClonglong)*8); | |
106 } | |
107 #endif | |
108 | |
109 /* push on stack */ | |
110 dcVecAppend(&self->mVecHead,(DCpointer) &d,sizeof(DCdouble)); | |
111 } | |
112 | |
113 #if DC__ABI_PPC64_ELF_V == 2 | |
114 static void dc_callvm_argDouble_ppc64_ellipsis(DCCallVM* in_self, DCdouble d) | |
115 { | |
116 DCCallVM_ppc64* self = (DCCallVM_ppc64*)in_self; | |
117 | |
83
54930a037e8a
- PPC64 single-precision float fixes for more than 13 float args (thanks Masanori!)
cslag
parents:
7
diff
changeset
|
118 if (dcVecSize(&self->mVecHead) == 0) |
0 | 119 dcVecSkip(&self->mVecHead,(sizeof(DClonglong))*(self->mIntRegs)); |
120 | |
83
54930a037e8a
- PPC64 single-precision float fixes for more than 13 float args (thanks Masanori!)
cslag
parents:
7
diff
changeset
|
121 if (self->mFloatRegs < 13) { |
0 | 122 self->mRegData.mFloatData[self->mFloatRegs++] = d; |
123 if (self->mIntRegs < 8) { | |
124 self->mRegData.mIntData[self->mIntRegs++] = *( (DClonglong*) &d ); | |
125 } | |
126 } | |
127 | |
128 /* push on stack */ | |
129 dcVecAppend(&self->mVecHead,(DCpointer) &d,sizeof(DCdouble)); | |
130 } | |
131 #endif | |
132 | |
133 | |
134 /* Floating-point */ | |
83
54930a037e8a
- PPC64 single-precision float fixes for more than 13 float args (thanks Masanori!)
cslag
parents:
7
diff
changeset
|
135 |
0 | 136 static void dc_callvm_argFloat_ppc64(DCCallVM* in_self, DCfloat f) |
137 { | |
83
54930a037e8a
- PPC64 single-precision float fixes for more than 13 float args (thanks Masanori!)
cslag
parents:
7
diff
changeset
|
138 DCCallVM_ppc64* self = (DCCallVM_ppc64*)in_self; |
54930a037e8a
- PPC64 single-precision float fixes for more than 13 float args (thanks Masanori!)
cslag
parents:
7
diff
changeset
|
139 |
54930a037e8a
- PPC64 single-precision float fixes for more than 13 float args (thanks Masanori!)
cslag
parents:
7
diff
changeset
|
140 DCdouble d; |
54930a037e8a
- PPC64 single-precision float fixes for more than 13 float args (thanks Masanori!)
cslag
parents:
7
diff
changeset
|
141 #if defined(DC__Endian_BIG) |
54930a037e8a
- PPC64 single-precision float fixes for more than 13 float args (thanks Masanori!)
cslag
parents:
7
diff
changeset
|
142 struct { DCfloat f_pad; DCfloat f; } sf; |
54930a037e8a
- PPC64 single-precision float fixes for more than 13 float args (thanks Masanori!)
cslag
parents:
7
diff
changeset
|
143 #else /* Endian_LITTLE */ |
54930a037e8a
- PPC64 single-precision float fixes for more than 13 float args (thanks Masanori!)
cslag
parents:
7
diff
changeset
|
144 struct { DCfloat f; DCfloat f_pad; } sf; |
54930a037e8a
- PPC64 single-precision float fixes for more than 13 float args (thanks Masanori!)
cslag
parents:
7
diff
changeset
|
145 #endif |
54930a037e8a
- PPC64 single-precision float fixes for more than 13 float args (thanks Masanori!)
cslag
parents:
7
diff
changeset
|
146 |
54930a037e8a
- PPC64 single-precision float fixes for more than 13 float args (thanks Masanori!)
cslag
parents:
7
diff
changeset
|
147 if (self->mFloatRegs < 13) { |
54930a037e8a
- PPC64 single-precision float fixes for more than 13 float args (thanks Masanori!)
cslag
parents:
7
diff
changeset
|
148 d = (DCdouble)f; |
54930a037e8a
- PPC64 single-precision float fixes for more than 13 float args (thanks Masanori!)
cslag
parents:
7
diff
changeset
|
149 self->mRegData.mFloatData[self->mFloatRegs++] = d; |
54930a037e8a
- PPC64 single-precision float fixes for more than 13 float args (thanks Masanori!)
cslag
parents:
7
diff
changeset
|
150 if (self->mIntRegs < 8) { |
54930a037e8a
- PPC64 single-precision float fixes for more than 13 float args (thanks Masanori!)
cslag
parents:
7
diff
changeset
|
151 self->mRegData.mIntData[self->mIntRegs++] = *( (DClonglong*) &d ); |
54930a037e8a
- PPC64 single-precision float fixes for more than 13 float args (thanks Masanori!)
cslag
parents:
7
diff
changeset
|
152 #if DC__ABI_PPC64_ELF_V == 2 |
54930a037e8a
- PPC64 single-precision float fixes for more than 13 float args (thanks Masanori!)
cslag
parents:
7
diff
changeset
|
153 return; |
54930a037e8a
- PPC64 single-precision float fixes for more than 13 float args (thanks Masanori!)
cslag
parents:
7
diff
changeset
|
154 #endif |
54930a037e8a
- PPC64 single-precision float fixes for more than 13 float args (thanks Masanori!)
cslag
parents:
7
diff
changeset
|
155 } |
54930a037e8a
- PPC64 single-precision float fixes for more than 13 float args (thanks Masanori!)
cslag
parents:
7
diff
changeset
|
156 } |
54930a037e8a
- PPC64 single-precision float fixes for more than 13 float args (thanks Masanori!)
cslag
parents:
7
diff
changeset
|
157 |
54930a037e8a
- PPC64 single-precision float fixes for more than 13 float args (thanks Masanori!)
cslag
parents:
7
diff
changeset
|
158 #if DC__ABI_PPC64_ELF_V == 2 |
54930a037e8a
- PPC64 single-precision float fixes for more than 13 float args (thanks Masanori!)
cslag
parents:
7
diff
changeset
|
159 if (dcVecSize(&self->mVecHead) == 0) { |
54930a037e8a
- PPC64 single-precision float fixes for more than 13 float args (thanks Masanori!)
cslag
parents:
7
diff
changeset
|
160 dcVecSkip(&self->mVecHead,sizeof(DClonglong)*8); |
54930a037e8a
- PPC64 single-precision float fixes for more than 13 float args (thanks Masanori!)
cslag
parents:
7
diff
changeset
|
161 } |
54930a037e8a
- PPC64 single-precision float fixes for more than 13 float args (thanks Masanori!)
cslag
parents:
7
diff
changeset
|
162 #endif |
54930a037e8a
- PPC64 single-precision float fixes for more than 13 float args (thanks Masanori!)
cslag
parents:
7
diff
changeset
|
163 |
54930a037e8a
- PPC64 single-precision float fixes for more than 13 float args (thanks Masanori!)
cslag
parents:
7
diff
changeset
|
164 /* push on stack */ |
54930a037e8a
- PPC64 single-precision float fixes for more than 13 float args (thanks Masanori!)
cslag
parents:
7
diff
changeset
|
165 sf.f = f; |
54930a037e8a
- PPC64 single-precision float fixes for more than 13 float args (thanks Masanori!)
cslag
parents:
7
diff
changeset
|
166 dcVecAppend(&self->mVecHead,(DCpointer) &sf,sizeof(DCdouble)); |
54930a037e8a
- PPC64 single-precision float fixes for more than 13 float args (thanks Masanori!)
cslag
parents:
7
diff
changeset
|
167 } |
54930a037e8a
- PPC64 single-precision float fixes for more than 13 float args (thanks Masanori!)
cslag
parents:
7
diff
changeset
|
168 |
54930a037e8a
- PPC64 single-precision float fixes for more than 13 float args (thanks Masanori!)
cslag
parents:
7
diff
changeset
|
169 #if DC__ABI_PPC64_ELF_V == 2 |
54930a037e8a
- PPC64 single-precision float fixes for more than 13 float args (thanks Masanori!)
cslag
parents:
7
diff
changeset
|
170 static void dc_callvm_argFloat_ppc64_ellipsis(DCCallVM* in_self, DCfloat f) |
54930a037e8a
- PPC64 single-precision float fixes for more than 13 float args (thanks Masanori!)
cslag
parents:
7
diff
changeset
|
171 { |
0 | 172 /* promote to double */ |
173 dcArgDouble(in_self, (DCdouble) f ); | |
174 } | |
83
54930a037e8a
- PPC64 single-precision float fixes for more than 13 float args (thanks Masanori!)
cslag
parents:
7
diff
changeset
|
175 #endif |
54930a037e8a
- PPC64 single-precision float fixes for more than 13 float args (thanks Masanori!)
cslag
parents:
7
diff
changeset
|
176 |
0 | 177 |
178 /* long long integer */ | |
179 | |
180 static void dc_callvm_argLongLong_ppc64(DCCallVM* in_self, DClonglong L) | |
181 { | |
182 DCCallVM_ppc64* self = (DCCallVM_ppc64*)in_self; | |
83
54930a037e8a
- PPC64 single-precision float fixes for more than 13 float args (thanks Masanori!)
cslag
parents:
7
diff
changeset
|
183 |
0 | 184 /* fillup integer register file */ |
185 if (self->mIntRegs < 8) { | |
186 self->mRegData.mIntData[self->mIntRegs++] = L; | |
187 #if DC__ABI_PPC64_ELF_V == 2 | |
188 return; | |
189 #endif | |
190 } | |
191 | |
192 #if DC__ABI_PPC64_ELF_V == 2 | |
193 if (dcVecSize(&self->mVecHead) == 0) { | |
194 dcVecSkip(&self->mVecHead,sizeof(DClonglong)*8); | |
195 } | |
196 #endif | |
197 | |
198 /* push on stack */ | |
199 dcVecAppend(&self->mVecHead,&L,sizeof(DClonglong)); | |
200 } | |
201 | |
202 #if DC__ABI_PPC64_ELF_V == 2 | |
203 static void dc_callvm_argLongLong_ppc64_ellipsis(DCCallVM* in_self, DClonglong L) | |
204 { | |
205 DCCallVM_ppc64* self = (DCCallVM_ppc64*)in_self; | |
206 | |
466
ddfb9577a00e
introduced platform-native thiscall mode (DC_CALL_C_DEFAULT_THIS), as needed
Tassilo Philipp
parents:
366
diff
changeset
|
207 if (dcVecSize(&self->mVecHead) == 0) |
0 | 208 dcVecSkip(&self->mVecHead,(sizeof(DClonglong))*(self->mIntRegs)); |
209 | |
466
ddfb9577a00e
introduced platform-native thiscall mode (DC_CALL_C_DEFAULT_THIS), as needed
Tassilo Philipp
parents:
366
diff
changeset
|
210 if (self->mIntRegs < 8) |
0 | 211 self->mRegData.mIntData[self->mIntRegs++] = L; |
212 | |
213 /* push on stack */ | |
214 dcVecAppend(&self->mVecHead,&L,sizeof(DClonglong)); | |
215 } | |
216 #endif | |
217 | |
218 | |
219 static void dc_callvm_argBool_ppc64(DCCallVM* in_self, DCbool x) | |
220 { | |
221 /* promote to longlong */ | |
222 dcArgLongLong(in_self, (DClonglong) x ); | |
223 } | |
224 | |
225 | |
226 static void dc_callvm_argChar_ppc64(DCCallVM* in_self, DCchar ch) | |
227 { | |
228 /* promote to longlong */ | |
229 dcArgLongLong(in_self, (DClonglong) ch ); | |
230 } | |
231 | |
232 | |
233 static void dc_callvm_argShort_ppc64(DCCallVM* in_self, DCshort s) | |
234 { | |
235 /* promote to longlong */ | |
236 dcArgLongLong(in_self, (DClonglong) s ); | |
237 } | |
238 | |
239 | |
240 static void dc_callvm_argLong_ppc64(DCCallVM* in_self, DClong l) | |
241 { | |
242 /* promote to longlong */ | |
243 dcArgLongLong(in_self, (DClonglong) l ); | |
244 } | |
245 | |
246 | |
247 static void dc_callvm_argPointer_ppc64(DCCallVM* in_self, DCpointer p) | |
248 { | |
249 /* promote to longlong */ | |
250 dcArgLongLong(in_self, *(DClonglong *) &p ); | |
251 } | |
252 | |
253 | |
254 void dc_callvm_call_ppc64(DCCallVM* in_self, DCpointer target) | |
255 { | |
256 DCCallVM_ppc64* self = (DCCallVM_ppc64*) in_self; | |
257 int size = dcVecSize(&self->mVecHead); | |
258 | |
259 if (size < 64) { | |
260 dcVecSkip(&self->mVecHead, 64-size); | |
261 } | |
533
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
466
diff
changeset
|
262 |
0 | 263 dcCall_ppc64( target, &self->mRegData, dcVecSize(&self->mVecHead) , dcVecData(&self->mVecHead)); |
264 } | |
265 | |
7 | 266 void dc_callvm_call_ppc64_syscall(DCCallVM* in_self, DCpointer target) |
267 { | |
268 DCCallVM_ppc64* self = (DCCallVM_ppc64*) in_self; | |
269 dcCall_ppc64_syscall( target, &self->mRegData, dcVecSize(&self->mVecHead) , dcVecData(&self->mVecHead)); | |
270 } | |
271 | |
0 | 272 void dc_callvm_mode_ppc64(DCCallVM* in_self, DCint mode); |
273 | |
274 DCCallVM_vt gVT_ppc64 = | |
275 { | |
276 &dc_callvm_free_ppc64 | |
277 , &dc_callvm_reset_ppc64 | |
278 , &dc_callvm_mode_ppc64 | |
279 , &dc_callvm_argBool_ppc64 | |
280 , &dc_callvm_argChar_ppc64 | |
281 , &dc_callvm_argShort_ppc64 | |
282 , &dc_callvm_argInt_ppc64 | |
283 , &dc_callvm_argLong_ppc64 | |
284 , &dc_callvm_argLongLong_ppc64 | |
285 , &dc_callvm_argFloat_ppc64 | |
286 , &dc_callvm_argDouble_ppc64 | |
287 , &dc_callvm_argPointer_ppc64 | |
533
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
466
diff
changeset
|
288 , NULL /* argAggr */ |
0 | 289 , (DCvoidvmfunc*) &dc_callvm_call_ppc64 |
290 , (DCboolvmfunc*) &dc_callvm_call_ppc64 | |
291 , (DCcharvmfunc*) &dc_callvm_call_ppc64 | |
292 , (DCshortvmfunc*) &dc_callvm_call_ppc64 | |
293 , (DCintvmfunc*) &dc_callvm_call_ppc64 | |
294 , (DClongvmfunc*) &dc_callvm_call_ppc64 | |
295 , (DClonglongvmfunc*) &dc_callvm_call_ppc64 | |
296 , (DCfloatvmfunc*) &dc_callvm_call_ppc64 | |
297 , (DCdoublevmfunc*) &dc_callvm_call_ppc64 | |
298 , (DCpointervmfunc*) &dc_callvm_call_ppc64 | |
533
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
466
diff
changeset
|
299 , NULL /* callAggr */ |
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
466
diff
changeset
|
300 , NULL /* beginAggr */ |
0 | 301 }; |
302 | |
303 #if DC__ABI_PPC64_ELF_V == 2 | |
304 DCCallVM_vt gVT_ppc64_ellipsis = | |
305 { | |
306 &dc_callvm_free_ppc64 | |
307 , &dc_callvm_reset_ppc64 | |
308 , &dc_callvm_mode_ppc64 | |
309 , &dc_callvm_argBool_ppc64 | |
310 , &dc_callvm_argChar_ppc64 | |
311 , &dc_callvm_argShort_ppc64 | |
312 , &dc_callvm_argInt_ppc64 | |
313 , &dc_callvm_argLong_ppc64 | |
314 , &dc_callvm_argLongLong_ppc64_ellipsis | |
83
54930a037e8a
- PPC64 single-precision float fixes for more than 13 float args (thanks Masanori!)
cslag
parents:
7
diff
changeset
|
315 , &dc_callvm_argFloat_ppc64_ellipsis |
0 | 316 , &dc_callvm_argDouble_ppc64_ellipsis |
317 , &dc_callvm_argPointer_ppc64 | |
533
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
466
diff
changeset
|
318 , NULL /* argAggr */ |
0 | 319 , (DCvoidvmfunc*) &dc_callvm_call_ppc64 |
320 , (DCboolvmfunc*) &dc_callvm_call_ppc64 | |
321 , (DCcharvmfunc*) &dc_callvm_call_ppc64 | |
322 , (DCshortvmfunc*) &dc_callvm_call_ppc64 | |
323 , (DCintvmfunc*) &dc_callvm_call_ppc64 | |
324 , (DClongvmfunc*) &dc_callvm_call_ppc64 | |
325 , (DClonglongvmfunc*) &dc_callvm_call_ppc64 | |
326 , (DCfloatvmfunc*) &dc_callvm_call_ppc64 | |
327 , (DCdoublevmfunc*) &dc_callvm_call_ppc64 | |
328 , (DCpointervmfunc*) &dc_callvm_call_ppc64 | |
533
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
466
diff
changeset
|
329 , NULL /* callAggr */ |
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
466
diff
changeset
|
330 , NULL /* beginAggr */ |
0 | 331 }; |
332 #endif | |
333 | |
7 | 334 DCCallVM_vt gVT_ppc64_syscall = |
335 { | |
336 &dc_callvm_free_ppc64 | |
337 , &dc_callvm_reset_ppc64 | |
338 , &dc_callvm_mode_ppc64 | |
339 , &dc_callvm_argBool_ppc64 | |
340 , &dc_callvm_argChar_ppc64 | |
341 , &dc_callvm_argShort_ppc64 | |
342 , &dc_callvm_argInt_ppc64 | |
343 , &dc_callvm_argLong_ppc64 | |
344 , &dc_callvm_argLongLong_ppc64 | |
345 , &dc_callvm_argFloat_ppc64 | |
346 , &dc_callvm_argDouble_ppc64 | |
347 , &dc_callvm_argPointer_ppc64 | |
533
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
466
diff
changeset
|
348 , NULL /* argAggr */ |
7 | 349 , (DCvoidvmfunc*) &dc_callvm_call_ppc64_syscall |
350 , (DCboolvmfunc*) &dc_callvm_call_ppc64_syscall | |
351 , (DCcharvmfunc*) &dc_callvm_call_ppc64_syscall | |
352 , (DCshortvmfunc*) &dc_callvm_call_ppc64_syscall | |
353 , (DCintvmfunc*) &dc_callvm_call_ppc64_syscall | |
354 , (DClongvmfunc*) &dc_callvm_call_ppc64_syscall | |
355 , (DClonglongvmfunc*) &dc_callvm_call_ppc64_syscall | |
356 , (DCfloatvmfunc*) &dc_callvm_call_ppc64_syscall | |
357 , (DCdoublevmfunc*) &dc_callvm_call_ppc64_syscall | |
358 , (DCpointervmfunc*) &dc_callvm_call_ppc64_syscall | |
533
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
466
diff
changeset
|
359 , NULL /* callAggr */ |
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
466
diff
changeset
|
360 , NULL /* beginAggr */ |
7 | 361 }; |
362 | |
0 | 363 void dc_callvm_mode_ppc64(DCCallVM* in_self, DCint mode) |
364 { | |
365 DCCallVM_ppc64* self = (DCCallVM_ppc64*) in_self; | |
366 DCCallVM_vt* vt; | |
84 | 367 |
0 | 368 switch(mode) { |
84 | 369 case DC_CALL_C_DEFAULT: |
466
ddfb9577a00e
introduced platform-native thiscall mode (DC_CALL_C_DEFAULT_THIS), as needed
Tassilo Philipp
parents:
366
diff
changeset
|
370 case DC_CALL_C_DEFAULT_THIS: |
ddfb9577a00e
introduced platform-native thiscall mode (DC_CALL_C_DEFAULT_THIS), as needed
Tassilo Philipp
parents:
366
diff
changeset
|
371 case DC_CALL_C_PPC64: |
0 | 372 case DC_CALL_C_ELLIPSIS: |
373 #if DC__ABI_PPC64_ELF_V == 2 | |
374 vt = &gVT_ppc64; | |
375 break; | |
376 case DC_CALL_C_ELLIPSIS_VARARGS: | |
377 vt = &gVT_ppc64_ellipsis; | |
378 break; | |
379 #else | |
380 case DC_CALL_C_ELLIPSIS_VARARGS: | |
381 vt = &gVT_ppc64; | |
382 break; | |
383 #endif | |
384 | |
7 | 385 case DC_CALL_SYS_DEFAULT: |
386 case DC_CALL_SYS_PPC64: | |
387 vt = &gVT_ppc64_syscall; | |
388 break; | |
389 | |
466
ddfb9577a00e
introduced platform-native thiscall mode (DC_CALL_C_DEFAULT_THIS), as needed
Tassilo Philipp
parents:
366
diff
changeset
|
390 default: |
ddfb9577a00e
introduced platform-native thiscall mode (DC_CALL_C_DEFAULT_THIS), as needed
Tassilo Philipp
parents:
366
diff
changeset
|
391 self->mInterface.mError = DC_ERROR_UNSUPPORTED_MODE; |
0 | 392 return; |
393 } | |
466
ddfb9577a00e
introduced platform-native thiscall mode (DC_CALL_C_DEFAULT_THIS), as needed
Tassilo Philipp
parents:
366
diff
changeset
|
394 |
0 | 395 dc_callvm_base_init(&self->mInterface, vt); |
396 } | |
397 | |
84 | 398 /* Public API. */ |
0 | 399 DCCallVM* dcNewCallVM(DCsize size) |
400 { | |
84 | 401 DCCallVM_ppc64* p = (DCCallVM_ppc64*)dcAllocMem(sizeof(DCCallVM_ppc64)+size); |
402 | |
403 dc_callvm_mode_ppc64((DCCallVM*)p, DC_CALL_C_DEFAULT); | |
404 | |
405 dcVecInit(&p->mVecHead, size); | |
406 dc_callvm_reset_ppc64((DCCallVM*)p); | |
407 | |
408 return (DCCallVM*)p; | |
0 | 409 } |
410 |