enableUnrollIfLinear();   FieldInitMover.moveStreamInitialAssignments(str);   System.err.print("Running Constant Prop and Unroll... "); ConstantProp.propagateAndUnroll(str); System.err.println("done.");   if (KjcOptions.poptopeek) { System.err.print("Converting pop to peek... "); PopToPeek.removeAllPops(str); ConstantProp.propagateAndUnroll(str); System.err.println("done."); }   ConstructSIRTree.doit(str); INIT_STATEMENTS_RESOLVED = true;
flattenBeforePartition(str);
    public static void flatten(SIRStream str,			       JInterfaceDeclaration[] 			       interfaces,			       SIRInterfaceTable[]			       interfaceTables,			       SIRStructure[] structs) {	/* DEBUGGING PRINTING        System.out.println("--------- ON ENTRY TO FLATTENER ----------------");	SIRPrinter printer1 = new SIRPrinter();	IterFactory.createIter(str).accept(printer1);	printer1.close();	*/	enableUnrollIfLinear();	// move field initializations into init function	FieldInitMover.moveStreamInitialAssignments(str);		// propagate constants and unroll loops	System.err.print("Running Constant Prop and Unroll... ");	ConstantProp.propagateAndUnroll(str);	System.err.println("done.");	// Convert Peeks to Pops	if (KjcOptions.poptopeek) {	    System.err.print("Converting pop to peek... ");	    PopToPeek.removeAllPops(str);	    ConstantProp.propagateAndUnroll(str);	    System.err.println("done.");	}		// construct stream hierarchy from SIRInitStatements	ConstructSIRTree.doit(str);	INIT_STATEMENTS_RESOLVED = true;	// dump the original graph to a dot format	StreamItDot.printGraph(str, "before.dot");	if (KjcOptions.fusion) {	    System.err.print("Running FuseAll...");	    FuseAll.fuse(str);	    System.err.println("done.");	}	if (KjcOptions.partition || KjcOptions.ilppartition || KjcOptions.dppartition) {	    System.err.print("Partitioning...");	    str = Partitioner.doit(str, 				   KjcOptions.raw * KjcOptions.raw);	    System.err.println("done.");	}	if (KjcOptions.sjtopipe) {	    SJToPipe.doit(str);	}	/* Not general code: Just a test for sync-removal on TwoWeightedRR.java */ 	/* StreamItDot.printGraph(str, "before-syncremov.dot");	SIRPipeline parentPipe = (SIRPipeline)str; 	SyncRemovalSJPair.diffuseSJPair((SIRSplitJoin)parentPipe.get(1), (SIRSplitJoin)parentPipe.get(2)); 	StreamItDot.printGraph(str, "after-syncremov.dot"); */ 	/*	SIRFilter toDuplicate = ((SIRFilter)				 ((SIRPipeline)				  ((SIRPipeline)str).get(1)).get(0));	System.err.println("Trying to duplicate " + toDuplicate);	StatelessDuplicate.doit(toDuplicate, 2);	*/	//Raise NewArray's up to top	System.err.print("Raising variable declarations... ");	new VarDeclRaiser().raiseVars(str);	System.err.println("done.");		/* aal -- changed so that the default action is to do field prop.	 * turn off field prop using --nofieldprop or -L */	// do constant propagation on fields        if (KjcOptions.nofieldprop) {	} else {	    System.err.print("Propagating constant fields... ");	    FieldProp.doPropagate(str);	    System.err.println("done.");	}	/* dzm -- note phase ordering issue here.  In particular, we	 * probably want to form filter phases before fusing the world, but we need	 * to run field prop before forming phases. */	// resolve phases in phased filters	FilterPhaser.resolvePhasedFilters(str);            	// move field initializations into init function	System.err.print("Moving initial assignments... ");	FieldInitMover.moveStreamInitialAssignments(str);	System.err.println("done.");	/* DEBUGGING PRINTING	System.out.println("--------- AFTER CONSTANT PROP / FUSION --------");	printer1 = new SIRPrinter();	IterFactory.createIter(str).accept(printer1);	printer1.close();	*/		if (KjcOptions.nofieldprop) {	} else {	    //Flatten Blocks	    System.err.print("Flattening blocks... ");	    new BlockFlattener().flattenBlocks(str);	    System.err.println("done.");	    //Analyze Branches	    //System.err.print("Analyzing branches... ");	    //new BranchAnalyzer().analyzeBranches(str);	    //System.err.println("done.");	}	//Destroys arrays into local variables if possible	//System.err.print("Destroying arrays... ");	//new ArrayDestroyer().destroyArrays(str);	//System.err.println("done.");	//Raise variables to the top of their block	System.err.print("Raising variables... ");	new VarDeclRaiser().raiseVars(str);	System.err.println("done.");	str = doLinearAnalysis(str);	// dump the partitioned graph to a dot format	StreamItDot.printGraph(str, "after.dot");	// if we have don't have a container, wrap it in a pipeline	// for the sake of SIRScheduler.	if (!(str instanceof SIRContainer)) {	    str = SIRContainer.makeWrapper(str);	}	// make single structure	SIRIterator iter = IterFactory.createIter(str);	System.err.print("Structuring... ");	JClassDeclaration flatClass = Structurer.structure(iter,							   interfaces,							   interfaceTables,                                                           structs);	System.err.println("done.");	// optionally print a version of the source code that we're	// sending to the scheduler	if (KjcOptions.print_partitioned_source) {	    new streamit.scheduler2.print.PrintProgram().printProgram(IterFactory.createIter(str));	}	// build schedule as set of higher-level work functions	System.err.print("Scheduling... ");	SIRSchedule schedule = SIRScheduler.buildWorkFunctions((SIRContainer)str, flatClass);	System.err.println("done.");	// add LIR hooks to init and work functions	System.err.print("Annotating IR for uniprocessor... ");	LowerInitFunctions.lower(iter, schedule);        LowerWorkFunctions.lower(iter);	System.err.println("done.");	/* DEBUGGING PRINTING	System.out.println("----------- AFTER FLATTENER ------------------");	IRPrinter printer = new IRPrinter();	flatClass.accept(printer);	printer.close();	*/	System.err.println("Generating code...");	LIRToC.generateCode(flatClass);	//System.err.println("done.");    }