| 1 | //===------ jit_dispatch.h - Call back to an ORC controller -----*- C++ -*-===// |
|---|---|
| 2 | // |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 | // See https://llvm.org/LICENSE.txt for license information. |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 6 | // |
| 7 | //===----------------------------------------------------------------------===// |
| 8 | // |
| 9 | // This file is a part of the ORC runtime support library. |
| 10 | // |
| 11 | //===----------------------------------------------------------------------===// |
| 12 | |
| 13 | #ifndef ORC_RT_JIT_DISPATCH_H |
| 14 | #define ORC_RT_JIT_DISPATCH_H |
| 15 | |
| 16 | #include "common.h" |
| 17 | #include "wrapper_function_utils.h" |
| 18 | |
| 19 | namespace orc_rt { |
| 20 | |
| 21 | class JITDispatch { |
| 22 | public: |
| 23 | JITDispatch(const void *FnTag) : FnTag(FnTag) {} |
| 24 | |
| 25 | WrapperFunctionResult operator()(const char *ArgData, size_t ArgSize) { |
| 26 | // Since the functions cannot be zero/unresolved on Windows, the following |
| 27 | // reference taking would always be non-zero, thus generating a compiler |
| 28 | // warning otherwise. |
| 29 | #if !defined(_WIN32) |
| 30 | if (ORC_RT_UNLIKELY(!&__orc_rt_jit_dispatch_ctx)) |
| 31 | return WrapperFunctionResult::createOutOfBandError( |
| 32 | Msg: "__orc_rt_jit_dispatch_ctx not set") |
| 33 | .release(); |
| 34 | if (ORC_RT_UNLIKELY(!&__orc_rt_jit_dispatch)) |
| 35 | return WrapperFunctionResult::createOutOfBandError( |
| 36 | Msg: "__orc_rt_jit_dispatch not set") |
| 37 | .release(); |
| 38 | #endif |
| 39 | |
| 40 | return __orc_rt_jit_dispatch(DispatchCtx: &__orc_rt_jit_dispatch_ctx, FnTag, Data: ArgData, |
| 41 | Size: ArgSize); |
| 42 | } |
| 43 | |
| 44 | private: |
| 45 | const void *FnTag; |
| 46 | }; |
| 47 | |
| 48 | } // namespace orc_rt |
| 49 | |
| 50 | #endif // ORC_RT_JIT_DISPATCH_H |
| 51 |