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 16#ifndef PANDA_IRTOC_INTERPRETER_UTILS_H_ 17#define PANDA_IRTOC_INTERPRETER_UTILS_H_ 18 19namespace panda::interpreter { 20 21% # If it is GN Build with disabled asmjit and irtoc is disabled 22#if defined(PANDA_TARGET_AMD64) && !defined(PANDA_COMPILER_TARGET_X86_64) 23% Panda::instructions.each do |i| 24 static constexpr void (*HANDLE_FAST_<%= i.handler_name %>)() = nullptr; 25% end 26% Panda::prefixes.each do |p| 27 static constexpr void (*HANDLE_FAST_<%= p.handler_name %>)() = nullptr; 28% end 29 static constexpr void (*HANDLE_FAST_INVALID)() = nullptr; 30#else 31% Panda::instructions.each do |i| 32 extern "C" void HANDLE_FAST_<%= i.handler_name %>(); 33% end 34% Panda::prefixes.each do |p| 35 extern "C" void HANDLE_FAST_<%= p.handler_name %>(); 36% end 37 extern "C" void HANDLE_FAST_INVALID(); 38#endif 39void* SetupDispatchTableImpl() 40{ 41 static const std::array<void (*)(), <%= Panda::dispatch_table.handler_names.size() %>> dispatch_table { 42#if defined(PANDA_TARGET_AMD64) && !defined(PANDA_COMPILER_TARGET_X86_64) 43% Panda::dispatch_table.handler_names.each do |name| 44 HANDLE_FAST_<%= name %>, 45% end 46#else 47% Panda::dispatch_table.handler_names.each do |name| 48 &HANDLE_FAST_<%= name %>, 49% end 50#endif 51 }; 52 return (void *)dispatch_table.data(); 53} 54} // namespace panda::interpreter 55 56#endif // PANDA_IRTOC_INTERPRETER_UTILS_H_ 57