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

sml/branches/SMLNJ/src/MLRISC/mltree/mltree.sml revision 411, Fri Sep 3 00:25:03 1999 UTC sml/trunk/src/MLRISC/mltree/mltree.sml revision 775, Fri Jan 12 01:17:51 2001 UTC
# Line 4  Line 4 
4   *   *
5   *)   *)
6    
7  functor MLTreeF(structure Const : CONSTANT  functor MLTreeF(structure Constant  : CONSTANT
8                  structure P : PSEUDO_OPS                  structure Region    : REGION
9                  structure R : REGION                  structure Stream    : INSTRUCTION_STREAM
10                  structure B : BLOCK_NAMES                  structure Extension : MLTREE_EXTENSION
                 type rextension  
                 type fextension  
11                 ) : MLTREE =                 ) : MLTREE =
12  struct  struct
13    structure Constant = Const    structure Constant = Constant
14    structure PseudoOp = P    structure PseudoOp = Stream.P
15    structure Region = R    structure Stream = Stream
16    structure BNames = B    structure Region = Region
17      structure Basis  = MLTreeBasis
18    open MLTreeBasis    structure Extension = Extension
19      structure I = MachineInt
20    type rextension = rextension  
21    type fextension = rextension    type ty  = Basis.ty
22      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    (* phi-functions for SSA form *)    datatype cond = datatype Basis.cond
30    datatype phi =    datatype fcond = datatype Basis.fcond
31        PHI  of ty * dst * src list    datatype rounding_mode = datatype Basis.rounding_mode
32      | FPHI of fty * dst * src list    datatype ext = datatype Basis.ext
33      | CCPHI of dst * src list  
34      (* Statements/effects.  These types are parameterized by the statement
35    (* aliasing declarations     * extension type.  Unfortunately, this has to be made polymorphic to make
36     * These are used to define physical register bindings for SSA names     * it possible for recursive type definitions to work.
37     *)     *)
   datatype alias = ALIAS   of ty * var * reg  
                  | FALIAS  of fty * var * reg  
                  | CCALIAS of 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      | RET     of controlflow
55      | BCC    of cond * ccexp * Label.label      | IF      of ccexp * stm * stm
56      | FBCC   of fcond * ccexp * Label.label  
57      | ANNOTATION of stm * Annotations.annotation        (* memory update: ea, data *)
58        | STORE  of ty * rexp * rexp * Region.region
59        (* The following are used internally by SSA optimizations;      | FSTORE of fty * rexp * fexp * Region.region
60         * The frontend should not generate these.  
61         *)        (* control dependence *)
62      | RTL of word ref * word * stm (* an RTL *)      | REGION of stm * ctrl
63      | RTLPHI of int (* a phi-function at block id *)  
64      | RTLPINNED of stm (* pinned statement *)      | SEQ    of stm list   (* sequencing *)
65      | RTLPAR of stm list (* parallel execution *)      | DEFINE of Label.label   (* define local label *)
66    
67        | ANNOTATION of stm * an
68        | EXT of sext  (* extension *)
69    
70          (* RTL operators:
71           * The following are used internally
72           * for describing instruction semantics.
73           * The frontend must not use these.
74           *)
75        | PHI    of {preds:int list,block:int}
76        | ASSIGN of ty * rexp * rexp
77        | SOURCE
78        | SINK
79        | RTL    of {hash:word, attribs:Basis.attribs ref, e:stm}
80    
81    and rexp =    and rexp =
82        REG    of ty * src        REG    of ty * reg
83    
84        (* sizes of constants are inferred by context *)        (* sizes of constants are inferred by context *)
85      | LI     of int      | LI     of I.machine_int
86      | LI32   of Word32.word      | LABEL  of Label.label
     | LI64   of Word64.word  
     | LABEL  of LabelExp.labexp  
