Source file src/internal/simd/variants/variants.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 variants 6 7 // DO NOT EDIT WITHOUT READING THIS FIRST. 8 9 // This file is shared by the simd bridge generator 10 // and the compiler's midway tree rewriter. The sharing 11 // is facilitated by an automatic copy from the file 12 // embedded in the simd bridge generator, which itself 13 // copies it from its "variants" subdirectory. To 14 // change this file, edit the copy in 15 // src/simd/archsimd/_gen/midway/variants/variants.go, 16 // and then rerun ("go run") the simd bridge generator 17 // and it will create a bridge consistent with the contents 18 // of this file, for use with a compiler built to use this 19 // file. Minor version skews will only affect code 20 // (e.g., rebuilding the compiler) that uses "simd" 21 // (not "archsimd") and that runs on hardware lacking 22 // the expected feature set. In the worst case, 23 // GODEBUG=simd=0 will avoid the problem, unless it 24 // involves missing emulation methods (which you are 25 // expected to write anyway if you are tinkering with 26 // this code). 27 28 type Key struct { 29 Arch string 30 Size int 31 } 32 33 type Variant struct { 34 Suffix string // the name (suffix) for this variant. 35 Emulated map[string]bool // Methods that are emulated for this variant. 36 DefaultRequires string // default requires this function return true, false means variant. 37 } 38 39 // Name returns the variant name of type t. 40 // If receiver v is nil, returns t. 41 func (v *Variant) Name(t string) string { 42 if v == nil { 43 return t 44 } 45 return t + v.Suffix 46 } 47 48 var Variants map[Key]*Variant 49 50 func init() { 51 Variants = make(map[Key]*Variant) 52 Variants[Key{"arm64", 128}] = &Variant{ 53 Suffix: "nclm", 54 Emulated: map[string]bool{ 55 "CarrylessMultiplyEven": true, 56 "CarrylessMultiplyOdd": true, 57 }, 58 DefaultRequires: "HasHardwareCarrylessMultiply", 59 } 60 61 } 62