[fir] Add !fir.len type conversion

This patch adds the !fir.len type conversion. The type is converted
to the a 32 bits integer.

This patch is part of the upstreaming effort from fir-dev branch.

Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>

Reviewed By: kiranchandramohan

Differential Revision: https://reviews.llvm.org/D113658
This commit is contained in:
Valentin Clement 2021-11-15 10:17:50 +01:00
parent 599ea3e73f
commit 6c8eecd676
No known key found for this signature in database
GPG Key ID: 086D54783C928776
2 changed files with 13 additions and 0 deletions

View File

@ -73,6 +73,11 @@ public:
// Convert to i32 because of LLVM GEP indexing restriction. // Convert to i32 because of LLVM GEP indexing restriction.
return mlir::IntegerType::get(field.getContext(), 32); return mlir::IntegerType::get(field.getContext(), 32);
}); });
addConversion([&](fir::LenType field) {
// Get size of len paramter from the descriptor.
return getModel<Fortran::runtime::typeInfo::TypeParameterValue>()(
&getContext());
});
addConversion( addConversion(
[&](fir::ComplexType cmplx) { return convertComplexType(cmplx); }); [&](fir::ComplexType cmplx) { return convertComplexType(cmplx); });
addConversion( addConversion(

View File

@ -293,3 +293,11 @@ func private @foo1(%arg0: !fir.boxchar<2>)
func private @foo0(%arg0: !fir.field) func private @foo0(%arg0: !fir.field)
// CHECK-LABEL: foo0 // CHECK-LABEL: foo0
// CHECK-SAME: i32 // CHECK-SAME: i32
// -----
// Test `!fir.len` conversion.
func private @foo0(%arg0: !fir.len)
// CHECK-LABEL: foo0
// CHECK-SAME: i64