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_OPTIMIZER_BUILDER_RUNTIME_INTRINSICS_H
17#define FORTRAN_OPTIMIZER_BUILDER_RUNTIME_INTRINSICS_H
18
19#include <optional>
20
21namespace mlir {
22class Location;
23class Value;
24} // namespace mlir
25
26namespace fir {
27class CharBoxValue;
28class FirOpBuilder;
29
30namespace runtime {
31
32mlir::Value genAssociated(fir::FirOpBuilder &, mlir::Location,
33 mlir::Value pointer, mlir::Value target);
34
35mlir::Value genCpuTime(fir::FirOpBuilder &, mlir::Location);
36void genDateAndTime(fir::FirOpBuilder &, mlir::Location,
37 std::optional<fir::CharBoxValue> date,
38 std::optional<fir::CharBoxValue> time,
39 std::optional<fir::CharBoxValue> zone, mlir::Value values);
40
41mlir::Value genDsecnds(fir::FirOpBuilder &builder, mlir::Location loc,
42 mlir::Value refTime);
43
44void genEtime(fir::FirOpBuilder &builder, mlir::Location loc,
45 mlir::Value values, mlir::Value time);
46
47void genFlush(fir::FirOpBuilder &builder, mlir::Location loc, mlir::Value unit);
48
49void genFree(fir::FirOpBuilder &builder, mlir::Location loc, mlir::Value ptr);
50
51mlir::Value genFseek(fir::FirOpBuilder &builder, mlir::Location loc,
52 mlir::Value unit, mlir::Value offset, mlir::Value whence);
53mlir::Value genFtell(fir::FirOpBuilder &builder, mlir::Location loc,
54 mlir::Value unit);
55
56mlir::Value genGetUID(fir::FirOpBuilder &, mlir::Location);
57mlir::Value genGetGID(fir::FirOpBuilder &, mlir::Location);
58
59mlir::Value genMalloc(fir::FirOpBuilder &builder, mlir::Location loc,
60 mlir::Value size);
61
62void genRandomInit(fir::FirOpBuilder &, mlir::Location, mlir::Value repeatable,
63 mlir::Value imageDistinct);
64void genRandomNumber(fir::FirOpBuilder &, mlir::Location, mlir::Value harvest);
65void genRandomSeed(fir::FirOpBuilder &, mlir::Location, mlir::Value size,
66 mlir::Value put, mlir::Value get);
67
69void genRename(fir::FirOpBuilder &builder, mlir::Location loc,
70 mlir::Value path1, mlir::Value path2, mlir::Value status);
71
72mlir::Value genSecnds(fir::FirOpBuilder &builder, mlir::Location loc,
73 mlir::Value refTime);
74
76mlir::Value genTime(fir::FirOpBuilder &builder, mlir::Location loc);
77
79mlir::Value genTimef(fir::FirOpBuilder &builder, mlir::Location loc);
80
82void genTransfer(fir::FirOpBuilder &builder, mlir::Location loc,
83 mlir::Value resultBox, mlir::Value sourceBox,
84 mlir::Value moldBox);
85
87void genTransferSize(fir::FirOpBuilder &builder, mlir::Location loc,
88 mlir::Value resultBox, mlir::Value sourceBox,
89 mlir::Value moldBox, mlir::Value size);
90
93void genSystemClock(fir::FirOpBuilder &, mlir::Location, mlir::Value count,
94 mlir::Value rate, mlir::Value max);
95
96// generate signal runtime call
97// CALL SIGNAL(NUMBER, HANDLER [, STATUS])
98// status can be {} or a value. It may also be dynamically absent
99void genSignal(fir::FirOpBuilder &builder, mlir::Location loc,
100 mlir::Value number, mlir::Value handler, mlir::Value status);
101
103void genSleep(fir::FirOpBuilder &builder, mlir::Location loc,
104 mlir::Value seconds);
105
107mlir::Value genChdir(fir::FirOpBuilder &builder, mlir::Location loc,
108 mlir::Value name);
109
110mlir::Value genIrand(fir::FirOpBuilder &builder, mlir::Location loc,
111 mlir::Value i);
112mlir::Value genRand(fir::FirOpBuilder &builder, mlir::Location loc,
113 mlir::Value i);
114
116void genShowDescriptor(fir::FirOpBuilder &builder, mlir::Location loc,
117 mlir::Value descriptor);
118
119} // namespace runtime
120} // namespace fir
121
122#endif // FORTRAN_OPTIMIZER_BUILDER_RUNTIME_INTRINSICS_H
Definition BoxValue.h:76
Definition FIRBuilder.h:66
Definition AbstractConverter.h:37
Definition AbstractConverter.h:32