Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- dlls/d3dcompiler_43/d3dcompiler_private.h | 2 ++ dlls/d3dcompiler_43/hlsl.y | 20 +++++++++++++++----- 2 files changed, 17 insertions(+), 5 deletions(-)
diff --git a/dlls/d3dcompiler_43/d3dcompiler_private.h b/dlls/d3dcompiler_43/d3dcompiler_private.h index 9feaee0d8ac..a2d9c04d3bc 100644 --- a/dlls/d3dcompiler_43/d3dcompiler_private.h +++ b/dlls/d3dcompiler_43/d3dcompiler_private.h @@ -979,6 +979,8 @@ struct hlsl_parse_ctx struct hlsl_type *sampler[HLSL_SAMPLER_DIM_MAX + 1]; struct hlsl_type *Void; } builtin_types; + + struct list static_initializers; };
extern struct hlsl_parse_ctx hlsl_ctx DECLSPEC_HIDDEN; diff --git a/dlls/d3dcompiler_43/hlsl.y b/dlls/d3dcompiler_43/hlsl.y index 393f8d52fbd..c9dbdeb8c18 100644 --- a/dlls/d3dcompiler_43/hlsl.y +++ b/dlls/d3dcompiler_43/hlsl.y @@ -888,14 +888,17 @@ static struct list *declare_vars(struct hlsl_type *basic_type, DWORD modifiers, continue; }
- list_move_tail(statements_list, v->initializer.instrs); - d3dcompiler_free(v->initializer.instrs); - load = new_var_load(var, var->loc); - list_add_tail(statements_list, &load->node.entry); + list_add_tail(v->initializer.instrs, &load->node.entry); assignment = make_assignment(&load->node, ASSIGN_OP_ASSIGN, v->initializer.args[0]); d3dcompiler_free(v->initializer.args); - list_add_tail(statements_list, &assignment->entry); + list_add_tail(v->initializer.instrs, &assignment->entry); + + if (modifiers & HLSL_STORAGE_STATIC) + list_move_tail(&hlsl_ctx.static_initializers, v->initializer.instrs); + else + list_move_tail(statements_list, v->initializer.instrs); + d3dcompiler_free(v->initializer.instrs); } d3dcompiler_free(v); } @@ -1514,6 +1517,10 @@ hlsl_prog: /* empty */ | hlsl_prog declaration_statement { TRACE("Declaration statement parsed.\n"); + + if (!list_empty($2)) + FIXME("Uniform initializer.\n"); + free_instr_list($2); } | hlsl_prog preproc_directive { @@ -2961,6 +2968,7 @@ HRESULT parse_hlsl(enum shader_type type, DWORD major, DWORD minor, list_init(&hlsl_ctx.scopes); list_init(&hlsl_ctx.types); init_functions_tree(&hlsl_ctx.functions); + list_init(&hlsl_ctx.static_initializers);
push_scope(&hlsl_ctx); hlsl_ctx.globals = hlsl_ctx.cur_scope; @@ -2984,6 +2992,8 @@ HRESULT parse_hlsl(enum shader_type type, DWORD major, DWORD minor, "entry point "%s" is missing a return value semantic", entry_func->func->name); }
+ list_move_head(entry_func->body, &hlsl_ctx.static_initializers); + /* Index 0 means unused; index 1 means function entry, so start at 2. */ index_instructions(entry_func->body, 2);
Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- dlls/d3dcompiler_43/d3dcompiler_private.h | 5 +-- dlls/d3dcompiler_43/hlsl.y | 37 +++++++++++------------ dlls/d3dcompiler_43/utils.c | 5 +-- 3 files changed, 23 insertions(+), 24 deletions(-)
diff --git a/dlls/d3dcompiler_43/d3dcompiler_private.h b/dlls/d3dcompiler_43/d3dcompiler_private.h index a2d9c04d3bc..e9b7b5ada43 100644 --- a/dlls/d3dcompiler_43/d3dcompiler_private.h +++ b/dlls/d3dcompiler_43/d3dcompiler_private.h @@ -1057,6 +1057,9 @@ static inline void init_node(struct hlsl_ir_node *node, enum hlsl_ir_node_type t node->loc = loc; }
+struct hlsl_ir_node *add_assignment(struct list *instrs, struct hlsl_ir_node *left, + enum parse_assign_op assign_op, struct hlsl_ir_node *right) DECLSPEC_HIDDEN; + BOOL add_declaration(struct hlsl_scope *scope, struct hlsl_ir_var *decl, BOOL local_var) DECLSPEC_HIDDEN; struct hlsl_ir_var *get_variable(struct hlsl_scope *scope, const char *name) DECLSPEC_HIDDEN; void free_declaration(struct hlsl_ir_var *decl) DECLSPEC_HIDDEN; @@ -1076,8 +1079,6 @@ struct hlsl_ir_expr *new_cast(struct hlsl_ir_node *node, struct hlsl_type *type, struct source_location *loc) DECLSPEC_HIDDEN; struct hlsl_ir_node *implicit_conversion(struct hlsl_ir_node *node, struct hlsl_type *type, struct source_location *loc) DECLSPEC_HIDDEN; -struct hlsl_ir_node *make_assignment(struct hlsl_ir_node *left, enum parse_assign_op assign_op, - struct hlsl_ir_node *right) DECLSPEC_HIDDEN; void push_scope(struct hlsl_parse_ctx *ctx) DECLSPEC_HIDDEN; BOOL pop_scope(struct hlsl_parse_ctx *ctx) DECLSPEC_HIDDEN; void init_functions_tree(struct wine_rb_tree *funcs) DECLSPEC_HIDDEN; diff --git a/dlls/d3dcompiler_43/hlsl.y b/dlls/d3dcompiler_43/hlsl.y index c9dbdeb8c18..f7ae8a604af 100644 --- a/dlls/d3dcompiler_43/hlsl.y +++ b/dlls/d3dcompiler_43/hlsl.y @@ -775,7 +775,6 @@ static struct list *declare_vars(struct hlsl_type *basic_type, DWORD modifiers, struct hlsl_type *type; struct parse_variable_def *v, *v_next; struct hlsl_ir_var *var; - struct hlsl_ir_node *assignment; BOOL ret, local = TRUE; struct list *statements_list = d3dcompiler_alloc(sizeof(*statements_list));
@@ -890,9 +889,8 @@ static struct list *declare_vars(struct hlsl_type *basic_type, DWORD modifiers,
load = new_var_load(var, var->loc); list_add_tail(v->initializer.instrs, &load->node.entry); - assignment = make_assignment(&load->node, ASSIGN_OP_ASSIGN, v->initializer.args[0]); + add_assignment(v->initializer.instrs, &load->node, ASSIGN_OP_ASSIGN, v->initializer.args[0]); d3dcompiler_free(v->initializer.args); - list_add_tail(v->initializer.instrs, &assignment->entry);
if (modifiers & HLSL_STORAGE_STATIC) list_move_tail(&hlsl_ctx.static_initializers, v->initializer.instrs); @@ -2721,24 +2719,23 @@ conditional_expr: logicor_expr FIXME("ternary operator\n"); }
-assignment_expr: conditional_expr - { - $$ = $1; - } - | unary_expr assign_op assignment_expr - { - struct hlsl_ir_node *instr; +assignment_expr:
- if (node_from_list($1)->data_type->modifiers & HLSL_MODIFIER_CONST) - { - hlsl_report_message(get_location(&@2), HLSL_LEVEL_ERROR, "l-value is const"); - YYABORT; - } - if (!(instr = make_assignment(node_from_list($1), $2, node_from_list($3)))) - YYABORT; - instr->loc = get_location(&@2); - $$ = append_binop($3, $1, instr); - } + conditional_expr + | unary_expr assign_op assignment_expr + { + struct hlsl_ir_node *lhs = node_from_list($1), *rhs = node_from_list($3); + if (node_from_list($1)->data_type->modifiers & HLSL_MODIFIER_CONST) + { + hlsl_report_message(get_location(&@2), HLSL_LEVEL_ERROR, "l-value is const"); + YYABORT; + } + list_move_tail($3, $1); + d3dcompiler_free($1); + if (!add_assignment($3, lhs, $2, rhs)) + YYABORT; + $$ = $3; + }
assign_op: '=' { diff --git a/dlls/d3dcompiler_43/utils.c b/dlls/d3dcompiler_43/utils.c index 4b1e8f7ff06..1c7b5727ebd 100644 --- a/dlls/d3dcompiler_43/utils.c +++ b/dlls/d3dcompiler_43/utils.c @@ -1443,8 +1443,8 @@ static BOOL invert_swizzle(unsigned int *swizzle, unsigned int *writemask, unsig return TRUE; }
-struct hlsl_ir_node *make_assignment(struct hlsl_ir_node *lhs, enum parse_assign_op assign_op, - struct hlsl_ir_node *rhs) +struct hlsl_ir_node *add_assignment(struct list *instrs, struct hlsl_ir_node *lhs, + enum parse_assign_op assign_op, struct hlsl_ir_node *rhs) { struct hlsl_ir_assignment *assign = d3dcompiler_alloc(sizeof(*assign)); struct hlsl_type *lhs_type; @@ -1524,6 +1524,7 @@ struct hlsl_ir_node *make_assignment(struct hlsl_ir_node *lhs, enum parse_assign rhs = expr; } assign->rhs = rhs; + list_add_tail(instrs, &assign->node.entry);
return &assign->node; }
Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- dlls/d3dcompiler_43/hlsl.y | 39 ++++++++++++++++++++------------------ 1 file changed, 21 insertions(+), 18 deletions(-)
diff --git a/dlls/d3dcompiler_43/hlsl.y b/dlls/d3dcompiler_43/hlsl.y index f7ae8a604af..2d300f8476e 100644 --- a/dlls/d3dcompiler_43/hlsl.y +++ b/dlls/d3dcompiler_43/hlsl.y @@ -562,7 +562,8 @@ static struct hlsl_ir_assignment *make_simple_assignment(struct hlsl_ir_var *lhs return new_assignment(lhs, NULL, rhs, 0, rhs->loc); }
-static struct hlsl_ir_jump *new_return(struct hlsl_ir_node *return_value, struct source_location loc) +static struct hlsl_ir_jump *add_return(struct list *instrs, + struct hlsl_ir_node *return_value, struct source_location loc) { struct hlsl_type *return_type = hlsl_ctx.cur_function->return_type; struct hlsl_ir_jump *jump; @@ -591,6 +592,7 @@ static struct hlsl_ir_jump *new_return(struct hlsl_ir_node *return_value, struct } init_node(&jump->node, HLSL_IR_JUMP, NULL, loc); jump->type = HLSL_IR_JUMP_RETURN; + list_add_tail(instrs, &jump->node.entry);
return jump; } @@ -2160,24 +2162,25 @@ statement: declaration_statement | selection_statement | loop_statement
-jump_statement: KW_RETURN expr ';' - { - struct hlsl_ir_jump *jump; - if (!(jump = new_return(node_from_list($2), get_location(&@1)))) - YYABORT; +jump_statement:
- $$ = $2; - list_add_tail($$, &jump->node.entry); - } - | KW_RETURN ';' - { - struct hlsl_ir_jump *jump; - if (!(jump = new_return(NULL, get_location(&@1)))) - YYABORT; - $$ = d3dcompiler_alloc(sizeof(*$$)); - list_init($$); - list_add_tail($$, &jump->node.entry); - } + KW_RETURN expr ';' + { + struct hlsl_ir_jump *jump; + if (!(jump = add_return($2, node_from_list($2), get_location(&@1)))) + YYABORT; + $$ = $2; + } + | KW_RETURN ';' + { + struct hlsl_ir_jump *jump; + + if (!($$ = d3dcompiler_alloc(sizeof(*$$)))) + YYABORT; + list_init($$); + if (!(jump = add_return($$, NULL, get_location(&@1)))) + YYABORT; + }
selection_statement: KW_IF '(' expr ')' if_body {
Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- dlls/d3dcompiler_43/d3dcompiler_private.h | 4 ++-- dlls/d3dcompiler_43/hlsl.y | 4 ++-- dlls/d3dcompiler_43/utils.c | 8 ++++---- 3 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/dlls/d3dcompiler_43/d3dcompiler_private.h b/dlls/d3dcompiler_43/d3dcompiler_private.h index e9b7b5ada43..29f2455aac0 100644 --- a/dlls/d3dcompiler_43/d3dcompiler_private.h +++ b/dlls/d3dcompiler_43/d3dcompiler_private.h @@ -1059,6 +1059,8 @@ static inline void init_node(struct hlsl_ir_node *node, enum hlsl_ir_node_type t
struct hlsl_ir_node *add_assignment(struct list *instrs, struct hlsl_ir_node *left, enum parse_assign_op assign_op, struct hlsl_ir_node *right) DECLSPEC_HIDDEN; +struct hlsl_ir_node *add_implicit_conversion(struct list *instrs, struct hlsl_ir_node *node, struct hlsl_type *type, + struct source_location *loc) DECLSPEC_HIDDEN;
BOOL add_declaration(struct hlsl_scope *scope, struct hlsl_ir_var *decl, BOOL local_var) DECLSPEC_HIDDEN; struct hlsl_ir_var *get_variable(struct hlsl_scope *scope, const char *name) DECLSPEC_HIDDEN; @@ -1077,8 +1079,6 @@ struct hlsl_ir_expr *new_expr(enum hlsl_ir_expr_op op, struct hlsl_ir_node **ope struct source_location *loc) DECLSPEC_HIDDEN; struct hlsl_ir_expr *new_cast(struct hlsl_ir_node *node, struct hlsl_type *type, struct source_location *loc) DECLSPEC_HIDDEN; -struct hlsl_ir_node *implicit_conversion(struct hlsl_ir_node *node, struct hlsl_type *type, - struct source_location *loc) DECLSPEC_HIDDEN; void push_scope(struct hlsl_parse_ctx *ctx) DECLSPEC_HIDDEN; BOOL pop_scope(struct hlsl_parse_ctx *ctx) DECLSPEC_HIDDEN; void init_functions_tree(struct wine_rb_tree *funcs) DECLSPEC_HIDDEN; diff --git a/dlls/d3dcompiler_43/hlsl.y b/dlls/d3dcompiler_43/hlsl.y index 2d300f8476e..b01a6d51c98 100644 --- a/dlls/d3dcompiler_43/hlsl.y +++ b/dlls/d3dcompiler_43/hlsl.y @@ -572,7 +572,7 @@ static struct hlsl_ir_jump *add_return(struct list *instrs, { struct hlsl_ir_assignment *assignment;
- if (!(return_value = implicit_conversion(return_value, return_type, &loc))) + if (!(return_value = add_implicit_conversion(instrs, return_value, return_type, &loc))) return NULL;
if (!(assignment = make_simple_assignment(hlsl_ctx.cur_function->return_var, return_value))) @@ -2476,7 +2476,7 @@ postfix_expr: primary_expr continue; }
- if (!(arg = implicit_conversion(arg, + if (!(arg = add_implicit_conversion($4.instrs, arg, hlsl_ctx.builtin_types.vector[$2->base_type][width - 1], &arg->loc))) continue;
diff --git a/dlls/d3dcompiler_43/utils.c b/dlls/d3dcompiler_43/utils.c index 1c7b5727ebd..3f063e1a0ae 100644 --- a/dlls/d3dcompiler_43/utils.c +++ b/dlls/d3dcompiler_43/utils.c @@ -1301,8 +1301,8 @@ static struct hlsl_type *expr_common_type(struct hlsl_type *t1, struct hlsl_type return new_hlsl_type(NULL, type, base, dimx, dimy); }
-struct hlsl_ir_node *implicit_conversion(struct hlsl_ir_node *node, struct hlsl_type *dst_type, - struct source_location *loc) +struct hlsl_ir_node *add_implicit_conversion(struct list *instrs, struct hlsl_ir_node *node, + struct hlsl_type *dst_type, struct source_location *loc) { struct hlsl_type *src_type = node->data_type; struct hlsl_ir_expr *cast; @@ -1324,7 +1324,7 @@ struct hlsl_ir_node *implicit_conversion(struct hlsl_ir_node *node, struct hlsl_
if (!(cast = new_cast(node, dst_type, loc))) return NULL; - list_add_after(&node->entry, &cast->node.entry); + list_add_tail(instrs, &cast->node.entry); return &cast->node; }
@@ -1455,7 +1455,7 @@ struct hlsl_ir_node *add_assignment(struct list *instrs, struct hlsl_ir_node *lh { writemask = (1 << lhs_type->dimx) - 1;
- if (!(rhs = implicit_conversion(rhs, lhs_type, &rhs->loc))) + if (!(rhs = add_implicit_conversion(instrs, rhs, lhs_type, &rhs->loc))) return NULL; }
Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- dlls/d3dcompiler_43/hlsl.y | 61 +++++++++++++++++++------------------- 1 file changed, 31 insertions(+), 30 deletions(-)
diff --git a/dlls/d3dcompiler_43/hlsl.y b/dlls/d3dcompiler_43/hlsl.y index b01a6d51c98..136f6999e8a 100644 --- a/dlls/d3dcompiler_43/hlsl.y +++ b/dlls/d3dcompiler_43/hlsl.y @@ -622,7 +622,7 @@ static struct hlsl_ir_load *new_var_load(struct hlsl_ir_var *var, const struct s return load; }
-static struct hlsl_ir_load *new_load(struct hlsl_ir_node *var_node, struct hlsl_ir_node *offset, +static struct hlsl_ir_load *add_load(struct list *instrs, struct hlsl_ir_node *var_node, struct hlsl_ir_node *offset, struct hlsl_type *data_type, const struct source_location loc) { struct hlsl_ir_node *add = NULL; @@ -638,7 +638,7 @@ static struct hlsl_ir_load *new_load(struct hlsl_ir_node *var_node, struct hlsl_ { if (!(add = new_binary_expr(HLSL_IR_BINOP_ADD, src->offset, offset, loc))) return NULL; - list_add_after(&offset->entry, &add->entry); + list_add_tail(instrs, &add->entry); offset = add; } } @@ -656,7 +656,7 @@ static struct hlsl_ir_load *new_load(struct hlsl_ir_node *var_node, struct hlsl_ if (!(assign = make_simple_assignment(var, var_node))) return NULL;
- list_add_after(&var_node->entry, &assign->node.entry); + list_add_tail(instrs, &assign->node.entry); }
if (!(load = d3dcompiler_alloc(sizeof(*load)))) @@ -664,23 +664,23 @@ static struct hlsl_ir_load *new_load(struct hlsl_ir_node *var_node, struct hlsl_ init_node(&load->node, HLSL_IR_LOAD, data_type, loc); load->src.var = var; load->src.offset = offset; - list_add_after(&offset->entry, &load->node.entry); + list_add_tail(instrs, &load->node.entry); return load; }
-static struct hlsl_ir_load *new_record_load(struct hlsl_ir_node *record, +static struct hlsl_ir_load *add_record_load(struct list *instrs, struct hlsl_ir_node *record, const struct hlsl_struct_field *field, const struct source_location loc) { struct hlsl_ir_constant *c;
if (!(c = new_uint_constant(field->reg_offset * 4, loc))) return NULL; - list_add_after(&record->entry, &c->node.entry); + list_add_tail(instrs, &c->node.entry);
- return new_load(record, &c->node, field->type, loc); + return add_load(instrs, record, &c->node, field->type, loc); }
-static struct hlsl_ir_load *new_array_load(struct hlsl_ir_node *array, +static struct hlsl_ir_load *add_array_load(struct list *instrs, struct hlsl_ir_node *array, struct hlsl_ir_node *index, const struct source_location loc) { const struct hlsl_type *expr_type = array->data_type; @@ -711,13 +711,13 @@ static struct hlsl_ir_load *new_array_load(struct hlsl_ir_node *array,
if (!(c = new_uint_constant(data_type->reg_size * 4, loc))) return NULL; - list_add_after(&index->entry, &c->node.entry); + list_add_tail(instrs, &c->node.entry); if (!(mul = new_binary_expr(HLSL_IR_BINOP_MUL, index, &c->node, loc))) return NULL; - list_add_after(&c->node.entry, &mul->entry); + list_add_tail(instrs, &mul->entry); index = mul;
- return new_load(array, index, data_type, loc); + return add_load(instrs, array, index, data_type, loc); }
static void struct_var_initializer(struct list *list, struct hlsl_ir_var *var, @@ -2366,7 +2366,7 @@ postfix_expr: primary_expr { if (!strcmp($3, field->name)) { - if (!new_record_load(node, field, loc)) + if (!add_record_load($1, node, field, loc)) YYABORT; $$ = $1; break; @@ -2399,26 +2399,27 @@ postfix_expr: primary_expr YYABORT; } } - | postfix_expr '[' expr ']' - { - struct hlsl_ir_load *load; + | postfix_expr '[' expr ']' + { + struct hlsl_ir_node *array = node_from_list($1), *index = node_from_list($3);
- if (node_from_list($3)->data_type->type != HLSL_CLASS_SCALAR) - { - hlsl_report_message(get_location(&@3), HLSL_LEVEL_ERROR, "array index is not scalar"); - free_instr_list($1); - free_instr_list($3); - YYABORT; - } + list_move_tail($1, $3); + d3dcompiler_free($3);
- if (!(load = new_array_load(node_from_list($1), node_from_list($3), get_location(&@2)))) - { - free_instr_list($1); - free_instr_list($3); - YYABORT; - } - $$ = append_binop($1, $3, &load->node); - } + if (index->data_type->type != HLSL_CLASS_SCALAR) + { + hlsl_report_message(get_location(&@3), HLSL_LEVEL_ERROR, "array index is not scalar"); + free_instr_list($1); + YYABORT; + } + + if (!add_array_load($1, array, index, get_location(&@2))) + { + free_instr_list($1); + YYABORT; + } + $$ = $1; + }
/* "var_modifiers" doesn't make sense in this case, but it's needed in the grammar to avoid shift/reduce conflicts. */
Signed-off-by: Matteo Bruni mbruni@codeweavers.com
From: Zebediah Figura z.figura12@gmail.com
Signed-off-by: Zebediah Figura zfigura@codeweavers.com Signed-off-by: Matteo Bruni mbruni@codeweavers.com --- v2: Tiny improvements.
dlls/d3dcompiler_43/d3dcompiler_private.h | 5 +-- dlls/d3dcompiler_43/hlsl.y | 38 +++++++++++------------ dlls/d3dcompiler_43/utils.c | 5 +-- 3 files changed, 24 insertions(+), 24 deletions(-)
diff --git a/dlls/d3dcompiler_43/d3dcompiler_private.h b/dlls/d3dcompiler_43/d3dcompiler_private.h index a2d9c04d3bc..d54b9088b68 100644 --- a/dlls/d3dcompiler_43/d3dcompiler_private.h +++ b/dlls/d3dcompiler_43/d3dcompiler_private.h @@ -1057,6 +1057,9 @@ static inline void init_node(struct hlsl_ir_node *node, enum hlsl_ir_node_type t node->loc = loc; }
+struct hlsl_ir_node *add_assignment(struct list *instrs, struct hlsl_ir_node *lhs, + enum parse_assign_op assign_op, struct hlsl_ir_node *rhs) DECLSPEC_HIDDEN; + BOOL add_declaration(struct hlsl_scope *scope, struct hlsl_ir_var *decl, BOOL local_var) DECLSPEC_HIDDEN; struct hlsl_ir_var *get_variable(struct hlsl_scope *scope, const char *name) DECLSPEC_HIDDEN; void free_declaration(struct hlsl_ir_var *decl) DECLSPEC_HIDDEN; @@ -1076,8 +1079,6 @@ struct hlsl_ir_expr *new_cast(struct hlsl_ir_node *node, struct hlsl_type *type, struct source_location *loc) DECLSPEC_HIDDEN; struct hlsl_ir_node *implicit_conversion(struct hlsl_ir_node *node, struct hlsl_type *type, struct source_location *loc) DECLSPEC_HIDDEN; -struct hlsl_ir_node *make_assignment(struct hlsl_ir_node *left, enum parse_assign_op assign_op, - struct hlsl_ir_node *right) DECLSPEC_HIDDEN; void push_scope(struct hlsl_parse_ctx *ctx) DECLSPEC_HIDDEN; BOOL pop_scope(struct hlsl_parse_ctx *ctx) DECLSPEC_HIDDEN; void init_functions_tree(struct wine_rb_tree *funcs) DECLSPEC_HIDDEN; diff --git a/dlls/d3dcompiler_43/hlsl.y b/dlls/d3dcompiler_43/hlsl.y index c9dbdeb8c18..511a43d156a 100644 --- a/dlls/d3dcompiler_43/hlsl.y +++ b/dlls/d3dcompiler_43/hlsl.y @@ -775,7 +775,6 @@ static struct list *declare_vars(struct hlsl_type *basic_type, DWORD modifiers, struct hlsl_type *type; struct parse_variable_def *v, *v_next; struct hlsl_ir_var *var; - struct hlsl_ir_node *assignment; BOOL ret, local = TRUE; struct list *statements_list = d3dcompiler_alloc(sizeof(*statements_list));
@@ -890,9 +889,8 @@ static struct list *declare_vars(struct hlsl_type *basic_type, DWORD modifiers,
load = new_var_load(var, var->loc); list_add_tail(v->initializer.instrs, &load->node.entry); - assignment = make_assignment(&load->node, ASSIGN_OP_ASSIGN, v->initializer.args[0]); + add_assignment(v->initializer.instrs, &load->node, ASSIGN_OP_ASSIGN, v->initializer.args[0]); d3dcompiler_free(v->initializer.args); - list_add_tail(v->initializer.instrs, &assignment->entry);
if (modifiers & HLSL_STORAGE_STATIC) list_move_tail(&hlsl_ctx.static_initializers, v->initializer.instrs); @@ -2721,24 +2719,24 @@ conditional_expr: logicor_expr FIXME("ternary operator\n"); }
-assignment_expr: conditional_expr - { - $$ = $1; - } - | unary_expr assign_op assignment_expr - { - struct hlsl_ir_node *instr; +assignment_expr:
- if (node_from_list($1)->data_type->modifiers & HLSL_MODIFIER_CONST) - { - hlsl_report_message(get_location(&@2), HLSL_LEVEL_ERROR, "l-value is const"); - YYABORT; - } - if (!(instr = make_assignment(node_from_list($1), $2, node_from_list($3)))) - YYABORT; - instr->loc = get_location(&@2); - $$ = append_binop($3, $1, instr); - } + conditional_expr + | unary_expr assign_op assignment_expr + { + struct hlsl_ir_node *lhs = node_from_list($1), *rhs = node_from_list($3); + + if (lhs->data_type->modifiers & HLSL_MODIFIER_CONST) + { + hlsl_report_message(get_location(&@2), HLSL_LEVEL_ERROR, "l-value is const"); + YYABORT; + } + list_move_tail($3, $1); + d3dcompiler_free($1); + if (!add_assignment($3, lhs, $2, rhs)) + YYABORT; + $$ = $3; + }
assign_op: '=' { diff --git a/dlls/d3dcompiler_43/utils.c b/dlls/d3dcompiler_43/utils.c index 4b1e8f7ff06..1c7b5727ebd 100644 --- a/dlls/d3dcompiler_43/utils.c +++ b/dlls/d3dcompiler_43/utils.c @@ -1443,8 +1443,8 @@ static BOOL invert_swizzle(unsigned int *swizzle, unsigned int *writemask, unsig return TRUE; }
-struct hlsl_ir_node *make_assignment(struct hlsl_ir_node *lhs, enum parse_assign_op assign_op, - struct hlsl_ir_node *rhs) +struct hlsl_ir_node *add_assignment(struct list *instrs, struct hlsl_ir_node *lhs, + enum parse_assign_op assign_op, struct hlsl_ir_node *rhs) { struct hlsl_ir_assignment *assign = d3dcompiler_alloc(sizeof(*assign)); struct hlsl_type *lhs_type; @@ -1524,6 +1524,7 @@ struct hlsl_ir_node *make_assignment(struct hlsl_ir_node *lhs, enum parse_assign rhs = expr; } assign->rhs = rhs; + list_add_tail(instrs, &assign->node.entry);
return &assign->node; }
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=73914
Your paranoid android.
=== debiant (build log) ===
error: patch failed: dlls/d3dcompiler_43/hlsl.y:890 Task: Patch failed to apply
=== debiant (build log) ===
error: patch failed: dlls/d3dcompiler_43/hlsl.y:890 Task: Patch failed to apply
From: Zebediah Figura z.figura12@gmail.com
Signed-off-by: Zebediah Figura zfigura@codeweavers.com Signed-off-by: Matteo Bruni mbruni@codeweavers.com --- v2: Get rid of the "jump" variables.
dlls/d3dcompiler_43/hlsl.y | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-)
diff --git a/dlls/d3dcompiler_43/hlsl.y b/dlls/d3dcompiler_43/hlsl.y index 511a43d156a..5d8d7c56a76 100644 --- a/dlls/d3dcompiler_43/hlsl.y +++ b/dlls/d3dcompiler_43/hlsl.y @@ -562,7 +562,8 @@ static struct hlsl_ir_assignment *make_simple_assignment(struct hlsl_ir_var *lhs return new_assignment(lhs, NULL, rhs, 0, rhs->loc); }
-static struct hlsl_ir_jump *new_return(struct hlsl_ir_node *return_value, struct source_location loc) +static struct hlsl_ir_jump *add_return(struct list *instrs, + struct hlsl_ir_node *return_value, struct source_location loc) { struct hlsl_type *return_type = hlsl_ctx.cur_function->return_type; struct hlsl_ir_jump *jump; @@ -591,6 +592,7 @@ static struct hlsl_ir_jump *new_return(struct hlsl_ir_node *return_value, struct } init_node(&jump->node, HLSL_IR_JUMP, NULL, loc); jump->type = HLSL_IR_JUMP_RETURN; + list_add_tail(instrs, &jump->node.entry);
return jump; } @@ -2160,24 +2162,22 @@ statement: declaration_statement | selection_statement | loop_statement
-jump_statement: KW_RETURN expr ';' - { - struct hlsl_ir_jump *jump; - if (!(jump = new_return(node_from_list($2), get_location(&@1)))) - YYABORT; +jump_statement:
- $$ = $2; - list_add_tail($$, &jump->node.entry); - } - | KW_RETURN ';' - { - struct hlsl_ir_jump *jump; - if (!(jump = new_return(NULL, get_location(&@1)))) - YYABORT; - $$ = d3dcompiler_alloc(sizeof(*$$)); - list_init($$); - list_add_tail($$, &jump->node.entry); - } + KW_RETURN expr ';' + { + if (!add_return($2, node_from_list($2), get_location(&@1))) + YYABORT; + $$ = $2; + } + | KW_RETURN ';' + { + if (!($$ = d3dcompiler_alloc(sizeof(*$$)))) + YYABORT; + list_init($$); + if (!add_return($$, NULL, get_location(&@1))) + YYABORT; + }
selection_statement: KW_IF '(' expr ')' if_body {
From: Zebediah Figura z.figura12@gmail.com
Signed-off-by: Zebediah Figura zfigura@codeweavers.com Signed-off-by: Matteo Bruni mbruni@codeweavers.com --- v2: Rebase.
dlls/d3dcompiler_43/d3dcompiler_private.h | 4 ++-- dlls/d3dcompiler_43/hlsl.y | 4 ++-- dlls/d3dcompiler_43/utils.c | 8 ++++---- 3 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/dlls/d3dcompiler_43/d3dcompiler_private.h b/dlls/d3dcompiler_43/d3dcompiler_private.h index d54b9088b68..97b84c44945 100644 --- a/dlls/d3dcompiler_43/d3dcompiler_private.h +++ b/dlls/d3dcompiler_43/d3dcompiler_private.h @@ -1059,6 +1059,8 @@ static inline void init_node(struct hlsl_ir_node *node, enum hlsl_ir_node_type t
struct hlsl_ir_node *add_assignment(struct list *instrs, struct hlsl_ir_node *lhs, enum parse_assign_op assign_op, struct hlsl_ir_node *rhs) DECLSPEC_HIDDEN; +struct hlsl_ir_node *add_implicit_conversion(struct list *instrs, struct hlsl_ir_node *node, struct hlsl_type *type, + struct source_location *loc) DECLSPEC_HIDDEN;
BOOL add_declaration(struct hlsl_scope *scope, struct hlsl_ir_var *decl, BOOL local_var) DECLSPEC_HIDDEN; struct hlsl_ir_var *get_variable(struct hlsl_scope *scope, const char *name) DECLSPEC_HIDDEN; @@ -1077,8 +1079,6 @@ struct hlsl_ir_expr *new_expr(enum hlsl_ir_expr_op op, struct hlsl_ir_node **ope struct source_location *loc) DECLSPEC_HIDDEN; struct hlsl_ir_expr *new_cast(struct hlsl_ir_node *node, struct hlsl_type *type, struct source_location *loc) DECLSPEC_HIDDEN; -struct hlsl_ir_node *implicit_conversion(struct hlsl_ir_node *node, struct hlsl_type *type, - struct source_location *loc) DECLSPEC_HIDDEN; void push_scope(struct hlsl_parse_ctx *ctx) DECLSPEC_HIDDEN; BOOL pop_scope(struct hlsl_parse_ctx *ctx) DECLSPEC_HIDDEN; void init_functions_tree(struct wine_rb_tree *funcs) DECLSPEC_HIDDEN; diff --git a/dlls/d3dcompiler_43/hlsl.y b/dlls/d3dcompiler_43/hlsl.y index 5d8d7c56a76..efb1a69fea3 100644 --- a/dlls/d3dcompiler_43/hlsl.y +++ b/dlls/d3dcompiler_43/hlsl.y @@ -572,7 +572,7 @@ static struct hlsl_ir_jump *add_return(struct list *instrs, { struct hlsl_ir_assignment *assignment;
- if (!(return_value = implicit_conversion(return_value, return_type, &loc))) + if (!(return_value = add_implicit_conversion(instrs, return_value, return_type, &loc))) return NULL;
if (!(assignment = make_simple_assignment(hlsl_ctx.cur_function->return_var, return_value))) @@ -2473,7 +2473,7 @@ postfix_expr: primary_expr continue; }
- if (!(arg = implicit_conversion(arg, + if (!(arg = add_implicit_conversion($4.instrs, arg, hlsl_ctx.builtin_types.vector[$2->base_type][width - 1], &arg->loc))) continue;
diff --git a/dlls/d3dcompiler_43/utils.c b/dlls/d3dcompiler_43/utils.c index 1c7b5727ebd..3f063e1a0ae 100644 --- a/dlls/d3dcompiler_43/utils.c +++ b/dlls/d3dcompiler_43/utils.c @@ -1301,8 +1301,8 @@ static struct hlsl_type *expr_common_type(struct hlsl_type *t1, struct hlsl_type return new_hlsl_type(NULL, type, base, dimx, dimy); }
-struct hlsl_ir_node *implicit_conversion(struct hlsl_ir_node *node, struct hlsl_type *dst_type, - struct source_location *loc) +struct hlsl_ir_node *add_implicit_conversion(struct list *instrs, struct hlsl_ir_node *node, + struct hlsl_type *dst_type, struct source_location *loc) { struct hlsl_type *src_type = node->data_type; struct hlsl_ir_expr *cast; @@ -1324,7 +1324,7 @@ struct hlsl_ir_node *implicit_conversion(struct hlsl_ir_node *node, struct hlsl_
if (!(cast = new_cast(node, dst_type, loc))) return NULL; - list_add_after(&node->entry, &cast->node.entry); + list_add_tail(instrs, &cast->node.entry); return &cast->node; }
@@ -1455,7 +1455,7 @@ struct hlsl_ir_node *add_assignment(struct list *instrs, struct hlsl_ir_node *lh { writemask = (1 << lhs_type->dimx) - 1;
- if (!(rhs = implicit_conversion(rhs, lhs_type, &rhs->loc))) + if (!(rhs = add_implicit_conversion(instrs, rhs, lhs_type, &rhs->loc))) return NULL; }
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=73910
Your paranoid android.
=== debiant (build log) ===
error: patch failed: dlls/d3dcompiler_43/d3dcompiler_private.h:1059 Task: Patch failed to apply
=== debiant (build log) ===
error: patch failed: dlls/d3dcompiler_43/d3dcompiler_private.h:1059 Task: Patch failed to apply