summaryrefslogtreecommitdiff
path: root/src/glsl/ir.cpp
diff options
context:
space:
mode:
authorIan Romanick <ian.d.romanick@intel.com>2010-11-16 12:01:42 -0800
committerIan Romanick <ian.d.romanick@intel.com>2010-11-19 15:00:26 -0800
commit11d6f1c69871d0b7edc28f639256460839fccd2d (patch)
treedf65ce56f09c3eaeb78c4e8ba9d509e12f176dfa /src/glsl/ir.cpp
parent13f57d42b6929f50d8ef8b4123f46a61c46fde7b (diff)
glsl: Add ir_quadop_vector expression
The vector operator collects 2, 3, or 4 scalar components into a vector. Doing this has several advantages. First, it will make ud-chain tracking for components of vectors much easier. Second, a later optimization pass could collect scalars into vectors to allow generation of SWZ instructions (or similar as operands to other instructions on R200 and i915). It also enables an easy way to generate IR for SWZ instructions in the ARB_vertex_program assembler.
Diffstat (limited to 'src/glsl/ir.cpp')
-rw-r--r--src/glsl/ir.cpp25
1 files changed, 23 insertions, 2 deletions
diff --git a/src/glsl/ir.cpp b/src/glsl/ir.cpp
index 1f5e2ebdcb..741e3cb177 100644
--- a/src/glsl/ir.cpp
+++ b/src/glsl/ir.cpp
@@ -200,18 +200,35 @@ ir_expression::ir_expression(int op, const struct glsl_type *type,
this->operation = ir_expression_operation(op);
this->operands[0] = op0;
this->operands[1] = NULL;
+ this->operands[2] = NULL;
+ this->operands[3] = NULL;
}
ir_expression::ir_expression(int op, const struct glsl_type *type,
ir_rvalue *op0, ir_rvalue *op1)
{
- assert((op1 == NULL) && (get_num_operands(ir_expression_operation(op)) == 1)
+ assert(((op1 == NULL) && (get_num_operands(ir_expression_operation(op)) == 1))
|| (get_num_operands(ir_expression_operation(op)) == 2));
this->ir_type = ir_type_expression;
this->type = type;
this->operation = ir_expression_operation(op);
this->operands[0] = op0;
this->operands[1] = op1;
+ this->operands[2] = NULL;
+ this->operands[3] = NULL;
+}
+
+ir_expression::ir_expression(int op, const struct glsl_type *type,
+ ir_rvalue *op0, ir_rvalue *op1,
+ ir_rvalue *op2, ir_rvalue *op3)
+{
+ this->ir_type = ir_type_expression;
+ this->type = type;
+ this->operation = ir_expression_operation(op);
+ this->operands[0] = op0;
+ this->operands[1] = op1;
+ this->operands[2] = op2;
+ this->operands[3] = op3;
}
unsigned int
@@ -225,6 +242,9 @@ ir_expression::get_num_operands(ir_expression_operation op)
if (op <= ir_last_binop)
return 2;
+ if (op == ir_quadop_vector)
+ return 4;
+
assert(false);
return 0;
}
@@ -287,12 +307,13 @@ static const char *const operator_strs[] = {
"min",
"max",
"pow",
+ "vector",
};
const char *ir_expression::operator_string(ir_expression_operation op)
{
assert((unsigned int) op < Elements(operator_strs));
- assert(Elements(operator_strs) == (ir_binop_pow + 1));
+ assert(Elements(operator_strs) == (ir_quadop_vector + 1));
return operator_strs[op];
}