• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/**
2 * Copyright (c) 2021-2022 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% Compiler::intrinsics.select(&:has_impl?).uniq{ |i| i.impl }.each do |intrinsic|
19%     if intrinsic.private
20#ifndef PANDA_PRODUCT_BUILD
21%     end
22% impl = intrinsic.respond_to?(:fast_path) ? intrinsic.fast_path : intrinsic.impl
23% if intrinsic.respond_to?(:fast_path)
24#if defined(PANDA_TARGET_AMD64) && !defined(PANDA_COMPILER_TARGET_X86_64)
25    extern "C" void <%= intrinsic.impl.rpartition('::').last %>Bridge();
26    extern "C" void <%= intrinsic.impl.rpartition('::').last %>RuntimeCallChecker();
27#else
28% end
29% if intrinsic.respond_to?(:fast_path)
30    extern "C" void <%= impl.rpartition('::').last %>();
31% else
32    extern "C" void <%= impl.rpartition('::').last %>Bridge();
33% end
34    extern "C" void <%= impl.rpartition('::').last %>RuntimeCallChecker();
35%   if intrinsic.respond_to?(:fast_path)
36#endif
37%   end
38%     if intrinsic.private
39#endif  // PANDA_PRODUCT_BUILD
40%     end
41% end
42
43extern "C" void ObjectCloneStub();
44
45// NOLINTNEXTLINE(readability-function-size)
46inline RuntimeInterface::IntrinsicId GetIntrinsicEntryPointId(intrinsics::Intrinsic intrinsic) {
47    switch (intrinsic)
48    {
49% Compiler::intrinsics.each do |intrinsic|
50    case intrinsics::Intrinsic::<%= intrinsic.enum_name %>:
51        return RuntimeInterface::IntrinsicId::<%= intrinsic.entrypoint_name %>;
52% end
53    default:
54        return RuntimeInterface::IntrinsicId::COUNT;
55    }
56}
57
58// NOLINTNEXTLINE(readability-function-size)
59uintptr_t PandaRuntimeInterface::GetIntrinsicAddress(bool runtime_call, PandaRuntimeInterface::IntrinsicId id) const {
60    switch (id) {
61    case IntrinsicId::LIB_CALL_FMOD: {
62        using fp = double (*)(double, double);
63        return reinterpret_cast<uintptr_t>(static_cast<fp>(fmod));
64    }
65    case IntrinsicId::LIB_CALL_FMODF: {
66        using fp = float (*)(float, float);
67        return reinterpret_cast<uintptr_t>(static_cast<fp>(fmodf));
68    }
69    case IntrinsicId::LIB_CALL_MEM_COPY: {
70        using fp = void *(*)(void *, const void *, size_t);
71        return reinterpret_cast<uintptr_t>(static_cast<fp>(memcpy));
72    }
73#include "intrinsics_stub.inl"
74
75% Compiler::intrinsics.each do |intrinsic|
76    case IntrinsicId::<%= intrinsic.entrypoint_name %>:
77%   if !intrinsic.has_impl?
78        return 0;
79%     next
80%   end
81%   impl = intrinsic.respond_to?(:fast_path) ? intrinsic.fast_path : intrinsic.impl
82%   bridge = intrinsic.respond_to?(:fast_path) ? intrinsic.fast_path : "#{intrinsic.impl.rpartition('::').last}Bridge"
83%   if intrinsic.private
84#ifndef PANDA_PRODUCT_BUILD
85%   end
86% if intrinsic.respond_to?(:fast_path)
87#if defined(PANDA_TARGET_AMD64) && !defined(PANDA_COMPILER_TARGET_X86_64)
88        return runtime_call ? reinterpret_cast<uintptr_t>(<%= "#{intrinsic.impl.rpartition('::').last}Bridge" %>) :
89#ifdef NDEBUG
90          reinterpret_cast<uintptr_t>(<%= intrinsic.impl %>);
91#else
92          reinterpret_cast<uintptr_t>(<%= intrinsic.impl.rpartition('::').last %>RuntimeCallChecker);
93#endif
94#else
95% end
96        return runtime_call ? reinterpret_cast<uintptr_t>(<%= bridge %>) :
97#ifdef NDEBUG
98          reinterpret_cast<uintptr_t>(<%= impl %>);
99#else
100          reinterpret_cast<uintptr_t>(<%= impl.rpartition('::').last %>RuntimeCallChecker);
101#endif
102% if intrinsic.respond_to?(:fast_path)
103#endif
104% end
105%   if intrinsic.private
106#else
107        return reinterpret_cast<uintptr_t>(intrinsics::UnknownIntrinsic);
108#endif  // PANDA_PRODUCT_BUILD
109%   end
110% end
111    default:
112        UNREACHABLE();
113    }
114}
115