Extends avo to support most AVX-512 instruction sets.
The instruction type is extended to support suffixes. The K family of opmask
registers is added to the register package, and the operand package is updated
to support the new operand types. Move instruction deduction in `Load` and
`Store` is extended to support KMOV* and VMOV* forms.
Internal code generation packages were overhauled. Instruction database loading
required various messy changes to account for the additional complexities of the
AVX-512 instruction sets. The internal/api package was added to introduce a
separation between instruction forms in the database, and the functions avo
provides to create them. This was required since with instruction suffixes there
is no longer a one-to-one mapping between instruction constructors and opcodes.
AVX-512 bloated generated source code size substantially, initially increasing
compilation and CI test times to an unacceptable level. Two changes were made to
address this:
1. Instruction constructors in the `x86` package moved to an optab-based
approach. This compiles substantially faster than the verbose code
generation we had before.
2. The most verbose code-generated tests are moved under build tags and
limited to a stress test mode. Stress test builds are run on
schedule but not in regular CI.
An example of AVX-512 accelerated 16-lane MD5 is provided to demonstrate and
test the new functionality.
Updates #20 #163 #229
Co-authored-by: Vaughn Iverson <vsivsi@yahoo.com>
76 lines
2.1 KiB
Go
76 lines
2.1 KiB
Go
package api
|
|
|
|
import (
|
|
"path"
|
|
"sort"
|
|
"strings"
|
|
)
|
|
|
|
const (
|
|
// Package is the avo package import path.
|
|
Package = "github.com/mmcloughlin/avo"
|
|
|
|
// IRPackage is the package that defines intermediate representation types.
|
|
IRPackage = "ir"
|
|
|
|
// OperandPackage is the package for operand types.
|
|
OperandPackage = "operand"
|
|
|
|
// OperandType is the type used for operands.
|
|
OperandType = OperandPackage + ".Op"
|
|
|
|
// RegisterPackage is the name of the package containing register types.
|
|
RegisterPackage = "reg"
|
|
|
|
// RegisterType is the type used for registers.
|
|
RegisterType = RegisterPackage + ".Register"
|
|
)
|
|
|
|
// ImportPath returns the full import path for an avo subpackage.
|
|
func ImportPath(pkg string) string {
|
|
return path.Join(Package, pkg)
|
|
}
|
|
|
|
// ImplicitRegisterIdentifier maps an implicit register name to a string
|
|
// suitable for a related Go identifier.
|
|
func ImplicitRegisterIdentifier(r string) string {
|
|
r = strings.Replace(r, "mm", "", 1) // handles the "xmm0" type
|
|
return strings.ToUpper(r)
|
|
}
|
|
|
|
// ImplicitRegister returns avo syntax for the given implicit register type (from Opcodes XML).
|
|
func ImplicitRegister(r string) string {
|
|
return RegisterPackage + "." + ImplicitRegisterIdentifier(r)
|
|
}
|
|
|
|
// OperandTypeIdentifier maps an operand type to a string suitable for a related
|
|
// Go identifier.
|
|
func OperandTypeIdentifier(t string) string {
|
|
return strings.ToUpper(strings.ReplaceAll(t, "/", ""))
|
|
}
|
|
|
|
// CheckerName returns the name of the function that checks an operand of type t.
|
|
func CheckerName(t string) string {
|
|
return "operand.Is" + OperandTypeIdentifier(t)
|
|
}
|
|
|
|
// ISAsIdentifier returns a string representation of an ISA list that suitable
|
|
// for use in a Go identifier.
|
|
func ISAsIdentifier(isas []string) string {
|
|
if len(isas) == 0 {
|
|
return "Base"
|
|
}
|
|
sorted := append([]string(nil), isas...)
|
|
sort.Strings(sorted)
|
|
ident := strings.Join(sorted, "_")
|
|
ident = strings.ReplaceAll(ident, ".", "") // SSE4.1
|
|
ident = strings.ReplaceAll(ident, "+", "") // MMX+
|
|
return ident
|
|
}
|
|
|
|
// SuffixesClassIdentifier returns a string representation of a suffix class
|
|
// that's suitable for use in a Go identifier.
|
|
func SuffixesClassIdentifier(c string) string {
|
|
return strings.ToUpper(c)
|
|
}
|