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 1181, Wed Mar 27 21:27:27 2002 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
                 structure Stream    : INSTRUCTION_STREAM  
9                  structure Extension : MLTREE_EXTENSION                  structure Extension : MLTREE_EXTENSION
10                 ) : MLTREE =                 ) : MLTREE =
11  struct  struct
12    structure LabelExp = LabelExp    structure Constant = Constant
   structure Constant = LabelExp.Constant  
   structure PseudoOp = Stream.P  
   structure Stream = Stream  
13    structure Region = Region    structure Region = Region
14    structure Basis  = MLTreeBasis    structure Basis  = MLTreeBasis
15    structure Extension = Extension    structure Extension = Extension
16      structure I = MachineInt
17    
18    type ty  = Basis.ty    type ty  = Basis.ty
19    type fty = Basis.fty    type fty = Basis.fty
20    type var = int (* variable *)    type var = CellsBasis.cell (* variable *)
21    type src = var (* source variable *)    type src = var (* source variable *)
22    type dst = var (* destination variable *)    type dst = var (* destination variable *)
23    type reg = var (* physical register *)    type reg = var (* physical register *)
# Line 29  Line 26 
26    datatype cond = datatype Basis.cond    datatype cond = datatype Basis.cond
27    datatype fcond = datatype Basis.fcond    datatype fcond = datatype Basis.fcond
28    datatype rounding_mode = datatype Basis.rounding_mode    datatype rounding_mode = datatype Basis.rounding_mode
29      datatype div_rounding_mode = datatype Basis.div_rounding_mode
30    datatype ext = datatype Basis.ext    datatype ext = datatype Basis.ext
31    
   (* 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 *)  
   
32    (* Statements/effects.  These types are parameterized by the statement    (* Statements/effects.  These types are parameterized by the statement
33     * extension type.  Unfortunately, this has to be made polymorphic to make     * extension type.  Unfortunately, this has to be made polymorphic to make
34     * 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  
35     *)     *)
36    datatype stm =    datatype stm =
37        (* assignment *)        (* assignment *)
38        MV      of ty * dst * rexp   (* rtl *)        MV      of ty * dst * rexp
39      | CCMV    of dst * ccexp      | CCMV    of dst * ccexp
40      | FMV     of fty * dst * fexp      | FMV     of fty * dst * fexp
41    
42        (* parallel copies *)        (* parallel copies *)
43      | COPY    of ty * dst list * src list   (* rtl *)      | COPY    of ty * dst list * src list
44      | FCOPY   of fty * dst list * src list      | FCOPY   of fty * dst list * src list
45    
46        (* control flow *)        (* Control flow *)
47      | JMP     of ctrls * rexp * controlflow (* rtl *)      | JMP     of rexp * controlflow
48      | BCC     of ctrls * ccexp * Label.label      | BCC     of ccexp * Label.label
49      | CALL    of {funct:rexp, targets:controlflow,      | CALL    of {funct:rexp, targets:controlflow,
50                    defs:mlrisc list, uses:mlrisc list,                    defs:mlrisc list, uses:mlrisc list,
51                    cdefs:ctrls, cuses: ctrls, region: Region.region} (* rtl *)                    region: Region.region, pops: Int32.int}
52      | RET     of ctrls * controlflow (* rtl *)      | FLOW_TO of stm * controlflow
53      | JOIN    of ctrls      | RET     of controlflow
54      | IF      of ctrls * ccexp * stm * stm   (* rtl *)      | IF      of ccexp * stm * stm
55    
56        (* memory update: ea, data *)        (* memory update: ea, data *)
57      | STORE  of ty * rexp * rexp * Region.region      | STORE  of ty * rexp * rexp * Region.region
# Line 81  Line 66 
66      | ANNOTATION of stm * an      | ANNOTATION of stm * an
67      | EXT of sext  (* extension *)      | EXT of sext  (* extension *)
68    
69        | LIVE of mlrisc list
70        | KILL of mlrisc list
71    
72        (* RTL operators:        (* RTL operators:
73         * The following are used internally for describing instruction semantics.         * The following are used internally
74           * for describing instruction semantics.
75         * The frontend must not use these.         * The frontend must not use these.
76         *)         *)
77      | PHI    of {preds:int list, block:int}      | PHI    of {preds:int list, block:int}
78      | SOURCE of {block:int, liveIn:reg list}      | ASSIGN of ty * rexp * rexp
79      | SINK   of {block:int, liveOut:reg list}      | SOURCE
80      | RTL    of {hash:word ref, attribs:Basis.attribs, e:stm}      | SINK
81        | RTL    of {hash:word, attribs:Basis.attribs ref, e:stm}
82    
83    and rexp =    and rexp =
84        REG    of ty * reg            (* rtl *)        REG    of ty * reg
85    
86        (* sizes of constants are inferred by context *)        (* sizes of constants are inferred by context *)
87      | LI     of int                 (* rtl *)      | LI     of I.machine_int
88      | LI32   of Word32.word         (* rtl *)      | LABEL  of Label.label
     | LI64   of Word64.word         (* rtl *)  
     | LABEL  of LabelExp.labexp  
89      | CONST  of Constant.const      | CONST  of Constant.const
90        | LABEXP of rexp
91    
92      | NEG    of ty * rexp      | NEG    of ty * rexp
93      | ADD    of ty * rexp * rexp    (* rtl *)      | ADD    of ty * rexp * rexp
94      | SUB    of ty * rexp * rexp    (* rtl *)      | SUB    of ty * rexp * rexp
95    
96        (* signed multiplication etc. *)        (* signed multiplication etc. *)
97      | MULS   of ty * rexp * rexp    (* rtl *)      | MULS   of ty * rexp * rexp
98      | DIVS   of ty * rexp * rexp    (* rtl *)      | DIVS   of div_rounding_mode * ty * rexp * rexp
99      | QUOTS  of ty * rexp * rexp    (* rtl *)      | REMS   of div_rounding_mode * ty * rexp * rexp
     | REMS   of ty * rexp * rexp    (* rtl *)  
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 div_rounding_mode * ty * rexp * rexp
112      | QUOTT  of ty * rexp * rexp    (* rtl *)      | REMT   of div_rounding_mode * ty * rexp * rexp
     | REMT   of ty * rexp * rexp    (* rtl *)  
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
   (*  
    * Instruction streams  
    *)  
   type ('i,'regmap,'cellset) stream =  
        ('i -> unit,'regmap, an list, 'cellset, alias, phi) Stream.stream  
   
   (*  
    * Extension mechanism  
    *)  
   
   datatype ('instr,'regmap,'cellset,'operand,'addressing_mode) reducer =  
     REDUCER of  
     { reduceRexp    : rexp -> reg,  
       reduceFexp    : fexp -> reg,  
       reduceCCexp   : ccexp -> reg,  
       reduceStm     : stm * an list -> unit,  
       operand       : rexp -> 'operand,  
       reduceOperand : 'operand -> reg,  
       addressOf     : rexp -> 'addressing_mode,  
       emit          : 'instr * an list -> unit,  
       instrStream   : ('instr,'regmap,'cellset) stream,  
       mltreeStream  : (stm,'regmap,mlrisc list) stream  
     }  
212    
213    (*    (*
214     * Useful type abbreviations for working for MLTree.     * Useful type abbreviations for working for MLTree.

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

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