File: sparcInstr.sml

package info (click to toggle)
mlton 20210117%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 58,464 kB
  • sloc: ansic: 27,682; sh: 4,455; asm: 3,569; lisp: 2,879; makefile: 2,347; perl: 1,169; python: 191; pascal: 68; javascript: 7
file content (551 lines) | stat: -rw-r--r-- 14,469 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
(*
 * WARNING: This file was automatically generated by MDLGen (v3.1)
 * from the machine description file "sparc/sparc.mdl".
 * DO NOT EDIT this file directly
 *)


signature SPARCINSTR =
sig
   structure C : SPARCCELLS
   structure CB : CELLS_BASIS (* = CellsBasis *)
                  where type CellSet.cellset = CellsBasis.CellSet.cellset
                    and type 'a ColorTable.hash_table = 'a CellsBasis.ColorTable.hash_table
                    and type 'a HashTable.hash_table = 'a CellsBasis.HashTable.hash_table
                    and type SortedCells.sorted_cells = CellsBasis.SortedCells.sorted_cells
                    and type cell = CellsBasis.cell
                    and type cellColor = CellsBasis.cellColor
                    and type cellkind = CellsBasis.cellkind
                    and type cellkindDesc = CellsBasis.cellkindDesc
                    and type cellkindInfo = CellsBasis.cellkindInfo
   structure T : MLTREE
   structure Constant: CONSTANT
   structure Region : REGION
      sharing Constant = T.Constant
      sharing Region = T.Region
   datatype load =
     LDSB
   | LDSH
   | LDUB
   | LDUH
   | LD
   | LDX
   | LDD
   datatype store =
     STB
   | STH
   | ST
   | STX
   | STD
   datatype fload =
     LDF
   | LDDF
   | LDQF
   | LDFSR
   | LDXFSR
   datatype fstore =
     STF
   | STDF
   | STFSR
   datatype arith =
     AND
   | ANDCC
   | ANDN
   | ANDNCC
   | OR
   | ORCC
   | ORN
   | ORNCC
   | XOR
   | XORCC
   | XNOR
   | XNORCC
   | ADD
   | ADDCC
   | TADD
   | TADDCC
   | TADDTV
   | TADDTVCC
   | SUB
   | SUBCC
   | TSUB
   | TSUBCC
   | TSUBTV
   | TSUBTVCC
   | UMUL
   | UMULCC
   | SMUL
   | SMULCC
   | UDIV
   | UDIVCC
   | SDIV
   | SDIVCC
   | MULX
   | SDIVX
   | UDIVX
   datatype shift =
     SLL
   | SRL
   | SRA
   | SLLX
   | SRLX
   | SRAX
   datatype farith1 =
     FiTOs
   | FiTOd
   | FiTOq
   | FsTOi
   | FdTOi
   | FqTOi
   | FsTOd
   | FsTOq
   | FdTOs
   | FdTOq
   | FqTOs
   | FqTOd
   | FMOVs
   | FNEGs
   | FABSs
   | FMOVd
   | FNEGd
   | FABSd
   | FMOVq
   | FNEGq
   | FABSq
   | FSQRTs
   | FSQRTd
   | FSQRTq
   datatype farith2 =
     FADDs
   | FADDd
   | FADDq
   | FSUBs
   | FSUBd
   | FSUBq
   | FMULs
   | FMULd
   | FMULq
   | FsMULd
   | FdMULq
   | FDIVs
   | FDIVd
   | FDIVq
   datatype fcmp =
     FCMPs
   | FCMPd
   | FCMPq
   | FCMPEs
   | FCMPEd
   | FCMPEq
   datatype branch =
     BN
   | BE
   | BLE
   | BL
   | BLEU
   | BCS
   | BNEG
   | BVS
   | BA
   | BNE
   | BG
   | BGE
   | BGU
   | BCC
   | BPOS
   | BVC
   datatype rcond =
     RZ
   | RLEZ
   | RLZ
   | RNZ
   | RGZ
   | RGEZ
   datatype cc =
     ICC
   | XCC
   datatype prediction =
     PT
   | PN
   datatype fbranch =
     FBN
   | FBNE
   | FBLG
   | FBUL
   | FBL
   | FBUG
   | FBG
   | FBU
   | FBA
   | FBE
   | FBUE
   | FBGE
   | FBUGE
   | FBLE
   | FBULE
   | FBO
   datatype ea =
     Direct of CellsBasis.cell
   | FDirect of CellsBasis.cell
   | Displace of {base:CellsBasis.cell, disp:T.labexp, mem:Region.region}
   datatype fsize =
     S
   | D
   | Q
   datatype operand =
     REG of CellsBasis.cell
   | IMMED of int
   | LAB of T.labexp
   | LO of T.labexp
   | HI of T.labexp
   type addressing_mode = CellsBasis.cell * operand
   datatype instr =
     LOAD of {l:load, d:CellsBasis.cell, r:CellsBasis.cell, i:operand, mem:Region.region}
   | STORE of {s:store, d:CellsBasis.cell, r:CellsBasis.cell, i:operand, mem:Region.region}
   | FLOAD of {l:fload, r:CellsBasis.cell, i:operand, d:CellsBasis.cell, mem:Region.region}
   | FSTORE of {s:fstore, d:CellsBasis.cell, r:CellsBasis.cell, i:operand, 
        mem:Region.region}
   | UNIMP of {const22:int}
   | SETHI of {i:int, d:CellsBasis.cell}
   | ARITH of {a:arith, r:CellsBasis.cell, i:operand, d:CellsBasis.cell}
   | SHIFT of {s:shift, r:CellsBasis.cell, i:operand, d:CellsBasis.cell}
   | MOVicc of {b:branch, i:operand, d:CellsBasis.cell}
   | MOVfcc of {b:fbranch, i:operand, d:CellsBasis.cell}
   | MOVR of {rcond:rcond, r:CellsBasis.cell, i:operand, d:CellsBasis.cell}
   | FMOVicc of {sz:fsize, b:branch, r:CellsBasis.cell, d:CellsBasis.cell}
   | FMOVfcc of {sz:fsize, b:fbranch, r:CellsBasis.cell, d:CellsBasis.cell}
   | Bicc of {b:branch, a:bool, label:Label.label, nop:bool}
   | FBfcc of {b:fbranch, a:bool, label:Label.label, nop:bool}
   | BR of {rcond:rcond, p:prediction, r:CellsBasis.cell, a:bool, label:Label.label, 
        nop:bool}
   | BP of {b:branch, p:prediction, cc:cc, a:bool, label:Label.label, nop:bool}
   | JMP of {r:CellsBasis.cell, i:operand, labs:Label.label list, nop:bool}
   | JMPL of {r:CellsBasis.cell, i:operand, d:CellsBasis.cell, defs:C.cellset, 
        uses:C.cellset, cutsTo:Label.label list, nop:bool, mem:Region.region}
   | CALL of {defs:C.cellset, uses:C.cellset, label:Label.label, cutsTo:Label.label list, 
        nop:bool, mem:Region.region}
   | Ticc of {t:branch, cc:cc, r:CellsBasis.cell, i:operand}
   | FPop1 of {a:farith1, r:CellsBasis.cell, d:CellsBasis.cell}
   | FPop2 of {a:farith2, r1:CellsBasis.cell, r2:CellsBasis.cell, d:CellsBasis.cell}
   | FCMP of {cmp:fcmp, r1:CellsBasis.cell, r2:CellsBasis.cell, nop:bool}
   | SAVE of {r:CellsBasis.cell, i:operand, d:CellsBasis.cell}
   | RESTORE of {r:CellsBasis.cell, i:operand, d:CellsBasis.cell}
   | RDY of {d:CellsBasis.cell}
   | WRY of {r:CellsBasis.cell, i:operand}
   | RET of {leaf:bool, nop:bool}
   | SOURCE of {}
   | SINK of {}
   | PHI of {}
   and instruction =
     LIVE of {regs: C.cellset, spilled: C.cellset}
   | KILL of {regs: C.cellset, spilled: C.cellset}
   | COPY of {k: CellsBasis.cellkind, 
              sz: int,          (* in bits *)
              dst: CellsBasis.cell list,
              src: CellsBasis.cell list,
              tmp: ea option (* NONE if |dst| = {src| = 1 *)}
   | ANNOTATION of {i:instruction, a:Annotations.annotation}
   | INSTR of instr
   val load : {l:load, d:CellsBasis.cell, r:CellsBasis.cell, i:operand, mem:Region.region} -> instruction
   val store : {s:store, d:CellsBasis.cell, r:CellsBasis.cell, i:operand, mem:Region.region} -> instruction
   val fload : {l:fload, r:CellsBasis.cell, i:operand, d:CellsBasis.cell, mem:Region.region} -> instruction
   val fstore : {s:fstore, d:CellsBasis.cell, r:CellsBasis.cell, i:operand, 
      mem:Region.region} -> instruction
   val unimp : {const22:int} -> instruction
   val sethi : {i:int, d:CellsBasis.cell} -> instruction
   val arith : {a:arith, r:CellsBasis.cell, i:operand, d:CellsBasis.cell} -> instruction
   val shift : {s:shift, r:CellsBasis.cell, i:operand, d:CellsBasis.cell} -> instruction
   val movicc : {b:branch, i:operand, d:CellsBasis.cell} -> instruction
   val movfcc : {b:fbranch, i:operand, d:CellsBasis.cell} -> instruction
   val movr : {rcond:rcond, r:CellsBasis.cell, i:operand, d:CellsBasis.cell} -> instruction
   val fmovicc : {sz:fsize, b:branch, r:CellsBasis.cell, d:CellsBasis.cell} -> instruction
   val fmovfcc : {sz:fsize, b:fbranch, r:CellsBasis.cell, d:CellsBasis.cell} -> instruction
   val bicc : {b:branch, a:bool, label:Label.label, nop:bool} -> instruction
   val fbfcc : {b:fbranch, a:bool, label:Label.label, nop:bool} -> instruction
   val br : {rcond:rcond, p:prediction, r:CellsBasis.cell, a:bool, label:Label.label, 
      nop:bool} -> instruction
   val bp : {b:branch, p:prediction, cc:cc, a:bool, label:Label.label, nop:bool} -> instruction
   val jmp : {r:CellsBasis.cell, i:operand, labs:Label.label list, nop:bool} -> instruction
   val jmpl : {r:CellsBasis.cell, i:operand, d:CellsBasis.cell, defs:C.cellset, 
      uses:C.cellset, cutsTo:Label.label list, nop:bool, mem:Region.region} -> instruction
   val call : {defs:C.cellset, uses:C.cellset, label:Label.label, cutsTo:Label.label list, 
      nop:bool, mem:Region.region} -> instruction
   val ticc : {t:branch, cc:cc, r:CellsBasis.cell, i:operand} -> instruction
   val fpop1 : {a:farith1, r:CellsBasis.cell, d:CellsBasis.cell} -> instruction
   val fpop2 : {a:farith2, r1:CellsBasis.cell, r2:CellsBasis.cell, d:CellsBasis.cell} -> instruction
   val fcmp : {cmp:fcmp, r1:CellsBasis.cell, r2:CellsBasis.cell, nop:bool} -> instruction
   val save : {r:CellsBasis.cell, i:operand, d:CellsBasis.cell} -> instruction
   val restore : {r:CellsBasis.cell, i:operand, d:CellsBasis.cell} -> instruction
   val rdy : {d:CellsBasis.cell} -> instruction
   val wry : {r:CellsBasis.cell, i:operand} -> instruction
   val ret : {leaf:bool, nop:bool} -> instruction
   val source : {} -> instruction
   val sink : {} -> instruction
   val phi : {} -> instruction
end

functor SparcInstr(T: MLTREE
                  ) : SPARCINSTR =
struct
   structure C = SparcCells
   structure CB = CellsBasis
   structure T = T
   structure Region = T.Region
   structure Constant = T.Constant
   datatype load =
     LDSB
   | LDSH
   | LDUB
   | LDUH
   | LD
   | LDX
   | LDD
   datatype store =
     STB
   | STH
   | ST
   | STX
   | STD
   datatype fload =
     LDF
   | LDDF
   | LDQF
   | LDFSR
   | LDXFSR
   datatype fstore =
     STF
   | STDF
   | STFSR
   datatype arith =
     AND
   | ANDCC
   | ANDN
   | ANDNCC
   | OR
   | ORCC
   | ORN
   | ORNCC
   | XOR
   | XORCC
   | XNOR
   | XNORCC
   | ADD
   | ADDCC
   | TADD
   | TADDCC
   | TADDTV
   | TADDTVCC
   | SUB
   | SUBCC
   | TSUB
   | TSUBCC
   | TSUBTV
   | TSUBTVCC
   | UMUL
   | UMULCC
   | SMUL
   | SMULCC
   | UDIV
   | UDIVCC
   | SDIV
   | SDIVCC
   | MULX
   | SDIVX
   | UDIVX
   datatype shift =
     SLL
   | SRL
   | SRA
   | SLLX
   | SRLX
   | SRAX
   datatype farith1 =
     FiTOs
   | FiTOd
   | FiTOq
   | FsTOi
   | FdTOi
   | FqTOi
   | FsTOd
   | FsTOq
   | FdTOs
   | FdTOq
   | FqTOs
   | FqTOd
   | FMOVs
   | FNEGs
   | FABSs
   | FMOVd
   | FNEGd
   | FABSd
   | FMOVq
   | FNEGq
   | FABSq
   | FSQRTs
   | FSQRTd
   | FSQRTq
   datatype farith2 =
     FADDs
   | FADDd
   | FADDq
   | FSUBs
   | FSUBd
   | FSUBq
   | FMULs
   | FMULd
   | FMULq
   | FsMULd
   | FdMULq
   | FDIVs
   | FDIVd
   | FDIVq
   datatype fcmp =
     FCMPs
   | FCMPd
   | FCMPq
   | FCMPEs
   | FCMPEd
   | FCMPEq
   datatype branch =
     BN
   | BE
   | BLE
   | BL
   | BLEU
   | BCS
   | BNEG
   | BVS
   | BA
   | BNE
   | BG
   | BGE
   | BGU
   | BCC
   | BPOS
   | BVC
   datatype rcond =
     RZ
   | RLEZ
   | RLZ
   | RNZ
   | RGZ
   | RGEZ
   datatype cc =
     ICC
   | XCC
   datatype prediction =
     PT
   | PN
   datatype fbranch =
     FBN
   | FBNE
   | FBLG
   | FBUL
   | FBL
   | FBUG
   | FBG
   | FBU
   | FBA
   | FBE
   | FBUE
   | FBGE
   | FBUGE
   | FBLE
   | FBULE
   | FBO
   datatype ea =
     Direct of CellsBasis.cell
   | FDirect of CellsBasis.cell
   | Displace of {base:CellsBasis.cell, disp:T.labexp, mem:Region.region}
   datatype fsize =
     S
   | D
   | Q
   datatype operand =
     REG of CellsBasis.cell
   | IMMED of int
   | LAB of T.labexp
   | LO of T.labexp
   | HI of T.labexp
   type addressing_mode = CellsBasis.cell * operand
   datatype instr =
     LOAD of {l:load, d:CellsBasis.cell, r:CellsBasis.cell, i:operand, mem:Region.region}
   | STORE of {s:store, d:CellsBasis.cell, r:CellsBasis.cell, i:operand, mem:Region.region}
   | FLOAD of {l:fload, r:CellsBasis.cell, i:operand, d:CellsBasis.cell, mem:Region.region}
   | FSTORE of {s:fstore, d:CellsBasis.cell, r:CellsBasis.cell, i:operand, 
        mem:Region.region}
   | UNIMP of {const22:int}
   | SETHI of {i:int, d:CellsBasis.cell}
   | ARITH of {a:arith, r:CellsBasis.cell, i:operand, d:CellsBasis.cell}
   | SHIFT of {s:shift, r:CellsBasis.cell, i:operand, d:CellsBasis.cell}
   | MOVicc of {b:branch, i:operand, d:CellsBasis.cell}
   | MOVfcc of {b:fbranch, i:operand, d:CellsBasis.cell}
   | MOVR of {rcond:rcond, r:CellsBasis.cell, i:operand, d:CellsBasis.cell}
   | FMOVicc of {sz:fsize, b:branch, r:CellsBasis.cell, d:CellsBasis.cell}
   | FMOVfcc of {sz:fsize, b:fbranch, r:CellsBasis.cell, d:CellsBasis.cell}
   | Bicc of {b:branch, a:bool, label:Label.label, nop:bool}
   | FBfcc of {b:fbranch, a:bool, label:Label.label, nop:bool}
   | BR of {rcond:rcond, p:prediction, r:CellsBasis.cell, a:bool, label:Label.label, 
        nop:bool}
   | BP of {b:branch, p:prediction, cc:cc, a:bool, label:Label.label, nop:bool}
   | JMP of {r:CellsBasis.cell, i:operand, labs:Label.label list, nop:bool}
   | JMPL of {r:CellsBasis.cell, i:operand, d:CellsBasis.cell, defs:C.cellset, 
        uses:C.cellset, cutsTo:Label.label list, nop:bool, mem:Region.region}
   | CALL of {defs:C.cellset, uses:C.cellset, label:Label.label, cutsTo:Label.label list, 
        nop:bool, mem:Region.region}
   | Ticc of {t:branch, cc:cc, r:CellsBasis.cell, i:operand}
   | FPop1 of {a:farith1, r:CellsBasis.cell, d:CellsBasis.cell}
   | FPop2 of {a:farith2, r1:CellsBasis.cell, r2:CellsBasis.cell, d:CellsBasis.cell}
   | FCMP of {cmp:fcmp, r1:CellsBasis.cell, r2:CellsBasis.cell, nop:bool}
   | SAVE of {r:CellsBasis.cell, i:operand, d:CellsBasis.cell}
   | RESTORE of {r:CellsBasis.cell, i:operand, d:CellsBasis.cell}
   | RDY of {d:CellsBasis.cell}
   | WRY of {r:CellsBasis.cell, i:operand}
   | RET of {leaf:bool, nop:bool}
   | SOURCE of {}
   | SINK of {}
   | PHI of {}
   and instruction =
     LIVE of {regs: C.cellset, spilled: C.cellset}
   | KILL of {regs: C.cellset, spilled: C.cellset}
   | COPY of {k: CellsBasis.cellkind, 
              sz: int,          (* in bits *)
              dst: CellsBasis.cell list,
              src: CellsBasis.cell list,
              tmp: ea option (* NONE if |dst| = {src| = 1 *)}
   | ANNOTATION of {i:instruction, a:Annotations.annotation}
   | INSTR of instr
   val load = INSTR o LOAD
   and store = INSTR o STORE
   and fload = INSTR o FLOAD
   and fstore = INSTR o FSTORE
   and unimp = INSTR o UNIMP
   and sethi = INSTR o SETHI
   and arith = INSTR o ARITH
   and shift = INSTR o SHIFT
   and movicc = INSTR o MOVicc
   and movfcc = INSTR o MOVfcc
   and movr = INSTR o MOVR
   and fmovicc = INSTR o FMOVicc
   and fmovfcc = INSTR o FMOVfcc
   and bicc = INSTR o Bicc
   and fbfcc = INSTR o FBfcc
   and br = INSTR o BR
   and bp = INSTR o BP
   and jmp = INSTR o JMP
   and jmpl = INSTR o JMPL
   and call = INSTR o CALL
   and ticc = INSTR o Ticc
   and fpop1 = INSTR o FPop1
   and fpop2 = INSTR o FPop2
   and fcmp = INSTR o FCMP
   and save = INSTR o SAVE
   and restore = INSTR o RESTORE
   and rdy = INSTR o RDY
   and wry = INSTR o WRY
   and ret = INSTR o RET
   and source = INSTR o SOURCE
   and sink = INSTR o SINK
   and phi = INSTR o PHI
end