| 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 | |
| 9 | #include "mlir/Dialect/OpenACC/Extensions/GPUInterfaces.h" |
| 10 | #include "mlir/Dialect/GPU/IR/GPUDialect.h" |
| 11 | #include "mlir/Dialect/OpenACC/OpenACC.h" |
| 12 | #include "mlir/IR/DialectRegistry.h" |
| 13 | |
| 14 | using namespace mlir; |
| 15 | using namespace mlir::acc; |
| 16 | |
| 17 | namespace { |
| 18 | struct GPULaunchOffloadRegionModel |
| 19 | : public acc::OffloadRegionOpInterface::ExternalModel< |
| 20 | GPULaunchOffloadRegionModel, gpu::LaunchOp> { |
| 21 | mlir::Region &getOffloadRegion(mlir::Operation *op) const { |
| 22 | return cast<gpu::LaunchOp>(Val: op).getBody(); |
| 23 | } |
| 24 | }; |
| 25 | } // namespace |
| 26 | |
| 27 | void mlir::acc::registerGPUInterfaces(DialectRegistry ®istry) { |
| 28 | registry.addExtension( |
| 29 | extensionFn: +[](MLIRContext *ctx, OpenACCDialect *, gpu::GPUDialect *) { |
| 30 | gpu::LaunchOp::attachInterface<GPULaunchOffloadRegionModel>(context&: *ctx); |
| 31 | }); |
| 32 | } |
| 33 |