[Mlir-commits] [mlir] [mlir][python] Enable python bindings for Index dialect (PR #85827)
Steven Varoumas
llvmlistbot at llvm.org
Tue Mar 19 11:03:04 PDT 2024
================
@@ -0,0 +1,335 @@
+# RUN: %PYTHON %s | FileCheck %s
+
+from mlir.ir import *
+from mlir.dialects import index, arith
+
+
+def run(f):
+ print("\nTEST:", f.__name__)
+ f()
+
+
+# CHECK-LABEL: TEST: testConstantOp
+ at run
+def testConstantOp():
+ with Context() as ctx, Location.unknown():
+ module = Module.create()
+ with InsertionPoint(module.body):
+ a = index.ConstantOp(value=42)
+ # CHECK: %[[A:.*]] = index.constant 42
+ print(module)
+
+
+# CHECK-LABEL: TEST: testBoolConstantOp
+ at run
+def testBoolConstantOp():
+ with Context() as ctx, Location.unknown():
+ module = Module.create()
+ with InsertionPoint(module.body):
+ a = index.BoolConstantOp(value=True)
+ # CHECK: %[[A:.*]] = index.bool.constant true
+ print(module)
+
+
+# CHECK-LABEL: TEST: testAndOp
+ at run
+def testAndOp():
+ with Context() as ctx, Location.unknown():
+ module = Module.create()
+ with InsertionPoint(module.body):
+ a = index.ConstantOp(value=42)
+ r = index.AndOp(a, a)
+ # CHECK: %[[R:.*]] = index.and {{.*}}, {{.*}}
+ print(module)
+
+
+# CHECK-LABEL: TEST: testOrOp
+ at run
+def testOrOp():
+ with Context() as ctx, Location.unknown():
+ module = Module.create()
+ with InsertionPoint(module.body):
----------------
stevenvar wrote:
Surely! Thank you for the suggestion
https://github.com/llvm/llvm-project/pull/85827
More information about the Mlir-commits
mailing list