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