]> Cypherpunks.ru repositories - gostls13.git/commit
[dev.regabi] cmd/compile: refactoring prep for ConstExpr
authorMatthew Dempsky <mdempsky@google.com>
Thu, 3 Dec 2020 07:55:42 +0000 (23:55 -0800)
committerMatthew Dempsky <mdempsky@google.com>
Thu, 3 Dec 2020 18:03:53 +0000 (18:03 +0000)
commitbeb5e0540406e2281a7502a2009db752668219da
tree0d55338df7ff5ec08f8c35b7be5797884e8652c7
parent7e81135be7b264517cf2ae17dec0fdbafc4c6841
[dev.regabi] cmd/compile: refactoring prep for ConstExpr

The next CL adds ConstExpr, which is a more memory efficient
representation for constant expressions than Name. However, currently
a bunch of Val helper methods are defined on Name. This CL changes
them into standalone functions that work with any Node.Val
implementation.

There's also an existing standalone function named Int64Val, which
takes a Type argument to specify what type of integer is expected. So
to avoid collisions, this CL renames it to IntVal.

Passes buildall w/ toolstash -cmp.

[git-generate]
cd src/cmd/compile/internal/ir
rf 'mv Int64Val IntVal'
sed -i -E -e 's/\(n \*Name\) (CanInt64|((I|Ui)nt64|Bool|String)Val)\(/\1(n Node/' name.go

cd ../gc
rf '
ex {
  import "cmd/compile/internal/ir"
  var n ir.Node
  n.CanInt64() -> ir.CanInt64(n)
  n.Int64Val() -> ir.Int64Val(n)
  n.Uint64Val() -> ir.Uint64Val(n)
  n.BoolVal() -> ir.BoolVal(n)
  n.StringVal() -> ir.StringVal(n)
}
'

cd ../ir
rf '
mv CanInt64 Int64Val Uint64Val BoolVal StringVal val.go
rm Node.CanInt64 Node.Int64Val Node.Uint64Val Node.BoolVal Node.StringVal
'

Change-Id: I003140bda1690d770fd608bdd087e6d4ff00fb1f
Reviewed-on: https://go-review.googlesource.com/c/go/+/275032
Trust: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
13 files changed:
src/cmd/compile/internal/gc/const.go
src/cmd/compile/internal/gc/escape.go
src/cmd/compile/internal/gc/noder.go
src/cmd/compile/internal/gc/obj.go
src/cmd/compile/internal/gc/order.go
src/cmd/compile/internal/gc/sinit.go
src/cmd/compile/internal/gc/ssa.go
src/cmd/compile/internal/gc/swt.go
src/cmd/compile/internal/gc/typecheck.go
src/cmd/compile/internal/gc/walk.go
src/cmd/compile/internal/ir/name.go
src/cmd/compile/internal/ir/node.go
src/cmd/compile/internal/ir/val.go