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 651, Thu Jun 1 18:34:03 2000 UTC revision 839, Thu Jun 7 20:28:44 2001 UTC
# Line 4  Line 4 
4   *   *
5   *)   *)
6    
7  functor MLTreeF(structure LabelExp  : LABELEXP  functor MLTreeF(structure Constant  : CONSTANT
8                  structure Region    : REGION                  structure Region    : REGION
9                  structure Stream    : INSTRUCTION_STREAM                  structure Stream    : INSTRUCTION_STREAM
10                  structure Extension : MLTREE_EXTENSION                  structure Extension : MLTREE_EXTENSION
11                 ) : MLTREE =                 ) : MLTREE =
12  struct  struct
13    structure LabelExp = LabelExp    structure Constant = Constant
   structure Constant = LabelExp.Constant  
14    structure PseudoOp = Stream.P    structure PseudoOp = Stream.P
15    structure Stream = Stream    structure Stream = Stream
16    structure Region = Region    structure Region = Region
17    structure Basis  = MLTreeBasis    structure Basis  = MLTreeBasis
18    structure Extension = Extension    structure Extension = Extension
19      structure I = MachineInt
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 *)
# Line 31  Line 31 
31    datatype rounding_mode = datatype Basis.rounding_mode    datatype rounding_mode = datatype Basis.rounding_mode
32    datatype ext = datatype Basis.ext    datatype ext = datatype Basis.ext
33    
   (* phi-functions for SSA form *)  
   datatype phi =  
       RPHI  of ty * dst * src list  
     | FPHI  of fty * dst * src list  
     | CCPHI of dst * src list  
   
   (* aliasing declarations  
    * These are used to define physical register bindings for SSA names  
    *)  
   type alias = var * reg (* var is aliased to register *)  
   
34    (* Statements/effects.  These types are parameterized by the statement    (* Statements/effects.  These types are parameterized by the statement
35     * extension type.  Unfortunately, this has to be made polymorphic to make     * extension type.  Unfortunately, this has to be made polymorphic to make
36     * it possible for recursive type definitions to work.     * it possible for recursive type definitions to work.
    *  
    * Terms marked with rtl are used within the rtl language  
37     *)     *)
38    datatype stm =    datatype stm =
39        (* assignment *)        (* assignment *)
40        MV      of ty * dst * rexp   (* rtl *)        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 *)        (* parallel copies *)
45      | COPY    of ty * dst list * src list   (* rtl *)      | COPY    of ty * dst list * src list
46      | FCOPY   of fty * dst list * src list      | FCOPY   of fty * dst list * src list
47    
48        (* control flow *)        (* control flow *)
49      | JMP     of ctrls * rexp * controlflow (* rtl *)      | JMP     of rexp * controlflow
50      | BCC     of ctrls * ccexp * Label.label      | BCC     of ccexp * Label.label
51      | CALL    of {funct:rexp, targets:controlflow,      | CALL    of {funct:rexp, targets:controlflow,
52                    defs:mlrisc list, uses:mlrisc list,                    defs:mlrisc list, uses:mlrisc list,
53                    cdefs:ctrls, cuses: ctrls, region: Region.region} (* rtl *)                    region: Region.region, pops: Int32.int}
54      | RET     of ctrls * controlflow (* rtl *)      | FLOW_TO of stm * controlflow
55      | JOIN    of ctrls      | RET     of controlflow
56      | IF      of ctrls * ccexp * stm * stm   (* rtl *)      | IF      of ccexp * stm * stm
57    
58        (* memory update: ea, data *)        (* memory update: ea, data *)
59      | STORE  of ty * rexp * rexp * Region.region      | STORE  of ty * rexp * rexp * Region.region
# Line 82  Line 69 
69      | EXT of sext  (* extension *)      | EXT of sext  (* extension *)
70    
71        (* RTL operators:        (* RTL operators:
72         * The following are used internally for describing instruction semantics.         * The following are used internally
73           * for describing instruction semantics.
74         * The frontend must not use these.         * The frontend must not use these.
75         *)         *)
76      | PHI    of {preds:int list, block:int}      | PHI    of {preds:int list, block:int}
77      | SOURCE of {block:int, liveIn:reg list}      | ASSIGN of ty * rexp * rexp
78      | SINK   of {block:int, liveOut:reg list}      | SOURCE
79      | RTL    of {hash:word ref, attribs:Basis.attribs, e:stm}      | SINK
80        | RTL    of {hash:word, attribs:Basis.attribs ref, e:stm}
81    
82    and rexp =    and rexp =
83        REG    of ty * reg            (* rtl *)        REG    of ty * reg
84    
85        (* sizes of constants are inferred by context *)        (* sizes of constants are inferred by context *)
86      | LI     of int                 (* rtl *)      | LI     of I.machine_int
87      | LI32   of Word32.word         (* rtl *)      | LABEL  of Label.label
     | LI64   of Word64.word         (* rtl *)  
     | LABEL  of LabelExp.labexp  
