• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2024 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// Autogenerated file -- DO NOT EDIT!
17
18#include "libabckit/src/adapter_dynamic/runtime_adapter_dynamic.h"
19
20namespace libabckit {
21
22% additional_deprecated_opcodes = ["JNSTRICTEQUNDEFINED",
23%                                 "JSTRICTEQUNDEFINED",
24%                                 "JNEUNDEFINED",
25%                                 "JEQUNDEFINED",
26%                                 "JNSTRICTEQNULL",
27%                                 "JSTRICTEQNULL",
28%                                 "JNENULL",
29%                                 "JEQNULL",
30%                                 "JNSTRICTEQZ",
31%                                 "JSTRICTEQZ",
32%                                 "STTOGLOBALRECORD",
33%                                 "STCONSTTOGLOBALRECORD",
34%                                 "CREATEREGEXPWITHLITERAL",
35%                                 "CLOSEITERATOR"]
36
37% replaced_opcodes = ["JNSTRICTEQ",
38%                    "JSTRICTEQ",
39%                    "JNE",
40%                    "JEQ"]
41
42% skipped_opcodes = additional_deprecated_opcodes + replaced_opcodes
43
44// NOLINTNEXTLINE(readability-function-size)
45static inline AbckitIsaApiDynamicOpcode GetDYNIntrinsicOpcode(ark::compiler::IntrinsicInst *inst) {
46    switch(inst->GetIntrinsicId()) {
47% Panda::instructions.select{|b| b.namespace == "ecmascript"}.each do |inst|
48        case ark::compiler::RuntimeInterface::IntrinsicId::DYN_<%= inst.opcode.upcase %>: {
49%   if (inst.mnemonic.include? "deprecated") || (skipped_opcodes.include? inst.mnemonic.upcase)
50            return ABCKIT_ISA_API_DYNAMIC_OPCODE_INVALID;
51%   else
52            return ABCKIT_ISA_API_DYNAMIC_OPCODE_<%= inst.mnemonic.gsub('.', '_').upcase%>;
53%   end
54        }
55% end
56        default: {
57            return ABCKIT_ISA_API_DYNAMIC_OPCODE_INVALID;
58        }
59    }
60}
61
62// NOLINTNEXTLINE(readability-function-size)
63static inline size_t GetIntrinicDYNMaxInputsCount(ark::compiler::IntrinsicInst *inst) {
64    switch(inst->GetIntrinsicId()) {
65% Panda::instructions.select{|b| b.namespace == "ecmascript"}.each do |inst|
66%   if !(inst.mnemonic.include? "deprecated") && !(skipped_opcodes.include? inst.mnemonic.upcase)
67        case ark::compiler::RuntimeInterface::IntrinsicId::DYN_<%= inst.opcode.upcase %>:
68%     if (inst.mnemonic.include? "range")
69            return -1;
70%     else
71%       num_vregs = inst.operands.select{|b| b.reg?}.length
72%       num_inputs = inst.acc.include?("in") ? num_vregs + 1 : num_vregs + 0
73            return <%= num_inputs %>;
74%     end
75%   end
76% end
77        default:
78            LIBABCKIT_UNREACHABLE;
79    }
80}
81
82// NOLINTNEXTLINE(readability-function-size)
83static inline bool IsCallDYNInst(ark::compiler::Inst *inst) {
84    if (!inst->IsIntrinsic()) {
85        return inst->IsCall();
86    }
87    switch(inst->CastToIntrinsic()->GetIntrinsicId()) {
88% Panda::instructions.select{|b| b.namespace == "ecmascript"}.each do |inst|
89        case ark::compiler::RuntimeInterface::IntrinsicId::DYN_<%= inst.opcode.upcase %>: {
90%   mnemonic = inst.mnemonic.split(/\s|\./)
91%   if ((mnemonic.length() > 1) && (mnemonic[0] == "callruntime") && ((mnemonic[1]).include? "call"))
92            return true;
93        }
94%       next
95%   end
96%   desc = inst.description.split
97%   if (desc.length() > 0 && desc[0] == "call")
98            return true;
99%   else
100            return false;
101%   end
102        }
103% end
104        case ark::compiler::RuntimeInterface::IntrinsicId::INTRINSIC_ABCKIT_LOAD_STRING: {
105            return false;
106        }
107        default: {
108            LIBABCKIT_UNREACHABLE;
109        }
110    }
111}
112
113}   // libabckit
114