]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile/internal: intrinsify publicationBarrier on mips64x
authorJulian Zhu <jz531210@gmail.com>
Tue, 20 May 2025 02:55:33 +0000 (10:55 +0800)
committerGopher Robot <gobot@golang.org>
Wed, 21 May 2025 19:06:44 +0000 (12:06 -0700)
This enables publicationBarrier to be used as an intrinsic on mips64x.

Change-Id: I4030ea65086c37ee1dcc1675d0d5d40ef8683851
Reviewed-on: https://go-review.googlesource.com/c/go/+/674855
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Keith Randall <khr@google.com>
Auto-Submit: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
src/cmd/compile/internal/mips64/ssa.go
src/cmd/compile/internal/ssa/_gen/MIPS64.rules
src/cmd/compile/internal/ssa/_gen/MIPS64Ops.go
src/cmd/compile/internal/ssa/opGen.go
src/cmd/compile/internal/ssa/rewriteMIPS64.go
src/cmd/compile/internal/ssagen/intrinsics.go
src/cmd/compile/internal/ssagen/intrinsics_test.go

index 5b5edf622a1e9b902553f462b0dea2638fe2ca88..af94c16f6df5927435a4e18e528c91ae72dcd94b 100644 (file)
@@ -813,6 +813,9 @@ func ssaGenValue(s *ssagen.State, v *ssa.Value) {
                p := s.Prog(obj.AGETCALLERPC)
                p.To.Type = obj.TYPE_REG
                p.To.Reg = v.Reg()
+       case ssa.OpMIPS64LoweredPubBarrier:
+               // SYNC
+               s.Prog(v.Op.Asm())
        case ssa.OpClobber, ssa.OpClobberReg:
                // TODO: implement for clobberdead experiment. Nop is ok for now.
        default:
index cd82655ff3fa99f170f882f6f0b572cd6108262a..8e484f4a3d3182e010804002647c6b219b303d53 100644 (file)
 // Write barrier.
 (WB ...) => (LoweredWB ...)
 
+// Publication barrier as intrinsic
+(PubBarrier ...) => (LoweredPubBarrier ...)
+
 (PanicBounds [kind] x y mem) && boundsABI(kind) == 0 => (LoweredPanicBoundsA [kind] x y mem)
 (PanicBounds [kind] x y mem) && boundsABI(kind) == 1 => (LoweredPanicBoundsB [kind] x y mem)
 (PanicBounds [kind] x y mem) && boundsABI(kind) == 2 => (LoweredPanicBoundsC [kind] x y mem)
index 3d1abb16b60e79d1ee0f3dc8e0b35513ebb729e1..6c04a1aea26d805187d4213b921f6caabaef1843 100644 (file)
@@ -466,6 +466,9 @@ func init() {
                // Returns a pointer to a write barrier buffer in R25.
                {name: "LoweredWB", argLength: 1, reg: regInfo{clobbers: (callerSave &^ gpg) | buildReg("R31"), outputs: []regMask{buildReg("R25")}}, clobberFlags: true, aux: "Int64"},
 
+               // Do data barrier. arg0=memorys
+               {name: "LoweredPubBarrier", argLength: 1, asm: "SYNC", hasSideEffects: true},
+
                // There are three of these functions so that they can have three different register inputs.
                // When we check 0 <= c <= cap (A), then 0 <= b <= c (B), then 0 <= a <= b (C), we want the
                // default registers to match so we don't need to copy registers around unnecessarily.
index 37af79f9a3411086a2979c8a1fa06e0f3d3b7db8..b5eb74742215f6b3383f077953c1806a47344b98 100644 (file)
@@ -2207,6 +2207,7 @@ const (
        OpMIPS64LoweredGetCallerSP
        OpMIPS64LoweredGetCallerPC
        OpMIPS64LoweredWB
+       OpMIPS64LoweredPubBarrier
        OpMIPS64LoweredPanicBoundsA
        OpMIPS64LoweredPanicBoundsB
        OpMIPS64LoweredPanicBoundsC
@@ -29755,6 +29756,13 @@ var opcodeTable = [...]opInfo{
                        },
                },
        },
+       {
+               name:           "LoweredPubBarrier",
+               argLen:         1,
+               hasSideEffects: true,
+               asm:            mips.ASYNC,
+               reg:            regInfo{},
+       },
        {
                name:    "LoweredPanicBoundsA",
                auxType: auxInt64,
index 14b273f9aa0db1c8c8cee071555d227db6c4345a..c30815cefb5b9996a67e766872a3ed47a212192b 100644 (file)
@@ -502,6 +502,9 @@ func rewriteValueMIPS64(v *Value) bool {
                return true
        case OpPanicBounds:
                return rewriteValueMIPS64_OpPanicBounds(v)
+       case OpPubBarrier:
+               v.Op = OpMIPS64LoweredPubBarrier
+               return true
        case OpRotateLeft16:
                return rewriteValueMIPS64_OpRotateLeft16(v)
        case OpRotateLeft32:
index 97798f5bcc4b51500459351c319fd04a448a3889..5ad528cc62692a854e74a409cd9922ae1fc5aa43 100644 (file)
@@ -163,7 +163,7 @@ func initIntrinsics(cfg *intrinsicBuildConfig) {
                        s.vars[memVar] = s.newValue1(ssa.OpPubBarrier, types.TypeMem, s.mem())
                        return nil
                },
-               sys.ARM64, sys.Loong64, sys.PPC64, sys.RISCV64)
+               sys.ARM64, sys.Loong64, sys.MIPS64, sys.PPC64, sys.RISCV64)
 
        /******** internal/runtime/sys ********/
        add("internal/runtime/sys", "GetCallerPC",
index 6757e1e802928e8c97a8bcd7cc845a3de9506e17..127f26acbf70bece146fa3e91e38981ad9c0bad9 100644 (file)
@@ -631,6 +631,7 @@ var wantIntrinsics = map[testIntrinsicKey]struct{}{
        {"mips64", "math/bits", "Sub"}:                                     struct{}{},
        {"mips64", "math/bits", "Sub64"}:                                   struct{}{},
        {"mips64", "runtime", "KeepAlive"}:                                 struct{}{},
+       {"mips64", "runtime", "publicationBarrier"}:                        struct{}{},
        {"mips64", "runtime", "slicebytetostringtmp"}:                      struct{}{},
        {"mips64", "sync", "runtime_LoadAcquintptr"}:                       struct{}{},
        {"mips64", "sync", "runtime_StoreReluintptr"}:                      struct{}{},
@@ -718,6 +719,7 @@ var wantIntrinsics = map[testIntrinsicKey]struct{}{
        {"mips64le", "math/bits", "Sub"}:                                   struct{}{},
        {"mips64le", "math/bits", "Sub64"}:                                 struct{}{},
        {"mips64le", "runtime", "KeepAlive"}:                               struct{}{},
+       {"mips64le", "runtime", "publicationBarrier"}:                      struct{}{},
        {"mips64le", "runtime", "slicebytetostringtmp"}:                    struct{}{},
        {"mips64le", "sync", "runtime_LoadAcquintptr"}:                     struct{}{},
        {"mips64le", "sync", "runtime_StoreReluintptr"}:                    struct{}{},