File tree Expand file tree Collapse file tree 4 files changed +19
-42
lines changed Expand file tree Collapse file tree 4 files changed +19
-42
lines changed Original file line number Diff line number Diff line change @@ -467,30 +467,18 @@ hard:
467
467
return
468
468
}
469
469
470
- func intLiteral (n * gc.Node ) (x int64 , ok bool ) {
471
- switch {
472
- case n == nil :
473
- return
474
- case gc .Isconst (n , gc .CTINT ):
475
- return n .Int (), true
476
- case gc .Isconst (n , gc .CTBOOL ):
477
- return int64 (obj .Bool2int (n .Bool ())), true
478
- }
479
- return
480
- }
481
-
482
470
// gins is called by the front end.
483
471
// It synthesizes some multiple-instruction sequences
484
472
// so the front end can stay simpler.
485
473
func gins (as int , f , t * gc.Node ) * obj.Prog {
486
474
if as >= obj .A_ARCHSPECIFIC {
487
- if x , ok := intLiteral ( f ); ok {
475
+ if x , ok := f . IntLiteral ( ); ok {
488
476
ginscon (as , x , t )
489
477
return nil // caller must not use
490
478
}
491
479
}
492
480
if as == arm64 .ACMP {
493
- if x , ok := intLiteral ( t ); ok {
481
+ if x , ok := t . IntLiteral ( ); ok {
494
482
ginscon2 (as , f , x )
495
483
return nil // caller must not use
496
484
}
Original file line number Diff line number Diff line change @@ -10,6 +10,19 @@ import (
10
10
"strings"
11
11
)
12
12
13
+ // IntLiteral returns the Node's literal value as an interger.
14
+ func (n * Node ) IntLiteral () (x int64 , ok bool ) {
15
+ switch {
16
+ case n == nil :
17
+ return
18
+ case Isconst (n , CTINT ):
19
+ return n .Int (), true
20
+ case Isconst (n , CTBOOL ):
21
+ return int64 (obj .Bool2int (n .Bool ())), true
22
+ }
23
+ return
24
+ }
25
+
13
26
// Int returns n as an int.
14
27
// n must be an integer constant.
15
28
func (n * Node ) Int () int64 {
Original file line number Diff line number Diff line change @@ -545,30 +545,18 @@ hard:
545
545
return
546
546
}
547
547
548
- func intLiteral (n * gc.Node ) (x int64 , ok bool ) {
549
- switch {
550
- case n == nil :
551
- return
552
- case gc .Isconst (n , gc .CTINT ):
553
- return n .Int (), true
554
- case gc .Isconst (n , gc .CTBOOL ):
555
- return int64 (obj .Bool2int (n .Bool ())), true
556
- }
557
- return
558
- }
559
-
560
548
// gins is called by the front end.
561
549
// It synthesizes some multiple-instruction sequences
562
550
// so the front end can stay simpler.
563
551
func gins (as int , f , t * gc.Node ) * obj.Prog {
564
552
if as >= obj .A_ARCHSPECIFIC {
565
- if x , ok := intLiteral ( f ); ok {
553
+ if x , ok := f . IntLiteral ( ); ok {
566
554
ginscon (as , x , t )
567
555
return nil // caller must not use
568
556
}
569
557
}
570
558
if as == ppc64 .ACMP || as == ppc64 .ACMPU {
571
- if x , ok := intLiteral ( t ); ok {
559
+ if x , ok := t . IntLiteral ( ); ok {
572
560
ginscon2 (as , f , x )
573
561
return nil // caller must not use
574
562
}
Original file line number Diff line number Diff line change @@ -545,30 +545,18 @@ hard:
545
545
return
546
546
}
547
547
548
- func intLiteral (n * gc.Node ) (x int64 , ok bool ) {
549
- switch {
550
- case n == nil :
551
- return
552
- case gc .Isconst (n , gc .CTINT ):
553
- return n .Int (), true
554
- case gc .Isconst (n , gc .CTBOOL ):
555
- return int64 (obj .Bool2int (n .Bool ())), true
556
- }
557
- return
558
- }
559
-
560
548
// gins is called by the front end.
561
549
// It synthesizes some multiple-instruction sequences
562
550
// so the front end can stay simpler.
563
551
func gins (as int , f , t * gc.Node ) * obj.Prog {
564
552
if as >= obj .A_ARCHSPECIFIC {
565
- if x , ok := intLiteral ( f ); ok {
553
+ if x , ok := f . IntLiteral ( ); ok {
566
554
ginscon (as , x , t )
567
555
return nil // caller must not use
568
556
}
569
557
}
570
558
if as == ppc64 .ACMP || as == ppc64 .ACMPU {
571
- if x , ok := intLiteral ( t ); ok {
559
+ if x , ok := t . IntLiteral ( ); ok {
572
560
ginscon2 (as , f , x )
573
561
return nil // caller must not use
574
562
}
You can’t perform that action at this time.
0 commit comments