blob: 0c42c2d4084f194e63ced4235ad3b34b869075a7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
# RUN: %PYTHON %s | FileCheck %s
from mlir.ir import *
import mlir.dialects.emitc as emitc
def run(f):
print("\nTEST:", f.__name__)
with Context() as ctx, Location.unknown():
module = Module.create()
with InsertionPoint(module.body):
f(ctx)
print(module)
# CHECK-LABEL: TEST: testConstantOp
@run
def testConstantOp(ctx):
i32 = IntegerType.get_signless(32)
a = emitc.ConstantOp(result=i32, value=IntegerAttr.get(i32, 42))
# CHECK: %{{.*}} = "emitc.constant"() <{value = 42 : i32}> : () -> i32
# CHECK-LABEL: TEST: testAddOp
@run
def testAddOp(ctx):
i32 = IntegerType.get_signless(32)
lhs = emitc.ConstantOp(result=i32, value=IntegerAttr.get(i32, 0))
rhs = emitc.ConstantOp(result=i32, value=IntegerAttr.get(i32, 0))
a = emitc.AddOp(i32, lhs, rhs)
# CHECK: %{{.*}} = emitc.add %{{.*}}, %{{.*}} : (i32, i32) -> i32
|