1
2
3 package ssa
4
5 import "internal/buildcfg"
6 import "cmd/compile/internal/types"
7
8 func rewriteValuePPC64latelower(v *Value) bool {
9 switch v.Op {
10 case OpPPC64ADD:
11 return rewriteValuePPC64latelower_OpPPC64ADD(v)
12 case OpPPC64AND:
13 return rewriteValuePPC64latelower_OpPPC64AND(v)
14 case OpPPC64CMPconst:
15 return rewriteValuePPC64latelower_OpPPC64CMPconst(v)
16 case OpPPC64ISEL:
17 return rewriteValuePPC64latelower_OpPPC64ISEL(v)
18 case OpPPC64RLDICL:
19 return rewriteValuePPC64latelower_OpPPC64RLDICL(v)
20 case OpPPC64SETBC:
21 return rewriteValuePPC64latelower_OpPPC64SETBC(v)
22 case OpPPC64SETBCR:
23 return rewriteValuePPC64latelower_OpPPC64SETBCR(v)
24 case OpSelect0:
25 return rewriteValuePPC64latelower_OpSelect0(v)
26 }
27 return false
28 }
29 func rewriteValuePPC64latelower_OpPPC64ADD(v *Value) bool {
30 v_1 := v.Args[1]
31 v_0 := v.Args[0]
32
33
34
35 for {
36 for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 {
37 if v_0.Op != OpPPC64MOVDconst {
38 continue
39 }
40 m := auxIntToInt64(v_0.AuxInt)
41 x := v_1
42 if !(supportsPPC64PCRel() && (m<<30)>>30 == m) {
43 continue
44 }
45 v.reset(OpPPC64ADDconst)
46 v.AuxInt = int64ToAuxInt(m)
47 v.AddArg(x)
48 return true
49 }
50 break
51 }
52 return false
53 }
54 func rewriteValuePPC64latelower_OpPPC64AND(v *Value) bool {
55 v_1 := v.Args[1]
56 v_0 := v.Args[0]
57 b := v.Block
58 typ := &b.Func.Config.Types
59
60
61
62 for {
63 t := v.Type
64 for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 {
65 x := v_0
66 if x.Op != OpPPC64MOVDconst {
67 continue
68 }
69 m := auxIntToInt64(x.AuxInt)
70 n := v_1
71 if !(t.Size() <= 2) {
72 continue
73 }
74 v.reset(OpSelect0)
75 v0 := b.NewValue0(v.Pos, OpPPC64ANDCCconst, types.NewTuple(typ.Int, types.TypeFlags))
76 v0.AuxInt = int64ToAuxInt(int64(int16(m)))
77 v0.AddArg(n)
78 v.AddArg(v0)
79 return true
80 }
81 break
82 }
83
84
85
86 for {
87 for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 {
88 x := v_0
89 if x.Op != OpPPC64MOVDconst {
90 continue
91 }
92 m := auxIntToInt64(x.AuxInt)
93 n := v_1
94 if !(isPPC64ValidShiftMask(m)) {
95 continue
96 }
97 v.reset(OpPPC64RLDICL)
98 v.AuxInt = int64ToAuxInt(encodePPC64RotateMask(0, m, 64))
99 v.AddArg(n)
100 return true
101 }
102 break
103 }
104
105
106
107 for {
108 for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 {
109 x := v_0
110 if x.Op != OpPPC64MOVDconst {
111 continue
112 }
113 m := auxIntToInt64(x.AuxInt)
114 n := v_1
115 if !(m != 0 && isPPC64ValidShiftMask(^m)) {
116 continue
117 }
118 v.reset(OpPPC64RLDICR)
119 v.AuxInt = int64ToAuxInt(encodePPC64RotateMask(0, m, 64))
120 v.AddArg(n)
121 return true
122 }
123 break
124 }
125
126
127
128 for {
129 t := v.Type
130 for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 {
131 x := v_0
132 if x.Op != OpPPC64MOVDconst {
133 continue
134 }
135 m := auxIntToInt64(x.AuxInt)
136 n := v_1
137 if !(t.Size() == 4 && isPPC64WordRotateMask(m)) {
138 continue
139 }
140 v.reset(OpPPC64RLWINM)
141 v.AuxInt = int64ToAuxInt(encodePPC64RotateMask(0, m, 32))
142 v.AddArg(n)
143 return true
144 }
145 break
146 }
147 return false
148 }
149 func rewriteValuePPC64latelower_OpPPC64CMPconst(v *Value) bool {
150 v_0 := v.Args[0]
151
152
153
154 for {
155 if auxIntToInt64(v.AuxInt) != 0 {
156 break
157 }
158 z := v_0
159 if z.Op != OpPPC64ADD {
160 break
161 }
162 if !(v.Block == z.Block) {
163 break
164 }
165 v.reset(OpPPC64CMPconst)
166 v.AuxInt = int64ToAuxInt(0)
167 v.AddArg(convertPPC64OpToOpCC(z))
168 return true
169 }
170
171
172
173 for {
174 if auxIntToInt64(v.AuxInt) != 0 {
175 break
176 }
177 z := v_0
178 if z.Op != OpPPC64AND {
179 break
180 }
181 if !(v.Block == z.Block) {
182 break
183 }
184 v.reset(OpPPC64CMPconst)
185 v.AuxInt = int64ToAuxInt(0)
186 v.AddArg(convertPPC64OpToOpCC(z))
187 return true
188 }
189
190
191
192 for {
193 if auxIntToInt64(v.AuxInt) != 0 {
194 break
195 }
196 z := v_0
197 if z.Op != OpPPC64ANDN {
198 break
199 }
200 if !(v.Block == z.Block) {
201 break
202 }
203 v.reset(OpPPC64CMPconst)
204 v.AuxInt = int64ToAuxInt(0)
205 v.AddArg(convertPPC64OpToOpCC(z))
206 return true
207 }
208
209
210
211 for {
212 if auxIntToInt64(v.AuxInt) != 0 {
213 break
214 }
215 z := v_0
216 if z.Op != OpPPC64OR {
217 break
218 }
219 if !(v.Block == z.Block) {
220 break
221 }
222 v.reset(OpPPC64CMPconst)
223 v.AuxInt = int64ToAuxInt(0)
224 v.AddArg(convertPPC64OpToOpCC(z))
225 return true
226 }
227
228
229
230 for {
231 if auxIntToInt64(v.AuxInt) != 0 {
232 break
233 }
234 z := v_0
235 if z.Op != OpPPC64SUB {
236 break
237 }
238 if !(v.Block == z.Block) {
239 break
240 }
241 v.reset(OpPPC64CMPconst)
242 v.AuxInt = int64ToAuxInt(0)
243 v.AddArg(convertPPC64OpToOpCC(z))
244 return true
245 }
246
247
248
249 for {
250 if auxIntToInt64(v.AuxInt) != 0 {
251 break
252 }
253 z := v_0
254 if z.Op != OpPPC64NOR {
255 break
256 }
257 if !(v.Block == z.Block) {
258 break
259 }
260 v.reset(OpPPC64CMPconst)
261 v.AuxInt = int64ToAuxInt(0)
262 v.AddArg(convertPPC64OpToOpCC(z))
263 return true
264 }
265
266
267
268 for {
269 if auxIntToInt64(v.AuxInt) != 0 {
270 break
271 }
272 z := v_0
273 if z.Op != OpPPC64XOR {
274 break
275 }
276 if !(v.Block == z.Block) {
277 break
278 }
279 v.reset(OpPPC64CMPconst)
280 v.AuxInt = int64ToAuxInt(0)
281 v.AddArg(convertPPC64OpToOpCC(z))
282 return true
283 }
284
285
286
287 for {
288 if auxIntToInt64(v.AuxInt) != 0 {
289 break
290 }
291 z := v_0
292 if z.Op != OpPPC64NEG {
293 break
294 }
295 if !(v.Block == z.Block) {
296 break
297 }
298 v.reset(OpPPC64CMPconst)
299 v.AuxInt = int64ToAuxInt(0)
300 v.AddArg(convertPPC64OpToOpCC(z))
301 return true
302 }
303
304
305
306 for {
307 if auxIntToInt64(v.AuxInt) != 0 {
308 break
309 }
310 z := v_0
311 if z.Op != OpPPC64CNTLZD {
312 break
313 }
314 if !(v.Block == z.Block) {
315 break
316 }
317 v.reset(OpPPC64CMPconst)
318 v.AuxInt = int64ToAuxInt(0)
319 v.AddArg(convertPPC64OpToOpCC(z))
320 return true
321 }
322
323
324
325 for {
326 if auxIntToInt64(v.AuxInt) != 0 {
327 break
328 }
329 z := v_0
330 if z.Op != OpPPC64ADDconst {
331 break
332 }
333 c := auxIntToInt64(z.AuxInt)
334 if !(int64(int16(c)) == c && v.Block == z.Block) {
335 break
336 }
337 v.reset(OpPPC64CMPconst)
338 v.AuxInt = int64ToAuxInt(0)
339 v.AddArg(convertPPC64OpToOpCC(z))
340 return true
341 }
342
343
344 for {
345 t := v.Type
346 if auxIntToInt64(v.AuxInt) != 0 || v_0.Op != OpSelect0 {
347 break
348 }
349 z := v_0.Args[0]
350 if z.Op != OpPPC64ADDCC {
351 break
352 }
353 v.reset(OpSelect1)
354 v.Type = t
355 v.AddArg(z)
356 return true
357 }
358
359
360 for {
361 t := v.Type
362 if auxIntToInt64(v.AuxInt) != 0 || v_0.Op != OpSelect0 {
363 break
364 }
365 z := v_0.Args[0]
366 if z.Op != OpPPC64ANDCC {
367 break
368 }
369 v.reset(OpSelect1)
370 v.Type = t
371 v.AddArg(z)
372 return true
373 }
374
375
376 for {
377 t := v.Type
378 if auxIntToInt64(v.AuxInt) != 0 || v_0.Op != OpSelect0 {
379 break
380 }
381 z := v_0.Args[0]
382 if z.Op != OpPPC64ANDNCC {
383 break
384 }
385 v.reset(OpSelect1)
386 v.Type = t
387 v.AddArg(z)
388 return true
389 }
390
391
392 for {
393 t := v.Type
394 if auxIntToInt64(v.AuxInt) != 0 || v_0.Op != OpSelect0 {
395 break
396 }
397 z := v_0.Args[0]
398 if z.Op != OpPPC64ORCC {
399 break
400 }
401 v.reset(OpSelect1)
402 v.Type = t
403 v.AddArg(z)
404 return true
405 }
406
407
408 for {
409 t := v.Type
410 if auxIntToInt64(v.AuxInt) != 0 || v_0.Op != OpSelect0 {
411 break
412 }
413 z := v_0.Args[0]
414 if z.Op != OpPPC64SUBCC {
415 break
416 }
417 v.reset(OpSelect1)
418 v.Type = t
419 v.AddArg(z)
420 return true
421 }
422
423
424 for {
425 t := v.Type
426 if auxIntToInt64(v.AuxInt) != 0 || v_0.Op != OpSelect0 {
427 break
428 }
429 z := v_0.Args[0]
430 if z.Op != OpPPC64NORCC {
431 break
432 }
433 v.reset(OpSelect1)
434 v.Type = t
435 v.AddArg(z)
436 return true
437 }
438
439
440 for {
441 t := v.Type
442 if auxIntToInt64(v.AuxInt) != 0 || v_0.Op != OpSelect0 {
443 break
444 }
445 z := v_0.Args[0]
446 if z.Op != OpPPC64XORCC {
447 break
448 }
449 v.reset(OpSelect1)
450 v.Type = t
451 v.AddArg(z)
452 return true
453 }
454
455
456 for {
457 t := v.Type
458 if auxIntToInt64(v.AuxInt) != 0 || v_0.Op != OpSelect0 {
459 break
460 }
461 z := v_0.Args[0]
462 if z.Op != OpPPC64ADDCCconst {
463 break
464 }
465 v.reset(OpSelect1)
466 v.Type = t
467 v.AddArg(z)
468 return true
469 }
470
471
472 for {
473 t := v.Type
474 if auxIntToInt64(v.AuxInt) != 0 || v_0.Op != OpSelect0 {
475 break
476 }
477 z := v_0.Args[0]
478 if z.Op != OpPPC64NEGCC {
479 break
480 }
481 v.reset(OpSelect1)
482 v.Type = t
483 v.AddArg(z)
484 return true
485 }
486
487
488 for {
489 t := v.Type
490 if auxIntToInt64(v.AuxInt) != 0 || v_0.Op != OpSelect0 {
491 break
492 }
493 z := v_0.Args[0]
494 if z.Op != OpPPC64CNTLZDCC {
495 break
496 }
497 v.reset(OpSelect1)
498 v.Type = t
499 v.AddArg(z)
500 return true
501 }
502 return false
503 }
504 func rewriteValuePPC64latelower_OpPPC64ISEL(v *Value) bool {
505 v_2 := v.Args[2]
506 v_1 := v.Args[1]
507 v_0 := v.Args[0]
508
509
510 for {
511 a := auxIntToInt32(v.AuxInt)
512 x := v_0
513 if v_1.Op != OpPPC64MOVDconst || auxIntToInt64(v_1.AuxInt) != 0 {
514 break
515 }
516 z := v_2
517 v.reset(OpPPC64ISELZ)
518 v.AuxInt = int32ToAuxInt(a)
519 v.AddArg2(x, z)
520 return true
521 }
522
523
524 for {
525 a := auxIntToInt32(v.AuxInt)
526 if v_0.Op != OpPPC64MOVDconst || auxIntToInt64(v_0.AuxInt) != 0 {
527 break
528 }
529 y := v_1
530 z := v_2
531 v.reset(OpPPC64ISELZ)
532 v.AuxInt = int32ToAuxInt(a ^ 0x4)
533 v.AddArg2(y, z)
534 return true
535 }
536 return false
537 }
538 func rewriteValuePPC64latelower_OpPPC64RLDICL(v *Value) bool {
539 v_0 := v.Args[0]
540
541
542
543 for {
544 em := auxIntToInt64(v.AuxInt)
545 x := v_0
546 if x.Op != OpPPC64SRDconst {
547 break
548 }
549 s := auxIntToInt64(x.AuxInt)
550 a := x.Args[0]
551 if !((em & 0xFF0000) == 0) {
552 break
553 }
554 v.reset(OpPPC64RLDICL)
555 v.AuxInt = int64ToAuxInt(mergePPC64RLDICLandSRDconst(em, s))
556 v.AddArg(a)
557 return true
558 }
559 return false
560 }
561 func rewriteValuePPC64latelower_OpPPC64SETBC(v *Value) bool {
562 v_0 := v.Args[0]
563 b := v.Block
564 typ := &b.Func.Config.Types
565
566
567
568 for {
569 if auxIntToInt32(v.AuxInt) != 2 {
570 break
571 }
572 cmp := v_0
573 if !(buildcfg.GOPPC64 <= 9) {
574 break
575 }
576 v.reset(OpPPC64ISELZ)
577 v.AuxInt = int32ToAuxInt(2)
578 v0 := b.NewValue0(v.Pos, OpPPC64MOVDconst, typ.Int64)
579 v0.AuxInt = int64ToAuxInt(1)
580 v.AddArg2(v0, cmp)
581 return true
582 }
583
584
585
586 for {
587 if auxIntToInt32(v.AuxInt) != 0 {
588 break
589 }
590 cmp := v_0
591 if !(buildcfg.GOPPC64 <= 9) {
592 break
593 }
594 v.reset(OpPPC64ISELZ)
595 v.AuxInt = int32ToAuxInt(0)
596 v0 := b.NewValue0(v.Pos, OpPPC64MOVDconst, typ.Int64)
597 v0.AuxInt = int64ToAuxInt(1)
598 v.AddArg2(v0, cmp)
599 return true
600 }
601
602
603
604 for {
605 if auxIntToInt32(v.AuxInt) != 1 {
606 break
607 }
608 cmp := v_0
609 if !(buildcfg.GOPPC64 <= 9) {
610 break
611 }
612 v.reset(OpPPC64ISELZ)
613 v.AuxInt = int32ToAuxInt(1)
614 v0 := b.NewValue0(v.Pos, OpPPC64MOVDconst, typ.Int64)
615 v0.AuxInt = int64ToAuxInt(1)
616 v.AddArg2(v0, cmp)
617 return true
618 }
619 return false
620 }
621 func rewriteValuePPC64latelower_OpPPC64SETBCR(v *Value) bool {
622 v_0 := v.Args[0]
623 b := v.Block
624 typ := &b.Func.Config.Types
625
626
627
628 for {
629 if auxIntToInt32(v.AuxInt) != 2 {
630 break
631 }
632 cmp := v_0
633 if !(buildcfg.GOPPC64 <= 9) {
634 break
635 }
636 v.reset(OpPPC64ISELZ)
637 v.AuxInt = int32ToAuxInt(6)
638 v0 := b.NewValue0(v.Pos, OpPPC64MOVDconst, typ.Int64)
639 v0.AuxInt = int64ToAuxInt(1)
640 v.AddArg2(v0, cmp)
641 return true
642 }
643
644
645
646 for {
647 if auxIntToInt32(v.AuxInt) != 0 {
648 break
649 }
650 cmp := v_0
651 if !(buildcfg.GOPPC64 <= 9) {
652 break
653 }
654 v.reset(OpPPC64ISELZ)
655 v.AuxInt = int32ToAuxInt(4)
656 v0 := b.NewValue0(v.Pos, OpPPC64MOVDconst, typ.Int64)
657 v0.AuxInt = int64ToAuxInt(1)
658 v.AddArg2(v0, cmp)
659 return true
660 }
661
662
663
664 for {
665 if auxIntToInt32(v.AuxInt) != 1 {
666 break
667 }
668 cmp := v_0
669 if !(buildcfg.GOPPC64 <= 9) {
670 break
671 }
672 v.reset(OpPPC64ISELZ)
673 v.AuxInt = int32ToAuxInt(5)
674 v0 := b.NewValue0(v.Pos, OpPPC64MOVDconst, typ.Int64)
675 v0.AuxInt = int64ToAuxInt(1)
676 v.AddArg2(v0, cmp)
677 return true
678 }
679 return false
680 }
681 func rewriteValuePPC64latelower_OpSelect0(v *Value) bool {
682 v_0 := v.Args[0]
683
684
685
686 for {
687 z := v_0
688 if z.Op != OpPPC64ANDCCconst {
689 break
690 }
691 m := auxIntToInt64(z.AuxInt)
692 x := z.Args[0]
693 if !(z.Uses == 1 && isPPC64ValidShiftMask(m)) {
694 break
695 }
696 v.reset(OpPPC64RLDICL)
697 v.AuxInt = int64ToAuxInt(encodePPC64RotateMask(0, m, 64))
698 v.AddArg(x)
699 return true
700 }
701 return false
702 }
703 func rewriteBlockPPC64latelower(b *Block) bool {
704 return false
705 }
706
View as plain text