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

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

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