[flang-commits] [flang] aa26119 - [Flang] Add type conversion for FIR integer kind
Kiran Chandramohan via flang-commits
flang-commits at lists.llvm.org
Fri Nov 12 02:23:00 PST 2021
Author: Kiran Chandramohan
Date: 2021-11-12T10:15:21Z
New Revision: aa26119b82cdabcba7c215bdd3a224a6ec3eedc0
URL: https://github.com/llvm/llvm-project/commit/aa26119b82cdabcba7c215bdd3a224a6ec3eedc0
DIFF: https://github.com/llvm/llvm-project/commit/aa26119b82cdabcba7c215bdd3a224a6ec3eedc0.diff
LOG: [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 at nvidia.com>
Added:
Modified:
flang/lib/Optimizer/CodeGen/TypeConverter.h
flang/test/Fir/types-to-llvm.fir
Removed:
################################################################################
diff --git a/flang/lib/Optimizer/CodeGen/TypeConverter.h b/flang/lib/Optimizer/CodeGen/TypeConverter.h
index 3c21dfa50443..ec0607fd7381 100644
--- a/flang/lib/Optimizer/CodeGen/TypeConverter.h
+++ b/flang/lib/Optimizer/CodeGen/TypeConverter.h
@@ -57,6 +57,10 @@ class LLVMTypeConverter : public mlir::LLVMTypeConverter {
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()));
diff --git a/flang/test/Fir/types-to-llvm.fir b/flang/test/Fir/types-to-llvm.fir
index 739a36647750..5ab21a408235 100644
--- a/flang/test/Fir/types-to-llvm.fir
+++ b/flang/test/Fir/types-to-llvm.fir
@@ -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>)
More information about the flang-commits
mailing list