blob: dbf09ea31e20ca6bf372fe70f6498a831d6e5b8f [file] [log] [blame]
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001//===-- llvm/CodeGen/ParallelCG.h - Parallel code generation ----*- C++ -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10// This header declares functions that can be used for parallel code generation.
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef LLVM_CODEGEN_PARALLELCG_H
15#define LLVM_CODEGEN_PARALLELCG_H
16
17#include "llvm/Support/CodeGen.h"
18#include "llvm/Target/TargetMachine.h"
19
20#include <functional>
21
22namespace llvm {
23
24template <typename T> class ArrayRef;
25class Module;
26class TargetOptions;
27class raw_pwrite_stream;
28
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.
34///
35/// Writes bitcode for individual partitions into output streams in BCOSs, if
36/// BCOSs is not empty.
37///
38/// \returns M if OSs.size() == 1, otherwise returns std::unique_ptr<Module>().
39std::unique_ptr<Module>
40splitCodeGen(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,
Andrew Scullcdfcccc2018-10-05 20:58:37 +010043 TargetMachine::CodeGenFileType FileType = TargetMachine::CGFT_ObjectFile,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +010044 bool PreserveLocals = false);
45
46} // namespace llvm
47
48#endif