1//===----------------------------------------------------------------------===//
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// Registration for OpenMP extensions as applied to CIR dialect.
10//
11//===----------------------------------------------------------------------===//
12
13#include "clang/CIR/Dialect/OpenMP/RegisterOpenMPExtensions.h"
14#include "mlir/Dialect/OpenMP/OpenMPDialect.h"
15#include "mlir/Dialect/OpenMP/OpenMPInterfaces.h"
16#include "clang/CIR/Dialect/IR/CIRDialect.h"
17#include "clang/CIR/Dialect/IR/CIRTypes.h"
18
19namespace {
20struct OpenMPPointerLikeModel
21 : public mlir::omp::PointerLikeType::ExternalModel<OpenMPPointerLikeModel,
22 cir::PointerType> {
23 mlir::Type getElementType(mlir::Type pointer) const {
24 return mlir::cast<cir::PointerType>(Val&: pointer).getPointee();
25 }
26};
27} // namespace
28
29namespace cir::omp {
30
31void registerOpenMPExtensions(mlir::DialectRegistry &registry) {
32 registry.addExtension(extensionFn: +[](mlir::MLIRContext *ctx, cir::CIRDialect *dialect) {
33 cir::FuncOp::attachInterface<
34 mlir::omp::DeclareTargetDefaultModel<cir::FuncOp>>(context&: *ctx);
35 cir::PointerType::attachInterface<OpenMPPointerLikeModel>(context&: *ctx);
36 });
37}
38
39} // namespace cir::omp
40