|
36 | 36 | } \ |
37 | 37 | } while (0) |
38 | 38 |
|
| 39 | +#define REQUIRE_ZBR(ctx) do { \ |
| 40 | + if (!ctx->cfg_ptr->ext_zbr) { \ |
| 41 | + return false; \ |
| 42 | + } \ |
| 43 | +} while (0) |
| 44 | + |
39 | 45 | #define REQUIRE_ZBS(ctx) do { \ |
40 | 46 | if (!ctx->cfg_ptr->ext_zbs) { \ |
41 | 47 | return false; \ |
@@ -569,3 +575,34 @@ static bool trans_xperm8(DisasContext *ctx, arg_xperm8 *a) |
569 | 575 | REQUIRE_ZBKX(ctx); |
570 | 576 | return gen_arith(ctx, a, EXT_NONE, gen_helper_xperm8, NULL); |
571 | 577 | } |
| 578 | + |
| 579 | +static bool gen_crc(DisasContext *ctx, arg_r2 *a, |
| 580 | + void (*func)(TCGv, TCGv, TCGv), TCGv tsz) |
| 581 | +{ |
| 582 | + REQUIRE_ZBR(ctx); |
| 583 | + TCGv dest = dest_gpr(ctx, a->rd); |
| 584 | + TCGv src1 = get_gpr(ctx, a->rs1, EXT_NONE); |
| 585 | + |
| 586 | + func(dest, src1, tsz); |
| 587 | + gen_set_gpr(ctx, a->rd, dest); |
| 588 | + |
| 589 | + return true; |
| 590 | +} |
| 591 | + |
| 592 | +#define TRANS_CRC32(NAME, SIZE) \ |
| 593 | + static bool trans_crc32_##NAME(DisasContext *ctx, arg_r2 *a) \ |
| 594 | + { if (SIZE == 8) { REQUIRE_64BIT(ctx); }; \ |
| 595 | + return gen_crc(ctx, a, gen_helper_crc32, tcg_constant_tl(SIZE)); } |
| 596 | +#define TRANS_CRC32C(NAME, SIZE) \ |
| 597 | + static bool trans_crc32c_##NAME(DisasContext *ctx, arg_r2 *a) \ |
| 598 | + { if (SIZE == 8) { REQUIRE_64BIT(ctx); }; \ |
| 599 | + return gen_crc(ctx, a, gen_helper_crc32c, tcg_constant_tl(SIZE)); } |
| 600 | + |
| 601 | +TRANS_CRC32(b, 1); |
| 602 | +TRANS_CRC32(h, 2); |
| 603 | +TRANS_CRC32(w, 4); |
| 604 | +TRANS_CRC32(d, 8); |
| 605 | +TRANS_CRC32C(b, 1); |
| 606 | +TRANS_CRC32C(h, 2); |
| 607 | +TRANS_CRC32C(w, 4); |
| 608 | +TRANS_CRC32C(d, 8); |
0 commit comments