MLIR  20.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 class Operation;
25 class OpPrintingFlags;
26 class Pass;
27 
28 #define GEN_PASS_DECL_LOCATIONSNAPSHOT
29 #include "mlir/Transforms/Passes.h.inc"
30 
31 /// This function generates new locations from the given IR by snapshotting the
32 /// IR to the given stream, and using the printed locations within that stream.
33 /// The generated locations replace the current operation locations.
34 void generateLocationsFromIR(raw_ostream &os, StringRef fileName, Operation *op,
35  OpPrintingFlags flags);
36 /// This function generates new locations from the given IR by snapshotting the
37 /// IR to the given file, and using the printed locations within that file. If
38 /// `filename` is empty, a temporary file is generated instead.
39 LogicalResult generateLocationsFromIR(StringRef fileName, Operation *op,
40  OpPrintingFlags flags);
41 
42 /// This function generates new locations from the given IR by snapshotting the
43 /// IR to the given stream, and using the printed locations within that stream.
44 /// The generated locations are represented as a NameLoc with the given tag as
45 /// the name, and then fused with the existing locations.
46 void generateLocationsFromIR(raw_ostream &os, StringRef fileName, StringRef tag,
47  Operation *op, OpPrintingFlags flags);
48 /// This function generates new locations from the given IR by snapshotting the
49 /// IR to the given file, and using the printed locations within that file. If
50 /// `filename` is empty, a temporary file is generated instead.
51 LogicalResult generateLocationsFromIR(StringRef fileName, StringRef tag,
52  Operation *op, OpPrintingFlags flags);
53 
54 /// Create a pass to generate new locations by snapshotting the IR to the given
55 /// file, and using the printed locations within that file. If `filename` is
56 /// empty, a temporary file is generated instead. If a 'tag' is non-empty, the
57 /// generated locations are represented as a NameLoc with the given tag as the
58 /// name, and then fused with the existing locations. Otherwise, the existing
59 /// locations are replaced.
60 std::unique_ptr<Pass> createLocationSnapshotPass(OpPrintingFlags flags,
61  StringRef fileName = "",
62  StringRef tag = "");
63 /// Overload utilizing pass options for initialization.
64 std::unique_ptr<Pass> createLocationSnapshotPass();
65 
66 } // namespace mlir
67 
68 #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...