ir_algebraic_visitor()
{
this->progress = false;
+ this->mem_ctx = NULL;
}
virtual ~ir_algebraic_visitor()
int op1,
ir_expression *ir2,
int op2);
+
+ void *mem_ctx;
bool progress;
};
op_expr[i] = ir->operands[i]->as_expression();
}
+ if (this->mem_ctx == NULL)
+ this->mem_ctx = talloc_parent(ir);
+
switch (ir->operation) {
case ir_unop_logic_not: {
enum ir_expression_operation new_op = ir_unop_logic_not;
if (new_op != ir_unop_logic_not) {
this->progress = true;
- return new(ir) ir_expression(new_op,
- ir->type,
- op_expr[0]->operands[0],
- op_expr[0]->operands[1]);
+ return new(mem_ctx) ir_expression(new_op,
+ ir->type,
+ op_expr[0]->operands[0],
+ op_expr[0]->operands[1]);
}
break;
case ir_binop_sub:
if (is_vec_zero(op_const[0])) {
this->progress = true;
- return new(ir) ir_expression(ir_unop_neg,
- ir->type,
- ir->operands[1],
- NULL);
+ return new(mem_ctx) ir_expression(ir_unop_neg,
+ ir->type,
+ ir->operands[1],
+ NULL);
}
if (is_vec_zero(op_const[1])) {
this->progress = true;
case ir_binop_div:
if (is_vec_one(op_const[0]) && ir->type->base_type == GLSL_TYPE_FLOAT) {
this->progress = true;
- return new(ir) ir_expression(ir_unop_rcp,
- ir->type,
- ir->operands[1],
- NULL);
+ return new(mem_ctx) ir_expression(ir_unop_rcp,
+ ir->type,
+ ir->operands[1],
+ NULL);
}
if (is_vec_one(op_const[1])) {
this->progress = true;
/* As far as we know, all backends are OK with rsq. */
if (op_expr[0] && op_expr[0]->operation == ir_unop_sqrt) {
this->progress = true;
- return new(ir) ir_expression(ir_unop_rsq,
- ir->type,
- op_expr[0]->operands[0],
- NULL);
+ return new(mem_ctx) ir_expression(ir_unop_rsq,
+ ir->type,
+ op_expr[0]->operands[0],
+ NULL);
}
break;