FLANG
Coarray.h
1//===-- Coarray.h -- generate Coarray intrinsics runtime calls --*- 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_OPTIMIZER_BUILDER_RUNTIME_COARRAY_H
10#define FORTRAN_OPTIMIZER_BUILDER_RUNTIME_COARRAY_H
11
12#include "flang/Lower/AbstractConverter.h"
13#include "flang/Optimizer/Support/InternalNames.h"
14#include "mlir/Dialect/Func/IR/FuncOps.h"
15
16namespace fir {
17class ExtendedValue;
18class FirOpBuilder;
19} // namespace fir
20
21namespace fir::runtime {
22
23// Get the function type for a prif subroutine with a variable number of
24// arguments
25#define PRIF_FUNCTYPE(...) \
26 mlir::FunctionType::get(builder.getContext(), /*inputs*/ {__VA_ARGS__}, \
27 /*result*/ {})
28
29// Default prefix for subroutines of PRIF compiled with LLVM
30#define PRIFNAME_SUB(fmt) \
31 []() { \
32 std::ostringstream oss; \
33 oss << "prif_" << fmt; \
34 return fir::NameUniquer::doProcedure({"prif"}, {}, oss.str()); \
35 }()
36
37#define PRIF_STAT_TYPE builder.getRefType(builder.getI32Type())
38#define PRIF_ERRMSG_TYPE \
39 fir::BoxType::get(fir::CharacterType::get(builder.getContext(), 1, \
40 fir::CharacterType::unknownLen()))
41
43mlir::Value genInitCoarray(fir::FirOpBuilder &builder, mlir::Location loc);
44
46mlir::Value getNumImages(fir::FirOpBuilder &builder, mlir::Location loc);
47
50mlir::Value getNumImagesWithTeam(fir::FirOpBuilder &builder, mlir::Location loc,
51 mlir::Value team);
52
54mlir::Value getThisImage(fir::FirOpBuilder &builder, mlir::Location loc,
55 mlir::Value team = {});
56
58void genCoBroadcast(fir::FirOpBuilder &builder, mlir::Location loc,
59 mlir::Value A, mlir::Value sourceImage, mlir::Value stat,
60 mlir::Value errmsg);
61
63void genCoMax(fir::FirOpBuilder &builder, mlir::Location loc, mlir::Value A,
64 mlir::Value resultImage, mlir::Value stat, mlir::Value errmsg);
65
67void genCoMin(fir::FirOpBuilder &builder, mlir::Location loc, mlir::Value A,
68 mlir::Value resultImage, mlir::Value stat, mlir::Value errmsg);
69
71void genCoSum(fir::FirOpBuilder &builder, mlir::Location loc, mlir::Value A,
72 mlir::Value resultImage, mlir::Value stat, mlir::Value errmsg);
73
75void genSyncAllStatement(fir::FirOpBuilder &builder, mlir::Location loc,
76 mlir::Value stat, mlir::Value errmsg);
78void genSyncMemoryStatement(fir::FirOpBuilder &builder, mlir::Location loc,
79 mlir::Value stat, mlir::Value errmsg);
81void genSyncImagesStatement(fir::FirOpBuilder &builder, mlir::Location loc,
82 mlir::Value imageSet, mlir::Value stat,
83 mlir::Value errmsg);
84} // namespace fir::runtime
85#endif // FORTRAN_OPTIMIZER_BUILDER_RUNTIME_COARRAY_H
Definition BoxValue.h:478
Definition FIRBuilder.h:55
Definition AbstractConverter.h:34