File: sparcCells.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 (163 lines) | stat: -rw-r--r-- 7,981 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
(*
 * 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 SPARCCELLS =
sig
   include CELLS
   val Y : CellsBasis.cellkind
   val PSR : CellsBasis.cellkind
   val FSR : CellsBasis.cellkind
   val CELLSET : CellsBasis.cellkind
   val showGP : CellsBasis.register_id -> string
   val showFP : CellsBasis.register_id -> string
   val showY : CellsBasis.register_id -> string
   val showPSR : CellsBasis.register_id -> string
   val showFSR : CellsBasis.register_id -> string
   val showCC : CellsBasis.register_id -> string
   val showMEM : CellsBasis.register_id -> string
   val showCTRL : CellsBasis.register_id -> string
   val showCELLSET : CellsBasis.register_id -> string
   val showGPWithSize : CellsBasis.register_id * CellsBasis.sz -> string
   val showFPWithSize : CellsBasis.register_id * CellsBasis.sz -> string
   val showYWithSize : CellsBasis.register_id * CellsBasis.sz -> string
   val showPSRWithSize : CellsBasis.register_id * CellsBasis.sz -> string
   val showFSRWithSize : CellsBasis.register_id * CellsBasis.sz -> string
   val showCCWithSize : CellsBasis.register_id * CellsBasis.sz -> string
   val showMEMWithSize : CellsBasis.register_id * CellsBasis.sz -> string
   val showCTRLWithSize : CellsBasis.register_id * CellsBasis.sz -> string
   val showCELLSETWithSize : CellsBasis.register_id * CellsBasis.sz -> string
   val frameptrR : CellsBasis.cell
   val linkReg : CellsBasis.cell
   val y : CellsBasis.cell
   val psr : CellsBasis.cell
   val fsr : CellsBasis.cell
   val r0 : CellsBasis.cell
   val addGP : CellsBasis.cell * cellset -> cellset
   val addFP : CellsBasis.cell * cellset -> cellset
   val addY : CellsBasis.cell * cellset -> cellset
   val addPSR : CellsBasis.cell * cellset -> cellset
   val addFSR : CellsBasis.cell * cellset -> cellset
   val addCC : CellsBasis.cell * cellset -> cellset
   val addMEM : CellsBasis.cell * cellset -> cellset
   val addCTRL : CellsBasis.cell * cellset -> cellset
   val addCELLSET : CellsBasis.cell * cellset -> cellset
end

structure SparcCells : SPARCCELLS =
struct
   exception SparcCells
   fun error msg = MLRiscErrorMsg.error("SparcCells",msg)
   open CellsBasis
   fun showGPWithSize (r, ty) = (fn (r, _) => (if (r < 8)
                                       then ("%g" ^ (Int.toString r))
                                       else (if (r = 14)
                                          then "%sp"
                                          else (if (r < 16)
                                             then ("%o" ^ (Int.toString (r - 8)))
                                             else (if (r < 24)
                                                then ("%l" ^ (Int.toString (r - 16)))
                                                else (if (r = 30)
                                                   then "%fp"
                                                   else (if (r < 32)
                                                      then ("%i" ^ (Int.toString (r - 24)))
                                                      else ("%r" ^ (Int.toString r))))))))
                                ) (r, ty)
   and showFPWithSize (r, ty) = (fn (f, _) => "%f" ^ (Int.toString f)
                                ) (r, ty)
   and showYWithSize (r, ty) = (fn _ => "%y"
                               ) (r, ty)
   and showPSRWithSize (r, ty) = (fn (0, _) => "%psr"
                                   | (n, _) => "%psr" ^ (Int.toString n)
                                 ) (r, ty)
   and showFSRWithSize (r, ty) = (fn (0, _) => "%fsr"
                                   | (n, _) => "%fsr" ^ (Int.toString n)
                                 ) (r, ty)
   and showCCWithSize (r, ty) = (fn _ => "%cc"
                                ) (r, ty)
   and showMEMWithSize (r, ty) = (fn (r, _) => "m" ^ (Int.toString r)
                                 ) (r, ty)
   and showCTRLWithSize (r, ty) = (fn (r, _) => "ctrl" ^ (Int.toString r)
                                  ) (r, ty)
   and showCELLSETWithSize (r, ty) = (fn _ => "CELLSET"
                                     ) (r, ty)
   fun showGP r = showGPWithSize (r, 64)
   fun showFP r = showFPWithSize (r, 32)
   fun showY r = showYWithSize (r, 64)
   fun showPSR r = showPSRWithSize (r, 64)
   fun showFSR r = showFSRWithSize (r, 64)
   fun showCC r = showCCWithSize (r, 64)
   fun showMEM r = showMEMWithSize (r, 8)
   fun showCTRL r = showCTRLWithSize (r, 0)
   fun showCELLSET r = showCELLSETWithSize (r, 0)
   val Y = CellsBasis.newCellKind {name="Y", nickname="y"}
   and PSR = CellsBasis.newCellKind {name="PSR", nickname="psr"}
   and FSR = CellsBasis.newCellKind {name="FSR", nickname="fsr"}
   and CELLSET = CellsBasis.newCellKind {name="CELLSET", nickname="cellset"}
   structure MyCells = Cells
      (exception Cells = SparcCells
       val firstPseudo = 256
       val desc_GP = CellsBasis.DESC {low=0, high=31, kind=CellsBasis.GP, defaultValues=[(0, 
              0)], zeroReg=SOME 0, toString=showGP, toStringWithSize=showGPWithSize, 
              counter=ref 0, dedicated=ref 0, physicalRegs=ref CellsBasis.array0}
       and desc_FP = CellsBasis.DESC {low=32, high=63, kind=CellsBasis.FP, 
              defaultValues=[], zeroReg=NONE, toString=showFP, toStringWithSize=showFPWithSize, 
              counter=ref 0, dedicated=ref 0, physicalRegs=ref CellsBasis.array0}
       and desc_Y = CellsBasis.DESC {low=64, high=64, kind=Y, defaultValues=[], 
              zeroReg=NONE, toString=showY, toStringWithSize=showYWithSize, 
              counter=ref 0, dedicated=ref 0, physicalRegs=ref CellsBasis.array0}
       and desc_PSR = CellsBasis.DESC {low=65, high=65, kind=PSR, defaultValues=[], 
              zeroReg=NONE, toString=showPSR, toStringWithSize=showPSRWithSize, 
              counter=ref 0, dedicated=ref 0, physicalRegs=ref CellsBasis.array0}
       and desc_FSR = CellsBasis.DESC {low=66, high=66, kind=FSR, defaultValues=[], 
              zeroReg=NONE, toString=showFSR, toStringWithSize=showFSRWithSize, 
              counter=ref 0, dedicated=ref 0, physicalRegs=ref CellsBasis.array0}
       and desc_MEM = CellsBasis.DESC {low=67, high=66, kind=CellsBasis.MEM, 
              defaultValues=[], zeroReg=NONE, toString=showMEM, toStringWithSize=showMEMWithSize, 
              counter=ref 0, dedicated=ref 0, physicalRegs=ref CellsBasis.array0}
       and desc_CTRL = CellsBasis.DESC {low=67, high=66, kind=CellsBasis.CTRL, 
              defaultValues=[], zeroReg=NONE, toString=showCTRL, toStringWithSize=showCTRLWithSize, 
              counter=ref 0, dedicated=ref 0, physicalRegs=ref CellsBasis.array0}
       and desc_CELLSET = CellsBasis.DESC {low=67, high=66, kind=CELLSET, defaultValues=[], 
              zeroReg=NONE, toString=showCELLSET, toStringWithSize=showCELLSETWithSize, 
              counter=ref 0, dedicated=ref 0, physicalRegs=ref CellsBasis.array0}
       val cellKindDescs = [(CellsBasis.GP, desc_GP), (CellsBasis.FP, desc_FP), 
              (Y, desc_Y), (PSR, desc_PSR), (FSR, desc_FSR), (CellsBasis.CC, 
              desc_GP), (CellsBasis.MEM, desc_MEM), (CellsBasis.CTRL, desc_CTRL), 
              (CELLSET, desc_CELLSET)]
       val cellSize = 8
      )

   open MyCells
   val addGP = CellSet.add
   and addFP = CellSet.add
   and addY = CellSet.add
   and addPSR = CellSet.add
   and addFSR = CellSet.add
   and addCC = CellSet.add
   and addMEM = CellSet.add
   and addCTRL = CellSet.add
   and addCELLSET = CellSet.add
   val RegGP = Reg GP
   and RegFP = Reg FP
   and RegY = Reg Y
   and RegPSR = Reg PSR
   and RegFSR = Reg FSR
   and RegCC = Reg CC
   and RegMEM = Reg MEM
   and RegCTRL = Reg CTRL
   and RegCELLSET = Reg CELLSET
   val stackptrR = RegGP 14
   val frameptrR = RegGP 30
   val asmTmpR = RegGP 10
   val linkReg = RegGP 15
   val fasmTmp = RegFP 30
   val y = RegY 0
   val psr = RegPSR 0
   val fsr = RegFSR 0
   val r0 = RegGP 0
end