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 545, Thu Feb 24 13:56:44 2000 UTC revision 651, Thu Jun 1 18:34:03 2000 UTC
# Line 5  Line 5 
5   *)   *)
6    
7  functor MLTreeF(structure LabelExp : LABELEXP  functor MLTreeF(structure LabelExp : LABELEXP
8                  structure R : REGION                  structure Region    : REGION
9                  structure S : INSTRUCTION_STREAM                  structure Stream    : INSTRUCTION_STREAM
10                    structure Extension : MLTREE_EXTENSION
11                 ) : MLTREE =                 ) : MLTREE =
12  struct  struct
13    structure LabelExp = LabelExp    structure LabelExp = LabelExp
14    structure Constant = LabelExp.Constant    structure Constant = LabelExp.Constant
15    structure PseudoOp = S.P    structure PseudoOp = Stream.P
16    structure Stream = S    structure Stream = Stream
17    structure Region = R    structure Region = Region
18    structure Basis  = MLTreeBasis    structure Basis  = MLTreeBasis
19      structure Extension = Extension
20    
21    type ty  = Basis.ty    type ty  = Basis.ty
22    type fty = Basis.fty    type fty = Basis.fty
# Line 46  Line 48 
48     *     *
49     * Terms marked with rtl are used within the rtl language     * Terms marked with rtl are used within the rtl language
50     *)     *)
51    datatype ('s,'r,'f,'c) stm =    datatype stm =
52        (* assignment *)        (* assignment *)
53        MV      of ty * dst * ('s,'r,'f,'c) rexp   (* rtl *)        MV      of ty * dst * rexp   (* rtl *)
54      | CCMV    of dst * ('s,'r,'f,'c) ccexp      | CCMV    of dst * ccexp
55      | FMV     of fty * dst * ('s,'r,'f,'c) fexp      | FMV     of fty * dst * fexp
56    
57        (* parallel copies *)        (* parallel copies *)
58      | COPY    of ty * dst list * src list   (* rtl *)      | COPY    of ty * dst list * src list   (* rtl *)
59      | FCOPY   of fty * dst list * src list      | FCOPY   of fty * dst list * src list
60    
61        (* control flow *)        (* control flow *)
62      | JMP     of ctrls * ('s,'r,'f,'c) rexp * controlflow (* rtl *)      | JMP     of ctrls * rexp * controlflow (* rtl *)
63      | BCC     of ctrls * ('s,'r,'f,'c) ccexp * Label.label      | BCC     of ctrls * ccexp * Label.label
64      | CALL    of ('s,'r,'f,'c) rexp * controlflow * ('s,'r,'f,'c) mlrisc list * ('s,'r,'f,'c) mlrisc list *      | CALL    of {funct:rexp, targets:controlflow,
65                   ctrls * ctrls * Region.region (* rtl *)                    defs:mlrisc list, uses:mlrisc list,
66                      cdefs:ctrls, cuses: ctrls, region: Region.region} (* rtl *)
67      | RET     of ctrls * controlflow (* rtl *)      | RET     of ctrls * controlflow (* rtl *)
68      | JOIN    of ctrls      | JOIN    of ctrls
69      | IF      of ctrls * ('s,'r,'f,'c) ccexp *      | IF      of ctrls * ccexp * stm * stm   (* rtl *)
                   ('s,'r,'f,'c) stm * ('s,'r,'f,'c) stm   (* rtl *)  
