forked from OSchip/llvm-project
[Polly][Isl] Refactoring IslAstInfo::getBuild() and IslAstInfo::IslAstUserPayload::Build to use isl++. NFC
Polly uses algorithms from the Integer Set Library (isl), which is a library written in C and which is incompatible with the rest of the LLVM as it is written in C++. Changes made: - Refactoring the method `IslAstInfo::getBuild()` - `IslAstInfo::IslAstUserPayload.Build` now uses C++ types instead of C types - Removing destructor of `IslAstInfo::IslAstUserPayload` Reviewed By: Meinersbur Differential Revision: https://reviews.llvm.org/D104370
This commit is contained in:
parent
7670938bba
commit
2a629efc74
|
@ -78,9 +78,6 @@ public:
|
|||
/// Construct and initialize the payload.
|
||||
IslAstUserPayload() = default;
|
||||
|
||||
/// Cleanup all isl structs on destruction.
|
||||
~IslAstUserPayload();
|
||||
|
||||
/// Does the dependence analysis determine that there are no loop-carried
|
||||
/// dependencies?
|
||||
bool IsParallel = false;
|
||||
|
@ -101,7 +98,7 @@ public:
|
|||
isl::pw_aff MinimalDependenceDistance;
|
||||
|
||||
/// The build environment at the time this node was constructed.
|
||||
isl_ast_build *Build = nullptr;
|
||||
isl::ast_build Build;
|
||||
|
||||
/// Set of accesses which break reduction dependences.
|
||||
MemoryAccessSet BrokenReductions;
|
||||
|
@ -164,7 +161,7 @@ public:
|
|||
static MemoryAccessSet *getBrokenReductions(const isl::ast_node &Node);
|
||||
|
||||
/// Get the nodes build context or a nullptr if not available.
|
||||
static __isl_give isl_ast_build *getBuild(__isl_keep isl_ast_node *Node);
|
||||
static isl::ast_build getBuild(const isl::ast_node &Node);
|
||||
|
||||
///}
|
||||
};
|
||||
|
|
|
@ -124,10 +124,6 @@ static void freeIslAstUserPayload(void *Ptr) {
|
|||
delete ((IslAstInfo::IslAstUserPayload *)Ptr);
|
||||
}
|
||||
|
||||
IslAstInfo::IslAstUserPayload::~IslAstUserPayload() {
|
||||
isl_ast_build_free(Build);
|
||||
}
|
||||
|
||||
/// Print a string @p str in a single line using @p Printer.
|
||||
static isl_printer *printLine(__isl_take isl_printer *Printer,
|
||||
const std::string &str,
|
||||
|
@ -286,8 +282,8 @@ astBuildAfterFor(__isl_take isl_ast_node *Node, __isl_keep isl_ast_build *Build,
|
|||
assert(Payload && "Post order visit assumes annotated for nodes");
|
||||
|
||||
AstBuildUserInfo *BuildInfo = (AstBuildUserInfo *)User;
|
||||
assert(!Payload->Build && "Build environment already set");
|
||||
Payload->Build = isl_ast_build_copy(Build);
|
||||
assert(Payload->Build.is_null() && "Build environment already set");
|
||||
Payload->Build = isl::manage_copy(Build);
|
||||
Payload->IsInnermost = (Id == BuildInfo->LastForNodeId);
|
||||
|
||||
Payload->IsInnermostParallel =
|
||||
|
@ -333,7 +329,7 @@ static __isl_give isl_ast_node *AtEachDomain(__isl_take isl_ast_node *Node,
|
|||
isl_id *Id = isl_id_alloc(isl_ast_build_get_ctx(Build), "", Payload);
|
||||
Id = isl_id_set_free_user(Id, freeIslAstUserPayload);
|
||||
|
||||
Payload->Build = isl_ast_build_copy(Build);
|
||||
Payload->Build = isl::manage_copy(Build);
|
||||
|
||||
return isl_ast_node_set_annotation(Node, Id);
|
||||
}
|
||||
|
@ -622,11 +618,7 @@ bool IslAstInfo::isExecutedInParallel(const isl::ast_node &Node) {
|
|||
|
||||
isl::union_map IslAstInfo::getSchedule(const isl::ast_node &Node) {
|
||||
IslAstUserPayload *Payload = getNodePayload(Node);
|
||||
if (!Payload)
|
||||
return {};
|
||||
|
||||
isl::ast_build Build = isl::manage_copy(Payload->Build);
|
||||
return Build.get_schedule();
|
||||
return Payload ? Payload->Build.get_schedule() : isl::union_map();
|
||||
}
|
||||
|
||||
isl::pw_aff
|
||||
|
@ -641,9 +633,9 @@ IslAstInfo::getBrokenReductions(const isl::ast_node &Node) {
|
|||
return Payload ? &Payload->BrokenReductions : nullptr;
|
||||
}
|
||||
|
||||
isl_ast_build *IslAstInfo::getBuild(__isl_keep isl_ast_node *Node) {
|
||||
IslAstUserPayload *Payload = getNodePayload(isl::manage_copy(Node));
|
||||
return Payload ? Payload->Build : nullptr;
|
||||
isl::ast_build IslAstInfo::getBuild(const isl::ast_node &Node) {
|
||||
IslAstUserPayload *Payload = getNodePayload(Node);
|
||||
return Payload ? Payload->Build : isl::ast_build();
|
||||
}
|
||||
|
||||
static std::unique_ptr<IslAstInfo> runIslAst(
|
||||
|
@ -706,7 +698,7 @@ static __isl_give isl_printer *cbPrintUser(__isl_take isl_printer *P,
|
|||
else
|
||||
P = isl_printer_print_str(P, "/* write */ ");
|
||||
|
||||
isl::ast_build Build = isl::manage_copy(IslAstInfo::getBuild(Node));
|
||||
isl::ast_build Build = IslAstInfo::getBuild(isl::manage_copy(Node));
|
||||
if (MemAcc->isAffine()) {
|
||||
isl_pw_multi_aff *PwmaPtr =
|
||||
MemAcc->applyScheduleToAccessRelation(Build.get_schedule()).release();
|
||||
|
|
|
@ -850,12 +850,12 @@ void IslNodeBuilder::createIf(__isl_take isl_ast_node *If) {
|
|||
__isl_give isl_id_to_ast_expr *
|
||||
IslNodeBuilder::createNewAccesses(ScopStmt *Stmt,
|
||||
__isl_keep isl_ast_node *Node) {
|
||||
isl_id_to_ast_expr *NewAccesses =
|
||||
isl_id_to_ast_expr_alloc(Stmt->getParent()->getIslCtx().get(), 0);
|
||||
isl::id_to_ast_expr NewAccesses =
|
||||
isl::id_to_ast_expr::alloc(Stmt->getParent()->getIslCtx(), 0);
|
||||
|
||||
auto *Build = IslAstInfo::getBuild(Node);
|
||||
assert(Build && "Could not obtain isl_ast_build from user node");
|
||||
Stmt->setAstBuild(isl::manage_copy(Build));
|
||||
isl::ast_build Build = IslAstInfo::getBuild(isl::manage_copy(Node));
|
||||
assert(!Build.is_null() && "Could not obtain isl_ast_build from user node");
|
||||
Stmt->setAstBuild(Build);
|
||||
|
||||
for (auto *MA : *Stmt) {
|
||||
if (!MA->hasNewAccessRelation()) {
|
||||
|
@ -876,13 +876,12 @@ IslNodeBuilder::createNewAccesses(ScopStmt *Stmt,
|
|||
assert(MA->isAffine() &&
|
||||
"Only affine memory accesses can be code generated");
|
||||
|
||||
auto Schedule = isl_ast_build_get_schedule(Build);
|
||||
isl::union_map Schedule = Build.get_schedule();
|
||||
|
||||
#ifndef NDEBUG
|
||||
if (MA->isRead()) {
|
||||
auto Dom = Stmt->getDomain().release();
|
||||
auto SchedDom = isl_set_from_union_set(
|
||||
isl_union_map_domain(isl_union_map_copy(Schedule)));
|
||||
auto SchedDom = isl_set_from_union_set(Schedule.domain().release());
|
||||
auto AccDom = isl_map_domain(MA->getAccessRelation().release());
|
||||
Dom = isl_set_intersect_params(Dom,
|
||||
Stmt->getParent()->getContext().release());
|
||||
|
@ -898,25 +897,20 @@ IslNodeBuilder::createNewAccesses(ScopStmt *Stmt,
|
|||
}
|
||||
#endif
|
||||
|
||||
auto PWAccRel =
|
||||
MA->applyScheduleToAccessRelation(isl::manage(Schedule)).release();
|
||||
isl::pw_multi_aff PWAccRel = MA->applyScheduleToAccessRelation(Schedule);
|
||||
|
||||
// isl cannot generate an index expression for access-nothing accesses.
|
||||
isl::set AccDomain =
|
||||
isl::manage(isl_pw_multi_aff_domain(isl_pw_multi_aff_copy(PWAccRel)));
|
||||
isl::set AccDomain = PWAccRel.domain();
|
||||
isl::set Context = S.getContext();
|
||||
AccDomain = AccDomain.intersect_params(Context);
|
||||
if (AccDomain.is_empty()) {
|
||||
isl_pw_multi_aff_free(PWAccRel);
|
||||
if (AccDomain.is_empty())
|
||||
continue;
|
||||
}
|
||||
|
||||
auto AccessExpr = isl_ast_build_access_from_pw_multi_aff(Build, PWAccRel);
|
||||
NewAccesses =
|
||||
isl_id_to_ast_expr_set(NewAccesses, MA->getId().release(), AccessExpr);
|
||||
isl::ast_expr AccessExpr = Build.access_from(PWAccRel);
|
||||
NewAccesses = NewAccesses.set(MA->getId(), AccessExpr);
|
||||
}
|
||||
|
||||
return NewAccesses;
|
||||
return NewAccesses.release();
|
||||
}
|
||||
|
||||
void IslNodeBuilder::createSubstitutions(__isl_take isl_ast_expr *Expr,
|
||||
|
|
Loading…
Reference in New Issue