diff options
author | Chris Lattner <sabre@nondot.org> | 2001-06-20 19:27:11 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2001-06-20 19:27:11 +0000 |
commit | d213f0f3a1bdaab212c15714f76d6e0babf8c57f (patch) | |
tree | 4cb8e3c09384ca9d606f6896e10ab7f5cdd47b7e /lib/Transforms | |
parent | 113b2ffd353acc93cb61b4e7b2daa3b5acf78ac6 (diff) | |
download | external_llvm-d213f0f3a1bdaab212c15714f76d6e0babf8c57f.zip external_llvm-d213f0f3a1bdaab212c15714f76d6e0babf8c57f.tar.gz external_llvm-d213f0f3a1bdaab212c15714f76d6e0babf8c57f.tar.bz2 |
Add a test case for interval code
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms')
-rw-r--r-- | lib/Transforms/Scalar/InductionVars.cpp | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/lib/Transforms/Scalar/InductionVars.cpp b/lib/Transforms/Scalar/InductionVars.cpp new file mode 100644 index 0000000..a4bb983 --- /dev/null +++ b/lib/Transforms/Scalar/InductionVars.cpp @@ -0,0 +1,44 @@ +//===- InductionVars.cpp - Induction Variable Cannonicalization code --------=// +// +// This file implements induction variable cannonicalization of loops. +// +// Specifically, after this executes, the following is true: +// - There is a single induction variable for each loop (that used to contain +// at least one induction variable) +// - This induction variable starts at 0 and steps by 1 per iteration +// - All other preexisting induction variables are adjusted to operate in +// terms of this primary induction variable +// +//===----------------------------------------------------------------------===// + +#include "llvm/Analysis/Intervals.h" +#include "llvm/Opt/AllOpts.h" +#include "llvm/Assembly/Writer.h" + +static void PrintIntervalInfo(cfg::Interval *I) { + cerr << "-------------------------------------------------------------\n" + << "Interval Contents:\n"; + + // Print out all of the basic blocks in the interval... + copy(I->Nodes.begin(), I->Nodes.end(), + ostream_iterator<BasicBlock*>(cerr, "\n")); + + cerr << "Interval Predecessors:\n"; + copy(I->Predecessors.begin(), I->Predecessors.end(), + ostream_iterator<BasicBlock*>(cerr, "\n")); + + cerr << "Interval Successors:\n"; + copy(I->Successors.begin(), I->Successors.end(), + ostream_iterator<BasicBlock*>(cerr, "\n")); +} + +// DoInductionVariableCannonicalize - Simplify induction variables in loops +// +bool DoInductionVariableCannonicalize(Method *M) { + cfg::IntervalPartition Intervals(M); + + // This currently just prints out information about the interval structure + // of the method... + for_each(Intervals.begin(), Intervals.end(), PrintIntervalInfo); + return false; +} |