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/move-sums.sml
ViewVC logotype

Diff of /branches/charisee/src/compiler/high-il/move-sums.sml

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

revision 2837, Wed Nov 19 23:42:17 2014 UTC revision 2838, Tue Nov 25 03:40:24 2014 UTC
# Line 17  Line 17 
17    
18      fun rewriteSum(c,p)= E.Sum(c, rewriteProd p)      fun rewriteSum(c,p)= E.Sum(c, rewriteProd p)
19    
20    
21      fun embed(A, c1, B, c2, C)=let      fun embed(A, c1, B, c2, C)=let
22          val C'=rewriteSum(c2,C)          val C'=rewriteSum(c2,C)
23          in (A, c1,B@[C'])          in (A, c1,B@[C'])
24          end          end
25    
26        fun rewriteProdSum(pre,_,[])=rewriteProd pre
27        | rewriteProdSum(pre,outer,post)=rewriteProd(pre@[rewriteSum(outer,post)])
28    
29    
30      (* return pre, outer Sum, post*)      (* return pre, outer Sum, post*)
31      fun splitMultipleSum(c1,c2,pre,post)=(case (pre,post)      fun splitMultipleSum(c1,c2,pre,post)=(case (pre,post)
# Line 47  Line 51 
51          val c2=List.hd(sx')          val c2=List.hd(sx')
52          val (A,B)=F.splitSum(c2,e)          val (A,B)=F.splitSum(c2,e)
53    
54          fun double([], outer, pre, post)=  rewriteProd(pre@[rewriteSum(outer,post)])          fun double([], outer, pre, post)=  rewriteProdSum(pre,outer,post)
55          | double(c1::cs, outer, pre, post)= let          | double(c1::cs, outer, pre, post)= let
56              val (pre',outer', post')=splitMultipleSum(c1,outer,pre,post)              val (pre',outer', post')=splitMultipleSum(c1,outer,pre,post)
57              in double(cs, outer',pre',post')              in double(cs, outer',pre',post')
# Line 76  Line 80 
80          | E.Apply(e1,e2)  => E.Apply(rewriteBody e1, rewriteBody e2)          | E.Apply(e1,e2)  => E.Apply(rewriteBody e1, rewriteBody e2)
81          | E.Probe(e1,e2)  => E.Probe(e1, rewriteBody e2)          | E.Probe(e1,e2)  => E.Probe(e1, rewriteBody e2)
82          | E.Lift e        => E.Lift(rewriteBody e)          | E.Lift e        => E.Lift(rewriteBody e)
83            | E.Sum (sx,E.Prod[e])         => shiftSum(sx,[e])
84          | E.Sum(sx,E.Prod e)   => shiftSum(sx,e)          | E.Sum(sx,E.Prod e)   => shiftSum(sx,e)
85          | E.Sum (sx,e)         => shiftSum(sx,[e])          | E.Sum (sx,e)         => shiftSum(sx,[e])
86          (* end case *))          (* end case *))

Legend:
Removed from v.2837  
changed lines
  Added in v.2838

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