IEEE_ARITHMETIC intrinsic module procedures IEEE_NEXT_AFTER, IEEE_NEXT_DOWN, and IEEE_NEXT_UP, and intrinsic NEAREST return larger or smaller values adjacent to their primary REAL argument. The four procedures vary in how the direction is chosen, in how special cases are treated, and in what exceptions are generated. Implement the three IEEE_ARITHMETIC procedures. Update the NEAREST implementation to support all six REAL kinds 2,3,4,8,10,16, and fix several bugs. IEEE_NEXT_AFTER(X,Y) returns a NaN when Y is a NaN as that seems to be the universal choice of other compilers. Change the front end compile time implementation of these procedures to return normal (HUGE) values for infinities when applicable, rather than always returning the input infinity.
23 lines
965 B
C++
23 lines
965 B
C++
//===-- Exceptions.cpp ----------------------------------------------------===//
|
|
//
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#include "flang/Optimizer/Builder/Runtime/Exceptions.h"
|
|
#include "flang/Optimizer/Builder/FIRBuilder.h"
|
|
#include "flang/Optimizer/Builder/Runtime/RTBuilder.h"
|
|
#include "flang/Runtime/exceptions.h"
|
|
|
|
using namespace Fortran::runtime;
|
|
|
|
mlir::Value fir::runtime::genMapExcept(fir::FirOpBuilder &builder,
|
|
mlir::Location loc,
|
|
mlir::Value excepts) {
|
|
mlir::func::FuncOp func{
|
|
fir::runtime::getRuntimeFunc<mkRTKey(MapException)>(loc, builder)};
|
|
return builder.create<fir::CallOp>(loc, func, excepts).getResult(0);
|
|
}
|