xref: /llvm-project/mlir/examples/standalone/test/python/smoketest.py (revision 392622d0848b2d0da951d3a4da6fb390a83f812b)
1# RUN: %python %s pybind11 | FileCheck %s
2# RUN: %python %s nanobind | FileCheck %s
3
4import sys
5from mlir_standalone.ir import *
6from mlir_standalone.dialects import builtin as builtin_d
7
8if sys.argv[1] == "pybind11":
9    from mlir_standalone.dialects import standalone_pybind11 as standalone_d
10elif sys.argv[1] == "nanobind":
11    from mlir_standalone.dialects import standalone_nanobind as standalone_d
12else:
13    raise ValueError("Expected either pybind11 or nanobind as arguments")
14
15
16with Context():
17    standalone_d.register_dialect()
18    module = Module.parse(
19        """
20    %0 = arith.constant 2 : i32
21    %1 = standalone.foo %0 : i32
22    """
23    )
24    # CHECK: %[[C:.*]] = arith.constant 2 : i32
25    # CHECK: standalone.foo %[[C]] : i32
26    print(str(module))
27