1 //===-- llvm/CodeGen/ParallelCG.h - Parallel code generation ----*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This header declares functions that can be used for parallel code generation.
12 //===----------------------------------------------------------------------===//
14 #ifndef LLVM_CODEGEN_PARALLELCG_H
15 #define LLVM_CODEGEN_PARALLELCG_H
17 #include "llvm/Support/CodeGen.h"
18 #include "llvm/Target/TargetMachine.h"
24 template <typename T> class ArrayRef;
27 class raw_pwrite_stream;
29 /// Split M into OSs.size() partitions, and generate code for each. Takes a
30 /// factory function for the TargetMachine TMFactory. Writes OSs.size() output
31 /// files to the output streams in OSs. The resulting output files if linked
32 /// together are intended to be equivalent to the single output file that would
33 /// have been code generated from M.
35 /// Writes bitcode for individual partitions into output streams in BCOSs, if
36 /// BCOSs is not empty.
38 /// \returns M if OSs.size() == 1, otherwise returns std::unique_ptr<Module>().
39 std::unique_ptr<Module>
40 splitCodeGen(std::unique_ptr<Module> M, ArrayRef<raw_pwrite_stream *> OSs,
41 ArrayRef<llvm::raw_pwrite_stream *> BCOSs,
42 const std::function<std::unique_ptr<TargetMachine>()> &TMFactory,
43 TargetMachine::CodeGenFileType FileType = TargetMachine::CGFT_ObjectFile,
44 bool PreserveLocals = false);