| 1 |
(* |
| 2 |
* WARNING: This file was automatically generated by MDLGen (v3.1) |
| 3 |
* from the machine description file "sparc/sparc.mdl". |
| 4 |
* DO NOT EDIT this file directly |
| 5 |
*) |
| 6 |
|
| 7 |
|
| 8 |
signature SPARCCELLS = |
| 9 |
sig |
| 10 |
include CELLS |
| 11 |
val Y : CellsBasis.cellkind |
| 12 |
val PSR : CellsBasis.cellkind |
| 13 |
val FSR : CellsBasis.cellkind |
| 14 |
val CELLSET : CellsBasis.cellkind |
| 15 |
val showGP : CellsBasis.register_id -> string |
| 16 |
val showFP : CellsBasis.register_id -> string |
| 17 |
val showY : CellsBasis.register_id -> string |
| 18 |
val showPSR : CellsBasis.register_id -> string |
| 19 |
val showFSR : CellsBasis.register_id -> string |
| 20 |
val showCC : CellsBasis.register_id -> string |
| 21 |
val showMEM : CellsBasis.register_id -> string |
| 22 |
val showCTRL : CellsBasis.register_id -> string |
| 23 |
val showCELLSET : CellsBasis.register_id -> string |
| 24 |
val showGPWithSize : CellsBasis.register_id * CellsBasis.sz -> string |
| 25 |
val showFPWithSize : CellsBasis.register_id * CellsBasis.sz -> string |
| 26 |
val showYWithSize : CellsBasis.register_id * CellsBasis.sz -> string |
| 27 |
val showPSRWithSize : CellsBasis.register_id * CellsBasis.sz -> string |
| 28 |
val showFSRWithSize : CellsBasis.register_id * CellsBasis.sz -> string |
| 29 |
val showCCWithSize : CellsBasis.register_id * CellsBasis.sz -> string |
| 30 |
val showMEMWithSize : CellsBasis.register_id * CellsBasis.sz -> string |
| 31 |
val showCTRLWithSize : CellsBasis.register_id * CellsBasis.sz -> string |
| 32 |
val showCELLSETWithSize : CellsBasis.register_id * CellsBasis.sz -> string |
| 33 |
val frameptrR : CellsBasis.cell |
| 34 |
val linkReg : CellsBasis.cell |
| 35 |
val y : CellsBasis.cell |
| 36 |
val psr : CellsBasis.cell |
| 37 |
val fsr : CellsBasis.cell |
| 38 |
val r0 : CellsBasis.cell |
| 39 |
val addGP : CellsBasis.cell * cellset -> cellset |
| 40 |
val addFP : CellsBasis.cell * cellset -> cellset |
| 41 |
val addY : CellsBasis.cell * cellset -> cellset |
| 42 |
val addPSR : CellsBasis.cell * cellset -> cellset |
| 43 |
val addFSR : CellsBasis.cell * cellset -> cellset |
| 44 |
val addCC : CellsBasis.cell * cellset -> cellset |
| 45 |
val addMEM : CellsBasis.cell * cellset -> cellset |
| 46 |
val addCTRL : CellsBasis.cell * cellset -> cellset |
| 47 |
val addCELLSET : CellsBasis.cell * cellset -> cellset |
| 48 |
end |
| 49 |
|
| 50 |
structure SparcCells : SPARCCELLS = |
| 51 |
struct |
| 52 |
exception SparcCells |
| 53 |
fun error msg = MLRiscErrorMsg.error("SparcCells",msg) |
| 54 |
open CellsBasis |
| 55 |
fun showGPWithSize (r, ty) = (fn (r, _) => (if (r < 8) |
| 56 |
then ("%g" ^ (Int.toString r)) |
| 57 |
else (if (r = 14) |
| 58 |
then "%sp" |
| 59 |
else (if (r < 16) |
| 60 |
then ("%o" ^ (Int.toString (r - 8))) |
| 61 |
else (if (r < 24) |
| 62 |
then ("%l" ^ (Int.toString (r - 16))) |
| 63 |
else (if (r = 30) |
| 64 |
then "%fp" |
| 65 |
else (if (r < 32) |
| 66 |
then ("%i" ^ (Int.toString (r - 24))) |
| 67 |
else ("%r" ^ (Int.toString r)))))))) |
| 68 |
) (r, ty) |
| 69 |
and showFPWithSize (r, ty) = (fn (f, _) => "%f" ^ (Int.toString f) |
| 70 |
) (r, ty) |
| 71 |
and showYWithSize (r, ty) = (fn _ => "%y" |
| 72 |
) (r, ty) |
| 73 |
and showPSRWithSize (r, ty) = (fn (0, _) => "%psr" |
| 74 |
| (n, _) => "%psr" ^ (Int.toString n) |
| 75 |
) (r, ty) |
| 76 |
and showFSRWithSize (r, ty) = (fn (0, _) => "%fsr" |
| 77 |
| (n, _) => "%fsr" ^ (Int.toString n) |
| 78 |
) (r, ty) |
| 79 |
and showCCWithSize (r, ty) = (fn _ => "%cc" |
| 80 |
) (r, ty) |
| 81 |
and showMEMWithSize (r, ty) = (fn (r, _) => "m" ^ (Int.toString r) |
| 82 |
) (r, ty) |
| 83 |
and showCTRLWithSize (r, ty) = (fn (r, _) => "ctrl" ^ (Int.toString r) |
| 84 |
) (r, ty) |
| 85 |
and showCELLSETWithSize (r, ty) = (fn _ => "CELLSET" |
| 86 |
) (r, ty) |
| 87 |
fun showGP r = showGPWithSize (r, 64) |
| 88 |
fun showFP r = showFPWithSize (r, 32) |
| 89 |
fun showY r = showYWithSize (r, 64) |
| 90 |
fun showPSR r = showPSRWithSize (r, 64) |
| 91 |
fun showFSR r = showFSRWithSize (r, 64) |
| 92 |
fun showCC r = showCCWithSize (r, 64) |
| 93 |
fun showMEM r = showMEMWithSize (r, 8) |
| 94 |
fun showCTRL r = showCTRLWithSize (r, 0) |
| 95 |
fun showCELLSET r = showCELLSETWithSize (r, 0) |
| 96 |
val Y = CellsBasis.newCellKind {name="Y", nickname="y"} |
| 97 |
and PSR = CellsBasis.newCellKind {name="PSR", nickname="psr"} |
| 98 |
and FSR = CellsBasis.newCellKind {name="FSR", nickname="fsr"} |
| 99 |
and CELLSET = CellsBasis.newCellKind {name="CELLSET", nickname="cellset"} |
| 100 |
structure MyCells = Cells |
| 101 |
(exception Cells = SparcCells |
| 102 |
val firstPseudo = 256 |
| 103 |
val desc_GP = CellsBasis.DESC {low=0, high=31, kind=CellsBasis.GP, defaultValues=[(0, |
| 104 |
0)], zeroReg=SOME 0, toString=showGP, toStringWithSize=showGPWithSize, |
| 105 |
counter=ref 0, dedicated=ref 0, physicalRegs=ref CellsBasis.array0} |
| 106 |
and desc_FP = CellsBasis.DESC {low=32, high=63, kind=CellsBasis.FP, |
| 107 |
defaultValues=[], zeroReg=NONE, toString=showFP, toStringWithSize=showFPWithSize, |
| 108 |
counter=ref 0, dedicated=ref 0, physicalRegs=ref CellsBasis.array0} |
| 109 |
and desc_Y = CellsBasis.DESC {low=64, high=64, kind=Y, defaultValues=[], |
| 110 |
zeroReg=NONE, toString=showY, toStringWithSize=showYWithSize, |
| 111 |
counter=ref 0, dedicated=ref 0, physicalRegs=ref CellsBasis.array0} |
| 112 |
and desc_PSR = CellsBasis.DESC {low=65, high=65, kind=PSR, defaultValues=[], |
| 113 |
zeroReg=NONE, toString=showPSR, toStringWithSize=showPSRWithSize, |
| 114 |
counter=ref 0, dedicated=ref 0, physicalRegs=ref CellsBasis.array0} |
| 115 |
and desc_FSR = CellsBasis.DESC {low=66, high=66, kind=FSR, defaultValues=[], |
| 116 |
zeroReg=NONE, toString=showFSR, toStringWithSize=showFSRWithSize, |
| 117 |
counter=ref 0, dedicated=ref 0, physicalRegs=ref CellsBasis.array0} |
| 118 |
and desc_MEM = CellsBasis.DESC {low=67, high=66, kind=CellsBasis.MEM, |
| 119 |
defaultValues=[], zeroReg=NONE, toString=showMEM, toStringWithSize=showMEMWithSize, |
| 120 |
counter=ref 0, dedicated=ref 0, physicalRegs=ref CellsBasis.array0} |
| 121 |
and desc_CTRL = CellsBasis.DESC {low=67, high=66, kind=CellsBasis.CTRL, |
| 122 |
defaultValues=[], zeroReg=NONE, toString=showCTRL, toStringWithSize=showCTRLWithSize, |
| 123 |
counter=ref 0, dedicated=ref 0, physicalRegs=ref CellsBasis.array0} |
| 124 |
and desc_CELLSET = CellsBasis.DESC {low=67, high=66, kind=CELLSET, defaultValues=[], |
| 125 |
zeroReg=NONE, toString=showCELLSET, toStringWithSize=showCELLSETWithSize, |
| 126 |
counter=ref 0, dedicated=ref 0, physicalRegs=ref CellsBasis.array0} |
| 127 |
val cellKindDescs = [(CellsBasis.GP, desc_GP), (CellsBasis.FP, desc_FP), |
| 128 |
(Y, desc_Y), (PSR, desc_PSR), (FSR, desc_FSR), (CellsBasis.CC, |
| 129 |
desc_GP), (CellsBasis.MEM, desc_MEM), (CellsBasis.CTRL, desc_CTRL), |
| 130 |
(CELLSET, desc_CELLSET)] |
| 131 |
val cellSize = 8 |
| 132 |
) |
| 133 |
|
| 134 |
open MyCells |
| 135 |
val addGP = CellSet.add |
| 136 |
and addFP = CellSet.add |
| 137 |
and addY = CellSet.add |
| 138 |
and addPSR = CellSet.add |
| 139 |
and addFSR = CellSet.add |
| 140 |
and addCC = CellSet.add |
| 141 |
and addMEM = CellSet.add |
| 142 |
and addCTRL = CellSet.add |
| 143 |
and addCELLSET = CellSet.add |
| 144 |
val RegGP = Reg GP |
| 145 |
and RegFP = Reg FP |
| 146 |
and RegY = Reg Y |
| 147 |
and RegPSR = Reg PSR |
| 148 |
and RegFSR = Reg FSR |
| 149 |
and RegCC = Reg CC |
| 150 |
and RegMEM = Reg MEM |
| 151 |
and RegCTRL = Reg CTRL |
| 152 |
and RegCELLSET = Reg CELLSET |
| 153 |
val stackptrR = RegGP 14 |
| 154 |
val frameptrR = RegGP 30 |
| 155 |
val asmTmpR = RegGP 10 |
| 156 |
val linkReg = RegGP 15 |
| 157 |
val fasmTmp = RegFP 30 |
| 158 |
val y = RegY 0 |
| 159 |
val psr = RegPSR 0 |
| 160 |
val fsr = RegFSR 0 |
| 161 |
val r0 = RegGP 0 |
| 162 |
end |
| 163 |
|