[compiler-rt] 1ed29f8 - [ORC-RT] Add common.h -- Logging, casting and remote dispatch utilities.

Lang Hames via llvm-commits llvm-commits at lists.llvm.org
Sun May 30 11:44:50 PDT 2021


Author: Lang Hames
Date: 2021-05-30T11:21:17-07:00
New Revision: 1ed29f8784ee528f54cd33300ab8420372141283

URL: https://github.com/llvm/llvm-project/commit/1ed29f8784ee528f54cd33300ab8420372141283
DIFF: https://github.com/llvm/llvm-project/commit/1ed29f8784ee528f54cd33300ab8420372141283.diff

LOG: [ORC-RT] Add common.h -- Logging, casting and remote dispatch utilities.

Added: 
    compiler-rt/lib/orc/common.h

Modified: 
    compiler-rt/lib/orc/CMakeLists.txt

Removed: 
    


################################################################################
diff  --git a/compiler-rt/lib/orc/CMakeLists.txt b/compiler-rt/lib/orc/CMakeLists.txt
index fb45f28f4076..8aac8f455acc 100644
--- a/compiler-rt/lib/orc/CMakeLists.txt
+++ b/compiler-rt/lib/orc/CMakeLists.txt
@@ -14,6 +14,7 @@ set(ORC_IMPL_HEADERS
 # Implementation headers will go here.
   adt.h
   c_api.h
+  common.h
   compiler.h
   endian.h
   error.h

diff  --git a/compiler-rt/lib/orc/common.h b/compiler-rt/lib/orc/common.h
new file mode 100644
index 000000000000..90ee5c559ac2
--- /dev/null
+++ b/compiler-rt/lib/orc/common.h
@@ -0,0 +1,60 @@
+//===- common.h - Common utilities for the ORC runtime ----------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+//
+// This file is a part of the ORC runtime support library.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef ORC_RT_COMMON_H
+#define ORC_RT_COMMON_H
+
+#include "c_api.h"
+
+/// Opaque struct for external symbols.
+struct __orc_rt_Opaque {};
+
+/// Error reporting function.
+extern "C" void __orc_rt_log_error(const char *ErrMsg);
+
+/// Context object for dispatching calls to the JIT object.
+///
+/// This is declared for use by the runtime, but should be implemented in the
+/// executor or provided by a definition added to the JIT before the runtime
+/// is loaded.
+extern "C" __orc_rt_Opaque __orc_rt_jit_dispatch_ctx
+  __attribute__((weak_import));
+
+/// For dispatching calls to the JIT object.
+///
+/// This is declared for use by the runtime, but should be implemented in the
+/// executor or provided by a definition added to the JIT before the runtime
+/// is loaded.
+extern "C" OrcRTCWrapperFunctionResult
+__orc_rt_jit_dispatch(__orc_rt_Opaque *DispatchCtx, const void *FnTag,
+                      const char *Data, size_t Size)
+  __attribute__((weak_import));
+
+namespace __orc_rt {
+
+/// Must be kept in sync with JITSymbol.h
+using JITTargetAddress = uint64_t;
+
+/// Cast from JITTargetAddress to pointer.
+template <typename T> T jitTargetAddressToPointer(JITTargetAddress Addr) {
+  static_assert(std::is_pointer<T>::value, "T must be a pointer type");
+  return reinterpret_cast<T>(static_cast<uintptr_t>(Addr));
+}
+
+/// Cast from pointer to JITTargetAddress.
+template <typename T> JITTargetAddress pointerToJITTargetAddress(T *Ptr) {
+  return static_cast<JITTargetAddress>(reinterpret_cast<uintptr_t>(Ptr));
+}
+
+} // end namespace __orc_rt
+
+#endif // ORC_RT_COMMON_H


        


More information about the llvm-commits mailing list