//===-- ModuloScheduling.cpp - ModuloScheduling ----------------*- C++ -*-===////// The LLVM Compiler Infrastructure//// This file was developed by the LLVM research group and is distributed under// the University of Illinois Open Source License. See LICENSE.TXT for details.////===----------------------------------------------------------------------===////// ////===----------------------------------------------------------------------===//#define DEBUG_TYPE "ModuloSched"#include"ModuloScheduling.h"#include"llvm/CodeGen/MachineFunction.h"#include"llvm/CodeGen/Passes.h"#include"llvm/Support/CFG.h"#include"llvm/Target/TargetSchedInfo.h"#include"Support/Debug.h"#include"Support/GraphWriter.h"#include"Support/StringExtras.h"#include<vector>#include<utility>#include<iostream>#include<fstream>#include<sstream>usingnamespacellvm;/// Create ModuloSchedulingPass///FunctionPass*llvm::createModuloSchedulingPass(TargetMachine&targ){DEBUG(std::cerr<<"Created ModuloSchedulingPass\n");returnnewModuloSchedulingPass(targ);}template<typenameGraphType>staticvoidWriteGraphToFile(std::ostream&O,conststd::string&GraphName,constGraphType>){std::stringFilename=GraphName+".dot";O<<"Writing '"<<Filename<<"'...";std::ofstreamF(Filename.c_str());if(F.good())WriteGraph(F,GT);elseO<<" error opening file for writing!";O<<"\n";};namespacellvm{template<>structDOTGraphTraits<MSchedGraph*>:publicDefaultDOTGraphTraits{staticstd::stringgetGraphName(MSchedGraph*F){return"Dependence Graph";}staticstd::stringgetNodeLabel(MSchedGraphNode*Node,MSchedGraph*Graph){if(Node->getInst()){std::stringstreamss;ss<<*(Node->getInst());returnss.str();//((MachineInstr*)Node->getInst());}elsereturn"No Inst";}staticstd::stringgetEdgeSourceLabel(MSchedGraphNode*Node,MSchedGraphNode::succ_iteratorI){//Label each edge with the type of dependencestd::stringedgelabel="";switch(I.getEdge().getDepOrderType()){caseMSchedGraphEdge::TrueDep:edgelabel="True";break;caseMSchedGraphEdge::AntiDep:edgelabel="Anti";break;caseMSchedGraphEdge::OutputDep:edgelabel="Output";break;default:edgelabel="Unknown";break;}//FIXMEintiteDiff=I.getEdge().getIteDiff();std::stringintStr="(IteDiff: ";intStr