16bool DeltaAlgorithm::GetTestResult(
const changeset_ty &Changes) {
17 if (FailedTestsCache.count(Changes))
22 FailedTestsCache.insert(Changes);
27void DeltaAlgorithm::Split(
const changeset_ty &S, changesetlist_ty &Res) {
32 unsigned idx = 0,
N = S.size() / 2;
33 for (changeset_ty::const_iterator it = S.begin(),
34 ie = S.end(); it != ie; ++it, ++idx)
35 ((idx <
N) ? LHS : RHS).insert(*it);
43DeltaAlgorithm::Delta(
const changeset_ty &Changes,
44 const changesetlist_ty &Sets) {
54 if (Search(Changes, Sets, Res))
60 Split(Set, SplitSets);
61 if (SplitSets.size() == Sets.size())
64 return Delta(Changes, SplitSets);
67bool DeltaAlgorithm::Search(
const changeset_ty &Changes,
68 const changesetlist_ty &Sets,
71 for (changesetlist_ty::const_iterator it = Sets.begin(),
72 ie = Sets.end(); it != ie; ++it) {
74 if (GetTestResult(*it)) {
77 Res = Delta(*it, Sets);
83 if (Sets.size() > 2) {
86 std::set_difference(Changes.begin(), Changes.end(), it->begin(),
88 std::inserter(Complement, Complement.begin()));
89 if (GetTestResult(Complement)) {
91 ComplementSets.insert(ComplementSets.end(), Sets.begin(), it);
92 ComplementSets.insert(ComplementSets.end(), it + 1, Sets.end());
93 Res = Delta(Complement, ComplementSets);
109 Split(Changes, Sets);
111 return Delta(Changes, Sets);
virtual bool ExecuteOneTest(const changeset_ty &S)=0
ExecuteOneTest - Execute a single test predicate on the change set S.
virtual ~DeltaAlgorithm()
virtual void UpdatedSearchState(const changeset_ty &Changes, const changesetlist_ty &Sets)
UpdatedSearchState - Callback used when the search state changes.
changeset_ty Run(const changeset_ty &Changes)
Run - Minimize the set Changes by executing.
std::set< change_ty > changeset_ty
std::vector< changeset_ty > changesetlist_ty
This is an optimization pass for GlobalISel generic memory operations.