FLANG
OpenMP-utils.h
1//===-- include/flang/Common/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_COMMON_OPENMP_UTILS_H_
10#define FORTRAN_COMMON_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 llvm::ArrayRef<mlir::Value> hostEvalVars;
38 EntryBlockArgsEntry inReduction;
41 EntryBlockArgsEntry reduction;
42 EntryBlockArgsEntry taskReduction;
43 EntryBlockArgsEntry useDeviceAddr;
44 EntryBlockArgsEntry useDevicePtr;
45
46 bool isValid() const {
47 return inReduction.isValid() && map.isValid() && priv.isValid() &&
48 reduction.isValid() && taskReduction.isValid() &&
49 useDeviceAddr.isValid() && useDevicePtr.isValid();
50 }
51
52 auto getSyms() const {
53 return llvm::concat<const semantics::Symbol *const>(inReduction.syms,
54 map.syms, priv.syms, reduction.syms, taskReduction.syms,
55 useDeviceAddr.syms, useDevicePtr.syms);
56 }
57
58 auto getVars() const {
59 return llvm::concat<const mlir::Value>(hostEvalVars, inReduction.vars,
60 map.vars, priv.vars, reduction.vars, taskReduction.vars,
61 useDeviceAddr.vars, useDevicePtr.vars);
62 }
63};
64
72mlir::Block *genEntryBlock(
73 mlir::OpBuilder &builder, const EntryBlockArgs &args, mlir::Region &region);
74} // namespace Fortran::common::openmp
75
76#endif // FORTRAN_COMMON_OPENMP_UTILS_H_
Definition: FIRType.h:77
Definition: OpenMP-utils.h:36