]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: make processor capability variable naming platform specific
authorMartin Möhrmann <moehrmann@google.com>
Tue, 6 Nov 2018 16:00:04 +0000 (17:00 +0100)
committerMartin Möhrmann <martisch@uos.de>
Wed, 14 Nov 2018 20:30:31 +0000 (20:30 +0000)
The current support_XXX variables are specific for the
amd64 and 386 platforms.

Prefix processor capability variables by architecture to have a
consistent naming scheme and avoid reuse of the existing
variables for new platforms.

This also aligns naming of runtime variables closer with internal/cpu
processor capability variable names.

Change-Id: I3eabb29a03874678851376185d3a62e73c1aff1d
Reviewed-on: https://go-review.googlesource.com/c/91435
Run-TryBot: Martin Möhrmann <martisch@uos.de>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
src/cmd/compile/internal/gc/builtin.go
src/cmd/compile/internal/gc/builtin/runtime.go
src/cmd/compile/internal/gc/go.go
src/cmd/compile/internal/gc/ssa.go
src/cmd/compile/internal/ssa/gen/AMD64Ops.go
src/runtime/cpuflags.go
src/runtime/proc.go
src/runtime/runtime2.go
test/codegen/mathbits.go

index 4e9f11c8b320567ff6c87e223177275e55c0633b..04f4cbfd5852d2df95e6bb04b8aad72f4cf2e586 100644 (file)
@@ -144,8 +144,9 @@ var runtimeDecls = [...]struct {
        {"racewriterange", funcTag, 113},
        {"msanread", funcTag, 113},
        {"msanwrite", funcTag, 113},
-       {"support_popcnt", varTag, 11},
-       {"support_sse41", varTag, 11},
+       {"x86HasPOPCNT", varTag, 11},
+       {"x86HasSSE41", varTag, 11},
+       {"arm64HasATOMICS", varTag, 11},
 }
 
 func runtimeTypes() []*types.Type {
index 1eaf332e5020f03de569ff6812b44bed3a7201c5..fc879badb2b7eb36e95d359c136f2016392fe7ca 100644 (file)
@@ -195,5 +195,6 @@ func msanread(addr, size uintptr)
 func msanwrite(addr, size uintptr)
 
 // architecture variants
-var support_popcnt bool
-var support_sse41 bool
+var x86HasPOPCNT bool
+var x86HasSSE41 bool
+var arm64HasATOMICS bool
index 471746ed7dde218c962da841acd393ae060444fd..cb76398629742559ddfeff20312a42fe4f8b4fa6 100644 (file)
@@ -305,9 +305,9 @@ var (
        racereadrange,
        racewrite,
        racewriterange,
-       supportPopcnt,
-       supportSSE41,
-       arm64SupportAtomics,
+       x86HasPOPCNT,
+       x86HasSSE41,
+       arm64HasATOMICS,
        typedmemclr,
        typedmemmove,
        Udiv,
index 9da45258f52686b9ffe4d6741fadf83ac1fc7a4a..1c64c6437d4b2e56a7ac3e8aa1735ac9bca6f1d2 100644 (file)
@@ -86,9 +86,9 @@ func initssaconfig() {
        racereadrange = sysfunc("racereadrange")
        racewrite = sysfunc("racewrite")
        racewriterange = sysfunc("racewriterange")
-       supportPopcnt = sysvar("support_popcnt")              // bool
-       supportSSE41 = sysvar("support_sse41")                // bool
-       arm64SupportAtomics = sysvar("arm64_support_atomics") // bool
+       x86HasPOPCNT = sysvar("x86HasPOPCNT")       // bool
+       x86HasSSE41 = sysvar("x86HasSSE41")         // bool
+       arm64HasATOMICS = sysvar("arm64HasATOMICS") // bool
        typedmemclr = sysfunc("typedmemclr")
        typedmemmove = sysfunc("typedmemmove")
        Udiv = sysvar("udiv")                 // asm func with special ABI
@@ -3068,7 +3068,7 @@ func init() {
        makeXaddARM64 := func(op0 ssa.Op, op1 ssa.Op, ty types.EType) func(s *state, n *Node, args []*ssa.Value) *ssa.Value {
                return func(s *state, n *Node, args []*ssa.Value) *ssa.Value {
                        // Target Atomic feature is identified by dynamic detection
-                       addr := s.entryNewValue1A(ssa.OpAddr, types.Types[TBOOL].PtrTo(), arm64SupportAtomics, s.sb)
+                       addr := s.entryNewValue1A(ssa.OpAddr, types.Types[TBOOL].PtrTo(), arm64HasATOMICS, s.sb)
                        v := s.load(types.Types[TBOOL], addr)
                        b := s.endBlock()
                        b.Kind = ssa.BlockIf
@@ -3208,7 +3208,7 @@ func init() {
 
        makeRoundAMD64 := func(op ssa.Op) func(s *state, n *Node, args []*ssa.Value) *ssa.Value {
                return func(s *state, n *Node, args []*ssa.Value) *ssa.Value {
-                       addr := s.entryNewValue1A(ssa.OpAddr, types.Types[TBOOL].PtrTo(), supportSSE41, s.sb)
+                       addr := s.entryNewValue1A(ssa.OpAddr, types.Types[TBOOL].PtrTo(), x86HasSSE41, s.sb)
                        v := s.load(types.Types[TBOOL], addr)
                        b := s.endBlock()
                        b.Kind = ssa.BlockIf
@@ -3416,7 +3416,7 @@ func init() {
 
        makeOnesCountAMD64 := func(op64 ssa.Op, op32 ssa.Op) func(s *state, n *Node, args []*ssa.Value) *ssa.Value {
                return func(s *state, n *Node, args []*ssa.Value) *ssa.Value {
-                       addr := s.entryNewValue1A(ssa.OpAddr, types.Types[TBOOL].PtrTo(), supportPopcnt, s.sb)
+                       addr := s.entryNewValue1A(ssa.OpAddr, types.Types[TBOOL].PtrTo(), x86HasPOPCNT, s.sb)
                        v := s.load(types.Types[TBOOL], addr)
                        b := s.endBlock()
                        b.Kind = ssa.BlockIf
index bd1339b43ab66376b12909566794dd031cc3d0e3..c2ed0ea1d95117560e69d33ebdf8566cba1ddc46 100644 (file)
@@ -467,14 +467,14 @@ func init() {
                {name: "BSWAPL", argLength: 1, reg: gp11, asm: "BSWAPL", resultInArg0: true, clobberFlags: true}, // arg0 swap bytes
 
                // POPCNT instructions aren't guaranteed to be on the target platform (they are SSE4).
-               // Any use must be preceded by a successful check of runtime.support_popcnt.
+               // Any use must be preceded by a successful check of runtime.x86HasPOPCNT.
                {name: "POPCNTQ", argLength: 1, reg: gp11, asm: "POPCNTQ", clobberFlags: true}, // count number of set bits in arg0
                {name: "POPCNTL", argLength: 1, reg: gp11, asm: "POPCNTL", clobberFlags: true}, // count number of set bits in arg0
 
                {name: "SQRTSD", argLength: 1, reg: fp11, asm: "SQRTSD"}, // sqrt(arg0)
 
                // ROUNDSD instruction isn't guaranteed to be on the target platform (it is SSE4.1)
-               // Any use must be preceded by a successful check of runtime.support_sse41.
+               // Any use must be preceded by a successful check of runtime.x86HasSSE41.
                {name: "ROUNDSD", argLength: 1, reg: fp11, aux: "Int8", asm: "ROUNDSD"}, // rounds arg0 depending on auxint, 1 means math.Floor, 2 Ceil, 3 Trunc
 
                {name: "SBBQcarrymask", argLength: 1, reg: flagsgp, asm: "SBBQ"}, // (int64)(-1) if carry is set, 0 if carry is clear.
index b65523766af5f79d10022ccc4de7d757d16a8ef8..1565afb93a5573d37bb4b7d3456514a7519d9dbd 100644 (file)
@@ -17,3 +17,12 @@ const (
 
        offsetARMHasIDIVA = unsafe.Offsetof(cpu.ARM.HasIDIVA)
 )
+
+var (
+       // Set in runtime.cpuinit.
+       // TODO: deprecate these; use internal/cpu directly.
+       x86HasPOPCNT bool
+       x86HasSSE41  bool
+
+       arm64HasATOMICS bool
+)
index 837fa93bfac0c1ecb690edea2c779d14256b9629..41ac75d3dd992091b0a3e4eb2e61f02fefd46231 100644 (file)
@@ -509,10 +509,10 @@ func cpuinit() {
 
        // Support cpu feature variables are used in code generated by the compiler
        // to guard execution of instructions that can not be assumed to be always supported.
-       support_popcnt = cpu.X86.HasPOPCNT
-       support_sse41 = cpu.X86.HasSSE41
+       x86HasPOPCNT = cpu.X86.HasPOPCNT
+       x86HasSSE41 = cpu.X86.HasSSE41
 
-       arm64_support_atomics = cpu.ARM64.HasATOMICS
+       arm64HasATOMICS = cpu.ARM64.HasATOMICS
 }
 
 // The bootstrap sequence is:
index 66dd1b19c13b3d2e174d5f7769cf8d1af91976e6..290a7bd3111a7160fb74f072d666f4c63a4ac2f5 100644 (file)
@@ -858,12 +858,6 @@ var (
        isIntel              bool
        lfenceBeforeRdtsc    bool
 
-       // Set in runtime.cpuinit.
-       // TODO: deprecate these; use internal/cpu directly.
-       support_popcnt        bool
-       support_sse41         bool
-       arm64_support_atomics bool
-
        goarm                uint8 // set by cmd/link on arm systems
        framepointer_enabled bool  // set by cmd/link
 )
index 977cbe6eb13179b010ec4359c460f20ce4fdddf3..85d5bdea331bf8938b38391bc82aacd456b33c40 100644 (file)
@@ -101,7 +101,7 @@ func Len8(n uint8) int {
 // -------------------- //
 
 func OnesCount(n uint) int {
-       // amd64:"POPCNTQ",".*support_popcnt"
+       // amd64:"POPCNTQ",".*x86HasPOPCNT"
        // arm64:"VCNT","VUADDLV"
        // s390x:"POPCNT"
        // ppc64:"POPCNTD"
@@ -110,7 +110,7 @@ func OnesCount(n uint) int {
 }
 
 func OnesCount64(n uint64) int {
-       // amd64:"POPCNTQ",".*support_popcnt"
+       // amd64:"POPCNTQ",".*x86HasPOPCNT"
        // arm64:"VCNT","VUADDLV"
        // s390x:"POPCNT"
        // ppc64:"POPCNTD"
@@ -119,7 +119,7 @@ func OnesCount64(n uint64) int {
 }
 
 func OnesCount32(n uint32) int {
-       // amd64:"POPCNTL",".*support_popcnt"
+       // amd64:"POPCNTL",".*x86HasPOPCNT"
        // arm64:"VCNT","VUADDLV"
        // s390x:"POPCNT"
        // ppc64:"POPCNTW"
@@ -128,7 +128,7 @@ func OnesCount32(n uint32) int {
 }
 
 func OnesCount16(n uint16) int {
-       // amd64:"POPCNTL",".*support_popcnt"
+       // amd64:"POPCNTL",".*x86HasPOPCNT"
        // arm64:"VCNT","VUADDLV"
        // s390x:"POPCNT"
        // ppc64:"POPCNTW"