4 type :fi1 = { h, s } # in a gp & fp pair
5 type :fi2 = { s, w } # ditto
7 type :fi3 = { s, :uw } # in a single gp reg
8 type :ss = { s, s } # in two fp regs
9 type :sd = { s, d } # ditto
10 type :ww = { w, w } # in a single gp reg
11 type :lb = { l, b } # in two gp regs
12 type :big = { b 17 } # by reference
13 type :ddd = { d, d, d} # big hfa on arm64
15 data $ctoqbestr = { b "c->qbe(%d)", b 0 }
16 data $emptystr = { b 0 }
19 function $qfn0(s %p0, s %p1, s %p2, s %p3, s %p4, s %p5, s %p6, s %p7, s %p8) {
21 %r0 =w call $printf(l $ctoqbestr, ..., w 0)
23 %r1 =w call $puts(l $emptystr)
27 function $qfn1(w %p0, s %p1, :fi1 %p2) {
29 %r0 =w call $printf(l $ctoqbestr, ..., w 1)
33 %r1 =w call $puts(l $emptystr)
37 function $qfn2(w %p0, :fi2 %p1, s %p2) {
39 %r0 =w call $printf(l $ctoqbestr, ..., w 2)
43 %r1 =w call $puts(l $emptystr)
47 function $qfn3(w %p0, s %p1, :fi3 %p2) {
49 %r0 =w call $printf(l $ctoqbestr, ..., w 3)
53 %r1 =w call $puts(l $emptystr)
57 function $qfn4(:ss %p0) {
59 %r0 =w call $printf(l $ctoqbestr, ..., w 4)
61 %r1 =w call $puts(l $emptystr)
65 function $qfn5(d %p0, d %p1, d %p2, d %p3, d %p4, d %p5, d %p6, :ss %p7, s %p8, l %p9) {
67 %r0 =w call $printf(l $ctoqbestr, ..., w 5)
71 %r1 =w call $puts(l $emptystr)
75 function $qfn6(:lb %p0) {
77 %r0 =w call $printf(l $ctoqbestr, ..., w 6)
79 %r1 =w call $puts(l $emptystr)
83 function $qfn7(w %p0, w %p1, w %p2, w %p3, w %p4, w %p5, w %p6, :lb %p7) {
85 %r0 =w call $printf(l $ctoqbestr, ..., w 7)
87 %r1 =w call $puts(l $emptystr)
91 function $qfn8(w %p0, w %p1, w %p2, w %p3, w %p4, w %p5, w %p6, w %p7, :lb %p8) {
93 %r0 =w call $printf(l $ctoqbestr, ..., w 8)
95 %r1 =w call $puts(l $emptystr)
99 function $qfn9(:big %p0) {
101 %r0 =w call $printf(l $ctoqbestr, ..., w 9)
103 %r1 =w call $puts(l $emptystr)
107 function $qfn10(w %p0, w %p1, w %p2, w %p3, w %p4, w %p5, w %p6, w %p7, :big %p8, s %p9, l %p10) {
109 %r0 =w call $printf(l $ctoqbestr, ..., w 10)
113 %r1 =w call $puts(l $emptystr)
117 function $qfn11(:ddd %p0) {
119 %r0 =w call $printf(l $ctoqbestr, ..., w 11)
121 %r1 =w call $puts(l $emptystr)
129 call $cfn0(s 0, s 0, s 0, s 0, s 0, s 0, s 0, s 0, s s_9.9)
130 call $cfn1(w 1, s s_2.2, :fi1 $fi1)
131 call $cfn2(w 1, :fi2 $fi2, s s_3.3)
132 call $cfn3(w 1, s s_2.2, :fi3 $fi3)
134 call $cfn5(d 0, d 0, d 0, d 0, d 0, d 0, d 0, :ss $ss, s s_9.9, l 10)
136 call $cfn7(w 0, w 0, w 0, w 0, w 0, w 0, w 0, :lb $lb)
137 call $cfn8(w 0, w 0, w 0, w 0, w 0, w 0, w 0, w 0, :lb $lb)
138 call $cfn9(:big $big)
139 call $cfn10(w 0, w 0, w 0, w 0, w 0, w 0, w 0, w 0, :big $big, s s_10.10, l 11)
140 call $cfn11(:ddd $ddd)
147 # typedef struct { short h; float s; } Sfi1;
148 # typedef struct { float s; int w; } Sfi2;
149 # typedef struct { float s; union { int w; } u; } Sfi3;
150 # typedef struct { float s0, s1; } Sss;
151 # typedef struct { float s; double d; } Ssd;
152 # typedef struct { int w0, w1; } Sww;
153 # typedef struct { long l; char b; } Slb;
154 # typedef struct { char b[17]; } Sbig;
155 # typedef struct { double d0, d1, d2; } Sddd;
156 # Sfi1 zfi1, fi1 = { -123, 4.56 };
157 # Sfi2 zfi2, fi2 = { 1.23, 456 };
158 # Sfi3 zfi3, fi3 = { 3.45, 567 };
159 # Sss zss, ss = { 1.23, 45.6 };
160 # Ssd zsd, sd = { 2.34, 5.67 };
161 # Sww zww, ww = { -123, -456 };
162 # Slb zlb, lb = { 123, 'z' };
163 # Sbig zbig, big = { "abcdefhijklmnopqr" };
164 # Sddd zddd, ddd = { 1.23, 45.6, 7.89 };
165 # void pfi1(Sfi1 *s) { printf(" { %d, %g }", s->h, s->s); }
166 # void pfi2(Sfi2 *s) { printf(" { %g, %d }", s->s, s->w); }
167 # void pfi3(Sfi3 *s) { printf(" { %g, %d }", s->s, s->u.w); }
168 # void pss(Sss *s) { printf(" { %g, %g }", s->s0, s->s1); }
169 # void psd(Ssd *s) { printf(" { %g, %g }", s->s, s->d); }
170 # void pww(Sww *s) { printf(" { %d, %d }", s->w0, s->w1); }
171 # void plb(Slb *s) { printf(" { %ld, '%c' }", s->l, s->b); }
172 # void pbig(Sbig *s) { printf(" \"%.17s\"", s->b); }
173 # void pddd(Sddd *s) { printf(" { %g, %g, %g }", s->d0, s->d1, s->d2); }
174 # void pw(int w) { printf(" %d", w); }
175 # void pl(long l) { printf(" %ld", l); }
176 # void ps(float s) { printf(" %g", s); }
177 # void pd(double d) { printf(" %g", d); }
178 # /* --------------------------- */
179 # extern void qfn0(float, float, float, float, float, float, float, float, float);
180 # void cfn0(float p0, float p1, float p2, float p3, float p4, float p5, float p6, float p7, float p8) {
181 # printf("qbe->c(%d)", 0);
183 # qfn0(p0, p1, p2, p3, p4, p5, p6, p7, p8);
185 # extern void qfn1(int, float, Sfi1);
186 # void cfn1(int p0, float p1, Sfi1 p2) {
187 # printf("qbe->c(%d)", 1);
188 # pw(p0); ps(p1); pfi1(&p2); puts("");
191 # extern void qfn2(int, Sfi2, float);
192 # void cfn2(int p0, Sfi2 p1, float p2) {
193 # printf("qbe->c(%d)", 2);
194 # pw(p0); pfi2(&p1); ps(p2); puts("");
197 # extern void qfn3(int, float, Sfi3);
198 # void cfn3(int p0, float p1, Sfi3 p2) {
199 # printf("qbe->c(%d)", 3);
200 # pw(p0); ps(p1); pfi3(&p2); puts("");
203 # extern void qfn4(Sss);
204 # void cfn4(Sss p0) {
205 # printf("qbe->c(%d)", 4);
206 # pss(&p0); puts("");
209 # extern void qfn5(double, double, double, double, double, double, double, Sss, float, long);
210 # void cfn5(double p0, double p1, double p2, double p3, double p4, double p5, double p6, Sss p7, float p8, long p9) {
211 # printf("qbe->c(%d)", 5);
212 # pss(&p7); ps(p8); pl(p9); puts("");
213 # qfn5(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9);
215 # extern void qfn6(Slb);
216 # void cfn6(Slb p0) {
217 # printf("qbe->c(%d)", 6);
218 # plb(&p0); puts("");
221 # extern void qfn7(int, int, int, int, int, int, int, Slb);
222 # void cfn7(int p0, int p1, int p2, int p3, int p4, int p5, int p6, Slb p7) {
223 # printf("qbe->c(%d)", 7);
224 # plb(&p7); puts("");
225 # qfn7(p0, p1, p2, p3, p4, p5, p6, p7);
227 # extern void qfn8(int, int, int, int, int, int, int, int, Slb);
228 # void cfn8(int p0, int p1, int p2, int p3, int p4, int p5, int p6, int p7, Slb p8) {
229 # printf("qbe->c(%d)", 8);
230 # plb(&p8); puts("");
231 # qfn8(p0, p1, p2, p3, p4, p5, p6, p7, p8);
233 # extern void qfn9(Sbig);
234 # void cfn9(Sbig p0) {
235 # printf("qbe->c(%d)", 9);
236 # pbig(&p0); puts("");
239 # extern void qfn10(int, int, int, int, int, int, int, int, Sbig, float, long);
240 # void cfn10(int p0, int p1, int p2, int p3, int p4, int p5, int p6, int p7, Sbig p8, float p9, long p10) {
241 # printf("qbe->c(%d)", 10);
242 # pbig(&p8); ps(p9); pl(p10); puts("");
243 # qfn10(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10);
245 # extern void qfn11(Sddd);
246 # void cfn11(Sddd p0) {
247 # printf("qbe->c(%d)", 11);
248 # pddd(&p0); puts("");
256 # qbe->c(1) 1 2.2 { -123, 4.56 }
257 # c->qbe(1) 1 2.2 { -123, 4.56 }
258 # qbe->c(2) 1 { 1.23, 456 } 3.3
259 # c->qbe(2) 1 { 1.23, 456 } 3.3
260 # qbe->c(3) 1 2.2 { 3.45, 567 }
261 # c->qbe(3) 1 2.2 { 3.45, 567 }
262 # qbe->c(4) { 1.23, 45.6 }
263 # c->qbe(4) { 1.23, 45.6 }
264 # qbe->c(5) { 1.23, 45.6 } 9.9 10
265 # c->qbe(5) { 1.23, 45.6 } 9.9 10
266 # qbe->c(6) { 123, 'z' }
267 # c->qbe(6) { 123, 'z' }
268 # qbe->c(7) { 123, 'z' }
269 # c->qbe(7) { 123, 'z' }
270 # qbe->c(8) { 123, 'z' }
271 # c->qbe(8) { 123, 'z' }
272 # qbe->c(9) "abcdefhijklmnopqr"
273 # c->qbe(9) "abcdefhijklmnopqr"
274 # qbe->c(10) "abcdefhijklmnopqr" 10.1 11
275 # c->qbe(10) "abcdefhijklmnopqr" 10.1 11
276 # qbe->c(11) { 1.23, 45.6, 7.89 }
277 # c->qbe(11) { 1.23, 45.6, 7.89 }