2015-02-13 14:40:36 -05:00
|
|
|
// Copyright 2009 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 gc
|
|
|
|
|
2020-11-19 20:49:23 -05:00
|
|
|
import (
|
|
|
|
"cmd/compile/internal/base"
|
[dev.regabi] cmd/compile: introduce cmd/compile/internal/ir [generated]
If we want to break up package gc at all, we will need to move
the compiler IR it defines into a separate package that can be
imported by packages that gc itself imports. This CL does that.
It also removes the TINT8 etc aliases so that all code is clear
about which package things are coming from.
This CL is automatically generated by the script below.
See the comments in the script for details about the changes.
[git-generate]
cd src/cmd/compile/internal/gc
rf '
# These names were never fully qualified
# when the types package was added.
# Do it now, to avoid confusion about where they live.
inline -rm \
Txxx \
TINT8 \
TUINT8 \
TINT16 \
TUINT16 \
TINT32 \
TUINT32 \
TINT64 \
TUINT64 \
TINT \
TUINT \
TUINTPTR \
TCOMPLEX64 \
TCOMPLEX128 \
TFLOAT32 \
TFLOAT64 \
TBOOL \
TPTR \
TFUNC \
TSLICE \
TARRAY \
TSTRUCT \
TCHAN \
TMAP \
TINTER \
TFORW \
TANY \
TSTRING \
TUNSAFEPTR \
TIDEAL \
TNIL \
TBLANK \
TFUNCARGS \
TCHANARGS \
NTYPE \
BADWIDTH
# esc.go and escape.go do not need to be split.
# Append esc.go onto the end of escape.go.
mv esc.go escape.go
# Pull out the type format installation from func Main,
# so it can be carried into package ir.
mv Main:/Sconv.=/-0,/TypeLinkSym/-1 InstallTypeFormats
# Names that need to be exported for use by code left in gc.
mv Isconst IsConst
mv asNode AsNode
mv asNodes AsNodes
mv asTypesNode AsTypesNode
mv basicnames BasicTypeNames
mv builtinpkg BuiltinPkg
mv consttype ConstType
mv dumplist DumpList
mv fdumplist FDumpList
mv fmtMode FmtMode
mv goopnames OpNames
mv inspect Inspect
mv inspectList InspectList
mv localpkg LocalPkg
mv nblank BlankNode
mv numImport NumImport
mv opprec OpPrec
mv origSym OrigSym
mv stmtwithinit StmtWithInit
mv dump DumpAny
mv fdump FDumpAny
mv nod Nod
mv nodl NodAt
mv newname NewName
mv newnamel NewNameAt
mv assertRepresents AssertValidTypeForConst
mv represents ValidTypeForConst
mv nodlit NewLiteral
# Types and fields that need to be exported for use by gc.
mv nowritebarrierrecCallSym SymAndPos
mv SymAndPos.lineno SymAndPos.Pos
mv SymAndPos.target SymAndPos.Sym
mv Func.lsym Func.LSym
mv Func.setWBPos Func.SetWBPos
mv Func.numReturns Func.NumReturns
mv Func.numDefers Func.NumDefers
mv Func.nwbrCalls Func.NWBRCalls
# initLSym is an algorithm left behind in gc,
# not an operation on Func itself.
mv Func.initLSym initLSym
mv nodeQueue NodeQueue
mv NodeQueue.empty NodeQueue.Empty
mv NodeQueue.popLeft NodeQueue.PopLeft
mv NodeQueue.pushRight NodeQueue.PushRight
# Many methods on Node are actually algorithms that
# would apply to any node implementation.
# Those become plain functions.
mv Node.funcname FuncName
mv Node.isBlank IsBlank
mv Node.isGoConst isGoConst
mv Node.isNil IsNil
mv Node.isParamHeapCopy isParamHeapCopy
mv Node.isParamStackCopy isParamStackCopy
mv Node.isSimpleName isSimpleName
mv Node.mayBeShared MayBeShared
mv Node.pkgFuncName PkgFuncName
mv Node.backingArrayPtrLen backingArrayPtrLen
mv Node.isterminating isTermNode
mv Node.labeledControl labeledControl
mv Nodes.isterminating isTermNodes
mv Nodes.sigerr fmtSignature
mv Node.MethodName methodExprName
mv Node.MethodFunc methodExprFunc
mv Node.IsMethod IsMethod
# Every node will need to implement RawCopy;
# Copy and SepCopy algorithms will use it.
mv Node.rawcopy Node.RawCopy
mv Node.copy Copy
mv Node.sepcopy SepCopy
# Extract Node.Format method body into func FmtNode,
# but leave method wrapper behind.
mv Node.Format:0,$ FmtNode
# Formatting helpers that will apply to all node implementations.
mv Node.Line Line
mv Node.exprfmt exprFmt
mv Node.jconv jconvFmt
mv Node.modeString modeString
mv Node.nconv nconvFmt
mv Node.nodedump nodeDumpFmt
mv Node.nodefmt nodeFmt
mv Node.stmtfmt stmtFmt
# Constant support needed for code moving to ir.
mv okforconst OKForConst
mv vconv FmtConst
mv int64Val Int64Val
mv float64Val Float64Val
mv Node.ValueInterface ConstValue
# Organize code into files.
mv LocalPkg BuiltinPkg ir.go
mv NumImport InstallTypeFormats Line fmt.go
mv syntax.go Nod NodAt NewNameAt Class Pxxx PragmaFlag Nointerface SymAndPos \
AsNode AsTypesNode BlankNode OrigSym \
Node.SliceBounds Node.SetSliceBounds Op.IsSlice3 \
IsConst Node.Int64Val Node.CanInt64 Node.Uint64Val Node.BoolVal Node.StringVal \
Node.RawCopy SepCopy Copy \
IsNil IsBlank IsMethod \
Node.Typ Node.StorageClass node.go
mv ConstType ConstValue Int64Val Float64Val AssertValidTypeForConst ValidTypeForConst NewLiteral idealType OKForConst val.go
# Move files to new ir package.
mv bitset.go class_string.go dump.go fmt.go \
ir.go node.go op_string.go val.go \
sizeof_test.go cmd/compile/internal/ir
'
: # fix mkbuiltin.go to generate the changes made to builtin.go during rf
sed -i '' '
s/\[T/[types.T/g
s/\*Node/*ir.Node/g
/internal\/types/c \
fmt.Fprintln(&b, `import (`) \
fmt.Fprintln(&b, ` "cmd/compile/internal/ir"`) \
fmt.Fprintln(&b, ` "cmd/compile/internal/types"`) \
fmt.Fprintln(&b, `)`)
' mkbuiltin.go
gofmt -w mkbuiltin.go
: # update cmd/dist to add internal/ir
cd ../../../dist
sed -i '' '/compile.internal.gc/a\
"cmd/compile/internal/ir",
' buildtool.go
gofmt -w buildtool.go
: # update cmd/compile TestFormats
cd ../..
go install std cmd
cd cmd/compile
go test -u || go test # first one updates but fails; second passes
Change-Id: I5f7caf6b20629b51970279e81231a3574d5b51db
Reviewed-on: https://go-review.googlesource.com/c/go/+/273008
Trust: Russ Cox <rsc@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2020-11-19 21:09:22 -05:00
|
|
|
"cmd/compile/internal/ir"
|
2020-11-19 20:49:23 -05:00
|
|
|
"cmd/compile/internal/types"
|
|
|
|
)
|
cmd/compile: factor out Pkg, Sym, and Type into package types
- created new package cmd/compile/internal/types
- moved Pkg, Sym, Type to new package
- to break cycles, for now we need the (ugly) types/utils.go
file which contains a handful of functions that must be installed
early by the gc frontend
- to break cycles, for now we need two functions to convert between
*gc.Node and *types.Node (the latter is a dummy type)
- adjusted the gc's code to use the new package and the conversion
functions as needed
- made several Pkg, Sym, and Type methods functions as needed
- renamed constructors typ, typPtr, typArray, etc. to types.New,
types.NewPtr, types.NewArray, etc.
Passes toolstash-check -all.
Change-Id: I8adfa5e85c731645d0a7fd2030375ed6ebf54b72
Reviewed-on: https://go-review.googlesource.com/39855
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2017-04-04 17:54:02 -07:00
|
|
|
|
2015-10-22 09:51:12 +09:00
|
|
|
// select
|
[dev.regabi] cmd/compile: cleanup for concrete types - range, select, swt
An automated rewrite will add concrete type assertions after
a test of n.Op(), when n can be safely type-asserted
(meaning, n is not reassigned a different type, n is not reassigned
and then used outside the scope of the type assertion,
and so on).
This sequence of CLs handles the code that the automated
rewrite does not: adding specific types to function arguments,
adjusting code not to call n.Left() etc when n may have multiple
representations, and so on.
This CL focuses on range.go, select.go, and swt.go: the big
control structures.
Passes buildall w/ toolstash -cmp.
Change-Id: I033fe056a7b815edb6e8a06f45c12ffd990f4d45
Reviewed-on: https://go-review.googlesource.com/c/go/+/277929
Trust: Russ Cox <rsc@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2020-12-10 18:47:32 -05:00
|
|
|
func typecheckselect(sel *ir.SelectStmt) {
|
[dev.regabi] cmd/compile: replace *Node type with an interface Node [generated]
The plan is to introduce a Node interface that replaces the old *Node pointer-to-struct.
The previous CL defined an interface INode modeling a *Node.
This CL:
- Changes all references outside internal/ir to use INode,
along with many references inside internal/ir as well.
- Renames Node to node.
- Renames INode to Node
So now ir.Node is an interface implemented by *ir.node, which is otherwise inaccessible,
and the code outside package ir is now (clearly) using only the interface.
The usual rule is never to redefine an existing name with a new meaning,
so that old code that hasn't been updated gets a "unknown name" error
instead of more mysterious errors or silent misbehavior. That rule would
caution against replacing Node-the-struct with Node-the-interface,
as in this CL, because code that says *Node would now be using a pointer
to an interface. But this CL is being landed at the same time as another that
moves Node from gc to ir. So the net effect is to replace *gc.Node with ir.Node,
which does follow the rule: any lingering references to gc.Node will be told
it's gone, not silently start using pointers to interfaces. So the rule is followed
by the CL sequence, just not this specific CL.
Overall, the loss of inlining caused by using interfaces cuts the compiler speed
by about 6%, a not insignificant amount. However, as we convert the representation
to concrete structs that are not the giant Node over the next weeks, that speed
should come back as more of the compiler starts operating directly on concrete types
and the memory taken up by the graph of Nodes drops due to the more precise
structs. Honestly, I was expecting worse.
% benchstat bench.old bench.new
name old time/op new time/op delta
Template 168ms ± 4% 182ms ± 2% +8.34% (p=0.000 n=9+9)
Unicode 72.2ms ±10% 82.5ms ± 6% +14.38% (p=0.000 n=9+9)
GoTypes 563ms ± 8% 598ms ± 2% +6.14% (p=0.006 n=9+9)
Compiler 2.89s ± 4% 3.04s ± 2% +5.37% (p=0.000 n=10+9)
SSA 6.45s ± 4% 7.25s ± 5% +12.41% (p=0.000 n=9+10)
Flate 105ms ± 2% 115ms ± 1% +9.66% (p=0.000 n=10+8)
GoParser 144ms ±10% 152ms ± 2% +5.79% (p=0.011 n=9+8)
Reflect 345ms ± 9% 370ms ± 4% +7.28% (p=0.001 n=10+9)
Tar 149ms ± 9% 161ms ± 5% +8.05% (p=0.001 n=10+9)
XML 190ms ± 3% 209ms ± 2% +9.54% (p=0.000 n=9+8)
LinkCompiler 327ms ± 2% 325ms ± 2% ~ (p=0.382 n=8+8)
ExternalLinkCompiler 1.77s ± 4% 1.73s ± 6% ~ (p=0.113 n=9+10)
LinkWithoutDebugCompiler 214ms ± 4% 211ms ± 2% ~ (p=0.360 n=10+8)
StdCmd 14.8s ± 3% 15.9s ± 1% +6.98% (p=0.000 n=10+9)
[Geo mean] 480ms 510ms +6.31%
name old user-time/op new user-time/op delta
Template 223ms ± 3% 237ms ± 3% +6.16% (p=0.000 n=9+10)
Unicode 103ms ± 6% 113ms ± 3% +9.53% (p=0.000 n=9+9)
GoTypes 758ms ± 8% 800ms ± 2% +5.55% (p=0.003 n=10+9)
Compiler 3.95s ± 2% 4.12s ± 2% +4.34% (p=0.000 n=10+9)
SSA 9.43s ± 1% 9.74s ± 4% +3.25% (p=0.000 n=8+10)
Flate 132ms ± 2% 141ms ± 2% +6.89% (p=0.000 n=9+9)
GoParser 177ms ± 9% 183ms ± 4% ~ (p=0.050 n=9+9)
Reflect 467ms ±10% 495ms ± 7% +6.17% (p=0.029 n=10+10)
Tar 183ms ± 9% 197ms ± 5% +7.92% (p=0.001 n=10+10)
XML 249ms ± 5% 268ms ± 4% +7.82% (p=0.000 n=10+9)
LinkCompiler 544ms ± 5% 544ms ± 6% ~ (p=0.863 n=9+9)
ExternalLinkCompiler 1.79s ± 4% 1.75s ± 6% ~ (p=0.075 n=10+10)
LinkWithoutDebugCompiler 248ms ± 6% 246ms ± 2% ~ (p=0.965 n=10+8)
[Geo mean] 483ms 504ms +4.41%
[git-generate]
cd src/cmd/compile/internal/ir
: # We need to do the conversion in multiple steps, so we introduce
: # a temporary type alias that will start out meaning the pointer-to-struct
: # and then change to mean the interface.
rf '
mv Node OldNode
add node.go \
type Node = *OldNode
'
: # It should work to do this ex in ir, but it misses test files, due to a bug in rf.
: # Run the command in gc to handle gc's tests, and then again in ssa for ssa's tests.
cd ../gc
rf '
ex . ../arm ../riscv64 ../arm64 ../mips64 ../ppc64 ../mips ../wasm {
import "cmd/compile/internal/ir"
*ir.OldNode -> ir.Node
}
'
cd ../ssa
rf '
ex {
import "cmd/compile/internal/ir"
*ir.OldNode -> ir.Node
}
'
: # Back in ir, finish conversion clumsily with sed,
: # because type checking and circular aliases do not mix.
cd ../ir
sed -i '' '
/type Node = \*OldNode/d
s/\*OldNode/Node/g
s/^func (n Node)/func (n *OldNode)/
s/OldNode/node/g
s/type INode interface/type Node interface/
s/var _ INode = (Node)(nil)/var _ Node = (*node)(nil)/
' *.go
gofmt -w *.go
sed -i '' '
s/{Func{}, 136, 248}/{Func{}, 152, 280}/
s/{Name{}, 32, 56}/{Name{}, 44, 80}/
s/{Param{}, 24, 48}/{Param{}, 44, 88}/
s/{node{}, 76, 128}/{node{}, 88, 152}/
' sizeof_test.go
cd ../ssa
sed -i '' '
s/{LocalSlot{}, 28, 40}/{LocalSlot{}, 32, 48}/
' sizeof_test.go
cd ../gc
sed -i '' 's/\*ir.Node/ir.Node/' mkbuiltin.go
cd ../../../..
go install std cmd
cd cmd/compile
go test -u || go test -u
Change-Id: I196bbe3b648e4701662e4a2bada40bf155e2a553
Reviewed-on: https://go-review.googlesource.com/c/go/+/272935
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2020-11-25 01:11:56 -05:00
|
|
|
var def ir.Node
|
2016-03-02 17:34:42 -08:00
|
|
|
lno := setlineno(sel)
|
2020-11-22 09:59:15 -05:00
|
|
|
typecheckslice(sel.Init().Slice(), ctxStmt)
|
|
|
|
for _, ncase := range sel.List().Slice() {
|
[dev.regabi] cmd/compile: cleanup for concrete types - range, select, swt
An automated rewrite will add concrete type assertions after
a test of n.Op(), when n can be safely type-asserted
(meaning, n is not reassigned a different type, n is not reassigned
and then used outside the scope of the type assertion,
and so on).
This sequence of CLs handles the code that the automated
rewrite does not: adding specific types to function arguments,
adjusting code not to call n.Left() etc when n may have multiple
representations, and so on.
This CL focuses on range.go, select.go, and swt.go: the big
control structures.
Passes buildall w/ toolstash -cmp.
Change-Id: I033fe056a7b815edb6e8a06f45c12ffd990f4d45
Reviewed-on: https://go-review.googlesource.com/c/go/+/277929
Trust: Russ Cox <rsc@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2020-12-10 18:47:32 -05:00
|
|
|
ncase := ncase.(*ir.CaseStmt)
|
2015-02-13 14:40:36 -05:00
|
|
|
|
2020-11-22 09:59:15 -05:00
|
|
|
if ncase.List().Len() == 0 {
|
2015-02-13 14:40:36 -05:00
|
|
|
// default
|
|
|
|
if def != nil {
|
2020-11-22 09:59:15 -05:00
|
|
|
base.ErrorfAt(ncase.Pos(), "multiple defaults in select (first at %v)", ir.Line(def))
|
2015-02-13 14:40:36 -05:00
|
|
|
} else {
|
|
|
|
def = ncase
|
|
|
|
}
|
2020-11-22 09:59:15 -05:00
|
|
|
} else if ncase.List().Len() > 1 {
|
|
|
|
base.ErrorfAt(ncase.Pos(), "select cases cannot be lists")
|
2015-02-13 14:40:36 -05:00
|
|
|
} else {
|
2020-11-22 09:59:15 -05:00
|
|
|
ncase.List().SetFirst(typecheck(ncase.List().First(), ctxStmt))
|
|
|
|
n := ncase.List().First()
|
|
|
|
ncase.SetLeft(n)
|
|
|
|
ncase.PtrList().Set(nil)
|
2020-12-07 03:24:04 +07:00
|
|
|
oselrecv2 := func(dst, recv ir.Node, colas bool) {
|
[dev.regabi] cmd/compile: remove ir.Nod [generated]
Rewrite all uses of ir.Nod and friends to call the IR constructors directly.
This gives the results a more specific type and will play nicely with
introduction of more specific types throughout the code in a followup CL.
Passes buildall w/ toolstash -cmp.
[git-generate]
cd src/cmd/compile/internal/gc
rf '
ex . ../ir {
import "cmd/compile/internal/ir"
import "cmd/compile/internal/types"
import "cmd/compile/internal/syntax"
import "cmd/internal/src"
var p *noder
var orig syntax.Node
var op ir.Op
var l, r ir.Node
var sym *types.Sym
p.nod(orig, op, l, r) -> ir.NodAt(p.pos(orig), op, l, r)
p.nodSym(orig, op, l, sym) -> nodlSym(p.pos(orig), op, l, sym)
var xpos src.XPos
var ns ir.Nodes
npos(xpos, nodSym(op, l, sym)) -> nodlSym(xpos, op, l, sym)
npos(xpos, liststmt(ns)) -> ir.NewBlockStmt(xpos, ns)
}
ex . ../ir {
import "cmd/compile/internal/base"
import "cmd/compile/internal/ir"
import "cmd/compile/internal/types"
var op ir.Op
var l, r ir.Node
ir.Nod(op, l, r) -> ir.NodAt(base.Pos, op, l, r)
var sym *types.Sym
nodSym(op, l, sym) -> nodlSym(base.Pos, op, l, sym)
}
ex . ../ir {
import "cmd/compile/internal/ir"
import "cmd/internal/src"
# rf overlapping match handling is not quite good enough
# for certain nested rewrites, so handle these two - which often contain other ir.NodAt calls - early.
var l, r ir.Node
var xpos src.XPos
ir.NodAt(xpos, ir.OAS, l, r) -> ir.NewAssignStmt(xpos, l, r)
ir.NodAt(xpos, ir.OIF, l, nil) -> ir.NewIfStmt(xpos, l, nil, nil)
}
ex . ../ir {
import "cmd/compile/internal/ir"
import "cmd/compile/internal/types"
import "cmd/internal/src"
var l, r ir.Node
var sym *types.Sym
var xpos src.XPos
nodlSym(xpos, ir.ODOT, l, sym) -> ir.NewSelectorExpr(xpos, ir.ODOT, l, sym)
nodlSym(xpos, ir.OXDOT, l, sym) -> ir.NewSelectorExpr(xpos, ir.OXDOT, l, sym)
nodlSym(xpos, ir.ODOTPTR, l, sym) -> ir.NewSelectorExpr(xpos, ir.ODOTPTR, l, sym)
nodlSym(xpos, ir.OGOTO, nil, sym) -> ir.NewBranchStmt(xpos, ir.OGOTO, sym)
nodlSym(xpos, ir.ORETJMP, nil, sym) -> ir.NewBranchStmt(xpos, ir.ORETJMP, sym)
nodlSym(xpos, ir.OLABEL, nil, sym) -> ir.NewLabelStmt(xpos, sym)
nodlSym(xpos, ir.OSTRUCTKEY, l, sym) -> ir.NewStructKeyExpr(xpos, sym, l)
ir.NodAt(xpos, ir.OADD, l, r) -> ir.NewBinaryExpr(xpos, ir.OADD, l, r)
ir.NodAt(xpos, ir.OAND, l, r) -> ir.NewBinaryExpr(xpos, ir.OAND, l, r)
ir.NodAt(xpos, ir.OANDNOT, l, r) -> ir.NewBinaryExpr(xpos, ir.OANDNOT, l, r)
ir.NodAt(xpos, ir.ODIV, l, r) -> ir.NewBinaryExpr(xpos, ir.ODIV, l, r)
ir.NodAt(xpos, ir.OEQ, l, r) -> ir.NewBinaryExpr(xpos, ir.OEQ, l, r)
ir.NodAt(xpos, ir.OGE, l, r) -> ir.NewBinaryExpr(xpos, ir.OGE, l, r)
ir.NodAt(xpos, ir.OGT, l, r) -> ir.NewBinaryExpr(xpos, ir.OGT, l, r)
ir.NodAt(xpos, ir.OLE, l, r) -> ir.NewBinaryExpr(xpos, ir.OLE, l, r)
ir.NodAt(xpos, ir.OLSH, l, r) -> ir.NewBinaryExpr(xpos, ir.OLSH, l, r)
ir.NodAt(xpos, ir.OLT, l, r) -> ir.NewBinaryExpr(xpos, ir.OLT, l, r)
ir.NodAt(xpos, ir.OMOD, l, r) -> ir.NewBinaryExpr(xpos, ir.OMOD, l, r)
ir.NodAt(xpos, ir.OMUL, l, r) -> ir.NewBinaryExpr(xpos, ir.OMUL, l, r)
ir.NodAt(xpos, ir.ONE, l, r) -> ir.NewBinaryExpr(xpos, ir.ONE, l, r)
ir.NodAt(xpos, ir.OOR, l, r) -> ir.NewBinaryExpr(xpos, ir.OOR, l, r)
ir.NodAt(xpos, ir.ORSH, l, r) -> ir.NewBinaryExpr(xpos, ir.ORSH, l, r)
ir.NodAt(xpos, ir.OSUB, l, r) -> ir.NewBinaryExpr(xpos, ir.OSUB, l, r)
ir.NodAt(xpos, ir.OXOR, l, r) -> ir.NewBinaryExpr(xpos, ir.OXOR, l, r)
ir.NodAt(xpos, ir.OCOPY, l, r) -> ir.NewBinaryExpr(xpos, ir.OCOPY, l, r)
ir.NodAt(xpos, ir.OCOMPLEX, l, r) -> ir.NewBinaryExpr(xpos, ir.OCOMPLEX, l, r)
ir.NodAt(xpos, ir.OEFACE, l, r) -> ir.NewBinaryExpr(xpos, ir.OEFACE, l, r)
ir.NodAt(xpos, ir.OADDR, l, nil) -> ir.NewAddrExpr(xpos, l)
ir.NodAt(xpos, ir.OADDSTR, nil, nil) -> ir.NewAddStringExpr(xpos, nil)
ir.NodAt(xpos, ir.OANDAND, l, r) -> ir.NewLogicalExpr(xpos, ir.OANDAND, l, r)
ir.NodAt(xpos, ir.OOROR, l, r) -> ir.NewLogicalExpr(xpos, ir.OOROR, l, r)
ir.NodAt(xpos, ir.OARRAYLIT, nil, nil) -> ir.NewCompLitExpr(xpos, ir.OARRAYLIT, nil, nil)
ir.NodAt(xpos, ir.OCOMPLIT, nil, nil) -> ir.NewCompLitExpr(xpos, ir.OCOMPLIT, nil, nil)
ir.NodAt(xpos, ir.OMAPLIT, nil, nil) -> ir.NewCompLitExpr(xpos, ir.OMAPLIT, nil, nil)
ir.NodAt(xpos, ir.OSTRUCTLIT, nil, nil) -> ir.NewCompLitExpr(xpos, ir.OSTRUCTLIT, nil, nil)
ir.NodAt(xpos, ir.OSLICELIT, nil, nil) -> ir.NewCompLitExpr(xpos, ir.OSLICELIT, nil, nil)
ir.NodAt(xpos, ir.OARRAYLIT, nil, r) -> ir.NewCompLitExpr(xpos, ir.OARRAYLIT, r.(ir.Ntype), nil)
ir.NodAt(xpos, ir.OCOMPLIT, nil, r) -> ir.NewCompLitExpr(xpos, ir.OCOMPLIT, r.(ir.Ntype), nil)
ir.NodAt(xpos, ir.OMAPLIT, nil, r) -> ir.NewCompLitExpr(xpos, ir.OMAPLIT, r.(ir.Ntype), nil)
ir.NodAt(xpos, ir.OSTRUCTLIT, nil, r) -> ir.NewCompLitExpr(xpos, ir.OSTRUCTLIT, r.(ir.Ntype), nil)
ir.NodAt(xpos, ir.OSLICELIT, nil, r) -> ir.NewCompLitExpr(xpos, ir.OSLICELIT, r.(ir.Ntype), nil)
ir.NodAt(xpos, ir.OAS2, nil, nil) -> ir.NewAssignListStmt(xpos, ir.OAS2, nil, nil)
ir.NodAt(xpos, ir.OAS2DOTTYPE, nil, nil) -> ir.NewAssignListStmt(xpos, ir.OAS2DOTTYPE, nil, nil)
ir.NodAt(xpos, ir.OAS2FUNC, nil, nil) -> ir.NewAssignListStmt(xpos, ir.OAS2FUNC, nil, nil)
ir.NodAt(xpos, ir.OAS2MAPR, nil, nil) -> ir.NewAssignListStmt(xpos, ir.OAS2MAPR, nil, nil)
ir.NodAt(xpos, ir.OAS2RECV, nil, nil) -> ir.NewAssignListStmt(xpos, ir.OAS2RECV, nil, nil)
ir.NodAt(xpos, ir.OSELRECV2, nil, nil) -> ir.NewAssignListStmt(xpos, ir.OSELRECV2, nil, nil)
ir.NodAt(xpos, ir.OASOP, l, r) -> ir.NewAssignOpStmt(xpos, ir.OXXX, l, r)
ir.NodAt(xpos, ir.OBITNOT, l, nil) -> ir.NewUnaryExpr(xpos, ir.OBITNOT, l)
ir.NodAt(xpos, ir.ONEG, l, nil) -> ir.NewUnaryExpr(xpos, ir.ONEG, l)
ir.NodAt(xpos, ir.ONOT, l, nil) -> ir.NewUnaryExpr(xpos, ir.ONOT, l)
ir.NodAt(xpos, ir.OPLUS, l, nil) -> ir.NewUnaryExpr(xpos, ir.OPLUS, l)
ir.NodAt(xpos, ir.ORECV, l, nil) -> ir.NewUnaryExpr(xpos, ir.ORECV, l)
ir.NodAt(xpos, ir.OALIGNOF, l, nil) -> ir.NewUnaryExpr(xpos, ir.OALIGNOF, l)
ir.NodAt(xpos, ir.OCAP, l, nil) -> ir.NewUnaryExpr(xpos, ir.OCAP, l)
ir.NodAt(xpos, ir.OCLOSE, l, nil) -> ir.NewUnaryExpr(xpos, ir.OCLOSE, l)
ir.NodAt(xpos, ir.OIMAG, l, nil) -> ir.NewUnaryExpr(xpos, ir.OIMAG, l)
ir.NodAt(xpos, ir.OLEN, l, nil) -> ir.NewUnaryExpr(xpos, ir.OLEN, l)
ir.NodAt(xpos, ir.ONEW, l, nil) -> ir.NewUnaryExpr(xpos, ir.ONEW, l)
ir.NodAt(xpos, ir.ONEWOBJ, l, nil) -> ir.NewUnaryExpr(xpos, ir.ONEWOBJ, l)
ir.NodAt(xpos, ir.OOFFSETOF, l, nil) -> ir.NewUnaryExpr(xpos, ir.OOFFSETOF, l)
ir.NodAt(xpos, ir.OPANIC, l, nil) -> ir.NewUnaryExpr(xpos, ir.OPANIC, l)
ir.NodAt(xpos, ir.OREAL, l, nil) -> ir.NewUnaryExpr(xpos, ir.OREAL, l)
ir.NodAt(xpos, ir.OSIZEOF, l, nil) -> ir.NewUnaryExpr(xpos, ir.OSIZEOF, l)
ir.NodAt(xpos, ir.OCHECKNIL, l, nil) -> ir.NewUnaryExpr(xpos, ir.OCHECKNIL, l)
ir.NodAt(xpos, ir.OCFUNC, l, nil) -> ir.NewUnaryExpr(xpos, ir.OCFUNC, l)
ir.NodAt(xpos, ir.OIDATA, l, nil) -> ir.NewUnaryExpr(xpos, ir.OIDATA, l)
ir.NodAt(xpos, ir.OITAB, l, nil) -> ir.NewUnaryExpr(xpos, ir.OITAB, l)
ir.NodAt(xpos, ir.OSPTR, l, nil) -> ir.NewUnaryExpr(xpos, ir.OSPTR, l)
ir.NodAt(xpos, ir.OVARDEF, l, nil) -> ir.NewUnaryExpr(xpos, ir.OVARDEF, l)
ir.NodAt(xpos, ir.OVARKILL, l, nil) -> ir.NewUnaryExpr(xpos, ir.OVARKILL, l)
ir.NodAt(xpos, ir.OVARLIVE, l, nil) -> ir.NewUnaryExpr(xpos, ir.OVARLIVE, l)
ir.NodAt(xpos, ir.OBLOCK, nil, nil) -> ir.NewBlockStmt(xpos, nil)
ir.NodAt(xpos, ir.OBREAK, nil, nil) -> ir.NewBranchStmt(xpos, ir.OBREAK, nil)
ir.NodAt(xpos, ir.OCONTINUE, nil, nil) -> ir.NewBranchStmt(xpos, ir.OCONTINUE, nil)
ir.NodAt(xpos, ir.OFALL, nil, nil) -> ir.NewBranchStmt(xpos, ir.OFALL, nil)
ir.NodAt(xpos, ir.OGOTO, nil, nil) -> ir.NewBranchStmt(xpos, ir.OGOTO, nil)
ir.NodAt(xpos, ir.ORETJMP, nil, nil) -> ir.NewBranchStmt(xpos, ir.ORETJMP, nil)
ir.NodAt(xpos, ir.OCALL, l, nil) -> ir.NewCallExpr(xpos, ir.OCALL, l, nil)
ir.NodAt(xpos, ir.OCALLFUNC, l, nil) -> ir.NewCallExpr(xpos, ir.OCALLFUNC, l, nil)
ir.NodAt(xpos, ir.OCALLINTER, l, nil) -> ir.NewCallExpr(xpos, ir.OCALLINTER, l, nil)
ir.NodAt(xpos, ir.OCALLMETH, l, nil) -> ir.NewCallExpr(xpos, ir.OCALLMETH, l, nil)
ir.NodAt(xpos, ir.OAPPEND, l, nil) -> ir.NewCallExpr(xpos, ir.OAPPEND, l, nil)
ir.NodAt(xpos, ir.ODELETE, l, nil) -> ir.NewCallExpr(xpos, ir.ODELETE, l, nil)
ir.NodAt(xpos, ir.OGETG, l, nil) -> ir.NewCallExpr(xpos, ir.OGETG, l, nil)
ir.NodAt(xpos, ir.OMAKE, l, nil) -> ir.NewCallExpr(xpos, ir.OMAKE, l, nil)
ir.NodAt(xpos, ir.OPRINT, l, nil) -> ir.NewCallExpr(xpos, ir.OPRINT, l, nil)
ir.NodAt(xpos, ir.OPRINTN, l, nil) -> ir.NewCallExpr(xpos, ir.OPRINTN, l, nil)
ir.NodAt(xpos, ir.ORECOVER, l, nil) -> ir.NewCallExpr(xpos, ir.ORECOVER, l, nil)
ir.NodAt(xpos, ir.OCASE, nil, nil) -> ir.NewCaseStmt(xpos, nil, nil)
ir.NodAt(xpos, ir.OCONV, l, nil) -> ir.NewConvExpr(xpos, ir.OCONV, nil, l)
ir.NodAt(xpos, ir.OCONVIFACE, l, nil) -> ir.NewConvExpr(xpos, ir.OCONVIFACE, nil, l)
ir.NodAt(xpos, ir.OCONVNOP, l, nil) -> ir.NewConvExpr(xpos, ir.OCONVNOP, nil, l)
ir.NodAt(xpos, ir.ORUNESTR, l, nil) -> ir.NewConvExpr(xpos, ir.ORUNESTR, nil, l)
ir.NodAt(xpos, ir.ODCL, l, nil) -> ir.NewDecl(xpos, ir.ODCL, l)
ir.NodAt(xpos, ir.ODCLCONST, l, nil) -> ir.NewDecl(xpos, ir.ODCLCONST, l)
ir.NodAt(xpos, ir.ODCLTYPE, l, nil) -> ir.NewDecl(xpos, ir.ODCLTYPE, l)
ir.NodAt(xpos, ir.ODCLFUNC, nil, nil) -> ir.NewFunc(xpos)
ir.NodAt(xpos, ir.ODEFER, l, nil) -> ir.NewGoDeferStmt(xpos, ir.ODEFER, l)
ir.NodAt(xpos, ir.OGO, l, nil) -> ir.NewGoDeferStmt(xpos, ir.OGO, l)
ir.NodAt(xpos, ir.ODEREF, l, nil) -> ir.NewStarExpr(xpos, l)
ir.NodAt(xpos, ir.ODOT, l, nil) -> ir.NewSelectorExpr(xpos, ir.ODOT, l, nil)
ir.NodAt(xpos, ir.ODOTPTR, l, nil) -> ir.NewSelectorExpr(xpos, ir.ODOTPTR, l, nil)
ir.NodAt(xpos, ir.ODOTMETH, l, nil) -> ir.NewSelectorExpr(xpos, ir.ODOTMETH, l, nil)
ir.NodAt(xpos, ir.ODOTINTER, l, nil) -> ir.NewSelectorExpr(xpos, ir.ODOTINTER, l, nil)
ir.NodAt(xpos, ir.OXDOT, l, nil) -> ir.NewSelectorExpr(xpos, ir.OXDOT, l, nil)
ir.NodAt(xpos, ir.ODOTTYPE, l, nil) -> ir.NewTypeAssertExpr(xpos, l, nil)
ir.NodAt(xpos, ir.ODOTTYPE, l, r) -> ir.NewTypeAssertExpr(xpos, l, r.(ir.Ntype))
ir.NodAt(xpos, ir.OFOR, l, r) -> ir.NewForStmt(xpos, nil, l, r, nil)
ir.NodAt(xpos, ir.OINDEX, l, r) -> ir.NewIndexExpr(xpos, l, r)
ir.NodAt(xpos, ir.OINLMARK, nil, nil) -> ir.NewInlineMarkStmt(xpos, types.BADWIDTH)
ir.NodAt(xpos, ir.OKEY, l, r) -> ir.NewKeyExpr(xpos, l, r)
ir.NodAt(xpos, ir.OLABEL, nil, nil) -> ir.NewLabelStmt(xpos, nil)
ir.NodAt(xpos, ir.OMAKECHAN, l, r) -> ir.NewMakeExpr(xpos, ir.OMAKECHAN, l, r)
ir.NodAt(xpos, ir.OMAKEMAP, l, r) -> ir.NewMakeExpr(xpos, ir.OMAKEMAP, l, r)
ir.NodAt(xpos, ir.OMAKESLICE, l, r) -> ir.NewMakeExpr(xpos, ir.OMAKESLICE, l, r)
ir.NodAt(xpos, ir.OMAKESLICECOPY, l, r) -> ir.NewMakeExpr(xpos, ir.OMAKESLICECOPY, l, r)
ir.NodAt(xpos, ir.ONIL, nil, nil) -> ir.NewNilExpr(xpos)
ir.NodAt(xpos, ir.OPACK, nil, nil) -> ir.NewPkgName(xpos, nil, nil)
ir.NodAt(xpos, ir.OPAREN, l, nil) -> ir.NewParenExpr(xpos, l)
ir.NodAt(xpos, ir.ORANGE, nil, r) -> ir.NewRangeStmt(xpos, nil, r, nil)
ir.NodAt(xpos, ir.ORESULT, nil, nil) -> ir.NewResultExpr(xpos, nil, types.BADWIDTH)
ir.NodAt(xpos, ir.ORETURN, nil, nil) -> ir.NewReturnStmt(xpos, nil)
ir.NodAt(xpos, ir.OSELECT, nil, nil) -> ir.NewSelectStmt(xpos, nil)
ir.NodAt(xpos, ir.OSEND, l, r) -> ir.NewSendStmt(xpos, l, r)
ir.NodAt(xpos, ir.OSLICE, l, nil) -> ir.NewSliceExpr(xpos, ir.OSLICE, l)
ir.NodAt(xpos, ir.OSLICEARR, l, nil) -> ir.NewSliceExpr(xpos, ir.OSLICEARR, l)
ir.NodAt(xpos, ir.OSLICESTR, l, nil) -> ir.NewSliceExpr(xpos, ir.OSLICESTR, l)
ir.NodAt(xpos, ir.OSLICE3, l, nil) -> ir.NewSliceExpr(xpos, ir.OSLICE3, l)
ir.NodAt(xpos, ir.OSLICE3ARR, l, nil) -> ir.NewSliceExpr(xpos, ir.OSLICE3ARR, l)
ir.NodAt(xpos, ir.OSLICEHEADER, l, nil) -> ir.NewSliceHeaderExpr(xpos, nil, l, nil, nil)
ir.NodAt(xpos, ir.OSWITCH, l, nil) -> ir.NewSwitchStmt(xpos, l, nil)
ir.NodAt(xpos, ir.OINLCALL, nil, nil) -> ir.NewInlinedCallExpr(xpos, nil, nil)
}
rm noder.nod noder.nodSym nodSym nodlSym ir.NodAt ir.Nod
'
Change-Id: Ibf1eb708de8463ae74ccc47d7966cc263a18295e
Reviewed-on: https://go-review.googlesource.com/c/go/+/277933
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2020-12-22 23:55:29 -05:00
|
|
|
n := ir.NewAssignListStmt(n.Pos(), ir.OSELRECV2, nil, nil)
|
2020-12-07 03:24:04 +07:00
|
|
|
n.PtrList().Set2(dst, ir.BlankNode)
|
|
|
|
n.PtrRlist().Set1(recv)
|
|
|
|
n.SetColas(colas)
|
|
|
|
n.SetTypecheck(1)
|
|
|
|
ncase.SetLeft(n)
|
|
|
|
}
|
2020-11-22 09:59:15 -05:00
|
|
|
switch n.Op() {
|
2015-02-13 14:40:36 -05:00
|
|
|
default:
|
2020-11-22 09:59:15 -05:00
|
|
|
pos := n.Pos()
|
|
|
|
if n.Op() == ir.ONAME {
|
2018-06-19 10:20:35 -07:00
|
|
|
// We don't have the right position for ONAME nodes (see #15459 and
|
|
|
|
// others). Using ncase.Pos for now as it will provide the correct
|
|
|
|
// line number (assuming the expression follows the "case" keyword
|
|
|
|
// on the same line). This matches the approach before 1.10.
|
2020-11-22 09:59:15 -05:00
|
|
|
pos = ncase.Pos()
|
2018-06-19 10:20:35 -07:00
|
|
|
}
|
2020-11-19 20:49:23 -05:00
|
|
|
base.ErrorfAt(pos, "select case must be receive, send or assign recv")
|
2015-02-13 14:40:36 -05:00
|
|
|
|
[dev.regabi] cmd/compile: introduce cmd/compile/internal/ir [generated]
If we want to break up package gc at all, we will need to move
the compiler IR it defines into a separate package that can be
imported by packages that gc itself imports. This CL does that.
It also removes the TINT8 etc aliases so that all code is clear
about which package things are coming from.
This CL is automatically generated by the script below.
See the comments in the script for details about the changes.
[git-generate]
cd src/cmd/compile/internal/gc
rf '
# These names were never fully qualified
# when the types package was added.
# Do it now, to avoid confusion about where they live.
inline -rm \
Txxx \
TINT8 \
TUINT8 \
TINT16 \
TUINT16 \
TINT32 \
TUINT32 \
TINT64 \
TUINT64 \
TINT \
TUINT \
TUINTPTR \
TCOMPLEX64 \
TCOMPLEX128 \
TFLOAT32 \
TFLOAT64 \
TBOOL \
TPTR \
TFUNC \
TSLICE \
TARRAY \
TSTRUCT \
TCHAN \
TMAP \
TINTER \
TFORW \
TANY \
TSTRING \
TUNSAFEPTR \
TIDEAL \
TNIL \
TBLANK \
TFUNCARGS \
TCHANARGS \
NTYPE \
BADWIDTH
# esc.go and escape.go do not need to be split.
# Append esc.go onto the end of escape.go.
mv esc.go escape.go
# Pull out the type format installation from func Main,
# so it can be carried into package ir.
mv Main:/Sconv.=/-0,/TypeLinkSym/-1 InstallTypeFormats
# Names that need to be exported for use by code left in gc.
mv Isconst IsConst
mv asNode AsNode
mv asNodes AsNodes
mv asTypesNode AsTypesNode
mv basicnames BasicTypeNames
mv builtinpkg BuiltinPkg
mv consttype ConstType
mv dumplist DumpList
mv fdumplist FDumpList
mv fmtMode FmtMode
mv goopnames OpNames
mv inspect Inspect
mv inspectList InspectList
mv localpkg LocalPkg
mv nblank BlankNode
mv numImport NumImport
mv opprec OpPrec
mv origSym OrigSym
mv stmtwithinit StmtWithInit
mv dump DumpAny
mv fdump FDumpAny
mv nod Nod
mv nodl NodAt
mv newname NewName
mv newnamel NewNameAt
mv assertRepresents AssertValidTypeForConst
mv represents ValidTypeForConst
mv nodlit NewLiteral
# Types and fields that need to be exported for use by gc.
mv nowritebarrierrecCallSym SymAndPos
mv SymAndPos.lineno SymAndPos.Pos
mv SymAndPos.target SymAndPos.Sym
mv Func.lsym Func.LSym
mv Func.setWBPos Func.SetWBPos
mv Func.numReturns Func.NumReturns
mv Func.numDefers Func.NumDefers
mv Func.nwbrCalls Func.NWBRCalls
# initLSym is an algorithm left behind in gc,
# not an operation on Func itself.
mv Func.initLSym initLSym
mv nodeQueue NodeQueue
mv NodeQueue.empty NodeQueue.Empty
mv NodeQueue.popLeft NodeQueue.PopLeft
mv NodeQueue.pushRight NodeQueue.PushRight
# Many methods on Node are actually algorithms that
# would apply to any node implementation.
# Those become plain functions.
mv Node.funcname FuncName
mv Node.isBlank IsBlank
mv Node.isGoConst isGoConst
mv Node.isNil IsNil
mv Node.isParamHeapCopy isParamHeapCopy
mv Node.isParamStackCopy isParamStackCopy
mv Node.isSimpleName isSimpleName
mv Node.mayBeShared MayBeShared
mv Node.pkgFuncName PkgFuncName
mv Node.backingArrayPtrLen backingArrayPtrLen
mv Node.isterminating isTermNode
mv Node.labeledControl labeledControl
mv Nodes.isterminating isTermNodes
mv Nodes.sigerr fmtSignature
mv Node.MethodName methodExprName
mv Node.MethodFunc methodExprFunc
mv Node.IsMethod IsMethod
# Every node will need to implement RawCopy;
# Copy and SepCopy algorithms will use it.
mv Node.rawcopy Node.RawCopy
mv Node.copy Copy
mv Node.sepcopy SepCopy
# Extract Node.Format method body into func FmtNode,
# but leave method wrapper behind.
mv Node.Format:0,$ FmtNode
# Formatting helpers that will apply to all node implementations.
mv Node.Line Line
mv Node.exprfmt exprFmt
mv Node.jconv jconvFmt
mv Node.modeString modeString
mv Node.nconv nconvFmt
mv Node.nodedump nodeDumpFmt
mv Node.nodefmt nodeFmt
mv Node.stmtfmt stmtFmt
# Constant support needed for code moving to ir.
mv okforconst OKForConst
mv vconv FmtConst
mv int64Val Int64Val
mv float64Val Float64Val
mv Node.ValueInterface ConstValue
# Organize code into files.
mv LocalPkg BuiltinPkg ir.go
mv NumImport InstallTypeFormats Line fmt.go
mv syntax.go Nod NodAt NewNameAt Class Pxxx PragmaFlag Nointerface SymAndPos \
AsNode AsTypesNode BlankNode OrigSym \
Node.SliceBounds Node.SetSliceBounds Op.IsSlice3 \
IsConst Node.Int64Val Node.CanInt64 Node.Uint64Val Node.BoolVal Node.StringVal \
Node.RawCopy SepCopy Copy \
IsNil IsBlank IsMethod \
Node.Typ Node.StorageClass node.go
mv ConstType ConstValue Int64Val Float64Val AssertValidTypeForConst ValidTypeForConst NewLiteral idealType OKForConst val.go
# Move files to new ir package.
mv bitset.go class_string.go dump.go fmt.go \
ir.go node.go op_string.go val.go \
sizeof_test.go cmd/compile/internal/ir
'
: # fix mkbuiltin.go to generate the changes made to builtin.go during rf
sed -i '' '
s/\[T/[types.T/g
s/\*Node/*ir.Node/g
/internal\/types/c \
fmt.Fprintln(&b, `import (`) \
fmt.Fprintln(&b, ` "cmd/compile/internal/ir"`) \
fmt.Fprintln(&b, ` "cmd/compile/internal/types"`) \
fmt.Fprintln(&b, `)`)
' mkbuiltin.go
gofmt -w mkbuiltin.go
: # update cmd/dist to add internal/ir
cd ../../../dist
sed -i '' '/compile.internal.gc/a\
"cmd/compile/internal/ir",
' buildtool.go
gofmt -w buildtool.go
: # update cmd/compile TestFormats
cd ../..
go install std cmd
cd cmd/compile
go test -u || go test # first one updates but fails; second passes
Change-Id: I5f7caf6b20629b51970279e81231a3574d5b51db
Reviewed-on: https://go-review.googlesource.com/c/go/+/273008
Trust: Russ Cox <rsc@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2020-11-19 21:09:22 -05:00
|
|
|
case ir.OAS:
|
2020-12-07 03:24:04 +07:00
|
|
|
// convert x = <-c into x, _ = <-c
|
[dev.regabi] cmd/compile: clean up in preparation for statement Nodes
Using statement nodes restricts the set of valid SetOp operations,
because you can't SetOp across representation. Rewrite various
code to avoid crossing those as-yet-unintroduced boundaries.
In particular, code like
x, y := v.(T)
x, y := f()
x, y := m[k]
x, y := <-c
starts out with Op = OAS2, and then it turns into a specific Op
OAS2DOTTYPE, OAS2FUNC, OAS2MAPR, OAS2RECV, and then
later in walk is lowered to an OAS2 again.
In the middle, the specific forms move the right-hand side from
n.Rlist().First() to n.Right(), and then the conversion to OAS2 moves
it back. This is unnecessary and makes it hard for these all to
share an underlying Node implementation.
This CL changes these specific forms to leave the right-hand side
in n.Rlist().First().
Similarly, OSELRECV2 is really just a temporary form of OAS2.
This CL changes it to use same fields too.
Finally, this CL fixes the printing of OAS2 nodes in ir/fmt.go,
which formerly printed n.Right() instead of n.Rlist().
This results in a (correct!) update to cmd/compile/internal/logopt's
expected output: ~R0 = <N> becomes ~R0 = &y.b.
Passes buildall w/ toolstash -cmp.
Change-Id: I164aa2e17dc55bfb292024de53d7d250192ad64a
Reviewed-on: https://go-review.googlesource.com/c/go/+/274105
Trust: Russ Cox <rsc@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2020-11-28 15:28:18 -05:00
|
|
|
// remove implicit conversions; the eventual assignment
|
|
|
|
// will reintroduce them.
|
[dev.regabi] cmd/compile: cleanup for concrete types - range, select, swt
An automated rewrite will add concrete type assertions after
a test of n.Op(), when n can be safely type-asserted
(meaning, n is not reassigned a different type, n is not reassigned
and then used outside the scope of the type assertion,
and so on).
This sequence of CLs handles the code that the automated
rewrite does not: adding specific types to function arguments,
adjusting code not to call n.Left() etc when n may have multiple
representations, and so on.
This CL focuses on range.go, select.go, and swt.go: the big
control structures.
Passes buildall w/ toolstash -cmp.
Change-Id: I033fe056a7b815edb6e8a06f45c12ffd990f4d45
Reviewed-on: https://go-review.googlesource.com/c/go/+/277929
Trust: Russ Cox <rsc@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2020-12-10 18:47:32 -05:00
|
|
|
if r := n.Right(); r.Op() == ir.OCONVNOP || r.Op() == ir.OCONVIFACE {
|
|
|
|
if r.Implicit() {
|
|
|
|
n.SetRight(r.Left())
|
|
|
|
}
|
2015-02-13 14:40:36 -05:00
|
|
|
}
|
2020-11-22 09:59:15 -05:00
|
|
|
if n.Right().Op() != ir.ORECV {
|
|
|
|
base.ErrorfAt(n.Pos(), "select assignment must have receive on right hand side")
|
2015-02-13 14:40:36 -05:00
|
|
|
break
|
|
|
|
}
|
2020-12-07 03:24:04 +07:00
|
|
|
oselrecv2(n.Left(), n.Right(), n.Colas())
|
2015-02-13 14:40:36 -05:00
|
|
|
|
[dev.regabi] cmd/compile: introduce cmd/compile/internal/ir [generated]
If we want to break up package gc at all, we will need to move
the compiler IR it defines into a separate package that can be
imported by packages that gc itself imports. This CL does that.
It also removes the TINT8 etc aliases so that all code is clear
about which package things are coming from.
This CL is automatically generated by the script below.
See the comments in the script for details about the changes.
[git-generate]
cd src/cmd/compile/internal/gc
rf '
# These names were never fully qualified
# when the types package was added.
# Do it now, to avoid confusion about where they live.
inline -rm \
Txxx \
TINT8 \
TUINT8 \
TINT16 \
TUINT16 \
TINT32 \
TUINT32 \
TINT64 \
TUINT64 \
TINT \
TUINT \
TUINTPTR \
TCOMPLEX64 \
TCOMPLEX128 \
TFLOAT32 \
TFLOAT64 \
TBOOL \
TPTR \
TFUNC \
TSLICE \
TARRAY \
TSTRUCT \
TCHAN \
TMAP \
TINTER \
TFORW \
TANY \
TSTRING \
TUNSAFEPTR \
TIDEAL \
TNIL \
TBLANK \
TFUNCARGS \
TCHANARGS \
NTYPE \
BADWIDTH
# esc.go and escape.go do not need to be split.
# Append esc.go onto the end of escape.go.
mv esc.go escape.go
# Pull out the type format installation from func Main,
# so it can be carried into package ir.
mv Main:/Sconv.=/-0,/TypeLinkSym/-1 InstallTypeFormats
# Names that need to be exported for use by code left in gc.
mv Isconst IsConst
mv asNode AsNode
mv asNodes AsNodes
mv asTypesNode AsTypesNode
mv basicnames BasicTypeNames
mv builtinpkg BuiltinPkg
mv consttype ConstType
mv dumplist DumpList
mv fdumplist FDumpList
mv fmtMode FmtMode
mv goopnames OpNames
mv inspect Inspect
mv inspectList InspectList
mv localpkg LocalPkg
mv nblank BlankNode
mv numImport NumImport
mv opprec OpPrec
mv origSym OrigSym
mv stmtwithinit StmtWithInit
mv dump DumpAny
mv fdump FDumpAny
mv nod Nod
mv nodl NodAt
mv newname NewName
mv newnamel NewNameAt
mv assertRepresents AssertValidTypeForConst
mv represents ValidTypeForConst
mv nodlit NewLiteral
# Types and fields that need to be exported for use by gc.
mv nowritebarrierrecCallSym SymAndPos
mv SymAndPos.lineno SymAndPos.Pos
mv SymAndPos.target SymAndPos.Sym
mv Func.lsym Func.LSym
mv Func.setWBPos Func.SetWBPos
mv Func.numReturns Func.NumReturns
mv Func.numDefers Func.NumDefers
mv Func.nwbrCalls Func.NWBRCalls
# initLSym is an algorithm left behind in gc,
# not an operation on Func itself.
mv Func.initLSym initLSym
mv nodeQueue NodeQueue
mv NodeQueue.empty NodeQueue.Empty
mv NodeQueue.popLeft NodeQueue.PopLeft
mv NodeQueue.pushRight NodeQueue.PushRight
# Many methods on Node are actually algorithms that
# would apply to any node implementation.
# Those become plain functions.
mv Node.funcname FuncName
mv Node.isBlank IsBlank
mv Node.isGoConst isGoConst
mv Node.isNil IsNil
mv Node.isParamHeapCopy isParamHeapCopy
mv Node.isParamStackCopy isParamStackCopy
mv Node.isSimpleName isSimpleName
mv Node.mayBeShared MayBeShared
mv Node.pkgFuncName PkgFuncName
mv Node.backingArrayPtrLen backingArrayPtrLen
mv Node.isterminating isTermNode
mv Node.labeledControl labeledControl
mv Nodes.isterminating isTermNodes
mv Nodes.sigerr fmtSignature
mv Node.MethodName methodExprName
mv Node.MethodFunc methodExprFunc
mv Node.IsMethod IsMethod
# Every node will need to implement RawCopy;
# Copy and SepCopy algorithms will use it.
mv Node.rawcopy Node.RawCopy
mv Node.copy Copy
mv Node.sepcopy SepCopy
# Extract Node.Format method body into func FmtNode,
# but leave method wrapper behind.
mv Node.Format:0,$ FmtNode
# Formatting helpers that will apply to all node implementations.
mv Node.Line Line
mv Node.exprfmt exprFmt
mv Node.jconv jconvFmt
mv Node.modeString modeString
mv Node.nconv nconvFmt
mv Node.nodedump nodeDumpFmt
mv Node.nodefmt nodeFmt
mv Node.stmtfmt stmtFmt
# Constant support needed for code moving to ir.
mv okforconst OKForConst
mv vconv FmtConst
mv int64Val Int64Val
mv float64Val Float64Val
mv Node.ValueInterface ConstValue
# Organize code into files.
mv LocalPkg BuiltinPkg ir.go
mv NumImport InstallTypeFormats Line fmt.go
mv syntax.go Nod NodAt NewNameAt Class Pxxx PragmaFlag Nointerface SymAndPos \
AsNode AsTypesNode BlankNode OrigSym \
Node.SliceBounds Node.SetSliceBounds Op.IsSlice3 \
IsConst Node.Int64Val Node.CanInt64 Node.Uint64Val Node.BoolVal Node.StringVal \
Node.RawCopy SepCopy Copy \
IsNil IsBlank IsMethod \
Node.Typ Node.StorageClass node.go
mv ConstType ConstValue Int64Val Float64Val AssertValidTypeForConst ValidTypeForConst NewLiteral idealType OKForConst val.go
# Move files to new ir package.
mv bitset.go class_string.go dump.go fmt.go \
ir.go node.go op_string.go val.go \
sizeof_test.go cmd/compile/internal/ir
'
: # fix mkbuiltin.go to generate the changes made to builtin.go during rf
sed -i '' '
s/\[T/[types.T/g
s/\*Node/*ir.Node/g
/internal\/types/c \
fmt.Fprintln(&b, `import (`) \
fmt.Fprintln(&b, ` "cmd/compile/internal/ir"`) \
fmt.Fprintln(&b, ` "cmd/compile/internal/types"`) \
fmt.Fprintln(&b, `)`)
' mkbuiltin.go
gofmt -w mkbuiltin.go
: # update cmd/dist to add internal/ir
cd ../../../dist
sed -i '' '/compile.internal.gc/a\
"cmd/compile/internal/ir",
' buildtool.go
gofmt -w buildtool.go
: # update cmd/compile TestFormats
cd ../..
go install std cmd
cd cmd/compile
go test -u || go test # first one updates but fails; second passes
Change-Id: I5f7caf6b20629b51970279e81231a3574d5b51db
Reviewed-on: https://go-review.googlesource.com/c/go/+/273008
Trust: Russ Cox <rsc@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2020-11-19 21:09:22 -05:00
|
|
|
case ir.OAS2RECV:
|
[dev.regabi] cmd/compile: clean up in preparation for statement Nodes
Using statement nodes restricts the set of valid SetOp operations,
because you can't SetOp across representation. Rewrite various
code to avoid crossing those as-yet-unintroduced boundaries.
In particular, code like
x, y := v.(T)
x, y := f()
x, y := m[k]
x, y := <-c
starts out with Op = OAS2, and then it turns into a specific Op
OAS2DOTTYPE, OAS2FUNC, OAS2MAPR, OAS2RECV, and then
later in walk is lowered to an OAS2 again.
In the middle, the specific forms move the right-hand side from
n.Rlist().First() to n.Right(), and then the conversion to OAS2 moves
it back. This is unnecessary and makes it hard for these all to
share an underlying Node implementation.
This CL changes these specific forms to leave the right-hand side
in n.Rlist().First().
Similarly, OSELRECV2 is really just a temporary form of OAS2.
This CL changes it to use same fields too.
Finally, this CL fixes the printing of OAS2 nodes in ir/fmt.go,
which formerly printed n.Right() instead of n.Rlist().
This results in a (correct!) update to cmd/compile/internal/logopt's
expected output: ~R0 = <N> becomes ~R0 = &y.b.
Passes buildall w/ toolstash -cmp.
Change-Id: I164aa2e17dc55bfb292024de53d7d250192ad64a
Reviewed-on: https://go-review.googlesource.com/c/go/+/274105
Trust: Russ Cox <rsc@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2020-11-28 15:28:18 -05:00
|
|
|
if n.Rlist().First().Op() != ir.ORECV {
|
2020-11-22 09:59:15 -05:00
|
|
|
base.ErrorfAt(n.Pos(), "select assignment must have receive on right hand side")
|
2015-02-13 14:40:36 -05:00
|
|
|
break
|
|
|
|
}
|
2020-11-22 09:59:15 -05:00
|
|
|
n.SetOp(ir.OSELRECV2)
|
2015-02-13 14:40:36 -05:00
|
|
|
|
[dev.regabi] cmd/compile: introduce cmd/compile/internal/ir [generated]
If we want to break up package gc at all, we will need to move
the compiler IR it defines into a separate package that can be
imported by packages that gc itself imports. This CL does that.
It also removes the TINT8 etc aliases so that all code is clear
about which package things are coming from.
This CL is automatically generated by the script below.
See the comments in the script for details about the changes.
[git-generate]
cd src/cmd/compile/internal/gc
rf '
# These names were never fully qualified
# when the types package was added.
# Do it now, to avoid confusion about where they live.
inline -rm \
Txxx \
TINT8 \
TUINT8 \
TINT16 \
TUINT16 \
TINT32 \
TUINT32 \
TINT64 \
TUINT64 \
TINT \
TUINT \
TUINTPTR \
TCOMPLEX64 \
TCOMPLEX128 \
TFLOAT32 \
TFLOAT64 \
TBOOL \
TPTR \
TFUNC \
TSLICE \
TARRAY \
TSTRUCT \
TCHAN \
TMAP \
TINTER \
TFORW \
TANY \
TSTRING \
TUNSAFEPTR \
TIDEAL \
TNIL \
TBLANK \
TFUNCARGS \
TCHANARGS \
NTYPE \
BADWIDTH
# esc.go and escape.go do not need to be split.
# Append esc.go onto the end of escape.go.
mv esc.go escape.go
# Pull out the type format installation from func Main,
# so it can be carried into package ir.
mv Main:/Sconv.=/-0,/TypeLinkSym/-1 InstallTypeFormats
# Names that need to be exported for use by code left in gc.
mv Isconst IsConst
mv asNode AsNode
mv asNodes AsNodes
mv asTypesNode AsTypesNode
mv basicnames BasicTypeNames
mv builtinpkg BuiltinPkg
mv consttype ConstType
mv dumplist DumpList
mv fdumplist FDumpList
mv fmtMode FmtMode
mv goopnames OpNames
mv inspect Inspect
mv inspectList InspectList
mv localpkg LocalPkg
mv nblank BlankNode
mv numImport NumImport
mv opprec OpPrec
mv origSym OrigSym
mv stmtwithinit StmtWithInit
mv dump DumpAny
mv fdump FDumpAny
mv nod Nod
mv nodl NodAt
mv newname NewName
mv newnamel NewNameAt
mv assertRepresents AssertValidTypeForConst
mv represents ValidTypeForConst
mv nodlit NewLiteral
# Types and fields that need to be exported for use by gc.
mv nowritebarrierrecCallSym SymAndPos
mv SymAndPos.lineno SymAndPos.Pos
mv SymAndPos.target SymAndPos.Sym
mv Func.lsym Func.LSym
mv Func.setWBPos Func.SetWBPos
mv Func.numReturns Func.NumReturns
mv Func.numDefers Func.NumDefers
mv Func.nwbrCalls Func.NWBRCalls
# initLSym is an algorithm left behind in gc,
# not an operation on Func itself.
mv Func.initLSym initLSym
mv nodeQueue NodeQueue
mv NodeQueue.empty NodeQueue.Empty
mv NodeQueue.popLeft NodeQueue.PopLeft
mv NodeQueue.pushRight NodeQueue.PushRight
# Many methods on Node are actually algorithms that
# would apply to any node implementation.
# Those become plain functions.
mv Node.funcname FuncName
mv Node.isBlank IsBlank
mv Node.isGoConst isGoConst
mv Node.isNil IsNil
mv Node.isParamHeapCopy isParamHeapCopy
mv Node.isParamStackCopy isParamStackCopy
mv Node.isSimpleName isSimpleName
mv Node.mayBeShared MayBeShared
mv Node.pkgFuncName PkgFuncName
mv Node.backingArrayPtrLen backingArrayPtrLen
mv Node.isterminating isTermNode
mv Node.labeledControl labeledControl
mv Nodes.isterminating isTermNodes
mv Nodes.sigerr fmtSignature
mv Node.MethodName methodExprName
mv Node.MethodFunc methodExprFunc
mv Node.IsMethod IsMethod
# Every node will need to implement RawCopy;
# Copy and SepCopy algorithms will use it.
mv Node.rawcopy Node.RawCopy
mv Node.copy Copy
mv Node.sepcopy SepCopy
# Extract Node.Format method body into func FmtNode,
# but leave method wrapper behind.
mv Node.Format:0,$ FmtNode
# Formatting helpers that will apply to all node implementations.
mv Node.Line Line
mv Node.exprfmt exprFmt
mv Node.jconv jconvFmt
mv Node.modeString modeString
mv Node.nconv nconvFmt
mv Node.nodedump nodeDumpFmt
mv Node.nodefmt nodeFmt
mv Node.stmtfmt stmtFmt
# Constant support needed for code moving to ir.
mv okforconst OKForConst
mv vconv FmtConst
mv int64Val Int64Val
mv float64Val Float64Val
mv Node.ValueInterface ConstValue
# Organize code into files.
mv LocalPkg BuiltinPkg ir.go
mv NumImport InstallTypeFormats Line fmt.go
mv syntax.go Nod NodAt NewNameAt Class Pxxx PragmaFlag Nointerface SymAndPos \
AsNode AsTypesNode BlankNode OrigSym \
Node.SliceBounds Node.SetSliceBounds Op.IsSlice3 \
IsConst Node.Int64Val Node.CanInt64 Node.Uint64Val Node.BoolVal Node.StringVal \
Node.RawCopy SepCopy Copy \
IsNil IsBlank IsMethod \
Node.Typ Node.StorageClass node.go
mv ConstType ConstValue Int64Val Float64Val AssertValidTypeForConst ValidTypeForConst NewLiteral idealType OKForConst val.go
# Move files to new ir package.
mv bitset.go class_string.go dump.go fmt.go \
ir.go node.go op_string.go val.go \
sizeof_test.go cmd/compile/internal/ir
'
: # fix mkbuiltin.go to generate the changes made to builtin.go during rf
sed -i '' '
s/\[T/[types.T/g
s/\*Node/*ir.Node/g
/internal\/types/c \
fmt.Fprintln(&b, `import (`) \
fmt.Fprintln(&b, ` "cmd/compile/internal/ir"`) \
fmt.Fprintln(&b, ` "cmd/compile/internal/types"`) \
fmt.Fprintln(&b, `)`)
' mkbuiltin.go
gofmt -w mkbuiltin.go
: # update cmd/dist to add internal/ir
cd ../../../dist
sed -i '' '/compile.internal.gc/a\
"cmd/compile/internal/ir",
' buildtool.go
gofmt -w buildtool.go
: # update cmd/compile TestFormats
cd ../..
go install std cmd
cd cmd/compile
go test -u || go test # first one updates but fails; second passes
Change-Id: I5f7caf6b20629b51970279e81231a3574d5b51db
Reviewed-on: https://go-review.googlesource.com/c/go/+/273008
Trust: Russ Cox <rsc@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2020-11-19 21:09:22 -05:00
|
|
|
case ir.ORECV:
|
2020-12-07 03:24:04 +07:00
|
|
|
// convert <-c into _, _ = <-c
|
|
|
|
oselrecv2(ir.BlankNode, n, false)
|
2015-02-13 14:40:36 -05:00
|
|
|
|
[dev.regabi] cmd/compile: introduce cmd/compile/internal/ir [generated]
If we want to break up package gc at all, we will need to move
the compiler IR it defines into a separate package that can be
imported by packages that gc itself imports. This CL does that.
It also removes the TINT8 etc aliases so that all code is clear
about which package things are coming from.
This CL is automatically generated by the script below.
See the comments in the script for details about the changes.
[git-generate]
cd src/cmd/compile/internal/gc
rf '
# These names were never fully qualified
# when the types package was added.
# Do it now, to avoid confusion about where they live.
inline -rm \
Txxx \
TINT8 \
TUINT8 \
TINT16 \
TUINT16 \
TINT32 \
TUINT32 \
TINT64 \
TUINT64 \
TINT \
TUINT \
TUINTPTR \
TCOMPLEX64 \
TCOMPLEX128 \
TFLOAT32 \
TFLOAT64 \
TBOOL \
TPTR \
TFUNC \
TSLICE \
TARRAY \
TSTRUCT \
TCHAN \
TMAP \
TINTER \
TFORW \
TANY \
TSTRING \
TUNSAFEPTR \
TIDEAL \
TNIL \
TBLANK \
TFUNCARGS \
TCHANARGS \
NTYPE \
BADWIDTH
# esc.go and escape.go do not need to be split.
# Append esc.go onto the end of escape.go.
mv esc.go escape.go
# Pull out the type format installation from func Main,
# so it can be carried into package ir.
mv Main:/Sconv.=/-0,/TypeLinkSym/-1 InstallTypeFormats
# Names that need to be exported for use by code left in gc.
mv Isconst IsConst
mv asNode AsNode
mv asNodes AsNodes
mv asTypesNode AsTypesNode
mv basicnames BasicTypeNames
mv builtinpkg BuiltinPkg
mv consttype ConstType
mv dumplist DumpList
mv fdumplist FDumpList
mv fmtMode FmtMode
mv goopnames OpNames
mv inspect Inspect
mv inspectList InspectList
mv localpkg LocalPkg
mv nblank BlankNode
mv numImport NumImport
mv opprec OpPrec
mv origSym OrigSym
mv stmtwithinit StmtWithInit
mv dump DumpAny
mv fdump FDumpAny
mv nod Nod
mv nodl NodAt
mv newname NewName
mv newnamel NewNameAt
mv assertRepresents AssertValidTypeForConst
mv represents ValidTypeForConst
mv nodlit NewLiteral
# Types and fields that need to be exported for use by gc.
mv nowritebarrierrecCallSym SymAndPos
mv SymAndPos.lineno SymAndPos.Pos
mv SymAndPos.target SymAndPos.Sym
mv Func.lsym Func.LSym
mv Func.setWBPos Func.SetWBPos
mv Func.numReturns Func.NumReturns
mv Func.numDefers Func.NumDefers
mv Func.nwbrCalls Func.NWBRCalls
# initLSym is an algorithm left behind in gc,
# not an operation on Func itself.
mv Func.initLSym initLSym
mv nodeQueue NodeQueue
mv NodeQueue.empty NodeQueue.Empty
mv NodeQueue.popLeft NodeQueue.PopLeft
mv NodeQueue.pushRight NodeQueue.PushRight
# Many methods on Node are actually algorithms that
# would apply to any node implementation.
# Those become plain functions.
mv Node.funcname FuncName
mv Node.isBlank IsBlank
mv Node.isGoConst isGoConst
mv Node.isNil IsNil
mv Node.isParamHeapCopy isParamHeapCopy
mv Node.isParamStackCopy isParamStackCopy
mv Node.isSimpleName isSimpleName
mv Node.mayBeShared MayBeShared
mv Node.pkgFuncName PkgFuncName
mv Node.backingArrayPtrLen backingArrayPtrLen
mv Node.isterminating isTermNode
mv Node.labeledControl labeledControl
mv Nodes.isterminating isTermNodes
mv Nodes.sigerr fmtSignature
mv Node.MethodName methodExprName
mv Node.MethodFunc methodExprFunc
mv Node.IsMethod IsMethod
# Every node will need to implement RawCopy;
# Copy and SepCopy algorithms will use it.
mv Node.rawcopy Node.RawCopy
mv Node.copy Copy
mv Node.sepcopy SepCopy
# Extract Node.Format method body into func FmtNode,
# but leave method wrapper behind.
mv Node.Format:0,$ FmtNode
# Formatting helpers that will apply to all node implementations.
mv Node.Line Line
mv Node.exprfmt exprFmt
mv Node.jconv jconvFmt
mv Node.modeString modeString
mv Node.nconv nconvFmt
mv Node.nodedump nodeDumpFmt
mv Node.nodefmt nodeFmt
mv Node.stmtfmt stmtFmt
# Constant support needed for code moving to ir.
mv okforconst OKForConst
mv vconv FmtConst
mv int64Val Int64Val
mv float64Val Float64Val
mv Node.ValueInterface ConstValue
# Organize code into files.
mv LocalPkg BuiltinPkg ir.go
mv NumImport InstallTypeFormats Line fmt.go
mv syntax.go Nod NodAt NewNameAt Class Pxxx PragmaFlag Nointerface SymAndPos \
AsNode AsTypesNode BlankNode OrigSym \
Node.SliceBounds Node.SetSliceBounds Op.IsSlice3 \
IsConst Node.Int64Val Node.CanInt64 Node.Uint64Val Node.BoolVal Node.StringVal \
Node.RawCopy SepCopy Copy \
IsNil IsBlank IsMethod \
Node.Typ Node.StorageClass node.go
mv ConstType ConstValue Int64Val Float64Val AssertValidTypeForConst ValidTypeForConst NewLiteral idealType OKForConst val.go
# Move files to new ir package.
mv bitset.go class_string.go dump.go fmt.go \
ir.go node.go op_string.go val.go \
sizeof_test.go cmd/compile/internal/ir
'
: # fix mkbuiltin.go to generate the changes made to builtin.go during rf
sed -i '' '
s/\[T/[types.T/g
s/\*Node/*ir.Node/g
/internal\/types/c \
fmt.Fprintln(&b, `import (`) \
fmt.Fprintln(&b, ` "cmd/compile/internal/ir"`) \
fmt.Fprintln(&b, ` "cmd/compile/internal/types"`) \
fmt.Fprintln(&b, `)`)
' mkbuiltin.go
gofmt -w mkbuiltin.go
: # update cmd/dist to add internal/ir
cd ../../../dist
sed -i '' '/compile.internal.gc/a\
"cmd/compile/internal/ir",
' buildtool.go
gofmt -w buildtool.go
: # update cmd/compile TestFormats
cd ../..
go install std cmd
cd cmd/compile
go test -u || go test # first one updates but fails; second passes
Change-Id: I5f7caf6b20629b51970279e81231a3574d5b51db
Reviewed-on: https://go-review.googlesource.com/c/go/+/273008
Trust: Russ Cox <rsc@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2020-11-19 21:09:22 -05:00
|
|
|
case ir.OSEND:
|
2015-02-13 14:40:36 -05:00
|
|
|
break
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-22 09:59:15 -05:00
|
|
|
typecheckslice(ncase.Body().Slice(), ctxStmt)
|
2015-02-13 14:40:36 -05:00
|
|
|
}
|
|
|
|
|
2020-11-19 20:49:23 -05:00
|
|
|
base.Pos = lno
|
2015-02-13 14:40:36 -05:00
|
|
|
}
|
|
|
|
|
[dev.regabi] cmd/compile: cleanup for concrete types - range, select, swt
An automated rewrite will add concrete type assertions after
a test of n.Op(), when n can be safely type-asserted
(meaning, n is not reassigned a different type, n is not reassigned
and then used outside the scope of the type assertion,
and so on).
This sequence of CLs handles the code that the automated
rewrite does not: adding specific types to function arguments,
adjusting code not to call n.Left() etc when n may have multiple
representations, and so on.
This CL focuses on range.go, select.go, and swt.go: the big
control structures.
Passes buildall w/ toolstash -cmp.
Change-Id: I033fe056a7b815edb6e8a06f45c12ffd990f4d45
Reviewed-on: https://go-review.googlesource.com/c/go/+/277929
Trust: Russ Cox <rsc@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2020-12-10 18:47:32 -05:00
|
|
|
func walkselect(sel *ir.SelectStmt) {
|
2017-10-22 17:18:51 +01:00
|
|
|
lno := setlineno(sel)
|
2020-11-22 09:59:15 -05:00
|
|
|
if sel.Body().Len() != 0 {
|
2020-11-19 20:49:23 -05:00
|
|
|
base.Fatalf("double walkselect")
|
2015-02-13 14:40:36 -05:00
|
|
|
}
|
|
|
|
|
2020-11-22 09:59:15 -05:00
|
|
|
init := sel.Init().Slice()
|
|
|
|
sel.PtrInit().Set(nil)
|
2017-10-22 17:18:51 +01:00
|
|
|
|
[dev.regabi] cmd/compile: cleanup for concrete types - range, select, swt
An automated rewrite will add concrete type assertions after
a test of n.Op(), when n can be safely type-asserted
(meaning, n is not reassigned a different type, n is not reassigned
and then used outside the scope of the type assertion,
and so on).
This sequence of CLs handles the code that the automated
rewrite does not: adding specific types to function arguments,
adjusting code not to call n.Left() etc when n may have multiple
representations, and so on.
This CL focuses on range.go, select.go, and swt.go: the big
control structures.
Passes buildall w/ toolstash -cmp.
Change-Id: I033fe056a7b815edb6e8a06f45c12ffd990f4d45
Reviewed-on: https://go-review.googlesource.com/c/go/+/277929
Trust: Russ Cox <rsc@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2020-12-10 18:47:32 -05:00
|
|
|
init = append(init, walkselectcases(sel.List())...)
|
|
|
|
sel.SetList(ir.Nodes{})
|
2017-10-22 17:18:51 +01:00
|
|
|
|
2020-11-22 09:59:15 -05:00
|
|
|
sel.PtrBody().Set(init)
|
|
|
|
walkstmtlist(sel.Body().Slice())
|
2017-10-22 17:18:51 +01:00
|
|
|
|
2020-11-19 20:49:23 -05:00
|
|
|
base.Pos = lno
|
2017-10-22 17:18:51 +01:00
|
|
|
}
|
|
|
|
|
[dev.regabi] cmd/compile: cleanup for concrete types - range, select, swt
An automated rewrite will add concrete type assertions after
a test of n.Op(), when n can be safely type-asserted
(meaning, n is not reassigned a different type, n is not reassigned
and then used outside the scope of the type assertion,
and so on).
This sequence of CLs handles the code that the automated
rewrite does not: adding specific types to function arguments,
adjusting code not to call n.Left() etc when n may have multiple
representations, and so on.
This CL focuses on range.go, select.go, and swt.go: the big
control structures.
Passes buildall w/ toolstash -cmp.
Change-Id: I033fe056a7b815edb6e8a06f45c12ffd990f4d45
Reviewed-on: https://go-review.googlesource.com/c/go/+/277929
Trust: Russ Cox <rsc@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2020-12-10 18:47:32 -05:00
|
|
|
func walkselectcases(cases ir.Nodes) []ir.Node {
|
2020-07-27 16:19:15 -07:00
|
|
|
ncas := cases.Len()
|
2020-11-19 20:49:23 -05:00
|
|
|
sellineno := base.Pos
|
2015-02-13 14:40:36 -05:00
|
|
|
|
|
|
|
// optimization: zero-case select
|
2020-07-27 16:19:15 -07:00
|
|
|
if ncas == 0 {
|
[dev.regabi] cmd/compile: replace *Node type with an interface Node [generated]
The plan is to introduce a Node interface that replaces the old *Node pointer-to-struct.
The previous CL defined an interface INode modeling a *Node.
This CL:
- Changes all references outside internal/ir to use INode,
along with many references inside internal/ir as well.
- Renames Node to node.
- Renames INode to Node
So now ir.Node is an interface implemented by *ir.node, which is otherwise inaccessible,
and the code outside package ir is now (clearly) using only the interface.
The usual rule is never to redefine an existing name with a new meaning,
so that old code that hasn't been updated gets a "unknown name" error
instead of more mysterious errors or silent misbehavior. That rule would
caution against replacing Node-the-struct with Node-the-interface,
as in this CL, because code that says *Node would now be using a pointer
to an interface. But this CL is being landed at the same time as another that
moves Node from gc to ir. So the net effect is to replace *gc.Node with ir.Node,
which does follow the rule: any lingering references to gc.Node will be told
it's gone, not silently start using pointers to interfaces. So the rule is followed
by the CL sequence, just not this specific CL.
Overall, the loss of inlining caused by using interfaces cuts the compiler speed
by about 6%, a not insignificant amount. However, as we convert the representation
to concrete structs that are not the giant Node over the next weeks, that speed
should come back as more of the compiler starts operating directly on concrete types
and the memory taken up by the graph of Nodes drops due to the more precise
structs. Honestly, I was expecting worse.
% benchstat bench.old bench.new
name old time/op new time/op delta
Template 168ms ± 4% 182ms ± 2% +8.34% (p=0.000 n=9+9)
Unicode 72.2ms ±10% 82.5ms ± 6% +14.38% (p=0.000 n=9+9)
GoTypes 563ms ± 8% 598ms ± 2% +6.14% (p=0.006 n=9+9)
Compiler 2.89s ± 4% 3.04s ± 2% +5.37% (p=0.000 n=10+9)
SSA 6.45s ± 4% 7.25s ± 5% +12.41% (p=0.000 n=9+10)
Flate 105ms ± 2% 115ms ± 1% +9.66% (p=0.000 n=10+8)
GoParser 144ms ±10% 152ms ± 2% +5.79% (p=0.011 n=9+8)
Reflect 345ms ± 9% 370ms ± 4% +7.28% (p=0.001 n=10+9)
Tar 149ms ± 9% 161ms ± 5% +8.05% (p=0.001 n=10+9)
XML 190ms ± 3% 209ms ± 2% +9.54% (p=0.000 n=9+8)
LinkCompiler 327ms ± 2% 325ms ± 2% ~ (p=0.382 n=8+8)
ExternalLinkCompiler 1.77s ± 4% 1.73s ± 6% ~ (p=0.113 n=9+10)
LinkWithoutDebugCompiler 214ms ± 4% 211ms ± 2% ~ (p=0.360 n=10+8)
StdCmd 14.8s ± 3% 15.9s ± 1% +6.98% (p=0.000 n=10+9)
[Geo mean] 480ms 510ms +6.31%
name old user-time/op new user-time/op delta
Template 223ms ± 3% 237ms ± 3% +6.16% (p=0.000 n=9+10)
Unicode 103ms ± 6% 113ms ± 3% +9.53% (p=0.000 n=9+9)
GoTypes 758ms ± 8% 800ms ± 2% +5.55% (p=0.003 n=10+9)
Compiler 3.95s ± 2% 4.12s ± 2% +4.34% (p=0.000 n=10+9)
SSA 9.43s ± 1% 9.74s ± 4% +3.25% (p=0.000 n=8+10)
Flate 132ms ± 2% 141ms ± 2% +6.89% (p=0.000 n=9+9)
GoParser 177ms ± 9% 183ms ± 4% ~ (p=0.050 n=9+9)
Reflect 467ms ±10% 495ms ± 7% +6.17% (p=0.029 n=10+10)
Tar 183ms ± 9% 197ms ± 5% +7.92% (p=0.001 n=10+10)
XML 249ms ± 5% 268ms ± 4% +7.82% (p=0.000 n=10+9)
LinkCompiler 544ms ± 5% 544ms ± 6% ~ (p=0.863 n=9+9)
ExternalLinkCompiler 1.79s ± 4% 1.75s ± 6% ~ (p=0.075 n=10+10)
LinkWithoutDebugCompiler 248ms ± 6% 246ms ± 2% ~ (p=0.965 n=10+8)
[Geo mean] 483ms 504ms +4.41%
[git-generate]
cd src/cmd/compile/internal/ir
: # We need to do the conversion in multiple steps, so we introduce
: # a temporary type alias that will start out meaning the pointer-to-struct
: # and then change to mean the interface.
rf '
mv Node OldNode
add node.go \
type Node = *OldNode
'
: # It should work to do this ex in ir, but it misses test files, due to a bug in rf.
: # Run the command in gc to handle gc's tests, and then again in ssa for ssa's tests.
cd ../gc
rf '
ex . ../arm ../riscv64 ../arm64 ../mips64 ../ppc64 ../mips ../wasm {
import "cmd/compile/internal/ir"
*ir.OldNode -> ir.Node
}
'
cd ../ssa
rf '
ex {
import "cmd/compile/internal/ir"
*ir.OldNode -> ir.Node
}
'
: # Back in ir, finish conversion clumsily with sed,
: # because type checking and circular aliases do not mix.
cd ../ir
sed -i '' '
/type Node = \*OldNode/d
s/\*OldNode/Node/g
s/^func (n Node)/func (n *OldNode)/
s/OldNode/node/g
s/type INode interface/type Node interface/
s/var _ INode = (Node)(nil)/var _ Node = (*node)(nil)/
' *.go
gofmt -w *.go
sed -i '' '
s/{Func{}, 136, 248}/{Func{}, 152, 280}/
s/{Name{}, 32, 56}/{Name{}, 44, 80}/
s/{Param{}, 24, 48}/{Param{}, 44, 88}/
s/{node{}, 76, 128}/{node{}, 88, 152}/
' sizeof_test.go
cd ../ssa
sed -i '' '
s/{LocalSlot{}, 28, 40}/{LocalSlot{}, 32, 48}/
' sizeof_test.go
cd ../gc
sed -i '' 's/\*ir.Node/ir.Node/' mkbuiltin.go
cd ../../../..
go install std cmd
cd cmd/compile
go test -u || go test -u
Change-Id: I196bbe3b648e4701662e4a2bada40bf155e2a553
Reviewed-on: https://go-review.googlesource.com/c/go/+/272935
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2020-11-25 01:11:56 -05:00
|
|
|
return []ir.Node{mkcall("block", nil, nil)}
|
2015-02-13 14:40:36 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
// optimization: one-case select: single op.
|
2020-07-27 16:19:15 -07:00
|
|
|
if ncas == 1 {
|
[dev.regabi] cmd/compile: cleanup for concrete types - range, select, swt
An automated rewrite will add concrete type assertions after
a test of n.Op(), when n can be safely type-asserted
(meaning, n is not reassigned a different type, n is not reassigned
and then used outside the scope of the type assertion,
and so on).
This sequence of CLs handles the code that the automated
rewrite does not: adding specific types to function arguments,
adjusting code not to call n.Left() etc when n may have multiple
representations, and so on.
This CL focuses on range.go, select.go, and swt.go: the big
control structures.
Passes buildall w/ toolstash -cmp.
Change-Id: I033fe056a7b815edb6e8a06f45c12ffd990f4d45
Reviewed-on: https://go-review.googlesource.com/c/go/+/277929
Trust: Russ Cox <rsc@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2020-12-10 18:47:32 -05:00
|
|
|
cas := cases.First().(*ir.CaseStmt)
|
2015-02-13 14:40:36 -05:00
|
|
|
setlineno(cas)
|
2020-11-22 09:59:15 -05:00
|
|
|
l := cas.Init().Slice()
|
|
|
|
if cas.Left() != nil { // not default:
|
|
|
|
n := cas.Left()
|
|
|
|
l = append(l, n.Init().Slice()...)
|
|
|
|
n.PtrInit().Set(nil)
|
|
|
|
switch n.Op() {
|
2015-02-13 14:40:36 -05:00
|
|
|
default:
|
2020-11-22 09:59:15 -05:00
|
|
|
base.Fatalf("select %v", n.Op())
|
2015-02-13 14:40:36 -05:00
|
|
|
|
[dev.regabi] cmd/compile: introduce cmd/compile/internal/ir [generated]
If we want to break up package gc at all, we will need to move
the compiler IR it defines into a separate package that can be
imported by packages that gc itself imports. This CL does that.
It also removes the TINT8 etc aliases so that all code is clear
about which package things are coming from.
This CL is automatically generated by the script below.
See the comments in the script for details about the changes.
[git-generate]
cd src/cmd/compile/internal/gc
rf '
# These names were never fully qualified
# when the types package was added.
# Do it now, to avoid confusion about where they live.
inline -rm \
Txxx \
TINT8 \
TUINT8 \
TINT16 \
TUINT16 \
TINT32 \
TUINT32 \
TINT64 \
TUINT64 \
TINT \
TUINT \
TUINTPTR \
TCOMPLEX64 \
TCOMPLEX128 \
TFLOAT32 \
TFLOAT64 \
TBOOL \
TPTR \
TFUNC \
TSLICE \
TARRAY \
TSTRUCT \
TCHAN \
TMAP \
TINTER \
TFORW \
TANY \
TSTRING \
TUNSAFEPTR \
TIDEAL \
TNIL \
TBLANK \
TFUNCARGS \
TCHANARGS \
NTYPE \
BADWIDTH
# esc.go and escape.go do not need to be split.
# Append esc.go onto the end of escape.go.
mv esc.go escape.go
# Pull out the type format installation from func Main,
# so it can be carried into package ir.
mv Main:/Sconv.=/-0,/TypeLinkSym/-1 InstallTypeFormats
# Names that need to be exported for use by code left in gc.
mv Isconst IsConst
mv asNode AsNode
mv asNodes AsNodes
mv asTypesNode AsTypesNode
mv basicnames BasicTypeNames
mv builtinpkg BuiltinPkg
mv consttype ConstType
mv dumplist DumpList
mv fdumplist FDumpList
mv fmtMode FmtMode
mv goopnames OpNames
mv inspect Inspect
mv inspectList InspectList
mv localpkg LocalPkg
mv nblank BlankNode
mv numImport NumImport
mv opprec OpPrec
mv origSym OrigSym
mv stmtwithinit StmtWithInit
mv dump DumpAny
mv fdump FDumpAny
mv nod Nod
mv nodl NodAt
mv newname NewName
mv newnamel NewNameAt
mv assertRepresents AssertValidTypeForConst
mv represents ValidTypeForConst
mv nodlit NewLiteral
# Types and fields that need to be exported for use by gc.
mv nowritebarrierrecCallSym SymAndPos
mv SymAndPos.lineno SymAndPos.Pos
mv SymAndPos.target SymAndPos.Sym
mv Func.lsym Func.LSym
mv Func.setWBPos Func.SetWBPos
mv Func.numReturns Func.NumReturns
mv Func.numDefers Func.NumDefers
mv Func.nwbrCalls Func.NWBRCalls
# initLSym is an algorithm left behind in gc,
# not an operation on Func itself.
mv Func.initLSym initLSym
mv nodeQueue NodeQueue
mv NodeQueue.empty NodeQueue.Empty
mv NodeQueue.popLeft NodeQueue.PopLeft
mv NodeQueue.pushRight NodeQueue.PushRight
# Many methods on Node are actually algorithms that
# would apply to any node implementation.
# Those become plain functions.
mv Node.funcname FuncName
mv Node.isBlank IsBlank
mv Node.isGoConst isGoConst
mv Node.isNil IsNil
mv Node.isParamHeapCopy isParamHeapCopy
mv Node.isParamStackCopy isParamStackCopy
mv Node.isSimpleName isSimpleName
mv Node.mayBeShared MayBeShared
mv Node.pkgFuncName PkgFuncName
mv Node.backingArrayPtrLen backingArrayPtrLen
mv Node.isterminating isTermNode
mv Node.labeledControl labeledControl
mv Nodes.isterminating isTermNodes
mv Nodes.sigerr fmtSignature
mv Node.MethodName methodExprName
mv Node.MethodFunc methodExprFunc
mv Node.IsMethod IsMethod
# Every node will need to implement RawCopy;
# Copy and SepCopy algorithms will use it.
mv Node.rawcopy Node.RawCopy
mv Node.copy Copy
mv Node.sepcopy SepCopy
# Extract Node.Format method body into func FmtNode,
# but leave method wrapper behind.
mv Node.Format:0,$ FmtNode
# Formatting helpers that will apply to all node implementations.
mv Node.Line Line
mv Node.exprfmt exprFmt
mv Node.jconv jconvFmt
mv Node.modeString modeString
mv Node.nconv nconvFmt
mv Node.nodedump nodeDumpFmt
mv Node.nodefmt nodeFmt
mv Node.stmtfmt stmtFmt
# Constant support needed for code moving to ir.
mv okforconst OKForConst
mv vconv FmtConst
mv int64Val Int64Val
mv float64Val Float64Val
mv Node.ValueInterface ConstValue
# Organize code into files.
mv LocalPkg BuiltinPkg ir.go
mv NumImport InstallTypeFormats Line fmt.go
mv syntax.go Nod NodAt NewNameAt Class Pxxx PragmaFlag Nointerface SymAndPos \
AsNode AsTypesNode BlankNode OrigSym \
Node.SliceBounds Node.SetSliceBounds Op.IsSlice3 \
IsConst Node.Int64Val Node.CanInt64 Node.Uint64Val Node.BoolVal Node.StringVal \
Node.RawCopy SepCopy Copy \
IsNil IsBlank IsMethod \
Node.Typ Node.StorageClass node.go
mv ConstType ConstValue Int64Val Float64Val AssertValidTypeForConst ValidTypeForConst NewLiteral idealType OKForConst val.go
# Move files to new ir package.
mv bitset.go class_string.go dump.go fmt.go \
ir.go node.go op_string.go val.go \
sizeof_test.go cmd/compile/internal/ir
'
: # fix mkbuiltin.go to generate the changes made to builtin.go during rf
sed -i '' '
s/\[T/[types.T/g
s/\*Node/*ir.Node/g
/internal\/types/c \
fmt.Fprintln(&b, `import (`) \
fmt.Fprintln(&b, ` "cmd/compile/internal/ir"`) \
fmt.Fprintln(&b, ` "cmd/compile/internal/types"`) \
fmt.Fprintln(&b, `)`)
' mkbuiltin.go
gofmt -w mkbuiltin.go
: # update cmd/dist to add internal/ir
cd ../../../dist
sed -i '' '/compile.internal.gc/a\
"cmd/compile/internal/ir",
' buildtool.go
gofmt -w buildtool.go
: # update cmd/compile TestFormats
cd ../..
go install std cmd
cd cmd/compile
go test -u || go test # first one updates but fails; second passes
Change-Id: I5f7caf6b20629b51970279e81231a3574d5b51db
Reviewed-on: https://go-review.googlesource.com/c/go/+/273008
Trust: Russ Cox <rsc@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2020-11-19 21:09:22 -05:00
|
|
|
case ir.OSEND:
|
2020-07-27 16:45:48 -07:00
|
|
|
// already ok
|
2015-02-13 14:40:36 -05:00
|
|
|
|
[dev.regabi] cmd/compile: clean up in preparation for statement Nodes
Using statement nodes restricts the set of valid SetOp operations,
because you can't SetOp across representation. Rewrite various
code to avoid crossing those as-yet-unintroduced boundaries.
In particular, code like
x, y := v.(T)
x, y := f()
x, y := m[k]
x, y := <-c
starts out with Op = OAS2, and then it turns into a specific Op
OAS2DOTTYPE, OAS2FUNC, OAS2MAPR, OAS2RECV, and then
later in walk is lowered to an OAS2 again.
In the middle, the specific forms move the right-hand side from
n.Rlist().First() to n.Right(), and then the conversion to OAS2 moves
it back. This is unnecessary and makes it hard for these all to
share an underlying Node implementation.
This CL changes these specific forms to leave the right-hand side
in n.Rlist().First().
Similarly, OSELRECV2 is really just a temporary form of OAS2.
This CL changes it to use same fields too.
Finally, this CL fixes the printing of OAS2 nodes in ir/fmt.go,
which formerly printed n.Right() instead of n.Rlist().
This results in a (correct!) update to cmd/compile/internal/logopt's
expected output: ~R0 = <N> becomes ~R0 = &y.b.
Passes buildall w/ toolstash -cmp.
Change-Id: I164aa2e17dc55bfb292024de53d7d250192ad64a
Reviewed-on: https://go-review.googlesource.com/c/go/+/274105
Trust: Russ Cox <rsc@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2020-11-28 15:28:18 -05:00
|
|
|
case ir.OSELRECV2:
|
[dev.regabi] cmd/compile: cleanup for concrete types - range, select, swt
An automated rewrite will add concrete type assertions after
a test of n.Op(), when n can be safely type-asserted
(meaning, n is not reassigned a different type, n is not reassigned
and then used outside the scope of the type assertion,
and so on).
This sequence of CLs handles the code that the automated
rewrite does not: adding specific types to function arguments,
adjusting code not to call n.Left() etc when n may have multiple
representations, and so on.
This CL focuses on range.go, select.go, and swt.go: the big
control structures.
Passes buildall w/ toolstash -cmp.
Change-Id: I033fe056a7b815edb6e8a06f45c12ffd990f4d45
Reviewed-on: https://go-review.googlesource.com/c/go/+/277929
Trust: Russ Cox <rsc@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2020-12-10 18:47:32 -05:00
|
|
|
r := n.(*ir.AssignListStmt)
|
|
|
|
if ir.IsBlank(r.List().First()) && ir.IsBlank(r.List().Second()) {
|
|
|
|
n = r.Rlist().First()
|
[dev.regabi] cmd/compile: clean up in preparation for statement Nodes
Using statement nodes restricts the set of valid SetOp operations,
because you can't SetOp across representation. Rewrite various
code to avoid crossing those as-yet-unintroduced boundaries.
In particular, code like
x, y := v.(T)
x, y := f()
x, y := m[k]
x, y := <-c
starts out with Op = OAS2, and then it turns into a specific Op
OAS2DOTTYPE, OAS2FUNC, OAS2MAPR, OAS2RECV, and then
later in walk is lowered to an OAS2 again.
In the middle, the specific forms move the right-hand side from
n.Rlist().First() to n.Right(), and then the conversion to OAS2 moves
it back. This is unnecessary and makes it hard for these all to
share an underlying Node implementation.
This CL changes these specific forms to leave the right-hand side
in n.Rlist().First().
Similarly, OSELRECV2 is really just a temporary form of OAS2.
This CL changes it to use same fields too.
Finally, this CL fixes the printing of OAS2 nodes in ir/fmt.go,
which formerly printed n.Right() instead of n.Rlist().
This results in a (correct!) update to cmd/compile/internal/logopt's
expected output: ~R0 = <N> becomes ~R0 = &y.b.
Passes buildall w/ toolstash -cmp.
Change-Id: I164aa2e17dc55bfb292024de53d7d250192ad64a
Reviewed-on: https://go-review.googlesource.com/c/go/+/274105
Trust: Russ Cox <rsc@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2020-11-28 15:28:18 -05:00
|
|
|
break
|
2015-02-13 14:40:36 -05:00
|
|
|
}
|
[dev.regabi] cmd/compile: cleanup for concrete types - range, select, swt
An automated rewrite will add concrete type assertions after
a test of n.Op(), when n can be safely type-asserted
(meaning, n is not reassigned a different type, n is not reassigned
and then used outside the scope of the type assertion,
and so on).
This sequence of CLs handles the code that the automated
rewrite does not: adding specific types to function arguments,
adjusting code not to call n.Left() etc when n may have multiple
representations, and so on.
This CL focuses on range.go, select.go, and swt.go: the big
control structures.
Passes buildall w/ toolstash -cmp.
Change-Id: I033fe056a7b815edb6e8a06f45c12ffd990f4d45
Reviewed-on: https://go-review.googlesource.com/c/go/+/277929
Trust: Russ Cox <rsc@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2020-12-10 18:47:32 -05:00
|
|
|
r.SetOp(ir.OAS2RECV)
|
2015-02-13 14:40:36 -05:00
|
|
|
}
|
|
|
|
|
2020-07-27 16:45:48 -07:00
|
|
|
l = append(l, n)
|
2015-02-13 14:40:36 -05:00
|
|
|
}
|
|
|
|
|
2020-11-22 09:59:15 -05:00
|
|
|
l = append(l, cas.Body().Slice()...)
|
[dev.regabi] cmd/compile: remove ir.Nod [generated]
Rewrite all uses of ir.Nod and friends to call the IR constructors directly.
This gives the results a more specific type and will play nicely with
introduction of more specific types throughout the code in a followup CL.
Passes buildall w/ toolstash -cmp.
[git-generate]
cd src/cmd/compile/internal/gc
rf '
ex . ../ir {
import "cmd/compile/internal/ir"
import "cmd/compile/internal/types"
import "cmd/compile/internal/syntax"
import "cmd/internal/src"
var p *noder
var orig syntax.Node
var op ir.Op
var l, r ir.Node
var sym *types.Sym
p.nod(orig, op, l, r) -> ir.NodAt(p.pos(orig), op, l, r)
p.nodSym(orig, op, l, sym) -> nodlSym(p.pos(orig), op, l, sym)
var xpos src.XPos
var ns ir.Nodes
npos(xpos, nodSym(op, l, sym)) -> nodlSym(xpos, op, l, sym)
npos(xpos, liststmt(ns)) -> ir.NewBlockStmt(xpos, ns)
}
ex . ../ir {
import "cmd/compile/internal/base"
import "cmd/compile/internal/ir"
import "cmd/compile/internal/types"
var op ir.Op
var l, r ir.Node
ir.Nod(op, l, r) -> ir.NodAt(base.Pos, op, l, r)
var sym *types.Sym
nodSym(op, l, sym) -> nodlSym(base.Pos, op, l, sym)
}
ex . ../ir {
import "cmd/compile/internal/ir"
import "cmd/internal/src"
# rf overlapping match handling is not quite good enough
# for certain nested rewrites, so handle these two - which often contain other ir.NodAt calls - early.
var l, r ir.Node
var xpos src.XPos
ir.NodAt(xpos, ir.OAS, l, r) -> ir.NewAssignStmt(xpos, l, r)
ir.NodAt(xpos, ir.OIF, l, nil) -> ir.NewIfStmt(xpos, l, nil, nil)
}
ex . ../ir {
import "cmd/compile/internal/ir"
import "cmd/compile/internal/types"
import "cmd/internal/src"
var l, r ir.Node
var sym *types.Sym
var xpos src.XPos
nodlSym(xpos, ir.ODOT, l, sym) -> ir.NewSelectorExpr(xpos, ir.ODOT, l, sym)
nodlSym(xpos, ir.OXDOT, l, sym) -> ir.NewSelectorExpr(xpos, ir.OXDOT, l, sym)
nodlSym(xpos, ir.ODOTPTR, l, sym) -> ir.NewSelectorExpr(xpos, ir.ODOTPTR, l, sym)
nodlSym(xpos, ir.OGOTO, nil, sym) -> ir.NewBranchStmt(xpos, ir.OGOTO, sym)
nodlSym(xpos, ir.ORETJMP, nil, sym) -> ir.NewBranchStmt(xpos, ir.ORETJMP, sym)
nodlSym(xpos, ir.OLABEL, nil, sym) -> ir.NewLabelStmt(xpos, sym)
nodlSym(xpos, ir.OSTRUCTKEY, l, sym) -> ir.NewStructKeyExpr(xpos, sym, l)
ir.NodAt(xpos, ir.OADD, l, r) -> ir.NewBinaryExpr(xpos, ir.OADD, l, r)
ir.NodAt(xpos, ir.OAND, l, r) -> ir.NewBinaryExpr(xpos, ir.OAND, l, r)
ir.NodAt(xpos, ir.OANDNOT, l, r) -> ir.NewBinaryExpr(xpos, ir.OANDNOT, l, r)
ir.NodAt(xpos, ir.ODIV, l, r) -> ir.NewBinaryExpr(xpos, ir.ODIV, l, r)
ir.NodAt(xpos, ir.OEQ, l, r) -> ir.NewBinaryExpr(xpos, ir.OEQ, l, r)
ir.NodAt(xpos, ir.OGE, l, r) -> ir.NewBinaryExpr(xpos, ir.OGE, l, r)
ir.NodAt(xpos, ir.OGT, l, r) -> ir.NewBinaryExpr(xpos, ir.OGT, l, r)
ir.NodAt(xpos, ir.OLE, l, r) -> ir.NewBinaryExpr(xpos, ir.OLE, l, r)
ir.NodAt(xpos, ir.OLSH, l, r) -> ir.NewBinaryExpr(xpos, ir.OLSH, l, r)
ir.NodAt(xpos, ir.OLT, l, r) -> ir.NewBinaryExpr(xpos, ir.OLT, l, r)
ir.NodAt(xpos, ir.OMOD, l, r) -> ir.NewBinaryExpr(xpos, ir.OMOD, l, r)
ir.NodAt(xpos, ir.OMUL, l, r) -> ir.NewBinaryExpr(xpos, ir.OMUL, l, r)
ir.NodAt(xpos, ir.ONE, l, r) -> ir.NewBinaryExpr(xpos, ir.ONE, l, r)
ir.NodAt(xpos, ir.OOR, l, r) -> ir.NewBinaryExpr(xpos, ir.OOR, l, r)
ir.NodAt(xpos, ir.ORSH, l, r) -> ir.NewBinaryExpr(xpos, ir.ORSH, l, r)
ir.NodAt(xpos, ir.OSUB, l, r) -> ir.NewBinaryExpr(xpos, ir.OSUB, l, r)
ir.NodAt(xpos, ir.OXOR, l, r) -> ir.NewBinaryExpr(xpos, ir.OXOR, l, r)
ir.NodAt(xpos, ir.OCOPY, l, r) -> ir.NewBinaryExpr(xpos, ir.OCOPY, l, r)
ir.NodAt(xpos, ir.OCOMPLEX, l, r) -> ir.NewBinaryExpr(xpos, ir.OCOMPLEX, l, r)
ir.NodAt(xpos, ir.OEFACE, l, r) -> ir.NewBinaryExpr(xpos, ir.OEFACE, l, r)
ir.NodAt(xpos, ir.OADDR, l, nil) -> ir.NewAddrExpr(xpos, l)
ir.NodAt(xpos, ir.OADDSTR, nil, nil) -> ir.NewAddStringExpr(xpos, nil)
ir.NodAt(xpos, ir.OANDAND, l, r) -> ir.NewLogicalExpr(xpos, ir.OANDAND, l, r)
ir.NodAt(xpos, ir.OOROR, l, r) -> ir.NewLogicalExpr(xpos, ir.OOROR, l, r)
ir.NodAt(xpos, ir.OARRAYLIT, nil, nil) -> ir.NewCompLitExpr(xpos, ir.OARRAYLIT, nil, nil)
ir.NodAt(xpos, ir.OCOMPLIT, nil, nil) -> ir.NewCompLitExpr(xpos, ir.OCOMPLIT, nil, nil)
ir.NodAt(xpos, ir.OMAPLIT, nil, nil) -> ir.NewCompLitExpr(xpos, ir.OMAPLIT, nil, nil)
ir.NodAt(xpos, ir.OSTRUCTLIT, nil, nil) -> ir.NewCompLitExpr(xpos, ir.OSTRUCTLIT, nil, nil)
ir.NodAt(xpos, ir.OSLICELIT, nil, nil) -> ir.NewCompLitExpr(xpos, ir.OSLICELIT, nil, nil)
ir.NodAt(xpos, ir.OARRAYLIT, nil, r) -> ir.NewCompLitExpr(xpos, ir.OARRAYLIT, r.(ir.Ntype), nil)
ir.NodAt(xpos, ir.OCOMPLIT, nil, r) -> ir.NewCompLitExpr(xpos, ir.OCOMPLIT, r.(ir.Ntype), nil)
ir.NodAt(xpos, ir.OMAPLIT, nil, r) -> ir.NewCompLitExpr(xpos, ir.OMAPLIT, r.(ir.Ntype), nil)
ir.NodAt(xpos, ir.OSTRUCTLIT, nil, r) -> ir.NewCompLitExpr(xpos, ir.OSTRUCTLIT, r.(ir.Ntype), nil)
ir.NodAt(xpos, ir.OSLICELIT, nil, r) -> ir.NewCompLitExpr(xpos, ir.OSLICELIT, r.(ir.Ntype), nil)
ir.NodAt(xpos, ir.OAS2, nil, nil) -> ir.NewAssignListStmt(xpos, ir.OAS2, nil, nil)
ir.NodAt(xpos, ir.OAS2DOTTYPE, nil, nil) -> ir.NewAssignListStmt(xpos, ir.OAS2DOTTYPE, nil, nil)
ir.NodAt(xpos, ir.OAS2FUNC, nil, nil) -> ir.NewAssignListStmt(xpos, ir.OAS2FUNC, nil, nil)
ir.NodAt(xpos, ir.OAS2MAPR, nil, nil) -> ir.NewAssignListStmt(xpos, ir.OAS2MAPR, nil, nil)
ir.NodAt(xpos, ir.OAS2RECV, nil, nil) -> ir.NewAssignListStmt(xpos, ir.OAS2RECV, nil, nil)
ir.NodAt(xpos, ir.OSELRECV2, nil, nil) -> ir.NewAssignListStmt(xpos, ir.OSELRECV2, nil, nil)
ir.NodAt(xpos, ir.OASOP, l, r) -> ir.NewAssignOpStmt(xpos, ir.OXXX, l, r)
ir.NodAt(xpos, ir.OBITNOT, l, nil) -> ir.NewUnaryExpr(xpos, ir.OBITNOT, l)
ir.NodAt(xpos, ir.ONEG, l, nil) -> ir.NewUnaryExpr(xpos, ir.ONEG, l)
ir.NodAt(xpos, ir.ONOT, l, nil) -> ir.NewUnaryExpr(xpos, ir.ONOT, l)
ir.NodAt(xpos, ir.OPLUS, l, nil) -> ir.NewUnaryExpr(xpos, ir.OPLUS, l)
ir.NodAt(xpos, ir.ORECV, l, nil) -> ir.NewUnaryExpr(xpos, ir.ORECV, l)
ir.NodAt(xpos, ir.OALIGNOF, l, nil) -> ir.NewUnaryExpr(xpos, ir.OALIGNOF, l)
ir.NodAt(xpos, ir.OCAP, l, nil) -> ir.NewUnaryExpr(xpos, ir.OCAP, l)
ir.NodAt(xpos, ir.OCLOSE, l, nil) -> ir.NewUnaryExpr(xpos, ir.OCLOSE, l)
ir.NodAt(xpos, ir.OIMAG, l, nil) -> ir.NewUnaryExpr(xpos, ir.OIMAG, l)
ir.NodAt(xpos, ir.OLEN, l, nil) -> ir.NewUnaryExpr(xpos, ir.OLEN, l)
ir.NodAt(xpos, ir.ONEW, l, nil) -> ir.NewUnaryExpr(xpos, ir.ONEW, l)
ir.NodAt(xpos, ir.ONEWOBJ, l, nil) -> ir.NewUnaryExpr(xpos, ir.ONEWOBJ, l)
ir.NodAt(xpos, ir.OOFFSETOF, l, nil) -> ir.NewUnaryExpr(xpos, ir.OOFFSETOF, l)
ir.NodAt(xpos, ir.OPANIC, l, nil) -> ir.NewUnaryExpr(xpos, ir.OPANIC, l)
ir.NodAt(xpos, ir.OREAL, l, nil) -> ir.NewUnaryExpr(xpos, ir.OREAL, l)
ir.NodAt(xpos, ir.OSIZEOF, l, nil) -> ir.NewUnaryExpr(xpos, ir.OSIZEOF, l)
ir.NodAt(xpos, ir.OCHECKNIL, l, nil) -> ir.NewUnaryExpr(xpos, ir.OCHECKNIL, l)
ir.NodAt(xpos, ir.OCFUNC, l, nil) -> ir.NewUnaryExpr(xpos, ir.OCFUNC, l)
ir.NodAt(xpos, ir.OIDATA, l, nil) -> ir.NewUnaryExpr(xpos, ir.OIDATA, l)
ir.NodAt(xpos, ir.OITAB, l, nil) -> ir.NewUnaryExpr(xpos, ir.OITAB, l)
ir.NodAt(xpos, ir.OSPTR, l, nil) -> ir.NewUnaryExpr(xpos, ir.OSPTR, l)
ir.NodAt(xpos, ir.OVARDEF, l, nil) -> ir.NewUnaryExpr(xpos, ir.OVARDEF, l)
ir.NodAt(xpos, ir.OVARKILL, l, nil) -> ir.NewUnaryExpr(xpos, ir.OVARKILL, l)
ir.NodAt(xpos, ir.OVARLIVE, l, nil) -> ir.NewUnaryExpr(xpos, ir.OVARLIVE, l)
ir.NodAt(xpos, ir.OBLOCK, nil, nil) -> ir.NewBlockStmt(xpos, nil)
ir.NodAt(xpos, ir.OBREAK, nil, nil) -> ir.NewBranchStmt(xpos, ir.OBREAK, nil)
ir.NodAt(xpos, ir.OCONTINUE, nil, nil) -> ir.NewBranchStmt(xpos, ir.OCONTINUE, nil)
ir.NodAt(xpos, ir.OFALL, nil, nil) -> ir.NewBranchStmt(xpos, ir.OFALL, nil)
ir.NodAt(xpos, ir.OGOTO, nil, nil) -> ir.NewBranchStmt(xpos, ir.OGOTO, nil)
ir.NodAt(xpos, ir.ORETJMP, nil, nil) -> ir.NewBranchStmt(xpos, ir.ORETJMP, nil)
ir.NodAt(xpos, ir.OCALL, l, nil) -> ir.NewCallExpr(xpos, ir.OCALL, l, nil)
ir.NodAt(xpos, ir.OCALLFUNC, l, nil) -> ir.NewCallExpr(xpos, ir.OCALLFUNC, l, nil)
ir.NodAt(xpos, ir.OCALLINTER, l, nil) -> ir.NewCallExpr(xpos, ir.OCALLINTER, l, nil)
ir.NodAt(xpos, ir.OCALLMETH, l, nil) -> ir.NewCallExpr(xpos, ir.OCALLMETH, l, nil)
ir.NodAt(xpos, ir.OAPPEND, l, nil) -> ir.NewCallExpr(xpos, ir.OAPPEND, l, nil)
ir.NodAt(xpos, ir.ODELETE, l, nil) -> ir.NewCallExpr(xpos, ir.ODELETE, l, nil)
ir.NodAt(xpos, ir.OGETG, l, nil) -> ir.NewCallExpr(xpos, ir.OGETG, l, nil)
ir.NodAt(xpos, ir.OMAKE, l, nil) -> ir.NewCallExpr(xpos, ir.OMAKE, l, nil)
ir.NodAt(xpos, ir.OPRINT, l, nil) -> ir.NewCallExpr(xpos, ir.OPRINT, l, nil)
ir.NodAt(xpos, ir.OPRINTN, l, nil) -> ir.NewCallExpr(xpos, ir.OPRINTN, l, nil)
ir.NodAt(xpos, ir.ORECOVER, l, nil) -> ir.NewCallExpr(xpos, ir.ORECOVER, l, nil)
ir.NodAt(xpos, ir.OCASE, nil, nil) -> ir.NewCaseStmt(xpos, nil, nil)
ir.NodAt(xpos, ir.OCONV, l, nil) -> ir.NewConvExpr(xpos, ir.OCONV, nil, l)
ir.NodAt(xpos, ir.OCONVIFACE, l, nil) -> ir.NewConvExpr(xpos, ir.OCONVIFACE, nil, l)
ir.NodAt(xpos, ir.OCONVNOP, l, nil) -> ir.NewConvExpr(xpos, ir.OCONVNOP, nil, l)
ir.NodAt(xpos, ir.ORUNESTR, l, nil) -> ir.NewConvExpr(xpos, ir.ORUNESTR, nil, l)
ir.NodAt(xpos, ir.ODCL, l, nil) -> ir.NewDecl(xpos, ir.ODCL, l)
ir.NodAt(xpos, ir.ODCLCONST, l, nil) -> ir.NewDecl(xpos, ir.ODCLCONST, l)
ir.NodAt(xpos, ir.ODCLTYPE, l, nil) -> ir.NewDecl(xpos, ir.ODCLTYPE, l)
ir.NodAt(xpos, ir.ODCLFUNC, nil, nil) -> ir.NewFunc(xpos)
ir.NodAt(xpos, ir.ODEFER, l, nil) -> ir.NewGoDeferStmt(xpos, ir.ODEFER, l)
ir.NodAt(xpos, ir.OGO, l, nil) -> ir.NewGoDeferStmt(xpos, ir.OGO, l)
ir.NodAt(xpos, ir.ODEREF, l, nil) -> ir.NewStarExpr(xpos, l)
ir.NodAt(xpos, ir.ODOT, l, nil) -> ir.NewSelectorExpr(xpos, ir.ODOT, l, nil)
ir.NodAt(xpos, ir.ODOTPTR, l, nil) -> ir.NewSelectorExpr(xpos, ir.ODOTPTR, l, nil)
ir.NodAt(xpos, ir.ODOTMETH, l, nil) -> ir.NewSelectorExpr(xpos, ir.ODOTMETH, l, nil)
ir.NodAt(xpos, ir.ODOTINTER, l, nil) -> ir.NewSelectorExpr(xpos, ir.ODOTINTER, l, nil)
ir.NodAt(xpos, ir.OXDOT, l, nil) -> ir.NewSelectorExpr(xpos, ir.OXDOT, l, nil)
ir.NodAt(xpos, ir.ODOTTYPE, l, nil) -> ir.NewTypeAssertExpr(xpos, l, nil)
ir.NodAt(xpos, ir.ODOTTYPE, l, r) -> ir.NewTypeAssertExpr(xpos, l, r.(ir.Ntype))
ir.NodAt(xpos, ir.OFOR, l, r) -> ir.NewForStmt(xpos, nil, l, r, nil)
ir.NodAt(xpos, ir.OINDEX, l, r) -> ir.NewIndexExpr(xpos, l, r)
ir.NodAt(xpos, ir.OINLMARK, nil, nil) -> ir.NewInlineMarkStmt(xpos, types.BADWIDTH)
ir.NodAt(xpos, ir.OKEY, l, r) -> ir.NewKeyExpr(xpos, l, r)
ir.NodAt(xpos, ir.OLABEL, nil, nil) -> ir.NewLabelStmt(xpos, nil)
ir.NodAt(xpos, ir.OMAKECHAN, l, r) -> ir.NewMakeExpr(xpos, ir.OMAKECHAN, l, r)
ir.NodAt(xpos, ir.OMAKEMAP, l, r) -> ir.NewMakeExpr(xpos, ir.OMAKEMAP, l, r)
ir.NodAt(xpos, ir.OMAKESLICE, l, r) -> ir.NewMakeExpr(xpos, ir.OMAKESLICE, l, r)
ir.NodAt(xpos, ir.OMAKESLICECOPY, l, r) -> ir.NewMakeExpr(xpos, ir.OMAKESLICECOPY, l, r)
ir.NodAt(xpos, ir.ONIL, nil, nil) -> ir.NewNilExpr(xpos)
ir.NodAt(xpos, ir.OPACK, nil, nil) -> ir.NewPkgName(xpos, nil, nil)
ir.NodAt(xpos, ir.OPAREN, l, nil) -> ir.NewParenExpr(xpos, l)
ir.NodAt(xpos, ir.ORANGE, nil, r) -> ir.NewRangeStmt(xpos, nil, r, nil)
ir.NodAt(xpos, ir.ORESULT, nil, nil) -> ir.NewResultExpr(xpos, nil, types.BADWIDTH)
ir.NodAt(xpos, ir.ORETURN, nil, nil) -> ir.NewReturnStmt(xpos, nil)
ir.NodAt(xpos, ir.OSELECT, nil, nil) -> ir.NewSelectStmt(xpos, nil)
ir.NodAt(xpos, ir.OSEND, l, r) -> ir.NewSendStmt(xpos, l, r)
ir.NodAt(xpos, ir.OSLICE, l, nil) -> ir.NewSliceExpr(xpos, ir.OSLICE, l)
ir.NodAt(xpos, ir.OSLICEARR, l, nil) -> ir.NewSliceExpr(xpos, ir.OSLICEARR, l)
ir.NodAt(xpos, ir.OSLICESTR, l, nil) -> ir.NewSliceExpr(xpos, ir.OSLICESTR, l)
ir.NodAt(xpos, ir.OSLICE3, l, nil) -> ir.NewSliceExpr(xpos, ir.OSLICE3, l)
ir.NodAt(xpos, ir.OSLICE3ARR, l, nil) -> ir.NewSliceExpr(xpos, ir.OSLICE3ARR, l)
ir.NodAt(xpos, ir.OSLICEHEADER, l, nil) -> ir.NewSliceHeaderExpr(xpos, nil, l, nil, nil)
ir.NodAt(xpos, ir.OSWITCH, l, nil) -> ir.NewSwitchStmt(xpos, l, nil)
ir.NodAt(xpos, ir.OINLCALL, nil, nil) -> ir.NewInlinedCallExpr(xpos, nil, nil)
}
rm noder.nod noder.nodSym nodSym nodlSym ir.NodAt ir.Nod
'
Change-Id: Ibf1eb708de8463ae74ccc47d7966cc263a18295e
Reviewed-on: https://go-review.googlesource.com/c/go/+/277933
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2020-12-22 23:55:29 -05:00
|
|
|
l = append(l, ir.NewBranchStmt(base.Pos, ir.OBREAK, nil))
|
2017-10-22 17:18:51 +01:00
|
|
|
return l
|
2015-02-13 14:40:36 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
// convert case value arguments to addresses.
|
|
|
|
// this rewrite is used by both the general code and the next optimization.
|
[dev.regabi] cmd/compile: cleanup for concrete types - range, select, swt
An automated rewrite will add concrete type assertions after
a test of n.Op(), when n can be safely type-asserted
(meaning, n is not reassigned a different type, n is not reassigned
and then used outside the scope of the type assertion,
and so on).
This sequence of CLs handles the code that the automated
rewrite does not: adding specific types to function arguments,
adjusting code not to call n.Left() etc when n may have multiple
representations, and so on.
This CL focuses on range.go, select.go, and swt.go: the big
control structures.
Passes buildall w/ toolstash -cmp.
Change-Id: I033fe056a7b815edb6e8a06f45c12ffd990f4d45
Reviewed-on: https://go-review.googlesource.com/c/go/+/277929
Trust: Russ Cox <rsc@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2020-12-10 18:47:32 -05:00
|
|
|
var dflt *ir.CaseStmt
|
2017-10-22 17:18:51 +01:00
|
|
|
for _, cas := range cases.Slice() {
|
[dev.regabi] cmd/compile: cleanup for concrete types - range, select, swt
An automated rewrite will add concrete type assertions after
a test of n.Op(), when n can be safely type-asserted
(meaning, n is not reassigned a different type, n is not reassigned
and then used outside the scope of the type assertion,
and so on).
This sequence of CLs handles the code that the automated
rewrite does not: adding specific types to function arguments,
adjusting code not to call n.Left() etc when n may have multiple
representations, and so on.
This CL focuses on range.go, select.go, and swt.go: the big
control structures.
Passes buildall w/ toolstash -cmp.
Change-Id: I033fe056a7b815edb6e8a06f45c12ffd990f4d45
Reviewed-on: https://go-review.googlesource.com/c/go/+/277929
Trust: Russ Cox <rsc@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2020-12-10 18:47:32 -05:00
|
|
|
cas := cas.(*ir.CaseStmt)
|
2015-02-13 14:40:36 -05:00
|
|
|
setlineno(cas)
|
2020-11-22 09:59:15 -05:00
|
|
|
n := cas.Left()
|
2015-02-13 14:40:36 -05:00
|
|
|
if n == nil {
|
2020-07-27 16:19:15 -07:00
|
|
|
dflt = cas
|
2015-02-13 14:40:36 -05:00
|
|
|
continue
|
|
|
|
}
|
2020-11-22 09:59:15 -05:00
|
|
|
switch n.Op() {
|
[dev.regabi] cmd/compile: introduce cmd/compile/internal/ir [generated]
If we want to break up package gc at all, we will need to move
the compiler IR it defines into a separate package that can be
imported by packages that gc itself imports. This CL does that.
It also removes the TINT8 etc aliases so that all code is clear
about which package things are coming from.
This CL is automatically generated by the script below.
See the comments in the script for details about the changes.
[git-generate]
cd src/cmd/compile/internal/gc
rf '
# These names were never fully qualified
# when the types package was added.
# Do it now, to avoid confusion about where they live.
inline -rm \
Txxx \
TINT8 \
TUINT8 \
TINT16 \
TUINT16 \
TINT32 \
TUINT32 \
TINT64 \
TUINT64 \
TINT \
TUINT \
TUINTPTR \
TCOMPLEX64 \
TCOMPLEX128 \
TFLOAT32 \
TFLOAT64 \
TBOOL \
TPTR \
TFUNC \
TSLICE \
TARRAY \
TSTRUCT \
TCHAN \
TMAP \
TINTER \
TFORW \
TANY \
TSTRING \
TUNSAFEPTR \
TIDEAL \
TNIL \
TBLANK \
TFUNCARGS \
TCHANARGS \
NTYPE \
BADWIDTH
# esc.go and escape.go do not need to be split.
# Append esc.go onto the end of escape.go.
mv esc.go escape.go
# Pull out the type format installation from func Main,
# so it can be carried into package ir.
mv Main:/Sconv.=/-0,/TypeLinkSym/-1 InstallTypeFormats
# Names that need to be exported for use by code left in gc.
mv Isconst IsConst
mv asNode AsNode
mv asNodes AsNodes
mv asTypesNode AsTypesNode
mv basicnames BasicTypeNames
mv builtinpkg BuiltinPkg
mv consttype ConstType
mv dumplist DumpList
mv fdumplist FDumpList
mv fmtMode FmtMode
mv goopnames OpNames
mv inspect Inspect
mv inspectList InspectList
mv localpkg LocalPkg
mv nblank BlankNode
mv numImport NumImport
mv opprec OpPrec
mv origSym OrigSym
mv stmtwithinit StmtWithInit
mv dump DumpAny
mv fdump FDumpAny
mv nod Nod
mv nodl NodAt
mv newname NewName
mv newnamel NewNameAt
mv assertRepresents AssertValidTypeForConst
mv represents ValidTypeForConst
mv nodlit NewLiteral
# Types and fields that need to be exported for use by gc.
mv nowritebarrierrecCallSym SymAndPos
mv SymAndPos.lineno SymAndPos.Pos
mv SymAndPos.target SymAndPos.Sym
mv Func.lsym Func.LSym
mv Func.setWBPos Func.SetWBPos
mv Func.numReturns Func.NumReturns
mv Func.numDefers Func.NumDefers
mv Func.nwbrCalls Func.NWBRCalls
# initLSym is an algorithm left behind in gc,
# not an operation on Func itself.
mv Func.initLSym initLSym
mv nodeQueue NodeQueue
mv NodeQueue.empty NodeQueue.Empty
mv NodeQueue.popLeft NodeQueue.PopLeft
mv NodeQueue.pushRight NodeQueue.PushRight
# Many methods on Node are actually algorithms that
# would apply to any node implementation.
# Those become plain functions.
mv Node.funcname FuncName
mv Node.isBlank IsBlank
mv Node.isGoConst isGoConst
mv Node.isNil IsNil
mv Node.isParamHeapCopy isParamHeapCopy
mv Node.isParamStackCopy isParamStackCopy
mv Node.isSimpleName isSimpleName
mv Node.mayBeShared MayBeShared
mv Node.pkgFuncName PkgFuncName
mv Node.backingArrayPtrLen backingArrayPtrLen
mv Node.isterminating isTermNode
mv Node.labeledControl labeledControl
mv Nodes.isterminating isTermNodes
mv Nodes.sigerr fmtSignature
mv Node.MethodName methodExprName
mv Node.MethodFunc methodExprFunc
mv Node.IsMethod IsMethod
# Every node will need to implement RawCopy;
# Copy and SepCopy algorithms will use it.
mv Node.rawcopy Node.RawCopy
mv Node.copy Copy
mv Node.sepcopy SepCopy
# Extract Node.Format method body into func FmtNode,
# but leave method wrapper behind.
mv Node.Format:0,$ FmtNode
# Formatting helpers that will apply to all node implementations.
mv Node.Line Line
mv Node.exprfmt exprFmt
mv Node.jconv jconvFmt
mv Node.modeString modeString
mv Node.nconv nconvFmt
mv Node.nodedump nodeDumpFmt
mv Node.nodefmt nodeFmt
mv Node.stmtfmt stmtFmt
# Constant support needed for code moving to ir.
mv okforconst OKForConst
mv vconv FmtConst
mv int64Val Int64Val
mv float64Val Float64Val
mv Node.ValueInterface ConstValue
# Organize code into files.
mv LocalPkg BuiltinPkg ir.go
mv NumImport InstallTypeFormats Line fmt.go
mv syntax.go Nod NodAt NewNameAt Class Pxxx PragmaFlag Nointerface SymAndPos \
AsNode AsTypesNode BlankNode OrigSym \
Node.SliceBounds Node.SetSliceBounds Op.IsSlice3 \
IsConst Node.Int64Val Node.CanInt64 Node.Uint64Val Node.BoolVal Node.StringVal \
Node.RawCopy SepCopy Copy \
IsNil IsBlank IsMethod \
Node.Typ Node.StorageClass node.go
mv ConstType ConstValue Int64Val Float64Val AssertValidTypeForConst ValidTypeForConst NewLiteral idealType OKForConst val.go
# Move files to new ir package.
mv bitset.go class_string.go dump.go fmt.go \
ir.go node.go op_string.go val.go \
sizeof_test.go cmd/compile/internal/ir
'
: # fix mkbuiltin.go to generate the changes made to builtin.go during rf
sed -i '' '
s/\[T/[types.T/g
s/\*Node/*ir.Node/g
/internal\/types/c \
fmt.Fprintln(&b, `import (`) \
fmt.Fprintln(&b, ` "cmd/compile/internal/ir"`) \
fmt.Fprintln(&b, ` "cmd/compile/internal/types"`) \
fmt.Fprintln(&b, `)`)
' mkbuiltin.go
gofmt -w mkbuiltin.go
: # update cmd/dist to add internal/ir
cd ../../../dist
sed -i '' '/compile.internal.gc/a\
"cmd/compile/internal/ir",
' buildtool.go
gofmt -w buildtool.go
: # update cmd/compile TestFormats
cd ../..
go install std cmd
cd cmd/compile
go test -u || go test # first one updates but fails; second passes
Change-Id: I5f7caf6b20629b51970279e81231a3574d5b51db
Reviewed-on: https://go-review.googlesource.com/c/go/+/273008
Trust: Russ Cox <rsc@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2020-11-19 21:09:22 -05:00
|
|
|
case ir.OSEND:
|
2020-11-28 15:53:32 -08:00
|
|
|
n.SetRight(nodAddr(n.Right()))
|
2020-11-22 09:59:15 -05:00
|
|
|
n.SetRight(typecheck(n.Right(), ctxExpr))
|
2015-02-13 14:40:36 -05:00
|
|
|
|
[dev.regabi] cmd/compile: clean up in preparation for statement Nodes
Using statement nodes restricts the set of valid SetOp operations,
because you can't SetOp across representation. Rewrite various
code to avoid crossing those as-yet-unintroduced boundaries.
In particular, code like
x, y := v.(T)
x, y := f()
x, y := m[k]
x, y := <-c
starts out with Op = OAS2, and then it turns into a specific Op
OAS2DOTTYPE, OAS2FUNC, OAS2MAPR, OAS2RECV, and then
later in walk is lowered to an OAS2 again.
In the middle, the specific forms move the right-hand side from
n.Rlist().First() to n.Right(), and then the conversion to OAS2 moves
it back. This is unnecessary and makes it hard for these all to
share an underlying Node implementation.
This CL changes these specific forms to leave the right-hand side
in n.Rlist().First().
Similarly, OSELRECV2 is really just a temporary form of OAS2.
This CL changes it to use same fields too.
Finally, this CL fixes the printing of OAS2 nodes in ir/fmt.go,
which formerly printed n.Right() instead of n.Rlist().
This results in a (correct!) update to cmd/compile/internal/logopt's
expected output: ~R0 = <N> becomes ~R0 = &y.b.
Passes buildall w/ toolstash -cmp.
Change-Id: I164aa2e17dc55bfb292024de53d7d250192ad64a
Reviewed-on: https://go-review.googlesource.com/c/go/+/274105
Trust: Russ Cox <rsc@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2020-11-28 15:28:18 -05:00
|
|
|
case ir.OSELRECV2:
|
|
|
|
if !ir.IsBlank(n.List().First()) {
|
2020-11-28 15:53:32 -08:00
|
|
|
n.List().SetIndex(0, nodAddr(n.List().First()))
|
[dev.regabi] cmd/compile: clean up in preparation for statement Nodes
Using statement nodes restricts the set of valid SetOp operations,
because you can't SetOp across representation. Rewrite various
code to avoid crossing those as-yet-unintroduced boundaries.
In particular, code like
x, y := v.(T)
x, y := f()
x, y := m[k]
x, y := <-c
starts out with Op = OAS2, and then it turns into a specific Op
OAS2DOTTYPE, OAS2FUNC, OAS2MAPR, OAS2RECV, and then
later in walk is lowered to an OAS2 again.
In the middle, the specific forms move the right-hand side from
n.Rlist().First() to n.Right(), and then the conversion to OAS2 moves
it back. This is unnecessary and makes it hard for these all to
share an underlying Node implementation.
This CL changes these specific forms to leave the right-hand side
in n.Rlist().First().
Similarly, OSELRECV2 is really just a temporary form of OAS2.
This CL changes it to use same fields too.
Finally, this CL fixes the printing of OAS2 nodes in ir/fmt.go,
which formerly printed n.Right() instead of n.Rlist().
This results in a (correct!) update to cmd/compile/internal/logopt's
expected output: ~R0 = <N> becomes ~R0 = &y.b.
Passes buildall w/ toolstash -cmp.
Change-Id: I164aa2e17dc55bfb292024de53d7d250192ad64a
Reviewed-on: https://go-review.googlesource.com/c/go/+/274105
Trust: Russ Cox <rsc@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2020-11-28 15:28:18 -05:00
|
|
|
n.List().SetIndex(0, typecheck(n.List().First(), ctxExpr))
|
|
|
|
}
|
2015-02-13 14:40:36 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// optimization: two-case select but one is default: single non-blocking op.
|
2020-07-27 16:19:15 -07:00
|
|
|
if ncas == 2 && dflt != nil {
|
[dev.regabi] cmd/compile: cleanup for concrete types - range, select, swt
An automated rewrite will add concrete type assertions after
a test of n.Op(), when n can be safely type-asserted
(meaning, n is not reassigned a different type, n is not reassigned
and then used outside the scope of the type assertion,
and so on).
This sequence of CLs handles the code that the automated
rewrite does not: adding specific types to function arguments,
adjusting code not to call n.Left() etc when n may have multiple
representations, and so on.
This CL focuses on range.go, select.go, and swt.go: the big
control structures.
Passes buildall w/ toolstash -cmp.
Change-Id: I033fe056a7b815edb6e8a06f45c12ffd990f4d45
Reviewed-on: https://go-review.googlesource.com/c/go/+/277929
Trust: Russ Cox <rsc@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2020-12-10 18:47:32 -05:00
|
|
|
cas := cases.First().(*ir.CaseStmt)
|
2020-07-27 16:19:15 -07:00
|
|
|
if cas == dflt {
|
[dev.regabi] cmd/compile: cleanup for concrete types - range, select, swt
An automated rewrite will add concrete type assertions after
a test of n.Op(), when n can be safely type-asserted
(meaning, n is not reassigned a different type, n is not reassigned
and then used outside the scope of the type assertion,
and so on).
This sequence of CLs handles the code that the automated
rewrite does not: adding specific types to function arguments,
adjusting code not to call n.Left() etc when n may have multiple
representations, and so on.
This CL focuses on range.go, select.go, and swt.go: the big
control structures.
Passes buildall w/ toolstash -cmp.
Change-Id: I033fe056a7b815edb6e8a06f45c12ffd990f4d45
Reviewed-on: https://go-review.googlesource.com/c/go/+/277929
Trust: Russ Cox <rsc@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2020-12-10 18:47:32 -05:00
|
|
|
cas = cases.Second().(*ir.CaseStmt)
|
2015-02-13 14:40:36 -05:00
|
|
|
}
|
|
|
|
|
2020-11-22 09:59:15 -05:00
|
|
|
n := cas.Left()
|
2015-02-13 14:40:36 -05:00
|
|
|
setlineno(n)
|
[dev.regabi] cmd/compile: remove ir.Nod [generated]
Rewrite all uses of ir.Nod and friends to call the IR constructors directly.
This gives the results a more specific type and will play nicely with
introduction of more specific types throughout the code in a followup CL.
Passes buildall w/ toolstash -cmp.
[git-generate]
cd src/cmd/compile/internal/gc
rf '
ex . ../ir {
import "cmd/compile/internal/ir"
import "cmd/compile/internal/types"
import "cmd/compile/internal/syntax"
import "cmd/internal/src"
var p *noder
var orig syntax.Node
var op ir.Op
var l, r ir.Node
var sym *types.Sym
p.nod(orig, op, l, r) -> ir.NodAt(p.pos(orig), op, l, r)
p.nodSym(orig, op, l, sym) -> nodlSym(p.pos(orig), op, l, sym)
var xpos src.XPos
var ns ir.Nodes
npos(xpos, nodSym(op, l, sym)) -> nodlSym(xpos, op, l, sym)
npos(xpos, liststmt(ns)) -> ir.NewBlockStmt(xpos, ns)
}
ex . ../ir {
import "cmd/compile/internal/base"
import "cmd/compile/internal/ir"
import "cmd/compile/internal/types"
var op ir.Op
var l, r ir.Node
ir.Nod(op, l, r) -> ir.NodAt(base.Pos, op, l, r)
var sym *types.Sym
nodSym(op, l, sym) -> nodlSym(base.Pos, op, l, sym)
}
ex . ../ir {
import "cmd/compile/internal/ir"
import "cmd/internal/src"
# rf overlapping match handling is not quite good enough
# for certain nested rewrites, so handle these two - which often contain other ir.NodAt calls - early.
var l, r ir.Node
var xpos src.XPos
ir.NodAt(xpos, ir.OAS, l, r) -> ir.NewAssignStmt(xpos, l, r)
ir.NodAt(xpos, ir.OIF, l, nil) -> ir.NewIfStmt(xpos, l, nil, nil)
}
ex . ../ir {
import "cmd/compile/internal/ir"
import "cmd/compile/internal/types"
import "cmd/internal/src"
var l, r ir.Node
var sym *types.Sym
var xpos src.XPos
nodlSym(xpos, ir.ODOT, l, sym) -> ir.NewSelectorExpr(xpos, ir.ODOT, l, sym)
nodlSym(xpos, ir.OXDOT, l, sym) -> ir.NewSelectorExpr(xpos, ir.OXDOT, l, sym)
nodlSym(xpos, ir.ODOTPTR, l, sym) -> ir.NewSelectorExpr(xpos, ir.ODOTPTR, l, sym)
nodlSym(xpos, ir.OGOTO, nil, sym) -> ir.NewBranchStmt(xpos, ir.OGOTO, sym)
nodlSym(xpos, ir.ORETJMP, nil, sym) -> ir.NewBranchStmt(xpos, ir.ORETJMP, sym)
nodlSym(xpos, ir.OLABEL, nil, sym) -> ir.NewLabelStmt(xpos, sym)
nodlSym(xpos, ir.OSTRUCTKEY, l, sym) -> ir.NewStructKeyExpr(xpos, sym, l)
ir.NodAt(xpos, ir.OADD, l, r) -> ir.NewBinaryExpr(xpos, ir.OADD, l, r)
ir.NodAt(xpos, ir.OAND, l, r) -> ir.NewBinaryExpr(xpos, ir.OAND, l, r)
ir.NodAt(xpos, ir.OANDNOT, l, r) -> ir.NewBinaryExpr(xpos, ir.OANDNOT, l, r)
ir.NodAt(xpos, ir.ODIV, l, r) -> ir.NewBinaryExpr(xpos, ir.ODIV, l, r)
ir.NodAt(xpos, ir.OEQ, l, r) -> ir.NewBinaryExpr(xpos, ir.OEQ, l, r)
ir.NodAt(xpos, ir.OGE, l, r) -> ir.NewBinaryExpr(xpos, ir.OGE, l, r)
ir.NodAt(xpos, ir.OGT, l, r) -> ir.NewBinaryExpr(xpos, ir.OGT, l, r)
ir.NodAt(xpos, ir.OLE, l, r) -> ir.NewBinaryExpr(xpos, ir.OLE, l, r)
ir.NodAt(xpos, ir.OLSH, l, r) -> ir.NewBinaryExpr(xpos, ir.OLSH, l, r)
ir.NodAt(xpos, ir.OLT, l, r) -> ir.NewBinaryExpr(xpos, ir.OLT, l, r)
ir.NodAt(xpos, ir.OMOD, l, r) -> ir.NewBinaryExpr(xpos, ir.OMOD, l, r)
ir.NodAt(xpos, ir.OMUL, l, r) -> ir.NewBinaryExpr(xpos, ir.OMUL, l, r)
ir.NodAt(xpos, ir.ONE, l, r) -> ir.NewBinaryExpr(xpos, ir.ONE, l, r)
ir.NodAt(xpos, ir.OOR, l, r) -> ir.NewBinaryExpr(xpos, ir.OOR, l, r)
ir.NodAt(xpos, ir.ORSH, l, r) -> ir.NewBinaryExpr(xpos, ir.ORSH, l, r)
ir.NodAt(xpos, ir.OSUB, l, r) -> ir.NewBinaryExpr(xpos, ir.OSUB, l, r)
ir.NodAt(xpos, ir.OXOR, l, r) -> ir.NewBinaryExpr(xpos, ir.OXOR, l, r)
ir.NodAt(xpos, ir.OCOPY, l, r) -> ir.NewBinaryExpr(xpos, ir.OCOPY, l, r)
ir.NodAt(xpos, ir.OCOMPLEX, l, r) -> ir.NewBinaryExpr(xpos, ir.OCOMPLEX, l, r)
ir.NodAt(xpos, ir.OEFACE, l, r) -> ir.NewBinaryExpr(xpos, ir.OEFACE, l, r)
ir.NodAt(xpos, ir.OADDR, l, nil) -> ir.NewAddrExpr(xpos, l)
ir.NodAt(xpos, ir.OADDSTR, nil, nil) -> ir.NewAddStringExpr(xpos, nil)
ir.NodAt(xpos, ir.OANDAND, l, r) -> ir.NewLogicalExpr(xpos, ir.OANDAND, l, r)
ir.NodAt(xpos, ir.OOROR, l, r) -> ir.NewLogicalExpr(xpos, ir.OOROR, l, r)
ir.NodAt(xpos, ir.OARRAYLIT, nil, nil) -> ir.NewCompLitExpr(xpos, ir.OARRAYLIT, nil, nil)
ir.NodAt(xpos, ir.OCOMPLIT, nil, nil) -> ir.NewCompLitExpr(xpos, ir.OCOMPLIT, nil, nil)
ir.NodAt(xpos, ir.OMAPLIT, nil, nil) -> ir.NewCompLitExpr(xpos, ir.OMAPLIT, nil, nil)
ir.NodAt(xpos, ir.OSTRUCTLIT, nil, nil) -> ir.NewCompLitExpr(xpos, ir.OSTRUCTLIT, nil, nil)
ir.NodAt(xpos, ir.OSLICELIT, nil, nil) -> ir.NewCompLitExpr(xpos, ir.OSLICELIT, nil, nil)
ir.NodAt(xpos, ir.OARRAYLIT, nil, r) -> ir.NewCompLitExpr(xpos, ir.OARRAYLIT, r.(ir.Ntype), nil)
ir.NodAt(xpos, ir.OCOMPLIT, nil, r) -> ir.NewCompLitExpr(xpos, ir.OCOMPLIT, r.(ir.Ntype), nil)
ir.NodAt(xpos, ir.OMAPLIT, nil, r) -> ir.NewCompLitExpr(xpos, ir.OMAPLIT, r.(ir.Ntype), nil)
ir.NodAt(xpos, ir.OSTRUCTLIT, nil, r) -> ir.NewCompLitExpr(xpos, ir.OSTRUCTLIT, r.(ir.Ntype), nil)
ir.NodAt(xpos, ir.OSLICELIT, nil, r) -> ir.NewCompLitExpr(xpos, ir.OSLICELIT, r.(ir.Ntype), nil)
ir.NodAt(xpos, ir.OAS2, nil, nil) -> ir.NewAssignListStmt(xpos, ir.OAS2, nil, nil)
ir.NodAt(xpos, ir.OAS2DOTTYPE, nil, nil) -> ir.NewAssignListStmt(xpos, ir.OAS2DOTTYPE, nil, nil)
ir.NodAt(xpos, ir.OAS2FUNC, nil, nil) -> ir.NewAssignListStmt(xpos, ir.OAS2FUNC, nil, nil)
ir.NodAt(xpos, ir.OAS2MAPR, nil, nil) -> ir.NewAssignListStmt(xpos, ir.OAS2MAPR, nil, nil)
ir.NodAt(xpos, ir.OAS2RECV, nil, nil) -> ir.NewAssignListStmt(xpos, ir.OAS2RECV, nil, nil)
ir.NodAt(xpos, ir.OSELRECV2, nil, nil) -> ir.NewAssignListStmt(xpos, ir.OSELRECV2, nil, nil)
ir.NodAt(xpos, ir.OASOP, l, r) -> ir.NewAssignOpStmt(xpos, ir.OXXX, l, r)
ir.NodAt(xpos, ir.OBITNOT, l, nil) -> ir.NewUnaryExpr(xpos, ir.OBITNOT, l)
ir.NodAt(xpos, ir.ONEG, l, nil) -> ir.NewUnaryExpr(xpos, ir.ONEG, l)
ir.NodAt(xpos, ir.ONOT, l, nil) -> ir.NewUnaryExpr(xpos, ir.ONOT, l)
ir.NodAt(xpos, ir.OPLUS, l, nil) -> ir.NewUnaryExpr(xpos, ir.OPLUS, l)
ir.NodAt(xpos, ir.ORECV, l, nil) -> ir.NewUnaryExpr(xpos, ir.ORECV, l)
ir.NodAt(xpos, ir.OALIGNOF, l, nil) -> ir.NewUnaryExpr(xpos, ir.OALIGNOF, l)
ir.NodAt(xpos, ir.OCAP, l, nil) -> ir.NewUnaryExpr(xpos, ir.OCAP, l)
ir.NodAt(xpos, ir.OCLOSE, l, nil) -> ir.NewUnaryExpr(xpos, ir.OCLOSE, l)
ir.NodAt(xpos, ir.OIMAG, l, nil) -> ir.NewUnaryExpr(xpos, ir.OIMAG, l)
ir.NodAt(xpos, ir.OLEN, l, nil) -> ir.NewUnaryExpr(xpos, ir.OLEN, l)
ir.NodAt(xpos, ir.ONEW, l, nil) -> ir.NewUnaryExpr(xpos, ir.ONEW, l)
ir.NodAt(xpos, ir.ONEWOBJ, l, nil) -> ir.NewUnaryExpr(xpos, ir.ONEWOBJ, l)
ir.NodAt(xpos, ir.OOFFSETOF, l, nil) -> ir.NewUnaryExpr(xpos, ir.OOFFSETOF, l)
ir.NodAt(xpos, ir.OPANIC, l, nil) -> ir.NewUnaryExpr(xpos, ir.OPANIC, l)
ir.NodAt(xpos, ir.OREAL, l, nil) -> ir.NewUnaryExpr(xpos, ir.OREAL, l)
ir.NodAt(xpos, ir.OSIZEOF, l, nil) -> ir.NewUnaryExpr(xpos, ir.OSIZEOF, l)
ir.NodAt(xpos, ir.OCHECKNIL, l, nil) -> ir.NewUnaryExpr(xpos, ir.OCHECKNIL, l)
ir.NodAt(xpos, ir.OCFUNC, l, nil) -> ir.NewUnaryExpr(xpos, ir.OCFUNC, l)
ir.NodAt(xpos, ir.OIDATA, l, nil) -> ir.NewUnaryExpr(xpos, ir.OIDATA, l)
ir.NodAt(xpos, ir.OITAB, l, nil) -> ir.NewUnaryExpr(xpos, ir.OITAB, l)
ir.NodAt(xpos, ir.OSPTR, l, nil) -> ir.NewUnaryExpr(xpos, ir.OSPTR, l)
ir.NodAt(xpos, ir.OVARDEF, l, nil) -> ir.NewUnaryExpr(xpos, ir.OVARDEF, l)
ir.NodAt(xpos, ir.OVARKILL, l, nil) -> ir.NewUnaryExpr(xpos, ir.OVARKILL, l)
ir.NodAt(xpos, ir.OVARLIVE, l, nil) -> ir.NewUnaryExpr(xpos, ir.OVARLIVE, l)
ir.NodAt(xpos, ir.OBLOCK, nil, nil) -> ir.NewBlockStmt(xpos, nil)
ir.NodAt(xpos, ir.OBREAK, nil, nil) -> ir.NewBranchStmt(xpos, ir.OBREAK, nil)
ir.NodAt(xpos, ir.OCONTINUE, nil, nil) -> ir.NewBranchStmt(xpos, ir.OCONTINUE, nil)
ir.NodAt(xpos, ir.OFALL, nil, nil) -> ir.NewBranchStmt(xpos, ir.OFALL, nil)
ir.NodAt(xpos, ir.OGOTO, nil, nil) -> ir.NewBranchStmt(xpos, ir.OGOTO, nil)
ir.NodAt(xpos, ir.ORETJMP, nil, nil) -> ir.NewBranchStmt(xpos, ir.ORETJMP, nil)
ir.NodAt(xpos, ir.OCALL, l, nil) -> ir.NewCallExpr(xpos, ir.OCALL, l, nil)
ir.NodAt(xpos, ir.OCALLFUNC, l, nil) -> ir.NewCallExpr(xpos, ir.OCALLFUNC, l, nil)
ir.NodAt(xpos, ir.OCALLINTER, l, nil) -> ir.NewCallExpr(xpos, ir.OCALLINTER, l, nil)
ir.NodAt(xpos, ir.OCALLMETH, l, nil) -> ir.NewCallExpr(xpos, ir.OCALLMETH, l, nil)
ir.NodAt(xpos, ir.OAPPEND, l, nil) -> ir.NewCallExpr(xpos, ir.OAPPEND, l, nil)
ir.NodAt(xpos, ir.ODELETE, l, nil) -> ir.NewCallExpr(xpos, ir.ODELETE, l, nil)
ir.NodAt(xpos, ir.OGETG, l, nil) -> ir.NewCallExpr(xpos, ir.OGETG, l, nil)
ir.NodAt(xpos, ir.OMAKE, l, nil) -> ir.NewCallExpr(xpos, ir.OMAKE, l, nil)
ir.NodAt(xpos, ir.OPRINT, l, nil) -> ir.NewCallExpr(xpos, ir.OPRINT, l, nil)
ir.NodAt(xpos, ir.OPRINTN, l, nil) -> ir.NewCallExpr(xpos, ir.OPRINTN, l, nil)
ir.NodAt(xpos, ir.ORECOVER, l, nil) -> ir.NewCallExpr(xpos, ir.ORECOVER, l, nil)
ir.NodAt(xpos, ir.OCASE, nil, nil) -> ir.NewCaseStmt(xpos, nil, nil)
ir.NodAt(xpos, ir.OCONV, l, nil) -> ir.NewConvExpr(xpos, ir.OCONV, nil, l)
ir.NodAt(xpos, ir.OCONVIFACE, l, nil) -> ir.NewConvExpr(xpos, ir.OCONVIFACE, nil, l)
ir.NodAt(xpos, ir.OCONVNOP, l, nil) -> ir.NewConvExpr(xpos, ir.OCONVNOP, nil, l)
ir.NodAt(xpos, ir.ORUNESTR, l, nil) -> ir.NewConvExpr(xpos, ir.ORUNESTR, nil, l)
ir.NodAt(xpos, ir.ODCL, l, nil) -> ir.NewDecl(xpos, ir.ODCL, l)
ir.NodAt(xpos, ir.ODCLCONST, l, nil) -> ir.NewDecl(xpos, ir.ODCLCONST, l)
ir.NodAt(xpos, ir.ODCLTYPE, l, nil) -> ir.NewDecl(xpos, ir.ODCLTYPE, l)
ir.NodAt(xpos, ir.ODCLFUNC, nil, nil) -> ir.NewFunc(xpos)
ir.NodAt(xpos, ir.ODEFER, l, nil) -> ir.NewGoDeferStmt(xpos, ir.ODEFER, l)
ir.NodAt(xpos, ir.OGO, l, nil) -> ir.NewGoDeferStmt(xpos, ir.OGO, l)
ir.NodAt(xpos, ir.ODEREF, l, nil) -> ir.NewStarExpr(xpos, l)
ir.NodAt(xpos, ir.ODOT, l, nil) -> ir.NewSelectorExpr(xpos, ir.ODOT, l, nil)
ir.NodAt(xpos, ir.ODOTPTR, l, nil) -> ir.NewSelectorExpr(xpos, ir.ODOTPTR, l, nil)
ir.NodAt(xpos, ir.ODOTMETH, l, nil) -> ir.NewSelectorExpr(xpos, ir.ODOTMETH, l, nil)
ir.NodAt(xpos, ir.ODOTINTER, l, nil) -> ir.NewSelectorExpr(xpos, ir.ODOTINTER, l, nil)
ir.NodAt(xpos, ir.OXDOT, l, nil) -> ir.NewSelectorExpr(xpos, ir.OXDOT, l, nil)
ir.NodAt(xpos, ir.ODOTTYPE, l, nil) -> ir.NewTypeAssertExpr(xpos, l, nil)
ir.NodAt(xpos, ir.ODOTTYPE, l, r) -> ir.NewTypeAssertExpr(xpos, l, r.(ir.Ntype))
ir.NodAt(xpos, ir.OFOR, l, r) -> ir.NewForStmt(xpos, nil, l, r, nil)
ir.NodAt(xpos, ir.OINDEX, l, r) -> ir.NewIndexExpr(xpos, l, r)
ir.NodAt(xpos, ir.OINLMARK, nil, nil) -> ir.NewInlineMarkStmt(xpos, types.BADWIDTH)
ir.NodAt(xpos, ir.OKEY, l, r) -> ir.NewKeyExpr(xpos, l, r)
ir.NodAt(xpos, ir.OLABEL, nil, nil) -> ir.NewLabelStmt(xpos, nil)
ir.NodAt(xpos, ir.OMAKECHAN, l, r) -> ir.NewMakeExpr(xpos, ir.OMAKECHAN, l, r)
ir.NodAt(xpos, ir.OMAKEMAP, l, r) -> ir.NewMakeExpr(xpos, ir.OMAKEMAP, l, r)
ir.NodAt(xpos, ir.OMAKESLICE, l, r) -> ir.NewMakeExpr(xpos, ir.OMAKESLICE, l, r)
ir.NodAt(xpos, ir.OMAKESLICECOPY, l, r) -> ir.NewMakeExpr(xpos, ir.OMAKESLICECOPY, l, r)
ir.NodAt(xpos, ir.ONIL, nil, nil) -> ir.NewNilExpr(xpos)
ir.NodAt(xpos, ir.OPACK, nil, nil) -> ir.NewPkgName(xpos, nil, nil)
ir.NodAt(xpos, ir.OPAREN, l, nil) -> ir.NewParenExpr(xpos, l)
ir.NodAt(xpos, ir.ORANGE, nil, r) -> ir.NewRangeStmt(xpos, nil, r, nil)
ir.NodAt(xpos, ir.ORESULT, nil, nil) -> ir.NewResultExpr(xpos, nil, types.BADWIDTH)
ir.NodAt(xpos, ir.ORETURN, nil, nil) -> ir.NewReturnStmt(xpos, nil)
ir.NodAt(xpos, ir.OSELECT, nil, nil) -> ir.NewSelectStmt(xpos, nil)
ir.NodAt(xpos, ir.OSEND, l, r) -> ir.NewSendStmt(xpos, l, r)
ir.NodAt(xpos, ir.OSLICE, l, nil) -> ir.NewSliceExpr(xpos, ir.OSLICE, l)
ir.NodAt(xpos, ir.OSLICEARR, l, nil) -> ir.NewSliceExpr(xpos, ir.OSLICEARR, l)
ir.NodAt(xpos, ir.OSLICESTR, l, nil) -> ir.NewSliceExpr(xpos, ir.OSLICESTR, l)
ir.NodAt(xpos, ir.OSLICE3, l, nil) -> ir.NewSliceExpr(xpos, ir.OSLICE3, l)
ir.NodAt(xpos, ir.OSLICE3ARR, l, nil) -> ir.NewSliceExpr(xpos, ir.OSLICE3ARR, l)
ir.NodAt(xpos, ir.OSLICEHEADER, l, nil) -> ir.NewSliceHeaderExpr(xpos, nil, l, nil, nil)
ir.NodAt(xpos, ir.OSWITCH, l, nil) -> ir.NewSwitchStmt(xpos, l, nil)
ir.NodAt(xpos, ir.OINLCALL, nil, nil) -> ir.NewInlinedCallExpr(xpos, nil, nil)
}
rm noder.nod noder.nodSym nodSym nodlSym ir.NodAt ir.Nod
'
Change-Id: Ibf1eb708de8463ae74ccc47d7966cc263a18295e
Reviewed-on: https://go-review.googlesource.com/c/go/+/277933
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2020-12-22 23:55:29 -05:00
|
|
|
r := ir.NewIfStmt(base.Pos, nil, nil, nil)
|
2020-11-22 09:59:15 -05:00
|
|
|
r.PtrInit().Set(cas.Init().Slice())
|
[dev.regabi] cmd/compile: clean up in preparation for statement Nodes
Using statement nodes restricts the set of valid SetOp operations,
because you can't SetOp across representation. Rewrite various
code to avoid crossing those as-yet-unintroduced boundaries.
In particular, code like
x, y := v.(T)
x, y := f()
x, y := m[k]
x, y := <-c
starts out with Op = OAS2, and then it turns into a specific Op
OAS2DOTTYPE, OAS2FUNC, OAS2MAPR, OAS2RECV, and then
later in walk is lowered to an OAS2 again.
In the middle, the specific forms move the right-hand side from
n.Rlist().First() to n.Right(), and then the conversion to OAS2 moves
it back. This is unnecessary and makes it hard for these all to
share an underlying Node implementation.
This CL changes these specific forms to leave the right-hand side
in n.Rlist().First().
Similarly, OSELRECV2 is really just a temporary form of OAS2.
This CL changes it to use same fields too.
Finally, this CL fixes the printing of OAS2 nodes in ir/fmt.go,
which formerly printed n.Right() instead of n.Rlist().
This results in a (correct!) update to cmd/compile/internal/logopt's
expected output: ~R0 = <N> becomes ~R0 = &y.b.
Passes buildall w/ toolstash -cmp.
Change-Id: I164aa2e17dc55bfb292024de53d7d250192ad64a
Reviewed-on: https://go-review.googlesource.com/c/go/+/274105
Trust: Russ Cox <rsc@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2020-11-28 15:28:18 -05:00
|
|
|
var call ir.Node
|
2020-11-22 09:59:15 -05:00
|
|
|
switch n.Op() {
|
2015-02-13 14:40:36 -05:00
|
|
|
default:
|
2020-11-22 09:59:15 -05:00
|
|
|
base.Fatalf("select %v", n.Op())
|
2015-02-13 14:40:36 -05:00
|
|
|
|
[dev.regabi] cmd/compile: introduce cmd/compile/internal/ir [generated]
If we want to break up package gc at all, we will need to move
the compiler IR it defines into a separate package that can be
imported by packages that gc itself imports. This CL does that.
It also removes the TINT8 etc aliases so that all code is clear
about which package things are coming from.
This CL is automatically generated by the script below.
See the comments in the script for details about the changes.
[git-generate]
cd src/cmd/compile/internal/gc
rf '
# These names were never fully qualified
# when the types package was added.
# Do it now, to avoid confusion about where they live.
inline -rm \
Txxx \
TINT8 \
TUINT8 \
TINT16 \
TUINT16 \
TINT32 \
TUINT32 \
TINT64 \
TUINT64 \
TINT \
TUINT \
TUINTPTR \
TCOMPLEX64 \
TCOMPLEX128 \
TFLOAT32 \
TFLOAT64 \
TBOOL \
TPTR \
TFUNC \
TSLICE \
TARRAY \
TSTRUCT \
TCHAN \
TMAP \
TINTER \
TFORW \
TANY \
TSTRING \
TUNSAFEPTR \
TIDEAL \
TNIL \
TBLANK \
TFUNCARGS \
TCHANARGS \
NTYPE \
BADWIDTH
# esc.go and escape.go do not need to be split.
# Append esc.go onto the end of escape.go.
mv esc.go escape.go
# Pull out the type format installation from func Main,
# so it can be carried into package ir.
mv Main:/Sconv.=/-0,/TypeLinkSym/-1 InstallTypeFormats
# Names that need to be exported for use by code left in gc.
mv Isconst IsConst
mv asNode AsNode
mv asNodes AsNodes
mv asTypesNode AsTypesNode
mv basicnames BasicTypeNames
mv builtinpkg BuiltinPkg
mv consttype ConstType
mv dumplist DumpList
mv fdumplist FDumpList
mv fmtMode FmtMode
mv goopnames OpNames
mv inspect Inspect
mv inspectList InspectList
mv localpkg LocalPkg
mv nblank BlankNode
mv numImport NumImport
mv opprec OpPrec
mv origSym OrigSym
mv stmtwithinit StmtWithInit
mv dump DumpAny
mv fdump FDumpAny
mv nod Nod
mv nodl NodAt
mv newname NewName
mv newnamel NewNameAt
mv assertRepresents AssertValidTypeForConst
mv represents ValidTypeForConst
mv nodlit NewLiteral
# Types and fields that need to be exported for use by gc.
mv nowritebarrierrecCallSym SymAndPos
mv SymAndPos.lineno SymAndPos.Pos
mv SymAndPos.target SymAndPos.Sym
mv Func.lsym Func.LSym
mv Func.setWBPos Func.SetWBPos
mv Func.numReturns Func.NumReturns
mv Func.numDefers Func.NumDefers
mv Func.nwbrCalls Func.NWBRCalls
# initLSym is an algorithm left behind in gc,
# not an operation on Func itself.
mv Func.initLSym initLSym
mv nodeQueue NodeQueue
mv NodeQueue.empty NodeQueue.Empty
mv NodeQueue.popLeft NodeQueue.PopLeft
mv NodeQueue.pushRight NodeQueue.PushRight
# Many methods on Node are actually algorithms that
# would apply to any node implementation.
# Those become plain functions.
mv Node.funcname FuncName
mv Node.isBlank IsBlank
mv Node.isGoConst isGoConst
mv Node.isNil IsNil
mv Node.isParamHeapCopy isParamHeapCopy
mv Node.isParamStackCopy isParamStackCopy
mv Node.isSimpleName isSimpleName
mv Node.mayBeShared MayBeShared
mv Node.pkgFuncName PkgFuncName
mv Node.backingArrayPtrLen backingArrayPtrLen
mv Node.isterminating isTermNode
mv Node.labeledControl labeledControl
mv Nodes.isterminating isTermNodes
mv Nodes.sigerr fmtSignature
mv Node.MethodName methodExprName
mv Node.MethodFunc methodExprFunc
mv Node.IsMethod IsMethod
# Every node will need to implement RawCopy;
# Copy and SepCopy algorithms will use it.
mv Node.rawcopy Node.RawCopy
mv Node.copy Copy
mv Node.sepcopy SepCopy
# Extract Node.Format method body into func FmtNode,
# but leave method wrapper behind.
mv Node.Format:0,$ FmtNode
# Formatting helpers that will apply to all node implementations.
mv Node.Line Line
mv Node.exprfmt exprFmt
mv Node.jconv jconvFmt
mv Node.modeString modeString
mv Node.nconv nconvFmt
mv Node.nodedump nodeDumpFmt
mv Node.nodefmt nodeFmt
mv Node.stmtfmt stmtFmt
# Constant support needed for code moving to ir.
mv okforconst OKForConst
mv vconv FmtConst
mv int64Val Int64Val
mv float64Val Float64Val
mv Node.ValueInterface ConstValue
# Organize code into files.
mv LocalPkg BuiltinPkg ir.go
mv NumImport InstallTypeFormats Line fmt.go
mv syntax.go Nod NodAt NewNameAt Class Pxxx PragmaFlag Nointerface SymAndPos \
AsNode AsTypesNode BlankNode OrigSym \
Node.SliceBounds Node.SetSliceBounds Op.IsSlice3 \
IsConst Node.Int64Val Node.CanInt64 Node.Uint64Val Node.BoolVal Node.StringVal \
Node.RawCopy SepCopy Copy \
IsNil IsBlank IsMethod \
Node.Typ Node.StorageClass node.go
mv ConstType ConstValue Int64Val Float64Val AssertValidTypeForConst ValidTypeForConst NewLiteral idealType OKForConst val.go
# Move files to new ir package.
mv bitset.go class_string.go dump.go fmt.go \
ir.go node.go op_string.go val.go \
sizeof_test.go cmd/compile/internal/ir
'
: # fix mkbuiltin.go to generate the changes made to builtin.go during rf
sed -i '' '
s/\[T/[types.T/g
s/\*Node/*ir.Node/g
/internal\/types/c \
fmt.Fprintln(&b, `import (`) \
fmt.Fprintln(&b, ` "cmd/compile/internal/ir"`) \
fmt.Fprintln(&b, ` "cmd/compile/internal/types"`) \
fmt.Fprintln(&b, `)`)
' mkbuiltin.go
gofmt -w mkbuiltin.go
: # update cmd/dist to add internal/ir
cd ../../../dist
sed -i '' '/compile.internal.gc/a\
"cmd/compile/internal/ir",
' buildtool.go
gofmt -w buildtool.go
: # update cmd/compile TestFormats
cd ../..
go install std cmd
cd cmd/compile
go test -u || go test # first one updates but fails; second passes
Change-Id: I5f7caf6b20629b51970279e81231a3574d5b51db
Reviewed-on: https://go-review.googlesource.com/c/go/+/273008
Trust: Russ Cox <rsc@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2020-11-19 21:09:22 -05:00
|
|
|
case ir.OSEND:
|
2017-03-01 15:50:57 -08:00
|
|
|
// if selectnbsend(c, v) { body } else { default body }
|
2020-11-22 09:59:15 -05:00
|
|
|
ch := n.Left()
|
[dev.regabi] cmd/compile: clean up in preparation for statement Nodes
Using statement nodes restricts the set of valid SetOp operations,
because you can't SetOp across representation. Rewrite various
code to avoid crossing those as-yet-unintroduced boundaries.
In particular, code like
x, y := v.(T)
x, y := f()
x, y := m[k]
x, y := <-c
starts out with Op = OAS2, and then it turns into a specific Op
OAS2DOTTYPE, OAS2FUNC, OAS2MAPR, OAS2RECV, and then
later in walk is lowered to an OAS2 again.
In the middle, the specific forms move the right-hand side from
n.Rlist().First() to n.Right(), and then the conversion to OAS2 moves
it back. This is unnecessary and makes it hard for these all to
share an underlying Node implementation.
This CL changes these specific forms to leave the right-hand side
in n.Rlist().First().
Similarly, OSELRECV2 is really just a temporary form of OAS2.
This CL changes it to use same fields too.
Finally, this CL fixes the printing of OAS2 nodes in ir/fmt.go,
which formerly printed n.Right() instead of n.Rlist().
This results in a (correct!) update to cmd/compile/internal/logopt's
expected output: ~R0 = <N> becomes ~R0 = &y.b.
Passes buildall w/ toolstash -cmp.
Change-Id: I164aa2e17dc55bfb292024de53d7d250192ad64a
Reviewed-on: https://go-review.googlesource.com/c/go/+/274105
Trust: Russ Cox <rsc@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2020-11-28 15:28:18 -05:00
|
|
|
call = mkcall1(chanfn("selectnbsend", 2, ch.Type()), types.Types[types.TBOOL], r.PtrInit(), ch, n.Right())
|
2015-02-13 14:40:36 -05:00
|
|
|
|
[dev.regabi] cmd/compile: introduce cmd/compile/internal/ir [generated]
If we want to break up package gc at all, we will need to move
the compiler IR it defines into a separate package that can be
imported by packages that gc itself imports. This CL does that.
It also removes the TINT8 etc aliases so that all code is clear
about which package things are coming from.
This CL is automatically generated by the script below.
See the comments in the script for details about the changes.
[git-generate]
cd src/cmd/compile/internal/gc
rf '
# These names were never fully qualified
# when the types package was added.
# Do it now, to avoid confusion about where they live.
inline -rm \
Txxx \
TINT8 \
TUINT8 \
TINT16 \
TUINT16 \
TINT32 \
TUINT32 \
TINT64 \
TUINT64 \
TINT \
TUINT \
TUINTPTR \
TCOMPLEX64 \
TCOMPLEX128 \
TFLOAT32 \
TFLOAT64 \
TBOOL \
TPTR \
TFUNC \
TSLICE \
TARRAY \
TSTRUCT \
TCHAN \
TMAP \
TINTER \
TFORW \
TANY \
TSTRING \
TUNSAFEPTR \
TIDEAL \
TNIL \
TBLANK \
TFUNCARGS \
TCHANARGS \
NTYPE \
BADWIDTH
# esc.go and escape.go do not need to be split.
# Append esc.go onto the end of escape.go.
mv esc.go escape.go
# Pull out the type format installation from func Main,
# so it can be carried into package ir.
mv Main:/Sconv.=/-0,/TypeLinkSym/-1 InstallTypeFormats
# Names that need to be exported for use by code left in gc.
mv Isconst IsConst
mv asNode AsNode
mv asNodes AsNodes
mv asTypesNode AsTypesNode
mv basicnames BasicTypeNames
mv builtinpkg BuiltinPkg
mv consttype ConstType
mv dumplist DumpList
mv fdumplist FDumpList
mv fmtMode FmtMode
mv goopnames OpNames
mv inspect Inspect
mv inspectList InspectList
mv localpkg LocalPkg
mv nblank BlankNode
mv numImport NumImport
mv opprec OpPrec
mv origSym OrigSym
mv stmtwithinit StmtWithInit
mv dump DumpAny
mv fdump FDumpAny
mv nod Nod
mv nodl NodAt
mv newname NewName
mv newnamel NewNameAt
mv assertRepresents AssertValidTypeForConst
mv represents ValidTypeForConst
mv nodlit NewLiteral
# Types and fields that need to be exported for use by gc.
mv nowritebarrierrecCallSym SymAndPos
mv SymAndPos.lineno SymAndPos.Pos
mv SymAndPos.target SymAndPos.Sym
mv Func.lsym Func.LSym
mv Func.setWBPos Func.SetWBPos
mv Func.numReturns Func.NumReturns
mv Func.numDefers Func.NumDefers
mv Func.nwbrCalls Func.NWBRCalls
# initLSym is an algorithm left behind in gc,
# not an operation on Func itself.
mv Func.initLSym initLSym
mv nodeQueue NodeQueue
mv NodeQueue.empty NodeQueue.Empty
mv NodeQueue.popLeft NodeQueue.PopLeft
mv NodeQueue.pushRight NodeQueue.PushRight
# Many methods on Node are actually algorithms that
# would apply to any node implementation.
# Those become plain functions.
mv Node.funcname FuncName
mv Node.isBlank IsBlank
mv Node.isGoConst isGoConst
mv Node.isNil IsNil
mv Node.isParamHeapCopy isParamHeapCopy
mv Node.isParamStackCopy isParamStackCopy
mv Node.isSimpleName isSimpleName
mv Node.mayBeShared MayBeShared
mv Node.pkgFuncName PkgFuncName
mv Node.backingArrayPtrLen backingArrayPtrLen
mv Node.isterminating isTermNode
mv Node.labeledControl labeledControl
mv Nodes.isterminating isTermNodes
mv Nodes.sigerr fmtSignature
mv Node.MethodName methodExprName
mv Node.MethodFunc methodExprFunc
mv Node.IsMethod IsMethod
# Every node will need to implement RawCopy;
# Copy and SepCopy algorithms will use it.
mv Node.rawcopy Node.RawCopy
mv Node.copy Copy
mv Node.sepcopy SepCopy
# Extract Node.Format method body into func FmtNode,
# but leave method wrapper behind.
mv Node.Format:0,$ FmtNode
# Formatting helpers that will apply to all node implementations.
mv Node.Line Line
mv Node.exprfmt exprFmt
mv Node.jconv jconvFmt
mv Node.modeString modeString
mv Node.nconv nconvFmt
mv Node.nodedump nodeDumpFmt
mv Node.nodefmt nodeFmt
mv Node.stmtfmt stmtFmt
# Constant support needed for code moving to ir.
mv okforconst OKForConst
mv vconv FmtConst
mv int64Val Int64Val
mv float64Val Float64Val
mv Node.ValueInterface ConstValue
# Organize code into files.
mv LocalPkg BuiltinPkg ir.go
mv NumImport InstallTypeFormats Line fmt.go
mv syntax.go Nod NodAt NewNameAt Class Pxxx PragmaFlag Nointerface SymAndPos \
AsNode AsTypesNode BlankNode OrigSym \
Node.SliceBounds Node.SetSliceBounds Op.IsSlice3 \
IsConst Node.Int64Val Node.CanInt64 Node.Uint64Val Node.BoolVal Node.StringVal \
Node.RawCopy SepCopy Copy \
IsNil IsBlank IsMethod \
Node.Typ Node.StorageClass node.go
mv ConstType ConstValue Int64Val Float64Val AssertValidTypeForConst ValidTypeForConst NewLiteral idealType OKForConst val.go
# Move files to new ir package.
mv bitset.go class_string.go dump.go fmt.go \
ir.go node.go op_string.go val.go \
sizeof_test.go cmd/compile/internal/ir
'
: # fix mkbuiltin.go to generate the changes made to builtin.go during rf
sed -i '' '
s/\[T/[types.T/g
s/\*Node/*ir.Node/g
/internal\/types/c \
fmt.Fprintln(&b, `import (`) \
fmt.Fprintln(&b, ` "cmd/compile/internal/ir"`) \
fmt.Fprintln(&b, ` "cmd/compile/internal/types"`) \
fmt.Fprintln(&b, `)`)
' mkbuiltin.go
gofmt -w mkbuiltin.go
: # update cmd/dist to add internal/ir
cd ../../../dist
sed -i '' '/compile.internal.gc/a\
"cmd/compile/internal/ir",
' buildtool.go
gofmt -w buildtool.go
: # update cmd/compile TestFormats
cd ../..
go install std cmd
cd cmd/compile
go test -u || go test # first one updates but fails; second passes
Change-Id: I5f7caf6b20629b51970279e81231a3574d5b51db
Reviewed-on: https://go-review.googlesource.com/c/go/+/273008
Trust: Russ Cox <rsc@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2020-11-19 21:09:22 -05:00
|
|
|
case ir.OSELRECV2:
|
[dev.regabi] cmd/compile: cleanup for concrete types - range, select, swt
An automated rewrite will add concrete type assertions after
a test of n.Op(), when n can be safely type-asserted
(meaning, n is not reassigned a different type, n is not reassigned
and then used outside the scope of the type assertion,
and so on).
This sequence of CLs handles the code that the automated
rewrite does not: adding specific types to function arguments,
adjusting code not to call n.Left() etc when n may have multiple
representations, and so on.
This CL focuses on range.go, select.go, and swt.go: the big
control structures.
Passes buildall w/ toolstash -cmp.
Change-Id: I033fe056a7b815edb6e8a06f45c12ffd990f4d45
Reviewed-on: https://go-review.googlesource.com/c/go/+/277929
Trust: Russ Cox <rsc@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2020-12-10 18:47:32 -05:00
|
|
|
recv := n.Rlist().First().(*ir.UnaryExpr)
|
|
|
|
ch := recv.Left()
|
[dev.regabi] cmd/compile: clean up in preparation for statement Nodes
Using statement nodes restricts the set of valid SetOp operations,
because you can't SetOp across representation. Rewrite various
code to avoid crossing those as-yet-unintroduced boundaries.
In particular, code like
x, y := v.(T)
x, y := f()
x, y := m[k]
x, y := <-c
starts out with Op = OAS2, and then it turns into a specific Op
OAS2DOTTYPE, OAS2FUNC, OAS2MAPR, OAS2RECV, and then
later in walk is lowered to an OAS2 again.
In the middle, the specific forms move the right-hand side from
n.Rlist().First() to n.Right(), and then the conversion to OAS2 moves
it back. This is unnecessary and makes it hard for these all to
share an underlying Node implementation.
This CL changes these specific forms to leave the right-hand side
in n.Rlist().First().
Similarly, OSELRECV2 is really just a temporary form of OAS2.
This CL changes it to use same fields too.
Finally, this CL fixes the printing of OAS2 nodes in ir/fmt.go,
which formerly printed n.Right() instead of n.Rlist().
This results in a (correct!) update to cmd/compile/internal/logopt's
expected output: ~R0 = <N> becomes ~R0 = &y.b.
Passes buildall w/ toolstash -cmp.
Change-Id: I164aa2e17dc55bfb292024de53d7d250192ad64a
Reviewed-on: https://go-review.googlesource.com/c/go/+/274105
Trust: Russ Cox <rsc@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2020-11-28 15:28:18 -05:00
|
|
|
elem := n.List().First()
|
|
|
|
if ir.IsBlank(elem) {
|
2017-03-07 14:26:27 -08:00
|
|
|
elem = nodnil()
|
|
|
|
}
|
2020-12-07 03:24:04 +07:00
|
|
|
if ir.IsBlank(n.List().Second()) {
|
|
|
|
// if selectnbrecv(&v, c) { body } else { default body }
|
|
|
|
call = mkcall1(chanfn("selectnbrecv", 2, ch.Type()), types.Types[types.TBOOL], r.PtrInit(), elem, ch)
|
|
|
|
} else {
|
|
|
|
// TODO(cuonglm): make this use selectnbrecv()
|
|
|
|
// if selectnbrecv2(&v, &received, c) { body } else { default body }
|
2020-12-18 11:29:49 -05:00
|
|
|
receivedp := typecheck(nodAddr(n.List().Second()), ctxExpr)
|
2020-12-07 03:24:04 +07:00
|
|
|
call = mkcall1(chanfn("selectnbrecv2", 2, ch.Type()), types.Types[types.TBOOL], r.PtrInit(), elem, receivedp, ch)
|
|
|
|
}
|
2015-02-13 14:40:36 -05:00
|
|
|
}
|
|
|
|
|
[dev.regabi] cmd/compile: clean up in preparation for statement Nodes
Using statement nodes restricts the set of valid SetOp operations,
because you can't SetOp across representation. Rewrite various
code to avoid crossing those as-yet-unintroduced boundaries.
In particular, code like
x, y := v.(T)
x, y := f()
x, y := m[k]
x, y := <-c
starts out with Op = OAS2, and then it turns into a specific Op
OAS2DOTTYPE, OAS2FUNC, OAS2MAPR, OAS2RECV, and then
later in walk is lowered to an OAS2 again.
In the middle, the specific forms move the right-hand side from
n.Rlist().First() to n.Right(), and then the conversion to OAS2 moves
it back. This is unnecessary and makes it hard for these all to
share an underlying Node implementation.
This CL changes these specific forms to leave the right-hand side
in n.Rlist().First().
Similarly, OSELRECV2 is really just a temporary form of OAS2.
This CL changes it to use same fields too.
Finally, this CL fixes the printing of OAS2 nodes in ir/fmt.go,
which formerly printed n.Right() instead of n.Rlist().
This results in a (correct!) update to cmd/compile/internal/logopt's
expected output: ~R0 = <N> becomes ~R0 = &y.b.
Passes buildall w/ toolstash -cmp.
Change-Id: I164aa2e17dc55bfb292024de53d7d250192ad64a
Reviewed-on: https://go-review.googlesource.com/c/go/+/274105
Trust: Russ Cox <rsc@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2020-11-28 15:28:18 -05:00
|
|
|
r.SetLeft(typecheck(call, ctxExpr))
|
2020-11-22 09:59:15 -05:00
|
|
|
r.PtrBody().Set(cas.Body().Slice())
|
|
|
|
r.PtrRlist().Set(append(dflt.Init().Slice(), dflt.Body().Slice()...))
|
[dev.regabi] cmd/compile: remove ir.Nod [generated]
Rewrite all uses of ir.Nod and friends to call the IR constructors directly.
This gives the results a more specific type and will play nicely with
introduction of more specific types throughout the code in a followup CL.
Passes buildall w/ toolstash -cmp.
[git-generate]
cd src/cmd/compile/internal/gc
rf '
ex . ../ir {
import "cmd/compile/internal/ir"
import "cmd/compile/internal/types"
import "cmd/compile/internal/syntax"
import "cmd/internal/src"
var p *noder
var orig syntax.Node
var op ir.Op
var l, r ir.Node
var sym *types.Sym
p.nod(orig, op, l, r) -> ir.NodAt(p.pos(orig), op, l, r)
p.nodSym(orig, op, l, sym) -> nodlSym(p.pos(orig), op, l, sym)
var xpos src.XPos
var ns ir.Nodes
npos(xpos, nodSym(op, l, sym)) -> nodlSym(xpos, op, l, sym)
npos(xpos, liststmt(ns)) -> ir.NewBlockStmt(xpos, ns)
}
ex . ../ir {
import "cmd/compile/internal/base"
import "cmd/compile/internal/ir"
import "cmd/compile/internal/types"
var op ir.Op
var l, r ir.Node
ir.Nod(op, l, r) -> ir.NodAt(base.Pos, op, l, r)
var sym *types.Sym
nodSym(op, l, sym) -> nodlSym(base.Pos, op, l, sym)
}
ex . ../ir {
import "cmd/compile/internal/ir"
import "cmd/internal/src"
# rf overlapping match handling is not quite good enough
# for certain nested rewrites, so handle these two - which often contain other ir.NodAt calls - early.
var l, r ir.Node
var xpos src.XPos
ir.NodAt(xpos, ir.OAS, l, r) -> ir.NewAssignStmt(xpos, l, r)
ir.NodAt(xpos, ir.OIF, l, nil) -> ir.NewIfStmt(xpos, l, nil, nil)
}
ex . ../ir {
import "cmd/compile/internal/ir"
import "cmd/compile/internal/types"
import "cmd/internal/src"
var l, r ir.Node
var sym *types.Sym
var xpos src.XPos
nodlSym(xpos, ir.ODOT, l, sym) -> ir.NewSelectorExpr(xpos, ir.ODOT, l, sym)
nodlSym(xpos, ir.OXDOT, l, sym) -> ir.NewSelectorExpr(xpos, ir.OXDOT, l, sym)
nodlSym(xpos, ir.ODOTPTR, l, sym) -> ir.NewSelectorExpr(xpos, ir.ODOTPTR, l, sym)
nodlSym(xpos, ir.OGOTO, nil, sym) -> ir.NewBranchStmt(xpos, ir.OGOTO, sym)
nodlSym(xpos, ir.ORETJMP, nil, sym) -> ir.NewBranchStmt(xpos, ir.ORETJMP, sym)
nodlSym(xpos, ir.OLABEL, nil, sym) -> ir.NewLabelStmt(xpos, sym)
nodlSym(xpos, ir.OSTRUCTKEY, l, sym) -> ir.NewStructKeyExpr(xpos, sym, l)
ir.NodAt(xpos, ir.OADD, l, r) -> ir.NewBinaryExpr(xpos, ir.OADD, l, r)
ir.NodAt(xpos, ir.OAND, l, r) -> ir.NewBinaryExpr(xpos, ir.OAND, l, r)
ir.NodAt(xpos, ir.OANDNOT, l, r) -> ir.NewBinaryExpr(xpos, ir.OANDNOT, l, r)
ir.NodAt(xpos, ir.ODIV, l, r) -> ir.NewBinaryExpr(xpos, ir.ODIV, l, r)
ir.NodAt(xpos, ir.OEQ, l, r) -> ir.NewBinaryExpr(xpos, ir.OEQ, l, r)
ir.NodAt(xpos, ir.OGE, l, r) -> ir.NewBinaryExpr(xpos, ir.OGE, l, r)
ir.NodAt(xpos, ir.OGT, l, r) -> ir.NewBinaryExpr(xpos, ir.OGT, l, r)
ir.NodAt(xpos, ir.OLE, l, r) -> ir.NewBinaryExpr(xpos, ir.OLE, l, r)
ir.NodAt(xpos, ir.OLSH, l, r) -> ir.NewBinaryExpr(xpos, ir.OLSH, l, r)
ir.NodAt(xpos, ir.OLT, l, r) -> ir.NewBinaryExpr(xpos, ir.OLT, l, r)
ir.NodAt(xpos, ir.OMOD, l, r) -> ir.NewBinaryExpr(xpos, ir.OMOD, l, r)
ir.NodAt(xpos, ir.OMUL, l, r) -> ir.NewBinaryExpr(xpos, ir.OMUL, l, r)
ir.NodAt(xpos, ir.ONE, l, r) -> ir.NewBinaryExpr(xpos, ir.ONE, l, r)
ir.NodAt(xpos, ir.OOR, l, r) -> ir.NewBinaryExpr(xpos, ir.OOR, l, r)
ir.NodAt(xpos, ir.ORSH, l, r) -> ir.NewBinaryExpr(xpos, ir.ORSH, l, r)
ir.NodAt(xpos, ir.OSUB, l, r) -> ir.NewBinaryExpr(xpos, ir.OSUB, l, r)
ir.NodAt(xpos, ir.OXOR, l, r) -> ir.NewBinaryExpr(xpos, ir.OXOR, l, r)
ir.NodAt(xpos, ir.OCOPY, l, r) -> ir.NewBinaryExpr(xpos, ir.OCOPY, l, r)
ir.NodAt(xpos, ir.OCOMPLEX, l, r) -> ir.NewBinaryExpr(xpos, ir.OCOMPLEX, l, r)
ir.NodAt(xpos, ir.OEFACE, l, r) -> ir.NewBinaryExpr(xpos, ir.OEFACE, l, r)
ir.NodAt(xpos, ir.OADDR, l, nil) -> ir.NewAddrExpr(xpos, l)
ir.NodAt(xpos, ir.OADDSTR, nil, nil) -> ir.NewAddStringExpr(xpos, nil)
ir.NodAt(xpos, ir.OANDAND, l, r) -> ir.NewLogicalExpr(xpos, ir.OANDAND, l, r)
ir.NodAt(xpos, ir.OOROR, l, r) -> ir.NewLogicalExpr(xpos, ir.OOROR, l, r)
ir.NodAt(xpos, ir.OARRAYLIT, nil, nil) -> ir.NewCompLitExpr(xpos, ir.OARRAYLIT, nil, nil)
ir.NodAt(xpos, ir.OCOMPLIT, nil, nil) -> ir.NewCompLitExpr(xpos, ir.OCOMPLIT, nil, nil)
ir.NodAt(xpos, ir.OMAPLIT, nil, nil) -> ir.NewCompLitExpr(xpos, ir.OMAPLIT, nil, nil)
ir.NodAt(xpos, ir.OSTRUCTLIT, nil, nil) -> ir.NewCompLitExpr(xpos, ir.OSTRUCTLIT, nil, nil)
ir.NodAt(xpos, ir.OSLICELIT, nil, nil) -> ir.NewCompLitExpr(xpos, ir.OSLICELIT, nil, nil)
ir.NodAt(xpos, ir.OARRAYLIT, nil, r) -> ir.NewCompLitExpr(xpos, ir.OARRAYLIT, r.(ir.Ntype), nil)
ir.NodAt(xpos, ir.OCOMPLIT, nil, r) -> ir.NewCompLitExpr(xpos, ir.OCOMPLIT, r.(ir.Ntype), nil)
ir.NodAt(xpos, ir.OMAPLIT, nil, r) -> ir.NewCompLitExpr(xpos, ir.OMAPLIT, r.(ir.Ntype), nil)
ir.NodAt(xpos, ir.OSTRUCTLIT, nil, r) -> ir.NewCompLitExpr(xpos, ir.OSTRUCTLIT, r.(ir.Ntype), nil)
ir.NodAt(xpos, ir.OSLICELIT, nil, r) -> ir.NewCompLitExpr(xpos, ir.OSLICELIT, r.(ir.Ntype), nil)
ir.NodAt(xpos, ir.OAS2, nil, nil) -> ir.NewAssignListStmt(xpos, ir.OAS2, nil, nil)
ir.NodAt(xpos, ir.OAS2DOTTYPE, nil, nil) -> ir.NewAssignListStmt(xpos, ir.OAS2DOTTYPE, nil, nil)
ir.NodAt(xpos, ir.OAS2FUNC, nil, nil) -> ir.NewAssignListStmt(xpos, ir.OAS2FUNC, nil, nil)
ir.NodAt(xpos, ir.OAS2MAPR, nil, nil) -> ir.NewAssignListStmt(xpos, ir.OAS2MAPR, nil, nil)
ir.NodAt(xpos, ir.OAS2RECV, nil, nil) -> ir.NewAssignListStmt(xpos, ir.OAS2RECV, nil, nil)
ir.NodAt(xpos, ir.OSELRECV2, nil, nil) -> ir.NewAssignListStmt(xpos, ir.OSELRECV2, nil, nil)
ir.NodAt(xpos, ir.OASOP, l, r) -> ir.NewAssignOpStmt(xpos, ir.OXXX, l, r)
ir.NodAt(xpos, ir.OBITNOT, l, nil) -> ir.NewUnaryExpr(xpos, ir.OBITNOT, l)
ir.NodAt(xpos, ir.ONEG, l, nil) -> ir.NewUnaryExpr(xpos, ir.ONEG, l)
ir.NodAt(xpos, ir.ONOT, l, nil) -> ir.NewUnaryExpr(xpos, ir.ONOT, l)
ir.NodAt(xpos, ir.OPLUS, l, nil) -> ir.NewUnaryExpr(xpos, ir.OPLUS, l)
ir.NodAt(xpos, ir.ORECV, l, nil) -> ir.NewUnaryExpr(xpos, ir.ORECV, l)
ir.NodAt(xpos, ir.OALIGNOF, l, nil) -> ir.NewUnaryExpr(xpos, ir.OALIGNOF, l)
ir.NodAt(xpos, ir.OCAP, l, nil) -> ir.NewUnaryExpr(xpos, ir.OCAP, l)
ir.NodAt(xpos, ir.OCLOSE, l, nil) -> ir.NewUnaryExpr(xpos, ir.OCLOSE, l)
ir.NodAt(xpos, ir.OIMAG, l, nil) -> ir.NewUnaryExpr(xpos, ir.OIMAG, l)
ir.NodAt(xpos, ir.OLEN, l, nil) -> ir.NewUnaryExpr(xpos, ir.OLEN, l)
ir.NodAt(xpos, ir.ONEW, l, nil) -> ir.NewUnaryExpr(xpos, ir.ONEW, l)
ir.NodAt(xpos, ir.ONEWOBJ, l, nil) -> ir.NewUnaryExpr(xpos, ir.ONEWOBJ, l)
ir.NodAt(xpos, ir.OOFFSETOF, l, nil) -> ir.NewUnaryExpr(xpos, ir.OOFFSETOF, l)
ir.NodAt(xpos, ir.OPANIC, l, nil) -> ir.NewUnaryExpr(xpos, ir.OPANIC, l)
ir.NodAt(xpos, ir.OREAL, l, nil) -> ir.NewUnaryExpr(xpos, ir.OREAL, l)
ir.NodAt(xpos, ir.OSIZEOF, l, nil) -> ir.NewUnaryExpr(xpos, ir.OSIZEOF, l)
ir.NodAt(xpos, ir.OCHECKNIL, l, nil) -> ir.NewUnaryExpr(xpos, ir.OCHECKNIL, l)
ir.NodAt(xpos, ir.OCFUNC, l, nil) -> ir.NewUnaryExpr(xpos, ir.OCFUNC, l)
ir.NodAt(xpos, ir.OIDATA, l, nil) -> ir.NewUnaryExpr(xpos, ir.OIDATA, l)
ir.NodAt(xpos, ir.OITAB, l, nil) -> ir.NewUnaryExpr(xpos, ir.OITAB, l)
ir.NodAt(xpos, ir.OSPTR, l, nil) -> ir.NewUnaryExpr(xpos, ir.OSPTR, l)
ir.NodAt(xpos, ir.OVARDEF, l, nil) -> ir.NewUnaryExpr(xpos, ir.OVARDEF, l)
ir.NodAt(xpos, ir.OVARKILL, l, nil) -> ir.NewUnaryExpr(xpos, ir.OVARKILL, l)
ir.NodAt(xpos, ir.OVARLIVE, l, nil) -> ir.NewUnaryExpr(xpos, ir.OVARLIVE, l)
ir.NodAt(xpos, ir.OBLOCK, nil, nil) -> ir.NewBlockStmt(xpos, nil)
ir.NodAt(xpos, ir.OBREAK, nil, nil) -> ir.NewBranchStmt(xpos, ir.OBREAK, nil)
ir.NodAt(xpos, ir.OCONTINUE, nil, nil) -> ir.NewBranchStmt(xpos, ir.OCONTINUE, nil)
ir.NodAt(xpos, ir.OFALL, nil, nil) -> ir.NewBranchStmt(xpos, ir.OFALL, nil)
ir.NodAt(xpos, ir.OGOTO, nil, nil) -> ir.NewBranchStmt(xpos, ir.OGOTO, nil)
ir.NodAt(xpos, ir.ORETJMP, nil, nil) -> ir.NewBranchStmt(xpos, ir.ORETJMP, nil)
ir.NodAt(xpos, ir.OCALL, l, nil) -> ir.NewCallExpr(xpos, ir.OCALL, l, nil)
ir.NodAt(xpos, ir.OCALLFUNC, l, nil) -> ir.NewCallExpr(xpos, ir.OCALLFUNC, l, nil)
ir.NodAt(xpos, ir.OCALLINTER, l, nil) -> ir.NewCallExpr(xpos, ir.OCALLINTER, l, nil)
ir.NodAt(xpos, ir.OCALLMETH, l, nil) -> ir.NewCallExpr(xpos, ir.OCALLMETH, l, nil)
ir.NodAt(xpos, ir.OAPPEND, l, nil) -> ir.NewCallExpr(xpos, ir.OAPPEND, l, nil)
ir.NodAt(xpos, ir.ODELETE, l, nil) -> ir.NewCallExpr(xpos, ir.ODELETE, l, nil)
ir.NodAt(xpos, ir.OGETG, l, nil) -> ir.NewCallExpr(xpos, ir.OGETG, l, nil)
ir.NodAt(xpos, ir.OMAKE, l, nil) -> ir.NewCallExpr(xpos, ir.OMAKE, l, nil)
ir.NodAt(xpos, ir.OPRINT, l, nil) -> ir.NewCallExpr(xpos, ir.OPRINT, l, nil)
ir.NodAt(xpos, ir.OPRINTN, l, nil) -> ir.NewCallExpr(xpos, ir.OPRINTN, l, nil)
ir.NodAt(xpos, ir.ORECOVER, l, nil) -> ir.NewCallExpr(xpos, ir.ORECOVER, l, nil)
ir.NodAt(xpos, ir.OCASE, nil, nil) -> ir.NewCaseStmt(xpos, nil, nil)
ir.NodAt(xpos, ir.OCONV, l, nil) -> ir.NewConvExpr(xpos, ir.OCONV, nil, l)
ir.NodAt(xpos, ir.OCONVIFACE, l, nil) -> ir.NewConvExpr(xpos, ir.OCONVIFACE, nil, l)
ir.NodAt(xpos, ir.OCONVNOP, l, nil) -> ir.NewConvExpr(xpos, ir.OCONVNOP, nil, l)
ir.NodAt(xpos, ir.ORUNESTR, l, nil) -> ir.NewConvExpr(xpos, ir.ORUNESTR, nil, l)
ir.NodAt(xpos, ir.ODCL, l, nil) -> ir.NewDecl(xpos, ir.ODCL, l)
ir.NodAt(xpos, ir.ODCLCONST, l, nil) -> ir.NewDecl(xpos, ir.ODCLCONST, l)
ir.NodAt(xpos, ir.ODCLTYPE, l, nil) -> ir.NewDecl(xpos, ir.ODCLTYPE, l)
ir.NodAt(xpos, ir.ODCLFUNC, nil, nil) -> ir.NewFunc(xpos)
ir.NodAt(xpos, ir.ODEFER, l, nil) -> ir.NewGoDeferStmt(xpos, ir.ODEFER, l)
ir.NodAt(xpos, ir.OGO, l, nil) -> ir.NewGoDeferStmt(xpos, ir.OGO, l)
ir.NodAt(xpos, ir.ODEREF, l, nil) -> ir.NewStarExpr(xpos, l)
ir.NodAt(xpos, ir.ODOT, l, nil) -> ir.NewSelectorExpr(xpos, ir.ODOT, l, nil)
ir.NodAt(xpos, ir.ODOTPTR, l, nil) -> ir.NewSelectorExpr(xpos, ir.ODOTPTR, l, nil)
ir.NodAt(xpos, ir.ODOTMETH, l, nil) -> ir.NewSelectorExpr(xpos, ir.ODOTMETH, l, nil)
ir.NodAt(xpos, ir.ODOTINTER, l, nil) -> ir.NewSelectorExpr(xpos, ir.ODOTINTER, l, nil)
ir.NodAt(xpos, ir.OXDOT, l, nil) -> ir.NewSelectorExpr(xpos, ir.OXDOT, l, nil)
ir.NodAt(xpos, ir.ODOTTYPE, l, nil) -> ir.NewTypeAssertExpr(xpos, l, nil)
ir.NodAt(xpos, ir.ODOTTYPE, l, r) -> ir.NewTypeAssertExpr(xpos, l, r.(ir.Ntype))
ir.NodAt(xpos, ir.OFOR, l, r) -> ir.NewForStmt(xpos, nil, l, r, nil)
ir.NodAt(xpos, ir.OINDEX, l, r) -> ir.NewIndexExpr(xpos, l, r)
ir.NodAt(xpos, ir.OINLMARK, nil, nil) -> ir.NewInlineMarkStmt(xpos, types.BADWIDTH)
ir.NodAt(xpos, ir.OKEY, l, r) -> ir.NewKeyExpr(xpos, l, r)
ir.NodAt(xpos, ir.OLABEL, nil, nil) -> ir.NewLabelStmt(xpos, nil)
ir.NodAt(xpos, ir.OMAKECHAN, l, r) -> ir.NewMakeExpr(xpos, ir.OMAKECHAN, l, r)
ir.NodAt(xpos, ir.OMAKEMAP, l, r) -> ir.NewMakeExpr(xpos, ir.OMAKEMAP, l, r)
ir.NodAt(xpos, ir.OMAKESLICE, l, r) -> ir.NewMakeExpr(xpos, ir.OMAKESLICE, l, r)
ir.NodAt(xpos, ir.OMAKESLICECOPY, l, r) -> ir.NewMakeExpr(xpos, ir.OMAKESLICECOPY, l, r)
ir.NodAt(xpos, ir.ONIL, nil, nil) -> ir.NewNilExpr(xpos)
ir.NodAt(xpos, ir.OPACK, nil, nil) -> ir.NewPkgName(xpos, nil, nil)
ir.NodAt(xpos, ir.OPAREN, l, nil) -> ir.NewParenExpr(xpos, l)
ir.NodAt(xpos, ir.ORANGE, nil, r) -> ir.NewRangeStmt(xpos, nil, r, nil)
ir.NodAt(xpos, ir.ORESULT, nil, nil) -> ir.NewResultExpr(xpos, nil, types.BADWIDTH)
ir.NodAt(xpos, ir.ORETURN, nil, nil) -> ir.NewReturnStmt(xpos, nil)
ir.NodAt(xpos, ir.OSELECT, nil, nil) -> ir.NewSelectStmt(xpos, nil)
ir.NodAt(xpos, ir.OSEND, l, r) -> ir.NewSendStmt(xpos, l, r)
ir.NodAt(xpos, ir.OSLICE, l, nil) -> ir.NewSliceExpr(xpos, ir.OSLICE, l)
ir.NodAt(xpos, ir.OSLICEARR, l, nil) -> ir.NewSliceExpr(xpos, ir.OSLICEARR, l)
ir.NodAt(xpos, ir.OSLICESTR, l, nil) -> ir.NewSliceExpr(xpos, ir.OSLICESTR, l)
ir.NodAt(xpos, ir.OSLICE3, l, nil) -> ir.NewSliceExpr(xpos, ir.OSLICE3, l)
ir.NodAt(xpos, ir.OSLICE3ARR, l, nil) -> ir.NewSliceExpr(xpos, ir.OSLICE3ARR, l)
ir.NodAt(xpos, ir.OSLICEHEADER, l, nil) -> ir.NewSliceHeaderExpr(xpos, nil, l, nil, nil)
ir.NodAt(xpos, ir.OSWITCH, l, nil) -> ir.NewSwitchStmt(xpos, l, nil)
ir.NodAt(xpos, ir.OINLCALL, nil, nil) -> ir.NewInlinedCallExpr(xpos, nil, nil)
}
rm noder.nod noder.nodSym nodSym nodlSym ir.NodAt ir.Nod
'
Change-Id: Ibf1eb708de8463ae74ccc47d7966cc263a18295e
Reviewed-on: https://go-review.googlesource.com/c/go/+/277933
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2020-12-22 23:55:29 -05:00
|
|
|
return []ir.Node{r, ir.NewBranchStmt(base.Pos, ir.OBREAK, nil)}
|
2015-02-13 14:40:36 -05:00
|
|
|
}
|
|
|
|
|
2020-07-27 16:19:15 -07:00
|
|
|
if dflt != nil {
|
|
|
|
ncas--
|
|
|
|
}
|
[dev.regabi] cmd/compile: cleanup for concrete types - range, select, swt
An automated rewrite will add concrete type assertions after
a test of n.Op(), when n can be safely type-asserted
(meaning, n is not reassigned a different type, n is not reassigned
and then used outside the scope of the type assertion,
and so on).
This sequence of CLs handles the code that the automated
rewrite does not: adding specific types to function arguments,
adjusting code not to call n.Left() etc when n may have multiple
representations, and so on.
This CL focuses on range.go, select.go, and swt.go: the big
control structures.
Passes buildall w/ toolstash -cmp.
Change-Id: I033fe056a7b815edb6e8a06f45c12ffd990f4d45
Reviewed-on: https://go-review.googlesource.com/c/go/+/277929
Trust: Russ Cox <rsc@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2020-12-10 18:47:32 -05:00
|
|
|
casorder := make([]*ir.CaseStmt, ncas)
|
2020-07-27 16:19:15 -07:00
|
|
|
nsends, nrecvs := 0, 0
|
|
|
|
|
[dev.regabi] cmd/compile: replace *Node type with an interface Node [generated]
The plan is to introduce a Node interface that replaces the old *Node pointer-to-struct.
The previous CL defined an interface INode modeling a *Node.
This CL:
- Changes all references outside internal/ir to use INode,
along with many references inside internal/ir as well.
- Renames Node to node.
- Renames INode to Node
So now ir.Node is an interface implemented by *ir.node, which is otherwise inaccessible,
and the code outside package ir is now (clearly) using only the interface.
The usual rule is never to redefine an existing name with a new meaning,
so that old code that hasn't been updated gets a "unknown name" error
instead of more mysterious errors or silent misbehavior. That rule would
caution against replacing Node-the-struct with Node-the-interface,
as in this CL, because code that says *Node would now be using a pointer
to an interface. But this CL is being landed at the same time as another that
moves Node from gc to ir. So the net effect is to replace *gc.Node with ir.Node,
which does follow the rule: any lingering references to gc.Node will be told
it's gone, not silently start using pointers to interfaces. So the rule is followed
by the CL sequence, just not this specific CL.
Overall, the loss of inlining caused by using interfaces cuts the compiler speed
by about 6%, a not insignificant amount. However, as we convert the representation
to concrete structs that are not the giant Node over the next weeks, that speed
should come back as more of the compiler starts operating directly on concrete types
and the memory taken up by the graph of Nodes drops due to the more precise
structs. Honestly, I was expecting worse.
% benchstat bench.old bench.new
name old time/op new time/op delta
Template 168ms ± 4% 182ms ± 2% +8.34% (p=0.000 n=9+9)
Unicode 72.2ms ±10% 82.5ms ± 6% +14.38% (p=0.000 n=9+9)
GoTypes 563ms ± 8% 598ms ± 2% +6.14% (p=0.006 n=9+9)
Compiler 2.89s ± 4% 3.04s ± 2% +5.37% (p=0.000 n=10+9)
SSA 6.45s ± 4% 7.25s ± 5% +12.41% (p=0.000 n=9+10)
Flate 105ms ± 2% 115ms ± 1% +9.66% (p=0.000 n=10+8)
GoParser 144ms ±10% 152ms ± 2% +5.79% (p=0.011 n=9+8)
Reflect 345ms ± 9% 370ms ± 4% +7.28% (p=0.001 n=10+9)
Tar 149ms ± 9% 161ms ± 5% +8.05% (p=0.001 n=10+9)
XML 190ms ± 3% 209ms ± 2% +9.54% (p=0.000 n=9+8)
LinkCompiler 327ms ± 2% 325ms ± 2% ~ (p=0.382 n=8+8)
ExternalLinkCompiler 1.77s ± 4% 1.73s ± 6% ~ (p=0.113 n=9+10)
LinkWithoutDebugCompiler 214ms ± 4% 211ms ± 2% ~ (p=0.360 n=10+8)
StdCmd 14.8s ± 3% 15.9s ± 1% +6.98% (p=0.000 n=10+9)
[Geo mean] 480ms 510ms +6.31%
name old user-time/op new user-time/op delta
Template 223ms ± 3% 237ms ± 3% +6.16% (p=0.000 n=9+10)
Unicode 103ms ± 6% 113ms ± 3% +9.53% (p=0.000 n=9+9)
GoTypes 758ms ± 8% 800ms ± 2% +5.55% (p=0.003 n=10+9)
Compiler 3.95s ± 2% 4.12s ± 2% +4.34% (p=0.000 n=10+9)
SSA 9.43s ± 1% 9.74s ± 4% +3.25% (p=0.000 n=8+10)
Flate 132ms ± 2% 141ms ± 2% +6.89% (p=0.000 n=9+9)
GoParser 177ms ± 9% 183ms ± 4% ~ (p=0.050 n=9+9)
Reflect 467ms ±10% 495ms ± 7% +6.17% (p=0.029 n=10+10)
Tar 183ms ± 9% 197ms ± 5% +7.92% (p=0.001 n=10+10)
XML 249ms ± 5% 268ms ± 4% +7.82% (p=0.000 n=10+9)
LinkCompiler 544ms ± 5% 544ms ± 6% ~ (p=0.863 n=9+9)
ExternalLinkCompiler 1.79s ± 4% 1.75s ± 6% ~ (p=0.075 n=10+10)
LinkWithoutDebugCompiler 248ms ± 6% 246ms ± 2% ~ (p=0.965 n=10+8)
[Geo mean] 483ms 504ms +4.41%
[git-generate]
cd src/cmd/compile/internal/ir
: # We need to do the conversion in multiple steps, so we introduce
: # a temporary type alias that will start out meaning the pointer-to-struct
: # and then change to mean the interface.
rf '
mv Node OldNode
add node.go \
type Node = *OldNode
'
: # It should work to do this ex in ir, but it misses test files, due to a bug in rf.
: # Run the command in gc to handle gc's tests, and then again in ssa for ssa's tests.
cd ../gc
rf '
ex . ../arm ../riscv64 ../arm64 ../mips64 ../ppc64 ../mips ../wasm {
import "cmd/compile/internal/ir"
*ir.OldNode -> ir.Node
}
'
cd ../ssa
rf '
ex {
import "cmd/compile/internal/ir"
*ir.OldNode -> ir.Node
}
'
: # Back in ir, finish conversion clumsily with sed,
: # because type checking and circular aliases do not mix.
cd ../ir
sed -i '' '
/type Node = \*OldNode/d
s/\*OldNode/Node/g
s/^func (n Node)/func (n *OldNode)/
s/OldNode/node/g
s/type INode interface/type Node interface/
s/var _ INode = (Node)(nil)/var _ Node = (*node)(nil)/
' *.go
gofmt -w *.go
sed -i '' '
s/{Func{}, 136, 248}/{Func{}, 152, 280}/
s/{Name{}, 32, 56}/{Name{}, 44, 80}/
s/{Param{}, 24, 48}/{Param{}, 44, 88}/
s/{node{}, 76, 128}/{node{}, 88, 152}/
' sizeof_test.go
cd ../ssa
sed -i '' '
s/{LocalSlot{}, 28, 40}/{LocalSlot{}, 32, 48}/
' sizeof_test.go
cd ../gc
sed -i '' 's/\*ir.Node/ir.Node/' mkbuiltin.go
cd ../../../..
go install std cmd
cd cmd/compile
go test -u || go test -u
Change-Id: I196bbe3b648e4701662e4a2bada40bf155e2a553
Reviewed-on: https://go-review.googlesource.com/c/go/+/272935
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2020-11-25 01:11:56 -05:00
|
|
|
var init []ir.Node
|
2015-02-13 14:40:36 -05:00
|
|
|
|
|
|
|
// generate sel-struct
|
2020-11-19 20:49:23 -05:00
|
|
|
base.Pos = sellineno
|
2020-07-27 16:19:15 -07:00
|
|
|
selv := temp(types.NewArray(scasetype(), int64(ncas)))
|
[dev.regabi] cmd/compile: remove ir.Nod [generated]
Rewrite all uses of ir.Nod and friends to call the IR constructors directly.
This gives the results a more specific type and will play nicely with
introduction of more specific types throughout the code in a followup CL.
Passes buildall w/ toolstash -cmp.
[git-generate]
cd src/cmd/compile/internal/gc
rf '
ex . ../ir {
import "cmd/compile/internal/ir"
import "cmd/compile/internal/types"
import "cmd/compile/internal/syntax"
import "cmd/internal/src"
var p *noder
var orig syntax.Node
var op ir.Op
var l, r ir.Node
var sym *types.Sym
p.nod(orig, op, l, r) -> ir.NodAt(p.pos(orig), op, l, r)
p.nodSym(orig, op, l, sym) -> nodlSym(p.pos(orig), op, l, sym)
var xpos src.XPos
var ns ir.Nodes
npos(xpos, nodSym(op, l, sym)) -> nodlSym(xpos, op, l, sym)
npos(xpos, liststmt(ns)) -> ir.NewBlockStmt(xpos, ns)
}
ex . ../ir {
import "cmd/compile/internal/base"
import "cmd/compile/internal/ir"
import "cmd/compile/internal/types"
var op ir.Op
var l, r ir.Node
ir.Nod(op, l, r) -> ir.NodAt(base.Pos, op, l, r)
var sym *types.Sym
nodSym(op, l, sym) -> nodlSym(base.Pos, op, l, sym)
}
ex . ../ir {
import "cmd/compile/internal/ir"
import "cmd/internal/src"
# rf overlapping match handling is not quite good enough
# for certain nested rewrites, so handle these two - which often contain other ir.NodAt calls - early.
var l, r ir.Node
var xpos src.XPos
ir.NodAt(xpos, ir.OAS, l, r) -> ir.NewAssignStmt(xpos, l, r)
ir.NodAt(xpos, ir.OIF, l, nil) -> ir.NewIfStmt(xpos, l, nil, nil)
}
ex . ../ir {
import "cmd/compile/internal/ir"
import "cmd/compile/internal/types"
import "cmd/internal/src"
var l, r ir.Node
var sym *types.Sym
var xpos src.XPos
nodlSym(xpos, ir.ODOT, l, sym) -> ir.NewSelectorExpr(xpos, ir.ODOT, l, sym)
nodlSym(xpos, ir.OXDOT, l, sym) -> ir.NewSelectorExpr(xpos, ir.OXDOT, l, sym)
nodlSym(xpos, ir.ODOTPTR, l, sym) -> ir.NewSelectorExpr(xpos, ir.ODOTPTR, l, sym)
nodlSym(xpos, ir.OGOTO, nil, sym) -> ir.NewBranchStmt(xpos, ir.OGOTO, sym)
nodlSym(xpos, ir.ORETJMP, nil, sym) -> ir.NewBranchStmt(xpos, ir.ORETJMP, sym)
nodlSym(xpos, ir.OLABEL, nil, sym) -> ir.NewLabelStmt(xpos, sym)
nodlSym(xpos, ir.OSTRUCTKEY, l, sym) -> ir.NewStructKeyExpr(xpos, sym, l)
ir.NodAt(xpos, ir.OADD, l, r) -> ir.NewBinaryExpr(xpos, ir.OADD, l, r)
ir.NodAt(xpos, ir.OAND, l, r) -> ir.NewBinaryExpr(xpos, ir.OAND, l, r)
ir.NodAt(xpos, ir.OANDNOT, l, r) -> ir.NewBinaryExpr(xpos, ir.OANDNOT, l, r)
ir.NodAt(xpos, ir.ODIV, l, r) -> ir.NewBinaryExpr(xpos, ir.ODIV, l, r)
ir.NodAt(xpos, ir.OEQ, l, r) -> ir.NewBinaryExpr(xpos, ir.OEQ, l, r)
ir.NodAt(xpos, ir.OGE, l, r) -> ir.NewBinaryExpr(xpos, ir.OGE, l, r)
ir.NodAt(xpos, ir.OGT, l, r) -> ir.NewBinaryExpr(xpos, ir.OGT, l, r)
ir.NodAt(xpos, ir.OLE, l, r) -> ir.NewBinaryExpr(xpos, ir.OLE, l, r)
ir.NodAt(xpos, ir.OLSH, l, r) -> ir.NewBinaryExpr(xpos, ir.OLSH, l, r)
ir.NodAt(xpos, ir.OLT, l, r) -> ir.NewBinaryExpr(xpos, ir.OLT, l, r)
ir.NodAt(xpos, ir.OMOD, l, r) -> ir.NewBinaryExpr(xpos, ir.OMOD, l, r)
ir.NodAt(xpos, ir.OMUL, l, r) -> ir.NewBinaryExpr(xpos, ir.OMUL, l, r)
ir.NodAt(xpos, ir.ONE, l, r) -> ir.NewBinaryExpr(xpos, ir.ONE, l, r)
ir.NodAt(xpos, ir.OOR, l, r) -> ir.NewBinaryExpr(xpos, ir.OOR, l, r)
ir.NodAt(xpos, ir.ORSH, l, r) -> ir.NewBinaryExpr(xpos, ir.ORSH, l, r)
ir.NodAt(xpos, ir.OSUB, l, r) -> ir.NewBinaryExpr(xpos, ir.OSUB, l, r)
ir.NodAt(xpos, ir.OXOR, l, r) -> ir.NewBinaryExpr(xpos, ir.OXOR, l, r)
ir.NodAt(xpos, ir.OCOPY, l, r) -> ir.NewBinaryExpr(xpos, ir.OCOPY, l, r)
ir.NodAt(xpos, ir.OCOMPLEX, l, r) -> ir.NewBinaryExpr(xpos, ir.OCOMPLEX, l, r)
ir.NodAt(xpos, ir.OEFACE, l, r) -> ir.NewBinaryExpr(xpos, ir.OEFACE, l, r)
ir.NodAt(xpos, ir.OADDR, l, nil) -> ir.NewAddrExpr(xpos, l)
ir.NodAt(xpos, ir.OADDSTR, nil, nil) -> ir.NewAddStringExpr(xpos, nil)
ir.NodAt(xpos, ir.OANDAND, l, r) -> ir.NewLogicalExpr(xpos, ir.OANDAND, l, r)
ir.NodAt(xpos, ir.OOROR, l, r) -> ir.NewLogicalExpr(xpos, ir.OOROR, l, r)
ir.NodAt(xpos, ir.OARRAYLIT, nil, nil) -> ir.NewCompLitExpr(xpos, ir.OARRAYLIT, nil, nil)
ir.NodAt(xpos, ir.OCOMPLIT, nil, nil) -> ir.NewCompLitExpr(xpos, ir.OCOMPLIT, nil, nil)
ir.NodAt(xpos, ir.OMAPLIT, nil, nil) -> ir.NewCompLitExpr(xpos, ir.OMAPLIT, nil, nil)
ir.NodAt(xpos, ir.OSTRUCTLIT, nil, nil) -> ir.NewCompLitExpr(xpos, ir.OSTRUCTLIT, nil, nil)
ir.NodAt(xpos, ir.OSLICELIT, nil, nil) -> ir.NewCompLitExpr(xpos, ir.OSLICELIT, nil, nil)
ir.NodAt(xpos, ir.OARRAYLIT, nil, r) -> ir.NewCompLitExpr(xpos, ir.OARRAYLIT, r.(ir.Ntype), nil)
ir.NodAt(xpos, ir.OCOMPLIT, nil, r) -> ir.NewCompLitExpr(xpos, ir.OCOMPLIT, r.(ir.Ntype), nil)
ir.NodAt(xpos, ir.OMAPLIT, nil, r) -> ir.NewCompLitExpr(xpos, ir.OMAPLIT, r.(ir.Ntype), nil)
ir.NodAt(xpos, ir.OSTRUCTLIT, nil, r) -> ir.NewCompLitExpr(xpos, ir.OSTRUCTLIT, r.(ir.Ntype), nil)
ir.NodAt(xpos, ir.OSLICELIT, nil, r) -> ir.NewCompLitExpr(xpos, ir.OSLICELIT, r.(ir.Ntype), nil)
ir.NodAt(xpos, ir.OAS2, nil, nil) -> ir.NewAssignListStmt(xpos, ir.OAS2, nil, nil)
ir.NodAt(xpos, ir.OAS2DOTTYPE, nil, nil) -> ir.NewAssignListStmt(xpos, ir.OAS2DOTTYPE, nil, nil)
ir.NodAt(xpos, ir.OAS2FUNC, nil, nil) -> ir.NewAssignListStmt(xpos, ir.OAS2FUNC, nil, nil)
ir.NodAt(xpos, ir.OAS2MAPR, nil, nil) -> ir.NewAssignListStmt(xpos, ir.OAS2MAPR, nil, nil)
ir.NodAt(xpos, ir.OAS2RECV, nil, nil) -> ir.NewAssignListStmt(xpos, ir.OAS2RECV, nil, nil)
ir.NodAt(xpos, ir.OSELRECV2, nil, nil) -> ir.NewAssignListStmt(xpos, ir.OSELRECV2, nil, nil)
ir.NodAt(xpos, ir.OASOP, l, r) -> ir.NewAssignOpStmt(xpos, ir.OXXX, l, r)
ir.NodAt(xpos, ir.OBITNOT, l, nil) -> ir.NewUnaryExpr(xpos, ir.OBITNOT, l)
ir.NodAt(xpos, ir.ONEG, l, nil) -> ir.NewUnaryExpr(xpos, ir.ONEG, l)
ir.NodAt(xpos, ir.ONOT, l, nil) -> ir.NewUnaryExpr(xpos, ir.ONOT, l)
ir.NodAt(xpos, ir.OPLUS, l, nil) -> ir.NewUnaryExpr(xpos, ir.OPLUS, l)
ir.NodAt(xpos, ir.ORECV, l, nil) -> ir.NewUnaryExpr(xpos, ir.ORECV, l)
ir.NodAt(xpos, ir.OALIGNOF, l, nil) -> ir.NewUnaryExpr(xpos, ir.OALIGNOF, l)
ir.NodAt(xpos, ir.OCAP, l, nil) -> ir.NewUnaryExpr(xpos, ir.OCAP, l)
ir.NodAt(xpos, ir.OCLOSE, l, nil) -> ir.NewUnaryExpr(xpos, ir.OCLOSE, l)
ir.NodAt(xpos, ir.OIMAG, l, nil) -> ir.NewUnaryExpr(xpos, ir.OIMAG, l)
ir.NodAt(xpos, ir.OLEN, l, nil) -> ir.NewUnaryExpr(xpos, ir.OLEN, l)
ir.NodAt(xpos, ir.ONEW, l, nil) -> ir.NewUnaryExpr(xpos, ir.ONEW, l)
ir.NodAt(xpos, ir.ONEWOBJ, l, nil) -> ir.NewUnaryExpr(xpos, ir.ONEWOBJ, l)
ir.NodAt(xpos, ir.OOFFSETOF, l, nil) -> ir.NewUnaryExpr(xpos, ir.OOFFSETOF, l)
ir.NodAt(xpos, ir.OPANIC, l, nil) -> ir.NewUnaryExpr(xpos, ir.OPANIC, l)
ir.NodAt(xpos, ir.OREAL, l, nil) -> ir.NewUnaryExpr(xpos, ir.OREAL, l)
ir.NodAt(xpos, ir.OSIZEOF, l, nil) -> ir.NewUnaryExpr(xpos, ir.OSIZEOF, l)
ir.NodAt(xpos, ir.OCHECKNIL, l, nil) -> ir.NewUnaryExpr(xpos, ir.OCHECKNIL, l)
ir.NodAt(xpos, ir.OCFUNC, l, nil) -> ir.NewUnaryExpr(xpos, ir.OCFUNC, l)
ir.NodAt(xpos, ir.OIDATA, l, nil) -> ir.NewUnaryExpr(xpos, ir.OIDATA, l)
ir.NodAt(xpos, ir.OITAB, l, nil) -> ir.NewUnaryExpr(xpos, ir.OITAB, l)
ir.NodAt(xpos, ir.OSPTR, l, nil) -> ir.NewUnaryExpr(xpos, ir.OSPTR, l)
ir.NodAt(xpos, ir.OVARDEF, l, nil) -> ir.NewUnaryExpr(xpos, ir.OVARDEF, l)
ir.NodAt(xpos, ir.OVARKILL, l, nil) -> ir.NewUnaryExpr(xpos, ir.OVARKILL, l)
ir.NodAt(xpos, ir.OVARLIVE, l, nil) -> ir.NewUnaryExpr(xpos, ir.OVARLIVE, l)
ir.NodAt(xpos, ir.OBLOCK, nil, nil) -> ir.NewBlockStmt(xpos, nil)
ir.NodAt(xpos, ir.OBREAK, nil, nil) -> ir.NewBranchStmt(xpos, ir.OBREAK, nil)
ir.NodAt(xpos, ir.OCONTINUE, nil, nil) -> ir.NewBranchStmt(xpos, ir.OCONTINUE, nil)
ir.NodAt(xpos, ir.OFALL, nil, nil) -> ir.NewBranchStmt(xpos, ir.OFALL, nil)
ir.NodAt(xpos, ir.OGOTO, nil, nil) -> ir.NewBranchStmt(xpos, ir.OGOTO, nil)
ir.NodAt(xpos, ir.ORETJMP, nil, nil) -> ir.NewBranchStmt(xpos, ir.ORETJMP, nil)
ir.NodAt(xpos, ir.OCALL, l, nil) -> ir.NewCallExpr(xpos, ir.OCALL, l, nil)
ir.NodAt(xpos, ir.OCALLFUNC, l, nil) -> ir.NewCallExpr(xpos, ir.OCALLFUNC, l, nil)
ir.NodAt(xpos, ir.OCALLINTER, l, nil) -> ir.NewCallExpr(xpos, ir.OCALLINTER, l, nil)
ir.NodAt(xpos, ir.OCALLMETH, l, nil) -> ir.NewCallExpr(xpos, ir.OCALLMETH, l, nil)
ir.NodAt(xpos, ir.OAPPEND, l, nil) -> ir.NewCallExpr(xpos, ir.OAPPEND, l, nil)
ir.NodAt(xpos, ir.ODELETE, l, nil) -> ir.NewCallExpr(xpos, ir.ODELETE, l, nil)
ir.NodAt(xpos, ir.OGETG, l, nil) -> ir.NewCallExpr(xpos, ir.OGETG, l, nil)
ir.NodAt(xpos, ir.OMAKE, l, nil) -> ir.NewCallExpr(xpos, ir.OMAKE, l, nil)
ir.NodAt(xpos, ir.OPRINT, l, nil) -> ir.NewCallExpr(xpos, ir.OPRINT, l, nil)
ir.NodAt(xpos, ir.OPRINTN, l, nil) -> ir.NewCallExpr(xpos, ir.OPRINTN, l, nil)
ir.NodAt(xpos, ir.ORECOVER, l, nil) -> ir.NewCallExpr(xpos, ir.ORECOVER, l, nil)
ir.NodAt(xpos, ir.OCASE, nil, nil) -> ir.NewCaseStmt(xpos, nil, nil)
ir.NodAt(xpos, ir.OCONV, l, nil) -> ir.NewConvExpr(xpos, ir.OCONV, nil, l)
ir.NodAt(xpos, ir.OCONVIFACE, l, nil) -> ir.NewConvExpr(xpos, ir.OCONVIFACE, nil, l)
ir.NodAt(xpos, ir.OCONVNOP, l, nil) -> ir.NewConvExpr(xpos, ir.OCONVNOP, nil, l)
ir.NodAt(xpos, ir.ORUNESTR, l, nil) -> ir.NewConvExpr(xpos, ir.ORUNESTR, nil, l)
ir.NodAt(xpos, ir.ODCL, l, nil) -> ir.NewDecl(xpos, ir.ODCL, l)
ir.NodAt(xpos, ir.ODCLCONST, l, nil) -> ir.NewDecl(xpos, ir.ODCLCONST, l)
ir.NodAt(xpos, ir.ODCLTYPE, l, nil) -> ir.NewDecl(xpos, ir.ODCLTYPE, l)
ir.NodAt(xpos, ir.ODCLFUNC, nil, nil) -> ir.NewFunc(xpos)
ir.NodAt(xpos, ir.ODEFER, l, nil) -> ir.NewGoDeferStmt(xpos, ir.ODEFER, l)
ir.NodAt(xpos, ir.OGO, l, nil) -> ir.NewGoDeferStmt(xpos, ir.OGO, l)
ir.NodAt(xpos, ir.ODEREF, l, nil) -> ir.NewStarExpr(xpos, l)
ir.NodAt(xpos, ir.ODOT, l, nil) -> ir.NewSelectorExpr(xpos, ir.ODOT, l, nil)
ir.NodAt(xpos, ir.ODOTPTR, l, nil) -> ir.NewSelectorExpr(xpos, ir.ODOTPTR, l, nil)
ir.NodAt(xpos, ir.ODOTMETH, l, nil) -> ir.NewSelectorExpr(xpos, ir.ODOTMETH, l, nil)
ir.NodAt(xpos, ir.ODOTINTER, l, nil) -> ir.NewSelectorExpr(xpos, ir.ODOTINTER, l, nil)
ir.NodAt(xpos, ir.OXDOT, l, nil) -> ir.NewSelectorExpr(xpos, ir.OXDOT, l, nil)
ir.NodAt(xpos, ir.ODOTTYPE, l, nil) -> ir.NewTypeAssertExpr(xpos, l, nil)
ir.NodAt(xpos, ir.ODOTTYPE, l, r) -> ir.NewTypeAssertExpr(xpos, l, r.(ir.Ntype))
ir.NodAt(xpos, ir.OFOR, l, r) -> ir.NewForStmt(xpos, nil, l, r, nil)
ir.NodAt(xpos, ir.OINDEX, l, r) -> ir.NewIndexExpr(xpos, l, r)
ir.NodAt(xpos, ir.OINLMARK, nil, nil) -> ir.NewInlineMarkStmt(xpos, types.BADWIDTH)
ir.NodAt(xpos, ir.OKEY, l, r) -> ir.NewKeyExpr(xpos, l, r)
ir.NodAt(xpos, ir.OLABEL, nil, nil) -> ir.NewLabelStmt(xpos, nil)
ir.NodAt(xpos, ir.OMAKECHAN, l, r) -> ir.NewMakeExpr(xpos, ir.OMAKECHAN, l, r)
ir.NodAt(xpos, ir.OMAKEMAP, l, r) -> ir.NewMakeExpr(xpos, ir.OMAKEMAP, l, r)
ir.NodAt(xpos, ir.OMAKESLICE, l, r) -> ir.NewMakeExpr(xpos, ir.OMAKESLICE, l, r)
ir.NodAt(xpos, ir.OMAKESLICECOPY, l, r) -> ir.NewMakeExpr(xpos, ir.OMAKESLICECOPY, l, r)
ir.NodAt(xpos, ir.ONIL, nil, nil) -> ir.NewNilExpr(xpos)
ir.NodAt(xpos, ir.OPACK, nil, nil) -> ir.NewPkgName(xpos, nil, nil)
ir.NodAt(xpos, ir.OPAREN, l, nil) -> ir.NewParenExpr(xpos, l)
ir.NodAt(xpos, ir.ORANGE, nil, r) -> ir.NewRangeStmt(xpos, nil, r, nil)
ir.NodAt(xpos, ir.ORESULT, nil, nil) -> ir.NewResultExpr(xpos, nil, types.BADWIDTH)
ir.NodAt(xpos, ir.ORETURN, nil, nil) -> ir.NewReturnStmt(xpos, nil)
ir.NodAt(xpos, ir.OSELECT, nil, nil) -> ir.NewSelectStmt(xpos, nil)
ir.NodAt(xpos, ir.OSEND, l, r) -> ir.NewSendStmt(xpos, l, r)
ir.NodAt(xpos, ir.OSLICE, l, nil) -> ir.NewSliceExpr(xpos, ir.OSLICE, l)
ir.NodAt(xpos, ir.OSLICEARR, l, nil) -> ir.NewSliceExpr(xpos, ir.OSLICEARR, l)
ir.NodAt(xpos, ir.OSLICESTR, l, nil) -> ir.NewSliceExpr(xpos, ir.OSLICESTR, l)
ir.NodAt(xpos, ir.OSLICE3, l, nil) -> ir.NewSliceExpr(xpos, ir.OSLICE3, l)
ir.NodAt(xpos, ir.OSLICE3ARR, l, nil) -> ir.NewSliceExpr(xpos, ir.OSLICE3ARR, l)
ir.NodAt(xpos, ir.OSLICEHEADER, l, nil) -> ir.NewSliceHeaderExpr(xpos, nil, l, nil, nil)
ir.NodAt(xpos, ir.OSWITCH, l, nil) -> ir.NewSwitchStmt(xpos, l, nil)
ir.NodAt(xpos, ir.OINLCALL, nil, nil) -> ir.NewInlinedCallExpr(xpos, nil, nil)
}
rm noder.nod noder.nodSym nodSym nodlSym ir.NodAt ir.Nod
'
Change-Id: Ibf1eb708de8463ae74ccc47d7966cc263a18295e
Reviewed-on: https://go-review.googlesource.com/c/go/+/277933
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2020-12-22 23:55:29 -05:00
|
|
|
init = append(init, typecheck(ir.NewAssignStmt(base.Pos, selv, nil), ctxStmt))
|
runtime: eliminate runtime.hselect
Now the registration phase looks like:
var cases [4]runtime.scases
var order [8]uint16
selectsend(&cases[0], c1, &v1)
selectrecv(&cases[1], c2, &v2, nil)
selectrecv(&cases[2], c3, &v3, &ok)
selectdefault(&cases[3])
chosen := selectgo(&cases[0], &order[0], 4)
Primarily, this is just preparation for having the compiler open-code
selectsend, selectrecv, and selectdefault.
As a minor benefit, order can now be layed out separately on the stack
in the pointer-free segment, so it won't take up space in the
function's stack pointer maps.
Change-Id: I5552ba594201efd31fcb40084da20b42ea569a45
Reviewed-on: https://go-review.googlesource.com/37933
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
2017-03-07 13:44:53 -08:00
|
|
|
|
2020-08-29 03:25:21 +07:00
|
|
|
// No initialization for order; runtime.selectgo is responsible for that.
|
[dev.regabi] cmd/compile: introduce cmd/compile/internal/ir [generated]
If we want to break up package gc at all, we will need to move
the compiler IR it defines into a separate package that can be
imported by packages that gc itself imports. This CL does that.
It also removes the TINT8 etc aliases so that all code is clear
about which package things are coming from.
This CL is automatically generated by the script below.
See the comments in the script for details about the changes.
[git-generate]
cd src/cmd/compile/internal/gc
rf '
# These names were never fully qualified
# when the types package was added.
# Do it now, to avoid confusion about where they live.
inline -rm \
Txxx \
TINT8 \
TUINT8 \
TINT16 \
TUINT16 \
TINT32 \
TUINT32 \
TINT64 \
TUINT64 \
TINT \
TUINT \
TUINTPTR \
TCOMPLEX64 \
TCOMPLEX128 \
TFLOAT32 \
TFLOAT64 \
TBOOL \
TPTR \
TFUNC \
TSLICE \
TARRAY \
TSTRUCT \
TCHAN \
TMAP \
TINTER \
TFORW \
TANY \
TSTRING \
TUNSAFEPTR \
TIDEAL \
TNIL \
TBLANK \
TFUNCARGS \
TCHANARGS \
NTYPE \
BADWIDTH
# esc.go and escape.go do not need to be split.
# Append esc.go onto the end of escape.go.
mv esc.go escape.go
# Pull out the type format installation from func Main,
# so it can be carried into package ir.
mv Main:/Sconv.=/-0,/TypeLinkSym/-1 InstallTypeFormats
# Names that need to be exported for use by code left in gc.
mv Isconst IsConst
mv asNode AsNode
mv asNodes AsNodes
mv asTypesNode AsTypesNode
mv basicnames BasicTypeNames
mv builtinpkg BuiltinPkg
mv consttype ConstType
mv dumplist DumpList
mv fdumplist FDumpList
mv fmtMode FmtMode
mv goopnames OpNames
mv inspect Inspect
mv inspectList InspectList
mv localpkg LocalPkg
mv nblank BlankNode
mv numImport NumImport
mv opprec OpPrec
mv origSym OrigSym
mv stmtwithinit StmtWithInit
mv dump DumpAny
mv fdump FDumpAny
mv nod Nod
mv nodl NodAt
mv newname NewName
mv newnamel NewNameAt
mv assertRepresents AssertValidTypeForConst
mv represents ValidTypeForConst
mv nodlit NewLiteral
# Types and fields that need to be exported for use by gc.
mv nowritebarrierrecCallSym SymAndPos
mv SymAndPos.lineno SymAndPos.Pos
mv SymAndPos.target SymAndPos.Sym
mv Func.lsym Func.LSym
mv Func.setWBPos Func.SetWBPos
mv Func.numReturns Func.NumReturns
mv Func.numDefers Func.NumDefers
mv Func.nwbrCalls Func.NWBRCalls
# initLSym is an algorithm left behind in gc,
# not an operation on Func itself.
mv Func.initLSym initLSym
mv nodeQueue NodeQueue
mv NodeQueue.empty NodeQueue.Empty
mv NodeQueue.popLeft NodeQueue.PopLeft
mv NodeQueue.pushRight NodeQueue.PushRight
# Many methods on Node are actually algorithms that
# would apply to any node implementation.
# Those become plain functions.
mv Node.funcname FuncName
mv Node.isBlank IsBlank
mv Node.isGoConst isGoConst
mv Node.isNil IsNil
mv Node.isParamHeapCopy isParamHeapCopy
mv Node.isParamStackCopy isParamStackCopy
mv Node.isSimpleName isSimpleName
mv Node.mayBeShared MayBeShared
mv Node.pkgFuncName PkgFuncName
mv Node.backingArrayPtrLen backingArrayPtrLen
mv Node.isterminating isTermNode
mv Node.labeledControl labeledControl
mv Nodes.isterminating isTermNodes
mv Nodes.sigerr fmtSignature
mv Node.MethodName methodExprName
mv Node.MethodFunc methodExprFunc
mv Node.IsMethod IsMethod
# Every node will need to implement RawCopy;
# Copy and SepCopy algorithms will use it.
mv Node.rawcopy Node.RawCopy
mv Node.copy Copy
mv Node.sepcopy SepCopy
# Extract Node.Format method body into func FmtNode,
# but leave method wrapper behind.
mv Node.Format:0,$ FmtNode
# Formatting helpers that will apply to all node implementations.
mv Node.Line Line
mv Node.exprfmt exprFmt
mv Node.jconv jconvFmt
mv Node.modeString modeString
mv Node.nconv nconvFmt
mv Node.nodedump nodeDumpFmt
mv Node.nodefmt nodeFmt
mv Node.stmtfmt stmtFmt
# Constant support needed for code moving to ir.
mv okforconst OKForConst
mv vconv FmtConst
mv int64Val Int64Val
mv float64Val Float64Val
mv Node.ValueInterface ConstValue
# Organize code into files.
mv LocalPkg BuiltinPkg ir.go
mv NumImport InstallTypeFormats Line fmt.go
mv syntax.go Nod NodAt NewNameAt Class Pxxx PragmaFlag Nointerface SymAndPos \
AsNode AsTypesNode BlankNode OrigSym \
Node.SliceBounds Node.SetSliceBounds Op.IsSlice3 \
IsConst Node.Int64Val Node.CanInt64 Node.Uint64Val Node.BoolVal Node.StringVal \
Node.RawCopy SepCopy Copy \
IsNil IsBlank IsMethod \
Node.Typ Node.StorageClass node.go
mv ConstType ConstValue Int64Val Float64Val AssertValidTypeForConst ValidTypeForConst NewLiteral idealType OKForConst val.go
# Move files to new ir package.
mv bitset.go class_string.go dump.go fmt.go \
ir.go node.go op_string.go val.go \
sizeof_test.go cmd/compile/internal/ir
'
: # fix mkbuiltin.go to generate the changes made to builtin.go during rf
sed -i '' '
s/\[T/[types.T/g
s/\*Node/*ir.Node/g
/internal\/types/c \
fmt.Fprintln(&b, `import (`) \
fmt.Fprintln(&b, ` "cmd/compile/internal/ir"`) \
fmt.Fprintln(&b, ` "cmd/compile/internal/types"`) \
fmt.Fprintln(&b, `)`)
' mkbuiltin.go
gofmt -w mkbuiltin.go
: # update cmd/dist to add internal/ir
cd ../../../dist
sed -i '' '/compile.internal.gc/a\
"cmd/compile/internal/ir",
' buildtool.go
gofmt -w buildtool.go
: # update cmd/compile TestFormats
cd ../..
go install std cmd
cd cmd/compile
go test -u || go test # first one updates but fails; second passes
Change-Id: I5f7caf6b20629b51970279e81231a3574d5b51db
Reviewed-on: https://go-review.googlesource.com/c/go/+/273008
Trust: Russ Cox <rsc@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2020-11-19 21:09:22 -05:00
|
|
|
order := temp(types.NewArray(types.Types[types.TUINT16], 2*int64(ncas)))
|
2017-03-01 15:50:57 -08:00
|
|
|
|
[dev.regabi] cmd/compile: replace *Node type with an interface Node [generated]
The plan is to introduce a Node interface that replaces the old *Node pointer-to-struct.
The previous CL defined an interface INode modeling a *Node.
This CL:
- Changes all references outside internal/ir to use INode,
along with many references inside internal/ir as well.
- Renames Node to node.
- Renames INode to Node
So now ir.Node is an interface implemented by *ir.node, which is otherwise inaccessible,
and the code outside package ir is now (clearly) using only the interface.
The usual rule is never to redefine an existing name with a new meaning,
so that old code that hasn't been updated gets a "unknown name" error
instead of more mysterious errors or silent misbehavior. That rule would
caution against replacing Node-the-struct with Node-the-interface,
as in this CL, because code that says *Node would now be using a pointer
to an interface. But this CL is being landed at the same time as another that
moves Node from gc to ir. So the net effect is to replace *gc.Node with ir.Node,
which does follow the rule: any lingering references to gc.Node will be told
it's gone, not silently start using pointers to interfaces. So the rule is followed
by the CL sequence, just not this specific CL.
Overall, the loss of inlining caused by using interfaces cuts the compiler speed
by about 6%, a not insignificant amount. However, as we convert the representation
to concrete structs that are not the giant Node over the next weeks, that speed
should come back as more of the compiler starts operating directly on concrete types
and the memory taken up by the graph of Nodes drops due to the more precise
structs. Honestly, I was expecting worse.
% benchstat bench.old bench.new
name old time/op new time/op delta
Template 168ms ± 4% 182ms ± 2% +8.34% (p=0.000 n=9+9)
Unicode 72.2ms ±10% 82.5ms ± 6% +14.38% (p=0.000 n=9+9)
GoTypes 563ms ± 8% 598ms ± 2% +6.14% (p=0.006 n=9+9)
Compiler 2.89s ± 4% 3.04s ± 2% +5.37% (p=0.000 n=10+9)
SSA 6.45s ± 4% 7.25s ± 5% +12.41% (p=0.000 n=9+10)
Flate 105ms ± 2% 115ms ± 1% +9.66% (p=0.000 n=10+8)
GoParser 144ms ±10% 152ms ± 2% +5.79% (p=0.011 n=9+8)
Reflect 345ms ± 9% 370ms ± 4% +7.28% (p=0.001 n=10+9)
Tar 149ms ± 9% 161ms ± 5% +8.05% (p=0.001 n=10+9)
XML 190ms ± 3% 209ms ± 2% +9.54% (p=0.000 n=9+8)
LinkCompiler 327ms ± 2% 325ms ± 2% ~ (p=0.382 n=8+8)
ExternalLinkCompiler 1.77s ± 4% 1.73s ± 6% ~ (p=0.113 n=9+10)
LinkWithoutDebugCompiler 214ms ± 4% 211ms ± 2% ~ (p=0.360 n=10+8)
StdCmd 14.8s ± 3% 15.9s ± 1% +6.98% (p=0.000 n=10+9)
[Geo mean] 480ms 510ms +6.31%
name old user-time/op new user-time/op delta
Template 223ms ± 3% 237ms ± 3% +6.16% (p=0.000 n=9+10)
Unicode 103ms ± 6% 113ms ± 3% +9.53% (p=0.000 n=9+9)
GoTypes 758ms ± 8% 800ms ± 2% +5.55% (p=0.003 n=10+9)
Compiler 3.95s ± 2% 4.12s ± 2% +4.34% (p=0.000 n=10+9)
SSA 9.43s ± 1% 9.74s ± 4% +3.25% (p=0.000 n=8+10)
Flate 132ms ± 2% 141ms ± 2% +6.89% (p=0.000 n=9+9)
GoParser 177ms ± 9% 183ms ± 4% ~ (p=0.050 n=9+9)
Reflect 467ms ±10% 495ms ± 7% +6.17% (p=0.029 n=10+10)
Tar 183ms ± 9% 197ms ± 5% +7.92% (p=0.001 n=10+10)
XML 249ms ± 5% 268ms ± 4% +7.82% (p=0.000 n=10+9)
LinkCompiler 544ms ± 5% 544ms ± 6% ~ (p=0.863 n=9+9)
ExternalLinkCompiler 1.79s ± 4% 1.75s ± 6% ~ (p=0.075 n=10+10)
LinkWithoutDebugCompiler 248ms ± 6% 246ms ± 2% ~ (p=0.965 n=10+8)
[Geo mean] 483ms 504ms +4.41%
[git-generate]
cd src/cmd/compile/internal/ir
: # We need to do the conversion in multiple steps, so we introduce
: # a temporary type alias that will start out meaning the pointer-to-struct
: # and then change to mean the interface.
rf '
mv Node OldNode
add node.go \
type Node = *OldNode
'
: # It should work to do this ex in ir, but it misses test files, due to a bug in rf.
: # Run the command in gc to handle gc's tests, and then again in ssa for ssa's tests.
cd ../gc
rf '
ex . ../arm ../riscv64 ../arm64 ../mips64 ../ppc64 ../mips ../wasm {
import "cmd/compile/internal/ir"
*ir.OldNode -> ir.Node
}
'
cd ../ssa
rf '
ex {
import "cmd/compile/internal/ir"
*ir.OldNode -> ir.Node
}
'
: # Back in ir, finish conversion clumsily with sed,
: # because type checking and circular aliases do not mix.
cd ../ir
sed -i '' '
/type Node = \*OldNode/d
s/\*OldNode/Node/g
s/^func (n Node)/func (n *OldNode)/
s/OldNode/node/g
s/type INode interface/type Node interface/
s/var _ INode = (Node)(nil)/var _ Node = (*node)(nil)/
' *.go
gofmt -w *.go
sed -i '' '
s/{Func{}, 136, 248}/{Func{}, 152, 280}/
s/{Name{}, 32, 56}/{Name{}, 44, 80}/
s/{Param{}, 24, 48}/{Param{}, 44, 88}/
s/{node{}, 76, 128}/{node{}, 88, 152}/
' sizeof_test.go
cd ../ssa
sed -i '' '
s/{LocalSlot{}, 28, 40}/{LocalSlot{}, 32, 48}/
' sizeof_test.go
cd ../gc
sed -i '' 's/\*ir.Node/ir.Node/' mkbuiltin.go
cd ../../../..
go install std cmd
cd cmd/compile
go test -u || go test -u
Change-Id: I196bbe3b648e4701662e4a2bada40bf155e2a553
Reviewed-on: https://go-review.googlesource.com/c/go/+/272935
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2020-11-25 01:11:56 -05:00
|
|
|
var pc0, pcs ir.Node
|
2020-11-19 20:49:23 -05:00
|
|
|
if base.Flag.Race {
|
[dev.regabi] cmd/compile: introduce cmd/compile/internal/ir [generated]
If we want to break up package gc at all, we will need to move
the compiler IR it defines into a separate package that can be
imported by packages that gc itself imports. This CL does that.
It also removes the TINT8 etc aliases so that all code is clear
about which package things are coming from.
This CL is automatically generated by the script below.
See the comments in the script for details about the changes.
[git-generate]
cd src/cmd/compile/internal/gc
rf '
# These names were never fully qualified
# when the types package was added.
# Do it now, to avoid confusion about where they live.
inline -rm \
Txxx \
TINT8 \
TUINT8 \
TINT16 \
TUINT16 \
TINT32 \
TUINT32 \
TINT64 \
TUINT64 \
TINT \
TUINT \
TUINTPTR \
TCOMPLEX64 \
TCOMPLEX128 \
TFLOAT32 \
TFLOAT64 \
TBOOL \
TPTR \
TFUNC \
TSLICE \
TARRAY \
TSTRUCT \
TCHAN \
TMAP \
TINTER \
TFORW \
TANY \
TSTRING \
TUNSAFEPTR \
TIDEAL \
TNIL \
TBLANK \
TFUNCARGS \
TCHANARGS \
NTYPE \
BADWIDTH
# esc.go and escape.go do not need to be split.
# Append esc.go onto the end of escape.go.
mv esc.go escape.go
# Pull out the type format installation from func Main,
# so it can be carried into package ir.
mv Main:/Sconv.=/-0,/TypeLinkSym/-1 InstallTypeFormats
# Names that need to be exported for use by code left in gc.
mv Isconst IsConst
mv asNode AsNode
mv asNodes AsNodes
mv asTypesNode AsTypesNode
mv basicnames BasicTypeNames
mv builtinpkg BuiltinPkg
mv consttype ConstType
mv dumplist DumpList
mv fdumplist FDumpList
mv fmtMode FmtMode
mv goopnames OpNames
mv inspect Inspect
mv inspectList InspectList
mv localpkg LocalPkg
mv nblank BlankNode
mv numImport NumImport
mv opprec OpPrec
mv origSym OrigSym
mv stmtwithinit StmtWithInit
mv dump DumpAny
mv fdump FDumpAny
mv nod Nod
mv nodl NodAt
mv newname NewName
mv newnamel NewNameAt
mv assertRepresents AssertValidTypeForConst
mv represents ValidTypeForConst
mv nodlit NewLiteral
# Types and fields that need to be exported for use by gc.
mv nowritebarrierrecCallSym SymAndPos
mv SymAndPos.lineno SymAndPos.Pos
mv SymAndPos.target SymAndPos.Sym
mv Func.lsym Func.LSym
mv Func.setWBPos Func.SetWBPos
mv Func.numReturns Func.NumReturns
mv Func.numDefers Func.NumDefers
mv Func.nwbrCalls Func.NWBRCalls
# initLSym is an algorithm left behind in gc,
# not an operation on Func itself.
mv Func.initLSym initLSym
mv nodeQueue NodeQueue
mv NodeQueue.empty NodeQueue.Empty
mv NodeQueue.popLeft NodeQueue.PopLeft
mv NodeQueue.pushRight NodeQueue.PushRight
# Many methods on Node are actually algorithms that
# would apply to any node implementation.
# Those become plain functions.
mv Node.funcname FuncName
mv Node.isBlank IsBlank
mv Node.isGoConst isGoConst
mv Node.isNil IsNil
mv Node.isParamHeapCopy isParamHeapCopy
mv Node.isParamStackCopy isParamStackCopy
mv Node.isSimpleName isSimpleName
mv Node.mayBeShared MayBeShared
mv Node.pkgFuncName PkgFuncName
mv Node.backingArrayPtrLen backingArrayPtrLen
mv Node.isterminating isTermNode
mv Node.labeledControl labeledControl
mv Nodes.isterminating isTermNodes
mv Nodes.sigerr fmtSignature
mv Node.MethodName methodExprName
mv Node.MethodFunc methodExprFunc
mv Node.IsMethod IsMethod
# Every node will need to implement RawCopy;
# Copy and SepCopy algorithms will use it.
mv Node.rawcopy Node.RawCopy
mv Node.copy Copy
mv Node.sepcopy SepCopy
# Extract Node.Format method body into func FmtNode,
# but leave method wrapper behind.
mv Node.Format:0,$ FmtNode
# Formatting helpers that will apply to all node implementations.
mv Node.Line Line
mv Node.exprfmt exprFmt
mv Node.jconv jconvFmt
mv Node.modeString modeString
mv Node.nconv nconvFmt
mv Node.nodedump nodeDumpFmt
mv Node.nodefmt nodeFmt
mv Node.stmtfmt stmtFmt
# Constant support needed for code moving to ir.
mv okforconst OKForConst
mv vconv FmtConst
mv int64Val Int64Val
mv float64Val Float64Val
mv Node.ValueInterface ConstValue
# Organize code into files.
mv LocalPkg BuiltinPkg ir.go
mv NumImport InstallTypeFormats Line fmt.go
mv syntax.go Nod NodAt NewNameAt Class Pxxx PragmaFlag Nointerface SymAndPos \
AsNode AsTypesNode BlankNode OrigSym \
Node.SliceBounds Node.SetSliceBounds Op.IsSlice3 \
IsConst Node.Int64Val Node.CanInt64 Node.Uint64Val Node.BoolVal Node.StringVal \
Node.RawCopy SepCopy Copy \
IsNil IsBlank IsMethod \
Node.Typ Node.StorageClass node.go
mv ConstType ConstValue Int64Val Float64Val AssertValidTypeForConst ValidTypeForConst NewLiteral idealType OKForConst val.go
# Move files to new ir package.
mv bitset.go class_string.go dump.go fmt.go \
ir.go node.go op_string.go val.go \
sizeof_test.go cmd/compile/internal/ir
'
: # fix mkbuiltin.go to generate the changes made to builtin.go during rf
sed -i '' '
s/\[T/[types.T/g
s/\*Node/*ir.Node/g
/internal\/types/c \
fmt.Fprintln(&b, `import (`) \
fmt.Fprintln(&b, ` "cmd/compile/internal/ir"`) \
fmt.Fprintln(&b, ` "cmd/compile/internal/types"`) \
fmt.Fprintln(&b, `)`)
' mkbuiltin.go
gofmt -w mkbuiltin.go
: # update cmd/dist to add internal/ir
cd ../../../dist
sed -i '' '/compile.internal.gc/a\
"cmd/compile/internal/ir",
' buildtool.go
gofmt -w buildtool.go
: # update cmd/compile TestFormats
cd ../..
go install std cmd
cd cmd/compile
go test -u || go test # first one updates but fails; second passes
Change-Id: I5f7caf6b20629b51970279e81231a3574d5b51db
Reviewed-on: https://go-review.googlesource.com/c/go/+/273008
Trust: Russ Cox <rsc@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2020-11-19 21:09:22 -05:00
|
|
|
pcs = temp(types.NewArray(types.Types[types.TUINTPTR], int64(ncas)))
|
[dev.regabi] cmd/compile: remove ir.Nod [generated]
Rewrite all uses of ir.Nod and friends to call the IR constructors directly.
This gives the results a more specific type and will play nicely with
introduction of more specific types throughout the code in a followup CL.
Passes buildall w/ toolstash -cmp.
[git-generate]
cd src/cmd/compile/internal/gc
rf '
ex . ../ir {
import "cmd/compile/internal/ir"
import "cmd/compile/internal/types"
import "cmd/compile/internal/syntax"
import "cmd/internal/src"
var p *noder
var orig syntax.Node
var op ir.Op
var l, r ir.Node
var sym *types.Sym
p.nod(orig, op, l, r) -> ir.NodAt(p.pos(orig), op, l, r)
p.nodSym(orig, op, l, sym) -> nodlSym(p.pos(orig), op, l, sym)
var xpos src.XPos
var ns ir.Nodes
npos(xpos, nodSym(op, l, sym)) -> nodlSym(xpos, op, l, sym)
npos(xpos, liststmt(ns)) -> ir.NewBlockStmt(xpos, ns)
}
ex . ../ir {
import "cmd/compile/internal/base"
import "cmd/compile/internal/ir"
import "cmd/compile/internal/types"
var op ir.Op
var l, r ir.Node
ir.Nod(op, l, r) -> ir.NodAt(base.Pos, op, l, r)
var sym *types.Sym
nodSym(op, l, sym) -> nodlSym(base.Pos, op, l, sym)
}
ex . ../ir {
import "cmd/compile/internal/ir"
import "cmd/internal/src"
# rf overlapping match handling is not quite good enough
# for certain nested rewrites, so handle these two - which often contain other ir.NodAt calls - early.
var l, r ir.Node
var xpos src.XPos
ir.NodAt(xpos, ir.OAS, l, r) -> ir.NewAssignStmt(xpos, l, r)
ir.NodAt(xpos, ir.OIF, l, nil) -> ir.NewIfStmt(xpos, l, nil, nil)
}
ex . ../ir {
import "cmd/compile/internal/ir"
import "cmd/compile/internal/types"
import "cmd/internal/src"
var l, r ir.Node
var sym *types.Sym
var xpos src.XPos
nodlSym(xpos, ir.ODOT, l, sym) -> ir.NewSelectorExpr(xpos, ir.ODOT, l, sym)
nodlSym(xpos, ir.OXDOT, l, sym) -> ir.NewSelectorExpr(xpos, ir.OXDOT, l, sym)
nodlSym(xpos, ir.ODOTPTR, l, sym) -> ir.NewSelectorExpr(xpos, ir.ODOTPTR, l, sym)
nodlSym(xpos, ir.OGOTO, nil, sym) -> ir.NewBranchStmt(xpos, ir.OGOTO, sym)
nodlSym(xpos, ir.ORETJMP, nil, sym) -> ir.NewBranchStmt(xpos, ir.ORETJMP, sym)
nodlSym(xpos, ir.OLABEL, nil, sym) -> ir.NewLabelStmt(xpos, sym)
nodlSym(xpos, ir.OSTRUCTKEY, l, sym) -> ir.NewStructKeyExpr(xpos, sym, l)
ir.NodAt(xpos, ir.OADD, l, r) -> ir.NewBinaryExpr(xpos, ir.OADD, l, r)
ir.NodAt(xpos, ir.OAND, l, r) -> ir.NewBinaryExpr(xpos, ir.OAND, l, r)
ir.NodAt(xpos, ir.OANDNOT, l, r) -> ir.NewBinaryExpr(xpos, ir.OANDNOT, l, r)
ir.NodAt(xpos, ir.ODIV, l, r) -> ir.NewBinaryExpr(xpos, ir.ODIV, l, r)
ir.NodAt(xpos, ir.OEQ, l, r) -> ir.NewBinaryExpr(xpos, ir.OEQ, l, r)
ir.NodAt(xpos, ir.OGE, l, r) -> ir.NewBinaryExpr(xpos, ir.OGE, l, r)
ir.NodAt(xpos, ir.OGT, l, r) -> ir.NewBinaryExpr(xpos, ir.OGT, l, r)
ir.NodAt(xpos, ir.OLE, l, r) -> ir.NewBinaryExpr(xpos, ir.OLE, l, r)
ir.NodAt(xpos, ir.OLSH, l, r) -> ir.NewBinaryExpr(xpos, ir.OLSH, l, r)
ir.NodAt(xpos, ir.OLT, l, r) -> ir.NewBinaryExpr(xpos, ir.OLT, l, r)
ir.NodAt(xpos, ir.OMOD, l, r) -> ir.NewBinaryExpr(xpos, ir.OMOD, l, r)
ir.NodAt(xpos, ir.OMUL, l, r) -> ir.NewBinaryExpr(xpos, ir.OMUL, l, r)
ir.NodAt(xpos, ir.ONE, l, r) -> ir.NewBinaryExpr(xpos, ir.ONE, l, r)
ir.NodAt(xpos, ir.OOR, l, r) -> ir.NewBinaryExpr(xpos, ir.OOR, l, r)
ir.NodAt(xpos, ir.ORSH, l, r) -> ir.NewBinaryExpr(xpos, ir.ORSH, l, r)
ir.NodAt(xpos, ir.OSUB, l, r) -> ir.NewBinaryExpr(xpos, ir.OSUB, l, r)
ir.NodAt(xpos, ir.OXOR, l, r) -> ir.NewBinaryExpr(xpos, ir.OXOR, l, r)
ir.NodAt(xpos, ir.OCOPY, l, r) -> ir.NewBinaryExpr(xpos, ir.OCOPY, l, r)
ir.NodAt(xpos, ir.OCOMPLEX, l, r) -> ir.NewBinaryExpr(xpos, ir.OCOMPLEX, l, r)
ir.NodAt(xpos, ir.OEFACE, l, r) -> ir.NewBinaryExpr(xpos, ir.OEFACE, l, r)
ir.NodAt(xpos, ir.OADDR, l, nil) -> ir.NewAddrExpr(xpos, l)
ir.NodAt(xpos, ir.OADDSTR, nil, nil) -> ir.NewAddStringExpr(xpos, nil)
ir.NodAt(xpos, ir.OANDAND, l, r) -> ir.NewLogicalExpr(xpos, ir.OANDAND, l, r)
ir.NodAt(xpos, ir.OOROR, l, r) -> ir.NewLogicalExpr(xpos, ir.OOROR, l, r)
ir.NodAt(xpos, ir.OARRAYLIT, nil, nil) -> ir.NewCompLitExpr(xpos, ir.OARRAYLIT, nil, nil)
ir.NodAt(xpos, ir.OCOMPLIT, nil, nil) -> ir.NewCompLitExpr(xpos, ir.OCOMPLIT, nil, nil)
ir.NodAt(xpos, ir.OMAPLIT, nil, nil) -> ir.NewCompLitExpr(xpos, ir.OMAPLIT, nil, nil)
ir.NodAt(xpos, ir.OSTRUCTLIT, nil, nil) -> ir.NewCompLitExpr(xpos, ir.OSTRUCTLIT, nil, nil)
ir.NodAt(xpos, ir.OSLICELIT, nil, nil) -> ir.NewCompLitExpr(xpos, ir.OSLICELIT, nil, nil)
ir.NodAt(xpos, ir.OARRAYLIT, nil, r) -> ir.NewCompLitExpr(xpos, ir.OARRAYLIT, r.(ir.Ntype), nil)
ir.NodAt(xpos, ir.OCOMPLIT, nil, r) -> ir.NewCompLitExpr(xpos, ir.OCOMPLIT, r.(ir.Ntype), nil)
ir.NodAt(xpos, ir.OMAPLIT, nil, r) -> ir.NewCompLitExpr(xpos, ir.OMAPLIT, r.(ir.Ntype), nil)
ir.NodAt(xpos, ir.OSTRUCTLIT, nil, r) -> ir.NewCompLitExpr(xpos, ir.OSTRUCTLIT, r.(ir.Ntype), nil)
ir.NodAt(xpos, ir.OSLICELIT, nil, r) -> ir.NewCompLitExpr(xpos, ir.OSLICELIT, r.(ir.Ntype), nil)
ir.NodAt(xpos, ir.OAS2, nil, nil) -> ir.NewAssignListStmt(xpos, ir.OAS2, nil, nil)
ir.NodAt(xpos, ir.OAS2DOTTYPE, nil, nil) -> ir.NewAssignListStmt(xpos, ir.OAS2DOTTYPE, nil, nil)
ir.NodAt(xpos, ir.OAS2FUNC, nil, nil) -> ir.NewAssignListStmt(xpos, ir.OAS2FUNC, nil, nil)
ir.NodAt(xpos, ir.OAS2MAPR, nil, nil) -> ir.NewAssignListStmt(xpos, ir.OAS2MAPR, nil, nil)
ir.NodAt(xpos, ir.OAS2RECV, nil, nil) -> ir.NewAssignListStmt(xpos, ir.OAS2RECV, nil, nil)
ir.NodAt(xpos, ir.OSELRECV2, nil, nil) -> ir.NewAssignListStmt(xpos, ir.OSELRECV2, nil, nil)
ir.NodAt(xpos, ir.OASOP, l, r) -> ir.NewAssignOpStmt(xpos, ir.OXXX, l, r)
ir.NodAt(xpos, ir.OBITNOT, l, nil) -> ir.NewUnaryExpr(xpos, ir.OBITNOT, l)
ir.NodAt(xpos, ir.ONEG, l, nil) -> ir.NewUnaryExpr(xpos, ir.ONEG, l)
ir.NodAt(xpos, ir.ONOT, l, nil) -> ir.NewUnaryExpr(xpos, ir.ONOT, l)
ir.NodAt(xpos, ir.OPLUS, l, nil) -> ir.NewUnaryExpr(xpos, ir.OPLUS, l)
ir.NodAt(xpos, ir.ORECV, l, nil) -> ir.NewUnaryExpr(xpos, ir.ORECV, l)
ir.NodAt(xpos, ir.OALIGNOF, l, nil) -> ir.NewUnaryExpr(xpos, ir.OALIGNOF, l)
ir.NodAt(xpos, ir.OCAP, l, nil) -> ir.NewUnaryExpr(xpos, ir.OCAP, l)
ir.NodAt(xpos, ir.OCLOSE, l, nil) -> ir.NewUnaryExpr(xpos, ir.OCLOSE, l)
ir.NodAt(xpos, ir.OIMAG, l, nil) -> ir.NewUnaryExpr(xpos, ir.OIMAG, l)
ir.NodAt(xpos, ir.OLEN, l, nil) -> ir.NewUnaryExpr(xpos, ir.OLEN, l)
ir.NodAt(xpos, ir.ONEW, l, nil) -> ir.NewUnaryExpr(xpos, ir.ONEW, l)
ir.NodAt(xpos, ir.ONEWOBJ, l, nil) -> ir.NewUnaryExpr(xpos, ir.ONEWOBJ, l)
ir.NodAt(xpos, ir.OOFFSETOF, l, nil) -> ir.NewUnaryExpr(xpos, ir.OOFFSETOF, l)
ir.NodAt(xpos, ir.OPANIC, l, nil) -> ir.NewUnaryExpr(xpos, ir.OPANIC, l)
ir.NodAt(xpos, ir.OREAL, l, nil) -> ir.NewUnaryExpr(xpos, ir.OREAL, l)
ir.NodAt(xpos, ir.OSIZEOF, l, nil) -> ir.NewUnaryExpr(xpos, ir.OSIZEOF, l)
ir.NodAt(xpos, ir.OCHECKNIL, l, nil) -> ir.NewUnaryExpr(xpos, ir.OCHECKNIL, l)
ir.NodAt(xpos, ir.OCFUNC, l, nil) -> ir.NewUnaryExpr(xpos, ir.OCFUNC, l)
ir.NodAt(xpos, ir.OIDATA, l, nil) -> ir.NewUnaryExpr(xpos, ir.OIDATA, l)
ir.NodAt(xpos, ir.OITAB, l, nil) -> ir.NewUnaryExpr(xpos, ir.OITAB, l)
ir.NodAt(xpos, ir.OSPTR, l, nil) -> ir.NewUnaryExpr(xpos, ir.OSPTR, l)
ir.NodAt(xpos, ir.OVARDEF, l, nil) -> ir.NewUnaryExpr(xpos, ir.OVARDEF, l)
ir.NodAt(xpos, ir.OVARKILL, l, nil) -> ir.NewUnaryExpr(xpos, ir.OVARKILL, l)
ir.NodAt(xpos, ir.OVARLIVE, l, nil) -> ir.NewUnaryExpr(xpos, ir.OVARLIVE, l)
ir.NodAt(xpos, ir.OBLOCK, nil, nil) -> ir.NewBlockStmt(xpos, nil)
ir.NodAt(xpos, ir.OBREAK, nil, nil) -> ir.NewBranchStmt(xpos, ir.OBREAK, nil)
ir.NodAt(xpos, ir.OCONTINUE, nil, nil) -> ir.NewBranchStmt(xpos, ir.OCONTINUE, nil)
ir.NodAt(xpos, ir.OFALL, nil, nil) -> ir.NewBranchStmt(xpos, ir.OFALL, nil)
ir.NodAt(xpos, ir.OGOTO, nil, nil) -> ir.NewBranchStmt(xpos, ir.OGOTO, nil)
ir.NodAt(xpos, ir.ORETJMP, nil, nil) -> ir.NewBranchStmt(xpos, ir.ORETJMP, nil)
ir.NodAt(xpos, ir.OCALL, l, nil) -> ir.NewCallExpr(xpos, ir.OCALL, l, nil)
ir.NodAt(xpos, ir.OCALLFUNC, l, nil) -> ir.NewCallExpr(xpos, ir.OCALLFUNC, l, nil)
ir.NodAt(xpos, ir.OCALLINTER, l, nil) -> ir.NewCallExpr(xpos, ir.OCALLINTER, l, nil)
ir.NodAt(xpos, ir.OCALLMETH, l, nil) -> ir.NewCallExpr(xpos, ir.OCALLMETH, l, nil)
ir.NodAt(xpos, ir.OAPPEND, l, nil) -> ir.NewCallExpr(xpos, ir.OAPPEND, l, nil)
ir.NodAt(xpos, ir.ODELETE, l, nil) -> ir.NewCallExpr(xpos, ir.ODELETE, l, nil)
ir.NodAt(xpos, ir.OGETG, l, nil) -> ir.NewCallExpr(xpos, ir.OGETG, l, nil)
ir.NodAt(xpos, ir.OMAKE, l, nil) -> ir.NewCallExpr(xpos, ir.OMAKE, l, nil)
ir.NodAt(xpos, ir.OPRINT, l, nil) -> ir.NewCallExpr(xpos, ir.OPRINT, l, nil)
ir.NodAt(xpos, ir.OPRINTN, l, nil) -> ir.NewCallExpr(xpos, ir.OPRINTN, l, nil)
ir.NodAt(xpos, ir.ORECOVER, l, nil) -> ir.NewCallExpr(xpos, ir.ORECOVER, l, nil)
ir.NodAt(xpos, ir.OCASE, nil, nil) -> ir.NewCaseStmt(xpos, nil, nil)
ir.NodAt(xpos, ir.OCONV, l, nil) -> ir.NewConvExpr(xpos, ir.OCONV, nil, l)
ir.NodAt(xpos, ir.OCONVIFACE, l, nil) -> ir.NewConvExpr(xpos, ir.OCONVIFACE, nil, l)
ir.NodAt(xpos, ir.OCONVNOP, l, nil) -> ir.NewConvExpr(xpos, ir.OCONVNOP, nil, l)
ir.NodAt(xpos, ir.ORUNESTR, l, nil) -> ir.NewConvExpr(xpos, ir.ORUNESTR, nil, l)
ir.NodAt(xpos, ir.ODCL, l, nil) -> ir.NewDecl(xpos, ir.ODCL, l)
ir.NodAt(xpos, ir.ODCLCONST, l, nil) -> ir.NewDecl(xpos, ir.ODCLCONST, l)
ir.NodAt(xpos, ir.ODCLTYPE, l, nil) -> ir.NewDecl(xpos, ir.ODCLTYPE, l)
ir.NodAt(xpos, ir.ODCLFUNC, nil, nil) -> ir.NewFunc(xpos)
ir.NodAt(xpos, ir.ODEFER, l, nil) -> ir.NewGoDeferStmt(xpos, ir.ODEFER, l)
ir.NodAt(xpos, ir.OGO, l, nil) -> ir.NewGoDeferStmt(xpos, ir.OGO, l)
ir.NodAt(xpos, ir.ODEREF, l, nil) -> ir.NewStarExpr(xpos, l)
ir.NodAt(xpos, ir.ODOT, l, nil) -> ir.NewSelectorExpr(xpos, ir.ODOT, l, nil)
ir.NodAt(xpos, ir.ODOTPTR, l, nil) -> ir.NewSelectorExpr(xpos, ir.ODOTPTR, l, nil)
ir.NodAt(xpos, ir.ODOTMETH, l, nil) -> ir.NewSelectorExpr(xpos, ir.ODOTMETH, l, nil)
ir.NodAt(xpos, ir.ODOTINTER, l, nil) -> ir.NewSelectorExpr(xpos, ir.ODOTINTER, l, nil)
ir.NodAt(xpos, ir.OXDOT, l, nil) -> ir.NewSelectorExpr(xpos, ir.OXDOT, l, nil)
ir.NodAt(xpos, ir.ODOTTYPE, l, nil) -> ir.NewTypeAssertExpr(xpos, l, nil)
ir.NodAt(xpos, ir.ODOTTYPE, l, r) -> ir.NewTypeAssertExpr(xpos, l, r.(ir.Ntype))
ir.NodAt(xpos, ir.OFOR, l, r) -> ir.NewForStmt(xpos, nil, l, r, nil)
ir.NodAt(xpos, ir.OINDEX, l, r) -> ir.NewIndexExpr(xpos, l, r)
ir.NodAt(xpos, ir.OINLMARK, nil, nil) -> ir.NewInlineMarkStmt(xpos, types.BADWIDTH)
ir.NodAt(xpos, ir.OKEY, l, r) -> ir.NewKeyExpr(xpos, l, r)
ir.NodAt(xpos, ir.OLABEL, nil, nil) -> ir.NewLabelStmt(xpos, nil)
ir.NodAt(xpos, ir.OMAKECHAN, l, r) -> ir.NewMakeExpr(xpos, ir.OMAKECHAN, l, r)
ir.NodAt(xpos, ir.OMAKEMAP, l, r) -> ir.NewMakeExpr(xpos, ir.OMAKEMAP, l, r)
ir.NodAt(xpos, ir.OMAKESLICE, l, r) -> ir.NewMakeExpr(xpos, ir.OMAKESLICE, l, r)
ir.NodAt(xpos, ir.OMAKESLICECOPY, l, r) -> ir.NewMakeExpr(xpos, ir.OMAKESLICECOPY, l, r)
ir.NodAt(xpos, ir.ONIL, nil, nil) -> ir.NewNilExpr(xpos)
ir.NodAt(xpos, ir.OPACK, nil, nil) -> ir.NewPkgName(xpos, nil, nil)
ir.NodAt(xpos, ir.OPAREN, l, nil) -> ir.NewParenExpr(xpos, l)
ir.NodAt(xpos, ir.ORANGE, nil, r) -> ir.NewRangeStmt(xpos, nil, r, nil)
ir.NodAt(xpos, ir.ORESULT, nil, nil) -> ir.NewResultExpr(xpos, nil, types.BADWIDTH)
ir.NodAt(xpos, ir.ORETURN, nil, nil) -> ir.NewReturnStmt(xpos, nil)
ir.NodAt(xpos, ir.OSELECT, nil, nil) -> ir.NewSelectStmt(xpos, nil)
ir.NodAt(xpos, ir.OSEND, l, r) -> ir.NewSendStmt(xpos, l, r)
ir.NodAt(xpos, ir.OSLICE, l, nil) -> ir.NewSliceExpr(xpos, ir.OSLICE, l)
ir.NodAt(xpos, ir.OSLICEARR, l, nil) -> ir.NewSliceExpr(xpos, ir.OSLICEARR, l)
ir.NodAt(xpos, ir.OSLICESTR, l, nil) -> ir.NewSliceExpr(xpos, ir.OSLICESTR, l)
ir.NodAt(xpos, ir.OSLICE3, l, nil) -> ir.NewSliceExpr(xpos, ir.OSLICE3, l)
ir.NodAt(xpos, ir.OSLICE3ARR, l, nil) -> ir.NewSliceExpr(xpos, ir.OSLICE3ARR, l)
ir.NodAt(xpos, ir.OSLICEHEADER, l, nil) -> ir.NewSliceHeaderExpr(xpos, nil, l, nil, nil)
ir.NodAt(xpos, ir.OSWITCH, l, nil) -> ir.NewSwitchStmt(xpos, l, nil)
ir.NodAt(xpos, ir.OINLCALL, nil, nil) -> ir.NewInlinedCallExpr(xpos, nil, nil)
}
rm noder.nod noder.nodSym nodSym nodlSym ir.NodAt ir.Nod
'
Change-Id: Ibf1eb708de8463ae74ccc47d7966cc263a18295e
Reviewed-on: https://go-review.googlesource.com/c/go/+/277933
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2020-12-22 23:55:29 -05:00
|
|
|
pc0 = typecheck(nodAddr(ir.NewIndexExpr(base.Pos, pcs, nodintconst(0))), ctxExpr)
|
2020-07-27 15:20:18 -07:00
|
|
|
} else {
|
|
|
|
pc0 = nodnil()
|
|
|
|
}
|
|
|
|
|
2015-02-13 14:40:36 -05:00
|
|
|
// register cases
|
2020-07-27 16:19:15 -07:00
|
|
|
for _, cas := range cases.Slice() {
|
[dev.regabi] cmd/compile: cleanup for concrete types - range, select, swt
An automated rewrite will add concrete type assertions after
a test of n.Op(), when n can be safely type-asserted
(meaning, n is not reassigned a different type, n is not reassigned
and then used outside the scope of the type assertion,
and so on).
This sequence of CLs handles the code that the automated
rewrite does not: adding specific types to function arguments,
adjusting code not to call n.Left() etc when n may have multiple
representations, and so on.
This CL focuses on range.go, select.go, and swt.go: the big
control structures.
Passes buildall w/ toolstash -cmp.
Change-Id: I033fe056a7b815edb6e8a06f45c12ffd990f4d45
Reviewed-on: https://go-review.googlesource.com/c/go/+/277929
Trust: Russ Cox <rsc@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2020-12-10 18:47:32 -05:00
|
|
|
cas := cas.(*ir.CaseStmt)
|
2015-02-13 14:40:36 -05:00
|
|
|
setlineno(cas)
|
2017-03-01 15:50:57 -08:00
|
|
|
|
2020-11-22 09:59:15 -05:00
|
|
|
init = append(init, cas.Init().Slice()...)
|
|
|
|
cas.PtrInit().Set(nil)
|
2015-02-13 14:40:36 -05:00
|
|
|
|
2020-11-22 09:59:15 -05:00
|
|
|
n := cas.Left()
|
2020-07-27 16:19:15 -07:00
|
|
|
if n == nil { // default:
|
|
|
|
continue
|
|
|
|
}
|
2017-03-07 14:26:27 -08:00
|
|
|
|
2020-07-27 16:19:15 -07:00
|
|
|
var i int
|
[dev.regabi] cmd/compile: replace *Node type with an interface Node [generated]
The plan is to introduce a Node interface that replaces the old *Node pointer-to-struct.
The previous CL defined an interface INode modeling a *Node.
This CL:
- Changes all references outside internal/ir to use INode,
along with many references inside internal/ir as well.
- Renames Node to node.
- Renames INode to Node
So now ir.Node is an interface implemented by *ir.node, which is otherwise inaccessible,
and the code outside package ir is now (clearly) using only the interface.
The usual rule is never to redefine an existing name with a new meaning,
so that old code that hasn't been updated gets a "unknown name" error
instead of more mysterious errors or silent misbehavior. That rule would
caution against replacing Node-the-struct with Node-the-interface,
as in this CL, because code that says *Node would now be using a pointer
to an interface. But this CL is being landed at the same time as another that
moves Node from gc to ir. So the net effect is to replace *gc.Node with ir.Node,
which does follow the rule: any lingering references to gc.Node will be told
it's gone, not silently start using pointers to interfaces. So the rule is followed
by the CL sequence, just not this specific CL.
Overall, the loss of inlining caused by using interfaces cuts the compiler speed
by about 6%, a not insignificant amount. However, as we convert the representation
to concrete structs that are not the giant Node over the next weeks, that speed
should come back as more of the compiler starts operating directly on concrete types
and the memory taken up by the graph of Nodes drops due to the more precise
structs. Honestly, I was expecting worse.
% benchstat bench.old bench.new
name old time/op new time/op delta
Template 168ms ± 4% 182ms ± 2% +8.34% (p=0.000 n=9+9)
Unicode 72.2ms ±10% 82.5ms ± 6% +14.38% (p=0.000 n=9+9)
GoTypes 563ms ± 8% 598ms ± 2% +6.14% (p=0.006 n=9+9)
Compiler 2.89s ± 4% 3.04s ± 2% +5.37% (p=0.000 n=10+9)
SSA 6.45s ± 4% 7.25s ± 5% +12.41% (p=0.000 n=9+10)
Flate 105ms ± 2% 115ms ± 1% +9.66% (p=0.000 n=10+8)
GoParser 144ms ±10% 152ms ± 2% +5.79% (p=0.011 n=9+8)
Reflect 345ms ± 9% 370ms ± 4% +7.28% (p=0.001 n=10+9)
Tar 149ms ± 9% 161ms ± 5% +8.05% (p=0.001 n=10+9)
XML 190ms ± 3% 209ms ± 2% +9.54% (p=0.000 n=9+8)
LinkCompiler 327ms ± 2% 325ms ± 2% ~ (p=0.382 n=8+8)
ExternalLinkCompiler 1.77s ± 4% 1.73s ± 6% ~ (p=0.113 n=9+10)
LinkWithoutDebugCompiler 214ms ± 4% 211ms ± 2% ~ (p=0.360 n=10+8)
StdCmd 14.8s ± 3% 15.9s ± 1% +6.98% (p=0.000 n=10+9)
[Geo mean] 480ms 510ms +6.31%
name old user-time/op new user-time/op delta
Template 223ms ± 3% 237ms ± 3% +6.16% (p=0.000 n=9+10)
Unicode 103ms ± 6% 113ms ± 3% +9.53% (p=0.000 n=9+9)
GoTypes 758ms ± 8% 800ms ± 2% +5.55% (p=0.003 n=10+9)
Compiler 3.95s ± 2% 4.12s ± 2% +4.34% (p=0.000 n=10+9)
SSA 9.43s ± 1% 9.74s ± 4% +3.25% (p=0.000 n=8+10)
Flate 132ms ± 2% 141ms ± 2% +6.89% (p=0.000 n=9+9)
GoParser 177ms ± 9% 183ms ± 4% ~ (p=0.050 n=9+9)
Reflect 467ms ±10% 495ms ± 7% +6.17% (p=0.029 n=10+10)
Tar 183ms ± 9% 197ms ± 5% +7.92% (p=0.001 n=10+10)
XML 249ms ± 5% 268ms ± 4% +7.82% (p=0.000 n=10+9)
LinkCompiler 544ms ± 5% 544ms ± 6% ~ (p=0.863 n=9+9)
ExternalLinkCompiler 1.79s ± 4% 1.75s ± 6% ~ (p=0.075 n=10+10)
LinkWithoutDebugCompiler 248ms ± 6% 246ms ± 2% ~ (p=0.965 n=10+8)
[Geo mean] 483ms 504ms +4.41%
[git-generate]
cd src/cmd/compile/internal/ir
: # We need to do the conversion in multiple steps, so we introduce
: # a temporary type alias that will start out meaning the pointer-to-struct
: # and then change to mean the interface.
rf '
mv Node OldNode
add node.go \
type Node = *OldNode
'
: # It should work to do this ex in ir, but it misses test files, due to a bug in rf.
: # Run the command in gc to handle gc's tests, and then again in ssa for ssa's tests.
cd ../gc
rf '
ex . ../arm ../riscv64 ../arm64 ../mips64 ../ppc64 ../mips ../wasm {
import "cmd/compile/internal/ir"
*ir.OldNode -> ir.Node
}
'
cd ../ssa
rf '
ex {
import "cmd/compile/internal/ir"
*ir.OldNode -> ir.Node
}
'
: # Back in ir, finish conversion clumsily with sed,
: # because type checking and circular aliases do not mix.
cd ../ir
sed -i '' '
/type Node = \*OldNode/d
s/\*OldNode/Node/g
s/^func (n Node)/func (n *OldNode)/
s/OldNode/node/g
s/type INode interface/type Node interface/
s/var _ INode = (Node)(nil)/var _ Node = (*node)(nil)/
' *.go
gofmt -w *.go
sed -i '' '
s/{Func{}, 136, 248}/{Func{}, 152, 280}/
s/{Name{}, 32, 56}/{Name{}, 44, 80}/
s/{Param{}, 24, 48}/{Param{}, 44, 88}/
s/{node{}, 76, 128}/{node{}, 88, 152}/
' sizeof_test.go
cd ../ssa
sed -i '' '
s/{LocalSlot{}, 28, 40}/{LocalSlot{}, 32, 48}/
' sizeof_test.go
cd ../gc
sed -i '' 's/\*ir.Node/ir.Node/' mkbuiltin.go
cd ../../../..
go install std cmd
cd cmd/compile
go test -u || go test -u
Change-Id: I196bbe3b648e4701662e4a2bada40bf155e2a553
Reviewed-on: https://go-review.googlesource.com/c/go/+/272935
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2020-11-25 01:11:56 -05:00
|
|
|
var c, elem ir.Node
|
2020-11-22 09:59:15 -05:00
|
|
|
switch n.Op() {
|
2020-07-27 16:19:15 -07:00
|
|
|
default:
|
2020-11-22 09:59:15 -05:00
|
|
|
base.Fatalf("select %v", n.Op())
|
[dev.regabi] cmd/compile: introduce cmd/compile/internal/ir [generated]
If we want to break up package gc at all, we will need to move
the compiler IR it defines into a separate package that can be
imported by packages that gc itself imports. This CL does that.
It also removes the TINT8 etc aliases so that all code is clear
about which package things are coming from.
This CL is automatically generated by the script below.
See the comments in the script for details about the changes.
[git-generate]
cd src/cmd/compile/internal/gc
rf '
# These names were never fully qualified
# when the types package was added.
# Do it now, to avoid confusion about where they live.
inline -rm \
Txxx \
TINT8 \
TUINT8 \
TINT16 \
TUINT16 \
TINT32 \
TUINT32 \
TINT64 \
TUINT64 \
TINT \
TUINT \
TUINTPTR \
TCOMPLEX64 \
TCOMPLEX128 \
TFLOAT32 \
TFLOAT64 \
TBOOL \
TPTR \
TFUNC \
TSLICE \
TARRAY \
TSTRUCT \
TCHAN \
TMAP \
TINTER \
TFORW \
TANY \
TSTRING \
TUNSAFEPTR \
TIDEAL \
TNIL \
TBLANK \
TFUNCARGS \
TCHANARGS \
NTYPE \
BADWIDTH
# esc.go and escape.go do not need to be split.
# Append esc.go onto the end of escape.go.
mv esc.go escape.go
# Pull out the type format installation from func Main,
# so it can be carried into package ir.
mv Main:/Sconv.=/-0,/TypeLinkSym/-1 InstallTypeFormats
# Names that need to be exported for use by code left in gc.
mv Isconst IsConst
mv asNode AsNode
mv asNodes AsNodes
mv asTypesNode AsTypesNode
mv basicnames BasicTypeNames
mv builtinpkg BuiltinPkg
mv consttype ConstType
mv dumplist DumpList
mv fdumplist FDumpList
mv fmtMode FmtMode
mv goopnames OpNames
mv inspect Inspect
mv inspectList InspectList
mv localpkg LocalPkg
mv nblank BlankNode
mv numImport NumImport
mv opprec OpPrec
mv origSym OrigSym
mv stmtwithinit StmtWithInit
mv dump DumpAny
mv fdump FDumpAny
mv nod Nod
mv nodl NodAt
mv newname NewName
mv newnamel NewNameAt
mv assertRepresents AssertValidTypeForConst
mv represents ValidTypeForConst
mv nodlit NewLiteral
# Types and fields that need to be exported for use by gc.
mv nowritebarrierrecCallSym SymAndPos
mv SymAndPos.lineno SymAndPos.Pos
mv SymAndPos.target SymAndPos.Sym
mv Func.lsym Func.LSym
mv Func.setWBPos Func.SetWBPos
mv Func.numReturns Func.NumReturns
mv Func.numDefers Func.NumDefers
mv Func.nwbrCalls Func.NWBRCalls
# initLSym is an algorithm left behind in gc,
# not an operation on Func itself.
mv Func.initLSym initLSym
mv nodeQueue NodeQueue
mv NodeQueue.empty NodeQueue.Empty
mv NodeQueue.popLeft NodeQueue.PopLeft
mv NodeQueue.pushRight NodeQueue.PushRight
# Many methods on Node are actually algorithms that
# would apply to any node implementation.
# Those become plain functions.
mv Node.funcname FuncName
mv Node.isBlank IsBlank
mv Node.isGoConst isGoConst
mv Node.isNil IsNil
mv Node.isParamHeapCopy isParamHeapCopy
mv Node.isParamStackCopy isParamStackCopy
mv Node.isSimpleName isSimpleName
mv Node.mayBeShared MayBeShared
mv Node.pkgFuncName PkgFuncName
mv Node.backingArrayPtrLen backingArrayPtrLen
mv Node.isterminating isTermNode
mv Node.labeledControl labeledControl
mv Nodes.isterminating isTermNodes
mv Nodes.sigerr fmtSignature
mv Node.MethodName methodExprName
mv Node.MethodFunc methodExprFunc
mv Node.IsMethod IsMethod
# Every node will need to implement RawCopy;
# Copy and SepCopy algorithms will use it.
mv Node.rawcopy Node.RawCopy
mv Node.copy Copy
mv Node.sepcopy SepCopy
# Extract Node.Format method body into func FmtNode,
# but leave method wrapper behind.
mv Node.Format:0,$ FmtNode
# Formatting helpers that will apply to all node implementations.
mv Node.Line Line
mv Node.exprfmt exprFmt
mv Node.jconv jconvFmt
mv Node.modeString modeString
mv Node.nconv nconvFmt
mv Node.nodedump nodeDumpFmt
mv Node.nodefmt nodeFmt
mv Node.stmtfmt stmtFmt
# Constant support needed for code moving to ir.
mv okforconst OKForConst
mv vconv FmtConst
mv int64Val Int64Val
mv float64Val Float64Val
mv Node.ValueInterface ConstValue
# Organize code into files.
mv LocalPkg BuiltinPkg ir.go
mv NumImport InstallTypeFormats Line fmt.go
mv syntax.go Nod NodAt NewNameAt Class Pxxx PragmaFlag Nointerface SymAndPos \
AsNode AsTypesNode BlankNode OrigSym \
Node.SliceBounds Node.SetSliceBounds Op.IsSlice3 \
IsConst Node.Int64Val Node.CanInt64 Node.Uint64Val Node.BoolVal Node.StringVal \
Node.RawCopy SepCopy Copy \
IsNil IsBlank IsMethod \
Node.Typ Node.StorageClass node.go
mv ConstType ConstValue Int64Val Float64Val AssertValidTypeForConst ValidTypeForConst NewLiteral idealType OKForConst val.go
# Move files to new ir package.
mv bitset.go class_string.go dump.go fmt.go \
ir.go node.go op_string.go val.go \
sizeof_test.go cmd/compile/internal/ir
'
: # fix mkbuiltin.go to generate the changes made to builtin.go during rf
sed -i '' '
s/\[T/[types.T/g
s/\*Node/*ir.Node/g
/internal\/types/c \
fmt.Fprintln(&b, `import (`) \
fmt.Fprintln(&b, ` "cmd/compile/internal/ir"`) \
fmt.Fprintln(&b, ` "cmd/compile/internal/types"`) \
fmt.Fprintln(&b, `)`)
' mkbuiltin.go
gofmt -w mkbuiltin.go
: # update cmd/dist to add internal/ir
cd ../../../dist
sed -i '' '/compile.internal.gc/a\
"cmd/compile/internal/ir",
' buildtool.go
gofmt -w buildtool.go
: # update cmd/compile TestFormats
cd ../..
go install std cmd
cd cmd/compile
go test -u || go test # first one updates but fails; second passes
Change-Id: I5f7caf6b20629b51970279e81231a3574d5b51db
Reviewed-on: https://go-review.googlesource.com/c/go/+/273008
Trust: Russ Cox <rsc@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2020-11-19 21:09:22 -05:00
|
|
|
case ir.OSEND:
|
2020-07-27 16:19:15 -07:00
|
|
|
i = nsends
|
|
|
|
nsends++
|
2020-11-22 09:59:15 -05:00
|
|
|
c = n.Left()
|
|
|
|
elem = n.Right()
|
[dev.regabi] cmd/compile: clean up in preparation for statement Nodes
Using statement nodes restricts the set of valid SetOp operations,
because you can't SetOp across representation. Rewrite various
code to avoid crossing those as-yet-unintroduced boundaries.
In particular, code like
x, y := v.(T)
x, y := f()
x, y := m[k]
x, y := <-c
starts out with Op = OAS2, and then it turns into a specific Op
OAS2DOTTYPE, OAS2FUNC, OAS2MAPR, OAS2RECV, and then
later in walk is lowered to an OAS2 again.
In the middle, the specific forms move the right-hand side from
n.Rlist().First() to n.Right(), and then the conversion to OAS2 moves
it back. This is unnecessary and makes it hard for these all to
share an underlying Node implementation.
This CL changes these specific forms to leave the right-hand side
in n.Rlist().First().
Similarly, OSELRECV2 is really just a temporary form of OAS2.
This CL changes it to use same fields too.
Finally, this CL fixes the printing of OAS2 nodes in ir/fmt.go,
which formerly printed n.Right() instead of n.Rlist().
This results in a (correct!) update to cmd/compile/internal/logopt's
expected output: ~R0 = <N> becomes ~R0 = &y.b.
Passes buildall w/ toolstash -cmp.
Change-Id: I164aa2e17dc55bfb292024de53d7d250192ad64a
Reviewed-on: https://go-review.googlesource.com/c/go/+/274105
Trust: Russ Cox <rsc@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2020-11-28 15:28:18 -05:00
|
|
|
case ir.OSELRECV2:
|
|
|
|
nrecvs++
|
|
|
|
i = ncas - nrecvs
|
[dev.regabi] cmd/compile: cleanup for concrete types - range, select, swt
An automated rewrite will add concrete type assertions after
a test of n.Op(), when n can be safely type-asserted
(meaning, n is not reassigned a different type, n is not reassigned
and then used outside the scope of the type assertion,
and so on).
This sequence of CLs handles the code that the automated
rewrite does not: adding specific types to function arguments,
adjusting code not to call n.Left() etc when n may have multiple
representations, and so on.
This CL focuses on range.go, select.go, and swt.go: the big
control structures.
Passes buildall w/ toolstash -cmp.
Change-Id: I033fe056a7b815edb6e8a06f45c12ffd990f4d45
Reviewed-on: https://go-review.googlesource.com/c/go/+/277929
Trust: Russ Cox <rsc@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2020-12-10 18:47:32 -05:00
|
|
|
recv := n.Rlist().First().(*ir.UnaryExpr)
|
|
|
|
c = recv.Left()
|
[dev.regabi] cmd/compile: clean up in preparation for statement Nodes
Using statement nodes restricts the set of valid SetOp operations,
because you can't SetOp across representation. Rewrite various
code to avoid crossing those as-yet-unintroduced boundaries.
In particular, code like
x, y := v.(T)
x, y := f()
x, y := m[k]
x, y := <-c
starts out with Op = OAS2, and then it turns into a specific Op
OAS2DOTTYPE, OAS2FUNC, OAS2MAPR, OAS2RECV, and then
later in walk is lowered to an OAS2 again.
In the middle, the specific forms move the right-hand side from
n.Rlist().First() to n.Right(), and then the conversion to OAS2 moves
it back. This is unnecessary and makes it hard for these all to
share an underlying Node implementation.
This CL changes these specific forms to leave the right-hand side
in n.Rlist().First().
Similarly, OSELRECV2 is really just a temporary form of OAS2.
This CL changes it to use same fields too.
Finally, this CL fixes the printing of OAS2 nodes in ir/fmt.go,
which formerly printed n.Right() instead of n.Rlist().
This results in a (correct!) update to cmd/compile/internal/logopt's
expected output: ~R0 = <N> becomes ~R0 = &y.b.
Passes buildall w/ toolstash -cmp.
Change-Id: I164aa2e17dc55bfb292024de53d7d250192ad64a
Reviewed-on: https://go-review.googlesource.com/c/go/+/274105
Trust: Russ Cox <rsc@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2020-11-28 15:28:18 -05:00
|
|
|
elem = n.List().First()
|
2015-02-13 14:40:36 -05:00
|
|
|
}
|
|
|
|
|
2020-07-27 16:19:15 -07:00
|
|
|
casorder[i] = cas
|
|
|
|
|
[dev.regabi] cmd/compile: replace *Node type with an interface Node [generated]
The plan is to introduce a Node interface that replaces the old *Node pointer-to-struct.
The previous CL defined an interface INode modeling a *Node.
This CL:
- Changes all references outside internal/ir to use INode,
along with many references inside internal/ir as well.
- Renames Node to node.
- Renames INode to Node
So now ir.Node is an interface implemented by *ir.node, which is otherwise inaccessible,
and the code outside package ir is now (clearly) using only the interface.
The usual rule is never to redefine an existing name with a new meaning,
so that old code that hasn't been updated gets a "unknown name" error
instead of more mysterious errors or silent misbehavior. That rule would
caution against replacing Node-the-struct with Node-the-interface,
as in this CL, because code that says *Node would now be using a pointer
to an interface. But this CL is being landed at the same time as another that
moves Node from gc to ir. So the net effect is to replace *gc.Node with ir.Node,
which does follow the rule: any lingering references to gc.Node will be told
it's gone, not silently start using pointers to interfaces. So the rule is followed
by the CL sequence, just not this specific CL.
Overall, the loss of inlining caused by using interfaces cuts the compiler speed
by about 6%, a not insignificant amount. However, as we convert the representation
to concrete structs that are not the giant Node over the next weeks, that speed
should come back as more of the compiler starts operating directly on concrete types
and the memory taken up by the graph of Nodes drops due to the more precise
structs. Honestly, I was expecting worse.
% benchstat bench.old bench.new
name old time/op new time/op delta
Template 168ms ± 4% 182ms ± 2% +8.34% (p=0.000 n=9+9)
Unicode 72.2ms ±10% 82.5ms ± 6% +14.38% (p=0.000 n=9+9)
GoTypes 563ms ± 8% 598ms ± 2% +6.14% (p=0.006 n=9+9)
Compiler 2.89s ± 4% 3.04s ± 2% +5.37% (p=0.000 n=10+9)
SSA 6.45s ± 4% 7.25s ± 5% +12.41% (p=0.000 n=9+10)
Flate 105ms ± 2% 115ms ± 1% +9.66% (p=0.000 n=10+8)
GoParser 144ms ±10% 152ms ± 2% +5.79% (p=0.011 n=9+8)
Reflect 345ms ± 9% 370ms ± 4% +7.28% (p=0.001 n=10+9)
Tar 149ms ± 9% 161ms ± 5% +8.05% (p=0.001 n=10+9)
XML 190ms ± 3% 209ms ± 2% +9.54% (p=0.000 n=9+8)
LinkCompiler 327ms ± 2% 325ms ± 2% ~ (p=0.382 n=8+8)
ExternalLinkCompiler 1.77s ± 4% 1.73s ± 6% ~ (p=0.113 n=9+10)
LinkWithoutDebugCompiler 214ms ± 4% 211ms ± 2% ~ (p=0.360 n=10+8)
StdCmd 14.8s ± 3% 15.9s ± 1% +6.98% (p=0.000 n=10+9)
[Geo mean] 480ms 510ms +6.31%
name old user-time/op new user-time/op delta
Template 223ms ± 3% 237ms ± 3% +6.16% (p=0.000 n=9+10)
Unicode 103ms ± 6% 113ms ± 3% +9.53% (p=0.000 n=9+9)
GoTypes 758ms ± 8% 800ms ± 2% +5.55% (p=0.003 n=10+9)
Compiler 3.95s ± 2% 4.12s ± 2% +4.34% (p=0.000 n=10+9)
SSA 9.43s ± 1% 9.74s ± 4% +3.25% (p=0.000 n=8+10)
Flate 132ms ± 2% 141ms ± 2% +6.89% (p=0.000 n=9+9)
GoParser 177ms ± 9% 183ms ± 4% ~ (p=0.050 n=9+9)
Reflect 467ms ±10% 495ms ± 7% +6.17% (p=0.029 n=10+10)
Tar 183ms ± 9% 197ms ± 5% +7.92% (p=0.001 n=10+10)
XML 249ms ± 5% 268ms ± 4% +7.82% (p=0.000 n=10+9)
LinkCompiler 544ms ± 5% 544ms ± 6% ~ (p=0.863 n=9+9)
ExternalLinkCompiler 1.79s ± 4% 1.75s ± 6% ~ (p=0.075 n=10+10)
LinkWithoutDebugCompiler 248ms ± 6% 246ms ± 2% ~ (p=0.965 n=10+8)
[Geo mean] 483ms 504ms +4.41%
[git-generate]
cd src/cmd/compile/internal/ir
: # We need to do the conversion in multiple steps, so we introduce
: # a temporary type alias that will start out meaning the pointer-to-struct
: # and then change to mean the interface.
rf '
mv Node OldNode
add node.go \
type Node = *OldNode
'
: # It should work to do this ex in ir, but it misses test files, due to a bug in rf.
: # Run the command in gc to handle gc's tests, and then again in ssa for ssa's tests.
cd ../gc
rf '
ex . ../arm ../riscv64 ../arm64 ../mips64 ../ppc64 ../mips ../wasm {
import "cmd/compile/internal/ir"
*ir.OldNode -> ir.Node
}
'
cd ../ssa
rf '
ex {
import "cmd/compile/internal/ir"
*ir.OldNode -> ir.Node
}
'
: # Back in ir, finish conversion clumsily with sed,
: # because type checking and circular aliases do not mix.
cd ../ir
sed -i '' '
/type Node = \*OldNode/d
s/\*OldNode/Node/g
s/^func (n Node)/func (n *OldNode)/
s/OldNode/node/g
s/type INode interface/type Node interface/
s/var _ INode = (Node)(nil)/var _ Node = (*node)(nil)/
' *.go
gofmt -w *.go
sed -i '' '
s/{Func{}, 136, 248}/{Func{}, 152, 280}/
s/{Name{}, 32, 56}/{Name{}, 44, 80}/
s/{Param{}, 24, 48}/{Param{}, 44, 88}/
s/{node{}, 76, 128}/{node{}, 88, 152}/
' sizeof_test.go
cd ../ssa
sed -i '' '
s/{LocalSlot{}, 28, 40}/{LocalSlot{}, 32, 48}/
' sizeof_test.go
cd ../gc
sed -i '' 's/\*ir.Node/ir.Node/' mkbuiltin.go
cd ../../../..
go install std cmd
cd cmd/compile
go test -u || go test -u
Change-Id: I196bbe3b648e4701662e4a2bada40bf155e2a553
Reviewed-on: https://go-review.googlesource.com/c/go/+/272935
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2020-11-25 01:11:56 -05:00
|
|
|
setField := func(f string, val ir.Node) {
|
[dev.regabi] cmd/compile: remove ir.Nod [generated]
Rewrite all uses of ir.Nod and friends to call the IR constructors directly.
This gives the results a more specific type and will play nicely with
introduction of more specific types throughout the code in a followup CL.
Passes buildall w/ toolstash -cmp.
[git-generate]
cd src/cmd/compile/internal/gc
rf '
ex . ../ir {
import "cmd/compile/internal/ir"
import "cmd/compile/internal/types"
import "cmd/compile/internal/syntax"
import "cmd/internal/src"
var p *noder
var orig syntax.Node
var op ir.Op
var l, r ir.Node
var sym *types.Sym
p.nod(orig, op, l, r) -> ir.NodAt(p.pos(orig), op, l, r)
p.nodSym(orig, op, l, sym) -> nodlSym(p.pos(orig), op, l, sym)
var xpos src.XPos
var ns ir.Nodes
npos(xpos, nodSym(op, l, sym)) -> nodlSym(xpos, op, l, sym)
npos(xpos, liststmt(ns)) -> ir.NewBlockStmt(xpos, ns)
}
ex . ../ir {
import "cmd/compile/internal/base"
import "cmd/compile/internal/ir"
import "cmd/compile/internal/types"
var op ir.Op
var l, r ir.Node
ir.Nod(op, l, r) -> ir.NodAt(base.Pos, op, l, r)
var sym *types.Sym
nodSym(op, l, sym) -> nodlSym(base.Pos, op, l, sym)
}
ex . ../ir {
import "cmd/compile/internal/ir"
import "cmd/internal/src"
# rf overlapping match handling is not quite good enough
# for certain nested rewrites, so handle these two - which often contain other ir.NodAt calls - early.
var l, r ir.Node
var xpos src.XPos
ir.NodAt(xpos, ir.OAS, l, r) -> ir.NewAssignStmt(xpos, l, r)
ir.NodAt(xpos, ir.OIF, l, nil) -> ir.NewIfStmt(xpos, l, nil, nil)
}
ex . ../ir {
import "cmd/compile/internal/ir"
import "cmd/compile/internal/types"
import "cmd/internal/src"
var l, r ir.Node
var sym *types.Sym
var xpos src.XPos
nodlSym(xpos, ir.ODOT, l, sym) -> ir.NewSelectorExpr(xpos, ir.ODOT, l, sym)
nodlSym(xpos, ir.OXDOT, l, sym) -> ir.NewSelectorExpr(xpos, ir.OXDOT, l, sym)
nodlSym(xpos, ir.ODOTPTR, l, sym) -> ir.NewSelectorExpr(xpos, ir.ODOTPTR, l, sym)
nodlSym(xpos, ir.OGOTO, nil, sym) -> ir.NewBranchStmt(xpos, ir.OGOTO, sym)
nodlSym(xpos, ir.ORETJMP, nil, sym) -> ir.NewBranchStmt(xpos, ir.ORETJMP, sym)
nodlSym(xpos, ir.OLABEL, nil, sym) -> ir.NewLabelStmt(xpos, sym)
nodlSym(xpos, ir.OSTRUCTKEY, l, sym) -> ir.NewStructKeyExpr(xpos, sym, l)
ir.NodAt(xpos, ir.OADD, l, r) -> ir.NewBinaryExpr(xpos, ir.OADD, l, r)
ir.NodAt(xpos, ir.OAND, l, r) -> ir.NewBinaryExpr(xpos, ir.OAND, l, r)
ir.NodAt(xpos, ir.OANDNOT, l, r) -> ir.NewBinaryExpr(xpos, ir.OANDNOT, l, r)
ir.NodAt(xpos, ir.ODIV, l, r) -> ir.NewBinaryExpr(xpos, ir.ODIV, l, r)
ir.NodAt(xpos, ir.OEQ, l, r) -> ir.NewBinaryExpr(xpos, ir.OEQ, l, r)
ir.NodAt(xpos, ir.OGE, l, r) -> ir.NewBinaryExpr(xpos, ir.OGE, l, r)
ir.NodAt(xpos, ir.OGT, l, r) -> ir.NewBinaryExpr(xpos, ir.OGT, l, r)
ir.NodAt(xpos, ir.OLE, l, r) -> ir.NewBinaryExpr(xpos, ir.OLE, l, r)
ir.NodAt(xpos, ir.OLSH, l, r) -> ir.NewBinaryExpr(xpos, ir.OLSH, l, r)
ir.NodAt(xpos, ir.OLT, l, r) -> ir.NewBinaryExpr(xpos, ir.OLT, l, r)
ir.NodAt(xpos, ir.OMOD, l, r) -> ir.NewBinaryExpr(xpos, ir.OMOD, l, r)
ir.NodAt(xpos, ir.OMUL, l, r) -> ir.NewBinaryExpr(xpos, ir.OMUL, l, r)
ir.NodAt(xpos, ir.ONE, l, r) -> ir.NewBinaryExpr(xpos, ir.ONE, l, r)
ir.NodAt(xpos, ir.OOR, l, r) -> ir.NewBinaryExpr(xpos, ir.OOR, l, r)
ir.NodAt(xpos, ir.ORSH, l, r) -> ir.NewBinaryExpr(xpos, ir.ORSH, l, r)
ir.NodAt(xpos, ir.OSUB, l, r) -> ir.NewBinaryExpr(xpos, ir.OSUB, l, r)
ir.NodAt(xpos, ir.OXOR, l, r) -> ir.NewBinaryExpr(xpos, ir.OXOR, l, r)
ir.NodAt(xpos, ir.OCOPY, l, r) -> ir.NewBinaryExpr(xpos, ir.OCOPY, l, r)
ir.NodAt(xpos, ir.OCOMPLEX, l, r) -> ir.NewBinaryExpr(xpos, ir.OCOMPLEX, l, r)
ir.NodAt(xpos, ir.OEFACE, l, r) -> ir.NewBinaryExpr(xpos, ir.OEFACE, l, r)
ir.NodAt(xpos, ir.OADDR, l, nil) -> ir.NewAddrExpr(xpos, l)
ir.NodAt(xpos, ir.OADDSTR, nil, nil) -> ir.NewAddStringExpr(xpos, nil)
ir.NodAt(xpos, ir.OANDAND, l, r) -> ir.NewLogicalExpr(xpos, ir.OANDAND, l, r)
ir.NodAt(xpos, ir.OOROR, l, r) -> ir.NewLogicalExpr(xpos, ir.OOROR, l, r)
ir.NodAt(xpos, ir.OARRAYLIT, nil, nil) -> ir.NewCompLitExpr(xpos, ir.OARRAYLIT, nil, nil)
ir.NodAt(xpos, ir.OCOMPLIT, nil, nil) -> ir.NewCompLitExpr(xpos, ir.OCOMPLIT, nil, nil)
ir.NodAt(xpos, ir.OMAPLIT, nil, nil) -> ir.NewCompLitExpr(xpos, ir.OMAPLIT, nil, nil)
ir.NodAt(xpos, ir.OSTRUCTLIT, nil, nil) -> ir.NewCompLitExpr(xpos, ir.OSTRUCTLIT, nil, nil)
ir.NodAt(xpos, ir.OSLICELIT, nil, nil) -> ir.NewCompLitExpr(xpos, ir.OSLICELIT, nil, nil)
ir.NodAt(xpos, ir.OARRAYLIT, nil, r) -> ir.NewCompLitExpr(xpos, ir.OARRAYLIT, r.(ir.Ntype), nil)
ir.NodAt(xpos, ir.OCOMPLIT, nil, r) -> ir.NewCompLitExpr(xpos, ir.OCOMPLIT, r.(ir.Ntype), nil)
ir.NodAt(xpos, ir.OMAPLIT, nil, r) -> ir.NewCompLitExpr(xpos, ir.OMAPLIT, r.(ir.Ntype), nil)
ir.NodAt(xpos, ir.OSTRUCTLIT, nil, r) -> ir.NewCompLitExpr(xpos, ir.OSTRUCTLIT, r.(ir.Ntype), nil)
ir.NodAt(xpos, ir.OSLICELIT, nil, r) -> ir.NewCompLitExpr(xpos, ir.OSLICELIT, r.(ir.Ntype), nil)
ir.NodAt(xpos, ir.OAS2, nil, nil) -> ir.NewAssignListStmt(xpos, ir.OAS2, nil, nil)
ir.NodAt(xpos, ir.OAS2DOTTYPE, nil, nil) -> ir.NewAssignListStmt(xpos, ir.OAS2DOTTYPE, nil, nil)
ir.NodAt(xpos, ir.OAS2FUNC, nil, nil) -> ir.NewAssignListStmt(xpos, ir.OAS2FUNC, nil, nil)
ir.NodAt(xpos, ir.OAS2MAPR, nil, nil) -> ir.NewAssignListStmt(xpos, ir.OAS2MAPR, nil, nil)
ir.NodAt(xpos, ir.OAS2RECV, nil, nil) -> ir.NewAssignListStmt(xpos, ir.OAS2RECV, nil, nil)
ir.NodAt(xpos, ir.OSELRECV2, nil, nil) -> ir.NewAssignListStmt(xpos, ir.OSELRECV2, nil, nil)
ir.NodAt(xpos, ir.OASOP, l, r) -> ir.NewAssignOpStmt(xpos, ir.OXXX, l, r)
ir.NodAt(xpos, ir.OBITNOT, l, nil) -> ir.NewUnaryExpr(xpos, ir.OBITNOT, l)
ir.NodAt(xpos, ir.ONEG, l, nil) -> ir.NewUnaryExpr(xpos, ir.ONEG, l)
ir.NodAt(xpos, ir.ONOT, l, nil) -> ir.NewUnaryExpr(xpos, ir.ONOT, l)
ir.NodAt(xpos, ir.OPLUS, l, nil) -> ir.NewUnaryExpr(xpos, ir.OPLUS, l)
ir.NodAt(xpos, ir.ORECV, l, nil) -> ir.NewUnaryExpr(xpos, ir.ORECV, l)
ir.NodAt(xpos, ir.OALIGNOF, l, nil) -> ir.NewUnaryExpr(xpos, ir.OALIGNOF, l)
ir.NodAt(xpos, ir.OCAP, l, nil) -> ir.NewUnaryExpr(xpos, ir.OCAP, l)
ir.NodAt(xpos, ir.OCLOSE, l, nil) -> ir.NewUnaryExpr(xpos, ir.OCLOSE, l)
ir.NodAt(xpos, ir.OIMAG, l, nil) -> ir.NewUnaryExpr(xpos, ir.OIMAG, l)
ir.NodAt(xpos, ir.OLEN, l, nil) -> ir.NewUnaryExpr(xpos, ir.OLEN, l)
ir.NodAt(xpos, ir.ONEW, l, nil) -> ir.NewUnaryExpr(xpos, ir.ONEW, l)
ir.NodAt(xpos, ir.ONEWOBJ, l, nil) -> ir.NewUnaryExpr(xpos, ir.ONEWOBJ, l)
ir.NodAt(xpos, ir.OOFFSETOF, l, nil) -> ir.NewUnaryExpr(xpos, ir.OOFFSETOF, l)
ir.NodAt(xpos, ir.OPANIC, l, nil) -> ir.NewUnaryExpr(xpos, ir.OPANIC, l)
ir.NodAt(xpos, ir.OREAL, l, nil) -> ir.NewUnaryExpr(xpos, ir.OREAL, l)
ir.NodAt(xpos, ir.OSIZEOF, l, nil) -> ir.NewUnaryExpr(xpos, ir.OSIZEOF, l)
ir.NodAt(xpos, ir.OCHECKNIL, l, nil) -> ir.NewUnaryExpr(xpos, ir.OCHECKNIL, l)
ir.NodAt(xpos, ir.OCFUNC, l, nil) -> ir.NewUnaryExpr(xpos, ir.OCFUNC, l)
ir.NodAt(xpos, ir.OIDATA, l, nil) -> ir.NewUnaryExpr(xpos, ir.OIDATA, l)
ir.NodAt(xpos, ir.OITAB, l, nil) -> ir.NewUnaryExpr(xpos, ir.OITAB, l)
ir.NodAt(xpos, ir.OSPTR, l, nil) -> ir.NewUnaryExpr(xpos, ir.OSPTR, l)
ir.NodAt(xpos, ir.OVARDEF, l, nil) -> ir.NewUnaryExpr(xpos, ir.OVARDEF, l)
ir.NodAt(xpos, ir.OVARKILL, l, nil) -> ir.NewUnaryExpr(xpos, ir.OVARKILL, l)
ir.NodAt(xpos, ir.OVARLIVE, l, nil) -> ir.NewUnaryExpr(xpos, ir.OVARLIVE, l)
ir.NodAt(xpos, ir.OBLOCK, nil, nil) -> ir.NewBlockStmt(xpos, nil)
ir.NodAt(xpos, ir.OBREAK, nil, nil) -> ir.NewBranchStmt(xpos, ir.OBREAK, nil)
ir.NodAt(xpos, ir.OCONTINUE, nil, nil) -> ir.NewBranchStmt(xpos, ir.OCONTINUE, nil)
ir.NodAt(xpos, ir.OFALL, nil, nil) -> ir.NewBranchStmt(xpos, ir.OFALL, nil)
ir.NodAt(xpos, ir.OGOTO, nil, nil) -> ir.NewBranchStmt(xpos, ir.OGOTO, nil)
ir.NodAt(xpos, ir.ORETJMP, nil, nil) -> ir.NewBranchStmt(xpos, ir.ORETJMP, nil)
ir.NodAt(xpos, ir.OCALL, l, nil) -> ir.NewCallExpr(xpos, ir.OCALL, l, nil)
ir.NodAt(xpos, ir.OCALLFUNC, l, nil) -> ir.NewCallExpr(xpos, ir.OCALLFUNC, l, nil)
ir.NodAt(xpos, ir.OCALLINTER, l, nil) -> ir.NewCallExpr(xpos, ir.OCALLINTER, l, nil)
ir.NodAt(xpos, ir.OCALLMETH, l, nil) -> ir.NewCallExpr(xpos, ir.OCALLMETH, l, nil)
ir.NodAt(xpos, ir.OAPPEND, l, nil) -> ir.NewCallExpr(xpos, ir.OAPPEND, l, nil)
ir.NodAt(xpos, ir.ODELETE, l, nil) -> ir.NewCallExpr(xpos, ir.ODELETE, l, nil)
ir.NodAt(xpos, ir.OGETG, l, nil) -> ir.NewCallExpr(xpos, ir.OGETG, l, nil)
ir.NodAt(xpos, ir.OMAKE, l, nil) -> ir.NewCallExpr(xpos, ir.OMAKE, l, nil)
ir.NodAt(xpos, ir.OPRINT, l, nil) -> ir.NewCallExpr(xpos, ir.OPRINT, l, nil)
ir.NodAt(xpos, ir.OPRINTN, l, nil) -> ir.NewCallExpr(xpos, ir.OPRINTN, l, nil)
ir.NodAt(xpos, ir.ORECOVER, l, nil) -> ir.NewCallExpr(xpos, ir.ORECOVER, l, nil)
ir.NodAt(xpos, ir.OCASE, nil, nil) -> ir.NewCaseStmt(xpos, nil, nil)
ir.NodAt(xpos, ir.OCONV, l, nil) -> ir.NewConvExpr(xpos, ir.OCONV, nil, l)
ir.NodAt(xpos, ir.OCONVIFACE, l, nil) -> ir.NewConvExpr(xpos, ir.OCONVIFACE, nil, l)
ir.NodAt(xpos, ir.OCONVNOP, l, nil) -> ir.NewConvExpr(xpos, ir.OCONVNOP, nil, l)
ir.NodAt(xpos, ir.ORUNESTR, l, nil) -> ir.NewConvExpr(xpos, ir.ORUNESTR, nil, l)
ir.NodAt(xpos, ir.ODCL, l, nil) -> ir.NewDecl(xpos, ir.ODCL, l)
ir.NodAt(xpos, ir.ODCLCONST, l, nil) -> ir.NewDecl(xpos, ir.ODCLCONST, l)
ir.NodAt(xpos, ir.ODCLTYPE, l, nil) -> ir.NewDecl(xpos, ir.ODCLTYPE, l)
ir.NodAt(xpos, ir.ODCLFUNC, nil, nil) -> ir.NewFunc(xpos)
ir.NodAt(xpos, ir.ODEFER, l, nil) -> ir.NewGoDeferStmt(xpos, ir.ODEFER, l)
ir.NodAt(xpos, ir.OGO, l, nil) -> ir.NewGoDeferStmt(xpos, ir.OGO, l)
ir.NodAt(xpos, ir.ODEREF, l, nil) -> ir.NewStarExpr(xpos, l)
ir.NodAt(xpos, ir.ODOT, l, nil) -> ir.NewSelectorExpr(xpos, ir.ODOT, l, nil)
ir.NodAt(xpos, ir.ODOTPTR, l, nil) -> ir.NewSelectorExpr(xpos, ir.ODOTPTR, l, nil)
ir.NodAt(xpos, ir.ODOTMETH, l, nil) -> ir.NewSelectorExpr(xpos, ir.ODOTMETH, l, nil)
ir.NodAt(xpos, ir.ODOTINTER, l, nil) -> ir.NewSelectorExpr(xpos, ir.ODOTINTER, l, nil)
ir.NodAt(xpos, ir.OXDOT, l, nil) -> ir.NewSelectorExpr(xpos, ir.OXDOT, l, nil)
ir.NodAt(xpos, ir.ODOTTYPE, l, nil) -> ir.NewTypeAssertExpr(xpos, l, nil)
ir.NodAt(xpos, ir.ODOTTYPE, l, r) -> ir.NewTypeAssertExpr(xpos, l, r.(ir.Ntype))
ir.NodAt(xpos, ir.OFOR, l, r) -> ir.NewForStmt(xpos, nil, l, r, nil)
ir.NodAt(xpos, ir.OINDEX, l, r) -> ir.NewIndexExpr(xpos, l, r)
ir.NodAt(xpos, ir.OINLMARK, nil, nil) -> ir.NewInlineMarkStmt(xpos, types.BADWIDTH)
ir.NodAt(xpos, ir.OKEY, l, r) -> ir.NewKeyExpr(xpos, l, r)
ir.NodAt(xpos, ir.OLABEL, nil, nil) -> ir.NewLabelStmt(xpos, nil)
ir.NodAt(xpos, ir.OMAKECHAN, l, r) -> ir.NewMakeExpr(xpos, ir.OMAKECHAN, l, r)
ir.NodAt(xpos, ir.OMAKEMAP, l, r) -> ir.NewMakeExpr(xpos, ir.OMAKEMAP, l, r)
ir.NodAt(xpos, ir.OMAKESLICE, l, r) -> ir.NewMakeExpr(xpos, ir.OMAKESLICE, l, r)
ir.NodAt(xpos, ir.OMAKESLICECOPY, l, r) -> ir.NewMakeExpr(xpos, ir.OMAKESLICECOPY, l, r)
ir.NodAt(xpos, ir.ONIL, nil, nil) -> ir.NewNilExpr(xpos)
ir.NodAt(xpos, ir.OPACK, nil, nil) -> ir.NewPkgName(xpos, nil, nil)
ir.NodAt(xpos, ir.OPAREN, l, nil) -> ir.NewParenExpr(xpos, l)
ir.NodAt(xpos, ir.ORANGE, nil, r) -> ir.NewRangeStmt(xpos, nil, r, nil)
ir.NodAt(xpos, ir.ORESULT, nil, nil) -> ir.NewResultExpr(xpos, nil, types.BADWIDTH)
ir.NodAt(xpos, ir.ORETURN, nil, nil) -> ir.NewReturnStmt(xpos, nil)
ir.NodAt(xpos, ir.OSELECT, nil, nil) -> ir.NewSelectStmt(xpos, nil)
ir.NodAt(xpos, ir.OSEND, l, r) -> ir.NewSendStmt(xpos, l, r)
ir.NodAt(xpos, ir.OSLICE, l, nil) -> ir.NewSliceExpr(xpos, ir.OSLICE, l)
ir.NodAt(xpos, ir.OSLICEARR, l, nil) -> ir.NewSliceExpr(xpos, ir.OSLICEARR, l)
ir.NodAt(xpos, ir.OSLICESTR, l, nil) -> ir.NewSliceExpr(xpos, ir.OSLICESTR, l)
ir.NodAt(xpos, ir.OSLICE3, l, nil) -> ir.NewSliceExpr(xpos, ir.OSLICE3, l)
ir.NodAt(xpos, ir.OSLICE3ARR, l, nil) -> ir.NewSliceExpr(xpos, ir.OSLICE3ARR, l)
ir.NodAt(xpos, ir.OSLICEHEADER, l, nil) -> ir.NewSliceHeaderExpr(xpos, nil, l, nil, nil)
ir.NodAt(xpos, ir.OSWITCH, l, nil) -> ir.NewSwitchStmt(xpos, l, nil)
ir.NodAt(xpos, ir.OINLCALL, nil, nil) -> ir.NewInlinedCallExpr(xpos, nil, nil)
}
rm noder.nod noder.nodSym nodSym nodlSym ir.NodAt ir.Nod
'
Change-Id: Ibf1eb708de8463ae74ccc47d7966cc263a18295e
Reviewed-on: https://go-review.googlesource.com/c/go/+/277933
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2020-12-22 23:55:29 -05:00
|
|
|
r := ir.NewAssignStmt(base.Pos, ir.NewSelectorExpr(base.Pos, ir.ODOT, ir.NewIndexExpr(base.Pos, selv, nodintconst(int64(i))), lookup(f)), val)
|
2020-12-07 14:56:49 -05:00
|
|
|
init = append(init, typecheck(r, ctxStmt))
|
2017-03-07 14:26:27 -08:00
|
|
|
}
|
|
|
|
|
[dev.regabi] cmd/compile: introduce cmd/compile/internal/ir [generated]
If we want to break up package gc at all, we will need to move
the compiler IR it defines into a separate package that can be
imported by packages that gc itself imports. This CL does that.
It also removes the TINT8 etc aliases so that all code is clear
about which package things are coming from.
This CL is automatically generated by the script below.
See the comments in the script for details about the changes.
[git-generate]
cd src/cmd/compile/internal/gc
rf '
# These names were never fully qualified
# when the types package was added.
# Do it now, to avoid confusion about where they live.
inline -rm \
Txxx \
TINT8 \
TUINT8 \
TINT16 \
TUINT16 \
TINT32 \
TUINT32 \
TINT64 \
TUINT64 \
TINT \
TUINT \
TUINTPTR \
TCOMPLEX64 \
TCOMPLEX128 \
TFLOAT32 \
TFLOAT64 \
TBOOL \
TPTR \
TFUNC \
TSLICE \
TARRAY \
TSTRUCT \
TCHAN \
TMAP \
TINTER \
TFORW \
TANY \
TSTRING \
TUNSAFEPTR \
TIDEAL \
TNIL \
TBLANK \
TFUNCARGS \
TCHANARGS \
NTYPE \
BADWIDTH
# esc.go and escape.go do not need to be split.
# Append esc.go onto the end of escape.go.
mv esc.go escape.go
# Pull out the type format installation from func Main,
# so it can be carried into package ir.
mv Main:/Sconv.=/-0,/TypeLinkSym/-1 InstallTypeFormats
# Names that need to be exported for use by code left in gc.
mv Isconst IsConst
mv asNode AsNode
mv asNodes AsNodes
mv asTypesNode AsTypesNode
mv basicnames BasicTypeNames
mv builtinpkg BuiltinPkg
mv consttype ConstType
mv dumplist DumpList
mv fdumplist FDumpList
mv fmtMode FmtMode
mv goopnames OpNames
mv inspect Inspect
mv inspectList InspectList
mv localpkg LocalPkg
mv nblank BlankNode
mv numImport NumImport
mv opprec OpPrec
mv origSym OrigSym
mv stmtwithinit StmtWithInit
mv dump DumpAny
mv fdump FDumpAny
mv nod Nod
mv nodl NodAt
mv newname NewName
mv newnamel NewNameAt
mv assertRepresents AssertValidTypeForConst
mv represents ValidTypeForConst
mv nodlit NewLiteral
# Types and fields that need to be exported for use by gc.
mv nowritebarrierrecCallSym SymAndPos
mv SymAndPos.lineno SymAndPos.Pos
mv SymAndPos.target SymAndPos.Sym
mv Func.lsym Func.LSym
mv Func.setWBPos Func.SetWBPos
mv Func.numReturns Func.NumReturns
mv Func.numDefers Func.NumDefers
mv Func.nwbrCalls Func.NWBRCalls
# initLSym is an algorithm left behind in gc,
# not an operation on Func itself.
mv Func.initLSym initLSym
mv nodeQueue NodeQueue
mv NodeQueue.empty NodeQueue.Empty
mv NodeQueue.popLeft NodeQueue.PopLeft
mv NodeQueue.pushRight NodeQueue.PushRight
# Many methods on Node are actually algorithms that
# would apply to any node implementation.
# Those become plain functions.
mv Node.funcname FuncName
mv Node.isBlank IsBlank
mv Node.isGoConst isGoConst
mv Node.isNil IsNil
mv Node.isParamHeapCopy isParamHeapCopy
mv Node.isParamStackCopy isParamStackCopy
mv Node.isSimpleName isSimpleName
mv Node.mayBeShared MayBeShared
mv Node.pkgFuncName PkgFuncName
mv Node.backingArrayPtrLen backingArrayPtrLen
mv Node.isterminating isTermNode
mv Node.labeledControl labeledControl
mv Nodes.isterminating isTermNodes
mv Nodes.sigerr fmtSignature
mv Node.MethodName methodExprName
mv Node.MethodFunc methodExprFunc
mv Node.IsMethod IsMethod
# Every node will need to implement RawCopy;
# Copy and SepCopy algorithms will use it.
mv Node.rawcopy Node.RawCopy
mv Node.copy Copy
mv Node.sepcopy SepCopy
# Extract Node.Format method body into func FmtNode,
# but leave method wrapper behind.
mv Node.Format:0,$ FmtNode
# Formatting helpers that will apply to all node implementations.
mv Node.Line Line
mv Node.exprfmt exprFmt
mv Node.jconv jconvFmt
mv Node.modeString modeString
mv Node.nconv nconvFmt
mv Node.nodedump nodeDumpFmt
mv Node.nodefmt nodeFmt
mv Node.stmtfmt stmtFmt
# Constant support needed for code moving to ir.
mv okforconst OKForConst
mv vconv FmtConst
mv int64Val Int64Val
mv float64Val Float64Val
mv Node.ValueInterface ConstValue
# Organize code into files.
mv LocalPkg BuiltinPkg ir.go
mv NumImport InstallTypeFormats Line fmt.go
mv syntax.go Nod NodAt NewNameAt Class Pxxx PragmaFlag Nointerface SymAndPos \
AsNode AsTypesNode BlankNode OrigSym \
Node.SliceBounds Node.SetSliceBounds Op.IsSlice3 \
IsConst Node.Int64Val Node.CanInt64 Node.Uint64Val Node.BoolVal Node.StringVal \
Node.RawCopy SepCopy Copy \
IsNil IsBlank IsMethod \
Node.Typ Node.StorageClass node.go
mv ConstType ConstValue Int64Val Float64Val AssertValidTypeForConst ValidTypeForConst NewLiteral idealType OKForConst val.go
# Move files to new ir package.
mv bitset.go class_string.go dump.go fmt.go \
ir.go node.go op_string.go val.go \
sizeof_test.go cmd/compile/internal/ir
'
: # fix mkbuiltin.go to generate the changes made to builtin.go during rf
sed -i '' '
s/\[T/[types.T/g
s/\*Node/*ir.Node/g
/internal\/types/c \
fmt.Fprintln(&b, `import (`) \
fmt.Fprintln(&b, ` "cmd/compile/internal/ir"`) \
fmt.Fprintln(&b, ` "cmd/compile/internal/types"`) \
fmt.Fprintln(&b, `)`)
' mkbuiltin.go
gofmt -w mkbuiltin.go
: # update cmd/dist to add internal/ir
cd ../../../dist
sed -i '' '/compile.internal.gc/a\
"cmd/compile/internal/ir",
' buildtool.go
gofmt -w buildtool.go
: # update cmd/compile TestFormats
cd ../..
go install std cmd
cd cmd/compile
go test -u || go test # first one updates but fails; second passes
Change-Id: I5f7caf6b20629b51970279e81231a3574d5b51db
Reviewed-on: https://go-review.googlesource.com/c/go/+/273008
Trust: Russ Cox <rsc@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2020-11-19 21:09:22 -05:00
|
|
|
c = convnop(c, types.Types[types.TUNSAFEPTR])
|
2020-07-27 16:19:15 -07:00
|
|
|
setField("c", c)
|
[dev.regabi] cmd/compile: clean up in preparation for statement Nodes
Using statement nodes restricts the set of valid SetOp operations,
because you can't SetOp across representation. Rewrite various
code to avoid crossing those as-yet-unintroduced boundaries.
In particular, code like
x, y := v.(T)
x, y := f()
x, y := m[k]
x, y := <-c
starts out with Op = OAS2, and then it turns into a specific Op
OAS2DOTTYPE, OAS2FUNC, OAS2MAPR, OAS2RECV, and then
later in walk is lowered to an OAS2 again.
In the middle, the specific forms move the right-hand side from
n.Rlist().First() to n.Right(), and then the conversion to OAS2 moves
it back. This is unnecessary and makes it hard for these all to
share an underlying Node implementation.
This CL changes these specific forms to leave the right-hand side
in n.Rlist().First().
Similarly, OSELRECV2 is really just a temporary form of OAS2.
This CL changes it to use same fields too.
Finally, this CL fixes the printing of OAS2 nodes in ir/fmt.go,
which formerly printed n.Right() instead of n.Rlist().
This results in a (correct!) update to cmd/compile/internal/logopt's
expected output: ~R0 = <N> becomes ~R0 = &y.b.
Passes buildall w/ toolstash -cmp.
Change-Id: I164aa2e17dc55bfb292024de53d7d250192ad64a
Reviewed-on: https://go-review.googlesource.com/c/go/+/274105
Trust: Russ Cox <rsc@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2020-11-28 15:28:18 -05:00
|
|
|
if !ir.IsBlank(elem) {
|
[dev.regabi] cmd/compile: introduce cmd/compile/internal/ir [generated]
If we want to break up package gc at all, we will need to move
the compiler IR it defines into a separate package that can be
imported by packages that gc itself imports. This CL does that.
It also removes the TINT8 etc aliases so that all code is clear
about which package things are coming from.
This CL is automatically generated by the script below.
See the comments in the script for details about the changes.
[git-generate]
cd src/cmd/compile/internal/gc
rf '
# These names were never fully qualified
# when the types package was added.
# Do it now, to avoid confusion about where they live.
inline -rm \
Txxx \
TINT8 \
TUINT8 \
TINT16 \
TUINT16 \
TINT32 \
TUINT32 \
TINT64 \
TUINT64 \
TINT \
TUINT \
TUINTPTR \
TCOMPLEX64 \
TCOMPLEX128 \
TFLOAT32 \
TFLOAT64 \
TBOOL \
TPTR \
TFUNC \
TSLICE \
TARRAY \
TSTRUCT \
TCHAN \
TMAP \
TINTER \
TFORW \
TANY \
TSTRING \
TUNSAFEPTR \
TIDEAL \
TNIL \
TBLANK \
TFUNCARGS \
TCHANARGS \
NTYPE \
BADWIDTH
# esc.go and escape.go do not need to be split.
# Append esc.go onto the end of escape.go.
mv esc.go escape.go
# Pull out the type format installation from func Main,
# so it can be carried into package ir.
mv Main:/Sconv.=/-0,/TypeLinkSym/-1 InstallTypeFormats
# Names that need to be exported for use by code left in gc.
mv Isconst IsConst
mv asNode AsNode
mv asNodes AsNodes
mv asTypesNode AsTypesNode
mv basicnames BasicTypeNames
mv builtinpkg BuiltinPkg
mv consttype ConstType
mv dumplist DumpList
mv fdumplist FDumpList
mv fmtMode FmtMode
mv goopnames OpNames
mv inspect Inspect
mv inspectList InspectList
mv localpkg LocalPkg
mv nblank BlankNode
mv numImport NumImport
mv opprec OpPrec
mv origSym OrigSym
mv stmtwithinit StmtWithInit
mv dump DumpAny
mv fdump FDumpAny
mv nod Nod
mv nodl NodAt
mv newname NewName
mv newnamel NewNameAt
mv assertRepresents AssertValidTypeForConst
mv represents ValidTypeForConst
mv nodlit NewLiteral
# Types and fields that need to be exported for use by gc.
mv nowritebarrierrecCallSym SymAndPos
mv SymAndPos.lineno SymAndPos.Pos
mv SymAndPos.target SymAndPos.Sym
mv Func.lsym Func.LSym
mv Func.setWBPos Func.SetWBPos
mv Func.numReturns Func.NumReturns
mv Func.numDefers Func.NumDefers
mv Func.nwbrCalls Func.NWBRCalls
# initLSym is an algorithm left behind in gc,
# not an operation on Func itself.
mv Func.initLSym initLSym
mv nodeQueue NodeQueue
mv NodeQueue.empty NodeQueue.Empty
mv NodeQueue.popLeft NodeQueue.PopLeft
mv NodeQueue.pushRight NodeQueue.PushRight
# Many methods on Node are actually algorithms that
# would apply to any node implementation.
# Those become plain functions.
mv Node.funcname FuncName
mv Node.isBlank IsBlank
mv Node.isGoConst isGoConst
mv Node.isNil IsNil
mv Node.isParamHeapCopy isParamHeapCopy
mv Node.isParamStackCopy isParamStackCopy
mv Node.isSimpleName isSimpleName
mv Node.mayBeShared MayBeShared
mv Node.pkgFuncName PkgFuncName
mv Node.backingArrayPtrLen backingArrayPtrLen
mv Node.isterminating isTermNode
mv Node.labeledControl labeledControl
mv Nodes.isterminating isTermNodes
mv Nodes.sigerr fmtSignature
mv Node.MethodName methodExprName
mv Node.MethodFunc methodExprFunc
mv Node.IsMethod IsMethod
# Every node will need to implement RawCopy;
# Copy and SepCopy algorithms will use it.
mv Node.rawcopy Node.RawCopy
mv Node.copy Copy
mv Node.sepcopy SepCopy
# Extract Node.Format method body into func FmtNode,
# but leave method wrapper behind.
mv Node.Format:0,$ FmtNode
# Formatting helpers that will apply to all node implementations.
mv Node.Line Line
mv Node.exprfmt exprFmt
mv Node.jconv jconvFmt
mv Node.modeString modeString
mv Node.nconv nconvFmt
mv Node.nodedump nodeDumpFmt
mv Node.nodefmt nodeFmt
mv Node.stmtfmt stmtFmt
# Constant support needed for code moving to ir.
mv okforconst OKForConst
mv vconv FmtConst
mv int64Val Int64Val
mv float64Val Float64Val
mv Node.ValueInterface ConstValue
# Organize code into files.
mv LocalPkg BuiltinPkg ir.go
mv NumImport InstallTypeFormats Line fmt.go
mv syntax.go Nod NodAt NewNameAt Class Pxxx PragmaFlag Nointerface SymAndPos \
AsNode AsTypesNode BlankNode OrigSym \
Node.SliceBounds Node.SetSliceBounds Op.IsSlice3 \
IsConst Node.Int64Val Node.CanInt64 Node.Uint64Val Node.BoolVal Node.StringVal \
Node.RawCopy SepCopy Copy \
IsNil IsBlank IsMethod \
Node.Typ Node.StorageClass node.go
mv ConstType ConstValue Int64Val Float64Val AssertValidTypeForConst ValidTypeForConst NewLiteral idealType OKForConst val.go
# Move files to new ir package.
mv bitset.go class_string.go dump.go fmt.go \
ir.go node.go op_string.go val.go \
sizeof_test.go cmd/compile/internal/ir
'
: # fix mkbuiltin.go to generate the changes made to builtin.go during rf
sed -i '' '
s/\[T/[types.T/g
s/\*Node/*ir.Node/g
/internal\/types/c \
fmt.Fprintln(&b, `import (`) \
fmt.Fprintln(&b, ` "cmd/compile/internal/ir"`) \
fmt.Fprintln(&b, ` "cmd/compile/internal/types"`) \
fmt.Fprintln(&b, `)`)
' mkbuiltin.go
gofmt -w mkbuiltin.go
: # update cmd/dist to add internal/ir
cd ../../../dist
sed -i '' '/compile.internal.gc/a\
"cmd/compile/internal/ir",
' buildtool.go
gofmt -w buildtool.go
: # update cmd/compile TestFormats
cd ../..
go install std cmd
cd cmd/compile
go test -u || go test # first one updates but fails; second passes
Change-Id: I5f7caf6b20629b51970279e81231a3574d5b51db
Reviewed-on: https://go-review.googlesource.com/c/go/+/273008
Trust: Russ Cox <rsc@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2020-11-19 21:09:22 -05:00
|
|
|
elem = convnop(elem, types.Types[types.TUNSAFEPTR])
|
2017-03-07 14:26:27 -08:00
|
|
|
setField("elem", elem)
|
|
|
|
}
|
|
|
|
|
|
|
|
// TODO(mdempsky): There should be a cleaner way to
|
|
|
|
// handle this.
|
2020-11-19 20:49:23 -05:00
|
|
|
if base.Flag.Race {
|
[dev.regabi] cmd/compile: remove ir.Nod [generated]
Rewrite all uses of ir.Nod and friends to call the IR constructors directly.
This gives the results a more specific type and will play nicely with
introduction of more specific types throughout the code in a followup CL.
Passes buildall w/ toolstash -cmp.
[git-generate]
cd src/cmd/compile/internal/gc
rf '
ex . ../ir {
import "cmd/compile/internal/ir"
import "cmd/compile/internal/types"
import "cmd/compile/internal/syntax"
import "cmd/internal/src"
var p *noder
var orig syntax.Node
var op ir.Op
var l, r ir.Node
var sym *types.Sym
p.nod(orig, op, l, r) -> ir.NodAt(p.pos(orig), op, l, r)
p.nodSym(orig, op, l, sym) -> nodlSym(p.pos(orig), op, l, sym)
var xpos src.XPos
var ns ir.Nodes
npos(xpos, nodSym(op, l, sym)) -> nodlSym(xpos, op, l, sym)
npos(xpos, liststmt(ns)) -> ir.NewBlockStmt(xpos, ns)
}
ex . ../ir {
import "cmd/compile/internal/base"
import "cmd/compile/internal/ir"
import "cmd/compile/internal/types"
var op ir.Op
var l, r ir.Node
ir.Nod(op, l, r) -> ir.NodAt(base.Pos, op, l, r)
var sym *types.Sym
nodSym(op, l, sym) -> nodlSym(base.Pos, op, l, sym)
}
ex . ../ir {
import "cmd/compile/internal/ir"
import "cmd/internal/src"
# rf overlapping match handling is not quite good enough
# for certain nested rewrites, so handle these two - which often contain other ir.NodAt calls - early.
var l, r ir.Node
var xpos src.XPos
ir.NodAt(xpos, ir.OAS, l, r) -> ir.NewAssignStmt(xpos, l, r)
ir.NodAt(xpos, ir.OIF, l, nil) -> ir.NewIfStmt(xpos, l, nil, nil)
}
ex . ../ir {
import "cmd/compile/internal/ir"
import "cmd/compile/internal/types"
import "cmd/internal/src"
var l, r ir.Node
var sym *types.Sym
var xpos src.XPos
nodlSym(xpos, ir.ODOT, l, sym) -> ir.NewSelectorExpr(xpos, ir.ODOT, l, sym)
nodlSym(xpos, ir.OXDOT, l, sym) -> ir.NewSelectorExpr(xpos, ir.OXDOT, l, sym)
nodlSym(xpos, ir.ODOTPTR, l, sym) -> ir.NewSelectorExpr(xpos, ir.ODOTPTR, l, sym)
nodlSym(xpos, ir.OGOTO, nil, sym) -> ir.NewBranchStmt(xpos, ir.OGOTO, sym)
nodlSym(xpos, ir.ORETJMP, nil, sym) -> ir.NewBranchStmt(xpos, ir.ORETJMP, sym)
nodlSym(xpos, ir.OLABEL, nil, sym) -> ir.NewLabelStmt(xpos, sym)
nodlSym(xpos, ir.OSTRUCTKEY, l, sym) -> ir.NewStructKeyExpr(xpos, sym, l)
ir.NodAt(xpos, ir.OADD, l, r) -> ir.NewBinaryExpr(xpos, ir.OADD, l, r)
ir.NodAt(xpos, ir.OAND, l, r) -> ir.NewBinaryExpr(xpos, ir.OAND, l, r)
ir.NodAt(xpos, ir.OANDNOT, l, r) -> ir.NewBinaryExpr(xpos, ir.OANDNOT, l, r)
ir.NodAt(xpos, ir.ODIV, l, r) -> ir.NewBinaryExpr(xpos, ir.ODIV, l, r)
ir.NodAt(xpos, ir.OEQ, l, r) -> ir.NewBinaryExpr(xpos, ir.OEQ, l, r)
ir.NodAt(xpos, ir.OGE, l, r) -> ir.NewBinaryExpr(xpos, ir.OGE, l, r)
ir.NodAt(xpos, ir.OGT, l, r) -> ir.NewBinaryExpr(xpos, ir.OGT, l, r)
ir.NodAt(xpos, ir.OLE, l, r) -> ir.NewBinaryExpr(xpos, ir.OLE, l, r)
ir.NodAt(xpos, ir.OLSH, l, r) -> ir.NewBinaryExpr(xpos, ir.OLSH, l, r)
ir.NodAt(xpos, ir.OLT, l, r) -> ir.NewBinaryExpr(xpos, ir.OLT, l, r)
ir.NodAt(xpos, ir.OMOD, l, r) -> ir.NewBinaryExpr(xpos, ir.OMOD, l, r)
ir.NodAt(xpos, ir.OMUL, l, r) -> ir.NewBinaryExpr(xpos, ir.OMUL, l, r)
ir.NodAt(xpos, ir.ONE, l, r) -> ir.NewBinaryExpr(xpos, ir.ONE, l, r)
ir.NodAt(xpos, ir.OOR, l, r) -> ir.NewBinaryExpr(xpos, ir.OOR, l, r)
ir.NodAt(xpos, ir.ORSH, l, r) -> ir.NewBinaryExpr(xpos, ir.ORSH, l, r)
ir.NodAt(xpos, ir.OSUB, l, r) -> ir.NewBinaryExpr(xpos, ir.OSUB, l, r)
ir.NodAt(xpos, ir.OXOR, l, r) -> ir.NewBinaryExpr(xpos, ir.OXOR, l, r)
ir.NodAt(xpos, ir.OCOPY, l, r) -> ir.NewBinaryExpr(xpos, ir.OCOPY, l, r)
ir.NodAt(xpos, ir.OCOMPLEX, l, r) -> ir.NewBinaryExpr(xpos, ir.OCOMPLEX, l, r)
ir.NodAt(xpos, ir.OEFACE, l, r) -> ir.NewBinaryExpr(xpos, ir.OEFACE, l, r)
ir.NodAt(xpos, ir.OADDR, l, nil) -> ir.NewAddrExpr(xpos, l)
ir.NodAt(xpos, ir.OADDSTR, nil, nil) -> ir.NewAddStringExpr(xpos, nil)
ir.NodAt(xpos, ir.OANDAND, l, r) -> ir.NewLogicalExpr(xpos, ir.OANDAND, l, r)
ir.NodAt(xpos, ir.OOROR, l, r) -> ir.NewLogicalExpr(xpos, ir.OOROR, l, r)
ir.NodAt(xpos, ir.OARRAYLIT, nil, nil) -> ir.NewCompLitExpr(xpos, ir.OARRAYLIT, nil, nil)
ir.NodAt(xpos, ir.OCOMPLIT, nil, nil) -> ir.NewCompLitExpr(xpos, ir.OCOMPLIT, nil, nil)
ir.NodAt(xpos, ir.OMAPLIT, nil, nil) -> ir.NewCompLitExpr(xpos, ir.OMAPLIT, nil, nil)
ir.NodAt(xpos, ir.OSTRUCTLIT, nil, nil) -> ir.NewCompLitExpr(xpos, ir.OSTRUCTLIT, nil, nil)
ir.NodAt(xpos, ir.OSLICELIT, nil, nil) -> ir.NewCompLitExpr(xpos, ir.OSLICELIT, nil, nil)
ir.NodAt(xpos, ir.OARRAYLIT, nil, r) -> ir.NewCompLitExpr(xpos, ir.OARRAYLIT, r.(ir.Ntype), nil)
ir.NodAt(xpos, ir.OCOMPLIT, nil, r) -> ir.NewCompLitExpr(xpos, ir.OCOMPLIT, r.(ir.Ntype), nil)
ir.NodAt(xpos, ir.OMAPLIT, nil, r) -> ir.NewCompLitExpr(xpos, ir.OMAPLIT, r.(ir.Ntype), nil)
ir.NodAt(xpos, ir.OSTRUCTLIT, nil, r) -> ir.NewCompLitExpr(xpos, ir.OSTRUCTLIT, r.(ir.Ntype), nil)
ir.NodAt(xpos, ir.OSLICELIT, nil, r) -> ir.NewCompLitExpr(xpos, ir.OSLICELIT, r.(ir.Ntype), nil)
ir.NodAt(xpos, ir.OAS2, nil, nil) -> ir.NewAssignListStmt(xpos, ir.OAS2, nil, nil)
ir.NodAt(xpos, ir.OAS2DOTTYPE, nil, nil) -> ir.NewAssignListStmt(xpos, ir.OAS2DOTTYPE, nil, nil)
ir.NodAt(xpos, ir.OAS2FUNC, nil, nil) -> ir.NewAssignListStmt(xpos, ir.OAS2FUNC, nil, nil)
ir.NodAt(xpos, ir.OAS2MAPR, nil, nil) -> ir.NewAssignListStmt(xpos, ir.OAS2MAPR, nil, nil)
ir.NodAt(xpos, ir.OAS2RECV, nil, nil) -> ir.NewAssignListStmt(xpos, ir.OAS2RECV, nil, nil)
ir.NodAt(xpos, ir.OSELRECV2, nil, nil) -> ir.NewAssignListStmt(xpos, ir.OSELRECV2, nil, nil)
ir.NodAt(xpos, ir.OASOP, l, r) -> ir.NewAssignOpStmt(xpos, ir.OXXX, l, r)
ir.NodAt(xpos, ir.OBITNOT, l, nil) -> ir.NewUnaryExpr(xpos, ir.OBITNOT, l)
ir.NodAt(xpos, ir.ONEG, l, nil) -> ir.NewUnaryExpr(xpos, ir.ONEG, l)
ir.NodAt(xpos, ir.ONOT, l, nil) -> ir.NewUnaryExpr(xpos, ir.ONOT, l)
ir.NodAt(xpos, ir.OPLUS, l, nil) -> ir.NewUnaryExpr(xpos, ir.OPLUS, l)
ir.NodAt(xpos, ir.ORECV, l, nil) -> ir.NewUnaryExpr(xpos, ir.ORECV, l)
ir.NodAt(xpos, ir.OALIGNOF, l, nil) -> ir.NewUnaryExpr(xpos, ir.OALIGNOF, l)
ir.NodAt(xpos, ir.OCAP, l, nil) -> ir.NewUnaryExpr(xpos, ir.OCAP, l)
ir.NodAt(xpos, ir.OCLOSE, l, nil) -> ir.NewUnaryExpr(xpos, ir.OCLOSE, l)
ir.NodAt(xpos, ir.OIMAG, l, nil) -> ir.NewUnaryExpr(xpos, ir.OIMAG, l)
ir.NodAt(xpos, ir.OLEN, l, nil) -> ir.NewUnaryExpr(xpos, ir.OLEN, l)
ir.NodAt(xpos, ir.ONEW, l, nil) -> ir.NewUnaryExpr(xpos, ir.ONEW, l)
ir.NodAt(xpos, ir.ONEWOBJ, l, nil) -> ir.NewUnaryExpr(xpos, ir.ONEWOBJ, l)
ir.NodAt(xpos, ir.OOFFSETOF, l, nil) -> ir.NewUnaryExpr(xpos, ir.OOFFSETOF, l)
ir.NodAt(xpos, ir.OPANIC, l, nil) -> ir.NewUnaryExpr(xpos, ir.OPANIC, l)
ir.NodAt(xpos, ir.OREAL, l, nil) -> ir.NewUnaryExpr(xpos, ir.OREAL, l)
ir.NodAt(xpos, ir.OSIZEOF, l, nil) -> ir.NewUnaryExpr(xpos, ir.OSIZEOF, l)
ir.NodAt(xpos, ir.OCHECKNIL, l, nil) -> ir.NewUnaryExpr(xpos, ir.OCHECKNIL, l)
ir.NodAt(xpos, ir.OCFUNC, l, nil) -> ir.NewUnaryExpr(xpos, ir.OCFUNC, l)
ir.NodAt(xpos, ir.OIDATA, l, nil) -> ir.NewUnaryExpr(xpos, ir.OIDATA, l)
ir.NodAt(xpos, ir.OITAB, l, nil) -> ir.NewUnaryExpr(xpos, ir.OITAB, l)
ir.NodAt(xpos, ir.OSPTR, l, nil) -> ir.NewUnaryExpr(xpos, ir.OSPTR, l)
ir.NodAt(xpos, ir.OVARDEF, l, nil) -> ir.NewUnaryExpr(xpos, ir.OVARDEF, l)
ir.NodAt(xpos, ir.OVARKILL, l, nil) -> ir.NewUnaryExpr(xpos, ir.OVARKILL, l)
ir.NodAt(xpos, ir.OVARLIVE, l, nil) -> ir.NewUnaryExpr(xpos, ir.OVARLIVE, l)
ir.NodAt(xpos, ir.OBLOCK, nil, nil) -> ir.NewBlockStmt(xpos, nil)
ir.NodAt(xpos, ir.OBREAK, nil, nil) -> ir.NewBranchStmt(xpos, ir.OBREAK, nil)
ir.NodAt(xpos, ir.OCONTINUE, nil, nil) -> ir.NewBranchStmt(xpos, ir.OCONTINUE, nil)
ir.NodAt(xpos, ir.OFALL, nil, nil) -> ir.NewBranchStmt(xpos, ir.OFALL, nil)
ir.NodAt(xpos, ir.OGOTO, nil, nil) -> ir.NewBranchStmt(xpos, ir.OGOTO, nil)
ir.NodAt(xpos, ir.ORETJMP, nil, nil) -> ir.NewBranchStmt(xpos, ir.ORETJMP, nil)
ir.NodAt(xpos, ir.OCALL, l, nil) -> ir.NewCallExpr(xpos, ir.OCALL, l, nil)
ir.NodAt(xpos, ir.OCALLFUNC, l, nil) -> ir.NewCallExpr(xpos, ir.OCALLFUNC, l, nil)
ir.NodAt(xpos, ir.OCALLINTER, l, nil) -> ir.NewCallExpr(xpos, ir.OCALLINTER, l, nil)
ir.NodAt(xpos, ir.OCALLMETH, l, nil) -> ir.NewCallExpr(xpos, ir.OCALLMETH, l, nil)
ir.NodAt(xpos, ir.OAPPEND, l, nil) -> ir.NewCallExpr(xpos, ir.OAPPEND, l, nil)
ir.NodAt(xpos, ir.ODELETE, l, nil) -> ir.NewCallExpr(xpos, ir.ODELETE, l, nil)
ir.NodAt(xpos, ir.OGETG, l, nil) -> ir.NewCallExpr(xpos, ir.OGETG, l, nil)
ir.NodAt(xpos, ir.OMAKE, l, nil) -> ir.NewCallExpr(xpos, ir.OMAKE, l, nil)
ir.NodAt(xpos, ir.OPRINT, l, nil) -> ir.NewCallExpr(xpos, ir.OPRINT, l, nil)
ir.NodAt(xpos, ir.OPRINTN, l, nil) -> ir.NewCallExpr(xpos, ir.OPRINTN, l, nil)
ir.NodAt(xpos, ir.ORECOVER, l, nil) -> ir.NewCallExpr(xpos, ir.ORECOVER, l, nil)
ir.NodAt(xpos, ir.OCASE, nil, nil) -> ir.NewCaseStmt(xpos, nil, nil)
ir.NodAt(xpos, ir.OCONV, l, nil) -> ir.NewConvExpr(xpos, ir.OCONV, nil, l)
ir.NodAt(xpos, ir.OCONVIFACE, l, nil) -> ir.NewConvExpr(xpos, ir.OCONVIFACE, nil, l)
ir.NodAt(xpos, ir.OCONVNOP, l, nil) -> ir.NewConvExpr(xpos, ir.OCONVNOP, nil, l)
ir.NodAt(xpos, ir.ORUNESTR, l, nil) -> ir.NewConvExpr(xpos, ir.ORUNESTR, nil, l)
ir.NodAt(xpos, ir.ODCL, l, nil) -> ir.NewDecl(xpos, ir.ODCL, l)
ir.NodAt(xpos, ir.ODCLCONST, l, nil) -> ir.NewDecl(xpos, ir.ODCLCONST, l)
ir.NodAt(xpos, ir.ODCLTYPE, l, nil) -> ir.NewDecl(xpos, ir.ODCLTYPE, l)
ir.NodAt(xpos, ir.ODCLFUNC, nil, nil) -> ir.NewFunc(xpos)
ir.NodAt(xpos, ir.ODEFER, l, nil) -> ir.NewGoDeferStmt(xpos, ir.ODEFER, l)
ir.NodAt(xpos, ir.OGO, l, nil) -> ir.NewGoDeferStmt(xpos, ir.OGO, l)
ir.NodAt(xpos, ir.ODEREF, l, nil) -> ir.NewStarExpr(xpos, l)
ir.NodAt(xpos, ir.ODOT, l, nil) -> ir.NewSelectorExpr(xpos, ir.ODOT, l, nil)
ir.NodAt(xpos, ir.ODOTPTR, l, nil) -> ir.NewSelectorExpr(xpos, ir.ODOTPTR, l, nil)
ir.NodAt(xpos, ir.ODOTMETH, l, nil) -> ir.NewSelectorExpr(xpos, ir.ODOTMETH, l, nil)
ir.NodAt(xpos, ir.ODOTINTER, l, nil) -> ir.NewSelectorExpr(xpos, ir.ODOTINTER, l, nil)
ir.NodAt(xpos, ir.OXDOT, l, nil) -> ir.NewSelectorExpr(xpos, ir.OXDOT, l, nil)
ir.NodAt(xpos, ir.ODOTTYPE, l, nil) -> ir.NewTypeAssertExpr(xpos, l, nil)
ir.NodAt(xpos, ir.ODOTTYPE, l, r) -> ir.NewTypeAssertExpr(xpos, l, r.(ir.Ntype))
ir.NodAt(xpos, ir.OFOR, l, r) -> ir.NewForStmt(xpos, nil, l, r, nil)
ir.NodAt(xpos, ir.OINDEX, l, r) -> ir.NewIndexExpr(xpos, l, r)
ir.NodAt(xpos, ir.OINLMARK, nil, nil) -> ir.NewInlineMarkStmt(xpos, types.BADWIDTH)
ir.NodAt(xpos, ir.OKEY, l, r) -> ir.NewKeyExpr(xpos, l, r)
ir.NodAt(xpos, ir.OLABEL, nil, nil) -> ir.NewLabelStmt(xpos, nil)
ir.NodAt(xpos, ir.OMAKECHAN, l, r) -> ir.NewMakeExpr(xpos, ir.OMAKECHAN, l, r)
ir.NodAt(xpos, ir.OMAKEMAP, l, r) -> ir.NewMakeExpr(xpos, ir.OMAKEMAP, l, r)
ir.NodAt(xpos, ir.OMAKESLICE, l, r) -> ir.NewMakeExpr(xpos, ir.OMAKESLICE, l, r)
ir.NodAt(xpos, ir.OMAKESLICECOPY, l, r) -> ir.NewMakeExpr(xpos, ir.OMAKESLICECOPY, l, r)
ir.NodAt(xpos, ir.ONIL, nil, nil) -> ir.NewNilExpr(xpos)
ir.NodAt(xpos, ir.OPACK, nil, nil) -> ir.NewPkgName(xpos, nil, nil)
ir.NodAt(xpos, ir.OPAREN, l, nil) -> ir.NewParenExpr(xpos, l)
ir.NodAt(xpos, ir.ORANGE, nil, r) -> ir.NewRangeStmt(xpos, nil, r, nil)
ir.NodAt(xpos, ir.ORESULT, nil, nil) -> ir.NewResultExpr(xpos, nil, types.BADWIDTH)
ir.NodAt(xpos, ir.ORETURN, nil, nil) -> ir.NewReturnStmt(xpos, nil)
ir.NodAt(xpos, ir.OSELECT, nil, nil) -> ir.NewSelectStmt(xpos, nil)
ir.NodAt(xpos, ir.OSEND, l, r) -> ir.NewSendStmt(xpos, l, r)
ir.NodAt(xpos, ir.OSLICE, l, nil) -> ir.NewSliceExpr(xpos, ir.OSLICE, l)
ir.NodAt(xpos, ir.OSLICEARR, l, nil) -> ir.NewSliceExpr(xpos, ir.OSLICEARR, l)
ir.NodAt(xpos, ir.OSLICESTR, l, nil) -> ir.NewSliceExpr(xpos, ir.OSLICESTR, l)
ir.NodAt(xpos, ir.OSLICE3, l, nil) -> ir.NewSliceExpr(xpos, ir.OSLICE3, l)
ir.NodAt(xpos, ir.OSLICE3ARR, l, nil) -> ir.NewSliceExpr(xpos, ir.OSLICE3ARR, l)
ir.NodAt(xpos, ir.OSLICEHEADER, l, nil) -> ir.NewSliceHeaderExpr(xpos, nil, l, nil, nil)
ir.NodAt(xpos, ir.OSWITCH, l, nil) -> ir.NewSwitchStmt(xpos, l, nil)
ir.NodAt(xpos, ir.OINLCALL, nil, nil) -> ir.NewInlinedCallExpr(xpos, nil, nil)
}
rm noder.nod noder.nodSym nodSym nodlSym ir.NodAt ir.Nod
'
Change-Id: Ibf1eb708de8463ae74ccc47d7966cc263a18295e
Reviewed-on: https://go-review.googlesource.com/c/go/+/277933
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2020-12-22 23:55:29 -05:00
|
|
|
r := mkcall("selectsetpc", nil, nil, nodAddr(ir.NewIndexExpr(base.Pos, pcs, nodintconst(int64(i)))))
|
2017-03-07 14:26:27 -08:00
|
|
|
init = append(init, r)
|
|
|
|
}
|
2017-03-01 15:50:57 -08:00
|
|
|
}
|
2020-07-27 16:19:15 -07:00
|
|
|
if nsends+nrecvs != ncas {
|
2020-11-19 20:49:23 -05:00
|
|
|
base.Fatalf("walkselectcases: miscount: %v + %v != %v", nsends, nrecvs, ncas)
|
2020-07-27 16:19:15 -07:00
|
|
|
}
|
2017-03-01 15:50:57 -08:00
|
|
|
|
|
|
|
// run the select
|
2020-11-19 20:49:23 -05:00
|
|
|
base.Pos = sellineno
|
[dev.regabi] cmd/compile: introduce cmd/compile/internal/ir [generated]
If we want to break up package gc at all, we will need to move
the compiler IR it defines into a separate package that can be
imported by packages that gc itself imports. This CL does that.
It also removes the TINT8 etc aliases so that all code is clear
about which package things are coming from.
This CL is automatically generated by the script below.
See the comments in the script for details about the changes.
[git-generate]
cd src/cmd/compile/internal/gc
rf '
# These names were never fully qualified
# when the types package was added.
# Do it now, to avoid confusion about where they live.
inline -rm \
Txxx \
TINT8 \
TUINT8 \
TINT16 \
TUINT16 \
TINT32 \
TUINT32 \
TINT64 \
TUINT64 \
TINT \
TUINT \
TUINTPTR \
TCOMPLEX64 \
TCOMPLEX128 \
TFLOAT32 \
TFLOAT64 \
TBOOL \
TPTR \
TFUNC \
TSLICE \
TARRAY \
TSTRUCT \
TCHAN \
TMAP \
TINTER \
TFORW \
TANY \
TSTRING \
TUNSAFEPTR \
TIDEAL \
TNIL \
TBLANK \
TFUNCARGS \
TCHANARGS \
NTYPE \
BADWIDTH
# esc.go and escape.go do not need to be split.
# Append esc.go onto the end of escape.go.
mv esc.go escape.go
# Pull out the type format installation from func Main,
# so it can be carried into package ir.
mv Main:/Sconv.=/-0,/TypeLinkSym/-1 InstallTypeFormats
# Names that need to be exported for use by code left in gc.
mv Isconst IsConst
mv asNode AsNode
mv asNodes AsNodes
mv asTypesNode AsTypesNode
mv basicnames BasicTypeNames
mv builtinpkg BuiltinPkg
mv consttype ConstType
mv dumplist DumpList
mv fdumplist FDumpList
mv fmtMode FmtMode
mv goopnames OpNames
mv inspect Inspect
mv inspectList InspectList
mv localpkg LocalPkg
mv nblank BlankNode
mv numImport NumImport
mv opprec OpPrec
mv origSym OrigSym
mv stmtwithinit StmtWithInit
mv dump DumpAny
mv fdump FDumpAny
mv nod Nod
mv nodl NodAt
mv newname NewName
mv newnamel NewNameAt
mv assertRepresents AssertValidTypeForConst
mv represents ValidTypeForConst
mv nodlit NewLiteral
# Types and fields that need to be exported for use by gc.
mv nowritebarrierrecCallSym SymAndPos
mv SymAndPos.lineno SymAndPos.Pos
mv SymAndPos.target SymAndPos.Sym
mv Func.lsym Func.LSym
mv Func.setWBPos Func.SetWBPos
mv Func.numReturns Func.NumReturns
mv Func.numDefers Func.NumDefers
mv Func.nwbrCalls Func.NWBRCalls
# initLSym is an algorithm left behind in gc,
# not an operation on Func itself.
mv Func.initLSym initLSym
mv nodeQueue NodeQueue
mv NodeQueue.empty NodeQueue.Empty
mv NodeQueue.popLeft NodeQueue.PopLeft
mv NodeQueue.pushRight NodeQueue.PushRight
# Many methods on Node are actually algorithms that
# would apply to any node implementation.
# Those become plain functions.
mv Node.funcname FuncName
mv Node.isBlank IsBlank
mv Node.isGoConst isGoConst
mv Node.isNil IsNil
mv Node.isParamHeapCopy isParamHeapCopy
mv Node.isParamStackCopy isParamStackCopy
mv Node.isSimpleName isSimpleName
mv Node.mayBeShared MayBeShared
mv Node.pkgFuncName PkgFuncName
mv Node.backingArrayPtrLen backingArrayPtrLen
mv Node.isterminating isTermNode
mv Node.labeledControl labeledControl
mv Nodes.isterminating isTermNodes
mv Nodes.sigerr fmtSignature
mv Node.MethodName methodExprName
mv Node.MethodFunc methodExprFunc
mv Node.IsMethod IsMethod
# Every node will need to implement RawCopy;
# Copy and SepCopy algorithms will use it.
mv Node.rawcopy Node.RawCopy
mv Node.copy Copy
mv Node.sepcopy SepCopy
# Extract Node.Format method body into func FmtNode,
# but leave method wrapper behind.
mv Node.Format:0,$ FmtNode
# Formatting helpers that will apply to all node implementations.
mv Node.Line Line
mv Node.exprfmt exprFmt
mv Node.jconv jconvFmt
mv Node.modeString modeString
mv Node.nconv nconvFmt
mv Node.nodedump nodeDumpFmt
mv Node.nodefmt nodeFmt
mv Node.stmtfmt stmtFmt
# Constant support needed for code moving to ir.
mv okforconst OKForConst
mv vconv FmtConst
mv int64Val Int64Val
mv float64Val Float64Val
mv Node.ValueInterface ConstValue
# Organize code into files.
mv LocalPkg BuiltinPkg ir.go
mv NumImport InstallTypeFormats Line fmt.go
mv syntax.go Nod NodAt NewNameAt Class Pxxx PragmaFlag Nointerface SymAndPos \
AsNode AsTypesNode BlankNode OrigSym \
Node.SliceBounds Node.SetSliceBounds Op.IsSlice3 \
IsConst Node.Int64Val Node.CanInt64 Node.Uint64Val Node.BoolVal Node.StringVal \
Node.RawCopy SepCopy Copy \
IsNil IsBlank IsMethod \
Node.Typ Node.StorageClass node.go
mv ConstType ConstValue Int64Val Float64Val AssertValidTypeForConst ValidTypeForConst NewLiteral idealType OKForConst val.go
# Move files to new ir package.
mv bitset.go class_string.go dump.go fmt.go \
ir.go node.go op_string.go val.go \
sizeof_test.go cmd/compile/internal/ir
'
: # fix mkbuiltin.go to generate the changes made to builtin.go during rf
sed -i '' '
s/\[T/[types.T/g
s/\*Node/*ir.Node/g
/internal\/types/c \
fmt.Fprintln(&b, `import (`) \
fmt.Fprintln(&b, ` "cmd/compile/internal/ir"`) \
fmt.Fprintln(&b, ` "cmd/compile/internal/types"`) \
fmt.Fprintln(&b, `)`)
' mkbuiltin.go
gofmt -w mkbuiltin.go
: # update cmd/dist to add internal/ir
cd ../../../dist
sed -i '' '/compile.internal.gc/a\
"cmd/compile/internal/ir",
' buildtool.go
gofmt -w buildtool.go
: # update cmd/compile TestFormats
cd ../..
go install std cmd
cd cmd/compile
go test -u || go test # first one updates but fails; second passes
Change-Id: I5f7caf6b20629b51970279e81231a3574d5b51db
Reviewed-on: https://go-review.googlesource.com/c/go/+/273008
Trust: Russ Cox <rsc@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2020-11-19 21:09:22 -05:00
|
|
|
chosen := temp(types.Types[types.TINT])
|
|
|
|
recvOK := temp(types.Types[types.TBOOL])
|
[dev.regabi] cmd/compile: remove ir.Nod [generated]
Rewrite all uses of ir.Nod and friends to call the IR constructors directly.
This gives the results a more specific type and will play nicely with
introduction of more specific types throughout the code in a followup CL.
Passes buildall w/ toolstash -cmp.
[git-generate]
cd src/cmd/compile/internal/gc
rf '
ex . ../ir {
import "cmd/compile/internal/ir"
import "cmd/compile/internal/types"
import "cmd/compile/internal/syntax"
import "cmd/internal/src"
var p *noder
var orig syntax.Node
var op ir.Op
var l, r ir.Node
var sym *types.Sym
p.nod(orig, op, l, r) -> ir.NodAt(p.pos(orig), op, l, r)
p.nodSym(orig, op, l, sym) -> nodlSym(p.pos(orig), op, l, sym)
var xpos src.XPos
var ns ir.Nodes
npos(xpos, nodSym(op, l, sym)) -> nodlSym(xpos, op, l, sym)
npos(xpos, liststmt(ns)) -> ir.NewBlockStmt(xpos, ns)
}
ex . ../ir {
import "cmd/compile/internal/base"
import "cmd/compile/internal/ir"
import "cmd/compile/internal/types"
var op ir.Op
var l, r ir.Node
ir.Nod(op, l, r) -> ir.NodAt(base.Pos, op, l, r)
var sym *types.Sym
nodSym(op, l, sym) -> nodlSym(base.Pos, op, l, sym)
}
ex . ../ir {
import "cmd/compile/internal/ir"
import "cmd/internal/src"
# rf overlapping match handling is not quite good enough
# for certain nested rewrites, so handle these two - which often contain other ir.NodAt calls - early.
var l, r ir.Node
var xpos src.XPos
ir.NodAt(xpos, ir.OAS, l, r) -> ir.NewAssignStmt(xpos, l, r)
ir.NodAt(xpos, ir.OIF, l, nil) -> ir.NewIfStmt(xpos, l, nil, nil)
}
ex . ../ir {
import "cmd/compile/internal/ir"
import "cmd/compile/internal/types"
import "cmd/internal/src"
var l, r ir.Node
var sym *types.Sym
var xpos src.XPos
nodlSym(xpos, ir.ODOT, l, sym) -> ir.NewSelectorExpr(xpos, ir.ODOT, l, sym)
nodlSym(xpos, ir.OXDOT, l, sym) -> ir.NewSelectorExpr(xpos, ir.OXDOT, l, sym)
nodlSym(xpos, ir.ODOTPTR, l, sym) -> ir.NewSelectorExpr(xpos, ir.ODOTPTR, l, sym)
nodlSym(xpos, ir.OGOTO, nil, sym) -> ir.NewBranchStmt(xpos, ir.OGOTO, sym)
nodlSym(xpos, ir.ORETJMP, nil, sym) -> ir.NewBranchStmt(xpos, ir.ORETJMP, sym)
nodlSym(xpos, ir.OLABEL, nil, sym) -> ir.NewLabelStmt(xpos, sym)
nodlSym(xpos, ir.OSTRUCTKEY, l, sym) -> ir.NewStructKeyExpr(xpos, sym, l)
ir.NodAt(xpos, ir.OADD, l, r) -> ir.NewBinaryExpr(xpos, ir.OADD, l, r)
ir.NodAt(xpos, ir.OAND, l, r) -> ir.NewBinaryExpr(xpos, ir.OAND, l, r)
ir.NodAt(xpos, ir.OANDNOT, l, r) -> ir.NewBinaryExpr(xpos, ir.OANDNOT, l, r)
ir.NodAt(xpos, ir.ODIV, l, r) -> ir.NewBinaryExpr(xpos, ir.ODIV, l, r)
ir.NodAt(xpos, ir.OEQ, l, r) -> ir.NewBinaryExpr(xpos, ir.OEQ, l, r)
ir.NodAt(xpos, ir.OGE, l, r) -> ir.NewBinaryExpr(xpos, ir.OGE, l, r)
ir.NodAt(xpos, ir.OGT, l, r) -> ir.NewBinaryExpr(xpos, ir.OGT, l, r)
ir.NodAt(xpos, ir.OLE, l, r) -> ir.NewBinaryExpr(xpos, ir.OLE, l, r)
ir.NodAt(xpos, ir.OLSH, l, r) -> ir.NewBinaryExpr(xpos, ir.OLSH, l, r)
ir.NodAt(xpos, ir.OLT, l, r) -> ir.NewBinaryExpr(xpos, ir.OLT, l, r)
ir.NodAt(xpos, ir.OMOD, l, r) -> ir.NewBinaryExpr(xpos, ir.OMOD, l, r)
ir.NodAt(xpos, ir.OMUL, l, r) -> ir.NewBinaryExpr(xpos, ir.OMUL, l, r)
ir.NodAt(xpos, ir.ONE, l, r) -> ir.NewBinaryExpr(xpos, ir.ONE, l, r)
ir.NodAt(xpos, ir.OOR, l, r) -> ir.NewBinaryExpr(xpos, ir.OOR, l, r)
ir.NodAt(xpos, ir.ORSH, l, r) -> ir.NewBinaryExpr(xpos, ir.ORSH, l, r)
ir.NodAt(xpos, ir.OSUB, l, r) -> ir.NewBinaryExpr(xpos, ir.OSUB, l, r)
ir.NodAt(xpos, ir.OXOR, l, r) -> ir.NewBinaryExpr(xpos, ir.OXOR, l, r)
ir.NodAt(xpos, ir.OCOPY, l, r) -> ir.NewBinaryExpr(xpos, ir.OCOPY, l, r)
ir.NodAt(xpos, ir.OCOMPLEX, l, r) -> ir.NewBinaryExpr(xpos, ir.OCOMPLEX, l, r)
ir.NodAt(xpos, ir.OEFACE, l, r) -> ir.NewBinaryExpr(xpos, ir.OEFACE, l, r)
ir.NodAt(xpos, ir.OADDR, l, nil) -> ir.NewAddrExpr(xpos, l)
ir.NodAt(xpos, ir.OADDSTR, nil, nil) -> ir.NewAddStringExpr(xpos, nil)
ir.NodAt(xpos, ir.OANDAND, l, r) -> ir.NewLogicalExpr(xpos, ir.OANDAND, l, r)
ir.NodAt(xpos, ir.OOROR, l, r) -> ir.NewLogicalExpr(xpos, ir.OOROR, l, r)
ir.NodAt(xpos, ir.OARRAYLIT, nil, nil) -> ir.NewCompLitExpr(xpos, ir.OARRAYLIT, nil, nil)
ir.NodAt(xpos, ir.OCOMPLIT, nil, nil) -> ir.NewCompLitExpr(xpos, ir.OCOMPLIT, nil, nil)
ir.NodAt(xpos, ir.OMAPLIT, nil, nil) -> ir.NewCompLitExpr(xpos, ir.OMAPLIT, nil, nil)
ir.NodAt(xpos, ir.OSTRUCTLIT, nil, nil) -> ir.NewCompLitExpr(xpos, ir.OSTRUCTLIT, nil, nil)
ir.NodAt(xpos, ir.OSLICELIT, nil, nil) -> ir.NewCompLitExpr(xpos, ir.OSLICELIT, nil, nil)
ir.NodAt(xpos, ir.OARRAYLIT, nil, r) -> ir.NewCompLitExpr(xpos, ir.OARRAYLIT, r.(ir.Ntype), nil)
ir.NodAt(xpos, ir.OCOMPLIT, nil, r) -> ir.NewCompLitExpr(xpos, ir.OCOMPLIT, r.(ir.Ntype), nil)
ir.NodAt(xpos, ir.OMAPLIT, nil, r) -> ir.NewCompLitExpr(xpos, ir.OMAPLIT, r.(ir.Ntype), nil)
ir.NodAt(xpos, ir.OSTRUCTLIT, nil, r) -> ir.NewCompLitExpr(xpos, ir.OSTRUCTLIT, r.(ir.Ntype), nil)
ir.NodAt(xpos, ir.OSLICELIT, nil, r) -> ir.NewCompLitExpr(xpos, ir.OSLICELIT, r.(ir.Ntype), nil)
ir.NodAt(xpos, ir.OAS2, nil, nil) -> ir.NewAssignListStmt(xpos, ir.OAS2, nil, nil)
ir.NodAt(xpos, ir.OAS2DOTTYPE, nil, nil) -> ir.NewAssignListStmt(xpos, ir.OAS2DOTTYPE, nil, nil)
ir.NodAt(xpos, ir.OAS2FUNC, nil, nil) -> ir.NewAssignListStmt(xpos, ir.OAS2FUNC, nil, nil)
ir.NodAt(xpos, ir.OAS2MAPR, nil, nil) -> ir.NewAssignListStmt(xpos, ir.OAS2MAPR, nil, nil)
ir.NodAt(xpos, ir.OAS2RECV, nil, nil) -> ir.NewAssignListStmt(xpos, ir.OAS2RECV, nil, nil)
ir.NodAt(xpos, ir.OSELRECV2, nil, nil) -> ir.NewAssignListStmt(xpos, ir.OSELRECV2, nil, nil)
ir.NodAt(xpos, ir.OASOP, l, r) -> ir.NewAssignOpStmt(xpos, ir.OXXX, l, r)
ir.NodAt(xpos, ir.OBITNOT, l, nil) -> ir.NewUnaryExpr(xpos, ir.OBITNOT, l)
ir.NodAt(xpos, ir.ONEG, l, nil) -> ir.NewUnaryExpr(xpos, ir.ONEG, l)
ir.NodAt(xpos, ir.ONOT, l, nil) -> ir.NewUnaryExpr(xpos, ir.ONOT, l)
ir.NodAt(xpos, ir.OPLUS, l, nil) -> ir.NewUnaryExpr(xpos, ir.OPLUS, l)
ir.NodAt(xpos, ir.ORECV, l, nil) -> ir.NewUnaryExpr(xpos, ir.ORECV, l)
ir.NodAt(xpos, ir.OALIGNOF, l, nil) -> ir.NewUnaryExpr(xpos, ir.OALIGNOF, l)
ir.NodAt(xpos, ir.OCAP, l, nil) -> ir.NewUnaryExpr(xpos, ir.OCAP, l)
ir.NodAt(xpos, ir.OCLOSE, l, nil) -> ir.NewUnaryExpr(xpos, ir.OCLOSE, l)
ir.NodAt(xpos, ir.OIMAG, l, nil) -> ir.NewUnaryExpr(xpos, ir.OIMAG, l)
ir.NodAt(xpos, ir.OLEN, l, nil) -> ir.NewUnaryExpr(xpos, ir.OLEN, l)
ir.NodAt(xpos, ir.ONEW, l, nil) -> ir.NewUnaryExpr(xpos, ir.ONEW, l)
ir.NodAt(xpos, ir.ONEWOBJ, l, nil) -> ir.NewUnaryExpr(xpos, ir.ONEWOBJ, l)
ir.NodAt(xpos, ir.OOFFSETOF, l, nil) -> ir.NewUnaryExpr(xpos, ir.OOFFSETOF, l)
ir.NodAt(xpos, ir.OPANIC, l, nil) -> ir.NewUnaryExpr(xpos, ir.OPANIC, l)
ir.NodAt(xpos, ir.OREAL, l, nil) -> ir.NewUnaryExpr(xpos, ir.OREAL, l)
ir.NodAt(xpos, ir.OSIZEOF, l, nil) -> ir.NewUnaryExpr(xpos, ir.OSIZEOF, l)
ir.NodAt(xpos, ir.OCHECKNIL, l, nil) -> ir.NewUnaryExpr(xpos, ir.OCHECKNIL, l)
ir.NodAt(xpos, ir.OCFUNC, l, nil) -> ir.NewUnaryExpr(xpos, ir.OCFUNC, l)
ir.NodAt(xpos, ir.OIDATA, l, nil) -> ir.NewUnaryExpr(xpos, ir.OIDATA, l)
ir.NodAt(xpos, ir.OITAB, l, nil) -> ir.NewUnaryExpr(xpos, ir.OITAB, l)
ir.NodAt(xpos, ir.OSPTR, l, nil) -> ir.NewUnaryExpr(xpos, ir.OSPTR, l)
ir.NodAt(xpos, ir.OVARDEF, l, nil) -> ir.NewUnaryExpr(xpos, ir.OVARDEF, l)
ir.NodAt(xpos, ir.OVARKILL, l, nil) -> ir.NewUnaryExpr(xpos, ir.OVARKILL, l)
ir.NodAt(xpos, ir.OVARLIVE, l, nil) -> ir.NewUnaryExpr(xpos, ir.OVARLIVE, l)
ir.NodAt(xpos, ir.OBLOCK, nil, nil) -> ir.NewBlockStmt(xpos, nil)
ir.NodAt(xpos, ir.OBREAK, nil, nil) -> ir.NewBranchStmt(xpos, ir.OBREAK, nil)
ir.NodAt(xpos, ir.OCONTINUE, nil, nil) -> ir.NewBranchStmt(xpos, ir.OCONTINUE, nil)
ir.NodAt(xpos, ir.OFALL, nil, nil) -> ir.NewBranchStmt(xpos, ir.OFALL, nil)
ir.NodAt(xpos, ir.OGOTO, nil, nil) -> ir.NewBranchStmt(xpos, ir.OGOTO, nil)
ir.NodAt(xpos, ir.ORETJMP, nil, nil) -> ir.NewBranchStmt(xpos, ir.ORETJMP, nil)
ir.NodAt(xpos, ir.OCALL, l, nil) -> ir.NewCallExpr(xpos, ir.OCALL, l, nil)
ir.NodAt(xpos, ir.OCALLFUNC, l, nil) -> ir.NewCallExpr(xpos, ir.OCALLFUNC, l, nil)
ir.NodAt(xpos, ir.OCALLINTER, l, nil) -> ir.NewCallExpr(xpos, ir.OCALLINTER, l, nil)
ir.NodAt(xpos, ir.OCALLMETH, l, nil) -> ir.NewCallExpr(xpos, ir.OCALLMETH, l, nil)
ir.NodAt(xpos, ir.OAPPEND, l, nil) -> ir.NewCallExpr(xpos, ir.OAPPEND, l, nil)
ir.NodAt(xpos, ir.ODELETE, l, nil) -> ir.NewCallExpr(xpos, ir.ODELETE, l, nil)
ir.NodAt(xpos, ir.OGETG, l, nil) -> ir.NewCallExpr(xpos, ir.OGETG, l, nil)
ir.NodAt(xpos, ir.OMAKE, l, nil) -> ir.NewCallExpr(xpos, ir.OMAKE, l, nil)
ir.NodAt(xpos, ir.OPRINT, l, nil) -> ir.NewCallExpr(xpos, ir.OPRINT, l, nil)
ir.NodAt(xpos, ir.OPRINTN, l, nil) -> ir.NewCallExpr(xpos, ir.OPRINTN, l, nil)
ir.NodAt(xpos, ir.ORECOVER, l, nil) -> ir.NewCallExpr(xpos, ir.ORECOVER, l, nil)
ir.NodAt(xpos, ir.OCASE, nil, nil) -> ir.NewCaseStmt(xpos, nil, nil)
ir.NodAt(xpos, ir.OCONV, l, nil) -> ir.NewConvExpr(xpos, ir.OCONV, nil, l)
ir.NodAt(xpos, ir.OCONVIFACE, l, nil) -> ir.NewConvExpr(xpos, ir.OCONVIFACE, nil, l)
ir.NodAt(xpos, ir.OCONVNOP, l, nil) -> ir.NewConvExpr(xpos, ir.OCONVNOP, nil, l)
ir.NodAt(xpos, ir.ORUNESTR, l, nil) -> ir.NewConvExpr(xpos, ir.ORUNESTR, nil, l)
ir.NodAt(xpos, ir.ODCL, l, nil) -> ir.NewDecl(xpos, ir.ODCL, l)
ir.NodAt(xpos, ir.ODCLCONST, l, nil) -> ir.NewDecl(xpos, ir.ODCLCONST, l)
ir.NodAt(xpos, ir.ODCLTYPE, l, nil) -> ir.NewDecl(xpos, ir.ODCLTYPE, l)
ir.NodAt(xpos, ir.ODCLFUNC, nil, nil) -> ir.NewFunc(xpos)
ir.NodAt(xpos, ir.ODEFER, l, nil) -> ir.NewGoDeferStmt(xpos, ir.ODEFER, l)
ir.NodAt(xpos, ir.OGO, l, nil) -> ir.NewGoDeferStmt(xpos, ir.OGO, l)
ir.NodAt(xpos, ir.ODEREF, l, nil) -> ir.NewStarExpr(xpos, l)
ir.NodAt(xpos, ir.ODOT, l, nil) -> ir.NewSelectorExpr(xpos, ir.ODOT, l, nil)
ir.NodAt(xpos, ir.ODOTPTR, l, nil) -> ir.NewSelectorExpr(xpos, ir.ODOTPTR, l, nil)
ir.NodAt(xpos, ir.ODOTMETH, l, nil) -> ir.NewSelectorExpr(xpos, ir.ODOTMETH, l, nil)
ir.NodAt(xpos, ir.ODOTINTER, l, nil) -> ir.NewSelectorExpr(xpos, ir.ODOTINTER, l, nil)
ir.NodAt(xpos, ir.OXDOT, l, nil) -> ir.NewSelectorExpr(xpos, ir.OXDOT, l, nil)
ir.NodAt(xpos, ir.ODOTTYPE, l, nil) -> ir.NewTypeAssertExpr(xpos, l, nil)
ir.NodAt(xpos, ir.ODOTTYPE, l, r) -> ir.NewTypeAssertExpr(xpos, l, r.(ir.Ntype))
ir.NodAt(xpos, ir.OFOR, l, r) -> ir.NewForStmt(xpos, nil, l, r, nil)
ir.NodAt(xpos, ir.OINDEX, l, r) -> ir.NewIndexExpr(xpos, l, r)
ir.NodAt(xpos, ir.OINLMARK, nil, nil) -> ir.NewInlineMarkStmt(xpos, types.BADWIDTH)
ir.NodAt(xpos, ir.OKEY, l, r) -> ir.NewKeyExpr(xpos, l, r)
ir.NodAt(xpos, ir.OLABEL, nil, nil) -> ir.NewLabelStmt(xpos, nil)
ir.NodAt(xpos, ir.OMAKECHAN, l, r) -> ir.NewMakeExpr(xpos, ir.OMAKECHAN, l, r)
ir.NodAt(xpos, ir.OMAKEMAP, l, r) -> ir.NewMakeExpr(xpos, ir.OMAKEMAP, l, r)
ir.NodAt(xpos, ir.OMAKESLICE, l, r) -> ir.NewMakeExpr(xpos, ir.OMAKESLICE, l, r)
ir.NodAt(xpos, ir.OMAKESLICECOPY, l, r) -> ir.NewMakeExpr(xpos, ir.OMAKESLICECOPY, l, r)
ir.NodAt(xpos, ir.ONIL, nil, nil) -> ir.NewNilExpr(xpos)
ir.NodAt(xpos, ir.OPACK, nil, nil) -> ir.NewPkgName(xpos, nil, nil)
ir.NodAt(xpos, ir.OPAREN, l, nil) -> ir.NewParenExpr(xpos, l)
ir.NodAt(xpos, ir.ORANGE, nil, r) -> ir.NewRangeStmt(xpos, nil, r, nil)
ir.NodAt(xpos, ir.ORESULT, nil, nil) -> ir.NewResultExpr(xpos, nil, types.BADWIDTH)
ir.NodAt(xpos, ir.ORETURN, nil, nil) -> ir.NewReturnStmt(xpos, nil)
ir.NodAt(xpos, ir.OSELECT, nil, nil) -> ir.NewSelectStmt(xpos, nil)
ir.NodAt(xpos, ir.OSEND, l, r) -> ir.NewSendStmt(xpos, l, r)
ir.NodAt(xpos, ir.OSLICE, l, nil) -> ir.NewSliceExpr(xpos, ir.OSLICE, l)
ir.NodAt(xpos, ir.OSLICEARR, l, nil) -> ir.NewSliceExpr(xpos, ir.OSLICEARR, l)
ir.NodAt(xpos, ir.OSLICESTR, l, nil) -> ir.NewSliceExpr(xpos, ir.OSLICESTR, l)
ir.NodAt(xpos, ir.OSLICE3, l, nil) -> ir.NewSliceExpr(xpos, ir.OSLICE3, l)
ir.NodAt(xpos, ir.OSLICE3ARR, l, nil) -> ir.NewSliceExpr(xpos, ir.OSLICE3ARR, l)
ir.NodAt(xpos, ir.OSLICEHEADER, l, nil) -> ir.NewSliceHeaderExpr(xpos, nil, l, nil, nil)
ir.NodAt(xpos, ir.OSWITCH, l, nil) -> ir.NewSwitchStmt(xpos, l, nil)
ir.NodAt(xpos, ir.OINLCALL, nil, nil) -> ir.NewInlinedCallExpr(xpos, nil, nil)
}
rm noder.nod noder.nodSym nodSym nodlSym ir.NodAt ir.Nod
'
Change-Id: Ibf1eb708de8463ae74ccc47d7966cc263a18295e
Reviewed-on: https://go-review.googlesource.com/c/go/+/277933
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2020-12-22 23:55:29 -05:00
|
|
|
r := ir.NewAssignListStmt(base.Pos, ir.OAS2, nil, nil)
|
2020-11-22 09:59:15 -05:00
|
|
|
r.PtrList().Set2(chosen, recvOK)
|
2017-03-07 15:12:11 -08:00
|
|
|
fn := syslook("selectgo")
|
2020-11-22 09:59:15 -05:00
|
|
|
r.PtrRlist().Set1(mkcall1(fn, fn.Type().Results(), nil, bytePtrToIndex(selv, 0), bytePtrToIndex(order, 0), pc0, nodintconst(int64(nsends)), nodintconst(int64(nrecvs)), nodbool(dflt == nil)))
|
2020-12-07 14:56:49 -05:00
|
|
|
init = append(init, typecheck(r, ctxStmt))
|
2017-03-01 15:50:57 -08:00
|
|
|
|
runtime: eliminate runtime.hselect
Now the registration phase looks like:
var cases [4]runtime.scases
var order [8]uint16
selectsend(&cases[0], c1, &v1)
selectrecv(&cases[1], c2, &v2, nil)
selectrecv(&cases[2], c3, &v3, &ok)
selectdefault(&cases[3])
chosen := selectgo(&cases[0], &order[0], 4)
Primarily, this is just preparation for having the compiler open-code
selectsend, selectrecv, and selectdefault.
As a minor benefit, order can now be layed out separately on the stack
in the pointer-free segment, so it won't take up space in the
function's stack pointer maps.
Change-Id: I5552ba594201efd31fcb40084da20b42ea569a45
Reviewed-on: https://go-review.googlesource.com/37933
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
2017-03-07 13:44:53 -08:00
|
|
|
// selv and order are no longer alive after selectgo.
|
[dev.regabi] cmd/compile: remove ir.Nod [generated]
Rewrite all uses of ir.Nod and friends to call the IR constructors directly.
This gives the results a more specific type and will play nicely with
introduction of more specific types throughout the code in a followup CL.
Passes buildall w/ toolstash -cmp.
[git-generate]
cd src/cmd/compile/internal/gc
rf '
ex . ../ir {
import "cmd/compile/internal/ir"
import "cmd/compile/internal/types"
import "cmd/compile/internal/syntax"
import "cmd/internal/src"
var p *noder
var orig syntax.Node
var op ir.Op
var l, r ir.Node
var sym *types.Sym
p.nod(orig, op, l, r) -> ir.NodAt(p.pos(orig), op, l, r)
p.nodSym(orig, op, l, sym) -> nodlSym(p.pos(orig), op, l, sym)
var xpos src.XPos
var ns ir.Nodes
npos(xpos, nodSym(op, l, sym)) -> nodlSym(xpos, op, l, sym)
npos(xpos, liststmt(ns)) -> ir.NewBlockStmt(xpos, ns)
}
ex . ../ir {
import "cmd/compile/internal/base"
import "cmd/compile/internal/ir"
import "cmd/compile/internal/types"
var op ir.Op
var l, r ir.Node
ir.Nod(op, l, r) -> ir.NodAt(base.Pos, op, l, r)
var sym *types.Sym
nodSym(op, l, sym) -> nodlSym(base.Pos, op, l, sym)
}
ex . ../ir {
import "cmd/compile/internal/ir"
import "cmd/internal/src"
# rf overlapping match handling is not quite good enough
# for certain nested rewrites, so handle these two - which often contain other ir.NodAt calls - early.
var l, r ir.Node
var xpos src.XPos
ir.NodAt(xpos, ir.OAS, l, r) -> ir.NewAssignStmt(xpos, l, r)
ir.NodAt(xpos, ir.OIF, l, nil) -> ir.NewIfStmt(xpos, l, nil, nil)
}
ex . ../ir {
import "cmd/compile/internal/ir"
import "cmd/compile/internal/types"
import "cmd/internal/src"
var l, r ir.Node
var sym *types.Sym
var xpos src.XPos
nodlSym(xpos, ir.ODOT, l, sym) -> ir.NewSelectorExpr(xpos, ir.ODOT, l, sym)
nodlSym(xpos, ir.OXDOT, l, sym) -> ir.NewSelectorExpr(xpos, ir.OXDOT, l, sym)
nodlSym(xpos, ir.ODOTPTR, l, sym) -> ir.NewSelectorExpr(xpos, ir.ODOTPTR, l, sym)
nodlSym(xpos, ir.OGOTO, nil, sym) -> ir.NewBranchStmt(xpos, ir.OGOTO, sym)
nodlSym(xpos, ir.ORETJMP, nil, sym) -> ir.NewBranchStmt(xpos, ir.ORETJMP, sym)
nodlSym(xpos, ir.OLABEL, nil, sym) -> ir.NewLabelStmt(xpos, sym)
nodlSym(xpos, ir.OSTRUCTKEY, l, sym) -> ir.NewStructKeyExpr(xpos, sym, l)
ir.NodAt(xpos, ir.OADD, l, r) -> ir.NewBinaryExpr(xpos, ir.OADD, l, r)
ir.NodAt(xpos, ir.OAND, l, r) -> ir.NewBinaryExpr(xpos, ir.OAND, l, r)
ir.NodAt(xpos, ir.OANDNOT, l, r) -> ir.NewBinaryExpr(xpos, ir.OANDNOT, l, r)
ir.NodAt(xpos, ir.ODIV, l, r) -> ir.NewBinaryExpr(xpos, ir.ODIV, l, r)
ir.NodAt(xpos, ir.OEQ, l, r) -> ir.NewBinaryExpr(xpos, ir.OEQ, l, r)
ir.NodAt(xpos, ir.OGE, l, r) -> ir.NewBinaryExpr(xpos, ir.OGE, l, r)
ir.NodAt(xpos, ir.OGT, l, r) -> ir.NewBinaryExpr(xpos, ir.OGT, l, r)
ir.NodAt(xpos, ir.OLE, l, r) -> ir.NewBinaryExpr(xpos, ir.OLE, l, r)
ir.NodAt(xpos, ir.OLSH, l, r) -> ir.NewBinaryExpr(xpos, ir.OLSH, l, r)
ir.NodAt(xpos, ir.OLT, l, r) -> ir.NewBinaryExpr(xpos, ir.OLT, l, r)
ir.NodAt(xpos, ir.OMOD, l, r) -> ir.NewBinaryExpr(xpos, ir.OMOD, l, r)
ir.NodAt(xpos, ir.OMUL, l, r) -> ir.NewBinaryExpr(xpos, ir.OMUL, l, r)
ir.NodAt(xpos, ir.ONE, l, r) -> ir.NewBinaryExpr(xpos, ir.ONE, l, r)
ir.NodAt(xpos, ir.OOR, l, r) -> ir.NewBinaryExpr(xpos, ir.OOR, l, r)
ir.NodAt(xpos, ir.ORSH, l, r) -> ir.NewBinaryExpr(xpos, ir.ORSH, l, r)
ir.NodAt(xpos, ir.OSUB, l, r) -> ir.NewBinaryExpr(xpos, ir.OSUB, l, r)
ir.NodAt(xpos, ir.OXOR, l, r) -> ir.NewBinaryExpr(xpos, ir.OXOR, l, r)
ir.NodAt(xpos, ir.OCOPY, l, r) -> ir.NewBinaryExpr(xpos, ir.OCOPY, l, r)
ir.NodAt(xpos, ir.OCOMPLEX, l, r) -> ir.NewBinaryExpr(xpos, ir.OCOMPLEX, l, r)
ir.NodAt(xpos, ir.OEFACE, l, r) -> ir.NewBinaryExpr(xpos, ir.OEFACE, l, r)
ir.NodAt(xpos, ir.OADDR, l, nil) -> ir.NewAddrExpr(xpos, l)
ir.NodAt(xpos, ir.OADDSTR, nil, nil) -> ir.NewAddStringExpr(xpos, nil)
ir.NodAt(xpos, ir.OANDAND, l, r) -> ir.NewLogicalExpr(xpos, ir.OANDAND, l, r)
ir.NodAt(xpos, ir.OOROR, l, r) -> ir.NewLogicalExpr(xpos, ir.OOROR, l, r)
ir.NodAt(xpos, ir.OARRAYLIT, nil, nil) -> ir.NewCompLitExpr(xpos, ir.OARRAYLIT, nil, nil)
ir.NodAt(xpos, ir.OCOMPLIT, nil, nil) -> ir.NewCompLitExpr(xpos, ir.OCOMPLIT, nil, nil)
ir.NodAt(xpos, ir.OMAPLIT, nil, nil) -> ir.NewCompLitExpr(xpos, ir.OMAPLIT, nil, nil)
ir.NodAt(xpos, ir.OSTRUCTLIT, nil, nil) -> ir.NewCompLitExpr(xpos, ir.OSTRUCTLIT, nil, nil)
ir.NodAt(xpos, ir.OSLICELIT, nil, nil) -> ir.NewCompLitExpr(xpos, ir.OSLICELIT, nil, nil)
ir.NodAt(xpos, ir.OARRAYLIT, nil, r) -> ir.NewCompLitExpr(xpos, ir.OARRAYLIT, r.(ir.Ntype), nil)
ir.NodAt(xpos, ir.OCOMPLIT, nil, r) -> ir.NewCompLitExpr(xpos, ir.OCOMPLIT, r.(ir.Ntype), nil)
ir.NodAt(xpos, ir.OMAPLIT, nil, r) -> ir.NewCompLitExpr(xpos, ir.OMAPLIT, r.(ir.Ntype), nil)
ir.NodAt(xpos, ir.OSTRUCTLIT, nil, r) -> ir.NewCompLitExpr(xpos, ir.OSTRUCTLIT, r.(ir.Ntype), nil)
ir.NodAt(xpos, ir.OSLICELIT, nil, r) -> ir.NewCompLitExpr(xpos, ir.OSLICELIT, r.(ir.Ntype), nil)
ir.NodAt(xpos, ir.OAS2, nil, nil) -> ir.NewAssignListStmt(xpos, ir.OAS2, nil, nil)
ir.NodAt(xpos, ir.OAS2DOTTYPE, nil, nil) -> ir.NewAssignListStmt(xpos, ir.OAS2DOTTYPE, nil, nil)
ir.NodAt(xpos, ir.OAS2FUNC, nil, nil) -> ir.NewAssignListStmt(xpos, ir.OAS2FUNC, nil, nil)
ir.NodAt(xpos, ir.OAS2MAPR, nil, nil) -> ir.NewAssignListStmt(xpos, ir.OAS2MAPR, nil, nil)
ir.NodAt(xpos, ir.OAS2RECV, nil, nil) -> ir.NewAssignListStmt(xpos, ir.OAS2RECV, nil, nil)
ir.NodAt(xpos, ir.OSELRECV2, nil, nil) -> ir.NewAssignListStmt(xpos, ir.OSELRECV2, nil, nil)
ir.NodAt(xpos, ir.OASOP, l, r) -> ir.NewAssignOpStmt(xpos, ir.OXXX, l, r)
ir.NodAt(xpos, ir.OBITNOT, l, nil) -> ir.NewUnaryExpr(xpos, ir.OBITNOT, l)
ir.NodAt(xpos, ir.ONEG, l, nil) -> ir.NewUnaryExpr(xpos, ir.ONEG, l)
ir.NodAt(xpos, ir.ONOT, l, nil) -> ir.NewUnaryExpr(xpos, ir.ONOT, l)
ir.NodAt(xpos, ir.OPLUS, l, nil) -> ir.NewUnaryExpr(xpos, ir.OPLUS, l)
ir.NodAt(xpos, ir.ORECV, l, nil) -> ir.NewUnaryExpr(xpos, ir.ORECV, l)
ir.NodAt(xpos, ir.OALIGNOF, l, nil) -> ir.NewUnaryExpr(xpos, ir.OALIGNOF, l)
ir.NodAt(xpos, ir.OCAP, l, nil) -> ir.NewUnaryExpr(xpos, ir.OCAP, l)
ir.NodAt(xpos, ir.OCLOSE, l, nil) -> ir.NewUnaryExpr(xpos, ir.OCLOSE, l)
ir.NodAt(xpos, ir.OIMAG, l, nil) -> ir.NewUnaryExpr(xpos, ir.OIMAG, l)
ir.NodAt(xpos, ir.OLEN, l, nil) -> ir.NewUnaryExpr(xpos, ir.OLEN, l)
ir.NodAt(xpos, ir.ONEW, l, nil) -> ir.NewUnaryExpr(xpos, ir.ONEW, l)
ir.NodAt(xpos, ir.ONEWOBJ, l, nil) -> ir.NewUnaryExpr(xpos, ir.ONEWOBJ, l)
ir.NodAt(xpos, ir.OOFFSETOF, l, nil) -> ir.NewUnaryExpr(xpos, ir.OOFFSETOF, l)
ir.NodAt(xpos, ir.OPANIC, l, nil) -> ir.NewUnaryExpr(xpos, ir.OPANIC, l)
ir.NodAt(xpos, ir.OREAL, l, nil) -> ir.NewUnaryExpr(xpos, ir.OREAL, l)
ir.NodAt(xpos, ir.OSIZEOF, l, nil) -> ir.NewUnaryExpr(xpos, ir.OSIZEOF, l)
ir.NodAt(xpos, ir.OCHECKNIL, l, nil) -> ir.NewUnaryExpr(xpos, ir.OCHECKNIL, l)
ir.NodAt(xpos, ir.OCFUNC, l, nil) -> ir.NewUnaryExpr(xpos, ir.OCFUNC, l)
ir.NodAt(xpos, ir.OIDATA, l, nil) -> ir.NewUnaryExpr(xpos, ir.OIDATA, l)
ir.NodAt(xpos, ir.OITAB, l, nil) -> ir.NewUnaryExpr(xpos, ir.OITAB, l)
ir.NodAt(xpos, ir.OSPTR, l, nil) -> ir.NewUnaryExpr(xpos, ir.OSPTR, l)
ir.NodAt(xpos, ir.OVARDEF, l, nil) -> ir.NewUnaryExpr(xpos, ir.OVARDEF, l)
ir.NodAt(xpos, ir.OVARKILL, l, nil) -> ir.NewUnaryExpr(xpos, ir.OVARKILL, l)
ir.NodAt(xpos, ir.OVARLIVE, l, nil) -> ir.NewUnaryExpr(xpos, ir.OVARLIVE, l)
ir.NodAt(xpos, ir.OBLOCK, nil, nil) -> ir.NewBlockStmt(xpos, nil)
ir.NodAt(xpos, ir.OBREAK, nil, nil) -> ir.NewBranchStmt(xpos, ir.OBREAK, nil)
ir.NodAt(xpos, ir.OCONTINUE, nil, nil) -> ir.NewBranchStmt(xpos, ir.OCONTINUE, nil)
ir.NodAt(xpos, ir.OFALL, nil, nil) -> ir.NewBranchStmt(xpos, ir.OFALL, nil)
ir.NodAt(xpos, ir.OGOTO, nil, nil) -> ir.NewBranchStmt(xpos, ir.OGOTO, nil)
ir.NodAt(xpos, ir.ORETJMP, nil, nil) -> ir.NewBranchStmt(xpos, ir.ORETJMP, nil)
ir.NodAt(xpos, ir.OCALL, l, nil) -> ir.NewCallExpr(xpos, ir.OCALL, l, nil)
ir.NodAt(xpos, ir.OCALLFUNC, l, nil) -> ir.NewCallExpr(xpos, ir.OCALLFUNC, l, nil)
ir.NodAt(xpos, ir.OCALLINTER, l, nil) -> ir.NewCallExpr(xpos, ir.OCALLINTER, l, nil)
ir.NodAt(xpos, ir.OCALLMETH, l, nil) -> ir.NewCallExpr(xpos, ir.OCALLMETH, l, nil)
ir.NodAt(xpos, ir.OAPPEND, l, nil) -> ir.NewCallExpr(xpos, ir.OAPPEND, l, nil)
ir.NodAt(xpos, ir.ODELETE, l, nil) -> ir.NewCallExpr(xpos, ir.ODELETE, l, nil)
ir.NodAt(xpos, ir.OGETG, l, nil) -> ir.NewCallExpr(xpos, ir.OGETG, l, nil)
ir.NodAt(xpos, ir.OMAKE, l, nil) -> ir.NewCallExpr(xpos, ir.OMAKE, l, nil)
ir.NodAt(xpos, ir.OPRINT, l, nil) -> ir.NewCallExpr(xpos, ir.OPRINT, l, nil)
ir.NodAt(xpos, ir.OPRINTN, l, nil) -> ir.NewCallExpr(xpos, ir.OPRINTN, l, nil)
ir.NodAt(xpos, ir.ORECOVER, l, nil) -> ir.NewCallExpr(xpos, ir.ORECOVER, l, nil)
ir.NodAt(xpos, ir.OCASE, nil, nil) -> ir.NewCaseStmt(xpos, nil, nil)
ir.NodAt(xpos, ir.OCONV, l, nil) -> ir.NewConvExpr(xpos, ir.OCONV, nil, l)
ir.NodAt(xpos, ir.OCONVIFACE, l, nil) -> ir.NewConvExpr(xpos, ir.OCONVIFACE, nil, l)
ir.NodAt(xpos, ir.OCONVNOP, l, nil) -> ir.NewConvExpr(xpos, ir.OCONVNOP, nil, l)
ir.NodAt(xpos, ir.ORUNESTR, l, nil) -> ir.NewConvExpr(xpos, ir.ORUNESTR, nil, l)
ir.NodAt(xpos, ir.ODCL, l, nil) -> ir.NewDecl(xpos, ir.ODCL, l)
ir.NodAt(xpos, ir.ODCLCONST, l, nil) -> ir.NewDecl(xpos, ir.ODCLCONST, l)
ir.NodAt(xpos, ir.ODCLTYPE, l, nil) -> ir.NewDecl(xpos, ir.ODCLTYPE, l)
ir.NodAt(xpos, ir.ODCLFUNC, nil, nil) -> ir.NewFunc(xpos)
ir.NodAt(xpos, ir.ODEFER, l, nil) -> ir.NewGoDeferStmt(xpos, ir.ODEFER, l)
ir.NodAt(xpos, ir.OGO, l, nil) -> ir.NewGoDeferStmt(xpos, ir.OGO, l)
ir.NodAt(xpos, ir.ODEREF, l, nil) -> ir.NewStarExpr(xpos, l)
ir.NodAt(xpos, ir.ODOT, l, nil) -> ir.NewSelectorExpr(xpos, ir.ODOT, l, nil)
ir.NodAt(xpos, ir.ODOTPTR, l, nil) -> ir.NewSelectorExpr(xpos, ir.ODOTPTR, l, nil)
ir.NodAt(xpos, ir.ODOTMETH, l, nil) -> ir.NewSelectorExpr(xpos, ir.ODOTMETH, l, nil)
ir.NodAt(xpos, ir.ODOTINTER, l, nil) -> ir.NewSelectorExpr(xpos, ir.ODOTINTER, l, nil)
ir.NodAt(xpos, ir.OXDOT, l, nil) -> ir.NewSelectorExpr(xpos, ir.OXDOT, l, nil)
ir.NodAt(xpos, ir.ODOTTYPE, l, nil) -> ir.NewTypeAssertExpr(xpos, l, nil)
ir.NodAt(xpos, ir.ODOTTYPE, l, r) -> ir.NewTypeAssertExpr(xpos, l, r.(ir.Ntype))
ir.NodAt(xpos, ir.OFOR, l, r) -> ir.NewForStmt(xpos, nil, l, r, nil)
ir.NodAt(xpos, ir.OINDEX, l, r) -> ir.NewIndexExpr(xpos, l, r)
ir.NodAt(xpos, ir.OINLMARK, nil, nil) -> ir.NewInlineMarkStmt(xpos, types.BADWIDTH)
ir.NodAt(xpos, ir.OKEY, l, r) -> ir.NewKeyExpr(xpos, l, r)
ir.NodAt(xpos, ir.OLABEL, nil, nil) -> ir.NewLabelStmt(xpos, nil)
ir.NodAt(xpos, ir.OMAKECHAN, l, r) -> ir.NewMakeExpr(xpos, ir.OMAKECHAN, l, r)
ir.NodAt(xpos, ir.OMAKEMAP, l, r) -> ir.NewMakeExpr(xpos, ir.OMAKEMAP, l, r)
ir.NodAt(xpos, ir.OMAKESLICE, l, r) -> ir.NewMakeExpr(xpos, ir.OMAKESLICE, l, r)
ir.NodAt(xpos, ir.OMAKESLICECOPY, l, r) -> ir.NewMakeExpr(xpos, ir.OMAKESLICECOPY, l, r)
ir.NodAt(xpos, ir.ONIL, nil, nil) -> ir.NewNilExpr(xpos)
ir.NodAt(xpos, ir.OPACK, nil, nil) -> ir.NewPkgName(xpos, nil, nil)
ir.NodAt(xpos, ir.OPAREN, l, nil) -> ir.NewParenExpr(xpos, l)
ir.NodAt(xpos, ir.ORANGE, nil, r) -> ir.NewRangeStmt(xpos, nil, r, nil)
ir.NodAt(xpos, ir.ORESULT, nil, nil) -> ir.NewResultExpr(xpos, nil, types.BADWIDTH)
ir.NodAt(xpos, ir.ORETURN, nil, nil) -> ir.NewReturnStmt(xpos, nil)
ir.NodAt(xpos, ir.OSELECT, nil, nil) -> ir.NewSelectStmt(xpos, nil)
ir.NodAt(xpos, ir.OSEND, l, r) -> ir.NewSendStmt(xpos, l, r)
ir.NodAt(xpos, ir.OSLICE, l, nil) -> ir.NewSliceExpr(xpos, ir.OSLICE, l)
ir.NodAt(xpos, ir.OSLICEARR, l, nil) -> ir.NewSliceExpr(xpos, ir.OSLICEARR, l)
ir.NodAt(xpos, ir.OSLICESTR, l, nil) -> ir.NewSliceExpr(xpos, ir.OSLICESTR, l)
ir.NodAt(xpos, ir.OSLICE3, l, nil) -> ir.NewSliceExpr(xpos, ir.OSLICE3, l)
ir.NodAt(xpos, ir.OSLICE3ARR, l, nil) -> ir.NewSliceExpr(xpos, ir.OSLICE3ARR, l)
ir.NodAt(xpos, ir.OSLICEHEADER, l, nil) -> ir.NewSliceHeaderExpr(xpos, nil, l, nil, nil)
ir.NodAt(xpos, ir.OSWITCH, l, nil) -> ir.NewSwitchStmt(xpos, l, nil)
ir.NodAt(xpos, ir.OINLCALL, nil, nil) -> ir.NewInlinedCallExpr(xpos, nil, nil)
}
rm noder.nod noder.nodSym nodSym nodlSym ir.NodAt ir.Nod
'
Change-Id: Ibf1eb708de8463ae74ccc47d7966cc263a18295e
Reviewed-on: https://go-review.googlesource.com/c/go/+/277933
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2020-12-22 23:55:29 -05:00
|
|
|
init = append(init, ir.NewUnaryExpr(base.Pos, ir.OVARKILL, selv))
|
|
|
|
init = append(init, ir.NewUnaryExpr(base.Pos, ir.OVARKILL, order))
|
2020-11-19 20:49:23 -05:00
|
|
|
if base.Flag.Race {
|
[dev.regabi] cmd/compile: remove ir.Nod [generated]
Rewrite all uses of ir.Nod and friends to call the IR constructors directly.
This gives the results a more specific type and will play nicely with
introduction of more specific types throughout the code in a followup CL.
Passes buildall w/ toolstash -cmp.
[git-generate]
cd src/cmd/compile/internal/gc
rf '
ex . ../ir {
import "cmd/compile/internal/ir"
import "cmd/compile/internal/types"
import "cmd/compile/internal/syntax"
import "cmd/internal/src"
var p *noder
var orig syntax.Node
var op ir.Op
var l, r ir.Node
var sym *types.Sym
p.nod(orig, op, l, r) -> ir.NodAt(p.pos(orig), op, l, r)
p.nodSym(orig, op, l, sym) -> nodlSym(p.pos(orig), op, l, sym)
var xpos src.XPos
var ns ir.Nodes
npos(xpos, nodSym(op, l, sym)) -> nodlSym(xpos, op, l, sym)
npos(xpos, liststmt(ns)) -> ir.NewBlockStmt(xpos, ns)
}
ex . ../ir {
import "cmd/compile/internal/base"
import "cmd/compile/internal/ir"
import "cmd/compile/internal/types"
var op ir.Op
var l, r ir.Node
ir.Nod(op, l, r) -> ir.NodAt(base.Pos, op, l, r)
var sym *types.Sym
nodSym(op, l, sym) -> nodlSym(base.Pos, op, l, sym)
}
ex . ../ir {
import "cmd/compile/internal/ir"
import "cmd/internal/src"
# rf overlapping match handling is not quite good enough
# for certain nested rewrites, so handle these two - which often contain other ir.NodAt calls - early.
var l, r ir.Node
var xpos src.XPos
ir.NodAt(xpos, ir.OAS, l, r) -> ir.NewAssignStmt(xpos, l, r)
ir.NodAt(xpos, ir.OIF, l, nil) -> ir.NewIfStmt(xpos, l, nil, nil)
}
ex . ../ir {
import "cmd/compile/internal/ir"
import "cmd/compile/internal/types"
import "cmd/internal/src"
var l, r ir.Node
var sym *types.Sym
var xpos src.XPos
nodlSym(xpos, ir.ODOT, l, sym) -> ir.NewSelectorExpr(xpos, ir.ODOT, l, sym)
nodlSym(xpos, ir.OXDOT, l, sym) -> ir.NewSelectorExpr(xpos, ir.OXDOT, l, sym)
nodlSym(xpos, ir.ODOTPTR, l, sym) -> ir.NewSelectorExpr(xpos, ir.ODOTPTR, l, sym)
nodlSym(xpos, ir.OGOTO, nil, sym) -> ir.NewBranchStmt(xpos, ir.OGOTO, sym)
nodlSym(xpos, ir.ORETJMP, nil, sym) -> ir.NewBranchStmt(xpos, ir.ORETJMP, sym)
nodlSym(xpos, ir.OLABEL, nil, sym) -> ir.NewLabelStmt(xpos, sym)
nodlSym(xpos, ir.OSTRUCTKEY, l, sym) -> ir.NewStructKeyExpr(xpos, sym, l)
ir.NodAt(xpos, ir.OADD, l, r) -> ir.NewBinaryExpr(xpos, ir.OADD, l, r)
ir.NodAt(xpos, ir.OAND, l, r) -> ir.NewBinaryExpr(xpos, ir.OAND, l, r)
ir.NodAt(xpos, ir.OANDNOT, l, r) -> ir.NewBinaryExpr(xpos, ir.OANDNOT, l, r)
ir.NodAt(xpos, ir.ODIV, l, r) -> ir.NewBinaryExpr(xpos, ir.ODIV, l, r)
ir.NodAt(xpos, ir.OEQ, l, r) -> ir.NewBinaryExpr(xpos, ir.OEQ, l, r)
ir.NodAt(xpos, ir.OGE, l, r) -> ir.NewBinaryExpr(xpos, ir.OGE, l, r)
ir.NodAt(xpos, ir.OGT, l, r) -> ir.NewBinaryExpr(xpos, ir.OGT, l, r)
ir.NodAt(xpos, ir.OLE, l, r) -> ir.NewBinaryExpr(xpos, ir.OLE, l, r)
ir.NodAt(xpos, ir.OLSH, l, r) -> ir.NewBinaryExpr(xpos, ir.OLSH, l, r)
ir.NodAt(xpos, ir.OLT, l, r) -> ir.NewBinaryExpr(xpos, ir.OLT, l, r)
ir.NodAt(xpos, ir.OMOD, l, r) -> ir.NewBinaryExpr(xpos, ir.OMOD, l, r)
ir.NodAt(xpos, ir.OMUL, l, r) -> ir.NewBinaryExpr(xpos, ir.OMUL, l, r)
ir.NodAt(xpos, ir.ONE, l, r) -> ir.NewBinaryExpr(xpos, ir.ONE, l, r)
ir.NodAt(xpos, ir.OOR, l, r) -> ir.NewBinaryExpr(xpos, ir.OOR, l, r)
ir.NodAt(xpos, ir.ORSH, l, r) -> ir.NewBinaryExpr(xpos, ir.ORSH, l, r)
ir.NodAt(xpos, ir.OSUB, l, r) -> ir.NewBinaryExpr(xpos, ir.OSUB, l, r)
ir.NodAt(xpos, ir.OXOR, l, r) -> ir.NewBinaryExpr(xpos, ir.OXOR, l, r)
ir.NodAt(xpos, ir.OCOPY, l, r) -> ir.NewBinaryExpr(xpos, ir.OCOPY, l, r)
ir.NodAt(xpos, ir.OCOMPLEX, l, r) -> ir.NewBinaryExpr(xpos, ir.OCOMPLEX, l, r)
ir.NodAt(xpos, ir.OEFACE, l, r) -> ir.NewBinaryExpr(xpos, ir.OEFACE, l, r)
ir.NodAt(xpos, ir.OADDR, l, nil) -> ir.NewAddrExpr(xpos, l)
ir.NodAt(xpos, ir.OADDSTR, nil, nil) -> ir.NewAddStringExpr(xpos, nil)
ir.NodAt(xpos, ir.OANDAND, l, r) -> ir.NewLogicalExpr(xpos, ir.OANDAND, l, r)
ir.NodAt(xpos, ir.OOROR, l, r) -> ir.NewLogicalExpr(xpos, ir.OOROR, l, r)
ir.NodAt(xpos, ir.OARRAYLIT, nil, nil) -> ir.NewCompLitExpr(xpos, ir.OARRAYLIT, nil, nil)
ir.NodAt(xpos, ir.OCOMPLIT, nil, nil) -> ir.NewCompLitExpr(xpos, ir.OCOMPLIT, nil, nil)
ir.NodAt(xpos, ir.OMAPLIT, nil, nil) -> ir.NewCompLitExpr(xpos, ir.OMAPLIT, nil, nil)
ir.NodAt(xpos, ir.OSTRUCTLIT, nil, nil) -> ir.NewCompLitExpr(xpos, ir.OSTRUCTLIT, nil, nil)
ir.NodAt(xpos, ir.OSLICELIT, nil, nil) -> ir.NewCompLitExpr(xpos, ir.OSLICELIT, nil, nil)
ir.NodAt(xpos, ir.OARRAYLIT, nil, r) -> ir.NewCompLitExpr(xpos, ir.OARRAYLIT, r.(ir.Ntype), nil)
ir.NodAt(xpos, ir.OCOMPLIT, nil, r) -> ir.NewCompLitExpr(xpos, ir.OCOMPLIT, r.(ir.Ntype), nil)
ir.NodAt(xpos, ir.OMAPLIT, nil, r) -> ir.NewCompLitExpr(xpos, ir.OMAPLIT, r.(ir.Ntype), nil)
ir.NodAt(xpos, ir.OSTRUCTLIT, nil, r) -> ir.NewCompLitExpr(xpos, ir.OSTRUCTLIT, r.(ir.Ntype), nil)
ir.NodAt(xpos, ir.OSLICELIT, nil, r) -> ir.NewCompLitExpr(xpos, ir.OSLICELIT, r.(ir.Ntype), nil)
ir.NodAt(xpos, ir.OAS2, nil, nil) -> ir.NewAssignListStmt(xpos, ir.OAS2, nil, nil)
ir.NodAt(xpos, ir.OAS2DOTTYPE, nil, nil) -> ir.NewAssignListStmt(xpos, ir.OAS2DOTTYPE, nil, nil)
ir.NodAt(xpos, ir.OAS2FUNC, nil, nil) -> ir.NewAssignListStmt(xpos, ir.OAS2FUNC, nil, nil)
ir.NodAt(xpos, ir.OAS2MAPR, nil, nil) -> ir.NewAssignListStmt(xpos, ir.OAS2MAPR, nil, nil)
ir.NodAt(xpos, ir.OAS2RECV, nil, nil) -> ir.NewAssignListStmt(xpos, ir.OAS2RECV, nil, nil)
ir.NodAt(xpos, ir.OSELRECV2, nil, nil) -> ir.NewAssignListStmt(xpos, ir.OSELRECV2, nil, nil)
ir.NodAt(xpos, ir.OASOP, l, r) -> ir.NewAssignOpStmt(xpos, ir.OXXX, l, r)
ir.NodAt(xpos, ir.OBITNOT, l, nil) -> ir.NewUnaryExpr(xpos, ir.OBITNOT, l)
ir.NodAt(xpos, ir.ONEG, l, nil) -> ir.NewUnaryExpr(xpos, ir.ONEG, l)
ir.NodAt(xpos, ir.ONOT, l, nil) -> ir.NewUnaryExpr(xpos, ir.ONOT, l)
ir.NodAt(xpos, ir.OPLUS, l, nil) -> ir.NewUnaryExpr(xpos, ir.OPLUS, l)
ir.NodAt(xpos, ir.ORECV, l, nil) -> ir.NewUnaryExpr(xpos, ir.ORECV, l)
ir.NodAt(xpos, ir.OALIGNOF, l, nil) -> ir.NewUnaryExpr(xpos, ir.OALIGNOF, l)
ir.NodAt(xpos, ir.OCAP, l, nil) -> ir.NewUnaryExpr(xpos, ir.OCAP, l)
ir.NodAt(xpos, ir.OCLOSE, l, nil) -> ir.NewUnaryExpr(xpos, ir.OCLOSE, l)
ir.NodAt(xpos, ir.OIMAG, l, nil) -> ir.NewUnaryExpr(xpos, ir.OIMAG, l)
ir.NodAt(xpos, ir.OLEN, l, nil) -> ir.NewUnaryExpr(xpos, ir.OLEN, l)
ir.NodAt(xpos, ir.ONEW, l, nil) -> ir.NewUnaryExpr(xpos, ir.ONEW, l)
ir.NodAt(xpos, ir.ONEWOBJ, l, nil) -> ir.NewUnaryExpr(xpos, ir.ONEWOBJ, l)
ir.NodAt(xpos, ir.OOFFSETOF, l, nil) -> ir.NewUnaryExpr(xpos, ir.OOFFSETOF, l)
ir.NodAt(xpos, ir.OPANIC, l, nil) -> ir.NewUnaryExpr(xpos, ir.OPANIC, l)
ir.NodAt(xpos, ir.OREAL, l, nil) -> ir.NewUnaryExpr(xpos, ir.OREAL, l)
ir.NodAt(xpos, ir.OSIZEOF, l, nil) -> ir.NewUnaryExpr(xpos, ir.OSIZEOF, l)
ir.NodAt(xpos, ir.OCHECKNIL, l, nil) -> ir.NewUnaryExpr(xpos, ir.OCHECKNIL, l)
ir.NodAt(xpos, ir.OCFUNC, l, nil) -> ir.NewUnaryExpr(xpos, ir.OCFUNC, l)
ir.NodAt(xpos, ir.OIDATA, l, nil) -> ir.NewUnaryExpr(xpos, ir.OIDATA, l)
ir.NodAt(xpos, ir.OITAB, l, nil) -> ir.NewUnaryExpr(xpos, ir.OITAB, l)
ir.NodAt(xpos, ir.OSPTR, l, nil) -> ir.NewUnaryExpr(xpos, ir.OSPTR, l)
ir.NodAt(xpos, ir.OVARDEF, l, nil) -> ir.NewUnaryExpr(xpos, ir.OVARDEF, l)
ir.NodAt(xpos, ir.OVARKILL, l, nil) -> ir.NewUnaryExpr(xpos, ir.OVARKILL, l)
ir.NodAt(xpos, ir.OVARLIVE, l, nil) -> ir.NewUnaryExpr(xpos, ir.OVARLIVE, l)
ir.NodAt(xpos, ir.OBLOCK, nil, nil) -> ir.NewBlockStmt(xpos, nil)
ir.NodAt(xpos, ir.OBREAK, nil, nil) -> ir.NewBranchStmt(xpos, ir.OBREAK, nil)
ir.NodAt(xpos, ir.OCONTINUE, nil, nil) -> ir.NewBranchStmt(xpos, ir.OCONTINUE, nil)
ir.NodAt(xpos, ir.OFALL, nil, nil) -> ir.NewBranchStmt(xpos, ir.OFALL, nil)
ir.NodAt(xpos, ir.OGOTO, nil, nil) -> ir.NewBranchStmt(xpos, ir.OGOTO, nil)
ir.NodAt(xpos, ir.ORETJMP, nil, nil) -> ir.NewBranchStmt(xpos, ir.ORETJMP, nil)
ir.NodAt(xpos, ir.OCALL, l, nil) -> ir.NewCallExpr(xpos, ir.OCALL, l, nil)
ir.NodAt(xpos, ir.OCALLFUNC, l, nil) -> ir.NewCallExpr(xpos, ir.OCALLFUNC, l, nil)
ir.NodAt(xpos, ir.OCALLINTER, l, nil) -> ir.NewCallExpr(xpos, ir.OCALLINTER, l, nil)
ir.NodAt(xpos, ir.OCALLMETH, l, nil) -> ir.NewCallExpr(xpos, ir.OCALLMETH, l, nil)
ir.NodAt(xpos, ir.OAPPEND, l, nil) -> ir.NewCallExpr(xpos, ir.OAPPEND, l, nil)
ir.NodAt(xpos, ir.ODELETE, l, nil) -> ir.NewCallExpr(xpos, ir.ODELETE, l, nil)
ir.NodAt(xpos, ir.OGETG, l, nil) -> ir.NewCallExpr(xpos, ir.OGETG, l, nil)
ir.NodAt(xpos, ir.OMAKE, l, nil) -> ir.NewCallExpr(xpos, ir.OMAKE, l, nil)
ir.NodAt(xpos, ir.OPRINT, l, nil) -> ir.NewCallExpr(xpos, ir.OPRINT, l, nil)
ir.NodAt(xpos, ir.OPRINTN, l, nil) -> ir.NewCallExpr(xpos, ir.OPRINTN, l, nil)
ir.NodAt(xpos, ir.ORECOVER, l, nil) -> ir.NewCallExpr(xpos, ir.ORECOVER, l, nil)
ir.NodAt(xpos, ir.OCASE, nil, nil) -> ir.NewCaseStmt(xpos, nil, nil)
ir.NodAt(xpos, ir.OCONV, l, nil) -> ir.NewConvExpr(xpos, ir.OCONV, nil, l)
ir.NodAt(xpos, ir.OCONVIFACE, l, nil) -> ir.NewConvExpr(xpos, ir.OCONVIFACE, nil, l)
ir.NodAt(xpos, ir.OCONVNOP, l, nil) -> ir.NewConvExpr(xpos, ir.OCONVNOP, nil, l)
ir.NodAt(xpos, ir.ORUNESTR, l, nil) -> ir.NewConvExpr(xpos, ir.ORUNESTR, nil, l)
ir.NodAt(xpos, ir.ODCL, l, nil) -> ir.NewDecl(xpos, ir.ODCL, l)
ir.NodAt(xpos, ir.ODCLCONST, l, nil) -> ir.NewDecl(xpos, ir.ODCLCONST, l)
ir.NodAt(xpos, ir.ODCLTYPE, l, nil) -> ir.NewDecl(xpos, ir.ODCLTYPE, l)
ir.NodAt(xpos, ir.ODCLFUNC, nil, nil) -> ir.NewFunc(xpos)
ir.NodAt(xpos, ir.ODEFER, l, nil) -> ir.NewGoDeferStmt(xpos, ir.ODEFER, l)
ir.NodAt(xpos, ir.OGO, l, nil) -> ir.NewGoDeferStmt(xpos, ir.OGO, l)
ir.NodAt(xpos, ir.ODEREF, l, nil) -> ir.NewStarExpr(xpos, l)
ir.NodAt(xpos, ir.ODOT, l, nil) -> ir.NewSelectorExpr(xpos, ir.ODOT, l, nil)
ir.NodAt(xpos, ir.ODOTPTR, l, nil) -> ir.NewSelectorExpr(xpos, ir.ODOTPTR, l, nil)
ir.NodAt(xpos, ir.ODOTMETH, l, nil) -> ir.NewSelectorExpr(xpos, ir.ODOTMETH, l, nil)
ir.NodAt(xpos, ir.ODOTINTER, l, nil) -> ir.NewSelectorExpr(xpos, ir.ODOTINTER, l, nil)
ir.NodAt(xpos, ir.OXDOT, l, nil) -> ir.NewSelectorExpr(xpos, ir.OXDOT, l, nil)
ir.NodAt(xpos, ir.ODOTTYPE, l, nil) -> ir.NewTypeAssertExpr(xpos, l, nil)
ir.NodAt(xpos, ir.ODOTTYPE, l, r) -> ir.NewTypeAssertExpr(xpos, l, r.(ir.Ntype))
ir.NodAt(xpos, ir.OFOR, l, r) -> ir.NewForStmt(xpos, nil, l, r, nil)
ir.NodAt(xpos, ir.OINDEX, l, r) -> ir.NewIndexExpr(xpos, l, r)
ir.NodAt(xpos, ir.OINLMARK, nil, nil) -> ir.NewInlineMarkStmt(xpos, types.BADWIDTH)
ir.NodAt(xpos, ir.OKEY, l, r) -> ir.NewKeyExpr(xpos, l, r)
ir.NodAt(xpos, ir.OLABEL, nil, nil) -> ir.NewLabelStmt(xpos, nil)
ir.NodAt(xpos, ir.OMAKECHAN, l, r) -> ir.NewMakeExpr(xpos, ir.OMAKECHAN, l, r)
ir.NodAt(xpos, ir.OMAKEMAP, l, r) -> ir.NewMakeExpr(xpos, ir.OMAKEMAP, l, r)
ir.NodAt(xpos, ir.OMAKESLICE, l, r) -> ir.NewMakeExpr(xpos, ir.OMAKESLICE, l, r)
ir.NodAt(xpos, ir.OMAKESLICECOPY, l, r) -> ir.NewMakeExpr(xpos, ir.OMAKESLICECOPY, l, r)
ir.NodAt(xpos, ir.ONIL, nil, nil) -> ir.NewNilExpr(xpos)
ir.NodAt(xpos, ir.OPACK, nil, nil) -> ir.NewPkgName(xpos, nil, nil)
ir.NodAt(xpos, ir.OPAREN, l, nil) -> ir.NewParenExpr(xpos, l)
ir.NodAt(xpos, ir.ORANGE, nil, r) -> ir.NewRangeStmt(xpos, nil, r, nil)
ir.NodAt(xpos, ir.ORESULT, nil, nil) -> ir.NewResultExpr(xpos, nil, types.BADWIDTH)
ir.NodAt(xpos, ir.ORETURN, nil, nil) -> ir.NewReturnStmt(xpos, nil)
ir.NodAt(xpos, ir.OSELECT, nil, nil) -> ir.NewSelectStmt(xpos, nil)
ir.NodAt(xpos, ir.OSEND, l, r) -> ir.NewSendStmt(xpos, l, r)
ir.NodAt(xpos, ir.OSLICE, l, nil) -> ir.NewSliceExpr(xpos, ir.OSLICE, l)
ir.NodAt(xpos, ir.OSLICEARR, l, nil) -> ir.NewSliceExpr(xpos, ir.OSLICEARR, l)
ir.NodAt(xpos, ir.OSLICESTR, l, nil) -> ir.NewSliceExpr(xpos, ir.OSLICESTR, l)
ir.NodAt(xpos, ir.OSLICE3, l, nil) -> ir.NewSliceExpr(xpos, ir.OSLICE3, l)
ir.NodAt(xpos, ir.OSLICE3ARR, l, nil) -> ir.NewSliceExpr(xpos, ir.OSLICE3ARR, l)
ir.NodAt(xpos, ir.OSLICEHEADER, l, nil) -> ir.NewSliceHeaderExpr(xpos, nil, l, nil, nil)
ir.NodAt(xpos, ir.OSWITCH, l, nil) -> ir.NewSwitchStmt(xpos, l, nil)
ir.NodAt(xpos, ir.OINLCALL, nil, nil) -> ir.NewInlinedCallExpr(xpos, nil, nil)
}
rm noder.nod noder.nodSym nodSym nodlSym ir.NodAt ir.Nod
'
Change-Id: Ibf1eb708de8463ae74ccc47d7966cc263a18295e
Reviewed-on: https://go-review.googlesource.com/c/go/+/277933
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2020-12-22 23:55:29 -05:00
|
|
|
init = append(init, ir.NewUnaryExpr(base.Pos, ir.OVARKILL, pcs))
|
2020-07-27 15:20:18 -07:00
|
|
|
}
|
2017-03-01 15:50:57 -08:00
|
|
|
|
|
|
|
// dispatch cases
|
[dev.regabi] cmd/compile: cleanup for concrete types - range, select, swt
An automated rewrite will add concrete type assertions after
a test of n.Op(), when n can be safely type-asserted
(meaning, n is not reassigned a different type, n is not reassigned
and then used outside the scope of the type assertion,
and so on).
This sequence of CLs handles the code that the automated
rewrite does not: adding specific types to function arguments,
adjusting code not to call n.Left() etc when n may have multiple
representations, and so on.
This CL focuses on range.go, select.go, and swt.go: the big
control structures.
Passes buildall w/ toolstash -cmp.
Change-Id: I033fe056a7b815edb6e8a06f45c12ffd990f4d45
Reviewed-on: https://go-review.googlesource.com/c/go/+/277929
Trust: Russ Cox <rsc@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2020-12-10 18:47:32 -05:00
|
|
|
dispatch := func(cond ir.Node, cas *ir.CaseStmt) {
|
2018-11-18 08:34:38 -08:00
|
|
|
cond = typecheck(cond, ctxExpr)
|
cmd/compile: prevent untyped types from reaching walk
We already require expressions to have already been typechecked before
reaching walk. Moreover, all untyped expressions should have been
converted to their default type by walk.
However, in practice, we've been somewhat sloppy and inconsistent
about ensuring this. In particular, a lot of AST rewrites ended up
leaving untyped bool expressions scattered around. These likely aren't
harmful in practice, but it seems worth cleaning up.
The two most common cases addressed by this CL are:
1) When generating OIF and OFOR nodes, we would often typecheck the
conditional expression, but not apply defaultlit to force it to the
expression's default type.
2) When rewriting string comparisons into more fundamental primitives,
we were simply overwriting r.Type with the desired type, which didn't
propagate the type to nested subexpressions. These are fixed by
utilizing finishcompare, which correctly handles this (and is already
used by other comparison lowering rewrites).
Lastly, walkexpr is extended to assert that it's not called on untyped
expressions.
Fixes #23834.
Change-Id: Icbd29648a293555e4015d3b06a95a24ccbd3f790
Reviewed-on: https://go-review.googlesource.com/98337
Reviewed-by: Robert Griesemer <gri@golang.org>
2018-03-02 15:20:49 -08:00
|
|
|
cond = defaultlit(cond, nil)
|
2017-03-01 15:50:57 -08:00
|
|
|
|
[dev.regabi] cmd/compile: remove ir.Nod [generated]
Rewrite all uses of ir.Nod and friends to call the IR constructors directly.
This gives the results a more specific type and will play nicely with
introduction of more specific types throughout the code in a followup CL.
Passes buildall w/ toolstash -cmp.
[git-generate]
cd src/cmd/compile/internal/gc
rf '
ex . ../ir {
import "cmd/compile/internal/ir"
import "cmd/compile/internal/types"
import "cmd/compile/internal/syntax"
import "cmd/internal/src"
var p *noder
var orig syntax.Node
var op ir.Op
var l, r ir.Node
var sym *types.Sym
p.nod(orig, op, l, r) -> ir.NodAt(p.pos(orig), op, l, r)
p.nodSym(orig, op, l, sym) -> nodlSym(p.pos(orig), op, l, sym)
var xpos src.XPos
var ns ir.Nodes
npos(xpos, nodSym(op, l, sym)) -> nodlSym(xpos, op, l, sym)
npos(xpos, liststmt(ns)) -> ir.NewBlockStmt(xpos, ns)
}
ex . ../ir {
import "cmd/compile/internal/base"
import "cmd/compile/internal/ir"
import "cmd/compile/internal/types"
var op ir.Op
var l, r ir.Node
ir.Nod(op, l, r) -> ir.NodAt(base.Pos, op, l, r)
var sym *types.Sym
nodSym(op, l, sym) -> nodlSym(base.Pos, op, l, sym)
}
ex . ../ir {
import "cmd/compile/internal/ir"
import "cmd/internal/src"
# rf overlapping match handling is not quite good enough
# for certain nested rewrites, so handle these two - which often contain other ir.NodAt calls - early.
var l, r ir.Node
var xpos src.XPos
ir.NodAt(xpos, ir.OAS, l, r) -> ir.NewAssignStmt(xpos, l, r)
ir.NodAt(xpos, ir.OIF, l, nil) -> ir.NewIfStmt(xpos, l, nil, nil)
}
ex . ../ir {
import "cmd/compile/internal/ir"
import "cmd/compile/internal/types"
import "cmd/internal/src"
var l, r ir.Node
var sym *types.Sym
var xpos src.XPos
nodlSym(xpos, ir.ODOT, l, sym) -> ir.NewSelectorExpr(xpos, ir.ODOT, l, sym)
nodlSym(xpos, ir.OXDOT, l, sym) -> ir.NewSelectorExpr(xpos, ir.OXDOT, l, sym)
nodlSym(xpos, ir.ODOTPTR, l, sym) -> ir.NewSelectorExpr(xpos, ir.ODOTPTR, l, sym)
nodlSym(xpos, ir.OGOTO, nil, sym) -> ir.NewBranchStmt(xpos, ir.OGOTO, sym)
nodlSym(xpos, ir.ORETJMP, nil, sym) -> ir.NewBranchStmt(xpos, ir.ORETJMP, sym)
nodlSym(xpos, ir.OLABEL, nil, sym) -> ir.NewLabelStmt(xpos, sym)
nodlSym(xpos, ir.OSTRUCTKEY, l, sym) -> ir.NewStructKeyExpr(xpos, sym, l)
ir.NodAt(xpos, ir.OADD, l, r) -> ir.NewBinaryExpr(xpos, ir.OADD, l, r)
ir.NodAt(xpos, ir.OAND, l, r) -> ir.NewBinaryExpr(xpos, ir.OAND, l, r)
ir.NodAt(xpos, ir.OANDNOT, l, r) -> ir.NewBinaryExpr(xpos, ir.OANDNOT, l, r)
ir.NodAt(xpos, ir.ODIV, l, r) -> ir.NewBinaryExpr(xpos, ir.ODIV, l, r)
ir.NodAt(xpos, ir.OEQ, l, r) -> ir.NewBinaryExpr(xpos, ir.OEQ, l, r)
ir.NodAt(xpos, ir.OGE, l, r) -> ir.NewBinaryExpr(xpos, ir.OGE, l, r)
ir.NodAt(xpos, ir.OGT, l, r) -> ir.NewBinaryExpr(xpos, ir.OGT, l, r)
ir.NodAt(xpos, ir.OLE, l, r) -> ir.NewBinaryExpr(xpos, ir.OLE, l, r)
ir.NodAt(xpos, ir.OLSH, l, r) -> ir.NewBinaryExpr(xpos, ir.OLSH, l, r)
ir.NodAt(xpos, ir.OLT, l, r) -> ir.NewBinaryExpr(xpos, ir.OLT, l, r)
ir.NodAt(xpos, ir.OMOD, l, r) -> ir.NewBinaryExpr(xpos, ir.OMOD, l, r)
ir.NodAt(xpos, ir.OMUL, l, r) -> ir.NewBinaryExpr(xpos, ir.OMUL, l, r)
ir.NodAt(xpos, ir.ONE, l, r) -> ir.NewBinaryExpr(xpos, ir.ONE, l, r)
ir.NodAt(xpos, ir.OOR, l, r) -> ir.NewBinaryExpr(xpos, ir.OOR, l, r)
ir.NodAt(xpos, ir.ORSH, l, r) -> ir.NewBinaryExpr(xpos, ir.ORSH, l, r)
ir.NodAt(xpos, ir.OSUB, l, r) -> ir.NewBinaryExpr(xpos, ir.OSUB, l, r)
ir.NodAt(xpos, ir.OXOR, l, r) -> ir.NewBinaryExpr(xpos, ir.OXOR, l, r)
ir.NodAt(xpos, ir.OCOPY, l, r) -> ir.NewBinaryExpr(xpos, ir.OCOPY, l, r)
ir.NodAt(xpos, ir.OCOMPLEX, l, r) -> ir.NewBinaryExpr(xpos, ir.OCOMPLEX, l, r)
ir.NodAt(xpos, ir.OEFACE, l, r) -> ir.NewBinaryExpr(xpos, ir.OEFACE, l, r)
ir.NodAt(xpos, ir.OADDR, l, nil) -> ir.NewAddrExpr(xpos, l)
ir.NodAt(xpos, ir.OADDSTR, nil, nil) -> ir.NewAddStringExpr(xpos, nil)
ir.NodAt(xpos, ir.OANDAND, l, r) -> ir.NewLogicalExpr(xpos, ir.OANDAND, l, r)
ir.NodAt(xpos, ir.OOROR, l, r) -> ir.NewLogicalExpr(xpos, ir.OOROR, l, r)
ir.NodAt(xpos, ir.OARRAYLIT, nil, nil) -> ir.NewCompLitExpr(xpos, ir.OARRAYLIT, nil, nil)
ir.NodAt(xpos, ir.OCOMPLIT, nil, nil) -> ir.NewCompLitExpr(xpos, ir.OCOMPLIT, nil, nil)
ir.NodAt(xpos, ir.OMAPLIT, nil, nil) -> ir.NewCompLitExpr(xpos, ir.OMAPLIT, nil, nil)
ir.NodAt(xpos, ir.OSTRUCTLIT, nil, nil) -> ir.NewCompLitExpr(xpos, ir.OSTRUCTLIT, nil, nil)
ir.NodAt(xpos, ir.OSLICELIT, nil, nil) -> ir.NewCompLitExpr(xpos, ir.OSLICELIT, nil, nil)
ir.NodAt(xpos, ir.OARRAYLIT, nil, r) -> ir.NewCompLitExpr(xpos, ir.OARRAYLIT, r.(ir.Ntype), nil)
ir.NodAt(xpos, ir.OCOMPLIT, nil, r) -> ir.NewCompLitExpr(xpos, ir.OCOMPLIT, r.(ir.Ntype), nil)
ir.NodAt(xpos, ir.OMAPLIT, nil, r) -> ir.NewCompLitExpr(xpos, ir.OMAPLIT, r.(ir.Ntype), nil)
ir.NodAt(xpos, ir.OSTRUCTLIT, nil, r) -> ir.NewCompLitExpr(xpos, ir.OSTRUCTLIT, r.(ir.Ntype), nil)
ir.NodAt(xpos, ir.OSLICELIT, nil, r) -> ir.NewCompLitExpr(xpos, ir.OSLICELIT, r.(ir.Ntype), nil)
ir.NodAt(xpos, ir.OAS2, nil, nil) -> ir.NewAssignListStmt(xpos, ir.OAS2, nil, nil)
ir.NodAt(xpos, ir.OAS2DOTTYPE, nil, nil) -> ir.NewAssignListStmt(xpos, ir.OAS2DOTTYPE, nil, nil)
ir.NodAt(xpos, ir.OAS2FUNC, nil, nil) -> ir.NewAssignListStmt(xpos, ir.OAS2FUNC, nil, nil)
ir.NodAt(xpos, ir.OAS2MAPR, nil, nil) -> ir.NewAssignListStmt(xpos, ir.OAS2MAPR, nil, nil)
ir.NodAt(xpos, ir.OAS2RECV, nil, nil) -> ir.NewAssignListStmt(xpos, ir.OAS2RECV, nil, nil)
ir.NodAt(xpos, ir.OSELRECV2, nil, nil) -> ir.NewAssignListStmt(xpos, ir.OSELRECV2, nil, nil)
ir.NodAt(xpos, ir.OASOP, l, r) -> ir.NewAssignOpStmt(xpos, ir.OXXX, l, r)
ir.NodAt(xpos, ir.OBITNOT, l, nil) -> ir.NewUnaryExpr(xpos, ir.OBITNOT, l)
ir.NodAt(xpos, ir.ONEG, l, nil) -> ir.NewUnaryExpr(xpos, ir.ONEG, l)
ir.NodAt(xpos, ir.ONOT, l, nil) -> ir.NewUnaryExpr(xpos, ir.ONOT, l)
ir.NodAt(xpos, ir.OPLUS, l, nil) -> ir.NewUnaryExpr(xpos, ir.OPLUS, l)
ir.NodAt(xpos, ir.ORECV, l, nil) -> ir.NewUnaryExpr(xpos, ir.ORECV, l)
ir.NodAt(xpos, ir.OALIGNOF, l, nil) -> ir.NewUnaryExpr(xpos, ir.OALIGNOF, l)
ir.NodAt(xpos, ir.OCAP, l, nil) -> ir.NewUnaryExpr(xpos, ir.OCAP, l)
ir.NodAt(xpos, ir.OCLOSE, l, nil) -> ir.NewUnaryExpr(xpos, ir.OCLOSE, l)
ir.NodAt(xpos, ir.OIMAG, l, nil) -> ir.NewUnaryExpr(xpos, ir.OIMAG, l)
ir.NodAt(xpos, ir.OLEN, l, nil) -> ir.NewUnaryExpr(xpos, ir.OLEN, l)
ir.NodAt(xpos, ir.ONEW, l, nil) -> ir.NewUnaryExpr(xpos, ir.ONEW, l)
ir.NodAt(xpos, ir.ONEWOBJ, l, nil) -> ir.NewUnaryExpr(xpos, ir.ONEWOBJ, l)
ir.NodAt(xpos, ir.OOFFSETOF, l, nil) -> ir.NewUnaryExpr(xpos, ir.OOFFSETOF, l)
ir.NodAt(xpos, ir.OPANIC, l, nil) -> ir.NewUnaryExpr(xpos, ir.OPANIC, l)
ir.NodAt(xpos, ir.OREAL, l, nil) -> ir.NewUnaryExpr(xpos, ir.OREAL, l)
ir.NodAt(xpos, ir.OSIZEOF, l, nil) -> ir.NewUnaryExpr(xpos, ir.OSIZEOF, l)
ir.NodAt(xpos, ir.OCHECKNIL, l, nil) -> ir.NewUnaryExpr(xpos, ir.OCHECKNIL, l)
ir.NodAt(xpos, ir.OCFUNC, l, nil) -> ir.NewUnaryExpr(xpos, ir.OCFUNC, l)
ir.NodAt(xpos, ir.OIDATA, l, nil) -> ir.NewUnaryExpr(xpos, ir.OIDATA, l)
ir.NodAt(xpos, ir.OITAB, l, nil) -> ir.NewUnaryExpr(xpos, ir.OITAB, l)
ir.NodAt(xpos, ir.OSPTR, l, nil) -> ir.NewUnaryExpr(xpos, ir.OSPTR, l)
ir.NodAt(xpos, ir.OVARDEF, l, nil) -> ir.NewUnaryExpr(xpos, ir.OVARDEF, l)
ir.NodAt(xpos, ir.OVARKILL, l, nil) -> ir.NewUnaryExpr(xpos, ir.OVARKILL, l)
ir.NodAt(xpos, ir.OVARLIVE, l, nil) -> ir.NewUnaryExpr(xpos, ir.OVARLIVE, l)
ir.NodAt(xpos, ir.OBLOCK, nil, nil) -> ir.NewBlockStmt(xpos, nil)
ir.NodAt(xpos, ir.OBREAK, nil, nil) -> ir.NewBranchStmt(xpos, ir.OBREAK, nil)
ir.NodAt(xpos, ir.OCONTINUE, nil, nil) -> ir.NewBranchStmt(xpos, ir.OCONTINUE, nil)
ir.NodAt(xpos, ir.OFALL, nil, nil) -> ir.NewBranchStmt(xpos, ir.OFALL, nil)
ir.NodAt(xpos, ir.OGOTO, nil, nil) -> ir.NewBranchStmt(xpos, ir.OGOTO, nil)
ir.NodAt(xpos, ir.ORETJMP, nil, nil) -> ir.NewBranchStmt(xpos, ir.ORETJMP, nil)
ir.NodAt(xpos, ir.OCALL, l, nil) -> ir.NewCallExpr(xpos, ir.OCALL, l, nil)
ir.NodAt(xpos, ir.OCALLFUNC, l, nil) -> ir.NewCallExpr(xpos, ir.OCALLFUNC, l, nil)
ir.NodAt(xpos, ir.OCALLINTER, l, nil) -> ir.NewCallExpr(xpos, ir.OCALLINTER, l, nil)
ir.NodAt(xpos, ir.OCALLMETH, l, nil) -> ir.NewCallExpr(xpos, ir.OCALLMETH, l, nil)
ir.NodAt(xpos, ir.OAPPEND, l, nil) -> ir.NewCallExpr(xpos, ir.OAPPEND, l, nil)
ir.NodAt(xpos, ir.ODELETE, l, nil) -> ir.NewCallExpr(xpos, ir.ODELETE, l, nil)
ir.NodAt(xpos, ir.OGETG, l, nil) -> ir.NewCallExpr(xpos, ir.OGETG, l, nil)
ir.NodAt(xpos, ir.OMAKE, l, nil) -> ir.NewCallExpr(xpos, ir.OMAKE, l, nil)
ir.NodAt(xpos, ir.OPRINT, l, nil) -> ir.NewCallExpr(xpos, ir.OPRINT, l, nil)
ir.NodAt(xpos, ir.OPRINTN, l, nil) -> ir.NewCallExpr(xpos, ir.OPRINTN, l, nil)
ir.NodAt(xpos, ir.ORECOVER, l, nil) -> ir.NewCallExpr(xpos, ir.ORECOVER, l, nil)
ir.NodAt(xpos, ir.OCASE, nil, nil) -> ir.NewCaseStmt(xpos, nil, nil)
ir.NodAt(xpos, ir.OCONV, l, nil) -> ir.NewConvExpr(xpos, ir.OCONV, nil, l)
ir.NodAt(xpos, ir.OCONVIFACE, l, nil) -> ir.NewConvExpr(xpos, ir.OCONVIFACE, nil, l)
ir.NodAt(xpos, ir.OCONVNOP, l, nil) -> ir.NewConvExpr(xpos, ir.OCONVNOP, nil, l)
ir.NodAt(xpos, ir.ORUNESTR, l, nil) -> ir.NewConvExpr(xpos, ir.ORUNESTR, nil, l)
ir.NodAt(xpos, ir.ODCL, l, nil) -> ir.NewDecl(xpos, ir.ODCL, l)
ir.NodAt(xpos, ir.ODCLCONST, l, nil) -> ir.NewDecl(xpos, ir.ODCLCONST, l)
ir.NodAt(xpos, ir.ODCLTYPE, l, nil) -> ir.NewDecl(xpos, ir.ODCLTYPE, l)
ir.NodAt(xpos, ir.ODCLFUNC, nil, nil) -> ir.NewFunc(xpos)
ir.NodAt(xpos, ir.ODEFER, l, nil) -> ir.NewGoDeferStmt(xpos, ir.ODEFER, l)
ir.NodAt(xpos, ir.OGO, l, nil) -> ir.NewGoDeferStmt(xpos, ir.OGO, l)
ir.NodAt(xpos, ir.ODEREF, l, nil) -> ir.NewStarExpr(xpos, l)
ir.NodAt(xpos, ir.ODOT, l, nil) -> ir.NewSelectorExpr(xpos, ir.ODOT, l, nil)
ir.NodAt(xpos, ir.ODOTPTR, l, nil) -> ir.NewSelectorExpr(xpos, ir.ODOTPTR, l, nil)
ir.NodAt(xpos, ir.ODOTMETH, l, nil) -> ir.NewSelectorExpr(xpos, ir.ODOTMETH, l, nil)
ir.NodAt(xpos, ir.ODOTINTER, l, nil) -> ir.NewSelectorExpr(xpos, ir.ODOTINTER, l, nil)
ir.NodAt(xpos, ir.OXDOT, l, nil) -> ir.NewSelectorExpr(xpos, ir.OXDOT, l, nil)
ir.NodAt(xpos, ir.ODOTTYPE, l, nil) -> ir.NewTypeAssertExpr(xpos, l, nil)
ir.NodAt(xpos, ir.ODOTTYPE, l, r) -> ir.NewTypeAssertExpr(xpos, l, r.(ir.Ntype))
ir.NodAt(xpos, ir.OFOR, l, r) -> ir.NewForStmt(xpos, nil, l, r, nil)
ir.NodAt(xpos, ir.OINDEX, l, r) -> ir.NewIndexExpr(xpos, l, r)
ir.NodAt(xpos, ir.OINLMARK, nil, nil) -> ir.NewInlineMarkStmt(xpos, types.BADWIDTH)
ir.NodAt(xpos, ir.OKEY, l, r) -> ir.NewKeyExpr(xpos, l, r)
ir.NodAt(xpos, ir.OLABEL, nil, nil) -> ir.NewLabelStmt(xpos, nil)
ir.NodAt(xpos, ir.OMAKECHAN, l, r) -> ir.NewMakeExpr(xpos, ir.OMAKECHAN, l, r)
ir.NodAt(xpos, ir.OMAKEMAP, l, r) -> ir.NewMakeExpr(xpos, ir.OMAKEMAP, l, r)
ir.NodAt(xpos, ir.OMAKESLICE, l, r) -> ir.NewMakeExpr(xpos, ir.OMAKESLICE, l, r)
ir.NodAt(xpos, ir.OMAKESLICECOPY, l, r) -> ir.NewMakeExpr(xpos, ir.OMAKESLICECOPY, l, r)
ir.NodAt(xpos, ir.ONIL, nil, nil) -> ir.NewNilExpr(xpos)
ir.NodAt(xpos, ir.OPACK, nil, nil) -> ir.NewPkgName(xpos, nil, nil)
ir.NodAt(xpos, ir.OPAREN, l, nil) -> ir.NewParenExpr(xpos, l)
ir.NodAt(xpos, ir.ORANGE, nil, r) -> ir.NewRangeStmt(xpos, nil, r, nil)
ir.NodAt(xpos, ir.ORESULT, nil, nil) -> ir.NewResultExpr(xpos, nil, types.BADWIDTH)
ir.NodAt(xpos, ir.ORETURN, nil, nil) -> ir.NewReturnStmt(xpos, nil)
ir.NodAt(xpos, ir.OSELECT, nil, nil) -> ir.NewSelectStmt(xpos, nil)
ir.NodAt(xpos, ir.OSEND, l, r) -> ir.NewSendStmt(xpos, l, r)
ir.NodAt(xpos, ir.OSLICE, l, nil) -> ir.NewSliceExpr(xpos, ir.OSLICE, l)
ir.NodAt(xpos, ir.OSLICEARR, l, nil) -> ir.NewSliceExpr(xpos, ir.OSLICEARR, l)
ir.NodAt(xpos, ir.OSLICESTR, l, nil) -> ir.NewSliceExpr(xpos, ir.OSLICESTR, l)
ir.NodAt(xpos, ir.OSLICE3, l, nil) -> ir.NewSliceExpr(xpos, ir.OSLICE3, l)
ir.NodAt(xpos, ir.OSLICE3ARR, l, nil) -> ir.NewSliceExpr(xpos, ir.OSLICE3ARR, l)
ir.NodAt(xpos, ir.OSLICEHEADER, l, nil) -> ir.NewSliceHeaderExpr(xpos, nil, l, nil, nil)
ir.NodAt(xpos, ir.OSWITCH, l, nil) -> ir.NewSwitchStmt(xpos, l, nil)
ir.NodAt(xpos, ir.OINLCALL, nil, nil) -> ir.NewInlinedCallExpr(xpos, nil, nil)
}
rm noder.nod noder.nodSym nodSym nodlSym ir.NodAt ir.Nod
'
Change-Id: Ibf1eb708de8463ae74ccc47d7966cc263a18295e
Reviewed-on: https://go-review.googlesource.com/c/go/+/277933
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2020-12-22 23:55:29 -05:00
|
|
|
r := ir.NewIfStmt(base.Pos, cond, nil, nil)
|
2017-03-07 15:12:11 -08:00
|
|
|
|
2020-12-18 11:29:49 -05:00
|
|
|
if n := cas.Left(); n != nil && n.Op() == ir.OSELRECV2 {
|
|
|
|
if !ir.IsBlank(n.List().Second()) {
|
[dev.regabi] cmd/compile: remove ir.Nod [generated]
Rewrite all uses of ir.Nod and friends to call the IR constructors directly.
This gives the results a more specific type and will play nicely with
introduction of more specific types throughout the code in a followup CL.
Passes buildall w/ toolstash -cmp.
[git-generate]
cd src/cmd/compile/internal/gc
rf '
ex . ../ir {
import "cmd/compile/internal/ir"
import "cmd/compile/internal/types"
import "cmd/compile/internal/syntax"
import "cmd/internal/src"
var p *noder
var orig syntax.Node
var op ir.Op
var l, r ir.Node
var sym *types.Sym
p.nod(orig, op, l, r) -> ir.NodAt(p.pos(orig), op, l, r)
p.nodSym(orig, op, l, sym) -> nodlSym(p.pos(orig), op, l, sym)
var xpos src.XPos
var ns ir.Nodes
npos(xpos, nodSym(op, l, sym)) -> nodlSym(xpos, op, l, sym)
npos(xpos, liststmt(ns)) -> ir.NewBlockStmt(xpos, ns)
}
ex . ../ir {
import "cmd/compile/internal/base"
import "cmd/compile/internal/ir"
import "cmd/compile/internal/types"
var op ir.Op
var l, r ir.Node
ir.Nod(op, l, r) -> ir.NodAt(base.Pos, op, l, r)
var sym *types.Sym
nodSym(op, l, sym) -> nodlSym(base.Pos, op, l, sym)
}
ex . ../ir {
import "cmd/compile/internal/ir"
import "cmd/internal/src"
# rf overlapping match handling is not quite good enough
# for certain nested rewrites, so handle these two - which often contain other ir.NodAt calls - early.
var l, r ir.Node
var xpos src.XPos
ir.NodAt(xpos, ir.OAS, l, r) -> ir.NewAssignStmt(xpos, l, r)
ir.NodAt(xpos, ir.OIF, l, nil) -> ir.NewIfStmt(xpos, l, nil, nil)
}
ex . ../ir {
import "cmd/compile/internal/ir"
import "cmd/compile/internal/types"
import "cmd/internal/src"
var l, r ir.Node
var sym *types.Sym
var xpos src.XPos
nodlSym(xpos, ir.ODOT, l, sym) -> ir.NewSelectorExpr(xpos, ir.ODOT, l, sym)
nodlSym(xpos, ir.OXDOT, l, sym) -> ir.NewSelectorExpr(xpos, ir.OXDOT, l, sym)
nodlSym(xpos, ir.ODOTPTR, l, sym) -> ir.NewSelectorExpr(xpos, ir.ODOTPTR, l, sym)
nodlSym(xpos, ir.OGOTO, nil, sym) -> ir.NewBranchStmt(xpos, ir.OGOTO, sym)
nodlSym(xpos, ir.ORETJMP, nil, sym) -> ir.NewBranchStmt(xpos, ir.ORETJMP, sym)
nodlSym(xpos, ir.OLABEL, nil, sym) -> ir.NewLabelStmt(xpos, sym)
nodlSym(xpos, ir.OSTRUCTKEY, l, sym) -> ir.NewStructKeyExpr(xpos, sym, l)
ir.NodAt(xpos, ir.OADD, l, r) -> ir.NewBinaryExpr(xpos, ir.OADD, l, r)
ir.NodAt(xpos, ir.OAND, l, r) -> ir.NewBinaryExpr(xpos, ir.OAND, l, r)
ir.NodAt(xpos, ir.OANDNOT, l, r) -> ir.NewBinaryExpr(xpos, ir.OANDNOT, l, r)
ir.NodAt(xpos, ir.ODIV, l, r) -> ir.NewBinaryExpr(xpos, ir.ODIV, l, r)
ir.NodAt(xpos, ir.OEQ, l, r) -> ir.NewBinaryExpr(xpos, ir.OEQ, l, r)
ir.NodAt(xpos, ir.OGE, l, r) -> ir.NewBinaryExpr(xpos, ir.OGE, l, r)
ir.NodAt(xpos, ir.OGT, l, r) -> ir.NewBinaryExpr(xpos, ir.OGT, l, r)
ir.NodAt(xpos, ir.OLE, l, r) -> ir.NewBinaryExpr(xpos, ir.OLE, l, r)
ir.NodAt(xpos, ir.OLSH, l, r) -> ir.NewBinaryExpr(xpos, ir.OLSH, l, r)
ir.NodAt(xpos, ir.OLT, l, r) -> ir.NewBinaryExpr(xpos, ir.OLT, l, r)
ir.NodAt(xpos, ir.OMOD, l, r) -> ir.NewBinaryExpr(xpos, ir.OMOD, l, r)
ir.NodAt(xpos, ir.OMUL, l, r) -> ir.NewBinaryExpr(xpos, ir.OMUL, l, r)
ir.NodAt(xpos, ir.ONE, l, r) -> ir.NewBinaryExpr(xpos, ir.ONE, l, r)
ir.NodAt(xpos, ir.OOR, l, r) -> ir.NewBinaryExpr(xpos, ir.OOR, l, r)
ir.NodAt(xpos, ir.ORSH, l, r) -> ir.NewBinaryExpr(xpos, ir.ORSH, l, r)
ir.NodAt(xpos, ir.OSUB, l, r) -> ir.NewBinaryExpr(xpos, ir.OSUB, l, r)
ir.NodAt(xpos, ir.OXOR, l, r) -> ir.NewBinaryExpr(xpos, ir.OXOR, l, r)
ir.NodAt(xpos, ir.OCOPY, l, r) -> ir.NewBinaryExpr(xpos, ir.OCOPY, l, r)
ir.NodAt(xpos, ir.OCOMPLEX, l, r) -> ir.NewBinaryExpr(xpos, ir.OCOMPLEX, l, r)
ir.NodAt(xpos, ir.OEFACE, l, r) -> ir.NewBinaryExpr(xpos, ir.OEFACE, l, r)
ir.NodAt(xpos, ir.OADDR, l, nil) -> ir.NewAddrExpr(xpos, l)
ir.NodAt(xpos, ir.OADDSTR, nil, nil) -> ir.NewAddStringExpr(xpos, nil)
ir.NodAt(xpos, ir.OANDAND, l, r) -> ir.NewLogicalExpr(xpos, ir.OANDAND, l, r)
ir.NodAt(xpos, ir.OOROR, l, r) -> ir.NewLogicalExpr(xpos, ir.OOROR, l, r)
ir.NodAt(xpos, ir.OARRAYLIT, nil, nil) -> ir.NewCompLitExpr(xpos, ir.OARRAYLIT, nil, nil)
ir.NodAt(xpos, ir.OCOMPLIT, nil, nil) -> ir.NewCompLitExpr(xpos, ir.OCOMPLIT, nil, nil)
ir.NodAt(xpos, ir.OMAPLIT, nil, nil) -> ir.NewCompLitExpr(xpos, ir.OMAPLIT, nil, nil)
ir.NodAt(xpos, ir.OSTRUCTLIT, nil, nil) -> ir.NewCompLitExpr(xpos, ir.OSTRUCTLIT, nil, nil)
ir.NodAt(xpos, ir.OSLICELIT, nil, nil) -> ir.NewCompLitExpr(xpos, ir.OSLICELIT, nil, nil)
ir.NodAt(xpos, ir.OARRAYLIT, nil, r) -> ir.NewCompLitExpr(xpos, ir.OARRAYLIT, r.(ir.Ntype), nil)
ir.NodAt(xpos, ir.OCOMPLIT, nil, r) -> ir.NewCompLitExpr(xpos, ir.OCOMPLIT, r.(ir.Ntype), nil)
ir.NodAt(xpos, ir.OMAPLIT, nil, r) -> ir.NewCompLitExpr(xpos, ir.OMAPLIT, r.(ir.Ntype), nil)
ir.NodAt(xpos, ir.OSTRUCTLIT, nil, r) -> ir.NewCompLitExpr(xpos, ir.OSTRUCTLIT, r.(ir.Ntype), nil)
ir.NodAt(xpos, ir.OSLICELIT, nil, r) -> ir.NewCompLitExpr(xpos, ir.OSLICELIT, r.(ir.Ntype), nil)
ir.NodAt(xpos, ir.OAS2, nil, nil) -> ir.NewAssignListStmt(xpos, ir.OAS2, nil, nil)
ir.NodAt(xpos, ir.OAS2DOTTYPE, nil, nil) -> ir.NewAssignListStmt(xpos, ir.OAS2DOTTYPE, nil, nil)
ir.NodAt(xpos, ir.OAS2FUNC, nil, nil) -> ir.NewAssignListStmt(xpos, ir.OAS2FUNC, nil, nil)
ir.NodAt(xpos, ir.OAS2MAPR, nil, nil) -> ir.NewAssignListStmt(xpos, ir.OAS2MAPR, nil, nil)
ir.NodAt(xpos, ir.OAS2RECV, nil, nil) -> ir.NewAssignListStmt(xpos, ir.OAS2RECV, nil, nil)
ir.NodAt(xpos, ir.OSELRECV2, nil, nil) -> ir.NewAssignListStmt(xpos, ir.OSELRECV2, nil, nil)
ir.NodAt(xpos, ir.OASOP, l, r) -> ir.NewAssignOpStmt(xpos, ir.OXXX, l, r)
ir.NodAt(xpos, ir.OBITNOT, l, nil) -> ir.NewUnaryExpr(xpos, ir.OBITNOT, l)
ir.NodAt(xpos, ir.ONEG, l, nil) -> ir.NewUnaryExpr(xpos, ir.ONEG, l)
ir.NodAt(xpos, ir.ONOT, l, nil) -> ir.NewUnaryExpr(xpos, ir.ONOT, l)
ir.NodAt(xpos, ir.OPLUS, l, nil) -> ir.NewUnaryExpr(xpos, ir.OPLUS, l)
ir.NodAt(xpos, ir.ORECV, l, nil) -> ir.NewUnaryExpr(xpos, ir.ORECV, l)
ir.NodAt(xpos, ir.OALIGNOF, l, nil) -> ir.NewUnaryExpr(xpos, ir.OALIGNOF, l)
ir.NodAt(xpos, ir.OCAP, l, nil) -> ir.NewUnaryExpr(xpos, ir.OCAP, l)
ir.NodAt(xpos, ir.OCLOSE, l, nil) -> ir.NewUnaryExpr(xpos, ir.OCLOSE, l)
ir.NodAt(xpos, ir.OIMAG, l, nil) -> ir.NewUnaryExpr(xpos, ir.OIMAG, l)
ir.NodAt(xpos, ir.OLEN, l, nil) -> ir.NewUnaryExpr(xpos, ir.OLEN, l)
ir.NodAt(xpos, ir.ONEW, l, nil) -> ir.NewUnaryExpr(xpos, ir.ONEW, l)
ir.NodAt(xpos, ir.ONEWOBJ, l, nil) -> ir.NewUnaryExpr(xpos, ir.ONEWOBJ, l)
ir.NodAt(xpos, ir.OOFFSETOF, l, nil) -> ir.NewUnaryExpr(xpos, ir.OOFFSETOF, l)
ir.NodAt(xpos, ir.OPANIC, l, nil) -> ir.NewUnaryExpr(xpos, ir.OPANIC, l)
ir.NodAt(xpos, ir.OREAL, l, nil) -> ir.NewUnaryExpr(xpos, ir.OREAL, l)
ir.NodAt(xpos, ir.OSIZEOF, l, nil) -> ir.NewUnaryExpr(xpos, ir.OSIZEOF, l)
ir.NodAt(xpos, ir.OCHECKNIL, l, nil) -> ir.NewUnaryExpr(xpos, ir.OCHECKNIL, l)
ir.NodAt(xpos, ir.OCFUNC, l, nil) -> ir.NewUnaryExpr(xpos, ir.OCFUNC, l)
ir.NodAt(xpos, ir.OIDATA, l, nil) -> ir.NewUnaryExpr(xpos, ir.OIDATA, l)
ir.NodAt(xpos, ir.OITAB, l, nil) -> ir.NewUnaryExpr(xpos, ir.OITAB, l)
ir.NodAt(xpos, ir.OSPTR, l, nil) -> ir.NewUnaryExpr(xpos, ir.OSPTR, l)
ir.NodAt(xpos, ir.OVARDEF, l, nil) -> ir.NewUnaryExpr(xpos, ir.OVARDEF, l)
ir.NodAt(xpos, ir.OVARKILL, l, nil) -> ir.NewUnaryExpr(xpos, ir.OVARKILL, l)
ir.NodAt(xpos, ir.OVARLIVE, l, nil) -> ir.NewUnaryExpr(xpos, ir.OVARLIVE, l)
ir.NodAt(xpos, ir.OBLOCK, nil, nil) -> ir.NewBlockStmt(xpos, nil)
ir.NodAt(xpos, ir.OBREAK, nil, nil) -> ir.NewBranchStmt(xpos, ir.OBREAK, nil)
ir.NodAt(xpos, ir.OCONTINUE, nil, nil) -> ir.NewBranchStmt(xpos, ir.OCONTINUE, nil)
ir.NodAt(xpos, ir.OFALL, nil, nil) -> ir.NewBranchStmt(xpos, ir.OFALL, nil)
ir.NodAt(xpos, ir.OGOTO, nil, nil) -> ir.NewBranchStmt(xpos, ir.OGOTO, nil)
ir.NodAt(xpos, ir.ORETJMP, nil, nil) -> ir.NewBranchStmt(xpos, ir.ORETJMP, nil)
ir.NodAt(xpos, ir.OCALL, l, nil) -> ir.NewCallExpr(xpos, ir.OCALL, l, nil)
ir.NodAt(xpos, ir.OCALLFUNC, l, nil) -> ir.NewCallExpr(xpos, ir.OCALLFUNC, l, nil)
ir.NodAt(xpos, ir.OCALLINTER, l, nil) -> ir.NewCallExpr(xpos, ir.OCALLINTER, l, nil)
ir.NodAt(xpos, ir.OCALLMETH, l, nil) -> ir.NewCallExpr(xpos, ir.OCALLMETH, l, nil)
ir.NodAt(xpos, ir.OAPPEND, l, nil) -> ir.NewCallExpr(xpos, ir.OAPPEND, l, nil)
ir.NodAt(xpos, ir.ODELETE, l, nil) -> ir.NewCallExpr(xpos, ir.ODELETE, l, nil)
ir.NodAt(xpos, ir.OGETG, l, nil) -> ir.NewCallExpr(xpos, ir.OGETG, l, nil)
ir.NodAt(xpos, ir.OMAKE, l, nil) -> ir.NewCallExpr(xpos, ir.OMAKE, l, nil)
ir.NodAt(xpos, ir.OPRINT, l, nil) -> ir.NewCallExpr(xpos, ir.OPRINT, l, nil)
ir.NodAt(xpos, ir.OPRINTN, l, nil) -> ir.NewCallExpr(xpos, ir.OPRINTN, l, nil)
ir.NodAt(xpos, ir.ORECOVER, l, nil) -> ir.NewCallExpr(xpos, ir.ORECOVER, l, nil)
ir.NodAt(xpos, ir.OCASE, nil, nil) -> ir.NewCaseStmt(xpos, nil, nil)
ir.NodAt(xpos, ir.OCONV, l, nil) -> ir.NewConvExpr(xpos, ir.OCONV, nil, l)
ir.NodAt(xpos, ir.OCONVIFACE, l, nil) -> ir.NewConvExpr(xpos, ir.OCONVIFACE, nil, l)
ir.NodAt(xpos, ir.OCONVNOP, l, nil) -> ir.NewConvExpr(xpos, ir.OCONVNOP, nil, l)
ir.NodAt(xpos, ir.ORUNESTR, l, nil) -> ir.NewConvExpr(xpos, ir.ORUNESTR, nil, l)
ir.NodAt(xpos, ir.ODCL, l, nil) -> ir.NewDecl(xpos, ir.ODCL, l)
ir.NodAt(xpos, ir.ODCLCONST, l, nil) -> ir.NewDecl(xpos, ir.ODCLCONST, l)
ir.NodAt(xpos, ir.ODCLTYPE, l, nil) -> ir.NewDecl(xpos, ir.ODCLTYPE, l)
ir.NodAt(xpos, ir.ODCLFUNC, nil, nil) -> ir.NewFunc(xpos)
ir.NodAt(xpos, ir.ODEFER, l, nil) -> ir.NewGoDeferStmt(xpos, ir.ODEFER, l)
ir.NodAt(xpos, ir.OGO, l, nil) -> ir.NewGoDeferStmt(xpos, ir.OGO, l)
ir.NodAt(xpos, ir.ODEREF, l, nil) -> ir.NewStarExpr(xpos, l)
ir.NodAt(xpos, ir.ODOT, l, nil) -> ir.NewSelectorExpr(xpos, ir.ODOT, l, nil)
ir.NodAt(xpos, ir.ODOTPTR, l, nil) -> ir.NewSelectorExpr(xpos, ir.ODOTPTR, l, nil)
ir.NodAt(xpos, ir.ODOTMETH, l, nil) -> ir.NewSelectorExpr(xpos, ir.ODOTMETH, l, nil)
ir.NodAt(xpos, ir.ODOTINTER, l, nil) -> ir.NewSelectorExpr(xpos, ir.ODOTINTER, l, nil)
ir.NodAt(xpos, ir.OXDOT, l, nil) -> ir.NewSelectorExpr(xpos, ir.OXDOT, l, nil)
ir.NodAt(xpos, ir.ODOTTYPE, l, nil) -> ir.NewTypeAssertExpr(xpos, l, nil)
ir.NodAt(xpos, ir.ODOTTYPE, l, r) -> ir.NewTypeAssertExpr(xpos, l, r.(ir.Ntype))
ir.NodAt(xpos, ir.OFOR, l, r) -> ir.NewForStmt(xpos, nil, l, r, nil)
ir.NodAt(xpos, ir.OINDEX, l, r) -> ir.NewIndexExpr(xpos, l, r)
ir.NodAt(xpos, ir.OINLMARK, nil, nil) -> ir.NewInlineMarkStmt(xpos, types.BADWIDTH)
ir.NodAt(xpos, ir.OKEY, l, r) -> ir.NewKeyExpr(xpos, l, r)
ir.NodAt(xpos, ir.OLABEL, nil, nil) -> ir.NewLabelStmt(xpos, nil)
ir.NodAt(xpos, ir.OMAKECHAN, l, r) -> ir.NewMakeExpr(xpos, ir.OMAKECHAN, l, r)
ir.NodAt(xpos, ir.OMAKEMAP, l, r) -> ir.NewMakeExpr(xpos, ir.OMAKEMAP, l, r)
ir.NodAt(xpos, ir.OMAKESLICE, l, r) -> ir.NewMakeExpr(xpos, ir.OMAKESLICE, l, r)
ir.NodAt(xpos, ir.OMAKESLICECOPY, l, r) -> ir.NewMakeExpr(xpos, ir.OMAKESLICECOPY, l, r)
ir.NodAt(xpos, ir.ONIL, nil, nil) -> ir.NewNilExpr(xpos)
ir.NodAt(xpos, ir.OPACK, nil, nil) -> ir.NewPkgName(xpos, nil, nil)
ir.NodAt(xpos, ir.OPAREN, l, nil) -> ir.NewParenExpr(xpos, l)
ir.NodAt(xpos, ir.ORANGE, nil, r) -> ir.NewRangeStmt(xpos, nil, r, nil)
ir.NodAt(xpos, ir.ORESULT, nil, nil) -> ir.NewResultExpr(xpos, nil, types.BADWIDTH)
ir.NodAt(xpos, ir.ORETURN, nil, nil) -> ir.NewReturnStmt(xpos, nil)
ir.NodAt(xpos, ir.OSELECT, nil, nil) -> ir.NewSelectStmt(xpos, nil)
ir.NodAt(xpos, ir.OSEND, l, r) -> ir.NewSendStmt(xpos, l, r)
ir.NodAt(xpos, ir.OSLICE, l, nil) -> ir.NewSliceExpr(xpos, ir.OSLICE, l)
ir.NodAt(xpos, ir.OSLICEARR, l, nil) -> ir.NewSliceExpr(xpos, ir.OSLICEARR, l)
ir.NodAt(xpos, ir.OSLICESTR, l, nil) -> ir.NewSliceExpr(xpos, ir.OSLICESTR, l)
ir.NodAt(xpos, ir.OSLICE3, l, nil) -> ir.NewSliceExpr(xpos, ir.OSLICE3, l)
ir.NodAt(xpos, ir.OSLICE3ARR, l, nil) -> ir.NewSliceExpr(xpos, ir.OSLICE3ARR, l)
ir.NodAt(xpos, ir.OSLICEHEADER, l, nil) -> ir.NewSliceHeaderExpr(xpos, nil, l, nil, nil)
ir.NodAt(xpos, ir.OSWITCH, l, nil) -> ir.NewSwitchStmt(xpos, l, nil)
ir.NodAt(xpos, ir.OINLCALL, nil, nil) -> ir.NewInlinedCallExpr(xpos, nil, nil)
}
rm noder.nod noder.nodSym nodSym nodlSym ir.NodAt ir.Nod
'
Change-Id: Ibf1eb708de8463ae74ccc47d7966cc263a18295e
Reviewed-on: https://go-review.googlesource.com/c/go/+/277933
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2020-12-22 23:55:29 -05:00
|
|
|
x := ir.NewAssignStmt(base.Pos, n.List().Second(), recvOK)
|
2020-12-18 11:29:49 -05:00
|
|
|
r.PtrBody().Append(typecheck(x, ctxStmt))
|
|
|
|
}
|
2017-03-07 15:12:11 -08:00
|
|
|
}
|
|
|
|
|
2020-11-22 09:59:15 -05:00
|
|
|
r.PtrBody().AppendNodes(cas.PtrBody())
|
[dev.regabi] cmd/compile: remove ir.Nod [generated]
Rewrite all uses of ir.Nod and friends to call the IR constructors directly.
This gives the results a more specific type and will play nicely with
introduction of more specific types throughout the code in a followup CL.
Passes buildall w/ toolstash -cmp.
[git-generate]
cd src/cmd/compile/internal/gc
rf '
ex . ../ir {
import "cmd/compile/internal/ir"
import "cmd/compile/internal/types"
import "cmd/compile/internal/syntax"
import "cmd/internal/src"
var p *noder
var orig syntax.Node
var op ir.Op
var l, r ir.Node
var sym *types.Sym
p.nod(orig, op, l, r) -> ir.NodAt(p.pos(orig), op, l, r)
p.nodSym(orig, op, l, sym) -> nodlSym(p.pos(orig), op, l, sym)
var xpos src.XPos
var ns ir.Nodes
npos(xpos, nodSym(op, l, sym)) -> nodlSym(xpos, op, l, sym)
npos(xpos, liststmt(ns)) -> ir.NewBlockStmt(xpos, ns)
}
ex . ../ir {
import "cmd/compile/internal/base"
import "cmd/compile/internal/ir"
import "cmd/compile/internal/types"
var op ir.Op
var l, r ir.Node
ir.Nod(op, l, r) -> ir.NodAt(base.Pos, op, l, r)
var sym *types.Sym
nodSym(op, l, sym) -> nodlSym(base.Pos, op, l, sym)
}
ex . ../ir {
import "cmd/compile/internal/ir"
import "cmd/internal/src"
# rf overlapping match handling is not quite good enough
# for certain nested rewrites, so handle these two - which often contain other ir.NodAt calls - early.
var l, r ir.Node
var xpos src.XPos
ir.NodAt(xpos, ir.OAS, l, r) -> ir.NewAssignStmt(xpos, l, r)
ir.NodAt(xpos, ir.OIF, l, nil) -> ir.NewIfStmt(xpos, l, nil, nil)
}
ex . ../ir {
import "cmd/compile/internal/ir"
import "cmd/compile/internal/types"
import "cmd/internal/src"
var l, r ir.Node
var sym *types.Sym
var xpos src.XPos
nodlSym(xpos, ir.ODOT, l, sym) -> ir.NewSelectorExpr(xpos, ir.ODOT, l, sym)
nodlSym(xpos, ir.OXDOT, l, sym) -> ir.NewSelectorExpr(xpos, ir.OXDOT, l, sym)
nodlSym(xpos, ir.ODOTPTR, l, sym) -> ir.NewSelectorExpr(xpos, ir.ODOTPTR, l, sym)
nodlSym(xpos, ir.OGOTO, nil, sym) -> ir.NewBranchStmt(xpos, ir.OGOTO, sym)
nodlSym(xpos, ir.ORETJMP, nil, sym) -> ir.NewBranchStmt(xpos, ir.ORETJMP, sym)
nodlSym(xpos, ir.OLABEL, nil, sym) -> ir.NewLabelStmt(xpos, sym)
nodlSym(xpos, ir.OSTRUCTKEY, l, sym) -> ir.NewStructKeyExpr(xpos, sym, l)
ir.NodAt(xpos, ir.OADD, l, r) -> ir.NewBinaryExpr(xpos, ir.OADD, l, r)
ir.NodAt(xpos, ir.OAND, l, r) -> ir.NewBinaryExpr(xpos, ir.OAND, l, r)
ir.NodAt(xpos, ir.OANDNOT, l, r) -> ir.NewBinaryExpr(xpos, ir.OANDNOT, l, r)
ir.NodAt(xpos, ir.ODIV, l, r) -> ir.NewBinaryExpr(xpos, ir.ODIV, l, r)
ir.NodAt(xpos, ir.OEQ, l, r) -> ir.NewBinaryExpr(xpos, ir.OEQ, l, r)
ir.NodAt(xpos, ir.OGE, l, r) -> ir.NewBinaryExpr(xpos, ir.OGE, l, r)
ir.NodAt(xpos, ir.OGT, l, r) -> ir.NewBinaryExpr(xpos, ir.OGT, l, r)
ir.NodAt(xpos, ir.OLE, l, r) -> ir.NewBinaryExpr(xpos, ir.OLE, l, r)
ir.NodAt(xpos, ir.OLSH, l, r) -> ir.NewBinaryExpr(xpos, ir.OLSH, l, r)
ir.NodAt(xpos, ir.OLT, l, r) -> ir.NewBinaryExpr(xpos, ir.OLT, l, r)
ir.NodAt(xpos, ir.OMOD, l, r) -> ir.NewBinaryExpr(xpos, ir.OMOD, l, r)
ir.NodAt(xpos, ir.OMUL, l, r) -> ir.NewBinaryExpr(xpos, ir.OMUL, l, r)
ir.NodAt(xpos, ir.ONE, l, r) -> ir.NewBinaryExpr(xpos, ir.ONE, l, r)
ir.NodAt(xpos, ir.OOR, l, r) -> ir.NewBinaryExpr(xpos, ir.OOR, l, r)
ir.NodAt(xpos, ir.ORSH, l, r) -> ir.NewBinaryExpr(xpos, ir.ORSH, l, r)
ir.NodAt(xpos, ir.OSUB, l, r) -> ir.NewBinaryExpr(xpos, ir.OSUB, l, r)
ir.NodAt(xpos, ir.OXOR, l, r) -> ir.NewBinaryExpr(xpos, ir.OXOR, l, r)
ir.NodAt(xpos, ir.OCOPY, l, r) -> ir.NewBinaryExpr(xpos, ir.OCOPY, l, r)
ir.NodAt(xpos, ir.OCOMPLEX, l, r) -> ir.NewBinaryExpr(xpos, ir.OCOMPLEX, l, r)
ir.NodAt(xpos, ir.OEFACE, l, r) -> ir.NewBinaryExpr(xpos, ir.OEFACE, l, r)
ir.NodAt(xpos, ir.OADDR, l, nil) -> ir.NewAddrExpr(xpos, l)
ir.NodAt(xpos, ir.OADDSTR, nil, nil) -> ir.NewAddStringExpr(xpos, nil)
ir.NodAt(xpos, ir.OANDAND, l, r) -> ir.NewLogicalExpr(xpos, ir.OANDAND, l, r)
ir.NodAt(xpos, ir.OOROR, l, r) -> ir.NewLogicalExpr(xpos, ir.OOROR, l, r)
ir.NodAt(xpos, ir.OARRAYLIT, nil, nil) -> ir.NewCompLitExpr(xpos, ir.OARRAYLIT, nil, nil)
ir.NodAt(xpos, ir.OCOMPLIT, nil, nil) -> ir.NewCompLitExpr(xpos, ir.OCOMPLIT, nil, nil)
ir.NodAt(xpos, ir.OMAPLIT, nil, nil) -> ir.NewCompLitExpr(xpos, ir.OMAPLIT, nil, nil)
ir.NodAt(xpos, ir.OSTRUCTLIT, nil, nil) -> ir.NewCompLitExpr(xpos, ir.OSTRUCTLIT, nil, nil)
ir.NodAt(xpos, ir.OSLICELIT, nil, nil) -> ir.NewCompLitExpr(xpos, ir.OSLICELIT, nil, nil)
ir.NodAt(xpos, ir.OARRAYLIT, nil, r) -> ir.NewCompLitExpr(xpos, ir.OARRAYLIT, r.(ir.Ntype), nil)
ir.NodAt(xpos, ir.OCOMPLIT, nil, r) -> ir.NewCompLitExpr(xpos, ir.OCOMPLIT, r.(ir.Ntype), nil)
ir.NodAt(xpos, ir.OMAPLIT, nil, r) -> ir.NewCompLitExpr(xpos, ir.OMAPLIT, r.(ir.Ntype), nil)
ir.NodAt(xpos, ir.OSTRUCTLIT, nil, r) -> ir.NewCompLitExpr(xpos, ir.OSTRUCTLIT, r.(ir.Ntype), nil)
ir.NodAt(xpos, ir.OSLICELIT, nil, r) -> ir.NewCompLitExpr(xpos, ir.OSLICELIT, r.(ir.Ntype), nil)
ir.NodAt(xpos, ir.OAS2, nil, nil) -> ir.NewAssignListStmt(xpos, ir.OAS2, nil, nil)
ir.NodAt(xpos, ir.OAS2DOTTYPE, nil, nil) -> ir.NewAssignListStmt(xpos, ir.OAS2DOTTYPE, nil, nil)
ir.NodAt(xpos, ir.OAS2FUNC, nil, nil) -> ir.NewAssignListStmt(xpos, ir.OAS2FUNC, nil, nil)
ir.NodAt(xpos, ir.OAS2MAPR, nil, nil) -> ir.NewAssignListStmt(xpos, ir.OAS2MAPR, nil, nil)
ir.NodAt(xpos, ir.OAS2RECV, nil, nil) -> ir.NewAssignListStmt(xpos, ir.OAS2RECV, nil, nil)
ir.NodAt(xpos, ir.OSELRECV2, nil, nil) -> ir.NewAssignListStmt(xpos, ir.OSELRECV2, nil, nil)
ir.NodAt(xpos, ir.OASOP, l, r) -> ir.NewAssignOpStmt(xpos, ir.OXXX, l, r)
ir.NodAt(xpos, ir.OBITNOT, l, nil) -> ir.NewUnaryExpr(xpos, ir.OBITNOT, l)
ir.NodAt(xpos, ir.ONEG, l, nil) -> ir.NewUnaryExpr(xpos, ir.ONEG, l)
ir.NodAt(xpos, ir.ONOT, l, nil) -> ir.NewUnaryExpr(xpos, ir.ONOT, l)
ir.NodAt(xpos, ir.OPLUS, l, nil) -> ir.NewUnaryExpr(xpos, ir.OPLUS, l)
ir.NodAt(xpos, ir.ORECV, l, nil) -> ir.NewUnaryExpr(xpos, ir.ORECV, l)
ir.NodAt(xpos, ir.OALIGNOF, l, nil) -> ir.NewUnaryExpr(xpos, ir.OALIGNOF, l)
ir.NodAt(xpos, ir.OCAP, l, nil) -> ir.NewUnaryExpr(xpos, ir.OCAP, l)
ir.NodAt(xpos, ir.OCLOSE, l, nil) -> ir.NewUnaryExpr(xpos, ir.OCLOSE, l)
ir.NodAt(xpos, ir.OIMAG, l, nil) -> ir.NewUnaryExpr(xpos, ir.OIMAG, l)
ir.NodAt(xpos, ir.OLEN, l, nil) -> ir.NewUnaryExpr(xpos, ir.OLEN, l)
ir.NodAt(xpos, ir.ONEW, l, nil) -> ir.NewUnaryExpr(xpos, ir.ONEW, l)
ir.NodAt(xpos, ir.ONEWOBJ, l, nil) -> ir.NewUnaryExpr(xpos, ir.ONEWOBJ, l)
ir.NodAt(xpos, ir.OOFFSETOF, l, nil) -> ir.NewUnaryExpr(xpos, ir.OOFFSETOF, l)
ir.NodAt(xpos, ir.OPANIC, l, nil) -> ir.NewUnaryExpr(xpos, ir.OPANIC, l)
ir.NodAt(xpos, ir.OREAL, l, nil) -> ir.NewUnaryExpr(xpos, ir.OREAL, l)
ir.NodAt(xpos, ir.OSIZEOF, l, nil) -> ir.NewUnaryExpr(xpos, ir.OSIZEOF, l)
ir.NodAt(xpos, ir.OCHECKNIL, l, nil) -> ir.NewUnaryExpr(xpos, ir.OCHECKNIL, l)
ir.NodAt(xpos, ir.OCFUNC, l, nil) -> ir.NewUnaryExpr(xpos, ir.OCFUNC, l)
ir.NodAt(xpos, ir.OIDATA, l, nil) -> ir.NewUnaryExpr(xpos, ir.OIDATA, l)
ir.NodAt(xpos, ir.OITAB, l, nil) -> ir.NewUnaryExpr(xpos, ir.OITAB, l)
ir.NodAt(xpos, ir.OSPTR, l, nil) -> ir.NewUnaryExpr(xpos, ir.OSPTR, l)
ir.NodAt(xpos, ir.OVARDEF, l, nil) -> ir.NewUnaryExpr(xpos, ir.OVARDEF, l)
ir.NodAt(xpos, ir.OVARKILL, l, nil) -> ir.NewUnaryExpr(xpos, ir.OVARKILL, l)
ir.NodAt(xpos, ir.OVARLIVE, l, nil) -> ir.NewUnaryExpr(xpos, ir.OVARLIVE, l)
ir.NodAt(xpos, ir.OBLOCK, nil, nil) -> ir.NewBlockStmt(xpos, nil)
ir.NodAt(xpos, ir.OBREAK, nil, nil) -> ir.NewBranchStmt(xpos, ir.OBREAK, nil)
ir.NodAt(xpos, ir.OCONTINUE, nil, nil) -> ir.NewBranchStmt(xpos, ir.OCONTINUE, nil)
ir.NodAt(xpos, ir.OFALL, nil, nil) -> ir.NewBranchStmt(xpos, ir.OFALL, nil)
ir.NodAt(xpos, ir.OGOTO, nil, nil) -> ir.NewBranchStmt(xpos, ir.OGOTO, nil)
ir.NodAt(xpos, ir.ORETJMP, nil, nil) -> ir.NewBranchStmt(xpos, ir.ORETJMP, nil)
ir.NodAt(xpos, ir.OCALL, l, nil) -> ir.NewCallExpr(xpos, ir.OCALL, l, nil)
ir.NodAt(xpos, ir.OCALLFUNC, l, nil) -> ir.NewCallExpr(xpos, ir.OCALLFUNC, l, nil)
ir.NodAt(xpos, ir.OCALLINTER, l, nil) -> ir.NewCallExpr(xpos, ir.OCALLINTER, l, nil)
ir.NodAt(xpos, ir.OCALLMETH, l, nil) -> ir.NewCallExpr(xpos, ir.OCALLMETH, l, nil)
ir.NodAt(xpos, ir.OAPPEND, l, nil) -> ir.NewCallExpr(xpos, ir.OAPPEND, l, nil)
ir.NodAt(xpos, ir.ODELETE, l, nil) -> ir.NewCallExpr(xpos, ir.ODELETE, l, nil)
ir.NodAt(xpos, ir.OGETG, l, nil) -> ir.NewCallExpr(xpos, ir.OGETG, l, nil)
ir.NodAt(xpos, ir.OMAKE, l, nil) -> ir.NewCallExpr(xpos, ir.OMAKE, l, nil)
ir.NodAt(xpos, ir.OPRINT, l, nil) -> ir.NewCallExpr(xpos, ir.OPRINT, l, nil)
ir.NodAt(xpos, ir.OPRINTN, l, nil) -> ir.NewCallExpr(xpos, ir.OPRINTN, l, nil)
ir.NodAt(xpos, ir.ORECOVER, l, nil) -> ir.NewCallExpr(xpos, ir.ORECOVER, l, nil)
ir.NodAt(xpos, ir.OCASE, nil, nil) -> ir.NewCaseStmt(xpos, nil, nil)
ir.NodAt(xpos, ir.OCONV, l, nil) -> ir.NewConvExpr(xpos, ir.OCONV, nil, l)
ir.NodAt(xpos, ir.OCONVIFACE, l, nil) -> ir.NewConvExpr(xpos, ir.OCONVIFACE, nil, l)
ir.NodAt(xpos, ir.OCONVNOP, l, nil) -> ir.NewConvExpr(xpos, ir.OCONVNOP, nil, l)
ir.NodAt(xpos, ir.ORUNESTR, l, nil) -> ir.NewConvExpr(xpos, ir.ORUNESTR, nil, l)
ir.NodAt(xpos, ir.ODCL, l, nil) -> ir.NewDecl(xpos, ir.ODCL, l)
ir.NodAt(xpos, ir.ODCLCONST, l, nil) -> ir.NewDecl(xpos, ir.ODCLCONST, l)
ir.NodAt(xpos, ir.ODCLTYPE, l, nil) -> ir.NewDecl(xpos, ir.ODCLTYPE, l)
ir.NodAt(xpos, ir.ODCLFUNC, nil, nil) -> ir.NewFunc(xpos)
ir.NodAt(xpos, ir.ODEFER, l, nil) -> ir.NewGoDeferStmt(xpos, ir.ODEFER, l)
ir.NodAt(xpos, ir.OGO, l, nil) -> ir.NewGoDeferStmt(xpos, ir.OGO, l)
ir.NodAt(xpos, ir.ODEREF, l, nil) -> ir.NewStarExpr(xpos, l)
ir.NodAt(xpos, ir.ODOT, l, nil) -> ir.NewSelectorExpr(xpos, ir.ODOT, l, nil)
ir.NodAt(xpos, ir.ODOTPTR, l, nil) -> ir.NewSelectorExpr(xpos, ir.ODOTPTR, l, nil)
ir.NodAt(xpos, ir.ODOTMETH, l, nil) -> ir.NewSelectorExpr(xpos, ir.ODOTMETH, l, nil)
ir.NodAt(xpos, ir.ODOTINTER, l, nil) -> ir.NewSelectorExpr(xpos, ir.ODOTINTER, l, nil)
ir.NodAt(xpos, ir.OXDOT, l, nil) -> ir.NewSelectorExpr(xpos, ir.OXDOT, l, nil)
ir.NodAt(xpos, ir.ODOTTYPE, l, nil) -> ir.NewTypeAssertExpr(xpos, l, nil)
ir.NodAt(xpos, ir.ODOTTYPE, l, r) -> ir.NewTypeAssertExpr(xpos, l, r.(ir.Ntype))
ir.NodAt(xpos, ir.OFOR, l, r) -> ir.NewForStmt(xpos, nil, l, r, nil)
ir.NodAt(xpos, ir.OINDEX, l, r) -> ir.NewIndexExpr(xpos, l, r)
ir.NodAt(xpos, ir.OINLMARK, nil, nil) -> ir.NewInlineMarkStmt(xpos, types.BADWIDTH)
ir.NodAt(xpos, ir.OKEY, l, r) -> ir.NewKeyExpr(xpos, l, r)
ir.NodAt(xpos, ir.OLABEL, nil, nil) -> ir.NewLabelStmt(xpos, nil)
ir.NodAt(xpos, ir.OMAKECHAN, l, r) -> ir.NewMakeExpr(xpos, ir.OMAKECHAN, l, r)
ir.NodAt(xpos, ir.OMAKEMAP, l, r) -> ir.NewMakeExpr(xpos, ir.OMAKEMAP, l, r)
ir.NodAt(xpos, ir.OMAKESLICE, l, r) -> ir.NewMakeExpr(xpos, ir.OMAKESLICE, l, r)
ir.NodAt(xpos, ir.OMAKESLICECOPY, l, r) -> ir.NewMakeExpr(xpos, ir.OMAKESLICECOPY, l, r)
ir.NodAt(xpos, ir.ONIL, nil, nil) -> ir.NewNilExpr(xpos)
ir.NodAt(xpos, ir.OPACK, nil, nil) -> ir.NewPkgName(xpos, nil, nil)
ir.NodAt(xpos, ir.OPAREN, l, nil) -> ir.NewParenExpr(xpos, l)
ir.NodAt(xpos, ir.ORANGE, nil, r) -> ir.NewRangeStmt(xpos, nil, r, nil)
ir.NodAt(xpos, ir.ORESULT, nil, nil) -> ir.NewResultExpr(xpos, nil, types.BADWIDTH)
ir.NodAt(xpos, ir.ORETURN, nil, nil) -> ir.NewReturnStmt(xpos, nil)
ir.NodAt(xpos, ir.OSELECT, nil, nil) -> ir.NewSelectStmt(xpos, nil)
ir.NodAt(xpos, ir.OSEND, l, r) -> ir.NewSendStmt(xpos, l, r)
ir.NodAt(xpos, ir.OSLICE, l, nil) -> ir.NewSliceExpr(xpos, ir.OSLICE, l)
ir.NodAt(xpos, ir.OSLICEARR, l, nil) -> ir.NewSliceExpr(xpos, ir.OSLICEARR, l)
ir.NodAt(xpos, ir.OSLICESTR, l, nil) -> ir.NewSliceExpr(xpos, ir.OSLICESTR, l)
ir.NodAt(xpos, ir.OSLICE3, l, nil) -> ir.NewSliceExpr(xpos, ir.OSLICE3, l)
ir.NodAt(xpos, ir.OSLICE3ARR, l, nil) -> ir.NewSliceExpr(xpos, ir.OSLICE3ARR, l)
ir.NodAt(xpos, ir.OSLICEHEADER, l, nil) -> ir.NewSliceHeaderExpr(xpos, nil, l, nil, nil)
ir.NodAt(xpos, ir.OSWITCH, l, nil) -> ir.NewSwitchStmt(xpos, l, nil)
ir.NodAt(xpos, ir.OINLCALL, nil, nil) -> ir.NewInlinedCallExpr(xpos, nil, nil)
}
rm noder.nod noder.nodSym nodSym nodlSym ir.NodAt ir.Nod
'
Change-Id: Ibf1eb708de8463ae74ccc47d7966cc263a18295e
Reviewed-on: https://go-review.googlesource.com/c/go/+/277933
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2020-12-22 23:55:29 -05:00
|
|
|
r.PtrBody().Append(ir.NewBranchStmt(base.Pos, ir.OBREAK, nil))
|
2016-02-27 14:31:33 -08:00
|
|
|
init = append(init, r)
|
2015-02-13 14:40:36 -05:00
|
|
|
}
|
|
|
|
|
2020-07-27 16:19:15 -07:00
|
|
|
if dflt != nil {
|
|
|
|
setlineno(dflt)
|
[dev.regabi] cmd/compile: remove ir.Nod [generated]
Rewrite all uses of ir.Nod and friends to call the IR constructors directly.
This gives the results a more specific type and will play nicely with
introduction of more specific types throughout the code in a followup CL.
Passes buildall w/ toolstash -cmp.
[git-generate]
cd src/cmd/compile/internal/gc
rf '
ex . ../ir {
import "cmd/compile/internal/ir"
import "cmd/compile/internal/types"
import "cmd/compile/internal/syntax"
import "cmd/internal/src"
var p *noder
var orig syntax.Node
var op ir.Op
var l, r ir.Node
var sym *types.Sym
p.nod(orig, op, l, r) -> ir.NodAt(p.pos(orig), op, l, r)
p.nodSym(orig, op, l, sym) -> nodlSym(p.pos(orig), op, l, sym)
var xpos src.XPos
var ns ir.Nodes
npos(xpos, nodSym(op, l, sym)) -> nodlSym(xpos, op, l, sym)
npos(xpos, liststmt(ns)) -> ir.NewBlockStmt(xpos, ns)
}
ex . ../ir {
import "cmd/compile/internal/base"
import "cmd/compile/internal/ir"
import "cmd/compile/internal/types"
var op ir.Op
var l, r ir.Node
ir.Nod(op, l, r) -> ir.NodAt(base.Pos, op, l, r)
var sym *types.Sym
nodSym(op, l, sym) -> nodlSym(base.Pos, op, l, sym)
}
ex . ../ir {
import "cmd/compile/internal/ir"
import "cmd/internal/src"
# rf overlapping match handling is not quite good enough
# for certain nested rewrites, so handle these two - which often contain other ir.NodAt calls - early.
var l, r ir.Node
var xpos src.XPos
ir.NodAt(xpos, ir.OAS, l, r) -> ir.NewAssignStmt(xpos, l, r)
ir.NodAt(xpos, ir.OIF, l, nil) -> ir.NewIfStmt(xpos, l, nil, nil)
}
ex . ../ir {
import "cmd/compile/internal/ir"
import "cmd/compile/internal/types"
import "cmd/internal/src"
var l, r ir.Node
var sym *types.Sym
var xpos src.XPos
nodlSym(xpos, ir.ODOT, l, sym) -> ir.NewSelectorExpr(xpos, ir.ODOT, l, sym)
nodlSym(xpos, ir.OXDOT, l, sym) -> ir.NewSelectorExpr(xpos, ir.OXDOT, l, sym)
nodlSym(xpos, ir.ODOTPTR, l, sym) -> ir.NewSelectorExpr(xpos, ir.ODOTPTR, l, sym)
nodlSym(xpos, ir.OGOTO, nil, sym) -> ir.NewBranchStmt(xpos, ir.OGOTO, sym)
nodlSym(xpos, ir.ORETJMP, nil, sym) -> ir.NewBranchStmt(xpos, ir.ORETJMP, sym)
nodlSym(xpos, ir.OLABEL, nil, sym) -> ir.NewLabelStmt(xpos, sym)
nodlSym(xpos, ir.OSTRUCTKEY, l, sym) -> ir.NewStructKeyExpr(xpos, sym, l)
ir.NodAt(xpos, ir.OADD, l, r) -> ir.NewBinaryExpr(xpos, ir.OADD, l, r)
ir.NodAt(xpos, ir.OAND, l, r) -> ir.NewBinaryExpr(xpos, ir.OAND, l, r)
ir.NodAt(xpos, ir.OANDNOT, l, r) -> ir.NewBinaryExpr(xpos, ir.OANDNOT, l, r)
ir.NodAt(xpos, ir.ODIV, l, r) -> ir.NewBinaryExpr(xpos, ir.ODIV, l, r)
ir.NodAt(xpos, ir.OEQ, l, r) -> ir.NewBinaryExpr(xpos, ir.OEQ, l, r)
ir.NodAt(xpos, ir.OGE, l, r) -> ir.NewBinaryExpr(xpos, ir.OGE, l, r)
ir.NodAt(xpos, ir.OGT, l, r) -> ir.NewBinaryExpr(xpos, ir.OGT, l, r)
ir.NodAt(xpos, ir.OLE, l, r) -> ir.NewBinaryExpr(xpos, ir.OLE, l, r)
ir.NodAt(xpos, ir.OLSH, l, r) -> ir.NewBinaryExpr(xpos, ir.OLSH, l, r)
ir.NodAt(xpos, ir.OLT, l, r) -> ir.NewBinaryExpr(xpos, ir.OLT, l, r)
ir.NodAt(xpos, ir.OMOD, l, r) -> ir.NewBinaryExpr(xpos, ir.OMOD, l, r)
ir.NodAt(xpos, ir.OMUL, l, r) -> ir.NewBinaryExpr(xpos, ir.OMUL, l, r)
ir.NodAt(xpos, ir.ONE, l, r) -> ir.NewBinaryExpr(xpos, ir.ONE, l, r)
ir.NodAt(xpos, ir.OOR, l, r) -> ir.NewBinaryExpr(xpos, ir.OOR, l, r)
ir.NodAt(xpos, ir.ORSH, l, r) -> ir.NewBinaryExpr(xpos, ir.ORSH, l, r)
ir.NodAt(xpos, ir.OSUB, l, r) -> ir.NewBinaryExpr(xpos, ir.OSUB, l, r)
ir.NodAt(xpos, ir.OXOR, l, r) -> ir.NewBinaryExpr(xpos, ir.OXOR, l, r)
ir.NodAt(xpos, ir.OCOPY, l, r) -> ir.NewBinaryExpr(xpos, ir.OCOPY, l, r)
ir.NodAt(xpos, ir.OCOMPLEX, l, r) -> ir.NewBinaryExpr(xpos, ir.OCOMPLEX, l, r)
ir.NodAt(xpos, ir.OEFACE, l, r) -> ir.NewBinaryExpr(xpos, ir.OEFACE, l, r)
ir.NodAt(xpos, ir.OADDR, l, nil) -> ir.NewAddrExpr(xpos, l)
ir.NodAt(xpos, ir.OADDSTR, nil, nil) -> ir.NewAddStringExpr(xpos, nil)
ir.NodAt(xpos, ir.OANDAND, l, r) -> ir.NewLogicalExpr(xpos, ir.OANDAND, l, r)
ir.NodAt(xpos, ir.OOROR, l, r) -> ir.NewLogicalExpr(xpos, ir.OOROR, l, r)
ir.NodAt(xpos, ir.OARRAYLIT, nil, nil) -> ir.NewCompLitExpr(xpos, ir.OARRAYLIT, nil, nil)
ir.NodAt(xpos, ir.OCOMPLIT, nil, nil) -> ir.NewCompLitExpr(xpos, ir.OCOMPLIT, nil, nil)
ir.NodAt(xpos, ir.OMAPLIT, nil, nil) -> ir.NewCompLitExpr(xpos, ir.OMAPLIT, nil, nil)
ir.NodAt(xpos, ir.OSTRUCTLIT, nil, nil) -> ir.NewCompLitExpr(xpos, ir.OSTRUCTLIT, nil, nil)
ir.NodAt(xpos, ir.OSLICELIT, nil, nil) -> ir.NewCompLitExpr(xpos, ir.OSLICELIT, nil, nil)
ir.NodAt(xpos, ir.OARRAYLIT, nil, r) -> ir.NewCompLitExpr(xpos, ir.OARRAYLIT, r.(ir.Ntype), nil)
ir.NodAt(xpos, ir.OCOMPLIT, nil, r) -> ir.NewCompLitExpr(xpos, ir.OCOMPLIT, r.(ir.Ntype), nil)
ir.NodAt(xpos, ir.OMAPLIT, nil, r) -> ir.NewCompLitExpr(xpos, ir.OMAPLIT, r.(ir.Ntype), nil)
ir.NodAt(xpos, ir.OSTRUCTLIT, nil, r) -> ir.NewCompLitExpr(xpos, ir.OSTRUCTLIT, r.(ir.Ntype), nil)
ir.NodAt(xpos, ir.OSLICELIT, nil, r) -> ir.NewCompLitExpr(xpos, ir.OSLICELIT, r.(ir.Ntype), nil)
ir.NodAt(xpos, ir.OAS2, nil, nil) -> ir.NewAssignListStmt(xpos, ir.OAS2, nil, nil)
ir.NodAt(xpos, ir.OAS2DOTTYPE, nil, nil) -> ir.NewAssignListStmt(xpos, ir.OAS2DOTTYPE, nil, nil)
ir.NodAt(xpos, ir.OAS2FUNC, nil, nil) -> ir.NewAssignListStmt(xpos, ir.OAS2FUNC, nil, nil)
ir.NodAt(xpos, ir.OAS2MAPR, nil, nil) -> ir.NewAssignListStmt(xpos, ir.OAS2MAPR, nil, nil)
ir.NodAt(xpos, ir.OAS2RECV, nil, nil) -> ir.NewAssignListStmt(xpos, ir.OAS2RECV, nil, nil)
ir.NodAt(xpos, ir.OSELRECV2, nil, nil) -> ir.NewAssignListStmt(xpos, ir.OSELRECV2, nil, nil)
ir.NodAt(xpos, ir.OASOP, l, r) -> ir.NewAssignOpStmt(xpos, ir.OXXX, l, r)
ir.NodAt(xpos, ir.OBITNOT, l, nil) -> ir.NewUnaryExpr(xpos, ir.OBITNOT, l)
ir.NodAt(xpos, ir.ONEG, l, nil) -> ir.NewUnaryExpr(xpos, ir.ONEG, l)
ir.NodAt(xpos, ir.ONOT, l, nil) -> ir.NewUnaryExpr(xpos, ir.ONOT, l)
ir.NodAt(xpos, ir.OPLUS, l, nil) -> ir.NewUnaryExpr(xpos, ir.OPLUS, l)
ir.NodAt(xpos, ir.ORECV, l, nil) -> ir.NewUnaryExpr(xpos, ir.ORECV, l)
ir.NodAt(xpos, ir.OALIGNOF, l, nil) -> ir.NewUnaryExpr(xpos, ir.OALIGNOF, l)
ir.NodAt(xpos, ir.OCAP, l, nil) -> ir.NewUnaryExpr(xpos, ir.OCAP, l)
ir.NodAt(xpos, ir.OCLOSE, l, nil) -> ir.NewUnaryExpr(xpos, ir.OCLOSE, l)
ir.NodAt(xpos, ir.OIMAG, l, nil) -> ir.NewUnaryExpr(xpos, ir.OIMAG, l)
ir.NodAt(xpos, ir.OLEN, l, nil) -> ir.NewUnaryExpr(xpos, ir.OLEN, l)
ir.NodAt(xpos, ir.ONEW, l, nil) -> ir.NewUnaryExpr(xpos, ir.ONEW, l)
ir.NodAt(xpos, ir.ONEWOBJ, l, nil) -> ir.NewUnaryExpr(xpos, ir.ONEWOBJ, l)
ir.NodAt(xpos, ir.OOFFSETOF, l, nil) -> ir.NewUnaryExpr(xpos, ir.OOFFSETOF, l)
ir.NodAt(xpos, ir.OPANIC, l, nil) -> ir.NewUnaryExpr(xpos, ir.OPANIC, l)
ir.NodAt(xpos, ir.OREAL, l, nil) -> ir.NewUnaryExpr(xpos, ir.OREAL, l)
ir.NodAt(xpos, ir.OSIZEOF, l, nil) -> ir.NewUnaryExpr(xpos, ir.OSIZEOF, l)
ir.NodAt(xpos, ir.OCHECKNIL, l, nil) -> ir.NewUnaryExpr(xpos, ir.OCHECKNIL, l)
ir.NodAt(xpos, ir.OCFUNC, l, nil) -> ir.NewUnaryExpr(xpos, ir.OCFUNC, l)
ir.NodAt(xpos, ir.OIDATA, l, nil) -> ir.NewUnaryExpr(xpos, ir.OIDATA, l)
ir.NodAt(xpos, ir.OITAB, l, nil) -> ir.NewUnaryExpr(xpos, ir.OITAB, l)
ir.NodAt(xpos, ir.OSPTR, l, nil) -> ir.NewUnaryExpr(xpos, ir.OSPTR, l)
ir.NodAt(xpos, ir.OVARDEF, l, nil) -> ir.NewUnaryExpr(xpos, ir.OVARDEF, l)
ir.NodAt(xpos, ir.OVARKILL, l, nil) -> ir.NewUnaryExpr(xpos, ir.OVARKILL, l)
ir.NodAt(xpos, ir.OVARLIVE, l, nil) -> ir.NewUnaryExpr(xpos, ir.OVARLIVE, l)
ir.NodAt(xpos, ir.OBLOCK, nil, nil) -> ir.NewBlockStmt(xpos, nil)
ir.NodAt(xpos, ir.OBREAK, nil, nil) -> ir.NewBranchStmt(xpos, ir.OBREAK, nil)
ir.NodAt(xpos, ir.OCONTINUE, nil, nil) -> ir.NewBranchStmt(xpos, ir.OCONTINUE, nil)
ir.NodAt(xpos, ir.OFALL, nil, nil) -> ir.NewBranchStmt(xpos, ir.OFALL, nil)
ir.NodAt(xpos, ir.OGOTO, nil, nil) -> ir.NewBranchStmt(xpos, ir.OGOTO, nil)
ir.NodAt(xpos, ir.ORETJMP, nil, nil) -> ir.NewBranchStmt(xpos, ir.ORETJMP, nil)
ir.NodAt(xpos, ir.OCALL, l, nil) -> ir.NewCallExpr(xpos, ir.OCALL, l, nil)
ir.NodAt(xpos, ir.OCALLFUNC, l, nil) -> ir.NewCallExpr(xpos, ir.OCALLFUNC, l, nil)
ir.NodAt(xpos, ir.OCALLINTER, l, nil) -> ir.NewCallExpr(xpos, ir.OCALLINTER, l, nil)
ir.NodAt(xpos, ir.OCALLMETH, l, nil) -> ir.NewCallExpr(xpos, ir.OCALLMETH, l, nil)
ir.NodAt(xpos, ir.OAPPEND, l, nil) -> ir.NewCallExpr(xpos, ir.OAPPEND, l, nil)
ir.NodAt(xpos, ir.ODELETE, l, nil) -> ir.NewCallExpr(xpos, ir.ODELETE, l, nil)
ir.NodAt(xpos, ir.OGETG, l, nil) -> ir.NewCallExpr(xpos, ir.OGETG, l, nil)
ir.NodAt(xpos, ir.OMAKE, l, nil) -> ir.NewCallExpr(xpos, ir.OMAKE, l, nil)
ir.NodAt(xpos, ir.OPRINT, l, nil) -> ir.NewCallExpr(xpos, ir.OPRINT, l, nil)
ir.NodAt(xpos, ir.OPRINTN, l, nil) -> ir.NewCallExpr(xpos, ir.OPRINTN, l, nil)
ir.NodAt(xpos, ir.ORECOVER, l, nil) -> ir.NewCallExpr(xpos, ir.ORECOVER, l, nil)
ir.NodAt(xpos, ir.OCASE, nil, nil) -> ir.NewCaseStmt(xpos, nil, nil)
ir.NodAt(xpos, ir.OCONV, l, nil) -> ir.NewConvExpr(xpos, ir.OCONV, nil, l)
ir.NodAt(xpos, ir.OCONVIFACE, l, nil) -> ir.NewConvExpr(xpos, ir.OCONVIFACE, nil, l)
ir.NodAt(xpos, ir.OCONVNOP, l, nil) -> ir.NewConvExpr(xpos, ir.OCONVNOP, nil, l)
ir.NodAt(xpos, ir.ORUNESTR, l, nil) -> ir.NewConvExpr(xpos, ir.ORUNESTR, nil, l)
ir.NodAt(xpos, ir.ODCL, l, nil) -> ir.NewDecl(xpos, ir.ODCL, l)
ir.NodAt(xpos, ir.ODCLCONST, l, nil) -> ir.NewDecl(xpos, ir.ODCLCONST, l)
ir.NodAt(xpos, ir.ODCLTYPE, l, nil) -> ir.NewDecl(xpos, ir.ODCLTYPE, l)
ir.NodAt(xpos, ir.ODCLFUNC, nil, nil) -> ir.NewFunc(xpos)
ir.NodAt(xpos, ir.ODEFER, l, nil) -> ir.NewGoDeferStmt(xpos, ir.ODEFER, l)
ir.NodAt(xpos, ir.OGO, l, nil) -> ir.NewGoDeferStmt(xpos, ir.OGO, l)
ir.NodAt(xpos, ir.ODEREF, l, nil) -> ir.NewStarExpr(xpos, l)
ir.NodAt(xpos, ir.ODOT, l, nil) -> ir.NewSelectorExpr(xpos, ir.ODOT, l, nil)
ir.NodAt(xpos, ir.ODOTPTR, l, nil) -> ir.NewSelectorExpr(xpos, ir.ODOTPTR, l, nil)
ir.NodAt(xpos, ir.ODOTMETH, l, nil) -> ir.NewSelectorExpr(xpos, ir.ODOTMETH, l, nil)
ir.NodAt(xpos, ir.ODOTINTER, l, nil) -> ir.NewSelectorExpr(xpos, ir.ODOTINTER, l, nil)
ir.NodAt(xpos, ir.OXDOT, l, nil) -> ir.NewSelectorExpr(xpos, ir.OXDOT, l, nil)
ir.NodAt(xpos, ir.ODOTTYPE, l, nil) -> ir.NewTypeAssertExpr(xpos, l, nil)
ir.NodAt(xpos, ir.ODOTTYPE, l, r) -> ir.NewTypeAssertExpr(xpos, l, r.(ir.Ntype))
ir.NodAt(xpos, ir.OFOR, l, r) -> ir.NewForStmt(xpos, nil, l, r, nil)
ir.NodAt(xpos, ir.OINDEX, l, r) -> ir.NewIndexExpr(xpos, l, r)
ir.NodAt(xpos, ir.OINLMARK, nil, nil) -> ir.NewInlineMarkStmt(xpos, types.BADWIDTH)
ir.NodAt(xpos, ir.OKEY, l, r) -> ir.NewKeyExpr(xpos, l, r)
ir.NodAt(xpos, ir.OLABEL, nil, nil) -> ir.NewLabelStmt(xpos, nil)
ir.NodAt(xpos, ir.OMAKECHAN, l, r) -> ir.NewMakeExpr(xpos, ir.OMAKECHAN, l, r)
ir.NodAt(xpos, ir.OMAKEMAP, l, r) -> ir.NewMakeExpr(xpos, ir.OMAKEMAP, l, r)
ir.NodAt(xpos, ir.OMAKESLICE, l, r) -> ir.NewMakeExpr(xpos, ir.OMAKESLICE, l, r)
ir.NodAt(xpos, ir.OMAKESLICECOPY, l, r) -> ir.NewMakeExpr(xpos, ir.OMAKESLICECOPY, l, r)
ir.NodAt(xpos, ir.ONIL, nil, nil) -> ir.NewNilExpr(xpos)
ir.NodAt(xpos, ir.OPACK, nil, nil) -> ir.NewPkgName(xpos, nil, nil)
ir.NodAt(xpos, ir.OPAREN, l, nil) -> ir.NewParenExpr(xpos, l)
ir.NodAt(xpos, ir.ORANGE, nil, r) -> ir.NewRangeStmt(xpos, nil, r, nil)
ir.NodAt(xpos, ir.ORESULT, nil, nil) -> ir.NewResultExpr(xpos, nil, types.BADWIDTH)
ir.NodAt(xpos, ir.ORETURN, nil, nil) -> ir.NewReturnStmt(xpos, nil)
ir.NodAt(xpos, ir.OSELECT, nil, nil) -> ir.NewSelectStmt(xpos, nil)
ir.NodAt(xpos, ir.OSEND, l, r) -> ir.NewSendStmt(xpos, l, r)
ir.NodAt(xpos, ir.OSLICE, l, nil) -> ir.NewSliceExpr(xpos, ir.OSLICE, l)
ir.NodAt(xpos, ir.OSLICEARR, l, nil) -> ir.NewSliceExpr(xpos, ir.OSLICEARR, l)
ir.NodAt(xpos, ir.OSLICESTR, l, nil) -> ir.NewSliceExpr(xpos, ir.OSLICESTR, l)
ir.NodAt(xpos, ir.OSLICE3, l, nil) -> ir.NewSliceExpr(xpos, ir.OSLICE3, l)
ir.NodAt(xpos, ir.OSLICE3ARR, l, nil) -> ir.NewSliceExpr(xpos, ir.OSLICE3ARR, l)
ir.NodAt(xpos, ir.OSLICEHEADER, l, nil) -> ir.NewSliceHeaderExpr(xpos, nil, l, nil, nil)
ir.NodAt(xpos, ir.OSWITCH, l, nil) -> ir.NewSwitchStmt(xpos, l, nil)
ir.NodAt(xpos, ir.OINLCALL, nil, nil) -> ir.NewInlinedCallExpr(xpos, nil, nil)
}
rm noder.nod noder.nodSym nodSym nodlSym ir.NodAt ir.Nod
'
Change-Id: Ibf1eb708de8463ae74ccc47d7966cc263a18295e
Reviewed-on: https://go-review.googlesource.com/c/go/+/277933
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2020-12-22 23:55:29 -05:00
|
|
|
dispatch(ir.NewBinaryExpr(base.Pos, ir.OLT, chosen, nodintconst(0)), dflt)
|
2020-07-27 16:19:15 -07:00
|
|
|
}
|
|
|
|
for i, cas := range casorder {
|
|
|
|
setlineno(cas)
|
[dev.regabi] cmd/compile: remove ir.Nod [generated]
Rewrite all uses of ir.Nod and friends to call the IR constructors directly.
This gives the results a more specific type and will play nicely with
introduction of more specific types throughout the code in a followup CL.
Passes buildall w/ toolstash -cmp.
[git-generate]
cd src/cmd/compile/internal/gc
rf '
ex . ../ir {
import "cmd/compile/internal/ir"
import "cmd/compile/internal/types"
import "cmd/compile/internal/syntax"
import "cmd/internal/src"
var p *noder
var orig syntax.Node
var op ir.Op
var l, r ir.Node
var sym *types.Sym
p.nod(orig, op, l, r) -> ir.NodAt(p.pos(orig), op, l, r)
p.nodSym(orig, op, l, sym) -> nodlSym(p.pos(orig), op, l, sym)
var xpos src.XPos
var ns ir.Nodes
npos(xpos, nodSym(op, l, sym)) -> nodlSym(xpos, op, l, sym)
npos(xpos, liststmt(ns)) -> ir.NewBlockStmt(xpos, ns)
}
ex . ../ir {
import "cmd/compile/internal/base"
import "cmd/compile/internal/ir"
import "cmd/compile/internal/types"
var op ir.Op
var l, r ir.Node
ir.Nod(op, l, r) -> ir.NodAt(base.Pos, op, l, r)
var sym *types.Sym
nodSym(op, l, sym) -> nodlSym(base.Pos, op, l, sym)
}
ex . ../ir {
import "cmd/compile/internal/ir"
import "cmd/internal/src"
# rf overlapping match handling is not quite good enough
# for certain nested rewrites, so handle these two - which often contain other ir.NodAt calls - early.
var l, r ir.Node
var xpos src.XPos
ir.NodAt(xpos, ir.OAS, l, r) -> ir.NewAssignStmt(xpos, l, r)
ir.NodAt(xpos, ir.OIF, l, nil) -> ir.NewIfStmt(xpos, l, nil, nil)
}
ex . ../ir {
import "cmd/compile/internal/ir"
import "cmd/compile/internal/types"
import "cmd/internal/src"
var l, r ir.Node
var sym *types.Sym
var xpos src.XPos
nodlSym(xpos, ir.ODOT, l, sym) -> ir.NewSelectorExpr(xpos, ir.ODOT, l, sym)
nodlSym(xpos, ir.OXDOT, l, sym) -> ir.NewSelectorExpr(xpos, ir.OXDOT, l, sym)
nodlSym(xpos, ir.ODOTPTR, l, sym) -> ir.NewSelectorExpr(xpos, ir.ODOTPTR, l, sym)
nodlSym(xpos, ir.OGOTO, nil, sym) -> ir.NewBranchStmt(xpos, ir.OGOTO, sym)
nodlSym(xpos, ir.ORETJMP, nil, sym) -> ir.NewBranchStmt(xpos, ir.ORETJMP, sym)
nodlSym(xpos, ir.OLABEL, nil, sym) -> ir.NewLabelStmt(xpos, sym)
nodlSym(xpos, ir.OSTRUCTKEY, l, sym) -> ir.NewStructKeyExpr(xpos, sym, l)
ir.NodAt(xpos, ir.OADD, l, r) -> ir.NewBinaryExpr(xpos, ir.OADD, l, r)
ir.NodAt(xpos, ir.OAND, l, r) -> ir.NewBinaryExpr(xpos, ir.OAND, l, r)
ir.NodAt(xpos, ir.OANDNOT, l, r) -> ir.NewBinaryExpr(xpos, ir.OANDNOT, l, r)
ir.NodAt(xpos, ir.ODIV, l, r) -> ir.NewBinaryExpr(xpos, ir.ODIV, l, r)
ir.NodAt(xpos, ir.OEQ, l, r) -> ir.NewBinaryExpr(xpos, ir.OEQ, l, r)
ir.NodAt(xpos, ir.OGE, l, r) -> ir.NewBinaryExpr(xpos, ir.OGE, l, r)
ir.NodAt(xpos, ir.OGT, l, r) -> ir.NewBinaryExpr(xpos, ir.OGT, l, r)
ir.NodAt(xpos, ir.OLE, l, r) -> ir.NewBinaryExpr(xpos, ir.OLE, l, r)
ir.NodAt(xpos, ir.OLSH, l, r) -> ir.NewBinaryExpr(xpos, ir.OLSH, l, r)
ir.NodAt(xpos, ir.OLT, l, r) -> ir.NewBinaryExpr(xpos, ir.OLT, l, r)
ir.NodAt(xpos, ir.OMOD, l, r) -> ir.NewBinaryExpr(xpos, ir.OMOD, l, r)
ir.NodAt(xpos, ir.OMUL, l, r) -> ir.NewBinaryExpr(xpos, ir.OMUL, l, r)
ir.NodAt(xpos, ir.ONE, l, r) -> ir.NewBinaryExpr(xpos, ir.ONE, l, r)
ir.NodAt(xpos, ir.OOR, l, r) -> ir.NewBinaryExpr(xpos, ir.OOR, l, r)
ir.NodAt(xpos, ir.ORSH, l, r) -> ir.NewBinaryExpr(xpos, ir.ORSH, l, r)
ir.NodAt(xpos, ir.OSUB, l, r) -> ir.NewBinaryExpr(xpos, ir.OSUB, l, r)
ir.NodAt(xpos, ir.OXOR, l, r) -> ir.NewBinaryExpr(xpos, ir.OXOR, l, r)
ir.NodAt(xpos, ir.OCOPY, l, r) -> ir.NewBinaryExpr(xpos, ir.OCOPY, l, r)
ir.NodAt(xpos, ir.OCOMPLEX, l, r) -> ir.NewBinaryExpr(xpos, ir.OCOMPLEX, l, r)
ir.NodAt(xpos, ir.OEFACE, l, r) -> ir.NewBinaryExpr(xpos, ir.OEFACE, l, r)
ir.NodAt(xpos, ir.OADDR, l, nil) -> ir.NewAddrExpr(xpos, l)
ir.NodAt(xpos, ir.OADDSTR, nil, nil) -> ir.NewAddStringExpr(xpos, nil)
ir.NodAt(xpos, ir.OANDAND, l, r) -> ir.NewLogicalExpr(xpos, ir.OANDAND, l, r)
ir.NodAt(xpos, ir.OOROR, l, r) -> ir.NewLogicalExpr(xpos, ir.OOROR, l, r)
ir.NodAt(xpos, ir.OARRAYLIT, nil, nil) -> ir.NewCompLitExpr(xpos, ir.OARRAYLIT, nil, nil)
ir.NodAt(xpos, ir.OCOMPLIT, nil, nil) -> ir.NewCompLitExpr(xpos, ir.OCOMPLIT, nil, nil)
ir.NodAt(xpos, ir.OMAPLIT, nil, nil) -> ir.NewCompLitExpr(xpos, ir.OMAPLIT, nil, nil)
ir.NodAt(xpos, ir.OSTRUCTLIT, nil, nil) -> ir.NewCompLitExpr(xpos, ir.OSTRUCTLIT, nil, nil)
ir.NodAt(xpos, ir.OSLICELIT, nil, nil) -> ir.NewCompLitExpr(xpos, ir.OSLICELIT, nil, nil)
ir.NodAt(xpos, ir.OARRAYLIT, nil, r) -> ir.NewCompLitExpr(xpos, ir.OARRAYLIT, r.(ir.Ntype), nil)
ir.NodAt(xpos, ir.OCOMPLIT, nil, r) -> ir.NewCompLitExpr(xpos, ir.OCOMPLIT, r.(ir.Ntype), nil)
ir.NodAt(xpos, ir.OMAPLIT, nil, r) -> ir.NewCompLitExpr(xpos, ir.OMAPLIT, r.(ir.Ntype), nil)
ir.NodAt(xpos, ir.OSTRUCTLIT, nil, r) -> ir.NewCompLitExpr(xpos, ir.OSTRUCTLIT, r.(ir.Ntype), nil)
ir.NodAt(xpos, ir.OSLICELIT, nil, r) -> ir.NewCompLitExpr(xpos, ir.OSLICELIT, r.(ir.Ntype), nil)
ir.NodAt(xpos, ir.OAS2, nil, nil) -> ir.NewAssignListStmt(xpos, ir.OAS2, nil, nil)
ir.NodAt(xpos, ir.OAS2DOTTYPE, nil, nil) -> ir.NewAssignListStmt(xpos, ir.OAS2DOTTYPE, nil, nil)
ir.NodAt(xpos, ir.OAS2FUNC, nil, nil) -> ir.NewAssignListStmt(xpos, ir.OAS2FUNC, nil, nil)
ir.NodAt(xpos, ir.OAS2MAPR, nil, nil) -> ir.NewAssignListStmt(xpos, ir.OAS2MAPR, nil, nil)
ir.NodAt(xpos, ir.OAS2RECV, nil, nil) -> ir.NewAssignListStmt(xpos, ir.OAS2RECV, nil, nil)
ir.NodAt(xpos, ir.OSELRECV2, nil, nil) -> ir.NewAssignListStmt(xpos, ir.OSELRECV2, nil, nil)
ir.NodAt(xpos, ir.OASOP, l, r) -> ir.NewAssignOpStmt(xpos, ir.OXXX, l, r)
ir.NodAt(xpos, ir.OBITNOT, l, nil) -> ir.NewUnaryExpr(xpos, ir.OBITNOT, l)
ir.NodAt(xpos, ir.ONEG, l, nil) -> ir.NewUnaryExpr(xpos, ir.ONEG, l)
ir.NodAt(xpos, ir.ONOT, l, nil) -> ir.NewUnaryExpr(xpos, ir.ONOT, l)
ir.NodAt(xpos, ir.OPLUS, l, nil) -> ir.NewUnaryExpr(xpos, ir.OPLUS, l)
ir.NodAt(xpos, ir.ORECV, l, nil) -> ir.NewUnaryExpr(xpos, ir.ORECV, l)
ir.NodAt(xpos, ir.OALIGNOF, l, nil) -> ir.NewUnaryExpr(xpos, ir.OALIGNOF, l)
ir.NodAt(xpos, ir.OCAP, l, nil) -> ir.NewUnaryExpr(xpos, ir.OCAP, l)
ir.NodAt(xpos, ir.OCLOSE, l, nil) -> ir.NewUnaryExpr(xpos, ir.OCLOSE, l)
ir.NodAt(xpos, ir.OIMAG, l, nil) -> ir.NewUnaryExpr(xpos, ir.OIMAG, l)
ir.NodAt(xpos, ir.OLEN, l, nil) -> ir.NewUnaryExpr(xpos, ir.OLEN, l)
ir.NodAt(xpos, ir.ONEW, l, nil) -> ir.NewUnaryExpr(xpos, ir.ONEW, l)
ir.NodAt(xpos, ir.ONEWOBJ, l, nil) -> ir.NewUnaryExpr(xpos, ir.ONEWOBJ, l)
ir.NodAt(xpos, ir.OOFFSETOF, l, nil) -> ir.NewUnaryExpr(xpos, ir.OOFFSETOF, l)
ir.NodAt(xpos, ir.OPANIC, l, nil) -> ir.NewUnaryExpr(xpos, ir.OPANIC, l)
ir.NodAt(xpos, ir.OREAL, l, nil) -> ir.NewUnaryExpr(xpos, ir.OREAL, l)
ir.NodAt(xpos, ir.OSIZEOF, l, nil) -> ir.NewUnaryExpr(xpos, ir.OSIZEOF, l)
ir.NodAt(xpos, ir.OCHECKNIL, l, nil) -> ir.NewUnaryExpr(xpos, ir.OCHECKNIL, l)
ir.NodAt(xpos, ir.OCFUNC, l, nil) -> ir.NewUnaryExpr(xpos, ir.OCFUNC, l)
ir.NodAt(xpos, ir.OIDATA, l, nil) -> ir.NewUnaryExpr(xpos, ir.OIDATA, l)
ir.NodAt(xpos, ir.OITAB, l, nil) -> ir.NewUnaryExpr(xpos, ir.OITAB, l)
ir.NodAt(xpos, ir.OSPTR, l, nil) -> ir.NewUnaryExpr(xpos, ir.OSPTR, l)
ir.NodAt(xpos, ir.OVARDEF, l, nil) -> ir.NewUnaryExpr(xpos, ir.OVARDEF, l)
ir.NodAt(xpos, ir.OVARKILL, l, nil) -> ir.NewUnaryExpr(xpos, ir.OVARKILL, l)
ir.NodAt(xpos, ir.OVARLIVE, l, nil) -> ir.NewUnaryExpr(xpos, ir.OVARLIVE, l)
ir.NodAt(xpos, ir.OBLOCK, nil, nil) -> ir.NewBlockStmt(xpos, nil)
ir.NodAt(xpos, ir.OBREAK, nil, nil) -> ir.NewBranchStmt(xpos, ir.OBREAK, nil)
ir.NodAt(xpos, ir.OCONTINUE, nil, nil) -> ir.NewBranchStmt(xpos, ir.OCONTINUE, nil)
ir.NodAt(xpos, ir.OFALL, nil, nil) -> ir.NewBranchStmt(xpos, ir.OFALL, nil)
ir.NodAt(xpos, ir.OGOTO, nil, nil) -> ir.NewBranchStmt(xpos, ir.OGOTO, nil)
ir.NodAt(xpos, ir.ORETJMP, nil, nil) -> ir.NewBranchStmt(xpos, ir.ORETJMP, nil)
ir.NodAt(xpos, ir.OCALL, l, nil) -> ir.NewCallExpr(xpos, ir.OCALL, l, nil)
ir.NodAt(xpos, ir.OCALLFUNC, l, nil) -> ir.NewCallExpr(xpos, ir.OCALLFUNC, l, nil)
ir.NodAt(xpos, ir.OCALLINTER, l, nil) -> ir.NewCallExpr(xpos, ir.OCALLINTER, l, nil)
ir.NodAt(xpos, ir.OCALLMETH, l, nil) -> ir.NewCallExpr(xpos, ir.OCALLMETH, l, nil)
ir.NodAt(xpos, ir.OAPPEND, l, nil) -> ir.NewCallExpr(xpos, ir.OAPPEND, l, nil)
ir.NodAt(xpos, ir.ODELETE, l, nil) -> ir.NewCallExpr(xpos, ir.ODELETE, l, nil)
ir.NodAt(xpos, ir.OGETG, l, nil) -> ir.NewCallExpr(xpos, ir.OGETG, l, nil)
ir.NodAt(xpos, ir.OMAKE, l, nil) -> ir.NewCallExpr(xpos, ir.OMAKE, l, nil)
ir.NodAt(xpos, ir.OPRINT, l, nil) -> ir.NewCallExpr(xpos, ir.OPRINT, l, nil)
ir.NodAt(xpos, ir.OPRINTN, l, nil) -> ir.NewCallExpr(xpos, ir.OPRINTN, l, nil)
ir.NodAt(xpos, ir.ORECOVER, l, nil) -> ir.NewCallExpr(xpos, ir.ORECOVER, l, nil)
ir.NodAt(xpos, ir.OCASE, nil, nil) -> ir.NewCaseStmt(xpos, nil, nil)
ir.NodAt(xpos, ir.OCONV, l, nil) -> ir.NewConvExpr(xpos, ir.OCONV, nil, l)
ir.NodAt(xpos, ir.OCONVIFACE, l, nil) -> ir.NewConvExpr(xpos, ir.OCONVIFACE, nil, l)
ir.NodAt(xpos, ir.OCONVNOP, l, nil) -> ir.NewConvExpr(xpos, ir.OCONVNOP, nil, l)
ir.NodAt(xpos, ir.ORUNESTR, l, nil) -> ir.NewConvExpr(xpos, ir.ORUNESTR, nil, l)
ir.NodAt(xpos, ir.ODCL, l, nil) -> ir.NewDecl(xpos, ir.ODCL, l)
ir.NodAt(xpos, ir.ODCLCONST, l, nil) -> ir.NewDecl(xpos, ir.ODCLCONST, l)
ir.NodAt(xpos, ir.ODCLTYPE, l, nil) -> ir.NewDecl(xpos, ir.ODCLTYPE, l)
ir.NodAt(xpos, ir.ODCLFUNC, nil, nil) -> ir.NewFunc(xpos)
ir.NodAt(xpos, ir.ODEFER, l, nil) -> ir.NewGoDeferStmt(xpos, ir.ODEFER, l)
ir.NodAt(xpos, ir.OGO, l, nil) -> ir.NewGoDeferStmt(xpos, ir.OGO, l)
ir.NodAt(xpos, ir.ODEREF, l, nil) -> ir.NewStarExpr(xpos, l)
ir.NodAt(xpos, ir.ODOT, l, nil) -> ir.NewSelectorExpr(xpos, ir.ODOT, l, nil)
ir.NodAt(xpos, ir.ODOTPTR, l, nil) -> ir.NewSelectorExpr(xpos, ir.ODOTPTR, l, nil)
ir.NodAt(xpos, ir.ODOTMETH, l, nil) -> ir.NewSelectorExpr(xpos, ir.ODOTMETH, l, nil)
ir.NodAt(xpos, ir.ODOTINTER, l, nil) -> ir.NewSelectorExpr(xpos, ir.ODOTINTER, l, nil)
ir.NodAt(xpos, ir.OXDOT, l, nil) -> ir.NewSelectorExpr(xpos, ir.OXDOT, l, nil)
ir.NodAt(xpos, ir.ODOTTYPE, l, nil) -> ir.NewTypeAssertExpr(xpos, l, nil)
ir.NodAt(xpos, ir.ODOTTYPE, l, r) -> ir.NewTypeAssertExpr(xpos, l, r.(ir.Ntype))
ir.NodAt(xpos, ir.OFOR, l, r) -> ir.NewForStmt(xpos, nil, l, r, nil)
ir.NodAt(xpos, ir.OINDEX, l, r) -> ir.NewIndexExpr(xpos, l, r)
ir.NodAt(xpos, ir.OINLMARK, nil, nil) -> ir.NewInlineMarkStmt(xpos, types.BADWIDTH)
ir.NodAt(xpos, ir.OKEY, l, r) -> ir.NewKeyExpr(xpos, l, r)
ir.NodAt(xpos, ir.OLABEL, nil, nil) -> ir.NewLabelStmt(xpos, nil)
ir.NodAt(xpos, ir.OMAKECHAN, l, r) -> ir.NewMakeExpr(xpos, ir.OMAKECHAN, l, r)
ir.NodAt(xpos, ir.OMAKEMAP, l, r) -> ir.NewMakeExpr(xpos, ir.OMAKEMAP, l, r)
ir.NodAt(xpos, ir.OMAKESLICE, l, r) -> ir.NewMakeExpr(xpos, ir.OMAKESLICE, l, r)
ir.NodAt(xpos, ir.OMAKESLICECOPY, l, r) -> ir.NewMakeExpr(xpos, ir.OMAKESLICECOPY, l, r)
ir.NodAt(xpos, ir.ONIL, nil, nil) -> ir.NewNilExpr(xpos)
ir.NodAt(xpos, ir.OPACK, nil, nil) -> ir.NewPkgName(xpos, nil, nil)
ir.NodAt(xpos, ir.OPAREN, l, nil) -> ir.NewParenExpr(xpos, l)
ir.NodAt(xpos, ir.ORANGE, nil, r) -> ir.NewRangeStmt(xpos, nil, r, nil)
ir.NodAt(xpos, ir.ORESULT, nil, nil) -> ir.NewResultExpr(xpos, nil, types.BADWIDTH)
ir.NodAt(xpos, ir.ORETURN, nil, nil) -> ir.NewReturnStmt(xpos, nil)
ir.NodAt(xpos, ir.OSELECT, nil, nil) -> ir.NewSelectStmt(xpos, nil)
ir.NodAt(xpos, ir.OSEND, l, r) -> ir.NewSendStmt(xpos, l, r)
ir.NodAt(xpos, ir.OSLICE, l, nil) -> ir.NewSliceExpr(xpos, ir.OSLICE, l)
ir.NodAt(xpos, ir.OSLICEARR, l, nil) -> ir.NewSliceExpr(xpos, ir.OSLICEARR, l)
ir.NodAt(xpos, ir.OSLICESTR, l, nil) -> ir.NewSliceExpr(xpos, ir.OSLICESTR, l)
ir.NodAt(xpos, ir.OSLICE3, l, nil) -> ir.NewSliceExpr(xpos, ir.OSLICE3, l)
ir.NodAt(xpos, ir.OSLICE3ARR, l, nil) -> ir.NewSliceExpr(xpos, ir.OSLICE3ARR, l)
ir.NodAt(xpos, ir.OSLICEHEADER, l, nil) -> ir.NewSliceHeaderExpr(xpos, nil, l, nil, nil)
ir.NodAt(xpos, ir.OSWITCH, l, nil) -> ir.NewSwitchStmt(xpos, l, nil)
ir.NodAt(xpos, ir.OINLCALL, nil, nil) -> ir.NewInlinedCallExpr(xpos, nil, nil)
}
rm noder.nod noder.nodSym nodSym nodlSym ir.NodAt ir.Nod
'
Change-Id: Ibf1eb708de8463ae74ccc47d7966cc263a18295e
Reviewed-on: https://go-review.googlesource.com/c/go/+/277933
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2020-12-22 23:55:29 -05:00
|
|
|
dispatch(ir.NewBinaryExpr(base.Pos, ir.OEQ, chosen, nodintconst(int64(i))), cas)
|
2020-07-27 16:19:15 -07:00
|
|
|
}
|
|
|
|
|
2017-10-22 17:18:51 +01:00
|
|
|
return init
|
2015-02-13 14:40:36 -05:00
|
|
|
}
|
|
|
|
|
runtime: eliminate runtime.hselect
Now the registration phase looks like:
var cases [4]runtime.scases
var order [8]uint16
selectsend(&cases[0], c1, &v1)
selectrecv(&cases[1], c2, &v2, nil)
selectrecv(&cases[2], c3, &v3, &ok)
selectdefault(&cases[3])
chosen := selectgo(&cases[0], &order[0], 4)
Primarily, this is just preparation for having the compiler open-code
selectsend, selectrecv, and selectdefault.
As a minor benefit, order can now be layed out separately on the stack
in the pointer-free segment, so it won't take up space in the
function's stack pointer maps.
Change-Id: I5552ba594201efd31fcb40084da20b42ea569a45
Reviewed-on: https://go-review.googlesource.com/37933
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
2017-03-07 13:44:53 -08:00
|
|
|
// bytePtrToIndex returns a Node representing "(*byte)(&n[i])".
|
[dev.regabi] cmd/compile: replace *Node type with an interface Node [generated]
The plan is to introduce a Node interface that replaces the old *Node pointer-to-struct.
The previous CL defined an interface INode modeling a *Node.
This CL:
- Changes all references outside internal/ir to use INode,
along with many references inside internal/ir as well.
- Renames Node to node.
- Renames INode to Node
So now ir.Node is an interface implemented by *ir.node, which is otherwise inaccessible,
and the code outside package ir is now (clearly) using only the interface.
The usual rule is never to redefine an existing name with a new meaning,
so that old code that hasn't been updated gets a "unknown name" error
instead of more mysterious errors or silent misbehavior. That rule would
caution against replacing Node-the-struct with Node-the-interface,
as in this CL, because code that says *Node would now be using a pointer
to an interface. But this CL is being landed at the same time as another that
moves Node from gc to ir. So the net effect is to replace *gc.Node with ir.Node,
which does follow the rule: any lingering references to gc.Node will be told
it's gone, not silently start using pointers to interfaces. So the rule is followed
by the CL sequence, just not this specific CL.
Overall, the loss of inlining caused by using interfaces cuts the compiler speed
by about 6%, a not insignificant amount. However, as we convert the representation
to concrete structs that are not the giant Node over the next weeks, that speed
should come back as more of the compiler starts operating directly on concrete types
and the memory taken up by the graph of Nodes drops due to the more precise
structs. Honestly, I was expecting worse.
% benchstat bench.old bench.new
name old time/op new time/op delta
Template 168ms ± 4% 182ms ± 2% +8.34% (p=0.000 n=9+9)
Unicode 72.2ms ±10% 82.5ms ± 6% +14.38% (p=0.000 n=9+9)
GoTypes 563ms ± 8% 598ms ± 2% +6.14% (p=0.006 n=9+9)
Compiler 2.89s ± 4% 3.04s ± 2% +5.37% (p=0.000 n=10+9)
SSA 6.45s ± 4% 7.25s ± 5% +12.41% (p=0.000 n=9+10)
Flate 105ms ± 2% 115ms ± 1% +9.66% (p=0.000 n=10+8)
GoParser 144ms ±10% 152ms ± 2% +5.79% (p=0.011 n=9+8)
Reflect 345ms ± 9% 370ms ± 4% +7.28% (p=0.001 n=10+9)
Tar 149ms ± 9% 161ms ± 5% +8.05% (p=0.001 n=10+9)
XML 190ms ± 3% 209ms ± 2% +9.54% (p=0.000 n=9+8)
LinkCompiler 327ms ± 2% 325ms ± 2% ~ (p=0.382 n=8+8)
ExternalLinkCompiler 1.77s ± 4% 1.73s ± 6% ~ (p=0.113 n=9+10)
LinkWithoutDebugCompiler 214ms ± 4% 211ms ± 2% ~ (p=0.360 n=10+8)
StdCmd 14.8s ± 3% 15.9s ± 1% +6.98% (p=0.000 n=10+9)
[Geo mean] 480ms 510ms +6.31%
name old user-time/op new user-time/op delta
Template 223ms ± 3% 237ms ± 3% +6.16% (p=0.000 n=9+10)
Unicode 103ms ± 6% 113ms ± 3% +9.53% (p=0.000 n=9+9)
GoTypes 758ms ± 8% 800ms ± 2% +5.55% (p=0.003 n=10+9)
Compiler 3.95s ± 2% 4.12s ± 2% +4.34% (p=0.000 n=10+9)
SSA 9.43s ± 1% 9.74s ± 4% +3.25% (p=0.000 n=8+10)
Flate 132ms ± 2% 141ms ± 2% +6.89% (p=0.000 n=9+9)
GoParser 177ms ± 9% 183ms ± 4% ~ (p=0.050 n=9+9)
Reflect 467ms ±10% 495ms ± 7% +6.17% (p=0.029 n=10+10)
Tar 183ms ± 9% 197ms ± 5% +7.92% (p=0.001 n=10+10)
XML 249ms ± 5% 268ms ± 4% +7.82% (p=0.000 n=10+9)
LinkCompiler 544ms ± 5% 544ms ± 6% ~ (p=0.863 n=9+9)
ExternalLinkCompiler 1.79s ± 4% 1.75s ± 6% ~ (p=0.075 n=10+10)
LinkWithoutDebugCompiler 248ms ± 6% 246ms ± 2% ~ (p=0.965 n=10+8)
[Geo mean] 483ms 504ms +4.41%
[git-generate]
cd src/cmd/compile/internal/ir
: # We need to do the conversion in multiple steps, so we introduce
: # a temporary type alias that will start out meaning the pointer-to-struct
: # and then change to mean the interface.
rf '
mv Node OldNode
add node.go \
type Node = *OldNode
'
: # It should work to do this ex in ir, but it misses test files, due to a bug in rf.
: # Run the command in gc to handle gc's tests, and then again in ssa for ssa's tests.
cd ../gc
rf '
ex . ../arm ../riscv64 ../arm64 ../mips64 ../ppc64 ../mips ../wasm {
import "cmd/compile/internal/ir"
*ir.OldNode -> ir.Node
}
'
cd ../ssa
rf '
ex {
import "cmd/compile/internal/ir"
*ir.OldNode -> ir.Node
}
'
: # Back in ir, finish conversion clumsily with sed,
: # because type checking and circular aliases do not mix.
cd ../ir
sed -i '' '
/type Node = \*OldNode/d
s/\*OldNode/Node/g
s/^func (n Node)/func (n *OldNode)/
s/OldNode/node/g
s/type INode interface/type Node interface/
s/var _ INode = (Node)(nil)/var _ Node = (*node)(nil)/
' *.go
gofmt -w *.go
sed -i '' '
s/{Func{}, 136, 248}/{Func{}, 152, 280}/
s/{Name{}, 32, 56}/{Name{}, 44, 80}/
s/{Param{}, 24, 48}/{Param{}, 44, 88}/
s/{node{}, 76, 128}/{node{}, 88, 152}/
' sizeof_test.go
cd ../ssa
sed -i '' '
s/{LocalSlot{}, 28, 40}/{LocalSlot{}, 32, 48}/
' sizeof_test.go
cd ../gc
sed -i '' 's/\*ir.Node/ir.Node/' mkbuiltin.go
cd ../../../..
go install std cmd
cd cmd/compile
go test -u || go test -u
Change-Id: I196bbe3b648e4701662e4a2bada40bf155e2a553
Reviewed-on: https://go-review.googlesource.com/c/go/+/272935
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2020-11-25 01:11:56 -05:00
|
|
|
func bytePtrToIndex(n ir.Node, i int64) ir.Node {
|
[dev.regabi] cmd/compile: remove ir.Nod [generated]
Rewrite all uses of ir.Nod and friends to call the IR constructors directly.
This gives the results a more specific type and will play nicely with
introduction of more specific types throughout the code in a followup CL.
Passes buildall w/ toolstash -cmp.
[git-generate]
cd src/cmd/compile/internal/gc
rf '
ex . ../ir {
import "cmd/compile/internal/ir"
import "cmd/compile/internal/types"
import "cmd/compile/internal/syntax"
import "cmd/internal/src"
var p *noder
var orig syntax.Node
var op ir.Op
var l, r ir.Node
var sym *types.Sym
p.nod(orig, op, l, r) -> ir.NodAt(p.pos(orig), op, l, r)
p.nodSym(orig, op, l, sym) -> nodlSym(p.pos(orig), op, l, sym)
var xpos src.XPos
var ns ir.Nodes
npos(xpos, nodSym(op, l, sym)) -> nodlSym(xpos, op, l, sym)
npos(xpos, liststmt(ns)) -> ir.NewBlockStmt(xpos, ns)
}
ex . ../ir {
import "cmd/compile/internal/base"
import "cmd/compile/internal/ir"
import "cmd/compile/internal/types"
var op ir.Op
var l, r ir.Node
ir.Nod(op, l, r) -> ir.NodAt(base.Pos, op, l, r)
var sym *types.Sym
nodSym(op, l, sym) -> nodlSym(base.Pos, op, l, sym)
}
ex . ../ir {
import "cmd/compile/internal/ir"
import "cmd/internal/src"
# rf overlapping match handling is not quite good enough
# for certain nested rewrites, so handle these two - which often contain other ir.NodAt calls - early.
var l, r ir.Node
var xpos src.XPos
ir.NodAt(xpos, ir.OAS, l, r) -> ir.NewAssignStmt(xpos, l, r)
ir.NodAt(xpos, ir.OIF, l, nil) -> ir.NewIfStmt(xpos, l, nil, nil)
}
ex . ../ir {
import "cmd/compile/internal/ir"
import "cmd/compile/internal/types"
import "cmd/internal/src"
var l, r ir.Node
var sym *types.Sym
var xpos src.XPos
nodlSym(xpos, ir.ODOT, l, sym) -> ir.NewSelectorExpr(xpos, ir.ODOT, l, sym)
nodlSym(xpos, ir.OXDOT, l, sym) -> ir.NewSelectorExpr(xpos, ir.OXDOT, l, sym)
nodlSym(xpos, ir.ODOTPTR, l, sym) -> ir.NewSelectorExpr(xpos, ir.ODOTPTR, l, sym)
nodlSym(xpos, ir.OGOTO, nil, sym) -> ir.NewBranchStmt(xpos, ir.OGOTO, sym)
nodlSym(xpos, ir.ORETJMP, nil, sym) -> ir.NewBranchStmt(xpos, ir.ORETJMP, sym)
nodlSym(xpos, ir.OLABEL, nil, sym) -> ir.NewLabelStmt(xpos, sym)
nodlSym(xpos, ir.OSTRUCTKEY, l, sym) -> ir.NewStructKeyExpr(xpos, sym, l)
ir.NodAt(xpos, ir.OADD, l, r) -> ir.NewBinaryExpr(xpos, ir.OADD, l, r)
ir.NodAt(xpos, ir.OAND, l, r) -> ir.NewBinaryExpr(xpos, ir.OAND, l, r)
ir.NodAt(xpos, ir.OANDNOT, l, r) -> ir.NewBinaryExpr(xpos, ir.OANDNOT, l, r)
ir.NodAt(xpos, ir.ODIV, l, r) -> ir.NewBinaryExpr(xpos, ir.ODIV, l, r)
ir.NodAt(xpos, ir.OEQ, l, r) -> ir.NewBinaryExpr(xpos, ir.OEQ, l, r)
ir.NodAt(xpos, ir.OGE, l, r) -> ir.NewBinaryExpr(xpos, ir.OGE, l, r)
ir.NodAt(xpos, ir.OGT, l, r) -> ir.NewBinaryExpr(xpos, ir.OGT, l, r)
ir.NodAt(xpos, ir.OLE, l, r) -> ir.NewBinaryExpr(xpos, ir.OLE, l, r)
ir.NodAt(xpos, ir.OLSH, l, r) -> ir.NewBinaryExpr(xpos, ir.OLSH, l, r)
ir.NodAt(xpos, ir.OLT, l, r) -> ir.NewBinaryExpr(xpos, ir.OLT, l, r)
ir.NodAt(xpos, ir.OMOD, l, r) -> ir.NewBinaryExpr(xpos, ir.OMOD, l, r)
ir.NodAt(xpos, ir.OMUL, l, r) -> ir.NewBinaryExpr(xpos, ir.OMUL, l, r)
ir.NodAt(xpos, ir.ONE, l, r) -> ir.NewBinaryExpr(xpos, ir.ONE, l, r)
ir.NodAt(xpos, ir.OOR, l, r) -> ir.NewBinaryExpr(xpos, ir.OOR, l, r)
ir.NodAt(xpos, ir.ORSH, l, r) -> ir.NewBinaryExpr(xpos, ir.ORSH, l, r)
ir.NodAt(xpos, ir.OSUB, l, r) -> ir.NewBinaryExpr(xpos, ir.OSUB, l, r)
ir.NodAt(xpos, ir.OXOR, l, r) -> ir.NewBinaryExpr(xpos, ir.OXOR, l, r)
ir.NodAt(xpos, ir.OCOPY, l, r) -> ir.NewBinaryExpr(xpos, ir.OCOPY, l, r)
ir.NodAt(xpos, ir.OCOMPLEX, l, r) -> ir.NewBinaryExpr(xpos, ir.OCOMPLEX, l, r)
ir.NodAt(xpos, ir.OEFACE, l, r) -> ir.NewBinaryExpr(xpos, ir.OEFACE, l, r)
ir.NodAt(xpos, ir.OADDR, l, nil) -> ir.NewAddrExpr(xpos, l)
ir.NodAt(xpos, ir.OADDSTR, nil, nil) -> ir.NewAddStringExpr(xpos, nil)
ir.NodAt(xpos, ir.OANDAND, l, r) -> ir.NewLogicalExpr(xpos, ir.OANDAND, l, r)
ir.NodAt(xpos, ir.OOROR, l, r) -> ir.NewLogicalExpr(xpos, ir.OOROR, l, r)
ir.NodAt(xpos, ir.OARRAYLIT, nil, nil) -> ir.NewCompLitExpr(xpos, ir.OARRAYLIT, nil, nil)
ir.NodAt(xpos, ir.OCOMPLIT, nil, nil) -> ir.NewCompLitExpr(xpos, ir.OCOMPLIT, nil, nil)
ir.NodAt(xpos, ir.OMAPLIT, nil, nil) -> ir.NewCompLitExpr(xpos, ir.OMAPLIT, nil, nil)
ir.NodAt(xpos, ir.OSTRUCTLIT, nil, nil) -> ir.NewCompLitExpr(xpos, ir.OSTRUCTLIT, nil, nil)
ir.NodAt(xpos, ir.OSLICELIT, nil, nil) -> ir.NewCompLitExpr(xpos, ir.OSLICELIT, nil, nil)
ir.NodAt(xpos, ir.OARRAYLIT, nil, r) -> ir.NewCompLitExpr(xpos, ir.OARRAYLIT, r.(ir.Ntype), nil)
ir.NodAt(xpos, ir.OCOMPLIT, nil, r) -> ir.NewCompLitExpr(xpos, ir.OCOMPLIT, r.(ir.Ntype), nil)
ir.NodAt(xpos, ir.OMAPLIT, nil, r) -> ir.NewCompLitExpr(xpos, ir.OMAPLIT, r.(ir.Ntype), nil)
ir.NodAt(xpos, ir.OSTRUCTLIT, nil, r) -> ir.NewCompLitExpr(xpos, ir.OSTRUCTLIT, r.(ir.Ntype), nil)
ir.NodAt(xpos, ir.OSLICELIT, nil, r) -> ir.NewCompLitExpr(xpos, ir.OSLICELIT, r.(ir.Ntype), nil)
ir.NodAt(xpos, ir.OAS2, nil, nil) -> ir.NewAssignListStmt(xpos, ir.OAS2, nil, nil)
ir.NodAt(xpos, ir.OAS2DOTTYPE, nil, nil) -> ir.NewAssignListStmt(xpos, ir.OAS2DOTTYPE, nil, nil)
ir.NodAt(xpos, ir.OAS2FUNC, nil, nil) -> ir.NewAssignListStmt(xpos, ir.OAS2FUNC, nil, nil)
ir.NodAt(xpos, ir.OAS2MAPR, nil, nil) -> ir.NewAssignListStmt(xpos, ir.OAS2MAPR, nil, nil)
ir.NodAt(xpos, ir.OAS2RECV, nil, nil) -> ir.NewAssignListStmt(xpos, ir.OAS2RECV, nil, nil)
ir.NodAt(xpos, ir.OSELRECV2, nil, nil) -> ir.NewAssignListStmt(xpos, ir.OSELRECV2, nil, nil)
ir.NodAt(xpos, ir.OASOP, l, r) -> ir.NewAssignOpStmt(xpos, ir.OXXX, l, r)
ir.NodAt(xpos, ir.OBITNOT, l, nil) -> ir.NewUnaryExpr(xpos, ir.OBITNOT, l)
ir.NodAt(xpos, ir.ONEG, l, nil) -> ir.NewUnaryExpr(xpos, ir.ONEG, l)
ir.NodAt(xpos, ir.ONOT, l, nil) -> ir.NewUnaryExpr(xpos, ir.ONOT, l)
ir.NodAt(xpos, ir.OPLUS, l, nil) -> ir.NewUnaryExpr(xpos, ir.OPLUS, l)
ir.NodAt(xpos, ir.ORECV, l, nil) -> ir.NewUnaryExpr(xpos, ir.ORECV, l)
ir.NodAt(xpos, ir.OALIGNOF, l, nil) -> ir.NewUnaryExpr(xpos, ir.OALIGNOF, l)
ir.NodAt(xpos, ir.OCAP, l, nil) -> ir.NewUnaryExpr(xpos, ir.OCAP, l)
ir.NodAt(xpos, ir.OCLOSE, l, nil) -> ir.NewUnaryExpr(xpos, ir.OCLOSE, l)
ir.NodAt(xpos, ir.OIMAG, l, nil) -> ir.NewUnaryExpr(xpos, ir.OIMAG, l)
ir.NodAt(xpos, ir.OLEN, l, nil) -> ir.NewUnaryExpr(xpos, ir.OLEN, l)
ir.NodAt(xpos, ir.ONEW, l, nil) -> ir.NewUnaryExpr(xpos, ir.ONEW, l)
ir.NodAt(xpos, ir.ONEWOBJ, l, nil) -> ir.NewUnaryExpr(xpos, ir.ONEWOBJ, l)
ir.NodAt(xpos, ir.OOFFSETOF, l, nil) -> ir.NewUnaryExpr(xpos, ir.OOFFSETOF, l)
ir.NodAt(xpos, ir.OPANIC, l, nil) -> ir.NewUnaryExpr(xpos, ir.OPANIC, l)
ir.NodAt(xpos, ir.OREAL, l, nil) -> ir.NewUnaryExpr(xpos, ir.OREAL, l)
ir.NodAt(xpos, ir.OSIZEOF, l, nil) -> ir.NewUnaryExpr(xpos, ir.OSIZEOF, l)
ir.NodAt(xpos, ir.OCHECKNIL, l, nil) -> ir.NewUnaryExpr(xpos, ir.OCHECKNIL, l)
ir.NodAt(xpos, ir.OCFUNC, l, nil) -> ir.NewUnaryExpr(xpos, ir.OCFUNC, l)
ir.NodAt(xpos, ir.OIDATA, l, nil) -> ir.NewUnaryExpr(xpos, ir.OIDATA, l)
ir.NodAt(xpos, ir.OITAB, l, nil) -> ir.NewUnaryExpr(xpos, ir.OITAB, l)
ir.NodAt(xpos, ir.OSPTR, l, nil) -> ir.NewUnaryExpr(xpos, ir.OSPTR, l)
ir.NodAt(xpos, ir.OVARDEF, l, nil) -> ir.NewUnaryExpr(xpos, ir.OVARDEF, l)
ir.NodAt(xpos, ir.OVARKILL, l, nil) -> ir.NewUnaryExpr(xpos, ir.OVARKILL, l)
ir.NodAt(xpos, ir.OVARLIVE, l, nil) -> ir.NewUnaryExpr(xpos, ir.OVARLIVE, l)
ir.NodAt(xpos, ir.OBLOCK, nil, nil) -> ir.NewBlockStmt(xpos, nil)
ir.NodAt(xpos, ir.OBREAK, nil, nil) -> ir.NewBranchStmt(xpos, ir.OBREAK, nil)
ir.NodAt(xpos, ir.OCONTINUE, nil, nil) -> ir.NewBranchStmt(xpos, ir.OCONTINUE, nil)
ir.NodAt(xpos, ir.OFALL, nil, nil) -> ir.NewBranchStmt(xpos, ir.OFALL, nil)
ir.NodAt(xpos, ir.OGOTO, nil, nil) -> ir.NewBranchStmt(xpos, ir.OGOTO, nil)
ir.NodAt(xpos, ir.ORETJMP, nil, nil) -> ir.NewBranchStmt(xpos, ir.ORETJMP, nil)
ir.NodAt(xpos, ir.OCALL, l, nil) -> ir.NewCallExpr(xpos, ir.OCALL, l, nil)
ir.NodAt(xpos, ir.OCALLFUNC, l, nil) -> ir.NewCallExpr(xpos, ir.OCALLFUNC, l, nil)
ir.NodAt(xpos, ir.OCALLINTER, l, nil) -> ir.NewCallExpr(xpos, ir.OCALLINTER, l, nil)
ir.NodAt(xpos, ir.OCALLMETH, l, nil) -> ir.NewCallExpr(xpos, ir.OCALLMETH, l, nil)
ir.NodAt(xpos, ir.OAPPEND, l, nil) -> ir.NewCallExpr(xpos, ir.OAPPEND, l, nil)
ir.NodAt(xpos, ir.ODELETE, l, nil) -> ir.NewCallExpr(xpos, ir.ODELETE, l, nil)
ir.NodAt(xpos, ir.OGETG, l, nil) -> ir.NewCallExpr(xpos, ir.OGETG, l, nil)
ir.NodAt(xpos, ir.OMAKE, l, nil) -> ir.NewCallExpr(xpos, ir.OMAKE, l, nil)
ir.NodAt(xpos, ir.OPRINT, l, nil) -> ir.NewCallExpr(xpos, ir.OPRINT, l, nil)
ir.NodAt(xpos, ir.OPRINTN, l, nil) -> ir.NewCallExpr(xpos, ir.OPRINTN, l, nil)
ir.NodAt(xpos, ir.ORECOVER, l, nil) -> ir.NewCallExpr(xpos, ir.ORECOVER, l, nil)
ir.NodAt(xpos, ir.OCASE, nil, nil) -> ir.NewCaseStmt(xpos, nil, nil)
ir.NodAt(xpos, ir.OCONV, l, nil) -> ir.NewConvExpr(xpos, ir.OCONV, nil, l)
ir.NodAt(xpos, ir.OCONVIFACE, l, nil) -> ir.NewConvExpr(xpos, ir.OCONVIFACE, nil, l)
ir.NodAt(xpos, ir.OCONVNOP, l, nil) -> ir.NewConvExpr(xpos, ir.OCONVNOP, nil, l)
ir.NodAt(xpos, ir.ORUNESTR, l, nil) -> ir.NewConvExpr(xpos, ir.ORUNESTR, nil, l)
ir.NodAt(xpos, ir.ODCL, l, nil) -> ir.NewDecl(xpos, ir.ODCL, l)
ir.NodAt(xpos, ir.ODCLCONST, l, nil) -> ir.NewDecl(xpos, ir.ODCLCONST, l)
ir.NodAt(xpos, ir.ODCLTYPE, l, nil) -> ir.NewDecl(xpos, ir.ODCLTYPE, l)
ir.NodAt(xpos, ir.ODCLFUNC, nil, nil) -> ir.NewFunc(xpos)
ir.NodAt(xpos, ir.ODEFER, l, nil) -> ir.NewGoDeferStmt(xpos, ir.ODEFER, l)
ir.NodAt(xpos, ir.OGO, l, nil) -> ir.NewGoDeferStmt(xpos, ir.OGO, l)
ir.NodAt(xpos, ir.ODEREF, l, nil) -> ir.NewStarExpr(xpos, l)
ir.NodAt(xpos, ir.ODOT, l, nil) -> ir.NewSelectorExpr(xpos, ir.ODOT, l, nil)
ir.NodAt(xpos, ir.ODOTPTR, l, nil) -> ir.NewSelectorExpr(xpos, ir.ODOTPTR, l, nil)
ir.NodAt(xpos, ir.ODOTMETH, l, nil) -> ir.NewSelectorExpr(xpos, ir.ODOTMETH, l, nil)
ir.NodAt(xpos, ir.ODOTINTER, l, nil) -> ir.NewSelectorExpr(xpos, ir.ODOTINTER, l, nil)
ir.NodAt(xpos, ir.OXDOT, l, nil) -> ir.NewSelectorExpr(xpos, ir.OXDOT, l, nil)
ir.NodAt(xpos, ir.ODOTTYPE, l, nil) -> ir.NewTypeAssertExpr(xpos, l, nil)
ir.NodAt(xpos, ir.ODOTTYPE, l, r) -> ir.NewTypeAssertExpr(xpos, l, r.(ir.Ntype))
ir.NodAt(xpos, ir.OFOR, l, r) -> ir.NewForStmt(xpos, nil, l, r, nil)
ir.NodAt(xpos, ir.OINDEX, l, r) -> ir.NewIndexExpr(xpos, l, r)
ir.NodAt(xpos, ir.OINLMARK, nil, nil) -> ir.NewInlineMarkStmt(xpos, types.BADWIDTH)
ir.NodAt(xpos, ir.OKEY, l, r) -> ir.NewKeyExpr(xpos, l, r)
ir.NodAt(xpos, ir.OLABEL, nil, nil) -> ir.NewLabelStmt(xpos, nil)
ir.NodAt(xpos, ir.OMAKECHAN, l, r) -> ir.NewMakeExpr(xpos, ir.OMAKECHAN, l, r)
ir.NodAt(xpos, ir.OMAKEMAP, l, r) -> ir.NewMakeExpr(xpos, ir.OMAKEMAP, l, r)
ir.NodAt(xpos, ir.OMAKESLICE, l, r) -> ir.NewMakeExpr(xpos, ir.OMAKESLICE, l, r)
ir.NodAt(xpos, ir.OMAKESLICECOPY, l, r) -> ir.NewMakeExpr(xpos, ir.OMAKESLICECOPY, l, r)
ir.NodAt(xpos, ir.ONIL, nil, nil) -> ir.NewNilExpr(xpos)
ir.NodAt(xpos, ir.OPACK, nil, nil) -> ir.NewPkgName(xpos, nil, nil)
ir.NodAt(xpos, ir.OPAREN, l, nil) -> ir.NewParenExpr(xpos, l)
ir.NodAt(xpos, ir.ORANGE, nil, r) -> ir.NewRangeStmt(xpos, nil, r, nil)
ir.NodAt(xpos, ir.ORESULT, nil, nil) -> ir.NewResultExpr(xpos, nil, types.BADWIDTH)
ir.NodAt(xpos, ir.ORETURN, nil, nil) -> ir.NewReturnStmt(xpos, nil)
ir.NodAt(xpos, ir.OSELECT, nil, nil) -> ir.NewSelectStmt(xpos, nil)
ir.NodAt(xpos, ir.OSEND, l, r) -> ir.NewSendStmt(xpos, l, r)
ir.NodAt(xpos, ir.OSLICE, l, nil) -> ir.NewSliceExpr(xpos, ir.OSLICE, l)
ir.NodAt(xpos, ir.OSLICEARR, l, nil) -> ir.NewSliceExpr(xpos, ir.OSLICEARR, l)
ir.NodAt(xpos, ir.OSLICESTR, l, nil) -> ir.NewSliceExpr(xpos, ir.OSLICESTR, l)
ir.NodAt(xpos, ir.OSLICE3, l, nil) -> ir.NewSliceExpr(xpos, ir.OSLICE3, l)
ir.NodAt(xpos, ir.OSLICE3ARR, l, nil) -> ir.NewSliceExpr(xpos, ir.OSLICE3ARR, l)
ir.NodAt(xpos, ir.OSLICEHEADER, l, nil) -> ir.NewSliceHeaderExpr(xpos, nil, l, nil, nil)
ir.NodAt(xpos, ir.OSWITCH, l, nil) -> ir.NewSwitchStmt(xpos, l, nil)
ir.NodAt(xpos, ir.OINLCALL, nil, nil) -> ir.NewInlinedCallExpr(xpos, nil, nil)
}
rm noder.nod noder.nodSym nodSym nodlSym ir.NodAt ir.Nod
'
Change-Id: Ibf1eb708de8463ae74ccc47d7966cc263a18295e
Reviewed-on: https://go-review.googlesource.com/c/go/+/277933
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2020-12-22 23:55:29 -05:00
|
|
|
s := nodAddr(ir.NewIndexExpr(base.Pos, n, nodintconst(i)))
|
[dev.regabi] cmd/compile: introduce cmd/compile/internal/ir [generated]
If we want to break up package gc at all, we will need to move
the compiler IR it defines into a separate package that can be
imported by packages that gc itself imports. This CL does that.
It also removes the TINT8 etc aliases so that all code is clear
about which package things are coming from.
This CL is automatically generated by the script below.
See the comments in the script for details about the changes.
[git-generate]
cd src/cmd/compile/internal/gc
rf '
# These names were never fully qualified
# when the types package was added.
# Do it now, to avoid confusion about where they live.
inline -rm \
Txxx \
TINT8 \
TUINT8 \
TINT16 \
TUINT16 \
TINT32 \
TUINT32 \
TINT64 \
TUINT64 \
TINT \
TUINT \
TUINTPTR \
TCOMPLEX64 \
TCOMPLEX128 \
TFLOAT32 \
TFLOAT64 \
TBOOL \
TPTR \
TFUNC \
TSLICE \
TARRAY \
TSTRUCT \
TCHAN \
TMAP \
TINTER \
TFORW \
TANY \
TSTRING \
TUNSAFEPTR \
TIDEAL \
TNIL \
TBLANK \
TFUNCARGS \
TCHANARGS \
NTYPE \
BADWIDTH
# esc.go and escape.go do not need to be split.
# Append esc.go onto the end of escape.go.
mv esc.go escape.go
# Pull out the type format installation from func Main,
# so it can be carried into package ir.
mv Main:/Sconv.=/-0,/TypeLinkSym/-1 InstallTypeFormats
# Names that need to be exported for use by code left in gc.
mv Isconst IsConst
mv asNode AsNode
mv asNodes AsNodes
mv asTypesNode AsTypesNode
mv basicnames BasicTypeNames
mv builtinpkg BuiltinPkg
mv consttype ConstType
mv dumplist DumpList
mv fdumplist FDumpList
mv fmtMode FmtMode
mv goopnames OpNames
mv inspect Inspect
mv inspectList InspectList
mv localpkg LocalPkg
mv nblank BlankNode
mv numImport NumImport
mv opprec OpPrec
mv origSym OrigSym
mv stmtwithinit StmtWithInit
mv dump DumpAny
mv fdump FDumpAny
mv nod Nod
mv nodl NodAt
mv newname NewName
mv newnamel NewNameAt
mv assertRepresents AssertValidTypeForConst
mv represents ValidTypeForConst
mv nodlit NewLiteral
# Types and fields that need to be exported for use by gc.
mv nowritebarrierrecCallSym SymAndPos
mv SymAndPos.lineno SymAndPos.Pos
mv SymAndPos.target SymAndPos.Sym
mv Func.lsym Func.LSym
mv Func.setWBPos Func.SetWBPos
mv Func.numReturns Func.NumReturns
mv Func.numDefers Func.NumDefers
mv Func.nwbrCalls Func.NWBRCalls
# initLSym is an algorithm left behind in gc,
# not an operation on Func itself.
mv Func.initLSym initLSym
mv nodeQueue NodeQueue
mv NodeQueue.empty NodeQueue.Empty
mv NodeQueue.popLeft NodeQueue.PopLeft
mv NodeQueue.pushRight NodeQueue.PushRight
# Many methods on Node are actually algorithms that
# would apply to any node implementation.
# Those become plain functions.
mv Node.funcname FuncName
mv Node.isBlank IsBlank
mv Node.isGoConst isGoConst
mv Node.isNil IsNil
mv Node.isParamHeapCopy isParamHeapCopy
mv Node.isParamStackCopy isParamStackCopy
mv Node.isSimpleName isSimpleName
mv Node.mayBeShared MayBeShared
mv Node.pkgFuncName PkgFuncName
mv Node.backingArrayPtrLen backingArrayPtrLen
mv Node.isterminating isTermNode
mv Node.labeledControl labeledControl
mv Nodes.isterminating isTermNodes
mv Nodes.sigerr fmtSignature
mv Node.MethodName methodExprName
mv Node.MethodFunc methodExprFunc
mv Node.IsMethod IsMethod
# Every node will need to implement RawCopy;
# Copy and SepCopy algorithms will use it.
mv Node.rawcopy Node.RawCopy
mv Node.copy Copy
mv Node.sepcopy SepCopy
# Extract Node.Format method body into func FmtNode,
# but leave method wrapper behind.
mv Node.Format:0,$ FmtNode
# Formatting helpers that will apply to all node implementations.
mv Node.Line Line
mv Node.exprfmt exprFmt
mv Node.jconv jconvFmt
mv Node.modeString modeString
mv Node.nconv nconvFmt
mv Node.nodedump nodeDumpFmt
mv Node.nodefmt nodeFmt
mv Node.stmtfmt stmtFmt
# Constant support needed for code moving to ir.
mv okforconst OKForConst
mv vconv FmtConst
mv int64Val Int64Val
mv float64Val Float64Val
mv Node.ValueInterface ConstValue
# Organize code into files.
mv LocalPkg BuiltinPkg ir.go
mv NumImport InstallTypeFormats Line fmt.go
mv syntax.go Nod NodAt NewNameAt Class Pxxx PragmaFlag Nointerface SymAndPos \
AsNode AsTypesNode BlankNode OrigSym \
Node.SliceBounds Node.SetSliceBounds Op.IsSlice3 \
IsConst Node.Int64Val Node.CanInt64 Node.Uint64Val Node.BoolVal Node.StringVal \
Node.RawCopy SepCopy Copy \
IsNil IsBlank IsMethod \
Node.Typ Node.StorageClass node.go
mv ConstType ConstValue Int64Val Float64Val AssertValidTypeForConst ValidTypeForConst NewLiteral idealType OKForConst val.go
# Move files to new ir package.
mv bitset.go class_string.go dump.go fmt.go \
ir.go node.go op_string.go val.go \
sizeof_test.go cmd/compile/internal/ir
'
: # fix mkbuiltin.go to generate the changes made to builtin.go during rf
sed -i '' '
s/\[T/[types.T/g
s/\*Node/*ir.Node/g
/internal\/types/c \
fmt.Fprintln(&b, `import (`) \
fmt.Fprintln(&b, ` "cmd/compile/internal/ir"`) \
fmt.Fprintln(&b, ` "cmd/compile/internal/types"`) \
fmt.Fprintln(&b, `)`)
' mkbuiltin.go
gofmt -w mkbuiltin.go
: # update cmd/dist to add internal/ir
cd ../../../dist
sed -i '' '/compile.internal.gc/a\
"cmd/compile/internal/ir",
' buildtool.go
gofmt -w buildtool.go
: # update cmd/compile TestFormats
cd ../..
go install std cmd
cd cmd/compile
go test -u || go test # first one updates but fails; second passes
Change-Id: I5f7caf6b20629b51970279e81231a3574d5b51db
Reviewed-on: https://go-review.googlesource.com/c/go/+/273008
Trust: Russ Cox <rsc@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2020-11-19 21:09:22 -05:00
|
|
|
t := types.NewPtr(types.Types[types.TUINT8])
|
2018-05-10 13:25:39 +02:00
|
|
|
return convnop(s, t)
|
runtime: eliminate runtime.hselect
Now the registration phase looks like:
var cases [4]runtime.scases
var order [8]uint16
selectsend(&cases[0], c1, &v1)
selectrecv(&cases[1], c2, &v2, nil)
selectrecv(&cases[2], c3, &v3, &ok)
selectdefault(&cases[3])
chosen := selectgo(&cases[0], &order[0], 4)
Primarily, this is just preparation for having the compiler open-code
selectsend, selectrecv, and selectdefault.
As a minor benefit, order can now be layed out separately on the stack
in the pointer-free segment, so it won't take up space in the
function's stack pointer maps.
Change-Id: I5552ba594201efd31fcb40084da20b42ea569a45
Reviewed-on: https://go-review.googlesource.com/37933
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
2017-03-07 13:44:53 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
var scase *types.Type
|
|
|
|
|
2016-03-17 04:58:34 -07:00
|
|
|
// Keep in sync with src/runtime/select.go.
|
runtime: eliminate runtime.hselect
Now the registration phase looks like:
var cases [4]runtime.scases
var order [8]uint16
selectsend(&cases[0], c1, &v1)
selectrecv(&cases[1], c2, &v2, nil)
selectrecv(&cases[2], c3, &v3, &ok)
selectdefault(&cases[3])
chosen := selectgo(&cases[0], &order[0], 4)
Primarily, this is just preparation for having the compiler open-code
selectsend, selectrecv, and selectdefault.
As a minor benefit, order can now be layed out separately on the stack
in the pointer-free segment, so it won't take up space in the
function's stack pointer maps.
Change-Id: I5552ba594201efd31fcb40084da20b42ea569a45
Reviewed-on: https://go-review.googlesource.com/37933
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
2017-03-07 13:44:53 -08:00
|
|
|
func scasetype() *types.Type {
|
|
|
|
if scase == nil {
|
2020-11-26 07:02:13 -05:00
|
|
|
scase = tostruct([]*ir.Field{
|
[dev.regabi] cmd/compile: introduce cmd/compile/internal/ir [generated]
If we want to break up package gc at all, we will need to move
the compiler IR it defines into a separate package that can be
imported by packages that gc itself imports. This CL does that.
It also removes the TINT8 etc aliases so that all code is clear
about which package things are coming from.
This CL is automatically generated by the script below.
See the comments in the script for details about the changes.
[git-generate]
cd src/cmd/compile/internal/gc
rf '
# These names were never fully qualified
# when the types package was added.
# Do it now, to avoid confusion about where they live.
inline -rm \
Txxx \
TINT8 \
TUINT8 \
TINT16 \
TUINT16 \
TINT32 \
TUINT32 \
TINT64 \
TUINT64 \
TINT \
TUINT \
TUINTPTR \
TCOMPLEX64 \
TCOMPLEX128 \
TFLOAT32 \
TFLOAT64 \
TBOOL \
TPTR \
TFUNC \
TSLICE \
TARRAY \
TSTRUCT \
TCHAN \
TMAP \
TINTER \
TFORW \
TANY \
TSTRING \
TUNSAFEPTR \
TIDEAL \
TNIL \
TBLANK \
TFUNCARGS \
TCHANARGS \
NTYPE \
BADWIDTH
# esc.go and escape.go do not need to be split.
# Append esc.go onto the end of escape.go.
mv esc.go escape.go
# Pull out the type format installation from func Main,
# so it can be carried into package ir.
mv Main:/Sconv.=/-0,/TypeLinkSym/-1 InstallTypeFormats
# Names that need to be exported for use by code left in gc.
mv Isconst IsConst
mv asNode AsNode
mv asNodes AsNodes
mv asTypesNode AsTypesNode
mv basicnames BasicTypeNames
mv builtinpkg BuiltinPkg
mv consttype ConstType
mv dumplist DumpList
mv fdumplist FDumpList
mv fmtMode FmtMode
mv goopnames OpNames
mv inspect Inspect
mv inspectList InspectList
mv localpkg LocalPkg
mv nblank BlankNode
mv numImport NumImport
mv opprec OpPrec
mv origSym OrigSym
mv stmtwithinit StmtWithInit
mv dump DumpAny
mv fdump FDumpAny
mv nod Nod
mv nodl NodAt
mv newname NewName
mv newnamel NewNameAt
mv assertRepresents AssertValidTypeForConst
mv represents ValidTypeForConst
mv nodlit NewLiteral
# Types and fields that need to be exported for use by gc.
mv nowritebarrierrecCallSym SymAndPos
mv SymAndPos.lineno SymAndPos.Pos
mv SymAndPos.target SymAndPos.Sym
mv Func.lsym Func.LSym
mv Func.setWBPos Func.SetWBPos
mv Func.numReturns Func.NumReturns
mv Func.numDefers Func.NumDefers
mv Func.nwbrCalls Func.NWBRCalls
# initLSym is an algorithm left behind in gc,
# not an operation on Func itself.
mv Func.initLSym initLSym
mv nodeQueue NodeQueue
mv NodeQueue.empty NodeQueue.Empty
mv NodeQueue.popLeft NodeQueue.PopLeft
mv NodeQueue.pushRight NodeQueue.PushRight
# Many methods on Node are actually algorithms that
# would apply to any node implementation.
# Those become plain functions.
mv Node.funcname FuncName
mv Node.isBlank IsBlank
mv Node.isGoConst isGoConst
mv Node.isNil IsNil
mv Node.isParamHeapCopy isParamHeapCopy
mv Node.isParamStackCopy isParamStackCopy
mv Node.isSimpleName isSimpleName
mv Node.mayBeShared MayBeShared
mv Node.pkgFuncName PkgFuncName
mv Node.backingArrayPtrLen backingArrayPtrLen
mv Node.isterminating isTermNode
mv Node.labeledControl labeledControl
mv Nodes.isterminating isTermNodes
mv Nodes.sigerr fmtSignature
mv Node.MethodName methodExprName
mv Node.MethodFunc methodExprFunc
mv Node.IsMethod IsMethod
# Every node will need to implement RawCopy;
# Copy and SepCopy algorithms will use it.
mv Node.rawcopy Node.RawCopy
mv Node.copy Copy
mv Node.sepcopy SepCopy
# Extract Node.Format method body into func FmtNode,
# but leave method wrapper behind.
mv Node.Format:0,$ FmtNode
# Formatting helpers that will apply to all node implementations.
mv Node.Line Line
mv Node.exprfmt exprFmt
mv Node.jconv jconvFmt
mv Node.modeString modeString
mv Node.nconv nconvFmt
mv Node.nodedump nodeDumpFmt
mv Node.nodefmt nodeFmt
mv Node.stmtfmt stmtFmt
# Constant support needed for code moving to ir.
mv okforconst OKForConst
mv vconv FmtConst
mv int64Val Int64Val
mv float64Val Float64Val
mv Node.ValueInterface ConstValue
# Organize code into files.
mv LocalPkg BuiltinPkg ir.go
mv NumImport InstallTypeFormats Line fmt.go
mv syntax.go Nod NodAt NewNameAt Class Pxxx PragmaFlag Nointerface SymAndPos \
AsNode AsTypesNode BlankNode OrigSym \
Node.SliceBounds Node.SetSliceBounds Op.IsSlice3 \
IsConst Node.Int64Val Node.CanInt64 Node.Uint64Val Node.BoolVal Node.StringVal \
Node.RawCopy SepCopy Copy \
IsNil IsBlank IsMethod \
Node.Typ Node.StorageClass node.go
mv ConstType ConstValue Int64Val Float64Val AssertValidTypeForConst ValidTypeForConst NewLiteral idealType OKForConst val.go
# Move files to new ir package.
mv bitset.go class_string.go dump.go fmt.go \
ir.go node.go op_string.go val.go \
sizeof_test.go cmd/compile/internal/ir
'
: # fix mkbuiltin.go to generate the changes made to builtin.go during rf
sed -i '' '
s/\[T/[types.T/g
s/\*Node/*ir.Node/g
/internal\/types/c \
fmt.Fprintln(&b, `import (`) \
fmt.Fprintln(&b, ` "cmd/compile/internal/ir"`) \
fmt.Fprintln(&b, ` "cmd/compile/internal/types"`) \
fmt.Fprintln(&b, `)`)
' mkbuiltin.go
gofmt -w mkbuiltin.go
: # update cmd/dist to add internal/ir
cd ../../../dist
sed -i '' '/compile.internal.gc/a\
"cmd/compile/internal/ir",
' buildtool.go
gofmt -w buildtool.go
: # update cmd/compile TestFormats
cd ../..
go install std cmd
cd cmd/compile
go test -u || go test # first one updates but fails; second passes
Change-Id: I5f7caf6b20629b51970279e81231a3574d5b51db
Reviewed-on: https://go-review.googlesource.com/c/go/+/273008
Trust: Russ Cox <rsc@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2020-11-19 21:09:22 -05:00
|
|
|
namedfield("c", types.Types[types.TUNSAFEPTR]),
|
|
|
|
namedfield("elem", types.Types[types.TUNSAFEPTR]),
|
runtime: eliminate runtime.hselect
Now the registration phase looks like:
var cases [4]runtime.scases
var order [8]uint16
selectsend(&cases[0], c1, &v1)
selectrecv(&cases[1], c2, &v2, nil)
selectrecv(&cases[2], c3, &v3, &ok)
selectdefault(&cases[3])
chosen := selectgo(&cases[0], &order[0], 4)
Primarily, this is just preparation for having the compiler open-code
selectsend, selectrecv, and selectdefault.
As a minor benefit, order can now be layed out separately on the stack
in the pointer-free segment, so it won't take up space in the
function's stack pointer maps.
Change-Id: I5552ba594201efd31fcb40084da20b42ea569a45
Reviewed-on: https://go-review.googlesource.com/37933
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
2017-03-07 13:44:53 -08:00
|
|
|
})
|
|
|
|
scase.SetNoalg(true)
|
|
|
|
}
|
|
|
|
return scase
|
2015-02-13 14:40:36 -05:00
|
|
|
}
|