Lines Matching defs:CHRScope

143 // CHRScope - a sequence of regions to CHR together. It corresponds to a
146 class CHRScope {
148 CHRScope(RegInfo RI) : BranchInsertPoint(nullptr) {
154 assert(RegInfos.size() > 0 && "Empty CHRScope");
161 assert(RegInfos.size() > 0 && "Empty CHRScope");
166 assert(RegInfos.size() > 0 && "Empty CHRScope");
170 bool appendable(CHRScope *Next) {
187 void append(CHRScope *Next) {
188 assert(RegInfos.size() > 0 && "Empty CHRScope");
189 assert(Next->RegInfos.size() > 0 && "Empty CHRScope");
198 void addSub(CHRScope *SubIn) {
213 CHRScope *split(Region *Boundary) {
227 std::stable_partition(Subs.begin(), Subs.end(), [&](CHRScope *Sub) {
239 ArrayRef<CHRScope *> TailSubs(TailIt, Subs.end());
242 auto *Scope = new CHRScope(TailRegInfos, TailSubs);
259 SmallVector<CHRScope *, 8> Subs; // Subscopes.
283 CHRScope(ArrayRef<RegInfo> RegInfosIn, ArrayRef<CHRScope *> SubsIn)
296 for (CHRScope *Scope : Scopes) {
307 void findScopes(SmallVectorImpl<CHRScope *> &Output) {
309 if (CHRScope *Scope = findScopes(R, nullptr, nullptr, Output)) {
313 CHRScope *findScopes(Region *R, Region *NextRegion, Region *ParentRegion,
314 SmallVectorImpl<CHRScope *> &Scopes);
315 CHRScope *findScope(Region *R);
316 void checkScopeHoistable(CHRScope *Scope);
318 void splitScopes(SmallVectorImpl<CHRScope *> &Input,
319 SmallVectorImpl<CHRScope *> &Output);
320 SmallVector<CHRScope *, 8> splitScope(CHRScope *Scope,
321 CHRScope *Outer,
324 SmallVectorImpl<CHRScope *> &Output,
327 void classifyBiasedScopes(SmallVectorImpl<CHRScope *> &Scopes);
328 void classifyBiasedScopes(CHRScope *Scope, CHRScope *OutermostScope);
330 void filterScopes(SmallVectorImpl<CHRScope *> &Input,
331 SmallVectorImpl<CHRScope *> &Output);
333 void setCHRRegions(SmallVectorImpl<CHRScope *> &Input,
334 SmallVectorImpl<CHRScope *> &Output);
335 void setCHRRegions(CHRScope *Scope, CHRScope *OutermostScope);
337 void sortScopes(SmallVectorImpl<CHRScope *> &Input,
338 SmallVectorImpl<CHRScope *> &Output);
340 void transformScopes(SmallVectorImpl<CHRScope *> &CHRScopes);
341 void transformScopes(CHRScope *Scope, DenseSet<PHINode *> &TrivialPHIs);
342 void cloneScopeBlocks(CHRScope *Scope,
351 void fixupBranchesAndSelects(CHRScope *Scope, BasicBlock *PreEntryBlock,
353 void fixupBranch(Region *R, CHRScope *Scope, IRBuilder<> &IRB,
355 void fixupSelect(SelectInst *SI, CHRScope *Scope, IRBuilder<> &IRB,
358 Instruction *BranchOrSelect, CHRScope *Scope,
394 DenseSet<CHRScope *> Scopes;
409 raw_ostream &operator<<(raw_ostream &OS, const CHRScope &Scope) {
444 void CHRScope::print(raw_ostream &OS) const {
445 assert(RegInfos.size() > 0 && "Empty CHRScope");
446 OS << "CHRScope[";
463 for (CHRScope *Sub : Subs) {
715 CHRScope * CHR::findScope(Region *R) {
716 CHRScope *Result = nullptr;
776 Result = new CHRScope(RI);
836 Result = new CHRScope(RI);
873 void CHR::checkScopeHoistable(CHRScope *Scope) {
976 CHRScope * CHR::findScopes(Region *R, Region *NextRegion, Region *ParentRegion,
977 SmallVectorImpl<CHRScope *> &Scopes) {
979 CHRScope *Result = findScope(R);
981 CHRScope *ConsecutiveSubscope = nullptr;
982 SmallVector<CHRScope *, 8> Subscopes;
989 CHRScope *SubCHRScope = findScopes(SubR.get(), NextSubR, R, Scopes);
1013 for (CHRScope *Sub : Subscopes) {
1106 static void getSelectsInScope(CHRScope *Scope,
1111 for (CHRScope *Sub : Scope->Subs)
1115 void CHR::splitScopes(SmallVectorImpl<CHRScope *> &Input,
1116 SmallVectorImpl<CHRScope *> &Output) {
1117 for (CHRScope *Scope : Input) {
1125 for (CHRScope *Scope : Output) {
1131 SmallVector<CHRScope *, 8> CHR::splitScope(
1132 CHRScope *Scope,
1133 CHRScope *Outer,
1136 SmallVectorImpl<CHRScope *> &Output,
1145 SmallVector<CHRScope *, 8> Splits;
1195 CHRScope *Tail = Scope->split(RI.R);
1227 CHRScope *Split = Splits[I];
1230 SmallVector<CHRScope *, 8> NewSubs;
1233 for (CHRScope *Sub : Split->Subs) {
1234 SmallVector<CHRScope *, 8> SubSplits = splitScope(
1241 SmallVector<CHRScope *, 8> Result;
1243 CHRScope *Split = Splits[I];
1261 void CHR::classifyBiasedScopes(SmallVectorImpl<CHRScope *> &Scopes) {
1262 for (CHRScope *Scope : Scopes) {
1290 void CHR::classifyBiasedScopes(CHRScope *Scope, CHRScope *OutermostScope) {
1310 for (CHRScope *Sub : Scope->Subs) {
1315 static bool hasAtLeastTwoBiasedBranches(CHRScope *Scope) {
1323 void CHR::filterScopes(SmallVectorImpl<CHRScope *> &Input,
1324 SmallVectorImpl<CHRScope *> &Output) {
1325 for (CHRScope *Scope : Input) {
1348 void CHR::setCHRRegions(SmallVectorImpl<CHRScope *> &Input,
1349 SmallVectorImpl<CHRScope *> &Output) {
1350 for (CHRScope *Scope : Input) {
1371 void CHR::setCHRRegions(CHRScope *Scope, CHRScope *OutermostScope) {
1416 for (CHRScope *Sub : Scope->Subs)
1420 static bool CHRScopeSorter(CHRScope *Scope1, CHRScope *Scope2) {
1424 void CHR::sortScopes(SmallVectorImpl<CHRScope *> &Input,
1425 SmallVectorImpl<CHRScope *> &Output) {
1481 static void hoistScopeConditions(CHRScope *Scope, Instruction *HoistPoint,
1509 CHRScope *Scope) {
1556 static void insertTrivialPHIs(CHRScope *Scope,
1619 assertCHRRegionsHaveBiasedBranchOrSelect(CHRScope *Scope) {
1621 auto HasBiasedBranchOrSelect = [](RegInfo &RI, CHRScope *Scope) {
1641 CHRScope *Scope, BasicBlock *PreEntryBlock) {
1675 void CHR::transformScopes(CHRScope *Scope, DenseSet<PHINode *> &TrivialPHIs) {
1763 void CHR::cloneScopeBlocks(CHRScope *Scope,
1771 // CHRScope/Region/RegionInfo can stay valid in pointing to the hot-path code
1848 void CHR::fixupBranchesAndSelects(CHRScope *Scope,
1889 void CHR::fixupBranch(Region *R, CHRScope *Scope,
1932 void CHR::fixupSelect(SelectInst *SI, CHRScope *Scope,
1957 Instruction *BranchOrSelect, CHRScope *Scope,
1977 void CHR::transformScopes(SmallVectorImpl<CHRScope *> &CHRScopes) {
1980 for (CHRScope *Scope : CHRScopes) {
1991 dumpScopes(SmallVectorImpl<CHRScope *> &Scopes, const char *Label) {
1993 for (CHRScope *Scope : Scopes) {
2012 SmallVector<CHRScope *, 8> AllScopes;
2021 SmallVector<CHRScope *, 8> SplitScopes;
2032 SmallVector<CHRScope *, 8> FilteredScopes;
2037 SmallVector<CHRScope *, 8> SetScopes;
2044 SmallVector<CHRScope *, 8> SortedScopes;