Home My Page Projects Code Snippets Project Openings SML/NJ
Summary Activity Forums Tracker Lists Tasks Docs Surveys News SCM Files

SCM Repository

[smlnj] Diff of /sml/trunk/src/MLRISC/mltree/mltree.sml
ViewVC logotype

Diff of /sml/trunk/src/MLRISC/mltree/mltree.sml

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 476, Wed Nov 10 22:59:58 1999 UTC revision 984, Wed Nov 21 19:00:08 2001 UTC
# Line 4  Line 4 
4   *   *
5   *)   *)
6    
7  functor MLTreeF(structure Const : CONSTANT  functor MLTreeF(structure Constant  : CONSTANT
8                  structure R : REGION                  structure Region    : REGION
9                  structure S : INSTRUCTION_STREAM                  structure Extension : MLTREE_EXTENSION
                 type rextension  
                 type fextension  
10                 ) : MLTREE =                 ) : MLTREE =
11  struct  struct
12    structure Constant = Const    structure Constant = Constant
13    structure PseudoOp = S.P    structure Region = Region
   structure Stream = S  
   structure Region = R  
14    structure Basis  = MLTreeBasis    structure Basis  = MLTreeBasis
15    structure Util   = MLTreeUtil    structure Extension = Extension
16      structure I = MachineInt
   type rextension = rextension  
   type fextension = rextension  
17    
18    type ty  = Basis.ty    type ty  = Basis.ty
19    type fty = Basis.fty    type fty = Basis.fty
20    type var = int (* variable *)    type var = CellsBasis.cell (* variable *)
21    type src = var (* source variable *)    type src = var (* source variable *)
22    type dst = var (* destination variable *)    type dst = var (* destination variable *)
23    type reg = var (* physical register *)    type reg = var (* physical register *)
24      type an  = Annotations.annotation
25    
26    datatype cond = datatype Basis.cond    datatype cond = datatype Basis.cond
27    datatype fcond = datatype Basis.fcond    datatype fcond = datatype Basis.fcond
   datatype ext = datatype Basis.ext  
28    datatype rounding_mode = datatype Basis.rounding_mode    datatype rounding_mode = datatype Basis.rounding_mode
29      datatype ext = datatype Basis.ext
30    
31    (* phi-functions for SSA form *)    (* Statements/effects.  These types are parameterized by the statement
32    datatype phi =     * extension type.  Unfortunately, this has to be made polymorphic to make
33        PHI  of ty * dst * src list     * it possible for recursive type definitions to work.
     | FPHI of fty * dst * src list  
     | CCPHI of dst * src list  
   
   (* aliasing declarations  
    * These are used to define physical register bindings for SSA names  
34     *)     *)
   type alias = var * reg  
   
   (* statements *)  
35    datatype stm =    datatype stm =
36          (* assignment *)
37        MV      of ty * dst * rexp        MV      of ty * dst * rexp
38      | CCMV    of dst * ccexp      | CCMV    of dst * ccexp
39      | FMV     of fty * dst * fexp      | FMV     of fty * dst * fexp
40    
41          (* parallel copies *)
42      | COPY    of ty * dst list * src list      | COPY    of ty * dst list * src list
43      | FCOPY   of fty * dst list * src list      | FCOPY   of fty * dst list * src list
     | JMP     of rexp * Label.label list  
     | CALL    of rexp * mlrisc list * mlrisc list * Region.region  
     | RET  
   
     | STORE  of ty * rexp * rexp * Region.region        (* address, data *)  
     | STORE_UNALIGNED of ty * rexp * rexp * Region.region  
     | FSTORE of fty * rexp * fexp * Region.region       (* address, data *)  
     | FSTORE_UNALIGNED of fty * rexp * fexp * Region.region  
     | BCC    of Basis.cond * ccexp * Label.label  
     | FBCC   of Basis.fcond * ccexp * Label.label  
     | ANNOTATION of stm * Annotations.annotation  
44    
45        (* The following are used internally by SSA optimizations;        (* control flow *)
46         * The frontend should not generate these.      | JMP     of rexp * controlflow
47        | BCC     of ccexp * Label.label
48        | CALL    of {funct:rexp, targets:controlflow,
49                      defs:mlrisc list, uses:mlrisc list,
50                      region: Region.region, pops: Int32.int}
51        | FLOW_TO of stm * controlflow
52        | RET     of controlflow
53        | IF      of ccexp * stm * stm
54    
55          (* memory update: ea, data *)
56        | STORE  of ty * rexp * rexp * Region.region
57        | FSTORE of fty * rexp * fexp * Region.region
58    
59          (* control dependence *)
60        | REGION of stm * ctrl
61    
62        | SEQ    of stm list   (* sequencing *)
63        | DEFINE of Label.label   (* define local label *)
64    
65        | ANNOTATION of stm * an
66        | EXT of sext  (* extension *)
67    
68          (* RTL operators:
69           * The following are used internally
70           * for describing instruction semantics.
71           * The frontend must not use these.
72         *)         *)
73      | RTL of word ref * word * stm (* an RTL *)      | PHI    of {preds:int list,block:int}
74      | RTLPHI of int (* a phi-function at block id *)      | ASSIGN of ty * rexp * rexp
75      | RTLPINNED of stm (* pinned statement *)      | SOURCE
76      | RTLPAR of stm list (* parallel execution *)      | SINK
77        | RTL    of {hash:word, attribs:Basis.attribs ref, e:stm}
78    
79    and rexp =    and rexp =
80        REG    of ty * src        REG    of ty * reg
81    
82        (* sizes of constants are inferred by context *)        (* sizes of constants are inferred by context *)
83      | LI     of int      | LI     of I.machine_int
84      | LI32   of Word32.word      | LABEL  of Label.label
     | LI64   of Word64.word  
     | LABEL  of LabelExp.labexp  
