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.
This commit is contained in:
@@ -374,6 +374,51 @@ ir_validate::visit_leave(ir_expression *ir)
|
||||
assert(ir->operands[0]->type->is_vector());
|
||||
assert(ir->operands[0]->type == ir->operands[1]->type);
|
||||
break;
|
||||
|
||||
case ir_quadop_vector:
|
||||
/* The vector operator collects some number of scalars and generates a
|
||||
* vector from them.
|
||||
*
|
||||
* - All of the operands must be scalar.
|
||||
* - Number of operands must matche the size of the resulting vector.
|
||||
* - Base type of the operands must match the base type of the result.
|
||||
*/
|
||||
assert(ir->type->is_vector());
|
||||
switch (ir->type->vector_elements) {
|
||||
case 2:
|
||||
assert(ir->operands[0]->type->is_scalar());
|
||||
assert(ir->operands[0]->type->base_type == ir->type->base_type);
|
||||
assert(ir->operands[1]->type->is_scalar());
|
||||
assert(ir->operands[1]->type->base_type == ir->type->base_type);
|
||||
assert(ir->operands[2] == NULL);
|
||||
assert(ir->operands[3] == NULL);
|
||||
break;
|
||||
case 3:
|
||||
assert(ir->operands[0]->type->is_scalar());
|
||||
assert(ir->operands[0]->type->base_type == ir->type->base_type);
|
||||
assert(ir->operands[1]->type->is_scalar());
|
||||
assert(ir->operands[1]->type->base_type == ir->type->base_type);
|
||||
assert(ir->operands[2]->type->is_scalar());
|
||||
assert(ir->operands[2]->type->base_type == ir->type->base_type);
|
||||
assert(ir->operands[3] == NULL);
|
||||
break;
|
||||
case 4:
|
||||
assert(ir->operands[0]->type->is_scalar());
|
||||
assert(ir->operands[0]->type->base_type == ir->type->base_type);
|
||||
assert(ir->operands[1]->type->is_scalar());
|
||||
assert(ir->operands[1]->type->base_type == ir->type->base_type);
|
||||
assert(ir->operands[2]->type->is_scalar());
|
||||
assert(ir->operands[2]->type->base_type == ir->type->base_type);
|
||||
assert(ir->operands[3]->type->is_scalar());
|
||||
assert(ir->operands[3]->type->base_type == ir->type->base_type);
|
||||
break;
|
||||
default:
|
||||
/* The is_vector assertion above should prevent execution from ever
|
||||
* getting here.
|
||||
*/
|
||||
assert(!"Should not get here.");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return visit_continue;
|
||||
|
Reference in New Issue
Block a user