[Mlir-commits] [mlir] [mlir][python] expose LLVMStructType API (PR #81672)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Tue Feb 13 13:54:48 PST 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 f219cda7bd43696792ca4668ca5a9fbf55a9f09f f12fc66f9829f6de485bcfd7807470ec613daf84 -- mlir/lib/Bindings/Python/DialectLLVM.cpp mlir/include/mlir-c/Dialect/LLVM.h mlir/lib/CAPI/Dialect/LLVM.cpp
``````````

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/mlir/include/mlir-c/Dialect/LLVM.h b/mlir/include/mlir-c/Dialect/LLVM.h
index 80170b7e48..a1bc6092b8 100644
--- a/mlir/include/mlir-c/Dialect/LLVM.h
+++ b/mlir/include/mlir-c/Dialect/LLVM.h
@@ -35,8 +35,7 @@ mlirLLVMFunctionTypeGet(MlirType resultType, intptr_t nArgumentTypes,
                         MlirType const *argumentTypes, bool isVarArg);
 
 /// Returns `true` if the type is an LLVM dialect struct type.
-MLIR_CAPI_EXPORTED bool
-mlirTypeIsALLVMStructType(MlirType type);
+MLIR_CAPI_EXPORTED bool mlirTypeIsALLVMStructType(MlirType type);
 
 /// Returns `true` if the type is a literal (unnamed) LLVM struct type.
 MLIR_CAPI_EXPORTED bool mlirLLVMStructTypeIsLiteral(MlirType type);
@@ -47,7 +46,8 @@ MLIR_CAPI_EXPORTED intptr_t mlirLLVMStructTypeGetNumElementTypes(MlirType type);
 
 /// Returns the `positions`-th field of the struct. Asserts if the struct is
 /// opaque, not yet initialized or if the position is out of range.
-MLIR_CAPI_EXPORTED MlirType mlirLLVMStructTypeGetElementType(MlirType type, intptr_t position);
+MLIR_CAPI_EXPORTED MlirType mlirLLVMStructTypeGetElementType(MlirType type,
+                                                             intptr_t position);
 
 /// Returns `true` if the struct is packed.
 MLIR_CAPI_EXPORTED bool mlirLLVMStructTypeIsPacked(MlirType type);
@@ -78,8 +78,8 @@ mlirLLVMStructTypeLiteralGetChecked(MlirLocation loc, intptr_t nFieldTypes,
 /// mlirLLVMStructTypeIdentifiedNewGet to create a fresh struct type,
 /// potentially renaming it. The body should be set separatelty by calling
 /// mlirLLVMStructTypeSetBody, if it isn't set already.
-MLIR_CAPI_EXPORTED MlirType
-mlirLLVMStructTypeIdentifiedGet(MlirContext ctx, MlirStringRef name);
+MLIR_CAPI_EXPORTED MlirType mlirLLVMStructTypeIdentifiedGet(MlirContext ctx,
+                                                            MlirStringRef name);
 
 /// Creates an LLVM identified struct type with no body and a name starting with
 /// the given prefix. If a struct with the exact name as the given prefix
@@ -94,10 +94,9 @@ MLIR_CAPI_EXPORTED MlirType mlirLLVMStructTypeOpaqueGet(MlirContext ctx,
 
 /// Sets the body of the identified struct if it hasn't been set yet. Returns
 /// whether the operation was successful.
-MLIR_CAPI_EXPORTED MlirLogicalResult mlirLLVMStructTypeSetBody(MlirType structType,
-                                                  intptr_t nFieldTypes,
-                                                  MlirType const *fieldTypes,
-                                                  bool isPacked);
+MLIR_CAPI_EXPORTED MlirLogicalResult
+mlirLLVMStructTypeSetBody(MlirType structType, intptr_t nFieldTypes,
+                          MlirType const *fieldTypes, bool isPacked);
 
 #ifdef __cplusplus
 }
diff --git a/mlir/lib/Bindings/Python/DialectLLVM.cpp b/mlir/lib/Bindings/Python/DialectLLVM.cpp
index 583375e1e2..560ff167ea 100644
--- a/mlir/lib/Bindings/Python/DialectLLVM.cpp
+++ b/mlir/lib/Bindings/Python/DialectLLVM.cpp
@@ -84,7 +84,8 @@ void populateDialectLLVMSubmodule(const pybind11::module &m) {
       [](py::object cls, const std::string &name, MlirContext context) {
         return cls(mlirLLVMStructTypeOpaqueGet(
             context, mlirStringRefCreate(name.data(), name.size())));
-      }, py::arg("cls"), py::arg("name"), py::arg("context") = py::none());
+      },
+      py::arg("cls"), py::arg("name"), py::arg("context") = py::none());
 
   llvmStructType.def(
       "set_body",
diff --git a/mlir/lib/CAPI/Dialect/LLVM.cpp b/mlir/lib/CAPI/Dialect/LLVM.cpp
index ada9fcb46b..369203a045 100644
--- a/mlir/lib/CAPI/Dialect/LLVM.cpp
+++ b/mlir/lib/CAPI/Dialect/LLVM.cpp
@@ -92,7 +92,9 @@ MlirType mlirLLVMStructTypeIdentifiedGet(MlirContext ctx, MlirStringRef name) {
 }
 
 MlirType mlirLLVMStructTypeIdentifiedNewGet(MlirContext ctx, MlirStringRef name,
-intptr_t nFieldTypes, MlirType const *fieldTypes, bool isPacked) {
+                                            intptr_t nFieldTypes,
+                                            MlirType const *fieldTypes,
+                                            bool isPacked) {
   SmallVector<Type> fields;
   return wrap(LLVMStructType::getNewIdentified(
       unwrap(ctx), unwrap(name), unwrapList(nFieldTypes, fieldTypes, fields),

``````````

</details>


https://github.com/llvm/llvm-project/pull/81672


More information about the Mlir-commits mailing list