Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- libs/vkd3d-shader/hlsl.c | 1 - libs/vkd3d-shader/hlsl.h | 1 - libs/vkd3d-shader/hlsl.y | 20 ++++++++++++++++++-- libs/vkd3d-shader/hlsl_sm1.c | 4 ---- 4 files changed, 18 insertions(+), 8 deletions(-)
diff --git a/libs/vkd3d-shader/hlsl.c b/libs/vkd3d-shader/hlsl.c index d0be0750..e4070572 100644 --- a/libs/vkd3d-shader/hlsl.c +++ b/libs/vkd3d-shader/hlsl.c @@ -1062,7 +1062,6 @@ static const char *debug_expr_op(const struct hlsl_ir_expr *expr) "sat",
"+", - "-", "*", "/",
diff --git a/libs/vkd3d-shader/hlsl.h b/libs/vkd3d-shader/hlsl.h index e566ac7d..3b0e5207 100644 --- a/libs/vkd3d-shader/hlsl.h +++ b/libs/vkd3d-shader/hlsl.h @@ -302,7 +302,6 @@ enum hlsl_ir_expr_op HLSL_IR_UNOP_SAT,
HLSL_IR_BINOP_ADD, - HLSL_IR_BINOP_SUB, HLSL_IR_BINOP_MUL, HLSL_IR_BINOP_DIV,
diff --git a/libs/vkd3d-shader/hlsl.y b/libs/vkd3d-shader/hlsl.y index 34cdb543..2754514d 100644 --- a/libs/vkd3d-shader/hlsl.y +++ b/libs/vkd3d-shader/hlsl.y @@ -1118,7 +1118,7 @@ static enum hlsl_ir_expr_op op_from_assignment(enum parse_assign_op op) { 0, HLSL_IR_BINOP_ADD, - HLSL_IR_BINOP_SUB, + 0, HLSL_IR_BINOP_MUL, HLSL_IR_BINOP_DIV, HLSL_IR_BINOP_MOD, @@ -1176,12 +1176,23 @@ static struct hlsl_ir_node *add_assignment(struct hlsl_ctx *ctx, struct list *in struct hlsl_ir_expr *copy; DWORD writemask = 0;
+ if (assign_op == ASSIGN_OP_SUB) + { + struct hlsl_ir_node *args[3] = {rhs}; + struct hlsl_ir_expr *expr; + + if (!(expr = add_expr(ctx, instrs, HLSL_IR_UNOP_NEG, args, &rhs->loc))) + return NULL; + rhs = &expr->node; + assign_op = ASSIGN_OP_ADD; + } if (assign_op != ASSIGN_OP_ASSIGN) { enum hlsl_ir_expr_op op = op_from_assignment(assign_op); struct hlsl_ir_node *args[3] = {lhs, rhs}; struct hlsl_ir_expr *expr;
+ assert(op); if (!(expr = add_expr(ctx, instrs, op, args, &rhs->loc))) return NULL; rhs = &expr->node; @@ -2909,7 +2920,12 @@ add_expr: } | add_expr '-' mul_expr { - $$ = add_binary_expr(ctx, $1, $3, HLSL_IR_BINOP_SUB, @2); + struct hlsl_ir_node *neg; + + if (!(neg = hlsl_new_unary_expr(ctx, HLSL_IR_UNOP_NEG, node_from_list($3), @2))) + YYABORT; + list_add_tail($3, &neg->entry); + $$ = add_binary_expr(ctx, $1, $3, HLSL_IR_BINOP_ADD, @2); }
shift_expr: diff --git a/libs/vkd3d-shader/hlsl_sm1.c b/libs/vkd3d-shader/hlsl_sm1.c index ca02f01c..8ea663dc 100644 --- a/libs/vkd3d-shader/hlsl_sm1.c +++ b/libs/vkd3d-shader/hlsl_sm1.c @@ -620,10 +620,6 @@ static void write_sm1_expr(struct hlsl_ctx *ctx, struct vkd3d_bytecode_buffer *b write_sm1_binary_op(ctx, buffer, D3DSIO_MUL, &instr->reg, &arg1->reg, &arg2->reg); break;
- case HLSL_IR_BINOP_SUB: - write_sm1_binary_op(ctx, buffer, D3DSIO_SUB, &instr->reg, &arg1->reg, &arg2->reg); - break; - case HLSL_IR_UNOP_NEG: write_sm1_unary_op(ctx, buffer, D3DSIO_MOV, &instr->reg, &arg1->reg, D3DSPSM_NEG); break;