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 }; 42 43 class MIRType; // circular dependency exists, no other choice 44 class MIRModule; // circular dependency exists, no other choice 45 struct IntrinDesc { 46 static constexpr int kMaxArgsNum = 7; 47 const char *name; 48 IntrinArgType argTypes[1 + kMaxArgsNum]; // argTypes[0] is the return type 49 50 MIRType *GetReturnType() const; 51 MIRType *GetArgType(uint32 index) const; 52 MIRType *GetTypeFromArgTy(IntrinArgType argType) const; 53 static MIRType *jsValueType; 54 static MIRModule *mirModule; 55 static void InitMIRModule(MIRModule *mirModule); 56 static IntrinDesc intrinTable[INTRN_LAST + 1]; 57 }; 58 } // namespace maple 59 #endif // MAPLE_IR_INCLUDE_INTRINSICS_H 60