1 | //===------ DumpModulePass.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 | // Write a module to a file. |
10 | // |
11 | //===----------------------------------------------------------------------===// |
12 | |
13 | #ifndef POLLY_SUPPORT_DUMPMODULEPASS_H |
14 | #define POLLY_SUPPORT_DUMPMODULEPASS_H |
15 | |
16 | #include "llvm/IR/PassManager.h" |
17 | #include <string> |
18 | |
19 | namespace llvm { |
20 | class ModulePass; |
21 | } // namespace llvm |
22 | |
23 | namespace polly { |
24 | /// Create a pass that prints the module into a file. |
25 | /// |
26 | /// The meaning of @p Filename depends on @p IsSuffix. If IsSuffix==false, then |
27 | /// the module is written to the @p Filename. If it is true, the filename is |
28 | /// generated from the module's name, @p Filename with an '.ll' extension. |
29 | /// |
30 | /// The intent of IsSuffix is to avoid the file being overwritten when |
31 | /// processing multiple modules and/or with multiple dump passes in the |
32 | /// pipeline. |
33 | llvm::ModulePass *createDumpModuleWrapperPass(std::string Filename, |
34 | bool IsSuffix); |
35 | |
36 | /// A pass that prints the module into a file. |
37 | struct DumpModulePass final : llvm::PassInfoMixin<DumpModulePass> { |
38 | std::string Filename; |
39 | bool IsSuffix; |
40 | |
41 | DumpModulePass(std::string Filename, bool IsSuffix) |
42 | : Filename(std::move(Filename)), IsSuffix(IsSuffix) {} |
43 | |
44 | llvm::PreservedAnalyses run(llvm::Module &M, llvm::ModuleAnalysisManager &AM); |
45 | }; |
46 | |
47 | } // namespace polly |
48 | |
49 | namespace llvm { |
50 | class PassRegistry; |
51 | void initializeDumpModuleWrapperPassPass(llvm::PassRegistry &); |
52 | } // namespace llvm |
53 | |
54 | #endif /* POLLY_SUPPORT_DUMPMODULEPASS_H */ |
55 | |