[PATCH] D113670: [Flang] Add type conversion for FIR heap type

Kiran Chandramohan via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Nov 12 01:50:57 PST 2021


This revision was automatically updated to reflect the committed changes.
Closed by commit rG2b247941cac6: [Flang] Add type conversion for FIR heap type (authored by kiranchandramohan).

Changed prior to commit:
  https://reviews.llvm.org/D113670?vs=386520&id=386766#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D113670/new/

https://reviews.llvm.org/D113670

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
@@ -28,6 +28,9 @@
 func private @foo1(%arg0: !fir.ref<!fir.array<10xf32>>)
 // CHECK-LABEL: foo1
 // CHECK-SAME: !llvm.ptr<array<10 x f32>>
+func private @foo2(%arg0: !fir.ref<!fir.box<!fir.heap<!fir.type<_QMs1Ta1{x:i32,y:f32}>>>>)
+// CHECK-LABEL: foo2
+// CHECK-SAME: !llvm.ptr<struct<(ptr<struct<"_QMs1Ta1", (i32, f32)>>, i{{.*}}, i{{.*}}, i{{.*}}, i{{.*}}, i{{.*}}, i{{.*}}, ptr<i{{.*}}>, array<1 x i{{.*}}>)>>
 
 // -----
 
@@ -61,6 +64,10 @@
 // CHECK-LABEL: foo3
 // CHECK-SAME: !llvm.ptr<struct<(ptr<struct<"derived", (f32)>>, i{{.*}}, i{{.*}}, i{{.*}}, i{{.*}}, i{{.*}}, i{{.*}}, ptr<i{{.*}}>, array<1 x i{{.*}}>)>>
 
+func private @foo4(%arg0: !fir.box<!fir.heap<!fir.type<_QMs1Ta1{x:i32,y:f32}>>>)
+// CHECK-LABEL: foo4
+// CHECK-SAME: !llvm.ptr<struct<(ptr<struct<"_QMs1Ta1", (i32, f32)>>, i{{.*}}, i{{.*}}, i{{.*}}, i{{.*}}, i{{.*}}, i{{.*}}, ptr<i{{.*}}>, array<1 x i{{.*}}>)>>
+
 // -----
 
 // Test char types `!fir.char<k, n>`
@@ -82,6 +89,45 @@
 
 // -----
 
+// Test `!fir.heap<>` conversion.
+func private @foo0(%arg0: !fir.heap<i32>)
+// CHECK-LABEL: foo0
+// CHECK-SAME: !llvm.ptr<i32>
+
+func private @foo1(%arg0: !fir.heap<!fir.array<4xf32>>)
+// CHECK-LABEL: foo1
+// CHECK-SAME: !llvm.ptr<array<4 x f32>>
+
+func private @foo2(%arg0: !fir.heap<!fir.array<?xf32>>)
+// CHECK-LABEL: foo2
+// CHECK-SAME: !llvm.ptr<f32>
+
+func private @foo3(%arg0: !fir.heap<!fir.char<1,10>>)
+// CHECK-LABEL: foo3
+// CHECK-SAME: !llvm.ptr<array<10 x i8>>
+
+func private @foo4(%arg0: !fir.heap<!fir.char<1,?>>)
+// CHECK-LABEL: foo4
+// CHECK-SAME: !llvm.ptr<i8>
+
+func private @foo5(%arg0: !fir.heap<!fir.array<2xf32>>)
+// CHECK-LABEL: foo5
+// CHECK-SAME: !llvm.ptr<array<2 x f32>>
+
+func private @foo6(%arg0: !fir.heap<!fir.array<?x?xf32>>)
+// CHECK-LABEL: foo6
+// CHECK-SAME: !llvm.ptr<f32>
+
+func private @foo7(%arg0: !fir.heap<!fir.type<ZT>>)
+// CHECK-LABEL: foo7
+// CHECK-SAME: !llvm.ptr<struct<"ZT", ()>>
+
+func private @foo8(%arg0: !fir.heap<!fir.type<_QMalloc_assignTt{i:i32}>>)
+// CHECK-LABEL: foo8
+// CHECK-SAME: !llvm.ptr<struct<"_QMalloc_assignTt", (i32)>>
+
+// -----
+
 // 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
@@ -56,6 +56,7 @@
     });
     addConversion(
         [&](fir::CharacterType charTy) { return convertCharType(charTy); });
+    addConversion([&](HeapType heap) { return convertPointerLike(heap); });
     addConversion([&](fir::LogicalType boolTy) {
       return mlir::IntegerType::get(
           &getContext(), kindMapping.getLogicalBitsize(boolTy.getFKind()));


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D113670.386766.patch
Type: text/x-patch
Size: 2957 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211112/44ec5f91/attachment.bin>


More information about the llvm-commits mailing list