Skip to content

Commit be185b6

Browse files
committed
Revert "Add indented raw_ostream class"
This reverts commit 78530ce. Fails on shared_lib build.
1 parent b82a748 commit be185b6

File tree

8 files changed

+166
-416
lines changed

8 files changed

+166
-416
lines changed

mlir/include/mlir/Support/IndentedOstream.h

Lines changed: 0 additions & 102 deletions
This file was deleted.

mlir/lib/Support/CMakeLists.txt

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
set(LLVM_OPTIONAL_SOURCES
22
FileUtilities.cpp
3-
IndentedOstream.cpp
43
MlirOptMain.cpp
54
StorageUniquer.cpp
65
ToolUtilities.cpp
@@ -28,10 +27,3 @@ add_mlir_library(MLIROptLib
2827
MLIRParser
2928
MLIRSupport
3029
)
31-
32-
# This doesn't use add_mlir_library as it is used in mlir-tblgen and else
33-
# mlir-tblgen ends up depending on mlir-generic-headers.
34-
add_llvm_library(MLIRSupportIdentedOstream
35-
IndentedOstream.cpp
36-
37-
${MLIR_MAIN_INCLUDE_DIR}/mlir/Support)

mlir/lib/Support/IndentedOstream.cpp

Lines changed: 0 additions & 65 deletions
This file was deleted.

mlir/tools/mlir-tblgen/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ add_tablegen(mlir-tblgen MLIR
2525
set_target_properties(mlir-tblgen PROPERTIES FOLDER "Tablegenning")
2626
target_link_libraries(mlir-tblgen
2727
PRIVATE
28-
MLIRSupportIdentedOstream
2928
MLIRTableGen)
3029

3130
mlir_check_all_link_libraries(mlir-tblgen)

mlir/tools/mlir-tblgen/OpDocGen.cpp

Lines changed: 35 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
//===----------------------------------------------------------------------===//
1313

1414
#include "DocGenUtilities.h"
15-
#include "mlir/Support/IndentedOstream.h"
1615
#include "mlir/TableGen/GenInfo.h"
1716
#include "mlir/TableGen/Operator.h"
1817
#include "llvm/ADT/DenseMap.h"
@@ -36,8 +35,39 @@ using mlir::tblgen::Operator;
3635
// in a way the user wanted but has some additional indenting due to being
3736
// nested in the op definition.
3837
void mlir::tblgen::emitDescription(StringRef description, raw_ostream &os) {
39-
raw_indented_ostream ros(os);
40-
ros.reindent(description.rtrim(" \t"));
38+
// Determine the minimum number of spaces in a line.
39+
size_t min_indent = -1;
40+
StringRef remaining = description;
41+
while (!remaining.empty()) {
42+
auto split = remaining.split('\n');
43+
size_t indent = split.first.find_first_not_of(" \t");
44+
if (indent != StringRef::npos)
45+
min_indent = std::min(indent, min_indent);
46+
remaining = split.second;
47+
}
48+
49+
// Print out the description indented.
50+
os << "\n";
51+
remaining = description;
52+
bool printed = false;
53+
while (!remaining.empty()) {
54+
auto split = remaining.split('\n');
55+
if (split.second.empty()) {
56+
// Skip last line with just spaces.
57+
if (split.first.ltrim().empty())
58+
break;
59+
}
60+
// Print empty new line without spaces if line only has spaces, unless no
61+
// text has been emitted before.
62+
if (split.first.ltrim().empty()) {
63+
if (printed)
64+
os << "\n";
65+
} else {
66+
os << split.first.substr(min_indent) << "\n";
67+
printed = true;
68+
}
69+
remaining = split.second;
70+
}
4171
}
4272

4373
// Emits `str` with trailing newline if not empty.
@@ -86,7 +116,7 @@ static void emitOpDoc(Operator op, raw_ostream &os) {
86116

87117
// Emit the summary, syntax, and description if present.
88118
if (op.hasSummary())
89-
os << "\n" << op.getSummary() << "\n\n";
119+
os << "\n" << op.getSummary() << "\n";
90120
if (op.hasAssemblyFormat())
91121
emitAssemblyFormat(op.getOperationName(), op.getAssemblyFormat().trim(),
92122
os);
@@ -198,7 +228,7 @@ static void emitDialectDoc(const RecordKeeper &recordKeeper, raw_ostream &os) {
198228
}
199229

200230
os << "<!-- Autogenerated by mlir-tblgen; don't manually edit -->\n";
201-
for (const auto &dialectWithOps : dialectOps)
231+
for (auto dialectWithOps : dialectOps)
202232
emitDialectDoc(dialectWithOps.first, dialectWithOps.second,
203233
dialectTypes[dialectWithOps.first], os);
204234
}

0 commit comments

Comments
 (0)