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/OpenMP/OpenMPDialect.h" 13 14 /// models for FIR pointer like types that already provide a `getElementType` or 15 /// a `getEleTy` method 16 17 template <typename T> 18 struct PointerLikeModel 19 : public mlir::omp::PointerLikeType::ExternalModel<PointerLikeModel<T>, T> { getElementTypePointerLikeModel20 mlir::Type getElementType(mlir::Type pointer) const { 21 return pointer.cast<T>().getElementType(); 22 } 23 }; 24 25 template <typename T> 26 struct AlternativePointerLikeModel 27 : public mlir::omp::PointerLikeType::ExternalModel< 28 AlternativePointerLikeModel<T>, T> { getElementTypeAlternativePointerLikeModel29 mlir::Type getElementType(mlir::Type pointer) const { 30 return pointer.cast<T>().getEleTy(); 31 } 32 }; 33 34 #endif // FORTRAN_TOOLS_POINTER_MODELS_H 35