1 | //===-- Exceptions.cpp ----------------------------------------------------===// |
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 | #include "flang/Optimizer/Builder/Runtime/Exceptions.h" |
10 | #include "flang/Optimizer/Builder/FIRBuilder.h" |
11 | #include "flang/Optimizer/Builder/Runtime/RTBuilder.h" |
12 | #include "flang/Runtime/exceptions.h" |
13 | |
14 | using namespace Fortran::runtime; |
15 | |
16 | mlir::Value fir::runtime::genMapExcept(fir::FirOpBuilder &builder, |
17 | mlir::Location loc, |
18 | mlir::Value excepts) { |
19 | mlir::func::FuncOp func{ |
20 | fir::runtime::getRuntimeFunc<mkRTKey(MapException)>(loc, builder)}; |
21 | return builder.create<fir::CallOp>(loc, func, excepts).getResult(0); |
22 | } |
23 | |
24 | void fir::runtime::genFeclearexcept(fir::FirOpBuilder &builder, |
25 | mlir::Location loc, mlir::Value excepts) { |
26 | mlir::func::FuncOp func{ |
27 | fir::runtime::getRuntimeFunc<mkRTKey(feclearexcept)>(loc, builder)}; |
28 | builder.create<fir::CallOp>(loc, func, excepts); |
29 | } |
30 | |
31 | void fir::runtime::genFeraiseexcept(fir::FirOpBuilder &builder, |
32 | mlir::Location loc, mlir::Value excepts) { |
33 | mlir::func::FuncOp func{ |
34 | fir::runtime::getRuntimeFunc<mkRTKey(feraiseexcept)>(loc, builder)}; |
35 | builder.create<fir::CallOp>(loc, func, excepts); |
36 | } |
37 | |
38 | mlir::Value fir::runtime::genFetestexcept(fir::FirOpBuilder &builder, |
39 | mlir::Location loc, |
40 | mlir::Value excepts) { |
41 | mlir::func::FuncOp func{ |
42 | fir::runtime::getRuntimeFunc<mkRTKey(fetestexcept)>(loc, builder)}; |
43 | return builder.create<fir::CallOp>(loc, func, excepts).getResult(0); |
44 | } |
45 | |
46 | void fir::runtime::genFedisableexcept(fir::FirOpBuilder &builder, |
47 | mlir::Location loc, mlir::Value excepts) { |
48 | mlir::func::FuncOp func{ |
49 | fir::runtime::getRuntimeFunc<mkRTKey(fedisableexcept)>(loc, builder)}; |
50 | builder.create<fir::CallOp>(loc, func, excepts); |
51 | } |
52 | |
53 | void fir::runtime::genFeenableexcept(fir::FirOpBuilder &builder, |
54 | mlir::Location loc, mlir::Value excepts) { |
55 | mlir::func::FuncOp func{ |
56 | fir::runtime::getRuntimeFunc<mkRTKey(feenableexcept)>(loc, builder)}; |
57 | builder.create<fir::CallOp>(loc, func, excepts); |
58 | } |
59 | |
60 | mlir::Value fir::runtime::genFegetexcept(fir::FirOpBuilder &builder, |
61 | mlir::Location loc) { |
62 | mlir::func::FuncOp func{ |
63 | fir::runtime::getRuntimeFunc<mkRTKey(fegetexcept)>(loc, builder)}; |
64 | return builder.create<fir::CallOp>(loc, func).getResult(0); |
65 | } |
66 | |
67 | mlir::Value fir::runtime::genSupportHalting(fir::FirOpBuilder &builder, |
68 | mlir::Location loc, |
69 | mlir::Value excepts) { |
70 | mlir::func::FuncOp func{ |
71 | fir::runtime::getRuntimeFunc<mkRTKey(SupportHalting)>(loc, builder)}; |
72 | return builder.create<fir::CallOp>(loc, func, excepts).getResult(0); |
73 | } |
74 | |
75 | mlir::Value fir::runtime::genGetUnderflowMode(fir::FirOpBuilder &builder, |
76 | mlir::Location loc) { |
77 | mlir::func::FuncOp func{ |
78 | fir::runtime::getRuntimeFunc<mkRTKey(GetUnderflowMode)>(loc, builder)}; |
79 | return builder.create<fir::CallOp>(loc, func).getResult(0); |
80 | } |
81 | |
82 | void fir::runtime::genSetUnderflowMode(fir::FirOpBuilder &builder, |
83 | mlir::Location loc, mlir::Value flag) { |
84 | mlir::func::FuncOp func{ |
85 | fir::runtime::getRuntimeFunc<mkRTKey(SetUnderflowMode)>(loc, builder)}; |
86 | builder.create<fir::CallOp>(loc, func, flag); |
87 | } |
88 | |
89 | mlir::Value fir::runtime::genGetModesTypeSize(fir::FirOpBuilder &builder, |
90 | mlir::Location loc) { |
91 | mlir::func::FuncOp func{ |
92 | fir::runtime::getRuntimeFunc<mkRTKey(GetModesTypeSize)>(loc, builder)}; |
93 | return builder.create<fir::CallOp>(loc, func).getResult(0); |
94 | } |
95 | |
96 | mlir::Value fir::runtime::genGetStatusTypeSize(fir::FirOpBuilder &builder, |
97 | mlir::Location loc) { |
98 | mlir::func::FuncOp func{ |
99 | fir::runtime::getRuntimeFunc<mkRTKey(GetStatusTypeSize)>(loc, builder)}; |
100 | return builder.create<fir::CallOp>(loc, func).getResult(0); |
101 | } |
102 | |