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/lowOp-to-treeOp.sml
ViewVC logotype

Diff of /branches/charisee/src/compiler/tree-il/lowOp-to-treeOp.sml

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

revision 2690, Fri Aug 29 15:41:22 2014 UTC revision 2691, Fri Sep 5 01:59:12 2014 UTC
# Line 4  Line 4 
4  local  local
5    
6      structure SrcOp = LowOps      structure SrcOp = LowOps
     structure DstOp = TreeOps  
7      structure SrcTy = LowILTypes      structure SrcTy = LowILTypes
8        structure DstOp = TreeOps
9      structure DstTy = TreeILTypes      structure DstTy = TreeILTypes
10      structure Dst = TreeIL      structure Dst = TreeIL
11      structure VTree = TreeIL.Var      structure DstV = Dst.Var
     structure VLow = LowIL.Var  
         structure VTree = TreeIL.Var  
12      structure Ty=TreeIL.Ty      structure Ty=TreeIL.Ty
13    
14    
   
15  in  in
16    
17      val testing=1      val testing=1
# Line 23  Line 20 
20           |_ =>1           |_ =>1
21      (*end case*))      (*end case*))
22    
23        (**************************************)
24        (*assignment, store-statement, and store-expression*)
25    
26  (*      fun mkStmt(lhsExp,lhsKind,rator,nSize,oSize,pieces,isFill,A,splitTy,ops,indexAt)= (case (rator nSize)
27  assumes that if it is a local then it is a vector.          of DstOp.sumVec _ => (SOME( addSca ops),NONE)
28  not always true          | DstOp.dotVec _  => (SOME( addSca ops),NONE)
29  maybe just check size          | _               => (case lhsKind
30                of TreeIL.VK_Local =>(SOME (Dst.E_Mux(A,nSize,oSize,splitTy,ops)),NONE)
31                | _=> (NONE,SOME(Dst.S_StoreVec(lhsExp,A,nSize,oSize,splitTy,ops)))
32                (*end case*))
33            (*end case*))
34        and addSca [e1]=e1
35        | addSca(e1::e2::es)= addSca([Dst.E_Op(DstOp.addSca,[e1,e2])]@es)
36    
 *)  
37          (**************************************)          (**************************************)
38      (*creates a load when it is not a local variable *)      (*creates a load when it is not a local variable *)
39      fun  getArg(t,count,aligned, nSize, oSize,offset)=let      fun getArg(lhsKind,t,count,aligned, nSize, oSize,offset)=let
40          fun getExp (Dst.E_Var a) =(case ( VTree.kind a,VTree.ty a)          fun getExp (Dst.E_Var a) =(case ( DstV.kind a,DstV.ty a)
41              of (TreeIL.VK_Local,Ty.TensorTy [nv]) =>              of (TreeIL.VK_Local,Ty.TensorTy [nv]) =>
42                  if (nv=nSize) then t                  if (nv=nSize) then (print "same size";t)
43                  else  Dst.E_LoadArr(aligned, nSize, oSize,t, Dst.E_Lit(Literal.Int offset))                  else  (print "not the same size";Dst.E_LoadVec(aligned, nSize, oSize,t, Dst.E_Lit(Literal.Int offset)))
44              |(TreeIL.VK_Local,_) =>t              | (TreeIL.VK_Local,_) =>(print "not vector";t)
45              | (_,_) =>  Dst.E_LoadArr(aligned, nSize,oSize,t, Dst.E_Lit(Literal.Int offset))              | (_,_) =>  (print "not a local var ";Dst.E_LoadArr(aligned, nSize,oSize,t, Dst.E_Lit(Literal.Int offset)))
46              (*end case*))              (*end case*))
47          | getExp (Dst.E_Mux(_,_,_,_,ops))= List.nth(ops,count)          | getExp (Dst.E_Mux(_,_,_,_,ops))= List.nth(ops,count)
48          | getExp _ = t          | getExp _ = t
   
49          val exp =getExp t          val exp =getExp t
50          val _ =testp ["\n\t Arg",Dst.toString t, "====>>",Dst.toString exp]          val _ =testp ["\n\t Arg",Dst.toString t, "====>>",Dst.toString exp]
51          in          in
52              exp              exp
53          end          end
54          (**************************************)      and mkOps(lhsKind,rator,oSize,pieces,argScas,argVecs,aligned,indexAt)= let
   
     fun getLHS(lhs,cnt,A,nSize,oSize,indexAt,splitTy,ops) =(case VTree.kind lhs  
         of TreeIL.VK_Local =>(SOME (Dst.E_Mux(A,nSize,oSize,splitTy,ops)),NONE)  
         | _=> (NONE,SOME(Dst.S_StoreVec(Dst.E_Var lhs,A,nSize,oSize,splitTy,ops)))  
     (*end case*))  
   
   
     (**************************************)  
     (*Create Op and Ld expressions*)  
   
     fun mkOps(rator,oSize,pieces,argScas,argVecs,aligned,indexAt)= let  
