@@ -15,6 +15,7 @@ import (
15
15
"cmd/compile/internal/types"
16
16
"cmd/internal/obj"
17
17
"cmd/internal/obj/mips"
18
+ "internal/abi"
18
19
)
19
20
20
21
// isFPreg reports whether r is an FP register.
@@ -507,12 +508,93 @@ func ssaGenValue(s *ssagen.State, v *ssa.Value) {
507
508
p .To .Name = obj .NAME_EXTERN
508
509
// AuxInt encodes how many buffer entries we need.
509
510
p .To .Sym = ir .Syms .GCWriteBarrier [v .AuxInt - 1 ]
510
- case ssa .OpMIPS64LoweredPanicBoundsA , ssa .OpMIPS64LoweredPanicBoundsB , ssa .OpMIPS64LoweredPanicBoundsC :
511
- p := s .Prog (obj .ACALL )
511
+
512
+ case ssa .OpMIPS64LoweredPanicBoundsRR , ssa .OpMIPS64LoweredPanicBoundsRC , ssa .OpMIPS64LoweredPanicBoundsCR , ssa .OpMIPS64LoweredPanicBoundsCC :
513
+ // Compute the constant we put in the PCData entry for this call.
514
+ code , signed := ssa .BoundsKind (v .AuxInt ).Code ()
515
+ xIsReg := false
516
+ yIsReg := false
517
+ xVal := 0
518
+ yVal := 0
519
+ switch v .Op {
520
+ case ssa .OpMIPS64LoweredPanicBoundsRR :
521
+ xIsReg = true
522
+ xVal = int (v .Args [0 ].Reg () - mips .REG_R1 )
523
+ yIsReg = true
524
+ yVal = int (v .Args [1 ].Reg () - mips .REG_R1 )
525
+ case ssa .OpMIPS64LoweredPanicBoundsRC :
526
+ xIsReg = true
527
+ xVal = int (v .Args [0 ].Reg () - mips .REG_R1 )
528
+ c := v .Aux .(ssa.PanicBoundsC ).C
529
+ if c >= 0 && c <= abi .BoundsMaxConst {
530
+ yVal = int (c )
531
+ } else {
532
+ // Move constant to a register
533
+ yIsReg = true
534
+ if yVal == xVal {
535
+ yVal = 1
536
+ }
537
+ p := s .Prog (mips .AMOVV )
538
+ p .From .Type = obj .TYPE_CONST
539
+ p .From .Offset = c
540
+ p .To .Type = obj .TYPE_REG
541
+ p .To .Reg = mips .REG_R1 + int16 (yVal )
542
+ }
543
+ case ssa .OpMIPS64LoweredPanicBoundsCR :
544
+ yIsReg = true
545
+ yVal := int (v .Args [0 ].Reg () - mips .REG_R1 )
546
+ c := v .Aux .(ssa.PanicBoundsC ).C
547
+ if c >= 0 && c <= abi .BoundsMaxConst {
548
+ xVal = int (c )
549
+ } else {
550
+ // Move constant to a register
551
+ xIsReg = true
552
+ if xVal == yVal {
553
+ xVal = 1
554
+ }
555
+ p := s .Prog (mips .AMOVV )
556
+ p .From .Type = obj .TYPE_CONST
557
+ p .From .Offset = c
558
+ p .To .Type = obj .TYPE_REG
559
+ p .To .Reg = mips .REG_R1 + int16 (xVal )
560
+ }
561
+ case ssa .OpMIPS64LoweredPanicBoundsCC :
562
+ c := v .Aux .(ssa.PanicBoundsCC ).Cx
563
+ if c >= 0 && c <= abi .BoundsMaxConst {
564
+ xVal = int (c )
565
+ } else {
566
+ // Move constant to a register
567
+ xIsReg = true
568
+ p := s .Prog (mips .AMOVV )
569
+ p .From .Type = obj .TYPE_CONST
570
+ p .From .Offset = c
571
+ p .To .Type = obj .TYPE_REG
572
+ p .To .Reg = mips .REG_R1 + int16 (xVal )
573
+ }
574
+ c = v .Aux .(ssa.PanicBoundsCC ).Cy
575
+ if c >= 0 && c <= abi .BoundsMaxConst {
576
+ yVal = int (c )
577
+ } else {
578
+ // Move constant to a register
579
+ yIsReg = true
580
+ yVal = 1
581
+ p := s .Prog (mips .AMOVV )
582
+ p .From .Type = obj .TYPE_CONST
583
+ p .From .Offset = c
584
+ p .To .Type = obj .TYPE_REG
585
+ p .To .Reg = mips .REG_R1 + int16 (yVal )
586
+ }
587
+ }
588
+ c := abi .BoundsEncode (code , signed , xIsReg , yIsReg , xVal , yVal )
589
+
590
+ p := s .Prog (obj .APCDATA )
591
+ p .From .SetConst (abi .PCDATA_PanicBounds )
592
+ p .To .SetConst (int64 (c ))
593
+ p = s .Prog (obj .ACALL )
512
594
p .To .Type = obj .TYPE_MEM
513
595
p .To .Name = obj .NAME_EXTERN
514
- p .To .Sym = ssagen . BoundsCheckFunc [ v . AuxInt ]
515
- s . UseArgs ( 16 ) // space used in callee args area by assembly stubs
596
+ p .To .Sym = ir . Syms . PanicBounds
597
+
516
598
case ssa .OpMIPS64LoweredAtomicLoad8 , ssa .OpMIPS64LoweredAtomicLoad32 , ssa .OpMIPS64LoweredAtomicLoad64 :
517
599
as := mips .AMOVV
518
600
switch v .Op {
0 commit comments