diff options
author | Chris Lattner <sabre@nondot.org> | 2001-11-26 18:53:29 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2001-11-26 18:53:29 +0000 |
commit | 34dfe56c1a6d63deb8364efbe88fc7c0aee31d0d (patch) | |
tree | 991e4d6c5a55a25b1e43e3e84cc76e9641d7db73 /llvm/lib/Analysis/Writer.cpp | |
parent | b4a7eb10fa7f3a176aae30ed2112595f4034968a (diff) | |
download | bcm5719-llvm-34dfe56c1a6d63deb8364efbe88fc7c0aee31d0d.tar.gz bcm5719-llvm-34dfe56c1a6d63deb8364efbe88fc7c0aee31d0d.zip |
Implement writer support for Loops, Induction Variables, and CallGraphs
llvm-svn: 1372
Diffstat (limited to 'llvm/lib/Analysis/Writer.cpp')
-rw-r--r-- | llvm/lib/Analysis/Writer.cpp | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/llvm/lib/Analysis/Writer.cpp b/llvm/lib/Analysis/Writer.cpp index 6fce54a8288..3d9134f0dc4 100644 --- a/llvm/lib/Analysis/Writer.cpp +++ b/llvm/lib/Analysis/Writer.cpp @@ -8,6 +8,8 @@ #include "llvm/Analysis/Writer.h" #include "llvm/Analysis/IntervalPartition.h" #include "llvm/Analysis/Dominators.h" +#include "llvm/Analysis/LoopInfo.h" +#include "llvm/Analysis/InductionVariable.h" #include <iterator> #include <algorithm> @@ -95,3 +97,52 @@ void cfg::WriteToOutput(const DominanceFrontier &DF, ostream &o) { } } + +//===----------------------------------------------------------------------===// +// Loop Printing Routines +//===----------------------------------------------------------------------===// + +void cfg::WriteToOutput(const Loop *L, ostream &o) { + o << string(L->getLoopDepth()*2, ' ') << "Loop Containing: "; + + for (unsigned i = 0; i < L->getBlocks().size(); ++i) { + if (i) o << ","; + WriteAsOperand(o, (const Value*)L->getBlocks()[i]); + } + o << endl; + + copy(L->getSubLoops().begin(), L->getSubLoops().end(), + ostream_iterator<const Loop*>(o, "\n")); +} + +void cfg::WriteToOutput(const LoopInfo &LI, ostream &o) { + copy(LI.getTopLevelLoops().begin(), LI.getTopLevelLoops().end(), + ostream_iterator<const Loop*>(o, "\n")); +} + + + +//===----------------------------------------------------------------------===// +// Induction Variable Printing Routines +//===----------------------------------------------------------------------===// + +void WriteToOutput(const InductionVariable &IV, ostream &o) { + switch (IV.InductionType) { + case InductionVariable::Cannonical: o << "Cannonical "; break; + case InductionVariable::SimpleLinear: o << "SimpleLinear "; break; + case InductionVariable::Linear: o << "Linear "; break; + case InductionVariable::Unknown: o << "Unrecognized "; break; + } + o << "Induction Variable"; + if (IV.Phi) { + WriteAsOperand(o, (const Value*)IV.Phi); + o << ":\n" << (const Value*)IV.Phi; + } else { + o << endl; + } + if (IV.InductionType == InductionVariable::Unknown) return; + + o << " Start ="; WriteAsOperand(o, IV.Start); + o << " Step =" ; WriteAsOperand(o, IV.Step); + o << endl; +} |