1 //===- irdl.c - Test for the C bindings for IRDL registration -------------===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM
5 // See https://llvm.org/LICENSE.txt for license information.
6 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
8 //===----------------------------------------------------------------------===//
10 /* RUN: mlir-capi-irdl-test 2>&1 | FileCheck %s
13 #include "mlir-c/Dialect/IRDL.h"
14 #include "mlir-c/IR.h"
16 const char irdlDialect
[] = "\
31 // CHECK-NEXT: %[[RES:.*]] = "foo.op"() : () -> i32
32 // CHECK-NEXT: "bar.op"(%[[RES]]) : (i32) -> ()
34 const char newDialectUsage
[] = "\
36 %res = \"foo.op\"() : () -> i32\
37 \"bar.op\"(%res) : (i32) -> ()\
41 MlirContext ctx
= mlirContextCreate();
42 mlirDialectHandleLoadDialect(mlirGetDialectHandle__irdl__(), ctx
);
44 MlirModule dialectDecl
=
45 mlirModuleCreateParse(ctx
, mlirStringRefCreateFromCString(irdlDialect
));
47 mlirLoadIRDLDialects(dialectDecl
);
48 mlirModuleDestroy(dialectDecl
);
50 MlirModule usingModule
= mlirModuleCreateParse(
51 ctx
, mlirStringRefCreateFromCString(newDialectUsage
));
53 mlirOperationDump(mlirModuleGetOperation(usingModule
));
55 mlirModuleDestroy(usingModule
);
56 mlirContextDestroy(ctx
);