1
2
3
4
5 package sve
6
7 import (
8 "sort"
9
10 "simd/archsimd/_gen/unify"
11
12 "golang.org/x/arch/arm64/instgen/xmlspec"
13 )
14
15
16
17 func parseInstructions(path string) ([]*Instruction, error) {
18 xmlInsts := xmlspec.ParseXMLFiles(path)
19
20
21
22 var insts []*Instruction
23 for _, xmlInst := range xmlInsts {
24 if xmlInst == nil {
25 continue
26 }
27 for i := range xmlInst.Instruction.Classes.Iclass {
28 inst := &Instruction{
29 Instruction: xmlInst.Instruction,
30 iclass: &xmlInst.Instruction.Classes.Iclass[i],
31 }
32 if inst.mnemonic() == "" || !inst.isSVE() {
33
34 continue
35 }
36 insts = append(insts, inst)
37 }
38 }
39
40 sort.Slice(insts, func(i, j int) bool {
41 return insts[i].mnemonic() < insts[j].mnemonic()
42 })
43 return insts, nil
44 }
45
46
47
48 func Load(path string) ([]*unify.Value, error) {
49 insts, err := parseInstructions(path)
50 if err != nil {
51 return nil, err
52 }
53 var defs []*unify.Value
54 for _, inst := range insts {
55 defs = append(defs, inst.emitAll()...)
56 }
57 return defs, nil
58 }
59
View as plain text