- Removed unused HandleEvent method.
[AROS.git] / arch / m68k-all / include / gencall.c
blob9ef70f5b39f555166335fc66777b9e37781ff172
1 /*
2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
3 $Id$
4 */
5 /* This program generates the libcall.h macroset for gcc-4.5.1 m68k-elf
7 * WARNING: The header generated by this program is designed
8 * to work with GCC 4.5.1 and GCC 4.6.1 m68k-elf ONLY.
10 * If it breaks, you get to keep both pieces.
13 #include <stdlib.h>
14 #include <stdio.h>
15 #include <string.h>
17 #define GENCALL_MAX (13 + 1) /* Max number of arguments */
19 /* NOTE: For all 'call' macros, ie AROS_LC5(), the
20 * 'bt' parameter is frequently garbled by
21 * callers who use '#define's like:
23 * #define UtilityBase mydata->utilitybase
25 * this makes a 'bt' parameter of 'struct UtilityBase *'
26 * turn into 'struct mydata->utilitybase *'.
28 * Unhappiness ensues. So, we must use 'void *'
29 * for all 'bt' arguments in the call macros.
32 #define FLAG_BN (1 << 0)
33 #define FLAG_DOUBLE (1 << 1)
34 #define FLAG_NR (1 << 2)
36 void aros_ufp(int id, int is_static)
38 int i;
40 printf("#define AROS_UFP%d%s(t,n", id, is_static ? "S" : "");
41 for (i = 0; i < id; i++)
42 printf(",a%d", i + 1);
43 printf(") \\\n");
44 printf("\t%st n (void)\n", is_static ? "static " : "");
47 void aros_ufh(int id, int is_static)
49 int i;
51 printf("#define AROS_UFH%d%s(t,n", id, is_static ? "S" : "");
52 for (i = 0; i < id; i++)
53 printf(",a%d", i + 1);
54 printf(") \\\n");
55 printf("\t%st n (void) {%s\n", is_static ? "static " : "", (i==0) ? "" : " \\");
56 for (i = 0; i < id; i++)
57 printf(" \\\n\t__AROS_UFPA(a%d) __attribute__((unused)) __AROS_UFCA(a%d) = __AROS_ISREG(a%d,__AROS_FP_REG) ? (__AROS_UFPA(a%d))(ULONG)__builtin_frame_address(1) : ({register ULONG __r asm(__AROS_UFSA(a%d));(__AROS_UFPA(a%d))__r;});", i+1, i+1, i+1, i+1, i+1, i+1);
58 printf("\n");
61 static void asm_regs_init(int id, int flags, const char *type, const char *jmp, const char *addr)
63 int i;
64 int has_bn = (flags & FLAG_BN);
66 /* Input values */
67 for (i = 0; i < id; i++)
68 printf("\t ULONG _arg%d = (ULONG)__AROS_%sCA(a%d); \\\n",
69 i + 1, type, i + 1
71 if (has_bn)
72 printf("\t ULONG _bn_arg = (ULONG)bn; \\\n");
74 /* Define registers */
75 for (i = 0; i < id; i++)
76 printf("\t register volatile ULONG __AROS_%sTA(a%d) asm(__AROS_%sSA(a%d)); \\\n",
77 type, i + 1, type, i + 1
79 if (has_bn)
80 printf("\t register volatile ULONG _bn asm(\"%%a6\"); \\\n");
83 /* Set registers (non FP) */
84 for (i = 1; i <= id; i++)
85 printf("\t if (! __AROS_ISREG(a%d,__AROS_FP_REG)) { \\\n"
86 "\t __AROS_%sTA(a%d) = _arg%d; } \\\n",
87 i, type, i, i
89 if (has_bn)
90 printf("\t if (! __AROS_ISREG(bt,bn,A6,__AROS_FP_REG)) { \\\n"
91 "\t _bn = _bn_arg; } \\\n"
94 /* Set FP register */
95 for (i = 1; i <= id; i++)
97 int j;
98 printf("\t if ( __AROS_ISREG(a%d,__AROS_FP_REG)) { \\\n"
99 "\t asm volatile (\"move.l %%%%\" __AROS_FP_SREG \",%%%%sp@-\\nmove.l %%0,%%%%\" __AROS_FP_SREG \"\\n%s\\nmove.l %%%%sp@+,%%%%\" __AROS_FP_SREG \"\\n\" : : \"r\" (_arg%d), %s \\\n",
100 i, jmp, i, addr
102 for (j = 0; j < id; j++)
103 printf("\t\t, \"r\" (__AROS_%sTA(a%d)) \\\n", type, j + 1);
104 printf("\t ); }\\\n");
106 if (has_bn)
108 int j;
109 printf("\t if ( __AROS_ISREG(bt,bn,A6,__AROS_FP_REG)) { \\\n"
110 "\t asm volatile (\"move.l %%%%\" __AROS_FP_SREG \",%%%%sp@-\\nmove.l %%0,%%%%\" __AROS_FP_SREG \"\\n%s\\nmove.l %%%%sp@+,%%%%\" __AROS_FP_SREG \"\\n\" : : \"r\" (_bn_arg), %s \\\n", jmp, addr
112 for (j = 0; j < id; j++)
113 printf("\t\t, \"r\" (__AROS_%sTA(a%d)) \\\n", type, j + 1);
114 printf("\t ); }\\\n");
116 if (has_bn || id > 0)
118 int j;
119 printf("\t if (!(0");
120 if (has_bn)
121 printf(" || __AROS_ISREG(bt,bn,A6,__AROS_FP_REG)");
122 for (i = 0; i < id; i++)
123 printf(" || __AROS_ISREG(a%d,__AROS_FP_REG)", i+1);
124 printf(")) {\\\n"
125 "\t asm volatile (\"%s\\n\" : : \"i\" (0), %s \\\n", jmp, addr
127 for (j = 0; j < id; j++)
128 printf("\t\t, \"r\" (__AROS_%sTA(a%d)) \\\n", type, j + 1);
129 printf("\t ); }\\\n");
133 static void asm_regs_exit(int id, int flags)
135 if (flags & FLAG_NR) {
136 printf("\t asm volatile (\"\" : : : \"%%d0\", \"%%d1\", \"%%a0\", \"%%a1\", \"cc\", \"memory\"); \\\n");
137 return;
140 /* Get the return code
142 * We rely upon the compiler to optimize this to either
143 * as single %d0 for BYTE..LONG, or %d0/%d1 for QUAD/double
145 * Struct returns are not supported.
147 printf("\t register volatile ULONG _ret0 asm(\"%%d0\"); \\\n");
148 printf("\t register volatile ULONG _ret1 asm(\"%%d1\"); \\\n");
149 printf("\t asm volatile (\"\" : \"=r\" (_ret0), \"=r\" (_ret1) : : \"%%a0\", \"%%a1\", \"cc\", \"memory\"); \\\n");
150 printf("\t (sizeof(t) < sizeof(QUAD)) ? (t)(_ret0) :\\\n");
151 printf("\t ({struct { ULONG r0,r1; } rv;\\\n");
152 printf("\t t *t_ptr = (t *)&rv.r0;\\\n");
153 printf("\t rv.r0 = _ret0; rv.r1 = _ret1; *t_ptr; });\\\n");
156 static inline const char *nr(int flags)
158 if (flags & FLAG_NR)
159 return "NR";
160 else
161 return "";
164 static void aros_ufc(int id, int flags)
166 int i;
167 char jmp[256];
169 printf("#define __AROS_UFC%d%s(t,n", id, nr(flags));
170 for (i = 0; i < id; i++)
171 printf(",a%d", i + 1);
172 printf(") \\\n");
173 printf("\t({ APTR _n = (n);\\\n");
174 snprintf(jmp, sizeof(jmp),
175 "pea.l 0f\\n"
176 "move.l %%1, %%%%sp@-\\n"
177 "rts\\n"
178 "0:\\n"
180 jmp[sizeof(jmp)-1]=0;
181 asm_regs_init(i, flags, "UF", jmp, "\"r\" (_n), \"i\" (__LINE__)");
183 asm_regs_exit(i, flags);
184 printf("\t })\n\n");
185 printf("#define AROS_UFC%d%s __AROS_UFC%d%s\n", id, nr(flags), id, nr(flags));
188 void aros_lc(int id, int flags)
190 int i;
191 int is_double = (flags & FLAG_DOUBLE);
192 flags |= FLAG_BN;
194 printf("#define __AROS_LC%d%s%s(t,n,", id, is_double ? "D" : "", nr(flags));
195 for (i = 0; i < id; i++)
196 printf("a%d,", i + 1);
197 printf("bt,bn,o,s) \\\n");
198 printf("\t({ \\\n");
199 asm_regs_init(id, flags, "L", "jsr %c1(%%a6)", "\"i\" (-1 * (o) * LIB_VECTSIZE), \"r\" (_bn)");
200 asm_regs_exit(id, flags);
201 printf("\t })\n\n");
202 printf("#define AROS_LC%d%s%s __AROS_LC%d%s%s\n", id, is_double ? "D" : "", nr(flags), id, is_double ? "D" : "", nr(flags));
205 void aros_lp(int id, int is_ignored)
207 int i;
209 printf("#define __AROS_LP%d%s(t,n,", id, is_ignored ? "I" : "");
210 for (i = 0; i < id; i++)
211 printf("a%d,", i + 1);
212 printf("bt,bn,o,s) \\\n");
213 printf("\tt n ( ");
214 for (i = 0; i < id; i++)
215 printf("__AROS_LHA(a%d)%s",
216 i + 1,
217 ((i + 1) == id) ? "" : ", \\\n\t"
219 if (id == 0)
220 printf("void ");
221 printf(")\n");
222 printf("#define AROS_LP%d%s __AROS_LP%d%s\n", id, is_ignored ? "I" : "", id, is_ignored ? "I" : "");
225 void aros_lh(int id, int is_ignored)
227 int i;
229 printf("#define __AROS_LH%d%s(t,n,", id, is_ignored ? "I" : "");
230 for (i = 0; i < id; i++)
231 printf("a%d,", i + 1);
232 printf("bt,bn,o,s) \\\n");
233 printf("\tt AROS_SLIB_ENTRY(n,s,o) (void) {");
234 for (i = 0; i < id; i++)
235 printf(" \\\n\t__AROS_LPA(a%d) __attribute__((unused)) __AROS_LCA(a%d) = __AROS_ISREG(a%d,__AROS_FP_REG) ? (__AROS_LPA(a%d))(ULONG)__builtin_frame_address(1) : ({register ULONG __r asm(__AROS_LSA(a%d));(__AROS_LPA(a%d))__r;});", i+1, i+1, i+1, i+1, i+1, i+1);
236 if (!is_ignored)
237 printf(" \\\n\tregister bt __attribute__((unused)) bn = __AROS_ISREG(bn,bt,A6,__AROS_FP_REG) ? (bt)(ULONG)__builtin_frame_address(1) : ({register ULONG __r asm(\"%%a6\");(bt)__r;});");
238 printf("\n");
239 printf("#define AROS_LH%d%s __AROS_LH%d%s\n", id, is_ignored ? "I" : "", id, is_ignored ? "I" : "");
242 static void aros_call(int id, int flags)
244 int i;
245 printf("#define __AROS_CALL%d%s(t,n,", id, nr(flags));
246 for (i = 0; i < id; i++)
247 printf("a%d,", i + 1);
248 printf("bt,bn) \\\n");
249 printf("\tAROS_UFC%d%s(t,n", id + 1, nr(flags));
250 for (i = 0; i < id; i++)
252 printf(",AROS_UFCA(a%d)", i + 1);
254 printf(",AROS_UFCA(bt,bn,A6))\n");
255 printf("#define AROS_CALL%d%s __AROS_CALL%d%s\n", id, nr(flags), id, nr(flags));
258 static void aros_lvo_call(int id, int flags)
260 int i;
261 printf("#define __AROS_LVO_CALL%d%s(t,", id, nr(flags));
262 for (i = 0; i < id; i++)
263 printf("a%d,", i + 1);
264 printf("bt,bn,o,s) \\\n");
265 printf("\t__AROS_CALL%d%s(t,__AROS_GETVECADDR(bn,o), \\\n", id, nr(flags));
266 for (i = 0; i < id; i++)
267 printf("\t\tAROS_LCA(a%d), \\\n", i + 1);
268 printf("\t\tbt,bn)\n");
269 printf("#define AROS_LVO_CALL%d%s __AROS_LVO_CALL%d%s\n", id, nr(flags), id, nr(flags));
272 static void aros_ld(int id, int is_ignored)
274 int i;
276 printf("#define __AROS_LD%d%s(t,n,", id, is_ignored ? "I" : "");
277 for (i = 0; i < id; i++)
278 printf("a%d,", i + 1);
279 printf("bt,bn,o,s) \\\n");
280 printf("\t__AROS_LD_PREFIX t AROS_SLIB_ENTRY(n,s,o) (void)\n");
281 printf("#define AROS_LD%d%s __AROS_LD%d%s\n", id, is_ignored ? "I" : "", id, is_ignored ? "I" : "");
284 static const char asmextra[] =
285 "/* Get the register from a triplet */\n"
286 "#define __AROS_UFRA(type,name,reg) reg\n"
287 "\n"
288 "/* Temporary variables */\n"
289 "#define __AROS_UFTA(type,name,reg) reg##_tmp\n"
290 "\n"
291 "/* Get the register as a string from the triplet */\n"
292 "#define __AROS_UFSA(type,name,reg) \"%\"#reg\n"
295 static const char libextra[] =
296 "/* Get the register from a triplet */\n"
297 "#define __AROS_LRA(type,name,reg) reg\n"
298 "#define __AROS_LRAQUAD1(type,name,reg1,reg2) reg1\n"
299 "#define __AROS_LRAQUAD2(type,name,reg1,reg2) reg2\n"
300 "\n"
301 "/* Temporary variables */\n"
302 "#define __AROS_LTA(type,name,reg) reg##_tmp\n"
303 "#define __AROS_LTAQUAD(type,name,reg1,reg2) reg1##_##reg2##_tmp\n"
304 "#define __AROS_LTAQUAD1(type,name,reg1,reg2) reg1##_tmp\n"
305 "#define __AROS_LTAQUAD2(type,name,reg1,reg2) reg2##_tmp\n"
306 "\n"
307 "/* Get the register as a string from the triplet */\n"
308 "#define __AROS_LSA(type,name,reg) \"%\"#reg\n"
309 "#define __AROS_LSAQUAD1(type,name,reg1,reg2) \"%\"#reg1\n"
310 "#define __AROS_LSAQUAD2(type,name,reg1,reg2) \"%\"#reg2\n"
311 "\n"
312 "#define __AROS_LHQUAD1(t,n,q1,bt,bn,o,s) \\\n"
313 " __AROS_LH2(t,n, \\\n"
314 " AROS_LHA(ULONG, __AROS_LTAQUAD1(q1), __AROS_LRAQUAD1(q1)), \\\n"
315 " AROS_LHA(ULONG, __AROS_LTAQUAD2(q1), __AROS_LRAQUAD2(q1)), \\\n"
316 " bt, bn, o, s) \\\n"
317 " union { \\\n"
318 " __AROS_LPAQUAD(q1) val; \\\n"
319 " ULONG reg[2]; \\\n"
320 " } __AROS_LTAQUAD(q1); \\\n"
321 " __AROS_LTAQUAD(q1).reg[0] = __AROS_LTAQUAD1(q1); \\\n"
322 " __AROS_LTAQUAD(q1).reg[1] = __AROS_LTAQUAD2(q1); \\\n"
323 " __AROS_LPAQUAD(q1) __attribute__((unused)) __AROS_LCAQUAD(q1) = __AROS_LTAQUAD(q1).val;\n"
324 "\n"
325 "#define AROS_LHQUAD1 __AROS_LHQUAD1\n"
326 "\n"
327 "#define __AROS_LHQUAD2(t,n,q1,q2,bt,bn,o,s) \\\n"
328 " __AROS_LH4(t,n, \\\n"
329 " AROS_LHA(ULONG, __AROS_LTAQUAD1(q1), __AROS_LRAQUAD1(q1)), \\\n"
330 " AROS_LHA(ULONG, __AROS_LTAQUAD2(q1), __AROS_LRAQUAD2(q1)), \\\n"
331 " AROS_LHA(ULONG, __AROS_LTAQUAD1(q2), __AROS_LRAQUAD1(q2)), \\\n"
332 " AROS_LHA(ULONG, __AROS_LTAQUAD2(q2), __AROS_LRAQUAD2(q2)), \\\n"
333 " bt, bn, o, s) \\\n"
334 " union { \\\n"
335 " __AROS_LPAQUAD(q1) val; \\\n"
336 " ULONG reg[2]; \\\n"
337 " } __AROS_LTAQUAD(q1); \\\n"
338 " union { \\\n"
339 " __AROS_LPAQUAD(q2) val; \\\n"
340 " ULONG reg[2]; \\\n"
341 " } __AROS_LTAQUAD(q2); \\\n"
342 " __AROS_LTAQUAD(q1).reg[0] = __AROS_LTAQUAD1(q1); \\\n"
343 " __AROS_LTAQUAD(q1).reg[1] = __AROS_LTAQUAD2(q1); \\\n"
344 " __AROS_LPAQUAD(q1) __attribute__((unused)) __AROS_LCAQUAD(q1) = __AROS_LTAQUAD(q1).val; \\\n"
345 " __AROS_LTAQUAD(q2).reg[0] = __AROS_LTAQUAD1(q2); \\\n"
346 " __AROS_LTAQUAD(q2).reg[1] = __AROS_LTAQUAD2(q2); \\\n"
347 " __AROS_LPAQUAD(q2) __attribute__((unused)) __AROS_LCAQUAD(q2) = __AROS_LTAQUAD(q2).val;\n"
348 "\n"
349 "#define AROS_LHQUAD2 __AROS_LHQUAD2\n"
350 "\n"
351 "#define __AROS_LH1QUAD2(t,n,a1,q1,q2,bt,bn,o,s) \\\n"
352 " __AROS_LH5(t,n, \\\n"
353 " AROS_LHA(a1), \\\n"
354 " AROS_LHA(ULONG, __AROS_LTAQUAD1(q1), __AROS_LRAQUAD1(q1)), \\\n"
355 " AROS_LHA(ULONG, __AROS_LTAQUAD2(q1), __AROS_LRAQUAD2(q1)), \\\n"
356 " AROS_LHA(ULONG, __AROS_LTAQUAD1(q2), __AROS_LRAQUAD1(q2)), \\\n"
357 " AROS_LHA(ULONG, __AROS_LTAQUAD2(q2), __AROS_LRAQUAD2(q2)), \\\n"
358 " bt, bn, o, s) \\\n"
359 " union { \\\n"
360 " __AROS_LPAQUAD(q1) val; \\\n"
361 " ULONG reg[2]; \\\n"
362 " } __AROS_LTAQUAD(q1); \\\n"
363 " union { \\\n"
364 " __AROS_LPAQUAD(q2) val; \\\n"
365 " ULONG reg[2]; \\\n"
366 " } __AROS_LTAQUAD(q2); \\\n"
367 " __AROS_LTAQUAD(q1).reg[0] = __AROS_LTAQUAD1(q1); \\\n"
368 " __AROS_LTAQUAD(q1).reg[1] = __AROS_LTAQUAD2(q1); \\\n"
369 " __AROS_LPAQUAD(q1) __attribute__((unused)) __AROS_LCAQUAD(q1) = __AROS_LTAQUAD(q1).val; \\\n"
370 " __AROS_LTAQUAD(q2).reg[0] = __AROS_LTAQUAD1(q2); \\\n"
371 " __AROS_LTAQUAD(q2).reg[1] = __AROS_LTAQUAD2(q2); \\\n"
372 " __AROS_LPAQUAD(q2) __attribute__((unused)) __AROS_LCAQUAD(q2) = __AROS_LTAQUAD(q2).val;\n"
373 "\n"
374 "#define AROS_LH1QUAD2 __AROS_LH1QUAD2\n"
375 "\n"
376 "#define __AROS_LH1QUAD1(t,n,a1,q1,bt,bn,o,s) \\\n"
377 " __AROS_LH3(t,n, \\\n"
378 " AROS_LHA(a1), \\\n"
379 " AROS_LHA(ULONG, __AROS_LTAQUAD1(q1), __AROS_LRAQUAD1(q1)), \\\n"
380 " AROS_LHA(ULONG, __AROS_LTAQUAD2(q1), __AROS_LRAQUAD2(q1)), \\\n"
381 " bt, bn, o, s) \\\n"
382 " union { \\\n"
383 " __AROS_LPAQUAD(q1) val; \\\n"
384 " ULONG reg[2]; \\\n"
385 " } __AROS_LTAQUAD(q1); \\\n"
386 " __AROS_LTAQUAD(q1).reg[0] = __AROS_LTAQUAD1(q1); \\\n"
387 " __AROS_LTAQUAD(q1).reg[1] = __AROS_LTAQUAD2(q1); \\\n"
388 " __AROS_LPAQUAD(q1) __attribute__((unused)) __AROS_LCAQUAD(q1) = __AROS_LTAQUAD(q1).val;\n"
389 "\n"
390 "#define AROS_LH1QUAD1 __AROS_LH1QUAD1\n"
391 "\n"
392 "#define __AROS_LH2QUAD1(t,n,a1,a2,q1,bt,bn,o,s) \\\n"
393 " __AROS_LH4(t,n, \\\n"
394 " AROS_LHA(a1), \\\n"
395 " AROS_LHA(a2), \\\n"
396 " AROS_LHA(ULONG, __AROS_LTAQUAD1(q1), __AROS_LRAQUAD1(q1)), \\\n"
397 " AROS_LHA(ULONG, __AROS_LTAQUAD2(q1), __AROS_LRAQUAD2(q1)), \\\n"
398 " bt, bn, o, s) \\\n"
399 " union { \\\n"
400 " __AROS_LPAQUAD(q1) val; \\\n"
401 " ULONG reg[2]; \\\n"
402 " } __AROS_LTAQUAD(q1); \\\n"
403 " __AROS_LTAQUAD(q1).reg[0] = __AROS_LTAQUAD1(q1); \\\n"
404 " __AROS_LTAQUAD(q1).reg[1] = __AROS_LTAQUAD2(q1); \\\n"
405 " __AROS_LPAQUAD(q1) __attribute__((unused)) __AROS_LCAQUAD(q1) = __AROS_LTAQUAD(q1).val;\n"
406 "\n"
407 "#define AROS_LH2QUAD1 __AROS_LH2QUAD1\n"
408 "\n"
409 "#define __AROS_LH3QUAD1(t,n,a1,a2,a3,q1,bt,bn,o,s) \\\n"
410 " __AROS_LH5(t,n, \\\n"
411 " AROS_LHA(a1), \\\n"
412 " AROS_LHA(a2), \\\n"
413 " AROS_LHA(a3), \\\n"
414 " AROS_LHA(ULONG, __AROS_LTAQUAD1(q1), __AROS_LRAQUAD1(q1)), \\\n"
415 " AROS_LHA(ULONG, __AROS_LTAQUAD2(q1), __AROS_LRAQUAD2(q1)), \\\n"
416 " bt, bn, o, s) \\\n"
417 " union { \\\n"
418 " __AROS_LPAQUAD(q1) val; \\\n"
419 " ULONG reg[2]; \\\n"
420 " } __AROS_LTAQUAD(q1); \\\n"
421 " __AROS_LTAQUAD(q1).reg[0] = __AROS_LTAQUAD1(q1); \\\n"
422 " __AROS_LTAQUAD(q1).reg[1] = __AROS_LTAQUAD2(q1); \\\n"
423 " __AROS_LPAQUAD(q1) __attribute__((unused)) __AROS_LCAQUAD(q1) = __AROS_LTAQUAD(q1).val;\n"
424 "\n"
425 "#define AROS_LH3QUAD1 __AROS_LH3QUAD1\n"
426 "\n"
427 "#define __AROS_LCQUAD1(t,n,q1,bt,bn,o,s) \\\n"
428 " ({ \\\n"
429 " union { \\\n"
430 " __AROS_LPAQUAD(q1) val; \\\n"
431 " ULONG reg[2]; \\\n"
432 " } _q1 = { .val = __AROS_LCAQUAD(q1) }; \\\n"
433 " __AROS_LC2##t(t, n, \\\n"
434 " AROS_LCA(ULONG, _q1.reg[0], __AROS_LRAQUAD1(q1)), \\\n"
435 " AROS_LCA(ULONG, _q1.reg[1], __AROS_LRAQUAD2(q1)), \\\n"
436 " bt, bn, o, s); \\\n"
437 " })\n"
438 "\n"
439 "#define AROS_LCQUAD1 __AROS_LCQUAD1\n"
440 "\n"
441 "#define __AROS_LCQUAD2(t,n,q1,q2,bt,bn,o,s) \\\n"
442 " ({ \\\n"
443 " union { \\\n"
444 " __AROS_LPAQUAD(q1) val; \\\n"
445 " ULONG reg[2]; \\\n"
446 " } _q1 = { .val = __AROS_LCAQUAD(q1) }; \\\n"
447 " union { \\\n"
448 " __AROS_LPAQUAD(q2) val; \\\n"
449 " ULONG reg[2]; \\\n"
450 " } _q2 = { .val = __AROS_LCAQUAD(q2) }; \\\n"
451 " __AROS_LC4##t(t, n, \\\n"
452 " AROS_LCA(ULONG, _q1.reg[0], __AROS_LRAQUAD1(q1)), \\\n"
453 " AROS_LCA(ULONG, _q1.reg[1], __AROS_LRAQUAD2(q1)), \\\n"
454 " AROS_LCA(ULONG, _q2.reg[0], __AROS_LRAQUAD1(q2)), \\\n"
455 " AROS_LCA(ULONG, _q2.reg[1], __AROS_LRAQUAD2(q2)), \\\n"
456 " bt, bn, o, s); \\\n"
457 " })\n"
458 "\n"
459 "#define AROS_LCQUAD2 __AROS_LCQUAD2\n"
460 "\n"
461 "#define __AROS_LC1QUAD1(t,n,a1,q1,bt,bn,o,s) \\\n"
462 " ({ \\\n"
463 " union { \\\n"
464 " __AROS_LPAQUAD(q1) val; \\\n"
465 " ULONG reg[2]; \\\n"
466 " } _q1 = { .val = __AROS_LCAQUAD(q1) }; \\\n"
467 " __AROS_LC3##t(t, n, \\\n"
468 " AROS_LCA(a1), \\\n"
469 " AROS_LCA(ULONG, _q1.reg[0], __AROS_LRAQUAD1(q1)), \\\n"
470 " AROS_LCA(ULONG, _q1.reg[1], __AROS_LRAQUAD2(q1)), \\\n"
471 " bt, bn, o, s); \\\n"
472 " })\n"
473 "\n"
474 "#define AROS_LC1QUAD1 __AROS_LC1QUAD1\n"
475 "\n"
476 "#define __AROS_LC2QUAD1(t,n,a1,a2,q1,bt,bn,o,s) \\\n"
477 " ({ \\\n"
478 " union { \\\n"
479 " __AROS_LPAQUAD(q1) val; \\\n"
480 " ULONG reg[2]; \\\n"
481 " } _q1 = { .val = __AROS_LCAQUAD(q1) }; \\\n"
482 " __AROS_LC4##t(t, n, \\\n"
483 " AROS_LCA(a1), \\\n"
484 " AROS_LCA(a2), \\\n"
485 " AROS_LCA(ULONG, _q1.reg[0], __AROS_LRAQUAD1(q1)), \\\n"
486 " AROS_LCA(ULONG, _q1.reg[1], __AROS_LRAQUAD2(q1)), \\\n"
487 " bt, bn, o, s); \\\n"
488 " })\n"
489 "\n"
490 "#define AROS_LC2QUAD1 __AROS_LC2QUAD1\n"
491 "\n"
492 "#define __AROS_LC3QUAD1(t,n,a1,a2,a3,q1,bt,bn,o,s) \\\n"
493 " ({ \\\n"
494 " union { \\\n"
495 " __AROS_LPAQUAD(q1) val; \\\n"
496 " ULONG reg[2]; \\\n"
497 " } _q1 = { .val = __AROS_LCAQUAD(q1) }; \\\n"
498 " __AROS_LC5##t(t, n, \\\n"
499 " AROS_LCA(a1), \\\n"
500 " AROS_LCA(a2), \\\n"
501 " AROS_LCA(a3), \\\n"
502 " AROS_LCA(ULONG, _q1.reg[0], __AROS_LRAQUAD1(q1)), \\\n"
503 " AROS_LCA(ULONG, _q1.reg[1], __AROS_LRAQUAD2(q1)), \\\n"
504 " bt, bn, o, s); \\\n"
505 " })\n"
506 "\n"
507 "#define AROS_LC3QUAD1 __AROS_LC3QUAD1\n"
508 "\n"
509 "#define __AROS_LC2double __AROS_LC2D\n"
510 "#define __AROS_LC3double __AROS_LC3D\n"
511 "#define __AROS_LC4double __AROS_LC4D\n"
512 "#define __AROS_LC2LONG __AROS_LC2\n"
513 "#define __AROS_LC3LONG __AROS_LC3\n"
514 "#define __AROS_LC4LONG __AROS_LC4\n"
515 "#define __AROS_LC5LONG __AROS_LC5\n"
516 "\n"
517 "# define AROS_LDQUAD1(t,n,q1,bt,bn,o,s) \\\n"
518 " __AROS_LD_PREFIX t AROS_SLIB_ENTRY(n,s,o) ( \\\n"
519 " __AROS_LDAQUAD(q1), __AROS_LD_BASE(bt,bn))\n"
520 "# define AROS_LDQUAD2(t,n,q1,q2,bt,bn,o,s) \\\n"
521 " __AROS_LD_PREFIX t AROS_SLIB_ENTRY(n,s,o) ( \\\n"
522 " __AROS_LDAQUAD(q1), \\\n"
523 " __AROS_LDAQUAD(q2),__AROS_LD_BASE(bt,bn))\n"
524 "\n"
525 "#define AROS_LPQUAD1(t,n,q1,bt,bn,o,s) \\\n"
526 " t n (__AROS_LPAQUAD(q1))\n"
527 "#define AROS_LPQUAD2(t,n,q1,q2,bt,bn,o,s) \\\n"
528 " t n (__AROS_LPAQUAD(q1), __AROS_LPAQUAD(q2))\n"
531 int main(int argc, char **argv)
533 int i;
535 if (argc != 2)
537 fprintf(stderr,
538 "Error in arguments\n"
539 "Usage: %s (asmcall|libcall)\n",
540 argv[0]
542 exit(20);
545 if (strcmp(argv[1], "asmcall") == 0)
547 printf("/* AUTOGENERATED by arch/m68k-all/include/gencall.c */\n");
548 printf("/* If you can get this to work for anything other */\n");
549 printf("/* than gcc-4.5.1 m68k-elf, it would be surprising. */\n");
550 printf("\n");
551 printf("#ifndef AROS_M68K_ASMCALL_H\n");
552 printf("#define AROS_M68K_ASMCALL_H\n");
553 printf("\n");
555 printf("#define __AROS_CPU_SPECIFIC_ASMCALLS\n\n");
557 for (i = 0; i < GENCALL_MAX; i++)
558 aros_ufp(i, 0);
560 for (i = 0; i < GENCALL_MAX; i++)
561 aros_ufp(i, 1);
563 for (i = 0; i < GENCALL_MAX; i++)
564 aros_ufh(i, 0);
566 for (i = 0; i < GENCALL_MAX; i++)
567 aros_ufh(i, 1);
569 for (i = 0; i < GENCALL_MAX; i++)
570 aros_ufc(i, 0);
572 for (i = 0; i < GENCALL_MAX; i++)
573 aros_ufc(i, FLAG_NR);
575 printf("\n%s\n", asmextra);
577 printf("#endif /* AROS_M68K_ASMCALL_H */\n");
579 else if (strcmp(argv[1], "libcall") == 0)
581 printf("/* AUTOGENERATED by arch/m68k-all/include/gencall.c */\n");
582 printf("/* If you can get this to work for anything other */\n");
583 printf("/* than gcc-4.5.1 m68k-elf, it would be surprising. */\n");
584 printf("\n");
585 printf("#ifndef AROS_M68K_LIBCALL_H\n");
586 printf("#define AROS_M68K_LIBCALL_H\n");
587 printf("\n");
588 printf("/* Call a libary function which requires the libbase */\n");
589 printf("\n");
591 printf("#define __AROS_CPU_SPECIFIC_LP\n\n");
593 for (i = 0; i < GENCALL_MAX; i++)
594 aros_lp(i, 0);
596 for (i = 0; i < GENCALL_MAX; i++)
597 aros_lp(i, 1);
599 printf("\n");
600 printf("#define __AROS_CPU_SPECIFIC_LH\n\n");
602 for (i = 0; i < GENCALL_MAX; i++)
603 aros_lh(i, 0);
605 for (i = 0; i < GENCALL_MAX; i++)
606 aros_lh(i, 1);
608 printf("\n");
609 printf("#define __AROS_CPU_SPECIFIC_LC\n\n");
611 for (i = 0; i < GENCALL_MAX; i++) {
612 aros_lc(i, 0);
613 aros_lc(i, FLAG_NR);
616 /* For double return AROS_LC2D..AROS_LC4D */
617 aros_lc(2, FLAG_DOUBLE);
618 aros_lc(3, FLAG_DOUBLE);
619 aros_lc(4, FLAG_DOUBLE);
621 for (i = 0; i < GENCALL_MAX; i++) {
622 aros_call(i, 0);
623 aros_call(i, FLAG_NR);
626 for (i = 0; i < GENCALL_MAX; i++)
627 aros_lvo_call(i, 0);
629 for (i = 0; i < GENCALL_MAX; i++)
630 aros_lvo_call(i, FLAG_NR);
632 printf("\n");
633 printf("#define __AROS_CPU_SPECIFIC_LD\n\n");
635 for (i = 0; i < GENCALL_MAX; i++)
636 aros_ld(i, 0);
638 for (i = 0; i < GENCALL_MAX; i++)
639 aros_ld(i, 1);
641 printf("\n%s\n", libextra);
643 printf("#endif /* AROS_M68K_LIBCALL_H */\n");
645 else
647 fprintf(stderr,
648 "Error in arguments\n"
649 "Usage: %s (asmcall|libcall)\n",
650 argv[0]
652 exit(20);
655 return 0;