85      | CONST  of Constant.const      | CONST  of Constant.const
86        | LABEXP of rexp
87    
88        | NEG    of ty * rexp
89      | ADD    of ty * rexp * rexp      | ADD    of ty * rexp * rexp
90      | SUB    of ty * rexp * rexp      | SUB    of ty * rexp * rexp
91    
92        (* signed multiplication etc. *)        (* signed multiplication etc. *)
93      | MULS   of ty * rexp * rexp      | MULS   of ty * rexp * rexp
94      | DIVS   of ty * rexp * rexp      | DIVS   of ty * rexp * rexp
95        | QUOTS  of ty * rexp * rexp
96      | REMS   of ty * rexp * rexp      | REMS   of ty * rexp * rexp
97    
98        (* unsigned multiplication etc. *)        (* unsigned multiplication etc. *)
# Line 95  Line 101 
101      | REMU   of ty * rexp * rexp      | REMU   of ty * rexp * rexp
102    
103        (* trapping versions of above. These are all signed *)        (* trapping versions of above. These are all signed *)
104        | NEGT   of ty * rexp
105      | ADDT   of ty * rexp * rexp      | ADDT   of ty * rexp * rexp
106      | SUBT   of ty * rexp * rexp      | SUBT   of ty * rexp * rexp
107      | MULT   of ty * rexp * rexp      | MULT   of ty * rexp * rexp
108      | DIVT   of ty * rexp * rexp      | DIVT   of ty * rexp * rexp
109        | QUOTT  of ty * rexp * rexp
110      | REMT   of ty * rexp * rexp      | REMT   of ty * rexp * rexp
111    
112          (* bit operations *)
113      | ANDB   of ty * rexp * rexp      | ANDB   of ty * rexp * rexp
114      | ORB    of ty * rexp * rexp      | ORB    of ty * rexp * rexp
115      | XORB   of ty * rexp * rexp      | XORB   of ty * rexp * rexp
116        | EQVB   of ty * rexp * rexp
117      | NOTB   of ty * rexp      | NOTB   of ty * rexp
118    
119      | SRA   of ty * rexp * rexp         (* value, shift *)      | SRA   of ty * rexp * rexp         (* value, shift *)
120      | SRL   of ty * rexp * rexp      | SRL   of ty * rexp * rexp
121      | SLL   of ty * rexp * rexp      | SLL   of ty * rexp * rexp
122    
123        (* type promotion *)        (* type promotion/conversion *)
124      | CVTI2I of ty * Basis.ext * ty * rexp      | SX     of ty * ty * rexp  (* toTy, fromTy *)
125      | CVTF2I of ty * Basis.rounding_mode * fty * fexp      | ZX     of ty * ty * rexp  (* toTy, fromTy *)
126        | CVTF2I of ty * rounding_mode * fty * fexp
127        (* conditional (eager) evaluation *)  
128          (*
129           * COND(ty,cc,e1,e2):
130           * Evaluate into either e1 or e2, depending on cc.
131           * Both e1 and e2 are allowed to be evaluated eagerly.
132           *)
133      | COND of ty * ccexp * rexp * rexp      | COND of ty * ccexp * rexp * rexp
134    
135        (* integer load *)        (* integer load *)
136      | LOAD of ty * rexp * Region.region      | LOAD of ty * rexp * Region.region
     | LOAD_UNALIGNED of ty * rexp * Region.region  
137    
138      | SEQ of stm * rexp        (* predication *)
139        | PRED of rexp * ctrl
140    
141        | LET of stm * rexp
142    
143        | REXT of ty * rext
144    
145        | MARK of rexp * an
146    
147      | EXT of ty * rextension * rexp list      | OP    of ty * oper * rexp list
148        | ARG   of ty * rep ref * string
149        | $     of ty * CellsBasis.cellkind * rexp
150        | PARAM of int
151        | BITSLICE of ty * (int * int) list * rexp
152        | ???
153    
154      | MARK of rexp * Annotations.annotation    and rep  = REP of string
155    
156        (* Used in RTL *)    and oper = OPER of Basis.misc_op
     | RTLPC (* the program counter; used for describing relative addressing *)  
     | RTLMISC of Basis.misc_op ref * rexp list  
