23 Commits

Author SHA1 Message Date
Cuong Manh Le
b89a840d65 cmd/compile: add clear(x) builtin
To clear map, and zero content of slice.

Updates #56351

Change-Id: I5f81dfbc465500f5acadaf2c6beb9b5f0d2c4045
Reviewed-on: https://go-review.googlesource.com/c/go/+/453395
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>
2023-01-31 19:43:07 +00:00
Keith Randall
8477562ce5 cmd/compile: be more careful about pointer incrementing in range loops
For range loops, we use a pointer to the backing store that gets
incremented on each iteration of the loop.

The problem with this scheme is that at the end of the last iteration,
we may briefly have a pointer that points past the end of the backing store
of the slice that is being iterated over. We cannot let the garbage collector
see that pointer.

To fix this problem, have the incremented pointer live briefly as
a uintptr instead of a normal pointer, so it doesn't keep anything
alive. Convert back to a normal pointer just after the loop condition
is checked, but before anything that requires a real pointer representation
(in practice, any call, which is what could cause a GC scan or stack copy).

Fixes #56699

Change-Id: Ia928d23f85a211565357603668bea4e5c534f989
Reviewed-on: https://go-review.googlesource.com/c/go/+/449995
Reviewed-by: David Chase <drchase@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
2022-11-15 22:52:03 +00:00
Keith Randall
a5370d038e cmd/compile: remove OFORUNTIL
Not used any more.

Fixes #53860

Change-Id: Id0b1c3ed30b576d6c5f08f064d1262de337262b3
Reviewed-on: https://go-review.googlesource.com/c/go/+/418374
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: David Chase <drchase@google.com>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-08-18 18:07:23 +00:00
Keith Randall
661146bc0b cmd/compile: don't use OFORUNTIL when implementing range loops
We don't need this special loop construct anymore now that we do
conservative GC scanning of the top of stack. Rewrite instead to a simple
pointer increment on every iteration. This leads to having a potential
past-the-end pointer at the end of the last iteration, but that value
immediately goes dead after the loop condition fails, and the past-the-end
pointer is never live across any call.

This simplifies and speeds up loops.

R=go1.20

TODO: actually delete all support for OFORUNTIL. It is now never generated,
but code to handle it (e.g. in ssagen) is still around.

TODO: in "for _, x := range" loops, we could get rid of the index
altogether and use a "pointer to the last element" reference to determine
when the loop is complete.

Fixes #53409

Change-Id: Ifc141600ff898a8bc6a75f793e575f8862679ba1
Reviewed-on: https://go-review.googlesource.com/c/go/+/414876
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
Reviewed-by: Keith Randall <khr@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-08-18 17:32:44 +00:00
Matthew Dempsky
d667be8831 [dev.unified] cmd/compile/internal/walk: RType fields for range assignments
This CL adds extra fields to RangeStmt that can be used when
desugaring into primitive assignment statements. This will allow the
frontend to wire up all of the RTTI necessary, pulling from
dictionaries as necessary.

Updates #53328.

Change-Id: Iab0e3029ff18c947782ff24f71ef20b2b5cb8305
Reviewed-on: https://go-review.googlesource.com/c/go/+/415518
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: David Chase <drchase@google.com>
2022-07-01 15:12:15 +00:00
Matthew Dempsky
0a503cf43a [dev.unified] cmd/compile: refactor range desugaring
This CL refactors the code responsible for emitting the user-visible
assignments within a range statement. This will make it easier to
propagate RTTI from the frontend into any implicit conversions.

Updates #53328.

Change-Id: Ibed15e3b4951b0a6a726067b401a630977f4c6c2
Reviewed-on: https://go-review.googlesource.com/c/go/+/415158
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-06-30 18:42:33 +00:00
Matthew Dempsky
93833cd5d8 [dev.unified] cmd/compile: extract rtype code from walk
This CL removes (almost*) all reflectdata.{TypePtr,ITabAddr} calls
from package walk. This will allow us to next start adding RType/ITab
fields to IR nodes directly, and have the helpers start returning them
when available instead.

The one survining ITabAddr call is due to ODOTTYPE{,2}, but we already
have ODYNAMICDOTTYPE{,2}, which I plan to have Unified IR always
use. (Longer term, once the Go 1.18 frontend is gone, we can get rid
of ODOTTYPE*, and rename ODYNAMICDOTTYPE*.)

