xref: /llvm-project/flang/include/flang/Optimizer/Builder/Runtime/Numeric.h (revision a03e93e1b2172791085f3f8c293b8e5d6ed8d841)
1 //===-- Numeric.h -- generate numeric 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_NUMERIC_H
10 #define FORTRAN_OPTIMIZER_BUILDER_RUNTIME_NUMERIC_H
11 
12 #include "mlir/Dialect/Func/IR/FuncOps.h"
13 
14 namespace fir {
15 class ExtendedValue;
16 class FirOpBuilder;
17 } // namespace fir
18 
19 namespace fir::runtime {
20 
21 /// Generate call to ErfcScaled intrinsic runtime routine.
22 mlir::Value genErfcScaled(fir::FirOpBuilder &builder, mlir::Location loc,
23                           mlir::Value x);
24 
25 /// Generate call to Exponent intrinsic runtime routine.
26 mlir::Value genExponent(fir::FirOpBuilder &builder, mlir::Location loc,
27                         mlir::Type resultType, mlir::Value x);
28 
29 /// Generate call to Fraction intrinsic runtime routine.
30 mlir::Value genFraction(fir::FirOpBuilder &builder, mlir::Location loc,
31                         mlir::Value x);
32 
33 /// Generate call to Mod intrinsic runtime routine.
34 mlir::Value genMod(fir::FirOpBuilder &builder, mlir::Location loc,
35                    mlir::Value a, mlir::Value p);
36 
37 /// Generate call to Modulo intrinsic runtime routine.
38 mlir::Value genModulo(fir::FirOpBuilder &builder, mlir::Location loc,
39                       mlir::Value a, mlir::Value p);
40 
41 /// Generate call to Nearest intrinsic runtime routine.
42 mlir::Value genNearest(fir::FirOpBuilder &builder, mlir::Location loc,
43                        mlir::Value x, mlir::Value s);
44 
45 /// Generate call to RRSpacing intrinsic runtime routine.
46 mlir::Value genRRSpacing(fir::FirOpBuilder &builder, mlir::Location loc,
47                          mlir::Value x);
48 
49 /// Generate call to Scale intrinsic runtime routine.
50 mlir::Value genScale(fir::FirOpBuilder &builder, mlir::Location loc,
51                      mlir::Value x, mlir::Value i);
52 
53 /// Generate call to Selected_char_kind intrinsic runtime routine.
54 mlir::Value genSelectedCharKind(fir::FirOpBuilder &builder, mlir::Location loc,
55                                 mlir::Value name, mlir::Value length);
56 
57 /// Generate call to Selected_int_kind intrinsic runtime routine.
58 mlir::Value genSelectedIntKind(fir::FirOpBuilder &builder, mlir::Location loc,
59                                mlir::Value x);
60 
61 /// Generate call to Selected_logical_kind intrinsic runtime routine.
62 mlir::Value genSelectedLogicalKind(fir::FirOpBuilder &builder,
63                                    mlir::Location loc, mlir::Value x);
64 
65 /// Generate call to Selected_real_kind intrinsic runtime routine.
66 mlir::Value genSelectedRealKind(fir::FirOpBuilder &builder, mlir::Location loc,
67                                 mlir::Value precision, mlir::Value range,
68                                 mlir::Value radix);
69 
70 /// Generate call to Set_exponent intrinsic runtime routine.
71 mlir::Value genSetExponent(fir::FirOpBuilder &builder, mlir::Location loc,
72                            mlir::Value x, mlir::Value i);
73 
74 /// Generate call to Spacing intrinsic runtime routine.
75 mlir::Value genSpacing(fir::FirOpBuilder &builder, mlir::Location loc,
76                        mlir::Value x);
77 
78 } // namespace fir::runtime
79 #endif // FORTRAN_OPTIMIZER_BUILDER_RUNTIME_NUMERIC_H
80