Age | Commit message (Collapse) | Author |
|
This moves the package types setup code from package typecheck into
package types itself. This is a prereq for making types.Type more
opaque, because some unit tests depend on being able to init the basic
universal types.
A few notable details of this CL:
1. Creating the builtin types requires being able to create the
ir.Name/ir.OTYPE that represents it, but package types can't depend on
package ir. So we add a callback function to handle creating the
ir.Name.
2. This CL moves ir.Pkgs.Unsafe to types.UnsafePkg. Package unsafe is
part of the language, not like the other ir.Pkgs packages that are
purely implementation details.
3. This CL also moves typecheck.FakeRecv to types.FakeRecv, addressing
an outstanding TODO.
Change-Id: I64de04ce82fbcd1bb59f547e2eea3cda52d89429
Reviewed-on: https://go-review.googlesource.com/c/go/+/345474
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>
|
|
Currently, for hidden closures, we always push them to compile queue
during typechecking. If the hidden closure is discarded from the outer
function body during deadcode, any desugaring phase after deadcode won't
be applied to the closure. Thus, some un-expected OPs are passed to
downstream passes, which they can't handle, the compiler goes boom!
To fix this, we keep track of discarded hidden closures during deadcode
pass, and won't compile them then.
Fixes #47712
Change-Id: I078717d5d1f4f2fa39cbaf610cfffbb042e70ceb
Reviewed-on: https://go-review.googlesource.com/c/go/+/342350
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>
|
|
Previously, softfloat mode does not work with register ABI, mainly
because the compiler doesn't know how to pass floating point
arguments and results. According to the ABI it should be passed in
FP registers, but there isn't any in softfloat mode.
This CL makes it work. When softfloat is used, we define the ABI
as having 0 floating point registers (because there aren't any).
The integer registers are unchanged. So floating point arguments
and results are passed in memory.
Another option is to pass (the bit representation of) floating
point values in integer registers. But this complicates things
because it'd need to reorder integer argument registers.
Change-Id: Ibecbeccb658c10a868fa7f2dcf75138f719cc809
Reviewed-on: https://go-review.googlesource.com/c/go/+/327274
Trust: Cherry Mui <cherryyz@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
|
|
This CL changes unified IR to incrementally typecheck the IR as it's
constructed. This is significant, because it means reader can now use
typecheck.Expr to typecheck sub-expressions when it's needed. This
should be helpful for construction and insertion of dictionaries.
This CL does introduce two quirks outside of unified IR itself,
which simplify preserving binary output:
1. Top-level declarations are sorted after they're constructed, to
avoid worrying about the order that closures are added.
2. Zero-padding autotmp_N variable names. Interleaving typechecking
means autotmp variables are sometimes named differently (since their
naming depends on the number of variables declared so far), and this
ensures that code that sorts variables by names doesn't suddenly sort
autotmp_8/autotmp_9 differently than it would have sorted
autotmp_9/autotmp_10.
While at it, this CL also updated reader to use ir.WithFunc instead of
manually setting and restoring ir.CurFunc. There's now only one
remaining direct use of ir.CurFunc.
Change-Id: I6233b4c059596e471c53166f94750917d710462f
Reviewed-on: https://go-review.googlesource.com/c/go/+/332469
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>
|
|
This CL extends unified IR to handle creating wrapper methods. There's
relatively little about this code that's actually specific to unified
IR, but rewriting this logic allows a few benefits:
1. It decouples unified IR from reflectdata.methodWrapper, so the
latter code can evolve freely for -G=3's needs. This will also allow
the new code to evolve to unified IR's wrapper needs, which I
anticipate will operate slightly differently.
2. It provided an opportunity to revisit a lot of the code and
simplify/update it to current style. E.g., in the process, I
discovered #46903, which unified IR now gets correctly. (I have not
yet attempted to fix reflectdata.methodWrapper.)
3. It gives a convenient way for unified IR to ensure all of the
wrapper methods it needs are generated correctly.
For now, the wrapper generation is specific to non-quirks mode.
Change-Id: I5798de6b141f29e8eb6a5c563e7049627ff2868a
Reviewed-on: https://go-review.googlesource.com/c/go/+/330569
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>
|
|
This CL implements a few improvements to SSA devirtualization to make
it simpler and more general:
1. Change reflectdata.ITabAddr to now immediately generate the wrapper
functions and write out the itab symbol data. Previously, these were
each handled by separate phases later on.
2. Removes the hack in typecheck where we marked itabs that we
expected to need later. Instead, the calls to ITabAddr in walk now
handle generating the wrappers.
3. Changes the SSA interface call devirtualization algorithm to just
use the itab symbol data (namely, its relocations) to figure out what
pointer is available in memory at the given offset. This decouples it
somewhat from reflectdata.
Change-Id: I8fe06922af8f8a1e7c93f5aff2b60ff59b8e7114
Reviewed-on: https://go-review.googlesource.com/c/go/+/327871
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
|
|
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>
|
|
Softfloat mode with register ABI is not implemented yet. In
particular, we did not rewrite the float types in AuxCalls to
integer types, so arguments are still passed in floating point
registers, which do not exist in softfloat mode. To make it work
I think we may want to reorder softfloat pass with expand_calls
pass. We also need to rewrite the OpArgFloatRegs for the spilling
of non-SSA-able arguments, which may involve renumbering interger
arguments. Maybe in softfloat mode we want to just define the
ABI with 0 float registers. They are not fundamentally hard, but
may be not worth doing for the moment, as we don't use softfloat
mode on AMD64 anyway.
Run the test with noregabiargs. Also in the compiler reject
-d=softfloat if regabiargs is enabled.
Change-Id: I8cc0c2cfa88a138bc1338ed8710670245f1bd2cd
Reviewed-on: https://go-review.googlesource.com/c/go/+/308710
Trust: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
|
|
This CL restructures how we track function ABIs and generate ABI
wrappers in the compiler and adds import/export of ABIs across package
boundaries.
Currently, we start by tracking definition and referencing ABIs in two
global maps and eventually move some of this information into the
LSyms for functions. This complicates a lot of the existing code for
handling wrappers and makes it particularly hard to export ABI
information across packages. This change is built around instead
recording this information on the ir.Func.
First, this change replaces the global ABI def/ref maps with a type,
which makes the data flow and lifetime of this information clear in
gc.Main. These are populated during flag parsing.
Then, early in the front-end, we loop over all ir.Funcs to 1. attach
ABI def/ref information to the ir.Funcs and 2. create new ir.Funcs for
ABI wrappers. Step 1 is slightly subtle because the information is
keyed by linker symbol names, so we can't simply look things up in the
compiler's regular symbol table.
By generating ABI wrappers early in the front-end, we decouple this
step from LSym creation, which makes LSym creation much simpler (like
it was before ABI wrappers). In particular, LSyms for wrappers are now
created at the same time as all other functions instead of by
makeABIWrapper, which means we're back to the simpler, old situation
where InitLSym was the only thing responsible for constructing
function LSyms. Hence, we can restore the check that InitLSym is
called exactly once per function.
Attaching the ABI information to the ir.Func has several follow-on
benefits:
1. It's now easy to include in the export info. This enables direct
cross-package cross-ABI calls, which are important for the performance
of calling various hot assembly functions (e.g., internal/bytealg.*).
This was really the point of this whole change.
2. Since all Funcs, including wrappers, now record their definition
ABI, callTargetLSym no longer needs to distinguish wrappers from
non-wrappers, so it's now nearly trivial (it would be completely
trivial except that it has to work around a handful of cases where
ir.Name.Func is nil).
The simplification of callTargetLSym has one desirable but potentially
surprising side-effect: the compiler will now generate direct calls to
the definition ABI even when ABI wrappers are turned off. This is
almost completely unnoticeable except that cmd/internal/obj/wasm looks
for the call from runtime.deferreturn (defined in Go) to
runtime.jmpdefer (defined in assembly) to compile is specially. That
now looks like a direct call to ABI0 rather than going through the
ABIInternal alias.
While we're in here, we also set up the structures to support more
than just ABI0 and ABIInternal and add various additional consistency
checks all around.
Performance-wise, this reduces the overhead induced by wrappers from
1.24% geomean (on Sweet) to 0.52% geomean, and reduces the number of
benchmarks impacts >2% from 5 to 3. It has no impact on compiler speed.
Impact of wrappers before this change:
name old time/op new time/op delta
BiogoIgor 15.8s ± 2% 15.8s ± 1% ~ (p=0.863 n=25+25)
BiogoKrishna 18.3s ± 6% 18.1s ± 7% -1.39% (p=0.015 n=25+25)
BleveIndexBatch100 5.88s ± 3% 6.04s ± 6% +2.72% (p=0.000 n=25+25)
BleveQuery 6.42s ± 1% 6.76s ± 1% +5.31% (p=0.000 n=24+24)
CompileTemplate 245ms ± 3% 250ms ± 6% ~ (p=0.068 n=22+25)
CompileUnicode 93.6ms ± 2% 93.9ms ± 5% ~ (p=0.958 n=22+25)
CompileGoTypes 1.60s ± 2% 1.59s ± 2% ~ (p=0.115 n=24+24)
CompileCompiler 104ms ± 4% 104ms ± 3% ~ (p=0.453 n=22+25)
CompileSSA 11.0s ± 2% 11.0s ± 1% ~ (p=0.789 n=24+25)
CompileFlate 153ms ± 2% 153ms ± 1% ~ (p=0.055 n=21+20)
CompileGoParser 229ms ± 2% 230ms ± 2% ~ (p=0.305 n=21+22)
CompileReflect 585ms ± 5% 582ms ± 3% ~ (p=0.365 n=25+25)
CompileTar 211ms ± 1% 211ms ± 3% ~ (p=0.592 n=20+22)
CompileXML 282ms ± 3% 281ms ± 2% ~ (p=0.937 n=22+23)
CompileStdCmd 13.7s ± 3% 13.6s ± 2% ~ (p=0.700 n=25+25)
FoglemanFauxGLRenderRotateBoat 8.67s ± 1% 8.78s ± 1% +1.30% (p=0.000 n=25+25)
FoglemanPathTraceRenderGopherIter1 20.5s ± 2% 20.9s ± 2% +1.85% (p=0.000 n=25+25)
GopherLuaKNucleotide 30.1s ± 2% 31.1s ± 2% +3.38% (p=0.000 n=25+25)
MarkdownRenderXHTML 246ms ± 5% 250ms ± 1% +1.42% (p=0.002 n=25+23)
Tile38WithinCircle100kmRequest 828µs ± 6% 885µs ± 6% +6.85% (p=0.000 n=23+25)
Tile38IntersectsCircle100kmRequest 1.04ms ± 5% 1.10ms ± 7% +5.63% (p=0.000 n=25+25)
Tile38KNearestLimit100Request 974µs ± 4% 972µs ± 4% ~ (p=0.356 n=25+24)
[Geo mean] 588ms 595ms +1.24%
(https://perf.golang.org/search?q=upload:20210328.5)
And after this change:
name old time/op new time/op delta
BiogoIgor 15.9s ± 1% 15.8s ± 1% -0.48% (p=0.008 n=22+25)
BiogoKrishna 18.4s ± 6% 17.8s ± 6% -3.55% (p=0.008 n=25+25)
BleveIndexBatch100 5.86s ± 3% 5.97s ± 4% +1.88% (p=0.001 n=25+25)
BleveQuery 6.42s ± 1% 6.75s ± 1% +5.14% (p=0.000 n=25+25)
CompileTemplate 246ms ± 5% 245ms ± 2% ~ (p=0.472 n=23+23)
CompileUnicode 93.7ms ± 3% 93.5ms ± 2% ~ (p=0.813 n=22+23)
CompileGoTypes 1.60s ± 2% 1.60s ± 2% ~ (p=0.108 n=25+23)
CompileCompiler 104ms ± 3% 104ms ± 2% ~ (p=0.845 n=23+23)
CompileSSA 11.0s ± 2% 11.0s ± 2% ~ (p=0.525 n=25+25)
CompileFlate 152ms ± 1% 153ms ± 2% ~ (p=0.408 n=22+22)
CompileGoParser 230ms ± 1% 230ms ± 1% ~ (p=0.363 n=21+23)
CompileReflect 582ms ± 3% 584ms ± 4% ~ (p=0.658 n=25+25)
CompileTar 212ms ± 2% 211ms ± 2% ~ (p=0.315 n=23+24)
CompileXML 282ms ± 1% 282ms ± 1% ~ (p=0.991 n=23+22)
CompileStdCmd 13.6s ± 2% 13.6s ± 2% ~ (p=0.699 n=25+24)
FoglemanFauxGLRenderRotateBoat 8.66s ± 1% 8.69s ± 1% +0.28% (p=0.002 n=25+24)
FoglemanPathTraceRenderGopherIter1 20.5s ± 3% 20.5s ± 2% ~ (p=0.407 n=25+25)
GopherLuaKNucleotide 30.1s ± 2% 31.2s ± 2% +3.82% (p=0.000 n=25+25)
MarkdownRenderXHTML 246ms ± 3% 245ms ± 1% ~ (p=0.478 n=23+22)
Tile38WithinCircle100kmRequest 820µs ± 4% 856µs ± 5% +4.39% (p=0.000 n=24+25)
Tile38IntersectsCircle100kmRequest 1.05ms ± 6% 1.07ms ± 6% +1.91% (p=0.014 n=25+25)
Tile38KNearestLimit100Request 970µs ± 4% 970µs ± 3% ~ (p=0.819 n=22+24)
[Geo mean] 588ms 591ms +0.52%
(https://perf.golang.org/search?q=upload:20210328.6)
For #40724.
Change-Id: I1c374e32d4bbc88efed062a1b360017d3642140d
Reviewed-on: https://go-review.googlesource.com/c/go/+/305274
Trust: Austin Clements <austin@google.com>
Run-TryBot: Austin Clements <austin@google.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
|
|
Move DWARF generation for global variables from the linker to the
compiler. This effectively parallelizes this part of DWARF generation,
speeds up the linker minutely, and gives us a slightly more rational
implementation (there was really no compelling reason to do DWARF gen
for globals in the linker).
Change-Id: I0c1c98d3a647258697e90eb91d1d8a9f6f7f376a
Reviewed-on: https://go-review.googlesource.com/c/go/+/295011
Trust: Than McIntosh <thanm@google.com>
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
|
|
These symbols are implementation details and don't correspond to Go
source symbols, so directly create them as linker symbols and get rid
of their pseudo packages.
Passes toolstash -cmp w/ -gcflags=all=-abiwrap.
Change-Id: I2e97374c21f3e909f6d350f15e7a5ed3574cadf4
Reviewed-on: https://go-review.googlesource.com/c/go/+/284372
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Trust: Matthew Dempsky <mdempsky@google.com>
|
|
ir.Pkgs.Itablink isn't used anymore. (I don't recall what it was ever
used for.)
ir.Pkgs.Race and ir.Pkgs.Msan are only needed in exactly only place,
so just create them on demand there, the same way that we create
"main" on demand.
Change-Id: I3474bb949f71cd40c7a462b9f4a369adeacde0d6
Reviewed-on: https://go-review.googlesource.com/c/go/+/284230
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>
|
|
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>
|
|
We used to transform directly called closures in a separate pass
before walk, because we couldn't guarantee whether we'd see the
closure call or the closure itself first. As of the last CL, this
ordering is always guaranteed, so we can rewrite calls and the closure
at the same time.
Change-Id: Ia6f4d504c24795e41500108589b53395d301123b
Reviewed-on: https://go-review.googlesource.com/c/go/+/283315
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
|
|
The compiler currently has two modes for compilation: one where it
compiles each function as it sees them, and another where it enqueues
them all into a work queue. A subsequent CL is going to reorder
function compilation to ensure that functions are always compiled
before any non-trivial function literals they enclose, and this will
be easier if we always use the compile work queue.
Also, fewer compilation modes makes things simpler to reason about.
Change-Id: Ie090e81f7476c49486296f2b90911fa0a466a5dd
Reviewed-on: https://go-review.googlesource.com/c/go/+/283313
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
|
|
InitLSym is where we're now generating ABI wrappers, so it seems as
good a place as any to make sure we're generating the degenerate
closure wrappers for declared functions and methods.
Change-Id: I097f34bbcee65dee87a97f9ed6f3f38e4cf2e2b5
Reviewed-on: https://go-review.googlesource.com/c/go/+/283312
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
|
|
Capture analysis is now part of escape analysis.
Passes toolstash -cmp.
Change-Id: Ifcd3ecc342074c590e0db1ff0646dfa1ea2ff57b
Reviewed-on: https://go-review.googlesource.com/c/go/+/281543
Trust: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
|
|
This CL moves the general deadcode-removal pass to before computing
Addrtaken, which allows variables to still be converted to SSA if
their address is only taken in unreachable code paths (e.g., the "&mp"
expression in the "if false" block in runtime/os_linux.go:newosproc).
This doesn't pass toolstash -cmp, because it allows SSA to better
optimize some code.
Change-Id: I43e54acc02fdcbad8eb6493283f355aa1ee0de84
Reviewed-on: https://go-review.googlesource.com/c/go/+/280992
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>
|
|
This CL fixes package initialization order by creating the init task
before the general deadcode-removal pass.
It also changes noder to emit zero-initialization assignments (i.e.,
OAS with nil RHS) for package-block variables, so that initOrder can
tell the variables still need initialization. To allow this, we need
to also extend the static-init code to recognize zero-initialization
assignments.
This doesn't pass toolstash -cmp, because it reorders some package
initialization routines.
Fixes #43444.
Change-Id: I0da7996a62c85e15e97ce965298127e075390a7e
Reviewed-on: https://go-review.googlesource.com/c/go/+/280976
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>
|
|
More minor reshuffling of passes.
Passes toolstash -cmp.
Change-Id: I22633b3741f668fc5ee8579d7d610035ed57df1f
Reviewed-on: https://go-review.googlesource.com/c/go/+/280975
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>
|
|
This commit splits up typecheck.Package and moves the code
elsewhere. The type-checking code is moved into noder, so that it can
eventually be interleaved with the noding process. The
non-type-checking code is moved back into package gc, so that it can
be incorporated into appropriate compiler backend phases.
While here, deadcode removal is moved into its own package.
Passes toolstash -cmp.
[git-generate]
cd src/cmd/compile/internal/typecheck
: Split into two functions.
sed -i -e '/Phase 6/i}\n\nfunc postTypecheck() {' typecheck.go
rf '
# Export needed identifiers.
mv deadcode Deadcode
mv loadsys InitRuntime
mv declareUniverse DeclareUniverse
mv dirtyAddrtaken DirtyAddrtaken
mv computeAddrtaken ComputeAddrtaken
mv incrementalAddrtaken IncrementalAddrtaken
# Move into new package.
mv Deadcode deadcodeslice deadcodeexpr deadcode.go
mv deadcode.go cmd/compile/internal/deadcode
# Move top-level type-checking code into noder.
# Move DeclVars there too, now that nothing else uses it.
mv DeclVars Package noder.go
mv noder.go cmd/compile/internal/noder
# Move non-type-checking code back into gc.
mv postTypecheck main.go
mv main.go cmd/compile/internal/gc
'
cd ../deadcode
rf '
# Destutter names.
mv Deadcode Func
mv deadcodeslice stmts
mv deadcodeexpr expr
'
cd ../noder
rf '
# Move functions up, next to their related code.
mv noder.go:/func Package/-1,$ \
noder.go:/makeSrcPosBase translates/-1
mv noder.go:/func DeclVars/-3,$ \
noder.go:/constState tracks/-1
'
cd ../gc
rf '
# Inline postTypecheck code back into gc.Main.
mv main.go:/func postTypecheck/+0,/AllImportedBodies/+1 \
main.go:/Build init task/-1
rm postTypecheck
'
Change-Id: Ie5e992ece4a42204cce6aa98dd6eb52112d098c8
Reviewed-on: https://go-review.googlesource.com/c/go/+/280974
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>
|
|
Thanks to package reorganizing, we can remove types.TypeLinkSym by
simply having its only callers use reflectdata.TypeLinksym directly.
Passes toolstash -cmp.
Change-Id: I5bc5dbb6bf0664af43ae5130cfe1f19bd23b2bfe
Reviewed-on: https://go-review.googlesource.com/c/go/+/280644
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>
|
|
Passes toolstash -cmp.
[git-generate]
cd src/cmd/compile/internal/gc
pkgs=$(grep -l -w Linksym ../*/*.go | xargs dirname | grep -v '/gc$' | sort -u)
rf '
ex . '"$(echo $pkgs)"' {
import "cmd/compile/internal/ir"
import "cmd/compile/internal/reflectdata"
import "cmd/compile/internal/staticdata"
import "cmd/compile/internal/types"
avoid reflectdata.TypeLinksym
avoid reflectdata.TypeLinksymLookup
avoid reflectdata.TypeLinksymPrefix
avoid staticdata.FuncLinksym
var f *ir.Func
var n *ir.Name
var s string
var t *types.Type
f.Sym().Linksym() -> f.Linksym()
n.Sym().Linksym() -> n.Linksym()
reflectdata.TypeSym(t).Linksym() -> reflectdata.TypeLinksym(t)
reflectdata.TypeSymPrefix(s, t).Linksym() -> reflectdata.TypeLinksymPrefix(s, t)
staticdata.FuncSym(n.Sym()).Linksym() -> staticdata.FuncLinksym(n)
types.TypeSymLookup(s).Linksym() -> reflectdata.TypeLinksymLookup(s)
}
'
Change-Id: I7a3ae1dcd61bcdf4a29f708ff12f7f80c2b280c6
Reviewed-on: https://go-review.googlesource.com/c/go/+/280640
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>
|
|
During recent refactoring, we moved mkbuiltin.go to package typecheck,
but accidentally duplicated its //go:generate directive into a bunch
of other files/directories. This CL cleans up the unnecessary
duplicates.
Also, update all of the stringer invocations to use an explicit file
name, and regenerate their files.
Updates #43369.
Change-Id: I4e493c1fff103d742de0a839d7a3375659270b50
Reviewed-on: https://go-review.googlesource.com/c/go/+/280635
Trust: Matthew Dempsky <mdempsky@google.com>
Trust: Meng Zhuo <mzh@golangcn.org>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Meng Zhuo <mzh@golangcn.org>
|
|
The devirtualization code was only in inl.go because it reused some of
the same helper functions as inlining (notably staticValue), but that
code all ended up in package ir instead anyway. Beyond that minor
commonality, it's entirely separate from inlining.
It's definitely on the small side, but consistent with the new
micropass-as-a-package approach we're trying.
[git-generate]
cd src/cmd/compile/internal/inline
rf '
mv Devirtualize Func
mv devirtualizeCall Call
mv Func Call devirtualize.go
mv devirtualize.go cmd/compile/internal/devirtualize
'
Change-Id: Iff7b9fe486856660a8107d5391c54b7e8d238706
Reviewed-on: https://go-review.googlesource.com/c/go/+/280212
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>
|
|
[git-generate]
cd src/cmd/compile/internal/gc
rf '
mv fninit Task
mv init.go initorder.go cmd/compile/internal/pkginit
'
Change-Id: Ie2a924784c7a6fa029eaef821384eef4b262e1af
Reviewed-on: https://go-review.googlesource.com/c/go/+/279479
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
|
|
[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>
|
|
[git-generate]
cd src/cmd/compile/internal/gc
rf '
# Inline and remove ngotype.
ex {
import "cmd/compile/internal/ir"
import "cmd/compile/internal/reflectdata"
var n ir.Node
ngotype(n) -> reflectdata.TypeSym(n.Type())
}
rm ngotype
mv recordFlags RecordFlags
mv recordPackageName RecordPackageName
mv RecordFlags RecordPackageName dwarf.go
mv debuginfo Info
mv genAbstractFunc AbstractFunc
mv scope.go scope_test.go dwarf.go dwinl.go cmd/compile/internal/dwarfgen
'
Change-Id: I31fa982900dbba2066ca4c7a706af922e5481c70
Reviewed-on: https://go-review.googlesource.com/c/go/+/279477
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
|
|
[git-generate]
cd src/cmd/compile/internal/gc
rf '
# maxOpenDefers is declared in ssa.go but used only by walk.
mv maxOpenDefers walk.go
# gc.Arch -> ssagen.Arch
# It is not as nice but will do for now.
mv Arch ArchInfo
mv thearch Arch
mv Arch ArchInfo arch.go
# Pull dwarf out of pgen.go.
mv debuginfo declPos createDwarfVars preInliningDcls \
createSimpleVars createSimpleVar \
createComplexVars createComplexVar \
dwarf.go
# Pull high-level compilation out of pgen.go,
# leaving only the SSA code.
mv compilequeue funccompile compile compilenow \
compileFunctions isInlinableButNotInlined \
initLSym \
compile.go
mv BoundsCheckFunc GCWriteBarrierReg ssa.go
mv largeStack largeStackFrames CheckLargeStacks pgen.go
# All that is left in dcl.go is the nowritebarrierrecCheck
mv dcl.go nowb.go
# Export API and unexport non-API.
mv initssaconfig InitConfig
mv isIntrinsicCall IsIntrinsicCall
mv ssaDumpInline DumpInline
mv initSSATables InitTables
mv initSSAEnv InitEnv
mv compileSSA Compile
mv stackOffset StackOffset
mv canSSAType TypeOK
mv SSAGenState State
mv FwdRefAux fwdRefAux
mv cgoSymABIs CgoSymABIs
mv readSymABIs ReadSymABIs
mv initLSym InitLSym
mv useABIWrapGen symabiDefs CgoSymABIs ReadSymABIs InitLSym selectLSym makeABIWrapper setupTextLSym abi.go
mv arch.go abi.go nowb.go phi.go pgen.go pgen_test.go ssa.go cmd/compile/internal/ssagen
'
rm go.go gsubr.go
Change-Id: I47fad6cbf1d1e583fd9139003a08401d7cd048a1
Reviewed-on: https://go-review.googlesource.com/c/go/+/279476
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
|
|
[git-generate]
cd src/cmd/compile/internal/gc
rf '
ex {
import "cmd/compile/internal/base"
thearch.LinkArch.Name -> base.Ctxt.Arch.Name
}
# Move out of reflect.go a few functions that should stay.
mv addsignats obj.go
mv deferstruct ssa.go
# Export reflectdata API.
mv zerosize ZeroSize
mv hmap MapType
mv bmap MapBucketType
mv hiter MapIterType
mv addsignat NeedRuntimeType
mv typename TypePtr
mv typenamesym TypeSym
mv typesymprefix TypeSymPrefix
mv itabsym ITabSym
mv tracksym TrackSym
mv zeroaddr ZeroAddr
mv itabname ITabAddr
mv ifaceMethodOffset InterfaceMethodOffset
mv peekitabs CompileITabs
mv addptabs CollectPTabs
mv algtype AlgType
mv dtypesym WriteType
mv dumpbasictypes WriteBasicTypes
mv dumpimportstrings WriteImportStrings
mv dumpsignats WriteRuntimeTypes
mv dumptabs WriteTabs
mv eqinterface EqInterface
mv eqstring EqString
mv GCProg gcProg
mv EqCanPanic eqCanPanic
mv IsRegularMemory isRegularMemory
mv Sig typeSig
mv hashmem alg.go
mv CollectPTabs genwrapper ZeroSize reflect.go
mv alg.go reflect.go cmd/compile/internal/reflectdata
'
Change-Id: Iaae9da9e9fad5f772f5216004823ccff2ea8f139
Reviewed-on: https://go-review.googlesource.com/c/go/+/279475
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
|
|
[git-generate]
cd src/cmd/compile/internal/gc
rf '
# Export API and move to its own files.
mv addrsym InitAddr
mv pfuncsym InitFunc
mv slicesym InitSlice
mv slicebytes InitSliceBytes
mv stringsym StringSym
mv funcsym FuncSym
mv makefuncsym NeedFuncSym
mv dumpfuncsyms WriteFuncSyms
mv InitAddr InitFunc InitSlice InitSliceBytes stringSymPrefix \
StringSym fileStringSym slicedataGen slicedata dstringdata \
funcsyms FuncSym NeedFuncSym WriteFuncSyms \
data.go
mv initEmbed WriteEmbed
mv dumpembeds obj.go
mv data.go embed.go cmd/compile/internal/staticdata
'
Change-Id: I209c5e597c8acfa29a48527695a9ddc1e9ea8e6a
Reviewed-on: https://go-review.googlesource.com/c/go/+/279474
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
|
|
[git-generate]
cd src/cmd/compile/internal/gc
rf '
mv ArhdrSize HeaderSize
mv arsize ReadHeader
mv formathdr FormatHeader
mv HeaderSize ReadHeader FormatHeader archive.go
mv archive.go cmd/internal/archive
mv makePos main.go
mv checkDotImports CheckDotImports
mv parseFiles ParseFiles
mv Pragma pragmas
mv PragmaEmbed pragmaEmbed
mv PragmaPos pragmaPos
mv FuncPragmas funcPragmas
mv TypePragmas typePragmas
mv fakeRecv noder.funcLit renameinitgen renameinit oldname varEmbed noder.go
mv isDriveLetter islocalname findpkg myheight importfile \
reservedimports isbadimport \
pkgnotused \
mkpackage clearImports \
CheckDotImports dotImports importDot \
importName \
import.go
mv noder _noder
mv import.go lex.go lex_test.go noder.go cmd/compile/internal/noder
'
cd ../noder
rf '
mv _noder noder
'
Change-Id: Iac2b856f7b86143c666d818e4b7c5b261cf387d5
Reviewed-on: https://go-review.googlesource.com/c/go/+/279473
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
|
|
[git-generate]
cd src/cmd/compile/internal/gc
rf '
# Trivial min, max defined in escape.go but only used in ssa.go.
mv min8 max8 ssa.go
# Export package escape API.
mv escapes Funcs
mv escapeFuncs Batch
mv escFmt Fmt
mv unsafeUintptrTag UnsafeUintptrNote
mv uintptrEscapesTag UintptrEscapesNote
mv heapAllocReason HeapAllocReason
# Unexport non-API.
mv EscEdge edge
mv EscHole hole
mv EscLeaks leaks
mv ParseLeaks parseLeaks
mv EscLocation location
mv EscNote note
mv Escape _escape # leave room for escape import, fixed below
mv EscFuncUnknown escFuncUnknown
mv EscFuncPlanned escFuncPlanned
mv EscFuncStarted escFuncStarted
mv EscFuncTagged escFuncTagged
mv escape.go cmd/compile/internal/escape
'
cd ../escape
rf '
mv _escape escape
'
Change-Id: I3a6d1bfb6eba12bea936354ea1fe9813cbde425c
Reviewed-on: https://go-review.googlesource.com/c/go/+/279472
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
|
|
[git-generate]
cd src/cmd/compile/internal/gc
rf '
mv numNonClosures inl.go
mv inlFlood Inline_Flood
mv inlcalls InlineCalls
mv devirtualize Devirtualize
mv caninl CanInline
mv inl.go cmd/compile/internal/inline
'
Change-Id: Iee1f5b1e82d5cea6be4ecd91e6920500810f21de
Reviewed-on: https://go-review.googlesource.com/c/go/+/279309
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>
|
|
This commit splits the typechecking logic into its own package,
the first of a sequence of CLs to break package gc into more
manageable units.
[git-generate]
cd src/cmd/compile/internal/gc
rf '
# The binary import/export has to be part of typechecking,
# because we load inlined function bodies lazily, but "exporter"
# should not be. Move that out of bexport.go.
mv exporter exporter.markObject exporter.markType export.go
# Use the typechecking helpers, so that the calls left behind
# in package gc do not need access to ctxExpr etc.
ex {
import "cmd/compile/internal/ir"
# TODO(rsc): Should not be necessary.
avoid TypecheckExpr
avoid TypecheckStmt
avoid TypecheckExprs
avoid TypecheckStmts
avoid TypecheckAssignExpr
avoid TypecheckCallee
var n ir.Node
var ns []ir.Node
typecheck(n, ctxExpr) -> TypecheckExpr(n)
typecheck(n, ctxStmt) -> TypecheckStmt(n)
typecheckslice(ns, ctxExpr) -> TypecheckExprs(ns)
typecheckslice(ns, ctxStmt) -> TypecheckStmts(ns)
typecheck(n, ctxExpr|ctxAssign) -> TypecheckAssignExpr(n)
typecheck(n, ctxExpr|ctxCallee) -> TypecheckCallee(n)
}
# Move some typechecking API to typecheck.
mv syslook LookupRuntime
mv substArgTypes SubstArgTypes
mv LookupRuntime SubstArgTypes syms.go
mv conv Conv
mv convnop ConvNop
mv Conv ConvNop typecheck.go
mv colasdefn AssignDefn
mv colasname assignableName
mv Target target.go
mv initname autoexport exportsym dcl.go
mv exportsym Export
# Export API to be called from outside typecheck.
# The ones with "Typecheck" prefixes will be renamed later to drop the prefix.
mv adddot AddImplicitDots
mv assignconv AssignConv
mv expandmeth CalcMethods
mv capturevarscomplete CaptureVarsComplete
mv checkMapKeys CheckMapKeys
mv checkreturn CheckReturn
mv dclcontext DeclContext
mv dclfunc DeclFunc
mv declare Declare
mv dotImportRefs DotImportRefs
mv declImporter DeclImporter
mv variter DeclVars
mv defaultlit DefaultLit
mv evalConst EvalConst
mv expandInline ImportBody
mv finishUniverse declareUniverse
mv funcbody FinishFuncBody
mv funchdr StartFuncBody
mv indexconst IndexConst
mv initTodo InitTodoFunc
mv lookup Lookup
mv resolve Resolve
mv lookupN LookupNum
mv nodAddr NodAddr
mv nodAddrAt NodAddrAt
mv nodnil NodNil
mv origBoolConst OrigBool
mv origConst OrigConst
mv origIntConst OrigInt
mv redeclare Redeclared
mv tostruct NewStructType
mv functype NewFuncType
mv methodfunc NewMethodType
mv structargs NewFuncParams
mv temp Temp
mv tempAt TempAt
mv typecheckok TypecheckAllowed
mv typecheck _typecheck # make room for typecheck pkg
mv typecheckinl TypecheckImportedBody
mv typecheckFunc TypecheckFunc
mv iimport ReadImports
mv iexport WriteExports
mv sysfunc LookupRuntimeFunc
mv sysvar LookupRuntimeVar
# Move function constructors to typecheck.
mv mkdotargslice MakeDotArgs
mv fixVariadicCall FixVariadicCall
mv closureType ClosureType
mv partialCallType PartialCallType
mv capturevars CaptureVars
mv MakeDotArgs FixVariadicCall ClosureType PartialCallType CaptureVars typecheckclosure func.go
mv autolabel AutoLabel
mv AutoLabel syms.go
mv Dlist dlist
mv Symlink symlink
mv \
AssignDefn assignableName \
AssignConv \
CaptureVarsComplete \
DeclContext \
DeclFunc \
DeclImporter \
DeclVars \
Declare \
DotImportRefs \
Export \
InitTodoFunc \
Lookup \
LookupNum \
LookupRuntimeFunc \
LookupRuntimeVar \
NewFuncParams \
NewName \
NodAddr \
NodAddrAt \
NodNil \
Redeclared \
StartFuncBody \
FinishFuncBody \
TypecheckImportedBody \
AddImplicitDots \
CalcMethods \
CheckFuncStack \
NewFuncType \
NewMethodType \
NewStructType \
TypecheckAllowed \
Temp \
TempAt \
adddot1 \
dotlist \
addmethod \
assignconvfn \
assignop \
autotmpname \
autoexport \
bexport.go \
checkdupfields \
checkembeddedtype \
closurename \
convertop \
declare_typegen \
decldepth \
dlist \
dotpath \
expand0 \
expand1 \
expandDecl \
fakeRecvField \
fnpkg \
funcStack \
funcStackEnt \
funcarg \
funcarg2 \
funcargs \
funcargs2 \
globClosgen \
ifacelookdot \
implements \
importalias \
importconst \
importfunc \
importobj \
importsym \
importtype \
importvar \
inimport \
initname \
isptrto \
loadsys \
lookdot0 \
lookdot1 \
makepartialcall \
okfor \
okforlen \
operandType \
slist \
symlink \
tointerface \
typeSet \
typeSet.add \
typeSetEntry \
typecheckExprSwitch \
typecheckTypeSwitch \
typecheckpartialcall \
typecheckrange \
typecheckrangeExpr \
typecheckselect \
typecheckswitch \
vargen \
builtin.go \
builtin_test.go \
const.go \
func.go \
iexport.go \
iimport.go \
mapfile_mmap.go \
syms.go \
target.go \
typecheck.go \
unsafe.go \
universe.go \
cmd/compile/internal/typecheck
'
rm gen.go types.go types_acc.go
sed -i '' 's/package gc/package typecheck/' mapfile_read.go mkbuiltin.go
mv mapfile_read.go ../typecheck # not part of default build
mv mkbuiltin.go ../typecheck # package main helper
mv builtin ../typecheck
cd ../typecheck
mv dcl.go dcl1.go
mv typecheck.go typecheck1.go
mv universe.go universe1.go
rf '
# Sweep some small files into larger ones.
# "mv sym... file1.go file.go" (after the mv file1.go file.go above)
# lets us insert sym... at the top of file.go.
mv okfor okforeq universe1.go universe.go
mv DeclContext vargen dcl1.go Temp TempAt autotmpname NewMethodType dcl.go
mv InitTodoFunc inimport decldepth TypecheckAllowed typecheck1.go typecheck.go
mv inl.go closure.go func.go
mv range.go select.go swt.go stmt.go
mv Lookup loadsys LookupRuntimeFunc LookupRuntimeVar syms.go
mv unsafe.go const.go
mv TypecheckAssignExpr AssignExpr
mv TypecheckExpr Expr
mv TypecheckStmt Stmt
mv TypecheckExprs Exprs
mv TypecheckStmts Stmts
mv TypecheckCall Call
mv TypecheckCallee Callee
mv _typecheck check
mv TypecheckFunc Func
mv TypecheckFuncBody FuncBody
mv TypecheckImports AllImportedBodies
mv TypecheckImportedBody ImportedBody
mv TypecheckInit Init
mv TypecheckPackage Package
'
rm gen.go go.go init.go main.go reflect.go
Change-Id: Iea6a7aaf6407d690670ec58aeb36cc0b280f80b0
Reviewed-on: https://go-review.googlesource.com/c/go/+/279236
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>
|
|
[generated]
To break up package gc, we need to put these calculations somewhere
lower in the import graph, either an existing or new package. Package types
already needs this code and is using hacks to get it without an import cycle.
We can remove the hacks and set up for the new package gc by moving the
code into package types itself.
[git-generate]
cd src/cmd/compile/internal/gc
rf '
# Remove old import cycle hacks in gc.
rm TypecheckInit:/types.Widthptr =/-0,/types.Dowidth =/+0 \
../ssa/export_test.go:/types.Dowidth =/-+
ex {
import "cmd/compile/internal/types"
types.Widthptr -> Widthptr
types.Dowidth -> dowidth
}
# Disable CalcSize in tests instead of base.Fatalf
sub dowidth:/base.Fatalf\("dowidth without betypeinit"\)/ \
// Assume this is a test. \
return
# Move size calculation into cmd/compile/internal/types
mv Widthptr PtrSize
mv Widthreg RegSize
mv slicePtrOffset SlicePtrOffset
mv sliceLenOffset SliceLenOffset
mv sliceCapOffset SliceCapOffset
mv sizeofSlice SliceSize
mv sizeofString StringSize
mv skipDowidthForTracing SkipSizeForTracing
mv dowidth CalcSize
mv checkwidth CheckSize
mv widstruct calcStructOffset
mv sizeCalculationDisabled CalcSizeDisabled
mv defercheckwidth DeferCheckSize
mv resumecheckwidth ResumeCheckSize
mv typeptrdata PtrDataSize
mv \
PtrSize RegSize SlicePtrOffset SkipSizeForTracing typePos align.go PtrDataSize \
size.go
mv size.go cmd/compile/internal/types
'
: # Remove old import cycle hacks in types.
cd ../types
rf '
ex {
Widthptr -> PtrSize
Dowidth -> CalcSize
}
rm Widthptr Dowidth
'
Change-Id: Ib96cdc6bda2617235480c29392ea5cfb20f60cd8
Reviewed-on: https://go-review.googlesource.com/c/go/+/279234
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>
|
|
[git-generate]
cd src/cmd/compile/internal/gc
sed -i '' 's/TestBuiltin.*/& t.Skip("mkbuiltin needs fixing")/' builtin_test.go
gofmt -w builtin_test.go
rf '
# Inline a few little-used constructors to avoid bringing them.
ex {
import "cmd/compile/internal/base"
import "cmd/compile/internal/ir"
import "cmd/compile/internal/types"
import "cmd/internal/src"
var typ *types.Type
var sym *types.Sym
var str string
symfield(sym, typ) -> ir.NewField(base.Pos, sym, nil, typ)
anonfield(typ) -> ir.NewField(base.Pos, nil, nil, typ)
namedfield(str, typ) -> ir.NewField(base.Pos, lookup(str), nil, typ)
var cp *ir.CallPartExpr
callpartMethod(cp) -> cp.Method
var n ir.Node
callpartMethod(n) -> n.(*ir.CallPartExpr).Method
var ns []ir.Node
liststmt(ns) -> ir.NewBlockStmt(src.NoXPos, ns)
}
rm symfield anonfield namedfield liststmt callpartMethod
mv maxStackVarSize MaxStackVarSize
mv maxImplicitStackVarSize MaxImplicitStackVarSize
mv smallArrayBytes MaxSmallArraySize
mv MaxStackVarSize cfg.go
mv nodbool NewBool
mv nodintconst NewInt
mv nodstr NewString
mv NewBool NewInt NewString const.go
mv Mpprec ConstPrec
mv bigFloatVal BigFloat
mv doesoverflow ConstOverflow
mv isGoConst IsConstNode
mv smallintconst IsSmallIntConst
mv isZero IsZero
mv islvalue IsAssignable
mv staticValue StaticValue
mv samesafeexpr SameSafeExpr
mv checkPtr ShouldCheckPtr
mv isReflectHeaderDataField IsReflectHeaderDataField
mv paramNnames ParamNames
mv methodSym MethodSym
mv methodSymSuffix MethodSymSuffix
mv methodExprFunc MethodExprFunc
mv methodExprName MethodExprName
mv IsZero IsAssignable StaticValue staticValue1 reassigned \
IsIntrinsicCall \
SameSafeExpr ShouldCheckPtr IsReflectHeaderDataField \
ParamNames MethodSym MethodSymSuffix \
MethodExprName MethodExprFunc \
expr.go
mv Curfn CurFunc
mv funcsymname FuncSymName
mv newFuncNameAt NewFuncNameAt
mv setNodeNameFunc MarkFunc
mv CurFunc FuncSymName NewFuncNameAt MarkFunc func.go
mv isParamStackCopy IsParamStackCopy
mv isParamHeapCopy IsParamHeapCopy
mv nodfp RegFP
mv IsParamStackCopy IsParamHeapCopy RegFP name.go
mv hasUniquePos HasUniquePos
mv setlineno SetPos
mv initExpr InitExpr
mv hasNamedResults HasNamedResults
mv outervalue OuterValue
mv HasNamedResults HasUniquePos SetPos InitExpr OuterValue EscNever node.go
mv visitBottomUp VisitFuncsBottomUp # scc.go
mv cfg.go \
NewBool NewInt NewString \ # parts of const.go
ConstPrec BigFloat ConstOverflow IsConstNode IsSmallIntConst \
expr.go func.go name.go node.go scc.go \
cmd/compile/internal/ir
'
Change-Id: I13402c5a2cedbf78d993a1eae2940718f23ac166
Reviewed-on: https://go-review.googlesource.com/c/go/+/279421
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>
|
|
There are a handful of pre-computed magic symbols known by
package gc, and we need a place to store them.
If we keep them together, the need for type *ir.Name means that
package ir is the lowest package in the import hierarchy that they
can go in. And package ir needs gopkg for methodSymSuffix
(in a later CL), so they can't go any higher either, at least not all together.
So package ir it is.
Rather than dump them all into the top-level package ir
namespace, however, we introduce global structs, Syms, Pkgs, and Names,
and make the known symbols, packages, and names fields of those.
[git-generate]
cd src/cmd/compile/internal/gc
rf '
add go.go:$ \
// Names holds known names. \
var Names struct{} \
\
// Syms holds known symbols. \
var Syms struct {} \
\
// Pkgs holds known packages. \
var Pkgs struct {} \
mv staticuint64s Names.Staticuint64s
mv zerobase Names.Zerobase
mv assertE2I Syms.AssertE2I
mv assertE2I2 Syms.AssertE2I2
mv assertI2I Syms.AssertI2I
mv assertI2I2 Syms.AssertI2I2
mv deferproc Syms.Deferproc
mv deferprocStack Syms.DeferprocStack
mv Deferreturn Syms.Deferreturn
mv Duffcopy Syms.Duffcopy
mv Duffzero Syms.Duffzero
mv gcWriteBarrier Syms.GCWriteBarrier
mv goschedguarded Syms.Goschedguarded
mv growslice Syms.Growslice
mv msanread Syms.Msanread
mv msanwrite Syms.Msanwrite
mv msanmove Syms.Msanmove
mv newobject Syms.Newobject
mv newproc Syms.Newproc
mv panicdivide Syms.Panicdivide
mv panicshift Syms.Panicshift
mv panicdottypeE Syms.PanicdottypeE
mv panicdottypeI Syms.PanicdottypeI
mv panicnildottype Syms.Panicnildottype
mv panicoverflow Syms.Panicoverflow
mv raceread Syms.Raceread
mv racereadrange Syms.Racereadrange
mv racewrite Syms.Racewrite
mv racewriterange Syms.Racewriterange
mv SigPanic Syms.SigPanic
mv typedmemclr Syms.Typedmemclr
mv typedmemmove Syms.Typedmemmove
mv Udiv Syms.Udiv
mv writeBarrier Syms.WriteBarrier
mv zerobaseSym Syms.Zerobase
mv arm64HasATOMICS Syms.ARM64HasATOMICS
mv armHasVFPv4 Syms.ARMHasVFPv4
mv x86HasFMA Syms.X86HasFMA
mv x86HasPOPCNT Syms.X86HasPOPCNT
mv x86HasSSE41 Syms.X86HasSSE41
mv WasmDiv Syms.WasmDiv
mv WasmMove Syms.WasmMove
mv WasmZero Syms.WasmZero
mv WasmTruncS Syms.WasmTruncS
mv WasmTruncU Syms.WasmTruncU
mv gopkg Pkgs.Go
mv itabpkg Pkgs.Itab
mv itablinkpkg Pkgs.Itablink
mv mappkg Pkgs.Map
mv msanpkg Pkgs.Msan
mv racepkg Pkgs.Race
mv Runtimepkg Pkgs.Runtime
mv trackpkg Pkgs.Track
mv unsafepkg Pkgs.Unsafe
mv Names Syms Pkgs symtab.go
mv symtab.go cmd/compile/internal/ir
'
Change-Id: Ic143862148569a3bcde8e70b26d75421aa2d00f3
Reviewed-on: https://go-review.googlesource.com/c/go/+/279235
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>
|
|
[git-generate]
cd src/cmd/compile/internal/gc
rf '
# Type hash (formatting).
mv typehash TypeHash
mv TypeHash fmt.go
# Method sorting.
mv methcmp MethodsByName
mv MethodsByName MethodsByName.Len MethodsByName.Swap \
MethodsByName.Less sort.go
# Move version check into types.
# A little surprising, but its keyed off the types.Pkg.
ex {
import "cmd/compile/internal/types"
var p *types.Pkg
var major, minor int
langSupported(major, minor, p) -> AllowsGoVersion(p, major, minor)
}
rm langSupported
mv checkLang ParseLangFlag
mv lang langWant AllowsGoVersion ParseLangFlag \
parseLang currentLang goVersionRE goversion.go
mv testdclstack CheckDclstack
mv CheckDclstack scope.go
mv algtype1 AlgType
mv isComplex IsComplex
mv isFloat IsFloat
mv isInt IsInt
mv issimple IsSimple
mv okforcmp IsOrdered
mv floatForComplex FloatForComplex
mv complexForFloat ComplexForFloat
mv isdirectiface IsDirectIface
mv isifacemethod IsInterfaceMethod
mv isMethodApplicable IsMethodApplicable
mv ispaddedfield IsPaddedField
mv isRuntimePkg IsRuntimePkg
mv isReflectPkg IsReflectPkg
mv methtype ReceiverBaseType
mv typesymname TypeSymName
mv typesym TypeSym
mv typeLookup TypeSymLookup
mv IsAlias IsDotAlias
mv isreflexive IsReflexive
mv simtype SimType
# The type1.go here is to avoid an undiagnosed bug in rf
# that does not get the follow-up typechecking right if we
# move directly to type.go during the mv into package types below.
mv \
IsInt IsOrdered IsReflexive \
IsDirectIface IsInterfaceMethod IsMethodApplicable IsPaddedField \
IsRuntimePkg IsReflectPkg ReceiverBaseType \
FloatForComplex ComplexForFloat \
TypeSym TypeSymLookup TypeSymName \
typepkg SimType \
type1.go
# The alg1.go here is because we are only moving part of alg.go.
mv typeHasNoAlg TypeHasNoAlg
mv AlgKind ANOEQ AlgType TypeHasNoAlg IsComparable IncomparableField IsPaddedField alg1.go
mv IsDotAlias pkg.go
mv alg1.go algkind_string.go fmt.go goversion.go pkg.go \
CheckDclstack \ # scope.go
sort.go type1.go \
cmd/compile/internal/types
'
cd ../types
rf '
mv IsDclstackValid isDclstackValid
mv alg1.go alg.go
mv type1.go type.go
'
Change-Id: I8bd53b21c7bdd1770e1b525de32f136833e84c9d
Reviewed-on: https://go-review.googlesource.com/c/go/+/279307
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>
|
|
[git-generate]
cd src/cmd/compile/internal/gc
rf '
# Move EnableTrace constant into base, with the other flags.
mv enableTrace EnableTrace
mv EnableTrace base.go
# Move compilation checks to base.
mv instrumenting Instrumenting
mv ispkgin Compiling
mv omit_pkgs NoInstrumentPkgs
mv norace_inst_pkgs NoRacePkgs
mv Instrumenting Compiling NoInstrumentPkgs NoRacePkgs base.go
# Move AutogeneratedPos to package base, next to Pos.
mv autogeneratedPos AutogeneratedPos
mv AutogeneratedPos print.go
mv timings Timer
mv base.go print.go timings.go cmd/compile/internal/base
'
cd ../base
rf '
mv Instrumenting Flag.Cfg.Instrumenting
'
Change-Id: I534437fa75857d31531fc499d833c9930c0a06d0
Reviewed-on: https://go-review.googlesource.com/c/go/+/279420
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>
|
|
Now that the generic graph structure methods - Left, Right, and so on -
have been removed from the Node interface, each implementation's uses
can be replaced with direct field access, using more specific names,
and the methods themselves can be deleted.
Passes buildall w/ toolstash -cmp.
[git-generate]
cd src/cmd/compile/internal/ir
rf '
mv Func.iota Func.Iota_
mv Name.fn Name.Func_
'
cd ../gc
rf '
ex . ../ir {
import "cmd/compile/internal/ir"
import "cmd/compile/internal/types"
var ns ir.Nodes
var b bool
var i64 int64
var n ir.Node
var op ir.Op
var sym *types.Sym
var class ir.Class
var decl *ir.Decl
decl.Left() -> decl.X
decl.SetLeft(n) -> decl.X = n
var asl *ir.AssignListStmt
asl.List() -> asl.Lhs
asl.PtrList() -> &asl.Lhs
asl.SetList(ns) -> asl.Lhs = ns
asl.Rlist() -> asl.Rhs
asl.PtrRlist() -> &asl.Rhs
asl.SetRlist(ns) -> asl.Rhs = ns
asl.Colas() -> asl.Def
asl.SetColas(b) -> asl.Def = b
var as *ir.AssignStmt
as.Left() -> as.X
as.SetLeft(n) -> as.X = n
as.Right() -> as.Y
as.SetRight(n) -> as.Y = n
as.Colas() -> as.Def
as.SetColas(b) -> as.Def = b
var ao *ir.AssignOpStmt
ao.Left() -> ao.X
ao.SetLeft(n) -> ao.X = n
ao.Right() -> ao.Y
ao.SetRight(n) -> ao.Y = n
ao.SubOp() -> ao.AsOp
ao.SetSubOp(op) -> ao.AsOp = op
ao.Implicit() -> ao.IncDec
ao.SetImplicit(b) -> ao.IncDec = b
var bl *ir.BlockStmt
bl.List() -> bl.List_
bl.PtrList() -> &bl.List_
bl.SetList(ns) -> bl.List_ = ns
var br *ir.BranchStmt
br.Sym() -> br.Label
br.SetSym(sym) -> br.Label = sym
var cas *ir.CaseStmt
cas.List() -> cas.List_
cas.PtrList() -> &cas.List_
cas.SetList(ns) -> cas.List_ = ns
cas.Body() -> cas.Body_
cas.PtrBody() -> &cas.Body_
cas.SetBody(ns) -> cas.Body_ = ns
cas.Rlist() -> cas.Vars
cas.PtrRlist() -> &cas.Vars
cas.SetRlist(ns) -> cas.Vars = ns
cas.Left() -> cas.Comm
cas.SetLeft(n) -> cas.Comm = n
var fr *ir.ForStmt
fr.Sym() -> fr.Label
fr.SetSym(sym) -> fr.Label = sym
fr.Left() -> fr.Cond
fr.SetLeft(n) -> fr.Cond = n
fr.Right() -> fr.Post
fr.SetRight(n) -> fr.Post = n
fr.Body() -> fr.Body_
fr.PtrBody() -> &fr.Body_
fr.SetBody(ns) -> fr.Body_ = ns
fr.List() -> fr.Late
fr.PtrList() -> &fr.Late
fr.SetList(ns) -> fr.Late = ns
fr.HasBreak() -> fr.HasBreak_
fr.SetHasBreak(b) -> fr.HasBreak_ = b
var gs *ir.GoDeferStmt
gs.Left() -> gs.Call
gs.SetLeft(n) -> gs.Call = n
var ifs *ir.IfStmt
ifs.Left() -> ifs.Cond
ifs.SetLeft(n) -> ifs.Cond = n
ifs.Body() -> ifs.Body_
ifs.PtrBody() -> &ifs.Body_
ifs.SetBody(ns) -> ifs.Body_ = ns
ifs.Rlist() -> ifs.Else
ifs.PtrRlist() -> &ifs.Else
ifs.SetRlist(ns) -> ifs.Else = ns
ifs.Likely() -> ifs.Likely_
ifs.SetLikely(b) -> ifs.Likely_ = b
var im *ir.InlineMarkStmt
im.Offset() -> im.Index
im.SetOffset(i64) -> im.Index = i64
var lab *ir.LabelStmt
lab.Sym() -> lab.Label
lab.SetSym(sym) -> lab.Label = sym
var rng *ir.RangeStmt
rng.Sym() -> rng.Label
rng.SetSym(sym) -> rng.Label = sym
rng.Right() -> rng.X
rng.SetRight(n) -> rng.X = n
rng.Body() -> rng.Body_
rng.PtrBody() -> &rng.Body_
rng.SetBody(ns) -> rng.Body_ = ns
rng.List() -> rng.Vars
rng.PtrList() -> &rng.Vars
rng.SetList(ns) -> rng.Vars = ns
rng.HasBreak() -> rng.HasBreak_
rng.SetHasBreak(b) -> rng.HasBreak_ = b
rng.Colas() -> rng.Def
rng.SetColas(b) -> rng.Def = b
var ret *ir.ReturnStmt
ret.List() -> ret.Results
ret.PtrList() -> &ret.Results
ret.SetList(ns) -> ret.Results = ns
var sel *ir.SelectStmt
sel.List() -> sel.Cases
sel.PtrList() -> &sel.Cases
sel.SetList(ns) -> sel.Cases = ns
sel.Sym() -> sel.Label
sel.SetSym(sym) -> sel.Label = sym
sel.HasBreak() -> sel.HasBreak_
sel.SetHasBreak(b) -> sel.HasBreak_ = b
sel.Body() -> sel.Compiled
sel.PtrBody() -> &sel.Compiled
sel.SetBody(ns) -> sel.Compiled = ns
var send *ir.SendStmt
send.Left() -> send.Chan
send.SetLeft(n) -> send.Chan = n
send.Right() -> send.Value
send.SetRight(n) -> send.Value = n
var sw *ir.SwitchStmt
sw.Left() -> sw.Tag
sw.SetLeft(n) -> sw.Tag = n
sw.List() -> sw.Cases
sw.PtrList() -> &sw.Cases
sw.SetList(ns) -> sw.Cases = ns
sw.Body() -> sw.Compiled
sw.PtrBody() -> &sw.Compiled
sw.SetBody(ns) -> sw.Compiled = ns
sw.Sym() -> sw.Label
sw.SetSym(sym) -> sw.Label = sym
sw.HasBreak() -> sw.HasBreak_
sw.SetHasBreak(b) -> sw.HasBreak_ = b
var tg *ir.TypeSwitchGuard
tg.Left() -> tg.Tag
tg.SetLeft(nil) -> tg.Tag = nil
tg.SetLeft(n) -> tg.Tag = n.(*ir.Ident)
tg.Right() -> tg.X
tg.SetRight(n) -> tg.X = n
var adds *ir.AddStringExpr
adds.List() -> adds.List_
adds.PtrList() -> &adds.List_
adds.SetList(ns) -> adds.List_ = ns
var addr *ir.AddrExpr
addr.Left() -> addr.X
addr.SetLeft(n) -> addr.X = n
addr.Right() -> addr.Alloc
addr.SetRight(n) -> addr.Alloc = n
var bin *ir.BinaryExpr
bin.Left() -> bin.X
bin.SetLeft(n) -> bin.X = n
bin.Right() -> bin.Y
bin.SetRight(n) -> bin.Y = n
var log *ir.LogicalExpr
log.Left() -> log.X
log.SetLeft(n) -> log.X = n
log.Right() -> log.Y
log.SetRight(n) -> log.Y = n
var call *ir.CallExpr
call.Left() -> call.X
call.SetLeft(n) -> call.X = n
call.List() -> call.Args
call.PtrList() -> &call.Args
call.SetList(ns) -> call.Args = ns
call.Rlist() -> call.Rargs
call.PtrRlist() -> &call.Rargs
call.SetRlist(ns) -> call.Rargs = ns
call.IsDDD() -> call.DDD
call.SetIsDDD(b) -> call.DDD = b
call.NoInline() -> call.NoInline_
call.SetNoInline(b) -> call.NoInline_ = b
call.Body() -> call.Body_
call.PtrBody() -> &call.Body_
call.SetBody(ns) -> call.Body_ = ns
var cp *ir.CallPartExpr
cp.Func() -> cp.Func_
cp.Left() -> cp.X
cp.SetLeft(n) -> cp.X = n
cp.Sym() -> cp.Method.Sym
var clo *ir.ClosureExpr
clo.Func() -> clo.Func_
var cr *ir.ClosureReadExpr
cr.Offset() -> cr.Offset_
var cl *ir.CompLitExpr
cl.Right() -> cl.Ntype
cl.SetRight(nil) -> cl.Ntype = nil
cl.SetRight(n) -> cl.Ntype = ir.Node(n).(ir.Ntype)
cl.List() -> cl.List_
cl.PtrList() -> &cl.List_
cl.SetList(ns) -> cl.List_ = ns
var conv *ir.ConvExpr
conv.Left() -> conv.X
conv.SetLeft(n) -> conv.X = n
var ix *ir.IndexExpr
ix.Left() -> ix.X
ix.SetLeft(n) -> ix.X = n
ix.Right() -> ix.Index
ix.SetRight(n) -> ix.Index = n
ix.IndexMapLValue() -> ix.Assigned
ix.SetIndexMapLValue(b) -> ix.Assigned = b
var kv *ir.KeyExpr
kv.Left() -> kv.Key
kv.SetLeft(n) -> kv.Key = n
kv.Right() -> kv.Value
kv.SetRight(n) -> kv.Value = n
var sk *ir.StructKeyExpr
sk.Sym() -> sk.Field
sk.SetSym(sym) -> sk.Field = sym
sk.Left() -> sk.Value
sk.SetLeft(n) -> sk.Value = n
sk.Offset() -> sk.Offset_
sk.SetOffset(i64) -> sk.Offset_ = i64
var ic *ir.InlinedCallExpr
ic.Body() -> ic.Body_
ic.PtrBody() -> &ic.Body_
ic.SetBody(ns) -> ic.Body_ = ns
ic.Rlist() -> ic.ReturnVars
ic.PtrRlist() -> &ic.ReturnVars
ic.SetRlist(ns) -> ic.ReturnVars = ns
var mak *ir.MakeExpr
mak.Left() -> mak.Len
mak.SetLeft(n) -> mak.Len = n
mak.Right() -> mak.Cap
mak.SetRight(n) -> mak.Cap = n
var par *ir.ParenExpr
par.Left() -> par.X
par.SetLeft(n) -> par.X = n
var res *ir.ResultExpr
res.Offset() -> res.Offset_
res.SetOffset(i64) -> res.Offset_ = i64
var dot *ir.SelectorExpr
dot.Left() -> dot.X
dot.SetLeft(n) -> dot.X = n
dot.Sym() -> dot.Sel
dot.SetSym(sym) -> dot.Sel = sym
dot.Offset() -> dot.Offset_
dot.SetOffset(i64) -> dot.Offset_ = i64
var sl *ir.SliceExpr
sl.Left() -> sl.X
sl.SetLeft(n) -> sl.X = n
sl.List() -> sl.List_
sl.PtrList() -> &sl.List_
sl.SetList(ns) -> sl.List_ = ns
var sh *ir.SliceHeaderExpr
sh.Left() -> sh.Ptr
sh.SetLeft(n) -> sh.Ptr = n
sh.List() -> sh.LenCap_
sh.PtrList() -> &sh.LenCap_
sh.SetList(ns) -> sh.LenCap_ = ns
var st *ir.StarExpr
st.Left() -> st.X
st.SetLeft(n) -> st.X = n
var ta *ir.TypeAssertExpr
ta.Left() -> ta.X
ta.SetLeft(n) -> ta.X = n
ta.Right() -> ta.Ntype
ta.SetRight(n) -> ta.Ntype = n
ta.List() -> ta.Itab
ta.PtrList() -> &ta.Itab
ta.SetList(ns) -> ta.Itab = ns
var u *ir.UnaryExpr
u.Left() -> u.X
u.SetLeft(n) -> u.X = n
var fn *ir.Func
fn.Body() -> fn.Body_
fn.PtrBody() -> &fn.Body_
fn.SetBody(ns) -> fn.Body_ = ns
fn.Iota() -> fn.Iota_
fn.SetIota(i64) -> fn.Iota_ = i64
fn.Func() -> fn
var nam *ir.Name
nam.SubOp() -> nam.BuiltinOp
nam.SetSubOp(op) -> nam.BuiltinOp = op
nam.Class() -> nam.Class_
nam.SetClass(class) -> nam.Class_ = class
nam.Func() -> nam.Func_
nam.Offset() -> nam.Offset_
nam.SetOffset(i64) -> nam.Offset_ = i64
}
ex . ../ir {
import "cmd/compile/internal/ir"
var n ir.Nodes
(&n).Append -> n.Append
(&n).AppendNodes -> n.AppendNodes
(&n).MoveNodes -> n.MoveNodes
(&n).Prepend -> n.Prepend
(&n).Set -> n.Set
(&n).Set1 -> n.Set1
(&n).Set2 -> n.Set2
(&n).Set3 -> n.Set3
var ntype ir.Ntype
ir.Node(ntype).(ir.Ntype) -> ntype
}
'
cd ../ir
rf '
rm \
Decl.Left Decl.SetLeft \
AssignListStmt.List AssignListStmt.PtrList AssignListStmt.SetList \
AssignListStmt.Rlist AssignListStmt.PtrRlist AssignListStmt.SetRlist \
AssignListStmt.Colas AssignListStmt.SetColas \
AssignStmt.Left AssignStmt.SetLeft \
AssignStmt.Right AssignStmt.SetRight \
AssignStmt.Colas AssignStmt.SetColas \
AssignOpStmt.Left AssignOpStmt.SetLeft \
AssignOpStmt.Right AssignOpStmt.SetRight \
AssignOpStmt.SubOp AssignOpStmt.SetSubOp \
AssignOpStmt.Implicit AssignOpStmt.SetImplicit \
BlockStmt.List BlockStmt.PtrList BlockStmt.SetList \
BranchStmt.SetSym \
CaseStmt.List CaseStmt.PtrList CaseStmt.SetList \
CaseStmt.Body CaseStmt.PtrBody CaseStmt.SetBody \
CaseStmt.Rlist CaseStmt.PtrRlist CaseStmt.SetRlist \
CaseStmt.Left CaseStmt.SetLeft \
ForStmt.Left ForStmt.SetLeft \
ForStmt.Right ForStmt.SetRight \
ForStmt.Body ForStmt.PtrBody ForStmt.SetBody \
ForStmt.List ForStmt.PtrList ForStmt.SetList \
ForStmt.HasBreak ForStmt.SetHasBreak \
ForStmt.Sym ForStmt.SetSym \
GoDeferStmt.Left GoDeferStmt.SetLeft \
IfStmt.Left IfStmt.SetLeft \
IfStmt.Body IfStmt.PtrBody IfStmt.SetBody \
IfStmt.Rlist IfStmt.PtrRlist IfStmt.SetRlist \
IfStmt.Likely IfStmt.SetLikely \
LabelStmt.SetSym \
RangeStmt.Right RangeStmt.SetRight \
RangeStmt.Body RangeStmt.PtrBody RangeStmt.SetBody \
RangeStmt.List RangeStmt.PtrList RangeStmt.SetList \
RangeStmt.HasBreak RangeStmt.SetHasBreak \
RangeStmt.Colas RangeStmt.SetColas \
RangeStmt.Sym RangeStmt.SetSym \
ReturnStmt.List ReturnStmt.PtrList ReturnStmt.SetList \
SelectStmt.List SelectStmt.PtrList SelectStmt.SetList \
SelectStmt.HasBreak SelectStmt.SetHasBreak \
SelectStmt.Body SelectStmt.PtrBody SelectStmt.SetBody \
SelectStmt.Sym SelectStmt.SetSym \
SendStmt.Left SendStmt.SetLeft \
SendStmt.Right SendStmt.SetRight \
SwitchStmt.Left SwitchStmt.SetLeft \
SwitchStmt.List SwitchStmt.PtrList SwitchStmt.SetList \
SwitchStmt.Body SwitchStmt.PtrBody SwitchStmt.SetBody \
SwitchStmt.HasBreak SwitchStmt.SetHasBreak \
SwitchStmt.Sym SwitchStmt.SetSym \
TypeSwitchGuard.Left TypeSwitchGuard.SetLeft \
TypeSwitchGuard.Right TypeSwitchGuard.SetRight \
AddStringExpr.List AddStringExpr.PtrList AddStringExpr.SetList \
AddrExpr.Left AddrExpr.SetLeft \
AddrExpr.Right AddrExpr.SetRight \
BinaryExpr.Left BinaryExpr.SetLeft \
BinaryExpr.Right BinaryExpr.SetRight \
LogicalExpr.Left LogicalExpr.SetLeft \
LogicalExpr.Right LogicalExpr.SetRight \
CallExpr.Left CallExpr.SetLeft \
CallExpr.List CallExpr.PtrList CallExpr.SetList \
CallExpr.Rlist CallExpr.PtrRlist CallExpr.SetRlist \
CallExpr.NoInline CallExpr.SetNoInline \
CallExpr.Body CallExpr.PtrBody CallExpr.SetBody \
CallExpr.IsDDD CallExpr.SetIsDDD \
CallPartExpr.Left CallPartExpr.SetLeft \
ClosureReadExpr.Offset \
ClosureReadExpr.Type \ # provided by miniExpr already
CompLitExpr.Right CompLitExpr.SetRight \
CompLitExpr.List CompLitExpr.PtrList CompLitExpr.SetList \
ConvExpr.Left ConvExpr.SetLeft \
IndexExpr.Left IndexExpr.SetLeft \
IndexExpr.Right IndexExpr.SetRight \
IndexExpr.IndexMapLValue IndexExpr.SetIndexMapLValue \
KeyExpr.Left KeyExpr.SetLeft \
KeyExpr.Right KeyExpr.SetRight \
StructKeyExpr.Left StructKeyExpr.SetLeft \
StructKeyExpr.Offset StructKeyExpr.SetOffset \
StructKeyExpr.SetSym \
InlinedCallExpr.Body InlinedCallExpr.PtrBody InlinedCallExpr.SetBody \
InlinedCallExpr.Rlist InlinedCallExpr.PtrRlist InlinedCallExpr.SetRlist \
MakeExpr.Left MakeExpr.SetLeft \
MakeExpr.Right MakeExpr.SetRight \
MethodExpr.Left MethodExpr.SetLeft \
MethodExpr.Right MethodExpr.SetRight \
MethodExpr.Offset MethodExpr.SetOffset \
MethodExpr.Class MethodExpr.SetClass \
ParenExpr.Left ParenExpr.SetLeft \
ResultExpr.Offset ResultExpr.SetOffset \
ReturnStmt.IsDDD \
SelectorExpr.Left SelectorExpr.SetLeft \
SelectorExpr.Offset SelectorExpr.SetOffset \
SelectorExpr.SetSym \
SliceExpr.Left SliceExpr.SetLeft \
SliceExpr.List SliceExpr.PtrList SliceExpr.SetList \
SliceHeaderExpr.Left SliceHeaderExpr.SetLeft \
SliceHeaderExpr.List SliceHeaderExpr.PtrList SliceHeaderExpr.SetList \
StarExpr.Left StarExpr.SetLeft \
TypeAssertExpr.Left TypeAssertExpr.SetLeft \
TypeAssertExpr.Right TypeAssertExpr.SetRight \
TypeAssertExpr.List TypeAssertExpr.PtrList TypeAssertExpr.SetList \
UnaryExpr.Left UnaryExpr.SetLeft \
Func.Body Func.PtrBody Func.SetBody \
Func.Iota Func.SetIota \
CallPartExpr.Func ClosureExpr.Func Func.Func Name.Func \
mv BlockStmt.List_ BlockStmt.List
mv CaseStmt.List_ CaseStmt.List
mv CaseStmt.Body_ CaseStmt.Body
mv ForStmt.Body_ ForStmt.Body
mv ForStmt.HasBreak_ ForStmt.HasBreak
mv Func.Iota_ Func.Iota
mv IfStmt.Body_ IfStmt.Body
mv IfStmt.Likely_ IfStmt.Likely
mv RangeStmt.Body_ RangeStmt.Body
mv RangeStmt.HasBreak_ RangeStmt.HasBreak
mv SelectStmt.HasBreak_ SelectStmt.HasBreak
mv SwitchStmt.HasBreak_ SwitchStmt.HasBreak
mv AddStringExpr.List_ AddStringExpr.List
mv CallExpr.NoInline_ CallExpr.NoInline
mv CallExpr.Body_ CallExpr.Body # TODO what is this?
mv CallExpr.DDD CallExpr.IsDDD
mv ClosureReadExpr.Offset_ ClosureReadExpr.Offset
mv CompLitExpr.List_ CompLitExpr.List
mv StructKeyExpr.Offset_ StructKeyExpr.Offset
mv InlinedCallExpr.Body_ InlinedCallExpr.Body
mv ResultExpr.Offset_ ResultExpr.Offset
mv SelectorExpr.Offset_ SelectorExpr.Offset
mv SliceExpr.List_ SliceExpr.List
mv SliceHeaderExpr.LenCap_ SliceHeaderExpr.LenCap
mv Func.Body_ Func.Body
mv CallPartExpr.Func_ CallPartExpr.Func
mv ClosureExpr.Func_ ClosureExpr.Func
mv Name.Func_ Name.Func
'
Change-Id: Ia2ee59649674f83eb123e63fda7a7781cf91cc56
Reviewed-on: https://go-review.googlesource.com/c/go/+/277935
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>
|
|
Sets up for removing Func from Node interface.
That means that once the Name reorg is done,
which will let us remove Name, Sym, and Val,
Node will be basically a minimal interface.
Passes buildall w/ toolstash -cmp.
Change-Id: I6e87897572debd7f8e29b4f5167763dc2792b408
Reviewed-on: https://go-review.googlesource.com/c/go/+/279484
Trust: Russ Cox <rsc@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
|
|
Misc cleanup for splitting package gc: API tweaks
and boundary adjustments.
The change in ir.NewBlockStmt makes it a drop-in
replacement for liststmt.
Change-Id: I9455fe8ccae7d71fe8ccf390ac96672389bf4f3d
Reviewed-on: https://go-review.googlesource.com/c/go/+/279305
Trust: Russ Cox <rsc@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
|
|
Move various code out of Main itself and into helper functions
that can be moved into other packages as package gc splits up.
Similarly, move order and instrument inside walk to reduce the amount
of API surface needed from the eventual package walk.
Change-Id: I7849258038c6e39625a0385af9c0edd6a3b654a1
Reviewed-on: https://go-review.googlesource.com/c/go/+/279304
Trust: Russ Cox <rsc@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
|
|
Abstract the typecheck API a bit more so that it is
easier to move into a new package.
Change-Id: Ia0a0146151fa7f6073113e68a2c3f6e42a5d0ad8
Reviewed-on: https://go-review.googlesource.com/c/go/+/279303
Trust: Russ Cox <rsc@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
|
|
Having a global MaxWidth lets us avoid needing to
refer to thearch from split-out packages when all
they need is thearch.MAXWIDTH.
And make a couple interface changes to let dowidth
avoid importing package ir directly.
Then it can move into package types.
Change-Id: I2c12e8e22252597530e648848320e19bdd490a01
Reviewed-on: https://go-review.googlesource.com/c/go/+/279302
Trust: Russ Cox <rsc@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
|
|
Add compiler support for emitting ABI wrappers by creating real IR as
opposed to introducing ABI aliases. At the moment these are "no-op"
wrappers in the sense that they make a simple call (using the existing
ABI) to their target. The assumption here is that once late call
expansion can handle both ABI0 and the "new" ABIInternal (register
version), it can expand the call to do the right thing.
Note that the runtime contains functions that do not strictly follow
the rules of the current Go ABI0; this has been handled in most cases
by treating these as ABIInternal instead (these changes have been made
in previous patches).
Generation of ABI wrappers (as opposed to ABI aliases) is currently
gated by GOEXPERIMENT=regabi -- wrapper generation is on by default if
GOEXPERIMENT=regabi is set and off otherwise (but can be turned on
using "-gcflags=all=-abiwrap -ldflags=-abiwrap"). Wrapper generation
currently only workd on AMD64; explicitly enabling wrapper for other
architectures (via the command line) is not supported.
Also in this patch are a few other command line options for debugging
(tracing and/or limiting wrapper creation). These will presumably go
away at some point.
Updates #27539, #40724.
Change-Id: I1ee3226fc15a3c32ca2087b8ef8e41dbe6df4a75
Reviewed-on: https://go-review.googlesource.com/c/go/+/270863
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Trust: Than McIntosh <thanm@google.com>
|
|
Main knows a bit too much about nowritebarrierrec.
Abstract the API a little bit to make the package split easier.
Change-Id: I4b76bdb1fed73dfb0d44e1a6c86de8c2d29a9488
Reviewed-on: https://go-review.googlesource.com/c/go/+/279301
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>
|
|
isIntrinsicCall and ssaDumpInline are the only two "forward references"
to ssa by earlier phases. Make them a bit more explicit so that the
uses and the definitions can end up in different packages.
Change-Id: I02c7a27464fbedef9fee43c0e4094fa08b4d7a5c
Reviewed-on: https://go-review.googlesource.com/c/go/+/279300
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>
|
|
Separate embed, cgo pragmas, and Main trackScopes variable
from noder more cleanly.
This lets us split embed and noder into new packages.
It also assumes that the local embedded variables will be
removed and deletes them now for simplicity.
Change-Id: I9638bcc2c5f0e76440de056c6285b6aa2f73a00d
Reviewed-on: https://go-review.googlesource.com/c/go/+/279299
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>
|