Passes toolstash -cmp.

Change-Id: I5e00da06a93d069abf383d7628e692dd7fd2a1c7
Reviewed-on: https://go-review.googlesource.com/c/go/+/413356
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: David Chase <drchase@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-06-21 23:50:58 +00:00
Matthew Dempsky
fc5dad6646 [dev.unified] cmd/compile/internal/walk: minor prep refactoring
Two small refactorings that will make it easier to thread through
RType parameters later. Behavior preserving, but seemed worth
separating out.

Passes toolstash -cmp.

Change-Id: I77905775015b6582bad2b32dd7700880c415893f
Reviewed-on: https://go-review.googlesource.com/c/go/+/413354
Reviewed-by: David Chase <drchase@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-06-21 17:49:09 +00:00
Cuong Manh Le
0668e3cb1a cmd/compile: support pointers to arrays in arrayClear
Fixes #52635

Change-Id: I85f182931e30292983ef86c55a0ab6e01282395c
Reviewed-on: https://go-review.googlesource.com/c/go/+/403337
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2022-05-03 05:42:48 +00:00
Russ Cox
7d87ccc860 all: fix various doc comment formatting nits
A run of lines that are indented with any number of spaces or tabs
format as a <pre> block. This commit fixes various doc comments
that format badly according to that (standard) rule.

For example, consider:

	// - List item.
	//   Second line.
	// - Another item.

Because the - lines are unindented, this is actually two paragraphs
separated by a one-line <pre> block. This CL rewrites it to:

	//  - List item.
	//    Second line.
	//  - Another item.

Today, that will format as a single <pre> block.
In a future release, we hope to format it as a bulleted list.

Various other minor fixes as well, all in preparation for reformatting.

For #51082.

Change-Id: I95cf06040d4186830e571cd50148be3bf8daf189
Reviewed-on: https://go-review.googlesource.com/c/go/+/384257
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-04-01 18:18:01 +00:00
Matthew Dempsky
72c003ef82 cmd/compile: unexport Type.Width and Type.Align [generated]
[git-generate]
cd src/cmd/compile/internal

