FLANG
OpenMP-utils.h
1//===-- include/flang/Support/OpenMP-utils.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_SUPPORT_OPENMP_UTILS_H_
10#define FORTRAN_SUPPORT_OPENMP_UTILS_H_
11
12#include "flang/Semantics/symbol.h"
13
14#include "mlir/IR/Builders.h"
15#include "mlir/IR/Value.h"
16
17#include "llvm/ADT/ArrayRef.h"
18
19namespace Fortran::common::openmp {
25
26 bool isValid() const {
27 // This check allows specifying a smaller number of symbols than values
28 // because in some case cases a single symbol generates multiple block
29 // arguments.
30 return syms.size() <= vars.size();
31 }
32};
33
37 EntryBlockArgsEntry hasDeviceAddr;
38 llvm::ArrayRef<mlir::Value> hostEvalVars;
39 EntryBlockArgsEntry inReduction;
42 EntryBlockArgsEntry reduction;
43 EntryBlockArgsEntry taskReduction;
44 EntryBlockArgsEntry useDeviceAddr;
45 EntryBlockArgsEntry useDevicePtr;
46
47 bool isValid() const {
48 return hasDeviceAddr.isValid() && inReduction.isValid() && map.isValid() &&
49 priv.isValid() && reduction.isValid() && taskReduction.isValid() &&
50 useDeviceAddr.isValid() && useDevicePtr.isValid();
51 }
52
53 auto getSyms() const {
54 return llvm::concat<const semantics::Symbol *const>(hasDeviceAddr.syms,
55 inReduction.syms, map.syms, priv.syms, reduction.syms,
56 taskReduction.syms, useDeviceAddr.syms, useDevicePtr.syms);
57 }
58
59 auto getVars() const {
60 return llvm::concat<const mlir::Value>(hasDeviceAddr.vars, hostEvalVars,
61 inReduction.vars, map.vars, priv.vars, reduction.vars,
62 taskReduction.vars, useDeviceAddr.vars, useDevicePtr.vars);
63 }
64};
65
73mlir::Block *genEntryBlock(
74 mlir::OpBuilder &builder, const EntryBlockArgs &args, mlir::Region &region);
75} // namespace Fortran::common::openmp
76
77#endif // FORTRAN_SUPPORT_OPENMP_UTILS_H_
Definition FIRType.h:89
Definition OpenMP-utils.h:36