Changeset View
Changeset View
Standalone View
Standalone View
mlir/lib/Dialect/SPIRV/Serialization/Serializer.cpp
Show First 20 Lines • Show All 54 Lines • ▼ Show 20 Lines | |||||
/// | /// | ||||
/// SPIR-V spec "2.16.1. Universal Validation Rules" requires that "the order | /// SPIR-V spec "2.16.1. Universal Validation Rules" requires that "the order | ||||
/// of blocks in a function must satisfy the rule that blocks appear before | /// of blocks in a function must satisfy the rule that blocks appear before | ||||
/// all blocks they dominate." This can be achieved by a pre-order CFG | /// all blocks they dominate." This can be achieved by a pre-order CFG | ||||
/// traversal algorithm. To make the serialization output more logical and | /// traversal algorithm. To make the serialization output more logical and | ||||
/// readable to human, we perform depth-first CFG traversal and delay the | /// readable to human, we perform depth-first CFG traversal and delay the | ||||
/// serialization of the merge block and the continue block, if exists, until | /// serialization of the merge block and the continue block, if exists, until | ||||
/// after all other blocks have been processed. | /// after all other blocks have been processed. | ||||
static LogicalResult visitInPrettyBlockOrder( | static LogicalResult | ||||
Block *headerBlock, function_ref<LogicalResult(Block *)> blockHandler, | visitInPrettyBlockOrder(Block *headerBlock, | ||||
bool skipHeader = false, ArrayRef<Block *> skipBlocks = {}) { | function_ref<LogicalResult(Block *)> blockHandler, | ||||
bool skipHeader = false, BlockRange skipBlocks = {}) { | |||||
llvm::df_iterator_default_set<Block *, 4> doneBlocks; | llvm::df_iterator_default_set<Block *, 4> doneBlocks; | ||||
doneBlocks.insert(skipBlocks.begin(), skipBlocks.end()); | doneBlocks.insert(skipBlocks.begin(), skipBlocks.end()); | ||||
for (Block *block : llvm::depth_first_ext(headerBlock, doneBlocks)) { | for (Block *block : llvm::depth_first_ext(headerBlock, doneBlocks)) { | ||||
if (skipHeader && block == headerBlock) | if (skipHeader && block == headerBlock) | ||||
continue; | continue; | ||||
if (failed(blockHandler(block))) | if (failed(blockHandler(block))) | ||||
return failure(); | return failure(); | ||||
▲ Show 20 Lines • Show All 1,929 Lines • Show Last 20 Lines |