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

SCM Repository

[smlnj] View of /sml/trunk/src/MLRISC/flowgraph/cfgExpandCopies.sml
ViewVC logotype

View of /sml/trunk/src/MLRISC/flowgraph/cfgExpandCopies.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1016 - (download) (annotate)
Tue Jan 15 23:10:06 2002 UTC (17 years, 5 months ago) by george
File size: 1104 byte(s)
1. Since COPY instructions are no longer native to the architecture,
   a generic functor can be used to implement the expandCopies function.

2. Allowed EXPORT and IMPORT pseudo-op declarations to appear inside a
   TEXT segment.
(* cfgExpandCopies.sml
 *
 * COPYRIGHT (c) 2001 Bell Labs, Lucent Technologies
 *
 * This module expands all parallel copies into normal instructions
 *)

functor CFGExpandCopies
   (structure CFG    : CONTROL_FLOW_GRAPH
    structure Shuffle : SHUFFLE
    			where I = CFG.I
   ) : CFG_OPTIMIZATION =
  struct
    structure CFG = CFG
    structure I = CFG.I

    val name = "expand copies"

    fun run (cfg as Graph.GRAPH graph) = let
      fun expand(I.COPY{k,  dst, src, tmp, ...}) = let
	    val shuffle = 
		case k 
                  of CellsBasis.GP => Shuffle.shuffle 
                   | CellsBasis.FP => Shuffle.shufflefp
		   | _ =>  MLRiscErrorMsg.error ("CFGExpandCopies", "shuffle")
          in shuffle{dst=dst, src=src, tmp=tmp}
          end
	| expand(I.ANNOTATION{i,a}) = 
	    map (fn i => I.ANNOTATION{i=i, a=a}) (expand i)
	| expand i = [i]
      
      fun expandInstrs(_, CFG.BLOCK{insns, ...}) = 
	  insns := 
	    List.foldr 
	      (fn (i, rest) => List.revAppend(expand(i), rest))
	      []
	      (!insns)
    in
      #forall_nodes graph expandInstrs;
      cfg
    end
end

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