MLIR  19.0.0git
ActionLogging.h
Go to the documentation of this file.
1 //===- ActionLogging.h - Logging Actions *- 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 #ifndef MLIR_TRACING_OBSERVERS_ACTIONLOGGING_H
10 #define MLIR_TRACING_OBSERVERS_ACTIONLOGGING_H
11 
14 #include "mlir/IR/Action.h"
15 #include "llvm/ADT/SmallVector.h"
16 #include "llvm/Support/raw_ostream.h"
17 
18 namespace mlir {
19 namespace tracing {
20 
21 /// This class defines an observer that print Actions before and after execution
22 /// on the provided stream.
24  ActionLogger(raw_ostream &os, bool printActions = true,
25  bool printBreakpoints = true, bool printIRUnits = true)
26  : os(os), printActions(printActions), printBreakpoints(printBreakpoints),
27  printIRUnits(printIRUnits) {}
28 
29  void beforeExecute(const ActionActiveStack *action, Breakpoint *breakpoint,
30  bool willExecute) override;
31  void afterExecute(const ActionActiveStack *action) override;
32 
33  /// If one of multiple breakpoint managers are set, only actions that are
34  /// matching a breakpoint will be logged.
35  void addBreakpointManager(const BreakpointManager *manager) {
36  breakpointManagers.push_back(manager);
37  }
38 
39 private:
40  /// Check if we should log this action or not.
41  bool shouldLog(const ActionActiveStack *action);
42 
43  raw_ostream &os;
44  bool printActions;
45  bool printBreakpoints;
46  bool printIRUnits;
47  std::vector<const BreakpointManager *> breakpointManagers;
48 };
49 
50 } // namespace tracing
51 } // namespace mlir
52 
53 #endif // MLIR_TRACING_OBSERVERS_ACTIONLOGGING_H
A breakpoint manager is responsible for managing a set of breakpoints and matching them to a given ac...
This abstract class represents a breakpoint.
Include the generated interface declarations.
This class is used to keep track of the active actions in the stack.
This class defines an observer that print Actions before and after execution on the provided stream.
Definition: ActionLogging.h:23
void beforeExecute(const ActionActiveStack *action, Breakpoint *breakpoint, bool willExecute) override
This method is called before the Action is executed If a breakpoint was hit, it is passed as an argum...
void afterExecute(const ActionActiveStack *action) override
This method is called after the Action is executed, if it was executed.
void addBreakpointManager(const BreakpointManager *manager)
If one of multiple breakpoint managers are set, only actions that are matching a breakpoint will be l...
Definition: ActionLogging.h:35
ActionLogger(raw_ostream &os, bool printActions=true, bool printBreakpoints=true, bool printIRUnits=true)
Definition: ActionLogging.h:24
This abstract class defines the interface used to observe an Action execution.