|
34 | 34 | (Mul32uhilo x y) -> (MULLU x y)
|
35 | 35 |
|
36 | 36 | (Div32 x y) ->
|
37 |
| - (SUB (XOR <config.fe.TypeUInt32()> // negate the result if one operand is negative |
38 |
| - (Select0 <config.fe.TypeUInt32()> (CALLudiv {config.ctxt.Lookup("udiv", 0)} |
39 |
| - (SUB <config.fe.TypeUInt32()> (XOR x <config.fe.TypeUInt32()> (Signmask x)) (Signmask x)) // negate x if negative |
40 |
| - (SUB <config.fe.TypeUInt32()> (XOR y <config.fe.TypeUInt32()> (Signmask y)) (Signmask y)))) // negate y if negative |
41 |
| - (Signmask (XOR <config.fe.TypeUInt32()> x y))) (Signmask (XOR <config.fe.TypeUInt32()> x y))) |
42 |
| -(Div32u x y) -> (Select0 <config.fe.TypeUInt32()> (CALLudiv {config.ctxt.Lookup("udiv", 0)} x y)) |
| 37 | + (SUB (XOR <fe.TypeUInt32()> // negate the result if one operand is negative |
| 38 | + (Select0 <fe.TypeUInt32()> (CALLudiv {config.ctxt.Lookup("udiv", 0)} |
| 39 | + (SUB <fe.TypeUInt32()> (XOR x <fe.TypeUInt32()> (Signmask x)) (Signmask x)) // negate x if negative |
| 40 | + (SUB <fe.TypeUInt32()> (XOR y <fe.TypeUInt32()> (Signmask y)) (Signmask y)))) // negate y if negative |
| 41 | + (Signmask (XOR <fe.TypeUInt32()> x y))) (Signmask (XOR <fe.TypeUInt32()> x y))) |
| 42 | +(Div32u x y) -> (Select0 <fe.TypeUInt32()> (CALLudiv {config.ctxt.Lookup("udiv", 0)} x y)) |
43 | 43 | (Div16 x y) -> (Div32 (SignExt16to32 x) (SignExt16to32 y))
|
44 | 44 | (Div16u x y) -> (Div32u (ZeroExt16to32 x) (ZeroExt16to32 y))
|
45 | 45 | (Div8 x y) -> (Div32 (SignExt8to32 x) (SignExt8to32 y))
|
|
48 | 48 | (Div64F x y) -> (DIVD x y)
|
49 | 49 |
|
50 | 50 | (Mod32 x y) ->
|
51 |
| - (SUB (XOR <config.fe.TypeUInt32()> // negate the result if x is negative |
52 |
| - (Select1 <config.fe.TypeUInt32()> (CALLudiv {config.ctxt.Lookup("udiv", 0)} |
53 |
| - (SUB <config.fe.TypeUInt32()> (XOR <config.fe.TypeUInt32()> x (Signmask x)) (Signmask x)) // negate x if negative |
54 |
| - (SUB <config.fe.TypeUInt32()> (XOR <config.fe.TypeUInt32()> y (Signmask y)) (Signmask y)))) // negate y if negative |
| 51 | + (SUB (XOR <fe.TypeUInt32()> // negate the result if x is negative |
| 52 | + (Select1 <fe.TypeUInt32()> (CALLudiv {config.ctxt.Lookup("udiv", 0)} |
| 53 | + (SUB <fe.TypeUInt32()> (XOR <fe.TypeUInt32()> x (Signmask x)) (Signmask x)) // negate x if negative |
| 54 | + (SUB <fe.TypeUInt32()> (XOR <fe.TypeUInt32()> y (Signmask y)) (Signmask y)))) // negate y if negative |
55 | 55 | (Signmask x)) (Signmask x))
|
56 |
| -(Mod32u x y) -> (Select1 <config.fe.TypeUInt32()> (CALLudiv {config.ctxt.Lookup("udiv", 0)} x y)) |
| 56 | +(Mod32u x y) -> (Select1 <fe.TypeUInt32()> (CALLudiv {config.ctxt.Lookup("udiv", 0)} x y)) |
57 | 57 | (Mod16 x y) -> (Mod32 (SignExt16to32 x) (SignExt16to32 y))
|
58 | 58 | (Mod16u x y) -> (Mod32u (ZeroExt16to32 x) (ZeroExt16to32 y))
|
59 | 59 | (Mod8 x y) -> (Mod32 (SignExt8to32 x) (SignExt8to32 y))
|
|
111 | 111 | // boolean ops -- booleans are represented with 0=false, 1=true
|
112 | 112 | (AndB x y) -> (AND x y)
|
113 | 113 | (OrB x y) -> (OR x y)
|
114 |
| -(EqB x y) -> (XORconst [1] (XOR <config.fe.TypeBool()> x y)) |
| 114 | +(EqB x y) -> (XORconst [1] (XOR <fe.TypeBool()> x y)) |
115 | 115 | (NeqB x y) -> (XOR x y)
|
116 | 116 | (Not x) -> (XORconst [1] x)
|
117 | 117 |
|
|
160 | 160 | (Rsh32x64 x (Const64 [c])) && uint64(c) < 32 -> (SRAconst x [c])
|
161 | 161 | (Rsh32Ux64 x (Const64 [c])) && uint64(c) < 32 -> (SRLconst x [c])
|
162 | 162 | (Lsh16x64 x (Const64 [c])) && uint64(c) < 16 -> (SLLconst x [c])
|
163 |
| -(Rsh16x64 x (Const64 [c])) && uint64(c) < 16 -> (SRAconst (SLLconst <config.fe.TypeUInt32()> x [16]) [c+16]) |
164 |
| -(Rsh16Ux64 x (Const64 [c])) && uint64(c) < 16 -> (SRLconst (SLLconst <config.fe.TypeUInt32()> x [16]) [c+16]) |
| 163 | +(Rsh16x64 x (Const64 [c])) && uint64(c) < 16 -> (SRAconst (SLLconst <fe.TypeUInt32()> x [16]) [c+16]) |
| 164 | +(Rsh16Ux64 x (Const64 [c])) && uint64(c) < 16 -> (SRLconst (SLLconst <fe.TypeUInt32()> x [16]) [c+16]) |
165 | 165 | (Lsh8x64 x (Const64 [c])) && uint64(c) < 8 -> (SLLconst x [c])
|
166 |
| -(Rsh8x64 x (Const64 [c])) && uint64(c) < 8 -> (SRAconst (SLLconst <config.fe.TypeUInt32()> x [24]) [c+24]) |
167 |
| -(Rsh8Ux64 x (Const64 [c])) && uint64(c) < 8 -> (SRLconst (SLLconst <config.fe.TypeUInt32()> x [24]) [c+24]) |
| 166 | +(Rsh8x64 x (Const64 [c])) && uint64(c) < 8 -> (SRAconst (SLLconst <fe.TypeUInt32()> x [24]) [c+24]) |
| 167 | +(Rsh8Ux64 x (Const64 [c])) && uint64(c) < 8 -> (SRLconst (SLLconst <fe.TypeUInt32()> x [24]) [c+24]) |
168 | 168 |
|
169 | 169 | // large constant shifts
|
170 | 170 | (Lsh32x64 _ (Const64 [c])) && uint64(c) >= 32 -> (Const32 [0])
|
|
176 | 176 |
|
177 | 177 | // large constant signed right shift, we leave the sign bit
|
178 | 178 | (Rsh32x64 x (Const64 [c])) && uint64(c) >= 32 -> (SRAconst x [31])
|
179 |
| -(Rsh16x64 x (Const64 [c])) && uint64(c) >= 16 -> (SRAconst (SLLconst <config.fe.TypeUInt32()> x [16]) [31]) |
180 |
| -(Rsh8x64 x (Const64 [c])) && uint64(c) >= 8 -> (SRAconst (SLLconst <config.fe.TypeUInt32()> x [24]) [31]) |
| 179 | +(Rsh16x64 x (Const64 [c])) && uint64(c) >= 16 -> (SRAconst (SLLconst <fe.TypeUInt32()> x [16]) [31]) |
| 180 | +(Rsh8x64 x (Const64 [c])) && uint64(c) >= 8 -> (SRAconst (SLLconst <fe.TypeUInt32()> x [24]) [31]) |
181 | 181 |
|
182 | 182 | // constants
|
183 | 183 | (Const8 [val]) -> (MOVWconst [val])
|
|
204 | 204 | (SignExt16to32 x) -> (MOVHreg x)
|
205 | 205 |
|
206 | 206 | (Signmask x) -> (SRAconst x [31])
|
207 |
| -(Zeromask x) -> (SRAconst (RSBshiftRL <config.fe.TypeInt32()> x x [1]) [31]) // sign bit of uint32(x)>>1 - x |
| 207 | +(Zeromask x) -> (SRAconst (RSBshiftRL <fe.TypeInt32()> x x [1]) [31]) // sign bit of uint32(x)>>1 - x |
208 | 208 | (Slicemask <t> x) -> (SRAconst (RSBconst <t> [0] x) [31])
|
209 | 209 |
|
210 | 210 | // float <-> int conversion
|
|
0 commit comments