Lines Matching full:block
14 #include "mlir/IR/Block.h"
26 /// Builds and holds block information during the construction phase.
30 /// Constructs an empty block builder.
33 /// Fills the block builder with initial liveness information.
34 BlockInfoBuilder(Block *block) : block(block) { in BlockInfoBuilder()
37 // this block). Due to the SSA properties of the program, the uses must in BlockInfoBuilder()
41 Block *ownerBlock = useOp->getBlock(); in BlockInfoBuilder()
42 // Find an owner block in the current region. Note that a value does not in BlockInfoBuilder()
43 // escape this block if it is used in a nested region. in BlockInfoBuilder()
44 ownerBlock = block->getParent()->findAncestorBlockInRegion(*ownerBlock); in BlockInfoBuilder()
46 if (ownerBlock != block) { in BlockInfoBuilder()
53 // Mark all block arguments (phis) as defined. in BlockInfoBuilder()
54 for (BlockArgument argument : block->getArguments()) { in BlockInfoBuilder()
58 // Gather all out values of all arguments in the current block. in BlockInfoBuilder()
62 // Gather out values of all operations in the current block. in BlockInfoBuilder()
63 for (Operation &operation : *block) in BlockInfoBuilder()
70 block->walk([&](Operation *op) { in BlockInfoBuilder()
76 for (Block &child : region.getBlocks()) in BlockInfoBuilder()
83 /// Updates live-in information of the current block. To do so it uses the
101 /// Updates live-out information of the current block. It iterates over all
104 void updateLiveOut(const DenseMap<Block *, BlockInfoBuilder> &builders) { in updateLiveOut()
105 for (Block *succ : block->getSuccessors()) { in updateLiveOut()
111 /// The current block.
112 Block *block{nullptr}; member
128 /// Builds the internal liveness block mapping.
130 DenseMap<Block *, BlockInfoBuilder> &builders) { in buildBlockMapping() argument
131 SetVector<Block *> toProcess; in buildBlockMapping()
133 operation->walk<WalkOrder::PreOrder>([&](Block *block) { in buildBlockMapping() argument
135 builders.try_emplace(block, block).first->second; in buildBlockMapping()
138 toProcess.insert(block->pred_begin(), block->pred_end()); in buildBlockMapping()
143 Block *current = toProcess.pop_back_val(); in buildBlockMapping()
165 // Build internal block mapping. in build()
166 DenseMap<Block *, BlockInfoBuilder> builders; in build()
169 // Store internal block data. in build()
174 info.block = builder.block; in build()
183 SmallPtrSet<Block *, 32> visited; in resolveLiveness()
184 SmallVector<Block *, 8> toProcess; in resolveLiveness()
186 // Start with the defining block in resolveLiveness()
187 Block *currentBlock; in resolveLiveness()
197 Block *useBlock = use.getOwner()->getBlock(); in resolveLiveness()
203 // Get block and block liveness information. in resolveLiveness()
204 Block *block = toProcess.back(); in resolveLiveness() local
206 const LivenessBlockInfo *blockInfo = getLiveness(block); in resolveLiveness()
208 // Note that start and end will be in the same block. in resolveLiveness()
218 for (Block *successor : block->getSuccessors()) { in resolveLiveness()
228 /// Gets liveness info (if any) for the block.
229 const LivenessBlockInfo *Liveness::getLiveness(Block *block) const { in getLiveness()
230 auto it = blockMapping.find(block); in getLiveness()
235 const Liveness::ValueSetT &Liveness::getLiveIn(Block *block) const { in getLiveIn()
236 return getLiveness(block)->in(); in getLiveIn()
240 const Liveness::ValueSetT &Liveness::getLiveOut(Block *block) const { in getLiveOut()
241 return getLiveness(block)->out(); in getLiveOut()
246 Block *block = operation->getBlock(); in isDeadAfter() local
247 const LivenessBlockInfo *blockInfo = getLiveness(block); in isDeadAfter()
249 // The given value escapes the associated block. in isDeadAfter()
256 // the given operation in the block. in isDeadAfter()
267 // Builds unique block/value mappings for testing purposes. in print()
268 DenseMap<Block *, size_t> blockIds; in print()
271 operation->walk<WalkOrder::PreOrder>([&](Block *block) { in print() argument
272 blockIds.insert({block, blockIds.size()}); in print()
273 for (BlockArgument argument : block->getArguments()) in print()
275 for (Operation &operation : *block) { in print()
304 operation->walk<WalkOrder::PreOrder>([&](Block *block) { in print() argument
305 os << "// - Block: " << blockIds[block] << "\n"; in print()
306 const auto *liveness = getLiveness(block); in print()
315 for (Operation &op : *block) { in print()
337 for (Operation &op : *block) { in print()
367 /// block).
371 // in the scope of this block. in getStartOperation()
373 return &block->front(); in getStartOperation()
378 /// provided (must be referenced in this block).
381 // The given value is either dying in this block or live-out. in getEndOperation()
383 return &block->back(); in getEndOperation()
388 // Find the associated operation in the current block (if any). in getEndOperation()
389 useOp = block->findAncestorOpInBlock(*useOp); in getEndOperation()
390 // Check whether the use is in our block and after the current end in getEndOperation()
406 // Determine the live range of this value inside this block. in currentlyLiveValues()
409 // If it's a live in or a block argument, then the start is the beginning in currentlyLiveValues()
410 // of the block. in currentlyLiveValues()
412 startOfLiveRange = &block->front(); in currentlyLiveValues()
414 startOfLiveRange = block->findAncestorOpInBlock(*startOfLiveRange); in currentlyLiveValues()
416 // If it's a live out, then the end is the back of the block. in currentlyLiveValues()
418 endOfLiveRange = &block->back(); in currentlyLiveValues()
432 // Handle block arguments if any. in currentlyLiveValues()
433 for (Value arg : block->getArguments()) in currentlyLiveValues()
437 // every value in the block. in currentlyLiveValues()
441 // Now walk the block and handle all values used in the block and values in currentlyLiveValues()
442 // defined by the block. in currentlyLiveValues()
444 llvm::make_range(block->begin(), ++op->getIterator())) in currentlyLiveValues()