From 51ba53f5c2d58dd0c02b5ee1f4ef1db2577c4d3a Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Mon, 21 Dec 2020 01:20:20 -0500 Subject: [dev.regabi] cmd/compile: separate misc for gc split 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 Reviewed-by: Matthew Dempsky --- src/cmd/compile/internal/gc/main.go | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'src/cmd/compile/internal/gc/main.go') diff --git a/src/cmd/compile/internal/gc/main.go b/src/cmd/compile/internal/gc/main.go index 4aa2a2ca47..80b17ebbf8 100644 --- a/src/cmd/compile/internal/gc/main.go +++ b/src/cmd/compile/internal/gc/main.go @@ -54,9 +54,6 @@ func hidePanic() { // Target is the package being compiled. var Target *ir.Package -// timing data for compiler phases -var timings Timings - // Main parses flags and Go source files specified in the command-line // arguments, type-checks the parsed Go package, compiles functions to machine // code, and finally writes the compiled package definition to disk. @@ -189,6 +186,7 @@ func Main(archInit func(*Arch)) { logopt.LogJsonOption(base.Flag.JSON) } + ir.EscFmt = escFmt IsIntrinsicCall = isIntrinsicCall SSADumpInline = ssaDumpInline initSSAEnv() @@ -962,9 +960,11 @@ type lang struct { // any language version is supported. var langWant lang -// langSupported reports whether language version major.minor is -// supported in a particular package. -func langSupported(major, minor int, pkg *types.Pkg) bool { +// AllowsGoVersion reports whether a particular package +// is allowed to use Go version major.minor. +// We assume the imported packages have all been checked, +// so we only have to check the local package against the -lang flag. +func AllowsGoVersion(pkg *types.Pkg, major, minor int) bool { if pkg == nil { // TODO(mdempsky): Set Pkg for local types earlier. pkg = types.LocalPkg @@ -973,13 +973,16 @@ func langSupported(major, minor int, pkg *types.Pkg) bool { // Assume imported packages passed type-checking. return true } - if langWant.major == 0 && langWant.minor == 0 { return true } return langWant.major > major || (langWant.major == major && langWant.minor >= minor) } +func langSupported(major, minor int, pkg *types.Pkg) bool { + return AllowsGoVersion(pkg, major, minor) +} + // checkLang verifies that the -lang flag holds a valid value, and // exits if not. It initializes data used by langSupported. func checkLang() { -- cgit v1.2.3-54-g00ecf