LLVM API Documentation

ScalarEvolutionNormalization.h
Go to the documentation of this file.
00001 //===- llvm/Analysis/ScalarEvolutionNormalization.h - See below -*- C++ -*-===//
00002 //
00003 //                     The LLVM Compiler Infrastructure
00004 //
00005 // This file is distributed under the University of Illinois Open Source
00006 // License. See LICENSE.TXT for details.
00007 //
00008 //===----------------------------------------------------------------------===//
00009 //
00010 // This file defines utilities for working with "normalized" ScalarEvolution
00011 // expressions.
00012 //
00013 // The following example illustrates post-increment uses and how normalized
00014 // expressions help.
00015 //
00016 //   for (i=0; i!=n; ++i) {
00017 //     ...
00018 //   }
00019 //   use(i);
00020 //
00021 // While the expression for most uses of i inside the loop is {0,+,1}<%L>, the
00022 // expression for the use of i outside the loop is {1,+,1}<%L>, since i is
00023 // incremented at the end of the loop body. This is inconveient, since it
00024 // suggests that we need two different induction variables, one that starts
00025 // at 0 and one that starts at 1. We'd prefer to be able to think of these as
00026 // the same induction variable, with uses inside the loop using the
00027 // "pre-incremented" value, and uses after the loop using the
00028 // "post-incremented" value.
00029 //
00030 // Expressions for post-incremented uses are represented as an expression
00031 // paired with a set of loops for which the expression is in "post-increment"
00032 // mode (there may be multiple loops).
00033 //
00034 //===----------------------------------------------------------------------===//
00035 
00036 #ifndef LLVM_ANALYSIS_SCALAREVOLUTIONNORMALIZATION_H
00037 #define LLVM_ANALYSIS_SCALAREVOLUTIONNORMALIZATION_H
00038 
00039 #include "llvm/ADT/SmallPtrSet.h"
00040 
00041 namespace llvm {
00042 
00043 class Instruction;
00044 class DominatorTree;
00045 class Loop;
00046 class ScalarEvolution;
00047 class SCEV;
00048 class Value;
00049 
00050 /// TransformKind - Different types of transformations that
00051 /// TransformForPostIncUse can do.
00052 enum TransformKind {
00053   /// Normalize - Normalize according to the given loops.
00054   Normalize,
00055   /// NormalizeAutodetect - Detect post-inc opportunities on new expressions,
00056   /// update the given loop set, and normalize.
00057   NormalizeAutodetect,
00058   /// Denormalize - Perform the inverse transform on the expression with the
00059   /// given loop set.
00060   Denormalize
00061 };
00062 
00063 /// PostIncLoopSet - A set of loops.
00064 typedef SmallPtrSet<const Loop *, 2> PostIncLoopSet;
00065 
00066 /// TransformForPostIncUse - Transform the given expression according to the
00067 /// given transformation kind.
00068 const SCEV *TransformForPostIncUse(TransformKind Kind,
00069                                    const SCEV *S,
00070                                    Instruction *User,
00071                                    Value *OperandValToReplace,
00072                                    PostIncLoopSet &Loops,
00073                                    ScalarEvolution &SE,
00074                                    DominatorTree &DT);
00075 
00076 }
00077 
00078 #endif