70    
71        (* memory update: ea, data *)        (* memory update: ea, data *)
72      | STORE  of ty * ('s,'r,'f,'c) rexp * ('s,'r,'f,'c) rexp * Region.region      | STORE  of ty * rexp * rexp * Region.region
73      | FSTORE of fty * ('s,'r,'f,'c) rexp * ('s,'r,'f,'c) fexp * Region.region      | FSTORE of fty * rexp * fexp * Region.region
74    
75        (* control dependence *)        (* control dependence *)
76      | REGION of ('s,'r,'f,'c) stm * ctrl      | REGION of stm * ctrl
77    
78      | SEQ    of ('s,'r,'f,'c) stm list   (* sequencing *)      | SEQ    of stm list   (* sequencing *)
79      | DEFINE of Label.label   (* define local label *)      | DEFINE of Label.label   (* define local label *)
80    
81      | ANNOTATION of ('s,'r,'f,'c) stm * an      | ANNOTATION of stm * an
82      | EXT of 's    (* extension *)      | EXT of sext  (* extension *)
83    
84        (* RTL operators:        (* RTL operators:
85         * The following are used internally for describing instruction semantics.         * The following are used internally for describing instruction semantics.
86         * The frontend must not use these.         * The frontend must not use these.
87         *)         *)
88      | PHI    of int                    (* a phi-function at some block id *)      | PHI    of {preds:int list, block:int}
89      | PINNED of ('s,'r,'f,'c) stm      (* pinned statement *)      | SOURCE of {block:int, liveIn:reg list}
90      | RTL    of {hash:word ref, attribs:Basis.attribs, e:('s,'r,'f,'c) stm}      | SINK   of {block:int, liveOut:reg list}
91        | RTL    of {hash:word ref, attribs:Basis.attribs, e:stm}
92    
93    and ('s,'r,'f,'c) rexp =    and rexp =
94        REG    of ty * reg            (* rtl *)        REG    of ty * reg            (* rtl *)
95    
96        (* sizes of constants are inferred by context *)        (* sizes of constants are inferred by context *)
# Line 97  Line 100 
100      | LABEL  of LabelExp.labexp      | LABEL  of LabelExp.labexp
101      | CONST  of Constant.const      | CONST  of Constant.const
102    
103      | NEG    of ty * ('s,'r,'f,'c) rexp      | NEG    of ty * rexp
104      | ADD    of ty * ('s,'r,'f,'c) rexp * ('s,'r,'f,'c) rexp    (* rtl *)      | ADD    of ty * rexp * rexp    (* rtl *)
105      | SUB    of ty * ('s,'r,'f,'c) rexp * ('s,'r,'f,'c) rexp    (* rtl *)      | SUB    of ty * rexp * rexp    (* rtl *)
106    
107        (* signed multiplication etc. *)        (* signed multiplication etc. *)
108      | MULS   of ty * ('s,'r,'f,'c) rexp * ('s,'r,'f,'c) rexp    (* rtl *)      | MULS   of ty * rexp * rexp    (* rtl *)
109      | DIVS   of ty * ('s,'r,'f,'c) rexp * ('s,'r,'f,'c) rexp    (* rtl *)      | DIVS   of ty * rexp * rexp    (* rtl *)
110      | QUOTS  of ty * ('s,'r,'f,'c) rexp * ('s,'r,'f,'c) rexp    (* rtl *)      | QUOTS  of ty * rexp * rexp    (* rtl *)
111      | REMS   of ty * ('s,'r,'f,'c) rexp * ('s,'r,'f,'c) rexp    (* rtl *)      | REMS   of ty * rexp * rexp    (* rtl *)
112    
113        (* unsigned multiplication etc. *)        (* unsigned multiplication etc. *)
114      | MULU   of ty * ('s,'r,'f,'c) rexp * ('s,'r,'f,'c) rexp    (* rtl *)      | MULU   of ty * rexp * rexp    (* rtl *)
115      | DIVU   of ty * ('s,'r,'f,'c) rexp * ('s,'r,'f,'c) rexp    (* rtl *)      | DIVU   of ty * rexp * rexp    (* rtl *)
116      | REMU   of ty * ('s,'r,'f,'c) rexp * ('s,'r,'f,'c) rexp    (* rtl *)      | 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      | NEGT   of ty * ('s,'r,'f,'c) rexp      | NEGT   of ty * rexp
120      | ADDT   of ty * ('s,'r,'f,'c) rexp * ('s,'r,'f,'c) rexp    (* rtl *)      | ADDT   of ty * rexp * rexp    (* rtl *)
121      | SUBT   of ty * ('s,'r,'f,'c) rexp * ('s,'r,'f,'c) rexp    (* rtl *)      | SUBT   of ty * rexp * rexp    (* rtl *)
122      | MULT   of ty * ('s,'r,'f,'c) rexp * ('s,'r,'f,'c) rexp    (* rtl *)      | MULT   of ty * rexp * rexp    (* rtl *)
123      | DIVT   of ty * ('s,'r,'f,'c) rexp * ('s,'r,'f,'c) rexp    (* rtl *)      | DIVT   of ty * rexp * rexp    (* rtl *)
124      | QUOTT  of ty * ('s,'r,'f,'c) rexp * ('s,'r,'f,'c) rexp    (* rtl *)      | QUOTT  of ty * rexp * rexp    (* rtl *)
125      | REMT   of ty * ('s,'r,'f,'c) rexp * ('s,'r,'f,'c) rexp    (* rtl *)      | REMT   of ty * rexp * rexp    (* rtl *)
126    
127        (* bit operations *)        (* bit operations *)
128      | ANDB   of ty * ('s,'r,'f,'c) rexp * ('s,'r,'f,'c) rexp    (* rtl *)      | ANDB   of ty * rexp * rexp    (* rtl *)
129      | ORB    of ty * ('s,'r,'f,'c) rexp * ('s,'r,'f,'c) rexp    (* rtl *)      | ORB    of ty * rexp * rexp    (* rtl *)
130      | XORB   of ty * ('s,'r,'f,'c) rexp * ('s,'r,'f,'c) rexp    (* rtl *)      | XORB   of ty * rexp * rexp    (* rtl *)
131      | NOTB   of ty * ('s,'r,'f,'c) rexp              (* rtl *)      | NOTB   of ty * rexp              (* rtl *)
132    
133      | SRA   of ty * ('s,'r,'f,'c) rexp * ('s,'r,'f,'c) rexp       (* value, shift *) (* rtl *)      | SRA   of ty * rexp * rexp   (* value, shift *) (* rtl *)
134      | SRL   of ty * ('s,'r,'f,'c) rexp * ('s,'r,'f,'c) rexp     (* rtl *)      | SRL   of ty * rexp * rexp     (* rtl *)
135      | SLL   of ty * ('s,'r,'f,'c) rexp * ('s,'r,'f,'c) rexp     (* rtl *)      | SLL   of ty * rexp * rexp     (* rtl *)
136    
137        (* type promotion/conversion *)        (* type promotion/conversion *)
138      | CVTI2I of ty * ext * ty * ('s,'r,'f,'c) rexp  (* signed extension *) (* rtl *)      | CVTI2I of ty * ext * ty * rexp  (* signed extension *) (* rtl *)
139      | CVTF2I of ty * rounding_mode * fty * ('s,'r,'f,'c) fexp (* rtl *)      | CVTF2I of ty * rounding_mode * fty * fexp (* rtl *)
140    
141        (*        (*
142         * COND(ty,cc,e1,e2):         * COND(ty,cc,e1,e2):
143         * Evaluate into either e1 or e2, depending on cc.         * Evaluate into either e1 or e2, depending on cc.
144         * Both e1 and e2 are allowed to be evaluated eagerly.         * Both e1 and e2 are allowed to be evaluated eagerly.
145         *)         *)
146      | COND of ty * ('s,'r,'f,'c) ccexp * ('s,'r,'f,'c) rexp * ('s,'r,'f,'c) rexp  (* rtl *)      | COND of ty * ccexp * rexp * rexp  (* rtl *)
147    
148        (* integer load *)        (* integer load *)
149      | LOAD of ty * ('s,'r,'f,'c) rexp * Region.region (* rtl *)      | LOAD of ty * rexp * Region.region (* rtl *)
150    
151        (* predication *)        (* predication *)
152      | PRED of ('s,'r,'f,'c) rexp * ctrl      | PRED of rexp * ctrl
153    
154      | LET of ('s,'r,'f,'c) stm * ('s,'r,'f,'c) rexp      | LET of stm * rexp
155    
156      | REXT of ty * 'r      | REXT of ty * rext
157    
158      | MARK of ('s,'r,'f,'c) rexp * an      | MARK of rexp * an
159    
160    and ('s,'r,'f,'c) fexp =    and fexp =
161        FREG   of fty * src        FREG   of fty * src
162      | FLOAD  of fty * ('s,'r,'f,'c) rexp * Region.region      | FLOAD  of fty * rexp * Region.region
163    
164      | FADD   of fty * ('s,'r,'f,'c) fexp * ('s,'r,'f,'c) fexp      | FADD   of fty * fexp * fexp
165      | FMUL   of fty * ('s,'r,'f,'c) fexp * ('s,'r,'f,'c) fexp      | FMUL   of fty * fexp * fexp
166      | FSUB   of fty * ('s,'r,'f,'c) fexp * ('s,'r,'f,'c) fexp      | FSUB   of fty * fexp * fexp
167      | FDIV   of fty * ('s,'r,'f,'c) fexp * ('s,'r,'f,'c) fexp      | FDIV   of fty * fexp * fexp
168      | FABS   of fty * ('s,'r,'f,'c) fexp      | FABS   of fty * fexp
169      | FNEG   of fty * ('s,'r,'f,'c) fexp      | FNEG   of fty * fexp
170      | FSQRT  of fty * ('s,'r,'f,'c) fexp      | FSQRT  of fty * fexp
171      | FCOND  of fty * ('s,'r,'f,'c) ccexp *      | FCOND  of fty * ccexp *
172                  ('s,'r,'f,'c) fexp * ('s,'r,'f,'c) fexp                  fexp * fexp
173      | FCOPYSIGN of fty * ('s,'r,'f,'c) fexp (*sign*) *      | FCOPYSIGN of fty * fexp (*sign*) * fexp (*magnitude*)
                          ('s,'r,'f,'c) fexp (*magnitude*)  
   
     | CVTI2F of fty * ty * ('s,'r,'f,'c) rexp  (* from signed integer *)  
     | CVTF2F of fty * fty * ('s,'r,'f,'c) fexp (* float to float conversion *)  
