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

SCM Repository

[diderot] Diff of /branches/vis15/src/compiler/high-opt/eps-util.sml
ViewVC logotype

Diff of /branches/vis15/src/compiler/high-opt/eps-util.sml

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

revision 3977, Wed Jun 15 19:06:30 2016 UTC revision 3978, Wed Jun 15 19:07:40 2016 UTC
# Line 17  Line 17 
17      val reduceDelta : Ein.ein_exp list * Ein.ein_exp list * Ein.ein_exp list      val reduceDelta : Ein.ein_exp list * Ein.ein_exp list * Ein.ein_exp list
18            -> bool * Ein.ein_exp            -> bool * Ein.ein_exp
19    
20      val matchEps : Ein.mu list * Ein.index_id list -> bool      val matchEps : Ein.index_id list * Ein.mu list -> bool
21    
22    end = struct    end = struct
23    
# Line 33  Line 33 
33                  if (s=u andalso t=v) orelse (s=v andalso t=u)                  if (s=u andalso t=v) orelse (s=v andalso t=u)
34                    then NONE                    then NONE
35                    else let                    else let
36                      val d1 = [E.Delta(E.V s, E.V u), E.Delta(E.V t, E.V v)]                      val d1 = [E.Delta(s, u), E.Delta(t, v)]
37                      val d2 = [E.Delta(E.V s, E.V v), E.Delta(E.V t, E.V u)]                      val d2 = [E.Delta(s, v), E.Delta(t, u)]
38                      in                      in
39                        SOME(d1, d2)                        SOME(d1, d2)
40                      end                      end
# Line 124  Line 124 
124            fun appDel (changed, [], beta, mu, nu) = (changed, beta, mu@nu)            fun appDel (changed, [], beta, mu, nu) = (changed, beta, mu@nu)
125              | appDel (changed, a::alpha, beta, [], nu) = appDel(changed, alpha, beta@[a], nu, [])              | appDel (changed, a::alpha, beta, [], nu) = appDel(changed, alpha, beta@[a], nu, [])
126              | appDel (changed, a::alpha, beta, E.Delta(i, j)::mu, nu) =              | appDel (changed, a::alpha, beta, E.Delta(i, j)::mu, nu) =
127                  if (a = j)                  if (a = E.V j)
128                    then appDel(true, alpha, beta@[i], mu, nu)                    then appDel(true, alpha, beta@[E.V i], mu, nu)
129                    else appDel(changed, a::alpha, beta, mu, nu@[E.Delta(i, j)])                    else appDel(changed, a::alpha, beta, mu, nu@[E.Delta(i, j)])
130          (* *)          (* *)
131  (* FIXME: instead of appending singletons, build results in reverse order! *)  (* FIXME: instead of appending singletons, build results in reverse order! *)
# Line 165  Line 165 
165              distribute (false, es, [], dels)              distribute (false, es, [], dels)
166            end            end
167    
168      (*matchEps:int*mu list *mu list  * index_id list->int      (* matchEps: checks if two indices in 'ids' matches two indices in 'mus' *)
169      *looks to see if two indices in delta(px) matches 2 in epsilon ids      fun matchEps (ids, mus) = let
170      *if so returns 1 so the ein_exp becomes 0          fun match (_, _, 2) = true
171      *)          | match ([], _, _) = false
172  (* FIXME: rewrite once we understand what this is supposed to be doing *)          | match (_, [], _) = false
173      fun matchEps (mus, epsx) = let          | match (id::ids, mus, cnt) = let
174            fun match (2, _, _, _) = true (* matched two *)              (* check to see if 'id' is in 'rest' and update count and rest*)
175              | match (_, _, _, []) = false              (* remove mention of id from list*)
176              | match (0, _, _, [_]) = false              val mus = List.filter (fn (E.C _) => false |(E.V x) => ((x>id) orelse (id>x))) mus
177              | match (num, [], rest, eps::epsx) = match (num, rest, [], epsx)              (* did we find ids*)
178              | match (num, E.V p :: px, rest, eps::epsx) =              val cnt' = if (cnt = length(mus)) then cnt else cnt+1
                 if (p = eps)  
                   then match (num+1, rest@px, [], epsx)  
                   else match (num, px, rest@[E.V p], eps::epsx)  
             | match (num, p::px, rest, eps) = match (num, px, rest, eps)  
179            in            in
180              match (0, mus, [], epsx)                  match(ids, mus, cnt')
181            end            end
182            in match(ids, mus, 0) end
183    
184    end    end

Legend:
Removed from v.3977  
changed lines
  Added in v.3978

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