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 2667, Thu Jun 5 18:54:12 2014 UTC revision 2668, Thu Jun 12 03:29:04 2014 UTC
# Line 12  Line 12 
12    
13      val testing=1      val testing=1
14    
15      fun mkLd(vn, origTy,offset, args,aligned)=(case aligned      fun mkVec(aligned,from,to,indexAt,splitTy,code) = Dst.E_mkVec(aligned,from,to, Dst.E_Lit(Literal.Int indexAt),splitTy,code)
16          of 0=>  List.map (fn a => Dst.E_LoadVec(vn, origTy, a, Dst.E_Lit(Literal.Int offset))) args  
17          | _ =>  List.map (fn a => Dst.E_LoadVecAligned(vn, origTy, a, Dst.E_Lit(Literal.Int offset))) args      fun mkLd(aligned,vn, origTy,offset, args)=
18          (*end case*))          List.map (fn a => Dst.E_LoadVec(aligned, vn, origTy, a, Dst.E_Lit(Literal.Int offset))) args
19    
20    
21      fun getLd(pieces, 0, rator, argsS, args, origTy,aligned)= let      fun getLd(pieces, 0, rator, argsS, args, origTy,aligned)= let
22          fun createOps ([], _, code) = code          fun createOps ([], _, code) = code
23            | createOps (vn::es, offset, code)=let            | createOps (vn::es, offset, code)=let
24              val args' =mkLd(vn, origTy, offset, args,aligned)              val args' =mkLd(aligned,vn, origTy, offset, args)
25              val exp = Dst.E_Op(rator vn, argsS@args')              val exp = Dst.E_Op(rator vn, argsS@args')
26              in              in
27                  createOps (es, offset + IntInf.fromInt vn, code@[exp])                  createOps (es, offset + IntInf.fromInt vn, code@[exp])
# Line 34  Line 34 
34      fun addSca [e1]=e1      fun addSca [e1]=e1
35        | addSca(e1::e2::es)= addSca([Dst.E_Op(DstOp.addSca,[e1,e2])]@es)        | addSca(e1::e2::es)= addSca([Dst.E_Op(DstOp.addSca,[e1,e2])]@es)
36    
     fun mkVec(n,origTy,splitTy,code,aligned)=(case aligned  
         of 0=> Dst.E_mkVec(n,origTy,splitTy,code)  
         | _=> Dst.E_mkVecAligned(n,origTy,splitTy,code)  
         (*end case*))  
37    
38      fun creatLd(lhs,rator,n,origTy,pieces,argsS,args)= let      fun mkFromP([],_,lhs, aligned,splitTy, _)=[]
39          | mkFromP(n::pieces,indexAt,lhs,aligned,splitTy, code::es)=
40            mkFromP(pieces,indexAt + IntInf.fromInt n, lhs, aligned,splitTy,es)@
41            [Dst.S_Assign([lhs],mkVec(aligned,n,n,indexAt,splitTy,code))]
42    
43    
44    
45        fun filled([n],lhs, aligned,origTy,splitTy, [code])=
46            [Dst.S_Assign([lhs],mkVec(aligned,n,origTy,0,splitTy,code))]
47          | filled _=raise Fail"Too man pieces for fillVec"
48    
49    
50        fun creatLd(lhs,rator,n,origTy,pieces,argsS,args,f)= let
51          val splitTy=DstTy.vectorLength pieces          val splitTy=DstTy.vectorLength pieces
52          val aligned=1          val aligned=(case f
53                of true=>false
54                | _ => true (*add more here *)
55                (**))
56    
57          val code=getLd(pieces, 0,rator,argsS,args,origTy,aligned)          val code=getLd(pieces, 0,rator,argsS,args,origTy,aligned)
58    
59          val exp=(case (rator n)          val exp=(case (rator n)
60              of DstOp.sumVec _ => Dst.S_Assign([lhs],addSca code)              of DstOp.sumVec _ => [Dst.S_Assign([lhs],addSca code)]
61                  (*already checked for vector types*)                  (*already checked for vector types*)
62              | _ =>(*Dst.S_Mk(lhs,mkVec(n,origTy,splitTy,code,aligned)) *)              | _ => (case f
63                  Dst.S_Assign([lhs],mkVec(n,origTy,splitTy,code,aligned))                      of true =>filled(pieces,lhs,aligned,origTy,splitTy, code)
64              (*end case*))                      |_ => mkFromP(pieces, 0,lhs, aligned,  splitTy, code)
65                (*end case*)))
66          val _=(case testing          val _=(case testing
67              of 1=>(print((Dst.toStringS exp)^"\n\n");1)              of 1=>(print((String.concatWith "," (List.map Dst.toStringS exp))^"\n\n");1)
68              |_ =>1)              |_ =>1)
69          in          in
70              [exp] (*[Dst.S_Assign([lhs],exp)]*)              exp
71          end          end
72    
73    
# Line 77  Line 91 
91          | SrcOp.Min =>    DstOp.Min          | SrcOp.Min =>    DstOp.Min
92          | SrcOp.Clamp ty =>    DstOp.Clamp ty          | SrcOp.Clamp ty =>    DstOp.Clamp ty
93          | SrcOp.Lerp ty =>    DstOp.Lerp  ty          | SrcOp.Lerp ty =>    DstOp.Lerp  ty
         (*  
         | SrcOp.Norm (SrcTy.TensorTy [v]) =>    raise Fail"Should have been replaced in mid-to-low-il"  
         | SrcOp.Norm ty =>    DstOp.Norm  ty  
         | SrcOp.Normalize d =>    DstOp.Normalize d  
         *)  
94          | SrcOp.Zero ty =>    DstOp.Zero  ty          | SrcOp.Zero ty =>    DstOp.Zero  ty
95          | SrcOp.PrincipleEvec ty =>    DstOp.PrincipleEvec ty          | SrcOp.PrincipleEvec ty =>    DstOp.PrincipleEvec ty
96          | SrcOp.EigenVals2x2 =>    DstOp.EigenVals2x2          | SrcOp.EigenVals2x2 =>    DstOp.EigenVals2x2

Legend:
Removed from v.2667  
changed lines
  Added in v.2668

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