Debian Codegraph @

arm64/instgen/xmlspec/parsed.go

raw symbols SCIP
1 // Copyright 2026 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
4
5 package xmlspec
6
7 // This file contains the parsed data type.
8
9 // The unexported fields are filled by the parser. Example:
10 // For instruction ADD predicated
11 // https://developer.arm.com/documentation/111108/2025-12/SVE-Instructions/ADD--vectors--predicated---Add--predicated--?lang=en)
12 // - parsed data in RegDiagram
13 // --- Parsed Data ---
14 // fixedBin: 0x4000000
15 // mask: 0xff3fe000
16 // varBin:
17 // size: [22, 24]
18 // Pg: [10, 13]
19 // Zm: [5, 10]
20 // Zdn: [0, 5]
21 // parsed: true
22 // --- Parsed Data ---
23 //
24 // - parsed data in Encoding
25 // --- Parsed Data ---
26 // binary: 0x4000000
27 // mask: 0xff3fe000
28 // asm: ADD <Zdn>.<T>, <Pg>/M, <Zdn>.<T>, <Zm>.<T>
29 // goOp: AZADD
30 // arm64Op: A64ADD
31 // class: C_SVE
32 // invalid: false
33 // alias: false
34 // prefix: AZ
35 // operands:
36 // operand{
37 // name: ADD
38 // typ:
39 // elems:
40 // }
41 // operand{
42 // name: <Zm>.<T>
43 // typ: AC_ARNG
44 // elems:
45 // element{
46 // encodedIn: Zm
47 // textExp: Is the name of the second source scalable vector register, encoded in the "Zm" field.
48 // symbol: <Zm>
49 // }
50 // element{
51 // encodedIn: size
52 // textExp: size <T>
53 // 00 B
54 // 01 H
55 // 10 S
56 // 11 D
57 // symbol: <T>
58 // }
59 // }
60 // operand{
61 // name: <Zdn>.<T>
62 // typ: AC_ARNG
63 // elems:
64 // element{
65 // encodedIn: Zdn
66 // textExp: Is the name of the first source and destination scalable vector register, encoded in the "Zdn" field.
67 // symbol: <Zdn>
68 // }
69 // element{
70 // encodedIn: size
71 // textExp: size <T>
72 // 00 B
73 // 01 H
74 // 10 S
75 // 11 D
76 // symbol: <T>
77 // }
78 // }
79 // operand{
80 // name: <Pg>/M
81 // typ: AC_PREGM
82 // elems:
83 // element{
84 // encodedIn: Pg
85 // textExp: Is the name of the governing scalable predicate register P0-P7, encoded in the "Pg" field.
86 // symbol: <Pg>
87 // }
88 // }
89 // operand{
90 // name: <Zdn>.<T>
91 // typ: AC_ARNG
92 // elems:
93 // element{
94 // encodedIn: Zdn
95 // textExp: Is the name of the first source and destination scalable vector register, encoded in the "Zdn" field.
96 // symbol: <Zdn>
97 // }
98 // element{
99 // encodedIn: size
100 // textExp: size <T>
101 // 00 B
102 // 01 H
103 // 10 S
104 // 11 D
105 // symbol: <T>
106 // }
107 // }
108 // parsed: true
109 // --- Parsed Data ---
110
111 // InstructionParsed is the parsed Instruction, with additional fields for parsing status.
112 type InstructionParsed struct {
113 Instruction
114 ParseError string
115 // The file that this instruction is from, used for error reporting.
116 file string
117 }
118
119 // bitRange represents a range of bits from lo (inclusive) to hi (exclusive)
120 type bitRange struct {
121 lo, hi int
122 }
123
124 // EncodingParsed is the parsed Encoding.
125 type EncodingParsed struct {
126 Encoding
127 Binary uint32 // more specific instruction encoding than regdiagram.fixedBin
128 GoOp string // opcode in Go
129 Operands []Operand // The operands of the instruction
130 Asm string // asm template
131 Alias bool // whether it is an alias
132 Parsed bool // whether this encoding has been parsed
133 mask uint32
134 arm64Op string // arm64 opcode
135 class class // instruction class
136 invalid bool // indicate if this is a valid encoding that need to print
137 prefix string // prefix to GoOp
138 }
139
140 // RegDiagramParsed is the parsed RegDiagram.
141 type RegDiagramParsed struct {
142 RegDiagram
143 Parsed bool // whether this regdiagram has been parsed
144 fixedBin uint32 // instruction encoding binary
145 mask uint32 // instruction decoding mask, it specifies the fixed bit positions of the instruction encoding
146 varBin map[string]bitRange // named bit ranges, key is the name
147 }
148
149 // Operand is the parsed operand of the instruction.
150 type Operand struct {
151 Name string // asm template
152 Typ string // The operand type
153 Elems []Element
154 constraints []string
155 }
156
157 // Element represents a parsed element of an operand.
158 type Element struct {
159 TextExpWithRanges string // text explanation with named bit ranges mapping attached.
160 encodedIn string // the name of the binary box this element is encoded in.
161 textExp string // text explanation extracted
162 symbol string // asm template
163 // Fields below are useful for deduplication at instruction matching.
164 // When they are default value, they should have no effect on the instruction matching.
165 fixedArng string // if non empty, this element has a fixed arrangement
166 fixedLSL string // if non empty, this element has a fixed LSL
167 fixedSXTW bool // if true, this element has a fixed SXTW
168 fixedUXTW bool // if true, this element has a fixed UXTW
169 fixedModAmt string // if non empty, <mod> comes with a fixed <amount>
170 fixedScalarWidth int // if non zero, this element has a fixed scalar width
171 hasMod bool // if true, this element is a <mod>
172 isP bool // if true, this element is a scalable predicate register
173 isZ bool // if true, this element is a scalable vector register
174 }
175
176 type class int
177
178 const (
179 C_NONE class = iota
180 C_SVE
181 C_SVE2
182 )