MLIR  19.0.0git
LocationSnapshot.h
Go to the documentation of this file.
1 //===- LocationSnapshot.h - Location Snapshot Utilities ---------*- 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 // This header file several utility methods for snapshotting the current IR to
10 // produce new debug locations.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #ifndef MLIR_TRANSFORMS_LOCATIONSNAPSHOT_H
15 #define MLIR_TRANSFORMS_LOCATIONSNAPSHOT_H
16 
17 #include "mlir/Support/LLVM.h"
18 #include "llvm/ADT/StringRef.h"
19 
20 #include <memory>
21 
22 namespace mlir {
23 class Location;
24 struct LogicalResult;
25 class Operation;
26 class OpPrintingFlags;
27 class Pass;
28 
29 #define GEN_PASS_DECL_LOCATIONSNAPSHOT
30 #include "mlir/Transforms/Passes.h.inc"
31 
32 /// This function generates new locations from the given IR by snapshotting the
33 /// IR to the given stream, and using the printed locations within that stream.
34 /// The generated locations replace the current operation locations.
35 void generateLocationsFromIR(raw_ostream &os, StringRef fileName, Operation *op,
36  OpPrintingFlags flags);
37 /// This function generates new locations from the given IR by snapshotting the
38 /// IR to the given file, and using the printed locations within that file. If
39 /// `filename` is empty, a temporary file is generated instead.
40 LogicalResult generateLocationsFromIR(StringRef fileName, Operation *op,
41  OpPrintingFlags flags);
42 
43 /// This function generates new locations from the given IR by snapshotting the
44 /// IR to the given stream, and using the printed locations within that stream.
45 /// The generated locations are represented as a NameLoc with the given tag as
46 /// the name, and then fused with the existing locations.
47 void generateLocationsFromIR(raw_ostream &os, StringRef fileName, StringRef tag,
48  Operation *op, OpPrintingFlags flags);
49 /// This function generates new locations from the given IR by snapshotting the
50 /// IR to the given file, and using the printed locations within that file. If
51 /// `filename` is empty, a temporary file is generated instead.
52 LogicalResult generateLocationsFromIR(StringRef fileName, StringRef tag,
53  Operation *op, OpPrintingFlags flags);
54 
55 /// Create a pass to generate new locations by snapshotting the IR to the given
56 /// file, and using the printed locations within that file. If `filename` is
57 /// empty, a temporary file is generated instead. If a 'tag' is non-empty, the
58 /// generated locations are represented as a NameLoc with the given tag as the
59 /// name, and then fused with the existing locations. Otherwise, the existing
60 /// locations are replaced.
61 std::unique_ptr<Pass> createLocationSnapshotPass(OpPrintingFlags flags,
62  StringRef fileName = "",
63  StringRef tag = "");
64 /// Overload utilizing pass options for initialization.
65 std::unique_ptr<Pass> createLocationSnapshotPass();
66 
67 } // namespace mlir
68 
69 #endif // MLIR_TRANSFORMS_LOCATIONSNAPSHOT_H
Include the generated interface declarations.
void generateLocationsFromIR(raw_ostream &os, StringRef fileName, Operation *op, OpPrintingFlags flags)
This function generates new locations from the given IR by snapshotting the IR to the given stream,...
std::unique_ptr< Pass > createLocationSnapshotPass(OpPrintingFlags flags, StringRef fileName="", StringRef tag="")
Create a pass to generate new locations by snapshotting the IR to the given file, and using the print...