blob: f2b8ba91794ce923bb54f06b95983d6cf1c83b90 [file] [log] [blame]
// Copyright 2023 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
<%!
import vec_test_helpers
%>\
<%def name="test_opivv_opivx(template_helper, src2, src1, rs1, ref_vv, ref_vx)">
<%
src1 = vec_test_helpers.to_carr_str(src1)
src2 = vec_test_helpers.to_carr_str(src2)
ref_vv = vec_test_helpers.to_carr_str(ref_vv)
ref_vx = vec_test_helpers.to_carr_str(ref_vx)
%>\
namespace softrvv_${template_helper.op_code}_test {
namespace {
${insert_variable_init(template_helper, src2, src1, rs1, ref_vv, ref_vx)}
class SoftRvv${template_helper.op_code.capitalize()}Test : public ::testing::Test {
protected:
void SetUp() override { memset(dest, 0, sizeof(dest)); }
};
${insert_test(template_helper)}\
} // namespace
} // namespace softrvv_${op}_test\
</%def>\
<%def name="insert_variable_init(template_helper, src2, src1, rs1, ref_vv, ref_vx)">
<%
var_types = template_helper.get_var_types()
%>\
${var_types.src1_type} src1[] = {${src1}};
${var_types.src2_type} src2[] = {${src2}};
${var_types.imm_type} rs1 = ${rs1};
const int kAVL = sizeof(src1)/sizeof(src1[0]);
${var_types.dest_type} dest[kAVL];
${var_types.dest_type} ref_vv[kAVL] = {${ref_vv}};
${var_types.dest_type} ref_vx[kAVL] = {${ref_vx}};
</%def>\
<%def name="insert_test(template_helper)">
<%
var_types = template_helper.get_var_types()
datatypes = template_helper.get_softrvv_template_data_type()
%>\
TEST_F(SoftRvv${template_helper.op_code.capitalize()}Test, VV) {
softrvv::${template_helper.op_code}_vv<${datatypes}>(dest, src2, src1, kAVL);\
${insert_check(template_helper, var_types.dest_type, "ref_vv")}\
}
TEST_F(SoftRvv${template_helper.op_code.capitalize()}Test, VX) {
softrvv::${template_helper.op_code}_vx<${datatypes}>(dest, src2, &rs1, kAVL);\
${insert_check(template_helper, var_types.dest_type, "ref_vx")}\
}
</%def>\
<%def name="insert_check(template_helper, dest_type, ref_var)">
% if template_helper.is_destination_mask_register():
assert_vec_mask_eq<${dest_type}>(kAVL, dest, ${ref_var});
% else:
assert_vec_elem_eq<${dest_type}>(kAVL, dest, ${ref_var});
% endif
</%def>\