19
19
20
20
#include " swift/Basic/LLVM.h"
21
21
#include " swift/Basic/OptionSet.h"
22
+ #include " swift/Basic/Version.h"
22
23
#include " llvm/IR/LLVMContext.h"
23
24
#include " llvm/ADT/ArrayRef.h"
24
25
#include " llvm/ADT/Optional.h"
25
26
#include " llvm/ADT/StringRef.h"
27
+ #include " llvm/Support/Mutex.h"
26
28
27
29
#include < memory>
28
30
29
31
namespace llvm {
32
+ class GlobalVariable ;
30
33
class MemoryBuffer ;
31
34
class Module ;
32
35
class TargetOptions ;
@@ -258,18 +261,22 @@ namespace swift {
258
261
259
262
// / Turn the given Swift module into either LLVM IR or native code
260
263
// / and return the generated LLVM IR module.
264
+ // / If you set an outModuleHash, then you need to call performLLVM.
261
265
std::unique_ptr<llvm::Module>
262
266
performIRGeneration (IRGenOptions &Opts, ModuleDecl *M,
263
267
std::unique_ptr<SILModule> SILMod,
264
- StringRef ModuleName, llvm::LLVMContext &LLVMContext);
268
+ StringRef ModuleName, llvm::LLVMContext &LLVMContext,
269
+ llvm::GlobalVariable **outModuleHash = nullptr );
265
270
266
271
// / Turn the given Swift module into either LLVM IR or native code
267
272
// / and return the generated LLVM IR module.
273
+ // / If you set an outModuleHash, then you need to call performLLVM.
268
274
std::unique_ptr<llvm::Module>
269
275
performIRGeneration (IRGenOptions &Opts, SourceFile &SF,
270
276
std::unique_ptr<SILModule> SILMod,
271
277
StringRef ModuleName, llvm::LLVMContext &LLVMContext,
272
- unsigned StartElem = 0 );
278
+ unsigned StartElem = 0 ,
279
+ llvm::GlobalVariable **outModuleHash = nullptr );
273
280
274
281
// / Given an already created LLVM module, construct a pass pipeline and run
275
282
// / the Swift LLVM Pipeline upon it. This does not cause the module to be
@@ -285,6 +292,29 @@ namespace swift {
285
292
bool performLLVM (IRGenOptions &Opts, ASTContext &Ctx,
286
293
llvm::Module *Module);
287
294
295
+ // / Run the LLVM passes. In multi-threaded compilation this will be done for
296
+ // / multiple LLVM modules in parallel.
297
+ // / \param Diags may be null if LLVM code gen diagnostics are not required.
298
+ // / \param DiagMutex may also be null if a mutex around \p Diags is not
299
+ // / required.
300
+ // / \param HashGlobal used with incremental LLVMCodeGen to know if a module
301
+ // / was already compiled, may be null if not desired.
302
+ // / \param Module LLVM module to code gen, required.
303
+ // / \param TargetMachine target of code gen, required.
304
+ // / \param effectiveLanguageVersion version of the language, effectively.
305
+ // / \param OutputFilename Filename for output.
306
+ bool performLLVM (IRGenOptions &Opts, DiagnosticEngine *Diags,
307
+ llvm::sys::Mutex *DiagMutex,
308
+ llvm::GlobalVariable *HashGlobal,
309
+ llvm::Module *Module,
310
+ llvm::TargetMachine *TargetMachine,
311
+ const version::Version &effectiveLanguageVersion,
312
+ StringRef OutputFilename);
313
+
314
+ // / Creates a TargetMachine from the IRGen opts and AST Context.
315
+ std::unique_ptr<llvm::TargetMachine>
316
+ createTargetMachine (IRGenOptions &Opts, ASTContext &Ctx);
317
+
288
318
// / A convenience wrapper for Parser functionality.
289
319
class ParserUnit {
290
320
public:
0 commit comments