1
2
3
4
5 package main
6
7 import (
8 "fmt"
9 "go/token"
10 "regexp"
11
12 "simd/archsimd/_gen/sgutil"
13 "simd/archsimd/_gen/specgen"
14 )
15
16
17
18 func apiPhase() sgutil.Phase {
19 if CurrentArch().isSVE() {
20 return sgutil.PhaseExperiment
21 }
22 return sgutil.PhaseStable
23 }
24
25
26
27
28
29
30
31
32 func opPhase(op Operation, specIdx *specgen.Index) sgutil.Phase {
33 recv, name, ok := opDecl(op)
34 if !ok {
35 return sgutil.PhaseExperiment
36 }
37 if token.IsExported(name) && specIdx.IsExperiment(recv, name) {
38 return sgutil.PhaseExperiment
39 }
40 return sgutil.PhaseStable
41 }
42
43 var stubDeclRE = regexp.MustCompile(`(?m)^func \(\w+ (\w+)\) (\w+)\(`)
44
45
46
47 func opDecl(op Operation) (recv, name string, ok bool) {
48 stub, ok := opStub(op)
49 if !ok {
50 return "", "", false
51 }
52
53
54
55 m := stubDeclRE.FindSubmatch(stub)
56 if m == nil {
57 panic(fmt.Errorf("can't find method declaration in stub for op %v:\n%s", op.Go, stub))
58 }
59 return string(m[1]), string(m[2]), true
60 }
61
View as plain text