: Workaround rf issue with types2 tests.
rm types2/*_test.go

: Rewrite uses. First a type-safe rewrite,
: then a second pass to fix unnecessary conversions.
rf '
ex ./abi ./escape ./gc ./liveness ./noder ./reflectdata ./ssa ./ssagen ./staticinit ./typebits ./typecheck ./walk {
  import "cmd/compile/internal/types"
  var t *types.Type
  t.Width -> t.Size()
  t.Align -> uint8(t.Alignment())
}

ex ./abi ./escape ./gc ./liveness ./noder ./reflectdata ./ssa ./ssagen ./staticinit ./typebits ./typecheck ./walk {
  import "cmd/compile/internal/types"
  var t *types.Type
  int64(uint8(t.Alignment())) -> t.Alignment()
}
'

: Rename fields to lower case.
(
cd types
rf '
mv Type.Width Type.width
mv Type.Align Type.align
'
)

: Revert types2 changes.
git checkout HEAD^ types2

Change-Id: I42091faece104c4ef619d9d4d50514fd48c8f029
Reviewed-on: https://go-review.googlesource.com/c/go/+/345480
Trust: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2021-08-27 20:43:31 +00:00
cuiweixie
c4c68fb57f cmd/compile/internal/walk: delete unused statement
Change-Id: I3f118c868b13ec51b2e501424b35564929eed56d
GitHub-Last-Rev: d15ae124c582417cd10bceaef0b5c0ebbf100f7e
GitHub-Pull-Request: golang/go#45816
Reviewed-on: https://go-review.googlesource.com/c/go/+/314570
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Trust: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
2021-04-29 11:37:05 +00:00
cuiweixie
b9dfaf77f5 cmd/compile/internal/walk: merge operations
Change-Id: I018872da519dfb4aa6c252ea28fc09289c2d9711
GitHub-Last-Rev: 5969776197003cae317f6b45f88ac4ced10beaf3
GitHub-Pull-Request: golang/go#45795
Reviewed-on: https://go-review.googlesource.com/c/go/+/313550
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Keith Randall <khr@golang.org>
2021-04-27 19:40:24 +00:00
Russ Cox
95ed5c3800 internal/buildcfg: move build configuration out of cmd/internal/objabi
The go/build package needs access to this configuration,
so move it into a new package available to the standard library.

Change-Id: I868a94148b52350c76116451f4ad9191246adcff
Reviewed-on: https://go-review.googlesource.com/c/go/+/310731
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
Reviewed-by: Jay Conrod <jayconrod@google.com>
2021-04-16 19:20:53 +00:00
Makdon
e306d06063 runtime/map: update comment for gc/reflect
update comment cause gc/reflect.go has been moved to reflectdata/reflect.go

In the commit (attach below), gc/reflect.go is moved to reflectdata/reflect.go
So the  comment referring gc/reflect.go should be updated to reflectdata/reflect.go

There maybe other places that refers gc/reflect.go that should be updated.
I would work around it soon.

commit:
de65151e50
e4895ab4c0

Change-Id: Ieed5c48049ffe6889c08e164972fc7825653ac05
GitHub-Last-Rev: eec9c2328d0be40842c3994f26f26f03fa650a91
GitHub-Pull-Request: golang/go#45421
Reviewed-on: https://go-review.googlesource.com/c/go/+/307930
Reviewed-by: Keith Randall <khr@golang.org>
Trust: Emmanuel Odeke <emmanuel@orijtech.com>
2021-04-07 18:44:30 +00:00
Cuong Manh Le
19a6db6b63 [dev.regabi] cmd/compile: make sure mkcall* passed non-nil init
So next CL can pass temporaries assignments for function arguments in to
init instead of CallExpr.Rargs.

Passes toolstash -cmp.

Change-Id: I2c3cb6a63e8bf9d0418052b39c1db58050f71305
Reviewed-on: https://go-review.googlesource.com/c/go/+/284893
Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2021-01-21 06:38:18 +00:00
Dan Scales
a956a0e909 [dev.regabi] cmd/compile, runtime: fix up comments/error messages from recent renames
Went in a semi-automated way through the clearest renames of functions,
and updated comments and error messages where it made sense.

Change-Id: Ied8e152b562b705da7f52f715991a77dab60da35
Reviewed-on: https://go-review.googlesource.com/c/go/+/284216
Trust: Dan Scales <danscales@google.com>
Run-TryBot: Dan Scales <danscales@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2021-01-16 02:31:08 +00:00
Matthew Dempsky
f2538033c0 [dev.regabi] cmd/compile: remove Nodes.Set [generated]
Just "=". It's cleaner.

Passes toolstash -cmp.

[git-generate]
cd src/cmd/compile/internal/ir
pkgs=$(go list . ../...)
rf '
	ex '"$(echo $pkgs)"' {
		var l Nodes
		var p *Nodes

		p.Set(l) -> *p = l
	}

	ex '"$(echo $pkgs)"' {
		var n InitNode
		var l Nodes

		*n.PtrInit() = l -> n.SetInit(l)
	}

	rm Nodes.Set
'

Change-Id: Ic97219792243667146a02776553942ae1189ff7d
Reviewed-on: https://go-review.googlesource.com/c/go/+/281002
Trust: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
2021-01-02 10:57:25 +00:00
Matthew Dempsky
2f2d4b4e68 [dev.regabi] cmd/compile: remove {Ptr,Set}Init from Node interface
This CL separates out PtrInit and SetInit into a new InitNode
extension interface, and adds a new TakeInit helper function for
taking and clearing the Init list (if any) from a Node.

This allows removing miniNode.SetInit and miniNode.PtrInit, which in
turn allow getting rid of immutableEmptyNodes, and will allow
simplification of the Nodes API.

It would be nice to get rid of the default Init method too, but
there's way more code that expects to be able to call that at the
moment, so that'll have to wait.

Passes toolstash -cmp.

Change-Id: Ia8c18fab9555b774376f7f43eeecfde4f07b5946
Reviewed-on: https://go-review.googlesource.com/c/go/+/281001
Trust: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
2021-01-02 10:57:23 +00:00
Cuong Manh Le
e24d2f3d05 [dev.regabi] cmd/compile: remove typ from RangeStmt
We can use RangeStmt.X.Type() instead.

Passes buildall w/ toolstash -cmp.

Change-Id: Id63ce9cb046c3b39bcc35453b1602c986794dfe1
Reviewed-on: https://go-review.googlesource.com/c/go/+/279437
Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2020-12-25 05:18:05 +00:00
Cuong Manh Le
27b248b307 [dev.regabi] cmd/compile: separate range stmt Vars to Key, Value nodes
Passes buildall w/ toolstash -cmp.

Change-Id: I9738fcabc8ebf3afa34d102afadf1b474b50db35
Reviewed-on: https://go-review.googlesource.com/c/go/+/279435
Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
2020-12-24 11:15:02 +00:00
Russ Cox
3f04d964ab [dev.regabi] cmd/compile: split up walkexpr1, walkstmt [generated]
walkexpr1 is the second largest non-machine-generated function in the compiler.
weighing in at 1,164 lines. Since we are destroying the git blame history
anyway, now is a good time to split each different case into its own function,
making future work on this function more manageable.
Do the same to walkstmt too for consistency, even though it is a paltry 259 lines.

[git-generate]
cd src/cmd/compile/internal/walk
rf '
	mv addstr walkAddString
	mv walkCall walkCall1
	mv walkpartialcall walkCallPart
	mv walkclosure walkClosure
	mv walkrange walkRange
	mv walkselect walkSelect
	mv walkselectcases walkSelectCases
	mv walkswitch walkSwitch
	mv walkExprSwitch walkSwitchExpr
	mv walkTypeSwitch walkSwitchType
	mv walkstmt walkStmt
	mv walkstmtlist walkStmtList
	mv walkexprlist walkExprList
	mv walkexprlistsafe walkExprListSafe
	mv walkexprlistcheap walkExprListCheap
	mv walkexpr walkExpr
	mv walkexpr1 walkExpr1
	mv walkprint walkPrint
	mv walkappend walkAppend
	mv walkcompare walkCompare
	mv walkcompareInterface walkCompareInterface
	mv walkcompareString walkCompareString

	mv appendslice appendSlice
	mv cheapexpr cheapExpr
	mv copyany walkCopy
	mv copyexpr copyExpr
	mv eqfor eqFor
	mv extendslice extendSlice
	mv finishcompare finishCompare
	mv safeexpr safeExpr

	mv walkStmt:/^\tcase ir.ORECV:/+2,/^\tcase /-2 walkRecv
	add walk.go:/^func walkRecv/-0 \
		// walkRecv walks an ORECV node.
	mv walkStmt:/^\tcase ir.ODCL:/+2,/^\tcase /-2 walkDecl
	add walk.go:/^func walkDecl/-0 \
		// walkDecl walks an ODCL node.
	mv walkStmt:/^\tcase ir.OGO:/+2,/^\tcase /-2 walkGoDefer
	add walk.go:/^func walkGoDefer/-0 \
		// walkGoDefer walks an OGO or ODEFER node.
	mv walkStmt:/^\tcase ir.OFOR,/+2,/^\tcase /-2 walkFor
	add walk.go:/^func walkFor/-0 \
		// walkFor walks an OFOR or OFORUNTIL node.
	mv walkStmt:/^\tcase ir.OIF:/+2,/^\tcase /-2 walkIf
	add walk.go:/^func walkIf/-0 \
		// walkIf walks an OIF node.
	mv walkStmt:/^\tcase ir.ORETURN:/+2,/^\tcase /-2 walkReturn
	add walk.go:/^func walkReturn/-0 \
		// walkReturn walks an ORETURN node.

	mv walkExpr1:/^\tcase ir.ODOT,/+2,/^\tcase /-2 walkDot
	add walk.go:/^func walkDot/-0 \
		// walkDot walks an ODOT or ODOTPTR node.
	mv walkExpr1:/^\tcase ir.ODOTTYPE,/+2,/^\tcase /-2 walkDotType
	add walk.go:/^func walkDotType/-0 \
		// walkDotType walks an ODOTTYPE or ODOTTYPE2 node.
	mv walkExpr1:/^\tcase ir.OLEN,/+2,/^\tcase /-2 walkLenCap
	add walk.go:/^func walkLenCap/-0 \
		// walkLenCap walks an OLEN or OCAP node.
	mv walkExpr1:/^\tcase ir.OANDAND,/+2,/^\tcase /-2 walkLogical
	add walk.go:/^func walkLogical/-0 \
		// walkLogical walks an OANDAND or OOROR node.
	mv walkExpr1:/^\tcase ir.OCALLINTER,/+2,/^\tcase /-2 walkCall
	add walk.go:/^func walkCall/-0 \
		// walkCall walks an OCALLFUNC, OCALLINTER, or OCALLMETH node.
	mv walkExpr1:/^\tcase ir.OAS,/+1,/^\tcase /-2 walkAssign
	add walk.go:/^func walkAssign/-0 \
		// walkAssign walks an OAS (AssignExpr) or OASOP (AssignOpExpr) node.
	mv walkExpr1:/^\tcase ir.OAS2:/+2,/^\tcase /-3 walkAssignList
	add walk.go:/^func walkAssignList/-0 \
		// walkAssignList walks an OAS2 node.
	mv walkExpr1:/^\tcase ir.OAS2FUNC:/+2,/^\tcase /-4 walkAssignFunc
	add walk.go:/^func walkAssignFunc/-0 \
		// walkAssignFunc walks an OAS2FUNC node.
	mv walkExpr1:/^\tcase ir.OAS2RECV:/+2,/^\tcase /-3 walkAssignRecv
	add walk.go:/^func walkAssignRecv/-0 \
		// walkAssignRecv walks an OAS2RECV node.
	mv walkExpr1:/^\tcase ir.OAS2MAPR:/+2,/^\tcase /-2 walkAssignMapRead
	add walk.go:/^func walkAssignMapRead/-0 \
		// walkAssignMapRead walks an OAS2MAPR node.
	mv walkExpr1:/^\tcase ir.ODELETE:/+2,/^\tcase /-2 walkDelete
	add walk.go:/^func walkDelete/-0 \
		// walkDelete walks an ODELETE node.
	mv walkExpr1:/^\tcase ir.OAS2DOTTYPE:/+2,/^\tcase /-2 walkAssignDotType
	add walk.go:/^func walkAssignDotType/-0 \
		// walkAssignDotType walks an OAS2DOTTYPE node.
	mv walkExpr1:/^\tcase ir.OCONVIFACE:/+2,/^\tcase /-2 walkConvInterface
	add walk.go:/^func walkConvInterface/-0 \
		// walkConvInterface walks an OCONVIFACE node.
	mv walkExpr1:/^\tcase ir.OCONV,/+2,/^\tcase /-2 walkConv
	add walk.go:/^func walkConv/-0 \
		// walkConv walks an OCONV or OCONVNOP (but not OCONVIFACE) node.
	mv walkExpr1:/^\tcase ir.ODIV,/+2,/^\tcase /-2 walkDivMod
	add walk.go:/^func walkDivMod/-0 \
		// walkDivMod walks an ODIV or OMOD node.
	mv walkExpr1:/^\tcase ir.OINDEX:/+2,/^\tcase /-2 walkIndex
	add walk.go:/^func walkIndex/-0 \
		// walkIndex walks an OINDEX node.
	# move type assertion above comment
	mv walkExpr1:/^\tcase ir.OINDEXMAP:/+/n := n/-+ walkExpr1:/^\tcase ir.OINDEXMAP:/+0
	mv walkExpr1:/^\tcase ir.OINDEXMAP:/+2,/^\tcase /-2 walkIndexMap
	add walk.go:/^func walkIndexMap/-0 \
		// walkIndexMap walks an OINDEXMAP node.
	mv walkExpr1:/^\tcase ir.OSLICEHEADER:/+2,/^\tcase /-2 walkSliceHeader
	add walk.go:/^func walkSliceHeader/-0 \
		// walkSliceHeader walks an OSLICEHEADER node.
	mv walkExpr1:/^\tcase ir.OSLICE,/+2,/^\tcase /-2 walkSlice
	add walk.go:/^func walkSlice/-0 \
		// walkSlice walks an OSLICE, OSLICEARR, OSLICESTR, OSLICE3, or OSLICE3ARR node.
	mv walkExpr1:/^\tcase ir.ONEW:/+2,/^\tcase /-2 walkNew
	add walk.go:/^func walkNew/-0 \
		// walkNew walks an ONEW node.
	# move type assertion above comment
	mv walkExpr1:/^\tcase ir.OCLOSE:/+/n := n/-+ walkExpr1:/^\tcase ir.OCLOSE:/+0
	mv walkExpr1:/^\tcase ir.OCLOSE:/+2,/^\tcase /-2 walkClose
	add walk.go:/^func walkClose/-0 \
		// walkClose walks an OCLOSE node.
	# move type assertion above comment
	mv walkExpr1:/^\tcase ir.OMAKECHAN:/+/n := n/-+ walkExpr1:/^\tcase ir.OMAKECHAN:/+0
	mv walkExpr1:/^\tcase ir.OMAKECHAN:/+2,/^\tcase /-2 walkMakeChan
	add walk.go:/^func walkMakeChan/-0 \
		// walkMakeChan walks an OMAKECHAN node.
	mv walkExpr1:/^\tcase ir.OMAKEMAP:/+2,/^\tcase /-2 walkMakeMap
	add walk.go:/^func walkMakeMap/-0 \
		// walkMakeMap walks an OMAKEMAP node.
	mv walkExpr1:/^\tcase ir.OMAKESLICE:/+2,/^\tcase /-2 walkMakeSlice
	add walk.go:/^func walkMakeSlice/-0 \
		// walkMakeSlice walks an OMAKESLICE node.
	mv walkExpr1:/^\tcase ir.OMAKESLICECOPY:/+2,/^\tcase /-2 walkMakeSliceCopy
	add walk.go:/^func walkMakeSliceCopy/-0 \
		// walkMakeSliceCopy walks an OMAKESLICECOPY node.
	mv walkExpr1:/^\tcase ir.ORUNESTR:/+2,/^\tcase /-2 walkRuneToString
	add walk.go:/^func walkRuneToString/-0 \
		// walkRuneToString walks an ORUNESTR node.
	mv walkExpr1:/^\tcase ir.OBYTES2STR,/+2,/^\tcase /-2 walkBytesRunesToString
	add walk.go:/^func walkBytesRunesToString/-0 \
		// walkBytesRunesToString walks an OBYTES2STR or ORUNES2STR node.
	mv walkExpr1:/^\tcase ir.OBYTES2STRTMP:/+2,/^\tcase /-2 walkBytesToStringTemp
	add walk.go:/^func walkBytesToStringTemp/-0 \
		// walkBytesToStringTemp walks an OBYTES2STRTMP node.
	mv walkExpr1:/^\tcase ir.OSTR2BYTES:/+2,/^\tcase /-2 walkStringToBytes
	add walk.go:/^func walkStringToBytes/-0 \
		// walkStringToBytes walks an OSTR2BYTES node.
	# move type assertion above comment
	mv walkExpr1:/^\tcase ir.OSTR2BYTESTMP:/+/n := n/-+ walkExpr1:/^\tcase ir.OSTR2BYTESTMP:/+0
	mv walkExpr1:/^\tcase ir.OSTR2BYTESTMP:/+2,/^\tcase /-2 walkStringToBytesTemp
	add walk.go:/^func walkStringToBytesTemp/-0 \
		// walkStringToBytesTemp walks an OSTR2BYTESTMP node.
	mv walkExpr1:/^\tcase ir.OSTR2RUNES:/+2,/^\tcase /-2 walkStringToRunes
	add walk.go:/^func walkStringToRunes/-0 \
		// walkStringToRunes walks an OSTR2RUNES node.
	mv walkExpr1:/^\tcase ir.OARRAYLIT,/+1,/^\tcase /-2 walkCompLit
	add walk.go:/^func walkCompLit/-0 \
		// walkCompLit walks a composite literal node: \
		// OARRAYLIT, OSLICELIT, OMAPLIT, OSTRUCTLIT (all CompLitExpr), or OPTRLIT (AddrExpr).
	mv walkExpr1:/^\tcase ir.OSEND:/+2,/^\tcase /-2 walkSend
	add walk.go:/^func walkSend/-0 \
		// walkSend walks an OSEND node.

	mv walkStmt walkStmtList \
		walkDecl \
		walkFor \
		walkGoDefer \
		walkIf \
		wrapCall \
		stmt.go

	mv walkExpr walkExpr1 walkExprList walkExprListCheap walkExprListSafe \
		cheapExpr safeExpr copyExpr \
		walkAddString \
		walkCall \
		walkCall1 \
		walkDivMod \
		walkDot \
		walkDotType \
		walkIndex \
		walkIndexMap \
		walkLogical \
		walkSend \
		walkSlice \
		walkSliceHeader \
		reduceSlice \
		bounded \
		usemethod \
		usefield \
		expr.go

	mv \
		walkAssign \
		walkAssignDotType \
		walkAssignFunc \
		walkAssignList \
		walkAssignMapRead \
		walkAssignRecv \
		walkReturn \
		fncall \
		ascompatee \
		ascompatee1 \
		ascompatet \
		reorder3 \
		reorder3save \
		aliased \
		anyAddrTaken \
		refersToName \
		refersToCommonName \
		appendSlice \
		isAppendOfMake \
		extendSlice \
		assign.go

	mv \
		walkCompare \
		walkCompareInterface \
		walkCompareString \
		finishCompare \
		eqFor \
		brcom \
		brrev \
		tracecmpArg \
		canMergeLoads \
		compare.go

	mv \
		walkConv \
		walkConvInterface \
		walkBytesRunesToString \
		walkBytesToStringTemp \
		walkRuneToString \
		walkStringToBytes \
		walkStringToBytesTemp \
		walkStringToRunes \
		convFuncName \
		rtconvfn \
		byteindex \
		walkCheckPtrAlignment \
		walkCheckPtrArithmetic \
		convert.go

	mv \
		walkAppend \
		walkClose \
		walkCopy \
		walkDelete \
		walkLenCap \
		walkMakeChan \
		walkMakeMap \
		walkMakeSlice \
		walkMakeSliceCopy \
		walkNew \
		walkPrint \
		badtype \
		callnew \
		writebarrierfn \
		isRuneCount \
		builtin.go

	mv \
		walkCompLit \
		sinit.go \
		complit.go

	mv subr.go walk.go
'

Change-Id: Ie0cf3ba4adf363c120c134d57cb7ef37934eaab9
Reviewed-on: https://go-review.googlesource.com/c/go/+/279430
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2020-12-23 06:39:50 +00:00
Russ Cox
e4895ab4c0 [dev.regabi] cmd/compile: split out package walk [generated]
[git-generate]
cd src/cmd/compile/internal/gc
rf '
	# Late addition to package ir.
	mv closuredebugruntimecheck ClosureDebugRuntimeCheck
	mv hasemptycvars IsTrivialClosure
	mv ClosureDebugRuntimeCheck IsTrivialClosure func.go
	mv func.go cmd/compile/internal/ir

	# Late addition to package reflectdata.
	mv markTypeUsedInInterface MarkTypeUsedInInterface
	mv markUsedIfaceMethod MarkUsedIfaceMethod
	mv MarkTypeUsedInInterface MarkUsedIfaceMethod reflect.go
	mv reflect.go cmd/compile/internal/reflectdata

	# Late addition to package staticdata.
	mv litsym InitConst
	mv InitConst data.go
	mv data.go cmd/compile/internal/staticdata

	# Extract staticinit out of walk into its own package.
	mv InitEntry InitPlan InitSchedule InitSchedule.append InitSchedule.staticInit \
		InitSchedule.tryStaticInit InitSchedule.staticcopy \
		InitSchedule.staticassign InitSchedule.initplan InitSchedule.addvalue \
		statuniqgen staticname stataddr anySideEffects getlit isvaluelit \
		sched.go
	mv InitSchedule.initplans InitSchedule.Plans
	mv InitSchedule.inittemps InitSchedule.Temps
	mv InitSchedule.out InitSchedule.Out
	mv InitSchedule.staticInit InitSchedule.StaticInit
	mv InitSchedule.staticassign InitSchedule.StaticAssign
	mv InitSchedule Schedule
	mv InitPlan Plan
	mv InitEntry Entry
	mv anySideEffects AnySideEffects
	mv staticname StaticName
	mv stataddr StaticLoc
	mv sched.go cmd/compile/internal/staticinit

	# Export API and unexport non-API.
	mv transformclosure Closure
	mv walk Walk

	mv Order orderState

	mv swt.go switch.go
	mv racewalk.go race.go

	mv closure.go order.go range.go select.go switch.go race.go \
		sinit.go subr.go walk.go \
		cmd/compile/internal/walk
'

: # Update format test.
cd ../../
go install cmd/compile/... cmd/internal/archive
go test -u || go test -u
rm -rf ../../../pkg/darwin_amd64/cmd

Change-Id: I11c7a45f74d4a9e963da15c080e1018caaa99c05
Reviewed-on: https://go-review.googlesource.com/c/go/+/279478
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2020-12-23 06:39:43 +00:00