/*
 * Copyright (c) 2023 Huawei Device Co., Ltd.
 * 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.
 */

// DEF_MIR_INTRINSIC(STR, NAME, INTRN_CLASS, RETURN_TYPE, ARG0, ARG1, ARG2, ARG3, ARG4, ARG5)
DEF_MIR_INTRINSIC(UNDEFINED,\
                  nullptr, kIntrnUndef, kArgTyUndef, kArgTyUndef, kArgTyUndef, kArgTyUndef, kArgTyUndef, kArgTyUndef, kArgTyUndef)
DEF_MIR_INTRINSIC(DEX_ATOMIC_INC,\
                  "__dex_ainc", kIntrnIsAtomic, kArgTyI32, kArgTyDynany, kArgTyUndef, kArgTyUndef, kArgTyUndef, kArgTyUndef, kArgTyUndef)
DEF_MIR_INTRINSIC(DEX_ATOMIC_DEC,\
                  "__dex_adec", kIntrnIsAtomic, kArgTyI32, kArgTyDynany, kArgTyUndef, kArgTyUndef, kArgTyUndef, kArgTyUndef, kArgTyUndef)
DEF_MIR_INTRINSIC(MPL_ATOMIC_EXCHANGE_PTR,\
                  "__mpl_atomic_exchange_ptr", kIntrnIsAtomic, kArgTyPtr, kArgTyPtr, kArgTyUndef, kArgTyUndef, kArgTyUndef, kArgTyUndef, kArgTyUndef)
DEF_MIR_INTRINSIC(MPL_PROF_COUNTER_INC,\
                  "__mpl_prof_counter_inc", INTRNNOSIDEEFFECT | INTRNISSPECIAL, kArgTyVoid, kArgTyU32, kArgTyUndef, kArgTyUndef, kArgTyUndef, kArgTyUndef, kArgTyUndef)
DEF_MIR_INTRINSIC(MPL_CLEAR_STACK,\
                  "__mpl_clear_stack", kIntrnUndef, kArgTyVoid, kArgTyDynany, kArgTyDynany, kArgTyUndef, kArgTyUndef, kArgTyUndef, kArgTyUndef)
DEF_MIR_INTRINSIC(MPL_GET_VTAB_FUNC,\
                  "MCC_getFuncPtrFromVtab", kIntrnUndef, kArgTyA64, kArgTyDynany, kArgTyDynany, kArgTyUndef, kArgTyUndef, kArgTyUndef, kArgTyUndef)
DEF_MIR_INTRINSIC(MPL_READ_OVTABLE_ENTRY,\
                  "__mpl_const_offset", INTRNISPURE, kArgTyA32, kArgTyDynany, kArgTyUndef, kArgTyUndef, kArgTyUndef, kArgTyUndef, kArgTyUndef)
DEF_MIR_INTRINSIC(MPL_READ_OVTABLE_ENTRY2,\
                  "__mpl_const_offset2", INTRNISPURE, kArgTyA32, kArgTyDynany, kArgTyDynany, kArgTyUndef, kArgTyUndef, kArgTyUndef, kArgTyUndef)
DEF_MIR_INTRINSIC(MPL_READ_OVTABLE_ENTRY_LAZY,\
                  "__mpl_const_offset_lazy", INTRNNOSIDEEFFECT, kArgTyA32, kArgTyDynany, kArgTyUndef, kArgTyUndef, kArgTyUndef, kArgTyUndef, kArgTyUndef)
DEF_MIR_INTRINSIC(MPL_READ_OVTABLE_ENTRY_VTAB_LAZY,\
                  "__mpl_const_offset_vtab_lazy", INTRNISPURE, kArgTyDynany, kArgTyDynany, kArgTyDynany, kArgTyDynany, kArgTyUndef, kArgTyUndef, kArgTyUndef)
DEF_MIR_INTRINSIC(MPL_READ_OVTABLE_ENTRY_FIELD_LAZY,\
                  "__mpl_const_offset_field_lazy", INTRNISPURE, kArgTyA32, kArgTyDynany, kArgTyDynany, kArgTyDynany, kArgTyUndef, kArgTyUndef, kArgTyUndef)
DEF_MIR_INTRINSIC(MPL_READ_ARRAYCLASS_CACHE_ENTRY,\
                  "__mpl_const_arrayclass_cache", kIntrnUndef, kArgTyPtr, kArgTyU32, kArgTyDynany, kArgTyDynany, kArgTyUndef, kArgTyUndef, kArgTyUndef)

// start of RC Intrinsics with one parameters
DEF_MIR_INTRINSIC(MCCSetPermanent,\
                  "MCC_SetObjectPermanent", INTRNISRC | INTRNNOSIDEEFFECT, kArgTyVoid, kArgTyRef)
DEF_MIR_INTRINSIC(MCCIncRef,\
                  "MCC_IncRef_NaiveRCFast", INTRNISRC | INTRNNOSIDEEFFECT, kArgTyVoid, kArgTyRef)
