[Mlir-commits] [mlir] [MLIR][Python] Forward the name of MLIR types to Python side (PR #174700)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Tue Jan 6 22:13:16 PST 2026


https://github.com/PragmaTwice created https://github.com/llvm/llvm-project/pull/174700

In this PR, I added a C API for each (upstream) MLIR type to retrieve its type name (for example, `IntegerType` -> `mlirIntegerTypeGetName()` -> `"builtin.integer"`), and exposed a corresponding `type_name` class attribute in the Python bindings (e.g., `IntegerType.type_name` -> `"builtin.integer"`). This can be used in various places to avoid hard-coded strings, such as eliminating the manual string in `irdl.base("!builtin.integer")`.

Note that parts of this PR (mainly mechanical changes) were produced via GitHub Copilot and GPT-5.2. I have manually reviewed the changes and verified them with tests to ensure correctness.


>From ca6c374ca54ea281f718fe7a8c6f65154c21443e Mon Sep 17 00:00:00 2001
From: PragmaTwice <twice at apache.org>
Date: Wed, 7 Jan 2026 13:00:15 +0800
Subject: [PATCH 1/3] [MLIR][Python] Forward the name of MLIR types to Python
 side

---
 mlir/include/mlir-c/BuiltinTypes.h          | 56 ++++++++++++++
 mlir/include/mlir-c/Dialect/AMDGPU.h        |  6 ++
 mlir/include/mlir-c/Dialect/EmitC.h         | 14 ++++
 mlir/include/mlir-c/Dialect/GPU.h           |  2 +
 mlir/include/mlir-c/Dialect/LLVM.h          |  8 ++
 mlir/include/mlir-c/Dialect/NVGPU.h         |  2 +
 mlir/include/mlir-c/Dialect/PDL.h           | 10 +++
 mlir/include/mlir-c/Dialect/Quant.h         | 10 +++
 mlir/include/mlir-c/Dialect/Transform.h     | 10 +++
 mlir/include/mlir/Bindings/Python/IRCore.h  |  8 ++
 mlir/include/mlir/Bindings/Python/IRTypes.h |  2 +
 mlir/lib/CAPI/Dialect/AMDGPU.cpp            | 12 +++
 mlir/lib/CAPI/Dialect/EmitC.cpp             | 28 +++++++
 mlir/lib/CAPI/Dialect/GPU.cpp               |  4 +
 mlir/lib/CAPI/Dialect/LLVM.cpp              | 14 ++++
 mlir/lib/CAPI/Dialect/NVGPU.cpp             |  4 +
 mlir/lib/CAPI/Dialect/PDL.cpp               | 14 ++++
 mlir/lib/CAPI/Dialect/Quant.cpp             | 20 +++++
 mlir/lib/CAPI/Dialect/Transform.cpp         | 20 +++++
 mlir/lib/CAPI/IR/BuiltinTypes.cpp           | 84 +++++++++++++++++++++
 20 files changed, 328 insertions(+)

diff --git a/mlir/include/mlir-c/BuiltinTypes.h b/mlir/include/mlir-c/BuiltinTypes.h
index c981bfd0967c5..f6c30f375cb1a 100644
--- a/mlir/include/mlir-c/BuiltinTypes.h
+++ b/mlir/include/mlir-c/BuiltinTypes.h
@@ -33,6 +33,8 @@ MLIR_CAPI_EXPORTED bool mlirTypeIsAInteger(MlirType type);
 MLIR_CAPI_EXPORTED MlirType mlirIntegerTypeGet(MlirContext ctx,
                                                unsigned bitwidth);
 
+MLIR_CAPI_EXPORTED MlirStringRef mlirIntegerTypeGetName(void);
+
 /// Creates a signed integer type of the given bitwidth in the context. The type
 /// is owned by the context.
 MLIR_CAPI_EXPORTED MlirType mlirIntegerTypeSignedGet(MlirContext ctx,
@@ -69,6 +71,8 @@ MLIR_CAPI_EXPORTED bool mlirTypeIsAIndex(MlirType type);
 /// context.
 MLIR_CAPI_EXPORTED MlirType mlirIndexTypeGet(MlirContext ctx);
 
+MLIR_CAPI_EXPORTED MlirStringRef mlirIndexTypeGetName(void);
+
 //===----------------------------------------------------------------------===//
 // Floating-point types.
 //===----------------------------------------------------------------------===//
@@ -89,6 +93,8 @@ MLIR_CAPI_EXPORTED bool mlirTypeIsAFloat4E2M1FN(MlirType type);
 /// context.
 MLIR_CAPI_EXPORTED MlirType mlirFloat4E2M1FNTypeGet(MlirContext ctx);
 
+MLIR_CAPI_EXPORTED MlirStringRef mlirFloat4E2M1FNTypeGetName(void);
+
 /// Returns the typeID of an Float6E2M3FN type.
 MLIR_CAPI_EXPORTED MlirTypeID mlirFloat6E2M3FNTypeGetTypeID(void);
 
@@ -99,6 +105,8 @@ MLIR_CAPI_EXPORTED bool mlirTypeIsAFloat6E2M3FN(MlirType type);
 /// context.
 MLIR_CAPI_EXPORTED MlirType mlirFloat6E2M3FNTypeGet(MlirContext ctx);
 
+MLIR_CAPI_EXPORTED MlirStringRef mlirFloat6E2M3FNTypeGetName(void);
+
 /// Returns the typeID of an Float6E3M2FN type.
 MLIR_CAPI_EXPORTED MlirTypeID mlirFloat6E3M2FNTypeGetTypeID(void);
 
@@ -109,6 +117,8 @@ MLIR_CAPI_EXPORTED bool mlirTypeIsAFloat6E3M2FN(MlirType type);
 /// context.
 MLIR_CAPI_EXPORTED MlirType mlirFloat6E3M2FNTypeGet(MlirContext ctx);
 
+MLIR_CAPI_EXPORTED MlirStringRef mlirFloat6E3M2FNTypeGetName(void);
+
 /// Returns the typeID of an Float8E5M2 type.
 MLIR_CAPI_EXPORTED MlirTypeID mlirFloat8E5M2TypeGetTypeID(void);
 
@@ -119,6 +129,8 @@ MLIR_CAPI_EXPORTED bool mlirTypeIsAFloat8E5M2(MlirType type);
 /// context.
 MLIR_CAPI_EXPORTED MlirType mlirFloat8E5M2TypeGet(MlirContext ctx);
 
+MLIR_CAPI_EXPORTED MlirStringRef mlirFloat8E5M2TypeGetName(void);
+
 /// Returns the typeID of an Float8E4M3 type.
 MLIR_CAPI_EXPORTED MlirTypeID mlirFloat8E4M3TypeGetTypeID(void);
 
@@ -129,6 +141,8 @@ MLIR_CAPI_EXPORTED bool mlirTypeIsAFloat8E4M3(MlirType type);
 /// context.
 MLIR_CAPI_EXPORTED MlirType mlirFloat8E4M3TypeGet(MlirContext ctx);
 
+MLIR_CAPI_EXPORTED MlirStringRef mlirFloat8E4M3TypeGetName(void);
+
 /// Returns the typeID of an Float8E4M3FN type.
 MLIR_CAPI_EXPORTED MlirTypeID mlirFloat8E4M3FNTypeGetTypeID(void);
 
@@ -139,6 +153,8 @@ MLIR_CAPI_EXPORTED bool mlirTypeIsAFloat8E4M3FN(MlirType type);
 /// context.
 MLIR_CAPI_EXPORTED MlirType mlirFloat8E4M3FNTypeGet(MlirContext ctx);
 
+MLIR_CAPI_EXPORTED MlirStringRef mlirFloat8E4M3FNTypeGetName(void);
+
 /// Returns the typeID of an Float8E5M2FNUZ type.
 MLIR_CAPI_EXPORTED MlirTypeID mlirFloat8E5M2FNUZTypeGetTypeID(void);
 
@@ -149,6 +165,8 @@ MLIR_CAPI_EXPORTED bool mlirTypeIsAFloat8E5M2FNUZ(MlirType type);
 /// context.
 MLIR_CAPI_EXPORTED MlirType mlirFloat8E5M2FNUZTypeGet(MlirContext ctx);
 
+MLIR_CAPI_EXPORTED MlirStringRef mlirFloat8E5M2FNUZTypeGetName(void);
+
 /// Returns the typeID of an Float8E4M3FNUZ type.
 MLIR_CAPI_EXPORTED MlirTypeID mlirFloat8E4M3FNUZTypeGetTypeID(void);
 
@@ -159,6 +177,8 @@ MLIR_CAPI_EXPORTED bool mlirTypeIsAFloat8E4M3FNUZ(MlirType type);
 /// context.
 MLIR_CAPI_EXPORTED MlirType mlirFloat8E4M3FNUZTypeGet(MlirContext ctx);
 
+MLIR_CAPI_EXPORTED MlirStringRef mlirFloat8E4M3FNUZTypeGetName(void);
+
 /// Returns the typeID of an Float8E4M3B11FNUZ type.
 MLIR_CAPI_EXPORTED MlirTypeID mlirFloat8E4M3B11FNUZTypeGetTypeID(void);
 
@@ -169,6 +189,8 @@ MLIR_CAPI_EXPORTED bool mlirTypeIsAFloat8E4M3B11FNUZ(MlirType type);
 /// context.
 MLIR_CAPI_EXPORTED MlirType mlirFloat8E4M3B11FNUZTypeGet(MlirContext ctx);
 
+MLIR_CAPI_EXPORTED MlirStringRef mlirFloat8E4M3B11FNUZTypeGetName(void);
+
 /// Returns the typeID of an Float8E3M4 type.
 MLIR_CAPI_EXPORTED MlirTypeID mlirFloat8E3M4TypeGetTypeID(void);
 
@@ -179,6 +201,8 @@ MLIR_CAPI_EXPORTED bool mlirTypeIsAFloat8E3M4(MlirType type);
 /// context.
 MLIR_CAPI_EXPORTED MlirType mlirFloat8E3M4TypeGet(MlirContext ctx);
 
+MLIR_CAPI_EXPORTED MlirStringRef mlirFloat8E3M4TypeGetName(void);
+
 /// Returns the typeID of an Float8E8M0FNU type.
 MLIR_CAPI_EXPORTED MlirTypeID mlirFloat8E8M0FNUTypeGetTypeID(void);
 
@@ -189,6 +213,8 @@ MLIR_CAPI_EXPORTED bool mlirTypeIsAFloat8E8M0FNU(MlirType type);
 /// context.
 MLIR_CAPI_EXPORTED MlirType mlirFloat8E8M0FNUTypeGet(MlirContext ctx);
 
+MLIR_CAPI_EXPORTED MlirStringRef mlirFloat8E8M0FNUTypeGetName(void);
+
 /// Returns the typeID of an BFloat16 type.
 MLIR_CAPI_EXPORTED MlirTypeID mlirBFloat16TypeGetTypeID(void);
 
@@ -199,6 +225,8 @@ MLIR_CAPI_EXPORTED bool mlirTypeIsABF16(MlirType type);
 /// context.
 MLIR_CAPI_EXPORTED MlirType mlirBF16TypeGet(MlirContext ctx);
 
+MLIR_CAPI_EXPORTED MlirStringRef mlirBF16TypeGetName(void);
+
 /// Returns the typeID of an Float16 type.
 MLIR_CAPI_EXPORTED MlirTypeID mlirFloat16TypeGetTypeID(void);
 
@@ -209,6 +237,8 @@ MLIR_CAPI_EXPORTED bool mlirTypeIsAF16(MlirType type);
 /// context.
 MLIR_CAPI_EXPORTED MlirType mlirF16TypeGet(MlirContext ctx);
 
+MLIR_CAPI_EXPORTED MlirStringRef mlirF16TypeGetName(void);
+
 /// Returns the typeID of an Float32 type.
 MLIR_CAPI_EXPORTED MlirTypeID mlirFloat32TypeGetTypeID(void);
 
@@ -219,6 +249,8 @@ MLIR_CAPI_EXPORTED bool mlirTypeIsAF32(MlirType type);
 /// context.
 MLIR_CAPI_EXPORTED MlirType mlirF32TypeGet(MlirContext ctx);
 
+MLIR_CAPI_EXPORTED MlirStringRef mlirF32TypeGetName(void);
+
 /// Returns the typeID of an Float64 type.
 MLIR_CAPI_EXPORTED MlirTypeID mlirFloat64TypeGetTypeID(void);
 
@@ -229,6 +261,8 @@ MLIR_CAPI_EXPORTED bool mlirTypeIsAF64(MlirType type);
 /// context.
 MLIR_CAPI_EXPORTED MlirType mlirF64TypeGet(MlirContext ctx);
 
+MLIR_CAPI_EXPORTED MlirStringRef mlirF64TypeGetName(void);
+
 /// Returns the typeID of a TF32 type.
 MLIR_CAPI_EXPORTED MlirTypeID mlirFloatTF32TypeGetTypeID(void);
 
@@ -239,6 +273,8 @@ MLIR_CAPI_EXPORTED bool mlirTypeIsATF32(MlirType type);
 /// context.
 MLIR_CAPI_EXPORTED MlirType mlirTF32TypeGet(MlirContext ctx);
 
+MLIR_CAPI_EXPORTED MlirStringRef mlirTF32TypeGetName(void);
+
 //===----------------------------------------------------------------------===//
 // None type.
 //===----------------------------------------------------------------------===//
@@ -253,6 +289,8 @@ MLIR_CAPI_EXPORTED bool mlirTypeIsANone(MlirType type);
 /// context.
 MLIR_CAPI_EXPORTED MlirType mlirNoneTypeGet(MlirContext ctx);
 
+MLIR_CAPI_EXPORTED MlirStringRef mlirNoneTypeGetName(void);
+
 //===----------------------------------------------------------------------===//
 // Complex type.
 //===----------------------------------------------------------------------===//
@@ -267,6 +305,8 @@ MLIR_CAPI_EXPORTED bool mlirTypeIsAComplex(MlirType type);
 /// the element type. The type is owned by the context.
 MLIR_CAPI_EXPORTED MlirType mlirComplexTypeGet(MlirType elementType);
 
+MLIR_CAPI_EXPORTED MlirStringRef mlirComplexTypeGetName(void);
+
 /// Returns the element type of the given complex type.
 MLIR_CAPI_EXPORTED MlirType mlirComplexTypeGetElementType(MlirType type);
 
@@ -341,6 +381,8 @@ MLIR_CAPI_EXPORTED MlirType mlirVectorTypeGet(intptr_t rank,
                                               const int64_t *shape,
                                               MlirType elementType);
 
+MLIR_CAPI_EXPORTED MlirStringRef mlirVectorTypeGetName(void);
+
 /// Same as "mlirVectorTypeGet" but returns a nullptr wrapping MlirType on
 /// illegal arguments, emitting appropriate diagnostics.
 MLIR_CAPI_EXPORTED MlirType mlirVectorTypeGetChecked(MlirLocation loc,
@@ -402,6 +444,8 @@ MLIR_CAPI_EXPORTED MlirType mlirRankedTensorTypeGet(intptr_t rank,
                                                     MlirType elementType,
                                                     MlirAttribute encoding);
 
+MLIR_CAPI_EXPORTED MlirStringRef mlirRankedTensorTypeGetName(void);
+
 /// Same as "mlirRankedTensorTypeGet" but returns a nullptr wrapping MlirType on
 /// illegal arguments, emitting appropriate diagnostics.
 MLIR_CAPI_EXPORTED MlirType mlirRankedTensorTypeGetChecked(
@@ -416,6 +460,8 @@ MLIR_CAPI_EXPORTED MlirAttribute mlirRankedTensorTypeGetEncoding(MlirType type);
 /// context as the element type. The type is owned by the context.
 MLIR_CAPI_EXPORTED MlirType mlirUnrankedTensorTypeGet(MlirType elementType);
 
+MLIR_CAPI_EXPORTED MlirStringRef mlirUnrankedTensorTypeGetName(void);
+
 /// Same as "mlirUnrankedTensorTypeGet" but returns a nullptr wrapping MlirType
 /// on illegal arguments, emitting appropriate diagnostics.
 MLIR_CAPI_EXPORTED MlirType
@@ -446,6 +492,8 @@ MLIR_CAPI_EXPORTED MlirType mlirMemRefTypeGet(MlirType elementType,
                                               MlirAttribute layout,
                                               MlirAttribute memorySpace);
 
+MLIR_CAPI_EXPORTED MlirStringRef mlirMemRefTypeGetName(void);
+
 /// Same as "mlirMemRefTypeGet" but returns a nullptr-wrapping MlirType o
 /// illegal arguments, emitting appropriate diagnostics.
 MLIR_CAPI_EXPORTED MlirType mlirMemRefTypeGetChecked(
@@ -471,6 +519,8 @@ MLIR_CAPI_EXPORTED MlirType mlirMemRefTypeContiguousGetChecked(
 MLIR_CAPI_EXPORTED MlirType
 mlirUnrankedMemRefTypeGet(MlirType elementType, MlirAttribute memorySpace);
 
+MLIR_CAPI_EXPORTED MlirStringRef mlirUnrankedMemRefTypeGetName(void);
+
 /// Same as "mlirUnrankedMemRefTypeGet" but returns a nullptr wrapping
 /// MlirType on illegal arguments, emitting appropriate diagnostics.
 MLIR_CAPI_EXPORTED MlirType mlirUnrankedMemRefTypeGetChecked(
@@ -511,6 +561,8 @@ MLIR_CAPI_EXPORTED MlirType mlirTupleTypeGet(MlirContext ctx,
                                              intptr_t numElements,
                                              MlirType const *elements);
 
+MLIR_CAPI_EXPORTED MlirStringRef mlirTupleTypeGetName(void);
+
 /// Returns the number of types contained in a tuple.
 MLIR_CAPI_EXPORTED intptr_t mlirTupleTypeGetNumTypes(MlirType type);
 
@@ -534,6 +586,8 @@ MLIR_CAPI_EXPORTED MlirType mlirFunctionTypeGet(MlirContext ctx,
                                                 intptr_t numResults,
                                                 MlirType const *results);
 
+MLIR_CAPI_EXPORTED MlirStringRef mlirFunctionTypeGetName(void);
+
 /// Returns the number of input types.
 MLIR_CAPI_EXPORTED intptr_t mlirFunctionTypeGetNumInputs(MlirType type);
 
@@ -565,6 +619,8 @@ MLIR_CAPI_EXPORTED MlirType mlirOpaqueTypeGet(MlirContext ctx,
                                               MlirStringRef dialectNamespace,
                                               MlirStringRef typeData);
 
+MLIR_CAPI_EXPORTED MlirStringRef mlirOpaqueTypeGetName(void);
+
 /// Returns the namespace of the dialect with which the given opaque type
 /// is associated. The namespace string is owned by the context.
 MLIR_CAPI_EXPORTED MlirStringRef
diff --git a/mlir/include/mlir-c/Dialect/AMDGPU.h b/mlir/include/mlir-c/Dialect/AMDGPU.h
index 83cfe8f5dd65e..7ce6bcc8e6942 100644
--- a/mlir/include/mlir-c/Dialect/AMDGPU.h
+++ b/mlir/include/mlir-c/Dialect/AMDGPU.h
@@ -29,6 +29,8 @@ MLIR_CAPI_EXPORTED MlirTypeID mlirAMDGPUTDMBaseTypeGetTypeID();
 MLIR_CAPI_EXPORTED MlirType mlirAMDGPUTDMBaseTypeGet(MlirContext ctx,
                                                      MlirType elementType);
 
+MLIR_CAPI_EXPORTED MlirStringRef mlirAMDGPUTDMBaseTypeGetName(void);
+
 //===---------------------------------------------------------------------===//
 // TDMDescriptorType
 //===---------------------------------------------------------------------===//
@@ -39,6 +41,8 @@ MLIR_CAPI_EXPORTED MlirTypeID mlirAMDGPUTDMDescriptorTypeGetTypeID();
 
 MLIR_CAPI_EXPORTED MlirType mlirAMDGPUTDMDescriptorTypeGet(MlirContext ctx);
 
+MLIR_CAPI_EXPORTED MlirStringRef mlirAMDGPUTDMDescriptorTypeGetName(void);
+
 //===---------------------------------------------------------------------===//
 // TDMGatherBaseType
 //===---------------------------------------------------------------------===//
@@ -51,6 +55,8 @@ MLIR_CAPI_EXPORTED MlirType mlirAMDGPUTDMGatherBaseTypeGet(MlirContext ctx,
                                                            MlirType elementType,
                                                            MlirType indexType);
 
+MLIR_CAPI_EXPORTED MlirStringRef mlirAMDGPUTDMGatherBaseTypeGetName(void);
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/mlir/include/mlir-c/Dialect/EmitC.h b/mlir/include/mlir-c/Dialect/EmitC.h
index a0e3ea08a5a9f..78e09ffe53ff8 100644
--- a/mlir/include/mlir-c/Dialect/EmitC.h
+++ b/mlir/include/mlir-c/Dialect/EmitC.h
@@ -41,6 +41,8 @@ MLIR_CAPI_EXPORTED MlirType mlirEmitCArrayTypeGet(intptr_t nDims,
                                                   int64_t *shape,
                                                   MlirType elementType);
 
+MLIR_CAPI_EXPORTED MlirStringRef mlirEmitCArrayTypeGetName(void);
+
 //===---------------------------------------------------------------------===//
 // LValueType
 //===---------------------------------------------------------------------===//
@@ -51,6 +53,8 @@ MLIR_CAPI_EXPORTED MlirTypeID mlirEmitCLValueTypeGetTypeID(void);
 
 MLIR_CAPI_EXPORTED MlirType mlirEmitCLValueTypeGet(MlirType valueType);
 
+MLIR_CAPI_EXPORTED MlirStringRef mlirEmitCLValueTypeGetName(void);
+
 //===---------------------------------------------------------------------===//
 // OpaqueType
 //===---------------------------------------------------------------------===//
@@ -62,6 +66,8 @@ MLIR_CAPI_EXPORTED MlirTypeID mlirEmitCOpaqueTypeGetTypeID(void);
 MLIR_CAPI_EXPORTED MlirType mlirEmitCOpaqueTypeGet(MlirContext ctx,
                                                    MlirStringRef value);
 
+MLIR_CAPI_EXPORTED MlirStringRef mlirEmitCOpaqueTypeGetName(void);
+
 //===---------------------------------------------------------------------===//
 // PointerType
 //===---------------------------------------------------------------------===//
@@ -72,6 +78,8 @@ MLIR_CAPI_EXPORTED MlirTypeID mlirEmitCPointerTypeGetTypeID(void);
 
 MLIR_CAPI_EXPORTED MlirType mlirEmitCPointerTypeGet(MlirType pointee);
 
+MLIR_CAPI_EXPORTED MlirStringRef mlirEmitCPointerTypeGetName(void);
+
 //===---------------------------------------------------------------------===//
 // PtrDiffTType
 //===---------------------------------------------------------------------===//
@@ -82,6 +90,8 @@ MLIR_CAPI_EXPORTED MlirTypeID mlirEmitCPtrDiffTTypeGetTypeID(void);
 
 MLIR_CAPI_EXPORTED MlirType mlirEmitCPtrDiffTTypeGet(MlirContext ctx);
 
+MLIR_CAPI_EXPORTED MlirStringRef mlirEmitCPtrDiffTTypeGetName(void);
+
 //===---------------------------------------------------------------------===//
 // SignedSizeTType
 //===---------------------------------------------------------------------===//
@@ -92,6 +102,8 @@ MLIR_CAPI_EXPORTED MlirTypeID mlirEmitCSignedSizeTTypeGetTypeID(void);
 
 MLIR_CAPI_EXPORTED MlirType mlirEmitCSignedSizeTTypeGet(MlirContext ctx);
 
+MLIR_CAPI_EXPORTED MlirStringRef mlirEmitCSignedSizeTTypeGetName(void);
+
 //===---------------------------------------------------------------------===//
 // SizeTType
 //===---------------------------------------------------------------------===//
@@ -102,6 +114,8 @@ MLIR_CAPI_EXPORTED MlirTypeID mlirEmitCSizeTTypeGetTypeID(void);
 
 MLIR_CAPI_EXPORTED MlirType mlirEmitCSizeTTypeGet(MlirContext ctx);
 
+MLIR_CAPI_EXPORTED MlirStringRef mlirEmitCSizeTTypeGetName(void);
+
 //===----------------------------------------------------------------------===//
 // CmpPredicate attribute.
 //===----------------------------------------------------------------------===//
diff --git a/mlir/include/mlir-c/Dialect/GPU.h b/mlir/include/mlir-c/Dialect/GPU.h
index 321c1122c3370..4e7448d427cda 100644
--- a/mlir/include/mlir-c/Dialect/GPU.h
+++ b/mlir/include/mlir-c/Dialect/GPU.h
@@ -27,6 +27,8 @@ MLIR_CAPI_EXPORTED bool mlirTypeIsAGPUAsyncTokenType(MlirType type);
 
 MLIR_CAPI_EXPORTED MlirType mlirGPUAsyncTokenTypeGet(MlirContext ctx);
 
+MLIR_CAPI_EXPORTED MlirStringRef mlirGPUAsyncTokenTypeGetName(void);
+
 //===---------------------------------------------------------------------===//
 // ObjectAttr
 //===---------------------------------------------------------------------===//
diff --git a/mlir/include/mlir-c/Dialect/LLVM.h b/mlir/include/mlir-c/Dialect/LLVM.h
index cc7f09f71d028..623b790d88d03 100644
--- a/mlir/include/mlir-c/Dialect/LLVM.h
+++ b/mlir/include/mlir-c/Dialect/LLVM.h
@@ -23,6 +23,8 @@ MLIR_DECLARE_CAPI_DIALECT_REGISTRATION(LLVM, llvm);
 MLIR_CAPI_EXPORTED MlirType mlirLLVMPointerTypeGet(MlirContext ctx,
                                                    unsigned addressSpace);
 
+MLIR_CAPI_EXPORTED MlirStringRef mlirLLVMPointerTypeGetName(void);
+
 MLIR_CAPI_EXPORTED MlirTypeID mlirLLVMPointerTypeGetTypeID(void);
 
 /// Returns `true` if the type is an LLVM dialect pointer type.
@@ -35,10 +37,14 @@ mlirLLVMPointerTypeGetAddressSpace(MlirType pointerType);
 /// Creates an llmv.void type.
 MLIR_CAPI_EXPORTED MlirType mlirLLVMVoidTypeGet(MlirContext ctx);
 
+MLIR_CAPI_EXPORTED MlirStringRef mlirLLVMVoidTypeGetName(void);
+
 /// Creates an llvm.array type.
 MLIR_CAPI_EXPORTED MlirType mlirLLVMArrayTypeGet(MlirType elementType,
                                                  unsigned numElements);
 
+MLIR_CAPI_EXPORTED MlirStringRef mlirLLVMArrayTypeGetName(void);
+
 /// Returns the element type of the llvm.array type.
 MLIR_CAPI_EXPORTED MlirType mlirLLVMArrayTypeGetElementType(MlirType type);
 
@@ -47,6 +53,8 @@ MLIR_CAPI_EXPORTED MlirType
 mlirLLVMFunctionTypeGet(MlirType resultType, intptr_t nArgumentTypes,
                         MlirType const *argumentTypes, bool isVarArg);
 
+MLIR_CAPI_EXPORTED MlirStringRef mlirLLVMFunctionTypeGetName(void);
+
 /// Returns the number of input types.
 MLIR_CAPI_EXPORTED intptr_t mlirLLVMFunctionTypeGetNumInputs(MlirType type);
 
diff --git a/mlir/include/mlir-c/Dialect/NVGPU.h b/mlir/include/mlir-c/Dialect/NVGPU.h
index e58015a4a3421..3f1284ed8d68d 100644
--- a/mlir/include/mlir-c/Dialect/NVGPU.h
+++ b/mlir/include/mlir-c/Dialect/NVGPU.h
@@ -29,6 +29,8 @@ MLIR_CAPI_EXPORTED MlirType mlirNVGPUTensorMapDescriptorTypeGet(
     MlirContext ctx, MlirType tensorMemrefType, int swizzle, int l2promo,
     int oobFill, int interleave);
 
+MLIR_CAPI_EXPORTED MlirStringRef mlirNVGPUTensorMapDescriptorTypeGetName(void);
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/mlir/include/mlir-c/Dialect/PDL.h b/mlir/include/mlir-c/Dialect/PDL.h
index d04f69e391b13..e247c770438c6 100644
--- a/mlir/include/mlir-c/Dialect/PDL.h
+++ b/mlir/include/mlir-c/Dialect/PDL.h
@@ -34,6 +34,8 @@ MLIR_CAPI_EXPORTED MlirTypeID mlirPDLAttributeTypeGetTypeID(void);
 
 MLIR_CAPI_EXPORTED MlirType mlirPDLAttributeTypeGet(MlirContext ctx);
 
+MLIR_CAPI_EXPORTED MlirStringRef mlirPDLAttributeTypeGetName(void);
+
 //===---------------------------------------------------------------------===//
 // OperationType
 //===---------------------------------------------------------------------===//
@@ -44,6 +46,8 @@ MLIR_CAPI_EXPORTED MlirTypeID mlirPDLOperationTypeGetTypeID(void);
 
 MLIR_CAPI_EXPORTED MlirType mlirPDLOperationTypeGet(MlirContext ctx);
 
+MLIR_CAPI_EXPORTED MlirStringRef mlirPDLOperationTypeGetName(void);
+
 //===---------------------------------------------------------------------===//
 // RangeType
 //===---------------------------------------------------------------------===//
@@ -54,6 +58,8 @@ MLIR_CAPI_EXPORTED MlirTypeID mlirPDLRangeTypeGetTypeID(void);
 
 MLIR_CAPI_EXPORTED MlirType mlirPDLRangeTypeGet(MlirType elementType);
 
+MLIR_CAPI_EXPORTED MlirStringRef mlirPDLRangeTypeGetName(void);
+
 MLIR_CAPI_EXPORTED MlirType mlirPDLRangeTypeGetElementType(MlirType type);
 
 //===---------------------------------------------------------------------===//
@@ -66,6 +72,8 @@ MLIR_CAPI_EXPORTED MlirTypeID mlirPDLTypeTypeGetTypeID(void);
 
 MLIR_CAPI_EXPORTED MlirType mlirPDLTypeTypeGet(MlirContext ctx);
 
+MLIR_CAPI_EXPORTED MlirStringRef mlirPDLTypeTypeGetName(void);
+
 //===---------------------------------------------------------------------===//
 // ValueType
 //===---------------------------------------------------------------------===//
@@ -76,6 +84,8 @@ MLIR_CAPI_EXPORTED MlirTypeID mlirPDLValueTypeGetTypeID(void);
 
 MLIR_CAPI_EXPORTED MlirType mlirPDLValueTypeGet(MlirContext ctx);
 
+MLIR_CAPI_EXPORTED MlirStringRef mlirPDLValueTypeGetName(void);
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/mlir/include/mlir-c/Dialect/Quant.h b/mlir/include/mlir-c/Dialect/Quant.h
index f961c01d5dc2a..4fe0fba25e157 100644
--- a/mlir/include/mlir-c/Dialect/Quant.h
+++ b/mlir/include/mlir-c/Dialect/Quant.h
@@ -114,6 +114,8 @@ MLIR_CAPI_EXPORTED MlirType mlirAnyQuantizedTypeGet(unsigned flags,
                                                     int64_t storageTypeMin,
                                                     int64_t storageTypeMax);
 
+MLIR_CAPI_EXPORTED MlirStringRef mlirAnyQuantizedTypeGetName(void);
+
 //===---------------------------------------------------------------------===//
 // UniformQuantizedType
 //===---------------------------------------------------------------------===//
@@ -130,6 +132,8 @@ MLIR_CAPI_EXPORTED MlirType mlirUniformQuantizedTypeGet(
     unsigned flags, MlirType storageType, MlirType expressedType, double scale,
     int64_t zeroPoint, int64_t storageTypeMin, int64_t storageTypeMax);
 
+MLIR_CAPI_EXPORTED MlirStringRef mlirUniformQuantizedTypeGetName(void);
+
 /// Returns the scale of the given uniform quantized type.
 MLIR_CAPI_EXPORTED double mlirUniformQuantizedTypeGetScale(MlirType type);
 
@@ -157,6 +161,8 @@ MLIR_CAPI_EXPORTED MlirType mlirUniformQuantizedPerAxisTypeGet(
     intptr_t nDims, double *scales, int64_t *zeroPoints,
     int32_t quantizedDimension, int64_t storageTypeMin, int64_t storageTypeMax);
 
+MLIR_CAPI_EXPORTED MlirStringRef mlirUniformQuantizedPerAxisTypeGetName(void);
+
 /// Returns the number of axes in the given quantized per-axis type.
 MLIR_CAPI_EXPORTED intptr_t
 mlirUniformQuantizedPerAxisTypeGetNumDims(MlirType type);
@@ -200,6 +206,8 @@ MLIR_CAPI_EXPORTED MlirType mlirUniformQuantizedSubChannelTypeGet(
     intptr_t blockSizeInfoLength, int32_t *quantizedDimensions,
     int64_t *blockSizes, int64_t storageTypeMin, int64_t storageTypeMax);
 
+MLIR_CAPI_EXPORTED MlirStringRef mlirUniformQuantizedSubChannelTypeGetName(void);
+
 /// Returns the number of block sizes provided in type.
 MLIR_CAPI_EXPORTED intptr_t
 mlirUniformQuantizedSubChannelTypeGetNumBlockSizes(MlirType type);
@@ -236,6 +244,8 @@ MLIR_CAPI_EXPORTED MlirTypeID mlirCalibratedQuantizedTypeGetTypeID(void);
 MLIR_CAPI_EXPORTED MlirType
 mlirCalibratedQuantizedTypeGet(MlirType expressedType, double min, double max);
 
+MLIR_CAPI_EXPORTED MlirStringRef mlirCalibratedQuantizedTypeGetName(void);
+
 /// Returns the min value of the given calibrated quantized type.
 MLIR_CAPI_EXPORTED double mlirCalibratedQuantizedTypeGetMin(MlirType type);
 
diff --git a/mlir/include/mlir-c/Dialect/Transform.h b/mlir/include/mlir-c/Dialect/Transform.h
index 02c99b5921882..51c4386f3115c 100644
--- a/mlir/include/mlir-c/Dialect/Transform.h
+++ b/mlir/include/mlir-c/Dialect/Transform.h
@@ -29,6 +29,8 @@ MLIR_CAPI_EXPORTED MlirTypeID mlirTransformAnyOpTypeGetTypeID(void);
 
 MLIR_CAPI_EXPORTED MlirType mlirTransformAnyOpTypeGet(MlirContext ctx);
 
+MLIR_CAPI_EXPORTED MlirStringRef mlirTransformAnyOpTypeGetName(void);
+
 //===---------------------------------------------------------------------===//
 // AnyParamType
 //===---------------------------------------------------------------------===//
@@ -39,6 +41,8 @@ MLIR_CAPI_EXPORTED MlirTypeID mlirTransformAnyParamTypeGetTypeID(void);
 
 MLIR_CAPI_EXPORTED MlirType mlirTransformAnyParamTypeGet(MlirContext ctx);
 
+MLIR_CAPI_EXPORTED MlirStringRef mlirTransformAnyParamTypeGetName(void);
+
 //===---------------------------------------------------------------------===//
 // AnyValueType
 //===---------------------------------------------------------------------===//
@@ -49,6 +53,8 @@ MLIR_CAPI_EXPORTED MlirTypeID mlirTransformAnyValueTypeGetTypeID(void);
 
 MLIR_CAPI_EXPORTED MlirType mlirTransformAnyValueTypeGet(MlirContext ctx);
 
+MLIR_CAPI_EXPORTED MlirStringRef mlirTransformAnyValueTypeGetName(void);
+
 //===---------------------------------------------------------------------===//
 // OperationType
 //===---------------------------------------------------------------------===//
@@ -60,6 +66,8 @@ MLIR_CAPI_EXPORTED MlirTypeID mlirTransformOperationTypeGetTypeID(void);
 MLIR_CAPI_EXPORTED MlirType
 mlirTransformOperationTypeGet(MlirContext ctx, MlirStringRef operationName);
 
+MLIR_CAPI_EXPORTED MlirStringRef mlirTransformOperationTypeGetName(void);
+
 MLIR_CAPI_EXPORTED MlirStringRef
 mlirTransformOperationTypeGetOperationName(MlirType type);
 
@@ -74,6 +82,8 @@ MLIR_CAPI_EXPORTED MlirTypeID mlirTransformParamTypeGetTypeID(void);
 MLIR_CAPI_EXPORTED MlirType mlirTransformParamTypeGet(MlirContext ctx,
                                                       MlirType type);
 
+MLIR_CAPI_EXPORTED MlirStringRef mlirTransformParamTypeGetName(void);
+
 MLIR_CAPI_EXPORTED MlirType mlirTransformParamTypeGetType(MlirType type);
 
 #ifdef __cplusplus
diff --git a/mlir/include/mlir/Bindings/Python/IRCore.h b/mlir/include/mlir/Bindings/Python/IRCore.h
index 8a8d2a1b2270f..1f093d60a3979 100644
--- a/mlir/include/mlir/Bindings/Python/IRCore.h
+++ b/mlir/include/mlir/Bindings/Python/IRCore.h
@@ -24,6 +24,7 @@
 #include "mlir-c/Diagnostics.h"
 #include "mlir-c/IR.h"
 #include "mlir-c/IntegerSet.h"
+#include "mlir-c/Support.h"
 #include "mlir-c/Transforms.h"
 #include "mlir/Bindings/Python/Nanobind.h"
 #include "mlir/Bindings/Python/NanobindAdaptors.h"
@@ -933,6 +934,7 @@ class MLIR_PYTHON_API_EXPORTED PyConcreteType : public BaseTy {
   using GetTypeIDFunctionTy = MlirTypeID (*)();
   using Base = PyConcreteType;
   static constexpr GetTypeIDFunctionTy getTypeIdFunction = nullptr;
+  static inline const MlirStringRef name{};
 
   PyConcreteType() = default;
   PyConcreteType(PyMlirContextRef contextRef, MlirType t)
@@ -988,6 +990,12 @@ class MLIR_PYTHON_API_EXPORTED PyConcreteType : public BaseTy {
           /*replace*/ true);
     }
 
+    if (DerivedTy::name.length != 0) {
+      cls.def("type_name", [](nanobind::object & /*self*/) {
+        return nanobind::str(DerivedTy::name.data, DerivedTy::name.length);
+      });
+    }
+
     DerivedTy::bindDerived(cls);
   }
 
diff --git a/mlir/include/mlir/Bindings/Python/IRTypes.h b/mlir/include/mlir/Bindings/Python/IRTypes.h
index b305dec188f5a..88c0ef9ebf84c 100644
--- a/mlir/include/mlir/Bindings/Python/IRTypes.h
+++ b/mlir/include/mlir/Bindings/Python/IRTypes.h
@@ -10,6 +10,7 @@
 #define MLIR_BINDINGS_PYTHON_IRTYPES_H
 
 #include "mlir-c/BuiltinTypes.h"
+#include "mlir/Bindings/Python/IRCore.h"
 
 namespace mlir {
 namespace python {
@@ -24,6 +25,7 @@ class MLIR_PYTHON_API_EXPORTED PyIntegerType
   static constexpr GetTypeIDFunctionTy getTypeIdFunction =
       mlirIntegerTypeGetTypeID;
   static constexpr const char *pyClassName = "IntegerType";
+  static inline const MlirStringRef name = mlirIntegerTypeGetName();
   using PyConcreteType::PyConcreteType;
 
   enum Signedness { Signless, Signed, Unsigned };
diff --git a/mlir/lib/CAPI/Dialect/AMDGPU.cpp b/mlir/lib/CAPI/Dialect/AMDGPU.cpp
index ddca1cb55edab..c981731d48e60 100644
--- a/mlir/lib/CAPI/Dialect/AMDGPU.cpp
+++ b/mlir/lib/CAPI/Dialect/AMDGPU.cpp
@@ -32,6 +32,10 @@ MlirType mlirAMDGPUTDMBaseTypeGet(MlirContext ctx, MlirType elementType) {
   return wrap(amdgpu::TDMBaseType::get(unwrap(ctx), unwrap(elementType)));
 }
 
+MlirStringRef mlirAMDGPUTDMBaseTypeGetName(void) {
+  return wrap(amdgpu::TDMBaseType::name);
+}
+
 //===---------------------------------------------------------------------===//
 // TDMDescriptorType
 //===---------------------------------------------------------------------===//
@@ -48,6 +52,10 @@ MlirType mlirAMDGPUTDMDescriptorTypeGet(MlirContext ctx) {
   return wrap(amdgpu::TDMDescriptorType::get(unwrap(ctx)));
 }
 
+MlirStringRef mlirAMDGPUTDMDescriptorTypeGetName(void) {
+  return wrap(amdgpu::TDMDescriptorType::name);
+}
+
 //===---------------------------------------------------------------------===//
 // TDMGatherBaseType
 //===---------------------------------------------------------------------===//
@@ -65,3 +73,7 @@ MlirType mlirAMDGPUTDMGatherBaseTypeGet(MlirContext ctx, MlirType elementType,
   return wrap(amdgpu::TDMGatherBaseType::get(unwrap(ctx), unwrap(elementType),
                                              unwrap(indexType)));
 }
+
+MlirStringRef mlirAMDGPUTDMGatherBaseTypeGetName(void) {
+  return wrap(amdgpu::TDMGatherBaseType::name);
+}
diff --git a/mlir/lib/CAPI/Dialect/EmitC.cpp b/mlir/lib/CAPI/Dialect/EmitC.cpp
index b6d197366f622..285d995d6653f 100644
--- a/mlir/lib/CAPI/Dialect/EmitC.cpp
+++ b/mlir/lib/CAPI/Dialect/EmitC.cpp
@@ -49,6 +49,10 @@ MlirType mlirEmitCArrayTypeGet(intptr_t nDims, int64_t *shape,
       emitc::ArrayType::get(llvm::ArrayRef(shape, nDims), unwrap(elementType)));
 }
 
+MlirStringRef mlirEmitCArrayTypeGetName(void) {
+  return wrap(emitc::ArrayType::name);
+}
+
 //===---------------------------------------------------------------------===//
 // LValueType
 //===---------------------------------------------------------------------===//
@@ -65,6 +69,10 @@ MlirType mlirEmitCLValueTypeGet(MlirType valueType) {
   return wrap(emitc::LValueType::get(unwrap(valueType)));
 }
 
+MlirStringRef mlirEmitCLValueTypeGetName(void) {
+  return wrap(emitc::LValueType::name);
+}
+
 //===---------------------------------------------------------------------===//
 // OpaqueType
 //===---------------------------------------------------------------------===//
@@ -81,6 +89,10 @@ MlirType mlirEmitCOpaqueTypeGet(MlirContext ctx, MlirStringRef value) {
   return wrap(emitc::OpaqueType::get(unwrap(ctx), unwrap(value)));
 }
 
+MlirStringRef mlirEmitCOpaqueTypeGetName(void) {
+  return wrap(emitc::OpaqueType::name);
+}
+
 //===---------------------------------------------------------------------===//
 // PointerType
 //===---------------------------------------------------------------------===//
@@ -97,6 +109,10 @@ MlirType mlirEmitCPointerTypeGet(MlirType pointee) {
   return wrap(emitc::PointerType::get(unwrap(pointee)));
 }
 
+MlirStringRef mlirEmitCPointerTypeGetName(void) {
+  return wrap(emitc::PointerType::name);
+}
+
 //===---------------------------------------------------------------------===//
 // PtrDiffTType
 //===---------------------------------------------------------------------===//
@@ -113,6 +129,10 @@ MlirType mlirEmitCPtrDiffTTypeGet(MlirContext ctx) {
   return wrap(emitc::PtrDiffTType::get(unwrap(ctx)));
 }
 
+MlirStringRef mlirEmitCPtrDiffTTypeGetName(void) {
+  return wrap(emitc::PtrDiffTType::name);
+}
+
 //===---------------------------------------------------------------------===//
 // SignedSizeTType
 //===---------------------------------------------------------------------===//
@@ -129,6 +149,10 @@ MlirType mlirEmitCSignedSizeTTypeGet(MlirContext ctx) {
   return wrap(emitc::SignedSizeTType::get(unwrap(ctx)));
 }
 
+MlirStringRef mlirEmitCSignedSizeTTypeGetName(void) {
+  return wrap(emitc::SignedSizeTType::name);
+}
+
 //===---------------------------------------------------------------------===//
 // SizeTType
 //===---------------------------------------------------------------------===//
@@ -145,6 +169,10 @@ MlirType mlirEmitCSizeTTypeGet(MlirContext ctx) {
   return wrap(emitc::SizeTType::get(unwrap(ctx)));
 }
 
+MlirStringRef mlirEmitCSizeTTypeGetName(void) {
+  return wrap(emitc::SizeTType::name);
+}
+
 //===----------------------------------------------------------------------===//
 // CmpPredicate attribute.
 //===----------------------------------------------------------------------===//
diff --git a/mlir/lib/CAPI/Dialect/GPU.cpp b/mlir/lib/CAPI/Dialect/GPU.cpp
index e4796ed1499ea..943ca17a57ee2 100644
--- a/mlir/lib/CAPI/Dialect/GPU.cpp
+++ b/mlir/lib/CAPI/Dialect/GPU.cpp
@@ -27,6 +27,10 @@ MlirType mlirGPUAsyncTokenTypeGet(MlirContext ctx) {
   return wrap(gpu::AsyncTokenType::get(unwrap(ctx)));
 }
 
+MlirStringRef mlirGPUAsyncTokenTypeGetName(void) {
+  return wrap(gpu::AsyncTokenType::name);
+}
+
 //===---------------------------------------------------------------------===//
 // ObjectAttr
 //===---------------------------------------------------------------------===//
diff --git a/mlir/lib/CAPI/Dialect/LLVM.cpp b/mlir/lib/CAPI/Dialect/LLVM.cpp
index bf231767320a5..a8e0e91404cd0 100644
--- a/mlir/lib/CAPI/Dialect/LLVM.cpp
+++ b/mlir/lib/CAPI/Dialect/LLVM.cpp
@@ -27,6 +27,10 @@ MlirType mlirLLVMPointerTypeGet(MlirContext ctx, unsigned addressSpace) {
   return wrap(LLVMPointerType::get(unwrap(ctx), addressSpace));
 }
 
+MlirStringRef mlirLLVMPointerTypeGetName(void) {
+  return wrap(LLVM::LLVMPointerType::name);
+}
+
 MlirTypeID mlirLLVMPointerTypeGetTypeID() {
   return wrap(LLVM::LLVMPointerType::getTypeID());
 }
@@ -43,10 +47,16 @@ MlirType mlirLLVMVoidTypeGet(MlirContext ctx) {
   return wrap(LLVMVoidType::get(unwrap(ctx)));
 }
 
+MlirStringRef mlirLLVMVoidTypeGetName(void) { return wrap(LLVMVoidType::name); }
+
 MlirType mlirLLVMArrayTypeGet(MlirType elementType, unsigned numElements) {
   return wrap(LLVMArrayType::get(unwrap(elementType), numElements));
 }
 
+MlirStringRef mlirLLVMArrayTypeGetName(void) {
+  return wrap(LLVMArrayType::name);
+}
+
 MlirType mlirLLVMArrayTypeGetElementType(MlirType type) {
   return wrap(cast<LLVM::LLVMArrayType>(unwrap(type)).getElementType());
 }
@@ -59,6 +69,10 @@ MlirType mlirLLVMFunctionTypeGet(MlirType resultType, intptr_t nArgumentTypes,
       unwrapList(nArgumentTypes, argumentTypes, argumentStorage), isVarArg));
 }
 
+MlirStringRef mlirLLVMFunctionTypeGetName(void) {
+  return wrap(LLVMFunctionType::name);
+}
+
 intptr_t mlirLLVMFunctionTypeGetNumInputs(MlirType type) {
   return llvm::cast<LLVM::LLVMFunctionType>(unwrap(type)).getNumParams();
 }
diff --git a/mlir/lib/CAPI/Dialect/NVGPU.cpp b/mlir/lib/CAPI/Dialect/NVGPU.cpp
index e6da529e1b6b5..044e6b09db83d 100644
--- a/mlir/lib/CAPI/Dialect/NVGPU.cpp
+++ b/mlir/lib/CAPI/Dialect/NVGPU.cpp
@@ -29,3 +29,7 @@ MlirType mlirNVGPUTensorMapDescriptorTypeGet(MlirContext ctx,
       TensorMapSwizzleKind(swizzle), TensorMapL2PromoKind(l2promo),
       TensorMapOOBKind(oobFill), TensorMapInterleaveKind(interleave)));
 }
+
+MlirStringRef mlirNVGPUTensorMapDescriptorTypeGetName(void) {
+  return wrap(nvgpu::TensorMapDescriptorType::name);
+}
diff --git a/mlir/lib/CAPI/Dialect/PDL.cpp b/mlir/lib/CAPI/Dialect/PDL.cpp
index 88cd6056480f1..e707a05d0e872 100644
--- a/mlir/lib/CAPI/Dialect/PDL.cpp
+++ b/mlir/lib/CAPI/Dialect/PDL.cpp
@@ -40,6 +40,10 @@ MlirType mlirPDLAttributeTypeGet(MlirContext ctx) {
   return wrap(pdl::AttributeType::get(unwrap(ctx)));
 }
 
+MlirStringRef mlirPDLAttributeTypeGetName(void) {
+  return wrap(pdl::AttributeType::name);
+}
+
 //===---------------------------------------------------------------------===//
 // OperationType
 //===---------------------------------------------------------------------===//
@@ -56,6 +60,10 @@ MlirType mlirPDLOperationTypeGet(MlirContext ctx) {
   return wrap(pdl::OperationType::get(unwrap(ctx)));
 }
 
+MlirStringRef mlirPDLOperationTypeGetName(void) {
+  return wrap(pdl::OperationType::name);
+}
+
 //===---------------------------------------------------------------------===//
 // RangeType
 //===---------------------------------------------------------------------===//
@@ -72,6 +80,8 @@ MlirType mlirPDLRangeTypeGet(MlirType elementType) {
   return wrap(pdl::RangeType::get(unwrap(elementType)));
 }
 
+MlirStringRef mlirPDLRangeTypeGetName(void) { return wrap(pdl::RangeType::name); }
+
 MlirType mlirPDLRangeTypeGetElementType(MlirType type) {
   return wrap(cast<pdl::RangeType>(unwrap(type)).getElementType());
 }
@@ -92,6 +102,8 @@ MlirType mlirPDLTypeTypeGet(MlirContext ctx) {
   return wrap(pdl::TypeType::get(unwrap(ctx)));
 }
 
+MlirStringRef mlirPDLTypeTypeGetName(void) { return wrap(pdl::TypeType::name); }
+
 //===---------------------------------------------------------------------===//
 // ValueType
 //===---------------------------------------------------------------------===//
@@ -107,3 +119,5 @@ MlirTypeID mlirPDLValueTypeGetTypeID(void) {
 MlirType mlirPDLValueTypeGet(MlirContext ctx) {
   return wrap(pdl::ValueType::get(unwrap(ctx)));
 }
+
+MlirStringRef mlirPDLValueTypeGetName(void) { return wrap(pdl::ValueType::name); }
diff --git a/mlir/lib/CAPI/Dialect/Quant.cpp b/mlir/lib/CAPI/Dialect/Quant.cpp
index 840051caab852..f45bcc1832cbc 100644
--- a/mlir/lib/CAPI/Dialect/Quant.cpp
+++ b/mlir/lib/CAPI/Dialect/Quant.cpp
@@ -125,6 +125,10 @@ MlirType mlirAnyQuantizedTypeGet(unsigned flags, MlirType storageType,
                                            storageTypeMin, storageTypeMax));
 }
 
+MlirStringRef mlirAnyQuantizedTypeGetName(void) {
+  return wrap(quant::AnyQuantizedType::name);
+}
+
 //===---------------------------------------------------------------------===//
 // UniformQuantizedType
 //===---------------------------------------------------------------------===//
@@ -146,6 +150,10 @@ MlirType mlirUniformQuantizedTypeGet(unsigned flags, MlirType storageType,
       storageTypeMin, storageTypeMax));
 }
 
