xref: /llvm-project/mlir/test/python/dialects/arith_llvm.py (revision 8934b10642664c0824f45f115b2a0afcb56a5e5f)
1# RUN: %PYTHON %s | FileCheck %s
2from functools import partialmethod
3
4from mlir.ir import *
5import mlir.dialects.arith as arith
6import mlir.dialects.func as func
7import mlir.dialects.llvm as llvm
8
9
10def run(f):
11    print("\nTEST:", f.__name__)
12    f()
13
14
15# CHECK-LABEL: TEST: testOverflowFlags
16# Test mostly to repro and verify error addressed for Python bindings.
17@run
18def testOverflowFlags():
19    with Context() as ctx, Location.unknown():
20        module = Module.create()
21        with InsertionPoint(module.body):
22            a = arith.ConstantOp(value=42, result=IntegerType.get_signless(32))
23            r = arith.AddIOp(a, a, overflowFlags=arith.IntegerOverflowFlags.nsw)
24            # CHECK: arith.addi {{.*}}, {{.*}} overflow<nsw> : i32
25            print(r)
26