glsl: Eliminate assumptions about size of ir_expression::operands
This may grow in the near future.
This commit is contained in:
@@ -22,6 +22,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include "main/compiler.h"
|
||||||
#include "ir.h"
|
#include "ir.h"
|
||||||
#include "glsl_types.h"
|
#include "glsl_types.h"
|
||||||
extern "C" {
|
extern "C" {
|
||||||
@@ -160,7 +161,7 @@ ir_call::clone(void *mem_ctx, struct hash_table *ht) const
|
|||||||
ir_expression *
|
ir_expression *
|
||||||
ir_expression::clone(void *mem_ctx, struct hash_table *ht) const
|
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;
|
unsigned int i;
|
||||||
|
|
||||||
for (i = 0; i < get_num_operands(); i++) {
|
for (i = 0; i < get_num_operands(); i++) {
|
||||||
|
@@ -57,7 +57,7 @@ ir_expression::constant_expression_value()
|
|||||||
if (this->type->is_error())
|
if (this->type->is_error())
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
ir_constant *op[2] = { NULL, NULL };
|
ir_constant *op[Elements(this->operands)] = { NULL, };
|
||||||
ir_constant_data data;
|
ir_constant_data data;
|
||||||
|
|
||||||
memset(&data, 0, sizeof(data));
|
memset(&data, 0, sizeof(data));
|
||||||
|
@@ -182,11 +182,10 @@ void ir_print_visitor::visit(ir_expression *ir)
|
|||||||
|
|
||||||
printf(" %s ", ir->operator_string());
|
printf(" %s ", ir->operator_string());
|
||||||
|
|
||||||
if (ir->operands[0])
|
for (unsigned i = 0; i < ir->get_num_operands(); i++) {
|
||||||
ir->operands[0]->accept(this);
|
ir->operands[i]->accept(this);
|
||||||
|
}
|
||||||
|
|
||||||
if (ir->operands[1])
|
|
||||||
ir->operands[1]->accept(this);
|
|
||||||
printf(") ");
|
printf(") ");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -366,6 +366,8 @@ ir_mat_op_to_vec_visitor::visit_leave(ir_assignment *orig_assign)
|
|||||||
if (!has_matrix_operand(orig_expr, matrix_columns))
|
if (!has_matrix_operand(orig_expr, matrix_columns))
|
||||||
return visit_continue;
|
return visit_continue;
|
||||||
|
|
||||||
|
assert(orig_expr->get_num_operands() <= 2);
|
||||||
|
|
||||||
mem_ctx = talloc_parent(orig_assign);
|
mem_ctx = talloc_parent(orig_assign);
|
||||||
|
|
||||||
ir_dereference_variable *lhs_deref =
|
ir_dereference_variable *lhs_deref =
|
||||||
|
@@ -181,6 +181,7 @@ ir_algebraic_visitor::handle_expression(ir_expression *ir)
|
|||||||
ir_expression *temp;
|
ir_expression *temp;
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
|
||||||
|
assert(ir->get_num_operands() <= 2);
|
||||||
for (i = 0; i < ir->get_num_operands(); i++) {
|
for (i = 0; i < ir->get_num_operands(); i++) {
|
||||||
if (ir->operands[i]->type->is_matrix())
|
if (ir->operands[i]->type->is_matrix())
|
||||||
return ir;
|
return ir;
|
||||||
|
@@ -708,6 +708,7 @@ fs_visitor::visit(ir_expression *ir)
|
|||||||
fs_reg op[2], temp;
|
fs_reg op[2], temp;
|
||||||
fs_inst *inst;
|
fs_inst *inst;
|
||||||
|
|
||||||
|
assert(ir->get_num_operands() <= 2);
|
||||||
for (operand = 0; operand < ir->get_num_operands(); operand++) {
|
for (operand = 0; operand < ir->get_num_operands(); operand++) {
|
||||||
ir->operands[operand]->accept(this);
|
ir->operands[operand]->accept(this);
|
||||||
if (this->result.file == BAD_FILE) {
|
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_reg op[2];
|
||||||
fs_inst *inst;
|
fs_inst *inst;
|
||||||
|
|
||||||
|
assert(expr->get_num_operands() <= 2);
|
||||||
for (unsigned int i = 0; i < expr->get_num_operands(); i++) {
|
for (unsigned int i = 0; i < expr->get_num_operands(); i++) {
|
||||||
assert(expr->operands[i]->type->is_scalar());
|
assert(expr->operands[i]->type->is_scalar());
|
||||||
|
|
||||||
@@ -1494,6 +1496,7 @@ fs_visitor::emit_if_gen6(ir_if *ir)
|
|||||||
fs_inst *inst;
|
fs_inst *inst;
|
||||||
fs_reg temp;
|
fs_reg temp;
|
||||||
|
|
||||||
|
assert(expr->get_num_operands() <= 2);
|
||||||
for (unsigned int i = 0; i < expr->get_num_operands(); i++) {
|
for (unsigned int i = 0; i < expr->get_num_operands(); i++) {
|
||||||
assert(expr->operands[i]->type->is_scalar());
|
assert(expr->operands[i]->type->is_scalar());
|
||||||
|
|
||||||
|
@@ -961,7 +961,7 @@ void
|
|||||||
ir_to_mesa_visitor::visit(ir_expression *ir)
|
ir_to_mesa_visitor::visit(ir_expression *ir)
|
||||||
{
|
{
|
||||||
unsigned int operand;
|
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_src_reg result_src;
|
||||||
struct ir_to_mesa_dst_reg result_dst;
|
struct ir_to_mesa_dst_reg result_dst;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user