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 } // namespace mlir 55 56 #endif // MLIR_TRANSFORMS_LOCATIONSNAPSHOT_H 57