1 /*
2 * Copyright (c) 2023 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16 #include "mir_nodes.h"
17 #include <algorithm>
18 #include <stack>
19 #include "maple_string.h"
20 #include "mir_function.h"
21 #include "namemangler.h"
22 #include "opcode_info.h"
23 #include "printing.h"
24 #include "utils.h"
25
26 #include "gtest/gtest.h"
27 #include <iostream>
28 using namespace std;
29 using namespace maple;
30
31 namespace {
32
TEST(GetIntrinsicName_FUNC,t01)33 TEST(GetIntrinsicName_FUNC, t01)
34 {
35 std::vector<MIRIntrinsicID> input_ls_intrinsic_js = {
36 INTRN_ADD_WITH_OVERFLOW, INTRN_SUB_WITH_OVERFLOW, INTRN_MUL_WITH_OVERFLOW};
37 std::vector<const char *> output_ls_intrinsic_js = {
38 "ADD_WITH_OVERFLOW", "SUB_WITH_OVERFLOW", "MUL_WITH_OVERFLOW"};
39
40 std::vector<MIRIntrinsicID> input_ls_intrinsic_c = {INTRN_C_clz32, INTRN_C_clz64};
41 std::vector<const char *> output_ls_intrinsic_c = {"C_clz32", "C_clz64"};
42
43 ASSERT_EQ(input_ls_intrinsic_js.size(), output_ls_intrinsic_js.size());
44 ASSERT_EQ(input_ls_intrinsic_c.size(), output_ls_intrinsic_c.size());
45 for (int i = 0; i < input_ls_intrinsic_js.size(); i++)
46 {
47 ASSERT_STREQ(output_ls_intrinsic_js[i], GetIntrinsicName(input_ls_intrinsic_js[i]));
48 }
49 for (int i = 0; i < input_ls_intrinsic_c.size(); i++)
50 {
51 ASSERT_STREQ(output_ls_intrinsic_c[i], GetIntrinsicName(input_ls_intrinsic_c[i]));
52 }
53 }
54 } // namespace