FLANG
Intrinsics.h
1// Builder/Runtime/Intrinsics.h Fortran runtime codegen interface -*- 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// Builder routines for constructing the FIR dialect of MLIR. As FIR is a
10// dialect of MLIR, it makes extensive use of MLIR interfaces and MLIR's coding
11// style (https://mlir.llvm.org/getting_started/DeveloperGuide/) is used in this
12// module.
13//
14//===----------------------------------------------------------------------===//
15
16#ifndef FORTRAN_LOWER_RUNTIME_H
17#define FORTRAN_LOWER_RUNTIME_H
18
19#include <optional>
20
21namespace mlir {
22class Location;
23class Type;
24class Value;
25} // namespace mlir
26
27namespace fir {
28class CharBoxValue;
29class FirOpBuilder;
30
31namespace runtime {
32
33mlir::Value genAssociated(fir::FirOpBuilder &, mlir::Location,
34 mlir::Value pointer, mlir::Value target);
35
36void genPointerAssociate(fir::FirOpBuilder &, mlir::Location,
37 mlir::Value pointer, mlir::Value target);
38void genPointerAssociateRemapping(fir::FirOpBuilder &, mlir::Location,
39 mlir::Value pointer, mlir::Value target,
40 mlir::Value bounds, bool isMonomorphic);
41
42mlir::Value genCpuTime(fir::FirOpBuilder &, mlir::Location);
43void genDateAndTime(fir::FirOpBuilder &, mlir::Location,
44 std::optional<fir::CharBoxValue> date,
45 std::optional<fir::CharBoxValue> time,
46 std::optional<fir::CharBoxValue> zone, mlir::Value values);
47
48mlir::Value genDsecnds(fir::FirOpBuilder &builder, mlir::Location loc,
49 mlir::Value refTime);
50
51void genEtime(fir::FirOpBuilder &builder, mlir::Location loc,
52 mlir::Value values, mlir::Value time);
53
54void genFlush(fir::FirOpBuilder &builder, mlir::Location loc, mlir::Value unit);
55
56void genFree(fir::FirOpBuilder &builder, mlir::Location loc, mlir::Value ptr);
57
58mlir::Value genFseek(fir::FirOpBuilder &builder, mlir::Location loc,
59 mlir::Value unit, mlir::Value offset, mlir::Value whence);
60mlir::Value genFtell(fir::FirOpBuilder &builder, mlir::Location loc,
61 mlir::Value unit);
62
63mlir::Value genGetUID(fir::FirOpBuilder &, mlir::Location);
64mlir::Value genGetGID(fir::FirOpBuilder &, mlir::Location);
65
66mlir::Value genMalloc(fir::FirOpBuilder &builder, mlir::Location loc,
67 mlir::Value size);
68
69void genRandomInit(fir::FirOpBuilder &, mlir::Location, mlir::Value repeatable,
70 mlir::Value imageDistinct);
71void genRandomNumber(fir::FirOpBuilder &, mlir::Location, mlir::Value harvest);
72void genRandomSeed(fir::FirOpBuilder &, mlir::Location, mlir::Value size,
73 mlir::Value put, mlir::Value get);
74
76void genRename(fir::FirOpBuilder &builder, mlir::Location loc,
77 mlir::Value path1, mlir::Value path2, mlir::Value status);
78
79mlir::Value genSecnds(fir::FirOpBuilder &builder, mlir::Location loc,
80 mlir::Value refTime);
81
83mlir::Value genTime(fir::FirOpBuilder &builder, mlir::Location loc);
84
86void genTransfer(fir::FirOpBuilder &builder, mlir::Location loc,
87 mlir::Value resultBox, mlir::Value sourceBox,
88 mlir::Value moldBox);
89
91void genTransferSize(fir::FirOpBuilder &builder, mlir::Location loc,
92 mlir::Value resultBox, mlir::Value sourceBox,
93 mlir::Value moldBox, mlir::Value size);
94
97void genSystemClock(fir::FirOpBuilder &, mlir::Location, mlir::Value count,
98 mlir::Value rate, mlir::Value max);
99
100// generate signal runtime call
101// CALL SIGNAL(NUMBER, HANDLER [, STATUS])
102// status can be {} or a value. It may also be dynamically absent
103void genSignal(fir::FirOpBuilder &builder, mlir::Location loc,
104 mlir::Value number, mlir::Value handler, mlir::Value status);
105
107void genSleep(fir::FirOpBuilder &builder, mlir::Location loc,
108 mlir::Value seconds);
109
111mlir::Value genChdir(fir::FirOpBuilder &builder, mlir::Location loc,
112 mlir::Value name);
113
114mlir::Value genIrand(fir::FirOpBuilder &builder, mlir::Location loc,
115 mlir::Value i);
116mlir::Value genRand(fir::FirOpBuilder &builder, mlir::Location loc,
117 mlir::Value i);
118
120void genShowDescriptor(fir::FirOpBuilder &builder, mlir::Location loc,
121 mlir::Value descriptor);
122
123} // namespace runtime
124} // namespace fir
125
126#endif // FORTRAN_LOWER_RUNTIME_H
Definition BoxValue.h:77
Definition FIRBuilder.h:55
Definition AbstractConverter.h:34
Definition AbstractConverter.h:29