Lines Matching refs:ir
61 virtual ir_visitor_status visit_enter(ir_assignment *ir);
63 ir_rvalue *handle_expression(ir_expression *ir);
86 ir_algebraic_visitor::visit_enter(ir_assignment *ir) in visit_enter() argument
88 ir_variable *var = ir->lhs->variable_referenced(); in visit_enter()
103 is_vec_zero(ir_constant *ir) in is_vec_zero() argument
105 return (ir == NULL) ? false : ir->is_zero(); in is_vec_zero()
109 is_vec_one(ir_constant *ir) in is_vec_one() argument
111 return (ir == NULL) ? false : ir->is_one(); in is_vec_one()
115 is_vec_two(ir_constant *ir) in is_vec_two() argument
117 return (ir == NULL) ? false : ir->is_value(2.0, 2); in is_vec_two()
121 is_vec_four(ir_constant *ir) in is_vec_four() argument
123 return (ir == NULL) ? false : ir->is_value(4.0, 4); in is_vec_four()
127 is_vec_negative_one(ir_constant *ir) in is_vec_negative_one() argument
129 return (ir == NULL) ? false : ir->is_negative_one(); in is_vec_negative_one()
133 is_valid_vec_const(ir_constant *ir) in is_valid_vec_const() argument
135 if (ir == NULL) in is_valid_vec_const()
138 if (!ir->type->is_scalar() && !ir->type->is_vector()) in is_valid_vec_const()
145 is_less_than_one(ir_constant *ir) in is_less_than_one() argument
147 assert(ir->type->is_float()); in is_less_than_one()
149 if (!is_valid_vec_const(ir)) in is_less_than_one()
153 for (int c = 0; c < ir->type->vector_elements; c++) { in is_less_than_one()
154 if (ir->get_float_component(c) < 1.0f) in is_less_than_one()
158 return (component == ir->type->vector_elements); in is_less_than_one()
162 is_greater_than_zero(ir_constant *ir) in is_greater_than_zero() argument
164 assert(ir->type->is_float()); in is_greater_than_zero()
166 if (!is_valid_vec_const(ir)) in is_greater_than_zero()
170 for (int c = 0; c < ir->type->vector_elements; c++) { in is_greater_than_zero()
171 if (ir->get_float_component(c) > 0.0f) in is_greater_than_zero()
175 return (component == ir->type->vector_elements); in is_greater_than_zero()
179 update_type(ir_expression *ir) in update_type() argument
181 if (ir->operands[0]->type->is_vector()) in update_type()
182 ir->type = ir->operands[0]->type; in update_type()
184 ir->type = ir->operands[1]->type; in update_type()
314 ir_algebraic_visitor::handle_expression(ir_expression *ir) in handle_expression() argument
319 if (ir->operation == ir_binop_mul && in handle_expression()
320 ir->operands[0]->type->is_matrix() && in handle_expression()
321 ir->operands[1]->type->is_vector()) { in handle_expression()
322 ir_expression *matrix_mul = ir->operands[0]->as_expression(); in handle_expression()
329 mul(matrix_mul->operands[1], ir->operands[1])); in handle_expression()
333 assert(ir->num_operands <= 4); in handle_expression()
334 for (unsigned i = 0; i < ir->num_operands; i++) { in handle_expression()
335 if (ir->operands[i]->type->is_matrix()) in handle_expression()
336 return ir; in handle_expression()
339 ir->operands[i]->constant_expression_value(ralloc_parent(ir)); in handle_expression()
340 op_expr[i] = ir->operands[i]->as_expression(); in handle_expression()
344 this->mem_ctx = ralloc_parent(ir); in handle_expression()
346 switch (ir->operation) { in handle_expression()
407 ir->type, in handle_expression()
427 return new(mem_ctx) ir_expression(ir->operation, in handle_expression()
428 ir->type, in handle_expression()
455 ir->type, in handle_expression()
480 ir_expression *const op = ir->operands[0]->as_expression(); \ in handle_expression()
505 return ir->operands[1]; in handle_expression()
507 return ir->operands[0]; in handle_expression()
513 reassociate_constant(ir, 0, op_const[0], op_expr[1]); in handle_expression()
515 reassociate_constant(ir, 1, op_const[1], op_expr[0]); in handle_expression()
560 ir_rvalue *x_operand = ir->operands[1 - mul_pos]; in handle_expression()
581 return neg(ir->operands[1]); in handle_expression()
583 return ir->operands[0]; in handle_expression()
588 return ir->operands[1]; in handle_expression()
590 return ir->operands[0]; in handle_expression()
593 return ir_constant::zero(ir, ir->type); in handle_expression()
596 return neg(ir->operands[1]); in handle_expression()
598 return neg(ir->operands[0]); in handle_expression()
609 reassociate_constant(ir, 0, op_const[0], op_expr[1]); in handle_expression()
611 reassociate_constant(ir, 1, op_const[1], op_expr[0]); in handle_expression()
622 ir_expression *sign_expr = ir->operands[i]->as_expression(); in handle_expression()
623 ir_expression *floor_expr = ir->operands[1 - i]->as_expression(); in handle_expression()
652 ir->type->is_float() || ir->type->is_double())) { in handle_expression()
654 ir->operands[1]->type, in handle_expression()
655 ir->operands[1], in handle_expression()
659 return ir->operands[0]; in handle_expression()
664 return ir_constant::zero(mem_ctx, ir->type); in handle_expression()
689 ir_expression(op, ir->type, in handle_expression()
690 new(mem_ctx) ir_swizzle(ir->operands[0], in handle_expression()
692 new(mem_ctx) ir_swizzle(ir->operands[1], in handle_expression()
715 return new(mem_ctx) ir_expression(ir->operation, in handle_expression()
719 return new(mem_ctx) ir_expression(ir->operation, in handle_expression()
728 if (ir->operands[0]->type->is_scalar() && in handle_expression()
729 ir->operands[1]->type->is_scalar()) in handle_expression()
730 return new(mem_ctx) ir_expression(ir->operation == ir_binop_all_equal in handle_expression()
732 ir->operands[0], in handle_expression()
733 ir->operands[1]); in handle_expression()
740 return ir->operands[0]; in handle_expression()
743 return ir->operands[0]; in handle_expression()
748 return ir->operands[1]; in handle_expression()
750 return ir->operands[0]; in handle_expression()
752 return ir_constant::zero(mem_ctx, ir->type); in handle_expression()
760 } else if (ir->operands[0]->equals(ir->operands[1])) { in handle_expression()
762 return ir->operands[0]; in handle_expression()
768 return ir->operands[1]; in handle_expression()
770 return ir->operands[0]; in handle_expression()
772 return logic_not(ir->operands[1]); in handle_expression()
774 return logic_not(ir->operands[0]); in handle_expression()
775 } else if (ir->operands[0]->equals(ir->operands[1])) { in handle_expression()
777 return ir_constant::zero(mem_ctx, ir->type); in handle_expression()
783 return ir->operands[1]; in handle_expression()
785 return ir->operands[0]; in handle_expression()
792 return new(mem_ctx) ir_constant(ir->type, &data); in handle_expression()
800 } else if (ir->operands[0]->equals(ir->operands[1])) { in handle_expression()
802 return ir->operands[0]; in handle_expression()
813 return ir->operands[0]; in handle_expression()
817 return expr(ir_unop_exp2, ir->operands[1]); in handle_expression()
820 ir_variable *x = new(ir) ir_variable(ir->operands[1]->type, "x", in handle_expression()
823 base_ir->insert_before(assign(x, ir->operands[0])); in handle_expression()
828 ir_variable *x = new(ir) ir_variable(ir->operands[1]->type, "x", in handle_expression()
831 base_ir->insert_before(assign(x, ir->operands[0])); in handle_expression()
833 ir_variable *squared = new(ir) ir_variable(ir->operands[1]->type, in handle_expression()
845 if (!ir->type->is_float() || options->EmitNoSat) in handle_expression()
854 ir_expression_operation op_cond = (ir->operation == ir_binop_max) ? in handle_expression()
877 if (ir->operation == ir_binop_min && in handle_expression()
883 if (ir->operation == ir_binop_max && in handle_expression()
889 if (ir->operation == ir_binop_min && in handle_expression()
895 if (ir->operation == ir_binop_max && in handle_expression()
901 if (ir->operation == ir_binop_max && in handle_expression()
907 if (ir->operation == ir_binop_min && in handle_expression()
922 return new(mem_ctx) ir_expression(op_expr[0]->operation, ir->type, in handle_expression()
942 return ir->operands[2]; in handle_expression()
944 return mul(ir->operands[0], ir->operands[1]); in handle_expression()
946 return add(ir->operands[1], ir->operands[2]); in handle_expression()
948 return add(ir->operands[0], ir->operands[2]); in handle_expression()
955 return ir->operands[0]; in handle_expression()
957 return ir->operands[1]; in handle_expression()
958 } else if (ir->operands[0]->equals(ir->operands[1])) { in handle_expression()
959 return ir->operands[0]; in handle_expression()
961 return mul(ir->operands[1], ir->operands[2]); in handle_expression()
963 unsigned op2_components = ir->operands[2]->type->vector_elements; in handle_expression()
966 switch (ir->type->base_type) { in handle_expression()
978 return mul(ir->operands[0], add(one, neg(ir->operands[2]))); in handle_expression()
984 return ir->operands[1]; in handle_expression()
986 return ir->operands[2]; in handle_expression()
996 return ir->operands[0]; in handle_expression()
1003 return ir; in handle_expression()