xref: /llvm-project/flang/include/flang/Tools/PointerModels.h (revision fac349a169976f822fb27f03e623fa0d28aec1f3)
1 //===-- Tools/PointerModels.h --------------------- *-C++-*-===//
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 #ifndef FORTRAN_TOOLS_POINTER_MODELS_H
10 #define FORTRAN_TOOLS_POINTER_MODELS_H
11 
12 #include "mlir/Dialect/OpenACC/OpenACC.h"
13 #include "mlir/Dialect/OpenMP/OpenMPDialect.h"
14 
15 /// models for FIR pointer like types that already provide a `getElementType`
16 /// method
17 
18 template <typename T>
19 struct OpenMPPointerLikeModel
20     : public mlir::omp::PointerLikeType::ExternalModel<
21           OpenMPPointerLikeModel<T>, T> {
getElementTypeOpenMPPointerLikeModel22   mlir::Type getElementType(mlir::Type pointer) const {
23     return mlir::cast<T>(pointer).getElementType();
24   }
25 };
26 
27 template <typename T>
28 struct OpenACCPointerLikeModel
29     : public mlir::acc::PointerLikeType::ExternalModel<
30           OpenACCPointerLikeModel<T>, T> {
getElementTypeOpenACCPointerLikeModel31   mlir::Type getElementType(mlir::Type pointer) const {
32     return mlir::cast<T>(pointer).getElementType();
33   }
34 };
35 
36 #endif // FORTRAN_TOOLS_POINTER_MODELS_H
37