1
2
3 package ssa
4
5 func rewriteValueRISCV64latelower(v *Value) bool {
6 switch v.Op {
7 case OpRISCV64AND:
8 return rewriteValueRISCV64latelower_OpRISCV64AND(v)
9 case OpRISCV64NOT:
10 return rewriteValueRISCV64latelower_OpRISCV64NOT(v)
11 case OpRISCV64OR:
12 return rewriteValueRISCV64latelower_OpRISCV64OR(v)
13 case OpRISCV64SLLI:
14 return rewriteValueRISCV64latelower_OpRISCV64SLLI(v)
15 case OpRISCV64SRAI:
16 return rewriteValueRISCV64latelower_OpRISCV64SRAI(v)
17 case OpRISCV64SRLI:
18 return rewriteValueRISCV64latelower_OpRISCV64SRLI(v)
19 case OpRISCV64XOR:
20 return rewriteValueRISCV64latelower_OpRISCV64XOR(v)
21 }
22 return false
23 }
24 func rewriteValueRISCV64latelower_OpRISCV64AND(v *Value) bool {
25 v_1 := v.Args[1]
26 v_0 := v.Args[0]
27
28
29 for {
30 for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 {
31 x := v_0
32 if v_1.Op != OpRISCV64NOT {
33 continue
34 }
35 y := v_1.Args[0]
36 v.reset(OpRISCV64ANDN)
37 v.AddArg2(x, y)
38 return true
39 }
40 break
41 }
42 return false
43 }
44 func rewriteValueRISCV64latelower_OpRISCV64NOT(v *Value) bool {
45 v_0 := v.Args[0]
46
47
48 for {
49 if v_0.Op != OpRISCV64XOR {
50 break
51 }
52 y := v_0.Args[1]
53 x := v_0.Args[0]
54 v.reset(OpRISCV64XNOR)
55 v.AddArg2(x, y)
56 return true
57 }
58 return false
59 }
60 func rewriteValueRISCV64latelower_OpRISCV64OR(v *Value) bool {
61 v_1 := v.Args[1]
62 v_0 := v.Args[0]
63
64
65 for {
66 for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 {
67 x := v_0
68 if v_1.Op != OpRISCV64NOT {
69 continue
70 }
71 y := v_1.Args[0]
72 v.reset(OpRISCV64ORN)
73 v.AddArg2(x, y)
74 return true
75 }
76 break
77 }
78 return false
79 }
80 func rewriteValueRISCV64latelower_OpRISCV64SLLI(v *Value) bool {
81 v_0 := v.Args[0]
82 b := v.Block
83 typ := &b.Func.Config.Types
84
85
86
87 for {
88 c := auxIntToInt64(v.AuxInt)
89 if v_0.Op != OpRISCV64MOVBUreg {
90 break
91 }
92 x := v_0.Args[0]
93 if !(c <= 56) {
94 break
95 }
96 v.reset(OpRISCV64SRLI)
97 v.AuxInt = int64ToAuxInt(56 - c)
98 v0 := b.NewValue0(v.Pos, OpRISCV64SLLI, typ.UInt64)
99 v0.AuxInt = int64ToAuxInt(56)
100 v0.AddArg(x)
101 v.AddArg(v0)
102 return true
103 }
104
105
106
107 for {
108 c := auxIntToInt64(v.AuxInt)
109 if v_0.Op != OpRISCV64MOVHUreg {
110 break
111 }
112 x := v_0.Args[0]
113 if !(c <= 48) {
114 break
115 }
116 v.reset(OpRISCV64SRLI)
117 v.AuxInt = int64ToAuxInt(48 - c)
118 v0 := b.NewValue0(v.Pos, OpRISCV64SLLI, typ.UInt64)
119 v0.AuxInt = int64ToAuxInt(48)
120 v0.AddArg(x)
121 v.AddArg(v0)
122 return true
123 }
124
125
126
127 for {
128 c := auxIntToInt64(v.AuxInt)
129 if v_0.Op != OpRISCV64MOVWUreg {
130 break
131 }
132 x := v_0.Args[0]
133 if !(c <= 32) {
134 break
135 }
136 v.reset(OpRISCV64SRLI)
137 v.AuxInt = int64ToAuxInt(32 - c)
138 v0 := b.NewValue0(v.Pos, OpRISCV64SLLI, typ.UInt64)
139 v0.AuxInt = int64ToAuxInt(32)
140 v0.AddArg(x)
141 v.AddArg(v0)
142 return true
143 }
144
145
146 for {
147 if auxIntToInt64(v.AuxInt) != 0 {
148 break
149 }
150 x := v_0
151 v.copyOf(x)
152 return true
153 }
154 return false
155 }
156 func rewriteValueRISCV64latelower_OpRISCV64SRAI(v *Value) bool {
157 v_0 := v.Args[0]
158 b := v.Block
159 typ := &b.Func.Config.Types
160
161
162
163 for {
164 c := auxIntToInt64(v.AuxInt)
165 if v_0.Op != OpRISCV64MOVBreg {
166 break
167 }
168 x := v_0.Args[0]
169 if !(c < 8) {
170 break
171 }
172 v.reset(OpRISCV64SRAI)
173 v.AuxInt = int64ToAuxInt(56 + c)
174 v0 := b.NewValue0(v.Pos, OpRISCV64SLLI, typ.Int64)
175 v0.AuxInt = int64ToAuxInt(56)
176 v0.AddArg(x)
177 v.AddArg(v0)
178 return true
179 }
180
181
182
183 for {
184 c := auxIntToInt64(v.AuxInt)
185 if v_0.Op != OpRISCV64MOVHreg {
186 break
187 }
188 x := v_0.Args[0]
189 if !(c < 16) {
190 break
191 }
192 v.reset(OpRISCV64SRAI)
193 v.AuxInt = int64ToAuxInt(48 + c)
194 v0 := b.NewValue0(v.Pos, OpRISCV64SLLI, typ.Int64)
195 v0.AuxInt = int64ToAuxInt(48)
196 v0.AddArg(x)
197 v.AddArg(v0)
198 return true
199 }
200
201
202
203 for {
204 c := auxIntToInt64(v.AuxInt)
205 if v_0.Op != OpRISCV64MOVWreg {
206 break
207 }
208 x := v_0.Args[0]
209 if !(c < 32) {
210 break
211 }
212 v.reset(OpRISCV64SRAI)
213 v.AuxInt = int64ToAuxInt(32 + c)
214 v0 := b.NewValue0(v.Pos, OpRISCV64SLLI, typ.Int64)
215 v0.AuxInt = int64ToAuxInt(32)
216 v0.AddArg(x)
217 v.AddArg(v0)
218 return true
219 }
220
221
222 for {
223 if auxIntToInt64(v.AuxInt) != 0 {
224 break
225 }
226 x := v_0
227 v.copyOf(x)
228 return true
229 }
230 return false
231 }
232 func rewriteValueRISCV64latelower_OpRISCV64SRLI(v *Value) bool {
233 v_0 := v.Args[0]
234 b := v.Block
235 typ := &b.Func.Config.Types
236
237
238
239 for {
240 c := auxIntToInt64(v.AuxInt)
241 if v_0.Op != OpRISCV64MOVBUreg {
242 break
243 }
244 x := v_0.Args[0]
245 if !(c < 8) {
246 break
247 }
248 v.reset(OpRISCV64SRLI)
249 v.AuxInt = int64ToAuxInt(56 + c)
250 v0 := b.NewValue0(v.Pos, OpRISCV64SLLI, typ.UInt64)
251 v0.AuxInt = int64ToAuxInt(56)
252 v0.AddArg(x)
253 v.AddArg(v0)
254 return true
255 }
256
257
258
259 for {
260 c := auxIntToInt64(v.AuxInt)
261 if v_0.Op != OpRISCV64MOVHUreg {
262 break
263 }
264 x := v_0.Args[0]
265 if !(c < 16) {
266 break
267 }
268 v.reset(OpRISCV64SRLI)
269 v.AuxInt = int64ToAuxInt(48 + c)
270 v0 := b.NewValue0(v.Pos, OpRISCV64SLLI, typ.UInt64)
271 v0.AuxInt = int64ToAuxInt(48)
272 v0.AddArg(x)
273 v.AddArg(v0)
274 return true
275 }
276
277
278
279 for {
280 c := auxIntToInt64(v.AuxInt)
281 if v_0.Op != OpRISCV64MOVWUreg {
282 break
283 }
284 x := v_0.Args[0]
285 if !(c < 32) {
286 break
287 }
288 v.reset(OpRISCV64SRLI)
289 v.AuxInt = int64ToAuxInt(32 + c)
290 v0 := b.NewValue0(v.Pos, OpRISCV64SLLI, typ.UInt64)
291 v0.AuxInt = int64ToAuxInt(32)
292 v0.AddArg(x)
293 v.AddArg(v0)
294 return true
295 }
296
297
298 for {
299 if auxIntToInt64(v.AuxInt) != 0 {
300 break
301 }
302 x := v_0
303 v.copyOf(x)
304 return true
305 }
306 return false
307 }
308 func rewriteValueRISCV64latelower_OpRISCV64XOR(v *Value) bool {
309 v_1 := v.Args[1]
310 v_0 := v.Args[0]
311
312
313 for {
314 for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 {
315 x := v_0
316 if v_1.Op != OpRISCV64NOT {
317 continue
318 }
319 y := v_1.Args[0]
320 v.reset(OpRISCV64XNOR)
321 v.AddArg2(x, y)
322 return true
323 }
324 break
325 }
326 return false
327 }
328 func rewriteBlockRISCV64latelower(b *Block) bool {
329 return false
330 }
331
View as plain text