[InstCombine] Signed saturation patterns
[llvm-core.git] / include / llvm / Passes / StandardInstrumentations.h
blob3d3002eecce98ccb48548bb7db9585df85c9a632
1 //===- StandardInstrumentations.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 /// \file
9 ///
10 /// This header defines a class that provides bookkeeping for all standard
11 /// (i.e in-tree) pass instrumentations.
12 ///
13 //===----------------------------------------------------------------------===//
15 #ifndef LLVM_PASSES_STANDARDINSTRUMENTATIONS_H
16 #define LLVM_PASSES_STANDARDINSTRUMENTATIONS_H
18 #include "llvm/ADT/SmallVector.h"
19 #include "llvm/IR/PassInstrumentation.h"
20 #include "llvm/IR/PassTimingInfo.h"
22 #include <string>
23 #include <utility>
25 namespace llvm {
27 class Module;
29 /// Instrumentation to print IR before/after passes.
30 ///
31 /// Needs state to be able to print module after pass that invalidates IR unit
32 /// (typically Loop or SCC).
33 class PrintIRInstrumentation {
34 public:
35 PrintIRInstrumentation() = default;
36 ~PrintIRInstrumentation();
38 void registerCallbacks(PassInstrumentationCallbacks &PIC);
40 private:
41 bool printBeforePass(StringRef PassID, Any IR);
42 void printAfterPass(StringRef PassID, Any IR);
43 void printAfterPassInvalidated(StringRef PassID);
45 using PrintModuleDesc = std::tuple<const Module *, std::string, StringRef>;
47 void pushModuleDesc(StringRef PassID, Any IR);
48 PrintModuleDesc popModuleDesc(StringRef PassID);
50 /// Stack of Module description, enough to print the module after a given
51 /// pass.
52 SmallVector<PrintModuleDesc, 2> ModuleDescStack;
53 bool StoreModuleDesc = false;
56 /// This class provides an interface to register all the standard pass
57 /// instrumentations and manages their state (if any).
58 class StandardInstrumentations {
59 PrintIRInstrumentation PrintIR;
60 TimePassesHandler TimePasses;
62 public:
63 StandardInstrumentations() = default;
65 void registerCallbacks(PassInstrumentationCallbacks &PIC);
67 TimePassesHandler &getTimePasses() { return TimePasses; }
69 } // namespace llvm
71 #endif