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

SCM Repository

[diderot] Diff of /branches/charisee/src/compiler/tree-il/expandOp.sml
ViewVC logotype

Diff of /branches/charisee/src/compiler/tree-il/expandOp.sml

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

revision 2627, Sat May 17 00:44:22 2014 UTC revision 2628, Wed May 21 04:02:06 2014 UTC
# Line 7  Line 7 
7      structure SrcTy = LowILTypes      structure SrcTy = LowILTypes
8      structure DstTy = TreeILTypes      structure DstTy = TreeILTypes
9      structure T = TreeIL      structure T = TreeIL
10        structure P= TreeILPP
11        structure Var = T.Var
12  in  in
13    
14        val testing=0
15    
16      (*val t=T.Var.new("x1" ,T.VK_Local,ty)*)      fun q m=Int.toString(m)
17    
18      (*use next largest vector size*)      fun toStringEx(T.E_LoadVec(tyNew, tyOrig,offset,arg))=
19      fun creatFl(lhs,rator,n,vn,[a,b])= let          String.concat["LDVec:", q tyNew ,"|",q  tyOrig,Int.toString(offset),"(",toStringEx arg,")"]
20          val newTy=DstTy.NativeVecTy vn        | toStringEx(T.E_mkVec(tyNew, tyOrig,pieces,args)) =let
21          val origTy=DstTy.NativeVecTy n          val a=String.concatWith "," (List.map toStringEx args)
         val A=T.E_LoadVec(newTy,origTy,0,a)  
         val B=T.E_LoadVec(newTy,origTy,0,b)  
         val C=T.E_Op(rator vn,[A,B])  
         val tyInd=DstTy.vectorLength [vn]  
         val D=T.E_mkVec(newTy,origTy,tyInd,[C])  
22          in          in
23              [T.S_Assign([lhs],D)]                  String.concat["mkVec:",q tyNew,"|",
24                    q tyOrig,"[", DstTy.toString pieces ,"]\n\t",a]
25          end          end
26          | toStringEx(T.E_Op(rator, args)) =
27            String.concat[DstOp.toString rator,"(", String.concatWith"," (List.map toStringEx args),")"]
28          | toStringEx(T.E_Cons(ty, args)) =
29            String.concat ["Cons:", DstTy.toString ty, "(",String.concatWith"," (List.map toStringEx args),")"]
30          | toStringEx(T.E_State x) = "State"
31          | toStringEx (T.E_Var x) = Var.name x
32          | toStringEx (T.E_Lit lit) = Literal.toString lit
33    
34      (*Load vectors*)  
35      fun creatLd(lhs,rator,n,n',[a,b])= let  
36          fun createOps([],_, shape,code)=(shape,code)  
37            | createOps(vn::es,offset,shape, code)=let      (*Low-IL vector operators to Tree-IL Assignmentss*)
38              val vnTy=DstTy.NativeVecTy vn      fun creatLd(lhs,rator,n,origLength,pieces,args)= let
39              val A=T.E_LoadVec(vnTy,vnTy,offset,a)          val newTy=n
40              val B=T.E_LoadVec(vnTy,vnTy,offset,b)          val origTy= origLength
41              val C=T.E_Op(rator vn,[A,B])          val splitTy=DstTy.vectorLength pieces
42    
43            fun createOps([],_,code)=code
44              | createOps(vn::es,offset, code)=let
45                val vnTy= vn
46                val args'=List.map (fn A=>T.E_LoadVec(vnTy,origTy,offset,A)) args
47                val exp=T.E_Op(rator vn,args')
48              in              in
49                  createOps (es,offset+vn,shape@[vn],code@[C])                  createOps (es,offset+vn,code@[exp])
50              end              end
51          val (shape,code)=createOps(n',0,[],[])          val code=createOps(pieces,0,[])
52          val tyInd=DstTy.vectorLength shape          val exp=T.E_mkVec(newTy,origTy,splitTy,code)
53          val newTy=DstTy.NativeVecTy n          val _=(case testing
54          val D=T.E_mkVec(newTy,newTy,tyInd,code)              of 1=>(print((toStringEx exp)^"\n\n");1)
55                |_ =>1)
56          in          in
57              [T.S_Assign([lhs],D)]              [T.S_Assign([lhs],exp)]
58          end          end
59    
60    
61        (*Convert Types*)
62        (*fun cvtTy SrcTy.BoolTy = DstTy.BoolTy
63          | cvtTy SrcTy.StringTy = DstTy.StringTy
64          | cvtTy SrcTy.IntTy = DstTy.intTy
65          | cvtTy (SrcTy.TensorTy dd) = DstTy.tensorTy dd
66          | cvtTy (SrcTy.TupleTy tys) = DstTy.TupleTy(List.map cvtTy tys)
67          | cvtTy (SrcTy.SeqTy(ty, n)) = DstTy.SeqTy(cvtTy ty, n)
68          | cvtTy (SrcTy.AddrTy v) = DstTy.AddrTy v
69          | cvtTy (SrcTy.ImageTy  v) = DstTy.ImageTy v
70          | cvtTy SrcTy.KernelTy = DstTy.KernelTy
71          | cvtTy (SrcTy.indexTy indexAt) = DstTy.indexTy indexAt
72          | cvtTy (SrcTy.imgIndex indexAt) = DstTy.imgIndex indexAt
73          | cvtTy (SrcTy.vectorLength pieces) = DstTy.vectorLength pieces
74    
75    
76    *)
77    
78    
79        (*Low-IL operators to Tree-IL operators*)
80      fun expandOp rator=(case rator      fun expandOp rator=(case rator
81          of SrcOp.IAdd  =>    DstOp.IAdd          of SrcOp.IAdd  =>    DstOp.IAdd
82          | SrcOp.ISub  =>    DstOp.ISub          | SrcOp.ISub  =>    DstOp.ISub

Legend:
Removed from v.2627  
changed lines
  Added in v.2628

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