9 #ifndef MLIR_TRACING_BREAKPOINTMANAGERS_FILELINECOLLOCBREAKPOINTMANAGER_H
10 #define MLIR_TRACING_BREAKPOINTMANAGERS_FILELINECOLLOCBREAKPOINTMANAGER_H
17 #include "llvm/ADT/DenseMap.h"
31 : line(line), col(col) {}
33 void print(raw_ostream &os)
const override {
34 os <<
"Location: " << file <<
':' << line <<
':' << col;
40 static FailureOr<std::tuple<StringRef, int64_t, int64_t>>
parseFromString(
65 if (
auto *op = llvm::dyn_cast_if_present<Operation *>(unit)) {
66 if (
auto match = matchFromLocation(op->getLoc()))
70 if (
auto *block = llvm::dyn_cast_if_present<Block *>(unit)) {
71 for (
auto &op : block->getOperations()) {
72 if (
auto match = matchFromLocation(op.getLoc()))
77 if (
Region *region = llvm::dyn_cast_if_present<Region *>(unit)) {
78 if (
auto match = matchFromLocation(region->getLoc()))
88 auto &breakpoint = breakpoints[std::make_tuple(file, line, col)];
90 breakpoint = std::make_unique<FileLineColLocBreakpoint>(file, line, col);
91 return breakpoint.get();
95 std::optional<Breakpoint *> matchFromLocation(
Location initialLoc)
const {
96 std::optional<Breakpoint *>
match = std::nullopt;
98 auto fileLoc = dyn_cast<FileLineColLoc>(loc);
101 StringRef file = fileLoc.getFilename();
102 int64_t line = fileLoc.getLine();
103 int64_t col = fileLoc.getColumn();
104 auto lookup = breakpoints.find(std::make_tuple(file, line, col));
105 if (lookup != breakpoints.end() && lookup->second->isEnabled()) {
106 match = lookup->second.get();
111 lookup = breakpoints.find(std::make_tuple(file, line, -1));
112 if (lookup != breakpoints.end() && lookup->second->isEnabled()) {
113 match = lookup->second.get();
118 lookup = breakpoints.find(std::make_tuple(file, -1, -1));
119 if (lookup != breakpoints.end() && lookup->second->isEnabled()) {
120 match = lookup->second.get();
129 DenseMap<std::tuple<StringRef, int64_t, int64_t>,
130 std::unique_ptr<FileLineColLocBreakpoint>>
static std::string diag(const llvm::Value &value)
IRUnit is a union of the different types of IR objects that consistute the IR structure (other than T...
WalkResult walk(function_ref< WalkResult(Location)> walkFn)
Walk all of the locations nested directly under, and including, the current.
This class defines the main interface for locations in MLIR and acts as a non-nullable wrapper around...
This class contains a list of basic blocks and a link to the parent operation it is attached to.
static WalkResult advance()
static WalkResult interrupt()
An action is a specific action that is to be taken by the compiler, that can be toggled and controlle...
virtual ArrayRef< IRUnit > getContextIRUnits() const
Return the set of IR units that are associated with this action.
This class provides a CRTP wrapper around a base breakpoint class to define a few necessary utility m...
CRTP base class for BreakpointManager implementations.
This abstract class represents a breakpoint.
This breakpoint manager is responsible for matching FileLineColLocBreakpoint.
FileLineColLocBreakpoint * addBreakpoint(StringRef file, int64_t line, int64_t col=-1)
Breakpoint * match(const Action &action) const override
Try to match a Breakpoint to a given Action.
This breakpoing intends to match a FileLineColLocation, that is a tuple of file name,...
void print(raw_ostream &os) const override
static FailureOr< std::tuple< StringRef, int64_t, int64_t > > parseFromString(StringRef str, llvm::function_ref< void(Twine)> diag=[](Twine) {})
Parse a string representation in the form of "<file>:<line>:<col>".
FileLineColLocBreakpoint(StringRef file, int64_t line, int64_t col)
Include the generated interface declarations.