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 345, Mon Sep 20 19:22:51 2010 UTC revision 387, Fri Oct 8 15:29:24 2010 UTC
# Line 12  Line 12 
12    
13          end = struct          end = struct
14    
15    
16      structure SrcIL = MidIL      structure SrcIL = MidIL
17      structure SrcOp = MidOps      structure SrcOp = MidOps
18        structure VTbl = SrcIL.Var.Tbl
19      structure DstIL = LowIL      structure DstIL = LowIL
20      structure DstOp = LowOps      structure DstOp = LowOps
     structure VMap = SrcIL.Var.Map  
21    
22      fun lookupVar (env, x) = (case VMap.find(env, x)      type var_env = DstIL.var VTbl.hash_table
23    
24        fun rename (env : var_env, x) = (case VTbl.find env x
25             of SOME x' => x'             of SOME x' => x'
26              | NONE => raise Fail("unknown variable "^SrcIL.Var.toString x)              | NONE => let
27                    val x' = DstIL.Var.new (SrcIL.Var.name x)
28                    in
29                      VTbl.insert env (x, x');
30                      x'
31                    end
32            (* end case *))            (* end case *))
33        fun renameList (env, xs) = List.map (fn x => rename(env, x)) xs
   
         fun lookup  
34    
35    (* expand the EvalKernel operations into vector operations *)    (* expand the EvalKernel operations into vector operations *)
36      fun expandKernel (dimSize,kern,k,vec) =      fun expandKernel (dimSize, kern, k, vec) = ??
   
   
37    
38    (* compute the load address for a given set of voxels indices *)    (* compute the load address for a given set of voxels indices *)
39      fun computeVoxelAddress (info,vec) =      fun computeVoxelAddress (info, vec) = ??
   
40    
41      (* expand a SrcIL assignment to a list of DstIL assignments *)
42        fun expand (env, (y, rhs)) = let
43              val y' = rename (env, y)
44              fun assign rhs = [(y', rhs)]
45              in
46                case rhs
47                 of SrcIL.VAR x => assign (DstIL.VAR(rename(env, x)))
48                  | SrcIL.LIT lit => assign (DstIL.LIT lit)
49                  | SrcIL.OP(rator, args) => expandOp (env, y', rator, args)
50                  | SrcIL.CONS args => assign (DstIL.CONS(renameList(env, args)))
51                (* end case *)
52              end
53    
54      fun translate prog = raise Fail "FIXME"      structure Trans =  TranslateFn (
55          struct
56            structure SrcIL = SrcIL
57            structure DstIL = DstIL
58    
59            type var_env = var_env
60    
61            val rename = rename
62            val expand = expand
63          end)
64    
65        fun translate (SrcIL.Program{globals, globalInit, actors}) = let
66              val env = VTbl.mkTable (256, Fail "env")
67              fun transMethod (SrcIL.Method{name, stateIn, stateOut, body}) =
68                    DstIL.Method{
69                        name = name,
70                        stateIn = renameList (env, stateIn),
71                        stateOut = renameList (env, stateOut),
72                        body = Trans.translate (env, body)
73                      }
74              fun transActor (SrcIL.Actor{name, params, state, stateInit, methods}) =
75                    DstIL.Actor{
76                        name = name,
77                        params = renameList (env, params),
78                        state = renameList (env, state),
79                        stateInit = Trans.translate (env, stateInit),
80                        methods = List.map transMethod methods
81                      }
82              in
83                DstIL.Program{
84                    globals = renameList (env, globals),
85                    globalInit = Trans.translate (env, globalInit),
86                    actors = List.map transActor actors
87                  }
88              end
89    
90    end    end

Legend:
Removed from v.345  
changed lines
  Added in v.387

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