|
21 | 21 | namespace llvm { |
22 | 22 | namespace orc { |
23 | 23 |
|
| 24 | +/// IRMaterializationUnit is a convenient base class for MaterializationUnits |
| 25 | +/// wrapping LLVM IR. Represents materialization responsibility for all symbols |
| 26 | +/// in the given module. If symbols are overridden by other definitions, then |
| 27 | +/// their linkage is changed to available-externally. |
| 28 | +class IRMaterializationUnit : public MaterializationUnit { |
| 29 | +public: |
| 30 | + struct ManglingOptions { |
| 31 | + bool EmulatedTLS = false; |
| 32 | + }; |
| 33 | + |
| 34 | + using SymbolNameToDefinitionMap = std::map<SymbolStringPtr, GlobalValue *>; |
| 35 | + |
| 36 | + /// Create an IRMaterializationLayer. Scans the module to build the |
| 37 | + /// SymbolFlags and SymbolToDefinition maps. |
| 38 | + IRMaterializationUnit(ExecutionSession &ES, const ManglingOptions &MO, |
| 39 | + ThreadSafeModule TSM, VModuleKey K); |
| 40 | + |
| 41 | + /// Create an IRMaterializationLayer from a module, and pre-existing |
| 42 | + /// SymbolFlags and SymbolToDefinition maps. The maps must provide |
| 43 | + /// entries for each definition in M. |
| 44 | + /// This constructor is useful for delegating work from one |
| 45 | + /// IRMaterializationUnit to another. |
| 46 | + IRMaterializationUnit(ThreadSafeModule TSM, VModuleKey K, |
| 47 | + SymbolFlagsMap SymbolFlags, |
| 48 | + SymbolNameToDefinitionMap SymbolToDefinition); |
| 49 | + |
| 50 | + /// Return the ModuleIdentifier as the name for this MaterializationUnit. |
| 51 | + StringRef getName() const override; |
| 52 | + |
| 53 | + const ThreadSafeModule &getModule() const { return TSM; } |
| 54 | + |
| 55 | +protected: |
| 56 | + ThreadSafeModule TSM; |
| 57 | + SymbolNameToDefinitionMap SymbolToDefinition; |
| 58 | + |
| 59 | +private: |
| 60 | + void discard(const JITDylib &JD, const SymbolStringPtr &Name) override; |
| 61 | +}; |
| 62 | + |
24 | 63 | /// Interface for layers that accept LLVM IR. |
25 | 64 | class IRLayer { |
26 | 65 | public: |
27 | | - IRLayer(ExecutionSession &ES); |
| 66 | + IRLayer(ExecutionSession &ES, |
| 67 | + const IRMaterializationUnit::ManglingOptions *&MO) |
| 68 | + : ES(ES), MO(MO) {} |
| 69 | + |
28 | 70 | virtual ~IRLayer(); |
29 | 71 |
|
30 | 72 | /// Returns the ExecutionSession for this layer. |
31 | 73 | ExecutionSession &getExecutionSession() { return ES; } |
32 | 74 |
|
| 75 | + /// Get the mangling options for this layer. |
| 76 | + const IRMaterializationUnit::ManglingOptions *&getManglingOptions() const { |
| 77 | + return MO; |
| 78 | + } |
| 79 | + |
33 | 80 | /// Sets the CloneToNewContextOnEmit flag (false by default). |
34 | 81 | /// |
35 | 82 | /// When set, IR modules added to this layer will be cloned on to a new |
@@ -57,49 +104,15 @@ class IRLayer { |
57 | 104 | private: |
58 | 105 | bool CloneToNewContextOnEmit = false; |
59 | 106 | ExecutionSession &ES; |
60 | | -}; |
61 | | - |
62 | | -/// IRMaterializationUnit is a convenient base class for MaterializationUnits |
63 | | -/// wrapping LLVM IR. Represents materialization responsibility for all symbols |
64 | | -/// in the given module. If symbols are overridden by other definitions, then |
65 | | -/// their linkage is changed to available-externally. |
66 | | -class IRMaterializationUnit : public MaterializationUnit { |
67 | | -public: |
68 | | - using SymbolNameToDefinitionMap = std::map<SymbolStringPtr, GlobalValue *>; |
69 | | - |
70 | | - /// Create an IRMaterializationLayer. Scans the module to build the |
71 | | - /// SymbolFlags and SymbolToDefinition maps. |
72 | | - IRMaterializationUnit(ExecutionSession &ES, ThreadSafeModule TSM, |
73 | | - VModuleKey K); |
74 | | - |
75 | | - /// Create an IRMaterializationLayer from a module, and pre-existing |
76 | | - /// SymbolFlags and SymbolToDefinition maps. The maps must provide |
77 | | - /// entries for each definition in M. |
78 | | - /// This constructor is useful for delegating work from one |
79 | | - /// IRMaterializationUnit to another. |
80 | | - IRMaterializationUnit(ThreadSafeModule TSM, VModuleKey K, |
81 | | - SymbolFlagsMap SymbolFlags, |
82 | | - SymbolNameToDefinitionMap SymbolToDefinition); |
83 | | - |
84 | | - /// Return the ModuleIdentifier as the name for this MaterializationUnit. |
85 | | - StringRef getName() const override; |
86 | | - |
87 | | - const ThreadSafeModule &getModule() const { return TSM; } |
88 | | - |
89 | | -protected: |
90 | | - ThreadSafeModule TSM; |
91 | | - SymbolNameToDefinitionMap SymbolToDefinition; |
92 | | - |
93 | | -private: |
94 | | - void discard(const JITDylib &JD, const SymbolStringPtr &Name) override; |
| 107 | + const IRMaterializationUnit::ManglingOptions *&MO; |
95 | 108 | }; |
96 | 109 |
|
97 | 110 | /// MaterializationUnit that materializes modules by calling the 'emit' method |
98 | 111 | /// on the given IRLayer. |
99 | 112 | class BasicIRLayerMaterializationUnit : public IRMaterializationUnit { |
100 | 113 | public: |
101 | | - BasicIRLayerMaterializationUnit(IRLayer &L, VModuleKey K, |
102 | | - ThreadSafeModule TSM); |
| 114 | + BasicIRLayerMaterializationUnit(IRLayer &L, const ManglingOptions &MO, |
| 115 | + ThreadSafeModule TSM, VModuleKey K); |
103 | 116 |
|
104 | 117 | private: |
105 | 118 |
|
|
0 commit comments