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