@@ -171,11 +171,14 @@ LLVMSwift provides a JIT abstraction to make executing code in LLVM modules quic
171
171
172
172
``` swift
173
173
// Setup the JIT
174
- let jit = try ! JIT (module : module, machine : TargetMachine ())
174
+ let jit = try JIT (machine : TargetMachine ())
175
175
typealias FnPtr = @convention (c) (Bool ) -> Double
176
+ _ = try jit.addEagerlyCompiledIR (module) { (name) -> JIT.TargetAddress in
177
+ return JIT.TargetAddress ()
178
+ }
176
179
// Retrieve a handle to the function we're going to invoke
177
- let fnAddr = jit.addressOfFunction ( name : " calculateFibs" )
178
- let fn = unsafeBitCast (fnAddr , to : FnPtr.self )
180
+ let addr = try jit.address ( of : " calculateFibs" )
181
+ let fn = unsafeBitCast (addr , to : FnPtr.self )
179
182
// Call the function!
180
183
print (fn (true )) // 0.00917431192660551...
181
184
print (fn (false )) // 0.0112359550561798...
@@ -186,7 +189,7 @@ print(fn(false)) // 0.0112359550561798...
186
189
There are a couple annoying steps you need to accomplish before building
187
190
LLVMSwift:
188
191
189
- - Install LLVM 5 .0+ using your favorite package manager. For example:
192
+ - Install LLVM 7 .0+ using your favorite package manager. For example:
190
193
- ` brew install llvm `
191
194
- Ensure ` llvm-config ` is in your ` PATH `
192
195
- That will reside in the ` /bin ` folder wherever your package manager
@@ -200,7 +203,7 @@ compiler projects!
200
203
### Installation with Swift Package Manager
201
204
202
205
``` swift
203
- .package (url : " https://github.com/llvm-swift/LLVMSwift.git" , from : " 0.2 .0" )
206
+ .package (url : " https://github.com/llvm-swift/LLVMSwift.git" , from : " 0.4 .0" )
204
207
```
205
208
206
209
### Installation without Swift Package Manager
0 commit comments