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, 58, 1, 59, 47, 53, 2,
36 60, 39, 48, 27, 54, 33, 42, 3,
37 61, 51, 37, 40, 49, 18, 28, 20,
38 55, 30, 34, 11, 43, 14, 22, 4,
39 62, 57, 46, 52, 38, 26, 32, 41,
40 50, 36, 17, 19, 29, 10, 13, 21,
41 56, 45, 25, 31, 35, 16, 9, 12,
42 44, 24, 15, 8, 23, 7, 6, 5
48 return ulog2_tab64
[(pow2
* 0x07EDD5E59A4E28C2) >> 58];
54 return (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
);
88 if (KBASE(i
->cls
) == 0)
89 if (rtype(r
) == RCon
) {
92 if (ispow2(c
->bits
.i
)) {
96 i
->arg
[1] = getcon((1ull<<n
) - 1, fn
);
97 } else if (i
->op
== Oudiv
) {
99 i
->arg
[1] = getcon(n
, fn
);
100 } else if (i
->op
== Omul
) {
102 i
->arg
[1] = getcon(n
, fn
);
121 for (b
=fn
->start
; b
; b
=b
->link
) {
123 for (i
=&b
->ins
[b
->nins
]; i
!=b
->ins
;) {
125 ins(&i
, &new, b
, fn
);
128 b
->nins
= &insb
[NIns
] - curi
;
129 idup(&b
->ins
, curi
, b
->nins
);