blob: 24767082fb16018217d8e4a237776ccef9f27983 [file] [log] [blame]
/* Automatically generated file */
#include <limits.h>
#include <riscv_vector.h>
#include <softrvv.h>
#include <springbok.h>
#include <stdio.h>
#include <stdlib.h>
#include <bit>
#include <tuple>
#include "pw_unit_test/framework.h"
#include "test_v_helpers.h"
namespace ${op_code}_vx_test {
namespace {
using namespace test_v_helpers;
uint8_t src_vector_1[MAXVL_BYTES];
uint8_t dest_vector[MAXVL_BYTES];
uint8_t ref_dest_vector[MAXVL_BYTES];
class ${op_code.capitalize()}Test : public ::testing::Test {
protected:
void SetUp() override { zero_vector_registers(); }
void TearDown() override { zero_vector_registers(); }
};
% for sew in [8, 16, 32]:
% for lmul in [1, 2, 4, 8]:
<%
var_type = "int%d_t" % sew
%>\
TEST_F(${op_code.capitalize()}Test, ${op_code.lower()}_vx${sew}m${lmul}) {
for (int i = 0; i < AVL_COUNT; i++) {
int32_t avl = AVLS[i];
int vlmax;
int vl;
std::tie(vlmax, vl) = vector_test_setup<${var_type}>(
VLMUL::LMUL_M${lmul}, avl,
{src_vector_1, dest_vector, ref_dest_vector});
if (avl > vlmax) {
continue;
}
${var_type} *ptr_vec_1 = reinterpret_cast<${var_type} *>(src_vector_1);
${var_type} *ptr_dest_vec = reinterpret_cast<${var_type} *>(dest_vector);
${var_type} *ptr_ref_dest_vec = reinterpret_cast<${var_type} *>(ref_dest_vector);
${var_type} test_val = static_cast<${var_type}>(rand());
// set up values to test up to index of the AVL
fill_random_vector<${var_type}>(ptr_vec_1, avl);
memset(dest_vector, 0, MAXVL_BYTES);
memset(ref_dest_vector, 0, MAXVL_BYTES);
// Generate reference vector
softrvv::${op_code}_vx<${var_type}>(ptr_ref_dest_vec, ptr_vec_1, &test_val, avl);
// Load vector registers
__asm__ volatile("vle${sew}.v v8, (%0)" : : "r"(ptr_vec_1));
// Run target instruction
__asm__ volatile("${op_code}.vx v24, v8, %[RS1]" ::[RS1] "r"(test_val));
// Store result vector register
__asm__ volatile("vse${sew}.v v24, (%0)" : : "r"(ptr_dest_vec));
// Check vector elements
assert_vec_elem_eq<${var_type}>(vlmax, dest_vector, ref_dest_vector);
}
}
%endfor
%endfor
} // namespace
} // namespace ${op_code}_vx_test