55          fun createOps ([], _,_, code) = code          fun createOps ([], _,_, code) = code
56            | createOps (nSize::es, count,offset, code)=let            | createOps (nSize::es, count,offset, code)=let
57              val argsLd =List.map (fn a =>getArg(a,count, aligned, nSize, oSize, offset))  argVecs              val argsLd =List.map (fn a =>getArg(lhsKind,a,count, aligned, nSize, oSize, offset))  argVecs
58              val exp = Dst.E_Op(rator nSize, argScas@argsLd)              val exp = Dst.E_Op(rator nSize, argScas@argsLd)
59              in              in
60                  createOps (es, count+1,offset + IntInf.fromInt nSize, code@[exp])                  createOps (es, count+1,offset + IntInf.fromInt nSize, code@[exp])
# Line 72  Line 64 
64      end      end
65    
66    
     (**************************************)  
   
   
     (*addSca function used for sumVec function *)  
     fun addSca [e1]=e1  
       | addSca(e1::e2::es)= addSca([Dst.E_Op(DstOp.addSca,[e1,e2])]@es)  
   
   
     (**************************************)  
   
         (*assignment, store-statement, and store-expression*)  
     fun mkAssn(lhs,cnt,rator,nSize,oSize,pieces,isFill,aligned,splitTy,ops,indexAt)= (case rator nSize  
         of DstOp.sumVec _ =>(SOME( addSca ops),NONE)  
         | DstOp.dotVec _ => (SOME( addSca ops),NONE)  
         | _=>getLHS(lhs,cnt,aligned,nSize,oSize,indexAt,splitTy,ops)  
   
         (*end case*))  
   
     (* This will create assignments with multiple mkVec*)  
     (*x=[MkVec 2(Add 2), mkVec 4(Add 4)] Multiple mkVecs *)  
67    
68      (**************************************)      (**************************************)
69      (*If it is matrix then we need to add offset to indexAt*)      (*If it is matrix then we need to add offset to indexAt*)
# Line 116  Line 88 
88    
89          (**************************************)          (**************************************)
90      (*Main functions*)      (*Main functions*)
91      fun vecToTree(lhs,cnt,rator,nSize,oSize,pieces,argScas,argV',isFill)= let      fun vecToTree(lhs,rator,nSize,oSize,pieces,argScas,argV',isFill)= let
92    
93          val splitTy=DstTy.vectorLength pieces          val splitTy=DstTy.vectorLength pieces
94          val (indexAt', argVecs)=isMatrix2(argV',[])          val (indexAt', argVecs)=isMatrix2(argV',[])
95    
96          val _ =  testp ["\n\t ",Dst.kindToString(VTree.kind lhs)]          val lhsKind=DstV.kind lhs
97            val _ =testp ["\n\t LHS ",Dst.kindToString lhsKind,"- Var:",DstV.name lhs]
98          val aligned= isAligned isFill          val aligned= isAligned isFill
99          val indexAt=IntInf.fromInt indexAt'          val indexAt=IntInf.fromInt indexAt'
100    
101          (*Create Ld Expressions and Tree Ops*)          (*Create Ld Expressions and Tree Ops*)
102          val ops=mkOps(rator,oSize,pieces,argScas,argVecs,aligned,indexAt)          val ops=mkOps(lhsKind,rator,oSize,pieces,argScas,argVecs,aligned,indexAt)
   
         (* create statement*)  
         val expA=mkAssn(lhs,cnt,rator,nSize,oSize,pieces,isFill,aligned,splitTy,ops, indexAt)  
   
103      in      in
104          expA          mkStmt(Dst.E_Var lhs,lhsKind,rator,nSize,oSize,pieces,isFill,aligned,splitTy,ops, indexAt)
105      end      end
106    
107          (**************************************)          (**************************************)
# Line 171  Line 140 
140          | SrcOp.RealToInt d =>    DstOp.RealToInt d          | SrcOp.RealToInt d =>    DstOp.RealToInt d
141          (*| SrcOp.VoxelAddress( info, offset)  => expandVoxelAddress  (y, info, offset, args')          (*| SrcOp.VoxelAddress( info, offset)  => expandVoxelAddress  (y, info, offset, args')
142          | SrcOp.LoadVoxels (rty, d ) =>    DstOp.LoadVoxels( rty, d)*)          | SrcOp.LoadVoxels (rty, d ) =>    DstOp.LoadVoxels( rty, d)*)
   
   
143          (*Maybe should delete?*)          (*Maybe should delete?*)
144        (*  | SrcOp.LoadImage info =>    DstOp.LoadImage info*)        (*  | SrcOp.LoadImage info =>    DstOp.LoadImage info*)
   
145          | SrcOp.Inside info =>    DstOp.Inside info          | SrcOp.Inside info =>    DstOp.Inside info
146          | SrcOp.Transform V=>    DstOp.Transform V          | SrcOp.Transform V=>    DstOp.Transform V
147          | SrcOp.Translate V=>  DstOp.Translate V          | SrcOp.Translate V=>  DstOp.Translate V
# Line 186  Line 152 
152          | SrcOp.Sqrt =>DstOp.Sqrt          | SrcOp.Sqrt =>DstOp.Sqrt
153          (*Still need to sort *)          (*Still need to sort *)
154          | SrcOp.IndexTensor e=> DstOp.IndexTensor e          | SrcOp.IndexTensor e=> DstOp.IndexTensor e
   
155          | SrcOp.imgAddr(v,indexAt, dim)=>DstOp.imgAddr(v, indexAt, dim)          | SrcOp.imgAddr(v,indexAt, dim)=>DstOp.imgAddr(v, indexAt, dim)
156          | SrcOp.imgLoad(v,dim,n)=>DstOp.imgLoad(v,dim,n)          | SrcOp.imgLoad(v,dim,n)=>DstOp.imgLoad(v,dim,n)
   
157      | SrcOp.baseAddr V => DstOp.baseAddr V      | SrcOp.baseAddr V => DstOp.baseAddr V
158          (*EigenVecs,mkDynamic, Append,Prepend, Concat,Length,ImageAddress,LoadVoxel,Inputs, and Pritns*)          (*EigenVecs,mkDynamic, Append,Prepend, Concat,Length,ImageAddress,LoadVoxel,Inputs, and Pritns*)
159          | rator => raise Fail ("bogus operator " ^ SrcOp.toString rator)          | rator => raise Fail ("bogus operator " ^ SrcOp.toString rator)

Legend:
Removed from v.2690  
changed lines
  Added in v.2691

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