2 * Copyright 2010 Christoph Bumiller
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:
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
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
23 #define NOUVEAU_DEBUG 1
25 /* #define NVC0_RA_DEBUG_LIVEI */
26 /* #define NVC0_RA_DEBUG_LIVE_SETS */
27 /* #define NVC0_RA_DEBUG_JOIN */
30 #include "util/u_simple_list.h"
32 #define NVC0_NUM_REGISTER_FILES 3
34 /* @unit_shift: log2 of min allocation unit for register */
36 uint32_t bits
[NVC0_NUM_REGISTER_FILES
][2];
37 uint32_t last
[NVC0_NUM_REGISTER_FILES
];
38 int log2_unit
[NVC0_NUM_REGISTER_FILES
];
44 struct nv_instruction
**insns
;
50 ranges_coalesce(struct nv_range
*range
)
52 while (range
->next
&& range
->end
>= range
->next
->bgn
) {
53 struct nv_range
*rnn
= range
->next
->next
;
54 assert(range
->bgn
<= range
->next
->bgn
);
55 range
->end
= MAX2(range
->end
, range
->next
->end
);
62 add_range_ex(struct nv_value
*val
, int bgn
, int end
, struct nv_range
*new_range
)
64 struct nv_range
*range
, **nextp
= &val
->livei
;
66 for (range
= val
->livei
; range
; range
= range
->next
) {
68 break; /* insert before */
70 if (bgn
> range
->end
) {
72 continue; /* insert after */
76 if (bgn
< range
->bgn
) {
80 ranges_coalesce(range
);
83 if (end
> range
->end
) {
85 ranges_coalesce(range
);
88 assert(bgn
>= range
->bgn
);
89 assert(end
<= range
->end
);
94 new_range
= CALLOC_STRUCT(nv_range
);
98 new_range
->next
= range
;
104 add_range(struct nv_value
*val
, struct nv_basic_block
*b
, int end
)
108 if (!val
->insn
) /* ignore non-def values */
110 assert(b
->entry
->serial
<= b
->exit
->serial
);
111 assert(b
->phi
->serial
<= end
);
112 assert(b
->exit
->serial
+ 1 >= end
);
114 bgn
= val
->insn
->serial
;
115 if (bgn
< b
->entry
->serial
|| bgn
> b
->exit
->serial
)
116 bgn
= b
->entry
->serial
;
120 add_range_ex(val
, bgn
, end
, NULL
);
123 #if defined(NVC0_RA_DEBUG_JOIN) || defined(NVC0_RA_DEBUG_LIVEI)
125 livei_print(struct nv_value
*a
)
127 struct nv_range
*r
= a
->livei
;
129 debug_printf("livei %i: ", a
->n
);
131 debug_printf("[%i, %i) ", r
->bgn
, r
->end
);
139 livei_unify(struct nv_value
*dst
, struct nv_value
*src
)
141 struct nv_range
*range
, *next
;
143 for (range
= src
->livei
; range
; range
= next
) {
145 if (add_range_ex(dst
, range
->bgn
, range
->end
, range
))
152 livei_release(struct nv_value
*val
)
154 struct nv_range
*range
, *next
;
156 for (range
= val
->livei
; range
; range
= next
) {
163 livei_have_overlap(struct nv_value
*a
, struct nv_value
*b
)
165 struct nv_range
*r_a
, *r_b
;
167 for (r_a
= a
->livei
; r_a
; r_a
= r_a
->next
) {
168 for (r_b
= b
->livei
; r_b
; r_b
= r_b
->next
) {
169 if (r_b
->bgn
< r_a
->end
&&
178 livei_end(struct nv_value
*a
)
180 struct nv_range
*r
= a
->livei
;
189 livei_contains(struct nv_value
*a
, int pos
)
193 for (r
= a
->livei
; r
&& r
->bgn
<= pos
; r
= r
->next
)
200 reg_assign(struct register_set
*set
, struct nv_value
**def
, int n
)
204 int f
= def
[0]->reg
.file
;
209 s
= (k
* def
[0]->reg
.size
) >> set
->log2_unit
[f
];
214 for (i
= 0; i
* 32 < set
->last
[f
]; ++i
) {
215 if (set
->bits
[f
][i
] == 0xffffffff)
218 for (id
= 0; id
< 32; id
+= s
)
219 if (!(set
->bits
[f
][i
] & (m
<< id
)))
224 if (i
* 32 + id
> set
->last
[f
])
227 set
->bits
[f
][i
] |= m
<< id
;
231 set
->pc
->max_reg
[f
] = MAX2(set
->pc
->max_reg
[f
], id
+ s
- 1);
233 for (i
= 0; i
< n
; ++i
)
235 def
[i
]->reg
.id
= id
++;
241 reg_occupy(struct register_set
*set
, struct nv_value
*val
)
243 int id
= val
->reg
.id
, f
= val
->reg
.file
;
248 m
= (1 << (val
->reg
.size
>> set
->log2_unit
[f
])) - 1;
250 set
->bits
[f
][id
/ 32] |= m
<< (id
% 32);
252 if (set
->pc
->max_reg
[f
] < id
)
253 set
->pc
->max_reg
[f
] = id
;
257 reg_release(struct register_set
*set
, struct nv_value
*val
)
259 int id
= val
->reg
.id
, f
= val
->reg
.file
;
264 m
= (1 << (val
->reg
.size
>> set
->log2_unit
[f
])) - 1;
266 set
->bits
[f
][id
/ 32] &= ~(m
<< (id
% 32));
269 static INLINE boolean
270 join_allowed(struct nv_pc_pass
*ctx
, struct nv_value
*a
, struct nv_value
*b
)
273 struct nv_value
*val
;
275 if (a
->reg
.file
!= b
->reg
.file
|| a
->reg
.size
!= b
->reg
.size
)
278 if (a
->join
->reg
.id
== b
->join
->reg
.id
)
281 /* either a or b or both have been assigned */
283 if (a
->join
->reg
.id
>= 0 && b
->join
->reg
.id
>= 0)
286 if (b
->join
->reg
.id
>= 0) {
287 if (b
->join
->reg
.id
== 63)
293 if (a
->join
->reg
.id
== 63)
296 for (i
= 0; i
< ctx
->pc
->num_values
; ++i
) {
297 val
= &ctx
->pc
->values
[i
];
299 if (val
->join
->reg
.id
!= a
->join
->reg
.id
)
301 if (val
->join
!= a
->join
&& livei_have_overlap(val
->join
, b
->join
))
308 do_join_values(struct nv_pc_pass
*ctx
, struct nv_value
*a
, struct nv_value
*b
)
311 struct nv_value
*bjoin
= b
->join
;
313 if (b
->join
->reg
.id
>= 0)
314 a
->join
->reg
.id
= b
->join
->reg
.id
;
316 livei_unify(a
->join
, b
->join
);
318 #ifdef NVC0_RA_DEBUG_JOIN
319 debug_printf("joining %i to %i\n", b
->n
, a
->n
);
322 /* make a->join the new representative */
323 for (j
= 0; j
< ctx
->pc
->num_values
; ++j
)
324 if (ctx
->pc
->values
[j
].join
== bjoin
)
325 ctx
->pc
->values
[j
].join
= a
->join
;
327 assert(b
->join
== a
->join
);
331 try_join_values(struct nv_pc_pass
*ctx
, struct nv_value
*a
, struct nv_value
*b
)
333 if (!join_allowed(ctx
, a
, b
)) {
334 #ifdef NVC0_RA_DEBUG_JOIN
335 debug_printf("cannot join %i to %i: not allowed\n", b
->n
, a
->n
);
339 if (livei_have_overlap(a
->join
, b
->join
)) {
340 #ifdef NVC0_RA_DEBUG_JOIN
341 debug_printf("cannot join %i to %i: livei overlap\n", b
->n
, a
->n
);
348 do_join_values(ctx
, a
, b
);
351 static INLINE boolean
352 need_new_else_block(struct nv_basic_block
*b
, struct nv_basic_block
*p
)
357 if (p
->out
[i
] && !IS_LOOP_EDGE(p
->out_kind
[i
]))
360 return (b
->num_in
> 1) && (n
== 2);
364 phi_opnd_for_bb(struct nv_instruction
*phi
, struct nv_basic_block
*b
,
365 struct nv_basic_block
*tb
)
369 for (j
= -1, i
= 0; i
< 6 && phi
->src
[i
]; ++i
) {
370 if (!nvc0_bblock_reachable_by(b
, phi
->src
[i
]->value
->insn
->bb
, tb
))
372 /* NOTE: back-edges are ignored by the reachable-by check */
373 if (j
< 0 || !nvc0_bblock_reachable_by(phi
->src
[j
]->value
->insn
->bb
,
374 phi
->src
[i
]->value
->insn
->bb
, tb
))
380 /* For each operand of each PHI in b, generate a new value by inserting a MOV
381 * at the end of the block it is coming from and replace the operand with its
382 * result. This eliminates liveness conflicts and enables us to let values be
383 * copied to the right register if such a conflict exists nonetheless.
385 * These MOVs are also crucial in making sure the live intervals of phi srces
386 * are extended until the end of the loop, since they are not included in the
390 pass_generate_phi_movs(struct nv_pc_pass
*ctx
, struct nv_basic_block
*b
)
392 struct nv_instruction
*i
, *ni
;
393 struct nv_value
*val
;
394 struct nv_basic_block
*p
, *pn
;
397 b
->pass_seq
= ctx
->pc
->pass_seq
;
399 for (n
= 0; n
< b
->num_in
; ++n
) {
403 if (need_new_else_block(b
, p
)) {
404 pn
= new_basic_block(ctx
->pc
);
411 if (p
->exit
->target
== b
) /* target to new else-block */
412 p
->exit
->target
= pn
;
420 ctx
->pc
->current_block
= pn
;
422 for (i
= b
->phi
; i
&& i
->opcode
== NV_OP_PHI
; i
= i
->next
) {
423 if ((j
= phi_opnd_for_bb(i
, p
, b
)) < 0)
425 val
= i
->src
[j
]->value
;
427 if (i
->src
[j
]->flags
) {
428 /* value already encountered from a different in-block */
429 val
= val
->insn
->src
[0]->value
;
430 while (j
< 6 && i
->src
[j
])
435 ni
= new_instruction(ctx
->pc
, NV_OP_MOV
);
437 /* TODO: insert instruction at correct position in the first place */
438 if (ni
->prev
&& ni
->prev
->target
)
439 nvc0_insns_permute(ni
->prev
, ni
);
441 ni
->def
[0] = new_value_like(ctx
->pc
, val
);
442 ni
->def
[0]->insn
= ni
;
443 nv_reference(ctx
->pc
, ni
, 0, val
);
444 nv_reference(ctx
->pc
, i
, j
, ni
->def
[0]); /* new phi source = MOV def */
445 i
->src
[j
]->flags
= 1;
448 if (pn
!= p
&& pn
->exit
) {
449 ctx
->pc
->current_block
= b
->in
[n
? 0 : 1];
450 ni
= new_instruction(ctx
->pc
, NV_OP_BRA
);
456 for (j
= 0; j
< 2; ++j
)
457 if (b
->out
[j
] && b
->out
[j
]->pass_seq
< ctx
->pc
->pass_seq
)
458 pass_generate_phi_movs(ctx
, b
->out
[j
]);
464 pass_join_values(struct nv_pc_pass
*ctx
, int iter
)
468 for (n
= 0; n
< ctx
->num_insns
; ++n
) {
469 struct nv_instruction
*i
= ctx
->insns
[n
];
475 for (c
= 0; c
< 6 && i
->src
[c
]; ++c
)
476 try_join_values(ctx
, i
->def
[0], i
->src
[c
]->value
);
479 if ((iter
== 2) && i
->src
[0]->value
->insn
&&
480 !nv_is_texture_op(i
->src
[0]->value
->join
->insn
->opcode
))
481 try_join_values(ctx
, i
->def
[0], i
->src
[0]->value
);
486 for (c
= 0; c
< 6 && i
->src
[c
]; ++c
) {
487 assert(join_allowed(ctx
, i
->def
[0], i
->src
[c
]->value
));
488 do_join_values(ctx
, i
->def
[0], i
->src
[c
]->value
);
498 for (c
= 0; c
< 6 && i
->src
[c
]; ++c
)
499 do_join_values(ctx
, i
->def
[c
], i
->src
[c
]->value
);
508 /* Order the instructions so that live intervals can be expressed in numbers. */
510 pass_order_instructions(void *priv
, struct nv_basic_block
*b
)
512 struct nv_pc_pass
*ctx
= (struct nv_pc_pass
*)priv
;
513 struct nv_instruction
*i
;
515 b
->pass_seq
= ctx
->pc
->pass_seq
;
517 assert(!b
->exit
|| !b
->exit
->next
);
518 for (i
= b
->phi
; i
; i
= i
->next
) {
519 i
->serial
= ctx
->num_insns
;
520 ctx
->insns
[ctx
->num_insns
++] = i
;
525 bb_live_set_print(struct nv_pc
*pc
, struct nv_basic_block
*b
)
527 #ifdef NVC0_RA_DEBUG_LIVE_SETS
528 struct nv_value
*val
;
531 debug_printf("LIVE-INs of BB:%i: ", b
->id
);
533 for (j
= 0; j
< pc
->num_values
; ++j
) {
534 if (!(b
->live_set
[j
/ 32] & (1 << (j
% 32))))
536 val
= &pc
->values
[j
];
539 debug_printf("%i ", val
->n
);
546 live_set_add(struct nv_basic_block
*b
, struct nv_value
*val
)
548 if (!val
->insn
) /* don't add non-def values */
550 b
->live_set
[val
->n
/ 32] |= 1 << (val
->n
% 32);
554 live_set_rem(struct nv_basic_block
*b
, struct nv_value
*val
)
556 b
->live_set
[val
->n
/ 32] &= ~(1 << (val
->n
% 32));
559 static INLINE boolean
560 live_set_test(struct nv_basic_block
*b
, struct nv_ref
*ref
)
562 int n
= ref
->value
->n
;
563 return b
->live_set
[n
/ 32] & (1 << (n
% 32));
566 /* The live set of a block contains those values that are live immediately
567 * before the beginning of the block, so do a backwards scan.
570 pass_build_live_sets(struct nv_pc_pass
*ctx
, struct nv_basic_block
*b
)
572 struct nv_instruction
*i
;
575 if (b
->pass_seq
>= ctx
->pc
->pass_seq
)
577 b
->pass_seq
= ctx
->pc
->pass_seq
;
579 /* slight hack for undecidedness: set phi = entry if it's undefined */
583 for (n
= 0; n
< 2; ++n
) {
584 if (!b
->out
[n
] || b
->out
[n
] == b
)
586 ret
= pass_build_live_sets(ctx
, b
->out
[n
]);
591 for (j
= 0; j
< (ctx
->pc
->num_values
+ 31) / 32; ++j
)
592 b
->live_set
[j
] = b
->out
[n
]->live_set
[j
];
594 for (j
= 0; j
< (ctx
->pc
->num_values
+ 31) / 32; ++j
)
595 b
->live_set
[j
] |= b
->out
[n
]->live_set
[j
];
602 bb_live_set_print(ctx
->pc
, b
);
604 for (i
= b
->exit
; i
!= b
->entry
->prev
; i
= i
->prev
) {
605 for (j
= 0; j
< 5 && i
->def
[j
]; j
++)
606 live_set_rem(b
, i
->def
[j
]);
607 for (j
= 0; j
< 6 && i
->src
[j
]; j
++)
608 live_set_add(b
, i
->src
[j
]->value
);
610 for (i
= b
->phi
; i
&& i
->opcode
== NV_OP_PHI
; i
= i
->next
)
611 live_set_rem(b
, i
->def
[0]);
613 bb_live_set_print(ctx
->pc
, b
);
618 static void collect_live_values(struct nv_basic_block
*b
, const int n
)
623 if (b
->out
[1]) { /* what to do about back-edges ? */
624 for (i
= 0; i
< n
; ++i
)
625 b
->live_set
[i
] = b
->out
[0]->live_set
[i
] | b
->out
[1]->live_set
[i
];
627 memcpy(b
->live_set
, b
->out
[0]->live_set
, n
* sizeof(uint32_t));
631 memcpy(b
->live_set
, b
->out
[1]->live_set
, n
* sizeof(uint32_t));
633 memset(b
->live_set
, 0, n
* sizeof(uint32_t));
637 /* NOTE: the live intervals of phi functions start at the first non-phi insn. */
639 pass_build_intervals(struct nv_pc_pass
*ctx
, struct nv_basic_block
*b
)
641 struct nv_instruction
*i
, *i_stop
;
643 const int n
= (ctx
->pc
->num_values
+ 31) / 32;
645 /* verify that first block does not have live-in values */
647 for (j
= 0; j
< n
; ++j
)
648 assert(b
->live_set
[j
] == 0);
650 collect_live_values(b
, n
);
652 /* remove live-outs def'd in a parallel block, hopefully they're all phi'd */
653 for (j
= 0; j
< 2; ++j
) {
654 if (!b
->out
[j
] || !b
->out
[j
]->phi
)
656 for (i
= b
->out
[j
]->phi
; i
->opcode
== NV_OP_PHI
; i
= i
->next
) {
657 live_set_rem(b
, i
->def
[0]);
659 for (s
= 0; s
< 6 && i
->src
[s
]; ++s
) {
660 assert(i
->src
[s
]->value
->insn
);
661 if (nvc0_bblock_reachable_by(b
, i
->src
[s
]->value
->insn
->bb
,
663 live_set_add(b
, i
->src
[s
]->value
);
665 live_set_rem(b
, i
->src
[s
]->value
);
670 /* remaining live-outs are live until the end */
672 for (j
= 0; j
< ctx
->pc
->num_values
; ++j
) {
673 if (!(b
->live_set
[j
/ 32] & (1 << (j
% 32))))
675 add_range(&ctx
->pc
->values
[j
], b
, b
->exit
->serial
+ 1);
676 #ifdef NVC0_RA_DEBUG_LIVEI
677 debug_printf("adding range for live value %i: ", j
);
678 livei_print(&ctx
->pc
->values
[j
]);
683 i_stop
= b
->entry
? b
->entry
->prev
: NULL
;
685 /* don't have to include phi functions here (will have 0 live range) */
686 for (i
= b
->exit
; i
!= i_stop
; i
= i
->prev
) {
687 assert(i
->serial
>= b
->phi
->serial
&& i
->serial
<= b
->exit
->serial
);
688 for (j
= 0; j
< 4 && i
->def
[j
]; ++j
)
689 live_set_rem(b
, i
->def
[j
]);
691 for (j
= 0; j
< 6 && i
->src
[j
]; ++j
) {
692 if (!live_set_test(b
, i
->src
[j
])) {
693 live_set_add(b
, i
->src
[j
]->value
);
694 add_range(i
->src
[j
]->value
, b
, i
->serial
);
695 #ifdef NVC0_RA_DEBUG_LIVEI
696 debug_printf("adding range for source %i (ends living): ",
697 i
->src
[j
]->value
->n
);
698 livei_print(i
->src
[j
]->value
);
704 b
->pass_seq
= ctx
->pc
->pass_seq
;
706 if (b
->out
[0] && b
->out
[0]->pass_seq
< ctx
->pc
->pass_seq
)
707 pass_build_intervals(ctx
, b
->out
[0]);
709 if (b
->out
[1] && b
->out
[1]->pass_seq
< ctx
->pc
->pass_seq
)
710 pass_build_intervals(ctx
, b
->out
[1]);
716 nvc0_ctor_register_set(struct nv_pc
*pc
, struct register_set
*set
)
718 memset(set
, 0, sizeof(*set
));
720 set
->last
[NV_FILE_GPR
] = 62;
721 set
->last
[NV_FILE_PRED
] = 6;
722 set
->last
[NV_FILE_COND
] = 1;
724 set
->log2_unit
[NV_FILE_GPR
] = 2;
725 set
->log2_unit
[NV_FILE_COND
] = 0;
726 set
->log2_unit
[NV_FILE_PRED
] = 0;
732 insert_ordered_tail(struct nv_value
*list
, struct nv_value
*nval
)
734 struct nv_value
*elem
;
736 for (elem
= list
->prev
;
737 elem
!= list
&& elem
->livei
->bgn
> nval
->livei
->bgn
;
739 /* now elem begins before or at the same time as val */
742 nval
->next
= elem
->next
;
743 elem
->next
->prev
= nval
;
748 pass_linear_scan(struct nv_pc_pass
*ctx
, int iter
)
750 struct nv_instruction
*i
;
751 struct register_set f
, free
;
753 struct nv_value
*cur
, *val
, *tmp
[2];
754 struct nv_value active
, inactive
, handled
, unhandled
;
756 make_empty_list(&active
);
757 make_empty_list(&inactive
);
758 make_empty_list(&handled
);
759 make_empty_list(&unhandled
);
761 nvc0_ctor_register_set(ctx
->pc
, &free
);
763 /* joined values should have range = NULL and thus not be added;
764 * also, fixed memory values won't be added because they're not
767 for (n
= 0; n
< ctx
->num_insns
; ++n
) {
770 for (k
= 0; k
< 5; ++k
) {
771 if (i
->def
[k
] && i
->def
[k
]->livei
)
772 insert_ordered_tail(&unhandled
, i
->def
[k
]);
775 debug_printf("skipping def'd value %i: no livei\n", i
->def
[k
]->n
);
779 for (val
= unhandled
.next
; val
!= unhandled
.prev
; val
= val
->next
) {
780 assert(val
->join
== val
);
781 assert(val
->livei
->bgn
<= val
->next
->livei
->bgn
);
784 foreach_s(cur
, tmp
[0], &unhandled
) {
785 remove_from_list(cur
);
787 foreach_s(val
, tmp
[1], &active
) {
788 if (livei_end(val
) <= cur
->livei
->bgn
) {
789 reg_release(&free
, val
);
790 move_to_head(&handled
, val
);
792 if (!livei_contains(val
, cur
->livei
->bgn
)) {
793 reg_release(&free
, val
);
794 move_to_head(&inactive
, val
);
798 foreach_s(val
, tmp
[1], &inactive
) {
799 if (livei_end(val
) <= cur
->livei
->bgn
)
800 move_to_head(&handled
, val
);
802 if (livei_contains(val
, cur
->livei
->bgn
)) {
803 reg_occupy(&free
, val
);
804 move_to_head(&active
, val
);
810 foreach(val
, &inactive
)
811 if (livei_have_overlap(val
, cur
))
814 foreach(val
, &unhandled
)
815 if (val
->reg
.id
>= 0 && livei_have_overlap(val
, cur
))
818 if (cur
->reg
.id
< 0) {
820 int v
= nvi_vector_size(cur
->insn
);
823 mem
= !reg_assign(&f
, &cur
->insn
->def
[0], v
);
826 mem
= !reg_assign(&f
, &cur
, 1);
829 NOUVEAU_ERR("out of registers\n");
833 insert_at_head(&active
, cur
);
834 reg_occupy(&free
, cur
);
841 nv_pc_pass1(struct nv_pc
*pc
, struct nv_basic_block
*root
)
843 struct nv_pc_pass
*ctx
;
846 NOUVEAU_DBG("REGISTER ALLOCATION - entering\n");
848 ctx
= CALLOC_STRUCT(nv_pc_pass
);
853 ctx
->insns
= CALLOC(NV_PC_MAX_INSTRUCTIONS
, sizeof(struct nv_instruction
*));
860 ret
= pass_generate_phi_movs(ctx
, root
);
863 for (i
= 0; i
< pc
->loop_nesting_bound
; ++i
) {
865 ret
= pass_build_live_sets(ctx
, root
);
866 assert(!ret
&& "live sets");
868 NOUVEAU_ERR("failed to build live sets (iteration %d)\n", i
);
874 nvc0_pc_pass_in_order(root
, pass_order_instructions
, ctx
);
877 ret
= pass_build_intervals(ctx
, root
);
878 assert(!ret
&& "build intervals");
880 NOUVEAU_ERR("failed to build live intervals\n");
884 #ifdef NVC0_RA_DEBUG_LIVEI
885 for (i
= 0; i
< pc
->num_values
; ++i
)
886 livei_print(&pc
->values
[i
]);
889 ret
= pass_join_values(ctx
, 0);
892 ret
= pass_linear_scan(ctx
, 0);
895 ret
= pass_join_values(ctx
, 1);
898 ret
= pass_join_values(ctx
, 2);
901 ret
= pass_linear_scan(ctx
, 1);
905 for (i
= 0; i
< pc
->num_values
; ++i
)
906 livei_release(&pc
->values
[i
]);
908 NOUVEAU_DBG("REGISTER ALLOCATION - leaving\n");
917 nvc0_pc_exec_pass1(struct nv_pc
*pc
)
921 for (i
= 0; i
< pc
->num_subroutines
+ 1; ++i
)
922 if (pc
->root
[i
] && (ret
= nv_pc_pass1(pc
, pc
->root
[i
])))