| 1 |
(* mltree.sig |
| 2 |
* |
| 3 |
* COPYRIGHT (c) 1994 AT&T Bell Laboratories. |
| 4 |
* |
| 5 |
*) |
| 6 |
|
| 7 |
signature MLTREE = sig |
| 8 |
structure Constant : CONSTANT |
| 9 |
structure Region : REGION |
| 10 |
(* structure Stream : INSTRUCTION_STREAM *) |
| 11 |
structure Basis : MLTREE_BASIS |
| 12 |
structure Extension : MLTREE_EXTENSION |
| 13 |
structure I : MACHINE_INT |
| 14 |
|
| 15 |
type ty = Basis.ty |
| 16 |
type fty = Basis.fty |
| 17 |
type var = CellsBasis.cell (* variable *) |
| 18 |
type src = var (* source variable *) |
| 19 |
type dst = var (* destination variable *) |
| 20 |
type reg = var (* physical register *) |
| 21 |
type an = Annotations.annotation |
| 22 |
|
| 23 |
datatype cond = datatype Basis.cond |
| 24 |
datatype fcond = datatype Basis.fcond |
| 25 |
datatype rounding_mode = datatype Basis.rounding_mode |
| 26 |
datatype div_rounding_mode = datatype Basis.div_rounding_mode |
| 27 |
datatype ext = datatype Basis.ext |
| 28 |
|
| 29 |
(* Statements/effects. These types are parameterized by the statement |
| 30 |
* extension type. Unfortunately, this has to be made polymorphic to make |
| 31 |
* it possible for recursive type definitions to work. |
| 32 |
*) |
| 33 |
type controlflow = Label.label list (* control flow info *) |
| 34 |
type ctrl = var (* control dependence info *) |
| 35 |
type ctrls = ctrl list |
| 36 |
|
| 37 |
datatype stm = |
| 38 |
(* assignment *) |
| 39 |
MV of ty * dst * rexp |
| 40 |
| CCMV of dst * ccexp |
| 41 |
| FMV of fty * dst * fexp |
| 42 |
|
| 43 |
(* parallel copies *) |
| 44 |
| COPY of ty * dst list * src list |
| 45 |
| FCOPY of fty * dst list * src list |
| 46 |
|
| 47 |
(* control flow *) |
| 48 |
| JMP of rexp * controlflow |
| 49 |
(* |
| 50 |
| SWITCH of |
| 51 |
{tblLab: Label.label, (* label associated with table *) |
| 52 |
base : rexp option, (* base pointer -- if any *) |
| 53 |
table : fn Label.label -> rexp, (* get table address *) |
| 54 |
index : rexp, (* index into table *) |
| 55 |
targets : controlflow} (* targets of switch *) |
| 56 |
*) |
| 57 |
| BCC of ccexp * Label.label |
| 58 |
| CALL of {funct:rexp, targets:controlflow, |
| 59 |
defs:mlrisc list, uses:mlrisc list, |
| 60 |
region: Region.region, |
| 61 |
pops: Int32.int} |
| 62 |
| FLOW_TO of stm * controlflow |
| 63 |
| RET of controlflow |
| 64 |
| IF of ccexp * stm * stm |
| 65 |
|
| 66 |
(* memory update: ea, data *) |
| 67 |
| STORE of ty * rexp * rexp * Region.region |
| 68 |
| FSTORE of fty * rexp * fexp * Region.region |
| 69 |
|
| 70 |
(* control dependence *) |
| 71 |
| REGION of stm * ctrl |
| 72 |
|
| 73 |
| SEQ of stm list (* sequencing *) |
| 74 |
| DEFINE of Label.label (* define local label *) |
| 75 |
|
| 76 |
| ANNOTATION of stm * an |
| 77 |
| EXT of sext (* extension *) |
| 78 |
|
| 79 |
(* synthetic instructions to indicated that the regs are live or |
| 80 |
* killed at this program point. The spilled list must always |
| 81 |
* start out as the empty list. |
| 82 |
*) |
| 83 |
| LIVE of mlrisc list |
| 84 |
| KILL of mlrisc list |
| 85 |
|
| 86 |
(* RTL operators: |
| 87 |
* The following are used internally |
| 88 |
* for describing instruction semantics. |
| 89 |
* The frontend must not use these. |
| 90 |
*) |
| 91 |
| PHI of {preds:int list,block:int} |
| 92 |
| ASSIGN of ty * rexp * rexp |
| 93 |
| SOURCE |
| 94 |
| SINK |
| 95 |
| RTL of {hash:word, attribs:Basis.attribs ref, e:stm} |
| 96 |
|
| 97 |
and rexp = |
| 98 |
REG of ty * reg |
| 99 |
|
| 100 |
(* sizes of constants are inferred by context *) |
| 101 |
| LI of I.machine_int |
| 102 |
| LABEL of Label.label |
| 103 |
| CONST of Constant.const |
| 104 |
| LABEXP of rexp |
| 105 |
|
| 106 |
| NEG of ty * rexp |
| 107 |
| ADD of ty * rexp * rexp |
| 108 |
| SUB of ty * rexp * rexp |
| 109 |
|
| 110 |
(* signed multiplication etc. *) |
| 111 |
| MULS of ty * rexp * rexp |
| 112 |
| DIVS of div_rounding_mode * ty * rexp * rexp |
| 113 |
| REMS of div_rounding_mode * ty * rexp * rexp |
| 114 |
|
| 115 |
(* unsigned multiplication etc. *) |
| 116 |
| MULU of ty * rexp * rexp |
| 117 |
| DIVU of ty * rexp * rexp |
| 118 |
| REMU of ty * rexp * rexp |
| 119 |
|
| 120 |
(* overflow-trapping versions of above. These are all signed *) |
| 121 |
| NEGT of ty * rexp |
| 122 |
| ADDT of ty * rexp * rexp |
| 123 |
| SUBT of ty * rexp * rexp |
| 124 |
| MULT of ty * rexp * rexp |
| 125 |
| DIVT of div_rounding_mode * ty * rexp * rexp |
| 126 |
(* there is no REMT because remainder never overflows *) |
| 127 |
|
| 128 |
(* bit operations *) |
| 129 |
| ANDB of ty * rexp * rexp |
| 130 |
| ORB of ty * rexp * rexp |
| 131 |
| XORB of ty * rexp * rexp |
| 132 |
| EQVB of ty * rexp * rexp |
| 133 |
| NOTB of ty * rexp |
| 134 |
|
| 135 |
| SRA of ty * rexp * rexp (* value, shift *) |
| 136 |
| SRL of ty * rexp * rexp |
| 137 |
| SLL of ty * rexp * rexp |
| 138 |
|
| 139 |
(* type promotion/conversion *) |
| 140 |
| SX of ty * ty * rexp (* toTy, fromTy *) |
| 141 |
| ZX of ty * ty * rexp (* toTy, fromTy *) |
| 142 |
| CVTF2I of ty * rounding_mode * fty * fexp |
| 143 |
|
| 144 |
(* |
| 145 |
* COND(ty,cc,e1,e2): |
| 146 |
* Evaluate into either e1 or e2, depending on cc. |
| 147 |
* Both e1 and e2 are allowed to be evaluated eagerly. |
| 148 |
*) |
| 149 |
| COND of ty * ccexp * rexp * rexp |
| 150 |
|
| 151 |
(* integer load *) |
| 152 |
| LOAD of ty * rexp * Region.region |
| 153 |
|
| 154 |
(* predication *) |
| 155 |
| PRED of rexp * ctrl |
| 156 |
|
| 157 |
| LET of stm * rexp |
| 158 |
|
| 159 |
| REXT of ty * rext |
| 160 |
|
| 161 |
| MARK of rexp * an |
| 162 |
|
| 163 |
| OP of ty * oper * rexp list |
| 164 |
| ARG of ty * rep ref * string |
| 165 |
| $ of ty * CellsBasis.cellkind * rexp |
| 166 |
| PARAM of int |
| 167 |
| BITSLICE of ty * (int * int) list * rexp |
| 168 |
| ??? |
| 169 |
|
| 170 |
and rep = REP of string |
| 171 |
|
| 172 |
and oper = OPER of Basis.misc_op |
| 173 |
|
| 174 |
and fexp = |
| 175 |
FREG of fty * src |
| 176 |
| FLOAD of fty * rexp * Region.region |
| 177 |
|
| 178 |
| FADD of fty * fexp * fexp |
| 179 |
| FMUL of fty * fexp * fexp |
| 180 |
| FSUB of fty * fexp * fexp |
| 181 |
| FDIV of fty * fexp * fexp |
| 182 |
| FABS of fty * fexp |
| 183 |
| FNEG of fty * fexp |
| 184 |
| FSQRT of fty * fexp |
| 185 |
| FCOND of fty * ccexp * |
| 186 |
fexp * fexp |
| 187 |
| FCOPYSIGN of fty * fexp (*sign*) * fexp (*magnitude*) |
| 188 |
|
| 189 |
| CVTI2F of fty * ty * rexp (* from signed integer *) |
| 190 |
| CVTF2F of fty * fty * fexp (* float to float conversion *) |
| 191 |
|
| 192 |
| FPRED of fexp * ctrl |
| 193 |
|
| 194 |
| FEXT of fty * fext |
| 195 |
|
| 196 |
| FMARK of fexp * an |
| 197 |
|
| 198 |
and ccexp = |
| 199 |
CC of Basis.cond * src |
| 200 |
| FCC of Basis.fcond * src |
| 201 |
| TRUE |
| 202 |
| FALSE |
| 203 |
| NOT of ccexp |
| 204 |
| AND of ccexp * ccexp |
| 205 |
| OR of ccexp * ccexp |
| 206 |
| XOR of ccexp * ccexp |
| 207 |
| EQV of ccexp * ccexp |
| 208 |
| CMP of ty * Basis.cond * rexp * rexp |
| 209 |
| FCMP of fty * Basis.fcond * fexp * fexp |
| 210 |
| CCMARK of ccexp * an |
| 211 |
| CCEXT of ty * ccext |
| 212 |
|
| 213 |
and mlrisc = |
| 214 |
CCR of ccexp |
| 215 |
| GPR of rexp |
| 216 |
| FPR of fexp |
| 217 |
|
| 218 |
withtype sext = (stm, rexp, fexp, ccexp) Extension.sx |
| 219 |
and rext = (stm, rexp, fexp, ccexp) Extension.rx |
| 220 |
and fext = (stm, rexp, fexp, ccexp) Extension.fx |
| 221 |
and ccext = (stm, rexp, fexp, ccexp) Extension.ccx |
| 222 |
and labexp = rexp |
| 223 |
(* |
| 224 |
* Useful type abbreviations for working for MLTree. |
| 225 |
*) |
| 226 |
type rewriter = (* rewriting functions *) |
| 227 |
{stm:stm->stm, rexp:rexp->rexp, fexp:fexp->fexp, ccexp:ccexp->ccexp} |
| 228 |
type 'a folder = (* aggregation functions *) |
| 229 |
{stm:stm*'a->'a, rexp:rexp*'a->'a, fexp:fexp*'a->'a, ccexp:ccexp*'a->'a} |
| 230 |
type hasher = (* hashing functions *) |
| 231 |
{stm:stm->word, rexp:rexp->word, fexp:fexp->word, ccexp:ccexp->word} |
| 232 |
type equality = (* comparison functions *) |
| 233 |
{stm:stm * stm->bool, rexp:rexp * rexp->bool, |
| 234 |
fexp:fexp * fexp->bool, ccexp:ccexp * ccexp->bool} |
| 235 |
type printer = (* pretty printing functions *) |
| 236 |
{stm:stm->string, rexp:rexp->string, fexp:fexp->string, ccexp:ccexp->string, |
| 237 |
dstReg : ty * var -> string, srcReg : ty * var -> string} |
| 238 |
|
| 239 |
end (* MLTREE *) |