cmd/compile/internal: intrinsify publicationBarrier on mipsx

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>
This commit is contained in:
Julian Zhu 2025-05-21 16:36:53 +08:00 committed by Gopher Robot
parent 3a7a856951
commit 3dbc775d60
7 changed files with 23 additions and 1 deletions

View File

@ -804,6 +804,9 @@ func ssaGenValue(s *ssagen.State, v *ssa.Value) {
p := s.Prog(obj.AGETCALLERPC) p := s.Prog(obj.AGETCALLERPC)
p.To.Type = obj.TYPE_REG p.To.Type = obj.TYPE_REG
p.To.Reg = v.Reg() p.To.Reg = v.Reg()
case ssa.OpMIPSLoweredPubBarrier:
// SYNC
s.Prog(v.Op.Asm())
case ssa.OpClobber, ssa.OpClobberReg: case ssa.OpClobber, ssa.OpClobberReg:
// TODO: implement for clobberdead experiment. Nop is ok for now. // TODO: implement for clobberdead experiment. Nop is ok for now.
default: default:

View File

@ -420,6 +420,9 @@
// Write barrier. // Write barrier.
(WB ...) => (LoweredWB ...) (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) == 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) == 1 => (LoweredPanicBoundsB [kind] x y mem)
(PanicBounds [kind] x y mem) && boundsABI(kind) == 2 => (LoweredPanicBoundsC [kind] x y mem) (PanicBounds [kind] x y mem) && boundsABI(kind) == 2 => (LoweredPanicBoundsC [kind] x y mem)

View File

@ -408,6 +408,9 @@ func init() {
// Returns a pointer to a write barrier buffer in R25. // 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"}, {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. // 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 // 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. // default registers to match so we don't need to copy registers around unnecessarily.

View File

@ -2076,6 +2076,7 @@ const (
OpMIPSLoweredGetCallerSP OpMIPSLoweredGetCallerSP
OpMIPSLoweredGetCallerPC OpMIPSLoweredGetCallerPC
OpMIPSLoweredWB OpMIPSLoweredWB
OpMIPSLoweredPubBarrier
OpMIPSLoweredPanicBoundsA OpMIPSLoweredPanicBoundsA
OpMIPSLoweredPanicBoundsB OpMIPSLoweredPanicBoundsB
OpMIPSLoweredPanicBoundsC OpMIPSLoweredPanicBoundsC
@ -27990,6 +27991,13 @@ var opcodeTable = [...]opInfo{
}, },
}, },
}, },
{
name: "LoweredPubBarrier",
argLen: 1,
hasSideEffects: true,
asm: mips.ASYNC,
reg: regInfo{},
},
{ {
name: "LoweredPanicBoundsA", name: "LoweredPanicBoundsA",
auxType: auxInt64, auxType: auxInt64,

View File

@ -450,6 +450,9 @@ func rewriteValueMIPS(v *Value) bool {
return rewriteValueMIPS_OpPanicBounds(v) return rewriteValueMIPS_OpPanicBounds(v)
case OpPanicExtend: case OpPanicExtend:
return rewriteValueMIPS_OpPanicExtend(v) return rewriteValueMIPS_OpPanicExtend(v)
case OpPubBarrier:
v.Op = OpMIPSLoweredPubBarrier
return true
case OpRotateLeft16: case OpRotateLeft16:
return rewriteValueMIPS_OpRotateLeft16(v) return rewriteValueMIPS_OpRotateLeft16(v)
case OpRotateLeft32: case OpRotateLeft32:

View File

@ -163,7 +163,7 @@ func initIntrinsics(cfg *intrinsicBuildConfig) {
s.vars[memVar] = s.newValue1(ssa.OpPubBarrier, types.TypeMem, s.mem()) s.vars[memVar] = s.newValue1(ssa.OpPubBarrier, types.TypeMem, s.mem())
return nil 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 ********/ /******** internal/runtime/sys ********/
add("internal/runtime/sys", "GetCallerPC", add("internal/runtime/sys", "GetCallerPC",

View File

@ -554,6 +554,7 @@ var wantIntrinsics = map[testIntrinsicKey]struct{}{
{"mips", "math/bits", "TrailingZeros64"}: struct{}{}, {"mips", "math/bits", "TrailingZeros64"}: struct{}{},
{"mips", "math/bits", "TrailingZeros8"}: struct{}{}, {"mips", "math/bits", "TrailingZeros8"}: struct{}{},
{"mips", "runtime", "KeepAlive"}: struct{}{}, {"mips", "runtime", "KeepAlive"}: struct{}{},
{"mips", "runtime", "publicationBarrier"}: struct{}{},
{"mips", "runtime", "slicebytetostringtmp"}: struct{}{}, {"mips", "runtime", "slicebytetostringtmp"}: struct{}{},
{"mips", "sync", "runtime_LoadAcquintptr"}: struct{}{}, {"mips", "sync", "runtime_LoadAcquintptr"}: struct{}{},
{"mips", "sync", "runtime_StoreReluintptr"}: struct{}{}, {"mips", "sync", "runtime_StoreReluintptr"}: struct{}{},
@ -799,6 +800,7 @@ var wantIntrinsics = map[testIntrinsicKey]struct{}{
{"mipsle", "math/bits", "TrailingZeros64"}: struct{}{}, {"mipsle", "math/bits", "TrailingZeros64"}: struct{}{},
{"mipsle", "math/bits", "TrailingZeros8"}: struct{}{}, {"mipsle", "math/bits", "TrailingZeros8"}: struct{}{},
{"mipsle", "runtime", "KeepAlive"}: struct{}{}, {"mipsle", "runtime", "KeepAlive"}: struct{}{},
{"mipsle", "runtime", "publicationBarrier"}: struct{}{},
{"mipsle", "runtime", "slicebytetostringtmp"}: struct{}{}, {"mipsle", "runtime", "slicebytetostringtmp"}: struct{}{},
{"mipsle", "sync", "runtime_LoadAcquintptr"}: struct{}{}, {"mipsle", "sync", "runtime_LoadAcquintptr"}: struct{}{},
{"mipsle", "sync", "runtime_StoreReluintptr"}: struct{}{}, {"mipsle", "sync", "runtime_StoreReluintptr"}: struct{}{},