LLVM API Documentation

Public Member Functions | Friends
llvm::SCEVExpander Class Reference

#include <ScalarEvolutionExpander.h>

Inheritance diagram for llvm::SCEVExpander:
Inheritance graph
[legend]
Collaboration diagram for llvm::SCEVExpander:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 SCEVExpander (ScalarEvolution &se, const char *name)
 SCEVExpander - Construct a SCEVExpander in "canonical" mode.
void setDebugType (const char *s)
void clear ()
PHINodegetOrInsertCanonicalInductionVariable (const Loop *L, Type *Ty)
InstructiongetIVIncOperand (Instruction *IncV, Instruction *InsertPos, bool allowScale)
 getIVIncOperand - Return the induction variable increment's IV operand.
bool hoistIVInc (Instruction *IncV, Instruction *InsertPos)
 hoistIVInc - Utility for hoisting an IV increment.
unsigned replaceCongruentIVs (Loop *L, const DominatorTree *DT, SmallVectorImpl< WeakVH > &DeadInsts, const TargetTransformInfo *TTI=nullptr)
ValueexpandCodeFor (const SCEV *SH, Type *Ty, Instruction *I)
void setIVIncInsertPos (const Loop *L, Instruction *Pos)
 setIVIncInsertPos - Set the current IV increment loop and position.
void setPostInc (const PostIncLoopSet &L)
void clearPostInc ()
 clearPostInc - Disable all post-inc expansion.
void disableCanonicalMode ()
void enableLSRMode ()
void clearInsertPoint ()
bool isInsertedInstruction (Instruction *I) const
void setChainedPhi (PHINode *PN)

Friends

struct SCEVVisitor< SCEVExpander, Value * >

Detailed Description

SCEVExpander - This class uses information about analyze scalars to rewrite expressions in canonical form.

Clients should create an instance of this class when rewriting is needed, and destroy it when finished to allow the release of the associated memory.

Definition at line 37 of file ScalarEvolutionExpander.h.


Constructor & Destructor Documentation

llvm::SCEVExpander::SCEVExpander ( ScalarEvolution se,
const char *  name 
) [inline, explicit]

SCEVExpander - Construct a SCEVExpander in "canonical" mode.

Definition at line 94 of file ScalarEvolutionExpander.h.


Member Function Documentation

void llvm::SCEVExpander::clear ( ) [inline]

clear - Erase the contents of the InsertedExpressions map so that users trying to expand the same expression into multiple BasicBlocks or different places within the same BasicBlock can do so.

Definition at line 110 of file ScalarEvolutionExpander.h.

clearInsertPoint - Clear the current insertion point. This is useful if the instruction that had been serving as the insertion point may have been deleted.

Definition at line 177 of file ScalarEvolutionExpander.h.

References llvm::IRBuilderBase::ClearInsertionPoint().

clearPostInc - Disable all post-inc expansion.

Definition at line 159 of file ScalarEvolutionExpander.h.

References llvm::SmallPtrSetImplBase::clear().

disableCanonicalMode - Disable the behavior of expanding expressions in canonical form rather than in a more literal form. Non-canonical mode is useful for late optimization passes.

Definition at line 170 of file ScalarEvolutionExpander.h.

Definition at line 172 of file ScalarEvolutionExpander.h.

expandCodeFor - Insert code to directly compute the specified SCEV expression into the program. The inserted code is inserted into the specified block.

Definition at line 1582 of file ScalarEvolutionExpander.cpp.

References llvm::Instruction::getParent(), and llvm::IRBuilderBase::SetInsertPoint().

Referenced by genLoopLimit(), and getOrInsertCanonicalInductionVariable().

Instruction * SCEVExpander::getIVIncOperand ( Instruction IncV,
Instruction InsertPos,
bool  allowScale 
)

getIVIncOperand - Return the induction variable increment's IV operand.

getIVIncOperand returns an induction variable increment's induction variable operand.

If allowScale is set, any type of GEP is allowed as long as the nonIV operands dominate InsertPos.

If allowScale is not set, ensure that a GEP increment conforms to one of the simple patterns generated by getAddRecExprPHILiterally and expandAddtoGEP. If the pattern isn't recognized, return NULL.

Definition at line 892 of file ScalarEvolutionExpander.cpp.

References llvm::DominatorTree::dominates(), llvm::dyn_cast(), llvm::ScalarEvolution::getContext(), llvm::Type::getInt1PtrTy(), llvm::Type::getInt8PtrTy(), llvm::User::getNumOperands(), llvm::Instruction::getOpcode(), llvm::User::getOperand(), llvm::Value::getType(), I, llvm::User::op_begin(), and llvm::User::op_end().

