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 4406, Fri Aug 12 13:21:28 2016 UTC revision 4407, Fri Aug 12 13:33:46 2016 UTC
# Line 20  Line 20 
20      structure Env = CodeGenEnv      structure Env = CodeGenEnv
21      structure Out = CodeOutput      structure Out = CodeOutput
22      structure RN = CxxNames      structure RN = CxxNames
23        structure Frags = CPUFragments
24    
25      val openCxxOut = Out.openOut {ext = "cxx", ppDecl = PrintAsCxx.output}      val openCxxOut = Out.openOut {ext = "cxx", ppDecl = PrintAsCxx.output}
26    
# Line 137  Line 138 
138                GenUtil.genBodyWithGlobPtr (env, body))                GenUtil.genBodyWithGlobPtr (env, body))
139            end            end
140    
141      fun runFrag (spec, subs) = if TargetSpec.noBSP spec    (* specialize the fragments that implement the run and run_initially world methods *)
142              then verbFrag (spec, CPUFragments.parallelRunNoBSP, CPUFragments.sequentialRunNoBSP, subs)      fun runFrag (spec, subs) = let
143              else verbFrag (spec, CPUFragments.parallelRun, CPUFragments.sequentialRun, subs)            val code = if TargetSpec.noBSP spec
144                  then [verbFrag (spec, Frags.parRunNoBSP, Frags.seqRunNoBSP, subs)]
145                  else [verbFrag (spec, Frags.parRun, Frags.seqRun, subs)]
146              in
147                if #hasInitiallyMeth spec
148                  then verbFrag (spec, Frags.parRunInit, Frags.seqRunInit, subs) :: code
149                  else code
150              end
151    
152      fun compile (spec : TargetSpec.t, basename) = let      fun compile (spec : TargetSpec.t, basename) = let
153          (* generate the C compiler flags *)          (* generate the C compiler flags *)
# Line 171  Line 179 
179            fun pp (true, dcl) = ppDecl (CL.D_Verbatim ["#define " ^ dcl])            fun pp (true, dcl) = ppDecl (CL.D_Verbatim ["#define " ^ dcl])
180              | pp _ = ()              | pp _ = ()
181            in            in
182              pp (#hasStabilize spec, "DIDEROT_HAS_STABILIZE");              pp (#hasStabilizeMeth spec, "DIDEROT_HAS_STABILIZE");
183              pp (TargetSpec.dualState spec, "DIDEROT_DUAL_STATE");              pp (TargetSpec.dualState spec, "DIDEROT_DUAL_STATE");
184              pp (not(#hasGlobals spec), "DIDEROT_NO_GLOBALS");              pp (not(#hasGlobals spec), "DIDEROT_NO_GLOBALS");
185              pp (not(#hasInputs spec), "DIDEROT_NO_INPUTS");              pp (not(#hasInputs spec), "DIDEROT_NO_INPUTS");
# Line 194  Line 202 
202              ppDecl structDef;              ppDecl structDef;
203              ppDecl (GenWorld.genStruct(env, strandName, Option.getOpt(dim, 1)));              ppDecl (GenWorld.genStruct(env, strandName, Option.getOpt(dim, 1)));
204              if (TargetSpec.isParallel spec)              if (TargetSpec.isParallel spec)
205                then ppDecl (CL.verbatimDcl [CPUFragments.parallelExtras] substitutions)                then ppDecl (CL.verbatimDcl [Frags.parExtras] substitutions)
206                else ();                else ();
207              List.app ppDecl (genInputCode());              List.app ppDecl (genInputCode());
208              List.app (ppDecl o genFunc spec) funcs;              List.app (ppDecl o genFunc spec) funcs;
# Line 203  Line 211 
211                else ();                else ();
212              List.app ppDecl methods;              List.app ppDecl methods;
213              List.app ppDecl (GenOutputs.gen (env, dim, outputs));              List.app ppDecl (GenOutputs.gen (env, dim, outputs));
214              ppDecl (CL.verbatimDcl [CPUFragments.worldMethods] substitutions);              ppDecl (CL.verbatimDcl [Frags.worldMethods] substitutions);
215              ppDecl (GenWorld.genInitiallyFun (env, globInit, strand, create));              ppDecl (GenWorld.genCreateFun (env, globInit, strand, create));
216              ppDecl (runFrag (spec, substitutions));              List.app ppDecl (runFrag (spec, substitutions));
217              Option.app (fn blk => ppDecl (GenGlobalUpdate.gen (env, "initially", blk))) init;              Option.app (fn blk => ppDecl (GenGlobalUpdate.gen (env, "initially", blk))) init;
218              Option.app (fn blk => ppDecl (GenGlobalUpdate.gen (env, "update", blk))) update              Option.app (fn blk => ppDecl (GenGlobalUpdate.gen (env, "update", blk))) update
219            end            end
# Line 235  Line 243 
243                  GenOutputsUtil.genRegisterOutputOpts (env, OutputUtil.gatherOutputs prog)));                  GenOutputsUtil.genRegisterOutputOpts (env, OutputUtil.gatherOutputs prog)));
244              ppDecl (CL.verbatimDcl [CxxFragments.namespaceClose] substitutions);              ppDecl (CL.verbatimDcl [CxxFragments.namespaceClose] substitutions);
245            (* generate main function after closing off the namespace *)            (* generate main function after closing off the namespace *)
246              ppDecl (verbFrag (spec, CPUFragments.parallelMain, CPUFragments.sequentialMain, substitutions));              ppDecl (verbFrag (spec, Frags.parMain, Frags.seqMain, substitutions));
247              Out.closeOut outS;              Out.closeOut outS;
248              compile (spec, baseName);              compile (spec, baseName);
249              RunCC.linkExec (baseName, ldFlags spec)              RunCC.linkExec (baseName, ldFlags spec)
# Line 272  Line 280 
280              outputSrc (outS, env, spec, prog, strand, substitutions,              outputSrc (outS, env, spec, prog, strand, substitutions,
281                fn () => (postWorld @ GenInputs.genLibraryInputFuns (env, prog)));                fn () => (postWorld @ GenInputs.genLibraryInputFuns (env, prog)));
282              ppDecl (CL.verbatimDcl [CxxFragments.namespaceClose] substitutions);              ppDecl (CL.verbatimDcl [CxxFragments.namespaceClose] substitutions);
283              ppDecl (CL.verbatimDcl [CPUFragments.cWrappers] substitutions);              ppDecl (CL.verbatimDcl [Frags.cWrappers] substitutions);
284              Out.closeOut outS;              Out.closeOut outS;
285            (* compile and link *)            (* compile and link *)
286              compile (spec, baseName);              compile (spec, baseName);

Legend:
Removed from v.4406  
changed lines
  Added in v.4407

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