88      | CONST  of Constant.const      | CONST  of Constant.const
89        | LABEXP of rexp
90    
91      | NEG    of ty * rexp      | NEG    of ty * rexp
92      | ADD    of ty * rexp * rexp    (* rtl *)      | ADD    of ty * rexp * rexp
93      | SUB    of ty * rexp * rexp    (* rtl *)      | SUB    of ty * rexp * rexp
94    
95        (* signed multiplication etc. *)        (* signed multiplication etc. *)
96      | MULS   of ty * rexp * rexp    (* rtl *)      | MULS   of ty * rexp * rexp
97      | DIVS   of ty * rexp * rexp    (* rtl *)      | DIVS   of ty * rexp * rexp
98      | QUOTS  of ty * rexp * rexp    (* rtl *)      | QUOTS  of ty * rexp * rexp
99      | REMS   of ty * rexp * rexp    (* rtl *)      | REMS   of ty * rexp * rexp
100    
101        (* unsigned multiplication etc. *)        (* unsigned multiplication etc. *)
102      | MULU   of ty * rexp * rexp    (* rtl *)      | MULU   of ty * rexp * rexp
103      | DIVU   of ty * rexp * rexp    (* rtl *)      | DIVU   of ty * rexp * rexp
104      | REMU   of ty * rexp * rexp    (* rtl *)      | 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      | NEGT   of ty * rexp
108      | ADDT   of ty * rexp * rexp    (* rtl *)      | ADDT   of ty * rexp * rexp
109      | SUBT   of ty * rexp * rexp    (* rtl *)      | SUBT   of ty * rexp * rexp
110      | MULT   of ty * rexp * rexp    (* rtl *)      | MULT   of ty * rexp * rexp
111      | DIVT   of ty * rexp * rexp    (* rtl *)      | DIVT   of ty * rexp * rexp
112      | QUOTT  of ty * rexp * rexp    (* rtl *)      | QUOTT  of ty * rexp * rexp
113      | REMT   of ty * rexp * rexp    (* rtl *)      | REMT   of ty * rexp * rexp
114    
115        (* bit operations *)        (* bit operations *)
116      | ANDB   of ty * rexp * rexp    (* rtl *)      | ANDB   of ty * rexp * rexp
117      | ORB    of ty * rexp * rexp    (* rtl *)      | ORB    of ty * rexp * rexp
118      | XORB   of ty * rexp * rexp    (* rtl *)      | XORB   of ty * rexp * rexp
119      | NOTB   of ty * rexp              (* rtl *)      | EQVB   of ty * rexp * rexp
120        | NOTB   of ty * rexp
121      | SRA   of ty * rexp * rexp   (* value, shift *) (* rtl *)  
122      | SRL   of ty * rexp * rexp     (* rtl *)      | SRA    of ty * rexp * rexp    (* value, shift *)
123      | SLL   of ty * rexp * rexp     (* rtl *)      | SRL    of ty * rexp * rexp
124        | SLL    of ty * rexp * rexp
125    
126        (* type promotion/conversion *)        (* type promotion/conversion *)
127      | CVTI2I of ty * ext * ty * rexp  (* signed extension *) (* rtl *)      | SX     of ty * ty * rexp  (* toTy, fromTy *)
128      | CVTF2I of ty * rounding_mode * fty * fexp (* rtl *)      | ZX     of ty * ty * rexp  (* toTy, fromTy *)
129        | CVTF2I of ty * rounding_mode * fty * fexp
130    
131        (*        (*
132         * COND(ty,cc,e1,e2):         * COND(ty,cc,e1,e2):
133         * Evaluate into either e1 or e2, depending on cc.         * Evaluate into either e1 or e2, depending on cc.
134         * Both e1 and e2 are allowed to be evaluated eagerly.         * Both e1 and e2 are allowed to be evaluated eagerly.
135         *)         *)
136      | COND of ty * ccexp * rexp * rexp  (* rtl *)      | COND of ty * ccexp * rexp * rexp
137    
138        (* integer load *)        (* integer load *)
139      | LOAD of ty * rexp * Region.region (* rtl *)      | LOAD of ty * rexp * Region.region
140    
141        (* predication *)        (* predication *)
142      | PRED of rexp * ctrl      | PRED of rexp * ctrl
# Line 157  Line 147 
147    
148      | MARK of rexp * an      | MARK of rexp * an
149    
150        | 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
# Line 182  Line 183 
183      | FMARK of fexp * an      | FMARK of fexp * an
184    
185    and ccexp =    and ccexp =
186        CC     of Basis.cond * src                        (* rtl *)        CC     of Basis.cond * src
187      | FCC    of Basis.fcond * src                       (* rtl *)      | FCC    of Basis.fcond * src
188      | TRUE                                              (* rtl *)      | TRUE
189      | FALSE                                             (* rtl *)      | FALSE
190      | NOT    of ccexp                     (* rtl *)      | NOT    of ccexp
191      | AND    of ccexp * ccexp   (* rtl *)      | AND    of ccexp * ccexp
192      | OR     of ccexp * ccexp   (* rtl *)      | OR     of ccexp * ccexp
193      | XOR    of ccexp * ccexp   (* rtl *)      | XOR    of ccexp * ccexp
194      | CMP    of ty * Basis.cond * rexp * rexp(*rtl*)      | EQV    of ccexp * ccexp
195        | 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 * an      | CCMARK of ccexp * an
198      | CCEXT  of ty * ccext      | CCEXT  of ty * ccext
# Line 207  Line 209 
209         and rext   = (stm, rexp, fexp, ccexp) Extension.rx         and rext   = (stm, rexp, fexp, ccexp) Extension.rx
210         and fext   = (stm, rexp, fexp, ccexp) Extension.fx         and fext   = (stm, rexp, fexp, ccexp) Extension.fx
211         and ccext  = (stm, rexp, fexp, ccexp) Extension.ccx         and ccext  = (stm, rexp, fexp, ccexp) Extension.ccx
212           and labexp = rexp
213    
214    (*    (*
215     * Instruction streams     * Instruction streams
216     *)     *)
217    type ('i,'regmap,'cellset) stream =    type ('i,'cellset) stream = ('i, an list, 'cellset) Stream.stream
        ('i -> unit,'regmap, an list, 'cellset, alias, phi) Stream.stream  
218    
219    (*    (*
220     * Extension mechanism     * Extension mechanism
221     *)     *)
222    
223    datatype ('instr,'regmap,'cellset,'operand,'addressing_mode) reducer =    datatype ('instr,'cellset,'operand,'addressing_mode) reducer =
224      REDUCER of      REDUCER of
225      { reduceRexp    : rexp -> reg,      { reduceRexp    : rexp -> reg,
226        reduceFexp    : fexp -> reg,        reduceFexp    : fexp -> reg,
# Line 228  Line 230 
230        reduceOperand : 'operand -> reg,        reduceOperand : 'operand -> reg,
231        addressOf     : rexp -> 'addressing_mode,        addressOf     : rexp -> 'addressing_mode,
232        emit          : 'instr * an list -> unit,        emit          : 'instr * an list -> unit,
233        instrStream   : ('instr,'regmap,'cellset) stream,        instrStream   : ('instr,'cellset) stream,
234        mltreeStream  : (stm,'regmap,mlrisc list) stream        mltreeStream  : (stm,mlrisc list) stream
235      }      }
236    
237    (*    (*

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

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