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

SCM Repository

[diderot] Diff of /branches/vis15/src/compiler/target-cpu/gen.sml
ViewVC logotype

Diff of /branches/vis15/src/compiler/target-cpu/gen.sml

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

revision 4363, Thu Aug 4 22:42:10 2016 UTC revision 4364, Fri Aug 5 15:27:42 2016 UTC
# Line 123  Line 123 
123                TreeToCxx.trBlock (env, body))                TreeToCxx.trBlock (env, body))
124            end            end
125    
   (* generate code for a block, where we optionally add a local variable that points  
    * to the globals struct.  
    *)  
     fun genBodyWithGlobPtr (env, IR.Block{locals, body}) = let  
           fun mkBody env = let  
                 val stms = #2(TreeToCxx.trStms(env, body))  
                 val stms = if #hasGlobals(Env.target env)  
                       then CL.mkDeclInit(  
                           RN.globalPtrTy, RN.globalsVar,  
                           CL.mkIndirect(CL.mkVar(Env.world env), "_globals")  
                         ) :: stms  
                       else stms  
                 in  
                   stms  
                 end  
           in  
             TreeToCxx.trWithLocals (env, !locals, mkBody)  
           end  
   
126  (* QUESTION: should init_globals be a member of the world struct? *)  (* QUESTION: should init_globals be a member of the world struct? *)
127      fun genInitGlobals (env, IR.Block{locals, body}) = let      fun genInitGlobals (env, IR.Block{locals, body}) = let
128          (* the init_globals function should return false on success *)          (* the init_globals function should return false on success *)
# Line 152  Line 133 
133            in            in
134              CL.D_Func(["static"], CL.boolTy, [], "init_globals",              CL.D_Func(["static"], CL.boolTy, [], "init_globals",
135                [RN.worldParam],                [RN.worldParam],
136                genBodyWithGlobPtr (env, body))                GenUtil.genBodyWithGlobPtr (env, body))
137            end            end
138    
139    (* generate the global initially code, which runs after the initial strands have been    (* generate the global initially code, which runs after the initial strands have been
# Line 163  Line 144 
144            in            in
145              CL.D_Func([], CL.voidTy, [], "world::global_initially",              CL.D_Func([], CL.voidTy, [], "world::global_initially",
146                [],                [],
147                genBodyWithGlobPtr (env, body))                GenUtil.genBodyWithGlobPtr (env, body))
           end  
   
   (* generate the global-update code *)  
     fun genGlobalUpdate (env, body) =let  
           val env = Env.insert(env, PseudoVars.world, "this")  
           in  
             CL.D_Func([], CL.voidTy, [], "world::global_update",  
               [],  
               genBodyWithGlobPtr (env, body))  
148            end            end
149    
150      fun runFrag (spec, subs) = if TargetSpec.noBSP spec      fun runFrag (spec, subs) = if TargetSpec.noBSP spec
# Line 244  Line 216 
216              ppDecl (GenWorld.genInitiallyFun (env, globInit, strand, create));              ppDecl (GenWorld.genInitiallyFun (env, globInit, strand, create));
217              ppDecl (runFrag (spec, substitutions));              ppDecl (runFrag (spec, substitutions));
218              Option.app (fn blk => ppDecl (genGlobalInitially (env, blk))) init;              Option.app (fn blk => ppDecl (genGlobalInitially (env, blk))) init;
219              Option.app (fn blk => ppDecl (genGlobalUpdate (env, blk))) update              Option.app (fn blk => ppDecl (GenGlobalUpdate.gen (env, blk))) update
220            end            end
221    
222      fun exec (spec : TargetSpec.t, prog) = let      fun exec (spec : TargetSpec.t, prog) = let

Legend:
Removed from v.4363  
changed lines
  Added in v.4364

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