DEF_MIR_INTRINSIC(MCCDecRef,\
                  "MCC_DecRef_NaiveRCFast", INTRNISRC | INTRNNOSIDEEFFECT, kArgTyVoid, kArgTyRef)
DEF_MIR_INTRINSIC(MCCDecRefReset,\
                  "MCC_ClearLocalStackRef", INTRNISRC | INTRNNOSIDEEFFECT, kArgTyVoid, kArgTyPtr)
DEF_MIR_INTRINSIC(MCCLoadRefSVol,\
                  "MCC_LoadVolatileStaticField", INTRNISRC | INTRNNOSIDEEFFECT, kArgTyVoid, kArgTyRef)
DEF_MIR_INTRINSIC(MCCLoadRefS,\
                  "MCC_LoadRefStatic", INTRNISRC | INTRNNOSIDEEFFECT, kArgTyVoid, kArgTyRef)
DEF_MIR_INTRINSIC(MCCSetObjectPermanent,\
                  "MCC_SetObjectPermanent", INTRNISRC | INTRNNOSIDEEFFECT, kArgTyVoid, kArgTyRef)

// start of RC Intrinsics with two parameters
DEF_MIR_INTRINSIC(MCCCheck,\
                  "MCC_CheckRefCount", INTRNISRC | INTRNNOSIDEEFFECT, kArgTyVoid, kArgTyRef, kArgTyU32)
DEF_MIR_INTRINSIC(MCCCheckArrayStore,\
                  "MCC_Reflect_Check_Arraystore", INTRNISRC | INTRNNOSIDEEFFECT, kArgTyVoid, kArgTyRef, kArgTyRef)
DEF_MIR_INTRINSIC(MCCIncDecRef,\
                  "MCC_IncDecRef_NaiveRCFast", INTRNISRC | INTRNNOSIDEEFFECT, kArgTyVoid, kArgTyRef, kArgTyRef)
DEF_MIR_INTRINSIC(MCCIncDecRefReset,\
                  "MCC_IncDecRefReset", INTRNISRC | INTRNNOSIDEEFFECT, kArgTyVoid, kArgTyRef, kArgTyPtr)
DEF_MIR_INTRINSIC(MCCDecRefResetPair,\
                  "MCC_DecRefResetPair", INTRNISRC | INTRNNOSIDEEFFECT, kArgTyVoid, kArgTyPtr, kArgTyPtr)
DEF_MIR_INTRINSIC(MCCLoadWeakVol,\
                  "MCC_LoadVolatileWeakField", INTRNISRC | INTRNNOSIDEEFFECT, kArgTyVoid, kArgTyRef, kArgTyRef)
DEF_MIR_INTRINSIC(MCCLoadWeak,\
                  "MCC_LoadWeakField", INTRNISRC | INTRNNOSIDEEFFECT, kArgTyVoid, kArgTyRef, kArgTyRef)
DEF_MIR_INTRINSIC(MCCLoadRef,\
                  "MCC_LoadRefField_NaiveRCFast", INTRNISRC | INTRNNOSIDEEFFECT, kArgTyVoid, kArgTyRef, kArgTyRef)
DEF_MIR_INTRINSIC(MCCLoadRefVol,\
                  "MCC_LoadVolatileField", INTRNISRC | INTRNNOSIDEEFFECT, kArgTyVoid, kArgTyRef, kArgTyRef)
DEF_MIR_INTRINSIC(MCCWriteReferent,\
                  "MCC_WriteReferent", INTRNISRC | INTRNNOSIDEEFFECT, kArgTyVoid, kArgTyRef, kArgTyRef)
DEF_MIR_INTRINSIC(MCCWriteSVolNoInc,\
                  "MCC_WriteVolatileStaticFieldNoInc", INTRNISRC | INTRNNOSIDEEFFECT, kArgTyVoid, kArgTyRef, kArgTyRef)
DEF_MIR_INTRINSIC(MCCWriteSVolNoDec,\
                  "MCC_WriteVolatileStaticFieldNoDec", INTRNISRC | INTRNNOSIDEEFFECT, kArgTyVoid, kArgTyRef, kArgTyRef)
DEF_MIR_INTRINSIC(MCCWriteSVolNoRC,\
                  "MCC_WriteVolatileStaticFieldNoRC", INTRNISRC | INTRNNOSIDEEFFECT, kArgTyVoid, kArgTyRef, kArgTyRef)
DEF_MIR_INTRINSIC(MCCWriteSVol,\
                  "MCC_WriteVolatileStaticField", INTRNISRC | INTRNNOSIDEEFFECT, kArgTyVoid, kArgTyRef, kArgTyRef)
DEF_MIR_INTRINSIC(MCCWriteSNoInc,\
                  "MCC_WriteRefFieldStaticNoInc", INTRNISRC | INTRNNOSIDEEFFECT, kArgTyVoid, kArgTyRef, kArgTyRef)
