1fe6060f1SDimitry Andric //===- common.h - Common utilities for the ORC runtime ----------*- C++ -*-===// 2fe6060f1SDimitry Andric // 3fe6060f1SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4fe6060f1SDimitry Andric // See https://llvm.org/LICENSE.txt for license information. 5fe6060f1SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6fe6060f1SDimitry Andric // 7fe6060f1SDimitry Andric //===----------------------------------------------------------------------===// 8fe6060f1SDimitry Andric // 9fe6060f1SDimitry Andric // This file is a part of the ORC runtime support library. 10fe6060f1SDimitry Andric // 11fe6060f1SDimitry Andric //===----------------------------------------------------------------------===// 12fe6060f1SDimitry Andric 13fe6060f1SDimitry Andric #ifndef ORC_RT_COMMON_H 14fe6060f1SDimitry Andric #define ORC_RT_COMMON_H 15fe6060f1SDimitry Andric 16fe6060f1SDimitry Andric #include "compiler.h" 17bdd1243dSDimitry Andric #include "orc_rt/c_api.h" 18fe6060f1SDimitry Andric #include <type_traits> 19fe6060f1SDimitry Andric 20fe6060f1SDimitry Andric /// This macro should be used to define tags that will be associated with 21fe6060f1SDimitry Andric /// handlers in the JIT process, and call can be used to define tags f 22fe6060f1SDimitry Andric #define ORC_RT_JIT_DISPATCH_TAG(X) \ 23fe6060f1SDimitry Andric extern "C" char X; \ 24fe6060f1SDimitry Andric char X = 0; 25fe6060f1SDimitry Andric 26fe6060f1SDimitry Andric /// Opaque struct for external symbols. 27fe6060f1SDimitry Andric struct __orc_rt_Opaque {}; 28fe6060f1SDimitry Andric 29fe6060f1SDimitry Andric /// Error reporting function. 30fe6060f1SDimitry Andric extern "C" void __orc_rt_log_error(const char *ErrMsg); 31fe6060f1SDimitry Andric 32fe6060f1SDimitry Andric /// Context object for dispatching calls to the JIT object. 33fe6060f1SDimitry Andric /// 34fe6060f1SDimitry Andric /// This is declared for use by the runtime, but should be implemented in the 35fe6060f1SDimitry Andric /// executor or provided by a definition added to the JIT before the runtime 36fe6060f1SDimitry Andric /// is loaded. 37bdd1243dSDimitry Andric ORC_RT_IMPORT __orc_rt_Opaque __orc_rt_jit_dispatch_ctx ORC_RT_WEAK_IMPORT; 38fe6060f1SDimitry Andric 39fe6060f1SDimitry Andric /// For dispatching calls to the JIT object. 40fe6060f1SDimitry Andric /// 41fe6060f1SDimitry Andric /// This is declared for use by the runtime, but should be implemented in the 42fe6060f1SDimitry Andric /// executor or provided by a definition added to the JIT before the runtime 43fe6060f1SDimitry Andric /// is loaded. 44*06c3fb27SDimitry Andric ORC_RT_IMPORT orc_rt_CWrapperFunctionResult 45fe6060f1SDimitry Andric __orc_rt_jit_dispatch(__orc_rt_Opaque *DispatchCtx, const void *FnTag, 46fe6060f1SDimitry Andric const char *Data, size_t Size) ORC_RT_WEAK_IMPORT; 47fe6060f1SDimitry Andric 48fe6060f1SDimitry Andric #endif // ORC_RT_COMMON_H 49