• 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 #ifndef MAPLE_IR_INCLUDE_INTRINSICS_H
17 #define MAPLE_IR_INCLUDE_INTRINSICS_H
18 #include "prim_types.h"
19 #include "intrinsic_op.h"
20 
21 namespace maple {
22 enum IntrinArgType {
23     kArgTyUndef,
24     kArgTyVoid,
25     kArgTyI8,
26     kArgTyI16,
27     kArgTyI32,
28     kArgTyI64,
29     kArgTyU8,
30     kArgTyU16,
31     kArgTyU32,
32     kArgTyU64,
33     kArgTyU1,
34     kArgTyPtr,
35     kArgTyRef,
36     kArgTyA32,
37     kArgTyA64,
38     kArgTyF32,
39     kArgTyF64,
40     kArgTyF128,
41     kArgTyDynany
42 };
43 
44 class MIRType;    // circular dependency exists, no other choice
45 class MIRModule;  // circular dependency exists, no other choice
46 struct IntrinDesc {
47     static constexpr int kMaxArgsNum = 7;
48     const char *name;
49     IntrinArgType argTypes[1 + kMaxArgsNum];  // argTypes[0] is the return type
50 
51     MIRType *GetReturnType() const;
52     MIRType *GetArgType(uint32 index) const;
53     MIRType *GetTypeFromArgTy(IntrinArgType argType) const;
54     static MIRType *jsValueType;
55     static MIRModule *mirModule;
56     static void InitMIRModule(MIRModule *mirModule);
57     static IntrinDesc intrinTable[INTRN_LAST + 1];
58 };
59 }  // namespace maple
60 #endif  // MAPLE_IR_INCLUDE_INTRINSICS_H
61