summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Grosser <grosser@fim.uni-passau.de>2011-11-07 12:58:59 +0000
committerTobias Grosser <grosser@fim.uni-passau.de>2011-11-07 12:58:59 +0000
commit76c2e32a8ee74b9c8aea9090f855c39385e11643 (patch)
treec828b0543ffca787ccfa11aed9356cfcb9e6a669
parent120db6b583618352ac4175b6c74d54a0b08be2da (diff)
downloadbcm5719-llvm-76c2e32a8ee74b9c8aea9090f855c39385e11643.tar.gz
bcm5719-llvm-76c2e32a8ee74b9c8aea9090f855c39385e11643.zip
ScopInfo: Extract function getIdForParam()
llvm-svn: 143961
-rwxr-xr-xpolly/include/polly/ScopInfo.h9
-rw-r--r--polly/lib/Analysis/ScopInfo.cpp52
2 files changed, 39 insertions, 22 deletions
diff --git a/polly/include/polly/ScopInfo.h b/polly/include/polly/ScopInfo.h
index 794169a323c..0a00a01606d 100755
--- a/polly/include/polly/ScopInfo.h
+++ b/polly/include/polly/ScopInfo.h
@@ -40,6 +40,7 @@ namespace llvm {
struct isl_map;
struct isl_basic_map;
+struct isl_id;
struct isl_set;
struct isl_space;
struct isl_constraint;
@@ -454,6 +455,14 @@ public:
/// @return The set containing the parameters used in this Scop.
inline const ParamVecType &getParams() const { return Parameters; }
+
+ /// @brief Return the isl_id that represents a certain parameter.
+ ///
+ /// @param Parameter A SCEV that was recognized as a Parameter.
+ ///
+ /// @return The corresponding isl_id or NULL otherwise.
+ isl_id *getIdForParam(const SCEV *Parameter) const;
+
/// @name Parameter Iterators
///
/// These iterators iterate over all parameters of this Scop.
diff --git a/polly/lib/Analysis/ScopInfo.cpp b/polly/lib/Analysis/ScopInfo.cpp
index 9c910f11c6c..e0a3f821c1f 100644
--- a/polly/lib/Analysis/ScopInfo.cpp
+++ b/polly/lib/Analysis/ScopInfo.cpp
@@ -87,28 +87,20 @@ public:
}
isl_pw_aff *visit(const SCEV *scev) {
- // In case the scev is contained in our list of parameters, we do not
- // further analyze this expression, but create a new parameter in the
- // isl_pw_aff. This allows us to treat subexpressions that we cannot
- // translate into an piecewise affine expression, as constant parameters of
- // the piecewise affine expression.
- int i = 0;
- for (Scop::const_param_iterator PI = scop->param_begin(),
- PE = scop->param_end(); PI != PE; ++PI) {
- if (*PI == scev) {
- isl_id *ID = isl_id_alloc(ctx, ("p" + convertInt(i)).c_str(),
- (void *) scev);
- isl_space *Space = isl_space_set_alloc(ctx, 1, NbLoopSpaces);
- Space = isl_space_set_dim_id(Space, isl_dim_param, 0, ID);
-
- isl_set *Domain = isl_set_universe(isl_space_copy(Space));
- isl_aff *Affine = isl_aff_zero_on_domain(
- isl_local_space_from_space(Space));
- Affine = isl_aff_add_coefficient_si(Affine, isl_dim_param, 0, 1);
-
- return isl_pw_aff_alloc(Domain, Affine);
- }
- i++;
+ // In case the scev is a valid parameter, we do not further analyze this
+ // expression, but create a new parameter in the isl_pw_aff. This allows us
+ // to treat subexpressions that we cannot translate into an piecewise affine
+ // expression, as constant parameters of the piecewise affine expression.
+ if (isl_id *Id = scop->getIdForParam(scev)) {
+ isl_space *Space = isl_space_set_alloc(ctx, 1, NbLoopSpaces);
+ Space = isl_space_set_dim_id(Space, isl_dim_param, 0, Id);
+
+ isl_set *Domain = isl_set_universe(isl_space_copy(Space));
+ isl_aff *Affine = isl_aff_zero_on_domain(
+ isl_local_space_from_space(Space));
+ Affine = isl_aff_add_coefficient_si(Affine, isl_dim_param, 0, 1);
+
+ return isl_pw_aff_alloc(Domain, Affine);
}
return SCEVVisitor<SCEVAffinator, isl_pw_aff*>::visit(scev);
@@ -854,6 +846,22 @@ void ScopStmt::dump() const { print(dbgs()); }
//===----------------------------------------------------------------------===//
/// Scop class implement
+isl_id *Scop::getIdForParam(const SCEV *Parameter) const {
+ int i = 0;
+
+ for (const_param_iterator PI = param_begin(), PE = param_end(); PI != PE;
+ ++PI) {
+ if (Parameter == *PI) {
+ std::string ParameterName = "p" + convertInt(i);
+ isl_id *id = isl_id_alloc(getIslCtx(), ParameterName.c_str(),
+ (void *) Parameter);
+ return id;
+ }
+ i++;
+ }
+
+ return NULL;
+}
void Scop::buildContext(isl_ctx *IslCtx, ParamSetType *ParamSet) {
isl_space *Space = isl_space_params_alloc(IslCtx, ParamSet->size());
OpenPOWER on IntegriCloud