/* * Copyright (c) 2021-2022 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef PANDA_IRTOC_INTERPRETER_UTILS_H_ #define PANDA_IRTOC_INTERPRETER_UTILS_H_ namespace panda::interpreter { % # If it is GN Build with disabled asmjit and irtoc is disabled #if defined(PANDA_TARGET_AMD64) && !defined(PANDA_COMPILER_TARGET_X86_64) % Panda::instructions.each do |i| static constexpr void (*HANDLE_FAST_<%= i.handler_name %>)() = nullptr; % end % Panda::prefixes.each do |p| static constexpr void (*HANDLE_FAST_<%= p.handler_name %>)() = nullptr; % end static constexpr void (*HANDLE_FAST_INVALID)() = nullptr; #else % Panda::instructions.each do |i| extern "C" void HANDLE_FAST_<%= i.handler_name %>(); % end % Panda::prefixes.each do |p| extern "C" void HANDLE_FAST_<%= p.handler_name %>(); % end extern "C" void HANDLE_FAST_INVALID(); #endif void* SetupDispatchTableImpl() { static const std::array> dispatch_table { #if defined(PANDA_TARGET_AMD64) && !defined(PANDA_COMPILER_TARGET_X86_64) % Panda::dispatch_table.handler_names.each do |name| HANDLE_FAST_<%= name %>, % end #else % Panda::dispatch_table.handler_names.each do |name| &HANDLE_FAST_<%= name %>, % end #endif }; return (void *)dispatch_table.data(); } } // namespace panda::interpreter #endif // PANDA_IRTOC_INTERPRETER_UTILS_H_