[PATCH] D113669: [fir] Add !fir.field type conversion

Valentin Clement via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 11 06:40:36 PST 2021


This revision was automatically updated to reflect the committed changes.
Closed by commit rGb67be520548e: [fir] Add !fir.field type conversion (authored by clementval).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113669

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
@@ -215,3 +215,11 @@
 func private @foo1(%arg0: !fir.boxchar<2>)
 // CHECK-LABEL: foo1
 // CHECK-SAME: !llvm.struct<(ptr<i16>, i64)>
+
+// -----
+
+// Test `!fir.field` conversion
+
+func private @foo0(%arg0: !fir.field)
+// CHECK-LABEL: foo0
+// CHECK-SAME: i32
Index: flang/lib/Optimizer/CodeGen/TypeConverter.h
===================================================================
--- flang/lib/Optimizer/CodeGen/TypeConverter.h
+++ flang/lib/Optimizer/CodeGen/TypeConverter.h
@@ -64,6 +64,10 @@
         [&](fir::PointerType pointer) { return convertPointerLike(pointer); });
     addConversion(
         [&](fir::RecordType derived) { return convertRecordType(derived); });
+    addConversion([&](fir::FieldType field) {
+      // Convert to i32 because of LLVM GEP indexing restriction.
+      return mlir::IntegerType::get(field.getContext(), 32);
+    });
     addConversion(
         [&](fir::ComplexType cmplx) { return convertComplexType(cmplx); });
     addConversion(


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D113669.386501.patch
Type: text/x-patch
Size: 1161 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211111/ca8e7aa6/attachment.bin>


More information about the llvm-commits mailing list