History

make variadic args explicit

Some abis, like the riscv one, treat arguments differently depending on whether they are variadic or not. To prepare for the upcomming riscv target, we change the variadic call syntax and give meaning to the location of the '...' marker. # new syntax %ret =w call $f(w %regular, ..., w %variadic) By nature of their abis, the change is backwards compatible for existing targets.

Quentin Carbonneaux committed 5 years ago

Commit fcdef101 parent 9858a1213 files · +101 −75Browse files

Unified · Split

13 files
  1. all.h +1 −2
  2. amd64/sysv.c +21 −13
  3. arm64/abi.c +11 −6
  4. doc/il.txt +3 −3
  5. live.c +1 −1
  6. load.c +1 −1
  7. ops.h +1 −1
  8. parse.c +31 −17
  9. test/_slow.qbe +5 −5
  10. test/abi5.ssa +9 −9
  11. test/abi6.ssa +2 −2
  12. test/echo.ssa +1 −1
  13. test/vararg2.ssa +14 −14
all.h+1−2
@@ -171,12 +171,11 @@ enum { · 170 unmodified lines
171};171};
172 172
173#define INRANGE(x, l, u) ((unsigned)(x) - l <= u - l) /* linear in x */173#define INRANGE(x, l, u) ((unsigned)(x) - l <= u - l) /* linear in x */
174#define iscall(o) INRANGE(o, Ocall, Ovacall)
175#define isstore(o) INRANGE(o, Ostoreb, Ostored)174#define isstore(o) INRANGE(o, Ostoreb, Ostored)
176#define isload(o) INRANGE(o, Oloadsb, Oload)175#define isload(o) INRANGE(o, Oloadsb, Oload)
177#define isext(o) INRANGE(o, Oextsb, Oextuw)176#define isext(o) INRANGE(o, Oextsb, Oextuw)
178#define ispar(o) INRANGE(o, Opar, Opare)177#define ispar(o) INRANGE(o, Opar, Opare)
179#define isarg(o) INRANGE(o, Oarg, Oarge)178#define isarg(o) INRANGE(o, Oarg, Oargv)
180#define isret(j) INRANGE(j, Jret0, Jretc)179#define isret(j) INRANGE(j, Jret0, Jretc)
181 180
182enum Class {181enum Class {
amd64/sysv.c+21−13
@@ -153,7 +153,7 @@ selret(Blk *b, Fn *fn) · 152 unmodified lines
153static int153static int
154argsclass(Ins *i0, Ins *i1, AClass *ac, int op, AClass *aret, Ref *env)154argsclass(Ins *i0, Ins *i1, AClass *ac, int op, AClass *aret, Ref *env)
155{155{
156 int nint, ni, nsse, ns, n, *pn;156 int varc, envc, nint, ni, nsse, ns, n, *pn;
157 AClass *a;157 AClass *a;
158 Ins *i;158 Ins *i;
159 159
@@ -162,6 +162,8 @@ argsclass(Ins *i0, Ins *i1, AClass *ac, int op, AClass *aret, Ref *env) · 2 unmodified lines
162 else162 else
163 nint = 6;163 nint = 6;
164 nsse = 8;164 nsse = 8;
165 varc = 0;
166 envc = 0;
165 for (i=i0, a=ac; i<i1; i++, a++)167 for (i=i0, a=ac; i<i1; i++, a++)
166 switch (i->op - op + Oarg) {168 switch (i->op - op + Oarg) {
167 case Oarg:169 case Oarg:
@@ -196,14 +198,23 @@ argsclass(Ins *i0, Ins *i1, AClass *ac, int op, AClass *aret, Ref *env) · 28 unmodified lines
196 a->inmem = 1;198 a->inmem = 1;
197 break;199 break;
198 case Oarge:200 case Oarge:
201 envc = 1;
199 if (op == Opar)202 if (op == Opar)
200 *env = i->to;203 *env = i->to;
201 else204 else
202 *env = i->arg[0];205 *env = i->arg[0];
203 break;206 break;
207 case Oargv:
208 varc = 1;
209 break;
210 default:
211 die("unreachable");
204 }212 }
205 213
206 return (!req(R, *env) << 12) | ((6-nint) << 4) | ((8-nsse) << 8);214 if (varc && envc)
215 err("sysv abi does not support variadic env calls");
216
217 return ((varc|envc) << 12) | ((6-nint) << 4) | ((8-nsse) << 8);
207}218}
208 219
209int amd64_sysv_rsave[] = {220int amd64_sysv_rsave[] = {
@@ -290,7 +301,7 @@ selcall(Fn *fn, Ins *i0, Ins *i1, RAlloc **rap) · 80 unmodified lines
290{301{
291 Ins *i;302 Ins *i;
292 AClass *ac, *a, aret;303 AClass *ac, *a, aret;
293 int ca, ni, ns, al, varc, envc;304 int ca, ni, ns, al;
294 uint stk, off;305 uint stk, off;
295 Ref r, r1, r2, reg[2], env;306 Ref r, r1, r2, reg[2], env;
296 RAlloc *ra;307 RAlloc *ra;
@@ -358,22 +369,20 @@ selcall(Fn *fn, Ins *i0, Ins *i1, RAlloc **rap) · 61 unmodified lines
358 ca += 1 << 2;369 ca += 1 << 2;
359 }370 }
360 }371 }
361 envc = !req(R, env);372
362 varc = i1->op == Ovacall;
363 if (varc && envc)
364 err("sysv abi does not support variadic env calls");
365 ca |= varc << 12; /* envc set in argsclass() */
366 emit(Ocall, i1->cls, R, i1->arg[0], CALL(ca));373 emit(Ocall, i1->cls, R, i1->arg[0], CALL(ca));
367 if (envc)374
375 if (!req(R, env))
368 emit(Ocopy, Kl, TMP(RAX), env, R);376 emit(Ocopy, Kl, TMP(RAX), env, R);
369 if (varc)377 else if ((ca >> 12) & 1) /* vararg call */
370 emit(Ocopy, Kw, TMP(RAX), getcon((ca >> 8) & 15, fn), R);378 emit(Ocopy, Kw, TMP(RAX), getcon((ca >> 8) & 15, fn), R);
371 379
372 ni = ns = 0;380 ni = ns = 0;
373 if (ra && aret.inmem)381 if (ra && aret.inmem)
374 emit(Ocopy, Kl, rarg(Kl, &ni, &ns), ra->i.to, R); /* pass hidden argument */382 emit(Ocopy, Kl, rarg(Kl, &ni, &ns), ra->i.to, R); /* pass hidden argument */
383
375 for (i=i0, a=ac; i<i1; i++, a++) {384 for (i=i0, a=ac; i<i1; i++, a++) {
376 if (a->inmem || i->op == Oarge)385 if (i->op >= Oarge || a->inmem)
377 continue;386 continue;
378 r1 = rarg(a->cls[0], &ni, &ns);387 r1 = rarg(a->cls[0], &ni, &ns);
379 if (i->op == Oargc) {388 if (i->op == Oargc) {
@@ -393,7 +402,7 @@ selcall(Fn *fn, Ins *i0, Ins *i1, RAlloc **rap) · 13 unmodified lines
393 402
394 r = newtmp("abi", Kl, fn);403 r = newtmp("abi", Kl, fn);
395 for (i=i0, a=ac, off=0; i<i1; i++, a++) {404 for (i=i0, a=ac, off=0; i<i1; i++, a++) {
396 if (!a->inmem)405 if (i->op >= Oarge || !a->inmem)
397 continue;406 continue;
398 if (i->op == Oargc) {407 if (i->op == Oargc) {
399 if (a->align == 4)408 if (a->align == 4)
@@ -676,7 +685,6 @@ amd64_sysv_abi(Fn *fn) · 276 unmodified lines
676 emiti(*i);685 emiti(*i);
677 break;686 break;
678 case Ocall:687 case Ocall:
679 case Ovacall:
680 for (i0=i; i0>b->ins; i0--)688 for (i0=i; i0>b->ins; i0--)
681 if (!isarg((i0-1)->op))689 if (!isarg((i0-1)->op))
682 break;690 break;
arm64/abi.c+11−6
@@ -255,6 +255,10 @@ argsclass(Ins *i0, Ins *i1, Class *carg, Ref *env) · 254 unmodified lines
255 case Oarge:255 case Oarge:
256 *env = i->arg[0];256 *env = i->arg[0];
257 break;257 break;
258 case Oargv:
259 break;
260 default:
261 die("unreachable");
258 }262 }
259 263
260 return ((gp-gpreg) << 5) | ((fp-fpreg) << 9);264 return ((gp-gpreg) << 5) | ((fp-fpreg) << 9);
@@ -371,10 +375,11 @@ selcall(Fn *fn, Ins *i0, Ins *i1, Insl **ilp) · 110 unmodified lines
371 }375 }
372 }376 }
373 377
378 emit(Ocall, 0, R, i1->arg[0], CALL(cty));
379
374 envc = !req(R, env);380 envc = !req(R, env);
375 if (envc)381 if (envc)
376 die("todo (arm abi): env calls");382 die("todo (arm abi): env calls");
377 emit(Ocall, 0, R, i1->arg[0], CALL(cty));
378 383
379 if (cty & (1 << 13))384 if (cty & (1 << 13))
380 /* struct return argument */385 /* struct return argument */
@@ -383,9 +388,9 @@ selcall(Fn *fn, Ins *i0, Ins *i1, Insl **ilp) · 2 unmodified lines
383 for (i=i0, c=ca; i<i1; i++, c++) {388 for (i=i0, c=ca; i<i1; i++, c++) {
384 if ((c->class & Cstk) != 0)389 if ((c->class & Cstk) != 0)
385 continue;390 continue;
386 if (i->op != Oargc)391 if (i->op == Oarg)
387 emit(Ocopy, *c->cls, TMP(*c->reg), i->arg[0], R);392 emit(Ocopy, *c->cls, TMP(*c->reg), i->arg[0], R);
388 else393 if (i->op == Oargc)
389 ldregs(c->reg, c->cls, c->nreg, i->arg[1], fn);394 ldregs(c->reg, c->cls, c->nreg, i->arg[1], fn);
390 }395 }
391 396
@@ -393,11 +398,12 @@ selcall(Fn *fn, Ins *i0, Ins *i1, Insl **ilp) · 1 unmodified line
393 for (i=i0, c=ca; i<i1; i++, c++) {398 for (i=i0, c=ca; i<i1; i++, c++) {
394 if ((c->class & Cstk) == 0)399 if ((c->class & Cstk) == 0)
395 continue;400 continue;
396 if (i->op != Oargc) {401 if (i->op == Oarg) {
397 r = newtmp("abi", Kl, fn);402 r = newtmp("abi", Kl, fn);
398 emit(Ostorel, 0, R, i->arg[0], r);403 emit(Ostorel, 0, R, i->arg[0], r);
399 emit(Oadd, Kl, r, TMP(SP), getcon(off, fn));404 emit(Oadd, Kl, r, TMP(SP), getcon(off, fn));
400 } else405 }
406 if (i->op == Oargc)
401 blit(TMP(SP), off, i->arg[1], c->size, fn);407 blit(TMP(SP), off, i->arg[1], c->size, fn);
402 off += c->size;408 off += c->size;
403 }409 }
@@ -675,7 +681,6 @@ arm64_abi(Fn *fn) · 271 unmodified lines
675 emiti(*i);681 emiti(*i);
676 break;682 break;
677 case Ocall:683 case Ocall:
678 case Ovacall:
679 for (i0=i; i0>b->ins; i0--)684 for (i0=i; i0>b->ins; i0--)
680 if (!isarg((i0-1)->op))685 if (!isarg((i0-1)->op))
681 break;686 break;
doc/il.txt+3−3
@@ -751,7 +751,7 @@ single-precision floating point number `%f` into `%rs`. · 750 unmodified lines
751 ARG :=751 ARG :=
752 ABITY VAL # Regular argument752 ABITY VAL # Regular argument
753 | 'env' VAL # Environment argument (first)753 | 'env' VAL # Environment argument (first)
754 | '...' # Variadic marker (last)754 | '...' # Variadic marker
755 755
756 ABITY := BASETY | :IDENT756 ABITY := BASETY | :IDENT
757 757
@@ -778,8 +778,8 @@ integer. If the called function does not expect an environment · 20 unmodified lines
778parameter, it will be safely discarded. See the <@ Functions >778parameter, it will be safely discarded. See the <@ Functions >
779section for more information about environment parameters.779section for more information about environment parameters.
780 780
781When the called function is variadic, the last argument781When the called function is variadic, there must be a `...`
782must be `...`.782marker separating the named and variadic arguments.
783 783
784~ Variadic784~ Variadic
785~~~~~~~~~~785~~~~~~~~~~
live.c+1−1
@@ -82,7 +82,7 @@ Again: · 81 unmodified lines
82 for (k=0; k<2; k++)82 for (k=0; k<2; k++)
83 b->nlive[k] = nlv[k];83 b->nlive[k] = nlv[k];
84 for (i=&b->ins[b->nins]; i!=b->ins;) {84 for (i=&b->ins[b->nins]; i!=b->ins;) {
85 if (iscall((--i)->op) && rtype(i->arg[1]) == RCall) {85 if ((--i)->op == Ocall && rtype(i->arg[1]) == RCall) {
86 b->in->t[0] &= ~T.retregs(i->arg[1], m);86 b->in->t[0] &= ~T.retregs(i->arg[1], m);
87 for (k=0; k<2; k++) {87 for (k=0; k<2; k++) {
88 nlv[k] -= m[k];88 nlv[k] -= m[k];
load.c+1−1
@@ -234,7 +234,7 @@ def(Slice sl, bits msk, Blk *b, Ins *i, Loc *il) · 233 unmodified lines
234 while (i > b->ins) {234 while (i > b->ins) {
235 --i;235 --i;
236 if (killsl(i->to, sl)236 if (killsl(i->to, sl)
237 || (iscall(i->op) && escapes(sl.ref, curf)))237 || (i->op == Ocall && escapes(sl.ref, curf)))
238 goto Load;238 goto Load;
239 ld = isload(i->op);239 ld = isload(i->op);
240 if (ld) {240 if (ld) {
ops.h+1−1
@@ -137,8 +137,8 @@ O(pare, T(e,x,e,e, e,x,e,e), 0) X(0, 0, 0) · 136 unmodified lines
137O(arg, T(w,l,s,d, x,x,x,x), 0) X(0, 0, 0)137O(arg, T(w,l,s,d, x,x,x,x), 0) X(0, 0, 0)
138O(argc, T(e,x,e,e, e,l,e,e), 0) X(0, 0, 0)138O(argc, T(e,x,e,e, e,l,e,e), 0) X(0, 0, 0)
139O(arge, T(e,l,e,e, e,x,e,e), 0) X(0, 0, 0)139O(arge, T(e,l,e,e, e,x,e,e), 0) X(0, 0, 0)
140O(argv, T(x,x,x,x, x,x,x,x), 0) X(0, 0, 0)
140O(call, T(m,m,m,m, x,x,x,x), 0) X(0, 0, 0)141O(call, T(m,m,m,m, x,x,x,x), 0) X(0, 0, 0)
141O(vacall, T(m,m,m,m, x,x,x,x), 0) X(0, 0, 0)
142 142
143/* Flags Setting */143/* Flags Setting */
144O(flagieq, T(x,x,e,e, x,x,e,e), 0) X(0, 0, 1)144O(flagieq, T(x,x,e,e, x,x,e,e), 0) X(0, 0, 1)
parse.c+31−17
@@ -450,25 +450,44 @@ parsecls(int *tyn) · 449 unmodified lines
450static int450static int
451parserefl(int arg)451parserefl(int arg)
452{452{
453 int k, ty, env, hasenv;453 int k, ty, env, hasenv, vararg;
454 Ref r;454 Ref r;
455 455
456 hasenv = 0;456 hasenv = 0;
457 vararg = 0;
457 expect(Tlparen);458 expect(Tlparen);
458 while (peek() != Trparen && peek() != Tdots) {459 while (peek() != Trparen) {
459 if (curi - insb >= NIns)460 if (curi - insb >= NIns)
460 err("too many instructions (1)");461 err("too many instructions (1)");
461 env = peek() == Tenv;462 if (!arg && vararg)
462 if (env) {463 err("no parameters allowed after '...'");
464 switch (peek()) {
465 case Tdots:
466 if (vararg)
467 err("only one '...' allowed");
468 vararg = 1;
469 if (arg) {
470 *curi = (Ins){.op = Oargv};
471 curi++;
472 }
473 next();
474 goto Next;
475 case Tenv:
476 if (hasenv)
477 err("only one environment allowed");
478 hasenv = 1;
479 env = 1;
463 next();480 next();
464 k = Kl;481 k = Kl;
465 } else482 break;
483 default:
484 env = 0;
466 k = parsecls(&ty);485 k = parsecls(&ty);
486 break;
487 }
467 r = parseref();488 r = parseref();
468 if (req(r, R))489 if (req(r, R))
469 err("invalid argument");490 err("invalid argument");
470 if (hasenv && env)
471 err("only one environment allowed");
472 if (!arg && rtype(r) != RTmp)491 if (!arg && rtype(r) != RTmp)
473 err("invalid function parameter");492 err("invalid function parameter");
474 if (k == 4)493 if (k == 4)
@@ -487,16 +506,13 @@ parserefl(int arg) · 12 unmodified lines
487 else506 else
488 *curi = (Ins){Opar, k, r, {R}};507 *curi = (Ins){Opar, k, r, {R}};
489 curi++;508 curi++;
490 hasenv |= env;509 Next:
491 if (peek() == Trparen)510 if (peek() == Trparen)
492 break;511 break;
493 expect(Tcomma);512 expect(Tcomma);
494 }513 }
495 if (next() == Tdots) {514 expect(Trparen);
496 expect(Trparen);515 return vararg;
497 return 1;
498 }
499 return 0;
500}516}
501 517
502static Blk *518static Blk *
@@ -621,10 +637,8 @@ DoOp: · 118 unmodified lines
621 }637 }
622 if (op == Tcall) {638 if (op == Tcall) {
623 arg[0] = parseref();639 arg[0] = parseref();
624 if (parserefl(1))640 parserefl(1);
625 op = Ovacall;641 op = Ocall;
626 else
627 op = Ocall;
628 expect(Tnl);642 expect(Tnl);
629 if (k == 4) {643 if (k == 4) {
630 k = Kl;644 k = Kl;
test/_slow.qbe+5−5
@@ -3408,7 +3408,7 @@ function $transparent_crc(l %.1, l %.3, w %.5) { · 3407 unmodified lines
3408 %.9 =l copy $.Lstring.933408 %.9 =l copy $.Lstring.93
3409 %.10 =l loadl %.43409 %.10 =l loadl %.4
3410 %.11 =l loadl %.23410 %.11 =l loadl %.2
3411 %.12 =w call $printf(l %.9, l %.10, l %.11, ...)3411 %.12 =w call $printf(l %.9, ..., l %.10, l %.11)
3412@if_false.6793412@if_false.679
3413 %.13 =l loadl $crc32_context3413 %.13 =l loadl $crc32_context
3414 %.14 =l loadl %.23414 %.14 =l loadl %.2
@@ -3461,7 +3461,7 @@ function $transparent_crc_bytes(l %.1, w %.3, l %.5, w %.7) { · 46 unmodified lines
3461 %.28 =l loadl $crc32_context3461 %.28 =l loadl $crc32_context
3462 %.29 =l copy 42949672953462 %.29 =l copy 4294967295
3463 %.30 =l xor %.28, %.293463 %.30 =l xor %.28, %.29
3464 %.31 =w call $printf(l %.26, l %.27, l %.30, ...)3464 %.31 =w call $printf(l %.26, ..., l %.27, l %.30)
3465@if_false.6873465@if_false.687
3466 ret3466 ret
3467}3467}
@@ -3480,7 +3480,7 @@ function $platform_main_end(l %.1, w %.3) { · 12 unmodified lines
3480@if_true.6903480@if_true.690
3481 %.8 =l copy $.Lstring.973481 %.8 =l copy $.Lstring.97
3482 %.9 =l loadl %.23482 %.9 =l loadl %.2
3483 %.10 =w call $printf(l %.8, l %.9, ...)3483 %.10 =w call $printf(l %.8, ..., l %.9)
3484@if_false.6913484@if_false.691
3485 ret3485 ret
3486}3486}
@@ -35219,7 +35219,7 @@ function w $main(w %.1, l %.3) { · 31732 unmodified lines
35219 %.53 =w loadsw %.535219 %.53 =w loadsw %.5
35220 %.54 =w loadsw %.635220 %.54 =w loadsw %.6
35221 %.55 =w loadsw %.735221 %.55 =w loadsw %.7
35222 %.56 =w call $printf(l %.52, w %.53, w %.54, w %.55, ...)35222 %.56 =w call $printf(l %.52, ..., w %.53, w %.54, w %.55)
35223@if_false.151935223@if_false.1519
35224@for_cont.151635224@for_cont.1516
35225 %.57 =w loadsw %.735225 %.57 =w loadsw %.7
@@ -35338,7 +35338,7 @@ function w $main(w %.1, l %.3) { · 112 unmodified lines
35338@if_true.152435338@if_true.1524
35339 %.138 =l copy $.Lstring.12935339 %.138 =l copy $.Lstring.129
35340 %.139 =w loadsw %.535340 %.139 =w loadsw %.5
35341 %.140 =w call $printf(l %.138, w %.139, ...)35341 %.140 =w call $printf(l %.138, ..., w %.139)
35342@if_false.152535342@if_false.1525
35343@for_cont.152235343@for_cont.1522
35344 %.141 =w loadsw %.535344 %.141 =w loadsw %.5
test/abi5.ssa+9−9
@@ -25,41 +25,41 @@ export · 24 unmodified lines
25function $test() {25function $test() {
26@start26@start
27 %r1 =:st1 call $t1()27 %r1 =:st1 call $t1()
28 %i1 =w call $printf(l $fmt1, l %r1, ...)28 %i1 =w call $printf(l $fmt1, ..., l %r1)
29 29
30 %r2 =:st2 call $t2()30 %r2 =:st2 call $t2()
31 %w2 =w loadw %r231 %w2 =w loadw %r2
32 %i2 =w call $printf(l $fmt2, w %w2, ...)32 %i2 =w call $printf(l $fmt2, ..., w %w2)
33 33
34 %r3 =:st3 call $t3()34 %r3 =:st3 call $t3()
35 %s3 =s loads %r335 %s3 =s loads %r3
36 %r34 =l add %r3, 436 %r34 =l add %r3, 4
37 %w3 =w loadw %r3437 %w3 =w loadw %r34
38 %p3 =d exts %s338 %p3 =d exts %s3
39 %i3 =w call $printf(l $fmt3, d %p3, w %w3, ...)39 %i3 =w call $printf(l $fmt3, ..., d %p3, w %w3)
40 40
41 %r4 =:st4 call $t4()41 %r4 =:st4 call $t4()
42 %w4 =w loadw %r442 %w4 =w loadw %r4
43 %r48 =l add 8, %r443 %r48 =l add 8, %r4
44 %d4 =d loadd %r4844 %d4 =d loadd %r48
45 %i4 =w call $printf(l $fmt4, w %w4, d %d4, ...)45 %i4 =w call $printf(l $fmt4, ..., w %w4, d %d4)
46 46
47 %r5 =:st5 call $t5()47 %r5 =:st5 call $t5()
48 %s5 =s loads %r548 %s5 =s loads %r5
49 %d5 =d exts %s549 %d5 =d exts %s5
50 %r58 =l add %r5, 850 %r58 =l add %r5, 8
51 %l5 =l loadl %r5851 %l5 =l loadl %r58
52 %i5 =w call $printf(l $fmt5, d %d5, l %l5, ...)52 %i5 =w call $printf(l $fmt5, ..., d %d5, l %l5)
53 53
54 %r6 =:st6 call $t6()54 %r6 =:st6 call $t6()
55 %i6 =w call $printf(l $fmt6, l %r6, ...)55 %i6 =w call $printf(l $fmt6, ..., l %r6)
56 56
57 %r7 =:st7 call $t7()57 %r7 =:st7 call $t7()
58 %s7 =s loads %r758 %s7 =s loads %r7
59 %d71 =d exts %s759 %d71 =d exts %s7
60 %r78 =l add %r7, 860 %r78 =l add %r7, 8
61 %d72 =d loadd %r7861 %d72 =d loadd %r78
62 %i7 =w call $printf(l $fmt7, d %d71, d %d72, ...)62 %i7 =w call $printf(l $fmt7, ..., d %d71, d %d72)
63 63
64 %r8 =:st8 call $t8()64 %r8 =:st8 call $t8()
65 %r84 =l add 4, %r865 %r84 =l add 4, %r8
@@ -69,14 +69,14 @@ function $test() { · 3 unmodified lines
69 %w82 =w loadw %r8469 %w82 =w loadw %r84
70 %w83 =w loadw %r8870 %w83 =w loadw %r88
71 %w84 =w loadw %r81271 %w84 =w loadw %r812
72 %i8 =w call $printf(l $fmt8, w %w81, w %w82, w %w83, w %w84, ...)72 %i8 =w call $printf(l $fmt8, ..., w %w81, w %w82, w %w83, w %w84)
73 73
74 %r9 =:st9 call $t9()74 %r9 =:st9 call $t9()
75 %r94 =l add 4, %r975 %r94 =l add 4, %r9
76 %w9 =w loadw %r976 %w9 =w loadw %r9
77 %s9 =s loads %r9477 %s9 =s loads %r94
78 %d9 =d exts %s978 %d9 =d exts %s9
79 %i9 =w call $printf(l $fmt9, w %w9, d %d9, ...)79 %i9 =w call $printf(l $fmt9, ..., w %w9, d %d9)
80 80
81 ret81 ret
82}82}
test/abi6.ssa+2−2
@@ -13,8 +13,8 @@ function $f(:hfa3 %h1, :hfa3 %h2, d %d1, :hfa3 %h3, d %d2) { · 12 unmodified lines
13 call $phfa3(:hfa3 %h1)13 call $phfa3(:hfa3 %h1)
14 call $phfa3(:hfa3 %h2)14 call $phfa3(:hfa3 %h2)
15 call $phfa3(:hfa3 %h3)15 call $phfa3(:hfa3 %h3)
16 call $printf(l $dfmt, d %d1, ...)16 call $printf(l $dfmt, ..., d %d1)
17 call $printf(l $dfmt, d %d2, ...)17 call $printf(l $dfmt, ..., d %d2)
18 ret18 ret
19}19}
20 20
test/echo.ssa+1−1
@@ -20,7 +20,7 @@ function w $main(w %argc, l %argv) { · 19 unmodified lines
20@loop220@loop2
21 %sep =w phi @last 10, @nolast 3221 %sep =w phi @last 10, @nolast 32
22 %arg =l loadl %av22 %arg =l loadl %av
23 %r =w call $printf(l %fmt, l %arg, w %sep, ...)23 %r =w call $printf(l %fmt, ..., l %arg, w %sep)
24 %av1 =l add %av, 824 %av1 =l add %av, 8
25 %ac1 =w sub %ac, 125 %ac1 =w sub %ac, 1
26 jmp @loop26 jmp @loop
test/vararg2.ssa+14−14
@@ -19,11 +19,11 @@ export function $qbeprint0(l %fmt, ...) { · 18 unmodified lines
19 jnz %isg, @casef, @cased19 jnz %isg, @casef, @cased
20@casef20@casef
21 %dbl =d vaarg %vp21 %dbl =d vaarg %vp
22 %r =w call $printf(l %fmtdbl, d %dbl, ...)22 %r =w call $printf(l %fmtdbl, ..., d %dbl)
23 jmp @loop23 jmp @loop
24@cased24@cased
25 %int =w vaarg %vp25 %int =w vaarg %vp
26 %r =w call $printf(l %fmtint, w %int, ...)26 %r =w call $printf(l %fmtint, ..., w %int)
27 jmp @loop27 jmp @loop
28@end28@end
29 %r =w call $puts(l %emptys)29 %r =w call $puts(l %emptys)
@@ -59,11 +59,11 @@ export function $qbeprint1(w %argw0, l %fmt, ...) { · 29 unmodified lines
59 jnz %isg, @casef, @cased59 jnz %isg, @casef, @cased
60@casef60@casef
61 %dbl =d vaarg %vp61 %dbl =d vaarg %vp
62 %r =w call $printf(l %fmtdbl, d %dbl, ...)62 %r =w call $printf(l %fmtdbl, ..., d %dbl)
63 jmp @loop63 jmp @loop
64@cased64@cased
65 %int =w vaarg %vp65 %int =w vaarg %vp
66 %r =w call $printf(l %fmtint, w %int, ...)66 %r =w call $printf(l %fmtint, ..., w %int)
67 jmp @loop67 jmp @loop
68@end68@end
69 %r =w call $puts(l %emptys)69 %r =w call $puts(l %emptys)
@@ -99,11 +99,11 @@ export function $qbeprint2(d %argd0, l %fmt, ...) { · 29 unmodified lines
99 jnz %isg, @casef, @cased99 jnz %isg, @casef, @cased
100@casef100@casef
101 %dbl =d vaarg %vp101 %dbl =d vaarg %vp
102 %r =w call $printf(l %fmtdbl, d %dbl, ...)102 %r =w call $printf(l %fmtdbl, ..., d %dbl)
103 jmp @loop103 jmp @loop
104@cased104@cased
105 %int =w vaarg %vp105 %int =w vaarg %vp
106 %r =w call $printf(l %fmtint, w %int, ...)106 %r =w call $printf(l %fmtint, ..., w %int)
107 jmp @loop107 jmp @loop
108@end108@end
109 %r =w call $puts(l %emptys)109 %r =w call $puts(l %emptys)
@@ -139,11 +139,11 @@ export function $qbeprint3(w %argw0, w %argw1, w %argw2, w %argw3, l %fmt, ...) · 29 unmodified lines
139 jnz %isg, @casef, @cased139 jnz %isg, @casef, @cased
140@casef140@casef
141 %dbl =d vaarg %vp141 %dbl =d vaarg %vp
142 %r =w call $printf(l %fmtdbl, d %dbl, ...)142 %r =w call $printf(l %fmtdbl, ..., d %dbl)
143 jmp @loop143 jmp @loop
144@cased144@cased
145 %int =w vaarg %vp145 %int =w vaarg %vp
146 %r =w call $printf(l %fmtint, w %int, ...)146 %r =w call $printf(l %fmtint, ..., w %int)
147 jmp @loop147 jmp @loop
148@end148@end
149 %r =w call $puts(l %emptys)149 %r =w call $puts(l %emptys)
@@ -179,11 +179,11 @@ export function $qbeprint4(d %argd0, d %argd1, d %argd2, d %argd3, d %argd4, d % · 29 unmodified lines
179 jnz %isg, @casef, @cased179 jnz %isg, @casef, @cased
180@casef180@casef
181 %dbl =d vaarg %vp181 %dbl =d vaarg %vp
182 %r =w call $printf(l %fmtdbl, d %dbl, ...)182 %r =w call $printf(l %fmtdbl, ..., d %dbl)
183 jmp @loop183 jmp @loop
184@cased184@cased
185 %int =w vaarg %vp185 %int =w vaarg %vp
186 %r =w call $printf(l %fmtint, w %int, ...)186 %r =w call $printf(l %fmtint, ..., w %int)
187 jmp @loop187 jmp @loop
188@end188@end
189 %r =w call $puts(l %emptys)189 %r =w call $puts(l %emptys)
@@ -219,11 +219,11 @@ export function $qbeprint5(w %argw0, w %argw1, w %argw2, w %argw3, w %argw4, d % · 29 unmodified lines
219 jnz %isg, @casef, @cased219 jnz %isg, @casef, @cased
220@casef220@casef
221 %dbl =d vaarg %vp221 %dbl =d vaarg %vp
222 %r =w call $printf(l %fmtdbl, d %dbl, ...)222 %r =w call $printf(l %fmtdbl, ..., d %dbl)
223 jmp @loop223 jmp @loop
224@cased224@cased
225 %int =w vaarg %vp225 %int =w vaarg %vp
226 %r =w call $printf(l %fmtint, w %int, ...)226 %r =w call $printf(l %fmtint, ..., w %int)
227 jmp @loop227 jmp @loop
228@end228@end
229 %r =w call $puts(l %emptys)229 %r =w call $puts(l %emptys)
@@ -259,11 +259,11 @@ export function $qbeprint6(w %argw0, w %argw1, w %argw2, w %argw3, w %argw4, w % · 29 unmodified lines
259 jnz %isg, @casef, @cased259 jnz %isg, @casef, @cased
260@casef260@casef
261 %dbl =d vaarg %vp261 %dbl =d vaarg %vp
262 %r =w call $printf(l %fmtdbl, d %dbl, ...)262 %r =w call $printf(l %fmtdbl, ..., d %dbl)
263 jmp @loop263 jmp @loop
264@cased264@cased
265 %int =w vaarg %vp265 %int =w vaarg %vp
266 %r =w call $printf(l %fmtint, w %int, ...)266 %r =w call $printf(l %fmtint, ..., w %int)
267 jmp @loop267 jmp @loop
268@end268@end
269 %r =w call $puts(l %emptys)269 %r =w call $puts(l %emptys)

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t