mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-30 04:16:08 +00:00

Replace MlirDialectRegistrationHooks with MlirDialectHandle, which under-the-hood is an opaque pointer to MlirDialectRegistrationHooks. Then we expose the functionality previously directly on MlirDialectRegistrationHooks, as functions which take the opaque MlirDialectHandle struct. This makes the actual structure of the registration hooks an implementation detail, and happens to avoid this issue: https://llvm.discourse.group/t/strange-swift-issues-with-dialect-registration-hooks/2759/3 Reviewed By: stellaraccident Differential Revision: https://reviews.llvm.org/D96229
29 lines
1004 B
C++
29 lines
1004 B
C++
//===- DialectHandle.cpp - C Interface for MLIR Dialect Operations -------===//
|
|
//
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#include "mlir/CAPI/Registration.h"
|
|
|
|
static inline const MlirDialectRegistrationHooks *
|
|
unwrap(MlirDialectHandle handle) {
|
|
return (const MlirDialectRegistrationHooks *)handle.ptr;
|
|
}
|
|
|
|
MlirStringRef mlirDialectHandleGetNamespace(MlirDialectHandle handle) {
|
|
return unwrap(handle)->getNamespaceHook();
|
|
}
|
|
|
|
void mlirDialectHandleRegisterDialect(MlirDialectHandle handle,
|
|
MlirContext ctx) {
|
|
unwrap(handle)->registerHook(ctx);
|
|
}
|
|
|
|
MlirDialect mlirDialectHandleLoadDialect(MlirDialectHandle handle,
|
|
MlirContext ctx) {
|
|
return unwrap(handle)->loadHook(ctx);
|
|
}
|