[flang-commits] [flang] [flang] Lower MATMUL to type specific runtime calls. (PR #97547)
via flang-commits
flang-commits at lists.llvm.org
Wed Jul 3 06:59:43 PDT 2024
================
@@ -133,10 +142,70 @@ inline void intrinsicTypeTODO(fir::FirOpBuilder &builder, mlir::Type type,
const llvm::Twine &intrinsicName) {
TODO(loc,
"intrinsic: " +
- fir::numericMlirTypeToFortran(builder, type, loc, intrinsicName) +
+ fir::mlirTypeToIntrinsicFortran(builder, type, loc, intrinsicName) +
" in " + intrinsicName);
}
+inline void intrinsicTypeTODO2(fir::FirOpBuilder &builder, mlir::Type type1,
+ mlir::Type type2, mlir::Location loc,
+ const llvm::Twine &intrinsicName) {
+ TODO(loc,
+ "intrinsic: {" +
+ fir::mlirTypeToIntrinsicFortran(builder, type2, loc, intrinsicName) +
+ ", " +
+ fir::mlirTypeToIntrinsicFortran(builder, type2, loc, intrinsicName) +
+ "} in " + intrinsicName);
+}
+
+inline std::pair<Fortran::common::TypeCategory, KindMapping::KindTy>
+mlirTypeToCategoryKind(mlir::Location loc, mlir::Type type) {
+ if (type.isF16())
+ return {Fortran::common::TypeCategory::Real, 2};
+ else if (type.isBF16())
+ return {Fortran::common::TypeCategory::Real, 3};
+ else if (type.isF32())
+ return {Fortran::common::TypeCategory::Real, 4};
+ else if (type.isF64())
+ return {Fortran::common::TypeCategory::Real, 8};
+ else if (type.isF80())
+ return {Fortran::common::TypeCategory::Real, 10};
+ else if (type.isF128())
+ return {Fortran::common::TypeCategory::Real, 16};
+ else if (type.isInteger(8))
+ return {Fortran::common::TypeCategory::Integer, 1};
+ else if (type.isInteger(16))
+ return {Fortran::common::TypeCategory::Integer, 2};
+ else if (type.isInteger(32))
+ return {Fortran::common::TypeCategory::Integer, 4};
+ else if (type.isInteger(64))
+ return {Fortran::common::TypeCategory::Integer, 8};
+ else if (type.isInteger(128))
+ return {Fortran::common::TypeCategory::Integer, 16};
+ else if (type == fir::ComplexType::get(loc.getContext(), 2))
+ return {Fortran::common::TypeCategory::Complex, 2};
+ else if (type == fir::ComplexType::get(loc.getContext(), 3))
+ return {Fortran::common::TypeCategory::Complex, 3};
+ else if (type == fir::ComplexType::get(loc.getContext(), 4))
+ return {Fortran::common::TypeCategory::Complex, 4};
+ else if (type == fir::ComplexType::get(loc.getContext(), 8))
+ return {Fortran::common::TypeCategory::Complex, 8};
+ else if (type == fir::ComplexType::get(loc.getContext(), 10))
+ return {Fortran::common::TypeCategory::Complex, 10};
+ else if (type == fir::ComplexType::get(loc.getContext(), 16))
+ return {Fortran::common::TypeCategory::Complex, 16};
+ else if (type == fir::LogicalType::get(loc.getContext(), 1))
+ return {Fortran::common::TypeCategory::Logical, 1};
+ else if (type == fir::LogicalType::get(loc.getContext(), 2))
+ return {Fortran::common::TypeCategory::Logical, 2};
+ else if (type == fir::LogicalType::get(loc.getContext(), 4))
+ return {Fortran::common::TypeCategory::Logical, 4};
+ else if (type == fir::LogicalType::get(loc.getContext(), 8))
+ return {Fortran::common::TypeCategory::Logical, 8};
----------------
jeanPerier wrote:
nit:
```
if(complexType = mlir::dyn_cast<fir::ComplexType>(type))
return {Fortran::common::TypeCategory::Complex, complexType.getFKind()};
else if (logicalType = mlir::dyn_cast<fir::LogicalType>(type))
return {Fortran::common::TypeCategory::Logical, logicalType.getFKind()};
```
https://github.com/llvm/llvm-project/pull/97547
More information about the flang-commits
mailing list