Skip to content

Commit

Permalink
[zvknf] adding macros
Browse files Browse the repository at this point in the history
  • Loading branch information
nibrunie committed Apr 7, 2023
1 parent 47ea9c8 commit 4b81532
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
22 changes: 22 additions & 0 deletions riscv/zvk_ext_macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,14 @@
require_extension(EXT_ZVKNED); \
} while (0)

// Ensures that the ZVKNED extension (vector AES single round) is present,
// which depends on vector.
#define require_zvknf \
do { \
require_vector(true); \
require_extension(EXT_ZVKNF); \
} while (0)

// Ensures that a ZVK extension supporting SHA-512 is present.
// For SHA-512, this support is only present in Zvknhb.
// Also ensures that vector support is present.
Expand Down Expand Up @@ -971,6 +979,20 @@
(DST)[bidx] = (A)[bidx] ^ (B)[bidx]; \
}

// Performs "DST = A ^ B;", i.e., DST (overwritten) receives
// the xor of the bytes in A and B (both unchanged).
#define EGU8x16_XOR_EGU32x4(DST, A, B) \
for (std::size_t bidx = 0; bidx < 16; ++bidx) { \
(DST)[bidx] = (A)[bidx] ^ ((((B)[bidx / 4]) >> ((bidx % 4) * 8)) & 0xff); \
}

// Performs "MUT_A ^= CONST_B;", i.e., xor of the bytes
// in A (mutated) with the bytes in B (unchanged).
#define EGU8x16_XOREQ_EGU32x4(MUT_A, CONST_B) \
for (std::size_t bidx = 0; bidx < 16; ++bidx) { \
(MUT_A)[bidx] ^= ((((CONST_B)[bidx / 4]) >> ((bidx % 4) * 8)) & 0xff); \
}

// Performs "DST = A ^ B;", i.e., DST (overwritten) receives
// the xor of the bytes in A and B (both unchanged).
#define EGU32x4_XOR(DST, A, B) \
Expand Down
14 changes: 14 additions & 0 deletions riscv/zvkned_ext_macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,20 @@
require_egw_fits(128); \
} while (false)

// vaese*.vv instruction constraints. Those are the same as the .vs ones,
// except for the overlap constraint that is not present for .vv variants.
// - Zvknf is enabled
// - LMUL * VLEN <= EGW (128)
//
// The constraint that vstart and vl are both EGS (4) aligned
// is checked in the VI_ZVK_..._EGU32x4_..._LOOP macros.
#define require_vaes_vv_all_rounds_constraints \
do { \
require_zvknf; \
require_vsew(32); \
require_egw_fits(128); \
} while (false)

// vaeskf*.vi instruction constraints. Those are the same as the .vv ones.
#define require_vaeskf_vi_constraints \
do { \
Expand Down

0 comments on commit 4b81532

Please sign in to comment.