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

SCM Repository

[diderot] Diff of /branches/charisee/src/compiler/mid-to-low/mid-to-low.sml
ViewVC logotype

Diff of /branches/charisee/src/compiler/mid-to-low/mid-to-low.sml

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

revision 2844, Tue Dec 9 18:05:29 2014 UTC revision 2845, Fri Dec 12 06:46:23 2014 UTC
# Line 23  Line 23 
23      structure E=Ein      structure E=Ein
24      structure P=Printer      structure P=Printer
25      structure S1=step1      structure S1=step1
26        structure LowToS= LowToString
   
27    
28    (* instantiate the translation environment *)    (* instantiate the translation environment *)
29      local      local
# Line 88  Line 87 
87                | SrcOp.Min => assign (DstOp.Min)                | SrcOp.Min => assign (DstOp.Min)
88                | SrcOp.Clamp ty => assign (DstOp.Clamp ty)                | SrcOp.Clamp ty => assign (DstOp.Clamp ty)
89                | SrcOp.Lerp ty => assign (DstOp.Lerp ty)                | SrcOp.Lerp ty => assign (DstOp.Lerp ty)
90                  | SrcOp.Sqrt=>assign DstOp.Sqrt
91                | SrcOp.Zero ty => assign (DstOp.Zero ty)                | SrcOp.Zero ty => assign (DstOp.Zero ty)
92                | SrcOp.PrincipleEvec ty => assign (DstOp.PrincipleEvec ty)                | SrcOp.PrincipleEvec ty => assign (DstOp.PrincipleEvec ty)
93            | SrcOp.EigenVals2x2 => assign (DstOp.EigenVals2x2)            | SrcOp.EigenVals2x2 => assign (DstOp.EigenVals2x2)
# Line 95  Line 95 
95            | SrcOp.Select(ty as SrcTy.TupleTy tys, i) => assign (DstOp.Select(ty, i))            | SrcOp.Select(ty as SrcTy.TupleTy tys, i) => assign (DstOp.Select(ty, i))
96            | SrcOp.Index(ty, i) => assign (DstOp.Index(ty, i))            | SrcOp.Index(ty, i) => assign (DstOp.Index(ty, i))
97            | SrcOp.Subscript ty => assign (DstOp.Subscript ty)            | SrcOp.Subscript ty => assign (DstOp.Subscript ty)
         |SrcOp.Sqrt => assign (DstOp.Sqrt)  
98                | SrcOp.Ceiling d => assign (DstOp.Ceiling d)                | SrcOp.Ceiling d => assign (DstOp.Ceiling d)
99                | SrcOp.Floor d => assign (DstOp.Floor d)                | SrcOp.Floor d => assign (DstOp.Floor d)
100                | SrcOp.Round d => assign (DstOp.Round d)                | SrcOp.Round d => assign (DstOp.Round d)
101                | SrcOp.Trunc d => assign (DstOp.Trunc d)                | SrcOp.Trunc d => assign (DstOp.Trunc d)
102                  | SrcOp.sumVec d=>assign (DstOp.sumVec d)
103                | SrcOp.IntToReal => assign (DstOp.IntToReal)                | SrcOp.IntToReal => assign (DstOp.IntToReal)
104                | SrcOp.RealToInt d => assign (DstOp.RealToInt d)                | SrcOp.RealToInt d => assign (DstOp.RealToInt d)
   
105                | SrcOp.LoadVoxels(rty, d) => assign (DstOp.LoadVoxels(rty, d))                | SrcOp.LoadVoxels(rty, d) => assign (DstOp.LoadVoxels(rty, d))
106            | SrcOp.Kernel h => [] (* assign(DstOp.Kernel h)*)            | SrcOp.Kernel h => [] (* assign(DstOp.Kernel h)*)
107            | SrcOp.LoadImage info => assign (DstOp.LoadImage info)            | SrcOp.LoadImage info => assign (DstOp.LoadImage info)
108                | SrcOp.Inside info => assign (DstOp.Inside info)                | SrcOp.Inside info => assign (DstOp.Inside info)
   
