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
19namespace llvm {
20class ModulePass;
21} // namespace llvm
22
23namespace 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.
33llvm::ModulePass *createDumpModuleWrapperPass(std::string Filename,
34 bool IsSuffix);
35
36/// A pass that prints the module into a file.
37struct 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
49namespace llvm {
50class PassRegistry;
51void initializeDumpModuleWrapperPassPass(llvm::PassRegistry &);
52} // namespace llvm
53
54#endif /* POLLY_SUPPORT_DUMPMODULEPASS_H */
55

source code of polly/include/polly/Support/DumpModulePass.h