• 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#include <iostream>
17#include "assembly-ins.h"
18
19namespace libabckit {
20
21% additional_deprecated_opcodes = ["JNSTRICTEQUNDEFINED",
22%                                 "JSTRICTEQUNDEFINED",
23%                                 "JNEUNDEFINED",
24%                                 "JEQUNDEFINED",
25%                                 "JNSTRICTEQNULL",
26%                                 "JSTRICTEQNULL",
27%                                 "JNENULL",
28%                                 "JEQNULL",
29%                                 "JNSTRICTEQZ",
30%                                 "JSTRICTEQZ",
31%                                 "STTOGLOBALRECORD",
32%                                 "STCONSTTOGLOBALRECORD",
33%                                 "CREATEREGEXPWITHLITERAL",
34%                                 "CLOSEITERATOR"]
35
36% replaced_opcodes = ["JNSTRICTEQ",
37%                    "JSTRICTEQ",
38%                    "JNE",
39%                    "JEQ"]
40
41% skipped_opcodes = additional_deprecated_opcodes + replaced_opcodes
42
43// NOLINTNEXTLINE(readability-function-size)
44inline panda::pandasm::Opcode OpcFromName(const std::string &name) {
45% Panda::instructions.group_by(&:mnemonic).each do |mnemonic, group|
46%  insn = group.first
47%   if !(insn.opcode.upcase.include? "DEPRECATED_") && !(skipped_opcodes.include? insn.mnemonic.upcase)
48    if (name == "<%= insn.mnemonic.gsub('.', '_') %>") {
49        return panda::pandasm::Opcode::<%= insn.asm_token%>;
50    }
51%   end
52% end
53% Panda::pseudo_instructions.each do |insn|
54    if (name == "<%= insn.opcode.gsub('.', '_') %>") {
55            return panda::pandasm::Opcode::<%= insn.opcode %>;
56    }
57% end
58    if (name == "INVALID") {
59        return panda::pandasm::Opcode::INVALID;
60    }
61    UNREACHABLE();
62}
63
64} // namespace libabckit
65