Austin Clements would like David Chase and Junyang Shao to review this change.
[dev.simd] simd/archsimd/_gen/cmd/specls: command to list spec API
This is a simple command-line tool to inspect and debug API generation
from the SIMD spec package.
diff --git a/src/simd/archsimd/_gen/cmd/specls/main.go b/src/simd/archsimd/_gen/cmd/specls/main.go
new file mode 100644
index 0000000..e143fb8
--- /dev/null
+++ b/src/simd/archsimd/_gen/cmd/specls/main.go
@@ -0,0 +1,80 @@
+// Copyright 2026 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// specls prints the expanded API from the SIMD spec package.
+package main
+
+import (
+ "_gen/specgen"
+ "flag"
+ "fmt"
+ "go/ast"
+ "log"
+ "os"
+ "os/exec"
+ "path/filepath"
+ "regexp"
+ "strings"
+)
+
+var (
+ flagFilter = flag.String("f", "", "only process spec functions matching `regexp`")
+ flagTrace = flag.Bool("trace", false, "trace solver steps")
+)
+
+func main() {
+ flag.Usage = func() {
+ w := flag.CommandLine.Output()
+ fmt.Fprintf(w, "usage: specls [flags] [spec dir]\n")
+ flag.CommandLine.PrintDefaults()
+ }
+
+ flag.Parse()
+ if flag.NArg() > 1 {
+ flag.Usage()
+ os.Exit(1)
+ }
+ var specDir string
+ if flag.NArg() == 1 {
+ specDir = flag.Arg(0)
+ } else {
+ goroot, err := goEnvGoroot()
+ if err != nil {
+ log.Fatalf("could not find GOROOT: %s", err)
+ }
+ specDir = filepath.Join(goroot, "src/simd/archsimd/_gen/spec")
+ }
+
+ var opts specgen.LoadOptions
+ if *flagFilter != "" {
+ re, err := regexp.Compile(*flagFilter)
+ if err != nil {
+ log.Fatal("invalid -f: ", err)
+ }
+ opts.Filter = func(fd *ast.FuncDecl) bool {
+ return re.MatchString(fd.Name.Name)
+ }
+ }
+ if *flagTrace {
+ opts.Trace = os.Stderr
+ }
+
+ funcs, err := specgen.Load(specDir, &opts)
+ if err != nil {
+ fmt.Fprintf(os.Stderr, "%s\n", err.Error())
+ }
+
+ for _, fn := range funcs {
+ fmt.Print(fn.Decl())
+ fmt.Println()
+ }
+}
+
+func goEnvGoroot() (string, error) {
+ out, err := exec.Command("go", "env", "GOROOT").Output()
+ if err != nil {
+ return "", err
+ }
+ return strings.TrimSpace(string(out)), nil
+}
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
"_gen/specgen"I need to change this to `"simd/archsimd/_gen/specgen"` to make gopls not complaint on my end.
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
I need to change this to `"simd/archsimd/_gen/specgen"` to make gopls not complaint on my end.
It sounds like you rebased this CL past the go.mod change. I'll need to do that, but right now that's not in the parent chain of this CL.
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
Austin Clements would like David Chase and Junyang Shao to review this change.
simd/archsimd/_gen/cmd/specls: command to list spec API
This is a simple command-line tool to inspect and debug API generation
from the SIMD spec package.
diff --git a/src/simd/archsimd/_gen/cmd/specls/main.go b/src/simd/archsimd/_gen/cmd/specls/main.go
new file mode 100644
index 0000000..2149d98
--- /dev/null
+++ b/src/simd/archsimd/_gen/cmd/specls/main.go
@@ -0,0 +1,66 @@
+// Copyright 2026 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// specls prints the expanded API from the SIMD spec package.
+package main
+
+import (
+ "flag"
+ "fmt"
+ "go/ast"
+ "log"
+ "os"
+ "regexp"
+ "simd/archsimd/_gen/specgen"
+)
+
+var (
+ flagFilter = flag.String("f", "", "only process spec functions matching `regexp`")
+ flagTrace = flag.Bool("trace", false, "trace solver steps")
+)
+
+func main() {
+ flag.Usage = func() {
+ w := flag.CommandLine.Output()
+ fmt.Fprintf(w, "usage: specls [flags] [spec dir]\n")
+ flag.CommandLine.PrintDefaults()
+ }
+
+ flag.Parse()
+ var specDir string
+ switch flag.NArg() {
+ case 0:
+ specDir = specgen.MustFindSpecDir()
+ case 1:
+ specDir = flag.Arg(0)
+ default:
+ flag.Usage()
+ os.Exit(1)
+ }
+
+ var opts specgen.LoadOptions
+ if *flagFilter != "" {
+ re, err := regexp.Compile(*flagFilter)
+ if err != nil {
+ log.Fatal("invalid -f: ", err)
+ }
+ opts.Filter = func(fd *ast.FuncDecl) bool {
+ return re.MatchString(fd.Name.Name)
+ }
+ }
+ if *flagTrace {
+ opts.Trace = os.Stderr
+ }
+
+ funcs, err := specgen.Load(specDir, &opts)
+ if err != nil {
+ fmt.Fprintf(os.Stderr, "%s\n\n", err.Error())
+ defer os.Exit(1)
+ }
+
+ for _, fn := range funcs {
+ fmt.Print(fn.Decl())
+ fmt.Println()
+ }
+}
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |