Home | History | Annotate | Download | only in glsl

Lines Matching refs:ir

81 #include "ir.h"
119 lower_instructions_visitor::sub_to_add_neg(ir_expression *ir)
121 ir->operation = ir_binop_add;
122 ir->operands[1] = new(ir) ir_expression(ir_unop_neg, ir->operands[1]->type,
123 ir->operands[1], NULL);
128 lower_instructions_visitor::div_to_mul_rcp(ir_expression *ir)
130 if (!ir->operands[1]->type->is_integer()) {
133 expr = new(ir) ir_expression(ir_unop_rcp,
134 ir->operands[1]->type,
135 ir->operands[1],
139 ir->operation = ir_binop_mul;
140 ir->operands[1] = expr;
150 ir->operands[1]->type->vector_elements,
151 ir->operands[1]->type->matrix_columns);
153 if (ir->operands[1]->type->base_type == GLSL_TYPE_INT)
154 op1 = new(ir) ir_expression(ir_unop_i2f, vec_type, ir->operands[1], NULL);
156 op1 = new(ir) ir_expression(ir_unop_u2f, vec_type, ir->operands[1], NULL);
158 op1 = new(ir) ir_expression(ir_unop_rcp, op1->type, op1, NULL);
161 ir->operands[0]->type->vector_elements,
162 ir->operands[0]->type->matrix_columns);
164 if (ir->operands[0]->type->base_type == GLSL_TYPE_INT)
165 op0 = new(ir) ir_expression(ir_unop_i2f, vec_type, ir->operands[0], NULL);
167 op0 = new(ir) ir_expression(ir_unop_u2f, vec_type, ir->operands[0], NULL);
169 op0 = new(ir) ir_expression(ir_binop_mul, vec_type, op0, op1);
171 ir->operation = ir_unop_f2i;
172 ir->operands[0] = op0;
173 ir->operands[1] = NULL;
180 lower_instructions_visitor::exp_to_exp2(ir_expression *ir)
182 ir_constant *log2_e = new(ir) ir_constant(float(M_LOG2E));
184 ir->operation = ir_unop_exp2;
185 ir->operands[0] = new(ir) ir_expression(ir_binop_mul, ir->operands[0]->type,
186 ir->operands[0], log2_e);
191 lower_instructions_visitor::pow_to_exp2(ir_expression *ir)
194 new(ir) ir_expression(ir_unop_log2, ir->operands[0]->type,
195 ir->operands[0]);
197 ir->operation = ir_unop_exp2;
198 ir->operands[0] = new(ir) ir_expression(ir_binop_mul, ir->operands[1]->type,
199 ir->operands[1], log2_x);
200 ir->operands[1] = NULL;
205 lower_instructions_visitor::log_to_log2(ir_expression *ir)
207 ir->operation = ir_binop_mul;
208 ir->operands[0] = new(ir) ir_expression(ir_unop_log2, ir->operands[0]->type,
209 ir->operands[0], NULL);
210 ir->operands[1] = new(ir) ir_constant(float(1.0 / M_LOG2E));
215 lower_instructions_visitor::mod_to_fract(ir_expression *ir)
217 ir_variable *temp = new(ir) ir_variable(ir->operands[1]->type, "mod_b",
222 new(ir) ir_assignment(new(ir) ir_dereference_variable(temp),
223 ir->operands[1], NULL);
228 new(ir) ir_expression(ir_binop_div, ir->operands[0]->type,
229 ir->operands[0],
230 new(ir) ir_dereference_variable(temp));
232 /* Don't generate new IR that would need to be lowered in an additional
238 ir_rvalue *expr = new(ir) ir_expression(ir_unop_fract,
239 ir->operands[0]->type,
243 ir->operation = ir_binop_mul;
244 ir->operands[0] = new(ir) ir_dereference_variable(temp);
245 ir->operands[1] = expr;
250 lower_instructions_visitor::visit_leave(ir_expression *ir)
252 switch (ir->operation) {
255 sub_to_add_neg(ir);
260 div_to_mul_rcp(ir);
265 exp_to_exp2(ir);
270 log_to_log2(ir);
275 mod_to_fract(ir);
280 pow_to_exp2(ir);