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