diff options
author | Johannes Doerfert <doerfert@cs.uni-saarland.de> | 2015-09-30 09:52:08 +0000 |
---|---|---|
committer | Johannes Doerfert <doerfert@cs.uni-saarland.de> | 2015-09-30 09:52:08 +0000 |
commit | ebfd72493cc68b085d3feac59f032acb518f4163 (patch) | |
tree | d3f4ee239a2a7862fdcfd49b0bb305a0f899bf04 | |
parent | ef19ead20efe75b8d9b6d3f61fe2a1ab8eabff5f (diff) | |
download | bcm5719-llvm-ebfd72493cc68b085d3feac59f032acb518f4163.tar.gz bcm5719-llvm-ebfd72493cc68b085d3feac59f032acb518f4163.zip |
[NFC] Extract materialization of parameters
llvm-svn: 248882
-rw-r--r-- | polly/include/polly/CodeGen/IslNodeBuilder.h | 9 | ||||
-rw-r--r-- | polly/lib/CodeGen/IslNodeBuilder.cpp | 29 |
2 files changed, 30 insertions, 8 deletions
diff --git a/polly/include/polly/CodeGen/IslNodeBuilder.h b/polly/include/polly/CodeGen/IslNodeBuilder.h index 2b65c3e3ec2..ad508def63a 100644 --- a/polly/include/polly/CodeGen/IslNodeBuilder.h +++ b/polly/include/polly/CodeGen/IslNodeBuilder.h @@ -117,6 +117,15 @@ protected: /// llvm::Values to new llvm::Values. polly::ValueMapT ValueMap; + /// @brief Materialize code for @p Id if it was not done before. + void materializeValue(__isl_take isl_id *Id); + + /// @brief Materialize parameters of @p Set. + /// + /// @param All If not set only parameters referred to by the constraints in + /// @p Set will be materialized, otherwise all. + void materializeParameters(__isl_take isl_set *Set, bool All); + // Extract the upper bound of this loop // // The isl code generation can generate arbitrary expressions to check if the diff --git a/polly/lib/CodeGen/IslNodeBuilder.cpp b/polly/lib/CodeGen/IslNodeBuilder.cpp index 0797f1e24ff..a0cc896dcc1 100644 --- a/polly/lib/CodeGen/IslNodeBuilder.cpp +++ b/polly/lib/CodeGen/IslNodeBuilder.cpp @@ -814,6 +814,25 @@ void IslNodeBuilder::create(__isl_take isl_ast_node *Node) { llvm_unreachable("Unknown isl_ast_node type"); } +void IslNodeBuilder::materializeValue(isl_id *Id) { + Value *&V = IDToValue[Id]; + + // If the Id is already mapped, skip it. + if (!V) + V = generateSCEV((const SCEV *)isl_id_get_user(Id)); + + isl_id_free(Id); +} + +void IslNodeBuilder::materializeParameters(isl_set *Set, bool All) { + for (unsigned i = 0, e = isl_set_dim(Set, isl_dim_param); i < e; ++i) { + if (!All && !isl_set_involves_dims(Set, isl_dim_param, i, 1)) + continue; + isl_id *Id = isl_set_get_dim_id(Set, isl_dim_param, i); + materializeValue(Id); + } +} + /// @brief Create the actual preload memory access for @p MA. static inline Value *createPreloadLoad(Scop &S, const MemoryAccess &MA, isl_ast_build *Build, @@ -944,14 +963,8 @@ void IslNodeBuilder::preloadInvariantLoads() { void IslNodeBuilder::addParameters(__isl_take isl_set *Context) { - for (unsigned i = 0; i < isl_set_dim(Context, isl_dim_param); ++i) { - isl_id *Id; - - Id = isl_set_get_dim_id(Context, isl_dim_param, i); - IDToValue[Id] = generateSCEV((const SCEV *)isl_id_get_user(Id)); - - isl_id_free(Id); - } + // Materialize values for the parameters of the SCoP. + materializeParameters(Context, /* all */ true); // Generate values for the current loop iteration for all surrounding loops. // |