glsl: Add an ir_expression triop constructor with type inference.
We already have ir_expression constructors for unary and binary operations, which automatically infer the type based on the opcode and operand types. These are convenient and also required for ir_builder support. Signed-off-by: Kenneth Graunke <kenneth@whitecape.org> Reviewed-by: Matt Turner <mattst88@gmail.com> Reviewed-by: Paul Berry <stereotype441@gmail.com>
This commit is contained in:
@@ -413,6 +413,37 @@ ir_expression::ir_expression(int op, ir_rvalue *op0, ir_rvalue *op1)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ir_expression::ir_expression(int op, ir_rvalue *op0, ir_rvalue *op1,
|
||||||
|
ir_rvalue *op2)
|
||||||
|
{
|
||||||
|
this->ir_type = ir_type_expression;
|
||||||
|
|
||||||
|
this->operation = ir_expression_operation(op);
|
||||||
|
this->operands[0] = op0;
|
||||||
|
this->operands[1] = op1;
|
||||||
|
this->operands[2] = op2;
|
||||||
|
this->operands[3] = NULL;
|
||||||
|
|
||||||
|
assert(op > ir_last_binop && op <= ir_last_triop);
|
||||||
|
|
||||||
|
switch (this->operation) {
|
||||||
|
case ir_triop_fma:
|
||||||
|
case ir_triop_lrp:
|
||||||
|
case ir_triop_bitfield_extract:
|
||||||
|
case ir_triop_vector_insert:
|
||||||
|
this->type = op0->type;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case ir_triop_bfi:
|
||||||
|
this->type = op1->type;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
assert(!"not reached: missing automatic type setup for ir_expression");
|
||||||
|
this->type = glsl_type::float_type;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
unsigned int
|
unsigned int
|
||||||
ir_expression::get_num_operands(ir_expression_operation op)
|
ir_expression::get_num_operands(ir_expression_operation op)
|
||||||
{
|
{
|
||||||
|
@@ -1252,6 +1252,11 @@ public:
|
|||||||
*/
|
*/
|
||||||
ir_expression(int op, ir_rvalue *op0, ir_rvalue *op1);
|
ir_expression(int op, ir_rvalue *op0, ir_rvalue *op1);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor for ternary operation expressions
|
||||||
|
*/
|
||||||
|
ir_expression(int op, ir_rvalue *op0, ir_rvalue *op1, ir_rvalue *op2);
|
||||||
|
|
||||||
virtual ir_expression *as_expression()
|
virtual ir_expression *as_expression()
|
||||||
{
|
{
|
||||||
return this;
|
return this;
|
||||||
|
Reference in New Issue
Block a user