2 * Copyright © 2014 Intel Corporation
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 (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
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
24 * Connor Abbott (cwabbott0@gmail.com)
32 * This file checks for invalid IR indicating a bug somewhere in the compiler.
36 * Per-register validation state.
41 * equivalent to the uses and defs in nir_register, but built up by the
42 * validator. At the end, we verify that the sets have the same entries.
44 struct set
*uses
, *defs
;
45 nir_function_impl
*where_defined
; /* NULL for global registers */
49 /* map of register -> validation state (struct above) */
50 struct hash_table
*regs
;
52 /* the current instruction being validated */
55 /* the current basic block being validated */
58 /* the current if statement being validated */
61 /* the parent of the current cf node being visited */
62 nir_cf_node
*parent_node
;
64 /* the current function implementation being validated */
65 nir_function_impl
*impl
;
67 /* map of SSA value -> function implementation where it is defined */
68 struct hash_table
*ssa_defs
;
70 /* map of local variable -> function implementation where it is defined */
71 struct hash_table
*var_defs
;
74 static void validate_src(nir_src
*src
, validate_state
*state
);
77 validate_reg_src(nir_reg_src
*src
, validate_state
*state
)
79 assert(src
->reg
!= NULL
);
81 struct set_entry
*entry
=
82 _mesa_set_search(src
->reg
->uses
, _mesa_hash_pointer(state
->instr
),
84 assert(entry
&& "use not in nir_register.uses");
86 struct hash_entry
*entry2
;
87 entry2
= _mesa_hash_table_search(state
->regs
, src
->reg
);
91 reg_validate_state
*reg_state
= (reg_validate_state
*) entry2
->data
;
92 _mesa_set_add(reg_state
->uses
, _mesa_hash_pointer(state
->instr
),
95 if (!src
->reg
->is_global
) {
96 assert(reg_state
->where_defined
== state
->impl
&&
97 "using a register declared in a different function");
100 assert((src
->reg
->num_array_elems
== 0 ||
101 src
->base_offset
< src
->reg
->num_array_elems
) &&
102 "definitely out-of-bounds array access");
105 assert(src
->reg
->num_array_elems
!= 0);
106 assert((src
->indirect
->is_ssa
|| src
->indirect
->reg
.indirect
== NULL
) &&
107 "only one level of indirection allowed");
108 validate_src(src
->indirect
, state
);
113 validate_ssa_src(nir_ssa_def
*def
, validate_state
*state
)
117 struct hash_entry
*entry
= _mesa_hash_table_search(state
->ssa_defs
, def
);
121 assert((nir_function_impl
*) entry
->data
== state
->impl
&&
122 "using an SSA value defined in a different function");
124 struct set_entry
*entry2
;
126 entry2
= _mesa_set_search(def
->uses
, _mesa_hash_pointer(state
->instr
),
129 assert(entry2
&& "SSA use missing");
131 /* TODO validate that the use is dominated by the definition */
135 validate_src(nir_src
*src
, validate_state
*state
)
138 validate_ssa_src(src
->ssa
, state
);
140 validate_reg_src(&src
->reg
, state
);
144 validate_alu_src(nir_alu_instr
*instr
, unsigned index
, validate_state
*state
)
146 nir_alu_src
*src
= &instr
->src
[index
];
148 unsigned num_components
;
150 num_components
= src
->src
.ssa
->num_components
;
152 if (src
->src
.reg
.reg
->is_packed
)
153 num_components
= 4; /* can't check anything */
155 num_components
= src
->src
.reg
.reg
->num_components
;
157 for (unsigned i
= 0; i
< 4; i
++) {
158 assert(src
->swizzle
[i
] < 4);
160 if (nir_alu_instr_channel_used(instr
, index
, i
))
161 assert(src
->swizzle
[i
] < num_components
);
164 validate_src(&src
->src
, state
);
168 validate_reg_dest(nir_reg_dest
*dest
, validate_state
*state
)
170 assert(dest
->reg
!= NULL
);
172 struct set_entry
*entry
=
173 _mesa_set_search(dest
->reg
->defs
, _mesa_hash_pointer(state
->instr
),
175 assert(entry
&& "definition not in nir_register.defs");
177 struct hash_entry
*entry2
;
178 entry2
= _mesa_hash_table_search(state
->regs
, dest
->reg
);
182 reg_validate_state
*reg_state
= (reg_validate_state
*) entry2
->data
;
183 _mesa_set_add(reg_state
->defs
, _mesa_hash_pointer(state
->instr
),
186 if (!dest
->reg
->is_global
) {
187 assert(reg_state
->where_defined
== state
->impl
&&
188 "writing to a register declared in a different function");
191 assert((dest
->reg
->num_array_elems
== 0 ||
192 dest
->base_offset
< dest
->reg
->num_array_elems
) &&
193 "definitely out-of-bounds array access");
195 if (dest
->indirect
) {
196 assert(dest
->reg
->num_array_elems
!= 0);
197 assert((dest
->indirect
->is_ssa
|| dest
->indirect
->reg
.indirect
== NULL
) &&
198 "only one level of indirection allowed");
199 validate_src(dest
->indirect
, state
);
204 validate_ssa_def(nir_ssa_def
*def
, validate_state
*state
)
206 assert(def
->num_components
<= 4);
207 _mesa_hash_table_insert(state
->ssa_defs
, def
, state
->impl
);
211 validate_dest(nir_dest
*dest
, validate_state
*state
)
214 validate_ssa_def(&dest
->ssa
, state
);
216 validate_reg_dest(&dest
->reg
, state
);
220 validate_alu_dest(nir_alu_dest
*dest
, validate_state
*state
)
223 dest
->dest
.is_ssa
? dest
->dest
.ssa
.num_components
224 : dest
->dest
.reg
.reg
->num_components
;
225 bool is_packed
= !dest
->dest
.is_ssa
&& dest
->dest
.reg
.reg
->is_packed
;
227 * validate that the instruction doesn't write to components not in the
230 assert(is_packed
|| !(dest
->write_mask
& ~((1 << dest_size
) - 1)));
231 validate_dest(&dest
->dest
, state
);
235 validate_alu_instr(nir_alu_instr
*instr
, validate_state
*state
)
237 assert(instr
->op
< nir_num_opcodes
);
239 validate_alu_dest(&instr
->dest
, state
);
241 for (unsigned i
= 0; i
< nir_op_infos
[instr
->op
].num_inputs
; i
++) {
242 validate_alu_src(instr
, i
, state
);
245 if (instr
->has_predicate
)
246 validate_src(&instr
->predicate
, state
);
250 validate_deref_chain(nir_deref
*deref
, validate_state
*state
)
252 nir_deref
*parent
= NULL
;
253 while (deref
!= NULL
) {
254 switch (deref
->deref_type
) {
255 case nir_deref_type_array
:
256 assert(deref
->type
== glsl_get_array_element(parent
->type
));
257 if (nir_deref_as_array(deref
)->has_indirect
)
258 validate_src(&nir_deref_as_array(deref
)->indirect
, state
);
261 case nir_deref_type_struct
:
262 assert(deref
->type
==
263 glsl_get_struct_field(parent
->type
,
264 nir_deref_as_struct(deref
)->elem
));
267 case nir_deref_type_var
:
271 assert(!"Invalid deref type");
276 deref
= deref
->child
;
281 validate_var_use(nir_variable
*var
, validate_state
*state
)
283 if (var
->data
.mode
== nir_var_local
) {
284 struct hash_entry
*entry
= _mesa_hash_table_search(state
->var_defs
, var
);
287 assert((nir_function_impl
*) entry
->data
== state
->impl
);
292 validate_deref_var(nir_deref_var
*deref
, validate_state
*state
)
294 assert(deref
!= NULL
);
295 assert(deref
->deref
.type
== deref
->var
->type
);
297 validate_var_use(deref
->var
, state
);
299 validate_deref_chain(&deref
->deref
, state
);
303 validate_intrinsic_instr(nir_intrinsic_instr
*instr
, validate_state
*state
)
305 unsigned num_srcs
= nir_intrinsic_infos
[instr
->intrinsic
].num_srcs
;
306 for (unsigned i
= 0; i
< num_srcs
; i
++) {
307 validate_src(&instr
->src
[i
], state
);
310 if (nir_intrinsic_infos
[instr
->intrinsic
].has_dest
) {
311 validate_dest(&instr
->dest
, state
);
314 unsigned num_vars
= nir_intrinsic_infos
[instr
->intrinsic
].num_variables
;
315 for (unsigned i
= 0; i
< num_vars
; i
++) {
316 validate_deref_var(instr
->variables
[i
], state
);
319 if (instr
->has_predicate
)
320 validate_src(&instr
->predicate
, state
);
324 validate_tex_instr(nir_tex_instr
*instr
, validate_state
*state
)
326 validate_dest(&instr
->dest
, state
);
328 bool src_type_seen
[nir_num_texinput_types
];
329 for (unsigned i
= 0; i
< nir_num_texinput_types
; i
++)
330 src_type_seen
[i
] = false;
332 for (unsigned i
= 0; i
< instr
->num_srcs
; i
++) {
333 assert(!src_type_seen
[instr
->src_type
[i
]]);
334 src_type_seen
[instr
->src_type
[i
]] = true;
335 validate_src(&instr
->src
[i
], state
);
338 if (instr
->sampler
!= NULL
)
339 validate_deref_var(instr
->sampler
, state
);
343 validate_call_instr(nir_call_instr
*instr
, validate_state
*state
)
345 if (instr
->return_deref
== NULL
)
346 assert(glsl_type_is_void(instr
->callee
->return_type
));
348 assert(instr
->return_deref
->deref
.type
== instr
->callee
->return_type
);
350 assert(instr
->num_params
== instr
->callee
->num_params
);
352 for (unsigned i
= 0; i
< instr
->num_params
; i
++) {
353 assert(instr
->callee
->params
[i
].type
== instr
->params
[i
]->deref
.type
);
354 validate_deref_var(instr
->params
[i
], state
);
357 validate_deref_var(instr
->return_deref
, state
);
359 if (instr
->has_predicate
)
360 validate_src(&instr
->predicate
, state
);
364 validate_load_const_instr(nir_load_const_instr
*instr
, validate_state
*state
)
366 validate_dest(&instr
->dest
, state
);
368 if (instr
->array_elems
!= 0) {
369 assert(!instr
->dest
.is_ssa
);
370 assert(instr
->dest
.reg
.base_offset
+ instr
->array_elems
<=
371 instr
->dest
.reg
.reg
->num_array_elems
);
374 if (instr
->has_predicate
)
375 validate_src(&instr
->predicate
, state
);
379 validate_ssa_undef_instr(nir_ssa_undef_instr
*instr
, validate_state
*state
)
381 validate_ssa_def(&instr
->def
, state
);
385 validate_phi_instr(nir_phi_instr
*instr
, validate_state
*state
)
388 * don't validate the sources until we get to them from their predecessor
389 * basic blocks, to avoid validating an SSA use before its definition.
392 validate_dest(&instr
->dest
, state
);
394 exec_list_validate(&instr
->srcs
);
395 assert(exec_list_length(&instr
->srcs
) ==
396 state
->block
->predecessors
->entries
);
400 validate_instr(nir_instr
*instr
, validate_state
*state
)
402 assert(instr
->block
== state
->block
);
404 state
->instr
= instr
;
406 switch (instr
->type
) {
407 case nir_instr_type_alu
:
408 validate_alu_instr(nir_instr_as_alu(instr
), state
);
411 case nir_instr_type_call
:
412 validate_call_instr(nir_instr_as_call(instr
), state
);
415 case nir_instr_type_intrinsic
:
416 validate_intrinsic_instr(nir_instr_as_intrinsic(instr
), state
);
419 case nir_instr_type_texture
:
420 validate_tex_instr(nir_instr_as_texture(instr
), state
);
423 case nir_instr_type_load_const
:
424 validate_load_const_instr(nir_instr_as_load_const(instr
), state
);
427 case nir_instr_type_phi
:
428 validate_phi_instr(nir_instr_as_phi(instr
), state
);
431 case nir_instr_type_ssa_undef
:
432 validate_ssa_undef_instr(nir_instr_as_ssa_undef(instr
), state
);
435 case nir_instr_type_jump
:
439 assert(!"Invalid ALU instruction type");
445 validate_phi_src(nir_phi_instr
*instr
, nir_block
*pred
, validate_state
*state
)
447 state
->instr
= &instr
->instr
;
449 exec_list_validate(&instr
->srcs
);
450 foreach_list_typed(nir_phi_src
, src
, node
, &instr
->srcs
) {
451 if (src
->pred
== pred
) {
452 validate_src(&src
->src
, state
);
461 validate_phi_srcs(nir_block
*block
, nir_block
*succ
, validate_state
*state
)
463 nir_foreach_instr(succ
, instr
) {
464 if (instr
->type
!= nir_instr_type_phi
)
467 validate_phi_src(nir_instr_as_phi(instr
), block
, state
);
471 static void validate_cf_node(nir_cf_node
*node
, validate_state
*state
);
474 validate_block(nir_block
*block
, validate_state
*state
)
476 assert(block
->cf_node
.parent
== state
->parent_node
);
478 state
->block
= block
;
480 exec_list_validate(&block
->instr_list
);
481 nir_foreach_instr(block
, instr
) {
482 if (instr
->type
== nir_instr_type_phi
) {
483 assert(instr
== nir_block_first_instr(block
) ||
484 nir_instr_prev(instr
)->type
== nir_instr_type_phi
);
487 if (instr
->type
== nir_instr_type_jump
) {
488 assert(instr
== nir_block_last_instr(block
));
491 validate_instr(instr
, state
);
494 assert(block
->successors
[0] != NULL
);
496 for (unsigned i
= 0; i
< 2; i
++) {
497 if (block
->successors
[i
] != NULL
) {
498 struct set_entry
*entry
=
499 _mesa_set_search(block
->successors
[i
]->predecessors
,
500 _mesa_hash_pointer(block
), block
);
503 validate_phi_srcs(block
, block
->successors
[i
], state
);
507 if (!exec_list_is_empty(&block
->instr_list
) &&
508 nir_block_last_instr(block
)->type
== nir_instr_type_jump
)
509 assert(block
->successors
[1] == NULL
);
513 validate_if(nir_if
*if_stmt
, validate_state
*state
)
515 assert(!exec_node_is_head_sentinel(if_stmt
->cf_node
.node
.prev
));
516 nir_cf_node
*prev_node
= nir_cf_node_prev(&if_stmt
->cf_node
);
517 assert(prev_node
->type
== nir_cf_node_block
);
519 nir_block
*prev_block
= nir_cf_node_as_block(prev_node
);
520 assert(&prev_block
->successors
[0]->cf_node
==
521 nir_if_first_then_node(if_stmt
));
522 assert(&prev_block
->successors
[1]->cf_node
==
523 nir_if_first_else_node(if_stmt
));
525 assert(!exec_node_is_tail_sentinel(if_stmt
->cf_node
.node
.next
));
526 nir_cf_node
*next_node
= nir_cf_node_next(&if_stmt
->cf_node
);
527 assert(next_node
->type
== nir_cf_node_block
);
529 if (!if_stmt
->condition
.is_ssa
) {
530 nir_register
*reg
= if_stmt
->condition
.reg
.reg
;
531 struct set_entry
*entry
=
532 _mesa_set_search(reg
->if_uses
, _mesa_hash_pointer(if_stmt
), if_stmt
);
535 nir_ssa_def
*def
= if_stmt
->condition
.ssa
;
536 struct set_entry
*entry
=
537 _mesa_set_search(def
->if_uses
, _mesa_hash_pointer(if_stmt
), if_stmt
);
541 assert(!exec_list_is_empty(&if_stmt
->then_list
));
542 assert(!exec_list_is_empty(&if_stmt
->else_list
));
544 nir_cf_node
*old_parent
= state
->parent_node
;
545 state
->parent_node
= &if_stmt
->cf_node
;
547 exec_list_validate(&if_stmt
->then_list
);
548 foreach_list_typed(nir_cf_node
, cf_node
, node
, &if_stmt
->then_list
) {
549 validate_cf_node(cf_node
, state
);
552 exec_list_validate(&if_stmt
->else_list
);
553 foreach_list_typed(nir_cf_node
, cf_node
, node
, &if_stmt
->else_list
) {
554 validate_cf_node(cf_node
, state
);
557 state
->parent_node
= old_parent
;
561 validate_loop(nir_loop
*loop
, validate_state
*state
)
563 assert(!exec_node_is_head_sentinel(loop
->cf_node
.node
.prev
));
564 nir_cf_node
*prev_node
= nir_cf_node_prev(&loop
->cf_node
);
565 assert(prev_node
->type
== nir_cf_node_block
);
567 nir_block
*prev_block
= nir_cf_node_as_block(prev_node
);
568 assert(&prev_block
->successors
[0]->cf_node
== nir_loop_first_cf_node(loop
));
569 assert(prev_block
->successors
[1] == NULL
);
571 assert(!exec_node_is_tail_sentinel(loop
->cf_node
.node
.next
));
572 nir_cf_node
*next_node
= nir_cf_node_next(&loop
->cf_node
);
573 assert(next_node
->type
== nir_cf_node_block
);
575 assert(!exec_list_is_empty(&loop
->body
));
577 nir_cf_node
*old_parent
= state
->parent_node
;
578 state
->parent_node
= &loop
->cf_node
;
580 exec_list_validate(&loop
->body
);
581 foreach_list_typed(nir_cf_node
, cf_node
, node
, &loop
->body
) {
582 validate_cf_node(cf_node
, state
);
585 state
->parent_node
= old_parent
;
589 validate_cf_node(nir_cf_node
*node
, validate_state
*state
)
591 assert(node
->parent
== state
->parent_node
);
593 switch (node
->type
) {
594 case nir_cf_node_block
:
595 validate_block(nir_cf_node_as_block(node
), state
);
599 validate_if(nir_cf_node_as_if(node
), state
);
602 case nir_cf_node_loop
:
603 validate_loop(nir_cf_node_as_loop(node
), state
);
607 assert(!"Invalid ALU instruction type");
613 prevalidate_reg_decl(nir_register
*reg
, bool is_global
, validate_state
*state
)
615 assert(reg
->is_global
== is_global
);
617 reg_validate_state
*reg_state
= ralloc(state
->regs
, reg_validate_state
);
618 reg_state
->uses
= _mesa_set_create(reg_state
, _mesa_key_pointer_equal
);
619 reg_state
->defs
= _mesa_set_create(reg_state
, _mesa_key_pointer_equal
);
621 reg_state
->where_defined
= is_global
? NULL
: state
->impl
;
623 _mesa_hash_table_insert(state
->regs
, reg
, reg_state
);
627 postvalidate_reg_decl(nir_register
*reg
, validate_state
*state
)
629 struct hash_entry
*entry
= _mesa_hash_table_search(state
->regs
, reg
);
631 reg_validate_state
*reg_state
= (reg_validate_state
*) entry
->data
;
633 if (reg_state
->uses
->entries
!= reg
->uses
->entries
) {
634 printf("extra entries in register uses:\n");
635 struct set_entry
*entry
;
636 set_foreach(reg
->uses
, entry
) {
637 struct set_entry
*entry2
=
638 _mesa_set_search(reg_state
->uses
, _mesa_hash_pointer(entry
->key
),
641 if (entry2
== NULL
) {
642 printf("%p\n", entry
->key
);
649 if (reg_state
->defs
->entries
!= reg
->defs
->entries
) {
650 printf("extra entries in register defs:\n");
651 struct set_entry
*entry
;
652 set_foreach(reg
->defs
, entry
) {
653 struct set_entry
*entry2
=
654 _mesa_set_search(reg_state
->defs
, _mesa_hash_pointer(entry
->key
),
657 if (entry2
== NULL
) {
658 printf("%p\n", entry
->key
);
667 validate_var_decl(nir_variable
*var
, bool is_global
, validate_state
*state
)
669 assert(is_global
!= (var
->data
.mode
== nir_var_local
));
672 * TODO validate some things ir_validate.cpp does (requires more GLSL type
677 _mesa_hash_table_insert(state
->var_defs
, var
, state
->impl
);
682 validate_function_impl(nir_function_impl
*impl
, validate_state
*state
)
684 assert(impl
->overload
->impl
== impl
);
685 assert(impl
->cf_node
.parent
== NULL
);
687 assert(impl
->num_params
== impl
->overload
->num_params
);
688 for (unsigned i
= 0; i
< impl
->num_params
; i
++)
689 assert(impl
->params
[i
]->type
== impl
->overload
->params
[i
].type
);
691 if (glsl_type_is_void(impl
->overload
->return_type
))
692 assert(impl
->return_var
== NULL
);
694 assert(impl
->return_var
->type
== impl
->overload
->return_type
);
696 assert(exec_list_is_empty(&impl
->end_block
->instr_list
));
697 assert(impl
->end_block
->successors
[0] == NULL
);
698 assert(impl
->end_block
->successors
[1] == NULL
);
701 state
->parent_node
= &impl
->cf_node
;
703 exec_list_validate(&impl
->locals
);
704 foreach_list_typed(nir_variable
, var
, node
, &impl
->locals
) {
705 validate_var_decl(var
, false, state
);
708 exec_list_validate(&impl
->registers
);
709 foreach_list_typed(nir_register
, reg
, node
, &impl
->registers
) {
710 prevalidate_reg_decl(reg
, false, state
);
713 exec_list_validate(&impl
->body
);
714 foreach_list_typed(nir_cf_node
, node
, node
, &impl
->body
) {
715 validate_cf_node(node
, state
);
718 foreach_list_typed(nir_register
, reg
, node
, &impl
->registers
) {
719 postvalidate_reg_decl(reg
, state
);
724 validate_function_overload(nir_function_overload
*overload
,
725 validate_state
*state
)
727 if (overload
->impl
!= NULL
)
728 validate_function_impl(overload
->impl
, state
);
732 validate_function(nir_function
*func
, validate_state
*state
)
734 exec_list_validate(&func
->overload_list
);
735 foreach_list_typed(nir_function_overload
, overload
, node
, &func
->overload_list
) {
736 assert(overload
->function
== func
);
737 validate_function_overload(overload
, state
);
742 init_validate_state(validate_state
*state
)
744 state
->regs
= _mesa_hash_table_create(NULL
, _mesa_hash_pointer
,
745 _mesa_key_pointer_equal
);
746 state
->ssa_defs
= _mesa_hash_table_create(NULL
, _mesa_hash_pointer
,
747 _mesa_key_pointer_equal
);
748 state
->var_defs
= _mesa_hash_table_create(NULL
, _mesa_hash_pointer
,
749 _mesa_key_pointer_equal
);
753 destroy_validate_state(validate_state
*state
)
755 _mesa_hash_table_destroy(state
->regs
, NULL
);
756 _mesa_hash_table_destroy(state
->ssa_defs
, NULL
);
757 _mesa_hash_table_destroy(state
->var_defs
, NULL
);
761 nir_validate_shader(nir_shader
*shader
)
763 validate_state state
;
764 init_validate_state(&state
);
766 struct hash_entry
*entry
;
767 hash_table_foreach(shader
->uniforms
, entry
) {
768 validate_var_decl((nir_variable
*) entry
->data
, true, &state
);
771 hash_table_foreach(shader
->inputs
, entry
) {
772 validate_var_decl((nir_variable
*) entry
->data
, true, &state
);
775 hash_table_foreach(shader
->outputs
, entry
) {
776 validate_var_decl((nir_variable
*) entry
->data
, true, &state
);
779 exec_list_validate(&shader
->globals
);
780 foreach_list_typed(nir_variable
, var
, node
, &shader
->globals
) {
781 validate_var_decl(var
, true, &state
);
784 exec_list_validate(&shader
->system_values
);
785 foreach_list_typed(nir_variable
, var
, node
, &shader
->system_values
) {
786 validate_var_decl(var
, true, &state
);
789 exec_list_validate(&shader
->registers
);
790 foreach_list_typed(nir_register
, reg
, node
, &shader
->registers
) {
791 prevalidate_reg_decl(reg
, true, &state
);
794 exec_list_validate(&shader
->functions
);
795 foreach_list_typed(nir_function
, func
, node
, &shader
->functions
) {
796 validate_function(func
, &state
);
799 foreach_list_typed(nir_register
, reg
, node
, &shader
->registers
) {
800 postvalidate_reg_decl(reg
, &state
);
803 destroy_validate_state(&state
);