MLIR 24.0.0git
GPUInterfaces.cpp
Go to the documentation of this file.
1//===- GPUInterfaces.cpp - OpenACC external models ------------------------===//
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
13
14using namespace mlir;
15using namespace mlir::acc;
16
17namespace {
18struct GPULaunchOffloadRegionModel
19 : public acc::OffloadRegionOpInterface::ExternalModel<
20 GPULaunchOffloadRegionModel, gpu::LaunchOp> {
21 mlir::Region &getOffloadRegion(mlir::Operation *op) const {
22 return cast<gpu::LaunchOp>(op).getBody();
23 }
24};
25} // namespace
26
28 registry.addExtension(
29 +[](MLIRContext *ctx, OpenACCDialect *, gpu::GPUDialect *) {
30 gpu::LaunchOp::attachInterface<GPULaunchOffloadRegionModel>(*ctx);
31 });
32}
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
void registerGPUInterfaces(DialectRegistry &registry)
Register OpenACC interfaces for GPU IR. This does not load dialects.
Include the generated interface declarations.