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

Signed-off-by: Zebediah Figura <zfigura@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 2019-08-13 10:23:32 -05:00 committed by Alexandre Julliard
parent 32fd9ff479
commit bf31a900d1
3 changed files with 27 additions and 47 deletions

View File

@ -706,8 +706,7 @@ struct source_location
enum hlsl_ir_node_type
{
HLSL_IR_VAR = 0,
HLSL_IR_ASSIGNMENT,
HLSL_IR_ASSIGNMENT = 0,
HLSL_IR_CONSTANT,
HLSL_IR_CONSTRUCTOR,
HLSL_IR_DEREF,
@ -755,12 +754,13 @@ struct reg_reservation
struct hlsl_ir_var
{
struct hlsl_ir_node node;
struct hlsl_type *data_type;
struct source_location loc;
const char *name;
const char *semantic;
unsigned int modifiers;
const struct reg_reservation *reg_reservation;
struct list scope_entry;
struct list scope_entry, param_entry;
struct hlsl_var_allocation *allocation;
};
@ -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,
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)
{
assert(node->type == HLSL_IR_EXPR);

View File

@ -122,7 +122,7 @@ static BOOL declare_variable(struct hlsl_ir_var *decl, BOOL local)
BOOL ret;
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)))
{
@ -131,7 +131,7 @@ static BOOL declare_variable(struct hlsl_ir_var *decl, BOOL local)
}
}
else
check_invalid_matrix_modifiers(decl->modifiers, &decl->node.loc);
check_invalid_matrix_modifiers(decl->modifiers, &decl->loc);
if (local)
{
@ -139,12 +139,12 @@ static BOOL declare_variable(struct hlsl_ir_var *decl, BOOL local)
| HLSL_STORAGE_GROUPSHARED | HLSL_STORAGE_UNIFORM);
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));
}
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");
return FALSE;
}
@ -153,7 +153,7 @@ static BOOL declare_variable(struct hlsl_ir_var *decl, BOOL local)
{
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);
return FALSE;
}
@ -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);
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);
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);
return FALSE;
}
@ -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,
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_ir_node *assignment;
struct hlsl_ir_deref *deref;
@ -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))
{
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");
free_parse_initializer(initializer);
return;
@ -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))
{
deref = new_record_deref(&var->node, field);
deref = new_record_deref(&new_var_deref(var)->node, field);
if (!deref)
{
ERR("Out of memory.\n");
@ -570,13 +570,12 @@ static struct list *declare_vars(struct hlsl_type *basic_type, DWORD modifiers,
d3dcompiler_free(v);
continue;
}
var->node.type = HLSL_IR_VAR;
if (v->array_size)
type = new_array_type(basic_type, v->array_size);
else
type = basic_type;
var->node.data_type = type;
var->node.loc = v->loc;
var->data_type = type;
var->loc = v->loc;
var->name = v->name;
var->modifiers = modifiers;
var->semantic = v->semantic;
@ -662,7 +661,7 @@ static struct list *declare_vars(struct hlsl_type *basic_type, DWORD modifiers,
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]);
d3dcompiler_free(v->initializer.args);
list_add_tail(statements_list, &assignment->entry);
@ -800,9 +799,8 @@ static BOOL add_func_parameter(struct list *list, struct parse_parameter *param,
ERR("Out of memory.\n");
return FALSE;
}
decl->node.type = HLSL_IR_VAR;
decl->node.data_type = param->type;
decl->node.loc = *loc;
decl->data_type = param->type;
decl->loc = *loc;
decl->name = param->name;
decl->semantic = param->semantic;
decl->reg_reservation = param->reg_reservation;
@ -813,7 +811,7 @@ static BOOL add_func_parameter(struct list *list, struct parse_parameter *param,
free_declaration(decl);
return FALSE;
}
list_add_tail(list, &decl->node.entry);
list_add_tail(list, &decl->param_entry);
return TRUE;
}

View File

@ -1361,7 +1361,7 @@ struct hlsl_ir_deref *new_var_deref(struct hlsl_ir_var *var)
return NULL;
}
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->v.var = var;
return deref;
@ -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.data_type = field->type;
deref->type = HLSL_IR_DEREF_RECORD;
if (record->type == HLSL_IR_VAR)
deref->v.record.record = &new_var_deref(var_from_node(record))->node;
else
deref->v.record.record = record;
deref->v.record.record = record;
deref->v.record.field = field;
return deref;
}
@ -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");
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. */
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
while (p1cur && p2cur)
{
struct hlsl_ir_var *p1, *p2;
p1 = LIST_ENTRY(p1cur, struct hlsl_ir_var, node.entry);
p2 = LIST_ENTRY(p2cur, struct hlsl_ir_var, node.entry);
if ((r = compare_param_hlsl_types(p1->node.data_type, p2->node.data_type)))
p1 = LIST_ENTRY(p1cur, struct hlsl_ir_var, param_entry);
p2 = LIST_ENTRY(p2cur, struct hlsl_ir_var, param_entry);
if ((r = compare_param_hlsl_types(p1->data_type, p2->data_type)))
return r;
p1cur = list_next(params, p1cur);
p2cur = list_next(decl->parameters, p2cur);
@ -1768,7 +1760,6 @@ static const char *debug_node_type(enum hlsl_ir_node_type type)
{
static const char * const names[] =
{
"HLSL_IR_VAR",
"HLSL_IR_ASSIGNMENT",
"HLSL_IR_CONSTANT",
"HLSL_IR_CONSTRUCTOR",
@ -1801,7 +1792,7 @@ static void debug_dump_ir_var(const struct hlsl_ir_var *var)
{
if (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)
TRACE(" : %s", debugstr_a(var->semantic));
}
@ -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("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);
TRACE("\n");
@ -2234,9 +2225,6 @@ void free_instr(struct hlsl_ir_node *node)
{
switch (node->type)
{
case HLSL_IR_VAR:
/* These are freed later on from the scopes. */
break;
case HLSL_IR_CONSTANT:
free_ir_constant(constant_from_node(node));
break;