Differences From Artifact [f1a54526dd]:

To Artifact [367866faaf]:


1
2
3
4
5
6
7
8
9
10
11
12
13
1
2
3
4
5

6
7
8
9
10
11
12





-







#ifndef _avcall_mips_c				/*-*- C -*-*/
#define _avcall_mips_c
/**
  Copyright 1993 Bill Triggs, <Bill.Triggs@inrialpes.fr>
  Copyright 1995-1999 Bruno Haible, <bruno@clisp.org>
  Copyright 2005 Thiemo Seufer  <ths@debian.org>

  This is free software distributed under the GNU General Public
  Licence described in the file COPYING. Contact the author if
  you don't have this or can't live with it. There is ABSOLUTELY
  NO WARRANTY, explicit or implied, on this software.
**/
/*----------------------------------------------------------------------
46
47
48
49
50
51
52
53
54
55
56




57
58
59
60
61

62
63
64
65
66
67
68
69




70
71
72
73
74


75
76
77
78
79
80


81
82
83
84
85
86

87
88

89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120































121
122

123
124
125


126
127
128


129
130
131
132
133
134





135
136
137
138

139
140
141

142
143
144

145
146
147
148


149
150
151
152

153
154
155
156
157
158

159
160
161

162
163
164

165
166
167
168
169
170
171
172
173
45
46
47
48
49
50
51




52
53
54
55
56
57
58


59



60




61
62
63
64





65
66
67
68
69
70


71
72



73
74

75


76
































77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107


108
109


110
111
112


113
114
115





116
117
118
119
120
121
122
123

124
125
126

127
128
129

130
131
132


133
134
135
136
137

138
139
140
141
142
143

144
145
146

147
148
149

150
151
152
153

154
155
156
157
158







-
-
-
-
+
+
+
+



-
-
+
-
-
-

-
-
-
-
+
+
+
+
-
-
-
-
-
+
+




-
-
+
+
-
-
-


-
+
-
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
+

-
-
+
+

-
-
+
+

-
-
-
-
-
+
+
+
+
+



-
+


-
+


-
+


-
-
+
+



-
+





-
+


-
+


-
+



-






typedef __avword (*func_pointer)();
register func_pointer	t9	__asm__("$25");

int
__builtin_avcall(av_alist* l)
{
  register __avword*	sp __asm__("$sp");  /* C names for registers */
  register __avword	iret2_tmp __asm__("$3");
  register float	fret_tmp __asm__("$f0");
  register double	dret_tmp __asm__("$f0");
  register __avword*	sp	__asm__("$sp");  /* C names for registers */
  register __avword	iret2	__asm__("$3");
  register float	fret	__asm__("$f0");
  register double	dret	__asm__("$f0");
  __avword *space = __builtin_alloca(__AV_ALIST_WORDS * sizeof(__avword));	/* big space for child's stack frame */
  __avword *argframe = (__avword*)sp;	/* stack offset for argument list is 0 */
  int arglen = l->aptr - l->args;
  int i;
  __avword iret;
  __avword i;
  long long iret2;
  float fret;
  double dret;

  /* load leading float args */
  if (l->flags & __AV_FLOAT_1)
    __asm__("l.s $f12,%1(%0)" : : "p" (l), "i" OFFSETOF(av_alist,floatarg[0]));
  if (l->flags & __AV_DOUBLE_1)
  if (l->flags & __AV_FLOAT_1)		/* push leading float args */
  {
    __asm__("l.d $f12,%1(%0)" : : "p" (l), "i" OFFSETOF(av_alist,floatarg[0]));
    if (l->flags & __AV_FLOAT_2)
    __asm__("l.d $f12,%1(%0)" : : "p" (l), "i" OFFSETOF(av_alist,doublearg[0]));
  if ((l->flags & __AV_FLOAT_2) && (l->flags & (__AV_FLOAT_1 | __AV_DOUBLE_1)))
    __asm__("l.s $f14,%1(%0)" : : "p" (l), "i" OFFSETOF(av_alist,floatarg[1]));
  if ((l->flags & __AV_DOUBLE_2) && (l->flags & (__AV_FLOAT_1 | __AV_DOUBLE_1)))
    __asm__("l.d $f14,%1(%0)" : : "p" (l), "i" OFFSETOF(av_alist,doublearg[1]));
      __asm__("l.d $f14,%1(%0)" : : "p" (l), "i" OFFSETOF(av_alist,floatarg[1]));
  }

  for (i = 4; i < arglen; i++)		/* push excess function args */
    argframe[i] = l->args[i];

  iret = (*(t9 = l->func))(l->args[0], l->args[1],  /* call function with 1st 4 args */
			   l->args[2], l->args[3]);
  i = (*(t9 = l->func))(l->args[0], l->args[1],  /* call function with 1st 4 args */
			l->args[2], l->args[3]);
  iret2 = iret2_tmp;
  fret = fret_tmp;
  dret = dret_tmp;

  /* save return value */
  switch (l->rtype) {
  if (l->rtype == __AVvoid) {
  default:
  case __AVvoid:
  } else
    break;
  case __AVword:
    RETURN(__avword, iret);
    break;
  case __AVchar:
    RETURN(char, iret);
    break;
  case __AVschar:
    RETURN(signed char, iret);
    break;
  case __AVuchar:
    RETURN(unsigned char, iret);
    break;
  case __AVshort:
    RETURN(short, iret);
    break;
  case __AVushort:
    RETURN(unsigned short, iret);
    break;
  case __AVint:
    RETURN(int, iret);
    break;
  case __AVuint:
    RETURN(unsigned int, iret);
    break;
  case __AVlong:
    RETURN(long, iret);
    break;
  case __AVulong:
    RETURN(unsigned long, iret);
    break;
  case __AVlonglong:
  if (l->rtype == __AVword) {
    RETURN(__avword, i);
  } else
  if (l->rtype == __AVchar) {
    RETURN(char, i);
  } else
  if (l->rtype == __AVschar) {
    RETURN(signed char, i);
  } else
  if (l->rtype == __AVuchar) {
    RETURN(unsigned char, i);
  } else
  if (l->rtype == __AVshort) {
    RETURN(short, i);
  } else
  if (l->rtype == __AVushort) {
    RETURN(unsigned short, i);
  } else
  if (l->rtype == __AVint) {
    RETURN(int, i);
  } else
  if (l->rtype == __AVuint) {
    RETURN(unsigned int, i);
  } else
  if (l->rtype == __AVlong) {
    RETURN(long, i);
  } else
  if (l->rtype == __AVulong) {
    RETURN(unsigned long, i);
  } else
  if (l->rtype == __AVlonglong || l->rtype == __AVulonglong) {
  case __AVulonglong:
    ((__avword*)l->raddr)[0] = (__avword)(iret);
    ((__avword*)l->raddr)[0] = i;
    ((__avword*)l->raddr)[1] = iret2;
    break;
  case __AVfloat:
  } else
  if (l->rtype == __AVfloat) {
    RETURN(float, fret);
    break;
  case __AVdouble:
  } else
  if (l->rtype == __AVdouble) {
    RETURN(double, dret);
    break;
  case __AVvoidp:
    RETURN(void*, (__avword)iret);
    break;
  case __AVstruct:
  } else
  if (l->rtype == __AVvoidp) {
    RETURN(void*, i);
  } else
  if (l->rtype == __AVstruct) {
    if (l->flags & __AV_PCC_STRUCT_RETURN) {
      /* pcc struct return convention: need a  *(TYPE*)l->raddr = *(TYPE*)i;  */
      if (l->rsize == sizeof(char)) {
        RETURN(char, *(char*)(__avword)iret);
        RETURN(char, *(char*)i);
      } else
      if (l->rsize == sizeof(short)) {
        RETURN(short, *(short*)(__avword)iret);
        RETURN(short, *(short*)i);
      } else
      if (l->rsize == sizeof(int)) {
        RETURN(int, *(int*)(__avword)iret);
        RETURN(int, *(int*)i);
      } else
      if (l->rsize == sizeof(double)) {
        ((int*)l->raddr)[0] = ((int*)(__avword)iret)[0];
        ((int*)l->raddr)[1] = ((int*)(__avword)iret)[1];
        ((int*)l->raddr)[0] = ((int*)i)[0];
        ((int*)l->raddr)[1] = ((int*)i)[1];
      } else {
        int n = (l->rsize + sizeof(__avword)-1)/sizeof(__avword);
        while (--n >= 0)
          ((__avword*)l->raddr)[n] = ((__avword*)(__avword)iret)[n];
          ((__avword*)l->raddr)[n] = ((__avword*)i)[n];
      }
    } else {
      /* normal struct return convention */
      if (l->flags & __AV_SMALL_STRUCT_RETURN) {
        if (l->rsize == sizeof(char)) {
          RETURN(char, iret);
          RETURN(char, i);
        } else
        if (l->rsize == sizeof(short)) {
          RETURN(short, iret);
          RETURN(short, i);
        } else
        if (l->rsize == sizeof(int)) {
          RETURN(int, iret);
          RETURN(int, i);
        }
      }
    }
    break;
  }
  return 0;
}

#endif /*_avcall_mips_c */