ir_expression::ir_expression(int op, const struct glsl_type *type, ir_rvalue *op0) { assert(get_num_operands(ir_expression_operation(op)) == 1); this->ir_type = ir_type_expression; this->type = type; this->operation = ir_expression_operation(op); this->operands[0] = op0; this->operands[1] = NULL; this->operands[2] = NULL; this->operands[3] = NULL; }
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 *op2) { this->ir_type = ir_type_expression; this->operation = ir_expression_operation(op); this->operands[0] = op0; this->operands[1] = op1; this->operands[2] = op2; this->operands[3] = NULL; assert(op > ir_last_binop && op <= ir_last_triop); switch (this->operation) { case ir_triop_fma: case ir_triop_lrp: case ir_triop_bitfield_extract: case ir_triop_vector_insert: this->type = op0->type; break; case ir_triop_bfi: case ir_triop_csel: this->type = op1->type; break; default: assert(!"not reached: missing automatic type setup for ir_expression"); this->type = glsl_type::float_type; } }
ir_expression::ir_expression(int op, const struct glsl_type *type, ir_rvalue *op0, ir_rvalue *op1) { this->ir_type = ir_type_expression; this->type = type; this->operation = ir_expression_operation(op); this->operands[0] = op0; this->operands[1] = op1; }
ir_expression::ir_expression(int op, ir_rvalue *op0, ir_rvalue *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: 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_or: if (op0->type->is_scalar()) { this->type = op1->type; } else if (op1->type->is_scalar()) { this->type = op0->type; } break; case ir_binop_dot: this->type = glsl_type::float_type; break; default: assert(!"not reached: missing automatic type setup for ir_expression"); this->type = glsl_type::float_type; } }
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; }
ir_expression::ir_expression(int op, ir_rvalue *op0) { this->ir_type = ir_type_expression; this->operation = ir_expression_operation(op); this->operands[0] = op0; this->operands[1] = NULL; this->operands[2] = NULL; this->operands[3] = NULL; assert(op <= ir_last_unop); switch (this->operation) { case ir_unop_bit_not: case ir_unop_logic_not: case ir_unop_neg: case ir_unop_abs: case ir_unop_sign: case ir_unop_rcp: case ir_unop_rsq: case ir_unop_sqrt: case ir_unop_exp: case ir_unop_log: case ir_unop_exp2: case ir_unop_log2: case ir_unop_trunc: case ir_unop_ceil: case ir_unop_floor: case ir_unop_fract: case ir_unop_round_even: case ir_unop_cos: case ir_unop_dFdx: case ir_unop_dFdy: this->type = op0->type; break; case ir_unop_any: this->type = glsl_type::bool_type; break; default: assert(!"not reached: missing automatic type setup for ir_expression"); this->type = op0->type; break; } }
ir_expression::ir_expression(int op, const struct glsl_type *type, ir_rvalue *op0, ir_rvalue *op1, ir_rvalue *op2, ir_rvalue *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, 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; } }
ir_expression::ir_expression(int op, ir_rvalue *op0) : ir_rvalue(precision_from_ir(op0)) { this->ir_type = ir_type_expression; this->operation = ir_expression_operation(op); this->operands[0] = op0; this->operands[1] = NULL; this->operands[2] = NULL; this->operands[3] = NULL; assert(op <= ir_last_unop); switch (this->operation) { case ir_unop_bit_not: case ir_unop_logic_not: case ir_unop_neg: case ir_unop_abs: case ir_unop_sign: case ir_unop_rcp: case ir_unop_rsq: case ir_unop_sqrt: case ir_unop_normalize: case ir_unop_exp: case ir_unop_log: case ir_unop_exp2: case ir_unop_log2: case ir_unop_trunc: case ir_unop_ceil: case ir_unop_floor: case ir_unop_fract: case ir_unop_round_even: case ir_unop_sin: case ir_unop_cos: case ir_unop_sin_reduced: case ir_unop_cos_reduced: case ir_unop_dFdx: case ir_unop_dFdy: this->type = op0->type; break; case ir_unop_f2i: case ir_unop_b2i: case ir_unop_u2i: case ir_unop_bitcast_f2i: this->type = glsl_type::get_instance(GLSL_TYPE_INT, op0->type->vector_elements, 1); break; case ir_unop_b2f: case ir_unop_i2f: case ir_unop_u2f: case ir_unop_bitcast_i2f: case ir_unop_bitcast_u2f: this->type = glsl_type::get_instance(GLSL_TYPE_FLOAT, op0->type->vector_elements, 1); break; case ir_unop_f2b: case ir_unop_i2b: this->type = glsl_type::get_instance(GLSL_TYPE_BOOL, op0->type->vector_elements, 1); break; case ir_unop_i2u: case ir_unop_f2u: case ir_unop_bitcast_f2u: this->type = glsl_type::get_instance(GLSL_TYPE_UINT, op0->type->vector_elements, 1); break; case ir_unop_noise: this->type = glsl_type::float_type; break; case ir_unop_any: this->type = glsl_type::bool_type; break; default: assert(!"not reached: missing automatic type setup for ir_expression"); this->type = op0->type; break; } }