#ifndef IR_H
#define IR_H
+#include <cstdio>
+#include <cstdlib>
+
#include "list.h"
#include "ir_visitor.h"
#include "ir_hierarchical_visitor.h"
const struct glsl_type *type;
class ir_constant *constant_expression_value();
+
+ /** ir_print_visitor helper for debugging. */
+ void print(void);
+
virtual void accept(ir_visitor *) = 0;
virtual ir_visitor_status accept(ir_hierarchical_visitor *) = 0;
return var;
}
+ /**
+ * Get the string value for the interpolation qualifier
+ *
+ * \return
+ * If none of \c shader_in or \c shader_out is set, an empty string will
+ * be returned. Otherwise the string that would be used in a shader to
+ * specify \c mode will be returned.
+ */
+ const char *interpolation_string() const;
+
const char *name;
/**
ir_unop_cos,
/*@}*/
+ /**
+ * \name Partial derivatives.
+ */
+ /*@{*/
+ ir_unop_dFdx,
+ ir_unop_dFdy,
+ /*@}*/
+
ir_binop_add,
ir_binop_sub,
ir_binop_mul,
class ir_texture : public ir_rvalue {
public:
ir_texture(enum ir_texture_opcode op)
- : op(op)
+ : op(op), projector(NULL), shadow_comparitor(NULL)
{
/* empty */
}
+ virtual void accept(ir_visitor *v)
+ {
+ v->visit(this);
+ }
+
+ virtual ir_visitor_status accept(ir_hierarchical_visitor *);
+
/**
* Return a string representing the ir_texture_opcode.
*/
const char *opcode_string();
+ /** Set the sampler and infer the type. */
+ void set_sampler(ir_dereference *sampler);
+
/**
* Do a reverse-lookup to translate a string into an ir_texture_opcode.
*/
};
+/**
+ * Data stored in an ir_constant
+ */
+union ir_constant_data {
+ unsigned u[16];
+ int i[16];
+ float f[16];
+ bool b[16];
+};
+
+
class ir_constant : public ir_rvalue {
public:
- ir_constant(const struct glsl_type *type, const void *data);
+ ir_constant(const struct glsl_type *type, const ir_constant_data *data);
ir_constant(bool b);
ir_constant(unsigned int u);
ir_constant(int i);
ir_constant(float f);
+ /**
+ * Construct an ir_constant from a list of ir_constant values
+ */
+ ir_constant(const struct glsl_type *type, exec_list *values);
+
+ /**
+ * Construct an ir_constant from a scalar component of another ir_constant
+ *
+ * The new \c ir_constant inherits the type of the component from the
+ * source constant.
+ *
+ * \note
+ * In the case of a matrix constant, the new constant is a scalar, \b not
+ * a vector.
+ */
+ ir_constant(const ir_constant *c, unsigned i);
+
virtual ir_constant *as_constant()
{
return this;
virtual ir_visitor_status accept(ir_hierarchical_visitor *);
- ir_constant *clone()
- {
- return new ir_constant(this->type, &this->value);
- }
+ ir_constant *clone();
+
+ /**
+ * Get a particular component of a constant as a specific type
+ *
+ * This is useful, for example, to get a value from an integer constant
+ * as a float or bool. This appears frequently when constructors are
+ * called with all constant parameters.
+ */
+ /*@{*/
+ bool get_bool_component(unsigned i) const;
+ float get_float_component(unsigned i) const;
+ int get_int_component(unsigned i) const;
+ unsigned get_uint_component(unsigned i) const;
+ /*@}*/
+
+ ir_constant *get_record_field(const char *name);
+
+ /**
+ * Determine whether a constant has the same value as another constant
+ */
+ bool has_value(const ir_constant *) const;
/**
* Value of the constant.
* by the type associated with the \c ir_instruction. Constants may be
* scalars, vectors, or matrices.
*/
- union {
- unsigned u[16];
- int i[16];
- float f[16];
- bool b[16];
- } value;
+ union ir_constant_data value;
+
+ exec_list components;
+
+private:
+ /**
+ * Parameterless constructor only used by the clone method
+ */
+ ir_constant(void);
};
void
visit_exec_list(exec_list *list, ir_visitor *visitor);
+void validate_ir_tree(exec_list *instructions);
+
extern void
_mesa_glsl_initialize_variables(exec_list *instructions,
struct _mesa_glsl_parse_state *state);