brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.6 KiB · e343bbc Raw
70 lines · cpp
1//===-- FIROpenMPAttributes.cpp -------------------------------------------===//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-exception6//7//===----------------------------------------------------------------------===//8/// \file9/// This file implements attribute interfaces that are promised by FIR10/// dialect attributes related to OpenMP.11//===----------------------------------------------------------------------===//12 13#include "flang/Optimizer/Builder/FIRBuilder.h"14#include "flang/Optimizer/Builder/Todo.h"15#include "flang/Optimizer/Dialect/FIRAttr.h"16#include "flang/Optimizer/Dialect/FIRDialect.h"17#include "mlir/Dialect/OpenMP/OpenMPDialect.h"18 19namespace fir::omp {20class FortranSafeTempArrayCopyAttrImpl21    : public fir::SafeTempArrayCopyAttrInterface::FallbackModel<22          FortranSafeTempArrayCopyAttrImpl> {23public:24  // SafeTempArrayCopyAttrInterface interface methods.25  static bool isDynamicallySafe() { return false; }26 27  static mlir::Value genDynamicCheck(mlir::Location loc,28                                     fir::FirOpBuilder &builder,29                                     mlir::Value array) {30    TODO(loc, "fir::omp::FortranSafeTempArrayCopyAttrImpl::genDynamicCheck()");31    return nullptr;32  }33 34  static void registerTempDeallocation(mlir::Location loc,35                                       fir::FirOpBuilder &builder,36                                       mlir::Value array, mlir::Value temp) {37    TODO(loc, "fir::omp::FortranSafeTempArrayCopyAttrImpl::"38              "registerTempDeallocation()");39  }40 41  // Extra helper methods.42 43  /// Attach the implementation to fir::OpenMPSafeTempArrayCopyAttr.44  static void registerExternalModel(mlir::DialectRegistry &registry);45 46  /// If the methods above create any new operations, this method47  /// must register all the corresponding dialect.48  static void getDependentDialects(mlir::DialectRegistry &registry) {}49};50 51void FortranSafeTempArrayCopyAttrImpl::registerExternalModel(52    mlir::DialectRegistry &registry) {53  registry.addExtension(54      +[](mlir::MLIRContext *ctx, fir::FIROpsDialect *dialect) {55        fir::OpenMPSafeTempArrayCopyAttr::attachInterface<56            FortranSafeTempArrayCopyAttrImpl>(*ctx);57      });58}59 60void registerAttrsExtensions(mlir::DialectRegistry &registry) {61  FortranSafeTempArrayCopyAttrImpl::registerExternalModel(registry);62}63 64void registerTransformationalAttrsDependentDialects(65    mlir::DialectRegistry &registry) {66  FortranSafeTempArrayCopyAttrImpl::getDependentDialects(registry);67}68 69} // namespace fir::omp70