109  (*| SrcOp.Norm ty => assign (DstOp.Norm ty)*)  (*| SrcOp.Norm ty => assign (DstOp.Norm ty)*)
110  | SrcOp.Normalize d => assign (DstOp.Normalize d)  | SrcOp.Normalize d => assign (DstOp.Normalize d)
   
             (*Input problems *)  
111                | SrcOp.Input(ty, s, desc) => assign (DstOp.Input(ty, s, desc))                | SrcOp.Input(ty, s, desc) => assign (DstOp.Input(ty, s, desc))
112                | SrcOp.InputWithDefault(ty, s, desc) =>assign (DstOp.InputWithDefault(ty, s, desc))                | SrcOp.InputWithDefault(ty, s, desc) =>assign (DstOp.InputWithDefault(ty, s, desc))
   
113            | SrcOp.Transform V=> assign (DstOp.Transform V)            | SrcOp.Transform V=> assign (DstOp.Transform V)
114            | SrcOp.Translate V=> assign(DstOp.Translate V)            | SrcOp.Translate V=> assign(DstOp.Translate V)
115                | rator => raise Fail("bogus operator " ^ SrcOp.toString rator)                | rator => raise Fail("bogus operator " ^ SrcOp.toString rator)
116              (* end case *)              (* end case *)
117            end            end
118    
   
119      val testing=1      val testing=1
120      fun testp c=(case testing      fun testp c=(case testing
121          of 0 => 1          of 0 => 1
122          | _  => (print(String.concat(c));1)          | _  => (print(String.concat(c));1)
123          (*end case*))          (*end case*))
124    
   
125      fun expandEinOp (env, y, e, args) = let      fun expandEinOp (env, y, e, args) = let
126          val einargs=Env.renameList(env, args)          val einargs=Env.renameList(env, args)
127          val _ =testp(["\n\n new ein \n", DstIL.Var.toString(y),"=",P.printerE(e)]@(List.map (fn e=> (DstIL.Var.toString(e)^",")) einargs)@["\n ** pre gen**"])          val _ =testp(["\n\n new ein \n", DstIL.Var.toString(y),"=",P.printerE(e)]
128                @(List.map (fn e=> (DstIL.Var.toString(e)^",")) einargs)@["\n ** pre gen**"])
129          val (_,code)=S1.genfn(DstIL.Var.name y,e,einargs,args)          val (_,code)=S1.genfn(DstIL.Var.name y,e,einargs,args)
130          val DstIL.ASSGN (a1,A)=List.hd(List.rev(code))          val DstIL.ASSGN (a1,A)=List.hd(List.rev(code))
131          val c=DstIL.ASSGN (y,A)          val c=DstIL.ASSGN (y,A)
132  val _=print(String.concat["\n\n previous:\n ",toS.ASSIGNtoString (a1,A),"\n newbie\n",toS.ASSIGNtoString (y,A) ])          val _=testp["\n\n previous:\n ",LowToS.ASSIGNtoString (a1,A),"\n newbie\n",LowToS.ASSIGNtoString (y,A) ]
133          in code@[c]          in
134                code@[c]
135          end          end
136    
   
137          handle ex => (print(concat["error converting  \n"]); raise ex)          handle ex => (print(concat["error converting  \n"]); raise ex)
138    
   
139    (* expand a SrcIL assignment to a DstIL CFG *)    (* expand a SrcIL assignment to a DstIL CFG *)
140      fun expand (env, (y, rhs)) = let      fun expand (env, (y, rhs)) = let
141            val y' = Env.rename (env, y)            val y' = Env.rename (env, y)
# Line 164  Line 157 
157                   (* end case *)                   (* end case *)
158          end          end
159    
   
160    (* expand a SrcIL multi-assignment to a DstIL CFG *)    (* expand a SrcIL multi-assignment to a DstIL CFG *)
161      fun mexpand (env, (ys, rator, xs)) = let      fun mexpand (env, (ys, rator, xs)) = let
162            val ys' = Env.renameList(env, ys)            val ys' = Env.renameList(env, ys)

Legend:
Removed from v.2844  
changed lines
  Added in v.2845

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