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 3327 - (view) (download)

1 : cchiw 2845 (* Expands probe ein
2 :     *
3 :     * COPYRIGHT (c) 2012 The Diderot Project (http://diderot-language.cs.uchicago.edu)
4 :     * All rights reserved.
5 :     *)
6 :    
7 :     structure handleEin = struct
8 :    
9 :     local
10 :    
11 :     structure E = Ein
12 :     structure DstIL = MidIL
13 :     structure P=Printer
14 :     structure MidToS=MidToString
15 : cchiw 3325 structure L=LiftEin
16 : cchiw 2845 in
17 :    
18 : cchiw 3304 val testinitial=0
19 : cchiw 3259 val testing=0
20 : cchiw 2845 fun testp n=(case testing
21 :     of 0=> 1
22 :     | _ =>(print(String.concat n);1)
23 :     (*end case*))
24 : cchiw 3166 fun test0 n=(case testinitial
25 : cchiw 3203 of 0=>testp n
26 : cchiw 3166 | _ => (print(String.concat n);1))
27 : cchiw 3324 fun toStringBind e= MidToS.toStringBind e
28 : cchiw 3271 fun useCount (HighIL.V{useCnt, ...}) = !useCnt
29 :     fun expandEinOp (srcy,bind00)=let
30 : cchiw 3324
31 : cchiw 3033 val star="************"
32 : cchiw 3325 val _=print("\n Start"^star)
33 : cchiw 3260 val _ =test0[star,"\n Original EinApp",star,"\n\n","start get test",toStringBind bind00]
34 : cchiw 3203 val (y,einapp as DstIL.EINAPP(Ein.EIN{params, index, body},args))=bind00
35 : cchiw 3166
36 : cchiw 3033
37 :     (* ************* Sweep for 0's'*********** *)
38 : cchiw 3203 val bodysweep=sweepEin.sweep body
39 : cchiw 3033 val ein1=Ein.EIN{params=params, index=index, body=bodysweep}
40 : cchiw 3203 val _=testp["Post Sweep\n",P.printbody bodysweep,"\n"]
41 : cchiw 3033
42 :    
43 : cchiw 3203 (* ************** distribute and push Summation*********** *)
44 :     val bind3 = (y,DstIL.EINAPP(SummationEin.main ein1,args))
45 : cchiw 3260 val _ =testp["\n\n summation \n\n =>", toStringBind bind3]
46 : cchiw 3033
47 : cchiw 3325
48 : cchiw 3166 (* **************** split phase ************* *)
49 : cchiw 3327 val (newbies5)= Split.splitEinApp bind3
50 : cchiw 3276 val _ =test0["\n\n Returning \n\n =>",
51 : cchiw 3260 String.concatWith",\n\t"(List.map toStringBind newbies5)]
52 : cchiw 3327
53 : cchiw 3325 (* **************** lift field phase ************* *)
54 : cchiw 3327 (* val newbies5 = L.testLift bind3
55 : cchiw 3325 *)
56 : cchiw 3166 (* ************** ProbeEIN *********** *)
57 : cchiw 3189 (*gives probeEIN the set. Could split into a sepearate step*)
58 : cchiw 3174 val fieldset= einSet.EinSet.empty
59 : cchiw 3271 val isField = ref 0
60 :     val isFieldR = ref 0
61 :     val isReplaced = ref 0
62 : cchiw 3174 fun iter([],_)=[]
63 :     | iter(e1::es,fieldset)= let
64 : cchiw 3271 val (e2,fieldset,isFieldt,isReplacedt) = ProbeEin.expandEinOp(e1,fieldset)
65 :     val rtn=[e2]@(iter(es,fieldset))
66 :     val isFieldRt=if ((isFieldt+isReplacedt)=2) then 1 else 0
67 :     in (isField:=(!isField)+isFieldt;isReplaced:=(!isReplaced )+isReplacedt;
68 :     isFieldR:=(!isFieldR)+isFieldRt;rtn)
69 :     end
70 : cchiw 3174 val code=iter(newbies5, fieldset)
71 : cchiw 3271
72 :     val n= List.length(code)
73 :    
74 :     val _ = if (n>5)
75 : cchiw 3276 then (String.concat["\n\n",star,":Name:",HighIL.Var.name srcy ,
76 : cchiw 3271 ":VarCount(",Int.toString(useCount srcy),")",
77 :     "\n\t",star,"Pieces now: ",Int.toString (n),
78 :     " Fields:",Int.toString(!isField)," isReplaced:",Int.toString(!isReplaced),
79 :     " Replaced_Fields:",Int.toString(!isFieldR)
80 :     ,toStringBind bind3])
81 : cchiw 3276 else ""
82 : cchiw 3271
83 : cchiw 3033 val flatcode= List.foldr op@ [] code
84 : cchiw 3048 (*val _=List.map (fn(_,DstIL.EINAPP(e,_))=>checkEin.checkEIN e | _=> 1) flatcode*)
85 : cchiw 3325 val _=print(star^"end")
86 : cchiw 3033 in
87 :     List.map (fn (y,rator)=> DstIL.ASSGN(y,rator)) flatcode
88 :     end
89 :    
90 : cchiw 2845 end; (* local *)
91 :    
92 :     end (* local *)

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