diff --git a/flang/include/flang/Optimizer/Builder/Runtime/RTBuilder.h b/flang/include/flang/Optimizer/Builder/Runtime/RTBuilder.h index a4b315319eab5a..a69a8910d3f5b1 100644 --- a/flang/include/flang/Optimizer/Builder/Runtime/RTBuilder.h +++ b/flang/include/flang/Optimizer/Builder/Runtime/RTBuilder.h @@ -18,6 +18,7 @@ #define FORTRAN_OPTIMIZER_BUILDER_RUNTIME_RTBUILDER_H #include "flang/Common/Fortran.h" +#include "flang/Common/uint128.h" #include "flang/Optimizer/Builder/FIRBuilder.h" #include "flang/Optimizer/Dialect/FIRType.h" #include "mlir/IR/BuiltinTypes.h" @@ -141,6 +142,13 @@ constexpr TypeBuilderFunc getModel() { }; } template <> +constexpr TypeBuilderFunc getModel() { + return [](mlir::MLIRContext *context) -> mlir::Type { + return mlir::IntegerType::get(context, + 8 * sizeof(Fortran::common::int128_t)); + }; +} +template <> constexpr TypeBuilderFunc getModel() { return [](mlir::MLIRContext *context) -> mlir::Type { TypeBuilderFunc f{getModel()}; diff --git a/flang/lib/Lower/IO.cpp b/flang/lib/Lower/IO.cpp index 9df40e3c79aef2..9f442347856fd5 100644 --- a/flang/lib/Lower/IO.cpp +++ b/flang/lib/Lower/IO.cpp @@ -13,6 +13,7 @@ #include "flang/Lower/IO.h" #include "ConvertVariable.h" #include "StatementContext.h" +#include "flang/Common/uint128.h" #include "flang/Lower/Allocatable.h" #include "flang/Lower/Bridge.h" #include "flang/Lower/ConvertExpr.h" @@ -85,15 +86,17 @@ static constexpr std::tuple< mkIOKey(SetRec), mkIOKey(SetRound), mkIOKey(SetSign), mkIOKey(OutputNamelist), mkIOKey(InputNamelist), mkIOKey(OutputDescriptor), mkIOKey(InputDescriptor), mkIOKey(OutputUnformattedBlock), - mkIOKey(InputUnformattedBlock), mkIOKey(OutputInteger64), - mkIOKey(InputInteger), mkIOKey(OutputReal32), mkIOKey(InputReal32), - mkIOKey(OutputReal64), mkIOKey(InputReal64), mkIOKey(OutputComplex32), - mkIOKey(InputComplex32), mkIOKey(OutputComplex64), mkIOKey(InputComplex64), - mkIOKey(OutputAscii), mkIOKey(InputAscii), mkIOKey(OutputLogical), - mkIOKey(InputLogical), mkIOKey(SetAccess), mkIOKey(SetAction), - mkIOKey(SetAsynchronous), mkIOKey(SetCarriagecontrol), mkIOKey(SetEncoding), - mkIOKey(SetForm), mkIOKey(SetPosition), mkIOKey(SetRecl), - mkIOKey(SetStatus), mkIOKey(SetFile), mkIOKey(GetNewUnit), mkIOKey(GetSize), + mkIOKey(InputUnformattedBlock), mkIOKey(OutputInteger8), + mkIOKey(OutputInteger16), mkIOKey(OutputInteger32), + mkIOKey(OutputInteger64), mkIOKey(OutputInteger128), mkIOKey(InputInteger), + mkIOKey(OutputReal32), mkIOKey(InputReal32), mkIOKey(OutputReal64), + mkIOKey(InputReal64), mkIOKey(OutputComplex32), mkIOKey(InputComplex32), + mkIOKey(OutputComplex64), mkIOKey(InputComplex64), mkIOKey(OutputAscii), + mkIOKey(InputAscii), mkIOKey(OutputLogical), mkIOKey(InputLogical), + mkIOKey(SetAccess), mkIOKey(SetAction), mkIOKey(SetAsynchronous), + mkIOKey(SetCarriagecontrol), mkIOKey(SetEncoding), mkIOKey(SetForm), + mkIOKey(SetPosition), mkIOKey(SetRecl), mkIOKey(SetStatus), + mkIOKey(SetFile), mkIOKey(GetNewUnit), mkIOKey(GetSize), mkIOKey(GetIoLength), mkIOKey(GetIoMsg), mkIOKey(InquireCharacter), mkIOKey(InquireLogical), mkIOKey(InquirePendingId), mkIOKey(InquireInteger64), mkIOKey(EndIoStatement)> @@ -390,10 +393,23 @@ static mlir::FuncOp getOutputFunc(mlir::Location loc, bool isFormatted) { if (!isFormatted) return getIORuntimeFunc(loc, builder); - if (auto ty = type.dyn_cast()) - return ty.getWidth() == 1 - ? getIORuntimeFunc(loc, builder) - : getIORuntimeFunc(loc, builder); + if (auto ty = type.dyn_cast()) { + switch (ty.getWidth()) { + case 1: + return getIORuntimeFunc(loc, builder); + case 8: + return getIORuntimeFunc(loc, builder); + case 16: + return getIORuntimeFunc(loc, builder); + case 32: + return getIORuntimeFunc(loc, builder); + case 64: + return getIORuntimeFunc(loc, builder); + case 128: + return getIORuntimeFunc(loc, builder); + } + llvm_unreachable("unknown OutputInteger kind"); + } if (auto ty = type.dyn_cast()) return ty.getWidth() <= 32 ? getIORuntimeFunc(loc, builder) diff --git a/flang/test/Lower/OpenMP/omp-master.f90 b/flang/test/Lower/OpenMP/omp-master.f90 index 71c95cb9226d95..945d423b59d4ad 100644 --- a/flang/test/Lower/OpenMP/omp-master.f90 +++ b/flang/test/Lower/OpenMP/omp-master.f90 @@ -68,7 +68,7 @@ program main !$OMP PARALLEL !FIRDialect: omp.parallel { !FIRDialect: fir.call @_FortranAioBeginExternalListOutput -!FIRDialect: fir.call @_FortranAioOutputInteger64 +!FIRDialect: fir.call @_FortranAioOutputInteger32 !FIRDialect: fir.call @_FortranAioEndIoStatement !FIRDialect: omp.terminator !FIRDialect: } diff --git a/flang/test/Lower/OpenMP/omp-parallel-firstprivate-clause-scalar.f90 b/flang/test/Lower/OpenMP/omp-parallel-firstprivate-clause-scalar.f90 index d9de9530752111..3e965b4cdbc484 100644 --- a/flang/test/Lower/OpenMP/omp-parallel-firstprivate-clause-scalar.f90 +++ b/flang/test/Lower/OpenMP/omp-parallel-firstprivate-clause-scalar.f90 @@ -91,22 +91,17 @@ subroutine firstprivate_complex(arg1, arg2) !FIRDialect-DAG: fir.store %[[ARG6_VAL]] to %[[ARG6_PVT]] : !fir.ref !FIRDialect-DAG: %[[LIST_IO:.*]] = fir.call @_FortranAioBeginExternalListOutput !FIRDialect-DAG: %[[ARG1_PVT_VAL:.*]] = fir.load %[[ARG1_PVT]] : !fir.ref -!FIRDialect-DAG: %[[ARG1_PVT_CVT:.*]] = fir.convert %[[ARG1_PVT_VAL]] : (i32) -> i64 -!FIRDialect-DAG: %{{.*}} = fir.call @_FortranAioOutputInteger64(%[[LIST_IO]], %[[ARG1_PVT_CVT]]) : (!fir.ref, i64) -> i1 +!FIRDialect-DAG: %{{.*}} = fir.call @_FortranAioOutputInteger32(%[[LIST_IO]], %[[ARG1_PVT_VAL]]) : (!fir.ref, i32) -> i1 !FIRDialect-DAG: %[[ARG2_PVT_VAL:.*]] = fir.load %[[ARG2_PVT]] : !fir.ref -!FIRDialect-DAG: %[[ARG2_PVT_CVT:.*]] = fir.convert %[[ARG2_PVT_VAL]] : (i8) -> i64 -!FIRDialect-DAG: %{{.*}} = fir.call @_FortranAioOutputInteger64(%[[LIST_IO]], %[[ARG2_PVT_CVT]]) : (!fir.ref, i64) -> i1 +!FIRDialect-DAG: %{{.*}} = fir.call @_FortranAioOutputInteger8(%[[LIST_IO]], %[[ARG2_PVT_VAL]]) : (!fir.ref, i8) -> i1 !FIRDialect-DAG: %[[ARG3_PVT_VAL:.*]] = fir.load %[[ARG3_PVT]] : !fir.ref -!FIRDialect-DAG: %[[ARG3_PVT_CVT:.*]] = fir.convert %[[ARG3_PVT_VAL]] : (i16) -> i64 -!FIRDialect-DAG: %{{.*}} = fir.call @_FortranAioOutputInteger64(%[[LIST_IO]], %[[ARG3_PVT_CVT]]) : (!fir.ref, i64) -> i1 +!FIRDialect-DAG: %{{.*}} = fir.call @_FortranAioOutputInteger16(%[[LIST_IO]], %[[ARG3_PVT_VAL]]) : (!fir.ref, i16) -> i1 !FIRDialect-DAG: %[[ARG4_PVT_VAL:.*]] = fir.load %[[ARG4_PVT]] : !fir.ref -!FIRDialect-DAG: %[[ARG4_PVT_CVT:.*]] = fir.convert %[[ARG4_PVT_VAL]] : (i32) -> i64 -!FIRDialect-DAG: %{{.*}} = fir.call @_FortranAioOutputInteger64(%[[LIST_IO]], %[[ARG4_PVT_CVT]]) : (!fir.ref, i64) -> i1 +!FIRDialect-DAG: %{{.*}} = fir.call @_FortranAioOutputInteger32(%[[LIST_IO]], %[[ARG4_PVT_VAL]]) : (!fir.ref, i32) -> i1 !FIRDialect-DAG: %[[ARG5_PVT_VAL:.*]] = fir.load %[[ARG5_PVT]] : !fir.ref !FIRDialect-DAG: %{{.*}} = fir.call @_FortranAioOutputInteger64(%[[LIST_IO]], %[[ARG5_PVT_VAL]]) : (!fir.ref, i64) -> i1 !FIRDialect-DAG: %[[ARG6_PVT_VAL:.*]] = fir.load %[[ARG6_PVT]] : !fir.ref -!FIRDialect-DAG: %[[ARG6_PVT_CVT:.*]] = fir.convert %[[ARG6_PVT_VAL]] : (i128) -> i64 -!FIRDialect-DAG: %{{.*}} = fir.call @_FortranAioOutputInteger64(%[[LIST_IO]], %[[ARG6_PVT_CVT]]) : (!fir.ref, i64) -> i1 +!FIRDialect-DAG: %{{.*}} = fir.call @_FortranAioOutputInteger128(%[[LIST_IO]], %[[ARG6_PVT_VAL]]) : (!fir.ref, i128) -> i1 !FIRDialect-DAG: omp.terminator !FIRDialect-DAG: } diff --git a/flang/test/Lower/OpenMP/omp-parallel-region.f90 b/flang/test/Lower/OpenMP/omp-parallel-region.f90 index 92d564dd4b54d9..ef7051122d2877 100644 --- a/flang/test/Lower/OpenMP/omp-parallel-region.f90 +++ b/flang/test/Lower/OpenMP/omp-parallel-region.f90 @@ -46,7 +46,7 @@ program parallel !FIRDialect-NEXT: } !FIRDialect: fir.call @_FortranAioBeginExternalListOutput !FIRDialect: fir.load %[[VAR_C]] -!FIRDialect: fir.call @_FortranAioOutputInteger64 +!FIRDialect: fir.call @_FortranAioOutputInteger32 !FIRDialect: fir.call @_FortranAioEndIoStatement !FIRDialect: omp.terminator !FIRDialect-NEXT: } @@ -67,7 +67,7 @@ program parallel !LLVMIRDialect: ^bb2: // 2 preds: ^bb0, ^bb1 !LLVMIRDialect: llvm.call @_FortranAioBeginExternalListOutput !LLVMIRDialect: llvm.load %[[VAR_C]] : !llvm.ptr -!LLVMIRDialect: llvm.call @_FortranAioOutputInteger64 +!LLVMIRDialect: llvm.call @_FortranAioOutputInteger32 !LLVMIRDialect: llvm.call @_FortranAioEndIoStatement !LLVMIRDialect: omp.terminator !LLVMIRDialect-NEXT: } @@ -82,7 +82,7 @@ program parallel !LLVMIR: %[[COND_RES:.*]] = icmp sgt i32 %{{.*}}, 4 !LLVMIR: br i1 %[[COND_RES]], label %{{.*}}, label %{{.*}} !LLVMIR: call i8* @_FortranAioBeginExternalListOutput -!LLVMIR: call i1 @_FortranAioOutputInteger64 +!LLVMIR: call i1 @_FortranAioOutputInteger32 !LLVMIR: call i32 @_FortranAioEndIoStatement c = a + b diff --git a/flang/test/Lower/OpenMP/omp-wsloop-dynamic.f90 b/flang/test/Lower/OpenMP/omp-wsloop-dynamic.f90 index 3808559842e608..2a1b7837c3e116 100644 --- a/flang/test/Lower/OpenMP/omp-wsloop-dynamic.f90 +++ b/flang/test/Lower/OpenMP/omp-wsloop-dynamic.f90 @@ -58,14 +58,12 @@ program wsloop_dynamic do i=1, 9 print*, i !FIRDialect: %[[RTBEGIN:.*]] = fir.call @_FortranAioBeginExternalListOutput -!FIRDialect: %[[CONVERTED:.*]] = fir.convert %[[I]] : (i32) -> i64 -!FIRDialect: fir.call @_FortranAioOutputInteger64(%[[RTBEGIN]], %[[CONVERTED]]) : (!fir.ref, i64) -> i1 +!FIRDialect: fir.call @_FortranAioOutputInteger32(%[[RTBEGIN]], %[[I]]) : (!fir.ref, i32) -> i1 !FIRDialect: fir.call @_FortranAioEndIoStatement(%[[RTBEGIN]]) : (!fir.ref) -> i32 !LLVMIRDialect: llvm.call @_FortranAioBeginExternalListOutput(%{{.*}}, %{{.*}}, %{{.*}}) : (i32, !llvm.ptr, i32) -> !llvm.ptr -!LLVMIRDialect: %{{.*}} = llvm.sext %arg0 : i32 to i64 -!LLVMIRDialect: llvm.call @_FortranAioOutputInteger64(%{{.*}}, %{{.*}}) : (!llvm.ptr, i64) -> i1 +!LLVMIRDialect: llvm.call @_FortranAioOutputInteger32(%{{.*}}, %{{.*}}) : (!llvm.ptr, i32) -> i1 !LLVMIRDialect: llvm.call @_FortranAioEndIoStatement(%{{.*}}) : (!llvm.ptr) -> i32 !LLVMIR: br label %omp_loop.cond @@ -79,8 +77,7 @@ program wsloop_dynamic !LLVMIR: br label %omp.wsloop.region !LLVMIR: omp.wsloop.region: ; preds = %omp_loop.body !LLVMIR: %{{.*}} = call i8* @_FortranAioBeginExternalListOutput -!LLVMIR: %{{.*}} = sext i32 %{{.*}} to i64 -!LLVMIR: %{{.*}} = call i1 @_FortranAioOutputInteger64 +!LLVMIR: %{{.*}} = call i1 @_FortranAioOutputInteger32 !LLVMIR: %{{.*}} = call i32 @_FortranAioEndIoStatement end do diff --git a/flang/test/Lower/OpenMP/omp-wsloop-monotonic.f90 b/flang/test/Lower/OpenMP/omp-wsloop-monotonic.f90 index 91b4001eb73ceb..5bc70f2b909d5e 100644 --- a/flang/test/Lower/OpenMP/omp-wsloop-monotonic.f90 +++ b/flang/test/Lower/OpenMP/omp-wsloop-monotonic.f90 @@ -58,14 +58,12 @@ program wsloop_dynamic do i=1, 9 print*, i !FIRDialect: %[[RTBEGIN:.*]] = fir.call @_FortranAioBeginExternalListOutput -!FIRDialect: %[[CONVERTED:.*]] = fir.convert %[[I]] : (i32) -> i64 -!FIRDialect: fir.call @_FortranAioOutputInteger64(%[[RTBEGIN]], %[[CONVERTED]]) : (!fir.ref, i64) -> i1 +!FIRDialect: fir.call @_FortranAioOutputInteger32(%[[RTBEGIN]], %[[I]]) : (!fir.ref, i32) -> i1 !FIRDialect: fir.call @_FortranAioEndIoStatement(%[[RTBEGIN]]) : (!fir.ref) -> i32 !LLVMIRDialect: llvm.call @_FortranAioBeginExternalListOutput(%{{.*}}, %{{.*}}, %{{.*}}) : (i32, !llvm.ptr, i32) -> !llvm.ptr -!LLVMIRDialect: %{{.*}} = llvm.sext %[[I]] : i32 to i64 -!LLVMIRDialect: llvm.call @_FortranAioOutputInteger64(%{{.*}}, %{{.*}}) : (!llvm.ptr, i64) -> i1 +!LLVMIRDialect: llvm.call @_FortranAioOutputInteger32(%{{.*}}, %{{.*}}) : (!llvm.ptr, i32) -> i1 !LLVMIRDialect: llvm.call @_FortranAioEndIoStatement(%{{.*}}) : (!llvm.ptr) -> i32 !LLVMIR: br label %omp_loop.cond @@ -79,8 +77,7 @@ program wsloop_dynamic !LLVMIR: br label %omp.wsloop.region !LLVMIR: omp.wsloop.region: ; preds = %omp_loop.body !LLVMIR: %{{.*}} = call i8* @_FortranAioBeginExternalListOutput -!LLVMIR: %{{.*}} = sext i32 %{{.*}} to i64 -!LLVMIR: %{{.*}} = call i1 @_FortranAioOutputInteger64 +!LLVMIR: %{{.*}} = call i1 @_FortranAioOutputInteger32 !LLVMIR: %{{.*}} = call i32 @_FortranAioEndIoStatement end do diff --git a/flang/test/Lower/OpenMP/omp-wsloop-nonmonotonic.f90 b/flang/test/Lower/OpenMP/omp-wsloop-nonmonotonic.f90 index 815357168d2a36..4d420326a71df9 100644 --- a/flang/test/Lower/OpenMP/omp-wsloop-nonmonotonic.f90 +++ b/flang/test/Lower/OpenMP/omp-wsloop-nonmonotonic.f90 @@ -58,14 +58,12 @@ program wsloop_dynamic do i=1, 9 print*, i !FIRDialect: %[[RTBEGIN:.*]] = fir.call @_FortranAioBeginExternalListOutput -!FIRDialect: %[[CONVERTED:.*]] = fir.convert %[[I]] : (i32) -> i64 -!FIRDialect: fir.call @_FortranAioOutputInteger64(%[[RTBEGIN]], %[[CONVERTED]]) : (!fir.ref, i64) -> i1 +!FIRDialect: fir.call @_FortranAioOutputInteger32(%[[RTBEGIN]], %[[I]]) : (!fir.ref, i32) -> i1 !FIRDialect: fir.call @_FortranAioEndIoStatement(%[[RTBEGIN]]) : (!fir.ref) -> i32 !LLVMIRDialect: llvm.call @_FortranAioBeginExternalListOutput(%{{.*}}, %{{.*}}, %{{.*}}) : (i32, !llvm.ptr, i32) -> !llvm.ptr -!LLVMIRDialect: %{{.*}} = llvm.sext %arg0 : i32 to i64 -!LLVMIRDialect: llvm.call @_FortranAioOutputInteger64(%{{.*}}, %{{.*}}) : (!llvm.ptr, i64) -> i1 +!LLVMIRDialect: llvm.call @_FortranAioOutputInteger32(%{{.*}}, %{{.*}}) : (!llvm.ptr, i32) -> i1 !LLVMIRDialect: llvm.call @_FortranAioEndIoStatement(%{{.*}}) : (!llvm.ptr) -> i32 !LLVMIR: br label %omp_loop.cond @@ -79,8 +77,7 @@ program wsloop_dynamic !LLVMIR: br label %omp.wsloop.region !LLVMIR: omp.wsloop.region: ; preds = %omp_loop.body !LLVMIR: %{{.*}} = call i8* @_FortranAioBeginExternalListOutput -!LLVMIR: %{{.*}} = sext i32 %{{.*}} to i64 -!LLVMIR: %{{.*}} = call i1 @_FortranAioOutputInteger64 +!LLVMIR: %{{.*}} = call i1 @_FortranAioOutputInteger32 !LLVMIR: %{{.*}} = call i32 @_FortranAioEndIoStatement end do diff --git a/flang/test/Lower/OpenMP/omp-wsloop-simd.f90 b/flang/test/Lower/OpenMP/omp-wsloop-simd.f90 index 6ff808f1d9b3cc..a425dd8fcbb31b 100644 --- a/flang/test/Lower/OpenMP/omp-wsloop-simd.f90 +++ b/flang/test/Lower/OpenMP/omp-wsloop-simd.f90 @@ -58,14 +58,12 @@ program wsloop_dynamic do i=1, 9 print*, i !FIRDialect: %[[RTBEGIN:.*]] = fir.call @_FortranAioBeginExternalListOutput -!FIRDialect: %[[CONVERTED:.*]] = fir.convert %[[I]] : (i32) -> i64 -!FIRDialect: fir.call @_FortranAioOutputInteger64(%[[RTBEGIN]], %[[CONVERTED]]) : (!fir.ref, i64) -> i1 +!FIRDialect: fir.call @_FortranAioOutputInteger32(%[[RTBEGIN]], %[[I]]) : (!fir.ref, i32) -> i1 !FIRDialect: fir.call @_FortranAioEndIoStatement(%[[RTBEGIN]]) : (!fir.ref) -> i32 !LLVMIRDialect: llvm.call @_FortranAioBeginExternalListOutput(%{{.*}}, %{{.*}}, %{{.*}}) : (i32, !llvm.ptr, i32) -> !llvm.ptr -!LLVMIRDialect: %{{.*}} = llvm.sext %arg0 : i32 to i64 -!LLVMIRDialect: llvm.call @_FortranAioOutputInteger64(%{{.*}}, %{{.*}}) : (!llvm.ptr, i64) -> i1 +!LLVMIRDialect: llvm.call @_FortranAioOutputInteger32(%{{.*}}, %{{.*}}) : (!llvm.ptr, i32) -> i1 !LLVMIRDialect: llvm.call @_FortranAioEndIoStatement(%{{.*}}) : (!llvm.ptr) -> i32 !LLVMIR: br label %omp_loop.cond @@ -79,8 +77,7 @@ program wsloop_dynamic !LLVMIR: br label %omp.wsloop.region !LLVMIR: omp.wsloop.region: ; preds = %omp_loop.body !LLVMIR: %{{.*}} = call i8* @_FortranAioBeginExternalListOutput -!LLVMIR: %{{.*}} = sext i32 %{{.*}} to i64 -!LLVMIR: %{{.*}} = call i1 @_FortranAioOutputInteger64 +!LLVMIR: %{{.*}} = call i1 @_FortranAioOutputInteger32 !LLVMIR: %{{.*}} = call i32 @_FortranAioEndIoStatement end do diff --git a/flang/test/Lower/OpenMP/omp-wsloop.f90 b/flang/test/Lower/OpenMP/omp-wsloop.f90 index d1b0b92611a511..efca65455a1a26 100644 --- a/flang/test/Lower/OpenMP/omp-wsloop.f90 +++ b/flang/test/Lower/OpenMP/omp-wsloop.f90 @@ -50,14 +50,12 @@ program wsloop do i=1, 9 print*, i !FIRDialect: %[[RTBEGIN:.*]] = fir.call @_FortranAioBeginExternalListOutput -!FIRDialect: %[[CONVERTED:.*]] = fir.convert %[[I]] : (i32) -> i64 -!FIRDialect: fir.call @_FortranAioOutputInteger64(%[[RTBEGIN]], %[[CONVERTED]]) : (!fir.ref, i64) -> i1 +!FIRDialect: fir.call @_FortranAioOutputInteger32(%[[RTBEGIN]], %[[I]]) : (!fir.ref, i32) -> i1 !FIRDialect: fir.call @_FortranAioEndIoStatement(%[[RTBEGIN]]) : (!fir.ref) -> i32 !LLVMIRDialect: llvm.call @_FortranAioBeginExternalListOutput(%{{.*}}, %{{.*}}, %{{.*}}) : (i32, !llvm.ptr, i32) -> !llvm.ptr -!LLVMIRDialect: %{{.*}} = llvm.sext %[[I]] : i32 to i64 -!LLVMIRDialect: llvm.call @_FortranAioOutputInteger64(%{{.*}}, %{{.*}}) : (!llvm.ptr, i64) -> i1 +!LLVMIRDialect: llvm.call @_FortranAioOutputInteger32(%{{.*}}, %{{.*}}) : (!llvm.ptr, i32) -> i1 !LLVMIRDialect: llvm.call @_FortranAioEndIoStatement(%{{.*}}) : (!llvm.ptr) -> i32 !LLVMIR: br label %omp_loop.cond @@ -73,8 +71,7 @@ program wsloop !LLVMIR: br label %omp.wsloop.region !LLVMIR: omp.wsloop.region: ; preds = %omp_loop.body !LLVMIR: %{{.*}} = call i8* @_FortranAioBeginExternalListOutput -!LLVMIR: %{{.*}} = sext i32 %{{.*}} to i64 -!LLVMIR: %{{.*}} = call i1 @_FortranAioOutputInteger64 +!LLVMIR: %{{.*}} = call i1 @_FortranAioOutputInteger32 !LLVMIR: %{{.*}} = call i32 @_FortranAioEndIoStatement end do diff --git a/flang/test/Lower/io-statement-1.f90 b/flang/test/Lower/io-statement-1.f90 index 4e67cf12b5944f..c4489f59caf012 100644 --- a/flang/test/Lower/io-statement-1.f90 +++ b/flang/test/Lower/io-statement-1.f90 @@ -39,7 +39,7 @@ ! CHECK: call {{.*}}BeginExternalListOutput ! Note that 32 bit integers are output as 64 bits in the runtime API - ! CHECK: call {{.*}}OutputInteger64 + ! CHECK: call {{.*}}OutputInteger32 ! CHECK: call {{.*}}OutputReal32 ! CHECK: call {{.*}}EndIoStatement write (8,*) i, f @@ -113,3 +113,33 @@ subroutine inquire_test(ch, i, b) ! CHECK: call {{.*}}EndIoStatement inquire(91, id=id_func(), pending=b) end subroutine inquire_test + +! CHECK-LABEL: @_QPboz +subroutine boz + ! CHECK: fir.call @_FortranAioOutputInteger8(%{{.*}}, %{{.*}}) : (!fir.ref, i8) -> i1 + ! CHECK: fir.call @_FortranAioOutputInteger16(%{{.*}}, %{{.*}}) : (!fir.ref, i16) -> i1 + ! CHECK: fir.call @_FortranAioOutputInteger32(%{{.*}}, %{{.*}}) : (!fir.ref, i32) -> i1 + ! CHECK: fir.call @_FortranAioOutputInteger64(%{{.*}}, %{{.*}}) : (!fir.ref, i64) -> i1 + ! CHECK: fir.call @_FortranAioOutputInteger128(%{{.*}}, %{{.*}}) : (!fir.ref, i128) -> i1 + print '(*(Z3))', 96_1, 96_2, 96_4, 96_8, 96_16 + + ! CHECK: fir.call @_FortranAioOutputInteger32(%{{.*}}, %{{.*}}) : (!fir.ref, i32) -> i1 + ! CHECK: fir.call @_FortranAioOutputInteger64(%{{.*}}, %{{.*}}) : (!fir.ref, i64) -> i1 + ! CHECK: fir.call @_FortranAioOutputInteger64(%{{.*}}, %{{.*}}) : (!fir.ref, i64) -> i1 + print '(I3,2Z44)', 40, 2**40_8, 2**40_8+1 + + ! CHECK: fir.call @_FortranAioOutputInteger32(%{{.*}}, %{{.*}}) : (!fir.ref, i32) -> i1 + ! CHECK: fir.call @_FortranAioOutputInteger64(%{{.*}}, %{{.*}}) : (!fir.ref, i64) -> i1 + ! CHECK: fir.call @_FortranAioOutputInteger64(%{{.*}}, %{{.*}}) : (!fir.ref, i64) -> i1 + print '(I3,2I44)', 40, 1099511627776, 1099511627777 + + ! CHECK: fir.call @_FortranAioOutputInteger32(%{{.*}}, %{{.*}}) : (!fir.ref, i32) -> i1 + ! CHECK: fir.call @_FortranAioOutputInteger64(%{{.*}}, %{{.*}}) : (!fir.ref, i64) -> i1 + ! CHECK: fir.call @_FortranAioOutputInteger64(%{{.*}}, %{{.*}}) : (!fir.ref, i64) -> i1 + print '(I3,2O44)', 40, 2**40_8, 2**40_8+1 + + ! CHECK: fir.call @_FortranAioOutputInteger32(%{{.*}}, %{{.*}}) : (!fir.ref, i32) -> i1 + ! CHECK: fir.call @_FortranAioOutputInteger64(%{{.*}}, %{{.*}}) : (!fir.ref, i64) -> i1 + ! CHECK: fir.call @_FortranAioOutputInteger64(%{{.*}}, %{{.*}}) : (!fir.ref, i64) -> i1 + print '(I3,2B44)', 40, 2**40_8, 2**40_8+1 +end diff --git a/flang/test/Lower/io-statement-2.f90 b/flang/test/Lower/io-statement-2.f90 index 906b7fba0c9c5f..cde39c6fb8c830 100644 --- a/flang/test/Lower/io-statement-2.f90 +++ b/flang/test/Lower/io-statement-2.f90 @@ -116,7 +116,7 @@ subroutine loopnest ! CHECK: fir.if {{.*}} -> (i1) { ! CHECK: {{.*}}:2 = fir.iterate_while ({{.*}} = {{.*}} to {{.*}} step {{.*}}) and ({{.*}} = {{.*}}) -> (index, i1) { ! CHECK: fir.if {{.*}} -> (i1) { - ! CHECK: OutputInteger64 + ! CHECK: OutputInteger32 ! CHECK: fir.result {{.*}} : i1 ! CHECK: } else { ! CHECK: fir.result {{.*}} : i1