1 //===-- Analysis/Writer.cpp - Printing routines for analyses -----*- C++ -*--=//
3 // This library file implements analysis result printing support for
4 // llvm/Analysis/Writer.h
6 //===----------------------------------------------------------------------===//
8 #include "llvm/Analysis/Writer.h"
9 #include "llvm/Analysis/Interval.h"
10 #include "llvm/Analysis/Dominators.h"
14 void cfg::WriteToOutput(const Interval *I, ostream &o) {
15 o << "-------------------------------------------------------------\n"
16 << "Interval Contents:\n";
18 // Print out all of the basic blocks in the interval...
19 copy(I->Nodes.begin(), I->Nodes.end(),
20 ostream_iterator<BasicBlock*>(o, "\n"));
22 o << "Interval Predecessors:\n";
23 copy(I->Predecessors.begin(), I->Predecessors.end(),
24 ostream_iterator<BasicBlock*>(o, "\n"));
26 o << "Interval Successors:\n";
27 copy(I->Successors.begin(), I->Successors.end(),
28 ostream_iterator<BasicBlock*>(o, "\n"));
31 ostream &operator<<(ostream &o, const set<const BasicBlock*> &BBs) {
32 copy(BBs.begin(), BBs.end(), ostream_iterator<const BasicBlock*>(o, "\n"));
36 void cfg::WriteToOutput(const DominatorSet &DS, ostream &o) {
37 for (DominatorSet::const_iterator I = DS.begin(), E = DS.end(); I != E; ++I) {
38 o << "=============================--------------------------------\n"
39 << "\nDominator Set For Basic Block\n" << I->first
40 << "-------------------------------\n" << I->second << endl;
45 void cfg::WriteToOutput(const ImmediateDominators &ID, ostream &o) {
46 for (ImmediateDominators::const_iterator I = ID.begin(), E = ID.end();
48 o << "=============================--------------------------------\n"
49 << "\nImmediate Dominator For Basic Block\n" << I->first
50 << "is: \n" << I->second << endl;
55 static ostream &operator<<(ostream &o, const cfg::DominatorTree::Node *Node) {
56 return o << Node->getNode() << "\n------------------------------------------\n";
60 static void PrintDomTree(const cfg::DominatorTree::Node *N, ostream &o,
62 o << "Level #" << Lev << ": " << N;
63 for (cfg::DominatorTree::Node::const_iterator I = N->begin(), E = N->end();
65 PrintDomTree(*I, o, Lev+1);
69 void cfg::WriteToOutput(const DominatorTree &DT, ostream &o) {
70 o << "=============================--------------------------------\n"
71 << "Inorder Dominator Tree:\n";
72 PrintDomTree(DT[DT.getRoot()], o, 1);
75 void cfg::WriteToOutput(const DominanceFrontier &DF, ostream &o) {
76 for (DominanceFrontier::const_iterator I = DF.begin(), E = DF.end();
78 o << "=============================--------------------------------\n"
79 << "\nDominance Frontier For Basic Block\n" << I->first
80 << "is: \n" << I->second << endl;