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

SCM Repository

[diderot] Diff of /trunk/src/compiler/high-to-mid/high-to-mid.sml
ViewVC logotype

Diff of /trunk/src/compiler/high-to-mid/high-to-mid.sml

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

revision 394, Thu Oct 14 16:30:29 2010 UTC revision 397, Thu Oct 14 20:08:03 2010 UTC
# Line 27  Line 27 
27        | cvtTy SrcTy.IntTy = DstTy.intTy        | cvtTy SrcTy.IntTy = DstTy.intTy
28        | cvtTy (SrcTy.TensorTy[]) = DstTy.realTy        | cvtTy (SrcTy.TensorTy[]) = DstTy.realTy
29        | cvtTy (SrcTy.TensorTy[d]) = DstTy.VecTy d        | cvtTy (SrcTy.TensorTy[d]) = DstTy.VecTy d
30        | cvtTy _ = raise Fail "unexpected higher-order tensor type"        | cvtTy SrcTy.ImageTy = DstTy.ImageTy
31          | cvtTy ty = raise Fail("unexpected type " ^ SrcTy.toString ty)
32    
33      fun rename (env : var_env, x) = (case VTbl.find env x      fun rename (env : var_env, x) = (case VTbl.find env x
34             of SOME x' => x'             of SOME x' => x'
# Line 112  Line 113 
113                | SrcOp.Inside => (case args                | SrcOp.Inside => (case args
114                     of [pos, fld] => expandInside(env, y, pos, fld)                     of [pos, fld] => expandInside(env, y, pos, fld)
115                    (* end case *))                    (* end case *))
116  (* QUESTION: there is no MidIL equivalant, but these might be floating                | SrcOp.Field fld => raise Fail "impossible"
  * around, which could cause invalid MidIL to be generated.  
  *)  
               | SrcOp.Field fld => []  
117                | SrcOp.Probe => (case args                | SrcOp.Probe => (case args
118                     of [fld, pos] => expandProbe(env, y, fld, pos)                     of [fld, pos] => expandProbe(env, y, fld, pos)
119                    (* end case *))                    (* end case *))
# Line 127  Line 125 
125    
126    (* expand a SrcIL assignment to a list of DstIL assignments *)    (* expand a SrcIL assignment to a list of DstIL assignments *)
127      fun expand (env, (y, rhs)) = let      fun expand (env, (y, rhs)) = let
128            val y' = rename (env, y)            fun assign rhs = [(rename (env, y), rhs)]
           fun assign rhs = [(y', rhs)]  
129            in            in
130              case rhs              case rhs
131               of SrcIL.VAR x => assign (DstIL.VAR(rename(env, x)))               of SrcIL.VAR x => assign (DstIL.VAR(rename(env, x)))
132                | SrcIL.LIT lit => assign (DstIL.LIT lit)                | SrcIL.LIT lit => assign (DstIL.LIT lit)
133                | SrcIL.OP(rator, args) => expandOp (env, y', rator, args)                | SrcIL.OP(SrcOp.Field _, args) => []
134                  | SrcIL.OP(rator, args) => expandOp (env, rename (env, y), rator, args)
135                | SrcIL.CONS args => assign (DstIL.CONS(renameList(env, args)))                | SrcIL.CONS args => assign (DstIL.CONS(renameList(env, args)))
136              (* end case *)              (* end case *)
137            end            end
# Line 166  Line 164 
164                      stateInit = Trans.translate (env, stateInit),                      stateInit = Trans.translate (env, stateInit),
165                      methods = List.map transMethod methods                      methods = List.map transMethod methods
166                    }                    }
167            (* filter out field variables, since they will be made explicit in
168             * the MidIL.
169             *)
170              val globals = let
171                    fun filter x = (case SrcIL.Var.ty x
172                           of SrcTy.FieldTy => NONE
173                            | _ => SOME x
174                          (* end case *))
175                    in
176                      List.mapPartial filter globals
177                    end
178            in            in
179              DstIL.Program{              DstIL.Program{
180                  globals = renameList (env, globals),                  globals = renameList (env, globals),

Legend:
Removed from v.394  
changed lines
  Added in v.397

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