87      | CONST  of Constant.const      | CONST  of Constant.const
88        | LABEXP of rexp
89    
90        | NEG    of ty * rexp
91      | ADD    of ty * rexp * rexp      | ADD    of ty * rexp * rexp
92      | SUB    of ty * rexp * rexp      | SUB    of ty * rexp * rexp
93    
94        (* signed multiplication etc. *)        (* signed multiplication etc. *)
95      | MULS   of ty * rexp * rexp      | MULS   of ty * rexp * rexp
96      | DIVS   of ty * rexp * rexp      | DIVS   of ty * rexp * rexp
97        | QUOTS  of ty * rexp * rexp
98      | REMS   of ty * rexp * rexp      | REMS   of ty * rexp * rexp
99    
100        (* unsigned multiplication etc. *)        (* unsigned multiplication etc. *)
# Line 91  Line 103 
103      | REMU   of ty * rexp * rexp      | REMU   of ty * rexp * rexp
104    
105        (* trapping versions of above. These are all signed *)        (* trapping versions of above. These are all signed *)
106        | NEGT   of ty * rexp
107      | ADDT   of ty * rexp * rexp      | ADDT   of ty * rexp * rexp
108      | SUBT   of ty * rexp * rexp      | SUBT   of ty * rexp * rexp
109      | MULT   of ty * rexp * rexp      | MULT   of ty * rexp * rexp
110      | DIVT   of ty * rexp * rexp      | DIVT   of ty * rexp * rexp
111        | QUOTT  of ty * rexp * rexp
112      | REMT   of ty * rexp * rexp      | REMT   of ty * rexp * rexp
113    
114          (* bit operations *)
115      | ANDB   of ty * rexp * rexp      | ANDB   of ty * rexp * rexp
116      | ORB    of ty * rexp * rexp      | ORB    of ty * rexp * rexp
117      | XORB   of ty * rexp * rexp      | XORB   of ty * rexp * rexp
118        | EQVB   of ty * rexp * rexp
119      | NOTB   of ty * rexp      | NOTB   of ty * rexp
120    
121      | SRA   of ty * rexp * rexp         (* value, shift *)      | SRA   of ty * rexp * rexp         (* value, shift *)
122      | SRL   of ty * rexp * rexp      | SRL   of ty * rexp * rexp
123      | SLL   of ty * rexp * rexp      | SLL   of ty * rexp * rexp
124    
125        (* type promotion *)        (* type promotion/conversion *)
126      | CVTI2I of ty * ext * rexp      | SX     of ty * ty * rexp  (* toTy, fromTy *)
127      | CVTF2I of ty * rounding_mode * fexp      | ZX     of ty * ty * rexp  (* toTy, fromTy *)
128        | CVTF2I of ty * rounding_mode * fty * fexp
129        (* conditional (eager) evaluation *)  
130          (*
131           * COND(ty,cc,e1,e2):
132           * Evaluate into either e1 or e2, depending on cc.
133           * Both e1 and e2 are allowed to be evaluated eagerly.
134           *)
135      | COND of ty * ccexp * rexp * rexp      | COND of ty * ccexp * rexp * rexp
136    
137        (* integer load *)        (* integer load *)
138      | LOAD of ty * rexp * Region.region      | LOAD of ty * rexp * Region.region
     | LOAD_UNALIGNED of ty * rexp * Region.region  
139    
140      | SEQ of stm * rexp        (* predication *)
141        | PRED of rexp * ctrl
142    
143      | EXTENSION of rextension * rexp list      | LET of stm * rexp
144    
145      | MARK of rexp * Annotations.annotation      | REXT of ty * rext
146    
147        (* Used in RTL *)      | MARK of rexp * an
148      | RTLPC (* the program counter; used for describing relative addressing *)  
149      | RTLMISC of misc_op ref * rexp list      | OP    of ty * oper * rexp list
150        | ARG   of ty * rep ref * string
151        | $     of ty * CellsBasis.cellkind * rexp
152        | PARAM of int
153        | BITSLICE of ty * (int * int) list * rexp
154        | ???
155    
156      and rep  = REP of string
157    
158      and oper = OPER of Basis.misc_op
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 139  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 * ext * rexp      | CVTI2F of fty * ty * rexp  (* from signed integer *)
176      | CVTF2F of fty * rounding_mode * fexp      | CVTF2F of fty * fty * fexp (* float to float conversion *)
     | FSEQ   of stm * fexp  
