MLIR 24.0.0git
OpenACC.cpp
Go to the documentation of this file.
1//===- OpenACC.cpp - C Interface for OpenACC dialect ----------------------===//
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
14
15using namespace mlir;
16using namespace mlir::acc;
17
18namespace {
19// Keep the C API's complete registration behavior. Frontends that only need
20// OpenACC IR can link MLIROpenACCDialect directly instead.
21void registerOpenACC(DialectRegistry &registry) {
22 registry.insert<OpenACCDialect, gpu::GPUDialect>();
24 registry.addExtension(+[](MLIRContext *context, OpenACCDialect *) {
25 context->getOrLoadDialect<gpu::GPUDialect>();
26 });
27}
28
29void insertOpenACC(MlirDialectRegistry registry) {
30 registerOpenACC(*unwrap(registry));
31}
32
33MlirDialect loadOpenACC(MlirContext context) {
34 DialectRegistry registry;
35 registerOpenACC(registry);
36 unwrap(context)->appendDialectRegistry(registry);
37 return wrap(unwrap(context)->getOrLoadDialect<OpenACCDialect>());
38}
39
40MlirStringRef getNamespace() {
41 return wrap(OpenACCDialect::getDialectNamespace());
42}
43} // namespace
44
46 static MlirDialectRegistrationHooks hooks = {insertOpenACC, loadOpenACC,
47 getNamespace};
48 return MlirDialectHandle{&hooks};
49}
MlirDialectHandle mlirGetDialectHandle__acc__()
Definition OpenACC.cpp:45
The DialectRegistry maps a dialect namespace to a constructor for the matching dialect.
bool addExtension(TypeID extensionID, std::unique_ptr< DialectExtensionBase > extension)
Add the given extension to the registry.
MLIRContext is the top-level object for a collection of MLIR operations.
Definition MLIRContext.h:64
T * getOrLoadDialect()
Get (or create) a dialect for the given derived dialect type.
MlirDiagnostic wrap(mlir::Diagnostic &diagnostic)
Definition Diagnostics.h:24
mlir::Diagnostic & unwrap(MlirDiagnostic diagnostic)
Definition Diagnostics.h:19
void registerAllExtensions(DialectRegistry &registry)
Register the standard OpenACC models for GPU, LLVM and MemRef IR.
Include the generated interface declarations.
Structure of dialect registration hooks.
A pointer to a sized fragment of a string, not necessarily null-terminated.
Definition Support.h:78