Lines Matching defs:CHRScope

142 // CHRScope - a sequence of regions to CHR together. It corresponds to a
145 class CHRScope {
147 CHRScope(RegInfo RI) : BranchInsertPoint(nullptr) {
153 assert(RegInfos.size() > 0 && "Empty CHRScope");
160 assert(RegInfos.size() > 0 && "Empty CHRScope");
165 assert(RegInfos.size() > 0 && "Empty CHRScope");
169 bool appendable(CHRScope *Next) {
186 void append(CHRScope *Next) {
187 assert(RegInfos.size() > 0 && "Empty CHRScope");
188 assert(Next->RegInfos.size() > 0 && "Empty CHRScope");
197 void addSub(CHRScope *SubIn) {
212 CHRScope *split(Region *Boundary) {
226 std::stable_partition(Subs.begin(), Subs.end(), [&](CHRScope *Sub) {
238 ArrayRef<CHRScope *> TailSubs(TailIt, Subs.end());
241 auto *Scope = new CHRScope(TailRegInfos, TailSubs);
258 SmallVector<CHRScope *, 8> Subs; // Subscopes.
282 CHRScope(ArrayRef<RegInfo> RegInfosIn, ArrayRef<CHRScope *> SubsIn)
294 for (CHRScope *Scope : Scopes) {
305 void findScopes(SmallVectorImpl<CHRScope *> &Output) {
307 if (CHRScope *Scope = findScopes(R, nullptr, nullptr, Output)) {
311 CHRScope *findScopes(Region *R, Region *NextRegion, Region *ParentRegion,
312 SmallVectorImpl<CHRScope *> &Scopes);
313 CHRScope *findScope(Region *R);
314 void checkScopeHoistable(CHRScope *Scope);
316 void splitScopes(SmallVectorImpl<CHRScope *> &Input,
317 SmallVectorImpl<CHRScope *> &Output);
318 SmallVector<CHRScope *, 8> splitScope(CHRScope *Scope,
319 CHRScope *Outer,
322 SmallVectorImpl<CHRScope *> &Output,
325 void classifyBiasedScopes(SmallVectorImpl<CHRScope *> &Scopes);
326 void classifyBiasedScopes(CHRScope *Scope, CHRScope *OutermostScope);
328 void filterScopes(SmallVectorImpl<CHRScope *> &Input,
329 SmallVectorImpl<CHRScope *> &Output);
331 void setCHRRegions(SmallVectorImpl<CHRScope *> &Input,
332 SmallVectorImpl<CHRScope *> &Output);
333 void setCHRRegions(CHRScope *Scope, CHRScope *OutermostScope);
335 void sortScopes(SmallVectorImpl<CHRScope *> &Input,
336 SmallVectorImpl<CHRScope *> &Output);
338 void transformScopes(SmallVectorImpl<CHRScope *> &CHRScopes);
339 void transformScopes(CHRScope *Scope, DenseSet<PHINode *> &TrivialPHIs);
340 void cloneScopeBlocks(CHRScope *Scope,
349 void fixupBranchesAndSelects(CHRScope *Scope, BasicBlock *PreEntryBlock,
351 void fixupBranch(Region *R, CHRScope *Scope, IRBuilder<> &IRB,
353 void fixupSelect(SelectInst *SI, CHRScope *Scope, IRBuilder<> &IRB,
356 Instruction *BranchOrSelect, CHRScope *Scope,
392 DenseSet<CHRScope *> Scopes;
407 raw_ostream &operator<<(raw_ostream &OS, const CHRScope &Scope) {
442 void CHRScope::print(raw_ostream &OS) const {
443 assert(RegInfos.size() > 0 && "Empty CHRScope");
444 OS << "CHRScope[";
461 for (CHRScope *Sub : Subs) {
713 CHRScope * CHR::findScope(Region *R) {
714 CHRScope *Result = nullptr;
774 Result = new CHRScope(RI);
834 Result = new CHRScope(RI);
871 void CHR::checkScopeHoistable(CHRScope *Scope) {
974 CHRScope * CHR::findScopes(Region *R, Region *NextRegion, Region *ParentRegion,
975 SmallVectorImpl<CHRScope *> &Scopes) {
977 CHRScope *Result = findScope(R);
979 CHRScope *ConsecutiveSubscope = nullptr;
980 SmallVector<CHRScope *, 8> Subscopes;
987 CHRScope *SubCHRScope = findScopes(SubR.get(), NextSubR, R, Scopes);
1011 for (CHRScope *Sub : Subscopes) {
1104 static void getSelectsInScope(CHRScope *Scope,
1109 for (CHRScope *Sub : Scope->Subs)
1113 void CHR::splitScopes(SmallVectorImpl<CHRScope *> &Input,
1114 SmallVectorImpl<CHRScope *> &Output) {
1115 for (CHRScope *Scope : Input) {
1123 for (CHRScope *Scope : Output) {
1129 SmallVector<CHRScope *, 8> CHR::splitScope(
1130 CHRScope *Scope,
1131 CHRScope *Outer,
1134 SmallVectorImpl<CHRScope *> &Output,
1143 SmallVector<CHRScope *, 8> Splits;
1193 CHRScope *Tail = Scope->split(RI.R);
1225 CHRScope *Split = Splits[I];
1228 SmallVector<CHRScope *, 8> NewSubs;
1231 for (CHRScope *Sub : Split->Subs) {
1232 SmallVector<CHRScope *, 8> SubSplits = splitScope(
1239 SmallVector<CHRScope *, 8> Result;
1241 CHRScope *Split = Splits[I];
1259 void CHR::classifyBiasedScopes(SmallVectorImpl<CHRScope *> &Scopes) {
1260 for (CHRScope *Scope : Scopes) {
1288 void CHR::classifyBiasedScopes(CHRScope *Scope, CHRScope *OutermostScope) {
1308 for (CHRScope *Sub : Scope->Subs) {
1313 static bool hasAtLeastTwoBiasedBranches(CHRScope *Scope) {
1321 void CHR::filterScopes(SmallVectorImpl<CHRScope *> &Input,
1322 SmallVectorImpl<CHRScope *> &Output) {
1323 for (CHRScope *Scope : Input) {
1346 void CHR::setCHRRegions(SmallVectorImpl<CHRScope *> &Input,
1347 SmallVectorImpl<CHRScope *> &Output) {
1348 for (CHRScope *Scope : Input) {
1369 void CHR::setCHRRegions(CHRScope *Scope, CHRScope *OutermostScope) {
1414 for (CHRScope *Sub : Scope->Subs)
1418 static bool CHRScopeSorter(CHRScope *Scope1, CHRScope *Scope2) {
1422 void CHR::sortScopes(SmallVectorImpl<CHRScope *> &Input,
1423 SmallVectorImpl<CHRScope *> &Output) {
1479 static void hoistScopeConditions(CHRScope *Scope, Instruction *HoistPoint,
1507 CHRScope *Scope) {
1554 static void insertTrivialPHIs(CHRScope *Scope,
1617 assertCHRRegionsHaveBiasedBranchOrSelect(CHRScope *Scope) {
1619 auto HasBiasedBranchOrSelect = [](RegInfo &RI, CHRScope *Scope) {
1639 CHRScope *Scope, BasicBlock *PreEntryBlock) {
1673 void CHR::transformScopes(CHRScope *Scope, DenseSet<PHINode *> &TrivialPHIs) {
1761 void CHR::cloneScopeBlocks(CHRScope *Scope,
1769 // CHRScope/Region/RegionInfo can stay valid in pointing to the hot-path code
1846 void CHR::fixupBranchesAndSelects(CHRScope *Scope,
1888 void CHR::fixupBranch(Region *R, CHRScope *Scope,
1931 void CHR::fixupSelect(SelectInst *SI, CHRScope *Scope,
1956 Instruction *BranchOrSelect, CHRScope *Scope,
1976 void CHR::transformScopes(SmallVectorImpl<CHRScope *> &CHRScopes) {
1979 for (CHRScope *Scope : CHRScopes) {
1990 dumpScopes(SmallVectorImpl<CHRScope *> &Scopes, const char *Label) {
1992 for (CHRScope *Scope : Scopes) {
2011 SmallVector<CHRScope *, 8> AllScopes;
2020 SmallVector<CHRScope *, 8> SplitScopes;
2031 SmallVector<CHRScope *, 8> FilteredScopes;
2036 SmallVector<CHRScope *, 8> SetScopes;
2043 SmallVector<CHRScope *, 8> SortedScopes;