+MlirStringRef mlirUniformQuantizedTypeGetName(void) {
+  return wrap(quant::UniformQuantizedType::name);
+}
+
 double mlirUniformQuantizedTypeGetScale(MlirType type) {
   return cast<quant::UniformQuantizedType>(unwrap(type)).getScale();
 }
@@ -181,6 +189,10 @@ MlirType mlirUniformQuantizedPerAxisTypeGet(
       quantizedDimension, storageTypeMin, storageTypeMax));
 }
 
+MlirStringRef mlirUniformQuantizedPerAxisTypeGetName(void) {
+  return wrap(quant::UniformQuantizedPerAxisType::name);
+}
+
 intptr_t mlirUniformQuantizedPerAxisTypeGetNumDims(MlirType type) {
   return cast<quant::UniformQuantizedPerAxisType>(unwrap(type))
       .getScales()
@@ -238,6 +250,10 @@ MlirType mlirUniformQuantizedSubChannelTypeGet(
       storageTypeMax));
 }
 
+MlirStringRef mlirUniformQuantizedSubChannelTypeGetName(void) {
+  return wrap(quant::UniformQuantizedSubChannelType::name);
+}
+
 intptr_t mlirUniformQuantizedSubChannelTypeGetNumBlockSizes(MlirType type) {
   return cast<quant::UniformQuantizedSubChannelType>(unwrap(type))
       .getBlockSizes()
@@ -284,6 +300,10 @@ MlirType mlirCalibratedQuantizedTypeGet(MlirType expressedType, double min,
       quant::CalibratedQuantizedType::get(unwrap(expressedType), min, max));
 }
 
