aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Analysis/ScalarEvolutionNormalization.cpp
diff options
context:
space:
mode:
authorSanjoy Das <sanjoy@playingwithpointers.com>2017-04-14 15:49:59 +0000
committerSanjoy Das <sanjoy@playingwithpointers.com>2017-04-14 15:49:59 +0000
commite3a15e832cd1f62a51a734a0d083d51db4127494 (patch)
treec0e6ef903eacab99e56d670587f76ab6dbdac125 /llvm/lib/Analysis/ScalarEvolutionNormalization.cpp
parentac9f3ea0b437d881bc9879601b0777139b9fd864 (diff)
downloadllvm-e3a15e832cd1f62a51a734a0d083d51db4127494.zip
llvm-e3a15e832cd1f62a51a734a0d083d51db4127494.tar.gz
llvm-e3a15e832cd1f62a51a734a0d083d51db4127494.tar.bz2
Tighten the API for ScalarEvolutionNormalization
llvm-svn: 300331
Diffstat (limited to 'llvm/lib/Analysis/ScalarEvolutionNormalization.cpp')
-rw-r--r--llvm/lib/Analysis/ScalarEvolutionNormalization.cpp40
1 files changed, 34 insertions, 6 deletions
diff --git a/llvm/lib/Analysis/ScalarEvolutionNormalization.cpp b/llvm/lib/Analysis/ScalarEvolutionNormalization.cpp
index becc4bb..8923727 100644
--- a/llvm/lib/Analysis/ScalarEvolutionNormalization.cpp
+++ b/llvm/lib/Analysis/ScalarEvolutionNormalization.cpp
@@ -19,19 +19,29 @@ using namespace llvm;
namespace {
+/// TransformKind - Different types of transformations that
+/// TransformForPostIncUse can do.
+enum TransformKind {
+ /// Normalize - Normalize according to the given loops.
+ Normalize,
+ /// Denormalize - Perform the inverse transform on the expression with the
+ /// given loop set.
+ Denormalize
+};
+
/// Hold the state used during post-inc expression transformation, including a
/// map of transformed expressions.
class PostIncTransform {
TransformKind Kind;
Optional<NormalizePredTy> Pred;
- PostIncLoopSet &Loops;
+ const PostIncLoopSet &Loops;
ScalarEvolution &SE;
DenseMap<const SCEV*, const SCEV*> Transformed;
public:
PostIncTransform(TransformKind kind, Optional<NormalizePredTy> Pred,
- PostIncLoopSet &loops, ScalarEvolution &se)
+ const PostIncLoopSet &loops, ScalarEvolution &se)
: Kind(kind), Pred(Pred), Loops(loops), SE(se) {}
const SCEV *TransformSubExpr(const SCEV *S);
@@ -160,10 +170,28 @@ const SCEV *PostIncTransform::TransformSubExpr(const SCEV *S) {
/// Top level driver for transforming an expression DAG into its requested
/// post-inc form (either "Normalized" or "Denormalized").
-const SCEV *llvm::TransformForPostIncUse(TransformKind Kind, const SCEV *S,
- Optional<NormalizePredTy> Pred,
- PostIncLoopSet &Loops,
- ScalarEvolution &SE) {
+static const SCEV *TransformForPostIncUse(TransformKind Kind, const SCEV *S,
+ Optional<NormalizePredTy> Pred,
+ const PostIncLoopSet &Loops,
+ ScalarEvolution &SE) {
PostIncTransform Transform(Kind, Pred, Loops, SE);
return Transform.TransformSubExpr(S);
}
+
+const SCEV *llvm::normalizeForPostIncUse(const SCEV *S,
+ const PostIncLoopSet &Loops,
+ ScalarEvolution &SE) {
+ return TransformForPostIncUse(Normalize, S, None, Loops, SE);
+}
+
+const SCEV *llvm::normalizeForPostIncUseIf(const SCEV *S, NormalizePredTy Pred,
+ ScalarEvolution &SE) {
+ PostIncLoopSet Empty;
+ return TransformForPostIncUse(Normalize, S, Pred, Empty, SE);
+}
+
+const SCEV *llvm::denormalizeForPostIncUse(const SCEV *S,
+ const PostIncLoopSet &Loops,
+ ScalarEvolution &SE) {
+ return TransformForPostIncUse(Denormalize, S, None, Loops, SE);
+}