gn build: Merge r374476
[llvm-complete.git] / tools / llvm-jitlink / llvm-jitlink.h
blobf94a50993c1226578c7aa55ff9086f76b2923f51
1 //===---- llvm-jitlink.h - Session and format-specific decls ----*- C++ -*-===//
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 // Utilities for remote-JITing with LLI.
11 //===----------------------------------------------------------------------===//
13 #ifndef LLVM_TOOLS_LLVM_JITLINK_LLVM_JITLINK_H
14 #define LLVM_TOOLS_LLVM_JITLINK_LLVM_JITLINK_H
16 #include "llvm/ADT/Triple.h"
17 #include "llvm/ExecutionEngine/Orc/Core.h"
18 #include "llvm/ExecutionEngine/Orc/ObjectLinkingLayer.h"
19 #include "llvm/ExecutionEngine/RuntimeDyldChecker.h"
20 #include "llvm/Support/Error.h"
21 #include "llvm/Support/raw_ostream.h"
23 #include <vector>
25 namespace llvm {
27 struct Session {
28 orc::ExecutionSession ES;
29 std::unique_ptr<jitlink::JITLinkMemoryManager> MemMgr;
30 orc::ObjectLinkingLayer ObjLayer;
31 std::vector<orc::JITDylib *> JDSearchOrder;
32 Triple TT;
34 Session(Triple TT);
35 void dumpSessionInfo(raw_ostream &OS);
36 void modifyPassConfig(const Triple &FTT,
37 jitlink::PassConfiguration &PassConfig);
39 using MemoryRegionInfo = RuntimeDyldChecker::MemoryRegionInfo;
41 struct FileInfo {
42 StringMap<MemoryRegionInfo> SectionInfos;
43 StringMap<MemoryRegionInfo> StubInfos;
44 StringMap<MemoryRegionInfo> GOTEntryInfos;
47 using SymbolInfoMap = StringMap<MemoryRegionInfo>;
48 using FileInfoMap = StringMap<FileInfo>;
50 Expected<FileInfo &> findFileInfo(StringRef FileName);
51 Expected<MemoryRegionInfo &> findSectionInfo(StringRef FileName,
52 StringRef SectionName);
53 Expected<MemoryRegionInfo &> findStubInfo(StringRef FileName,
54 StringRef TargetName);
55 Expected<MemoryRegionInfo &> findGOTEntryInfo(StringRef FileName,
56 StringRef TargetName);
58 bool isSymbolRegistered(StringRef Name);
59 Expected<MemoryRegionInfo &> findSymbolInfo(StringRef SymbolName,
60 Twine ErrorMsgStem);
62 SymbolInfoMap SymbolInfos;
63 FileInfoMap FileInfos;
64 uint64_t SizeBeforePruning = 0;
65 uint64_t SizeAfterFixups = 0;
68 Error registerMachOStubsAndGOT(Session &S, jitlink::LinkGraph &G);
70 } // end namespace llvm
72 #endif // LLVM_TOOLS_LLVM_JITLINK_LLVM_JITLINK_H