aboutsummaryrefslogtreecommitdiffstats
path: root/include/llvm/ExecutionEngine/Orc/OrcTargetSupport.h
blob: c6f866a0469a5271f4e76c91262666cb9cab7003 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
//===-- OrcTargetSupport.h - Code to support specific targets  --*- C++ -*-===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// Target specific code for Orc, e.g. callback assembly.
//
//===----------------------------------------------------------------------===//

#ifndef LLVM_EXECUTIONENGINE_ORC_ORCTARGETSUPPORT_H
#define LLVM_EXECUTIONENGINE_ORC_ORCTARGETSUPPORT_H

#include "IndirectionUtils.h"

namespace llvm {
namespace orc {

class OrcX86_64 {
public:
  static const char *ResolverBlockName;

  /// @brief Insert module-level inline callback asm into module M for the
  /// symbols managed by JITResolveCallbackHandler J.
  static void insertResolverBlock(
                                 Module &M,
                                 JITCompileCallbackManagerBase<OrcX86_64> &JCBM);

  /// @brief Get a label name from the given index.
  typedef std::function<std::string(unsigned)> LabelNameFtor;

  static const unsigned CallSize = 6;

  /// @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);

};

} // End namespace orc.
} // End namespace llvm.

#endif // LLVM_EXECUTIONENGINE_ORC_ORCTARGETSUPPORT_H