]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: some cleanup with old irgen code
authorCuong Manh Le <cuong.manhle.vn@gmail.com>
Tue, 3 Oct 2023 15:51:03 +0000 (22:51 +0700)
committerGopher Robot <gobot@golang.org>
Thu, 5 Oct 2023 19:45:58 +0000 (19:45 +0000)
 - Un-export Convertop: it's only used by tcConv.
 - Remove AssignOp1: introduced in CL 349614, only used by irgen.
 - Un-export Assignop: it was exported to be used by irgen only.

Change-Id: I7e78b35d90f165c537cf32a104156bf2a13ca8b8
Reviewed-on: https://go-review.googlesource.com/c/go/+/532516
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

src/cmd/compile/internal/typecheck/expr.go
src/cmd/compile/internal/typecheck/stmt.go
src/cmd/compile/internal/typecheck/subr.go
src/cmd/compile/internal/typecheck/typecheck.go

index 83d1355fe5dbdd567a87e0b6eaf331cedf11b303..24c677e753fecbc393ad1b119352a501be2f7bc3 100644 (file)
@@ -69,7 +69,7 @@ func tcArith(n ir.Node, op ir.Op, l, r ir.Node) (ir.Node, ir.Node, *types.Type)
                // The conversion allocates, so only do it if the concrete type is huge.
                converted := false
                if r.Type().Kind() != types.TBLANK {
-                       aop, _ = Assignop(l.Type(), r.Type())
+                       aop, _ = assignOp(l.Type(), r.Type())
                        if aop != ir.OXXX {
                                if r.Type().IsInterface() && !l.Type().IsInterface() && !types.IsComparable(l.Type()) {
                                        base.Errorf("invalid operation: %v (operator %v not defined on %s)", n, op, typekind(l.Type()))
@@ -88,7 +88,7 @@ func tcArith(n ir.Node, op ir.Op, l, r ir.Node) (ir.Node, ir.Node, *types.Type)
                }
 
                if !converted && l.Type().Kind() != types.TBLANK {
-                       aop, _ = Assignop(r.Type(), l.Type())
+                       aop, _ = assignOp(r.Type(), l.Type())
                        if aop != ir.OXXX {
                                if l.Type().IsInterface() && !r.Type().IsInterface() && !types.IsComparable(r.Type()) {
                                        base.Errorf("invalid operation: %v (operator %v not defined on %s)", n, op, typekind(r.Type()))
@@ -352,7 +352,7 @@ func tcConv(n *ir.ConvExpr) ir.Node {
                n.SetType(nil)
                return n
        }
-       op, why := Convertop(n.X.Op() == ir.OLITERAL, t, n.Type())
+       op, why := convertOp(n.X.Op() == ir.OLITERAL, t, n.Type())
        if op == ir.OXXX {
                // Due to //go:nointerface, we may be stricter than types2 here (#63333).
                base.ErrorfAt(n.Pos(), errors.InvalidConversion, "cannot convert %L to type %v%s", n.X, n.Type(), why)
index 8642e0d14dc3fdee106f13561f135f5d9e0509ce..e54d5256e6a61bda99f1cb9a72d2a451eb0e0cec 100644 (file)
@@ -600,8 +600,8 @@ func tcSwitchExpr(n *ir.SwitchStmt) {
                        } else if t.IsInterface() && !n1.Type().IsInterface() && !types.IsComparable(n1.Type()) {
                                base.ErrorfAt(ncase.Pos(), errors.UndefinedOp, "invalid case %L in switch (incomparable type)", n1)
                        } else {
-                               op1, _ := Assignop(n1.Type(), t)
-                               op2, _ := Assignop(t, n1.Type())
+                               op1, _ := assignOp(n1.Type(), t)
+                               op2, _ := assignOp(t, n1.Type())
                                if op1 == ir.OXXX && op2 == ir.OXXX {
                                        if n.Tag != nil {
                                                base.ErrorfAt(ncase.Pos(), errors.MismatchedTypes, "invalid case %v in switch on %v (mismatched types %v and %v)", n1, n.Tag, n1.Type(), t)
index 6cc93c45fb2c4671690795cf06fa5c3486e6a9a6..d64b0f0e2230542681655c69e64f3776a819afa3 100644 (file)
@@ -237,7 +237,7 @@ func assignconvfn(n ir.Node, t *types.Type, context func() string) ir.Node {
                return n
        }
 
-       op, why := Assignop(n.Type(), t)
+       op, why := assignOp(n.Type(), t)
        if op == ir.OXXX {
                base.Errorf("cannot use %L as type %v in %s%s", n, t, context(), why)
                op = ir.OCONV
@@ -253,7 +253,7 @@ func assignconvfn(n ir.Node, t *types.Type, context func() string) ir.Node {
 // If so, return op code to use in conversion.
 // If not, return OXXX. In this case, the string return parameter may
 // hold a reason why. In all other cases, it'll be the empty string.
-func Assignop(src, dst *types.Type) (ir.Op, string) {
+func assignOp(src, dst *types.Type) (ir.Op, string) {
        if src == dst {
                return ir.OCONVNOP, ""
        }
@@ -265,10 +265,7 @@ func Assignop(src, dst *types.Type) (ir.Op, string) {
        if types.Identical(src, dst) {
                return ir.OCONVNOP, ""
        }
-       return Assignop1(src, dst)
-}
 
-func Assignop1(src, dst *types.Type) (ir.Op, string) {
        // 2. src and dst have identical underlying types and
        //   a. either src or dst is not a named type, or
        //   b. both are empty interface types, or
@@ -367,7 +364,7 @@ func Assignop1(src, dst *types.Type) (ir.Op, string) {
 // If not, return OXXX. In this case, the string return parameter may
 // hold a reason why. In all other cases, it'll be the empty string.
 // srcConstant indicates whether the value of type src is a constant.
-func Convertop(srcConstant bool, src, dst *types.Type) (ir.Op, string) {
+func convertOp(srcConstant bool, src, dst *types.Type) (ir.Op, string) {
        if src == dst {
                return ir.OCONVNOP, ""
        }
@@ -390,7 +387,7 @@ func Convertop(srcConstant bool, src, dst *types.Type) (ir.Op, string) {
        }
 
        // 1. src can be assigned to dst.
-       op, why := Assignop(src, dst)
+       op, why := assignOp(src, dst)
        if op != ir.OXXX {
                return op, why
        }
index 74dc09fdb6782c30c94a784f4d370768924339c6..b22e45358ea83184905d8e826ec1192689430a0f 100644 (file)
@@ -1209,7 +1209,7 @@ func checkassignto(src *types.Type, dst ir.Node) {
                return
        }
 
-       if op, why := Assignop(src, dst.Type()); op == ir.OXXX {
+       if op, why := assignOp(src, dst.Type()); op == ir.OXXX {
                base.Errorf("cannot assign %v to %L in multiple assignment%s", src, dst, why)
                return
        }