1/* 2 * Copyright (c) 2021 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}; 22 23constexpr const char* GetEntrypointName(EntrypointId id) { 24 ASSERT(id < EntrypointId::COUNT); 25 // NOLINTNEXTLINE(modernize-avoid-c-arrays) 26 constexpr const char* NAMES[static_cast<size_t>(EntrypointId::COUNT)] = { 27% Compiler::entrypoints.each do |entrypoint| 28 "<%= entrypoint.name %>", 29% end 30 }; 31 return NAMES[static_cast<size_t>(id)]; 32} 33 34bool IsEntrypointNoreturn(EntrypointId id) { 35 ASSERT(id < EntrypointId::COUNT); 36 switch(id) { 37% Compiler::entrypoints.each do |entrypoint| 38 case EntrypointId::<%= entrypoint.enum_name %>: 39 return <%= entrypoint.has_property? 'no_return' %>; 40% end 41 case EntrypointId::COUNT: 42 UNREACHABLE(); 43 } 44 UNREACHABLE(); 45} 46 47size_t GetEntrypointArgsNum(EntrypointId id) { 48 ASSERT(id < EntrypointId::COUNT); 49 switch(id) { 50% Compiler::entrypoints.each do |entrypoint| 51 case EntrypointId::<%= entrypoint.enum_name %>: 52 return <%= entrypoint.signature.length - 1 %>; 53% end 54 case EntrypointId::COUNT: 55 UNREACHABLE(); 56 } 57 UNREACHABLE(); 58} 59 60uint32_t GetEntrypointsCrc32() { 61 static constexpr uint32_t ENTRYPOINTS_CRC32 = <%= Compiler::entrypoints_crc32 %>; 62 return ENTRYPOINTS_CRC32; 63} 64