[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
================
@@ -557,20 +557,20 @@ llvm::Constant *mlir::LLVM::detail::getLLVMConstant(
return llvm::UndefValue::get(llvmType);
if (auto *structType = dyn_cast<::llvm::StructType>(llvmType)) {
auto arrayAttr = dyn_cast<ArrayAttr>(attr);
- if (!arrayAttr || arrayAttr.size() != 2) {
- emitError(loc, "expected struct type to be a complex number");
+ if (!arrayAttr) {
+ emitError(loc, "expected an array attribute for a struct constant");
return nullptr;
}
- llvm::Type *elementType = structType->getElementType(0);
- llvm::Constant *real =
- getLLVMConstant(elementType, arrayAttr[0], loc, moduleTranslation);
- if (!real)
- return nullptr;
- llvm::Constant *imag =
- getLLVMConstant(elementType, arrayAttr[1], loc, moduleTranslation);
- if (!imag)
- return nullptr;
- return llvm::ConstantStruct::get(structType, {real, imag});
+ llvm::SmallVector<llvm::Constant *, 8> structElements;
----------------
Dinistro wrote:
```suggestion
SmallVector<llvm::Constant *, 8> structElements;
```
https://github.com/llvm/llvm-project/pull/102752
More information about the Mlir-commits
mailing list