nir: Make nir_foo_first/last_cf_node return a block instead
[mesa.git] / src / compiler / nir / nir_control_flow.c
1 /*
2 * Copyright © 2014 Intel Corporation
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21 * IN THE SOFTWARE.
22 *
23 * Authors:
24 * Connor Abbott (cwabbott0@gmail.com)
25 *
26 */
27
28 #include "nir_control_flow_private.h"
29
30 /**
31 * \name Control flow modification
32 *
33 * These functions modify the control flow tree while keeping the control flow
34 * graph up-to-date. The invariants respected are:
35 * 1. Each then statement, else statement, or loop body must have at least one
36 * control flow node.
37 * 2. Each if-statement and loop must have one basic block before it and one
38 * after.
39 * 3. Two basic blocks cannot be directly next to each other.
40 * 4. If a basic block has a jump instruction, there must be only one and it
41 * must be at the end of the block.
42 *
43 * The purpose of the second one is so that we have places to insert code during
44 * GCM, as well as eliminating the possibility of critical edges.
45 */
46 /*@{*/
47
48 static bool
49 block_ends_in_jump(nir_block *block)
50 {
51 return !exec_list_is_empty(&block->instr_list) &&
52 nir_block_last_instr(block)->type == nir_instr_type_jump;
53 }
54
55 static inline void
56 block_add_pred(nir_block *block, nir_block *pred)
57 {
58 _mesa_set_add(block->predecessors, pred);
59 }
60
61 static inline void
62 block_remove_pred(nir_block *block, nir_block *pred)
63 {
64 struct set_entry *entry = _mesa_set_search(block->predecessors, pred);
65
66 assert(entry);
67
68 _mesa_set_remove(block->predecessors, entry);
69 }
70
71 static void
72 link_blocks(nir_block *pred, nir_block *succ1, nir_block *succ2)
73 {
74 pred->successors[0] = succ1;
75 if (succ1 != NULL)
76 block_add_pred(succ1, pred);
77
78 pred->successors[1] = succ2;
79 if (succ2 != NULL)
80 block_add_pred(succ2, pred);
81 }
82
83 static void
84 unlink_blocks(nir_block *pred, nir_block *succ)
85 {
86 if (pred->successors[0] == succ) {
87 pred->successors[0] = pred->successors[1];
88 pred->successors[1] = NULL;
89 } else {
90 assert(pred->successors[1] == succ);
91 pred->successors[1] = NULL;
92 }
93
94 block_remove_pred(succ, pred);
95 }
96
97 static void
98 unlink_block_successors(nir_block *block)
99 {
100 if (block->successors[1] != NULL)
101 unlink_blocks(block, block->successors[1]);
102 if (block->successors[0] != NULL)
103 unlink_blocks(block, block->successors[0]);
104 }
105
106 static void
107 link_non_block_to_block(nir_cf_node *node, nir_block *block)
108 {
109 if (node->type == nir_cf_node_if) {
110 /*
111 * We're trying to link an if to a block after it; this just means linking
112 * the last block of the then and else branches.
113 */
114
115 nir_if *if_stmt = nir_cf_node_as_if(node);
116
117 nir_block *last_then_block = nir_if_last_then_block(if_stmt);
118 nir_block *last_else_block = nir_if_last_else_block(if_stmt);
119
120 if (!block_ends_in_jump(last_then_block)) {
121 unlink_block_successors(last_then_block);
122 link_blocks(last_then_block, block, NULL);
123 }
124
125 if (!block_ends_in_jump(last_else_block)) {
126 unlink_block_successors(last_else_block);
127 link_blocks(last_else_block, block, NULL);
128 }
129 } else {
130 assert(node->type == nir_cf_node_loop);
131 }
132 }
133
134 static void
135 link_block_to_non_block(nir_block *block, nir_cf_node *node)
136 {
137 if (node->type == nir_cf_node_if) {
138 /*
139 * We're trying to link a block to an if after it; this just means linking
140 * the block to the first block of the then and else branches.
141 */
142
143 nir_if *if_stmt = nir_cf_node_as_if(node);
144
145 nir_block *first_then_block = nir_if_first_then_block(if_stmt);
146 nir_block *first_else_block = nir_if_first_else_block(if_stmt);
147
148 unlink_block_successors(block);
149 link_blocks(block, first_then_block, first_else_block);
150 } else {
151 /*
152 * For similar reasons as the corresponding case in
153 * link_non_block_to_block(), don't worry about if the loop header has
154 * any predecessors that need to be unlinked.
155 */
156
157 assert(node->type == nir_cf_node_loop);
158
159 nir_loop *loop = nir_cf_node_as_loop(node);
160
161 nir_block *loop_header_block = nir_loop_first_block(loop);
162
163 unlink_block_successors(block);
164 link_blocks(block, loop_header_block, NULL);
165 }
166
167 }
168
169 /**
170 * Replace a block's successor with a different one.
171 */
172 static void
173 replace_successor(nir_block *block, nir_block *old_succ, nir_block *new_succ)
174 {
175 if (block->successors[0] == old_succ) {
176 block->successors[0] = new_succ;
177 } else {
178 assert(block->successors[1] == old_succ);
179 block->successors[1] = new_succ;
180 }
181
182 block_remove_pred(old_succ, block);
183 block_add_pred(new_succ, block);
184 }
185
186 /**
187 * Takes a basic block and inserts a new empty basic block before it, making its
188 * predecessors point to the new block. This essentially splits the block into
189 * an empty header and a body so that another non-block CF node can be inserted
190 * between the two. Note that this does *not* link the two basic blocks, so
191 * some kind of cleanup *must* be performed after this call.
192 */
193
194 static nir_block *
195 split_block_beginning(nir_block *block)
196 {
197 nir_block *new_block = nir_block_create(ralloc_parent(block));
198 new_block->cf_node.parent = block->cf_node.parent;
199 exec_node_insert_node_before(&block->cf_node.node, &new_block->cf_node.node);
200
201 struct set_entry *entry;
202 set_foreach(block->predecessors, entry) {
203 nir_block *pred = (nir_block *) entry->key;
204 replace_successor(pred, block, new_block);
205 }
206
207 /* Any phi nodes must stay part of the new block, or else their
208 * sourcse will be messed up. This will reverse the order of the phi's, but
209 * order shouldn't matter.
210 */
211 nir_foreach_instr_safe(instr, block) {
212 if (instr->type != nir_instr_type_phi)
213 break;
214
215 exec_node_remove(&instr->node);
216 instr->block = new_block;
217 exec_list_push_head(&new_block->instr_list, &instr->node);
218 }
219
220 return new_block;
221 }
222
223 static void
224 rewrite_phi_preds(nir_block *block, nir_block *old_pred, nir_block *new_pred)
225 {
226 nir_foreach_instr_safe(instr, block) {
227 if (instr->type != nir_instr_type_phi)
228 break;
229
230 nir_phi_instr *phi = nir_instr_as_phi(instr);
231 nir_foreach_phi_src(src, phi) {
232 if (src->pred == old_pred) {
233 src->pred = new_pred;
234 break;
235 }
236 }
237 }
238 }
239
240 static void
241 insert_phi_undef(nir_block *block, nir_block *pred)
242 {
243 nir_function_impl *impl = nir_cf_node_get_function(&block->cf_node);
244 nir_foreach_instr(instr, block) {
245 if (instr->type != nir_instr_type_phi)
246 break;
247
248 nir_phi_instr *phi = nir_instr_as_phi(instr);
249 nir_ssa_undef_instr *undef =
250 nir_ssa_undef_instr_create(ralloc_parent(phi),
251 phi->dest.ssa.num_components,
252 phi->dest.ssa.bit_size);
253 nir_instr_insert_before_cf_list(&impl->body, &undef->instr);
254 nir_phi_src *src = ralloc(phi, nir_phi_src);
255 src->pred = pred;
256 src->src.parent_instr = &phi->instr;
257 src->src.is_ssa = true;
258 src->src.ssa = &undef->def;
259
260 list_addtail(&src->src.use_link, &undef->def.uses);
261
262 exec_list_push_tail(&phi->srcs, &src->node);
263 }
264 }
265
266 /**
267 * Moves the successors of source to the successors of dest, leaving both
268 * successors of source NULL.
269 */
270
271 static void
272 move_successors(nir_block *source, nir_block *dest)
273 {
274 nir_block *succ1 = source->successors[0];
275 nir_block *succ2 = source->successors[1];
276
277 if (succ1) {
278 unlink_blocks(source, succ1);
279 rewrite_phi_preds(succ1, source, dest);
280 }
281
282 if (succ2) {
283 unlink_blocks(source, succ2);
284 rewrite_phi_preds(succ2, source, dest);
285 }
286
287 unlink_block_successors(dest);
288 link_blocks(dest, succ1, succ2);
289 }
290
291 /* Given a basic block with no successors that has been inserted into the
292 * control flow tree, gives it the successors it would normally have assuming
293 * it doesn't end in a jump instruction. Also inserts phi sources with undefs
294 * if necessary.
295 */
296 static void
297 block_add_normal_succs(nir_block *block)
298 {
299 if (exec_node_is_tail_sentinel(block->cf_node.node.next)) {
300 nir_cf_node *parent = block->cf_node.parent;
301 if (parent->type == nir_cf_node_if) {
302 nir_cf_node *next = nir_cf_node_next(parent);
303 assert(next->type == nir_cf_node_block);
304 nir_block *next_block = nir_cf_node_as_block(next);
305
306 link_blocks(block, next_block, NULL);
307 } else if (parent->type == nir_cf_node_loop) {
308 nir_loop *loop = nir_cf_node_as_loop(parent);
309
310 nir_block *head_block = nir_loop_first_block(loop);
311
312 link_blocks(block, head_block, NULL);
313 insert_phi_undef(head_block, block);
314 } else {
315 assert(parent->type == nir_cf_node_function);
316 nir_function_impl *impl = nir_cf_node_as_function(parent);
317 link_blocks(block, impl->end_block, NULL);
318 }
319 } else {
320 nir_cf_node *next = nir_cf_node_next(&block->cf_node);
321 if (next->type == nir_cf_node_if) {
322 nir_if *next_if = nir_cf_node_as_if(next);
323
324 nir_block *first_then_block = nir_if_first_then_block(next_if);
325 nir_block *first_else_block = nir_if_first_else_block(next_if);
326
327 link_blocks(block, first_then_block, first_else_block);
328 } else {
329 assert(next->type == nir_cf_node_loop);
330 nir_loop *next_loop = nir_cf_node_as_loop(next);
331
332 nir_block *first_block = nir_loop_first_block(next_loop);
333
334 link_blocks(block, first_block, NULL);
335 insert_phi_undef(first_block, block);
336 }
337 }
338 }
339
340 static nir_block *
341 split_block_end(nir_block *block)
342 {
343 nir_block *new_block = nir_block_create(ralloc_parent(block));
344 new_block->cf_node.parent = block->cf_node.parent;
345 exec_node_insert_after(&block->cf_node.node, &new_block->cf_node.node);
346
347 if (block_ends_in_jump(block)) {
348 /* Figure out what successor block would've had if it didn't have a jump
349 * instruction, and make new_block have that successor.
350 */
351 block_add_normal_succs(new_block);
352 } else {
353 move_successors(block, new_block);
354 }
355
356 return new_block;
357 }
358
359 static nir_block *
360 split_block_before_instr(nir_instr *instr)
361 {
362 assert(instr->type != nir_instr_type_phi);
363 nir_block *new_block = split_block_beginning(instr->block);
364
365 nir_foreach_instr_safe(cur_instr, instr->block) {
366 if (cur_instr == instr)
367 break;
368
369 exec_node_remove(&cur_instr->node);
370 cur_instr->block = new_block;
371 exec_list_push_tail(&new_block->instr_list, &cur_instr->node);
372 }
373
374 return new_block;
375 }
376
377 /* Splits a basic block at the point specified by the cursor. The "before" and
378 * "after" arguments are filled out with the blocks resulting from the split
379 * if non-NULL. Note that the "beginning" of the block is actually interpreted
380 * as before the first non-phi instruction, and it's illegal to split a block
381 * before a phi instruction.
382 */
383
384 static void
385 split_block_cursor(nir_cursor cursor,
386 nir_block **_before, nir_block **_after)
387 {
388 nir_block *before, *after;
389 switch (cursor.option) {
390 case nir_cursor_before_block:
391 after = cursor.block;
392 before = split_block_beginning(cursor.block);
393 break;
394
395 case nir_cursor_after_block:
396 before = cursor.block;
397 after = split_block_end(cursor.block);
398 break;
399
400 case nir_cursor_before_instr:
401 after = cursor.instr->block;
402 before = split_block_before_instr(cursor.instr);
403 break;
404
405 case nir_cursor_after_instr:
406 /* We lower this to split_block_before_instr() so that we can keep the
407 * after-a-jump-instr case contained to split_block_end().
408 */
409 if (nir_instr_is_last(cursor.instr)) {
410 before = cursor.instr->block;
411 after = split_block_end(cursor.instr->block);
412 } else {
413 after = cursor.instr->block;
414 before = split_block_before_instr(nir_instr_next(cursor.instr));
415 }
416 break;
417
418 default:
419 unreachable("not reached");
420 }
421
422 if (_before)
423 *_before = before;
424 if (_after)
425 *_after = after;
426 }
427
428 /**
429 * Inserts a non-basic block between two basic blocks and links them together.
430 */
431
432 static void
433 insert_non_block(nir_block *before, nir_cf_node *node, nir_block *after)
434 {
435 node->parent = before->cf_node.parent;
436 exec_node_insert_after(&before->cf_node.node, &node->node);
437 link_block_to_non_block(before, node);
438 link_non_block_to_block(node, after);
439 }
440
441 /* walk up the control flow tree to find the innermost enclosed loop */
442 static nir_loop *
443 nearest_loop(nir_cf_node *node)
444 {
445 while (node->type != nir_cf_node_loop) {
446 node = node->parent;
447 }
448
449 return nir_cf_node_as_loop(node);
450 }
451
452 /*
453 * update the CFG after a jump instruction has been added to the end of a block
454 */
455
456 void
457 nir_handle_add_jump(nir_block *block)
458 {
459 nir_instr *instr = nir_block_last_instr(block);
460 nir_jump_instr *jump_instr = nir_instr_as_jump(instr);
461
462 unlink_block_successors(block);
463
464 nir_function_impl *impl = nir_cf_node_get_function(&block->cf_node);
465 nir_metadata_preserve(impl, nir_metadata_none);
466
467 if (jump_instr->type == nir_jump_break ||
468 jump_instr->type == nir_jump_continue) {
469 nir_loop *loop = nearest_loop(&block->cf_node);
470
471 if (jump_instr->type == nir_jump_continue) {
472 nir_block *first_block = nir_loop_first_block(loop);
473 link_blocks(block, first_block, NULL);
474 } else {
475 nir_cf_node *after = nir_cf_node_next(&loop->cf_node);
476 assert(after->type == nir_cf_node_block);
477 nir_block *after_block = nir_cf_node_as_block(after);
478 link_blocks(block, after_block, NULL);
479 }
480 } else {
481 assert(jump_instr->type == nir_jump_return);
482 link_blocks(block, impl->end_block, NULL);
483 }
484 }
485
486 static void
487 remove_phi_src(nir_block *block, nir_block *pred)
488 {
489 nir_foreach_instr(instr, block) {
490 if (instr->type != nir_instr_type_phi)
491 break;
492
493 nir_phi_instr *phi = nir_instr_as_phi(instr);
494 nir_foreach_phi_src_safe(src, phi) {
495 if (src->pred == pred) {
496 list_del(&src->src.use_link);
497 exec_node_remove(&src->node);
498 }
499 }
500 }
501 }
502
503 /* Removes the successor of a block with a jump. Note that the jump to be
504 * eliminated may be free-floating.
505 */
506
507 static void
508 unlink_jump(nir_block *block, nir_jump_type type, bool add_normal_successors)
509 {
510 if (block->successors[0])
511 remove_phi_src(block->successors[0], block);
512 if (block->successors[1])
513 remove_phi_src(block->successors[1], block);
514
515 unlink_block_successors(block);
516 if (add_normal_successors)
517 block_add_normal_succs(block);
518 }
519
520 void
521 nir_handle_remove_jump(nir_block *block, nir_jump_type type)
522 {
523 unlink_jump(block, type, true);
524
525 nir_function_impl *impl = nir_cf_node_get_function(&block->cf_node);
526 nir_metadata_preserve(impl, nir_metadata_none);
527 }
528
529 static void
530 update_if_uses(nir_cf_node *node)
531 {
532 if (node->type != nir_cf_node_if)
533 return;
534
535 nir_if *if_stmt = nir_cf_node_as_if(node);
536
537 if_stmt->condition.parent_if = if_stmt;
538 if (if_stmt->condition.is_ssa) {
539 list_addtail(&if_stmt->condition.use_link,
540 &if_stmt->condition.ssa->if_uses);
541 } else {
542 list_addtail(&if_stmt->condition.use_link,
543 &if_stmt->condition.reg.reg->if_uses);
544 }
545 }
546
547 /**
548 * Stitch two basic blocks together into one. The aggregate must have the same
549 * predecessors as the first and the same successors as the second.
550 */
551
552 static void
553 stitch_blocks(nir_block *before, nir_block *after)
554 {
555 /*
556 * We move after into before, so we have to deal with up to 2 successors vs.
557 * possibly a large number of predecessors.
558 *
559 * TODO: special case when before is empty and after isn't?
560 */
561
562 if (block_ends_in_jump(before)) {
563 assert(exec_list_is_empty(&after->instr_list));
564 if (after->successors[0])
565 remove_phi_src(after->successors[0], after);
566 if (after->successors[1])
567 remove_phi_src(after->successors[1], after);
568 unlink_block_successors(after);
569 exec_node_remove(&after->cf_node.node);
570 } else {
571 move_successors(after, before);
572
573 foreach_list_typed(nir_instr, instr, node, &after->instr_list) {
574 instr->block = before;
575 }
576
577 exec_list_append(&before->instr_list, &after->instr_list);
578 exec_node_remove(&after->cf_node.node);
579 }
580 }
581
582 void
583 nir_cf_node_insert(nir_cursor cursor, nir_cf_node *node)
584 {
585 nir_block *before, *after;
586
587 split_block_cursor(cursor, &before, &after);
588
589 if (node->type == nir_cf_node_block) {
590 nir_block *block = nir_cf_node_as_block(node);
591 exec_node_insert_after(&before->cf_node.node, &block->cf_node.node);
592 block->cf_node.parent = before->cf_node.parent;
593 /* stitch_blocks() assumes that any block that ends with a jump has
594 * already been setup with the correct successors, so we need to set
595 * up jumps here as the block is being inserted.
596 */
597 if (block_ends_in_jump(block))
598 nir_handle_add_jump(block);
599
600 stitch_blocks(block, after);
601 stitch_blocks(before, block);
602 } else {
603 update_if_uses(node);
604 insert_non_block(before, node, after);
605 }
606 }
607
608 static bool
609 replace_ssa_def_uses(nir_ssa_def *def, void *void_impl)
610 {
611 nir_function_impl *impl = void_impl;
612 void *mem_ctx = ralloc_parent(impl);
613
614 nir_ssa_undef_instr *undef =
615 nir_ssa_undef_instr_create(mem_ctx, def->num_components,
616 def->bit_size);
617 nir_instr_insert_before_cf_list(&impl->body, &undef->instr);
618 nir_ssa_def_rewrite_uses(def, nir_src_for_ssa(&undef->def));
619 return true;
620 }
621
622 static void
623 cleanup_cf_node(nir_cf_node *node, nir_function_impl *impl)
624 {
625 switch (node->type) {
626 case nir_cf_node_block: {
627 nir_block *block = nir_cf_node_as_block(node);
628 /* We need to walk the instructions and clean up defs/uses */
629 nir_foreach_instr_safe(instr, block) {
630 if (instr->type == nir_instr_type_jump) {
631 nir_jump_type jump_type = nir_instr_as_jump(instr)->type;
632 unlink_jump(block, jump_type, false);
633 } else {
634 nir_foreach_ssa_def(instr, replace_ssa_def_uses, impl);
635 nir_instr_remove(instr);
636 }
637 }
638 break;
639 }
640
641 case nir_cf_node_if: {
642 nir_if *if_stmt = nir_cf_node_as_if(node);
643 foreach_list_typed(nir_cf_node, child, node, &if_stmt->then_list)
644 cleanup_cf_node(child, impl);
645 foreach_list_typed(nir_cf_node, child, node, &if_stmt->else_list)
646 cleanup_cf_node(child, impl);
647
648 list_del(&if_stmt->condition.use_link);
649 break;
650 }
651
652 case nir_cf_node_loop: {
653 nir_loop *loop = nir_cf_node_as_loop(node);
654 foreach_list_typed(nir_cf_node, child, node, &loop->body)
655 cleanup_cf_node(child, impl);
656 break;
657 }
658 case nir_cf_node_function: {
659 nir_function_impl *impl = nir_cf_node_as_function(node);
660 foreach_list_typed(nir_cf_node, child, node, &impl->body)
661 cleanup_cf_node(child, impl);
662 break;
663 }
664 default:
665 unreachable("Invalid CF node type");
666 }
667 }
668
669 void
670 nir_cf_extract(nir_cf_list *extracted, nir_cursor begin, nir_cursor end)
671 {
672 nir_block *block_begin, *block_end, *block_before, *block_after;
673
674 if (nir_cursors_equal(begin, end)) {
675 exec_list_make_empty(&extracted->list);
676 extracted->impl = NULL; /* we shouldn't need this */
677 return;
678 }
679
680 /* In the case where begin points to an instruction in some basic block and
681 * end points to the end of the same basic block, we rely on the fact that
682 * splitting on an instruction moves earlier instructions into a new basic
683 * block. If the later instructions were moved instead, then the end cursor
684 * would be pointing to the same place that begin used to point to, which
685 * is obviously not what we want.
686 */
687 split_block_cursor(begin, &block_before, &block_begin);
688 split_block_cursor(end, &block_end, &block_after);
689
690 extracted->impl = nir_cf_node_get_function(&block_begin->cf_node);
691 exec_list_make_empty(&extracted->list);
692
693 /* Dominance and other block-related information is toast. */
694 nir_metadata_preserve(extracted->impl, nir_metadata_none);
695
696 nir_cf_node *cf_node = &block_begin->cf_node;
697 nir_cf_node *cf_node_end = &block_end->cf_node;
698 while (true) {
699 nir_cf_node *next = nir_cf_node_next(cf_node);
700
701 exec_node_remove(&cf_node->node);
702 cf_node->parent = NULL;
703 exec_list_push_tail(&extracted->list, &cf_node->node);
704
705 if (cf_node == cf_node_end)
706 break;
707
708 cf_node = next;
709 }
710
711 stitch_blocks(block_before, block_after);
712 }
713
714 void
715 nir_cf_reinsert(nir_cf_list *cf_list, nir_cursor cursor)
716 {
717 nir_block *before, *after;
718
719 if (exec_list_is_empty(&cf_list->list))
720 return;
721
722 split_block_cursor(cursor, &before, &after);
723
724 foreach_list_typed_safe(nir_cf_node, node, node, &cf_list->list) {
725 exec_node_remove(&node->node);
726 node->parent = before->cf_node.parent;
727 exec_node_insert_node_before(&after->cf_node.node, &node->node);
728 }
729
730 stitch_blocks(before,
731 nir_cf_node_as_block(nir_cf_node_next(&before->cf_node)));
732 stitch_blocks(nir_cf_node_as_block(nir_cf_node_prev(&after->cf_node)),
733 after);
734 }
735
736 void
737 nir_cf_delete(nir_cf_list *cf_list)
738 {
739 foreach_list_typed(nir_cf_node, node, node, &cf_list->list) {
740 cleanup_cf_node(node, cf_list->impl);
741 }
742 }