+MlirStringRef mlirCalibratedQuantizedTypeGetName(void) {
+  return wrap(quant::CalibratedQuantizedType::name);
+}
+
 double mlirCalibratedQuantizedTypeGetMin(MlirType type) {
   return cast<quant::CalibratedQuantizedType>(unwrap(type)).getMin();
 }
diff --git a/mlir/lib/CAPI/Dialect/Transform.cpp b/mlir/lib/CAPI/Dialect/Transform.cpp
index 5fd773572bd3c..18d4c075dbb9c 100644
--- a/mlir/lib/CAPI/Dialect/Transform.cpp
+++ b/mlir/lib/CAPI/Dialect/Transform.cpp
@@ -33,6 +33,10 @@ MlirType mlirTransformAnyOpTypeGet(MlirContext ctx) {
   return wrap(transform::AnyOpType::get(unwrap(ctx)));
 }
 
+MlirStringRef mlirTransformAnyOpTypeGetName(void) {
+  return wrap(transform::AnyOpType::name);
+}
+
 //===---------------------------------------------------------------------===//
 // AnyParamType
 //===---------------------------------------------------------------------===//
@@ -49,6 +53,10 @@ MlirType mlirTransformAnyParamTypeGet(MlirContext ctx) {
   return wrap(transform::AnyParamType::get(unwrap(ctx)));
 }
 
