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/emit/cfgEmit.sml
ViewVC logotype

View of /sml/trunk/src/MLRISC/emit/cfgEmit.sml

Parent Directory Parent Directory | Revision Log Revision Log

Revision 1192 - (download) (annotate)
Wed May 15 14:02:06 2002 UTC (17 years, 4 months ago) by george
File size: 1325 byte(s)
        All pseudo-ops emitted before the first segment declaration
such as TEXT, DATA, and BSS directives are assumed to be global
declarations and are emitted first in the assembly file. This is
useful in a number of situations where one has pseudo-ops that are not
specific to any segment, and also works around the constraint that one
cannot have client pseudo-ops in the TEXT segment.

        Because no segment is associated with these declarations it is
an error to allocate any space or objects before the first segment
directive and an exception will be raised. However, we cannot make
this check for client pseudo-ops.

        These top level declarations are a field in the CFG graph_info.
In theory you can continue to add to this field after the CFG has been
built -- provided you know what you are doing;-)
(* cfgEmit.sml
 * COPYRIGHT (c) 2001 Bell Labs, Lucent Technologies
 * This module takes a flowgraph and an assembly emitter module and 
 * ties them together into one.  The output is sent to AsmStream.
 *  --Allen
 * TODO: Need to check for the REORDER/NOREORDER annotation on
 * blocks and call P.Client.AsmPseudoOps.toString function to
 * print out the appropriate assembler directive. -- Lal.

functor CFGEmit
  (structure E   : INSTRUCTION_EMITTER
		   where I = E.I
		     and P = E.S.P)  : ASSEMBLY_EMITTER = 
  structure CFG = CFG

  fun asmEmit (Graph.GRAPH graph, blocks) = let
	val CFG.INFO{annotations=an, data, decls, ...} = #graph_info graph
	val E.S.STREAM{pseudoOp,defineLabel,emit,annotation,comment,...} = 
             E.makeStream (!an)
	fun emitIt (id, CFG.BLOCK{labels, annotations=a, align, insns, ...}) = (
              case !align of NONE => () | SOME p => (pseudoOp p);
	      List.app defineLabel (!labels); 
	      List.app emitAn (!a);
	      List.app emit (rev (!insns)))
	and emitAn a = if Annotations.toString a = "" then () else annotation(a)
	  List.app emitAn (!an);
	  List.app pseudoOp (rev (!decls));
	  List.app emitIt blocks;
	  List.app pseudoOp (rev (!data))

ViewVC Help
Powered by ViewVC 1.0.0