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