Files
avo/internal/opcodesextra/instructions.go
Michael McLoughlin 946323570a all: add GFNI instructions (#344)
Adds support for the GFNI "Galois Field New Instructions" instruction set.

These instructions are not included in the Opcodes database, therefore they're
added using the "extras" mechanism introduced in #345.

For simplicity, the loading phase is updated slightly so that AVX-512 form
expansion rules are applied after extras are added to the list. This greatly
reduces the number of forms that have to be specified by hand.

Based on #343
Fixes #335

Co-authored-by: Klaus Post <klauspost@gmail.com>
2022-11-27 18:53:46 -08:00

34 lines
1.1 KiB
Go

// Package opcodesextra provides curated extensions to the instruction database.
package opcodesextra
import "github.com/mmcloughlin/avo/internal/inst"
// sets of extra instructions.
var sets = [][]*inst.Instruction{
movlqzx,
gfni,
}
// Instructions returns a list of extras to add to the instructions database.
//
// Note that instructions returned are expected to be injected into the loading
// process, as if they had been read out of the Opcodes database. As such, they
// are not expected to be in the final form required for the instruction
// database. For example, AVX-512 instruction form transformations do not need
// to be applied, and operand types such as xmm{k}{z} or m256/m64bcst may be
// used for brevity.
func Instructions() []*inst.Instruction {
// Concatenate and clone the instruction lists. It can be convenient for
// forms lists and other data structures to be shared in the curated lists,
// but we want to return distinct copies here to avoid subtle bugs in
// consumers.
var is []*inst.Instruction
for _, set := range sets {
for _, i := range set {
c := i.Clone()
is = append(is, &c)
}
}
return is
}