On 9/3/21 7:13 AM, Matteo Bruni wrote:
On Thu, Sep 2, 2021 at 12:23 AM Zebediah Figura zfigura@codeweavers.com wrote:
The parameters are specified as a list of hlsl_ir_var structures, but add_call() is given an array of hlsl_ir_node pointers. Even if the former were changed to use an array instead, it's not worth trying to reuse the same function for both cases.
Signed-off-by: Zebediah Figura zfigura@codeweavers.com
libs/vkd3d-shader/hlsl.y | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-)
diff --git a/libs/vkd3d-shader/hlsl.y b/libs/vkd3d-shader/hlsl.y index ddc429ba..2512bcc0 100644 --- a/libs/vkd3d-shader/hlsl.y +++ b/libs/vkd3d-shader/hlsl.y @@ -790,25 +790,17 @@ static struct hlsl_reg_reservation parse_reg_reservation(const char *reg_string) return reservation; }
-static const struct hlsl_ir_function_decl *get_overloaded_func(struct rb_tree *funcs, char *name,
struct list *params, bool exact_signature)
+static const struct hlsl_ir_function_decl *get_func_decl(struct rb_tree *funcs, char *name, struct list *params) { struct hlsl_ir_function *func; struct rb_entry *entry;
- entry = rb_get(funcs, name);
- if (entry)
- if ((entry = rb_get(funcs, name))) { func = RB_ENTRY_VALUE(entry, struct hlsl_ir_function, entry);
entry = rb_get(&func->overloads, params);
if (!entry)
{
if (!exact_signature)
FIXME("No exact match, search for a compatible overloaded function (if any).\n");
return NULL;
}
return RB_ENTRY_VALUE(entry, struct hlsl_ir_function_decl, entry);
if ((entry = rb_get(&func->overloads, params)))
}return RB_ENTRY_VALUE(entry, struct hlsl_ir_function_decl, entry); } return NULL;
@@ -1813,7 +1805,7 @@ hlsl_prog: { const struct hlsl_ir_function_decl *decl;
decl = get_overloaded_func(&ctx->functions, $2.name, $2.decl->parameters, true);
decl = get_func_decl(&ctx->functions, $2.name, $2.decl->parameters); if (decl && !decl->func->intrinsic) { if (decl->body && $2.decl->body)
I have a question / concern unrelated to the patch itself but in the same general area. There's a hlsl_get_func_decl() function, currently used only to find the entry point, that basically returns the first overload of a function. Should we make sure to throw an error in there if there are multiple overloads? Also, are there other instances where we'll need to use that function? I'm wondering if it makes sense to rename it to hlsl_get_entry_point_function() or something and move it into hlsl.y.
It's used in two places: to find the entry point, and to check if a variable name was previously defined as a function. But yeah, we probably want to return an hlsl_ir_function instead, for both purposes. I'll put it on the to-do list.