[Mlir-commits] [mlir] [mlir][tblgen] Expose all of TableGen as library (PR #92709)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Sun May 19 16:09:32 PDT 2024
github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {clang-format}-->
:warning: C/C++ code formatter, clang-format found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
git-clang-format --diff 2f52bbeb6f6f3b7abef19cb5297773d95aa0b434 d75d60f51365972935d2f76a428510801ccfcaca -- mlir/include/mlir/TableGen/AttrOrTypeFormatGen.h mlir/include/mlir/TableGen/DialectGenUtilities.h mlir/include/mlir/TableGen/DocGenUtilities.h mlir/include/mlir/TableGen/FormatGen.h mlir/include/mlir/TableGen/OpClass.h mlir/include/mlir/TableGen/OpFormatGen.h mlir/include/mlir/TableGen/OpGenHelpers.h mlir/lib/TableGen/AttrOrTypeDefGen.cpp mlir/lib/TableGen/AttrOrTypeFormatGen.cpp mlir/lib/TableGen/BytecodeDialectGen.cpp mlir/lib/TableGen/DialectGen.cpp mlir/lib/TableGen/DirectiveCommonGen.cpp mlir/lib/TableGen/EnumPythonBindingGen.cpp mlir/lib/TableGen/EnumsGen.cpp mlir/lib/TableGen/FormatGen.cpp mlir/lib/TableGen/LLVMIRConversionGen.cpp mlir/lib/TableGen/LLVMIRIntrinsicGen.cpp mlir/lib/TableGen/OpClass.cpp mlir/lib/TableGen/OpDefinitionsGen.cpp mlir/lib/TableGen/OpDocGen.cpp mlir/lib/TableGen/OpFormatGen.cpp mlir/lib/TableGen/OpGenHelpers.cpp mlir/lib/TableGen/OpInterfacesGen.cpp mlir/lib/TableGen/OpPythonBindingGen.cpp mlir/lib/TableGen/PassCAPIGen.cpp mlir/lib/TableGen/PassDocGen.cpp mlir/lib/TableGen/PassGen.cpp mlir/lib/TableGen/RewriterGen.cpp mlir/lib/TableGen/SPIRVUtilsGen.cpp
``````````
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/mlir/lib/TableGen/AttrOrTypeDefGen.cpp b/mlir/lib/TableGen/AttrOrTypeDefGen.cpp
index 4f792b2cfa..a3f7e77251 100644
--- a/mlir/lib/TableGen/AttrOrTypeDefGen.cpp
+++ b/mlir/lib/TableGen/AttrOrTypeDefGen.cpp
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#include "mlir/TableGen/AttrOrTypeFormatGen.h"
#include "mlir/TableGen/AttrOrTypeDef.h"
+#include "mlir/TableGen/AttrOrTypeFormatGen.h"
#include "mlir/TableGen/Class.h"
#include "mlir/TableGen/CodeGenHelpers.h"
#include "mlir/TableGen/Format.h"
diff --git a/mlir/lib/TableGen/AttrOrTypeFormatGen.cpp b/mlir/lib/TableGen/AttrOrTypeFormatGen.cpp
index bba237ddb4..e03a19369b 100644
--- a/mlir/lib/TableGen/AttrOrTypeFormatGen.cpp
+++ b/mlir/lib/TableGen/AttrOrTypeFormatGen.cpp
@@ -7,11 +7,11 @@
//===----------------------------------------------------------------------===//
#include "mlir/TableGen/AttrOrTypeFormatGen.h"
-#include "mlir/TableGen/FormatGen.h"
#include "mlir/Support/LLVM.h"
#include "mlir/Support/LogicalResult.h"
#include "mlir/TableGen/AttrOrTypeDef.h"
#include "mlir/TableGen/Format.h"
+#include "mlir/TableGen/FormatGen.h"
#include "mlir/TableGen/GenInfo.h"
#include "llvm/ADT/BitVector.h"
#include "llvm/ADT/StringExtras.h"
diff --git a/mlir/lib/TableGen/BytecodeDialectGen.cpp b/mlir/lib/TableGen/BytecodeDialectGen.cpp
index 66a3750d7c..82f887f595 100644
--- a/mlir/lib/TableGen/BytecodeDialectGen.cpp
+++ b/mlir/lib/TableGen/BytecodeDialectGen.cpp
@@ -134,7 +134,9 @@ void Generator::emitParse(StringRef kind, Record &x) {
R"(static {0} read{1}(MLIRContext* context, DialectBytecodeReader &reader) )";
mlir::raw_indented_ostream os(output);
std::string returnType = getCType(&x);
- os << formatv(head, kind == "attribute" ? "::mlir::Attribute" : "::mlir::Type", x.getName());
+ os << formatv(head,
+ kind == "attribute" ? "::mlir::Attribute" : "::mlir::Type",
+ x.getName());
DagInit *members = x.getValueAsDag("members");
SmallVector<std::string> argNames =
llvm::to_vector(map_range(members->getArgNames(), [](StringInit *init) {
diff --git a/mlir/lib/TableGen/DialectGen.cpp b/mlir/lib/TableGen/DialectGen.cpp
index 8b4cdc52ad..17c2cbcf37 100644
--- a/mlir/lib/TableGen/DialectGen.cpp
+++ b/mlir/lib/TableGen/DialectGen.cpp
@@ -10,9 +10,9 @@
//
//===----------------------------------------------------------------------===//
-#include "mlir/TableGen/DialectGenUtilities.h"
#include "mlir/TableGen/Class.h"
#include "mlir/TableGen/CodeGenHelpers.h"
+#include "mlir/TableGen/DialectGenUtilities.h"
#include "mlir/TableGen/Format.h"
#include "mlir/TableGen/GenInfo.h"
#include "mlir/TableGen/Interfaces.h"
diff --git a/mlir/lib/TableGen/EnumsGen.cpp b/mlir/lib/TableGen/EnumsGen.cpp
index 85bd7e8c59..e836d86b91 100644
--- a/mlir/lib/TableGen/EnumsGen.cpp
+++ b/mlir/lib/TableGen/EnumsGen.cpp
@@ -10,9 +10,9 @@
//
//===----------------------------------------------------------------------===//
-#include "mlir/TableGen/FormatGen.h"
#include "mlir/TableGen/Attribute.h"
#include "mlir/TableGen/Format.h"
+#include "mlir/TableGen/FormatGen.h"
#include "mlir/TableGen/GenInfo.h"
#include "llvm/ADT/BitVector.h"
#include "llvm/ADT/SmallVector.h"
diff --git a/mlir/lib/TableGen/OpDefinitionsGen.cpp b/mlir/lib/TableGen/OpDefinitionsGen.cpp
index a4e702f4b2..06f3fceefd 100644
--- a/mlir/lib/TableGen/OpDefinitionsGen.cpp
+++ b/mlir/lib/TableGen/OpDefinitionsGen.cpp
@@ -11,9 +11,6 @@
//
//===----------------------------------------------------------------------===//
-#include "mlir/TableGen/OpClass.h"
-#include "mlir/TableGen/OpFormatGen.h"
-#include "mlir/TableGen/OpGenHelpers.h"
#include "mlir/TableGen/Argument.h"
#include "mlir/TableGen/Attribute.h"
#include "mlir/TableGen/Class.h"
@@ -21,6 +18,9 @@
#include "mlir/TableGen/Format.h"
#include "mlir/TableGen/GenInfo.h"
#include "mlir/TableGen/Interfaces.h"
+#include "mlir/TableGen/OpClass.h"
+#include "mlir/TableGen/OpFormatGen.h"
+#include "mlir/TableGen/OpGenHelpers.h"
#include "mlir/TableGen/Operator.h"
#include "mlir/TableGen/Property.h"
#include "mlir/TableGen/SideEffects.h"
diff --git a/mlir/lib/TableGen/OpDocGen.cpp b/mlir/lib/TableGen/OpDocGen.cpp
index de77d0a361..63da3711fd 100644
--- a/mlir/lib/TableGen/OpDocGen.cpp
+++ b/mlir/lib/TableGen/OpDocGen.cpp
@@ -11,12 +11,12 @@
//
//===----------------------------------------------------------------------===//
-#include "mlir/TableGen/DialectGenUtilities.h"
-#include "mlir/TableGen/DocGenUtilities.h"
-#include "mlir/TableGen/OpGenHelpers.h"
#include "mlir/Support/IndentedOstream.h"
#include "mlir/TableGen/AttrOrTypeDef.h"
+#include "mlir/TableGen/DialectGenUtilities.h"
+#include "mlir/TableGen/DocGenUtilities.h"
#include "mlir/TableGen/GenInfo.h"
+#include "mlir/TableGen/OpGenHelpers.h"
#include "mlir/TableGen/Operator.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/SetVector.h"
diff --git a/mlir/lib/TableGen/OpFormatGen.cpp b/mlir/lib/TableGen/OpFormatGen.cpp
index 4e157d4092..cf7095b363 100644
--- a/mlir/lib/TableGen/OpFormatGen.cpp
+++ b/mlir/lib/TableGen/OpFormatGen.cpp
@@ -7,11 +7,11 @@
//===----------------------------------------------------------------------===//
#include "mlir/TableGen/OpFormatGen.h"
-#include "mlir/TableGen/FormatGen.h"
-#include "mlir/TableGen/OpClass.h"
#include "mlir/Support/LLVM.h"
#include "mlir/TableGen/Class.h"
#include "mlir/TableGen/Format.h"
+#include "mlir/TableGen/FormatGen.h"
+#include "mlir/TableGen/OpClass.h"
#include "mlir/TableGen/Operator.h"
#include "mlir/TableGen/Trait.h"
#include "llvm/ADT/MapVector.h"
diff --git a/mlir/lib/TableGen/OpInterfacesGen.cpp b/mlir/lib/TableGen/OpInterfacesGen.cpp
index a76fbbbbc7..8d6255bba3 100644
--- a/mlir/lib/TableGen/OpInterfacesGen.cpp
+++ b/mlir/lib/TableGen/OpInterfacesGen.cpp
@@ -588,7 +588,8 @@ void InterfaceGenerator::emitInterfaceDecl(const Interface &interface) {
<< " auto* interface = getInterfaceFor(base);\n"
<< " if (!interface)\n"
" return false;\n"
- " " << interfaceName << " odsInterfaceInstance(base, interface);\n"
+ " "
+ << interfaceName << " odsInterfaceInstance(base, interface);\n"
<< " " << tblgen::tgfmt(extraClassOf->trim(), &extraClassOfFmt)
<< "\n }\n";
}
diff --git a/mlir/lib/TableGen/RewriterGen.cpp b/mlir/lib/TableGen/RewriterGen.cpp
index e63a065a07..811f85952f 100644
--- a/mlir/lib/TableGen/RewriterGen.cpp
+++ b/mlir/lib/TableGen/RewriterGen.cpp
@@ -610,7 +610,8 @@ void PatternEmitter::emitOpMatch(DagNode tree, StringRef opName, int depth) {
++opArgIdx;
continue;
}
- if (auto *operand = llvm::dyn_cast_if_present<NamedTypeConstraint *>(opArg)) {
+ if (auto *operand =
+ llvm::dyn_cast_if_present<NamedTypeConstraint *>(opArg)) {
if (argTree.isVariadic()) {
if (!operand->isVariadic()) {
auto error = formatv("variadic DAG construct can't match op {0}'s "
@@ -1669,8 +1670,8 @@ void PatternEmitter::createSeparateLocalVarsForOpArgs(
int valueIndex = 0; // An index for uniquing local variable names.
for (int argIndex = 0, e = resultOp.getNumArgs(); argIndex < e; ++argIndex) {
- const auto *operand =
- llvm::dyn_cast_if_present<NamedTypeConstraint *>(resultOp.getArg(argIndex));
+ const auto *operand = llvm::dyn_cast_if_present<NamedTypeConstraint *>(
+ resultOp.getArg(argIndex));
// We do not need special handling for attributes.
if (!operand)
continue;
@@ -1725,7 +1726,8 @@ void PatternEmitter::supplyValuesForOpArgs(
Argument opArg = resultOp.getArg(argIndex);
// Handle the case of operand first.
- if (auto *operand = llvm::dyn_cast_if_present<NamedTypeConstraint *>(opArg)) {
+ if (auto *operand =
+ llvm::dyn_cast_if_present<NamedTypeConstraint *>(opArg)) {
if (!operand->name.empty())
os << "/*" << operand->name << "=*/";
os << childNodeNames.lookup(argIndex);
diff --git a/mlir/lib/TableGen/SPIRVUtilsGen.cpp b/mlir/lib/TableGen/SPIRVUtilsGen.cpp
index 9aeb14d14e..62be18afd1 100644
--- a/mlir/lib/TableGen/SPIRVUtilsGen.cpp
+++ b/mlir/lib/TableGen/SPIRVUtilsGen.cpp
@@ -399,10 +399,9 @@ static void emitAvailabilityQueryForBitEnum(const Record &enumDef,
avail.getMergeInstanceType(), avail.getQueryFnName(),
enumName);
- os << formatv(
- " assert(::llvm::popcount(static_cast<{0}>(value)) <= 1"
- " && \"cannot have more than one bit set\");\n",
- underlyingType);
+ os << formatv(" assert(::llvm::popcount(static_cast<{0}>(value)) <= 1"
+ " && \"cannot have more than one bit set\");\n",
+ underlyingType);
os << " switch (value) {\n";
for (const auto &caseSpecPair : classCasePair.getValue()) {
@@ -936,7 +935,8 @@ static void emitOperandDeserialization(const Operator &op, ArrayRef<SMLoc> loc,
// Process operands/attributes
for (unsigned i = 0, e = op.getNumArgs(); i < e; ++i) {
auto argument = op.getArg(i);
- if (auto *valueArg = llvm::dyn_cast_if_present<NamedTypeConstraint *>(argument)) {
+ if (auto *valueArg =
+ llvm::dyn_cast_if_present<NamedTypeConstraint *>(argument)) {
if (valueArg->isVariableLength()) {
if (i != e - 1) {
PrintFatalError(
``````````
</details>
https://github.com/llvm/llvm-project/pull/92709
More information about the Mlir-commits
mailing list