Extract SCEV generation into subfunction

This makes the code more readable and will be reused in subsequent OpenMP
patches.

llvm-svn: 221418
This commit is contained in:
Tobias Grosser 2014-11-06 00:27:01 +00:00
parent 5a29e6aadb
commit ec7d67ede0
1 changed files with 16 additions and 8 deletions
polly/lib/CodeGen

View File

@ -86,6 +86,15 @@ private:
// ivs.
IslExprBuilder::IDToValueTy IDToValue;
/// Generate code for a given SCEV*
///
/// This function generates code for a given SCEV expression. It generated
/// code is emmitted at the end of the basic block our Builder currently
/// points to and the resulting value is returned.
///
/// @param Expr The expression to code generate.
Value *generateSCEV(const SCEV *Expr);
// Extract the upper bound of this loop
//
// The isl code generation can generate arbitrary expressions to check if the
@ -542,16 +551,9 @@ void IslNodeBuilder::addParameters(__isl_take isl_set *Context) {
for (unsigned i = 0; i < isl_set_dim(Context, isl_dim_param); ++i) {
isl_id *Id;
const SCEV *Scev;
IntegerType *T;
Instruction *InsertLocation;
Id = isl_set_get_dim_id(Context, isl_dim_param, i);
Scev = (const SCEV *)isl_id_get_user(Id);
T = dyn_cast<IntegerType>(Scev->getType());
InsertLocation = --(Builder.GetInsertBlock()->end());
Value *V = Rewriter->expandCodeFor(Scev, T, InsertLocation);
IDToValue[Id] = V;
IDToValue[Id] = generateSCEV((const SCEV *)isl_id_get_user(Id));
isl_id_free(Id);
}
@ -559,6 +561,12 @@ void IslNodeBuilder::addParameters(__isl_take isl_set *Context) {
isl_set_free(Context);
}
Value *IslNodeBuilder::generateSCEV(const SCEV *Expr) {
Instruction *InsertLocation = --(Builder.GetInsertBlock()->end());
return Rewriter->expandCodeFor(Expr, cast<IntegerType>(Expr->getType()),
InsertLocation);
}
namespace {
class IslCodeGeneration : public ScopPass {
public: