]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile/internal: intrinsify publicationBarrier on mipsx
authorJulian Zhu <jz531210@gmail.com>
Wed, 21 May 2025 08:36:53 +0000 (16:36 +0800)
committerGopher Robot <gobot@golang.org>
Wed, 21 May 2025 19:08:18 +0000 (12:08 -0700)
This enables publicationBarrier to be used as an intrinsic on mipsx.

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

index 4c7c8eafcda30dd068571631717b130020084610..9762554829c2953bc0854f26375ee90504b50077 100644 (file)
@@ -804,6 +804,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.OpMIPSLoweredPubBarrier:
+               // SYNC
+               s.Prog(v.Op.Asm())
        case ssa.OpClobber, ssa.OpClobberReg:
                // TODO: implement for clobberdead experiment. Nop is ok for now.
        default:
index a4899ac24d176770cd38b6466455f13871b7e1b8..a9bac5fabe1b72fe368b12a8e7c1ad4e269961b0 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 48e06a4189ed89f13702ecaf1a2ad5f493dce225..62c35ed49f2a854538387996e1d544e06ee8951c 100644 (file)
@@ -408,6 +408,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 b5eb74742215f6b3383f077953c1806a47344b98..90a38c783a861c5fa3d44d41a276f11dde6584a7 100644 (file)
@@ -2076,6 +2076,7 @@ const (
        OpMIPSLoweredGetCallerSP
        OpMIPSLoweredGetCallerPC
        OpMIPSLoweredWB
+       OpMIPSLoweredPubBarrier
        OpMIPSLoweredPanicBoundsA
        OpMIPSLoweredPanicBoundsB
        OpMIPSLoweredPanicBoundsC
@@ -27990,6 +27991,13 @@ var opcodeTable = [...]opInfo{
                        },
                },
        },
+       {
+               name:           "LoweredPubBarrier",
+               argLen:         1,
+               hasSideEffects: true,
+               asm:            mips.ASYNC,
+               reg:            regInfo{},
+       },
        {
                name:    "LoweredPanicBoundsA",
                auxType: auxInt64,
index fe24f0fd0f50541ac941f3310e51f3506b318b88..4c5edb8694d28499401c1f0515c6745a22757f96 100644 (file)
@@ -450,6 +450,9 @@ func rewriteValueMIPS(v *Value) bool {
                return rewriteValueMIPS_OpPanicBounds(v)
        case OpPanicExtend:
                return rewriteValueMIPS_OpPanicExtend(v)
+       case OpPubBarrier:
+               v.Op = OpMIPSLoweredPubBarrier
+               return true
        case OpRotateLeft16:
                return rewriteValueMIPS_OpRotateLeft16(v)
        case OpRotateLeft32:
index 5ad528cc62692a854e74a409cd9922ae1fc5aa43..6b58e7e5914538de18baaf04a507bd925147f888 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.MIPS64, sys.PPC64, sys.RISCV64)
+               sys.ARM64, sys.Loong64, sys.MIPS, sys.MIPS64, sys.PPC64, sys.RISCV64)
 
        /******** internal/runtime/sys ********/
        add("internal/runtime/sys", "GetCallerPC",
index 127f26acbf70bece146fa3e91e38981ad9c0bad9..0623c5f2098c4ebe5a09b2e0571f9e5ec821caa7 100644 (file)
@@ -554,6 +554,7 @@ var wantIntrinsics = map[testIntrinsicKey]struct{}{
        {"mips", "math/bits", "TrailingZeros64"}:                           struct{}{},
        {"mips", "math/bits", "TrailingZeros8"}:                            struct{}{},
        {"mips", "runtime", "KeepAlive"}:                                   struct{}{},
+       {"mips", "runtime", "publicationBarrier"}:                          struct{}{},
        {"mips", "runtime", "slicebytetostringtmp"}:                        struct{}{},
        {"mips", "sync", "runtime_LoadAcquintptr"}:                         struct{}{},
        {"mips", "sync", "runtime_StoreReluintptr"}:                        struct{}{},
@@ -799,6 +800,7 @@ var wantIntrinsics = map[testIntrinsicKey]struct{}{
        {"mipsle", "math/bits", "TrailingZeros64"}:                         struct{}{},
        {"mipsle", "math/bits", "TrailingZeros8"}:                          struct{}{},
        {"mipsle", "runtime", "KeepAlive"}:                                 struct{}{},
+       {"mipsle", "runtime", "publicationBarrier"}:                        struct{}{},
        {"mipsle", "runtime", "slicebytetostringtmp"}:                      struct{}{},
        {"mipsle", "sync", "runtime_LoadAcquintptr"}:                       struct{}{},
        {"mipsle", "sync", "runtime_StoreReluintptr"}:                      struct{}{},