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 mlir::Value fir::runtime::genSupportHalting(fir::FirOpBuilder &builder, 25 mlir::Location loc, 26 mlir::Value excepts) { 27 mlir::func::FuncOp func{ 28 fir::runtime::getRuntimeFunc<mkRTKey(SupportHalting)>(loc, builder)}; 29 return builder.create<fir::CallOp>(loc, func, excepts).getResult(0); 30 } 31 32 mlir::Value fir::runtime::genGetUnderflowMode(fir::FirOpBuilder &builder, 33 mlir::Location loc) { 34 mlir::func::FuncOp func{ 35 fir::runtime::getRuntimeFunc<mkRTKey(GetUnderflowMode)>(loc, builder)}; 36 return builder.create<fir::CallOp>(loc, func).getResult(0); 37 } 38 39 void fir::runtime::genSetUnderflowMode(fir::FirOpBuilder &builder, 40 mlir::Location loc, mlir::Value flag) { 41 mlir::func::FuncOp func{ 42 fir::runtime::getRuntimeFunc<mkRTKey(SetUnderflowMode)>(loc, builder)}; 43 builder.create<fir::CallOp>(loc, func, flag); 44 } 45 46 mlir::Value fir::runtime::genGetModesTypeSize(fir::FirOpBuilder &builder, 47 mlir::Location loc) { 48 mlir::func::FuncOp func{ 49 fir::runtime::getRuntimeFunc<mkRTKey(GetModesTypeSize)>(loc, builder)}; 50 return builder.create<fir::CallOp>(loc, func).getResult(0); 51 } 52 53 mlir::Value fir::runtime::genGetStatusTypeSize(fir::FirOpBuilder &builder, 54 mlir::Location loc) { 55 mlir::func::FuncOp func{ 56 fir::runtime::getRuntimeFunc<mkRTKey(GetStatusTypeSize)>(loc, builder)}; 57 return builder.create<fir::CallOp>(loc, func).getResult(0); 58 } 59