• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2021-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
16enum class EntrypointId : uint32_t {
17% Compiler::entrypoints.each_with_index do |entrypoint, index|
18    <%= entrypoint.enum_name %> = <%= index %>,
19% end
20    COUNT,
21    INVALID = COUNT
22};
23
24// NOLINTNEXTLINE(readability-function-size)
25constexpr const char* GetEntrypointName(EntrypointId id) {
26    ASSERT(id < EntrypointId::COUNT);
27    // NOLINTNEXTLINE(modernize-avoid-c-arrays)
28    constexpr const char* NAMES[static_cast<size_t>(EntrypointId::COUNT)] = {
29% Compiler::entrypoints.each do |entrypoint|
30        "<%= entrypoint.name %>",
31% end
32    };
33    return NAMES[static_cast<size_t>(id)];
34}
35
36// NOLINTNEXTLINE(readability-function-size)
37bool IsEntrypointNoreturn(EntrypointId id) {
38    ASSERT(id < EntrypointId::COUNT);
39    switch(id) {
40% Compiler::entrypoints.each do |entrypoint|
41        case EntrypointId::<%= entrypoint.enum_name %>:
42            return <%= entrypoint.has_property? 'no_return' %>;
43% end
44        case EntrypointId::COUNT:
45            UNREACHABLE();
46    }
47    UNREACHABLE();
48}
49
50// NOLINTNEXTLINE(readability-function-size)
51size_t GetEntrypointArgsNum(EntrypointId id) {
52    ASSERT(id < EntrypointId::COUNT);
53    switch(id) {
54% Compiler::entrypoints.each do |entrypoint|
55        case EntrypointId::<%= entrypoint.enum_name %>:
56            return <%= entrypoint.signature.length - 1 %>;
57% end
58        case EntrypointId::COUNT:
59            UNREACHABLE();
60    }
61    UNREACHABLE();
62}
63
64bool IsEntrypointFastPath(EntrypointId id) {
65    ASSERT(id < EntrypointId::COUNT);
66    switch (id) {
67% Compiler::entrypoints.select { |e| e.has_property? 'irtoc' }.each do |entrypoint|
68    case EntrypointId::<%= entrypoint.enum_name %>:
69% end
70    return true;
71default:
72    return false;
73    }
74}
75