qbe

Internal scc patchset buffer for QBE
Log | Files | Refs | README | LICENSE

abi8.ssa (7357B)


      1 # riscv64 ABI stress
      2 # see tools/abi8.py
      3 
      4 type :fi1 = { h, s }   # in a gp & fp pair
      5 type :fi2 = { s, w }   # ditto
      6 type :uw = { { w } }
      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 
     14 data $ctoqbestr = { b "c->qbe(%d)", b 0 }
     15 data $emptystr = { b 0 }
     16 
     17 export
     18 function $qfn0(s %p0, s %p1, s %p2, s %p3, s %p4, s %p5, s %p6, s %p7, s %p8) {
     19 @start
     20 	%r0 =w call $printf(l $ctoqbestr, ..., w 0)
     21 	call $ps(s %p8)
     22 	%r1 =w call $puts(l $emptystr)
     23 	ret
     24 }
     25 export
     26 function $qfn1(w %p0, s %p1, :fi1 %p2) {
     27 @start
     28 	%r0 =w call $printf(l $ctoqbestr, ..., w 1)
     29 	call $pw(w %p0)
     30 	call $ps(s %p1)
     31 	call $pfi1(l %p2)
     32 	%r1 =w call $puts(l $emptystr)
     33 	ret
     34 }
     35 export
     36 function $qfn2(w %p0, :fi2 %p1, s %p2) {
     37 @start
     38 	%r0 =w call $printf(l $ctoqbestr, ..., w 2)
     39 	call $pw(w %p0)
     40 	call $pfi2(l %p1)
     41 	call $ps(s %p2)
     42 	%r1 =w call $puts(l $emptystr)
     43 	ret
     44 }
     45 export
     46 function $qfn3(w %p0, s %p1, :fi3 %p2) {
     47 @start
     48 	%r0 =w call $printf(l $ctoqbestr, ..., w 3)
     49 	call $pw(w %p0)
     50 	call $ps(s %p1)
     51 	call $pfi3(l %p2)
     52 	%r1 =w call $puts(l $emptystr)
     53 	ret
     54 }
     55 export
     56 function $qfn4(:ss %p0) {
     57 @start
     58 	%r0 =w call $printf(l $ctoqbestr, ..., w 4)
     59 	call $pss(l %p0)
     60 	%r1 =w call $puts(l $emptystr)
     61 	ret
     62 }
     63 export
     64 function $qfn5(d %p0, d %p1, d %p2, d %p3, d %p4, d %p5, d %p6, :ss %p7, s %p8, l %p9) {
     65 @start
     66 	%r0 =w call $printf(l $ctoqbestr, ..., w 5)
     67 	call $pss(l %p7)
     68 	call $ps(s %p8)
     69 	call $pl(l %p9)
     70 	%r1 =w call $puts(l $emptystr)
     71 	ret
     72 }
     73 export
     74 function $qfn6(:lb %p0) {
     75 @start
     76 	%r0 =w call $printf(l $ctoqbestr, ..., w 6)
     77 	call $plb(l %p0)
     78 	%r1 =w call $puts(l $emptystr)
     79 	ret
     80 }
     81 export
     82 function $qfn7(w %p0, w %p1, w %p2, w %p3, w %p4, w %p5, w %p6, :lb %p7) {
     83 @start
     84 	%r0 =w call $printf(l $ctoqbestr, ..., w 7)
     85 	call $plb(l %p7)
     86 	%r1 =w call $puts(l $emptystr)
     87 	ret
     88 }
     89 export
     90 function $qfn8(w %p0, w %p1, w %p2, w %p3, w %p4, w %p5, w %p6, w %p7, :lb %p8) {
     91 @start
     92 	%r0 =w call $printf(l $ctoqbestr, ..., w 8)
     93 	call $plb(l %p8)
     94 	%r1 =w call $puts(l $emptystr)
     95 	ret
     96 }
     97 export
     98 function $qfn9(:big %p0) {
     99 @start
    100 	%r0 =w call $printf(l $ctoqbestr, ..., w 9)
    101 	call $pbig(l %p0)
    102 	%r1 =w call $puts(l $emptystr)
    103 	ret
    104 }
    105 export
    106 function $qfn10(w %p0, w %p1, w %p2, w %p3, w %p4, w %p5, w %p6, w %p7, :big %p8, s %p9, l %p10) {
    107 @start
    108 	%r0 =w call $printf(l $ctoqbestr, ..., w 10)
    109 	call $pbig(l %p8)
    110 	call $ps(s %p9)
    111 	call $pl(l %p10)
    112 	%r1 =w call $puts(l $emptystr)
    113 	ret
    114 }
    115 
    116 export
    117 function w $main() {
    118 @start
    119 
    120 	call $cfn0(s 0, s 0, s 0, s 0, s 0, s 0, s 0, s 0, s s_9.9)
    121 	call $cfn1(w 1, s s_2.2, :fi1 $fi1)
    122 	call $cfn2(w 1, :fi2 $fi2, s s_3.3)
    123 	call $cfn3(w 1, s s_2.2, :fi3 $fi3)
    124 	call $cfn4(:ss $ss)
    125 	call $cfn5(d 0, d 0, d 0, d 0, d 0, d 0, d 0, :ss $ss, s s_9.9, l 10)
    126 	call $cfn6(:lb $lb)
    127 	call $cfn7(w 0, w 0, w 0, w 0, w 0, w 0, w 0, :lb $lb)
    128 	call $cfn8(w 0, w 0, w 0, w 0, w 0, w 0, w 0, w 0, :lb $lb)
    129 	call $cfn9(:big $big)
    130 	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)
    131 
    132 	ret 0
    133 }
    134 
    135 # >>> driver
    136 # #include <stdio.h>
    137 # typedef struct { short h; float s; } Sfi1;
    138 # typedef struct { float s; int w; } Sfi2;
    139 # typedef struct { float s; union { int w; } u; } Sfi3;
    140 # typedef struct { float s0, s1; } Sss;
    141 # typedef struct { float s; double d; } Ssd;
    142 # typedef struct { int w0, w1; } Sww;
    143 # typedef struct { long l; char b; } Slb;
    144 # typedef struct { char b[17]; } Sbig;
    145 # Sfi1 zfi1, fi1 = { -123, 4.56 };
    146 # Sfi2 zfi2, fi2 = { 1.23, 456 };
    147 # Sfi3 zfi3, fi3 = { 3.45, 567 };
    148 # Sss zss, ss = { 1.23, 45.6 };
    149 # Ssd zsd, sd = { 2.34, 5.67 };
    150 # Sww zww, ww = { -123, -456 };
    151 # Slb zlb, lb = { 123, 'z' };
    152 # Sbig zbig, big = { "abcdefhijklmnopqr" };
    153 # void pfi1(Sfi1 *s) { printf(" { %d, %g }", s->h, s->s); }
    154 # void pfi2(Sfi2 *s) { printf(" { %g, %d }", s->s, s->w); }
    155 # void pfi3(Sfi3 *s) { printf(" { %g, %d }", s->s, s->u.w); }
    156 # void pss(Sss *s) { printf(" { %g, %g }", s->s0, s->s1); }
    157 # void psd(Ssd *s) { printf(" { %g, %g }", s->s, s->d); }
    158 # void pww(Sww *s) { printf(" { %d, %d }", s->w0, s->w1); }
    159 # void plb(Slb *s) { printf(" { %ld, '%c' }", s->l, s->b); }
    160 # void pbig(Sbig *s) { printf(" \"%.17s\"", s->b); }
    161 # void pw(int w) { printf(" %d", w); }
    162 # void pl(long l) { printf(" %ld", l); }
    163 # void ps(float s) { printf(" %g", s); }
    164 # void pd(double d) { printf(" %g", d); }
    165 # /* --------------------------- */
    166 # extern void qfn0(float, float, float, float, float, float, float, float, float);
    167 # void cfn0(float p0, float p1, float p2, float p3, float p4, float p5, float p6, float p7, float p8) {
    168 # 	printf("qbe->c(%d)", 0);
    169 # 	ps(p8); puts("");
    170 # 	qfn0(p0, p1, p2, p3, p4, p5, p6, p7, p8);
    171 # }
    172 # extern void qfn1(int, float, Sfi1);
    173 # void cfn1(int p0, float p1, Sfi1 p2) {
    174 # 	printf("qbe->c(%d)", 1);
    175 # 	pw(p0); ps(p1); pfi1(&p2); puts("");
    176 # 	qfn1(p0, p1, p2);
    177 # }
    178 # extern void qfn2(int, Sfi2, float);
    179 # void cfn2(int p0, Sfi2 p1, float p2) {
    180 # 	printf("qbe->c(%d)", 2);
    181 # 	pw(p0); pfi2(&p1); ps(p2); puts("");
    182 # 	qfn2(p0, p1, p2);
    183 # }
    184 # extern void qfn3(int, float, Sfi3);
    185 # void cfn3(int p0, float p1, Sfi3 p2) {
    186 # 	printf("qbe->c(%d)", 3);
    187 # 	pw(p0); ps(p1); pfi3(&p2); puts("");
    188 # 	qfn3(p0, p1, p2);
    189 # }
    190 # extern void qfn4(Sss);
    191 # void cfn4(Sss p0) {
    192 # 	printf("qbe->c(%d)", 4);
    193 # 	pss(&p0); puts("");
    194 # 	qfn4(p0);
    195 # }
    196 # extern void qfn5(double, double, double, double, double, double, double, Sss, float, long);
    197 # void cfn5(double p0, double p1, double p2, double p3, double p4, double p5, double p6, Sss p7, float p8, long p9) {
    198 # 	printf("qbe->c(%d)", 5);
    199 # 	pss(&p7); ps(p8); pl(p9); puts("");
    200 # 	qfn5(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9);
    201 # }
    202 # extern void qfn6(Slb);
    203 # void cfn6(Slb p0) {
    204 # 	printf("qbe->c(%d)", 6);
    205 # 	plb(&p0); puts("");
    206 # 	qfn6(p0);
    207 # }
    208 # extern void qfn7(int, int, int, int, int, int, int, Slb);
    209 # void cfn7(int p0, int p1, int p2, int p3, int p4, int p5, int p6, Slb p7) {
    210 # 	printf("qbe->c(%d)", 7);
    211 # 	plb(&p7); puts("");
    212 # 	qfn7(p0, p1, p2, p3, p4, p5, p6, p7);
    213 # }
    214 # extern void qfn8(int, int, int, int, int, int, int, int, Slb);
    215 # void cfn8(int p0, int p1, int p2, int p3, int p4, int p5, int p6, int p7, Slb p8) {
    216 # 	printf("qbe->c(%d)", 8);
    217 # 	plb(&p8); puts("");
    218 # 	qfn8(p0, p1, p2, p3, p4, p5, p6, p7, p8);
    219 # }
    220 # extern void qfn9(Sbig);
    221 # void cfn9(Sbig p0) {
    222 # 	printf("qbe->c(%d)", 9);
    223 # 	pbig(&p0); puts("");
    224 # 	qfn9(p0);
    225 # }
    226 # extern void qfn10(int, int, int, int, int, int, int, int, Sbig, float, long);
    227 # void cfn10(int p0, int p1, int p2, int p3, int p4, int p5, int p6, int p7, Sbig p8, float p9, long p10) {
    228 # 	printf("qbe->c(%d)", 10);
    229 # 	pbig(&p8); ps(p9); pl(p10); puts("");
    230 # 	qfn10(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10);
    231 # }
    232 # <<<
    233 
    234 # >>> output
    235 # qbe->c(0) 9.9
    236 # c->qbe(0) 9.9
    237 # qbe->c(1) 1 2.2 { -123, 4.56 }
    238 # c->qbe(1) 1 2.2 { -123, 4.56 }
    239 # qbe->c(2) 1 { 1.23, 456 } 3.3
    240 # c->qbe(2) 1 { 1.23, 456 } 3.3
    241 # qbe->c(3) 1 2.2 { 3.45, 567 }
    242 # c->qbe(3) 1 2.2 { 3.45, 567 }
    243 # qbe->c(4) { 1.23, 45.6 }
    244 # c->qbe(4) { 1.23, 45.6 }
    245 # qbe->c(5) { 1.23, 45.6 } 9.9 10
    246 # c->qbe(5) { 1.23, 45.6 } 9.9 10
    247 # qbe->c(6) { 123, 'z' }
    248 # c->qbe(6) { 123, 'z' }
    249 # qbe->c(7) { 123, 'z' }
    250 # c->qbe(7) { 123, 'z' }
    251 # qbe->c(8) { 123, 'z' }
    252 # c->qbe(8) { 123, 'z' }
    253 # qbe->c(9) "abcdefhijklmnopqr"
    254 # c->qbe(9) "abcdefhijklmnopqr"
    255 # qbe->c(10) "abcdefhijklmnopqr" 10.1 11
    256 # c->qbe(10) "abcdefhijklmnopqr" 10.1 11
    257 # <<<