Source file src/pkg/cmd/compile/internal/ssa/gen/MIPS64Ops.go
1
2
3
4
5
6
7 package main
8
9 import "strings"
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33 var regNamesMIPS64 = []string{
34 "R0",
35 "R1",
36 "R2",
37 "R3",
38 "R4",
39 "R5",
40 "R6",
41 "R7",
42 "R8",
43 "R9",
44 "R10",
45 "R11",
46 "R12",
47 "R13",
48 "R14",
49 "R15",
50 "R16",
51 "R17",
52 "R18",
53 "R19",
54 "R20",
55 "R21",
56 "R22",
57
58 "R24",
59 "R25",
60
61
62
63 "SP",
64 "g",
65 "R31",
66
67 "F0",
68 "F1",
69 "F2",
70 "F3",
71 "F4",
72 "F5",
73 "F6",
74 "F7",
75 "F8",
76 "F9",
77 "F10",
78 "F11",
79 "F12",
80 "F13",
81 "F14",
82 "F15",
83 "F16",
84 "F17",
85 "F18",
86 "F19",
87 "F20",
88 "F21",
89 "F22",
90 "F23",
91 "F24",
92 "F25",
93 "F26",
94 "F27",
95 "F28",
96 "F29",
97 "F30",
98 "F31",
99
100 "HI",
101 "LO",
102
103
104 "SB",
105 }
106
107 func init() {
108
109 if len(regNamesMIPS64) > 64 {
110 panic("too many registers")
111 }
112 num := map[string]int{}
113 for i, name := range regNamesMIPS64 {
114 num[name] = i
115 }
116 buildReg := func(s string) regMask {
117 m := regMask(0)
118 for _, r := range strings.Split(s, " ") {
119 if n, ok := num[r]; ok {
120 m |= regMask(1) << uint(n)
121 continue
122 }
123 panic("register " + r + " not found")
124 }
125 return m
126 }
127
128
129 var (
130 gp = buildReg("R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R20 R21 R22 R24 R25 R31")
131 gpg = gp | buildReg("g")
132 gpsp = gp | buildReg("SP")
133 gpspg = gpg | buildReg("SP")
134 gpspsbg = gpspg | buildReg("SB")
135 fp = buildReg("F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 F16 F17 F18 F19 F20 F21 F22 F23 F24 F25 F26 F27 F28 F29 F30 F31")
136 lo = buildReg("LO")
137 hi = buildReg("HI")
138 callerSave = gp | fp | lo | hi | buildReg("g")
139 r1 = buildReg("R1")
140 r2 = buildReg("R2")
141 r3 = buildReg("R3")
142 r4 = buildReg("R4")
143 )
144
145 var (
146 gp01 = regInfo{inputs: nil, outputs: []regMask{gp}}
147 gp11 = regInfo{inputs: []regMask{gpg}, outputs: []regMask{gp}}
148 gp11sp = regInfo{inputs: []regMask{gpspg}, outputs: []regMask{gp}}
149 gp21 = regInfo{inputs: []regMask{gpg, gpg}, outputs: []regMask{gp}}
150 gp2hilo = regInfo{inputs: []regMask{gpg, gpg}, outputs: []regMask{hi, lo}}
151 gpload = regInfo{inputs: []regMask{gpspsbg}, outputs: []regMask{gp}}
152 gpstore = regInfo{inputs: []regMask{gpspsbg, gpg}}
153 gpstore0 = regInfo{inputs: []regMask{gpspsbg}}
154 gpxchg = regInfo{inputs: []regMask{gpspsbg, gpg}, outputs: []regMask{gp}}
155 gpcas = regInfo{inputs: []regMask{gpspsbg, gpg, gpg}, outputs: []regMask{gp}}
156 fp01 = regInfo{inputs: nil, outputs: []regMask{fp}}
157 fp11 = regInfo{inputs: []regMask{fp}, outputs: []regMask{fp}}
158
159
160
161 fp21 = regInfo{inputs: []regMask{fp, fp}, outputs: []regMask{fp}}
162 fp2flags = regInfo{inputs: []regMask{fp, fp}}
163 fpload = regInfo{inputs: []regMask{gpspsbg}, outputs: []regMask{fp}}
164 fpstore = regInfo{inputs: []regMask{gpspsbg, fp}}
165 readflags = regInfo{inputs: nil, outputs: []regMask{gp}}
166 )
167 ops := []opData{
168
169 {name: "ADDV", argLength: 2, reg: gp21, asm: "ADDVU", commutative: true},
170 {name: "ADDVconst", argLength: 1, reg: gp11sp, asm: "ADDVU", aux: "Int64"},
171 {name: "SUBV", argLength: 2, reg: gp21, asm: "SUBVU"},
172 {name: "SUBVconst", argLength: 1, reg: gp11, asm: "SUBVU", aux: "Int64"},
173 {name: "MULV", argLength: 2, reg: gp2hilo, asm: "MULV", commutative: true, typ: "(Int64,Int64)"},
174 {name: "MULVU", argLength: 2, reg: gp2hilo, asm: "MULVU", commutative: true, typ: "(UInt64,UInt64)"},
175 {name: "DIVV", argLength: 2, reg: gp2hilo, asm: "DIVV", typ: "(Int64,Int64)"},
176 {name: "DIVVU", argLength: 2, reg: gp2hilo, asm: "DIVVU", typ: "(UInt64,UInt64)"},
177
178 {name: "ADDF", argLength: 2, reg: fp21, asm: "ADDF", commutative: true},
179 {name: "ADDD", argLength: 2, reg: fp21, asm: "ADDD", commutative: true},
180 {name: "SUBF", argLength: 2, reg: fp21, asm: "SUBF"},
181 {name: "SUBD", argLength: 2, reg: fp21, asm: "SUBD"},
182 {name: "MULF", argLength: 2, reg: fp21, asm: "MULF", commutative: true},
183 {name: "MULD", argLength: 2, reg: fp21, asm: "MULD", commutative: true},
184 {name: "DIVF", argLength: 2, reg: fp21, asm: "DIVF"},
185 {name: "DIVD", argLength: 2, reg: fp21, asm: "DIVD"},
186
187 {name: "AND", argLength: 2, reg: gp21, asm: "AND", commutative: true},
188 {name: "ANDconst", argLength: 1, reg: gp11, asm: "AND", aux: "Int64"},
189 {name: "OR", argLength: 2, reg: gp21, asm: "OR", commutative: true},
190 {name: "ORconst", argLength: 1, reg: gp11, asm: "OR", aux: "Int64"},
191 {name: "XOR", argLength: 2, reg: gp21, asm: "XOR", commutative: true, typ: "UInt64"},
192 {name: "XORconst", argLength: 1, reg: gp11, asm: "XOR", aux: "Int64", typ: "UInt64"},
193 {name: "NOR", argLength: 2, reg: gp21, asm: "NOR", commutative: true},
194 {name: "NORconst", argLength: 1, reg: gp11, asm: "NOR", aux: "Int64"},
195
196 {name: "NEGV", argLength: 1, reg: gp11},
197 {name: "NEGF", argLength: 1, reg: fp11, asm: "NEGF"},
198 {name: "NEGD", argLength: 1, reg: fp11, asm: "NEGD"},
199 {name: "SQRTD", argLength: 1, reg: fp11, asm: "SQRTD"},
200
201
202 {name: "SLLV", argLength: 2, reg: gp21, asm: "SLLV"},
203 {name: "SLLVconst", argLength: 1, reg: gp11, asm: "SLLV", aux: "Int64"},
204 {name: "SRLV", argLength: 2, reg: gp21, asm: "SRLV"},
205 {name: "SRLVconst", argLength: 1, reg: gp11, asm: "SRLV", aux: "Int64"},
206 {name: "SRAV", argLength: 2, reg: gp21, asm: "SRAV"},
207 {name: "SRAVconst", argLength: 1, reg: gp11, asm: "SRAV", aux: "Int64"},
208
209
210 {name: "SGT", argLength: 2, reg: gp21, asm: "SGT", typ: "Bool"},
211 {name: "SGTconst", argLength: 1, reg: gp11, asm: "SGT", aux: "Int64", typ: "Bool"},
212 {name: "SGTU", argLength: 2, reg: gp21, asm: "SGTU", typ: "Bool"},
213 {name: "SGTUconst", argLength: 1, reg: gp11, asm: "SGTU", aux: "Int64", typ: "Bool"},
214
215 {name: "CMPEQF", argLength: 2, reg: fp2flags, asm: "CMPEQF", typ: "Flags"},
216 {name: "CMPEQD", argLength: 2, reg: fp2flags, asm: "CMPEQD", typ: "Flags"},
217 {name: "CMPGEF", argLength: 2, reg: fp2flags, asm: "CMPGEF", typ: "Flags"},
218 {name: "CMPGED", argLength: 2, reg: fp2flags, asm: "CMPGED", typ: "Flags"},
219 {name: "CMPGTF", argLength: 2, reg: fp2flags, asm: "CMPGTF", typ: "Flags"},
220 {name: "CMPGTD", argLength: 2, reg: fp2flags, asm: "CMPGTD", typ: "Flags"},
221
222
223 {name: "MOVVconst", argLength: 0, reg: gp01, aux: "Int64", asm: "MOVV", typ: "UInt64", rematerializeable: true},
224 {name: "MOVFconst", argLength: 0, reg: fp01, aux: "Float64", asm: "MOVF", typ: "Float32", rematerializeable: true},
225 {name: "MOVDconst", argLength: 0, reg: fp01, aux: "Float64", asm: "MOVD", typ: "Float64", rematerializeable: true},
226
227 {name: "MOVVaddr", argLength: 1, reg: regInfo{inputs: []regMask{buildReg("SP") | buildReg("SB")}, outputs: []regMask{gp}}, aux: "SymOff", asm: "MOVV", rematerializeable: true, symEffect: "Addr"},
228
229 {name: "MOVBload", argLength: 2, reg: gpload, aux: "SymOff", asm: "MOVB", typ: "Int8", faultOnNilArg0: true, symEffect: "Read"},
230 {name: "MOVBUload", argLength: 2, reg: gpload, aux: "SymOff", asm: "MOVBU", typ: "UInt8", faultOnNilArg0: true, symEffect: "Read"},
231 {name: "MOVHload", argLength: 2, reg: gpload, aux: "SymOff", asm: "MOVH", typ: "Int16", faultOnNilArg0: true, symEffect: "Read"},
232 {name: "MOVHUload", argLength: 2, reg: gpload, aux: "SymOff", asm: "MOVHU", typ: "UInt16", faultOnNilArg0: true, symEffect: "Read"},
233 {name: "MOVWload", argLength: 2, reg: gpload, aux: "SymOff", asm: "MOVW", typ: "Int32", faultOnNilArg0: true, symEffect: "Read"},
234 {name: "MOVWUload", argLength: 2, reg: gpload, aux: "SymOff", asm: "MOVWU", typ: "UInt32", faultOnNilArg0: true, symEffect: "Read"},
235 {name: "MOVVload", argLength: 2, reg: gpload, aux: "SymOff", asm: "MOVV", typ: "UInt64", faultOnNilArg0: true, symEffect: "Read"},
236 {name: "MOVFload", argLength: 2, reg: fpload, aux: "SymOff", asm: "MOVF", typ: "Float32", faultOnNilArg0: true, symEffect: "Read"},
237 {name: "MOVDload", argLength: 2, reg: fpload, aux: "SymOff", asm: "MOVD", typ: "Float64", faultOnNilArg0: true, symEffect: "Read"},
238
239 {name: "MOVBstore", argLength: 3, reg: gpstore, aux: "SymOff", asm: "MOVB", typ: "Mem", faultOnNilArg0: true, symEffect: "Write"},
240 {name: "MOVHstore", argLength: 3, reg: gpstore, aux: "SymOff", asm: "MOVH", typ: "Mem", faultOnNilArg0: true, symEffect: "Write"},
241 {name: "MOVWstore", argLength: 3, reg: gpstore, aux: "SymOff", asm: "MOVW", typ: "Mem", faultOnNilArg0: true, symEffect: "Write"},
242 {name: "MOVVstore", argLength: 3, reg: gpstore, aux: "SymOff", asm: "MOVV", typ: "Mem", faultOnNilArg0: true, symEffect: "Write"},
243 {name: "MOVFstore", argLength: 3, reg: fpstore, aux: "SymOff", asm: "MOVF", typ: "Mem", faultOnNilArg0: true, symEffect: "Write"},
244 {name: "MOVDstore", argLength: 3, reg: fpstore, aux: "SymOff", asm: "MOVD", typ: "Mem", faultOnNilArg0: true, symEffect: "Write"},
245
246 {name: "MOVBstorezero", argLength: 2, reg: gpstore0, aux: "SymOff", asm: "MOVB", typ: "Mem", faultOnNilArg0: true, symEffect: "Write"},
247 {name: "MOVHstorezero", argLength: 2, reg: gpstore0, aux: "SymOff", asm: "MOVH", typ: "Mem", faultOnNilArg0: true, symEffect: "Write"},
248 {name: "MOVWstorezero", argLength: 2, reg: gpstore0, aux: "SymOff", asm: "MOVW", typ: "Mem", faultOnNilArg0: true, symEffect: "Write"},
249 {name: "MOVVstorezero", argLength: 2, reg: gpstore0, aux: "SymOff", asm: "MOVV", typ: "Mem", faultOnNilArg0: true, symEffect: "Write"},
250
251
252 {name: "MOVBreg", argLength: 1, reg: gp11, asm: "MOVB"},
253 {name: "MOVBUreg", argLength: 1, reg: gp11, asm: "MOVBU"},
254 {name: "MOVHreg", argLength: 1, reg: gp11, asm: "MOVH"},
255 {name: "MOVHUreg", argLength: 1, reg: gp11, asm: "MOVHU"},
256 {name: "MOVWreg", argLength: 1, reg: gp11, asm: "MOVW"},
257 {name: "MOVWUreg", argLength: 1, reg: gp11, asm: "MOVWU"},
258 {name: "MOVVreg", argLength: 1, reg: gp11, asm: "MOVV"},
259
260 {name: "MOVVnop", argLength: 1, reg: regInfo{inputs: []regMask{gp}, outputs: []regMask{gp}}, resultInArg0: true},
261
262 {name: "MOVWF", argLength: 1, reg: fp11, asm: "MOVWF"},
263 {name: "MOVWD", argLength: 1, reg: fp11, asm: "MOVWD"},
264 {name: "MOVVF", argLength: 1, reg: fp11, asm: "MOVVF"},
265 {name: "MOVVD", argLength: 1, reg: fp11, asm: "MOVVD"},
266 {name: "TRUNCFW", argLength: 1, reg: fp11, asm: "TRUNCFW"},
267 {name: "TRUNCDW", argLength: 1, reg: fp11, asm: "TRUNCDW"},
268 {name: "TRUNCFV", argLength: 1, reg: fp11, asm: "TRUNCFV"},
269 {name: "TRUNCDV", argLength: 1, reg: fp11, asm: "TRUNCDV"},
270 {name: "MOVFD", argLength: 1, reg: fp11, asm: "MOVFD"},
271 {name: "MOVDF", argLength: 1, reg: fp11, asm: "MOVDF"},
272
273
274 {name: "CALLstatic", argLength: 1, reg: regInfo{clobbers: callerSave}, aux: "SymOff", clobberFlags: true, call: true, symEffect: "None"},
275 {name: "CALLclosure", argLength: 3, reg: regInfo{inputs: []regMask{gpsp, buildReg("R22"), 0}, clobbers: callerSave}, aux: "Int64", clobberFlags: true, call: true},
276 {name: "CALLinter", argLength: 2, reg: regInfo{inputs: []regMask{gp}, clobbers: callerSave}, aux: "Int64", clobberFlags: true, call: true},
277
278
279
280
281
282
283
284 {
285 name: "DUFFZERO",
286 aux: "Int64",
287 argLength: 2,
288 reg: regInfo{
289 inputs: []regMask{gp},
290 clobbers: buildReg("R1 R31"),
291 },
292 faultOnNilArg0: true,
293 },
294
295
296
297
298
299
300
301
302
303
304
305 {
306 name: "LoweredZero",
307 aux: "Int64",
308 argLength: 3,
309 reg: regInfo{
310 inputs: []regMask{buildReg("R1"), gp},
311 clobbers: buildReg("R1"),
312 },
313 clobberFlags: true,
314 faultOnNilArg0: true,
315 },
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330 {
331 name: "LoweredMove",
332 aux: "Int64",
333 argLength: 4,
334 reg: regInfo{
335 inputs: []regMask{buildReg("R2"), buildReg("R1"), gp},
336 clobbers: buildReg("R1 R2"),
337 },
338 clobberFlags: true,
339 faultOnNilArg0: true,
340 faultOnNilArg1: true,
341 },
342
343
344
345
346 {name: "LoweredAtomicLoad8", argLength: 2, reg: gpload, faultOnNilArg0: true},
347 {name: "LoweredAtomicLoad32", argLength: 2, reg: gpload, faultOnNilArg0: true},
348 {name: "LoweredAtomicLoad64", argLength: 2, reg: gpload, faultOnNilArg0: true},
349
350
351
352 {name: "LoweredAtomicStore32", argLength: 3, reg: gpstore, faultOnNilArg0: true, hasSideEffects: true},
353 {name: "LoweredAtomicStore64", argLength: 3, reg: gpstore, faultOnNilArg0: true, hasSideEffects: true},
354
355 {name: "LoweredAtomicStorezero32", argLength: 2, reg: gpstore0, faultOnNilArg0: true, hasSideEffects: true},
356 {name: "LoweredAtomicStorezero64", argLength: 2, reg: gpstore0, faultOnNilArg0: true, hasSideEffects: true},
357
358
359
360
361
362
363
364
365
366 {name: "LoweredAtomicExchange32", argLength: 3, reg: gpxchg, resultNotInArgs: true, faultOnNilArg0: true, hasSideEffects: true},
367 {name: "LoweredAtomicExchange64", argLength: 3, reg: gpxchg, resultNotInArgs: true, faultOnNilArg0: true, hasSideEffects: true},
368
369
370
371
372
373
374
375
376
377
378 {name: "LoweredAtomicAdd32", argLength: 3, reg: gpxchg, resultNotInArgs: true, faultOnNilArg0: true, hasSideEffects: true},
379 {name: "LoweredAtomicAdd64", argLength: 3, reg: gpxchg, resultNotInArgs: true, faultOnNilArg0: true, hasSideEffects: true},
380
381 {name: "LoweredAtomicAddconst32", argLength: 2, reg: regInfo{inputs: []regMask{gpspsbg}, outputs: []regMask{gp}}, aux: "Int32", resultNotInArgs: true, faultOnNilArg0: true, hasSideEffects: true},
382 {name: "LoweredAtomicAddconst64", argLength: 2, reg: regInfo{inputs: []regMask{gpspsbg}, outputs: []regMask{gp}}, aux: "Int64", resultNotInArgs: true, faultOnNilArg0: true, hasSideEffects: true},
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400 {name: "LoweredAtomicCas32", argLength: 4, reg: gpcas, resultNotInArgs: true, faultOnNilArg0: true, hasSideEffects: true},
401 {name: "LoweredAtomicCas64", argLength: 4, reg: gpcas, resultNotInArgs: true, faultOnNilArg0: true, hasSideEffects: true},
402
403
404 {name: "LoweredNilCheck", argLength: 2, reg: regInfo{inputs: []regMask{gpg}}, nilCheck: true, faultOnNilArg0: true},
405
406 {name: "FPFlagTrue", argLength: 1, reg: readflags},
407 {name: "FPFlagFalse", argLength: 1, reg: readflags},
408
409
410
411
412 {name: "LoweredGetClosurePtr", reg: regInfo{outputs: []regMask{buildReg("R22")}}, zeroWidth: true},
413
414
415 {name: "LoweredGetCallerSP", reg: gp01, rematerializeable: true},
416
417
418
419
420
421 {name: "LoweredGetCallerPC", reg: gp01, rematerializeable: true},
422
423
424
425
426
427 {name: "LoweredWB", argLength: 3, reg: regInfo{inputs: []regMask{buildReg("R20"), buildReg("R21")}, clobbers: (callerSave &^ gpg) | buildReg("R31")}, clobberFlags: true, aux: "Sym", symEffect: "None"},
428
429
430
431
432 {name: "LoweredPanicBoundsA", argLength: 3, aux: "Int64", reg: regInfo{inputs: []regMask{r3, r4}}, typ: "Mem"},
433 {name: "LoweredPanicBoundsB", argLength: 3, aux: "Int64", reg: regInfo{inputs: []regMask{r2, r3}}, typ: "Mem"},
434 {name: "LoweredPanicBoundsC", argLength: 3, aux: "Int64", reg: regInfo{inputs: []regMask{r1, r2}}, typ: "Mem"},
435 }
436
437 blocks := []blockData{
438 {name: "EQ"},
439 {name: "NE"},
440 {name: "LTZ"},
441 {name: "LEZ"},
442 {name: "GTZ"},
443 {name: "GEZ"},
444 {name: "FPT"},
445 {name: "FPF"},
446 }
447
448 archs = append(archs, arch{
449 name: "MIPS64",
450 pkg: "cmd/internal/obj/mips",
451 genfile: "../../mips64/ssa.go",
452 ops: ops,
453 blocks: blocks,
454 regnames: regNamesMIPS64,
455 gpregmask: gp,
456 fpregmask: fp,
457 specialregmask: hi | lo,
458 framepointerreg: -1,
459 linkreg: int8(num["R31"]),
460 })
461 }
462
View as plain text