#include "flang/Optimizer/Builder/Runtime/Numeric.h"
#include "flang/Optimizer/Builder/Runtime/RTBuilder.h"
#include "flang/Optimizer/Builder/Runtime/Reduction.h"
+#include "flang/Optimizer/Builder/Runtime/Stop.h"
#include "flang/Optimizer/Builder/Runtime/Transformational.h"
#include "flang/Optimizer/Dialect/FIROpsSupport.h"
#include "flang/Optimizer/Support/FatalError.h"
fir::ExtendedValue genDotProduct(mlir::Type,
llvm::ArrayRef<fir::ExtendedValue>);
fir::ExtendedValue genEoshift(mlir::Type, llvm::ArrayRef<fir::ExtendedValue>);
+ void genExit(llvm::ArrayRef<fir::ExtendedValue>);
mlir::Value genExponent(mlir::Type, llvm::ArrayRef<mlir::Value>);
template <Extremum, ExtremumBehavior>
mlir::Value genExtremum(mlir::Type, llvm::ArrayRef<mlir::Value>);
{"boundary", asBox, handleDynamicOptional},
{"dim", asValue}}},
/*isElemental=*/false},
+ {"exit",
+ &I::genExit,
+ {{{"status", asValue}}},
+ /*isElemental=*/false},
{"exponent", &I::genExponent},
{"floor", &I::genFloor},
{"fraction", &I::genFraction},
"unexpected result for EOSHIFT");
}
+// EXIT
+void IntrinsicLibrary::genExit(llvm::ArrayRef<fir::ExtendedValue> args) {
+ assert(args.size() == 1);
+
+ mlir::Value status =
+ isAbsent(args[0])
+ ? builder.createIntegerConstant(loc, builder.getDefaultIntegerType(),
+ EXIT_SUCCESS)
+ : fir::getBase(args[0]);
+
+ assert(status.getType() == builder.getDefaultIntegerType() &&
+ "STATUS parameter must be an INTEGER of default kind");
+
+ fir::runtime::genExit(builder, loc, status);
+}
+
// EXPONENT
mlir::Value IntrinsicLibrary::genExponent(mlir::Type resultType,
llvm::ArrayRef<mlir::Value> args) {
--- /dev/null
+! RUN: bbc -emit-fir %s -o - | FileCheck --check-prefixes=CHECK,CHECK-32 -DDEFAULT_INTEGER_SIZE=32 %s
+! bbc doesn't have a way to set the default kinds so we use flang-new driver
+! RUN: flang-new -fc1 -fdefault-integer-8 -emit-fir %s -o - | FileCheck --check-prefixes=CHECK,CHECK-64 -DDEFAULT_INTEGER_SIZE=64 %s
+
+! CHECK-LABEL: func @_QPexit_test1() {
+subroutine exit_test1
+ call exit()
+ ! CHECK: %[[status:.*]] = arith.constant 0 : i[[DEFAULT_INTEGER_SIZE]]
+ ! CHECK-64: %[[statusConvert:.*]] = fir.convert %[[status]] : (i64) -> i32
+ ! CHECK-32: %{{[0-9]+}} = fir.call @_FortranAExit(%[[status]]) : (i32) -> none
+ ! CHECK-64: %{{[0-9]+}} = fir.call @_FortranAExit(%[[statusConvert]]) : (i32) -> none
+ end subroutine exit_test1
+
+ ! CHECK-LABEL: func @_QPexit_test2(
+ ! CHECK-SAME: %[[statusArg:.*]]: !fir.ref<i[[DEFAULT_INTEGER_SIZE]]>{{.*}}) {
+ subroutine exit_test2(status)
+ integer :: status
+ call exit(status)
+ ! CHECK: %[[status:.*]] = fir.load %[[statusArg]] : !fir.ref<i[[DEFAULT_INTEGER_SIZE]]>
+ ! CHECK-64: %[[statusConv:.*]] = fir.convert %[[status]] : (i64) -> i32
+ ! CHECK-32: %{{[0-9]+}} = fir.call @_FortranAExit(%[[status]]) : (i32) -> none
+ ! CHECK-64: %{{[0-9]+}} = fir.call @_FortranAExit(%[[statusConv]]) : (i32) -> none
+ end subroutine exit_test2