Skip to content

Commit e838453

Browse files
Chao Liualistair23
authored andcommitted
target/riscv: refactor VSTART_CHECK_EARLY_EXIT() to accept vl as a parameter
Some vector instructions are special, such as the vlm.v instruction, where setting its vl actually sets evl = (vl + 7) >> 3. To improve maintainability, we will uniformly use VSTART_CHECK_EARLY_EXIT() to check for the condition vstart >= vl. This function will also handle cases involving evl. Fixes: df4252b ("target/riscv/vector_helpers: do early exit when vstart >= vl") Signed-off-by: Chao Liu <[email protected]> Reviewed-by: Daniel Henrique Barboza <[email protected]> Message-ID: <f575979874e323a9e0da7796aa391c7d87e56f88.1741573286.git.lc00631@tecorigin.com> Signed-off-by: Alistair Francis <[email protected]>
1 parent ec6411a commit e838453

File tree

4 files changed

+57
-60
lines changed

4 files changed

+57
-60
lines changed

target/riscv/vcrypto_helper.c

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ static inline void xor_round_key(AESState *round_state, AESState *round_key)
222222
uint32_t total_elems = vext_get_total_elems(env, desc, 4); \
223223
uint32_t vta = vext_vta(desc); \
224224
\
225-
VSTART_CHECK_EARLY_EXIT(env); \
225+
VSTART_CHECK_EARLY_EXIT(env, vl); \
226226
\
227227
for (uint32_t i = env->vstart / 4; i < env->vl / 4; i++) { \
228228
AESState round_key; \
@@ -248,7 +248,7 @@ static inline void xor_round_key(AESState *round_state, AESState *round_key)
248248
uint32_t total_elems = vext_get_total_elems(env, desc, 4); \
249249
uint32_t vta = vext_vta(desc); \
250250
\
251-
VSTART_CHECK_EARLY_EXIT(env); \
251+
VSTART_CHECK_EARLY_EXIT(env, vl); \
252252
\
253253
for (uint32_t i = env->vstart / 4; i < env->vl / 4; i++) { \
254254
AESState round_key; \
@@ -309,7 +309,7 @@ void HELPER(vaeskf1_vi)(void *vd_vptr, void *vs2_vptr, uint32_t uimm,
309309
uint32_t total_elems = vext_get_total_elems(env, desc, 4);
310310
uint32_t vta = vext_vta(desc);
311311

312-
VSTART_CHECK_EARLY_EXIT(env);
312+
VSTART_CHECK_EARLY_EXIT(env, vl);
313313

314314
uimm &= 0b1111;
315315
if (uimm > 10 || uimm == 0) {
@@ -357,7 +357,7 @@ void HELPER(vaeskf2_vi)(void *vd_vptr, void *vs2_vptr, uint32_t uimm,
357357
uint32_t total_elems = vext_get_total_elems(env, desc, 4);
358358
uint32_t vta = vext_vta(desc);
359359

360-
VSTART_CHECK_EARLY_EXIT(env);
360+
VSTART_CHECK_EARLY_EXIT(env, vl);
361361

362362
uimm &= 0b1111;
363363
if (uimm > 14 || uimm < 2) {
@@ -465,7 +465,7 @@ void HELPER(vsha2ms_vv)(void *vd, void *vs1, void *vs2, CPURISCVState *env,
465465
uint32_t total_elems;
466466
uint32_t vta = vext_vta(desc);
467467

468-
VSTART_CHECK_EARLY_EXIT(env);
468+
VSTART_CHECK_EARLY_EXIT(env, env->vl);
469469

470470
for (uint32_t i = env->vstart / 4; i < env->vl / 4; i++) {
471471
if (sew == MO_32) {
@@ -582,7 +582,7 @@ void HELPER(vsha2ch32_vv)(void *vd, void *vs1, void *vs2, CPURISCVState *env,
582582
uint32_t total_elems;
583583
uint32_t vta = vext_vta(desc);
584584

585-
VSTART_CHECK_EARLY_EXIT(env);
585+
VSTART_CHECK_EARLY_EXIT(env, env->vl);
586586

587587
for (uint32_t i = env->vstart / 4; i < env->vl / 4; i++) {
588588
vsha2c_32(((uint32_t *)vs2) + 4 * i, ((uint32_t *)vd) + 4 * i,
@@ -602,7 +602,7 @@ void HELPER(vsha2ch64_vv)(void *vd, void *vs1, void *vs2, CPURISCVState *env,
602602
uint32_t total_elems;
603603
uint32_t vta = vext_vta(desc);
604604

605-
VSTART_CHECK_EARLY_EXIT(env);
605+
VSTART_CHECK_EARLY_EXIT(env, env->vl);
606606

607607
for (uint32_t i = env->vstart / 4; i < env->vl / 4; i++) {
608608
vsha2c_64(((uint64_t *)vs2) + 4 * i, ((uint64_t *)vd) + 4 * i,
@@ -622,7 +622,7 @@ void HELPER(vsha2cl32_vv)(void *vd, void *vs1, void *vs2, CPURISCVState *env,
622622
uint32_t total_elems;
623623
uint32_t vta = vext_vta(desc);
624624

625-
VSTART_CHECK_EARLY_EXIT(env);
625+
VSTART_CHECK_EARLY_EXIT(env, env->vl);
626626

627627
for (uint32_t i = env->vstart / 4; i < env->vl / 4; i++) {
628628
vsha2c_32(((uint32_t *)vs2) + 4 * i, ((uint32_t *)vd) + 4 * i,
@@ -642,7 +642,7 @@ void HELPER(vsha2cl64_vv)(void *vd, void *vs1, void *vs2, CPURISCVState *env,
642642
uint32_t total_elems;
643643
uint32_t vta = vext_vta(desc);
644644

645-
VSTART_CHECK_EARLY_EXIT(env);
645+
VSTART_CHECK_EARLY_EXIT(env, env->vl);
646646

647647
for (uint32_t i = env->vstart / 4; i < env->vl / 4; i++) {
648648
vsha2c_64(((uint64_t *)vs2) + 4 * i, ((uint64_t *)vd) + 4 * i,
@@ -676,7 +676,7 @@ void HELPER(vsm3me_vv)(void *vd_vptr, void *vs1_vptr, void *vs2_vptr,
676676
uint32_t *vs1 = vs1_vptr;
677677
uint32_t *vs2 = vs2_vptr;
678678

679-
VSTART_CHECK_EARLY_EXIT(env);
679+
VSTART_CHECK_EARLY_EXIT(env, env->vl);
680680

681681
for (int i = env->vstart / 8; i < env->vl / 8; i++) {
682682
uint32_t w[24];
@@ -777,7 +777,7 @@ void HELPER(vsm3c_vi)(void *vd_vptr, void *vs2_vptr, uint32_t uimm,
777777
uint32_t *vs2 = vs2_vptr;
778778
uint32_t v1[8], v2[8], v3[8];
779779

780-
VSTART_CHECK_EARLY_EXIT(env);
780+
VSTART_CHECK_EARLY_EXIT(env, env->vl);
781781

782782
for (int i = env->vstart / 8; i < env->vl / 8; i++) {
783783
for (int k = 0; k < 8; k++) {
@@ -802,7 +802,7 @@ void HELPER(vghsh_vv)(void *vd_vptr, void *vs1_vptr, void *vs2_vptr,
802802
uint32_t vta = vext_vta(desc);
803803
uint32_t total_elems = vext_get_total_elems(env, desc, 4);
804804

805-
VSTART_CHECK_EARLY_EXIT(env);
805+
VSTART_CHECK_EARLY_EXIT(env, env->vl);
806806

807807
for (uint32_t i = env->vstart / 4; i < env->vl / 4; i++) {
808808
uint64_t Y[2] = {vd[i * 2 + 0], vd[i * 2 + 1]};
@@ -841,7 +841,7 @@ void HELPER(vgmul_vv)(void *vd_vptr, void *vs2_vptr, CPURISCVState *env,
841841
uint32_t vta = vext_vta(desc);
842842
uint32_t total_elems = vext_get_total_elems(env, desc, 4);
843843

844-
VSTART_CHECK_EARLY_EXIT(env);
844+
VSTART_CHECK_EARLY_EXIT(env, env->vl);
845845

846846
for (uint32_t i = env->vstart / 4; i < env->vl / 4; i++) {
847847
uint64_t Y[2] = {brev8(vd[i * 2 + 0]), brev8(vd[i * 2 + 1])};
@@ -879,7 +879,7 @@ void HELPER(vsm4k_vi)(void *vd, void *vs2, uint32_t uimm5, CPURISCVState *env,
879879
uint32_t esz = sizeof(uint32_t);
880880
uint32_t total_elems = vext_get_total_elems(env, desc, esz);
881881

882-
VSTART_CHECK_EARLY_EXIT(env);
882+
VSTART_CHECK_EARLY_EXIT(env, env->vl);
883883

884884
for (uint32_t i = group_start; i < group_end; ++i) {
885885
uint32_t vstart = i * egs;
@@ -937,7 +937,7 @@ void HELPER(vsm4r_vv)(void *vd, void *vs2, CPURISCVState *env, uint32_t desc)
937937
uint32_t esz = sizeof(uint32_t);
938938
uint32_t total_elems = vext_get_total_elems(env, desc, esz);
939939

940-
VSTART_CHECK_EARLY_EXIT(env);
940+
VSTART_CHECK_EARLY_EXIT(env, env->vl);
941941

942942
for (uint32_t i = group_start; i < group_end; ++i) {
943943
uint32_t vstart = i * egs;
@@ -973,7 +973,7 @@ void HELPER(vsm4r_vs)(void *vd, void *vs2, CPURISCVState *env, uint32_t desc)
973973
uint32_t esz = sizeof(uint32_t);
974974
uint32_t total_elems = vext_get_total_elems(env, desc, esz);
975975

976-
VSTART_CHECK_EARLY_EXIT(env);
976+
VSTART_CHECK_EARLY_EXIT(env, env->vl);
977977

978978
for (uint32_t i = group_start; i < group_end; ++i) {
979979
uint32_t vstart = i * egs;

0 commit comments

Comments
 (0)