[PATCH vkd3d v2 07/10] vkd3d-shader/hlsl: Add helpers for binary arithmetic operations.

Matteo Bruni matteo.mystral at gmail.com
Thu Oct 21 09:21:54 CDT 2021


On Fri, Oct 15, 2021 at 4:34 PM Giovanni Mascellani
<gmascellani at codeweavers.com> wrote:
>
> This commit moves the logic for casting operands to a common type
> out of add_expr, so that different helpers can use different logics
> (corresponding to the different typing rules used by e.g. arithmetic,
> comparison or bitwise operations).

Technically this isn't quite the case anymore, add_expr() is still
there unchanged after this patch. Some rewording might be in order.

> Signed-off-by: Giovanni Mascellani <gmascellani at codeweavers.com>
> ---
>  libs/vkd3d-shader/hlsl.y | 71 ++++++++++++++++++++++++----------------
>  1 file changed, 43 insertions(+), 28 deletions(-)
>
> diff --git a/libs/vkd3d-shader/hlsl.y b/libs/vkd3d-shader/hlsl.y
> index 0ed09732..7bbf0318 100644
> --- a/libs/vkd3d-shader/hlsl.y
> +++ b/libs/vkd3d-shader/hlsl.y
> @@ -1072,14 +1072,38 @@ static struct list *add_unary_expr(struct hlsl_ctx *ctx, struct list *instrs,
>      return instrs;
>  }
>
> -static struct list *add_binary_expr(struct hlsl_ctx *ctx, struct list *list1, struct list *list2,
> +static struct hlsl_ir_expr *add_binary_arithmetic_expr(struct hlsl_ctx *ctx, struct list *instrs,
> +        enum hlsl_ir_expr_op op, struct hlsl_ir_node *arg1, struct hlsl_ir_node *arg2,
> +        struct vkd3d_shader_location *loc)
> +{
> +    struct hlsl_type *common_type;
> +    enum hlsl_base_type base = expr_common_base_type(arg1->data_type->base_type, arg2->data_type->base_type);
> +    enum hlsl_type_class type;
> +    unsigned int dimx, dimy;
> +    struct hlsl_ir_node *args[HLSL_MAX_OPERANDS] = {0};

Style nitpick: we usually order declarations according to descending
line length when possible.



More information about the wine-devel mailing list