[flang-commits] [flang] deafc6f - [fir] Add !fir.ptr type conversion

Diana Picus via flang-commits flang-commits at lists.llvm.org
Wed Nov 10 04:28:55 PST 2021


Author: Diana Picus
Date: 2021-11-10T12:27:39Z
New Revision: deafc6fc6de6bb0781984c0a0182a7b75c55926e

URL: https://github.com/llvm/llvm-project/commit/deafc6fc6de6bb0781984c0a0182a7b75c55926e
DIFF: https://github.com/llvm/llvm-project/commit/deafc6fc6de6bb0781984c0a0182a7b75c55926e.diff

LOG: [fir] Add !fir.ptr type conversion

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

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

Co-authored-by: Jean Perier <jperier 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 f4d252dfc7eea..2f5eb0603e293 100644
--- a/flang/lib/Optimizer/CodeGen/TypeConverter.h
+++ b/flang/lib/Optimizer/CodeGen/TypeConverter.h
@@ -41,6 +41,8 @@ class LLVMTypeConverter : public mlir::LLVMTypeConverter {
       return mlir::IntegerType::get(
           &getContext(), kindMapping.getLogicalBitsize(boolTy.getFKind()));
     });
+    addConversion(
+        [&](fir::PointerType pointer) { return convertPointerLike(pointer); });
     addConversion(
         [&](fir::RecordType derived) { return convertRecordType(derived); });
     addConversion(

diff  --git a/flang/test/Fir/types-to-llvm.fir b/flang/test/Fir/types-to-llvm.fir
index 3bf56d6893f8b..94b1a0b76ba85 100644
--- a/flang/test/Fir/types-to-llvm.fir
+++ b/flang/test/Fir/types-to-llvm.fir
@@ -31,6 +31,18 @@ func private @foo1(%arg0: !fir.ref<!fir.array<10xf32>>)
 
 // -----
 
+// Test pointer types `!fir.ptr`
+
+func private @foo0(%arg0: !fir.ptr<i32>)
+// CHECK-LABEL: foo0
+// CHECK-SAME: !llvm.ptr<i32>
+
+func private @foo1(%arg0: !fir.ptr<!fir.array<10xf32>>)
+// CHECK-LABEL: foo1
+// CHECK-SAME: !llvm.ptr<array<10 x f32>>
+
+// -----
+
 // Test box types `!fir.box`
 
 func private @foo0(%arg0: !fir.box<!fir.array<?xf32>>)


        


More information about the flang-commits mailing list