Skip to content

Commit b10164b

Browse files
committed
cmd/compile/internal/ir: remove un-used code for const
CL 390474 removed last usages of ConstValue, it can now be removed, and also Float64Val, since when it's only used by ConstValue. CanInt64 is un-used for a long time, its original form last usage was removed in CL 221802. Change-Id: Id142b0da49c319faca73ef1b2090325f81431321 Reviewed-on: https://go-review.googlesource.com/c/go/+/396078 Trust: Cuong Manh Le <[email protected]> Run-TryBot: Cuong Manh Le <[email protected]> TryBot-Result: Gopher Robot <[email protected]> Reviewed-by: Matthew Dempsky <[email protected]>
1 parent 5fcc655 commit b10164b

File tree

1 file changed

+0
-42
lines changed
  • src/cmd/compile/internal/ir

1 file changed

+0
-42
lines changed

src/cmd/compile/internal/ir/val.go

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ package ir
66

77
import (
88
"go/constant"
9-
"math"
109

1110
"cmd/compile/internal/base"
1211
"cmd/compile/internal/types"
@@ -19,27 +18,6 @@ func ConstType(n Node) constant.Kind {
1918
return n.Val().Kind()
2019
}
2120

22-
// ConstValue returns the constant value stored in n as an interface{}.
23-
// It returns int64s for ints and runes, float64s for floats,
24-
// and complex128s for complex values.
25-
func ConstValue(n Node) interface{} {
26-
switch v := n.Val(); v.Kind() {
27-
default:
28-
base.Fatalf("unexpected constant: %v", v)
29-
panic("unreachable")
30-
case constant.Bool:
31-
return constant.BoolVal(v)
32-
case constant.String:
33-
return constant.StringVal(v)
34-
case constant.Int:
35-
return IntVal(n.Type(), v)
36-
case constant.Float:
37-
return Float64Val(v)
38-
case constant.Complex:
39-
return complex(Float64Val(constant.Real(v)), Float64Val(constant.Imag(v)))
40-
}
41-
}
42-
4321
// IntVal returns v converted to int64.
4422
// Note: if t is uint64, very large values will be converted to negative int64.
4523
func IntVal(t *types.Type, v constant.Value) int64 {
@@ -56,14 +34,6 @@ func IntVal(t *types.Type, v constant.Value) int64 {
5634
panic("unreachable")
5735
}
5836

59-
func Float64Val(v constant.Value) float64 {
60-
if x, _ := constant.Float64Val(v); !math.IsInf(x, 0) {
61-
return x + 0 // avoid -0 (should not be needed, but be conservative)
62-
}
63-
base.Fatalf("bad float64 value: %v", v)
64-
panic("unreachable")
65-
}
66-
6737
func AssertValidTypeForConst(t *types.Type, v constant.Value) {
6838
if !ValidTypeForConst(t, v) {
6939
base.Fatalf("%v (%v) does not represent %v (%v)", t, t.Kind(), v, v.Kind())
@@ -114,18 +84,6 @@ func idealType(ct constant.Kind) *types.Type {
11484

11585
var OKForConst [types.NTYPE]bool
11686

117-
// CanInt64 reports whether it is safe to call Int64Val() on n.
118-
func CanInt64(n Node) bool {
119-
if !IsConst(n, constant.Int) {
120-
return false
121-
}
122-
123-
// if the value inside n cannot be represented as an int64, the
124-
// return value of Int64 is undefined
125-
_, ok := constant.Int64Val(n.Val())
126-
return ok
127-
}
128-
12987
// Int64Val returns n as an int64.
13088
// n must be an integer or rune constant.
13189
func Int64Val(n Node) int64 {

0 commit comments

Comments
 (0)