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

SCM Repository

[diderot] Diff of /branches/vis12/src/compiler/c-target/c-target.sml
ViewVC logotype

Diff of /branches/vis12/src/compiler/c-target/c-target.sml

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

revision 1705, Tue Mar 6 21:59:47 2012 UTC revision 1706, Wed Mar 7 12:06:48 2012 UTC
# Line 22  Line 22 
22                  | NONE => raise Fail(concat["lookup(_, ", V.name x, ")"])                  | NONE => raise Fail(concat["lookup(_, ", V.name x, ")"])
23                (* end case *))                (* end case *))
24        (* 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) *)
25          fun lvalueVar (env, x) = (case V.kind x          fun lvalueVar (env, x) = CL.mkVar(lookup(env, x))
                of IL.VK_Global => CL.mkVar(lookup(env, x))  
                 | IL.VK_Local => CL.mkVar(lookup(env, x))  
               (* end case *))  
26        (* translate a variable that occurs in an r-value context *)        (* translate a variable that occurs in an r-value context *)
27          fun rvalueVar (env, x) = (case V.kind x          fun rvalueVar (env, x) = CL.mkVar(lookup(env, x))
                of IL.VK_Global => CL.mkVar(lookup(env, x))  
                 | IL.VK_Local => CL.mkVar(lookup(env, x))  
               (* end case *))  
28        (* translate a strand state variable that occurs in an l-value context *)        (* translate a strand state variable that occurs in an l-value context *)
29          fun lvalueStateVar x = CL.mkIndirect(CL.mkVar "selfOut", IL.StateVar.name x)          fun lvalueStateVar x = CL.mkIndirect(CL.mkVar "selfOut", IL.StateVar.name x)
30        (* translate a strand state variable that occurs in an r-value context *)        (* translate a strand state variable that occurs in an r-value context *)
# Line 159  Line 153 
153                          CL.D_Var(["static"], CL.charPtr, "ProgramName",                          CL.D_Var(["static"], CL.charPtr, "ProgramName",
154                            SOME(CL.I_Exp(CL.mkStr(#srcFile tgt)))),                            SOME(CL.I_Exp(CL.mkStr(#srcFile tgt)))),
155                          CL.D_Verbatim([                          CL.D_Verbatim([
156                              if #double tgt                              concat["#define " ^ TargetUtil.floatPrecisionDef tgt, "\n"],
157                                then "#define DIDEROT_DOUBLE_PRECISION\n"                              concat["#define " ^ TargetUtil.intPrecisionDef tgt, "\n"],
158                                else "#define DIDEROT_SINGLE_PRECISION\n",                              concat["#define " ^ TargetUtil.targetDef tgt, "\n"]
                             "#define DIDEROT_INT\n",  
                             if #parallel tgt  
                               then "#define DIDEROT_TARGET_PARALLEL\n"  
                               else "#define DIDEROT_TARGET_C\n"  
159                            ] @ includes)                            ] @ includes)
160                        ],                        ],
161                      topDecls = ref [],                      topDecls = ref [],
# Line 381  Line 371 
371        (* output the code to a file.  The string is the basename of the file, the extension        (* output the code to a file.  The string is the basename of the file, the extension
372         * is provided by the target.         * is provided by the target.
373         *)         *)
374          fun generate (prog as Prog{tgt, ...}) = let          fun generateExec (prog as Prog{tgt, ...}) = let
375                val {outDir, outBase, exec, double, parallel, debug, ...} = tgt                val {outDir, outBase, exec, double, parallel, debug, ...} = tgt
376                fun condCons (true, x, xs) = x::xs                fun condCons (true, x, xs) = x::xs
377                  | condCons (false, _, xs) = xs                  | condCons (false, _, xs) = xs
# Line 395  Line 385 
385              (* generate the loader flags *)              (* generate the loader flags *)
386                val extraLibs = condCons (parallel, #pthread Paths.extraLibs, [])                val extraLibs = condCons (parallel, #pthread Paths.extraLibs, [])
387                val extraLibs = Paths.teemLinkFlags @ #base Paths.extraLibs :: extraLibs                val extraLibs = Paths.teemLinkFlags @ #base Paths.extraLibs :: extraLibs
388                val rtLib = TargetUtil.runtimeName {                val rtLib = TargetUtil.runtimeName tgt
                       target = TargetUtil.TARGET_C, exec = exec,  
                       parallel = parallel, double = double, debug = debug  
                     }  
389                val ldOpts = rtLib :: extraLibs                val ldOpts = rtLib :: extraLibs
390                val basename = OS.Path.joinDirFile{dir=outDir, file=outBase}                val basename = OS.Path.joinDirFile{dir=outDir, file=outBase}
391                in                in
# Line 407  Line 394 
394                  RunCC.link (basename, ldOpts)                  RunCC.link (basename, ldOpts)
395                end                end
396    
397            fun generateLib (prog as Prog{tgt, strands, ...}) = let
398                  val {outDir, outBase, exec, double, parallel, debug, ...} = tgt
399                  val basename = OS.Path.joinDirFile{dir=outDir, file=outBase}
400                  val [Strand{state, output, ...}] = AtomTable.listItems strands
401                  in
402                    GenLibraryInterface.gen {
403                        tgt = tgt,
404                        inputs = [], (* FIXME *)
405                        outputs = [output]
406                      }
407                  end
408    
409            fun generate (prog as Prog{tgt, ...}) = if #exec tgt
410                  then generateExec prog
411                  else generateLib prog
412    
413        end        end
414    
415    (* strands *)    (* strands *)

Legend:
Removed from v.1705  
changed lines
  Added in v.1706

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