nv50: put low limit on REG_ALLOC_TEMP and FP_RESULT_COUNT
[mesa.git] / src / gallium / drivers / nv50 / nv50_pc.c
1 /*
2 * Copyright 2010 Christoph Bumiller
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 shall be included in
12 * all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
18 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
19 * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 * SOFTWARE.
21 */
22
23 /* #define NV50PC_DEBUG */
24
25 #include "nv50_pc.h"
26 #include "nv50_program.h"
27
28 #include <stdio.h>
29
30 /* returns TRUE if operands 0 and 1 can be swapped */
31 boolean
32 nv_op_commutative(uint opcode)
33 {
34 switch (opcode) {
35 case NV_OP_ADD:
36 case NV_OP_MUL:
37 case NV_OP_MAD:
38 case NV_OP_AND:
39 case NV_OP_OR:
40 case NV_OP_XOR:
41 case NV_OP_MIN:
42 case NV_OP_MAX:
43 case NV_OP_SAD:
44 return TRUE;
45 default:
46 return FALSE;
47 }
48 }
49
50 /* return operand to which the address register applies */
51 int
52 nv50_indirect_opnd(struct nv_instruction *i)
53 {
54 if (!i->src[4])
55 return -1;
56
57 switch (i->opcode) {
58 case NV_OP_MOV:
59 case NV_OP_LDA:
60 case NV_OP_STA:
61 return 0;
62 default:
63 return 1;
64 }
65 }
66
67 boolean
68 nv50_nvi_can_use_imm(struct nv_instruction *nvi, int s)
69 {
70 if (nvi->flags_src || nvi->flags_def)
71 return FALSE;
72
73 switch (nvi->opcode) {
74 case NV_OP_ADD:
75 case NV_OP_MUL:
76 case NV_OP_AND:
77 case NV_OP_OR:
78 case NV_OP_XOR:
79 case NV_OP_SHL:
80 case NV_OP_SHR:
81 return (s == 1) && (nvi->src[0]->value->reg.file == NV_FILE_GPR) &&
82 (nvi->def[0]->reg.file == NV_FILE_GPR);
83 case NV_OP_MOV:
84 assert(s == 0);
85 return (nvi->def[0]->reg.file == NV_FILE_GPR);
86 default:
87 return FALSE;
88 }
89 }
90
91 boolean
92 nv50_nvi_can_load(struct nv_instruction *nvi, int s, struct nv_value *value)
93 {
94 int i;
95
96 for (i = 0; i < 3 && nvi->src[i]; ++i)
97 if (nvi->src[i]->value->reg.file == NV_FILE_IMM)
98 return FALSE;
99
100 switch (nvi->opcode) {
101 case NV_OP_ABS:
102 case NV_OP_ADD:
103 case NV_OP_CEIL:
104 case NV_OP_FLOOR:
105 case NV_OP_TRUNC:
106 case NV_OP_CVT:
107 case NV_OP_NEG:
108 case NV_OP_MAD:
109 case NV_OP_MUL:
110 case NV_OP_SAT:
111 case NV_OP_SUB:
112 case NV_OP_MAX:
113 case NV_OP_MIN:
114 if (s == 0 && (value->reg.file == NV_FILE_MEM_S ||
115 value->reg.file == NV_FILE_MEM_P))
116 return TRUE;
117 if (value->reg.file < NV_FILE_MEM_C(0) ||
118 value->reg.file > NV_FILE_MEM_C(15))
119 return FALSE;
120 return (s == 1) ||
121 ((s == 2) && (nvi->src[1]->value->reg.file == NV_FILE_GPR));
122 case NV_OP_MOV:
123 assert(s == 0);
124 return /* TRUE */ FALSE; /* don't turn MOVs into loads */
125 default:
126 return FALSE;
127 }
128 }
129
130 /* Return whether this instruction can be executed conditionally. */
131 boolean
132 nv50_nvi_can_predicate(struct nv_instruction *nvi)
133 {
134 int i;
135
136 if (nvi->flags_src)
137 return FALSE;
138 for (i = 0; i < 4 && nvi->src[i]; ++i)
139 if (nvi->src[i]->value->reg.file == NV_FILE_IMM)
140 return FALSE;
141 return TRUE;
142 }
143
144 ubyte
145 nv50_supported_src_mods(uint opcode, int s)
146 {
147 switch (opcode) {
148 case NV_OP_ABS:
149 return NV_MOD_NEG | NV_MOD_ABS; /* obviously */
150 case NV_OP_ADD:
151 case NV_OP_MUL:
152 case NV_OP_MAD:
153 return NV_MOD_NEG;
154 case NV_OP_DFDX:
155 case NV_OP_DFDY:
156 assert(s == 0);
157 return NV_MOD_NEG;
158 case NV_OP_MAX:
159 case NV_OP_MIN:
160 return NV_MOD_ABS;
161 case NV_OP_CVT:
162 case NV_OP_LG2:
163 case NV_OP_NEG:
164 case NV_OP_PREEX2:
165 case NV_OP_PRESIN:
166 case NV_OP_RCP:
167 case NV_OP_RSQ:
168 return NV_MOD_ABS | NV_MOD_NEG;
169 default:
170 return 0;
171 }
172 }
173
174 /* We may want an opcode table. */
175 boolean
176 nv50_op_can_write_flags(uint opcode)
177 {
178 if (nv_is_vector_op(opcode))
179 return FALSE;
180 switch (opcode) { /* obvious ones like KIL, CALL, etc. not included */
181 case NV_OP_PHI:
182 case NV_OP_MOV:
183 case NV_OP_LINTERP:
184 case NV_OP_PINTERP:
185 case NV_OP_LDA:
186 return FALSE;
187 default:
188 break;
189 }
190 if (opcode >= NV_OP_RCP && opcode <= NV_OP_PREEX2)
191 return FALSE;
192 return TRUE;
193 }
194
195 int
196 nv_nvi_refcount(struct nv_instruction *nvi)
197 {
198 int i, rc;
199
200 rc = nvi->flags_def ? nvi->flags_def->refc : 0;
201
202 for (i = 0; i < 4; ++i) {
203 if (!nvi->def[i])
204 return rc;
205 rc += nvi->def[i]->refc;
206 }
207 return rc;
208 }
209
210 int
211 nvcg_replace_value(struct nv_pc *pc, struct nv_value *old_val,
212 struct nv_value *new_val)
213 {
214 int i, n;
215
216 if (old_val == new_val)
217 return old_val->refc;
218
219 for (i = 0, n = 0; i < pc->num_refs; ++i) {
220 if (pc->refs[i]->value == old_val) {
221 ++n;
222 nv_reference(pc, &pc->refs[i], new_val);
223 }
224 }
225 return n;
226 }
227
228 struct nv_value *
229 nvcg_find_constant(struct nv_ref *ref)
230 {
231 struct nv_value *src;
232
233 if (!ref)
234 return NULL;
235
236 src = ref->value;
237 while (src->insn && src->insn->opcode == NV_OP_MOV) {
238 assert(!src->insn->src[0]->mod);
239 src = src->insn->src[0]->value;
240 }
241 if ((src->reg.file == NV_FILE_IMM) ||
242 (src->insn && src->insn->opcode == NV_OP_LDA &&
243 src->insn->src[0]->value->reg.file >= NV_FILE_MEM_C(0) &&
244 src->insn->src[0]->value->reg.file <= NV_FILE_MEM_C(15)))
245 return src;
246 return NULL;
247 }
248
249 struct nv_value *
250 nvcg_find_immediate(struct nv_ref *ref)
251 {
252 struct nv_value *src = nvcg_find_constant(ref);
253
254 return (src && src->reg.file == NV_FILE_IMM) ? src : NULL;
255 }
256
257 static void
258 nv_pc_free_refs(struct nv_pc *pc)
259 {
260 int i;
261 for (i = 0; i < pc->num_refs; i += 64)
262 FREE(pc->refs[i]);
263 FREE(pc->refs);
264 }
265
266 static const char *
267 edge_name(ubyte type)
268 {
269 switch (type) {
270 case CFG_EDGE_FORWARD: return "forward";
271 case CFG_EDGE_BACK: return "back";
272 case CFG_EDGE_LOOP_ENTER: return "loop";
273 case CFG_EDGE_LOOP_LEAVE: return "break";
274 case CFG_EDGE_FAKE: return "fake";
275 default:
276 return "?";
277 }
278 }
279
280 void
281 nv_pc_pass_in_order(struct nv_basic_block *root, nv_pc_pass_func f, void *priv)
282 {
283 struct nv_basic_block *bb[64], *bbb[16], *b;
284 int j, p, pp;
285
286 bb[0] = root;
287 p = 1;
288 pp = 0;
289
290 while (p > 0) {
291 b = bb[--p];
292 b->priv = 0;
293
294 for (j = 1; j >= 0; --j) {
295 if (!b->out[j])
296 continue;
297
298 switch (b->out_kind[j]) {
299 case CFG_EDGE_BACK:
300 continue;
301 case CFG_EDGE_FORWARD:
302 case CFG_EDGE_FAKE:
303 if (++b->out[j]->priv == b->out[j]->num_in)
304 bb[p++] = b->out[j];
305 break;
306 case CFG_EDGE_LOOP_ENTER:
307 bb[p++] = b->out[j];
308 break;
309 case CFG_EDGE_LOOP_LEAVE:
310 bbb[pp++] = b->out[j];
311 break;
312 default:
313 assert(0);
314 break;
315 }
316 }
317
318 f(priv, b);
319
320 if (!p) {
321 p = pp;
322 for (; pp > 0; --pp)
323 bb[pp - 1] = bbb[pp - 1];
324 }
325 }
326 }
327
328 static void
329 nv_do_print_function(void *priv, struct nv_basic_block *b)
330 {
331 struct nv_instruction *i = b->phi;
332
333 debug_printf("=== BB %i ", b->id);
334 if (b->out[0])
335 debug_printf("[%s -> %i] ", edge_name(b->out_kind[0]), b->out[0]->id);
336 if (b->out[1])
337 debug_printf("[%s -> %i] ", edge_name(b->out_kind[1]), b->out[1]->id);
338 debug_printf("===\n");
339
340 i = b->phi;
341 if (!i)
342 i = b->entry;
343 for (; i; i = i->next)
344 nv_print_instruction(i);
345 }
346
347 void
348 nv_print_function(struct nv_basic_block *root)
349 {
350 if (root->subroutine)
351 debug_printf("SUBROUTINE %i\n", root->subroutine);
352 else
353 debug_printf("MAIN\n");
354
355 nv_pc_pass_in_order(root, nv_do_print_function, root);
356 }
357
358 void
359 nv_print_program(struct nv_pc *pc)
360 {
361 int i;
362 for (i = 0; i < pc->num_subroutines + 1; ++i)
363 if (pc->root[i])
364 nv_print_function(pc->root[i]);
365 }
366
367 #ifdef NV50PC_DEBUG
368 static void
369 nv_do_print_cfgraph(struct nv_pc *pc, FILE *f, struct nv_basic_block *b)
370 {
371 int i;
372
373 b->pass_seq = pc->pass_seq;
374
375 fprintf(f, "\t%i [shape=box]\n", b->id);
376
377 for (i = 0; i < 2; ++i) {
378 if (!b->out[i])
379 continue;
380 switch (b->out_kind[i]) {
381 case CFG_EDGE_FORWARD:
382 fprintf(f, "\t%i -> %i;\n", b->id, b->out[i]->id);
383 break;
384 case CFG_EDGE_LOOP_ENTER:
385 fprintf(f, "\t%i -> %i [color=green];\n", b->id, b->out[i]->id);
386 break;
387 case CFG_EDGE_LOOP_LEAVE:
388 fprintf(f, "\t%i -> %i [color=red];\n", b->id, b->out[i]->id);
389 break;
390 case CFG_EDGE_BACK:
391 fprintf(f, "\t%i -> %i;\n", b->id, b->out[i]->id);
392 continue;
393 case CFG_EDGE_FAKE:
394 fprintf(f, "\t%i -> %i [style=dotted];\n", b->id, b->out[i]->id);
395 break;
396 default:
397 assert(0);
398 break;
399 }
400 if (b->out[i]->pass_seq < pc->pass_seq)
401 nv_do_print_cfgraph(pc, f, b->out[i]);
402 }
403 }
404
405 /* Print the control flow graph of subroutine @subr (0 == MAIN) to a file. */
406 static void
407 nv_print_cfgraph(struct nv_pc *pc, const char *filepath, int subr)
408 {
409 FILE *f;
410
411 f = fopen(filepath, "a");
412 if (!f)
413 return;
414
415 fprintf(f, "digraph G {\n");
416
417 ++pc->pass_seq;
418
419 nv_do_print_cfgraph(pc, f, pc->root[subr]);
420
421 fprintf(f, "}\n");
422
423 fclose(f);
424 }
425 #endif
426
427 static INLINE void
428 nvcg_show_bincode(struct nv_pc *pc)
429 {
430 unsigned i;
431
432 for (i = 0; i < pc->bin_size / 4; ++i) {
433 debug_printf("0x%08x ", pc->emit[i]);
434 if ((i % 16) == 15)
435 debug_printf("\n");
436 }
437 debug_printf("\n");
438 }
439
440 static int
441 nv50_emit_program(struct nv_pc *pc)
442 {
443 uint32_t *code = pc->emit;
444 int n;
445
446 NV50_DBGMSG("emitting program: size = %u\n", pc->bin_size);
447
448 for (n = 0; n < pc->num_blocks; ++n) {
449 struct nv_instruction *i;
450 struct nv_basic_block *b = pc->bb_list[n];
451
452 for (i = b->entry; i; i = i->next) {
453 nv50_emit_instruction(pc, i);
454
455 pc->bin_pos += 1 + (pc->emit[0] & 1);
456 pc->emit += 1 + (pc->emit[0] & 1);
457 }
458 }
459 assert(pc->emit == &code[pc->bin_size / 4]);
460
461 /* XXX: we can do better than this ... */
462 if (!(pc->emit[-2] & 1) || (pc->emit[-2] & 2) || (pc->emit[-1] & 3)) {
463 pc->emit[0] = 0xf0000001;
464 pc->emit[1] = 0xe0000000;
465 pc->bin_size += 8;
466 }
467
468 pc->emit = code;
469 code[pc->bin_size / 4 - 1] |= 1;
470
471 #ifdef NV50PC_DEBUG
472 nvcg_show_bincode(pc);
473 #endif
474
475 return 0;
476 }
477
478 int
479 nv50_generate_code(struct nv50_translation_info *ti)
480 {
481 struct nv_pc *pc;
482 int ret;
483 int i;
484
485 pc = CALLOC_STRUCT(nv_pc);
486 if (!pc)
487 return 1;
488
489 pc->root = CALLOC(ti->subr_nr + 1, sizeof(pc->root[0]));
490 if (!pc->root) {
491 FREE(pc);
492 return 1;
493 }
494 pc->num_subroutines = ti->subr_nr;
495
496 ret = nv50_tgsi_to_nc(pc, ti);
497 if (ret)
498 goto out;
499 #ifdef NV50PC_DEBUG
500 nv_print_program(pc);
501 #endif
502
503 pc->opt_reload_elim = ti->store_to_memory ? FALSE : TRUE;
504
505 /* optimization */
506 ret = nv_pc_exec_pass0(pc);
507 if (ret)
508 goto out;
509 #ifdef NV50PC_DEBUG
510 nv_print_program(pc);
511 #endif
512
513 /* register allocation */
514 ret = nv_pc_exec_pass1(pc);
515 if (ret)
516 goto out;
517 #ifdef NV50PC_DEBUG
518 nv_print_program(pc);
519 nv_print_cfgraph(pc, "nv50_shader_cfgraph.dot", 0);
520 #endif
521
522 /* prepare for emission */
523 ret = nv_pc_exec_pass2(pc);
524 if (ret)
525 goto out;
526
527 pc->emit = CALLOC(pc->bin_size / 4 + 2, 4);
528 if (!pc->emit) {
529 ret = 3;
530 goto out;
531 }
532 ret = nv50_emit_program(pc);
533 if (ret)
534 goto out;
535
536 ti->p->code_size = pc->bin_size;
537 ti->p->code = pc->emit;
538
539 ti->p->immd_size = pc->immd_count * 4;
540 ti->p->immd = pc->immd_buf;
541
542 /* highest 16 bit reg to num of 32 bit regs, limit to >= 4 */
543 ti->p->max_gpr = MAX2(4, (pc->max_reg[NV_FILE_GPR] >> 1) + 1);
544
545 ti->p->fixups = pc->fixups;
546 ti->p->num_fixups = pc->num_fixups;
547
548 NV50_DBGMSG("SHADER TRANSLATION - %s\n", ret ? "failure" : "success");
549
550 out:
551 nv_pc_free_refs(pc);
552
553 for (i = 0; i < pc->num_blocks; ++i)
554 FREE(pc->bb_list[i]);
555 if (pc->root)
556 FREE(pc->root);
557 if (ret) { /* on success, these will be referenced by nv50_program */
558 if (pc->emit)
559 FREE(pc->emit);
560 if (pc->immd_buf)
561 FREE(pc->immd_buf);
562 if (pc->fixups)
563 FREE(pc->fixups);
564 }
565 FREE(pc);
566 return ret;
567 }
568
569 static void
570 nvbb_insert_phi(struct nv_basic_block *b, struct nv_instruction *i)
571 {
572 if (!b->phi) {
573 i->prev = NULL;
574 b->phi = i;
575 i->next = b->entry;
576 if (b->entry) {
577 assert(!b->entry->prev && b->exit);
578 b->entry->prev = i;
579 } else {
580 b->entry = i;
581 b->exit = i;
582 }
583 } else {
584 assert(b->entry);
585 if (b->entry->opcode == NV_OP_PHI) { /* insert after entry */
586 assert(b->entry == b->exit);
587 b->entry->next = i;
588 i->prev = b->entry;
589 b->entry = i;
590 b->exit = i;
591 } else { /* insert before entry */
592 assert(b->entry->prev && b->exit);
593 i->next = b->entry;
594 i->prev = b->entry->prev;
595 b->entry->prev = i;
596 i->prev->next = i;
597 }
598 }
599 }
600
601 void
602 nvbb_insert_tail(struct nv_basic_block *b, struct nv_instruction *i)
603 {
604 if (i->opcode == NV_OP_PHI) {
605 nvbb_insert_phi(b, i);
606 } else {
607 i->prev = b->exit;
608 if (b->exit)
609 b->exit->next = i;
610 b->exit = i;
611 if (!b->entry)
612 b->entry = i;
613 else
614 if (i->prev && i->prev->opcode == NV_OP_PHI)
615 b->entry = i;
616 }
617
618 i->bb = b;
619 b->num_instructions++;
620 }
621
622 void
623 nvi_insert_after(struct nv_instruction *at, struct nv_instruction *ni)
624 {
625 if (!at->next) {
626 nvbb_insert_tail(at->bb, ni);
627 return;
628 }
629 ni->next = at->next;
630 ni->prev = at;
631 ni->next->prev = ni;
632 ni->prev->next = ni;
633 }
634
635 void
636 nv_nvi_delete(struct nv_instruction *nvi)
637 {
638 struct nv_basic_block *b = nvi->bb;
639 int j;
640
641 /* debug_printf("REM: "); nv_print_instruction(nvi); */
642
643 for (j = 0; j < 5; ++j)
644 nv_reference(NULL, &nvi->src[j], NULL);
645 nv_reference(NULL, &nvi->flags_src, NULL);
646
647 if (nvi->next)
648 nvi->next->prev = nvi->prev;
649 else {
650 assert(nvi == b->exit);
651 b->exit = nvi->prev;
652 }
653
654 if (nvi->prev)
655 nvi->prev->next = nvi->next;
656
657 if (nvi == b->entry) {
658 /* PHIs don't get hooked to b->entry */
659 b->entry = nvi->next;
660 assert(!nvi->prev || nvi->prev->opcode == NV_OP_PHI);
661 }
662
663 if (nvi == b->phi) {
664 if (nvi->opcode != NV_OP_PHI)
665 NV50_DBGMSG("NOTE: b->phi points to non-PHI instruction\n");
666
667 assert(!nvi->prev);
668 if (!nvi->next || nvi->next->opcode != NV_OP_PHI)
669 b->phi = NULL;
670 else
671 b->phi = nvi->next;
672 }
673 }
674
675 void
676 nv_nvi_permute(struct nv_instruction *i1, struct nv_instruction *i2)
677 {
678 struct nv_basic_block *b = i1->bb;
679
680 assert(i1->opcode != NV_OP_PHI &&
681 i2->opcode != NV_OP_PHI);
682 assert(i1->next == i2);
683
684 if (b->exit == i2)
685 b->exit = i1;
686
687 if (b->entry == i1)
688 b->entry = i2;
689
690 i2->prev = i1->prev;
691 i1->next = i2->next;
692 i2->next = i1;
693 i1->prev = i2;
694
695 if (i2->prev)
696 i2->prev->next = i2;
697 if (i1->next)
698 i1->next->prev = i1;
699 }
700
701 void
702 nvbb_attach_block(struct nv_basic_block *parent,
703 struct nv_basic_block *b, ubyte edge_kind)
704 {
705 assert(b->num_in < 8);
706
707 if (parent->out[0]) {
708 assert(!parent->out[1]);
709 parent->out[1] = b;
710 parent->out_kind[1] = edge_kind;
711 } else {
712 parent->out[0] = b;
713 parent->out_kind[0] = edge_kind;
714 }
715
716 b->in[b->num_in] = parent;
717 b->in_kind[b->num_in++] = edge_kind;
718 }
719
720 /* NOTE: all BRKs are treated as conditional, so there are 2 outgoing BBs */
721
722 boolean
723 nvbb_dominated_by(struct nv_basic_block *b, struct nv_basic_block *d)
724 {
725 int j;
726
727 if (b == d)
728 return TRUE;
729
730 for (j = 0; j < b->num_in; ++j)
731 if ((b->in_kind[j] != CFG_EDGE_BACK) && !nvbb_dominated_by(b->in[j], d))
732 return FALSE;
733
734 return j ? TRUE : FALSE;
735 }
736
737 /* check if @bf (future) can be reached from @bp (past), stop at @bt */
738 boolean
739 nvbb_reachable_by(struct nv_basic_block *bf, struct nv_basic_block *bp,
740 struct nv_basic_block *bt)
741 {
742 struct nv_basic_block *q[NV_PC_MAX_BASIC_BLOCKS], *b;
743 int i, p, n;
744
745 p = 0;
746 n = 1;
747 q[0] = bp;
748
749 while (p < n) {
750 b = q[p++];
751
752 if (b == bf)
753 break;
754 if (b == bt)
755 continue;
756 assert(n <= (1024 - 2));
757
758 for (i = 0; i < 2; ++i) {
759 if (b->out[i] && !IS_WALL_EDGE(b->out_kind[i]) && !b->out[i]->priv) {
760 q[n] = b->out[i];
761 q[n++]->priv = 1;
762 }
763 }
764 }
765 for (--n; n >= 0; --n)
766 q[n]->priv = 0;
767
768 return (b == bf);
769 }
770
771 static struct nv_basic_block *
772 nvbb_find_dom_frontier(struct nv_basic_block *b, struct nv_basic_block *df)
773 {
774 struct nv_basic_block *out;
775 int i;
776
777 if (!nvbb_dominated_by(df, b)) {
778 for (i = 0; i < df->num_in; ++i) {
779 if (df->in_kind[i] == CFG_EDGE_BACK)
780 continue;
781 if (nvbb_dominated_by(df->in[i], b))
782 return df;
783 }
784 }
785 for (i = 0; i < 2 && df->out[i]; ++i) {
786 if (df->out_kind[i] == CFG_EDGE_BACK)
787 continue;
788 if ((out = nvbb_find_dom_frontier(b, df->out[i])))
789 return out;
790 }
791 return NULL;
792 }
793
794 struct nv_basic_block *
795 nvbb_dom_frontier(struct nv_basic_block *b)
796 {
797 struct nv_basic_block *df;
798 int i;
799
800 for (i = 0; i < 2 && b->out[i]; ++i)
801 if ((df = nvbb_find_dom_frontier(b, b->out[i])))
802 return df;
803 return NULL;
804 }