Source file src/simd/archsimd/_gen/sgutil/phase.go

     1  // Copyright 2026 The Go Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  package sgutil
     6  
     7  import "fmt"
     8  
     9  // A Phase identifies the GOEXPERIMENT that enables an API or a file. Phases
    10  // are ordered from least to most stable, and the zero Phase means the phase
    11  // is unknown (or, for an [Output], that it isn't enabled by a GOEXPERIMENT).
    12  type Phase int
    13  
    14  const (
    15  	// PhaseExperiment APIs are enabled only by GOEXPERIMENT=simd.
    16  	PhaseExperiment Phase = 1
    17  
    18  	// PhaseStable APIs are generally available, enabled by
    19  	// GOEXPERIMENT=simdstable (which GOEXPERIMENT=simd implies).
    20  	PhaseStable Phase = 2
    21  )
    22  
    23  // Experiment returns the GOEXPERIMENT that enables phase p.
    24  func (p Phase) Experiment() string {
    25  	switch p {
    26  	case PhaseStable:
    27  		return "simdstable"
    28  	case PhaseExperiment:
    29  		return "simd"
    30  	}
    31  	panic(fmt.Sprintf("unknown phase %d", int(p)))
    32  }
    33  
    34  func (p Phase) String() string {
    35  	return p.Experiment()
    36  }
    37  
    38  // AllPhaseTags lists the build tags that a phase's GOEXPERIMENT can set (see
    39  // [Phase.BuildTags]).
    40  var AllPhaseTags = []string{"goexperiment.simdstable", "goexperiment.simd"}
    41  
    42  // BuildTags returns the build tags that the GOEXPERIMENT of phase p sets: none
    43  // for the zero Phase, goexperiment.simdstable for [PhaseStable], and both
    44  // goexperiment.simdstable and goexperiment.simd for [PhaseExperiment].
    45  func (p Phase) BuildTags() []string {
    46  	switch p {
    47  	case 0:
    48  		return nil
    49  	case PhaseStable:
    50  		return []string{"goexperiment.simdstable"}
    51  	case PhaseExperiment:
    52  		return []string{"goexperiment.simdstable", "goexperiment.simd"}
    53  	}
    54  	panic(fmt.Sprintf("unknown phase %d", int(p)))
    55  }
    56  

View as plain text