Referenced by hoistIVInc().

getOrInsertCanonicalInductionVariable - This method returns the canonical induction variable of the specified type for the specified loop (inserting one if there is none). A canonical induction variable starts at zero and steps by one on each iteration.

Definition at line 1663 of file ScalarEvolutionExpander.cpp.

References llvm::BasicBlock::begin(), expandCodeFor(), llvm::SCEV::FlagAnyWrap, llvm::ScalarEvolution::getAddRecExpr(), llvm::ScalarEvolution::getConstant(), llvm::LoopBase< BlockT, LoopT >::getHeader(), H, and llvm::Type::isIntegerTy().

bool SCEVExpander::hoistIVInc ( Instruction IncV,
Instruction InsertPos 
)

hoistIVInc - Utility for hoisting an IV increment.

hoistStep - Attempt to hoist a simple IV increment above InsertPos to make it available to other uses in this loop. Recursively hoist any operands, until we reach a value that dominates InsertPos.

Definition at line 943 of file ScalarEvolutionExpander.cpp.

References llvm::DominatorTree::dominates(), getIVIncOperand(), llvm::Instruction::getParent(), I, llvm::Instruction::moveBefore(), llvm::SmallVectorTemplateBase< T, isPodLike >::push_back(), llvm::SmallVectorTemplateCommon< T, typename >::rbegin(), and llvm::SmallVectorTemplateCommon< T, typename >::rend().

Referenced by replaceCongruentIVs().

isInsertedInstruction - Return true if the specified instruction was inserted by the code rewriter. If so, the client should not modify the instruction.

Definition at line 184 of file ScalarEvolutionExpander.h.

replaceCongruentIVs - replace congruent phis with their most canonical representative. Return the number of phis eliminated.

replaceCongruentIVs - Check for congruent phis in this loop header and replace them with their most canonical representative. Return the number of phis eliminated.

This does not depend on any SCEVExpander state but should be used in the same context that SCEVExpander is used.

Definition at line 1686 of file ScalarEvolutionExpander.cpp.

References llvm::SmallVectorTemplateCommon< T >::back(), llvm::SmallVectorTemplateCommon< T >::begin(), llvm::BasicBlock::begin(), llvm::IRBuilder< preserveNames, T, Inserter >::CreateTruncOrBitCast(), llvm::dbgs(), DEBUG_WITH_TYPE, llvm::dyn_cast(), llvm::SmallVectorTemplateCommon< T >::end(), llvm::Instruction::getDebugLoc(), llvm::BasicBlock::getFirstInsertionPt(), llvm::LoopBase< BlockT, LoopT >::getHeader(), llvm::PHINode::getIncomingValueForBlock(), llvm::LoopBase< BlockT, LoopT >::getLoopLatch(), llvm::ilist_node< NodeTy >::getNextNode(), llvm::Type::getPrimitiveSizeInBits(), llvm::ScalarEvolution::getSCEV(), llvm::ScalarEvolution::getTruncateExpr(), llvm::ScalarEvolution::getTruncateOrNoop(), llvm::SCEV::getType(), llvm::Value::getType(), hoistIVInc(), I, llvm::Type::isIntegerTy(), llvm::Type::isPointerTy(), llvm::ScalarEvolution::isSCEVable(), llvm::TargetTransformInfo::isTruncateFree(), llvm::SmallVectorTemplateBase< T, isPodLike< T >::value >::push_back(), llvm::SmallVectorTemplateBase< T, isPodLike >::push_back(), llvm::Value::replaceAllUsesWith(), llvm::IRBuilderBase::SetCurrentDebugLocation(), llvm::SimplifyInstruction(), and std::swap().

void llvm::SCEVExpander::setChainedPhi ( PHINode PN) [inline]

Definition at line 188 of file ScalarEvolutionExpander.h.

void llvm::SCEVExpander::setDebugType ( const char *  s) [inline]

Definition at line 104 of file ScalarEvolutionExpander.h.

void llvm::SCEVExpander::setIVIncInsertPos ( const Loop L,
Instruction Pos 
) [inline]

setIVIncInsertPos - Set the current IV increment loop and position.

Definition at line 142 of file ScalarEvolutionExpander.h.

setPostInc - Enable post-inc expansion for addrecs referring to the given loops. Post-inc expansion is only supported in non-canonical mode.

Definition at line 152 of file ScalarEvolutionExpander.h.


Friends And Related Function Documentation

friend struct SCEVVisitor< SCEVExpander, Value * > [friend]

Definition at line 90 of file ScalarEvolutionExpander.h.


The documentation for this class was generated from the following files: