aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile/internal/noder
diff options
context:
space:
mode:
authorMatthew Dempsky <mdempsky@google.com>2023-09-06 14:00:30 -0700
committerGopher Robot <gobot@golang.org>2023-09-08 18:50:24 +0000
commit18c6ec1e4a62d25ce9801174c1c17360eb95233c (patch)
treeadfcf0d69f611aae2a688fa38db1dd3babf3ca54 /src/cmd/compile/internal/noder
parentc6d550a6683cebb2a11d7fa91823edf7db1d58a5 (diff)
downloadgo-18c6ec1e4a62d25ce9801174c1c17360eb95233c.tar.xz
cmd/compile/internal/noder: stop preserving original const strings
One of the more tedious quirks of the original frontend (i.e., typecheck) to preserve was that it preserved the original representation of constants into the backend. To fit into the unified IR model, I ended up implementing a fairly heavyweight workaround: simply record the original constant's string expression in the export data, so that diagnostics could still report it back, and match the old test expectations. But now that there's just a single frontend to support, it's easy enough to just update the test expectations and drop this support for "raw" constant expressions. Change-Id: I1d859c5109d679879d937a2b213e777fbddf4f2f Reviewed-on: https://go-review.googlesource.com/c/go/+/526376 Reviewed-by: Keith Randall <khr@golang.org> Reviewed-by: Keith Randall <khr@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Matthew Dempsky <mdempsky@google.com> Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Diffstat (limited to 'src/cmd/compile/internal/noder')
-rw-r--r--src/cmd/compile/internal/noder/expr.go34
-rw-r--r--src/cmd/compile/internal/noder/helpers.go5
-rw-r--r--src/cmd/compile/internal/noder/reader.go4
-rw-r--r--src/cmd/compile/internal/noder/writer.go5
4 files changed, 1 insertions, 47 deletions
diff --git a/src/cmd/compile/internal/noder/expr.go b/src/cmd/compile/internal/noder/expr.go
deleted file mode 100644
index 14ef3b958f..0000000000
--- a/src/cmd/compile/internal/noder/expr.go
+++ /dev/null
@@ -1,34 +0,0 @@
-// Copyright 2021 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-package noder
-
-import (
- "fmt"
-
- "cmd/compile/internal/ir"
- "cmd/compile/internal/syntax"
-)
-
-// constExprOp returns an ir.Op that represents the outermost
-// operation of the given constant expression. It's intended for use
-// with ir.RawOrigExpr.
-func constExprOp(expr syntax.Expr) ir.Op {
- switch expr := expr.(type) {
- default:
- panic(fmt.Sprintf("%s: unexpected expression: %T", expr.Pos(), expr))
-
- case *syntax.BasicLit:
- return ir.OLITERAL
- case *syntax.Name, *syntax.SelectorExpr:
- return ir.ONAME
- case *syntax.CallExpr:
- return ir.OCALL
- case *syntax.Operation:
- if expr.Y == nil {
- return unOps[expr.Op]
- }
- return binOps[expr.Op]
- }
-}
diff --git a/src/cmd/compile/internal/noder/helpers.go b/src/cmd/compile/internal/noder/helpers.go
index 8aa93ef5dc..ae31f86006 100644
--- a/src/cmd/compile/internal/noder/helpers.go
+++ b/src/cmd/compile/internal/noder/helpers.go
@@ -40,11 +40,6 @@ func typed(typ *types.Type, n ir.Node) ir.Node {
// Values
-func OrigConst(pos src.XPos, typ *types.Type, val constant.Value, op ir.Op, raw string) ir.Node {
- orig := ir.NewRawOrigExpr(pos, op, raw)
- return ir.NewConstExpr(val, typed(typ, orig))
-}
-
// FixValue returns val after converting and truncating it as
// appropriate for typ.
func FixValue(typ *types.Type, val constant.Value) constant.Value {
diff --git a/src/cmd/compile/internal/noder/reader.go b/src/cmd/compile/internal/noder/reader.go
index 26865fdae2..8e28260499 100644
--- a/src/cmd/compile/internal/noder/reader.go
+++ b/src/cmd/compile/internal/noder/reader.go
@@ -2172,9 +2172,7 @@ func (r *reader) expr() (res ir.Node) {
pos := r.pos()
typ := r.typ()
val := FixValue(typ, r.Value())
- op := r.op()
- orig := r.String()
- return typecheck.Expr(OrigConst(pos, typ, val, op, orig))
+ return typed(typ, ir.NewBasicLit(pos, val))
case exprNil:
pos := r.pos()
diff --git a/src/cmd/compile/internal/noder/writer.go b/src/cmd/compile/internal/noder/writer.go
index 5982e714a3..044771609d 100644
--- a/src/cmd/compile/internal/noder/writer.go
+++ b/src/cmd/compile/internal/noder/writer.go
@@ -1748,11 +1748,6 @@ func (w *writer) expr(expr syntax.Expr) {
assert(typ != nil)
w.typ(typ)
w.Value(tv.Value)
-
- // TODO(mdempsky): These details are only important for backend
- // diagnostics. Explore writing them out separately.
- w.op(constExprOp(expr))
- w.String(syntax.String(expr))
return
}