diff options
author | Russ Cox <rsc@golang.org> | 2021-04-15 23:05:49 -0400 |
---|---|---|
committer | Russ Cox <rsc@golang.org> | 2021-04-16 19:20:53 +0000 |
commit | 95ed5c3800a87ddf9b0ec3958eaaa1a969306293 (patch) | |
tree | cb0c555f10ab706a5c491cbe48dd36da16658a1e /src/cmd/compile/internal | |
parent | 2fc0ebb623e2859094ad3f41e61325df0c2163f8 (diff) | |
download | go-95ed5c3800a87ddf9b0ec3958eaaa1a969306293.tar.gz go-95ed5c3800a87ddf9b0ec3958eaaa1a969306293.zip |
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>
Diffstat (limited to 'src/cmd/compile/internal')
43 files changed, 301 insertions, 276 deletions
diff --git a/src/cmd/compile/internal/amd64/ggen.go b/src/cmd/compile/internal/amd64/ggen.go index b5847d48b9..1484ad5404 100644 --- a/src/cmd/compile/internal/amd64/ggen.go +++ b/src/cmd/compile/internal/amd64/ggen.go @@ -11,11 +11,11 @@ import ( "cmd/compile/internal/types" "cmd/internal/obj" "cmd/internal/obj/x86" - "cmd/internal/objabi" + "internal/buildcfg" ) // no floating point in note handlers on Plan 9 -var isPlan9 = objabi.GOOS == "plan9" +var isPlan9 = buildcfg.GOOS == "plan9" // DUFFZERO consists of repeated blocks of 4 MOVUPSs + LEAQ, // See runtime/mkduff.go. @@ -85,7 +85,7 @@ func zerorange(pp *objw.Progs, p *obj.Prog, off, cnt int64, state *uint32) *obj. } p = pp.Append(p, x86.AMOVQ, obj.TYPE_REG, x86.REG_R13, 0, obj.TYPE_MEM, x86.REG_SP, off) } else if !isPlan9 && cnt <= int64(8*types.RegSize) { - if !objabi.Experiment.RegabiG && *state&x15 == 0 { + if !buildcfg.Experiment.RegabiG && *state&x15 == 0 { p = pp.Append(p, x86.AXORPS, obj.TYPE_REG, x86.REG_X15, 0, obj.TYPE_REG, x86.REG_X15, 0) *state |= x15 } @@ -98,7 +98,7 @@ func zerorange(pp *objw.Progs, p *obj.Prog, off, cnt int64, state *uint32) *obj. p = pp.Append(p, x86.AMOVUPS, obj.TYPE_REG, x86.REG_X15, 0, obj.TYPE_MEM, x86.REG_SP, off+cnt-int64(16)) } } else if !isPlan9 && (cnt <= int64(128*types.RegSize)) { - if !objabi.Experiment.RegabiG && *state&x15 == 0 { + if !buildcfg.Experiment.RegabiG && *state&x15 == 0 { p = pp.Append(p, x86.AXORPS, obj.TYPE_REG, x86.REG_X15, 0, obj.TYPE_REG, x86.REG_X15, 0) *state |= x15 } diff --git a/src/cmd/compile/internal/amd64/ssa.go b/src/cmd/compile/internal/amd64/ssa.go index fce3c6b820..42c12953f9 100644 --- a/src/cmd/compile/internal/amd64/ssa.go +++ b/src/cmd/compile/internal/amd64/ssa.go @@ -6,6 +6,7 @@ package amd64 import ( "fmt" + "internal/buildcfg" "math" "cmd/compile/internal/base" @@ -17,7 +18,6 @@ import ( "cmd/compile/internal/types" "cmd/internal/obj" "cmd/internal/obj/x86" - "cmd/internal/objabi" ) // markMoves marks any MOVXconst ops that need to avoid clobbering flags. @@ -825,7 +825,7 @@ func ssaGenValue(s *ssagen.State, v *ssa.Value) { p.To.Reg = v.Args[0].Reg() ssagen.AddAux2(&p.To, v, sc.Off64()) case ssa.OpAMD64MOVOstorezero: - if !objabi.Experiment.RegabiG || s.ABI != obj.ABIInternal { + if !buildcfg.Experiment.RegabiG || s.ABI != obj.ABIInternal { // zero X15 manually opregreg(s, x86.AXORPS, x86.REG_X15, x86.REG_X15) } @@ -916,7 +916,7 @@ func ssaGenValue(s *ssagen.State, v *ssa.Value) { p.To.Type = obj.TYPE_REG p.To.Reg = v.Reg() case ssa.OpAMD64DUFFZERO: - if !objabi.Experiment.RegabiG || s.ABI != obj.ABIInternal { + if !buildcfg.Experiment.RegabiG || s.ABI != obj.ABIInternal { // zero X15 manually opregreg(s, x86.AXORPS, x86.REG_X15, x86.REG_X15) } @@ -999,20 +999,20 @@ func ssaGenValue(s *ssagen.State, v *ssa.Value) { // Closure pointer is DX. ssagen.CheckLoweredGetClosurePtr(v) case ssa.OpAMD64LoweredGetG: - if objabi.Experiment.RegabiG && s.ABI == obj.ABIInternal { + if buildcfg.Experiment.RegabiG && s.ABI == obj.ABIInternal { v.Fatalf("LoweredGetG should not appear in ABIInternal") } r := v.Reg() getgFromTLS(s, r) case ssa.OpAMD64CALLstatic: - if objabi.Experiment.RegabiG && s.ABI == obj.ABI0 && v.Aux.(*ssa.AuxCall).Fn.ABI() == obj.ABIInternal { + if buildcfg.Experiment.RegabiG && s.ABI == obj.ABI0 && v.Aux.(*ssa.AuxCall).Fn.ABI() == obj.ABIInternal { // zeroing X15 when entering ABIInternal from ABI0 opregreg(s, x86.AXORPS, x86.REG_X15, x86.REG_X15) // set G register from TLS getgFromTLS(s, x86.REG_R14) } s.Call(v) - if objabi.Experiment.RegabiG && s.ABI == obj.ABIInternal && v.Aux.(*ssa.AuxCall).Fn.ABI() == obj.ABI0 { + if buildcfg.Experiment.RegabiG && s.ABI == obj.ABIInternal && v.Aux.(*ssa.AuxCall).Fn.ABI() == obj.ABI0 { // zeroing X15 when entering ABIInternal from ABI0 opregreg(s, x86.AXORPS, x86.REG_X15, x86.REG_X15) // set G register from TLS @@ -1306,7 +1306,7 @@ func ssaGenBlock(s *ssagen.State, b, next *ssa.Block) { case ssa.BlockRet: s.Prog(obj.ARET) case ssa.BlockRetJmp: - if objabi.Experiment.RegabiG && s.ABI == obj.ABI0 && b.Aux.(*obj.LSym).ABI() == obj.ABIInternal { + if buildcfg.Experiment.RegabiG && s.ABI == obj.ABI0 && b.Aux.(*obj.LSym).ABI() == obj.ABIInternal { // zeroing X15 when entering ABIInternal from ABI0 opregreg(s, x86.AXORPS, x86.REG_X15, x86.REG_X15) // set G register from TLS diff --git a/src/cmd/compile/internal/arm/galign.go b/src/cmd/compile/internal/arm/galign.go index 81959ae0ab..d68500280d 100644 --- a/src/cmd/compile/internal/arm/galign.go +++ b/src/cmd/compile/internal/arm/galign.go @@ -8,14 +8,14 @@ import ( "cmd/compile/internal/ssa" "cmd/compile/internal/ssagen" "cmd/internal/obj/arm" - "cmd/internal/objabi" + "internal/buildcfg" ) func Init(arch *ssagen.ArchInfo) { arch.LinkArch = &arm.Linkarm arch.REGSP = arm.REGSP arch.MAXWIDTH = (1 << 32) - 1 - arch.SoftFloat = objabi.GOARM == 5 + arch.SoftFloat = buildcfg.GOARM == 5 arch.ZeroRange = zerorange arch.Ginsnop = ginsnop arch.Ginsnopdefer = ginsnop diff --git a/src/cmd/compile/internal/arm/ssa.go b/src/cmd/compile/internal/arm/ssa.go index 832f940c26..4b083cec46 100644 --- a/src/cmd/compile/internal/arm/ssa.go +++ b/src/cmd/compile/internal/arm/ssa.go @@ -6,6 +6,7 @@ package arm import ( "fmt" + "internal/buildcfg" "math" "math/bits" @@ -17,7 +18,6 @@ import ( "cmd/compile/internal/types" "cmd/internal/obj" "cmd/internal/obj/arm" - "cmd/internal/objabi" ) // loadByType returns the load instruction of the given type. @@ -286,7 +286,7 @@ func ssaGenValue(s *ssagen.State, v *ssa.Value) { case ssa.OpARMANDconst, ssa.OpARMBICconst: // try to optimize ANDconst and BICconst to BFC, which saves bytes and ticks // BFC is only available on ARMv7, and its result and source are in the same register - if objabi.GOARM == 7 && v.Reg() == v.Args[0].Reg() { + if buildcfg.GOARM == 7 && v.Reg() == v.Args[0].Reg() { var val uint32 if v.Op == ssa.OpARMANDconst { val = ^uint32(v.AuxInt) @@ -643,7 +643,7 @@ func ssaGenValue(s *ssagen.State, v *ssa.Value) { default: } } - if objabi.GOARM >= 6 { + if buildcfg.GOARM >= 6 { // generate more efficient "MOVB/MOVBU/MOVH/MOVHU Reg@>0, Reg" on ARMv6 & ARMv7 genshift(s, v.Op.Asm(), 0, v.Args[0].Reg(), v.Reg(), arm.SHIFT_RR, 0) return diff --git a/src/cmd/compile/internal/arm64/ggen.go b/src/cmd/compile/internal/arm64/ggen.go index 8364535f63..89be496461 100644 --- a/src/cmd/compile/internal/arm64/ggen.go +++ b/src/cmd/compile/internal/arm64/ggen.go @@ -10,10 +10,10 @@ import ( "cmd/compile/internal/types" "cmd/internal/obj" "cmd/internal/obj/arm64" - "cmd/internal/objabi" + "internal/buildcfg" ) -var darwin = objabi.GOOS == "darwin" || objabi.GOOS == "ios" +var darwin = buildcfg.GOOS == "darwin" || buildcfg.GOOS == "ios" func padframe(frame int64) int64 { // arm64 requires that the frame size (not counting saved FP&LR) diff --git a/src/cmd/compile/internal/base/flag.go b/src/cmd/compile/internal/base/flag.go index 4b7ef155a1..42c0c1b94b 100644 --- a/src/cmd/compile/internal/base/flag.go +++ b/src/cmd/compile/internal/base/flag.go @@ -8,6 +8,7 @@ import ( "encoding/json" "flag" "fmt" + "internal/buildcfg" "io/ioutil" "log" "os" @@ -146,7 +147,7 @@ func ParseFlags() { Flag.LowerP = &Ctxt.Pkgpath Flag.LowerV = &Ctxt.Debugvlog - Flag.Dwarf = objabi.GOARCH != "wasm" + Flag.Dwarf = buildcfg.GOARCH != "wasm" Flag.DwarfBASEntries = &Ctxt.UseBASEntries Flag.DwarfLocationLists = &Ctxt.Flag_locationlists *Flag.DwarfLocationLists = true @@ -168,14 +169,14 @@ func ParseFlags() { registerFlags() objabi.Flagparse(usage) - if Flag.MSan && !sys.MSanSupported(objabi.GOOS, objabi.GOARCH) { - log.Fatalf("%s/%s does not support -msan", objabi.GOOS, objabi.GOARCH) + if Flag.MSan && !sys.MSanSupported(buildcfg.GOOS, buildcfg.GOARCH) { + log.Fatalf("%s/%s does not support -msan", buildcfg.GOOS, buildcfg.GOARCH) } - if Flag.Race && !sys.RaceDetectorSupported(objabi.GOOS, objabi.GOARCH) { - log.Fatalf("%s/%s does not support -race", objabi.GOOS, objabi.GOARCH) + if Flag.Race && !sys.RaceDetectorSupported(buildcfg.GOOS, buildcfg.GOARCH) { + log.Fatalf("%s/%s does not support -race", buildcfg.GOOS, buildcfg.GOARCH) } if (*Flag.Shared || *Flag.Dynlink || *Flag.LinkShared) && !Ctxt.Arch.InFamily(sys.AMD64, sys.ARM, sys.ARM64, sys.I386, sys.PPC64, sys.RISCV64, sys.S390X) { - log.Fatalf("%s/%s does not support -shared", objabi.GOOS, objabi.GOARCH) + log.Fatalf("%s/%s does not support -shared", buildcfg.GOOS, buildcfg.GOARCH) } parseSpectre(Flag.Spectre) // left as string for RecordFlags @@ -347,7 +348,7 @@ func concurrentBackendAllowed() bool { return false } // TODO: Test and delete this condition. - if objabi.Experiment.FieldTrack { + if buildcfg.Experiment.FieldTrack { return false } // TODO: fix races and enable the following flags @@ -458,11 +459,11 @@ func parseSpectre(s string) { } if Flag.Cfg.SpectreIndex { - switch objabi.GOARCH { + switch buildcfg.GOARCH { case "amd64": // ok default: - log.Fatalf("GOARCH=%s does not support -spectre=index", objabi.GOARCH) + log.Fatalf("GOARCH=%s does not support -spectre=index", buildcfg.GOARCH) } } } diff --git a/src/cmd/compile/internal/base/print.go b/src/cmd/compile/internal/base/print.go index 668c600d31..b095fd704d 100644 --- a/src/cmd/compile/internal/base/print.go +++ b/src/cmd/compile/internal/base/print.go @@ -6,12 +6,12 @@ package base import ( "fmt" + "internal/buildcfg" "os" "runtime/debug" "sort" "strings" - "cmd/internal/objabi" "cmd/internal/src" ) @@ -217,7 +217,7 @@ func FatalfAt(pos src.XPos, format string, args ...interface{}) { fmt.Printf("\n") // If this is a released compiler version, ask for a bug report. - if strings.HasPrefix(objabi.Version, "go") { + if strings.HasPrefix(buildcfg.Version, "go") { fmt.Printf("\n") fmt.Printf("Please file a bug report including a short program that triggers the error.\n") fmt.Printf("https://golang.org/issue/new\n") diff --git a/src/cmd/compile/internal/dwarfgen/dwarf.go b/src/cmd/compile/internal/dwarfgen/dwarf.go index 7b5863bbc6..0754a8810c 100644 --- a/src/cmd/compile/internal/dwarfgen/dwarf.go +++ b/src/cmd/compile/internal/dwarfgen/dwarf.go @@ -8,6 +8,7 @@ import ( "bytes" "flag" "fmt" + "internal/buildcfg" "sort" "cmd/compile/internal/base" @@ -278,7 +279,7 @@ func createSimpleVar(fnsym *obj.LSym, n *ir.Name) *dwarf.Var { if base.Ctxt.FixedFrameSize() == 0 { offs -= int64(types.PtrSize) } - if objabi.FramePointerEnabled { + if buildcfg.FramePointerEnabled { offs -= int64(types.PtrSize) } diff --git a/src/cmd/compile/internal/gc/main.go b/src/cmd/compile/internal/gc/main.go index 68506c7a7b..ce50cbb4c2 100644 --- a/src/cmd/compile/internal/gc/main.go +++ b/src/cmd/compile/internal/gc/main.go @@ -28,6 +28,7 @@ import ( "cmd/internal/src" "flag" "fmt" + "internal/buildcfg" "log" "os" "runtime" @@ -158,7 +159,7 @@ func Main(archInit func(*ssagen.ArchInfo)) { dwarf.EnableLogging(base.Debug.DwarfInl != 0) } if base.Debug.SoftFloat != 0 { - if objabi.Experiment.RegabiArgs { + if buildcfg.Experiment.RegabiArgs { log.Fatalf("softfloat mode with GOEXPERIMENT=regabiargs not implemented ") } ssagen.Arch.SoftFloat = true @@ -335,7 +336,7 @@ func writebench(filename string) error { } var buf bytes.Buffer - fmt.Fprintln(&buf, "commit:", objabi.Version) + fmt.Fprintln(&buf, "commit:", buildcfg.Version) fmt.Fprintln(&buf, "goos:", runtime.GOOS) fmt.Fprintln(&buf, "goarch:", runtime.GOARCH) base.Timer.Write(&buf, "BenchmarkCompile:"+base.Ctxt.Pkgpath+":") diff --git a/src/cmd/compile/internal/logopt/log_opts.go b/src/cmd/compile/internal/logopt/log_opts.go index 37a049d640..97ebf56944 100644 --- a/src/cmd/compile/internal/logopt/log_opts.go +++ b/src/cmd/compile/internal/logopt/log_opts.go @@ -6,10 +6,10 @@ package logopt import ( "cmd/internal/obj" - "cmd/internal/objabi" "cmd/internal/src" "encoding/json" "fmt" + "internal/buildcfg" "io" "log" "net/url" @@ -408,7 +408,7 @@ func uprootedPath(filename string) string { if !strings.HasPrefix(filename, "$GOROOT/") { return filename } - return objabi.GOROOT + filename[len("$GOROOT"):] + return buildcfg.GOROOT + filename[len("$GOROOT"):] } // FlushLoggedOpts flushes all the accumulated optimization log entries. @@ -448,7 +448,7 @@ func FlushLoggedOpts(ctxt *obj.Link, slashPkgPath string) { currentFile = p0f w = writerForLSP(subdirpath, currentFile) encoder = json.NewEncoder(w) - encoder.Encode(VersionHeader{Version: 0, Package: slashPkgPath, Goos: objabi.GOOS, Goarch: objabi.GOARCH, GcVersion: objabi.Version, File: currentFile}) + encoder.Encode(VersionHeader{Version: 0, Package: slashPkgPath, Goos: buildcfg.GOOS, Goarch: buildcfg.GOARCH, GcVersion: buildcfg.Version, File: currentFile}) } // The first "target" is the most important one. diff --git a/src/cmd/compile/internal/mips/galign.go b/src/cmd/compile/internal/mips/galign.go index 599163550b..f892923ba0 100644 --- a/src/cmd/compile/internal/mips/galign.go +++ b/src/cmd/compile/internal/mips/galign.go @@ -8,17 +8,17 @@ import ( "cmd/compile/internal/ssa" "cmd/compile/internal/ssagen" "cmd/internal/obj/mips" - "cmd/internal/objabi" + "internal/buildcfg" ) func Init(arch *ssagen.ArchInfo) { arch.LinkArch = &mips.Linkmips - if objabi.GOARCH == "mipsle" { + if buildcfg.GOARCH == "mipsle" { arch.LinkArch = &mips.Linkmipsle } arch.REGSP = mips.REGSP arch.MAXWIDTH = (1 << 31) - 1 - arch.SoftFloat = (objabi.GOMIPS == "softfloat") + arch.SoftFloat = (buildcfg.GOMIPS == "softfloat") arch.ZeroRange = zerorange arch.Ginsnop = ginsnop arch.Ginsnopdefer = ginsnop diff --git a/src/cmd/compile/internal/mips64/galign.go b/src/cmd/compile/internal/mips64/galign.go index fc0a34228c..af81366e51 100644 --- a/src/cmd/compile/internal/mips64/galign.go +++ b/src/cmd/compile/internal/mips64/galign.go @@ -8,17 +8,17 @@ import ( "cmd/compile/internal/ssa" "cmd/compile/internal/ssagen" "cmd/internal/obj/mips" - "cmd/internal/objabi" + "internal/buildcfg" ) func Init(arch *ssagen.ArchInfo) { arch.LinkArch = &mips.Linkmips64 - if objabi.GOARCH == "mips64le" { + if buildcfg.GOARCH == "mips64le" { arch.LinkArch = &mips.Linkmips64le } arch.REGSP = mips.REGSP arch.MAXWIDTH = 1 << 50 - arch.SoftFloat = objabi.GOMIPS64 == "softfloat" + arch.SoftFloat = buildcfg.GOMIPS64 == "softfloat" arch.ZeroRange = zerorange arch.Ginsnop = ginsnop arch.Ginsnopdefer = ginsnop diff --git a/src/cmd/compile/internal/noder/import.go b/src/cmd/compile/internal/noder/import.go index e6e3fe1834..701e9001c8 100644 --- a/src/cmd/compile/internal/noder/import.go +++ b/src/cmd/compile/internal/noder/import.go @@ -7,6 +7,7 @@ package noder import ( "errors" "fmt" + "internal/buildcfg" "io" "os" pathpkg "path" @@ -108,7 +109,7 @@ func openPackage(path string) (*os.File, error) { } } - if objabi.GOROOT != "" { + if buildcfg.GOROOT != "" { suffix := "" if base.Flag.InstallSuffix != "" { suffix = "_" + base.Flag.InstallSuffix @@ -118,10 +119,10 @@ func openPackage(path string) (*os.File, error) { suffix = "_msan" } - if file, err := os.Open(fmt.Sprintf("%s/pkg/%s_%s%s/%s.a", objabi.GOROOT, objabi.GOOS, objabi.GOARCH, suffix, path)); err == nil { + if file, err := os.Open(fmt.Sprintf("%s/pkg/%s_%s%s/%s.a", buildcfg.GOROOT, buildcfg.GOOS, buildcfg.GOARCH, suffix, path)); err == nil { return file, nil } - if file, err := os.Open(fmt.Sprintf("%s/pkg/%s_%s%s/%s.o", objabi.GOROOT, objabi.GOOS, objabi.GOARCH, suffix, path)); err == nil { + if file, err := os.Open(fmt.Sprintf("%s/pkg/%s_%s%s/%s.o", buildcfg.GOROOT, buildcfg.GOOS, buildcfg.GOARCH, suffix, path)); err == nil { return file, nil } } diff --git a/src/cmd/compile/internal/noder/lex.go b/src/cmd/compile/internal/noder/lex.go index 60b724d154..66a56a50ec 100644 --- a/src/cmd/compile/internal/noder/lex.go +++ b/src/cmd/compile/internal/noder/lex.go @@ -6,11 +6,11 @@ package noder import ( "fmt" + "internal/buildcfg" "strings" "cmd/compile/internal/ir" "cmd/compile/internal/syntax" - "cmd/internal/objabi" ) func isSpace(c rune) bool { @@ -44,7 +44,7 @@ func pragmaFlag(verb string) ir.PragmaFlag { case "go:build": return ir.GoBuildPragma case "go:nointerface": - if objabi.Experiment.FieldTrack { + if buildcfg.Experiment.FieldTrack { return ir.Nointerface } case "go:noescape": @@ -110,7 +110,7 @@ func (p *noder) pragcgo(pos syntax.Pos, text string) { case len(f) == 3 && !isQuoted(f[1]) && !isQuoted(f[2]): case len(f) == 4 && !isQuoted(f[1]) && !isQuoted(f[2]) && isQuoted(f[3]): f[3] = strings.Trim(f[3], `"`) - if objabi.GOOS == "aix" && f[3] != "" { + if buildcfg.GOOS == "aix" && f[3] != "" { // On Aix, library pattern must be "lib.a/object.o" // or "lib.a/libname.so.X" n := strings.Split(f[3], "/") diff --git a/src/cmd/compile/internal/ppc64/galign.go b/src/cmd/compile/internal/ppc64/galign.go index c72d1aa834..590290fa37 100644 --- a/src/cmd/compile/internal/ppc64/galign.go +++ b/src/cmd/compile/internal/ppc64/galign.go @@ -7,12 +7,12 @@ package ppc64 import ( "cmd/compile/internal/ssagen" "cmd/internal/obj/ppc64" - "cmd/internal/objabi" + "internal/buildcfg" ) func Init(arch *ssagen.ArchInfo) { arch.LinkArch = &ppc64.Linkppc64 - if objabi.GOARCH == "ppc64le" { + if buildcfg.GOARCH == "ppc64le" { arch.LinkArch = &ppc64.Linkppc64le } arch.REGSP = ppc64.REGSP diff --git a/src/cmd/compile/internal/ppc64/ssa.go b/src/cmd/compile/internal/ppc64/ssa.go index a0ad69a68d..11226f65a0 100644 --- a/src/cmd/compile/internal/ppc64/ssa.go +++ b/src/cmd/compile/internal/ppc64/ssa.go @@ -13,7 +13,7 @@ import ( "cmd/compile/internal/types" "cmd/internal/obj" "cmd/internal/obj/ppc64" - "cmd/internal/objabi" + "internal/buildcfg" "math" "strings" ) @@ -1873,7 +1873,7 @@ func ssaGenValue(s *ssagen.State, v *ssa.Value) { s.UseArgs(16) // space used in callee args area by assembly stubs case ssa.OpPPC64LoweredNilCheck: - if objabi.GOOS == "aix" { + if buildcfg.GOOS == "aix" { // CMP Rarg0, R0 // BNE 2(PC) // STW R0, 0(R0) diff --git a/src/cmd/compile/internal/reflectdata/reflect.go b/src/cmd/compile/internal/reflectdata/reflect.go index 379735e86b..f0a60998a1 100644 --- a/src/cmd/compile/internal/reflectdata/reflect.go +++ b/src/cmd/compile/internal/reflectdata/reflect.go @@ -6,6 +6,7 @@ package reflectdata import ( "fmt" + "internal/buildcfg" "os" "sort" "strings" @@ -1774,7 +1775,7 @@ func methodWrapper(rcvr *types.Type, method *types.Field) *obj.LSym { // Disable tailcall for RegabiArgs for now. The IR does not connect the // arguments with the OTAILCALL node, and the arguments are not marshaled // correctly. - if !base.Flag.Cfg.Instrumenting && rcvr.IsPtr() && methodrcvr.IsPtr() && method.Embedded != 0 && !types.IsInterfaceMethod(method.Type) && !(base.Ctxt.Arch.Name == "ppc64le" && base.Ctxt.Flag_dynlink) && !objabi.Experiment.RegabiArgs { + if !base.Flag.Cfg.Instrumenting && rcvr.IsPtr() && methodrcvr.IsPtr() && method.Embedded != 0 && !types.IsInterfaceMethod(method.Type) && !(base.Ctxt.Arch.Name == "ppc64le" && base.Ctxt.Flag_dynlink) && !buildcfg.Experiment.RegabiArgs { // generate tail call: adjust pointer receiver and jump to embedded method. left := dot.X // skip final .M if !left.Type().IsPtr() { diff --git a/src/cmd/compile/internal/ssa/compile.go b/src/cmd/compile/internal/ssa/compile.go index b1bcd4566e..8aae04f2ec 100644 --- a/src/cmd/compile/internal/ssa/compile.go +++ b/src/cmd/compile/internal/ssa/compile.go @@ -6,10 +6,10 @@ package ssa import ( "bytes" - "cmd/internal/objabi" "cmd/internal/src" "fmt" "hash/crc32" + "internal/buildcfg" "log" "math/rand" "os" @@ -454,7 +454,7 @@ var passes = [...]pass{ {name: "dse", fn: dse}, {name: "writebarrier", fn: writebarrier, required: true}, // expand write barrier ops {name: "insert resched checks", fn: insertLoopReschedChecks, - disabled: !objabi.Experiment.PreemptibleLoops}, // insert resched checks in loops. + disabled: !buildcfg.Experiment.PreemptibleLoops}, // insert resched checks in loops. {name: "lower", fn: lower, required: true}, {name: "addressing modes", fn: addressingModes, required: false}, {name: "lowered deadcode for cse", fn: deadcode}, // deadcode immediately before CSE avoids CSE making dead values live again diff --git a/src/cmd/compile/internal/ssa/config.go b/src/cmd/compile/internal/ssa/config.go index 75fa71ce35..4ffa047096 100644 --- a/src/cmd/compile/internal/ssa/config.go +++ b/src/cmd/compile/internal/ssa/config.go @@ -9,8 +9,8 @@ import ( "cmd/compile/internal/ir" "cmd/compile/internal/types" "cmd/internal/obj" - "cmd/internal/objabi" "cmd/internal/src" + "internal/buildcfg" ) // A Config holds readonly compilation information. @@ -203,7 +203,7 @@ func NewConfig(arch string, types Types, ctxt *obj.Link, optimize bool) *Config c.floatParamRegs = paramFloatRegAMD64 c.FPReg = framepointerRegAMD64 c.LinkReg = linkRegAMD64 - c.hasGReg = objabi.Experiment.RegabiG + c.hasGReg = buildcfg.Experiment.RegabiG case "386": c.PtrSize = 4 c.RegSize = 4 @@ -238,7 +238,7 @@ func NewConfig(arch string, types Types, ctxt *obj.Link, optimize bool) *Config c.FPReg = framepointerRegARM64 c.LinkReg = linkRegARM64 c.hasGReg = true - c.noDuffDevice = objabi.GOOS == "darwin" || objabi.GOOS == "ios" // darwin linker cannot handle BR26 reloc with non-zero addend + c.noDuffDevice = buildcfg.GOOS == "darwin" || buildcfg.GOOS == "ios" // darwin linker cannot handle BR26 reloc with non-zero addend case "ppc64": c.BigEndian = true fallthrough @@ -336,7 +336,7 @@ func NewConfig(arch string, types Types, ctxt *obj.Link, optimize bool) *Config c.ABI1 = abi.NewABIConfig(len(c.intParamRegs), len(c.floatParamRegs), ctxt.FixedFrameSize()) // On Plan 9, floating point operations are not allowed in note handler. - if objabi.GOOS == "plan9" { + if buildcfg.GOOS == "plan9" { // Don't use FMA on Plan 9 c.UseFMA = false diff --git a/src/cmd/compile/internal/ssa/gen/AMD64.rules b/src/cmd/compile/internal/ssa/gen/AMD64.rules index 839d4a330e..7a88a488c0 100644 --- a/src/cmd/compile/internal/ssa/gen/AMD64.rules +++ b/src/cmd/compile/internal/ssa/gen/AMD64.rules @@ -460,7 +460,7 @@ (IsInBounds idx len) => (SETB (CMPQ idx len)) (IsSliceInBounds idx len) => (SETBE (CMPQ idx len)) (NilCheck ...) => (LoweredNilCheck ...) -(GetG mem) && !(objabi.Experiment.RegabiG && v.Block.Func.OwnAux.Fn.ABI() == obj.ABIInternal) => (LoweredGetG mem) // only lower in old ABI. in new ABI we have a G register. +(GetG mem) && !(buildcfg.Experiment.RegabiG && v.Block.Func.OwnAux.Fn.ABI() == obj.ABIInternal) => (LoweredGetG mem) // only lower in old ABI. in new ABI we have a G register. (GetClosurePtr ...) => (LoweredGetClosurePtr ...) (GetCallerPC ...) => (LoweredGetCallerPC ...) (GetCallerSP ...) => (LoweredGetCallerSP ...) diff --git a/src/cmd/compile/internal/ssa/gen/ARM.rules b/src/cmd/compile/internal/ssa/gen/ARM.rules index 5c6438a986..bcacbafe3a 100644 --- a/src/cmd/compile/internal/ssa/gen/ARM.rules +++ b/src/cmd/compile/internal/ssa/gen/ARM.rules @@ -66,17 +66,17 @@ // count trailing zero for ARMv5 and ARMv6 // 32 - CLZ(x&-x - 1) -(Ctz32 <t> x) && objabi.GOARM<=6 => +(Ctz32 <t> x) && buildcfg.GOARM<=6 => (RSBconst [32] (CLZ <t> (SUBconst <t> (AND <t> x (RSBconst <t> [0] x)) [1]))) -(Ctz16 <t> x) && objabi.GOARM<=6 => +(Ctz16 <t> x) && buildcfg.GOARM<=6 => (RSBconst [32] (CLZ <t> (SUBconst <typ.UInt32> (AND <typ.UInt32> (ORconst <typ.UInt32> [0x10000] x) (RSBconst <typ.UInt32> [0] (ORconst <typ.UInt32> [0x10000] x))) [1]))) -(Ctz8 <t> x) && objabi.GOARM<=6 => +(Ctz8 <t> x) && buildcfg.GOARM<=6 => (RSBconst [32] (CLZ <t> (SUBconst <typ.UInt32> (AND <typ.UInt32> (ORconst <typ.UInt32> [0x100] x) (RSBconst <typ.UInt32> [0] (ORconst <typ.UInt32> [0x100] x))) [1]))) // count trailing zero for ARMv7 -(Ctz32 <t> x) && objabi.GOARM==7 => (CLZ <t> (RBIT <t> x)) -(Ctz16 <t> x) && objabi.GOARM==7 => (CLZ <t> (RBIT <typ.UInt32> (ORconst <typ.UInt32> [0x10000] x))) -(Ctz8 <t> x) && objabi.GOARM==7 => (CLZ <t> (RBIT <typ.UInt32> (ORconst <typ.UInt32> [0x100] x))) +(Ctz32 <t> x) && buildcfg.GOARM==7 => (CLZ <t> (RBIT <t> x)) +(Ctz16 <t> x) && buildcfg.GOARM==7 => (CLZ <t> (RBIT <typ.UInt32> (ORconst <typ.UInt32> [0x10000] x))) +(Ctz8 <t> x) && buildcfg.GOARM==7 => (CLZ <t> (RBIT <typ.UInt32> (ORconst <typ.UInt32> [0x100] x))) // bit length (BitLen32 <t> x) => (RSBconst [32] (CLZ <t> x)) @@ -90,13 +90,13 @@ // t5 = x right rotate 8 bits -- (d, a, b, c ) // result = t4 ^ t5 -- (d, c, b, a ) // using shifted ops this can be done in 4 instructions. -(Bswap32 <t> x) && objabi.GOARM==5 => +(Bswap32 <t> x) && buildcfg.GOARM==5 => (XOR <t> (SRLconst <t> (BICconst <t> (XOR <t> x (SRRconst <t> [16] x)) [0xff0000]) [8]) (SRRconst <t> x [8])) // byte swap for ARMv6 and above -(Bswap32 x) && objabi.GOARM>=6 => (REV x) +(Bswap32 x) && buildcfg.GOARM>=6 => (REV x) // boolean ops -- booleans are represented with 0=false, 1=true (AndB ...) => (AND ...) @@ -737,10 +737,10 @@ (SUBconst [c] x) && !isARMImmRot(uint32(c)) && isARMImmRot(uint32(-c)) => (ADDconst [-c] x) (ANDconst [c] x) && !isARMImmRot(uint32(c)) && isARMImmRot(^uint32(c)) => (BICconst [int32(^uint32(c))] x) (BICconst [c] x) && !isARMImmRot(uint32(c)) && isARMImmRot(^uint32(c)) => (ANDconst [int32(^uint32(c))] x) -(ADDconst [c] x) && objabi.GOARM==7 && !isARMImmRot(uint32(c)) && uint32(c)>0xffff && uint32(-c)<=0xffff => (SUBconst [-c] x) -(SUBconst [c] x) && objabi.GOARM==7 && !isARMImmRot(uint32(c)) && uint32(c)>0xffff && uint32(-c)<=0xffff => (ADDconst [-c] x) -(ANDconst [c] x) && objabi.GOARM==7 && !isARMImmRot(uint32(c)) && uint32(c)>0xffff && ^uint32(c)<=0xffff => (BICconst [int32(^uint32(c))] x) -(BICconst [c] x) && objabi.GOARM==7 && !isARMImmRot(uint32(c)) && uint32(c)>0xffff && ^uint32(c)<=0xffff => (ANDconst [int32(^uint32(c))] x) +(ADDconst [c] x) && buildcfg.GOARM==7 && !isARMImmRot(uint32(c)) && uint32(c)>0xffff && uint32(-c)<=0xffff => (SUBconst [-c] x) +(SUBconst [c] x) && buildcfg.GOARM==7 && !isARMImmRot(uint32(c)) && uint32(c)>0xffff && uint32(-c)<=0xffff => (ADDconst [-c] x) +(ANDconst [c] x) && buildcfg.GOARM==7 && !isARMImmRot(uint32(c)) && uint32(c)>0xffff && ^uint32(c)<=0xffff => (BICconst [int32(^uint32(c))] x) +(BICconst [c] x) && buildcfg.GOARM==7 && !isARMImmRot(uint32(c)) && uint32(c)>0xffff && ^uint32(c)<=0xffff => (ANDconst [int32(^uint32(c))] x) (ADDconst [c] (MOVWconst [d])) => (MOVWconst [c+d]) (ADDconst [c] (ADDconst [d] x)) => (ADDconst [c+d] x) (ADDconst [c] (SUBconst [d] x)) => (ADDconst [c-d] x) @@ -1144,7 +1144,7 @@ // UBFX instruction is supported by ARMv6T2, ARMv7 and above versions, REV16 is supported by // ARMv6 and above versions. So for ARMv6, we need to match SLLconst, SRLconst and ORshiftLL. ((ADDshiftLL|ORshiftLL|XORshiftLL) <typ.UInt16> [8] (BFXU <typ.UInt16> [int32(armBFAuxInt(8, 8))] x) x) => (REV16 x) -((ADDshiftLL|ORshiftLL|XORshiftLL) <typ.UInt16> [8] (SRLconst <typ.UInt16> [24] (SLLconst [16] x)) x) && objabi.GOARM>=6 => (REV16 x) +((ADDshiftLL|ORshiftLL|XORshiftLL) <typ.UInt16> [8] (SRLconst <typ.UInt16> [24] (SLLconst [16] x)) x) && buildcfg.GOARM>=6 => (REV16 x) // use indexed loads and stores (MOVWload [0] {sym} (ADD ptr idx) mem) && sym == nil => (MOVWloadidx ptr idx mem) @@ -1214,25 +1214,25 @@ (BIC x x) => (MOVWconst [0]) (ADD (MUL x y) a) => (MULA x y a) -(SUB a (MUL x y)) && objabi.GOARM == 7 => (MULS x y a) -(RSB (MUL x y) a) && objabi.GOARM == 7 => (MULS x y a) +(SUB a (MUL x y)) && buildcfg.GOARM == 7 => (MULS x y a) +(RSB (MUL x y) a) && buildcfg.GOARM == 7 => (MULS x y a) -(NEGF (MULF x y)) && objabi.GOARM >= 6 => (NMULF x y) -(NEGD (MULD x y)) && objabi.GOARM >= 6 => (NMULD x y) -(MULF (NEGF x) y) && objabi.GOARM >= 6 => (NMULF x y) -(MULD (NEGD x) y) && objabi.GOARM >= 6 => (NMULD x y) +(NEGF (MULF x y)) && buildcfg.GOARM >= 6 => (NMULF x y) +(NEGD (MULD x y)) && buildcfg.GOARM >= 6 => (NMULD x y) +(MULF (NEGF x) y) && buildcfg.GOARM >= 6 => (NMULF x y) +(MULD (NEGD x) y) && buildcfg.GOARM >= 6 => (NMULD x y) (NMULF (NEGF x) y) => (MULF x y) (NMULD (NEGD x) y) => (MULD x y) // the result will overwrite the addend, since they are in the same register -(ADDF a (MULF x y)) && a.Uses == 1 && objabi.GOARM >= 6 => (MULAF a x y) -(ADDF a (NMULF x y)) && a.Uses == 1 && objabi.GOARM >= 6 => (MULSF a x y) -(ADDD a (MULD x y)) && a.Uses == 1 && objabi.GOARM >= 6 => (MULAD a x y) -(ADDD a (NMULD x y)) && a.Uses == 1 && objabi.GOARM >= 6 => (MULSD a x y) -(SUBF a (MULF x y)) && a.Uses == 1 && objabi.GOARM >= 6 => (MULSF a x y) -(SUBF a (NMULF x y)) && a.Uses == 1 && objabi.GOARM >= 6 => (MULAF a x y) -(SUBD a (MULD x y)) && a.Uses == 1 && objabi.GOARM >= 6 => (MULSD a x y) -(SUBD a (NMULD x y)) && a.Uses == 1 && objabi.GOARM >= 6 => (MULAD a x y) +(ADDF a (MULF x y)) && a.Uses == 1 && buildcfg.GOARM >= 6 => (MULAF a x y) +(ADDF a (NMULF x y)) && a.Uses == 1 && buildcfg.GOARM >= 6 => (MULSF a x y) +(ADDD a (MULD x y)) && a.Uses == 1 && buildcfg.GOARM >= 6 => (MULAD a x y) +(ADDD a (NMULD x y)) && a.Uses == 1 && buildcfg.GOARM >= 6 => (MULSD a x y) +(SUBF a (MULF x y)) && a.Uses == 1 && buildcfg.GOARM >= 6 => (MULSF a x y) +(SUBF a (NMULF x y)) && a.Uses == 1 && buildcfg.GOARM >= 6 => (MULAF a x y) +(SUBD a (MULD x y)) && a.Uses == 1 && buildcfg.GOARM >= 6 => (MULSD a x y) +(SUBD a (NMULD x y)) && a.Uses == 1 && buildcfg.GOARM >= 6 => (MULAD a x y) (AND x (MVN y)) => (BIC x y) @@ -1264,8 +1264,8 @@ (CMPD x (MOVDconst [0])) => (CMPD0 x) // bit extraction -(SRAconst (SLLconst x [c]) [d]) && objabi.GOARM==7 && uint64(d)>=uint64(c) && uint64(d)<=31 => (BFX [(d-c)|(32-d)<<8] x) -(SRLconst (SLLconst x [c]) [d]) && objabi.GOARM==7 && uint64(d)>=uint64(c) && uint64(d)<=31 => (BFXU [(d-c)|(32-d)<<8] x) +(SRAconst (SLLconst x [c]) [d]) && buildcfg.GOARM==7 && uint64(d)>=uint64(c) && uint64(d)<=31 => (BFX [(d-c)|(32-d)<<8] x) +(SRLconst (SLLconst x [c]) [d]) && buildcfg.GOARM==7 && uint64(d)>=uint64(c) && uint64(d)<=31 => (BFXU [(d-c)|(32-d)<<8] x) // comparison simplification ((LT|LE|EQ|NE|GE|GT) (CMP x (RSBconst [0] y))) => ((LT|LE|EQ|NE|GE|GT) (CMN x y)) // sense of carry bit not preserved diff --git a/src/cmd/compile/internal/ssa/gen/PPC64.rules b/src/cmd/compile/internal/ssa/gen/PPC64.rules index f83ff75761..ce4b324b5e 100644 --- a/src/cmd/compile/internal/ssa/gen/PPC64.rules +++ b/src/cmd/compile/internal/ssa/gen/PPC64.rules @@ -12,20 +12,20 @@ (Sub64F ...) => (FSUB ...) // Combine 64 bit integer multiply and adds -(ADD l:(MULLD x y) z) && objabi.GOPPC64 >= 9 && l.Uses == 1 && clobber(l) => (MADDLD x y z) +(ADD l:(MULLD x y) z) && buildcfg.GOPPC64 >= 9 && l.Uses == 1 && clobber(l) => (MADDLD x y z) (Mod16 x y) => (Mod32 (SignExt16to32 x) (SignExt16to32 y)) (Mod16u x y) => (Mod32u (ZeroExt16to32 x) (ZeroExt16to32 y)) (Mod8 x y) => (Mod32 (SignExt8to32 x) (SignExt8to32 y)) (Mod8u x y) => (Mod32u (ZeroExt8to32 x) (ZeroExt8to32 y)) -(Mod64 x y) && objabi.GOPPC64 >=9 => (MODSD x y) -(Mod64 x y) && objabi.GOPPC64 <=8 => (SUB x (MULLD y (DIVD x y))) -(Mod64u x y) && objabi.GOPPC64 >= 9 => (MODUD x y) -(Mod64u x y) && objabi.GOPPC64 <= 8 => (SUB x (MULLD y (DIVDU x y))) -(Mod32 x y) && objabi.GOPPC64 >= 9 => (MODSW x y) -(Mod32 x y) && objabi.GOPPC64 <= 8 => (SUB x (MULLW y (DIVW x y))) -(Mod32u x y) && objabi.GOPPC64 >= 9 => (MODUW x y) -(Mod32u x y) && objabi.GOPPC64 <= 8 => (SUB x (MULLW y (DIVWU x y))) +(Mod64 x y) && buildcfg.GOPPC64 >=9 => (MODSD x y) +(Mod64 x y) && buildcfg.GOPPC64 <=8 => (SUB x (MULLD y (DIVD x y))) +(Mod64u x y) && buildcfg.GOPPC64 >= 9 => (MODUD x y) +(Mod64u x y) && buildcfg.GOPPC64 <= 8 => (SUB x (MULLD y (DIVDU x y))) +(Mod32 x y) && buildcfg.GOPPC64 >= 9 => (MODSW x y) +(Mod32 x y) && buildcfg.GOPPC64 <= 8 => (SUB x (MULLW y (DIVW x y))) +(Mod32u x y) && buildcfg.GOPPC64 >= 9 => (MODUW x y) +(Mod32u x y) && buildcfg.GOPPC64 <= 8 => (SUB x (MULLW y (DIVWU x y))) // (x + y) / 2 with x>=y => (x - y) / 2 + y (Avg64u <t> x y) => (ADD (SRDconst <t> (SUB <t> x y) [1]) y) @@ -351,9 +351,9 @@ (Ctz32NonZero ...) => (Ctz32 ...) (Ctz64NonZero ...) => (Ctz64 ...) -(Ctz64 x) && objabi.GOPPC64<=8 => (POPCNTD (ANDN <typ.Int64> (ADDconst <typ.Int64> [-1] x) x)) +(Ctz64 x) && buildcfg.GOPPC64<=8 => (POPCNTD (ANDN <typ.Int64> (ADDconst <typ.Int64> [-1] x) x)) (Ctz64 x) => (CNTTZD x) -(Ctz32 x) && objabi.GOPPC64<=8 => (POPCNTW (MOVWZreg (ANDN <typ.Int> (ADDconst <typ.Int> [-1] x) x))) +(Ctz32 x) && buildcfg.GOPPC64<=8 => (POPCNTW (MOVWZreg (ANDN <typ.Int> (ADDconst <typ.Int> [-1] x) x))) (Ctz32 x) => (CNTTZW (MOVWZreg x)) (Ctz16 x) => (POPCNTW (MOVHZreg (ANDN <typ.Int16> (ADDconst <typ.Int16> [-1] x) x))) (Ctz8 x) => (POPCNTB (MOVBZreg (ANDN <typ.UInt8> (ADDconst <typ.UInt8> [-1] x) x))) @@ -627,10 +627,10 @@ // Handle cases not handled above // Lowered Short cases do not generate loops, and as a result don't clobber // the address registers or flags. -(Zero [s] ptr mem) && objabi.GOPPC64 <= 8 && s < 64 => (LoweredZeroShort [s] ptr mem) -(Zero [s] ptr mem) && objabi.GOPPC64 <= 8 => (LoweredZero [s] ptr mem) -(Zero [s] ptr mem) && s < 128 && objabi.GOPPC64 >= 9 => (LoweredQuadZeroShort [s] ptr mem) -(Zero [s] ptr mem) && objabi.GOPPC64 >= 9 => (LoweredQuadZero [s] ptr mem) +(Zero [s] ptr mem) && buildcfg.GOPPC64 <= 8 && s < 64 => (LoweredZeroShort [s] ptr mem) +(Zero [s] ptr mem) && buildcfg.GOPPC64 <= 8 => (LoweredZero [s] ptr mem) +(Zero [s] ptr mem) && s < 128 && buildcfg.GOPPC64 >= 9 => (LoweredQuadZeroShort [s] ptr mem) +(Zero [s] ptr mem) && buildcfg.GOPPC64 >= 9 => (LoweredQuadZero [s] ptr mem) // moves (Move [0] _ _ mem) => mem @@ -658,11 +658,11 @@ // Large move uses a loop. Since the address is computed and the // offset is zero, any alignment can be used. -(Move [s] dst src mem) && s > 8 && objabi.GOPPC64 <= 8 && logLargeCopy(v, s) => +(Move [s] dst src mem) && s > 8 && buildcfg.GOPPC64 <= 8 && logLargeCopy(v, s) => (LoweredMove [s] dst src mem) -(Move [s] dst src mem) && s > 8 && s <= 64 && objabi.GOPPC64 >= 9 => +(Move [s] dst src mem) && s > 8 && s <= 64 && buildcfg.GOPPC64 >= 9 => (LoweredQuadMoveShort [s] dst src mem) -(Move [s] dst src mem) && s > 8 && objabi.GOPPC64 >= 9 && logLargeCopy(v, s) => +(Move [s] dst src mem) && s > 8 && buildcfg.GOPPC64 >= 9 && logLargeCopy(v, s) => (LoweredQuadMove [s] dst src mem) // Calls @@ -1048,7 +1048,7 @@ (SLWconst [c] z:(ANDconst [d] x)) && z.Uses == 1 && isPPC64ValidShiftMask(d) && c<=(32-getPPC64ShiftMaskLength(d)) => (CLRLSLWI [newPPC64ShiftAuxInt(c,32-getPPC64ShiftMaskLength(d),31,32)] x) (SLWconst [c] z:(AND (MOVDconst [d]) x)) && z.Uses == 1 && isPPC64ValidShiftMask(d) && c<=(32-getPPC64ShiftMaskLength(d)) => (CLRLSLWI [newPPC64ShiftAuxInt(c,32-getPPC64ShiftMaskLength(d),31,32)] x) // special case for power9 -(SL(W|D)const [c] z:(MOVWreg x)) && c < 32 && objabi.GOPPC64 >= 9 => (EXTSWSLconst [c] x) +(SL(W|D)const [c] z:(MOVWreg x)) && c < 32 && buildcfg.GOPPC64 >= 9 => (EXTSWSLconst [c] x) // Lose widening ops fed to stores (MOVBstore [off] {sym} ptr (MOV(B|BZ|H|HZ|W|WZ)reg x) mem) => (MOVBstore [off] {sym} ptr x mem) diff --git a/src/cmd/compile/internal/ssa/gen/Wasm.rules b/src/cmd/compile/internal/ssa/gen/Wasm.rules index 7cda16b4b5..7ad3d1c72e 100644 --- a/src/cmd/compile/internal/ssa/gen/Wasm.rules +++ b/src/cmd/compile/internal/ssa/gen/Wasm.rules @@ -55,9 +55,9 @@ (ZeroExt32to64 x:(I64Load32U _ _)) => x (ZeroExt16to(64|32) x:(I64Load16U _ _)) => x (ZeroExt8to(64|32|16) x:(I64Load8U _ _)) => x -(SignExt32to64 x) && objabi.GOWASM.SignExt => (I64Extend32S x) -(SignExt8to(64|32|16) x) && objabi.GOWASM.SignExt => (I64Extend8S x) -(SignExt16to(64|32) x) && objabi.GOWASM.SignExt => (I64Extend16S x) +(SignExt32to64 x) && buildcfg.GOWASM.SignExt => (I64Extend32S x) +(SignExt8to(64|32|16) x) && buildcfg.GOWASM.SignExt => (I64Extend8S x) +(SignExt16to(64|32) x) && buildcfg.GOWASM.SignExt => (I64Extend16S x) (SignExt32to64 x) => (I64ShrS (I64Shl x (I64Const [32])) (I64Const [32])) (SignExt16to(64|32) x) => (I64ShrS (I64Shl x (I64Const [48])) (I64Const [48])) (SignExt8to(64|32|16) x) => (I64ShrS (I64Shl x (I64Const [56])) (I64Const [56])) diff --git a/src/cmd/compile/internal/ssa/gen/rulegen.go b/src/cmd/compile/internal/ssa/gen/rulegen.go index fd672b2f74..fe8db4ed1f 100644 --- a/src/cmd/compile/internal/ssa/gen/rulegen.go +++ b/src/cmd/compile/internal/ssa/gen/rulegen.go @@ -584,9 +584,9 @@ func fprint(w io.Writer, n Node) { fmt.Fprintf(w, "\npackage ssa\n") for _, path := range append([]string{ "fmt", + "internal/buildcfg", "math", "cmd/internal/obj", - "cmd/internal/objabi", "cmd/compile/internal/base", "cmd/compile/internal/types", }, n.Arch.imports...) { diff --git a/src/cmd/compile/internal/ssa/nilcheck.go b/src/cmd/compile/internal/ssa/nilcheck.go index bae50657c9..14f511a5f1 100644 --- a/src/cmd/compile/internal/ssa/nilcheck.go +++ b/src/cmd/compile/internal/ssa/nilcheck.go @@ -6,8 +6,8 @@ package ssa import ( "cmd/compile/internal/ir" - "cmd/internal/objabi" "cmd/internal/src" + "internal/buildcfg" ) // nilcheckelim eliminates unnecessary nil checks. @@ -192,7 +192,7 @@ func nilcheckelim(f *Func) { const minZeroPage = 4096 // faultOnLoad is true if a load to an address below minZeroPage will trigger a SIGSEGV. -var faultOnLoad = objabi.GOOS != "aix" +var faultOnLoad = buildcfg.GOOS != "aix" // nilcheckelim2 eliminates unnecessary nil checks. // Runs after lowering and scheduling. diff --git a/src/cmd/compile/internal/ssa/regalloc.go b/src/cmd/compile/internal/ssa/regalloc.go index 1baff184b0..336cd3d737 100644 --- a/src/cmd/compile/internal/ssa/regalloc.go +++ b/src/cmd/compile/internal/ssa/regalloc.go @@ -117,10 +117,10 @@ import ( "cmd/compile/internal/base" "cmd/compile/internal/ir" "cmd/compile/internal/types" - "cmd/internal/objabi" "cmd/internal/src" "cmd/internal/sys" "fmt" + "internal/buildcfg" "math/bits" "unsafe" ) @@ -609,7 +609,7 @@ func (s *regAllocState) init(f *Func) { if s.f.Config.hasGReg { s.allocatable &^= 1 << s.GReg } - if objabi.FramePointerEnabled && s.f.Config.FPReg >= 0 { + if buildcfg.FramePointerEnabled && s.f.Config.FPReg >= 0 { s.allocatable &^= 1 << uint(s.f.Config.FPReg) } if s.f.Config.LinkReg != -1 { diff --git a/src/cmd/compile/internal/ssa/rewrite386.go b/src/cmd/compile/internal/ssa/rewrite386.go index 1ec2d26f75..93b258afac 100644 --- a/src/cmd/compile/internal/ssa/rewrite386.go +++ b/src/cmd/compile/internal/ssa/rewrite386.go @@ -3,8 +3,10 @@ package ssa -import "math" -import "cmd/compile/internal/types" +import ( + "cmd/compile/internal/types" + "math" +) func rewriteValue386(v *Value) bool { switch v.Op { diff --git a/src/cmd/compile/internal/ssa/rewriteAMD64.go b/src/cmd/compile/internal/ssa/rewriteAMD64.go index 1f56b70816..dd92b41c20 100644 --- a/src/cmd/compile/internal/ssa/rewriteAMD64.go +++ b/src/cmd/compile/internal/ssa/rewriteAMD64.go @@ -3,10 +3,12 @@ package ssa -import "math" -import "cmd/internal/obj" -import "cmd/internal/objabi" -import "cmd/compile/internal/types" +import ( + "cmd/compile/internal/types" + "cmd/internal/obj" + "internal/buildcfg" + "math" +) func rewriteValueAMD64(v *Value) bool { switch v.Op { @@ -30466,11 +30468,11 @@ func rewriteValueAMD64_OpFloor(v *Value) bool { func rewriteValueAMD64_OpGetG(v *Value) bool { v_0 := v.Args[0] // match: (GetG mem) - // cond: !(objabi.Experiment.RegabiG && v.Block.Func.OwnAux.Fn.ABI() == obj.ABIInternal) + // cond: !(buildcfg.Experiment.RegabiG && v.Block.Func.OwnAux.Fn.ABI() == obj.ABIInternal) // result: (LoweredGetG mem) for { mem := v_0 - if !(!(objabi.Experiment.RegabiG && v.Block.Func.OwnAux.Fn.ABI() == obj.ABIInternal)) { + if !(!(buildcfg.Experiment.RegabiG && v.Block.Func.OwnAux.Fn.ABI() == obj.ABIInternal)) { break } v.reset(OpAMD64LoweredGetG) diff --git a/src/cmd/compile/internal/ssa/rewriteARM.go b/src/cmd/compile/internal/ssa/rewriteARM.go index 175bbc3e7e..25db5b9fba 100644 --- a/src/cmd/compile/internal/ssa/rewriteARM.go +++ b/src/cmd/compile/internal/ssa/rewriteARM.go @@ -3,8 +3,10 @@ package ssa -import "cmd/internal/objabi" -import "cmd/compile/internal/types" +import ( + "cmd/compile/internal/types" + "internal/buildcfg" +) func rewriteValueARM(v *Value) bool { switch v.Op { @@ -1475,7 +1477,7 @@ func rewriteValueARM_OpARMADDD(v *Value) bool { v_1 := v.Args[1] v_0 := v.Args[0] // match: (ADDD a (MULD x y)) - // cond: a.Uses == 1 && objabi.GOARM >= 6 + // cond: a.Uses == 1 && buildcfg.GOARM >= 6 // result: (MULAD a x y) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { @@ -1485,7 +1487,7 @@ func rewriteValueARM_OpARMADDD(v *Value) bool { } y := v_1.Args[1] x := v_1.Args[0] - if !(a.Uses == 1 && objabi.GOARM >= 6) { + if !(a.Uses == 1 && buildcfg.GOARM >= 6) { continue } v.reset(OpARMMULAD) @@ -1495,7 +1497,7 @@ func rewriteValueARM_OpARMADDD(v *Value) bool { break } // match: (ADDD a (NMULD x y)) - // cond: a.Uses == 1 && objabi.GOARM >= 6 + // cond: a.Uses == 1 && buildcfg.GOARM >= 6 // result: (MULSD a x y) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { @@ -1505,7 +1507,7 @@ func rewriteValueARM_OpARMADDD(v *Value) bool { } y := v_1.Args[1] x := v_1.Args[0] - if !(a.Uses == 1 && objabi.GOARM >= 6) { + if !(a.Uses == 1 && buildcfg.GOARM >= 6) { continue } v.reset(OpARMMULSD) @@ -1520,7 +1522,7 @@ func rewriteValueARM_OpARMADDF(v *Value) bool { v_1 := v.Args[1] v_0 := v.Args[0] // match: (ADDF a (MULF x y)) - // cond: a.Uses == 1 && objabi.GOARM >= 6 + // cond: a.Uses == 1 && buildcfg.GOARM >= 6 // result: (MULAF a x y) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { @@ -1530,7 +1532,7 @@ func rewriteValueARM_OpARMADDF(v *Value) bool { } y := v_1.Args[1] x := v_1.Args[0] - if !(a.Uses == 1 && objabi.GOARM >= 6) { + if !(a.Uses == 1 && buildcfg.GOARM >= 6) { continue } v.reset(OpARMMULAF) @@ -1540,7 +1542,7 @@ func rewriteValueARM_OpARMADDF(v *Value) bool { break } // match: (ADDF a (NMULF x y)) - // cond: a.Uses == 1 && objabi.GOARM >= 6 + // cond: a.Uses == 1 && buildcfg.GOARM >= 6 // result: (MULSF a x y) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { @@ -1550,7 +1552,7 @@ func rewriteValueARM_OpARMADDF(v *Value) bool { } y := v_1.Args[1] x := v_1.Args[0] - if !(a.Uses == 1 && objabi.GOARM >= 6) { + if !(a.Uses == 1 && buildcfg.GOARM >= 6) { continue } v.reset(OpARMMULSF) @@ -1946,12 +1948,12 @@ func rewriteValueARM_OpARMADDconst(v *Value) bool { return true } // match: (ADDconst [c] x) - // cond: objabi.GOARM==7 && !isARMImmRot(uint32(c)) && uint32(c)>0xffff && uint32(-c)<=0xffff + // cond: buildcfg.GOARM==7 && !isARMImmRot(uint32(c)) && uint32(c)>0xffff && uint32(-c)<=0xffff // result: (SUBconst [-c] x) for { c := auxIntToInt32(v.AuxInt) x := v_0 - if !(objabi.GOARM == 7 && !isARMImmRot(uint32(c)) && uint32(c) > 0xffff && uint32(-c) <= 0xffff) { + if !(buildcfg.GOARM == 7 && !isARMImmRot(uint32(c)) && uint32(c) > 0xffff && uint32(-c) <= 0xffff) { break } v.reset(OpARMSUBconst) @@ -2082,7 +2084,7 @@ func rewriteValueARM_OpARMADDshiftLL(v *Value) bool { return true } // match: (ADDshiftLL <typ.UInt16> [8] (SRLconst <typ.UInt16> [24] (SLLconst [16] x)) x) - // cond: objabi.GOARM>=6 + // cond: buildcfg.GOARM>=6 // result: (REV16 x) for { if v.Type != typ.UInt16 || auxIntToInt32(v.AuxInt) != 8 || v_0.Op != OpARMSRLconst || v_0.Type != typ.UInt16 || auxIntToInt32(v_0.AuxInt) != 24 { @@ -2093,7 +2095,7 @@ func rewriteValueARM_OpARMADDshiftLL(v *Value) bool { break } x := v_0_0.Args[0] - if x != v_1 || !(objabi.GOARM >= 6) { + if x != v_1 || !(buildcfg.GOARM >= 6) { break } v.reset(OpARMREV16) @@ -2538,12 +2540,12 @@ func rewriteValueARM_OpARMANDconst(v *Value) bool { return true } // match: (ANDconst [c] x) - // cond: objabi.GOARM==7 && !isARMImmRot(uint32(c)) && uint32(c)>0xffff && ^uint32(c)<=0xffff + // cond: buildcfg.GOARM==7 && !isARMImmRot(uint32(c)) && uint32(c)>0xffff && ^uint32(c)<=0xffff // result: (BICconst [int32(^uint32(c))] x) for { c := auxIntToInt32(v.AuxInt) x := v_0 - if !(objabi.GOARM == 7 && !isARMImmRot(uint32(c)) && uint32(c) > 0xffff && ^uint32(c) <= 0xffff) { + if !(buildcfg.GOARM == 7 && !isARMImmRot(uint32(c)) && uint32(c) > 0xffff && ^uint32(c) <= 0xffff) { break } v.reset(OpARMBICconst) @@ -3033,12 +3035,12 @@ func rewriteValueARM_OpARMBICconst(v *Value) bool { return true } // match: (BICconst [c] x) - // cond: objabi.GOARM==7 && !isARMImmRot(uint32(c)) && uint32(c)>0xffff && ^uint32(c)<=0xffff + // cond: buildcfg.GOARM==7 && !isARMImmRot(uint32(c)) && uint32(c)>0xffff && ^uint32(c)<=0xffff // result: (ANDconst [int32(^uint32(c))] x) for { c := auxIntToInt32(v.AuxInt) x := v_0 - if !(objabi.GOARM == 7 && !isARMImmRot(uint32(c)) && uint32(c) > 0xffff && ^uint32(c) <= 0xffff) { + if !(buildcfg.GOARM == 7 && !isARMImmRot(uint32(c)) && uint32(c) > 0xffff && ^uint32(c) <= 0xffff) { break } v.reset(OpARMANDconst) @@ -7541,7 +7543,7 @@ func rewriteValueARM_OpARMMULD(v *Value) bool { v_1 := v.Args[1] v_0 := v.Args[0] // match: (MULD (NEGD x) y) - // cond: objabi.GOARM >= 6 + // cond: buildcfg.GOARM >= 6 // result: (NMULD x y) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { @@ -7550,7 +7552,7 @@ func rewriteValueARM_OpARMMULD(v *Value) bool { } x := v_0.Args[0] y := v_1 - if !(objabi.GOARM >= 6) { + if !(buildcfg.GOARM >= 6) { continue } v.reset(OpARMNMULD) @@ -7565,7 +7567,7 @@ func rewriteValueARM_OpARMMULF(v *Value) bool { v_1 := v.Args[1] v_0 := v.Args[0] // match: (MULF (NEGF x) y) - // cond: objabi.GOARM >= 6 + // cond: buildcfg.GOARM >= 6 // result: (NMULF x y) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { @@ -7574,7 +7576,7 @@ func rewriteValueARM_OpARMMULF(v *Value) bool { } x := v_0.Args[0] y := v_1 - if !(objabi.GOARM >= 6) { + if !(buildcfg.GOARM >= 6) { continue } v.reset(OpARMNMULF) @@ -8186,7 +8188,7 @@ func rewriteValueARM_OpARMMVNshiftRLreg(v *Value) bool { func rewriteValueARM_OpARMNEGD(v *Value) bool { v_0 := v.Args[0] // match: (NEGD (MULD x y)) - // cond: objabi.GOARM >= 6 + // cond: buildcfg.GOARM >= 6 // result: (NMULD x y) for { if v_0.Op != OpARMMULD { @@ -8194,7 +8196,7 @@ func rewriteValueARM_OpARMNEGD(v *Value) bool { } y := v_0.Args[1] x := v_0.Args[0] - if !(objabi.GOARM >= 6) { + if !(buildcfg.GOARM >= 6) { break } v.reset(OpARMNMULD) @@ -8206,7 +8208,7 @@ func rewriteValueARM_OpARMNEGD(v *Value) bool { func rewriteValueARM_OpARMNEGF(v *Value) bool { v_0 := v.Args[0] // match: (NEGF (MULF x y)) - // cond: objabi.GOARM >= 6 + // cond: buildcfg.GOARM >= 6 // result: (NMULF x y) for { if v_0.Op != OpARMMULF { @@ -8214,7 +8216,7 @@ func rewriteValueARM_OpARMNEGF(v *Value) bool { } y := v_0.Args[1] x := v_0.Args[0] - if !(objabi.GOARM >= 6) { + if !(buildcfg.GOARM >= 6) { break } v.reset(OpARMNMULF) @@ -8538,7 +8540,7 @@ func rewriteValueARM_OpARMORshiftLL(v *Value) bool { return true } // match: (ORshiftLL <typ.UInt16> [8] (SRLconst <typ.UInt16> [24] (SLLconst [16] x)) x) - // cond: objabi.GOARM>=6 + // cond: buildcfg.GOARM>=6 // result: (REV16 x) for { if v.Type != typ.UInt16 || auxIntToInt32(v.AuxInt) != 8 || v_0.Op != OpARMSRLconst || v_0.Type != typ.UInt16 || auxIntToInt32(v_0.AuxInt) != 24 { @@ -8549,7 +8551,7 @@ func rewriteValueARM_OpARMORshiftLL(v *Value) bool { break } x := v_0_0.Args[0] - if x != v_1 || !(objabi.GOARM >= 6) { + if x != v_1 || !(buildcfg.GOARM >= 6) { break } v.reset(OpARMREV16) @@ -9013,7 +9015,7 @@ func rewriteValueARM_OpARMRSB(v *Value) bool { return true } // match: (RSB (MUL x y) a) - // cond: objabi.GOARM == 7 + // cond: buildcfg.GOARM == 7 // result: (MULS x y a) for { if v_0.Op != OpARMMUL { @@ -9022,7 +9024,7 @@ func rewriteValueARM_OpARMRSB(v *Value) bool { y := v_0.Args[1] x := v_0.Args[0] a := v_1 - if !(objabi.GOARM == 7) { + if !(buildcfg.GOARM == 7) { break } v.reset(OpARMMULS) @@ -10449,7 +10451,7 @@ func rewriteValueARM_OpARMSRAconst(v *Value) bool { return true } // match: (SRAconst (SLLconst x [c]) [d]) - // cond: objabi.GOARM==7 && uint64(d)>=uint64(c) && uint64(d)<=31 + // cond: buildcfg.GOARM==7 && uint64(d)>=uint64(c) && uint64(d)<=31 // result: (BFX [(d-c)|(32-d)<<8] x) for { d := auxIntToInt32(v.AuxInt) @@ -10458,7 +10460,7 @@ func rewriteValueARM_OpARMSRAconst(v *Value) bool { } c := auxIntToInt32(v_0.AuxInt) x := v_0.Args[0] - if !(objabi.GOARM == 7 && uint64(d) >= uint64(c) && uint64(d) <= 31) { + if !(buildcfg.GOARM == 7 && uint64(d) >= uint64(c) && uint64(d) <= 31) { break } v.reset(OpARMBFX) @@ -10501,7 +10503,7 @@ func rewriteValueARM_OpARMSRLconst(v *Value) bool { return true } // match: (SRLconst (SLLconst x [c]) [d]) - // cond: objabi.GOARM==7 && uint64(d)>=uint64(c) && uint64(d)<=31 + // cond: buildcfg.GOARM==7 && uint64(d)>=uint64(c) && uint64(d)<=31 // result: (BFXU [(d-c)|(32-d)<<8] x) for { d := auxIntToInt32(v.AuxInt) @@ -10510,7 +10512,7 @@ func rewriteValueARM_OpARMSRLconst(v *Value) bool { } c := auxIntToInt32(v_0.AuxInt) x := v_0.Args[0] - if !(objabi.GOARM == 7 && uint64(d) >= uint64(c) && uint64(d) <= 31) { + if !(buildcfg.GOARM == 7 && uint64(d) >= uint64(c) && uint64(d) <= 31) { break } v.reset(OpARMBFXU) @@ -10723,7 +10725,7 @@ func rewriteValueARM_OpARMSUB(v *Value) bool { return true } // match: (SUB a (MUL x y)) - // cond: objabi.GOARM == 7 + // cond: buildcfg.GOARM == 7 // result: (MULS x y a) for { a := v_0 @@ -10732,7 +10734,7 @@ func rewriteValueARM_OpARMSUB(v *Value) bool { } y := v_1.Args[1] x := v_1.Args[0] - if !(objabi.GOARM == 7) { + if !(buildcfg.GOARM == 7) { break } v.reset(OpARMMULS) @@ -10745,7 +10747,7 @@ func rewriteValueARM_OpARMSUBD(v *Value) bool { v_1 := v.Args[1] v_0 := v.Args[0] // match: (SUBD a (MULD x y)) - // cond: a.Uses == 1 && objabi.GOARM >= 6 + // cond: a.Uses == 1 && buildcfg.GOARM >= 6 // result: (MULSD a x y) for { a := v_0 @@ -10754,7 +10756,7 @@ func rewriteValueARM_OpARMSUBD(v *Value) bool { } y := v_1.Args[1] x := v_1.Args[0] - if !(a.Uses == 1 && objabi.GOARM >= 6) { + if !(a.Uses == 1 && buildcfg.GOARM >= 6) { break } v.reset(OpARMMULSD) @@ -10762,7 +10764,7 @@ func rewriteValueARM_OpARMSUBD(v *Value) bool { return true } // match: (SUBD a (NMULD x y)) - // cond: a.Uses == 1 && objabi.GOARM >= 6 + // cond: a.Uses == 1 && buildcfg.GOARM >= 6 // result: (MULAD a x y) for { a := v_0 @@ -10771,7 +10773,7 @@ func rewriteValueARM_OpARMSUBD(v *Value) bool { } y := v_1.Args[1] x := v_1.Args[0] - if !(a.Uses == 1 && objabi.GOARM >= 6) { + if !(a.Uses == 1 && buildcfg.GOARM >= 6) { break } v.reset(OpARMMULAD) @@ -10784,7 +10786,7 @@ func rewriteValueARM_OpARMSUBF(v *Value) bool { v_1 := v.Args[1] v_0 := v.Args[0] // match: (SUBF a (MULF x y)) - // cond: a.Uses == 1 && objabi.GOARM >= 6 + // cond: a.Uses == 1 && buildcfg.GOARM >= 6 // result: (MULSF a x y) for { a := v_0 @@ -10793,7 +10795,7 @@ func rewriteValueARM_OpARMSUBF(v *Value) bool { } y := v_1.Args[1] x := v_1.Args[0] - if !(a.Uses == 1 && objabi.GOARM >= 6) { + if !(a.Uses == 1 && buildcfg.GOARM >= 6) { break } v.reset(OpARMMULSF) @@ -10801,7 +10803,7 @@ func rewriteValueARM_OpARMSUBF(v *Value) bool { return true } // match: (SUBF a (NMULF x y)) - // cond: a.Uses == 1 && objabi.GOARM >= 6 + // cond: a.Uses == 1 && buildcfg.GOARM >= 6 // result: (MULAF a x y) for { a := v_0 @@ -10810,7 +10812,7 @@ func rewriteValueARM_OpARMSUBF(v *Value) bool { } y := v_1.Args[1] x := v_1.Args[0] - if !(a.Uses == 1 && objabi.GOARM >= 6) { + if !(a.Uses == 1 && buildcfg.GOARM >= 6) { break } v.reset(OpARMMULAF) @@ -11264,12 +11266,12 @@ func rewriteValueARM_OpARMSUBconst(v *Value) bool { return true } // match: (SUBconst [c] x) - // cond: objabi.GOARM==7 && !isARMImmRot(uint32(c)) && uint32(c)>0xffff && uint32(-c)<=0xffff + // cond: buildcfg.GOARM==7 && !isARMImmRot(uint32(c)) && uint32(c)>0xffff && uint32(-c)<=0xffff // result: (ADDconst [-c] x) for { c := auxIntToInt32(v.AuxInt) x := v_0 - if !(objabi.GOARM == 7 && !isARMImmRot(uint32(c)) && uint32(c) > 0xffff && uint32(-c) <= 0xffff) { + if !(buildcfg.GOARM == 7 && !isARMImmRot(uint32(c)) && uint32(c) > 0xffff && uint32(-c) <= 0xffff) { break } v.reset(OpARMADDconst) @@ -12577,7 +12579,7 @@ func rewriteValueARM_OpARMXORshiftLL(v *Value) bool { return true } // match: (XORshiftLL <typ.UInt16> [8] (SRLconst <typ.UInt16> [24] (SLLconst [16] x)) x) - // cond: objabi.GOARM>=6 + // cond: buildcfg.GOARM>=6 // result: (REV16 x) for { if v.Type != typ.UInt16 || auxIntToInt32(v.AuxInt) != 8 || v_0.Op != OpARMSRLconst || v_0.Type != typ.UInt16 || auxIntToInt32(v_0.AuxInt) != 24 { @@ -12588,7 +12590,7 @@ func rewriteValueARM_OpARMXORshiftLL(v *Value) bool { break } x := v_0_0.Args[0] - if x != v_1 || !(objabi.GOARM >= 6) { + if x != v_1 || !(buildcfg.GOARM >= 6) { break } v.reset(OpARMREV16) @@ -12939,12 +12941,12 @@ func rewriteValueARM_OpBswap32(v *Value) bool { v_0 := v.Args[0] b := v.Block // match: (Bswap32 <t> x) - // cond: objabi.GOARM==5 + // cond: buildcfg.GOARM==5 // result: (XOR <t> (SRLconst <t> (BICconst <t> (XOR <t> x (SRRconst <t> [16] x)) [0xff0000]) [8]) (SRRconst <t> x [8])) for { t := v.Type x := v_0 - if !(objabi.GOARM == 5) { + if !(buildcfg.GOARM == 5) { break } v.reset(OpARMXOR) @@ -12967,11 +12969,11 @@ func rewriteValueARM_OpBswap32(v *Value) bool { return true } // match: (Bswap32 x) - // cond: objabi.GOARM>=6 + // cond: buildcfg.GOARM>=6 // result: (REV x) for { x := v_0 - if !(objabi.GOARM >= 6) { + if !(buildcfg.GOARM >= 6) { break } v.reset(OpARMREV) @@ -13054,12 +13056,12 @@ func rewriteValueARM_OpCtz16(v *Value) bool { b := v.Block typ := &b.Func.Config.Types // match: (Ctz16 <t> x) - // cond: objabi.GOARM<=6 + // cond: buildcfg.GOARM<=6 // result: (RSBconst [32] (CLZ <t> (SUBconst <typ.UInt32> (AND <typ.UInt32> (ORconst <typ.UInt32> [0x10000] x) (RSBconst <typ.UInt32> [0] (ORconst <typ.UInt32> [0x10000] x))) [1]))) for { t := v.Type x := v_0 - if !(objabi.GOARM <= 6) { + if !(buildcfg.GOARM <= 6) { break } v.reset(OpARMRSBconst) @@ -13081,12 +13083,12 @@ func rewriteValueARM_OpCtz16(v *Value) bool { return true } // match: (Ctz16 <t> x) - // cond: objabi.GOARM==7 + // cond: buildcfg.GOARM==7 // result: (CLZ <t> (RBIT <typ.UInt32> (ORconst <typ.UInt32> [0x10000] x))) for { t := v.Type x := v_0 - if !(objabi.GOARM == 7) { + if !(buildcfg.GOARM == 7) { break } v.reset(OpARMCLZ) @@ -13105,12 +13107,12 @@ func rewriteValueARM_OpCtz32(v *Value) bool { v_0 := v.Args[0] b := v.Block // match: (Ctz32 <t> x) - // cond: objabi.GOARM<=6 + // cond: buildcfg.GOARM<=6 // result: (RSBconst [32] (CLZ <t> (SUBconst <t> (AND <t> x (RSBconst <t> [0] x)) [1]))) for { t := v.Type x := v_0 - if !(objabi.GOARM <= 6) { + if !(buildcfg.GOARM <= 6) { break } v.reset(OpARMRSBconst) @@ -13129,12 +13131,12 @@ func rewriteValueARM_OpCtz32(v *Value) bool { return true } // match: (Ctz32 <t> x) - // cond: objabi.GOARM==7 + // cond: buildcfg.GOARM==7 // result: (CLZ <t> (RBIT <t> x)) for { t := v.Type x := v_0 - if !(objabi.GOARM == 7) { + if !(buildcfg.GOARM == 7) { break } v.reset(OpARMCLZ) @@ -13151,12 +13153,12 @@ func rewriteValueARM_OpCtz8(v *Value) bool { b := v.Block typ := &b.Func.Config.Types // match: (Ctz8 <t> x) - // cond: objabi.GOARM<=6 + // cond: buildcfg.GOARM<=6 // result: (RSBconst [32] (CLZ <t> (SUBconst <typ.UInt32> (AND <typ.UInt32> (ORconst <typ.UInt32> [0x100] x) (RSBconst <typ.UInt32> [0] (ORconst <typ.UInt32> [0x100] x))) [1]))) for { t := v.Type x := v_0 - if !(objabi.GOARM <= 6) { + if !(buildcfg.GOARM <= 6) { break } v.reset(OpARMRSBconst) @@ -13178,12 +13180,12 @@ func rewriteValueARM_OpCtz8(v *Value) bool { return true } // match: (Ctz8 <t> x) - // cond: objabi.GOARM==7 + // cond: buildcfg.GOARM==7 // result: (CLZ <t> (RBIT <typ.UInt32> (ORconst <typ.UInt32> [0x100] x))) for { t := v.Type x := v_0 - if !(objabi.GOARM == 7) { + if !(buildcfg.GOARM == 7) { break } v.reset(OpARMCLZ) diff --git a/src/cmd/compile/internal/ssa/rewritePPC64.go b/src/cmd/compile/internal/ssa/rewritePPC64.go index f181d433cc..fe7620c218 100644 --- a/src/cmd/compile/internal/ssa/rewritePPC64.go +++ b/src/cmd/compile/internal/ssa/rewritePPC64.go @@ -3,9 +3,11 @@ package ssa -import "math" -import "cmd/internal/objabi" -import "cmd/compile/internal/types" +import ( + "cmd/compile/internal/types" + "internal/buildcfg" + "math" +) func rewriteValuePPC64(v *Value) bool { switch v.Op { @@ -1290,11 +1292,11 @@ func rewriteValuePPC64_OpCtz32(v *Value) bool { b := v.Block typ := &b.Func.Config.Types // match: (Ctz32 x) - // cond: objabi.GOPPC64<=8 + // cond: buildcfg.GOPPC64<=8 // result: (POPCNTW (MOVWZreg (ANDN <typ.Int> (ADDconst <typ.Int> [-1] x) x))) for { x := v_0 - if !(objabi.GOPPC64 <= 8) { + if !(buildcfg.GOPPC64 <= 8) { break } v.reset(OpPPC64POPCNTW) @@ -1324,11 +1326,11 @@ func rewriteValuePPC64_OpCtz64(v *Value) bool { b := v.Block typ := &b.Func.Config.Types // match: (Ctz64 x) - // cond: objabi.GOPPC64<=8 + // cond: buildcfg.GOPPC64<=8 // result: (POPCNTD (ANDN <typ.Int64> (ADDconst <typ.Int64> [-1] x) x)) for { x := v_0 - if !(objabi.GOPPC64 <= 8) { + if !(buildcfg.GOPPC64 <= 8) { break } v.reset(OpPPC64POPCNTD) @@ -3286,12 +3288,12 @@ func rewriteValuePPC64_OpMod32(v *Value) bool { b := v.Block typ := &b.Func.Config.Types // match: (Mod32 x y) - // cond: objabi.GOPPC64 >= 9 + // cond: buildcfg.GOPPC64 >= 9 // result: (MODSW x y) for { x := v_0 y := v_1 - if !(objabi.GOPPC64 >= 9) { + if !(buildcfg.GOPPC64 >= 9) { break } v.reset(OpPPC64MODSW) @@ -3299,12 +3301,12 @@ func rewriteValuePPC64_OpMod32(v *Value) bool { return true } // match: (Mod32 x y) - // cond: objabi.GOPPC64 <= 8 + // cond: buildcfg.GOPPC64 <= 8 // result: (SUB x (MULLW y (DIVW x y))) for { x := v_0 y := v_1 - if !(objabi.GOPPC64 <= 8) { + if !(buildcfg.GOPPC64 <= 8) { break } v.reset(OpPPC64SUB) @@ -3323,12 +3325,12 @@ func rewriteValuePPC64_OpMod32u(v *Value) bool { b := v.Block typ := &b.Func.Config.Types // match: (Mod32u x y) - // cond: objabi.GOPPC64 >= 9 + // cond: buildcfg.GOPPC64 >= 9 // result: (MODUW x y) for { x := v_0 y := v_1 - if !(objabi.GOPPC64 >= 9) { + if !(buildcfg.GOPPC64 >= 9) { break } v.reset(OpPPC64MODUW) @@ -3336,12 +3338,12 @@ func rewriteValuePPC64_OpMod32u(v *Value) bool { return true } // match: (Mod32u x y) - // cond: objabi.GOPPC64 <= 8 + // cond: buildcfg.GOPPC64 <= 8 // result: (SUB x (MULLW y (DIVWU x y))) for { x := v_0 y := v_1 - if !(objabi.GOPPC64 <= 8) { + if !(buildcfg.GOPPC64 <= 8) { break } v.reset(OpPPC64SUB) @@ -3360,12 +3362,12 @@ func rewriteValuePPC64_OpMod64(v *Value) bool { b := v.Block typ := &b.Func.Config.Types // match: (Mod64 x y) - // cond: objabi.GOPPC64 >=9 + // cond: buildcfg.GOPPC64 >=9 // result: (MODSD x y) for { x := v_0 y := v_1 - if !(objabi.GOPPC64 >= 9) { + if !(buildcfg.GOPPC64 >= 9) { break } v.reset(OpPPC64MODSD) @@ -3373,12 +3375,12 @@ func rewriteValuePPC64_OpMod64(v *Value) bool { return true } // match: (Mod64 x y) - // cond: objabi.GOPPC64 <=8 + // cond: buildcfg.GOPPC64 <=8 // result: (SUB x (MULLD y (DIVD x y))) for { x := v_0 y := v_1 - if !(objabi.GOPPC64 <= 8) { + if !(buildcfg.GOPPC64 <= 8) { break } v.reset(OpPPC64SUB) @@ -3397,12 +3399,12 @@ func rewriteValuePPC64_OpMod64u(v *Value) bool { b := v.Block typ := &b.Func.Config.Types // match: (Mod64u x y) - // cond: objabi.GOPPC64 >= 9 + // cond: buildcfg.GOPPC64 >= 9 // result: (MODUD x y) for { x := v_0 y := v_1 - if !(objabi.GOPPC64 >= 9) { + if !(buildcfg.GOPPC64 >= 9) { break } v.reset(OpPPC64MODUD) @@ -3410,12 +3412,12 @@ func rewriteValuePPC64_OpMod64u(v *Value) bool { return true } // match: (Mod64u x y) - // cond: objabi.GOPPC64 <= 8 + // cond: buildcfg.GOPPC64 <= 8 // result: (SUB x (MULLD y (DIVDU x y))) for { x := v_0 y := v_1 - if !(objabi.GOPPC64 <= 8) { + if !(buildcfg.GOPPC64 <= 8) { break } v.reset(OpPPC64SUB) @@ -3633,14 +3635,14 @@ func rewriteValuePPC64_OpMove(v *Value) bool { return true } // match: (Move [s] dst src mem) - // cond: s > 8 && objabi.GOPPC64 <= 8 && logLargeCopy(v, s) + // cond: s > 8 && buildcfg.GOPPC64 <= 8 && logLargeCopy(v, s) // result: (LoweredMove [s] dst src mem) for { s := auxIntToInt64(v.AuxInt) dst := v_0 src := v_1 mem := v_2 - if !(s > 8 && objabi.GOPPC64 <= 8 && logLargeCopy(v, s)) { + if !(s > 8 && buildcfg.GOPPC64 <= 8 && logLargeCopy(v, s)) { break } v.reset(OpPPC64LoweredMove) @@ -3649,14 +3651,14 @@ func rewriteValuePPC64_OpMove(v *Value) bool { return true } // match: (Move [s] dst src mem) - // cond: s > 8 && s <= 64 && objabi.GOPPC64 >= 9 + // cond: s > 8 && s <= 64 && buildcfg.GOPPC64 >= 9 // result: (LoweredQuadMoveShort [s] dst src mem) for { s := auxIntToInt64(v.AuxInt) dst := v_0 src := v_1 mem := v_2 - if !(s > 8 && s <= 64 && objabi.GOPPC64 >= 9) { + if !(s > 8 && s <= 64 && buildcfg.GOPPC64 >= 9) { break } v.reset(OpPPC64LoweredQuadMoveShort) @@ -3665,14 +3667,14 @@ func rewriteValuePPC64_OpMove(v *Value) bool { return true } // match: (Move [s] dst src mem) - // cond: s > 8 && objabi.GOPPC64 >= 9 && logLargeCopy(v, s) + // cond: s > 8 && buildcfg.GOPPC64 >= 9 && logLargeCopy(v, s) // result: (LoweredQuadMove [s] dst src mem) for { s := auxIntToInt64(v.AuxInt) dst := v_0 src := v_1 mem := v_2 - if !(s > 8 && objabi.GOPPC64 >= 9 && logLargeCopy(v, s)) { + if !(s > 8 && buildcfg.GOPPC64 >= 9 && logLargeCopy(v, s)) { break } v.reset(OpPPC64LoweredQuadMove) @@ -3882,7 +3884,7 @@ func rewriteValuePPC64_OpPPC64ADD(v *Value) bool { b := v.Block typ := &b.Func.Config.Types // match: (ADD l:(MULLD x y) z) - // cond: objabi.GOPPC64 >= 9 && l.Uses == 1 && clobber(l) + // cond: buildcfg.GOPPC64 >= 9 && l.Uses == 1 && clobber(l) // result: (MADDLD x y z) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { @@ -3893,7 +3895,7 @@ func rewriteValuePPC64_OpPPC64ADD(v *Value) bool { y := l.Args[1] x := l.Args[0] z := v_1 - if !(objabi.GOPPC64 >= 9 && l.Uses == 1 && clobber(l)) { + if !(buildcfg.GOPPC64 >= 9 && l.Uses == 1 && clobber(l)) { continue } v.reset(OpPPC64MADDLD) @@ -13241,7 +13243,7 @@ func rewriteValuePPC64_OpPPC64SLDconst(v *Value) bool { break } // match: (SLDconst [c] z:(MOVWreg x)) - // cond: c < 32 && objabi.GOPPC64 >= 9 + // cond: c < 32 && buildcfg.GOPPC64 >= 9 // result: (EXTSWSLconst [c] x) for { c := auxIntToInt64(v.AuxInt) @@ -13250,7 +13252,7 @@ func rewriteValuePPC64_OpPPC64SLDconst(v *Value) bool { break } x := z.Args[0] - if !(c < 32 && objabi.GOPPC64 >= 9) { + if !(c < 32 && buildcfg.GOPPC64 >= 9) { break } v.reset(OpPPC64EXTSWSLconst) @@ -13364,7 +13366,7 @@ func rewriteValuePPC64_OpPPC64SLWconst(v *Value) bool { break } // match: (SLWconst [c] z:(MOVWreg x)) - // cond: c < 32 && objabi.GOPPC64 >= 9 + // cond: c < 32 && buildcfg.GOPPC64 >= 9 // result: (EXTSWSLconst [c] x) for { c := auxIntToInt64(v.AuxInt) @@ -13373,7 +13375,7 @@ func rewriteValuePPC64_OpPPC64SLWconst(v *Value) bool { break } x := z.Args[0] - if !(c < 32 && objabi.GOPPC64 >= 9) { + if !(c < 32 && buildcfg.GOPPC64 >= 9) { break } v.reset(OpPPC64EXTSWSLconst) @@ -16906,13 +16908,13 @@ func rewriteValuePPC64_OpZero(v *Value) bool { return true } // match: (Zero [s] ptr mem) - // cond: objabi.GOPPC64 <= 8 && s < 64 + // cond: buildcfg.GOPPC64 <= 8 && s < 64 // result: (LoweredZeroShort [s] ptr mem) for { s := auxIntToInt64(v.AuxInt) ptr := v_0 mem := v_1 - if !(objabi.GOPPC64 <= 8 && s < 64) { + if !(buildcfg.GOPPC64 <= 8 && s < 64) { break } v.reset(OpPPC64LoweredZeroShort) @@ -16921,13 +16923,13 @@ func rewriteValuePPC64_OpZero(v *Value) bool { return true } // match: (Zero [s] ptr mem) - // cond: objabi.GOPPC64 <= 8 + // cond: buildcfg.GOPPC64 <= 8 // result: (LoweredZero [s] ptr mem) for { s := auxIntToInt64(v.AuxInt) ptr := v_0 mem := v_1 - if !(objabi.GOPPC64 <= 8) { + if !(buildcfg.GOPPC64 <= 8) { break } v.reset(OpPPC64LoweredZero) @@ -16936,13 +16938,13 @@ func rewriteValuePPC64_OpZero(v *Value) bool { return true } // match: (Zero [s] ptr mem) - // cond: s < 128 && objabi.GOPPC64 >= 9 + // cond: s < 128 && buildcfg.GOPPC64 >= 9 // result: (LoweredQuadZeroShort [s] ptr mem) for { s := auxIntToInt64(v.AuxInt) ptr := v_0 mem := v_1 - if !(s < 128 && objabi.GOPPC64 >= 9) { + if !(s < 128 && buildcfg.GOPPC64 >= 9) { break } v.reset(OpPPC64LoweredQuadZeroShort) @@ -16951,13 +16953,13 @@ func rewriteValuePPC64_OpZero(v *Value) bool { return true } // match: (Zero [s] ptr mem) - // cond: objabi.GOPPC64 >= 9 + // cond: buildcfg.GOPPC64 >= 9 // result: (LoweredQuadZero [s] ptr mem) for { s := auxIntToInt64(v.AuxInt) ptr := v_0 mem := v_1 - if !(objabi.GOPPC64 >= 9) { + if !(buildcfg.GOPPC64 >= 9) { break } v.reset(OpPPC64LoweredQuadZero) diff --git a/src/cmd/compile/internal/ssa/rewriteRISCV64.go b/src/cmd/compile/internal/ssa/rewriteRISCV64.go index 431fb1aaf6..bc4b18e0cd 100644 --- a/src/cmd/compile/internal/ssa/rewriteRISCV64.go +++ b/src/cmd/compile/internal/ssa/rewriteRISCV64.go @@ -3,8 +3,10 @@ package ssa -import "math" -import "cmd/compile/internal/types" +import ( + "cmd/compile/internal/types" + "math" +) func rewriteValueRISCV64(v *Value) bool { switch v.Op { diff --git a/src/cmd/compile/internal/ssa/rewriteS390X.go b/src/cmd/compile/internal/ssa/rewriteS390X.go index 8b41d62c31..49c5898704 100644 --- a/src/cmd/compile/internal/ssa/rewriteS390X.go +++ b/src/cmd/compile/internal/ssa/rewriteS390X.go @@ -3,9 +3,11 @@ package ssa -import "math" -import "cmd/compile/internal/types" -import "cmd/internal/obj/s390x" +import ( + "cmd/compile/internal/types" + "cmd/internal/obj/s390x" + "math" +) func rewriteValueS390X(v *Value) bool { switch v.Op { diff --git a/src/cmd/compile/internal/ssa/rewriteWasm.go b/src/cmd/compile/internal/ssa/rewriteWasm.go index 6efcdfe371..ed23ae032a 100644 --- a/src/cmd/compile/internal/ssa/rewriteWasm.go +++ b/src/cmd/compile/internal/ssa/rewriteWasm.go @@ -3,9 +3,11 @@ package ssa -import "math" -import "cmd/internal/objabi" -import "cmd/compile/internal/types" +import ( + "cmd/compile/internal/types" + "internal/buildcfg" + "math" +) func rewriteValueWasm(v *Value) bool { switch v.Op { @@ -3193,11 +3195,11 @@ func rewriteValueWasm_OpSignExt16to32(v *Value) bool { return true } // match: (SignExt16to32 x) - // cond: objabi.GOWASM.SignExt + // cond: buildcfg.GOWASM.SignExt // result: (I64Extend16S x) for { x := v_0 - if !(objabi.GOWASM.SignExt) { + if !(buildcfg.GOWASM.SignExt) { break } v.reset(OpWasmI64Extend16S) @@ -3232,11 +3234,11 @@ func rewriteValueWasm_OpSignExt16to64(v *Value) bool { return true } // match: (SignExt16to64 x) - // cond: objabi.GOWASM.SignExt + // cond: buildcfg.GOWASM.SignExt // result: (I64Extend16S x) for { x := v_0 - if !(objabi.GOWASM.SignExt) { + if !(buildcfg.GOWASM.SignExt) { break } v.reset(OpWasmI64Extend16S) @@ -3271,11 +3273,11 @@ func rewriteValueWasm_OpSignExt32to64(v *Value) bool { return true } // match: (SignExt32to64 x) - // cond: objabi.GOWASM.SignExt + // cond: buildcfg.GOWASM.SignExt // result: (I64Extend32S x) for { x := v_0 - if !(objabi.GOWASM.SignExt) { + if !(buildcfg.GOWASM.SignExt) { break } v.reset(OpWasmI64Extend32S) @@ -3310,11 +3312,11 @@ func rewriteValueWasm_OpSignExt8to16(v *Value) bool { return true } // match: (SignExt8to16 x) - // cond: objabi.GOWASM.SignExt + // cond: buildcfg.GOWASM.SignExt // result: (I64Extend8S x) for { x := v_0 - if !(objabi.GOWASM.SignExt) { + if !(buildcfg.GOWASM.SignExt) { break } v.reset(OpWasmI64Extend8S) @@ -3349,11 +3351,11 @@ func rewriteValueWasm_OpSignExt8to32(v *Value) bool { return true } // match: (SignExt8to32 x) - // cond: objabi.GOWASM.SignExt + // cond: buildcfg.GOWASM.SignExt // result: (I64Extend8S x) for { x := v_0 - if !(objabi.GOWASM.SignExt) { + if !(buildcfg.GOWASM.SignExt) { break } v.reset(OpWasmI64Extend8S) @@ -3388,11 +3390,11 @@ func rewriteValueWasm_OpSignExt8to64(v *Value) bool { return true } // match: (SignExt8to64 x) - // cond: objabi.GOWASM.SignExt + // cond: buildcfg.GOWASM.SignExt // result: (I64Extend8S x) for { x := v_0 - if !(objabi.GOWASM.SignExt) { + if !(buildcfg.GOWASM.SignExt) { break } v.reset(OpWasmI64Extend8S) diff --git a/src/cmd/compile/internal/ssa/rewritegeneric.go b/src/cmd/compile/internal/ssa/rewritegeneric.go index 52258201ca..0e5f49491e 100644 --- a/src/cmd/compile/internal/ssa/rewritegeneric.go +++ b/src/cmd/compile/internal/ssa/rewritegeneric.go @@ -3,8 +3,10 @@ package ssa -import "math" -import "cmd/compile/internal/types" +import ( + "cmd/compile/internal/types" + "math" +) func rewriteValuegeneric(v *Value) bool { switch v.Op { diff --git a/src/cmd/compile/internal/ssagen/abi.go b/src/cmd/compile/internal/ssagen/abi.go index 8103b08ce5..7d56362302 100644 --- a/src/cmd/compile/internal/ssagen/abi.go +++ b/src/cmd/compile/internal/ssagen/abi.go @@ -6,6 +6,7 @@ package ssagen import ( "fmt" + "internal/buildcfg" "io/ioutil" "log" "os" @@ -213,7 +214,7 @@ func (s *SymABIs) GenABIWrappers() { base.Fatalf("cgo exported function %s cannot have ABI wrappers", fn) } - if !objabi.Experiment.RegabiWrappers { + if !buildcfg.Experiment.RegabiWrappers { // We'll generate ABI aliases instead of // wrappers once we have LSyms in InitLSym. continue @@ -241,7 +242,7 @@ func InitLSym(f *ir.Func, hasBody bool) { if f.Pragma&ir.Systemstack != 0 { f.LSym.Set(obj.AttrCFunc, true) } - if f.ABI == obj.ABIInternal || !objabi.Experiment.RegabiWrappers { + if f.ABI == obj.ABIInternal || !buildcfg.Experiment.RegabiWrappers { // Function values can only point to // ABIInternal entry points. This will create // the funcsym for either the defining @@ -253,7 +254,7 @@ func InitLSym(f *ir.Func, hasBody bool) { // when we see that. staticdata.NeedFuncSym(f) } - if !objabi.Experiment.RegabiWrappers { + if !buildcfg.Experiment.RegabiWrappers { // Create ABI aliases instead of wrappers. forEachWrapperABI(f, makeABIAlias) } diff --git a/src/cmd/compile/internal/ssagen/pgen.go b/src/cmd/compile/internal/ssagen/pgen.go index 92f6f562f3..62567535d7 100644 --- a/src/cmd/compile/internal/ssagen/pgen.go +++ b/src/cmd/compile/internal/ssagen/pgen.go @@ -5,6 +5,7 @@ package ssagen import ( + "internal/buildcfg" "internal/race" "math/rand" "sort" @@ -215,7 +216,7 @@ func StackOffset(slot ssa.LocalSlot) int32 { if base.Ctxt.FixedFrameSize() == 0 { off -= int64(types.PtrSize) } - if objabi.FramePointerEnabled { + if buildcfg.FramePointerEnabled { off -= int64(types.PtrSize) } } @@ -228,7 +229,7 @@ func fieldtrack(fnsym *obj.LSym, tracked map[*obj.LSym]struct{}) { if fnsym == nil { return } - if !objabi.Experiment.FieldTrack || len(tracked) == 0 { + if !buildcfg.Experiment.FieldTrack || len(tracked) == 0 { return } diff --git a/src/cmd/compile/internal/ssagen/ssa.go b/src/cmd/compile/internal/ssagen/ssa.go index 61f23a9c40..f0bce0756a 100644 --- a/src/cmd/compile/internal/ssagen/ssa.go +++ b/src/cmd/compile/internal/ssagen/ssa.go @@ -12,6 +12,7 @@ import ( "fmt" "go/constant" "html" + "internal/buildcfg" "os" "path/filepath" "sort" @@ -227,7 +228,7 @@ const magicLastTypeName = "MagicLastTypeNameForTestingRegisterABI" // abiForFunc implements ABI policy for a function, but does not return a copy of the ABI. // Passing a nil function returns the default ABI based on experiment configuration. func abiForFunc(fn *ir.Func, abi0, abi1 *abi.ABIConfig) *abi.ABIConfig { - if objabi.Experiment.RegabiArgs { + if buildcfg.Experiment.RegabiArgs { // Select the ABI based on the function's defining ABI. if fn == nil { return abi1 @@ -4646,7 +4647,7 @@ func (s *state) openDeferRecord(n *ir.CallExpr) { var args []*ssa.Value var argNodes []*ir.Name - if objabi.Experiment.RegabiDefer && (len(n.Args) != 0 || n.Op() == ir.OCALLINTER || n.X.Type().NumResults() != 0) { + if buildcfg.Experiment.RegabiDefer && (len(n.Args) != 0 || n.Op() == ir.OCALLINTER || n.X.Type().NumResults() != 0) { s.Fatalf("defer call with arguments or results: %v", n) } @@ -4883,7 +4884,7 @@ func (s *state) call(n *ir.CallExpr, k callKind, returnResultAddr bool) *ssa.Val callABI := s.f.ABIDefault - if !objabi.Experiment.RegabiArgs { + if !buildcfg.Experiment.RegabiArgs { var magicFnNameSym *types.Sym if fn.Name() != nil { magicFnNameSym = fn.Name().Sym() @@ -4901,7 +4902,7 @@ func (s *state) call(n *ir.CallExpr, k callKind, returnResultAddr bool) *ssa.Val } } - if objabi.Experiment.RegabiDefer && k != callNormal && (len(n.Args) != 0 || n.Op() == ir.OCALLINTER || n.X.Type().NumResults() != 0) { + if buildcfg.Experiment.RegabiDefer && k != callNormal && (len(n.Args) != 0 || n.Op() == ir.OCALLINTER || n.X.Type().NumResults() != 0) { s.Fatalf("go/defer call with arguments: %v", n) } @@ -4910,7 +4911,7 @@ func (s *state) call(n *ir.CallExpr, k callKind, returnResultAddr bool) *ssa.Val if k == callNormal && fn.Op() == ir.ONAME && fn.(*ir.Name).Class == ir.PFUNC { fn := fn.(*ir.Name) callee = fn - if objabi.Experiment.RegabiArgs { + if buildcfg.Experiment.RegabiArgs { // This is a static call, so it may be // a direct call to a non-ABIInternal // function. fn.Func may be nil for @@ -4951,7 +4952,7 @@ func (s *state) call(n *ir.CallExpr, k callKind, returnResultAddr bool) *ssa.Val } } - if !objabi.Experiment.RegabiArgs { + if !buildcfg.Experiment.RegabiArgs { if regAbiForFuncType(n.X.Type().FuncType()) { // Magic last type in input args to call callABI = s.f.ABI1 @@ -5135,7 +5136,7 @@ func (s *state) call(n *ir.CallExpr, k callKind, returnResultAddr bool) *ssa.Val // maybeNilCheckClosure checks if a nil check of a closure is needed in some // architecture-dependent situations and, if so, emits the nil check. func (s *state) maybeNilCheckClosure(closure *ssa.Value, k callKind) { - if Arch.LinkArch.Family == sys.Wasm || objabi.GOOS == "aix" && k != callGo { + if Arch.LinkArch.Family == sys.Wasm || buildcfg.GOOS == "aix" && k != callGo { // On AIX, the closure needs to be verified as fn can be nil, except if it's a call go. This needs to be handled by the runtime to have the "go of nil func value" error. // TODO(neelance): On other architectures this should be eliminated by the optimization steps s.nilCheck(closure) @@ -6881,7 +6882,7 @@ func defframe(s *State, e *ssafn, f *ssa.Func) { // and not address-taken (for non-SSA-able or address-taken arguments we always // spill upfront). // TODO(register args) Make liveness more fine-grained to that partial spilling is okay. - if objabi.Experiment.RegabiArgs { + if buildcfg.Experiment.RegabiArgs { // First, see if it is already spilled before it may be live. Look for a spill // in the entry block up to the first safepoint. type nameOff struct { diff --git a/src/cmd/compile/internal/staticdata/data.go b/src/cmd/compile/internal/staticdata/data.go index 7ca05d3bf4..b5206c2442 100644 --- a/src/cmd/compile/internal/staticdata/data.go +++ b/src/cmd/compile/internal/staticdata/data.go @@ -8,6 +8,7 @@ import ( "crypto/sha256" "fmt" "go/constant" + "internal/buildcfg" "io" "io/ioutil" "os" @@ -269,7 +270,7 @@ func NeedFuncSym(fn *ir.Func) { // funcsymsmu, like in FuncSym. base.Fatalf("NeedFuncSym must be called in serial") } - if fn.ABI != obj.ABIInternal && objabi.Experiment.RegabiWrappers { + if fn.ABI != obj.ABIInternal && buildcfg.Experiment.RegabiWrappers { // Function values must always reference ABIInternal // entry points, so it doesn't make sense to create a // funcsym for other ABIs. diff --git a/src/cmd/compile/internal/walk/expr.go b/src/cmd/compile/internal/walk/expr.go index 0995c1314d..d8160d971c 100644 --- a/src/cmd/compile/internal/walk/expr.go +++ b/src/cmd/compile/internal/walk/expr.go @@ -7,6 +7,7 @@ package walk import ( "fmt" "go/constant" + "internal/buildcfg" "strings" "cmd/compile/internal/base" @@ -16,7 +17,6 @@ import ( "cmd/compile/internal/typecheck" "cmd/compile/internal/types" "cmd/internal/obj" - "cmd/internal/objabi" ) // The result of walkExpr MUST be assigned back to n, e.g. @@ -927,7 +927,7 @@ func usemethod(n *ir.CallExpr) { } func usefield(n *ir.SelectorExpr) { - if !objabi.Experiment.FieldTrack { + if !buildcfg.Experiment.FieldTrack { return } diff --git a/src/cmd/compile/internal/walk/order.go b/src/cmd/compile/internal/walk/order.go index 42d9d58971..7b69f34e85 100644 --- a/src/cmd/compile/internal/walk/order.go +++ b/src/cmd/compile/internal/walk/order.go @@ -7,6 +7,7 @@ package walk import ( "fmt" "go/constant" + "internal/buildcfg" "cmd/compile/internal/base" "cmd/compile/internal/escape" @@ -15,7 +16,6 @@ import ( "cmd/compile/internal/staticinit" "cmd/compile/internal/typecheck" "cmd/compile/internal/types" - "cmd/internal/objabi" "cmd/internal/src" ) @@ -780,7 +780,7 @@ func (o *orderState) stmt(n ir.Node) { n.Call = walkRecover(n.Call.(*ir.CallExpr), &init) o.stmtList(init) } - if objabi.Experiment.RegabiDefer { + if buildcfg.Experiment.RegabiDefer { o.wrapGoDefer(n) } o.out = append(o.out, n) diff --git a/src/cmd/compile/internal/walk/range.go b/src/cmd/compile/internal/walk/range.go index 80bd8750fa..3384bc826e 100644 --- a/src/cmd/compile/internal/walk/range.go +++ b/src/cmd/compile/internal/walk/range.go @@ -170,7 +170,7 @@ func walkRange(nrange *ir.RangeStmt) ir.Node { th := hit.Type() // depends on layout of iterator struct. // See cmd/compile/internal/reflectdata/reflect.go:MapIterType - keysym := th.Field(0).Sym + keysym := th.Field(0).Sym elemsym := th.Field(1).Sym // ditto fn := typecheck.LookupRuntime("mapiterinit") diff --git a/src/cmd/compile/internal/wasm/ssa.go b/src/cmd/compile/internal/wasm/ssa.go index 904871b15f..31b09016eb 100644 --- a/src/cmd/compile/internal/wasm/ssa.go +++ b/src/cmd/compile/internal/wasm/ssa.go @@ -14,7 +14,7 @@ import ( "cmd/compile/internal/types" "cmd/internal/obj" "cmd/internal/obj/wasm" - "cmd/internal/objabi" + "internal/buildcfg" ) func Init(arch *ssagen.ArchInfo) { @@ -325,7 +325,7 @@ func ssaGenValueOnStack(s *ssagen.State, v *ssa.Value, extend bool) { case ssa.OpWasmI64TruncSatF32S, ssa.OpWasmI64TruncSatF64S: getValue64(s, v.Args[0]) - if objabi.GOWASM.SatConv { + if buildcfg.GOWASM.SatConv { s.Prog(v.Op.Asm()) } else { if v.Op == ssa.OpWasmI64TruncSatF32S { @@ -337,7 +337,7 @@ func ssaGenValueOnStack(s *ssagen.State, v *ssa.Value, extend bool) { case ssa.OpWasmI64TruncSatF32U, ssa.OpWasmI64TruncSatF64U: getValue64(s, v.Args[0]) - if objabi.GOWASM.SatConv { + if buildcfg.GOWASM.SatConv { s.Prog(v.Op.Asm()) } else { if v.Op == ssa.OpWasmI64TruncSatF32U { diff --git a/src/cmd/compile/internal/x86/galign.go b/src/cmd/compile/internal/x86/galign.go index fc806f9119..00a20e429f 100644 --- a/src/cmd/compile/internal/x86/galign.go +++ b/src/cmd/compile/internal/x86/galign.go @@ -8,8 +8,8 @@ import ( "cmd/compile/internal/base" "cmd/compile/internal/ssagen" "cmd/internal/obj/x86" - "cmd/internal/objabi" "fmt" + "internal/buildcfg" "os" ) @@ -19,7 +19,7 @@ func Init(arch *ssagen.ArchInfo) { arch.SSAGenValue = ssaGenValue arch.SSAGenBlock = ssaGenBlock arch.MAXWIDTH = (1 << 32) - 1 - switch v := objabi.GO386; v { + switch v := buildcfg.GO386; v { case "sse2": case "softfloat": arch.SoftFloat = true |