1
2
3
4
5 package sve
6
7 import (
8 "flag"
9 "strings"
10 "testing"
11 )
12
13
14
15
16 var svePath = flag.String("svePath", "", "path to extracted ISA_A64 XML directory")
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31 func TestRealXMLNoAnomalies(t *testing.T) {
32 if *svePath == "" {
33 t.Skip("set -svePath to an extracted ISA_A64 XML directory")
34 }
35 r, err := analyze(*svePath)
36 if err != nil {
37 t.Fatal(err)
38 }
39 t.Logf("\n%s", r.String())
40 if len(r.Anomalies) > 0 {
41 t.Errorf("loader did not understand %d instruction form(s):\n %s",
42 len(r.Anomalies), strings.Join(r.Anomalies, "\n "))
43 }
44 }
45
46
47
48 func TestRealXMLAddFamily(t *testing.T) {
49 if *svePath == "" {
50 t.Skip("set -svePath to an extracted ISA_A64 XML directory")
51 }
52 insts, err := parseInstructions(*svePath)
53 if err != nil {
54 t.Fatal(err)
55 }
56
57 want := map[string]bool{"ADD": false, "FADD": false, "SQADD": false, "UQADD": false}
58 for _, inst := range insts {
59 m := inst.mnemonic()
60 if _, ok := want[m]; !ok {
61 continue
62 }
63 if len(inst.emitAll()) > 0 {
64 want[m] = true
65 }
66 }
67 for m, ok := range want {
68 if !ok {
69 t.Errorf("expected %s to emit at least one def", m)
70 }
71 }
72 }
73
View as plain text