Skip to content

Commit c52ce3a

Browse files
committed
Revert "Fix MLIR-TblGen to fix KW issues (#1)"
This reverts commit 1847b61.
1 parent 2ea951a commit c52ce3a

File tree

2 files changed

+19
-34
lines changed

2 files changed

+19
-34
lines changed

mlir/tools/mlir-tblgen/OpFormatGen.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -845,7 +845,7 @@ static void genElementParserStorage(FormatElement *element, const Operator &op,
845845
}
846846
} else {
847847
body << " ::mlir::OpAsmParser::UnresolvedOperand " << name
848-
<< "RawOperands = { };\n"
848+
<< "RawOperand{};\n"
849849
<< " ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> "
850850
<< name << "Operands(&" << name << "RawOperand, 1);";
851851
}
@@ -882,10 +882,11 @@ static void genElementParserStorage(FormatElement *element, const Operator &op,
882882
if (lengthKind != ArgumentLengthKind::Single)
883883
body << " ::llvm::SmallVector<::mlir::Type, 1> " << name << "Types;\n";
884884
else
885-
body << llvm::formatv(" ::mlir::Type {0}RawTypes = {{ };\n", name)
886-
<< llvm::formatv(
887-
" ::llvm::ArrayRef<::mlir::Type> {0}Types({0}RawTypes);\n",
888-
name);
885+
body
886+
<< llvm::formatv(" ::mlir::Type {0}RawType{{};\n", name)
887+
<< llvm::formatv(
888+
" ::llvm::ArrayRef<::mlir::Type> {0}Types(&{0}RawType, 1);\n",
889+
name);
889890
} else if (auto *dir = dyn_cast<FunctionalTypeDirective>(element)) {
890891
ArgumentLengthKind ignored;
891892
body << " ::llvm::ArrayRef<::mlir::Type> "

mlir/tools/mlir-tblgen/OpInterfacesGen.cpp

Lines changed: 13 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -179,18 +179,13 @@ static void emitInterfaceDefMethods(StringRef interfaceQualName,
179179
raw_ostream &os, bool isOpInterface) {
180180
for (auto &method : interface.getMethods()) {
181181
emitInterfaceMethodDoc(method, os);
182-
auto returnType = method.getReturnType();
183-
emitCPPType(returnType, os);
182+
emitCPPType(method.getReturnType(), os);
184183
os << interfaceQualName << "::";
185184
emitMethodNameAndArgs(method, os, valueType, /*addThisArg=*/false,
186185
/*addConst=*/!isOpInterface);
187186

188187
// Forward to the method on the concrete operation type.
189-
os << " {\n ";
190-
if (returnType != "void") {
191-
os << "return ";
192-
}
193-
os << implValue << "->" << method.getName() << '(';
188+
os << " {\n return " << implValue << "->" << method.getName() << '(';
194189
if (!method.isStatic()) {
195190
os << implValue << ", ";
196191
os << (isOpInterface ? "getOperation()" : "*this");
@@ -350,8 +345,7 @@ void InterfaceGenerator::emitModelMethodsDef(const Interface &interface) {
350345

351346
for (auto &method : interface.getMethods()) {
352347
os << "template<typename " << valueTemplate << ">\n";
353-
auto returnType = method.getReturnType();
354-
emitCPPType(returnType, os);
348+
emitCPPType(method.getReturnType(), os);
355349
os << "detail::" << interface.getName() << "InterfaceTraits::Model<"
356350
<< valueTemplate << ">::";
357351
emitMethodNameAndArgs(method, os, valueType,
@@ -370,15 +364,10 @@ void InterfaceGenerator::emitModelMethodsDef(const Interface &interface) {
370364
}
371365

372366
// Forward to the method on the concrete operation type.
373-
if (returnType != "void") {
374-
os << "return ";
375-
}
376-
377-
if (method.isStatic()) {
378-
os << valueTemplate << "::";
379-
} else {
380-
os << tblgen::tgfmt("$_self.", &nonStaticMethodFmt);
381-
}
367+
if (method.isStatic())
368+
os << "return " << valueTemplate << "::";
369+
else
370+
os << tblgen::tgfmt("return $_self.", &nonStaticMethodFmt);
382371

383372
// Add the arguments to the call.
384373
os << method.getName() << '(';
@@ -390,8 +379,7 @@ void InterfaceGenerator::emitModelMethodsDef(const Interface &interface) {
390379

391380
for (auto &method : interface.getMethods()) {
392381
os << "template<typename " << valueTemplate << ">\n";
393-
auto returnType = method.getReturnType();
394-
emitCPPType(returnType, os);
382+
emitCPPType(method.getReturnType(), os);
395383
os << "detail::" << interface.getName() << "InterfaceTraits::FallbackModel<"
396384
<< valueTemplate << ">::";
397385
emitMethodNameAndArgs(method, os, valueType,
@@ -400,15 +388,11 @@ void InterfaceGenerator::emitModelMethodsDef(const Interface &interface) {
400388
os << " {\n ";
401389

402390
// Forward to the method on the concrete Model implementation.
403-
if (returnType != "void") {
404-
os << "return ";
405-
}
391+
if (method.isStatic())
392+
os << "return " << valueTemplate << "::";
393+
else
394+
os << "return static_cast<const " << valueTemplate << " *>(impl)->";
406395

407-
if (method.isStatic()) {
408-
os << valueTemplate << "::";
409-
} else {
410-
os << "static_cast<const " << valueTemplate << " *>(impl)->";
411-
}
412396
// Add the arguments to the call.
413397
os << method.getName() << '(';
414398
if (!method.isStatic())
@@ -446,7 +430,7 @@ void InterfaceGenerator::emitModelMethodsDef(const Interface &interface) {
446430
if (!method.isStatic())
447431
os << " const";
448432

449-
os << " {\n ";
433+
os << " {\n";
450434

451435
// Use the empty context for static methods.
452436
tblgen::FmtContext ctx;

0 commit comments

Comments
 (0)