157    
158    and fexp =    and fexp =
159        FREG   of fty * src        FREG   of fty * src
160      | FLOAD  of fty * rexp * Region.region      | FLOAD  of fty * rexp * Region.region
     | FLOAD_UNALIGNED  of fty * rexp * Region.region  
161    
162      | FADD   of fty * fexp * fexp      | FADD   of fty * fexp * fexp
163      | FMUL   of fty * fexp * fexp      | FMUL   of fty * fexp * fexp
# Line 143  Line 166 
166      | FABS   of fty * fexp      | FABS   of fty * fexp
167      | FNEG   of fty * fexp      | FNEG   of fty * fexp
168      | FSQRT  of fty * fexp      | FSQRT  of fty * fexp
169        | FCOND  of fty * ccexp *
170                    fexp * fexp
171        | FCOPYSIGN of fty * fexp (*sign*) * fexp (*magnitude*)
172    
173      | CVTI2F of fty * Basis.ext * ty * rexp      | CVTI2F of fty * ty * rexp  (* from signed integer *)
174      | CVTF2F of fty * Basis.rounding_mode * fty * fexp      | CVTF2F of fty * fty * fexp (* float to float conversion *)
     | FSEQ   of stm * fexp  
175    
176      | FEXT of fty * fextension * fexp list      | FPRED of fexp * ctrl
177    
178      | FMARK of fexp * Annotations.annotation      | FEXT of fty * fext
179    
180        (* used in RTL *)      | FMARK of fexp * an
     | RTLFMISC of Basis.misc_op ref * fexp list  
181    
182    and ccexp =    and ccexp =
183        CC     of src        CC     of Basis.cond * src
184        | FCC    of Basis.fcond * src
185        | TRUE
186        | FALSE
187        | NOT    of ccexp
188        | AND    of ccexp * ccexp
189        | OR     of ccexp * ccexp
190        | XOR    of ccexp * ccexp
191        | EQV    of ccexp * ccexp
192      | CMP    of ty * Basis.cond * rexp * rexp      | CMP    of ty * Basis.cond * rexp * rexp
193      | FCMP   of fty * Basis.fcond * fexp * fexp      | FCMP   of fty * Basis.fcond * fexp * fexp
194      | CCMARK of ccexp * Annotations.annotation      | CCMARK of ccexp * an
195      | RTLCCMISC of Basis.misc_op ref * ccexp list      | CCEXT  of ty * ccext
196    
197    and mlrisc = CCR of ccexp | GPR of rexp | FPR of fexp    and mlrisc =
198          CCR of ccexp
199        | GPR of rexp
200        | FPR of fexp
201    
202      withtype controlflow = Label.label list (* control flow info *)
203           and ctrl   = var                   (* control dependence info *)
204           and ctrls  = ctrl list
205           and sext   = (stm, rexp, fexp, ccexp) Extension.sx
206           and rext   = (stm, rexp, fexp, ccexp) Extension.rx
207           and fext   = (stm, rexp, fexp, ccexp) Extension.fx
208           and ccext  = (stm, rexp, fexp, ccexp) Extension.ccx
209           and labexp = rexp
210    
211    exception Unsupported of string * rexp    (*
212       * Useful type abbreviations for working for MLTree.
213    type ('i,'regmap) stream =     *)
214         ('i -> unit,'regmap,Annotations.annotations,    type rewriter =  (* rewriting functions *)
215          mlrisc list, alias, phi) Stream.stream      {stm:stm->stm, rexp:rexp->rexp, fexp:fexp->fexp, ccexp:ccexp->ccexp}
216      type 'a folder = (* aggregation functions *)
217        {stm:stm*'a->'a, rexp:rexp*'a->'a, fexp:fexp*'a->'a, ccexp:ccexp*'a->'a}
218      type hasher =    (* hashing functions *)
219        {stm:stm->word, rexp:rexp->word, fexp:fexp->word, ccexp:ccexp->word}
220      type equality =  (* comparison functions *)
221        {stm:stm * stm->bool, rexp:rexp * rexp->bool,
222         fexp:fexp * fexp->bool, ccexp:ccexp * ccexp->bool}
223      type printer =   (* pretty printing functions *)
224        {stm:stm->string, rexp:rexp->string, fexp:fexp->string, ccexp:ccexp->string,
225         dstReg : ty * var -> string, srcReg : ty * var -> string}
226    
227  end (* MLTREE *)  end (* MLTREE *)
228    

Legend:
Removed from v.476  
changed lines
  Added in v.984

root@smlnj-gforge.cs.uchicago.edu
ViewVC Help
Powered by ViewVC 1.0.0