1
/* vacall function for powerpc64 CPU */
4
* Copyright 1995-2006 Bruno Haible, <bruno@clisp.org>
5
* Copyright 2000 Adam Fedor, <fedor@gnu.org>
6
* Copyright 2004 Paul Guyot, <pguyot@kallisys.net>
8
* This is free software distributed under the GNU General Public Licence
9
* described in the file COPYING. Contact the author if you don't have this
10
* or can't live with it. There is ABSOLUTELY NO WARRANTY, explicit or implied,
15
#include "vacall.h.in"
17
#include "vacall_r.h.in"
21
#define __vacall __vacall_r
22
register struct { void (*vacall_function) (void*,va_alist); void* arg; }
25
register double farg1 __asm__("fr1");
26
register double farg2 __asm__("fr2");
27
register double farg3 __asm__("fr3");
28
register double farg4 __asm__("fr4");
29
register double farg5 __asm__("fr5");
30
register double farg6 __asm__("fr6");
31
register double farg7 __asm__("fr7");
32
register double farg8 __asm__("fr8");
33
register double farg9 __asm__("fr9");
34
register double farg10 __asm__("fr10");
35
register double farg11 __asm__("fr11");
36
register double farg12 __asm__("fr12");
37
register double farg13 __asm__("fr13");
38
register __vaword iret __asm__("r3");
39
register float fret __asm__("fr1");
40
register double dret __asm__("fr1");
42
void /* the return type is variable, not void! */
43
__vacall (__vaword word1, __vaword word2, __vaword word3, __vaword word4,
44
__vaword word5, __vaword word6, __vaword word7, __vaword word8,
48
/* When a parameter is passed in a register,
49
* stack space is still allocated for it.
51
/* Move the arguments passed in registers to their stack locations. */
52
(&firstword)[-8] = word1;
53
(&firstword)[-7] = word2;
54
(&firstword)[-6] = word3;
55
(&firstword)[-5] = word4;
56
(&firstword)[-4] = word5;
57
(&firstword)[-3] = word6;
58
(&firstword)[-2] = word7;
59
(&firstword)[-1] = word8;
69
list.farg[9] = farg10;
70
list.farg[10] = farg11;
71
list.farg[11] = farg12;
72
list.farg[12] = farg13;
73
/* Prepare the va_alist. */
75
list.aptr = (long)(&firstword - 8);
76
list.raddr = (void*)0;
77
list.rtype = __VAvoid;
78
list.memfargptr = &list.farg[0];
79
/* Call vacall_function. The macros do all the rest. */
81
(*vacall_function) (&list);
83
(*env->vacall_function) (env->arg,&list);
85
/* Put return value into proper register. */
86
if (list.rtype == __VAvoid) {
88
if (list.rtype == __VAchar) {
89
iret = list.tmp._char;
91
if (list.rtype == __VAschar) {
92
iret = list.tmp._schar;
94
if (list.rtype == __VAuchar) {
95
iret = list.tmp._uchar;
97
if (list.rtype == __VAshort) {
98
iret = list.tmp._short;
100
if (list.rtype == __VAushort) {
101
iret = list.tmp._ushort;
103
if (list.rtype == __VAint) {
104
iret = list.tmp._int;
106
if (list.rtype == __VAuint) {
107
iret = list.tmp._uint;
109
if (list.rtype == __VAlong) {
110
iret = list.tmp._long;
112
if (list.rtype == __VAulong) {
113
iret = list.tmp._ulong;
115
if (list.rtype == __VAlonglong) {
116
iret = list.tmp._long;
118
if (list.rtype == __VAulonglong) {
119
iret = list.tmp._ulong;
121
if (list.rtype == __VAfloat) {
122
fret = list.tmp._float;
124
if (list.rtype == __VAdouble) {
125
dret = list.tmp._double;
127
if (list.rtype == __VAvoidp) {
128
iret = (long)list.tmp._ptr;
130
if (list.rtype == __VAstruct) {
131
/* __VA_PCC_STRUCT_RETURN and __VA_REGISTER_STRUCT_RETURN are ignored */