+MlirStringRef mlirTransformAnyParamTypeGetName(void) {
+  return wrap(transform::AnyParamType::name);
+}
+
 //===---------------------------------------------------------------------===//
 // AnyValueType
 //===---------------------------------------------------------------------===//
@@ -65,6 +73,10 @@ MlirType mlirTransformAnyValueTypeGet(MlirContext ctx) {
   return wrap(transform::AnyValueType::get(unwrap(ctx)));
 }
 
+MlirStringRef mlirTransformAnyValueTypeGetName(void) {
+  return wrap(transform::AnyValueType::name);
+}
+
 //===---------------------------------------------------------------------===//
 // OperationType
 //===---------------------------------------------------------------------===//
@@ -83,6 +95,10 @@ MlirType mlirTransformOperationTypeGet(MlirContext ctx,
       transform::OperationType::get(unwrap(ctx), unwrap(operationName)));
 }
 
+MlirStringRef mlirTransformOperationTypeGetName(void) {
+  return wrap(transform::OperationType::name);
+}
+
 MlirStringRef mlirTransformOperationTypeGetOperationName(MlirType type) {
   return wrap(cast<transform::OperationType>(unwrap(type)).getOperationName());
 }
@@ -103,6 +119,10 @@ MlirType mlirTransformParamTypeGet(MlirContext ctx, MlirType type) {
   return wrap(transform::ParamType::get(unwrap(ctx), unwrap(type)));
 }
 
