[PATCH vkd3d 4/5] vkd3d-shader: Replace struct source_location with struct vkd3d_shader_location.
Zebediah Figura
zfigura at codeweavers.com
Wed Feb 10 15:42:59 CST 2021
Signed-off-by: Zebediah Figura <zfigura at codeweavers.com>
---
libs/vkd3d-shader/hlsl.c | 28 ++++++++++++++-------------
libs/vkd3d-shader/hlsl.h | 41 +++++++++++++++++-----------------------
libs/vkd3d-shader/hlsl.l | 4 ++--
libs/vkd3d-shader/hlsl.y | 32 +++++++++++++++----------------
4 files changed, 50 insertions(+), 55 deletions(-)
diff --git a/libs/vkd3d-shader/hlsl.c b/libs/vkd3d-shader/hlsl.c
index 992e7062..6f19cbb3 100644
--- a/libs/vkd3d-shader/hlsl.c
+++ b/libs/vkd3d-shader/hlsl.c
@@ -25,7 +25,7 @@ void hlsl_message(const char *fmt, ...)
/* FIXME */
}
-void hlsl_note(struct hlsl_ctx *ctx, const struct source_location loc,
+void hlsl_note(struct hlsl_ctx *ctx, const struct vkd3d_shader_location loc,
enum vkd3d_shader_log_level level, const char *fmt, ...)
{
/* FIXME */
@@ -33,14 +33,14 @@ void hlsl_note(struct hlsl_ctx *ctx, const struct source_location loc,
set_parse_status(&ctx->status, PARSE_WARN);
}
-void hlsl_error(struct hlsl_ctx *ctx, const struct source_location loc, const char *fmt, ...)
+void hlsl_error(struct hlsl_ctx *ctx, const struct vkd3d_shader_location loc, const char *fmt, ...)
{
/* FIXME */
set_parse_status(&ctx->status, PARSE_ERR);
}
-void hlsl_warning(struct hlsl_ctx *ctx, const struct source_location loc, const char *fmt, ...)
+void hlsl_warning(struct hlsl_ctx *ctx, const struct vkd3d_shader_location loc, const char *fmt, ...)
{
/* FIXME */
@@ -350,7 +350,7 @@ bool hlsl_scope_add_type(struct hlsl_scope *scope, struct hlsl_type *type)
}
struct hlsl_ir_expr *hlsl_new_cast(struct hlsl_ir_node *node, struct hlsl_type *type,
- struct source_location *loc)
+ struct vkd3d_shader_location *loc)
{
struct hlsl_ir_node *cast;
@@ -360,7 +360,7 @@ struct hlsl_ir_expr *hlsl_new_cast(struct hlsl_ir_node *node, struct hlsl_type *
return hlsl_ir_expr(cast);
}
-struct hlsl_ir_var *hlsl_new_var(const char *name, struct hlsl_type *type, const struct source_location loc,
+struct hlsl_ir_var *hlsl_new_var(const char *name, struct hlsl_type *type, const struct vkd3d_shader_location loc,
const char *semantic, unsigned int modifiers, const struct hlsl_reg_reservation *reg_reservation)
{
struct hlsl_ir_var *var;
@@ -378,7 +378,7 @@ struct hlsl_ir_var *hlsl_new_var(const char *name, struct hlsl_type *type, const
}
struct hlsl_ir_var *hlsl_new_synthetic_var(struct hlsl_ctx *ctx, const char *name, struct hlsl_type *type,
- const struct source_location loc)
+ const struct vkd3d_shader_location loc)
{
struct hlsl_ir_var *var = hlsl_new_var(vkd3d_strdup(name), type, loc, NULL, 0, NULL);
@@ -393,7 +393,7 @@ static bool type_is_single_reg(const struct hlsl_type *type)
}
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 source_location loc)
+ struct hlsl_ir_node *rhs, unsigned int writemask, struct vkd3d_shader_location loc)
{
struct hlsl_ir_assignment *assign;
@@ -416,7 +416,8 @@ struct hlsl_ir_assignment *hlsl_new_simple_assignment(struct hlsl_ir_var *lhs, s
return hlsl_new_assignment(lhs, NULL, rhs, 0, rhs->loc);
}
-struct hlsl_ir_constant *hlsl_new_uint_constant(struct hlsl_ctx *ctx, unsigned int n, const struct source_location loc)
+struct hlsl_ir_constant *hlsl_new_uint_constant(struct hlsl_ctx *ctx, unsigned int n,
+ const struct vkd3d_shader_location loc)
{
struct hlsl_ir_constant *c;
@@ -427,7 +428,8 @@ struct hlsl_ir_constant *hlsl_new_uint_constant(struct hlsl_ctx *ctx, unsigned i
return c;
}
-struct hlsl_ir_node *hlsl_new_unary_expr(enum hlsl_ir_expr_op op, struct hlsl_ir_node *arg, struct source_location loc)
+struct hlsl_ir_node *hlsl_new_unary_expr(enum hlsl_ir_expr_op op,
+ struct hlsl_ir_node *arg, struct vkd3d_shader_location loc)
{
struct hlsl_ir_expr *expr;
@@ -454,7 +456,7 @@ struct hlsl_ir_node *hlsl_new_binary_expr(enum hlsl_ir_expr_op op, struct hlsl_i
return &expr->node;
}
-struct hlsl_ir_if *hlsl_new_if(struct hlsl_ir_node *condition, struct source_location loc)
+struct hlsl_ir_if *hlsl_new_if(struct hlsl_ir_node *condition, struct vkd3d_shader_location loc)
{
struct hlsl_ir_if *iff;
@@ -467,7 +469,7 @@ struct hlsl_ir_if *hlsl_new_if(struct hlsl_ir_node *condition, struct source_loc
return iff;
}
-struct hlsl_ir_load *hlsl_new_var_load(struct hlsl_ir_var *var, const struct source_location loc)
+struct hlsl_ir_load *hlsl_new_var_load(struct hlsl_ir_var *var, const struct vkd3d_shader_location loc)
{
struct hlsl_ir_load *load;
@@ -479,7 +481,7 @@ struct hlsl_ir_load *hlsl_new_var_load(struct hlsl_ir_var *var, const struct sou
}
struct hlsl_ir_swizzle *hlsl_new_swizzle(struct hlsl_ctx *ctx, DWORD s, unsigned int components,
- struct hlsl_ir_node *val, struct source_location *loc)
+ struct hlsl_ir_node *val, struct vkd3d_shader_location *loc)
{
struct hlsl_ir_swizzle *swizzle;
@@ -498,7 +500,7 @@ bool hlsl_type_is_void(const struct hlsl_type *type)
}
struct hlsl_ir_function_decl *hlsl_new_func_decl(struct hlsl_ctx *ctx, struct hlsl_type *return_type,
- struct list *parameters, const char *semantic, struct source_location loc)
+ struct list *parameters, const char *semantic, struct vkd3d_shader_location loc)
{
struct hlsl_ir_function_decl *decl;
diff --git a/libs/vkd3d-shader/hlsl.h b/libs/vkd3d-shader/hlsl.h
index 30c0215c..59bf3140 100644
--- a/libs/vkd3d-shader/hlsl.h
+++ b/libs/vkd3d-shader/hlsl.h
@@ -144,13 +144,6 @@ struct hlsl_struct_field
unsigned int reg_offset;
};
-struct source_location
-{
- const char *file;
- unsigned int line;
- unsigned int col;
-};
-
enum hlsl_ir_node_type
{
HLSL_IR_ASSIGNMENT = 0,
@@ -171,7 +164,7 @@ struct hlsl_ir_node
struct list uses;
- struct source_location loc;
+ struct vkd3d_shader_location loc;
/* Liveness ranges. "index" is the index of this instruction. Since this is
* essentially an SSA value, the earliest live point is the index. This is
@@ -215,7 +208,7 @@ struct hlsl_reg_reservation
struct hlsl_ir_var
{
struct hlsl_type *data_type;
- struct source_location loc;
+ struct vkd3d_shader_location loc;
const char *name;
const char *semantic;
unsigned int modifiers;
@@ -237,7 +230,7 @@ struct hlsl_ir_function_decl
{
struct hlsl_type *return_type;
struct hlsl_ir_var *return_var;
- struct source_location loc;
+ struct vkd3d_shader_location loc;
struct rb_entry entry;
struct hlsl_ir_function *func;
const char *semantic;
@@ -487,7 +480,7 @@ static inline struct hlsl_ir_swizzle *hlsl_ir_swizzle(const struct hlsl_ir_node
}
static inline void init_node(struct hlsl_ir_node *node, enum hlsl_ir_node_type type,
- struct hlsl_type *data_type, struct source_location loc)
+ struct hlsl_type *data_type, struct vkd3d_shader_location loc)
{
memset(node, 0, sizeof(*node));
node->type = type;
@@ -541,39 +534,39 @@ 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,
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 source_location loc) DECLSPEC_HIDDEN;
+ 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 *arg2) DECLSPEC_HIDDEN;
struct hlsl_ir_expr *hlsl_new_cast(struct hlsl_ir_node *node, struct hlsl_type *type,
- struct source_location *loc) DECLSPEC_HIDDEN;
+ struct vkd3d_shader_location *loc) DECLSPEC_HIDDEN;
struct hlsl_ir_function_decl *hlsl_new_func_decl(struct hlsl_ctx *ctx, struct hlsl_type *return_type,
- struct list *parameters, const char *semantic, struct source_location loc) DECLSPEC_HIDDEN;
-struct hlsl_ir_if *hlsl_new_if(struct hlsl_ir_node *condition, struct source_location loc) DECLSPEC_HIDDEN;
+ struct list *parameters, const char *semantic, struct vkd3d_shader_location loc) DECLSPEC_HIDDEN;
+struct hlsl_ir_if *hlsl_new_if(struct hlsl_ir_node *condition, struct vkd3d_shader_location loc) DECLSPEC_HIDDEN;
struct hlsl_ir_assignment *hlsl_new_simple_assignment(struct hlsl_ir_var *lhs,
struct hlsl_ir_node *rhs) 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_node *val, struct source_location *loc) DECLSPEC_HIDDEN;
+ struct hlsl_ir_node *val, struct vkd3d_shader_location *loc) DECLSPEC_HIDDEN;
struct hlsl_ir_var *hlsl_new_synthetic_var(struct hlsl_ctx *ctx, const char *name, struct hlsl_type *type,
- const struct source_location loc) DECLSPEC_HIDDEN;
+ const struct vkd3d_shader_location loc) DECLSPEC_HIDDEN;
struct hlsl_type *hlsl_new_type(struct hlsl_ctx *ctx, const char *name, enum hlsl_type_class type_class,
enum hlsl_base_type base_type, unsigned dimx, unsigned dimy) DECLSPEC_HIDDEN;
struct hlsl_ir_constant *hlsl_new_uint_constant(struct hlsl_ctx *ctx, unsigned int n,
- const struct source_location loc) DECLSPEC_HIDDEN;
+ const struct vkd3d_shader_location loc) DECLSPEC_HIDDEN;
struct hlsl_ir_node *hlsl_new_unary_expr(enum hlsl_ir_expr_op op, struct hlsl_ir_node *arg,
- struct source_location loc) DECLSPEC_HIDDEN;
-struct hlsl_ir_var *hlsl_new_var(const char *name, struct hlsl_type *type, const struct source_location loc,
+ struct vkd3d_shader_location loc) DECLSPEC_HIDDEN;
+struct hlsl_ir_var *hlsl_new_var(const char *name, struct hlsl_type *type, const struct vkd3d_shader_location loc,
const char *semantic, unsigned int modifiers,
const struct hlsl_reg_reservation *reg_reservation) DECLSPEC_HIDDEN;
-struct hlsl_ir_load *hlsl_new_var_load(struct hlsl_ir_var *var, const struct source_location loc) DECLSPEC_HIDDEN;
+struct hlsl_ir_load *hlsl_new_var_load(struct hlsl_ir_var *var, const struct vkd3d_shader_location loc) DECLSPEC_HIDDEN;
void hlsl_message(const char *fmt, ...) VKD3D_PRINTF_FUNC(1,2) DECLSPEC_HIDDEN;
-void hlsl_error(struct hlsl_ctx *ctx, const struct source_location loc,
+void hlsl_error(struct hlsl_ctx *ctx, const struct vkd3d_shader_location loc,
const char *fmt, ...) VKD3D_PRINTF_FUNC(3, 4) DECLSPEC_HIDDEN;
-void hlsl_warning(struct hlsl_ctx *ctx, const struct source_location loc,
+void hlsl_warning(struct hlsl_ctx *ctx, const struct vkd3d_shader_location loc,
const char *fmt, ...) VKD3D_PRINTF_FUNC(3, 4) DECLSPEC_HIDDEN;
-void hlsl_note(struct hlsl_ctx *ctx, const struct source_location loc, enum vkd3d_shader_log_level level,
+void hlsl_note(struct hlsl_ctx *ctx, const struct vkd3d_shader_location loc, enum vkd3d_shader_log_level level,
const char *fmt, ...) VKD3D_PRINTF_FUNC(4, 5) DECLSPEC_HIDDEN;
void hlsl_push_scope(struct hlsl_ctx *ctx) DECLSPEC_HIDDEN;
diff --git a/libs/vkd3d-shader/hlsl.l b/libs/vkd3d-shader/hlsl.l
index 7a3737ac..38b4bf1f 100644
--- a/libs/vkd3d-shader/hlsl.l
+++ b/libs/vkd3d-shader/hlsl.l
@@ -279,9 +279,9 @@ row_major {return KW_ROW_MAJOR; }
static void update_location(struct hlsl_ctx *ctx, YYLTYPE *lloc)
{
- lloc->file = ctx->source_file;
- lloc->col = ctx->column;
+ lloc->source_name = ctx->source_file;
lloc->line = ctx->line_no;
+ lloc->column = ctx->column;
ctx->column += yyget_leng(ctx->scanner);
}
diff --git a/libs/vkd3d-shader/hlsl.y b/libs/vkd3d-shader/hlsl.y
index d37f029e..15c9c9cd 100644
--- a/libs/vkd3d-shader/hlsl.y
+++ b/libs/vkd3d-shader/hlsl.y
@@ -26,7 +26,7 @@
#include "hlsl.h"
#include <stdio.h>
-#define HLSL_YYLTYPE struct source_location
+#define HLSL_YYLTYPE struct vkd3d_shader_location
struct parse_parameter
{
@@ -53,7 +53,7 @@ struct parse_initializer
struct parse_variable_def
{
struct list entry;
- struct source_location loc;
+ struct vkd3d_shader_location loc;
char *name;
uint32_t array_size;
@@ -129,7 +129,7 @@ static void debug_dump_decl(struct hlsl_type *type, DWORD modifiers, const char
TRACE("%s %s;\n", debug_hlsl_type(type), declname);
}
-static void check_invalid_matrix_modifiers(struct hlsl_ctx *ctx, DWORD modifiers, struct source_location loc)
+static void check_invalid_matrix_modifiers(struct hlsl_ctx *ctx, DWORD modifiers, struct vkd3d_shader_location loc)
{
if (modifiers & HLSL_MODIFIERS_MAJORITY_MASK)
hlsl_error(ctx, loc, "'row_major' or 'column_major' modifiers are only allowed for matrices.");
@@ -252,7 +252,7 @@ static bool implicit_compatible_data_types(struct hlsl_type *t1, struct hlsl_typ
}
static struct hlsl_ir_node *add_implicit_conversion(struct hlsl_ctx *ctx, struct list *instrs,
- struct hlsl_ir_node *node, struct hlsl_type *dst_type, struct source_location *loc)
+ struct hlsl_ir_node *node, struct hlsl_type *dst_type, struct vkd3d_shader_location *loc)
{
struct hlsl_type *src_type = node->data_type;
struct hlsl_ir_expr *cast;
@@ -321,7 +321,7 @@ static bool declare_variable(struct hlsl_ctx *ctx, struct hlsl_ir_var *decl, boo
return true;
}
-static DWORD add_modifiers(struct hlsl_ctx *ctx, DWORD modifiers, DWORD mod, const struct source_location loc)
+static DWORD add_modifiers(struct hlsl_ctx *ctx, DWORD modifiers, DWORD mod, const struct vkd3d_shader_location loc)
{
if (modifiers & mod)
{
@@ -371,7 +371,7 @@ enum loop_type
};
static struct list *create_loop(enum loop_type type, struct list *init, struct list *cond,
- struct list *iter, struct list *body, struct source_location loc)
+ struct list *iter, struct list *body, struct vkd3d_shader_location loc)
{
struct list *list = NULL;
struct hlsl_ir_loop *loop = NULL;
@@ -439,7 +439,7 @@ static void free_parse_initializer(struct parse_initializer *initializer)
}
static struct hlsl_ir_swizzle *get_swizzle(struct hlsl_ctx *ctx, struct hlsl_ir_node *value, const char *swizzle,
- struct source_location *loc)
+ struct vkd3d_shader_location *loc)
{
unsigned int len = strlen(swizzle), component = 0;
unsigned int i, set, swiz = 0;
@@ -521,7 +521,7 @@ static struct hlsl_ir_swizzle *get_swizzle(struct hlsl_ctx *ctx, struct hlsl_ir_
}
static struct hlsl_ir_jump *add_return(struct hlsl_ctx *ctx, struct list *instrs,
- struct hlsl_ir_node *return_value, struct source_location loc)
+ struct hlsl_ir_node *return_value, struct vkd3d_shader_location loc)
{
struct hlsl_type *return_type = ctx->cur_function->return_type;
struct hlsl_ir_jump *jump;
@@ -553,7 +553,7 @@ static struct hlsl_ir_jump *add_return(struct hlsl_ctx *ctx, struct list *instrs
}
static struct hlsl_ir_load *add_load(struct hlsl_ctx *ctx, 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 *offset, struct hlsl_type *data_type, const struct vkd3d_shader_location loc)
{
struct hlsl_ir_node *add = NULL;
struct hlsl_ir_load *load;
@@ -599,7 +599,7 @@ static struct hlsl_ir_load *add_load(struct hlsl_ctx *ctx, struct list *instrs,
}
static struct hlsl_ir_load *add_record_load(struct hlsl_ctx *ctx, struct list *instrs, struct hlsl_ir_node *record,
- const struct hlsl_struct_field *field, const struct source_location loc)
+ const struct hlsl_struct_field *field, const struct vkd3d_shader_location loc)
{
struct hlsl_ir_constant *c;
@@ -611,7 +611,7 @@ static struct hlsl_ir_load *add_record_load(struct hlsl_ctx *ctx, struct list *i
}
static struct hlsl_ir_load *add_array_load(struct hlsl_ctx *ctx, struct list *instrs, struct hlsl_ir_node *array,
- struct hlsl_ir_node *index, const struct source_location loc)
+ struct hlsl_ir_node *index, const struct vkd3d_shader_location loc)
{
const struct hlsl_type *expr_type = array->data_type;
struct hlsl_type *data_type;
@@ -671,7 +671,7 @@ bool hlsl_type_is_row_major(const struct hlsl_type *type)
}
static struct hlsl_type *apply_type_modifiers(struct hlsl_ctx *ctx, struct hlsl_type *type,
- unsigned int *modifiers, struct source_location loc)
+ unsigned int *modifiers, struct vkd3d_shader_location loc)
{
unsigned int default_majority = 0;
struct hlsl_type *new_type;
@@ -784,7 +784,7 @@ static bool add_typedef(struct hlsl_ctx *ctx, DWORD modifiers, struct hlsl_type
}
static bool add_func_parameter(struct hlsl_ctx *ctx, struct list *list,
- struct parse_parameter *param, const struct source_location loc)
+ struct parse_parameter *param, const struct vkd3d_shader_location loc)
{
struct hlsl_ir_var *var;
@@ -1003,7 +1003,7 @@ static enum hlsl_base_type expr_common_base_type(enum hlsl_base_type t1, enum hl
}
static struct hlsl_type *expr_common_type(struct hlsl_ctx *ctx, struct hlsl_type *t1, struct hlsl_type *t2,
- struct source_location *loc)
+ struct vkd3d_shader_location *loc)
{
enum hlsl_type_class type;
enum hlsl_base_type base;
@@ -1098,7 +1098,7 @@ static struct hlsl_type *expr_common_type(struct hlsl_ctx *ctx, struct hlsl_type
}
static struct hlsl_ir_expr *add_expr(struct hlsl_ctx *ctx, struct list *instrs,
- enum hlsl_ir_expr_op op, struct hlsl_ir_node *operands[3], struct source_location *loc)
+ enum hlsl_ir_expr_op op, struct hlsl_ir_node *operands[3], struct vkd3d_shader_location *loc)
{
struct hlsl_ir_expr *expr;
struct hlsl_type *type;
@@ -1152,7 +1152,7 @@ static struct list *append_unop(struct list *list, struct hlsl_ir_node *node)
}
static struct list *add_binary_expr(struct hlsl_ctx *ctx, struct list *list1, struct list *list2,
- enum hlsl_ir_expr_op op, struct source_location loc)
+ enum hlsl_ir_expr_op op, struct vkd3d_shader_location loc)
{
struct hlsl_ir_node *args[3] = {node_from_list(list1), node_from_list(list2)};
--
2.30.0
More information about the wine-devel
mailing list