~mmach/netext73/spirv-tools

« back to all changes in this revision

Viewing changes to source/val/function.cpp

  • Committer: mmach
  • Date: 2022-08-26 06:41:59 UTC
  • Revision ID: netbit73@gmail.com-20220826064159-00f072z4uek8w8e3
2022.3.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
73
73
  BasicBlock& continue_target_block = blocks_.at(continue_id);
74
74
  assert(current_block_ &&
75
75
         "RegisterLoopMerge must be called when called within a block");
 
76
  current_block_->RegisterStructuralSuccessor(&merge_block);
 
77
  current_block_->RegisterStructuralSuccessor(&continue_target_block);
76
78
 
77
79
  current_block_->set_type(kBlockTypeLoop);
78
80
  merge_block.set_type(kBlockTypeMerge);
101
103
  current_block_->set_type(kBlockTypeSelection);
102
104
  merge_block.set_type(kBlockTypeMerge);
103
105
  merge_block_header_[&merge_block] = current_block_;
 
106
  current_block_->RegisterStructuralSuccessor(&merge_block);
104
107
 
105
108
  AddConstruct({ConstructType::kSelection, current_block(), &merge_block});
106
109
 
251
254
  };
252
255
}
253
256
 
254
 
Function::GetBlocksFunction
255
 
Function::AugmentedCFGSuccessorsFunctionIncludingHeaderToContinueEdge() const {
256
 
  return [this](const BasicBlock* block) {
257
 
    auto where = loop_header_successors_plus_continue_target_map_.find(block);
258
 
    return where == loop_header_successors_plus_continue_target_map_.end()
259
 
               ? AugmentedCFGSuccessorsFunction()(block)
260
 
               : &(*where).second;
261
 
  };
262
 
}
263
 
 
264
257
Function::GetBlocksFunction Function::AugmentedCFGPredecessorsFunction() const {
265
258
  return [this](const BasicBlock* block) {
266
259
    auto where = augmented_predecessors_map_.find(block);
269
262
  };
270
263
}
271
264
 
 
265
Function::GetBlocksFunction Function::AugmentedStructuralCFGSuccessorsFunction()
 
266
    const {
 
267
  return [this](const BasicBlock* block) {
 
268
    auto where = augmented_successors_map_.find(block);
 
269
    return where == augmented_successors_map_.end()
 
270
               ? block->structural_successors()
 
271
               : &(*where).second;
 
272
  };
 
273
}
 
274
 
 
275
Function::GetBlocksFunction
 
276
Function::AugmentedStructuralCFGPredecessorsFunction() const {
 
277
  return [this](const BasicBlock* block) {
 
278
    auto where = augmented_predecessors_map_.find(block);
 
279
    return where == augmented_predecessors_map_.end()
 
280
               ? block->structural_predecessors()
 
281
               : &(*where).second;
 
282
  };
 
283
}
 
284
 
272
285
void Function::ComputeAugmentedCFG() {
273
286
  // Compute the successors of the pseudo-entry block, and
274
287
  // the predecessors of the pseudo exit block.
275
 
  auto succ_func = [](const BasicBlock* b) { return b->successors(); };
276
 
  auto pred_func = [](const BasicBlock* b) { return b->predecessors(); };
 
288
  auto succ_func = [](const BasicBlock* b) {
 
289
    return b->structural_successors();
 
290
  };
 
291
  auto pred_func = [](const BasicBlock* b) {
 
292
    return b->structural_predecessors();
 
293
  };
277
294
  CFA<BasicBlock>::ComputeAugmentedCFG(
278
295
      ordered_blocks_, &pseudo_entry_block_, &pseudo_exit_block_,
279
296
      &augmented_successors_map_, &augmented_predecessors_map_, succ_func,