[Flang] Add type conversion for FIR integer kind

Convert fir.int<kind> to their llvm equivalent type

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

Reviewed By: clementval, awarzynski

Differential Revision: https://reviews.llvm.org/D113660

Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>
This commit is contained in:
Kiran Chandramohan 2021-11-12 10:10:18 +00:00
parent bb4934601d
commit aa26119b82
2 changed files with 28 additions and 0 deletions

View File

@ -57,6 +57,10 @@ public:
addConversion(
[&](fir::CharacterType charTy) { return convertCharType(charTy); });
addConversion([&](HeapType heap) { return convertPointerLike(heap); });
addConversion([&](fir::IntegerType intTy) {
return mlir::IntegerType::get(
&getContext(), kindMapping.getIntegerBitsize(intTy.getFKind()));
});
addConversion([&](fir::LogicalType boolTy) {
return mlir::IntegerType::get(
&getContext(), kindMapping.getLogicalBitsize(boolTy.getFKind()));

View File

@ -128,6 +128,30 @@ func private @foo8(%arg0: !fir.heap<!fir.type<_QMalloc_assignTt{i:i32}>>)
// -----
// Test `!fir.integer<KIND>` conversion.
func private @foo0(%arg0: !fir.int<1>)
// CHECK-LABEL: foo0
// CHECK-SAME: i8
func private @foo1(%arg0: !fir.int<2>)
// CHECK-LABEL: foo1
// CHECK-SAME: i16
func private @foo2(%arg0: !fir.int<4>)
// CHECK-LABEL: foo2
// CHECK-SAME: i32
func private @foo3(%arg0: !fir.int<8>)
// CHECK-LABEL: foo3
// CHECK-SAME: i64
func private @foo4(%arg0: !fir.int<16>)
// CHECK-LABEL: foo4
// CHECK-SAME: i128
// -----
// Test `!fir.logical<KIND>` conversion.
func private @foo0(%arg0: !fir.logical<1>)