xref: /freebsd/contrib/llvm-project/llvm/lib/Target/AMDGPU/AMDGPUSplitModule.h (revision 0fca6ea1d4eea4c934cfff25ac9ee8ad6fe95583)
1 //===- AMDGPUSplitModule.h -------------------------------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 //===----------------------------------------------------------------------===//
10 
11 #ifndef LLVM_TARGET_AMDGPUSPLITMODULE_H
12 #define LLVM_TARGET_AMDGPUSPLITMODULE_H
13 
14 #include "llvm/ADT/STLFunctionalExtras.h"
15 #include "llvm/IR/PassManager.h"
16 #include <memory>
17 
18 namespace llvm {
19 
20 /// Splits the module M into N linkable partitions. The function ModuleCallback
21 /// is called N times passing each individual partition as the MPart argument.
22 class AMDGPUSplitModulePass : public PassInfoMixin<AMDGPUSplitModulePass> {
23 public:
24   using ModuleCreationCallback =
25       function_ref<void(std::unique_ptr<Module> MPart)>;
26 
AMDGPUSplitModulePass(unsigned N,ModuleCreationCallback ModuleCallback)27   AMDGPUSplitModulePass(unsigned N, ModuleCreationCallback ModuleCallback)
28       : N(N), ModuleCallback(ModuleCallback) {}
29 
30   PreservedAnalyses run(Module &M, ModuleAnalysisManager &MAM);
31 
32 private:
33   unsigned N;
34   ModuleCreationCallback ModuleCallback;
35 };
36 
37 } // end namespace llvm
38 
39 #endif // LLVM_TARGET_AMDGPUSPLITMODULE_H
40