[Orc] Directly emit machine code for the x86 resolver block and trampolines.
[oota-llvm.git] / include / llvm / ExecutionEngine / Orc / OrcTargetSupport.h
index 58273ae4616b9c9e6c77c143411b9b4af8be14d9..3e57314ba2df347cab815b6009fda6185940e7f4 100644 (file)
@@ -26,29 +26,24 @@ namespace orc {
 
 class OrcX86_64 {
 public:
-  static const char *ResolverBlockName;
+  static const unsigned PageSize = 4096;
+  static const unsigned PointerSize = 8;
+  static const unsigned TrampolineSize = 8;
+  static const unsigned ResolverCodeSize = 0x78;
 
-  /// @brief Insert module-level inline callback asm into module M for the
-  /// symbols managed by JITResolveCallbackHandler J.
-  static void insertResolverBlock(Module &M,
-                                  JITCompileCallbackManagerBase &JCBM);
+  typedef TargetAddress (*JITReentryFn)(void *CallbackMgr,
+                                        void *TrampolineId);
 
-  /// @brief Get a label name from the given index.
-  typedef std::function<std::string(unsigned)> LabelNameFtor;
+  /// @brief Write the resolver code into the given memory. The user is be
+  ///        responsible for allocating the memory and setting permissions.
+  static void writeResolverCode(uint8_t *ResolveMem, JITReentryFn Reentry,
+                               void *CallbackMgr);
 
-  /// @brief Insert the requested number of trampolines into the given module.
-  /// @param M Module to insert the call block into.
-  /// @param NumCalls Number of calls to create in the call block.
-  /// @param StartIndex Optional argument specifying the index suffix to start
-  ///                   with.
-  /// @return A functor that provides the symbol name for each entry in the call
-  ///         block.
-  ///
-  static LabelNameFtor insertCompileCallbackTrampolines(
-                                                    Module &M,
-                                                    TargetAddress TrampolineAddr,
-                                                    unsigned NumCalls,
-                                                    unsigned StartIndex = 0);
+  /// @brief Write the requsted number of trampolines into the given memory,
+  ///        which must be big enough to hold 1 pointer, plus NumTrampolines
+  ///        trampolines.
+  static void writeTrampolines(uint8_t *TrampolineMem, void *ResolverAddr,
+                              unsigned NumTrampolines);
 
   /// @brief Provide information about stub blocks generated by the
   ///        makeIndirectStubsBlock function.