177    
178      | FEXTENSION of 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 misc_op ref * fexp list  
183    
184    and ccexp =    and ccexp =
185        CC     of src        CC     of Basis.cond * src
186      | CMP    of ty * cond * rexp * rexp      | FCC    of Basis.fcond * src
187      | FCMP   of fty * fcond * fexp * fexp      | TRUE
188      | CCMARK of ccexp * Annotations.annotation      | FALSE
189      | RTLCCMISC of misc_op ref * ccexp list      | NOT    of ccexp
190        | AND    of ccexp * ccexp
191    and mlrisc = CCR of ccexp | GPR of rexp | FPR of fexp      | OR     of ccexp * ccexp
192        | XOR    of ccexp * ccexp
193    datatype mltree =      | EQV    of ccexp * ccexp
194        BEGINCLUSTER      | CMP    of ty * Basis.cond * rexp * rexp
195      | PSEUDO_OP of PseudoOp.pseudo_op      | FCMP   of fty * Basis.fcond * fexp * fexp
196      | DEFINELABEL of Label.label      | CCMARK of ccexp * an
197      | ENTRYLABEL of Label.label      | CCEXT  of ty * ccext
198      | CODE of stm list  
199      | ALIASDECLS of alias list    and mlrisc =
200      | PHIFUNS of phi list        CCR of ccexp
201      | BLOCK_NAME of BNames.name      | GPR of rexp
202      | BLOCK_ANNOTATION of Annotations.annotation      | FPR of fexp
203      | ESCAPEBLOCK of mlrisc list  
204      | ENDCLUSTER of int Intmap.intmap * Annotations.annotations    withtype controlflow = Label.label list (* control flow info *)
205           and ctrl   = var                   (* control dependence info *)
206           and ctrls  = ctrl list
207           and sext   = (stm, rexp, fexp, ccexp) Extension.sx
208           and rext   = (stm, rexp, fexp, ccexp) Extension.rx
209           and fext   = (stm, rexp, fexp, ccexp) Extension.fx
210           and ccext  = (stm, rexp, fexp, ccexp) Extension.ccx
211           and labexp = rexp
212    
213      (*
214       * Instruction streams
215       *)
216      type ('i,'cellset) stream = ('i, an list, 'cellset) Stream.stream
217    
218    exception Unsupported of string * rexp    (*
219       * Extension mechanism
220       *)
221    
222      datatype ('instr,'cellset,'operand,'addressing_mode) reducer =
223        REDUCER of
224        { reduceRexp    : rexp -> reg,
225          reduceFexp    : fexp -> reg,
226          reduceCCexp   : ccexp -> reg,
227          reduceStm     : stm * an list -> unit,
228          operand       : rexp -> 'operand,
229          reduceOperand : 'operand -> reg,
230          addressOf     : rexp -> 'addressing_mode,
231          emit          : 'instr * an list -> unit,
232          instrStream   : ('instr,'cellset) stream,
233          mltreeStream  : (stm,mlrisc list) stream
234        }
235    
236      (*
237       * Useful type abbreviations for working for MLTree.
238       *)
239      type rewriter =  (* rewriting functions *)
240        {stm:stm->stm, rexp:rexp->rexp, fexp:fexp->fexp, ccexp:ccexp->ccexp}
241      type 'a folder = (* aggregation functions *)
242        {stm:stm*'a->'a, rexp:rexp*'a->'a, fexp:fexp*'a->'a, ccexp:ccexp*'a->'a}
243      type hasher =    (* hashing functions *)
244        {stm:stm->word, rexp:rexp->word, fexp:fexp->word, ccexp:ccexp->word}
245      type equality =  (* comparison functions *)
246        {stm:stm * stm->bool, rexp:rexp * rexp->bool,
247         fexp:fexp * fexp->bool, ccexp:ccexp * ccexp->bool}
248      type printer =   (* pretty printing functions *)
249        {stm:stm->string, rexp:rexp->string, fexp:fexp->string, ccexp:ccexp->string,
250         dstReg : ty * var -> string, srcReg : ty * var -> string}
251    
252  end (* MLTREE *)  end (* MLTREE *)
253    

Legend:
Removed from v.411  
changed lines
  Added in v.775

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