1/* 2 * Copyright (c) 2023-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// NOLINTNEXTLINE(readability-function-size) 17ark::llvmbackend::BridgeType GetBridgeTypeInternal(ark::compiler::RuntimeInterface::EntrypointId id) 18{ 19 switch (id) { 20% Compiler::entrypoints.each do |entrypoint| 21 case ark::compiler::RuntimeInterface::EntrypointId::<%= entrypoint.enum_name %>: 22 return ark::llvmbackend::BridgeType::<%= entrypoint.bridge %>; 23% end 24 default: 25 ASSERT_DO(false, (std::cerr << "Cannot get bridge for EntrypointId = " << static_cast<int>(id) 26 << std::endl)); 27 UNREACHABLE(); 28 } 29} 30 31// NOLINTNEXTLINE(readability-function-size) 32llvm::FunctionType *GetEntrypointDeclaration(llvm::LLVMContext &ctx, llvm::Module *module, ark::compiler::RuntimeInterface::EntrypointId id) 33{ 34 constexpr auto GC_SPACE = ark::llvmbackend::LLVMArkInterface::GC_ADDR_SPACE; 35 // We hope that ARK will not use segmentated memory and size_t will have the same width as uintptr_t 36 // NOLINTNEXTLINE(readability-identifier-naming) 37 auto size_type = llvm::Type::getIntNTy(ctx, module->getDataLayout().getPointerSizeInBits(0)); 38 switch (id) { 39% Compiler::entrypoints.each do |entrypoint| 40 case ark::compiler::RuntimeInterface::EntrypointId::<%= entrypoint.enum_name %>: 41 return llvm::FunctionType::get(<%= llvm_type_getter(entrypoint.signature[0], 'GC_SPACE') %>, 42 {<%= entrypoint.signature[1..-1].select {|t| t != '...' }.map { |t| llvm_type_getter(t, 'GC_SPACE') }.join(', ') %>}, 43 <%= entrypoint.variadic? %>); 44% end 45 default: 46 ASSERT_DO(false, (std::cerr << "Cannot get entrypoint signature by EntrypointId = " << static_cast<int>(id) 47 << std::endl)); 48 UNREACHABLE(); 49 } 50} 51