vsetvl: Add test for vsetvl in asm. Change-Id: Ie372c934fbcf292c73539de9b778a28d3523cda4
diff --git a/test_v_helpers/include/test_v_helpers.h b/test_v_helpers/include/test_v_helpers.h index bb83f51..ef1236e 100644 --- a/test_v_helpers/include/test_v_helpers.h +++ b/test_v_helpers/include/test_v_helpers.h
@@ -18,7 +18,7 @@ enum VLMUL { -/* // Fractional LMUL not supported by our compiler +/* // Fractional LMUL not supported by our intrinsic compiler LMUL_MF8 = 5, LMUL_MF4 = 6, LMUL_MF2 = 7, @@ -29,6 +29,11 @@ LMUL_M8 = 3, }; +uint32_t get_vtype(VSEW sew, VLMUL lmul, bool tail_agnostic, bool mask_agnostic); + +// vsetvl rd, rs1, rs2 # rd = new vl, rs1 = AVL, rs2 = new vtype value +uint32_t set_vsetvl(VSEW sew, VLMUL lmul, uint32_t avl, bool tail_agnostic, bool mask_agnostic); + int set_vsetvl_intrinsic(VSEW sew, VLMUL lmul, uint32_t avl); int get_vsetvlmax_intrinsic(VSEW sew, VLMUL lmul);
diff --git a/test_v_helpers/test_v_helpers.cpp b/test_v_helpers/test_v_helpers.cpp index d092069..a98f217 100644 --- a/test_v_helpers/test_v_helpers.cpp +++ b/test_v_helpers/test_v_helpers.cpp
@@ -4,6 +4,25 @@ namespace test_v_helpers { +uint32_t get_vtype(VSEW sew, VLMUL lmul, bool tail_agnostic, + bool mask_agnostic) { + return (static_cast<int>(lmul) & 0x7) | + (static_cast<int>(sew) & 0x7) << 3 | + (tail_agnostic & 0x1) << 6 | + (mask_agnostic & 0x1) << 7; +} + +uint32_t set_vsetvl(VSEW sew, VLMUL lmul, uint32_t avl, bool tail_agnostic, bool mask_agnostic) { + uint32_t vtype = get_vtype(sew, lmul, tail_agnostic, mask_agnostic); + uint32_t vl; + __asm__ volatile( + "vsetvl %[VL], %[AVL], %[VTYPE]" + : [VL] "=r" (vl) + : [AVL] "r" (avl), [VTYPE] "r" (vtype) + ); + return vl; +} + int set_vsetvl_intrinsic(VSEW sew, VLMUL lmul, uint32_t avl) { switch(lmul) { case VLMUL::LMUL_M1:
diff --git a/test_vsetvl/test_vsetvl.cpp b/test_vsetvl/test_vsetvl.cpp index d57a163..6ae44d8 100644 --- a/test_vsetvl/test_vsetvl.cpp +++ b/test_vsetvl/test_vsetvl.cpp
@@ -32,6 +32,10 @@ size_t vl = set_vsetvl_intrinsic(sew, vlmul, AVLS[i]); EXPECT_EQ(vl, calculate_vl(width, AVLS[i], lmul)); } + for (int i = 0; i < AVL_COUNT; i++) { + uint32_t vl = set_vsetvl(sew, vlmul, AVLS[i], false, false); + EXPECT_EQ(vl, calculate_vl(width, AVLS[i], lmul)); + } } static void test_vsetvlmax(VSEW sew, VLMUL vlmul, uint32_t width, float lmul) {