174    
175      | FPRED of ('s,'r,'f,'c) fexp * ctrl      | CVTI2F of fty * ty * rexp  (* from signed integer *)
176        | CVTF2F of fty * fty * fexp (* float to float conversion *)
177    
178      | FEXT of fty * 'f      | FPRED of fexp * ctrl
179    
180      | FMARK of ('s,'r,'f,'c) fexp * an      | FEXT of fty * fext
181    
182    and ('s,'r,'f,'c) ccexp =      | FMARK of fexp * an
183    
184      and ccexp =
185        CC     of Basis.cond * src                        (* rtl *)        CC     of Basis.cond * src                        (* rtl *)
186      | FCC    of Basis.fcond * src                       (* rtl *)      | FCC    of Basis.fcond * src                       (* rtl *)
187      | TRUE                                              (* rtl *)      | TRUE                                              (* rtl *)
188      | FALSE                                             (* rtl *)      | FALSE                                             (* rtl *)
189      | NOT    of ('s,'r,'f,'c) ccexp                     (* rtl *)      | NOT    of ccexp                     (* rtl *)
190      | AND    of ('s,'r,'f,'c) ccexp * ('s,'r,'f,'c) ccexp   (* rtl *)      | AND    of ccexp * ccexp   (* rtl *)
191      | OR     of ('s,'r,'f,'c) ccexp * ('s,'r,'f,'c) ccexp   (* rtl *)      | OR     of ccexp * ccexp   (* rtl *)
192      | XOR    of ('s,'r,'f,'c) ccexp * ('s,'r,'f,'c) ccexp   (* rtl *)      | XOR    of ccexp * ccexp   (* rtl *)
193      | CMP    of ty * Basis.cond * ('s,'r,'f,'c) rexp * ('s,'r,'f,'c) rexp(*rtl*)      | CMP    of ty * Basis.cond * rexp * rexp(*rtl*)
194      | FCMP   of fty * Basis.fcond * ('s,'r,'f,'c) fexp * ('s,'r,'f,'c) fexp      | FCMP   of fty * Basis.fcond * fexp * fexp
195      | CCMARK of ('s,'r,'f,'c) ccexp * an      | CCMARK of ccexp * an
196      | CCEXT  of ty * 'c      | CCEXT  of ty * ccext
197    
198    and ('s,'r,'f,'c) mlrisc =    and mlrisc =
199        CCR of ('s,'r,'f,'c) ccexp        CCR of ccexp
200      | GPR of ('s,'r,'f,'c) rexp      | GPR of rexp
201      | FPR of ('s,'r,'f,'c) fexp      | FPR of fexp
202    
203    withtype controlflow = Label.label list (* control flow info *)    withtype controlflow = Label.label list (* control flow info *)
204         and ctrl = var                     (* control dependence info *)         and ctrl = var                     (* control dependence info *)
205         and ctrls = ctrl list         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     * Instruction streams
# Line 208  Line 214 
214    type ('i,'regmap,'cellset) stream =    type ('i,'regmap,'cellset) stream =
215         ('i -> unit,'regmap, an list, 'cellset, alias, phi) Stream.stream         ('i -> unit,'regmap, an list, 'cellset, alias, phi) Stream.stream
216    
217    (* Extension mechanism *)    (*
218       * Extension mechanism
219       *)
220    
221    (* These functions are supplied by the instruction selection module *)    datatype ('instr,'regmap,'cellset,'operand,'addressing_mode) reducer =
   datatype ('instr,'regmap,'cellset,'operand,'addressing_mode,'s,'r,'f,'c)  
     reducer =  
222      REDUCER of      REDUCER of
223      { reduceRexp    : ('s,'r,'f,'c) rexp -> reg,      { reduceRexp    : rexp -> reg,
224        reduceFexp    : ('s,'r,'f,'c) fexp -> reg,        reduceFexp    : fexp -> reg,
225        reduceCCexp   : ('s,'r,'f,'c) ccexp -> reg,        reduceCCexp   : ccexp -> reg,
226        reduceStm     : ('s,'r,'f,'c) stm * an list -> unit,        reduceStm     : stm * an list -> unit,
227        operand       : ('s,'r,'f,'c) rexp -> 'operand,        operand       : rexp -> 'operand,
228        reduceOperand : 'operand -> reg,        reduceOperand : 'operand -> reg,
229        addressOf     : ('s,'r,'f,'c) rexp -> 'addressing_mode,        addressOf     : rexp -> 'addressing_mode,
230        emit          : 'instr * an list -> unit,        emit          : 'instr * an list -> unit,
231        instrStream   : ('instr,'regmap,'cellset) stream,        instrStream   : ('instr,'regmap,'cellset) stream,
232        mltreeStream  :        mltreeStream  : (stm,'regmap,mlrisc list) stream
         (('s,'r,'f,'c) stm,'regmap,('s,'r,'f,'c) mlrisc list) stream  
233      }      }
234    
235      (*
236    (* These functions should be provided by the client *)     * Useful type abbreviations for working for MLTree.
237    datatype ('instr,'regmap,'cellset,'operand,'addressing_mode,'s,'r,'f,'c)     *)
238             extender =    type rewriter =  (* rewriting functions *)
239      EXTENDER of      {stm:stm->stm, rexp:rexp->rexp, fexp:fexp->fexp, ccexp:ccexp->ccexp}
240      { compileStm  :    type 'a folder = (* aggregation functions *)
241             ('instr,'regmap,'cellset,'operand,'addressing_mode,'s,'r,'f,'c)      {stm:stm*'a->'a, rexp:rexp*'a->'a, fexp:fexp*'a->'a, ccexp:ccexp*'a->'a}
242             reducer -> { stm : 's, an : an list} -> unit,    type hasher =    (* hashing functions *)
243        compileRexp :      {stm:stm->word, rexp:rexp->word, fexp:fexp->word, ccexp:ccexp->word}
244             ('instr,'regmap,'cellset,'operand,'addressing_mode,'s,'r,'f,'c)    type equality =  (* comparison functions *)
245             reducer -> {e:ty * 'r, an:an list, rd:reg} -> unit,      {stm:stm * stm->bool, rexp:rexp * rexp->bool,
246        compileFexp :       fexp:fexp * fexp->bool, ccexp:ccexp * ccexp->bool}
247             ('instr,'regmap,'cellset,'operand,'addressing_mode,'s,'r,'f,'c)    type printer =   (* pretty printing functions *)
248             reducer -> {e:fty * 'f, an:an list, fd:reg} -> unit,      {stm:stm->string, rexp:rexp->string, fexp:fexp->string, ccexp:ccexp->string,
249        compileCCexp :       dstReg : ty * var -> string, srcReg : ty * var -> string}
            ('instr,'regmap,'cellset,'operand,'addressing_mode,'s,'r,'f,'c)  
            reducer -> {e:ty * 'c, an:an list, cd:reg} -> unit  
     }  
250    
251  end (* MLTREE *)  end (* MLTREE *)
252    

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

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