@@ -15,6 +15,7 @@ import (
15
15
"cmd/compile/internal/types"
16
16
"cmd/internal/obj"
17
17
"cmd/internal/obj/s390x"
18
+ "internal/abi"
18
19
)
19
20
20
21
// ssaMarkMoves marks any MOVXconst ops that need to avoid clobbering flags.
@@ -573,12 +574,92 @@ func ssaGenValue(s *ssagen.State, v *ssa.Value) {
573
574
p .To .Name = obj .NAME_EXTERN
574
575
// AuxInt encodes how many buffer entries we need.
575
576
p .To .Sym = ir .Syms .GCWriteBarrier [v .AuxInt - 1 ]
576
- case ssa .OpS390XLoweredPanicBoundsA , ssa .OpS390XLoweredPanicBoundsB , ssa .OpS390XLoweredPanicBoundsC :
577
- p := s .Prog (obj .ACALL )
577
+
578
+ case ssa .OpS390XLoweredPanicBoundsRR , ssa .OpS390XLoweredPanicBoundsRC , ssa .OpS390XLoweredPanicBoundsCR , ssa .OpS390XLoweredPanicBoundsCC :
579
+ // Compute the constant we put in the PCData entry for this call.
580
+ code , signed := ssa .BoundsKind (v .AuxInt ).Code ()
581
+ xIsReg := false
582
+ yIsReg := false
583
+ xVal := 0
584
+ yVal := 0
585
+ switch v .Op {
586
+ case ssa .OpS390XLoweredPanicBoundsRR :
587
+ xIsReg = true
588
+ xVal = int (v .Args [0 ].Reg () - s390x .REG_R0 )
589
+ yIsReg = true
590
+ yVal = int (v .Args [1 ].Reg () - s390x .REG_R0 )
591
+ case ssa .OpS390XLoweredPanicBoundsRC :
592
+ xIsReg = true
593
+ xVal = int (v .Args [0 ].Reg () - s390x .REG_R0 )
594
+ c := v .Aux .(ssa.PanicBoundsC ).C
595
+ if c >= 0 && c <= abi .BoundsMaxConst {
596
+ yVal = int (c )
597
+ } else {
598
+ // Move constant to a register
599
+ yIsReg = true
600
+ if yVal == xVal {
601
+ yVal = 1
602
+ }
603
+ p := s .Prog (s390x .AMOVD )
604
+ p .From .Type = obj .TYPE_CONST
605
+ p .From .Offset = c
606
+ p .To .Type = obj .TYPE_REG
607
+ p .To .Reg = s390x .REG_R0 + int16 (yVal )
608
+ }
609
+ case ssa .OpS390XLoweredPanicBoundsCR :
610
+ yIsReg = true
611
+ yVal := int (v .Args [0 ].Reg () - s390x .REG_R0 )
612
+ c := v .Aux .(ssa.PanicBoundsC ).C
613
+ if c >= 0 && c <= abi .BoundsMaxConst {
614
+ xVal = int (c )
615
+ } else {
616
+ // Move constant to a register
617
+ if xVal == yVal {
618
+ xVal = 1
619
+ }
620
+ p := s .Prog (s390x .AMOVD )
621
+ p .From .Type = obj .TYPE_CONST
622
+ p .From .Offset = c
623
+ p .To .Type = obj .TYPE_REG
624
+ p .To .Reg = s390x .REG_R0 + int16 (xVal )
625
+ }
626
+ case ssa .OpS390XLoweredPanicBoundsCC :
627
+ c := v .Aux .(ssa.PanicBoundsCC ).Cx
628
+ if c >= 0 && c <= abi .BoundsMaxConst {
629
+ xVal = int (c )
630
+ } else {
631
+ // Move constant to a register
632
+ xIsReg = true
633
+ p := s .Prog (s390x .AMOVD )
634
+ p .From .Type = obj .TYPE_CONST
635
+ p .From .Offset = c
636
+ p .To .Type = obj .TYPE_REG
637
+ p .To .Reg = s390x .REG_R0 + int16 (xVal )
638
+ }
639
+ c = v .Aux .(ssa.PanicBoundsCC ).Cy
640
+ if c >= 0 && c <= abi .BoundsMaxConst {
641
+ yVal = int (c )
642
+ } else {
643
+ // Move constant to a register
644
+ yIsReg = true
645
+ yVal = 1
646
+ p := s .Prog (s390x .AMOVD )
647
+ p .From .Type = obj .TYPE_CONST
648
+ p .From .Offset = c
649
+ p .To .Type = obj .TYPE_REG
650
+ p .To .Reg = s390x .REG_R0 + int16 (yVal )
651
+ }
652
+ }
653
+ c := abi .BoundsEncode (code , signed , xIsReg , yIsReg , xVal , yVal )
654
+
655
+ p := s .Prog (obj .APCDATA )
656
+ p .From .SetConst (abi .PCDATA_PanicBounds )
657
+ p .To .SetConst (int64 (c ))
658
+ p = s .Prog (obj .ACALL )
578
659
p .To .Type = obj .TYPE_MEM
579
660
p .To .Name = obj .NAME_EXTERN
580
- p .To .Sym = ssagen . BoundsCheckFunc [ v . AuxInt ]
581
- s . UseArgs ( 16 ) // space used in callee args area by assembly stubs
661
+ p .To .Sym = ir . Syms . PanicBounds
662
+
582
663
case ssa .OpS390XFLOGR , ssa .OpS390XPOPCNT ,
583
664
ssa .OpS390XNEG , ssa .OpS390XNEGW ,
584
665
ssa .OpS390XMOVWBR , ssa .OpS390XMOVDBR :
0 commit comments