| 1 |
(* |
| 2 |
* WARNING: This file was automatically generated by MDLGen (v3.1) |
| 3 |
* from the machine description file "amd64/amd64.mdl". |
| 4 |
* DO NOT EDIT this file directly |
| 5 |
*) |
| 6 |
|
| 7 |
|
| 8 |
signature AMD64CELLS = |
| 9 |
sig |
| 10 |
include CELLS |
| 11 |
val EFLAGS : CellsBasis.cellkind |
| 12 |
val FFLAGS : CellsBasis.cellkind |
| 13 |
val CELLSET : CellsBasis.cellkind |
| 14 |
val showGP : CellsBasis.register_id -> string |
| 15 |
val showFP : CellsBasis.register_id -> string |
| 16 |
val showCC : CellsBasis.register_id -> string |
| 17 |
val showEFLAGS : CellsBasis.register_id -> string |
| 18 |
val showFFLAGS : CellsBasis.register_id -> string |
| 19 |
val showMEM : CellsBasis.register_id -> string |
| 20 |
val showCTRL : CellsBasis.register_id -> string |
| 21 |
val showCELLSET : CellsBasis.register_id -> string |
| 22 |
val showGPWithSize : CellsBasis.register_id * CellsBasis.sz -> string |
| 23 |
val showFPWithSize : CellsBasis.register_id * CellsBasis.sz -> string |
| 24 |
val showCCWithSize : CellsBasis.register_id * CellsBasis.sz -> string |
| 25 |
val showEFLAGSWithSize : CellsBasis.register_id * CellsBasis.sz -> string |
| 26 |
val showFFLAGSWithSize : CellsBasis.register_id * CellsBasis.sz -> string |
| 27 |
val showMEMWithSize : CellsBasis.register_id * CellsBasis.sz -> string |
| 28 |
val showCTRLWithSize : CellsBasis.register_id * CellsBasis.sz -> string |
| 29 |
val showCELLSETWithSize : CellsBasis.register_id * CellsBasis.sz -> string |
| 30 |
val rax : CellsBasis.cell |
| 31 |
val rcx : CellsBasis.cell |
| 32 |
val rdx : CellsBasis.cell |
| 33 |
val rbx : CellsBasis.cell |
| 34 |
val rsp : CellsBasis.cell |
| 35 |
val rbp : CellsBasis.cell |
| 36 |
val rsi : CellsBasis.cell |
| 37 |
val rdi : CellsBasis.cell |
| 38 |
val r8 : CellsBasis.cell |
| 39 |
val r9 : CellsBasis.cell |
| 40 |
val r10 : CellsBasis.cell |
| 41 |
val r11 : CellsBasis.cell |
| 42 |
val r12 : CellsBasis.cell |
| 43 |
val r13 : CellsBasis.cell |
| 44 |
val r14 : CellsBasis.cell |
| 45 |
val r15 : CellsBasis.cell |
| 46 |
val xmm0 : CellsBasis.cell |
| 47 |
val xmm1 : CellsBasis.cell |
| 48 |
val xmm2 : CellsBasis.cell |
| 49 |
val xmm3 : CellsBasis.cell |
| 50 |
val xmm4 : CellsBasis.cell |
| 51 |
val xmm5 : CellsBasis.cell |
| 52 |
val xmm6 : CellsBasis.cell |
| 53 |
val xmm7 : CellsBasis.cell |
| 54 |
val xmm8 : CellsBasis.cell |
| 55 |
val xmm9 : CellsBasis.cell |
| 56 |
val xmm10 : CellsBasis.cell |
| 57 |
val xmm11 : CellsBasis.cell |
| 58 |
val xmm12 : CellsBasis.cell |
| 59 |
val xmm13 : CellsBasis.cell |
| 60 |
val xmm14 : CellsBasis.cell |
| 61 |
val xmm15 : CellsBasis.cell |
| 62 |
val eflags : CellsBasis.cell |
| 63 |
val addGP : CellsBasis.cell * cellset -> cellset |
| 64 |
val addFP : CellsBasis.cell * cellset -> cellset |
| 65 |
val addCC : CellsBasis.cell * cellset -> cellset |
| 66 |
val addEFLAGS : CellsBasis.cell * cellset -> cellset |
| 67 |
val addFFLAGS : CellsBasis.cell * cellset -> cellset |
| 68 |
val addMEM : CellsBasis.cell * cellset -> cellset |
| 69 |
val addCTRL : CellsBasis.cell * cellset -> cellset |
| 70 |
val addCELLSET : CellsBasis.cell * cellset -> cellset |
| 71 |
end |
| 72 |
|
| 73 |
structure AMD64Cells : AMD64CELLS = |
| 74 |
struct |
| 75 |
exception AMD64Cells |
| 76 |
fun error msg = MLRiscErrorMsg.error("AMD64Cells",msg) |
| 77 |
open CellsBasis |
| 78 |
fun showGPWithSize (r, ty) = (fn (0, 8) => "%al" |
| 79 |
| (4, 8) => "%ah" |
| 80 |
| (1, 8) => "%cl" |
| 81 |
| (5, 8) => "%ch" |
| 82 |
| (2, 8) => "%dl" |
| 83 |
| (6, 8) => "%dh" |
| 84 |
| (3, 8) => "%bl" |
| 85 |
| (7, 8) => "%bh" |
| 86 |
| (r, 8) => ("%r" ^ (Int.toString r)) ^ "b" |
| 87 |
| (0, 16) => "%ax" |
| 88 |
| (4, 16) => "%sp" |
| 89 |
| (1, 16) => "%cx" |
| 90 |
| (5, 16) => "%bp" |
| 91 |
| (2, 16) => "%dx" |
| 92 |
| (6, 16) => "%si" |
| 93 |
| (3, 16) => "%bx" |
| 94 |
| (7, 16) => "%di" |
| 95 |
| (r, 16) => ("%r" ^ (Int.toString r)) ^ "w" |
| 96 |
| (0, 32) => "%eax" |
| 97 |
| (4, 32) => "%esp" |
| 98 |
| (1, 32) => "%ecx" |
| 99 |
| (5, 32) => "%ebp" |
| 100 |
| (2, 32) => "%edx" |
| 101 |
| (6, 32) => "%esi" |
| 102 |
| (3, 32) => "%ebx" |
| 103 |
| (7, 32) => "%edi" |
| 104 |
| (r, 32) => ("%r" ^ (Int.toString r)) ^ "d" |
| 105 |
| (0, 64) => "%rax" |
| 106 |
| (4, 64) => "%rsp" |
| 107 |
| (1, 64) => "%rcx" |
| 108 |
| (5, 64) => "%rbp" |
| 109 |
| (2, 64) => "%rdx" |
| 110 |
| (6, 64) => "%rsi" |
| 111 |
| (3, 64) => "%rbx" |
| 112 |
| (7, 64) => "%rdi" |
| 113 |
| (r, 64) => "%r" ^ (Int.toString r) |
| 114 |
| (r, _) => "%" ^ (Int.toString r) |
| 115 |
) (r, ty) |
| 116 |
and showFPWithSize (r, ty) = (fn (f, _) => (if (f < 16) |
| 117 |
then ("%xmm" ^ (Int.toString f)) |
| 118 |
else ("%f" ^ (Int.toString f))) |
| 119 |
) (r, ty) |
| 120 |
and showCCWithSize (r, ty) = (fn _ => "cc" |
| 121 |
) (r, ty) |
| 122 |
and showEFLAGSWithSize (r, ty) = (fn _ => "$eflags" |
| 123 |
) (r, ty) |
| 124 |
and showFFLAGSWithSize (r, ty) = (fn _ => "$fflags" |
| 125 |
) (r, ty) |
| 126 |
and showMEMWithSize (r, ty) = (fn _ => "mem" |
| 127 |
) (r, ty) |
| 128 |
and showCTRLWithSize (r, ty) = (fn _ => "ctrl" |
| 129 |
) (r, ty) |
| 130 |
and showCELLSETWithSize (r, ty) = (fn _ => "CELLSET" |
| 131 |
) (r, ty) |
| 132 |
fun showGP r = showGPWithSize (r, 64) |
| 133 |
fun showFP r = showFPWithSize (r, 64) |
| 134 |
fun showCC r = showCCWithSize (r, 32) |
| 135 |
fun showEFLAGS r = showEFLAGSWithSize (r, 32) |
| 136 |
fun showFFLAGS r = showFFLAGSWithSize (r, 32) |
| 137 |
fun showMEM r = showMEMWithSize (r, 8) |
| 138 |
fun showCTRL r = showCTRLWithSize (r, 0) |
| 139 |
fun showCELLSET r = showCELLSETWithSize (r, 0) |
| 140 |
val EFLAGS = CellsBasis.newCellKind {name="EFLAGS", nickname="eflags"} |
| 141 |
and FFLAGS = CellsBasis.newCellKind {name="FFLAGS", nickname="fflags"} |
| 142 |
and CELLSET = CellsBasis.newCellKind {name="CELLSET", nickname="cellset"} |
| 143 |
structure MyCells = Cells |
| 144 |
(exception Cells = AMD64Cells |
| 145 |
val firstPseudo = 256 |
| 146 |
val desc_GP = CellsBasis.DESC {low=0, high=15, kind=CellsBasis.GP, defaultValues=[], |
| 147 |
zeroReg=NONE, toString=showGP, toStringWithSize=showGPWithSize, |
| 148 |
counter=ref 0, dedicated=ref 0, physicalRegs=ref CellsBasis.array0} |
| 149 |
and desc_FP = CellsBasis.DESC {low=16, high=31, kind=CellsBasis.FP, |
| 150 |
defaultValues=[], zeroReg=NONE, toString=showFP, toStringWithSize=showFPWithSize, |
| 151 |
counter=ref 0, dedicated=ref 0, physicalRegs=ref CellsBasis.array0} |
| 152 |
and desc_EFLAGS = CellsBasis.DESC {low=32, high=32, kind=EFLAGS, defaultValues=[], |
| 153 |
zeroReg=NONE, toString=showEFLAGS, toStringWithSize=showEFLAGSWithSize, |
| 154 |
counter=ref 0, dedicated=ref 0, physicalRegs=ref CellsBasis.array0} |
| 155 |
and desc_FFLAGS = CellsBasis.DESC {low=33, high=33, kind=FFLAGS, defaultValues=[], |
| 156 |
zeroReg=NONE, toString=showFFLAGS, toStringWithSize=showFFLAGSWithSize, |
| 157 |
counter=ref 0, dedicated=ref 0, physicalRegs=ref CellsBasis.array0} |
| 158 |
and desc_MEM = CellsBasis.DESC {low=34, high=33, kind=CellsBasis.MEM, |
| 159 |
defaultValues=[], zeroReg=NONE, toString=showMEM, toStringWithSize=showMEMWithSize, |
| 160 |
counter=ref 0, dedicated=ref 0, physicalRegs=ref CellsBasis.array0} |
| 161 |
and desc_CTRL = CellsBasis.DESC {low=34, high=33, kind=CellsBasis.CTRL, |
| 162 |
defaultValues=[], zeroReg=NONE, toString=showCTRL, toStringWithSize=showCTRLWithSize, |
| 163 |
counter=ref 0, dedicated=ref 0, physicalRegs=ref CellsBasis.array0} |
| 164 |
and desc_CELLSET = CellsBasis.DESC {low=34, high=33, kind=CELLSET, defaultValues=[], |
| 165 |
zeroReg=NONE, toString=showCELLSET, toStringWithSize=showCELLSETWithSize, |
| 166 |
counter=ref 0, dedicated=ref 0, physicalRegs=ref CellsBasis.array0} |
| 167 |
val cellKindDescs = [(CellsBasis.GP, desc_GP), (CellsBasis.FP, desc_FP), |
| 168 |
(CellsBasis.CC, desc_GP), (EFLAGS, desc_EFLAGS), (FFLAGS, desc_FFLAGS), |
| 169 |
(CellsBasis.MEM, desc_MEM), (CellsBasis.CTRL, desc_CTRL), (CELLSET, |
| 170 |
desc_CELLSET)] |
| 171 |
val cellSize = 8 |
| 172 |
) |
| 173 |
|
| 174 |
open MyCells |
| 175 |
val addGP = CellSet.add |
| 176 |
and addFP = CellSet.add |
| 177 |
and addCC = CellSet.add |
| 178 |
and addEFLAGS = CellSet.add |
| 179 |
and addFFLAGS = CellSet.add |
| 180 |
and addMEM = CellSet.add |
| 181 |
and addCTRL = CellSet.add |
| 182 |
and addCELLSET = CellSet.add |
| 183 |
val RegGP = Reg GP |
| 184 |
and RegFP = Reg FP |
| 185 |
and RegCC = Reg CC |
| 186 |
and RegEFLAGS = Reg EFLAGS |
| 187 |
and RegFFLAGS = Reg FFLAGS |
| 188 |
and RegMEM = Reg MEM |
| 189 |
and RegCTRL = Reg CTRL |
| 190 |
and RegCELLSET = Reg CELLSET |
| 191 |
val rax = RegGP 0 |
| 192 |
val rcx = RegGP 1 |
| 193 |
val rdx = RegGP 2 |
| 194 |
val rbx = RegGP 3 |
| 195 |
val rsp = RegGP 4 |
| 196 |
val rbp = RegGP 5 |
| 197 |
val rsi = RegGP 6 |
| 198 |
val rdi = RegGP 7 |
| 199 |
val r8 = RegGP 8 |
| 200 |
val r9 = RegGP 9 |
| 201 |
val r10 = RegGP 10 |
| 202 |
val r11 = RegGP 11 |
| 203 |
val r12 = RegGP 12 |
| 204 |
val r13 = RegGP 13 |
| 205 |
val r14 = RegGP 14 |
| 206 |
val r15 = RegGP 15 |
| 207 |
val xmm0 = RegFP 0 |
| 208 |
val xmm1 = RegFP 1 |
| 209 |
val xmm2 = RegFP 2 |
| 210 |
val xmm3 = RegFP 3 |
| 211 |
val xmm4 = RegFP 4 |
| 212 |
val xmm5 = RegFP 5 |
| 213 |
val xmm6 = RegFP 6 |
| 214 |
val xmm7 = RegFP 7 |
| 215 |
val xmm8 = RegFP 8 |
| 216 |
val xmm9 = RegFP 9 |
| 217 |
val xmm10 = RegFP 10 |
| 218 |
val xmm11 = RegFP 11 |
| 219 |
val xmm12 = RegFP 12 |
| 220 |
val xmm13 = RegFP 13 |
| 221 |
val xmm14 = RegFP 14 |
| 222 |
val xmm15 = RegFP 15 |
| 223 |
val stackptrR = RegGP 4 |
| 224 |
val asmTmpR = RegGP 0 |
| 225 |
val fasmTmp = RegFP 0 |
| 226 |
val eflags = RegEFLAGS 0 |
| 227 |
end |
| 228 |
|