4 blit(Ref sd
[2], int sz
, Fn
*fn
)
6 struct { int st
, ld
, cls
, size
; } *p
, tbl
[] = {
7 { Ostorel
, Oload
, Kl
, 8 },
8 { Ostorew
, Oload
, Kw
, 4 },
9 { Ostoreh
, Oloaduh
, Kw
, 2 },
10 { Ostoreb
, Oloadub
, Kw
, 1 }
19 for (n
=p
->size
; sz
>=n
; sz
-=n
) {
21 r
= newtmp("blt", Kl
, fn
);
22 r1
= newtmp("blt", Kl
, fn
);
24 emit(p
->st
, 0, R
, r
, r1
);
25 emit(Oadd
, Kl
, r1
, sd
[1], ro
);
26 r1
= newtmp("blt", Kl
, fn
);
27 emit(p
->ld
, p
->cls
, r
, r1
, R
);
28 emit(Oadd
, Kl
, r1
, sd
[0], ro
);
35 63, 0, 1, 41, 37, 2, 16, 42,
36 38, 29, 32, 3, 12, 17, 43, 55,
37 39, 35, 30, 53, 33, 21, 4, 23,
38 13, 9, 18, 6, 25, 44, 48, 56,
39 62, 40, 36, 15, 28, 31, 11, 54,
40 34, 52, 20, 22, 8, 5, 24, 47,
41 61, 14, 27, 10, 51, 19, 7, 46,
42 60, 26, 50, 45, 59, 49, 58, 57,
48 return ulog2_tab64
[(pow2
* 0x5b31ab928877a7e) >> 58];
54 return v
&& (v
& (v
- 1)) == 0;
58 ins(Ins
**pi
, int *new, Blk
*b
, Fn
*fn
)
67 /* simplify more instructions here;
68 * copy 0 into xor, bit rotations,
73 assert((i
-1)->op
== Oblit0
);
76 ni
= &b
->ins
[b
->nins
] - (i
+1);
81 blit((i
-1)->arg
, rsval(i
->arg
[0]), fn
);
87 if (KBASE(i
->cls
) == 0)
88 if (rtype(r
) == RCon
) {
91 if (ispow2(c
->bits
.i
)) {
95 i
->arg
[1] = getcon((1ull<<n
) - 1, fn
);
98 i
->arg
[1] = getcon(n
, fn
);
115 for (b
=fn
->start
; b
; b
=b
->link
) {
117 for (i
=&b
->ins
[b
->nins
]; i
!=b
->ins
;) {
119 ins(&i
, &new, b
, fn
);
122 b
->nins
= &insb
[NIns
] - curi
;
123 idup(&b
->ins
, curi
, b
->nins
);