Lines Matching refs:ir
27 * Attempts to verify that various invariants of the IR tree are true.
31 * in the ir tree. ir_variable does appear multiple times: Once as a
36 #include "ir.h"
60 virtual ir_visitor_status visit(ir_dereference_variable *ir);
62 virtual ir_visitor_status visit_enter(ir_if *ir);
64 virtual ir_visitor_status visit_leave(ir_loop *ir);
65 virtual ir_visitor_status visit_enter(ir_function *ir);
66 virtual ir_visitor_status visit_leave(ir_function *ir);
67 virtual ir_visitor_status visit_enter(ir_function_signature *ir);
69 virtual ir_visitor_status visit_leave(ir_expression *ir);
70 virtual ir_visitor_status visit_leave(ir_swizzle *ir);
72 virtual ir_visitor_status visit_enter(ir_assignment *ir);
73 virtual ir_visitor_status visit_enter(ir_call *ir);
75 static void validate_ir(ir_instruction *ir, void *data);
84 ir_validate::visit(ir_dereference_variable *ir)
86 if ((ir->var == NULL) || (ir->var->as_variable() == NULL)) {
88 (void *) ir, (void *) ir->var);
92 if (hash_table_find(ht, ir->var) == NULL) {
95 (void *) ir, ir->var->name, (void *) ir->var);
99 this->validate_ir(ir, this->data);
105 ir_validate::visit_enter(ir_if *ir)
107 if (ir->condition->type != glsl_type::bool_type) {
109 ir->condition->type->name);
110 ir->print();
120 ir_validate::visit_leave(ir_loop *ir)
122 if (ir->counter != NULL) {
123 if ((ir->from == NULL) || (ir->to == NULL) || (ir->increment == NULL)) {
129 (void *) ir->counter, (void *) ir->from, (void *) ir->to,
130 (void *) ir->increment);
134 if ((ir->cmp < ir_binop_less) || (ir->cmp > ir_binop_nequal)) {
135 printf("ir_loop has invalid comparitor %d\n", ir->cmp);
139 if ((ir->from != NULL) || (ir->to != NULL) || (ir->increment != NULL)) {
145 (void *) ir->counter, (void *) ir->from, (void *) ir->to,
146 (void *) ir->increment);
156 ir_validate::visit_enter(ir_function *ir)
164 ir->name, (void *) ir,
173 this->current_function = ir;
175 this->validate_ir(ir, this->data);
180 foreach_list(node, &ir->signatures) {
185 ir->name);
194 ir_validate::visit_leave(ir_function *ir)
196 assert(ralloc_parent(ir->name) == ir);
203 ir_validate::visit_enter(ir_function_signature *ir)
205 if (this->current_function != ir->function()) {
209 (void *) ir,
211 ir->function_name(), (void *) ir->function());
215 if (ir->return_type == NULL) {
217 (void *) ir, ir->function_name());
221 this->validate_ir(ir, this->data);
227 ir_validate::visit_leave(ir_expression *ir)
229 switch (ir->operation) {
231 assert(ir->operands[0]->type == ir->type);
234 assert(ir->type->base_type == GLSL_TYPE_BOOL);
235 assert(ir->operands[0]->type->base_type == GLSL_TYPE_BOOL);
244 assert(ir->type == ir->operands[0]->type);
251 assert(ir->operands[0]->type->base_type == GLSL_TYPE_FLOAT);
252 assert(ir->type == ir->operands[0]->type);
256 assert(ir->operands[0]->type->base_type == GLSL_TYPE_FLOAT);
257 assert(ir->type->base_type == GLSL_TYPE_INT);
260 assert(ir->operands[0]->type->base_type == GLSL_TYPE_FLOAT);
261 assert(ir->type->base_type == GLSL_TYPE_UINT);
264 assert(ir->operands[0]->type->base_type == GLSL_TYPE_INT);
265 assert(ir->type->base_type == GLSL_TYPE_FLOAT);
268 assert(ir->operands[0]->type->base_type == GLSL_TYPE_FLOAT);
269 assert(ir->type->base_type == GLSL_TYPE_BOOL);
272 assert(ir->operands[0]->type->base_type == GLSL_TYPE_BOOL);
273 assert(ir->type->base_type == GLSL_TYPE_FLOAT);
276 assert(ir->operands[0]->type->base_type == GLSL_TYPE_INT);
277 assert(ir->type->base_type == GLSL_TYPE_BOOL);
280 assert(ir->operands[0]->type->base_type == GLSL_TYPE_BOOL);
281 assert(ir->type->base_type == GLSL_TYPE_INT);
284 assert(ir->operands[0]->type->base_type == GLSL_TYPE_UINT);
285 assert(ir->type->base_type == GLSL_TYPE_FLOAT);
288 assert(ir->operands[0]->type->base_type == GLSL_TYPE_INT);
289 assert(ir->type->base_type == GLSL_TYPE_UINT);
292 assert(ir->operands[0]->type->base_type == GLSL_TYPE_UINT);
293 assert(ir->type->base_type == GLSL_TYPE_INT);
296 assert(ir->operands[0]->type->base_type == GLSL_TYPE_INT);
297 assert(ir->type->base_type == GLSL_TYPE_FLOAT);
300 assert(ir->operands[0]->type->base_type == GLSL_TYPE_FLOAT);
301 assert(ir->type->base_type == GLSL_TYPE_INT);
304 assert(ir->operands[0]->type->base_type == GLSL_TYPE_UINT);
305 assert(ir->type->base_type == GLSL_TYPE_FLOAT);
308 assert(ir->operands[0]->type->base_type == GLSL_TYPE_FLOAT);
309 assert(ir->type->base_type == GLSL_TYPE_UINT);
313 assert(ir->operands[0]->type->base_type == GLSL_TYPE_BOOL);
314 assert(ir->type == glsl_type::bool_type);
328 assert(ir->operands[0]->type->base_type == GLSL_TYPE_FLOAT);
329 assert(ir->operands[0]->type == ir->type);
344 if (ir->operands[0]->type->is_scalar())
345 assert(ir->operands[1]->type == ir->type);
346 else if (ir->operands[1]->type->is_scalar())
347 assert(ir->operands[0]->type == ir->type);
348 else if (ir->operands[0]->type->is_vector() &&
349 ir->operands[1]->type->is_vector()) {
350 assert(ir->operands[0]->type == ir->operands[1]->type);
351 assert(ir->operands[0]->type == ir->type);
361 /* The semantics of the IR operators differ from the GLSL <, >, <=, >=,
362 * ==, and != operators. The IR operators perform a component-wise
366 assert(ir->type->base_type == GLSL_TYPE_BOOL);
367 assert(ir->operands[0]->type == ir->operands[1]->type);
368 assert(ir->operands[0]->type->is_vector()
369 || ir->operands[0]->type->is_scalar());
370 assert(ir->operands[0]->type->vector_elements
371 == ir->type->vector_elements);
377 * return a scalar boolean. The IR matches that.
379 assert(ir->type == glsl_type::bool_type);
380 assert(ir->operands[0]->type == ir->operands[1]->type);
385 assert(ir->operands[0]->type->is_integer() &&
386 ir->operands[1]->type->is_integer());
387 if (ir->operands[0]->type->is_scalar()) {
388 assert(ir->operands[1]->type->is_scalar());
390 if (ir->operands[0]->type->is_vector() &&
391 ir->operands[1]->type->is_vector()) {
392 assert(ir->operands[0]->type->components() ==
393 ir->operands[1]->type->components());
395 assert(ir->type == ir->operands[0]->type);
401 assert(ir->operands[0]->type->base_type ==
402 ir->operands[1]->type->base_type);
403 assert(ir->type->is_integer());
404 if (ir->operands[0]->type->is_vector() &&
405 ir->operands[1]->type->is_vector()) {
406 assert(ir->operands[0]->type->vector_elements ==
407 ir->operands[1]->type->vector_elements);
414 assert(ir->type == glsl_type::bool_type);
415 assert(ir->operands[0]->type == glsl_type::bool_type);
416 assert(ir->operands[1]->type == glsl_type::bool_type);
420 assert(ir->type == glsl_type::float_type);
421 assert(ir->operands[0]->type->base_type == GLSL_TYPE_FLOAT);
422 assert(ir->operands[0]->type->is_vector());
423 assert(ir->operands[0]->type == ir->operands[1]->type);
427 assert(ir->operands[0]->as_constant());
428 assert(ir->operands[0]->type == glsl_type::uint_type);
430 assert(ir->operands[1]->type == glsl_type::uint_type);
441 assert(ir->type->is_vector());
442 switch (ir->type->vector_elements) {
444 assert(ir->operands[0]->type->is_scalar());
445 assert(ir->operands[0]->type->base_type == ir->type->base_type);
446 assert(ir->operands[1]->type->is_scalar());
447 assert(ir->operands[1]->type->base_type == ir->type->base_type);
448 assert(ir->operands[2] == NULL);
449 assert(ir->operands[3] == NULL);
452 assert(ir->operands[0]->type->is_scalar());
453 assert(ir->operands[0]->type->base_type == ir->type->base_type);
454 assert(ir->operands[1]->type->is_scalar());
455 assert(ir->operands[1]->type->base_type == ir->type->base_type);
456 assert(ir->operands[2]->type->is_scalar());
457 assert(ir->operands[2]->type->base_type == ir->type->base_type);
458 assert(ir->operands[3] == NULL);
461 assert(ir->operands[0]->type->is_scalar());
462 assert(ir->operands[0]->type->base_type == ir->type->base_type);
463 assert(ir->operands[1]->type->is_scalar());
464 assert(ir->operands[1]->type->base_type == ir->type->base_type);
465 assert(ir->operands[2]->type->is_scalar());
466 assert(ir->operands[2]->type->base_type == ir->type->base_type);
467 assert(ir->operands[3]->type->is_scalar());
468 assert(ir->operands[3]->type->base_type == ir->type->base_type);
483 ir_validate::visit_leave(ir_swizzle *ir)
485 unsigned int chans[4] = {ir->mask.x, ir->mask.y, ir->mask.z, ir->mask.w};
487 for (unsigned int i = 0; i < ir->type->vector_elements; i++) {
488 if (chans[i] >= ir->val->type->vector_elements) {
490 "in the value.\n", (void *) ir);
491 ir->print();
500 ir_validate::visit(ir_variable *ir)
503 * in an IR tree. It is added to the hashtable so that it can be used
507 if (ir->name)
508 assert(ralloc_parent(ir->name) == ir);
510 hash_table_insert(ht, ir, ir);
517 if (ir->type->array_size() > 0) {
518 if (irir->type->length) {
520 ir->max_array_access, ir->type->length - 1);
521 ir->print();
526 if (ir->constant_initializer != NULL && !ir->has_initializer) {
529 ir->print();
537 ir_validate::visit_enter(ir_assignment *ir)
539 const ir_dereference *const lhs = ir->lhs;
541 if (ir->write_mask == 0) {
544 ir->print();
550 if (ir->write_mask & (1 << i))
554 if (lhs_components != ir->rhs->type->vector_elements) {
557 lhs_components, ir->rhs->type->vector_elements);
558 ir->print();
563 this->validate_ir(ir, this->data);
569 ir_validate::visit_enter(ir_call *ir)
571 ir_function_signature *const callee = ir->callee;
574 printf("IR called by ir_call is not ir_function_signature!\n");
578 if (ir->return_deref) {
579 if (ir->return_deref->type != callee->return_type) {
581 callee->return_type->name, ir->return_deref->type->name);
590 const exec_node *actual_param_node = ir->actual_parameters.head;
622 ir->print();
630 ir_validate::validate_ir(ir_instruction *ir, void *data)
634 if (hash_table_find(ht, ir)) {
635 printf("Instruction node present twice in ir tree:\n");
636 ir->print();
640 hash_table_insert(ht, ir, ir);
644 check_node_type(ir_instruction *ir, void *data)
648 if (ir->ir_type <= ir_type_unset || ir->ir_type >= ir_type_max) {
650 ir->print(); printf("\n");
652 ir_rvalue *value = ir->as_rvalue();
665 ir_instruction *ir = (ir_instruction *)iter.get();
667 visit_tree(ir, check_node_type, NULL);