mirror of
https://github.com/intel/llvm.git
synced 2026-01-18 07:57:36 +08:00
Rebase C++ bindings on top of latest isl bindings
The main difference in this change is that isl_stat is now always checked by default. As we elminiated most used of isl_stat, thanks to Philip Pfaffe's implementation of foreach, only a small set of changes is needed. This change does not include the following recent changes to isl's C++ bindings: - stricter error handling for isl_bool - dropping of the isl::namespace qualifiers The former requires a larger patch in Polly and consequently should go through a patch-review. The latter will be applied in the next commit to keep this commit free from noise. We also still apply a couple of other changes on top of the official isl bindings. This delta is expected to shrink over time. llvm-svn: 338504
This commit is contained in:
1648
polly/lib/External/isl/include/isl/isl-noexceptions.h
vendored
1648
polly/lib/External/isl/include/isl/isl-noexceptions.h
vendored
File diff suppressed because it is too large
Load Diff
@@ -509,40 +509,45 @@ isl::map polly::intersectRange(isl::map Map, isl::union_set Range) {
|
||||
isl::val polly::getConstant(isl::pw_aff PwAff, bool Max, bool Min) {
|
||||
assert(!Max || !Min); // Cannot return min and max at the same time.
|
||||
isl::val Result;
|
||||
PwAff.foreach_piece([=, &Result](isl::set Set, isl::aff Aff) -> isl::stat {
|
||||
if (Result && Result.is_nan())
|
||||
return isl::stat::ok;
|
||||
isl::stat Stat = PwAff.foreach_piece(
|
||||
[=, &Result](isl::set Set, isl::aff Aff) -> isl::stat {
|
||||
if (Result && Result.is_nan())
|
||||
return isl::stat::ok();
|
||||
|
||||
// TODO: If Min/Max, we can also determine a minimum/maximum value if
|
||||
// Set is constant-bounded.
|
||||
if (!Aff.is_cst()) {
|
||||
Result = isl::val::nan(Aff.get_ctx());
|
||||
return isl::stat::error;
|
||||
}
|
||||
// TODO: If Min/Max, we can also determine a minimum/maximum value if
|
||||
// Set is constant-bounded.
|
||||
if (!Aff.is_cst()) {
|
||||
Result = isl::val::nan(Aff.get_ctx());
|
||||
return isl::stat::error();
|
||||
}
|
||||
|
||||
isl::val ThisVal = Aff.get_constant_val();
|
||||
if (!Result) {
|
||||
Result = ThisVal;
|
||||
return isl::stat::ok;
|
||||
}
|
||||
isl::val ThisVal = Aff.get_constant_val();
|
||||
if (!Result) {
|
||||
Result = ThisVal;
|
||||
return isl::stat::ok();
|
||||
}
|
||||
|
||||
if (Result.eq(ThisVal))
|
||||
return isl::stat::ok;
|
||||
if (Result.eq(ThisVal))
|
||||
return isl::stat::ok();
|
||||
|
||||
if (Max && ThisVal.gt(Result)) {
|
||||
Result = ThisVal;
|
||||
return isl::stat::ok;
|
||||
}
|
||||
if (Max && ThisVal.gt(Result)) {
|
||||
Result = ThisVal;
|
||||
return isl::stat::ok();
|
||||
}
|
||||
|
||||
if (Min && ThisVal.lt(Result)) {
|
||||
Result = ThisVal;
|
||||
return isl::stat::ok;
|
||||
}
|
||||
if (Min && ThisVal.lt(Result)) {
|
||||
Result = ThisVal;
|
||||
return isl::stat::ok();
|
||||
}
|
||||
|
||||
// Not compatible
|
||||
Result = isl::val::nan(Aff.get_ctx());
|
||||
return isl::stat::error();
|
||||
});
|
||||
|
||||
if (Stat.is_error())
|
||||
return {};
|
||||
|
||||
// Not compatible
|
||||
Result = isl::val::nan(Aff.get_ctx());
|
||||
return isl::stat::error;
|
||||
});
|
||||
return Result;
|
||||
}
|
||||
|
||||
@@ -551,7 +556,7 @@ static void foreachPoint(const isl::set &Set,
|
||||
const std::function<void(isl::point P)> &F) {
|
||||
Set.foreach_point([&](isl::point P) -> isl::stat {
|
||||
F(P);
|
||||
return isl::stat::ok;
|
||||
return isl::stat::ok();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -75,13 +75,16 @@ isl::union_pw_aff subtract(isl::union_pw_aff UPwAff, isl::val Val) {
|
||||
return UPwAff;
|
||||
|
||||
auto Result = isl::union_pw_aff::empty(UPwAff.get_space());
|
||||
UPwAff.foreach_pw_aff([=, &Result](isl::pw_aff PwAff) -> isl::stat {
|
||||
auto ValAff =
|
||||
isl::pw_aff(isl::set::universe(PwAff.get_space().domain()), Val);
|
||||
auto Subtracted = PwAff.sub(ValAff);
|
||||
Result = Result.union_add(isl::union_pw_aff(Subtracted));
|
||||
return isl::stat::ok;
|
||||
});
|
||||
isl::stat Stat =
|
||||
UPwAff.foreach_pw_aff([=, &Result](isl::pw_aff PwAff) -> isl::stat {
|
||||
auto ValAff =
|
||||
isl::pw_aff(isl::set::universe(PwAff.get_space().domain()), Val);
|
||||
auto Subtracted = PwAff.sub(ValAff);
|
||||
Result = Result.union_add(isl::union_pw_aff(Subtracted));
|
||||
return isl::stat::ok();
|
||||
});
|
||||
if (Stat.is_error())
|
||||
return {};
|
||||
return Result;
|
||||
}
|
||||
|
||||
@@ -91,13 +94,16 @@ isl::union_pw_aff multiply(isl::union_pw_aff UPwAff, isl::val Val) {
|
||||
return UPwAff;
|
||||
|
||||
auto Result = isl::union_pw_aff::empty(UPwAff.get_space());
|
||||
UPwAff.foreach_pw_aff([=, &Result](isl::pw_aff PwAff) -> isl::stat {
|
||||
auto ValAff =
|
||||
isl::pw_aff(isl::set::universe(PwAff.get_space().domain()), Val);
|
||||
auto Multiplied = PwAff.mul(ValAff);
|
||||
Result = Result.union_add(Multiplied);
|
||||
return isl::stat::ok;
|
||||
});
|
||||
isl::stat Stat =
|
||||
UPwAff.foreach_pw_aff([=, &Result](isl::pw_aff PwAff) -> isl::stat {
|
||||
auto ValAff =
|
||||
isl::pw_aff(isl::set::universe(PwAff.get_space().domain()), Val);
|
||||
auto Multiplied = PwAff.mul(ValAff);
|
||||
Result = Result.union_add(Multiplied);
|
||||
return isl::stat::ok();
|
||||
});
|
||||
if (Stat.is_error())
|
||||
return {};
|
||||
return Result;
|
||||
}
|
||||
|
||||
|
||||
@@ -403,86 +403,98 @@ TEST(Isl, Foreach) {
|
||||
|
||||
{
|
||||
auto NumBMaps = 0;
|
||||
TestMap.foreach_basic_map([&](isl::basic_map BMap) -> isl::stat {
|
||||
EXPECT_EQ(BMap, TestBMap);
|
||||
NumBMaps++;
|
||||
return isl::stat::ok;
|
||||
});
|
||||
isl::stat Stat =
|
||||
TestMap.foreach_basic_map([&](isl::basic_map BMap) -> isl::stat {
|
||||
EXPECT_EQ(BMap, TestBMap);
|
||||
NumBMaps++;
|
||||
return isl::stat::ok();
|
||||
});
|
||||
|
||||
EXPECT_TRUE(Stat.is_ok());
|
||||
EXPECT_EQ(1, NumBMaps);
|
||||
}
|
||||
|
||||
{
|
||||
auto NumBSets = 0;
|
||||
TestSet.foreach_basic_set([&](isl::basic_set BSet) -> isl::stat {
|
||||
EXPECT_EQ(BSet, TestBSet);
|
||||
NumBSets++;
|
||||
return isl::stat::ok;
|
||||
});
|
||||
isl::stat Stat =
|
||||
TestSet.foreach_basic_set([&](isl::basic_set BSet) -> isl::stat {
|
||||
EXPECT_EQ(BSet, TestBSet);
|
||||
NumBSets++;
|
||||
return isl::stat::ok();
|
||||
});
|
||||
EXPECT_TRUE(Stat.is_ok());
|
||||
EXPECT_EQ(1, NumBSets);
|
||||
}
|
||||
|
||||
{
|
||||
auto NumMaps = 0;
|
||||
TestUMap.foreach_map([&](isl::map Map) -> isl::stat {
|
||||
isl::stat Stat = TestUMap.foreach_map([&](isl::map Map) -> isl::stat {
|
||||
EXPECT_EQ(Map, TestMap);
|
||||
NumMaps++;
|
||||
return isl::stat::ok;
|
||||
return isl::stat::ok();
|
||||
});
|
||||
EXPECT_TRUE(Stat.is_ok());
|
||||
EXPECT_EQ(1, NumMaps);
|
||||
}
|
||||
|
||||
{
|
||||
auto NumSets = 0;
|
||||
TestUSet.foreach_set([&](isl::set Set) -> isl::stat {
|
||||
isl::stat Stat = TestUSet.foreach_set([&](isl::set Set) -> isl::stat {
|
||||
EXPECT_EQ(Set, TestSet);
|
||||
NumSets++;
|
||||
return isl::stat::ok;
|
||||
return isl::stat::ok();
|
||||
});
|
||||
EXPECT_TRUE(Stat.is_ok());
|
||||
EXPECT_EQ(1, NumSets);
|
||||
}
|
||||
|
||||
{
|
||||
auto UPwAff = isl::union_pw_aff(TestUSet, isl::val::zero(Ctx.get()));
|
||||
auto NumPwAffs = 0;
|
||||
UPwAff.foreach_pw_aff([&](isl::pw_aff PwAff) -> isl::stat {
|
||||
isl::stat Stat = UPwAff.foreach_pw_aff([&](isl::pw_aff PwAff) -> isl::stat {
|
||||
EXPECT_TRUE(PwAff.is_cst());
|
||||
NumPwAffs++;
|
||||
return isl::stat::ok;
|
||||
return isl::stat::ok();
|
||||
});
|
||||
EXPECT_TRUE(Stat.is_ok());
|
||||
EXPECT_EQ(1, NumPwAffs);
|
||||
}
|
||||
|
||||
{
|
||||
auto NumBMaps = 0;
|
||||
EXPECT_EQ(isl::stat::error,
|
||||
TestMap.foreach_basic_map([&](isl::basic_map BMap) -> isl::stat {
|
||||
EXPECT_EQ(BMap, TestBMap);
|
||||
NumBMaps++;
|
||||
return isl::stat::error;
|
||||
}));
|
||||
EXPECT_TRUE(TestMap
|
||||
.foreach_basic_map([&](isl::basic_map BMap) -> isl::stat {
|
||||
EXPECT_EQ(BMap, TestBMap);
|
||||
NumBMaps++;
|
||||
return isl::stat::error();
|
||||
})
|
||||
.is_error());
|
||||
EXPECT_EQ(1, NumBMaps);
|
||||
}
|
||||
|
||||
{
|
||||
auto NumMaps = 0;
|
||||
EXPECT_EQ(isl::stat::error,
|
||||
TestUMap.foreach_map([&](isl::map Map) -> isl::stat {
|
||||
EXPECT_EQ(Map, TestMap);
|
||||
NumMaps++;
|
||||
return isl::stat::error;
|
||||
}));
|
||||
EXPECT_TRUE(TestUMap
|
||||
.foreach_map([&](isl::map Map) -> isl::stat {
|
||||
EXPECT_EQ(Map, TestMap);
|
||||
NumMaps++;
|
||||
return isl::stat::error();
|
||||
})
|
||||
.is_error());
|
||||
EXPECT_EQ(1, NumMaps);
|
||||
}
|
||||
|
||||
{
|
||||
auto TestPwAff = isl::pw_aff(TestSet, isl::val::zero(Ctx.get()));
|
||||
auto NumPieces = 0;
|
||||
TestPwAff.foreach_piece([&](isl::set Domain, isl::aff Aff) -> isl::stat {
|
||||
EXPECT_EQ(Domain, TestSet);
|
||||
EXPECT_TRUE(Aff.is_cst());
|
||||
NumPieces++;
|
||||
return isl::stat::error;
|
||||
});
|
||||
isl::stat Stat = TestPwAff.foreach_piece(
|
||||
[&](isl::set Domain, isl::aff Aff) -> isl::stat {
|
||||
EXPECT_EQ(Domain, TestSet);
|
||||
EXPECT_TRUE(Aff.is_cst());
|
||||
NumPieces++;
|
||||
return isl::stat::error();
|
||||
});
|
||||
EXPECT_TRUE(Stat.is_error());
|
||||
EXPECT_EQ(1, NumPieces);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user