1 //===- DialectHandle.cpp - C Interface for MLIR Dialect Operations -------===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 #include "mlir/CAPI/Registration.h"
11 static inline const MlirDialectRegistrationHooks
*
12 unwrap(MlirDialectHandle handle
) {
13 return (const MlirDialectRegistrationHooks
*)handle
.ptr
;
16 MlirStringRef
mlirDialectHandleGetNamespace(MlirDialectHandle handle
) {
17 return unwrap(handle
)->getNamespaceHook();
20 void mlirDialectHandleInsertDialect(MlirDialectHandle handle
,
21 MlirDialectRegistry registry
) {
22 unwrap(handle
)->insertHook(registry
);
25 void mlirDialectHandleRegisterDialect(MlirDialectHandle handle
,
27 mlir::DialectRegistry registry
;
28 mlirDialectHandleInsertDialect(handle
, wrap(®istry
));
29 unwrap(ctx
)->appendDialectRegistry(registry
);
32 MlirDialect
mlirDialectHandleLoadDialect(MlirDialectHandle handle
,
34 return unwrap(handle
)->loadHook(ctx
);