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

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

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