14514f5e3Sopenharmony_ci/* 24514f5e3Sopenharmony_ci * Copyright (c) 2023 Huawei Device Co., Ltd. 34514f5e3Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 44514f5e3Sopenharmony_ci * you may not use this file except in compliance with the License. 54514f5e3Sopenharmony_ci * You may obtain a copy of the License at 64514f5e3Sopenharmony_ci * 74514f5e3Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 84514f5e3Sopenharmony_ci * 94514f5e3Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 104514f5e3Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 114514f5e3Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 124514f5e3Sopenharmony_ci * See the License for the specific language governing permissions and 134514f5e3Sopenharmony_ci * limitations under the License. 144514f5e3Sopenharmony_ci */ 154514f5e3Sopenharmony_ci 164514f5e3Sopenharmony_ci#ifndef ECMASCRIPT_COMPILER_IR_BUILDER_H 174514f5e3Sopenharmony_ci#define ECMASCRIPT_COMPILER_IR_BUILDER_H 184514f5e3Sopenharmony_ci 194514f5e3Sopenharmony_ci#include "ecmascript/compiler/lcr_gate_meta_data.h" 204514f5e3Sopenharmony_ci 214514f5e3Sopenharmony_cinamespace panda::ecmascript::kungfu { 224514f5e3Sopenharmony_ciusing OperandsVector = std::set<int>; 234514f5e3Sopenharmony_cienum class MachineRep { 244514f5e3Sopenharmony_ci K_NONE, 254514f5e3Sopenharmony_ci K_BIT, 264514f5e3Sopenharmony_ci K_WORD8, 274514f5e3Sopenharmony_ci K_WORD16, 284514f5e3Sopenharmony_ci K_WORD32, 294514f5e3Sopenharmony_ci K_WORD64, 304514f5e3Sopenharmony_ci // FP representations must be last, and in order of increasing size. 314514f5e3Sopenharmony_ci K_FLOAT32, 324514f5e3Sopenharmony_ci K_FLOAT64, 334514f5e3Sopenharmony_ci K_SIMD128, 344514f5e3Sopenharmony_ci K_PTR_1, // Tagged Pointer 354514f5e3Sopenharmony_ci K_META, 364514f5e3Sopenharmony_ci}; 374514f5e3Sopenharmony_ci 384514f5e3Sopenharmony_cienum class CallInputs : size_t { 394514f5e3Sopenharmony_ci DEPEND = 0, 404514f5e3Sopenharmony_ci TARGET, 414514f5e3Sopenharmony_ci GLUE, 424514f5e3Sopenharmony_ci FIRST_PARAMETER 434514f5e3Sopenharmony_ci}; 444514f5e3Sopenharmony_ci 454514f5e3Sopenharmony_cienum class CallExceptionKind : bool { 464514f5e3Sopenharmony_ci HAS_PC_OFFSET = true, 474514f5e3Sopenharmony_ci NO_PC_OFFSET = false 484514f5e3Sopenharmony_ci}; 494514f5e3Sopenharmony_ci 504514f5e3Sopenharmony_ci#define OPCODES(V) \ 514514f5e3Sopenharmony_ci V(Call, (GateRef gate, const std::vector<GateRef> &inList, OpCode op)) \ 524514f5e3Sopenharmony_ci V(RuntimeCall, (GateRef gate, const std::vector<GateRef> &inList)) \ 534514f5e3Sopenharmony_ci V(RuntimeCallWithArgv, (GateRef gate, const std::vector<GateRef> &inList)) \ 544514f5e3Sopenharmony_ci V(ASMCallBarrier, (GateRef gate, const std::vector<GateRef> &inList)) \ 554514f5e3Sopenharmony_ci V(NoGcRuntimeCall, (GateRef gate, const std::vector<GateRef> &inList)) \ 564514f5e3Sopenharmony_ci V(BytecodeCall, (GateRef gate, const std::vector<GateRef> &inList)) \ 574514f5e3Sopenharmony_ci V(Alloca, (GateRef gate)) \ 584514f5e3Sopenharmony_ci V(Block, (int id, const OperandsVector &predecessors)) \ 594514f5e3Sopenharmony_ci V(Goto, (int block, int bbout)) \ 604514f5e3Sopenharmony_ci V(Parameter, (GateRef gate)) \ 614514f5e3Sopenharmony_ci V(Constant, (GateRef gate, std::bitset<64> value)) \ 624514f5e3Sopenharmony_ci V(ConstString, (GateRef gate, const ChunkVector<char> &str)) \ 634514f5e3Sopenharmony_ci V(RelocatableData, (GateRef gate, uint64_t value)) \ 644514f5e3Sopenharmony_ci V(ZExtInt, (GateRef gate, GateRef e1)) \ 654514f5e3Sopenharmony_ci V(SExtInt, (GateRef gate, GateRef e1)) \ 664514f5e3Sopenharmony_ci V(FPExt, (GateRef gate, GateRef e1)) \ 674514f5e3Sopenharmony_ci V(FPTrunc, (GateRef gate, GateRef e1)) \ 684514f5e3Sopenharmony_ci V(Load, (GateRef gate, GateRef base)) \ 694514f5e3Sopenharmony_ci V(Store, (GateRef gate, GateRef base, GateRef value)) \ 704514f5e3Sopenharmony_ci V(IntRev, (GateRef gate, GateRef e1)) \ 714514f5e3Sopenharmony_ci V(Add, (GateRef gate, GateRef e1, GateRef e2)) \ 724514f5e3Sopenharmony_ci V(Sub, (GateRef gate, GateRef e1, GateRef e2)) \ 734514f5e3Sopenharmony_ci V(Mul, (GateRef gate, GateRef e1, GateRef e2)) \ 744514f5e3Sopenharmony_ci V(FloatDiv, (GateRef gate, GateRef e1, GateRef e2)) \ 754514f5e3Sopenharmony_ci V(IntDiv, (GateRef gate, GateRef e1, GateRef e2)) \ 764514f5e3Sopenharmony_ci V(UDiv, (GateRef gate, GateRef e1, GateRef e2)) \ 774514f5e3Sopenharmony_ci V(IntOr, (GateRef gate, GateRef e1, GateRef e2)) \ 784514f5e3Sopenharmony_ci V(IntAnd, (GateRef gate, GateRef e1, GateRef e2)) \ 794514f5e3Sopenharmony_ci V(IntXor, (GateRef gate, GateRef e1, GateRef e2)) \ 804514f5e3Sopenharmony_ci V(IntLsr, (GateRef gate, GateRef e1, GateRef e2)) \ 814514f5e3Sopenharmony_ci V(IntAsr, (GateRef gate, GateRef e1, GateRef e2)) \ 824514f5e3Sopenharmony_ci V(Int32LessThanOrEqual, (GateRef gate, GateRef e1, GateRef e2)) \ 834514f5e3Sopenharmony_ci V(Cmp, (GateRef gate, GateRef e1, GateRef e2)) \ 844514f5e3Sopenharmony_ci V(Branch, (GateRef gate, GateRef cmp, GateRef btrue, GateRef bfalse)) \ 854514f5e3Sopenharmony_ci V(Switch, (GateRef gate, GateRef input, const std::vector<GateRef> &outList)) \ 864514f5e3Sopenharmony_ci V(SwitchCase, (GateRef gate, GateRef switchBranch, GateRef out)) \ 874514f5e3Sopenharmony_ci V(Phi, (GateRef gate, const std::vector<GateRef> &srcGates)) \ 884514f5e3Sopenharmony_ci V(Return, (GateRef gate, GateRef popCount, const std::vector<GateRef> &operands)) \ 894514f5e3Sopenharmony_ci V(ReturnVoid, (GateRef gate)) \ 904514f5e3Sopenharmony_ci V(CastIntXToIntY, (GateRef gate, GateRef e1)) \ 914514f5e3Sopenharmony_ci V(ChangeInt32ToDouble, (GateRef gate, GateRef e1)) \ 924514f5e3Sopenharmony_ci V(ChangeUInt32ToDouble, (GateRef gate, GateRef e1)) \ 934514f5e3Sopenharmony_ci V(ChangeDoubleToInt32, (GateRef gate, GateRef e1)) \ 944514f5e3Sopenharmony_ci V(BitCast, (GateRef gate, GateRef e1)) \ 954514f5e3Sopenharmony_ci V(IntLsl, (GateRef gate, GateRef e1, GateRef e2)) \ 964514f5e3Sopenharmony_ci V(Mod, (GateRef gate, GateRef e1, GateRef e2)) \ 974514f5e3Sopenharmony_ci V(ChangeTaggedPointerToInt64, (GateRef gate, GateRef e1)) \ 984514f5e3Sopenharmony_ci V(ChangeInt64ToTagged, (GateRef gate, GateRef e1)) \ 994514f5e3Sopenharmony_ci V(DeoptCheck, (GateRef gate)) \ 1004514f5e3Sopenharmony_ci V(TruncFloatToInt, (GateRef gate, GateRef e1)) \ 1014514f5e3Sopenharmony_ci V(AddWithOverflow, (GateRef gate, GateRef e1, GateRef e2)) \ 1024514f5e3Sopenharmony_ci V(SubWithOverflow, (GateRef gate, GateRef e1, GateRef e2)) \ 1034514f5e3Sopenharmony_ci V(MulWithOverflow, (GateRef gate, GateRef e1, GateRef e2)) \ 1044514f5e3Sopenharmony_ci V(ExtractValue, (GateRef gate, GateRef e1, GateRef e2)) \ 1054514f5e3Sopenharmony_ci V(Sqrt, (GateRef gate, GateRef e1)) \ 1064514f5e3Sopenharmony_ci V(Exp, (GateRef gate, GateRef e1, GateRef e2)) \ 1074514f5e3Sopenharmony_ci V(Abs, (GateRef gate, GateRef e1)) \ 1084514f5e3Sopenharmony_ci V(Min, (GateRef gate, GateRef e1, GateRef e2)) \ 1094514f5e3Sopenharmony_ci V(Max, (GateRef gate, GateRef e1, GateRef e2)) \ 1104514f5e3Sopenharmony_ci V(Clz32, (GateRef gate, GateRef e1)) \ 1114514f5e3Sopenharmony_ci V(DoubleTrunc, (GateRef gate, GateRef e1)) \ 1124514f5e3Sopenharmony_ci V(Ceil, (GateRef gate, GateRef e1)) \ 1134514f5e3Sopenharmony_ci V(Floor, (GateRef gate, GateRef e1)) \ 1144514f5e3Sopenharmony_ci V(ReadSp, (GateRef gate)) \ 1154514f5e3Sopenharmony_ci V(InitVreg, (GateRef gate)) \ 1164514f5e3Sopenharmony_ci V(FinishAllocate, (GateRef gate, GateRef e1)) 1174514f5e3Sopenharmony_ci 1184514f5e3Sopenharmony_cibool IsAddIntergerType(MachineType machineType); 1194514f5e3Sopenharmony_cibool IsMulIntergerType(MachineType machineType); 1204514f5e3Sopenharmony_ci} // namespace panda::ecmascript::kungfu 1214514f5e3Sopenharmony_ci#endif // ECMASCRIPT_COMPILER_IR_BUILDER_H 122