| 1 |
(* |
| 2 |
* This signature describes the internal RTL representation. |
| 3 |
* The internal representation differs from the user representation it that |
| 4 |
* it is lambda-lifted, i.e., instead of having references like REG(32,123), |
| 5 |
* it has references like PARAM i, which refers to the ith parameter. |
| 6 |
* |
| 7 |
* This representation is chosen so that multiple instructions can |
| 8 |
* share the same rtl template. Also, so that the templates can be |
| 9 |
* created once before compilation begins. |
| 10 |
*) |
| 11 |
signature MLTREE_RTL = |
| 12 |
sig |
| 13 |
structure T : MLTREE |
| 14 |
structure Util : MLTREE_UTILS |
| 15 |
structure Rewrite : MLTREE_REWRITE |
| 16 |
structure Fold : MLTREE_FOLD |
| 17 |
sharing Util.T = Rewrite.T = Fold.T = T |
| 18 |
|
| 19 |
type ty = T.ty |
| 20 |
type var = T.var |
| 21 |
type rtl = T.stm |
| 22 |
type exp = T.rexp |
| 23 |
type cond = T.ccexp |
| 24 |
type div_rounding_mode = T.div_rounding_mode |
| 25 |
|
| 26 |
datatype pos = IN of int | OUT of int | IO of int * int (* def/use *) |
| 27 |
|
| 28 |
(*----------------------------------------------------------------------- |
| 29 |
* Basic Operations |
| 30 |
*-----------------------------------------------------------------------*) |
| 31 |
val showRTL : {def:int->string, |
| 32 |
use:int->string, |
| 33 |
regionDef:T.Region.region->string, |
| 34 |
regionUse:T.Region.region->string} -> T.printer |
| 35 |
val rtlToString : rtl -> string |
| 36 |
val expToString : exp -> string |
| 37 |
val hashRTL : rtl -> word |
| 38 |
val eqRTL : rtl * rtl -> bool |
| 39 |
|
| 40 |
(*----------------------------------------------------------------------- |
| 41 |
* Construction |
| 42 |
*-----------------------------------------------------------------------*) |
| 43 |
val newOp : {name:string, attribs:T.Basis.attribs} -> T.Basis.misc_op |
| 44 |
val new : rtl -> rtl |
| 45 |
val pin : rtl -> rtl |
| 46 |
val COPY : rtl |
| 47 |
val JMP : rtl |
| 48 |
|
| 49 |
(*----------------------------------------------------------------------- |
| 50 |
* Type queries |
| 51 |
*-----------------------------------------------------------------------*) |
| 52 |
val isConditionalBranch : rtl -> bool |
| 53 |
val isJump : rtl -> bool |
| 54 |
val isLooker : rtl -> bool |
| 55 |
|
| 56 |
(*----------------------------------------------------------------------- |
| 57 |
* Def/use queries. |
| 58 |
*-----------------------------------------------------------------------*) |
| 59 |
val defUse : rtl -> exp list * exp list |
| 60 |
|
| 61 |
(*----------------------------------------------------------------------- |
| 62 |
* Assign positions to all arguments |
| 63 |
*-----------------------------------------------------------------------*) |
| 64 |
val argPos : rtl -> (exp * int) list * (exp * int) list |
| 65 |
exception NotAnArgument |
| 66 |
val argOf : rtl -> string -> (exp * pos) |
| 67 |
|
| 68 |
(*----------------------------------------------------------------------- |
| 69 |
* Number of arguments that an rtl maps into |
| 70 |
*-----------------------------------------------------------------------*) |
| 71 |
datatype arity = ZERO | ONE | MANY |
| 72 |
val arity : exp -> arity (* number of values *) |
| 73 |
val nonConstArity : exp -> arity (* number of non-constant values *) |
| 74 |
|
| 75 |
(*----------------------------------------------------------------------- |
| 76 |
* Extract naming constraints, if any |
| 77 |
*-----------------------------------------------------------------------*) |
| 78 |
val namingConstraints : exp list * exp list -> |
| 79 |
{ fixedDefs : (exp * int) list, (* these define fixed locations *) |
| 80 |
fixedUses : (exp * int) list, (* these define fixed locations *) |
| 81 |
twoAddress : exp list (* these are both src and dst *) |
| 82 |
} |
| 83 |
|
| 84 |
(*----------------------------------------------------------------------- |
| 85 |
* Code motion queries |
| 86 |
*-----------------------------------------------------------------------*) |
| 87 |
val can'tMoveUp : rtl -> bool |
| 88 |
val can'tMoveDown : rtl -> bool |
| 89 |
val pinned : rtl -> bool |
| 90 |
val hasSideEffect : rtl -> bool |
| 91 |
val can'tBeRemoved : rtl -> bool |
| 92 |
|
| 93 |
end |