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

SCM Repository

[diderot] Diff of /branches/charisee/src/compiler/high-il/filter-ein.sml
ViewVC logotype

Diff of /branches/charisee/src/compiler/high-il/filter-ein.sml

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

revision 2844, Tue Dec 9 18:05:29 2014 UTC revision 2845, Fri Dec 12 06:46:23 2014 UTC
# Line 1  Line 1 
1  (*  (*
2  A collection of Fiter function that are used to organize ein_exps  *A collection of Fiter function that are used to organize ein_exps
3  Some of them are only use by 1 file and could be moved there  *Some of them are only use by 1 file and could be moved there
4  Files include order-ein,normalize-ein,and move_sum  *Files include order-ein,normalize-ein,and move_sum
5  *)  *)
6  structure Filter = struct  structure Filter = struct
   
7      local      local
8    
9      structure E = Ein      structure E = Ein
10      structure P=Printer      structure P=Printer
11      in      in
12    
   
13  fun err str=raise Fail (String.concat["Ill-formed EIN Operator",str])  fun err str=raise Fail (String.concat["Ill-formed EIN Operator",str])
 fun insert (key, value) d =fn s =>  
     if s = key then SOME value  
     else d s  
   
 fun lookup k d = d k  
 val empty =fn key =>NONE  
14    
15    
16  (*******************************************************************************************      (************** Group of functions that rewrites ein_exp********)
 * Group of functions that rewrites ein_exp  
 *)  
17  (* mkAdd:ein_exp list->int* ein_exp  (* mkAdd:ein_exp list->int* ein_exp
18  *Flattens Add constructor: change, expression  *Flattens Add constructor: change, expression
19  *)  *)
# Line 52  Line 42 
42  fun mkProd [e]=(1,e)  fun mkProd [e]=(1,e)
43      | mkProd(e)=let      | mkProd(e)=let
44      fun flatten(i,((E.Prod l)::l'))= flatten(1,l@l')      fun flatten(i,((E.Prod l)::l'))= flatten(1,l@l')
45          |flatten(i,((E.Const c)::l'))=            | flatten(i,((E.Const 0)::l'))=(3,[E.Const 0])
46                  if(c>0 orelse  0>c) then (3,[E.Const 0])            | flatten(i,((E.Const 1)::l'))=flatten(1,l')
                 else flatten(i,l')  
47           | flatten(i,[])=(i,[])           | flatten(i,[])=(i,[])
48           | flatten (i,e::l') =  let val(a,b)=flatten(i,l') in (a,[e]@b) end           | flatten (i,e::l') =  let val(a,b)=flatten(i,l') in (a,[e]@b) end
49       val (change,a)=flatten(0,e)       val (change,a)=flatten(0,e)
# Line 66  Line 55 
55              (* end case *)              (* end case *)
56      end      end
57    
58    
59  (*rewriteProd: ein_exp list -> ein_exp  (*rewriteProd: ein_exp list -> ein_exp
60  * rewrite. Prod A  * rewrite. Prod A
61  *used by move_sum.sml  *used by move_sum.sml
# Line 74  Line 64 
64      of [A]=> A      of [A]=> A
65      | A => E.Prod A      | A => E.Prod A
66  (*end case*))  (*end case*))
67    (*
68        fun mkProd e=let
69            fun flatten([],[])=(1,E.Const 1)
70              | flatten([],rest)=(0,rewriteProd rest)
71              | flatten((E.Const 0)::es,_)=(1,E.Const 0)
72              | flatten((E.Const 1)::es,rest)=flatten(es, rest)
73              | flatten((E.Prod p)::es,rest)=flatten(p@es,E.Prod rest)
74              | flatten(e1::es,rest)=flatten(es,rest@[e1])
75            in
76                flatten(e,[])
77            end
78    *)
79  (*rewriteSum:sum_indexid list* ein_exp list -> ein_exp  (*rewriteSum:sum_indexid list* ein_exp list -> ein_exp
80  * rewrite. Sum(c,Prod p))  * rewrite. Sum(c,Prod p))
81  *used by move_sum.sml  *used by move_sum.sml
# Line 117  Line 118 
118    
119  (*filterField:ein_exp list->ein_exp list * ein_exp list  (*filterField:ein_exp list->ein_exp list * ein_exp list
120  * Note Lift indicates a Tensor  * Note Lift indicates a Tensor
121  So expression is either Lift, del, eps, or contains a Field      * So expression is either Lift, del, eps, or contains a Field
122  *used by order-ein.sml  *used by order-ein.sml
123  *)  *)
124  fun filterField e= let  fun filterField e= let

Legend:
Removed from v.2844  
changed lines
  Added in v.2845

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