Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions mlir/include/mlir-c/Dialect/LLVM.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ MLIR_CAPI_EXPORTED MlirType mlirLLVMFunctionTypeGetReturnType(MlirType type);
/// Returns `true` if the type is an LLVM dialect struct type.
MLIR_CAPI_EXPORTED bool mlirTypeIsALLVMStructType(MlirType type);

MLIR_CAPI_EXPORTED MlirTypeID mlirLLVMStructTypeGetTypeID();

/// Returns `true` if the type is a literal (unnamed) LLVM struct type.
MLIR_CAPI_EXPORTED bool mlirLLVMStructTypeIsLiteral(MlirType type);

Expand Down
4 changes: 2 additions & 2 deletions mlir/lib/Bindings/Python/DialectLLVM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ static void populateDialectLLVMSubmodule(nanobind::module_ &m) {
// StructType
//===--------------------------------------------------------------------===//

auto llvmStructType =
mlir_type_subclass(m, "StructType", mlirTypeIsALLVMStructType);
auto llvmStructType = mlir_type_subclass(
m, "StructType", mlirTypeIsALLVMStructType, mlirLLVMStructTypeGetTypeID);

llvmStructType
.def_classmethod(
Expand Down
4 changes: 4 additions & 0 deletions mlir/lib/CAPI/Dialect/LLVM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ bool mlirTypeIsALLVMStructType(MlirType type) {
return isa<LLVM::LLVMStructType>(unwrap(type));
}

MlirTypeID mlirLLVMStructTypeGetTypeID() {
return wrap(LLVM::LLVMStructType::getTypeID());
}

bool mlirLLVMStructTypeIsLiteral(MlirType type) {
return !cast<LLVM::LLVMStructType>(unwrap(type)).isIdentified();
}
Expand Down
3 changes: 3 additions & 0 deletions mlir/test/python/dialects/llvm.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,9 @@ def testStructType():
assert opaque.opaque
# CHECK: !llvm.struct<"opaque", opaque>

typ = Type.parse('!llvm.struct<"zoo", (i32, i64)>')
assert isinstance(typ, llvm.StructType)


# CHECK-LABEL: testSmoke
@constructAndPrintInModule
Expand Down
Loading