DEF_MIR_INTRINSIC(MCCWriteSNoDec,\
                  "MCC_WriteRefFieldStaticNoDec", INTRNISRC | INTRNNOSIDEEFFECT, kArgTyVoid, kArgTyRef, kArgTyRef)
DEF_MIR_INTRINSIC(MCCWriteSNoRC,\
                  "MCC_WriteRefFieldStaticNoRC", INTRNISRC | INTRNNOSIDEEFFECT, kArgTyVoid, kArgTyRef, kArgTyRef)
DEF_MIR_INTRINSIC(MCCWriteS,\
                  "MCC_WriteRefFieldStatic", INTRNISRC | INTRNNOSIDEEFFECT, kArgTyVoid, kArgTyRef, kArgTyRef)

// start of RC intrinsics with three parameters
DEF_MIR_INTRINSIC(MCCWriteVolNoInc,\
                  "MCC_WriteVolatileFieldNoInc", INTRNISRC | INTRNNOSIDEEFFECT, kArgTyVoid, kArgTyRef, kArgTyRef, kArgTyRef)
DEF_MIR_INTRINSIC(MCCWriteVolNoDec,\
                  "MCC_WriteVolatileFieldNoDec", INTRNISRC | INTRNNOSIDEEFFECT, kArgTyVoid, kArgTyRef, kArgTyRef, kArgTyRef)
DEF_MIR_INTRINSIC(MCCWriteVolNoRC,\
                  "MCC_WriteVolatileFieldNoRC", INTRNISRC | INTRNNOSIDEEFFECT, kArgTyVoid, kArgTyRef, kArgTyRef, kArgTyRef)
DEF_MIR_INTRINSIC(MCCWriteVol,\
                  "MCC_WriteVolatileField", INTRNISRC | INTRNNOSIDEEFFECT, kArgTyVoid, kArgTyRef, kArgTyRef, kArgTyRef)
DEF_MIR_INTRINSIC(MCCWriteNoInc,\
                  "MCC_WriteRefFieldNoInc", INTRNISRC | INTRNNOSIDEEFFECT, kArgTyVoid, kArgTyRef, kArgTyRef, kArgTyRef)
DEF_MIR_INTRINSIC(MCCWriteNoDec,\
                  "MCC_WriteRefFieldNoDec", INTRNISRC | INTRNNOSIDEEFFECT, kArgTyVoid, kArgTyRef, kArgTyRef, kArgTyRef)
DEF_MIR_INTRINSIC(MCCWriteNoRC,\
                  "MCC_WriteRefFieldNoRC", INTRNISRC | INTRNNOSIDEEFFECT, kArgTyVoid, kArgTyRef, kArgTyRef, kArgTyRef)
DEF_MIR_INTRINSIC(MCCWrite,\
                  "MCC_WriteRefField", INTRNISRC | INTRNNOSIDEEFFECT, kArgTyVoid, kArgTyRef, kArgTyRef, kArgTyRef)
DEF_MIR_INTRINSIC(MCCWriteVolWeak,\
                  "MCC_WriteVolatileWeakField", INTRNISRC | INTRNNOSIDEEFFECT, kArgTyVoid, kArgTyRef, kArgTyRef, kArgTyRef)
DEF_MIR_INTRINSIC(MCCWriteWeak,\
                  "MCC_WriteWeakField", INTRNISRC | INTRNNOSIDEEFFECT, kArgTyVoid, kArgTyRef, kArgTyRef, kArgTyRef)

DEF_MIR_INTRINSIC(MPL_MEMSET_LOCALVAR,\
                  "", kIntrnUndef, kArgTyPtr, kArgTyU32, kArgTyU8, kArgTyU32, kArgTyUndef, kArgTyUndef, kArgTyUndef)
DEF_MIR_INTRINSIC(MPL_SET_CLASS,\
                  "", kIntrnUndef, kArgTyPtr, kArgTyPtr, kArgTyUndef, kArgTyUndef, kArgTyUndef, kArgTyUndef, kArgTyUndef)

// start of GC Intrinsics
DEF_MIR_INTRINSIC(MCCGCCheck,\
                  "MCC_CheckObjAllocated", INTRNISRC | INTRNNOSIDEEFFECT, kArgTyVoid, kArgTyRef)

// start of Profile Intrinsics
DEF_MIR_INTRINSIC(MCCSaveProf,\
                  "MCC_SaveProfile", INTRNISRC | INTRNNOSIDEEFFECT, kArgTyVoid, kArgTyRef)

#include "intrinsic_c.def"
#include "intrinsic_js.def"
#include "intrinsic_js_eng.def"
#include "intrinsic_vector.def"
DEF_MIR_INTRINSIC(LAST,\
                  nullptr, kIntrnUndef, kArgTyUndef, kArgTyUndef, kArgTyUndef, kArgTyUndef, kArgTyUndef, kArgTyUndef, kArgTyUndef)
