Skip to content

Commit cc3cc5e

Browse files
authored
[flang][NFC] simplify dispatching of reduction runtime calls (#110479)
As part of t[he RFC to replace fir.complex usages by mlir complex](https://discourse.llvm.org/t/rfc-flang-replace-usages-of-fir-complex-by-mlir-complex-type/82292), this patch updates the type dispatch in Reduction.cpp to use macros to avoid naming the types everywhere and to avoid typos when copy-pasting the if/else chains.
1 parent 257707b commit cc3cc5e

File tree

2 files changed

+158
-464
lines changed

2 files changed

+158
-464
lines changed

flang/include/flang/Optimizer/Support/Utils.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,10 @@ mlirTypeToCategoryKind(mlir::Location loc, mlir::Type type) {
185185
return {Fortran::common::TypeCategory::Complex, complexType.getFKind()};
186186
else if (auto logicalType = mlir::dyn_cast<fir::LogicalType>(type))
187187
return {Fortran::common::TypeCategory::Logical, logicalType.getFKind()};
188+
else if (auto charType = mlir::dyn_cast<fir::CharacterType>(type))
189+
return {Fortran::common::TypeCategory::Character, charType.getFKind()};
190+
else if (mlir::isa<fir::RecordType>(type))
191+
return {Fortran::common::TypeCategory::Derived, 0};
188192
else
189193
fir::emitFatalError(loc,
190194
"unsupported type: " + fir::mlirTypeToString(type));

0 commit comments

Comments
 (0)