blob: 3ec41181cc2bdf3d729cfb8962c5b2254a9d0632 [file] [log] [blame]
Keith Randall0dca7352015-06-06 16:03:33 -07001// autogenerated from gen/generic.rules: do not edit!
2// generated with: cd gen; go run *.go
3package ssa
4
5func rewriteValuegeneric(v *Value, config *Config) bool {
Keith Randall683f5d72015-08-04 12:24:23 -07006 b := v.Block
Keith Randall0dca7352015-06-06 16:03:33 -07007 switch v.Op {
Keith Randall67fdb0d2015-07-19 15:48:20 -07008 case OpAdd64:
Keith Randall9cb332e2015-07-28 14:19:20 -07009 // match: (Add64 (Const64 [c]) (Const64 [d]))
Keith Randall67fdb0d2015-07-19 15:48:20 -070010 // cond:
Keith Randall9cb332e2015-07-28 14:19:20 -070011 // result: (Const64 [c+d])
Keith Randall0dca7352015-06-06 16:03:33 -070012 {
Keith Randall9cb332e2015-07-28 14:19:20 -070013 if v.Args[0].Op != OpConst64 {
14 goto end8c46df6f85a11cb1d594076b0e467908
Keith Randall0dca7352015-06-06 16:03:33 -070015 }
Keith Randall8f22b522015-06-11 21:29:25 -070016 c := v.Args[0].AuxInt
Keith Randall9cb332e2015-07-28 14:19:20 -070017 if v.Args[1].Op != OpConst64 {
18 goto end8c46df6f85a11cb1d594076b0e467908
Keith Randall0dca7352015-06-06 16:03:33 -070019 }
Keith Randall8f22b522015-06-11 21:29:25 -070020 d := v.Args[1].AuxInt
Keith Randall9cb332e2015-07-28 14:19:20 -070021 v.Op = OpConst64
Keith Randall8f22b522015-06-11 21:29:25 -070022 v.AuxInt = 0
Keith Randall0dca7352015-06-06 16:03:33 -070023 v.Aux = nil
24 v.resetArgs()
Keith Randall8f22b522015-06-11 21:29:25 -070025 v.AuxInt = c + d
Keith Randall0dca7352015-06-06 16:03:33 -070026 return true
27 }
Keith Randall9cb332e2015-07-28 14:19:20 -070028 goto end8c46df6f85a11cb1d594076b0e467908
29 end8c46df6f85a11cb1d594076b0e467908:
Keith Randall67fdb0d2015-07-19 15:48:20 -070030 ;
Keith Randallbe1eb572015-07-22 13:46:15 -070031 case OpAddPtr:
Keith Randall9cb332e2015-07-28 14:19:20 -070032 // match: (AddPtr (ConstPtr [c]) (ConstPtr [d]))
Keith Randallbe1eb572015-07-22 13:46:15 -070033 // cond:
Keith Randall9cb332e2015-07-28 14:19:20 -070034 // result: (ConstPtr [c+d])
Keith Randallbe1eb572015-07-22 13:46:15 -070035 {
Keith Randall9cb332e2015-07-28 14:19:20 -070036 if v.Args[0].Op != OpConstPtr {
37 goto end145c1aec793b2befff34bc8983b48a38
Keith Randallbe1eb572015-07-22 13:46:15 -070038 }
39 c := v.Args[0].AuxInt
Keith Randall9cb332e2015-07-28 14:19:20 -070040 if v.Args[1].Op != OpConstPtr {
41 goto end145c1aec793b2befff34bc8983b48a38
Keith Randallbe1eb572015-07-22 13:46:15 -070042 }
43 d := v.Args[1].AuxInt
Keith Randall9cb332e2015-07-28 14:19:20 -070044 v.Op = OpConstPtr
Keith Randallbe1eb572015-07-22 13:46:15 -070045 v.AuxInt = 0
46 v.Aux = nil
47 v.resetArgs()
48 v.AuxInt = c + d
49 return true
50 }
Keith Randall9cb332e2015-07-28 14:19:20 -070051 goto end145c1aec793b2befff34bc8983b48a38
52 end145c1aec793b2befff34bc8983b48a38:
Keith Randallbe1eb572015-07-22 13:46:15 -070053 ;
Alexandru Moșoi198fc9a2015-08-14 12:59:33 +020054 case OpAnd16:
55 // match: (And16 x x)
56 // cond:
57 // result: x
58 {
59 x := v.Args[0]
60 if v.Args[1] != x {
61 goto end69ed6ee2a4fb0491b56c17f3c1926b10
62 }
63 v.Op = OpCopy
64 v.AuxInt = 0
65 v.Aux = nil
66 v.resetArgs()
67 v.Type = x.Type
68 v.AddArg(x)
69 return true
70 }
71 goto end69ed6ee2a4fb0491b56c17f3c1926b10
72 end69ed6ee2a4fb0491b56c17f3c1926b10:
73 ;
74 case OpAnd32:
75 // match: (And32 x x)
76 // cond:
77 // result: x
78 {
79 x := v.Args[0]
80 if v.Args[1] != x {
81 goto endbbe8c3c5b2ca8f013aa178d856f3a99c
82 }
83 v.Op = OpCopy
84 v.AuxInt = 0
85 v.Aux = nil
86 v.resetArgs()
87 v.Type = x.Type
88 v.AddArg(x)
89 return true
90 }
91 goto endbbe8c3c5b2ca8f013aa178d856f3a99c
92 endbbe8c3c5b2ca8f013aa178d856f3a99c:
93 ;
94 case OpAnd64:
95 // match: (And64 x x)
96 // cond:
97 // result: x
98 {
99 x := v.Args[0]
100 if v.Args[1] != x {
101 goto endc9736bf24d2e5cd8d662e1bcf3164640
102 }
103 v.Op = OpCopy
104 v.AuxInt = 0
105 v.Aux = nil
106 v.resetArgs()
107 v.Type = x.Type
108 v.AddArg(x)
109 return true
110 }
111 goto endc9736bf24d2e5cd8d662e1bcf3164640
112 endc9736bf24d2e5cd8d662e1bcf3164640:
113 ;
114 case OpAnd8:
115 // match: (And8 x x)
116 // cond:
117 // result: x
118 {
119 x := v.Args[0]
120 if v.Args[1] != x {
121 goto endeaf127389bd0d4b0e0e297830f8f463b
122 }
123 v.Op = OpCopy
124 v.AuxInt = 0
125 v.Aux = nil
126 v.resetArgs()
127 v.Type = x.Type
128 v.AddArg(x)
129 return true
130 }
131 goto endeaf127389bd0d4b0e0e297830f8f463b
132 endeaf127389bd0d4b0e0e297830f8f463b:
133 ;
Keith Randall0dca7352015-06-06 16:03:33 -0700134 case OpArrayIndex:
135 // match: (ArrayIndex (Load ptr mem) idx)
136 // cond:
Josh Bleecher Snyder8c6abfe2015-06-12 11:01:13 -0700137 // result: (Load (PtrIndex <v.Type.PtrTo()> ptr idx) mem)
Keith Randall0dca7352015-06-06 16:03:33 -0700138 {
139 if v.Args[0].Op != OpLoad {
Josh Bleecher Snyder8c6abfe2015-06-12 11:01:13 -0700140 goto end4894dd7b58383fee5f8a92be08437c33
Keith Randall0dca7352015-06-06 16:03:33 -0700141 }
142 ptr := v.Args[0].Args[0]
143 mem := v.Args[0].Args[1]
144 idx := v.Args[1]
145 v.Op = OpLoad
Keith Randall8f22b522015-06-11 21:29:25 -0700146 v.AuxInt = 0
Keith Randall0dca7352015-06-06 16:03:33 -0700147 v.Aux = nil
148 v.resetArgs()
Keith Randall683f5d72015-08-04 12:24:23 -0700149 v0 := b.NewValue0(v.Line, OpPtrIndex, TypeInvalid)
Josh Bleecher Snyder8c6abfe2015-06-12 11:01:13 -0700150 v0.Type = v.Type.PtrTo()
Keith Randall0dca7352015-06-06 16:03:33 -0700151 v0.AddArg(ptr)
152 v0.AddArg(idx)
153 v.AddArg(v0)
154 v.AddArg(mem)
155 return true
156 }
Josh Bleecher Snyder8c6abfe2015-06-12 11:01:13 -0700157 goto end4894dd7b58383fee5f8a92be08437c33
158 end4894dd7b58383fee5f8a92be08437c33:
Keith Randall0dca7352015-06-06 16:03:33 -0700159 ;
Todd Neal38ed6c12015-07-30 16:02:24 -0400160 case OpCom16:
161 // match: (Com16 (Com16 x))
162 // cond:
Josh Bleecher Snyder0fb818a2015-08-05 10:33:09 -0700163 // result: x
Todd Neal38ed6c12015-07-30 16:02:24 -0400164 {
165 if v.Args[0].Op != OpCom16 {
Josh Bleecher Snyder0fb818a2015-08-05 10:33:09 -0700166 goto end1ea17710dd4dd7ba4e710e0e4c7b5a56
Todd Neal38ed6c12015-07-30 16:02:24 -0400167 }
168 x := v.Args[0].Args[0]
169 v.Op = OpCopy
170 v.AuxInt = 0
171 v.Aux = nil
172 v.resetArgs()
Josh Bleecher Snyder0fb818a2015-08-05 10:33:09 -0700173 v.Type = x.Type
Todd Neal38ed6c12015-07-30 16:02:24 -0400174 v.AddArg(x)
175 return true
176 }
Josh Bleecher Snyder0fb818a2015-08-05 10:33:09 -0700177 goto end1ea17710dd4dd7ba4e710e0e4c7b5a56
178 end1ea17710dd4dd7ba4e710e0e4c7b5a56:
Todd Neal38ed6c12015-07-30 16:02:24 -0400179 ;
180 case OpCom32:
181 // match: (Com32 (Com32 x))
182 // cond:
Josh Bleecher Snyder0fb818a2015-08-05 10:33:09 -0700183 // result: x
Todd Neal38ed6c12015-07-30 16:02:24 -0400184 {
185 if v.Args[0].Op != OpCom32 {
Josh Bleecher Snyder0fb818a2015-08-05 10:33:09 -0700186 goto end9a04ed536496e292c27bef4414128cbf
Todd Neal38ed6c12015-07-30 16:02:24 -0400187 }
188 x := v.Args[0].Args[0]
189 v.Op = OpCopy
190 v.AuxInt = 0
191 v.Aux = nil
192 v.resetArgs()
Josh Bleecher Snyder0fb818a2015-08-05 10:33:09 -0700193 v.Type = x.Type
Todd Neal38ed6c12015-07-30 16:02:24 -0400194 v.AddArg(x)
195 return true
196 }
Josh Bleecher Snyder0fb818a2015-08-05 10:33:09 -0700197 goto end9a04ed536496e292c27bef4414128cbf
198 end9a04ed536496e292c27bef4414128cbf:
Todd Neal38ed6c12015-07-30 16:02:24 -0400199 ;
200 case OpCom64:
201 // match: (Com64 (Com64 x))
202 // cond:
Josh Bleecher Snyder0fb818a2015-08-05 10:33:09 -0700203 // result: x
Todd Neal38ed6c12015-07-30 16:02:24 -0400204 {
205 if v.Args[0].Op != OpCom64 {
Josh Bleecher Snyder0fb818a2015-08-05 10:33:09 -0700206 goto ended44e29d5968f0f7b86972b7bf417ab3
Todd Neal38ed6c12015-07-30 16:02:24 -0400207 }
208 x := v.Args[0].Args[0]
209 v.Op = OpCopy
210 v.AuxInt = 0
211 v.Aux = nil
212 v.resetArgs()
Josh Bleecher Snyder0fb818a2015-08-05 10:33:09 -0700213 v.Type = x.Type
Todd Neal38ed6c12015-07-30 16:02:24 -0400214 v.AddArg(x)
215 return true
216 }
Josh Bleecher Snyder0fb818a2015-08-05 10:33:09 -0700217 goto ended44e29d5968f0f7b86972b7bf417ab3
218 ended44e29d5968f0f7b86972b7bf417ab3:
Todd Neal38ed6c12015-07-30 16:02:24 -0400219 ;
220 case OpCom8:
221 // match: (Com8 (Com8 x))
222 // cond:
Josh Bleecher Snyder0fb818a2015-08-05 10:33:09 -0700223 // result: x
Todd Neal38ed6c12015-07-30 16:02:24 -0400224 {
225 if v.Args[0].Op != OpCom8 {
Josh Bleecher Snyder0fb818a2015-08-05 10:33:09 -0700226 goto end4d92ff3ba567d9afd38fc9ca113602ad
Todd Neal38ed6c12015-07-30 16:02:24 -0400227 }
228 x := v.Args[0].Args[0]
229 v.Op = OpCopy
230 v.AuxInt = 0
231 v.Aux = nil
232 v.resetArgs()
Josh Bleecher Snyder0fb818a2015-08-05 10:33:09 -0700233 v.Type = x.Type
Todd Neal38ed6c12015-07-30 16:02:24 -0400234 v.AddArg(x)
235 return true
236 }
Josh Bleecher Snyder0fb818a2015-08-05 10:33:09 -0700237 goto end4d92ff3ba567d9afd38fc9ca113602ad
238 end4d92ff3ba567d9afd38fc9ca113602ad:
Todd Neal38ed6c12015-07-30 16:02:24 -0400239 ;
David Chase52578582015-08-28 14:24:10 -0400240 case OpComplexImag:
241 // match: (ComplexImag (ComplexMake _ imag ))
242 // cond:
243 // result: imag
244 {
245 if v.Args[0].Op != OpComplexMake {
246 goto endec3009fd8727d03002021997936e091f
247 }
248 imag := v.Args[0].Args[1]
249 v.Op = OpCopy
250 v.AuxInt = 0
251 v.Aux = nil
252 v.resetArgs()
253 v.Type = imag.Type
254 v.AddArg(imag)
255 return true
256 }
257 goto endec3009fd8727d03002021997936e091f
258 endec3009fd8727d03002021997936e091f:
259 ;
260 case OpComplexReal:
261 // match: (ComplexReal (ComplexMake real _ ))
262 // cond:
263 // result: real
264 {
265 if v.Args[0].Op != OpComplexMake {
266 goto end8db3e16bd59af1adaa4b734c8adcc71d
267 }
268 real := v.Args[0].Args[0]
269 v.Op = OpCopy
270 v.AuxInt = 0
271 v.Aux = nil
272 v.resetArgs()
273 v.Type = real.Type
274 v.AddArg(real)
275 return true
276 }
277 goto end8db3e16bd59af1adaa4b734c8adcc71d
278 end8db3e16bd59af1adaa4b734c8adcc71d:
279 ;
Keith Randall9f954db2015-08-18 10:26:28 -0700280 case OpConstInterface:
281 // match: (ConstInterface)
282 // cond:
283 // result: (IMake (ConstNil <config.fe.TypeBytePtr()>) (ConstNil <config.fe.TypeBytePtr()>))
284 {
285 v.Op = OpIMake
286 v.AuxInt = 0
287 v.Aux = nil
288 v.resetArgs()
289 v0 := b.NewValue0(v.Line, OpConstNil, TypeInvalid)
290 v0.Type = config.fe.TypeBytePtr()
291 v.AddArg(v0)
292 v1 := b.NewValue0(v.Line, OpConstNil, TypeInvalid)
293 v1.Type = config.fe.TypeBytePtr()
294 v.AddArg(v1)
295 return true
296 }
297 goto end0367bd8f20a320cc41568f2b28657f6b
298 end0367bd8f20a320cc41568f2b28657f6b:
299 ;
300 case OpConstSlice:
301 // match: (ConstSlice)
302 // cond:
303 // result: (SliceMake (ConstNil <config.fe.TypeBytePtr()>) (ConstPtr <config.fe.TypeUintptr()>) (ConstPtr <config.fe.TypeUintptr()>))
304 {
305 v.Op = OpSliceMake
306 v.AuxInt = 0
307 v.Aux = nil
308 v.resetArgs()
309 v0 := b.NewValue0(v.Line, OpConstNil, TypeInvalid)
310 v0.Type = config.fe.TypeBytePtr()
311 v.AddArg(v0)
312 v1 := b.NewValue0(v.Line, OpConstPtr, TypeInvalid)
313 v1.Type = config.fe.TypeUintptr()
314 v.AddArg(v1)
315 v2 := b.NewValue0(v.Line, OpConstPtr, TypeInvalid)
316 v2.Type = config.fe.TypeUintptr()
317 v.AddArg(v2)
318 return true
319 }
320 goto endfd2d8ffcd55eaf8a5092a20c3ae61ba3
321 endfd2d8ffcd55eaf8a5092a20c3ae61ba3:
322 ;
Keith Randall9cb332e2015-07-28 14:19:20 -0700323 case OpConstString:
324 // match: (ConstString {s})
325 // cond:
Keith Randall9f954db2015-08-18 10:26:28 -0700326 // result: (StringMake (Addr <config.fe.TypeBytePtr()> {config.fe.StringData(s.(string))} (SB <config.fe.TypeUintptr()>)) (ConstPtr <config.fe.TypeUintptr()> [int64(len(s.(string)))]))
Keith Randall0dca7352015-06-06 16:03:33 -0700327 {
Keith Randall0dca7352015-06-06 16:03:33 -0700328 s := v.Aux
Keith Randall0dca7352015-06-06 16:03:33 -0700329 v.Op = OpStringMake
Keith Randall8f22b522015-06-11 21:29:25 -0700330 v.AuxInt = 0
Keith Randall0dca7352015-06-06 16:03:33 -0700331 v.Aux = nil
332 v.resetArgs()
Keith Randall683f5d72015-08-04 12:24:23 -0700333 v0 := b.NewValue0(v.Line, OpAddr, TypeInvalid)
Keith Randall9f954db2015-08-18 10:26:28 -0700334 v0.Type = config.fe.TypeBytePtr()
Josh Bleecher Snyder8d31df18a2015-07-24 11:28:12 -0700335 v0.Aux = config.fe.StringData(s.(string))
Keith Randall683f5d72015-08-04 12:24:23 -0700336 v1 := b.NewValue0(v.Line, OpSB, TypeInvalid)
Keith Randall9f954db2015-08-18 10:26:28 -0700337 v1.Type = config.fe.TypeUintptr()
Keith Randall0dca7352015-06-06 16:03:33 -0700338 v0.AddArg(v1)
339 v.AddArg(v0)
Keith Randall683f5d72015-08-04 12:24:23 -0700340 v2 := b.NewValue0(v.Line, OpConstPtr, TypeInvalid)
Keith Randall9f954db2015-08-18 10:26:28 -0700341 v2.Type = config.fe.TypeUintptr()
Josh Bleecher Snyder8d31df18a2015-07-24 11:28:12 -0700342 v2.AuxInt = int64(len(s.(string)))
343 v.AddArg(v2)
Keith Randall0dca7352015-06-06 16:03:33 -0700344 return true
345 }
Keith Randall9f954db2015-08-18 10:26:28 -0700346 goto end51a3d96f2d304db9a52f36ee6b29c14e
347 end51a3d96f2d304db9a52f36ee6b29c14e:
Keith Randall0dca7352015-06-06 16:03:33 -0700348 ;
Alexandru Moșoi9b25da72015-07-31 12:32:22 +0200349 case OpEq16:
350 // match: (Eq16 x x)
351 // cond:
352 // result: (ConstBool {true})
353 {
354 x := v.Args[0]
355 if v.Args[1] != x {
356 goto enda503589f9b617e708a5ad3ddb047809f
357 }
358 v.Op = OpConstBool
359 v.AuxInt = 0
360 v.Aux = nil
361 v.resetArgs()
362 v.Aux = true
363 return true
364 }
365 goto enda503589f9b617e708a5ad3ddb047809f
366 enda503589f9b617e708a5ad3ddb047809f:
367 ;
368 case OpEq32:
369 // match: (Eq32 x x)
370 // cond:
371 // result: (ConstBool {true})
372 {
373 x := v.Args[0]
374 if v.Args[1] != x {
375 goto endc94ae3b97d0090257b02152e437b3e17
376 }
377 v.Op = OpConstBool
378 v.AuxInt = 0
379 v.Aux = nil
380 v.resetArgs()
381 v.Aux = true
382 return true
383 }
384 goto endc94ae3b97d0090257b02152e437b3e17
385 endc94ae3b97d0090257b02152e437b3e17:
386 ;
387 case OpEq64:
388 // match: (Eq64 x x)
389 // cond:
390 // result: (ConstBool {true})
391 {
392 x := v.Args[0]
393 if v.Args[1] != x {
394 goto end4d21cead60174989467a9c8202dbb91d
395 }
396 v.Op = OpConstBool
397 v.AuxInt = 0
398 v.Aux = nil
399 v.resetArgs()
400 v.Aux = true
401 return true
402 }
403 goto end4d21cead60174989467a9c8202dbb91d
404 end4d21cead60174989467a9c8202dbb91d:
405 ;
406 case OpEq8:
407 // match: (Eq8 x x)
408 // cond:
409 // result: (ConstBool {true})
410 {
411 x := v.Args[0]
412 if v.Args[1] != x {
413 goto end73dce8bba164e4f4a1dd701bf8cfb362
414 }
415 v.Op = OpConstBool
416 v.AuxInt = 0
417 v.Aux = nil
418 v.resetArgs()
419 v.Aux = true
420 return true
421 }
422 goto end73dce8bba164e4f4a1dd701bf8cfb362
423 end73dce8bba164e4f4a1dd701bf8cfb362:
424 ;
Josh Bleecher Snyder9ca24fc2015-07-27 13:17:45 -0700425 case OpEqFat:
426 // match: (EqFat x y)
Keith Randall9cb332e2015-07-28 14:19:20 -0700427 // cond: x.Op == OpConstNil && y.Op != OpConstNil
Josh Bleecher Snyder9ca24fc2015-07-27 13:17:45 -0700428 // result: (EqFat y x)
429 {
430 x := v.Args[0]
431 y := v.Args[1]
Keith Randall9cb332e2015-07-28 14:19:20 -0700432 if !(x.Op == OpConstNil && y.Op != OpConstNil) {
433 goto endcea7f7399afcff860c54d82230a9a934
Josh Bleecher Snyder9ca24fc2015-07-27 13:17:45 -0700434 }
435 v.Op = OpEqFat
436 v.AuxInt = 0
437 v.Aux = nil
438 v.resetArgs()
439 v.AddArg(y)
440 v.AddArg(x)
441 return true
442 }
Keith Randall9cb332e2015-07-28 14:19:20 -0700443 goto endcea7f7399afcff860c54d82230a9a934
444 endcea7f7399afcff860c54d82230a9a934:
Josh Bleecher Snyder9ca24fc2015-07-27 13:17:45 -0700445 ;
Keith Randall9cb332e2015-07-28 14:19:20 -0700446 // match: (EqFat (Load ptr mem) (ConstNil))
447 // cond:
Keith Randall9f954db2015-08-18 10:26:28 -0700448 // result: (EqPtr (Load <config.fe.TypeUintptr()> ptr mem) (ConstPtr <config.fe.TypeUintptr()> [0]))
Josh Bleecher Snyder9ca24fc2015-07-27 13:17:45 -0700449 {
450 if v.Args[0].Op != OpLoad {
Keith Randall9f954db2015-08-18 10:26:28 -0700451 goto ende10070e5ddd3dc059674d25ccc6a63b5
Josh Bleecher Snyder9ca24fc2015-07-27 13:17:45 -0700452 }
453 ptr := v.Args[0].Args[0]
454 mem := v.Args[0].Args[1]
Keith Randall9cb332e2015-07-28 14:19:20 -0700455 if v.Args[1].Op != OpConstNil {
Keith Randall9f954db2015-08-18 10:26:28 -0700456 goto ende10070e5ddd3dc059674d25ccc6a63b5
Josh Bleecher Snyder9ca24fc2015-07-27 13:17:45 -0700457 }
458 v.Op = OpEqPtr
459 v.AuxInt = 0
460 v.Aux = nil
461 v.resetArgs()
Keith Randall683f5d72015-08-04 12:24:23 -0700462 v0 := b.NewValue0(v.Line, OpLoad, TypeInvalid)
Keith Randall9f954db2015-08-18 10:26:28 -0700463 v0.Type = config.fe.TypeUintptr()
Josh Bleecher Snyder9ca24fc2015-07-27 13:17:45 -0700464 v0.AddArg(ptr)
465 v0.AddArg(mem)
466 v.AddArg(v0)
Keith Randall683f5d72015-08-04 12:24:23 -0700467 v1 := b.NewValue0(v.Line, OpConstPtr, TypeInvalid)
Keith Randall9f954db2015-08-18 10:26:28 -0700468 v1.Type = config.fe.TypeUintptr()
Josh Bleecher Snyder9ca24fc2015-07-27 13:17:45 -0700469 v1.AuxInt = 0
470 v.AddArg(v1)
471 return true
472 }
Keith Randall9f954db2015-08-18 10:26:28 -0700473 goto ende10070e5ddd3dc059674d25ccc6a63b5
474 ende10070e5ddd3dc059674d25ccc6a63b5:
475 ;
476 case OpIData:
477 // match: (IData (IMake _ data))
478 // cond:
479 // result: data
480 {
481 if v.Args[0].Op != OpIMake {
482 goto endbfa1bb944cdc07933effb16a35152e12
483 }
484 data := v.Args[0].Args[1]
485 v.Op = OpCopy
486 v.AuxInt = 0
487 v.Aux = nil
488 v.resetArgs()
489 v.Type = data.Type
490 v.AddArg(data)
491 return true
492 }
493 goto endbfa1bb944cdc07933effb16a35152e12
494 endbfa1bb944cdc07933effb16a35152e12:
495 ;
496 case OpITab:
497 // match: (ITab (IMake itab _))
498 // cond:
499 // result: itab
500 {
501 if v.Args[0].Op != OpIMake {
502 goto endfcbb9414a776ff9c8512da3e0f4d8fbd
503 }
504 itab := v.Args[0].Args[0]
505 v.Op = OpCopy
506 v.AuxInt = 0
507 v.Aux = nil
508 v.resetArgs()
509 v.Type = itab.Type
510 v.AddArg(itab)
511 return true
512 }
513 goto endfcbb9414a776ff9c8512da3e0f4d8fbd
514 endfcbb9414a776ff9c8512da3e0f4d8fbd:
Josh Bleecher Snyder9ca24fc2015-07-27 13:17:45 -0700515 ;
Keith Randall0dca7352015-06-06 16:03:33 -0700516 case OpIsInBounds:
Josh Bleecher Snyder3e7904b2015-08-12 13:48:36 -0700517 // match: (IsInBounds (Const32 [c]) (Const32 [d]))
Keith Randall0dca7352015-06-06 16:03:33 -0700518 // cond:
Josh Bleecher Snyder3e7904b2015-08-12 13:48:36 -0700519 // result: (ConstBool {inBounds32(c,d)})
Keith Randall0dca7352015-06-06 16:03:33 -0700520 {
Josh Bleecher Snyder3e7904b2015-08-12 13:48:36 -0700521 if v.Args[0].Op != OpConst32 {
522 goto endc3396bf88b56276e1691abe62811dba5
Keith Randall0dca7352015-06-06 16:03:33 -0700523 }
Keith Randall8f22b522015-06-11 21:29:25 -0700524 c := v.Args[0].AuxInt
Josh Bleecher Snyder3e7904b2015-08-12 13:48:36 -0700525 if v.Args[1].Op != OpConst32 {
526 goto endc3396bf88b56276e1691abe62811dba5
Keith Randall0dca7352015-06-06 16:03:33 -0700527 }
Keith Randall8f22b522015-06-11 21:29:25 -0700528 d := v.Args[1].AuxInt
Josh Bleecher Snyder3e7904b2015-08-12 13:48:36 -0700529 v.Op = OpConstBool
Keith Randall8f22b522015-06-11 21:29:25 -0700530 v.AuxInt = 0
Keith Randall0dca7352015-06-06 16:03:33 -0700531 v.Aux = nil
532 v.resetArgs()
Josh Bleecher Snyder3e7904b2015-08-12 13:48:36 -0700533 v.Aux = inBounds32(c, d)
Keith Randall0dca7352015-06-06 16:03:33 -0700534 return true
535 }
Josh Bleecher Snyder3e7904b2015-08-12 13:48:36 -0700536 goto endc3396bf88b56276e1691abe62811dba5
537 endc3396bf88b56276e1691abe62811dba5:
538 ;
539 // match: (IsInBounds (Const64 [c]) (Const64 [d]))
540 // cond:
541 // result: (ConstBool {inBounds64(c,d)})
542 {
543 if v.Args[0].Op != OpConst64 {
544 goto end0b4b8178a54662835b00bfa503cf879a
545 }
546 c := v.Args[0].AuxInt
547 if v.Args[1].Op != OpConst64 {
548 goto end0b4b8178a54662835b00bfa503cf879a
549 }
550 d := v.Args[1].AuxInt
551 v.Op = OpConstBool
552 v.AuxInt = 0
553 v.Aux = nil
554 v.resetArgs()
555 v.Aux = inBounds64(c, d)
556 return true
557 }
558 goto end0b4b8178a54662835b00bfa503cf879a
559 end0b4b8178a54662835b00bfa503cf879a:
560 ;
561 // match: (IsInBounds (ConstPtr [c]) (ConstPtr [d]))
562 // cond: config.PtrSize == 4
563 // result: (ConstBool {inBounds32(c,d)})
564 {
565 if v.Args[0].Op != OpConstPtr {
566 goto end2c6938f68a67e08dbd96edb1e693e549
567 }
568 c := v.Args[0].AuxInt
569 if v.Args[1].Op != OpConstPtr {
570 goto end2c6938f68a67e08dbd96edb1e693e549
571 }
572 d := v.Args[1].AuxInt
573 if !(config.PtrSize == 4) {
574 goto end2c6938f68a67e08dbd96edb1e693e549
575 }
576 v.Op = OpConstBool
577 v.AuxInt = 0
578 v.Aux = nil
579 v.resetArgs()
580 v.Aux = inBounds32(c, d)
581 return true
582 }
583 goto end2c6938f68a67e08dbd96edb1e693e549
584 end2c6938f68a67e08dbd96edb1e693e549:
585 ;
586 // match: (IsInBounds (ConstPtr [c]) (ConstPtr [d]))
587 // cond: config.PtrSize == 8
588 // result: (ConstBool {inBounds64(c,d)})
589 {
590 if v.Args[0].Op != OpConstPtr {
591 goto end84d6ae817944985f572ecaac51999d6c
592 }
593 c := v.Args[0].AuxInt
594 if v.Args[1].Op != OpConstPtr {
595 goto end84d6ae817944985f572ecaac51999d6c
596 }
597 d := v.Args[1].AuxInt
598 if !(config.PtrSize == 8) {
599 goto end84d6ae817944985f572ecaac51999d6c
600 }
601 v.Op = OpConstBool
602 v.AuxInt = 0
603 v.Aux = nil
604 v.resetArgs()
605 v.Aux = inBounds64(c, d)
606 return true
607 }
608 goto end84d6ae817944985f572ecaac51999d6c
609 end84d6ae817944985f572ecaac51999d6c:
Keith Randall0dca7352015-06-06 16:03:33 -0700610 ;
611 case OpLoad:
612 // match: (Load <t> ptr mem)
David Chase52578582015-08-28 14:24:10 -0400613 // cond: t.IsComplex() && t.Size() == 8
614 // result: (ComplexMake (Load <config.fe.TypeFloat32()> ptr mem) (Load <config.fe.TypeFloat32()> (OffPtr <config.fe.TypeFloat32().PtrTo()> [4] ptr) mem) )
615 {
616 t := v.Type
617 ptr := v.Args[0]
618 mem := v.Args[1]
619 if !(t.IsComplex() && t.Size() == 8) {
620 goto end665854b31b828893d90b36bb462ff381
621 }
622 v.Op = OpComplexMake
623 v.AuxInt = 0
624 v.Aux = nil
625 v.resetArgs()
626 v0 := b.NewValue0(v.Line, OpLoad, TypeInvalid)
627 v0.Type = config.fe.TypeFloat32()
628 v0.AddArg(ptr)
629 v0.AddArg(mem)
630 v.AddArg(v0)
631 v1 := b.NewValue0(v.Line, OpLoad, TypeInvalid)
632 v1.Type = config.fe.TypeFloat32()
633 v2 := b.NewValue0(v.Line, OpOffPtr, TypeInvalid)
634 v2.Type = config.fe.TypeFloat32().PtrTo()
635 v2.AuxInt = 4
636 v2.AddArg(ptr)
637 v1.AddArg(v2)
638 v1.AddArg(mem)
639 v.AddArg(v1)
640 return true
641 }
642 goto end665854b31b828893d90b36bb462ff381
643 end665854b31b828893d90b36bb462ff381:
644 ;
645 // match: (Load <t> ptr mem)
646 // cond: t.IsComplex() && t.Size() == 16
647 // result: (ComplexMake (Load <config.fe.TypeFloat64()> ptr mem) (Load <config.fe.TypeFloat64()> (OffPtr <config.fe.TypeFloat64().PtrTo()> [8] ptr) mem) )
648 {
649 t := v.Type
650 ptr := v.Args[0]
651 mem := v.Args[1]
652 if !(t.IsComplex() && t.Size() == 16) {
653 goto end1b106f89e0e3e26c613b957a7c98d8ad
654 }
655 v.Op = OpComplexMake
656 v.AuxInt = 0
657 v.Aux = nil
658 v.resetArgs()
659 v0 := b.NewValue0(v.Line, OpLoad, TypeInvalid)
660 v0.Type = config.fe.TypeFloat64()
661 v0.AddArg(ptr)
662 v0.AddArg(mem)
663 v.AddArg(v0)
664 v1 := b.NewValue0(v.Line, OpLoad, TypeInvalid)
665 v1.Type = config.fe.TypeFloat64()
666 v2 := b.NewValue0(v.Line, OpOffPtr, TypeInvalid)
667 v2.Type = config.fe.TypeFloat64().PtrTo()
668 v2.AuxInt = 8
669 v2.AddArg(ptr)
670 v1.AddArg(v2)
671 v1.AddArg(mem)
672 v.AddArg(v1)
673 return true
674 }
675 goto end1b106f89e0e3e26c613b957a7c98d8ad
676 end1b106f89e0e3e26c613b957a7c98d8ad:
677 ;
678 // match: (Load <t> ptr mem)
Keith Randall0dca7352015-06-06 16:03:33 -0700679 // cond: t.IsString()
Keith Randall9f954db2015-08-18 10:26:28 -0700680 // result: (StringMake (Load <config.fe.TypeBytePtr()> ptr mem) (Load <config.fe.TypeUintptr()> (OffPtr <config.fe.TypeUintptr().PtrTo()> [config.PtrSize] ptr) mem))
Keith Randall0dca7352015-06-06 16:03:33 -0700681 {
682 t := v.Type
683 ptr := v.Args[0]
684 mem := v.Args[1]
685 if !(t.IsString()) {
Keith Randall9f954db2015-08-18 10:26:28 -0700686 goto end7c75255555bf9dd796298d9f6eaf9cf2
Keith Randall0dca7352015-06-06 16:03:33 -0700687 }
688 v.Op = OpStringMake
Keith Randall8f22b522015-06-11 21:29:25 -0700689 v.AuxInt = 0
Keith Randall0dca7352015-06-06 16:03:33 -0700690 v.Aux = nil
691 v.resetArgs()
Keith Randall683f5d72015-08-04 12:24:23 -0700692 v0 := b.NewValue0(v.Line, OpLoad, TypeInvalid)
Keith Randall9f954db2015-08-18 10:26:28 -0700693 v0.Type = config.fe.TypeBytePtr()
Keith Randall0dca7352015-06-06 16:03:33 -0700694 v0.AddArg(ptr)
695 v0.AddArg(mem)
696 v.AddArg(v0)
Keith Randall683f5d72015-08-04 12:24:23 -0700697 v1 := b.NewValue0(v.Line, OpLoad, TypeInvalid)
Keith Randall9f954db2015-08-18 10:26:28 -0700698 v1.Type = config.fe.TypeUintptr()
Keith Randall683f5d72015-08-04 12:24:23 -0700699 v2 := b.NewValue0(v.Line, OpOffPtr, TypeInvalid)
Keith Randall9f954db2015-08-18 10:26:28 -0700700 v2.Type = config.fe.TypeUintptr().PtrTo()
Keith Randall67fdb0d2015-07-19 15:48:20 -0700701 v2.AuxInt = config.PtrSize
Keith Randall0dca7352015-06-06 16:03:33 -0700702 v2.AddArg(ptr)
703 v1.AddArg(v2)
704 v1.AddArg(mem)
705 v.AddArg(v1)
706 return true
707 }
Keith Randall9f954db2015-08-18 10:26:28 -0700708 goto end7c75255555bf9dd796298d9f6eaf9cf2
709 end7c75255555bf9dd796298d9f6eaf9cf2:
710 ;
711 // match: (Load <t> ptr mem)
712 // cond: t.IsSlice()
713 // result: (SliceMake (Load <config.fe.TypeBytePtr()> ptr mem) (Load <config.fe.TypeUintptr()> (OffPtr <config.fe.TypeUintptr().PtrTo()> [config.PtrSize] ptr) mem) (Load <config.fe.TypeUintptr()> (OffPtr <config.fe.TypeUintptr().PtrTo()> [2*config.PtrSize] ptr) mem))
714 {
715 t := v.Type
716 ptr := v.Args[0]
717 mem := v.Args[1]
718 if !(t.IsSlice()) {
719 goto end12c46556d962198680eb3238859e3016
720 }
721 v.Op = OpSliceMake
722 v.AuxInt = 0
723 v.Aux = nil
724 v.resetArgs()
725 v0 := b.NewValue0(v.Line, OpLoad, TypeInvalid)
726 v0.Type = config.fe.TypeBytePtr()
727 v0.AddArg(ptr)
728 v0.AddArg(mem)
729 v.AddArg(v0)
730 v1 := b.NewValue0(v.Line, OpLoad, TypeInvalid)
731 v1.Type = config.fe.TypeUintptr()
732 v2 := b.NewValue0(v.Line, OpOffPtr, TypeInvalid)
733 v2.Type = config.fe.TypeUintptr().PtrTo()
734 v2.AuxInt = config.PtrSize
735 v2.AddArg(ptr)
736 v1.AddArg(v2)
737 v1.AddArg(mem)
738 v.AddArg(v1)
739 v3 := b.NewValue0(v.Line, OpLoad, TypeInvalid)
740 v3.Type = config.fe.TypeUintptr()
741 v4 := b.NewValue0(v.Line, OpOffPtr, TypeInvalid)
742 v4.Type = config.fe.TypeUintptr().PtrTo()
743 v4.AuxInt = 2 * config.PtrSize
744 v4.AddArg(ptr)
745 v3.AddArg(v4)
746 v3.AddArg(mem)
747 v.AddArg(v3)
748 return true
749 }
750 goto end12c46556d962198680eb3238859e3016
751 end12c46556d962198680eb3238859e3016:
752 ;
753 // match: (Load <t> ptr mem)
754 // cond: t.IsInterface()
755 // result: (IMake (Load <config.fe.TypeBytePtr()> ptr mem) (Load <config.fe.TypeBytePtr()> (OffPtr <config.fe.TypeBytePtr().PtrTo()> [config.PtrSize] ptr) mem))
756 {
757 t := v.Type
758 ptr := v.Args[0]
759 mem := v.Args[1]
760 if !(t.IsInterface()) {
761 goto end12671c83ebe3ccbc8e53383765ee7675
762 }
763 v.Op = OpIMake
764 v.AuxInt = 0
765 v.Aux = nil
766 v.resetArgs()
767 v0 := b.NewValue0(v.Line, OpLoad, TypeInvalid)
768 v0.Type = config.fe.TypeBytePtr()
769 v0.AddArg(ptr)
770 v0.AddArg(mem)
771 v.AddArg(v0)
772 v1 := b.NewValue0(v.Line, OpLoad, TypeInvalid)
773 v1.Type = config.fe.TypeBytePtr()
774 v2 := b.NewValue0(v.Line, OpOffPtr, TypeInvalid)
775 v2.Type = config.fe.TypeBytePtr().PtrTo()
776 v2.AuxInt = config.PtrSize
777 v2.AddArg(ptr)
778 v1.AddArg(v2)
779 v1.AddArg(mem)
780 v.AddArg(v1)
781 return true
782 }
783 goto end12671c83ebe3ccbc8e53383765ee7675
784 end12671c83ebe3ccbc8e53383765ee7675:
Keith Randall0dca7352015-06-06 16:03:33 -0700785 ;
Keith Randallbe1eb572015-07-22 13:46:15 -0700786 case OpMul64:
Keith Randall9cb332e2015-07-28 14:19:20 -0700787 // match: (Mul64 (Const64 [c]) (Const64 [d]))
Keith Randallbe1eb572015-07-22 13:46:15 -0700788 // cond:
Keith Randall9cb332e2015-07-28 14:19:20 -0700789 // result: (Const64 [c*d])
Keith Randall0dca7352015-06-06 16:03:33 -0700790 {
Keith Randall9cb332e2015-07-28 14:19:20 -0700791 if v.Args[0].Op != OpConst64 {
792 goto end7aea1048b5d1230974b97f17238380ae
Keith Randall0dca7352015-06-06 16:03:33 -0700793 }
Keith Randall8f22b522015-06-11 21:29:25 -0700794 c := v.Args[0].AuxInt
Keith Randall9cb332e2015-07-28 14:19:20 -0700795 if v.Args[1].Op != OpConst64 {
796 goto end7aea1048b5d1230974b97f17238380ae
Keith Randall0dca7352015-06-06 16:03:33 -0700797 }
Keith Randall8f22b522015-06-11 21:29:25 -0700798 d := v.Args[1].AuxInt
Keith Randall9cb332e2015-07-28 14:19:20 -0700799 v.Op = OpConst64
Keith Randall8f22b522015-06-11 21:29:25 -0700800 v.AuxInt = 0
Keith Randall0dca7352015-06-06 16:03:33 -0700801 v.Aux = nil
802 v.resetArgs()
Keith Randall8f22b522015-06-11 21:29:25 -0700803 v.AuxInt = c * d
Keith Randall0dca7352015-06-06 16:03:33 -0700804 return true
805 }
Keith Randall9cb332e2015-07-28 14:19:20 -0700806 goto end7aea1048b5d1230974b97f17238380ae
807 end7aea1048b5d1230974b97f17238380ae:
Keith Randallbe1eb572015-07-22 13:46:15 -0700808 ;
Keith Randallbe1eb572015-07-22 13:46:15 -0700809 case OpMulPtr:
Keith Randall9cb332e2015-07-28 14:19:20 -0700810 // match: (MulPtr (ConstPtr [c]) (ConstPtr [d]))
Keith Randallbe1eb572015-07-22 13:46:15 -0700811 // cond:
Keith Randall9cb332e2015-07-28 14:19:20 -0700812 // result: (ConstPtr [c*d])
Keith Randallbe1eb572015-07-22 13:46:15 -0700813 {
Keith Randall9cb332e2015-07-28 14:19:20 -0700814 if v.Args[0].Op != OpConstPtr {
815 goto end808c190f346658bb1ad032bf37a1059f
Keith Randallbe1eb572015-07-22 13:46:15 -0700816 }
817 c := v.Args[0].AuxInt
Keith Randall9cb332e2015-07-28 14:19:20 -0700818 if v.Args[1].Op != OpConstPtr {
819 goto end808c190f346658bb1ad032bf37a1059f
Keith Randallbe1eb572015-07-22 13:46:15 -0700820 }
821 d := v.Args[1].AuxInt
Keith Randall9cb332e2015-07-28 14:19:20 -0700822 v.Op = OpConstPtr
Keith Randallbe1eb572015-07-22 13:46:15 -0700823 v.AuxInt = 0
824 v.Aux = nil
825 v.resetArgs()
826 v.AuxInt = c * d
827 return true
828 }
Keith Randall9cb332e2015-07-28 14:19:20 -0700829 goto end808c190f346658bb1ad032bf37a1059f
830 end808c190f346658bb1ad032bf37a1059f:
Keith Randall0dca7352015-06-06 16:03:33 -0700831 ;
Alexandru Moșoi9b25da72015-07-31 12:32:22 +0200832 case OpNeq16:
833 // match: (Neq16 x x)
834 // cond:
835 // result: (ConstBool {false})
836 {
837 x := v.Args[0]
838 if v.Args[1] != x {
839 goto end192755dd3c2be992e9d3deb53794a8d2
840 }
841 v.Op = OpConstBool
842 v.AuxInt = 0
843 v.Aux = nil
844 v.resetArgs()
845 v.Aux = false
846 return true
847 }
848 goto end192755dd3c2be992e9d3deb53794a8d2
849 end192755dd3c2be992e9d3deb53794a8d2:
850 ;
851 case OpNeq32:
852 // match: (Neq32 x x)
853 // cond:
854 // result: (ConstBool {false})
855 {
856 x := v.Args[0]
857 if v.Args[1] != x {
858 goto endeb23619fc85950a8df7b31126252c4dd
859 }
860 v.Op = OpConstBool
861 v.AuxInt = 0
862 v.Aux = nil
863 v.resetArgs()
864 v.Aux = false
865 return true
866 }
867 goto endeb23619fc85950a8df7b31126252c4dd
868 endeb23619fc85950a8df7b31126252c4dd:
869 ;
870 case OpNeq64:
871 // match: (Neq64 x x)
872 // cond:
873 // result: (ConstBool {false})
874 {
875 x := v.Args[0]
876 if v.Args[1] != x {
877 goto endfc6eea780fb4056afb9e4287076da60c
878 }
879 v.Op = OpConstBool
880 v.AuxInt = 0
881 v.Aux = nil
882 v.resetArgs()
883 v.Aux = false
884 return true
885 }
886 goto endfc6eea780fb4056afb9e4287076da60c
887 endfc6eea780fb4056afb9e4287076da60c:
888 ;
889 case OpNeq8:
890 // match: (Neq8 x x)
891 // cond:
892 // result: (ConstBool {false})
893 {
894 x := v.Args[0]
895 if v.Args[1] != x {
896 goto endcccf700d93c6d57765b80f92f7b3fa81
897 }
898 v.Op = OpConstBool
899 v.AuxInt = 0
900 v.Aux = nil
901 v.resetArgs()
902 v.Aux = false
903 return true
904 }
905 goto endcccf700d93c6d57765b80f92f7b3fa81
906 endcccf700d93c6d57765b80f92f7b3fa81:
907 ;
Josh Bleecher Snyder9ca24fc2015-07-27 13:17:45 -0700908 case OpNeqFat:
909 // match: (NeqFat x y)
Keith Randall9cb332e2015-07-28 14:19:20 -0700910 // cond: x.Op == OpConstNil && y.Op != OpConstNil
Josh Bleecher Snyder9ca24fc2015-07-27 13:17:45 -0700911 // result: (NeqFat y x)
912 {
913 x := v.Args[0]
914 y := v.Args[1]
Keith Randall9cb332e2015-07-28 14:19:20 -0700915 if !(x.Op == OpConstNil && y.Op != OpConstNil) {
916 goto end94c68f7dc30c66ed42e507e01c4e5dc7
Josh Bleecher Snyder9ca24fc2015-07-27 13:17:45 -0700917 }
918 v.Op = OpNeqFat
919 v.AuxInt = 0
920 v.Aux = nil
921 v.resetArgs()
922 v.AddArg(y)
923 v.AddArg(x)
924 return true
925 }
Keith Randall9cb332e2015-07-28 14:19:20 -0700926 goto end94c68f7dc30c66ed42e507e01c4e5dc7
927 end94c68f7dc30c66ed42e507e01c4e5dc7:
Josh Bleecher Snyder9ca24fc2015-07-27 13:17:45 -0700928 ;
Keith Randall9cb332e2015-07-28 14:19:20 -0700929 // match: (NeqFat (Load ptr mem) (ConstNil))
930 // cond:
Keith Randall9f954db2015-08-18 10:26:28 -0700931 // result: (NeqPtr (Load <config.fe.TypeUintptr()> ptr mem) (ConstPtr <config.fe.TypeUintptr()> [0]))
Josh Bleecher Snyder9ca24fc2015-07-27 13:17:45 -0700932 {
933 if v.Args[0].Op != OpLoad {
Keith Randall9f954db2015-08-18 10:26:28 -0700934 goto end423eea941d60473e73140e25f5818bfb
Josh Bleecher Snyder9ca24fc2015-07-27 13:17:45 -0700935 }
936 ptr := v.Args[0].Args[0]
937 mem := v.Args[0].Args[1]
Keith Randall9cb332e2015-07-28 14:19:20 -0700938 if v.Args[1].Op != OpConstNil {
Keith Randall9f954db2015-08-18 10:26:28 -0700939 goto end423eea941d60473e73140e25f5818bfb
Josh Bleecher Snyder9ca24fc2015-07-27 13:17:45 -0700940 }
941 v.Op = OpNeqPtr
942 v.AuxInt = 0
943 v.Aux = nil
944 v.resetArgs()
Keith Randall683f5d72015-08-04 12:24:23 -0700945 v0 := b.NewValue0(v.Line, OpLoad, TypeInvalid)
Keith Randall9f954db2015-08-18 10:26:28 -0700946 v0.Type = config.fe.TypeUintptr()
Josh Bleecher Snyder9ca24fc2015-07-27 13:17:45 -0700947 v0.AddArg(ptr)
948 v0.AddArg(mem)
949 v.AddArg(v0)
Keith Randall683f5d72015-08-04 12:24:23 -0700950 v1 := b.NewValue0(v.Line, OpConstPtr, TypeInvalid)
Keith Randall9f954db2015-08-18 10:26:28 -0700951 v1.Type = config.fe.TypeUintptr()
Josh Bleecher Snyder9ca24fc2015-07-27 13:17:45 -0700952 v1.AuxInt = 0
953 v.AddArg(v1)
954 return true
955 }
Keith Randall9f954db2015-08-18 10:26:28 -0700956 goto end423eea941d60473e73140e25f5818bfb
957 end423eea941d60473e73140e25f5818bfb:
Josh Bleecher Snyder9ca24fc2015-07-27 13:17:45 -0700958 ;
Alexandru Moșoi198fc9a2015-08-14 12:59:33 +0200959 case OpOr16:
960 // match: (Or16 x x)
961 // cond:
962 // result: x
963 {
964 x := v.Args[0]
965 if v.Args[1] != x {
966 goto end47a2f25fd31a76807aced3e2b126acdc
967 }
968 v.Op = OpCopy
969 v.AuxInt = 0
970 v.Aux = nil
971 v.resetArgs()
972 v.Type = x.Type
973 v.AddArg(x)
974 return true
975 }
976 goto end47a2f25fd31a76807aced3e2b126acdc
977 end47a2f25fd31a76807aced3e2b126acdc:
978 ;
979 case OpOr32:
980 // match: (Or32 x x)
981 // cond:
982 // result: x
983 {
984 x := v.Args[0]
985 if v.Args[1] != x {
986 goto end231e283e568e90bd9a3e6a4fa328c8a4
987 }
988 v.Op = OpCopy
989 v.AuxInt = 0
990 v.Aux = nil
991 v.resetArgs()
992 v.Type = x.Type
993 v.AddArg(x)
994 return true
995 }
996 goto end231e283e568e90bd9a3e6a4fa328c8a4
997 end231e283e568e90bd9a3e6a4fa328c8a4:
998 ;
999 case OpOr64:
1000 // match: (Or64 x x)
1001 // cond:
1002 // result: x
1003 {
1004 x := v.Args[0]
1005 if v.Args[1] != x {
1006 goto end6b0efc212016dc97d0e3939db04c81d9
1007 }
1008 v.Op = OpCopy
1009 v.AuxInt = 0
1010 v.Aux = nil
1011 v.resetArgs()
1012 v.Type = x.Type
1013 v.AddArg(x)
1014 return true
1015 }
1016 goto end6b0efc212016dc97d0e3939db04c81d9
1017 end6b0efc212016dc97d0e3939db04c81d9:
1018 ;
1019 case OpOr8:
1020 // match: (Or8 x x)
1021 // cond:
1022 // result: x
1023 {
1024 x := v.Args[0]
1025 if v.Args[1] != x {
1026 goto end05295dbfafd6869af79b4daee9fda000
1027 }
1028 v.Op = OpCopy
1029 v.AuxInt = 0
1030 v.Aux = nil
1031 v.resetArgs()
1032 v.Type = x.Type
1033 v.AddArg(x)
1034 return true
1035 }
1036 goto end05295dbfafd6869af79b4daee9fda000
1037 end05295dbfafd6869af79b4daee9fda000:
1038 ;
Keith Randall0dca7352015-06-06 16:03:33 -07001039 case OpPtrIndex:
1040 // match: (PtrIndex <t> ptr idx)
1041 // cond:
Keith Randall9f954db2015-08-18 10:26:28 -07001042 // result: (AddPtr ptr (MulPtr <config.fe.TypeUintptr()> idx (ConstPtr <config.fe.TypeUintptr()> [t.Elem().Size()])))
Keith Randall0dca7352015-06-06 16:03:33 -07001043 {
1044 t := v.Type
1045 ptr := v.Args[0]
1046 idx := v.Args[1]
Keith Randall67fdb0d2015-07-19 15:48:20 -07001047 v.Op = OpAddPtr
Keith Randall8f22b522015-06-11 21:29:25 -07001048 v.AuxInt = 0
Keith Randall0dca7352015-06-06 16:03:33 -07001049 v.Aux = nil
1050 v.resetArgs()
1051 v.AddArg(ptr)
Keith Randall683f5d72015-08-04 12:24:23 -07001052 v0 := b.NewValue0(v.Line, OpMulPtr, TypeInvalid)
Keith Randall9f954db2015-08-18 10:26:28 -07001053 v0.Type = config.fe.TypeUintptr()
Keith Randall0dca7352015-06-06 16:03:33 -07001054 v0.AddArg(idx)
Keith Randall683f5d72015-08-04 12:24:23 -07001055 v1 := b.NewValue0(v.Line, OpConstPtr, TypeInvalid)
Keith Randall9f954db2015-08-18 10:26:28 -07001056 v1.Type = config.fe.TypeUintptr()
Keith Randall8f22b522015-06-11 21:29:25 -07001057 v1.AuxInt = t.Elem().Size()
Keith Randall0dca7352015-06-06 16:03:33 -07001058 v0.AddArg(v1)
1059 v.AddArg(v0)
1060 return true
1061 }
Keith Randall9f954db2015-08-18 10:26:28 -07001062 goto end1e1c5ef80c11231f89a5439cdda98359
1063 end1e1c5ef80c11231f89a5439cdda98359:
Keith Randall0dca7352015-06-06 16:03:33 -07001064 ;
1065 case OpSliceCap:
Keith Randall9f954db2015-08-18 10:26:28 -07001066 // match: (SliceCap (SliceMake _ _ cap))
Keith Randall0dca7352015-06-06 16:03:33 -07001067 // cond:
Keith Randall9f954db2015-08-18 10:26:28 -07001068 // result: cap
Keith Randall0dca7352015-06-06 16:03:33 -07001069 {
Keith Randall9f954db2015-08-18 10:26:28 -07001070 if v.Args[0].Op != OpSliceMake {
1071 goto end1bd11616743632b33b410964667fb3c6
Keith Randall0dca7352015-06-06 16:03:33 -07001072 }
Keith Randall9f954db2015-08-18 10:26:28 -07001073 cap := v.Args[0].Args[2]
1074 v.Op = OpCopy
Keith Randall8f22b522015-06-11 21:29:25 -07001075 v.AuxInt = 0
Keith Randall0dca7352015-06-06 16:03:33 -07001076 v.Aux = nil
1077 v.resetArgs()
Keith Randall9f954db2015-08-18 10:26:28 -07001078 v.Type = cap.Type
1079 v.AddArg(cap)
Keith Randall0dca7352015-06-06 16:03:33 -07001080 return true
1081 }
Keith Randall9f954db2015-08-18 10:26:28 -07001082 goto end1bd11616743632b33b410964667fb3c6
1083 end1bd11616743632b33b410964667fb3c6:
Keith Randall0dca7352015-06-06 16:03:33 -07001084 ;
1085 case OpSliceLen:
Keith Randall9f954db2015-08-18 10:26:28 -07001086 // match: (SliceLen (SliceMake _ len _))
Keith Randall0dca7352015-06-06 16:03:33 -07001087 // cond:
Keith Randall9f954db2015-08-18 10:26:28 -07001088 // result: len
Keith Randall0dca7352015-06-06 16:03:33 -07001089 {
Keith Randall9f954db2015-08-18 10:26:28 -07001090 if v.Args[0].Op != OpSliceMake {
1091 goto endebb2090199d13e4c2ae52fb3e778f7fd
Keith Randall0dca7352015-06-06 16:03:33 -07001092 }
Keith Randall9f954db2015-08-18 10:26:28 -07001093 len := v.Args[0].Args[1]
1094 v.Op = OpCopy
Keith Randall8f22b522015-06-11 21:29:25 -07001095 v.AuxInt = 0
Keith Randall0dca7352015-06-06 16:03:33 -07001096 v.Aux = nil
1097 v.resetArgs()
Keith Randall9f954db2015-08-18 10:26:28 -07001098 v.Type = len.Type
1099 v.AddArg(len)
Keith Randall0dca7352015-06-06 16:03:33 -07001100 return true
1101 }
Keith Randall9f954db2015-08-18 10:26:28 -07001102 goto endebb2090199d13e4c2ae52fb3e778f7fd
1103 endebb2090199d13e4c2ae52fb3e778f7fd:
Keith Randall0dca7352015-06-06 16:03:33 -07001104 ;
1105 case OpSlicePtr:
Keith Randall9f954db2015-08-18 10:26:28 -07001106 // match: (SlicePtr (SliceMake ptr _ _ ))
Keith Randall0dca7352015-06-06 16:03:33 -07001107 // cond:
Keith Randall9f954db2015-08-18 10:26:28 -07001108 // result: ptr
Keith Randall0dca7352015-06-06 16:03:33 -07001109 {
Keith Randall9f954db2015-08-18 10:26:28 -07001110 if v.Args[0].Op != OpSliceMake {
1111 goto end526acc0a705137a5d25577499206720b
Keith Randall0dca7352015-06-06 16:03:33 -07001112 }
1113 ptr := v.Args[0].Args[0]
Keith Randall9f954db2015-08-18 10:26:28 -07001114 v.Op = OpCopy
Keith Randall8f22b522015-06-11 21:29:25 -07001115 v.AuxInt = 0
Keith Randall0dca7352015-06-06 16:03:33 -07001116 v.Aux = nil
1117 v.resetArgs()
Keith Randall9f954db2015-08-18 10:26:28 -07001118 v.Type = ptr.Type
Keith Randall0dca7352015-06-06 16:03:33 -07001119 v.AddArg(ptr)
Keith Randall0dca7352015-06-06 16:03:33 -07001120 return true
1121 }
Keith Randall9f954db2015-08-18 10:26:28 -07001122 goto end526acc0a705137a5d25577499206720b
1123 end526acc0a705137a5d25577499206720b:
Keith Randall0dca7352015-06-06 16:03:33 -07001124 ;
1125 case OpStore:
David Chase52578582015-08-28 14:24:10 -04001126 // match: (Store [8] dst (ComplexMake real imag) mem)
1127 // cond:
1128 // result: (Store [4] (OffPtr <config.fe.TypeFloat32().PtrTo()> [4] dst) imag (Store <TypeMem> [4] dst real mem))
1129 {
1130 if v.AuxInt != 8 {
1131 goto endba187c049aa71488994c8a2eb3453045
1132 }
1133 dst := v.Args[0]
1134 if v.Args[1].Op != OpComplexMake {
1135 goto endba187c049aa71488994c8a2eb3453045
1136 }
1137 real := v.Args[1].Args[0]
1138 imag := v.Args[1].Args[1]
1139 mem := v.Args[2]
1140 v.Op = OpStore
1141 v.AuxInt = 0
1142 v.Aux = nil
1143 v.resetArgs()
1144 v.AuxInt = 4
1145 v0 := b.NewValue0(v.Line, OpOffPtr, TypeInvalid)
1146 v0.Type = config.fe.TypeFloat32().PtrTo()
1147 v0.AuxInt = 4
1148 v0.AddArg(dst)
1149 v.AddArg(v0)
1150 v.AddArg(imag)
1151 v1 := b.NewValue0(v.Line, OpStore, TypeInvalid)
1152 v1.Type = TypeMem
1153 v1.AuxInt = 4
1154 v1.AddArg(dst)
1155 v1.AddArg(real)
1156 v1.AddArg(mem)
1157 v.AddArg(v1)
1158 return true
1159 }
1160 goto endba187c049aa71488994c8a2eb3453045
1161 endba187c049aa71488994c8a2eb3453045:
1162 ;
1163 // match: (Store [16] dst (ComplexMake real imag) mem)
1164 // cond:
1165 // result: (Store [8] (OffPtr <config.fe.TypeFloat64().PtrTo()> [8] dst) imag (Store <TypeMem> [8] dst real mem))
1166 {
1167 if v.AuxInt != 16 {
1168 goto end4df4c826201cf51af245d6b89de00589
1169 }
1170 dst := v.Args[0]
1171 if v.Args[1].Op != OpComplexMake {
1172 goto end4df4c826201cf51af245d6b89de00589
1173 }
1174 real := v.Args[1].Args[0]
1175 imag := v.Args[1].Args[1]
1176 mem := v.Args[2]
1177 v.Op = OpStore
1178 v.AuxInt = 0
1179 v.Aux = nil
1180 v.resetArgs()
1181 v.AuxInt = 8
1182 v0 := b.NewValue0(v.Line, OpOffPtr, TypeInvalid)
1183 v0.Type = config.fe.TypeFloat64().PtrTo()
1184 v0.AuxInt = 8
1185 v0.AddArg(dst)
1186 v.AddArg(v0)
1187 v.AddArg(imag)
1188 v1 := b.NewValue0(v.Line, OpStore, TypeInvalid)
1189 v1.Type = TypeMem
1190 v1.AuxInt = 8
1191 v1.AddArg(dst)
1192 v1.AddArg(real)
1193 v1.AddArg(mem)
1194 v.AddArg(v1)
1195 return true
1196 }
1197 goto end4df4c826201cf51af245d6b89de00589
1198 end4df4c826201cf51af245d6b89de00589:
1199 ;
Keith Randall9f954db2015-08-18 10:26:28 -07001200 // match: (Store [2*config.PtrSize] dst (StringMake ptr len) mem)
1201 // cond:
1202 // result: (Store [config.PtrSize] (OffPtr <config.fe.TypeUintptr().PtrTo()> [config.PtrSize] dst) len (Store <TypeMem> [config.PtrSize] dst ptr mem))
1203 {
1204 if v.AuxInt != 2*config.PtrSize {
1205 goto end25ae4fc3dc01583a4adc45067d49940a
1206 }
1207 dst := v.Args[0]
1208 if v.Args[1].Op != OpStringMake {
1209 goto end25ae4fc3dc01583a4adc45067d49940a
1210 }
1211 ptr := v.Args[1].Args[0]
1212 len := v.Args[1].Args[1]
1213 mem := v.Args[2]
1214 v.Op = OpStore
1215 v.AuxInt = 0
1216 v.Aux = nil
1217 v.resetArgs()
1218 v.AuxInt = config.PtrSize
1219 v0 := b.NewValue0(v.Line, OpOffPtr, TypeInvalid)
1220 v0.Type = config.fe.TypeUintptr().PtrTo()
1221 v0.AuxInt = config.PtrSize
1222 v0.AddArg(dst)
1223 v.AddArg(v0)
1224 v.AddArg(len)
1225 v1 := b.NewValue0(v.Line, OpStore, TypeInvalid)
1226 v1.Type = TypeMem
1227 v1.AuxInt = config.PtrSize
1228 v1.AddArg(dst)
1229 v1.AddArg(ptr)
1230 v1.AddArg(mem)
1231 v.AddArg(v1)
1232 return true
1233 }
1234 goto end25ae4fc3dc01583a4adc45067d49940a
1235 end25ae4fc3dc01583a4adc45067d49940a:
1236 ;
1237 // match: (Store [3*config.PtrSize] dst (SliceMake ptr len cap) mem)
1238 // cond:
1239 // result: (Store [config.PtrSize] (OffPtr <config.fe.TypeUintptr().PtrTo()> [2*config.PtrSize] dst) cap (Store <TypeMem> [config.PtrSize] (OffPtr <config.fe.TypeUintptr().PtrTo()> [config.PtrSize] dst) len (Store <TypeMem> [config.PtrSize] dst ptr mem)))
1240 {
1241 if v.AuxInt != 3*config.PtrSize {
1242 goto end39ab85d51c8cd7f5d54e3eea4fb79a96
1243 }
1244 dst := v.Args[0]
1245 if v.Args[1].Op != OpSliceMake {
1246 goto end39ab85d51c8cd7f5d54e3eea4fb79a96
1247 }
1248 ptr := v.Args[1].Args[0]
1249 len := v.Args[1].Args[1]
1250 cap := v.Args[1].Args[2]
1251 mem := v.Args[2]
1252 v.Op = OpStore
1253 v.AuxInt = 0
1254 v.Aux = nil
1255 v.resetArgs()
1256 v.AuxInt = config.PtrSize
1257 v0 := b.NewValue0(v.Line, OpOffPtr, TypeInvalid)
1258 v0.Type = config.fe.TypeUintptr().PtrTo()
1259 v0.AuxInt = 2 * config.PtrSize
1260 v0.AddArg(dst)
1261 v.AddArg(v0)
1262 v.AddArg(cap)
1263 v1 := b.NewValue0(v.Line, OpStore, TypeInvalid)
1264 v1.Type = TypeMem
1265 v1.AuxInt = config.PtrSize
1266 v2 := b.NewValue0(v.Line, OpOffPtr, TypeInvalid)
1267 v2.Type = config.fe.TypeUintptr().PtrTo()
1268 v2.AuxInt = config.PtrSize
1269 v2.AddArg(dst)
1270 v1.AddArg(v2)
1271 v1.AddArg(len)
1272 v3 := b.NewValue0(v.Line, OpStore, TypeInvalid)
1273 v3.Type = TypeMem
1274 v3.AuxInt = config.PtrSize
1275 v3.AddArg(dst)
1276 v3.AddArg(ptr)
1277 v3.AddArg(mem)
1278 v1.AddArg(v3)
1279 v.AddArg(v1)
1280 return true
1281 }
1282 goto end39ab85d51c8cd7f5d54e3eea4fb79a96
1283 end39ab85d51c8cd7f5d54e3eea4fb79a96:
1284 ;
1285 // match: (Store [2*config.PtrSize] dst (IMake itab data) mem)
1286 // cond:
1287 // result: (Store [config.PtrSize] (OffPtr <config.fe.TypeBytePtr().PtrTo()> [config.PtrSize] dst) data (Store <TypeMem> [config.PtrSize] dst itab mem))
1288 {
1289 if v.AuxInt != 2*config.PtrSize {
1290 goto end63b77ae78d92c05d496202e8b6b96ff3
1291 }
1292 dst := v.Args[0]
1293 if v.Args[1].Op != OpIMake {
1294 goto end63b77ae78d92c05d496202e8b6b96ff3
1295 }
1296 itab := v.Args[1].Args[0]
1297 data := v.Args[1].Args[1]
1298 mem := v.Args[2]
1299 v.Op = OpStore
1300 v.AuxInt = 0
1301 v.Aux = nil
1302 v.resetArgs()
1303 v.AuxInt = config.PtrSize
1304 v0 := b.NewValue0(v.Line, OpOffPtr, TypeInvalid)
1305 v0.Type = config.fe.TypeBytePtr().PtrTo()
1306 v0.AuxInt = config.PtrSize
1307 v0.AddArg(dst)
1308 v.AddArg(v0)
1309 v.AddArg(data)
1310 v1 := b.NewValue0(v.Line, OpStore, TypeInvalid)
1311 v1.Type = TypeMem
1312 v1.AuxInt = config.PtrSize
1313 v1.AddArg(dst)
1314 v1.AddArg(itab)
1315 v1.AddArg(mem)
1316 v.AddArg(v1)
1317 return true
1318 }
1319 goto end63b77ae78d92c05d496202e8b6b96ff3
1320 end63b77ae78d92c05d496202e8b6b96ff3:
1321 ;
Keith Randalld4cc51d2015-08-14 21:47:20 -07001322 // match: (Store [size] dst (Load src mem) mem)
1323 // cond: size > config.IntSize
1324 // result: (Move [size] dst src mem)
Keith Randall0dca7352015-06-06 16:03:33 -07001325 {
Keith Randalld4cc51d2015-08-14 21:47:20 -07001326 size := v.AuxInt
Keith Randall0dca7352015-06-06 16:03:33 -07001327 dst := v.Args[0]
1328 if v.Args[1].Op != OpLoad {
Keith Randalld4cc51d2015-08-14 21:47:20 -07001329 goto enda18a7163888e2f4fca9f38bae56cef42
Keith Randall0dca7352015-06-06 16:03:33 -07001330 }
Keith Randall0dca7352015-06-06 16:03:33 -07001331 src := v.Args[1].Args[0]
1332 mem := v.Args[1].Args[1]
Alexandru Moșoi9b25da72015-07-31 12:32:22 +02001333 if v.Args[2] != mem {
Keith Randalld4cc51d2015-08-14 21:47:20 -07001334 goto enda18a7163888e2f4fca9f38bae56cef42
Keith Randall0dca7352015-06-06 16:03:33 -07001335 }
Keith Randalld4cc51d2015-08-14 21:47:20 -07001336 if !(size > config.IntSize) {
1337 goto enda18a7163888e2f4fca9f38bae56cef42
Keith Randall0dca7352015-06-06 16:03:33 -07001338 }
1339 v.Op = OpMove
Keith Randall8f22b522015-06-11 21:29:25 -07001340 v.AuxInt = 0
Keith Randall0dca7352015-06-06 16:03:33 -07001341 v.Aux = nil
1342 v.resetArgs()
Keith Randalld4cc51d2015-08-14 21:47:20 -07001343 v.AuxInt = size
Keith Randall0dca7352015-06-06 16:03:33 -07001344 v.AddArg(dst)
1345 v.AddArg(src)
1346 v.AddArg(mem)
1347 return true
1348 }
Keith Randalld4cc51d2015-08-14 21:47:20 -07001349 goto enda18a7163888e2f4fca9f38bae56cef42
1350 enda18a7163888e2f4fca9f38bae56cef42:
Keith Randall0dca7352015-06-06 16:03:33 -07001351 ;
Keith Randall0dca7352015-06-06 16:03:33 -07001352 case OpStringLen:
1353 // match: (StringLen (StringMake _ len))
1354 // cond:
1355 // result: len
1356 {
1357 if v.Args[0].Op != OpStringMake {
1358 goto end0d922460b7e5ca88324034f4bd6c027c
1359 }
1360 len := v.Args[0].Args[1]
Josh Bleecher Snyder0fb818a2015-08-05 10:33:09 -07001361 v.Op = OpCopy
1362 v.AuxInt = 0
1363 v.Aux = nil
Keith Randall0dca7352015-06-06 16:03:33 -07001364 v.resetArgs()
Josh Bleecher Snyder0fb818a2015-08-05 10:33:09 -07001365 v.Type = len.Type
1366 v.AddArg(len)
Keith Randall0dca7352015-06-06 16:03:33 -07001367 return true
1368 }
1369 goto end0d922460b7e5ca88324034f4bd6c027c
1370 end0d922460b7e5ca88324034f4bd6c027c:
1371 ;
1372 case OpStringPtr:
1373 // match: (StringPtr (StringMake ptr _))
1374 // cond:
1375 // result: ptr
1376 {
1377 if v.Args[0].Op != OpStringMake {
1378 goto end061edc5d85c73ad909089af2556d9380
1379 }
1380 ptr := v.Args[0].Args[0]
Josh Bleecher Snyder0fb818a2015-08-05 10:33:09 -07001381 v.Op = OpCopy
1382 v.AuxInt = 0
1383 v.Aux = nil
Keith Randall0dca7352015-06-06 16:03:33 -07001384 v.resetArgs()
Josh Bleecher Snyder0fb818a2015-08-05 10:33:09 -07001385 v.Type = ptr.Type
1386 v.AddArg(ptr)
Keith Randall0dca7352015-06-06 16:03:33 -07001387 return true
1388 }
1389 goto end061edc5d85c73ad909089af2556d9380
1390 end061edc5d85c73ad909089af2556d9380:
Keith Randallcd7e0592015-07-15 21:33:49 -07001391 ;
1392 case OpStructSelect:
1393 // match: (StructSelect [idx] (Load ptr mem))
1394 // cond:
1395 // result: (Load (OffPtr <v.Type.PtrTo()> [idx] ptr) mem)
1396 {
1397 idx := v.AuxInt
1398 if v.Args[0].Op != OpLoad {
1399 goto end16fdb45e1dd08feb36e3cc3fb5ed8935
1400 }
1401 ptr := v.Args[0].Args[0]
1402 mem := v.Args[0].Args[1]
1403 v.Op = OpLoad
1404 v.AuxInt = 0
1405 v.Aux = nil
1406 v.resetArgs()
Keith Randall683f5d72015-08-04 12:24:23 -07001407 v0 := b.NewValue0(v.Line, OpOffPtr, TypeInvalid)
Keith Randallcd7e0592015-07-15 21:33:49 -07001408 v0.Type = v.Type.PtrTo()
1409 v0.AuxInt = idx
1410 v0.AddArg(ptr)
1411 v.AddArg(v0)
1412 v.AddArg(mem)
1413 return true
1414 }
1415 goto end16fdb45e1dd08feb36e3cc3fb5ed8935
1416 end16fdb45e1dd08feb36e3cc3fb5ed8935:
Alexandru Moșoi198fc9a2015-08-14 12:59:33 +02001417 ;
1418 case OpSub16:
1419 // match: (Sub16 x x)
1420 // cond:
1421 // result: (Const16 [0])
1422 {
1423 x := v.Args[0]
1424 if v.Args[1] != x {
1425 goto end83da541391be564f2a08464e674a49e7
1426 }
1427 v.Op = OpConst16
1428 v.AuxInt = 0
1429 v.Aux = nil
1430 v.resetArgs()
1431 v.AuxInt = 0
1432 return true
1433 }
1434 goto end83da541391be564f2a08464e674a49e7
1435 end83da541391be564f2a08464e674a49e7:
1436 ;
1437 case OpSub32:
1438 // match: (Sub32 x x)
1439 // cond:
1440 // result: (Const32 [0])
1441 {
1442 x := v.Args[0]
1443 if v.Args[1] != x {
1444 goto enda747581e798f199e07f4ad69747cd069
1445 }
1446 v.Op = OpConst32
1447 v.AuxInt = 0
1448 v.Aux = nil
1449 v.resetArgs()
1450 v.AuxInt = 0
1451 return true
1452 }
1453 goto enda747581e798f199e07f4ad69747cd069
1454 enda747581e798f199e07f4ad69747cd069:
1455 ;
1456 case OpSub64:
1457 // match: (Sub64 x x)
1458 // cond:
1459 // result: (Const64 [0])
1460 {
1461 x := v.Args[0]
1462 if v.Args[1] != x {
1463 goto end0387dc2b7bbe57d4aa54eab5d959da4b
1464 }
1465 v.Op = OpConst64
1466 v.AuxInt = 0
1467 v.Aux = nil
1468 v.resetArgs()
1469 v.AuxInt = 0
1470 return true
1471 }
1472 goto end0387dc2b7bbe57d4aa54eab5d959da4b
1473 end0387dc2b7bbe57d4aa54eab5d959da4b:
1474 ;
1475 case OpSub8:
1476 // match: (Sub8 x x)
1477 // cond:
1478 // result: (Const8 [0])
1479 {
1480 x := v.Args[0]
1481 if v.Args[1] != x {
1482 goto end4e2ee15ef17611919a1a6b5f80bbfe18
1483 }
1484 v.Op = OpConst8
1485 v.AuxInt = 0
1486 v.Aux = nil
1487 v.resetArgs()
1488 v.AuxInt = 0
1489 return true
1490 }
1491 goto end4e2ee15ef17611919a1a6b5f80bbfe18
1492 end4e2ee15ef17611919a1a6b5f80bbfe18:
1493 ;
1494 case OpXor16:
1495 // match: (Xor16 x x)
1496 // cond:
1497 // result: (Const16 [0])
1498 {
1499 x := v.Args[0]
1500 if v.Args[1] != x {
1501 goto end5733ceb1903b8140248d8e2cac02fefe
1502 }
1503 v.Op = OpConst16
1504 v.AuxInt = 0
1505 v.Aux = nil
1506 v.resetArgs()
1507 v.AuxInt = 0
1508 return true
1509 }
1510 goto end5733ceb1903b8140248d8e2cac02fefe
1511 end5733ceb1903b8140248d8e2cac02fefe:
1512 ;
1513 case OpXor32:
1514 // match: (Xor32 x x)
1515 // cond:
1516 // result: (Const32 [0])
1517 {
1518 x := v.Args[0]
1519 if v.Args[1] != x {
1520 goto end268ca02df6515d648e0bfb4e90981d25
1521 }
1522 v.Op = OpConst32
1523 v.AuxInt = 0
1524 v.Aux = nil
1525 v.resetArgs()
1526 v.AuxInt = 0
1527 return true
1528 }
1529 goto end268ca02df6515d648e0bfb4e90981d25
1530 end268ca02df6515d648e0bfb4e90981d25:
1531 ;
1532 case OpXor64:
1533 // match: (Xor64 x x)
1534 // cond:
1535 // result: (Const64 [0])
1536 {
1537 x := v.Args[0]
1538 if v.Args[1] != x {
1539 goto endaf44e7f9fc58af30df69070953fb45ce
1540 }
1541 v.Op = OpConst64
1542 v.AuxInt = 0
1543 v.Aux = nil
1544 v.resetArgs()
1545 v.AuxInt = 0
1546 return true
1547 }
1548 goto endaf44e7f9fc58af30df69070953fb45ce
1549 endaf44e7f9fc58af30df69070953fb45ce:
1550 ;
1551 case OpXor8:
1552 // match: (Xor8 x x)
1553 // cond:
1554 // result: (Const8 [0])
1555 {
1556 x := v.Args[0]
1557 if v.Args[1] != x {
1558 goto end949b3a60b7d181688e6f79f93c782fc8
1559 }
1560 v.Op = OpConst8
1561 v.AuxInt = 0
1562 v.Aux = nil
1563 v.resetArgs()
1564 v.AuxInt = 0
1565 return true
1566 }
1567 goto end949b3a60b7d181688e6f79f93c782fc8
1568 end949b3a60b7d181688e6f79f93c782fc8:
Keith Randall0dca7352015-06-06 16:03:33 -07001569 }
1570 return false
1571}
1572func rewriteBlockgeneric(b *Block) bool {
1573 switch b.Kind {
1574 case BlockIf:
Josh Bleecher Snyder3d23afb2015-08-12 11:22:16 -07001575 // match: (If (IsNonNil (GetG)) yes no)
1576 // cond:
Keith Randall186cf1b2015-08-28 16:45:17 -07001577 // result: (First nil yes no)
Josh Bleecher Snyder3d23afb2015-08-12 11:22:16 -07001578 {
1579 v := b.Control
1580 if v.Op != OpIsNonNil {
Keith Randall186cf1b2015-08-28 16:45:17 -07001581 goto endafdc4e2525f9933ab0ae7effc3559597
Josh Bleecher Snyder3d23afb2015-08-12 11:22:16 -07001582 }
1583 if v.Args[0].Op != OpGetG {
Keith Randall186cf1b2015-08-28 16:45:17 -07001584 goto endafdc4e2525f9933ab0ae7effc3559597
Josh Bleecher Snyder3d23afb2015-08-12 11:22:16 -07001585 }
1586 yes := b.Succs[0]
1587 no := b.Succs[1]
Keith Randall186cf1b2015-08-28 16:45:17 -07001588 b.Kind = BlockFirst
Josh Bleecher Snyder3d23afb2015-08-12 11:22:16 -07001589 b.Control = nil
Josh Bleecher Snyder3d23afb2015-08-12 11:22:16 -07001590 b.Succs[0] = yes
Keith Randall186cf1b2015-08-28 16:45:17 -07001591 b.Succs[1] = no
Josh Bleecher Snyder3d23afb2015-08-12 11:22:16 -07001592 return true
1593 }
Keith Randall186cf1b2015-08-28 16:45:17 -07001594 goto endafdc4e2525f9933ab0ae7effc3559597
1595 endafdc4e2525f9933ab0ae7effc3559597:
Josh Bleecher Snyder3d23afb2015-08-12 11:22:16 -07001596 ;
Todd Neal52d76f72015-07-23 18:44:09 -05001597 // match: (If (Not cond) yes no)
1598 // cond:
1599 // result: (If cond no yes)
1600 {
1601 v := b.Control
1602 if v.Op != OpNot {
1603 goto endebe19c1c3c3bec068cdb2dd29ef57f96
1604 }
1605 cond := v.Args[0]
1606 yes := b.Succs[0]
1607 no := b.Succs[1]
1608 b.Kind = BlockIf
1609 b.Control = cond
1610 b.Succs[0] = no
1611 b.Succs[1] = yes
Josh Bleecher Snyderbbf8c5c2015-08-11 17:28:56 -07001612 b.Likely *= -1
Todd Neal52d76f72015-07-23 18:44:09 -05001613 return true
1614 }
1615 goto endebe19c1c3c3bec068cdb2dd29ef57f96
1616 endebe19c1c3c3bec068cdb2dd29ef57f96:
1617 ;
Keith Randall9cb332e2015-07-28 14:19:20 -07001618 // match: (If (ConstBool {c}) yes no)
Keith Randall0dca7352015-06-06 16:03:33 -07001619 // cond: c.(bool)
Keith Randall186cf1b2015-08-28 16:45:17 -07001620 // result: (First nil yes no)
Keith Randall0dca7352015-06-06 16:03:33 -07001621 {
1622 v := b.Control
Keith Randall9cb332e2015-07-28 14:19:20 -07001623 if v.Op != OpConstBool {
Keith Randall186cf1b2015-08-28 16:45:17 -07001624 goto end7a20763049489cdb40bb1eaa57d113d8
Keith Randall0dca7352015-06-06 16:03:33 -07001625 }
1626 c := v.Aux
1627 yes := b.Succs[0]
1628 no := b.Succs[1]
1629 if !(c.(bool)) {
Keith Randall186cf1b2015-08-28 16:45:17 -07001630 goto end7a20763049489cdb40bb1eaa57d113d8
Keith Randall0dca7352015-06-06 16:03:33 -07001631 }
Keith Randall186cf1b2015-08-28 16:45:17 -07001632 b.Kind = BlockFirst
Keith Randall0dca7352015-06-06 16:03:33 -07001633 b.Control = nil
Keith Randall0dca7352015-06-06 16:03:33 -07001634 b.Succs[0] = yes
Keith Randall186cf1b2015-08-28 16:45:17 -07001635 b.Succs[1] = no
Keith Randall0dca7352015-06-06 16:03:33 -07001636 return true
1637 }
Keith Randall186cf1b2015-08-28 16:45:17 -07001638 goto end7a20763049489cdb40bb1eaa57d113d8
1639 end7a20763049489cdb40bb1eaa57d113d8:
Keith Randall0dca7352015-06-06 16:03:33 -07001640 ;
Keith Randall9cb332e2015-07-28 14:19:20 -07001641 // match: (If (ConstBool {c}) yes no)
Keith Randall0dca7352015-06-06 16:03:33 -07001642 // cond: !c.(bool)
Keith Randall186cf1b2015-08-28 16:45:17 -07001643 // result: (First nil no yes)
Keith Randall0dca7352015-06-06 16:03:33 -07001644 {
1645 v := b.Control
Keith Randall9cb332e2015-07-28 14:19:20 -07001646 if v.Op != OpConstBool {
Keith Randall186cf1b2015-08-28 16:45:17 -07001647 goto end3ecbf5b2cc1f0a08444d8ab1871a829c
Keith Randall0dca7352015-06-06 16:03:33 -07001648 }
1649 c := v.Aux
1650 yes := b.Succs[0]
1651 no := b.Succs[1]
1652 if !(!c.(bool)) {
Keith Randall186cf1b2015-08-28 16:45:17 -07001653 goto end3ecbf5b2cc1f0a08444d8ab1871a829c
Keith Randall0dca7352015-06-06 16:03:33 -07001654 }
Keith Randall186cf1b2015-08-28 16:45:17 -07001655 b.Kind = BlockFirst
Keith Randall0dca7352015-06-06 16:03:33 -07001656 b.Control = nil
Keith Randall0dca7352015-06-06 16:03:33 -07001657 b.Succs[0] = no
Keith Randall186cf1b2015-08-28 16:45:17 -07001658 b.Succs[1] = yes
1659 b.Likely *= -1
Keith Randall0dca7352015-06-06 16:03:33 -07001660 return true
1661 }
Keith Randall186cf1b2015-08-28 16:45:17 -07001662 goto end3ecbf5b2cc1f0a08444d8ab1871a829c
1663 end3ecbf5b2cc1f0a08444d8ab1871a829c:
Keith Randall0dca7352015-06-06 16:03:33 -07001664 }
1665 return false
1666}