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 555, Fri Mar 3 16:10:30 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 rexp * controlflow * mlrisc list * mlrisc list *
65      | STORE_UNALIGNED of ty * rexp * rexp * Region.region                   ctrls * ctrls * Region.region (* rtl *)
66      | FSTORE of fty * rexp * fexp * Region.region       (* address, data *)      | RET     of ctrls * controlflow (* rtl *)
67      | FSTORE_UNALIGNED of fty * rexp * fexp * Region.region      | JOIN    of ctrls
68      | BCC    of Basis.cond * ccexp * Label.label      | IF      of ctrls * ccexp * stm * stm   (* rtl *)
69      | FBCC   of Basis.fcond * ccexp * Label.label  
70      | ANNOTATION of stm * Annotations.annotation        (* memory update: ea, data *)
71        | STORE  of ty * rexp * rexp * Region.region
72        (* The following are used internally by SSA optimizations;      | FSTORE of fty * rexp * fexp * Region.region
73         * The frontend should not generate these.  
74         *)        (* control dependence *)
75      | RTL of word ref * word * stm (* an RTL *)      | REGION of stm * ctrl
76      | RTLPHI of int (* a phi-function at block id *)  
77      | RTLPINNED of stm (* pinned statement *)      | SEQ    of stm list   (* sequencing *)
78      | RTLPAR of stm list (* parallel execution *)      | DEFINE of Label.label   (* define local label *)
79    
80        | ANNOTATION of stm * an
81        | EXT of sext  (* extension *)
82    
83          (* RTL operators:
84           * The following are used internally for describing instruction semantics.
85           * The frontend must not use these.
86           *)
87        | PHI    of int                    (* a phi-function at some block id *)
88        | PINNED of stm      (* pinned statement *)
89        | RTL    of {hash:word ref, attribs:Basis.attribs, e:stm}
90    
91    and rexp =    and rexp =
92        REG    of ty * src        REG    of ty * reg            (* rtl *)
93    
94        (* sizes of constants are inferred by context *)        (* sizes of constants are inferred by context *)
95      | LI     of int      | LI     of int                 (* rtl *)
96      | LI32   of Word32.word      | LI32   of Word32.word         (* rtl *)
97      | LI64   of Word64.word      | LI64   of Word64.word         (* rtl *)
98      | LABEL  of LabelExp.labexp      | LABEL  of LabelExp.labexp
99      | CONST  of Constant.const      | CONST  of Constant.const
100    
101      | ADD    of ty * rexp * rexp      | NEG    of ty * rexp
102      | SUB    of ty * rexp * rexp      | ADD    of ty * rexp * rexp    (* rtl *)
103        | SUB    of ty * rexp * rexp    (* rtl *)
104    
105        (* signed multiplication etc. *)        (* signed multiplication etc. *)
106      | MULS   of ty * rexp * rexp      | MULS   of ty * rexp * rexp    (* rtl *)
107      | DIVS   of ty * rexp * rexp      | DIVS   of ty * rexp * rexp    (* rtl *)
108      | REMS   of ty * rexp * rexp      | QUOTS  of ty * rexp * rexp    (* rtl *)
109        | REMS   of ty * rexp * rexp    (* rtl *)
110    
111        (* unsigned multiplication etc. *)        (* unsigned multiplication etc. *)
112      | MULU   of ty * rexp * rexp      | MULU   of ty * rexp * rexp    (* rtl *)
113      | DIVU   of ty * rexp * rexp      | DIVU   of ty * rexp * rexp    (* rtl *)
114      | REMU   of ty * rexp * rexp      | REMU   of ty * rexp * rexp    (* rtl *)
115    
116        (* trapping versions of above. These are all signed *)        (* trapping versions of above. These are all signed *)
117      | ADDT   of ty * rexp * rexp      | NEGT   of ty * rexp
118      | SUBT   of ty * rexp * rexp      | ADDT   of ty * rexp * rexp    (* rtl *)
119      | MULT   of ty * rexp * rexp      | SUBT   of ty * rexp * rexp    (* rtl *)
120      | DIVT   of ty * rexp * rexp      | MULT   of ty * rexp * rexp    (* rtl *)
121      | REMT   of ty * rexp * rexp      | DIVT   of ty * rexp * rexp    (* rtl *)
122        | QUOTT  of ty * rexp * rexp    (* rtl *)
123      | ANDB   of ty * rexp * rexp      | REMT   of ty * rexp * rexp    (* rtl *)
124      | ORB    of ty * rexp * rexp  
125      | XORB   of ty * rexp * rexp        (* bit operations *)
126      | NOTB   of ty * rexp      | ANDB   of ty * rexp * rexp    (* rtl *)
127        | ORB    of ty * rexp * rexp    (* rtl *)
128      | SRA   of ty * rexp * rexp         (* value, shift *)      | XORB   of ty * rexp * rexp    (* rtl *)
129      | SRL   of ty * rexp * rexp      | NOTB   of ty * rexp              (* rtl *)
130      | SLL   of ty * rexp * rexp  
131        | SRA   of ty * rexp * rexp   (* value, shift *) (* rtl *)
132        (* type promotion *)      | SRL   of ty * rexp * rexp     (* rtl *)
133      | CVTI2I of ty * Basis.ext * ty * rexp      | SLL   of ty * rexp * rexp     (* rtl *)
134      | CVTF2I of ty * Basis.rounding_mode * fty * fexp  
135          (* type promotion/conversion *)
136        (* conditional (eager) evaluation *)      | CVTI2I of ty * ext * ty * rexp  (* signed extension *) (* rtl *)
137      | COND of ty * ccexp * rexp * rexp      | CVTF2I of ty * rounding_mode * fty * fexp (* rtl *)
138    
139          (*
140           * COND(ty,cc,e1,e2):
141           * Evaluate into either e1 or e2, depending on cc.
142           * Both e1 and e2 are allowed to be evaluated eagerly.
143           *)
144        | COND of ty * ccexp * rexp * rexp  (* rtl *)
145    
146        (* integer load *)        (* integer load *)
147      | LOAD of ty * rexp * Region.region      | LOAD of ty * rexp * Region.region (* rtl *)
     | LOAD_UNALIGNED of ty * rexp * Region.region  