+MlirStringRef mlirTransformParamTypeGetName(void) {
+  return wrap(transform::ParamType::name);
+}
+
 MlirType mlirTransformParamTypeGetType(MlirType type) {
   return wrap(cast<transform::ParamType>(unwrap(type)).getType());
 }
diff --git a/mlir/lib/CAPI/IR/BuiltinTypes.cpp b/mlir/lib/CAPI/IR/BuiltinTypes.cpp
index e2e236ab4b074..6464fef4653e1 100644
--- a/mlir/lib/CAPI/IR/BuiltinTypes.cpp
+++ b/mlir/lib/CAPI/IR/BuiltinTypes.cpp
@@ -35,6 +35,8 @@ MlirType mlirIntegerTypeGet(MlirContext ctx, unsigned bitwidth) {
   return wrap(IntegerType::get(unwrap(ctx), bitwidth));
 }
 
+MlirStringRef mlirIntegerTypeGetName(void) { return wrap(IntegerType::name); }
+
 MlirType mlirIntegerTypeSignedGet(MlirContext ctx, unsigned bitwidth) {
   return wrap(IntegerType::get(unwrap(ctx), bitwidth, IntegerType::Signed));
 }
@@ -73,6 +75,8 @@ MlirType mlirIndexTypeGet(MlirContext ctx) {
   return wrap(IndexType::get(unwrap(ctx)));
 }
 
+MlirStringRef mlirIndexTypeGetName(void) { return wrap(IndexType::name); }
+
 //===----------------------------------------------------------------------===//
 // Floating-point types.
 //===----------------------------------------------------------------------===//
@@ -97,6 +101,10 @@ MlirType mlirFloat4E2M1FNTypeGet(MlirContext ctx) {
   return wrap(Float4E2M1FNType::get(unwrap(ctx)));
 }
 
+MlirStringRef mlirFloat4E2M1FNTypeGetName(void) {
+  return wrap(Float4E2M1FNType::name);
+}
+
 MlirTypeID mlirFloat6E2M3FNTypeGetTypeID() {
   return wrap(Float6E2M3FNType::getTypeID());
 }
@@ -109,6 +117,10 @@ MlirType mlirFloat6E2M3FNTypeGet(MlirContext ctx) {
   return wrap(Float6E2M3FNType::get(unwrap(ctx)));
 }
 
+MlirStringRef mlirFloat6E2M3FNTypeGetName(void) {
+  return wrap(Float6E2M3FNType::name);
+}
+
 MlirTypeID mlirFloat6E3M2FNTypeGetTypeID() {
   return wrap(Float6E3M2FNType::getTypeID());
 }
@@ -121,6 +133,10 @@ MlirType mlirFloat6E3M2FNTypeGet(MlirContext ctx) {
   return wrap(Float6E3M2FNType::get(unwrap(ctx)));
 }
 
+MlirStringRef mlirFloat6E3M2FNTypeGetName(void) {
+  return wrap(Float6E3M2FNType::name);
+}
+
 MlirTypeID mlirFloat8E5M2TypeGetTypeID() {
   return wrap(Float8E5M2Type::getTypeID());
 }
@@ -133,6 +149,10 @@ MlirType mlirFloat8E5M2TypeGet(MlirContext ctx) {
   return wrap(Float8E5M2Type::get(unwrap(ctx)));
 }
 
+MlirStringRef mlirFloat8E5M2TypeGetName(void) {
+  return wrap(Float8E5M2Type::name);
+}
+
 MlirTypeID mlirFloat8E4M3TypeGetTypeID() {
   return wrap(Float8E4M3Type::getTypeID());
 }
@@ -145,6 +165,10 @@ MlirType mlirFloat8E4M3TypeGet(MlirContext ctx) {
   return wrap(Float8E4M3Type::get(unwrap(ctx)));
 }
 
+MlirStringRef mlirFloat8E4M3TypeGetName(void) {
+  return wrap(Float8E4M3Type::name);
+}
+
 MlirTypeID mlirFloat8E4M3FNTypeGetTypeID() {
   return wrap(Float8E4M3FNType::getTypeID());
 }
@@ -157,6 +181,10 @@ MlirType mlirFloat8E4M3FNTypeGet(MlirContext ctx) {
   return wrap(Float8E4M3FNType::get(unwrap(ctx)));
 }
 
+MlirStringRef mlirFloat8E4M3FNTypeGetName(void) {
+  return wrap(Float8E4M3FNType::name);
+}
+
 MlirTypeID mlirFloat8E5M2FNUZTypeGetTypeID() {
   return wrap(Float8E5M2FNUZType::getTypeID());
 }
@@ -169,6 +197,10 @@ MlirType mlirFloat8E5M2FNUZTypeGet(MlirContext ctx) {
   return wrap(Float8E5M2FNUZType::get(unwrap(ctx)));
 }
 
+MlirStringRef mlirFloat8E5M2FNUZTypeGetName(void) {
+  return wrap(Float8E5M2FNUZType::name);
+}
+
 MlirTypeID mlirFloat8E4M3FNUZTypeGetTypeID() {
   return wrap(Float8E4M3FNUZType::getTypeID());
 }
@@ -181,6 +213,10 @@ MlirType mlirFloat8E4M3FNUZTypeGet(MlirContext ctx) {
   return wrap(Float8E4M3FNUZType::get(unwrap(ctx)));
 }
 
+MlirStringRef mlirFloat8E4M3FNUZTypeGetName(void) {
+  return wrap(Float8E4M3FNUZType::name);
+}
+
 MlirTypeID mlirFloat8E4M3B11FNUZTypeGetTypeID() {
   return wrap(Float8E4M3B11FNUZType::getTypeID());
 }
@@ -193,6 +229,10 @@ MlirType mlirFloat8E4M3B11FNUZTypeGet(MlirContext ctx) {
   return wrap(Float8E4M3B11FNUZType::get(unwrap(ctx)));
 }
 
+MlirStringRef mlirFloat8E4M3B11FNUZTypeGetName(void) {
+  return wrap(Float8E4M3B11FNUZType::name);
+}
+
 MlirTypeID mlirFloat8E3M4TypeGetTypeID() {
   return wrap(Float8E3M4Type::getTypeID());
 }
@@ -205,6 +245,10 @@ MlirType mlirFloat8E3M4TypeGet(MlirContext ctx) {
   return wrap(Float8E3M4Type::get(unwrap(ctx)));
 }
 
+MlirStringRef mlirFloat8E3M4TypeGetName(void) {
+  return wrap(Float8E3M4Type::name);
+}
+
 MlirTypeID mlirFloat8E8M0FNUTypeGetTypeID() {
   return wrap(Float8E8M0FNUType::getTypeID());
 }
@@ -217,6 +261,10 @@ MlirType mlirFloat8E8M0FNUTypeGet(MlirContext ctx) {
   return wrap(Float8E8M0FNUType::get(unwrap(ctx)));
 }
 
+MlirStringRef mlirFloat8E8M0FNUTypeGetName(void) {
+  return wrap(Float8E8M0FNUType::name);
+}
+
 MlirTypeID mlirBFloat16TypeGetTypeID() {
   return wrap(BFloat16Type::getTypeID());
 }
@@ -229,6 +277,8 @@ MlirType mlirBF16TypeGet(MlirContext ctx) {
   return wrap(BFloat16Type::get(unwrap(ctx)));
 }
 
+MlirStringRef mlirBF16TypeGetName(void) { return wrap(BFloat16Type::name); }
+
 MlirTypeID mlirFloat16TypeGetTypeID() { return wrap(Float16Type::getTypeID()); }
 
 bool mlirTypeIsAF16(MlirType type) {
@@ -239,6 +289,8 @@ MlirType mlirF16TypeGet(MlirContext ctx) {
   return wrap(Float16Type::get(unwrap(ctx)));
 }
 
+MlirStringRef mlirF16TypeGetName(void) { return wrap(Float16Type::name); }
+
 MlirTypeID mlirFloatTF32TypeGetTypeID() {
   return wrap(FloatTF32Type::getTypeID());
 }
@@ -251,6 +303,8 @@ MlirType mlirTF32TypeGet(MlirContext ctx) {
   return wrap(FloatTF32Type::get(unwrap(ctx)));
 }
 
+MlirStringRef mlirTF32TypeGetName(void) { return wrap(FloatTF32Type::name); }
+
 MlirTypeID mlirFloat32TypeGetTypeID() { return wrap(Float32Type::getTypeID()); }
 
 bool mlirTypeIsAF32(MlirType type) {
@@ -261,6 +315,8 @@ MlirType mlirF32TypeGet(MlirContext ctx) {
   return wrap(Float32Type::get(unwrap(ctx)));
 }
 
+MlirStringRef mlirF32TypeGetName(void) { return wrap(Float32Type::name); }
+
 MlirTypeID mlirFloat64TypeGetTypeID() { return wrap(Float64Type::getTypeID()); }
 
 bool mlirTypeIsAF64(MlirType type) {
@@ -271,6 +327,8 @@ MlirType mlirF64TypeGet(MlirContext ctx) {
   return wrap(Float64Type::get(unwrap(ctx)));
 }
 
+MlirStringRef mlirF64TypeGetName(void) { return wrap(Float64Type::name); }
+
 //===----------------------------------------------------------------------===//
 // None type.
 //===----------------------------------------------------------------------===//
@@ -285,6 +343,8 @@ MlirType mlirNoneTypeGet(MlirContext ctx) {
   return wrap(NoneType::get(unwrap(ctx)));
 }
 
+MlirStringRef mlirNoneTypeGetName(void) { return wrap(NoneType::name); }
+
 //===----------------------------------------------------------------------===//
 // Complex type.
 //===----------------------------------------------------------------------===//
@@ -299,6 +359,8 @@ MlirType mlirComplexTypeGet(MlirType elementType) {
   return wrap(ComplexType::get(unwrap(elementType)));
 }
 
+MlirStringRef mlirComplexTypeGetName(void) { return wrap(ComplexType::name); }
+
 MlirType mlirComplexTypeGetElementType(MlirType type) {
   return wrap(llvm::cast<ComplexType>(unwrap(type)).getElementType());
 }
@@ -380,6 +442,8 @@ MlirType mlirVectorTypeGet(intptr_t rank, const int64_t *shape,
                               unwrap(elementType)));
 }
 
+MlirStringRef mlirVectorTypeGetName(void) { return wrap(VectorType::name); }
+
 MlirType mlirVectorTypeGetChecked(MlirLocation loc, intptr_t rank,
                                   const int64_t *shape, MlirType elementType) {
   return wrap(VectorType::getChecked(
@@ -443,6 +507,10 @@ MlirType mlirRankedTensorTypeGet(intptr_t rank, const int64_t *shape,
                             unwrap(elementType), unwrap(encoding)));
 }
 
+MlirStringRef mlirRankedTensorTypeGetName(void) {
+  return wrap(RankedTensorType::name);
+}
+
 MlirType mlirRankedTensorTypeGetChecked(MlirLocation loc, intptr_t rank,
                                         const int64_t *shape,
                                         MlirType elementType,
@@ -460,6 +528,10 @@ MlirType mlirUnrankedTensorTypeGet(MlirType elementType) {
   return wrap(UnrankedTensorType::get(unwrap(elementType)));
 }
 
+MlirStringRef mlirUnrankedTensorTypeGetName(void) {
+  return wrap(UnrankedTensorType::name);
+}
+
 MlirType mlirUnrankedTensorTypeGetChecked(MlirLocation loc,
                                           MlirType elementType) {
   return wrap(UnrankedTensorType::getChecked(unwrap(loc), unwrap(elementType)));
@@ -486,6 +558,8 @@ MlirType mlirMemRefTypeGet(MlirType elementType, intptr_t rank,
       unwrap(memorySpace)));
 }
 
+MlirStringRef mlirMemRefTypeGetName(void) { return wrap(MemRefType::name); }
+
 MlirType mlirMemRefTypeGetChecked(MlirLocation loc, MlirType elementType,
                                   intptr_t rank, const int64_t *shape,
                                   MlirAttribute layout,
@@ -554,6 +628,10 @@ MlirType mlirUnrankedMemRefTypeGet(MlirType elementType,
       UnrankedMemRefType::get(unwrap(elementType), unwrap(memorySpace)));
 }
 
+MlirStringRef mlirUnrankedMemRefTypeGetName(void) {
+  return wrap(UnrankedMemRefType::name);
+}
+
 MlirType mlirUnrankedMemRefTypeGetChecked(MlirLocation loc,
                                           MlirType elementType,
                                           MlirAttribute memorySpace) {
@@ -582,6 +660,8 @@ MlirType mlirTupleTypeGet(MlirContext ctx, intptr_t numElements,
   return wrap(TupleType::get(unwrap(ctx), typeRef));
 }
 
+MlirStringRef mlirTupleTypeGetName(void) { return wrap(TupleType::name); }
+
 intptr_t mlirTupleTypeGetNumTypes(MlirType type) {
   return llvm::cast<TupleType>(unwrap(type)).size();
 }
@@ -613,6 +693,8 @@ MlirType mlirFunctionTypeGet(MlirContext ctx, intptr_t numInputs,
   return wrap(FunctionType::get(unwrap(ctx), inputsList, resultsList));
 }
 
+MlirStringRef mlirFunctionTypeGetName(void) { return wrap(FunctionType::name); }
+
 intptr_t mlirFunctionTypeGetNumInputs(MlirType type) {
   return llvm::cast<FunctionType>(unwrap(type)).getNumInputs();
 }
@@ -650,6 +732,8 @@ MlirType mlirOpaqueTypeGet(MlirContext ctx, MlirStringRef dialectNamespace,
                       unwrap(typeData)));
 }
 
+MlirStringRef mlirOpaqueTypeGetName(void) { return wrap(OpaqueType::name); }
+
 MlirStringRef mlirOpaqueTypeGetDialectNamespace(MlirType type) {
   return wrap(
       llvm::cast<OpaqueType>(unwrap(type)).getDialectNamespace().strref());

>From 4f063015d0d6ec5a9ab6f0c29f48d372e6d57fb2 Mon Sep 17 00:00:00 2001
From: PragmaTwice <twice at apache.org>
Date: Wed, 7 Jan 2026 13:45:13 +0800
Subject: [PATCH 2/3] add python bindings

---
 mlir/include/mlir/Bindings/Python/IRTypes.h   | 27 +++++++++++++++++++
 mlir/lib/Bindings/Python/DialectAMDGPU.cpp    |  5 ++++
 mlir/lib/Bindings/Python/DialectGPU.cpp       |  1 +
 mlir/lib/Bindings/Python/DialectLLVM.cpp      |  1 +
 mlir/lib/Bindings/Python/DialectNVGPU.cpp     |  2 ++
 mlir/lib/Bindings/Python/DialectPDL.cpp       |  5 ++++
 mlir/lib/Bindings/Python/DialectQuant.cpp     |  8 ++++++
 mlir/lib/Bindings/Python/DialectTransform.cpp |  5 ++++
 8 files changed, 54 insertions(+)

diff --git a/mlir/include/mlir/Bindings/Python/IRTypes.h b/mlir/include/mlir/Bindings/Python/IRTypes.h
index 88c0ef9ebf84c..4a8c5904b55c8 100644
--- a/mlir/include/mlir/Bindings/Python/IRTypes.h
+++ b/mlir/include/mlir/Bindings/Python/IRTypes.h
@@ -41,6 +41,7 @@ class MLIR_PYTHON_API_EXPORTED PyIndexType
   static constexpr GetTypeIDFunctionTy getTypeIdFunction =
       mlirIndexTypeGetTypeID;
   static constexpr const char *pyClassName = "IndexType";
+  static inline const MlirStringRef name = mlirIndexTypeGetName();
   using PyConcreteType::PyConcreteType;
 
   static void bindDerived(ClassTy &c);
@@ -64,6 +65,7 @@ class MLIR_PYTHON_API_EXPORTED PyFloat4E2M1FNType
   static constexpr GetTypeIDFunctionTy getTypeIdFunction =
       mlirFloat4E2M1FNTypeGetTypeID;
   static constexpr const char *pyClassName = "Float4E2M1FNType";
+  static inline const MlirStringRef name = mlirFloat4E2M1FNTypeGetName();
   using PyConcreteType::PyConcreteType;
 
   static void bindDerived(ClassTy &c);
@@ -77,6 +79,7 @@ class MLIR_PYTHON_API_EXPORTED PyFloat6E2M3FNType
   static constexpr GetTypeIDFunctionTy getTypeIdFunction =
       mlirFloat6E2M3FNTypeGetTypeID;
   static constexpr const char *pyClassName = "Float6E2M3FNType";
+  static inline const MlirStringRef name = mlirFloat6E2M3FNTypeGetName();
   using PyConcreteType::PyConcreteType;
 
   static void bindDerived(ClassTy &c);
@@ -90,6 +93,7 @@ class MLIR_PYTHON_API_EXPORTED PyFloat6E3M2FNType
   static constexpr GetTypeIDFunctionTy getTypeIdFunction =
       mlirFloat6E3M2FNTypeGetTypeID;
   static constexpr const char *pyClassName = "Float6E3M2FNType";
+  static inline const MlirStringRef name = mlirFloat6E3M2FNTypeGetName();
   using PyConcreteType::PyConcreteType;
 
   static void bindDerived(ClassTy &c);
@@ -103,6 +107,7 @@ class MLIR_PYTHON_API_EXPORTED PyFloat8E4M3FNType
   static constexpr GetTypeIDFunctionTy getTypeIdFunction =
       mlirFloat8E4M3FNTypeGetTypeID;
   static constexpr const char *pyClassName = "Float8E4M3FNType";
+  static inline const MlirStringRef name = mlirFloat8E4M3FNTypeGetName();
   using PyConcreteType::PyConcreteType;
 
   static void bindDerived(ClassTy &c);
@@ -116,6 +121,7 @@ class MLIR_PYTHON_API_EXPORTED PyFloat8E5M2Type
   static constexpr GetTypeIDFunctionTy getTypeIdFunction =
       mlirFloat8E5M2TypeGetTypeID;
   static constexpr const char *pyClassName = "Float8E5M2Type";
+  static inline const MlirStringRef name = mlirFloat8E5M2TypeGetName();
   using PyConcreteType::PyConcreteType;
 
   static void bindDerived(ClassTy &c);
@@ -129,6 +135,7 @@ class MLIR_PYTHON_API_EXPORTED PyFloat8E4M3Type
   static constexpr GetTypeIDFunctionTy getTypeIdFunction =
       mlirFloat8E4M3TypeGetTypeID;
   static constexpr const char *pyClassName = "Float8E4M3Type";
+  static inline const MlirStringRef name = mlirFloat8E4M3TypeGetName();
   using PyConcreteType::PyConcreteType;
 
   static void bindDerived(ClassTy &c);
@@ -142,6 +149,7 @@ class MLIR_PYTHON_API_EXPORTED PyFloat8E4M3FNUZType
   static constexpr GetTypeIDFunctionTy getTypeIdFunction =
       mlirFloat8E4M3FNUZTypeGetTypeID;
   static constexpr const char *pyClassName = "Float8E4M3FNUZType";
+  static inline const MlirStringRef name = mlirFloat8E4M3FNUZTypeGetName();
   using PyConcreteType::PyConcreteType;
 
   static void bindDerived(ClassTy &c);
@@ -155,6 +163,7 @@ class MLIR_PYTHON_API_EXPORTED PyFloat8E4M3B11FNUZType
   static constexpr GetTypeIDFunctionTy getTypeIdFunction =
       mlirFloat8E4M3B11FNUZTypeGetTypeID;
   static constexpr const char *pyClassName = "Float8E4M3B11FNUZType";
+  static inline const MlirStringRef name = mlirFloat8E4M3B11FNUZTypeGetName();
   using PyConcreteType::PyConcreteType;
 
   static void bindDerived(ClassTy &c);
@@ -168,6 +177,7 @@ class MLIR_PYTHON_API_EXPORTED PyFloat8E5M2FNUZType
   static constexpr GetTypeIDFunctionTy getTypeIdFunction =
       mlirFloat8E5M2FNUZTypeGetTypeID;
   static constexpr const char *pyClassName = "Float8E5M2FNUZType";
+  static inline const MlirStringRef name = mlirFloat8E5M2FNUZTypeGetName();
   using PyConcreteType::PyConcreteType;
 
   static void bindDerived(ClassTy &c);
@@ -181,6 +191,7 @@ class MLIR_PYTHON_API_EXPORTED PyFloat8E3M4Type
   static constexpr GetTypeIDFunctionTy getTypeIdFunction =
       mlirFloat8E3M4TypeGetTypeID;
   static constexpr const char *pyClassName = "Float8E3M4Type";
+  static inline const MlirStringRef name = mlirFloat8E3M4TypeGetName();
   using PyConcreteType::PyConcreteType;
 
   static void bindDerived(ClassTy &c);
@@ -194,6 +205,7 @@ class MLIR_PYTHON_API_EXPORTED PyFloat8E8M0FNUType
   static constexpr GetTypeIDFunctionTy getTypeIdFunction =
       mlirFloat8E8M0FNUTypeGetTypeID;
   static constexpr const char *pyClassName = "Float8E8M0FNUType";
+  static inline const MlirStringRef name = mlirFloat8E8M0FNUTypeGetName();
   using PyConcreteType::PyConcreteType;
 
   static void bindDerived(ClassTy &c);
@@ -207,6 +219,7 @@ class MLIR_PYTHON_API_EXPORTED PyBF16Type
   static constexpr GetTypeIDFunctionTy getTypeIdFunction =
       mlirBFloat16TypeGetTypeID;
   static constexpr const char *pyClassName = "BF16Type";
+  static inline const MlirStringRef name = mlirBF16TypeGetName();
   using PyConcreteType::PyConcreteType;
 
   static void bindDerived(ClassTy &c);
@@ -220,6 +233,7 @@ class MLIR_PYTHON_API_EXPORTED PyF16Type
   static constexpr GetTypeIDFunctionTy getTypeIdFunction =
       mlirFloat16TypeGetTypeID;
   static constexpr const char *pyClassName = "F16Type";
+  static inline const MlirStringRef name = mlirF16TypeGetName();
   using PyConcreteType::PyConcreteType;
 
   static void bindDerived(ClassTy &c);
@@ -233,6 +247,7 @@ class MLIR_PYTHON_API_EXPORTED PyTF32Type
   static constexpr GetTypeIDFunctionTy getTypeIdFunction =
       mlirFloatTF32TypeGetTypeID;
   static constexpr const char *pyClassName = "FloatTF32Type";
+  static inline const MlirStringRef name = mlirTF32TypeGetName();
   using PyConcreteType::PyConcreteType;
 
   static void bindDerived(ClassTy &c);
@@ -246,6 +261,7 @@ class MLIR_PYTHON_API_EXPORTED PyF32Type
   static constexpr GetTypeIDFunctionTy getTypeIdFunction =
       mlirFloat32TypeGetTypeID;
   static constexpr const char *pyClassName = "F32Type";
+  static inline const MlirStringRef name = mlirF32TypeGetName();
   using PyConcreteType::PyConcreteType;
 
   static void bindDerived(ClassTy &c);
@@ -259,6 +275,7 @@ class MLIR_PYTHON_API_EXPORTED PyF64Type
   static constexpr GetTypeIDFunctionTy getTypeIdFunction =
       mlirFloat64TypeGetTypeID;
   static constexpr const char *pyClassName = "F64Type";
+  static inline const MlirStringRef name = mlirF64TypeGetName();
   using PyConcreteType::PyConcreteType;
 
   static void bindDerived(ClassTy &c);
@@ -271,6 +288,7 @@ class MLIR_PYTHON_API_EXPORTED PyNoneType : public PyConcreteType<PyNoneType> {
   static constexpr GetTypeIDFunctionTy getTypeIdFunction =
       mlirNoneTypeGetTypeID;
   static constexpr const char *pyClassName = "NoneType";
+  static inline const MlirStringRef name = mlirNoneTypeGetName();
   using PyConcreteType::PyConcreteType;
 
   static void bindDerived(ClassTy &c);
@@ -284,6 +302,7 @@ class MLIR_PYTHON_API_EXPORTED PyComplexType
   static constexpr GetTypeIDFunctionTy getTypeIdFunction =
       mlirComplexTypeGetTypeID;
   static constexpr const char *pyClassName = "ComplexType";
+  static inline const MlirStringRef name = mlirComplexTypeGetName();
   using PyConcreteType::PyConcreteType;
 
   static void bindDerived(ClassTy &c);
@@ -311,6 +330,7 @@ class MLIR_PYTHON_API_EXPORTED PyVectorType
   static constexpr GetTypeIDFunctionTy getTypeIdFunction =
       mlirVectorTypeGetTypeID;
   static constexpr const char *pyClassName = "VectorType";
+  static inline const MlirStringRef name = mlirVectorTypeGetName();
   using PyConcreteType::PyConcreteType;
 
   static void bindDerived(ClassTy &c);
@@ -336,6 +356,7 @@ class MLIR_PYTHON_API_EXPORTED PyRankedTensorType
   static constexpr GetTypeIDFunctionTy getTypeIdFunction =
       mlirRankedTensorTypeGetTypeID;
   static constexpr const char *pyClassName = "RankedTensorType";
+  static inline const MlirStringRef name = mlirRankedTensorTypeGetName();
   using PyConcreteType::PyConcreteType;
 
   static void bindDerived(ClassTy &c);
@@ -349,6 +370,7 @@ class MLIR_PYTHON_API_EXPORTED PyUnrankedTensorType
   static constexpr GetTypeIDFunctionTy getTypeIdFunction =
       mlirUnrankedTensorTypeGetTypeID;
   static constexpr const char *pyClassName = "UnrankedTensorType";
+  static inline const MlirStringRef name = mlirUnrankedTensorTypeGetName();
   using PyConcreteType::PyConcreteType;
 
   static void bindDerived(ClassTy &c);
@@ -362,6 +384,7 @@ class MLIR_PYTHON_API_EXPORTED PyMemRefType
   static constexpr GetTypeIDFunctionTy getTypeIdFunction =
       mlirMemRefTypeGetTypeID;
   static constexpr const char *pyClassName = "MemRefType";
+  static inline const MlirStringRef name = mlirMemRefTypeGetName();
   using PyConcreteType::PyConcreteType;
 
   static void bindDerived(ClassTy &c);
@@ -375,6 +398,7 @@ class MLIR_PYTHON_API_EXPORTED PyUnrankedMemRefType
   static constexpr GetTypeIDFunctionTy getTypeIdFunction =
       mlirUnrankedMemRefTypeGetTypeID;
   static constexpr const char *pyClassName = "UnrankedMemRefType";
+  static inline const MlirStringRef name = mlirUnrankedMemRefTypeGetName();
   using PyConcreteType::PyConcreteType;
 
   static void bindDerived(ClassTy &c);
@@ -388,6 +412,7 @@ class MLIR_PYTHON_API_EXPORTED PyTupleType
   static constexpr GetTypeIDFunctionTy getTypeIdFunction =
       mlirTupleTypeGetTypeID;
   static constexpr const char *pyClassName = "TupleType";
+  static inline const MlirStringRef name = mlirTupleTypeGetName();
   using PyConcreteType::PyConcreteType;
 
   static void bindDerived(ClassTy &c);
@@ -401,6 +426,7 @@ class MLIR_PYTHON_API_EXPORTED PyFunctionType
   static constexpr GetTypeIDFunctionTy getTypeIdFunction =
       mlirFunctionTypeGetTypeID;
   static constexpr const char *pyClassName = "FunctionType";
+  static inline const MlirStringRef name = mlirFunctionTypeGetName();
   using PyConcreteType::PyConcreteType;
 
   static void bindDerived(ClassTy &c);
@@ -414,6 +440,7 @@ class MLIR_PYTHON_API_EXPORTED PyOpaqueType
   static constexpr GetTypeIDFunctionTy getTypeIdFunction =
       mlirOpaqueTypeGetTypeID;
   static constexpr const char *pyClassName = "OpaqueType";
+  static inline const MlirStringRef name = mlirOpaqueTypeGetName();
   using PyConcreteType::PyConcreteType;
 
   static void bindDerived(ClassTy &c);
diff --git a/mlir/lib/Bindings/Python/DialectAMDGPU.cpp b/mlir/lib/Bindings/Python/DialectAMDGPU.cpp
index 0a0cb1d158abc..393c360e5b49c 100644
--- a/mlir/lib/Bindings/Python/DialectAMDGPU.cpp
+++ b/mlir/lib/Bindings/Python/DialectAMDGPU.cpp
@@ -26,6 +26,7 @@ struct TDMBaseType : PyConcreteType<TDMBaseType> {
   static constexpr GetTypeIDFunctionTy getTypeIdFunction =
       mlirAMDGPUTDMBaseTypeGetTypeID;
   static constexpr const char *pyClassName = "TDMBaseType";
+  static inline const MlirStringRef name = mlirAMDGPUTDMBaseTypeGetName();
   using Base::Base;
 
   static void bindDerived(ClassTy &c) {
@@ -47,6 +48,8 @@ struct TDMDescriptorType : PyConcreteType<TDMDescriptorType> {
   static constexpr GetTypeIDFunctionTy getTypeIdFunction =
       mlirAMDGPUTDMDescriptorTypeGetTypeID;
   static constexpr const char *pyClassName = "TDMDescriptorType";
+  static inline const MlirStringRef name =
+    mlirAMDGPUTDMDescriptorTypeGetName();
   using Base::Base;
 
   static void bindDerived(ClassTy &c) {
@@ -68,6 +71,8 @@ struct TDMGatherBaseType : PyConcreteType<TDMGatherBaseType> {
   static constexpr GetTypeIDFunctionTy getTypeIdFunction =
       mlirAMDGPUTDMGatherBaseTypeGetTypeID;
   static constexpr const char *pyClassName = "TDMGatherBaseType";
+  static inline const MlirStringRef name =
+    mlirAMDGPUTDMGatherBaseTypeGetName();
   using Base::Base;
 
   static void bindDerived(ClassTy &c) {
diff --git a/mlir/lib/Bindings/Python/DialectGPU.cpp b/mlir/lib/Bindings/Python/DialectGPU.cpp
index c2720b33ebacc..a3af9eed48e7a 100644
--- a/mlir/lib/Bindings/Python/DialectGPU.cpp
+++ b/mlir/lib/Bindings/Python/DialectGPU.cpp
@@ -29,6 +29,7 @@ namespace gpu {
 struct AsyncTokenType : PyConcreteType<AsyncTokenType> {
   static constexpr IsAFunctionTy isaFunction = mlirTypeIsAGPUAsyncTokenType;
   static constexpr const char *pyClassName = "AsyncTokenType";
+  static inline const MlirStringRef name = mlirGPUAsyncTokenTypeGetName();
   using Base::Base;
 
   static void bindDerived(ClassTy &c) {
diff --git a/mlir/lib/Bindings/Python/DialectLLVM.cpp b/mlir/lib/Bindings/Python/DialectLLVM.cpp
index a0fec7504ab6b..90275eb029674 100644
--- a/mlir/lib/Bindings/Python/DialectLLVM.cpp
+++ b/mlir/lib/Bindings/Python/DialectLLVM.cpp
@@ -169,6 +169,7 @@ struct PointerType : PyConcreteType<PointerType> {
   static constexpr GetTypeIDFunctionTy getTypeIdFunction =
       mlirLLVMPointerTypeGetTypeID;
   static constexpr const char *pyClassName = "PointerType";
+  static inline const MlirStringRef name = mlirLLVMPointerTypeGetName();
   using Base::Base;
 
   static void bindDerived(ClassTy &c) {
diff --git a/mlir/lib/Bindings/Python/DialectNVGPU.cpp b/mlir/lib/Bindings/Python/DialectNVGPU.cpp
index 325db6d41c460..66c3fcd6387c8 100644
--- a/mlir/lib/Bindings/Python/DialectNVGPU.cpp
+++ b/mlir/lib/Bindings/Python/DialectNVGPU.cpp
@@ -24,6 +24,8 @@ struct TensorMapDescriptorType : PyConcreteType<TensorMapDescriptorType> {
   static constexpr IsAFunctionTy isaFunction =
       mlirTypeIsANVGPUTensorMapDescriptorType;
   static constexpr const char *pyClassName = "TensorMapDescriptorType";
+  static inline const MlirStringRef name =
+      mlirNVGPUTensorMapDescriptorTypeGetName();
   using Base::Base;
 
   static void bindDerived(ClassTy &c) {
diff --git a/mlir/lib/Bindings/Python/DialectPDL.cpp b/mlir/lib/Bindings/Python/DialectPDL.cpp
index b180aed4f8719..fd2fbc1b1b5ee 100644
--- a/mlir/lib/Bindings/Python/DialectPDL.cpp
+++ b/mlir/lib/Bindings/Python/DialectPDL.cpp
@@ -42,6 +42,7 @@ struct AttributeType : PyConcreteType<AttributeType> {
   static constexpr GetTypeIDFunctionTy getTypeIdFunction =
       mlirPDLAttributeTypeGetTypeID;
   static constexpr const char *pyClassName = "AttributeType";
+  static inline const MlirStringRef name = mlirPDLAttributeTypeGetName();
   using Base::Base;
 
   static void bindDerived(ClassTy &c) {
@@ -65,6 +66,7 @@ struct OperationType : PyConcreteType<OperationType> {
   static constexpr GetTypeIDFunctionTy getTypeIdFunction =
       mlirPDLOperationTypeGetTypeID;
   static constexpr const char *pyClassName = "OperationType";
+  static inline const MlirStringRef name = mlirPDLOperationTypeGetName();
   using Base::Base;
 
   static void bindDerived(ClassTy &c) {
@@ -88,6 +90,7 @@ struct RangeType : PyConcreteType<RangeType> {
   static constexpr GetTypeIDFunctionTy getTypeIdFunction =
       mlirPDLRangeTypeGetTypeID;
   static constexpr const char *pyClassName = "RangeType";
+  static inline const MlirStringRef name = mlirPDLRangeTypeGetName();
   using Base::Base;
 
   static void bindDerived(ClassTy &c) {
@@ -118,6 +121,7 @@ struct TypeType : PyConcreteType<TypeType> {
   static constexpr GetTypeIDFunctionTy getTypeIdFunction =
       mlirPDLTypeTypeGetTypeID;
   static constexpr const char *pyClassName = "TypeType";
+  static inline const MlirStringRef name = mlirPDLTypeTypeGetName();
   using Base::Base;
 
   static void bindDerived(ClassTy &c) {
@@ -141,6 +145,7 @@ struct ValueType : PyConcreteType<ValueType> {
   static constexpr GetTypeIDFunctionTy getTypeIdFunction =
       mlirPDLValueTypeGetTypeID;
   static constexpr const char *pyClassName = "ValueType";
+  static inline const MlirStringRef name = mlirPDLValueTypeGetName();
   using Base::Base;
 
   static void bindDerived(ClassTy &c) {
diff --git a/mlir/lib/Bindings/Python/DialectQuant.cpp b/mlir/lib/Bindings/Python/DialectQuant.cpp
index 2f91b5f0c1d7d..b23affa7f0e66 100644
--- a/mlir/lib/Bindings/Python/DialectQuant.cpp
+++ b/mlir/lib/Bindings/Python/DialectQuant.cpp
@@ -198,6 +198,7 @@ struct AnyQuantizedType : PyConcreteType<AnyQuantizedType, QuantizedType> {
   static constexpr GetTypeIDFunctionTy getTypeIdFunction =
       mlirAnyQuantizedTypeGetTypeID;
   static constexpr const char *pyClassName = "AnyQuantizedType";
+  static inline const MlirStringRef name = mlirAnyQuantizedTypeGetName();
   using Base::Base;
 
   static void bindDerived(ClassTy &c) {
@@ -229,6 +230,7 @@ struct UniformQuantizedType
   static constexpr GetTypeIDFunctionTy getTypeIdFunction =
       mlirUniformQuantizedTypeGetTypeID;
   static constexpr const char *pyClassName = "UniformQuantizedType";
+  static inline const MlirStringRef name = mlirUniformQuantizedTypeGetName();
   using Base::Base;
 
   static void bindDerived(ClassTy &c) {
@@ -283,6 +285,8 @@ struct UniformQuantizedPerAxisType
   static constexpr GetTypeIDFunctionTy getTypeIdFunction =
       mlirUniformQuantizedPerAxisTypeGetTypeID;
   static constexpr const char *pyClassName = "UniformQuantizedPerAxisType";
+  static inline const MlirStringRef name =
+    mlirUniformQuantizedPerAxisTypeGetName();
   using Base::Base;
 
   static void bindDerived(ClassTy &c) {
@@ -369,6 +373,8 @@ struct UniformQuantizedSubChannelType
   static constexpr GetTypeIDFunctionTy getTypeIdFunction =
       mlirUniformQuantizedSubChannelTypeGetTypeID;
   static constexpr const char *pyClassName = "UniformQuantizedSubChannelType";
+  static inline const MlirStringRef name =
+    mlirUniformQuantizedSubChannelTypeGetName();
   using Base::Base;
 
   static void bindDerived(ClassTy &c) {
@@ -462,6 +468,8 @@ struct CalibratedQuantizedType
   static constexpr GetTypeIDFunctionTy getTypeIdFunction =
       mlirCalibratedQuantizedTypeGetTypeID;
   static constexpr const char *pyClassName = "CalibratedQuantizedType";
+  static inline const MlirStringRef name =
+    mlirCalibratedQuantizedTypeGetName();
   using Base::Base;
 
   static void bindDerived(ClassTy &c) {
diff --git a/mlir/lib/Bindings/Python/DialectTransform.cpp b/mlir/lib/Bindings/Python/DialectTransform.cpp
index df1a0c25ae171..82905498921ce 100644
--- a/mlir/lib/Bindings/Python/DialectTransform.cpp
+++ b/mlir/lib/Bindings/Python/DialectTransform.cpp
@@ -31,6 +31,7 @@ struct AnyOpType : PyConcreteType<AnyOpType> {
   static constexpr GetTypeIDFunctionTy getTypeIdFunction =
       mlirTransformAnyOpTypeGetTypeID;
   static constexpr const char *pyClassName = "AnyOpType";
+  static inline const MlirStringRef name = mlirTransformAnyOpTypeGetName();
   using Base::Base;
 
   static void bindDerived(ClassTy &c) {
@@ -54,6 +55,7 @@ struct AnyParamType : PyConcreteType<AnyParamType> {
   static constexpr GetTypeIDFunctionTy getTypeIdFunction =
       mlirTransformAnyParamTypeGetTypeID;
   static constexpr const char *pyClassName = "AnyParamType";
+  static inline const MlirStringRef name = mlirTransformAnyParamTypeGetName();
   using Base::Base;
 
   static void bindDerived(ClassTy &c) {
@@ -77,6 +79,7 @@ struct AnyValueType : PyConcreteType<AnyValueType> {
   static constexpr GetTypeIDFunctionTy getTypeIdFunction =
       mlirTransformAnyValueTypeGetTypeID;
   static constexpr const char *pyClassName = "AnyValueType";
+  static inline const MlirStringRef name = mlirTransformAnyValueTypeGetName();
   using Base::Base;
 
   static void bindDerived(ClassTy &c) {
@@ -101,6 +104,7 @@ struct OperationType : PyConcreteType<OperationType> {
   static constexpr GetTypeIDFunctionTy getTypeIdFunction =
       mlirTransformOperationTypeGetTypeID;
   static constexpr const char *pyClassName = "OperationType";
+  static inline const MlirStringRef name = mlirTransformOperationTypeGetName();
   using Base::Base;
 
   static void bindDerived(ClassTy &c) {
@@ -136,6 +140,7 @@ struct ParamType : PyConcreteType<ParamType> {
   static constexpr GetTypeIDFunctionTy getTypeIdFunction =
       mlirTransformParamTypeGetTypeID;
   static constexpr const char *pyClassName = "ParamType";
+  static inline const MlirStringRef name = mlirTransformParamTypeGetName();
   using Base::Base;
 
   static void bindDerived(ClassTy &c) {

>From a0be5027d96f023764ad90d7a6ded5faa01e0715 Mon Sep 17 00:00:00 2001
From: PragmaTwice <twice at apache.org>
Date: Wed, 7 Jan 2026 13:59:46 +0800
Subject: [PATCH 3/3] add for llvm.struct and smt

---
 mlir/include/mlir-c/Dialect/LLVM.h       | 2 ++
 mlir/include/mlir-c/Dialect/SMT.h        | 6 ++++++
 mlir/lib/Bindings/Python/DialectLLVM.cpp | 1 +
 mlir/lib/Bindings/Python/DialectSMT.cpp  | 3 +++
 mlir/lib/CAPI/Dialect/LLVM.cpp           | 4 ++++
 mlir/lib/CAPI/Dialect/SMT.cpp            | 8 ++++++++
 6 files changed, 24 insertions(+)

diff --git a/mlir/include/mlir-c/Dialect/LLVM.h b/mlir/include/mlir-c/Dialect/LLVM.h
index 623b790d88d03..35f3717ad2372 100644
--- a/mlir/include/mlir-c/Dialect/LLVM.h
+++ b/mlir/include/mlir-c/Dialect/LLVM.h
@@ -70,6 +70,8 @@ MLIR_CAPI_EXPORTED bool mlirTypeIsALLVMStructType(MlirType type);
 
 MLIR_CAPI_EXPORTED MlirTypeID mlirLLVMStructTypeGetTypeID(void);
 
+MLIR_CAPI_EXPORTED MlirStringRef mlirLLVMStructTypeGetName(void);
+
 /// Returns `true` if the type is a literal (unnamed) LLVM struct type.
 MLIR_CAPI_EXPORTED bool mlirLLVMStructTypeIsLiteral(MlirType type);
 
diff --git a/mlir/include/mlir-c/Dialect/SMT.h b/mlir/include/mlir-c/Dialect/SMT.h
index 0ad64746f148b..66caeffea8281 100644
--- a/mlir/include/mlir-c/Dialect/SMT.h
+++ b/mlir/include/mlir-c/Dialect/SMT.h
@@ -46,18 +46,24 @@ MLIR_CAPI_EXPORTED bool mlirSMTTypeIsABitVector(MlirType type);
 MLIR_CAPI_EXPORTED MlirType mlirSMTTypeGetBitVector(MlirContext ctx,
                                                     int32_t width);
 
+MLIR_CAPI_EXPORTED MlirStringRef mlirSMTBitVectorTypeGetName(void);
+
 /// Checks if the given type is a smt::BoolType.
 MLIR_CAPI_EXPORTED bool mlirSMTTypeIsABool(MlirType type);
 
 /// Creates a smt::BoolType.
 MLIR_CAPI_EXPORTED MlirType mlirSMTTypeGetBool(MlirContext ctx);
 
+MLIR_CAPI_EXPORTED MlirStringRef mlirSMTBoolTypeGetName(void);
+
 /// Checks if the given type is a smt::IntType.
 MLIR_CAPI_EXPORTED bool mlirSMTTypeIsAInt(MlirType type);
 
 /// Creates a smt::IntType.
 MLIR_CAPI_EXPORTED MlirType mlirSMTTypeGetInt(MlirContext ctx);
 
+MLIR_CAPI_EXPORTED MlirStringRef mlirSMTIntTypeGetName(void);
+
 /// Checks if the given type is a smt::FuncType.
 MLIR_CAPI_EXPORTED bool mlirSMTTypeIsASMTFunc(MlirType type);
 
diff --git a/mlir/lib/Bindings/Python/DialectLLVM.cpp b/mlir/lib/Bindings/Python/DialectLLVM.cpp
index 90275eb029674..0e4d81ce41b44 100644
--- a/mlir/lib/Bindings/Python/DialectLLVM.cpp
+++ b/mlir/lib/Bindings/Python/DialectLLVM.cpp
@@ -37,6 +37,7 @@ struct StructType : PyConcreteType<StructType> {
   static constexpr GetTypeIDFunctionTy getTypeIdFunction =
       mlirLLVMStructTypeGetTypeID;
   static constexpr const char *pyClassName = "StructType";
+  static inline const MlirStringRef name = mlirLLVMStructTypeGetName();
   using Base::Base;
 
   static void bindDerived(ClassTy &c) {
diff --git a/mlir/lib/Bindings/Python/DialectSMT.cpp b/mlir/lib/Bindings/Python/DialectSMT.cpp
index f13604abb4751..eff10a0e55c05 100644
--- a/mlir/lib/Bindings/Python/DialectSMT.cpp
+++ b/mlir/lib/Bindings/Python/DialectSMT.cpp
@@ -30,6 +30,7 @@ namespace smt {
 struct BoolType : PyConcreteType<BoolType> {
   static constexpr IsAFunctionTy isaFunction = mlirSMTTypeIsABool;
   static constexpr const char *pyClassName = "BoolType";
+  static inline const MlirStringRef name = mlirSMTBoolTypeGetName();
   using Base::Base;
 
   static void bindDerived(ClassTy &c) {
@@ -46,6 +47,7 @@ struct BoolType : PyConcreteType<BoolType> {
 struct BitVectorType : PyConcreteType<BitVectorType> {
   static constexpr IsAFunctionTy isaFunction = mlirSMTTypeIsABitVector;
   static constexpr const char *pyClassName = "BitVectorType";
+  static inline const MlirStringRef name = mlirSMTBitVectorTypeGetName();
   using Base::Base;
 
   static void bindDerived(ClassTy &c) {
@@ -63,6 +65,7 @@ struct BitVectorType : PyConcreteType<BitVectorType> {
 struct IntType : PyConcreteType<IntType> {
   static constexpr IsAFunctionTy isaFunction = mlirSMTTypeIsAInt;
   static constexpr const char *pyClassName = "IntType";
+  static inline const MlirStringRef name = mlirSMTIntTypeGetName();
   using Base::Base;
 
   static void bindDerived(ClassTy &c) {
diff --git a/mlir/lib/CAPI/Dialect/LLVM.cpp b/mlir/lib/CAPI/Dialect/LLVM.cpp
index a8e0e91404cd0..49eff0508f80d 100644
--- a/mlir/lib/CAPI/Dialect/LLVM.cpp
+++ b/mlir/lib/CAPI/Dialect/LLVM.cpp
@@ -95,6 +95,10 @@ MlirTypeID mlirLLVMStructTypeGetTypeID() {
   return wrap(LLVM::LLVMStructType::getTypeID());
 }
 
+MlirStringRef mlirLLVMStructTypeGetName(void) {
+  return wrap(LLVM::LLVMStructType::name);
+}
+
 bool mlirLLVMStructTypeIsLiteral(MlirType type) {
   return !cast<LLVM::LLVMStructType>(unwrap(type)).isIdentified();
 }
diff --git a/mlir/lib/CAPI/Dialect/SMT.cpp b/mlir/lib/CAPI/Dialect/SMT.cpp
index 7e96bbb071533..56b771f55b0e3 100644
--- a/mlir/lib/CAPI/Dialect/SMT.cpp
+++ b/mlir/lib/CAPI/Dialect/SMT.cpp
@@ -49,18 +49,26 @@ MlirType mlirSMTTypeGetBitVector(MlirContext ctx, int32_t width) {
   return wrap(BitVectorType::get(unwrap(ctx), width));
 }
 
+MlirStringRef mlirSMTBitVectorTypeGetName(void) {
+  return wrap(BitVectorType::name);
+}
+
 bool mlirSMTTypeIsABool(MlirType type) { return isa<BoolType>(unwrap(type)); }
 
 MlirType mlirSMTTypeGetBool(MlirContext ctx) {
   return wrap(BoolType::get(unwrap(ctx)));
 }
 
+MlirStringRef mlirSMTBoolTypeGetName(void) { return wrap(BoolType::name); }
+
 bool mlirSMTTypeIsAInt(MlirType type) { return isa<IntType>(unwrap(type)); }
 
 MlirType mlirSMTTypeGetInt(MlirContext ctx) {
   return wrap(IntType::get(unwrap(ctx)));
 }
 
+MlirStringRef mlirSMTIntTypeGetName(void) { return wrap(IntType::name); }
+
 bool mlirSMTTypeIsASMTFunc(MlirType type) {
   return isa<SMTFuncType>(unwrap(type));
 }



More information about the Mlir-commits mailing list