brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.3 KiB · 19f64d9 Raw
36 lines · cpp
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-exception6//7//===----------------------------------------------------------------------===//8 9#include "mlir/CAPI/Registration.h"10 11static inline const MlirDialectRegistrationHooks *12unwrap(MlirDialectHandle handle) {13  return (const MlirDialectRegistrationHooks *)handle.ptr;14}15 16MlirStringRef mlirDialectHandleGetNamespace(MlirDialectHandle handle) {17  return unwrap(handle)->getNamespaceHook();18}19 20void mlirDialectHandleInsertDialect(MlirDialectHandle handle,21                                    MlirDialectRegistry registry) {22  unwrap(handle)->insertHook(registry);23}24 25void mlirDialectHandleRegisterDialect(MlirDialectHandle handle,26                                      MlirContext ctx) {27  mlir::DialectRegistry registry;28  mlirDialectHandleInsertDialect(handle, wrap(&registry));29  unwrap(ctx)->appendDialectRegistry(registry);30}31 32MlirDialect mlirDialectHandleLoadDialect(MlirDialectHandle handle,33                                         MlirContext ctx) {34  return unwrap(handle)->loadHook(ctx);35}36