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