|
13 | 13 | #include "flang/Lower/IO.h" |
14 | 14 | #include "ConvertVariable.h" |
15 | 15 | #include "StatementContext.h" |
| 16 | +#include "flang/Common/uint128.h" |
16 | 17 | #include "flang/Lower/Allocatable.h" |
17 | 18 | #include "flang/Lower/Bridge.h" |
18 | 19 | #include "flang/Lower/ConvertExpr.h" |
@@ -85,15 +86,17 @@ static constexpr std::tuple< |
85 | 86 | mkIOKey(SetRec), mkIOKey(SetRound), mkIOKey(SetSign), |
86 | 87 | mkIOKey(OutputNamelist), mkIOKey(InputNamelist), mkIOKey(OutputDescriptor), |
87 | 88 | mkIOKey(InputDescriptor), mkIOKey(OutputUnformattedBlock), |
88 | | - mkIOKey(InputUnformattedBlock), mkIOKey(OutputInteger64), |
89 | | - mkIOKey(InputInteger), mkIOKey(OutputReal32), mkIOKey(InputReal32), |
90 | | - mkIOKey(OutputReal64), mkIOKey(InputReal64), mkIOKey(OutputComplex32), |
91 | | - mkIOKey(InputComplex32), mkIOKey(OutputComplex64), mkIOKey(InputComplex64), |
92 | | - mkIOKey(OutputAscii), mkIOKey(InputAscii), mkIOKey(OutputLogical), |
93 | | - mkIOKey(InputLogical), mkIOKey(SetAccess), mkIOKey(SetAction), |
94 | | - mkIOKey(SetAsynchronous), mkIOKey(SetCarriagecontrol), mkIOKey(SetEncoding), |
95 | | - mkIOKey(SetForm), mkIOKey(SetPosition), mkIOKey(SetRecl), |
96 | | - mkIOKey(SetStatus), mkIOKey(SetFile), mkIOKey(GetNewUnit), mkIOKey(GetSize), |
| 89 | + mkIOKey(InputUnformattedBlock), mkIOKey(OutputInteger8), |
| 90 | + mkIOKey(OutputInteger16), mkIOKey(OutputInteger32), |
| 91 | + mkIOKey(OutputInteger64), mkIOKey(OutputInteger128), mkIOKey(InputInteger), |
| 92 | + mkIOKey(OutputReal32), mkIOKey(InputReal32), mkIOKey(OutputReal64), |
| 93 | + mkIOKey(InputReal64), mkIOKey(OutputComplex32), mkIOKey(InputComplex32), |
| 94 | + mkIOKey(OutputComplex64), mkIOKey(InputComplex64), mkIOKey(OutputAscii), |
| 95 | + mkIOKey(InputAscii), mkIOKey(OutputLogical), mkIOKey(InputLogical), |
| 96 | + mkIOKey(SetAccess), mkIOKey(SetAction), mkIOKey(SetAsynchronous), |
| 97 | + mkIOKey(SetCarriagecontrol), mkIOKey(SetEncoding), mkIOKey(SetForm), |
| 98 | + mkIOKey(SetPosition), mkIOKey(SetRecl), mkIOKey(SetStatus), |
| 99 | + mkIOKey(SetFile), mkIOKey(GetNewUnit), mkIOKey(GetSize), |
97 | 100 | mkIOKey(GetIoLength), mkIOKey(GetIoMsg), mkIOKey(InquireCharacter), |
98 | 101 | mkIOKey(InquireLogical), mkIOKey(InquirePendingId), |
99 | 102 | mkIOKey(InquireInteger64), mkIOKey(EndIoStatement)> |
@@ -390,10 +393,23 @@ static mlir::FuncOp getOutputFunc(mlir::Location loc, |
390 | 393 | bool isFormatted) { |
391 | 394 | if (!isFormatted) |
392 | 395 | return getIORuntimeFunc<mkIOKey(OutputDescriptor)>(loc, builder); |
393 | | - if (auto ty = type.dyn_cast<mlir::IntegerType>()) |
394 | | - return ty.getWidth() == 1 |
395 | | - ? getIORuntimeFunc<mkIOKey(OutputLogical)>(loc, builder) |
396 | | - : getIORuntimeFunc<mkIOKey(OutputInteger64)>(loc, builder); |
| 396 | + if (auto ty = type.dyn_cast<mlir::IntegerType>()) { |
| 397 | + switch (ty.getWidth()) { |
| 398 | + case 1: |
| 399 | + return getIORuntimeFunc<mkIOKey(OutputLogical)>(loc, builder); |
| 400 | + case 8: |
| 401 | + return getIORuntimeFunc<mkIOKey(OutputInteger8)>(loc, builder); |
| 402 | + case 16: |
| 403 | + return getIORuntimeFunc<mkIOKey(OutputInteger16)>(loc, builder); |
| 404 | + case 32: |
| 405 | + return getIORuntimeFunc<mkIOKey(OutputInteger32)>(loc, builder); |
| 406 | + case 64: |
| 407 | + return getIORuntimeFunc<mkIOKey(OutputInteger64)>(loc, builder); |
| 408 | + case 128: |
| 409 | + return getIORuntimeFunc<mkIOKey(OutputInteger128)>(loc, builder); |
| 410 | + } |
| 411 | + llvm_unreachable("unknown OutputInteger kind"); |
| 412 | + } |
397 | 413 | if (auto ty = type.dyn_cast<mlir::FloatType>()) |
398 | 414 | return ty.getWidth() <= 32 |
399 | 415 | ? getIORuntimeFunc<mkIOKey(OutputReal32)>(loc, builder) |
|
0 commit comments