1
2
3
4
5
6
7
8 package main
9
10 import "strings"
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29 var regNamesARM = []string{
30 "R0",
31 "R1",
32 "R2",
33 "R3",
34 "R4",
35 "R5",
36 "R6",
37 "R7",
38 "R8",
39 "R9",
40 "g",
41 "R11",
42 "R12",
43 "SP",
44 "R14",
45 "R15",
46
47 "F0",
48 "F1",
49 "F2",
50 "F3",
51 "F4",
52 "F5",
53 "F6",
54 "F7",
55 "F8",
56 "F9",
57 "F10",
58 "F11",
59 "F12",
60 "F13",
61 "F14",
62 "F15",
63
64
65
66
67 "SB",
68 }
69
70 func init() {
71
72 if len(regNamesARM) > 64 {
73 panic("too many registers")
74 }
75 num := map[string]int{}
76 for i, name := range regNamesARM {
77 num[name] = i
78 }
79 buildReg := func(s string) regMask {
80 m := regMask(0)
81 for _, r := range strings.Split(s, " ") {
82 if n, ok := num[r]; ok {
83 m |= regMask(1) << uint(n)
84 continue
85 }
86 panic("register " + r + " not found")
87 }
88 return m
89 }
90
91
92 var (
93 gp = buildReg("R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R12 R14")
94 gpg = gp | buildReg("g")
95 gpsp = gp | buildReg("SP")
96 gpspg = gpg | buildReg("SP")
97 gpspsbg = gpspg | buildReg("SB")
98 fp = buildReg("F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15")
99 callerSave = gp | fp | buildReg("g")
100 r0 = buildReg("R0")
101 r1 = buildReg("R1")
102 r2 = buildReg("R2")
103 r3 = buildReg("R3")
104 r4 = buildReg("R4")
105 )
106
107 var (
108 gp01 = regInfo{inputs: nil, outputs: []regMask{gp}}
109 gp11 = regInfo{inputs: []regMask{gpg}, outputs: []regMask{gp}}
110 gp11carry = regInfo{inputs: []regMask{gpg}, outputs: []regMask{gp, 0}}
111 gp11sp = regInfo{inputs: []regMask{gpspg}, outputs: []regMask{gp}}
112 gp1flags = regInfo{inputs: []regMask{gpg}}
113 gp1flags1 = regInfo{inputs: []regMask{gp}, outputs: []regMask{gp}}
114 gp21 = regInfo{inputs: []regMask{gpg, gpg}, outputs: []regMask{gp}}
115 gp21carry = regInfo{inputs: []regMask{gpg, gpg}, outputs: []regMask{gp, 0}}
116 gp2flags = regInfo{inputs: []regMask{gpg, gpg}}
117 gp2flags1 = regInfo{inputs: []regMask{gp, gp}, outputs: []regMask{gp}}
118 gp22 = regInfo{inputs: []regMask{gpg, gpg}, outputs: []regMask{gp, gp}}
119 gp31 = regInfo{inputs: []regMask{gp, gp, gp}, outputs: []regMask{gp}}
120 gp31carry = regInfo{inputs: []regMask{gp, gp, gp}, outputs: []regMask{gp, 0}}
121 gp3flags = regInfo{inputs: []regMask{gp, gp, gp}}
122 gp3flags1 = regInfo{inputs: []regMask{gp, gp, gp}, outputs: []regMask{gp}}
123 gpload = regInfo{inputs: []regMask{gpspsbg}, outputs: []regMask{gp}}
124 gpstore = regInfo{inputs: []regMask{gpspsbg, gpg}}
125 gp2load = regInfo{inputs: []regMask{gpspsbg, gpg}, outputs: []regMask{gp}}
126 gp2store = regInfo{inputs: []regMask{gpspsbg, gpg, gpg}}
127 fp01 = regInfo{inputs: nil, outputs: []regMask{fp}}
128 fp11 = regInfo{inputs: []regMask{fp}, outputs: []regMask{fp}}
129 fp1flags = regInfo{inputs: []regMask{fp}}
130 fpgp = regInfo{inputs: []regMask{fp}, outputs: []regMask{gp}, clobbers: buildReg("F15")}
131 gpfp = regInfo{inputs: []regMask{gp}, outputs: []regMask{fp}, clobbers: buildReg("F15")}
132 fp21 = regInfo{inputs: []regMask{fp, fp}, outputs: []regMask{fp}}
133 fp31 = regInfo{inputs: []regMask{fp, fp, fp}, outputs: []regMask{fp}}
134 fp2flags = regInfo{inputs: []regMask{fp, fp}}
135 fpload = regInfo{inputs: []regMask{gpspsbg}, outputs: []regMask{fp}}
136 fpstore = regInfo{inputs: []regMask{gpspsbg, fp}}
137 readflags = regInfo{inputs: nil, outputs: []regMask{gp}}
138 )
139 ops := []opData{
140
141 {name: "ADD", argLength: 2, reg: gp21, asm: "ADD", commutative: true},
142 {name: "ADDconst", argLength: 1, reg: gp11sp, asm: "ADD", aux: "Int32"},
143 {name: "SUB", argLength: 2, reg: gp21, asm: "SUB"},
144 {name: "SUBconst", argLength: 1, reg: gp11, asm: "SUB", aux: "Int32"},
145 {name: "RSB", argLength: 2, reg: gp21, asm: "RSB"},
146 {name: "RSBconst", argLength: 1, reg: gp11, asm: "RSB", aux: "Int32"},
147 {name: "MUL", argLength: 2, reg: gp21, asm: "MUL", commutative: true},
148 {name: "HMUL", argLength: 2, reg: gp21, asm: "MULL", commutative: true},
149 {name: "HMULU", argLength: 2, reg: gp21, asm: "MULLU", commutative: true},
150
151
152
153
154 {
155 name: "CALLudiv",
156 argLength: 2,
157 reg: regInfo{
158 inputs: []regMask{buildReg("R1"), buildReg("R0")},
159 outputs: []regMask{buildReg("R0"), buildReg("R1")},
160 clobbers: buildReg("R2 R3 R12 R14"),
161 },
162 clobberFlags: true,
163 typ: "(UInt32,UInt32)",
164 call: false,
165 },
166
167 {name: "ADDS", argLength: 2, reg: gp21carry, asm: "ADD", commutative: true},
168 {name: "ADDSconst", argLength: 1, reg: gp11carry, asm: "ADD", aux: "Int32"},
169 {name: "ADC", argLength: 3, reg: gp2flags1, asm: "ADC", commutative: true},
170 {name: "ADCconst", argLength: 2, reg: gp1flags1, asm: "ADC", aux: "Int32"},
171 {name: "SUBS", argLength: 2, reg: gp21carry, asm: "SUB"},
172 {name: "SUBSconst", argLength: 1, reg: gp11carry, asm: "SUB", aux: "Int32"},
173 {name: "RSBSconst", argLength: 1, reg: gp11carry, asm: "RSB", aux: "Int32"},
174 {name: "SBC", argLength: 3, reg: gp2flags1, asm: "SBC"},
175 {name: "SBCconst", argLength: 2, reg: gp1flags1, asm: "SBC", aux: "Int32"},
176 {name: "RSCconst", argLength: 2, reg: gp1flags1, asm: "RSC", aux: "Int32"},
177
178 {name: "MULLU", argLength: 2, reg: gp22, asm: "MULLU", commutative: true},
179 {name: "MULA", argLength: 3, reg: gp31, asm: "MULA"},
180 {name: "MULS", argLength: 3, reg: gp31, asm: "MULS"},
181
182 {name: "ADDF", argLength: 2, reg: fp21, asm: "ADDF", commutative: true},
183 {name: "ADDD", argLength: 2, reg: fp21, asm: "ADDD", commutative: true},
184 {name: "SUBF", argLength: 2, reg: fp21, asm: "SUBF"},
185 {name: "SUBD", argLength: 2, reg: fp21, asm: "SUBD"},
186 {name: "MULF", argLength: 2, reg: fp21, asm: "MULF", commutative: true},
187 {name: "MULD", argLength: 2, reg: fp21, asm: "MULD", commutative: true},
188 {name: "NMULF", argLength: 2, reg: fp21, asm: "NMULF", commutative: true},
189 {name: "NMULD", argLength: 2, reg: fp21, asm: "NMULD", commutative: true},
190 {name: "DIVF", argLength: 2, reg: fp21, asm: "DIVF"},
191 {name: "DIVD", argLength: 2, reg: fp21, asm: "DIVD"},
192
193 {name: "MULAF", argLength: 3, reg: fp31, asm: "MULAF", resultInArg0: true},
194 {name: "MULAD", argLength: 3, reg: fp31, asm: "MULAD", resultInArg0: true},
195 {name: "MULSF", argLength: 3, reg: fp31, asm: "MULSF", resultInArg0: true},
196 {name: "MULSD", argLength: 3, reg: fp31, asm: "MULSD", resultInArg0: true},
197
198
199
200 {name: "FMULAD", argLength: 3, reg: fp31, asm: "FMULAD", resultInArg0: true},
201
202 {name: "AND", argLength: 2, reg: gp21, asm: "AND", commutative: true},
203 {name: "ANDconst", argLength: 1, reg: gp11, asm: "AND", aux: "Int32"},
204 {name: "OR", argLength: 2, reg: gp21, asm: "ORR", commutative: true},
205 {name: "ORconst", argLength: 1, reg: gp11, asm: "ORR", aux: "Int32"},
206 {name: "XOR", argLength: 2, reg: gp21, asm: "EOR", commutative: true},
207 {name: "XORconst", argLength: 1, reg: gp11, asm: "EOR", aux: "Int32"},
208 {name: "BIC", argLength: 2, reg: gp21, asm: "BIC"},
209 {name: "BICconst", argLength: 1, reg: gp11, asm: "BIC", aux: "Int32"},
210
211
212 {name: "BFX", argLength: 1, reg: gp11, asm: "BFX", aux: "Int32"},
213 {name: "BFXU", argLength: 1, reg: gp11, asm: "BFXU", aux: "Int32"},
214
215
216 {name: "MVN", argLength: 1, reg: gp11, asm: "MVN"},
217
218 {name: "NEGF", argLength: 1, reg: fp11, asm: "NEGF"},
219 {name: "NEGD", argLength: 1, reg: fp11, asm: "NEGD"},
220 {name: "SQRTD", argLength: 1, reg: fp11, asm: "SQRTD"},
221 {name: "SQRTF", argLength: 1, reg: fp11, asm: "SQRTF"},
222 {name: "ABSD", argLength: 1, reg: fp11, asm: "ABSD"},
223
224 {name: "CLZ", argLength: 1, reg: gp11, asm: "CLZ"},
225 {name: "REV", argLength: 1, reg: gp11, asm: "REV"},
226 {name: "REV16", argLength: 1, reg: gp11, asm: "REV16"},
227 {name: "RBIT", argLength: 1, reg: gp11, asm: "RBIT"},
228
229
230 {name: "SLL", argLength: 2, reg: gp21, asm: "SLL"},
231 {name: "SLLconst", argLength: 1, reg: gp11, asm: "SLL", aux: "Int32"},
232 {name: "SRL", argLength: 2, reg: gp21, asm: "SRL"},
233 {name: "SRLconst", argLength: 1, reg: gp11, asm: "SRL", aux: "Int32"},
234 {name: "SRA", argLength: 2, reg: gp21, asm: "SRA"},
235 {name: "SRAconst", argLength: 1, reg: gp11, asm: "SRA", aux: "Int32"},
236 {name: "SRR", argLength: 2, reg: gp21},
237 {name: "SRRconst", argLength: 1, reg: gp11, aux: "Int32"},
238
239
240 {name: "ADDshiftLL", argLength: 2, reg: gp21, asm: "ADD", aux: "Int32"},
241 {name: "ADDshiftRL", argLength: 2, reg: gp21, asm: "ADD", aux: "Int32"},
242 {name: "ADDshiftRA", argLength: 2, reg: gp21, asm: "ADD", aux: "Int32"},
243 {name: "SUBshiftLL", argLength: 2, reg: gp21, asm: "SUB", aux: "Int32"},
244 {name: "SUBshiftRL", argLength: 2, reg: gp21, asm: "SUB", aux: "Int32"},
245 {name: "SUBshiftRA", argLength: 2, reg: gp21, asm: "SUB", aux: "Int32"},
246 {name: "RSBshiftLL", argLength: 2, reg: gp21, asm: "RSB", aux: "Int32"},
247 {name: "RSBshiftRL", argLength: 2, reg: gp21, asm: "RSB", aux: "Int32"},
248 {name: "RSBshiftRA", argLength: 2, reg: gp21, asm: "RSB", aux: "Int32"},
249 {name: "ANDshiftLL", argLength: 2, reg: gp21, asm: "AND", aux: "Int32"},
250 {name: "ANDshiftRL", argLength: 2, reg: gp21, asm: "AND", aux: "Int32"},
251 {name: "ANDshiftRA", argLength: 2, reg: gp21, asm: "AND", aux: "Int32"},
252 {name: "ORshiftLL", argLength: 2, reg: gp21, asm: "ORR", aux: "Int32"},
253 {name: "ORshiftRL", argLength: 2, reg: gp21, asm: "ORR", aux: "Int32"},
254 {name: "ORshiftRA", argLength: 2, reg: gp21, asm: "ORR", aux: "Int32"},
255 {name: "XORshiftLL", argLength: 2, reg: gp21, asm: "EOR", aux: "Int32"},
256 {name: "XORshiftRL", argLength: 2, reg: gp21, asm: "EOR", aux: "Int32"},
257 {name: "XORshiftRA", argLength: 2, reg: gp21, asm: "EOR", aux: "Int32"},
258 {name: "XORshiftRR", argLength: 2, reg: gp21, asm: "EOR", aux: "Int32"},
259 {name: "BICshiftLL", argLength: 2, reg: gp21, asm: "BIC", aux: "Int32"},
260 {name: "BICshiftRL", argLength: 2, reg: gp21, asm: "BIC", aux: "Int32"},
261 {name: "BICshiftRA", argLength: 2, reg: gp21, asm: "BIC", aux: "Int32"},
262 {name: "MVNshiftLL", argLength: 1, reg: gp11, asm: "MVN", aux: "Int32"},
263 {name: "MVNshiftRL", argLength: 1, reg: gp11, asm: "MVN", aux: "Int32"},
264 {name: "MVNshiftRA", argLength: 1, reg: gp11, asm: "MVN", aux: "Int32"},
265
266 {name: "ADCshiftLL", argLength: 3, reg: gp2flags1, asm: "ADC", aux: "Int32"},
267 {name: "ADCshiftRL", argLength: 3, reg: gp2flags1, asm: "ADC", aux: "Int32"},
268 {name: "ADCshiftRA", argLength: 3, reg: gp2flags1, asm: "ADC", aux: "Int32"},
269 {name: "SBCshiftLL", argLength: 3, reg: gp2flags1, asm: "SBC", aux: "Int32"},
270 {name: "SBCshiftRL", argLength: 3, reg: gp2flags1, asm: "SBC", aux: "Int32"},
271 {name: "SBCshiftRA", argLength: 3, reg: gp2flags1, asm: "SBC", aux: "Int32"},
272 {name: "RSCshiftLL", argLength: 3, reg: gp2flags1, asm: "RSC", aux: "Int32"},
273 {name: "RSCshiftRL", argLength: 3, reg: gp2flags1, asm: "RSC", aux: "Int32"},
274 {name: "RSCshiftRA", argLength: 3, reg: gp2flags1, asm: "RSC", aux: "Int32"},
275
276 {name: "ADDSshiftLL", argLength: 2, reg: gp21carry, asm: "ADD", aux: "Int32"},
277 {name: "ADDSshiftRL", argLength: 2, reg: gp21carry, asm: "ADD", aux: "Int32"},
278 {name: "ADDSshiftRA", argLength: 2, reg: gp21carry, asm: "ADD", aux: "Int32"},
279 {name: "SUBSshiftLL", argLength: 2, reg: gp21carry, asm: "SUB", aux: "Int32"},
280 {name: "SUBSshiftRL", argLength: 2, reg: gp21carry, asm: "SUB", aux: "Int32"},
281 {name: "SUBSshiftRA", argLength: 2, reg: gp21carry, asm: "SUB", aux: "Int32"},
282 {name: "RSBSshiftLL", argLength: 2, reg: gp21carry, asm: "RSB", aux: "Int32"},
283 {name: "RSBSshiftRL", argLength: 2, reg: gp21carry, asm: "RSB", aux: "Int32"},
284 {name: "RSBSshiftRA", argLength: 2, reg: gp21carry, asm: "RSB", aux: "Int32"},
285
286 {name: "ADDshiftLLreg", argLength: 3, reg: gp31, asm: "ADD"},
287 {name: "ADDshiftRLreg", argLength: 3, reg: gp31, asm: "ADD"},
288 {name: "ADDshiftRAreg", argLength: 3, reg: gp31, asm: "ADD"},
289 {name: "SUBshiftLLreg", argLength: 3, reg: gp31, asm: "SUB"},
290 {name: "SUBshiftRLreg", argLength: 3, reg: gp31, asm: "SUB"},
291 {name: "SUBshiftRAreg", argLength: 3, reg: gp31, asm: "SUB"},
292 {name: "RSBshiftLLreg", argLength: 3, reg: gp31, asm: "RSB"},
293 {name: "RSBshiftRLreg", argLength: 3, reg: gp31, asm: "RSB"},
294 {name: "RSBshiftRAreg", argLength: 3, reg: gp31, asm: "RSB"},
295 {name: "ANDshiftLLreg", argLength: 3, reg: gp31, asm: "AND"},
296 {name: "ANDshiftRLreg", argLength: 3, reg: gp31, asm: "AND"},
297 {name: "ANDshiftRAreg", argLength: 3, reg: gp31, asm: "AND"},
298 {name: "ORshiftLLreg", argLength: 3, reg: gp31, asm: "ORR"},
299 {name: "ORshiftRLreg", argLength: 3, reg: gp31, asm: "ORR"},
300 {name: "ORshiftRAreg", argLength: 3, reg: gp31, asm: "ORR"},
301 {name: "XORshiftLLreg", argLength: 3, reg: gp31, asm: "EOR"},
302 {name: "XORshiftRLreg", argLength: 3, reg: gp31, asm: "EOR"},
303 {name: "XORshiftRAreg", argLength: 3, reg: gp31, asm: "EOR"},
304 {name: "BICshiftLLreg", argLength: 3, reg: gp31, asm: "BIC"},
305 {name: "BICshiftRLreg", argLength: 3, reg: gp31, asm: "BIC"},
306 {name: "BICshiftRAreg", argLength: 3, reg: gp31, asm: "BIC"},
307 {name: "MVNshiftLLreg", argLength: 2, reg: gp21, asm: "MVN"},
308 {name: "MVNshiftRLreg", argLength: 2, reg: gp21, asm: "MVN"},
309 {name: "MVNshiftRAreg", argLength: 2, reg: gp21, asm: "MVN"},
310
311 {name: "ADCshiftLLreg", argLength: 4, reg: gp3flags1, asm: "ADC"},
312 {name: "ADCshiftRLreg", argLength: 4, reg: gp3flags1, asm: "ADC"},
313 {name: "ADCshiftRAreg", argLength: 4, reg: gp3flags1, asm: "ADC"},
314 {name: "SBCshiftLLreg", argLength: 4, reg: gp3flags1, asm: "SBC"},
315 {name: "SBCshiftRLreg", argLength: 4, reg: gp3flags1, asm: "SBC"},
316 {name: "SBCshiftRAreg", argLength: 4, reg: gp3flags1, asm: "SBC"},
317 {name: "RSCshiftLLreg", argLength: 4, reg: gp3flags1, asm: "RSC"},
318 {name: "RSCshiftRLreg", argLength: 4, reg: gp3flags1, asm: "RSC"},
319 {name: "RSCshiftRAreg", argLength: 4, reg: gp3flags1, asm: "RSC"},
320
321 {name: "ADDSshiftLLreg", argLength: 3, reg: gp31carry, asm: "ADD"},
322 {name: "ADDSshiftRLreg", argLength: 3, reg: gp31carry, asm: "ADD"},
323 {name: "ADDSshiftRAreg", argLength: 3, reg: gp31carry, asm: "ADD"},
324 {name: "SUBSshiftLLreg", argLength: 3, reg: gp31carry, asm: "SUB"},
325 {name: "SUBSshiftRLreg", argLength: 3, reg: gp31carry, asm: "SUB"},
326 {name: "SUBSshiftRAreg", argLength: 3, reg: gp31carry, asm: "SUB"},
327 {name: "RSBSshiftLLreg", argLength: 3, reg: gp31carry, asm: "RSB"},
328 {name: "RSBSshiftRLreg", argLength: 3, reg: gp31carry, asm: "RSB"},
329 {name: "RSBSshiftRAreg", argLength: 3, reg: gp31carry, asm: "RSB"},
330
331
332 {name: "CMP", argLength: 2, reg: gp2flags, asm: "CMP", typ: "Flags"},
333 {name: "CMPconst", argLength: 1, reg: gp1flags, asm: "CMP", aux: "Int32", typ: "Flags"},
334 {name: "CMN", argLength: 2, reg: gp2flags, asm: "CMN", typ: "Flags", commutative: true},
335 {name: "CMNconst", argLength: 1, reg: gp1flags, asm: "CMN", aux: "Int32", typ: "Flags"},
336 {name: "TST", argLength: 2, reg: gp2flags, asm: "TST", typ: "Flags", commutative: true},
337 {name: "TSTconst", argLength: 1, reg: gp1flags, asm: "TST", aux: "Int32", typ: "Flags"},
338 {name: "TEQ", argLength: 2, reg: gp2flags, asm: "TEQ", typ: "Flags", commutative: true},
339 {name: "TEQconst", argLength: 1, reg: gp1flags, asm: "TEQ", aux: "Int32", typ: "Flags"},
340 {name: "CMPF", argLength: 2, reg: fp2flags, asm: "CMPF", typ: "Flags"},
341 {name: "CMPD", argLength: 2, reg: fp2flags, asm: "CMPD", typ: "Flags"},
342
343 {name: "CMPshiftLL", argLength: 2, reg: gp2flags, asm: "CMP", aux: "Int32", typ: "Flags"},
344 {name: "CMPshiftRL", argLength: 2, reg: gp2flags, asm: "CMP", aux: "Int32", typ: "Flags"},
345 {name: "CMPshiftRA", argLength: 2, reg: gp2flags, asm: "CMP", aux: "Int32", typ: "Flags"},
346 {name: "CMNshiftLL", argLength: 2, reg: gp2flags, asm: "CMN", aux: "Int32", typ: "Flags"},
347 {name: "CMNshiftRL", argLength: 2, reg: gp2flags, asm: "CMN", aux: "Int32", typ: "Flags"},
348 {name: "CMNshiftRA", argLength: 2, reg: gp2flags, asm: "CMN", aux: "Int32", typ: "Flags"},
349 {name: "TSTshiftLL", argLength: 2, reg: gp2flags, asm: "TST", aux: "Int32", typ: "Flags"},
350 {name: "TSTshiftRL", argLength: 2, reg: gp2flags, asm: "TST", aux: "Int32", typ: "Flags"},
351 {name: "TSTshiftRA", argLength: 2, reg: gp2flags, asm: "TST", aux: "Int32", typ: "Flags"},
352 {name: "TEQshiftLL", argLength: 2, reg: gp2flags, asm: "TEQ", aux: "Int32", typ: "Flags"},
353 {name: "TEQshiftRL", argLength: 2, reg: gp2flags, asm: "TEQ", aux: "Int32", typ: "Flags"},
354 {name: "TEQshiftRA", argLength: 2, reg: gp2flags, asm: "TEQ", aux: "Int32", typ: "Flags"},
355
356 {name: "CMPshiftLLreg", argLength: 3, reg: gp3flags, asm: "CMP", typ: "Flags"},
357 {name: "CMPshiftRLreg", argLength: 3, reg: gp3flags, asm: "CMP", typ: "Flags"},
358 {name: "CMPshiftRAreg", argLength: 3, reg: gp3flags, asm: "CMP", typ: "Flags"},
359 {name: "CMNshiftLLreg", argLength: 3, reg: gp3flags, asm: "CMN", typ: "Flags"},
360 {name: "CMNshiftRLreg", argLength: 3, reg: gp3flags, asm: "CMN", typ: "Flags"},
361 {name: "CMNshiftRAreg", argLength: 3, reg: gp3flags, asm: "CMN", typ: "Flags"},
362 {name: "TSTshiftLLreg", argLength: 3, reg: gp3flags, asm: "TST", typ: "Flags"},
363 {name: "TSTshiftRLreg", argLength: 3, reg: gp3flags, asm: "TST", typ: "Flags"},
364 {name: "TSTshiftRAreg", argLength: 3, reg: gp3flags, asm: "TST", typ: "Flags"},
365 {name: "TEQshiftLLreg", argLength: 3, reg: gp3flags, asm: "TEQ", typ: "Flags"},
366 {name: "TEQshiftRLreg", argLength: 3, reg: gp3flags, asm: "TEQ", typ: "Flags"},
367 {name: "TEQshiftRAreg", argLength: 3, reg: gp3flags, asm: "TEQ", typ: "Flags"},
368
369 {name: "CMPF0", argLength: 1, reg: fp1flags, asm: "CMPF", typ: "Flags"},
370 {name: "CMPD0", argLength: 1, reg: fp1flags, asm: "CMPD", typ: "Flags"},
371
372
373 {name: "MOVWconst", argLength: 0, reg: gp01, aux: "Int32", asm: "MOVW", typ: "UInt32", rematerializeable: true},
374 {name: "MOVFconst", argLength: 0, reg: fp01, aux: "Float64", asm: "MOVF", typ: "Float32", rematerializeable: true},
375 {name: "MOVDconst", argLength: 0, reg: fp01, aux: "Float64", asm: "MOVD", typ: "Float64", rematerializeable: true},
376
377 {name: "MOVWaddr", argLength: 1, reg: regInfo{inputs: []regMask{buildReg("SP") | buildReg("SB")}, outputs: []regMask{gp}}, aux: "SymOff", asm: "MOVW", rematerializeable: true, symEffect: "Addr"},
378
379 {name: "MOVBload", argLength: 2, reg: gpload, aux: "SymOff", asm: "MOVB", typ: "Int8", faultOnNilArg0: true, symEffect: "Read"},
380 {name: "MOVBUload", argLength: 2, reg: gpload, aux: "SymOff", asm: "MOVBU", typ: "UInt8", faultOnNilArg0: true, symEffect: "Read"},
381 {name: "MOVHload", argLength: 2, reg: gpload, aux: "SymOff", asm: "MOVH", typ: "Int16", faultOnNilArg0: true, symEffect: "Read"},
382 {name: "MOVHUload", argLength: 2, reg: gpload, aux: "SymOff", asm: "MOVHU", typ: "UInt16", faultOnNilArg0: true, symEffect: "Read"},
383 {name: "MOVWload", argLength: 2, reg: gpload, aux: "SymOff", asm: "MOVW", typ: "UInt32", faultOnNilArg0: true, symEffect: "Read"},
384 {name: "MOVFload", argLength: 2, reg: fpload, aux: "SymOff", asm: "MOVF", typ: "Float32", faultOnNilArg0: true, symEffect: "Read"},
385 {name: "MOVDload", argLength: 2, reg: fpload, aux: "SymOff", asm: "MOVD", typ: "Float64", faultOnNilArg0: true, symEffect: "Read"},
386
387 {name: "MOVBstore", argLength: 3, reg: gpstore, aux: "SymOff", asm: "MOVB", typ: "Mem", faultOnNilArg0: true, symEffect: "Write"},
388 {name: "MOVHstore", argLength: 3, reg: gpstore, aux: "SymOff", asm: "MOVH", typ: "Mem", faultOnNilArg0: true, symEffect: "Write"},
389 {name: "MOVWstore", argLength: 3, reg: gpstore, aux: "SymOff", asm: "MOVW", typ: "Mem", faultOnNilArg0: true, symEffect: "Write"},
390 {name: "MOVFstore", argLength: 3, reg: fpstore, aux: "SymOff", asm: "MOVF", typ: "Mem", faultOnNilArg0: true, symEffect: "Write"},
391 {name: "MOVDstore", argLength: 3, reg: fpstore, aux: "SymOff", asm: "MOVD", typ: "Mem", faultOnNilArg0: true, symEffect: "Write"},
392
393 {name: "MOVWloadidx", argLength: 3, reg: gp2load, asm: "MOVW", typ: "UInt32"},
394 {name: "MOVWloadshiftLL", argLength: 3, reg: gp2load, asm: "MOVW", aux: "Int32", typ: "UInt32"},
395 {name: "MOVWloadshiftRL", argLength: 3, reg: gp2load, asm: "MOVW", aux: "Int32", typ: "UInt32"},
396 {name: "MOVWloadshiftRA", argLength: 3, reg: gp2load, asm: "MOVW", aux: "Int32", typ: "UInt32"},
397 {name: "MOVBUloadidx", argLength: 3, reg: gp2load, asm: "MOVBU", typ: "UInt8"},
398 {name: "MOVBloadidx", argLength: 3, reg: gp2load, asm: "MOVB", typ: "Int8"},
399 {name: "MOVHUloadidx", argLength: 3, reg: gp2load, asm: "MOVHU", typ: "UInt16"},
400 {name: "MOVHloadidx", argLength: 3, reg: gp2load, asm: "MOVH", typ: "Int16"},
401
402 {name: "MOVWstoreidx", argLength: 4, reg: gp2store, asm: "MOVW", typ: "Mem"},
403 {name: "MOVWstoreshiftLL", argLength: 4, reg: gp2store, asm: "MOVW", aux: "Int32", typ: "Mem"},
404 {name: "MOVWstoreshiftRL", argLength: 4, reg: gp2store, asm: "MOVW", aux: "Int32", typ: "Mem"},
405 {name: "MOVWstoreshiftRA", argLength: 4, reg: gp2store, asm: "MOVW", aux: "Int32", typ: "Mem"},
406 {name: "MOVBstoreidx", argLength: 4, reg: gp2store, asm: "MOVB", typ: "Mem"},
407 {name: "MOVHstoreidx", argLength: 4, reg: gp2store, asm: "MOVH", typ: "Mem"},
408
409 {name: "MOVBreg", argLength: 1, reg: gp11, asm: "MOVBS"},
410 {name: "MOVBUreg", argLength: 1, reg: gp11, asm: "MOVBU"},
411 {name: "MOVHreg", argLength: 1, reg: gp11, asm: "MOVHS"},
412 {name: "MOVHUreg", argLength: 1, reg: gp11, asm: "MOVHU"},
413 {name: "MOVWreg", argLength: 1, reg: gp11, asm: "MOVW"},
414
415 {name: "MOVWnop", argLength: 1, reg: regInfo{inputs: []regMask{gp}, outputs: []regMask{gp}}, resultInArg0: true},
416
417 {name: "MOVWF", argLength: 1, reg: gpfp, asm: "MOVWF"},
418 {name: "MOVWD", argLength: 1, reg: gpfp, asm: "MOVWD"},
419 {name: "MOVWUF", argLength: 1, reg: gpfp, asm: "MOVWF"},
420 {name: "MOVWUD", argLength: 1, reg: gpfp, asm: "MOVWD"},
421 {name: "MOVFW", argLength: 1, reg: fpgp, asm: "MOVFW"},
422 {name: "MOVDW", argLength: 1, reg: fpgp, asm: "MOVDW"},
423 {name: "MOVFWU", argLength: 1, reg: fpgp, asm: "MOVFW"},
424 {name: "MOVDWU", argLength: 1, reg: fpgp, asm: "MOVDW"},
425 {name: "MOVFD", argLength: 1, reg: fp11, asm: "MOVFD"},
426 {name: "MOVDF", argLength: 1, reg: fp11, asm: "MOVDF"},
427
428
429 {name: "CMOVWHSconst", argLength: 2, reg: gp1flags1, asm: "MOVW", aux: "Int32", resultInArg0: true},
430 {name: "CMOVWLSconst", argLength: 2, reg: gp1flags1, asm: "MOVW", aux: "Int32", resultInArg0: true},
431 {name: "SRAcond", argLength: 3, reg: gp2flags1, asm: "SRA"},
432
433
434 {name: "CALLstatic", argLength: 1, reg: regInfo{clobbers: callerSave}, aux: "CallOff", clobberFlags: true, call: true},
435 {name: "CALLtail", argLength: 1, reg: regInfo{clobbers: callerSave}, aux: "CallOff", clobberFlags: true, call: true, tailCall: true},
436 {name: "CALLclosure", argLength: 3, reg: regInfo{inputs: []regMask{gpsp, buildReg("R7"), 0}, clobbers: callerSave}, aux: "CallOff", clobberFlags: true, call: true},
437 {name: "CALLinter", argLength: 2, reg: regInfo{inputs: []regMask{gp}, clobbers: callerSave}, aux: "CallOff", clobberFlags: true, call: true},
438
439
440 {name: "LoweredNilCheck", argLength: 2, reg: regInfo{inputs: []regMask{gpg}}, nilCheck: true, faultOnNilArg0: true},
441
442 {name: "Equal", argLength: 1, reg: readflags},
443 {name: "NotEqual", argLength: 1, reg: readflags},
444 {name: "LessThan", argLength: 1, reg: readflags},
445 {name: "LessEqual", argLength: 1, reg: readflags},
446 {name: "GreaterThan", argLength: 1, reg: readflags},
447 {name: "GreaterEqual", argLength: 1, reg: readflags},
448 {name: "LessThanU", argLength: 1, reg: readflags},
449 {name: "LessEqualU", argLength: 1, reg: readflags},
450 {name: "GreaterThanU", argLength: 1, reg: readflags},
451 {name: "GreaterEqualU", argLength: 1, reg: readflags},
452
453
454
455
456
457
458
459 {
460 name: "DUFFZERO",
461 aux: "Int64",
462 argLength: 3,
463 reg: regInfo{
464 inputs: []regMask{buildReg("R1"), buildReg("R0")},
465 clobbers: buildReg("R1 R12 R14"),
466 },
467 faultOnNilArg0: true,
468 },
469
470
471
472
473
474
475
476 {
477 name: "DUFFCOPY",
478 aux: "Int64",
479 argLength: 3,
480 reg: regInfo{
481 inputs: []regMask{buildReg("R2"), buildReg("R1")},
482 clobbers: buildReg("R0 R1 R2 R12 R14"),
483 },
484 faultOnNilArg0: true,
485 faultOnNilArg1: true,
486 },
487
488
489
490
491
492
493
494
495
496
497 {
498 name: "LoweredZero",
499 aux: "Int64",
500 argLength: 4,
501 reg: regInfo{
502 inputs: []regMask{buildReg("R1"), gp, gp},
503 clobbers: buildReg("R1"),
504 },
505 clobberFlags: true,
506 faultOnNilArg0: true,
507 },
508
509
510
511
512
513
514
515
516
517
518
519 {
520 name: "LoweredMove",
521 aux: "Int64",
522 argLength: 4,
523 reg: regInfo{
524 inputs: []regMask{buildReg("R2"), buildReg("R1"), gp},
525 clobbers: buildReg("R1 R2"),
526 },
527 clobberFlags: true,
528 faultOnNilArg0: true,
529 faultOnNilArg1: true,
530 },
531
532
533
534
535 {name: "LoweredGetClosurePtr", reg: regInfo{outputs: []regMask{buildReg("R7")}}, zeroWidth: true},
536
537
538 {name: "LoweredGetCallerSP", reg: gp01, rematerializeable: true},
539
540
541
542
543
544 {name: "LoweredGetCallerPC", reg: gp01, rematerializeable: true},
545
546
547
548
549 {name: "LoweredPanicBoundsA", argLength: 3, aux: "Int64", reg: regInfo{inputs: []regMask{r2, r3}}, typ: "Mem", call: true},
550 {name: "LoweredPanicBoundsB", argLength: 3, aux: "Int64", reg: regInfo{inputs: []regMask{r1, r2}}, typ: "Mem", call: true},
551 {name: "LoweredPanicBoundsC", argLength: 3, aux: "Int64", reg: regInfo{inputs: []regMask{r0, r1}}, typ: "Mem", call: true},
552
553 {name: "LoweredPanicExtendA", argLength: 4, aux: "Int64", reg: regInfo{inputs: []regMask{r4, r2, r3}}, typ: "Mem", call: true},
554 {name: "LoweredPanicExtendB", argLength: 4, aux: "Int64", reg: regInfo{inputs: []regMask{r4, r1, r2}}, typ: "Mem", call: true},
555 {name: "LoweredPanicExtendC", argLength: 4, aux: "Int64", reg: regInfo{inputs: []regMask{r4, r0, r1}}, typ: "Mem", call: true},
556
557
558
559
560
561
562 {name: "FlagConstant", aux: "FlagConstant"},
563
564
565
566 {name: "InvertFlags", argLength: 1},
567
568
569
570
571 {name: "LoweredWB", argLength: 3, reg: regInfo{inputs: []regMask{buildReg("R2"), buildReg("R3")}, clobbers: (callerSave &^ gpg) | buildReg("R12 R14")}, clobberFlags: true, aux: "Sym", symEffect: "None"},
572 }
573
574 blocks := []blockData{
575 {name: "EQ", controls: 1},
576 {name: "NE", controls: 1},
577 {name: "LT", controls: 1},
578 {name: "LE", controls: 1},
579 {name: "GT", controls: 1},
580 {name: "GE", controls: 1},
581 {name: "ULT", controls: 1},
582 {name: "ULE", controls: 1},
583 {name: "UGT", controls: 1},
584 {name: "UGE", controls: 1},
585 {name: "LTnoov", controls: 1},
586 {name: "LEnoov", controls: 1},
587 {name: "GTnoov", controls: 1},
588 {name: "GEnoov", controls: 1},
589 }
590
591 archs = append(archs, arch{
592 name: "ARM",
593 pkg: "cmd/internal/obj/arm",
594 genfile: "../../arm/ssa.go",
595 ops: ops,
596 blocks: blocks,
597 regnames: regNamesARM,
598 gpregmask: gp,
599 fpregmask: fp,
600 framepointerreg: -1,
601 linkreg: int8(num["R14"]),
602 })
603 }
604
View as plain text