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 775, Fri Jan 12 01:17:51 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}
54      | RET     of ctrls * controlflow (* rtl *)      | RET     of controlflow
55      | JOIN    of ctrls      | IF      of ccexp * stm * stm
     | IF      of ctrls * ccexp * stm * stm   (* rtl *)  
56    
57        (* memory update: ea, data *)        (* memory update: ea, data *)
58      | STORE  of ty * rexp * rexp * Region.region      | STORE  of ty * rexp * rexp * Region.region
# Line 82  Line 68 
68      | EXT of sext  (* extension *)      | EXT of sext  (* extension *)
69    
70        (* RTL operators:        (* RTL operators:
71         * The following are used internally for describing instruction semantics.         * The following are used internally
72           * for describing instruction semantics.
73         * The frontend must not use these.         * The frontend must not use these.
74         *)         *)
75      | PHI    of {preds:int list, block:int}      | PHI    of {preds:int list, block:int}
76      | SOURCE of {block:int, liveIn:reg list}      | ASSIGN of ty * rexp * rexp
77      | SINK   of {block:int, liveOut:reg list}      | SOURCE
78      | RTL    of {hash:word ref, attribs:Basis.attribs, e:stm}      | SINK
79        | RTL    of {hash:word, attribs:Basis.attribs ref, e:stm}
80    
81    and rexp =    and rexp =
82        REG    of ty * reg            (* rtl *)        REG    of ty * reg
83    
84        (* sizes of constants are inferred by context *)        (* sizes of constants are inferred by context *)
85      | LI     of int                 (* rtl *)      | LI     of I.machine_int
86      | LI32   of Word32.word         (* rtl *)      | LABEL  of Label.label
     | LI64   of Word64.word         (* rtl *)  
     | LABEL  of LabelExp.labexp  
