Home My Page Projects Code Snippets Project Openings diderot
Summary Activity Tracker Tasks SCM

SCM Repository

[diderot] Diff of /trunk/src/compiler/IL/ssa-fn.sml
ViewVC logotype

Diff of /trunk/src/compiler/IL/ssa-fn.sml

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 186, Thu Jul 29 04:26:57 2010 UTC revision 187, Thu Jul 29 14:00:37 2010 UTC
# Line 22  Line 22 
22     * a single continuation.     * a single continuation.
23     *)     *)
24      datatype stmt      datatype stmt
25        = BLOCK of stmt        = EXIT
26        | SEQ of stmt list        | SEQ of block * stmt
27        | IF of {        | IF of {
28            pre : stmt,            pre : stmt,
29            cond : var,            cond : var,
30            trueBranch : stmt            trueBranch : stmt,
31            falseBranch : stmt            falseBranch : stmt
32          }          }
33        | WHILE of {        | WHILE of {
34            hdr : block,            hdr : stmt,
35            cond : var,            cond : var,
36            body : stmt            body : stmt
37          }          }
# Line 60  Line 60 
60      val newVar : string -> var      val newVar : string -> var
61      val newBlock : unit -> block      val newBlock : unit -> block
62    
63    (*
64      val entryBlock : stmt -> block      val entryBlock : stmt -> block
65      val nextBlock : stmt -> block      val nextBlock : stmt -> block
66    *)
67    
68    end    end
69    
70  functor SSAFn (Op : OPERATORS) : SSA =  functor SSAFn (Op : OPERATORS) : SSA =
71    struct    struct
72    
73        structure Op = Op
74    
75      datatype var = V of {      datatype var = V of {
76          name : string,                  (* name *)          name : string,                  (* name *)
77          id : Stamp.stamp,               (* unique ID *)          id : Stamp.stamp,               (* unique ID *)
# Line 82  Line 86 
86          pre : stmt,          pre : stmt,
87          cond : var,          cond : var,
88          trueBranch : stmt,          trueBranch : stmt,
89          falseBranch : stmt,            falseBranch : stmt
         next : stmt             (* ?? *)  
90        }        }
91      | WHILE of {      | WHILE of {
92          hdr : stmt,          hdr : stmt,
93          cond : var,          cond : var,
94          body : stmt,            body : stmt
         exit : stmt             (* ?? *)  
95        }        }
96    
97    and block = BLK of {    and block = BLK of {
# Line 109  Line 111 
111    
112      and rhs      and rhs
113        = VAR of var        = VAR of var
114          | LIT of Literal.literal
115        | OP of Op.rator * var list        | OP of Op.rator * var list
116          | CONS of var list                (* tensor-value construction *)
117    
118    (* block properties *)    (* block properties *)
119      fun parentOf (BLK{parent, ...}) = !parent      fun parentOf (BLK{parent, ...}) = !parent
# Line 125  Line 129 
129            }            }
130    
131      fun newBlock () = BLK{      fun newBlock () = BLK{
132              parent = ref(SEQ[]),              parent = ref(EXIT),
133              id = Stamp.new(),              id = Stamp.new(),
134              preds = ref[],              preds = ref[],
135              phi = ref[],              phi = ref[],
136              body = ref[],              body = ref[],
137              succs = ref[]              succs = ref[]
138            }            }
139    (*
140      local      local
141        fun setParent (BKL{parent, ...}, s) = (parent := s)        fun setParent (BLK{parent, ...}, s) = (parent := s)
     in  
     fun mkBLOCK blk = let  
           val s = BLOCK blk  
142            in            in
             setParent (blk, s);  
             s  
           end  
143    
144      fun mkIF (pre, cond, t, f) = let      fun mkIF (pre, cond, t, f) = let
145            val s = IF{pre=pre, cond=cond, trueBranch=t, falseBranch=f}            val s = IF{pre=pre, cond=cond, trueBranch=t, falseBranch=f}
# Line 158  Line 156 
156            end            end
157    
158      end (* local *)      end (* local *)
159    *)
160    
161    (*
162      fun entryBlock (BLOCK blk) = blk      fun entryBlock (BLOCK blk) = blk
163        | entryBlock (SEQ(s1::_)) = entryBlock s1        | entryBlock (SEQ(s1::_)) = entryBlock s1
164        | entryBlock (IF{pre, ...}) = entryBlock pre        | entryBlock (IF{pre, ...}) = entryBlock pre
165        | entryBlock (WHILE{hdr, ...}) = entryBlock hdr        | entryBlock (WHILE{hdr, ...}) = entryBlock hdr
166    
167      fun nextBlock (SEQ(, next)) = nextBlock next      fun nextBlock (BLOCK(_, next)) = nextBlock next
168        | nextBlock (SEQ stms) = nextBlock(List.last stms)        | nextBlock (SEQ stms) = nextBlock(List.last stms)
169        | nextBlock (IF{pre, ...}) = entryBlock pre        | nextBlock (IF{pre, ...}) = entryBlock pre
170        | nextBlock (WHILE{hdr, ...}) = entryBlock hdr        | nextBlock (WHILE{hdr, ...}) = entryBlock hdr
171    *)
172    
173    end    end

Legend:
Removed from v.186  
changed lines
  Added in v.187

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