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

SCM Repository

[diderot] Annotation of /branches/charisee_dev/src/compiler/high-to-mid/handleEin.sml
ViewVC logotype

Annotation of /branches/charisee_dev/src/compiler/high-to-mid/handleEin.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3678 - (view) (download)

1 : cchiw 2845 (* Expands probe ein
2 :     *
3 : jhr 3349 * This code is part of the Diderot Project (http://diderot-language.cs.uchicago.edu)
4 :     *
5 :     * COPYRIGHT (c) 2015 The University of Chicago
6 : cchiw 2845 * All rights reserved.
7 :     *)
8 :    
9 :     structure handleEin = struct
10 :    
11 :     local
12 :    
13 :     structure E = Ein
14 :     structure DstIL = MidIL
15 :     structure P=Printer
16 :     structure MidToS=MidToString
17 : cchiw 3459 structure L=LiftEin
18 : cchiw 2845 in
19 :    
20 : cchiw 3678
21 :     val sumflag = true
22 :     val probeflag = true
23 :     val floatflag = true
24 :     val liftflag = false
25 :     val splitflag = false
26 :     val limit = NONE
27 :    
28 : cchiw 3503 val testinitial=0
29 : cchiw 3259 val testing=0
30 : cchiw 2845 fun testp n=(case testing
31 :     of 0=> 1
32 :     | _ =>(print(String.concat n);1)
33 :     (*end case*))
34 : cchiw 3166 fun test0 n=(case testinitial
35 : cchiw 3203 of 0=>testp n
36 : cchiw 3166 | _ => (print(String.concat n);1))
37 : cchiw 3324 fun toStringBind e= MidToS.toStringBind e
38 : cchiw 3271 fun useCount (HighIL.V{useCnt, ...}) = !useCnt
39 :     fun expandEinOp (srcy,bind00)=let
40 : cchiw 3540 (*val _= raise Fail"development branch- do not use"*)
41 : cchiw 3489
42 : cchiw 3033 val star="************"
43 : cchiw 3415 val _= ("\n Start"^star)
44 : cchiw 3260 val _ =test0[star,"\n Original EinApp",star,"\n\n","start get test",toStringBind bind00]
45 : cchiw 3203 val (y,einapp as DstIL.EINAPP(Ein.EIN{params, index, body},args))=bind00
46 : cchiw 3166
47 : cchiw 3033
48 :     (* ************* Sweep for 0's'*********** *)
49 : cchiw 3678 val bodysweep = sweepEin.sweep body
50 :     val ein = Ein.EIN{params=params, index=index, body=bodysweep}
51 : cchiw 3033
52 :    
53 : cchiw 3678 (* ************** distribute and push Summation*********** *)
54 :     val bind3 = case sumflag
55 :     of false => (y,DstIL.EINAPP( ein,args))
56 :     | _ => (y,DstIL.EINAPP(SummationEin.main ein,args))
57 : cchiw 3677
58 : cchiw 3472 (* **************** lift - split ************* *)
59 : cchiw 3678 val newbies5= (case (floatflag,liftflag,splitflag,limit)
60 :     of (true,_,_,_) (*Float*)
61 :     => List.map (fn MidIL.ASSGN(i)=> i ) (FloatEin.transform bind3)
62 :     | (false,true,_,_) => let
63 :     val (einapp1,e2,_)=L.testLift bind3
64 :     in (e2@[einapp1]) end (*LIFT*)
65 :     | (false,false,true,NONE) => Split.splitEinApp bind3 (*SPLIT*)
66 : cchiw 3472 (* **************** split phase ************* *)
67 : cchiw 3678 | (false,false,true, SOME limit) => Split.limitSplit(bind3,limit)
68 :     (* end case *))
69 : cchiw 3503
70 : cchiw 3166 (* ************** ProbeEIN *********** *)
71 : cchiw 3189 (*gives probeEIN the set. Could split into a sepearate step*)
72 : cchiw 3503 val fieldset= einVarSet.EinVarSet.empty
73 :     val varset= einVarSet.VarSet.empty
74 : cchiw 3271 val isField = ref 0
75 :     val isFieldR = ref 0
76 :     val isReplaced = ref 0
77 : cchiw 3503 fun iter([],_,_)=[]
78 :     | iter(e1::es,fieldset,varset)= let
79 :     val (e2,fieldset,varset,isFieldt,isReplacedt) = ProbeEin.expandEinOp(e1,fieldset,varset)
80 :     val rtn=[e2]@(iter(es,fieldset,varset))
81 : cchiw 3271 val isFieldRt=if ((isFieldt+isReplacedt)=2) then 1 else 0
82 :     in (isField:=(!isField)+isFieldt;isReplaced:=(!isReplaced )+isReplacedt;
83 :     isFieldR:=(!isFieldR)+isFieldRt;rtn)
84 :     end
85 :    
86 : cchiw 3678 val flatcode = (case probeflag
87 :     of true => List.foldr op@ [] (iter(newbies5, fieldset,varset))
88 :     | _ => newbies5)
89 : cchiw 3503
90 : cchiw 3033 in
91 :     List.map (fn (y,rator)=> DstIL.ASSGN(y,rator)) flatcode
92 :     end
93 :    
94 : cchiw 2845 end; (* local *)
95 :    
96 :     end (* local *)

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