1 //===- DialectHandle.cpp - C Interface for MLIR Dialect Operations -------===// 2 // 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 6 // 7 //===----------------------------------------------------------------------===// 8 9 #include "mlir/CAPI/Registration.h" 10 11 static inline const MlirDialectRegistrationHooks * 12 unwrap(MlirDialectHandle handle) { 13 return (const MlirDialectRegistrationHooks *)handle.ptr; 14 } 15 16 MlirStringRef mlirDialectHandleGetNamespace(MlirDialectHandle handle) { 17 return unwrap(handle)->getNamespaceHook(); 18 } 19 20 void mlirDialectHandleRegisterDialect(MlirDialectHandle handle, 21 MlirContext ctx) { 22 unwrap(handle)->registerHook(ctx); 23 } 24 25 MlirDialect mlirDialectHandleLoadDialect(MlirDialectHandle handle, 26 MlirContext ctx) { 27 return unwrap(handle)->loadHook(ctx); 28 } 29