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

SCM Repository

[diderot] Diff of /branches/vis15/src/compiler/translate/translate.sml
ViewVC logotype

Diff of /branches/vis15/src/compiler/translate/translate.sml

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

revision 3492, Thu Dec 10 22:28:29 2015 UTC revision 3493, Fri Dec 11 18:29:21 2015 UTC
# Line 28  Line 28 
28      structure Op = HighOps      structure Op = HighOps
29      structure DstTy = HighTypes      structure DstTy = HighTypes
30      structure Census = HighCensus      structure Census = HighCensus
31        structure Inp = Inputs
32    
33      val cvtTy = TranslateTy.tr      val cvtTy = TranslateTy.tr
34    
# Line 377  Line 378 
378            end            end
379  (*DEBUG*)handle ex => raise ex  (*DEBUG*)handle ex => raise ex
380    
     fun cvtFragmentBlock (env0, prefixCFG, blk) = let  
           val (cfg, env) = cvtBlock (([], []), env0, [], blk)  
           val cfg = IR.CFG.concat(prefixCFG, cfg)  
           val entry = IR.Node.mkENTRY ()  
         (* the live variables out are those that were not live coming in *)  
           val liveOut = VMap.foldli  
                 (fn (x, x', xs) => if VMap.inDomain(env0, x) then xs else x'::xs)  
                   [] env  
           val exit = IR.Node.mkFRAGMENT liveOut  
           in  
             if IR.CFG.isEmpty cfg  
               then IR.Node.addEdge (entry, exit)  
               else (  
                 IR.Node.addEdge (entry, IR.CFG.entry cfg);  
                 IR.Node.addEdge (IR.CFG.exit cfg, exit));  
             (IR.CFG{entry = entry, exit = exit}, env)  
           end  
 (*DEBUG*)handle ex => raise ex  
   
381      fun cvtMethod (loadGlobals, env, name, state, svars, blk) = let      fun cvtMethod (loadGlobals, env, name, state, svars, blk) = let
382          (* load the globals into fresh variables *)          (* load the globals into fresh variables *)
383            val (loadGlobsCFG, env) = loadGlobals env            val (loadGlobsCFG, env) = loadGlobals env
# Line 432  Line 414 
414            end            end
415  (*DEBUG*)handle ex => (print(concat["error in cvtMethod(", StrandUtil.nameToString name, ", ...)\n"]); raise ex)  (*DEBUG*)handle ex => (print(concat["error in cvtMethod(", StrandUtil.nameToString name, ", ...)\n"]); raise ex)
416    
417    (* convert the initially code *)    (* convert the initial strand creation code *)
418      fun cvtInitially (loadGlobals, S.Initially{isArray, rangeInit, create, iters}) = let      fun cvtCreate (loadGlobals, S.Create{dim, code}) = let
419            (* load the globals into fresh variables *)
420            val (loadCFG, env) = loadGlobals VMap.empty            val (loadCFG, env) = loadGlobals VMap.empty
421            val S.C_Create{argInit, name, args} = create          (* convert the code *)
422            fun cvtIter ({param, lo, hi}, (env, iters)) = let            val (cfg, _) = cvtBlock (([], []), env, [], code)
                 val param' = newVar param  
                 val env = VMap.insert (env, param, param')  
                 val iter = (param', lookup env lo, lookup env hi)  
                 in  
                   (env, iter::iters)  
                 end  
           val (cfg, env) = cvtFragmentBlock (env, loadCFG, rangeInit)  
           val (env, iters) = List.foldl cvtIter (env, []) iters  
           val (argInitCFG, env) = cvtFragmentBlock (env, IR.CFG.empty, argInit)  
423            in            in
424              IR.Initially{              IR.Initially{
425                  isArray = isArray,                  isArray = isArray,
# Line 472  Line 446 
446    
447      fun cvtInputs (inputInit, inputs) = let      fun cvtInputs (inputInit, inputs) = let
448            val (initBlk, env) = cvtBlock (([], []), VMap.empty, [], inputInit)            val (initBlk, env) = cvtBlock (([], []), VMap.empty, [], inputInit)
449              fun cvt (S.INP{var, desc, init}, (gvs, stms)) = let
450                    val name = SV.nameOf var
451                    val var' = newVar var
452                    val ty' = IR.Var.ty var'
453                    val gVar = IR.GlobalVar.new(true, name, ty')
454                    val rhs = (case init
455                           of S.NoDefault =>
456                                Op.Input(Inp.INP{ty = ty', name = name, desc = desc, init = NONE})
457                            | S.ConstExpr => ??
458                            | S.LoadSeq nrrd => ??
459                            | S.Proxy(nrrd, info) => ??
460                            | S.Image info =>
461                                Op.InputWithDefault(Inp.INP{
462                                })
463                          (* end case *))
464                    val stms = IR.ASSGN(var', rhs) :: IR.GASSGN(gVar, var') :: stms
465                    in
466                      ((var, gVar)::gvs, stms)
467                    end
468            fun cvt ((x, inp), (gvs, stms)) = let            fun cvt ((x, inp), (gvs, stms)) = let
469                  val x' = newVar x                  val x' = newVar x
470                  val gx = IR.GlobalVar.new(                  val gx = IR.GlobalVar.new(

Legend:
Removed from v.3492  
changed lines
  Added in v.3493

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