• 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 "src/adapter_dynamic/runtime_adapter_dynamic.h"
19#include "dyn_intrinsics_opcodes.inc"
20
21namespace libabckit {
22
23// NOLINTNEXTLINE(readability-function-size)
24static inline AbckitIsaApiStaticOpcode GetStaticIntrinsicOpcode(ark::compiler::IntrinsicInst *inst) {
25    switch(inst->GetIntrinsicId()) {
26% Compiler::intrinsics.select {|intrinsic| intrinsic.space == "abckit" }.each do |intrinsic|
27        case ark::compiler::RuntimeInterface::IntrinsicId::<%= intrinsic.entrypoint_name %>:
28            return ABCKIT_ISA_API_STATIC_OPCODE_<%= intrinsic.class_name.upcase %>;
29% end
30        default: {
31            LIBABCKIT_UNREACHABLE;
32            //return GetDYNIntrinsicOpcode(inst);
33        }
34    }
35}
36
37static inline AbckitIsaApiDynamicOpcode GetDynamicIntrinsicOpcode(ark::compiler::IntrinsicInst *inst) {
38    return GetDYNIntrinsicOpcode(inst);
39}
40
41// NOLINTNEXTLINE(readability-function-size)
42static inline size_t GetIntrinicMaxInputsCountStatic(ark::compiler::IntrinsicInst *inst) {
43    switch(inst->GetIntrinsicId()) {
44% Compiler::intrinsics.select {|intrinsic| intrinsic.space == "abckit" }.each do |intrinsic|
45        case ark::compiler::RuntimeInterface::IntrinsicId::<%= intrinsic.entrypoint_name %>: {
46%   inst = nil
47%   Panda::instructions.each do |asm_ins|
48%     if (asm_ins.mnemonic == intrinsic.method_name)
49%       inst = asm_ins
50%     end
51%   end
52%   if inst.mnemonic.include? "range"
53            return -1;
54%   else
55%     num_vregs = inst.operands.select{|b| b.reg? && b.src?}.length
56%     num_inputs = inst.acc.include?("in") ? num_vregs + 1 : num_vregs
57            return <%= num_inputs %>;
58%   end
59        }
60% end
61        default: {
62            LIBABCKIT_UNREACHABLE;
63        }
64    }
65}
66
67static inline size_t GetIntrinicMaxInputsCountDyn(ark::compiler::IntrinsicInst *inst) {
68    return GetIntrinicDYNMaxInputsCount(inst);
69}
70
71// NOLINTNEXTLINE(readability-function-size)
72static inline bool IsCallInstStatic(ark::compiler::Inst *inst) {
73    if (!inst->IsIntrinsic()) {
74        return inst->IsCall();
75    }
76    switch(inst->CastToIntrinsic()->GetIntrinsicId()) {
77% Compiler::intrinsics.select {|intrinsic| intrinsic.space == "abckit" }.each do |intrinsic|
78        case ark::compiler::RuntimeInterface::IntrinsicId::<%= intrinsic.entrypoint_name %>: {
79%   inst = nil
80%   Panda::instructions.each do |asm_ins|
81%     if (asm_ins.mnemonic == intrinsic.method_name)
82%       inst = asm_ins
83%     end
84%   end
85%   is_call = inst.properties.include? 'call'
86%   if is_call
87            return true;
88%   else
89            return false;
90%   end
91        }
92% end
93        default: {
94            LIBABCKIT_UNREACHABLE;
95        }
96    }
97}
98
99static inline bool IsCallInstDyn(ark::compiler::Inst *inst) {
100    return IsCallDYNInst(inst);
101}
102
103}   // libabckit
104