[PATCH] D113660: [Flang] Add type conversion for FIR integer kind
Kiran Chandramohan via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Nov 11 03:10:55 PST 2021
kiranchandramohan created this revision.
kiranchandramohan added reviewers: clementval, awarzynski, rovka, jeanPerier, schweitz, svedanayagam, AlexisPerry, pmccormick.
Herald added a subscriber: mehdi_amini.
Herald added a project: Flang.
kiranchandramohan requested review of this revision.
Herald added subscribers: llvm-commits, jdoerfert.
Herald added a project: LLVM.
Convert fir.int<kind> to their llvm equivalent type
This patch is part of the upstreaming effort from fir-dev branch.
Co-authored-by: Eric Schweitz <eschweitz at nvidia.com>
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D113660
Files:
flang/lib/Optimizer/CodeGen/TypeConverter.h
flang/test/Fir/types-to-llvm.fir
Index: flang/test/Fir/types-to-llvm.fir
===================================================================
--- flang/test/Fir/types-to-llvm.fir
+++ flang/test/Fir/types-to-llvm.fir
@@ -82,6 +82,30 @@
// -----
+// 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>)
Index: flang/lib/Optimizer/CodeGen/TypeConverter.h
===================================================================
--- flang/lib/Optimizer/CodeGen/TypeConverter.h
+++ flang/lib/Optimizer/CodeGen/TypeConverter.h
@@ -52,6 +52,10 @@
addConversion([&](BoxType box) { return convertBoxType(box); });
addConversion(
[&](fir::CharacterType charTy) { return convertCharType(charTy); });
+ 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()));
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D113660.386465.patch
Type: text/x-patch
Size: 1519 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211111/4034055c/attachment.bin>
More information about the llvm-commits
mailing list