148    
149      | SEQ of stm * rexp        (* predication *)
150        | PRED of rexp * ctrl
151    
152      | EXT of ty * rextension * rexp list      | LET of stm * rexp
153    
154      | MARK of rexp * Annotations.annotation      | REXT of ty * rext
155    
156        (* Used in RTL *)      | MARK of rexp * an
     | 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                        (* rtl *)
184      | CMP    of ty * Basis.cond * rexp * rexp      | FCC    of Basis.fcond * src                       (* rtl *)
185        | TRUE                                              (* rtl *)
186        | FALSE                                             (* rtl *)
187        | NOT    of ccexp                     (* rtl *)
188        | AND    of ccexp * ccexp   (* rtl *)
189        | OR     of ccexp * ccexp   (* rtl *)
190        | XOR    of ccexp * ccexp   (* rtl *)
191        | CMP    of ty * Basis.cond * rexp * rexp(*rtl*)
192      | FCMP   of fty * Basis.fcond * fexp * fexp      | FCMP   of fty * Basis.fcond * fexp * fexp
193      | CCMARK of ccexp * Annotations.annotation      | CCMARK of ccexp * an
194      | RTLCCMISC of Basis.misc_op ref * ccexp list      | CCEXT  of ty * ccext
195    
196      and mlrisc =
197          CCR of ccexp
198        | GPR of rexp
199        | FPR of fexp
200    
201      withtype controlflow = Label.label list (* control flow info *)
202           and ctrl   = var                   (* control dependence info *)
203           and ctrls  = ctrl list
204           and sext   = (stm, rexp, fexp, ccexp) Extension.sx
205           and rext   = (stm, rexp, fexp, ccexp) Extension.rx
206           and fext   = (stm, rexp, fexp, ccexp) Extension.fx
207           and ccext  = (stm, rexp, fexp, ccexp) Extension.ccx
208    
209      (*
210       * Instruction streams
211       *)
212      type ('i,'regmap,'cellset) stream =
213           ('i -> unit,'regmap, an list, 'cellset, alias, phi) Stream.stream
214    
215    and mlrisc = CCR of ccexp | GPR of rexp | FPR of fexp    (*
216       * Extension mechanism
217       *)
218    
219    exception Unsupported of string * rexp    datatype ('instr,'regmap,'cellset,'operand,'addressing_mode) reducer =
220        REDUCER of
221        { reduceRexp    : rexp -> reg,
222          reduceFexp    : fexp -> reg,
223          reduceCCexp   : ccexp -> reg,
224          reduceStm     : stm * an list -> unit,
225          operand       : rexp -> 'operand,
226          reduceOperand : 'operand -> reg,
227          addressOf     : rexp -> 'addressing_mode,
228          emit          : 'instr * an list -> unit,
229          instrStream   : ('instr,'regmap,'cellset) stream,
230          mltreeStream  : (stm,'regmap,mlrisc list) stream
231        }
232    
233    type ('i,'regmap) stream =    (*
234         ('i -> unit,'regmap,Annotations.annotations,     * Useful type abbreviations for working for MLTree.
235          mlrisc list, alias, phi) Stream.stream     *)
236      type rewriter =  (* rewriting functions *)
237        {stm:stm->stm, rexp:rexp->rexp, fexp:fexp->fexp, ccexp:ccexp->ccexp}
238      type 'a folder = (* aggregation functions *)
239        {stm:stm*'a->'a, rexp:rexp*'a->'a, fexp:fexp*'a->'a, ccexp:ccexp*'a->'a}
240      type hasher =    (* hashing functions *)
241        {stm:stm->word, rexp:rexp->word, fexp:fexp->word, ccexp:ccexp->word}
242      type equality =  (* comparison functions *)
243        {stm:stm * stm->bool, rexp:rexp * rexp->bool,
244         fexp:fexp * fexp->bool, ccexp:ccexp * ccexp->bool}
245      type printer =   (* pretty printing functions *)
246        {stm:stm->string, rexp:rexp->string, fexp:fexp->string, ccexp:ccexp->string,
247         dstReg : ty * var -> string, srcReg : ty * var -> string}
248    
249  end (* MLTREE *)  end (* MLTREE *)
250    

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

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