Lines Matching refs: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)
89 ir_variable *var = ir->lhs->variable_referenced();
104 is_vec_zero(ir_constant *ir)
106 return (ir == NULL) ? false : ir->is_zero();
110 is_vec_one(ir_constant *ir)
112 return (ir == NULL) ? false : ir->is_one();
116 is_vec_two(ir_constant *ir)
118 return (ir == NULL) ? false : ir->is_value(2.0, 2);
122 is_vec_four(ir_constant *ir)
124 return (ir == NULL) ? false : ir->is_value(4.0, 4);
128 is_vec_negative_one(ir_constant *ir)
130 return (ir == NULL) ? false : ir->is_negative_one();
134 is_valid_vec_const(ir_constant *ir)
136 if (ir == NULL)
139 if (!ir->type->is_scalar() && !ir->type->is_vector())
146 is_less_than_one(ir_constant *ir)
148 assert(ir->type->is_float());
150 if (!is_valid_vec_const(ir))
154 for (int c = 0; c < ir->type->vector_elements; c++) {
155 if (ir->get_float_component(c) < 1.0f)
159 return (component == ir->type->vector_elements);
163 is_greater_than_zero(ir_constant *ir)
165 assert(ir->type->is_float());
167 if (!is_valid_vec_const(ir))
171 for (int c = 0; c < ir->type->vector_elements; c++) {
172 if (ir->get_float_component(c) > 0.0f)
176 return (component == ir->type->vector_elements);
180 update_type(ir_expression *ir)
182 if (ir->operands[0]->type->is_vector())
183 ir->type = ir->operands[0]->type;
185 ir->type = ir->operands[1]->type;
315 ir_algebraic_visitor::handle_expression(ir_expression *ir)
320 if (ir->operation == ir_binop_mul &&
321 ir->operands[0]->type->is_matrix() &&
322 ir->operands[1]->type->is_vector()) {
323 ir_expression *matrix_mul = ir->operands[0]->as_expression();
330 mul(matrix_mul->operands[1], ir->operands[1]));
334 assert(ir->num_operands <= 4);
335 for (unsigned i = 0; i < ir->num_operands; i++) {
336 if (ir->operands[i]->type->is_matrix())
337 return ir;
340 ir->operands[i]->constant_expression_value(ralloc_parent(ir));
341 op_expr[i] = ir->operands[i]->as_expression();
345 this->mem_ctx = ralloc_parent(ir);
347 switch (ir->operation) {
408 ir->type,
428 return new(mem_ctx) ir_expression(ir->operation,
429 ir->type,
456 ir->type,
481 ir_expression *const op = ir->operands[0]->as_expression(); \
506 return ir->operands[1];
508 return ir->operands[0];
514 ir_rvalue *other = ir->operands[(i + 1) % 2];
516 return ir_constant::zero(ir, ir->type);
526 reassociate_constant(ir, 0, op_const[0], op_expr[1]);
528 reassociate_constant(ir, 1, op_const[1], op_expr[0]);
573 ir_rvalue *x_operand = ir->operands[1 - mul_pos];
595 return neg(ir->operands[1]);
597 return ir->operands[0];
602 return ir->operands[1];
604 return ir->operands[0];
607 return ir_constant::zero(ir, ir->type);
610 return neg(ir->operands[1]);
612 return neg(ir->operands[0]);
623 reassociate_constant(ir, 0, op_const[0], op_expr[1]);
625 reassociate_constant(ir, 1, op_const[1], op_expr[0]);
636 ir_expression *sign_expr = ir->operands[i]->as_expression();
637 ir_expression *floor_expr = ir->operands[1 - i]->as_expression();
666 ir->type->is_float() || ir->type->is_double())) {
668 ir->operands[1]->type,
669 ir->operands[1],
673 return ir->operands[0];
678 return ir_constant::zero(mem_ctx, ir->type);
703 ir_expression(op, ir->type,
704 new(mem_ctx) ir_swizzle(ir->operands[0],
706 new(mem_ctx) ir_swizzle(ir->operands[1],
733 return new(mem_ctx) ir_expression(ir->operation,
737 return new(mem_ctx) ir_expression(ir->operation,
746 if (ir->operands[0]->type->is_scalar() &&
747 ir->operands[1]->type->is_scalar())
748 return new(mem_ctx) ir_expression(ir->operation == ir_binop_all_equal
750 ir->operands[0],
751 ir->operands[1]);
758 return ir->operands[0];
761 return ir->operands[0];
766 return ir->operands[1];
768 return ir->operands[0];
770 return ir_constant::zero(mem_ctx, ir->type);
778 } else if (ir->operands[0]->equals(ir->operands[1])) {
780 return ir->operands[0];
786 return ir->operands[1];
788 return ir->operands[0];
790 return logic_not(ir->operands[1]);
792 return logic_not(ir->operands[0]);
793 } else if (ir->operands[0]->equals(ir->operands[1])) {
795 return ir_constant::zero(mem_ctx, ir->type);
801 return ir->operands[1];
803 return ir->operands[0];
810 return new(mem_ctx) ir_constant(ir->type, &data);
818 } else if (ir->operands[0]->equals(ir->operands[1])) {
820 return ir->operands[0];
831 return ir->operands[0];
835 return expr(ir_unop_exp2, ir->operands[1]);
838 ir_variable *x = new(ir) ir_variable(ir->operands[1]->type, "x",
841 base_ir->insert_before(assign(x, ir->operands[0]));
846 ir_variable *x = new(ir) ir_variable(ir->operands[1]->type, "x",
849 base_ir->insert_before(assign(x, ir->operands[0]));
851 ir_variable *squared = new(ir) ir_variable(ir->operands[1]->type,
863 if (!ir->type->is_float())
872 ir_expression_operation op_cond = (ir->operation == ir_binop_max) ?
895 if (ir->operation == ir_binop_min &&
901 if (ir->operation == ir_binop_max &&
907 if (ir->operation == ir_binop_min &&
913 if (ir->operation == ir_binop_max &&
919 if (ir->operation == ir_binop_max &&
925 if (ir->operation == ir_binop_min &&
940 return new(mem_ctx) ir_expression(op_expr[0]->operation, ir->type,
957 return ir->operands[2];
959 return mul(ir->operands[0], ir->operands[1]);
961 return add(ir->operands[1], ir->operands[2]);
963 return add(ir->operands[0], ir->operands[2]);
970 return ir->operands[0];
972 return ir->operands[1];
973 } else if (ir->operands[0]->equals(ir->operands[1])) {
974 return ir->operands[0];
976 return mul(ir->operands[1], ir->operands[2]);
978 unsigned op2_components = ir->operands[2]->type->vector_elements;
981 switch (ir->type->base_type) {
996 return mul(ir->operands[0], add(one, neg(ir->operands[2])));
1002 return ir->operands[1];
1004 return ir->operands[2];
1014 return ir->operands[0];
1021 return ir;