aboutsummaryrefslogtreecommitdiff
path: root/riscv/insns/vsm4r_vv.h
blob: 9a18cecee0e3ec52d5b5172f1e2ded7e7fe02b4f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// vsm4r.vv vd, vs2

#include "zvksed_ext_macros.h"

require_vsm4_constraints;

VI_ZVK_VD_VS2_EGU32x4_NOVM_LOOP(
  {},
  {
    // vd = {x0, x1,x2, x3} <- vd
    EXTRACT_EGU32x4_WORDS_LE(vd, x0, x1, x2, x3);
    // {rk0, rk1, rk2, rk3} <- vs2
    EXTRACT_EGU32x4_WORDS_LE(vs2, rk0, rk1, rk2, rk3);

    uint32_t B;
    uint32_t S;

    B = x1 ^ x2 ^ x3 ^ rk0;
    S = ZVKSED_SUB_BYTES(B);
    const uint32_t x4 = ZVKSED_ROUND(x0, S);

    B = x2 ^ x3 ^ x4 ^ rk1;
    S = ZVKSED_SUB_BYTES(B);
    const uint32_t x5 = ZVKSED_ROUND(x1, S);

    B = x3 ^ x4 ^ x5 ^ rk2;
    S = ZVKSED_SUB_BYTES(B);
    const uint32_t x6 = ZVKSED_ROUND(x2, S);

    B = x4 ^ x5 ^ x6 ^ rk3;
    S = ZVKSED_SUB_BYTES(B);
    const uint32_t x7 = ZVKSED_ROUND(x3, S);

    // Update the destination register.
    SET_EGU32x4_LE(vd, x4, x5, x6, x7);
  }
);