|
10 | 10 |
|
11 | 11 | #include "mlir/IR/AsmState.h" |
12 | 12 | #include "mlir/IR/Builders.h" |
| 13 | +#include "mlir/IR/OperationSupport.h" |
13 | 14 | #include "mlir/Pass/Pass.h" |
14 | 15 | #include "mlir/Support/FileUtilities.h" |
15 | 16 | #include "llvm/Support/FileSystem.h" |
@@ -131,29 +132,23 @@ LogicalResult mlir::generateLocationsFromIR(StringRef fileName, StringRef tag, |
131 | 132 | namespace { |
132 | 133 | struct LocationSnapshotPass |
133 | 134 | : public impl::LocationSnapshotBase<LocationSnapshotPass> { |
134 | | - LocationSnapshotPass() = default; |
135 | | - LocationSnapshotPass(OpPrintingFlags flags, StringRef fileName, StringRef tag) |
136 | | - : flags(flags) { |
137 | | - this->fileName = fileName.str(); |
138 | | - this->tag = tag.str(); |
139 | | - } |
| 135 | + using impl::LocationSnapshotBase<LocationSnapshotPass>::LocationSnapshotBase; |
140 | 136 |
|
141 | 137 | void runOnOperation() override { |
142 | 138 | Operation *op = getOperation(); |
143 | | - if (failed(generateLocationsFromIR(fileName, op, OpPrintingFlags(), tag))) |
| 139 | + if (failed(generateLocationsFromIR(fileName, op, getFlags(), tag))) |
144 | 140 | return signalPassFailure(); |
145 | 141 | } |
146 | 142 |
|
147 | | - /// The printing flags to use when creating the snapshot. |
148 | | - OpPrintingFlags flags; |
| 143 | +private: |
| 144 | + /// build the flags from the command line arguments to the pass |
| 145 | + OpPrintingFlags getFlags() { |
| 146 | + OpPrintingFlags flags; |
| 147 | + flags.enableDebugInfo(enableDebugInfo, printPrettyDebugInfo); |
| 148 | + flags.printGenericOpForm(printGenericOpForm); |
| 149 | + if (useLocalScope) |
| 150 | + flags.useLocalScope(); |
| 151 | + return flags; |
| 152 | + } |
149 | 153 | }; |
150 | 154 | } // namespace |
151 | | - |
152 | | -std::unique_ptr<Pass> mlir::createLocationSnapshotPass(OpPrintingFlags flags, |
153 | | - StringRef fileName, |
154 | | - StringRef tag) { |
155 | | - return std::make_unique<LocationSnapshotPass>(flags, fileName, tag); |
156 | | -} |
157 | | -std::unique_ptr<Pass> mlir::createLocationSnapshotPass() { |
158 | | - return std::make_unique<LocationSnapshotPass>(); |
159 | | -} |
0 commit comments