diff options
author | Ian Romanick <ian.d.romanick@intel.com> | 2010-11-10 16:33:10 -0800 |
---|---|---|
committer | Ian Romanick <ian.d.romanick@intel.com> | 2010-11-19 15:00:25 -0800 |
commit | fc92e87b9757eda01caf0bb3e2c31b1dbbd73aa0 (patch) | |
tree | 0166f7ad2f9b19794f8a65b0b050fe4dc4cd083a /src | |
parent | f2616e56de8a48360cae8f269727b58490555f4d (diff) | |
download | external_mesa3d-fc92e87b9757eda01caf0bb3e2c31b1dbbd73aa0.zip external_mesa3d-fc92e87b9757eda01caf0bb3e2c31b1dbbd73aa0.tar.gz external_mesa3d-fc92e87b9757eda01caf0bb3e2c31b1dbbd73aa0.tar.bz2 |
glsl: Eliminate assumptions about size of ir_expression::operands
This may grow in the near future.
Diffstat (limited to 'src')
-rw-r--r-- | src/glsl/ir_clone.cpp | 3 | ||||
-rw-r--r-- | src/glsl/ir_constant_expression.cpp | 2 | ||||
-rw-r--r-- | src/glsl/ir_print_visitor.cpp | 7 | ||||
-rw-r--r-- | src/glsl/lower_mat_op_to_vec.cpp | 2 | ||||
-rw-r--r-- | src/glsl/opt_algebraic.cpp | 1 | ||||
-rw-r--r-- | src/mesa/drivers/dri/i965/brw_fs.cpp | 3 | ||||
-rw-r--r-- | src/mesa/program/ir_to_mesa.cpp | 2 |
7 files changed, 13 insertions, 7 deletions
diff --git a/src/glsl/ir_clone.cpp b/src/glsl/ir_clone.cpp index a3cc8db..4032647 100644 --- a/src/glsl/ir_clone.cpp +++ b/src/glsl/ir_clone.cpp @@ -22,6 +22,7 @@ */ #include <string.h> +#include "main/compiler.h" #include "ir.h" #include "glsl_types.h" extern "C" { @@ -160,7 +161,7 @@ ir_call::clone(void *mem_ctx, struct hash_table *ht) const ir_expression * ir_expression::clone(void *mem_ctx, struct hash_table *ht) const { - ir_rvalue *op[2] = {NULL, NULL}; + ir_rvalue *op[Elements(this->operands)] = { NULL, }; unsigned int i; for (i = 0; i < get_num_operands(); i++) { diff --git a/src/glsl/ir_constant_expression.cpp b/src/glsl/ir_constant_expression.cpp index 45860b2..1fe1505 100644 --- a/src/glsl/ir_constant_expression.cpp +++ b/src/glsl/ir_constant_expression.cpp @@ -57,7 +57,7 @@ ir_expression::constant_expression_value() if (this->type->is_error()) return NULL; - ir_constant *op[2] = { NULL, NULL }; + ir_constant *op[Elements(this->operands)] = { NULL, }; ir_constant_data data; memset(&data, 0, sizeof(data)); diff --git a/src/glsl/ir_print_visitor.cpp b/src/glsl/ir_print_visitor.cpp index 5c19db1..e5067bf 100644 --- a/src/glsl/ir_print_visitor.cpp +++ b/src/glsl/ir_print_visitor.cpp @@ -182,11 +182,10 @@ void ir_print_visitor::visit(ir_expression *ir) printf(" %s ", ir->operator_string()); - if (ir->operands[0]) - ir->operands[0]->accept(this); + for (unsigned i = 0; i < ir->get_num_operands(); i++) { + ir->operands[i]->accept(this); + } - if (ir->operands[1]) - ir->operands[1]->accept(this); printf(") "); } diff --git a/src/glsl/lower_mat_op_to_vec.cpp b/src/glsl/lower_mat_op_to_vec.cpp index 4965df8..7065fde 100644 --- a/src/glsl/lower_mat_op_to_vec.cpp +++ b/src/glsl/lower_mat_op_to_vec.cpp @@ -366,6 +366,8 @@ ir_mat_op_to_vec_visitor::visit_leave(ir_assignment *orig_assign) if (!has_matrix_operand(orig_expr, matrix_columns)) return visit_continue; + assert(orig_expr->get_num_operands() <= 2); + mem_ctx = talloc_parent(orig_assign); ir_dereference_variable *lhs_deref = diff --git a/src/glsl/opt_algebraic.cpp b/src/glsl/opt_algebraic.cpp index 88b6c48..9a8080b 100644 --- a/src/glsl/opt_algebraic.cpp +++ b/src/glsl/opt_algebraic.cpp @@ -181,6 +181,7 @@ ir_algebraic_visitor::handle_expression(ir_expression *ir) ir_expression *temp; unsigned int i; + assert(ir->get_num_operands() <= 2); for (i = 0; i < ir->get_num_operands(); i++) { if (ir->operands[i]->type->is_matrix()) return ir; diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp b/src/mesa/drivers/dri/i965/brw_fs.cpp index 164f89e..105327c 100644 --- a/src/mesa/drivers/dri/i965/brw_fs.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs.cpp @@ -708,6 +708,7 @@ fs_visitor::visit(ir_expression *ir) fs_reg op[2], temp; fs_inst *inst; + assert(ir->get_num_operands() <= 2); for (operand = 0; operand < ir->get_num_operands(); operand++) { ir->operands[operand]->accept(this); if (this->result.file == BAD_FILE) { @@ -1387,6 +1388,7 @@ fs_visitor::emit_bool_to_cond_code(ir_rvalue *ir) fs_reg op[2]; fs_inst *inst; + assert(expr->get_num_operands() <= 2); for (unsigned int i = 0; i < expr->get_num_operands(); i++) { assert(expr->operands[i]->type->is_scalar()); @@ -1494,6 +1496,7 @@ fs_visitor::emit_if_gen6(ir_if *ir) fs_inst *inst; fs_reg temp; + assert(expr->get_num_operands() <= 2); for (unsigned int i = 0; i < expr->get_num_operands(); i++) { assert(expr->operands[i]->type->is_scalar()); diff --git a/src/mesa/program/ir_to_mesa.cpp b/src/mesa/program/ir_to_mesa.cpp index ef9f692..1b5337e 100644 --- a/src/mesa/program/ir_to_mesa.cpp +++ b/src/mesa/program/ir_to_mesa.cpp @@ -961,7 +961,7 @@ void ir_to_mesa_visitor::visit(ir_expression *ir) { unsigned int operand; - struct ir_to_mesa_src_reg op[2]; + struct ir_to_mesa_src_reg op[Elements(ir->operands)]; struct ir_to_mesa_src_reg result_src; struct ir_to_mesa_dst_reg result_dst; |