On Mon, Jun 8, 2020 at 11:50 PM Zebediah Figura z.figura12@gmail.com wrote:
if ($2->type == HLSL_CLASS_MATRIX)FIXME("Matrix constructors are not supported yet.\n");sprintf(name, "<constructor-%x>", counter++);if (!(var = new_synthetic_var(name, $2, get_location(&@2))))YYABORT;for (i = 0; i < $4.args_count; ++i){struct hlsl_ir_node *arg = $4.args[i];unsigned int width;if (arg->data_type->type == HLSL_CLASS_OBJECT){hlsl_report_message(arg->loc, HLSL_LEVEL_ERROR,"invalid constructor argument");continue;}width = components_count_type(arg->data_type);if (width > 4){FIXME("Constructor argument with %u components.\n", width);continue;}if (!(arg = implicit_conversion(arg,hlsl_ctx.builtin_types.vector[$2->base_type][width - 1], &arg->loc)))continue;if (!(assignment = new_assignment(var, NULL, arg,((1 << width) - 1) << writemask_offset, arg->loc)))YYABORT;writemask_offset += width;list_add_tail($4.instrs, &assignment->node.entry);
I'm still not sold on doing it like this. This generates nice code for vector constructors but it seems hard to extend to matrices in the future.
I'd do it component-by-component, generating swizzles as necessary. Any tidy up can be done by following passes, or not at all.