Debian Codegraph @

internal/opcodesextra/instructions.go

raw symbols SCIP
1 // Package opcodesextra provides curated extensions to the instruction database.
2 package opcodesextra
3
4 import (
5 "sort"
6
7 "github.com/mmcloughlin/avo/internal/inst"
8 )
9
10 // sets of extra instructions.
11 var sets = [][]*inst.Instruction{
12 movlqzx,
13 gfni,
14 vaes,
15 vnni,
16 vpclmulqdq,
17 vpopcntdq,
18 bitalg,
19 vbmi2,
20 }
21
22 // Instructions returns a list of extras to add to the instructions database.
23 //
24 // Note that instructions returned are expected to be injected into the loading
25 // process, as if they had been read out of the Opcodes database. As such, they
26 // are not expected to be in the final form required for the instruction
27 // database. For example, AVX-512 instruction form transformations do not need
28 // to be applied, and operand types such as xmm{k}{z} or m256/m64bcst may be
29 // used for brevity.
30 func Instructions() []*inst.Instruction {
31 // Concatenate and clone the instruction lists. It can be convenient for
32 // forms lists and other data structures to be shared in the curated lists,
33 // but we want to return distinct copies here to avoid subtle bugs in
34 // consumers.
35 var is []*inst.Instruction
36 for _, set := range sets {
37 for _, i := range set {
38 c := i.Clone()
39 is = append(is, &c)
40 }
41 }
42
43 // Sort ISA lists. Similarly, this facilitates sharing helper functions for
44 // building forms lists without worrying about whether the ISA list is in
45 // the right order.
46 for _, i := range is {
47 for idx := range i.Forms {
48 sort.Strings(i.Forms[idx].ISA)
49 }
50 }
51
52 return is
53 }