2022-11-27 18:32:31 -08:00
|
|
|
// Package opcodesextra provides curated extensions to the instruction database.
|
|
|
|
|
package opcodesextra
|
|
|
|
|
|
2023-01-14 13:25:44 -08:00
|
|
|
import (
|
|
|
|
|
"sort"
|
|
|
|
|
|
|
|
|
|
"github.com/mmcloughlin/avo/internal/inst"
|
|
|
|
|
)
|
2022-11-27 18:32:31 -08:00
|
|
|
|
|
|
|
|
// sets of extra instructions.
|
|
|
|
|
var sets = [][]*inst.Instruction{
|
|
|
|
|
movlqzx,
|
2022-11-27 18:53:46 -08:00
|
|
|
gfni,
|
2023-01-07 21:55:36 -08:00
|
|
|
vaes,
|
2023-01-08 11:42:48 -08:00
|
|
|
vnni,
|
2023-01-09 21:38:43 -08:00
|
|
|
vpclmulqdq,
|
2023-01-09 22:36:27 -08:00
|
|
|
vpopcntdq,
|
2023-01-10 18:55:12 -08:00
|
|
|
bitalg,
|
2023-01-14 13:25:44 -08:00
|
|
|
vbmi2,
|
2022-11-27 18:32:31 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Instructions returns a list of extras to add to the instructions database.
|
2022-11-27 18:53:46 -08:00
|
|
|
//
|
|
|
|
|
// 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.
|
2022-11-27 18:32:31 -08:00
|
|
|
func Instructions() []*inst.Instruction {
|
2022-11-27 18:53:46 -08:00
|
|
|
// 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.
|
2022-11-27 18:32:31 -08:00
|
|
|
var is []*inst.Instruction
|
|
|
|
|
for _, set := range sets {
|
2022-11-27 18:53:46 -08:00
|
|
|
for _, i := range set {
|
|
|
|
|
c := i.Clone()
|
|
|
|
|
is = append(is, &c)
|
|
|
|
|
}
|
2022-11-27 18:32:31 -08:00
|
|
|
}
|
2023-01-14 13:25:44 -08:00
|
|
|
|
|
|
|
|
// Sort ISA lists. Similarly, this facilitates sharing helper functions for
|
|
|
|
|
// building forms lists without worrying about whether the ISA list is in
|
|
|
|
|
// the right order.
|
|
|
|
|
for _, i := range is {
|
|
|
|
|
for idx := range i.Forms {
|
|
|
|
|
sort.Strings(i.Forms[idx].ISA)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-27 18:32:31 -08:00
|
|
|
return is
|
|
|
|
|
}
|