[libc] Switch to using the generic `<gpuintrin.h>` implementations (#121810)
[llvm-project.git] / compiler-rt / lib / orc / resolve.cpp
blob3d9b37d14d2a433aa102d01c0cee86019c61d5f3
1 //===- resolve.cpp --------------------------------------------------------===//
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 contains a generic "resolver" function compatible with the
10 // __orc_rt_reenter function.
12 //===----------------------------------------------------------------------===//
14 #include "executor_symbol_def.h"
15 #include "jit_dispatch.h"
16 #include "wrapper_function_utils.h"
18 #include <stdio.h>
20 #define DEBUG_TYPE "resolve"
22 using namespace orc_rt;
24 // Declare function tags for functions in the JIT process.
25 ORC_RT_JIT_DISPATCH_TAG(__orc_rt_resolve_tag)
27 // FIXME: Make this configurable via an alias.
28 static void __orc_rt_resolve_fail(void *Caller, const char *ErrMsg) {
29 fprintf(stderr, "error resolving implementation for stub %p: %s\n", Caller,
30 ErrMsg);
31 abort();
34 extern "C" ORC_RT_HIDDEN void *__orc_rt_resolve(void *Caller) {
35 Expected<ExecutorSymbolDef> Result((ExecutorSymbolDef()));
36 if (auto Err = WrapperFunction<SPSExpected<SPSExecutorSymbolDef>(
37 SPSExecutorAddr)>::call(JITDispatch(&__orc_rt_resolve_tag), Result,
38 ExecutorAddr::fromPtr(Caller))) {
39 __orc_rt_resolve_fail(Caller, toString(std::move(Err)).c_str());
40 return nullptr; // Unreachable.
43 if (!Result) {
44 __orc_rt_resolve_fail(Caller, toString(Result.takeError()).c_str());
45 return nullptr; // Unreachable.
48 return Result->getAddress().toPtr<void *>();