ir_expression::ir_expression(int op, const struct glsl_type *type, ir_rvalue *op0, ir_rvalue *op1, ir_rvalue *op2, ir_rvalue *op3) : ir_rvalue(higher_precision(higher_precision(op0,op1), higher_precision(op2,op3))) { this->ir_type = ir_type_expression; this->type = type; this->operation = ir_expression_operation(op); this->operands[0] = op0; this->operands[1] = op1; this->operands[2] = op2; this->operands[3] = op3; }
glsl_precision higher_precision (ir_instruction* a, ir_instruction* b) { if (!a && !b) return glsl_precision_undefined; if (!a) return precision_from_ir (b); if (!b) return precision_from_ir (a); return higher_precision (precision_from_ir(a), precision_from_ir(b)); }
ir_expression::ir_expression(int op, const struct glsl_type *type, ir_rvalue *op0, ir_rvalue *op1, ir_rvalue *op2, ir_rvalue *op3) : ir_rvalue(higher_precision(higher_precision(op0,op1), higher_precision(op2,op3))) { this->ir_type = ir_type_expression; this->type = type; this->operation = ir_expression_operation(op); this->operands[0] = op0; this->operands[1] = op1; this->operands[2] = op2; this->operands[3] = op3; #ifndef NDEBUG int num_operands = get_num_operands(this->operation); for (int i = num_operands; i < 4; i++) { assert(this->operands[i] == NULL); } #endif }
ir_expression::ir_expression(int op, const struct glsl_type *type, ir_rvalue *op0, ir_rvalue *op1) : ir_rvalue(higher_precision(op0,op1)) { assert(((op1 == NULL) && (get_num_operands(ir_expression_operation(op)) == 1)) || (get_num_operands(ir_expression_operation(op)) == 2)); this->ir_type = ir_type_expression; this->type = type; this->operation = ir_expression_operation(op); this->operands[0] = op0; this->operands[1] = op1; this->operands[2] = NULL; this->operands[3] = NULL; }
ir_expression::ir_expression(int op, ir_rvalue *op0, ir_rvalue *op1) : ir_rvalue(higher_precision(op0,op1)) { this->ir_type = ir_type_expression; this->operation = ir_expression_operation(op); this->operands[0] = op0; this->operands[1] = op1; this->operands[2] = NULL; this->operands[3] = NULL; assert(op > ir_last_unop); switch (this->operation) { case ir_binop_all_equal: case ir_binop_any_nequal: this->type = glsl_type::bool_type; break; case ir_binop_add: case ir_binop_sub: case ir_binop_min: case ir_binop_max: case ir_binop_pow: case ir_binop_mul: case ir_binop_div: case ir_binop_mod: if (op0->type->is_scalar()) { this->type = op1->type; } else if (op1->type->is_scalar()) { this->type = op0->type; } else { /* FINISHME: matrix types */ assert(!op0->type->is_matrix() && !op1->type->is_matrix()); assert(op0->type == op1->type); this->type = op0->type; } break; case ir_binop_logic_and: case ir_binop_logic_xor: case ir_binop_logic_or: case ir_binop_bit_and: case ir_binop_bit_xor: case ir_binop_bit_or: if (op0->type->is_scalar()) { this->type = op1->type; } else if (op1->type->is_scalar()) { this->type = op0->type; } break; case ir_binop_equal: case ir_binop_nequal: case ir_binop_lequal: case ir_binop_gequal: case ir_binop_less: case ir_binop_greater: assert(op0->type == op1->type); this->type = glsl_type::get_instance(GLSL_TYPE_BOOL, op0->type->vector_elements, 1); break; case ir_binop_dot: this->type = glsl_type::float_type; break; case ir_binop_lshift: case ir_binop_rshift: this->type = op0->type; break; default: assert(!"not reached: missing automatic type setup for ir_expression"); this->type = glsl_type::float_type; } }