blob: 7c81a14d78c6662fcd03763b012c4760a7f0d007 [file] [log] [blame]
#ifndef SOFTRVV_VNSRA_H
#define SOFTRVV_VNSRA_H
#include <stddef.h>
namespace softrvv {
template <typename T1, typename T2>
void vnsra_vx(T1 *dest, T2 *src1, const T1 *src2, int32_t avl) {
// Only low lg2(SEW*2) bits are used for shift
static_assert(sizeof(T1) * 2 == sizeof(T2));
const T1 low_bits_mask = sizeof(T2) * 8 - 1;
const T1 shift = *src2 & low_bits_mask;
for (int32_t idx = 0; idx < avl; idx++) {
dest[idx] = static_cast<T1>(src1[idx] >> shift);
}
}
template <typename T1, typename T2>
void vnsra_vv(T1 *dest, T2 *src1, T1 *src2, int32_t avl) {
// Only low lg2(SEW*2) bits are used for shift
static_assert(sizeof(T1) * 2 == sizeof(T2));
const T1 low_bits_mask = sizeof(T2) * 8 - 1;
for (int32_t idx = 0; idx < avl; idx++) {
dest[idx] = static_cast<T1>(src1[idx] >> (src2[idx] & low_bits_mask));
}
}
} // namespace softrvv
#endif // SOFTRVV_VNSRA_H