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

SCM Repository

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

Diff of /branches/pure-cfg/src/compiler/cl-target/cl-target.sml

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

revision 1285, Tue Jun 7 10:33:17 2011 UTC revision 1286, Tue Jun 7 10:54:18 2011 UTC
# Line 24  Line 24 
24                (* end case *))                (* end case *))
25        (* translate a variable that occurs in an l-value context (i.e., as the target of an assignment) *)        (* translate a variable that occurs in an l-value context (i.e., as the target of an assignment) *)
26          fun lvalueVar (env, x) = (case V.kind x          fun lvalueVar (env, x) = (case V.kind x
27                 of IL.VK_Global => CL.mkIndirect(CL.mkVar "diderotGlobals", lookup(env, x))                 of IL.VK_Global => CL.mkIndirect(CL.mkVar RN.globalsVarName, lookup(env, x))
28                  | IL.VK_State strand => raise Fail "unexpected strand context"                  | IL.VK_State strand => raise Fail "unexpected strand context"
29                  | IL.VK_Local => CL.mkVar(lookup(env, x))                  | IL.VK_Local => CL.mkVar(lookup(env, x))
30                (* end case *))                (* end case *))
# Line 98  Line 98 
98    (* TreeIL to target translations *)    (* TreeIL to target translations *)
99      structure Tr =      structure Tr =
100        struct        struct
101          (* this function is used for the initially clause, so it generates OpenCL *)
102          fun fragment (ENV{info, vMap, scope}, blk) = let          fun fragment (ENV{info, vMap, scope}, blk) = let
103                val (vMap, stms) = ToCL.trFragment (vMap, blk)                val (vMap, stms) = ToCL.trFragment (vMap, blk)
104                in                in
# Line 114  Line 115 
115          fun block (ENV{vMap, scope, ...}, blk) = (case scope          fun block (ENV{vMap, scope, ...}, blk) = (case scope
116                 of StrandScope stateVars => ToCL.trBlock (vMap, saveState "StrandScope" stateVars, blk)                 of StrandScope stateVars => ToCL.trBlock (vMap, saveState "StrandScope" stateVars, blk)
117                  | MethodScope stateVars => ToCL.trBlock (vMap, saveState "MethodScope" stateVars, blk)                  | MethodScope stateVars => ToCL.trBlock (vMap, saveState "MethodScope" stateVars, blk)
118                  | _ => ToCL.trBlock (vMap, fn (_, _, stm) => [stm], blk)                  | InitiallyScope => ToCL.trBlock (vMap, fn (_, _, stm) => [stm], blk)
119                    | _ => ToC.trBlock (vMap, fn (_, _, stm) => [stm], blk)
120                (* end case *))                (* end case *))
121          fun exp (ENV{vMap, ...}, e) = ToCL.trExp(vMap, e)          fun exp (ENV{vMap, ...}, e) = ToCL.trExp(vMap, e)
122        end        end
# Line 170  Line 172 
172        struct        struct
173          fun new {name, double, parallel, debug} = (          fun new {name, double, parallel, debug} = (
174                RN.initTargetSpec double;                RN.initTargetSpec double;
175                  CNames.initTargetSpec double;
176                Prog{                Prog{
177                    name = name,                    name = name,
178                    double = double, parallel = parallel, debug = debug,                    double = double, parallel = parallel, debug = debug,
# Line 202  Line 205 
205                  topDecls := inputsFn :: !topDecls                  topDecls := inputsFn :: !topDecls
206                end                end
207    
208          fun init (Prog{globals, topDecls,...}, CL.S_Block(init)) = let        (* register the global initialization part of a program *)
209                val params = [          fun init (Prog{topDecls, ...}, init) = let
210                        CL.PARAM([], CL.T_Ptr(CL.T_Named RN.globalsTy), RN.globalsVarName)                val globPtrTy = CL.T_Ptr(CL.T_Named RN.globalsTy)
211                      ]                val initFn = CL.D_Func(
212                val body = CL.S_Block(globalIndirects(!globals,init))                      [], CL.voidTy, RN.initGlobals, [CL.PARAM([], globPtrTy, RN.globalsVarName)],
213                val initFn = CL.D_Func([], CL.voidTy, RN.initGlobals, params, body)                      init)
214                in                val shutdownFn = CL.D_Func(
215                  topDecls := initFn :: !topDecls                      [], CL.voidTy, RN.shutdown,
216                end                      [CL.PARAM([], CL.T_Ptr(CL.T_Named RN.worldTy), "wrld")],
217            | init (Prog{globals,topDecls,...}, init) = let                      CL.S_Block[])
               val params = [  
                       CL.PARAM([], CL.T_Ptr(CL.T_Named RN.globalsTy), RN.globalsVarName)  
                     ]  
               val initFn = CL.D_Func([], CL.voidTy, RN.initGlobals, params, init)  
218                in                in
219                  topDecls := initFn :: !topDecls                  topDecls := shutdownFn :: initFn :: !topDecls
220                end                end
221    
222        (* create and register the initially function for a program *)        (* create and register the initially function for a program *)

Legend:
Removed from v.1285  
changed lines
  Added in v.1286

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