Home My Page Projects Code Snippets Project Openings SML/NJ
Summary Activity Forums Tracker Lists Tasks Docs Surveys News SCM Files

SCM Repository

[smlnj] Diff of /sml/trunk/src/MLRISC/backpatch/spanDep.sml
ViewVC logotype

Diff of /sml/trunk/src/MLRISC/backpatch/spanDep.sml

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

revision 1269, Mon Oct 7 15:01:02 2002 UTC revision 1270, Thu Oct 10 14:48:48 2002 UTC
# Line 18  Line 18 
18                          where I = CFG.I                          where I = CFG.I
19       structure Props     : INSN_PROPERTIES       structure Props     : INSN_PROPERTIES
20                          where I = CFG.I                          where I = CFG.I
21         structure Asm        : INSTRUCTION_EMITTER
22                                 where I = CFG.I
23                                 and   S = Emitter.S
24       ) : BBSCHED =       ) : BBSCHED =
25  struct  struct
26    
# Line 423  Line 426 
426      in if changed then fixpoint zl (i+1) else size      in if changed then fixpoint zl (i+1) else size
427      end      end
428    
     val E.S.STREAM{defineLabel,pseudoOp,emit,beginCluster,...} =  
         E.makeStream []  
   
429      val debug = MLRiscControl.mkFlag ("dump-cfg-after-spandep",      val debug = MLRiscControl.mkFlag ("dump-cfg-after-spandep",
430                                        "whether flow graph is shown after spandep phase")                                        "whether flow graph is shown after spandep phase")
431    
432      fun emitCluster (CLUSTER{comp},loc) = let      fun emitAllClusters
433        val emitInstrs = app emit           (E.S.STREAM{defineLabel, pseudoOp, emit, beginCluster, ...})
434               size compressed =
435        let
436            fun emitCluster (CLUSTER{comp},loc) =
437            let val emitInstrs = app emit
438        fun nops 0 = ()        fun nops 0 = ()
439          | nops n = if n < 0 then error "nops" else (emit(Props.nop()); nops(n-4))                      | nops n =
440                    if n < 0 then error "nops" else (emit(Props.nop()); nops(n-4))
441    
442        fun process(PSEUDO pOp,loc) = (pseudoOp pOp; loc+P.sizeOf(pOp,loc))        fun process(PSEUDO pOp,loc) = (pseudoOp pOp; loc+P.sizeOf(pOp,loc))
443          | process(LABEL lab,loc) = let                | process(LABEL lab,loc) =
444              val addr = Label.addrOf lab                  let val addr = Label.addrOf lab
445            in                  in  if addr = loc then (defineLabel lab; loc)
446              if addr = loc then (defineLabel lab; loc)                      else if addr > loc then
447              else if addr > loc then (nops(addr-loc); defineLabel lab; addr)                            (nops(addr-loc); defineLabel lab; addr)
448              else error "label"              else error "label"
449            end            end
450          | process(CODE(lab,code),loc) = let                | process(CODE(lab,code),loc) =
451              fun e(FIXED{insns, size, ...},loc) = (emitInstrs insns; loc+size)                  let fun e(FIXED{insns, size, ...},loc) =
452                              (emitInstrs insns; loc+size)
453                | e(SDI{size, insn},loc) =                | e(SDI{size, insn},loc) =
454                    (emitInstrs(J.expand(insn, !size, loc)); !size + loc)                    (emitInstrs(J.expand(insn, !size, loc)); !size + loc)
455                | e(BRANCH{insn,...},loc) = foldl e loc insn                | e(BRANCH{insn,...},loc) = foldl e loc insn
# Line 455  Line 461 
461            end            end
462      in foldl process loc comp      in foldl process loc comp
463      end      end
464       in
465           beginCluster size;
466           foldl emitCluster 0 compressed
467       end
468    
469      (* The dataList is in reverse order and the clusters are in reverse *)      (* The dataList is in reverse order and the clusters are in reverse *)
470      fun dataCluster([], acc) = CLUSTER{comp=acc}      fun dataCluster([], acc) = CLUSTER{comp=acc}
# Line 463  Line 473 
473        rev (dataCluster(!dataList, []) :: !clusterList) before cleanUp()        rev (dataCluster(!dataList, []) :: !clusterList) before cleanUp()
474    in    in
475       initLabels(compressed);       initLabels(compressed);
476       beginCluster(fixpoint compressed 0);       emitAllClusters (E.makeStream []) (fixpoint compressed 0) compressed;
477       foldl emitCluster 0 compressed;       if !debug then
478            (emitAllClusters (Asm.makeStream []) 0 compressed; ())
479         else ();
480       ()       ()
481    end (*finish*)    end (*finish*)
482  end (* spanDep.sml *)  end (* spanDep.sml *)
483    
484    

Legend:
Removed from v.1269  
changed lines
  Added in v.1270

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