sgutil

package standard library
go1.27.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 2, 2026 License: None detected not legal advice Imports: 0 Imported by: 0

Documentation

Index

Constants

View Source
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

View Source
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}}
	}
`)
View Source
var CvtToIntsIntrinsic = templateOf("cvtToIntIntrin", `{{.From.Name_}}.`+ConvertToIntName)
View Source
var CvtToUintsIntrinsic = templateOf("cvtToUintIntrin", `{{.To.Name_}}.`+ConvertToUintName)

Also used in a to-from-reversed context.

View Source
var ReshapeCall = templateOf("toBitsCall", "."+ReshapeName+"()")
View Source
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_}}
`)
View Source
var ReshapeIntrinsic = templateOf("reshapeIntrinsic", `{{.From.Name_}}.`+ReshapeName)
View Source
var ToBitsCall = templateOf("toBitsCall", "."+ToBitsName+"()")
View Source
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_}}
`)
View Source
var ToBitsIntrinsic = templateOf("toBitsIntrin", `{{.To.Name_}}.`+ToBitsName)

ToBitsIntrinsic is used in a uint -> T context, but reverse, so T is method receiver.

View Source
var ToFloatsCall = templateOf("toBitsCall", "."+ToFloatsName+"()")
View Source
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_}}
`)
View Source
var ToFloatsIntrinsic = templateOf("toFloatsIntrin", `{{.From.Name_}}.`+ToFloatsName)
View Source
var ToIntsCall = templateOf("toBitsCall", "."+ToIntsName+"()")
View Source
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_}}
`)
View Source
var ToIntsIntrinsic = templateOf("toIntsIntrin", `{{.From.Name_}}.`+ToIntsName)

Functions

func CompareNatural

func CompareNatural(s1, s2 string) int

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 CreatePath

func CreatePath(newFile string) (*os.File, error)

func FormatWriteAndClose

func FormatWriteAndClose(source *bytes.Buffer, newFile string)

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

func NumberLines(data []byte) string

NumberLines takes a slice of bytes, and returns a string where each line is numbered, starting from 1.

func TemplateNamed

func TemplateNamed(name, temp string) *template.Template

TemplateNamedreturns a parsed template from temp, named name.

func WriteAndClose

func WriteAndClose(b []byte, newFile string)

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

func (im *InsertMap[K, V]) All() iter.Seq2[K, V]

All returns an iterator over the key-value pairs of the map in insertion order.

func (*InsertMap[K, V]) Compare

func (im *InsertMap[K, V]) Compare(a, b K) int

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]) Contains

func (im *InsertMap[K, V]) Contains(key K) bool

Contains reports whether the map contains the specified key.

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

func (im *InsertMap[K, V]) GetOk(key K) (V, bool)

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

func (im *InsertMap[K, V]) Keys() iter.Seq[K]

Keys returns an iterator over the keys of the map in insertion order.

func (*InsertMap[K, V]) Put

func (im *InsertMap[K, V]) Put(key K, val V) (old V, updated bool)

Put inserts or updates a key-value pair in the map. If the key already exists, its value is updated while its insertion order remains unchanged. Returns the old value if there is one, and a boolean indicating whether an update occurred.

func (*InsertMap[K, V]) Values

func (im *InsertMap[K, V]) Values() iter.Seq[V]

Values returns an iterator over the values of the map in insertion order.

type TforAsBits

type TforAsBits interface {
	ElemBits() int
	Name_() string
}

type TypeDotMethod

type TypeDotMethod struct {
	TypeDotMethod string
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL