Expose llvm dialect in python bindings (#17762)
This PR exposes the llvm dialect in the python bindings to enable
downstream users (such as tkw) to call llvm intrinsics.
Signed-off-by: Harsh Menon <menon.harsh@gmail.com>
Co-authored-by: Harsh Menon <menon.harsh@gmail.com>
diff --git a/compiler/bindings/python/CMakeLists.txt b/compiler/bindings/python/CMakeLists.txt
index 65b817a..150c94f 100644
--- a/compiler/bindings/python/CMakeLists.txt
+++ b/compiler/bindings/python/CMakeLists.txt
@@ -185,6 +185,7 @@
MLIRPythonSources.Dialects.func
MLIRPythonSources.Dialects.gpu
MLIRPythonSources.Dialects.linalg
+ MLIRPythonSources.Dialects.llvm
MLIRPythonSources.Dialects.math
MLIRPythonSources.Dialects.memref
MLIRPythonSources.Dialects.pdl
diff --git a/compiler/src/iree/compiler/API/BUILD.bazel b/compiler/src/iree/compiler/API/BUILD.bazel
index 3076404..17320d2 100644
--- a/compiler/src/iree/compiler/API/BUILD.bazel
+++ b/compiler/src/iree/compiler/API/BUILD.bazel
@@ -39,6 +39,7 @@
"@llvm-project//mlir:CAPIGPU",
"@llvm-project//mlir:CAPIIR",
"@llvm-project//mlir:CAPIInterfaces",
+ "@llvm-project//mlir:CAPILLVM",
"@llvm-project//mlir:CAPILinalg",
"@llvm-project//mlir:CAPIPDL",
"@llvm-project//mlir:CAPITransformDialect",
diff --git a/compiler/src/iree/compiler/API/CMakeLists.txt b/compiler/src/iree/compiler/API/CMakeLists.txt
index f404793..6108e12 100644
--- a/compiler/src/iree/compiler/API/CMakeLists.txt
+++ b/compiler/src/iree/compiler/API/CMakeLists.txt
@@ -19,6 +19,7 @@
MLIRCAPIGPU
MLIRCAPIIR
MLIRCAPIInterfaces
+ MLIRCAPILLVM
MLIRCAPILinalg
MLIRCAPIPDL
MLIRCAPITransformDialect
@@ -69,6 +70,7 @@
obj.MLIRCAPIIR
obj.MLIRCAPIInterfaces
obj.MLIRCAPIGPU
+ obj.MLIRCAPILLVM
obj.MLIRCAPILinalg
obj.MLIRCAPIPDL
obj.MLIRCAPITransforms
diff --git a/compiler/src/iree/compiler/API/api_exports.c b/compiler/src/iree/compiler/API/api_exports.c
index 4904c65..003b722 100644
--- a/compiler/src/iree/compiler/API/api_exports.c
+++ b/compiler/src/iree/compiler/API/api_exports.c
@@ -412,6 +412,50 @@
extern void mlirIntegerTypeUnsignedGet();
extern void mlirIsCurrentDebugType();
extern void mlirIsGlobalDebugEnabled();
+extern void mlirLLVMArrayTypeGet();
+extern void mlirLLVMCConvAttrGet();
+extern void mlirLLVMComdatAttrGet();
+extern void mlirLLVMDIBasicTypeAttrGet();
+extern void mlirLLVMDICompileUnitAttrGet();
+extern void mlirLLVMDICompositeTypeAttrGet();
+extern void mlirLLVMDIDerivedTypeAttrGet();
+extern void mlirLLVMDIDerivedTypeAttrGetBaseType();
+extern void mlirLLVMDIExpressionAttrGet();
+extern void mlirLLVMDIExpressionElemAttrGet();
+extern void mlirLLVMDIFileAttrGet();
+extern void mlirLLVMDIFlagsAttrGet();
+extern void mlirLLVMDILexicalBlockAttrGet();
+extern void mlirLLVMDILexicalBlockFileAttrGet();
+extern void mlirLLVMDILocalVariableAttrGet();
+extern void mlirLLVMDIModuleAttrGet();
+extern void mlirLLVMDIModuleAttrGetScope();
+extern void mlirLLVMDINullTypeAttrGet();
+extern void mlirLLVMDIStringTypeAttrGet();
+extern void mlirLLVMDISubprogramAttrGet();
+extern void mlirLLVMDISubprogramAttrGetCompileUnit();
+extern void mlirLLVMDISubprogramAttrGetFile();
+extern void mlirLLVMDISubprogramAttrGetLine();
+extern void mlirLLVMDISubprogramAttrGetScope();
+extern void mlirLLVMDISubprogramAttrGetScopeLine();
+extern void mlirLLVMDISubprogramAttrGetType();
+extern void mlirLLVMDISubroutineTypeAttrGet();
+extern void mlirLLVMFunctionTypeGet();
+extern void mlirLLVMLinkageAttrGet();
+extern void mlirLLVMPointerTypeGet();
+extern void mlirLLVMPointerTypeGetAddressSpace();
+extern void mlirLLVMStructTypeGetElementType();
+extern void mlirLLVMStructTypeGetIdentifier();
+extern void mlirLLVMStructTypeGetNumElementTypes();
+extern void mlirLLVMStructTypeIdentifiedGet();
+extern void mlirLLVMStructTypeIdentifiedNewGet();
+extern void mlirLLVMStructTypeIsLiteral();
+extern void mlirLLVMStructTypeIsOpaque();
+extern void mlirLLVMStructTypeIsPacked();
+extern void mlirLLVMStructTypeLiteralGet();
+extern void mlirLLVMStructTypeLiteralGetChecked();
+extern void mlirLLVMStructTypeOpaqueGet();
+extern void mlirLLVMStructTypeSetBody();
+extern void mlirLLVMVoidTypeGet();
extern void mlirLinalgFillBuiltinNamedOpRegion();
extern void mlirLlvmThreadPoolCreate();
extern void mlirLlvmThreadPoolDestroy();
@@ -657,6 +701,8 @@
extern void mlirTypeIsAFunction();
extern void mlirTypeIsAIndex();
extern void mlirTypeIsAInteger();
+extern void mlirTypeIsALLVMPointerType();
+extern void mlirTypeIsALLVMStructType();
extern void mlirTypeIsAMemRef();
extern void mlirTypeIsANone();
extern void mlirTypeIsAOpaque();
@@ -1126,6 +1172,50 @@
x += (uintptr_t)&mlirIntegerTypeUnsignedGet;
x += (uintptr_t)&mlirIsCurrentDebugType;
x += (uintptr_t)&mlirIsGlobalDebugEnabled;
+ x += (uintptr_t)&mlirLLVMArrayTypeGet;
+ x += (uintptr_t)&mlirLLVMCConvAttrGet;
+ x += (uintptr_t)&mlirLLVMComdatAttrGet;
+ x += (uintptr_t)&mlirLLVMDIBasicTypeAttrGet;
+ x += (uintptr_t)&mlirLLVMDICompileUnitAttrGet;
+ x += (uintptr_t)&mlirLLVMDICompositeTypeAttrGet;
+ x += (uintptr_t)&mlirLLVMDIDerivedTypeAttrGet;
+ x += (uintptr_t)&mlirLLVMDIDerivedTypeAttrGetBaseType;
+ x += (uintptr_t)&mlirLLVMDIExpressionAttrGet;
+ x += (uintptr_t)&mlirLLVMDIExpressionElemAttrGet;
+ x += (uintptr_t)&mlirLLVMDIFileAttrGet;
+ x += (uintptr_t)&mlirLLVMDIFlagsAttrGet;
+ x += (uintptr_t)&mlirLLVMDILexicalBlockAttrGet;
+ x += (uintptr_t)&mlirLLVMDILexicalBlockFileAttrGet;
+ x += (uintptr_t)&mlirLLVMDILocalVariableAttrGet;
+ x += (uintptr_t)&mlirLLVMDIModuleAttrGet;
+ x += (uintptr_t)&mlirLLVMDIModuleAttrGetScope;
+ x += (uintptr_t)&mlirLLVMDINullTypeAttrGet;
+ x += (uintptr_t)&mlirLLVMDIStringTypeAttrGet;
+ x += (uintptr_t)&mlirLLVMDISubprogramAttrGet;
+ x += (uintptr_t)&mlirLLVMDISubprogramAttrGetCompileUnit;
+ x += (uintptr_t)&mlirLLVMDISubprogramAttrGetFile;
+ x += (uintptr_t)&mlirLLVMDISubprogramAttrGetLine;
+ x += (uintptr_t)&mlirLLVMDISubprogramAttrGetScope;
+ x += (uintptr_t)&mlirLLVMDISubprogramAttrGetScopeLine;
+ x += (uintptr_t)&mlirLLVMDISubprogramAttrGetType;
+ x += (uintptr_t)&mlirLLVMDISubroutineTypeAttrGet;
+ x += (uintptr_t)&mlirLLVMFunctionTypeGet;
+ x += (uintptr_t)&mlirLLVMLinkageAttrGet;
+ x += (uintptr_t)&mlirLLVMPointerTypeGet;
+ x += (uintptr_t)&mlirLLVMPointerTypeGetAddressSpace;
+ x += (uintptr_t)&mlirLLVMStructTypeGetElementType;
+ x += (uintptr_t)&mlirLLVMStructTypeGetIdentifier;
+ x += (uintptr_t)&mlirLLVMStructTypeGetNumElementTypes;
+ x += (uintptr_t)&mlirLLVMStructTypeIdentifiedGet;
+ x += (uintptr_t)&mlirLLVMStructTypeIdentifiedNewGet;
+ x += (uintptr_t)&mlirLLVMStructTypeIsLiteral;
+ x += (uintptr_t)&mlirLLVMStructTypeIsOpaque;
+ x += (uintptr_t)&mlirLLVMStructTypeIsPacked;
+ x += (uintptr_t)&mlirLLVMStructTypeLiteralGet;
+ x += (uintptr_t)&mlirLLVMStructTypeLiteralGetChecked;
+ x += (uintptr_t)&mlirLLVMStructTypeOpaqueGet;
+ x += (uintptr_t)&mlirLLVMStructTypeSetBody;
+ x += (uintptr_t)&mlirLLVMVoidTypeGet;
x += (uintptr_t)&mlirLinalgFillBuiltinNamedOpRegion;
x += (uintptr_t)&mlirLlvmThreadPoolCreate;
x += (uintptr_t)&mlirLlvmThreadPoolDestroy;
@@ -1371,6 +1461,8 @@
x += (uintptr_t)&mlirTypeIsAFunction;
x += (uintptr_t)&mlirTypeIsAIndex;
x += (uintptr_t)&mlirTypeIsAInteger;
+ x += (uintptr_t)&mlirTypeIsALLVMPointerType;
+ x += (uintptr_t)&mlirTypeIsALLVMStructType;
x += (uintptr_t)&mlirTypeIsAMemRef;
x += (uintptr_t)&mlirTypeIsANone;
x += (uintptr_t)&mlirTypeIsAOpaque;
diff --git a/compiler/src/iree/compiler/API/api_exports.def b/compiler/src/iree/compiler/API/api_exports.def
index 0c104a7..d46dea5 100644
--- a/compiler/src/iree/compiler/API/api_exports.def
+++ b/compiler/src/iree/compiler/API/api_exports.def
@@ -404,6 +404,50 @@
mlirIntegerTypeUnsignedGet
mlirIsCurrentDebugType
mlirIsGlobalDebugEnabled
+ mlirLLVMArrayTypeGet
+ mlirLLVMCConvAttrGet
+ mlirLLVMComdatAttrGet
+ mlirLLVMDIBasicTypeAttrGet
+ mlirLLVMDICompileUnitAttrGet
+ mlirLLVMDICompositeTypeAttrGet
+ mlirLLVMDIDerivedTypeAttrGet
+ mlirLLVMDIDerivedTypeAttrGetBaseType
+ mlirLLVMDIExpressionAttrGet
+ mlirLLVMDIExpressionElemAttrGet
+ mlirLLVMDIFileAttrGet
+ mlirLLVMDIFlagsAttrGet
+ mlirLLVMDILexicalBlockAttrGet
+ mlirLLVMDILexicalBlockFileAttrGet
+ mlirLLVMDILocalVariableAttrGet
+ mlirLLVMDIModuleAttrGet
+ mlirLLVMDIModuleAttrGetScope
+ mlirLLVMDINullTypeAttrGet
+ mlirLLVMDIStringTypeAttrGet
+ mlirLLVMDISubprogramAttrGet
+ mlirLLVMDISubprogramAttrGetCompileUnit
+ mlirLLVMDISubprogramAttrGetFile
+ mlirLLVMDISubprogramAttrGetLine
+ mlirLLVMDISubprogramAttrGetScope
+ mlirLLVMDISubprogramAttrGetScopeLine
+ mlirLLVMDISubprogramAttrGetType
+ mlirLLVMDISubroutineTypeAttrGet
+ mlirLLVMFunctionTypeGet
+ mlirLLVMLinkageAttrGet
+ mlirLLVMPointerTypeGet
+ mlirLLVMPointerTypeGetAddressSpace
+ mlirLLVMStructTypeGetElementType
+ mlirLLVMStructTypeGetIdentifier
+ mlirLLVMStructTypeGetNumElementTypes
+ mlirLLVMStructTypeIdentifiedGet
+ mlirLLVMStructTypeIdentifiedNewGet
+ mlirLLVMStructTypeIsLiteral
+ mlirLLVMStructTypeIsOpaque
+ mlirLLVMStructTypeIsPacked
+ mlirLLVMStructTypeLiteralGet
+ mlirLLVMStructTypeLiteralGetChecked
+ mlirLLVMStructTypeOpaqueGet
+ mlirLLVMStructTypeSetBody
+ mlirLLVMVoidTypeGet
mlirLinalgFillBuiltinNamedOpRegion
mlirLlvmThreadPoolCreate
mlirLlvmThreadPoolDestroy
@@ -649,6 +693,8 @@
mlirTypeIsAFunction
mlirTypeIsAIndex
mlirTypeIsAInteger
+ mlirTypeIsALLVMPointerType
+ mlirTypeIsALLVMStructType
mlirTypeIsAMemRef
mlirTypeIsANone
mlirTypeIsAOpaque
diff --git a/compiler/src/iree/compiler/API/api_exports.ld b/compiler/src/iree/compiler/API/api_exports.ld
index f810a0b..a55db88 100644
--- a/compiler/src/iree/compiler/API/api_exports.ld
+++ b/compiler/src/iree/compiler/API/api_exports.ld
@@ -405,6 +405,50 @@
mlirIntegerTypeUnsignedGet;
mlirIsCurrentDebugType;
mlirIsGlobalDebugEnabled;
+ mlirLLVMArrayTypeGet;
+ mlirLLVMCConvAttrGet;
+ mlirLLVMComdatAttrGet;
+ mlirLLVMDIBasicTypeAttrGet;
+ mlirLLVMDICompileUnitAttrGet;
+ mlirLLVMDICompositeTypeAttrGet;
+ mlirLLVMDIDerivedTypeAttrGet;
+ mlirLLVMDIDerivedTypeAttrGetBaseType;
+ mlirLLVMDIExpressionAttrGet;
+ mlirLLVMDIExpressionElemAttrGet;
+ mlirLLVMDIFileAttrGet;
+ mlirLLVMDIFlagsAttrGet;
+ mlirLLVMDILexicalBlockAttrGet;
+ mlirLLVMDILexicalBlockFileAttrGet;
+ mlirLLVMDILocalVariableAttrGet;
+ mlirLLVMDIModuleAttrGet;
+ mlirLLVMDIModuleAttrGetScope;
+ mlirLLVMDINullTypeAttrGet;
+ mlirLLVMDIStringTypeAttrGet;
+ mlirLLVMDISubprogramAttrGet;
+ mlirLLVMDISubprogramAttrGetCompileUnit;
+ mlirLLVMDISubprogramAttrGetFile;
+ mlirLLVMDISubprogramAttrGetLine;
+ mlirLLVMDISubprogramAttrGetScope;
+ mlirLLVMDISubprogramAttrGetScopeLine;
+ mlirLLVMDISubprogramAttrGetType;
+ mlirLLVMDISubroutineTypeAttrGet;
+ mlirLLVMFunctionTypeGet;
+ mlirLLVMLinkageAttrGet;
+ mlirLLVMPointerTypeGet;
+ mlirLLVMPointerTypeGetAddressSpace;
+ mlirLLVMStructTypeGetElementType;
+ mlirLLVMStructTypeGetIdentifier;
+ mlirLLVMStructTypeGetNumElementTypes;
+ mlirLLVMStructTypeIdentifiedGet;
+ mlirLLVMStructTypeIdentifiedNewGet;
+ mlirLLVMStructTypeIsLiteral;
+ mlirLLVMStructTypeIsOpaque;
+ mlirLLVMStructTypeIsPacked;
+ mlirLLVMStructTypeLiteralGet;
+ mlirLLVMStructTypeLiteralGetChecked;
+ mlirLLVMStructTypeOpaqueGet;
+ mlirLLVMStructTypeSetBody;
+ mlirLLVMVoidTypeGet;
mlirLinalgFillBuiltinNamedOpRegion;
mlirLlvmThreadPoolCreate;
mlirLlvmThreadPoolDestroy;
@@ -650,6 +694,8 @@
mlirTypeIsAFunction;
mlirTypeIsAIndex;
mlirTypeIsAInteger;
+ mlirTypeIsALLVMPointerType;
+ mlirTypeIsALLVMStructType;
mlirTypeIsAMemRef;
mlirTypeIsANone;
mlirTypeIsAOpaque;
diff --git a/compiler/src/iree/compiler/API/api_exports.macos.lst b/compiler/src/iree/compiler/API/api_exports.macos.lst
index 8a47e30..1edb563 100644
--- a/compiler/src/iree/compiler/API/api_exports.macos.lst
+++ b/compiler/src/iree/compiler/API/api_exports.macos.lst
@@ -403,6 +403,50 @@
_mlirIntegerTypeUnsignedGet
_mlirIsCurrentDebugType
_mlirIsGlobalDebugEnabled
+_mlirLLVMArrayTypeGet
+_mlirLLVMCConvAttrGet
+_mlirLLVMComdatAttrGet
+_mlirLLVMDIBasicTypeAttrGet
+_mlirLLVMDICompileUnitAttrGet
+_mlirLLVMDICompositeTypeAttrGet
+_mlirLLVMDIDerivedTypeAttrGet
+_mlirLLVMDIDerivedTypeAttrGetBaseType
+_mlirLLVMDIExpressionAttrGet
+_mlirLLVMDIExpressionElemAttrGet
+_mlirLLVMDIFileAttrGet
+_mlirLLVMDIFlagsAttrGet
+_mlirLLVMDILexicalBlockAttrGet
+_mlirLLVMDILexicalBlockFileAttrGet
+_mlirLLVMDILocalVariableAttrGet
+_mlirLLVMDIModuleAttrGet
+_mlirLLVMDIModuleAttrGetScope
+_mlirLLVMDINullTypeAttrGet
+_mlirLLVMDIStringTypeAttrGet
+_mlirLLVMDISubprogramAttrGet
+_mlirLLVMDISubprogramAttrGetCompileUnit
+_mlirLLVMDISubprogramAttrGetFile
+_mlirLLVMDISubprogramAttrGetLine
+_mlirLLVMDISubprogramAttrGetScope
+_mlirLLVMDISubprogramAttrGetScopeLine
+_mlirLLVMDISubprogramAttrGetType
+_mlirLLVMDISubroutineTypeAttrGet
+_mlirLLVMFunctionTypeGet
+_mlirLLVMLinkageAttrGet
+_mlirLLVMPointerTypeGet
+_mlirLLVMPointerTypeGetAddressSpace
+_mlirLLVMStructTypeGetElementType
+_mlirLLVMStructTypeGetIdentifier
+_mlirLLVMStructTypeGetNumElementTypes
+_mlirLLVMStructTypeIdentifiedGet
+_mlirLLVMStructTypeIdentifiedNewGet
+_mlirLLVMStructTypeIsLiteral
+_mlirLLVMStructTypeIsOpaque
+_mlirLLVMStructTypeIsPacked
+_mlirLLVMStructTypeLiteralGet
+_mlirLLVMStructTypeLiteralGetChecked
+_mlirLLVMStructTypeOpaqueGet
+_mlirLLVMStructTypeSetBody
+_mlirLLVMVoidTypeGet
_mlirLinalgFillBuiltinNamedOpRegion
_mlirLlvmThreadPoolCreate
_mlirLlvmThreadPoolDestroy
@@ -648,6 +692,8 @@
_mlirTypeIsAFunction
_mlirTypeIsAIndex
_mlirTypeIsAInteger
+_mlirTypeIsALLVMPointerType
+_mlirTypeIsALLVMStructType
_mlirTypeIsAMemRef
_mlirTypeIsANone
_mlirTypeIsAOpaque
diff --git a/compiler/src/iree/compiler/API/generate_exports.py b/compiler/src/iree/compiler/API/generate_exports.py
index 68f1c43..d7d2cd5 100755
--- a/compiler/src/iree/compiler/API/generate_exports.py
+++ b/compiler/src/iree/compiler/API/generate_exports.py
@@ -61,6 +61,7 @@
"Transforms.h",
"Dialect/GPU.h",
"Dialect/Linalg.h",
+ "Dialect/LLVM.h",
"Dialect/Transform.h",
"Dialect/Transform/Interpreter.h",
"Dialect/PDL.h",