[polly] r221418 - Extract SCEV generation into subfunction
Tobias Grosser
tobias at grosser.es
Wed Nov 5 16:27:02 PST 2014
Author: grosser
Date: Wed Nov 5 18:27:01 2014
New Revision: 221418
URL: http://llvm.org/viewvc/llvm-project?rev=221418&view=rev
Log:
Extract SCEV generation into subfunction
This makes the code more readable and will be reused in subsequent OpenMP
patches.
Modified:
polly/trunk/lib/CodeGen/IslCodeGeneration.cpp
Modified: polly/trunk/lib/CodeGen/IslCodeGeneration.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/CodeGen/IslCodeGeneration.cpp?rev=221418&r1=221417&r2=221418&view=diff
==============================================================================
--- polly/trunk/lib/CodeGen/IslCodeGeneration.cpp (original)
+++ polly/trunk/lib/CodeGen/IslCodeGeneration.cpp Wed Nov 5 18:27:01 2014
@@ -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
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
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:
More information about the llvm-commits
mailing list