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)
@run
def testConstantOp(ctx):
i32 = IntegerType.get_signless(32)
a = emitc.ConstantOp(result=i32, value=IntegerAttr.get(i32, 42))
@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)