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