clang 23.0.0git
RegisterOpenMPExtensions.cpp
Go to the documentation of this file.
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
14#include "mlir/Dialect/OpenMP/OpenMPDialect.h"
15#include "mlir/Dialect/OpenMP/OpenMPInterfaces.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>(pointer).getPointee();
25 }
26};
27} // namespace
28
29namespace cir::omp {
30
31void registerOpenMPExtensions(mlir::DialectRegistry &registry) {
32 registry.addExtension(+[](mlir::MLIRContext *ctx, cir::CIRDialect *dialect) {
33 cir::FuncOp::attachInterface<
34 mlir::omp::DeclareTargetDefaultModel<cir::FuncOp>>(*ctx);
35 cir::PointerType::attachInterface<OpenMPPointerLikeModel>(*ctx);
36 });
37}
38
39} // namespace cir::omp
void registerOpenMPExtensions(mlir::DialectRegistry &registry)