• Home
  • Raw
  • Download

Lines Matching full:ir

31 #include "ir.h"
62 virtual ir_visitor_status visit_enter(ir_assignment *ir);
64 ir_rvalue *handle_expression(ir_expression *ir);
87 ir_algebraic_visitor::visit_enter(ir_assignment *ir) in visit_enter() argument
89 ir_variable *var = ir->lhs->variable_referenced(); in visit_enter()
104 is_vec_zero(ir_constant *ir) in is_vec_zero() argument
106 return (ir == NULL) ? false : ir->is_zero(); in is_vec_zero()
110 is_vec_one(ir_constant *ir) in is_vec_one() argument
112 return (ir == NULL) ? false : ir->is_one(); in is_vec_one()
116 is_vec_two(ir_constant *ir) in is_vec_two() argument
118 return (ir == NULL) ? false : ir->is_value(2.0, 2); in is_vec_two()
122 is_vec_four(ir_constant *ir) in is_vec_four() argument
124 return (ir == NULL) ? false : ir->is_value(4.0, 4); in is_vec_four()
128 is_vec_negative_one(ir_constant *ir) in is_vec_negative_one() argument
130 return (ir == NULL) ? false : ir->is_negative_one(); in is_vec_negative_one()
134 is_valid_vec_const(ir_constant *ir) in is_valid_vec_const() argument
136 if (ir == NULL) in is_valid_vec_const()
139 if (!ir->type->is_scalar() && !ir->type->is_vector()) in is_valid_vec_const()
146 is_less_than_one(ir_constant *ir) in is_less_than_one() argument
148 assert(ir->type->is_float()); in is_less_than_one()
150 if (!is_valid_vec_const(ir)) in is_less_than_one()
154 for (int c = 0; c < ir->type->vector_elements; c++) { in is_less_than_one()
155 if (ir->get_float_component(c) < 1.0f) in is_less_than_one()
159 return (component == ir->type->vector_elements); in is_less_than_one()
163 is_greater_than_zero(ir_constant *ir) in is_greater_than_zero() argument
165 assert(ir->type->is_float()); in is_greater_than_zero()
167 if (!is_valid_vec_const(ir)) in is_greater_than_zero()
171 for (int c = 0; c < ir->type->vector_elements; c++) { in is_greater_than_zero()
172 if (ir->get_float_component(c) > 0.0f) in is_greater_than_zero()
176 return (component == ir->type->vector_elements); in is_greater_than_zero()
180 update_type(ir_expression *ir) in update_type() argument
182 if (ir->operands[0]->type->is_vector()) in update_type()
183 ir->type = ir->operands[0]->type; in update_type()
185 ir->type = ir->operands[1]->type; in update_type()
315 ir_algebraic_visitor::handle_expression(ir_expression *ir) in handle_expression() argument
320 if (ir->operation == ir_binop_mul && in handle_expression()
321 ir->operands[0]->type->is_matrix() && in handle_expression()
322 ir->operands[1]->type->is_vector()) { in handle_expression()
323 ir_expression *matrix_mul = ir->operands[0]->as_expression(); in handle_expression()
330 mul(matrix_mul->operands[1], ir->operands[1])); in handle_expression()
334 assert(ir->num_operands <= 4); in handle_expression()
335 for (unsigned i = 0; i < ir->num_operands; i++) { in handle_expression()
336 if (ir->operands[i]->type->is_matrix()) in handle_expression()
337 return ir; in handle_expression()
340 ir->operands[i]->constant_expression_value(ralloc_parent(ir)); in handle_expression()
341 op_expr[i] = ir->operands[i]->as_expression(); in handle_expression()
345 this->mem_ctx = ralloc_parent(ir); in handle_expression()
347 switch (ir->operation) { in handle_expression()
408 ir->type, in handle_expression()
428 return new(mem_ctx) ir_expression(ir->operation, in handle_expression()
429 ir->type, in handle_expression()
456 ir->type, in handle_expression()
481 ir_expression *const op = ir->operands[0]->as_expression(); \ in handle_expression()
506 return ir->operands[1]; in handle_expression()
508 return ir->operands[0]; in handle_expression()
514 ir_rvalue *other = ir->operands[(i + 1) % 2]; in handle_expression()
516 return ir_constant::zero(ir, ir->type); in handle_expression()
526 reassociate_constant(ir, 0, op_const[0], op_expr[1]); in handle_expression()
528 reassociate_constant(ir, 1, op_const[1], op_expr[0]); in handle_expression()
573 ir_rvalue *x_operand = ir->operands[1 - mul_pos]; in handle_expression()
595 return neg(ir->operands[1]); in handle_expression()
597 return ir->operands[0]; in handle_expression()
602 return ir->operands[1]; in handle_expression()
604 return ir->operands[0]; in handle_expression()
607 return ir_constant::zero(ir, ir->type); in handle_expression()
610 return neg(ir->operands[1]); in handle_expression()
612 return neg(ir->operands[0]); in handle_expression()
623 reassociate_constant(ir, 0, op_const[0], op_expr[1]); in handle_expression()
625 reassociate_constant(ir, 1, op_const[1], op_expr[0]); in handle_expression()
636 ir_expression *sign_expr = ir->operands[i]->as_expression(); in handle_expression()
637 ir_expression *floor_expr = ir->operands[1 - i]->as_expression(); in handle_expression()
666 ir->type->is_float() || ir->type->is_double())) { in handle_expression()
668 ir->operands[1]->type, in handle_expression()
669 ir->operands[1], in handle_expression()
673 return ir->operands[0]; in handle_expression()
678 return ir_constant::zero(mem_ctx, ir->type); in handle_expression()
703 ir_expression(op, ir->type, in handle_expression()
704 new(mem_ctx) ir_swizzle(ir->operands[0], in handle_expression()
706 new(mem_ctx) ir_swizzle(ir->operands[1], in handle_expression()
735 return new(mem_ctx) ir_expression(ir->operation, in handle_expression()
739 return new(mem_ctx) ir_expression(ir->operation, in handle_expression()
748 if (ir->operands[0]->type->is_scalar() && in handle_expression()
749 ir->operands[1]->type->is_scalar()) in handle_expression()
750 return new(mem_ctx) ir_expression(ir->operation == ir_binop_all_equal in handle_expression()
752 ir->operands[0], in handle_expression()
753 ir->operands[1]); in handle_expression()
760 return ir->operands[0]; in handle_expression()
763 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 ir_constant::zero(mem_ctx, ir->type); in handle_expression()
780 } else if (ir->operands[0]->equals(ir->operands[1])) { in handle_expression()
782 return ir->operands[0]; in handle_expression()
788 return ir->operands[1]; in handle_expression()
790 return ir->operands[0]; in handle_expression()
792 return logic_not(ir->operands[1]); in handle_expression()
794 return logic_not(ir->operands[0]); in handle_expression()
795 } else if (ir->operands[0]->equals(ir->operands[1])) { in handle_expression()
797 return ir_constant::zero(mem_ctx, ir->type); in handle_expression()
803 return ir->operands[1]; in handle_expression()
805 return ir->operands[0]; in handle_expression()
812 return new(mem_ctx) ir_constant(ir->type, &data); in handle_expression()
820 } else if (ir->operands[0]->equals(ir->operands[1])) { in handle_expression()
822 return ir->operands[0]; in handle_expression()
833 return ir->operands[0]; in handle_expression()
837 return expr(ir_unop_exp2, ir->operands[1]); in handle_expression()
840 ir_variable *x = new(ir) ir_variable(ir->operands[1]->type, "x", in handle_expression()
843 base_ir->insert_before(assign(x, ir->operands[0])); in handle_expression()
848 ir_variable *x = new(ir) ir_variable(ir->operands[1]->type, "x", in handle_expression()
851 base_ir->insert_before(assign(x, ir->operands[0])); in handle_expression()
853 ir_variable *squared = new(ir) ir_variable(ir->operands[1]->type, in handle_expression()
865 if (!ir->type->is_float() || options->EmitNoSat) in handle_expression()
874 ir_expression_operation op_cond = (ir->operation == ir_binop_max) ? in handle_expression()
897 if (ir->operation == ir_binop_min && in handle_expression()
903 if (ir->operation == ir_binop_max && in handle_expression()
909 if (ir->operation == ir_binop_min && in handle_expression()
915 if (ir->operation == ir_binop_max && in handle_expression()
921 if (ir->operation == ir_binop_max && in handle_expression()
927 if (ir->operation == ir_binop_min && in handle_expression()
942 return new(mem_ctx) ir_expression(op_expr[0]->operation, ir->type, in handle_expression()
947 * its IR level, so we can always apply this transformation. in handle_expression()
962 return ir->operands[2]; in handle_expression()
964 return mul(ir->operands[0], ir->operands[1]); in handle_expression()
966 return add(ir->operands[1], ir->operands[2]); in handle_expression()
968 return add(ir->operands[0], ir->operands[2]); in handle_expression()
975 return ir->operands[0]; in handle_expression()
977 return ir->operands[1]; in handle_expression()
978 } else if (ir->operands[0]->equals(ir->operands[1])) { in handle_expression()
979 return ir->operands[0]; in handle_expression()
981 return mul(ir->operands[1], ir->operands[2]); in handle_expression()
983 unsigned op2_components = ir->operands[2]->type->vector_elements; in handle_expression()
986 switch (ir->type->base_type) { in handle_expression()
1001 return mul(ir->operands[0], add(one, neg(ir->operands[2]))); in handle_expression()
1007 return ir->operands[1]; in handle_expression()
1009 return ir->operands[2]; in handle_expression()
1019 return ir->operands[0]; in handle_expression()
1026 return ir; in handle_expression()