87      | CONST  of Constant.const      | CONST  of Constant.const
88        | LABEXP of rexp
89    
90      | NEG    of ty * rexp      | NEG    of ty * rexp
91      | ADD    of ty * rexp * rexp    (* rtl *)      | ADD    of ty * rexp * rexp
92      | SUB    of ty * rexp * rexp    (* rtl *)      | SUB    of ty * rexp * rexp
93    
94        (* signed multiplication etc. *)        (* signed multiplication etc. *)
95      | MULS   of ty * rexp * rexp    (* rtl *)      | MULS   of ty * rexp * rexp
96      | DIVS   of ty * rexp * rexp    (* rtl *)      | DIVS   of ty * rexp * rexp
97      | QUOTS  of ty * rexp * rexp    (* rtl *)      | QUOTS  of ty * rexp * rexp
98      | REMS   of ty * rexp * rexp    (* rtl *)      | REMS   of ty * rexp * rexp
99    
100        (* unsigned multiplication etc. *)        (* unsigned multiplication etc. *)
101      | MULU   of ty * rexp * rexp    (* rtl *)      | MULU   of ty * rexp * rexp
102      | DIVU   of ty * rexp * rexp    (* rtl *)      | DIVU   of ty * rexp * rexp
103      | REMU   of ty * rexp * rexp    (* rtl *)      | 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      | NEGT   of ty * rexp
107      | ADDT   of ty * rexp * rexp    (* rtl *)      | ADDT   of ty * rexp * rexp
108      | SUBT   of ty * rexp * rexp    (* rtl *)      | SUBT   of ty * rexp * rexp
109      | MULT   of ty * rexp * rexp    (* rtl *)      | MULT   of ty * rexp * rexp
110      | DIVT   of ty * rexp * rexp    (* rtl *)      | DIVT   of ty * rexp * rexp
111      | QUOTT  of ty * rexp * rexp    (* rtl *)      | QUOTT  of ty * rexp * rexp
112      | REMT   of ty * rexp * rexp    (* rtl *)      | REMT   of ty * rexp * rexp
113    
114        (* bit operations *)        (* bit operations *)
115      | ANDB   of ty * rexp * rexp    (* rtl *)      | ANDB   of ty * rexp * rexp
116      | ORB    of ty * rexp * rexp    (* rtl *)      | ORB    of ty * rexp * rexp
117      | XORB   of ty * rexp * rexp    (* rtl *)      | XORB   of ty * rexp * rexp
118      | NOTB   of ty * rexp              (* rtl *)      | EQVB   of ty * rexp * rexp
119        | NOTB   of ty * rexp
120      | SRA   of ty * rexp * rexp   (* value, shift *) (* rtl *)  
121      | SRL   of ty * rexp * rexp     (* rtl *)      | SRA    of ty * rexp * rexp    (* value, shift *)
122      | SLL   of ty * rexp * rexp     (* rtl *)      | SRL    of ty * rexp * rexp
123        | SLL    of ty * rexp * rexp
124    
125        (* type promotion/conversion *)        (* type promotion/conversion *)
126      | CVTI2I of ty * ext * ty * rexp  (* signed extension *) (* rtl *)      | SX     of ty * ty * rexp  (* toTy, fromTy *)
127      | CVTF2I of ty * rounding_mode * fty * fexp (* rtl *)      | ZX     of ty * ty * rexp  (* toTy, fromTy *)
128        | CVTF2I of ty * rounding_mode * fty * fexp
129    
130        (*        (*
131         * COND(ty,cc,e1,e2):         * COND(ty,cc,e1,e2):
132         * Evaluate into either e1 or e2, depending on cc.         * Evaluate into either e1 or e2, depending on cc.
133         * Both e1 and e2 are allowed to be evaluated eagerly.         * Both e1 and e2 are allowed to be evaluated eagerly.
134         *)         *)
135      | COND of ty * ccexp * rexp * rexp  (* rtl *)      | COND of ty * ccexp * rexp * rexp
136    
137        (* integer load *)        (* integer load *)
138      | LOAD of ty * rexp * Region.region (* rtl *)      | LOAD of ty * rexp * Region.region
139    
140        (* predication *)        (* predication *)
141      | PRED of rexp * ctrl      | PRED of rexp * ctrl
# Line 157  Line 146 
146    
147      | MARK of rexp * an      | MARK of rexp * an
148    
149        | 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
# Line 182  Line 182 
182      | FMARK of fexp * an      | FMARK of fexp * an
183    
184    and ccexp =    and ccexp =
185        CC     of Basis.cond * src                        (* rtl *)        CC     of Basis.cond * src
186      | FCC    of Basis.fcond * src                       (* rtl *)      | FCC    of Basis.fcond * src
187      | TRUE                                              (* rtl *)      | TRUE
188      | FALSE                                             (* rtl *)      | FALSE
189      | NOT    of ccexp                     (* rtl *)      | NOT    of ccexp
190      | AND    of ccexp * ccexp   (* rtl *)      | AND    of ccexp * ccexp
191      | OR     of ccexp * ccexp   (* rtl *)      | OR     of ccexp * ccexp
192      | XOR    of ccexp * ccexp   (* rtl *)      | XOR    of ccexp * ccexp
193      | CMP    of ty * Basis.cond * rexp * rexp(*rtl*)      | EQV    of ccexp * ccexp
194        | CMP    of ty * Basis.cond * rexp * rexp
195      | FCMP   of fty * Basis.fcond * fexp * fexp      | FCMP   of fty * Basis.fcond * fexp * fexp
196      | CCMARK of ccexp * an      | CCMARK of ccexp * an
197      | CCEXT  of ty * ccext      | CCEXT  of ty * ccext
# Line 207  Line 208 
208         and rext   = (stm, rexp, fexp, ccexp) Extension.rx         and rext   = (stm, rexp, fexp, ccexp) Extension.rx
209         and fext   = (stm, rexp, fexp, ccexp) Extension.fx         and fext   = (stm, rexp, fexp, ccexp) Extension.fx
210         and ccext  = (stm, rexp, fexp, ccexp) Extension.ccx         and ccext  = (stm, rexp, fexp, ccexp) Extension.ccx
211           and labexp = rexp
212    
213    (*    (*
214     * Instruction streams     * Instruction streams
215     *)     *)
216    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  
217    
218    (*    (*
219     * Extension mechanism     * Extension mechanism
220     *)     *)
221    
222    datatype ('instr,'regmap,'cellset,'operand,'addressing_mode) reducer =    datatype ('instr,'cellset,'operand,'addressing_mode) reducer =
223      REDUCER of      REDUCER of
224      { reduceRexp    : rexp -> reg,      { reduceRexp    : rexp -> reg,
225        reduceFexp    : fexp -> reg,        reduceFexp    : fexp -> reg,
# Line 228  Line 229 
229        reduceOperand : 'operand -> reg,        reduceOperand : 'operand -> reg,
230        addressOf     : rexp -> 'addressing_mode,        addressOf     : rexp -> 'addressing_mode,
231        emit          : 'instr * an list -> unit,        emit          : 'instr * an list -> unit,
232        instrStream   : ('instr,'regmap,'cellset) stream,        instrStream   : ('instr,'cellset) stream,
233        mltreeStream  : (stm,'regmap,mlrisc list) stream        mltreeStream  : (stm,mlrisc list) stream
234      }      }
235    
236    (*    (*

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

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