[Mlir-commits] [mlir] [mlir][LLVM] Add support for constant struct with multiple fields (PR #102752)

Christian Ulmann llvmlistbot at llvm.org
Sun Aug 11 22:59:04 PDT 2024


================
@@ -2678,31 +2678,30 @@ LogicalResult LLVM::ConstantOp::verify() {
     return success();
   }
   if (auto structType = llvm::dyn_cast<LLVMStructType>(getType())) {
-    if (structType.getBody().size() != 2 ||
-        structType.getBody()[0] != structType.getBody()[1]) {
-      return emitError() << "expected struct type with two elements of the "
-                            "same type, the type of a complex constant";
-    }
-
     auto arrayAttr = llvm::dyn_cast<ArrayAttr>(getValue());
-    if (!arrayAttr || arrayAttr.size() != 2) {
-      return emitOpError() << "expected array attribute with two elements, "
-                              "representing a complex constant";
+    if (!arrayAttr) {
+      return emitOpError() << "expected array attribute for a struct constant";
     }
-    auto re = llvm::dyn_cast<TypedAttr>(arrayAttr[0]);
-    auto im = llvm::dyn_cast<TypedAttr>(arrayAttr[1]);
-    if (!re || !im || re.getType() != im.getType()) {
-      return emitOpError()
-             << "expected array attribute with two elements of the same type";
+
+    ArrayRef<Type> elementTypes = structType.getBody();
----------------
Dinistro wrote:

Shouldn't this check now be recursive, given that one can define nested struct constants?

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


More information about the Mlir-commits mailing list