Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vector: crypto: fix constraint checks for vector-crypto instructions #1888

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions riscv/insns/vghsh_vv.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@

#include "zvk_ext_macros.h"

const uint32_t EGS = 4;

require_zvkg;
require(P.VU.vsew == 32);
require_egw_fits(128);
require(P.VU.vl->read() % EGS == 0);
VI_CHECK_SSS(true)

VI_ZVK_VD_VS1_VS2_EGU32x4_NOVM_LOOP(
{},
Expand Down
4 changes: 4 additions & 0 deletions riscv/insns/vgmul_vv.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@

#include "zvk_ext_macros.h"

const uint32_t EGS = 4;

require_zvkg;
require(P.VU.vsew == 32);
require_egw_fits(128);
require(P.VU.vl->read() % EGS == 0);
VI_CHECK_SSS(false)

VI_ZVK_VD_VS2_EGU32x4_NOVM_LOOP(
{},
Expand Down
1 change: 1 addition & 0 deletions riscv/insns/vsm3c_vi.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "zvksh_ext_macros.h"

require_vsm3_constraints;
VI_CHECK_SSS(false)

VI_ZVK_VD_VS2_ZIMM5_EGU32x8_NOVM_LOOP(
{},
Expand Down
1 change: 1 addition & 0 deletions riscv/insns/vsm3me_vv.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
(ZVKSH_P1((M16) ^ (M9) ^ ZVK_ROL32((M3), 15)) ^ ZVK_ROL32((M13), 7) ^ (M6))

require_vsm3_constraints;
VI_CHECK_SSS(true)

VI_ZVK_VD_VS1_VS2_EGU32x8_NOVM_LOOP(
{},
Expand Down
1 change: 1 addition & 0 deletions riscv/insns/vsm4k_vi.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ static constexpr uint32_t zvksed_ck[32] = {
};

require_vsm4_constraints;
VI_CHECK_SSS(false)

VI_ZVK_VD_VS2_ZIMM5_EGU32x4_NOVM_LOOP(
{},
Expand Down
5 changes: 4 additions & 1 deletion riscv/insns/vsm4r_vs.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@

#include "zvksed_ext_macros.h"

const uint32_t EGS = 4;

require_vsm4_constraints;
require_align(insn.rd(), P.VU.vflmul);
// No overlap of vd and vs2.
require(insn.rd() != insn.rs2());
require_noover(insn.rs2(), 1, insn.rd(), P.VU.vflmul);

VI_ZVK_VD_VS2_NOOPERANDS_PRELOOP_EGU32x4_NOVM_LOOP(
{},
Expand Down
2 changes: 2 additions & 0 deletions riscv/insns/vsm4r_vv.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

#include "zvksed_ext_macros.h"


require_vsm4_constraints;
VI_CHECK_SSS(false)

VI_ZVK_VD_VS2_EGU32x4_NOVM_LOOP(
{},
Expand Down
1 change: 1 addition & 0 deletions riscv/insns/vwsll_vi.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "zvk_ext_macros.h"

require_zvbb;
VI_CHECK_DSS(false);

VI_ZVK_VI_WIDENING_ULOOP({
const reg_t shift = zimm5 & ((2 * sew) - 1);
Expand Down
1 change: 1 addition & 0 deletions riscv/insns/vwsll_vv.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "zvk_ext_macros.h"

require_zvbb;
VI_CHECK_DSS(true);

VI_ZVK_VV_WIDENING_ULOOP({
const reg_t shift = (vs1 & ((2 * sew) - 1));
Expand Down
1 change: 1 addition & 0 deletions riscv/insns/vwsll_vx.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "zvk_ext_macros.h"

require_zvbb;
VI_CHECK_DSS(false);

VI_ZVK_VX_WIDENING_ULOOP({
const reg_t shift = (rs1 & ((2 * sew) - 1));
Expand Down
12 changes: 11 additions & 1 deletion riscv/zvkned_ext_macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,13 @@
// is checked in the VI_ZVK_..._EGU32x4_..._LOOP macros.
#define require_vaes_vs_constraints \
do { \
const uint32_t EGS = 4; \
require_zvkned; \
require(P.VU.vl->read() % EGS == 0); \
require(P.VU.vsew == 32); \
require_egw_fits(128); \
require(insn.rd() != insn.rs2()); \
require_align(insn.rd(), P.VU.vflmul); \
require_noover(insn.rs2(), 1, insn.rd(), P.VU.vflmul); \
} while (false)

// vaes*.vv instruction constraints. Those are the same as the .vs ones,
Expand All @@ -30,17 +33,24 @@
// is checked in the VI_ZVK_..._EGU32x4_..._LOOP macros.
#define require_vaes_vv_constraints \
do { \
const uint32_t EGS = 4; \
require_zvkned; \
require(P.VU.vl->read() % EGS == 0); \
require(P.VU.vsew == 32); \
require_egw_fits(128); \
VI_CHECK_SSS(false) \
} while (false)

// vaeskf*.vi instruction constraints. Those are the same as the .vv ones.
#define require_vaeskf_vi_constraints \
do { \
const uint32_t EGS = 4; \
require_zvkned; \
require(P.VU.vstart->read() % EGS == 0); \
require(P.VU.vl->read() % EGS == 0); \
require(P.VU.vsew == 32); \
require_egw_fits(128); \
VI_CHECK_SSS(false) \
} while (false)

#define VAES_XTIME(A) (((A) << 1) ^ (((A) & 0x80) ? 0x1b : 0))
Expand Down
1 change: 1 addition & 0 deletions riscv/zvknh_ext_macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
// macros.
#define require_vsha2_common_constraints \
do { \
VI_CHECK_SSS(true) \
require(P.VU.vsew == 32 || P.VU.vsew == 64); \
require(insn.rd() != insn.rs1()); \
require(insn.rd() != insn.rs2()); \
Expand Down
3 changes: 3 additions & 0 deletions riscv/zvksed_ext_macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,12 @@
// is checked in the VI_ZVK_..._EGU32x4_..._LOOP macros.
#define require_vsm4_constraints \
do { \
const uint32_t EGS = 4; \
require_zvksed; \
require(P.VU.vsew == 32); \
require_egw_fits(128); \
require(P.VU.vstart->read() % EGS == 0); \
require(P.VU.vl->read() % EGS == 0); \
} while (false)

// Returns a uint32_t value constructed from the 4 bytes (uint8_t)
Expand Down
3 changes: 3 additions & 0 deletions riscv/zvksh_ext_macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,12 @@
// is checked in the VI_ZVK_..._EGU32x8_..._LOOP macros.
#define require_vsm3_constraints \
do { \
const uint32_t EGS = 4; \
require_zvksh; \
require(P.VU.vsew == 32); \
require_egw_fits(256); \
require(P.VU.vstart->read() % EGS == 0); \
require(P.VU.vl->read() % EGS == 0); \
require(insn.rd() != insn.rs2()); \
} while (false)

Expand Down