29e49c33333c271f4106d31a389e50f2b5d770fa
[oota-llvm.git] / include / llvm / ExecutionEngine / Orc / OrcTargetSupport.h
1 //===-- OrcTargetSupport.h - Code to support specific targets  --*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // Target specific code for Orc, e.g. callback assembly.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #ifndef LLVM_EXECUTIONENGINE_ORC_ORCTARGETSUPPORT_H
15 #define LLVM_EXECUTIONENGINE_ORC_ORCTARGETSUPPORT_H
16
17 #include "IndirectionUtils.h"
18
19 namespace llvm {
20
21 class OrcX86_64 {
22 public:
23   static const char *ResolverBlockName;
24
25   /// @brief Insert module-level inline callback asm into module M for the
26   /// symbols managed by JITResolveCallbackHandler J.
27   static void insertResolverBlock(
28                                  Module &M,
29                                  JITCompileCallbackManagerBase<OrcX86_64> &JCBM);
30
31   /// @brief Get a label name from the given index.
32   typedef std::function<std::string(unsigned)> LabelNameFtor;
33
34   static const unsigned CallSize = 6;
35
36   /// @brief Insert the requested number of trampolines into the given module.
37   /// @param M Module to insert the call block into.
38   /// @param NumCalls Number of calls to create in the call block.
39   /// @param StartIndex Optional argument specifying the index suffix to start
40   ///                   with.
41   /// @return A functor that provides the symbol name for each entry in the call
42   ///         block.
43   ///
44   static LabelNameFtor insertCompileCallbackTrampolines(
45                                                     Module &M,
46                                                     TargetAddress TrampolineAddr,
47                                                     unsigned NumCalls,
48                                                     unsigned StartIndex = 0);
49
50 };
51
52 }
53
54 #endif // LLVM_EXECUTIONENGINE_ORC_ORCTARGETSUPPORT_H