Commit bf31a900 authored by Zebediah Figura's avatar Zebediah Figura Committed by Alexandre Julliard

d3dcompiler: Get rid of the "node" field from struct hlsl_ir_var.

parent 32fd9ff4
...@@ -706,8 +706,7 @@ struct source_location ...@@ -706,8 +706,7 @@ struct source_location
enum hlsl_ir_node_type enum hlsl_ir_node_type
{ {
HLSL_IR_VAR = 0, HLSL_IR_ASSIGNMENT = 0,
HLSL_IR_ASSIGNMENT,
HLSL_IR_CONSTANT, HLSL_IR_CONSTANT,
HLSL_IR_CONSTRUCTOR, HLSL_IR_CONSTRUCTOR,
HLSL_IR_DEREF, HLSL_IR_DEREF,
...@@ -755,12 +754,13 @@ struct reg_reservation ...@@ -755,12 +754,13 @@ struct reg_reservation
struct hlsl_ir_var struct hlsl_ir_var
{ {
struct hlsl_ir_node node; struct hlsl_type *data_type;
struct source_location loc;
const char *name; const char *name;
const char *semantic; const char *semantic;
unsigned int modifiers; unsigned int modifiers;
const struct reg_reservation *reg_reservation; const struct reg_reservation *reg_reservation;
struct list scope_entry; struct list scope_entry, param_entry;
struct hlsl_var_allocation *allocation; struct hlsl_var_allocation *allocation;
}; };
...@@ -1066,12 +1066,6 @@ void WINAPIV hlsl_message(const char *fmt, ...) PRINTF_ATTR(1,2) DECLSPEC_HIDDEN ...@@ -1066,12 +1066,6 @@ void WINAPIV hlsl_message(const char *fmt, ...) PRINTF_ATTR(1,2) DECLSPEC_HIDDEN
void WINAPIV hlsl_report_message(const char *filename, DWORD line, DWORD column, void WINAPIV hlsl_report_message(const char *filename, DWORD line, DWORD column,
enum hlsl_error_level level, const char *fmt, ...) PRINTF_ATTR(5,6) DECLSPEC_HIDDEN; enum hlsl_error_level level, const char *fmt, ...) PRINTF_ATTR(5,6) DECLSPEC_HIDDEN;
static inline struct hlsl_ir_var *var_from_node(const struct hlsl_ir_node *node)
{
assert(node->type == HLSL_IR_VAR);
return CONTAINING_RECORD(node, struct hlsl_ir_var, node);
}
static inline struct hlsl_ir_expr *expr_from_node(const struct hlsl_ir_node *node) static inline struct hlsl_ir_expr *expr_from_node(const struct hlsl_ir_node *node)
{ {
assert(node->type == HLSL_IR_EXPR); assert(node->type == HLSL_IR_EXPR);
......
...@@ -122,7 +122,7 @@ static BOOL declare_variable(struct hlsl_ir_var *decl, BOOL local) ...@@ -122,7 +122,7 @@ static BOOL declare_variable(struct hlsl_ir_var *decl, BOOL local)
BOOL ret; BOOL ret;
TRACE("Declaring variable %s.\n", decl->name); TRACE("Declaring variable %s.\n", decl->name);
if (decl->node.data_type->type == HLSL_CLASS_MATRIX) if (decl->data_type->type == HLSL_CLASS_MATRIX)
{ {
if (!(decl->modifiers & (HLSL_MODIFIER_ROW_MAJOR | HLSL_MODIFIER_COLUMN_MAJOR))) if (!(decl->modifiers & (HLSL_MODIFIER_ROW_MAJOR | HLSL_MODIFIER_COLUMN_MAJOR)))
{ {
...@@ -131,7 +131,7 @@ static BOOL declare_variable(struct hlsl_ir_var *decl, BOOL local) ...@@ -131,7 +131,7 @@ static BOOL declare_variable(struct hlsl_ir_var *decl, BOOL local)
} }
} }
else else
check_invalid_matrix_modifiers(decl->modifiers, &decl->node.loc); check_invalid_matrix_modifiers(decl->modifiers, &decl->loc);
if (local) if (local)
{ {
...@@ -139,12 +139,12 @@ static BOOL declare_variable(struct hlsl_ir_var *decl, BOOL local) ...@@ -139,12 +139,12 @@ static BOOL declare_variable(struct hlsl_ir_var *decl, BOOL local)
| HLSL_STORAGE_GROUPSHARED | HLSL_STORAGE_UNIFORM); | HLSL_STORAGE_GROUPSHARED | HLSL_STORAGE_UNIFORM);
if (invalid) if (invalid)
{ {
hlsl_report_message(decl->node.loc.file, decl->node.loc.line, decl->node.loc.col, HLSL_LEVEL_ERROR, hlsl_report_message(decl->loc.file, decl->loc.line, decl->loc.col, HLSL_LEVEL_ERROR,
"modifier '%s' invalid for local variables", debug_modifiers(invalid)); "modifier '%s' invalid for local variables", debug_modifiers(invalid));
} }
if (decl->semantic) if (decl->semantic)
{ {
hlsl_report_message(decl->node.loc.file, decl->node.loc.line, decl->node.loc.col, HLSL_LEVEL_ERROR, hlsl_report_message(decl->loc.file, decl->loc.line, decl->loc.col, HLSL_LEVEL_ERROR,
"semantics are not allowed on local variables"); "semantics are not allowed on local variables");
return FALSE; return FALSE;
} }
...@@ -153,7 +153,7 @@ static BOOL declare_variable(struct hlsl_ir_var *decl, BOOL local) ...@@ -153,7 +153,7 @@ static BOOL declare_variable(struct hlsl_ir_var *decl, BOOL local)
{ {
if (find_function(decl->name)) if (find_function(decl->name))
{ {
hlsl_report_message(decl->node.loc.file, decl->node.loc.line, decl->node.loc.col, HLSL_LEVEL_ERROR, hlsl_report_message(decl->loc.file, decl->loc.line, decl->loc.col, HLSL_LEVEL_ERROR,
"redefinition of '%s'", decl->name); "redefinition of '%s'", decl->name);
return FALSE; return FALSE;
} }
...@@ -163,9 +163,9 @@ static BOOL declare_variable(struct hlsl_ir_var *decl, BOOL local) ...@@ -163,9 +163,9 @@ static BOOL declare_variable(struct hlsl_ir_var *decl, BOOL local)
{ {
struct hlsl_ir_var *old = get_variable(hlsl_ctx.cur_scope, decl->name); struct hlsl_ir_var *old = get_variable(hlsl_ctx.cur_scope, decl->name);
hlsl_report_message(decl->node.loc.file, decl->node.loc.line, decl->node.loc.col, HLSL_LEVEL_ERROR, hlsl_report_message(decl->loc.file, decl->loc.line, decl->loc.col, HLSL_LEVEL_ERROR,
"\"%s\" already declared", decl->name); "\"%s\" already declared", decl->name);
hlsl_report_message(old->node.loc.file, old->node.loc.line, old->node.loc.col, HLSL_LEVEL_NOTE, hlsl_report_message(old->loc.file, old->loc.line, old->loc.col, HLSL_LEVEL_NOTE,
"\"%s\" was previously declared here", old->name); "\"%s\" was previously declared here", old->name);
return FALSE; return FALSE;
} }
...@@ -494,7 +494,7 @@ static struct hlsl_ir_swizzle *get_swizzle(struct hlsl_ir_node *value, const cha ...@@ -494,7 +494,7 @@ static struct hlsl_ir_swizzle *get_swizzle(struct hlsl_ir_node *value, const cha
static void struct_var_initializer(struct list *list, struct hlsl_ir_var *var, static void struct_var_initializer(struct list *list, struct hlsl_ir_var *var,
struct parse_initializer *initializer) struct parse_initializer *initializer)
{ {
struct hlsl_type *type = var->node.data_type; struct hlsl_type *type = var->data_type;
struct hlsl_struct_field *field; struct hlsl_struct_field *field;
struct hlsl_ir_node *assignment; struct hlsl_ir_node *assignment;
struct hlsl_ir_deref *deref; struct hlsl_ir_deref *deref;
...@@ -502,7 +502,7 @@ static void struct_var_initializer(struct list *list, struct hlsl_ir_var *var, ...@@ -502,7 +502,7 @@ static void struct_var_initializer(struct list *list, struct hlsl_ir_var *var,
if (initializer_size(initializer) != components_count_type(type)) if (initializer_size(initializer) != components_count_type(type))
{ {
hlsl_report_message(var->node.loc.file, var->node.loc.line, var->node.loc.col, HLSL_LEVEL_ERROR, hlsl_report_message(var->loc.file, var->loc.line, var->loc.col, HLSL_LEVEL_ERROR,
"structure initializer mismatch"); "structure initializer mismatch");
free_parse_initializer(initializer); free_parse_initializer(initializer);
return; return;
...@@ -519,7 +519,7 @@ static void struct_var_initializer(struct list *list, struct hlsl_ir_var *var, ...@@ -519,7 +519,7 @@ static void struct_var_initializer(struct list *list, struct hlsl_ir_var *var,
} }
if (components_count_type(field->type) == components_count_type(node->data_type)) if (components_count_type(field->type) == components_count_type(node->data_type))
{ {
deref = new_record_deref(&var->node, field); deref = new_record_deref(&new_var_deref(var)->node, field);
if (!deref) if (!deref)
{ {
ERR("Out of memory.\n"); ERR("Out of memory.\n");
...@@ -570,13 +570,12 @@ static struct list *declare_vars(struct hlsl_type *basic_type, DWORD modifiers, ...@@ -570,13 +570,12 @@ static struct list *declare_vars(struct hlsl_type *basic_type, DWORD modifiers,
d3dcompiler_free(v); d3dcompiler_free(v);
continue; continue;
} }
var->node.type = HLSL_IR_VAR;
if (v->array_size) if (v->array_size)
type = new_array_type(basic_type, v->array_size); type = new_array_type(basic_type, v->array_size);
else else
type = basic_type; type = basic_type;
var->node.data_type = type; var->data_type = type;
var->node.loc = v->loc; var->loc = v->loc;
var->name = v->name; var->name = v->name;
var->modifiers = modifiers; var->modifiers = modifiers;
var->semantic = v->semantic; var->semantic = v->semantic;
...@@ -662,7 +661,7 @@ static struct list *declare_vars(struct hlsl_type *basic_type, DWORD modifiers, ...@@ -662,7 +661,7 @@ static struct list *declare_vars(struct hlsl_type *basic_type, DWORD modifiers,
continue; continue;
} }
assignment = make_assignment(&var->node, ASSIGN_OP_ASSIGN, assignment = make_assignment(&new_var_deref(var)->node, ASSIGN_OP_ASSIGN,
BWRITERSP_WRITEMASK_ALL, v->initializer.args[0]); BWRITERSP_WRITEMASK_ALL, v->initializer.args[0]);
d3dcompiler_free(v->initializer.args); d3dcompiler_free(v->initializer.args);
list_add_tail(statements_list, &assignment->entry); list_add_tail(statements_list, &assignment->entry);
...@@ -800,9 +799,8 @@ static BOOL add_func_parameter(struct list *list, struct parse_parameter *param, ...@@ -800,9 +799,8 @@ static BOOL add_func_parameter(struct list *list, struct parse_parameter *param,
ERR("Out of memory.\n"); ERR("Out of memory.\n");
return FALSE; return FALSE;
} }
decl->node.type = HLSL_IR_VAR; decl->data_type = param->type;
decl->node.data_type = param->type; decl->loc = *loc;
decl->node.loc = *loc;
decl->name = param->name; decl->name = param->name;
decl->semantic = param->semantic; decl->semantic = param->semantic;
decl->reg_reservation = param->reg_reservation; decl->reg_reservation = param->reg_reservation;
...@@ -813,7 +811,7 @@ static BOOL add_func_parameter(struct list *list, struct parse_parameter *param, ...@@ -813,7 +811,7 @@ static BOOL add_func_parameter(struct list *list, struct parse_parameter *param,
free_declaration(decl); free_declaration(decl);
return FALSE; return FALSE;
} }
list_add_tail(list, &decl->node.entry); list_add_tail(list, &decl->param_entry);
return TRUE; return TRUE;
} }
......
...@@ -1361,7 +1361,7 @@ struct hlsl_ir_deref *new_var_deref(struct hlsl_ir_var *var) ...@@ -1361,7 +1361,7 @@ struct hlsl_ir_deref *new_var_deref(struct hlsl_ir_var *var)
return NULL; return NULL;
} }
deref->node.type = HLSL_IR_DEREF; deref->node.type = HLSL_IR_DEREF;
deref->node.data_type = var->node.data_type; deref->node.data_type = var->data_type;
deref->type = HLSL_IR_DEREF_VAR; deref->type = HLSL_IR_DEREF_VAR;
deref->v.var = var; deref->v.var = var;
return deref; return deref;
...@@ -1379,10 +1379,7 @@ struct hlsl_ir_deref *new_record_deref(struct hlsl_ir_node *record, struct hlsl_ ...@@ -1379,10 +1379,7 @@ struct hlsl_ir_deref *new_record_deref(struct hlsl_ir_node *record, struct hlsl_
deref->node.type = HLSL_IR_DEREF; deref->node.type = HLSL_IR_DEREF;
deref->node.data_type = field->type; deref->node.data_type = field->type;
deref->type = HLSL_IR_DEREF_RECORD; deref->type = HLSL_IR_DEREF_RECORD;
if (record->type == HLSL_IR_VAR) deref->v.record.record = record;
deref->v.record.record = &new_var_deref(var_from_node(record))->node;
else
deref->v.record.record = record;
deref->v.record.field = field; deref->v.record.field = field;
return deref; return deref;
} }
...@@ -1459,11 +1456,6 @@ struct hlsl_ir_node *make_assignment(struct hlsl_ir_node *left, enum parse_assig ...@@ -1459,11 +1456,6 @@ struct hlsl_ir_node *make_assignment(struct hlsl_ir_node *left, enum parse_assig
FIXME("Check for casts in the lhs.\n"); FIXME("Check for casts in the lhs.\n");
lhs = left; lhs = left;
if (lhs->type == HLSL_IR_VAR)
{
struct hlsl_ir_deref *lhs_deref = new_var_deref(var_from_node(lhs));
lhs = &lhs_deref->node;
}
/* FIXME: check for invalid writemasks on the lhs. */ /* FIXME: check for invalid writemasks on the lhs. */
if (!compare_hlsl_types(type, rhs->data_type)) if (!compare_hlsl_types(type, rhs->data_type))
...@@ -1649,9 +1641,9 @@ static int compare_function_decl_rb(const void *key, const struct wine_rb_entry ...@@ -1649,9 +1641,9 @@ static int compare_function_decl_rb(const void *key, const struct wine_rb_entry
while (p1cur && p2cur) while (p1cur && p2cur)
{ {
struct hlsl_ir_var *p1, *p2; struct hlsl_ir_var *p1, *p2;
p1 = LIST_ENTRY(p1cur, struct hlsl_ir_var, node.entry); p1 = LIST_ENTRY(p1cur, struct hlsl_ir_var, param_entry);
p2 = LIST_ENTRY(p2cur, struct hlsl_ir_var, node.entry); p2 = LIST_ENTRY(p2cur, struct hlsl_ir_var, param_entry);
if ((r = compare_param_hlsl_types(p1->node.data_type, p2->node.data_type))) if ((r = compare_param_hlsl_types(p1->data_type, p2->data_type)))
return r; return r;
p1cur = list_next(params, p1cur); p1cur = list_next(params, p1cur);
p2cur = list_next(decl->parameters, p2cur); p2cur = list_next(decl->parameters, p2cur);
...@@ -1768,7 +1760,6 @@ static const char *debug_node_type(enum hlsl_ir_node_type type) ...@@ -1768,7 +1760,6 @@ static const char *debug_node_type(enum hlsl_ir_node_type type)
{ {
static const char * const names[] = static const char * const names[] =
{ {
"HLSL_IR_VAR",
"HLSL_IR_ASSIGNMENT", "HLSL_IR_ASSIGNMENT",
"HLSL_IR_CONSTANT", "HLSL_IR_CONSTANT",
"HLSL_IR_CONSTRUCTOR", "HLSL_IR_CONSTRUCTOR",
...@@ -1801,7 +1792,7 @@ static void debug_dump_ir_var(const struct hlsl_ir_var *var) ...@@ -1801,7 +1792,7 @@ static void debug_dump_ir_var(const struct hlsl_ir_var *var)
{ {
if (var->modifiers) if (var->modifiers)
TRACE("%s ", debug_modifiers(var->modifiers)); TRACE("%s ", debug_modifiers(var->modifiers));
TRACE("%s %s", debug_hlsl_type(var->node.data_type), var->name); TRACE("%s %s", debug_hlsl_type(var->data_type), var->name);
if (var->semantic) if (var->semantic)
TRACE(" : %s", debugstr_a(var->semantic)); TRACE(" : %s", debugstr_a(var->semantic));
} }
...@@ -2098,7 +2089,7 @@ void debug_dump_ir_function_decl(const struct hlsl_ir_function_decl *func) ...@@ -2098,7 +2089,7 @@ void debug_dump_ir_function_decl(const struct hlsl_ir_function_decl *func)
TRACE("Dumping function %s.\n", debugstr_a(func->func->name)); TRACE("Dumping function %s.\n", debugstr_a(func->func->name));
TRACE("Function parameters:\n"); TRACE("Function parameters:\n");
LIST_FOR_EACH_ENTRY(param, func->parameters, struct hlsl_ir_var, node.entry) LIST_FOR_EACH_ENTRY(param, func->parameters, struct hlsl_ir_var, param_entry)
{ {
debug_dump_ir_var(param); debug_dump_ir_var(param);
TRACE("\n"); TRACE("\n");
...@@ -2234,9 +2225,6 @@ void free_instr(struct hlsl_ir_node *node) ...@@ -2234,9 +2225,6 @@ void free_instr(struct hlsl_ir_node *node)
{ {
switch (node->type) switch (node->type)
{ {
case HLSL_IR_VAR:
/* These are freed later on from the scopes. */
break;
case HLSL_IR_CONSTANT: case HLSL_IR_CONSTANT:
free_ir_constant(constant_from_node(node)); free_ir_constant(constant_from_node(node));
break; break;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment