• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 "intrinsics.h"
17 #include "mir_module.h"
18 #include "mir_type.h"
19 #include "mir_builder.h"
20 
21 #include "gtest/gtest.h"
22 #include <iostream>
23 using namespace maple;
24 using namespace std;
25 namespace {
TEST(GetTypeFromArgTy_FUNC,t01)26 TEST(GetTypeFromArgTy_FUNC, t01)
27 {
28     struct IntrinDesc IntrinDesc_struc;
29     IntrinArgType input_ls[] = {kArgTyVoid, kArgTyI8, kArgTyI16, kArgTyI32, kArgTyI64, kArgTyU8,
30                                 kArgTyU16, kArgTyU32, kArgTyU64, kArgTyU1,
31                                 kArgTyA64, kArgTyF32, kArgTyF64};
32     PrimType res_ls[] = {
33             PTY_void, PTY_i8, PTY_i16, PTY_i32, PTY_i64, PTY_u8,
34             PTY_u16, PTY_u32, PTY_u64, PTY_u1,
35             PTY_a64, PTY_f32, PTY_f64
36     };
37     MIRType *mirtype_ptr;
38     int n = sizeof(input_ls) / sizeof(input_ls[0]);
39     for (int i = 0; i < n; i++)
40     {
41         mirtype_ptr = IntrinDesc_struc.GetTypeFromArgTy(input_ls[i]);
42         ASSERT_TRUE(mirtype_ptr != nullptr);
43         EXPECT_EQ(mirtype_ptr->GetPrimType(), res_ls[i]);
44     }
45 }
46 }  // namespace
47