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

SCM Repository

[diderot] Diff of /branches/pure-cfg/src/compiler/c-target/tree-to-c.sml
ViewVC logotype

Diff of /branches/pure-cfg/src/compiler/c-target/tree-to-c.sml

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

revision 841, Mon Apr 18 17:58:45 2011 UTC revision 842, Mon Apr 18 17:58:57 2011 UTC
# Line 18  Line 18 
18    
19      val trExp : env * TreeIL.exp -> CLang.exp      val trExp : env * TreeIL.exp -> CLang.exp
20    
21      (* vector indexing support.  Arguments are: vector, arity, index *)
22        val ivecIndex : CLang.exp * int * int -> CLang.exp
23        val vecIndex : CLang.exp * int * int -> CLang.exp
24    
25    end = struct    end = struct
26    
27      structure CL = CLang      structure CL = CLang
# Line 86  Line 90 
90            end            end
91      end (* local *)      end (* local *)
92    
93      (* vector indexing support.  Arguments are: vector, arity, index *)
94        fun ivecIndex (v, n, ix) = let
95              val unionTy = CL.T_Named(concat["union", Int.toString n, !RN.gIntSuffix, "_t"])
96              val e1 = CL.mkCast(unionTy, v)
97              val e2 = CL.mkSelect(e1, "i")
98              in
99                CL.mkSubscript(e2, intExp ix)
100              end
101    
102        fun vecIndex (v, n, ix) = let
103              val unionTy = CL.T_Named(concat["union", Int.toString n, !RN.gRealSuffix, "_t"])
104              val e1 = CL.mkCast(unionTy, v)
105              val e2 = CL.mkSelect(e1, "r")
106              in
107                CL.mkSubscript(e2, intExp ix)
108              end
109    
110    (* Translate a TreeIL operator application to a CLang expression *)    (* Translate a TreeIL operator application to a CLang expression *)
111      fun trOp (rator, args) = (case (rator, args)      fun trOp (rator, args) = (case (rator, args)
112             of (Op.Add ty, [a, b]) =>             of (Op.Add ty, [a, b]) =>
# Line 145  Line 166 
166                    else raise Fail "unsupported matrix-matrix multiply"                    else raise Fail "unsupported matrix-matrix multiply"
167              | (Op.Cross, args) =>              | (Op.Cross, args) =>
168                  CL.E_Apply(RN.cross(), args)                  CL.E_Apply(RN.cross(), args)
169              | (Op.Select(Ty.IVecTy n, i), [a]) => let              | (Op.Select(Ty.IVecTy n, i), [a]) =>
170                  val unionTy = CL.T_Named(concat["union", Int.toString n, !RN.gIntSuffix, "_t"])                  ivecIndex (a, n, i)
171                  val e1 = CL.mkCast(unionTy, a)              | (Op.Select(Ty.TensorTy[n], i), [a]) =>
172                  val e2 = CL.mkSelect(e1, "i")                  vecIndex (a, n, i)
                 in  
                   CL.mkSubscript(e2, intExp i)  
                 end  
             | (Op.Select(Ty.TensorTy[n], i), [a]) => let  
                 val unionTy = CL.T_Named(concat["union", Int.toString n, !RN.gRealSuffix, "_t"])  
                 val e1 = CL.mkCast(unionTy, a)  
                 val e2 = CL.mkSelect(e1, "r")  
                 in  
                   CL.mkSubscript(e2, intExp i)  
                 end  
173              | (Op.Norm(Ty.TensorTy[n]), args) =>              | (Op.Norm(Ty.TensorTy[n]), args) =>
174                  CL.E_Apply(RN.length n, args)                  CL.E_Apply(RN.length n, args)
175              | (Op.Normalize d, args) =>              | (Op.Normalize d, args) =>

Legend:
Removed from v.841  
changed lines
  Added in v.842

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