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