Documentation
¶
Index ¶
- Constants
- Variables
- func CompareNatural(s1, s2 string) int
- func CreatePath(newFile string) (*os.File, error)
- func FormatWriteAndClose(source *bytes.Buffer, newFile string)
- func MergeSIMDGenericOps(newOps []GenericOpsData, oldFile, currentArch string) *bytes.Buffer
- func NumberLines(data []byte) string
- func TemplateNamed(name, temp string) *template.Template
- func WriteAndClose(b []byte, newFile string)
- type AsConversion
- type GenericOpsData
- type InsertMap
- func (im *InsertMap[K, V]) All() iter.Seq2[K, V]
- func (im *InsertMap[K, V]) Compare(a, b K) int
- func (im *InsertMap[K, V]) Contains(key K) bool
- func (im *InsertMap[K, V]) Get(key K) V
- func (im *InsertMap[K, V]) GetOk(key K) (V, bool)
- func (im *InsertMap[K, V]) Keys() iter.Seq[K]
- func (im *InsertMap[K, V]) Put(key K, val V) (old V, updated bool)
- func (im *InsertMap[K, V]) Values() iter.Seq[V]
- type TforAsBits
- type TypeDotMethod
Constants ¶
const ( ToBitsName = "ToBits" ToIntsName = "BitsToInt{{.To.ElemBits}}" ConvertToIntName = "ConvertToInt{{.To.ElemBits}}" ConvertToUintName = "ConvertToUint{{.From.ElemBits}}" // backwards because done with ToInts ToFloatsName = "BitsToFloat{{.To.ElemBits}}" ReshapeName = "ReshapeToUint{{.To.ElemBits}}s" )
Variables ¶
var AsOp = templateOf("asConversion", `
// As{{.To.Name}} reinterprets the bits of a {{.From.Name}} vector as a {{.To.Name}} vector
//
// Deprecated: use combinations of ToBits, BitsTo{Int<N>,Float<N>}, ReshapeToUint<N>
//
//go:fix inline
func (x {{.From.Name}}) As{{.To.Name}}() {{.To.Name}} {
return x{{.AsTranslation}}
}
`)
var CvtToIntsIntrinsic = templateOf("cvtToIntIntrin", `{{.From.Name_}}.`+ConvertToIntName)
var CvtToUintsIntrinsic = templateOf("cvtToUintIntrin", `{{.To.Name_}}.`+ConvertToUintName)
Also used in a to-from-reversed context.
var ReshapeCall = templateOf("toBitsCall", "."+ReshapeName+"()")
var ReshapeDcl = templateOf("reshapeDcl", ` // `+ReshapeName+` reinterprets the bits of a {{.From.Name_}} vector as a {{.To.Name_}} vector func (x {{.From.Name_}}) `+ReshapeName+`() {{.To.Name_}} `)
var ReshapeIntrinsic = templateOf("reshapeIntrinsic", `{{.From.Name_}}.`+ReshapeName)
var ToBitsCall = templateOf("toBitsCall", "."+ToBitsName+"()")
var ToBitsDcl = templateOf("toBitsDcl", ` // `+ToBitsName+` reinterprets the bits of a {{.From.Name_}} vector as a {{.To.Name_}} vector func (x {{.From.Name_}}) `+ToBitsName+`() {{.To.Name_}} `)
var ToBitsIntrinsic = templateOf("toBitsIntrin", `{{.To.Name_}}.`+ToBitsName)
ToBitsIntrinsic is used in a uint -> T context, but reverse, so T is method receiver.
var ToFloatsCall = templateOf("toBitsCall", "."+ToFloatsName+"()")
var ToFloatsDcl = templateOf("toFloatsDcl", ` // `+ToFloatsName+` reinterprets the bits of a {{.From.Name_}} vector as a {{.To.Name_}} vector func (x {{.From.Name_}}) `+ToFloatsName+`() {{.To.Name_}} `)
var ToFloatsIntrinsic = templateOf("toFloatsIntrin", `{{.From.Name_}}.`+ToFloatsName)
var ToIntsCall = templateOf("toBitsCall", "."+ToIntsName+"()")
var ToIntsDcl = templateOf("toIntsDcl", ` // `+ToIntsName+` reinterprets the bits of a {{.From.Name_}} vector as a {{.To.Name_}} vector func (x {{.From.Name_}}) `+ToIntsName+`() {{.To.Name_}} // `+ConvertToIntName+` converts a {{.From.Name_}} vector to a {{.To.Name_}} vector func (x {{.From.Name_}}) `+ConvertToIntName+`() {{.To.Name_}} // `+ConvertToUintName+` converts a {{.To.Name_}} vector to a {{.From.Name_}} vector func (x {{.To.Name_}}) `+ConvertToUintName+`() {{.From.Name_}} `)
var ToIntsIntrinsic = templateOf("toIntsIntrin", `{{.From.Name_}}.`+ToIntsName)
Functions ¶
func CompareNatural ¶
CompareNatural performs a "natural sort" comparison of two strings. It compares non-digit sections lexicographically and digit sections numerically. In the case of string-unequal "equal" strings like "a01b" and "a1b", strings.Compare breaks the tie.
It returns:
-1 if s1 < s2 0 if s1 == s2 +1 if s1 > s2
func FormatWriteAndClose ¶
FormatWriteAndClose formats the Go source code in source and writes it to newFile. If there is a problem with the formatting, the entire source is numbered and emitted along with the error message, to help figure out where the source code generation went wrong.
func MergeSIMDGenericOps ¶
func MergeSIMDGenericOps(newOps []GenericOpsData, oldFile, currentArch string) *bytes.Buffer
MergeSIMDGenericOps merges a new set of generic ops with the existing ones read from goroot "/" file.
func NumberLines ¶
NumberLines takes a slice of bytes, and returns a string where each line is numbered, starting from 1.
func TemplateNamed ¶
TemplateNamedreturns a parsed template from temp, named name.
func WriteAndClose ¶
WriteAndClose creates newFile, writes g to it, and closes the file.
Types ¶
type AsConversion ¶
type AsConversion struct {
From, To TforAsBits
}
func Conversion ¶
func Conversion(from, to TforAsBits) *AsConversion
func (*AsConversion) AsTranslation ¶
func (a *AsConversion) AsTranslation() string
func (*AsConversion) ExecuteIntrinsicTemplateOfTypeDotMethod ¶
func (c *AsConversion) ExecuteIntrinsicTemplateOfTypeDotMethod(w io.Writer, t *template.Template)
ExecuteIntrinsicTemplateOfTypeDotMethod executes the template t on a variety of TypeDotMethod inputs with template parameter TypeDotMethod
func (*AsConversion) TypeDotMethod ¶
func (c *AsConversion) TypeDotMethod(t *template.Template) *TypeDotMethod
type GenericOpsData ¶
type GenericOpsData struct {
OpName string
OpInLen int
Comm bool
HasAux bool
Archs []string // e.g. ["amd64","arm64"]
}
GenericOpsData holds one generic op entry for template rendering.
func (GenericOpsData) ArchTag ¶
func (d GenericOpsData) ArchTag() string
ArchTag returns the comma-separated arch list for the template comment.
type InsertMap ¶
type InsertMap[K comparable, V any] struct { // contains filtered or unexported fields }
func (*InsertMap[K, V]) All ¶
All returns an iterator over the key-value pairs of the map in insertion order.
func (*InsertMap[K, V]) Compare ¶
Compare compares two keys based on their insertion order. It returns:
- -1 if 'a' was inserted before 'b'
- 1 if 'a' was inserted after 'b'
- 0 if 'a' and 'b' are equal, or if neither key exists in the map.
If only one of the keys exists in the map, the existing key is considered to be "before" (less than) the non-existing key, returning -1 if 'a' exists, and 1 if 'b' exists.
func (*InsertMap[K, V]) Get ¶
func (im *InsertMap[K, V]) Get(key K) V
Get returns the value associated with the specified key. If the key does not exist, the zero value of type V is returned.
func (*InsertMap[K, V]) GetOk ¶
GetOk returns the value associated with the specified key and a boolean indicating whether the key exists in the map. If the key is not in the map, the zero value is returned along with false.
func (*InsertMap[K, V]) Keys ¶
Keys returns an iterator over the keys of the map in insertion order.
type TforAsBits ¶
type TypeDotMethod ¶
type TypeDotMethod struct {
TypeDotMethod string
}