diff --git a/mlir/lib/Interfaces/DataLayoutInterfaces.cpp b/mlir/lib/Interfaces/DataLayoutInterfaces.cpp --- a/mlir/lib/Interfaces/DataLayoutInterfaces.cpp +++ b/mlir/lib/Interfaces/DataLayoutInterfaces.cpp @@ -53,6 +53,10 @@ if (type.isa()) return type.getIntOrFloatBitWidth(); + if (auto ctype = type.dyn_cast()) + return 2 * + getDefaultTypeSizeInBits(ctype.getElementType(), dataLayout, params); + // Index is an integer of some bitwidth. if (type.isa()) return dataLayout.getTypeSizeInBits( @@ -92,6 +96,9 @@ : 4; } + if (auto ctype = type.dyn_cast()) + return getDefaultABIAlignment(ctype.getElementType(), dataLayout, params); + if (auto typeInterface = type.dyn_cast()) return typeInterface.getABIAlignment(dataLayout, params); @@ -110,6 +117,10 @@ if (type.isa()) return llvm::PowerOf2Ceil(dataLayout.getTypeSize(type)); + if (auto ctype = type.dyn_cast()) + return getDefaultPreferredAlignment(ctype.getElementType(), dataLayout, + params); + if (auto typeInterface = type.dyn_cast()) return typeInterface.getPreferredAlignment(dataLayout, params); diff --git a/mlir/test/Interfaces/DataLayoutInterfaces/query.mlir b/mlir/test/Interfaces/DataLayoutInterfaces/query.mlir --- a/mlir/test/Interfaces/DataLayoutInterfaces/query.mlir +++ b/mlir/test/Interfaces/DataLayoutInterfaces/query.mlir @@ -12,7 +12,13 @@ // CHECK: preferred = 8 // CHECK: size = 8 "test.data_layout_query"() : () -> f64 + // CHECK: alignment = 4 + // CHECK: bitsize = 64 + // CHECK: preferred = 4 + // CHECK: size = 8 + "test.data_layout_query"() : () -> complex return + } // CHECK-LABEL: @no_layout_custom