-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add more iterators compatible with range-based `for` syntax for various data structures. These iterators all assume (and some check) that the underlying data structures determining the iteration are not changed during the iteration. For example, don't use these to iterate over the predecessor edges if you are changing the order or contents of the predecessor edge list. - BasicBlock: iterate over all blocks in the function, a subset starting not at the first block, or a specified range of blocks. Removed uses of the `foreach_block` macro. E.g.: ``` for (BasicBlock* const block : Blocks()) // all blocks in function for (BasicBlock* const block : BasicBlockSimpleList(fgFirstBB->bbNext)) // all blocks starting at fgFirstBB->bbNext for (BasicBlock* const testBlock : BasicBlockRangeList(firstNonLoopBlock, lastNonLoopBlock)) // all blocks in range (inclusive) ``` - block predecessors: iterate over all predecessor edges, or all predecessor blocks, e.g.: ``` for (flowList* const edge : block->PredEdges()) for (BasicBlock* const predBlock : block->PredBlocks()) ``` - block successors: iterate over all block successors using the `NumSucc()/GetSucc()`, or `NumSucc(Compiler*)/GetSucc(Compiler*)` pairs, e.g.: ``` for (BasicBlock* const succ : Succs()) for (BasicBlock* const succ : Succs(compiler)) ``` Note that there already exists the "AllSuccessorsIter" which iterates over block successors including possible EH successors, e.g.: ``` for (BasicBlock* succ : block->GetAllSuccs(m_pCompiler)) ``` - switch targets, (namely, the successors of `BBJ_SWITCH` blocks), e.g.: ``` for (BasicBlock* const bTarget : block->SwitchTargets()) ``` - loops blocks: iterate over all the blocks in a loop, e.g.: ``` for (BasicBlock* const blk : optLoopTable[loopInd].LoopBlocks()) ``` - Statements: added an iterator shortcut for the non-phi statements, e.g.: ``` for (Statement* const stmt : block->NonPhiStatements()) ``` Note that there already exists an iterator over all statements, e.g.: ``` for (Statement* const stmt : block->Statements()) ``` - EH clauses, e.g.: ``` for (EHblkDsc* const HBtab : EHClauses(this)) ``` - GenTree in linear order (but not LIR, which already has an iterator), namely, using the `gtNext` links, e.g.: ``` for (GenTree* const call : stmt->TreeList()) ``` This is a no-diff change.
- Loading branch information
1 parent
d173cca
commit 5788ea0
Showing
45 changed files
with
1,269 additions
and
928 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.