]> Cypherpunks repositories - gostls13.git/commitdiff
[dev.simd] cmd/compile: move simd helpers into compiler, out of generated code
authorDavid Chase <drchase@google.com>
Fri, 13 Jun 2025 20:10:22 +0000 (16:10 -0400)
committerDavid Chase <drchase@google.com>
Fri, 13 Jun 2025 21:27:02 +0000 (14:27 -0700)
PAIRED w/ arch/internal/simdgen CL 681615

This moves the helpers out of the generated code.

Change-Id: I6150afd45dbdf8d1499e0b8ee80c1bd8be5d558e
Reviewed-on: https://go-review.googlesource.com/c/go/+/681500
Reviewed-by: Cherry Mui <cherryyz@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

src/cmd/compile/internal/ssagen/intrinsics.go
src/cmd/compile/internal/ssagen/simdintrinsics.go

index d3a16a0f2431eb8a020cb3dd6c6c072f0544af45..186cfc4865ed182d188f704d77dc05debb3829d3 100644 (file)
@@ -1609,6 +1609,107 @@ func initIntrinsics(cfg *intrinsicBuildConfig) {
        }
 }
 
+func opLen1(op ssa.Op, t *types.Type) func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value {
+       return func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value {
+               return s.newValue1(op, t, args[0])
+       }
+}
+
+func opLen2(op ssa.Op, t *types.Type) func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value {
+       return func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value {
+               return s.newValue2(op, t, args[0], args[1])
+       }
+}
+
+func opLen3(op ssa.Op, t *types.Type) func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value {
+       return func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value {
+               return s.newValue3(op, t, args[0], args[1], args[2])
+       }
+}
+
+func opLen4(op ssa.Op, t *types.Type) func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value {
+       return func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value {
+               return s.newValue4(op, t, args[0], args[1], args[2], args[3])
+       }
+}
+
+func plainPanicSimdImm(s *state) {
+       cmp := s.newValue0(ssa.OpConstBool, types.Types[types.TBOOL])
+       cmp.AuxInt = 1
+       // TODO: make this a standalone panic instead of reusing the overflow panic.
+       // Or maybe after we implement the switch table this will be obsolete anyway.
+       s.check(cmp, ir.Syms.Panicoverflow)
+}
+
+func opLen1Imm8(op ssa.Op, t *types.Type, offset int) func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value {
+       return func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value {
+               if args[1].Op == ssa.OpConst8 {
+                       return s.newValue1I(op, t, args[1].AuxInt<<int64(offset), args[0])
+               }
+               plainPanicSimdImm(s)
+               // Even though this default call is unreachable semantically,
+               // it has to return something, otherwise the compiler will try to generate
+               // default codes which might lead to a FwdRef being put at the entry block
+               // triggering a compiler panic.
+               return s.newValue1I(op, t, 0, args[0])
+       }
+}
+
+func opLen2Imm8(op ssa.Op, t *types.Type, offset int) func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value {
+       return func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value {
+               if args[1].Op == ssa.OpConst8 {
+                       return s.newValue2I(op, t, args[1].AuxInt<<int64(offset), args[0], args[2])
+               }
+               plainPanicSimdImm(s)
+               // Even though this default call is unreachable semantically,
+               // it has to return something, otherwise the compiler will try to generate
+               // default codes which might lead to a FwdRef being put at the entry block
+               // triggering a compiler panic.
+               return s.newValue2I(op, t, 0, args[0], args[2])
+       }
+}
+
+func opLen3Imm8(op ssa.Op, t *types.Type, offset int) func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value {
+       return func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value {
+               if args[1].Op == ssa.OpConst8 {
+                       return s.newValue3I(op, t, args[1].AuxInt<<int64(offset), args[0], args[2], args[3])
+               }
+               plainPanicSimdImm(s)
+               // Even though this default call is unreachable semantically,
+               // it has to return something, otherwise the compiler will try to generate
+               // default codes which might lead to a FwdRef being put at the entry block
+               // triggering a compiler panic.
+               return s.newValue3I(op, t, 0, args[0], args[2], args[3])
+       }
+}
+
+func opLen4Imm8(op ssa.Op, t *types.Type, offset int) func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value {
+       return func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value {
+               if args[1].Op == ssa.OpConst8 {
+                       return s.newValue4I(op, t, args[1].AuxInt<<int64(offset), args[0], args[2], args[3], args[4])
+               }
+               plainPanicSimdImm(s)
+               // Even though this default call is unreachable semantically,
+               // it has to return something, otherwise the compiler will try to generate
+               // default codes which might lead to a FwdRef being put at the entry block
+               // triggering a compiler panic.
+               return s.newValue4I(op, t, 0, args[0], args[2], args[3], args[4])
+       }
+}
+
+func simdLoad() func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value {
+       return func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value {
+               return s.newValue2(ssa.OpLoad, n.Type(), args[0], s.mem())
+       }
+}
+
+func simdStore() func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value {
+       return func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value {
+               s.store(args[0].Type, args[1], args[0])
+               return nil
+       }
+}
+
 // findIntrinsic returns a function which builds the SSA equivalent of the
 // function identified by the symbol sym.  If sym is not an intrinsic call, returns nil.
 func findIntrinsic(sym *types.Sym) intrinsicBuilder {
index 8b9bd92a0cdebe82c2c17baa5797a16aa68f3bd5..f5492ac6e8e6b42ef77fc7ba1176f819bedf5a13 100644 (file)
@@ -1965,104 +1965,3 @@ func simdIntrinsics(addF func(pkg, fn string, b intrinsicBuilder, archFamilies .
        addF(simdPackage, "Mask8x64.And", opLen2(ssa.OpAndInt32x16, types.TypeVec512), sys.AMD64)
        addF(simdPackage, "Mask8x64.Or", opLen2(ssa.OpOrInt32x16, types.TypeVec512), sys.AMD64)
 }
-
-func opLen1(op ssa.Op, t *types.Type) func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value {
-       return func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value {
-               return s.newValue1(op, t, args[0])
-       }
-}
-
-func opLen2(op ssa.Op, t *types.Type) func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value {
-       return func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value {
-               return s.newValue2(op, t, args[0], args[1])
-       }
-}
-
-func opLen3(op ssa.Op, t *types.Type) func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value {
-       return func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value {
-               return s.newValue3(op, t, args[0], args[1], args[2])
-       }
-}
-
-func opLen4(op ssa.Op, t *types.Type) func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value {
-       return func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value {
-               return s.newValue4(op, t, args[0], args[1], args[2], args[3])
-       }
-}
-
-func plainPanicSimdImm(s *state) {
-       cmp := s.newValue0(ssa.OpConstBool, types.Types[types.TBOOL])
-       cmp.AuxInt = 1
-       // TODO: make this a standalone panic instead of reusing the overflow panic.
-       // Or maybe after we implement the switch table this will be obsolete anyway.
-       s.check(cmp, ir.Syms.Panicoverflow)
-}
-
-func opLen1Imm8(op ssa.Op, t *types.Type, offset int) func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value {
-       return func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value {
-               if args[1].Op == ssa.OpConst8 {
-                       return s.newValue1I(op, t, args[1].AuxInt<<int64(offset), args[0])
-               }
-               plainPanicSimdImm(s)
-               // Even though this default call is unreachable semantically,
-               // it has to return something, otherwise the compiler will try to generate
-               // default codes which might lead to a FwdRef being put at the entry block
-               // triggering a compiler panic.
-               return s.newValue1I(op, t, 0, args[0])
-       }
-}
-
-func opLen2Imm8(op ssa.Op, t *types.Type, offset int) func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value {
-       return func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value {
-               if args[1].Op == ssa.OpConst8 {
-                       return s.newValue2I(op, t, args[1].AuxInt<<int64(offset), args[0], args[2])
-               }
-               plainPanicSimdImm(s)
-               // Even though this default call is unreachable semantically,
-               // it has to return something, otherwise the compiler will try to generate
-               // default codes which might lead to a FwdRef being put at the entry block
-               // triggering a compiler panic.
-               return s.newValue2I(op, t, 0, args[0], args[2])
-       }
-}
-
-func opLen3Imm8(op ssa.Op, t *types.Type, offset int) func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value {
-       return func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value {
-               if args[1].Op == ssa.OpConst8 {
-                       return s.newValue3I(op, t, args[1].AuxInt<<int64(offset), args[0], args[2], args[3])
-               }
-               plainPanicSimdImm(s)
-               // Even though this default call is unreachable semantically,
-               // it has to return something, otherwise the compiler will try to generate
-               // default codes which might lead to a FwdRef being put at the entry block
-               // triggering a compiler panic.
-               return s.newValue3I(op, t, 0, args[0], args[2], args[3])
-       }
-}
-
-func opLen4Imm8(op ssa.Op, t *types.Type, offset int) func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value {
-       return func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value {
-               if args[1].Op == ssa.OpConst8 {
-                       return s.newValue4I(op, t, args[1].AuxInt<<int64(offset), args[0], args[2], args[3], args[4])
-               }
-               plainPanicSimdImm(s)
-               // Even though this default call is unreachable semantically,
-               // it has to return something, otherwise the compiler will try to generate
-               // default codes which might lead to a FwdRef being put at the entry block
-               // triggering a compiler panic.
-               return s.newValue4I(op, t, 0, args[0], args[2], args[3], args[4])
-       }
-}
-
-func simdLoad() func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value {
-       return func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value {
-               return s.newValue2(ssa.OpLoad, n.Type(), args[0], s.mem())
-       }
-}
-
-func simdStore() func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value {
-       return func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value {
-               s.store(args[0].Type, args[1], args[0])
-               return nil
-       }
-}