Browse Source
Implement the Zvbc instructions
- vclmul.{vv,vx}, vector carryless multiply low
- vclmulh.{vv,vx}, vector carryless multiply high
Signed-off-by: Eric Gouriou <ego@rivosinc.com>
pull/1303/head
5 changed files with 87 additions and 0 deletions
@ -0,0 +1,20 @@ |
|||
// vclmul.vv vd, vs2, vs1, vm
|
|||
|
|||
#include "zvk_ext_macros.h" |
|||
|
|||
require_zvbc; |
|||
require(P.VU.vsew == 64); |
|||
|
|||
VI_VV_ULOOP |
|||
({ |
|||
// Perform a carryless multiplication 64bx64b on each 64b element,
|
|||
// return the low 64b of the 128b product.
|
|||
// <https://en.wikipedia.org/wiki/Carry-less_product>
|
|||
vd = 0; |
|||
for (std::size_t bit_idx = 0; bit_idx < sew; ++bit_idx) { |
|||
const reg_t mask = ((reg_t) 1) << bit_idx; |
|||
if ((vs1 & mask) != 0) { |
|||
vd ^= vs2 << bit_idx; |
|||
} |
|||
} |
|||
}) |
|||
@ -0,0 +1,20 @@ |
|||
// vclmul.vx vd, vs2, rs1, vm
|
|||
|
|||
#include "zvk_ext_macros.h" |
|||
|
|||
require_zvbc; |
|||
require(P.VU.vsew == 64); |
|||
|
|||
VI_VX_ULOOP |
|||
({ |
|||
// Perform a carryless multiplication 64bx64b on each 64b element,
|
|||
// return the low 64b of the 128b product.
|
|||
// <https://en.wikipedia.org/wiki/Carry-less_product>
|
|||
vd = 0; |
|||
for (std::size_t bit_idx = 0; bit_idx < sew; ++bit_idx) { |
|||
const reg_t mask = ((reg_t) 1) << bit_idx; |
|||
if ((rs1 & mask) != 0) { |
|||
vd ^= vs2 << bit_idx; |
|||
} |
|||
} |
|||
}) |
|||
@ -0,0 +1,20 @@ |
|||
// vclmulh.vv vd, vs2, vs1, vm
|
|||
|
|||
#include "zvk_ext_macros.h" |
|||
|
|||
require_zvbc; |
|||
require(P.VU.vsew == 64); |
|||
|
|||
VI_VV_ULOOP |
|||
({ |
|||
// Perform a carryless multiplication 64bx64b on each 64b element,
|
|||
// return the high 64b of the 128b product.
|
|||
// <https://en.wikipedia.org/wiki/Carry-less_product>
|
|||
vd = 0; |
|||
for (std::size_t bit_idx = 1; bit_idx < sew; ++bit_idx) { |
|||
const reg_t mask = ((reg_t) 1) << bit_idx; |
|||
if ((vs1 & mask) != 0) { |
|||
vd ^= ((reg_t)vs2) >> (sew - bit_idx); |
|||
} |
|||
} |
|||
}) |
|||
@ -0,0 +1,20 @@ |
|||
// vclmulh.vx vd, vs2, rs1, vm
|
|||
|
|||
#include "zvk_ext_macros.h" |
|||
|
|||
require_zvbc; |
|||
require(P.VU.vsew == 64); |
|||
|
|||
VI_VX_ULOOP |
|||
({ |
|||
// Perform a carryless multiplication 64bx64b on each 64b element,
|
|||
// return the high 64b of the 128b product.
|
|||
// <https://en.wikipedia.org/wiki/Carry-less_product>
|
|||
vd = 0; |
|||
for (std::size_t bit_idx = 1; bit_idx < sew; ++bit_idx) { |
|||
const reg_t mask = ((reg_t) 1) << bit_idx; |
|||
if ((rs1 & mask) != 0) { |
|||
vd ^= ((reg_t)vs2) >> (sew - bit_idx); |
|||
} |
|||
} |
|||
}) |
|||
Loading…
Reference in new issue