} // namespace llvm
namespace polly {
+class ScopArrayInfo;
/// @brief LLVM-IR generator for isl_ast_expr[essions]
///
/// @brief A map from isl_ids to llvm::Values.
typedef llvm::MapVector<isl_id *, llvm::AssertingVH<llvm::Value>> IDToValueTy;
+ typedef llvm::MapVector<isl_id *, const ScopArrayInfo *> IDToScopArrayInfoTy;
+
+ /// @brief A map from isl_ids to ScopArrayInfo objects.
+ ///
+ /// This map is used to obtain ScopArrayInfo objects for isl_ids which do not
+ /// carry a ScopArrayInfo object in their user pointer. This is useful if the
+ /// construction of ScopArrayInfo objects happens only after references (e.g.
+ /// in an AST) to an isl_id are generated and the user pointer of the isl_id
+ /// can not be changed any more.
+ ///
+ /// This is useful for external users who just use the IslExprBuilder for
+ /// code generation.
+ IDToScopArrayInfoTy *IDToSAI = nullptr;
+
+ /// @brief Set the isl_id to ScopArrayInfo map.
+ ///
+ /// @param NewIDToSAI The new isl_id to ScopArrayInfo map to use.
+ void setIDToSAI(IDToScopArrayInfoTy *NewIDToSAI) { IDToSAI = NewIDToSAI; }
+
/// @brief Construct an IslExprBuilder.
///
/// @param Builder The IRBuilder used to construct the isl_ast_expr[ession].
BaseId = isl_ast_expr_get_id(BaseExpr);
isl_ast_expr_free(BaseExpr);
- const ScopArrayInfo *SAI = ScopArrayInfo::getFromId(BaseId);
+ const ScopArrayInfo *SAI = nullptr;
+
+ if (IDToSAI)
+ SAI = (*IDToSAI)[BaseId];
+
+ if (!SAI)
+ SAI = ScopArrayInfo::getFromId(BaseId);
+ else
+ isl_id_free(BaseId);
+
+ assert(SAI && "No ScopArrayInfo found for this isl_id.");
+
Base = SAI->getBasePtr();
if (auto NewBase = GlobalMap.lookup(Base))