ir_assignment::ir_assignment(ir_rvalue *lhs, ir_rvalue *rhs,
ir_rvalue *condition)
{
+ this->ir_type = ir_type_assignment;
this->lhs = lhs;
this->rhs = rhs;
this->condition = condition;
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;
ir_constant::ir_constant()
{
- /* empty */
+ this->ir_type = ir_type_constant;
}
ir_constant::ir_constant(const struct glsl_type *type,
assert((type->base_type >= GLSL_TYPE_UINT)
&& (type->base_type <= GLSL_TYPE_BOOL));
+ this->ir_type = ir_type_constant;
this->type = type;
memcpy(& this->value, data, sizeof(this->value));
}
ir_constant::ir_constant(float f)
{
+ this->ir_type = ir_type_constant;
this->type = glsl_type::float_type;
this->value.f[0] = f;
}
ir_constant::ir_constant(unsigned int u)
{
+ this->ir_type = ir_type_constant;
this->type = glsl_type::uint_type;
this->value.u[0] = u;
}
ir_constant::ir_constant(int i)
{
+ this->ir_type = ir_type_constant;
this->type = glsl_type::int_type;
this->value.i[0] = i;
}
ir_constant::ir_constant(bool b)
{
+ this->ir_type = ir_type_constant;
this->type = glsl_type::bool_type;
this->value.b[0] = b;
}
ir_constant::ir_constant(const ir_constant *c, unsigned i)
{
+ this->ir_type = ir_type_constant;
this->type = c->type->get_base_type();
switch (this->type->base_type) {
ir_constant::ir_constant(const struct glsl_type *type, exec_list *value_list)
{
+ this->ir_type = ir_type_constant;
this->type = type;
/* FINISHME: Support array types. */
ir_dereference_variable::ir_dereference_variable(ir_variable *var)
{
+ this->ir_type = ir_type_dereference_variable;
this->var = var;
this->type = (var != NULL) ? var->type : glsl_type::error_type;
}
ir_dereference_array::ir_dereference_array(ir_rvalue *value,
ir_rvalue *array_index)
{
+ this->ir_type = ir_type_dereference_array;
this->array_index = array_index;
this->set_array(value);
}
{
void *ctx = talloc_parent(var);
+ this->ir_type = ir_type_dereference_array;
this->array_index = array_index;
this->set_array(new(ctx) ir_dereference_variable(var));
}
ir_dereference_record::ir_dereference_record(ir_rvalue *value,
const char *field)
{
+ this->ir_type = ir_type_dereference_record;
this->record = value;
this->field = field;
this->type = (this->record != NULL)
{
void *ctx = talloc_parent(var);
+ this->ir_type = ir_type_dereference_record;
this->record = new(ctx) ir_dereference_variable(var);
this->field = field;
this->type = (this->record != NULL)
: val(val)
{
const unsigned components[4] = { x, y, z, w };
+ this->ir_type = ir_type_swizzle;
this->init_mask(components, count);
}
unsigned count)
: val(val)
{
+ this->ir_type = ir_type_swizzle;
this->init_mask(comp, count);
}
ir_swizzle::ir_swizzle(ir_rvalue *val, ir_swizzle_mask mask)
{
+ this->ir_type = ir_type_swizzle;
this->val = val;
this->mask = mask;
this->type = glsl_type::get_instance(val->type->base_type,
shader_in(false), shader_out(false),
mode(ir_var_auto), interpolation(ir_var_smooth), array_lvalue(false)
{
+ this->ir_type = ir_type_variable;
this->type = type;
this->name = talloc_strdup(this, name);
this->location = -1;
ir_function_signature::ir_function_signature(const glsl_type *return_type)
: return_type(return_type), is_defined(false), _function(NULL)
{
- /* empty */
+ this->ir_type = ir_type_function_signature;
}
ir_function::ir_function(const char *name)
{
+ this->ir_type = ir_type_function;
this->name = talloc_strdup(this, name);
}
#define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0]))
#endif
+enum ir_node_type {
+ ir_type_unset,
+ ir_type_variable,
+ ir_type_assignment,
+ ir_type_call,
+ ir_type_constant,
+ ir_type_dereference_array,
+ ir_type_dereference_record,
+ ir_type_dereference_variable,
+ ir_type_discard,
+ ir_type_expression,
+ ir_type_function,
+ ir_type_function_signature,
+ ir_type_if,
+ ir_type_loop,
+ ir_type_loop_jump,
+ ir_type_return,
+ ir_type_swizzle,
+ ir_type_texture,
+ ir_type_max, /**< maximum ir_type enum number, for validation */
+};
+
/**
* Base class of all IR instructions
*/
class ir_instruction : public exec_node {
public:
+ enum ir_node_type ir_type;
const struct glsl_type *type;
class ir_constant *constant_expression_value();
protected:
ir_instruction()
{
- /* empty */
+ ir_type = ir_type_unset;
}
};
ir_if(ir_rvalue *condition)
: condition(condition)
{
- /* empty */
+ ir_type = ir_type_if;
}
virtual ir_if *clone(struct hash_table *ht) const;
public:
ir_loop() : from(NULL), to(NULL), increment(NULL), counter(NULL)
{
- /* empty */
+ ir_type = ir_type_loop;
}
virtual ir_loop *clone(struct hash_table *ht) const;
ir_call(ir_function_signature *callee, exec_list *actual_parameters)
: callee(callee)
{
+ ir_type = ir_type_call;
assert(callee->return_type != NULL);
type = callee->return_type;
actual_parameters->move_nodes_to(& this->actual_parameters);
ir_call()
: callee(NULL)
{
- /* empty */
+ this->ir_type = ir_type_call;
}
ir_function_signature *callee;
protected:
ir_jump()
{
- /* empty */
+ ir_type = ir_type_unset;
}
};
ir_return()
: value(NULL)
{
- /* empty */
+ this->ir_type = ir_type_return;
}
ir_return(ir_rvalue *value)
: value(value)
{
- /* empty */
+ this->ir_type = ir_type_return;
}
virtual ir_return *clone(struct hash_table *) const;
ir_loop_jump(jump_mode mode)
{
+ this->ir_type = ir_type_loop_jump;
this->mode = mode;
this->loop = loop;
}
public:
ir_discard()
{
+ this->ir_type = ir_type_discard;
this->condition = NULL;
}
ir_texture(enum ir_texture_opcode op)
: op(op), projector(NULL), shadow_comparitor(NULL)
{
- /* empty */
+ this->ir_type = ir_type_texture;
}
virtual ir_texture *clone(struct hash_table *) const;