vkd3d-shader: Rename HLSL_IR_ASSIGNMENT to HLSL_IR_STORE.

Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Matteo Bruni <mbruni@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Zebediah Figura 2021-04-08 23:38:22 -05:00 committed by Alexandre Julliard
parent 3d22df25fe
commit 027f994fe0
4 changed files with 103 additions and 104 deletions

View File

@ -418,28 +418,28 @@ static bool type_is_single_reg(const struct hlsl_type *type)
return type->type == HLSL_CLASS_SCALAR || type->type == HLSL_CLASS_VECTOR; return type->type == HLSL_CLASS_SCALAR || type->type == HLSL_CLASS_VECTOR;
} }
struct hlsl_ir_assignment *hlsl_new_assignment(struct hlsl_ir_var *var, struct hlsl_ir_node *offset, struct hlsl_ir_store *hlsl_new_store(struct hlsl_ir_var *var, struct hlsl_ir_node *offset,
struct hlsl_ir_node *rhs, unsigned int writemask, struct vkd3d_shader_location loc) struct hlsl_ir_node *rhs, unsigned int writemask, struct vkd3d_shader_location loc)
{ {
struct hlsl_ir_assignment *assign; struct hlsl_ir_store *store;
if (!writemask && type_is_single_reg(rhs->data_type)) if (!writemask && type_is_single_reg(rhs->data_type))
writemask = (1 << rhs->data_type->dimx) - 1; writemask = (1 << rhs->data_type->dimx) - 1;
if (!(assign = vkd3d_malloc(sizeof(*assign)))) if (!(store = vkd3d_malloc(sizeof(*store))))
return NULL; return NULL;
init_node(&assign->node, HLSL_IR_ASSIGNMENT, NULL, loc); init_node(&store->node, HLSL_IR_STORE, NULL, loc);
assign->lhs.var = var; store->lhs.var = var;
hlsl_src_from_node(&assign->lhs.offset, offset); hlsl_src_from_node(&store->lhs.offset, offset);
hlsl_src_from_node(&assign->rhs, rhs); hlsl_src_from_node(&store->rhs, rhs);
assign->writemask = writemask; store->writemask = writemask;
return assign; return store;
} }
struct hlsl_ir_assignment *hlsl_new_simple_assignment(struct hlsl_ir_var *lhs, struct hlsl_ir_node *rhs) struct hlsl_ir_store *hlsl_new_simple_store(struct hlsl_ir_var *lhs, struct hlsl_ir_node *rhs)
{ {
return hlsl_new_assignment(lhs, NULL, rhs, 0, rhs->loc); return hlsl_new_store(lhs, NULL, rhs, 0, rhs->loc);
} }
struct hlsl_ir_constant *hlsl_new_uint_constant(struct hlsl_ctx *ctx, unsigned int n, struct hlsl_ir_constant *hlsl_new_uint_constant(struct hlsl_ctx *ctx, unsigned int n,
@ -830,13 +830,13 @@ const char *hlsl_node_type_to_string(enum hlsl_ir_node_type type)
{ {
static const char * const names[] = static const char * const names[] =
{ {
"HLSL_IR_ASSIGNMENT",
"HLSL_IR_CONSTANT", "HLSL_IR_CONSTANT",
"HLSL_IR_EXPR", "HLSL_IR_EXPR",
"HLSL_IR_IF", "HLSL_IR_IF",
"HLSL_IR_LOAD", "HLSL_IR_LOAD",
"HLSL_IR_LOOP", "HLSL_IR_LOOP",
"HLSL_IR_JUMP", "HLSL_IR_JUMP",
"HLSL_IR_STORE",
"HLSL_IR_SWIZZLE", "HLSL_IR_SWIZZLE",
}; };
@ -909,17 +909,6 @@ static const char *debug_writemask(DWORD writemask)
return vkd3d_dbg_sprintf(".%s", string); return vkd3d_dbg_sprintf(".%s", string);
} }
static void dump_ir_assignment(struct vkd3d_string_buffer *buffer, const struct hlsl_ir_assignment *assign)
{
vkd3d_string_buffer_printf(buffer, "= (");
dump_deref(buffer, &assign->lhs);
if (assign->writemask != VKD3DSP_WRITEMASK_ALL)
vkd3d_string_buffer_printf(buffer, "%s", debug_writemask(assign->writemask));
vkd3d_string_buffer_printf(buffer, " ");
dump_src(buffer, &assign->rhs);
vkd3d_string_buffer_printf(buffer, ")");
}
static void dump_ir_constant(struct vkd3d_string_buffer *buffer, const struct hlsl_ir_constant *constant) static void dump_ir_constant(struct vkd3d_string_buffer *buffer, const struct hlsl_ir_constant *constant)
{ {
struct hlsl_type *type = constant->node.data_type; struct hlsl_type *type = constant->node.data_type;
@ -1080,6 +1069,17 @@ static void dump_ir_loop(struct vkd3d_string_buffer *buffer, const struct hlsl_i
vkd3d_string_buffer_printf(buffer, "}\n"); vkd3d_string_buffer_printf(buffer, "}\n");
} }
static void dump_ir_store(struct vkd3d_string_buffer *buffer, const struct hlsl_ir_store *store)
{
vkd3d_string_buffer_printf(buffer, "= (");
dump_deref(buffer, &store->lhs);
if (store->writemask != VKD3DSP_WRITEMASK_ALL)
vkd3d_string_buffer_printf(buffer, "%s", debug_writemask(store->writemask));
vkd3d_string_buffer_printf(buffer, " ");
dump_src(buffer, &store->rhs);
vkd3d_string_buffer_printf(buffer, ")");
}
static void dump_ir_swizzle(struct vkd3d_string_buffer *buffer, const struct hlsl_ir_swizzle *swizzle) static void dump_ir_swizzle(struct vkd3d_string_buffer *buffer, const struct hlsl_ir_swizzle *swizzle)
{ {
unsigned int i; unsigned int i;
@ -1111,10 +1111,6 @@ static void dump_instr(struct vkd3d_string_buffer *buffer, const struct hlsl_ir_
switch (instr->type) switch (instr->type)
{ {
case HLSL_IR_ASSIGNMENT:
dump_ir_assignment(buffer, hlsl_ir_assignment(instr));
break;
case HLSL_IR_CONSTANT: case HLSL_IR_CONSTANT:
dump_ir_constant(buffer, hlsl_ir_constant(instr)); dump_ir_constant(buffer, hlsl_ir_constant(instr));
break; break;
@ -1139,6 +1135,10 @@ static void dump_instr(struct vkd3d_string_buffer *buffer, const struct hlsl_ir_
dump_ir_loop(buffer, hlsl_ir_loop(instr)); dump_ir_loop(buffer, hlsl_ir_loop(instr));
break; break;
case HLSL_IR_STORE:
dump_ir_store(buffer, hlsl_ir_store(instr));
break;
case HLSL_IR_SWIZZLE: case HLSL_IR_SWIZZLE:
dump_ir_swizzle(buffer, hlsl_ir_swizzle(instr)); dump_ir_swizzle(buffer, hlsl_ir_swizzle(instr));
break; break;
@ -1198,13 +1198,6 @@ void hlsl_free_instr_list(struct list *list)
vkd3d_free(list); vkd3d_free(list);
} }
static void free_ir_assignment(struct hlsl_ir_assignment *assignment)
{
hlsl_src_remove(&assignment->rhs);
hlsl_src_remove(&assignment->lhs.offset);
vkd3d_free(assignment);
}
static void free_ir_constant(struct hlsl_ir_constant *constant) static void free_ir_constant(struct hlsl_ir_constant *constant)
{ {
vkd3d_free(constant); vkd3d_free(constant);
@ -1251,6 +1244,13 @@ static void free_ir_loop(struct hlsl_ir_loop *loop)
vkd3d_free(loop); vkd3d_free(loop);
} }
static void free_ir_store(struct hlsl_ir_store *store)
{
hlsl_src_remove(&store->rhs);
hlsl_src_remove(&store->lhs.offset);
vkd3d_free(store);
}
static void free_ir_swizzle(struct hlsl_ir_swizzle *swizzle) static void free_ir_swizzle(struct hlsl_ir_swizzle *swizzle)
{ {
hlsl_src_remove(&swizzle->val); hlsl_src_remove(&swizzle->val);
@ -1261,10 +1261,6 @@ void hlsl_free_instr(struct hlsl_ir_node *node)
{ {
switch (node->type) switch (node->type)
{ {
case HLSL_IR_ASSIGNMENT:
free_ir_assignment(hlsl_ir_assignment(node));
break;
case HLSL_IR_CONSTANT: case HLSL_IR_CONSTANT:
free_ir_constant(hlsl_ir_constant(node)); free_ir_constant(hlsl_ir_constant(node));
break; break;
@ -1289,6 +1285,10 @@ void hlsl_free_instr(struct hlsl_ir_node *node)
free_ir_loop(hlsl_ir_loop(node)); free_ir_loop(hlsl_ir_loop(node));
break; break;
case HLSL_IR_STORE:
free_ir_store(hlsl_ir_store(node));
break;
case HLSL_IR_SWIZZLE: case HLSL_IR_SWIZZLE:
free_ir_swizzle(hlsl_ir_swizzle(node)); free_ir_swizzle(hlsl_ir_swizzle(node));
break; break;

View File

@ -139,13 +139,13 @@ struct hlsl_struct_field
enum hlsl_ir_node_type enum hlsl_ir_node_type
{ {
HLSL_IR_ASSIGNMENT = 0,
HLSL_IR_CONSTANT, HLSL_IR_CONSTANT,
HLSL_IR_EXPR, HLSL_IR_EXPR,
HLSL_IR_IF, HLSL_IR_IF,
HLSL_IR_LOAD, HLSL_IR_LOAD,
HLSL_IR_LOOP, HLSL_IR_LOOP,
HLSL_IR_JUMP, HLSL_IR_JUMP,
HLSL_IR_STORE,
HLSL_IR_SWIZZLE, HLSL_IR_SWIZZLE,
}; };
@ -352,7 +352,7 @@ struct hlsl_ir_load
struct hlsl_deref src; struct hlsl_deref src;
}; };
struct hlsl_ir_assignment struct hlsl_ir_store
{ {
struct hlsl_ir_node node; struct hlsl_ir_node node;
struct hlsl_deref lhs; struct hlsl_deref lhs;
@ -420,12 +420,6 @@ enum hlsl_error_level
HLSL_LEVEL_NOTE, HLSL_LEVEL_NOTE,
}; };
static inline struct hlsl_ir_assignment *hlsl_ir_assignment(const struct hlsl_ir_node *node)
{
assert(node->type == HLSL_IR_ASSIGNMENT);
return CONTAINING_RECORD(node, struct hlsl_ir_assignment, node);
}
static inline struct hlsl_ir_constant *hlsl_ir_constant(const struct hlsl_ir_node *node) static inline struct hlsl_ir_constant *hlsl_ir_constant(const struct hlsl_ir_node *node)
{ {
assert(node->type == HLSL_IR_CONSTANT); assert(node->type == HLSL_IR_CONSTANT);
@ -462,6 +456,12 @@ static inline struct hlsl_ir_loop *hlsl_ir_loop(const struct hlsl_ir_node *node)
return CONTAINING_RECORD(node, struct hlsl_ir_loop, node); return CONTAINING_RECORD(node, struct hlsl_ir_loop, node);
} }
static inline struct hlsl_ir_store *hlsl_ir_store(const struct hlsl_ir_node *node)
{
assert(node->type == HLSL_IR_STORE);
return CONTAINING_RECORD(node, struct hlsl_ir_store, node);
}
static inline struct hlsl_ir_swizzle *hlsl_ir_swizzle(const struct hlsl_ir_node *node) static inline struct hlsl_ir_swizzle *hlsl_ir_swizzle(const struct hlsl_ir_node *node)
{ {
assert(node->type == HLSL_IR_SWIZZLE); assert(node->type == HLSL_IR_SWIZZLE);
@ -520,8 +520,6 @@ struct hlsl_ir_var *hlsl_get_var(struct hlsl_scope *scope, const char *name) DEC
struct hlsl_type *hlsl_new_array_type(struct hlsl_ctx *ctx, struct hlsl_type *basic_type, struct hlsl_type *hlsl_new_array_type(struct hlsl_ctx *ctx, struct hlsl_type *basic_type,
unsigned int array_size) DECLSPEC_HIDDEN; unsigned int array_size) DECLSPEC_HIDDEN;
struct hlsl_ir_assignment *hlsl_new_assignment(struct hlsl_ir_var *var, struct hlsl_ir_node *offset,
struct hlsl_ir_node *rhs, unsigned int writemask, struct vkd3d_shader_location loc) DECLSPEC_HIDDEN;
struct hlsl_ir_node *hlsl_new_binary_expr(enum hlsl_ir_expr_op op, struct hlsl_ir_node *arg1, struct hlsl_ir_node *hlsl_new_binary_expr(enum hlsl_ir_expr_op op, struct hlsl_ir_node *arg1,
struct hlsl_ir_node *arg2) DECLSPEC_HIDDEN; struct hlsl_ir_node *arg2) DECLSPEC_HIDDEN;
struct hlsl_ir_expr *hlsl_new_cast(struct hlsl_ir_node *node, struct hlsl_type *type, struct hlsl_ir_expr *hlsl_new_cast(struct hlsl_ir_node *node, struct hlsl_type *type,
@ -534,8 +532,10 @@ struct hlsl_ir_jump *hlsl_new_jump(enum hlsl_ir_jump_type type, struct vkd3d_sha
struct hlsl_ir_load *hlsl_new_load(struct hlsl_ir_var *var, struct hlsl_ir_node *offset, struct hlsl_type *type, struct hlsl_ir_load *hlsl_new_load(struct hlsl_ir_var *var, struct hlsl_ir_node *offset, struct hlsl_type *type,
struct vkd3d_shader_location loc) DECLSPEC_HIDDEN; struct vkd3d_shader_location loc) DECLSPEC_HIDDEN;
struct hlsl_ir_loop *hlsl_new_loop(struct vkd3d_shader_location loc) DECLSPEC_HIDDEN; struct hlsl_ir_loop *hlsl_new_loop(struct vkd3d_shader_location loc) DECLSPEC_HIDDEN;
struct hlsl_ir_assignment *hlsl_new_simple_assignment(struct hlsl_ir_var *lhs, struct hlsl_ir_store *hlsl_new_simple_store(struct hlsl_ir_var *lhs,
struct hlsl_ir_node *rhs) DECLSPEC_HIDDEN; struct hlsl_ir_node *rhs) DECLSPEC_HIDDEN;
struct hlsl_ir_store *hlsl_new_store(struct hlsl_ir_var *var, struct hlsl_ir_node *offset,
struct hlsl_ir_node *rhs, unsigned int writemask, struct vkd3d_shader_location loc) DECLSPEC_HIDDEN;
struct hlsl_type *hlsl_new_struct_type(struct hlsl_ctx *ctx, const char *name, struct list *fields) DECLSPEC_HIDDEN; struct hlsl_type *hlsl_new_struct_type(struct hlsl_ctx *ctx, const char *name, struct list *fields) DECLSPEC_HIDDEN;
struct hlsl_ir_swizzle *hlsl_new_swizzle(struct hlsl_ctx *ctx, DWORD s, unsigned int components, struct hlsl_ir_swizzle *hlsl_new_swizzle(struct hlsl_ctx *ctx, DWORD s, unsigned int components,
struct hlsl_ir_node *val, struct vkd3d_shader_location *loc) DECLSPEC_HIDDEN; struct hlsl_ir_node *val, struct vkd3d_shader_location *loc) DECLSPEC_HIDDEN;

View File

@ -499,14 +499,14 @@ static struct hlsl_ir_jump *add_return(struct hlsl_ctx *ctx, struct list *instrs
if (return_value) if (return_value)
{ {
struct hlsl_ir_assignment *assignment; struct hlsl_ir_store *store;
if (!(return_value = add_implicit_conversion(ctx, instrs, return_value, return_type, &loc))) if (!(return_value = add_implicit_conversion(ctx, instrs, return_value, return_type, &loc)))
return NULL; return NULL;
if (!(assignment = hlsl_new_simple_assignment(ctx->cur_function->return_var, return_value))) if (!(store = hlsl_new_simple_store(ctx->cur_function->return_var, return_value)))
return NULL; return NULL;
list_add_after(&return_value->entry, &assignment->node.entry); list_add_after(&return_value->entry, &store->node.entry);
} }
else if (!hlsl_type_is_void(return_type)) else if (!hlsl_type_is_void(return_type))
{ {
@ -543,17 +543,17 @@ static struct hlsl_ir_load *add_load(struct hlsl_ctx *ctx, struct list *instrs,
} }
else else
{ {
struct hlsl_ir_assignment *assign; struct hlsl_ir_store *store;
char name[27]; char name[27];
sprintf(name, "<deref-%p>", var_node); sprintf(name, "<deref-%p>", var_node);
if (!(var = hlsl_new_synthetic_var(ctx, name, var_node->data_type, var_node->loc))) if (!(var = hlsl_new_synthetic_var(ctx, name, var_node->data_type, var_node->loc)))
return NULL; return NULL;
if (!(assign = hlsl_new_simple_assignment(var, var_node))) if (!(store = hlsl_new_simple_store(var, var_node)))
return NULL; return NULL;
list_add_tail(instrs, &assign->node.entry); list_add_tail(instrs, &store->node.entry);
} }
if (!(load = hlsl_new_load(var, offset, data_type, loc))) if (!(load = hlsl_new_load(var, offset, data_type, loc)))
@ -900,7 +900,7 @@ static unsigned int evaluate_array_dimension(struct hlsl_ir_node *node)
FIXME("Unhandled type %s.\n", hlsl_node_type_to_string(node->type)); FIXME("Unhandled type %s.\n", hlsl_node_type_to_string(node->type));
return 0; return 0;
case HLSL_IR_ASSIGNMENT: case HLSL_IR_STORE:
default: default:
WARN("Invalid node type %s.\n", hlsl_node_type_to_string(node->type)); WARN("Invalid node type %s.\n", hlsl_node_type_to_string(node->type));
return 0; return 0;
@ -1216,7 +1216,7 @@ static struct hlsl_ir_node *add_assignment(struct hlsl_ctx *ctx, struct list *in
enum parse_assign_op assign_op, struct hlsl_ir_node *rhs) enum parse_assign_op assign_op, struct hlsl_ir_node *rhs)
{ {
struct hlsl_type *lhs_type = lhs->data_type; struct hlsl_type *lhs_type = lhs->data_type;
struct hlsl_ir_assignment *assign; struct hlsl_ir_store *store;
struct hlsl_ir_expr *copy; struct hlsl_ir_expr *copy;
DWORD writemask = 0; DWORD writemask = 0;
@ -1239,7 +1239,7 @@ static struct hlsl_ir_node *add_assignment(struct hlsl_ctx *ctx, struct list *in
return NULL; return NULL;
} }
if (!(assign = vkd3d_malloc(sizeof(*assign)))) if (!(store = vkd3d_malloc(sizeof(*store))))
return NULL; return NULL;
while (lhs->type != HLSL_IR_LOAD) while (lhs->type != HLSL_IR_LOAD)
@ -1247,7 +1247,7 @@ static struct hlsl_ir_node *add_assignment(struct hlsl_ctx *ctx, struct list *in
if (lhs->type == HLSL_IR_EXPR && hlsl_ir_expr(lhs)->op == HLSL_IR_UNOP_CAST) if (lhs->type == HLSL_IR_EXPR && hlsl_ir_expr(lhs)->op == HLSL_IR_UNOP_CAST)
{ {
FIXME("Cast on the lhs.\n"); FIXME("Cast on the lhs.\n");
vkd3d_free(assign); vkd3d_free(store);
return NULL; return NULL;
} }
else if (lhs->type == HLSL_IR_SWIZZLE) else if (lhs->type == HLSL_IR_SWIZZLE)
@ -1261,13 +1261,13 @@ static struct hlsl_ir_node *add_assignment(struct hlsl_ctx *ctx, struct list *in
if (!invert_swizzle(&s, &writemask, &width)) if (!invert_swizzle(&s, &writemask, &width))
{ {
hlsl_error(ctx, lhs->loc, VKD3D_SHADER_ERROR_HLSL_INVALID_WRITEMASK, "Invalid writemask."); hlsl_error(ctx, lhs->loc, VKD3D_SHADER_ERROR_HLSL_INVALID_WRITEMASK, "Invalid writemask.");
vkd3d_free(assign); vkd3d_free(store);
return NULL; return NULL;
} }
if (!(new_swizzle = hlsl_new_swizzle(ctx, s, width, rhs, &swizzle->node.loc))) if (!(new_swizzle = hlsl_new_swizzle(ctx, s, width, rhs, &swizzle->node.loc)))
{ {
vkd3d_free(assign); vkd3d_free(store);
return NULL; return NULL;
} }
list_add_tail(instrs, &new_swizzle->node.entry); list_add_tail(instrs, &new_swizzle->node.entry);
@ -1278,17 +1278,17 @@ static struct hlsl_ir_node *add_assignment(struct hlsl_ctx *ctx, struct list *in
else else
{ {
hlsl_error(ctx, lhs->loc, VKD3D_SHADER_ERROR_HLSL_INVALID_LVALUE, "Invalid lvalue."); hlsl_error(ctx, lhs->loc, VKD3D_SHADER_ERROR_HLSL_INVALID_LVALUE, "Invalid lvalue.");
vkd3d_free(assign); vkd3d_free(store);
return NULL; return NULL;
} }
} }
init_node(&assign->node, HLSL_IR_ASSIGNMENT, NULL, lhs->loc); init_node(&store->node, HLSL_IR_STORE, NULL, lhs->loc);
assign->writemask = writemask; store->writemask = writemask;
assign->lhs.var = hlsl_ir_load(lhs)->src.var; store->lhs.var = hlsl_ir_load(lhs)->src.var;
hlsl_src_from_node(&assign->lhs.offset, hlsl_ir_load(lhs)->src.offset.node); hlsl_src_from_node(&store->lhs.offset, hlsl_ir_load(lhs)->src.offset.node);
hlsl_src_from_node(&assign->rhs, rhs); hlsl_src_from_node(&store->rhs, rhs);
list_add_tail(instrs, &assign->node.entry); list_add_tail(instrs, &store->node.entry);
/* Don't use the instruction itself as a source, as this makes structure /* Don't use the instruction itself as a source, as this makes structure
* splitting easier. Instead copy it here. Since we retrieve sources from * splitting easier. Instead copy it here. Since we retrieve sources from
@ -1355,7 +1355,7 @@ static void struct_var_initializer(struct hlsl_ctx *ctx, struct list *list, stru
LIST_FOR_EACH_ENTRY(field, type->e.elements, struct hlsl_struct_field, entry) LIST_FOR_EACH_ENTRY(field, type->e.elements, struct hlsl_struct_field, entry)
{ {
struct hlsl_ir_node *node = initializer->args[i]; struct hlsl_ir_node *node = initializer->args[i];
struct hlsl_ir_assignment *assign; struct hlsl_ir_store *store;
struct hlsl_ir_constant *c; struct hlsl_ir_constant *c;
if (i++ >= initializer->args_count) if (i++ >= initializer->args_count)
@ -1367,9 +1367,9 @@ static void struct_var_initializer(struct hlsl_ctx *ctx, struct list *list, stru
break; break;
list_add_tail(list, &c->node.entry); list_add_tail(list, &c->node.entry);
if (!(assign = hlsl_new_assignment(var, &c->node, node, 0, node->loc))) if (!(store = hlsl_new_store(var, &c->node, node, 0, node->loc)))
break; break;
list_add_tail(list, &assign->node.entry); list_add_tail(list, &store->node.entry);
} }
else else
FIXME("Initializing with \"mismatched\" fields is not supported yet.\n"); FIXME("Initializing with \"mismatched\" fields is not supported yet.\n");
@ -2724,8 +2724,8 @@ postfix_expr:
/* var_modifiers is necessary to avoid shift/reduce conflicts. */ /* var_modifiers is necessary to avoid shift/reduce conflicts. */
| var_modifiers type '(' initializer_expr_list ')' | var_modifiers type '(' initializer_expr_list ')'
{ {
struct hlsl_ir_assignment *assignment;
unsigned int i, writemask_offset = 0; unsigned int i, writemask_offset = 0;
struct hlsl_ir_store *store;
static unsigned int counter; static unsigned int counter;
struct hlsl_ir_load *load; struct hlsl_ir_load *load;
struct hlsl_ir_var *var; struct hlsl_ir_var *var;
@ -2788,11 +2788,11 @@ postfix_expr:
ctx->builtin_types.vector[$2->base_type][width - 1], &arg->loc))) ctx->builtin_types.vector[$2->base_type][width - 1], &arg->loc)))
continue; continue;
if (!(assignment = hlsl_new_assignment(var, NULL, arg, if (!(store = hlsl_new_store(var, NULL, arg,
((1 << width) - 1) << writemask_offset, arg->loc))) ((1 << width) - 1) << writemask_offset, arg->loc)))
YYABORT; YYABORT;
writemask_offset += width; writemask_offset += width;
list_add_tail($4.instrs, &assignment->node.entry); list_add_tail($4.instrs, &store->node.entry);
} }
vkd3d_free($4.args); vkd3d_free($4.args);
if (!(load = hlsl_new_var_load(var, @2))) if (!(load = hlsl_new_var_load(var, @2)))

View File

@ -27,8 +27,8 @@
static void prepend_uniform_copy(struct hlsl_ctx *ctx, struct list *instrs, struct hlsl_ir_var *var) static void prepend_uniform_copy(struct hlsl_ctx *ctx, struct list *instrs, struct hlsl_ir_var *var)
{ {
struct vkd3d_string_buffer *name; struct vkd3d_string_buffer *name;
struct hlsl_ir_assignment *store;
struct hlsl_ir_var *const_var; struct hlsl_ir_var *const_var;
struct hlsl_ir_store *store;
struct hlsl_ir_load *load; struct hlsl_ir_load *load;
if (!(name = vkd3d_string_buffer_get(&ctx->string_buffers))) if (!(name = vkd3d_string_buffer_get(&ctx->string_buffers)))
@ -55,7 +55,7 @@ static void prepend_uniform_copy(struct hlsl_ctx *ctx, struct list *instrs, stru
} }
list_add_head(instrs, &load->node.entry); list_add_head(instrs, &load->node.entry);
if (!(store = hlsl_new_simple_assignment(var, &load->node))) if (!(store = hlsl_new_simple_store(var, &load->node)))
{ {
ctx->failed = true; ctx->failed = true;
return; return;
@ -67,8 +67,8 @@ static void prepend_input_copy(struct hlsl_ctx *ctx, struct list *instrs, struct
struct hlsl_type *type, unsigned int field_offset, const char *semantic) struct hlsl_type *type, unsigned int field_offset, const char *semantic)
{ {
struct vkd3d_string_buffer *name; struct vkd3d_string_buffer *name;
struct hlsl_ir_assignment *store;
struct hlsl_ir_constant *offset; struct hlsl_ir_constant *offset;
struct hlsl_ir_store *store;
struct hlsl_ir_var *varying; struct hlsl_ir_var *varying;
struct hlsl_ir_load *load; struct hlsl_ir_load *load;
@ -102,7 +102,7 @@ static void prepend_input_copy(struct hlsl_ctx *ctx, struct list *instrs, struct
} }
list_add_after(&load->node.entry, &offset->node.entry); list_add_after(&load->node.entry, &offset->node.entry);
if (!(store = hlsl_new_assignment(var, &offset->node, &load->node, 0, var->loc))) if (!(store = hlsl_new_store(var, &offset->node, &load->node, 0, var->loc)))
{ {
ctx->failed = true; ctx->failed = true;
return; return;
@ -144,8 +144,8 @@ static void append_output_copy(struct hlsl_ctx *ctx, struct list *instrs, struct
struct hlsl_type *type, unsigned int field_offset, const char *semantic) struct hlsl_type *type, unsigned int field_offset, const char *semantic)
{ {
struct vkd3d_string_buffer *name; struct vkd3d_string_buffer *name;
struct hlsl_ir_assignment *store;
struct hlsl_ir_constant *offset; struct hlsl_ir_constant *offset;
struct hlsl_ir_store *store;
struct hlsl_ir_var *varying; struct hlsl_ir_var *varying;
struct hlsl_ir_load *load; struct hlsl_ir_load *load;
@ -179,7 +179,7 @@ static void append_output_copy(struct hlsl_ctx *ctx, struct list *instrs, struct
} }
list_add_after(&offset->node.entry, &load->node.entry); list_add_after(&offset->node.entry, &load->node.entry);
if (!(store = hlsl_new_assignment(varying, NULL, &load->node, 0, var->loc))) if (!(store = hlsl_new_store(varying, NULL, &load->node, 0, var->loc)))
{ {
ctx->failed = true; ctx->failed = true;
return; return;
@ -285,15 +285,15 @@ static bool split_struct_copies(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr
{ {
const struct hlsl_struct_field *field; const struct hlsl_struct_field *field;
const struct hlsl_ir_load *rhs_load; const struct hlsl_ir_load *rhs_load;
struct hlsl_ir_assignment *assign;
const struct hlsl_ir_node *rhs; const struct hlsl_ir_node *rhs;
const struct hlsl_type *type; const struct hlsl_type *type;
struct hlsl_ir_store *store;
if (instr->type != HLSL_IR_ASSIGNMENT) if (instr->type != HLSL_IR_STORE)
return false; return false;
assign = hlsl_ir_assignment(instr); store = hlsl_ir_store(instr);
rhs = assign->rhs.node; rhs = store->rhs.node;
type = rhs->data_type; type = rhs->data_type;
if (type->type != HLSL_CLASS_STRUCT) if (type->type != HLSL_CLASS_STRUCT)
return false; return false;
@ -302,8 +302,8 @@ static bool split_struct_copies(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr
LIST_FOR_EACH_ENTRY(field, type->e.elements, struct hlsl_struct_field, entry) LIST_FOR_EACH_ENTRY(field, type->e.elements, struct hlsl_struct_field, entry)
{ {
struct hlsl_ir_store *field_store;
struct hlsl_ir_node *offset, *add; struct hlsl_ir_node *offset, *add;
struct hlsl_ir_assignment *store;
struct hlsl_ir_load *field_load; struct hlsl_ir_load *field_load;
struct hlsl_ir_constant *c; struct hlsl_ir_constant *c;
@ -333,9 +333,9 @@ static bool split_struct_copies(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr
list_add_before(&instr->entry, &field_load->node.entry); list_add_before(&instr->entry, &field_load->node.entry);
offset = &c->node; offset = &c->node;
if (assign->lhs.offset.node) if (store->lhs.offset.node)
{ {
if (!(add = hlsl_new_binary_expr(HLSL_IR_BINOP_ADD, assign->lhs.offset.node, &c->node))) if (!(add = hlsl_new_binary_expr(HLSL_IR_BINOP_ADD, store->lhs.offset.node, &c->node)))
{ {
ctx->failed = true; ctx->failed = true;
return false; return false;
@ -344,20 +344,19 @@ static bool split_struct_copies(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr
offset = add; offset = add;
} }
if (!(store = hlsl_new_assignment(assign->lhs.var, offset, &field_load->node, 0, instr->loc))) if (!(field_store = hlsl_new_store(store->lhs.var, offset, &field_load->node, 0, instr->loc)))
{ {
ctx->failed = true; ctx->failed = true;
return false; return false;
} }
list_add_before(&instr->entry, &store->node.entry); list_add_before(&instr->entry, &field_store->node.entry);
} }
/* Remove the assignment instruction, so that we can split structs /* Remove the store instruction, so that we can split structs which contain
* which contain other structs. Although assignment instructions * other structs. Although assignments produce a value, we don't allow
* produce a value, we don't allow HLSL_IR_ASSIGNMENT to be used as * HLSL_IR_STORE to be used as a source. */
* a source. */ list_remove(&store->node.entry);
list_remove(&assign->node.entry); hlsl_free_instr(&store->node);
hlsl_free_instr(&assign->node);
return true; return true;
} }
@ -440,10 +439,10 @@ static bool dce(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr, void *context)
} }
break; break;
case HLSL_IR_ASSIGNMENT: case HLSL_IR_STORE:
{ {
struct hlsl_ir_assignment *assignment = hlsl_ir_assignment(instr); struct hlsl_ir_store *store = hlsl_ir_store(instr);
struct hlsl_ir_var *var = assignment->lhs.var; struct hlsl_ir_var *var = store->lhs.var;
if (var->last_read < instr->index) if (var->last_read < instr->index)
{ {
@ -517,16 +516,16 @@ static void compute_liveness_recurse(struct list *instrs, unsigned int loop_firs
{ {
switch (instr->type) switch (instr->type)
{ {
case HLSL_IR_ASSIGNMENT: case HLSL_IR_STORE:
{ {
struct hlsl_ir_assignment *assignment = hlsl_ir_assignment(instr); struct hlsl_ir_store *store = hlsl_ir_store(instr);
var = assignment->lhs.var; var = store->lhs.var;
if (!var->first_write) if (!var->first_write)
var->first_write = loop_first ? min(instr->index, loop_first) : instr->index; var->first_write = loop_first ? min(instr->index, loop_first) : instr->index;
assignment->rhs.node->last_read = instr->index; store->rhs.node->last_read = instr->index;
if (assignment->lhs.offset.node) if (store->lhs.offset.node)
assignment->lhs.offset.node->last_read = instr->index; store->lhs.offset.node->last_read = instr->index;
break; break;
} }
case HLSL_IR_EXPR: case HLSL_IR_EXPR: