Skip to content

Commit 8143005

Browse files
committed
[Zvbc32e] enabling 32-bit vclmul/vclmulh
1 parent 11ee6d0 commit 8143005

File tree

9 files changed

+45
-15
lines changed

9 files changed

+45
-15
lines changed

disasm/disasm.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2184,7 +2184,7 @@ void disassembler_t::add_instructions(const isa_parser_t* isa, bool strict)
21842184
#undef DISASM_VECTOR_VV_VX_VIU_ZIMM6
21852185
}
21862186

2187-
if (ext_enabled(EXT_ZVBC)) {
2187+
if (ext_enabled(EXT_ZVBC) || ext_enabled(EXT_ZVBC32E)) {
21882188
#define DISASM_VECTOR_VV_VX(name) \
21892189
DEFINE_VECTOR_VV(name##_vv); \
21902190
DEFINE_VECTOR_VX(name##_vx)

disasm/isa_parser.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,8 @@ isa_parser_t::isa_parser_t(const char* str, const char *priv)
282282
extension_table[EXT_ZVBB] = true;
283283
} else if (ext_str == "zvbc") {
284284
extension_table[EXT_ZVBC] = true;
285+
} else if (ext_str == "zvbc32e") {
286+
extension_table[EXT_ZVBC32E] = true;
285287
} else if (ext_str == "zvfbfmin") {
286288
extension_table[EXT_ZVFBFMIN] = true;
287289
} else if (ext_str == "zvfbfwma") {

riscv/decode_macros.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ static inline bool is_aligned(const unsigned val, const unsigned pos)
163163
#define require_rv32 require(xlen == 32)
164164
#define require_extension(s) require(p->extension_enabled(s))
165165
#define require_either_extension(A,B) require(p->extension_enabled(A) || p->extension_enabled(B));
166+
#define require_either_extension_condition(A,cA, B, cB) require(p->extension_enabled(A) && (cA) || p->extension_enabled(B) && (cB));
166167
#define require_impl(s) require(p->supports_impl(s))
167168
#define require_fp STATE.fflags->verify_permissions(insn, false)
168169
#define require_accelerator require(STATE.sstatus->enabled(SSTATUS_XS))

riscv/insns/vclmul_vv.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22

33
#include "zvk_ext_macros.h"
44

5-
require_zvbc;
6-
require(P.VU.vsew == 64);
5+
require_any_zvbc;
6+
require_either_extension_condition(EXT_ZVBC, P.VU.vsew == 64, EXT_ZVBC32E, P.VU.vsew == 32);
77

88
VI_VV_ULOOP
99
({
10-
// Perform a carryless multiplication 64bx64b on each 64b element,
11-
// return the low 64b of the 128b product.
10+
// Perform a carryless multiplication SEW-bit x SEW-bit on each SEW-bit element,
11+
// return the low SEW bits of the (2.SEW)-bit product.
1212
// <https://en.wikipedia.org/wiki/Carry-less_product>
1313
vd = 0;
1414
for (std::size_t bit_idx = 0; bit_idx < sew; ++bit_idx) {

riscv/insns/vclmul_vx.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22

33
#include "zvk_ext_macros.h"
44

5-
require_zvbc;
6-
require(P.VU.vsew == 64);
5+
require_any_zvbc;
6+
require_either_extension_condition(EXT_ZVBC, P.VU.vsew == 64, EXT_ZVBC32E, P.VU.vsew == 32);
77

88
VI_VX_ULOOP
99
({
10-
// Perform a carryless multiplication 64bx64b on each 64b element,
11-
// return the low 64b of the 128b product.
10+
// Perform a carryless multiplication SEW-bit x SEW-bit on each SEW-bit element,
11+
// return the low SEW bits of the (2.SEW)-bit product.
1212
// <https://en.wikipedia.org/wiki/Carry-less_product>
1313
vd = 0;
1414
for (std::size_t bit_idx = 0; bit_idx < sew; ++bit_idx) {

riscv/insns/vclmulh_vv.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
#include "zvk_ext_macros.h"
44

5-
require_zvbc;
6-
require(P.VU.vsew == 64);
5+
require_any_zvbc;
6+
require_either_extension_condition(EXT_ZVBC, P.VU.vsew == 64, EXT_ZVBC32E, P.VU.vsew == 32);
77

88
VI_VV_ULOOP
99
({

riscv/insns/vclmulh_vx.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22

33
#include "zvk_ext_macros.h"
44

5-
require_zvbc;
6-
require(P.VU.vsew == 64);
5+
require_any_zvbc;
6+
require_either_extension_condition(EXT_ZVBC, P.VU.vsew == 64, EXT_ZVBC32E, P.VU.vsew == 32);
77

88
VI_VX_ULOOP
99
({
10-
// Perform a carryless multiplication 64bx64b on each 64b element,
11-
// return the high 64b of the 128b product.
10+
// Perform a carryless multiplication SEW-bit x SEW-bit on each SEW-bit element,
11+
// return the high SEW bits of the (2.SEW)-bit product.
1212
// <https://en.wikipedia.org/wiki/Carry-less_product>
1313
vd = 0;
1414
for (std::size_t bit_idx = 1; bit_idx < sew; ++bit_idx) {

riscv/isa_parser.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,11 @@ typedef enum {
6060
EXT_ZILSD,
6161
EXT_ZVBB,
6262
EXT_ZVBC,
63+
EXT_ZVBC32E,
6364
EXT_ZVFBFMIN,
6465
EXT_ZVFBFWMA,
6566
EXT_ZVKG,
67+
EXT_ZVKGS,
6668
EXT_ZVKNED,
6769
EXT_ZVKNHA,
6870
EXT_ZVKNHB,

riscv/zvk_ext_macros.h

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,23 @@
2929
require_extension(EXT_ZVBC); \
3030
} while (0)
3131

32+
// Ensures that the ZVBC32e extension (vector carryless multiplication
33+
// with 32-bit elements) is present, and the vector unit is enabled
34+
// and in a valid state.
35+
#define require_zvbc32e \
36+
do { \
37+
require_vector(true); \
38+
require_extension(EXT_ZVBC32E); \
39+
} while (0)
40+
41+
// Ensures that any ZVBC extensions (vector carryless multiplication)
42+
// is present, and the vector unit is enabled and in a valid state.
43+
#define require_any_zvbc \
44+
do { \
45+
require_vector(true); \
46+
require_either_extension(EXT_ZVBC, EXT_ZVBC32E); \
47+
} while (0)
48+
3249
// Ensures that the ZVKG extension (vector Galois Field Multiplication)
3350
// is present, and the vector unit is enabled and in a valid state.
3451
#define require_zvkg \
@@ -37,6 +54,14 @@
3754
require_extension(EXT_ZVKG); \
3855
} while (0)
3956

57+
// Ensures that the ZVKGS extension (vector Galois Field Multiplication
58+
// with vector-scalar variant) is present, and the vector unit is
59+
// enabled and in a valid state.
60+
#define require_zvkgs \
61+
do { \
62+
require_vector(true); \
63+
require_extension(EXT_ZVKGS); \
64+
} while (0)
4065
// Ensures that a ZVK extension supporting SHA-256 is present.
4166
// For SHA-256, this support is present in either Zvknha or Zvknhb.
4267
// Also ensures that the vector unit is enabled and in a valid state.

0 commit comments

Comments
 (0)