|
13 | 13 | using Ubiquity.NET.Llvm; |
14 | 14 | using Ubiquity.NET.Llvm.DebugInfo; |
15 | 15 | using Ubiquity.NET.Llvm.Instructions; |
16 | | - |
17 | 16 | using Ubiquity.NET.Llvm.Types; |
18 | 17 | using Ubiquity.NET.Llvm.Values; |
19 | 18 |
|
@@ -58,8 +57,10 @@ public static void Main( string[] args ) |
58 | 57 | srcPath = Path.GetFullPath( srcPath ); |
59 | 58 | #endregion |
60 | 59 |
|
| 60 | + using ILibLlvm library = Library.InitializeLLVM(); |
| 61 | + |
61 | 62 | #region TargetABISelection |
62 | | - using var targetABI = AbiFactory(args[0]); |
| 63 | + ITargetABI? targetABI = AbiFactory(library, args[0]); |
63 | 64 | if(targetABI is null) |
64 | 65 | { |
65 | 66 | ShowUsage(); |
@@ -126,7 +127,7 @@ public static void Main( string[] args ) |
126 | 127 | // add module flags and compiler identifiers... |
127 | 128 | // this can technically occur at any point, though placing it here makes |
128 | 129 | // comparing against clang generated files easier |
129 | | - AddModuleFlags( targetABI, module ); |
| 130 | + AddModuleFlags( targetABI, module, library ); |
130 | 131 | #endregion |
131 | 132 |
|
132 | 133 | #region CreatingQualifiedTypes |
@@ -172,12 +173,12 @@ private static void ShowUsage( ) |
172 | 173 | Console.Error.WriteLine( "Usage: CodeGenWithDebugInfo [X64|M3] <source file path>" ); |
173 | 174 | } |
174 | 175 |
|
175 | | - private static ITargetABI? AbiFactory( string arg ) |
| 176 | + private static ITargetABI? AbiFactory( ILibLlvm library, string arg ) |
176 | 177 | { |
177 | 178 | return arg.ToUpperInvariant() switch |
178 | 179 | { |
179 | | - "M3" => new CortexM3ABI(), |
180 | | - "X64" => new X64ABI(), |
| 180 | + "M3" => new CortexM3ABI(library), |
| 181 | + "X64" => new X64ABI(library), |
181 | 182 | _ => null, |
182 | 183 | }; |
183 | 184 | } |
@@ -258,10 +259,10 @@ private static Function DeclareCopyFunc( ITargetABI abi |
258 | 259 | #endregion |
259 | 260 |
|
260 | 261 | #region AddModuleFlags |
261 | | - private static void AddModuleFlags( ITargetABI abi, Module module ) |
| 262 | + private static void AddModuleFlags( ITargetABI abi, Module module, ILibLlvm library ) |
262 | 263 | { |
263 | 264 | module.AddModuleFlag( ModuleFlagBehavior.Warning, Module.DwarfVersionValue, 4 ); |
264 | | - module.AddModuleFlag( ModuleFlagBehavior.Warning, Module.DebugVersionValue, Module.DebugMetadataVersion ); |
| 265 | + module.AddModuleFlag( ModuleFlagBehavior.Warning, Module.DebugVersionValue, library.DebugMetadataVersion ); |
265 | 266 | abi.AddModuleFlags( module ); |
266 | 267 | module.AddVersionIdentMetadata( VersionIdentString ); |
267 | 268 | } |
|
0 commit comments